Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: How were DFHack's structures created?  (Read 831 times)

Artemiuz28

  • Escaped Lunatic
    • View Profile
How were DFHack's structures created?
« on: July 30, 2018, 11:03:21 am »

What I'm talking about is https://github.com/DFHack/df-structures
It looks like an overwhelming amount of DF's variables listed, but I got absolutely no idea how DFHack's creator(s) even made this. Can somebody give me insight on this?
Logged

Starver

  • Bay Watcher
    • View Profile
Re: How were DFHack's structures created?
« Reply #1 on: July 30, 2018, 11:58:50 am »

At its most basic level, I imagine it started with examining changes detected and cross-comparing them with what the user knows has changed in the game, and building up a set of reasonable assumptions that can be then tested directly by poking instead of peeking, etc.

But we're well beyond that, now. Whole 'architectural features' have been mapped (and, where necessary, depacked from their non-trivial method of memorised storage), so that even when gross changes to the underlying layout changes upon a new version's release the fingerprints of known 'magic numbers' in the data layout can be quickly narrowed down in its reshuffled/enhanced new appearance and the a head-start is already gained upon demystifying the new bits and bobs.

It'd be a big task to start again from scratch, but countless person-hours (and machine-hours!) of work have gone into this.

None of them mine, sad to say, so I'm just wildly speculating. But I've previously done things like work with a debugger to extract the secrets of the original XCOM (UFO:EU) save-files, in my day (easy! No obfuscation at all, IIRC!) and also spent time trying to reverse-engineer particular implementations of variable-width encoding of values in obscure data files (intended to save file-space) and get past the likes of self-XORing-stream-encryptions (because someone thought they'd reinvent Enigma).


Or decompile (or actually run and step through, watching carefully) the .exe and observe what it does, if you really need to. Never underestimate the tenacity of an individual (or a group) with a purpose in mind..!
Logged

Fleeting Frames

  • Bay Watcher
  • Spooky cart at distance
    • View Profile
Re: How were DFHack's structures created?
« Reply #2 on: July 30, 2018, 12:42:46 pm »

I don't know, but if I was curious I'd look at what the initial commit looked like.

lethosor

  • Bay Watcher
    • View Profile
Re: How were DFHack's structures created?
« Reply #3 on: July 30, 2018, 12:51:20 pm »

http://www.bay12forums.com/smf/index.php?topic=139553.msg7142326#msg7142326 is a good explanation, as well as some posts around there (a bit on the page before too).
Logged
DFHack - Dwarf Manipulator (Lua) - DF Wiki talk

There was a typo in the siegers' campfire code. When the fires went out, so did the game.

Artemiuz28

  • Escaped Lunatic
    • View Profile
Re: How were DFHack's structures created?
« Reply #4 on: July 31, 2018, 10:29:41 am »

Thanks, this makes things clear.
Logged