diff --git a/source/g3d_viewer/main.cpp b/source/g3d_viewer/main.cpp index d87e4e15..953aca83 100644 --- a/source/g3d_viewer/main.cpp +++ b/source/g3d_viewer/main.cpp @@ -10,6 +10,7 @@ #include "xml_parser.h" #include #include +#include "game_constants.h" using namespace Shared::Platform; using namespace Shared::PlatformCommon; @@ -19,6 +20,7 @@ using namespace Shared::Util; using namespace Shared::Xml; using namespace std; +using namespace Glest::Game; #ifdef _WIN32 const char *folderDelimiter = "\\"; @@ -26,6 +28,9 @@ const char *folderDelimiter = "\\"; const char *folderDelimiter = "/"; #endif +int GameConstants::updateFps= 20; +int GameConstants::cameraFps= 50; + namespace Shared{ namespace G3dViewer{ // =============================================== diff --git a/source/glest_game/game/game.cpp b/source/glest_game/game/game.cpp index bcbfa2aa..c0e99133 100644 --- a/source/glest_game/game/game.cpp +++ b/source/glest_game/game/game.cpp @@ -45,6 +45,11 @@ Game::Game(Program *program, const GameSettings *gameSettings): { SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); + original_updateFps = GameConstants::updateFps; + original_cameraFps = GameConstants::cameraFps; + GameConstants::updateFps= 20; + GameConstants::cameraFps= 50; + quitTriggeredIndicator = false; originalDisplayMsgCallback = NULL; thisGamePtr = this; @@ -116,6 +121,9 @@ Game::~Game(){ // object pointers. renderer.endGame(); + GameConstants::updateFps = original_updateFps; + GameConstants::cameraFps = original_cameraFps; + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); } diff --git a/source/glest_game/game/game.h b/source/glest_game/game/game.h index 5fb5a4ea..087e4941 100644 --- a/source/glest_game/game/game.h +++ b/source/glest_game/game/game.h @@ -88,6 +88,9 @@ private: bool quitTriggeredIndicator; + int original_updateFps; + int original_cameraFps; + public: Game(Program *program, const GameSettings *gameSettings); ~Game(); diff --git a/source/glest_game/game/game_constants.h b/source/glest_game/game/game_constants.h index e3de74eb..d640ebdb 100644 --- a/source/glest_game/game/game_constants.h +++ b/source/glest_game/game/game_constants.h @@ -47,8 +47,11 @@ class GameConstants { public: static const int maxPlayers= 8; static const int serverPort= 61357; - static const int updateFps= 40; - static const int cameraFps= 100; + //static const int updateFps= 40; + //static const int cameraFps= 100; + static int updateFps; + static int cameraFps; + static int networkFramePeriod; static const int networkPingInterval = 5; //static const int networkExtraLatency= 200; diff --git a/source/glest_game/global/config.cpp b/source/glest_game/global/config.cpp index ef893417..ec50db3d 100644 --- a/source/glest_game/global/config.cpp +++ b/source/glest_game/global/config.cpp @@ -28,7 +28,9 @@ using namespace std; namespace Glest{ namespace Game{ -int GameConstants::networkFramePeriod= 20; +int GameConstants::networkFramePeriod = 20; +int GameConstants::updateFps = 40; +int GameConstants::cameraFps = 100; const char *GameConstants::folder_path_maps = "maps"; const char *GameConstants::folder_path_scenarios = "scenarios"; diff --git a/source/glest_game/main/main.cpp b/source/glest_game/main/main.cpp index 6da1d642..7b4fb5f3 100644 --- a/source/glest_game/main/main.cpp +++ b/source/glest_game/main/main.cpp @@ -68,7 +68,6 @@ enum GAME_ARG_TYPE { GAME_ARG_VALIDATE_FACTIONS }; - // ===================================================== // class ExceptionHandler // ===================================================== diff --git a/source/glest_game/main/program.cpp b/source/glest_game/main/program.cpp index 47fdc5a5..c2d217b3 100644 --- a/source/glest_game/main/program.cpp +++ b/source/glest_game/main/program.cpp @@ -389,6 +389,10 @@ void Program::setState(ProgramState *programState, bool cleanupOldState) msgBox.init(lang.get("Ok")); msgBox.setEnabled(msgBoxEnabled); + fpsTimer.init(1, maxTimes); + updateTimer.init(GameConstants::updateFps, maxTimes); + updateCameraTimer.init(GameConstants::cameraFps, maxTimes); + this->programState= programState; programState->load();