Save-breaking bug with no determinate cause

Started by birbules, January 25, 2021, 06:27:35 AM

Previous topic - Next topic

birbules

Hello!

I've been playing a fairly heavily modded Rimworld game for a while now and only just recently, I've run into a severe issue that causes my current colonies' map to generate completely grey, as so:



I have an autosave that luckily is devoid of this bug, but it always, no matter what I've tried, eventually ends up like the image above. I think I've managed to narrow it down to one specific error in the debug log:

Root level exception in Update(): System.InvalidCastException: Specified cast is not valid.
  at RimWorld.PowerConnectionMaker+<PotentialConnectorsForTransmitter>d__5.MoveNext () [0x00119] in <d72310b4d8f64d25aee502792b58549f>:0
  at System.Linq.Enumerable.Count[TSource] (System.Collections.Generic.IEnumerable`1[T] source) [0x00052] in <351e49e2a5bf4fd6beabb458ce2255f3>:0
  at VFEMech.PotentialConnectorsForTransmitter_Patch.Postfix (System.Collections.Generic.IEnumerable`1[RimWorld.CompPower]& __result, RimWorld.CompPower b) [0x00001] in <38822466d329429fa844bf0eb6a57d01>:0
  at (wrapper dynamic-method) RimWorld.PowerConnectionMaker.RimWorld.PowerConnectionMaker.PotentialConnectorsForTransmitter_Patch1(RimWorld.CompPower)
  at RimWorld.PowerConnectionMaker.ConnectAllConnectorsToTransmitter (RimWorld.CompPower newTransmitter) [0x00000] in <d72310b4d8f64d25aee502792b58549f>:0
  at RimWorld.PowerNetManager.TryCreateNetAt (Verse.IntVec3 cell) [0x00058] in <d72310b4d8f64d25aee502792b58549f>:0
  at RimWorld.PowerNetManager.UpdatePowerNetsAndConnections_First () [0x001cb] in <d72310b4d8f64d25aee502792b58549f>:0
  at (wrapper dynamic-method) Verse.Map.Verse.Map.MapUpdate_Patch2(Verse.Map)
  at (wrapper dynamic-method) Verse.Game.Verse.Game.UpdatePlay_Patch2(Verse.Game)
  at (wrapper dynamic-method) Verse.Root_Play.Verse.Root_Play.Update_Patch1(Verse.Root_Play)
Verse.Log:Error(String, Boolean)
Verse.Root_Play:Verse.Root_Play.Update_Patch1(Root_Play)


It seems to have something to do with my power grid and a structure that is trying to make a connection, but I wouldn't have a clue which it would be and why.  As far as I know, I see no way to properly resolve this issue without having to completely abandon my save which, you know, would kind of suck :(

Here is my log and modlist for reference:

https://gist.github.com/HugsLibRecordKeeper/50525b9fa5da12cc015d8e1784282433

Any help would be greatly appreciated, thanks in advance!

Canute

Hi,
since the error is about power/powerconnection i would ask at first place the author of
Underground Power Conduits
and/or
Vanilla Furniture Expanded - Power

tuk0z

Have the same issue, at least exact same error (minus a few lines named after mods I don't use) than birbules. I use neither Underground Power Conduits nor Vanilla Furniture Expanded - Power but Murmur's Subsurface Conduit, and just reported to this dev on the Steam workshop mod page

halfdan

Dang I just got this error too.

I was actually able to get back to pre-black screen with editing my savegame with ruby and an XML parser. Attempting to put the power grid back unfortunately gives me the same issue.

Like tuk0z I also thought this could be related to Subsurface Conduit, but when putting the grid back, and only using Vanilla Conduits, I get the same issue. It's also one specific grid cell, I put a conduit on that cell and then a conduit on an adjacent one and it goes black again. Very weird. Continuing to investigate as I'm not ready to abandon, and I'm having some progress.

Sorry to rez an old topic, but this is very relevant.

I'll also post my savegame editing code, though you'd need some time to understand so not sure if that helpful

```
#!/usr/bin/ruby -w

require 'rexml/document'
require 'byebug'
include REXML

# xmlfile = File.new("./save.xml")
xmlfile = File.new("./save.xml")
xmldoc = Document.new(xmlfile)

# Info for the first cloth found
CONDUIT_THING_REFERENCE = '//li[contains(text(),"Conduit")]'

SUBSURFACE_BUILDING = '//thing[@Class="MUR_SubsurfaceConduit.SubsurfaceConduit"]'
SWITCH_BUILDING = '//thing[@Class="Building_PowerSwitch"]/def[contains(text(), "PowerSwitch")]'
BATTERY_BUILDING = '//thing[@Class="Building_Battery"]/def[contains(text(), "Battery")]'
POWER_CONDUIT_BUILDING = '//thing[@Class"Building"]/def[contains(text(), "PowerConduit")]'

PARENT_CONDUIT = '//parentThing[contains(text(), "Conduit")] | //parentThing[contains(text(), "Battery")] | //parentThing[contains(text(), "Switch")]'

XPath.each(xmldoc, CONDUIT_THING_REFERENCE) do |node|
  puts node
  node.remove
end

XPath.each(xmldoc, SUBSURFACE_BUILDING) do |node|
  puts node
  node.remove
end

XPath.each(xmldoc, SWITCH_BUILDING) do |node|
  puts node.parent
  node.parent.remove
end

XPath.each(xmldoc, BATTERY_BUILDING) do |node|
  puts node.parent
  node.parent.remove
end

XPath.each(xmldoc, POWER_CONDUIT_BUILDING) do |node|
  puts node.parent
  node.parent.remove
end

XPath.each(xmldoc, PARENT_CONDUIT) do |node|
  replacement = Element.new("parentThing")
  replacement.text = "null"
  node.replace_with(replacement)
end

File.open("./output.xml", "w") {|f| f.write xmldoc.to_s}

```

halfdan

Wow @birbules saw your comment in https://steamcommunity.com/workshop/filedetails/discussion/1321849735/3114770279417190469 and realized I had two of those deployable barriers, removed them and now there's no error anymore!

Thank you!