Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: How to access map data?  (Read 1309 times)

SeveQ

  • Bay Watcher
    • View Profile
How to access map data?
« on: March 10, 2010, 08:11:54 am »

First steps are made in creating an Unreal map from Dwarf Fortress data. Well, actually from a textfile containing # for walls and . for walkable floor. And it's only one z-level by now. But I'm working on it...

I need some information on how to get the map data out of DF. Either from the process memory, (rather) from a save game file, or perhaps from an abandoned fortress, provided it's available somehow. I'd prefer the save game file because the Unreal map won't anyway be a realtime copy of an active DF map.

So is there anybody out there who can tell me how to get the map data? That would be great! I'm really looking forward to walking through my fortress :)

Logged

orbcontrolled

  • Bay Watcher
    • View Profile
Re: How to access map data?
« Reply #1 on: March 11, 2010, 06:30:36 am »

Well, if you have the programming skills for it, DFHack looks useful. I can't understand most of it, but methods like "ReadStoneMatgloss", and "ReadConstruction" certainly sound like what you're looking for.
Heck they might already have a method for outputting ASCII representations.

Alternatively, you could always "export local image" and maybe run it through an OCR program or something. :D
Logged

Haspen

  • Bay Watcher
  • Cthuwu
    • View Profile
Re: How to access map data?
« Reply #2 on: March 11, 2010, 10:16:53 am »

Or just do it non-lazy, dwarven way and make map, glancing on screenshots of all revelant z-levels of your fortress&surroundings ;)
Logged
SigFlags!
Quote from: Draignean@Spamkingdom+
Truly, we have the most uniquely talented spy network in all existence.
Quote from: mightymushroom@Spamkingdom#
Please tell me the Royal Physician didn't go to the same college as the Spymaster.

Zaranthan

  • Bay Watcher
  • Plump Helmet Smelter
    • View Profile
Re: How to access map data?
« Reply #3 on: March 11, 2010, 10:19:08 am »

I'd prefer the save game file because the Unreal map won't anyway be a realtime copy of an active DF map.

Oh, man. I just had the most awesome vision of a map that's half above ground, half tunnels, with dorfs here and there digging new tunnels, then caving them in, and digging them out again. Not sure how you could easily communicate to the players which tunnels were open at any given moment, though.
Logged
Quote from: Howard, Nerf This, by Scott D. Ferguson
Villains sleep with hookers, heroes sleep with destiny.

SeveQ

  • Bay Watcher
    • View Profile
Re: How to access map data?
« Reply #4 on: March 11, 2010, 11:24:01 am »

Okay, thanks to DFHack and its API I'm now able to dump the currently running map into a readable and thus parsable format.

Is there a reference somewhere on what every tiletype number means? :)

I'd prefer the save game file because the Unreal map won't anyway be a realtime copy of an active DF map.

Oh, man. I just had the most awesome vision of a map that's half above ground, half tunnels, with dorfs here and there digging new tunnels, then caving them in, and digging them out again. Not sure how you could easily communicate to the players which tunnels were open at any given moment, though.

That's exactly why I originally wanted to use the save game file. But the map dump will do the job as well. It is a snapshot of the map straight from the suspended dwarfort process.

The idea with the image and OCR isn't that bad but unfortunately won't work when using graphics and tilesets. Dumping the map data from the memory provides me with all the information I need for constructing a Unreal map from it. Or at least I hope so...

Not sure if you know, but someone did the same for Sauerbraten.
http://blog.plubble.com/?p=283
If nothing else, you could ask them how they did it and maybe get a few pointers.

Erm... thanks... but their site appears broken...
« Last Edit: March 11, 2010, 11:25:48 am by SeveQ »
Logged

Haspen

  • Bay Watcher
  • Cthuwu
    • View Profile
Re: How to access map data?
« Reply #5 on: March 11, 2010, 11:29:05 am »

Okay, thanks to DFHack and its API I'm now able to dump the currently running map into a readable and thus parsable format.

Is there a reference somewhere on what every tiletype number means? :)

You mean, what every ASCII character means?

http://df.magmawiki.com/index.php/Character_table

http://df.magmawiki.com/index.php/40d:Tilesets#What_tiles_are_used_for_what
Logged
SigFlags!
Quote from: Draignean@Spamkingdom+
Truly, we have the most uniquely talented spy network in all existence.
Quote from: mightymushroom@Spamkingdom#
Please tell me the Royal Physician didn't go to the same college as the Spymaster.

SeveQ

  • Bay Watcher
    • View Profile
Re: How to access map data?
« Reply #6 on: March 11, 2010, 02:34:13 pm »

Okay, thanks to DFHack and its API I'm now able to dump the currently running map into a readable and thus parsable format.

Is there a reference somewhere on what every tiletype number means? :)

You mean, what every ASCII character means?

http://df.magmawiki.com/index.php/Character_table

http://df.magmawiki.com/index.php/40d:Tilesets#What_tiles_are_used_for_what

No, I meant the values stored in the map blocks. For example 493 till 514 for floor tiles.
Logged

peterix

  • Bay Watcher
    • View Profile
    • Dethware
Re: How to access map data?
« Reply #7 on: March 14, 2010, 07:45:33 am »

There's something for that in DFTileTypes.h

Basically a big table of {name, generic shape, generic material, variant} structs, indexed by the tile type ID.