Skip to content

Commit

Permalink
Prevent crash when selecting first infected (#731)
Browse files Browse the repository at this point in the history
End match early if there are no players when trying to select infected
  • Loading branch information
ASpoonPlaysGames authored Jan 4, 2024
1 parent 0e15364 commit 4450583
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@ void function SelectFirstInfectedDelayed()
wait 10.0 + RandomFloat( 5.0 )

array<entity> players = GetPlayerArray()

// End game if server empty on selecting infected
if ( !players.len() )
{
printt( "Couldn't select first infected: player array was empty" )
SetWinner( INFECTION_TEAM_SURVIVOR )
return
}

entity infected = players[ RandomInt( players.len() ) ]

InfectPlayer( infected )
Expand Down

0 comments on commit 4450583

Please sign in to comment.