| OLD | NEW |
| 1 #include <fstream> | 1 #include <fstream> |
| 2 #include <stdio.h> | 2 #include <stdio.h> |
| 3 #include <sstream> | 3 #include <sstream> |
| 4 #include <Windows.h> | 4 #include <Windows.h> |
| 5 | 5 |
| 6 #include "../shared/Utils.h" | 6 #include "../shared/Utils.h" |
| 7 | 7 |
| 8 #include "Debug.h" | 8 #include "Debug.h" |
| 9 | 9 |
| 10 #ifdef _DEBUG | 10 #ifdef _DEBUG |
| 11 | 11 |
| 12 namespace | 12 CriticalSection debugLock; |
| 13 { | |
| 14 class CriticalSection | |
| 15 { | |
| 16 public: | |
| 17 CriticalSection() | |
| 18 { | |
| 19 InitializeCriticalSection(§ion); | |
| 20 } | |
| 21 | |
| 22 ~CriticalSection() | |
| 23 { | |
| 24 DeleteCriticalSection(§ion); | |
| 25 } | |
| 26 | |
| 27 class Lock | |
| 28 { | |
| 29 public: | |
| 30 Lock(CriticalSection& cs) | |
| 31 : section(&cs.section) | |
| 32 { | |
| 33 EnterCriticalSection(section); | |
| 34 } | |
| 35 | |
| 36 ~Lock() | |
| 37 { | |
| 38 LeaveCriticalSection(section); | |
| 39 } | |
| 40 private: | |
| 41 LPCRITICAL_SECTION section; | |
| 42 Lock(const Lock&); | |
| 43 Lock& operator=(const Lock&); | |
| 44 }; | |
| 45 private: | |
| 46 CRITICAL_SECTION section; | |
| 47 CriticalSection(const CriticalSection&); | |
| 48 CriticalSection& operator=(const CriticalSection&); | |
| 49 }; | |
| 50 | |
| 51 CriticalSection debugLock; | |
| 52 } | |
| 53 | 13 |
| 54 void Debug(const std::string& text) | 14 void Debug(const std::string& text) |
| 55 { | 15 { |
| 56 SYSTEMTIME st; | 16 SYSTEMTIME st; |
| 57 ::GetSystemTime(&st); | 17 ::GetSystemTime(&st); |
| 58 | 18 |
| 59 char timeBuf[14]; | 19 char timeBuf[14]; |
| 60 _snprintf_s(timeBuf, _TRUNCATE, "%02i:%02i:%02i.%03i", st.wHour, st.wMinute, s
t.wSecond, st.wMilliseconds); | 20 _snprintf_s(timeBuf, _TRUNCATE, "%02i:%02i:%02i.%03i", st.wHour, st.wMinute, s
t.wSecond, st.wMilliseconds); |
| 61 | 21 |
| 62 std::wstring filePath = GetAppDataPath() + L"\\debug_engine.txt"; | 22 std::wstring filePath = GetAppDataPath() + L"\\debug_engine.txt"; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 76 | 36 |
| 77 void DebugException(const std::exception& exception) | 37 void DebugException(const std::exception& exception) |
| 78 { | 38 { |
| 79 Debug(std::string("An exception occurred: ") + exception.what()); | 39 Debug(std::string("An exception occurred: ") + exception.what()); |
| 80 } | 40 } |
| 81 #else | 41 #else |
| 82 void Debug(const std::string& text) {} | 42 void Debug(const std::string& text) {} |
| 83 void DebugLastError(const std::string& message) {} | 43 void DebugLastError(const std::string& message) {} |
| 84 void DebugException(const std::exception& exception) {} | 44 void DebugException(const std::exception& exception) {} |
| 85 #endif // _DEBUG | 45 #endif // _DEBUG |
| OLD | NEW |