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 - sparr

#1
I am trying to transpile a new conditional code path into an existing method.

Here is the original code that I am targeting, as output by the Harmony library's CodeInstruction class:

ldarg.0
ldflda Verse.IntVec3 startDragCell


Here is my new code that replaces it:

ldobj DraggableCorners.DraggableCorners
ldfld System.Int32 initialDragAxis
ldc.i4.0
bne.un.s Label6 // do the original code instead of the new code
call IntVec3 MouseCell()
stloc.2
ldloca.s 2
br.s Label7 // skip past the original code
ldarg.0 [Label6]
ldflda Verse.IntVec3 startDragCell


The original code takes nothing off the stack and pushes the address of an IntVec3.
Both code paths through the new code, the new call/stloc/ldloca and the old code, should have that same behavior.

The code that comes after the above is as follows:

call Vector2 ToUIPosition() [Label7]
stloc.3
ldloca.s 3 (UnityEngine.Vector2)
ldfld System.Single y
stfld System.Single y


What this does in the original case is call theLoadedIntVec3.ToUIPosition(), get the .y field of the resulting Vector2, then put that into the .y field of another Vector2 that has been sitting on the stack since before any of this code ran.

I expect it to do the same thing with the new code, just the IntVec3 in question might be different.

However, what actually happens when I try to patch this IL into the method in question is that an error is thrown, "Invalid IL code in (wrapper dynamic-method)" with the reported problematic IL being "stfld 0x00000035". 0x35 is a reasonable offset into the Vector2 struct for its y property, so my hunch here is that the "Invalid IL" is about something wonky on the stack that I am failing to spot.
#2
I want to find every `return X` that could be reached during execution starting at a specific point, and modify X.
#3
Multiple people have reported that they get a Disk Write Error from Steam when they subscribe to https://steamcommunity.com/sharedfiles/filedetails/?id=1579958166 and I have no idea what might cause that.
#4
In the implementation of a transpiler I am looking at a particular CodeInstruction. From that point, I want to follow the code forward through every possible code path until I reach a return, and process instructions found along the way. I do not want to proceed to code that can't be reached during execution from my starting point. I think this means I need to handle every possible type of branching opcode, such as Br*, Ble* Blt*, Bge*, Bgt*, etc, as well as more complex things like Switch. This is a wheel I would particularly dislike to reinvent, if someone else has written a helper for it. Is there something like this?
#5
I compiled a new mod and hadn't put it on the steam workshop yet so I left the PublishedFileId.txt file empty. After some trial and error I discovered this was the cause of the game misbehaving. With that file empty in a mod in the Mods folder, the game launches to the loading screen, with the [...] visible for a few moments, then it changes to a black screen with the mouse cursor and stays that way until the game is closed. Deleting the file resolves the problem.
#6
The fact that a mod triggers the crash does not make it a mod issue. The game has a built in error log that is supposed to catch misbehavior by mods. If a mod can crash the game instead of produce an entry in the error log, that's a bug in the game. Not even an intentionally malicious mod should be able to crash the game.

If it helps, consider this bug report as if I had said "Hi, I'm a mod author, and when I add this line of code to my mod it causes the game to crash."
#7
With this mod enabled https://steamcommunity.com/sharedfiles/filedetails/?id=1558464886 when I build a crafting spot or butchering spot and select it, I immediately crash to desktop. Obviously I can just stop using the mod, and I'll report this to the mod author, but a mod shouldn't be able to crash the game without the error being caught. Crash report attached

[attachment deleted due to age]
#8
If you have one bill to make jackets at your tailor bench then only one colonist can have a jacket in progress at a time. While they sleep with an unfinished jacket sitting on/near the tailor's bench, no other colonist can start making a jacket. You can circumvent this by creating a second bill to make jackets, identical to the first, thus allowing two in-progress jackets at any given time.

I'd love to have a mod that just adds a slider/input to the bill creation/edit window, so that I can specify how many distinct works in progress should be allowed for the bill in question. It might be implemented with a lot of new logic behind the scenes, or it could just create the new bills and maybe make them invisible to the player.
#9
Releases / Re: [A17] Prepare Landing (v0.5.0)
September 14, 2017, 03:41:14 PM
I'm getting an error when trying to load the game with this mod, and then a misbehavior.

This is the copied debug log:

RimWorld 0.17.1557 rev1154
Verse.Log:Message(String)
RimWorld.VersionControl:LogVersionNumber()
Verse.Root:CheckGlobalInit()
Verse.Root:Start()
Verse.Root_Entry:Start()

