- attempt to further stabilize joining in progress games
This commit is contained in:
parent
b0a370900f
commit
e4235cc551
|
@ -79,6 +79,8 @@ Game::Game() : ProgramState(NULL) {
|
|||
avgRenderFps=0;
|
||||
currentAvgRenderFpsTotal=0;
|
||||
paused=false;
|
||||
pauseRequestSent=false;
|
||||
resumeRequestSent=false;
|
||||
pauseStateChanged=false;
|
||||
gameOver=false;
|
||||
renderNetworkStatus=false;
|
||||
|
@ -234,6 +236,8 @@ void Game::resetMembers() {
|
|||
currentAvgRenderFpsTotal=0;
|
||||
tickCount=0;
|
||||
paused= false;
|
||||
resumeRequestSent=false;
|
||||
pauseRequestSent=false;
|
||||
pauseStateChanged=false;
|
||||
gameOver= false;
|
||||
renderNetworkStatus= false;
|
||||
|
@ -2034,7 +2038,18 @@ void Game::update() {
|
|||
ServerInterface *server = NetworkManager::getInstance().getServerInterface();
|
||||
|
||||
if(server->getPauseForInGameConnection() == true) {
|
||||
if(paused == false) {
|
||||
|
||||
bool clientNeedsGameSetup = false;
|
||||
for(int i = 0; i < world.getFactionCount(); ++i) {
|
||||
Faction *faction = world.getFaction(i);
|
||||
ConnectionSlot *slot = server->getSlot(faction->getStartLocationIndex());
|
||||
if(slot != NULL && slot->getPauseForInGameConnection() == true) {
|
||||
clientNeedsGameSetup = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(paused == false || clientNeedsGameSetup == true) {
|
||||
//printf("================= Switching player pausing game\n");
|
||||
|
||||
for(int i = 0; i < world.getFactionCount(); ++i) {
|
||||
|
@ -2085,7 +2100,7 @@ void Game::update() {
|
|||
ConnectionSlot *slot = server->getSlot(faction->getStartLocationIndex());
|
||||
|
||||
if(slot != NULL && slot->getStartInGameConnectionLaunch() == true) {
|
||||
slot->setStartInGameConnectionLaunch(false);
|
||||
//slot->setStartInGameConnectionLaunch(false);
|
||||
pauseAndSaveGameForNewClient = true;
|
||||
}
|
||||
if(slot != NULL && slot->getJoinGameInProgress() == true) {
|
||||
|
@ -2113,13 +2128,15 @@ void Game::update() {
|
|||
}
|
||||
}
|
||||
|
||||
if(pauseAndSaveGameForNewClient == true) {
|
||||
if(pauseAndSaveGameForNewClient == true && paused == false &&
|
||||
pauseRequestSent == false) {
|
||||
commander.tryPauseGame(true);
|
||||
pauseRequestSent = true;
|
||||
//return;
|
||||
}
|
||||
}
|
||||
//else if(server->getPauseForInGameConnection() == true && paused == true &&
|
||||
else if(paused == true) {
|
||||
if(paused == true) {
|
||||
if(pauseStateChanged == true) {
|
||||
pauseStateChanged = false;
|
||||
}
|
||||
|
@ -2136,9 +2153,10 @@ void Game::update() {
|
|||
}
|
||||
}
|
||||
commander.tryResumeGame(false);
|
||||
resumeRequestSent = true;
|
||||
//return;
|
||||
}
|
||||
else {
|
||||
else if(server->getStartInGameConnectionLaunch() == true) {
|
||||
bool saveNetworkGame = false;
|
||||
|
||||
ServerInterface *server = NetworkManager::getInstance().getServerInterface();
|
||||
|
@ -2146,7 +2164,10 @@ void Game::update() {
|
|||
Faction *faction = world.getFaction(i);
|
||||
ConnectionSlot *slot = server->getSlot(faction->getStartLocationIndex());
|
||||
if(slot != NULL && slot->getJoinGameInProgress() == true &&
|
||||
slot->getSentSavedGameInfo() == false) {
|
||||
slot->getStartInGameConnectionLaunch() == true &&
|
||||
slot->getSentSavedGameInfo() == false) {
|
||||
slot->setStartInGameConnectionLaunch(false);
|
||||
|
||||
saveNetworkGame = true;
|
||||
break;
|
||||
}
|
||||
|
@ -2175,25 +2196,31 @@ void Game::update() {
|
|||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
// handle setting changes from clients
|
||||
Map *map= world.getMap();
|
||||
//printf("switchSetupRequests != NULL\n");
|
||||
//else {
|
||||
// handle setting changes from clients
|
||||
Map *map= world.getMap();
|
||||
//printf("switchSetupRequests != NULL\n");
|
||||
|
||||
bool switchRequested = switchSetupForSlots(server, 0, map->getMaxPlayers(), false);
|
||||
switchRequested = switchRequested || switchSetupForSlots(server, map->getMaxPlayers(), GameConstants::maxPlayers, true);
|
||||
bool switchRequested = switchSetupForSlots(server, 0, map->getMaxPlayers(), false);
|
||||
switchRequested = switchRequested || switchSetupForSlots(server, map->getMaxPlayers(), GameConstants::maxPlayers, true);
|
||||
|
||||
if(switchRequested == true) {
|
||||
//printf("Send new game setup from switch: %d\n",switchRequested);
|
||||
if(switchRequested == true) {
|
||||
//printf("Send new game setup from switch: %d\n",switchRequested);
|
||||
|
||||
//for(int i= 0; i < gameSettings.getFactionCount(); ++i) {
|
||||
//printf("#1 Faction Index: %d control: %d startlocation: %d\n",i,gameSettings.getFactionControl(i),gameSettings.getStartLocationIndex(i));
|
||||
//for(int i= 0; i < gameSettings.getFactionCount(); ++i) {
|
||||
//printf("#1 Faction Index: %d control: %d startlocation: %d\n",i,gameSettings.getFactionControl(i),gameSettings.getStartLocationIndex(i));
|
||||
|
||||
//printf("#2 Faction Index: %d control: %d startlocation: %d\n",i,server->gameSettings.getFactionControl(i),server->gameSettings.getStartLocationIndex(i));
|
||||
//}
|
||||
//printf("#2 Faction Index: %d control: %d startlocation: %d\n",i,server->gameSettings.getFactionControl(i),server->gameSettings.getStartLocationIndex(i));
|
||||
//}
|
||||
|
||||
server->broadcastGameSetup(&server->gameSettings,true);
|
||||
server->broadcastGameSetup(&server->gameSettings,true);
|
||||
}
|
||||
//}
|
||||
|
||||
// Make the server wait a bit for clients to start.
|
||||
if(paused == false && resumeRequestSent == true) {
|
||||
resumeRequestSent = false;
|
||||
sleep(500);
|
||||
}
|
||||
}
|
||||
// END - Handle joining in progress games
|
||||
|
@ -5395,6 +5422,9 @@ void Game::setPaused(bool value,bool forceAllowPauseStateChange,bool clearCaches
|
|||
}
|
||||
}
|
||||
//printf("setPaused new paused = %d\n",paused);
|
||||
|
||||
pauseRequestSent=false;
|
||||
//resumeRequestSent=false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -90,6 +90,8 @@ private:
|
|||
int totalRenderFps, renderFps, lastRenderFps, avgRenderFps,currentAvgRenderFpsTotal;
|
||||
uint64 tickCount;
|
||||
bool paused;
|
||||
bool pauseRequestSent;
|
||||
bool resumeRequestSent;
|
||||
bool pauseStateChanged;
|
||||
bool gameOver;
|
||||
bool renderNetworkStatus;
|
||||
|
|
|
@ -3199,8 +3199,9 @@ void MenuStateConnectedGame::update() {
|
|||
}
|
||||
|
||||
// check if we are joining an in progress game
|
||||
if(clientInterface->getJoinGameInProgress() == true &&
|
||||
clientInterface->getReadyForInGameJoin() == true &&
|
||||
if( clientInterface->getJoinGameInProgress() == true &&
|
||||
clientInterface->getJoinGameInProgressLaunch() == true &&
|
||||
clientInterface->getReadyForInGameJoin() == true &&
|
||||
ftpClientThread != NULL) {
|
||||
|
||||
MutexSafeWrapper safeMutexFTPProgress((ftpClientThread != NULL ? ftpClientThread->getProgressMutex() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
|
|
|
@ -58,7 +58,10 @@ ClientInterface::ClientInterface() : GameNetworkInterface() {
|
|||
sessionKey = 0;
|
||||
launchGame= false;
|
||||
introDone= false;
|
||||
joinGameInProgress = false;
|
||||
|
||||
this->joinGameInProgress = false;
|
||||
this->joinGameInProgressLaunch = false;
|
||||
|
||||
playerIndex= -1;
|
||||
setGameSettingsReceived(false);
|
||||
gotIntro = false;
|
||||
|
@ -251,7 +254,8 @@ void ClientInterface::updateLobby() {
|
|||
playerIndex= networkMessageIntro.getPlayerIndex();
|
||||
serverName= networkMessageIntro.getName();
|
||||
serverFTPPort = networkMessageIntro.getFtpPort();
|
||||
joinGameInProgress = networkMessageIntro.getGameInProgress();
|
||||
this->joinGameInProgress = networkMessageIntro.getGameInProgress();
|
||||
this->joinGameInProgressLaunch = false;
|
||||
|
||||
//printf("Client got intro playerIndex = %d\n",playerIndex);
|
||||
|
||||
|
@ -1333,7 +1337,8 @@ void ClientInterface::waitUntilReady(Checksum* checksum) {
|
|||
return;
|
||||
}
|
||||
|
||||
joinGameInProgress = false;
|
||||
this->joinGameInProgress = false;
|
||||
this->joinGameInProgressLaunch = false;
|
||||
|
||||
//printf("Client signalServerWhenReadyToStartJoinedGame = %d\n",signalServerWhenReadyToStartJoinedGame);
|
||||
if(signalServerWhenReadyToStartJoinedGame == true) {
|
||||
|
@ -1510,6 +1515,11 @@ void ClientInterface::close()
|
|||
connectedTime = 0;
|
||||
gotIntro = false;
|
||||
|
||||
this->joinGameInProgress = false;
|
||||
this->joinGameInProgressLaunch = false;
|
||||
this->pausedForInGameJoin = false;
|
||||
this->readyForInGameJoin = false;
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] END\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
|
@ -1713,6 +1723,7 @@ void ClientInterface::broadcastGameStart(const GameSettings *gameSettings) {
|
|||
//broadcastMessage(&networkMessageLaunch);
|
||||
sendMessage(&networkMessageLaunch);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] Line: %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
this->joinGameInProgressLaunch = true;
|
||||
}
|
||||
void ClientInterface::setGameSettingsReceived(bool value) {
|
||||
//printf("In [%s:%s] Line: %d gameSettingsReceived = %d value = %d, gameSettingsReceivedCount = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,gameSettingsReceived,value,gameSettingsReceivedCount);
|
||||
|
|
|
@ -49,7 +49,6 @@ private:
|
|||
int gameSettingsReceivedCount;
|
||||
time_t connectedTime;
|
||||
bool gotIntro;
|
||||
bool joinGameInProgress;
|
||||
|
||||
Ip ip;
|
||||
int port;
|
||||
|
@ -66,6 +65,9 @@ private:
|
|||
Mutex *networkCommandListThreadAccessor;
|
||||
std::map<int,Commands> cachedPendingCommands; //commands ready to be given
|
||||
uint64 cachedPendingCommandsIndex;
|
||||
|
||||
bool joinGameInProgress;
|
||||
bool joinGameInProgressLaunch;
|
||||
bool pausedForInGameJoin;
|
||||
bool readyForInGameJoin;
|
||||
|
||||
|
@ -78,6 +80,7 @@ public:
|
|||
virtual void close();
|
||||
|
||||
bool getJoinGameInProgress() const { return joinGameInProgress; }
|
||||
bool getJoinGameInProgressLaunch() const { return joinGameInProgressLaunch; }
|
||||
|
||||
bool getPausedForInGameJoin() const { return pausedForInGameJoin; }
|
||||
bool getReadyForInGameJoin() const { return readyForInGameJoin; }
|
||||
|
|
Loading…
Reference in New Issue