// //////////////////////////////////////////////////////////////////////////// // Accept a droid which was destroyed on another machine BOOL recvDestroyDroid(NETQUEUE queue) { DROID* psDroid; NETbeginDecode(queue, GAME_DROIDDEST); { uint32_t id; // Retrieve the droid NETuint32_t(&id); if (!IdToDroid(id, ANYPLAYER, &psDroid)) { debug(LOG_DEATH, "droid %d on request from player %d can't be found? Must be dead already?", id, queue.index ); return false; } } NETend(); // If the droid has not died on our machine yet, destroy it if(!psDroid->died) { turnOffMultiMsg(true); debug(LOG_DEATH, "Killing droid %d on request from player %d - huh?", psDroid->id, queue.index); destroyDroid(psDroid); turnOffMultiMsg(false); } else { debug(LOG_DEATH, "droid %d is confirmed dead by player %d.", psDroid->id, queue.index); } return true; }
/* ** when a remote player leaves an arena game do this! ** ** @param player -- the one we need to clear ** @param quietly -- true means without any visible effects */ void clearPlayer(UDWORD player,bool quietly) { UDWORD i; STRUCTURE *psStruct,*psNext; debug(LOG_NET, "R.I.P. %s (%u). quietly is %s", getPlayerName(player), player, quietly ? "true":"false"); ingame.JoiningInProgress[player] = false; // if they never joined, reset the flag ingame.DataIntegrity[player] = false; (void)setPlayerName(player,""); //clear custom player name (will use default instead) for(i = 0;i<MAX_PLAYERS;i++) // remove alliances { alliances[player][i] = ALLIANCE_BROKEN; alliances[i][player] = ALLIANCE_BROKEN; } debug(LOG_DEATH, "killing off all droids for player %d", player); while(apsDroidLists[player]) // delete all droids { if(quietly) // don't show effects { killDroid(apsDroidLists[player]); } else // show effects { destroyDroid(apsDroidLists[player], gameTime); } } debug(LOG_DEATH, "killing off all structures for player %d", player); psStruct = apsStructLists[player]; while(psStruct) // delete all structs { psNext = psStruct->psNext; // FIXME: look why destroyStruct() doesn't put back the feature like removeStruct() does if(quietly || psStruct->pStructureType->type == REF_RESOURCE_EXTRACTOR) // don't show effects { removeStruct(psStruct, true); } else // show effects { destroyStruct(psStruct, gameTime); } psStruct = psNext; } return; }
// //////////////////////////////////////////////////////////////////////////// // Accept a droid which was destroyed on another machine bool recvDestroyDroid(NETQUEUE queue) { DROID* psDroid; NETbeginDecode(queue, GAME_DEBUG_REMOVE_DROID); { uint32_t id; // Retrieve the droid NETuint32_t(&id); psDroid = IdToDroid(id, ANYPLAYER); if (!psDroid) { debug(LOG_DEATH, "droid %d on request from player %d can't be found? Must be dead already?", id, queue.index ); return false; } } NETend(); if (!getDebugMappingStatus()) { debug(LOG_WARNING, "Failed to remove droid for player %u.", NetPlay.players[queue.index].position); return false; } // If the droid has not died on our machine yet, destroy it if(!psDroid->died) { turnOffMultiMsg(true); debug(LOG_DEATH, "Killing droid %d on request from player %d - huh?", psDroid->id, queue.index); destroyDroid(psDroid, gameTime); turnOffMultiMsg(false); } else { debug(LOG_DEATH, "droid %d is confirmed dead by player %d.", psDroid->id, queue.index); } return true; }
// //////////////////////////////////////////////////////////////////////////// // Accept a droid which was destroyed on another machine bool recvDestroyDroid(NETQUEUE queue) { DROID *psDroid; NETbeginDecode(queue, GAME_DEBUG_REMOVE_DROID); { uint32_t id; // Retrieve the droid NETuint32_t(&id); psDroid = IdToDroid(id, ANYPLAYER); if (!psDroid) { debug(LOG_DEATH, "droid %d on request from player %d can't be found? Must be dead already?", id, queue.index); return false; } } NETend(); if (!getDebugMappingStatus() && bMultiPlayer) { debug(LOG_WARNING, "Failed to remove droid for player %u.", NetPlay.players[queue.index].position); return false; } // If the droid has not died on our machine yet, destroy it if (!psDroid->died) { turnOffMultiMsg(true); debug(LOG_DEATH, "Killing droid %d on request from player %d - huh?", psDroid->id, queue.index); destroyDroid(psDroid, gameTime - deltaGameTime + 1); // deltaGameTime is actually 0 here, since we're between updates. However, the value of gameTime - deltaGameTime + 1 will not change when we start the next tick. turnOffMultiMsg(false); } else { debug(LOG_DEATH, "droid %d is confirmed dead by player %d.", psDroid->id, queue.index); } return true; }