ReflectionTypeLoadException getting types in assembly PrepareLanding: System.Reflection.ReflectionTypeLoadException: The classes in the module cannot be loaded.
  at (wrapper managed-to-native) System.Reflection.Assembly:GetTypes (bool)
  at System.Reflection.Assembly.GetTypes () [0x00000] in <filename unknown>:0
  at Verse.ModAssemblyHandler.AssemblyIsUsable (System.Reflection.Assembly asm) [0x00000] in <filename unknown>:0

Loader exceptions:
   => System.TypeLoadException: Could not load type 'HugsLib.ModBase' from assembly 'HugsLib, Version=0.17.0.0, Culture=neutral, PublicKeyToken=null'.
   => System.TypeLoadException: Could not load type '<>c' from assembly 'PrepareLanding, Version=0.5.0.0, Culture=neutral, PublicKeyToken=null'.

Verse.Log:Error(String)
Verse.ModAssemblyHandler:AssemblyIsUsable(Assembly)
Verse.ModAssemblyHandler:ReloadAll()
Verse.ModContentPack:ReloadContent()
Verse.LoadedModManager:LoadAllActiveMods()
Verse.PlayDataLoader:DoPlayLoad()
Verse.PlayDataLoader:LoadAllPlayData(Boolean)
Verse.Root:<Start>m__84C()
Verse.LongEventHandler:RunEventFromAnotherThread(Action)
Verse.LongEventHandler:<UpdateCurrentAsynchronousEvent>m__84A()

Could not find a type named PrepareLanding.Defs.MainButtonWorkerToggleWorld
Verse.Log:Error(String)
Verse.ParseHelper:FromString(String, Type)
Verse.DirectXmlToObject:ObjectFromXml(XmlNode, Boolean)
System.Reflection.MonoMethod:InternalInvoke(Object, Object[], Exception&)
System.Reflection.MonoMethod:Invoke(Object, BindingFlags, Binder, Object[], CultureInfo)
System.Reflection.MethodBase:Invoke(Object, Object[])
Verse.DirectXmlToObject:ObjectFromXml(XmlNode, Boolean)
System.Reflection.MonoMethod:InternalInvoke(Object, Object[], Exception&)
System.Reflection.MonoMethod:Invoke(Object, BindingFlags, Binder, Object[], CultureInfo)
System.Reflection.MethodBase:Invoke(Object, Object[])
Verse.<AllDefsFromAsset>c__Iterator226:MoveNext()
Verse.ModContentPack:LoadDefs(IEnumerable`1)
Verse.LoadedModManager:LoadAllActiveMods()
Verse.PlayDataLoader:DoPlayLoad()
Verse.PlayDataLoader:LoadAllPlayData(Boolean)
Verse.Root:<Start>m__84C()
Verse.LongEventHandler:RunEventFromAnotherThread(Action)
Verse.LongEventHandler:<UpdateCurrentAsynchronousEvent>m__84A()


And the misbehavior is as follows: At the "Create World" dialog I click "Generate", then I get "Generating planet..." for a few seconds. Then I see the "Create World" dialog again, but now the background behind the dialog is a planet. If I click Back Back Back Back which should get me to the main menu, I instead get to see the planet and nagivate as if I'm about to pick a landing site... but the buttons to actually embark are missing. Every other part of the standard world UI is there, but I can't proceed past this. I also cannot get back to the main menu from here.

I tried putting this mod at the top of my load order list, and at the bottom. I haven't tried disabling all my other mods yet, because that's very annoying.
#10
resurrecting this long dead thread in case anyone else comes here looking for a solution to this problem...

I just discovered one cause of colonists refusing to eat. If your prisoner bedroom and food storage room get connected into a single room, such as while you're replacing your doors or installing vents, then your colonists will refuse to pick up things in the prisoner room on their own, including the food in your food storage room.
#11
And since my characters don't live in flatland, they can surely SEE the slope of the mountain, so... how do I tell whether it will be thick roof or not before I mine it?
#12
I haven't been able to discern a pattern.
#13
Tynan closed the Mantis bug saying it's intended. I understand that thick roofs cause cave ins, but I am unclear on why it's always those specific three tiles.
#14
No modding.

I do understand that mining out rock roofs will result in cave-ins. It just seems odd that in this case the cave-in is always in the exact same spot. And that it obliterates items/corpses. (And that my colonists aren't smart enough to not stand in that spot)
#15
In the attached save game, if you send a colonist to mine the three isolated tiles of rock west of the base entrance then there will be a collapse and those three tiles will magically re-fill with rock. Also, the colonist doing the mining may have their corpse obliterated by the magical rock.

[attachment deleted by admin: too old]