Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 2 [3] 4

Author Topic: Save Format  (Read 6344 times)

flap

  • Bay Watcher
    • View Profile
Re: Save Format
« Reply #30 on: April 02, 2007, 02:24:00 am »

quote:
Originally posted by Fieari:
<STRONG>Could that have something to do with the adamantine endgame?</STRONG>

Don't know. But anyway, my target is not to alter gameplay (such as adamantine engame), but improve a bit interface (at least to what I think couold be usefull). That game is still underdevelopment, so that wouldn't be fair to cheat too much yet...

Logged

Buffered

  • Escaped Lunatic
    • View Profile
Re: Save Format
« Reply #31 on: April 03, 2007, 05:14:00 pm »

I've found the material select cursor index and the item array pointer, when building aqueducts, bridges and such.

The array pointer is at 0x00E9E56C and the cursor position is at 0x00E9E5CC.

With this, one should be able to move the cursor directly to blocks or logs without having to painfully page through thousands of bars or tens of thousands of stones.

Logged

Rick

  • Bay Watcher
  • Engineer
    • View Profile
Re: Save Format
« Reply #32 on: April 04, 2007, 10:12:00 pm »

I found a list for items.

0x00ACB47C - pointer of the beginning of the list
0x00ACB480 - pointer of the end of the list

(this is like the dwarf list others found)

The starting pointer will be NULL if a game has yet to be started. When starting a new game, it is initialized at the prepare screen (where it asks you if you want to just play or carefully prepare).

Each item has basic structure, as far as I know, they are roughly 160 bytes, may be smaller or bigger, I have not looked into this that much.

code:
struct Item
{
   unsigned long vtable;
   unsigned long x;
   unsigned long y;
   unsigned long unk1; // may be Z.
   unsigned long maybeflags;
   unsigned long unk2;
   unsigned long id;
   unsigned char unk3[20];
   unsigned long t1start;
   unsigned long t1end;
   unsigned long t1unk;
   unsigned long count;
   unsigned char unk4[8];
   unsigned long temperature;
   unsigned char unk6[84];
};

vtable is the virtual table of the class (these pointers in the list are to C++ objects, a vtable points to a list of functions in the class).

I have identified many vtables already.

code:
#define VTABLE_ITEM_SEED      0x0075B5C8
#define VTABLE_ITEM_MEAT      0x00757CF4
#define VTABLE_ITEM_FISH      0x00757F84
#define VTABLE_ITEM_PLANT      0x00753E18
#define VTABLE_ITEM_DRINK      0x0075EED0
#define VTABLE_ITEM_MILK      0x0075E9B0
#define VTABLE_ITEM_CHEESE      0x007605E0

#define VTABLE_ITEM_WOOD      0x0075E720

#define VTABLE_ITEM_WEAPON      0x00758C10
#define VTABLE_ITEM_AMMO      0x00758EA0

#define VTABLE_ITEM_HAT         0x00759E00
#define VTABLE_ITEM_SHIRT      0x00759130
#define VTABLE_ITEM_PANTS      0x007598E0
#define VTABLE_ITEM_SHOES      0x007593C0
#define VTABLE_ITEM_GLOVES      0x00759B70
#define VTABLE_ITEM_SHIELD      0x00759650

#define VTABLE_ITEM_CLOTH      0x00760870
#define VTABLE_ITEM_THREAD      0x00756D7C
#define VTABLE_ITEM_LEATHER      0x0075FBA0

#define VTABLE_ITEM_BAG         0x00758214
#define VTABLE_ITEM_BARREL      0x0075A090

#define VTABLE_ITEM_CROWN      0x00763920
#define VTABLE_ITEM_SCEPTER      0x00763690
#define VTABLE_ITEM_RING      0x00763BB0
#define VTABLE_ITEM_EARRINGS   0x00763E40
#define VTABLE_ITEM_BRACELET   0x007640D0
#define VTABLE_ITEM_AMULET      0x00763400
#define VTABLE_ITEM_IDOL      0x00763170

#define VTABLE_ITEM_CAGE      0x00761A60



Item x/y that are 0,0 tend to be items that are inside another item, like a bag, I have not found how to identify what item they are inside yet, I suspect the t1start/t1end list refers to other items.

In addition, I have found memory locations for the X/Y of the pointer when using 'k' mode, these addresses may work for other modes too.

0x00789C1C - X
0x00789C20 - Y

X will be 0xFFFFFFFF if not using the pointer.

[ April 04, 2007: Message edited by: Rick ]

Logged

