diff options
author | zelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573> | 2009-01-03 22:35:28 +0000 |
---|---|---|
committer | zelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573> | 2009-01-03 22:35:28 +0000 |
commit | e9fd95f6c3dccee78f770c32757da8cd0f938011 (patch) | |
tree | d8db42feea3b77f5e4d3c46a85bab0d2c13a8201 /crawl-ref | |
parent | bf2a59fd761571998062b21409ee678e2852254b (diff) | |
download | crawl-ref-e9fd95f6c3dccee78f770c32757da8cd0f938011.tar.gz crawl-ref-e9fd95f6c3dccee78f770c32757da8cd0f938011.zip |
Add ASSERT(!crawl_state.arena) to a number of places.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@8184 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref')
-rw-r--r-- | crawl-ref/source/arena.cc | 5 | ||||
-rw-r--r-- | crawl-ref/source/delay.cc | 3 | ||||
-rw-r--r-- | crawl-ref/source/effects.cc | 18 | ||||
-rw-r--r-- | crawl-ref/source/fight.cc | 4 | ||||
-rw-r--r-- | crawl-ref/source/misc.cc | 6 | ||||
-rw-r--r-- | crawl-ref/source/player.cc | 62 | ||||
-rw-r--r-- | crawl-ref/source/spells1.cc | 4 | ||||
-rw-r--r-- | crawl-ref/source/spl-cast.cc | 2 |
8 files changed, 103 insertions, 1 deletions
diff --git a/crawl-ref/source/arena.cc b/crawl-ref/source/arena.cc index f9f5752cd9..b85c54e588 100644 --- a/crawl-ref/source/arena.cc +++ b/crawl-ref/source/arena.cc @@ -362,8 +362,11 @@ namespace arena you.mutation[MUT_ACUTE_VISION] = 3; coord_def yplace(dgn_find_feature_marker(DNGN_ESCAPE_HATCH_UP)); - // Fix up the viewport. + // Fix up the viewport. Temporarily unset arena mode to avoid + // assertion. + crawl_state.arena = false; you.moveto(yplace); + crawl_state.arena = true; strcpy(you.your_name, "Arena"); diff --git a/crawl-ref/source/delay.cc b/crawl-ref/source/delay.cc index e04b3c7762..0f8c5ed9e8 100644 --- a/crawl-ref/source/delay.cc +++ b/crawl-ref/source/delay.cc @@ -296,6 +296,7 @@ static void _clear_pending_delays() void start_delay( delay_type type, int turns, int parm1, int parm2 ) { + ASSERT(!crawl_state.arena); ASSERT(!crawl_state.is_repeating_cmd() || type == DELAY_MACRO); _interrupts_blocked = 0; // Just to be safe @@ -331,6 +332,8 @@ void stop_delay( bool stop_stair_travel ) if (you.delay_queue.empty()) return; + ASSERT(!crawl_state.arena); + delay_queue_item delay = you.delay_queue.front(); ASSERT(!crawl_state.is_repeating_cmd() || delay.type == DELAY_MACRO); diff --git a/crawl-ref/source/effects.cc b/crawl-ref/source/effects.cc index 483b045600..5dfa5ba42e 100644 --- a/crawl-ref/source/effects.cc +++ b/crawl-ref/source/effects.cc @@ -158,6 +158,8 @@ int holy_word(int pow, int caster, const coord_def& where, bool silent) int torment_player(int pow, int caster) { + ASSERT(!crawl_state.arena); + UNUSED(pow); // [dshaligram] Switched to using ouch() instead of dec_hp() so that @@ -266,6 +268,8 @@ int torment(int caster, const coord_def& where) void immolation(int caster, bool known) { + ASSERT(!crawl_state.arena); + const char *aux = "immolation"; bolt beam; @@ -311,6 +315,8 @@ static std::string _who_banished(const std::string &who) void banished(dungeon_feature_type gate_type, const std::string &who) { + ASSERT(!crawl_state.arena); + #ifdef DGL_MILESTONES if (gate_type == DNGN_ENTER_ABYSS) { @@ -457,6 +463,8 @@ void banished(dungeon_feature_type gate_type, const std::string &who) bool forget_spell(void) { + ASSERT(!crawl_state.arena); + if (!you.spell_no) return (false); @@ -692,6 +700,8 @@ void direct_effect(monsters *source, spell_type spell, void random_uselessness(int scroll_slot) { + ASSERT(!crawl_state.arena); + int temp_rand = random2(8); // If this isn't from a scroll, skip the first two possibilities. @@ -1520,6 +1530,8 @@ static void _do_book_acquirement(item_def &book, int agent) bool acquirement(object_class_type class_wanted, int agent, bool quiet, int* item_index) { + ASSERT(!crawl_state.arena); + int thing_created = NON_ITEM; if (item_index == NULL) @@ -1987,6 +1999,8 @@ static void _set_allies_patrol_point(bool clear = false) void yell(bool force) { + ASSERT(!crawl_state.arena); + bool targ_prev = false; int mons_targd = MHITNOT; struct dist targ; @@ -2168,6 +2182,8 @@ void yell(bool force) bool forget_inventory(bool quiet) { + ASSERT(!crawl_state.arena); + int items_forgotten = 0; for (int i = 0; i < ENDOFPACK; i++) @@ -3465,6 +3481,8 @@ static void _catchup_monster_moves(monsters *mon, int turns) //--------------------------------------------------------------- void update_level(double elapsedTime) { + ASSERT(!crawl_state.arena); + const int turns = static_cast<int>(elapsedTime / 10.0); #if DEBUG_DIAGNOSTICS diff --git a/crawl-ref/source/fight.cc b/crawl-ref/source/fight.cc index 945fe5efad..fc6afaffa3 100644 --- a/crawl-ref/source/fight.cc +++ b/crawl-ref/source/fight.cc @@ -4854,6 +4854,8 @@ static bool wielded_weapon_check(const item_def *weapon) // Returns true if you hit the monster. bool you_attack(int monster_attacked, bool unarmed_attacks) { + ASSERT(!crawl_state.arena); + monsters *defender = &menv[monster_attacked]; melee_attack attk(&you, defender, unarmed_attacks); @@ -4912,6 +4914,8 @@ static void mons_lose_attack_energy(monsters *attacker, int wpn_speed, // A monster attacking the player. bool monster_attack(int monster_attacking, bool allow_unarmed) { + ASSERT(!crawl_state.arena); + monsters *attacker = &menv[monster_attacking]; // Friendly and good neutral monsters won't attack unless confused. diff --git a/crawl-ref/source/misc.cc b/crawl-ref/source/misc.cc index 74c8a87898..b889a3cbd7 100644 --- a/crawl-ref/source/misc.cc +++ b/crawl-ref/source/misc.cc @@ -1261,6 +1261,8 @@ void generate_random_blood_spatter_on_level() void search_around( bool only_adjacent ) { + ASSERT(!crawl_state.arena); + // Traps and doors stepdown skill: // skill/(2x-1) for squares at distance x int max_dist = (you.skills[SK_TRAPS_DOORS] + 1) / 2; @@ -2571,6 +2573,8 @@ std::string weird_sound() bool scramble(void) { + ASSERT(!crawl_state.arena); + // Statues are too stiff and heavy to scramble out of the water. if (you.attribute[ATTR_TRANSFORMATION] == TRAN_STATUE) return (false); @@ -2586,6 +2590,8 @@ bool scramble(void) bool go_berserk(bool intentional) { + ASSERT(!crawl_state.arena); + if (!you.can_go_berserk(intentional)) return (false); diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc index 66cc61224a..e03b719612 100644 --- a/crawl-ref/source/player.cc +++ b/crawl-ref/source/player.cc @@ -100,6 +100,7 @@ static void _attribute_increase(); bool move_player_to_grid( const coord_def& p, bool stepped, bool allow_shift, bool force, bool swapping ) { + ASSERT(!crawl_state.arena); ASSERT( in_bounds( p ) ); // assuming that entering the same square means coming from above (levitate) @@ -995,6 +996,8 @@ int player_damage_brand( void ) int player_teleport(bool calc_unid) { + ASSERT(!crawl_state.arena); + int tp = 0; // rings @@ -2894,6 +2897,8 @@ bool you_resist_magic(int power) // force is true for forget_map command on level map. void forget_map(unsigned char chance_forgotten, bool force) { + ASSERT(!crawl_state.arena); + if (force && !yesno("Really forget level map?", true, 'n')) return; @@ -3584,6 +3589,7 @@ void level_change(bool skip_attribute_increase) // - 12mar2000 {dlb} int check_stealth(void) { + ASSERT(!crawl_state.arena); #ifdef WIZARD // Extreme stealthiness can be enforced by wizmode stealth setting. if (you.skills[SK_STEALTH] > 27) @@ -4537,6 +4543,8 @@ int scan_randarts(randart_prop_type which_property, bool calc_unid) void modify_stat(stat_type which_stat, char amount, bool suppress_msg, const char *cause, bool see_source) { + ASSERT(!crawl_state.arena); + char *ptr_stat = NULL; char *ptr_stat_max = NULL; bool *ptr_redraw = NULL; @@ -4671,6 +4679,8 @@ void modify_stat(stat_type which_stat, char amount, bool suppress_msg, void dec_hp(int hp_loss, bool fatal, const char *aux) { + ASSERT(!crawl_state.arena); + if (!fatal && you.hp < 1) you.hp = 1; @@ -4693,6 +4703,8 @@ void dec_hp(int hp_loss, bool fatal, const char *aux) void dec_mp(int mp_loss) { + ASSERT(!crawl_state.arena); + if (mp_loss < 1) return; @@ -4714,6 +4726,8 @@ void dec_mp(int mp_loss) bool enough_hp(int minimum, bool suppress_msg) { + ASSERT(!crawl_state.arena); + // We want to at least keep 1 HP. -- bwr if (you.hp < minimum + 1) { @@ -4730,6 +4744,8 @@ bool enough_hp(int minimum, bool suppress_msg) bool enough_mp(int minimum, bool suppress_msg) { + ASSERT(!crawl_state.arena); + if (you.magic_points < minimum) { if (!suppress_msg) @@ -4747,6 +4763,8 @@ bool enough_mp(int minimum, bool suppress_msg) // resulting max value is subject to penalties, bonuses, and scalings. void inc_mp(int mp_gain, bool max_too) { + ASSERT(!crawl_state.arena); + if (mp_gain < 1) return; @@ -4772,6 +4790,8 @@ void inc_mp(int mp_gain, bool max_too) // To avoid message spam, don't take notes when HP increases. void inc_hp(int hp_gain, bool max_too) { + ASSERT(!crawl_state.arena); + if (hp_gain < 1) return; @@ -4863,6 +4883,8 @@ void dec_max_mp( int mp_loss ) // Use of floor: false = hp max, true = hp min. {dlb} void deflate_hp(int new_level, bool floor) { + ASSERT(!crawl_state.arena); + if (floor && you.hp < new_level) you.hp = new_level; else if (!floor && you.hp > new_level) @@ -4876,6 +4898,8 @@ void deflate_hp(int new_level, bool floor) // resulting max value is subject to penalties, bonuses, and scalings. void set_hp(int new_amount, bool max_too) { + ASSERT(!crawl_state.arena); + if (you.hp != new_amount) you.hp = new_amount; @@ -4899,6 +4923,8 @@ void set_hp(int new_amount, bool max_too) // resulting max value is subject to penalties, bonuses, and scalings. void set_mp(int new_amount, bool max_too) { + ASSERT(!crawl_state.arena); + if (you.magic_points != new_amount) you.magic_points = new_amount; @@ -4992,6 +5018,8 @@ static int _get_contamination_level() // status_only is true only for the status output void contaminate_player(int change, bool controlled, bool status_only) { + ASSERT(!crawl_state.arena); + // get current contamination level int old_level = _get_contamination_level(); int new_level = 0; @@ -5065,6 +5093,8 @@ void contaminate_player(int change, bool controlled, bool status_only) bool confuse_player(int amount, bool resistable) { + ASSERT(!crawl_state.arena); + if (amount <= 0) return (false); @@ -5097,6 +5127,8 @@ bool confuse_player(int amount, bool resistable) bool curare_hits_player(int agent, int amount) { + ASSERT(!crawl_state.arena); + poison_player(amount); const bool res_poison = player_res_poison() > 0; @@ -5125,6 +5157,8 @@ bool curare_hits_player(int agent, int amount) bool poison_player(int amount, bool force) { + ASSERT(!crawl_state.arena); + if (!force && player_res_poison() > 0 || amount <= 0) return (false); @@ -5198,6 +5232,8 @@ void reduce_poison_player(int amount) bool napalm_player(int amount) { + ASSERT(!crawl_state.arena); + if (player_res_sticky_flame() > 0 || amount <= 0) return (false); @@ -5253,6 +5289,8 @@ void dec_napalm_player() bool slow_player(int amount) { + ASSERT(!crawl_state.arena); + if (amount <= 0) return (false); @@ -5310,6 +5348,8 @@ void dec_slow_player() void haste_player(int amount) { + ASSERT(!crawl_state.arena); + if (amount <= 0) return; @@ -5390,6 +5430,8 @@ void dec_disease_player() bool rot_player(int amount) { + ASSERT(!crawl_state.arena); + if (amount <= 0) return (false); @@ -6384,6 +6426,8 @@ static bool _equipment_make_berserk() void player::attacking(actor *other) { + ASSERT(!crawl_state.arena); + if (other && other->atype() == ACT_MONSTER) { const monsters *mon = dynamic_cast<monsters*>(other); @@ -6448,6 +6492,8 @@ void player::god_conduct(conduct_type thing_done, int level) void player::banish(const std::string &who) { + ASSERT(!crawl_state.arena); + banished = true; banished_by = who; } @@ -6782,6 +6828,8 @@ void player::blink(bool allow_partial_control) void player::teleport(bool now, bool abyss_shift) { + ASSERT(!crawl_state.arena); + if (now) you_teleport_now(true, abyss_shift); else @@ -6841,6 +6889,8 @@ void player::confuse(actor *who, int str) void player::paralyse(actor *who, int str) { + ASSERT(!crawl_state.arena); + int ¶lysis(duration[DUR_PARALYSIS]); mprf( "You %s the ability to move!", @@ -6855,6 +6905,8 @@ void player::paralyse(actor *who, int str) void player::petrify(actor *who, int str) { + ASSERT(!crawl_state.arena); + int &petrif(duration[DUR_PETRIFIED]); mprf( "You %s the ability to move!", @@ -6915,6 +6967,8 @@ kill_category player::kill_alignment() const bool player::sicken(int amount) { + ASSERT(!crawl_state.arena); + if (is_undead || amount <= 0) return (false); @@ -6986,6 +7040,8 @@ bool player::can_safely_mutate() const bool player::mutate() { + ASSERT(!crawl_state.arena); + if (!can_mutate()) return (false); @@ -7008,6 +7064,8 @@ bool player::is_icy() const void player::moveto(const coord_def &c) { + ASSERT(!crawl_state.arena); + const bool real_move = (c != pos()); position = c; crawl_view.set_player_at(c); @@ -7045,6 +7103,8 @@ bool player::can_throw_large_rocks() const void player::put_to_sleep(int) { + ASSERT(!crawl_state.arena); + if (duration[DUR_BERSERKER] || asleep()) // No cumulative sleeps. return; @@ -7067,6 +7127,8 @@ void player::put_to_sleep(int) void player::awake() { + ASSERT(!crawl_state.arena); + duration[DUR_SLEEP] = 0; mpr("You wake up."); you.flash_colour = BLACK; diff --git a/crawl-ref/source/spells1.cc b/crawl-ref/source/spells1.cc index 0dc35f0ce0..73b8d407ab 100644 --- a/crawl-ref/source/spells1.cc +++ b/crawl-ref/source/spells1.cc @@ -62,6 +62,8 @@ static bool _abyss_blocks_teleport(bool cblink) // contamination. int blink(int pow, bool high_level_controlled_blink, bool wizard_blink) { + ASSERT(!crawl_state.arena); + dist beam; if (crawl_state.is_repeating_cmd()) @@ -194,6 +196,8 @@ int blink(int pow, bool high_level_controlled_blink, bool wizard_blink) void random_blink(bool allow_partial_control, bool override_abyss) { + ASSERT(!crawl_state.arena); + bool success = false; coord_def target; diff --git a/crawl-ref/source/spl-cast.cc b/crawl-ref/source/spl-cast.cc index 7c2753a7ec..2e57483d43 100644 --- a/crawl-ref/source/spl-cast.cc +++ b/crawl-ref/source/spl-cast.cc @@ -991,6 +991,8 @@ int _setup_evaporate_cast() // Others are currently unused or unimplemented. spret_type your_spells(spell_type spell, int powc, bool allow_fail) { + ASSERT(!crawl_state.arena); + const bool wiz_cast = (crawl_state.prev_cmd == CMD_WIZARD && !allow_fail); dist spd; |