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