Skip to content

npc_destroy: Defer NPC destruction via timer

Free Yorp requested to merge save-this-one-for-later into master

055-1 _nodes.txt will call destroy; from within OnInit, that is during an iteration of the global ev_db. Previously, concurrent modification invalidated this iteration, resulting in a crash.

This still nullifes oid, dequeues all timers, and effectively calls builtin_end.

npc_data::deletion_pending is extended to include a third state. In addition to no deletion happening, and indicating when npc_free is currently on the stack, it now also tracks whether the NPC is about to be deleted by a timer.

This means that an NPC which is about to be deleted is still blocked from triggering new events, much like an NPC actively being deleted would.

Starting or continuing an NPC dialog with an NPC that does not, or is about to no longer exist, is now also blocked.

npc_scriptcont now also consistently returns 1 on failure, though in practice, this return value was always ignored.

Merge request reports