bugfixes to allow joining in progress game and also ensure disconnect list is correct.

This commit is contained in:
Mark Vejvoda 2013-06-04 08:01:33 +00:00
parent a313b26d74
commit 0af3e349d8
3 changed files with 17 additions and 5 deletions

View File

@ -415,9 +415,9 @@ void Commander::tryResumeGame(bool joinNetworkGame, bool clearCaches) const {
void Commander::tryNetworkPlayerDisconnected(int factionIndex) const {
//printf("tryNetworkPlayerDisconnected factionIndex: %d\n",factionIndex);
if(this->pauseNetworkCommands == true) {
return;
}
//if(this->pauseNetworkCommands == true) {
// return;
//}
NetworkCommand command(this->world,nctPlayerStatusChange, factionIndex, npst_Disconnected);
pushNetworkCommand(&command);

View File

@ -2291,7 +2291,7 @@ void Game::update() {
//server->setStartInGameConnectionLaunch(false);
this->speed = 1;
//this->speed = 1;
//Lang &lang= Lang::getInstance();
bool pauseAndSaveGameForNewClient = false;
@ -2351,12 +2351,13 @@ void Game::update() {
if(server->getUnPauseForInGameConnection() == true) {
//printf("^^^ getUnPauseForInGameConnection triggered!\n");
this->speed = 1;
//this->speed = 1;
for(int i = 0; i < world.getFactionCount(); ++i) {
Faction *faction = world.getFaction(i);
ConnectionSlot *slot = server->getSlot(faction->getStartLocationIndex());
if(slot != NULL && slot->getUnPauseForInGameConnection() == true) {
slot->setUnPauseForInGameConnection(false);
faction->setFactionDisconnectHandled(false);
}
}
//printf("Resuming game for join in progress game resumeRequestSent: %d...\n",resumeRequestSent);

View File

@ -602,13 +602,18 @@ void ConnectionSlot::update(bool checkForNewClients,int lockedSlotIndex) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] BEFORE accept new client connection, serverInterface->getOpenSlotCount() = %d\n",__FILE__,__FUNCTION__,__LINE__,serverInterface->getOpenSlotCount());
//printf("Checking for new connections...\n");
bool hasData = (serverInterface->getServerSocket() != NULL && serverInterface->getServerSocket()->hasDataToRead() == true);
//printf("Server socket hasData: %d\n",hasData);
if(hasData == true) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] about to accept new client connection playerIndex = %d\n",__FILE__,__FUNCTION__,__LINE__,playerIndex);
Socket *newSocket = serverInterface->getServerSocket()->accept(false);
//printf("Server socket newSocket: %p\n",newSocket);
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] called accept new client connection playerIndex = %d newSocket = %p\n",__FILE__,__FUNCTION__,__LINE__,playerIndex,newSocket);
if(newSocket != NULL) {
// Set Socket as non-blocking
@ -649,6 +654,8 @@ void ConnectionSlot::update(bool checkForNewClients,int lockedSlotIndex) {
//send intro message when connected
if(this->isConnected() == true) {
//printf("Server socket newSocket is connected: %d\n",playerIndex);
Chrono seed(true);
srand((unsigned int)seed.getCurTicks() / (this->playerIndex + 1));
@ -669,6 +676,10 @@ void ConnectionSlot::update(bool checkForNewClients,int lockedSlotIndex) {
serverInterface->getGameHasBeenInitiated(),
Config::getInstance().getString("PlayerId",""));
sendMessage(&networkMessageIntro);
if(this->serverInterface->getGameHasBeenInitiated() == true) {
setGameStarted(true);
}
}
}
}