Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - Autoquark

#1
Bugs / Possible bug in ExplosionCellsToHit
September 17, 2020, 08:08:48 AM
I was looking at the decompiled source for DamageWorker.ExplosionCellsToHit and I noticed that in the second loop, it only adds cells to adjWallCells if adjWallCells already contains that cell. Since adjWallCells starts out empty, this means that the second loop will never do anything. Not sure if this has any ingame effects, but it seems like it must be a bug - I suspect the intent was to check that adjWallCells does *not* already contain the cell.
#2
Repro steps:
1. In a mod dll, define a subclass of ThingComp and override PostDestroy. To make the bug obvious, you could have the method try to make use of the "previousMap" parameter e.g. by spawning something on that map.

GenPlace.TryPlaceThing(ThingMaker.MakeThing(ThingDefOf.Silver), parent.Position, previousMap, ThingPlaceMode.Near);

2. Attach the comp to a Pawn, e.g. by xml patching it into the comps list of some existing pawn type. Here's my XML that patches a comp into every pawn in the game:
<Patch>
<Operation Class="PatchOperationConditional">
<xpath>/Defs/ThingDef/category[text() = 'Pawn']/../comps</xpath>
<nomatch Class="PatchOperationAdd">
<xpath>/Defs/ThingDef/category[text() = 'Pawn']/..</xpath>
<value>
<comps>
<li>
<compClass>MyMod.MyComp</compClass>
</li>
</comps>
</value>
</nomatch>
<match Class="PatchOperationAdd">
<xpath>/Defs/ThingDef/category[text() = 'Pawn']/../comps</xpath>
<value>
<li>
<compClass>MyMod.MyComp</compClass>
</li>
</value>
</match>
</Operation>
</Patch>

3. Kill a pawn with the dev tools
Expected: previousMap refers to the map on which the pawn was just before being destroyed. Actual: previousMap is null