/** ** Player quit. ** ** @param player Player number that quit. */ void CommandQuit(int player) { // Set player to neutral, remove allied/enemy/shared vision status // If the player doesn't have any units then this is pointless? Players[player].Type = PlayerNeutral; for (int i = 0; i < NumPlayers; ++i) { if (i != player && Players[i].Team != Players[player].Team) { Players[i].SetDiplomacyNeutralWith(Players[player]); Players[player].SetDiplomacyNeutralWith(Players[i]); // We clear Shared vision by sending fake shared vision commands. // We do this because Shared vision is a bit complex. CommandSharedVision(i, 0, player); CommandSharedVision(player, 0, i); // Remove Selection from Quit Player std::vector<CUnit *> empty; ChangeTeamSelectedUnits(Players[player], empty); } } if (Players[player].GetUnitCount() != 0) { SetMessage(_("Player \"%s\" has left the game"), Players[player].Name.c_str()); } else { SetMessage(_("Player \"%s\" has been killed"), Players[player].Name.c_str()); } }
/** ** Player quit. ** ** @param player Player number that quit. */ void CommandQuit(int player) { int i; // Set player to neutral, remove allied/enemy/shared vision status // If the player doesn't have any units then this is pointless? Players[player].Type = PlayerNeutral; for (i = 0; i < NumPlayers; ++i) { if (i != player && Players[i].Team != Players[player].Team) { Players[i].Allied &= ~(1 << player); Players[i].Enemy &= ~(1 << player); Players[player].Enemy &= ~(1 << i); Players[player].Allied &= ~(1 << i); // We clear Shared vision by sending fake shared vision commands. // We do this because Shared vision is a bit complex. CommandSharedVision(i, 0, player); CommandSharedVision(player, 0, i); // Remove Selection from Quit Player ChangeTeamSelectedUnits(&Players[player], NULL, 0, 0); } } if (Players[player].TotalNumUnits != 0) { SetMessage(_("Player \"%s\" has left the game"), Players[player].Name.c_str()); } else { SetMessage(_("Player \"%s\" has been killed"), Players[player].Name.c_str()); } }
static void NetworkExecCommand_Selection(const CNetworkCommandQueue &ncq) { Assert((ncq.Type & 0x7F) == MessageSelection); CNetworkSelection ns; ns.Deserialize(&ncq.Data[0]); if (Players[ns.player].Team != ThisPlayer->Team) { return; } std::vector<CUnit *> units; for (size_t i = 0; i != ns.Units.size(); ++i) { units.push_back(&UnitManager.GetSlotUnit(ns.Units[i])); } ChangeTeamSelectedUnits(Players[ns.player], units); }