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

Topics - Micktu

#1
I've had this mod up on workshop for some time, but I think not a lot of people know about it.

The basic idea is that you don't have to dig through menus in order to build new stuff. It lets you order new constructions by copying selected buildings. It also retains temperature settings, etc. for buildings you copy. The full description can be found on the workshop page.

Some of the planned features are:

  • Replace material: rebuild something with material of your choice. Good for updating walls.
  • Target quality: rebuild until you manage to produce something of quality of your choice. Good for beds.
  • Walls into stone: order to mine out stone and replace it with a wall.
It's also pretty experimental as it makes use of some advanced dark magic instead of CCL to do its work. So if it happens to crash on you, please tell me when it did and what operating system you're on.

Links for version 0.30:
#2
Mods / New code injection method
August 05, 2016, 02:59:26 AM
I made a proof-of-concept method call patcher: https://github.com/micktu/RimWorld-BuildProductive/blob/master/Source/MethodCallPatcher.cs

What it does is it looks for every call to a specific method in other method's body and replaces it with a method of your choice.

Because there's no way I'm aware of to either to force Mono JIT compilation or to check if the method was compiled, it repeatedly scans the method over time until it finds what it needs. As it's just looping through a few hundreds bytes per tick with direct memory access it's not very taxing; funny thing is, method body does exist before the actual method is compiled, but I'm not sure about what it contains.

This enables more kinds of injections into methods; I'll provide an example of a better detour method than CCL has currently.

  • Read the first bunch of instructions from the source method and save them*;
  • Place a JMP to target method;
  • Allocate some executable memory, place preserved instructions there, followed by a JMP to the source method, to the next instruction after JMP to target;
  • Patch the call to the source method in target method body with a call to our allocated buffer.
* Implies every method is consistent with its first instructions, more research needed.

Et voila, we have a detour that can actually call the base method.
#3
It's not a big deal, but it being protected makes me jump through a few silly hoops.

Update: InspectGizmoGrid also.
#4
I have a designator that extends Designator_Build that is designated on a Building, stuff colors are not applied to its icon, and it drives me crazy already.

I debugged it to the point where I figured out that overriden GizmoOnGUI() is never called by DrawGizmoGrid(), and it behaves as Command.GizmoOnGUI() when it's a Thing and not an Architect panel. Designator_Build's override is not called, and if I override it, mine's not called too. Can you help me figure out the reason?