Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: intro dropship crash #917

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Bobbyperson
Copy link
Contributor

This PR fixes an inconsistent crash during the intro dropships, which was introduced in #809. Oddly, this issue only seems to happen on dedicated servers.

[00:47:00] [SCRIPT SV] [info] SCRIPT ERROR: [SERVER] getrandom(): Array is empty
[00:47:00] [SCRIPT SV] [info]  -> playerDropship = introDropships.getrandom()
[00:47:00] [SCRIPT SV] [info]
CALLSTACK
*FUNCTION [PutPlayerInDropship()] mp/_classic_mp_dropship_intro.gnut line [168]
*FUNCTION [DropshipIntro_OnClientConnected()] mp/_classic_mp_dropship_intro.gnut line [50]
*FUNCTION [CodeCallback_OnClientConnectionCompleted()] mp/_base_gametype_mp.gnut line [173]

Why this happens:

When the code runs GetEntArrayByClass_Expensive( "info_spawnpoint_dropship_start" ) to get places to spawn the dropships, sometimes it will run before the server has finished loading all the ents, which can cause this to return an empty or incomplete list. There are no checks for this, so the code will continue running until it tries to put players in the dropship, which will cause it to crash due to the list being empty.

The fix:

The prematch code will now wait until all entities have been loaded (AddCallback_EntitiesDidLoad). Additionally, the loop for spawning dropships has been updated to fix a rare case where too few or no dropships can spawn.

Testing:

This fix (and several other attempts) has been extensively tested on the previous ikhadhonger servers. But to test this, simply start a dedicated server and switch maps several times. Without this PR it will eventually crash.

@github-actions github-actions bot added needs testing Changes from the PR still need to be tested needs code review Changes from PR still need to be reviewed in code labels Feb 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs code review Changes from PR still need to be reviewed in code needs testing Changes from the PR still need to be tested
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

1 participant