RimWorld

RimWorld

Ancient mining industry
Fixes for ore dresser + gravship landing + 2 more
Bug 1: the ore dresser machine bug
The cause is this line in StoneCutter.cs:
pickUpCells = GenAdjFast.AdjacentCells8Way(parent.Position, parent.Rotation, parent.RotatedSize);
The problem is that AdjacentCells8Way() returns a reference to a static list, so pickUpCells contains the correct result at the beginning, but once something else uses AdjacentCells8Way() then pickUpCells contains the result given to the other thing and your ore dresser will look for rocks somewhere else on the map.

The fix is to replace the quoted line by:
pickUpCells = new List<IntVec3>(); GenAdjFast.AdjacentCells8Way(parent.Position, parent.Rotation, parent.RotatedSize).CopyToList(pickUpCells);


Bug 2: can't use gravships to go to mining missions
Solution: adding
<gravShipsCanLandOn>true</gravShipsCanLandOn>
inside all <SitePartDef> in Site_Cluster.xml


Bonus
You can remove the StoneCutterUtil class, the base game already has a cached list of all rock chunk defs. What you wanted to do can be done by replacing the inner foreach loop in TryFindChunk() by:
var thingsOnCell = cell.GetThingList(parent.Map); foreach (var thing in thingsOnCell) { if (thing is null) continue; if (ThingCategoryDefOf.StoneChunks.ContainedInThisOrDescendant(thing.def)) { return thing; } }
Internally, ContainedInThisOrDescendant() uses a cached HashSet so it's not rebuilding a list at every call.


Bug 3: the tunnel boring machine's boringCells, dumpingCells, and wallCells are not updated when the machine is manually relocated.
By "manually relocated" I mean that the building is minified, hauled, then redeployed elsewhere.

This becomes a problem when the TBM meets a water tile, automatically stops, but the boringCells are over water. In this case the player will try to relocate the TBM, but it will refuse to start since its boringCells still touches water, meaning that the TBM is essentially bricked there.

Sometimes the TBM stops before moving boringCells over water, in which case it can be restarted, so the easiest way to reproduce the nasty case of the bug is to build the TBM with boringCells over water.

Anyway the fix is to move the GetBoringCells() and GetDumpingCells() calls from Building_BoringMachine::Tick() to the end of Building_BoringMachine::SpawnSetup() .


Bug 4: "Object reference not set to an instance of an object" error in minified TBM description
How to reproduce: build a TBM, uninstall it, SAVE, (restart game?,) LOAD your save, then select the minified TBM. The error will appear in the inspector window.

The problem is that Building_BoringMachine.progress accessors use this.progressTicks which needs this.extension, but extension is only set after being deployed, so it's null for minified buildings.

I suggest checking if .extension is null in .progress accessors and returning 0 / bailing if it is.


Bug 5: "Object reference not set to an instance of an object" error when selecting minified automatic drills
I have not investigated this one yet, but it looks similar to bug 4 for a different building.
Last edited by Insane Chainsaw; Oct 11 @ 4:22pm
< >
Showing 1-7 of 7 comments
batou73 Nov 8 @ 8:16pm 
Hey Insane Chainsaw.
I have a problem with bug 1.

I found StoneCutter.cs
found pickUpCells
and replaced
GenAdjFast.AdjacentCells8Way(parent.Position, parent.Rotation, parent.RotatedSize);
with
new List<IntVec3>();
GenAdjFast.AdjacentCells8Way(parent.Position, parent.Rotation, parent.RotatedSize).CopyToList(pickUpCells);

it didnt work for me even when clicking on ore dresser nothing happens.

im experimenting with it but im out of ideas.
Would you help?
1-Did you recreate AncientMining.dll after making the documented changes? You are supposed to use Visual Studio for this. Sorry for the dumb question, but I don't know your level of experience.

2-If you did recompile, are you sure the game uses the dll you generated? The default settings output the dll in [mod folder]\Assemblies while the game might prefer loading the one in[mod folder]\1.6\Assemblies .
batou73 Nov 9 @ 7:09am 
1.- no i didn't that's a good question.
i haven't seen any guides online about extracting .dll files. thought that editing txt will do fine some games work like that.
on that note. d̶o̶ t̶x̶t̶ f̶i̶l̶e̶s̶ d̶o̶ a̶n̶y̶t̶h̶i̶n̶g̶ f̶o̶r̶ t̶h̶a̶t̶ m̶o̶d̶?̶ d̶o̶ i̶ h̶a̶v̶e̶ t̶o̶ e̶d̶i̶t̶ t̶h̶e̶m̶ a̶s̶ w̶e̶l̶l̶?̶
2.- so what… replace both just to be sure?

Im checking out Visual studio right now. I have some experience with different extractor this seems more comlicated but found guides as well.
I will give an update later. Thx for help <3

