diff options
author | j-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573> | 2009-04-20 18:01:09 +0000 |
---|---|---|
committer | j-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573> | 2009-04-20 18:01:09 +0000 |
commit | d9dd888a10a3087d3ec5cf82364cfd6495abd3e4 (patch) | |
tree | 6acddf0f589891b2925f7653208ba2e29d1478d6 /crawl-ref | |
parent | bb3b8b8286b84de95546d1121d0c305bbdc85851 (diff) | |
download | crawl-ref-d9dd888a10a3087d3ec5cf82364cfd6495abd3e4.tar.gz crawl-ref-d9dd888a10a3087d3ec5cf82364cfd6495abd3e4.zip |
* Fix database search crashing on pandemonium demons/player ghost.
* Make Xom say e.g. "gate" for the repel stair effect if there's only a
gate nearby.
* Weapons of vampiricism have no effect on summoned creatures, as is
already the case for Vampire bites and the Vampiric Draining spell.
* Make berserking monsters immune to fear. (The sanctuary still works.)
* General clean-up.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@9669 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref')
-rw-r--r-- | crawl-ref/docs/changes.stone_soup | 1 | ||||
-rw-r--r-- | crawl-ref/source/cmd-name.h | 1 | ||||
-rw-r--r-- | crawl-ref/source/command.cc | 7 | ||||
-rw-r--r-- | crawl-ref/source/dat/database/godspeak.txt | 2 | ||||
-rw-r--r-- | crawl-ref/source/dat/descript/spells.txt | 1 | ||||
-rw-r--r-- | crawl-ref/source/debug.cc | 461 | ||||
-rw-r--r-- | crawl-ref/source/decks.cc | 38 | ||||
-rw-r--r-- | crawl-ref/source/delay.cc | 10 | ||||
-rw-r--r-- | crawl-ref/source/describe.cc | 33 | ||||
-rw-r--r-- | crawl-ref/source/directn.cc | 42 | ||||
-rw-r--r-- | crawl-ref/source/dungeon.cc | 16 | ||||
-rw-r--r-- | crawl-ref/source/enum.h | 1 | ||||
-rw-r--r-- | crawl-ref/source/fight.cc | 17 | ||||
-rw-r--r-- | crawl-ref/source/files.cc | 17 | ||||
-rw-r--r-- | crawl-ref/source/mon-util.cc | 6 | ||||
-rw-r--r-- | crawl-ref/source/tilereg.cc | 2 | ||||
-rw-r--r-- | crawl-ref/source/xom.cc | 16 |
17 files changed, 361 insertions, 310 deletions
diff --git a/crawl-ref/docs/changes.stone_soup b/crawl-ref/docs/changes.stone_soup index 952f1b78aa..e912d22269 100644 --- a/crawl-ref/docs/changes.stone_soup +++ b/crawl-ref/docs/changes.stone_soup @@ -76,6 +76,7 @@ Monsters * Monsters raised from the dead are now equipped with their original equipment. * Zombies/skeletons no longer drown, but will still avoid water. * Fixed summoned monsters taking non-summoned items with them. +* Summoned monsters are no longer susceptible to Vampiric Draining. * Make abominations resist poison. * Butchered corpses sometimes leave skeletons. * Finally fixed monsters acting before being announced as "coming into view". diff --git a/crawl-ref/source/cmd-name.h b/crawl-ref/source/cmd-name.h index ec1176d372..5f16bd40cf 100644 --- a/crawl-ref/source/cmd-name.h +++ b/crawl-ref/source/cmd-name.h @@ -159,7 +159,6 @@ {CMD_TARGET_DIR_UP, "CMD_TARGET_DIR_UP"}, {CMD_TARGET_DIR_UP_RIGHT, "CMD_TARGET_DIR_UP_RIGHT"}, {CMD_TARGET_DESCRIBE, "CMD_TARGET_DESCRIBE"}, -{CMD_TARGET_ALL_DESCRIBE, "CMD_TARGET_ALL_DESCRIBE"}, {CMD_TARGET_CYCLE_TARGET_MODE, "CMD_TARGET_CYCLE_TARGET_MODE"}, {CMD_TARGET_PREV_TARGET, "CMD_TARGET_PREV_TARGET"}, {CMD_TARGET_MAYBE_PREV_TARGET, "CMD_TARGET_MAYBE_PREV_TARGET"}, diff --git a/crawl-ref/source/command.cc b/crawl-ref/source/command.cc index 36e95113f4..54628dc57a 100644 --- a/crawl-ref/source/command.cc +++ b/crawl-ref/source/command.cc @@ -27,6 +27,7 @@ REVISION("$Rev$"); #include "decks.h" #include "describe.h" #include "files.h" +#include "ghost.h" #include "initfile.h" #include "invent.h" #include "itemname.h" @@ -1335,7 +1336,11 @@ static bool _do_description(std::string key, std::string type, else { monster_type mon_num = get_monster_by_name(key, true); - if (mon_num != MONS_PROGRAM_BUG) + // Don't attempt to get more information on ghosts or + // pandemonium demons as the ghost struct has not been initialized + // which will cause a crash. + if (mon_num != MONS_PROGRAM_BUG && mon_num != MONS_PLAYER_GHOST + && mon_num != MONS_PANDEMONIUM_DEMON) { monsters mon; mon.type = mon_num; diff --git a/crawl-ref/source/dat/database/godspeak.txt b/crawl-ref/source/dat/database/godspeak.txt index ae58571dd0..b046569748 100644 --- a/crawl-ref/source/dat/database/godspeak.txt +++ b/crawl-ref/source/dat/database/godspeak.txt @@ -386,7 +386,7 @@ Xom repel stairs Xom changes the scenery. -Xom pokes at a staircase. +Xom pokes at a nearby @staircase@. "Tag, you're it!" diff --git a/crawl-ref/source/dat/descript/spells.txt b/crawl-ref/source/dat/descript/spells.txt index ab02bab8ef..499ae83021 100644 --- a/crawl-ref/source/dat/descript/spells.txt +++ b/crawl-ref/source/dat/descript/spells.txt @@ -637,6 +637,7 @@ This spell allows its caster to imbue a mass of deceased flesh with a magical li Vampiric Draining This spell steals the life of a living creature and grants it to the caster. Life will not be drained in excess of what the caster can capably absorb. +However, attempting to drain an undead or demonic creature will backfire on the caster. %%%% Venom Bolt diff --git a/crawl-ref/source/debug.cc b/crawl-ref/source/debug.cc index 43fec90503..ea72367ba2 100644 --- a/crawl-ref/source/debug.cc +++ b/crawl-ref/source/debug.cc @@ -173,7 +173,7 @@ static int _debug_prompt_for_monster( void ) { char specs[80]; - mpr( "Which monster by name? ", MSGCH_PROMPT ); + mpr("Which monster by name? ", MSGCH_PROMPT); if (!cancelable_get_line_autohist(specs, sizeof specs)) { if (specs[0] == '\0') @@ -193,7 +193,7 @@ static int _debug_prompt_for_skill( const char *prompt ) { char specs[80]; - mpr( prompt, MSGCH_PROMPT ); + mpr(prompt, MSGCH_PROMPT); get_input_line( specs, sizeof( specs ) ); if (specs[0] == '\0') @@ -201,7 +201,7 @@ static int _debug_prompt_for_skill( const char *prompt ) int skill = -1; - for (int i = 0; i < NUM_SKILLS; i++) + for (int i = 0; i < NUM_SKILLS; ++i) { // Avoid the bad values. if (is_invalid_skill(i)) @@ -233,7 +233,7 @@ void wizard_change_species( void ) char specs[80]; int i; - mpr( "What species would you like to be now? " , MSGCH_PROMPT ); + mpr("What species would you like to be now? " , MSGCH_PROMPT); get_input_line( specs, sizeof( specs ) ); if (specs[0] == '\0') @@ -242,7 +242,7 @@ void wizard_change_species( void ) species_type sp = SP_UNKNOWN; - for (i = SP_HUMAN; i < NUM_SPECIES; i++) + for (i = SP_HUMAN; i < NUM_SPECIES; ++i) { const species_type si = static_cast<species_type>(i); const std::string sp_name = @@ -264,12 +264,12 @@ void wizard_change_species( void ) if (sp == SP_UNKNOWN) { - mpr( "That species isn't available." ); + mpr("That species isn't available."); return; } // Re-scale skill-points. - for (i = 0; i < NUM_SKILLS; i++) + for (i = 0; i < NUM_SKILLS; ++i) { you.skill_points[i] *= species_skills( i, sp ); you.skill_points[i] /= species_skills( i, you.species ); @@ -346,7 +346,7 @@ void wizard_change_species( void ) int levels[] = {4, 9, 14, 19, 27}; int real_level = you.experience_level; - for (i = 0; i < powers; i++) + for (i = 0; i < powers; ++i) { // The types of demonspawn mutations you get depends on your // experience level at the time of gaining it. @@ -377,7 +377,7 @@ static int _debug_prompt_for_int( const char *prompt, bool nonneg ) { char specs[80]; - mpr( prompt, MSGCH_PROMPT ); + mpr(prompt, MSGCH_PROMPT); get_input_line( specs, sizeof( specs ) ); if (specs[0] == '\0') @@ -417,7 +417,7 @@ void wizard_cast_spec_spell_name(void) { char specs[80]; - mpr( "Cast which spell by name? ", MSGCH_PROMPT ); + mpr("Cast which spell by name? ", MSGCH_PROMPT); if (cancelable_get_line_autohist( specs, sizeof( specs ) ) || specs[0] == '\0') { @@ -472,7 +472,7 @@ void wizard_create_spec_monster(void) void wizard_create_spec_monster_name() { char specs[100]; - mpr( "Which monster by name? ", MSGCH_PROMPT ); + mpr("Which monster by name? ", MSGCH_PROMPT); if (cancelable_get_line_autohist(specs, sizeof specs) || !*specs) { canned_msg(MSG_OK); @@ -580,7 +580,7 @@ void wizard_create_spec_monster_name() } ghost.species = static_cast<species_type>(sp_id); - mpr( "Make player ghost which job? ", MSGCH_PROMPT ); + mpr("Make player ghost which job? ", MSGCH_PROMPT); get_input_line( input_str, sizeof( input_str ) ); int class_id = get_class_by_abbrev(input_str); @@ -837,7 +837,7 @@ void debug_list_monsters() int mon_nums[MAX_MONSTERS]; - for (int i = 0; i < MAX_MONSTERS; i++) + for (int i = 0; i < MAX_MONSTERS; ++i) mon_nums[i] = i; std::sort(mon_nums, mon_nums + MAX_MONSTERS, _sort_monster_list); @@ -894,11 +894,15 @@ void debug_list_monsters() mpr_comma_separated_list("Monsters: ", mons); if (total_adj_exp == total_exp) + { mprf("%d monsters, %d total exp value", nfound, total_exp); + } else + { mprf("%d monsters, %d total exp value (%d adjusted)", nfound, total_exp, total_adj_exp); + } } #endif @@ -917,7 +921,7 @@ static void _rune_from_specs(const char* _specs, item_def &item) if (strlen(specs) > 4) { - for (int i = 0; i < NUM_RUNE_TYPES; i++) + for (int i = 0; i < NUM_RUNE_TYPES; ++i) { item.plus = i; @@ -1018,7 +1022,7 @@ static void _deck_from_specs(const char* _specs, item_def &item) if (!type_str.empty()) { - for (int i = 0; types[i] != NUM_MISCELLANY; i++) + for (int i = 0; types[i] != NUM_MISCELLANY; ++i) { item.sub_type = types[i]; item.plus = 1; @@ -1071,7 +1075,7 @@ static void _deck_from_specs(const char* _specs, item_def &item) int rarity_val = -1; - for (int i = 0; rarities[i] != NULL; i++) + for (int i = 0; rarities[i] != NULL; ++i) if (specs.find(rarities[i]) != std::string::npos) { rarity_val = i; @@ -1143,7 +1147,7 @@ static bool _book_from_spell(const char* specs, item_def &item) if (type == SPELL_NO_SPELL) return (false); - for (int i = 0; i < NUM_FIXED_BOOKS; i++) + for (int i = 0; i < NUM_FIXED_BOOKS; ++i) for (int j = 0; j < 8; j++) if (which_spell_in_book(i, j) == type) { @@ -1222,7 +1226,7 @@ void wizard_create_spec_object() thing_created = get_item_slot(); if (thing_created == NON_ITEM) { - mpr( "Could not allocate item." ); + mpr("Could not allocate item."); return; } @@ -1252,7 +1256,7 @@ void wizard_create_spec_object() if (mon == -1 || mon == MONS_PROGRAM_BUG) { - mpr( "No such monster." ); + mpr("No such monster."); return; } @@ -1286,7 +1290,7 @@ void wizard_create_spec_object() } else { - mpr( "What type of item? ", MSGCH_PROMPT ); + mpr("What type of item? ", MSGCH_PROMPT); get_input_line( specs, sizeof( specs ) ); std::string temp = specs; @@ -1302,7 +1306,7 @@ void wizard_create_spec_object() if (!get_item_by_name(&mitm[thing_created], specs, class_wanted, true)) { - mpr( "No such item." ); + mpr("No such item."); // Clean up item destroy_item(thing_created); @@ -1355,7 +1359,6 @@ bool get_item_by_name(item_def *item, char* specs, char obj_name[ ITEMNAME_SIZE ]; char* ptr; - int i; int best_index; int type_wanted = -1; int special_wanted = 0; @@ -1390,7 +1393,7 @@ bool get_item_by_name(item_def *item, char* specs, type_wanted = -1; best_index = 10000; - for (i = 0; i < max_subtype[ item->base_type ]; i++) + for (int i = 0; i < max_subtype[ item->base_type ]; ++i) { item->sub_type = i; strcpy(obj_name, item->name(DESC_PLAIN).c_str()); @@ -1512,7 +1515,7 @@ bool get_item_by_name(item_def *item, char* specs, case OBJ_ARMOUR: { char buf[80]; - mpr( "What ego type? ", MSGCH_PROMPT ); + mpr("What ego type? ", MSGCH_PROMPT); get_input_line( buf, sizeof( buf ) ); if (buf[0] != '\0') @@ -1520,7 +1523,7 @@ bool get_item_by_name(item_def *item, char* specs, special_wanted = 0; best_index = 10000; - for (i = 1; i < 25; i++) + for (int i = SPWPN_NORMAL + 1; i < SPWPN_DEBUG_RANDART; ++i) { item->special = i; strcpy(obj_name, item->name(DESC_PLAIN).c_str()); @@ -1729,7 +1732,7 @@ static void _tweak_randart(item_def &item) std::string prompt = ""; - for (int i = 0; i < RAP_NUM_PROPERTIES; i++) + for (int i = 0; i < RAP_NUM_PROPERTIES; ++i) { if (i % 8 == 0 && i != 0) prompt += "\n"; @@ -1751,7 +1754,7 @@ static void _tweak_randart(item_def &item) } formatted_message_history(prompt, MSGCH_PROMPT, 0, 80); - mpr( "Change which field? ", MSGCH_PROMPT ); + mpr("Change which field? ", MSGCH_PROMPT); char keyin = tolower( get_ch() ); int choice; @@ -1819,20 +1822,20 @@ void wizard_tweak_object(void) while (true) { - mpr( you.inv[item].name(DESC_INVENTORY_EQUIP).c_str() ); + mpr(you.inv[item].name(DESC_INVENTORY_EQUIP).c_str()); if (is_art) { - mpr( "a - plus b - plus2 c - art props d - quantity " - "e - flags ESC - exit", MSGCH_PROMPT ); + mpr("a - plus b - plus2 c - art props d - quantity " + "e - flags ESC - exit", MSGCH_PROMPT); } else { - mpr( "a - plus b - plus2 c - special d - quantity " - "e - flags ESC - exit", MSGCH_PROMPT ); + mpr("a - plus b - plus2 c - special d - quantity " + "e - flags ESC - exit", MSGCH_PROMPT); } - mpr( "Which field? ", MSGCH_PROMPT ); + mpr("Which field? ", MSGCH_PROMPT); keyin = tolower( get_ch() ); @@ -1874,7 +1877,7 @@ void wizard_tweak_object(void) mprf("Old value: %ld (0x%08lx)", *ptr, *ptr ); } - mpr( "New value? ", MSGCH_PROMPT ); + mpr("New value? ", MSGCH_PROMPT); get_input_line( specs, sizeof( specs ) ); if (specs[0] == '\0') @@ -1940,7 +1943,7 @@ void wizard_value_randart() void wizard_create_all_artefacts() { // Create all unrandarts. Start at 1; the unrandart at 0 is a dummy. - for (int i = 1; i < NO_UNRANDARTS; i++) + for (int i = 1; i < NO_UNRANDARTS; ++i) { int islot = get_item_slot(); if (islot == NON_ITEM) @@ -1957,7 +1960,7 @@ void wizard_create_all_artefacts() } // Create all fixed artefacts. - for (int i = SPWPN_START_FIXEDARTS; i < SPWPN_START_NOGEN_FIXEDARTS; i++) + for (int i = SPWPN_START_FIXEDARTS; i < SPWPN_START_NOGEN_FIXEDARTS; ++i) { int islot = get_item_slot(); if (islot == NON_ITEM) @@ -2132,8 +2135,8 @@ void wizard_heal(bool super_heal) void wizard_set_hunger_state() { - mpr( "Set hunger state to s(T)arving, (N)ear starving, " - "(H)ungry, (S)atiated, (F)ull or (E)ngorged?", MSGCH_PROMPT ); + mpr("Set hunger state to s(T)arving, (N)ear starving, " + "(H)ungry, (S)atiated, (F)ull or (E)ngorged?", MSGCH_PROMPT); const int c = tolower(getch()); // Values taken from food.cc. @@ -2179,7 +2182,7 @@ void wizard_spawn_control() { // 50 spots are reserved for non-wandering monsters. int max_spawn = MAX_MONSTERS - 50; - for (int i = 0; i < MAX_MONSTERS; i++) + for (int i = 0; i < MAX_MONSTERS; ++i) if (menv[i].alive()) max_spawn--; @@ -2203,7 +2206,7 @@ void wizard_spawn_control() // the rate at 5 or less. env.spawn_random_rate = 5; - for (int i = 0; i < num; i++) + for (int i = 0; i < num; ++i) spawn_random_monsters(); env.spawn_random_rate = curr_rate; @@ -2249,8 +2252,8 @@ void wizard_create_portal() void wizard_identify_pack() { - mpr( "You feel a rush of knowledge." ); - for (int i = 0; i < ENDOFPACK; i++) + mpr("You feel a rush of knowledge."); + for (int i = 0; i < ENDOFPACK; ++i) { item_def& item = you.inv[i]; if (is_valid_item(item)) @@ -2265,8 +2268,8 @@ void wizard_identify_pack() void wizard_unidentify_pack() { - mpr( "You feel a rush of antiknowledge." ); - for (int i = 0; i < ENDOFPACK; i++) + mpr("You feel a rush of antiknowledge."); + for (int i = 0; i < ENDOFPACK; ++i) { item_def& item = you.inv[i]; if (is_valid_item(item)) @@ -2281,13 +2284,13 @@ void wizard_unidentify_pack() // Forget things that nearby monsters are carrying, as well. // (For use with the "give monster an item" wizard targetting // command.) - for (int i = 0; i < MAX_MONSTERS; i++) + for (int i = 0; i < MAX_MONSTERS; ++i) { monsters* mon = &menv[i]; if (mon->alive() && mons_near(mon)) { - for (int j = 0; j < NUM_MONSTER_SLOTS; j++) + for (int j = 0; j < NUM_MONSTER_SLOTS; ++j) { if (mon->inv[j] == NON_ITEM) continue; @@ -2378,7 +2381,7 @@ void wizard_create_feature_name() void wizard_list_branches() { - for (int i = 0; i < NUM_BRANCHES; i++) + for (int i = 0; i < NUM_BRANCHES; ++i) { if (branches[i].startdepth != - 1) { @@ -2422,8 +2425,8 @@ void wizard_gain_piety() else if (you.religion == GOD_XOM) { you.piety = random2(MAX_PIETY+1); // reroll mood - if (one_chance_in(10)) - you.gift_timeout = 0; + if (one_chance_in(5)) + you.gift_timeout = 0; // 20% chance to make Xom bored. else you.gift_timeout = random2(40) + random2(40); // reroll interest @@ -2468,7 +2471,7 @@ void wizard_list_items() { bool has_shops = false; - for (int i = 0; i < MAX_SHOPS; i++) + for (int i = 0; i < MAX_SHOPS; ++i) if (env.shop[i].type != SHOP_UNASSIGNED) { has_shops = true; @@ -2479,16 +2482,18 @@ void wizard_list_items() { mpr("Shop items:"); - for (int i = 0; i < MAX_SHOPS; i++) + for (int i = 0; i < MAX_SHOPS; ++i) if (env.shop[i].type != SHOP_UNASSIGNED) + { for (stack_iterator si(coord_def(0, i+5)); si; ++si) mpr(si->name(DESC_PLAIN, false, false, false).c_str()); + } mpr(EOL); } mpr("Item stacks (by location and top item):"); - for (int i = 0; i < MAX_ITEMS; i++) + for (int i = 0; i < MAX_ITEMS; ++i) { item_def &item(mitm[i]); if (!is_valid_item(item) || item.held_by_monster()) @@ -2502,16 +2507,15 @@ void wizard_list_items() mpr(EOL); mpr("Floor items (stacks only show top item):"); - for (int i = 1; i < GXM; i++) - for (int j = 1; j < GYM; j++) + for (rectangle_iterator ri(1); ri; ++ri) + { + int item = igrd(*ri); + if (item != NON_ITEM) { - int item = igrd[i][j]; - if (item != NON_ITEM) - { - mprf("%3d at (%2d,%2d): %s", item, i, j, - mitm[item].name(DESC_PLAIN, false, false, false).c_str()); - } + mprf("%3d at (%2d,%2d): %s", item, ri->x, ri->y, + mitm[item].name(DESC_PLAIN, false, false, false).c_str()); } + } } #endif @@ -2528,7 +2532,7 @@ void debug_stethoscope(int mon) i = mon; else { - mpr( "Which monster?", MSGCH_PROMPT ); + mpr("Which monster?", MSGCH_PROMPT); direction( stth ); @@ -2629,9 +2633,8 @@ void debug_stethoscope(int mon) { ASSERT(mons.ghost.get()); const ghost_demon &ghost = *mons.ghost; - mprf( MSGCH_DIAGNOSTICS, - "Ghost damage: %d; brand: %d", - ghost.damage, ghost.brand ); + mprf(MSGCH_DIAGNOSTICS, "Ghost damage: %d; brand: %d", + ghost.damage, ghost.brand ); } } #endif @@ -2639,7 +2642,7 @@ void debug_stethoscope(int mon) #if DEBUG_ITEM_SCAN static void _dump_item( const char *name, int num, const item_def &item ) { - mpr( name, MSGCH_ERROR ); + mpr(name, MSGCH_ERROR); mprf(" item #%d: base: %d; sub: %d; plus: %d; plus2: %d; special: %ld", num, item.base_type, item.sub_type, @@ -2668,62 +2671,64 @@ void debug_item_scan( void ) visited.init(false); // First we're going to check all the stacks on the level: - for (int x = 0; x < GXM; x++) + for (rectangle_iterator ri(0); ri; ++ri) { - for (int y = 0; y < GYM; y++) - { - // Unlinked temporary items. - if (x == 0 && y == 0) - continue; + // Unlinked temporary items. + if (*ri == coord_def()) + continue; - // Looking for infinite stacks (ie more links than items allowed) - // and for items which have bad coordinates (can't find their stack) - for (int obj = igrd[x][y]; obj != NON_ITEM; obj = mitm[obj].link) + // Looking for infinite stacks (ie more links than items allowed) + // and for items which have bad coordinates (can't find their stack) + for (int obj = igrd(*ri); obj != NON_ITEM; obj = mitm[obj].link) + { + if (obj < 0 || obj > MAX_ITEMS) { - if (obj < 0 || obj > MAX_ITEMS) + if (igrd(*ri) == obj) { - if (igrd[x][y] == obj) - mprf(MSGCH_ERROR, "Igrd has invalid item index %d " - "at (%d, %d)", - obj, x, y); - else - mprf(MSGCH_ERROR, "Item in stack at (%d, %d) has ", - "invalid link %d", - x, y, obj); - break; + mprf(MSGCH_ERROR, "Igrd has invalid item index %d " + "at (%d, %d)", + obj, ri->x, ri->y); } - - // Check for invalid (zero quantity) items that are linked in. - if (!is_valid_item( mitm[obj] )) + else { - mprf(MSGCH_ERROR, "Linked invalid item at (%d,%d)!", x, y); - _dump_item( mitm[obj].name(DESC_PLAIN).c_str(), - obj, mitm[obj] ); + mprf(MSGCH_ERROR, "Item in stack at (%d, %d) has ", + "invalid link %d", + ri->x, ri->y, obj); } + break; + } - // Check that item knows what stack it's in - if (mitm[obj].pos.x != x || mitm[obj].pos.y != y) - { - mprf(MSGCH_ERROR,"Item position incorrect at (%d,%d)!",x,y); - _dump_item( mitm[obj].name(DESC_PLAIN).c_str(), - obj, mitm[obj] ); - } + // Check for invalid (zero quantity) items that are linked in. + if (!is_valid_item( mitm[obj] )) + { + mprf(MSGCH_ERROR, "Linked invalid item at (%d,%d)!", + ri->x, ri->y); + _dump_item( mitm[obj].name(DESC_PLAIN).c_str(), obj, mitm[obj] ); + } - // If we run into a premarked item we're in real trouble, - // this will also keep this from being an infinite loop. - if (visited[obj]) - { - mprf(MSGCH_ERROR, - "Potential INFINITE STACK at (%d, %d)", x, y); - break; - } - visited[obj] = true; + // Check that item knows what stack it's in + if (mitm[obj].pos != *ri) + { + mprf(MSGCH_ERROR,"Item position incorrect at (%d,%d)!", + ri->x, ri->y); + _dump_item( mitm[obj].name(DESC_PLAIN).c_str(), + obj, mitm[obj] ); } + + // If we run into a premarked item we're in real trouble, + // this will also keep this from being an infinite loop. + if (visited[obj]) + { + mprf(MSGCH_ERROR, + "Potential INFINITE STACK at (%d, %d)", ri->x, ri->y); + break; + } + visited[obj] = true; } } // Now scan all the items on the level: - for (i = 0; i < MAX_ITEMS; i++) + for (i = 0; i < MAX_ITEMS; ++i) { if (!is_valid_item( mitm[i] )) continue; @@ -2736,35 +2741,39 @@ void debug_item_scan( void ) // (except to make sure that the monster is alive). if (mitm[i].pos.origin()) { - mpr( "Unlinked temporary item:", MSGCH_ERROR ); + mpr("Unlinked temporary item:", MSGCH_ERROR); _dump_item( name, i, mitm[i] ); } else if (mon != NULL && mon->type == -1) { - mpr( "Unlinked item held by dead monster:", MSGCH_ERROR ); + mpr("Unlinked item held by dead monster:", MSGCH_ERROR); _dump_item( name, i, mitm[i] ); } else if ((mitm[i].pos.x > 0 || mitm[i].pos.y > 0) && !visited[i]) { - mpr( "Unlinked item:", MSGCH_ERROR ); + mpr("Unlinked item:", MSGCH_ERROR); _dump_item( name, i, mitm[i] ); if (!in_bounds(mitm[i].pos)) + { mprf(MSGCH_ERROR, "Item position (%d, %d) is out of bounds", mitm[i].pos.x, mitm[i].pos.y); + } else + { mprf("igrd(%d,%d) = %d", mitm[i].pos.x, mitm[i].pos.y, igrd( mitm[i].pos )); + } // Let's check to see if it's an errant monster object: - for (int j = 0; j < MAX_MONSTERS; j++) - for (int k = 0; k < NUM_MONSTER_SLOTS; k++) + for (int j = 0; j < MAX_MONSTERS; ++j) + for (int k = 0; k < NUM_MONSTER_SLOTS; ++k) { if (menv[j].inv[k] == i) { mprf("Held by monster #%d: %s at (%d,%d)", j, menv[j].name(DESC_CAP_A, true).c_str(), - menv[j].pos().x, menv[j].pos().y ); + menv[j].pos().x, menv[j].pos().y); } } } @@ -2786,7 +2795,7 @@ void debug_item_scan( void ) || strstr( name, "bola" ) != NULL || strstr( name, "bugg" ) != NULL) { - mpr( "Bad item:", MSGCH_ERROR ); + mpr("Bad item:", MSGCH_ERROR); _dump_item( name, i, mitm[i] ); } else if ((mitm[i].base_type == OBJ_WEAPONS @@ -2806,19 +2815,19 @@ void debug_item_scan( void ) || !is_random_artefact( mitm[i] ) && mitm[i].special >= 30))) { - mpr( "Bad plus or special value:", MSGCH_ERROR ); + mpr("Bad plus or special value:", MSGCH_ERROR); _dump_item( name, i, mitm[i] ); } else if (mitm[i].flags & ISFLAG_SUMMONED && in_bounds(mitm[i].pos)) { - mpr( "Summoned item on floor:", MSGCH_ERROR ); + mpr("Summoned item on floor:", MSGCH_ERROR); _dump_item( name, i, mitm[i] ); } } // Quickly scan monsters for "program bug"s. - for (i = 0; i < MAX_MONSTERS; i++) + for (i = 0; i < MAX_MONSTERS; ++i) { const monsters& monster = menv[i]; @@ -2828,10 +2837,10 @@ void debug_item_scan( void ) if (monster.name(DESC_PLAIN, true).find("questionable") != std::string::npos) { - mprf( MSGCH_ERROR, "Program bug detected!" ); - mprf( MSGCH_ERROR, - "Buggy monster detected: monster #%d; position (%d,%d)", - i, monster.pos().x, monster.pos().y ); + mprf(MSGCH_ERROR, "Program bug detected!"); + mprf(MSGCH_ERROR, + "Buggy monster detected: monster #%d; position (%d,%d)", + i, monster.pos().x, monster.pos().y); } } } @@ -2862,14 +2871,14 @@ static std::vector<std::string> _in_vaults(const coord_def &pos) { std::vector<std::string> out; - for (unsigned int i = 0; i < Level_Vaults.size(); i++) + for (unsigned int i = 0; i < Level_Vaults.size(); ++i) { const vault_placement &vault = Level_Vaults[i]; if (_inside_vault(vault, pos)) out.push_back(vault.map.name); } - for (unsigned int i = 0; i < Temp_Vaults.size(); i++) + for (unsigned int i = 0; i < Temp_Vaults.size(); ++i) { const vault_placement &vault = Temp_Vaults[i]; if (_inside_vault(vault, pos)) @@ -2982,7 +2991,7 @@ void debug_mons_scan() } } // if (mgrd(m->pos()) != i) - for (int j = 0; j < NUM_MONSTER_SLOTS; j++) + for (int j = 0; j < NUM_MONSTER_SLOTS; ++j) { const int idx = m->inv[j]; if (idx == NON_ITEM) @@ -3038,7 +3047,7 @@ void debug_mons_scan() holder->pos().x, holder->pos().y, holder->mindex()); bool found = false; - for (int k = 0; k < NUM_MONSTER_SLOTS; k++) + for (int k = 0; k < NUM_MONSTER_SLOTS; ++k) { if (holder->inv[k] == idx) { @@ -3078,7 +3087,7 @@ void debug_mons_scan() mpr(""); - for (unsigned int i = 0; i < floating_mons.size(); i++) + for (unsigned int i = 0; i < floating_mons.size(); ++i) { const int idx = floating_mons[i]; const monsters* mon = &menv[idx]; @@ -3100,7 +3109,7 @@ void debug_mons_scan() mpr(""); - for (unsigned int i = 0; i < bogus_pos.size(); i++) + for (unsigned int i = 0; i < bogus_pos.size(); ++i) { const coord_def pos = bogus_pos[i]; const int idx = bogus_idx[i]; @@ -3167,8 +3176,8 @@ static void _debug_acquirement_stats(FILE *ostat) mitm[p].base_type = OBJ_UNASSIGNED; mesclr(); - mpr( "[a] Weapons [b] Armours [c] Jewellery [d] Books" ); - mpr( "[e] Staves [f] Food [g] Miscellaneous" ); + mpr("[a] Weapons [b] Armours [c] Jewellery [d] Books"); + mpr("[e] Staves [f] Food [g] Miscellaneous"); mpr("What kind of item would you like to get acquirement stats on? ", MSGCH_PROMPT); @@ -3209,7 +3218,7 @@ static void _debug_acquirement_stats(FILE *ostat) memset(subtype_quants, 0, sizeof(subtype_quants)); memset(ego_quants, 0, sizeof(ego_quants)); - for (int i = 0; i < num_itrs; i++) + for (int i = 0; i < num_itrs; ++i) { if (kbhit()) { @@ -3286,7 +3295,7 @@ static void _debug_acquirement_stats(FILE *ostat) "dragon slaying", "venom", "protection", - "draning", + "draining", "speed", "vorpal", "flame", @@ -3300,12 +3309,13 @@ static void _debug_acquirement_stats(FILE *ostat) "confusion", }; - for (int i = 0; i <= SPWPN_CONFUSE; i++) - { - if (ego_quants[i] > 0) - fprintf(ostat, "%14s: %5.2f\n", names[i], - 100.0 * (float) ego_quants[i] / (float) acq_calls); - } + for (int i = 0; i <= SPWPN_CONFUSE; ++i) + if (ego_quants[i] > 0) + { + fprintf(ostat, "%14s: %5.2f\n", names[i], + 100.0 * (float) ego_quants[i] / (float) acq_calls); + } + fprintf(ostat, "\n\n"); } else if (type == OBJ_ARMOUR) @@ -3340,7 +3350,7 @@ static void _debug_acquirement_stats(FILE *ostat) }; const int non_art = acq_calls - num_arts; - for (int i = 0; i <= SPARM_REFLECTION; i++) + for (int i = 0; i <= SPARM_REFLECTION; ++i) { if (ego_quants[i] > 0) fprintf(ostat, "%17s: %5.2f\n", names[i], @@ -3354,7 +3364,7 @@ static void _debug_acquirement_stats(FILE *ostat) item.base_type = type; int max_width = 0; - for (int i = 0; i < 256; i++) + for (int i = 0; i < 256; ++i) { if (subtype_quants[i] == 0) continue; @@ -3369,7 +3379,7 @@ static void _debug_acquirement_stats(FILE *ostat) char format_str[80]; sprintf(format_str, "%%%ds: %%6.2f\n", max_width); - for (int i = 0; i < 256; i++) + for (int i = 0; i < 256; ++i) { if (subtype_quants[i] == 0) continue; @@ -3449,7 +3459,7 @@ static void _debug_rap_stats(FILE *ostat) int all_props[RAP_NUM_PROPERTIES]; int good_props[RAP_NUM_PROPERTIES]; int bad_props[RAP_NUM_PROPERTIES]; - for (i = 0; i < RAP_NUM_PROPERTIES; i++) + for (i = 0; i < RAP_NUM_PROPERTIES; ++i) { all_props[i] = 0; good_props[i] = 0; @@ -3465,7 +3475,7 @@ static void _debug_rap_stats(FILE *ostat) randart_properties_t proprt; - for (i = 0; i < RANDART_SEED_MASK; i++) + for (i = 0; i < RANDART_SEED_MASK; ++i) { if (kbhit()) { @@ -3489,7 +3499,7 @@ static void _debug_rap_stats(FILE *ostat) proprt[RAP_CURSED] = 0; int num_props = 0, num_good_props = 0, num_bad_props = 0; - for (int j = 0; j < RAP_NUM_PROPERTIES; j++) + for (int j = 0; j < RAP_NUM_PROPERTIES; ++j) { const int val = proprt[j]; if (val) @@ -3591,7 +3601,7 @@ static void _debug_rap_stats(FILE *ostat) fprintf(ostat, " All Good Bad\n"); fprintf(ostat, " --------------------\n"); - for (i = 0; i < RAP_NUM_PROPERTIES; i++) + for (i = 0; i < RAP_NUM_PROPERTIES; ++i) { if (all_props[i] == 0) continue; @@ -3615,7 +3625,7 @@ void debug_item_statistics( void ) return; } - mpr( "Generate stats for: [a] acquirement [b] randart properties"); + mpr("Generate stats for: [a] acquirement [b] randart properties"); const int keyin = tolower( get_ch() ); switch ( keyin ) @@ -3660,7 +3670,7 @@ void wizard_set_skill_level(void) mpr("That skill doesn't seem to exist."); else { - mpr( skill_name(skill) ); + mpr(skill_name(skill)); int amount = _debug_prompt_for_int( "To what level? ", true ); if (amount < 0) @@ -3734,7 +3744,7 @@ void wizard_set_all_skills(void) if (amount > 27) amount = 27; - for (i = SK_FIGHTING; i < NUM_SKILLS; i++) + for (i = SK_FIGHTING; i < NUM_SKILLS; ++i) { if (is_invalid_skill(i)) continue; @@ -3894,19 +3904,15 @@ bool wizard_add_mutation() } else if (levels > 0) { - for (int i = 0; i < levels; i++) - { + for (int i = 0; i < levels; ++i) if (mutate(mutat, true, force, god_gift)) success = true; - } } else { - for (int i = 0; i < -levels; i++) - { + for (int i = 0; i < -levels; ++i) if (delete_mutation(mutat, true, force)) success = true; - } } } @@ -3919,7 +3925,7 @@ void wizard_get_religion(void) { char specs[80]; - mpr( "Which god (by name)? ", MSGCH_PROMPT ); + mpr("Which god (by name)? ", MSGCH_PROMPT); get_input_line( specs, sizeof( specs ) ); if (specs[0] == '\0') @@ -3929,10 +3935,10 @@ void wizard_get_religion(void) god_type god = GOD_NO_GOD; - for (int i = 1; i < NUM_GODS; i++) + for (int i = 1; i < NUM_GODS; ++i) { const god_type gi = static_cast<god_type>(i); - if ( lowercase_string(god_name(gi)).find(specs) != std::string::npos) + if (lowercase_string(god_name(gi)).find(specs) != std::string::npos) { god = gi; break; @@ -3940,7 +3946,7 @@ void wizard_get_religion(void) } if (god == GOD_NO_GOD) - mpr( "That god doesn't seem to be taking followers today." ); + mpr("That god doesn't seem to be taking followers today."); else { dungeon_feature_type feat = @@ -4738,7 +4744,7 @@ void wizard_edit_durations( void ) std::vector<int> durs; size_t max_len = 0; - for (int i = 0; i < NUM_DURATIONS; i++) + for (int i = 0; i < NUM_DURATIONS; ++i) { if (!you.duration[i]) continue; @@ -4749,7 +4755,7 @@ void wizard_edit_durations( void ) if (durs.size() > 0) { - for (unsigned int i = 0; i < durs.size(); i++) + for (unsigned int i = 0; i < durs.size(); ++i) { int dur = durs[i]; mprf(MSGCH_PROMPT, "%c) %-*s : %d", 'a' + i, max_len, @@ -4801,7 +4807,7 @@ void wizard_edit_durations( void ) std::vector<std::string> match_names; max_len = 0; - for (int i = 0; i < NUM_DURATIONS; i++) + for (int i = 0; i < NUM_DURATIONS; ++i) { if (strcmp(dur_names[i], buf) == 0) { @@ -5004,7 +5010,7 @@ void debug_place_map() // artefact or unrand artefact. static void _vanish_orig_eq(monsters* mons) { - for (int i = 0; i < NUM_MONSTER_SLOTS; i++) + for (int i = 0; i < NUM_MONSTER_SLOTS; ++i) { if (mons->inv[i] == NON_ITEM) continue; @@ -5199,7 +5205,7 @@ void debug_make_monster_shout(monsters* mon) else if (silenced(mon->pos())) mpr("The monster is silenced and likely won't give any shouts."); - for (int i = 0; i < num_times; i++) + for (int i = 0; i < num_times; ++i) force_monster_shout(mon); } else @@ -5220,7 +5226,7 @@ void debug_make_monster_shout(monsters* mon) "won't hear anything."); } - for (int i = 0; i< num_times; i++) + for (int i = 0; i< num_times; ++i) mons_speaks(mon); } @@ -5274,7 +5280,7 @@ void wizard_give_monster_item(monsters *mon) if (player_slot == PROMPT_ABORT) return; - for (int i = 0; i < NUM_EQUIP; i++) + for (int i = 0; i < NUM_EQUIP; ++i) if (you.equip[i] == player_slot) { mpr("Can't give equipped items to a monster."); @@ -5611,7 +5617,7 @@ void wizard_make_monster_summoned(monsters* mon) { char specs[80]; - mpr( "Cast which spell by name? ", MSGCH_PROMPT ); + mpr("Cast which spell by name? ", MSGCH_PROMPT); get_input_line( specs, sizeof( specs ) ); if (specs[0] == '\0') @@ -5712,7 +5718,7 @@ void debug_pathfind(int mid) std::vector<coord_def> path = mp.backtrack(); std::string path_str; mpr("Here's the shortest path: "); - for (unsigned int i = 0; i < path.size(); i++) + for (unsigned int i = 0; i < path.size(); ++i) { snprintf(info, INFO_SIZE, "(%d, %d) ", path[i].x, path[i].y); path_str += info; @@ -5725,7 +5731,7 @@ void debug_pathfind(int mid) path_str = ""; mpr(EOL); mpr("And here are the needed waypoints: "); - for (unsigned int i = 0; i < path.size(); i++) + for (unsigned int i = 0; i < path.size(); ++i) { snprintf(info, INFO_SIZE, "(%d, %d) ", path[i].x, path[i].y); path_str += info; @@ -5775,7 +5781,7 @@ void debug_miscast( int target_index ) } char specs[100]; - mpr( "Miscast which school or spell, by name? ", MSGCH_PROMPT ); + mpr("Miscast which school or spell, by name? ", MSGCH_PROMPT); if (cancelable_get_line_autohist(specs, sizeof specs) || !*specs) { canned_msg(MSG_OK); @@ -5830,11 +5836,12 @@ void debug_miscast( int target_index ) mprf("Miscasting school %s.", spelltype_long_name(school)); if (spell != SPELL_NO_SPELL) - mpr( "Enter spell_power,spell_failure: ", - MSGCH_PROMPT ); + mpr("Enter spell_power,spell_failure: ", MSGCH_PROMPT ); else - mpr( "Enter miscast_level or spell_power,spell_failure: ", - MSGCH_PROMPT ); + { + mpr("Enter miscast_level or spell_power,spell_failure: ", + MSGCH_PROMPT); + } if (cancelable_get_line_autohist(specs, sizeof specs) || !*specs) { @@ -5971,7 +5978,7 @@ static void _dump_levgen() { const CrawlVector &vec = props[LEVEL_EXTRAS_KEY].get_vector(); - for (unsigned int i = 0; i < vec.size(); i++) + for (unsigned int i = 0; i < vec.size(); ++i) extra += vec[i].get_string() + ", "; } @@ -5985,7 +5992,7 @@ static void _dump_levgen() const CrawlHashTable &vaults = props[LEVEL_VAULTS_KEY].get_table(); CrawlHashTable::const_iterator i = vaults.begin(); - for (; i != vaults.end(); i++) + for (; i != vaults.end(); ++i) mprf(" %s: %s", i->first.c_str(), i->second.get_string().c_str()); } @@ -5999,9 +6006,11 @@ static void _dump_levgen() const CrawlHashTable &vaults = props[TEMP_VAULTS_KEY].get_table(); CrawlHashTable::const_iterator i = vaults.begin(); - for (; i != vaults.end(); i++) + for (; i != vaults.end(); ++i) + { mprf(" %s: %s", i->first.c_str(), i->second.get_string().c_str()); + } } mpr(""); } @@ -6057,7 +6066,7 @@ static void _dump_player(FILE *file) fprintf(file, "{{{{{{{{{{{" EOL); bool name_overrun = true; - for (int i = 0; i < kNameLen; i++) + for (int i = 0; i < kNameLen; ++i) { if (you.your_name[i] == '\0') { @@ -6073,7 +6082,7 @@ static void _dump_player(FILE *file) } name_overrun = true; - for (int i = 0; i < 30; i++) + for (int i = 0; i < 30; ++i) { if (you.class_name[i] == '\0') { @@ -6129,7 +6138,7 @@ static void _dump_player(FILE *file) { fprintf(file, "Delayed (%lu):" EOL, (unsigned long) you.delay_queue.size()); - for (unsigned int i = 0; i < you.delay_queue.size(); i++) + for (unsigned int i = 0; i < you.delay_queue.size(); ++i) { const delay_queue_item &item = you.delay_queue[i]; @@ -6149,7 +6158,7 @@ static void _dump_player(FILE *file) } fprintf(file, "Spell bugs:" EOL); - for (size_t i = 0; i < you.spells.size(); i++) + for (size_t i = 0; i < you.spells.size(); ++i) { const spell_type spell = you.spells[i]; @@ -6178,39 +6187,35 @@ static void _dump_player(FILE *file) fprintf(file, EOL); fprintf(file, "Durations:" EOL); - for (int i = 0; i < NUM_DURATIONS; i++) - { + for (int i = 0; i < NUM_DURATIONS; ++i) if (you.duration[i] != 0) fprintf(file, " #%d: %d" EOL, i, you.duration[i]); - } + fprintf(file, EOL); fprintf(file, "Attributes:" EOL); - for (int i = 0; i < NUM_ATTRIBUTES; i++) - { + for (int i = 0; i < NUM_ATTRIBUTES; ++i) if (you.attribute[i] != 0) fprintf(file, " #%d: %lu" EOL, i, you.attribute[i]); - } + fprintf(file, EOL); fprintf(file, "Mutations:" EOL); - for (int i = 0; i < NUM_MUTATIONS; i++) - { + for (int i = 0; i < NUM_MUTATIONS; ++i) if (you.mutation[i] > 0) fprintf(file, " #%d: %d" EOL, i, you.mutation[i]); - } + fprintf(file, EOL); fprintf(file, "Demon mutations:" EOL); - for (int i = 0; i < NUM_MUTATIONS; i++) - { + for (int i = 0; i < NUM_MUTATIONS; ++i) if (you.demon_pow[i] > 0) fprintf(file, " #%d: %d" EOL, i, you.demon_pow[i]); - } + fprintf(file, EOL); fprintf(file, "Inventory bugs:" EOL); - for (int i = 0; i < ENDOFPACK; i++) + for (int i = 0; i < ENDOFPACK; ++i) { item_def &item(you.inv[i]); @@ -6238,21 +6243,27 @@ static void _dump_player(FILE *file) const std::string name = item.name(DESC_PLAIN, false, true); if (item.link != i) + { fprintf(file, " slot #%d: item '%s' has invalid link %d" EOL, i, name.c_str(), item.link); + } if (item.slot < 0 || item.slot > 127) + { fprintf(file, " slot #%d: item '%s' has invalid slot %d" EOL, i, name.c_str(), item.slot); + } if (!item.pos.equals(-1, -1)) + { fprintf(file, " slot #%d: item '%s' has invalid pos %s" EOL, i, name.c_str(), debug_coord_str(item.pos).c_str()); + } } fprintf(file, EOL); fprintf(file, "Equipment:" EOL); - for (int i = 0; i < NUM_EQUIP; i++) + for (int i = 0; i < NUM_EQUIP; ++i) { char eq = you.equip[i]; @@ -6293,7 +6304,7 @@ static void _debug_marker_scan() { std::vector<map_marker*> markers = env.markers.get_all(); - for (unsigned int i = 0; i < markers.size(); i++) + for (unsigned int i = 0; i < markers.size(); ++i) { map_marker* marker = markers[i]; @@ -6320,7 +6331,7 @@ static void _debug_marker_scan() std::vector<map_marker*> at_pos = env.markers.get_markers_at(marker->pos); - for (unsigned int j = 0; j < at_pos.size(); j++) + for (unsigned int j = 0; j < at_pos.size(); ++j) { map_marker* tmp = at_pos[j]; @@ -6338,43 +6349,42 @@ static void _debug_marker_scan() i, (int) type, marker->pos.x, marker->pos.y); } - for (int x = MAPGEN_BORDER; x < (GXM - MAPGEN_BORDER - 1); x++) - for (int y = MAPGEN_BORDER; y < (GYM - MAPGEN_BORDER - 1); y++) - { - coord_def pos(x, y); + for (rectangle_iterator ri(MAPGEN_BORDER); ri; ++ri) + { + std::vector<map_marker*> at_pos = env.markers.get_markers_at(*ri); - std::vector<map_marker*> at_pos - = env.markers.get_markers_at(pos); + for (unsigned int i = 0; i < at_pos.size(); ++i) + { + map_marker *marker = at_pos[i]; - for (unsigned int i = 0; i < at_pos.size(); i++) + if (marker == NULL) + { + mprf(MSGCH_ERROR, "Marker #%d at (%d, %d) NULL", + i, ri->x, ri->y); + continue; + } + if (marker->pos != *ri) { - map_marker *marker = at_pos[i]; + mprf(MSGCH_ERROR, "Marker #%d, type %d at (%d, %d) " + "thinks it's at (%d, %d)", + i, (int) marker->get_type(), ri->x, ri->y, + marker->pos.x, marker->pos.y); - if (marker == NULL) + if (!in_bounds(marker->pos)) { - mprf(MSGCH_ERROR, "Marker #%d at (%d, %d) NULL", - i, x, y); - continue; - } - if (marker->pos != pos) - { - mprf(MSGCH_ERROR, "Marker #%d, type %d at (%d, %d) " - "thinks it's at (%d, %d)", - i, (int) marker->get_type(), x, y, - marker->pos.x, marker->pos.y); - if (!in_bounds(marker->pos)) - mpr("Further, it thinks it's out of bounds.", - MSGCH_ERROR); + mpr("Further, it thinks it's out of bounds.", + MSGCH_ERROR); } } } + } } // _debug_marker_scan() static void _debug_dump_markers() { std::vector<map_marker*> markers = env.markers.get_all(); - for (unsigned int i = 0; i < markers.size(); i++) + for (unsigned int i = 0; i < markers.size(); ++i) { map_marker* marker = markers[i]; @@ -6385,13 +6395,13 @@ static void _debug_dump_markers() i, marker->pos.x, marker->pos.y, marker->debug_describe().c_str()); } -} // _debug_dump_markers() +} static void _debug_dump_lua_markers(FILE *file) { std::vector<map_marker*> markers = env.markers.get_all(); - for (unsigned int i = 0; i < markers.size(); i++) + for (unsigned int i = 0; i < markers.size(); ++i) { map_marker* marker = markers[i]; @@ -6641,8 +6651,10 @@ void debug_dump_mon(const monsters* mon, bool recurse) fprintf(stderr, EOL); if (mon->is_patrolling()) + { fprintf(stderr, "Patrolling: %s" EOL EOL, debug_coord_str(mon->patrol_point).c_str()); + } if (mon->travel_target != MTRAV_NONE) { @@ -6650,6 +6662,7 @@ void debug_dump_mon(const monsters* mon, bool recurse) fprintf(stderr, " travel_target = %d" EOL, mon->travel_target); fprintf(stderr, " travel_path.size() = %lu" EOL, (long unsigned int) mon->travel_path.size()); + if (mon->travel_path.size() > 0) { fprintf(stderr, " next travel step: %s" EOL, @@ -6661,7 +6674,7 @@ void debug_dump_mon(const monsters* mon, bool recurse) fprintf(stderr, EOL); fprintf(stderr, "Inventory:" EOL); - for (int i = 0; i < NUM_MONSTER_SLOTS; i++) + for (int i = 0; i < NUM_MONSTER_SLOTS; ++i) { const int idx = mon->inv[i]; @@ -6686,11 +6699,15 @@ void debug_dump_mon(const monsters* mon, bool recurse) fprintf(stderr, "%s", item.name(DESC_PLAIN, false, true).c_str()); if (!item.held_by_monster()) + { fprintf(stderr, " [not held by monster, pos = %s]", debug_coord_str(item.pos).c_str()); + } else if (item.holding_monster() != mon) + { fprintf(stderr, " [held by other monster: %s]", debug_mon_str(item.holding_monster()).c_str()); + } fprintf(stderr, EOL); } @@ -6700,7 +6717,7 @@ void debug_dump_mon(const monsters* mon, bool recurse) { fprintf(stderr, "Spells:" EOL); - for (int i = 0; i < NUM_MONSTER_SPELL_SLOTS; i++) + for (int i = 0; i < NUM_MONSTER_SPELL_SLOTS; ++i) { spell_type spell = mon->spells[i]; diff --git a/crawl-ref/source/decks.cc b/crawl-ref/source/decks.cc index 04b8cbed51..69bcaea97c 100644 --- a/crawl-ref/source/decks.cc +++ b/crawl-ref/source/decks.cc @@ -214,10 +214,10 @@ static void _shuffle_deck(item_def &deck) // Don't use std::shuffle(), since we want to apply exactly the // same shuffling to both the cards vector and the flags vector. std::vector<vec_size> pos; - for (unsigned long i = 0; i < cards.size(); i++) + for (unsigned long i = 0; i < cards.size(); ++i) pos.push_back(random2(cards.size())); - for (vec_size i = 0; i < pos.size(); i++) + for (vec_size i = 0; i < pos.size(); ++i) { std::swap(cards[i], cards[pos[i]]); std::swap(flags[i], flags[pos[i]]); @@ -538,7 +538,7 @@ static bool _check_buggy_deck(item_def& deck) unsigned int num_buggy = 0; unsigned int num_marked = 0; - for (vec_size i = 0; i < num_cards; i++) + for (vec_size i = 0; i < num_cards; ++i) { unsigned char card = cards[i].get_byte(); unsigned char _flags = flags[i].get_byte(); @@ -611,7 +611,7 @@ static bool _check_buggy_deck(item_def& deck) strm << "More cards than flags."; #endif strm << std::endl; - for (unsigned int i = num_flags + 1; i <= num_cards; i++) + for (unsigned int i = num_flags + 1; i <= num_cards; ++i) flags[i] = static_cast<char>(0); problems = true; @@ -625,7 +625,7 @@ static bool _check_buggy_deck(item_def& deck) #endif strm << std::endl; - for (unsigned int i = num_flags; i > num_cards; i--) + for (unsigned int i = num_flags; i > num_cards; --i) flags.erase(i); problems = true; @@ -1386,8 +1386,8 @@ static void _portal_card(int power, deck_rarity_type rarity) } const bool was_controlled = player_control_teleport(); - const bool short_control = (you.duration[DUR_CONTROL_TELEPORT] > 0) - && (you.duration[DUR_CONTROL_TELEPORT] < 6); + const bool short_control = (you.duration[DUR_CONTROL_TELEPORT] > 0 + && you.duration[DUR_CONTROL_TELEPORT] < 6); if (controlled && (!was_controlled || short_control)) you.duration[DUR_CONTROL_TELEPORT] = 6; // Long enough to kick in. @@ -1542,7 +1542,7 @@ static void _minefield_card(int power, deck_rarity_type rarity) const int radius = power_level * 2 + 2; for (radius_iterator ri(you.pos(), radius, false, false, false); ri; ++ri) { - if ( *ri == you.pos() ) + if (*ri == you.pos()) continue; if (grd(*ri) == DNGN_FLOOR && !find_trap(*ri) @@ -1623,7 +1623,7 @@ static void _move_stair(coord_def stair_pos, bool away) // Stairs already at edge, can't move further away. return; - if ( !in_bounds(ray.pos()) || ray.pos() == you.pos() ) + if (!in_bounds(ray.pos()) || ray.pos() == you.pos()) ray.regress(); while (!see_grid(ray.pos()) || grd(ray.pos()) != DNGN_FLOOR) @@ -1672,6 +1672,8 @@ static void _move_stair(coord_def stair_pos, bool away) } } +// This does not describe an actual card. Instead, it only exists to test +// the stair movement effect in wizard mode ("&c stairs"). static void _stairs_card(int power, deck_rarity_type rarity) { UNUSED(power); @@ -1705,7 +1707,7 @@ static void _stairs_card(int power, deck_rarity_type rarity) std::random_shuffle(stairs_avail.begin(), stairs_avail.end()); - for (unsigned int i = 0; i < stairs_avail.size(); i++) + for (unsigned int i = 0; i < stairs_avail.size(); ++i) _move_stair(stairs_avail[i], stair_draw_count % 2); stair_draw_count++; @@ -1984,8 +1986,8 @@ static void _shadow_card(int power, deck_rarity_type rarity) if (power_level >= 1) { - mpr( you.duration[DUR_STEALTH] ? "You feel more catlike." - : "You feel stealthy."); + mpr(you.duration[DUR_STEALTH] ? "You feel more catlike." + : "You feel stealthy."); you.duration[DUR_STEALTH] += random2(power/4) + 1; } @@ -2324,7 +2326,7 @@ static void _sage_card(int power, deck_rarity_type rarity) static void _create_pond(const coord_def& center, int radius, bool allow_deep) { - for ( radius_iterator ri(center, radius, false); ri; ++ri ) + for (radius_iterator ri(center, radius, false); ri; ++ri) { const coord_def p = *ri; if (p != you.pos() && coinflip()) @@ -2346,7 +2348,7 @@ static void _create_pond(const coord_def& center, int radius, bool allow_deep) static void _deepen_water(const coord_def& center, int radius) { - for ( radius_iterator ri(center, radius, false); ri; ++ri ) + for (radius_iterator ri(center, radius, false); ri; ++ri) { // FIXME The iteration shouldn't affect the later squares in the // same iteration, i.e., a newly-flooded square shouldn't count @@ -2387,7 +2389,7 @@ static void _water_card(int power, deck_rarity_type rarity) mpr("Water floods your area!"); // Flood all visible squares. - for ( radius_iterator ri( you.pos(), LOS_RADIUS, false ); ri; ++ri ) + for (radius_iterator ri( you.pos(), LOS_RADIUS, false ); ri; ++ri) { coord_def p = *ri; destroy_trap(p); @@ -2592,7 +2594,7 @@ static void _curse_card(int power, deck_rarity_type rarity) if (power_level >= 2) { // Curse (almost) everything + chance of decay. - while ( curse_an_item(one_chance_in(6), true) && !one_chance_in(1000) ) + while (curse_an_item(one_chance_in(6), true) && !one_chance_in(1000)) ; } else if (power_level == 1) @@ -2602,7 +2604,7 @@ static void _curse_card(int power, deck_rarity_type rarity) { curse_an_item(false); } - while ( !one_chance_in(4) ); + while (!one_chance_in(4)); } else { @@ -3143,7 +3145,7 @@ void init_deck(item_def &item) props["card_flags"].new_vector(SV_BYTE).resize((vec_size)item.plus); props["drawn_cards"].new_vector(SV_BYTE); - for (int i = 0; i < item.plus; i++) + for (int i = 0; i < item.plus; ++i) { bool was_odd = false; card_type card = _random_card(item, was_odd); diff --git a/crawl-ref/source/delay.cc b/crawl-ref/source/delay.cc index fe5610e65e..b5bc25dd1f 100644 --- a/crawl-ref/source/delay.cc +++ b/crawl-ref/source/delay.cc @@ -359,7 +359,7 @@ void stop_delay( bool stop_stair_travel ) bool butcher_swap_setup = false; int butcher_swap_weapon = 0; - for (unsigned int i = 1; i < you.delay_queue.size(); i++) + for (unsigned int i = 1; i < you.delay_queue.size(); ++i) { if (you.delay_queue[i].type == DELAY_BUTCHER || you.delay_queue[i].type == DELAY_BOTTLE_BLOOD @@ -660,7 +660,7 @@ bool is_being_butchered(const item_def &item, bool just_first) if (!you_are_delayed()) return (false); - for (unsigned int i = 0; i < you.delay_queue.size(); i++) + for (unsigned int i = 0; i < you.delay_queue.size(); ++i) { if (you.delay_queue[i].type == DELAY_BUTCHER || you.delay_queue[i].type == DELAY_BOTTLE_BLOOD @@ -707,7 +707,7 @@ int check_recital_audience() { bool found_monsters = false; - for ( radius_iterator ri(you.pos(), 8); ri; ++ri ) + for (radius_iterator ri(you.pos(), 8); ri; ++ri) { monsters* mons = monster_at(*ri); if (mons == NULL) @@ -1400,7 +1400,7 @@ static void _finish_delay(const delay_queue_item &delay) break; default: - mpr( "You finish doing something." ); + mpr("You finish doing something."); break; } @@ -1444,7 +1444,7 @@ void armour_wear_effects(const int item_slot) if (you.duration[DUR_ICY_ARMOUR] != 0) { - mpr( "Your icy armour melts away.", MSGCH_DURATION ); + mpr("Your icy armour melts away.", MSGCH_DURATION); you.redraw_armour_class = true; you.duration[DUR_ICY_ARMOUR] = 0; } diff --git a/crawl-ref/source/describe.cc b/crawl-ref/source/describe.cc index 1427a199fa..0b916d3882 100644 --- a/crawl-ref/source/describe.cc +++ b/crawl-ref/source/describe.cc @@ -84,7 +84,7 @@ int count_desc_lines(const std::string _desc, const int width) std::string desc = get_linebreak_string(_desc, width); int count = 0; - for (int i = 0, size = desc.size(); i < size; i++) + for (int i = 0, size = desc.size(); i < size; ++i) { const char ch = desc[i]; @@ -320,7 +320,7 @@ static void _trim_randart_inscrip( item_def& item ) { std::vector<std::string> propnames = _randart_propnames(item); - for (unsigned int i = 0; i < propnames.size(); i++) + for (unsigned int i = 0; i < propnames.size(); ++i) { item.inscription = replace_all(item.inscription, propnames[i]+",", ""); item.inscription = replace_all(item.inscription, propnames[i], ""); @@ -895,11 +895,15 @@ static std::string _describe_weapon(const item_def &item, bool verbose) break; case SPWPN_CHAOS: if (is_range_weapon(item)) + { description += "Each time it fires it turns the launched " "projectile into a different, random type of bolt."; + } else + { description += "Each time it hits an enemy it has a " "different, random effect."; + } break; case SPWPN_VAMPIRICISM: description += "It inflicts no extra harm, " @@ -1632,7 +1636,7 @@ void append_spells(std::string &desc, const item_def &item) desc += "$$Spells Type Level$"; - for (int j = 0; j < SPELLBOOK_SIZE; j++) + for (int j = 0; j < SPELLBOOK_SIZE; ++j) { spell_type stype = which_spell_in_book(item, j); if (stype == SPELL_NO_SPELL) @@ -1641,7 +1645,7 @@ void append_spells(std::string &desc, const item_def &item) std::string name = (is_memorised(stype) ? "*" : ""); name += spell_title(stype); desc += name; - for (unsigned int i = 0; i < 35 - name.length(); i++) + for (unsigned int i = 0; i < 35 - name.length(); ++i) desc += " "; name = ""; @@ -1651,7 +1655,7 @@ void append_spells(std::string &desc, const item_def &item) { bool already = false; - for (int i = 0; i <= SPTYP_LAST_EXPONENT; i++) + for (int i = 0; i <= SPTYP_LAST_EXPONENT; ++i) { if (spell_typematch( stype, 1 << i )) { @@ -1665,7 +1669,7 @@ void append_spells(std::string &desc, const item_def &item) } desc += name; - for (unsigned int i = 36; i < 65 - name.length(); i++) + for (unsigned int i = 36; i < 65 - name.length(); ++i) desc += " "; char sval[3]; @@ -2032,7 +2036,7 @@ std::string get_item_description( const item_def &item, bool verbose, description << "$Quantity: " << stack.quantity << " Timer size: " << (int) timer.size(); description << "$Timers:$"; - for (int i = 0; i < timer.size(); i++) + for (int i = 0; i < timer.size(); ++i) description << (timer[i].get_long()) << " "; } #endif @@ -2411,7 +2415,7 @@ void inscribe_item(item_def &item, bool proper_prompt) if (!cancelable_get_line(buf, sizeof buf)) { // Strip spaces from the end. - for (int i = strlen(buf) - 1; i >= 0; i--) + for (int i = strlen(buf) - 1; i >= 0; --i) { if (isspace( buf[i] )) buf[i] = 0; @@ -2694,9 +2698,10 @@ static std::string _monster_stat_description(const monsters& mon) if (mons_immune_magic(&mon)) result << pronoun << " is immune to magical enchantments.$"; - // Seeing/sensing invisible. + // These differ from ghost to ghost, so would be spoily. if (mon.type != MONS_PANDEMONIUM_DEMON && mon.type != MONS_PLAYER_GHOST) { + // Seeing/sensing invisible. if (mons_class_flag(mon.type, M_SEE_INVIS)) result << pronoun << " can see invisible.$"; else if (mons_class_flag(mon.type, M_SENSE_INVIS)) @@ -2913,7 +2918,7 @@ void get_monster_db_desc(const monsters& mons, describe_info &inf, const monster_spells &hspell_pass = mons.spells; bool found_spell = false; - for (int i = 0; i < NUM_MONSTER_SPELL_SLOTS; i++) + for (int i = 0; i < NUM_MONSTER_SPELL_SLOTS; ++i) { if (hspell_pass[i] != SPELL_NO_SPELL) { @@ -2932,7 +2937,7 @@ void get_monster_db_desc(const monsters& mons, describe_info &inf, } bool has_item = false; - for (int i = 0; i < NUM_MONSTER_SLOTS; i++) + for (int i = 0; i < NUM_MONSTER_SLOTS; ++i) { if (mons.inv[i] != NON_ITEM) { @@ -3503,7 +3508,7 @@ void describe_god( god_type which_god, bool give_title ) textcolor(colour); // mv: Some gods can protect you from harm. - // The god isn't really protecting player - only sometimes saving + // The god isn't really protecting the player - only sometimes saving // his life. bool have_any = false; @@ -3677,8 +3682,8 @@ std::string get_skill_description(int skill, bool need_title) || player_mutation_level( MUT_STINGER )) { // TSO worshippers will not use their venomous tails. - if (!(you.religion == GOD_SHINING_ONE - && player_mutation_level(MUT_STINGER))) + if (you.religion != GOD_SHINING_ONE + || !player_mutation_level(MUT_STINGER)) { unarmed_attacks.push_back("slap with your tail"); } diff --git a/crawl-ref/source/directn.cc b/crawl-ref/source/directn.cc index 0376d69563..5a10ce217b 100644 --- a/crawl-ref/source/directn.cc +++ b/crawl-ref/source/directn.cc @@ -221,7 +221,7 @@ static int _targeting_cmd_to_feature( command_type command ) { case CMD_TARGET_FIND_TRAP: return '^'; case CMD_TARGET_FIND_PORTAL: return '\\'; - case CMD_TARGET_FIND_ALTAR: return '_'; + case CMD_TARGET_FIND_ALTAR: return '_'; case CMD_TARGET_FIND_UPSTAIR: return '<'; case CMD_TARGET_FIND_DOWNSTAIR: return '>'; default: return 0; @@ -510,7 +510,7 @@ void full_describe_view() get_monster_pane_info(mons); std::sort(mons.begin(), mons.end(), monster_pane_info::less_than_wrapper); - for (unsigned int i = 0; i < mons.size(); i++) + for (unsigned int i = 0; i < mons.size(); ++i) list_mons.push_back(mons[i].m_mon); if (list_mons.empty() && list_items.empty() && list_features.empty()) @@ -618,7 +618,7 @@ void full_describe_view() std::vector<formatted_string> fss; formatted_string::parse_string_to_multiple(str, fss); MenuEntry *me; - for (unsigned int j = 0; j < fss.size(); j++) + for (unsigned int j = 0; j < fss.size(); ++j) { if (j == 0) { @@ -1348,11 +1348,11 @@ void direction(dist& moves, targeting_type restricts, case CMD_TARGET_CYCLE_TARGET_MODE: mode = static_cast<targ_mode_type>((mode + 1) % TARG_NUM_MODES); - mprf( "Targeting mode is now: %s", - (mode == TARG_ANY) ? "any" : - (mode == TARG_ENEMY) ? "enemies" : - (mode == TARG_HOSTILE) ? "hostiles" - : "friends" ); + mprf("Targeting mode is now: %s", + (mode == TARG_ANY) ? "any" : + (mode == TARG_ENEMY) ? "enemies" : + (mode == TARG_HOSTILE) ? "hostiles" + : "friends"); break; case CMD_TARGET_PREV_TARGET: @@ -1593,10 +1593,6 @@ void direction(dist& moves, targeting_type restricts, need_beam_redraw = true; break; - case CMD_TARGET_ALL_DESCRIBE: - full_describe_view(); - break; - case CMD_TARGET_HELP: show_targeting_help(); force_redraw = true; @@ -1955,7 +1951,7 @@ static bool _find_mlist( const coord_def& where, int idx, bool need_path, return (false); int real_idx = 0; - for (unsigned int i = 0; i+1 < mlist.size(); i++) + for (unsigned int i = 0; i+1 < mlist.size(); ++i) { if (real_idx == idx) { @@ -2271,9 +2267,8 @@ static char _find_square( const coord_def& where, { // This part checks all eight surrounding squares to find the // one that leads on to the present square. - for (i = -1; i < 2; i++) - { - for (j = -1; j < 2; j++) + for (i = -1; i < 2; ++i) + for (j = -1; j < 2; ++j) { if (i == 0 && j == 0) continue; @@ -2283,7 +2278,8 @@ static char _find_square( const coord_def& where, x_change = 0; y_change = -1; } - else if (temp_xps + i - ctrx == 0 && temp_yps + j - ctry == 0) + else if (temp_xps + i - ctrx == 0 + && temp_yps + j - ctry == 0) { x_change = -1; y_change = 0; @@ -2322,7 +2318,6 @@ static char _find_square( const coord_def& where, goto finished_spiralling; } } - } } // end else @@ -3289,7 +3284,7 @@ static void _describe_cell(const coord_def& where, bool in_range) #if DEBUG_DIAGNOSTICS if (!player_monster_visible(mon)) - mpr( "There is a non-visible monster here.", MSGCH_DIAGNOSTICS ); + mpr("There is a non-visible monster here.", MSGCH_DIAGNOSTICS); #else if (!player_monster_visible(mon)) goto look_clouds; @@ -3366,19 +3361,18 @@ static void _describe_cell(const coord_def& where, bool in_range) else { if (mitm[ targ_item ].base_type == OBJ_GOLD) - mprf( MSGCH_FLOOR_ITEMS, "A pile of gold coins." ); + mprf(MSGCH_FLOOR_ITEMS, "A pile of gold coins."); else { std::string name = get_menu_colour_prefix_tags(mitm[targ_item], DESC_NOCAP_A); - mprf( MSGCH_FLOOR_ITEMS, "You see %s here.", - name.c_str()); + mprf(MSGCH_FLOOR_ITEMS, "You see %s here.", name.c_str()); } if (mitm[ targ_item ].link != NON_ITEM) { - mprf( MSGCH_FLOOR_ITEMS, - "There is something else lying underneath."); + mprf(MSGCH_FLOOR_ITEMS, + "There is something else lying underneath."); } } item_described = true; diff --git a/crawl-ref/source/dungeon.cc b/crawl-ref/source/dungeon.cc index 3930a08826..323cf704c3 100644 --- a/crawl-ref/source/dungeon.cc +++ b/crawl-ref/source/dungeon.cc @@ -1131,17 +1131,17 @@ static void _fixup_branch_stairs() && you.level_type == LEVEL_DUNGEON) { const dungeon_feature_type exit = your_branch().exit_stairs; - for ( rectangle_iterator ri(1); ri; ++ri ) + for (rectangle_iterator ri(1); ri; ++ri) { - if (grd(*ri) >= DNGN_STONE_STAIRS_UP_I - && grd(*ri) <= DNGN_ESCAPE_HATCH_UP) - { - if (grd(*ri) == DNGN_STONE_STAIRS_UP_I) - env.markers.add(new map_feature_marker(*ri, grd(*ri))); + if (grd(*ri) >= DNGN_STONE_STAIRS_UP_I + && grd(*ri) <= DNGN_ESCAPE_HATCH_UP) + { + if (grd(*ri) == DNGN_STONE_STAIRS_UP_I) + env.markers.add(new map_feature_marker(*ri, grd(*ri))); - grd(*ri) = exit; - } + grd(*ri) = exit; } + } } // Branches that consist of only 1 level (Hall of Blades). diff --git a/crawl-ref/source/enum.h b/crawl-ref/source/enum.h index 757f20aa82..93449257b1 100644 --- a/crawl-ref/source/enum.h +++ b/crawl-ref/source/enum.h @@ -614,7 +614,6 @@ enum command_type CMD_TARGET_DIR_UP_RIGHT, CMD_TARGET_DESCRIBE, - CMD_TARGET_ALL_DESCRIBE, CMD_TARGET_CYCLE_TARGET_MODE, CMD_TARGET_PREV_TARGET, CMD_TARGET_MAYBE_PREV_TARGET, diff --git a/crawl-ref/source/fight.cc b/crawl-ref/source/fight.cc index f298b1ad60..a6c7a07e14 100644 --- a/crawl-ref/source/fight.cc +++ b/crawl-ref/source/fight.cc @@ -2921,8 +2921,15 @@ int melee_attack::random_chaos_brand() if (defender->holiness() == MH_UNDEAD) susceptible = false; break; - case SPWPN_DRAINING: case SPWPN_VAMPIRICISM: + if (defender->atype() != ACT_PLAYER + && defender_as_monster()->is_summoned()) + { + susceptible = false; + break; + } + // intentional fall-through + case SPWPN_DRAINING: if (defender->holiness() != MH_NATURAL) susceptible = false; break; @@ -3097,8 +3104,10 @@ bool melee_attack::apply_damage_brand() if (defender->atype() == ACT_PLAYER) old_poison = you.duration[DUR_POISONING]; else + { old_poison = (defender_as_monster()->get_ench(ENCH_POISON)).degree; + } // Poison monster message needs to arrive after hit message. emit_nodmg_hit_message(); @@ -3141,8 +3150,10 @@ bool melee_attack::apply_damage_brand() if (x_chance_in_y(defender->res_negative_energy(), 3)) break; - if (defender->holiness() != MH_NATURAL || !weapon - || damage_done < 1 || attacker->stat_hp() == attacker->stat_maxhp() + if (!weapon || defender->holiness() != MH_NATURAL || damage_done < 1 + || attacker->stat_hp() == attacker->stat_maxhp() + || defender->atype() != ACT_PLAYER + && defender_as_monster()->is_summoned() || one_chance_in(5)) { break; diff --git a/crawl-ref/source/files.cc b/crawl-ref/source/files.cc index d6f163c63d..18c9571f3b 100644 --- a/crawl-ref/source/files.cc +++ b/crawl-ref/source/files.cc @@ -900,19 +900,18 @@ static void _place_player_on_stair(level_area_type old_level_type, static void _close_level_gates() { - for ( int i = 0; i < GXM; ++i ) - for ( int j = 0; j < GYM; ++j ) + for (rectangle_iterator ri(0); ri; ++ri) + { + if (you.char_direction == GDT_ASCENDING + && you.level_type != LEVEL_PANDEMONIUM) { - if (you.char_direction == GDT_ASCENDING - && you.level_type != LEVEL_PANDEMONIUM) + if (grid_sealable_portal(grd(*ri))) { - if (grid_sealable_portal(grd[i][j])) - { - grd[i][j] = DNGN_STONE_ARCH; - env.markers.remove_markers_at(coord_def(i,j), MAT_ANY); - } + grd(*ri) = DNGN_STONE_ARCH; + env.markers.remove_markers_at(*ri, MAT_ANY); } } + } } static void _clear_env_map() diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc index cfbd60814f..b608e83836 100644 --- a/crawl-ref/source/mon-util.cc +++ b/crawl-ref/source/mon-util.cc @@ -6403,6 +6403,12 @@ bool monsters::add_ench(const mon_enchant &ench) if (ench.ench == ENCH_NONE) return (false); + if (ench.ench == ENCH_FEAR + && (holiness() == MH_NONLIVING || has_ench(ENCH_BERSERK))) + { + return (false); + } + mon_enchant_list::iterator i = enchantments.find(ench.ench); bool new_enchantment = false; mon_enchant *added = NULL; diff --git a/crawl-ref/source/tilereg.cc b/crawl-ref/source/tilereg.cc index d01265a669..5239865c50 100644 --- a/crawl-ref/source/tilereg.cc +++ b/crawl-ref/source/tilereg.cc @@ -2836,7 +2836,7 @@ TitleRegion::TitleRegion(int width, int height) : sx = sy = 0; dx = dy = 1; - if (!m_img.load_texture("title.png", GenericTexture::MIPMAP_NONE, NULL, false)) + if (!m_img.load_texture("title.png", GenericTexture::MIPMAP_NONE, NULL, true)) return; // Center diff --git a/crawl-ref/source/xom.cc b/crawl-ref/source/xom.cc index 72e8ae3f51..bf0ff04478 100644 --- a/crawl-ref/source/xom.cc +++ b/crawl-ref/source/xom.cc @@ -2463,6 +2463,7 @@ static bool _repel_stairs() } std::vector<coord_def> stairs_avail; + bool real_stairs = false; for (radius_iterator ri(you.pos(), LOS_RADIUS, false, true); ri; ++ri) { dungeon_feature_type feat = grd(*ri); @@ -2470,6 +2471,8 @@ static bool _repel_stairs() && feat != DNGN_ENTER_SHOP) { stairs_avail.push_back(*ri); + if (grid_is_staircase(feat)) + real_stairs = true; } } @@ -2477,8 +2480,17 @@ static bool _repel_stairs() if (stairs_avail.empty()) return (false); - god_speaks(GOD_XOM, - _get_xom_speech("repel stairs").c_str()); + // Don't mention staircases if there aren't any nearby. + std::string stair_msg = _get_xom_speech("repel stairs"); + if (!real_stairs && stair_msg.find("@staircase@") != std::string::npos) + { + std::string feat_name = "gate"; + if (grid_is_escape_hatch(grd(stairs_avail[0]))) + feat_name = "escape hatch"; + stair_msg = replace_all(stair_msg, "@staircase@", feat_name); + } + + god_speaks(GOD_XOM, stair_msg.c_str()); you.duration[DUR_REPEL_STAIRS_MOVE] = 1000; |