flap

  • Bay Watcher
    • View Profile
Re: Save Format
« Reply #33 on: April 05, 2007, 12:37:00 am »

Here is my "PauseDF" to pause Dwarf Fortress every few days.

Even more than my last application all test have not been executed, and in some case it might not work perfectly well. However it did most of the time the task I wanted : pause DF every 3 month so I could design, let the little guyes work and myself do something, and then come back.

I might add some more features. Mainly check how long DF has been waiting (whether pauseDF did it or whether it is the game which did it). Then it could play a sound or launch an other application (for those who wanted ot use Autohotkey to take screen shots at regular times, or do some autosave)
http://www.flap.fr/grenier/pauseDF_V01.zip

As usual I have included my source in it.

Logged

flap

  • Bay Watcher
    • View Profile
Re: Save Format
« Reply #34 on: April 05, 2007, 01:19:00 am »

Maybe we should set up a wiki page with these informations.

And eventually set up a kind of a code of conduct. Basically explaining that we don't want to cheat or spoil Toady's work, but mainly use these bits of information to temporarly improve the interface and solve some annoying bugs, while he is busy on other works...

Logged

flap

  • Bay Watcher
    • View Profile
Re: Save Format
« Reply #35 on: April 12, 2007, 05:11:00 am »

Logged

Mechanoid

  • Bay Watcher
  • [INTELLIGENT]
    • View Profile
Re: Save Format
« Reply #36 on: April 12, 2007, 05:43:00 am »

When you just can't wait for the official game-altering update you've been dreaming of...
Hack it in.  :D
Logged
Quote from: Max White
"Have all the steel you want!", says Toady, "It won't save your ass this time!"

Jifodus

  • Bay Watcher
  • Resident Lurker
    • View Profile
    • Dwarf Fortress Projects
Re: Save Format
« Reply #37 on: April 12, 2007, 12:34:00 pm »

That unidentified 4 byte value at the beginning of the dwarf structure is probably the vtable. So I think it should be instead considered an abstract unit type.

Also if you look at the MSVC++ header files:

code:
template<typename>
class std::string {
 T *buffer; // pointer to string
 size_t length; // current length of string
 size_t maxLength; // maximum length of string (buffer capacity)
}
template<typename>
class std::vector {
 T *start; // the start of the buffer
 T *last; // the last element in the buffer
 T *buffer; // end of the buffer pointer
}

Logged

Erasmus Darwin

  • Bay Watcher
    • View Profile
Re: Save Format
« Reply #38 on: April 12, 2007, 01:56:00 pm »

quote:
Originally posted by Jifodus:
<STRONG>That unidentified 4 byte value at the beginning of the dwarf structure is probably the vtable. So I think it should be instead considered an abstract unit type.</STRONG>

I seem to recall someone trying to find a vtable for creatures, and they came up empty handed.

 

quote:
<STRONG>
Also if you look at the MSVC++ header files:
</STRONG>

Whoa.  That makes a lot of sense.  I had figured that the strings were probably a class with a pointer followed by a length (hence their nice, consistent pairing every time we came across them in memory), but I hadn't even thought about the possibility of a third value.

It makes even more sense looking at my notes for dissecting the creature structure.  After every string's length was a value of 0x0000001F.  I didn't even notice it before.


