diff options
author | dshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573> | 2007-04-06 11:07:15 +0000 |
---|---|---|
committer | dshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573> | 2007-04-06 11:07:15 +0000 |
commit | 1a5bab739846c1a30df7f076d804870bb4f3c08b (patch) | |
tree | 7cd7a3e5620178077a10a5b535c60f5da4472b02 /crawl-ref/source/hiscores.cc | |
parent | 11bf30899fb8951c40b56da5d47cd6bccf782b7a (diff) | |
download | crawl-ref-1a5bab739846c1a30df7f076d804870bb4f3c08b.tar.gz crawl-ref-1a5bab739846c1a30df7f076d804870bb4f3c08b.zip |
hiscores.cc now preserves scorefile version correctly (was clobbering old
versions with the current version).
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1233 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/hiscores.cc')
-rw-r--r-- | crawl-ref/source/hiscores.cc | 21 |
1 files changed, 9 insertions, 12 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(); |