Status of 64-bit DFHack

July 18, 2016

Recently I spent couple days helping DFHack team with support for the new 64-bit Dwarf Fortress version in DFHack. Of course, I was primarily interested in the OS X platform. There were several things that needed to be done in this case:

Scripts to find globals

There is number of scripts in jjyg/df-misc repo that need to be run on new binaries to extract addresses of global variables and vtables, and other stuff. The author is away, and I don’t have any Ruby knowledge, so I decided to write my own scripts for Hopper. They are now available in mifki/df-hopper-scripts, couple of them even support Windows (and Linux support should be easy to do).

Update Lua to 5.3 and make sure DFHack builds for 64-bit

We needed to update Lua from 5.2 to 5.3 to support 64-bit integer numbers (in particular, memory addresses). Also I had to bunch of int32_t variables to intptr_t. Other than this, there were no major difficulties with DFHack. Lethosor fixed an issue with vararg functions that suddenly started to crash on 64-bit.

Update DF structure definitions

long type is used in the DF graphics code, so those structures needed to be updated. But that was easy. While the big problem is that in many places, when we don’t know the meaning of a field in some structure, we simply use int32_t type for it. However, some of this fields are actually pointers, and while this wasn’t a problem on 32-bit, now all the pointers changed size, and a lot of data structures became incorrect. On the bright side, now we can better understand what are pointers and what are integers in DF structures.

It took long time to find such fields in world, world_data and some other structures, but in the end I got a working 64-bit DFHack with most of the plugins (that I’ve tried) working.

Current status

Repos with 64-bit fixes (look for 64-bit branches): pronvit/dfhack, pronvit/df-structures, pronvit/scripts. The last one has an updated devel/find-offsets script to find almost all of the required global addresses.

I don’t have any more time to work on this (need to release DF Remote with support for DF 0.43.03 as soon as possible), and what needs to be done now is just further testing of all plugins to make sure all data structures are correct. I don’t know how much time this is going to take and who is working on it now.

comments powered by HyperComments