[MIRROR] Splits reagent metabolization from reagent effects. #733
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.
Mirrored on Skyrat: Skyrat-SS13/Skyrat-tg#25125
Original PR: tgstation/tgstation#79314
About The Pull Request
I've separated the instructions responsible for gradually removing reagents from a living holder from the main
on_mob_life
andon_mob_dead
procs, and made sure they're run after them.I've done a fair bit of early returns as well.
Why It's Good For The Game
The problem here is that most reagents will eventually be deleted before
on_mob_life
andon_mob_dead
have finished running, since the statements that handle the reagent removal are found within parent calls that are often called at the start of the different definitions of the proc . To make it easier to understand, here's a simplified chain of events:holder.metabolize_reagent -> the parent call of reagent.on_mob_life -> holder.remove_reagent -> holder.update_total -> reagent.on_mob_end_metabolizate -> reagent.on_mob_delete -> qdel(reagent) -> the actual reagent.on_mob_life
Basically, the reagent is getting deleted before it has finished "ticking", and that's bad, simple as that.
Also, by separating these instructions from the rest, we won't have to enforce any such nuisance as
return ..() || need_mob_update
.TL;DR: This fixes #79267.
Changelog
🆑 Ghommie
fix: Fixed the infinite growth serum exploit.
fix: Fixed generic nutriment processing even when dead.
/:cl: