// //////////////////////////////////////////////////////////////////////////// // acknowledge the destruction of a structure, from another player. bool recvDestroyStructure(NETQUEUE queue) { uint32_t structID; STRUCTURE *psStruct; NETbeginDecode(queue, GAME_DEBUG_REMOVE_STRUCTURE); NETuint32_t(&structID); NETend(); if (!getDebugMappingStatus() && bMultiPlayer) { debug(LOG_WARNING, "Failed to remove structure for player %u.", NetPlay.players[queue.index].position); return false; } // Struct to destory psStruct = IdToStruct(structID, ANYPLAYER); if (psStruct) { turnOffMultiMsg(true); // Remove the struct from remote players machine destroyStruct(psStruct, 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); // NOTE: I do not think this should be here! technologyGiveAway(psStruct); } 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; }
// //////////////////////////////////////////////////////////////////////////// // acknowledge the destruction of a structure, from another player. BOOL recvDestroyStructure(NETMSG * m) { UDWORD s; STRUCTURE *psStr; NetGet(m,0,s); // struct to destory psStr = IdToStruct(s,ANYPLAYER); if (psStr) { turnOffMultiMsg(TRUE); destroyStruct(psStr); // remove the struct from remote players machine. turnOffMultiMsg(FALSE); technologyGiveAway(psStr); return (TRUE); } return (TRUE); }
// //////////////////////////////////////////////////////////////////////////// // acknowledge the destruction of a structure, from another player. BOOL recvDestroyStructure(NETQUEUE queue) { uint32_t structID; STRUCTURE *psStruct; NETbeginDecode(queue, GAME_STRUCTDEST); NETuint32_t(&structID); NETend(); // Struct to destory psStruct = IdToStruct(structID,ANYPLAYER); if (psStruct) { turnOffMultiMsg(true); // Remove the struct from remote players machine destroyStruct(psStruct); turnOffMultiMsg(false); // NOTE: I do not think this should be here! technologyGiveAway(psStruct); } return true; }