- updated to allow dynamic changing of updatefps and camerafps

This commit is contained in:
Mark Vejvoda 2010-08-25 18:26:17 +00:00
parent 014165de69
commit 5e20ab5808
7 changed files with 28 additions and 4 deletions

View File

@ -10,6 +10,7 @@
#include "xml_parser.h" #include "xml_parser.h"
#include <iostream> #include <iostream>
#include <wx/event.h> #include <wx/event.h>
#include "game_constants.h"
using namespace Shared::Platform; using namespace Shared::Platform;
using namespace Shared::PlatformCommon; using namespace Shared::PlatformCommon;
@ -19,6 +20,7 @@ using namespace Shared::Util;
using namespace Shared::Xml; using namespace Shared::Xml;
using namespace std; using namespace std;
using namespace Glest::Game;
#ifdef _WIN32 #ifdef _WIN32
const char *folderDelimiter = "\\"; const char *folderDelimiter = "\\";
@ -26,6 +28,9 @@ const char *folderDelimiter = "\\";
const char *folderDelimiter = "/"; const char *folderDelimiter = "/";
#endif #endif
int GameConstants::updateFps= 20;
int GameConstants::cameraFps= 50;
namespace Shared{ namespace G3dViewer{ namespace Shared{ namespace G3dViewer{
// =============================================== // ===============================================

View File

@ -45,6 +45,11 @@ Game::Game(Program *program, const GameSettings *gameSettings):
{ {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); 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; quitTriggeredIndicator = false;
originalDisplayMsgCallback = NULL; originalDisplayMsgCallback = NULL;
thisGamePtr = this; thisGamePtr = this;
@ -116,6 +121,9 @@ Game::~Game(){
// object pointers. // object pointers.
renderer.endGame(); renderer.endGame();
GameConstants::updateFps = original_updateFps;
GameConstants::cameraFps = original_cameraFps;
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
} }

View File

@ -88,6 +88,9 @@ private:
bool quitTriggeredIndicator; bool quitTriggeredIndicator;
int original_updateFps;
int original_cameraFps;
public: public:
Game(Program *program, const GameSettings *gameSettings); Game(Program *program, const GameSettings *gameSettings);
~Game(); ~Game();

View File

@ -47,8 +47,11 @@ class GameConstants {
public: public:
static const int maxPlayers= 8; static const int maxPlayers= 8;
static const int serverPort= 61357; static const int serverPort= 61357;
static const int updateFps= 40; //static const int updateFps= 40;
static const int cameraFps= 100; //static const int cameraFps= 100;
static int updateFps;
static int cameraFps;
static int networkFramePeriod; static int networkFramePeriod;
static const int networkPingInterval = 5; static const int networkPingInterval = 5;
//static const int networkExtraLatency= 200; //static const int networkExtraLatency= 200;

View File

@ -28,7 +28,9 @@ using namespace std;
namespace Glest{ namespace Game{ 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_maps = "maps";
const char *GameConstants::folder_path_scenarios = "scenarios"; const char *GameConstants::folder_path_scenarios = "scenarios";

View File

@ -68,7 +68,6 @@ enum GAME_ARG_TYPE {
GAME_ARG_VALIDATE_FACTIONS GAME_ARG_VALIDATE_FACTIONS
}; };
// ===================================================== // =====================================================
// class ExceptionHandler // class ExceptionHandler
// ===================================================== // =====================================================

View File

@ -389,6 +389,10 @@ void Program::setState(ProgramState *programState, bool cleanupOldState)
msgBox.init(lang.get("Ok")); msgBox.init(lang.get("Ok"));
msgBox.setEnabled(msgBoxEnabled); msgBox.setEnabled(msgBoxEnabled);
fpsTimer.init(1, maxTimes);
updateTimer.init(GameConstants::updateFps, maxTimes);
updateCameraTimer.init(GameConstants::cameraFps, maxTimes);
this->programState= programState; this->programState= programState;
programState->load(); programState->load();