From 995617e91ecfbe335564a65120f41e1d38faad2a Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Tue, 28 May 2013 07:10:13 +0000 Subject: [PATCH] bugfix to allow admin to kick player in same slot multiple times --- source/glest_game/game/commander.cpp | 4 ++++ source/glest_game/game/game.cpp | 10 ++++++++++ source/glest_game/graphics/renderer.cpp | 14 ++++++++++++-- source/glest_game/network/connection_slot.cpp | 5 ++++- source/glest_game/network/server_interface.cpp | 1 + 5 files changed, 31 insertions(+), 3 deletions(-) diff --git a/source/glest_game/game/commander.cpp b/source/glest_game/game/commander.cpp index 5495d212..1a4045cb 100644 --- a/source/glest_game/game/commander.cpp +++ b/source/glest_game/game/commander.cpp @@ -499,6 +499,8 @@ void Commander::tryResumeGame(bool joinNetworkGame, bool clearCaches) const { } void Commander::tryNetworkPlayerDisconnected(int factionIndex) const { + //printf("tryNetworkPlayerDisconnected factionIndex: %d\n",factionIndex); + NetworkCommand command(this->world,nctPlayerStatusChange, factionIndex, npst_Disconnected); pushNetworkCommand(&command); } @@ -905,6 +907,8 @@ void Commander::giveNetworkCommand(NetworkCommand* networkCommand) const { GameSettings *settings = world->getGameSettingsPtr(); if(playerStatus == npst_Disconnected) { + //printf("Commander nctPlayerStatusChange factionIndex: %d\n",factionIndex); + settings->setNetworkPlayerStatuses(factionIndex,npst_Disconnected); //printf("nctPlayerStatusChange -> faction->getPersonalityType() = %d index [%d] control [%d] networkstatus [%d]\n", diff --git a/source/glest_game/game/game.cpp b/source/glest_game/game/game.cpp index b52512c7..bb662e74 100644 --- a/source/glest_game/game/game.cpp +++ b/source/glest_game/game/game.cpp @@ -2261,9 +2261,11 @@ void Game::update() { server->gameSettings.setFactionControl(i,ctNetwork); ConnectionSlot *slot = server->getSlot(faction->getStartLocationIndex()); server->gameSettings.setNetworkPlayerName(i,slot->getName()); + server->gameSettings.setNetworkPlayerStatuses(i,npst_None); this->gameSettings.setFactionControl(i,ctNetwork); this->gameSettings.setNetworkPlayerName(i,server->gameSettings.getNetworkPlayerName(i)); + this->gameSettings.setNetworkPlayerStatuses(i,npst_None); } } //printf("#1 Data synch: lmap %u ltile: %d ltech: %u\n",gameSettings.getMapCRC(),gameSettings.getTilesetCRC(),gameSettings.getTechCRC()); @@ -2302,6 +2304,10 @@ void Game::update() { this->gameSettings.setFactionControl(i,ctNetwork); this->gameSettings.setNetworkPlayerName(i,server->gameSettings.getNetworkPlayerName(i)); + if(this->gameSettings.getNetworkPlayerStatuses(i) == npst_Disconnected) { + this->gameSettings.setNetworkPlayerStatuses(i,npst_None); + } + //printf("START Purging AI player for index: %d\n",i); masterController.clearSlaves(true); delete aiInterfaces[i]; @@ -3578,6 +3584,10 @@ void Game::mouseDownLeft(int x, int y) { isSlotJoinInProgressClient = true; } } + + //printf("isSlotJoinInProgressClient: %d [%d] [%d][%d] [%d] [%d] [%d]\n", + // isSlotJoinInProgressClient,faction->getPersonalityType(),faction->getIndex(),world.getThisFaction()->getIndex(),faction->getControlType(),this->gameSettings.getNetworkPlayerStatuses(i),i); + if(isSlotJoinInProgressClient == true || (faction->getPersonalityType() != fpt_Observer && world.getThisFaction()->getIndex() != faction->getIndex() && diff --git a/source/glest_game/graphics/renderer.cpp b/source/glest_game/graphics/renderer.cpp index 35dc0c28..6f81e294 100644 --- a/source/glest_game/graphics/renderer.cpp +++ b/source/glest_game/graphics/renderer.cpp @@ -739,8 +739,18 @@ void Renderer::endGame(bool isFinalEnd) { this->game= NULL; this->gameCamera = NULL; - quadCache = VisibleQuadContainerCache(); - quadCache.clearFrustumData(); + try { + quadCache = VisibleQuadContainerCache(); + quadCache.clearFrustumData(); + } + catch(const exception &e) { + char szBuf[8096]=""; + snprintf(szBuf,8096,"In [%s::%s Line: %d]\nError [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,e.what()); + SystemFlags::OutputDebug(SystemFlags::debugError,szBuf); + if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,szBuf); + + abort(); + } if(isFinalEnd) { //delete resources diff --git a/source/glest_game/network/connection_slot.cpp b/source/glest_game/network/connection_slot.cpp index f28624b8..147bccbe 100644 --- a/source/glest_game/network/connection_slot.cpp +++ b/source/glest_game/network/connection_slot.cpp @@ -1041,7 +1041,10 @@ void ConnectionSlot::update(bool checkForNewClients,int lockedSlotIndex) { int factionIndex = this->serverInterface->gameSettings.getFactionIndexForStartLocation(playerIndex); this->serverInterface->gameSettings.setFactionControl(factionIndex,ctNetwork); this->serverInterface->gameSettings.setNetworkPlayerName(factionIndex,this->name); - //this->serverInterface->gameSettings.setNetworkPlayerStatuses(factionIndex,npst_None); + + if(this->serverInterface->gameSettings.getNetworkPlayerStatuses(factionIndex) == npst_Disconnected) { + this->serverInterface->gameSettings.setNetworkPlayerStatuses(factionIndex,npst_None); + } this->serverInterface->broadcastGameSetup(&this->serverInterface->gameSettings, true); diff --git a/source/glest_game/network/server_interface.cpp b/source/glest_game/network/server_interface.cpp index 6ed59ea4..a959e3ce 100644 --- a/source/glest_game/network/server_interface.cpp +++ b/source/glest_game/network/server_interface.cpp @@ -533,6 +533,7 @@ bool ServerInterface::switchSlot(int fromPlayerIndex, int toPlayerIndex) { ConnectionSlot *tmp = slots[toPlayerIndex]; slots[toPlayerIndex] = slots[fromPlayerIndex]; slots[fromPlayerIndex] = tmp; + safeMutex.ReleaseLock(); PlayerIndexMessage playerIndexMessage(toPlayerIndex);