Skip to content

Guard HuntManager.OnBotCreated against null SpawnProfileData/Id_spawn - #6

Open
jbo3320 wants to merge 1 commit into
TacticalToaster:mainfrom
jbo3320:fix/huntmanager-null-guard
Open

Guard HuntManager.OnBotCreated against null SpawnProfileData/Id_spawn#6
jbo3320 wants to merge 1 commit into
TacticalToaster:mainfrom
jbo3320:fix/huntmanager-null-guard

Conversation

@jbo3320

@jbo3320 jbo3320 commented Jul 23, 2026

Copy link
Copy Markdown

Fixes #5.

HuntManager.OnBotCreated runs for every created bot and dereferences bot.SpawnProfileData.SpawnParams.Id_spawn.ToLower() with no null check. Bots spawned outside the normal EFT flow — e.g. MiyakoCarryService's carry bot via SpawnMcsBotPlayer — can have a null SpawnProfileData / Id_spawn, so this throws a NullReferenceException (observed at offset 0x0000c). Because the handler runs inside BotSpawner.OnBotCreated, the throw propagates up and aborts the other mod's spawn — that mod's bot intermittently fails to appear.

This adds a null-conditional guard. A null Id_spawn is by definition not a "hunt" spawn, so early-returning is the correct behavior — no functional change for real hunt bots.

Before

if (!bot.SpawnProfileData.SpawnParams.Id_spawn.ToLower().Contains("hunt")) return;

After

if (bot?.SpawnProfileData?.SpawnParams?.Id_spawn?.ToLower().Contains("hunt") != true) return;

Full repro and stack trace are in #5. Cross-reported downstream at himesamanoyume/MiyakoCarryService#10.

OnBotCreated runs for every created bot and dereferenced
bot.SpawnProfileData.SpawnParams.Id_spawn.ToLower() with no null check. Bots
spawned outside the normal EFT flow (e.g. MiyakoCarryService's carry bot via
SpawnMcsBotPlayer) can have a null SpawnProfileData/Id_spawn, throwing an NRE.
Because the handler runs inside BotSpawner.OnBotCreated, the throw propagates
up and aborts the other mod's spawn. A null Id_spawn is not a "hunt" spawn, so
guarding and early-returning is the correct behavior.

Fixes TacticalToaster#5.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.

HuntManager.OnBotCreated throws unhandled NRE for a foreign bot, aborting another mod's spawn (Fika headless)

1 participant