RimWorld

RimWorld

Celsius Patches
Bugs
[RF] Concrete (Continued).xml
Line 41:
Instead of
RFFPlaticreteEmbrasure
it should be
RFFPlasticreteEmbrasure

Additionally:
There is a mod for a mod, Concrete Patches , one that modernizes [RF] Concrete (Continued), provides additional options, like disabling embrasures, as well as compatibility with other mods, like Soil Relocation Framework.

https://gtm.steamproxy.vip/workshop/filedetails/discussion/2012397587/4356745862498490708/

https://github.com/Mlg-arch/ConcretePatches

However, when using this mod, specifically options that remove certain things, causes errors with [RF] Concrete (Continued).xml patch. Below an example with embrasures set to disabled:
When an option is disabled, Concrete Patches removes the definition via:
<Operation Class="XmlExtensions.PatchOperationSafeRemove"> <xpath>Defs/ThingDef[defName="Embrasure"]</xpath> </Operation>

This in turn causes the following errors:

[Celsius Patches - Start of stack trace] Verse.PatchOperationAddModExtension(xpath="Defs/ThingDef[defName="Embrasure"]"): Failed to find a node with the given xpath Verse.PatchOperationSequence: Error in the operation at position=3 Verse.PatchOperationFindMod([RF] Concrete (Continued)): Error in <match> [End of stack trace] The top operation is the one that failed, the ones below it are the parents Source file: D:\games\RimWorld\Mods\3072081544\1.5\Patches\Mods\[RF] Concrete (Continued).xml UnityEngine.StackTraceUtility:ExtractStackTrace () (wrapper dynamic-method) MonoMod.Utils.DynamicMethodDefinition:Verse.Log.Error_Patch4 (string) XmlExtensions.ErrorManager:PrintErrors (string,Verse.ModContentPack) XmlExtensions.PatchOperation_Patch:Postfix (Verse.PatchOperation,bool&,System.Xml.XmlDocument) (wrapper dynamic-method) MonoMod.Utils.DynamicMethodDefinition:Verse.PatchOperation.Apply_Patch2 (Verse.PatchOperation,System.Xml.XmlDocument) (wrapper dynamic-method) MonoMod.Utils.DynamicMethodDefinition:Verse.LoadedModManager.ApplyPatches_Patch8 (System.Xml.XmlDocument,System.Collections.Generic.Dictionary`2<System.Xml.XmlNode, Verse.LoadableXmlAsset>) Verse.LoadedModManager:LoadAllActiveMods (bool) Verse.PlayDataLoader:DoPlayLoad () Verse.PlayDataLoader:LoadAllPlayData (bool) Verse.Root/<>c:<Start>b__6_1 () Verse.LongEventHandler:RunEventFromAnotherThread (System.Action) Verse.LongEventHandler/<>c:<UpdateCurrentAsynchronousEvent>b__28_0 () System.Threading.ThreadHelper:ThreadStart_Context (object) System.Threading.ExecutionContext:RunInternal (System.Threading.ExecutionContext,System.Threading.ContextCallback,object,bool) System.Threading.ExecutionContext:Run (System.Threading.ExecutionContext,System.Threading.ContextCallback,object,bool) System.Threading.ExecutionContext:Run (System.Threading.ExecutionContext,System.Threading.ContextCallback,object) System.Threading.ThreadHelper:ThreadStart () [Celsius Patches] Patch operation Verse.PatchOperationFindMod([RF] Concrete (Continued)) failed file: D:\games\RimWorld\Mods\3072081544\1.5\Patches\Mods\[RF] Concrete (Continued).xml UnityEngine.StackTraceUtility:ExtractStackTrace () (wrapper dynamic-method) MonoMod.Utils.DynamicMethodDefinition:Verse.Log.Error_Patch4 (string) Verse.PatchOperation:Complete (string) (wrapper dynamic-method) MonoMod.Utils.DynamicMethodDefinition:Verse.LoadedModManager.ClearCachedPatches_Patch3 () Verse.LoadedModManager:LoadAllActiveMods (bool) Verse.PlayDataLoader:DoPlayLoad () Verse.PlayDataLoader:LoadAllPlayData (bool) Verse.Root/<>c:<Start>b__6_1 () Verse.LongEventHandler:RunEventFromAnotherThread (System.Action) Verse.LongEventHandler/<>c:<UpdateCurrentAsynchronousEvent>b__28_0 () System.Threading.ThreadHelper:ThreadStart_Context (object) System.Threading.ExecutionContext:RunInternal (System.Threading.ExecutionContext,System.Threading.ContextCallback,object,bool) System.Threading.ExecutionContext:Run (System.Threading.ExecutionContext,System.Threading.ContextCallback,object,bool) System.Threading.ExecutionContext:Run (System.Threading.ExecutionContext,System.Threading.ContextCallback,object) System.Threading.ThreadHelper:ThreadStart ()


To avoid this, and make it compatibile with both, I have rewritten [RF] Concrete (Continued).xml, using PatchOperationConditional, hopefully correctly...
XML below, a bit unsure if ThingDef were set correctly but errors are gone, for both disabled and enabled options.

<?xml version="1.0" encoding="utf-8"?> <Patch> <Operation Class="PatchOperationFindMod"> <mods> <li>[RF] Concrete (Continued)</li> </mods> <match Class="PatchOperationSequence"> <operations> <li Class="PatchOperationConditional"> <xpath>Defs/ThingDef/RFC_WallBase[defName="RFFConcreteWall" or defName="RFFReinforcedConcreteWall" or defName="RFFPlasticreteWall"]</xpath> <match Class="PatchOperationAddModExtension"> <value> <li Class="Celsius.ThingThermalProperties"> <heatCapacity>8</heatCapacity> <insulation>6</insulation> </li> </value> </match> </li> <li Class="PatchOperationConditional"> <xpath>Defs/ThingDef/RFC_DoorBase[defName="RFFConcreteDoor" or defName="RFFConcreteAutodoor" or defName="RFFPlasticreteDoor" or defName="RFFPlasticreteAutodoor"]</xpath> <match Class="PatchOperationAddModExtension"> <value> <li Class="Celsius.ThingThermalProperties"> <heatCapacity>6</heatCapacity> <insulation>4</insulation> <airflowWhenOpen>0.75</airflowWhenOpen> </li> </value> </match> </li> <li Class="PatchOperationConditional"> <xpath>Defs/ThingDef/RFC_EmbrasureBase[defName="Embrasure"]</xpath> <match Class="PatchOperationAddModExtension"> <value> <li Class="Celsius.ThingThermalProperties"> <heatCapacity>7</heatCapacity> <insulation>5</insulation> <volume>.01</volume> <airflow>0.25</airflow> </li> </value> </match> </li> <li Class="PatchOperationConditional"> <xpath>Defs/ThingDef/RFC_EmbrasureBase[defName="BrickEmbrasure" or defName="RFFConcreteEmbrasure" or defName="RFFPlasticreteEmbrasure"]</xpath> <match Class="PatchOperationAddModExtension"> <value> <li Class="Celsius.ThingThermalProperties"> <heatCapacity>7</heatCapacity> <insulation>5</insulation> <airflow>0.25</airflow> </li> </value> </match> </li> <li Class="PatchOperationConditional"> <xpath>Defs/ThingDef/ResourceBase_Concrete[defName="RFFBlocksConcrete"]</xpath> <match Class="PatchOperationAddModExtension"> <value> <li Class="Celsius.StuffThermalProperties"> <volumetricHeatCapacity>1100</volumetricHeatCapacity> <insulationFactor>0.8</insulationFactor> </li> </value> </match> </li> </operations> </match> </Operation> </Patch>
Last edited by Jasser_Arrafat; 12 Jul @ 8:56am
< >
Showing 1-4 of 4 comments
albinogod  [developer] 16 Jul @ 7:34pm 
Thank you for the heads up and possible fix, I will check your proposed fix when I have time.
Not a problem :)
Last edited by Jasser_Arrafat; 17 Jul @ 4:13am
albinogod  [developer] 17 Jul @ 7:21am 
Your code almost worked, taking some minor tweaking. At the same time, it drew my attention to a different bug that needed to be fixed. At some point Mile changed it to use Wall as a parent introducing the inherit issue that plagues my 1.6 patches.

But this is for 1.5 so it is an easy fix, and worth going over in hopes it helps you get a better idea of how Rimworld deals with xml. This or something similar should be the first patch in the sequence.
<li Class="PatchOperationAdd"> <xpath>Defs/ThingDef[defName="RFFConcreteWall" or defName="RFFReinforcedConcreteWall" or defName="RFFPlasticreteWall" or defName="Embrasure" or defName="BrickEmbrasure" or defName="RFFConcreteEmbrasure" or defName="RFFPlasticreteEmbrasure"]</xpath> <value> <modExtensions Class="Celsius.ThingThermalProperties" Inherit="false"></modExtensions> </value> </li>

From there we still get no errors, but the walls do not have thermal values. This tells us that the match condition isn't being met. In this case it is because you are looking at an invalid xpath. I am not 100% which is the actual cause, but it is either that you can't use an object's parent for a xpath or the parent being abstract and thus not loaded in memory at the point xml patches are applied.

Fixing that by shorting the xpath to just "Defs/ThingDef[defName=...", we get a new error.
Verse.PatchOperationAddModExtension(xpath=""): '' is an invalid expression.

The Conditional does not pass on any details do the nested operation, so you do have to give it isn't own xpath. With the final note being that for ti to fully work as you desire, you would have to break up the patches so you are patching one wall/door/item at a time with each pair of patches looking something like this::
<li Class="PatchOperationConditional"> <xpath>Defs/ThingDef[defName="RFFConcreteDoor"]</xpath> <match Class="PatchOperationAdd"> <xpath>Defs/ThingDef[defName="RFFConcreteDoor"]</xpath> <value> <li Class="Celsius.ThingThermalProperties"> </value> </match> </li> <li Class="PatchOperationConditional"> <xpath>Defs/ThingDef[defName="RFFConcreteDoor"]</xpath> <match Class="PatchOperationAddModExtension"> <xpath>Defs/ThingDef[defName="RFFConcreteDoor"]</xpath> <value> <li Class="Celsius.ThingThermalProperties"> <heatCapacity>6</heatCapacity> <insulation>4</insulation> <airflowWhenOpen>0.75</airflowWhenOpen> </li> </value> </match> </li>

Personally, I feel like this kind of patch is a bit overkill for an edge case caused by advanced users. Especially since the error it causes is fairly benign.
Thanks a lot for the writeup! Yeah, I am a bit new to Rimworld XML world :)
I had the exact xpath error, hence added the parent ones and it seemed to be working - no error on disabled embrasures and concrete walls did show thermal properties.
But then again, guess not many people use that additional mod, and no idea if dev is even still maintaining it.
Thanks for looking into it though!
Last edited by Jasser_Arrafat; 17 Jul @ 9:13am
< >
Showing 1-4 of 4 comments
Per page: 1530 50