Well. I decided to experiment a bit... get crazy
Here are the problems currently plaguing DFHack:
- It can't allocate and free memory or manipulate things like strings and vectors properly.
- There is a significant performance bottleneck caused by us having to read sparse bits of information using the OS-provided debugging APIs - this means a fairly high constant cost for each call, no matter how much data is read. Writing data on linux is about two orders of magnitude slower than it should be (OS forces us to write in 4-byte chunks for no good reason).
- DFHack is ultimately unsafe because of no proper locking and synchronization with DF.
- The current memory description (memory.xml) is untyped and just lists arbitrarily grouped numerical values.
- DFHack is mostly hand-written code, while it's more of an interface.
So, what's the solution?
- I will move all of DFHack *into* DF itself - this should solve 1., because the data access will be direct (and unprotected, putting greater emphassis on testing).
- By moving into DF, the memory access cost for things also loaded into DF approaches zero. External API will be done with some cross-platform COM-like scheme. This should make creating language bindings easier too. I'm looking at CORBA.
- Memory.xml format will be redone - this time to actually describe the memory layout of objects, instead of just listing some offset values. Having the layout, a lot of DFHack can be generated instead of written. This includes tests!
- The distribution method will have to change significantly. To make things easy for users, I'll have to package DFHack along with DF. This will let me trim out the support for all the historic crud with each version. I doubt anyone will miss it.
- This all means the support for wine DF is going away. This could bite me in the a**.
- DFHack will have to use the same compiler as DF. You won't be able to build it with Mingw32 on windows anymore.
A crazy experiment.... just throwing stuff at a wall and seeing what sticks, Cave Johnson style... without the exploding lemons though. I'll have to figure things out as I go, because there's a lot of problems to solve not listed here.
I expect the new DF version to break quite a bit of stuff. I also expect it to be hilariously buggy. That should give me some time for working on core DFHack. And yes. I'm done with all the uni finals... so I actually have some time for all this. It will be fun
Expect explosions.
The source on github is only up to 0.5.14.
Any timeline on when the 0.5.15 source will be up?
dfstatus looks interesting I would like to check it out, but no source...
It's there. I just forgot to make a named version. Take current git HEAD.
A vein changer would definitely be doable; I've already been working on a basic vein viewer for the next release of dfmarmot.
As for changing layer stone: As I understand it, the type of layer stone (or soil) you get is determined by the tile's biome and geolayer_index designations. I think biome might be an index into the block's biome_indices array; if so, one could create tiles of any arbitrary layer stone by inserting new data into an unused biome_indices slot. That may be horribly wrong, though; I'm still trying to make sense of this.
Don't, you don't have to. Reading DFHack sources is better. Look at the Maps module. It's a horribly convoluted scheme, but in the end, it's just this: tile biome is index into an array of numbers stored in the block. Those in turn determine the positional offset at which the real source of biome is, relative to the current region (where region = 16x16 embark squares). This offset can be from -1 to +1 in both X and Y coordinates. Geolayer index is then the index of the geological layer. So, all you can do is change the geology of a whole biome, or change the layer and biome of a tile to one present near the current region. There is no way around this... and the ASM code looked horrible because Toady uses signed integers where he shouldn't.
Oh, and a vein changer would be trivial. I can make one today.