AsyncTime: Skip timestamp fixing for destroyed pawns - #979
Open
M-r-A wants to merge 1 commit into
Open
Conversation
FixPawn shifts a pawn's timestamps when it crosses between time contexts, and
visits the pawn's fields by saving it, so that a prefix on RegisterDeepSaved can
rewrite each one as the scribe walks past. Vanilla warns when a deep save reaches
a destroyed thing, so each visit for a dead pawn logged
Deep-saving destroyed thing X with saveDestroyedThings==false
Anything killed on a map reaches WorldPawns.AddPawn through Destroy, so an
ordinary predator hunt produced one warning per kill.
Return early instead. The fields involved -- canSleepTick, canLovinTick,
ticksWhenAllowedToEscapeAgain, lastPrisonBreakTicks -- all describe behaviour only
a live pawn has, so there is nothing to correct. A pawn that is later resurrected
and spawned gets the correction from the SpawnSetup path.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Every animal death writes a warning to the log. A predator hunt produces one per kill.
Where it comes from
The stack under that warning is a complete causal chain, and the middle of it is ours:
Reading upward from the bottom: a predator lands a melee hit, the prey dies,
Pawn.Destroyhands it toWorldPawns.PassToWorld, andAddPawnhits our prefix.FixPawnshifts a pawn's timestamps when it crosses between time contexts, sinceunder
asyncTimeeach map keeps its own tick counter. It visits the pawn's fieldsby saving it —
Scribe.saver.DebugOutputFor— so that a prefix onRegisterDeepSavedcan rewrite each timestamp as the scribe walks past it.That is what trips the warning. Vanilla objects to a deep save reaching a destroyed
thing, and a pawn that arrived here via
Destroyis destroyed by definition. So thewarning fires on every death that passes to world pawns.
Fix
Return early when the pawn is destroyed.
The four fields involved —
canSleepTick,canLovinTick,ticksWhenAllowedToEscapeAgain,lastPrisonBreakTicks— all describe behaviour onlya live pawn has. There is nothing to correct.
Why this is safe
SpawnSetuppathapplies the correction then, driven by
worldPawnRemoveTick.lastMapafter callingFixPawn, so theearly return does not strand a stale marker.
p.Destroyedis simulation state set insideDestroy(), whichruns in the synced tick, so every client takes the same branch. A guard on
client-local state here would have been worse than the warning.
an animal wandering off — still has
Destroyed == falseand still gets itstimestamps corrected.
Testing
Build clean in Debug and Release, 165/165 tests.
Manual verification, two checks:
Deep-saving destroyed thingwarning no longer appears,where it previously appeared once per kill.
Note
The same fix appears as one line item in the "QoL / smaller fixes" list of #961.
Extracted here as a standalone change since that PR touches 98 files and is still
in review; the code is identical, so whichever lands first makes the other a no-op.