when clients connect to a lobby or game see if the player was previously in a slot and if so give them this slot

This commit is contained in:
Mark Vejvoda 2013-06-05 20:04:03 +00:00
parent 6d349b839c
commit 8a3cf2f956
3 changed files with 43 additions and 2 deletions

View File

@ -1014,8 +1014,24 @@ void ConnectionSlot::update(bool checkForNewClients,int lockedSlotIndex) {
if(serverInterface->getGameHasBeenInitiated() == true &&
serverInterface->getAllowInGameConnections() == true) {
setJoinGameInProgressFlags();
this->setPauseForInGameConnection(true);
ConnectionSlot *slot = serverInterface->findSlotForUUID(this->playerUUID,true);
if(slot != NULL) {
slot->setJoinGameInProgressFlags();
slot->setPauseForInGameConnection(true);
serverInterface->switchSlot(this->playerIndex,slot->getPlayerIndex());
}
else {
setJoinGameInProgressFlags();
this->setPauseForInGameConnection(true);
}
}
else {
ConnectionSlot *slot = serverInterface->findSlotForUUID(this->playerUUID,true);
if(slot != NULL) {
serverInterface->switchSlot(this->playerIndex,slot->getPlayerIndex());
}
}
}
}

View File

@ -3016,6 +3016,27 @@ bool ServerInterface::getUnPauseForInGameConnection() {
return result;
}
ConnectionSlot * ServerInterface::findSlotForUUID(string uuid, bool unConnectedOnly) {
ConnectionSlot *result = NULL;
if(uuid != "") {
for(int i= 0; exitServer == false && i < GameConstants::maxPlayers; ++i) {
MutexSafeWrapper safeMutexSlot(slotAccessorMutexes[i],CODE_AT_LINE_X(i));
ConnectionSlot *connectionSlot= slots[i];
if(connectionSlot!= NULL) {
if(connectionSlot->getUUID() == uuid) {
if(unConnectedOnly == false ||
(unConnectedOnly == true && connectionSlot->isConnected() == false)) {
if(result == NULL ||
(result->getConnectedTime() > connectionSlot->getConnectedTime()))
result = connectionSlot;
}
}
}
}
}
return result;
}
void ServerInterface::saveGame(XmlNode *rootNode) {
std::map<string,string> mapTagReplacements;
XmlNode *serverInterfaceNode = rootNode->addChild("ServerInterface");

View File

@ -232,6 +232,8 @@ public:
void broadcastMessage(NetworkMessage *networkMessage, int excludeSlot = -1, int lockedSlotIndex = -1);
ConnectionSlot * findSlotForUUID(string uuid, bool unConnectedOnly=true);
private:
void broadcastMessageToConnectedClients(NetworkMessage *networkMessage, int excludeSlot = -1);
@ -255,6 +257,8 @@ protected:
void dispatchPendingHighlightCellMessages(std::vector <string> &errorMsgList);
void shutdownMasterserverPublishThread();
};
}}//end namespace