Also, version 1.1 is up for teleport.  Same url ( http://angband.org/~erasmus/df/teleport.zip ), and the Wiki description is updated.  I made the dwarf checking a little smarter, and I added a few command-line options.  -a teleports all creatures under the cursor, regardless of race.  -t teleports dwarves (or all creatures with -a) regardless of whether or not you're targetting them.  You can also specify X and Y coordinates for the teleport destination.

[ April 12, 2007: Message edited by: Erasmus Darwin ]

[ April 12, 2007: Message edited by: Erasmus Darwin ]

Logged

4bh0r53n

  • Bay Watcher
    • View Profile
    • http://www.phpbber.com/phpbb/index.php?c=1&mforum=abhorsengames
Re: Save Format
« Reply #39 on: April 12, 2007, 02:11:00 pm »

quote:
You can also specify X and Y coordinates for the teleport destination.

i can see an instant noble disposal system here (just set up the co-ords for the chasm)

reminds me of that bit from monty python and the holy grail when they have to answer the questions at the bridge (converted for dwarf s):

dwarf: what is your standard occupation here

noble: I dont know (teleport) aaaaaaaaaaahhhhhhh

Logged
.B.H.O.R.S.E.N.: Abhorrent, Bloodthirsty, Hitchhiker-Obliterating Ravager from the Sunless Enchanted Necropolis

I dont explode Cats, its way to hard to coax them into the microwave...

Rick

  • Bay Watcher
  • Engineer
    • View Profile
Re: Save Format
« Reply #40 on: April 12, 2007, 04:20:00 pm »

quote:
Originally posted by Erasmus Darwin:
<STRONG>
I seem to recall someone trying to find a vtable for creatures, and they came up empty handed.
</STRONG>
That was me, and creatures don't have a vtable, they are a structure rather than a class.

 

quote:
Originally posted by Erasmus Darwin:
<STRONG>Whoa.  That makes a lot of sense.  I had figured that the strings were probably a class with a pointer followed by a length (hence their nice, consistent pairing every time we came across them in memory), but I hadn't even thought about the possibility of a third value.

It makes even more sense looking at my notes for dissecting the creature structure.  After every string's length was a value of 0x0000001F.  I didn't even notice it before.</STRONG>


Strings take up 20 bytes, I've currently got it as struct LText {unsigned long unk1, unsigned long offset, unsigned long length, unsigned long unk2}. Offset is of course the pointer to the text - I have it as unsigned long because I'm using Read/WriteProcessMemory and not interacting with the memory directly.

 

quote:
Originally posted by Erasmus Darwin:
<STRONG>Also, version 1.1 is up for teleport.  Same url ( http://angband.org/~erasmus/df/teleport.zip ), and the Wiki description is updated.  I made the dwarf checking a little smarter, and I added a few command-line options.  -a teleports all creatures under the cursor, regardless of race.  -t teleports dwarves (or all creatures with -a) regardless of whether or not you're targetting them.  You can also specify X and Y coordinates for the teleport destination.
</STRONG>
Toady was saying you should respect the tile's occupancy flags when teleporting, else things will probably get stuck.

I made significant "breakthroughs" for map related data within the last few days, I can elaborate if you talk to me on the IRC channel. I'll eventually post more information on the wiki - I've supplied some information already.

[ April 12, 2007: Message edited by: Rick ]

Logged

Erasmus Darwin

  • Bay Watcher
    • View Profile
Re: Save Format
« Reply #41 on: April 13, 2007, 10:02:00 am »

quote:
Originally posted by Rick:
<STRONG>Toady was saying you should respect the tile's occupancy flags when teleporting, else things will probably get stuck.</STRONG>

Unfortunately, I'll have to take a look at it next week, as I've got company coming into town.

Also, the default teleport destination should be fairly safe (since it's out front of the fortress), and if there's something there, the player can just specify alternate coordinates and teleport the dwarf again.

I actually ran into the sticking issue when I was seeing if it was feasible to autoteleport dwarves to where they wanted to go (based on the work destination X, Y in their structure).  I first tried it with a mining dwarf, but it turns out the X, Y was the exact location to be mined out.  So the dwarf would get stuck embedded in the wall he was supposed to mine out, and DF's code was such that he wouldn't try and mine the square while he was standing on it nor would he move off the square into an adjacent open one.

So with map data, I could presumably make a cheat that teleports dwarves to where they need to be for their work tasks, not unlike high level imps in Dungeon Keeper.  Still, there's a lot more interesting things to do than making dwarves teleport all around, especially since anyone can just hack up the speed in the raws, anyway.

Logged

Zhentar

  • Bay Watcher
    • View Profile
Re: Save Format
« Reply #42 on: April 13, 2007, 10:45:00 pm »

I've been working on a program of my own from the addresses and source posted in this thread,  but I've run into a little problem while testing. I created a couple new fortresses, and was able to read the dwarves in them just fine,  but when I pointed it at my old, established fort, no luck- it seems that unit array pointer is somewhere else than in the other ones. I haven't tried hunting down where it is yet (which should be easy, the only hard part will be learning to use a tool), but I thought I'd ask here to see if any of you have run into the problem in your trials.

[ April 13, 2007: Message edited by: Zhentar ]

Logged

Fieari

  • Bay Watcher
    • View Profile
Re: Save Format
« Reply #43 on: April 14, 2007, 09:04:00 am »

Your old, established fortress... was generated in a world from an older version, maybe?
Logged

Zhentar

  • Bay Watcher
    • View Profile
Re: Save Format
« Reply #44 on: April 14, 2007, 10:55:00 am »

Yeah, it was. I would think that after it was converted and saved in the new version once, that issue would go away, but it's my best guess.
Logged
Pages: 1 2 [3] 4