diff --git a/source/glest_game/game/game.cpp b/source/glest_game/game/game.cpp index e7ef249ce..c573ea0ce 100644 --- a/source/glest_game/game/game.cpp +++ b/source/glest_game/game/game.cpp @@ -776,6 +776,8 @@ void Game::init(bool initForPreviewOnly) logger.add("Launching game"); } + logger.setCancelLoadingEnabled(false); + if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"================ STARTING GAME ================\n"); if(SystemFlags::getSystemSettingType(SystemFlags::debugPathFinder).enabled) SystemFlags::OutputDebug(SystemFlags::debugPathFinder,"================ STARTING GAME ================\n"); if(SystemFlags::getSystemSettingType(SystemFlags::debugPathFinder).enabled) SystemFlags::OutputDebug(SystemFlags::debugPathFinder,"PathFinderType: %s\n", (getGameSettings()->getPathFinderType() ? "RoutePlanner" : "PathFinder")); diff --git a/source/glest_game/main/main.cpp b/source/glest_game/main/main.cpp index 7aa37dd68..6197abad9 100644 --- a/source/glest_game/main/main.cpp +++ b/source/glest_game/main/main.cpp @@ -41,6 +41,9 @@ // For gcc backtrace on crash! #if defined(__GNUC__) && !defined(__MINGW32__) && !defined(__FreeBSD__) && !defined(BSD) + +//#include + #include #include #include @@ -2253,6 +2256,14 @@ int glestMain(int argc, char** argv) { } int glestMainWrapper(int argc, char** argv) { + +#if defined(__GNUC__) && !defined(__MINGW32__) && !defined(__FreeBSD__) && !defined(BSD) +//#ifdef DEBUG + //printf("MTRACE will be called...\n"); + //mtrace (); +//#endif +#endif + #ifdef WIN32_STACK_TRACE __try { #endif diff --git a/source/glest_game/menu/menu_state_options.cpp b/source/glest_game/menu/menu_state_options.cpp index 5ef853df0..a7bb8b61b 100644 --- a/source/glest_game/menu/menu_state_options.cpp +++ b/source/glest_game/menu/menu_state_options.cpp @@ -243,6 +243,22 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu): currentLine-=30; // end + // Screenshot type flag + labelScreenShotType.registerGraphicComponent(containerName,"labelScreenShotType"); + labelScreenShotType.init(currentLabelStart ,currentLine); + labelScreenShotType.setText(lang.get("ScreenShotFileType")); + + listBoxScreenShotType.registerGraphicComponent(containerName,"listBoxScreenShotType"); + listBoxScreenShotType.init(currentColumnStart ,currentLine, 80 ); + listBoxScreenShotType.pushBackItem("bmp"); + listBoxScreenShotType.pushBackItem("jpg"); + listBoxScreenShotType.pushBackItem("png"); + listBoxScreenShotType.pushBackItem("tga"); + listBoxScreenShotType.setSelectedItem(config.getString("ScreenShotFileType","png")); + + currentLine-=30; + // end + ////////////////////////////////////////////////////////////////// ///////// RIGHT SIDE ////////////////////////////////////////////////////////////////// @@ -586,6 +602,8 @@ void MenuStateOptions::mouseClick(int x, int y, MouseButton mouseButton){ checkBoxEnablePrivacy.mouseClick(x, y); checkBoxEnableTextureCompression.mouseClick(x, y); + + listBoxScreenShotType.mouseClick(x, y); } } @@ -625,6 +643,8 @@ void MenuStateOptions::mouseMove(int x, int y, const MouseState *ms){ checkBoxEnablePrivacy.mouseMove(x, y); checkBoxEnableTextureCompression.mouseMove(x, y); + + listBoxScreenShotType.mouseMove(x, y); } void MenuStateOptions::keyDown(char key){ @@ -746,6 +766,9 @@ void MenuStateOptions::render(){ renderer.renderLabel(&labelEnableTextureCompression); renderer.renderCheckBox(&checkBoxEnableTextureCompression); + + renderer.renderLabel(&labelScreenShotType); + renderer.renderListBox(&listBoxScreenShotType); } if(program != NULL) program->renderProgramMsgBox(); @@ -792,6 +815,8 @@ void MenuStateOptions::saveConfig(){ config.setBool("EnableTextureCompression", checkBoxEnableTextureCompression.getValue()); + config.setString("ScreenShotFileType", listBoxScreenShotType.getSelectedItem()); + string currentResolution=config.getString("ScreenWidth")+"x"+config.getString("ScreenHeight"); string selectedResolution=listBoxScreenModes.getSelectedItem(); if(currentResolution!=selectedResolution){ diff --git a/source/glest_game/menu/menu_state_options.h b/source/glest_game/menu/menu_state_options.h index 7c5d8ec65..ae06548d8 100644 --- a/source/glest_game/menu/menu_state_options.h +++ b/source/glest_game/menu/menu_state_options.h @@ -108,6 +108,10 @@ private: GraphicLabel labelEnableTextureCompression; GraphicCheckBox checkBoxEnableTextureCompression; + GraphicLabel labelScreenShotType; + GraphicListBox listBoxScreenShotType; + + public: MenuStateOptions(Program *program, MainMenu *mainMenu); diff --git a/source/shared_lib/include/graphics/gl/context_gl.h b/source/shared_lib/include/graphics/gl/context_gl.h index 7a88f1163..b8993db12 100644 --- a/source/shared_lib/include/graphics/gl/context_gl.h +++ b/source/shared_lib/include/graphics/gl/context_gl.h @@ -30,7 +30,7 @@ protected: public: ContextGl(); - virtual ~ContextGl(){} + virtual ~ContextGl(); virtual void init(); virtual void end(); diff --git a/source/shared_lib/sources/graphics/gl/context_gl.cpp b/source/shared_lib/sources/graphics/gl/context_gl.cpp index 49e81b7eb..c28f3458e 100644 --- a/source/shared_lib/sources/graphics/gl/context_gl.cpp +++ b/source/shared_lib/sources/graphics/gl/context_gl.cpp @@ -31,19 +31,23 @@ ContextGl::ContextGl() : Context() { } -void ContextGl::init(){ +void ContextGl::init() { pcgl.init(colorBits, depthBits, stencilBits, (hardware_acceleration != 0), (fullscreen_anti_aliasing != 0)); } -void ContextGl::end(){ +ContextGl::~ContextGl() { + end(); +} + +void ContextGl::end() { pcgl.end(); } -void ContextGl::makeCurrent(){ +void ContextGl::makeCurrent() { pcgl.makeCurrent(); } -void ContextGl::swapBuffers(){ +void ContextGl::swapBuffers() { pcgl.swapBuffers(); } diff --git a/source/shared_lib/sources/platform/miniupnpc/miniupnpc.c b/source/shared_lib/sources/platform/miniupnpc/miniupnpc.c index adc5f681c..ba7442865 100644 --- a/source/shared_lib/sources/platform/miniupnpc/miniupnpc.c +++ b/source/shared_lib/sources/platform/miniupnpc/miniupnpc.c @@ -78,6 +78,8 @@ LIBSPEC void parserootdesc(const char * buffer, int bufsize, struct IGDdatas * data) { struct xmlparser parser; + memset(&parser,0,sizeof(parser)); + /* xmlparser object */ parser.xmlstart = buffer; parser.xmlsize = bufsize; diff --git a/source/shared_lib/sources/platform/miniupnpc/upnpreplyparse.c b/source/shared_lib/sources/platform/miniupnpc/upnpreplyparse.c index c72b4c825..0d915091c 100644 --- a/source/shared_lib/sources/platform/miniupnpc/upnpreplyparse.c +++ b/source/shared_lib/sources/platform/miniupnpc/upnpreplyparse.c @@ -42,6 +42,7 @@ ParseNameValue(const char * buffer, int bufsize, struct NameValueParserData * data) { struct xmlparser parser; + memset(&parser,0,sizeof(parser)); LIST_INIT(&(data->head)); /* init xmlparser object */ parser.xmlstart = buffer; diff --git a/source/shared_lib/sources/platform/sdl/gl_wrap.cpp b/source/shared_lib/sources/platform/sdl/gl_wrap.cpp index 788eb2f3b..95d92b3c4 100644 --- a/source/shared_lib/sources/platform/sdl/gl_wrap.cpp +++ b/source/shared_lib/sources/platform/sdl/gl_wrap.cpp @@ -38,21 +38,7 @@ PlatformContextGl::PlatformContextGl() { PlatformContextGl::~PlatformContextGl() { if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); - if(icon != NULL) { - if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); - - SDL_FreeSurface(icon); - icon = NULL; - } - - if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); - - if(screen != NULL) { - if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); - - SDL_FreeSurface(screen); - screen = NULL; - } + end(); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); } @@ -131,6 +117,25 @@ void PlatformContextGl::init(int colorBits, int depthBits, int stencilBits,bool } void PlatformContextGl::end() { + if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); + + if(icon != NULL) { + if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); + + SDL_FreeSurface(icon); + icon = NULL; + } + + if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); + + if(screen != NULL) { + if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); + + SDL_FreeSurface(screen); + screen = NULL; + } + + if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); } void PlatformContextGl::makeCurrent() { diff --git a/source/shared_lib/sources/sound/openal/sound_player_openal.cpp b/source/shared_lib/sources/sound/openal/sound_player_openal.cpp index 52f0c8896..74048e5aa 100644 --- a/source/shared_lib/sources/sound/openal/sound_player_openal.cpp +++ b/source/shared_lib/sources/sound/openal/sound_player_openal.cpp @@ -322,7 +322,10 @@ bool SoundPlayerOpenAL::init(const SoundPlayerParams* params) { this->params = *params; try { - device = alcOpenDevice(0); + // Allows platforms to specify which sound device to use + // using the environment variable: MEGAGLEST_SOUND_DEVICE + char *deviceName = getenv("MEGAGLEST_SOUND_DEVICE"); + device = alcOpenDevice(deviceName); if(device == 0) { printOpenALInfo(); throw std::runtime_error("Couldn't open audio device."); diff --git a/source/shared_lib/sources/util/util.cpp b/source/shared_lib/sources/util/util.cpp index 94fa2123f..a6865fe1b 100644 --- a/source/shared_lib/sources/util/util.cpp +++ b/source/shared_lib/sources/util/util.cpp @@ -291,6 +291,12 @@ SystemFlags::~SystemFlags() { SystemFlags::cleanupHTTP(&curl_handle, true); curl_handle = NULL; } + if(SystemFlags::curl_global_init_called == true) { + SystemFlags::curl_global_init_called = false; + curl_global_cleanup(); + //printf("In [%s::%s Line %d] curl_global_cleanup called\n",__FILE__,__FUNCTION__,__LINE__); + } + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); }