summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/tags.cc
diff options
context:
space:
mode:
authorharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2009-02-06 16:31:52 +0000
committerharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2009-02-06 16:31:52 +0000
commit78e4b50a9ca14a10410bca6661433138892346cb (patch)
treef91e2d2edf451e217eb37b34f6ca1719bb92dd39 /crawl-ref/source/tags.cc
parent96797ebeaa01788ed1a6ed8f9ba38891ac165db2 (diff)
downloadcrawl-ref-78e4b50a9ca14a10410bca6661433138892346cb.tar.gz
crawl-ref-78e4b50a9ca14a10410bca6661433138892346cb.zip
Fix [2573054]: idle time not being clamped on level save/load (e.g. SIGHUP or
when the game is saved.) git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@8931 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/tags.cc')
-rw-r--r--crawl-ref/source/tags.cc113
1 files changed, 40 insertions, 73 deletions
diff --git a/crawl-ref/source/tags.cc b/crawl-ref/source/tags.cc
index b87d6cb184..071398da15 100644
--- a/crawl-ref/source/tags.cc
+++ b/crawl-ref/source/tags.cc
@@ -655,40 +655,22 @@ void tag_write(tag_type tagID, FILE* outf)
writer th(&buf);
switch(tagID)
{
- case TAG_YOU:
- tag_construct_you(th);
- break;
- case TAG_YOU_ITEMS:
- tag_construct_you_items(th);
- break;
- case TAG_YOU_DUNGEON:
- tag_construct_you_dungeon(th);
- break;
- case TAG_LEVEL:
- tag_construct_level(th);
- break;
- case TAG_LEVEL_ITEMS:
- tag_construct_level_items(th);
- break;
- case TAG_LEVEL_MONSTERS:
- tag_construct_level_monsters(th);
- break;
- case TAG_LEVEL_TILES:
- tag_construct_level_tiles(th);
- break;
- case TAG_LEVEL_ATTITUDE:
- tag_construct_level_attitude(th);
- break;
- case TAG_GHOST:
- tag_construct_ghost(th);
- break;
- case TAG_LOST_MONSTERS:
- tag_construct_lost_monsters(th);
- tag_construct_lost_items(th);
- break;
- default:
- // I don't know how to make that!
- break;
+ case TAG_YOU: tag_construct_you(th); break;
+ case TAG_YOU_ITEMS: tag_construct_you_items(th); break;
+ case TAG_YOU_DUNGEON: tag_construct_you_dungeon(th); break;
+ case TAG_LEVEL: tag_construct_level(th); break;
+ case TAG_LEVEL_ITEMS: tag_construct_level_items(th); break;
+ case TAG_LEVEL_MONSTERS: tag_construct_level_monsters(th); break;
+ case TAG_LEVEL_TILES: tag_construct_level_tiles(th); break;
+ case TAG_LEVEL_ATTITUDE: tag_construct_level_attitude(th); break;
+ case TAG_GHOST: tag_construct_ghost(th); break;
+ case TAG_LOST_MONSTERS:
+ tag_construct_lost_monsters(th);
+ tag_construct_lost_items(th);
+ break;
+ default:
+ // I don't know how to make that!
+ break;
}
// make sure there is some data to write!
@@ -720,9 +702,11 @@ tag_type tag_read(FILE *fp, char minorVersion)
{
reader tmp(fp);
tag_id = unmarshallShort(tmp);
- if (tag_id < 0) return TAG_NO_TAG;
+ if (tag_id < 0)
+ return TAG_NO_TAG;
const long data_size = unmarshallLong(tmp);
- if (data_size < 0) return TAG_NO_TAG;
+ if (data_size < 0)
+ return TAG_NO_TAG;
// Fetch data in one go
buf.resize(data_size);
@@ -736,44 +720,26 @@ tag_type tag_read(FILE *fp, char minorVersion)
reader th(buf);
switch (tag_id)
{
- case TAG_YOU:
- tag_read_you(th, minorVersion);
- break;
- case TAG_YOU_ITEMS:
- tag_read_you_items(th, minorVersion);
- break;
- case TAG_YOU_DUNGEON:
- tag_read_you_dungeon(th);
- break;
- case TAG_LEVEL:
- tag_read_level(th, minorVersion);
- break;
- case TAG_LEVEL_ITEMS:
- tag_read_level_items(th, minorVersion);
- break;
- case TAG_LEVEL_MONSTERS:
- tag_read_level_monsters(th, minorVersion);
- break;
- case TAG_LEVEL_ATTITUDE:
- tag_read_level_attitude(th);
- break;
- case TAG_LEVEL_TILES:
- tag_read_level_tiles(th);
- break;
- case TAG_GHOST:
- tag_read_ghost(th, minorVersion);
- break;
- case TAG_LOST_MONSTERS:
- tag_read_lost_monsters(th, minorVersion);
- tag_read_lost_items(th, minorVersion);
- break;
- default:
- // I don't know how to read that!
- ASSERT(false);
- return TAG_NO_TAG;
+ case TAG_YOU: tag_read_you(th, minorVersion); break;
+ case TAG_YOU_ITEMS: tag_read_you_items(th, minorVersion); break;
+ case TAG_YOU_DUNGEON: tag_read_you_dungeon(th); break;
+ case TAG_LEVEL: tag_read_level(th, minorVersion); break;
+ case TAG_LEVEL_ITEMS: tag_read_level_items(th, minorVersion); break;
+ case TAG_LEVEL_MONSTERS: tag_read_level_monsters(th, minorVersion); break;
+ case TAG_LEVEL_ATTITUDE: tag_read_level_attitude(th); break;
+ case TAG_LEVEL_TILES: tag_read_level_tiles(th); break;
+ case TAG_GHOST: tag_read_ghost(th, minorVersion); break;
+ case TAG_LOST_MONSTERS:
+ tag_read_lost_monsters(th, minorVersion);
+ tag_read_lost_items(th, minorVersion);
+ break;
+ default:
+ // I don't know how to read that!
+ ASSERT(false);
+ return TAG_NO_TAG;
}
- return (tag_type)tag_id;
+ return static_cast<tag_type>(tag_id);
}
@@ -1009,7 +975,8 @@ static void tag_construct_you(writer &th)
if (you.real_time != -1)
{
const time_t now = time(NULL);
- you.real_time += (now - you.start_time);
+ you.real_time += std::min<time_t>(now - you.start_time,
+ IDLE_TIME_CLAMP);
// Reset start_time now that real_time is being saved out...
// this may just be a level save.