diff options
author | pauldubois <pauldubois@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-04-20 21:58:18 +0000 |
---|---|---|
committer | pauldubois <pauldubois@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-04-20 21:58:18 +0000 |
commit | 9cc4ae67d7aba85a9eee26bb6e390ecd2e30da77 (patch) | |
tree | b615526b7a5a739df6cbee1331c7f493baaded33 /crawl-ref/source/python | |
parent | be9f773b92d011e6cb8a1bdfa72ae323807b8468 (diff) | |
download | crawl-ref-9cc4ae67d7aba85a9eee26bb6e390ecd2e30da77.tar.gz crawl-ref-9cc4ae67d7aba85a9eee26bb6e390ecd2e30da77.zip |
A little bit of savegame code cleanup; and a small format change to make
life easier (or rather, possible) for dump_savegame. Should not break
saves (let me know if they do).
- Fixed dump_savegame bug reading TAG_LEVEL. Handle lua map_markers
(by skipping over them) -- requires format change and minor version bump.
- Consolidated YOU_MINOR_VERSION, LEVEL_MINOR_VERSION, GHOST_MINOR_VERSION
into a single TAG_MINOR_VERSION, because otherwise versions can't be passed
into data structures being deserialized (because they may be contained in
both you and ghost, for example).
- Clean out old code that pretends to restore other major versions,
and some duplicate code that pretends level loading and general
tagged file loading are different. (Left ghosts alone because they
really do do something different, slightly)
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@4420 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/python')
-rw-r--r-- | crawl-ref/source/python/crawl/tags.py | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/crawl-ref/source/python/crawl/tags.py b/crawl-ref/source/python/crawl/tags.py index 4ba9c39c28..7548603d32 100644 --- a/crawl-ref/source/python/crawl/tags.py +++ b/crawl-ref/source/python/crawl/tags.py @@ -12,6 +12,9 @@ import binfile # Some constants and things # ---------------------------------------------------------------------- +TAG_MAJOR_VERSION = 5 +TAG_MINOR_VERSION = 4 + NUM_MONSTER_SPELL_SLOTS = 6 NUM_MONSTER_SLOTS = 10 MONS_PLAYER_GHOST = 400 @@ -212,7 +215,11 @@ class Quiver(object): def Coord(f): return f.stream('HH') class MapMarker(object): - def __init__(self, f): + def __init__(self, f, minor): + if minor >= 4: + expected_size = f.stream1('I') + + num_read = -f.file.tell() self.mark_type = mark_type = f.stream1('H') if mark_type == 0: # map_feature_marker self.read_base(f) @@ -233,6 +240,11 @@ class MapMarker(object): else: assert "Unknown map marker type %d" % mark_type + num_read += f.file.tell() + + if minor >= 4: + assert num_read == expected_size + def read_base(self, f): self.coord = Coord(f) @@ -246,6 +258,10 @@ class TaggedFile(object): f.byteorder = '>' self.f = f self.major, self.minor = f.stream('bb') + print ' version %d.%d' % (self.major, self.minor) + if (self.major != TAG_MAJOR_VERSION or + self.minor > TAG_MINOR_VERSION): + print " WARNING: Cannot handle this version!" self.tags = dict( self._gen_tags() ) def _gen_tags(self): @@ -258,9 +274,9 @@ class TaggedFile(object): tag_name = TAGS_NAMES[tag_id] try: constructor = TAG_TO_CLASS[tag_name] except KeyError: - print " Found %s (currently unsupported)" % tag_name + print " Skipping %s" % tag_name else: - print " Found %s (parsing)" % tag_name + print " Parsing %s" % tag_name sub_reader = binfile.reader(StringIO.StringIO(data)) sub_reader.byteorder = '>' data = constructor(sub_reader, self.minor) @@ -414,15 +430,18 @@ class TagLEVEL(TagBase): self.grid = [ f.stream('BHHHHH') for i in xrange(self.gx) for j in xrange(self.gy) ] - expected = self.gx * self.gy self.grid_colours = list(gen_run_length_decode(f, 'B', expected)) + self.cloud_no = f.stream1('H') self.clouds = stream_array(f, 'H', 'BBBHBH', limit=1000) self.shops = stream_array(f, 'B', 'BBBBBBBB', limit=15) self.sanctuary = Coord(f) self.sanctuary_time = f.stream1('B') - self.markers = [ MapMarker(f) for x in xrange(f.stream1('H')) ] + if minor >= 4: + cooky = f.stream1('I') + assert cooky == 0x17742C32 + self.markers = [ MapMarker(f, minor) for x in xrange(f.stream1('H')) ] assert_end(f.file) |