1
0
Fork 0
mirror of https://github.com/AquariaOSE/Aquaria.git synced 2025-01-24 17:26:41 +00:00

log to console in debug mode; close log properly; really #define _DEBUG for gcc debug builds + gcc _DEBUG compatibility

This commit is contained in:
fgenesis 2011-08-11 02:26:46 +02:00
parent 7f9af044d7
commit 2e4e2941db
4 changed files with 17 additions and 41 deletions

View file

@ -152,34 +152,6 @@ enum Direction
DIR_MAX = 8
};
#ifdef _DEBUG
#ifndef _DBG_NEW
#include <crtdbg.h>
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"

View file

@ -24,6 +24,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "Particles.h"
#include <time.h>
#include <iostream>
#ifdef BBGE_BUILD_UNIX
#include <limits.h>
@ -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)

View file

@ -1382,6 +1382,8 @@ protected:
__int64 lastTime, curTime, freq;
#endif
std::ofstream _logOut;
#ifdef BBGE_BUILD_SDL
int nowTicks, thenTicks;
#endif

View file

@ -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)