- attempt to fix the segfault reported by tomreyn when headless admin disconnects from the server

This commit is contained in:
Mark Vejvoda
2012-12-19 19:55:49 +00:00
parent 848b5fed07
commit c14c9ebc2d

View File

@@ -1361,7 +1361,7 @@ void ServerInterface::update() {
int iFirstConnectedSlot = -1;
for(int i= 0; i < GameConstants::maxPlayers; ++i) {
MutexSafeWrapper safeMutexSlot(slotAccessorMutexes[i],CODE_AT_LINE_X(i));
if(slots[i] != NULL) {
if(slots[i] != NULL && slots[i]->isConnected() == true) {
if(iFirstConnectedSlot < 0) {
iFirstConnectedSlot = i;
}
@@ -1375,15 +1375,19 @@ void ServerInterface::update() {
if(foundAdminSlot == false && iFirstConnectedSlot >= 0) {
printf("Switching masterserver admin to slot#%d...\n",iFirstConnectedSlot);
MutexSafeWrapper safeMutexSlot(slotAccessorMutexes[iFirstConnectedSlot],CODE_AT_LINE_X(iFirstConnectedSlot));
if(slots[iFirstConnectedSlot] != NULL) {
string sMsg = "Switching player to admin mode: " + slots[iFirstConnectedSlot]->getName();
sendTextMessage(sMsg,-1, true,"");
this->gameSettings.setMasterserver_admin(slots[iFirstConnectedSlot]->getSessionKey());
this->gameSettings.setMasterserver_admin_faction_index(slots[iFirstConnectedSlot]->getPlayerIndex());
safeMutexSlot.ReleaseLock();
this->broadcastGameSetup(&this->gameSettings);
}
}
}
//printf("\nServerInterface::update -- G\n");
}
catch(const exception &ex) {