From 4c8cec9f3cc53e21df1a80f3b260d0ef8642debd Mon Sep 17 00:00:00 2001 From: j-p-e-g Date: Sat, 17 May 2008 23:37:07 +0000 Subject: Fix 1965819: invisible monster given away when (un)wielding or wearing stuff. Also clean up in a couple of files. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@5115 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/files.cc | 41 ++--- crawl-ref/source/mon-util.cc | 35 +++-- crawl-ref/source/monstuff.cc | 51 +++--- crawl-ref/source/player.cc | 85 +++++----- crawl-ref/source/stuff.cc | 10 +- crawl-ref/source/tags.cc | 364 +++++++++++++++++++++---------------------- crawl-ref/source/travel.cc | 29 ++-- crawl-ref/source/view.cc | 4 +- 8 files changed, 303 insertions(+), 316 deletions(-) (limited to 'crawl-ref/source') diff --git a/crawl-ref/source/files.cc b/crawl-ref/source/files.cc index 7168911101..fe2a654037 100644 --- a/crawl-ref/source/files.cc +++ b/crawl-ref/source/files.cc @@ -332,7 +332,7 @@ static bool dir_exists(const std::string &dir) { #ifdef _MSC_VER DWORD lAttr = GetFileAttributes(dir.c_str()); - return (lAttr != INVALID_FILE_ATTRIBUTES + return (lAttr != INVALID_FILE_ATTRIBUTES && (lAttr & FILE_ATTRIBUTE_DIRECTORY)); #else DIR *d = opendir(dir.c_str()); @@ -517,9 +517,8 @@ std::vector find_saved_characters() continue; std::string basename = - filename.substr( - 0, - filename.length() - strlen(PACKAGE_SUFFIX)); + filename.substr(0, + filename.length() - strlen(PACKAGE_SUFFIX)); const std::string zipname = get_savedir_path(basename); @@ -558,7 +557,7 @@ std::vector find_saved_characters() std::string get_savedir() { const std::string &dir = Options.save_dir; - return (dir.empty()? "." : dir); + return (dir.empty() ? "." : dir); } std::string get_savedir_filename(const std::string &prefix, @@ -630,7 +629,7 @@ std::string make_filename( const char *prefix, int level, branch_type where, } static void _write_version( FILE *dataFile, int majorVersion, int minorVersion, - bool extended_version ) + bool extended_version ) { // write version writer outf(dataFile); @@ -669,12 +668,8 @@ static void _write_tagged_file( FILE *outf, int fileType, // all other tags for (int i = 1; i < NUM_TAGS; i++) - { if (tags[i] == 1) - { tag_write((tag_type)i, outf); - } - } } bool travel_load_map( branch_type branch, int absdepth ) @@ -811,7 +806,6 @@ static void place_player_on_stair(branch_type old_branch, static void close_level_gates() { for ( int i = 0; i < GXM; ++i ) - { for ( int j = 0; j < GYM; ++j ) { if (you.char_direction == GDT_ASCENDING @@ -824,7 +818,6 @@ static void close_level_gates() } } } - } } static void clear_env_map() @@ -867,7 +860,6 @@ static void grab_followers() { const bool can_follow = level_type_allows_followers(you.level_type); for (int i = you.x_pos - 1; i < you.x_pos + 2; i++) - { for (int j = you.y_pos - 1; j < you.y_pos + 2; j++) { if (i == you.x_pos && j == you.y_pos) @@ -886,7 +878,6 @@ static void grab_followers() continue; } } - } if (can_follow) { @@ -969,7 +960,7 @@ bool load( dungeon_feature_type stair_taken, load_mode_type load_mode, you.level_type, false ); - if ((you.level_type == LEVEL_DUNGEON && old_level_type == LEVEL_DUNGEON) + if (you.level_type == LEVEL_DUNGEON && old_level_type == LEVEL_DUNGEON || load_mode == LOAD_START_GAME) { if (tmp_file_pairs[you.your_level][you.where_are_you] == false) @@ -1170,11 +1161,13 @@ bool load( dungeon_feature_type stair_taken, load_mode_type load_mode, PlaceInfo& curr_PlaceInfo = you.get_place_info(); PlaceInfo delta; - if (load_mode == LOAD_START_GAME || - (load_mode == LOAD_ENTER_LEVEL && - (old_branch != you.where_are_you || - old_level_type != you.level_type))) + if (load_mode == LOAD_START_GAME + || (load_mode == LOAD_ENTER_LEVEL + && (old_branch != you.where_are_you + || old_level_type != you.level_type))) + { delta.num_visits++; + } if (just_created_level) delta.levels_seen++; @@ -1189,7 +1182,7 @@ bool load( dungeon_feature_type stair_taken, load_mode_type load_mode, if (just_created_level) you.attribute[ATTR_ABYSS_ENTOURAGE] = 0; - if ( load_mode != LOAD_VISITOR ) + if (load_mode != LOAD_VISITOR) dungeon_events.fire_event(DET_ENTERED_LEVEL); return just_created_level; @@ -1560,7 +1553,6 @@ bool apply_to_all_dungeons(bool (*applicator)()) save_level(original.absdepth(), original.level_type, original.branch); for ( int i = 0; i < MAX_LEVELS; ++i ) - { for ( int j = 0; j < NUM_BRANCHES; ++j ) { const branch_type br = static_cast(j); @@ -1576,7 +1568,6 @@ bool apply_to_all_dungeons(bool (*applicator)()) if (apply_to_level(thislevel, false, applicator)) success = true; } - } _restore_level(original); @@ -1603,13 +1594,15 @@ static bool _get_and_validate_version(FILE *restoreFile, char &major, char &mino if (major != TAG_MAJOR_VERSION) { - *reason = make_stringf("Major version mismatch: %d (want %d).", major, TAG_MAJOR_VERSION); + *reason = make_stringf("Major version mismatch: %d (want %d).", + major, TAG_MAJOR_VERSION); return false; } if (minor > TAG_MINOR_VERSION) { - *reason = make_stringf("Minor version mismatch: %d (want <= %d).", minor, TAG_MINOR_VERSION); + *reason = make_stringf("Minor version mismatch: %d (want <= %d).", + minor, TAG_MINOR_VERSION); return false; } diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc index 8471cafb92..7176e71d60 100644 --- a/crawl-ref/source/mon-util.cc +++ b/crawl-ref/source/mon-util.cc @@ -1593,7 +1593,7 @@ static std::string _str_monam(const monsters& mon, description_level_type desc, return (""); // Handle non-visible case first - if ( !force_seen && !player_monster_visible(&mon) ) + if (!force_seen && !player_monster_visible(&mon)) { switch (desc) { @@ -2995,9 +2995,10 @@ void monsters::equip_weapon(item_def &item, int near, bool msg) if (msg) { - mprf("%s wields %s.", name(DESC_CAP_THE).c_str(), - item.name(DESC_NOCAP_A, false, false, true, - false, ISFLAG_CURSED).c_str()); + snprintf(info, INFO_SIZE, " wields %s.", + item.name(DESC_NOCAP_A, false, false, true, false, + ISFLAG_CURSED).c_str()); + msg = simple_monster_message(this, info); } const int brand = get_weapon_brand(item); @@ -3051,8 +3052,9 @@ void monsters::equip_armour(item_def &item, int near) { if (need_message(near)) { - mprf("%s wears %s.", name(DESC_CAP_THE).c_str(), - item.name(DESC_NOCAP_A).c_str()); + snprintf(info, INFO_SIZE, " wears %s.", + item.name(DESC_NOCAP_A).c_str()); + simple_monster_message(this, info); } const equipment_type eq = get_armour_slot(item); @@ -3097,9 +3099,10 @@ void monsters::unequip_weapon(item_def &item, int near, bool msg) if (msg) { - mprf("%s unwields %s.", name(DESC_CAP_THE).c_str(), - item.name(DESC_NOCAP_A, false, false, true, - false, ISFLAG_CURSED).c_str()); + snprintf(info, INFO_SIZE, " unwields %s.", + item.name(DESC_NOCAP_A, false, false, true, false, + ISFLAG_CURSED).c_str()); + msg = simple_monster_message(this, info); } const int brand = get_weapon_brand(item); @@ -3143,8 +3146,9 @@ void monsters::unequip_armour(item_def &item, int near) { if (need_message(near)) { - mprf("%s takes off %s.", name(DESC_CAP_THE).c_str(), - item.name(DESC_NOCAP_A).c_str()); + snprintf(info, INFO_SIZE, " takes off %s.", + item.name(DESC_NOCAP_A).c_str()); + simple_monster_message(this, info); } const equipment_type eq = get_armour_slot(item); @@ -3207,8 +3211,8 @@ void monsters::pickup_message(const item_def &item, int near) { mprf("%s picks up %s.", name(DESC_CAP_THE).c_str(), - item.base_type == OBJ_GOLD? "some gold" - : item.name(DESC_NOCAP_A).c_str()); + item.base_type == OBJ_GOLD ? "some gold" + : item.name(DESC_NOCAP_A).c_str()); } } @@ -3901,7 +3905,8 @@ bool monsters::pickup_item(item_def &item, int near, bool force) bool monsters::need_message(int &near) const { - return near != -1? near : (near = visible()); + return (near != -1 ? near + : (near = visible()) ); } void monsters::swap_weapons(int near) @@ -4030,8 +4035,10 @@ bool monsters::fumbles_attack(bool verbose) if (verbose) { if (you.can_see(this)) + { mprf("%s splashes around in the water.", this->name(DESC_CAP_THE).c_str()); + } else if (!silenced(you.x_pos, you.y_pos) && !silenced(x, y)) mprf(MSGCH_SOUND, "You hear a splashing noise."); } diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc index 7c99ec5860..0676537633 100644 --- a/crawl-ref/source/monstuff.cc +++ b/crawl-ref/source/monstuff.cc @@ -1316,10 +1316,8 @@ void monster_cleanup(monsters *monster) monster->reset(); for (int dmi = 0; dmi < MAX_MONSTERS; dmi++) - { if (menv[dmi].foe == monster_killed) menv[dmi].foe = MHITNOT; - } if (you.pet_target == monster_killed) you.pet_target = MHITNOT; @@ -2172,10 +2170,10 @@ static void _handle_behaviour(monsters *mon) } // validate current target exists - if (mon->foe != MHITNOT && mon->foe != MHITYOU) + if (mon->foe != MHITNOT && mon->foe != MHITYOU + && menv[mon->foe].type == -1) { - if (menv[mon->foe].type == -1) - mon->foe = MHITNOT; + mon->foe = MHITNOT; } // change proxPlayer depending on invisibility and standing @@ -2207,8 +2205,8 @@ static void _handle_behaviour(monsters *mon) } } - // set friendly target, if they don't already have one - // berserking allies ignore your commands + // Set friendly target, if they don't already have one. + // Berserking allies ignore your commands! if (isFriendly && you.pet_target != MHITNOT && (mon->foe == MHITNOT || mon->foe == MHITYOU) @@ -2217,20 +2215,16 @@ static void _handle_behaviour(monsters *mon) mon->foe = you.pet_target; } - // instead berserkers attack nearest monsters. + // Instead, berserkers attack nearest monsters. if (mon->has_ench(ENCH_BERSERK) && (mon->foe == MHITNOT || isFriendly && mon->foe == MHITYOU)) { // intelligent monsters prefer to attack the player, // even when berserking if (!isFriendly && proxPlayer && mons_intel(mon->type) >= I_NORMAL) - { mon->foe = MHITYOU; - } else - { _set_nearest_monster_foe(mon); - } } if (isNeutral && mon->foe == MHITNOT) @@ -2242,10 +2236,10 @@ static void _handle_behaviour(monsters *mon) // friendly and good neutral monsters do not attack other friendly // and good neutral monsters - if (mon->foe != MHITNOT && mon->foe != MHITYOU) + if (mon->foe != MHITNOT && mon->foe != MHITYOU + && wontAttack && mons_wont_attack(&menv[mon->foe])) { - if (wontAttack && mons_wont_attack(&menv[mon->foe])) - mon->foe = MHITNOT; + mon->foe = MHITNOT; } // neutral monsters prefer not to attack players, or other neutrals @@ -2255,8 +2249,8 @@ static void _handle_behaviour(monsters *mon) mon->foe = MHITNOT; } - // unfriendly monsters fighting other monsters will usually - // target the player, if they're healthy + // Unfriendly monsters fighting other monsters will usually + // target the player, if they're healthy. if (!isFriendly && !isNeutral && mon->foe != MHITYOU && mon->foe != MHITNOT && proxPlayer && !(mon->has_ench(ENCH_BERSERK)) && isHealthy @@ -2266,10 +2260,10 @@ static void _handle_behaviour(monsters *mon) } // validate target again - if (mon->foe != MHITNOT && mon->foe != MHITYOU) + if (mon->foe != MHITNOT && mon->foe != MHITYOU + && menv[mon->foe].type == -1) { - if (menv[mon->foe].type == -1) - mon->foe = MHITNOT; + mon->foe = MHITNOT; } while (changed) @@ -2473,10 +2467,10 @@ static void _handle_behaviour(monsters *mon) // eventually relax their guard (stupid // ones will do so faster, smart monsters // have longer memories - if (!proxFoe && mon->foe != MHITNOT) + if (!proxFoe && mon->foe != MHITNOT + && one_chance_in( isSmart ? 60 : 20 )) { - if (one_chance_in( isSmart ? 60 : 20 )) - new_foe = MHITNOT; + new_foe = MHITNOT; } break; @@ -2740,9 +2734,10 @@ static void _handle_movement(monsters *monster) mmov_x = (dx > 0) ? 1 : ((dx < 0) ? -1 : 0); mmov_y = (dy > 0) ? 1 : ((dy < 0) ? -1 : 0); - if (monster->behaviour == BEH_FLEE && - (!mons_friendly(monster) || - monster->target_x != you.x_pos || monster->target_y != you.y_pos)) + if (monster->behaviour == BEH_FLEE + && (!mons_friendly(monster) + || monster->target_x != you.x_pos + || monster->target_y != you.y_pos)) { mmov_x *= -1; mmov_y *= -1; @@ -5892,8 +5887,8 @@ bool _mon_can_move_to_pos(const monsters *monster, const int count_x, } } - // friendlies shouldn't try to move onto the player's - // location, if they are aiming for some other target + // Friendlies shouldn't try to move onto the player's + // location, if they are aiming for some other target. if (mons_wont_attack(monster) && monster->foe != MHITNOT && monster->foe != MHITYOU diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc index f96b3ec1d2..b76c36349c 100644 --- a/crawl-ref/source/player.cc +++ b/crawl-ref/source/player.cc @@ -5370,9 +5370,9 @@ void player::copy_from(const player &other) // player struct initialization void player::init() { - birth_time = time( NULL ); - real_time = 0; - num_turns = 0L; + birth_time = time( NULL ); + real_time = 0; + num_turns = 0L; last_view_update = 0L; #ifdef WIZARD @@ -5391,57 +5391,57 @@ void player::init() just_autoprayed = false; berserk_penalty = 0; - disease = 0; - elapsed_time = 0; - rotting = 0; - special_wield = SPWLD_NONE; - synch_time = 0; + disease = 0; + elapsed_time = 0; + rotting = 0; + special_wield = SPWLD_NONE; + synch_time = 0; magic_contamination = 0; - base_hp = 5000; + base_hp = 5000; base_hp2 = 5000; - hp_max = 0; - base_magic_points = 5000; + hp_max = 0; + base_magic_points = 5000; base_magic_points2 = 5000; - max_magic_points = 0; + max_magic_points = 0; magic_points_regeneration = 0; - strength = 0; - max_strength = 0; - intel = 0; - max_intel = 0; - dex = 0; - max_dex = 0; - experience = 0; + strength = 0; + max_strength = 0; + intel = 0; + max_intel = 0; + dex = 0; + max_dex = 0; + experience = 0; experience_level = 1; - max_level = 1; - char_class = JOB_UNKNOWN; - species = SP_UNKNOWN; + max_level = 1; + char_class = JOB_UNKNOWN; + species = SP_UNKNOWN; - hunger = 6000; + hunger = 6000; hunger_state = HS_SATIATED; - wield_change = false; - redraw_quiver = false; + wield_change = false; + redraw_quiver = false; received_weapon_warning = false; gold = 0; // speed = 10; // 0.75; // unused - burden = 0; + burden = 0; burden_state = BS_UNENCUMBERED; spell_no = 0; - your_level = 0; - level_type = LEVEL_DUNGEON; + your_level = 0; + level_type = LEVEL_DUNGEON; entry_cause = EC_SELF_EXPLICIT; entry_cause_god = GOD_NO_GOD; - where_are_you = BRANCH_MAIN_DUNGEON; - char_direction = GDT_DESCENDING; + where_are_you = BRANCH_MAIN_DUNGEON; + char_direction = GDT_DESCENDING; - prev_targ = MHITNOT; + prev_targ = MHITNOT; pet_target = MHITNOT; prev_grd_targ = coord_def(0, 0); @@ -5456,11 +5456,11 @@ void player::init() travel_x = 0; travel_y = 0; - religion = GOD_NO_GOD; - piety = 0; + religion = GOD_NO_GOD; + piety = 0; piety_hysteresis = 0; - gift_timeout = 0; + gift_timeout = 0; penance.init(0); worshipped.init(0); @@ -5488,7 +5488,7 @@ void player::init() skill_order.init(MAX_SKILL_ORDER); practise_skill.init(true); - skill_cost_level = 1; + skill_cost_level = 1; total_skill_points = 0; attribute.init(0); @@ -5497,13 +5497,13 @@ void player::init() for (int i = 0; i < ENDOFPACK; i++) { - inv[i].quantity = 0; + inv[i].quantity = 0; inv[i].base_type = OBJ_WEAPONS; - inv[i].sub_type = WPN_CLUB; - inv[i].plus = 0; - inv[i].plus2 = 0; - inv[i].special = 0; - inv[i].colour = 0; + inv[i].sub_type = WPN_CLUB; + inv[i].plus = 0; + inv[i].plus2 = 0; + inv[i].special = 0; + inv[i].colour = 0; set_ident_flags( inv[i], ISFLAG_IDENT_MASK ); inv[i].x = -1; @@ -5532,7 +5532,8 @@ void player::init() non_branch_info[i].assert_validity(); } - if (m_quiver) delete m_quiver; + if (m_quiver) + delete m_quiver; m_quiver = new player_quiver; } diff --git a/crawl-ref/source/stuff.cc b/crawl-ref/source/stuff.cc index c9be50c2ed..51cd1685c9 100644 --- a/crawl-ref/source/stuff.cc +++ b/crawl-ref/source/stuff.cc @@ -238,8 +238,8 @@ static bool tag_follower_at(const coord_def &pos) // only friendly monsters, or those actively seeking the // player, will follow up/down stairs. - if (!(mons_friendly(fmenv) || - (fmenv->behaviour == BEH_SEEK && fmenv->foe == MHITYOU))) + if (!mons_friendly(fmenv) + && (fmenv->behaviour != BEH_SEEK || fmenv->foe != MHITYOU)) { return (false); } @@ -252,9 +252,11 @@ static bool tag_follower_at(const coord_def &pos) return (false); // Orcs will follow Beogh worshippers. - if (!(mons_species(fmenv->type) == MONS_ORC - && you.religion == GOD_BEOGH)) + if (mons_species(fmenv->type) != MONS_ORC + || you.religion != GOD_BEOGH) + { return (false); + } } // monster is chasing player through stairs: diff --git a/crawl-ref/source/tags.cc b/crawl-ref/source/tags.cc index 0fd7ecab8a..f98d821a02 100644 --- a/crawl-ref/source/tags.cc +++ b/crawl-ref/source/tags.cc @@ -44,10 +44,10 @@ 6. The marshalling and unmarshalling of data is done in network order and is meant to keep savefiles cross-platform. They are non-ascii - always - FTP in binary mode. Note also that the marshalling sizes are 1,2, and 4 + FTP in binary mode. Note also that the marshalling sizes are 1, 2, and 4 for byte, short, and long - assuming that 'int' would have been insufficient on 16 bit systems (and that Crawl otherwise lacks - system-indepedent data types). + system-independent data types). */ @@ -123,7 +123,9 @@ void reader::read(void *data, size_t size) else { ASSERT(_read_offset+size <= _pbuf->size()); - if (data) memcpy(data, &(*_pbuf)[_read_offset], size); + if (data) + memcpy(data, &(*_pbuf)[_read_offset], size); + _read_offset += size; } } @@ -139,9 +141,7 @@ void writer::writeByte(unsigned char ch) void writer::write(const void *data, size_t size) { if (_file) - { fwrite(data, 1, size, _file); - } else { const unsigned char* cdata = static_cast(data); @@ -378,8 +378,8 @@ T unmarshall_long_as( reader& th ) level_id unmarshall_level_id( reader& th ) { level_id id; - id.branch = static_cast(unmarshallByte(th)); - id.depth = unmarshallLong(th); + id.branch = static_cast(unmarshallByte(th)); + id.depth = unmarshallLong(th); id.level_type = static_cast(unmarshallByte(th)); return (id); } @@ -411,7 +411,6 @@ void run_length_encode(writer &th, marshall m, const grid &g, { int last = 0, nlast = 0; for (int y = 0; y < height; ++y) - { for (int x = 0; x < width; ++x) { if (!nlast) @@ -428,7 +427,6 @@ void run_length_encode(writer &th, marshall m, const grid &g, last = g[x][y]; nlast = 1; } - } marshallByte(th, nlast); m(th, last); @@ -791,10 +789,10 @@ void tag_set_expected(char tags[], int fileType) for (i = 0; i < NUM_TAGS; i++) { tags[i] = -1; - switch(fileType) + switch (fileType) { case TAGTYPE_PLAYER: - if ((i >= TAG_YOU && i <= TAG_YOU_DUNGEON) + if (i >= TAG_YOU && i <= TAG_YOU_DUNGEON || i == TAG_LOST_MONSTERS) { tags[i] = 1; @@ -838,27 +836,27 @@ static void tag_construct_you(writer &th) marshallString(th, you.your_name, 30); - marshallByte(th,you.religion); - marshallByte(th,you.piety); - marshallByte(th,you.rotting); - marshallByte(th,you.symbol); - marshallByte(th,you.colour); - marshallShort(th,you.pet_target); - - marshallByte(th,you.max_level); - marshallByte(th,you.where_are_you); - marshallByte(th,you.char_direction); - marshallByte(th,you.your_level); - marshallByte(th,you.is_undead); - marshallByte(th,you.special_wield); - marshallByte(th,you.berserk_penalty); - marshallByte(th,you.level_type); + marshallByte(th, you.religion); + marshallByte(th, you.piety); + marshallByte(th, you.rotting); + marshallByte(th, you.symbol); + marshallByte(th, you.colour); + marshallShort(th, you.pet_target); + + marshallByte(th, you.max_level); + marshallByte(th, you.where_are_you); + marshallByte(th, you.char_direction); + marshallByte(th, you.your_level); + marshallByte(th, you.is_undead); + marshallByte(th, you.special_wield); + marshallByte(th, you.berserk_penalty); + marshallByte(th, you.level_type); marshallString(th, you.level_type_name); - marshallByte(th,you.entry_cause); - marshallByte(th,you.entry_cause_god); - marshallByte(th,you.synch_time); - marshallByte(th,you.disease); - marshallByte(th,you.species); + marshallByte(th, you.entry_cause); + marshallByte(th, you.entry_cause_god); + marshallByte(th, you.synch_time); + marshallByte(th, you.disease); + marshallByte(th, you.species); marshallShort(th, you.hp); @@ -869,26 +867,26 @@ static void tag_construct_you(writer &th) for (i = 0; i < NUM_EQUIP; ++i) marshallByte(th,you.equip[i]); - marshallByte(th,you.magic_points); - marshallByte(th,you.max_magic_points); - marshallByte(th,you.strength); - marshallByte(th,you.intel); - marshallByte(th,you.dex); - marshallByte(th,you.hit_points_regeneration); - marshallByte(th,you.magic_points_regeneration); + marshallByte(th, you.magic_points); + marshallByte(th, you.max_magic_points); + marshallByte(th, you.strength); + marshallByte(th, you.intel); + marshallByte(th, you.dex); + marshallByte(th, you.hit_points_regeneration); + marshallByte(th, you.magic_points_regeneration); marshallShort(th, you.hit_points_regeneration * 100); marshallLong(th, you.experience); marshallLong(th, you.gold); - marshallByte(th,you.char_class); - marshallByte(th,you.experience_level); + marshallByte(th, you.char_class); + marshallByte(th, you.experience_level); marshallLong(th, you.exp_available); /* max values */ - marshallByte(th,you.max_strength); - marshallByte(th,you.max_intel); - marshallByte(th,you.max_dex); + marshallByte(th, you.max_strength); + marshallByte(th, you.max_intel); + marshallByte(th, you.max_dex); marshallShort(th, you.base_hp); marshallShort(th, you.base_hp2); @@ -919,21 +917,21 @@ static void tag_construct_you(writer &th) marshallByte(th, 50); for (j = 0; j < 50; ++j) { - marshallByte(th,you.skills[j]); /* skills! */ - marshallByte(th,you.practise_skill[j]); /* skills! */ - marshallLong(th,you.skill_points[j]); - marshallByte(th,you.skill_order[j]); /* skills ordering */ + marshallByte(th, you.skills[j]); /* skills! */ + marshallByte(th, you.practise_skill[j]); /* skills! */ + marshallLong(th, you.skill_points[j]); + marshallByte(th, you.skill_order[j]); /* skills ordering */ } // how many durations? marshallByte(th, NUM_DURATIONS); for (j = 0; j < NUM_DURATIONS; ++j) - marshallLong(th,you.duration[j]); + marshallLong(th, you.duration[j]); // how many attributes? marshallByte(th, NUM_ATTRIBUTES); for (j = 0; j < NUM_ATTRIBUTES; ++j) - marshallByte(th,you.attribute[j]); + marshallByte(th, you.attribute[j]); // was: remembered quiver items marshallByte(th, 0); @@ -947,8 +945,8 @@ static void tag_construct_you(writer &th) marshallShort(th, NUM_MUTATIONS); for (j = 0; j < NUM_MUTATIONS; ++j) { - marshallByte(th,you.mutation[j]); - marshallByte(th,you.demon_pow[j]); + marshallByte(th, you.mutation[j]); + marshallByte(th, you.demon_pow[j]); } // how many penances? @@ -1028,10 +1026,8 @@ static void tag_construct_you_items(writer &th) // how many subtypes? marshallByte(th, 50); for (i = 0; i < NUM_IDESC; ++i) - { for (j = 0; j < 50; ++j) marshallByte(th, you.item_description[i][j]); - } // identification status const id_arr& identy(get_typeid_array()); @@ -1225,60 +1221,60 @@ static void tag_read_you(reader &th, char minorVersion) unmarshallCString(th, you.your_name, 30); - you.religion = static_cast(unmarshallByte(th)); - you.piety = unmarshallByte(th); - you.rotting = unmarshallByte(th); - you.symbol = unmarshallByte(th); - you.colour = unmarshallByte(th); - you.pet_target = unmarshallShort(th); - - you.max_level = unmarshallByte(th); - you.where_are_you = static_cast( unmarshallByte(th) ); - you.char_direction = static_cast(unmarshallByte(th)); - you.your_level = unmarshallByte(th); - you.is_undead = static_cast(unmarshallByte(th)); - you.special_wield = unmarshallByte(th); + you.religion = static_cast(unmarshallByte(th)); + you.piety = unmarshallByte(th); + you.rotting = unmarshallByte(th); + you.symbol = unmarshallByte(th); + you.colour = unmarshallByte(th); + you.pet_target = unmarshallShort(th); + + you.max_level = unmarshallByte(th); + you.where_are_you = static_cast( unmarshallByte(th) ); + you.char_direction = static_cast(unmarshallByte(th)); + you.your_level = unmarshallByte(th); + you.is_undead = static_cast(unmarshallByte(th)); + you.special_wield = unmarshallByte(th); you.berserk_penalty = unmarshallByte(th); - you.level_type = static_cast( unmarshallByte(th) ); + you.level_type = static_cast( unmarshallByte(th) ); you.level_type_name = unmarshallString(th); - you.entry_cause = static_cast( unmarshallByte(th) ); + you.entry_cause = static_cast( unmarshallByte(th) ); you.entry_cause_god = static_cast( unmarshallByte(th) ); - you.synch_time = unmarshallByte(th); - you.disease = unmarshallByte(th); - you.species = static_cast(unmarshallByte(th)); - you.hp = unmarshallShort(th); - you.hunger = unmarshallShort(th); + you.synch_time = unmarshallByte(th); + you.disease = unmarshallByte(th); + you.species = static_cast(unmarshallByte(th)); + you.hp = unmarshallShort(th); + you.hunger = unmarshallShort(th); // how many you.equip? count_c = unmarshallByte(th); for (i = 0; i < count_c; ++i) you.equip[i] = unmarshallByte(th); - you.magic_points = unmarshallByte(th); - you.max_magic_points = unmarshallByte(th); - you.strength = unmarshallByte(th); - you.intel = unmarshallByte(th); - you.dex = unmarshallByte(th); - you.hit_points_regeneration = unmarshallByte(th); + you.magic_points = unmarshallByte(th); + you.max_magic_points = unmarshallByte(th); + you.strength = unmarshallByte(th); + you.intel = unmarshallByte(th); + you.dex = unmarshallByte(th); + you.hit_points_regeneration = unmarshallByte(th); you.magic_points_regeneration = unmarshallByte(th); - you.hit_points_regeneration = unmarshallShort(th) / 100; - you.experience = unmarshallLong(th); - you.gold = unmarshallLong(th); + you.hit_points_regeneration = unmarshallShort(th) / 100; + you.experience = unmarshallLong(th); + you.gold = unmarshallLong(th); - you.char_class = static_cast(unmarshallByte(th)); - you.experience_level = unmarshallByte(th); - you.exp_available = unmarshallLong(th); + you.char_class = static_cast(unmarshallByte(th)); + you.experience_level = unmarshallByte(th); + you.exp_available = unmarshallLong(th); /* max values */ - you.max_strength = unmarshallByte(th); - you.max_intel = unmarshallByte(th); - you.max_dex = unmarshallByte(th); + you.max_strength = unmarshallByte(th); + you.max_intel = unmarshallByte(th); + you.max_dex = unmarshallByte(th); - you.base_hp = unmarshallShort(th); - you.base_hp2 = unmarshallShort(th); - you.base_magic_points = unmarshallShort(th); - you.base_magic_points2 = unmarshallShort(th); + you.base_hp = unmarshallShort(th); + you.base_hp2 = unmarshallShort(th); + you.base_magic_points = unmarshallShort(th); + you.base_magic_points2 = unmarshallShort(th); const int x = unmarshallShort(th); const int y = unmarshallShort(th); @@ -1305,17 +1301,19 @@ static void tag_read_you(reader &th, char minorVersion) count_c = unmarshallByte(th); for (i = 0; i < count_c; i++) + { you.ability_letter_table[i] = static_cast(unmarshallShort(th)); + } // how many skills? count_c = unmarshallByte(th); for (j = 0; j < count_c; ++j) { - you.skills[j] = unmarshallByte(th); + you.skills[j] = unmarshallByte(th); you.practise_skill[j] = unmarshallByte(th); - you.skill_points[j] = unmarshallLong(th); - you.skill_order[j] = unmarshallByte(th); + you.skill_points[j] = unmarshallLong(th); + you.skill_order[j] = unmarshallByte(th); } // set up you.total_skill_points and you.skill_cost_level @@ -1335,10 +1333,9 @@ static void tag_read_you(reader &th, char minorVersion) count_c = unmarshallByte(th); if (minorVersion >= TAG_MINOR_QUIVER) ASSERT(count_c == 0); + for (j = 0; j < count_c; ++j) - { unmarshallByte(th); - } count_c = unmarshallByte(th); for (j = 0; j < count_c; ++j) @@ -1364,23 +1361,23 @@ static void tag_read_you(reader &th, char minorVersion) for (i = 0; i < count_c; i++) you.num_gifts[i] = unmarshallShort(th); - you.gift_timeout = unmarshallByte(th); - you.normal_vision = unmarshallByte(th); + you.gift_timeout = unmarshallByte(th); + you.normal_vision = unmarshallByte(th); you.current_vision = unmarshallByte(th); - you.hell_exit = unmarshallByte(th); + you.hell_exit = unmarshallByte(th); // elapsed time - you.elapsed_time = (double)unmarshallFloat(th); + you.elapsed_time = (double)unmarshallFloat(th); // wizard mode - you.wizard = (bool) unmarshallByte(th); + you.wizard = (bool) unmarshallByte(th); // time of character creation unmarshallCString( th, buff, 20 ); you.birth_time = parse_date_string( buff ); - you.real_time = unmarshallLong(th); - you.num_turns = unmarshallLong(th); + you.real_time = unmarshallLong(th); + you.num_turns = unmarshallLong(th); you.magic_contamination = unmarshallShort(th); @@ -1541,10 +1538,8 @@ static void tag_read_you_dungeon(reader &th) count_s = unmarshallShort(th); for (i = 0; i < count_s; ++i) - { for (j = 0; j < count_c; ++j) tmp_file_pairs[i][j] = unmarshallBoolean(th); - } unmarshallMap(th, stair_level, unmarshall_long_as, @@ -1701,21 +1696,21 @@ void marshallItem(writer &th, const item_def &item) void unmarshallItem(reader &th, item_def &item) { - item.base_type = static_cast(unmarshallByte(th)); - item.sub_type = (unsigned char) unmarshallByte(th); - item.plus = unmarshallShort(th); - item.plus2 = unmarshallShort(th); - item.special = unmarshallLong(th); - item.quantity = unmarshallShort(th); - item.colour = (unsigned char) unmarshallByte(th); - item.x = unmarshallShort(th); - item.y = unmarshallShort(th); - item.flags = (unsigned long) unmarshallLong(th); + item.base_type = static_cast(unmarshallByte(th)); + item.sub_type = (unsigned char) unmarshallByte(th); + item.plus = unmarshallShort(th); + item.plus2 = unmarshallShort(th); + item.special = unmarshallLong(th); + item.quantity = unmarshallShort(th); + item.colour = (unsigned char) unmarshallByte(th); + item.x = unmarshallShort(th); + item.y = unmarshallShort(th); + item.flags = (unsigned long) unmarshallLong(th); unmarshallShort(th); // mitm[].link -- unused unmarshallShort(th); // igrd[item.x][item.y] -- unused - item.slot = unmarshallByte(th); + item.slot = unmarshallByte(th); item.orig_place = unmarshallShort(th); item.orig_monnum = unmarshallShort(th); @@ -1754,10 +1749,10 @@ static void marshall_mon_enchant(writer &th, const mon_enchant &me) static mon_enchant unmarshall_mon_enchant(reader &th) { mon_enchant me; - me.ench = static_cast( unmarshallShort(th) ); - me.degree = unmarshallShort(th); - me.who = static_cast( unmarshallShort(th) ); - me.duration = unmarshallShort(th); + me.ench = static_cast( unmarshallShort(th) ); + me.degree = unmarshallShort(th); + me.who = static_cast( unmarshallShort(th) ); + me.duration = unmarshallShort(th); me.maxduration = unmarshallShort(th); return (me); } @@ -1889,7 +1884,6 @@ void tag_construct_level_tiles(writer &th) tile = env.tile_bk_fg[0][0]; rle_count = 0; for (int count_x = 0; count_x < GXM; count_x++) - { for (int count_y = 0; count_y < GYM; count_y++) { last_tile = tile; @@ -1912,20 +1906,19 @@ void tag_construct_level_tiles(writer &th) rle_count = 1; } } - } + marshallLong(th, tile); marshallByte(th, rle_count); - // flavor + // flavour for (int count_x = 0; count_x < GXM; count_x++) - { for (int count_y = 0; count_y < GYM; count_y++) { marshallByte(th, env.tile_flavor[count_x][count_y].wall); marshallByte(th, env.tile_flavor[count_x][count_y].floor); marshallByte(th, env.tile_flavor[count_x][count_y].special); } - } + #endif } @@ -1934,7 +1927,7 @@ static void tag_read_level( reader &th, char minorVersion ) env.floor_colour = unmarshallByte(th); env.rock_colour = unmarshallByte(th); - env.level_flags = (unsigned long) unmarshallLong(th); + env.level_flags = (unsigned long) unmarshallLong(th); env.elapsed_time = unmarshallFloat(th); // map grids @@ -1946,22 +1939,20 @@ static void tag_read_level( reader &th, char minorVersion ) env.turns_on_level = unmarshallLong(th); for (int i = 0; i < gx; i++) - { for (int j = 0; j < gy; j++) { grd[i][j] = static_cast( static_cast(unmarshallByte(th)) ); - env.map[i][j].object = unmarshallShort(th); - env.map[i][j].colour = unmarshallShort(th); - env.map[i][j].flags = unmarshallShort(th); + env.map[i][j].object = unmarshallShort(th); + env.map[i][j].colour = unmarshallShort(th); + env.map[i][j].flags = unmarshallShort(th); env.map[i][j].property = unmarshallShort(th); mgrd[i][j] = NON_MONSTER; env.cgrid[i][j] = (unsigned short) unmarshallShort(th); } - } env.grid_colours.init(BLACK); run_length_decode(th, unmarshallByte, env.grid_colours, GXM, GYM); @@ -1974,7 +1965,7 @@ static void tag_read_level( reader &th, char minorVersion ) { env.cloud[i].x = unmarshallByte(th); env.cloud[i].y = unmarshallByte(th); - env.cloud[i].type = static_cast(unmarshallByte(th)); + env.cloud[i].type = static_cast(unmarshallByte(th)); env.cloud[i].decay = unmarshallShort(th); env.cloud[i].spread_rate = (unsigned char) unmarshallByte(th); env.cloud[i].whose = static_cast(unmarshallShort(th)); @@ -1991,7 +1982,7 @@ static void tag_read_level( reader &th, char minorVersion ) env.shop[i].x = unmarshallByte(th); env.shop[i].y = unmarshallByte(th); env.shop[i].greed = unmarshallByte(th); - env.shop[i].type = static_cast(unmarshallByte(th)); + env.shop[i].type = static_cast(unmarshallByte(th)); env.shop[i].level = unmarshallByte(th); } @@ -2010,6 +2001,7 @@ static void tag_read_level_items(reader &th, char minorVersion) env.trap[i].type = static_cast( static_cast(unmarshallByte(th)) ); + env.trap[i].x = unmarshallByte(th); env.trap[i].y = unmarshallByte(th); } @@ -2027,19 +2019,19 @@ static void unmarshall_monster(reader &th, monsters &m) if (_tag_minor_version >= TAG_MINOR_MONNAM) m.mname = unmarshallString(th, 100); - m.ac = unmarshallByte(th); - m.ev = unmarshallByte(th); - m.hit_dice = unmarshallByte(th); - m.speed = unmarshallByte(th); + m.ac = unmarshallByte(th); + m.ev = unmarshallByte(th); + m.hit_dice = unmarshallByte(th); + m.speed = unmarshallByte(th); // Avoid sign extension when loading files (Elethiomel's hang) m.speed_increment = (unsigned char) unmarshallByte(th); - m.behaviour = static_cast(unmarshallByte(th)); - m.x = unmarshallByte(th); - m.y = unmarshallByte(th); - m.target_x = unmarshallByte(th); - m.target_y = unmarshallByte(th); - m.flags = unmarshallLong(th); - m.experience = static_cast(unmarshallLong(th)); + m.behaviour = static_cast(unmarshallByte(th)); + m.x = unmarshallByte(th); + m.y = unmarshallByte(th); + m.target_x = unmarshallByte(th); + m.target_y = unmarshallByte(th); + m.flags = unmarshallLong(th); + m.experience = static_cast(unmarshallLong(th)); m.enchantments.clear(); const int nenchs = unmarshallShort(th); @@ -2050,16 +2042,16 @@ static void unmarshall_monster(reader &th, monsters &m) } m.ench_countdown = unmarshallByte(th); - m.type = unmarshallShort(th); - m.hit_points = unmarshallShort(th); + m.type = unmarshallShort(th); + m.hit_points = unmarshallShort(th); m.max_hit_points = unmarshallShort(th); - m.number = unmarshallShort(th); + m.number = unmarshallShort(th); if (_tag_minor_version >= TAG_MINOR_MONBASE) m.base_monster = static_cast(unmarshallShort(th)); else m.base_monster = static_cast(m.number); - m.colour = unmarshallShort(th); + m.colour = unmarshallShort(th); for (int j = 0; j < NUM_MONSTER_SLOTS; j++) m.inv[j] = unmarshallShort(th); @@ -2109,7 +2101,7 @@ void tag_read_level_attitude(reader &th) for (i = 0; i < count; i++) { menv[i].attitude = static_cast(unmarshallByte(th)); - menv[i].foe = unmarshallShort(th); + menv[i].foe = unmarshallShort(th); } } @@ -2190,45 +2182,40 @@ void tag_read_level_tiles(struct reader &th) // BG first for (int i = 0; i < gx; i++) - { for (int j = 0; j < gy; j++) { if (rle_count == 0) { - tile = unmarshallLong(th); + tile = unmarshallLong(th); rle_count = unmarshallByte(th); } env.tile_bk_bg[i][j] = tile; rle_count--; } - } // FG rle_count = 0; for (int i = 0; i < gx; i++) - { for (int j = 0; j < gy; j++) { if (rle_count == 0) { - tile = unmarshallLong(th); + tile = unmarshallLong(th); rle_count = unmarshallByte(th); } env.tile_bk_fg[i][j] = tile; rle_count--; } - } - // flavor + // flavour for (int x = 0; x < gx; x++) - { for (int y = 0; y < gy; y++) { - env.tile_flavor[x][y].wall = unmarshallByte(th); - env.tile_flavor[x][y].floor = unmarshallByte(th); + env.tile_flavor[x][y].wall = unmarshallByte(th); + env.tile_flavor[x][y].floor = unmarshallByte(th); env.tile_flavor[x][y].special = unmarshallByte(th); } - } + #endif } @@ -2239,13 +2226,12 @@ static void tag_missing_level_tiles() int j; for (i = 0; i < GXM; i++) - { for (j = 0; j < GYM; j++) { env.tile_bk_bg[i][j] = 0; env.tile_bk_fg[i][j] = 0; } - } + #endif } @@ -2269,18 +2255,18 @@ static void marshallResists(writer &th, const mon_resist_def &res) static void unmarshallResists(reader &th, mon_resist_def &res) { - res.elec = unmarshallByte(th); - res.poison = unmarshallByte(th); - res.fire = unmarshallByte(th); - res.steam = unmarshallByte(th); - res.cold = unmarshallByte(th); - res.hellfire = unmarshallByte(th); - res.asphyx = unmarshallByte(th); - res.acid = unmarshallByte(th); + res.elec = unmarshallByte(th); + res.poison = unmarshallByte(th); + res.fire = unmarshallByte(th); + res.steam = unmarshallByte(th); + res.cold = unmarshallByte(th); + res.hellfire = unmarshallByte(th); + res.asphyx = unmarshallByte(th); + res.acid = unmarshallByte(th); res.sticky_flame = unmarshallByte(th); - res.pierce = unmarshallByte(th); - res.slice = unmarshallByte(th); - res.bludgeon = unmarshallByte(th); + res.pierce = unmarshallByte(th); + res.slice = unmarshallByte(th); + res.bludgeon = unmarshallByte(th); } static void marshallSpells(writer &th, const monster_spells &spells) @@ -2325,26 +2311,26 @@ static ghost_demon unmarshallGhost( reader &th ) { ghost_demon ghost; - ghost.name = unmarshallString(th, 20); + ghost.name = unmarshallString(th, 20); - ghost.species = static_cast( unmarshallShort(th) ); - ghost.job = static_cast( unmarshallShort(th) ); - ghost.best_skill = static_cast( unmarshallShort(th) ); + ghost.species = static_cast( unmarshallShort(th) ); + ghost.job = static_cast( unmarshallShort(th) ); + ghost.best_skill = static_cast( unmarshallShort(th) ); ghost.best_skill_level = unmarshallShort(th); - ghost.xl = unmarshallShort(th); - ghost.max_hp = unmarshallShort(th); - ghost.ev = unmarshallShort(th); - ghost.ac = unmarshallShort(th); - ghost.damage = unmarshallShort(th); - ghost.speed = unmarshallShort(th); - ghost.see_invis = unmarshallByte(th); - ghost.brand = static_cast( unmarshallShort(th) ); + ghost.xl = unmarshallShort(th); + ghost.max_hp = unmarshallShort(th); + ghost.ev = unmarshallShort(th); + ghost.ac = unmarshallShort(th); + ghost.damage = unmarshallShort(th); + ghost.speed = unmarshallShort(th); + ghost.see_invis = unmarshallByte(th); + ghost.brand = static_cast( unmarshallShort(th) ); unmarshallResists(th, ghost.resists); - ghost.spellcaster = unmarshallByte(th); - ghost.cycle_colours = unmarshallByte(th); - ghost.fly = static_cast( unmarshallShort(th) ); + ghost.spellcaster = unmarshallByte(th); + ghost.cycle_colours = unmarshallByte(th); + ghost.fly = static_cast( unmarshallShort(th) ); unmarshallSpells(th, ghost.spells); diff --git a/crawl-ref/source/travel.cc b/crawl-ref/source/travel.cc index d93c31df8d..5e6a845136 100644 --- a/crawl-ref/source/travel.cc +++ b/crawl-ref/source/travel.cc @@ -1214,7 +1214,7 @@ command_type travel() // we've reached that destination square. else if (runmode == RMODE_INTERLEVEL && (level_target.p.pos != you.pos() - || level_target.p.id != level_id::current())) + || level_target.p.id != level_id::current())) { if (last_stair.depth != -1 && last_stair == level_id::current()) @@ -1729,13 +1729,13 @@ bool travel_pathfind::path_flood(const coord_def &c, const coord_def &dc) { const int feature = grd(dc); - if (((feature != DNGN_FLOOR - && feature != DNGN_SHALLOW_WATER - && feature != DNGN_DEEP_WATER - && feature != DNGN_LAVA) - || is_waypoint(dc.x, dc.y) - || is_stash(ls, dc.x, dc.y)) - && dc != start) + if (dc != start + && (feature != DNGN_FLOOR + && feature != DNGN_SHALLOW_WATER + && feature != DNGN_DEEP_WATER + && feature != DNGN_LAVA + || is_waypoint(dc.x, dc.y) + || is_stash(ls, dc.x, dc.y))) { features->push_back(dc); } @@ -1781,10 +1781,8 @@ bool travel_pathfind::path_examine_point(const coord_def &c) // first so that the travel path doesn't zigzag all over the map. Note the // (dir = 1) is intentional assignment. for (int dir = 0; dir < 8; (dir += 2) == 8 && (dir = 1)) - { if (path_flood(c, c + Compass[dir])) return (true); - } return (false); } @@ -1798,14 +1796,17 @@ void find_travel_pos(int youx, int youy, travel_pathfind tp; if (move_x && move_y) + { tp.set_src_dst(coord_def(youx, youy), coord_def(you.running.x, you.running.y)); + } else tp.set_floodseed(coord_def(youx, youy)); tp.set_feature_vector(features); - run_mode_type rmode = move_x && move_y? RMODE_TRAVEL : RMODE_NOT_RUNNING; + run_mode_type rmode = (move_x && move_y) ? RMODE_TRAVEL + : RMODE_NOT_RUNNING; const coord_def dest = tp.pathfind( rmode ); @@ -2564,9 +2565,11 @@ static int find_transtravel_stair( const level_id &cur, // for a location on the same level. If that's the case, we can get // the distance off the travel_point_distance matrix. deltadist = travel_point_distance[target.pos.x][target.pos.y]; - if (!deltadist && - (stair.x != target.pos.x || stair.y != target.pos.y)) + if (!deltadist + && (stair.x != target.pos.x || stair.y != target.pos.y)) + { deltadist = -1; + } } if (deltadist != -1) diff --git a/crawl-ref/source/view.cc b/crawl-ref/source/view.cc index af93ca05f1..da1bbab112 100644 --- a/crawl-ref/source/view.cc +++ b/crawl-ref/source/view.cc @@ -4853,8 +4853,8 @@ void viewwindow(bool draw_it, bool do_updates) if (flash_colour && buffy[bufcount]) { buffy[bufcount + 1] = - see_grid(gc.x, gc.y)? - real_colour(flash_colour) : DARKGREY; + see_grid(gc.x, gc.y) ? real_colour(flash_colour) + : DARKGREY; } bufcount += 2; -- cgit v1.2.3-54-g00ecf