Skip to content

Fix net_Export assert when a save runs while an NPC is spawning - #763

Merged
themrdemonized merged 1 commit into
themrdemonized:prfrom
vacwave:azazel_netempty_fix
Oct 21, 2026
Merged

themrdemonized merged 1 commit into
themrdemonized:prfrom
vacwave:azazel_netempty_fix

Conversation

@vacwave

@vacwave vacwave commented Oct 15, 2026

Copy link
Copy Markdown

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() in CAI_Stalker::net_Export (or CCustomMonster / CBaseMonster::net_Export for mutants).

This can happen when a script saves from a spawn callback, or during a crash save. Since xrDebug::backend writes 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 the net_Export assert 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:

local fire = false

function on_game_start()
	RegisterScriptCallback("on_key_press", function(dik)
		if dik == DIK_keys.DIK_NUMPAD0 then fire = true end
	end)

	RegisterScriptCallback("npc_on_net_spawn", function()
		if fire then
			fire = false
			exec_console_cmd("save net_export")
		end
	end)
end

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.

@themrdemonized
themrdemonized changed the base branch from all-in-one-vs2022-wpo to pr October 21, 2026 20:51
@themrdemonized
themrdemonized merged commit 9175820 into themrdemonized:pr Oct 21, 2026
17 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Anomaly with only modded exes crashes with Azazael mode enabled

2 participants