- 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 <iostream>
#include <wx/event.h>
#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{
// ===============================================

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__);
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__);
}

View File

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

View File

@ -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;

View File

@ -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";

View File

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

View File

@ -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();