From f40c37f5e8e6d5ac39d9f701404ee26f741a5770 Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Mon, 23 Jan 2012 07:22:43 +0000 Subject: [PATCH] - ported bugfixes for 3.6.0.3 release: - CMake build system fixes applied during debian testing (like checking for compiler SSE support etc) - Windows client fix for headless server operation - Crash for some systems when trying to use VBO's - Fixed AZERTY keyboard support - Enhanced support for screenshots in g3d viewer - Updated particle code from titi - Bugfix for custom data path override causing compiler error - Bugfix for fontconfig to properly find fonts on systems that support and have fontconfig installed (fixes numerous non debian based systems that reported null font errors) - Minor UI fix on battle end screen when playing 8 players (last player was sometimes chopped off) --- CMakeLists.txt | 54 +++-- mk/cmake/Modules/FindFTGL.cmake | 32 ++- mk/cmake/Modules/Toolchain-mingw32.cmake | 19 +- .../megaglest-installer/makedeps_folder.sh | 2 +- mk/linux/start_megaglest_configurator | 2 +- mk/linux/start_megaglest_g3dviewer | 2 +- mk/linux/start_megaglest_mapeditor | 2 +- mk/windoze/Glest.suo | Bin 573952 -> 573952 bytes source/configurator/configuration.cpp | 1 + source/configurator/main.cpp | 1 + source/g3d_viewer/main.cpp | 135 ++++++++---- source/g3d_viewer/renderer.cpp | 16 +- source/g3d_viewer/renderer.h | 10 +- source/glest_game/facilities/game_util.cpp | 2 +- source/glest_game/global/config.cpp | 2 +- source/glest_game/global/core_data.cpp | 24 +-- source/glest_game/global/lang.cpp | 9 + source/glest_game/graphics/particle_type.cpp | 10 +- source/glest_game/graphics/particle_type.h | 1 + source/glest_game/graphics/renderer.cpp | 45 +--- source/glest_game/graphics/renderer.h | 1 - .../graphics/unit_particle_type.cpp | 16 +- .../glest_game/graphics/unit_particle_type.h | 1 + source/glest_game/main/battle_end.cpp | 6 +- source/glest_game/main/main.cpp | 84 ++++++-- source/glest_game/network/connection_slot.cpp | 26 ++- .../glest_game/network/server_interface.cpp | 47 +++- source/glest_game/network/server_interface.h | 3 +- source/glest_game/world/time_flow.cpp | 32 +++ source/glest_game/world/time_flow.h | 1 + source/glest_map_editor/CMakeLists.txt | 6 - source/glest_map_editor/main.cpp | 1 + source/shared_lib/CMakeLists.txt | 9 +- source/shared_lib/include/graphics/font.h | 4 +- .../shared_lib/include/graphics/font_text.h | 2 +- .../include/graphics/gl/font_textFTGL.h | 2 +- .../graphics/gl/font_text_freetypegl.h | 3 +- .../shared_lib/include/graphics/md5/Image.h | 7 +- .../include/graphics/md5/Md5Model.h | 8 +- source/shared_lib/include/graphics/particle.h | 5 + .../include/platform/posix/socket.h | 2 +- .../include/platform/sdl/platform_main.h | 7 +- .../shared_lib/include/platform/win32/types.h | 5 +- source/shared_lib/include/util/string_utils.h | 4 + source/shared_lib/sources/graphics/font.cpp | 175 +++++++++------ .../shared_lib/sources/graphics/font_text.cpp | 2 +- .../sources/graphics/gl/font_gl.cpp | 27 ++- .../sources/graphics/gl/font_textFTGL.cpp | 6 +- .../graphics/gl/font_text_freetypegl.cpp | 9 +- source/shared_lib/sources/graphics/model.cpp | 8 +- .../shared_lib/sources/graphics/particle.cpp | 19 +- source/shared_lib/sources/graphics/pixmap.cpp | 16 +- .../shared_lib/sources/graphics/texture.cpp | 106 +++++++++ source/shared_lib/sources/lua/lua_script.cpp | 6 +- .../platform/common/platform_common.cpp | 5 + .../sources/platform/posix/socket.cpp | 104 ++++++--- .../sources/platform/sdl/gl_wrap.cpp | 7 +- .../sources/platform/sdl/window.cpp | 202 +++++++++--------- .../sources/platform/win32/platform_util.cpp | 10 +- .../sources/streflop/CMakeLists.txt | 2 +- source/shared_lib/sources/util/conversion.cpp | 21 +- source/shared_lib/sources/util/properties.cpp | 30 +-- source/shared_lib/sources/xml/xml_parser.cpp | 12 +- 63 files changed, 948 insertions(+), 470 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 64584d3e7..1339fbcf6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ CMAKE_MINIMUM_REQUIRED( VERSION 2.6.2 ) PROJECT( MegaGlest ) -#SET(CMAKE_VERBOSE_MAKEFILE ON) +# SET(CMAKE_VERBOSE_MAKEFILE ON) # # *NOTE: For now we assume some variation of GCC Compiler (or MingW for Windows binaries) @@ -55,6 +55,7 @@ if (NOT ${XVFB_RUN} MATCHES "XVFB_RUN-NOTFOUND") message(STATUS "Using xvfb-run to run man2help.") endif() +include(${CMAKE_SOURCE_DIR}/mk/cmake/Modules/SpecialMacros.cmake) ## Compiler flags IF(CMAKE_COMPILER_IS_GNUCXX OR MINGW) @@ -74,11 +75,42 @@ IF(CMAKE_COMPILER_IS_GNUCXX OR MINGW) # For gcc warning options see: http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html IF(NOT MINGW) # For tons of verbose warnings add: -Wall - ADD_DEFINITIONS("-Wreturn-type -fno-strict-aliasing -frounding-math -fsignaling-nans -mfpmath=sse -msse -rdynamic") +# ADD_DEFINITIONS("-Wreturn-type -fno-strict-aliasing -frounding-math -fsignaling-nans -mfpmath=sse -msse -rdynamic") + ADD_DEFINITIONS("-Wreturn-type -fno-strict-aliasing -frounding-math -fsignaling-nans -rdynamic") ELSE() - ADD_DEFINITIONS("-Wreturn-type -fno-strict-aliasing -frounding-math -fsignaling-nans -mfpmath=sse -msse -DUNICODE") +# ADD_DEFINITIONS("-Wreturn-type -fno-strict-aliasing -frounding-math -fsignaling-nans -mfpmath=sse -msse -DUNICODE") + ADD_DEFINITIONS("-Wreturn-type -fno-strict-aliasing -frounding-math -fsignaling-nans -DUNICODE") ENDIF() #SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") + + IF(NOT MAX_SSE_LEVEL_DESIRED) + SET(MAX_SSE_LEVEL_DESIRED "1" CACHE STRING "Set the max SSE level to use if supported (0-3)" FORCE) + ENDIF() + + MESSAGE(STATUS "*NOTE: Checking for max SSE LEVEL [${MAX_SSE_LEVEL_DESIRED}]") + special_check_for_sse( ${MAX_SSE_LEVEL_DESIRED} ) + + OPTION(WANT_STREFLOP "use the library streflop" ON) + IF(WANT_STREFLOP) + ADD_DEFINITIONS("-DUSE_STREFLOP -DSTREFLOP_RANDOM_GEN_SIZE=32 -DLIBM_COMPILING_FLT32") + + IF(HAS_SSE_EXTENSIONS) + ADD_DEFINITIONS("-DSTREFLOP_SSE") + MESSAGE(STATUS "*NOTE: using SSE for STREFLOP.") + ELSE() + special_check_for_x87() + + IF(HAS_X87_SUPPORT) + ADD_DEFINITIONS("-DSTREFLOP_X87") + MESSAGE(STATUS "*NOTE: using X87 for STREFLOP.") + ELSE() + ADD_DEFINITIONS("-DSTREFLOP_SOFT") + MESSAGE(STATUS "*NOTE: using SOFT emulation for STREFLOP.") + ENDIF() + ENDIF() + ELSE() + MESSAGE(STATUS "*WARNING: Disabled use of STREFLOP! Out of synchs may occur") + ENDIF() # Debug compiler flags SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g3") @@ -169,21 +201,12 @@ IF(CMAKE_COMPILER_IS_GNUCXX OR MINGW) ENDIF() - OPTION(WANT_STREFLOP "use the library streflop" ON) - # Win32 specific Compiler Flags IF(WIN32) ADD_DEFINITIONS("-D_WINDOWS -D_WIN32 -D_STDCALL_SUPPORTED -D_M_IX86 -DXML_LIBRARY -D_LIB -DCURL_STATICLIB") ELSE() ADD_DEFINITIONS("-DCURL_STATICLIB") ENDIF() - - IF(WANT_STREFLOP) - ADD_DEFINITIONS("-DUSE_STREFLOP -DSTREFLOP_SSE -DSTREFLOP_RANDOM_GEN_SIZE=32 -DLIBM_COMPILING_FLT32") - ELSE() - MESSAGE(STATUS "*WARNING: Disabled use of STREFLOP! Out of synchs may occur") - ENDIF() - ENDIF() IF(WIN32) @@ -240,6 +263,13 @@ IF(EXISTS "${PROJECT_SOURCE_DIR}/data/glest_game/") ADD_SUBDIRECTORY( ${PROJECT_SOURCE_DIR}/data/glest_game ) ENDIF() +get_directory_property( DirDefs DIRECTORY ${CMAKE_SOURCE_DIR} COMPILE_DEFINITIONS ) +foreach( d ${DirDefs} ) + message( STATUS "=====> Found Define: " ${d} ) +endforeach() +message( STATUS "=====> DirDefs: " ${DirDefs} ) +#MESSAGE(STATUS "*** Compiler definitions are [${COMPILE_DEFINITIONS}]") + MARK_AS_ADVANCED(SDLMAIN_LIBRARY) MARK_AS_ADVANCED(SDL_INCLUDE_DIR) MARK_AS_ADVANCED(SDL_LIBRARY) diff --git a/mk/cmake/Modules/FindFTGL.cmake b/mk/cmake/Modules/FindFTGL.cmake index eaa85f0e9..393111683 100644 --- a/mk/cmake/Modules/FindFTGL.cmake +++ b/mk/cmake/Modules/FindFTGL.cmake @@ -5,7 +5,8 @@ # # FTGL_FOUND - system has ftgl # FTGL_INCLUDE_DIR - path to FTGL/FTGL.h -# FTGL_LIBRARY - the library that must be included +# FTGL_LIBRARY - the library that must be included +# FTGL_LIBRARY_PATH - the library path # # @@ -14,17 +15,34 @@ IF(WANT_STATIC_LIBS) OPTION(FTGL_STATIC "Set to ON to link your project with static library (instead of DLL)." ON) ENDIF() +#message(STATUS "!!!!!!!!!!!!!!!!!!!!!!!!!!!!! #1 Searching for FTGL lib in custom path: [${FTGL_LIBRARY_PATH}]") + IF (FTGL_LIBRARY AND FTGL_INCLUDE_DIR) SET(FTGL_FOUND "YES") + message(STATUS "!!!!!!!!!!!!!!!!!!!!!!!!!!!!! FTGL lib ALREADY FOUND in: [${FTGL_LIBRARY}]") ELSE (FTGL_LIBRARY AND FTGL_INCLUDE_DIR) - FIND_PATH(FTGL_INCLUDE_DIR FTGL/ftgl.h PATHS /usr/local/include /usr/include) + IF(FTGL_LIBRARY_PATH) + message(STATUS "!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Searching for FTGL lib in custom path: [${FTGL_LIBRARY_PATH}]") + ENDIF() -IF (FTGL_STATIC AND NOT FTGL_LIBRARY) - FIND_LIBRARY(FTGL_LIBRARY NAMES libftgl.a ftgl PATHS /usr/local/lib /usr/lib) -ELSE() - FIND_LIBRARY(FTGL_LIBRARY NAMES ftgl PATHS /usr/local/lib /usr/lib) -ENDIF() + FIND_PATH(FTGL_INCLUDE_DIR FTGL/ftgl.h + PATHS /usr/local/include + /usr/include) + + IF (FTGL_STATIC AND NOT FTGL_LIBRARY) + FIND_LIBRARY(FTGL_LIBRARY + NAMES libftgl.a ftgl libftgl libftgl.dll + PATHS /usr/local/lib + /usr/lib + ${FTGL_LIBRARY_PATH}) + ELSE() + FIND_LIBRARY(FTGL_LIBRARY + NAMES ftgl libftgl libftgl.dll libftgl.a + PATHS /usr/local/lib + /usr/lib + ${FTGL_LIBRARY_PATH}) + ENDIF() IF (FTGL_INCLUDE_DIR AND FTGL_LIBRARY) SET(FTGL_FOUND "YES") diff --git a/mk/cmake/Modules/Toolchain-mingw32.cmake b/mk/cmake/Modules/Toolchain-mingw32.cmake index 707cb00a5..9080a2603 100644 --- a/mk/cmake/Modules/Toolchain-mingw32.cmake +++ b/mk/cmake/Modules/Toolchain-mingw32.cmake @@ -2,12 +2,23 @@ SET(CMAKE_SYSTEM_NAME Windows) # which compilers to use for C and C++ -SET(CMAKE_C_COMPILER i586-mingw32msvc-gcc) -SET(CMAKE_CXX_COMPILER i586-mingw32msvc-g++) -SET(CMAKE_RC_COMPILER i586-mingw32msvc-windres) +#SET(CMAKE_C_COMPILER i586-mingw32msvc-gcc) +#SET(CMAKE_CXX_COMPILER i586-mingw32msvc-g++) +#SET(CMAKE_RC_COMPILER i586-mingw32msvc-windres) +SET(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc) +SET(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++) +SET(CMAKE_RC_COMPILER x86_64-w64-mingw32-windres) # here is the target environment located -SET(CMAKE_FIND_ROOT_PATH /usr/i586-mingw32msvc ${PROJECT_SOURCE_DIR}/source/win32_deps/lib) +#SET(CMAKE_FIND_ROOT_PATH /usr/i586-mingw32msvc ${PROJECT_SOURCE_DIR}/source/win32_deps/lib) +SET(CMAKE_FIND_ROOT_PATH /usr/x86_64-w64-mingw32 ${PROJECT_SOURCE_DIR}/source/win32_deps/lib) +include_directories(${PROJECT_SOURCE_DIR}/source/win32_deps/freetype-2.4.8/include) +include_directories(${PROJECT_SOURCE_DIR}/source/win32_deps/glew-1.7.0/include) +include_directories(${PROJECT_SOURCE_DIR}/source/win32_deps/ftgl-2.1.3~rc5/src) +#add_definitions(-std=c++0x) +add_definitions( -std=gnu++0x ) +add_definitions( -DTA3D_PLATFORM_MSVC=1 ) +add_definitions( -DTA3D_PLATFORM_WINDOWS=1 ) # adjust the default behaviour of the FIND_XXX() commands: # search headers and libraries in the target environment, search diff --git a/mk/linux/mojosetup/megaglest-installer/makedeps_folder.sh b/mk/linux/mojosetup/megaglest-installer/makedeps_folder.sh index 2eac1b51a..56df741ca 100755 --- a/mk/linux/mojosetup/megaglest-installer/makedeps_folder.sh +++ b/mk/linux/mojosetup/megaglest-installer/makedeps_folder.sh @@ -3,7 +3,7 @@ set -e # Use this script to copy shared (libs) files to specified location # ---------------------------------------------------------------------------- # Written by Vivek Gite -# (c) 2006 nixCraft under GNU GPL v2.0+ +# Copyright (c) 2006 nixCraft under GNU GPL v2.0+ # Last updated on: Apr/06/2010 by Vivek Gite # ---------------------------------------------------------------------------- # + Modified for megaglest deployment - Softcoder diff --git a/mk/linux/start_megaglest_configurator b/mk/linux/start_megaglest_configurator index 3d5370541..fe92e213b 100755 --- a/mk/linux/start_megaglest_configurator +++ b/mk/linux/start_megaglest_configurator @@ -19,4 +19,4 @@ cd $GAMEDIR # export game library directory test -n "${LIBDIR}" && export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${GAMEDIR}/${LIBDIR}" -./megaglest_configurator +./megaglest_configurator $@ diff --git a/mk/linux/start_megaglest_g3dviewer b/mk/linux/start_megaglest_g3dviewer index 7e50f1e91..ad58add73 100755 --- a/mk/linux/start_megaglest_g3dviewer +++ b/mk/linux/start_megaglest_g3dviewer @@ -120,4 +120,4 @@ findMissingSO "$LDCONFIG" "$GAMEDIR/$LIBDIR/${DIRECTFB_LINKEDLIBNAME}" "$DIRECTF findMissingSO "$LDCONFIG" "$GAMEDIR/$LIBDIR/${FUSION_LINKEDLIBNAME}" "$FUSION_LIBLOOKUP1" "$FUSION_LIBLOOKUP2" findMissingSO "$LDCONFIG" "$GAMEDIR/$LIBDIR/${DIRECT_LINKEDLIBNAME}" "$DIRECT_LIBLOOKUP1" "$DIRECT_LIBLOOKUP2" -"$GAMEDIR/megaglest_g3dviewer" "$1" +"$GAMEDIR/megaglest_g3dviewer" $@ diff --git a/mk/linux/start_megaglest_mapeditor b/mk/linux/start_megaglest_mapeditor index d70aa013d..d358424bc 100755 --- a/mk/linux/start_megaglest_mapeditor +++ b/mk/linux/start_megaglest_mapeditor @@ -120,4 +120,4 @@ findMissingSO "$LDCONFIG" "$GAMEDIR/$LIBDIR/${DIRECTFB_LINKEDLIBNAME}" "$DIRECTF findMissingSO "$LDCONFIG" "$GAMEDIR/$LIBDIR/${FUSION_LINKEDLIBNAME}" "$FUSION_LIBLOOKUP1" "$FUSION_LIBLOOKUP2" findMissingSO "$LDCONFIG" "$GAMEDIR/$LIBDIR/${DIRECT_LINKEDLIBNAME}" "$DIRECT_LIBLOOKUP1" "$DIRECT_LIBLOOKUP2" -"$GAMEDIR/megaglest_editor" "$1" +"$GAMEDIR/megaglest_editor" $@ diff --git a/mk/windoze/Glest.suo b/mk/windoze/Glest.suo index 0a3a31606b9c370f1becfae2df7d8bb4ebf85866..3e63ed8b050077cc7cdd3104a362146df09f11ad 100644 GIT binary patch delta 15417 zcmb_@4R{nq)^1mISN9N-FoYq*5W)~bi~++C5fBk35Ktk)fH4F_OkxNDF$N6CpJalF zKZ_VrIEO{Wh={DB2BMi&5C_(ET|kVivi=|jmUU4P!;gM0BHXunhRE)^--YMi<~eld zOig!n)u~hOdCwXDlJ5Q`-RoxEC!#qwLdr8F-_}#wVdx9ZL~g?JQ=3Jb9H&zIiF?9+3g>_yt~HGupPeF z1=0)h-iv+XzB_yDoYLn(3L%=@l-Wsojp2&7R4Q&xWpMa_>u-)Lh9%(0~W6X!2KbCwoLz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vBB5KtQn%ROi^nge_bUwRiX7x)XnG^iPEG%yk<0|h1*wH z9DURvkDM|K|M@x|Sr$25?gyC0g6aVPrCjslKNGpU0B{GGL$1(HglTtzz_i}LLV!y_ zn8s`HFX0h70eF;%W>K$wPp`Dv@bP0ILfw zF<~0h<5B0%To~mHnpq6l{*op|u%w<(q5K+(hRu2rT$rXg>xaT0wVCF>d4? MukrNGDJ$#$0hfHfeE #include"platform_util.h" using namespace std; diff --git a/source/configurator/main.cpp b/source/configurator/main.cpp index dfa746ffe..63b186536 100644 --- a/source/configurator/main.cpp +++ b/source/configurator/main.cpp @@ -24,6 +24,7 @@ #include "util.h" #include #include +#include using namespace std; using namespace Shared::PlatformCommon; diff --git a/source/g3d_viewer/main.cpp b/source/g3d_viewer/main.cpp index 887ce0ceb..356d88688 100644 --- a/source/g3d_viewer/main.cpp +++ b/source/g3d_viewer/main.cpp @@ -105,6 +105,7 @@ const wxChar *GAME_ARGS[] = { wxT("--rotate-x-value"), wxT("--rotate-y-value"), wxT("--screenshot-format"), + wxT("--verbose"), }; enum GAME_ARG_TYPE { @@ -121,6 +122,7 @@ enum GAME_ARG_TYPE { GAME_ARG_ROTATE_X_VALUE, GAME_ARG_ROTATE_Y_VALUE, GAME_ARG_SCREENSHOT_FORMAT, + GAME_ARG_VERBOSE, }; bool hasCommandArgument(int argc, wxChar** argv,const string argName, @@ -197,9 +199,9 @@ void printParameterHelp(const char *argv0, bool foundInvalidArgs) { printf("\n \t\t of the optional settings:"); printf("\n \t\ttransparent, enable_grid, enable_wireframe,"); printf("\n \t\tenable_normals, disable_grid, disable_wireframe,"); - printf("\n \t\tdisable_normals, saveas-"); + printf("\n \t\tdisable_normals, saveas-, resize-wxh"); printf("\n \t\texample:"); - printf("\n %s %s=transparent,disable_grid,saveas-test.png %s=techs/megapack/factions/tech/units/battle_machine/models/battle_machine_dying.g3d",extractFileFromDirectoryPath(argv0).c_str(),(const char *)wxConvCurrent->cWX2MB(GAME_ARGS[GAME_ARG_AUTO_SCREENSHOT]),(const char *)wxConvCurrent->cWX2MB(GAME_ARGS[GAME_ARG_LOAD_MODEL])); + printf("\n %s %s=transparent,disable_grid,saveas-test.png,resize-800x600 %s=techs/megapack/factions/tech/units/battle_machine/models/battle_machine_dying.g3d",extractFileFromDirectoryPath(argv0).c_str(),(const char *)wxConvCurrent->cWX2MB(GAME_ARGS[GAME_ARG_AUTO_SCREENSHOT]),(const char *)wxConvCurrent->cWX2MB(GAME_ARGS[GAME_ARG_LOAD_MODEL])); // "================================================================================" printf("\n%s=x",(const char *)wxConvCurrent->cWX2MB(GAME_ARGS[GAME_ARG_LOAD_PARTICLE])); @@ -258,6 +260,7 @@ void printParameterHelp(const char *argv0, bool foundInvalidArgs) { bool autoScreenShotAndExit = false; vector autoScreenShotParams; +std::pair overrideSize(0,0); // =============================================== // class MainWindow @@ -291,6 +294,7 @@ MainWindow::MainWindow( std::pair > unitToLoad, //getGlPlatformExtensions(); int args[] = { WX_GL_RGBA, WX_GL_DOUBLEBUFFER, WX_GL_MIN_ALPHA, 8 }; // to prevent flicker + //int args[] = { WX_GL_RGBA, WX_GL_MIN_ALPHA, 0 }; // to prevent flicker glCanvas = new GlCanvas(this, args); #if wxCHECK_VERSION(2, 9, 1) @@ -567,31 +571,25 @@ void MainWindow::onPaint(wxPaintEvent &event) { setupStartupSettings(); } + //wxClientDC &dc = event.GetDC(); +// wxPaintDC dc(this); +// if(overrideSize.first > 0 && overrideSize.second > 0) { +// wxRect r(0,0,100,100); +// dc.SetDeviceClippingRegion(r); +// // Then I destroy the clipping region +// dc.DestroyClippingRegion(); +// } + // notice that we use GetSize() here and not GetClientSize() because // the latter doesn't return correct results for the minimized windows // (at least not under Windows) -#if defined(WIN32) -/* - //Seems like windows cannot handle this consistently + int viewportW = GetClientSize().x; + int viewportH = GetClientSize().y; - if(autoScreenShotAndExit == true) { - printf("\n\n$$$ GetSize() x = %d y = %d, Renderer::windowW = %d H = %d\n",GetSize().x,GetSize().y,Renderer::windowW,Renderer::windowH); - //renderer->reset(GetSize().x, GetSize().y-10, playerColor); - //renderer->reset(Renderer::windowW, Renderer::windowH-20, playerColor); - //this->Iconize(false); - - //this->Refresh(); - //renderer->reset(GetClientSize().x, GetClientSize().y, playerColor); - renderer->reset(Renderer::windowW, Renderer::windowH-20, playerColor); - } - else { - printf("\n\n### GetClientSize() x = %d y = %d\n",GetClientSize().x,GetClientSize().y); - renderer->reset(GetClientSize().x, GetClientSize().y, playerColor); - } -*/ - renderer->reset(GetClientSize().x, GetClientSize().y, playerColor); +#if defined(WIN32) + renderer->reset(viewportW, viewportH, playerColor); #else - renderer->reset(GetClientSize().x, GetClientSize().y, playerColor); + renderer->reset(viewportW, viewportH, playerColor); #endif renderer->transform(rotX, rotY, zoom); @@ -616,8 +614,7 @@ void MainWindow::onPaint(wxPaintEvent &event) { } renderer->renderParticleManager(); - glCanvas->SwapBuffers(); - + bool haveLoadedParticles = (particleProjectilePathList.empty() == false || particleSplashPathList.empty() == false); if(autoScreenShotAndExit == true) { @@ -629,7 +626,10 @@ void MainWindow::onPaint(wxPaintEvent &event) { Close(); return; } - else if((modelPathList.empty() == false) && resetAnimation && haveLoadedParticles) { + + glCanvas->SwapBuffers(); + + if((modelPathList.empty() == false) && resetAnimation && haveLoadedParticles) { if(anim >= resetAnim && resetAnim > 0) { printf("RESETTING EVERYTHING [%f][%f]...\n",anim,resetAnim); fflush(stdout); @@ -963,7 +963,7 @@ void MainWindow::saveScreenshot() { FILE *f= fopen(saveAsFilename.c_str(), "rb"); #endif if(f == NULL) { - renderer->saveScreen(saveAsFilename.c_str()); + renderer->saveScreen(saveAsFilename.c_str(),&overrideSize); } else { if(f) { @@ -998,7 +998,7 @@ void MainWindow::saveScreenshot() { FILE *f= fopen(path.c_str(), "rb"); #endif if(f == NULL) { - renderer->saveScreen(path); + renderer->saveScreen(path,&overrideSize); break; } else { @@ -1095,10 +1095,11 @@ void MainWindow::loadUnit(string path, string skillName) { string skillParticleFile = ""; string skillParticleProjectileFile = ""; string skillParticleSplashFile = ""; + bool fileFound = fileExists(unitXML); - printf("Loading unit from file [%s]\n",unitXML.c_str()); + printf("Loading unit from file [%s] fileFound = %d\n",unitXML.c_str(),fileFound); - if(fileExists(unitXML) == true) { + if(fileFound == true) { XmlTree xmlTree; xmlTree.load(unitXML,Properties::getTagReplacementValues()); const XmlNode *unitNode= xmlTree.getRootNode(); @@ -1270,15 +1271,19 @@ void MainWindow::loadParticle(string path) { //int height = -1; if(fileExists(unitXML) == true) { + + int size = 0; + int height= 0; + { XmlTree xmlTree; xmlTree.load(unitXML,Properties::getTagReplacementValues()); const XmlNode *unitNode= xmlTree.getRootNode(); const XmlNode *parametersNode= unitNode->getChild("parameters"); //size - int size= parametersNode->getChild("size")->getAttribute("value")->getIntValue(); + size= parametersNode->getChild("size")->getAttribute("value")->getIntValue(); //height - int height= parametersNode->getChild("height")->getAttribute("value")->getIntValue(); - + height= parametersNode->getChild("height")->getAttribute("value")->getIntValue(); + } // std::cout << "About to load [" << particlePath << "] from [" << dir << "] unit [" << unitXML << "]" << std::endl; @@ -1323,6 +1328,8 @@ void MainWindow::loadParticle(string path) { } void MainWindow::loadProjectileParticle(string path) { + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] about to load [%s] particleProjectilePathList.size() = %lu\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,path.c_str(),this->particleProjectilePathList.size()); + if(timer) timer->Stop(); if(path != "" && fileExists(path) == true) { renderer->end(); @@ -1342,7 +1349,7 @@ void MainWindow::loadProjectileParticle(string path) { try { if(this->particleProjectilePathList.empty() == false) { - printf("this->particleProjectilePathList.size() = %lu\n",this->particleProjectilePathList.size()); + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("this->particleProjectilePathList.size() = %lu\n",this->particleProjectilePathList.size()); string titlestring=winHeader; for(unsigned int idx = 0; idx < this->particleProjectilePathList.size(); idx++) { @@ -1363,6 +1370,8 @@ void MainWindow::loadProjectileParticle(string path) { int height = -1; if(fileExists(unitXML) == true) { + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] loading [%s] idx = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,unitXML.c_str(),idx); + XmlTree xmlTree; xmlTree.load(unitXML,Properties::getTagReplacementValues()); const XmlNode *unitNode= xmlTree.getRootNode(); @@ -1375,18 +1384,21 @@ void MainWindow::loadProjectileParticle(string path) { // std::cout << "About to load [" << particlePath << "] from [" << dir << "] unit [" << unitXML << "]" << std::endl; + string particleFile = dir + folderDelimiter + particlePath; { - XmlTree xmlTree; - xmlTree.load(dir + folderDelimiter + particlePath,Properties::getTagReplacementValues()); - //const XmlNode *particleSystemNode= xmlTree.getRootNode(); + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] loading [%s] idx = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,particleFile.c_str(),idx); + XmlTree xmlTree; + xmlTree.load(particleFile,Properties::getTagReplacementValues()); + //const XmlNode *particleSystemNode= xmlTree.getRootNode(); - // std::cout << "Loaded successfully, loading values..." << std::endl; + // std::cout << "Loaded successfully, loading values..." << std::endl; } + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] loading [%s] idx = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,particleFile.c_str(),idx); std::map > > loadedFileList; ParticleSystemTypeProjectile *projectileParticleSystemType= new ParticleSystemTypeProjectile(); projectileParticleSystemType->load(NULL, dir, //### we don't know if there are overrides in the unit XML - dir + folderDelimiter + particlePath,renderer, loadedFileList, + particleFile,renderer, loadedFileList, "g3dviewer",""); // std::cout << "Values loaded, about to read..." << std::endl; @@ -1412,6 +1424,8 @@ void MainWindow::loadProjectileParticle(string path) { ps->setVisible(true); renderer->manageParticleSystem(ps); } + + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] loaded [%s] idx = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,particleFile.c_str(),idx); } SetTitle(ToUnicode(titlestring)); @@ -1428,9 +1442,12 @@ void MainWindow::loadProjectileParticle(string path) { wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Not a Mega-Glest projectile particle XML file, or broken"), wxOK | wxICON_ERROR).ShowModal(); } if(timer) timer->Start(100); + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] after load [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,path.c_str()); } void MainWindow::loadSplashParticle(string path) { // uses ParticleSystemTypeSplash::load (and own list...) + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] about to load [%s] particleSplashPathList.size() = %lu\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,path.c_str(),this->particleSplashPathList.size()); + if(timer) timer->Stop(); if(path != "" && fileExists(path) == true) { renderer->end(); @@ -1481,11 +1498,12 @@ void MainWindow::loadSplashParticle(string path) { // uses ParticleSystemTypeSp // std::cout << "About to load [" << particlePath << "] from [" << dir << "] unit [" << unitXML << "]" << std::endl; - XmlTree xmlTree; - xmlTree.load(dir + folderDelimiter + particlePath,Properties::getTagReplacementValues()); - //const XmlNode *particleSystemNode= xmlTree.getRootNode(); - - // std::cout << "Loaded successfully, loading values..." << std::endl; + { + XmlTree xmlTree; + xmlTree.load(dir + folderDelimiter + particlePath,Properties::getTagReplacementValues()); + //const XmlNode *particleSystemNode= xmlTree.getRootNode(); + // std::cout << "Loaded successfully, loading values..." << std::endl; + } std::map > > loadedFileList; ParticleSystemTypeSplash *splashParticleSystemType= new ParticleSystemTypeSplash(); @@ -1531,6 +1549,7 @@ void MainWindow::loadSplashParticle(string path) { // uses ParticleSystemTypeSp wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Not a Mega-Glest projectile particle XML file, or broken"), wxOK | wxICON_ERROR).ShowModal(); } if(timer) timer->Start(100); + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] after load [%s] particleSplashPathList.size() = %lu\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,path.c_str(),this->particleSplashPathList.size()); } void MainWindow::onMenuModeNormals(wxCommandEvent &event){ @@ -1980,6 +1999,10 @@ END_EVENT_TABLE() bool App::OnInit() { SystemFlags::VERBOSE_MODE_ENABLED = false; + //Renderer::windowW = 1920; + //Renderer::windowH = 1440; + //Renderer::windowX= 0; + //Renderer::windowY= 0; string modelPath=""; string particlePath=""; @@ -2005,6 +2028,10 @@ bool App::OnInit() { return false; } + if(hasCommandArgument(argc, argv,(const char *)wxConvCurrent->cWX2MB(GAME_ARGS[GAME_ARG_VERBOSE])) == true) { + SystemFlags::VERBOSE_MODE_ENABLED = true; + } + if(hasCommandArgument(argc, argv,(const char *)wxConvCurrent->cWX2MB(GAME_ARGS[GAME_ARG_AUTO_SCREENSHOT])) == true) { autoScreenShotAndExit = true; @@ -2026,13 +2053,29 @@ bool App::OnInit() { autoScreenShotParams.clear(); Tokenize(optionsValue,autoScreenShotParams,","); - #ifdef WIN32 for(unsigned int i = 0; i < autoScreenShotParams.size(); ++i) { + +#ifdef WIN32 std::auto_ptr wstr(Ansi2WideString(autoScreenShotParams[i].c_str())); autoScreenShotParams[i] = utf8_encode(wstr.get()); - } - #endif +#endif + if(_strnicmp(autoScreenShotParams[i].c_str(),"resize-",7) == 0) { + printf("Screenshot option [%s]\n",autoScreenShotParams[i].c_str()); + + string resize = autoScreenShotParams[i]; + resize = resize.erase(0,7); + vector values; + Tokenize(resize,values,"x"); + overrideSize.first = strToInt(values[0]); + overrideSize.second = strToInt(values[1]); + + Renderer::windowX= 0; + Renderer::windowY= 0; + Renderer::windowW = overrideSize.first; + Renderer::windowH = overrideSize.second + 25; + } + } } } diff --git a/source/g3d_viewer/renderer.cpp b/source/g3d_viewer/renderer.cpp index 87b363053..efc9e66d5 100644 --- a/source/g3d_viewer/renderer.cpp +++ b/source/g3d_viewer/renderer.cpp @@ -21,6 +21,11 @@ using namespace Shared::Graphics::Gl; namespace Shared{ namespace G3dViewer{ +int Renderer::windowX= 100; +int Renderer::windowY= 100; +int Renderer::windowW= 640; +int Renderer::windowH= 480; + // =============================================== // class MeshCallbackTeamColor // =============================================== @@ -483,16 +488,21 @@ void Renderer::setAlphaColor(float alpha) { //printf("#3.1 The framebuffer uses %d bit(s) per the alpha component\n", alpha_bits); } -void Renderer::saveScreen(const string &path) { +void Renderer::saveScreen(const string &path,std::pair *overrideSize) { Pixmap2D *pixmapScreenShot = new Pixmap2D(width, height, 4); - glFinish(); + //glFinish(); glPixelStorei(GL_PACK_ALIGNMENT, 1); - glReadPixels(0, 0, pixmapScreenShot->getW(), pixmapScreenShot->getH(),GL_RGBA, GL_UNSIGNED_BYTE, pixmapScreenShot->getPixels()); + glReadPixels(0, 0, pixmapScreenShot->getW(), pixmapScreenShot->getH(), + GL_RGBA, GL_UNSIGNED_BYTE, pixmapScreenShot->getPixels()); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + //if(overrideSize != NULL && overrideSize->first > 0 && overrideSize->second > 0) { + // pixmapScreenShot->Scale(GL_RGBA,overrideSize->first,overrideSize->second); + //} + pixmapScreenShot->save(path); delete pixmapScreenShot; } diff --git a/source/g3d_viewer/renderer.h b/source/g3d_viewer/renderer.h index 48b533e77..ed58caff1 100644 --- a/source/g3d_viewer/renderer.h +++ b/source/g3d_viewer/renderer.h @@ -68,10 +68,10 @@ public: class Renderer : public RendererInterface { public: - static const int windowX= 100; - static const int windowY= 100; - static const int windowW= 640; - static const int windowH= 480; + static int windowX; + static int windowY; + static int windowW; + static int windowH; public: enum PlayerColor{ @@ -157,7 +157,7 @@ public: void setBackgroundColor(float red, float green, float blue); void setAlphaColor(float alpha); - void saveScreen(const string &path); + void saveScreen(const string &path,std::pair *overrideSize); bool hasActiveParticleSystem(ParticleSystem::ParticleSystemType typeName) const; }; diff --git a/source/glest_game/facilities/game_util.cpp b/source/glest_game/facilities/game_util.cpp index 3119793ec..695c3b3db 100644 --- a/source/glest_game/facilities/game_util.cpp +++ b/source/glest_game/facilities/game_util.cpp @@ -27,7 +27,7 @@ using namespace Shared::Platform; namespace Glest { namespace Game { const char *mailString = " http://bugs.megaglest.org"; -const string glestVersionString = "v3.6.0.2"; +const string glestVersionString = "v3.6.0.3"; #if defined(SVNVERSION) const string SVN_Rev = string("Rev: ") + string(SVNVERSION); #elif defined(SVNVERSIONHEADER) diff --git a/source/glest_game/global/config.cpp b/source/glest_game/global/config.cpp index cc9214f66..9f436b112 100644 --- a/source/glest_game/global/config.cpp +++ b/source/glest_game/global/config.cpp @@ -147,7 +147,7 @@ Config::Config(std::pair type, std::pair f #if defined(CUSTOM_DATA_INSTALL_PATH) if(foundPath == false) { - foundPath = tryCustomPath(cfgType, fileName, CUSTOM_DATA_INSTALL_PATH); + foundPath = tryCustomPath(cfgType, fileName, TOSTRING(CUSTOM_DATA_INSTALL_PATH)); } #endif diff --git a/source/glest_game/global/core_data.cpp b/source/glest_game/global/core_data.cpp index a24cc64ed..089efb11d 100644 --- a/source/glest_game/global/core_data.cpp +++ b/source/glest_game/global/core_data.cpp @@ -350,7 +350,7 @@ void CoreData::loadFonts() { if(Renderer::renderText3DEnabled == false) { displayFont= renderer.newFont(rsGlobal); if(displayFont) { - displayFont->setType(displayFontName,config.getString("FontDisplay","")); + displayFont->setType(displayFontName,config.getString("FontDisplay",""),config.getString("FontDisplayFamily","")); displayFont->setSize(displayFontSize); //displayFont->setYOffsetFactor(config.getFloat("FontDisplayYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str())); } @@ -363,7 +363,7 @@ void CoreData::loadFonts() { if(Renderer::renderText3DEnabled == true) { displayFont3D= renderer.newFont3D(rsGlobal); if(displayFont3D) { - displayFont3D->setType(displayFontName,config.getString("FontDisplay","")); + displayFont3D->setType(displayFontName,config.getString("FontDisplay",""),config.getString("FontDisplayFamily","")); displayFont3D->setSize(displayFontSize); //displayFont3D->setYOffsetFactor(config.getFloat("FontDisplayYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str())); } @@ -395,7 +395,7 @@ void CoreData::loadFonts() { if(Renderer::renderText3DEnabled == false) { displayFontSmall= renderer.newFont(rsGlobal); if(displayFontSmall) { - displayFontSmall->setType(displayFontNameSmall,config.getString("FontSmallDisplay","")); + displayFontSmall->setType(displayFontNameSmall,config.getString("FontSmallDisplay",""),config.getString("FontSmallDisplayFamily","")); displayFontSmall->setSize(displayFontNameSmallSize); //displayFontSmall->setYOffsetFactor(config.getFloat("FontSmallDisplayYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str())); } @@ -408,7 +408,7 @@ void CoreData::loadFonts() { if(Renderer::renderText3DEnabled == true) { displayFontSmall3D= renderer.newFont3D(rsGlobal); if(displayFontSmall3D) { - displayFontSmall3D->setType(displayFontNameSmall,config.getString("FontSmallDisplay","")); + displayFontSmall3D->setType(displayFontNameSmall,config.getString("FontSmallDisplay",""),config.getString("FontSmallDisplayFamily","")); displayFontSmall3D->setSize(displayFontNameSmallSize); //displayFontSmall3D->setYOffsetFactor(config.getFloat("FontSmallDisplayYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str())); } @@ -439,7 +439,7 @@ void CoreData::loadFonts() { if(Renderer::renderText3DEnabled == false) { menuFontNormal= renderer.newFont(rsGlobal); if(menuFontNormal) { - menuFontNormal->setType(menuFontNameNormal,config.getString("FontMenuNormal","")); + menuFontNormal->setType(menuFontNameNormal,config.getString("FontMenuNormal",""),config.getString("FontMenuNormalFamily","")); menuFontNormal->setSize(menuFontNameNormalSize); menuFontNormal->setWidth(Font::wBold); //menuFontNormal->setYOffsetFactor(config.getFloat("FontMenuNormalYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str())); @@ -453,7 +453,7 @@ void CoreData::loadFonts() { if(Renderer::renderText3DEnabled == true) { menuFontNormal3D= renderer.newFont3D(rsGlobal); if(menuFontNormal3D) { - menuFontNormal3D->setType(menuFontNameNormal,config.getString("FontMenuNormal","")); + menuFontNormal3D->setType(menuFontNameNormal,config.getString("FontMenuNormal",""),config.getString("FontMenuNormalFamily","")); menuFontNormal3D->setSize(menuFontNameNormalSize); menuFontNormal3D->setWidth(Font::wBold); //menuFontNormal3D->setYOffsetFactor(config.getFloat("FontMenuNormalYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str())); @@ -485,7 +485,7 @@ void CoreData::loadFonts() { if(Renderer::renderText3DEnabled == false) { menuFontBig= renderer.newFont(rsGlobal); if(menuFontBig) { - menuFontBig->setType(menuFontNameBig,config.getString("FontMenuBig","")); + menuFontBig->setType(menuFontNameBig,config.getString("FontMenuBig",""),config.getString("FontMenuBigFamily","")); menuFontBig->setSize(menuFontNameBigSize); //menuFontBig->setYOffsetFactor(config.getFloat("FontMenuBigYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str())); } @@ -498,7 +498,7 @@ void CoreData::loadFonts() { if(Renderer::renderText3DEnabled == true) { menuFontBig3D= renderer.newFont3D(rsGlobal); if(menuFontBig3D) { - menuFontBig3D->setType(menuFontNameBig,config.getString("FontMenuBig","")); + menuFontBig3D->setType(menuFontNameBig,config.getString("FontMenuBig",""),config.getString("FontMenuBigFamily","")); menuFontBig3D->setSize(menuFontNameBigSize); //menuFontBig3D->setYOffsetFactor(config.getFloat("FontMenuBigYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str())); } @@ -529,7 +529,7 @@ void CoreData::loadFonts() { if(Renderer::renderText3DEnabled == false) { menuFontVeryBig= renderer.newFont(rsGlobal); if(menuFontVeryBig) { - menuFontVeryBig->setType(menuFontNameVeryBig,config.getString("FontMenuVeryBig","")); + menuFontVeryBig->setType(menuFontNameVeryBig,config.getString("FontMenuVeryBig",""),config.getString("FontMenuVeryBigFamily","")); menuFontVeryBig->setSize(menuFontNameVeryBigSize); //menuFontVeryBig->setYOffsetFactor(config.getFloat("FontMenuVeryBigYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str())); } @@ -542,7 +542,7 @@ void CoreData::loadFonts() { if(Renderer::renderText3DEnabled == true) { menuFontVeryBig3D= renderer.newFont3D(rsGlobal); if(menuFontVeryBig3D) { - menuFontVeryBig3D->setType(menuFontNameVeryBig,config.getString("FontMenuVeryBig","")); + menuFontVeryBig3D->setType(menuFontNameVeryBig,config.getString("FontMenuVeryBig",""),config.getString("FontMenuVeryBigFamily","")); menuFontVeryBig3D->setSize(menuFontNameVeryBigSize); //menuFontVeryBig3D->setYOffsetFactor(config.getFloat("FontMenuVeryBigYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str())); } @@ -576,7 +576,7 @@ void CoreData::loadFonts() { if(Renderer::renderText3DEnabled == false) { consoleFont= renderer.newFont(rsGlobal); if(consoleFont) { - consoleFont->setType(consoleFontName,config.getString("FontConsole","")); + consoleFont->setType(consoleFontName,config.getString("FontConsole",""),config.getString("FontConsoleFamily","")); consoleFont->setSize(consoleFontNameSize); //consoleFont->setYOffsetFactor(config.getFloat("FontConsoleYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str())); } @@ -589,7 +589,7 @@ void CoreData::loadFonts() { if(Renderer::renderText3DEnabled == true) { consoleFont3D= renderer.newFont3D(rsGlobal); if(consoleFont3D) { - consoleFont3D->setType(consoleFontName,config.getString("FontConsole","")); + consoleFont3D->setType(consoleFontName,config.getString("FontConsole",""),config.getString("FontConsoleFamily","")); consoleFont3D->setSize(consoleFontNameSize); //consoleFont3D->setYOffsetFactor(config.getFloat("FontConsoleYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str())); } diff --git a/source/glest_game/global/lang.cpp b/source/glest_game/global/lang.cpp index 5ba1793c7..5091f3e07 100644 --- a/source/glest_game/global/lang.cpp +++ b/source/glest_game/global/lang.cpp @@ -107,6 +107,15 @@ void Lang::loadStrings(string uselanguage, bool loadFonts, #endif } + if( lang.hasString("MEGAGLEST_FONT_FAMILY")) { + #if defined(WIN32) + string newEnvValue = "MEGAGLEST_FONT_FAMILY=" + lang.get("MEGAGLEST_FONT_FAMILY"); + _putenv(newEnvValue.c_str()); + #else + setenv("MEGAGLEST_FONT_FAMILY",lang.get("MEGAGLEST_FONT_FAMILY").c_str(),0); + #endif + } + // if( lang.hasString("FONT_YOFFSET_FACTOR")) { // FontMetrics::DEFAULT_Y_OFFSET_FACTOR = strToFloat(lang.get("FONT_YOFFSET_FACTOR")); // } diff --git a/source/glest_game/graphics/particle_type.cpp b/source/glest_game/graphics/particle_type.cpp index 109da64ba..c1aebdd3a 100644 --- a/source/glest_game/graphics/particle_type.cpp +++ b/source/glest_game/graphics/particle_type.cpp @@ -43,7 +43,8 @@ ParticleSystemType::ParticleSystemType() { teamcolorNoEnergy=false; teamcolorEnergy=false; - alternations=false; + alternations=0; + particleSystemStartDelay=0; texture=NULL; model=NULL; minmaxEnabled=false; @@ -101,6 +102,7 @@ void ParticleSystemType::copyAll(const ParticleSystemType &src) { this->teamcolorNoEnergy = src.teamcolorNoEnergy; this->teamcolorEnergy = src.teamcolorEnergy; this->alternations = src.alternations; + this->particleSystemStartDelay= src.particleSystemStartDelay; for(Children::iterator it = children.begin(); it != children.end(); ++it) { UnitParticleSystemType *child = *it; @@ -239,6 +241,11 @@ void ParticleSystemType::load(const XmlNode *particleSystemNode, const string &d const XmlNode *alternatingNode= particleSystemNode->getChild("alternations"); alternations= alternatingNode->getAttribute("value")->getIntValue(); } + //particleSystemStartDelay + if(particleSystemNode->hasChild("particleSystemStartDelay")){ + const XmlNode *node= particleSystemNode->getChild("particleSystemStartDelay"); + particleSystemStartDelay= node->getAttribute("value")->getIntValue(); + } //mode if(particleSystemNode->hasChild("mode")) { const XmlNode *modeNode= particleSystemNode->getChild("mode"); @@ -293,6 +300,7 @@ void ParticleSystemType::setValues(AttackParticleSystem *ats){ ats->setTeamcolorNoEnergy(teamcolorNoEnergy); ats->setTeamcolorEnergy(teamcolorEnergy); ats->setAlternations(alternations); + ats->setParticleSystemStartDelay(particleSystemStartDelay); ats->setBlendMode(ParticleSystem::strToBlendMode(mode)); } diff --git a/source/glest_game/graphics/particle_type.h b/source/glest_game/graphics/particle_type.h index 62b37fc0f..6d3ecc7e6 100644 --- a/source/glest_game/graphics/particle_type.h +++ b/source/glest_game/graphics/particle_type.h @@ -69,6 +69,7 @@ protected: bool teamcolorNoEnergy; bool teamcolorEnergy; int alternations; + int particleSystemStartDelay; typedef std::list Children; Children children; diff --git a/source/glest_game/graphics/renderer.cpp b/source/glest_game/graphics/renderer.cpp index 140436435..f39167ed0 100644 --- a/source/glest_game/graphics/renderer.cpp +++ b/source/glest_game/graphics/renderer.cpp @@ -839,7 +839,7 @@ void Renderer::setupLighting() { assertGl(); //sun/moon light - Vec3f lightColor= computeLightColor(time); + Vec3f lightColor= timeFlow->computeLightColor(); Vec3f fogColor= world->getTileset()->getFogColor(); Vec4f lightPos= timeFlow->isDay()? computeSunPos(time): computeMoonPos(time); nearestLightPos= lightPos; @@ -3260,7 +3260,7 @@ VisibleQuadContainerVBOCache * Renderer::GetSurfaceVBOs(SurfaceData *cellData) { glBindBufferARB( GL_ARRAY_BUFFER_ARB, vboCache.m_nVBOVertices ); // Bind The Buffer // Load The Data glBufferDataARB( GL_ARRAY_BUFFER_ARB, sizeof(Vec3f) * cellData->bufferCount, vertices, GL_STATIC_DRAW_ARB ); - glBindBuffer(GL_ARRAY_BUFFER_ARB, 0); + glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); assertGl(); // Generate And Bind The Texture Coordinate Buffer @@ -3268,7 +3268,7 @@ VisibleQuadContainerVBOCache * Renderer::GetSurfaceVBOs(SurfaceData *cellData) { glBindBufferARB( GL_ARRAY_BUFFER_ARB, vboCache.m_nVBOFowTexCoords ); // Bind The Buffer // Load The Data glBufferDataARB( GL_ARRAY_BUFFER_ARB, sizeof(Vec2f) * cellData->bufferCount, texCoords, GL_STATIC_DRAW_ARB ); - glBindBuffer(GL_ARRAY_BUFFER_ARB, 0); + glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); assertGl(); // Generate And Bind The Texture Coordinate Buffer @@ -3276,7 +3276,7 @@ VisibleQuadContainerVBOCache * Renderer::GetSurfaceVBOs(SurfaceData *cellData) { glBindBufferARB( GL_ARRAY_BUFFER_ARB, vboCache.m_nVBOSurfaceTexCoords ); // Bind The Buffer // Load The Data glBufferDataARB( GL_ARRAY_BUFFER_ARB, sizeof(Vec2f) * cellData->bufferCount, texCoordsSurface, GL_STATIC_DRAW_ARB ); - glBindBuffer(GL_ARRAY_BUFFER_ARB, 0); + glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); assertGl(); // Generate And Bind The Normal Buffer @@ -3284,7 +3284,7 @@ VisibleQuadContainerVBOCache * Renderer::GetSurfaceVBOs(SurfaceData *cellData) { glBindBufferARB( GL_ARRAY_BUFFER_ARB, vboCache.m_nVBONormals ); // Bind The Buffer // Load The Data glBufferDataARB( GL_ARRAY_BUFFER_ARB, sizeof(Vec3f) * cellData->bufferCount, normals, GL_STATIC_DRAW_ARB ); - glBindBuffer(GL_ARRAY_BUFFER_ARB, 0); + glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); vboCache.hasBuiltVBOs = true; @@ -3333,7 +3333,7 @@ template void _loadVBO(GLuint &vbo,std::vector buf,int target=GL_ assert(vbo); glBindBufferARB(target,vbo); glBufferDataARB(target,sizeof(T)*buf.size(),&buf[0],GL_STATIC_DRAW_ARB); - glBindBuffer(target,0); + glBindBufferARB(target,0); assertGl(); buf.clear(); } @@ -4183,7 +4183,7 @@ void Renderer::renderObjects(const int renderFps) { const Texture2D *fowTex = world->getMinimap()->getFowTexture(); const Pixmap2D *fowTexPixmap = fowTex->getPixmapConst(); - Vec3f baseFogColor = world->getTileset()->getFogColor() * computeLightColor(world->getTimeFlow()->getTime()); + Vec3f baseFogColor = world->getTileset()->getFogColor() * world->getTimeFlow()->computeLightColor(); bool modelRenderStarted = false; @@ -6395,7 +6395,7 @@ void Renderer::saveScreen(const string &path) { Pixmap2D *pixmapScreenShot = new Pixmap2D(sm.getScreenW(), sm.getScreenH(), 3); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); - glFinish(); + //glFinish(); glPixelStorei(GL_PACK_ALIGNMENT, 1); @@ -6461,35 +6461,6 @@ Vec4f Renderer::computeMoonPos(float time) { #endif } -Vec3f Renderer::computeLightColor(float time) { - const Tileset *tileset= game->getWorld()->getTileset(); - Vec3f color; - - const float transition= 2; - const float dayStart= TimeFlow::dawn; - const float dayEnd= TimeFlow::dusk-transition; - const float nightStart= TimeFlow::dusk; - const float nightEnd= TimeFlow::dawn-transition; - - if(time>dayStart && timegetSunLightColor(); - } - else if(time>nightStart || timegetMoonLightColor(); - } - else if(time>=dayEnd && time<=nightStart) { - color= tileset->getSunLightColor().lerp((time-dayEnd)/transition, tileset->getMoonLightColor()); - } - else if(time>=nightEnd && time<=dayStart) { - color= tileset->getMoonLightColor().lerp((time-nightEnd)/transition, tileset->getSunLightColor()); - } - else { - assert(false); - color= tileset->getSunLightColor(); - } - return color; -} - Vec4f Renderer::computeWaterColor(float waterLevel, float cellHeight) { const float waterFactor= 1.5f; return Vec4f(1.f, 1.f, 1.f, clamp((waterLevel-cellHeight)*waterFactor, 0.f, 1.f)); diff --git a/source/glest_game/graphics/renderer.h b/source/glest_game/graphics/renderer.h index 849329988..b0603a30d 100644 --- a/source/glest_game/graphics/renderer.h +++ b/source/glest_game/graphics/renderer.h @@ -581,7 +581,6 @@ private: float computeMoonAngle(float time); Vec4f computeSunPos(float time); Vec4f computeMoonPos(float time); - Vec3f computeLightColor(float time); Vec4f computeWaterColor(float waterLevel, float cellHeight); void checkExtension(const string &extension, const string &msg); diff --git a/source/glest_game/graphics/unit_particle_type.cpp b/source/glest_game/graphics/unit_particle_type.cpp index cecbc1c05..d42fe8d83 100644 --- a/source/glest_game/graphics/unit_particle_type.cpp +++ b/source/glest_game/graphics/unit_particle_type.cpp @@ -40,8 +40,9 @@ UnitParticleSystemType::UnitParticleSystemType() : ParticleSystemType() { relativeDirection = false; fixed = false; staticParticleCount = 0; - isVisibleAtNight = false; - isVisibleAtDay = false; + isVisibleAtNight = true; + isVisibleAtDay = true; + isDaylightAffected = false; radiusBasedStartenergy = false; delay = 0; lifetime = 0; @@ -146,6 +147,15 @@ void UnitParticleSystemType::load(const XmlNode *particleSystemNode, const strin isVisibleAtDay=true; } + //isDaylightAffected + if(particleSystemNode->hasChild("isDaylightAffected")){ + const XmlNode *node= particleSystemNode->getChild("isDaylightAffected"); + isDaylightAffected= node->getAttribute("value")->getBoolValue(); + } + else { + isDaylightAffected=false; + } + //radiusBasedStartenergy if(particleSystemNode->hasChild("radiusBasedStartenergy")){ const XmlNode *isVisibleAtDayNode= particleSystemNode->getChild("radiusBasedStartenergy"); @@ -217,9 +227,11 @@ const void UnitParticleSystemType::setValues(UnitParticleSystem *ups){ ups->setTeamcolorNoEnergy(teamcolorNoEnergy); ups->setTeamcolorEnergy(teamcolorEnergy); ups->setAlternations(alternations); + ups->setParticleSystemStartDelay(particleSystemStartDelay); ups->setIsVisibleAtNight(isVisibleAtNight); ups->setIsVisibleAtDay(isVisibleAtDay); + ups->setIsDaylightAffected(isDaylightAffected); ups->setStaticParticleCount(staticParticleCount); ups->setRadius(radius); ups->setMinRadius(minRadius); diff --git a/source/glest_game/graphics/unit_particle_type.h b/source/glest_game/graphics/unit_particle_type.h index 00c4ef794..a3e500161 100644 --- a/source/glest_game/graphics/unit_particle_type.h +++ b/source/glest_game/graphics/unit_particle_type.h @@ -58,6 +58,7 @@ protected: int staticParticleCount; bool isVisibleAtNight; bool isVisibleAtDay; + bool isDaylightAffected; bool radiusBasedStartenergy; int delay; int lifetime; diff --git a/source/glest_game/main/battle_end.cpp b/source/glest_game/main/battle_end.cpp index 780843f82..7e6b88bb6 100644 --- a/source/glest_game/main/battle_end.cpp +++ b/source/glest_game/main/battle_end.cpp @@ -237,7 +237,7 @@ void BattleEnd::render() { } realPlayerCount++; - int textX= lm + 60 + (realPlayerCount*110); + int textX= lm + 60 + (realPlayerCount*100); int team= stats.getTeam(i) + 1; int kills= stats.getKills(i); int enemykills= stats.getEnemyKills(i); @@ -292,7 +292,7 @@ void BattleEnd::render() { } if(stats.getControl(i) != ctHuman && stats.getControl(i) != ctNetwork ) { - controlString += " x " + floatToStr(stats.getResourceMultiplier(i),1); + controlString += "\nx " + floatToStr(stats.getResourceMultiplier(i),1); } if(score == bestScore && stats.getVictory(i)) { @@ -408,7 +408,7 @@ void BattleEnd::render() { //GameConstants::updateFps //string header2 = lang.get("GameDuration") + " " + floatToStr(stats.getWorldTimeElapsed() / 24.0,2); - string header2 = lang.get("GameDuration") + ": " + intToStr(stats.getFramesToCalculatePlaytime()/GameConstants::updateFps/60); + string header2 = lang.get("GameDuration") + ": " + floatToStr((float)stats.getFramesToCalculatePlaytime() / (float)GameConstants::updateFps / 60.0,2); textRenderer->render(header2, lm+250, bm+530); header2 = lang.get("GameMaxConcurrentUnitCount") + ": " + intToStr(stats.getMaxConcurrentUnitCount()); diff --git a/source/glest_game/main/main.cpp b/source/glest_game/main/main.cpp index 346b5b5f5..a22265ed3 100644 --- a/source/glest_game/main/main.cpp +++ b/source/glest_game/main/main.cpp @@ -2459,7 +2459,7 @@ int glestMain(int argc, char** argv) { #if defined(CUSTOM_DATA_INSTALL_PATH) - if(SystemFlags::VERBOSE_MODE_ENABLED) printf("\n\nCUSTOM_DATA_INSTALL_PATH = [%s]\n\n",CUSTOM_DATA_INSTALL_PATH); + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("\n\nCUSTOM_DATA_INSTALL_PATH = [%s]\n\n",TOSTRING(CUSTOM_DATA_INSTALL_PATH)); #endif const int knownArgCount = sizeof(GAME_ARGS) / sizeof(GAME_ARGS[0]); @@ -3543,6 +3543,10 @@ int glestMain(int argc, char** argv) { cinfd[0].events = POLLIN; #else h = GetStdHandle(STD_INPUT_HANDLE); + //DWORD dwMode; + //GetConsoleMode(h, &dwMode); + //SetConsoleMode(h, dwMode & ~ENABLE_MOUSE_INPUT); + FlushConsoleInputBuffer(h); #endif } @@ -3568,36 +3572,72 @@ int glestMain(int argc, char** argv) { // line buffer input. This does work okay as long as the user doesn't enter characters // without pressing enter, and then try to end the server another way (say a remote // console command), in which case we'll still be waiting for the stdin EOL and hang. - if (WaitForSingleObject(h, 0) == WAIT_OBJECT_0) + + DWORD saveMode; + GetConsoleMode(h, &saveMode); + DWORD dwMode = saveMode; + dwMode &= ~ENABLE_MOUSE_INPUT; + dwMode &= ~ENABLE_WINDOW_INPUT; + SetConsoleMode(h, dwMode); + + bool gotData = (WaitForSingleObject(h, 0) == WAIT_OBJECT_0); + SetConsoleMode(h, saveMode); + if(gotData == true) #endif { - getline(cin, command); - cin.clear(); - - printf("server command [%s]\n",command.c_str()); - if(command == "quit") { - break; + bool skip = true; +#ifdef WIN32 + DWORD nNumberOfCharsToRead = 1024; + DWORD nRead = 0; + INPUT_RECORD irInRec[1025]; + + PeekConsoleInput(h,&irInRec[0],nNumberOfCharsToRead,&nRead); + for(int i = 0; i < nRead; ++i) { + INPUT_RECORD &inr = irInRec[i]; + + //printf("inr.EventType = %d\n",inr.EventType); + if(inr.EventType == KEY_EVENT) { + if(inr.Event.KeyEvent.bKeyDown) { + char cHoldKey = inr.Event.KeyEvent.uChar.AsciiChar; + if(cHoldKey == '\r') { + skip = false; + break; + } + } + } } +#else + skip = false; +#endif + if(skip == false) { + getline(cin, command); + cin.clear(); + + printf("server command [%s]\n",command.c_str()); + if(command == "quit") { + break; + } #ifndef WIN32 - if (cinfd[0].revents & POLLNVAL) { - printf("invalid file descriptor\n"); - } - if (cinfd[0].revents & POLLERR) { - printf("error in file descriptor\n"); - } - if (cinfd[0].revents & POLLHUP) { - printf("hang up in file descriptor\n"); - } + if (cinfd[0].revents & POLLNVAL) { + printf("invalid file descriptor\n"); + } + if (cinfd[0].revents & POLLERR) { + printf("error in file descriptor\n"); + } + if (cinfd[0].revents & POLLHUP) { + printf("hang up in file descriptor\n"); + } - if(pollresult < 0) { - printf("pollresult = %d errno = %d [%s]\n",pollresult,pollerror,strerror(pollerror)); + if(pollresult < 0) { + printf("pollresult = %d errno = %d [%s]\n",pollresult,pollerror,strerror(pollerror)); - cinfd[0].fd = fileno(stdin); - cinfd[0].events = POLLIN; - } + cinfd[0].fd = fileno(stdin); + cinfd[0].events = POLLIN; + } #endif + } } } //printf("looping\n"); diff --git a/source/glest_game/network/connection_slot.cpp b/source/glest_game/network/connection_slot.cpp index 9f4e8afad..b464de8f8 100644 --- a/source/glest_game/network/connection_slot.cpp +++ b/source/glest_game/network/connection_slot.cpp @@ -385,9 +385,9 @@ void ConnectionSlot::update(bool checkForNewClients,int lockedSlotIndex) { if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] about to accept new client connection playerIndex = %d\n",__FILE__,__FUNCTION__,__LINE__,playerIndex); - Socket *newSocket = serverInterface->getServerSocket()->accept(); + Socket *newSocket = serverInterface->getServerSocket()->accept(false); - if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] called accept new client connection playerIndex = %d\n",__FILE__,__FUNCTION__,__LINE__,playerIndex); + if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] called accept new client connection playerIndex = %d newSocket = %p\n",__FILE__,__FUNCTION__,__LINE__,playerIndex,newSocket); if(newSocket != NULL) { // Set Socket as non-blocking newSocket->setBlock(false); @@ -436,14 +436,19 @@ void ConnectionSlot::update(bool checkForNewClients,int lockedSlotIndex) { //if(chrono.getMillis() > 1) printf("In [%s::%s Line: %d] action running for msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,(long long int)chrono.getMillis()); } + else { + close(); + return; + } //if(chrono.getMillis() > 1) printf("In [%s::%s Line: %d] action running for msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,(long long int)chrono.getMillis()); - } + //} //if(chrono.getMillis() > 1) printf("In [%s::%s Line: %d] action running for msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,(long long int)chrono.getMillis()); //send intro message when connected - if(hasData == true && this->isConnected() == true) { + //if(hasData == true && this->isConnected() == true) { + if(this->isConnected() == true) { //RandomGen random; //sessionKey = random.randRange(-100000, 100000); srand(time(NULL) / (this->playerIndex + 1)); @@ -473,6 +478,7 @@ void ConnectionSlot::update(bool checkForNewClients,int lockedSlotIndex) { //if(chrono.getMillis() > 1) printf("In [%s::%s Line: %d] action running for msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,(long long int)chrono.getMillis()); //} } + } } } //if(chrono.getMillis() > 1) printf("In [%s::%s Line: %d] action running for msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,(long long int)chrono.getMillis()); @@ -707,14 +713,14 @@ void ConnectionSlot::update(bool checkForNewClients,int lockedSlotIndex) { throw runtime_error(szBuf); } - GameSettings gameSettings; - networkMessageLaunch.buildGameSettings(&gameSettings); + GameSettings gameSettingsBuffer; + networkMessageLaunch.buildGameSettings(&gameSettingsBuffer); //printf("Connection slot got networkMessageLaunch.getMessageType() = %d, got map [%s]\n",networkMessageLaunch.getMessageType(),gameSettings.getMap().c_str()); //printf("\n\n\n\n=====Connection slot got settings:\n%s\n",gameSettings.toString().c_str()); - this->serverInterface->setGameSettings(&gameSettings,false); - this->serverInterface->broadcastGameSetup(&gameSettings); + //this->serverInterface->setGameSettings(&gameSettingsBuffer,false); + this->serverInterface->broadcastGameSetup(&gameSettingsBuffer, true); if(networkMessageLaunch.getMessageType() == nmtLaunch) { this->serverInterface->setMasterserverAdminRequestLaunch(true); @@ -1031,7 +1037,8 @@ void ConnectionSlot::update(bool checkForNewClients,int lockedSlotIndex) { } void ConnectionSlot::validateConnection() { - if(gotIntro == false && connectedTime > 0 && + if(this->isConnected() == true && + gotIntro == false && connectedTime > 0 && difftime(time(NULL),connectedTime) > GameConstants::maxClientConnectHandshakeSecs) { close(); } @@ -1063,6 +1070,7 @@ void ConnectionSlot::close() { ready = false; gotIntro = false; + connectedTime = 0; if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] END\n",__FILE__,__FUNCTION__); } diff --git a/source/glest_game/network/server_interface.cpp b/source/glest_game/network/server_interface.cpp index 9a79d954c..c6ed6bc3c 100644 --- a/source/glest_game/network/server_interface.cpp +++ b/source/glest_game/network/server_interface.cpp @@ -1708,10 +1708,17 @@ bool ServerInterface::launchGame(const GameSettings *gameSettings) { return bOkToStart; } -void ServerInterface::broadcastGameSetup(const GameSettings *gameSettings) { +void ServerInterface::broadcastGameSetup(GameSettings *gameSettingsBuffer, bool setGameSettingsBuffer) { if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__); + if(setGameSettingsBuffer == true) { + validateGameSettings(gameSettingsBuffer); + //setGameSettings(gameSettingsBuffer,false); + MutexSafeWrapper safeMutex(serverSynchAccessor,CODE_AT_LINE); + gameSettings = *gameSettingsBuffer; + gameSettingsUpdateCount++; + } MutexSafeWrapper safeMutex(serverSynchAccessor,CODE_AT_LINE); - NetworkMessageLaunch networkMessageLaunch(gameSettings, nmtBroadCastSetup); + NetworkMessageLaunch networkMessageLaunch(gameSettingsBuffer, nmtBroadCastSetup); broadcastMessage(&networkMessageLaunch); if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__); } @@ -1833,17 +1840,47 @@ int ServerInterface::getOpenSlotCount() { } int ServerInterface::getGameSettingsUpdateCount() { - if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] START gameSettingsUpdateCount = %d\n",__FILE__,__FUNCTION__,gameSettingsUpdateCount); MutexSafeWrapper safeMutex(serverSynchAccessor,CODE_AT_LINE); + if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] START gameSettingsUpdateCount = %d\n",__FILE__,__FUNCTION__,gameSettingsUpdateCount); int result = gameSettingsUpdateCount; safeMutex.ReleaseLock(); return result; } -void ServerInterface::setGameSettings(GameSettings *serverGameSettings, bool waitForClientAck) { - if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] START gameSettingsUpdateCount = %d, waitForClientAck = %d\n",__FILE__,__FUNCTION__,gameSettingsUpdateCount,waitForClientAck); +void ServerInterface::validateGameSettings(GameSettings *serverGameSettings) { MutexSafeWrapper safeMutex(serverSynchAccessor,CODE_AT_LINE); + if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s]\n",__FILE__,__FUNCTION__); + + string mapFile = serverGameSettings->getMap(); + if(find(mapFiles.begin(),mapFiles.end(),mapFile) == mapFiles.end()) { + printf("Reverting map from [%s] to [%s]\n",serverGameSettings->getMap().c_str(),gameSettings.getMap().c_str()); + + serverGameSettings->setMapFilterIndex(gameSettings.getMapFilterIndex()); + serverGameSettings->setMap(gameSettings.getMap()); + serverGameSettings->setMapCRC(gameSettings.getMapCRC()); + } + + string tilesetFile = serverGameSettings->getTileset(); + if(find(tilesetFiles.begin(),tilesetFiles.end(),tilesetFile) == tilesetFiles.end()) { + printf("Reverting tileset from [%s] to [%s]\n",serverGameSettings->getTileset().c_str(),gameSettings.getTileset().c_str()); + + serverGameSettings->setTileset(gameSettings.getTileset()); + serverGameSettings->setTilesetCRC(gameSettings.getTilesetCRC()); + } + + string techtreeFile = serverGameSettings->getTech(); + if(find(techTreeFiles.begin(),techTreeFiles.end(),techtreeFile) == techTreeFiles.end()) { + printf("Reverting tech from [%s] to [%s]\n",serverGameSettings->getTech().c_str(),gameSettings.getTech().c_str()); + + serverGameSettings->setTech(gameSettings.getTech()); + serverGameSettings->setTechCRC(gameSettings.getTechCRC()); + } +} + +void ServerInterface::setGameSettings(GameSettings *serverGameSettings, bool waitForClientAck) { + MutexSafeWrapper safeMutex(serverSynchAccessor,CODE_AT_LINE); + if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] START gameSettingsUpdateCount = %d, waitForClientAck = %d\n",__FILE__,__FUNCTION__,gameSettingsUpdateCount,waitForClientAck); string mapFile = serverGameSettings->getMap(); if(find(mapFiles.begin(),mapFiles.end(),mapFile) == mapFiles.end()) { diff --git a/source/glest_game/network/server_interface.h b/source/glest_game/network/server_interface.h index fe28280ed..ec48d5a98 100644 --- a/source/glest_game/network/server_interface.h +++ b/source/glest_game/network/server_interface.h @@ -124,8 +124,9 @@ public: int getConnectedSlotCount(); int getOpenSlotCount(); bool launchGame(const GameSettings *gameSettings); + void validateGameSettings(GameSettings *serverGameSettings); void setGameSettings(GameSettings *serverGameSettings, bool waitForClientAck); - void broadcastGameSetup(const GameSettings *gameSettings); + void broadcastGameSetup(GameSettings *gameSettingsBuffer, bool setGameSettingsBuffer=false); int getGameSettingsUpdateCount(); diff --git a/source/glest_game/world/time_flow.cpp b/source/glest_game/world/time_flow.cpp index d060dcf9c..8287f92e9 100644 --- a/source/glest_game/world/time_flow.cpp +++ b/source/glest_game/world/time_flow.cpp @@ -55,6 +55,7 @@ void TimeFlow::update() { soundRenderer.stopAmbient(ambientSounds->getNight()); UnitParticleSystem::isNight=false; } + UnitParticleSystem::lightColor=computeLightColor(); if((lastTime=dawn) || firstTime){ @@ -94,4 +95,35 @@ void TimeFlow::update() { // return (this->time>=time) && (this->timedayStart && timegetSunLightColor(); + } + else if(time>nightStart || timegetMoonLightColor(); + } + else if(time>=dayEnd && time<=nightStart) { + color= tileset->getSunLightColor().lerp((time-dayEnd)/transition, tileset->getMoonLightColor()); + } + else if(time>=nightEnd && time<=dayStart) { + color= tileset->getMoonLightColor().lerp((time-nightEnd)/transition, tileset->getSunLightColor()); + } + else { + assert(false); + color= tileset->getSunLightColor(); + } + return color; +} + + }}//end namespace diff --git a/source/glest_game/world/time_flow.h b/source/glest_game/world/time_flow.h index b099ce6a4..5090d3a3d 100644 --- a/source/glest_game/world/time_flow.h +++ b/source/glest_game/world/time_flow.h @@ -57,6 +57,7 @@ public: bool isTotalNight() const {return timedusk-1.f;} float getTimeInc() const {return timeInc;} + Vec3f computeLightColor() const; void update(); private: //bool isAproxTime(float time) const; diff --git a/source/glest_map_editor/CMakeLists.txt b/source/glest_map_editor/CMakeLists.txt index 0acfa0fa3..dbaf54381 100644 --- a/source/glest_map_editor/CMakeLists.txt +++ b/source/glest_map_editor/CMakeLists.txt @@ -17,12 +17,6 @@ IF(BUILD_MEGAGLEST_MAP_EDITOR) IF(NOT WIN32) # It was noticed that when using MinGW gcc it is essential that 'core' is mentioned before 'base'. - - IF(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") - SET(wxWidgets_CONFIG_OPTIONS --prefix=/usr/local) - MESSAGE(STATUS "Detected FreeBSD.....") - ENDIF() - FIND_PACKAGE(wxWidgets COMPONENTS core base gl REQUIRED) # wxWidgets include (this will do all the magic to configure everything) diff --git a/source/glest_map_editor/main.cpp b/source/glest_map_editor/main.cpp index be9474100..047f9bd78 100644 --- a/source/glest_map_editor/main.cpp +++ b/source/glest_map_editor/main.cpp @@ -21,6 +21,7 @@ #ifndef WIN32 #include #endif +#include using namespace Shared::Util; using namespace Shared::PlatformCommon; diff --git a/source/shared_lib/CMakeLists.txt b/source/shared_lib/CMakeLists.txt index e0924c051..c6b379713 100644 --- a/source/shared_lib/CMakeLists.txt +++ b/source/shared_lib/CMakeLists.txt @@ -138,7 +138,10 @@ IF(BUILD_MEGAGLEST_MODEL_VIEWER OR BUILD_MEGAGLEST_MAP_EDITOR OR BUILD_MEGAGLEST FIND_PACKAGE(FontConfig) IF(FONTCONFIG_FOUND) + MESSAGE(STATUS "**NOTE: FontConfig support was detected and enabled.") SET(HAVE_FONTCONFIG 1) + ADD_DEFINITIONS(-DHAVE_FONTCONFIG) + INCLUDE_DIRECTORIES( ${FONTCONFIG_INCLUDE_DIR} ) SET(EXTERNAL_LIBS ${EXTERNAL_LIBS} ${FONTCONFIG_LIBRARIES} ) ENDIF(FONTCONFIG_FOUND) @@ -348,9 +351,9 @@ IF(BUILD_MEGAGLEST_MODEL_VIEWER OR BUILD_MEGAGLEST_MAP_EDITOR OR BUILD_MEGAGLEST ENDIF() # FIXME: hackish... - IF(WANT_STREFLOP) - SET(STREFLOP_PROPERTIES "-DSTREFLOP_SSE -DLIBM_COMPILING_FLT32") - ENDIF() +# IF(WANT_STREFLOP) +# SET(STREFLOP_PROPERTIES "-DSTREFLOP_SSE -DLIBM_COMPILING_FLT32") +# ENDIF() SET_SOURCE_FILES_PROPERTIES(${MG_SOURCE_FILES} PROPERTIES COMPILE_FLAGS "${PLATFORM_SPECIFIC_DEFINES} ${STREFLOP_PROPERTIES} ${CXXFLAGS}") diff --git a/source/shared_lib/include/graphics/font.h b/source/shared_lib/include/graphics/font.h index 1c37f490a..d458430eb 100644 --- a/source/shared_lib/include/graphics/font.h +++ b/source/shared_lib/include/graphics/font.h @@ -101,7 +101,7 @@ public: string getType() const; //set - void setType(string typeX11, string typeGeneric); + void setType(string typeX11, string typeGeneric, string typeGenericFamily); void setWidth(int width); int getSize() const; @@ -139,7 +139,7 @@ public: Font3D *ConvertFont2DTo3D(Font2D *font); -const char* findFont(const char *firstFontToTry=NULL); +const char* findFont(const char *firstFontToTry=NULL,const char *firstFontFamilyToTry=NULL); }}//end namespace diff --git a/source/shared_lib/include/graphics/font_text.h b/source/shared_lib/include/graphics/font_text.h index 18934f6c7..8bfb63b1b 100644 --- a/source/shared_lib/include/graphics/font_text.h +++ b/source/shared_lib/include/graphics/font_text.h @@ -36,7 +36,7 @@ public: Text(FontTextHandlerType type); virtual ~Text(); - virtual void init(string fontName, int fontSize); + virtual void init(string fontName, string fontFamilyName, int fontSize); virtual void SetFaceSize(int); virtual int GetFaceSize(); diff --git a/source/shared_lib/include/graphics/gl/font_textFTGL.h b/source/shared_lib/include/graphics/gl/font_textFTGL.h index 99a48a84b..99a265d16 100644 --- a/source/shared_lib/include/graphics/gl/font_textFTGL.h +++ b/source/shared_lib/include/graphics/gl/font_textFTGL.h @@ -33,7 +33,7 @@ public: TextFTGL(FontTextHandlerType type); virtual ~TextFTGL(); - virtual void init(string fontName, int fontSize); + virtual void init(string fontName, string fontFamilyName, int fontSize); virtual void SetFaceSize(int); virtual int GetFaceSize(); diff --git a/source/shared_lib/include/graphics/gl/font_text_freetypegl.h b/source/shared_lib/include/graphics/gl/font_text_freetypegl.h index 1c057e1ea..09d397e9d 100644 --- a/source/shared_lib/include/graphics/gl/font_text_freetypegl.h +++ b/source/shared_lib/include/graphics/gl/font_text_freetypegl.h @@ -41,7 +41,7 @@ public: TextFreetypeGL(FontTextHandlerType type); virtual ~TextFreetypeGL(); - virtual void init(string fontName, int fontSize); + virtual void init(string fontName, string fontFamilyName, int fontSize); virtual void SetFaceSize(int); virtual int GetFaceSize(); @@ -66,6 +66,7 @@ private: int fontFaceSize; string fontName; + string fontFamilyName; const char* fontFile; void cleanupFont(); diff --git a/source/shared_lib/include/graphics/md5/Image.h b/source/shared_lib/include/graphics/md5/Image.h index 34fd3137f..267bfd5b1 100644 --- a/source/shared_lib/include/graphics/md5/Image.h +++ b/source/shared_lib/include/graphics/md5/Image.h @@ -43,10 +43,11 @@ #endif // _WIN32 #include -#ifndef _WIN32 -//#include + +#if !defined(_WIN32) || defined(__MINGW32__) #include #endif + #include #include #include @@ -61,7 +62,7 @@ using std::cout; using std::endl; using std::string; -#ifdef _WIN32 +#if defined(_WIN32) using std::tr1::shared_ptr; #endif diff --git a/source/shared_lib/include/graphics/md5/Md5Model.h b/source/shared_lib/include/graphics/md5/Md5Model.h index ee5502f9c..f4ded72bc 100644 --- a/source/shared_lib/include/graphics/md5/Md5Model.h +++ b/source/shared_lib/include/graphics/md5/Md5Model.h @@ -48,7 +48,11 @@ #include #include #include -//#include + +#if !defined(_WIN32) || defined(__MINGW32__) +#include +#endif + #include #include "Mathlib.h" @@ -60,7 +64,7 @@ using std::string; using std::vector; using std::map; -#ifdef _WIN32 +#if defined(_WIN32) using std::tr1::shared_ptr; #endif diff --git a/source/shared_lib/include/graphics/particle.h b/source/shared_lib/include/graphics/particle.h index 76471a6b6..201483e19 100644 --- a/source/shared_lib/include/graphics/particle.h +++ b/source/shared_lib/include/graphics/particle.h @@ -132,6 +132,7 @@ protected: bool teamcolorNoEnergy; bool teamcolorEnergy; int alternations; + int particleSystemStartDelay; ParticleObserver *particleObserver; public: @@ -173,6 +174,7 @@ public: void setTeamcolorNoEnergy(bool teamcolorNoEnergy) {this->teamcolorNoEnergy= teamcolorNoEnergy;} void setTeamcolorEnergy(bool teamcolorEnergy) {this->teamcolorEnergy= teamcolorEnergy;} void setAlternations(int alternations) {this->alternations= alternations;} + void setParticleSystemStartDelay(int delay) {this->particleSystemStartDelay= delay;} virtual void setFactionColor(Vec3f factionColor); static BlendMode strToBlendMode(const string &str); @@ -269,6 +271,7 @@ protected: class UnitParticleSystem: public GameParticleSystem{ public: static bool isNight; + static Vec3f lightColor; private: float radius; float minRadius; @@ -296,6 +299,7 @@ public: float rotation; bool isVisibleAtNight; bool isVisibleAtDay; + bool isDaylightAffected; bool radiusBasedStartenergy; int staticParticleCount; int delay; @@ -339,6 +343,7 @@ public: void setPrimitive(Primitive primitive) {this->primitive= primitive;} void setStaticParticleCount(int staticParticleCount){this->staticParticleCount= staticParticleCount;} void setIsVisibleAtNight(bool value) {this->isVisibleAtNight= value;} + void setIsDaylightAffected(bool value) {this->isDaylightAffected= value;} void setIsVisibleAtDay(bool value) {this->isVisibleAtDay= value;} void setRadiusBasedStartenergy(bool value) {this->radiusBasedStartenergy= value;} void setShape(Shape shape) {this->shape= shape;} diff --git a/source/shared_lib/include/platform/posix/socket.h b/source/shared_lib/include/platform/posix/socket.h index de41b0f67..79d707217 100644 --- a/source/shared_lib/include/platform/posix/socket.h +++ b/source/shared_lib/include/platform/posix/socket.h @@ -253,7 +253,7 @@ public: virtual ~ServerSocket(); void bind(int port); void listen(int connectionQueueSize= SOMAXCONN); - Socket *accept(); + Socket *accept(bool errorOnFail=true); void stopBroadCastThread(); void pauseBroadcast(); diff --git a/source/shared_lib/include/platform/sdl/platform_main.h b/source/shared_lib/include/platform/sdl/platform_main.h index b332c8ff4..2c9f30524 100644 --- a/source/shared_lib/include/platform/sdl/platform_main.h +++ b/source/shared_lib/include/platform/sdl/platform_main.h @@ -388,7 +388,8 @@ int mainSetup(int argc, char **argv) { hasCommandArgument(argc, argv,string(GAME_ARGS[GAME_ARG_VERSION])) == true || hasCommandArgument(argc, argv,string(GAME_ARGS[GAME_ARG_SHOW_INI_SETTINGS])) == true || hasCommandArgument(argc, argv,string(GAME_ARGS[GAME_ARG_MASTERSERVER_MODE])) == true) { - if(SDL_Init(SDL_INIT_TIMER | SDL_INIT_JOYSTICK) < 0) { + // Use this for masterserver mode for timers like Chrono + if(SDL_Init(SDL_INIT_TIMER) < 0) { std::cerr << "Couldn't initialize SDL: " << SDL_GetError() << "\n"; return 1; } @@ -398,9 +399,9 @@ int mainSetup(int argc, char **argv) { std::cerr << "Couldn't initialize SDL: " << SDL_GetError() << "\n"; return 1; } + SDL_EnableUNICODE(1); + SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); } - SDL_EnableUNICODE(1); - SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); return 0; } diff --git a/source/shared_lib/include/platform/win32/types.h b/source/shared_lib/include/platform/win32/types.h index aaa5636a7..9aca92520 100644 --- a/source/shared_lib/include/platform/win32/types.h +++ b/source/shared_lib/include/platform/win32/types.h @@ -33,10 +33,9 @@ typedef unsigned int uint32; typedef long long int64; typedef unsigned long long uint64; -//typedef uint8 byte; - }}//end namespace +#ifndef __MINGW32__ // ISO C9x compliant stdint.h for Microsoft Visual Studio // Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124 @@ -287,3 +286,5 @@ typedef uint64_t uintmax_t; #endif // _MSC_STDINT_H_ ] #endif + +#endif diff --git a/source/shared_lib/include/util/string_utils.h b/source/shared_lib/include/util/string_utils.h index 5637bb089..90131be42 100644 --- a/source/shared_lib/include/util/string_utils.h +++ b/source/shared_lib/include/util/string_utils.h @@ -25,6 +25,10 @@ # include #include "types.h" +#ifdef __MINGW32__ +typedef unsigned char byte; +#endif + //! \name Macros for Shared::Util::String //@{ diff --git a/source/shared_lib/sources/graphics/font.cpp b/source/shared_lib/sources/graphics/font.cpp index bc3c8a553..8639d06e7 100644 --- a/source/shared_lib/sources/graphics/font.cpp +++ b/source/shared_lib/sources/graphics/font.cpp @@ -84,8 +84,11 @@ void Font::resetToDefaults() { #if defined(WIN32) string newEnvValue = "MEGAGLEST_FONT="; _putenv(newEnvValue.c_str()); + newEnvValue = "MEGAGLEST_FONT_FAMILY="; + _putenv(newEnvValue.c_str()); #else unsetenv("MEGAGLEST_FONT"); + unsetenv("MEGAGLEST_FONT_FAMILY"); #endif } @@ -212,11 +215,11 @@ string Font::getType() const { return this->type; } -void Font::setType(string typeX11, string typeGeneric) { +void Font::setType(string typeX11, string typeGeneric, string typeGenericFamily) { if(textHandler) { try { this->type= typeGeneric; - textHandler->init(typeGeneric,textHandler->GetFaceSize()); + textHandler->init(typeGeneric,typeGenericFamily,textHandler->GetFaceSize()); metrics.setTextHandler(this->textHandler); } catch(exception &ex) { @@ -269,54 +272,11 @@ Font3D::Font3D(FontTextHandlerType type) : Font(type) { depth= 10.f; } -const char* findFont(const char *firstFontToTry) { - const char* font = NULL; - const char* path = NULL; - - #define CHECK_FONT_PATH(filename) \ - { \ - path = filename; \ - if( !font && path && fileExists(path) == true ) \ - font = strdup(path); \ - if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Found font file [%s]\n",font); \ - } - - string tryFont = ""; - if(firstFontToTry) { - tryFont = firstFontToTry; - #ifdef WIN32 - replaceAll(tryFont, "/", "\\"); - #endif - - CHECK_FONT_PATH(tryFont.c_str()) - } - - // Get user-specified font path - if(getenv("MEGAGLEST_FONT") != NULL) { - tryFont = getenv("MEGAGLEST_FONT"); - #ifdef WIN32 - replaceAll(tryFont, "/", "\\"); - #endif - - CHECK_FONT_PATH(tryFont.c_str()) - } - - string data_path = Text::DEFAULT_FONT_PATH; - string defaultFont = data_path + "data/core/fonts/LinBiolinum_RB.ttf";//LinBiolinum_Re-0.6.4.ttf - tryFont = defaultFont; - #ifdef WIN32 - replaceAll(tryFont, "/", "\\"); - #endif - CHECK_FONT_PATH(tryFont.c_str()) - -#ifdef FONT_PATH - // Get distro-specified font path - CHECK_FONT_PATH(FONT_PATH) -#endif - +string findFontFamily(const char* font, const char *fontFamily) { + string resultFile = ""; #ifdef HAVE_FONTCONFIG // Get default font via fontconfig - if( !font && FcInit() ) { + if( !font && FcInit() && fontFamily) { FcResult result; FcFontSet *fs; FcPattern* pat; @@ -327,30 +287,107 @@ const char* findFont(const char *firstFontToTry) { name of a font that contains all the Unicode characters in use in your translation. */ - pat = FcNameParse((FcChar8 *)"Gothic Uralic"); + //pat = FcNameParse((FcChar8 *)"Gothic Uralic"); + pat = FcNameParse((FcChar8 *)fontFamily); FcConfigSubstitute(0, pat, FcMatchPattern); - FcPatternDel(pat, FC_WEIGHT); - FcPatternAddInteger(pat, FC_WEIGHT, FC_WEIGHT_BOLD); + //FcPatternDel(pat, FC_WEIGHT); + //FcPatternAddInteger(pat, FC_WEIGHT, FC_WEIGHT_BOLD); FcDefaultSubstitute(pat); fs = FcFontSetCreate(); match = FcFontMatch(0, pat, &result); + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Trying fontconfig for fontfamily [%s]\n",fontFamily); + if (match) FcFontSetAdd(fs, match); if (pat) FcPatternDestroy(pat); if(fs) { FcChar8* file; if( FcPatternGetString (fs->fonts[0], FC_FILE, 0, &file) == FcResultMatch ) { - CHECK_FONT_PATH((const char*)file) + //CHECK_FONT_PATH((const char*)file,NULL) + resultFile = (const char*)file; } FcFontSetDestroy(fs); } FcFini(); } +#else + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("******************* NO FONT CONFIG ENABLED!\n"); #endif - CHECK_FONT_PATH("/usr/share/fonts/truetype/uralic/gothub__.ttf") + return resultFile; +} + +const char* findFont(const char *firstFontToTry,const char *firstFontFamilyToTry) { + const char* font = NULL; + const char* path = NULL; + + #define CHECK_FONT_PATH(filename,fontFamily) \ + { \ + path = filename; \ + if( !font && path && strlen(path) > 0 && fileExists(path) == true ) { \ + font = strdup(path); \ + } \ + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("#1 Searching for font file [%s] result [%s]\n",path,font); \ + if( !font && fontFamily && strlen(fontFamily) > 0) { \ + string fileFound = findFontFamily(font, fontFamily); \ + if(fileFound != "") { \ + path = fileFound.c_str(); \ + if( !font && path && strlen(path) > 0 && fileExists(path) == true ) { \ + font = strdup(path); \ + } \ + } \ + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("#2 Searching for font family [%s] result [%s]\n",fontFamily,font); \ + } \ + } + + string tryFont = ""; + if(firstFontToTry || firstFontFamilyToTry) { + if(firstFontToTry && strlen(firstFontToTry) > 0) { + tryFont = firstFontToTry; + #ifdef WIN32 + replaceAll(tryFont, "/", "\\"); + #endif + + + CHECK_FONT_PATH(tryFont.c_str(),firstFontFamilyToTry) + } + else { + CHECK_FONT_PATH(NULL,firstFontFamilyToTry) + } + } + + // Get user-specified font path + if(getenv("MEGAGLEST_FONT") != NULL || getenv("MEGAGLEST_FONT_FAMILY") != NULL) { + + if(getenv("MEGAGLEST_FONT") != NULL) { + tryFont = getenv("MEGAGLEST_FONT"); + #ifdef WIN32 + replaceAll(tryFont, "/", "\\"); + #endif + + CHECK_FONT_PATH(tryFont.c_str(),getenv("MEGAGLEST_FONT_FAMILY")) + } + else { + CHECK_FONT_PATH(NULL,getenv("MEGAGLEST_FONT_FAMILY")) + } + } + + string data_path = Text::DEFAULT_FONT_PATH; + string defaultFont = data_path + "data/core/fonts/LinBiolinum_RB.ttf";//LinBiolinum_Re-0.6.4.ttf + tryFont = defaultFont; + #ifdef WIN32 + replaceAll(tryFont, "/", "\\"); + #endif + CHECK_FONT_PATH(tryFont.c_str(),"Linux Biolinum O:style=Bold") + +#ifdef FONT_PATH + // Get distro-specified font path + CHECK_FONT_PATH(FONT_PATH) +#endif + + CHECK_FONT_PATH("/usr/share/fonts/truetype/uralic/gothub__.ttf","Gothic Uralic:style=Regular") // Check a couple of common paths for Gothic Uralic/bold as a last resort // Debian @@ -359,44 +396,44 @@ const char* findFont(const char *firstFontToTry) { font that contains all the Unicode characters in use in your translation. If the font is available in Debian it should be the Debian path. */ - CHECK_FONT_PATH("/usr/share/fonts/truetype/uralic/gothub__.ttf") + CHECK_FONT_PATH("/usr/share/fonts/truetype/uralic/gothub__.ttf","Gothic Uralic:style=Regular") /* TRANSLATORS: If using the FTGL backend, this should be the path of a font that contains all the Unicode characters in use in your translation. If the font is available in Debian it should be the Debian path. */ - CHECK_FONT_PATH("/usr/share/fonts/truetype/uralic/gothu___.ttf") + CHECK_FONT_PATH("/usr/share/fonts/truetype/uralic/gothu___.ttf","Gothic Uralic:style=Regular") // Mandrake /* TRANSLATORS: If using the FTGL backend, this should be the path of a bold font that contains all the Unicode characters in use in your translation. If the font is available in Mandrake it should be the Mandrake path. */ - CHECK_FONT_PATH("/usr/share/fonts/TTF/uralic/GOTHUB__.TTF") + CHECK_FONT_PATH("/usr/share/fonts/TTF/uralic/GOTHUB__.TTF","Gothic Uralic:style=Bold") /* TRANSLATORS: If using the FTGL backend, this should be the path of a font that contains all the Unicode characters in use in your translation. If the font is available in Mandrake it should be the Mandrake path. */ - CHECK_FONT_PATH("/usr/share/fonts/TTF/uralic/GOTHU___.TTF") + CHECK_FONT_PATH("/usr/share/fonts/TTF/uralic/GOTHU___.TTF","Gothic Uralic:style=Regular") // Check the non-translated versions of the above - CHECK_FONT_PATH("/usr/share/fonts/truetype/uralic/gothub__.ttf") - CHECK_FONT_PATH("/usr/share/fonts/truetype/uralic/gothu___.ttf") - CHECK_FONT_PATH("/usr/share/fonts/TTF/uralic/GOTHUB__.TTF") - CHECK_FONT_PATH("/usr/share/fonts/TTF/uralic/GOTHU___.TTF") + CHECK_FONT_PATH("/usr/share/fonts/truetype/uralic/gothub__.ttf","Gothic Uralic:style=Regular") + CHECK_FONT_PATH("/usr/share/fonts/truetype/uralic/gothu___.ttf","Gothic Uralic:style=Regular") + CHECK_FONT_PATH("/usr/share/fonts/TTF/uralic/GOTHUB__.TTF","Gothic Uralic:style=Regular") + CHECK_FONT_PATH("/usr/share/fonts/TTF/uralic/GOTHU___.TTF","Gothic Uralic:style=Regular") - CHECK_FONT_PATH("/usr/share/fonts/truetype/linux-libertine/LinLibertine_Re.ttf") + CHECK_FONT_PATH("/usr/share/fonts/truetype/linux-libertine/LinLibertine_Re.ttf","Linux Libertine O:style=Regular") - CHECK_FONT_PATH("/usr/share/fonts/truetype/freefont/FreeSerif.ttf") - CHECK_FONT_PATH("/usr/share/fonts/truetype/freefont/FreeSans.ttf") - CHECK_FONT_PATH("/usr/share/fonts/truetype/freefont/FreeMono.ttf") + CHECK_FONT_PATH("/usr/share/fonts/truetype/freefont/FreeSerif.ttf","FreeSerif") + CHECK_FONT_PATH("/usr/share/fonts/truetype/freefont/FreeSans.ttf","FreeSans") + CHECK_FONT_PATH("/usr/share/fonts/truetype/freefont/FreeMono.ttf","FreeMono") #ifdef _WIN32 - CHECK_FONT_PATH("c:\\windows\\fonts\\verdana.ttf") - CHECK_FONT_PATH("c:\\windows\\fonts\\tahoma.ttf") - CHECK_FONT_PATH("c:\\windows\\fonts\\arial.ttf") - CHECK_FONT_PATH("\\windows\\fonts\\arial.ttf") + CHECK_FONT_PATH("c:\\windows\\fonts\\verdana.ttf",NULL) + CHECK_FONT_PATH("c:\\windows\\fonts\\tahoma.ttf",NULL) + CHECK_FONT_PATH("c:\\windows\\fonts\\arial.ttf",NULL) + CHECK_FONT_PATH("\\windows\\fonts\\arial.ttf",NULL) #endif return font; diff --git a/source/shared_lib/sources/graphics/font_text.cpp b/source/shared_lib/sources/graphics/font_text.cpp index a98a57d80..1738a2f81 100644 --- a/source/shared_lib/sources/graphics/font_text.cpp +++ b/source/shared_lib/sources/graphics/font_text.cpp @@ -19,7 +19,7 @@ Text::Text(FontTextHandlerType type) { this->type = type; } Text::~Text() {} -void Text::init(string fontName, int fontSize) {} +void Text::init(string fontName, string fontFamilyName, int fontSize) {} void Text::Render(const char*, const int) {} float Text::Advance(const char*, const int) {return 0;} float Text::LineHeight(const char*, const int) {return 0;} diff --git a/source/shared_lib/sources/graphics/gl/font_gl.cpp b/source/shared_lib/sources/graphics/gl/font_gl.cpp index 8bed8a5b2..9f2731acb 100644 --- a/source/shared_lib/sources/graphics/gl/font_gl.cpp +++ b/source/shared_lib/sources/graphics/gl/font_gl.cpp @@ -84,17 +84,16 @@ void Font3DGl::end() { }}}//end namespace -namespace Shared { namespace Graphics { - - using namespace Gl; -Font3D * ConvertFont2DTo3D(Font2D *font) { - - Font3D *result = new Font3DGl(); - result->setSize(font->getSize()); - result->setType("",font->getType()); - result->setWidth(font->getWidth()); - result->init(); - return result; -} - -}} +//namespace Shared { namespace Graphics { +// +// using namespace Gl; +//Font3D * ConvertFont2DTo3D(Font2D *font) { +// +// Font3D *result = new Font3DGl(); +// result->setSize(font->getSize()); +// result->setType("",font->getType()); +// result->setWidth(font->getWidth()); +// result->init(); +// return result; +//} +//}} diff --git a/source/shared_lib/sources/graphics/gl/font_textFTGL.cpp b/source/shared_lib/sources/graphics/gl/font_textFTGL.cpp index 8315c3da0..e854cfebb 100644 --- a/source/shared_lib/sources/graphics/gl/font_textFTGL.cpp +++ b/source/shared_lib/sources/graphics/gl/font_textFTGL.cpp @@ -78,7 +78,7 @@ TextFTGL::TextFTGL(FontTextHandlerType type) : Text(type) { delete ftFont; ftFont = NULL; free((void*)fontFile); fontFile = NULL; - throw runtime_error("FTGL: error loading font"); + throw runtime_error(string("FTGL: error loading font: ") + string(fontFile)); } free((void*)fontFile); fontFile = NULL; @@ -123,9 +123,9 @@ void TextFTGL::cleanupFont() { fontFile = NULL; } -void TextFTGL::init(string fontName, int fontSize) { +void TextFTGL::init(string fontName, string fontFamilyName, int fontSize) { cleanupFont(); - fontFile = findFont(fontName.c_str()); + fontFile = findFont(fontName.c_str(),fontFamilyName.c_str()); //ftFont = new FTBufferFont(fontFile); //ftFont = new FTGLPixmapFont(fontFile); diff --git a/source/shared_lib/sources/graphics/gl/font_text_freetypegl.cpp b/source/shared_lib/sources/graphics/gl/font_text_freetypegl.cpp index 05a7439a9..99e5cb680 100644 --- a/source/shared_lib/sources/graphics/gl/font_text_freetypegl.cpp +++ b/source/shared_lib/sources/graphics/gl/font_text_freetypegl.cpp @@ -38,7 +38,7 @@ TextFreetypeGL::TextFreetypeGL(FontTextHandlerType type) : Text(type) { font=NULL; manager=NULL; - init("", 24); + init("", "", 24); } TextFreetypeGL::~TextFreetypeGL() { @@ -52,10 +52,11 @@ void TextFreetypeGL::cleanupFont() { } } -void TextFreetypeGL::init(string fontName, int fontSize) { +void TextFreetypeGL::init(string fontName, string fontFamilyName, int fontSize) { cleanupFont(); this->fontName = fontName; - this->fontFile = findFont(this->fontName.c_str()); + this->fontFamilyName = fontFamilyName; + this->fontFile = findFont(this->fontName.c_str(),this->fontFamilyName.c_str()); this->fontFaceSize = fontSize; const wchar_t *cache = L" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"; @@ -77,7 +78,7 @@ void TextFreetypeGL::init(string fontName, int fontSize) { void TextFreetypeGL::SetFaceSize(int value) { this->fontFaceSize = value; - init(this->fontName,this->fontFaceSize); + init(this->fontName,this->fontFamilyName,this->fontFaceSize); } int TextFreetypeGL::GetFaceSize() { diff --git a/source/shared_lib/sources/graphics/model.cpp b/source/shared_lib/sources/graphics/model.cpp index 3cda78ad0..561d80424 100644 --- a/source/shared_lib/sources/graphics/model.cpp +++ b/source/shared_lib/sources/graphics/model.cpp @@ -141,28 +141,28 @@ void Mesh::BuildVBOs() { glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nVBOVertices ); // Bind The Buffer // Load The Data glBufferDataARB( GL_ARRAY_BUFFER_ARB, sizeof(Vec3f)*frameCount*vertexCount, getInterpolationData()->getVertices(), GL_STATIC_DRAW_ARB ); - glBindBuffer(GL_ARRAY_BUFFER_ARB, 0); + glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); // Generate And Bind The Texture Coordinate Buffer glGenBuffersARB( 1, (GLuint*)&m_nVBOTexCoords ); // Get A Valid Name glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nVBOTexCoords ); // Bind The Buffer // Load The Data glBufferDataARB( GL_ARRAY_BUFFER_ARB, sizeof(Vec2f)*vertexCount, texCoords, GL_STATIC_DRAW_ARB ); - glBindBuffer(GL_ARRAY_BUFFER_ARB, 0); + glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); // Generate And Bind The Normal Buffer glGenBuffersARB( 1, (GLuint*)&m_nVBONormals ); // Get A Valid Name glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nVBONormals ); // Bind The Buffer // Load The Data glBufferDataARB( GL_ARRAY_BUFFER_ARB, sizeof(Vec3f)*frameCount*vertexCount, getInterpolationData()->getNormals(), GL_STATIC_DRAW_ARB ); - glBindBuffer(GL_ARRAY_BUFFER_ARB, 0); + glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); // Generate And Bind The Index Buffer glGenBuffersARB( 1, (GLuint*)&m_nVBOIndexes ); // Get A Valid Name glBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, m_nVBOIndexes ); // Bind The Buffer // Load The Data glBufferDataARB( GL_ELEMENT_ARRAY_BUFFER_ARB, sizeof(uint32)*indexCount, indices, GL_STATIC_DRAW_ARB ); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER_ARB, 0); + glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0); // Our Copy Of The Data Is No Longer Necessary, It Is Safe In The Graphics Card delete [] vertices; vertices = NULL; diff --git a/source/shared_lib/sources/graphics/particle.cpp b/source/shared_lib/sources/graphics/particle.cpp index 0a0a8a0e8..922e80407 100644 --- a/source/shared_lib/sources/graphics/particle.cpp +++ b/source/shared_lib/sources/graphics/particle.cpp @@ -74,6 +74,7 @@ ParticleSystem::ParticleSystem(int particleCount) { teamcolorNoEnergy= false; teamcolorEnergy= false; alternations= 0; + particleSystemStartDelay= 0; } ParticleSystem::~ParticleSystem(){ @@ -97,8 +98,10 @@ void ParticleSystem::update(){ if(aliveParticleCount > (int) particles.size()){ throw runtime_error("aliveParticleCount >= particles.size()"); } - - if(state != sPause){ + if(particleSystemStartDelay>0){ + particleSystemStartDelay--; + } + else if(state != sPause){ for(int i= 0; i < aliveParticleCount; ++i){ updateParticle(&particles[i]); @@ -527,6 +530,7 @@ void GameParticleSystem::setTween(float relative,float absolute) { // UnitParticleSystem // =========================================================================== bool UnitParticleSystem::isNight= false; +Vec3f UnitParticleSystem::lightColor=Vec3f(1.0f,1.0f,1.0f); UnitParticleSystem::UnitParticleSystem(int particleCount): GameParticleSystem(particleCount), @@ -537,11 +541,14 @@ UnitParticleSystem::UnitParticleSystem(int particleCount): setParticleSize(0.6f); setColorNoEnergy(Vec4f(1.0f, 0.5f, 0.0f, 1.0f)); + sizeNoEnergy=1.0f; primitive= pQuad; gravity= 0.0f; fixed= false; + shape = UnitParticleSystem::sLinear; + angle= 0.0f; rotation= 0.0f; relativeDirection= true; relative= false; @@ -549,6 +556,7 @@ UnitParticleSystem::UnitParticleSystem(int particleCount): isVisibleAtNight= true; isVisibleAtDay= true; + isDaylightAffected= false; cRotation= Vec3f(1.0f, 1.0f, 1.0f); fixedAddition= Vec3f(0.0f, 0.0f, 0.0f); @@ -560,6 +568,7 @@ UnitParticleSystem::UnitParticleSystem(int particleCount): delay = 0; // none lifetime = -1; // forever + emissionRateFade=0.0f; startTime = 0; endTime = 1; @@ -736,6 +745,12 @@ void UnitParticleSystem::updateParticle(Particle *p){ } p->speed+= p->accel; p->color= color * energyRatio + colorNoEnergy * (1.0f - energyRatio); + if(isDaylightAffected==true) + { + p->color.x=p->color.x*lightColor.x; + p->color.y=p->color.y*lightColor.y; + p->color.z=p->color.z*lightColor.z; + } p->size= particleSize * energyRatio + sizeNoEnergy * (1.0f - energyRatio); if(state == ParticleSystem::sFade || staticParticleCount < 1){ p->energy--; diff --git a/source/shared_lib/sources/graphics/pixmap.cpp b/source/shared_lib/sources/graphics/pixmap.cpp index d77933ebb..7e7b55601 100644 --- a/source/shared_lib/sources/graphics/pixmap.cpp +++ b/source/shared_lib/sources/graphics/pixmap.cpp @@ -916,20 +916,30 @@ Pixmap2D::~Pixmap2D() { void Pixmap2D::Scale(int format, int newW, int newH) { int useComponents = this->getComponents(); + int originalW = w; + int originalH = h; uint8 *newpixels= new uint8[newW * newH * useComponents]; glPixelStorei(GL_PACK_ALIGNMENT, 1); int error = gluScaleImage( format, w, h, GL_UNSIGNED_BYTE, pixels, newW, newH, GL_UNSIGNED_BYTE, newpixels); - if(error != GL_NO_ERROR) { + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + + if(error == GL_NO_ERROR) { init(newW,newH,this->components); pixels = newpixels; + + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Scaled image from [%d x %d] to [%d x %d]\n",originalW,originalH,w,h); } else { - assertGl(); + const char *errorString= reinterpret_cast(gluErrorString(error)); + printf("ERROR Scaling image from [%d x %d] to [%d x %d] error: %d [%s]\n",originalW,originalH,w,h,error,errorString); + + GLenum glErr = error; + assertGlWithErrorNumber(glErr); } - glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + CalculatePixelsCRC(pixels,getPixelByteCount(), crc); } diff --git a/source/shared_lib/sources/graphics/texture.cpp b/source/shared_lib/sources/graphics/texture.cpp index a9595fd86..1922a7447 100644 --- a/source/shared_lib/sources/graphics/texture.cpp +++ b/source/shared_lib/sources/graphics/texture.cpp @@ -26,6 +26,16 @@ const int Texture::defaultSize = 256; const int Texture::defaultComponents = 4; bool Texture::useTextureCompression = false; +/* Quick utility function for texture creation */ +static int powerOfTwo(int input) { + int value = 1; + + while (value < input) { + value <<= 1; + } + return value; +} + Texture::Texture() { assert(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == false); @@ -86,6 +96,102 @@ SDL_Surface* Texture2D::CreateSDLSurface(bool newPixelData) const { delete[] surfData; } +// SDL_Surface *prepGLTexture(SDL_Surface *surface, GLfloat *texCoords = NULL, const bool +// freeSource = false) { + /* Use the surface width and height expanded to powers of 2 */ + //int w = powerOfTwo(surface->w); + //int h = powerOfTwo(surface->h); + int w = surface->w; + int h = surface->h; + +// if (texCoords != 0) { +// texCoords[0] = 0.0f; /* Min +// X */ +// texCoords[1] = 0.0f; /* Min +// Y */ +// texCoords[2] = (GLfloat)surface->w / w; /* Max X */ +// texCoords[3] = (GLfloat)surface->h / h; /* Max Y */ +// } + + SDL_Surface *image = SDL_CreateRGBSurface( + SDL_SWSURFACE, + w, h, + 32, + #if SDL_BYTEORDER == SDL_LIL_ENDIAN /* OpenGL RGBA masks */ + 0x000000FF, + 0x0000FF00, + 0x00FF0000, + 0xFF000000 + #else + 0xFF000000, + 0x00FF0000, + 0x0000FF00, + 0x000000FF + #endif + ); + if ( image == NULL ) { + return 0; + } + + /* Save the alpha blending attributes */ + Uint32 savedFlags = surface->flags&(SDL_SRCALPHA|SDL_RLEACCELOK); + Uint8 savedAlpha = surface->format->alpha; + if ( (savedFlags & SDL_SRCALPHA) == SDL_SRCALPHA ) { + SDL_SetAlpha(surface, 0, 0); + } + + SDL_Rect srcArea, destArea; + /* Copy the surface into the GL texture image */ + srcArea.x = 0; destArea.x = 0; + /* Copy it in at the bottom, because we're going to flip + this image upside-down in a moment + */ + srcArea.y = 0; destArea.y = h - surface->h; + srcArea.w = surface->w; + srcArea.h = surface->h; + SDL_BlitSurface(surface, &srcArea, image, &destArea); + + /* Restore the alpha blending attributes */ + if ((savedFlags & SDL_SRCALPHA) == SDL_SRCALPHA) { + SDL_SetAlpha(surface, savedFlags, savedAlpha); + } + + /* Turn the image upside-down, because OpenGL textures + start at the bottom-left, instead of the top-left + */ + #ifdef _MSC_VER + Uint8 *line = new Uint8[image->pitch]; + #else + Uint8 line[image->pitch]; + #endif + /* These two make the following more readable */ + Uint8 *pixels = static_cast(image->pixels); + Uint16 pitch = image->pitch; + int ybegin = 0; + int yend = image->h - 1; + + // TODO: consider if this lock is legal/appropriate + if (SDL_MUSTLOCK(image)) { SDL_LockSurface(image); } + while (ybegin < yend) { + memcpy(line, pixels + pitch*ybegin, pitch); + memcpy(pixels + pitch*ybegin, pixels + pitch*yend, pitch); + memcpy(pixels + pitch*yend, line, pitch); + ybegin++; + yend--; + } + if (SDL_MUSTLOCK(image)) { SDL_UnlockSurface(image); } + +// if (freeSource) { +// SDL_FreeSurface(surface); +// } + + #ifdef _MSC_VER + delete[] line; + #endif + + return image; +// } + return surface; } diff --git a/source/shared_lib/sources/lua/lua_script.cpp b/source/shared_lib/sources/lua/lua_script.cpp index 2bdea2f53..1194fbfcf 100644 --- a/source/shared_lib/sources/lua/lua_script.cpp +++ b/source/shared_lib/sources/lua/lua_script.cpp @@ -192,7 +192,7 @@ void * LuaArguments::getGenericData(int argumentIndex) const{ if(lua_isstring(luaState, argumentIndex)) { const char *result = luaL_checkstring(luaState, argumentIndex); - printf("\nGENERIC param %d is a string, %s!\n",argumentIndex,result); + //printf("\nGENERIC param %d is a string, %s!\n",argumentIndex,result); return (void *)result; } //else if(lua_isnumber(luaState, argumentIndex)) { @@ -202,11 +202,11 @@ void * LuaArguments::getGenericData(int argumentIndex) const{ //} else if(lua_isnumber(luaState, argumentIndex)) { lua_Integer result = luaL_checkinteger(luaState, argumentIndex); - printf("\nGENERIC param %d is an int, %d!\n",argumentIndex,(int)result); + //printf("\nGENERIC param %d is an int, %d!\n",argumentIndex,(int)result); return (void *)result; } else { - printf("\nGENERIC param %d is a NULL!\n",argumentIndex); + //printf("\nGENERIC param %d is a NULL!\n",argumentIndex); return NULL; } } diff --git a/source/shared_lib/sources/platform/common/platform_common.cpp b/source/shared_lib/sources/platform/common/platform_common.cpp index 9ed0f029f..3f23c8803 100644 --- a/source/shared_lib/sources/platform/common/platform_common.cpp +++ b/source/shared_lib/sources/platform/common/platform_common.cpp @@ -1587,6 +1587,11 @@ bool changeVideoMode(int resW, int resH, int colorBits, int ) { void restoreVideoMode(bool exitingApp) { //SDL_Quit(); + if(exitingApp == true && SDL_WasInit(SDL_INIT_VIDEO)) { + SDL_ShowCursor(1); + SDL_WM_GrabInput(SDL_GRAB_OFF); + //SDL_SetGamma(1, 1, 1); + } } int getScreenW() { diff --git a/source/shared_lib/sources/platform/posix/socket.cpp b/source/shared_lib/sources/platform/posix/socket.cpp index 64c64998a..80950ed63 100644 --- a/source/shared_lib/sources/platform/posix/socket.cpp +++ b/source/shared_lib/sources/platform/posix/socket.cpp @@ -313,7 +313,7 @@ string Ip::getString() const{ // class Socket // =============================================== -#if defined(__FreeBSD__) || defined(BSD) || defined(__APPLE__) || defined(__linux__) +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(BSD) || defined(__APPLE__) || defined(__linux__) # define USE_GETIFADDRS 1 # include #endif @@ -768,7 +768,7 @@ bool Socket::isSocketValid() const { bool Socket::isSocketValid(const PLATFORM_SOCKET *validateSocket) { #ifdef WIN32 - if(validateSocket == NULL) { + if(validateSocket == NULL || (*validateSocket) == 0) { return false; } else { @@ -959,6 +959,8 @@ void Socket::disconnectSocket() { MutexSafeWrapper safeMutex(dataSynchAccessorRead,CODE_AT_LINE); MutexSafeWrapper safeMutex1(dataSynchAccessorWrite,CODE_AT_LINE); + + if(isSocketValid() == true) { ::shutdown(sock,2); #ifndef WIN32 ::close(sock); @@ -967,6 +969,7 @@ void Socket::disconnectSocket() { ::closesocket(sock); sock = -1; #endif + } safeMutex.ReleaseLock(); safeMutex1.ReleaseLock(); } @@ -985,6 +988,7 @@ bool Socket::hasDataToRead(std::map &socketTriggeredList) fd_set rfds; FD_ZERO(&rfds); + string socketDebugList = ""; PLATFORM_SOCKET imaxsocket = 0; for(std::map::iterator itermap = socketTriggeredList.begin(); itermap != socketTriggeredList.end(); ++itermap) @@ -994,6 +998,11 @@ bool Socket::hasDataToRead(std::map &socketTriggeredList) { FD_SET(socket, &rfds); imaxsocket = max(socket,imaxsocket); + + if(socketDebugList != "") { + socketDebugList += ","; + } + socketDebugList += intToStr(socket); } } @@ -1012,7 +1021,7 @@ bool Socket::hasDataToRead(std::map &socketTriggeredList) } if(retval < 0) { - if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] ERROR SELECTING SOCKET DATA retval = %d error = %s\n",__FILE__,__FUNCTION__,retval,getLastSocketErrorFormattedText().c_str()); + if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] Line: %d, ERROR SELECTING SOCKET DATA retval = %d error = %s, socketDebugList [%s]\n",__FILE__,__FUNCTION__,__LINE__,retval,getLastSocketErrorFormattedText().c_str(),socketDebugList.c_str()); } else if(retval) { @@ -1147,7 +1156,8 @@ int Socket::getDataToRead(bool wantImmediateReply) { #else int err= ioctlsocket(sock, FIONREAD, &size); #endif - if(err < 0 && getLastSocketError() != PLATFORM_SOCKET_TRY_AGAIN) + int lastSocketError = getLastSocketError(); + if(err < 0 && lastSocketError != PLATFORM_SOCKET_TRY_AGAIN) { if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] ERROR PEEKING SOCKET DATA, err = %d %s\n",__FILE__,__FUNCTION__,__LINE__,err,getLastSocketErrorFormattedText().c_str()); break; @@ -1201,11 +1211,13 @@ int Socket::send(const void *data, int dataSize) { MutexSafeWrapper safeMutex(dataSynchAccessorWrite,CODE_AT_LINE); + if(isSocketValid() == true) { #ifdef __APPLE__ bytesSent = ::send(sock, (const char *)data, dataSize, SO_NOSIGPIPE); #else bytesSent = ::send(sock, (const char *)data, dataSize, MSG_NOSIGNAL | MSG_DONTWAIT); #endif + } safeMutex.ReleaseLock(); } @@ -1213,15 +1225,16 @@ int Socket::send(const void *data, int dataSize) { //bytesSent = -1; // END TEST - if(bytesSent < 0 && getLastSocketError() != PLATFORM_SOCKET_TRY_AGAIN) { - if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] ERROR WRITING SOCKET DATA, err = %d error = %s\n",__FILE__,__FUNCTION__,__LINE__,bytesSent,getLastSocketErrorFormattedText().c_str()); + int lastSocketError = getLastSocketError(); + if(bytesSent < 0 && lastSocketError != PLATFORM_SOCKET_TRY_AGAIN) { + if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] ERROR WRITING SOCKET DATA, err = %d error = %s\n",__FILE__,__FUNCTION__,__LINE__,bytesSent,getLastSocketErrorFormattedText(&lastSocketError).c_str()); } - else if(bytesSent < 0 && getLastSocketError() == PLATFORM_SOCKET_TRY_AGAIN && isConnected() == true) { + else if(bytesSent < 0 && lastSocketError == PLATFORM_SOCKET_TRY_AGAIN && isConnected() == true) { if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] #1 EAGAIN during send, trying again...\n",__FILE__,__FUNCTION__,__LINE__); int attemptCount = 0; time_t tStartTimer = time(NULL); - while((bytesSent < 0 && getLastSocketError() == PLATFORM_SOCKET_TRY_AGAIN) && + while((bytesSent < 0 && lastSocketError == PLATFORM_SOCKET_TRY_AGAIN) && (difftime(time(NULL),tStartTimer) <= MAX_SEND_WAIT_SECONDS)) { attemptCount++; if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] attemptCount = %d\n",__FILE__,__FUNCTION__,__LINE__,attemptCount); @@ -1243,7 +1256,8 @@ int Socket::send(const void *data, int dataSize) { #else bytesSent = ::send(sock, (const char *)data, dataSize, MSG_NOSIGNAL | MSG_DONTWAIT); #endif - if(bytesSent < 0 && getLastSocketError() != PLATFORM_SOCKET_TRY_AGAIN) { + lastSocketError = getLastSocketError(); + if(bytesSent < 0 && lastSocketError != PLATFORM_SOCKET_TRY_AGAIN) { break; } @@ -1264,13 +1278,16 @@ int Socket::send(const void *data, int dataSize) { } if(isConnected() == true && bytesSent > 0 && bytesSent < dataSize) { - if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] need to send more data, trying again getLastSocketError() = %d, bytesSent = %d, dataSize = %d\n",__FILE__,__FUNCTION__,__LINE__,getLastSocketError(),bytesSent,dataSize); + lastSocketError = getLastSocketError(); + if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] need to send more data, trying again getLastSocketError() = %d, bytesSent = %d, dataSize = %d\n",__FILE__,__FUNCTION__,__LINE__,lastSocketError,bytesSent,dataSize); int totalBytesSent = bytesSent; int attemptCount = 0; + + time_t tStartTimer = time(NULL); while(((bytesSent > 0 && totalBytesSent < dataSize) || - (bytesSent < 0 && getLastSocketError() == PLATFORM_SOCKET_TRY_AGAIN)) && + (bytesSent < 0 && lastSocketError == PLATFORM_SOCKET_TRY_AGAIN)) && (difftime(time(NULL),tStartTimer) <= MAX_SEND_WAIT_SECONDS)) { attemptCount++; if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] attemptCount = %d, totalBytesSent = %d\n",__FILE__,__FUNCTION__,__LINE__,attemptCount,totalBytesSent); @@ -1293,11 +1310,12 @@ int Socket::send(const void *data, int dataSize) { #else bytesSent = ::send(sock, &sendBuf[totalBytesSent], dataSize - totalBytesSent, MSG_NOSIGNAL | MSG_DONTWAIT); #endif + lastSocketError = getLastSocketError(); if(bytesSent > 0) { totalBytesSent += bytesSent; } - if(bytesSent < 0 && getLastSocketError() != PLATFORM_SOCKET_TRY_AGAIN) { + if(bytesSent < 0 && lastSocketError != PLATFORM_SOCKET_TRY_AGAIN) { break; } @@ -1352,17 +1370,20 @@ int Socket::receive(void *data, int dataSize, bool tryReceiveUntilDataSizeMet) { // safeMutexSocketDestructorFlag.ReleaseLock(); MutexSafeWrapper safeMutex(dataSynchAccessorRead,CODE_AT_LINE); - bytesReceived = recv(sock, reinterpret_cast(data), dataSize, 0); + if(isSocketValid() == true) { + bytesReceived = recv(sock, reinterpret_cast(data), dataSize, 0); + } safeMutex.ReleaseLock(); } - if(bytesReceived < 0 && getLastSocketError() != PLATFORM_SOCKET_TRY_AGAIN) { - if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"[%s::%s Line: %d] ERROR READING SOCKET DATA error while sending socket data, bytesSent = %d, error = %s\n",__FILE__,__FUNCTION__,__LINE__,bytesReceived,getLastSocketErrorFormattedText().c_str()); + int lastSocketError = getLastSocketError(); + if(bytesReceived < 0 && lastSocketError != PLATFORM_SOCKET_TRY_AGAIN) { + if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"[%s::%s Line: %d] ERROR READING SOCKET DATA error while sending socket data, bytesSent = %d, error = %s\n",__FILE__,__FUNCTION__,__LINE__,bytesReceived,getLastSocketErrorFormattedText(&lastSocketError).c_str()); } - else if(bytesReceived < 0 && getLastSocketError() == PLATFORM_SOCKET_TRY_AGAIN) { + else if(bytesReceived < 0 && lastSocketError == PLATFORM_SOCKET_TRY_AGAIN) { if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] #1 EAGAIN during receive, trying again...\n",__FILE__,__FUNCTION__,__LINE__); time_t tStartTimer = time(NULL); - while((bytesReceived < 0 && getLastSocketError() == PLATFORM_SOCKET_TRY_AGAIN) && + while((bytesReceived < 0 && lastSocketError == PLATFORM_SOCKET_TRY_AGAIN) && (difftime(time(NULL),tStartTimer) <= MAX_RECV_WAIT_SECONDS)) { if(isConnected() == false) { int iErr = getLastSocketError(); @@ -1382,6 +1403,7 @@ int Socket::receive(void *data, int dataSize, bool tryReceiveUntilDataSizeMet) { MutexSafeWrapper safeMutex(dataSynchAccessorRead,CODE_AT_LINE); bytesReceived = recv(sock, reinterpret_cast(data), dataSize, 0); + lastSocketError = getLastSocketError(); safeMutex.ReleaseLock(); if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] #2 EAGAIN during receive, trying again returned: %d\n",__FILE__,__FUNCTION__,__LINE__,bytesReceived); @@ -1442,8 +1464,9 @@ int Socket::peek(void *data, int dataSize,bool mustGetData) { MutexSafeWrapper safeMutex(dataSynchAccessorRead,CODE_AT_LINE); //if(chrono.getMillis() > 1) printf("In [%s::%s Line: %d] action running for msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,(long long int)chrono.getMillis()); - - err = recv(sock, reinterpret_cast(data), dataSize, MSG_PEEK); + if(isSocketValid() == true) { + err = recv(sock, reinterpret_cast(data), dataSize, MSG_PEEK); + } safeMutex.ReleaseLock(); //printf("Peek #1 err = %d\n",err); @@ -1452,17 +1475,18 @@ int Socket::peek(void *data, int dataSize,bool mustGetData) { } //if(chrono.getMillis() > 1) printf("In [%s::%s Line: %d] action running for msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,(long long int)chrono.getMillis()); - if(err < 0 && getLastSocketError() != PLATFORM_SOCKET_TRY_AGAIN) { + int lastSocketError = getLastSocketError(); + if(err < 0 && lastSocketError != PLATFORM_SOCKET_TRY_AGAIN) { if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"[%s::%s Line: %d] ERROR PEEKING SOCKET DATA error while sending socket data, err = %d, error = %s\n",__FILE__,__FUNCTION__,__LINE__,err,getLastSocketErrorFormattedText().c_str()); disconnectSocket(); } - else if(err < 0 && getLastSocketError() == PLATFORM_SOCKET_TRY_AGAIN && mustGetData == true) { + else if(err < 0 && lastSocketError == PLATFORM_SOCKET_TRY_AGAIN && mustGetData == true) { if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] #1 ERROR EAGAIN during peek, trying again...\n",__FILE__,__FUNCTION__,__LINE__); //printf("Peek #2 err = %d\n",err); time_t tStartTimer = time(NULL); - while((err < 0 && getLastSocketError() == PLATFORM_SOCKET_TRY_AGAIN) && + while((err < 0 && lastSocketError == PLATFORM_SOCKET_TRY_AGAIN) && (difftime(time(NULL),tStartTimer) <= MAX_PEEK_WAIT_SECONDS)) { /* if(isConnected() == false) { @@ -1484,6 +1508,7 @@ int Socket::peek(void *data, int dataSize,bool mustGetData) { //MutexSafeWrapper safeMutex(&dataSynchAccessor,CODE_AT_LINE + "_" + intToStr(sock) + "_" + intToStr(dataSize)); MutexSafeWrapper safeMutex(dataSynchAccessorRead,CODE_AT_LINE); err = recv(sock, reinterpret_cast(data), dataSize, MSG_PEEK); + lastSocketError = getLastSocketError(); safeMutex.ReleaseLock(); if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) if(chrono.getMillis() > 1) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] action running for msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,(long long int)chrono.getMillis()); @@ -1498,8 +1523,9 @@ int Socket::peek(void *data, int dataSize,bool mustGetData) { if(err <= 0) { //printf("Peek #3 err = %d\n",err); - if(mustGetData == true || getLastSocketError() != PLATFORM_SOCKET_TRY_AGAIN) { - int iErr = getLastSocketError(); + lastSocketError = getLastSocketError(); + if(mustGetData == true || lastSocketError != PLATFORM_SOCKET_TRY_AGAIN) { + int iErr = lastSocketError; disconnectSocket(); if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"[%s::%s Line: %d] DISCONNECTED SOCKET error while peeking socket data, err = %d, error = %s\n",__FILE__,__FUNCTION__,__LINE__,err,getLastSocketErrorFormattedText(&iErr).c_str()); @@ -1761,8 +1787,9 @@ void ClientSocket::connect(const Ip &ip, int port) if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] #2 Error connecting socket for IP: %s for Port: %d err = %d error = %s\n",__FILE__,__FUNCTION__,__LINE__,ip.getString().c_str(),port,err,getLastSocketErrorFormattedText().c_str()); if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] #2 Error connecting socket for IP: %s for Port: %d err = %d error = %s\n",__FILE__,__FUNCTION__,__LINE__,ip.getString().c_str(),port,err,getLastSocketErrorFormattedText().c_str()); - if (getLastSocketError() == PLATFORM_SOCKET_INPROGRESS || - getLastSocketError() == PLATFORM_SOCKET_TRY_AGAIN) { + int lastSocketError = getLastSocketError(); + if (lastSocketError == PLATFORM_SOCKET_INPROGRESS || + lastSocketError == PLATFORM_SOCKET_TRY_AGAIN) { fd_set myset; struct timeval tv; int valopt=0; @@ -1781,10 +1808,11 @@ void ClientSocket::connect(const Ip &ip, int port) { MutexSafeWrapper safeMutex(dataSynchAccessorRead,CODE_AT_LINE); err = select((int)sock + 1, NULL, &myset, NULL, &tv); + lastSocketError = getLastSocketError(); //safeMutex.ReleaseLock(); } - if (err < 0 && getLastSocketError() != PLATFORM_SOCKET_INTERRUPTED) { + if (err < 0 && lastSocketError != PLATFORM_SOCKET_INTERRUPTED) { if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] Error connecting %s\n",__FILE__,__FUNCTION__,__LINE__,getLastSocketErrorFormattedText().c_str()); if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] Error connecting %s\n",__FILE__,__FUNCTION__,__LINE__,getLastSocketErrorFormattedText().c_str()); @@ -1900,7 +1928,7 @@ void BroadCastClientSocketThread::execute() { #else setsockopt(bcfd, SOL_SOCKET, SO_REUSEADDR, (char *)&val, sizeof(val)); #endif - if(bind( bcfd, (struct sockaddr *)&bcaddr, sizeof(bcaddr) ) < 0 ) { + if(::bind( bcfd, (struct sockaddr *)&bcaddr, sizeof(bcaddr) ) < 0 ) { if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"bind failed: %s\n", getLastSocketErrorFormattedText().c_str()); } else { @@ -2189,9 +2217,14 @@ void ServerSocket::listen(int connectionQueueSize) { } } -Socket *ServerSocket::accept() { +Socket *ServerSocket::accept(bool errorOnFail) { if(isSocketValid() == false) { - throwException("socket is invalid!"); + if(errorOnFail == true) { + throwException("socket is invalid!"); + } + else { + return NULL; + } } struct sockaddr_in cli_addr; @@ -2206,11 +2239,16 @@ Socket *ServerSocket::accept() { sprintf(szBuf, "In [%s::%s Line: %d] Error accepting socket connection sock = %d, err = %d, error = %s\n",__FILE__,__FUNCTION__,__LINE__,sock,newSock,getLastSocketErrorFormattedText().c_str()); if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] %s\n",__FILE__,__FUNCTION__,__LINE__,szBuf); - if(getLastSocketError() == PLATFORM_SOCKET_TRY_AGAIN) - { + int lastSocketError = getLastSocketError(); + if(lastSocketError == PLATFORM_SOCKET_TRY_AGAIN) { + return NULL; + } + if(errorOnFail == true) { + throwException(szBuf); + } + else { return NULL; } - throwException(szBuf); } else { diff --git a/source/shared_lib/sources/platform/sdl/gl_wrap.cpp b/source/shared_lib/sources/platform/sdl/gl_wrap.cpp index 692d0655b..3a3fd6bbe 100644 --- a/source/shared_lib/sources/platform/sdl/gl_wrap.cpp +++ b/source/shared_lib/sources/platform/sdl/gl_wrap.cpp @@ -137,13 +137,14 @@ void PlatformContextGl::init(int colorBits, int depthBits, int stencilBits,bool //uint32 colorkey = SDL_MapRGB(icon->format, 255, 0, 255); //SDL_SetColorKey(icon, SDL_SRCCOLORKEY, colorkey); + SDL_SetColorKey(icon, SDL_SRCCOLORKEY, SDL_MapRGB(icon->format, 255, 0, 255)); SDL_WM_SetIcon(icon, NULL); } } #endif - if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] about to set resolution: %d x %d, colorBits = %d.\n",__FILE__,__FUNCTION__,__LINE__,resW,resH,colorBits); + if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] about to set resolution: %d x %d, colorBits = %d.\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,resW,resH,colorBits); if(screen != NULL) { SDL_FreeSurface(screen); @@ -159,8 +160,8 @@ void PlatformContextGl::init(int colorBits, int depthBits, int stencilBits,bool << "bpp " << stencilBits << " stencil " << depthBits << " depth-buffer). SDL Error is: " << SDL_GetError(); - if(SystemFlags::getSystemSettingType(SystemFlags::debugError).enabled) SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] error [%s]\n",__FILE__,__FUNCTION__,__LINE__,msg.str().c_str()); - if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] error [%s]\n",__FILE__,__FUNCTION__,__LINE__,msg.str().c_str()); + if(SystemFlags::getSystemSettingType(SystemFlags::debugError).enabled) SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] error [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,msg.str().c_str()); + if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] error [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,msg.str().c_str()); for(int i = 32; i >= 8; i-=8) { // try different color bits diff --git a/source/shared_lib/sources/platform/sdl/window.cpp b/source/shared_lib/sources/platform/sdl/window.cpp index fdbb19867..2ff6e2cfd 100644 --- a/source/shared_lib/sources/platform/sdl/window.cpp +++ b/source/shared_lib/sources/platform/sdl/window.cpp @@ -128,7 +128,7 @@ bool Window::handleEvent() { case SDL_MOUSEBUTTONUP: case SDL_MOUSEMOTION: - //printf("In [%s::%s] Line :%d\n",__FILE__,__FUNCTION__,__LINE__); + //printf("In [%s::%s] Line :%d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); codeLocation = "d"; setLastMouseEvent(Chrono::getCurMillis()); @@ -140,21 +140,21 @@ bool Window::handleEvent() { switch(event.type) { case SDL_QUIT: - //printf("In [%s::%s] Line :%d\n",__FILE__,__FUNCTION__,__LINE__); + //printf("In [%s::%s] Line :%d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); codeLocation = "e"; return false; case SDL_MOUSEBUTTONDOWN: - //printf("In [%s::%s] Line :%d\n",__FILE__,__FUNCTION__,__LINE__); + //printf("In [%s::%s] Line :%d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); codeLocation = "f"; if(global_window) { - if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); + if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); global_window->handleMouseDown(event); - if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); + if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); } break; case SDL_MOUSEBUTTONUP: { - //printf("In [%s::%s] Line :%d\n",__FILE__,__FUNCTION__,__LINE__); + //printf("In [%s::%s] Line :%d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); codeLocation = "g"; if(global_window) { MouseButton b = getMouseButton(event.button.button); @@ -166,7 +166,7 @@ bool Window::handleEvent() { break; } case SDL_MOUSEMOTION: { - //printf("In [%s::%s] Line :%d\n",__FILE__,__FUNCTION__,__LINE__); + //printf("In [%s::%s] Line :%d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); //MouseState ms; //ms.leftMouse = (event.motion.state & SDL_BUTTON_LMASK) != 0; //ms.rightMouse = (event.motion.state & SDL_BUTTON_RMASK) != 0; @@ -183,11 +183,11 @@ bool Window::handleEvent() { break; } case SDL_KEYDOWN: - //printf("In [%s::%s] Line :%d\n",__FILE__,__FUNCTION__,__LINE__); + //printf("In [%s::%s] Line :%d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); { - if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] =================================== START OF SDL SDL_KEYDOWN ================================\n",__FILE__,__FUNCTION__,__LINE__); + if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] =================================== START OF SDL SDL_KEYDOWN ================================\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); codeLocation = "i"; Window::isKeyPressedDown = true; @@ -198,20 +198,20 @@ bool Window::handleEvent() { keystate = event.key.keysym; string keyName = SDL_GetKeyName(event.key.keysym.sym); - if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] Raw SDL key [%d - %c] mod [%d] unicode [%d - %c] scancode [%d] keyName [%s]\n",__FILE__,__FUNCTION__,__LINE__,event.key.keysym.sym,event.key.keysym.sym,event.key.keysym.mod,event.key.keysym.unicode,event.key.keysym.unicode,event.key.keysym.scancode,keyName.c_str()); - if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Raw SDL key [%d] mod [%d] unicode [%d] scancode [%d] keyName [%s]\n",__FILE__,__FUNCTION__,__LINE__,event.key.keysym.sym,event.key.keysym.mod,event.key.keysym.unicode,event.key.keysym.scancode,keyName.c_str()); + if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] Raw SDL key [%d - %c] mod [%d] unicode [%d - %c] scancode [%d] keyName [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,event.key.keysym.sym,event.key.keysym.sym,event.key.keysym.mod,event.key.keysym.unicode,event.key.keysym.unicode,event.key.keysym.scancode,keyName.c_str()); + if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Raw SDL key [%d] mod [%d] unicode [%d] scancode [%d] keyName [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,event.key.keysym.sym,event.key.keysym.mod,event.key.keysym.unicode,event.key.keysym.scancode,keyName.c_str()); /* handle ALT+Return */ if((keyName == "return" || keyName == "enter") && (event.key.keysym.mod & (KMOD_LALT | KMOD_RALT))) { - if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d] SDLK_RETURN pressed.\n",__FILE__,__FUNCTION__,__LINE__); + if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d] SDLK_RETURN pressed.\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); toggleFullscreen(); } #ifdef WIN32 /* handle ALT+f4 */ if((keyName == "f4" || keyName == "F4") && (event.key.keysym.mod & (KMOD_LALT | KMOD_RALT))) { - if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d] ALT-F4 pressed.\n",__FILE__,__FUNCTION__,__LINE__); + if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d] ALT-F4 pressed.\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); return false; } #endif @@ -224,17 +224,17 @@ bool Window::handleEvent() { global_window->eventKeyDown(event.key); global_window->eventKeyPress(event.key); - if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); + if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); } - if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] =================================== END OF SDL SDL_KEYDOWN ================================\n",__FILE__,__FUNCTION__,__LINE__); + if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] =================================== END OF SDL SDL_KEYDOWN ================================\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); } break; case SDL_KEYUP: - //printf("In [%s::%s] Line :%d\n",__FILE__,__FUNCTION__,__LINE__); + //printf("In [%s::%s] Line :%d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); - if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] =================================== START OF SDL SDL_KEYUP ================================\n",__FILE__,__FUNCTION__,__LINE__); + if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] =================================== START OF SDL SDL_KEYUP ================================\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); codeLocation = "j"; @@ -246,7 +246,7 @@ bool Window::handleEvent() { keystate = event.key.keysym; - if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] KEY_UP, Raw SDL key [%d] mod [%d] unicode [%d] scancode [%d]\n",__FILE__,__FUNCTION__,__LINE__,event.key.keysym.sym,event.key.keysym.mod,event.key.keysym.unicode,event.key.keysym.scancode); + if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] KEY_UP, Raw SDL key [%d] mod [%d] unicode [%d] scancode [%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,event.key.keysym.sym,event.key.keysym.mod,event.key.keysym.unicode,event.key.keysym.scancode); if(global_window) { //char key = getKey(event.key.keysym,true); @@ -254,15 +254,15 @@ bool Window::handleEvent() { global_window->eventKeyUp(event.key); } - if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] =================================== END OF SDL SDL_KEYUP ================================\n",__FILE__,__FUNCTION__,__LINE__); + if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] =================================== END OF SDL SDL_KEYUP ================================\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); break; case SDL_ACTIVEEVENT: { // codeLocation = "k"; -// if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] SDL_ACTIVEEVENT event.active.state = %d event.active. = %d\n",__FILE__,__FUNCTION__,__LINE__,event.active.state,event.active.gain); +// if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] SDL_ACTIVEEVENT event.active.state = %d event.active. = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,event.active.state,event.active.gain); // -// if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] Window::isActive = %d event.active.state = %d\n",__FILE__,__FUNCTION__,__LINE__,Window::isActive,event.active.state); +// if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] Window::isActive = %d event.active.state = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,Window::isActive,event.active.state); // // // Check if the program has lost window focus // if ((event.active.state & SDL_APPACTIVE) == SDL_APPACTIVE) { @@ -273,9 +273,9 @@ bool Window::handleEvent() { // Window::isActive = true; // } // -// if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] Window::isActive = %d \n",__FILE__,__FUNCTION__,__LINE__,Window::isActive); +// if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] Window::isActive = %d \n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,Window::isActive); // -// if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Window::isActive = %d\n",__FILE__,__FUNCTION__,__LINE__,Window::isActive); +// if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Window::isActive = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,Window::isActive); // // bool willShowCursor = (!Window::isActive || (Window::lastShowMouseState == SDL_ENABLE) || Window::getUseDefaultCursorOnly()); // showCursor(willShowCursor); @@ -292,18 +292,18 @@ bool Window::handleEvent() { // Window::isActive = true; // } // -// if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] Window::isActive = %d \n",__FILE__,__FUNCTION__,__LINE__,Window::isActive); +// if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] Window::isActive = %d \n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,Window::isActive); // -// if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Window::isActive = %d, event.active.state = %d\n",__FILE__,__FUNCTION__,__LINE__,Window::isActive,event.active.state); +// if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Window::isActive = %d, event.active.state = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,Window::isActive,event.active.state); // bool willShowCursor = (!Window::isActive || (Window::lastShowMouseState == SDL_ENABLE) || Window::getUseDefaultCursorOnly()); // showCursor(willShowCursor); // } // } codeLocation = "k"; - if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] SDL_ACTIVEEVENT event.active.state = %d event.active. = %d\n",__FILE__,__FUNCTION__,__LINE__,event.active.state,event.active.gain); + if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] SDL_ACTIVEEVENT event.active.state = %d event.active. = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,event.active.state,event.active.gain); - if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] Window::isActive = %d event.active.state = %d\n",__FILE__,__FUNCTION__,__LINE__,Window::isActive,event.active.state); + if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] Window::isActive = %d event.active.state = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,Window::isActive,event.active.state); // Check if the program has lost window focus if ((event.active.state & (SDL_APPACTIVE | SDL_APPINPUTFOCUS))) { @@ -314,9 +314,9 @@ bool Window::handleEvent() { Window::isActive = true; } - if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] Window::isActive = %d \n",__FILE__,__FUNCTION__,__LINE__,Window::isActive); + if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] Window::isActive = %d \n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,Window::isActive); - if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Window::isActive = %d\n",__FILE__,__FUNCTION__,__LINE__,Window::isActive); + if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Window::isActive = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,Window::isActive); bool willShowCursor = (!Window::isActive || (Window::lastShowMouseState == SDL_ENABLE) || Window::getUseDefaultCursorOnly()); showCursor(willShowCursor); @@ -326,22 +326,22 @@ bool Window::handleEvent() { } } catch(const char *e){ - SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] (a1) Couldn't process event: [%s] codeLocation = %s\n",__FILE__,__FUNCTION__,__LINE__,e,codeLocation.c_str()); - if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] (a1) Couldn't process event: [%s] codeLocation = %s\n",__FILE__,__FUNCTION__,__LINE__,e,codeLocation.c_str()); + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] (a1) Couldn't process event: [%s] codeLocation = %s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,e,codeLocation.c_str()); + if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] (a1) Couldn't process event: [%s] codeLocation = %s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,e,codeLocation.c_str()); throw runtime_error(e); } catch(const std::runtime_error& e) { - SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] (a2) Couldn't process event: [%s] codeLocation = %s\n",__FILE__,__FUNCTION__,__LINE__,e.what(),codeLocation.c_str()); - if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] (a2) Couldn't process event: [%s] codeLocation = %s\n",__FILE__,__FUNCTION__,__LINE__,e.what(),codeLocation.c_str()); + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] (a2) Couldn't process event: [%s] codeLocation = %s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,e.what(),codeLocation.c_str()); + if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] (a2) Couldn't process event: [%s] codeLocation = %s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,e.what(),codeLocation.c_str()); throw runtime_error(e.what()); } catch(const std::exception& e) { - SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] (b) Couldn't process event: [%s] codeLocation = %s\n",__FILE__,__FUNCTION__,__LINE__,e.what(),codeLocation.c_str()); - if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] (b) Couldn't process event: [%s] codeLocation = %s\n",__FILE__,__FUNCTION__,__LINE__,e.what(),codeLocation.c_str()); + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] (b) Couldn't process event: [%s] codeLocation = %s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,e.what(),codeLocation.c_str()); + if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] (b) Couldn't process event: [%s] codeLocation = %s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,e.what(),codeLocation.c_str()); } catch(...) { - SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] (c) Couldn't process event: [UNKNOWN ERROR] codeLocation = %s\n",__FILE__,__FUNCTION__,__LINE__,codeLocation.c_str()); - if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] (c) Couldn't process event: [UNKNOWN ERROR] codeLocation = %s\n",__FILE__,__FUNCTION__,__LINE__,codeLocation.c_str()); + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] (c) Couldn't process event: [UNKNOWN ERROR] codeLocation = %s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,codeLocation.c_str()); + if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] (c) Couldn't process event: [UNKNOWN ERROR] codeLocation = %s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,codeLocation.c_str()); } } @@ -443,7 +443,7 @@ void Window::setupGraphicsScreen(int depthBits, int stencilBits, bool hardware_a // setup LOD bias factor //const float lodBias = std::max(std::min( configHandler->Get("TextureLODBias", 0.0f) , 4.0f), -4.0f); const float lodBias = max(min(0.0f,4.0f),-4.0f); - //if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("\n\n\n\n\n$$$$ In [%s::%s Line: %d] lodBias = %f\n\n",__FILE__,__FUNCTION__,__LINE__,lodBias); + //if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("\n\n\n\n\n$$$$ In [%s::%s Line: %d] lodBias = %f\n\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,lodBias); #ifdef USE_STREFLOP if (streflop::fabs(lodBias) > 0.01f) { #else @@ -455,7 +455,7 @@ void Window::setupGraphicsScreen(int depthBits, int stencilBits, bool hardware_a } void Window::toggleFullscreen() { - if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__); + if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); Window::isFullScreen = !Window::isFullScreen; #ifdef WIN32 @@ -486,14 +486,14 @@ void Window::toggleFullscreen() { if ( (!surface) || (!(*surface)) ) // don't bother if there's no surface. return; - if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__); + if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); tmpflags = (*surface)->flags; w = (*surface)->w; h = (*surface)->h; bpp = (*surface)->format->BitsPerPixel; - if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n w = %d, h = %d, bpp = %d",__FILE__,__FUNCTION__,__LINE__,w,h,bpp); + if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n w = %d, h = %d, bpp = %d",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,w,h,bpp); if (flags == NULL) // use the surface's flags. flags = &tmpflags; @@ -507,16 +507,16 @@ void Window::toggleFullscreen() { SDL_GetClipRect(*surface, &clip); - if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__); + if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); *surface = SDL_SetVideoMode(w, h, bpp, (*flags)); if (*surface == NULL) { - if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__); + if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); *surface = SDL_SetVideoMode(w, h, bpp, tmpflags); } // if - if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__); + if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); SDL_SetClipRect(*surface, &clip); } @@ -524,14 +524,14 @@ void Window::toggleFullscreen() { else { HWND handle = GetSDLWindow(); if(Window::isFullScreen == true) { - if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d] Window::isFullScreen == true [%d]\n",__FILE__,__FUNCTION__,__LINE__,handle); + if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d] Window::isFullScreen == true [%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,handle); ShowWindow(handle, SW_MAXIMIZE); //if(Window::getUseDefaultCursorOnly() == false) { // showCursor(false); //} } else { - if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d] Window::isFullScreen == false [%d]\n",__FILE__,__FUNCTION__,__LINE__,handle); + if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d] Window::isFullScreen == false [%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,handle); ShowWindow(handle, SW_RESTORE); //showCursor(true); } @@ -539,31 +539,31 @@ void Window::toggleFullscreen() { #else if(Window::allowAltEnterFullscreenToggle == true) { - if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__); + if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == false) { SDL_Surface *cur_surface = SDL_GetVideoSurface(); if(cur_surface != NULL) { - if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__); + if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); SDL_WM_ToggleFullScreen(cur_surface); } } - if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__); + if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); } #endif - if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__); + if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); } void Window::handleMouseDown(SDL_Event event) { static const Uint32 DOUBLECLICKTIME = 500; static const int DOUBLECLICKDELTA = 5; - if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); + if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); MouseButton button = getMouseButton(event.button.button); - if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); + if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); // windows implementation uses 120 for the resolution of a standard mouse // wheel notch. However, newer mice have finer resolutions. I dunno if SDL @@ -579,35 +579,35 @@ void Window::handleMouseDown(SDL_Event event) { return; } - if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); + if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); Uint32 ticks = SDL_GetTicks(); int n = (int) button; assert(n >= 0 && n < mbCount); if(n >= 0 && n < mbCount) { - if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); + if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); if(ticks - lastMouseDown[n] < DOUBLECLICKTIME && abs(lastMouseX[n] - event.button.x) < DOUBLECLICKDELTA && abs(lastMouseY[n] - event.button.y) < DOUBLECLICKDELTA) { - if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); + if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); eventMouseDown(event.button.x, event.button.y, button); - if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); + if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); eventMouseDoubleClick(event.button.x, event.button.y, button); } else { - if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); + if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); eventMouseDown(event.button.x, event.button.y, button); } - if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); + if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); lastMouseDown[n] = ticks; lastMouseX[n] = event.button.x; lastMouseY[n] = event.button.y; - if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); + if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); } } @@ -625,7 +625,7 @@ MouseButton Window::getMouseButton(int sdlButton) { return mbWheelDown; default: //throw std::runtime_error("Mouse Button > 3 not handled."); - if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Mouse Button [%d] not handled.\n",__FILE__,__FUNCTION__,__LINE__,sdlButton); + if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Mouse Button [%d] not handled.\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,sdlButton); return mbUnknown; } @@ -637,16 +637,16 @@ bool isKeyPressed(SDLKey compareKey, SDL_KeyboardEvent input,bool modifiersAllow if(input.keysym.unicode > 0) { string unicodeKeyName = SDL_GetKeyName((SDLKey)input.keysym.unicode); - if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] input.keysym.unicode = %d input.keysym.mod = %d input.keysym.sym = %d unicodeKeyName [%s]\n",__FILE__,__FUNCTION__,__LINE__,input.keysym.unicode,input.keysym.mod,input.keysym.sym,unicodeKeyName.c_str()); - if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] input.keysym.unicode = %d input.keysym.mod = %d input.keysym.sym = %d unicodeKeyName [%s]\n",__FILE__,__FUNCTION__,__LINE__,input.keysym.unicode,input.keysym.mod,input.keysym.sym,unicodeKeyName.c_str()); + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] input.keysym.unicode = %d input.keysym.mod = %d input.keysym.sym = %d unicodeKeyName [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,input.keysym.unicode,input.keysym.mod,input.keysym.sym,unicodeKeyName.c_str()); + if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] input.keysym.unicode = %d input.keysym.mod = %d input.keysym.sym = %d unicodeKeyName [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,input.keysym.unicode,input.keysym.mod,input.keysym.sym,unicodeKeyName.c_str()); // When modifiers are pressed the unicode result is wrong // example CTRL-3 will give the ESCAPE vslue 27 in unicode if( !(input.keysym.mod & (KMOD_LCTRL | KMOD_RCTRL)) && !(input.keysym.mod & (KMOD_LALT | KMOD_RALT)) && !(input.keysym.mod & (KMOD_LSHIFT | KMOD_RSHIFT)) ) { - if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); - if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); + if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); c = input.keysym.unicode; //c = toupper(c); @@ -674,38 +674,40 @@ bool isKeyPressed(SDLKey compareKey, SDL_KeyboardEvent input,bool modifiersAllow input.keysym.unicode == SDLK_COMMA || input.keysym.unicode == SDLK_MINUS || input.keysym.unicode == SDLK_PERIOD || - input.keysym.unicode == SDLK_SLASH)) { - if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); - if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); + input.keysym.unicode == SDLK_SLASH || + // Need to allow Shift + # key for AZERTY style keyboards + (input.keysym.unicode >= SDLK_0 && input.keysym.unicode <= SDLK_9))) { + if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); c = input.keysym.unicode; } else if(input.keysym.mod & (KMOD_LCTRL | KMOD_RCTRL)) { - if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); - if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); + if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); if( (input.keysym.unicode >= SDLK_0 && input.keysym.unicode <= SDLK_9) || (input.keysym.unicode >= SDLK_KP0 && input.keysym.unicode <= SDLK_KP9)) { - if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); - if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); + if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); c = input.keysym.unicode; } } - if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] #1 (c & 0xFF) [%d]\n",__FILE__,__FUNCTION__,__LINE__,(c & 0xFF)); - if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem, "In [%s::%s Line: %d] #1 (c & 0xFF) [%d]\n",__FILE__,__FUNCTION__,__LINE__,(c & 0xFF)); + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] #1 (c & 0xFF) [%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,(c & 0xFF)); + if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem, "In [%s::%s Line: %d] #1 (c & 0xFF) [%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,(c & 0xFF)); } //if(c == 0) { if(c <= SDLK_UNKNOWN || c >= SDLK_LAST) { c = input.keysym.sym; } - if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %u] c = [%d]\n",__FILE__,__FUNCTION__,__LINE__,c); + if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %u] c = [%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,c); //c = (c & 0xFF); - if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] returning key [%d]\n",__FILE__,__FUNCTION__,__LINE__,c); - if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] returning key [%d]\n",__FILE__,__FUNCTION__,__LINE__,c); + if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] returning key [%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,c); + if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] returning key [%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,c); // SDL does NOT handle lowercase if(c >= 'A' && c <= 'Z') { @@ -806,20 +808,20 @@ bool isKeyPressed(SDLKey compareKey, SDL_KeyboardEvent input,bool modifiersAllow if( input.keysym.mod & (KMOD_LCTRL | KMOD_RCTRL) || input.keysym.mod & (KMOD_LALT | KMOD_RALT)) { //input.keysym.mod & (KMOD_LSHIFT | KMOD_RSHIFT)) { - if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] result *WOULD HAVE BEEN TRUE* but is false due to: modifiersAllowed = %d input.keysym.mod = %d\n",__FILE__,__FUNCTION__,__LINE__,modifiersAllowed,input.keysym.mod); + if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] result *WOULD HAVE BEEN TRUE* but is false due to: modifiersAllowed = %d input.keysym.mod = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,modifiersAllowed,input.keysym.mod); result = false; } } string compareKeyName = SDL_GetKeyName(compareKey); string pressKeyName = SDL_GetKeyName((SDLKey)c); - //printf ("In [%s::%s Line: %d] compareKey [%d - %s] pressed key [%d - %s] result = %d\n",__FILE__,__FUNCTION__,__LINE__,compareKey,compareKeyName.c_str(),c,pressKeyName.c_str(),result); + //printf ("In [%s::%s Line: %d] compareKey [%d - %s] pressed key [%d - %s] result = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,compareKey,compareKeyName.c_str(),c,pressKeyName.c_str(),result); - if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] compareKey [%d - %s] pressed key [%d - %s] result = %d\n",__FILE__,__FUNCTION__,__LINE__,compareKey,compareKeyName.c_str(),c,pressKeyName.c_str(),result); + if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] compareKey [%d - %s] pressed key [%d - %s] result = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,compareKey,compareKeyName.c_str(),c,pressKeyName.c_str(),result); //printf ("ISPRESS compareKey [%d - %s] pressed key [%d - %s] input.keysym.sym [%d] input.keysym.unicode [%d] mod = %d result = %d\n", // compareKey,compareKeyName.c_str(),c,pressKeyName.c_str(),input.keysym.sym,input.keysym.unicode,input.keysym.mod,result); - if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] compareKey [%d - %s] pressed key [%d - %s] result = %d\n",__FILE__,__FUNCTION__,__LINE__,compareKey,compareKeyName.c_str(),c,pressKeyName.c_str(),result); + if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] compareKey [%d - %s] pressed key [%d - %s] result = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,compareKey,compareKeyName.c_str(),c,pressKeyName.c_str(),result); return result; } @@ -828,7 +830,7 @@ wchar_t extractKeyPressedUnicode(SDL_KeyboardEvent input) { wchar_t c = SDLK_UNKNOWN; //if(input.keysym.unicode > 0 && input.keysym.unicode < 0x80) { if(input.keysym.unicode > 0) { - if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] input.keysym.unicode = %d input.keysym.mod = %d\n",__FILE__,__FUNCTION__,__LINE__,input.keysym.unicode,input.keysym.mod); + if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] input.keysym.unicode = %d input.keysym.mod = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,input.keysym.unicode,input.keysym.mod); c = input.keysym.unicode; // if(c <= SDLK_UNKNOWN || c >= SDLK_LAST) { @@ -837,18 +839,18 @@ wchar_t extractKeyPressedUnicode(SDL_KeyboardEvent input) { //c = toupper(c); - if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] #1 (c & 0xFF) [%d] c = [%lc]\n",__FILE__,__FUNCTION__,__LINE__,(c & 0xFF),c); - if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] #1 (c & 0xFF) [%d] c = [%lc]\n",__FILE__,__FUNCTION__,__LINE__,(c & 0xFF),c); + if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] #1 (c & 0xFF) [%d] c = [%lc]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,(c & 0xFF),c); + if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] #1 (c & 0xFF) [%d] c = [%lc]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,(c & 0xFF),c); } if(c == SDLK_UNKNOWN) { c = input.keysym.sym; } - if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %u] c = [%d][%lc]\n",__FILE__,__FUNCTION__,__LINE__,c); + if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %u] c = [%d][%lc]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,c); //c = (SDLKey)(c & 0xFF); - if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] returning key [%d]\n",__FILE__,__FUNCTION__,__LINE__,c); - if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] returning key [%d]\n",__FILE__,__FUNCTION__,__LINE__,c); + if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] returning key [%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,c); + if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] returning key [%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,c); string pressKeyName = SDL_GetKeyName((SDLKey)c); string inputKeyName = SDL_GetKeyName(input.keysym.sym); @@ -856,8 +858,8 @@ wchar_t extractKeyPressedUnicode(SDL_KeyboardEvent input) { //printf ("PRESS pressed key [%d - %s] input.keysym.sym [%d] input.keysym.unicode [%d] mod = %d\n", // c,pressKeyName.c_str(),input.keysym.sym,input.keysym.unicode,input.keysym.mod); - if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] pressed key [%d - %s]\n",__FILE__,__FUNCTION__,__LINE__,c,pressKeyName.c_str()); - if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] pressed key [%d - %s]\n",__FILE__,__FUNCTION__,__LINE__,c,pressKeyName.c_str()); + if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] pressed key [%d - %s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,c,pressKeyName.c_str()); + if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] pressed key [%d - %s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,c,pressKeyName.c_str()); return c; } @@ -866,7 +868,7 @@ SDLKey extractKeyPressed(SDL_KeyboardEvent input) { SDLKey c = SDLK_UNKNOWN; //if(input.keysym.unicode > 0 && input.keysym.unicode < 0x80) { if(input.keysym.unicode > 0) { - if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] input.keysym.unicode = %d input.keysym.mod = %d\n",__FILE__,__FUNCTION__,__LINE__,input.keysym.unicode,input.keysym.mod); + if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] input.keysym.unicode = %d input.keysym.mod = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,input.keysym.unicode,input.keysym.mod); c = (SDLKey)input.keysym.unicode; // if(c <= SDLK_UNKNOWN || c >= SDLK_LAST) { @@ -875,18 +877,18 @@ SDLKey extractKeyPressed(SDL_KeyboardEvent input) { //c = toupper(c); - if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] #1 (c & 0xFF) [%d]\n",__FILE__,__FUNCTION__,__LINE__,(c & 0xFF)); - if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] #1 (c & 0xFF) [%d]\n",__FILE__,__FUNCTION__,__LINE__,(c & 0xFF)); + if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] #1 (c & 0xFF) [%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,(c & 0xFF)); + if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] #1 (c & 0xFF) [%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,(c & 0xFF)); } if(c <= SDLK_UNKNOWN || c >= SDLK_LAST) { c = input.keysym.sym; } - if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %u] c = [%d]\n",__FILE__,__FUNCTION__,__LINE__,c); + if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %u] c = [%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,c); //c = (SDLKey)(c & 0xFF); - if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] returning key [%d]\n",__FILE__,__FUNCTION__,__LINE__,c); - if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] returning key [%d]\n",__FILE__,__FUNCTION__,__LINE__,c); + if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] returning key [%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,c); + if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] returning key [%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,c); string pressKeyName = SDL_GetKeyName((SDLKey)c); string inputKeyName = SDL_GetKeyName(input.keysym.sym); @@ -894,8 +896,8 @@ SDLKey extractKeyPressed(SDL_KeyboardEvent input) { //printf ("PRESS pressed key [%d - %s] input.keysym.sym [%d] input.keysym.unicode [%d] mod = %d\n", // c,pressKeyName.c_str(),input.keysym.sym,input.keysym.unicode,input.keysym.mod); - if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] pressed key [%d - %s]\n",__FILE__,__FUNCTION__,__LINE__,c,pressKeyName.c_str()); - if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] pressed key [%d - %s]\n",__FILE__,__FUNCTION__,__LINE__,c,pressKeyName.c_str()); + if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] pressed key [%d - %s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,c,pressKeyName.c_str()); + if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] pressed key [%d - %s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,c,pressKeyName.c_str()); return c; } @@ -954,8 +956,8 @@ bool isAllowedInputTextKey(wchar_t &key) { key != SDLK_POWER); string inputKeyName = SDL_GetKeyName((SDLKey)key); - if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] pressed key [%d - %s] result = %d\n",__FILE__,__FUNCTION__,__LINE__,key,inputKeyName.c_str(),result); - if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] pressed key [%d - %s] result = %d\n",__FILE__,__FUNCTION__,__LINE__,key,inputKeyName.c_str(),result); + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] pressed key [%d - %s] result = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,key,inputKeyName.c_str(),result); + if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] pressed key [%d - %s] result = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,key,inputKeyName.c_str(),result); return result; } @@ -1014,8 +1016,8 @@ bool isAllowedInputTextKey(SDLKey key) { key != SDLK_POWER); string inputKeyName = SDL_GetKeyName(key); - if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] pressed key [%d - %s] result = %d\n",__FILE__,__FUNCTION__,__LINE__,key,inputKeyName.c_str(),result); - if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] pressed key [%d - %s] result = %d\n",__FILE__,__FUNCTION__,__LINE__,key,inputKeyName.c_str(),result); + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] pressed key [%d - %s] result = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,key,inputKeyName.c_str(),result); + if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] pressed key [%d - %s] result = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,key,inputKeyName.c_str(),result); return result; } diff --git a/source/shared_lib/sources/platform/win32/platform_util.cpp b/source/shared_lib/sources/platform/win32/platform_util.cpp index 61cb20f1a..247692f6a 100644 --- a/source/shared_lib/sources/platform/win32/platform_util.cpp +++ b/source/shared_lib/sources/platform/win32/platform_util.cpp @@ -257,7 +257,15 @@ void init_win32() { HWND hwnd = wminfo.window; - ::SetClassLong(hwnd, GCL_HICON, (LONG) icon); +#ifdef __MINGW32__ + #define GCL_HICON -14 +#endif + +#ifndef __MINGW32__ + LONG iconPtr = (LONG)icon; + + ::SetClassLong(hwnd, GCL_HICON, iconPtr); +#endif } void done_win32() { ::DestroyIcon(icon); diff --git a/source/shared_lib/sources/streflop/CMakeLists.txt b/source/shared_lib/sources/streflop/CMakeLists.txt index 3a7717e10..0cc9027c4 100644 --- a/source/shared_lib/sources/streflop/CMakeLists.txt +++ b/source/shared_lib/sources/streflop/CMakeLists.txt @@ -13,7 +13,7 @@ INCLUDE_DIRECTORIES( SET(STREFLOP_SRC ${STREFLOP_GLOBBED_CPP}) # use SSE unconditionally (FIXME?) -SET_SOURCE_FILES_PROPERTIES(${STREFLOP_SRC} PROPERTIES COMPILE_FLAGS "-DSTREFLOP_SSE -DLIBM_COMPILING_FLT32 -O3 ${CXXFLAGS}") +#SET_SOURCE_FILES_PROPERTIES(${STREFLOP_SRC} PROPERTIES COMPILE_FLAGS "-DSTREFLOP_SSE -DLIBM_COMPILING_FLT32 -O3 ${CXXFLAGS}") ADD_LIBRARY(streflop STATIC EXCLUDE_FROM_ALL ${STREFLOP_SRC} diff --git a/source/shared_lib/sources/util/conversion.cpp b/source/shared_lib/sources/util/conversion.cpp index c75497e45..a2704c1c5 100644 --- a/source/shared_lib/sources/util/conversion.cpp +++ b/source/shared_lib/sources/util/conversion.cpp @@ -136,16 +136,19 @@ string doubleToStr(double d,int precsion) { } bool IsNumeric(const char *p, bool allowNegative) { - int index = 0; - for ( ; *p; p++) { - if (*p < '0' || *p > '9') { - if(allowNegative == false || (*p != '-' && index == 0)) { - return false; - } + if(p != NULL && strcmp(p,"-") == 0) { + return false; + } + int index = 0; + for ( ; *p; p++) { + if (*p < '0' || *p > '9') { + if(allowNegative == false || (*p != '-' && index == 0)) { + return false; + } + } + index++; } - index++; - } - return true; + return true; } class Comma: public numpunct// own facet class diff --git a/source/shared_lib/sources/util/properties.cpp b/source/shared_lib/sources/util/properties.cpp index a7f701f7c..cd05523ab 100644 --- a/source/shared_lib/sources/util/properties.cpp +++ b/source/shared_lib/sources/util/properties.cpp @@ -67,7 +67,7 @@ void Properties::load(const string &path, bool clearCurrentProperties) { #endif if(fileStream.is_open() == false){ - if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] path = [%s]\n",__FILE__,__FUNCTION__,__LINE__,path.c_str()); + if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] path = [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,path.c_str()); throw runtime_error("File NOT FOUND, can't open file: [" + path + "]"); } @@ -215,9 +215,9 @@ std::map Properties::getTagReplacementValues(std::map *mapTag replaceAll(value, "{APPLICATIONPATH}", Properties::applicationPath); #if defined(CUSTOM_DATA_INSTALL_PATH) - replaceAll(value, "$APPLICATIONDATAPATH", CUSTOM_DATA_INSTALL_PATH); - replaceAll(value, "%%APPLICATIONDATAPATH%%", CUSTOM_DATA_INSTALL_PATH); - replaceAll(value, "{APPLICATIONDATAPATH}", CUSTOM_DATA_INSTALL_PATH); + replaceAll(value, "$APPLICATIONDATAPATH", TOSTRING(CUSTOM_DATA_INSTALL_PATH)); + replaceAll(value, "%%APPLICATIONDATAPATH%%", TOSTRING(CUSTOM_DATA_INSTALL_PATH)); + replaceAll(value, "{APPLICATIONDATAPATH}", TOSTRING(CUSTOM_DATA_INSTALL_PATH)); //replaceAll(value, "$COMMONDATAPATH", string(CUSTOM_DATA_INSTALL_PATH) + "/commondata/"); //replaceAll(value, "%%COMMONDATAPATH%%", string(CUSTOM_DATA_INSTALL_PATH) + "/commondata/"); @@ -364,7 +364,7 @@ bool Properties::getBool(const string &key, const char *defaultValueIfNotFound) return strToBool(getString(key,defaultValueIfNotFound)); } catch(exception &e){ - SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what()); + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,e.what()); throw runtime_error("Error accessing value: " + key + " in: " + path+"\n[" + e.what() + "]"); } } @@ -374,7 +374,7 @@ int Properties::getInt(const string &key,const char *defaultValueIfNotFound) con return strToInt(getString(key,defaultValueIfNotFound)); } catch(exception &e){ - SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what()); + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,e.what()); throw runtime_error("Error accessing value: " + key + " in: " + path + "\n[" + e.what() + "]"); } } @@ -392,7 +392,7 @@ float Properties::getFloat(const string &key, const char *defaultValueIfNotFound return strToFloat(getString(key,defaultValueIfNotFound)); } catch(exception &e){ - SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what()); + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,e.what()); throw runtime_error("Error accessing value: " + key + " in: " + path + "\n[" + e.what() + "]"); } } @@ -410,7 +410,7 @@ const string Properties::getString(const string &key, const char *defaultValueIf it= propertyMap.find(key); if(it==propertyMap.end()){ if(defaultValueIfNotFound != NULL) { - //printf("In [%s::%s - %d]defaultValueIfNotFound = [%s]\n",__FILE__,__FUNCTION__,__LINE__,defaultValueIfNotFound); + //printf("In [%s::%s - %d]defaultValueIfNotFound = [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,defaultValueIfNotFound); return string(defaultValueIfNotFound); } else { @@ -456,7 +456,7 @@ bool Properties::getBool(const char *key, const char *defaultValueIfNotFound) co return strToBool(getString(key,defaultValueIfNotFound)); } catch(exception &e){ - SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what()); + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,e.what()); throw runtime_error("Error accessing value: " + string(key) + " in: " + path+"\n[" + e.what() + "]"); } } @@ -466,7 +466,7 @@ int Properties::getInt(const char *key,const char *defaultValueIfNotFound) const return strToInt(getString(key,defaultValueIfNotFound)); } catch(exception &e){ - SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what()); + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,e.what()); throw runtime_error("Error accessing value: " + string(key) + " in: " + path + "\n[" + e.what() + "]"); } } @@ -476,7 +476,7 @@ float Properties::getFloat(const char *key, const char *defaultValueIfNotFound) return strToFloat(getString(key,defaultValueIfNotFound)); } catch(exception &e){ - SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what()); + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,e.what()); throw runtime_error("Error accessing value: " + string(key) + " in: " + path + "\n[" + e.what() + "]"); } } @@ -486,7 +486,7 @@ const string Properties::getString(const char *key, const char *defaultValueIfNo it= propertyMap.find(key); if(it==propertyMap.end()){ if(defaultValueIfNotFound != NULL) { - //printf("In [%s::%s - %d]defaultValueIfNotFound = [%s]\n",__FILE__,__FUNCTION__,__LINE__,defaultValueIfNotFound); + //printf("In [%s::%s - %d]defaultValueIfNotFound = [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,defaultValueIfNotFound); return string(defaultValueIfNotFound); } else { diff --git a/source/shared_lib/sources/xml/xml_parser.cpp b/source/shared_lib/sources/xml/xml_parser.cpp index bfac71d70..3a2bf0c74 100644 --- a/source/shared_lib/sources/xml/xml_parser.cpp +++ b/source/shared_lib/sources/xml/xml_parser.cpp @@ -70,7 +70,7 @@ XmlIo::XmlIo() { XmlIo::initialized= true; } catch(const XMLException &e){ - SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error initializing XML system, msg %s\n",__FILE__,__FUNCTION__,__LINE__,e.getMessage()); + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error initializing XML system, msg %s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,e.getMessage()); throw runtime_error("Error initializing XML system"); } @@ -81,7 +81,7 @@ XmlIo::XmlIo() { implementation = DOMImplementationRegistry::getDOMImplementation(str); } catch(const DOMException &ex) { - SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Exception while creating XML parser, msg: %s\n",__FILE__,__FUNCTION__,__LINE__,ex.getMessage()); + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Exception while creating XML parser, msg: %s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,ex.getMessage()); throw runtime_error("Exception while creating XML parser"); } } @@ -135,7 +135,7 @@ XmlNode *XmlIo::load(const string &path, std::map mapTagReplaceme return rootNode; } catch(const DOMException &ex) { - SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Exception while loading: [%s], %s\n",__FILE__,__FUNCTION__,__LINE__,path.c_str(),XMLString::transcode(ex.msg)); + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Exception while loading: [%s], %s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,path.c_str(),XMLString::transcode(ex.msg)); throw runtime_error("Exception while loading: " + path + ": " + XMLString::transcode(ex.msg)); } } @@ -170,7 +170,7 @@ void XmlIo::save(const string &path, const XmlNode *node){ document->release(); } catch(const DOMException &e){ - SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Exception while saving: [%s], %s\n",__FILE__,__FUNCTION__,__LINE__,path.c_str(),XMLString::transcode(e.msg)); + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Exception while saving: [%s], %s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,path.c_str(),XMLString::transcode(e.msg)); throw runtime_error("Exception while saving: " + path + ": " + XMLString::transcode(e.msg)); } } @@ -191,6 +191,8 @@ typedef std::vector LoadStack; static string loadStackCacheName = string(__FILE__) + string("_loadStackCacheName"); void XmlTree::load(const string &path, std::map mapTagReplacementValues) { + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] about to load [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,path.c_str()); + //printf("XmlTree::load p [%p]\n",this); assert(!loadPath.size()); @@ -208,6 +210,8 @@ void XmlTree::load(const string &path, std::map mapTagReplacement loadPath = path; this->rootNode= XmlIo::getInstance().load(path, mapTagReplacementValues); + + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] about to load [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,path.c_str()); } void XmlTree::save(const string &path){