R2Northstar/NorthstarMods

Infection crashes when started with zero players

Closed this issue · 6 comments

Got a bug report by a server host with the following screenshot
image

Looking at the relevant line it seems like infection started with zero players, passing 0 to RandomInt which requires a value greater than zero.

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

Poking @x3Karma who wrote infection initially IIRC ^^

Honestly lobbies with 0 players should go into a like "hibernation" state where it just waits forever in prematch or something, instead of things like round based modes just going to round like 700 and then lagging loads.

I feel like this problem shouldn't be something that individual gamemodes should have to deal with really

Honestly lobbies with 0 players should go into a like "hibernation" state where it just waits forever in prematch or something, instead of things like round based modes just going to round like 700 and then lagging loads.

Agreed, although it won't fully solve the issue here cause someone joining the server to wake it up and then leaving before first infected is selected will still script error it.

however, simple solution would be to wait until at least 1 player after waiting for this

so that would be something like

while (GetPlayerArray().len() == 0)
	wait 1

come to think of it, infection isn't rly playable unless you have 2 players, cos otherwise the infected just instantly win after the first and only player gets automatically infected. Perhaps a check like this would be better

while (GetPlayerArray().len() < 2)
	wait 1

Could also do WaitFrame() here but personally I dont rly see the point in checking every frame for something like this

Agreed, although it won't fully solve the issue here cause someone joining the server to wake it up and then leaving before first infected is selected will still script error it.

This is also true, perhaps a pass should be made over all modes to make sure that we check things properly after doing any waiting, because I see issues like this very often in scripts

Honestly lobbies with 0 players should go into a like "hibernation" state where it just waits forever in prematch or something, instead of things like round based modes just going to round like 700 and then lagging loads.

I feel like this problem shouldn't be something that individual gamemodes should have to deal with really

Feel like it's already a thing, live fire matches won't start if there's no players.

I think it's just that a player joining then leaving would cause this bug to occur.