Edit: ok I'm really lost now.
i don't know what you ment by "recreate AncientMining.dll"
simply deleted it and pasted new one from backup. (could you explain what should i do or send me a link to an explenation. sorry i tried to find one on my own but failed)
suprisingly it works flawlessly on new save but...
on an old save where bug first occured i get this message every tick:

Exception ticking MinifiedThing2651144 (at (104, 0, 111)): System.NullReferenceException: Object reference not set to an instance of an object
[Ref 38E6770E] Duplicate stacktrace, see ref for original
UnityEngine.StackTraceUtility:ExtractStackTrace ()
(wrapper dynamic-method) MonoMod.Utils.DynamicMethodDefinition:Verse.Log.Error_Patch1 (string)
Verse.TickList:Tick ()
(wrapper dynamic-method) MonoMod.Utils.DynamicMethodDefinition:Verse.TickManager.DoSingleTick_Patch1 (Verse.TickManager)
Verse.TickManager:TickManagerUpdate ()
(wrapper dynamic-method) MonoMod.Utils.DynamicMethodDefinition:Verse.Game.UpdatePlay_Patch1 (Verse.Game)
(wrapper dynamic-method) MonoMod.Utils.DynamicMethodDefinition:Verse.Root_Play.Update_Patch1 (Verse.Root_Play)

Is there a way to soft reset a save so i don't loose progress? it should fix the issue yes?
Last edited by batou73; Nov 9 @ 10:12am
You know how every AAA game is made from a bunch of text called "source code"?
To put it simply, Visual Studio (VS) is what turns source code into the exe or dll(s) of a game.
VS is absolutely NOT an extractor, it's called an IDE - Integrated Development Environment, a collection of tools to make applications: text editor, compiler, linker, debugger, basic dependencies, and much more, all that for several programming languages.

When Rimworld mods want to do something complex that can't be handled by xml configuration files alone, then need to create a plugin .dll that the game will load, this is what you see in the Assemblies directories.
Rimworld does not read what you put in the Source directory, it expects you to turn this Source Code into a .dll, and loads this dll.

  • First, you need to install visual studio, then install the ".NET desktop development" feature as instructed here: https://rimworldwiki.com/wiki/Modding_Tutorials/Setting_up_a_solution . Ignore "Option 1" and anything below, these explain how to create a solution from scratch, while you will be using an existing solution: AncientMining.sln

  • Double click [mod folder]\Source\AncientMining\AncientMining.sln , this should open VS.

  • At the top you should see a selector saying "Debug" or "Release", then "Any CPU", then "|> Start".
    Make sure to select "Release". Debug has much lower performance and is only for programmers.

  • Open the solution explorer to the left, expand AncientMining->References, and delete "0Harmony", "Assembly-CSharp", "UnityEngine", and "UnityEngine.CoreModule", then re-add them via right click on references->add reference, and browse to YOUR dlls of the same name. The last 3 are in RimWorldWin64_Data\Managed, 0Harmony.dll is normally in Mods\Harmony\1.5\Assemblies .

  • Optional: in the solution explorer, right click the references you re-added->properties set Copy Local to False.

  • I suppose your StoneCutter.cs is already modified as instructed in the OP. If not, now is the time to do it. You can open this file in VS via the solution explorer to the left.

  • Press F7 or do Build->Build solution. This will try to build a dll out of the source code.

  • You should see some info about the build progress in the output tab at the bottom, make sure it says "1 succeeded" at the end. If there are errors, go to the "Error List" tab and use a search engine before asking. Sometimes you can just select an error in the list and press F1 for decent help.

  • If there were no errors, then you should have a new AncientMining.dll in [mod folder]\Assemblies , and it's best to move it to [mod folder]\1.6\Assemblies , replacing the original dll.

It's only at this point that the fix for bug 1 is in the game (well, the next time you start the game).

The exception you posted in your edit is likely bug 4 or 5.
batou73 Nov 9 @ 1:53pm 
Wow! Big thx man!
thats exactly what i wanted :D
I was just reading about libraries and VS.
i gotta say it's 1st time editing dll myself usually if i had to i found already edited version online. gonna test it right away.
(before that i edited old games... ufo afretshock i think, it used weird libraries that neded to be extracted to txt files and then compiled again to work thought dll work similarly, thought wrong.)
Sorry gor inconvenience, it's still magic to me but i definitely learned today!
Once again many thanks! <3

on the other note: do you know when original mod wil be pached?
I assume they'll update when Rimworld 1.7 comes out, here's hoping they'll notice the thread with bug fixes...
batou73 Nov 11 @ 11:42am 
heh, real

So you have no communicaton with org. creator and found out the patch on ur own? impresive!
< >
Showing 1-7 of 7 comments
Per page: 1530 50