Repository navigation
Fix net_Export assert when a save runs while an NPC is spawning - #763
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #551
Stalkers and mutants fill NET only at the end of net_Spawn. If a save or level change happens while an NPC is still inside net_Spawn, the NPC is exported with an empty queue and the game crashes with
!NET.empty()inCAI_Stalker::net_Export(orCCustomMonster/CBaseMonster::net_Exportfor mutants).This can happen when a script saves from a spawn callback, or during a crash save. Since
xrDebug::backendwrites the crash save before logging the error, any fatal error during an NPC spawn hits this assert inside the crash save. The log then shows thenet_Exportassert instead of the real error.Fix:
Add
CCustomMonster::net_Relevant(), which returns false until NET has been filled, so an NPC that hasn't finished spawning is not exported. The server still has the NPCs spawn state, so nothing is lost.This is the assert reported for azazel deaths in #551. What used to trigger it during the corpse spawn was probably removed by f5e8df4 (an object released while online stayed in the A-Life update list, Azazel releases the stalker you take over) and 07aeb74 (remove_links crashed on dead NPCs which have no squad memory). I crashed on azazel death with older builds but not with the latest one. The assert itself can still happen, and this fixes it.
Testing:
Save this as
zz_azazel_netexport.script, press numpad 0 in game then spawn a stalker. On current exes the game crashes with the assert. With the fix, the game makes a net_export save and the game doesn't crash. Used claude to find the issue. Tested in base Anomaly, Gamma and the MT build.