// Makes sure that the mTeams[] structure has the proper player counts // Needs to be called manually before accessing the structure // Bot counts do work on client. Yay! // Rating may only work on server... not tested on client void Game::countTeamPlayers() const { for(S32 i = 0; i < getTeamCount(); i++) { TNLAssert(dynamic_cast<Team *>(getTeam(i)), "Invalid team"); // Assert for safety static_cast<Team *>(getTeam(i))->clearStats(); // static_cast for speed } for(S32 i = 0; i < getClientCount(); i++) { ClientInfo *clientInfo = getClientInfo(i); S32 teamIndex = clientInfo->getTeamIndex(); if(teamIndex >= 0 && teamIndex < getTeamCount()) { // Robot could be neutral or hostile, skip out-of-range team numbers TNLAssert(dynamic_cast<Team *>(getTeam(teamIndex)), "Invalid team"); Team *team = static_cast<Team *>(getTeam(teamIndex)); if(clientInfo->isRobot()) team->incrementBotCount(); else team->incrementPlayerCount(); // The following bit won't work on the client... if(isServer()) { const F32 BASE_RATING = .1f; team->addRating(max(clientInfo->getCalculatedRating(), BASE_RATING)); } } } }