v50 Steam/Premium information for editors
  • v50 information can now be added to pages in the main namespace. v0.47 information can still be found in the DF2014 namespace. See here for more details on the new versioning policy.
  • Use this page to report any issues related to the migration.
This notice may be cached—the current version can be found here.

User talk:Rick/Save research

From Dwarf Fortress Wiki
< User talk:Rick
Revision as of 22:35, 31 January 2008 by Shadetree (talk | contribs) (New page: Using this info and some other resources I've scrounged up a bit of python code that will extract the chunks. I hope this is useful to someone. they seem to be one file broken up into 20k...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Using this info and some other resources I've scrounged up a bit of python code that will extract the chunks. I hope this is useful to someone. they seem to be one file broken up into 20k chunks. Useable on other dat files.

Usage: python script.py world.dat

a copy of World.dat must be in same directory as script.

import zlib, struct, sys

def main(args):
    fp = file(args[0], 'rb') 

    i = 1

    while True:
        data = fp.read(4)
        if len(data) != 4:
            break

        length = struct.unpack('<L', data)[0]
        file('Chunk_%i.dat' % i, 'wb').write(zlib.decompress(fp.read(length)))
        i += 1

if __name__=='__main__':
    sys.exit(main(sys.argv[1:]))