diff options
author | dshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573> | 2006-09-22 18:41:11 +0000 |
---|---|---|
committer | dshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573> | 2006-09-22 18:41:11 +0000 |
commit | de72d35c7452cc8d1cd51ca799b3aeb579a19238 (patch) | |
tree | 48fc2881d3d90980c7a641bd83e49d172be4722d | |
parent | 25f8a6e30654ad07fb3cbad80c98d5358c87c8b2 (diff) | |
download | crawl-ref-de72d35c7452cc8d1cd51ca799b3aeb579a19238.tar.gz crawl-ref-de72d35c7452cc8d1cd51ca799b3aeb579a19238.zip |
Incremented save minor versions for TAGTYPE_PLAYER and TAGTYPE_LEVEL to support
inscriptions and preserve backward compatibility.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/branches/stone_soup@75 c06c8d41-db1a-0410-9941-cceddc491573
-rw-r--r-- | crawl-ref/source/files.cc | 43 | ||||
-rw-r--r-- | crawl-ref/source/tags.cc | 29 |
2 files changed, 41 insertions, 31 deletions
diff --git a/crawl-ref/source/files.cc b/crawl-ref/source/files.cc index 353f731c5f..5ee9382f76 100644 --- a/crawl-ref/source/files.cc +++ b/crawl-ref/source/files.cc @@ -960,18 +960,18 @@ void save_level(int level_saved, bool was_a_labyrinth, char where_were_you) // nail all items to the ground fix_item_coordinates(); - // 4.0 initial genesis of saved format - // 4.1 added attitude tag - // 4.2 replaced old 'enchantment1' and with 'flags' (bitfield) - // 4.3 changes to make the item structure more sane - // 4.4 changes to the ghost save section - // 4.5 spell and ability letter arrays - // 4.6 inventory slots of items - // 4.7 origin tracking for items - // 4.8 widened env.map to 2 bytes - - // [dshaligram] Winding major version back all the way to 0. - write_tagged_file( saveFile, SAVE_MAJOR_VERSION, 8, TAGTYPE_LEVEL ); + // 0.0 initial genesis of saved format + // 0.1 added attitude tag + // 0.2 replaced old 'enchantment1' and with 'flags' (bitfield) + // 0.3 changes to make the item structure more sane + // 0.4 changes to the ghost save section + // 0.5 spell and ability letter arrays + // 0.6 inventory slots of items + // 0.7 origin tracking for items + // 0.8 widened env.map to 2 bytes + // 0.9 inscriptions (hp) + + write_tagged_file( saveFile, SAVE_MAJOR_VERSION, 9, TAGTYPE_LEVEL ); fclose(saveFile); @@ -1122,14 +1122,15 @@ void save_game(bool leave_game) end(-1); } - // 4.0 initial genesis of saved format - // 4.1 changes to make the item structure more sane - // 4.2 spell and ability tables - // 4.3 added you.magic_contamination (05/03/05) - // 4.4 added item origins - // 4.5 added num_gifts + // 0.0 initial genesis of saved format + // 0.1 changes to make the item structure more sane + // 0.2 spell and ability tables + // 0.3 added you.magic_contamination (05/03/05) + // 0.4 added item origins + // 0.5 added num_gifts + // 0.6 inscriptions (hp) - write_tagged_file( saveFile, SAVE_MAJOR_VERSION, 5, TAGTYPE_PLAYER ); + write_tagged_file( saveFile, SAVE_MAJOR_VERSION, 6, TAGTYPE_PLAYER ); fclose(saveFile); @@ -1632,8 +1633,8 @@ void save_ghost( bool force ) return; } - // 4.0-4.3 old tagged savefile (values as unsigned char) - // 4.4 new tagged savefile (values as signed short) + // 0.0-0.3 old tagged savefile (values as unsigned char) + // 0.4 new tagged savefile (values as signed short) write_tagged_file( gfile, SAVE_MAJOR_VERSION, 4, TAGTYPE_GHOST ); fclose(gfile); diff --git a/crawl-ref/source/tags.cc b/crawl-ref/source/tags.cc index 43eb0a83a5..060d10b7c0 100644 --- a/crawl-ref/source/tags.cc +++ b/crawl-ref/source/tags.cc @@ -1278,7 +1278,7 @@ static void tag_read_you_items(struct tagHeader &th, char minorVersion) for (i = 0; i < count_c; ++i) { you.inv[i].orig_monnum = you.inv[i].orig_place = 0; - you.inv[i].inscription = std::string(); + you.inv[i].inscription.clear(); if (minorVersion < 1) { you.inv[i].base_type = (unsigned char) unmarshallByte(th); @@ -1307,10 +1307,14 @@ static void tag_read_you_items(struct tagHeader &th, char minorVersion) { you.inv[i].orig_place = unmarshallShort(th); you.inv[i].orig_monnum = unmarshallShort(th); - /*** HP CHANGE ***/ - char insstring[80]; - unmarshallString(th, insstring, 80); - you.inv[i].inscription = std::string(insstring); + + if (minorVersion >= 6) + { + /*** HP CHANGE ***/ + char insstring[80]; + unmarshallString(th, insstring, 80); + you.inv[i].inscription = std::string(insstring); + } } } @@ -1697,20 +1701,25 @@ static void tag_read_level_items(struct tagHeader &th, char minorVersion) mitm[i].slot = unmarshallByte(th); } + mitm[i].inscription.clear(); + if (minorVersion >= 7) { mitm[i].orig_place = unmarshallShort(th); mitm[i].orig_monnum = unmarshallShort(th); - /*** HP CHANGE ***/ - char insstring[80]; - unmarshallString(th, insstring, 80); - mitm[i].inscription = std::string(insstring); + + if (minorVersion >= 9) + { + /*** HP CHANGE ***/ + char insstring[80]; + unmarshallString(th, insstring, 80); + mitm[i].inscription = std::string(insstring); + } } else { mitm[i].orig_place = 0; mitm[i].orig_monnum = 0; - mitm[i].inscription = std::string(); } } } |