diff options
Diffstat (limited to 'crawl-ref')
-rw-r--r-- | crawl-ref/source/abl-show.cc | 68 | ||||
-rw-r--r-- | crawl-ref/source/abyss.cc | 124 | ||||
-rw-r--r-- | crawl-ref/source/acr.cc | 61 | ||||
-rw-r--r-- | crawl-ref/source/beam.cc | 2 | ||||
-rw-r--r-- | crawl-ref/source/chardump.cc | 176 | ||||
-rw-r--r-- | crawl-ref/source/cio.cc | 6 | ||||
-rw-r--r-- | crawl-ref/source/cloud.cc | 96 | ||||
-rw-r--r-- | crawl-ref/source/clua.cc | 54 | ||||
-rw-r--r-- | crawl-ref/source/command.cc | 16 | ||||
-rw-r--r-- | crawl-ref/source/database.cc | 4 | ||||
-rw-r--r-- | crawl-ref/source/debug.cc | 29 | ||||
-rw-r--r-- | crawl-ref/source/decks.cc | 132 | ||||
-rw-r--r-- | crawl-ref/source/delay.cc | 153 | ||||
-rw-r--r-- | crawl-ref/source/describe.cc | 96 | ||||
-rw-r--r-- | crawl-ref/source/directn.cc | 219 | ||||
-rw-r--r-- | crawl-ref/source/dungeon.cc | 146 | ||||
-rw-r--r-- | crawl-ref/source/spells2.cc | 28 | ||||
-rw-r--r-- | crawl-ref/source/spells4.cc | 220 | ||||
-rw-r--r-- | crawl-ref/source/spl-book.cc | 6 | ||||
-rw-r--r-- | crawl-ref/source/spl-cast.cc | 8 | ||||
-rw-r--r-- | crawl-ref/source/spl-util.cc | 80 |
21 files changed, 869 insertions, 855 deletions
diff --git a/crawl-ref/source/abl-show.cc b/crawl-ref/source/abl-show.cc index 83ddb1e831..0eca049174 100644 --- a/crawl-ref/source/abl-show.cc +++ b/crawl-ref/source/abl-show.cc @@ -90,7 +90,7 @@ enum ability_flag_type }; static void _lugonu_bends_space(); -static int _find_ability_slot( ability_type which_ability ); +static int _find_ability_slot( ability_type which_ability ); static bool _activate_talent(const talent& tal); static bool _do_ability(const ability_def& abil); static void _pay_ability_costs(const ability_def& abil); @@ -1980,10 +1980,8 @@ static void _add_talent(std::vector<talent>& vec, const ability_type ability, bool check_confused) { const talent t = _get_talent(ability, check_confused); - if ( t.which != ABIL_NON_ABILITY ) - { + if (t.which != ABIL_NON_ABILITY) vec.push_back(t); - } } std::vector<talent> your_talents( bool check_confused ) @@ -2042,7 +2040,7 @@ std::vector<talent> your_talents( bool check_confused ) } } - // Mutations + // Mutations. if (player_mutation_level(MUT_MAPPING)) _add_talent(talents, ABIL_MAPPING, check_confused ); @@ -2088,13 +2086,13 @@ std::vector<talent> your_talents( bool check_confused ) if (player_mutation_level(MUT_TELEPORT_AT_WILL)) _add_talent(talents, ABIL_TELEPORTATION, check_confused ); - // Religious abilities + // Religious abilities. if (you.religion == GOD_ELYVILON) _add_talent(talents, ABIL_ELYVILON_DESTROY_WEAPONS, check_confused ); else if (you.religion == GOD_TROG) _add_talent(talents, ABIL_TROG_BURN_BOOKS, check_confused ); - // gods take abilities away until penance completed -- bwr + // Gods take abilities away until penance completed. -- bwr if (!player_under_penance() && !silenced( you.x_pos, you.y_pos )) { for ( int i = 0; i < MAX_GOD_ABILITIES; ++i ) @@ -2108,12 +2106,12 @@ std::vector<talent> your_talents( bool check_confused ) } } - // and finally, the ability to opt-out of your faith {dlb}: + // And finally, the ability to opt-out of your faith {dlb}: if (you.religion != GOD_NO_GOD && !silenced( you.x_pos, you.y_pos )) _add_talent(talents, ABIL_RENOUNCE_RELIGION, check_confused ); - //jmf: check for breath weapons -- they're exclusive of each other I hope! - // better make better ones first. + //jmf: Check for breath weapons -- they're exclusive of each other, I hope! + // Make better come ones first. if (you.attribute[ATTR_TRANSFORMATION] == TRAN_SERPENT_OF_HELL) _add_talent(talents, ABIL_BREATHE_HELLFIRE, check_confused ); else if (you.attribute[ATTR_TRANSFORMATION] == TRAN_DRAGON @@ -2122,11 +2120,11 @@ std::vector<talent> your_talents( bool check_confused ) _add_talent(talents, ABIL_BREATHE_FIRE, check_confused ); } - // checking for unreleased delayed fireball + // Checking for unreleased delayed Fireball. if (you.attribute[ ATTR_DELAYED_FIREBALL ]) _add_talent(talents, ABIL_DELAYED_FIREBALL, check_confused ); - // evocations from items: + // Evocations from items. if (scan_randarts(RAP_BLINK)) _add_talent(talents, ABIL_EVOKE_BLINK, check_confused ); @@ -2223,29 +2221,31 @@ static void _set_god_ability_helper( ability_type abil, char letter ) const int index = letter_to_index( letter ); for (i = 0; i < 52; i++) - { if (you.ability_letter_table[i] == abil) break; - } - if (i == 52) // ability is not already assigned + if (i == 52) // Ability is not already assigned. { - // if slot is unoccupied, move in + // If slot is unoccupied, move in. if (you.ability_letter_table[index] == ABIL_NON_ABILITY) you.ability_letter_table[index] = abil; } } -// return GOD_NO_GOD if it isn't a god ability, otherwise return -// the index of the god. +// Return GOD_NO_GOD if it isn't a god ability, otherwise return +// the index of the god.. static int _is_god_ability(int abil) { - if ( abil == ABIL_NON_ABILITY ) + if (abil == ABIL_NON_ABILITY) return GOD_NO_GOD; - for ( int i = 0; i < MAX_NUM_GODS; ++i ) - for ( int j = 0; j < MAX_GOD_ABILITIES; ++j ) - if ( god_abilities[i][j] == abil ) + + for (int i = 0; i < MAX_NUM_GODS; ++i) + for (int j = 0; j < MAX_GOD_ABILITIES; ++j) + { + if (god_abilities[i][j] == abil) return i; + } + return GOD_NO_GOD; } @@ -2257,19 +2257,19 @@ void set_god_ability_slots( void ) _set_god_ability_helper( ABIL_RENOUNCE_RELIGION, 'X' ); - // clear out other god invocations + // Clear out other god invocations. for (i = 0; i < 52; i++) { const int god = _is_god_ability(you.ability_letter_table[i]); - if ( god != GOD_NO_GOD && god != you.religion ) + if (god != GOD_NO_GOD && god != you.religion) you.ability_letter_table[i] = ABIL_NON_ABILITY; } - // finally, add in current god's invocations in traditional slots: + // Finally, add in current god's invocations in traditional slots. int num = 0; - for ( i = 0; i < MAX_GOD_ABILITIES; ++i ) + for (i = 0; i < MAX_GOD_ABILITIES; ++i) { - if ( god_abilities[you.religion][i] != ABIL_NON_ABILITY ) + if (god_abilities[you.religion][i] != ABIL_NON_ABILITY) { _set_god_ability_helper(god_abilities[you.religion][i], 'a' + num); ++num; @@ -2278,19 +2278,17 @@ void set_god_ability_slots( void ) } -// returns an index (0-51) if successful, -1 if you should -// just use the next one +// Returns an index (0-51) if successful, -1 if you should +// just use the next one. static int _find_ability_slot( ability_type which_ability ) { for (int slot = 0; slot < 52; slot++) - { if (you.ability_letter_table[slot] == which_ability) return slot; - } - // no requested slot, find new one and make it preferred. + // No requested slot, find new one and make it preferred. - // skip over a-e (invocations) + // Skip over a-e (invocations) for (int slot = 5; slot < 52; slot++) { if (you.ability_letter_table[slot] == ABIL_NON_ABILITY) @@ -2300,7 +2298,7 @@ static int _find_ability_slot( ability_type which_ability ) } } - // if we can't find anything else, try a-e + // If we can't find anything else, try a-e. for (int slot = 4; slot >= 0; slot--) { if (you.ability_letter_table[slot] == ABIL_NON_ABILITY) @@ -2374,5 +2372,5 @@ static void _lugonu_bends_space() int generic_cost::cost() const { - return base + (add > 0? random2avg(add, rolls) : 0); + return base + (add > 0 ? random2avg(add, rolls) : 0); } diff --git a/crawl-ref/source/abyss.cc b/crawl-ref/source/abyss.cc index 57d311e45c..b77e4bfd3f 100644 --- a/crawl-ref/source/abyss.cc +++ b/crawl-ref/source/abyss.cc @@ -38,11 +38,11 @@ #include "view.h" #include "xom.h" -static bool place_feature_near( const coord_def ¢re, - int radius, - dungeon_feature_type candidate, - dungeon_feature_type replacement, - int tries ) +static bool _place_feature_near( const coord_def ¢re, + int radius, + dungeon_feature_type candidate, + dungeon_feature_type replacement, + int tries ) { const int radius2 = radius * radius + 1; for (int i = 0; i < tries; ++i) @@ -93,8 +93,8 @@ void generate_abyss() grd[45][35] = DNGN_FLOOR; if (one_chance_in(5)) { - place_feature_near( coord_def(45, 35), LOS_RADIUS, - DNGN_FLOOR, DNGN_ALTAR_LUGONU, 50 ); + _place_feature_near( coord_def(45, 35), LOS_RADIUS, + DNGN_FLOOR, DNGN_ALTAR_LUGONU, 50 ); } } @@ -130,8 +130,8 @@ static int _abyssal_rune_roll() return (odds); } -static void generate_area(int gx1, int gy1, int gx2, int gy2, - bool spatter = false) +static void _generate_area(int gx1, int gy1, int gx2, int gy2, + bool spatter = false) { // Any rune on the floor prevents the abyssal rune from being generated. bool placed_abyssal_rune = @@ -139,7 +139,7 @@ static void generate_area(int gx1, int gy1, int gx2, int gy2, #if DEBUG_ABYSS mprf(MSGCH_DIAGNOSTICS, - "generate_area(). turns_on_level: %d, rune_on_floor: %s", + "_generate_area(). turns_on_level: %d, rune_on_floor: %s", env.turns_on_level, placed_abyssal_rune? "yes" : "no"); #endif @@ -285,7 +285,7 @@ static void generate_area(int gx1, int gy1, int gx2, int gy2, setup_environment_effects(); } -static int abyss_exit_nearness() +static int _abyss_exit_nearness() { int nearness = INFINITE_DISTANCE; @@ -307,7 +307,7 @@ static int abyss_exit_nearness() return (nearness); } -static int abyss_rune_nearness() +static int _abyss_rune_nearness() { int nearness = INFINITE_DISTANCE; @@ -343,23 +343,23 @@ static int abyss_rune_nearness() static int exit_was_near; static int rune_was_near; -static void xom_check_nearness_setup() +static void _xom_check_nearness_setup() { - exit_was_near = abyss_exit_nearness(); - rune_was_near = abyss_rune_nearness(); + exit_was_near = _abyss_exit_nearness(); + rune_was_near = _abyss_rune_nearness(); } // If the player was almost to the exit when it disppeared, Xom is // extremely amused. He's also extremely amused if the player winds // up right next to an exit when there wasn't one there before. The // same applies to Abyssal runes. -static void xom_check_nearness() +static void _xom_check_nearness() { // Update known terrain viewwindow(true, false); - int exit_is_near = abyss_exit_nearness(); - int rune_is_near = abyss_rune_nearness(); + int exit_is_near = _abyss_exit_nearness(); + int rune_is_near = _abyss_rune_nearness(); if (exit_was_near < INFINITE_DISTANCE && exit_is_near == INFINITE_DISTANCE @@ -380,7 +380,7 @@ static void xom_check_nearness() } } -static void abyss_lose_monster(monsters &mons) +static void _abyss_lose_monster(monsters &mons) { if (mons.needs_transit()) mons.set_transit( level_id(LEVEL_ABYSS) ); @@ -407,7 +407,7 @@ void area_shift(void) for ( ; ri; ++ri ) fprops(you.pos() - *ri + los_delta) = env.map(*ri).property; - xom_check_nearness_setup(); + _xom_check_nearness_setup(); for (unsigned int i = 0; i < MAX_MONSTERS; i++) { @@ -418,7 +418,7 @@ void area_shift(void) // Remove non-nearby monsters. if (grid_distance(m.x, m.y, you.x_pos, you.y_pos) > 10) - abyss_lose_monster(m); + _abyss_lose_monster(m); } for (int i = 5; i < (GXM - 5); i++) @@ -435,7 +435,7 @@ void area_shift(void) lose_item_stack( i, j ); if (mgrd[i][j] != NON_MONSTER) - abyss_lose_monster( menv[ mgrd[i][j] ] ); + _abyss_lose_monster( menv[ mgrd[i][j] ] ); } // Shift all monsters & items to new area. @@ -488,10 +488,10 @@ void area_shift(void) you.moveto(45, 35); - generate_area(MAPGEN_BORDER, MAPGEN_BORDER, - GXM - MAPGEN_BORDER, GYM - MAPGEN_BORDER, true); + _generate_area(MAPGEN_BORDER, MAPGEN_BORDER, + GXM - MAPGEN_BORDER, GYM - MAPGEN_BORDER, true); - xom_check_nearness(); + _xom_check_nearness(); // Can't re-use ri since you.pos() has changed. radius_iterator ri2(you.pos(), LOS_RADIUS); @@ -523,7 +523,7 @@ void save_abyss_uniques() void abyss_teleport( bool new_area ) /**********************************/ { - xom_check_nearness_setup(); + _xom_check_nearness_setup(); int x, y, i, j, k; @@ -550,7 +550,7 @@ void abyss_teleport( bool new_area ) mpr("Non-new area Abyss teleport.", MSGCH_DIAGNOSTICS); #endif you.moveto(x, y); - xom_check_nearness(); + _xom_check_nearness(); return; } } @@ -567,7 +567,7 @@ void abyss_teleport( bool new_area ) for (i = 0; i < MAX_MONSTERS; i++) { if (menv[i].alive()) - abyss_lose_monster(menv[i]); + _abyss_lose_monster(menv[i]); } // Orbs and fixed artefacts are marked as "lost in the abyss". @@ -596,16 +596,16 @@ void abyss_teleport( bool new_area ) you.moveto(45, 35); - generate_area(MAPGEN_BORDER, MAPGEN_BORDER, - GXM - MAPGEN_BORDER, GYM - MAPGEN_BORDER, true); + _generate_area(MAPGEN_BORDER, MAPGEN_BORDER, + GXM - MAPGEN_BORDER, GYM - MAPGEN_BORDER, true); - xom_check_nearness(); + _xom_check_nearness(); grd[you.x_pos][you.y_pos] = DNGN_FLOOR; if (one_chance_in(5)) { - place_feature_near( you.pos(), LOS_RADIUS, - DNGN_FLOOR, DNGN_ALTAR_LUGONU, 50 ); + _place_feature_near( you.pos(), LOS_RADIUS, + DNGN_FLOOR, DNGN_ALTAR_LUGONU, 50 ); } place_transiting_monsters(); @@ -615,12 +615,12 @@ void abyss_teleport( bool new_area ) ////////////////////////////////////////////////////////////////////////////// // Abyss effects in other levels, courtesy Lugonu. -static void place_corruption_seed(const coord_def &pos, int duration) +static void _place_corruption_seed(const coord_def &pos, int duration) { env.markers.add(new map_corruption_marker(pos, duration)); } -static void initialise_level_corrupt_seeds(int power) +static void _initialise_level_corrupt_seeds(int power) { const int low = power / 2, high = power * 3 / 2; int nseeds = random_range(1, std::min(2 + power / 110, 4)); @@ -630,7 +630,7 @@ static void initialise_level_corrupt_seeds(int power) #endif // The corruption centered on the player is free. - place_corruption_seed(you.pos(), high + 300); + _place_corruption_seed(you.pos(), high + 300); for (int i = 0; i < nseeds; ++i) { @@ -642,11 +642,11 @@ static void initialise_level_corrupt_seeds(int power) while (!in_bounds(where) || grd(where) != DNGN_FLOOR || env.markers.find(where, MAT_ANY)); - place_corruption_seed(where, random_range(low, high, 2) + 300); + _place_corruption_seed(where, random_range(low, high, 2) + 300); } } -static bool spawn_corrupted_servant_near(const coord_def &pos) +static bool _spawn_corrupted_servant_near(const coord_def &pos) { // Thirty tries for a place for (int i = 0; i < 30; ++i) @@ -676,8 +676,7 @@ static bool spawn_corrupted_servant_near(const coord_def &pos) return (false); } -static void apply_corruption_effect( - map_marker *marker, int duration) +static void _apply_corruption_effect( map_marker *marker, int duration) { if (!duration) return; @@ -689,7 +688,7 @@ static void apply_corruption_effect( for (int i = 0; i < neffects; ++i) { if (random2(4000) < cmark->duration - && !spawn_corrupted_servant_near(cmark->pos)) + && !_spawn_corrupted_servant_near(cmark->pos)) { break; } @@ -710,11 +709,11 @@ void run_corruption_effects(int duration) if (mark->get_type() != MAT_CORRUPTION_NEXUS) continue; - apply_corruption_effect(mark, duration); + _apply_corruption_effect(mark, duration); } } -static bool is_grid_corruptible(const coord_def &c) +static bool _is_grid_corruptible(const coord_def &c) { if (c == you.pos()) return (false); @@ -746,7 +745,7 @@ static bool is_grid_corruptible(const coord_def &c) } // Returns true if the square has <= 4 traversable neighbours. -static bool is_crowded_square(const coord_def &c) +static bool _is_crowded_square(const coord_def &c) { int neighbours = 0; for (int xi = -1; xi <= 1; ++xi) @@ -767,7 +766,7 @@ static bool is_crowded_square(const coord_def &c) } // Returns true if the square has all opaque neighbours. -static bool is_sealed_square(const coord_def &c) +static bool _is_sealed_square(const coord_def &c) { for (int xi = -1; xi <= 1; ++xi) for (int yi = -1; yi <= 1; ++yi) @@ -786,7 +785,7 @@ static bool is_sealed_square(const coord_def &c) return (true); } -static void corrupt_square(const crawl_environment &oenv, const coord_def &c) +static void _corrupt_square(const crawl_environment &oenv, const coord_def &c) { // To prevent the destruction of, say, branch entries. bool preserve_feat = true; @@ -804,10 +803,13 @@ static void corrupt_square(const crawl_environment &oenv, const coord_def &c) if (is_trap_square(feat) || feat == DNGN_SECRET_DOOR || feat == DNGN_UNSEEN) return; - if (is_traversable(grd(c)) && !is_traversable(feat) && is_crowded_square(c)) + if (is_traversable(grd(c)) && !is_traversable(feat) + && _is_crowded_square(c)) + { return; + } - if (!is_traversable(grd(c)) && is_traversable(feat) && is_sealed_square(c)) + if (!is_traversable(grd(c)) && is_traversable(feat) && _is_sealed_square(c)) return; // What's this supposed to achieve? (jpeg) @@ -836,7 +838,7 @@ static void corrupt_square(const crawl_environment &oenv, const coord_def &c) #endif } -static void corrupt_level_features(const crawl_environment &oenv) +static void _corrupt_level_features(const crawl_environment &oenv) { std::vector<coord_def> corrupt_seeds; std::vector<map_marker*> corrupt_markers = @@ -858,14 +860,14 @@ static void corrupt_level_features(const crawl_environment &oenv) } if ((distance < 6 || one_chance_in(1 + distance - 6)) - && is_grid_corruptible(c)) + && _is_grid_corruptible(c)) { - corrupt_square(oenv, c); + _corrupt_square(oenv, c); } } } -static bool is_level_corrupted() +static bool _is_level_corrupted() { if (you.level_type == LEVEL_ABYSS || you.level_type == LEVEL_PANDEMONIUM @@ -878,9 +880,9 @@ static bool is_level_corrupted() return (!!env.markers.find(MAT_CORRUPTION_NEXUS)); } -static bool is_level_incorruptible() +static bool _is_level_incorruptible() { - if (is_level_corrupted()) + if (_is_level_corrupted()) { mpr("This place is already infused with evil and corruption."); return (true); @@ -889,7 +891,7 @@ static bool is_level_incorruptible() return (false); } -static void corrupt_choose_colours() +static void _corrupt_choose_colours() { int colour = BLACK; do @@ -910,7 +912,7 @@ static void corrupt_choose_colours() bool lugonu_corrupt_level(int power) { - if (is_level_incorruptible()) + if (_is_level_incorruptible()) return (false); mprf(MSGCH_GOD, "Lugonu's Hand of Corruption reaches out!"); @@ -918,14 +920,14 @@ bool lugonu_corrupt_level(int power) you.flash_colour = EC_MUTAGENIC; viewwindow(true, false); - initialise_level_corrupt_seeds(power); + _initialise_level_corrupt_seeds(power); std::auto_ptr<crawl_environment> backup(new crawl_environment(env)); generate_abyss(); - generate_area(MAPGEN_BORDER, MAPGEN_BORDER, - GXM - MAPGEN_BORDER, GYM - MAPGEN_BORDER, false); + _generate_area(MAPGEN_BORDER, MAPGEN_BORDER, + GXM - MAPGEN_BORDER, GYM - MAPGEN_BORDER, false); - corrupt_choose_colours(); + _corrupt_choose_colours(); std::auto_ptr<crawl_environment> abyssal(new crawl_environment(env)); env = *backup; @@ -933,7 +935,7 @@ bool lugonu_corrupt_level(int power) dungeon_events.clear(); env.markers.activate_all(false); - corrupt_level_features(*abyssal); + _corrupt_level_features(*abyssal); run_corruption_effects(300); you.flash_colour = EC_MUTAGENIC; diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc index 5c1ddc6550..a548ec7d7b 100644 --- a/crawl-ref/source/acr.cc +++ b/crawl-ref/source/acr.cc @@ -201,17 +201,19 @@ static void _read_messages(); static void _compile_time_asserts(); -/* - It all starts here. Some initialisations are run first, then straight to - new_game and then input. -*/ +// +// It all starts here. Some initialisations are run first, then straight +// to new_game and then input. +// + #ifdef WIN32TILES int old_main( int argc, char *argv[] ) #else int main( int argc, char *argv[] ) #endif { - _compile_time_asserts(); // just to quiet "unused static function" warning + _compile_time_asserts(); // Just to quiet "unused static function" warning. + // Load in the system environment variables get_system_environment(); @@ -390,16 +392,17 @@ static void _take_starting_note() notestr << "HP: " << you.hp << "/" << you.hp_max << " MP: " << you.magic_points << "/" << you.max_magic_points; + take_note(Note(NOTE_XP_LEVEL_CHANGE, you.experience_level, 0, notestr.str().c_str())); } static void _startup_tutorial() { - // don't allow triggering at game start + // Don't allow triggering at game start. Options.tut_just_triggered = true; - // print stats and everything + // Print stats and everything. _prep_input(); #ifdef USE_TILE @@ -416,7 +419,7 @@ static void _startup_tutorial() } #ifdef WIZARD -// returns whether an item of this type can be an artefact, or cursed +// Returns whether an item of this type can be an artefact, or cursed. static bool _item_type_can_be_artefact( int type) { return (type == OBJ_WEAPONS || type == OBJ_ARMOUR || type == OBJ_JEWELLERY); @@ -1329,14 +1332,13 @@ static bool _cmd_is_repeatable(command_type cmd, bool is_again = false) return false; } -/* used to determine whether to apply the berserk penalty at end - of round */ +// Used to determine whether to apply the berserk penalty at end of round. bool apply_berserk_penalty = false; -/* - * This function handles the player's input. It's called from main(), - * from inside an endless loop. - */ +// +// This function handles the player's input. It's called from main(), +// from inside an endless loop. +// static void _input() { crawl_state.clear_god_acting(); @@ -1737,7 +1739,7 @@ static void _print_friendly_pickup_setting(bool was_changed) } else { - mprf("Your allies are %scollecting bugs!", now.c_str()); + mprf("Your allies%s are collecting bugs!", now.c_str()); } } @@ -2443,6 +2445,10 @@ static bool _decrement_a_duration(duration_type dur, const char* endmsg = NULL, return rc; } +// Perhaps we should write functions like: update_repel_undead(), +// update_liquid_flames(), and so on. Even better, we could have a +// vector of callback functions (or objects) which get installed +// at some point. static void _decrement_durations() { if (wearing_amulet(AMU_THE_GOURMAND)) @@ -2737,11 +2743,9 @@ static void _decrement_durations() //jmf: guilty for berserking /after/ berserk did_god_conduct( DID_STIMULANTS, 6 + random2(6) ); + // Sometimes berserk leaves us physically drained. // - // Sometimes berserk leaves us physically drained - // - - // chance of passing out: + // Chance of passing out: // - mutation gives a large plus in order to try and // avoid the mutation being a "death sentence" to // certain characters. @@ -2751,6 +2755,7 @@ static void _decrement_durations() // this should make it a bit more interesting for // Crusaders again. // - similarly for the amulet + if (you.berserk_penalty != NO_BERSERK_PENALTY) { const int chance = @@ -2959,12 +2964,6 @@ static void _check_banished() } } -/* Perhaps we should write functions like: update_repel_undead(), - update_liquid_flames(), and so on. Even better, we could have a - vector of callback functions (or objects) which get installed - at some point. -*/ - static void _check_shafts() { for (int i = 0; i < MAX_TRAPS; i++) @@ -3291,8 +3290,8 @@ static command_type _get_next_cmd() #endif #if DEBUG_DIAGNOSTICS - // save hunger at start of round - // for use with hunger "delta-meter" in output.cc + // Save hunger at start of round for use with hunger "delta-meter" + // in output.cc. you.old_hunger = you.hunger; #endif @@ -3321,7 +3320,7 @@ static command_type _get_next_cmd() return _keycode_to_command(keyin); } -/* for now, this is an extremely yucky hack */ +// For now, this is an extremely yucky hack. static command_type _keycode_to_command( keycode_type key ) { switch ( key ) @@ -3830,13 +3829,13 @@ static void _close_door(int door_x, int door_y) } } -// initialise whole lot of stuff... -// returns true if a new character +// Initialise whole lot of stuff... +// Returns true if a new character. static bool _initialise(void) { Options.fixup_options(); - // read the options the player used last time they created a new + // Read the options the player used last time they created a new // character. read_startup_prefs(); diff --git a/crawl-ref/source/beam.cc b/crawl-ref/source/beam.cc index 77f3c7dffa..6660690c8e 100644 --- a/crawl-ref/source/beam.cc +++ b/crawl-ref/source/beam.cc @@ -81,7 +81,7 @@ static int spready[] = { -1, 1, 0, 0 }; static int opdir[] = { 2, 1, 4, 3 }; static FixedArray < bool, 19, 19 > explode_map; -// helper functions (some of these should probably be public): +// Helper functions (some of these should probably be public). static void _sticky_flame_monster(int mn, kill_category who, int hurt_final); static bool _affects_wall(const bolt &beam, int wall_feature); static bool _isBouncy(bolt &beam, unsigned char gridtype); diff --git a/crawl-ref/source/chardump.cc b/crawl-ref/source/chardump.cc index 832ffd76ea..ee4a0b3c9b 100644 --- a/crawl-ref/source/chardump.cc +++ b/crawl-ref/source/chardump.cc @@ -66,32 +66,32 @@ struct dump_params; -static void sdump_header(dump_params &); -static void sdump_stats(dump_params &); -static void sdump_location(dump_params &); -static void sdump_religion(dump_params &); -static void sdump_burden(dump_params &); -static void sdump_hunger(dump_params &); -static void sdump_transform(dump_params &); -static void sdump_visits(dump_params &); -static void sdump_misc(dump_params &); -static void sdump_turns_by_place(dump_params &); -static void sdump_notes(dump_params &); -static void sdump_inventory(dump_params &); -static void sdump_skills(dump_params &); -static void sdump_spells(dump_params &); -static void sdump_mutations(dump_params &); -static void sdump_messages(dump_params &); -static void sdump_screenshot(dump_params &); -static void sdump_kills_by_place(dump_params &); -static void sdump_kills(dump_params &); -static void sdump_newline(dump_params &); -static void sdump_overview(dump_params &); -static void sdump_hiscore(dump_params &); -static void sdump_monster_list(dump_params &); -static void sdump_separator(dump_params &); +static void _sdump_header(dump_params &); +static void _sdump_stats(dump_params &); +static void _sdump_location(dump_params &); +static void _sdump_religion(dump_params &); +static void _sdump_burden(dump_params &); +static void _sdump_hunger(dump_params &); +static void _sdump_transform(dump_params &); +static void _sdump_visits(dump_params &); +static void _sdump_misc(dump_params &); +static void _sdump_turns_by_place(dump_params &); +static void _sdump_notes(dump_params &); +static void _sdump_inventory(dump_params &); +static void _sdump_skills(dump_params &); +static void _sdump_spells(dump_params &); +static void _sdump_mutations(dump_params &); +static void _sdump_messages(dump_params &); +static void _sdump_screenshot(dump_params &); +static void _sdump_kills_by_place(dump_params &); +static void _sdump_kills(dump_params &); +static void _sdump_newline(dump_params &); +static void _sdump_overview(dump_params &); +static void _sdump_hiscore(dump_params &); +static void _sdump_monster_list(dump_params &); +static void _sdump_separator(dump_params &); #ifdef CLUA_BINDINGS -static void sdump_lua(dump_params &); +static void _sdump_lua(dump_params &); #endif static bool write_dump(const std::string &fname, dump_params &); @@ -119,35 +119,35 @@ struct dump_params }; static dump_section_handler dump_handlers[] = { - { "header", sdump_header }, - { "stats", sdump_stats }, - { "location", sdump_location }, - { "religion", sdump_religion }, - { "burden", sdump_burden }, - { "hunger", sdump_hunger }, - { "transform", sdump_transform }, - { "visits", sdump_visits }, - { "misc", sdump_misc }, - { "turns_by_place", sdump_turns_by_place}, - { "notes", sdump_notes }, - { "inventory", sdump_inventory }, - { "skills", sdump_skills }, - { "spells", sdump_spells }, - { "mutations", sdump_mutations }, - { "messages", sdump_messages }, - { "screenshot", sdump_screenshot }, - { "kills_by_place", sdump_kills_by_place}, - { "kills", sdump_kills }, - { "overview", sdump_overview }, - { "hiscore", sdump_hiscore }, - { "monlist", sdump_monster_list }, + { "header", _sdump_header }, + { "stats", _sdump_stats }, + { "location", _sdump_location }, + { "religion", _sdump_religion }, + { "burden", _sdump_burden }, + { "hunger", _sdump_hunger }, + { "transform", _sdump_transform }, + { "visits", _sdump_visits }, + { "misc", _sdump_misc }, + { "turns_by_place", _sdump_turns_by_place}, + { "notes", _sdump_notes }, + { "inventory", _sdump_inventory }, + { "skills", _sdump_skills }, + { "spells", _sdump_spells }, + { "mutations", _sdump_mutations }, + { "messages", _sdump_messages }, + { "screenshot", _sdump_screenshot }, + { "kills_by_place", _sdump_kills_by_place}, + { "kills", _sdump_kills }, + { "overview", _sdump_overview }, + { "hiscore", _sdump_hiscore }, + { "monlist", _sdump_monster_list }, // Conveniences for the .crawlrc artist. - { "", sdump_newline }, - { "-", sdump_separator }, + { "", _sdump_newline }, + { "-", _sdump_separator }, #ifdef CLUA_BINDINGS - { NULL, sdump_lua } + { NULL, _sdump_lua } #else { NULL, NULL } #endif @@ -184,14 +184,16 @@ bool dump_char(const std::string &fname, bool show_prices, bool full_id, return write_dump(fname, par); } -static void sdump_header(dump_params &par) +static void _sdump_header(dump_params &par) { par.text += " " CRAWL " version " VERSION " character file.\n\n"; } -static void sdump_stats(dump_params &par) +static void _sdump_stats(dump_params &par) { /* + // This is the old dump screen and can be removed if no one wants to + // go back. std::vector<formatted_string> vfs = get_full_detail(par.full_id, par.se? par.se->points : -1); @@ -205,7 +207,7 @@ static void sdump_stats(dump_params &par) par.text += "\n\n"; } -static void sdump_burden(dump_params &par) +static void _sdump_burden(dump_params &par) { std::string verb = par.se? "were" : "are"; @@ -222,7 +224,7 @@ static void sdump_burden(dump_params &par) } } -static void sdump_hunger(dump_params &par) +static void _sdump_hunger(dump_params &par) { if (par.se) par.text += "You were "; @@ -233,7 +235,7 @@ static void sdump_hunger(dump_params &par) par.text += ".\n\n"; } -static void sdump_transform(dump_params &par) +static void _sdump_transform(dump_params &par) { std::string &text(par.text); if (you.attribute[ATTR_TRANSFORMATION]) @@ -278,7 +280,7 @@ static void sdump_transform(dump_params &par) } } -static void sdump_visits(dump_params &par) +static void _sdump_visits(dump_params &par) { std::string &text(par.text); @@ -348,19 +350,19 @@ static void sdump_visits(dump_params &par) text += "\n"; } -static void sdump_misc(dump_params &par) +static void _sdump_misc(dump_params &par) { - sdump_location(par); - sdump_religion(par); - sdump_burden(par); - sdump_hunger(par); - sdump_transform(par); - sdump_visits(par); + _sdump_location(par); + _sdump_religion(par); + _sdump_burden(par); + _sdump_hunger(par); + _sdump_transform(par); + _sdump_visits(par); } #define TO_PERCENT(x, y) (100.0f * ((float) (x)) / ((float) (y))) -static std::string sdump_turns_place_info(PlaceInfo place_info, +static std::string _sdump_turns_place_info(PlaceInfo place_info, std::string name = "") { PlaceInfo gi = you.global_info; @@ -392,7 +394,7 @@ static std::string sdump_turns_place_info(PlaceInfo place_info, return out; } -static void sdump_turns_by_place(dump_params &par) +static void _sdump_turns_by_place(dump_params &par) { std::string &text(par.text); @@ -419,12 +421,12 @@ static void sdump_turns_by_place(dump_params &par) text += " "; text += "+-------+-------+-------+-------+-------+----------------------\n"; - text += sdump_turns_place_info(you.global_info, "Total"); + text += _sdump_turns_place_info(you.global_info, "Total"); for (unsigned int i = 0; i < all_visited.size(); i++) { PlaceInfo pi = all_visited[i]; - text += sdump_turns_place_info(pi); + text += _sdump_turns_place_info(pi); } text += " "; @@ -433,12 +435,12 @@ static void sdump_turns_by_place(dump_params &par) text += "\n"; } -static void sdump_newline(dump_params &par) +static void _sdump_newline(dump_params &par) { par.text += "\n"; } -static void sdump_separator(dump_params &par) +static void _sdump_separator(dump_params &par) { par.text += std::string(79, '-') + "\n"; } @@ -446,7 +448,7 @@ static void sdump_separator(dump_params &par) #ifdef CLUA_BINDINGS // Assume this is an arbitrary Lua function name, call the function and // dump whatever it returns. -static void sdump_lua(dump_params &par) +static void _sdump_lua(dump_params &par) { std::string luatext; if (!clua.callfn(par.section.c_str(), ">s", &luatext) @@ -542,7 +544,7 @@ std::string munge_description(const std::string & inStr) return (outStr); } // end munge_description() -static void sdump_messages(dump_params &par) +static void _sdump_messages(dump_params &par) { // A little message history: if (Options.dump_message_count > 0) @@ -552,13 +554,13 @@ static void sdump_messages(dump_params &par) } } -static void sdump_screenshot(dump_params &par) +static void _sdump_screenshot(dump_params &par) { par.text += screenshot(); par.text += "\n\n"; } -static void sdump_notes(dump_params &par) +static void _sdump_notes(dump_params &par) { std::string &text(par.text); if ( note_list.empty() ) @@ -579,7 +581,7 @@ static void sdump_notes(dump_params &par) // dump_location // //--------------------------------------------------------------- -static void sdump_location(dump_params &par) +static void _sdump_location(dump_params &par) { if (you.your_level == -1 && you.where_are_you == BRANCH_MAIN_DUNGEON @@ -596,7 +598,7 @@ static void sdump_location(dump_params &par) par.text += "\n"; } // end dump_location() -static void sdump_religion(dump_params &par) +static void _sdump_religion(dump_params &par) { std::string &text(par.text); if (you.religion != GOD_NO_GOD) @@ -683,7 +685,7 @@ static bool dump_item_origin(const item_def &item, int value) // dump_inventory // //--------------------------------------------------------------- -static void sdump_inventory(dump_params &par) +static void _sdump_inventory(dump_params &par) { int i, j; @@ -793,7 +795,7 @@ static void sdump_inventory(dump_params &par) // dump_skills // //--------------------------------------------------------------- -static void sdump_skills(dump_params &par) +static void _sdump_skills(dump_params &par) { std::string &text(par.text); char tmp_quant[20]; @@ -855,7 +857,7 @@ static std::string spell_type_shortname(int spell_class, bool slash) // dump_spells // //--------------------------------------------------------------- -static void sdump_spells(dump_params &par) +static void _sdump_spells(dump_params &par) { std::string &text(par.text); char tmp_quant[20]; @@ -975,12 +977,12 @@ static void sdump_spells(dump_params &par) } // end dump_spells() -static void sdump_kills(dump_params &par) +static void _sdump_kills(dump_params &par) { par.text += you.kills->kill_info(); } -static std::string sdump_kills_place_info(PlaceInfo place_info, +static std::string _sdump_kills_place_info(PlaceInfo place_info, std::string name = "") { PlaceInfo gi = you.global_info; @@ -1029,7 +1031,7 @@ static std::string sdump_kills_place_info(PlaceInfo place_info, return out; } -static void sdump_kills_by_place(dump_params &par) +static void _sdump_kills_by_place(dump_params &par) { std::string &text(par.text); @@ -1062,19 +1064,19 @@ static void sdump_kills_by_place(dump_params &par) std::string footer = " "; footer += "+-------+-------+-------+-------+-------+-------+--------------\n"; - result += sdump_kills_place_info(you.global_info, "Total"); + result += _sdump_kills_place_info(you.global_info, "Total"); for (unsigned int i = 0; i < all_visited.size(); i++) { PlaceInfo pi = all_visited[i]; - result += sdump_kills_place_info(pi); + result += _sdump_kills_place_info(pi); } if (result.length() > 0) text += header + result + footer + "\n"; } -static void sdump_overview(dump_params &par) +static void _sdump_overview(dump_params &par) { std::string overview = formatted_string::parse_string(overview_description_string()); @@ -1083,7 +1085,7 @@ static void sdump_overview(dump_params &par) par.text += "\n\n"; } -static void sdump_hiscore(dump_params &par) +static void _sdump_hiscore(dump_params &par) { if (!par.se) return; @@ -1094,7 +1096,7 @@ static void sdump_hiscore(dump_params &par) par.text += "\n\n"; } -static void sdump_monster_list(dump_params &par) +static void _sdump_monster_list(dump_params &par) { std::string monlist = mpr_monster_list(par.se); trim_string(monlist); @@ -1102,7 +1104,7 @@ static void sdump_monster_list(dump_params &par) par.text += "\n\n"; } -static void sdump_mutations(dump_params &par) +static void _sdump_mutations(dump_params &par) { std::string &text(par.text); diff --git a/crawl-ref/source/cio.cc b/crawl-ref/source/cio.cc index 9e29f5c81f..2ffd89f8b7 100644 --- a/crawl-ref/source/cio.cc +++ b/crawl-ref/source/cio.cc @@ -16,7 +16,7 @@ #include <queue> #ifdef UNIX -static keycode_type numpad2vi(keycode_type key) +static keycode_type _numpad2vi(keycode_type key) { if (key >= '1' && key <= '9') { @@ -42,13 +42,13 @@ int unmangle_direction_keys(int keyin, int km, bool fake_ctrl, bool fake_shift) { keyin = getchm(keymap); // return control-key - keyin = CONTROL(toupper(numpad2vi(keyin))); + keyin = CONTROL(toupper(_numpad2vi(keyin))); } else if (fake_shift && keyin == '/') { keyin = getchm(keymap); // return shift-key - keyin = toupper(numpad2vi(keyin)); + keyin = toupper(_numpad2vi(keyin)); } #else // Old DOS keypad support diff --git a/crawl-ref/source/cloud.cc b/crawl-ref/source/cloud.cc index 94d065fd11..324b4c76e8 100644 --- a/crawl-ref/source/cloud.cc +++ b/crawl-ref/source/cloud.cc @@ -29,7 +29,7 @@ #include "terrain.h" // Returns true if this cloud spreads out as it dissipates. -static unsigned char actual_spread_rate(cloud_type type, int spread_rate) +static unsigned char _actual_spread_rate(cloud_type type, int spread_rate) { if (spread_rate >= 0) return (unsigned char) spread_rate; @@ -45,39 +45,39 @@ static unsigned char actual_spread_rate(cloud_type type, int spread_rate) } } -static void new_cloud( int cloud, cloud_type type, int x, int y, int decay, - kill_category whose, unsigned char spread_rate ) +static void _new_cloud( int cloud, cloud_type type, int x, int y, int decay, + kill_category whose, unsigned char spread_rate ) { ASSERT( env.cloud[ cloud ].type == CLOUD_NONE ); - env.cloud[ cloud ].type = type; - env.cloud[ cloud ].decay = decay; - env.cloud[ cloud ].x = x; - env.cloud[ cloud ].y = y; - env.cloud[ cloud ].whose = whose; + env.cloud[ cloud ].type = type; + env.cloud[ cloud ].decay = decay; + env.cloud[ cloud ].x = x; + env.cloud[ cloud ].y = y; + env.cloud[ cloud ].whose = whose; env.cloud[ cloud ].spread_rate = spread_rate; - env.cgrid[ x ][ y ] = cloud; + env.cgrid[ x ][ y ] = cloud; env.cloud_no++; } -static void place_new_cloud(cloud_type cltype, int x, int y, int decay, - kill_category whose, int spread_rate) +static void _place_new_cloud(cloud_type cltype, int x, int y, int decay, + kill_category whose, int spread_rate) { if (env.cloud_no >= MAX_CLOUDS) return; - // find slot for cloud + // Find slot for cloud. for (int ci = 0; ci < MAX_CLOUDS; ci++) { if (env.cloud[ci].type == CLOUD_NONE) // i.e., is empty { - new_cloud( ci, cltype, x, y, decay, whose, spread_rate ); + _new_cloud( ci, cltype, x, y, decay, whose, spread_rate ); break; } } } -static int spread_cloud(const cloud_struct &cloud) +static int _spread_cloud(const cloud_struct &cloud) { const int spreadch = cloud.decay > 30? 80 : cloud.decay > 20? 50 : @@ -103,8 +103,8 @@ static int spread_cloud(const cloud_struct &cloud) if (newdecay >= cloud.decay) newdecay = cloud.decay - 1; - place_new_cloud( cloud.type, x, y, newdecay, cloud.whose, - cloud.spread_rate ); + _place_new_cloud( cloud.type, x, y, newdecay, cloud.whose, + cloud.spread_rate ); extra_decay += 8; } @@ -113,30 +113,30 @@ static int spread_cloud(const cloud_struct &cloud) return (extra_decay); } -static void dissipate_cloud(int cc, cloud_struct &cloud, int dissipate) +static void _dissipate_cloud(int cc, cloud_struct &cloud, int dissipate) { - // apply calculated rate to the actual cloud: + // Apply calculated rate to the actual cloud. cloud.decay -= dissipate; if (random2(100) < cloud.spread_rate) { cloud.spread_rate -= div_rand_round(cloud.spread_rate, 10); - cloud.decay -= spread_cloud(cloud); + cloud.decay -= _spread_cloud(cloud); } - // check for total dissipation and handle accordingly: + // Check for total dissipation and handle accordingly. if (cloud.decay < 1) delete_cloud( cc ); } void manage_clouds(void) { - // amount which cloud dissipates - must be unsigned! {dlb} + // Amount which cloud dissipates - must be unsigned! {dlb} unsigned int dissipate = 0; for (unsigned char cc = 0; cc < MAX_CLOUDS; cc++) { - if (env.cloud[cc].type == CLOUD_NONE) // no cloud -> next iteration + if (env.cloud[cc].type == CLOUD_NONE) // No cloud -> next iteration. continue; dissipate = you.time_taken; @@ -157,11 +157,9 @@ void manage_clouds(void) expose_items_to_element(cloud2beam(env.cloud[cc].type), env.cloud[cc].x, env.cloud[cc].y); - dissipate_cloud(cc, env.cloud[cc], dissipate); + _dissipate_cloud(cc, env.cloud[cc], dissipate); } - - return; -} // end manage_clouds() +} void delete_cloud( int cloud ) { @@ -170,12 +168,12 @@ void delete_cloud( int cloud ) const int cloud_x = env.cloud[ cloud ].x; const int cloud_y = env.cloud[ cloud ].y; - env.cloud[ cloud ].type = CLOUD_NONE; - env.cloud[ cloud ].decay = 0; - env.cloud[ cloud ].x = 0; - env.cloud[ cloud ].y = 0; - env.cloud[ cloud ].whose = KC_OTHER; - env.cloud[ cloud ].spread_rate = 0; + env.cloud[ cloud ].type = CLOUD_NONE; + env.cloud[ cloud ].decay = 0; + env.cloud[ cloud ].x = 0; + env.cloud[ cloud ].y = 0; + env.cloud[ cloud ].whose = KC_OTHER; + env.cloud[ cloud ].spread_rate = 0; env.cgrid[ cloud_x ][ cloud_y ] = EMPTY_CLOUD; env.cloud_no--; } @@ -191,8 +189,8 @@ void move_cloud( int cloud, int new_x, int new_y ) const int old_y = env.cloud[ cloud ].y; env.cgrid[ new_x ][ new_y ] = cloud; - env.cloud[ cloud ].x = new_x; - env.cloud[ cloud ].y = new_y; + env.cloud[ cloud ].x = new_x; + env.cloud[ cloud ].y = new_y; env.cgrid[ old_x ][ old_y ] = EMPTY_CLOUD; } } @@ -235,8 +233,8 @@ void place_cloud(cloud_type cl_type, int ctarget_x, // that is, another cloud already there {dlb} if (target_cgrid != EMPTY_CLOUD) { - if ((env.cloud[ target_cgrid ].type >= CLOUD_GREY_SMOKE - && env.cloud[ target_cgrid ].type <= CLOUD_STEAM) + if (env.cloud[ target_cgrid ].type >= CLOUD_GREY_SMOKE + && env.cloud[ target_cgrid ].type <= CLOUD_STEAM || env.cloud[ target_cgrid ].type == CLOUD_STINK || env.cloud[ target_cgrid ].type == CLOUD_BLACK_SMOKE || env.cloud[ target_cgrid ].type == CLOUD_MIST @@ -251,18 +249,18 @@ void place_cloud(cloud_type cl_type, int ctarget_x, } } - unsigned char spread_rate = actual_spread_rate( cl_type, _spread_rate ); + unsigned char spread_rate = _actual_spread_rate( cl_type, _spread_rate ); - // too many clouds + // Too many clouds. if (env.cloud_no >= MAX_CLOUDS) { - // default to random in case there's no low quality clouds + // Default to random in case there's no low quality clouds. int cl_del = random2( MAX_CLOUDS ); for (int ci = 0; ci < MAX_CLOUDS; ci++) { - if ((env.cloud[ ci ].type >= CLOUD_GREY_SMOKE - && env.cloud[ ci ].type <= CLOUD_STEAM) + if (env.cloud[ ci ].type >= CLOUD_GREY_SMOKE + && env.cloud[ ci ].type <= CLOUD_STEAM || env.cloud[ ci ].type == CLOUD_STINK || env.cloud[ ci ].type == CLOUD_BLACK_SMOKE || env.cloud[ ci ].type == CLOUD_MIST @@ -277,24 +275,26 @@ void place_cloud(cloud_type cl_type, int ctarget_x, cl_new = cl_del; } - // create new cloud + // Create new cloud. if (cl_new != -1) - new_cloud( cl_new, cl_type, ctarget_x, ctarget_y, cl_range * 10, - whose, spread_rate ); + { + _new_cloud( cl_new, cl_type, ctarget_x, ctarget_y, cl_range * 10, + whose, spread_rate ); + } else { - // find slot for cloud + // Find slot for cloud. for (int ci = 0; ci < MAX_CLOUDS; ci++) { if (env.cloud[ci].type == CLOUD_NONE) // ie is empty { - new_cloud( ci, cl_type, ctarget_x, ctarget_y, cl_range * 10, - whose, spread_rate ); + _new_cloud( ci, cl_type, ctarget_x, ctarget_y, cl_range * 10, + whose, spread_rate ); break; } } } -} // end place_cloud(); +} bool is_opaque_cloud(unsigned char cloud_idx) { diff --git a/crawl-ref/source/clua.cc b/crawl-ref/source/clua.cc index 7f1e2180b0..149aeb44fa 100644 --- a/crawl-ref/source/clua.cc +++ b/crawl-ref/source/clua.cc @@ -63,12 +63,12 @@ } \ while (false) -static int clua_panic(lua_State *); -static void clua_throttle_hook(lua_State *, lua_Debug *); -static void *clua_allocator(void *ud, void *ptr, size_t osize, size_t nsize); -static int clua_guarded_pcall(lua_State *); -static int clua_dofile(lua_State *); -static int clua_loadfile(lua_State *); +static int _clua_panic(lua_State *); +static void _clua_throttle_hook(lua_State *, lua_Debug *); +static void *_clua_allocator(void *ud, void *ptr, size_t osize, size_t nsize); +static int _clua_guarded_pcall(lua_State *); +static int _clua_dofile(lua_State *); +static int _clua_loadfile(lua_State *); CLua::CLua(bool managed) : error(), managed_vm(managed), shutting_down(false), @@ -204,7 +204,7 @@ void CLua::init_throttle() if (!mixed_call_depth) { - lua_sethook(_state, clua_throttle_hook, + lua_sethook(_state, _clua_throttle_hook, LUA_MASKCOUNT, throttle_unit_lines); throttle_sleep_ms = 0; n_throttle_sleeps = 0; @@ -594,13 +594,13 @@ void CLua::init_lua() if (_state) return; - _state = managed_vm? lua_newstate(clua_allocator, this) : luaL_newstate(); + _state = managed_vm? lua_newstate(_clua_allocator, this) : luaL_newstate(); if (!_state) return; lua_stack_cleaner clean(_state); - lua_atpanic(_state, clua_panic); + lua_atpanic(_state, _clua_panic); luaopen_base(_state); luaopen_string(_state); @@ -622,12 +622,12 @@ void CLua::init_lua() load_cmacro(); load_chooks(); - lua_register(_state, "loadfile", clua_loadfile); - lua_register(_state, "dofile", clua_dofile); + lua_register(_state, "loadfile", _clua_loadfile); + lua_register(_state, "dofile", _clua_dofile); if (managed_vm) { - lua_register(_state, "pcall", clua_guarded_pcall); + lua_register(_state, "pcall", _clua_guarded_pcall); execfile("clua/userbase.lua", true, true); } @@ -659,9 +659,9 @@ void CLua::load_cmacro() ///////////////////////////////////////////////////////////////////// -static void clua_register_metatable(lua_State *ls, const char *tn, - const luaL_reg *lr, - int (*gcfn)(lua_State *ls) = NULL) +static void _clua_register_metatable(lua_State *ls, const char *tn, + const luaL_reg *lr, + int (*gcfn)(lua_State *ls) = NULL) { int top = lua_gettop(ls); @@ -2149,10 +2149,10 @@ static const struct luaL_reg crawl_lib[] = void luaopen_crawl(lua_State *ls) { - clua_register_metatable(ls, REGEX_METATABLE, crawl_regex_ops, - crawl_regex_gc); - clua_register_metatable(ls, MESSF_METATABLE, crawl_messf_ops, - crawl_messf_gc); + _clua_register_metatable(ls, REGEX_METATABLE, crawl_regex_ops, + crawl_regex_gc); + _clua_register_metatable(ls, MESSF_METATABLE, crawl_messf_ops, + crawl_messf_gc); luaL_openlib(ls, "crawl", crawl_lib, 0); } @@ -2671,7 +2671,7 @@ lua_call_throttle::lua_clua_map lua_call_throttle::lua_map; // cases the Lua interpreter will throw an exception instead of // panicking. // -static int clua_panic(lua_State *ls) +static int _clua_panic(lua_State *ls) { if (crawl_state.need_save && !crawl_state.saving_game && !crawl_state.updating_scores) @@ -2681,14 +2681,16 @@ static int clua_panic(lua_State *ls) return (0); } -static void *clua_allocator(void *ud, void *ptr, size_t osize, size_t nsize) +static void *_clua_allocator(void *ud, void *ptr, size_t osize, size_t nsize) { CLua *cl = static_cast<CLua *>( ud ); cl->memory_used += nsize - osize; if (nsize > osize && cl->memory_used >= CLUA_MAX_MEMORY_USE * 1024 - && cl->mixed_call_depth) + && cl->mixed_call_depth) + { return (NULL); + } if (!nsize) { @@ -2699,7 +2701,7 @@ static void *clua_allocator(void *ud, void *ptr, size_t osize, size_t nsize) return (realloc(ptr, nsize)); } -static void clua_throttle_hook(lua_State *ls, lua_Debug *dbg) +static void _clua_throttle_hook(lua_State *ls, lua_Debug *dbg) { CLua *lua = lua_call_throttle::find_clua(ls); @@ -2766,7 +2768,7 @@ CLua *lua_call_throttle::find_clua(lua_State *ls) // levels of nesting would just increase the chance of the script // beating our throttling). // -static int clua_guarded_pcall(lua_State *ls) +static int _clua_guarded_pcall(lua_State *ls) { const int nargs = lua_gettop(ls); const int err = lua_pcall(ls, nargs - 1, LUA_MULTRET, 0); @@ -2784,7 +2786,7 @@ static int clua_guarded_pcall(lua_State *ls) return (lua_gettop(ls)); } -static int clua_loadfile(lua_State *ls) +static int _clua_loadfile(lua_State *ls) { const char *file = luaL_checkstring(ls, 1); if (!file) @@ -2801,7 +2803,7 @@ static int clua_loadfile(lua_State *ls) return (1); } -static int clua_dofile(lua_State *ls) +static int _clua_dofile(lua_State *ls) { const char *file = luaL_checkstring(ls, 1); if (!file) diff --git a/crawl-ref/source/command.cc b/crawl-ref/source/command.cc index eb04dafcd5..3d6f26c32c 100644 --- a/crawl-ref/source/command.cc +++ b/crawl-ref/source/command.cc @@ -369,9 +369,9 @@ static void _adjust_ability(void) canned_msg( MSG_OK ); return; } - else if ( isalpha(keyin) ) + else if (isalpha(keyin)) { - // try to find the hotkey + // Try to find the hotkey. for (unsigned int i = 0; i < talents.size(); ++i) { if ( talents[i].hotkey == keyin ) @@ -381,7 +381,7 @@ static void _adjust_ability(void) } } - // if we can't, cancel out + // If we can't, cancel out. if ( selected < 0 ) { mpr("No such ability."); @@ -414,7 +414,7 @@ static void _adjust_ability(void) return; } - // see if we moved something out + // See if we moved something out. bool printed_message = false; for ( unsigned int i = 0; i < talents.size(); ++i ) { @@ -435,7 +435,7 @@ static void _adjust_ability(void) << ability_name(talents[selected].which) << std::endl; - // swap references in the letter table + // Swap references in the letter table. ability_type tmp = you.ability_letter_table[index2]; you.ability_letter_table[index2] = you.ability_letter_table[index1]; you.ability_letter_table[index1] = tmp; @@ -485,7 +485,7 @@ void list_armour() mpr( estr.str().c_str(), MSGCH_EQUIPMENT, colour); } -} // end list_armour() +} void list_jewellery(void) { @@ -555,7 +555,7 @@ void list_weapons(void) mpr(wstring.c_str(), MSGCH_EQUIPMENT, colour); - // Print out the swap slots + // Print out the swap slots. for (int i = 0; i <= 1; i++) { // We'll avoid repeating the current weapon for these slots, @@ -588,7 +588,7 @@ void list_weapons(void) mpr(wstring.c_str(), MSGCH_EQUIPMENT, colour); } - // Now we print out the current default fire weapon + // Now we print out the current default fire weapon. wstring = "Firing : "; const item_def* item; diff --git a/crawl-ref/source/database.cc b/crawl-ref/source/database.cc index c949606788..c64b6b44a0 100644 --- a/crawl-ref/source/database.cc +++ b/crawl-ref/source/database.cc @@ -469,7 +469,7 @@ static std::string _getWeightedString(DBM *database, const std::string &key, if (result.dsize <= 0) { - // Try ignoring the suffix + // Try ignoring the suffix. canonical_key = key; lowercase(canonical_key); @@ -529,7 +529,7 @@ static std::string _getRandomizedStr(DBM *database, const std::string &key, } // Replace any "@foo@" markers that can be found in this database. -// Those that can't be found are left alone for the caller to deal with +// Those that can't be found are left alone for the caller to deal with. static void _call_recursive_replacement(std::string &str, DBM *database, const std::string &suffix, int &num_replacements, diff --git a/crawl-ref/source/debug.cc b/crawl-ref/source/debug.cc index b5af1de786..ce2e5f254a 100644 --- a/crawl-ref/source/debug.cc +++ b/crawl-ref/source/debug.cc @@ -646,7 +646,7 @@ void level_travel( bool down ) down_stairs(you.your_level, stairs); else up_stairs(stairs); -} // end level_travel() +} static void _wizard_go_to_level(const level_pos &pos) { @@ -2768,7 +2768,7 @@ void debug_get_religion(void) pray(); } -} // end debug_add_skills() +} #endif @@ -2777,7 +2777,7 @@ void error_message_to_player(void) mpr("Oh dear. There appears to be a bug in the program."); mpr("I suggest you leave this level then save as soon as possible."); -} // end error_message_to_player() +} #ifdef WIZARD @@ -3345,10 +3345,9 @@ void debug_fight_statistics(bool use_defaults, bool defence) static int find_trap_slot() { for (int i = 0; i < MAX_TRAPS; ++i) - { if (env.trap[i].type == TRAP_UNASSIGNED) return (i); - } + return (-1); } @@ -4433,7 +4432,7 @@ void mapgen_report_error(const map_def &map, const std::string &err) mapgen_last_error = err; } -static void mapgen_report_avaiable_random_vaults(FILE *outf) +static void _mapgen_report_available_random_vaults(FILE *outf) { you.uniq_map_tags.clear(); you.uniq_map_names.clear(); @@ -4450,13 +4449,13 @@ static void mapgen_report_avaiable_random_vaults(FILE *outf) } } -static void check_mapless(const level_id &lid, std::vector<level_id> &mapless) +static void _check_mapless(const level_id &lid, std::vector<level_id> &mapless) { if (mapgen_level_mapsused.find(lid) == mapgen_level_mapsused.end()) mapless.push_back(lid); } -static void write_mapgen_stats() +static void _write_mapgen_stats() { FILE *outf = fopen("mapgen.log", "w"); fprintf(outf, "Map Generation Stats\n\n"); @@ -4485,14 +4484,14 @@ static void write_mapgen_stats() for (int dep = 1; dep <= branches[i].depth; ++dep) { const level_id lid(br, dep); - check_mapless(lid, mapless); + _check_mapless(lid, mapless); } } - check_mapless(level_id(LEVEL_ABYSS), mapless); - check_mapless(level_id(LEVEL_PANDEMONIUM), mapless); - check_mapless(level_id(LEVEL_LABYRINTH), mapless); - check_mapless(level_id(LEVEL_PORTAL_VAULT), mapless); + _check_mapless(level_id(LEVEL_ABYSS), mapless); + _check_mapless(level_id(LEVEL_PANDEMONIUM), mapless); + _check_mapless(level_id(LEVEL_LABYRINTH), mapless); + _check_mapless(level_id(LEVEL_PORTAL_VAULT), mapless); if (!mapless.empty()) { @@ -4501,7 +4500,7 @@ static void write_mapgen_stats() fprintf(outf, "%3d) %s\n", i + 1, mapless[i].describe().c_str()); } - mapgen_report_avaiable_random_vaults(outf); + _mapgen_report_available_random_vaults(outf); std::vector<std::string> unused_maps; for (int i = 0, size = map_count(); i < size; ++i) @@ -4628,7 +4627,7 @@ void generate_map_stats() // We have to run map preludes ourselves. run_map_preludes(); mg_build_levels(SysEnv.map_gen_iters); - write_mapgen_stats(); + _write_mapgen_stats(); } #endif // DEBUG_DIAGNOSTICS diff --git a/crawl-ref/source/decks.cc b/crawl-ref/source/decks.cc index 7ec0a1bd07..b3cb6a3e39 100644 --- a/crawl-ref/source/decks.cc +++ b/crawl-ref/source/decks.cc @@ -1344,10 +1344,9 @@ static void _warp_card(int power, deck_rarity_type rarity) static void _swap_monster_card(int power, deck_rarity_type rarity) { // Swap between you and another monster. - // Don't choose yourself unless there are no other monsters - // nearby. + // Don't choose yourself unless there are no monsters nearby. monsters *mon_to_swap = choose_random_nearby_monster(0); - if ( !mon_to_swap ) + if (!mon_to_swap) { mpr("You spin around."); } @@ -1356,7 +1355,7 @@ static void _swap_monster_card(int power, deck_rarity_type rarity) monsters& mon(*mon_to_swap); const coord_def newpos = mon.pos(); - // pick the monster up + // Pick the monster up. mgrd(newpos) = NON_MONSTER; mon.x = you.x_pos; @@ -1373,7 +1372,7 @@ static void _swap_monster_card(int power, deck_rarity_type rarity) static void _velocity_card(int power, deck_rarity_type rarity) { const int power_level = get_power_level(power, rarity); - if ( power_level >= 2 ) + if (power_level >= 2) potion_effect( POT_SPEED, random2(power / 4) ); else if ( power_level == 1 ) { @@ -1683,15 +1682,17 @@ static void _battle_lust_card(int power, deck_rarity_type rarity) potion_effect(POT_MIGHT, random2(power/4)); } -// doesn't allow transformation into bat +// Doesn't allow transformation into bat. +// The sudden stat drain of Str-5 would be fatal to some characters! +// XXX: Maybe we could allow it if it would be non-fatal, at least. static void _metamorphosis_card(int power, deck_rarity_type rarity) { const int power_level = get_power_level(power, rarity); transformation_type trans; - if ( power_level >= 2 ) + if (power_level >= 2) trans = coinflip() ? TRAN_DRAGON : TRAN_LICH; - else if ( power_level == 1 ) + else if (power_level == 1) trans = coinflip() ? TRAN_STATUE : TRAN_BLADE_HANDS; else trans = coinflip() ? TRAN_SPIDER : TRAN_ICE_BEAST; @@ -1773,11 +1774,11 @@ static void _blade_card(int power, deck_rarity_type rarity) wield_weapon(false); const int power_level = get_power_level(power, rarity); - if ( power_level >= 2 ) + if (power_level >= 2) { cast_tukimas_dance( random2(power/4) ); } - else if ( power_level == 1 ) + else if (power_level == 1) { cast_sure_blade( random2(power/4) ); } @@ -1788,18 +1789,12 @@ static void _blade_card(int power, deck_rarity_type rarity) SPWPN_VORPAL, SPWPN_DISTORTION, SPWPN_PAIN, SPWPN_DUMMY_CRUSHING }; - if ( !brand_weapon(RANDOM_ELEMENT(brands), random2(power/4)) ) + if (!brand_weapon(RANDOM_ELEMENT(brands), random2(power/4))) { - if ( you.equip[EQ_WEAPON] == -1 ) - { - msg::stream << "Your " << your_hand(true) << " twitch." - << std::endl; - } + if (you.equip[EQ_WEAPON] == -1) + mprf("Your %s twitch.", your_hand(true).c_str()); else - { - msg::stream << "Your weapon vibrates for a moment." - << std::endl; - } + mpr("Your weapon vibrates for a moment."); } } } @@ -1810,8 +1805,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; } @@ -1841,7 +1836,7 @@ static void _potion_card(int power, deck_rarity_type rarity) static void _focus_card(int power, deck_rarity_type rarity) { - char* max_statp[] = { &you.max_strength, &you.max_intel, &you.max_dex }; + char* max_statp[] = { &you.max_strength, &you.max_intel, &you.max_dex }; char* base_statp[] = { &you.strength, &you.intel, &you.dex }; int best_stat = 0; int worst_stat = 0; @@ -1906,8 +1901,8 @@ static void _focus_card(int power, deck_rarity_type rarity) static void _shuffle_card(int power, deck_rarity_type rarity) { stat_type stats[3] = {STAT_STRENGTH, STAT_DEXTERITY, STAT_INTELLIGENCE}; - int old_base[3] = { you.strength, you.dex, you.intel}; - int old_max[3] = {you.max_strength, you.max_dex, you.max_intel}; + int old_base[3] = { you.strength, you.dex, you.intel}; + int old_max[3] = {you.max_strength, you.max_dex, you.max_intel}; int modifiers[3]; int perm[3] = { 0, 1, 2 }; @@ -2149,8 +2144,8 @@ static void _create_pond(const coord_def& center, int radius, bool allow_deep) { dungeon_feature_type feat; - if ( allow_deep ) - feat = coinflip() ? DNGN_SHALLOW_WATER : DNGN_DEEP_WATER; + if (allow_deep && coinflip()) + feat = DNGN_DEEP_WATER; else feat = DNGN_SHALLOW_WATER; @@ -2202,7 +2197,8 @@ static void _water_card(int power, deck_rarity_type rarity) else { mpr("Water floods your area!"); - // Flood all visible squares + + // Flood all visible squares. radius_iterator ri( you.pos(), LOS_RADIUS, false ); for ( ; ri; ++ri ) { @@ -2232,20 +2228,20 @@ static void _dowsing_card(int power, deck_rarity_type rarity) bool things_to_do[3] = { false, false, false }; things_to_do[random2(3)] = true; - if ( power_level == 1 ) + if (power_level == 1) things_to_do[random2(3)] = true; - if ( power_level >= 2 ) + if (power_level >= 2) { for ( int i = 0; i < 3; ++i ) things_to_do[i] = true; } - if ( things_to_do[0] ) + if (things_to_do[0]) cast_detect_secret_doors( random2(power/4) ); - if ( things_to_do[1] ) + if (things_to_do[1]) detect_traps( random2(power/4) ); - if ( things_to_do[2] ) + if (things_to_do[2]) { mpr("You feel telepathic!"); you.duration[DUR_TELEPATHY] = random2(power/4); @@ -2254,7 +2250,7 @@ static void _dowsing_card(int power, deck_rarity_type rarity) static bool _trowel_card(int power, deck_rarity_type rarity) { - // Early exit: don't clobber important features + // Early exit: don't clobber important features. if (is_critical_feature(grd[you.x_pos][you.y_pos])) { mpr("The dungeon trembles momentarily."); @@ -2263,11 +2259,11 @@ static bool _trowel_card(int power, deck_rarity_type rarity) const int power_level = get_power_level(power, rarity); bool done_stuff = false; - if ( power_level >= 2 ) + if (power_level >= 2) { - // generate a portal to something + // Generate a portal to something. const int mapidx = random_map_for_tag("trowel_portal", false, false); - if ( mapidx == -1 ) + if (mapidx == -1) { mpr("A buggy portal flickers into view, then vanishes."); } @@ -2379,7 +2375,7 @@ static void _genie_card(int power, deck_rarity_type rarity) } } -// special case for *your* god maybe? +// Special case for *your* god, maybe? static void _godly_wrath() { divine_retribution(static_cast<god_type>(random2(NUM_GODS - 1) + 1)); @@ -2390,15 +2386,16 @@ static void _curse_card(int power, deck_rarity_type rarity) const int power_level = get_power_level(power, rarity); mpr("You feel a malignant aura surround you."); - if ( power_level >= 2 ) + if (power_level >= 2) { - // curse (almost) everything + decay + // Curse (almost) everything + decay. while ( curse_an_item(true, true) && !one_chance_in(1000) ) ; } - else if ( power_level == 1 ) + else if (power_level == 1) { - do // curse an average of four items + // Curse an average of four items. + do { curse_an_item(false); } @@ -2406,7 +2403,8 @@ static void _curse_card(int power, deck_rarity_type rarity) } else { - curse_an_item(false); // curse 1.5 items + // Curse 1.5 items on average. + curse_an_item(false); if ( coinflip() ) curse_an_item(false); } @@ -2470,9 +2468,9 @@ static void _summon_demon_card(int power, deck_rarity_type rarity) { const int power_level = get_power_level(power, rarity); demon_class_type dct; - if ( power_level >= 2 ) + if (power_level >= 2) dct = DEMON_GREATER; - else if ( power_level == 1 ) + else if (power_level == 1) dct = DEMON_COMMON; else dct = DEMON_LESSER; @@ -2490,14 +2488,14 @@ static void _summon_any_monster(int power, deck_rarity_type rarity) int chosen_x = 0, chosen_y = 0; int num_tries; - if ( power_level == 0 ) + if (power_level == 0) num_tries = 1; - else if ( power_level == 1 ) + else if (power_level == 1) num_tries = 4; else num_tries = 18; - for ( int i = 0; i < num_tries; ++i ) + for (int i = 0; i < num_tries; ++i) { int dx, dy; do @@ -2514,8 +2512,8 @@ static void _summon_any_monster(int power, deck_rarity_type rarity) } while ( mons_is_unique(cur_try) ); - if ( mon_chosen == NUM_MONSTERS || - mons_power(mon_chosen) < mons_power(cur_try) ) + if (mon_chosen == NUM_MONSTERS + || mons_power(mon_chosen) < mons_power(cur_try)) { mon_chosen = cur_try; chosen_x = you.x_pos; @@ -2523,7 +2521,7 @@ static void _summon_any_monster(int power, deck_rarity_type rarity) } } - if ( mon_chosen == NUM_MONSTERS ) // should never happen + if (mon_chosen == NUM_MONSTERS) // Should never happen. return; const bool friendly = (power_level > 0 || !one_chance_in(4)); @@ -2538,7 +2536,7 @@ static void _summon_any_monster(int power, deck_rarity_type rarity) static void _summon_dancing_weapon(int power, deck_rarity_type rarity) { const int power_level = get_power_level(power, rarity); - const bool friendly = (power_level > 0 || !one_chance_in(4)); + const bool friendly = (power_level > 0 || !one_chance_in(4)); const int mon = create_monster( @@ -2560,15 +2558,15 @@ static void _summon_dancing_weapon(int power, deck_rarity_type rarity) // FIXME Mega-hack (breaks encapsulation too) wpn.flags &= ~ISFLAG_RACIAL_MASK; - if ( power_level == 0 ) + if (power_level == 0) { - // Wimpy, negative-enchantment weapon + // Wimpy, negative-enchantment weapon. wpn.plus = -random2(4); wpn.plus2 = -random2(4); wpn.sub_type = (coinflip() ? WPN_DAGGER : WPN_CLUB ); set_item_ego_type(wpn, OBJ_WEAPONS, SPWPN_NORMAL); } - else if ( power_level == 1 ) + else if (power_level == 1) { // This is getting good... wpn.plus = random2(4) - 1; @@ -2580,9 +2578,9 @@ static void _summon_dancing_weapon(int power, deck_rarity_type rarity) coinflip() ? SPWPN_FLAMING : SPWPN_FREEZING); } } - else if ( power_level == 2 ) + else if (power_level == 2) { - // Rare and powerful + // Rare and powerful. wpn.plus = random2(4) + 2; wpn.plus2 = random2(4) + 2; wpn.sub_type = (coinflip() ? WPN_KATANA : WPN_EXECUTIONERS_AXE); @@ -2665,11 +2663,11 @@ static int _card_power(deck_rarity_type rarity) { int result = 0; - if ( you.penance[GOD_NEMELEX_XOBEH] ) + if (you.penance[GOD_NEMELEX_XOBEH]) { result -= you.penance[GOD_NEMELEX_XOBEH]; } - else if ( you.religion == GOD_NEMELEX_XOBEH ) + else if (you.religion == GOD_NEMELEX_XOBEH) { result = you.piety; result *= (you.skills[SK_EVOCATIONS] + 25); @@ -2944,16 +2942,16 @@ void init_deck(item_def &item) static void _unmark_deck(item_def& deck) { - if ( !is_deck(deck) ) + if (!is_deck(deck)) return; CrawlHashTable &props = deck.props; - if ( !props.exists("card_flags") ) + if (!props.exists("card_flags")) return; CrawlVector &flags = props["card_flags"]; - for ( unsigned int i = 0; i < flags.size(); ++i ) + for (unsigned int i = 0; i < flags.size(); ++i) { flags[i] = static_cast<char>((static_cast<char>(flags[i]) & ~CFLAG_MARKED)); @@ -2965,7 +2963,7 @@ static void _unmark_deck(item_def& deck) static void _unmark_and_shuffle_deck(item_def& deck) { - if ( is_deck(deck) ) + if (is_deck(deck)) { _unmark_deck(deck); _shuffle_deck(deck); @@ -2976,10 +2974,10 @@ static bool _shuffle_all_decks_on_level() { bool success = false; - 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) && is_deck(item) ) + if (is_valid_item(item) && is_deck(item)) { #ifdef DEBUG_DIAGNOSTICS mprf(MSGCH_DIAGNOSTICS, "Shuffling: %s on level %d, branch %d", @@ -3000,10 +2998,10 @@ static bool _shuffle_inventory_decks() { bool success = false; - for ( int i = 0; i < ENDOFPACK; ++i ) + for (int i = 0; i < ENDOFPACK; ++i) { item_def& item(you.inv[i]); - if ( is_valid_item(item) && is_deck(item) ) + if (is_valid_item(item) && is_deck(item)) { #ifdef DEBUG_DIAGNOSTICS mprf(MSGCH_DIAGNOSTICS, "Shuffling in inventory: %s", diff --git a/crawl-ref/source/delay.cc b/crawl-ref/source/delay.cc index 13bba97f25..c571d2985a 100644 --- a/crawl-ref/source/delay.cc +++ b/crawl-ref/source/delay.cc @@ -50,16 +50,16 @@ extern std::vector<SelItem> items_for_multidrop; static int _interrupts_blocked = 0; -static void xom_check_corpse_waste(); -static void armour_wear_effects(const int item_inv_slot); -static void handle_run_delays(const delay_queue_item &delay); -static void handle_macro_delay(); -static void finish_delay(const delay_queue_item &delay); +static void _xom_check_corpse_waste(); +static void _armour_wear_effects(const int item_inv_slot); +static void _handle_run_delays(const delay_queue_item &delay); +static void _handle_macro_delay(); +static void _finish_delay(const delay_queue_item &delay); // Monsters cannot be affected in these states. // (All results of Recite, plus friendly + stupid; // note that berserk monsters are also hasted.) -static bool recite_mons_useless(const monsters *mon) +static bool _recite_mons_useless(const monsters *mon) { return (mons_intel(mon->type) < I_NORMAL || mons_friendly(mon) @@ -73,7 +73,7 @@ static bool recite_mons_useless(const monsters *mon) } // power is maximum 50 -static int recite_to_monsters(int x, int y, int pow, int unused) +static int _recite_to_monsters(int x, int y, int pow, int unused) { UNUSED(unused); @@ -83,7 +83,7 @@ static int recite_to_monsters(int x, int y, int pow, int unused) monsters *mons = &menv[mon]; - if (recite_mons_useless(mons)) + if (_recite_mons_useless(mons)) return (0); if (coinflip()) // nothing happens @@ -235,7 +235,7 @@ static const char* _get_recite_speech(const std::string key, int weight) // other delays can be spawned while this delay is running. If is_parent_delay // returns true, new delays will be pushed immediately to the front of the // delay in question, rather than at the end of the queue. -static bool is_parent_delay(delay_type delay) +static bool _is_parent_delay(delay_type delay) { // Interlevel travel can do upstairs/downstairs delays. // Lua macros can in theory perform any of the other delays, @@ -246,13 +246,12 @@ static bool is_parent_delay(delay_type delay) || delay == DELAY_MULTIDROP); } -static int push_delay(const delay_queue_item &delay) +static int _push_delay(const delay_queue_item &delay) { for (delay_queue_type::iterator i = you.delay_queue.begin(); - i != you.delay_queue.end(); - ++i) + i != you.delay_queue.end(); ++i) { - if (is_parent_delay( i->type )) + if (_is_parent_delay( i->type )) { you.delay_queue.insert(i, delay); return (i - you.delay_queue.begin()); @@ -262,7 +261,7 @@ static int push_delay(const delay_queue_item &delay) return (you.delay_queue.size() - 1); } -static void pop_delay() +static void _pop_delay() { if (!you.delay_queue.empty()) you.delay_queue.erase( you.delay_queue.begin() ); @@ -271,7 +270,7 @@ static void pop_delay() static int delays_cleared[NUM_DELAYS]; static int cleared_delays_parm1[NUM_DELAYS]; -static void clear_pending_delays() +static void _clear_pending_delays() { memset(delays_cleared, 0, sizeof(delays_cleared)); memset(cleared_delays_parm1, 0, sizeof(cleared_delays_parm1)); @@ -311,11 +310,11 @@ void start_delay( delay_type type, int turns, int parm1, int parm2 ) { delay.started = true; // Don't issue startup message. - if (push_delay(delay) == 0) - finish_delay(delay); + if (_push_delay(delay) == 0) + _finish_delay(delay); return; } - push_delay( delay ); + _push_delay( delay ); } void stop_delay( bool stop_stair_travel ) @@ -336,7 +335,7 @@ void stop_delay( bool stop_stair_travel ) // as the effect of a delay doesn't normally allow interaction // until it is done... it merely chains up individual actions // into a single action. -- bwr - clear_pending_delays(); + _clear_pending_delays(); switch (delay.type) { @@ -407,14 +406,14 @@ void stop_delay( bool stop_stair_travel ) multiple_corpses ? "s" : ""); } - pop_delay(); + _pop_delay(); break; } case DELAY_MEMORISE: // Losing work here is okay... having to start from // scratch is a reasonable behaviour. -- bwr mpr( "Your memorisation is interrupted." ); - pop_delay(); + _pop_delay(); break; case DELAY_PASSWALL: @@ -423,20 +422,20 @@ void stop_delay( bool stop_stair_travel ) // the delay should be increased to reduce the power of // this spell. -- bwr mpr( "Your meditation is interrupted." ); - pop_delay(); + _pop_delay(); break; case DELAY_MULTIDROP: // No work lost if (!items_for_multidrop.empty()) mpr( "You stop dropping stuff." ); - pop_delay(); + _pop_delay(); break; case DELAY_RECITE: mprf(MSGCH_PLAIN, "You stop %s.", _get_recite_speech("other", you.num_turns + delay.duration)); - pop_delay(); + _pop_delay(); break; case DELAY_RUN: @@ -444,7 +443,7 @@ void stop_delay( bool stop_stair_travel ) case DELAY_TRAVEL: case DELAY_MACRO: // Always interruptible. - pop_delay(); + _pop_delay(); // Keep things consistent, otherwise disturbing phenomena can occur. // Note that runrest::stop() will turn around and call stop_delay() @@ -460,7 +459,7 @@ void stop_delay( bool stop_stair_travel ) case DELAY_INTERRUPTIBLE: // always stoppable by definition... // try using a more specific type anyways. -- bwr - pop_delay(); + _pop_delay(); break; case DELAY_EAT: @@ -473,7 +472,7 @@ void stop_delay( bool stop_stair_travel ) case DELAY_FEED_VAMPIRE: { mpr("You stop draining the corpse."); - xom_check_corpse_waste(); + _xom_check_corpse_waste(); item_def &corpse = (delay.parm1 ? you.inv[delay.parm2] : mitm[delay.parm2]); @@ -493,7 +492,7 @@ void stop_delay( bool stop_stair_travel ) } did_god_conduct(DID_DRINK_BLOOD, 8); delay.duration = 0; - pop_delay(); + _pop_delay(); break; } case DELAY_ARMOUR_ON: @@ -516,7 +515,7 @@ void stop_delay( bool stop_stair_travel ) #ifdef DEBUG_DIAGNOSTICS mpr("Stop ascending/descending stairs."); #endif - pop_delay(); + _pop_delay(); } break; @@ -617,7 +616,7 @@ int check_recital_audience() found_monsters = true; // Can not be affected in these states. - if (recite_mons_useless(mons)) + if (_recite_mons_useless(mons)) continue; return (1); @@ -640,7 +639,7 @@ int check_recital_audience() // Xom is amused by a potential food source going to waste, and is // more amused the hungrier you are. -static void xom_check_corpse_waste() +static void _xom_check_corpse_waste() { int food_need = 7000 - you.hunger; if (food_need < 0) @@ -690,7 +689,8 @@ void handle_delay( void ) case DELAY_RECITE: mprf(MSGCH_PLAIN, "You %s", _get_recite_speech("start", you.num_turns + delay.duration)); - if (apply_area_visible(recite_to_monsters, delay.parm1)) + + if (apply_area_visible(_recite_to_monsters, delay.parm1)) viewwindow(true, false); break; case DELAY_FEED_VAMPIRE: @@ -711,13 +711,13 @@ void handle_delay( void ) // Run delays and Lua delays don't have a specific end time. if (is_run_delay(delay.type)) { - handle_run_delays(delay); + _handle_run_delays(delay); return; } if (delay.type == DELAY_MACRO) { - handle_macro_delay(); + _handle_macro_delay(); return; } @@ -750,7 +750,7 @@ void handle_delay( void ) || delay.type == DELAY_BOTTLE_BLOOD) // Shouldn't happen. { if (player_mutation_level(MUT_SAPROVOROUS) == 3) - xom_check_corpse_waste(); + _xom_check_corpse_waste(); else xom_is_stimulated(32); delay.duration = 0; @@ -758,7 +758,7 @@ void handle_delay( void ) else { // Don't attempt to offer a skeleton. - pop_delay(); + _pop_delay(); // Chain onto the next delay. handle_delay(); @@ -775,7 +775,7 @@ void handle_delay( void ) if (delay.type == DELAY_OFFER_CORPSE) { // don't attempt to offer a rotten corpse - pop_delay(); + _pop_delay(); // Chain onto the next delay. handle_delay(); @@ -787,7 +787,7 @@ void handle_delay( void ) if (you.is_undead != US_UNDEAD && player_mutation_level(MUT_SAPROVOROUS) < 3) { - xom_check_corpse_waste(); + _xom_check_corpse_waste(); } // Vampires won't continue bottling rotting corpses. if (delay.type == DELAY_BOTTLE_BLOOD) @@ -808,7 +808,7 @@ void handle_delay( void ) mprf("Corpse %d no longer valid!", delay.parm1); #endif // Don't attempt to offer an invalid item. - pop_delay(); + _pop_delay(); // Chain onto the next delay. handle_delay(); @@ -834,10 +834,10 @@ void handle_delay( void ) items_for_multidrop.erase( items_for_multidrop.begin() ); } - if ( items_for_multidrop.empty() ) + if (items_for_multidrop.empty()) { - // ran out of things to drop - pop_delay(); + // Ran out of things to drop. + _pop_delay(); return; } } @@ -894,7 +894,8 @@ void handle_delay( void ) case DELAY_RECITE: mprf(MSGCH_MULTITURN_ACTION, "You continue %s.", _get_recite_speech("other", you.num_turns + delay.duration+1)); - if (apply_area_visible(recite_to_monsters, delay.parm1)) + + if (apply_area_visible(_recite_to_monsters, delay.parm1)) viewwindow(true, false); break; case DELAY_MULTIDROP: @@ -913,7 +914,7 @@ void handle_delay( void ) if (food_is_rotten(corpse)) { mpr("This corpse has started to rot.", MSGCH_ROTTEN_MEAT); - xom_check_corpse_waste(); + _xom_check_corpse_waste(); stop_delay(); return; } @@ -927,11 +928,11 @@ void handle_delay( void ) } else { - finish_delay(delay); + _finish_delay(delay); } } -static void finish_delay(const delay_queue_item &delay) +static void _finish_delay(const delay_queue_item &delay) { switch (delay.type) { @@ -944,7 +945,7 @@ static void finish_delay(const delay_queue_item &delay) break; case DELAY_ARMOUR_ON: - armour_wear_effects( delay.parm1 ); + _armour_wear_effects( delay.parm1 ); break; case DELAY_ARMOUR_OFF: @@ -1095,7 +1096,7 @@ static void finish_delay(const delay_queue_item &delay) : "butchering")); if (player_mutation_level(MUT_SAPROVOROUS) == 3) - xom_check_corpse_waste(); + _xom_check_corpse_waste(); else xom_is_stimulated(64); @@ -1230,13 +1231,13 @@ static void finish_delay(const delay_queue_item &delay) you.wield_change = true; print_stats(); // force redraw of the stats - pop_delay(); + _pop_delay(); // Chain onto the next delay. handle_delay(); } -static void armour_wear_effects(const int item_slot) +static void _armour_wear_effects(const int item_slot) { item_def &arm = you.inv[item_slot]; @@ -1395,7 +1396,7 @@ static void armour_wear_effects(const int item_slot) you.redraw_evasion = true; } -static command_type get_running_command() +static command_type _get_running_command() { if ( kbhit() ) { @@ -1405,8 +1406,8 @@ static command_type get_running_command() if ( is_resting() ) { you.running.rest(); - if ( !is_resting() && you.running.hp == you.hp - && you.running.mp == you.magic_points ) + if (!is_resting() && you.running.hp == you.hp + && you.running.mp == you.magic_points) { mpr("Done searching."); } @@ -1420,14 +1421,14 @@ static command_type get_running_command() return direction_to_command( you.running.x, you.running.y ); } -static void handle_run_delays(const delay_queue_item &delay) +static void _handle_run_delays(const delay_queue_item &delay) { // Handle inconsistencies between the delay queue and you.running. // We don't want to send the game into a deadlock. if (!you.running) { update_turn_count(); - pop_delay(); + _pop_delay(); return; } @@ -1439,7 +1440,7 @@ static void handle_run_delays(const delay_queue_item &delay) { case DELAY_REST: case DELAY_RUN: - cmd = get_running_command(); + cmd = _get_running_command(); break; case DELAY_TRAVEL: cmd = travel(); @@ -1460,7 +1461,7 @@ static void handle_run_delays(const delay_queue_item &delay) // find_travel_pos() function in travel.cc. if (!you.running && is_run_delay(current_delay_action())) { - pop_delay(); + _pop_delay(); update_turn_count(); } @@ -1472,7 +1473,7 @@ static void handle_run_delays(const delay_queue_item &delay) } } -static void handle_macro_delay() +static void _handle_macro_delay() { run_macro(); } @@ -1509,7 +1510,7 @@ void run_macro(const char *macroname) // Returns 1 if the delay should be interrupted, 0 if the user function // had no opinion on the matter, -1 if the delay should not be interrupted. -static int userdef_interrupt_activity( const delay_queue_item &idelay, +static int _userdef_interrupt_activity( const delay_queue_item &idelay, activity_interrupt_type ai, const activity_interrupt_data &at ) { @@ -1568,11 +1569,11 @@ static int userdef_interrupt_activity( const delay_queue_item &idelay, } // Returns true if the activity should be interrupted, false otherwise. -static bool should_stop_activity(const delay_queue_item &item, - activity_interrupt_type ai, - const activity_interrupt_data &at) +static bool _should_stop_activity(const delay_queue_item &item, + activity_interrupt_type ai, + const activity_interrupt_data &at) { - int userd = userdef_interrupt_activity(item, ai, at); + int userd = _userdef_interrupt_activity(item, ai, at); // If the user script wanted to stop the activity or cease processing, // do so. @@ -1581,9 +1582,11 @@ static bool should_stop_activity(const delay_queue_item &item, delay_type curr = current_delay_action(); - if (ai == AI_SEE_MONSTER && (curr == DELAY_ASCENDING_STAIRS || - curr == DELAY_DESCENDING_STAIRS)) + if (ai == AI_SEE_MONSTER && (curr == DELAY_ASCENDING_STAIRS + || curr == DELAY_DESCENDING_STAIRS)) + { return false; + } if (ai == AI_FULL_HP || ai == AI_FULL_MP) { @@ -1607,9 +1610,9 @@ static bool should_stop_activity(const delay_queue_item &item, || Options.activity_interrupts[item.type][ai]); } -inline static void monster_warning(activity_interrupt_type ai, - const activity_interrupt_data &at, - int atype) +inline static void _monster_warning(activity_interrupt_type ai, + const activity_interrupt_data &at, + int atype) { if (ai == AI_SEE_MONSTER && is_run_delay(atype)) { @@ -1674,8 +1677,8 @@ inline static void monster_warning(activity_interrupt_type ai, } } -static void paranoid_option_disable( activity_interrupt_type ai, - const activity_interrupt_data &at ) +static void _paranoid_option_disable( activity_interrupt_type ai, + const activity_interrupt_data &at ) { if (ai == AI_HIT_MONSTER || ai == AI_MONSTER_ATTACKS) { @@ -1717,7 +1720,7 @@ bool interrupt_activity( activity_interrupt_type ai, if (_interrupts_blocked > 0) return false; - paranoid_option_disable(ai, at); + _paranoid_option_disable(ai, at); if (crawl_state.is_repeating_cmd()) return interrupt_cmd_repeat(ai, at); @@ -1735,14 +1738,14 @@ bool interrupt_activity( activity_interrupt_type ai, // First try to stop the current delay. const delay_queue_item &item = you.delay_queue.front(); - if (should_stop_activity(item, ai, at)) + if (_should_stop_activity(item, ai, at)) { // no monster will attack you inside a sanctuary, // so presence of monsters won't matter if (is_sanctuary(you.x_pos, you.y_pos)) return (false); - monster_warning(ai, at, item.type); + _monster_warning(ai, at, item.type); stop_delay(); return (true); } @@ -1754,7 +1757,7 @@ bool interrupt_activity( activity_interrupt_type ai, for (int i = 1, size = you.delay_queue.size(); i < size; ++i) { const delay_queue_item &it = you.delay_queue[i]; - if (should_stop_activity(it, ai, at)) + if (_should_stop_activity(it, ai, at)) { // Do we have a queued run delay? If we do, flush the delay queue // so that stop running Lua notifications happen. @@ -1762,7 +1765,7 @@ bool interrupt_activity( activity_interrupt_type ai, { if (is_run_delay( you.delay_queue[j].type )) { - monster_warning(ai, at, you.delay_queue[j].type); + _monster_warning(ai, at, you.delay_queue[j].type); stop_delay(); return (true); } diff --git a/crawl-ref/source/describe.cc b/crawl-ref/source/describe.cc index 70afc49275..26ef0d24ab 100644 --- a/crawl-ref/source/describe.cc +++ b/crawl-ref/source/describe.cc @@ -1380,7 +1380,7 @@ static std::string _describe_jewellery( const item_def &item, bool verbose) return (description); } // end describe_jewellery() -static bool compare_card_names(card_type a, card_type b) +static bool _compare_card_names(card_type a, card_type b) { return std::string(card_name(a)) < std::string(card_name(b)); } @@ -1390,7 +1390,7 @@ static bool compare_card_names(card_type a, card_type b) // describe_misc_item // //--------------------------------------------------------------- -static std::string describe_deck( const item_def &item ) +static std::string _describe_deck( const item_def &item ) { std::string description; @@ -1445,7 +1445,7 @@ static std::string describe_deck( const item_def &item ) if ( !marked_cards.empty() ) { std::sort(marked_cards.begin(), marked_cards.end(), - compare_card_names); + _compare_card_names); description += "Marked card(s): "; for ( unsigned int i = 0; i < marked_cards.size(); ++i ) { @@ -1469,7 +1469,7 @@ static std::string describe_deck( const item_def &item ) if ( !seen_cards.empty() ) { std::sort(seen_cards.begin(), seen_cards.end(), - compare_card_names); + _compare_card_names); description += "Seen card(s): "; for ( unsigned int i = 0; i < seen_cards.size(); ++i ) { @@ -1728,7 +1728,7 @@ std::string get_item_description( const item_def &item, bool verbose, case OBJ_MISCELLANY: if (is_deck(item)) - description << describe_deck( item ); + description << _describe_deck( item ); break; case OBJ_BOOKS: @@ -1807,7 +1807,7 @@ std::string get_item_description( const item_def &item, bool verbose, return description.str(); } // end get_item_description() -static std::string get_feature_description_wide(int feat) +static std::string _get_feature_description_wide(int feat) { return std::string(); } @@ -1823,7 +1823,7 @@ void describe_feature_wide(int x, int y) : desc.substr(0, desc.length() - 3)); // For things which require logic - desc += get_feature_description_wide(grd[x][y]); + desc += _get_feature_description_wide(grd[x][y]); clrscr(); print_description(desc); @@ -1840,7 +1840,7 @@ void describe_feature_wide(int x, int y) } // Returns true if spells can be shown to player. -static bool show_item_description(const item_def &item) +static bool _show_item_description(const item_def &item) { clrscr(); @@ -1867,7 +1867,7 @@ static bool show_item_description(const item_def &item) return false; } -static bool describe_spells(const item_def &item) +static bool _describe_spells(const item_def &item) { int c = getch(); if (c < 'a' || c > 'h') //jmf: was 'g', but 8=h @@ -1898,14 +1898,14 @@ void describe_item( item_def &item, bool allow_inscribe ) { while (true) { - const bool spells_shown = show_item_description(item); + const bool spells_shown = _show_item_description(item); if (spells_shown) { cgotoxy(1, wherey()); textcolor(LIGHTGREY); cprintf("Select a spell to read its description."); - if (describe_spells(item)) + if (_describe_spells(item)) continue; return; } @@ -2043,17 +2043,17 @@ void describe_spell(spell_type spelled) description += spell_title( spelled ); description += "$$"; const std::string long_descrip = getLongDescription(spell_title(spelled)); - if ( !long_descrip.empty() ) + if (!long_descrip.empty()) description += long_descrip; else { description += "This spell has no description. " - "Casting it may therefore be unwise. " + "Casting it may therefore be unwise. " #if DEBUG - "Instead, go fix it. "; + "Instead, go fix it. "; #else - "Please file a bug report."; -#endif // DEBUG + "Please file a bug report."; +#endif } clrscr(); @@ -2065,9 +2065,9 @@ void describe_spell(spell_type spelled) if (getch() == 0) getch(); -} // end describe_spell() +} -static std::string describe_draconian_role(const monsters *mon) +static std::string _describe_draconian_role(const monsters *mon) { switch (mon->type) { @@ -2092,7 +2092,7 @@ static std::string describe_draconian_role(const monsters *mon) } } -static std::string describe_draconian_colour(int species) +static std::string _describe_draconian_colour(int species) { switch (species) { @@ -2116,7 +2116,7 @@ static std::string describe_draconian_colour(int species) return (""); } -static std::string describe_draconian(const monsters *mon) +static std::string _describe_draconian(const monsters *mon) { std::string description; const int subsp = draco_subspecies( mon ); @@ -2145,14 +2145,16 @@ static std::string describe_draconian(const monsters *mon) if (subsp != MONS_DRACONIAN) { - if (describe_draconian_colour(subsp) != "") - description += " " + describe_draconian_colour(subsp); + const std::string drac_col = _describe_draconian_colour(subsp); + if (!drac_col.empty()) + description += " " + drac_col; } if (subsp != mon->type) { - if (describe_draconian_role(mon) != "") - description += " " + describe_draconian_role(mon); + const std::string drac_role = _describe_draconian_role(mon); + if (!drac_role.empty()) + description += " " + drac_role; } return (description); @@ -2277,7 +2279,7 @@ void describe_monsters(monsters& mons) case MONS_DRACONIAN_MONK: case MONS_DRACONIAN_KNIGHT: { - description << describe_draconian( &mons ); + description << _describe_draconian( &mons ); break; } case MONS_PLAYER_GHOST: @@ -2443,25 +2445,25 @@ std::string ghost_description(const monsters &mons, bool concise) extern ability_type god_abilities[MAX_NUM_GODS][MAX_GOD_ABILITIES]; -static bool print_god_abil_desc( int god, int numpower ) +static bool _print_god_abil_desc( int god, int numpower ) { const char* pmsg = god_gain_power_messages[god][numpower]; - // if no message then no power + // If no message then no power. if ( !pmsg[0] ) return false; std::ostringstream buf; if ( isupper(pmsg[0]) ) - buf << pmsg; // complete sentence given + buf << pmsg; // Complete sentence given. else buf << "You can " << pmsg << "."; - // this might be ABIL_NON_ABILITY for passive abilities + // This might be ABIL_NON_ABILITY for passive abilities. const ability_type abil = god_abilities[god][numpower]; - if ( abil != ABIL_NON_ABILITY ) + if (abil != ABIL_NON_ABILITY) { const int spacesleft = 79 - buf.str().length(); const std::string cost = "(" + make_cost_description(abil) + ")"; @@ -2472,7 +2474,7 @@ static bool print_god_abil_desc( int god, int numpower ) return true; } -static std::string describe_favour_generic(god_type which_god) +static std::string _describe_favour_generic(god_type which_god) { const std::string godname = god_name(which_god); return (you.piety > 130) ? "A prized avatar of " + godname + ".": @@ -2503,11 +2505,11 @@ std::string describe_favour(god_type which_god) : "You should show more discipline."; } - return (which_god == GOD_XOM) ? - describe_xom_favour() : describe_favour_generic(which_god); + return (which_god == GOD_XOM) ? describe_xom_favour() + : _describe_favour_generic(which_god); } -static std::string religion_help( god_type god ) +static std::string _religion_help( god_type god ) { std::string result = ""; @@ -2561,8 +2563,10 @@ static std::string religion_help( god_type god ) case GOD_VEHUMET: if (you.piety >= 50) + { result += "Vehumet assists you in casting Conjurations" " and Summonings."; + } break; default: @@ -2605,17 +2609,17 @@ void describe_god( god_type which_god, bool give_title ) //mv: print god's name and title - if you can think up better titles //I have nothing against textcolor(colour); - cprintf( "%s", god_name(which_god, true).c_str()); //print long god's name + cprintf( "%s", god_name(which_god, true).c_str()); // Print long god's name. cprintf (EOL EOL); - //mv: print god's description + //mv: Print god's description. textcolor(LIGHTGRAY); std::string god_desc = getLongDescription(god_name(which_god, false)); const int numcols = get_number_of_cols(); cprintf("%s", get_linebreak_string(god_desc.c_str(), numcols).c_str()); - // title only shown for our own god + // Title only shown for our own god. if (you.religion == which_god) { //mv: print title based on piety @@ -2814,17 +2818,19 @@ void describe_god( god_type which_god, bool give_title ) // mv: No abilities (except divine protection) under penance if (!player_under_penance()) { - for ( int i = 0; i < MAX_GOD_ABILITIES; ++i ) - if ( you.piety >= piety_breakpoint(i) ) - if (print_god_abil_desc(which_god, i)) - have_any = true; + for (int i = 0; i < MAX_GOD_ABILITIES; ++i) + if (you.piety >= piety_breakpoint(i) + && _print_god_abil_desc(which_god, i)) + { + have_any = true; + } } - if ( !have_any ) + if (!have_any) cprintf( "None." EOL ); } - // only give this additional information for worshippers - if ( which_god == you.religion ) + // Only give this additional information for worshippers. + if (which_god == you.religion) { if (you.religion == GOD_ZIN || you.religion == GOD_SHINING_ONE @@ -2836,7 +2842,7 @@ void describe_god( god_type which_god, bool give_title ) cgotoxy(1, get_number_of_lines() - 2, GOTO_CRT); textcolor(LIGHTGRAY); - cprintf(get_linebreak_string(religion_help(which_god), + cprintf(get_linebreak_string(_religion_help(which_god), numcols).c_str()); } diff --git a/crawl-ref/source/directn.cc b/crawl-ref/source/directn.cc index 74083641d4..05e767730a 100644 --- a/crawl-ref/source/directn.cc +++ b/crawl-ref/source/directn.cc @@ -84,29 +84,29 @@ enum LOSSelect LOS_NONE = 0xFFFF }; -static void describe_feature(int mx, int my, bool oos); -static void describe_cell(int mx, int my); - -static bool find_object( int x, int y, int mode, bool need_path, int range ); -static bool find_monster( int x, int y, int mode, bool need_path, int range ); -static bool find_feature( int x, int y, int mode, bool need_path, int range ); - -static char find_square_wrapper( int tx, int ty, - FixedVector<char, 2> &mfp, char direction, - bool (*targ)(int, int, int, bool, int), - bool need_path = false, int mode = TARG_ANY, - int range = -1, bool wrap = false, - int los = LOS_ANY); - -static char find_square( int xps, int yps, - FixedVector<char, 2> &mfp, int direction, - bool (*targ)(int, int, int, bool, int), - bool need_path, int mode = TARG_ANY, int range = -1, - bool wrap = false, int los = LOS_ANY); - -static int targeting_cmd_to_compass( command_type command ); -static void describe_oos_square(int x, int y); -static void extend_move_to_edge(dist &moves); +static void _describe_feature(int mx, int my, bool oos); +static void _describe_cell(int mx, int my); + +static bool _find_object( int x, int y, int mode, bool need_path, int range ); +static bool _find_monster( int x, int y, int mode, bool need_path, int range ); +static bool _find_feature( int x, int y, int mode, bool need_path, int range ); + +static char _find_square_wrapper( int tx, int ty, + FixedVector<char, 2> &mfp, char direction, + bool (*targ)(int, int, int, bool, int), + bool need_path = false, int mode = TARG_ANY, + int range = -1, bool wrap = false, + int los = LOS_ANY); + +static char _find_square( int xps, int yps, + FixedVector<char, 2> &mfp, int direction, + bool (*targ)(int, int, int, bool, int), + bool need_path, int mode = TARG_ANY, int range = -1, + bool wrap = false, int los = LOS_ANY); + +static int _targeting_cmd_to_compass( command_type command ); +static void _describe_oos_square(int x, int y); +static void _extend_move_to_edge(dist &moves); void direction_choose_compass( dist& moves, targeting_behaviour *beh) { @@ -133,7 +133,7 @@ void direction_choose_compass( dist& moves, targeting_behaviour *beh) break; } - const int i = targeting_cmd_to_compass(key_command); + const int i = _targeting_cmd_to_compass(key_command); if ( i != -1 ) { moves.dx = Compass[i].x; @@ -150,7 +150,7 @@ void direction_choose_compass( dist& moves, targeting_behaviour *beh) return; } -static int targeting_cmd_to_compass( command_type command ) +static int _targeting_cmd_to_compass( command_type command ) { switch ( command ) { @@ -175,7 +175,7 @@ static int targeting_cmd_to_compass( command_type command ) } } -static int targeting_cmd_to_feature( command_type command ) +static int _targeting_cmd_to_feature( command_type command ) { switch ( command ) { @@ -615,7 +615,7 @@ void direction(dist& moves, targeting_type restricts, case CMD_TARGET_UP_LEFT: case CMD_TARGET_UP: case CMD_TARGET_UP_RIGHT: - i = targeting_cmd_to_compass(key_command); + i = _targeting_cmd_to_compass(key_command); moves.tx += Compass[i].x; moves.ty += Compass[i].y; break; @@ -628,7 +628,7 @@ void direction(dist& moves, targeting_type restricts, case CMD_TARGET_DIR_UP_LEFT: case CMD_TARGET_DIR_UP: case CMD_TARGET_DIR_UP_RIGHT: - i = targeting_cmd_to_compass(key_command); + i = _targeting_cmd_to_compass(key_command); if (restricts != DIR_TARGET) { @@ -708,10 +708,10 @@ void direction(dist& moves, targeting_type restricts, case CMD_TARGET_FIND_UPSTAIR: case CMD_TARGET_FIND_DOWNSTAIR: { - const int thing_to_find = targeting_cmd_to_feature(key_command); - if (find_square_wrapper(moves.tx, moves.ty, objfind_pos, 1, - find_feature, needs_path, thing_to_find, - range, true, Options.target_los_first ? + const int thing_to_find = _targeting_cmd_to_feature(key_command); + if (_find_square_wrapper(moves.tx, moves.ty, objfind_pos, 1, + _find_feature, needs_path, thing_to_find, + range, true, Options.target_los_first ? LOS_FLIPVH : LOS_ANY)) { moves.tx = objfind_pos[0]; @@ -803,11 +803,11 @@ void direction(dist& moves, targeting_type restricts, case CMD_TARGET_OBJ_CYCLE_BACK: case CMD_TARGET_OBJ_CYCLE_FORWARD: dir = (key_command == CMD_TARGET_OBJ_CYCLE_BACK) ? -1 : 1; - if (find_square_wrapper( moves.tx, moves.ty, objfind_pos, dir, - find_object, needs_path, TARG_ANY, range, - true, Options.target_los_first ? - (dir == 1? LOS_FLIPVH : LOS_FLIPHV) - : LOS_ANY)) + if (_find_square_wrapper( moves.tx, moves.ty, objfind_pos, dir, + _find_object, needs_path, TARG_ANY, range, + true, Options.target_los_first ? + (dir == 1? LOS_FLIPVH : LOS_FLIPHV) + : LOS_ANY)) { moves.tx = objfind_pos[0]; moves.ty = objfind_pos[1]; @@ -820,9 +820,9 @@ void direction(dist& moves, targeting_type restricts, case CMD_TARGET_CYCLE_FORWARD: case CMD_TARGET_CYCLE_BACK: dir = (key_command == CMD_TARGET_CYCLE_BACK) ? -1 : 1; - if (find_square_wrapper( moves.tx, moves.ty, monsfind_pos, dir, - find_monster, needs_path, mode, range, - Options.target_wrap)) + if (_find_square_wrapper( moves.tx, moves.ty, monsfind_pos, dir, + _find_monster, needs_path, mode, range, + Options.target_wrap)) { moves.tx = monsfind_pos[0]; moves.ty = monsfind_pos[1]; @@ -1056,22 +1056,22 @@ void direction(dist& moves, targeting_type restricts, #endif } - skip_iter = false; // only skip one iteration at most + skip_iter = false; // Only skip one iteration at most. } moves.isMe = (moves.tx == you.x_pos && moves.ty == you.y_pos); mesclr(); // We need this for directional explosions, otherwise they'll explode one // square away from the player. - extend_move_to_edge(moves); + _extend_move_to_edge(moves); } void terse_describe_square(const coord_def &c) { if (!see_grid(c.x, c.y)) - describe_oos_square(c.x, c.y); + _describe_oos_square(c.x, c.y); else if (in_bounds(c) ) - describe_cell(c.x, c.y); + _describe_cell(c.x, c.y); } void full_describe_square(const coord_def &c) @@ -1085,17 +1085,17 @@ void full_describe_square(const coord_def &c) if (mid != NON_MONSTER && player_monster_visible(&menv[mid])) { - // First priority: monsters + // First priority: monsters. describe_monsters(menv[mid]); } else if (oid != NON_ITEM) { - // Second priority: objects + // Second priority: objects. describe_item( mitm[oid] ); } else { - // Third priority: features + // Third priority: features. describe_feature_wide(c.x, c.y); } @@ -1103,12 +1103,12 @@ void full_describe_square(const coord_def &c) mesclr(true); } -static void extend_move_to_edge(dist &moves) +static void _extend_move_to_edge(dist &moves) { if (!moves.dx && !moves.dy) return; - // now the tricky bit - extend the target x,y out to map edge. + // Now the tricky bit - extend the target x,y out to map edge. int mx = 0, my = 0; if (moves.dx > 0) @@ -1136,7 +1136,7 @@ static void extend_move_to_edge(dist &moves) // there's a stash on the square, announces the top item and number // of items, otherwise, if there's a stair that's in the travel // cache and noted in the Dungeon (O)verview, names the stair. -static void describe_oos_square(int x, int y) +static void _describe_oos_square(int x, int y) { mpr("You can't see that place.", MSGCH_EXAMINE_FILTER); @@ -1144,7 +1144,7 @@ static void describe_oos_square(int x, int y) return; describe_stash(x, y); - describe_feature(x, y, true); + _describe_feature(x, y, true); } bool in_vlos(int x, int y) @@ -1164,8 +1164,8 @@ bool in_los(int x, int y) return (in_vlos(grid2view(coord_def(x, y)))); } -static bool find_monster( int x, int y, int mode, bool need_path, - int range = -1) +static bool _find_monster( int x, int y, int mode, bool need_path, + int range = -1) { // Target the player for friendly and general spells. if ((mode == TARG_FRIEND || mode == TARG_ANY) @@ -1225,8 +1225,8 @@ static bool find_monster( int x, int y, int mode, bool need_path, || !mons_class_flag( menv[targ_mon].type, M_NO_EXP_GAIN )); } -static bool find_feature( int x, int y, int mode, - bool /* need_path */, int /* range */) +static bool _find_feature( int x, int y, int mode, + bool /* need_path */, int /* range */) { // The stair need not be in LOS if the square is mapped. if (!in_los(x, y) && (!Options.target_oos || !is_terrain_seen(x, y))) @@ -1235,8 +1235,8 @@ static bool find_feature( int x, int y, int mode, return is_feature(mode, x, y); } -static bool find_object(int x, int y, int mode, - bool /* need_path */, int /* range */) +static bool _find_object(int x, int y, int mode, + bool /* need_path */, int /* range */) { // First, check for mimics. bool is_mimic = false; @@ -1257,7 +1257,7 @@ static bool find_object(int x, int y, int mode, && (is_stash(x, y) || is_mimic)); } -static int next_los(int dir, int los, bool wrap) +static int _next_los(int dir, int los, bool wrap) { if (los == LOS_ANY) return (wrap? los : LOS_NONE); @@ -1327,12 +1327,12 @@ bool in_los_bounds(int x, int y) // monsters will be targeted. // //--------------------------------------------------------------- -static char find_square( int xps, int yps, - FixedVector<char, 2> &mfp, int direction, - bool (*find_targ)( int x, int y, int mode, - bool need_path, int range ), - bool need_path, int mode, int range, bool wrap, - int los ) +static char _find_square( int xps, int yps, + FixedVector<char, 2> &mfp, int direction, + bool (*find_targ)( int x, int y, int mode, + bool need_path, int range ), + bool need_path, int mode, int range, bool wrap, + int los ) { // the day will come when [unsigned] chars will be consigned to // the fires of Gehenna. Not quite yet, though. @@ -1402,15 +1402,15 @@ static char find_square( int xps, int yps, mfp[1] = ctry; return (1); } - return find_square(ctrx, ctry, mfp, direction, find_targ, - need_path, mode, range, false, - next_los(direction, los, wrap)); + return _find_square(ctrx, ctry, mfp, direction, find_targ, + need_path, mode, range, false, + _next_los(direction, los, wrap)); } if (direction == -1 && temp_xps == ctrx && temp_yps == ctry) { - return find_square(minx, maxy, mfp, direction, find_targ, - need_path, mode, range, false, - next_los(direction, los, wrap)); + return _find_square(minx, maxy, mfp, direction, find_targ, + need_path, mode, range, false, + _next_los(direction, los, wrap)); } if (direction == 1) @@ -1543,31 +1543,31 @@ static char find_square( int xps, int yps, } return (direction == 1? - find_square(ctrx, ctry, mfp, direction, find_targ, need_path, mode, - range, false, next_los(direction, los, wrap)) - : find_square(minx, maxy, mfp, direction, find_targ, need_path, mode, - range, false, next_los(direction, los, wrap))); + _find_square(ctrx, ctry, mfp, direction, find_targ, need_path, mode, + range, false, _next_los(direction, los, wrap)) + : _find_square(minx, maxy, mfp, direction, find_targ, need_path, mode, + range, false, _next_los(direction, los, wrap))); } // XXX Unbelievably hacky. And to think that my goal was to clean up the code. // Identical to find_square, except that input (tx, ty) and output // (mfp) are in grid coordinates rather than view coordinates. -static char find_square_wrapper( int tx, int ty, - FixedVector<char, 2> &mfp, char direction, - bool (*find_targ)( int x, int y, int mode, - bool need_path, int range ), - bool need_path, int mode, int range, bool wrap, - int los ) +static char _find_square_wrapper( int tx, int ty, + FixedVector<char, 2> &mfp, char direction, + bool (*find_targ)(int x, int y, int mode, + bool need_path, int range), + bool need_path, int mode, int range, bool wrap, + int los ) { - const char r = find_square(grid2viewX(tx), grid2viewY(ty), mfp, - direction, find_targ, need_path, mode, range, - wrap, los); + const char r = _find_square(grid2viewX(tx), grid2viewY(ty), mfp, + direction, find_targ, need_path, mode, range, + wrap, los); mfp[0] = view2gridX(mfp[0]); mfp[1] = view2gridY(mfp[1]); return r; } -static void describe_feature(int mx, int my, bool oos) +static void _describe_feature(int mx, int my, bool oos) { if (oos && !is_terrain_seen(mx, my)) return; @@ -1640,7 +1640,7 @@ void describe_floor() msg_channel_type channel = MSGCH_EXAMINE; - // water is not terribly important if you don't mind it + // Water is not terribly important if you don't mind it- if ((grd[you.x_pos][you.y_pos] == DNGN_DEEP_WATER || grd[you.x_pos][you.y_pos] == DNGN_SHALLOW_WATER) && player_likes_water()) @@ -1652,10 +1652,10 @@ void describe_floor() mpr("Beware, for starvation awaits!", MSGCH_EXAMINE); } -static std::string feature_do_grammar(description_level_type dtype, - bool add_stop, - bool force_article, - std::string desc) +static std::string _feature_do_grammar(description_level_type dtype, + bool add_stop, + bool force_article, + std::string desc) { if (add_stop) desc += "."; @@ -1701,7 +1701,7 @@ std::string feature_description(dungeon_feature_type grid, if (bloody) desc += ", spattered with blood"; - return feature_do_grammar(dtype, add_stop, grid_is_trap(grid), desc); + return _feature_do_grammar(dtype, add_stop, grid_is_trap(grid), desc); } std::string raw_feature_description(dungeon_feature_type grid, @@ -1926,7 +1926,7 @@ std::string raw_feature_description(dungeon_feature_type grid, } } -static std::string marker_feature_description(const coord_def &p) +static std::string _marker_feature_description(const coord_def &p) { std::vector<map_marker*> markers = env.markers.get_markers_at(p); for (int i = 0, size = markers.size(); i < size; ++i) @@ -1941,9 +1941,8 @@ static std::string marker_feature_description(const coord_def &p) #ifndef DEBUG_DIAGNOSTICS // Is a feature interesting enough to 'v'iew it, even if a player normally // doesn't care about descriptions, i.e. does the description hold important -// information? (Yes, this is entirely subjective. JPEG) - -static bool interesting_feature(dungeon_feature_type feat) +// information? (Yes, this is entirely subjective. --jpeg) +static bool _interesting_feature(dungeon_feature_type feat) { return (get_feature_def(feat).flags & FFT_EXAMINE_HINT); } @@ -1970,7 +1969,7 @@ std::string feature_description(int mx, int my, bool bloody, if (bloody) desc += ", spattered with blood"; - return feature_do_grammar(dtype, add_stop, false, desc); + return _feature_do_grammar(dtype, add_stop, false, desc); } switch (grid) @@ -1984,17 +1983,17 @@ std::string feature_description(int mx, int my, bool bloody, return (shop_name(mx, my, add_stop)); case DNGN_ENTER_PORTAL_VAULT: - return (feature_do_grammar( + return (_feature_do_grammar( dtype, add_stop, false, - marker_feature_description(coord_def(mx, my)))); + _marker_feature_description(coord_def(mx, my)))); default: return (feature_description(grid, NUM_TRAPS, bloody, dtype, add_stop)); } } -static std::string describe_mons_enchantment(const monsters &mons, - const mon_enchant &ench, - bool paralysed) +static std::string _describe_mons_enchantment(const monsters &mons, + const mon_enchant &ench, + bool paralysed) { // Suppress silly-looking combinations, even if they're // internally valid. @@ -2037,10 +2036,10 @@ static std::string describe_mons_enchantment(const monsters &mons, return "entangled in a net"; default: return ""; - } // end switch + } } -static std::string describe_monster_weapon(const monsters *mons) +static std::string _describe_monster_weapon(const monsters *mons) { std::string desc = ""; std::string name1, name2; @@ -2086,7 +2085,7 @@ static std::string describe_monster_weapon(const monsters *mons) } #ifdef DEBUG_DIAGNOSTICS -static std::string stair_destination_description(const coord_def &pos) +static std::string _stair_destination_description(const coord_def &pos) { if (LevelInfo *linf = travel_cache.find_level_info(level_id::current())) { @@ -2100,7 +2099,7 @@ static std::string stair_destination_description(const coord_def &pos) } #endif -static void describe_monster(const monsters *mon) +static void _describe_monster(const monsters *mon) { // first print type and equipment std::string text = get_monster_desc(mon); @@ -2166,7 +2165,7 @@ static void describe_monster(const monsters *mon) for (mon_enchant_list::const_iterator e = mon->enchantments.begin(); e != mon->enchantments.end(); ++e) { - tmp = describe_mons_enchantment(*mon, e->second, paralysed); + tmp = _describe_mons_enchantment(*mon, e->second, paralysed); if (!tmp.empty()) { if (!desc.empty()) @@ -2214,7 +2213,7 @@ std::string get_monster_desc(const monsters *mon, bool full_desc, std::string weap = ""; if (mon->type != MONS_DANCING_WEAPON) - weap = describe_monster_weapon(mon); + weap = _describe_monster_weapon(mon); if (!weap.empty()) { @@ -2291,7 +2290,7 @@ std::string get_monster_desc(const monsters *mon, bool full_desc, return desc; } -static void describe_cell(int mx, int my) +static void _describe_cell(int mx, int my) { bool mimic_item = false; bool monster_described = false; @@ -2319,7 +2318,7 @@ static void describe_cell(int mx, int my) goto look_clouds; #endif - describe_monster(&menv[i]); + _describe_monster(&menv[i]); if (mons_is_mimic( menv[i].type )) { @@ -2404,7 +2403,7 @@ static void describe_cell(int mx, int my) marker = " (" + desc + ")"; } const std::string traveldest = - stair_destination_description(coord_def(mx, my)); + _stair_destination_description(coord_def(mx, my)); const dungeon_feature_type feat = grd[mx][my]; mprf(MSGCH_DIAGNOSTICS, "(%d,%d): %s - %s (%d/%s)%s%s", mx, my, stringize_glyph(get_screen_glyph(mx, my)).c_str(), @@ -2427,7 +2426,7 @@ static void describe_cell(int mx, int my) { const dungeon_feature_type feat = grd[mx][my]; - if (interesting_feature(feat)) + if (_interesting_feature(feat)) { #ifdef USE_TILE feature_desc += " (Right-click for more information.)"; diff --git a/crawl-ref/source/dungeon.cc b/crawl-ref/source/dungeon.cc index 1c9190d730..0fb14bb8e6 100644 --- a/crawl-ref/source/dungeon.cc +++ b/crawl-ref/source/dungeon.cc @@ -1234,10 +1234,10 @@ static void _build_dungeon_level(int level_number, int level_type) _place_traps(level_number); _place_fog_machines(level_number); - // place items + // Place items. _builder_items(level_number, level_type, _num_items_wanted(level_number)); - // place monsters + // Place monsters. _builder_monsters(level_number, level_type, _num_mons_wanted(level_type)); _fixup_walls(); @@ -1351,7 +1351,7 @@ static void _check_doors() grd[x][y] = ((solid_count < 2) ? DNGN_FLOOR : DNGN_CLOSED_DOOR); } -} // end check_doors() +} static void _hide_doors() { @@ -1361,7 +1361,7 @@ static void _hide_doors() for (dx = 1; dx < GXM-1; dx++) for (dy = 1; dy < GYM-1; dy++) { - // Only one out of four doors are candidates for hiding {gdl}: + // Only one out of four doors are candidates for hiding. {gdl} if (grd[dx][dy] == DNGN_CLOSED_DOOR && one_chance_in(4) && unforbidden(coord_def(dx, dy), MMT_NO_DOOR)) { @@ -1379,14 +1379,14 @@ static void _hide_doors() if (grd[dx][dy + 1] == DNGN_ROCK_WALL) wall_count++; - // if door is attached to more than one wall, hide it {dlb}: + // If door is attached to more than one wall, hide it. {dlb} if (wall_count > 1) grd[dx][dy] = DNGN_SECRET_DOOR; } } -} // end hide_doors() +} -// Places a randomized ellipse with centre (x,y) and half axes a and b +// Places a randomized ellipse with centre (x,y) and half axes a and b. static void _place_ellipse(int x, int y, int a, int b, dungeon_feature_type feat, int margin) { @@ -1419,7 +1419,7 @@ int count_antifeature_in_box(int x0, int y0, int x1, int y1, return (x1-x0)*(y1-y0) - count_feature_in_box(x0,y0,x1,y1,feat); } -// count how many neighbours of grd[x][y] are the feature feat. +// Count how many neighbours of grd[x][y] are the feature feat. int count_neighbours(int x, int y, dungeon_feature_type feat) { return count_feature_in_box(x-1, y-1, x+2, y+2, feat); @@ -1446,18 +1446,18 @@ static void _connected_flood(int margin, int i, int j, bool taken[GXM][GYM]) } taken[i][j] = true; - for ( int idelta = -1; idelta <= 1; ++idelta ) - for ( int jdelta = -1; jdelta <= 1; ++jdelta ) + for (int idelta = -1; idelta <= 1; ++idelta) + for (int jdelta = -1; jdelta <= 1; ++jdelta) _connected_flood(margin, i + idelta, j + jdelta, taken); } -// yes, yes, this can probably use travel to avoid duplicating code. +// Yes, yes, this can probably use travel to avoid duplicating code. static int _count_connected(int margin) { bool taken[GXM][GYM]; - for ( int i = margin; i < GXM - margin; ++i ) - for ( int j = margin; j < GYM - margin; ++j ) + for (int i = margin; i < GXM - margin; ++i) + for (int j = margin; j < GYM - margin; ++j) { taken[i][j] = (grd[i][j] == DNGN_DEEP_WATER || grd[i][j] == DNGN_SHALLOW_WATER); @@ -1465,9 +1465,9 @@ static int _count_connected(int margin) int count = 0; - for ( int i = margin; i < GXM - margin; ++i ) - for ( int j = margin; j < GYM - margin; ++j ) - if ( !taken[i][j] ) + for (int i = margin; i < GXM - margin; ++i) + for (int j = margin; j < GYM - margin; ++j) + if (!taken[i][j]) { ++count; _connected_flood(margin,i,j,taken); @@ -1501,8 +1501,8 @@ static void _place_base_islands(int margin, int num_islands, int estradius, for (int j = 0; j < i; ++j) { - // calculate the distance from the centers of - // previous islands + // Calculate the distance from the centers of + // previous islands. if ( distance(centres[i].x, centres[i].y, centres[j].x, centres[j].y) < island_distance ) { @@ -1708,7 +1708,7 @@ static void _prepare_swamp() } } } -} // end prepare_swamp() +} // Gives water which is next to ground/shallow water a chance of being // shallow. Checks each water space. @@ -1765,8 +1765,8 @@ static bool _find_in_area(int sx, int sy, int ex, int ey, return (false); } -// stamp a box. can avoid a possible type, and walls and floors can -// be different (or not stamped at all) +// Stamp a box. Can avoid a possible type, and walls and floors can +// be different (or not stamped at all). // Note that the box boundaries are INclusive. static bool _make_box(int room_x1, int room_y1, int room_x2, int room_y2, dungeon_feature_type floor, @@ -1775,11 +1775,11 @@ static bool _make_box(int room_x1, int room_y1, int room_x2, int room_y2, { int bx,by; - // check for avoidance + // Check for avoidance. if (_find_in_area(room_x1, room_y1, room_x2, room_y2, avoid)) - return false; + return (false); - // draw walls + // Draw walls. if (wall != 0) { for (bx = room_x1; bx <= room_x2; bx++) @@ -1794,7 +1794,7 @@ static bool _make_box(int room_x1, int room_y1, int room_x2, int room_y2, } } - // draw floor + // Draw floor. if (floor != 0) { for (bx = room_x1 + 1; bx < room_x2; bx++) @@ -1802,7 +1802,7 @@ static bool _make_box(int room_x1, int room_y1, int room_x2, int room_y2, grd[bx][by] = floor; } - return true; + return (true); } // Take care of labyrinth, abyss, pandemonium. @@ -1833,14 +1833,14 @@ static builder_rc_type _builder_by_type(int level_number, char level_type) int which_demon = -1; // Could do spotty_level, but that doesn't always put all paired // stairs reachable from each other which isn't a problem in normal - // dungeon but could be in Pandemonium + // dungeon but could be in Pandemonium. if (one_chance_in(4)) { do { which_demon = random2(4); - // makes these things less likely as you find more + // Makes these things less likely as you find more. if (one_chance_in(4)) { which_demon = -1; @@ -1882,7 +1882,7 @@ static builder_rc_type _builder_by_type(int level_number, char level_type) return BUILD_SKIP; } - // must be normal dungeon + // Must be normal dungeon. return BUILD_CONTINUE; } @@ -2073,7 +2073,7 @@ static void _place_minivaults(const std::string &tag, int lo, int hi, bool force } } -// returns 1 if we should dispense with city building, +// Returns 1 if we should dispense with city building, // 0 otherwise. Also sets special_room if one is generated // so that we can link it up later. static builder_rc_type _builder_normal(int level_number, char level_type, @@ -2084,7 +2084,7 @@ static builder_rc_type _builder_normal(int level_number, char level_type, bool skipped = false; int vault = _dgn_random_map_for_place(false); - // Can't have vaults on you.where_are_you != BRANCH_MAIN_DUNGEON levels + // Can't have vaults on you.where_are_you != BRANCH_MAIN_DUNGEON levels. if (vault == -1 && use_random_maps && one_chance_in(vault_chance)) @@ -2095,7 +2095,7 @@ static builder_rc_type _builder_normal(int level_number, char level_type, // but only ORIENT: encompass primary vaults in other // branches. Other kinds of vaults can still be placed in // other branches as secondary vaults. - // + if (vault != -1 && !player_in_branch(BRANCH_MAIN_DUNGEON) && map_by_index(vault)->orient != MAP_ENCOMPASS) { @@ -2184,7 +2184,7 @@ static builder_rc_type _builder_normal(int level_number, char level_type, return BUILD_CONTINUE; } -// returns 1 if we should skip extras(), otherwise 0 +// Returns 1 if we should skip extras(), otherwise 0. static builder_rc_type _builder_basic(int level_number) { int temp_rand; @@ -2299,8 +2299,8 @@ static void _builder_extras( int level_number, int level_type ) return; } - //mv: it's better to be here so other dungeon features - // are not overriden by water + //mv: It's better to be here so other dungeon features are not overridden + // by water. dungeon_feature_type river_type = (one_chance_in( 5 + level_number ) ? DNGN_SHALLOW_WATER : DNGN_DEEP_WATER); @@ -2347,16 +2347,17 @@ static bool _shaft_is_in_corridor(int x, int y) if ((!inside_level_bounds(x-1, y) || grd[x-1][y] < DNGN_SHALLOW_WATER) && (!inside_level_bounds(x+1, y) || grd[x+1][y] < DNGN_SHALLOW_WATER)) { - return true; + return (true); } // Now check vertical neighbouring squares. if ((!inside_level_bounds(x, y-1) || grd[x][y-1] < DNGN_SHALLOW_WATER) && (!inside_level_bounds(x, y+1) || grd[x][y+1] < DNGN_SHALLOW_WATER)) { - return true; + return (true); } - // No corridor found. + + // No corridor (found). return false; } @@ -2404,8 +2405,8 @@ static void _place_traps(int level_number) } grd[env.trap[i].x][env.trap[i].y] = DNGN_UNDISCOVERED_TRAP; - } // end "for i" -} // end place_traps() + } +} static void _place_fog_machines(int level_number) { @@ -2527,7 +2528,7 @@ static void _place_branch_entrances(int dlevel, char level_type) player_in_branch(branches[i].parent_branch) && player_branch_depth() == branches[i].startdepth ) { - // place a stair + // Place a stair. #ifdef DEBUG_DIAGNOSTICS mprf(MSGCH_DIAGNOSTICS, "Placing stair to %s", branches[i].shortname); @@ -2726,7 +2727,7 @@ static bool _make_room(int sx,int sy,int ex,int ey,int max_doors, int doorlevel) find_door += _good_door_spot(rx,ey); } - // check left and right for possible doors + // Check left and right for possible doors. for (ry = sy+1; ry < ey; ry++) { find_door += _good_door_spot(sx,ry); @@ -2739,14 +2740,14 @@ static bool _make_room(int sx,int sy,int ex,int ey,int max_doors, int doorlevel) diag_door += _good_door_spot(ex,ey); if ((diag_door + find_door) > 1 && max_doors == 1) - return false; + return (false); if (find_door == 0 || find_door > max_doors) - return false; + return (false); // Look for 'special' rock walls - don't interrupt them. if (_find_in_area(sx,sy,ex,ey,DNGN_BUILDER_SPECIAL_WALL)) - return false; + return (false); // Convert the area to floor. for (rx = sx; rx <= ex; rx++) @@ -2801,8 +2802,8 @@ static bool _make_room(int sx,int sy,int ex,int ey,int max_doors, int doorlevel) } } - return true; -} //end make_room() + return (true); +} static monster_type _pick_unique(int lev) { @@ -2919,6 +2920,7 @@ static void _place_aquatic_monsters(int level_number, char level_type) { if (grd[x][y] == DNGN_LAVA) lava_spaces++; + if (grd[x][y] == DNGN_DEEP_WATER || grd[x][y] == DNGN_SHALLOW_WATER) water_spaces++; } @@ -3453,7 +3455,7 @@ static void _special_room(int level_number, spec_room &sr) } } // end special_room() -// Fills a special room with bees +// Fills a special room with bees. static void _beehive(spec_room &sr) { int x,y; @@ -3578,7 +3580,7 @@ static bool _safe_minivault_place(int v1x, int v1y, static bool _connected_minivault_place(int v1x, int v1y, const vault_placement &place) { - // must not be completely isolated: + // Must not be completely isolated. const bool water_ok = place.map.has_tag("water_ok"); const std::vector<std::string> &lines = place.map.map.get_lines(); @@ -4171,10 +4173,8 @@ bool dgn_place_map(int map, bool generating_level, bool clobber, return (did_map); } -/* - * Places a vault somewhere in an already built level if possible. - * Returns true if the vault was successfully placed. - */ +// Places a vault somewhere in an already built level if possible. +// Returns true if the vault was successfully placed. static bool _build_secondary_vault(int level_number, int vault, int rune_subst, bool generating_level, bool clobber, bool no_exits, @@ -5161,7 +5161,7 @@ static void _place_pool(dungeon_feature_type pool_type, unsigned char pool_x1, int i, j; unsigned char left_edge, right_edge; - // Don't place LAVA pools in crypt.. use shallow water instead. + // Don't place LAVA pools in crypt... use shallow water instead. if (pool_type == DNGN_LAVA && (player_in_branch(BRANCH_CRYPT) || player_in_branch(BRANCH_TOMB))) { @@ -5323,7 +5323,7 @@ static dungeon_feature_type _pick_an_altar() } return (altar_type); -} // end pick_an_altar() +} static void _place_altars() { @@ -5364,7 +5364,7 @@ static void _place_altar() count_feature_in_box(px-2, py-2, px+3, py+3, DNGN_SECRET_DOOR) + count_feature_in_box(px-2, py-2, px+3, py+3, DNGN_FLOOR); - if ( numgood < 5*5 || numfloors == 0 ) + if (numgood < 5*5 || numfloors == 0) continue; bool mon_there = false; @@ -5376,7 +5376,7 @@ static void _place_altar() mon_there = true; } - if ( mon_there ) + if (mon_there) continue; for (int i = px - 2; i <= px + 2; i++) @@ -5386,7 +5386,7 @@ static void _place_altar() grd[px][py] = _pick_an_altar(); break; } -} // end place_altar() +} static void _place_shops(int level_number, int nshops) { @@ -5812,7 +5812,7 @@ static void _bigger_room() j + ((i == 0) ? DNGN_STONE_STAIRS_DOWN_I : DNGN_STONE_STAIRS_UP_I)) ); } -} // end bigger_room() +} // Various plan_xxx functions. static void _plan_main(int level_number, int force_plan) @@ -5860,7 +5860,7 @@ static void _plan_main(int level_number, int force_plan) if (one_chance_in(20)) _replace_area(0, 0, GXM-1, GYM-1, DNGN_ROCK_WALL, special_grid); -} // end plan_main() +} static char _plan_1(int level_number) { @@ -5874,7 +5874,7 @@ static char _plan_1(int level_number) _ensure_vault_placed(success); return 0; -} // end plan_2() +} static char _plan_2(int level_number) { @@ -5888,7 +5888,7 @@ static char _plan_2(int level_number) _ensure_vault_placed(success); return 0; -} // end plan_2() +} static char _plan_3() { @@ -5979,7 +5979,7 @@ static char _plan_3() } return 2; -} // end plan_3() +} // A more chaotic version of city level. static char _plan_4(char forbid_x1, char forbid_y1, char forbid_x2, @@ -6085,7 +6085,7 @@ static char _plan_4(char forbid_x1, char forbid_y1, char forbid_x2, } return 2; -} // end plan_4() +} static char _plan_5() { @@ -6495,7 +6495,7 @@ static void _labyrinth_level(int level_number) _labyrinth_place_entry_point(lab, end); link_items(); -} // end labyrinth_level() +} static bool _is_wall(int x, int y) { @@ -6511,9 +6511,9 @@ static bool _is_wall(int x, int y) case DNGN_CLEAR_ROCK_WALL: case DNGN_CLEAR_STONE_WALL: case DNGN_CLEAR_PERMAROCK_WALL: - return true; + return (true); default: - return false; + return (false); } } @@ -6577,7 +6577,7 @@ static int _box_room_doors( int bx1, int bx2, int by1, int by2, int new_doors) if (new_doors == 0) { - // count # of doors we HAD to place + // Count # of doors we HAD to place. for (i = 0; i < spot_count; i++) if (good_doors[i] == 2) doors_placed++; @@ -6684,7 +6684,7 @@ static void _city_level(int level_number) int temp_rand; // probability determination {dlb} // Remember, can have many wall types in one level. dungeon_feature_type wall_type; - // simplifies logic of innermost loop {dlb} + // Simplifies logic of innermost loop. {dlb} dungeon_feature_type wall_type_room; int xs = 0, ys = 0; @@ -6752,7 +6752,7 @@ static void _city_level(int level_number) : DNGN_STONE_STAIRS_UP_I)) ); } -} // end city_level() +} static bool _treasure_area(int level_number, unsigned char ta1_x, unsigned char ta2_x, unsigned char ta1_y, @@ -6797,7 +6797,7 @@ static void _diamond_rooms(int level_number) int runthru = 0; int i, oblique_max; - // I guess no diamond rooms in either of these places {dlb}: + // I guess no diamond rooms in either of these places. {dlb} if (player_in_branch( BRANCH_DIS ) || player_in_branch( BRANCH_TARTARUS )) return; @@ -6969,7 +6969,7 @@ static void _chequerboard( spec_room &sr, dungeon_feature_type target, if (grd[i][j] == target) grd[i][j] = (((i + j) % 2) ? floor2 : floor1); } -} // end chequerboard() +} static void _roguey_level(int level_number, spec_room &sr, bool make_stairs) { @@ -7585,7 +7585,7 @@ coord_def dgn_find_nearby_stair(dungeon_feature_type stair_to_find, } } - if ( found ) + if (found) return result; // Third pass: look for any clear terrain and abandon the idea of diff --git a/crawl-ref/source/spells2.cc b/crawl-ref/source/spells2.cc index b49ac3f3ce..c7867a2fe6 100644 --- a/crawl-ref/source/spells2.cc +++ b/crawl-ref/source/spells2.cc @@ -90,7 +90,7 @@ unsigned char detect_traps( int pow ) } return (traps_found); -} // end detect_traps() +} unsigned char detect_items( int pow ) { @@ -124,9 +124,9 @@ unsigned char detect_items( int pow ) } return (items_found); -} // end detect_items() +} -static void fuzz_detect_creatures(int pow, int *fuzz_radius, int *fuzz_chance) +static void _fuzz_detect_creatures(int pow, int *fuzz_radius, int *fuzz_chance) { #ifdef DEBUG_DIAGNOSTICS mprf(MSGCH_DIAGNOSTICS, "dc_fuzz: Power is %d", pow); @@ -144,8 +144,8 @@ static void fuzz_detect_creatures(int pow, int *fuzz_radius, int *fuzz_chance) *fuzz_chance = 10; } -static bool mark_detected_creature(int gridx, int gridy, const monsters *mon, - int fuzz_chance, int fuzz_radius) +static bool _mark_detected_creature(int gridx, int gridy, const monsters *mon, + int fuzz_chance, int fuzz_radius) { #ifdef USE_TILE // Get monster index pre-fuzz @@ -193,7 +193,7 @@ int detect_creatures( int pow, bool telepathic ) { int fuzz_radius = 0, fuzz_chance = 0; if (!telepathic) - fuzz_detect_creatures(pow, &fuzz_radius, &fuzz_chance); + _fuzz_detect_creatures(pow, &fuzz_radius, &fuzz_chance); if (pow > 50) pow = 50; @@ -220,7 +220,7 @@ int detect_creatures( int pow, bool telepathic ) // This only returns whether a valid "fuzzy" place has been // found for the monster. In any case, the monster gets // printed on the screen. - mark_detected_creature(i, j, mon, fuzz_chance, fuzz_radius); + _mark_detected_creature(i, j, mon, fuzz_chance, fuzz_radius); // Assuming that highly intelligent spellcasters can // detect scrying. -- bwr @@ -556,8 +556,8 @@ void turn_undead(int pow) typedef std::pair<const monsters*,int> counted_monster; typedef std::vector<counted_monster> counted_monster_list; -static void record_monster_by_name(counted_monster_list &list, - const monsters *mons) +static void _record_monster_by_name(counted_monster_list &list, + const monsters *mons) { const std::string name = mons->name(DESC_PLAIN); for (counted_monster_list::iterator i = list.begin(); i != list.end(); ++i) @@ -571,7 +571,7 @@ static void record_monster_by_name(counted_monster_list &list, list.push_back( counted_monster(mons, 1) ); } -static int monster_count(const counted_monster_list &list) +static int _monster_count(const counted_monster_list &list) { int nmons = 0; for (counted_monster_list::const_iterator i = list.begin(); @@ -582,7 +582,7 @@ static int monster_count(const counted_monster_list &list) return (nmons); } -static std::string describe_monsters(const counted_monster_list &list) +static std::string _describe_monsters(const counted_monster_list &list) { std::ostringstream out; @@ -653,7 +653,7 @@ void cast_toxic_radiance(void) affected = true; if (affected) - record_monster_by_name(affected_monsters, monster); + _record_monster_by_name(affected_monsters, monster); } else if (player_see_invis()) { @@ -668,8 +668,8 @@ void cast_toxic_radiance(void) { const std::string message = make_stringf("%s %s poisoned.", - describe_monsters(affected_monsters).c_str(), - monster_count(affected_monsters) == 1? "is" : "are"); + _describe_monsters(affected_monsters).c_str(), + _monster_count(affected_monsters) == 1? "is" : "are"); if (static_cast<int>(message.length()) < get_number_of_cols() - 2) mpr(message.c_str()); else diff --git a/crawl-ref/source/spells4.cc b/crawl-ref/source/spells4.cc index 7e7f321c62..519ef7401e 100644 --- a/crawl-ref/source/spells4.cc +++ b/crawl-ref/source/spells4.cc @@ -69,8 +69,8 @@ enum DEBRIS // jmf: add for shatter, dig, and Giants to throw NUM_DEBRIS }; // jmf: ...and I'll actually implement the items Real Soon Now... -static int make_a_rot_cloud(int x, int y, int pow, cloud_type ctype); -static int quadrant_blink(int x, int y, int pow, int garbage); +static int _make_a_rot_cloud(int x, int y, int pow, cloud_type ctype); +static int _quadrant_blink(int x, int y, int pow, int garbage); void do_monster_rot(int mon); @@ -100,7 +100,7 @@ inline bool player_hurt_monster(int monster, int damage) } // Here begin the actual spells: -static int shatter_monsters(int x, int y, int pow, int garbage) +static int _shatter_monsters(int x, int y, int pow, int garbage) { UNUSED( garbage ); @@ -195,7 +195,7 @@ static int shatter_monsters(int x, int y, int pow, int garbage) return (damage); } -static int shatter_items(int x, int y, int pow, int garbage) +static int _shatter_items(int x, int y, int pow, int garbage) { UNUSED( pow ); UNUSED( garbage ); @@ -237,7 +237,7 @@ static int shatter_items(int x, int y, int pow, int garbage) return 0; } -static int shatter_walls(int x, int y, int pow, int garbage) +static int _shatter_walls(int x, int y, int pow, int garbage) { UNUSED( garbage ); @@ -348,9 +348,11 @@ void cast_shatter(int pow) int rad = 3 + (you.skills[SK_EARTH_MAGIC] / 5); - apply_area_within_radius(shatter_items, you.x_pos, you.y_pos, pow, rad, 0); - apply_area_within_radius(shatter_monsters, you.x_pos, you.y_pos, pow, rad, 0); - int dest = apply_area_within_radius( shatter_walls, you.x_pos, you.y_pos, + apply_area_within_radius(_shatter_items, you.x_pos, you.y_pos, + pow, rad, 0); + apply_area_within_radius(_shatter_monsters, you.x_pos, you.y_pos, + pow, rad, 0); + int dest = apply_area_within_radius( _shatter_walls, you.x_pos, you.y_pos, pow, rad, 0 ); if (dest && !silence) @@ -415,9 +417,9 @@ void cast_detect_secret_doors(int pow) redraw_screen(); mprf("You detect %s", (found > 0) ? "secret doors!" : "nothing."); -} // end cast_detect_secret_doors() +} -static int sleep_monsters(int x, int y, int pow, int garbage) +static int _sleep_monsters(int x, int y, int pow, int garbage) { UNUSED( garbage ); const int mnstr = mgrd[x][y]; @@ -450,13 +452,13 @@ static int sleep_monsters(int x, int y, int pow, int garbage) void cast_mass_sleep(int pow) { - apply_area_visible(sleep_monsters, pow); + apply_area_visible(_sleep_monsters, pow); } // This is a hack until we set an is_beast flag in the monster data // (which we might never do, this is sort of minor.) // It's a list of monster types which can be affected by beast taming. -static bool is_domesticated_animal(int type) +static bool _is_domesticated_animal(int type) { const monster_type types[] = { MONS_GIANT_BAT, MONS_HOUND, MONS_JACKAL, MONS_RAT, @@ -475,7 +477,7 @@ static bool is_domesticated_animal(int type) return (false); } -static int tame_beast_monsters(int x, int y, int pow, int garbage) +static int _tame_beast_monsters(int x, int y, int pow, int garbage) { UNUSED( garbage ); const int which_mons = mgrd[x][y]; @@ -485,7 +487,7 @@ static int tame_beast_monsters(int x, int y, int pow, int garbage) monsters *monster = &menv[which_mons]; - if (!is_domesticated_animal(monster->type) || mons_friendly(monster) + if (!_is_domesticated_animal(monster->type) || mons_friendly(monster) || player_will_anger_monster(monster)) { return 0; @@ -513,10 +515,10 @@ static int tame_beast_monsters(int x, int y, int pow, int garbage) void cast_tame_beasts(int pow) { - apply_area_visible(tame_beast_monsters, pow); -} // end cast_tame_beasts() + apply_area_visible(_tame_beast_monsters, pow); +} -static int ignite_poison_objects(int x, int y, int pow, int garbage) +static int _ignite_poison_objects(int x, int y, int pow, int garbage) { UNUSED( pow ); UNUSED( garbage ); @@ -563,7 +565,7 @@ static int ignite_poison_objects(int x, int y, int pow, int garbage) return (strength); } -static int ignite_poison_clouds( int x, int y, int pow, int garbage ) +static int _ignite_poison_clouds( int x, int y, int pow, int garbage ) { UNUSED( pow ); UNUSED( garbage ); @@ -594,14 +596,14 @@ static int ignite_poison_clouds( int x, int y, int pow, int garbage ) return did_anything; } -static int ignite_poison_monsters(int x, int y, int pow, int garbage) +static int _ignite_poison_monsters(int x, int y, int pow, int garbage) { UNUSED( garbage ); struct bolt beam; - beam.flavour = BEAM_FIRE; // this is dumb, only used for adjust! + beam.flavour = BEAM_FIRE; // This is dumb, only used for adjust! - dice_def dam_dice( 0, 5 + pow / 7 ); // dice added below if applicable + dice_def dam_dice( 0, 5 + pow / 7 ); // Dice added below if applicable. const int mon_index = mgrd[x][y]; if (mon_index == NON_MONSTER) @@ -609,20 +611,20 @@ static int ignite_poison_monsters(int x, int y, int pow, int garbage) struct monsters *const mon = &menv[ mon_index ]; - // Monsters which have poison corpses or poisonous attacks: + // Monsters which have poison corpses or poisonous attacks. if (is_mons_poisoner(mon)) dam_dice.num = 3; // Monsters which are poisoned: int strength = 0; - // first check for player poison: + // First check for player poison. mon_enchant ench = mon->get_ench(ENCH_POISON); if (ench.ench != ENCH_NONE) strength += ench.degree; - // strength is now the sum of both poison types (although only - // one should actually be present at a given time): + // Strength is now the sum of both poison types + // (although only one should actually be present at a given time). dam_dice.num += strength; int damage = roll_dice( dam_dice ); @@ -654,7 +656,7 @@ void cast_ignite_poison(int pow) char item; bool wasWielding = false; - // temp weapon of venom => temp fire brand + // Temp weapon of venom => temp fire brand. const int wpn = you.equip[EQ_WEAPON]; if (wpn != -1 @@ -685,9 +687,10 @@ void cast_ignite_poison(int pow) if (you.inv[item].base_type == OBJ_MISSILES) { if (you.inv[item].special == 3) - { // burn poison ammo + { + // Burn poison ammo. strength = you.inv[item].quantity; - acount += you.inv[item].quantity; + acount += you.inv[item].quantity; } } @@ -746,7 +749,7 @@ void cast_ignite_poison(int pow) KC_YOU); } - // player is poisonous + // Player is poisonous. if (player_mutation_level(MUT_SPIT_POISON) || player_mutation_level(MUT_STINGER) || you.attribute[ATTR_TRANSFORMATION] == TRAN_SPIDER // poison attack @@ -758,7 +761,7 @@ void cast_ignite_poison(int pow) damage = roll_dice( 3, 5 + pow / 7 ); } - // player is poisoned + // Player is poisoned. damage += roll_dice( you.duration[DUR_POISONING], 6 ); if (damage) @@ -789,9 +792,9 @@ void cast_ignite_poison(int pow) } } - apply_area_visible(ignite_poison_clouds, pow); - apply_area_visible(ignite_poison_objects, pow); - apply_area_visible(ignite_poison_monsters, pow); + apply_area_visible(_ignite_poison_clouds, pow); + apply_area_visible(_ignite_poison_objects, pow); + apply_area_visible(_ignite_poison_monsters, pow); } // end cast_ignite_poison() void cast_silence(int pow) @@ -812,9 +815,9 @@ void cast_silence(int pow) you.duration[DUR_BEHELD] = 0; you.beheld_by.clear(); } -} // end cast_silence() +} -static int discharge_monsters( int x, int y, int pow, int garbage ) +static int _discharge_monsters( int x, int y, int pow, int garbage ) { UNUSED( garbage ); @@ -856,7 +859,7 @@ static int discharge_monsters( int x, int y, int pow, int garbage ) { mpr( "The lightning arcs!" ); pow /= (coinflip() ? 2 : 3); - damage += apply_random_around_square( discharge_monsters, x, y, + damage += apply_random_around_square( _discharge_monsters, x, y, true, pow, 1 ); } else if (damage > 0) @@ -867,14 +870,14 @@ static int discharge_monsters( int x, int y, int pow, int garbage ) } return (damage); -} // end discharge_monsters() +} void cast_discharge( int pow ) { int num_targs = 1 + random2( 1 + pow / 25 ); int dam; - dam = apply_random_around_square( discharge_monsters, you.x_pos, you.y_pos, + dam = apply_random_around_square( _discharge_monsters, you.x_pos, you.y_pos, true, pow, num_targs ); #if DEBUG_DIAGNOSTICS @@ -896,12 +899,12 @@ void cast_discharge( int pow ) coinflip() ? "behind" : "before")); } } -} // end cast_discharge() +} // NB: this must be checked against the same effects // in fight.cc for all forms of attack !!! {dlb} -// This function should be currently unused (the effect is too powerful) -static int distortion_monsters(int x, int y, int pow, int message) +// This function should be currently unused (the effect is too powerful). +static int _distortion_monsters(int x, int y, int pow, int message) { int specdam = 0; int monster_attacked = mgrd[x][y]; @@ -982,11 +985,11 @@ static int distortion_monsters(int x, int y, int pow, int message) player_hurt_monster(monster_attacked, specdam); return (specdam); -} // end distortion_monsters() +} void cast_bend(int pow) { - apply_one_neighbouring_square( distortion_monsters, pow ); + apply_one_neighbouring_square( _distortion_monsters, pow ); } // Really this is just applying the best of Band/Warp weapon/Warp field @@ -1039,7 +1042,7 @@ void cast_dispersal(int pow) } } -static int spell_swap_func(int x, int y, int pow, int message) +static int _spell_swap_func(int x, int y, int pow, int message) { UNUSED( message ); @@ -1077,10 +1080,10 @@ static int spell_swap_func(int x, int y, int pow, int message) void cast_swap(int pow) { - apply_one_neighbouring_square( spell_swap_func, pow ); + apply_one_neighbouring_square( _spell_swap_func, pow ); } -static int make_a_rot_cloud(int x, int y, int pow, cloud_type ctype) +static int _make_a_rot_cloud(int x, int y, int pow, cloud_type ctype) { int next = 0, obj = mgrd[x][y]; @@ -1110,7 +1113,7 @@ static int make_a_rot_cloud(int x, int y, int pow, cloud_type ctype) } return 0; -} // end make_a_rot_cloud() +} int make_a_normal_cloud(int x, int y, int pow, int spread_rate, cloud_type ctype, kill_category whose) @@ -1120,9 +1123,9 @@ int make_a_normal_cloud(int x, int y, int pow, int spread_rate, whose, spread_rate ); return 1; -} // end make_a_normal_cloud() +} -static int passwall(int x, int y, int pow, int garbage) +static int _passwall(int x, int y, int pow, int garbage) { UNUSED( garbage ); @@ -1132,12 +1135,12 @@ static int passwall(int x, int y, int pow, int garbage) int shallow = 1 + (you.skills[SK_EARTH_MAGIC] / 8); bool non_rock_barriers = false; - // allow statues as entry points? + // Irony: you can start on a secret door but not a door. + // Worked stone walls are out, they're not diggable and + // are used for impassable walls... I'm not sure we should + // even allow statues (should be contiguous rock). -- bwr + // XXX: Allow statues as entry points? if (grd[x][y] != DNGN_ROCK_WALL && grd[x][y] != DNGN_CLEAR_ROCK_WALL) - // Irony: you can start on a secret door but not a door. - // Worked stone walls are out, they're not diggable and - // are used for impassable walls... I'm not sure we should - // even allow statues (should be contiguous rock) -- bwr { mpr("That's not a passable wall."); return 0; @@ -1209,24 +1212,23 @@ static int passwall(int x, int y, int pow, int garbage) void cast_passwall(int pow) { - apply_one_neighbouring_square(passwall, pow); -} // end cast_passwall() + apply_one_neighbouring_square(_passwall, pow); +} -static int intoxicate_monsters(int x, int y, int pow, int garbage) +static int _intoxicate_monsters(int x, int y, int pow, int garbage) { UNUSED( pow ); UNUSED( garbage ); int mon = mgrd[x][y]; - if (mon == NON_MONSTER) - return 0; - if (mons_intel(menv[mon].type) < I_NORMAL) - return 0; - if (mons_holiness(&menv[mon]) != MH_NATURAL) - return 0; - if (mons_res_poison(&menv[mon]) > 0) + if (mon == NON_MONSTER + || mons_intel(menv[mon].type) < I_NORMAL + || mons_holiness(&menv[mon]) != MH_NATURAL + || mons_res_poison(&menv[mon]) > 0) + { return 0; + } menv[mon].add_ench(mon_enchant(ENCH_CONFUSION, 0, KC_YOU)); return 1; @@ -1243,7 +1245,7 @@ void cast_intoxicate(int pow) mpr("Your head spins!"); } - apply_area_visible(intoxicate_monsters, pow); + apply_area_visible(_intoxicate_monsters, pow); } bool backlight_monsters(int x, int y, int pow, int garbage) @@ -1278,7 +1280,7 @@ bool backlight_monsters(int x, int y, int pow, int garbage) case MONS_SPECTRAL_THING: case MONS_ORB_OF_FIRE: case MONS_EYE_OF_DEVASTATION: - return (false); // already glowing or invisible + return (false); // Already glowing or invisible. default: break; } @@ -1286,14 +1288,14 @@ bool backlight_monsters(int x, int y, int pow, int garbage) mon_enchant bklt = menv[mon].get_ench(ENCH_BACKLIGHT); const int lvl = bklt.degree; - // this enchantment overrides invisibility (neat) + // This enchantment overrides invisibility (neat). if (menv[mon].has_ench(ENCH_INVIS)) { if (!menv[mon].has_ench(ENCH_BACKLIGHT)) { menv[mon].add_ench( mon_enchant(ENCH_BACKLIGHT, 1, KC_OTHER, random_range(30, 50))); - simple_monster_message( &menv[mon], " is limned in light." ); + simple_monster_message( &menv[mon], " is lined in light." ); } return (true); } @@ -1308,7 +1310,7 @@ bool backlight_monsters(int x, int y, int pow, int garbage) simple_monster_message( &menv[mon], " glows brighter." ); return (true); -} // end backlight_monsters() +} bool cast_evaporate(int pow, bolt& beem, int potion) { @@ -1603,7 +1605,7 @@ void cast_fulsome_distillation( int powc ) mpr( "Unfortunately, you can't carry it right now!" ); } -static int rot_living(int x, int y, int pow, int message) +static int _rot_living(int x, int y, int pow, int message) { UNUSED( message ); @@ -1625,9 +1627,9 @@ static int rot_living(int x, int y, int pow, int message) menv[mon].add_ench( mon_enchant(ENCH_ROT, ench, KC_YOU) ); return 1; -} // end rot_living() +} -static int rot_undead(int x, int y, int pow, int garbage) +static int _rot_undead(int x, int y, int pow, int garbage) { UNUSED( garbage ); @@ -1674,7 +1676,7 @@ static int rot_undead(int x, int y, int pow, int garbage) break; case MONS_ROTTING_HULK: default: - return 0; // immune (no flesh) or already rotting + return 0; // Immune (no flesh) or already rotting. } ench = ((random2(pow) + random2(pow) + random2(pow) + random2(pow)) / 4); @@ -1685,18 +1687,18 @@ static int rot_undead(int x, int y, int pow, int garbage) return 1; } -static int rot_corpses(int x, int y, int pow, int garbage) +static int _rot_corpses(int x, int y, int pow, int garbage) { UNUSED( garbage ); - return make_a_rot_cloud(x, y, pow, CLOUD_MIASMA); + return _make_a_rot_cloud(x, y, pow, CLOUD_MIASMA); } void cast_rotting(int pow) { - apply_area_visible(rot_living, pow); - apply_area_visible(rot_undead, pow); - apply_area_visible(rot_corpses, pow); + apply_area_visible(_rot_living, pow); + apply_area_visible(_rot_undead, pow); + apply_area_visible(_rot_corpses, pow); return; } @@ -1714,7 +1716,7 @@ void do_monster_rot(int mon) return; } -static int snake_charm_monsters(int x, int y, int pow, int message) +static int _snake_charm_monsters(int x, int y, int pow, int message) { UNUSED( message ); @@ -1738,7 +1740,7 @@ static int snake_charm_monsters(int x, int y, int pow, int message) void cast_snake_charm(int pow) { // powc = (you.experience_level * 2) + (you.skills[SK_INVOCATIONS] * 3); - apply_one_neighbouring_square(snake_charm_monsters, pow); + apply_one_neighbouring_square(_snake_charm_monsters, pow); } void cast_fragmentation(int pow) // jmf: ripped idea from airstrike @@ -1760,7 +1762,7 @@ void cast_fragmentation(int pow) // jmf: ripped idea from airstrike return; } - //FIXME: if (player typed '>' to attack floor) goto do_terrain; + //FIXME: If (player typed '>' to attack floor) goto do_terrain; blast.beam_source = MHITYOU; blast.thrower = KILL_YOU; blast.ex_size = 1; // default @@ -1854,7 +1856,7 @@ void cast_fragmentation(int pow) // jmf: ripped idea from airstrike blast.damage.num += 2; break; - case MONS_CLAY_GOLEM: // assume baked clay and not wet loam + case MONS_CLAY_GOLEM: // Assume baked clay and not wet loam. case MONS_STONE_GOLEM: case MONS_EARTH_ELEMENTAL: case MONS_GARGOYLE: @@ -2046,12 +2048,12 @@ void cast_fragmentation(int pow) // jmf: ripped idea from airstrike case DNGN_OPEN_DOOR: case DNGN_CLOSED_DOOR: - // Doors always blow up, stone arches never do (would cause problems) + // Doors always blow up, stone arches never do (would cause problems). if (okay_to_dest) grd[beam.tx][beam.ty] = DNGN_FLOOR; // fall-through - case DNGN_STONE_ARCH: // floor -- small explosion + case DNGN_STONE_ARCH: // Floor -- small explosion. explode = true; hole = false; // to hit monsters standing on doors blast.name = "blast of rock fragments"; @@ -2180,7 +2182,6 @@ bool cast_portal_projectile(int pow) // to have a proper way to do a single weapon strike here (you_attack // does far more than we need or want here)). --bwr // - void cast_far_strike(int pow) { dist targ; @@ -2212,11 +2213,11 @@ void cast_far_strike(int pow) if (you.weapon()) // if not unarmed { const item_def& wpn(*you.weapon()); - // look up the damage base + // Look up the base damage. if (wpn.base_type == OBJ_WEAPONS) { damage = property( wpn, PWPN_DAMAGE ); - speed = property( wpn, PWPN_SPEED ); + speed = property( wpn, PWPN_SPEED ); if (get_weapon_brand(wpn) == SPWPN_SPEED) speed /= 2; @@ -2267,7 +2268,7 @@ void cast_far_strike(int pow) monsters *monster = &menv[ mgrd[targ.tx][targ.ty] ]; - // apply monster's AC + // Apply monster's AC. if (monster->ac > 0) damage -= random2( 1 + monster->ac ); @@ -2283,7 +2284,7 @@ void cast_far_strike(int pow) return; } - // Inflict the damage + // Inflict the damage. hurt_monster( monster, damage ); if (monster->hit_points < 1) monster_die( monster, KILL_YOU, 0 ); @@ -2291,7 +2292,7 @@ void cast_far_strike(int pow) print_wounds( monster ); return; -} // end cast_far_strike() +} int cast_apportation(int pow) { @@ -2363,17 +2364,17 @@ int cast_apportation(int pow) return (0); } - // mass of one unit + // Mass of one unit. const int unit_mass = item_mass( mitm[ item ] ); - // assume we can pull everything + // Assume we can pull everything. int max_units = mitm[ item ].quantity; - // item has mass: might not move all of them + // Item has mass: might not move all of them. if (unit_mass > 0) { const int max_mass = pow * 30 + random2( pow * 20 ); - // most units our power level will allow + // Most units our power level will allow. max_units = max_mass / unit_mass; } @@ -2402,7 +2403,7 @@ int cast_apportation(int pow) } done = 1; - // if we apport a net, free the monster under it + // If we apport a net, free the monster under it. if (mitm[item].base_type == OBJ_MISSILES && mitm[item].sub_type == MI_THROWING_NET && item_is_stationary(mitm[item])) @@ -2464,7 +2465,7 @@ void cast_condensation_shield(int pow) } return; -} // end cast_condensation_shield() +} void remove_divine_shield() { @@ -2503,7 +2504,7 @@ void cast_divine_shield() return; } -static int quadrant_blink(int x, int y, int pow, int garbage) +static int _quadrant_blink(int x, int y, int pow, int garbage) { UNUSED( garbage ); @@ -2531,17 +2532,21 @@ static int quadrant_blink(int x, int y, int pow, int garbage) bool found = false; for ( int i = 0; i < (pow*pow) / 500 + 1; ++i ) { - // find a space near our target... First try to find a random - // square not adjacent to the player, then one adjacent if - // that fails. - if ( !random_near_space(ox, oy, tx, ty) && - !random_near_space(ox, oy, tx, ty, true)) + // Find a space near our target... + // First try to find a random square not adjacent to the player, + // then one adjacent if that fails. + if (!random_near_space(ox, oy, tx, ty) + && !random_near_space(ox, oy, tx, ty, true)) + { return 0; + } - // which is close enough, and also far enough from us - if ( distance(ox, oy, tx, ty) > 10 && - distance(you.x_pos, you.y_pos, tx, ty) < 8 ) + // ... which is close enough, and also far enough from us. + if (distance(ox, oy, tx, ty) > 10 + && distance(you.x_pos, you.y_pos, tx, ty) < 8) + { continue; + } if (!see_grid_no_trans(tx, ty)) continue; @@ -2559,12 +2564,13 @@ static int quadrant_blink(int x, int y, int pow, int garbage) int cast_semi_controlled_blink(int pow) { - return apply_one_neighbouring_square(quadrant_blink, pow); + return apply_one_neighbouring_square(_quadrant_blink, pow); } void cast_stoneskin(int pow) { - if (you.is_undead) + if (you.is_undead + && (you.species != SP_VAMPIRE || you.hunger_state < HS_SATIATED)) { mpr("This spell does not affect your undead flesh."); return; diff --git a/crawl-ref/source/spl-book.cc b/crawl-ref/source/spl-book.cc index aaa7b2d5ed..d644675641 100644 --- a/crawl-ref/source/spl-book.cc +++ b/crawl-ref/source/spl-book.cc @@ -954,7 +954,7 @@ bool is_valid_spell_in_book( int splbook, int spell ) return which_spell_in_book(splbook, spell) != SPELL_NO_SPELL; } -static int which_spellbook( void ) +static int _which_spellbook( void ) { int book = -1; const int avail_levels = player_spell_levels(); @@ -996,7 +996,7 @@ static int which_spellbook( void ) } return (book); -} // end which_spellbook() +} // Returns false if the player cannot read/memorise from the book, // and true otherwise. -- bwr @@ -1222,7 +1222,7 @@ bool learn_spell(int book) } if (book < 0) - book = which_spellbook(); + book = _which_spellbook(); if (book < 0) // still -1? return (false); diff --git a/crawl-ref/source/spl-cast.cc b/crawl-ref/source/spl-cast.cc index a44084f7e7..077177ffca 100644 --- a/crawl-ref/source/spl-cast.cc +++ b/crawl-ref/source/spl-cast.cc @@ -3815,16 +3815,16 @@ int spell_power_colour(spell_type spell) static int _power_to_barcount( int power ) { - if ( power == -1 ) + if (power == -1) return -1; const int breakpoints[] = { 5, 10, 15, 25, 35, 50, 75, 100, 150 }; int result = 0; - for ( unsigned int i = 0; i < ARRAYSZ(breakpoints); ++i ) - if ( power > breakpoints[i] ) + for (unsigned int i = 0; i < ARRAYSZ(breakpoints); ++i) + if (power > breakpoints[i]) ++result; - return result + 1; + return (result + 1); } int spell_power_bars( spell_type spell ) diff --git a/crawl-ref/source/spl-util.cc b/crawl-ref/source/spl-util.cc index d3bca7ef8a..f308ca2f55 100644 --- a/crawl-ref/source/spl-util.cc +++ b/crawl-ref/source/spl-util.cc @@ -53,16 +53,16 @@ static int spell_list[NUM_SPELLS]; #define SPELLDATASIZE (sizeof(spelldata)/sizeof(struct spell_desc)) static struct spell_desc *_seekspell(spell_type spellid); -static bool cloud_helper(int (*func)(int, int, int, int, cloud_type, - kill_category), - int x, int y, int pow, int spread_rate, - cloud_type ctype, kill_category ); +static bool _cloud_helper(int (*func)(int, int, int, int, cloud_type, + kill_category), + int x, int y, int pow, int spread_rate, + cloud_type ctype, kill_category ); -/* - * BEGIN PUBLIC FUNCTIONS - */ +// +// BEGIN PUBLIC FUNCTIONS +// -// all this does is merely refresh the internal spell list {dlb}: +// All this does is merely refresh the internal spell list {dlb}: void init_spell_descs(void) { for (int i = 0; i < NUM_SPELLS; i++) @@ -590,8 +590,8 @@ void apply_area_cloud( int (*func) (int, int, int, int, cloud_type, int dx = 1, dy = 1; bool x_first; - if (clouds_left && cloud_helper(func, x, y, pow, spread_rate, - ctype, whose)) + if (clouds_left && _cloud_helper(func, x, y, pow, spread_rate, + ctype, whose)) clouds_left--; if (!clouds_left) @@ -606,32 +606,32 @@ void apply_area_cloud( int (*func) (int, int, int, int, cloud_type, if (x_first) { - if (clouds_left && cloud_helper(func, x + dx, y, pow, spread_rate, - ctype, whose)) + if (clouds_left && _cloud_helper(func, x + dx, y, pow, spread_rate, + ctype, whose)) { clouds_left--; good_squares++; neighbours[0]++; } - if (clouds_left && cloud_helper(func, x - dx, y, pow, spread_rate, - ctype, whose)) + if (clouds_left && _cloud_helper(func, x - dx, y, pow, spread_rate, + ctype, whose)) { clouds_left--; good_squares++; neighbours[1]++; } - if (clouds_left && cloud_helper(func, x, y + dy, pow, spread_rate, - ctype, whose)) + if (clouds_left && _cloud_helper(func, x, y + dy, pow, spread_rate, + ctype, whose)) { clouds_left--; good_squares++; neighbours[2]++; } - if (clouds_left && cloud_helper(func, x, y - dy, pow, spread_rate, - ctype, whose)) + if (clouds_left && _cloud_helper(func, x, y - dy, pow, spread_rate, + ctype, whose)) { clouds_left--; good_squares++; @@ -640,32 +640,32 @@ void apply_area_cloud( int (*func) (int, int, int, int, cloud_type, } else { - if (clouds_left && cloud_helper(func, x, y + dy, pow, spread_rate, - ctype, whose)) + if (clouds_left && _cloud_helper(func, x, y + dy, pow, spread_rate, + ctype, whose)) { clouds_left--; good_squares++; neighbours[2]++; } - if (clouds_left && cloud_helper(func, x, y - dy, pow, spread_rate, - ctype, whose)) + if (clouds_left && _cloud_helper(func, x, y - dy, pow, spread_rate, + ctype, whose)) { clouds_left--; good_squares++; neighbours[3]++; } - if (clouds_left && cloud_helper(func, x + dx, y, pow, spread_rate, - ctype, whose)) + if (clouds_left && _cloud_helper(func, x + dx, y, pow, spread_rate, + ctype, whose)) { clouds_left--; good_squares++; neighbours[0]++; } - if (clouds_left && cloud_helper(func, x - dx, y, pow, spread_rate, - ctype, whose)) + if (clouds_left && _cloud_helper(func, x - dx, y, pow, spread_rate, + ctype, whose)) { clouds_left--; good_squares++; @@ -673,40 +673,40 @@ void apply_area_cloud( int (*func) (int, int, int, int, cloud_type, } } - // now diagonals; we could randomize dx & dy again here - if (clouds_left && cloud_helper(func, x + dx, y + dy, pow, spread_rate, - ctype, whose)) + // Mow diagonals; we could randomize dx & dy again here. + if (clouds_left && _cloud_helper(func, x + dx, y + dy, pow, spread_rate, + ctype, whose)) { clouds_left--; good_squares++; neighbours[4]++; } - if (clouds_left && cloud_helper(func, x - dx, y + dy, pow, spread_rate, - ctype, whose)) + if (clouds_left && _cloud_helper(func, x - dx, y + dy, pow, spread_rate, + ctype, whose)) { clouds_left--; good_squares++; neighbours[5]++; } - if (clouds_left && cloud_helper(func, x + dx, y - dy, pow, spread_rate, - ctype, whose)) + if (clouds_left && _cloud_helper(func, x + dx, y - dy, pow, spread_rate, + ctype, whose)) { clouds_left--; good_squares++; neighbours[6]++; } - if (clouds_left && cloud_helper(func, x - dx, y - dy, pow, spread_rate, - ctype, whose)) + if (clouds_left && _cloud_helper(func, x - dx, y - dy, pow, spread_rate, + ctype, whose)) { clouds_left--; good_squares++; neighbours[7]++; } - if (!(clouds_left && good_squares)) + if (!clouds_left || !good_squares) return; for (int i = 0; i < 8 && clouds_left; i++) @@ -899,10 +899,10 @@ bool is_valid_spell(spell_type spell) return (spell < NUM_SPELLS && spell_list[spell] != -1); } -static bool cloud_helper(int (*func)(int, int, int, int, cloud_type, - kill_category), - int x, int y, int pow, int spread_rate, - cloud_type ctype, kill_category whose ) +static bool _cloud_helper(int (*func)(int, int, int, int, cloud_type, + kill_category), + int x, int y, int pow, int spread_rate, + cloud_type ctype, kill_category whose ) { if (!grid_is_solid(grd[x][y]) && env.cgrid[x][y] == EMPTY_CLOUD) { |