added networkframeperiod support to gamesettings and added possibility to over-ride in glest.ini for now
This commit is contained in:
parent
79c47e9e7f
commit
cf6d43247d
|
@ -21,7 +21,8 @@
|
|||
#include "console.h"
|
||||
#include "config.h"
|
||||
#include "platform_util.h"
|
||||
#include "leak_dumper.h"
|
||||
#include "game.h"
|
||||
#include "game_settings.h"
|
||||
#include "game.h"
|
||||
|
||||
using namespace Shared::Graphics;
|
||||
|
@ -259,11 +260,12 @@ CommandResult Commander::pushNetworkCommand(const NetworkCommand* networkCommand
|
|||
return cr;
|
||||
}
|
||||
|
||||
void Commander::updateNetwork(){
|
||||
void Commander::updateNetwork() {
|
||||
NetworkManager &networkManager= NetworkManager::getInstance();
|
||||
|
||||
//chech that this is a keyframe
|
||||
if( !networkManager.isNetworkGame() || (world->getFrameCount() % GameConstants::networkFramePeriod)==0){
|
||||
//check that this is a keyframe
|
||||
GameSettings *gameSettings = this->world->getGame()->getGameSettings();
|
||||
if( !networkManager.isNetworkGame() || (world->getFrameCount() % gameSettings->getNetworkFramePeriod()) == 0) {
|
||||
|
||||
GameNetworkInterface *gameNetworkInterface= NetworkManager::getInstance().getGameNetworkInterface();
|
||||
|
||||
|
|
|
@ -37,8 +37,8 @@ public:
|
|||
static const int serverPort= 61357;
|
||||
static const int updateFps= 40;
|
||||
static const int cameraFps= 100;
|
||||
static const int networkFramePeriod= 20;
|
||||
static const int networkExtraLatency= 200;
|
||||
static int networkFramePeriod;
|
||||
//static const int networkExtraLatency= 200;
|
||||
static const int maxClientConnectHandshakeSecs= 10;
|
||||
|
||||
static const char *folder_path_maps;
|
||||
|
|
|
@ -49,6 +49,7 @@ private:
|
|||
bool fogOfWar;
|
||||
bool enableObserverModeAtEndGame;
|
||||
bool enableServerControlledAI;
|
||||
int networkFramePeriod;
|
||||
|
||||
public:
|
||||
|
||||
|
@ -57,6 +58,7 @@ public:
|
|||
fogOfWar = true;
|
||||
enableObserverModeAtEndGame = false;
|
||||
enableServerControlledAI = false;
|
||||
networkFramePeriod = GameConstants::networkFramePeriod;
|
||||
}
|
||||
|
||||
// default copy constructor will do fine, and will maintain itself ;)
|
||||
|
@ -94,6 +96,7 @@ public:
|
|||
bool getFogOfWar() const {return fogOfWar;}
|
||||
bool getEnableObserverModeAtEndGame() const {return enableObserverModeAtEndGame;}
|
||||
bool getEnableServerControlledAI() const {return enableServerControlledAI;}
|
||||
int getNetworkFramePeriod() const {return networkFramePeriod; }
|
||||
|
||||
//set
|
||||
void setDescription(const string& description) {this->description= description;}
|
||||
|
@ -118,6 +121,7 @@ public:
|
|||
void setFogOfWar(bool fogOfWar) {this->fogOfWar = fogOfWar;}
|
||||
void setEnableObserverModeAtEndGame(bool value) {this->enableObserverModeAtEndGame = value;}
|
||||
void setEnableServerControlledAI(bool value) {this->enableServerControlledAI = value;}
|
||||
void setNetworkFramePeriod(int value) {this->networkFramePeriod = value; }
|
||||
|
||||
string toString() const {
|
||||
string result = "";
|
||||
|
@ -147,6 +151,7 @@ public:
|
|||
result += "fogOfWar = " + intToStr(fogOfWar) + "\n";
|
||||
result += "enableObserverModeAtEndGame = " + intToStr(enableObserverModeAtEndGame) + "\n";
|
||||
result += "enableServerControlledAI = " + intToStr(enableServerControlledAI) + "\n";
|
||||
result += "networkFramePeriod = " + intToStr(networkFramePeriod) + "\n";
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// ==============================================================
|
||||
// This file is part of Glest (www.glest.org)
|
||||
//
|
||||
// Copyright (C) 2001-2008 Martiño Figueroa
|
||||
// Copyright (C) 2001-2008 Martio Figueroa
|
||||
//
|
||||
// You can redistribute this code and/or modify it under
|
||||
// the terms of the GNU General Public License as published
|
||||
|
@ -22,6 +22,7 @@ using namespace Shared::Util;
|
|||
|
||||
namespace Glest{ namespace Game{
|
||||
|
||||
int GameConstants::networkFramePeriod= 20;
|
||||
|
||||
const char *GameConstants::folder_path_maps = "maps";
|
||||
const char *GameConstants::folder_path_scenarios = "scenarios";
|
||||
|
|
|
@ -350,6 +350,9 @@ int glestMain(int argc, char** argv){
|
|||
MeshCallbackTeamColor::noTeamColors = true;
|
||||
}
|
||||
|
||||
// Over-ride default network command framecount
|
||||
GameConstants::networkFramePeriod = config.getInt("NetworkFramePeriod",intToStr(GameConstants::networkFramePeriod).c_str());
|
||||
|
||||
//float pingTime = Socket::getAveragePingMS("soft-haus.com");
|
||||
//printf("Ping time = %f\n",pingTime);
|
||||
|
||||
|
|
|
@ -434,9 +434,10 @@ void MenuStateConnectedGame::update()
|
|||
label += " - data synch is ok";
|
||||
}
|
||||
|
||||
std::string networkFrameString = lang.get("NetworkFramePeriod") + " " + intToStr(clientInterface->getGameSettings()->getNetworkFramePeriod());
|
||||
float pingTime = clientInterface->getThreadedPingMS(clientInterface->getServerIpAddress().c_str());
|
||||
char szBuf[1024]="";
|
||||
sprintf(szBuf,"%s, ping = %.2fms",label.c_str(),pingTime);
|
||||
sprintf(szBuf,"%s, ping = %.2fms, %s",label.c_str(),pingTime,networkFrameString.c_str());
|
||||
|
||||
labelStatus.setText(szBuf);
|
||||
}
|
||||
|
@ -475,9 +476,10 @@ void MenuStateConnectedGame::update()
|
|||
label += " - data synch is ok";
|
||||
}
|
||||
|
||||
std::string networkFrameString = lang.get("NetworkFramePeriod") + " " + intToStr(clientInterface->getGameSettings()->getNetworkFramePeriod());
|
||||
float pingTime = clientInterface->getThreadedPingMS(clientInterface->getServerIpAddress().c_str());
|
||||
char szBuf[1024]="";
|
||||
sprintf(szBuf,"%s, ping = %.2fms",label.c_str(),pingTime);
|
||||
sprintf(szBuf,"%s, ping = %.2fms, %s",label.c_str(),pingTime,networkFrameString.c_str());
|
||||
|
||||
labelStatus.setText(szBuf);
|
||||
}
|
||||
|
|
|
@ -168,6 +168,7 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b
|
|||
listBoxEnableServerControlledAI.pushBackItem(lang.get("No"));
|
||||
listBoxEnableServerControlledAI.setSelectedItemIndex(0);
|
||||
|
||||
labelNetworkFramePeriod.init(420, networkHeadPos, 80);
|
||||
|
||||
//list boxes
|
||||
for(int i=0; i<GameConstants::maxPlayers; ++i){
|
||||
|
@ -272,6 +273,8 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b
|
|||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
labelNetworkFramePeriod.setText(lang.get("NetworkFramePeriod") + " " + intToStr(gameSettings.getNetworkFramePeriod()));
|
||||
|
||||
//chatManager.init(&console, world.getThisTeamIndex());
|
||||
chatManager.init(&console, -1);
|
||||
|
||||
|
@ -299,7 +302,6 @@ MenuStateCustomGame::~MenuStateCustomGame() {
|
|||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
|
||||
void MenuStateCustomGame::returnToParentMenu(){
|
||||
MutexSafeWrapper safeMutex(&masterServerThreadAccessor);
|
||||
needToBroadcastServerSettings = false;
|
||||
|
@ -347,6 +349,11 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton){
|
|||
}
|
||||
*/
|
||||
|
||||
MutexSafeWrapper safeMutex(&masterServerThreadAccessor);
|
||||
needToBroadcastServerSettings = false;
|
||||
needToRepublishToMasterserver = false;
|
||||
BaseThread::shutdownAndWait(publishToMasterserverThread);
|
||||
|
||||
returnToParentMenu();
|
||||
}
|
||||
else if(buttonPlayNow.mouseClick(x,y) && buttonPlayNow.getEnabled()) {
|
||||
|
@ -590,6 +597,7 @@ void MenuStateCustomGame::mouseMove(int x, int y, const MouseState *ms){
|
|||
listBoxPublishServer.mouseMove(x, y);
|
||||
listBoxEnableObserverMode.mouseMove(x, y);
|
||||
listBoxEnableServerControlledAI.mouseMove(x, y);
|
||||
labelNetworkFramePeriod.mouseMove(x, y);
|
||||
}
|
||||
|
||||
void MenuStateCustomGame::render(){
|
||||
|
@ -642,6 +650,7 @@ void MenuStateCustomGame::render(){
|
|||
renderer.renderLabel(&labelPublishServer);
|
||||
renderer.renderListBox(&listBoxEnableServerControlledAI);
|
||||
renderer.renderLabel(&labelEnableServerControlledAI);
|
||||
renderer.renderLabel(&labelNetworkFramePeriod);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1163,6 +1172,7 @@ void MenuStateCustomGame::saveGameSettingsToFile(std::string fileName) {
|
|||
saveGameFile << "FogOfWar=" << gameSettings.getFogOfWar() << std::endl;
|
||||
saveGameFile << "EnableObserverModeAtEndGame=" << gameSettings.getEnableObserverModeAtEndGame() << std::endl;
|
||||
saveGameFile << "EnableServerControlledAI=" << gameSettings.getEnableServerControlledAI() << std::endl;
|
||||
saveGameFile << "NetworkFramePeriod=" << gameSettings.getNetworkFramePeriod() << std::endl;
|
||||
|
||||
saveGameFile << "FactionThisFactionIndex=" << gameSettings.getThisFactionIndex() << std::endl;
|
||||
saveGameFile << "FactionCount=" << gameSettings.getFactionCount() << std::endl;
|
||||
|
@ -1209,6 +1219,7 @@ GameSettings MenuStateCustomGame::loadGameSettingsFromFile(std::string fileName)
|
|||
gameSettings.setFogOfWar(properties.getBool("FogOfWar"));
|
||||
gameSettings.setEnableObserverModeAtEndGame(properties.getBool("EnableObserverModeAtEndGame"));
|
||||
gameSettings.setEnableServerControlledAI(properties.getBool("EnableServerControlledAI","false"));
|
||||
gameSettings.setNetworkFramePeriod(properties.getBool("NetworkFramePeriod",intToStr(GameConstants::networkFramePeriod).c_str()));
|
||||
|
||||
gameSettings.setThisFactionIndex(properties.getInt("FactionThisFactionIndex"));
|
||||
gameSettings.setFactionCount(properties.getInt("FactionCount"));
|
||||
|
@ -1251,6 +1262,8 @@ GameSettings MenuStateCustomGame::loadGameSettingsFromFile(std::string fileName)
|
|||
listBoxEnableObserverMode.setSelectedItem(gameSettings.getEnableObserverModeAtEndGame() == true ? lang.get("Yes") : lang.get("No"));
|
||||
listBoxEnableServerControlledAI.setSelectedItem(gameSettings.getEnableServerControlledAI() == true ? lang.get("Yes") : lang.get("No"));
|
||||
|
||||
labelNetworkFramePeriod.setText(lang.get("NetworkFramePeriod") + " " + intToStr(gameSettings.getNetworkFramePeriod()));
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
reloadFactions();
|
||||
|
|
|
@ -36,6 +36,7 @@ private:
|
|||
GraphicLabel labelMapInfo;
|
||||
GraphicLabel labelEnableObserverMode;
|
||||
GraphicLabel labelEnableServerControlledAI;
|
||||
GraphicLabel labelNetworkFramePeriod;
|
||||
|
||||
GraphicListBox listBoxMap;
|
||||
GraphicListBox listBoxFogOfWar;
|
||||
|
|
|
@ -186,6 +186,7 @@ NetworkMessageLaunch::NetworkMessageLaunch(const GameSettings *gameSettings,int8
|
|||
data.fogOfWar = gameSettings->getFogOfWar();
|
||||
data.enableObserverModeAtEndGame = gameSettings->getEnableObserverModeAtEndGame();
|
||||
data.enableServerControlledAI = gameSettings->getEnableServerControlledAI();
|
||||
data.networkFramePeriod = gameSettings->getNetworkFramePeriod();
|
||||
|
||||
for(int i= 0; i<data.factionCount; ++i){
|
||||
data.factionTypeNames[i]= gameSettings->getFactionTypeName(i);
|
||||
|
@ -211,6 +212,7 @@ void NetworkMessageLaunch::buildGameSettings(GameSettings *gameSettings) const{
|
|||
gameSettings->setFogOfWar(data.fogOfWar);
|
||||
gameSettings->setEnableObserverModeAtEndGame(data.enableObserverModeAtEndGame);
|
||||
gameSettings->setEnableServerControlledAI(data.enableServerControlledAI);
|
||||
gameSettings->setNetworkFramePeriod(data.networkFramePeriod);
|
||||
|
||||
for(int i= 0; i<data.factionCount; ++i){
|
||||
gameSettings->setFactionTypeName(i, data.factionTypeNames[i].getString());
|
||||
|
|
|
@ -167,6 +167,7 @@ private:
|
|||
int8 fogOfWar;
|
||||
int8 enableObserverModeAtEndGame;
|
||||
int8 enableServerControlledAI;
|
||||
uint8 networkFramePeriod; // allowed values 0 - 255
|
||||
};
|
||||
|
||||
private:
|
||||
|
|
Loading…
Reference in New Issue