Fix Dead process - added dead transaction and refactored as state mac… - #39
Fix Dead process - added dead transaction and refactored as state mac…#39nightNR wants to merge 1 commit into
Conversation
…hine to ensure idempotency and retryability
|
Podla vsetkeho bug suvisi s tym, kedy sa characteru setne STATF_DEAD flag ak niektory z krokov po nom skonci vynimkou, tak char zostane v stave ze uz ho scheduler nepusti do CCHar:Dead() najjednoduchsie by bolo STATF_DEAD setnut az na konci ale to by v pripade vynimky dovolilo zbehnut Death viac krat, a tak by mohlo docahdzat trebarz k zdvojovaniu lootu.. V tejto prerabke je to prerobene na tranzakciu ktora si znaci kazdy bod processu ktory dokazal dobehnut.. ak niektory nedobehne, dovoli retry ale len bodov ktore mozu byt zopakovane alebo neboli skoncene. Mal by par krat skusit retry a potom zalogovat vyunimku a ticho skoncit... Neviem to rozumne vyskusat kedze neviem uplne dany stav nasimulovat.. + takze by to chcelo skor otestovat v zivej situacii |
Make character death a resumable state machine to ensure idempotency and retryability
Description
This PR fixes an issue where a character—particularly a summoned NPC such as Blade Spirit—could remain in the world with 0 HP while being impossible to kill or
dispel.
The original death process set STATF_DEAD before completing all cleanup operations. If an exception occurred afterward, the periodic tick caught it and
rescheduled the character. Subsequent ticks skipped Death() because STATF_DEAD was already set, leaving a permanently inconsistent character that could still
occupy summon/follower slots.
This PR refactors character death into a resumable transaction with explicit phases. Completed phases are recorded, internal cleanup operations can be retried,
and irreversible callbacks are protected against duplicate execution.
The implementation includes:
———
Type of Change
———
Related Issues
No related issue or pull request is currently linked.
———
Testing
Added isolated tests covering:
Test result:
8 test cases passed
66 assertions passed
The changed production translation units compile successfully. A complete server build is currently blocked by a pre-existing unrelated C4706 warning treated
as an error in CCChampion.cpp.
A full runtime Blade Spirit test with the latest ScriptPack has therefore not yet been completed.
———
Checklist
———
Additional Notes
Active death transactions remain tickable even when their sector is sleeping. Recovery therefore does not depend on a player keeping the current or adjacent
sector awake.
Script callbacks and other irreversible side effects use at-most-once semantics. Internal cleanup phases are retried until successful. After repeated failures,
non-bonded NPCs enter emergency finalization so they cannot remain permanently in the world or occupy follower slots.
The transaction is serialized as DEATHTXN while active. Completed player and bonded-pet deaths do not retain transaction state. Legacy dead non-bonded NPCs
without this state enter conservative recovery without replaying kill, loot, or corpse triggers.