void Commander::removeSquad(int id) { for (int i = 0; i < (int)squads.size(); i++) { Squad* sq = squads.at(i); if (sq->getID() == id) { sq->disband(); squads.erase(squads.begin() + i); return; } } }
void Commander::unitDestroyed(BaseAgent* agent) { int squadID = agent->getSquadID(); if (squadID != -1) { Squad* squad = getSquad(squadID); if (squad != NULL) { squad->removeMember(agent); } // remove empty squad //for ( // I AM HERE if (squad->getMembers().size() == 0) squad->disband(squad->getCenter()); // squads.erase(squads.begin()); } }