From dcf7801daff4c7c76e461c5ad08749394e64466b Mon Sep 17 00:00:00 2001 From: zelgadis Date: Sun, 16 Sep 2007 03:39:41 +0000 Subject: Add dump sections for branch/area details for turns and experience/kills, with the section names being turns_by_place and kills_by_place. Also includes a "visits" dump section (included in the "misc" section") a brief description of the number of branches/levels/areas/etc you visited. Breaks savefile compatibility. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@2102 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/tags.cc | 95 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 92 insertions(+), 3 deletions(-) (limited to 'crawl-ref/source/tags.cc') diff --git a/crawl-ref/source/tags.cc b/crawl-ref/source/tags.cc index 057682d004..b2a5a78100 100644 --- a/crawl-ref/source/tags.cc +++ b/crawl-ref/source/tags.cc @@ -13,7 +13,7 @@ /* ------------------------- how tags work ---------------------------------- -1. Tag types are enumerated in enum.h, from TAG_VERSION (more a placeholder +1. Tag types are enumerated in tags.h, from TAG_VERSION (more a placeholder than anything else, it is not actually saved as a tag) to TAG_XXX. NUM_TAGS is equal to the actual number of defined tags. @@ -978,6 +978,35 @@ static void tag_construct_you_items(struct tagHeader &th) marshallBoolean(th, does_unrandart_exist(j)); } +static void marshallPlaceInfo(struct tagHeader &th, PlaceInfo place_info) +{ + marshallLong(th, place_info.level_type); + marshallLong(th, place_info.branch); + + marshallLong(th, place_info.num_visits); + marshallLong(th, place_info.levels_seen); + + marshallLong(th, place_info.mon_kill_exp); + marshallLong(th, place_info.mon_kill_exp_avail); + + for (int i = 0; i < KC_NCATEGORIES; i++) + marshallLong(th, place_info.mon_kill_num[i]); + + marshallLong(th, place_info.turns_total); + marshallLong(th, place_info.turns_explore); + marshallLong(th, place_info.turns_travel); + marshallLong(th, place_info.turns_interlevel); + marshallLong(th, place_info.turns_resting); + marshallLong(th, place_info.turns_other); + + marshallFloat(th, place_info.elapsed_total); + marshallFloat(th, place_info.elapsed_explore); + marshallFloat(th, place_info.elapsed_travel); + marshallFloat(th, place_info.elapsed_interlevel); + marshallFloat(th, place_info.elapsed_resting); + marshallFloat(th, place_info.elapsed_other); +} + static void tag_construct_you_dungeon(struct tagHeader &th) { int i,j; @@ -1006,6 +1035,14 @@ static void tag_construct_you_dungeon(struct tagHeader &th) marshallMap(th, portals_present, marshall_level_pos, marshall_as_long); + marshallPlaceInfo(th, you.global_info); + std::vector list = you.get_all_place_info(); + // How many different places we have info on? + marshallShort(th, list.size()); + + for (unsigned int k = 0; k < list.size(); k++) + marshallPlaceInfo(th, list[k]); + marshall_iterator(th, you.uniq_map_tags.begin(), you.uniq_map_tags.end(), marshallString); marshall_iterator(th, you.uniq_map_names.begin(), you.uniq_map_names.end(), @@ -1315,12 +1352,47 @@ static void tag_read_you_items(struct tagHeader &th, char minorVersion) set_unrandart_exist(j, 0); } +static PlaceInfo unmarshallPlaceInfo(struct tagHeader &th) +{ + PlaceInfo place_info; + + place_info.level_type = (int) unmarshallLong(th); + place_info.branch = (int) unmarshallLong(th); + + place_info.num_visits = (unsigned long) unmarshallLong(th); + place_info.levels_seen = (unsigned long) unmarshallLong(th); + + place_info.mon_kill_exp = (unsigned long) unmarshallLong(th); + place_info.mon_kill_exp_avail = (unsigned long) unmarshallLong(th); + + for (int i = 0; i < KC_NCATEGORIES; i++) + place_info.mon_kill_num[i] = (unsigned long) unmarshallLong(th); + + place_info.turns_total = unmarshallLong(th); + place_info.turns_explore = unmarshallLong(th); + place_info.turns_travel = unmarshallLong(th); + place_info.turns_interlevel = unmarshallLong(th); + place_info.turns_resting = unmarshallLong(th); + place_info.turns_other = unmarshallLong(th); + + place_info.elapsed_total = (double) unmarshallFloat(th); + place_info.elapsed_explore = (double) unmarshallFloat(th); + place_info.elapsed_travel = (double) unmarshallFloat(th); + place_info.elapsed_interlevel = (double) unmarshallFloat(th); + place_info.elapsed_resting = (double) unmarshallFloat(th); + place_info.elapsed_other = (double) unmarshallFloat(th); + + return place_info; +} + static void tag_read_you_dungeon(struct tagHeader &th) { - int i,j; - int count_c; + int i,j; + int count_c; short count_s; + unsigned short count_p; + // how many unique creatures? count_c = unmarshallShort(th); you.unique_creatures.init(false); @@ -1354,6 +1426,23 @@ static void tag_read_you_dungeon(struct tagHeader &th) unmarshallMap(th, portals_present, unmarshall_level_pos, unmarshall_long_as); + PlaceInfo place_info = unmarshallPlaceInfo(th); + ASSERT(place_info.is_global()); + you.set_place_info(place_info); + + std::vector list = you.get_all_place_info(); + count_p = (unsigned short) unmarshallShort(th); + // Use "<=" so that adding more branches or non-dungeon places + // won't break save-file compatibility. + ASSERT(count_p <= list.size()); + + for (i = 0; i < count_p; i++) + { + place_info = unmarshallPlaceInfo(th); + ASSERT(!place_info.is_global()); + you.set_place_info(place_info); + } + typedef std::set string_set; typedef std::pair ssipair; unmarshall_container(th, you.uniq_map_tags, -- cgit v1.2.3-54-g00ecf