[HL25] Backport changes to multiplayer spawn selection logic

This commit is contained in:
Joël Troch 2024-08-28 15:43:29 +02:00
parent df5605d5a3
commit b61c0beadf

View file

@ -2817,6 +2817,8 @@ edict_t* EntSelectSpawnPoint(CBaseEntity* pPlayer)
CBaseEntity* pSpot;
edict_t* player;
int nNumRandomSpawnsToTry = 10;
player = pPlayer->edict();
// choose a info_player_deathmatch point
@ -2831,9 +2833,21 @@ edict_t* EntSelectSpawnPoint(CBaseEntity* pPlayer)
}
else if (g_pGameRules->IsDeathmatch())
{
if (NULL == g_pLastSpawn)
{
int nNumSpawnPoints = 0;
CBaseEntity* pEnt = UTIL_FindEntityByClassname(NULL, "info_player_deathmatch");
while (NULL != pEnt)
{
nNumSpawnPoints++;
pEnt = UTIL_FindEntityByClassname(pEnt, "info_player_deathmatch");
}
nNumRandomSpawnsToTry = nNumSpawnPoints;
}
pSpot = g_pLastSpawn;
// Randomize the start spot
for (int i = RANDOM_LONG(1, 5); i > 0; i--)
for (int i = RANDOM_LONG(1, nNumRandomSpawnsToTry - 1); i > 0; i--)
pSpot = UTIL_FindEntityByClassname(pSpot, "info_player_deathmatch");
if (FNullEnt(pSpot)) // skip over the null point
pSpot = UTIL_FindEntityByClassname(pSpot, "info_player_deathmatch");