diff options
author | haranp <haranp@c06c8d41-db1a-0410-9941-cceddc491573> | 2009-02-20 00:20:43 +0000 |
---|---|---|
committer | haranp <haranp@c06c8d41-db1a-0410-9941-cceddc491573> | 2009-02-20 00:20:43 +0000 |
commit | 207f41de95938d15bca36a7b5b8872adabd78e2d (patch) | |
tree | b287162b2c459ed2b5dc2a880b98a35f7f80c05d | |
parent | b846daeeb21ef06b3da9e3c445a65c3611ef181d (diff) | |
download | crawl-ref-207f41de95938d15bca36a7b5b8872adabd78e2d.tar.gz crawl-ref-207f41de95938d15bca36a7b5b8872adabd78e2d.zip |
For [2615112], add a hook for portal vault levels to override the
default extension (ptl) for ghost filenames. This currently has no
effect, as I don't know how to hook in Lua code; can someone who
knows this better put in code to allow .des files to override this
extension? [The idea is to give "suffix" a good value in
_make_ghost_filename().]
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@9135 c06c8d41-db1a-0410-9941-cceddc491573
-rw-r--r-- | crawl-ref/source/files.cc | 26 | ||||
-rw-r--r-- | crawl-ref/source/it_use3.cc | 70 | ||||
-rw-r--r-- | crawl-ref/source/monstuff.cc | 14 |
3 files changed, 51 insertions, 59 deletions
diff --git a/crawl-ref/source/files.cc b/crawl-ref/source/files.cc index 10833e6141..070076e706 100644 --- a/crawl-ref/source/files.cc +++ b/crawl-ref/source/files.cc @@ -1540,16 +1540,26 @@ void save_game_state() save_game(true); } +static std::string _make_ghost_filename() +{ + if (you.level_type == LEVEL_PORTAL_VAULT) + { + std::string suffix = "ptl"; + return get_savedir_filename("bones", "", suffix, true); + } + else + { + return make_filename("bones", you.your_level, you.where_are_you, + you.level_type, true); + } +} + void _load_ghost(void) { char majorVersion; char minorVersion; - std::string cha_fil = make_filename("bones", you.your_level, - you.where_are_you, - you.level_type, - true ); - + const std::string cha_fil = _make_ghost_filename(); FILE *gfile = fopen(cha_fil.c_str(), "rb"); if (gfile == NULL) @@ -1896,11 +1906,7 @@ void save_ghost( bool force ) return; } - std::string cha_fil = make_filename( "bones", you.your_level, - you.where_are_you, - you.level_type, - true ); - + const std::string cha_fil = _make_ghost_filename(); FILE *gfile = fopen(cha_fil.c_str(), "rb"); // Don't overwrite existing bones! diff --git a/crawl-ref/source/it_use3.cc b/crawl-ref/source/it_use3.cc index 1a1c7b03da..3de3c87738 100644 --- a/crawl-ref/source/it_use3.cc +++ b/crawl-ref/source/it_use3.cc @@ -11,6 +11,7 @@ REVISION("$Rev$"); #include "it_use3.h" +#include <algorithm> #include <cstdlib> #include <string.h> @@ -61,20 +62,17 @@ static bool efreet_flask(void); void special_wielded() { - const int wpn = you.equip[EQ_WEAPON]; - const int old_plus = you.inv[wpn].plus; - const int old_plus2 = you.inv[wpn].plus2; - const char old_colour = you.inv[wpn].colour; - bool makes_noise = false; + item_def& weapon = *you.weapon(); + const int old_plus = weapon.plus; + const int old_plus2 = weapon.plus2; + const char old_colour = weapon.colour; switch (you.special_wield) { case SPWLD_SING: case SPWLD_NOISE: { - makes_noise = (one_chance_in(20) && !silenced(you.pos())); - - if (makes_noise) + if (!silenced(you.pos()) && one_chance_in(20)) { std::string msg; @@ -150,7 +148,7 @@ void special_wielded() // replace weapon references msg = replace_all(msg, "@The_weapon@", "The @weapon@"); msg = replace_all(msg, "@the_weapon@", "the @weapon@"); - msg = replace_all(msg, "@weapon@", you.inv[wpn].name(DESC_BASENAME)); + msg = replace_all(msg, "@weapon@", weapon.name(DESC_BASENAME)); // replace references to player name and god msg = replace_all(msg, "@player_name@", you.your_name); msg = replace_all(msg, "@player_god@", @@ -159,7 +157,8 @@ void special_wielded() mpr(msg.c_str(), channel); - } // makes_noise + noisy(25, you.pos()); + } break; } @@ -169,25 +168,25 @@ void special_wielded() break; case SPWLD_VARIABLE: - do_uncurse_item( you.inv[wpn] ); + do_uncurse_item(weapon); - if (x_chance_in_y(2, 5)) // 40% chance {dlb} - you.inv[wpn].plus += (coinflip() ? +1 : -1); + if (x_chance_in_y(2, 5)) + weapon.plus += (coinflip() ? +1 : -1); - if (x_chance_in_y(2, 5)) // 40% chance {dlb} - you.inv[wpn].plus2 += (coinflip() ? +1 : -1); + if (x_chance_in_y(2, 5)) + weapon.plus2 += (coinflip() ? +1 : -1); - if (you.inv[wpn].plus < -4) - you.inv[wpn].plus = -4; - else if (you.inv[wpn].plus > 16) - you.inv[wpn].plus = 16; + if (weapon.plus < -4) + weapon.plus = -4; + else if (weapon.plus > 16) + weapon.plus = 16; - if (you.inv[wpn].plus2 < -4) - you.inv[wpn].plus2 = -4; - else if (you.inv[wpn].plus2 > 16) - you.inv[wpn].plus2 = 16; + if (weapon.plus2 < -4) + weapon.plus2 = -4; + else if (weapon.plus2 > 16) + weapon.plus2 = 16; - you.inv[wpn].colour = random_colour(); + weapon.colour = random_colour(); break; case SPWLD_TORMENT: @@ -207,20 +206,20 @@ void special_wielded() break; case SPWLD_POWER: - you.inv[wpn].plus = stepdown_value( -4 + (you.hp / 5), 4, 4, 4, 20 ); - you.inv[wpn].plus2 = you.inv[wpn].plus; + weapon.plus = stepdown_value( -4 + (you.hp / 5), 4, 4, 4, 20 ); + weapon.plus2 = weapon.plus; break; case SPWLD_OLGREB: // Giving Olgreb's staff a little lift since staves of poison have // been made better. -- bwr - you.inv[wpn].plus = you.skills[SK_POISON_MAGIC] / 3; - you.inv[wpn].plus2 = you.inv[wpn].plus; + weapon.plus = you.skills[SK_POISON_MAGIC] / 3; + weapon.plus2 = weapon.plus; break; case SPWLD_WUCAD_MU: - you.inv[wpn].plus = ((you.intel > 25) ? 22 : you.intel - 3); - you.inv[wpn].plus2 = ((you.intel > 25) ? 13 : you.intel / 2); + weapon.plus = std::min(you.intel - 3, 22); + weapon.plus2 = std::min(you.intel / 2, 13); break; case SPWLD_SHADOW: @@ -237,16 +236,13 @@ void special_wielded() return; } - if (makes_noise) - noisy(25, you.pos()); - - if (old_plus != you.inv[wpn].plus - || old_plus2 != you.inv[wpn].plus2 - || old_colour != you.inv[wpn].colour) + if (old_plus != weapon.plus + || old_plus2 != weapon.plus2 + || old_colour != weapon.colour) { you.wield_change = true; } -} // end special_wielded() +} static bool _reaching_weapon_attack(const item_def& wpn) { diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc index 7f688c2b2b..c77d13af2c 100644 --- a/crawl-ref/source/monstuff.cc +++ b/crawl-ref/source/monstuff.cc @@ -6894,8 +6894,6 @@ static void _swim_or_move_energy(monsters *mon) static void _handle_monster_move(monsters *monster) { - bool brkk = false; - monster->hit_points = std::min(monster->max_hit_points, monster->hit_points); @@ -7169,8 +7167,6 @@ static void _handle_monster_move(monsters *monster) // Calculates mmov based on monster target. _handle_movement(monster); - brkk = false; - if (mons_is_confused(monster) || monster->type == MONS_AIR_ELEMENTAL && mons_is_submerged(monster)) @@ -7191,9 +7187,9 @@ static void _handle_monster_move(monsters *monster) { if (monsters_fight(monster, enemy)) { - brkk = true; mmov.reset(); DEBUG_ENERGY_USE("monsters_fight()"); + continue; } else { @@ -7208,9 +7204,6 @@ static void _handle_monster_move(monsters *monster) } } } - - if (brkk) - continue; } _handle_nearby_ability( monster ); @@ -7306,14 +7299,11 @@ static void _handle_monster_move(monsters *monster) } mmov.reset(); - brkk = true; DEBUG_ENERGY_USE("monsters_fight()"); + continue; } } - if (brkk) - continue; - if (monster->pos() + mmov == you.pos()) { ASSERT(!crawl_state.arena); |