diff --git a/mk/windoze/Glest.sln b/mk/windoze/Glest.sln index 5223d02e2..2072fcf59 100755 --- a/mk/windoze/Glest.sln +++ b/mk/windoze/Glest.sln @@ -29,6 +29,7 @@ Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 Debug+MT|Win32 = Debug+MT|Win32 + Debug-MT|Win32 = Debug-MT|Win32 No debug|Win32 = No debug|Win32 Release with error catching|Win32 = Release with error catching|Win32 Release|Win32 = Release|Win32 @@ -40,6 +41,8 @@ Global {6B0C65F1-D031-46AF-AC0D-7C38892D2952}.Debug|Win32.Build.0 = Debug|Win32 {6B0C65F1-D031-46AF-AC0D-7C38892D2952}.Debug+MT|Win32.ActiveCfg = Debug|Win32 {6B0C65F1-D031-46AF-AC0D-7C38892D2952}.Debug+MT|Win32.Build.0 = Debug|Win32 + {6B0C65F1-D031-46AF-AC0D-7C38892D2952}.Debug-MT|Win32.ActiveCfg = Debug|Win32 + {6B0C65F1-D031-46AF-AC0D-7C38892D2952}.Debug-MT|Win32.Build.0 = Debug|Win32 {6B0C65F1-D031-46AF-AC0D-7C38892D2952}.No debug|Win32.ActiveCfg = Release|Win32 {6B0C65F1-D031-46AF-AC0D-7C38892D2952}.No debug|Win32.Build.0 = Release|Win32 {6B0C65F1-D031-46AF-AC0D-7C38892D2952}.Release with error catching|Win32.ActiveCfg = Release|Win32 @@ -54,6 +57,8 @@ Global {8DAA0C24-95CD-4F66-B4C5-19ABDD771746}.Debug|Win32.Build.0 = Debug|Win32 {8DAA0C24-95CD-4F66-B4C5-19ABDD771746}.Debug+MT|Win32.ActiveCfg = Debug|Win32 {8DAA0C24-95CD-4F66-B4C5-19ABDD771746}.Debug+MT|Win32.Build.0 = Debug|Win32 + {8DAA0C24-95CD-4F66-B4C5-19ABDD771746}.Debug-MT|Win32.ActiveCfg = Debug|Win32 + {8DAA0C24-95CD-4F66-B4C5-19ABDD771746}.Debug-MT|Win32.Build.0 = Debug|Win32 {8DAA0C24-95CD-4F66-B4C5-19ABDD771746}.No debug|Win32.ActiveCfg = Release|Win32 {8DAA0C24-95CD-4F66-B4C5-19ABDD771746}.No debug|Win32.Build.0 = Release|Win32 {8DAA0C24-95CD-4F66-B4C5-19ABDD771746}.Release with error catching|Win32.ActiveCfg = Release|Win32 @@ -68,6 +73,8 @@ Global {5D09BE33-81EC-450B-8A7B-2E7B941ADC56}.Debug|Win32.Build.0 = Debug|Win32 {5D09BE33-81EC-450B-8A7B-2E7B941ADC56}.Debug+MT|Win32.ActiveCfg = Debug|Win32 {5D09BE33-81EC-450B-8A7B-2E7B941ADC56}.Debug+MT|Win32.Build.0 = Debug|Win32 + {5D09BE33-81EC-450B-8A7B-2E7B941ADC56}.Debug-MT|Win32.ActiveCfg = Debug|Win32 + {5D09BE33-81EC-450B-8A7B-2E7B941ADC56}.Debug-MT|Win32.Build.0 = Debug|Win32 {5D09BE33-81EC-450B-8A7B-2E7B941ADC56}.No debug|Win32.ActiveCfg = Release|Win32 {5D09BE33-81EC-450B-8A7B-2E7B941ADC56}.No debug|Win32.Build.0 = Release|Win32 {5D09BE33-81EC-450B-8A7B-2E7B941ADC56}.Release with error catching|Win32.ActiveCfg = Release|Win32 @@ -82,6 +89,8 @@ Global {FE5C7C7C-F109-44F5-8329-25A4E24F162C}.Debug|Win32.Build.0 = Debug|Win32 {FE5C7C7C-F109-44F5-8329-25A4E24F162C}.Debug+MT|Win32.ActiveCfg = Debug|Win32 {FE5C7C7C-F109-44F5-8329-25A4E24F162C}.Debug+MT|Win32.Build.0 = Debug|Win32 + {FE5C7C7C-F109-44F5-8329-25A4E24F162C}.Debug-MT|Win32.ActiveCfg = Debug|Win32 + {FE5C7C7C-F109-44F5-8329-25A4E24F162C}.Debug-MT|Win32.Build.0 = Debug|Win32 {FE5C7C7C-F109-44F5-8329-25A4E24F162C}.No debug|Win32.ActiveCfg = Release|Win32 {FE5C7C7C-F109-44F5-8329-25A4E24F162C}.No debug|Win32.Build.0 = Release|Win32 {FE5C7C7C-F109-44F5-8329-25A4E24F162C}.Release with error catching|Win32.ActiveCfg = Release|Win32 @@ -96,6 +105,8 @@ Global {FE5C7C7C-F109-44F5-8329-19A4E24F162D}.Debug|Win32.Build.0 = Debug|Win32 {FE5C7C7C-F109-44F5-8329-19A4E24F162D}.Debug+MT|Win32.ActiveCfg = Debug|Win32 {FE5C7C7C-F109-44F5-8329-19A4E24F162D}.Debug+MT|Win32.Build.0 = Debug|Win32 + {FE5C7C7C-F109-44F5-8329-19A4E24F162D}.Debug-MT|Win32.ActiveCfg = Debug|Win32 + {FE5C7C7C-F109-44F5-8329-19A4E24F162D}.Debug-MT|Win32.Build.0 = Debug|Win32 {FE5C7C7C-F109-44F5-8329-19A4E24F162D}.No debug|Win32.ActiveCfg = Release|Win32 {FE5C7C7C-F109-44F5-8329-19A4E24F162D}.No debug|Win32.Build.0 = Release|Win32 {FE5C7C7C-F109-44F5-8329-19A4E24F162D}.Release with error catching|Win32.ActiveCfg = Release|Win32 @@ -110,6 +121,8 @@ Global {CDF4DDB9-945E-4D0D-9F0E-2BBEB5D22141}.Debug|Win32.Build.0 = Debug|Win32 {CDF4DDB9-945E-4D0D-9F0E-2BBEB5D22141}.Debug+MT|Win32.ActiveCfg = Debug|Win32 {CDF4DDB9-945E-4D0D-9F0E-2BBEB5D22141}.Debug+MT|Win32.Build.0 = Debug|Win32 + {CDF4DDB9-945E-4D0D-9F0E-2BBEB5D22141}.Debug-MT|Win32.ActiveCfg = Debug-MT|Win32 + {CDF4DDB9-945E-4D0D-9F0E-2BBEB5D22141}.Debug-MT|Win32.Build.0 = Debug-MT|Win32 {CDF4DDB9-945E-4D0D-9F0E-2BBEB5D22141}.No debug|Win32.ActiveCfg = Release|Win32 {CDF4DDB9-945E-4D0D-9F0E-2BBEB5D22141}.No debug|Win32.Build.0 = Release|Win32 {CDF4DDB9-945E-4D0D-9F0E-2BBEB5D22141}.Release with error catching|Win32.ActiveCfg = Release|Win32 diff --git a/mk/windoze/Glest.suo b/mk/windoze/Glest.suo index eeb2666bc..c19b4b8b0 100755 Binary files a/mk/windoze/Glest.suo and b/mk/windoze/Glest.suo differ diff --git a/mk/windoze/g3d_viewer.vcproj b/mk/windoze/g3d_viewer.vcproj index 3e5be7158..461a3fecc 100755 --- a/mk/windoze/g3d_viewer.vcproj +++ b/mk/windoze/g3d_viewer.vcproj @@ -116,6 +116,7 @@ /> @@ -107,6 +107,79 @@ /> + + + + + + + + + + + + + + + + + + + diff --git a/source/shared_lib/include/util/util.h b/source/shared_lib/include/util/util.h index 87e932aca..656ba44f3 100644 --- a/source/shared_lib/include/util/util.h +++ b/source/shared_lib/include/util/util.h @@ -15,10 +15,10 @@ #include #include #include -//#include "thread.h" +#include "thread.h" using std::string; -//using namespace Shared::Platform; +using namespace Shared::Platform; namespace Shared{ namespace Util{ @@ -45,7 +45,7 @@ public: this->fileStream = NULL; this->debugLogFileName = ""; this->fileStreamOwner = false; - //this->mutex = NULL; + this->mutex = NULL; } SystemFlagsType(DebugType debugType) { this->debugType = debugType; @@ -53,8 +53,11 @@ public: this->fileStream = NULL; this->debugLogFileName = ""; this->fileStreamOwner = false; - //this->mutex = NULL; + this->mutex = NULL; } + ~SystemFlagsType() { + Close(); + } SystemFlagsType(DebugType debugType,bool enabled, std::ofstream *fileStream,std::string debugLogFileName) { this->debugType = debugType; @@ -62,14 +65,28 @@ public: this->fileStream = fileStream; this->debugLogFileName = debugLogFileName; this->fileStreamOwner = false; - //this->mutex = mutex; + this->mutex = NULL; } + void Close() { + if(this->fileStreamOwner == true) { + if( this->fileStream != NULL && + this->fileStream->is_open() == true) { + this->fileStream->close(); + } + delete this->fileStream; + delete this->mutex; + } + this->fileStream = NULL; + this->fileStreamOwner = false; + this->mutex = NULL; + } + bool enabled; std::ofstream *fileStream; std::string debugLogFileName; bool fileStreamOwner; - //Mutex *mutex; + Mutex *mutex; }; protected: diff --git a/source/shared_lib/sources/util/util.cpp b/source/shared_lib/sources/util/util.cpp index 28bc15f21..c05e6f638 100644 --- a/source/shared_lib/sources/util/util.cpp +++ b/source/shared_lib/sources/util/util.cpp @@ -40,10 +40,12 @@ namespace Shared{ namespace Util{ std::map SystemFlags::debugLogFileList; void SystemFlags::init() { - SystemFlags::debugLogFileList[SystemFlags::debugSystem] = SystemFlags::SystemFlagsType(SystemFlags::debugSystem); - SystemFlags::debugLogFileList[SystemFlags::debugNetwork] = SystemFlags::SystemFlagsType(SystemFlags::debugNetwork); - SystemFlags::debugLogFileList[SystemFlags::debugPerformance] = SystemFlags::SystemFlagsType(SystemFlags::debugPerformance); - SystemFlags::debugLogFileList[SystemFlags::debugWorldSynch] = SystemFlags::SystemFlagsType(SystemFlags::debugWorldSynch); + if(SystemFlags::debugLogFileList.size() == 0) { + SystemFlags::debugLogFileList[SystemFlags::debugSystem] = SystemFlags::SystemFlagsType(SystemFlags::debugSystem); + SystemFlags::debugLogFileList[SystemFlags::debugNetwork] = SystemFlags::SystemFlagsType(SystemFlags::debugNetwork); + SystemFlags::debugLogFileList[SystemFlags::debugPerformance] = SystemFlags::SystemFlagsType(SystemFlags::debugPerformance); + SystemFlags::debugLogFileList[SystemFlags::debugWorldSynch] = SystemFlags::SystemFlagsType(SystemFlags::debugWorldSynch); + } } int SystemFlags::lockFile = -1; @@ -74,23 +76,13 @@ SystemFlags::~SystemFlags() { void SystemFlags::Close() { printf("START Closing logfiles\n"); - for(std::map::iterator iterMap = SystemFlags::debugLogFileList.begin(); - iterMap != SystemFlags::debugLogFileList.end(); iterMap++) { - SystemFlags::SystemFlagsType ¤tDebugLog = iterMap->second; - - if(currentDebugLog.fileStreamOwner == true) { - if( currentDebugLog.fileStream != NULL && - currentDebugLog.fileStream->is_open() == true) { - currentDebugLog.fileStream->close(); - } - delete currentDebugLog.fileStream; - //delete currentDebugLog.mutex; + if(SystemFlags::debugLogFileList.size() > 0) { + for(std::map::iterator iterMap = SystemFlags::debugLogFileList.begin(); + iterMap != SystemFlags::debugLogFileList.end(); iterMap++) { + SystemFlags::SystemFlagsType ¤tDebugLog = iterMap->second; + currentDebugLog.Close(); } - currentDebugLog.fileStream = NULL; - currentDebugLog.fileStreamOwner = false; - //currentDebugLog.mutex = NULL; } - if(SystemFlags::lockFile != -1) { #ifndef WIN32 close(SystemFlags::lockFile); @@ -109,6 +101,9 @@ void SystemFlags::Close() { } void SystemFlags::OutputDebug(DebugType type, const char *fmt, ...) { + if(SystemFlags::debugLogFileList.size() == 0) { + SystemFlags::init(); + } SystemFlags::SystemFlagsType ¤tDebugLog = SystemFlags::debugLogFileList[type]; if(currentDebugLog.enabled == false) { return; @@ -143,7 +138,7 @@ void SystemFlags::OutputDebug(DebugType type, const char *fmt, ...) { currentDebugLog2.fileStream != NULL) { currentDebugLog.fileStream = currentDebugLog2.fileStream; currentDebugLog.fileStreamOwner = false; - //currentDebugLog.mutex = currentDebugLog2.mutex; + currentDebugLog.mutex = currentDebugLog2.mutex; break; } } @@ -189,17 +184,17 @@ void SystemFlags::OutputDebug(DebugType type, const char *fmt, ...) { currentDebugLog.fileStream = new std::ofstream(); currentDebugLog.fileStream->open(debugLog.c_str(), ios_base::out | ios_base::trunc); currentDebugLog.fileStreamOwner = true; - //currentDebugLog.mutex = new Mutex(); + currentDebugLog.mutex = new Mutex(); } printf("Opening logfile [%s] type = %d, currentDebugLog.fileStreamOwner = %d\n",debugLog.c_str(),type, currentDebugLog.fileStreamOwner); - //currentDebugLog.mutex->p(); + currentDebugLog.mutex->p(); (*currentDebugLog.fileStream) << "Starting Mega-Glest logging for type: " << type << "\n"; (*currentDebugLog.fileStream).flush(); - //currentDebugLog.mutex->v(); + currentDebugLog.mutex->v(); } //printf("Logfile is open [%s]\n",SystemFlags::debugLogFile); @@ -208,12 +203,12 @@ void SystemFlags::OutputDebug(DebugType type, const char *fmt, ...) { assert(currentDebugLog.fileStream != NULL); - //currentDebugLog.mutex->p(); + currentDebugLog.mutex->p(); (*currentDebugLog.fileStream) << "[" << szBuf2 << "] " << szBuf; (*currentDebugLog.fileStream).flush(); - //currentDebugLog.mutex->v(); + currentDebugLog.mutex->v(); } // output to console else {