diff -rupN megaglest-source-3.3.7.2.old/glest_game/ai/ai_interface.h megaglest-source-3.3.7.2/glest_game/ai/ai_interface.h --- megaglest-source-3.3.7.2.old/glest_game/ai/ai_interface.h 2010-10-01 19:59:13.000000000 -0500 +++ megaglest-source-3.3.7.2/glest_game/ai/ai_interface.h 2010-11-27 13:10:08.000000000 -0500 @@ -89,7 +89,11 @@ public: bool isFreeCells(const Vec2i &pos, int size, Field field); private: - string getLogFilename() const {return "ai"+intToStr(factionIndex)+".log";} + string getLogFilename() const { + string logfn=getenv("HOME"); + logfn+="/.glest/ai"+intToStr(factionIndex)+".log"; + return logfn; + } bool executeCommandOverNetwork(); }; diff -rupN megaglest-source-3.3.7.2.old/glest_game/game/game.cpp megaglest-source-3.3.7.2/glest_game/game/game.cpp --- megaglest-source-3.3.7.2.old/glest_game/game/game.cpp 2010-10-06 13:00:02.000000000 -0500 +++ megaglest-source-3.3.7.2/glest_game/game/game.cpp 2010-11-27 13:13:37.000000000 -0500 @@ -1124,7 +1124,8 @@ void Game::keyDown(char key) { if(isdir(path.c_str()) == true) { for(int i=0; i<100; ++i){ path = GameConstants::folder_path_screenshots; - path += "screen" + intToStr(i) + ".tga"; + string path=getenv("HOME"); + path+="/.glest/screen" + intToStr(i) + ".tga"; FILE *f= fopen(path.c_str(), "rb"); if(f==NULL) { Renderer::getInstance().saveScreen(path); diff -rupN megaglest-source-3.3.7.2.old/glest_game/main/main.cpp megaglest-source-3.3.7.2/glest_game/main/main.cpp --- megaglest-source-3.3.7.2.old/glest_game/main/main.cpp 2010-10-09 15:33:12.000000000 -0500 +++ megaglest-source-3.3.7.2/glest_game/main/main.cpp 2010-11-27 14:10:26.763167355 -0500 @@ -465,8 +465,8 @@ bool hasCommandArgument(int argc, char** return result; } -void print_SDL_version(const char *preamble, SDL_version *v) { - printf("%s %u.%u.%u\n", preamble, v->major, v->minor, v->patch); +void print_SDL_version(const char *preamble, SDL_version *v) { + printf("%s %u.%u.%u\n", preamble, v->major, v->minor, v->patch); } void printParameterHelp(const char *argv0, bool foundInvalidArgs) { if(foundInvalidArgs == true) { @@ -497,7 +497,17 @@ void printParameterHelp(const char *argv printf("\n\n"); } int glestMain(int argc, char** argv){ + if (!getenv("HOME")) + throw runtime_error("HOME external variable is not set"); + char path[PATH_MAX]; + snprintf(path, PATH_MAX, "%s/.glest", getenv("HOME")); + mkdir(path, 0750); + + snprintf(path, PATH_MAX, "%s/.glest/screens", getenv("HOME")); + mkdir(path, 0750); + + chdir("@GENTOO_DATADIR@"); #ifdef SL_LEAK_DUMP AllocRegistry memoryLeaks = AllocRegistry::getInstance(); #endif @@ -540,14 +550,14 @@ int glestMain(int argc, char** argv){ } if(hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_SDL_INFO]) == true) { - SDL_version ver; - - // Prints the compile time version + SDL_version ver; + + // Prints the compile time version SDL_VERSION(&ver); - print_SDL_version("SDL compile-time version", &ver); - - // Prints the run-time version - ver = *SDL_Linked_Version(); + print_SDL_version("SDL compile-time version", &ver); + + // Prints the run-time version + ver = *SDL_Linked_Version(); print_SDL_version("SDL runtime version", &ver); } diff -rupN megaglest-source-3.3.7.2.old/glest_game/main/program.cpp megaglest-source-3.3.7.2/glest_game/main/program.cpp --- megaglest-source-3.3.7.2.old/glest_game/main/program.cpp 2010-10-06 13:00:47.000000000 -0500 +++ megaglest-source-3.3.7.2/glest_game/main/program.cpp 2010-11-27 15:21:03.671949728 -0500 @@ -491,7 +491,9 @@ void Program::init(WindowGl *window, boo //log start Logger &logger= Logger::getInstance(); - string logFile = "glest.log"; + string a=getenv("HOME"); + string b= "/.glest/glest.log"; + string logFile = a+b; if(getGameReadWritePath() != "") { logFile = getGameReadWritePath() + logFile; } diff -rupN megaglest-source-3.3.7.2.old/shared_lib/sources/util/leak_dumper.cpp megaglest-source-3.3.7.2/shared_lib/sources/util/leak_dumper.cpp --- megaglest-source-3.3.7.2.old/shared_lib/sources/util/leak_dumper.cpp 2010-09-08 17:37:30.000000000 -0500 +++ megaglest-source-3.3.7.2/shared_lib/sources/util/leak_dumper.cpp 2010-11-27 13:28:57.000000000 -0500 @@ -43,7 +43,9 @@ AllocRegistry &AllocRegistry::getInstanc AllocRegistry::~AllocRegistry(){ - dump("leak_dump.log"); + char path[PATH_MAX]; + snprintf(path, PATH_MAX, "%s/.glest/leak_dump.log", getenv("HOME")); + dump(path); } void AllocRegistry::allocate(AllocInfo info){ diff -rupN megaglest-source-3.3.7.2.old/shared_lib/sources/util/profiler.cpp megaglest-source-3.3.7.2/shared_lib/sources/util/profiler.cpp --- megaglest-source-3.3.7.2.old/shared_lib/sources/util/profiler.cpp 2010-03-27 13:37:52.000000000 -0500 +++ megaglest-source-3.3.7.2/shared_lib/sources/util/profiler.cpp 2010-11-27 13:30:42.000000000 -0500 @@ -76,9 +76,11 @@ Profiler::~Profiler(){ if(getGameReadWritePath() != "") { profileLog = getGameReadWritePath() + profileLog; } - FILE *f= fopen(profileLog.c_str(), "w"); + char path[PATH_MAX]; + snprintf(path, PATH_MAX, "%s/.glest/profiler.log", getenv("HOME")); + FILE *f= fopen(path, "w"); if(f==NULL) - throw runtime_error("Can not open file: " + profileLog); + throw runtime_error("Can not open file: %s",path); fprintf(f, "Profiler Results\n\n"); diff -rupN megaglest-source-3.3.7.2.old/shared_lib/sources/util/properties.cpp megaglest-source-3.3.7.2/shared_lib/sources/util/properties.cpp --- megaglest-source-3.3.7.2.old/shared_lib/sources/util/properties.cpp 2010-10-06 13:51:41.000000000 -0500 +++ megaglest-source-3.3.7.2/shared_lib/sources/util/properties.cpp 2010-11-27 13:27:12.000000000 -0500 @@ -14,7 +14,8 @@ #include #include #include - +#include +#include #include "conversion.h" #include "util.h" #include "leak_dumper.h" @@ -38,10 +39,15 @@ void Properties::load(const string &path //SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] path = [%s]\n",__FILE__,__FUNCTION__,__LINE__,path.c_str()); - fileStream.open(path.c_str(), ios_base::in); + char str[PATH_MAX]; + snprintf(str, PATH_MAX, "%s/.glest/%s", getenv("HOME"), path.c_str()); + fileStream.open(str, ios_base::in); if(fileStream.fail()){ - SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] path = [%s]\n",__FILE__,__FUNCTION__,__LINE__,path.c_str()); - throw runtime_error("Can't open propertyMap file: " + path); + fileStream.open(path.c_str(), ios_base::in); // use defaults + if(fileStream.fail()){ + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] path = [%s]\n",__FILE__,__FUNCTION__,__LINE__,path.c_str()); + throw runtime_error("Can't open propertyMap file: " + path + " cwd: "+ getenv("PWD")); + } } //SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] path = [%s]\n",__FILE__,__FUNCTION__,__LINE__,path.c_str()); @@ -78,7 +84,9 @@ void Properties::load(const string &path void Properties::save(const string &path){ ofstream fileStream; - fileStream.open(path.c_str(), ios_base::out | ios_base::trunc); + char str[PATH_MAX]; + snprintf(str, PATH_MAX, "%s/.glest/%s", getenv("HOME"), path.c_str()); + fileStream.open(str, ios_base::out | ios_base::trunc); fileStream << "; === propertyMap File === \n"; fileStream << '\n';