mirror of
https://github.com/s1lentq/ReGameDLL_CS.git
synced 2025-01-27 14:08:00 +03:00
Update player counts (#684)
* Update player counts in CheckWinConditions and SwitchTeam * Add UTIL_SpectatorsInGame and update MaintainBotQuota
This commit is contained in:
parent
da24c74c20
commit
dd243eaa0b
@ -852,6 +852,7 @@ void CCSBotManager::MaintainBotQuota()
|
||||
|
||||
int totalHumansInGame = UTIL_HumansInGame();
|
||||
int humanPlayersInGame = UTIL_HumansInGame(IGNORE_SPECTATORS);
|
||||
int spectatorPlayersInGame = UTIL_SpectatorsInGame();
|
||||
|
||||
// don't add bots until local player has been registered, to make sure he's player ID #1
|
||||
if (!IS_DEDICATED_SERVER() && totalHumansInGame == 0)
|
||||
@ -872,7 +873,7 @@ void CCSBotManager::MaintainBotQuota()
|
||||
// unless the round is already in progress, in which case we play with what we've been dealt
|
||||
if (!isRoundInProgress)
|
||||
{
|
||||
desiredBotCount = Q_max(0, desiredBotCount - humanPlayersInGame);
|
||||
desiredBotCount = Q_max(0, desiredBotCount - humanPlayersInGame + spectatorPlayersInGame);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -902,7 +903,7 @@ void CCSBotManager::MaintainBotQuota()
|
||||
// wait for a player to join, if necessary
|
||||
if (cv_bot_join_after_player.value > 0.0)
|
||||
{
|
||||
if (humanPlayersInGame == 0)
|
||||
if (humanPlayersInGame == 0 && spectatorPlayersInGame == 0)
|
||||
desiredBotCount = 0;
|
||||
}
|
||||
|
||||
@ -917,9 +918,9 @@ void CCSBotManager::MaintainBotQuota()
|
||||
|
||||
// if bots will auto-vacate, we need to keep one slot open to allow players to join
|
||||
if (cv_bot_auto_vacate.value > 0.0)
|
||||
desiredBotCount = Q_min(desiredBotCount, gpGlobals->maxClients - (totalHumansInGame + 1));
|
||||
desiredBotCount = Q_min(desiredBotCount, gpGlobals->maxClients - (humanPlayersInGame + 1));
|
||||
else
|
||||
desiredBotCount = Q_min(desiredBotCount, gpGlobals->maxClients - totalHumansInGame);
|
||||
desiredBotCount = Q_min(desiredBotCount, gpGlobals->maxClients - humanPlayersInGame + spectatorPlayersInGame);
|
||||
|
||||
#ifdef REGAMEDLL_FIXES
|
||||
// Try to balance teams, if we are in the first specified seconds of a round and bots can join either team.
|
||||
|
@ -880,7 +880,13 @@ void EXT_FUNC CHalfLifeMultiplay::__API_HOOK(CheckWinConditions)()
|
||||
#ifdef REGAMEDLL_FIXES
|
||||
// If a winner has already been determined.. then get the heck out of here
|
||||
if (m_iRoundWinStatus != WINSTATUS_NONE)
|
||||
{
|
||||
// still check if we lost players to where we need to do a full reset next round...
|
||||
int NumDeadCT, NumDeadTerrorist, NumAliveTerrorist, NumAliveCT;
|
||||
InitializePlayerCounts(NumAliveTerrorist, NumAliveCT, NumDeadTerrorist, NumDeadCT);
|
||||
|
||||
return;
|
||||
}
|
||||
#else
|
||||
// If a winner has already been determined and game of started.. then get the heck out of here
|
||||
if (m_bGameStarted && m_iRoundWinStatus != WINSTATUS_NONE)
|
||||
|
@ -8216,6 +8216,12 @@ void CBasePlayer::__API_HOOK(SwitchTeam)()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef REGAMEDLL_FIXES
|
||||
// Initialize the player counts now that a player has switched teams
|
||||
int NumDeadCT, NumDeadTerrorist, NumAliveTerrorist, NumAliveCT;
|
||||
CSGameRules()->InitializePlayerCounts(NumAliveTerrorist, NumAliveCT, NumDeadTerrorist, NumDeadCT);
|
||||
#endif
|
||||
}
|
||||
|
||||
void CBasePlayer::UpdateShieldCrosshair(bool draw)
|
||||
|
@ -131,6 +131,39 @@ int UTIL_HumansInGame(bool ignoreSpectators)
|
||||
return iCount;
|
||||
}
|
||||
|
||||
// Returns the number of human spectators in the game
|
||||
int UTIL_SpectatorsInGame()
|
||||
{
|
||||
int iCount = 0;
|
||||
|
||||
for (int iIndex = 1; iIndex <= gpGlobals->maxClients; iIndex++)
|
||||
{
|
||||
CBasePlayer* pPlayer = UTIL_PlayerByIndex(iIndex);
|
||||
|
||||
if (!pPlayer)
|
||||
continue;
|
||||
|
||||
if (FNullEnt(pPlayer->pev))
|
||||
continue;
|
||||
|
||||
if (FStrEq(STRING(pPlayer->pev->netname), ""))
|
||||
continue;
|
||||
|
||||
if (pPlayer->IsProxy())
|
||||
continue;
|
||||
|
||||
if (pPlayer->IsBot())
|
||||
continue;
|
||||
|
||||
if (pPlayer->m_iTeam != SPECTATOR)
|
||||
continue;
|
||||
|
||||
iCount++;
|
||||
}
|
||||
|
||||
return iCount;
|
||||
}
|
||||
|
||||
int UTIL_HumansOnTeam(int teamID, bool isAlive)
|
||||
{
|
||||
int iCount = 0;
|
||||
|
@ -167,6 +167,7 @@ int UTIL_HumansInGame(bool ignoreSpectators = false);
|
||||
|
||||
bool UTIL_IsNameTaken(const char *name, bool ignoreHumans = false);
|
||||
int UTIL_ClientsInGame();
|
||||
int UTIL_SpectatorsInGame();
|
||||
int UTIL_ActivePlayersInGame();
|
||||
int UTIL_BotsInGame();
|
||||
bool UTIL_KickBotFromTeam(TeamName kickTeam);
|
||||
|
Loading…
x
Reference in New Issue
Block a user