From 96b3fe9c02a9e4dc1ccecdac3157e33ec225d85a Mon Sep 17 00:00:00 2001 From: dshaligram Date: Fri, 6 Apr 2007 11:09:10 +0000 Subject: hiscores.cc version preserve fix for 0.2.2. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/branches/stone_soup-0.2@1234 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/hiscores.cc | 21 +++++++++------------ crawl-ref/source/hiscores.h | 3 +-- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/crawl-ref/source/hiscores.cc b/crawl-ref/source/hiscores.cc index cd28adc53e..5a8405ac6d 100644 --- a/crawl-ref/source/hiscores.cc +++ b/crawl-ref/source/hiscores.cc @@ -546,7 +546,6 @@ scorefile_entry &scorefile_entry::operator = (const scorefile_entry &se) void scorefile_entry::init_from(const scorefile_entry &se) { version = se.version; - release = se.release; points = se.points; name = se.name; uid = se.uid; @@ -676,6 +675,7 @@ static int str_to_god(const std::string &god) void scorefile_entry::init_with_fields() { + version = fields->str_field("v"); points = fields->long_field("sc"); name = fields->str_field("name"); uid = fields->int_field("uid"); @@ -719,7 +719,7 @@ void scorefile_entry::set_base_xlog_fields() const if (!fields.get()) fields.reset(new xlog_fields); - fields->add_field("v", VER_NUM); + fields->add_field("v", "%s", version.empty()? VER_NUM : version.c_str()); fields->add_field("lv", SCORE_VERSION); fields->add_field("name", "%s", name.c_str()); fields->add_field("uid", "%d", uid); @@ -856,14 +856,14 @@ bool scorefile_entry::parse_obsolete_scoreline(const std::string &line) { const char *inbuf = line.c_str(); - version = hs_nextint(inbuf); - release = hs_nextint(inbuf); + const int ver = hs_nextint(inbuf); + const int rel = hs_nextint(inbuf); // this would be a good point to check for version numbers and branch // appropriately // acceptable versions are 0 (converted from old hiscore format) and 4 - if (version != 4 || release < 2) + if (ver != 4 || rel < 2) return (false); points = hs_nextlong(inbuf); @@ -888,7 +888,7 @@ bool scorefile_entry::parse_obsolete_scoreline(const std::string &line) // To try and keep the scorefile backwards compatible, // we'll branch on version > 4.0 to read the auxkilldata // text field. - if (version == 4 && release >= 1) + if (ver == 4 && rel >= 1) auxkilldata = hs_nextstring( inbuf, ITEMNAME_SIZE ); else auxkilldata[0] = 0; @@ -1000,8 +1000,7 @@ void scorefile_entry::init_death_cause(int dam, int dsrc, void scorefile_entry::reset() { // simple init - version = 0; - release = 0; + version.clear(); points = -1; name[0] = 0; uid = 0; @@ -1046,10 +1045,8 @@ void scorefile_entry::init() // 4.1 - added real_time and num_turn fields // 4.2 - stats and god info - version = 4; - release = 2; - - name = you.your_name; + version = VER_NUM; + name = you.your_name; #ifdef MULTIUSER uid = (int) getuid(); diff --git a/crawl-ref/source/hiscores.h b/crawl-ref/source/hiscores.h index a40f9266a6..806265e928 100644 --- a/crawl-ref/source/hiscores.h +++ b/crawl-ref/source/hiscores.h @@ -84,8 +84,7 @@ private: struct scorefile_entry { public: - char version; - char release; + std::string version; long points; std::string name; long uid; // for multiuser systems -- cgit v1.2.3-54-g00ecf