diff --git a/BBGE/Base.h b/BBGE/Base.h index e6a0516..a0b7f31 100644 --- a/BBGE/Base.h +++ b/BBGE/Base.h @@ -152,34 +152,6 @@ enum Direction DIR_MAX = 8 }; -#ifdef _DEBUG - -#ifndef _DBG_NEW - - #include - - inline void* __operator_new(size_t __n) { - return ::operator new(__n,_NORMAL_BLOCK,__FILE__,__LINE__); - } - inline void* _cdecl operator new(size_t __n,const char* __fname,int __line) { - return ::operator new(__n,_NORMAL_BLOCK,__fname,__line); - } - inline void _cdecl operator delete(void* __p,const char*,int) { - ::operator delete(__p); - } - - #define _DBG_NEW new(__FILE__,__LINE__) - #define new _DBG_NEW - - - //#endif // _DBG_NEW -#else - - #define __operator_new(__n) operator new(__n) - -#endif -#endif - #include "Event.h" #include "Vector.h" diff --git a/BBGE/Core.cpp b/BBGE/Core.cpp index 3cc12af..35cafa3 100644 --- a/BBGE/Core.cpp +++ b/BBGE/Core.cpp @@ -24,6 +24,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Particles.h" #include +#include #ifdef BBGE_BUILD_UNIX #include @@ -852,15 +853,19 @@ void Core::debugLog(const std::string &s) { if (debugLogActive) { - static std::ofstream out((debugLogPath + "debug.log").c_str()); - out << s << std::endl; + _logOut << s << std::endl; } +#ifdef _DEBUG + std::cout << s << std::endl; +#endif } const float SORT_DELAY = 10; Core::Core(const std::string &filesystem, int numRenderLayers, const std::string &appName, int particleSize, std::string userDataSubFolder) : ActionMapper(), StateManager(), appName(appName) { + _logOut.open((debugLogPath + "debug.log").c_str()); + sound = NULL; screenCapScale = Vector(1,1,1); timeUpdateType = TIMEUPDATE_DYNAMIC; @@ -1153,6 +1158,8 @@ Core::~Core() delete sound; sound = 0; } + debugLog("~Core()"); + _logOut.close(); core = 0; } @@ -4201,17 +4208,7 @@ void Core::instantQuit() bool Core::exists(const std::string &filename) { - if (filename.empty()) return false; - FILE *file; - file=fopen(adjustFilenameCase(filename).c_str(),"r"); - - if (file) - { - fclose(file); - return true; - } - else - return false; + return ::exists(filename, false); // defined in Base.cpp } Resource* Core::findResource(const std::string &name) diff --git a/BBGE/Core.h b/BBGE/Core.h index 608612a..6c7495e 100644 --- a/BBGE/Core.h +++ b/BBGE/Core.h @@ -1382,6 +1382,8 @@ protected: __int64 lastTime, curTime, freq; #endif + std::ofstream _logOut; + #ifdef BBGE_BUILD_SDL int nowTicks, thenTicks; #endif diff --git a/CMakeLists.txt b/CMakeLists.txt index 9eba0b7..f814e17 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -203,6 +203,11 @@ ADD_DEFINITIONS(-DAQUARIA_FULL=1) ADD_DEFINITIONS(-DAQUARIA_BUILD_CONSOLE=1) ADD_DEFINITIONS(-DAQUARIA_BUILD_SCENEEDITOR=1) +IF(CMAKE_BUILD_TYPE STREQUAL "Debug") + ADD_DEFINITIONS(-D_DEBUG) # MSVC defines this in debug mode by default, gcc/mingw do not + message(STATUS "This is a debug build.") +ENDIF(CMAKE_BUILD_TYPE STREQUAL "Debug") + IF(UNIX) ADD_DEFINITIONS(-DBBGE_BUILD_UNIX=1) ENDIF(UNIX)