- bugfixes so that the mingw compile builds
This commit is contained in:
parent
1f1c0f34a3
commit
e221011af2
|
@ -60,7 +60,7 @@ IF(CMAKE_COMPILER_IS_GNUCXX OR MINGW)
|
|||
# For tons of verbose warnings add: -Wall
|
||||
ADD_DEFINITIONS("-Wreturn-type -fno-strict-aliasing -frounding-math -fsignaling-nans -mfpmath=sse -msse -rdynamic")
|
||||
ELSE()
|
||||
ADD_DEFINITIONS("-Wreturn-type -fno-strict-aliasing -frounding-math -fsignaling-nans -mfpmath=sse -msse")
|
||||
ADD_DEFINITIONS("-Wreturn-type -fno-strict-aliasing -frounding-math -fsignaling-nans -mfpmath=sse -msse -DUNICODE")
|
||||
ENDIF()
|
||||
#SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
|
||||
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
#!/bin/bash
|
||||
|
||||
NUMCORES=`cat /proc/cpuinfo | grep -cE '^processor'`
|
||||
|
||||
mkdir -p build
|
||||
cd build
|
||||
|
||||
[[ -f "CMakeCache.txt" ]] && rm -f "CMakeCache.txt"
|
||||
# This is for regular developers and used by our installer
|
||||
cmake -DCMAKE_INSTALL_PREFIX= -DWANT_STATIC_LIBS=ON ..
|
||||
make
|
||||
make -j$NUMCORES
|
||||
|
||||
cd ..
|
||||
echo 'You may now launch MegaGlest from this directory like this:'
|
||||
|
|
|
@ -64,7 +64,7 @@ SET(GLEST_LIB_INCLUDE_ROOT "../shared_lib/include/")
|
|||
|
||||
SET(GLEST_LIB_INCLUDE_DIRS
|
||||
${GLEST_LIB_INCLUDE_ROOT}platform/common
|
||||
${GLEST_LIB_INCLUDE_ROOT}platform/sdl
|
||||
# ${GLEST_LIB_INCLUDE_ROOT}platform/sdl
|
||||
${GLEST_LIB_INCLUDE_ROOT}platform/posix
|
||||
${GLEST_LIB_INCLUDE_ROOT}util
|
||||
${GLEST_LIB_INCLUDE_ROOT}graphics
|
||||
|
@ -79,6 +79,13 @@ SET(GLEST_LIB_INCLUDE_DIRS
|
|||
)
|
||||
INCLUDE_DIRECTORIES( ${GLEST_LIB_INCLUDE_DIRS} )
|
||||
|
||||
IF(WIN32)
|
||||
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/source/shared_lib/include/platform/win32)
|
||||
INCLUDE_DIRECTORIES( ${GLEST_LIB_INCLUDE_ROOT}platform/sdl )
|
||||
ELSE()
|
||||
INCLUDE_DIRECTORIES( ${GLEST_LIB_INCLUDE_ROOT}platform/sdl )
|
||||
ENDIF()
|
||||
|
||||
SET(MG_SOURCE_FILES "../glest_game/global/config.cpp")
|
||||
|
||||
FOREACH(DIR IN LISTS DIRS_WITH_SRC)
|
||||
|
|
|
@ -64,7 +64,7 @@ SET(GLEST_LIB_INCLUDE_ROOT "../shared_lib/include/")
|
|||
|
||||
SET(GLEST_LIB_INCLUDE_DIRS
|
||||
${GLEST_LIB_INCLUDE_ROOT}platform/common
|
||||
${GLEST_LIB_INCLUDE_ROOT}platform/sdl
|
||||
# ${GLEST_LIB_INCLUDE_ROOT}platform/sdl
|
||||
${GLEST_LIB_INCLUDE_ROOT}platform/posix
|
||||
${GLEST_LIB_INCLUDE_ROOT}util
|
||||
${GLEST_LIB_INCLUDE_ROOT}graphics
|
||||
|
@ -81,6 +81,13 @@ SET(GLEST_LIB_INCLUDE_DIRS
|
|||
)
|
||||
INCLUDE_DIRECTORIES( ${GLEST_LIB_INCLUDE_DIRS} )
|
||||
|
||||
IF(WIN32)
|
||||
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/source/shared_lib/include/platform/win32)
|
||||
INCLUDE_DIRECTORIES( ${GLEST_LIB_INCLUDE_ROOT}platform/sdl )
|
||||
ELSE()
|
||||
INCLUDE_DIRECTORIES( ${GLEST_LIB_INCLUDE_ROOT}platform/sdl )
|
||||
ENDIF()
|
||||
|
||||
SET(MG_SOURCE_FILES "../glest_game/graphics/particle_type.cpp" "../glest_game/graphics/unit_particle_type.cpp" "../glest_game/global/config.cpp")
|
||||
|
||||
FOREACH(DIR IN LISTS DIRS_WITH_SRC)
|
||||
|
|
|
@ -114,14 +114,17 @@ SET(GLEST_LIB_INCLUDE_DIRS
|
|||
${GLEST_LIB_INCLUDE_ROOT}streflop/libm_flt32_source
|
||||
${GLEST_LIB_INCLUDE_ROOT}map)
|
||||
INCLUDE_DIRECTORIES( ${GLEST_LIB_INCLUDE_DIRS} )
|
||||
INCLUDE_DIRECTORIES( ${GLEST_LIB_INCLUDE_ROOT}platform/sdl )
|
||||
|
||||
#INCLUDE_DIRECTORIES( ${GLEST_LIB_INCLUDE_ROOT}platform/sdl )
|
||||
|
||||
IF(WIN32)
|
||||
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/source/win32_deps/include)
|
||||
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/source/shared_lib/include/platform/posix)
|
||||
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/source/shared_lib/include/platform/win32)
|
||||
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/source/shared_lib/include/sound/ds8)
|
||||
INCLUDE_DIRECTORIES( ${GLEST_LIB_INCLUDE_ROOT}platform/sdl )
|
||||
ELSE()
|
||||
INCLUDE_DIRECTORIES( ${GLEST_LIB_INCLUDE_ROOT}platform/sdl )
|
||||
SET(GLEST_LIB_INCLUDE_DIRS ${GLEST_LIB_INCLUDE_DIRS} ${GLEST_LIB_INCLUDE_ROOT}platform/sdl)
|
||||
SET(GLEST_LIB_INCLUDE_DIRS ${GLEST_LIB_INCLUDE_DIRS} ${GLEST_LIB_INCLUDE_ROOT}platform/unix)
|
||||
ENDIF()
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "game.h"
|
||||
#include "config.h"
|
||||
#include "network_manager.h"
|
||||
#include "platform_util.h"
|
||||
#include "leak_dumper.h"
|
||||
|
||||
using namespace Shared::Util;
|
||||
|
@ -53,7 +54,7 @@ AiInterface::AiInterface(Game &game, int factionIndex, int teamIndex, int useSta
|
|||
//clear log file
|
||||
if(logLevel>0){
|
||||
#ifdef WIN32
|
||||
FILE *f= _wfopen(utf8_decode(getLogFilename()).c_str(), L"wt");
|
||||
FILE *f= _wfopen(Shared::Platform::utf8_decode(getLogFilename()).c_str(), L"wt");
|
||||
#else
|
||||
FILE *f= fopen(getLogFilename().c_str(), "wt");
|
||||
#endif
|
||||
|
|
|
@ -194,7 +194,7 @@ Config::Config(std::pair<ConfigType,ConfigType> type, std::pair<string,string> f
|
|||
if(fileName.second != "" && fileExists(fileName.second) == false) {
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] attempting to auto-create cfgFile.second = [%s]\n",__FILE__,__FUNCTION__,__LINE__,fileName.second.c_str());
|
||||
|
||||
#ifdef WIN32
|
||||
#if defined(WIN32) && !defined(__MINGW32__)
|
||||
wstring wstr = utf8_decode(fileName.second);
|
||||
FILE *fp = _wfopen(wstr.c_str(), L"w");
|
||||
std::ofstream userFile(fp);
|
||||
|
@ -203,7 +203,7 @@ Config::Config(std::pair<ConfigType,ConfigType> type, std::pair<string,string> f
|
|||
userFile.open(fileName.second.c_str(), ios_base::out | ios_base::trunc);
|
||||
#endif
|
||||
userFile.close();
|
||||
#ifdef WIN32
|
||||
#if defined(WIN32) && !defined(__MINGW32__)
|
||||
if(fp) {
|
||||
fclose(fp);
|
||||
}
|
||||
|
|
|
@ -104,7 +104,7 @@ string MenuStateAbout::loadAdditionalCredits(){
|
|||
string result= "";
|
||||
const string dir= data_path + "data/core/menu/credits.txt";
|
||||
if(fileExists(dir) == true) {
|
||||
#ifdef WIN32
|
||||
#if defined(WIN32) && !defined(__MINGW32__)
|
||||
FILE *fp = _wfopen(utf8_decode(dir).c_str(), L"r");
|
||||
ifstream file(fp);
|
||||
#else
|
||||
|
@ -117,7 +117,7 @@ string MenuStateAbout::loadAdditionalCredits(){
|
|||
}
|
||||
std::cout << buffer << std::endl;
|
||||
file.close();
|
||||
#ifdef WIN32
|
||||
#if defined(WIN32) && !defined(__MINGW32__)
|
||||
fclose(fp);
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -2373,7 +2373,7 @@ void MenuStateCustomGame::saveGameSettingsToFile(std::string fileName) {
|
|||
GameSettings gameSettings;
|
||||
loadGameSettings(&gameSettings);
|
||||
|
||||
#ifdef WIN32
|
||||
#if defined(WIN32) && !defined(__MINGW32__)
|
||||
FILE *fp = _wfopen(utf8_decode(fileName).c_str(), L"w");
|
||||
std::ofstream saveGameFile(fp);
|
||||
#else
|
||||
|
@ -2421,7 +2421,7 @@ void MenuStateCustomGame::saveGameSettingsToFile(std::string fileName) {
|
|||
saveGameFile << "FactionPlayerNameForIndex" << slotIndex << "=" << gameSettings.getNetworkPlayerName(i) << std::endl;
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
#if defined(WIN32) && !defined(__MINGW32__)
|
||||
fclose(fp);
|
||||
#endif
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
|
|
@ -1677,7 +1677,7 @@ std::string World::DumpWorldToLog(bool consoleBasicInfoOnly) const {
|
|||
}
|
||||
else {
|
||||
|
||||
#ifdef WIN32
|
||||
#if defined(WIN32) && !defined(__MINGW32__)
|
||||
FILE *fp = _wfopen(utf8_decode(debugWorldLogFile).c_str(), L"w");
|
||||
std::ofstream logFile(fp);
|
||||
#else
|
||||
|
@ -1708,7 +1708,7 @@ std::string World::DumpWorldToLog(bool consoleBasicInfoOnly) const {
|
|||
}
|
||||
|
||||
logFile.close();
|
||||
#ifdef WIN32
|
||||
#if defined(WIN32) && !defined(__MINGW32__)
|
||||
if(fp) {
|
||||
fclose(fp);
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ SET(GLEST_LIB_INCLUDE_ROOT "../shared_lib/include/")
|
|||
|
||||
SET(GLEST_LIB_INCLUDE_DIRS
|
||||
${GLEST_LIB_INCLUDE_ROOT}platform/common
|
||||
${GLEST_LIB_INCLUDE_ROOT}platform/sdl
|
||||
# ${GLEST_LIB_INCLUDE_ROOT}platform/sdl
|
||||
${GLEST_LIB_INCLUDE_ROOT}platform/posix
|
||||
${GLEST_LIB_INCLUDE_ROOT}util
|
||||
${GLEST_LIB_INCLUDE_ROOT}graphics
|
||||
|
@ -78,6 +78,14 @@ SET(GLEST_LIB_INCLUDE_DIRS
|
|||
|
||||
INCLUDE_DIRECTORIES( ${GLEST_LIB_INCLUDE_DIRS} )
|
||||
|
||||
IF(WIN32)
|
||||
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/source/shared_lib/include/platform/win32)
|
||||
INCLUDE_DIRECTORIES( ${GLEST_LIB_INCLUDE_ROOT}platform/sdl )
|
||||
ELSE()
|
||||
INCLUDE_DIRECTORIES( ${GLEST_LIB_INCLUDE_ROOT}platform/sdl )
|
||||
ENDIF()
|
||||
|
||||
|
||||
SET(MG_SOURCE_FILES "../glest_game/global/config.cpp")
|
||||
|
||||
FOREACH(DIR IN LISTS DIRS_WITH_SRC)
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include <stdexcept>
|
||||
#include <typeinfo>
|
||||
#include <vector>
|
||||
#include "conversion.h"
|
||||
#include "leak_dumper.h"
|
||||
|
||||
using std::map;
|
||||
|
@ -29,6 +30,7 @@ using std::vector;
|
|||
using std::ifstream;
|
||||
using std::ios;
|
||||
using std::runtime_error;
|
||||
using namespace Shared::Util;
|
||||
|
||||
using Shared::PlatformCommon::extractExtension;
|
||||
|
||||
|
@ -141,7 +143,7 @@ public:
|
|||
template <typename T>
|
||||
static inline T* readFromFileReaders(vector<FileReader<T> const *>* readers, const string& filepath) {
|
||||
//try to assign file
|
||||
#ifdef WIN32
|
||||
#if defined(WIN32) && !defined(__MINGW32__)
|
||||
FILE *fp = _wfopen(utf8_decode(filepath).c_str(), L"rb");
|
||||
ifstream file(fp);
|
||||
#else
|
||||
|
@ -161,14 +163,14 @@ static inline T* readFromFileReaders(vector<FileReader<T> const *>* readers, con
|
|||
}
|
||||
if (ret != NULL) {
|
||||
file.close();
|
||||
#ifdef WIN32
|
||||
#if defined(WIN32) && !defined(__MINGW32__)
|
||||
fclose(fp);
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
file.close();
|
||||
#ifdef WIN32
|
||||
#if defined(WIN32) && !defined(__MINGW32__)
|
||||
fclose(fp);
|
||||
#endif
|
||||
|
||||
|
@ -178,7 +180,7 @@ static inline T* readFromFileReaders(vector<FileReader<T> const *>* readers, con
|
|||
template <typename T>
|
||||
static inline T* readFromFileReaders(vector<FileReader<T> const *>* readers, const string& filepath, T* object) {
|
||||
//try to assign file
|
||||
#ifdef WIN32
|
||||
#if defined(WIN32) && !defined(__MINGW32__)
|
||||
wstring wstr = utf8_decode(filepath);
|
||||
FILE *fp = _wfopen(wstr.c_str(), L"rb");
|
||||
int fileErrno = errno;
|
||||
|
@ -187,7 +189,7 @@ static inline T* readFromFileReaders(vector<FileReader<T> const *>* readers, con
|
|||
ifstream file(filepath.c_str(), ios::in | ios::binary);
|
||||
#endif
|
||||
if (!file.is_open()) { //An error occured; TODO: Which one - throw an exception, print error message?
|
||||
#ifdef WIN32
|
||||
#if defined(WIN32) && !defined(__MINGW32__)
|
||||
DWORD error = GetLastError();
|
||||
throw runtime_error("Could not open file, result: " + intToStr(error) + " - " + intToStr(fileErrno) + " [" + filepath + "]");
|
||||
#else
|
||||
|
@ -205,14 +207,14 @@ static inline T* readFromFileReaders(vector<FileReader<T> const *>* readers, con
|
|||
}
|
||||
if (ret != NULL) {
|
||||
file.close();
|
||||
#ifdef WIN32
|
||||
#if defined(WIN32) && !defined(__MINGW32__)
|
||||
fclose(fp);
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
file.close();
|
||||
#ifdef WIN32
|
||||
#if defined(WIN32) && !defined(__MINGW32__)
|
||||
fclose(fp);
|
||||
#endif
|
||||
return NULL;
|
||||
|
@ -326,7 +328,7 @@ bool FileReader<T>::canRead(ifstream& file) const {
|
|||
*/
|
||||
template <typename T>
|
||||
T* FileReader<T>::read(const string& filepath) const {
|
||||
#ifdef WIN32
|
||||
#if defined(WIN32) && !defined(__MINGW32__)
|
||||
FILE *fp = _wfopen(utf8_decode(filepath).c_str(), L"rb");
|
||||
ifstream file(fp);
|
||||
#else
|
||||
|
@ -337,7 +339,7 @@ T* FileReader<T>::read(const string& filepath) const {
|
|||
}
|
||||
T* ret = read(file,filepath);
|
||||
file.close();
|
||||
#ifdef WIN32
|
||||
#if defined(WIN32) && !defined(__MINGW32__)
|
||||
fclose(fp);
|
||||
#endif
|
||||
|
||||
|
@ -351,7 +353,7 @@ T* FileReader<T>::read(const string& filepath) const {
|
|||
*/
|
||||
template <typename T>
|
||||
T* FileReader<T>::read(const string& filepath, T* object) const {
|
||||
#ifdef WIN32
|
||||
#if defined(WIN32) && !defined(__MINGW32__)
|
||||
FILE *fp = _wfopen(utf8_decode(filepath).c_str(), L"rb");
|
||||
ifstream file(fp);
|
||||
#else
|
||||
|
@ -362,7 +364,7 @@ T* FileReader<T>::read(const string& filepath, T* object) const {
|
|||
}
|
||||
T* ret = read(file,filepath,object);
|
||||
file.close();
|
||||
#ifdef WIN32
|
||||
#if defined(WIN32) && !defined(__MINGW32__)
|
||||
fclose(fp);
|
||||
#endif
|
||||
|
||||
|
|
|
@ -370,7 +370,11 @@ bool isdir(const char *path)
|
|||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
#if defined(__MINGW32__)
|
||||
struct _stat stats;
|
||||
#else
|
||||
struct _stat64i32 stats;
|
||||
#endif
|
||||
int result = _wstat(utf8_decode(friendly_path).c_str(), &stats);
|
||||
#else
|
||||
struct stat stats;
|
||||
|
@ -1717,7 +1721,11 @@ bool renameFile(string oldFile, string newFile) {
|
|||
|
||||
off_t getFileSize(string filename) {
|
||||
#ifdef WIN32
|
||||
#if defined(__MINGW32__)
|
||||
struct _stat stbuf;
|
||||
#else
|
||||
struct _stat64i32 stbuf;
|
||||
#endif
|
||||
if(_wstat(utf8_decode(filename).c_str(), &stbuf) != -1) {
|
||||
#else
|
||||
struct stat stbuf;
|
||||
|
@ -1873,7 +1881,7 @@ bool searchAndReplaceTextInFile(string fileName, string findText, string replace
|
|||
|
||||
void copyFileTo(string fromFileName, string toFileName) {
|
||||
//Open an input and output stream in binary mode
|
||||
#ifdef WIN32
|
||||
#if defined(WIN32) && !defined(__MINGW32__)
|
||||
FILE *fp1 = _wfopen(utf8_decode(fromFileName).c_str(), L"rb");
|
||||
ifstream in(fp1);
|
||||
FILE *fp2 = _wfopen(utf8_decode(toFileName).c_str(), L"wb");
|
||||
|
@ -1899,7 +1907,7 @@ void copyFileTo(string fromFileName, string toFileName) {
|
|||
in.close();
|
||||
out.close();
|
||||
|
||||
#ifdef WIN32
|
||||
#if defined(WIN32) && !defined(__MINGW32__)
|
||||
if(fp1) {
|
||||
fclose(fp1);
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ void Properties::load(const string &path, bool clearCurrentProperties) {
|
|||
size_t pos=0;
|
||||
this->path= path;
|
||||
|
||||
#ifdef WIN32
|
||||
#if defined(WIN32) && !defined(__MINGW32__)
|
||||
FILE *fp = _wfopen(utf8_decode(path).c_str(), L"r");
|
||||
ifstream fileStream(fp);
|
||||
#else
|
||||
|
@ -110,7 +110,7 @@ void Properties::load(const string &path, bool clearCurrentProperties) {
|
|||
}
|
||||
|
||||
fileStream.close();
|
||||
#ifdef WIN32
|
||||
#if defined(WIN32) && !defined(__MINGW32__)
|
||||
fclose(fp);
|
||||
#endif
|
||||
}
|
||||
|
@ -269,7 +269,7 @@ bool Properties::applyTagsToValue(string &value, std::map<string,string> *mapTag
|
|||
}
|
||||
|
||||
void Properties::save(const string &path){
|
||||
#ifdef WIN32
|
||||
#if defined(WIN32) && !defined(__MINGW32__)
|
||||
FILE *fp = _wfopen(utf8_decode(path).c_str(), L"w");
|
||||
ofstream fileStream(fp);
|
||||
#else
|
||||
|
@ -284,7 +284,7 @@ void Properties::save(const string &path){
|
|||
}
|
||||
|
||||
fileStream.close();
|
||||
#ifdef WIN32
|
||||
#if defined(WIN32) && !defined(__MINGW32__)
|
||||
fclose(fp);
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -513,7 +513,7 @@ void SystemFlags::logDebugEntry(DebugType type, string debugEntry, time_t debugT
|
|||
}
|
||||
|
||||
if(currentDebugLog.fileStream == NULL) {
|
||||
#ifdef WIN32
|
||||
#if defined(WIN32) && !defined(__MINGW32__)
|
||||
currentDebugLog.fileStream = new std::ofstream(_wfopen(utf8_decode(debugLog).c_str(), L"w"));
|
||||
#else
|
||||
currentDebugLog.fileStream = new std::ofstream();
|
||||
|
|
Loading…
Reference in New Issue