From 61cae4a761c2f72cda44ae269c7007b37a0c14a7 Mon Sep 17 00:00:00 2001 From: j-p-e-g Date: Thu, 26 Jun 2008 10:39:39 +0000 Subject: Misc. minor cleanups. (Yes, a huge amount of them but still...) git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@6146 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/docs/changes.stone_soup | 2 + crawl-ref/source/abl-show.cc | 12 +- crawl-ref/source/acr.cc | 10 +- crawl-ref/source/beam.cc | 14 +- crawl-ref/source/chardump.cc | 6 +- crawl-ref/source/cio.cc | 3 +- crawl-ref/source/cloud.cc | 20 +-- crawl-ref/source/clua.cc | 2 +- crawl-ref/source/command.cc | 12 +- crawl-ref/source/database.cc | 12 +- crawl-ref/source/debug.cc | 14 +- crawl-ref/source/decks.cc | 128 +++++++++-------- crawl-ref/source/delay.cc | 6 +- crawl-ref/source/describe.cc | 12 +- crawl-ref/source/directn.cc | 12 +- crawl-ref/source/dungeon.cc | 14 +- crawl-ref/source/effects.cc | 16 +-- crawl-ref/source/enum.h | 8 -- crawl-ref/source/fight.cc | 3 +- crawl-ref/source/files.cc | 8 +- crawl-ref/source/food.cc | 37 ++--- crawl-ref/source/guic-win.cc | 37 ++--- crawl-ref/source/guic-x11.cc | 4 +- crawl-ref/source/guic.cc | 72 ++++++---- crawl-ref/source/hiscores.cc | 116 +++++++-------- crawl-ref/source/invent.cc | 35 +++-- crawl-ref/source/it_use3.cc | 24 ++-- crawl-ref/source/item_use.cc | 179 +++++++++++------------ crawl-ref/source/itemname.cc | 25 +--- crawl-ref/source/itemprop.cc | 290 +++++++++++++++++++------------------- crawl-ref/source/items.cc | 82 +++++------ crawl-ref/source/libgui.cc | 20 ++- crawl-ref/source/libutil.cc | 10 +- crawl-ref/source/libw32c.cc | 13 +- crawl-ref/source/libwt.cc | 10 +- crawl-ref/source/luadgn.cc | 12 +- crawl-ref/source/makeitem.cc | 25 ++-- crawl-ref/source/mapdef.cc | 2 +- crawl-ref/source/mapmark.cc | 2 +- crawl-ref/source/maps.cc | 4 +- crawl-ref/source/menu.cc | 140 +++++++++--------- crawl-ref/source/mgrow.cc | 8 +- crawl-ref/source/misc.cc | 20 +-- crawl-ref/source/mon-pick.cc | 8 +- crawl-ref/source/mon-util.cc | 45 +++--- crawl-ref/source/monspeak.cc | 26 ++-- crawl-ref/source/monstuff.cc | 20 +-- crawl-ref/source/mutation.cc | 141 +++++++++--------- crawl-ref/source/newgame.cc | 7 + crawl-ref/source/notes.cc | 14 +- crawl-ref/source/output.cc | 4 +- crawl-ref/source/overmap.cc | 2 +- crawl-ref/source/player.cc | 122 ++++++++-------- crawl-ref/source/quiver.cc | 2 +- crawl-ref/source/randart.cc | 28 ++-- crawl-ref/source/religion.cc | 158 ++++++++++----------- crawl-ref/source/spells1.cc | 30 ++-- crawl-ref/source/spells2.cc | 52 +++---- crawl-ref/source/spells3.cc | 57 ++++---- crawl-ref/source/spl-book.cc | 116 +++++++-------- crawl-ref/source/spl-cast.cc | 14 +- crawl-ref/source/spl-util.cc | 8 +- crawl-ref/source/stash.cc | 65 +++++---- crawl-ref/source/state.cc | 35 ++--- crawl-ref/source/store.cc | 2 +- crawl-ref/source/stuff.cc | 48 +++---- crawl-ref/source/tile2.cc | 12 +- crawl-ref/source/transfor.cc | 4 +- crawl-ref/source/travel.cc | 20 +-- crawl-ref/source/tutorial.cc | 18 +-- crawl-ref/source/view.cc | 167 ++++++++++++---------- 71 files changed, 1386 insertions(+), 1320 deletions(-) diff --git a/crawl-ref/docs/changes.stone_soup b/crawl-ref/docs/changes.stone_soup index 5a069227d4..67fd4a323d 100644 --- a/crawl-ref/docs/changes.stone_soup +++ b/crawl-ref/docs/changes.stone_soup @@ -10,6 +10,7 @@ Highlights ---------- * Many interface improvements. * Greatly improved Tiles. +* Allow all sensible species/class combinations. * Added Vampire species. * Overhaul of the good gods. * Smarter monsters. @@ -58,6 +59,7 @@ Gods Characters ---------- * Added Vampire species. +* Enable all sensible species/class combinations. * Removed Glamour. * Red/White Draconians gain heat/cold resistance at xl 14 (rather than 18). * Mutations: Removed forgetfulness; introduced fur, shouting, +mp/-mp. diff --git a/crawl-ref/source/abl-show.cc b/crawl-ref/source/abl-show.cc index 71374f6498..99ba52f35e 100644 --- a/crawl-ref/source/abl-show.cc +++ b/crawl-ref/source/abl-show.cc @@ -868,17 +868,17 @@ bool activate_ability() mpr("Sorry, you're not good enough to have a special ability."); crawl_state.zero_turns_taken(); - return false; + return (false); } if (you.duration[DUR_CONF]) { talents = your_talents(true); - if ( talents.empty() ) + if (talents.empty()) { mpr("You're too confused!"); crawl_state.zero_turns_taken(); - return false; + return (false); } } @@ -1895,9 +1895,9 @@ static bool _do_ability(const ability_def& abil) case ABIL_RENOUNCE_RELIGION: if (yesno("Really renounce your faith, foregoing its fabulous benefits?", - false, 'n') + false, 'n') && yesno("Are you sure you won't change your mind later?", - false, 'n' )) + false, 'n' )) { excommunication(); } @@ -1911,7 +1911,7 @@ static bool _do_ability(const ability_def& abil) mpr("Sorry, you can't do that."); break; } - return true; + return (true); } static void _pay_ability_costs(const ability_def& abil) diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc index 16ef3c95f9..3da9db5d82 100644 --- a/crawl-ref/source/acr.cc +++ b/crawl-ref/source/acr.cc @@ -836,11 +836,11 @@ static void _handle_wizard_command( void ) dst = trim_string(dst); dst = replace_all(dst, " ", "_"); - if (dst == "") + if (dst.empty()) dst = "bazaar"; - if (find_map_by_name(dst) == -1 && - random_map_for_tag(dst, false) == -1) + if (find_map_by_name(dst) == -1 + && random_map_for_tag(dst, false) == -1) { mprf("No map named '%s' or tagged '%s'.", dst.c_str(), dst.c_str()); @@ -1646,10 +1646,10 @@ static bool _stairs_check_beheld() { mprf("You cannot move away from %s!", menv[you.beheld_by[0]].name(DESC_NOCAP_THE, true).c_str()); - return true; + return (true); } - return false; + return (false); } static void _go_downstairs(); diff --git a/crawl-ref/source/beam.cc b/crawl-ref/source/beam.cc index b5eaa111f8..370b0bb7ad 100644 --- a/crawl-ref/source/beam.cc +++ b/crawl-ref/source/beam.cc @@ -1706,7 +1706,7 @@ static bool _affect_mon_in_wall(bolt &pbolt, item_def *item, int tx, int ty) int mid = mgrd[tx][ty]; if (mid == NON_MONSTER) - return false; + return (false); if (pbolt.is_enchant || (!pbolt.is_explosion && !pbolt.is_big_cloud @@ -1715,10 +1715,10 @@ static bool _affect_mon_in_wall(bolt &pbolt, item_def *item, int tx, int ty) { monsters *mon = &menv[mid]; if (!mons_is_wall_shielded(mon->type)) - return true; + return (true); } - return false; + return (false); } /* @@ -2884,15 +2884,15 @@ void mimic_alert(monsters *mimic) static bool _isBouncy(bolt &beam, unsigned char gridtype) { if (beam.name[0] == '0') - return false; + return (false); if (beam.flavour == BEAM_ELECTRICITY && gridtype != DNGN_METAL_WALL) - return true; + return (true); - if ( (beam.flavour == BEAM_FIRE || beam.flavour == BEAM_COLD) + if ((beam.flavour == BEAM_FIRE || beam.flavour == BEAM_COLD) && gridtype == DNGN_GREEN_CRYSTAL_WALL ) { - return true; + return (true); } return (false); } diff --git a/crawl-ref/source/chardump.cc b/crawl-ref/source/chardump.cc index 9a1eb2f921..359467656d 100644 --- a/crawl-ref/source/chardump.cc +++ b/crawl-ref/source/chardump.cc @@ -363,12 +363,12 @@ static void _sdump_misc(dump_params &par) #define TO_PERCENT(x, y) (100.0f * ((float) (x)) / ((float) (y))) static std::string _sdump_turns_place_info(PlaceInfo place_info, - std::string name = "") + std::string name = "") { PlaceInfo gi = you.global_info; std::string out; - if (name == "") + if (name.empty()) name = place_info.short_name(); float a, b, c, d, e, f; @@ -988,7 +988,7 @@ static std::string _sdump_kills_place_info(PlaceInfo place_info, PlaceInfo gi = you.global_info; std::string out; - if (name == "") + if (name.empty()) name = place_info.short_name(); unsigned int global_total_kills = 0; diff --git a/crawl-ref/source/cio.cc b/crawl-ref/source/cio.cc index 2ffd89f8b7..8dfced98b0 100644 --- a/crawl-ref/source/cio.cc +++ b/crawl-ref/source/cio.cc @@ -331,7 +331,8 @@ void line_reader::cursorto(int ncx) int line_reader::read_line(bool clear_previous) { - if (bufsz <= 0) return false; + if (bufsz <= 0) + return (false); cursor_control coff(true); diff --git a/crawl-ref/source/cloud.cc b/crawl-ref/source/cloud.cc index 324b4c76e8..daaa238c0e 100644 --- a/crawl-ref/source/cloud.cc +++ b/crawl-ref/source/cloud.cc @@ -298,17 +298,19 @@ void place_cloud(cloud_type cl_type, int ctarget_x, bool is_opaque_cloud(unsigned char cloud_idx) { - if ( cloud_idx == EMPTY_CLOUD ) - return false; + if (cloud_idx == EMPTY_CLOUD) + return (false); + const int ctype = env.cloud[cloud_idx].type; - return ( ctype == CLOUD_BLACK_SMOKE || - (ctype >= CLOUD_GREY_SMOKE && ctype <= CLOUD_STEAM) ); + return (ctype == CLOUD_BLACK_SMOKE + || ctype >= CLOUD_GREY_SMOKE && ctype <= CLOUD_STEAM); } cloud_type cloud_type_at(const coord_def &c) { const int cloudno = env.cgrid(c); - return (cloudno == EMPTY_CLOUD? CLOUD_NONE : env.cloud[cloudno].type); + return (cloudno == EMPTY_CLOUD ? CLOUD_NONE + : env.cloud[cloudno].type); } cloud_type random_smoke_type() @@ -675,16 +677,16 @@ void place_fog_machine(fog_machine_data data, int x, int y) bool valid_fog_machine_data(fog_machine_data data) { if (data.fm_type < FM_GEYSER || data.fm_type >= NUM_FOG_MACHINE_TYPES) - return false; + return (false); if (data.cl_type <= CLOUD_NONE || (data.cl_type >= CLOUD_RANDOM && data.cl_type != CLOUD_DEBUGGING)) - return false; + return (false); if (data.size < 1 || data.power < 1) - return false; + return (false); - return true; + return (true); } int num_fogs_for_place(int level_number, const level_id &place) diff --git a/crawl-ref/source/clua.cc b/crawl-ref/source/clua.cc index 90c1cda06f..f9682b8206 100644 --- a/crawl-ref/source/clua.cc +++ b/crawl-ref/source/clua.cc @@ -2546,7 +2546,7 @@ std::string lua_text_pattern::new_fn_name() bool lua_text_pattern::translate() const { if (translated || !isvalid) - return false; + return (false); if (pattern.find("]]") != std::string::npos || pattern.find("[[") != std::string::npos) diff --git a/crawl-ref/source/command.cc b/crawl-ref/source/command.cc index 0365448d36..2e42c2b076 100644 --- a/crawl-ref/source/command.cc +++ b/crawl-ref/source/command.cc @@ -835,7 +835,7 @@ static bool _compare_mon_names(MenuEntry *entry_a, MenuEntry* entry_b) monster_type *b = static_cast( entry_b->data ); if (*a == *b) - return false; + return (false); std::string a_name = mons_type_name(*a, DESC_PLAIN); std::string b_name = mons_type_name(*b, DESC_PLAIN); @@ -850,7 +850,7 @@ static bool _compare_mon_toughness(MenuEntry *entry_a, MenuEntry* entry_b) monster_type *b = static_cast( entry_b->data ); if (*a == *b) - return false; + return (false); int a_toughness = mons_global_level(*a); int b_toughness = mons_global_level(*b); @@ -981,7 +981,7 @@ static std::vector _get_monster_keys(unsigned char showchar) if (me->mc != i) continue; - if (getLongDescription(me->name) == "") + if (getLongDescription(me->name).empty()) continue; if (me->showchar == showchar) @@ -1164,7 +1164,7 @@ static bool _do_description(std::string key, std::string footer = "") clrscr(); print_description(key + desc); - if (footer != "") + if (!footer.empty()) { int num_lines = linebreak_string2(footer, width); num_lines++; @@ -1277,7 +1277,7 @@ static bool _find_description(bool &again, std::string& error_inout) else regex = trimmed_string(buf); - if (regex == "") + if (regex.empty()) { error_inout = "Description must contain at least " "one non-space."; @@ -1297,7 +1297,7 @@ static bool _find_description(bool &again, std::string& error_inout) // Try to get an exact match first. std::string desc = getLongDescription(regex); - if (desc != "") + if (!desc.empty()) exact_match = true; } diff --git a/crawl-ref/source/database.cc b/crawl-ref/source/database.cc index 12eec729e2..2aaa4f8bd5 100644 --- a/crawl-ref/source/database.cc +++ b/crawl-ref/source/database.cc @@ -157,9 +157,9 @@ bool TextDB::_needs_update() const { std::string full_input_path = datafile_path(_input_files[i], true); if (is_newer(full_input_path, full_db_path)) - return true; + return (true); } - return false; + return (false); } void TextDB::_regenerate_db() @@ -407,7 +407,7 @@ static std::string _chooseStrByWeight(std::string entry, int fixed_weight = -1) { // Skip over multiple blank lines, and leading and trailing // blank lines. - while (i < size && lines[i] == "") + while (i < size && lines[i].empty()) i++; if (i == size) @@ -427,7 +427,7 @@ static std::string _chooseStrByWeight(std::string entry, int fixed_weight = -1) total_weight += weight; - while (i < size && lines[i] != "") + while (i < size && !lines[i].empty()) { part += lines[i++]; part += "\n"; @@ -561,9 +561,11 @@ static void _call_recursive_replacement(std::string &str, DBM *database, _getRandomisedStr(database, marker, suffix, num_replacements, recursion_depth); - if (replacement == "") + if (replacement.empty()) + { // Nothing in database, leave it alone and go onto next @foo@ pos = str.find("@", end + 1); + } else { str.replace(pos, marker_full.length(), replacement); diff --git a/crawl-ref/source/debug.cc b/crawl-ref/source/debug.cc index b462a5d3ac..57482ca992 100644 --- a/crawl-ref/source/debug.cc +++ b/crawl-ref/source/debug.cc @@ -776,13 +776,13 @@ static bool _sort_monster_list(int a, int b) if (m1->type == m2->type) { if (!m1->alive() || !m2->alive()) - return false; + return (false); return ( m1->name(DESC_PLAIN, true) < m2->name(DESC_PLAIN, true) ); } if (mons_char(m1->type) < mons_char(m2->type)) - return true; + return (true); return (m1->type < m2->type); } @@ -957,14 +957,14 @@ static void _deck_from_specs(const char* _specs, item_def &item) item.special = DECK_RARITY_COMMON; item.sub_type = NUM_MISCELLANY; - if (type_str != "") + if (!type_str.empty()) { for (int i = 0; types[i] != NUM_MISCELLANY; i++) { item.sub_type = types[i]; item.plus = 1; init_deck(item); - // Remove "plain " from front + // Remove "plain " from front. std::string name = item.name(DESC_PLAIN).substr(6); item.props.clear(); @@ -1083,17 +1083,17 @@ static bool _book_from_spell(const char* specs, item_def &item) spell_type type = spell_by_name(specs, true); if (type == SPELL_NO_SPELL) - return false; + return (false); for (int i = 0; i < NUM_BOOKS; i++) for (int j = 0; j < 8; j++) if (which_spell_in_book(i, j) == type) { item.sub_type = i; - return true; + return (true); } - return false; + return (false); } //--------------------------------------------------------------- diff --git a/crawl-ref/source/decks.cc b/crawl-ref/source/decks.cc index ff4fecc5f2..12b1cf1aa5 100644 --- a/crawl-ref/source/decks.cc +++ b/crawl-ref/source/decks.cc @@ -443,8 +443,10 @@ static void _push_top_card(item_def& deck, card_type card, static bool _wielding_deck() { - if ( you.equip[EQ_WEAPON] == -1 ) - return false; + // Nothing wielded? + if (you.equip[EQ_WEAPON] == -1) + return (false); + return is_deck(you.inv[you.equip[EQ_WEAPON]]); } @@ -456,7 +458,7 @@ static void _remember_drawn_card(item_def& deck, card_type card) drawn.push_back( static_cast(card) ); // Once you've drawn two cards, you know the deck. - if ( drawn.size() >= 2 ) + if (drawn.size() >= 2) _deck_ident(deck); } @@ -483,7 +485,7 @@ static bool _check_buggy_deck(item_def& deck) { crawl_state.zero_turns_taken(); strm << "This isn't a deck at all!" << std::endl; - return true; + return (true); } CrawlHashTable &props = deck.props; @@ -532,7 +534,7 @@ static bool _check_buggy_deck(item_def& deck) dec_inv_item_quantity( deck.link, 1 ); did_god_conduct(DID_CARDS, 1); - return true; + return (true); } bool problems = false; @@ -592,7 +594,7 @@ static bool _check_buggy_deck(item_def& deck) dec_inv_item_quantity( deck.link, 1 ); did_god_conduct(DID_CARDS, 1); - return true; + return (true); } if (static_cast(num_cards) > deck.plus) @@ -602,8 +604,10 @@ static bool _check_buggy_deck(item_def& deck) else if (deck.plus < 0) strm << "Deck was created with *negative* cards?!" << std::endl; else + { strm << "Deck has more cards than it was created with?" << std::endl; + } deck.plus = num_cards; problems = true; @@ -691,7 +695,7 @@ static bool _check_buggy_deck(item_def& deck) } if (!problems) - return false; + return (false); you.wield_change = true; @@ -699,9 +703,9 @@ static bool _check_buggy_deck(item_def& deck) "still use deck?", true, 'n')) { crawl_state.zero_turns_taken(); - return true; + return (true); } - return false; + return (false); } // Choose a deck from inventory and return its slot (or -1). @@ -729,14 +733,14 @@ bool choose_deck_and_draw() { const int slot = _choose_inventory_deck( "Draw from which deck?" ); - if ( slot == -1 ) + if (slot == -1) { crawl_state.zero_turns_taken(); - return false; + return (false); } evoke_deck(you.inv[slot]); - return true; + return (true); } static void _deck_ident(item_def& deck) @@ -773,17 +777,17 @@ static void _deck_lose_card(item_def& deck) bool deck_peek() { const int slot = _choose_inventory_deck( "Peek at which deck?" ); - if ( slot == -1 ) + if (slot == -1) { crawl_state.zero_turns_taken(); - return false; + return (false); } item_def& deck(you.inv[slot]); if (_check_buggy_deck(deck)) - return false; + return (false); - if ( cards_in_deck(deck) > 2 ) + if (cards_in_deck(deck) > 2) { _deck_lose_card(deck); mpr("A card falls out of the deck."); @@ -806,7 +810,7 @@ bool deck_peek() deck.plus2 = -1; you.wield_change = true; - return true; + return (true); } card2 = get_card_and_flags(deck, 1, flags2); @@ -834,7 +838,7 @@ bool deck_peek() _deck_ident(deck); you.wield_change = true; - return true; + return (true); } // Mark a deck: look at the next four cards, mark them, and shuffle @@ -845,32 +849,33 @@ bool deck_peek() bool deck_mark() { const int slot = _choose_inventory_deck( "Mark which deck?" ); - if ( slot == -1 ) + if (slot == -1) { crawl_state.zero_turns_taken(); - return false; + return (false); } item_def& deck(you.inv[slot]); if (_check_buggy_deck(deck)) - return false; + return (false); CrawlHashTable &props = deck.props; if (props["num_marked"].get_byte() > 0) { mpr("The deck is already marked."); crawl_state.zero_turns_taken(); - return false; + return (false); } // Lose some cards, but keep at least two. - if ( cards_in_deck(deck) > 2 ) + if (cards_in_deck(deck) > 2) { const int num_lost = std::min(cards_in_deck(deck)-2, random2(3) + 1); - for ( int i = 0; i < num_lost; ++i ) + for (int i = 0; i < num_lost; ++i) _deck_lose_card(deck); - if ( num_lost == 1 ) + + if (num_lost == 1) mpr("A card falls out of the deck."); - else if ( num_lost > 1 ) + else if (num_lost > 1) mpr("Some cards fall out of the deck."); } @@ -883,7 +888,7 @@ bool deck_mark() mprf("The deck only has %d cards.", num_cards); std::vector names; - for ( int i = 0; i < num_to_mark; ++i ) + for (int i = 0; i < num_to_mark; ++i) { unsigned char flags; card_type card = get_card_and_flags(deck, i, flags); @@ -910,7 +915,7 @@ bool deck_mark() _deck_ident(deck); you.wield_change = true; - return true; + return (true); } static void _redraw_stacked_cards(const std::vector& draws, @@ -918,7 +923,7 @@ static void _redraw_stacked_cards(const std::vector& draws, { for (unsigned int i = 0; i < draws.size(); ++i) { - cgotoxy(1,i+2); + cgotoxy(1, i+2); textcolor(selected == i ? WHITE : LIGHTGREY); cprintf("%u - %s", i+1, card_name(draws[i]) ); clear_to_end_of_line(); @@ -932,22 +937,22 @@ static void _redraw_stacked_cards(const std::vector& draws, bool deck_stack() { cursor_control con(false); - if ( !_wielding_deck() ) + if (!_wielding_deck()) { mpr("You aren't wielding a deck!"); crawl_state.zero_turns_taken(); - return false; + return (false); } item_def& deck(you.inv[you.equip[EQ_WEAPON]]); if (_check_buggy_deck(deck)) - return false; + return (false); CrawlHashTable &props = deck.props; if (props["num_marked"].get_byte() > 0) { mpr("You can't stack a marked deck."); crawl_state.zero_turns_taken(); - return false; + return (false); } const int num_cards = cards_in_deck(deck); @@ -955,7 +960,7 @@ bool deck_stack() std::vector draws; std::vector flags; - for ( int i = 0; i < num_cards; ++i ) + for (int i = 0; i < num_cards; ++i) { unsigned char _flags; card_type card = _draw_top_card(deck, false, _flags); @@ -965,22 +970,23 @@ bool deck_stack() draws.push_back(card); flags.push_back(_flags | CFLAG_SEEN | CFLAG_MARKED); } - else - ; // Rest of deck is discarded. + // Rest of deck is discarded. } - if ( num_cards == 1 ) + if (num_cards == 1) mpr("There's only one card left!"); else if (num_cards < 5) mprf("The deck only has %d cards.", num_to_stack); else if (num_cards == 5) mpr("The deck has exactly five cards."); else + { mprf("You draw the first five cards out of %d and discard the rest.", num_cards); + } more(); - if ( draws.size() > 1 ) + if (draws.size() > 1) { unsigned int selected = draws.size(); clrscr(); @@ -1002,7 +1008,7 @@ bool deck_stack() cgotoxy(1,11); textcolor(LIGHTGREY); cprintf("Are you sure? (press y or Y to confirm)"); - if ( toupper(getch()) == 'Y' ) + if (toupper(getch()) == 'Y') break; cgotoxy(1,11); clear_to_end_of_line(); @@ -1028,7 +1034,7 @@ bool deck_stack() } deck.plus2 = -num_to_stack; - for ( unsigned int i = 0; i < draws.size(); ++i ) + for (unsigned int i = 0; i < draws.size(); ++i) { _push_top_card(deck, draws[draws.size() - 1 - i], flags[flags.size() - 1 - i]); @@ -1039,38 +1045,38 @@ bool deck_stack() _check_buggy_deck(deck); - return true; + return (true); } // Draw the next three cards, discard two and pick one. bool deck_triple_draw() { const int slot = _choose_inventory_deck("Triple draw from which deck?"); - if ( slot == -1 ) + if (slot == -1) { crawl_state.zero_turns_taken(); - return false; + return (false); } item_def& deck(you.inv[slot]); if (_check_buggy_deck(deck)) - return false; + return (false); const int num_cards = cards_in_deck(deck); if (num_cards == 1) { - // only one card to draw, so just draw it + // Only one card to draw, so just draw it. evoke_deck(deck); - return true; + return (true); } const int num_to_draw = (num_cards < 3 ? num_cards : 3); std::vector draws; std::vector flags; - for ( int i = 0; i < num_to_draw; ++i ) + for (int i = 0; i < num_to_draw; ++i) { unsigned char _flags; card_type card = _draw_top_card(deck, false, _flags); @@ -1080,13 +1086,13 @@ bool deck_triple_draw() } mpr("You draw... (choose one card)"); - for ( int i = 0; i < num_to_draw; ++i ) + for (int i = 0; i < num_to_draw; ++i) { msg::streams(MSGCH_PROMPT) << (static_cast(i + 'a')) << " - " << card_name(draws[i]) << std::endl; } int selected = -1; - while ( true ) + while (true) { const int keyin = tolower(get_ch()); if (keyin >= 'a' && keyin < 'a' + num_to_draw) @@ -1100,7 +1106,7 @@ bool deck_triple_draw() // Note how many cards were removed from the deck. deck.plus2 += num_to_draw; - for ( int i = 0; i < num_to_draw; ++i ) + for (int i = 0; i < num_to_draw; ++i) _remember_drawn_card(deck, draws[i]); you.wield_change = true; @@ -1110,7 +1116,7 @@ bool deck_triple_draw() if (cards_in_deck(deck) == 0) { mpr("The deck of cards disappears in a puff of smoke."); - if ( slot == you.equip[EQ_WEAPON] ) + if (slot == you.equip[EQ_WEAPON]) unwield_item(); dec_inv_item_quantity( slot, 1 ); @@ -1119,7 +1125,7 @@ bool deck_triple_draw() // Note that card_effect() might cause you to unwield the deck. card_effect(draws[selected], rarity, flags[selected], false); - return true; + return (true); } // This is Nemelex retribution. @@ -2304,7 +2310,7 @@ static bool _trowel_card(int power, deck_rarity_type rarity) if (is_critical_feature(grd[you.x_pos][you.y_pos])) { mpr("The dungeon trembles momentarily."); - return false; + return (false); } const int power_level = get_power_level(power, rarity); @@ -2327,7 +2333,7 @@ static bool _trowel_card(int power, deck_rarity_type rarity) } done_stuff = true; } - else if ( power_level == 1 ) + else if (power_level == 1) { if (coinflip()) { @@ -2881,7 +2887,7 @@ bool card_effect(card_type which_card, deck_rarity_type rarity, bool top_card_is_known(const item_def &deck) { if (!is_deck(deck)) - return false; + return (false); unsigned char flags; get_card_and_flags(deck, -1, flags); @@ -2892,27 +2898,27 @@ bool top_card_is_known(const item_def &deck) card_type top_card(const item_def &deck) { if (!is_deck(deck)) - return NUM_CARDS; + return (NUM_CARDS); unsigned char flags; card_type card = get_card_and_flags(deck, -1, flags); UNUSED(flags); - return card; + return (card); } bool is_deck(const item_def &item) { - return item.base_type == OBJ_MISCELLANY - && (item.sub_type >= MISC_DECK_OF_ESCAPE && - item.sub_type <= MISC_DECK_OF_DEFENCE); + return (item.base_type == OBJ_MISCELLANY + && item.sub_type >= MISC_DECK_OF_ESCAPE + && item.sub_type <= MISC_DECK_OF_DEFENCE); } bool bad_deck(const item_def &item) { if (!is_deck(item)) - return false; + return (false); return (!item.props.exists("cards") || item.props["cards"].get_type() != SV_VEC diff --git a/crawl-ref/source/delay.cc b/crawl-ref/source/delay.cc index 905bf00048..52d5dac604 100644 --- a/crawl-ref/source/delay.cc +++ b/crawl-ref/source/delay.cc @@ -1603,7 +1603,7 @@ static bool _should_stop_activity(const delay_queue_item &item, if (ai == AI_SEE_MONSTER && (curr == DELAY_ASCENDING_STAIRS || curr == DELAY_DESCENDING_STAIRS)) { - return false; + return (false); } if (ai == AI_FULL_HP || ai == AI_FULL_MP) @@ -1620,7 +1620,7 @@ static bool _should_stop_activity(const delay_queue_item &item, && (you.magic_points < you.max_magic_points || you.hp < you.hp_max)) { - return false; + return (false); } } @@ -1738,7 +1738,7 @@ bool interrupt_activity( activity_interrupt_type ai, const activity_interrupt_data &at ) { if (_interrupts_blocked > 0) - return false; + return (false); _paranoid_option_disable(ai, at); diff --git a/crawl-ref/source/describe.cc b/crawl-ref/source/describe.cc index 90f5b2c6f4..f472fc12dc 100644 --- a/crawl-ref/source/describe.cc +++ b/crawl-ref/source/describe.cc @@ -1592,7 +1592,7 @@ std::string get_item_description( const item_def &item, bool verbose, std::string db_desc = getLongDescription(db_name, is_artefact(item)); - if (db_desc == "") + if (db_desc.empty()) { if (item_type_known(item)) { @@ -2460,7 +2460,7 @@ static bool _print_god_abil_desc( int god, int numpower ) std::ostringstream buf; - if ( isupper(pmsg[0]) ) + if (isupper(pmsg[0])) buf << pmsg; // Complete sentence given. else buf << "You can " << pmsg << "."; @@ -2476,7 +2476,7 @@ static bool _print_god_abil_desc( int god, int numpower ) } cprintf( "%s\n", buf.str().c_str() ); - return true; + return (true); } static std::string _describe_favour_generic(god_type which_god) @@ -2544,8 +2544,9 @@ static std::string _religion_help( god_type god ) if (!player_under_penance() && you.piety > 160 && !you.num_gifts[god]) { - if (result != "") + if (!result.empty()) result += " "; + result += "You can pray at an altar to have your weapon " "blessed, especially a long sword."; } @@ -2580,8 +2581,9 @@ static std::string _religion_help( god_type god ) if (god_likes_butchery(god)) { - if (result != "") + if (!result.empty()) result += " "; + result += "You can sacrifice corpses by dissecting" " them during prayer."; } diff --git a/crawl-ref/source/directn.cc b/crawl-ref/source/directn.cc index c0862fdda5..7b787fa0fa 100644 --- a/crawl-ref/source/directn.cc +++ b/crawl-ref/source/directn.cc @@ -255,7 +255,7 @@ static void draw_ray_glyph(const coord_def &pos, int colour, static bool _mon_submerged_in_water(const monsters *mon) { if (!mon) - return false; + return (false); return (grd[mon->x][mon->y] == DNGN_SHALLOW_WATER && see_grid(mon->x, mon->y) @@ -265,9 +265,9 @@ static bool _mon_submerged_in_water(const monsters *mon) static bool _is_target_in_range(int x, int y, int range) { - // range doesn't matter + // Range doesn't matter. if (range == -1) - return true; + return (true); return (grid_distance(you.x_pos, you.y_pos, x, y) <= range); } @@ -1367,14 +1367,14 @@ static bool _find_monster( int x, int y, int mode, bool need_path, // Now compare target modes. if (mode == TARG_ANY) - return true; + return (true); if (mode == TARG_FRIEND) return (mons_friendly(&menv[targ_mon] )); ASSERT(mode == TARG_ENEMY); if (mons_friendly(&menv[targ_mon])) - return false; + return (false); // Don't target zero xp monsters, unless target_zero_exp is set. return (Options.target_zero_exp @@ -1407,7 +1407,7 @@ static bool _find_object(int x, int y, int mode, const int item = igrd[x][y]; if (item == NON_ITEM && !is_mimic) - return false; + return (false); return (in_los(x, y) || Options.target_oos && is_terrain_seen(x, y) && (is_stash(x, y) || is_mimic)); diff --git a/crawl-ref/source/dungeon.cc b/crawl-ref/source/dungeon.cc index fc7a5cfcc4..3aee3dde2f 100644 --- a/crawl-ref/source/dungeon.cc +++ b/crawl-ref/source/dungeon.cc @@ -6164,7 +6164,7 @@ bool octa_room(spec_room &sr, int oblique_max, { for (y = sr.y1 + oblique; y < sr.y2 - oblique; y++) if (grd[x][y] == DNGN_BUILDER_SPECIAL_WALL) - return false; + return (false); if (oblique > 0) oblique--; @@ -6197,7 +6197,7 @@ bool octa_room(spec_room &sr, int oblique_max, oblique += 2; } - return true; + return (true); } static void _find_maze_neighbours(const coord_def &c, @@ -6756,10 +6756,10 @@ static bool _treasure_area(int level_number, unsigned char ta1_x, ta2_y++; if (ta2_x <= ta1_x || ta2_y <= ta1_y) - return false; + return (false); if ((ta2_x - ta1_x) * (ta2_y - ta1_y) >= 40) - return false; + return (false); for (x_count = ta1_x; x_count < ta2_x; x_count++) for (y_count = ta1_y; y_count < ta2_y; y_count++) @@ -6777,7 +6777,7 @@ static bool _treasure_area(int level_number, unsigned char ta1_x, } } - return true; + return (true); } static void _diamond_rooms(int level_number) @@ -7606,8 +7606,8 @@ coord_def dgn_find_nearby_stair(dungeon_feature_type stair_to_find, void dgn_set_lt_callback(std::string level_type_name, std::string callback_name) { - ASSERT(level_type_name != ""); - ASSERT(callback_name != ""); + ASSERT(!level_type_name.empty()); + ASSERT(!callback_name.empty()); level_type_post_callbacks[level_type_name] = callback_name; } diff --git a/crawl-ref/source/effects.cc b/crawl-ref/source/effects.cc index d680b97445..10ad2a1cb9 100644 --- a/crawl-ref/source/effects.cc +++ b/crawl-ref/source/effects.cc @@ -414,7 +414,7 @@ void banished(dungeon_feature_type gate_type, const std::string &who) if (!crawl_state.is_god_acting()) you.entry_cause_god = GOD_NO_GOD; - if (cast_into != "" && you.entry_cause != EC_SELF_EXPLICIT) + if (!cast_into.empty() && you.entry_cause != EC_SELF_EXPLICIT) { const std::string what = "Cast into " + cast_into + _who_banished(who); take_note(Note(NOTE_MESSAGE, 0, 0, what.c_str()), true); @@ -2253,38 +2253,36 @@ static void _hell_effects() create_monster(mg); for (int i = 0; i < 4; ++i) - { if (one_chance_in(3)) create_monster(mg); - } } } static bool _food_item_needs_time_check(item_def &item) { if (!is_valid_item(item)) - return false; + return (false); if (item.base_type != OBJ_CORPSES && item.base_type != OBJ_FOOD && item.base_type != OBJ_POTIONS) { - return false; + return (false); } if (item.base_type == OBJ_CORPSES && item.sub_type > CORPSE_SKELETON) { - return false; + return (false); } if (item.base_type == OBJ_FOOD && item.sub_type != FOOD_CHUNK) - return false; + return (false); if (item.base_type == OBJ_POTIONS && !is_blood_potion(item)) - return false; + return (false); - return true; + return (true); } static void _rot_inventory_food(long time_delta) diff --git a/crawl-ref/source/enum.h b/crawl-ref/source/enum.h index 8b9f3ff2e9..f9b3878b13 100644 --- a/crawl-ref/source/enum.h +++ b/crawl-ref/source/enum.h @@ -2799,14 +2799,6 @@ enum montravel_target_type MTRAV_SUBMERSIBLE // Travelling to reach a submersible place. }; -enum char_choice_restriction -{ - CC_BANNED = 0, - CC_RESTRICTED, - CC_UNRESTRICTED -}; - - #ifndef USE_TILE enum mlist_targetting_type { diff --git a/crawl-ref/source/fight.cc b/crawl-ref/source/fight.cc index 1c702548ac..6280043cdd 100644 --- a/crawl-ref/source/fight.cc +++ b/crawl-ref/source/fight.cc @@ -2356,7 +2356,8 @@ bool melee_attack::apply_damage_brand() } } - obvious_effect = obvious_effect || (special_damage_message != ""); + if (!obvious_effect) + obvious_effect = !special_damage_message.empty(); if (obvious_effect && attacker_visible && weapon != NULL && !is_artefact(*weapon)) diff --git a/crawl-ref/source/files.cc b/crawl-ref/source/files.cc index 50354f5ab9..e20fefc3b9 100644 --- a/crawl-ref/source/files.cc +++ b/crawl-ref/source/files.cc @@ -768,7 +768,7 @@ bool travel_load_map( branch_type branch, int absdepth ) FILE *levelFile = fopen(make_filename(you.your_name, absdepth, branch, LEVEL_DUNGEON, false).c_str(), "rb"); if (!levelFile) - return false; + return (false); char majorVersion; char minorVersion; @@ -776,14 +776,14 @@ bool travel_load_map( branch_type branch, int absdepth ) if (!_get_and_validate_version( levelFile, majorVersion, minorVersion )) { fclose(levelFile); - return false; + return (false); } tag_read(levelFile, minorVersion); fclose( levelFile ); - return true; + return (true); } static void _sanity_test_monster_inventory() @@ -1729,7 +1729,7 @@ static bool _determine_ghost_version( FILE *ghostFile, // Read first two bytes. char buf[2]; if (read2(ghostFile, buf, 2) != 2) - return false; // empty file? + return (false); // empty file? // Otherwise, read version and validate. majorVersion = buf[0]; diff --git a/crawl-ref/source/food.cc b/crawl-ref/source/food.cc index 81c2d16a18..07e8740533 100644 --- a/crawl-ref/source/food.cc +++ b/crawl-ref/source/food.cc @@ -220,12 +220,12 @@ static bool _find_butchering_implement( bool fallback ) { mpr("Switching to a butchering implement."); wield_weapon( true, i, false ); - return true; + return (true); } } if (!fallback) - return false; + return (false); // If we didn't swap above, then we still can't cut...let's call // wield_weapon() in the "prompt the user" way... @@ -327,7 +327,7 @@ static bool _butcher_corpse(int corpse_id, bool force_butcher = false) } you.turn_is_over = true; - return true; + return (true); } static void _terminate_butchery(bool wpn_switch, bool removed_gloves, @@ -685,9 +685,10 @@ static bool _userdef_eat_food() bool ret = clua.callfn("c_eat", 2, 0); if (!ret && clua.error.length()) mpr(clua.error.c_str()); - return ret; + + return (ret); #else - return false; + return (false); #endif } @@ -2024,7 +2025,7 @@ bool can_ingest(int what_isit, int kindof_thing, bool suppress_msg, bool reqid, { if (!suppress_msg) mpr("Blech - you need blood!"); - return false; + return (false); } int vorous = _player_likes_food_type(kindof_thing); @@ -2105,37 +2106,37 @@ bool can_ingest(int what_isit, int kindof_thing, bool suppress_msg, bool reqid, { if (!suppress_msg) mpr("Urks, you're a herbivore!"); - return false; + return (false); } - return true; + return (true); case POT_WATER: if (you.species == SP_VAMPIRE) { if (!suppress_msg) mpr("Blech - you need blood!"); - return false; + return (false); } - return true; + return (true); case POT_PORRIDGE: if (you.species == SP_VAMPIRE) { if (!suppress_msg) mpr("Blech - you need blood!"); - return false; + return (false); } else if (ur_carnivorous) { if (!suppress_msg) mpr("Sorry, you're a carnivore."); - return false; + return (false); } default: - return true; + return (true); } - // other object types are set to return false for now until + // Other object types are set to return false for now until // someone wants to recode the eating code to permit consumption - // of things other than just food + // of things other than just food. default: return (false); } @@ -2263,13 +2264,13 @@ static bool _vampire_consume_corpse(const int slot, bool invent) if (!mons_has_blood(corpse.plus)) { mpr( "There is no blood in this body!" ); - return false; + return (false); } if (food_is_rotten(corpse)) { mpr("It's not fresh enough."); - return false; + return (false); } // The delay for eating a chunk (mass 1000) is 2 @@ -2282,7 +2283,7 @@ static bool _vampire_consume_corpse(const int slot, bool invent) start_delay( DELAY_FEED_VAMPIRE, 1 + chunk_amount/2, (int) invent, slot ); - return true; + return (true); } static void _heal_from_food(int hp_amt, int mp_amt, bool unrot, diff --git a/crawl-ref/source/guic-win.cc b/crawl-ref/source/guic-win.cc index ba7208128b..bc8b2a50c0 100644 --- a/crawl-ref/source/guic-win.cc +++ b/crawl-ref/source/guic-win.cc @@ -42,10 +42,10 @@ bool GuicInit(HINSTANCE h, int nCmd) for (i = 0; i < MAX_TERM_COL; i++) { - int *c = (int *)&term_colors[i]; + int *c = (int *)&term_colors[i]; term_pix[i] = PALETTERGB( c[0], c[1], c[2] ); } - return true; + return (true); } void GuicDeinit() @@ -518,11 +518,11 @@ BOOL WinClass::create(const char *name) HWND_DESKTOP, NULL, hInst, NULL); ShowWindow( hWnd, nCmdShow ); } - if ( !hWnd ) - return FALSE; + if (!hWnd) + return (FALSE); clear(); - return TRUE; + return (TRUE); } void WinClass::move() @@ -653,23 +653,23 @@ void MapRegionClass::draw_data(unsigned char *buf, bool show_mark, force_redraw = false; } -/* XXXXX - * img_type related - */ +// +// img_type related +// LPBYTE dib_ref_pixel(dib_pack* dib, int x, int y) { int w = ((3 + dib->Width)/4)*4; LPBYTE ref = dib->pDibBits + x + (dib->Height -1 -y) * w; - return ref; + return (ref); } bool ImgIsTransparentAt(img_type img, int x, int y) { if (pix_transparent == *( dib_ref_pixel(img, x, y) )) - return true; + return (true); - return false; + return (false); } void ImgSetTransparentPix(img_type img) { @@ -692,7 +692,7 @@ img_type ImgCreateSimple(int wx, int wy) ptr->hDib = NULL; ptr->hDC = NULL; - return ptr; + return (ptr); } void ImgDestroy(img_type img) @@ -700,9 +700,14 @@ void ImgDestroy(img_type img) if (!img) return; - if (img->pDib) GlobalFree(img->pDib); - if (img->hDC) DeleteDC (img->hDC); - if (img->hDib) DeleteObject(img->hDib); + if (img->pDib) + GlobalFree(img->pDib); + + if (img->hDC) + DeleteDC(img->hDC); + + if (img->hDib) + DeleteObject(img->hDib); GlobalFree(img); } @@ -724,7 +729,7 @@ img_type ImgLoadFile(const char *name) if (fh == INVALID_HANDLE_VALUE) return NULL; - SetFilePointer(fh,0,NULL,FILE_BEGIN); + SetFilePointer(fh, 0, NULL, FILE_BEGIN); if (!ReadFile(fh,&bmHead, sizeof(BITMAPFILEHEADER), &dummy, NULL)) return NULL; diff --git a/crawl-ref/source/guic-x11.cc b/crawl-ref/source/guic-x11.cc index 632deea5a4..9093600d59 100644 --- a/crawl-ref/source/guic-x11.cc +++ b/crawl-ref/source/guic-x11.cc @@ -825,7 +825,7 @@ bool GuicInit(Display **d, int *s) if (!display) { fprintf(stderr,"Cannot open display\n"); - return false; + return (false); } screen=DefaultScreen(display); @@ -854,7 +854,7 @@ bool GuicInit(Display **d, int *s) pix_hilite = term_pix[PIX_LIGHTMAGENTA] ; pix_rimcolor = create_pixel(1,1,1); - return true; + return (true); } void GuicDeinit() diff --git a/crawl-ref/source/guic.cc b/crawl-ref/source/guic.cc index c21f24a581..3e0aa4e1c3 100644 --- a/crawl-ref/source/guic.cc +++ b/crawl-ref/source/guic.cc @@ -348,15 +348,20 @@ void MapRegionClass::resize(int mx0, int my0, int dx0, int dy0) bool RegionClass::is_active() { - if (!flag) return false; + if (!flag) + return (false); + if (win->active_layer == layer) - return true; - else return false; + return (true); + else + return (false); } void RegionClass::make_active() { - if (!flag) return; + if (!flag) + return; + win->active_layer = layer; } @@ -398,8 +403,8 @@ bool RegionClass::convert_redraw_rect(int x1, int y1, int x2, int y2, int cx2 = x2-ox; int cy2 = y2-oy; - if ( (cx2 < 0) || (cy2 < 0) || (cx1 >= dx*mx) || (cy1 >=dy*my)) - return false; + if (cx2 < 0 || cy2 < 0 || cx1 >= dx * mx || cy1 >= dy * my) + return (false); cx1 /= dx; cy1 /= dy; @@ -420,7 +425,7 @@ bool RegionClass::convert_redraw_rect(int x1, int y1, int x2, int y2, *rx2 = cx2; *ry2 = cy2; - return true; + return (true); } bool TileRegionClass::convert_redraw_rect(int x1, int y1, int x2, int y2, @@ -436,7 +441,7 @@ bool TileRegionClass::convert_redraw_rect(int x1, int y1, int x2, int y2, int wwy = dy*my; if (cx2 < 0 || cy2 < 0 || cx1 >= wwx || cy1 >=wwy) - return false; + return (false); if (cx2 >= wwx - 1) cx2 = wwx - 1; @@ -452,57 +457,76 @@ bool TileRegionClass::convert_redraw_rect(int x1, int y1, int x2, int y2, *rx2 = cx2; *ry2 = cy2; - return true; + return (true); } bool RegionClass::mouse_pos(int mouse_x, int mouse_y, int *cx, int *cy) { int x = mouse_x - ox; int y = mouse_y - oy; - if (!is_active()) return false; - if ( x < 0 || y < 0 ) return false; + + if (!is_active()) + return (false); + if ( x < 0 || y < 0 ) + return (false); + x /= dx; y /= dy; - if (x >= mx || y >= my) return false; + + if (x >= mx || y >= my) + return (false); + *cx = x; *cy = y; - return true; + + return (true); } bool MapRegionClass::mouse_pos(int mouse_x, int mouse_y, int *cx, int *cy) { int x = mouse_x - ox - x_margin; int y = mouse_y - oy - y_margin; - if ( x < 0 || y < 0 ) return false; + + if (x < 0 || y < 0) + return (false); + x /= dx; y /= dy; - if (x >= mx || y >= my) return false; - if (!is_active()) return false; + + if (x >= mx || y >= my) + return (false); + if (!is_active()) + return (false); *cx = x; *cy = y; - return true; + + return (true); } bool TileRegionClass::mouse_pos(int mouse_x, int mouse_y, int *cx, int *cy) { int x = mouse_x - ox; int y = mouse_y - oy; - if (!is_active()) return false; - if ( x < 0 || y < 0 ) return false; - if ( x >= dx*mx || y >= dy*my ) return false; + + if (!is_active()) + return (false); + if (x < 0 || y < 0) + return (false); + if (x >= dx * mx || y >= dy * my) + return (false); x /= dx; y /= dy; *cx = x; *cy = y; - return true; + return (true); } -/* - * Text related - */ +// +// Text related +// void TextRegionClass::scroll() { diff --git a/crawl-ref/source/hiscores.cc b/crawl-ref/source/hiscores.cc index d123e52c21..3d2f7dc281 100644 --- a/crawl-ref/source/hiscores.cc +++ b/crawl-ref/source/hiscores.cc @@ -89,7 +89,7 @@ std::string score_file_name() { if (!SysEnv.scorefile.empty()) return (SysEnv.scorefile); - + return (Options.save_dir + "scores"); } @@ -101,13 +101,13 @@ std::string log_file_name() void hiscores_new_entry( const scorefile_entry &ne ) { unwind_bool score_update(crawl_state.updating_scores, true); - + FILE *scores; int i, total_entries; bool inserted = false; // open highscore file (reading) -- NULL is fatal! - // + // // Opening as a+ instead of r+ to force an exclusive lock (see // hs_open) and to create the file if it's not there already. scores = _hs_open("a+", score_file_name()); @@ -116,7 +116,7 @@ void hiscores_new_entry( const scorefile_entry &ne ) // we're at the end of the file, seek back to beginning. fseek(scores, 0, SEEK_SET); - + // read highscore file, inserting new entry at appropriate point, for (i = 0; i < SCORE_FILE_ENTRIES; i++) { @@ -167,7 +167,7 @@ void hiscores_new_entry( const scorefile_entry &ne ) // closing it. if (ftruncate(fileno(scores), 0)) end(1, true, "unable to truncate scorefile"); - + rewind(scores); // write scorefile entries. @@ -184,7 +184,7 @@ void hiscores_new_entry( const scorefile_entry &ne ) void logfile_new_entry( const scorefile_entry &ne ) { unwind_bool logfile_update(crawl_state.updating_scores, true); - + FILE *logfile; scorefile_entry le = ne; @@ -227,7 +227,7 @@ static void _hiscores_print_entry(const scorefile_entry &se, void hiscores_print_all(int display_count, int format) { unwind_bool scorefile_display(crawl_state.updating_scores, true); - + FILE *scores = _hs_open("r", score_file_name()); if (scores == NULL) { @@ -256,7 +256,7 @@ void hiscores_print_all(int display_count, int format) void hiscores_print_list( int display_count, int format ) { unwind_bool scorefile_display(crawl_state.updating_scores, true); - + FILE *scores; int i, total_entries; @@ -344,7 +344,7 @@ static void _hiscore_date_string( time_t time, char buff[INFO_SIZE] ) const char *mons[12] = { "Jan", "Feb", "Mar", "Apr", "May", "June", "July", "Aug", "Sept", "Oct", "Nov", "Dec" }; - snprintf( buff, INFO_SIZE, "%s %d, %d", mons[date->tm_mon], + snprintf( buff, INFO_SIZE, "%s %d, %d", mons[date->tm_mon], date->tm_mday, date->tm_year + 1900 ); } @@ -353,7 +353,7 @@ static std::string _hiscore_newline_string() return (EOL " "); } -std::string hiscores_format_single_long( const scorefile_entry &se, +std::string hiscores_format_single_long( const scorefile_entry &se, bool verbose ) { return se.hiscore_line( verbose ? scorefile_entry::DDV_VERBOSE @@ -449,7 +449,7 @@ kill_method_type str_to_kill_method(const std::string &s) { ASSERT(NUM_KILLBY == (int) sizeof(kill_method_names) / sizeof(*kill_method_names)); - + for (int i = 0; i < NUM_KILLBY; ++i) { if (s == kill_method_names[i]) @@ -557,7 +557,7 @@ bool scorefile_entry::parse(const std::string &line) std::string scorefile_entry::raw_string() const { set_score_fields(); - + if (!fields.get()) return (""); @@ -568,7 +568,7 @@ bool scorefile_entry::parse_scoreline(const std::string &line) { fields.reset(new xlog_fields(line)); init_with_fields(); - + return (true); } @@ -596,7 +596,7 @@ static level_area_type _str_to_level_area_type(const std::string &s) for (int i = 0; i < NUM_LEVEL_AREA_TYPES; ++i) if (s == level_type_names[i]) return (static_cast(i)); - + return (LEVEL_DUNGEON); } @@ -625,7 +625,7 @@ void scorefile_entry::init_with_fields() final_hp = fields->int_field("hp"); final_max_hp = fields->int_field("mhp"); final_max_max_hp = fields->int_field("mmhp"); - + damage = fields->int_field("dam"); str = fields->int_field("str"); intel = fields->int_field("int"); @@ -635,12 +635,12 @@ void scorefile_entry::init_with_fields() piety = fields->int_field("piety"); penance = fields->int_field("pen"); wiz_mode = fields->int_field("wiz"); - + birth_time = _parse_time(fields->str_field("start")); death_time = _parse_time(fields->str_field("end")); real_time = fields->long_field("dur"); num_turns = fields->long_field("turn"); - + num_diff_runes = fields->int_field("urune"); num_runes = fields->int_field("nrune"); } @@ -688,7 +688,7 @@ void scorefile_entry::set_base_xlog_fields() const if (wiz_mode) fields->add_field("wiz", "%d", wiz_mode); - + fields->add_field("start", "%s", make_date_string(birth_time).c_str()); fields->add_field("dur", "%ld", real_time); fields->add_field("turn", "%ld", num_turns); @@ -697,7 +697,7 @@ void scorefile_entry::set_base_xlog_fields() const fields->add_field("urune", "%d", num_diff_runes); if (num_runes) - fields->add_field("nrune", "%d", num_runes); + fields->add_field("nrune", "%d", num_runes); } void scorefile_entry::set_score_fields() const @@ -708,7 +708,7 @@ void scorefile_entry::set_score_fields() const return; set_base_xlog_fields(); - + fields->add_field("sc", "%ld", points); fields->add_field("ktyp", ::kill_method_name(kill_method_type(death_type))); fields->add_field("killer", death_source_desc().c_str()); @@ -720,7 +720,7 @@ void scorefile_entry::set_score_fields() const fields->add_field("piety", "%d", piety); if (penance > 0) fields->add_field("pen", "%d", penance); - + fields->add_field("end", "%s", make_date_string(death_time).c_str()); #ifdef DGL_EXTENDED_LOGFILES @@ -765,14 +765,14 @@ std::string scorefile_entry::short_kill_message() const return (msg); } -void scorefile_entry::init_death_cause(int dam, int dsrc, +void scorefile_entry::init_death_cause(int dam, int dsrc, int dtype, const char *aux) { death_source = dsrc; death_type = dtype; damage = dam; - // Set the default aux data value... + // Set the default aux data value... // If aux is passed in (ie for a trap), we'll default to that. if (aux == NULL) auxkilldata.clear(); @@ -785,7 +785,7 @@ void scorefile_entry::init_death_cause(int dam, int dsrc, { const monsters *monster = &menv[death_source]; - if (monster->type >= 0 && monster->type < NUM_MONSTERS) + if (monster->type >= 0 && monster->type < NUM_MONSTERS) { death_source = monster->type; mon_num = monster->base_monster; @@ -794,7 +794,7 @@ void scorefile_entry::init_death_cause(int dam, int dsrc, // but now we pass it in as a string through the scorefile // entry to be appended in hiscores_format_single in long or // medium scorefile formats. - if (death_type == KILLED_BY_MONSTER + if (death_type == KILLED_BY_MONSTER && monster->inv[MSLOT_WEAPON] != NON_ITEM) { // [ds] The highscore entry may be constructed while the player @@ -810,7 +810,7 @@ void scorefile_entry::init_death_cause(int dam, int dsrc, unset_ident_flags( mitm[monster->inv[MSLOT_WEAPON]], ISFLAG_IDENT_MASK ); - set_ident_flags( mitm[monster->inv[MSLOT_WEAPON]], + set_ident_flags( mitm[monster->inv[MSLOT_WEAPON]], ISFLAG_KNOW_TYPE ); // clear "runed" description text to make shorter yet @@ -820,7 +820,7 @@ void scorefile_entry::init_death_cause(int dam, int dsrc, // Setting this is redundant for dancing weapons, however // we do care about the above indentification. -- bwr - if (monster->type != MONS_DANCING_WEAPON) + if (monster->type != MONS_DANCING_WEAPON) auxkilldata = mitm[monster->inv[MSLOT_WEAPON]].name(DESC_NOCAP_A); } @@ -846,7 +846,7 @@ void scorefile_entry::init_death_cause(int dam, int dsrc, || death_type == KILLED_BY_STUPIDITY || death_type == KILLED_BY_CLUMSINESS) { - if (auxkilldata == "") + if (auxkilldata.empty()) auxkilldata = "unknown source"; } } @@ -895,22 +895,22 @@ static int _award_modified_experience() { int xp = you.experience; int result = 0; - + if (xp <= 250000) return ((xp * 7) / 10); - + result += (250000 * 7) / 10; xp -= 250000; - + if (xp <= 750000) { result += (xp * 4) / 10; return (result); } - + result += (750000 * 4) / 10; xp -= 750000; - + if (xp <= 2000000) { result += (xp * 2) / 10; @@ -919,9 +919,9 @@ static int _award_modified_experience() result += (2000000 * 2) / 10; xp -= 2000000; - + result += (xp / 10); - + return (result); } @@ -963,7 +963,7 @@ void scorefile_entry::init() * + (250,000 * distinct Runes) * (25,000/(turns/rune)), for winners only * */ - + // do points first. points = you.gold; points += _award_modified_experience(); @@ -977,7 +977,7 @@ void scorefile_entry::init() // inventory value is only calculated for winners const bool calc_item_values = (death_type == KILLED_BY_WINNING); - + // Calculate value of pack and runes when character leaves dungeon for (int d = 0; d < ENDOFPACK; d++) { @@ -1010,10 +1010,10 @@ void scorefile_entry::init() } } - // Bonus for exploring different areas, not for collecting a - // huge stack of demonic runes in Pandemonium (gold value + // Bonus for exploring different areas, not for collecting a + // huge stack of demonic runes in Pandemonium (gold value // is enough for those). -- bwr - + if (calc_item_values && num_diff_runes >= 3) points += ((num_diff_runes + 2) * (num_diff_runes + 2) * 1000); @@ -1039,7 +1039,7 @@ void scorefile_entry::init() final_hp = you.hp; final_max_hp = you.hp_max; final_max_max_hp = you.hp_max + player_rotted(); - + str = std::max(you.strength - stat_modifier(STAT_STRENGTH), 1); intel = std::max(you.intel - stat_modifier(STAT_INTELLIGENCE), 1); dex = std::max(you.dex - stat_modifier(STAT_DEXTERITY), 1); @@ -1061,7 +1061,7 @@ void scorefile_entry::init() if (you.real_time != -1) real_time = you.real_time + long(death_time - you.start_time); - else + else real_time = -1; num_turns = you.num_turns; @@ -1134,14 +1134,14 @@ std::string scorefile_entry::death_source_desc() const return (""); // XXX no longer handles mons_num correctly! FIXME - return (!death_source_name.empty()? + return (!death_source_name.empty()? death_source_name : mons_type_name(death_source, DESC_NOCAP_A)); } std::string scorefile_entry::damage_string(bool terse) const { char scratch[50]; - snprintf( scratch, sizeof scratch, "(%d%s)", damage, + snprintf( scratch, sizeof scratch, "(%d%s)", damage, terse? "" : " damage" ); return (scratch); } @@ -1163,7 +1163,7 @@ std::string scorefile_entry::terse_missile_name() const }; const std::string &aux = auxkilldata; std::string missile; - + for (unsigned i = 0; i < sizeof(pre_post) / sizeof(*pre_post); ++i) { if (aux.find(pre_post[i][0]) != 0) @@ -1268,15 +1268,15 @@ scorefile_entry::character_description(death_desc_verbosity verbosity) const { snprintf( buf, HIGHSCORE_SIZE, "%8ld %s the %s (level %d", points, name.c_str(), - skill_title( best_skill, best_skill_lvl, + skill_title( best_skill, best_skill_lvl, race, str, dex, god ).c_str(), lvl ); desc = buf; } - else + else { snprintf( buf, HIGHSCORE_SIZE, "%8ld %s the %s %s (level %d", points, name.c_str(), - species_name(static_cast(race), lvl).c_str(), + species_name(static_cast(race), lvl).c_str(), get_class_name(cls), lvl ); desc = buf; } @@ -1339,7 +1339,7 @@ scorefile_entry::character_description(death_desc_verbosity verbosity) const (piety >= 50) ? "a Believer" : (piety >= 30) ? "a Follower" : "an Initiate", - god_name(god).c_str(), + god_name(god).c_str(), (penance > 0) ? " (penitent)." : "." ); desc += scratch; @@ -1384,7 +1384,7 @@ std::string scorefile_entry::death_place(death_desc_verbosity verbosity) const place += placename; - if (verbose && death_time + if (verbose && death_time && !_hiscore_same_day( birth_time, death_time )) { place += " on "; @@ -1418,7 +1418,7 @@ std::string scorefile_entry::death_description(death_desc_verbosity verbosity) char scratch[INFO_SIZE]; std::string desc; - + if (oneline) desc = " "; @@ -1462,7 +1462,7 @@ std::string scorefile_entry::death_description(death_desc_verbosity verbosity) if (oneline || semiverbose) { // keeping this short to leave room for the deep elf spellcasters: - snprintf( scratch, sizeof(scratch), "%s by ", + snprintf( scratch, sizeof(scratch), "%s by ", _range_type_verb( auxkilldata.c_str() ) ); desc += scratch; desc += death_source_desc(); @@ -1560,7 +1560,7 @@ std::string scorefile_entry::death_description(death_desc_verbosity verbosity) else { snprintf( scratch, sizeof(scratch), - "Killed by triggering a%s trap", + "Killed by triggering a%s trap", auxkilldata.c_str() ); desc += scratch; } @@ -1619,7 +1619,7 @@ std::string scorefile_entry::death_description(death_desc_verbosity verbosity) else { // A lot of sources for this case... some have "by" already. - snprintf( scratch, sizeof(scratch), "Killed %s%s", + snprintf( scratch, sizeof(scratch), "Killed %s%s", (auxkilldata.find("by ") != 0) ? "by " : "", auxkilldata.c_str() ); desc += scratch; @@ -1686,7 +1686,7 @@ std::string scorefile_entry::death_description(death_desc_verbosity verbosity) desc += terse? "acid" : "Splashed by acid"; needs_damage = true; break; - + case KILLED_BY_CURARE: desc += terse? "asphyx" : "Asphyxiated"; break; @@ -1814,7 +1814,7 @@ std::string scorefile_entry::death_description(death_desc_verbosity verbosity) { if (!semiverbose) { - desc += (is_vowel( auxkilldata[0] )) ? "... with an " + desc += (is_vowel( auxkilldata[0] )) ? "... with an " : "... with a "; desc += auxkilldata; needs_damage = true; @@ -1830,7 +1830,7 @@ std::string scorefile_entry::death_description(death_desc_verbosity verbosity) if (!semiverbose) { - if (needs_damage && !done_damage && damage > 0) + if (needs_damage && !done_damage && damage > 0) desc += " " + damage_string(); if (needs_damage) @@ -1991,7 +1991,7 @@ std::string xlog_fields::xlog_line() const // Don't write empty fields. if (f.second.empty()) continue; - + if (!line.empty()) line += ":"; diff --git a/crawl-ref/source/invent.cc b/crawl-ref/source/invent.cc index fb0d215369..2ba2af30b1 100644 --- a/crawl-ref/source/invent.cc +++ b/crawl-ref/source/invent.cc @@ -417,14 +417,14 @@ bool InvMenu::is_selectable(int index) const { InvEntry *item = dynamic_cast(items[index]); if (item->is_item_cursed() && item->is_item_equipped()) - return false; + return (false); std::string text = item->get_text(); if (text.find("!*") != std::string::npos || text.find("!d") != std::string::npos) { - return false; + return (false); } } @@ -685,7 +685,7 @@ bool InvMenu::process_key( int key ) deselect_all(); sel.clear(); draw_select_count(0, true); - return true; + return (true); } return Menu::process_key( key ); } @@ -898,22 +898,21 @@ static bool _any_items_to_select(int selector) if (is_valid_item(you.inv[i]) && _is_item_selected(you.inv[i], selector)) { - return true; + return (true); } } - return false; + return (false); } -unsigned char invent_select( - const char *title, - menu_type type, - int item_selector, - int flags, - invtitle_annotator titlefn, - std::vector *items, - std::vector *filter, - Menu::selitem_tfn selitemfn, - const std::vector *pre_select ) +unsigned char invent_select( const char *title, + menu_type type, + int item_selector, + int flags, + invtitle_annotator titlefn, + std::vector *items, + std::vector *filter, + Menu::selitem_tfn selitemfn, + const std::vector *pre_select ) { InvMenu menu(flags); @@ -1252,7 +1251,7 @@ static std::string _operation_verb(operation_types oper) } } -// Return true if user OK'd it (or no warning), false otherwise. +// Returns true if user OK'd it (or no warning), false otherwise. bool check_warning_inscriptions( const item_def& item, operation_types oper ) { @@ -1458,7 +1457,7 @@ int prompt_invent_item( const char *prompt, bool prompt_failed(int retval, std::string msg) { if (retval != PROMPT_ABORT && retval != PROMPT_NOTHING) - return false; + return (false); if (msg.empty()) { @@ -1470,5 +1469,5 @@ bool prompt_failed(int retval, std::string msg) crawl_state.cancel_cmd_repeat(); - return true; + return (true); } diff --git a/crawl-ref/source/it_use3.cc b/crawl-ref/source/it_use3.cc index 8f439ffe77..36be52164d 100644 --- a/crawl-ref/source/it_use3.cc +++ b/crawl-ref/source/it_use3.cc @@ -85,7 +85,7 @@ void special_wielded() if (you.special_wield == SPWLD_SING) { msg = getSpeakString("Singing Sword"); - if (msg != "") + if (!msg.empty()) { // "Your Singing Sword" sounds disrespectful // (as if there could be more than one!) @@ -96,21 +96,21 @@ void special_wielded() else // SPWLD_NOISE { msg = getSpeakString("noisy weapon"); - if (msg != "") + if (!msg.empty()) { msg = replace_all(msg, "@Your_weapon@", "Your @weapon@"); msg = replace_all(msg, "@your_weapon@", "your @weapon@"); } } - // set appropriate channel (will usually be TALK) + // Set appropriate channel (will usually be TALK). msg_channel_type channel = MSGCH_TALK; - // disallow anything with VISUAL in it; - if (msg != "" && msg.find("VISUAL") != std::string::npos) + // Disallow anything with VISUAL in it. + if (!msg.empty() && msg.find("VISUAL") != std::string::npos) msg = ""; - if (msg != "") + if (!msg.empty()) { std::string param = ""; std::string::size_type pos = msg.find(":"); @@ -135,12 +135,12 @@ void special_wielded() else if (param != "TALK") match = false; - if (match && msg != "") + if (match && !msg.empty()) msg = msg.substr(pos + 1); } } - if (msg == "") // give default noises + if (msg.empty()) // give default noises { if (you.special_wield == SPWLD_SING) msg = "@The_weapon@ sings."; @@ -261,12 +261,12 @@ static bool _reaching_weapon_attack(const item_def& wpn) direction(beam, DIR_TARGET, TARG_ENEMY, 2); if (!beam.isValid) - return false; + return (false); if (beam.isMe) { canned_msg(MSG_UNTHINKING_ACT); - return false; + return (false); } const int x_distance = abs(beam.tx - you.x_pos); @@ -275,7 +275,7 @@ static bool _reaching_weapon_attack(const item_def& wpn) if (x_distance > 2 || y_distance > 2) { mpr("Your weapon cannot reach that far!"); - return false; + return (false); } else if (!see_grid_no_trans(beam.tx, beam.ty)) { @@ -424,7 +424,7 @@ static bool evoke_sceptre_of_asmodeus() 0 )); your_spells( spl, you.skills[SK_EVOCATIONS] * 8, false ); } - return true; + return (true); } // returns true if item successfully evoked. diff --git a/crawl-ref/source/item_use.cc b/crawl-ref/source/item_use.cc index 392a37016f..e6a0deed8e 100644 --- a/crawl-ref/source/item_use.cc +++ b/crawl-ref/source/item_use.cc @@ -99,7 +99,7 @@ bool can_wield(const item_def *weapon, bool say_reason, if (!ignore_temporary_disability && you.duration[DUR_BERSERKER]) { SAY(canned_msg(MSG_TOO_BERSERK)); - return false; + return (false); } if (!can_equip( EQ_WEAPON, ignore_temporary_disability )) @@ -139,36 +139,37 @@ bool can_wield(const item_def *weapon, bool say_reason, && item_mass( *weapon ) >= 300) { SAY(mpr("That's too large and heavy for you to wield.")); - return false; + return (false); } + // FIXME: We should use a size check here instead. if ((you.species == SP_HALFLING || you.species == SP_GNOME || you.species == SP_KOBOLD || you.species == SP_SPRIGGAN) - && (weapon->sub_type == WPN_GREAT_SWORD - || weapon->sub_type == WPN_TRIPLE_SWORD - || weapon->sub_type == WPN_GREAT_MACE - || weapon->sub_type == WPN_DIRE_FLAIL - || weapon->sub_type == WPN_BATTLEAXE - || weapon->sub_type == WPN_EXECUTIONERS_AXE - || weapon->sub_type == WPN_BARDICHE - || weapon->sub_type == WPN_HALBERD - || weapon->sub_type == WPN_GLAIVE - || weapon->sub_type == WPN_GIANT_CLUB - || weapon->sub_type == WPN_GIANT_SPIKED_CLUB - || weapon->sub_type == WPN_LONGBOW - || weapon->sub_type == WPN_SCYTHE)) + && (weapon->sub_type == WPN_GREAT_SWORD + || weapon->sub_type == WPN_TRIPLE_SWORD + || weapon->sub_type == WPN_GREAT_MACE + || weapon->sub_type == WPN_DIRE_FLAIL + || weapon->sub_type == WPN_BATTLEAXE + || weapon->sub_type == WPN_EXECUTIONERS_AXE + || weapon->sub_type == WPN_BARDICHE + || weapon->sub_type == WPN_HALBERD + || weapon->sub_type == WPN_GLAIVE + || weapon->sub_type == WPN_GIANT_CLUB + || weapon->sub_type == WPN_GIANT_SPIKED_CLUB + || weapon->sub_type == WPN_LONGBOW + || weapon->sub_type == WPN_SCYTHE)) { SAY(mpr("That's too large for you to wield.")); - return false; + return (false); } int weap_brand = get_weapon_brand( *weapon ); if ((you.is_undead || you.species == SP_DEMONSPAWN) - && (weap_brand == SPWPN_HOLY_WRATH - || is_blessed_blade(*weapon))) + && (weap_brand == SPWPN_HOLY_WRATH + || is_blessed_blade(*weapon))) { SAY(mpr("This weapon will not allow you to wield it.")); - return false; + return (false); } if (!ignore_temporary_disability && is_shield_incompatible(*weapon)) @@ -178,7 +179,7 @@ bool can_wield(const item_def *weapon, bool say_reason, } // We can wield this weapon. Phew! - return true; + return (true); #undef SAY } @@ -1150,13 +1151,13 @@ bool takeoff_armour(int item) if (you.inv[item].base_type != OBJ_ARMOUR) { mpr("You aren't wearing that!"); - return false; + return (false); } if (you.duration[DUR_BERSERKER]) { canned_msg(MSG_TOO_BERSERK); - return false; + return (false); } if (item_cursed( you.inv[item] )) @@ -1167,7 +1168,7 @@ bool takeoff_armour(int item) { mprf("%s is stuck to your body!", you.inv[item].name(DESC_CAP_YOUR).c_str()); - return false; + return (false); } } } @@ -1194,17 +1195,15 @@ bool takeoff_armour(int item) else { mpr("Your cloak prevents you from removing the armour."); - return false; + return (false); } } if (item != you.equip[EQ_BODY_ARMOUR]) { mpr("You aren't wearing that!"); - return false; + return (false); } - - // you.equip[EQ_BODY_ARMOUR] = -1; } else { @@ -1214,7 +1213,7 @@ bool takeoff_armour(int item) if (item != you.equip[EQ_SHIELD]) { mpr("You aren't wearing that!"); - return false; + return (false); } break; @@ -1222,7 +1221,7 @@ bool takeoff_armour(int item) if (item != you.equip[EQ_CLOAK]) { mpr("You aren't wearing that!"); - return false; + return (false); } break; @@ -1230,7 +1229,7 @@ bool takeoff_armour(int item) if (item != you.equip[EQ_HELMET]) { mpr("You aren't wearing that!"); - return false; + return (false); } break; @@ -1238,7 +1237,7 @@ bool takeoff_armour(int item) if (item != you.equip[EQ_GLOVES]) { mpr("You aren't wearing that!"); - return false; + return (false); } break; @@ -1246,7 +1245,7 @@ bool takeoff_armour(int item) if (item != you.equip[EQ_BOOTS]) { mpr("You aren't wearing that!"); - return false; + return (false); } break; @@ -1263,7 +1262,7 @@ bool takeoff_armour(int item) if (removedCloak) start_delay( DELAY_ARMOUR_ON, 1, cloak ); - return true; + return (true); } // end takeoff_armour() int get_next_fire_item(int current, int direction) @@ -1451,19 +1450,21 @@ static bool _fire_choose_item_and_target(int& slot, dist& target, if (!_fire_validate_item(slot, warn)) { mpr(warn.c_str()); - return false; + return (false); } - beh.m_slot = slot; // Force item to be the prechosen one. + // Force item to be the prechosen one. + beh.m_slot = slot; } beh.message_ammo_prompt(); - message_current_target(); // XXX: This stuff should be done by direction()! + // XXX: This stuff should be done by direction()! + message_current_target(); direction( target, DIR_NONE, TARG_ENEMY, -1, false, !teleport, NULL, &beh ); if (beh.m_slot == -1) { canned_msg(MSG_OK); - return false; + return (false); } if (!target.isValid) { @@ -1472,6 +1473,7 @@ static bool _fire_choose_item_and_target(int& slot, dist& target, return (false); } + // Currently no difference between f() and fi. you.m_quiver->on_item_fired(you.inv[beh.m_slot], beh.chosen_ammo); /* // If ammo was chosen via 'fi', it's not supposed to get quivered. @@ -1517,31 +1519,31 @@ static int _fire_prompt_for_item(std::string& err) return slot; } -// Return false and err text if this item can't be fired. -static bool _fire_validate_item(int slot, std::string& err) +// Returns false and err text if this item can't be fired. +static bool _fire_validate_item(int slot, std::string &err) { if (slot == you.equip[EQ_WEAPON] && you.inv[slot].base_type == OBJ_WEAPONS && item_cursed(you.inv[slot])) { err = "That weapon is stuck to your hand!"; - return false; + return (false); } - else if ( wearing_slot(slot) ) + else if (wearing_slot(slot)) { err = "You are wearing that object!"; - return false; + return (false); } - return true; + return (true); } -// Return true if warning is given +// Returns true if warning is given. static bool _fire_warn_if_impossible() { if (you.attribute[ATTR_TRANSFORMATION] == TRAN_BAT) { canned_msg(MSG_PRESENT_FORM); - return true; + return (true); } if (you.attribute[ATTR_HELD]) @@ -1550,22 +1552,22 @@ static bool _fire_warn_if_impossible() if (!weapon || !is_range_weapon(*weapon)) { mpr("You cannot throw anything while held in a net!"); - return true; + return (true); } else if (weapon->sub_type != WPN_BLOWGUN) { mprf("You cannot shoot with your %s while held in a net!", weapon->name(DESC_BASENAME).c_str()); - return true; + return (true); } - // else shooting is possible + // Else shooting is possible. } if (you.duration[DUR_BERSERKER]) { canned_msg(MSG_TOO_BERSERK); - return true; + return (true); } - return false; + return (false); } int get_ammo_to_shoot(int item, dist &target, bool teleport) @@ -1715,13 +1717,13 @@ bool elemental_missile_beam(int launcher_brand, int ammo_brand) static bool determines_ammo_brand(int bow_brand, int ammo_brand) { if (bow_brand == SPWPN_FLAME && ammo_brand == SPMSL_FLAME) - return false; + return (false); if (bow_brand == SPWPN_FROST && ammo_brand == SPMSL_ICE) - return false; + return (false); if (bow_brand == SPWPN_VENOM && ammo_brand == SPMSL_POISONED) - return false; + return (false); - return true; + return (true); } static int stat_adjust(int value, int stat, int statbase, @@ -3030,7 +3032,7 @@ bool puton_item(int item_slot, bool prompt_finger) OPER_REMOVE) || !remove_ring( you.equip[EQ_AMULET], true )) { - return false; + return (false); } // Put on the new amulet. @@ -3658,33 +3660,33 @@ bool _drink_fountain() { const dungeon_feature_type feat = grd[you.x_pos][you.y_pos]; - if ( feat < DNGN_FOUNTAIN_BLUE || feat > DNGN_FOUNTAIN_BLOOD ) - return false; + if (feat < DNGN_FOUNTAIN_BLUE || feat > DNGN_FOUNTAIN_BLOOD) + return (false); if (you.flight_mode() == FL_LEVITATE) { mpr("You're floating high above the fountain."); - return false; + return (false); } if (you.duration[DUR_BERSERKER]) { canned_msg(MSG_TOO_BERSERK); - return true; + return (true); } potion_type fountain_effect = POT_WATER; - if ( feat == DNGN_FOUNTAIN_BLUE ) + if (feat == DNGN_FOUNTAIN_BLUE) { if (!yesno("Drink from the fountain?")) - return false; + return (false); mpr("You drink the pure, clear water."); } - else if ( feat == DNGN_FOUNTAIN_BLOOD ) + else if (feat == DNGN_FOUNTAIN_BLOOD) { if (!yesno("Drink from the fountain of blood?")) - return false; + return (false); mpr("You drink the blood."); fountain_effect = POT_BLOOD; @@ -3692,7 +3694,7 @@ bool _drink_fountain() else // sparkling fountain { if (!yesno("Drink from the sparkling fountain?")) - return false; + return (false); mpr("You drink the sparkling water."); @@ -3724,26 +3726,29 @@ bool _drink_fountain() if (fountain_effect != POT_WATER && fountain_effect != POT_BLOOD) xom_is_stimulated(64); - // good gods do not punish for bad random effects + // Good gods do not punish for bad random effects. However, they do + // punish drinking from a fountain of blood. potion_effect(fountain_effect, 100, feat != DNGN_FOUNTAIN_SPARKLING); bool gone_dry = false; - if ( feat == DNGN_FOUNTAIN_BLUE ) + if (feat == DNGN_FOUNTAIN_BLUE) { - if ( one_chance_in(20) ) + if (one_chance_in(20)) gone_dry = true; } - else if ( feat == DNGN_FOUNTAIN_BLOOD ) + else if (feat == DNGN_FOUNTAIN_BLOOD) { - if ( one_chance_in(3) ) + // High chance of drying up, to prevent abuse. + if (one_chance_in(3)) gone_dry = true; } - else // sparkling fountain + else // sparkling fountain { if (one_chance_in(10)) gone_dry = true; - else if ( random2(50) > 40 ) // no message! + else if (random2(50) > 40) { + // Turn fountain into a normal fountain - without any message. grd[you.x_pos][you.y_pos] = DNGN_FOUNTAIN_BLUE; set_terrain_changed(you.x_pos, you.y_pos); } @@ -3762,8 +3767,8 @@ bool _drink_fountain() } you.turn_is_over = true; - return true; -} // end _drink_fountain() + return (true); +} static bool affix_weapon_enchantment() { @@ -3789,17 +3794,17 @@ static bool affix_weapon_enchantment() case SPWPN_FLAMING: mprf("%s is engulfed in an explosion of flames!", itname.c_str()); - beam.type = dchar_glyph(DCHAR_FIRED_BURST); - beam.damage = dice_def( 3, 10 ); - beam.flavour = BEAM_FIRE; - beam.target_x = you.x_pos; - beam.target_y = you.y_pos; - beam.name = "fiery explosion"; - beam.colour = RED; - beam.thrower = KILL_YOU; + beam.name = "fiery explosion"; beam.aux_source = "a fiery explosion"; - beam.ex_size = 2; - beam.is_tracer = false; + beam.type = dchar_glyph(DCHAR_FIRED_BURST); + beam.damage = dice_def( 3, 10 ); + beam.flavour = BEAM_FIRE; + beam.target_x = you.x_pos; + beam.target_y = you.y_pos; + beam.colour = RED; + beam.thrower = KILL_YOU; + beam.ex_size = 2; + beam.is_tracer = false; beam.is_explosion = true; explosion(beam); @@ -4698,14 +4703,14 @@ void use_randart(item_def &item) bool wearing_slot(int inv_slot) { for (int i = EQ_CLOAK; i <= EQ_AMULET; ++i) - if ( inv_slot == you.equip[i] ) - return true; + if (inv_slot == you.equip[i]) + return (true); - return false; + return (false); } #ifdef USE_TILE -// Interactive menu for item drop/use +// Interactive menu for item drop/use. void tile_use_item(int idx, InvAction act) { if (act == INV_PICKUP) diff --git a/crawl-ref/source/itemname.cc b/crawl-ref/source/itemname.cc index e420d368ec..a7e2b459e4 100644 --- a/crawl-ref/source/itemname.cc +++ b/crawl-ref/source/itemname.cc @@ -1689,7 +1689,7 @@ bool item_type_known( const item_def& item ) // Artefacts have different descriptions from other items, // so we can't use general item knowledge for them. if (is_artefact(item)) - return false; + return (false); // Poisoned missiles are always identified. if (item.base_type == OBJ_MISSILES) @@ -1701,32 +1701,19 @@ bool item_type_known( const item_def& item ) const item_type_id_type idt = objtype_to_idtype(item.base_type); if ( idt != NUM_IDTYPE && item.sub_type < 50 ) - return ( type_ids[idt][item.sub_type] == ID_KNOWN_TYPE ); + return (type_ids[idt][item.sub_type] == ID_KNOWN_TYPE); else - return false; + return (false); } bool item_type_known(const object_class_type base_type, const int sub_type) { const item_type_id_type idt = objtype_to_idtype(base_type); if ( idt != NUM_IDTYPE && sub_type < 50 ) - return ( type_ids[idt][sub_type] == ID_KNOWN_TYPE ); + return (type_ids[idt][sub_type] == ID_KNOWN_TYPE); else - return false; -} - -// [ds] Will the owner of this unused function step up and end its -// suffering? :P -#if 0 -static bool _randart_has_known_property(const item_def &item) -{ - for (int rap = 0; rap < RAP_NUM_PROPERTIES; rap++) - if (randart_wpn_known_prop( item, static_cast(rap) )) - return true; - - return false; + return (false); } -#endif bool item_type_tried( const item_def& item ) { @@ -2470,7 +2457,7 @@ bool is_useless_item(const item_def &item, bool temp) return (false); if (is_artefact(item)) - return false; + return (false); if (is_bad_item(item, temp)) return (true); diff --git a/crawl-ref/source/itemprop.cc b/crawl-ref/source/itemprop.cc index 912153f1c7..dd26e6bd3e 100644 --- a/crawl-ref/source/itemprop.cc +++ b/crawl-ref/source/itemprop.cc @@ -2160,7 +2160,7 @@ bool food_is_veg( const item_def &item ) bool is_blood_potion( const item_def &item) { if (item.base_type != OBJ_POTIONS) - return false; + return (false); return (item.sub_type == POT_BLOOD || item.sub_type == POT_BLOOD_COAGULATED); @@ -2264,183 +2264,183 @@ int property( const item_def &item, int prop_type ) return (0); } +// Returns true if item is evokable. bool gives_ability( const item_def &item ) { if (!item_type_known(item)) - return false; + return (false); switch (item.base_type) { - case OBJ_WEAPONS: - { - // unwielded weapon - item_def *weap = you.slot_item(EQ_WEAPON); - if (!weap || (*weap).slot != item.slot) - return false; - break; - } - case OBJ_JEWELLERY: - { - if ( !jewellery_is_amulet(item)) - { - // unworn ring - item_def *lring = you.slot_item(EQ_LEFT_RING); - item_def *rring = you.slot_item(EQ_RIGHT_RING); - if ((!lring || (*lring).slot != item.slot) - && (!rring || (*rring).slot != item.slot)) - { - return false; - } - - if (item.sub_type == RING_TELEPORTATION - || item.sub_type == RING_LEVITATION - || item.sub_type == RING_INVISIBILITY) - { - return true; - } - } - else - { - // unworn amulet - item_def *amul = you.slot_item(EQ_AMULET); - if (!amul || (*amul).slot != item.slot) - return false; - - if (item.sub_type == AMU_RAGE) - return true; - } - break; - } - case OBJ_ARMOUR: - { - const equipment_type eq = get_armour_slot(item); - if (eq == EQ_NONE) - return false; - - // unworn armour - item_def *arm = you.slot_item(eq); - if (!arm || (*arm).slot != item.slot) - return false; - break; - } - default: - return false; + case OBJ_WEAPONS: + { + // unwielded weapon + item_def *weap = you.slot_item(EQ_WEAPON); + if (!weap || (*weap).slot != item.slot) + return (false); + break; + } + case OBJ_JEWELLERY: + { + if (!jewellery_is_amulet(item)) + { + // unworn ring + item_def *lring = you.slot_item(EQ_LEFT_RING); + item_def *rring = you.slot_item(EQ_RIGHT_RING); + if ((!lring || (*lring).slot != item.slot) + && (!rring || (*rring).slot != item.slot)) + { + return (false); + } + + if (item.sub_type == RING_TELEPORTATION + || item.sub_type == RING_LEVITATION + || item.sub_type == RING_INVISIBILITY) + { + return (true); + } + } + else + { + // unworn amulet + item_def *amul = you.slot_item(EQ_AMULET); + if (!amul || (*amul).slot != item.slot) + return (false); + + if (item.sub_type == AMU_RAGE) + return (true); + } + break; + } + case OBJ_ARMOUR: + { + const equipment_type eq = get_armour_slot(item); + if (eq == EQ_NONE) + return (false); + + // unworn armour + item_def *arm = you.slot_item(eq); + if (!arm || (*arm).slot != item.slot) + return (false); + break; + } + default: + return (false); } if (!is_random_artefact(item)) - return false; + return (false); - // check for evokable randart properties + // Check for evokable randart properties. for (int rap = RAP_INVISIBLE; rap <= RAP_MAPPING; rap++) - { if (randart_wpn_property( item, static_cast(rap) )) - return true; - } + return (true); - return false; + return (false); } +// Returns true if the item confers an intrinsic that is shown on the % screen.# bool gives_resistance( const item_def &item ) { if (!item_type_known(item)) - return false; + return (false); switch (item.base_type) { - case OBJ_WEAPONS: - { - // unwielded weapon - item_def *weap = you.slot_item(EQ_WEAPON); - if (!weap || (*weap).slot != item.slot) - return false; - break; - } - case OBJ_JEWELLERY: - { - if (item.sub_type < NUM_RINGS) - { - // unworn ring - item_def *lring = you.slot_item(EQ_LEFT_RING); - item_def *rring = you.slot_item(EQ_RIGHT_RING); - if ((!lring || (*lring).slot != item.slot) - && (!rring || (*rring).slot != item.slot)) - { - return false; - } - - if (item.sub_type >= RING_PROTECTION_FROM_FIRE - && item.sub_type <= RING_PROTECTION_FROM_COLD - || item.sub_type == RING_SEE_INVISIBLE - || item.sub_type >= RING_LIFE_PROTECTION - && item.sub_type <= RING_TELEPORT_CONTROL - || item.sub_type == RING_SUSTAIN_ABILITIES) - { - return true; - } - } - else - { - // unworn amulet - item_def *amul = you.slot_item(EQ_AMULET); - if (!amul || (*amul).slot != item.slot) - return false; - - if (item.sub_type != AMU_RAGE && item.sub_type != AMU_INACCURACY) - return true; - } - break; - } - case OBJ_ARMOUR: - { - const equipment_type eq = get_armour_slot(item); - if (eq == EQ_NONE) - return false; - - // unworn armour - item_def *arm = you.slot_item(eq); - if (!arm || (*arm).slot != item.slot) - return false; - break; - - const int ego = get_armour_ego_type( item ); - if (ego >= SPARM_FIRE_RESISTANCE && ego <= SPARM_SEE_INVISIBLE - || ego == SPARM_RESISTANCE || ego == SPARM_POSITIVE_ENERGY) - { - return true; - } - } - case OBJ_STAVES: - { - // unwielded weapon - item_def *weap = you.slot_item(EQ_WEAPON); - if (!weap || (*weap).slot != item.slot) - return false; - - if (item.sub_type >= STAFF_FIRE && item.sub_type <= STAFF_POISON - || item.sub_type == STAFF_AIR) - { - return true; - } - return false; - } - default: - return false; + case OBJ_WEAPONS: + { + // unwielded weapon + item_def *weap = you.slot_item(EQ_WEAPON); + if (!weap || (*weap).slot != item.slot) + return (false); + break; + } + case OBJ_JEWELLERY: + { + if (item.sub_type < NUM_RINGS) + { + // unworn ring + item_def *lring = you.slot_item(EQ_LEFT_RING); + item_def *rring = you.slot_item(EQ_RIGHT_RING); + if ((!lring || (*lring).slot != item.slot) + && (!rring || (*rring).slot != item.slot)) + { + return (false); + } + + if (item.sub_type >= RING_PROTECTION_FROM_FIRE + && item.sub_type <= RING_PROTECTION_FROM_COLD + || item.sub_type == RING_SEE_INVISIBLE + || item.sub_type >= RING_LIFE_PROTECTION + && item.sub_type <= RING_TELEPORT_CONTROL + || item.sub_type == RING_SUSTAIN_ABILITIES) + { + return (true); + } + } + else + { + // unworn amulet + item_def *amul = you.slot_item(EQ_AMULET); + if (!amul || (*amul).slot != item.slot) + return (false); + + if (item.sub_type != AMU_RAGE && item.sub_type != AMU_INACCURACY) + return (true); + } + break; + } + case OBJ_ARMOUR: + { + const equipment_type eq = get_armour_slot(item); + if (eq == EQ_NONE) + return (false); + + // unworn armour + item_def *arm = you.slot_item(eq); + if (!arm || (*arm).slot != item.slot) + return (false); + break; + + const int ego = get_armour_ego_type( item ); + if (ego >= SPARM_FIRE_RESISTANCE && ego <= SPARM_SEE_INVISIBLE + || ego == SPARM_RESISTANCE || ego == SPARM_POSITIVE_ENERGY) + { + return (true); + } + } + case OBJ_STAVES: + { + // unwielded staff + item_def *weap = you.slot_item(EQ_WEAPON); + if (!weap || (*weap).slot != item.slot) + return (false); + + if (item.sub_type >= STAFF_FIRE && item.sub_type <= STAFF_POISON + || item.sub_type == STAFF_AIR) + { + return (true); + } + return (false); + } + default: + return (false); } if (!is_random_artefact(item)) - return false; + return (false); - // check for randart resistances + // Check for randart resistances. for (int rap = RAP_FIRE; rap <= RAP_CAN_TELEPORT; rap++) { if (rap == RAP_MAGIC || rap >= RAP_INVISIBLE && rap != RAP_CAN_TELEPORT) continue; if (randart_wpn_property( item, static_cast(rap) )) - return true; + return (true); } - return false; + return (false); } int item_mass( const item_def &item ) diff --git a/crawl-ref/source/items.cc b/crawl-ref/source/items.cc index c5d298eb6d..5cbccb4b46 100644 --- a/crawl-ref/source/items.cc +++ b/crawl-ref/source/items.cc @@ -95,7 +95,7 @@ static bool will_autoinscribe = false; // sure item coordinates are correct to the stack they're in. -- bwr void fix_item_coordinates(void) { - // nails all items to the ground (i.e. sets x,y) + // Nails all items to the ground (i.e. sets x,y). for (int x = 0; x < GXM; x++) for (int y = 0; y < GYM; y++) { @@ -113,17 +113,17 @@ void fix_item_coordinates(void) // This function uses the items coordinates to relink all the igrd lists. void link_items(void) { - // first, initialise igrd array + // First, initialise igrd array. igrd.init(NON_ITEM); - // link all items on the grid, plus shop inventory, - // DON'T link the huge pile of monster items at (0,0) + // Link all items on the grid, plus shop inventory, + // but DON'T link the huge pile of monster items at (0,0). for (int i = 0; i < MAX_ITEMS; i++) { if (!is_valid_item(mitm[i]) || (mitm[i].x == 0 && mitm[i].y == 0)) { - // item is not assigned, or is monster item. ignore. + // Item is not assigned, or is monster item. Ignore. mitm[i].link = NON_ITEM; continue; } @@ -132,25 +132,25 @@ void link_items(void) mitm[i].link = igrd[ mitm[i].x ][ mitm[i].y ]; igrd[ mitm[i].x ][ mitm[i].y ] = i; } -} // end link_items() +} static bool _item_ok_to_clean(int item) { - // never clean food or Orbs + // Never clean food or Orbs. if (mitm[item].base_type == OBJ_FOOD || mitm[item].base_type == OBJ_ORBS) - return false; + return (false); - // never clean runes + // Never clean runes. if (mitm[item].base_type == OBJ_MISCELLANY && mitm[item].sub_type == MISC_RUNE_OF_ZOT) { - return false; + return (false); } - return true; + return (true); } -// returns index number of first available space, or NON_ITEM for +// Returns index number of first available space, or NON_ITEM for // unsuccessful cleanup (should be exceedingly rare!) static int _cull_items(void) { @@ -160,23 +160,21 @@ static int _cull_items(void) // deserves to know whenever this kicks in. -- bwr mpr( "Too many items on level, removing some.", MSGCH_WARN ); - /* rules: - 1. Don't cleanup anything nearby the player - 2. Don't cleanup shops - 3. Don't cleanup monster inventory - 4. Clean 15% of items - 5. never remove food, orbs, runes - 7. uniques weapons are moved to the abyss - 8. randarts are simply lost - 9. unrandarts are 'destroyed', but may be generated again - */ + // Rules: + // 1. Don't cleanup anything nearby the player + // 2. Don't cleanup shops + // 3. Don't cleanup monster inventory + // 4. Clean 15% of items + // 5. never remove food, orbs, runes + // 7. uniques weapons are moved to the abyss + // 8. randarts are simply lost + // 9. unrandarts are 'destroyed', but may be generated again int first_cleaned = NON_ITEM; // 2. avoid shops by avoiding (0,5..9) // 3. avoid monster inventory by iterating over the dungeon grid for (int x = 5; x < GXM; x++) - { for (int y = 5; y < GYM; y++) { // 1. not near player! @@ -217,8 +215,7 @@ static int _cull_items(void) } } // end for item - } // end y - } // end x + } return (first_cleaned); } @@ -1332,9 +1329,9 @@ bool items_stack( const item_def &item1, const item_def &item2, } } - // Check the ID flags + // Check the ID flags. if (ident_flags(item1) != ident_flags(item2)) - return false; + return (false); // Check the non-ID flags, but ignore dropped, thrown, cosmetic, // and note flags. Also, whether item was in inventory before. @@ -1344,9 +1341,7 @@ bool items_stack( const item_def &item1, const item_def &item2, ISFLAG_BEEN_IN_INV) if ((item1.flags & NON_IDENT_FLAGS) != (item2.flags & NON_IDENT_FLAGS)) - { - return false; - } + return (false); if (item1.base_type == OBJ_POTIONS) { @@ -1356,16 +1351,16 @@ bool items_stack( const item_def &item1, const item_def &item2, if (item1.plus != item2.plus && (!item_type_known(item1) || !item_type_known(item2))) { - return false; + return (false); } } // The inscriptions can differ if one of them is blank, but if they // are differing non-blank inscriptions then don't stack. if (item1.inscription != item2.inscription - && item1.inscription != "" && item2.inscription != "") + && !item1.inscription.empty() && !item2.inscription.empty()) { - return false; + return (false); } return (true); @@ -1377,6 +1372,7 @@ static int _userdef_find_free_slot(const item_def &i) int slot = -1; if (!clua.callfn("c_assign_invletter", "u>d", &i, &slot)) return (-1); + return (slot); #else return -1; @@ -1532,8 +1528,8 @@ int move_item_to_player( int obj, int quant_got, bool quiet ) // If the object on the ground is inscribed, but not // the one in inventory, then the inventory object // picks up the other's inscription. - if (mitm[obj].inscription != "" - && you.inv[m].inscription == "") + if (!(mitm[obj].inscription).empty() + && you.inv[m].inscription.empty()) { you.inv[m].inscription = mitm[obj].inscription; } @@ -2080,38 +2076,38 @@ void drop(void) // If the user answers "no" to an item an with a warning inscription, // then remove it from the list of items to drop by not copying it - // over to items_for_multidrop + // over to items_for_multidrop. items_for_multidrop.clear(); - for ( unsigned int i = 0; i < tmp_items.size(); ++i ) + for (unsigned int i = 0; i < tmp_items.size(); ++i) { SelItem& si(tmp_items[i]); const int item_quant = si.item->quantity; - // EVIL HACK: fix item quantity to match the quantity we will drop, + // EVIL HACK: Fix item quantity to match the quantity we will drop, // in order to prevent misleading messages when dropping // 15 of 25 arrows inscribed with {!d}. if ( si.quantity && si.quantity != item_quant ) const_cast(si.item)->quantity = si.quantity; - // Check if we can add it to the multidrop list + // Check if we can add it to the multidrop list. bool warning_ok = check_warning_inscriptions(*(si.item), OPER_DROP); - // Restore the item quantity if we mangled it + // Restore the item quantity if we mangled it. if ( item_quant != si.item->quantity ) const_cast(si.item)->quantity = item_quant; - if ( warning_ok ) + if (warning_ok) items_for_multidrop.push_back(si); } - if ( items_for_multidrop.empty() ) // only one item + if (items_for_multidrop.empty()) // no items. { canned_msg( MSG_OK ); return; } - if ( items_for_multidrop.size() == 1 ) // only one item + if (items_for_multidrop.size() == 1) // only one item { drop_item( items_for_multidrop[0].slot, items_for_multidrop[0].quantity, diff --git a/crawl-ref/source/libgui.cc b/crawl-ref/source/libgui.cc index b39b8ca26b..8b5ae1db7f 100644 --- a/crawl-ref/source/libgui.cc +++ b/crawl-ref/source/libgui.cc @@ -1225,7 +1225,7 @@ static bool _can_use_item(item_def item, bool equipped) { // Misc. items/rods can always be evoked, cursed or not. if (item.base_type == OBJ_MISCELLANY || item_is_rod(item)) - return true; + return (true); // You can't unwield/fire a wielded cursed weapon/staff // but cursed armour and rings can be unwielded without problems. @@ -1237,7 +1237,7 @@ static bool _can_use_item(item_def item, bool equipped) return (item.base_type != OBJ_POTIONS && item.base_type != OBJ_FOOD); // In all other cases you can use the item in some way. - return true; + return (true); } static int _handle_mouse_motion(int mouse_x, int mouse_y, bool init) @@ -2349,15 +2349,21 @@ bool is_smart_cursor_enabled() void set_cursor_enabled(bool enabled) { - if (gui_smart_cursor) return; - if (enabled) TextRegionClass::_setcursortype(1); - else TextRegionClass::_setcursortype(0); + if (gui_smart_cursor) + return; + + if (enabled) + TextRegionClass::_setcursortype(1); + else + TextRegionClass::_setcursortype(0); } bool is_cursor_enabled() { - if (TextRegionClass::cursor_flag) return true; - return false; + if (TextRegionClass::cursor_flag) + return (true); + + return (false); } int wherex() diff --git a/crawl-ref/source/libutil.cc b/crawl-ref/source/libutil.cc index 364d5bf3de..dc0d1bfd5c 100644 --- a/crawl-ref/source/libutil.cc +++ b/crawl-ref/source/libutil.cc @@ -115,7 +115,7 @@ std::string apply_description(description_level_type desc, bool shell_safe(const char *file) { int match = strcspn(file, "\\`$*?|><&\n!;"); - return !(match >= 0 && file[match]); + return (match < 0 || !file[match]); } void play_sound( const char *file ) @@ -662,7 +662,9 @@ static bool glob_match( const char *pattern, const char *text, bool icase ) t = pm_lower(*text++, icase); special = true; - if (!p) return t == 0; + if (!p) + return (t == 0); + if (p == '\\' && *pattern) { p = pm_lower(*pattern++, icase); @@ -673,14 +675,14 @@ static bool glob_match( const char *pattern, const char *text, bool icase ) { // Try to match exactly at the current text position... if (!*pattern || glob_match(pattern, text - 1, icase)) - return true; + return (true); // Or skip one character in the text and try the wildcard match // again. If this is the end of the text, the match has failed. return (t ? glob_match(pattern - 1, text, icase) : false); } else if (!t || p != t && (p != '?' || !special)) - return false; + return (false); } } diff --git a/crawl-ref/source/libw32c.cc b/crawl-ref/source/libw32c.cc index 015e33c906..b2f9d1e885 100644 --- a/crawl-ref/source/libw32c.cc +++ b/crawl-ref/source/libw32c.cc @@ -1061,13 +1061,13 @@ struct DIR bool init(const char* szFind) { - // Check that it's a directory, first + // Check that it's a directory, first. { const DWORD dwAttr = GetFileAttributes(szFind); if (dwAttr == INVALID_FILE_ATTRIBUTES) - return false; + return (false); if ((dwAttr & FILE_ATTRIBUTE_DIRECTORY) == 0) - return false; + return (false); } find = szFind; @@ -1075,17 +1075,18 @@ struct DIR hFind = FindFirstFileA(find.c_str(), &wfd); wfd_valid = (hFind != INVALID_HANDLE_VALUE); - return true; + return (true); } dirent* readdir() { - if (! wfd_valid) return 0; + if (!wfd_valid) + return 0; _convert_wfd_to_dirent(); wfd_valid = (bool) FindNextFileA(hFind, &wfd); - return &entry; + return (&entry); } private: diff --git a/crawl-ref/source/libwt.cc b/crawl-ref/source/libwt.cc index f36e12ebe5..df86c5fe87 100644 --- a/crawl-ref/source/libwt.cc +++ b/crawl-ref/source/libwt.cc @@ -130,7 +130,7 @@ void update_tip_text(const char *tip) bool libgui_init_sys( ) { - return true; + return (true); } void libgui_shutdown_sys() @@ -141,7 +141,7 @@ void libgui_shutdown_sys() } void GetNextEvent(int *etype, int *key, bool *sh, bool *ct, - int *x1, int *y1, int *x2, int *y2) + int *x1, int *y1, int *x2, int *y2) { MSG msg; @@ -520,9 +520,9 @@ bool windows_change_font(char *font_name, int *font_size, bool dos) { *font_size = (cf.iPointSize / 10); strcpy(font_name, lf.lfFaceName); - return true; + return (true); } - return false; + return (false); } void windows_get_winpos(int *x, int *y) @@ -532,7 +532,7 @@ void windows_get_winpos(int *x, int *y) // set length wndpl.length = sizeof( WINDOWPLACEMENT ); - if ( GetWindowPlacement( win_main->hWnd, &wndpl ) != 0 ) + if (GetWindowPlacement( win_main->hWnd, &wndpl ) != 0) { *x = wndpl.rcNormalPosition.top; *y = wndpl.rcNormalPosition.left; diff --git a/crawl-ref/source/luadgn.cc b/crawl-ref/source/luadgn.cc index ca017d2fdf..2a0d2faac9 100644 --- a/crawl-ref/source/luadgn.cc +++ b/crawl-ref/source/luadgn.cc @@ -1432,11 +1432,9 @@ static int dgn_floor_halo(lua_State *ls) error += "'."; } else if (colour == BLACK) - { error += "Can't set floor colour to black."; - } - if (error != "") + if (!error.empty()) { luaL_argerror(ls, 2, error.c_str()); return(0); @@ -1553,7 +1551,7 @@ static cloud_type dgn_cloud_name_to_type(std::string name) static kill_category dgn_kill_name_to_category(std::string name) { - if (name == "") + if (name.empty()) return KC_OTHER; lowercase(name); @@ -1993,7 +1991,7 @@ static int dgn_count_feature_in_box(lua_State *ls) return 1; } - lua_pushnumber(ls, count_feature_in_box(x1, y1, x2, y2, feat)); + lua_pushnumber(ls, count_feature_in_box(x1, y1, x2, y2, feat)); return 1; } @@ -2011,7 +2009,7 @@ static int dgn_count_antifeature_in_box(lua_State *ls) return 1; } - lua_pushnumber(ls, count_antifeature_in_box(x1, y1, x2, y2, feat)); + lua_pushnumber(ls, count_antifeature_in_box(x1, y1, x2, y2, feat)); return 1; } @@ -2027,7 +2025,7 @@ static int dgn_count_neighbours(lua_State *ls) return 1; } - lua_pushnumber(ls, count_neighbours(x, y, feat)); + lua_pushnumber(ls, count_neighbours(x, y, feat)); return 1; } diff --git a/crawl-ref/source/makeitem.cc b/crawl-ref/source/makeitem.cc index 52989e4462..5e5b98403d 100644 --- a/crawl-ref/source/makeitem.cc +++ b/crawl-ref/source/makeitem.cc @@ -907,7 +907,7 @@ static bool _try_make_weapon_artefact(item_def& item, int force_type, if (idx != -1) { make_item_unrandart( item, idx ); - return true; + return (true); } } @@ -939,7 +939,7 @@ static bool _try_make_weapon_artefact(item_def& item, int force_type, { do_curse_item( item ); } - return true; + return (true); } // If it isn't an artefact yet, try to make a fixed artefact. @@ -951,10 +951,10 @@ static bool _try_make_weapon_artefact(item_def& item, int force_type, mprf(MSGCH_DIAGNOSTICS, "Making fixed artefact."); #endif if (make_item_fixed_artefact( item, (item_level == 51) )) - return true; + return (true); } - return false; + return (false); } static item_status_flag_type _determine_weapon_race(const item_def& item, @@ -1832,7 +1832,7 @@ static bool _try_make_armour_artefact(item_def& item, int force_type, if (idx != -1) { make_item_unrandart( item, idx ); - return true; + return (true); } } @@ -1865,9 +1865,10 @@ static bool _try_make_armour_artefact(item_def& item, int force_type, if (item.plus < 0 && !one_chance_in(3)) do_curse_item( item ); } - return true; + return (true); } - return false; + + return (false); } static item_status_flag_type _determine_armour_race(const item_def& item, @@ -2879,24 +2880,24 @@ static bool _weapon_is_visibly_special(const item_def &item) if (item.sub_type == WPN_CLUB || item.sub_type == WPN_GIANT_CLUB || item.sub_type == WPN_GIANT_SPIKED_CLUB) { - return false; + return (false); } if (get_equip_desc(item) != ISFLAG_NO_DESC) - return false; + return (false); if (visibly_branded || is_random_artefact(item)) - return true; + return (true); if ((item.plus || item.plus2) && (one_chance_in(3) || get_equip_race(item) && one_chance_in(7))) { - return true; + return (true); } - return false; + return (false); } static void _give_monster_item(monsters *mon, int thing, diff --git a/crawl-ref/source/mapdef.cc b/crawl-ref/source/mapdef.cc index 252b17cb1f..89b9607479 100644 --- a/crawl-ref/source/mapdef.cc +++ b/crawl-ref/source/mapdef.cc @@ -2854,7 +2854,7 @@ map_flags map_flags::parse(const std::string flag_list[], const std::vector segs = split_string("/", s); flag_map flag_vals; - for (int i = 0; flag_list[i] != ""; i++) + for (int i = 0; !flag_list[i].empty(); i++) flag_vals[flag_list[i]] = 1 << i; for (int i = 0, size = segs.size(); i < size; i++) diff --git a/crawl-ref/source/mapmark.cc b/crawl-ref/source/mapmark.cc index 75ffcab11e..4994b6dc32 100644 --- a/crawl-ref/source/mapmark.cc +++ b/crawl-ref/source/mapmark.cc @@ -696,7 +696,7 @@ std::vector map_markers::get_all(const std::string &key, map_marker* marker = i->second; const std::string prop = marker->property(key); - if ((val == "" && !prop.empty()) || (val != "" && val == prop)) + if (val.empty() && !prop.empty() || !val.empty() && val == prop) rmarkers.push_back(marker); } diff --git a/crawl-ref/source/maps.cc b/crawl-ref/source/maps.cc index 518037e585..426136969b 100644 --- a/crawl-ref/source/maps.cc +++ b/crawl-ref/source/maps.cc @@ -318,6 +318,7 @@ static bool map_has_no_tags(const map_def &map, I begin, I end) for ( ; begin != end; ++begin) if (map.has_tag(*begin)) return (false); + return (true); } @@ -331,7 +332,7 @@ static bool vault_unforbidden(const map_def &map) static bool map_matches_layout_type(const map_def &map) { if (dgn_Layout_Type.empty() || !map.has_tag_prefix("layout_")) - return true; + return (true); return map.has_tag("layout_" + dgn_Layout_Type); } @@ -341,6 +342,7 @@ int find_map_by_name(const std::string &name) for (unsigned i = 0, size = vdefs.size(); i < size; ++i) if (vdefs[i].name == name) return (i); + return (-1); } diff --git a/crawl-ref/source/menu.cc b/crawl-ref/source/menu.cc index 3418517ea8..672bb3d14d 100644 --- a/crawl-ref/source/menu.cc +++ b/crawl-ref/source/menu.cc @@ -241,7 +241,7 @@ bool Menu::process_key( int keyin ) if (items.size() == 0) { lastch = keyin; - return false; + return (false); } bool nav = false, repaint = false; @@ -254,14 +254,14 @@ bool Menu::process_key( int keyin ) switch (keyin) { case 0: - return true; + return (true); case CK_ENTER: - return false; + return (false); case CK_ESCAPE: case CK_MOUSE_B2: sel.clear(); lastch = keyin; - return false; + return (false); case ' ': case CK_PGDN: case '>': case '\'': case CK_MOUSE_B1: nav = true; @@ -293,7 +293,7 @@ bool Menu::process_key( int keyin ) { nav = true; const int breakpoint = (items.size() + 1) - pagesize; - if ( first_entry < breakpoint ) + if (first_entry < breakpoint) { first_entry = breakpoint; repaint = true; @@ -302,7 +302,7 @@ bool Menu::process_key( int keyin ) } case CONTROL('F'): { - if ( !( flags & MF_ALLOW_FILTER ) ) + if (!(flags & MF_ALLOW_FILTER)) break; char linebuf[80]; cgotoxy(1,1); @@ -311,20 +311,20 @@ bool Menu::process_key( int keyin ) cprintf("Select what? (regex) "); textcolor(LIGHTGREY); bool validline = !cancelable_get_line(linebuf, sizeof linebuf, 80); - if ( validline && linebuf[0] ) + if (validline && linebuf[0]) { text_pattern tpat(linebuf, true); - for ( unsigned int i = 0; i < items.size(); ++i ) + for (unsigned int i = 0; i < items.size(); ++i) { - if ( items[i]->level == MEL_ITEM && - tpat.matches(items[i]->get_text()) ) + if (items[i]->level == MEL_ITEM + && tpat.matches(items[i]->get_text())) { select_index(i); - if ( flags & MF_SINGLESELECT ) + if (flags & MF_SINGLESELECT) { // Return the first item found. get_selected(&sel); - return false; + return (false); } } } @@ -356,7 +356,7 @@ bool Menu::process_key( int keyin ) // If no selection at all is allowed, exit now. if (!(flags & (MF_SINGLESELECT | MF_MULTISELECT))) - return false; + return (false); if (!is_set(MF_NO_SELECT_QTY) && isdigit( keyin )) { @@ -369,22 +369,23 @@ bool Menu::process_key( int keyin ) select_items( keyin, num ); get_selected( &sel ); if (sel.size() == 1 && (flags & MF_SINGLESELECT)) - return false; + return (false); + draw_select_count( sel.size() ); if (flags & MF_ANYPRINTABLE && (!isdigit(keyin) || is_set(MF_NO_SELECT_QTY))) { - return false; + return (false); } break; } - if (last_selected != -1 && - (items.size() == ((unsigned int) last_selected + 1) - || items[last_selected + 1] == NULL - || items[last_selected + 1]->level != MEL_ITEM)) + if (last_selected != -1 + && (items.size() == ((unsigned int) last_selected + 1) + || items[last_selected + 1] == NULL + || items[last_selected + 1]->level != MEL_ITEM)) { last_selected = -1; } @@ -400,10 +401,10 @@ bool Menu::process_key( int keyin ) else if (sel.empty() && is_set(MF_EASY_EXIT)) { sel.clear(); - return false; + return (false); } } - return true; + return (true); } bool Menu::draw_title_suffix( const std::string &s, bool titlefirst ) @@ -417,7 +418,7 @@ bool Menu::draw_title_suffix( const std::string &s, bool titlefirst ) if (x > get_number_of_cols() || x < 1) { cgotoxy(oldx, oldy); - return false; + return (false); } // Note: 1 <= x <= get_number_of_cols(); we have no fear of overflow. @@ -429,7 +430,7 @@ bool Menu::draw_title_suffix( const std::string &s, bool titlefirst ) cprintf("%s", towrite.c_str()); cgotoxy( oldx, oldy ); - return true; + return (true); } bool Menu::draw_title_suffix( const formatted_string &fs, bool titlefirst ) @@ -443,7 +444,7 @@ bool Menu::draw_title_suffix( const formatted_string &fs, bool titlefirst ) if (x > get_number_of_cols() || x < 1) { cgotoxy(oldx, oldy); - return false; + return (false); } // Note: 1 <= x <= get_number_of_cols(); we have no fear of overflow. @@ -466,7 +467,7 @@ bool Menu::draw_title_suffix( const formatted_string &fs, bool titlefirst ) } cgotoxy( oldx, oldy ); - return true; + return (true); } void Menu::draw_select_count( int count, bool force ) @@ -590,15 +591,16 @@ void Menu::select_items( int key, int qty ) bool Menu::is_selectable(int item) const { - if (select_filter.empty()) return true; + if (select_filter.empty()) + return (true); std::string text = items[item]->get_text(); for (int i = 0, count = select_filter.size(); i < count; ++i) { if (select_filter[i].matches(text)) - return true; + return (true); } - return false; + return (false); } void Menu::select_index( int index, int qty ) @@ -612,8 +614,10 @@ void Menu::select_index( int index, int qty ) for (int i = 0, count = items.size(); i < count; ++i) { if (items[i]->level != MEL_ITEM - || items[i]->hotkeys.empty()) + || items[i]->hotkeys.empty()) + { continue; + } if (is_hotkey(i, items[i]->hotkeys[0]) && is_selectable(i)) { last_selected = i; @@ -628,8 +632,10 @@ void Menu::select_index( int index, int qty ) for (int i = si + 1, count = items.size(); i < count; ++i) { if (items[i]->level != MEL_ITEM - || items[i]->hotkeys.empty()) + || items[i]->hotkeys.empty()) + { continue; + } if (is_hotkey(i, items[i]->hotkeys[0])) { last_selected = i; @@ -638,8 +644,8 @@ void Menu::select_index( int index, int qty ) } } } - else if (items[si]->level == MEL_ITEM && - (flags & (MF_SINGLESELECT | MF_MULTISELECT))) + else if (items[si]->level == MEL_ITEM + && (flags & (MF_SINGLESELECT | MF_MULTISELECT))) { last_selected = si; items[si]->select( qty ); @@ -653,7 +659,8 @@ int Menu::get_entry_index( const MenuEntry *e ) const for (unsigned int i = first_entry; i < items.size(); i++) { if (items[i] == e) - return index; + return (index); + if (items[i]->quantity != 0) index++; } @@ -673,9 +680,8 @@ void Menu::draw_menu() if (end > (int) items.size()) end = items.size(); for (int i = first_entry; i < end; ++i) - { draw_item( i ); - } + if (end < (int) items.size() || is_set(MF_ALWAYS_SHOW_MORE)) { cgotoxy( 1, y_offset + pagesize - count_linebreaks(more) ); @@ -781,9 +787,9 @@ bool Menu::page_down() // first_entry = items.size() - pagesize; if (old_first != first_entry) - return true; + return (true); } - return false; + return (false); } bool Menu::page_up() @@ -794,10 +800,11 @@ bool Menu::page_up() { if ((first_entry -= pagesize) < 0) first_entry = 0; + if (old_first != first_entry) - return true; + return (true); } - return false; + return (false); } bool Menu::line_down() @@ -805,9 +812,9 @@ bool Menu::line_down() if (first_entry + pagesize < (int) items.size()) { ++first_entry; - return true; + return (true); } - return false; + return (false); } bool Menu::line_up() @@ -815,9 +822,9 @@ bool Menu::line_up() if (first_entry > 0) { --first_entry; - return true; + return (true); } - return false; + return (false); } ///////////////////////////////////////////////////////////////// @@ -1507,13 +1514,15 @@ void print_formatted_paragraph(std::string &s, int maxcol, bool formatted_scroller::jump_to( int i ) { - if ( i == first_entry + 1 ) - return false; - if ( i == 0 ) + if (i == first_entry + 1) + return (false); + + if (i == 0) first_entry = 0; else first_entry = i - 1; - return true; + + return (true); } // Don't scroll past MEL_TITLE entries @@ -1521,8 +1530,8 @@ bool formatted_scroller::page_down() { const int old_first = first_entry; - if ( (int)items.size() <= first_entry + pagesize ) - return false; + if ((int) items.size() <= first_entry + pagesize) + return (false); // If, when scrolling forward, we encounter a MEL_TITLE // somewhere in the newly displayed page, stop scrolling @@ -1546,13 +1555,14 @@ bool formatted_scroller::page_up() // somewhere in the newly displayed page, stop scrolling // just before it becomes visible - if ( items[first_entry]->level == MEL_TITLE ) - return false; + if (items[first_entry]->level == MEL_TITLE) + return (false); for ( int i = 0; i < pagesize; ++i ) { if (first_entry == 0 || items[first_entry-1]->level == MEL_TITLE) break; + --first_entry; } @@ -1565,9 +1575,9 @@ bool formatted_scroller::line_down() items[first_entry + pagesize]->level != MEL_TITLE ) { ++first_entry; - return true; + return (true); } - return false; + return (false); } bool formatted_scroller::line_up() @@ -1576,17 +1586,18 @@ bool formatted_scroller::line_up() items[first_entry]->level != MEL_TITLE) { --first_entry; - return true; + return (true); } - return false; + return (false); } bool formatted_scroller::jump_to_hotkey( int keyin ) { - for ( unsigned int i = 0; i < items.size(); ++i ) - if ( items[i]->is_hotkey(keyin) ) + for (unsigned int i = 0; i < items.size(); ++i) + if (items[i]->is_hotkey(keyin)) return jump_to(i); - return false; + + return (false); } @@ -1599,13 +1610,13 @@ bool formatted_scroller::process_key( int keyin ) bool repaint = false; // Any key is assumed to be a movement key for now... bool moved = true; - switch ( keyin ) + switch (keyin) { case 0: - return true; + return (true); case -1: case CK_ESCAPE: - return false; + return (false); case ' ': case '+': case '=': case CK_PGDN: case '>': case '\'': #ifdef USE_TILE case CK_MOUSE_B5: @@ -1641,12 +1652,11 @@ bool formatted_scroller::process_key( int keyin ) select_items( keyin, -1 ); get_selected( &sel ); if (sel.size() >= 1) - return false; + return (false); } else - { repaint = jump_to_hotkey(keyin); - } + break; } @@ -1655,7 +1665,7 @@ bool formatted_scroller::process_key( int keyin ) else if (moved && is_set(MF_EASY_EXIT)) return (false); - return true; + return (true); } int ToggleableMenu::pre_process(int key) diff --git a/crawl-ref/source/mgrow.cc b/crawl-ref/source/mgrow.cc index a8c6f9b926..bdaf066465 100644 --- a/crawl-ref/source/mgrow.cc +++ b/crawl-ref/source/mgrow.cc @@ -192,19 +192,19 @@ void monsters::init_experience() bool monsters::gain_exp(int exp) { if (!alive()) - return false; + return (false); init_experience(); if (hit_dice >= MAX_MONS_HD) - return false; + return (false); // Only natural monsters can level-up. if (holiness() != MH_NATURAL) - return false; + return (false); // Avoid wrap-around. if (experience + exp < experience) - return false; + return (false); experience += exp; diff --git a/crawl-ref/source/misc.cc b/crawl-ref/source/misc.cc index 65af62fd85..bc66970127 100644 --- a/crawl-ref/source/misc.cc +++ b/crawl-ref/source/misc.cc @@ -12,7 +12,6 @@ * <1> -/--/-- LRH Created */ - #include "AppHdr.h" #include "misc.h" #include "notes.h" @@ -484,7 +483,7 @@ bool maybe_coagulate_blood_potions_inv(item_def &blood) } if (!rot_count && !coag_count) - return false; // nothing to be done + return (false); // Nothing to be done. #ifdef DEBUG_BLOOD_POTIONS mprf(MSGCH_DIAGNOSTICS, "in maybe_coagulate_blood_potions_INV " @@ -512,7 +511,7 @@ bool maybe_coagulate_blood_potions_inv(item_def &blood) else ASSERT(blood.quantity == timer.size()); - return true; + return (true); } // Coagulated blood cannot coagulate any further... @@ -687,7 +686,8 @@ bool maybe_coagulate_blood_potions_inv(item_def &blood) ASSERT(timer.size() == blood.quantity); if (!knew_blood) mpr(blood.name(DESC_INVENTORY).c_str()); - return true; + + return (true); } o = mitm[o].link; } @@ -696,7 +696,7 @@ bool maybe_coagulate_blood_potions_inv(item_def &blood) // Create a new stack of potions. o = get_item_slot( 100 + random2(200) ); if (o == NON_ITEM) - return false; + return (false); // These values are common to all: {dlb} mitm[o].base_type = OBJ_POTIONS; @@ -739,7 +739,7 @@ bool maybe_coagulate_blood_potions_inv(item_def &blood) if (!knew_blood) mpr(blood.name(DESC_INVENTORY).c_str()); } - return true; + return (true); } // Mostly used for (q)uaff, (f)ire, and Evaporate. @@ -2304,8 +2304,8 @@ bool go_berserk(bool intentional) if (you.berserk_penalty != NO_BERSERK_PENALTY) you.berserk_penalty = 0; - return true; -} // end go_berserk() + return (true); +} bool mons_is_safe(const struct monsters *mon, bool want_move) { @@ -2339,7 +2339,7 @@ bool mons_is_safe(const struct monsters *mon, bool want_move) } #endif - return is_safe; + return (is_safe); } // Return all monsters in range (default: LOS) that the player is able to see @@ -2414,7 +2414,7 @@ bool i_feel_safe(bool announce, bool want_move, bool just_monsters, int range) // No monsters found. if (visible.empty()) - return true; + return (true); // Announce the presence of monsters (Eidolos). if (visible.size() == 1) diff --git a/crawl-ref/source/mon-pick.cc b/crawl-ref/source/mon-pick.cc index 2c28233d78..e02a013110 100644 --- a/crawl-ref/source/mon-pick.cc +++ b/crawl-ref/source/mon-pick.cc @@ -291,9 +291,9 @@ bool mons_abyss(int mcls) case MONS_DRACONIAN_ANNIHILATOR: case MONS_DRACONIAN_ZEALOT: case MONS_DRACONIAN_SHIFTER: - return true; + return (true); default: - return false; + return (false); } } // end mons_abyss() @@ -539,9 +539,9 @@ bool mons_pan(int mcls) case MONS_UFETUBUS: case MONS_WHITE_IMP: case MONS_YNOXINUL: - return true; + return (true); default: - return false; + return (false); } } // end mons_pan() diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc index 9836615fba..ff97a897ef 100644 --- a/crawl-ref/source/mon-util.cc +++ b/crawl-ref/source/mon-util.cc @@ -493,10 +493,10 @@ bool mons_is_native_in_branch(const monsters *monster, bool mons_is_chaotic(const monsters *mon) { if (mon->has_ench(ENCH_GLOWING_SHAPESHIFTER, ENCH_SHAPESHIFTER)) - return true; + return (true); if (mon->has_spell(SPELL_POLYMORPH_OTHER)) - return true; + return (true); const int attk_flavour = mons_attack_spec(mon, 0).flavour; return (attk_flavour == AF_MUTATE || attk_flavour == AF_ROT); @@ -505,7 +505,7 @@ bool mons_is_chaotic(const monsters *mon) bool mons_is_poisoner(const monsters *mon) { if (mons_corpse_effect(mon->type) == CE_POISONOUS) - return true; + return (true); const int attk_flavour = mons_attack_spec(mon, 0).flavour; return (attk_flavour == AF_POISON @@ -1953,7 +1953,7 @@ bool give_monster_proper_name(monsters *mon, bool orcs_only) if (mons_species(mon->type) != MONS_ORC || mon->type == MONS_ORC && !one_chance_in(8)) { - return false; + return (false); } } @@ -3434,8 +3434,8 @@ void monsters::unequip_armour(item_def &item, int near) bool monsters::unequip(item_def &item, int slot, int near, bool force) { - if (item.cursed() && !force) - return false; + if (!force && item.cursed()) + return (false); if (!force && mons_near(this) && player_monster_visible(this)) set_ident_flags(item, ISFLAG_KNOW_CURSE); @@ -3457,7 +3457,7 @@ bool monsters::unequip(item_def &item, int slot, int near, bool force) break; } - return true; + return (true); } void monsters::lose_pickup_energy() @@ -3490,7 +3490,7 @@ bool monsters::pickup(item_def &item, int slot, int near, bool force_merge) && hands_reqd(item, body_size(PSIZE_BODY)) == HANDS_TWO) { if (!drop_item(MSLOT_SHIELD, near)) - return false; + return (false); } if (inv[slot] != NON_ITEM) @@ -3593,11 +3593,12 @@ bool monsters::pickup_launcher(item_def &launch, int near) static bool _is_signature_weapon(monsters *monster, const item_def &weapon) { if (weapon.base_type != OBJ_WEAPONS) - return false; + return (false); if (monster->type == MONS_DAEVA) return (weapon.sub_type == WPN_BLESSED_EUDEMON_BLADE); + // We might allow Sigmund to pick up a better scythe if he finds one... if (monster->type == MONS_SIGMUND) return (weapon.sub_type == WPN_SCYTHE); @@ -3613,7 +3614,7 @@ static bool _is_signature_weapon(monsters *monster, const item_def &weapon) return (monster->type == MONS_CEREBOV); } } - return false; + return (false); } bool monsters::pickup_melee_weapon(item_def &item, int near) @@ -3664,11 +3665,11 @@ bool monsters::pickup_melee_weapon(item_def &item, int near) // No slot found to place this item. if (eslot == -1) - return false; + return (false); // Current item cannot be dropped. if (inv[eslot] != NON_ITEM && !drop_item(eslot, near)) - return false; + return (false); return (pickup(item, eslot, near)); } @@ -3998,7 +3999,7 @@ bool monsters::pickup_scroll(item_def &item, int near) && item.sub_type != SCR_BLINKING && item.sub_type != SCR_SUMMONING) { - return false; + return (false); } return pickup(item, MSLOT_SCROLL, near); } @@ -4006,7 +4007,7 @@ bool monsters::pickup_scroll(item_def &item, int near) bool monsters::pickup_potion(item_def &item, int near) { // Only allow monsters to pick up potions if they can actually use them. - switch(item.sub_type) + switch (item.sub_type) { case POT_HEALING: case POT_HEAL_WOUNDS: @@ -4014,19 +4015,21 @@ bool monsters::pickup_potion(item_def &item, int near) || mons_holiness(this) == MH_NONLIVING || mons_holiness(this) == MH_PLANT) { - return false; + return (false); } break; case POT_BLOOD: case POT_BLOOD_COAGULATED: if (::mons_species(this->type) != MONS_VAMPIRE) - return false; + return (false); break; case POT_SPEED: case POT_INVISIBILITY: + // If there are any item using monsters that are permanently invisible + // this might have to be restricted. break; default: - return false; + return (false); } return pickup(item, MSLOT_POTION, near); @@ -5130,7 +5133,7 @@ bool monsters::del_ench(enchant_type ench, bool quiet, bool effect) const enchant_type et = i->first; if (!_prepare_del_ench(this, me)) - return false; + return (false); enchantments.erase(et); if (effect) @@ -5312,7 +5315,7 @@ void monsters::remove_enchantment_effect(const mon_enchant &me, bool quiet) && is_run_delay(current_delay_action())) { // Already set somewhere else. - if (seen_context != "") + if (!seen_context.empty()) return; if (type == MONS_AIR_ELEMENTAL) @@ -6100,7 +6103,7 @@ bool monsters::can_see(const actor *target) const return visible_to(target); if (!target->visible_to(this)) - return false; + return (false); if (target->atype() == ACT_PLAYER) return mons_near(this); @@ -6123,7 +6126,7 @@ bool monsters::can_safely_mutate() const bool monsters::mutate() { if (!can_mutate()) - return false; + return (false); return (monster_polymorph(this, RANDOM_MONSTER)); } diff --git a/crawl-ref/source/monspeak.cc b/crawl-ref/source/monspeak.cc index b1e5887ef1..de5db2b641 100644 --- a/crawl-ref/source/monspeak.cc +++ b/crawl-ref/source/monspeak.cc @@ -215,7 +215,7 @@ bool mons_speaks(const monsters *monster) if (monster->invisible() && !(player_monster_visible(monster) && monster->has_ench(ENCH_CONFUSION))) { - return false; + return (false); } // Silenced monsters only "speak" 1/3 as often as non-silenced, @@ -226,27 +226,27 @@ bool mons_speaks(const monsters *monster) && get_monster_data(monster->type)->shouts != S_SILENT) { if (!one_chance_in(3)) - return false; + return (false); } // Berserk monsters just want your hide. if (monster->has_ench(ENCH_BERSERK)) - return false; + return (false); // Monsters in a battle frenzy are likewise occupied. if (monster->has_ench(ENCH_BATTLE_FRENZY) && !one_chance_in(3)) - return false; + return (false); // Charmed monsters aren't too expressive. if (monster->has_ench(ENCH_CHARM) && !one_chance_in(3)) - return false; + return (false); std::vector prefixes; if (mons_neutral(monster)) { if (coinflip()) // Neutrals speak half as often. - return false; + return (false); prefixes.push_back("neutral"); } @@ -341,7 +341,7 @@ bool mons_speaks(const monsters *monster) #ifdef DEBUG_MONSPEAK mpr("result: \"__NONE\"!", MSGCH_DIAGNOSTICS); #endif - return false; + return (false); } // Now that we're not dealing with a specific monster name, include @@ -369,7 +369,7 @@ bool mons_speaks(const monsters *monster) #ifdef DEBUG_MONSPEAK mpr("result: \"__NONE\"!", MSGCH_DIAGNOSTICS); #endif - return false; + return (false); } // Monster symbol didn't work, try monster shape. Since we're @@ -421,7 +421,7 @@ bool mons_speaks(const monsters *monster) #ifdef DEBUG_MONSPEAK mpr("result: \"__NONE\"!", MSGCH_DIAGNOSTICS); #endif - return false; + return (false); } // If we failed to get a message with a winged or tailed humanoid, @@ -453,7 +453,7 @@ bool mons_speaks(const monsters *monster) #ifdef DEBUG_MONSPEAK mpr("result: \"__NONE\"!", MSGCH_DIAGNOSTICS); #endif - return false; + return (false); } if (msg2 == "__NONE") @@ -476,7 +476,7 @@ bool mons_speaks(const monsters *monster) mprf(MSGCH_DIAGNOSTICS, "final result: %s!", (msg.empty() ? "empty" : "\"__NONE\"")); #endif - return false; + return (false); } if (msg == "__NEXT") @@ -484,7 +484,7 @@ bool mons_speaks(const monsters *monster) msg::streams(MSGCH_DIAGNOSTICS) << "__NEXT used by shape-based speech string for monster '" << monster->name(DESC_PLAIN) << "'" << std::endl; - return false; + return (false); } // We have a speech string, now parse and act on it. @@ -562,5 +562,5 @@ bool mons_speaks(const monsters *monster) mpr(line.c_str(), msg_type); } - return true; + return (true); } // end mons_speaks = end of routine diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc index fea7ff7167..42c67aa419 100644 --- a/crawl-ref/source/monstuff.cc +++ b/crawl-ref/source/monstuff.cc @@ -520,7 +520,7 @@ static bool _ely_heals_monster(monsters *monster, killer_type killer, int i) god_type god = GOD_ELYVILON; if (!you.penance[god] || !is_evil_god(you.religion)) - return false; + return (false); const int ely_penance = you.penance[god]; @@ -3575,7 +3575,7 @@ void _set_nearest_monster_foe(monsters *mon) // The default suitable() function for choose_random_nearby_monster(). bool choose_any_monster(const monsters* mon) { - return true; + return (true); } // Find a nearby monster and return its index, including you as a @@ -4830,7 +4830,7 @@ static bool _handle_wand(monsters *monster, bolt &beem) // Monsters can be very trigger happy with wands, reduce this // for polymorph. if (!one_chance_in(5)) - return false; + return (false); break; // These are wands that monsters will aim at themselves {dlb}: @@ -6604,31 +6604,31 @@ static bool _do_move_monster(monsters *monster, int xi, int yi) fy = monster->y + yi; if (!in_bounds(fx, fy)) - return false; + return (false); if (fx == you.x_pos && fy == you.y_pos) { monster_attack( monster_index(monster) ); - return true; + return (true); } if (!xi && !yi) { const int mx = monster_index(monster); monsters_fight( mx, mx ); - return true; + return (true); } if (mgrd[fx][fy] != NON_MONSTER) { monsters_fight( monster_index(monster), mgrd[fx][fy] ); - return true; + return (true); } if (!xi && !yi) - return false; + return (false); - // this appears to be the real one, ie where the movement occurs: + // This appears to be the real one, ie where the movement occurs: _swim_or_move_energy(monster); mgrd[monster->x][monster->y] = NON_MONSTER; @@ -6641,7 +6641,7 @@ static bool _do_move_monster(monsters *monster, int xi, int yi) monster->check_redraw(monster->pos() - coord_def(xi, yi)); monster->apply_location_effects(); - return true; + return (true); } void mons_check_pool(monsters *mons, killer_type killer, int killnum) diff --git a/crawl-ref/source/mutation.cc b/crawl-ref/source/mutation.cc index 341eff36b7..e240da9408 100644 --- a/crawl-ref/source/mutation.cc +++ b/crawl-ref/source/mutation.cc @@ -1335,7 +1335,7 @@ formatted_string describe_mutations() std::string name = mutation_name(mut_type); - if (name == "") + if (name.empty()) { int level; if (!fully_active) @@ -1397,7 +1397,7 @@ formatted_string describe_mutations() std::string name = mutation_name(mut_type); - if (name == "") + if (name.empty()) { int level; if (!mutation_is_fully_active(mut_type)) @@ -1714,14 +1714,14 @@ bool mutate(mutation_type which_mutation, bool failMsg, { if (failMsg) mpr("You feel odd for a moment.", MSGCH_MUTATION); - return false; + return (false); } // Zin's protection. if (you.religion == GOD_ZIN && you.piety > random2(MAX_PIETY)) { simple_god_message(" protects your body from chaos!"); - return false; + return (false); } } @@ -1775,7 +1775,7 @@ bool mutate(mutation_type which_mutation, bool failMsg, } xom_is_stimulated(64); - return true; + return (true); } if (which_mutation == RANDOM_MUTATION @@ -1786,7 +1786,7 @@ bool mutate(mutation_type which_mutation, bool failMsg, // God gifts override mutation loss due to being heavily // mutated. if (!one_chance_in(3) && !god_gift && !force_mutation) - return false; + return (false); else return (delete_mutation(RANDOM_MUTATION)); } @@ -1798,43 +1798,45 @@ bool mutate(mutation_type which_mutation, bool failMsg, { mutat = static_cast(random2(NUM_MUTATIONS)); if (one_chance_in(1000)) - return false; + return (false); } while (!accept_mutation(mutat)); } else if (which_mutation == RANDOM_XOM_MUTATION) { if ((mutat = get_random_xom_mutation()) == NUM_MUTATIONS) - return false; + return (false); } else if (which_mutation == RANDOM_GOOD_MUTATION) { if ((mutat = get_random_mutation(true, 500)) == NUM_MUTATIONS) - return false; + return (false); } else if (which_mutation == RANDOM_BAD_MUTATION) { if ((mutat = get_random_mutation(false, 500)) == NUM_MUTATIONS) - return false; + return (false); } else if (you.mutation[mutat] >= 3 && mutat != MUT_STRONG && mutat != MUT_CLEVER && mutat != MUT_AGILE && mutat != MUT_WEAK && mutat != MUT_DOPEY && mutat != MUT_CLUMSY) { - return false; + // Mutation level greater than allowed. + return (false); } + // Mutation level greater than allowed for stat mutations. if (you.mutation[mutat] > 13 && !force_mutation) - return false; + return (false); // Saprovorous can't be randomly acquired. if (mutat == MUT_SAPROVOROUS && !force_mutation) - return false; + return (false); // Mutation resistance can't be acquired from god gifts. if (mutat == MUT_MUTATION_RESISTANCE && god_gift && !force_mutation) - return false; + return (false); // These can be forced by demonspawn or god gifts. if ((mutat == MUT_TOUGH_SKIN || mutat == MUT_SHAGGY_FUR @@ -1842,16 +1844,16 @@ bool mutate(mutation_type which_mutation, bool failMsg, || mutat >= MUT_RED_SCALES && mutat <= MUT_PATTERNED_SCALES) && body_covered() >= 3 && !god_gift && !force_mutation) { - return false; + return (false); } if (you.species == SP_NAGA) { - // gdl: spit poison 'upgrades' to breathe poison. Why not.. + // gdl: Spit poison 'upgrades' to breathe poison. Why not... if (mutat == MUT_SPIT_POISON) { if (coinflip()) - return false; + return (false); { mutat = MUT_BREATHE_POISON; @@ -1868,69 +1870,69 @@ bool mutate(mutation_type which_mutation, bool failMsg, && you.mutation[MUT_SLOW_METABOLISM] > 0 && !god_gift && !force_mutation) { - return false; // if you have a slow metabolism, no regen + // If you have a slow metabolism, no regeneration. + return (false); } + // If you have regen, no slow metabolism. if (mutat == MUT_SLOW_METABOLISM && you.mutation[MUT_REGENERATION] > 0) - return false; // if you have regen, no slow metabolism + return (false); // This one can be forced by demonspawn or god gifts. if (mutat == MUT_ACUTE_VISION && you.mutation[MUT_BLURRY_VISION] > 0 && !god_gift && !force_mutation) { - return false; + return (false); } + // blurred vision/see invis if (mutat == MUT_BLURRY_VISION && you.mutation[MUT_ACUTE_VISION] > 0) - return false; // blurred vision/see invis + return (false); - // only Nagas and Draconians can get this one + // Only Nagas and Draconians can get this one. if (mutat == MUT_STINGER && !(you.species == SP_NAGA || player_genus(GENPC_DRACONIAN))) { - return false; + return (false); } - // putting boots on after they are forced off. -- bwr + // Putting boots on after they are forced off. -- bwr if ((mutat == MUT_HOOVES || mutat == MUT_TALONS) && !player_has_feet()) { - return false; + return (false); } - // no fangs sprouting from Kenkus' beaks + // No fangs sprouting from Kenkus' beaks. if (mutat == MUT_FANGS && you.species == SP_KENKU) - return false; + return (false); - // already innate + // Already innate. if (mutat == MUT_BREATHE_POISON && you.species != SP_NAGA) - return false; + return (false); - // only Draconians can get wings + // Only Draconians can get wings. if (mutat == MUT_BIG_WINGS && !player_genus(GENPC_DRACONIAN)) - return false; + return (false); // Vampires' thirst rate depends on their blood level. if (you.species == SP_VAMPIRE && (mutat == MUT_SLOW_METABOLISM || mutat == MUT_FAST_METABOLISM || mutat == MUT_CARNIVOROUS || mutat == MUT_HERBIVOROUS)) { - return false; + return (false); } if (you.mutation[mutat] >= mutation_defs[mutat].levels) - return false; + return (false); - // find where these things are actually changed - // -- do not globally force redraw {dlb} + // FIXME: Find where these things are actually changed. + // -- Do not globally force redraw! {dlb} you.redraw_hit_points = 1; you.redraw_magic_points = 1; you.redraw_armour_class = 1; you.redraw_evasion = 1; -// you.redraw_experience = 1; -// you.redraw_gold = 1; -// you.redraw_hunger = 1; switch (mutat) { @@ -1938,9 +1940,9 @@ bool mutate(mutation_type which_mutation, bool failMsg, if (you.mutation[MUT_WEAK] > 0) { delete_mutation(MUT_WEAK); - return true; + return (true); } - // replaces earlier, redundant code - 12mar2000 {dlb} + // Replaces earlier, redundant code. - 12mar2000 {dlb} modify_stat(STAT_STRENGTH, 1, false, "gaining a mutation"); break; @@ -1948,9 +1950,9 @@ bool mutate(mutation_type which_mutation, bool failMsg, if (you.mutation[MUT_DOPEY] > 0) { delete_mutation(MUT_DOPEY); - return true; + return (true); } - // replaces earlier, redundant code - 12mar2000 {dlb} + // Replaces earlier, redundant code. - 12mar2000 {dlb} modify_stat(STAT_INTELLIGENCE, 1, false, "gaining a mutation"); break; @@ -1958,9 +1960,9 @@ bool mutate(mutation_type which_mutation, bool failMsg, if (you.mutation[MUT_CLUMSY] > 0) { delete_mutation(MUT_CLUMSY); - return true; + return (true); } - // replaces earlier, redundant code - 12mar2000 {dlb} + // Replaces earlier, redundant code - 12mar2000 {dlb} modify_stat(STAT_DEXTERITY, 1, false, "gaining a mutation"); break; @@ -1968,7 +1970,7 @@ bool mutate(mutation_type which_mutation, bool failMsg, if (you.mutation[MUT_STRONG] > 0) { delete_mutation(MUT_STRONG); - return true; + return (true); } modify_stat(STAT_STRENGTH, -1, true, "gaining a mutation"); mpr(gain_mutation[mutat][0], MSGCH_MUTATION); @@ -1978,7 +1980,7 @@ bool mutate(mutation_type which_mutation, bool failMsg, if (you.mutation[MUT_CLEVER] > 0) { delete_mutation(MUT_CLEVER); - return true; + return (true); } modify_stat(STAT_INTELLIGENCE, -1, true, "gaining a mutation"); mpr(gain_mutation[mutat][0], MSGCH_MUTATION); @@ -1988,7 +1990,7 @@ bool mutate(mutation_type which_mutation, bool failMsg, if (you.mutation[MUT_AGILE] > 0) { delete_mutation(MUT_AGILE); - return true; + return (true); } modify_stat(STAT_DEXTERITY, -1, true, "gaining a mutation"); mpr(gain_mutation[mutat][0], MSGCH_MUTATION); @@ -2020,7 +2022,7 @@ bool mutate(mutation_type which_mutation, bool failMsg, if (you.mutation[MUT_HERBIVOROUS] > 0) { delete_mutation(MUT_HERBIVOROUS); - return true; + return (true); } mpr(gain_mutation[mutat][you.mutation[mutat]], MSGCH_MUTATION); break; @@ -2029,7 +2031,7 @@ bool mutate(mutation_type which_mutation, bool failMsg, if (you.mutation[MUT_CARNIVOROUS] > 0) { delete_mutation(MUT_CARNIVOROUS); - return true; + return (true); } mpr(gain_mutation[mutat][you.mutation[mutat]], MSGCH_MUTATION); break; @@ -2038,7 +2040,7 @@ bool mutate(mutation_type which_mutation, bool failMsg, if (you.mutation[MUT_SLOW_METABOLISM] > 0) { delete_mutation(MUT_SLOW_METABOLISM); - return true; + return (true); } mpr(gain_mutation[mutat][you.mutation[mutat]], MSGCH_MUTATION); break; @@ -2047,7 +2049,7 @@ bool mutate(mutation_type which_mutation, bool failMsg, if (you.mutation[MUT_FAST_METABOLISM] > 0) { delete_mutation(MUT_FAST_METABOLISM); - return true; + return (true); } mpr(gain_mutation[mutat][you.mutation[mutat]], MSGCH_MUTATION); break; @@ -2088,7 +2090,7 @@ bool mutate(mutation_type which_mutation, bool failMsg, if (you.mutation[MUT_FLEXIBLE_WEAK] > 0) { delete_mutation(MUT_FLEXIBLE_WEAK); - return true; + return (true); } modify_stat(STAT_STRENGTH, 1, true, "gaining a mutation"); modify_stat(STAT_DEXTERITY, -1, true, "gaining a mutation"); @@ -2099,7 +2101,7 @@ bool mutate(mutation_type which_mutation, bool failMsg, if (you.mutation[MUT_STRONG_STIFF] > 0) { delete_mutation(MUT_STRONG_STIFF); - return true; + return (true); } modify_stat(STAT_STRENGTH, -1, true, "gaining a mutation"); modify_stat(STAT_DEXTERITY, 1, true, "gaining a mutation"); @@ -2110,7 +2112,7 @@ bool mutate(mutation_type which_mutation, bool failMsg, if (you.mutation[MUT_ROBUST] > 0) { delete_mutation(MUT_ROBUST); - return true; + return (true); } mpr(gain_mutation[mutat][you.mutation[mutat]], MSGCH_MUTATION); // special-case check @@ -2123,7 +2125,7 @@ bool mutate(mutation_type which_mutation, bool failMsg, if (you.mutation[MUT_FRAIL] > 0) { delete_mutation(MUT_FRAIL); - return true; + return (true); } mpr(gain_mutation[mutat][you.mutation[mutat]], MSGCH_MUTATION); // special-case check @@ -2136,7 +2138,7 @@ bool mutate(mutation_type which_mutation, bool failMsg, if (you.mutation[MUT_HIGH_MAGIC] > 0) { delete_mutation(MUT_HIGH_MAGIC); - return true; + return (true); } mpr(gain_mutation[mutat][you.mutation[mutat]], MSGCH_MUTATION); // special-case check @@ -2149,7 +2151,7 @@ bool mutate(mutation_type which_mutation, bool failMsg, if (you.mutation[MUT_LOW_MAGIC] > 0) { delete_mutation(MUT_LOW_MAGIC); - return true; + return (true); } mpr(gain_mutation[mutat][you.mutation[mutat]], MSGCH_MUTATION); // special-case check @@ -2195,12 +2197,12 @@ bool mutate(mutation_type which_mutation, bool failMsg, you.mutation[mutat]++; - // amusement value will be 16 * (11-rarity) * Xom's-sense-of-humor - int amusementvalue = calc_mutation_amusement_value(mutat); - xom_is_stimulated(amusementvalue); + // Amusement value will be 16 * (11-rarity) * Xom's-sense-of-humor. + int amusement_value = calc_mutation_amusement_value(mutat); + xom_is_stimulated(amusement_value); take_note(Note(NOTE_GET_MUTATION, mutat, you.mutation[mutat])); - return true; + return (true); } int how_mutated(bool all, bool levels) @@ -2251,7 +2253,7 @@ bool delete_mutation(mutation_type which_mutation, bool failMsg, { if (failMsg) mpr("You feel rather odd for a moment.", MSGCH_MUTATION); - return false; + return (false); } } @@ -2264,7 +2266,7 @@ bool delete_mutation(mutation_type which_mutation, bool failMsg, { mutat = static_cast(random2(NUM_MUTATIONS)); if (one_chance_in(1000)) - return false; + return (false); } while ((you.mutation[mutat] == 0 && (mutat != MUT_STRONG && mutat != MUT_CLEVER @@ -2280,10 +2282,10 @@ bool delete_mutation(mutation_type which_mutation, bool failMsg, } if (you.mutation[mutat] == 0) - return false; + return (false); if (you.demon_pow[mutat] >= you.mutation[mutat]) - return false; + return (false); switch (mutat) { @@ -2396,20 +2398,17 @@ bool delete_mutation(mutation_type which_mutation, bool failMsg, break; } - // find where these things are actually altered - // -- do not globally force redraw {dlb} + // FIXME: Find where these things are actually altered. + // -- Do not globally force redraw! {dlb} you.redraw_hit_points = 1; you.redraw_magic_points = 1; you.redraw_armour_class = 1; you.redraw_evasion = 1; -// you.redraw_experience = 1; -// you.redraw_gold = 1; -// you.redraw_hunger = 1; you.mutation[mutat]--; take_note(Note(NOTE_LOSE_MUTATION, mutat, you.mutation[mutat])); - return true; + return (true); } // end delete_mutation() static int body_covered() diff --git a/crawl-ref/source/newgame.cc b/crawl-ref/source/newgame.cc index ded648f89b..439e91a98b 100644 --- a/crawl-ref/source/newgame.cc +++ b/crawl-ref/source/newgame.cc @@ -106,6 +106,13 @@ extern std::string init_file_error; #define MIN_START_STAT 1 +enum char_choice_restriction +{ + CC_BANNED = 0, + CC_RESTRICTED, + CC_UNRESTRICTED +}; + static char_choice_restriction _class_allowed(species_type speci, job_type char_class); static bool _is_good_combination( species_type spc, job_type cls, diff --git a/crawl-ref/source/notes.cc b/crawl-ref/source/notes.cc index 0930e3f000..5a03322aab 100644 --- a/crawl-ref/source/notes.cc +++ b/crawl-ref/source/notes.cc @@ -51,21 +51,21 @@ static bool _is_noteworthy_skill_level( int level ) { for (unsigned int i = 0; i < Options.note_skill_levels.size(); ++i) if (level == Options.note_skill_levels[i]) - return true; + return (true); - return false; + return (false); } static bool _is_highest_skill( int skill ) { - for ( int i = 0; i < NUM_SKILLS; ++i ) + for (int i = 0; i < NUM_SKILLS; ++i) { - if ( i == skill ) + if (i == skill) continue; - if ( you.skills[i] >= you.skills[skill] ) - return false; + if (you.skills[i] >= you.skills[skill]) + return (false); } - return true; + return (true); } static bool _is_noteworthy_hp( int hp, int maxhp ) diff --git a/crawl-ref/source/output.cc b/crawl-ref/source/output.cc index 7da5db1f69..d382cbd2f8 100644 --- a/crawl-ref/source/output.cc +++ b/crawl-ref/source/output.cc @@ -1252,9 +1252,9 @@ monster_pane_info::less_than(const monster_pane_info& m1, #if 0 // for now, sort brands together. // By descending brands, so no brands sorts to the end if (m1.m_brands > m2.m_brands) - return true; + return (true); else if (m1.m_brands < m2.m_brands) - return false; + return (false); #endif return (false); diff --git a/crawl-ref/source/overmap.cc b/crawl-ref/source/overmap.cc index deda426c5e..caa364599a 100644 --- a/crawl-ref/source/overmap.cc +++ b/crawl-ref/source/overmap.cc @@ -576,7 +576,7 @@ void seen_other_thing( dungeon_feature_type which_thing, const coord_def& pos ) void set_level_annotation(std::string str, level_id li) { - if (str == "") + if (str.empty()) { clear_level_annotation(li); return; diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc index 33a97be0f4..227d7c11b2 100644 --- a/crawl-ref/source/player.cc +++ b/crawl-ref/source/player.cc @@ -630,12 +630,12 @@ bool you_can_wear(int eq, bool special_armour) bool player_has_feet() { if (you.species == SP_NAGA || player_genus(GENPC_DRACONIAN)) - return false; + return (false); if (player_mutation_level(MUT_HOOVES) || player_mutation_level(MUT_TALONS)) - return false; + return (false); - return true; + return (true); } bool you_tran_can_wear(int eq, bool check_mutation) @@ -1158,9 +1158,9 @@ bool player_knows_spell(int spell) { for (int i = 0; i < 25; i++) if (you.spells[i] == spell) - return true; + return (true); - return false; + return (false); } int player_res_magic(void) @@ -2612,11 +2612,11 @@ bool player_monster_visible( const monsters *mon ) bool player_beheld_by( const monsters *mon ) { if (!you.duration[DUR_BEHELD]) - return false; + return (false); // Can this monster even behold you? if (mon->type != MONS_MERMAID) - return false; + return (false); #ifdef DEBUG_DIAGNOSTICS mprf(MSGCH_DIAGNOSTICS, "beheld_by.size: %d, DUR_BEHELD: %d, current mon: %d", @@ -2627,17 +2627,17 @@ bool player_beheld_by( const monsters *mon ) if (you.beheld_by.empty()) // shouldn't happen { you.duration[DUR_BEHELD] = 0; - return false; + return (false); } for (unsigned int i = 0; i < you.beheld_by.size(); i++) { unsigned int which_mon = you.beheld_by[i]; if (monster_index(mon) == which_mon) - return true; + return (true); } - return false; + return (false); } // Removes a monster from the list of beholders if force == true @@ -2833,34 +2833,32 @@ bool you_resist_magic(int power) #endif if (mrch2 < mrchance) - return true; // ie saved successfully + return (true); // ie saved successfully - return false; -/* if (random2(power) / 3 + random2(power) / 3 + random2(power) / 3 >= player_res_magic()) return 0; - return 1; */ + return (false); } -// force is true for forget_map command on level map +// force is true for forget_map command on level map. void forget_map(unsigned char chance_forgotten, bool force) { - if ( force && !yesno("Really forget level map?", true, 'n') ) - return; + if (force && !yesno("Really forget level map?", true, 'n')) + return; for (unsigned char xcount = 0; xcount < GXM; xcount++) for (unsigned char ycount = 0; ycount < GYM; ycount++) { - if (!see_grid(xcount, ycount) && - (force || random2(100) < chance_forgotten)) - { - env.map[xcount][ycount].clear(); - } + if (!see_grid(xcount, ycount) + && (force || random2(100) < chance_forgotten)) + { + env.map[xcount][ycount].clear(); + } } #ifdef USE_TILE GmapInit(false); tile_clear_buf(); #endif -} // end forget_map() +} void gain_exp( unsigned int exp_gained, unsigned int* actual_gain, unsigned int* actual_avail_gain) @@ -4666,13 +4664,11 @@ void dec_mp(int mp_loss) take_note(Note(NOTE_MP_CHANGE, you.magic_points, you.max_magic_points)); you.redraw_magic_points = 1; - - return; -} // end dec_mp() +} bool enough_hp(int minimum, bool suppress_msg) { - // We want to at least keep 1 HP -- bwr + // We want to at least keep 1 HP. -- bwr if (you.hp < minimum + 1) { if (!suppress_msg) @@ -4680,11 +4676,11 @@ bool enough_hp(int minimum, bool suppress_msg) crawl_state.cancel_cmd_again(); crawl_state.cancel_cmd_repeat(); - return false; + return (false); } - return true; -} // end enough_hp() + return (true); +} bool enough_mp(int minimum, bool suppress_msg) { @@ -4695,11 +4691,11 @@ bool enough_mp(int minimum, bool suppress_msg) crawl_state.cancel_cmd_again(); crawl_state.cancel_cmd_repeat(); - return false; + return (false); } - return true; -} // end enough_mp() + return (true); +} // Note that "max_too" refers to the base potential, the actual // resulting max value is subject to penalties, bonuses, and scalings. @@ -4723,12 +4719,11 @@ void inc_mp(int mp_gain, bool max_too) take_note(Note(NOTE_MP_CHANGE, you.magic_points, you.max_magic_points)); you.redraw_magic_points = 1; - - return; -} // end inc_mp() +} // Note that "max_too" refers to the base potential, the actual // resulting max value is subject to penalties, bonuses, and scalings. +// To avoid message spam, don't take notes when HP increases. void inc_hp(int hp_gain, bool max_too) { if (hp_gain < 1) @@ -4747,11 +4742,8 @@ void inc_hp(int hp_gain, bool max_too) if (wasnt_max && you.hp == you.hp_max) interrupt_activity(AI_FULL_HP); - // to avoid message spam, no information when HP increases - // take_note(Note(NOTE_HP_CHANGE, you.hp, you.hp_max)); - you.redraw_hit_points = 1; -} // end inc_hp() +} void rot_hp( int hp_loss ) { @@ -4984,8 +4976,8 @@ void contaminate_player(int change, bool controlled, bool status_only) bool poison_player( int amount, bool force ) { - if ((!force && player_res_poison()) || amount <= 0) - return false; + if (!force && player_res_poison() || amount <= 0) + return (false); const int old_value = you.duration[DUR_POISONING]; you.duration[DUR_POISONING] += amount; @@ -4999,7 +4991,7 @@ bool poison_player( int amount, bool force ) (old_value > 0) ? "more " : "" ); learned_something_new(TUT_YOU_POISON); } - return true; + return (true); } void reduce_poison_player( int amount ) @@ -5015,20 +5007,18 @@ void reduce_poison_player( int amount ) mpr( "You feel better.", MSGCH_RECOVERY ); } else - { mpr( "You feel a little better.", MSGCH_RECOVERY ); - } } bool confuse_player( int amount, bool resistable ) { if (amount <= 0) - return false; + return (false); if (resistable && wearing_amulet(AMU_CLARITY)) { mpr( "You feel momentarily confused." ); - return false; + return (false); } const int old_value = you.duration[DUR_CONF]; @@ -5046,7 +5036,7 @@ bool confuse_player( int amount, bool resistable ) xom_is_stimulated(you.duration[DUR_CONF] - old_value); } - return true; + return (true); } void reduce_confuse_player( int amount ) @@ -5066,12 +5056,12 @@ void reduce_confuse_player( int amount ) bool slow_player( int amount ) { if (amount <= 0) - return false; + return (false); if (wearing_amulet( AMU_RESIST_SLOW )) { mpr("You feel momentarily lethargic."); - return false; + return (false); } else if (you.duration[DUR_SLOW] >= 100) mpr( "You already are as slow as you could be." ); @@ -5088,7 +5078,7 @@ bool slow_player( int amount ) you.duration[DUR_SLOW] = 100; learned_something_new(TUT_YOU_ENCHANTED); } - return true; + return (true); } void dec_slow_player( void ) @@ -5195,13 +5185,13 @@ void dec_disease_player( void ) bool rot_player( int amount ) { if (amount <= 0) - return false; + return (false); if (you.is_undead && (you.is_undead != US_SEMI_UNDEAD || you.hunger_state < HS_SATIATED)) { mpr( "You feel terrible." ); - return false; + return (false); } if (you.rotting < 40) @@ -5215,20 +5205,22 @@ bool rot_player( int amount ) learned_something_new(TUT_YOU_ROTTING); } - return true; + return (true); } int count_worn_ego( int which_ego ) { int result = 0; - for ( int slot = EQ_CLOAK; slot <= EQ_BODY_ARMOUR; ++slot ) + for (int slot = EQ_CLOAK; slot <= EQ_BODY_ARMOUR; ++slot) + { if (you.equip[slot] != -1 && get_armour_ego_type(you.inv[you.equip[slot]]) == which_ego) { result++; } + } - return result; + return (result); } static int _strength_modifier() @@ -5266,7 +5258,8 @@ static int _strength_modifier() case TRAN_BAT: result -= 5; break; default: break; } - return result; + + return (result); } static int _int_modifier() @@ -5289,7 +5282,7 @@ static int _int_modifier() result += player_mutation_level(MUT_CLEVER) - player_mutation_level(MUT_DOPEY); - return result; + return (result); } static int _dex_modifier() @@ -5335,12 +5328,13 @@ static int _dex_modifier() case TRAN_BAT: result += 5; break; default: break; } - return result; + + return (result); } int stat_modifier( stat_type stat ) { - switch ( stat ) + switch (stat) { case STAT_STRENGTH: return _strength_modifier(); case STAT_INTELLIGENCE: return _int_modifier(); @@ -6561,13 +6555,13 @@ bool player::haloed() const bool player::can_mutate() const { - return true; + return (true); } bool player::can_safely_mutate() const { if (!can_mutate()) - return false; + return (false); return (!you.is_undead || you.is_undead == US_SEMI_UNDEAD @@ -6577,14 +6571,14 @@ bool player::can_safely_mutate() const bool player::mutate() { if (!can_mutate()) - return false; + return (false); if (one_chance_in(5)) { if (::mutate(RANDOM_MUTATION)) { learned_something_new(TUT_YOU_MUTATED); - return true; + return (true); } } diff --git a/crawl-ref/source/quiver.cc b/crawl-ref/source/quiver.cc index a125f15d6f..8aa598d480 100644 --- a/crawl-ref/source/quiver.cc +++ b/crawl-ref/source/quiver.cc @@ -491,7 +491,7 @@ static bool _item_matches(const item_def &item, fire_type types, if (types & FIRE_INSCRIBED) if (item.inscription.find("+f", 0) != std::string::npos) - return true; + return (true); if (item.base_type == OBJ_MISSILES) { diff --git a/crawl-ref/source/randart.cc b/crawl-ref/source/randart.cc index ecbca074da..15396bfd7c 100644 --- a/crawl-ref/source/randart.cc +++ b/crawl-ref/source/randart.cc @@ -1286,7 +1286,7 @@ static bool _pick_db_name( const item_def &item ) case OBJ_JEWELLERY: return one_chance_in(5); default: - return false; + return (false); } } @@ -1634,7 +1634,7 @@ static bool _randart_is_redundant( const item_def &item, randart_properties_t &proprt ) { if (item.base_type != OBJ_JEWELLERY) - return false; + return (false); randart_prop_type provides = RAP_NUM_PROPERTIES; randart_prop_type provides2 = RAP_NUM_PROPERTIES; @@ -1723,25 +1723,25 @@ static bool _randart_is_redundant( const item_def &item, } if (provides == RAP_NUM_PROPERTIES) - return false; + return (false); if (proprt[provides] != 0) - return true; + return (true); if (provides2 == RAP_NUM_PROPERTIES) - return false; + return (false); if (proprt[provides2] != 0) - return true; + return (true); - return false; + return (false); } static bool _randart_is_conflicting( const item_def &item, randart_properties_t &proprt ) { if (item.base_type != OBJ_JEWELLERY) - return false; + return (false); randart_prop_type conflicts = RAP_NUM_PROPERTIES; @@ -1773,21 +1773,21 @@ static bool _randart_is_conflicting( const item_def &item, } if (conflicts == RAP_NUM_PROPERTIES) - return false; + return (false); if (proprt[conflicts] != 0) - return true; + return (true); - return false; + return (false); } bool randart_is_bad( const item_def &item, randart_properties_t &proprt ) { if (randart_wpn_num_props( proprt ) == 0) - return true; + return (true); - return ( _randart_is_redundant( item, proprt ) - || _randart_is_conflicting( item, proprt ) ); + return (_randart_is_redundant( item, proprt ) + || _randart_is_conflicting( item, proprt )); } bool randart_is_bad( const item_def &item ) diff --git a/crawl-ref/source/religion.cc b/crawl-ref/source/religion.cc index 7d74990ea3..2f06206918 100644 --- a/crawl-ref/source/religion.cc +++ b/crawl-ref/source/religion.cc @@ -1117,7 +1117,7 @@ static bool _blessing_wpn(monsters* mon) const int alt_weapon = mon->inv[MSLOT_ALT_WEAPON]; if (weapon == NON_ITEM && alt_weapon == NON_ITEM) - return false; + return (false); int slot; @@ -1133,12 +1133,11 @@ static bool _blessing_wpn(monsters* mon) if (!enchant_weapon((coinflip()) ? ENCHANT_TO_HIT : ENCHANT_TO_DAM, true, wpn)) { - return false; + return (false); } item_set_appearance(wpn); - - return true; + return (true); } static bool _blessing_AC(monsters* mon) @@ -1148,7 +1147,7 @@ static bool _blessing_AC(monsters* mon) const int shield = mon->inv[MSLOT_SHIELD]; if (armour == NON_ITEM && shield == NON_ITEM) - return false; + return (false); int slot; @@ -1164,11 +1163,10 @@ static bool _blessing_AC(monsters* mon) // And enchant or uncurse it. if (!enchant_armour(ac_change, true, arm)) - return false; + return (false); item_set_appearance(arm); - - return true; + return (true); } static bool _blessing_balms(monsters *mon) @@ -1207,9 +1205,9 @@ static bool _blessing_healing(monsters* mon, bool extra) // A high-HP monster might get a unique name. if (random2(100) <= mon->max_hit_points) give_monster_proper_name(mon); - return true; + return (true); } - return false; + return (false); } static bool _tso_blessing_holy_wpn(monsters* mon) @@ -1219,7 +1217,7 @@ static bool _tso_blessing_holy_wpn(monsters* mon) const int alt_weapon = mon->inv[MSLOT_ALT_WEAPON]; if (weapon == NON_ITEM && alt_weapon == NON_ITEM) - return false; + return (false); int slot; @@ -1239,7 +1237,7 @@ static bool _tso_blessing_holy_wpn(monsters* mon) && wpn_brand != SPWPN_PAIN && wpn_brand != SPWPN_VAMPIRICISM && wpn_brand != SPWPN_VENOM)) { - return false; + return (false); } // Convert a demonic weapon into a non-demonic weapon. @@ -1251,21 +1249,21 @@ static bool _tso_blessing_holy_wpn(monsters* mon) set_item_ego_type(wpn, OBJ_WEAPONS, SPWPN_HOLY_WRATH); wpn.colour = YELLOW; - return true; + return (true); } static bool _tso_blessing_holy_arm(monsters* mon) { // If a monster has full negative energy resistance, get out. if (mons_res_negative_energy(mon) == 3) - return false; + return (false); // Pick either a monster's armour or its shield. const int armour = mon->inv[MSLOT_ARMOUR]; const int shield = mon->inv[MSLOT_SHIELD]; if (armour == NON_ITEM && shield == NON_ITEM) - return false; + return (false); int slot; @@ -1281,14 +1279,14 @@ static bool _tso_blessing_holy_arm(monsters* mon) // Override certain brands. if (is_artefact(arm) || arm_brand != SPARM_NORMAL) - return false; + return (false); // And make it resistant to negative energy. set_equip_desc(arm, ISFLAG_GLOWING); set_item_ego_type(arm, OBJ_ARMOUR, SPARM_POSITIVE_ENERGY); arm.colour = WHITE; - return true; + return (true); } static int _tso_blessing_extend_stay(monsters* mon) @@ -1322,7 +1320,7 @@ static int _tso_blessing_extend_stay(monsters* mon) static bool _tso_blessing_friendliness(monsters* mon) { if (!mon->has_ench(ENCH_CHARM)) - return false; + return (false); mon->attitude = ATT_FRIENDLY; @@ -1338,7 +1336,7 @@ static bool _tso_blessing_friendliness(monsters* mon) // hostile. mon->del_ench(ENCH_CHARM, true, false); - return true; + return (true); } // If you don't currently have any followers, send a small band to help @@ -1390,7 +1388,7 @@ static bool _beogh_blessing_reinforcement() } } - return success; + return (success); } static bool _beogh_blessing_priesthood(monsters* mon) @@ -1409,10 +1407,10 @@ static bool _beogh_blessing_priesthood(monsters* mon) mon->upgrade_type(priest_type, true, true); give_monster_proper_name(mon); - return true; + return (true); } - return false; + return (false); } // Bless the follower indicated in follower, if any. If there isn't @@ -1431,11 +1429,12 @@ bool bless_follower(monsters *follower, // Otherwise, pick a random follower. if (!follower || (!force && !suitable(follower))) { + // Only Beogh blesses random followers. if (god != GOD_BEOGH) - return false; + return (false); if (chance > 2) - return false; + return (false); // Choose a random follower in LOS, preferably a named one (10% chance). follower = choose_random_nearby_monster(0, suitable, true, true); @@ -1443,7 +1442,7 @@ bool bless_follower(monsters *follower, if (!follower) { if (coinflip()) - return false; + return (false); // Try again, without the LOS restriction (5% chance). follower = choose_random_nearby_monster(0, suitable, false, true); @@ -1451,7 +1450,7 @@ bool bless_follower(monsters *follower, if (!follower) { if (coinflip()) - return false; + return (false); // Try *again*, on the entire level (2.5% chance). follower = choose_random_monster_on_level(0, suitable, @@ -1471,7 +1470,7 @@ bool bless_follower(monsters *follower, } if (!reinforced) - return false; + return (false); result = "reinforcement"; goto blessing_done; @@ -1654,7 +1653,7 @@ bool bless_follower(monsters *follower, if (force) mpr("Couldn't heal monster."); - return false; + return (false); } default: @@ -1707,7 +1706,7 @@ blessing_done: } #endif - return true; + return (true); } static void _do_god_gift(bool prayed_for) @@ -1930,7 +1929,7 @@ static bool _confirm_pray_sacrifice() && is_stash(you.x_pos, you.y_pos)) { mpr("You can't sacrifice explicitly marked stashes."); - return false; + return (false); } for ( int i = igrd[you.x_pos][you.y_pos]; i != NON_ITEM; @@ -1944,10 +1943,10 @@ static bool _confirm_pray_sacrifice() prompt += item.name(DESC_NOCAP_A); prompt += " in it?"; if ( !yesno(prompt.c_str(), false, 'n') ) - return false; + return (false); } } - return true; + return (true); } std::string god_prayer_reaction() @@ -1981,13 +1980,13 @@ static bool _god_accepts_prayer(god_type type) case GOD_SIF_MUNA: case GOD_KIKUBAAQUDGHA: case GOD_NO_GOD: - return false; + return (false); default: break; } - return true; + return (true); } void pray() @@ -2047,7 +2046,7 @@ void pray() } // Nemelexites can abort out now instead of offering something - // they don't want to lose + // they don't want to lose. if ( you.religion == GOD_NEMELEX_XOBEH && altar_god == GOD_NO_GOD && !_confirm_pray_sacrifice() ) { @@ -2060,7 +2059,7 @@ void pray() god_name(you.religion).c_str()); // ...otherwise, they offer what they're standing on - if ( you.religion == GOD_NEMELEX_XOBEH && altar_god == GOD_NO_GOD ) + if (you.religion == GOD_NEMELEX_XOBEH && altar_god == GOD_NO_GOD) offer_items(); you.duration[DUR_PRAYER] = 9 + (random2(you.piety) / 20) @@ -3028,41 +3027,41 @@ static bool _destroyed_valuable_weapon(int value, int type) { // Artefacts (incl. most randarts). if (random2(value) >= random2(250)) - return true; + return (true); // Medium valuable items are more likely to net piety at low piety. // This includes missiles in sufficiently large quantities. if (random2(value) >= random2(100) && one_chance_in(1 + you.piety/50)) { - return true; + return (true); } // If not for the above, missiles shouldn't yield piety. if (type == OBJ_MISSILES) - return false; + return (false); // Weapons, on the other hand, are always acceptable to boost low piety. if (you.piety < 30 || player_under_penance()) - return true; + return (true); - return false; + return (false); } bool ely_destroy_weapons() { if (you.religion != GOD_ELYVILON) - return false; + return (false); god_acting gdact; bool success = false; - for ( stack_iterator si(you.pos()); si; ++si ) + for (stack_iterator si(you.pos()); si; ++si) { item_def& item(*si); - if ( (item.base_type != OBJ_WEAPONS - && item.base_type != OBJ_MISSILES) - || item_is_stationary(item)) // Held in a net? + if (item.base_type != OBJ_WEAPONS + && item.base_type != OBJ_MISSILES + || item_is_stationary(item)) // Held in a net? { continue; } @@ -3103,7 +3102,7 @@ bool ely_destroy_weapons() if (!success) mpr("There are no weapons here to destroy!"); - return success; + return (success); } // Returns false if the invocation fails (no books in sight etc.). @@ -3339,19 +3338,19 @@ static bool _tso_retribution() } case 5: case 6: // either noisiness or silence (2/7) - if (coinflip()) - { - simple_god_message(" booms out: \"Take the path of righteousness! REPENT!\"", god); - noisy(25, you.x_pos, you.y_pos); // same as scroll of noise - } - else - { - god_speaks(god, "You feel the Shining One's silent rage upon you!"); - cast_silence( 25 ); - } - break; - } - return false; + if (coinflip()) + { + simple_god_message(" booms out: \"Take the path of righteousness! REPENT!\"", god); + noisy(25, you.x_pos, you.y_pos); // same as scroll of noise + } + else + { + god_speaks(god, "You feel the Shining One's silent rage upon you!"); + cast_silence( 25 ); + } + break; + } + return (false); } static bool _zin_retribution() @@ -3450,7 +3449,7 @@ static bool _zin_retribution() noisy(25, you.x_pos, you.y_pos); // same as scroll of noise break; } - return false; + return (false); } static void _ely_dull_inventory_weapons() @@ -3547,12 +3546,12 @@ static bool _elyvilon_retribution() break; case 3: - case 4: // dull weapons in your inventory + case 4: // Dull weapons in your inventory. _ely_dull_inventory_weapons(); break; } - return true; + return (true); } static bool _makhleb_retribution() @@ -3581,10 +3580,10 @@ static bool _makhleb_retribution() for (int i = 0; i < how_many; ++i) { if (create_monster( - mgen_data::hostile_at( - static_cast( - MONS_NEQOXEC + random2(5)), - you.pos(), 0, 0, true, GOD_MAKHLEB)) != -1) + mgen_data::hostile_at( + static_cast( + MONS_NEQOXEC + random2(5)), + you.pos(), 0, 0, true, GOD_MAKHLEB)) != -1) { count++; } @@ -3595,7 +3594,7 @@ static bool _makhleb_retribution() "'s minions fail to arrive.", god); } - return true; + return (true); } static bool _kikubaaqudgha_retribution() @@ -3632,7 +3631,7 @@ static bool _kikubaaqudgha_retribution() random2avg(88, 3), 100, "the malice of Kikubaaqudgha"); } - return true; + return (true); } static bool _yredelemnul_retribution() @@ -3668,7 +3667,7 @@ static bool _yredelemnul_retribution() random2avg(88, 3), 100, "the anger of Yredelemnul" ); } - return true; + return (true); } static bool _trog_retribution() @@ -3762,7 +3761,7 @@ static bool _trog_retribution() random2avg(98, 3), 100, "the fiery rage of Trog" ); } - return true; + return (true); } static bool _beogh_retribution() @@ -3884,7 +3883,7 @@ static bool _beogh_retribution() } } - return true; + return (true); } static bool _okawaru_retribution() @@ -3912,7 +3911,7 @@ static bool _okawaru_retribution() "'s forces are busy with other wars.", god); - return true; + return (true); } static bool _sif_muna_retribution() @@ -3960,7 +3959,7 @@ static bool _sif_muna_retribution() break; } - return true; + return (true); } static bool _lugonu_retribution() @@ -4024,7 +4023,7 @@ static bool _lugonu_retribution() god); } - return false; + return (false); } static bool _vehumet_retribution() @@ -4036,7 +4035,7 @@ static bool _vehumet_retribution() miscast_effect( coinflip() ? SPTYP_CONJURATION : SPTYP_SUMMONING, 8 + you.experience_level, random2avg(98, 3), 100, "the wrath of Vehumet" ); - return true; + return (true); } static bool _nemelex_retribution() @@ -4047,7 +4046,7 @@ static bool _nemelex_retribution() // like Xom, this might actually help the player -- bwr simple_god_message(" makes you draw from the Deck of Punishment.", god); draw_from_deck_of_punishment(); - return true; + return (true); } void divine_retribution( god_type god ) @@ -4530,11 +4529,10 @@ static bool _beogh_followers_abandon_you() } chan << std::endl; - - return true; + return (true); } - return false; + return (false); } // currently only used when orcish idols have been destroyed diff --git a/crawl-ref/source/spells1.cc b/crawl-ref/source/spells1.cc index 3b0abac19b..aab5108603 100644 --- a/crawl-ref/source/spells1.cc +++ b/crawl-ref/source/spells1.cc @@ -489,13 +489,13 @@ bool conjure_flame(int pow) if (!spelld.isValid) { canned_msg(MSG_OK); - return false; + return (false); } if (trans_wall_blocking(spelld.tx, spelld.ty)) { mpr("A translucent wall is in the way."); - return false; + return (false); } else if (!see_grid(spelld.tx, spelld.ty)) { @@ -518,14 +518,14 @@ bool conjure_flame(int pow) mpr( "There's already something there!" ); continue; } - else if ( cloud != EMPTY_CLOUD ) + else if (cloud != EMPTY_CLOUD) { - // reinforce the cloud - but not too much + // Reinforce the cloud - but not too much. mpr( "The fire roars with new energy!" ); const int extra_dur = 2 + std::min(random2(pow) / 2, 20); env.cloud[cloud].decay += extra_dur * 5; env.cloud[cloud].whose = KC_YOU; - return true; + return (true); } break; @@ -537,7 +537,7 @@ bool conjure_flame(int pow) durat = 23; place_cloud( CLOUD_FIRE, spelld.tx, spelld.ty, durat, KC_YOU ); - return true; + return (true); } bool stinking_cloud( int pow, bolt &beem ) @@ -609,13 +609,15 @@ static bool _can_pacify_monster(const monsters *mon, const int healed) ASSERT(you.religion == GOD_ELYVILON); if (healed < 1) - return false; + return (false); if (!_mons_hostile(mon)) - return false; + return (false); + // I was thinking of jellies when I wrote this, but maybe we shouldn't + // exclude zombies and such... (jpeg) if (mons_intel(mon->type) <= I_PLANT) // no self-awareness - return false; + return (false); const mon_holy_type holiness = mons_holiness(mon); @@ -624,14 +626,14 @@ static bool _can_pacify_monster(const monsters *mon, const int healed) && holiness != MH_UNDEAD && holiness != MH_DEMONIC) { - return false; + return (false); } if (mons_is_stationary(mon)) // not able to leave the level - return false; + return (false); if (mons_is_sleeping(mon)) // not aware of what is happening - return false; + return (false); const int factor = (mons_intel(mon->type) <= I_ANIMAL) ? 3 : // animals (is_player_same_species(mon->type)) ? 2 // same species @@ -657,9 +659,9 @@ static bool _can_pacify_monster(const monsters *mon, const int healed) #endif if (mon->max_hit_points < factor * random_factor) - return true; + return (true); - return false; + return (false); } static int _healing_spell( int healed, int target_x = -1, int target_y = -1) diff --git a/crawl-ref/source/spells2.cc b/crawl-ref/source/spells2.cc index e37f0c4f10..11f9aeb63a 100644 --- a/crawl-ref/source/spells2.cc +++ b/crawl-ref/source/spells2.cc @@ -311,27 +311,27 @@ int corpse_rot(int power) bool brand_weapon(brand_type which_brand, int power) { int temp_rand; // probability determination {dlb} - int duration_affected = 0; //jmf: NB: now HOW LONG, not WHICH BRAND. + int duration_affected = 0; const int wpn = you.equip[EQ_WEAPON]; if (you.duration[DUR_WEAPON_BRAND]) - return false; + return (false); if (wpn == -1) - return false; + return (false); if (you.inv[wpn].base_type != OBJ_WEAPONS || is_range_weapon(you.inv[wpn])) { - return false; + return (false); } if (is_fixed_artefact( you.inv[wpn] ) || is_random_artefact( you.inv[wpn] ) || get_weapon_brand( you.inv[wpn] ) != SPWPN_NORMAL ) { - return false; + return (false); } std::string msg = you.inv[wpn].name(DESC_CAP_YOUR); @@ -352,7 +352,7 @@ bool brand_weapon(brand_type which_brand, int power) case SPWPN_VENOM: if (wpn_type == DVORP_CRUSHING) - return false; + return (false); msg += " starts dripping with poison."; duration_affected = 15; @@ -365,13 +365,13 @@ bool brand_weapon(brand_type which_brand, int power) case SPWPN_VORPAL: if (wpn_type != DVORP_SLICING) - return false; + return (false); msg += " glows silver and looks extremely sharp."; duration_affected = 10; break; - case SPWPN_DISTORTION: //jmf: added for Warp Weapon + case SPWPN_DISTORTION: //jmf: Added for Warp Weapon. msg += " seems to "; temp_rand = random2(6); @@ -398,16 +398,16 @@ bool brand_weapon(brand_type which_brand, int power) break; case SPWPN_PAIN: - // well, in theory, we could be silenced, but then how are + // Well, in theory, we could be silenced, but then how are // we casting the brand spell? msg += " shrieks in agony."; noisy(15, you.x_pos, you.y_pos); duration_affected = 8; break; - case SPWPN_DUMMY_CRUSHING: //jmf: added for Maxwell's Silver Hammer + case SPWPN_DUMMY_CRUSHING: //jmf: Added for Maxwell's Silver Hammer. if (wpn_type != DVORP_CRUSHING) - return false; + return (false); which_brand = SPWPN_VORPAL; msg += " glows silver and feels heavier."; @@ -429,7 +429,7 @@ bool brand_weapon(brand_type which_brand, int power) if (you.duration[DUR_WEAPON_BRAND] > 50) you.duration[DUR_WEAPON_BRAND] = 50; - return true; + return (true); } // end brand_weapon() // Restore the stat in which_stat by the amount in stat_gain, displaying @@ -441,8 +441,8 @@ bool restore_stat(unsigned char which_stat, unsigned char stat_gain, { bool stat_restored = false; - // a bit hackish, but cut me some slack, man! -- - // besides, a little recursion never hurt anyone {dlb}: + // A bit hackish, but cut me some slack, man! -- + // Besides, a little recursion never hurt anyone {dlb}: if (which_stat == STAT_ALL) { for (unsigned char loopy = STAT_STRENGTH; loopy < NUM_STATS; ++loopy) @@ -450,10 +450,10 @@ bool restore_stat(unsigned char which_stat, unsigned char stat_gain, if (restore_stat(loopy, stat_gain, suppress_msg)) stat_restored = true; } - return stat_restored; // early return {dlb} + return (stat_restored); // early return {dlb} } - // the real function begins here {dlb}: + // The real function begins here. {dlb} char *ptr_stat = NULL; char *ptr_stat_max = NULL; bool *ptr_redraw = NULL; @@ -493,7 +493,7 @@ bool restore_stat(unsigned char which_stat, unsigned char stat_gain, if (*ptr_stat < *ptr_stat_max) { msg += " returning."; - if ( !suppress_msg ) + if (!suppress_msg) mpr(msg.c_str(), (recovery) ? MSGCH_RECOVERY : MSGCH_PLAIN); if (stat_gain == 0 || *ptr_stat + stat_gain > *ptr_stat_max) @@ -510,8 +510,8 @@ bool restore_stat(unsigned char which_stat, unsigned char stat_gain, } } - return stat_restored; -} // end restore_stat() + return (stat_restored); +} void turn_undead(int pow) { @@ -526,8 +526,8 @@ void turn_undead(int pow) if (monster->type == -1 || !mons_near(monster)) continue; - // used to inflict random2(5) + (random2(pow) / 20) damage, - // in addition {dlb} + // Used to inflict random2(5) + (random2(pow) / 20) damage, + // in addition. {dlb} if (mons_holiness(monster) == MH_UNDEAD) { if (check_mons_resist_magic( monster, pow )) @@ -542,17 +542,17 @@ void turn_undead(int pow) simple_monster_message( monster, " is repelled!" ); - //mv: must be here to work + //mv: Must be here to work. behaviour_event( monster, ME_SCARE, MHITYOU ); - // reduce power based on monster turned + // Reduce power based on monster turned. pow -= monster->hit_dice * 3; if (pow <= 0) break; - } // end "if mons_holiness" - } // end "for tu" -} // end turn_undead() + } + } +} typedef std::pair counted_monster; typedef std::vector counted_monster_list; diff --git a/crawl-ref/source/spells3.cc b/crawl-ref/source/spells3.cc index 95ee7797f7..d3b5ae799a 100644 --- a/crawl-ref/source/spells3.cc +++ b/crawl-ref/source/spells3.cc @@ -1557,7 +1557,7 @@ static int _inside_circle(int posx, int posy, int radius) if (dist > radius*radius) return -1; - return dist; + return (dist); } bool remove_sanctuary(bool did_attack) @@ -1566,7 +1566,7 @@ bool remove_sanctuary(bool did_attack) env.sanctuary_time = 0; if (!inside_level_bounds(env.sanctuary_pos)) - return false; + return (false); const int radius = 5; bool seen_change = false; @@ -1601,15 +1601,15 @@ bool remove_sanctuary(bool did_attack) if (is_resting()) stop_running(); - return true; + return (true); } -// For the last (radius) counter turns the sanctuary will slowly shrink +// For the last (radius) counter turns the sanctuary will slowly shrink. void decrease_sanctuary_radius() { int radius = 5; - // for the last (radius-1) turns 33% chance of not decreasing + // For the last (radius-1) turns 33% chance of not decreasing. if (env.sanctuary_time < radius && one_chance_in(3)) return; @@ -1625,23 +1625,23 @@ void decrease_sanctuary_radius() radius = size+1; for (int x = -radius; x <= radius; x++) - for (int y = -radius; y <= radius; y++) - { - int posx = env.sanctuary_pos.x + x; - int posy = env.sanctuary_pos.y + y; + for (int y = -radius; y <= radius; y++) + { + int posx = env.sanctuary_pos.x + x; + int posy = env.sanctuary_pos.y + y; - if (!inside_level_bounds(posx,posy)) - continue; + if (!inside_level_bounds(posx,posy)) + continue; - int dist = distance(posx, posy, env.sanctuary_pos.x, - env.sanctuary_pos.y); + int dist = distance(posx, posy, env.sanctuary_pos.x, + env.sanctuary_pos.y); - // if necessary overwrite sanctuary property - if (dist > size*size) - env.map[posx][posy].property = FPROP_NONE; - } + // If necessary overwrite sanctuary property. + if (dist > size*size) + env.map[posx][posy].property = FPROP_NONE; + } - // special case for time-out of sanctuary + // Special case for time-out of sanctuary. if (!size) { env.map[env.sanctuary_pos.x][env.sanctuary_pos.y].property = FPROP_NONE; @@ -1650,10 +1650,15 @@ void decrease_sanctuary_radius() } } -// maybe disallow recasting while previous sanctuary in effect... bool cast_sanctuary(const int power) { - if (!silenced(you.x_pos, you.y_pos)) // how did you manage that? + // Casting is disallowed while previous sanctuary in effect. + // (Checked in abl-show.cc.) + if (env.sanctuary_time) + return (false); + + // Yes, shamelessly stolen from NetHack... + if (!silenced(you.x_pos, you.y_pos)) // How did you manage that? mpr("You hear a choir sing!", MSGCH_SOUND); else mpr("You are suddenly bathed in radiance!"); @@ -1670,7 +1675,7 @@ bool cast_sanctuary(const int power) env.sanctuary_time = 7 + you.skills[SK_INVOCATIONS]/2; // radius could also be influenced by Inv - // and would then have to be stored globally + // and would then have to be stored globally. const int radius = 5; const int pattern = random2(4); int count = 0; @@ -1742,7 +1747,7 @@ int halo_radius() bool inside_halo(int posx, int posy) { if (!halo_radius()) - return false; + return (false); return (_inside_circle(posx, posy, halo_radius()) != -1); } @@ -1775,11 +1780,9 @@ void cast_poison_ammo(void) you.wield_change = true; } else - { canned_msg(MSG_NOTHING_HAPPENS); - } } -} // end cast_poison_ammo() +} bool project_noise(void) { @@ -1808,15 +1811,17 @@ bool project_noise(void) if (!silenced( you.x_pos, you.y_pos )) { if (success) + { mprf(MSGCH_SOUND, "You hear a %svoice call your name.", (!see_grid( pos.x, pos.y ) ? "distant " : "") ); + } else mprf(MSGCH_SOUND, "You hear a dull thud."); } } return (success); -} // end project_noise() +} // Type recalled: // 0 = anything diff --git a/crawl-ref/source/spl-book.cc b/crawl-ref/source/spl-book.cc index 0ad951587b..9192e4dd4e 100644 --- a/crawl-ref/source/spl-book.cc +++ b/crawl-ref/source/spl-book.cc @@ -739,11 +739,9 @@ int spellbook_contents( item_def &book, read_book_action_type action, out.cprintf(" "); - bool knowsSpell = false; - for (i = 0; i < 25 && !knowsSpell; i++) - { - knowsSpell = (you.spells[i] == stype); - } + bool knows_spell = false; + for (i = 0; i < 25 && !knows_spell; i++) + knows_spell = (you.spells[i] == stype); const int level_diff = spell_difficulty( stype ); const int levels_req = spell_levels_required( stype ); @@ -751,9 +749,9 @@ int spellbook_contents( item_def &book, read_book_action_type action, int colour = DARKGREY; if (action == RBOOK_USE_STAFF) { - if (book.base_type == OBJ_BOOKS? + if (book.base_type == OBJ_BOOKS ? you.experience_level >= level_diff - && you.magic_points >= level_diff + && you.magic_points >= level_diff : book.plus >= level_diff * ROD_CHARGE_MULT) { colour = LIGHTGREY; @@ -761,11 +759,11 @@ int spellbook_contents( item_def &book, read_book_action_type action, } else { - if (knowsSpell) + if (knows_spell) colour = LIGHTGREY; else if (you.experience_level >= level_diff - && spell_levels >= levels_req - && spell_skills) + && spell_levels >= levels_req + && spell_skills) { colour = LIGHTBLUE; } @@ -773,12 +771,7 @@ int spellbook_contents( item_def &book, read_book_action_type action, out.textcolor( colour ); - // Old: - // textcolor(knowsSpell ? DARKGREY : LIGHTGREY); - // was: ? LIGHTGREY : LIGHTBLUE - char strng[2]; - strng[0] = index_to_letter(spelcount); strng[1] = 0; @@ -1051,7 +1044,7 @@ int read_book( item_def &book, read_book_action_type action ) return (0); } - // remember that this function is called from staff spells as well: + // Remember that this function is called from staff spells as well. const int keyin = spellbook_contents( book, action ); if (book.base_type == OBJ_BOOKS) @@ -1059,21 +1052,21 @@ int read_book( item_def &book, read_book_action_type action ) redraw_screen(); - /* Put special book effects in another function which can be called from - memorise as well */ + // Put special book effects in another function which can be called + // from memorise as well. set_ident_flags( book, ISFLAG_KNOW_TYPE ); return (keyin); -} // end read_book() +} -// recoded to answer whether an UNDEAD_STATE is +// Recoded to answer whether an UNDEAD_STATE is // barred from a particular spell passed to the -// function - note that the function can be expanded +// function. Note that the function can be expanded // to prevent memorisation of certain spells by // the living by setting up an US_ALIVE case returning // a value of false for a set of spells ... might be -// an idea worth further consideration - 12mar2000 {dlb} +// an idea worth further consideration. - 12mar2000 {dlb} bool undead_cannot_memorise(spell_type spell, char being) { switch (being) @@ -1096,9 +1089,9 @@ bool undead_cannot_memorise(spell_type spell, char being) case SPELL_STATUE_FORM: case SPELL_SYMBOL_OF_TORMENT: case SPELL_TAME_BEASTS: - return true; + return (true); default: - return false; + return (false); } break; @@ -1108,11 +1101,11 @@ bool undead_cannot_memorise(spell_type spell, char being) case SPELL_BORGNJORS_REVIVIFICATION: case SPELL_DEATHS_DOOR: case SPELL_NECROMUTATION: - return true; + return (true); default: - // also, the above US_HUNGRY_DEAD spells are not castable - // when satiated or worse - return false; + // In addition, the above US_HUNGRY_DEAD spells are not castable + // when satiated or worse. + return (false); } break; @@ -1138,51 +1131,50 @@ bool undead_cannot_memorise(spell_type spell, char being) case SPELL_SUMMON_HORRIBLE_THINGS: case SPELL_SYMBOL_OF_TORMENT: case SPELL_TAME_BEASTS: - return true; + return (true); default: - return false; + return (false); } break; } - return false; -} // end undead_cannot_memorise() + return (false); +} bool player_can_memorise(const item_def &book) { - if (book.base_type != OBJ_BOOKS || book.sub_type == BOOK_MANUAL) - return false; + if (book.base_type != OBJ_BOOKS || book.sub_type == BOOK_MANUAL + || book.sub_type == BOOK_DESTRUCTION) + { + return (false); + } if (!player_spell_levels()) - return false; + return (false); for (int j = 0; j < SPELLBOOK_SIZE; j++) { - const spell_type stype = which_spell_in_book(book.book_number(), j); - - if (stype == SPELL_NO_SPELL) - continue; - - // easiest spell already too difficult - if (spell_difficulty(stype) > you.experience_level - || player_spell_levels() < spell_levels_required(stype)) - { - return false; - } - - bool knowsSpell = false; - for (int i = 0; i < 25 && !knowsSpell; i++) - { - knowsSpell = (you.spells[i] == stype); - } - - // don't already know this spell - if (!knowsSpell) - { - return true; - } + const spell_type stype = which_spell_in_book(book.book_number(), j); + + if (stype == SPELL_NO_SPELL) + continue; + + // Easiest spell already too difficult? + if (spell_difficulty(stype) > you.experience_level + || player_spell_levels() < spell_levels_required(stype)) + { + return (false); + } + + bool knows_spell = false; + for (int i = 0; i < 25 && !knows_spell; i++) + knows_spell = (you.spells[i] == stype); + + // You don't already know this spell. + if (!knows_spell) + return (true); } - return false; + return (false); } bool learn_spell(int book) @@ -1195,10 +1187,8 @@ bool learn_spell(int book) int j = 0; for (i = SK_SPELLCASTING; i <= SK_POISON_MAGIC; i++) - { if (you.skills[i]) j++; - } if (j == 0) { @@ -1238,8 +1228,8 @@ bool learn_spell(int book) index = letter_to_index( spell ); - if (index >= SPELLBOOK_SIZE || - !is_valid_spell_in_book( you.inv[book].sub_type, index )) + if (index >= SPELLBOOK_SIZE + || !is_valid_spell_in_book( you.inv[book].sub_type, index )) { canned_msg( MSG_HUH ); return (false); diff --git a/crawl-ref/source/spl-cast.cc b/crawl-ref/source/spl-cast.cc index 3a477828bc..5d60865592 100644 --- a/crawl-ref/source/spl-cast.cc +++ b/crawl-ref/source/spl-cast.cc @@ -113,11 +113,11 @@ static bool _surge_identify_boosters(spell_type spell) } } - return true; + return (true); } } } - return false; + return (false); } static void _surge_power(spell_type spell) @@ -125,8 +125,6 @@ static void _surge_power(spell_type spell) int enhanced = 0; _surge_identify_boosters(spell); - - //jmf: simplified enhanced += spell_enhancement(get_spell_disciplines(spell)); if (enhanced) // one way or the other {dlb} @@ -853,10 +851,10 @@ static void _spellcasting_side_effects(spell_type spell, bool idonly = false) static bool _vampire_cannot_cast(spell_type spell) { if (you.species != SP_VAMPIRE) - return false; + return (false); if (you.hunger_state > HS_SATIATED) - return false; + return (false); // Satiated or less switch (spell) @@ -872,9 +870,9 @@ static bool _vampire_cannot_cast(spell_type spell) case SPELL_SPIDER_FORM: case SPELL_STATUE_FORM: case SPELL_TAME_BEASTS: - return true; + return (true); default: - return false; + return (false); } } diff --git a/crawl-ref/source/spl-util.cc b/crawl-ref/source/spl-util.cc index 0b4f541951..ac35b94fbe 100644 --- a/crawl-ref/source/spl-util.cc +++ b/crawl-ref/source/spl-util.cc @@ -887,7 +887,7 @@ int spell_type2skill(unsigned int spelltype) ************************************************** */ -//jmf: simplified; moved init code to top function, init_spell_descs() +//jmf: Simplified; moved init code to top function, init_spell_descs(). static spell_desc *_seekspell(spell_type spell) { const int index = spell_list[spell]; @@ -908,13 +908,13 @@ static bool _cloud_helper(int (*func)(int, int, int, int, cloud_type, if (!grid_is_solid(grd[x][y]) && env.cgrid[x][y] == EMPTY_CLOUD) { func(x, y, pow, spread_rate, ctype, whose); - return true; + return (true); } - return false; + return (false); } int spell_power_cap(spell_type spell) { - return _seekspell(spell)->power_cap; + return (_seekspell(spell)->power_cap); } diff --git a/crawl-ref/source/stash.cc b/crawl-ref/source/stash.cc index 5bdb3a7855..95a1f323d1 100644 --- a/crawl-ref/source/stash.cc +++ b/crawl-ref/source/stash.cc @@ -104,9 +104,9 @@ bool is_stash(int x, int y) if (ls) { Stash *s = ls->find_stash(x, y); - return s && s->enabled; + return (s && s->enabled); } - return false; + return (false); } void describe_stash(int x, int y) @@ -212,12 +212,14 @@ bool Stash::is_filtered(const item_def &item) for (int i = 0, count = filters.size(); i < count; ++i) { const item_def &filter = filters[i]; - if (item.base_type == filter.base_type && - (filter.sub_type == 255 || - item.sub_type == filter.sub_type)) - return true; + if (item.base_type == filter.base_type + && (filter.sub_type == 255 + || item.sub_type == filter.sub_type)) + { + return (true); + } } - return false; + return (false); } bool Stash::unverified() const @@ -230,6 +232,7 @@ bool Stash::pickup_eligible() const for (int i = 0, size = items.size(); i < size; ++i) if (item_needs_autopickup(items[i])) return (true); + return (false); } @@ -457,7 +460,7 @@ bool StashMenu::process_key(int key) { // Travel activates. lastch = 1; - return false; + return (false); } return Menu::process_key(key); } @@ -494,16 +497,15 @@ bool Stash::show_menu(const std::string &prefix, bool can_travel) const { sel = menu.show(); if (menu.getkey() == 1) - return true; + return (true); if (sel.size() != 1) break; - item_def *item = - static_cast( sel[0]->data ); + item_def *item = static_cast( sel[0]->data ); describe_item(*item); } - return false; + return (false); } std::string Stash::description() const @@ -539,7 +541,7 @@ bool Stash::matches_search(const std::string &prefix, stash_search_result &res) const { if (!enabled || items.empty() && feat == DNGN_FLOOR) - return false; + return (false); for (unsigned i = 0; i < items.size(); ++i) { @@ -882,16 +884,15 @@ bool ShopInfo::show_menu(const std::string &place, { sel = menu.show(); if (menu.getkey() == 1) - return true; + return (true); if (sel.size() != 1) break; - const shop_item *item = - static_cast( sel[0]->data ); + const shop_item *item = static_cast( sel[0]->data ); describe_shop_item(*item); } - return false; + return (false); } std::string ShopInfo::description() const @@ -904,7 +905,7 @@ bool ShopInfo::matches_search(const std::string &prefix, stash_search_result &res) const { if (items.empty() && visited) - return false; + return (false); bool note_status = notes_are_active(); activate_notes(false); @@ -1112,9 +1113,9 @@ bool LevelStashes::update_stash(int x, int y) s->update(); if (s->empty()) kill_stash(*s); - return true; + return (true); } - return false; + return (false); } // Removes a Stash from the level. @@ -1335,9 +1336,9 @@ bool StashTracker::update_stash(int x, int y) bool res = lev->update_stash(x, y); if (!lev->stash_count()) remove_level(); - return res; + return (res); } - return false; + return (false); } void StashTracker::remove_level(const level_id &place) @@ -1538,7 +1539,7 @@ struct compare_by_distance return (lhs.matches > rhs.matches); } else - return false; + return (false); } }; @@ -1564,7 +1565,7 @@ struct compare_by_name return (lhs.matches > rhs.matches); } else - return false; + return (false); } }; @@ -1751,12 +1752,12 @@ bool StashSearchMenu::process_key(int key) sel.clear(); menu_action = (action)((menu_action+1) % ACT_NUM); update_title(); - return true; + return (true); } else if (key == '/') { request_toggle_sort_method = true; - return false; + return (false); } return Menu::process_key(key); @@ -1768,7 +1769,7 @@ bool StashTracker::display_search_results( const char* sort_style) { if (results.empty()) - return false; + return (false); bool travelable = can_travel_interlevel(); @@ -1793,13 +1794,16 @@ bool StashTracker::display_search_results( std::ostringstream matchtitle; matchtitle << "[" << short_place_name(res.pos.id) << "] " << res.match; + if (res.matches > 1 && res.count > 1) matchtitle << " (" << res.matches << ")"; MenuEntry *me = new MenuEntry(matchtitle.str(), MEL_ITEM, 1, hotkey); me->data = &res; + if (res.shop && !res.shop->is_visited()) me->colour = CYAN; + stashmenu.add_entry(me); } @@ -1812,7 +1816,7 @@ bool StashTracker::display_search_results( if (stashmenu.request_toggle_sort_method) { - return true; + return (true); } if (sel.size() == 1 && stashmenu.menu_action == StashSearchMenu::ACT_EXAMINE) @@ -1837,7 +1841,7 @@ bool StashTracker::display_search_results( redraw_screen(); const travel_target lp = res->pos; start_translevel_travel(lp); - return false; + return (false); } continue; } @@ -1851,9 +1855,8 @@ bool StashTracker::display_search_results( static_cast(sel[0]->data); const level_pos lp = res->pos; start_translevel_travel(lp); - return false; } - return false; + return (false); } void StashTracker::update_corpses() diff --git a/crawl-ref/source/state.cc b/crawl-ref/source/state.cc index 7ed5d08de1..ae00ab869a 100644 --- a/crawl-ref/source/state.cc +++ b/crawl-ref/source/state.cc @@ -96,7 +96,7 @@ void game_state::cancel_cmd_repeat(std::string reason) reset_cmd_repeat(); - if (reason != "") + if (!reason.empty()) mpr(reason.c_str()); } @@ -112,13 +112,13 @@ void game_state::cancel_cmd_again(std::string reason) reset_cmd_again(); - if (reason != "") + if (!reason.empty()) mpr(reason.c_str()); } void game_state::cant_cmd_repeat(std::string reason) { - if (reason == "") + if (reason.empty()) reason = "Can't repeat that command."; cancel_cmd_repeat(reason); @@ -126,7 +126,7 @@ void game_state::cant_cmd_repeat(std::string reason) void game_state::cant_cmd_again(std::string reason) { - if (reason == "") + if (reason.empty()) reason = "Can't redo that command."; cancel_cmd_again(reason); @@ -147,10 +147,10 @@ bool interrupt_cmd_repeat( activity_interrupt_type ai, const activity_interrupt_data &at ) { if (crawl_state.cmd_repeat_start) - return false; + return (false); if (crawl_state.repeat_cmd == CMD_WIZARD) - return false; + return (false); switch (ai) { @@ -161,7 +161,7 @@ bool interrupt_cmd_repeat( activity_interrupt_type ai, case AI_HP_LOSS: case AI_MONSTER_ATTACKS: crawl_state.cancel_cmd_repeat("Command repetition interrupted."); - return true; + return (true); default: break; @@ -171,12 +171,12 @@ bool interrupt_cmd_repeat( activity_interrupt_type ai, { const monsters* mon = static_cast(at.data); if (!mon->visible()) - return false; + return (false); if (crawl_state.cmd_repeat_started_unsafe && at.context != "newly seen") { - return false; + return (false); } crawl_state.cancel_cmd_repeat(); @@ -196,12 +196,12 @@ bool interrupt_cmd_repeat( activity_interrupt_type ai, fs.cprintf("%s (", mon->name(DESC_PLAIN, true).c_str()); fs.add_glyph( mon ); fs.cprintf(") in view: (%d,%d), see_grid: %s", - mon->x, mon->y, - see_grid(mon->x, mon->y)? "yes" : "no"); + mon->x, mon->y, + see_grid(mon->x, mon->y)? "yes" : "no"); formatted_mpr(fs, MSGCH_WARN); #endif - return true; + return (true); } // If command repitition is being used to immitate the rest command, @@ -215,11 +215,12 @@ bool interrupt_cmd_repeat( activity_interrupt_type ai, crawl_state.cancel_cmd_repeat("HP restored."); else crawl_state.cancel_cmd_repeat("Command repetition interrupted."); - return true; + + return (true); } if (crawl_state.cmd_repeat_started_unsafe) - return false; + return (false); if (ai == AI_HIT_MONSTER) { @@ -231,14 +232,14 @@ bool interrupt_cmd_repeat( activity_interrupt_type ai, if (mons_class_flag(mon->type, M_NO_EXP_GAIN) && player_monster_visible(mon)) { - return false; + return (false); } crawl_state.cancel_cmd_repeat("Command repetition interrupted."); - return true; + return (true); } - return false; + return (false); } void game_state::reset_cmd_repeat() diff --git a/crawl-ref/source/store.cc b/crawl-ref/source/store.cc index 63935079f5..eadfc1a5d9 100644 --- a/crawl-ref/source/store.cc +++ b/crawl-ref/source/store.cc @@ -1147,7 +1147,7 @@ void CrawlHashTable::assert_validity() const const std::string &key = i->first; const CrawlStoreValue &val = i->second; - ASSERT(key != ""); + ASSERT(!key.empty()); std::string trimmed = trimmed_string(key); ASSERT(key == trimmed); diff --git a/crawl-ref/source/stuff.cc b/crawl-ref/source/stuff.cc index 352fda180c..8461fb0f4a 100644 --- a/crawl-ref/source/stuff.cc +++ b/crawl-ref/source/stuff.cc @@ -204,14 +204,15 @@ void radius_iterator::step_back() bool radius_iterator::on_valid_square() const { if (!in_bounds(location)) - return false; + return (false); if (!roguelike_metric && (location - center).abs() > radius*radius) - return false; + return (false); if (require_los && !see_grid(location)) - return false; + return (false); if (exclude_center && location == center) - return false; - return true; + return (false); + + return (true); } const radius_iterator& radius_iterator::operator++() @@ -220,9 +221,9 @@ const radius_iterator& radius_iterator::operator++() { this->step(); } - while ( !this->done() && !this->on_valid_square() ); + while (!this->done() && !this->on_valid_square()); - return *this; + return (*this); } const radius_iterator& radius_iterator::operator--() @@ -231,23 +232,23 @@ const radius_iterator& radius_iterator::operator--() { this->step_back(); } - while ( !this->done() && !this->on_valid_square() ); + while (!this->done() && !this->on_valid_square()); - return *this; + return (*this); } radius_iterator radius_iterator::operator++(int dummy) { const radius_iterator copy = *this; ++(*this); - return copy; + return (copy); } radius_iterator radius_iterator::operator--(int dummy) { const radius_iterator copy = *this; --(*this); - return copy; + return (copy); } // Crude, but functional. @@ -967,10 +968,11 @@ bool yes_or_no( const char* fmt, ... ) mprf(MSGCH_PROMPT, "%s? (Confirm with \"yes\".) ", buf); if (cancelable_get_line(buf, sizeof buf)) - return false; + return (false); if (strcasecmp(buf, "yes") != 0) - return false; - return true; + return (false); + + return (true); } // jmf: general helper (should be used all over in code) @@ -1011,9 +1013,9 @@ bool yesno( const char *str, bool safe, int safeanswer, bool clear_after, mesclr(); if (tmp == 'N') - return false; + return (false); else if (tmp == 'Y') - return true; + return (true); else if (!noprompt) mpr("[Y]es or [N]o only, please."); } @@ -1156,7 +1158,7 @@ bool silenced(int x, int y) if (you.duration[DUR_SILENCE] > 0 && distance(x, y, you.x_pos, you.y_pos) <= 36) // (6 * 6) { - return true; + return (true); } else { @@ -1164,16 +1166,16 @@ bool silenced(int x, int y) // for (int i = 0; i < MAX_SILENCES; i++) // { // if (distance(x, y, silencer[i].x, silencer[i].y) <= 36) - // return true; + // return (true); // } - return false; + return (false); } -} // end silenced() +} bool player_can_hear(int x, int y) { return (!silenced(x, y) && !silenced(you.x_pos, you.y_pos)); -} // end player_can_hear() +} // Returns true if inside the area the player can move and dig (ie exclusive). bool in_bounds( int x, int y ) @@ -1539,7 +1541,7 @@ int near_stairs(const coord_def &p, int max_dist, } } - return false; + return (false); } bool is_trap_square(dungeon_feature_type grid) @@ -1555,7 +1557,6 @@ void zap_los_monsters() losight(env.show, grd, you.x_pos, you.y_pos); for (int y = crawl_view.vlos1.y; y <= crawl_view.vlos2.y; ++y) - { for (int x = crawl_view.vlos1.x; x <= crawl_view.vlos2.x; ++x) { if (!in_vlos(x, y)) @@ -1599,7 +1600,6 @@ void zap_los_monsters() mon->mark_summoned(1, true); monster_die(mon, KILL_DISMISSED, 0); } - } } ////////////////////////////////////////////////////////////////////////// diff --git a/crawl-ref/source/tile2.cc b/crawl-ref/source/tile2.cc index c4ee319a0c..0e85818e53 100644 --- a/crawl-ref/source/tile2.cc +++ b/crawl-ref/source/tile2.cc @@ -1407,16 +1407,16 @@ static bool _draw_doll(img_type img, dolls_data *doll, bool force_redraw = false if (!changed && !force_redraw) - return false; + return (false); tilep_calc_flags(parts2, flags); ImgClear(img); - // Hack: change overlay order of boots/skirts + // Hack: change overlay order of boots/skirts. for (i = 0; i < TILEP_PARTS_TOTAL; i++) p_order2[i] = p_order[i]; - // swap boot and leg-armor + // Swap boot and leg-armour. if (parts2[TILEP_PART_LEG] < TILEP_LEG_SKIRT_OFS) { p_order2[6] = TILEP_PART_LEG; @@ -1450,16 +1450,16 @@ static bool _draw_doll(img_type img, dolls_data *doll, bool force_redraw = false else if (parts2[p] && flags[p]) _tcache_overlay_player(img, 0, 0, p, parts2[p], ymax, &c); } - return true; + return (true); } static void _load_doll_data(const char *fn, dolls_data *dolls, int max, int *mode, int *cur) { char fbuf[1024]; - int cur0 = 0; + int cur0 = 0; int mode0 = TILEP_M_DEFAULT; - FILE *fp = NULL; + FILE *fp = NULL; std::string dollsTxtString = datafile_path(fn, false, true); const char *dollsTxt = (dollsTxtString.c_str()[0] == 0) ? diff --git a/crawl-ref/source/transfor.cc b/crawl-ref/source/transfor.cc index f4152cb2ef..4cda163fe6 100644 --- a/crawl-ref/source/transfor.cc +++ b/crawl-ref/source/transfor.cc @@ -563,7 +563,7 @@ bool transform(int pow, transformation_type which_trans, bool quiet) case TRAN_AIR: if (check_for_cursed_equipment( rem_stuff )) - return false; + return (false); // Check in case we'll auto-remove stat boosting equipment. if (check_transformation_stat_loss(rem_stuff, quiet)) @@ -600,7 +600,7 @@ bool transform(int pow, transformation_type which_trans, bool quiet) case TRAN_SERPENT_OF_HELL: if (check_for_cursed_equipment(rem_stuff, quiet)) - return false; + return (false); // Check in case we'll auto-remove stat boosting equipment. if (check_transformation_stat_loss(rem_stuff, quiet)) diff --git a/crawl-ref/source/travel.cc b/crawl-ref/source/travel.cc index d91adee0a1..cc4136719c 100644 --- a/crawl-ref/source/travel.cc +++ b/crawl-ref/source/travel.cc @@ -654,9 +654,9 @@ bool is_travelable_stair(dungeon_feature_type gridc) case DNGN_RETURN_FROM_TOMB: case DNGN_RETURN_FROM_SWAMP: case DNGN_RETURN_FROM_SHOALS: - return true; + return (true); default: - return false; + return (false); } } @@ -673,9 +673,9 @@ bool is_gate(dungeon_feature_type gridc) case DNGN_TRANSIT_PANDEMONIUM: case DNGN_ENTER_PORTAL_VAULT: case DNGN_EXIT_PORTAL_VAULT: - return true; + return (true); default: - return false; + return (false); } } @@ -1975,11 +1975,11 @@ static bool _is_known_branch_id(int branch) { // The main dungeon is always known. if (branch == BRANCH_MAIN_DUNGEON) - return true; + return (true); // If we're in the branch, it darn well is known. if (you.where_are_you == branch) - return true; + return (true); // The Vestibule is special: there are no stairs to it, just a // portal @@ -3331,9 +3331,9 @@ bool LevelInfo::is_known_branch(unsigned char branch) const { for (int i = 0, count = stairs.size(); i < count; ++i) if (stairs[i].destination.id.branch == branch) - return true; + return (true); - return false; + return (false); } void LevelInfo::save(writer& outf) const @@ -3600,9 +3600,9 @@ bool TravelCache::is_known_branch(unsigned char branch) const std::map::const_iterator i = levels.begin(); for ( ; i != levels.end(); ++i) if (i->second.is_known_branch(branch)) - return true; + return (true); - return false; + return (false); } void TravelCache::save(writer& outf) const diff --git a/crawl-ref/source/tutorial.cc b/crawl-ref/source/tutorial.cc index 3b0bf63551..803d7c4192 100644 --- a/crawl-ref/source/tutorial.cc +++ b/crawl-ref/source/tutorial.cc @@ -173,7 +173,7 @@ bool pick_tutorial() Options.random_pick = true; // random choice of starting spellbook Options.weapon = WPN_HAND_AXE; // easiest choice for fighters - return true; + return (true); } if (keyn == CK_BKSP || keyn == ' ') @@ -189,17 +189,17 @@ bool pick_tutorial() { case CK_BKSP: choose_race(); - return false; + return (false); case ' ': choose_class(); - return false; + return (false); case 'X': cprintf(EOL "Goodbye!"); end(0); - return false; + return (false); } } - return false; + return (false); } void print_tutorial_menu(unsigned int type) @@ -207,7 +207,7 @@ void print_tutorial_menu(unsigned int type) char letter = 'a' + type; char desc[100]; - switch(type) + switch (type) { case TUT_BERSERK_CHAR: strcpy(desc, "(Melee oriented character with divine support)"); @@ -3768,12 +3768,12 @@ bool tutorial_monster_interesting(const monsters *mons) return (true); // The monster is (seriously) out of depth. - if (you.level_type == LEVEL_DUNGEON && - mons_level(mons->type) >= you.your_level + 8) + if (you.level_type == LEVEL_DUNGEON + && mons_level(mons->type) >= you.your_level + 8) { return (true); } - return false; + return (false); } void tutorial_describe_monster(const monsters *mons) diff --git a/crawl-ref/source/view.cc b/crawl-ref/source/view.cc index 776504af6b..f9e59cb24b 100644 --- a/crawl-ref/source/view.cc +++ b/crawl-ref/source/view.cc @@ -866,7 +866,7 @@ void beogh_follower_convert(monsters *monster, bool orc_hit) static void _handle_seen_interrupt(monsters* monster) { activity_interrupt_data aid(monster); - if (monster->seen_context != "") + if (!monster->seen_context.empty()) aid.context = monster->seen_context; else if (testbits(monster->flags, MF_WAS_IN_VIEW)) aid.context = "already seen"; @@ -995,7 +995,7 @@ void handle_monster_shouts(monsters* monster, bool force) if (msg == "__DEFAULT" || msg == "__NEXT") msg = getShoutString(default_msg_key, suffix); - else if (msg == "") + else if (msg.empty()) { // See if there's a shout for all monsters using the // same glyph/symbol @@ -1009,7 +1009,7 @@ void handle_monster_shouts(monsters* monster, bool force) glyph_key += "'"; msg = getShoutString(glyph_key, suffix); - if (msg == "" || msg == "__DEFAULT") + if (msg.empty() || msg == "__DEFAULT") msg = getShoutString(default_msg_key, suffix); } @@ -1018,11 +1018,11 @@ void handle_monster_shouts(monsters* monster, bool force) msg::streams(MSGCH_SOUND) << "You hear something buggy!" << std::endl; } - else if (s_type == S_SILENT && (msg == "" || msg == "__NONE")) + else if (s_type == S_SILENT && (msg.empty() || msg == "__NONE")) { ; // No "visual shout" defined for silent monster, do nothing. } - else if (msg == "") // Still nothing found? + else if (msg.empty()) // Still nothing found? { msg::streams(MSGCH_DIAGNOSTICS) << "No shout entry for default shout type '" @@ -1930,36 +1930,36 @@ static int _shoot_ray( double accx, double accy, const double slope, { int curx, cury; int cellnum; - for ( cellnum = 0; true; ++cellnum ) + for (cellnum = 0; true; ++cellnum) { _find_next_intercept( &accx, &accy, slope ); curx = static_cast(accx); cury = static_cast(accy); - if ( curx > maxrange || cury > maxrange ) + if (curx > maxrange || cury > maxrange) break; - // work with the new square + // Work with the new square. xpos[cellnum] = curx; ypos[cellnum] = cury; } return cellnum; } -// check if the passed ray has already been created +// Check if the passed ray has already been created. static bool _is_duplicate_ray( int len, int xpos[], int ypos[] ) { int cur_offset = 0; - for ( unsigned int i = 0; i < raylengths.size(); ++i ) + for (unsigned int i = 0; i < raylengths.size(); ++i) { - // only compare equal-length rays - if ( raylengths[i] != len ) + // Only compare equal-length rays. + if (raylengths[i] != len) { cur_offset += raylengths[i]; continue; } int j; - for ( j = 0; j < len; ++j ) + for (j = 0; j < len; ++j) { if (ray_coord_x[j + cur_offset] != xpos[j] || ray_coord_y[j + cur_offset] != ypos[j]) @@ -1968,41 +1968,46 @@ static bool _is_duplicate_ray( int len, int xpos[], int ypos[] ) } } - // exact duplicate? - if ( j == len ) - return true; + // Exact duplicate? + if (j == len) + return (true); - // move to beginning of next ray + // Move to beginning of next ray. cur_offset += raylengths[i]; } - return false; + return (false); } -// is starta...lengtha a subset of startb...lengthb? +// Is starta...lengtha a subset of startb...lengthb? static bool _is_subset( int starta, int startb, int lengtha, int lengthb ) { int cura = starta, curb = startb; int enda = starta + lengtha, endb = startb + lengthb; - while ( cura < enda && curb < endb ) + + while (cura < enda && curb < endb) { - if ( ray_coord_x[curb] > ray_coord_x[cura] ) - return false; - if ( ray_coord_y[curb] > ray_coord_y[cura] ) - return false; - if ( ray_coord_x[cura] == ray_coord_x[curb] && - ray_coord_y[cura] == ray_coord_y[curb] ) + if (ray_coord_x[curb] > ray_coord_x[cura]) + return (false); + if (ray_coord_y[curb] > ray_coord_y[cura]) + return (false); + + if (ray_coord_x[cura] == ray_coord_x[curb] + && ray_coord_y[cura] == ray_coord_y[curb]) + { ++cura; + } ++curb; } - return ( cura == enda ); + + return (cura == enda); } -// return a vector which lists all the nonduped cellrays (by index) +// Returns a vector which lists all the nonduped cellrays (by index). static std::vector _find_nonduped_cellrays() { - // a cellray c in a fullray f is duped if there is a fullray g - // such that g contains c and g[:c] is a subset of f[:c] + // A cellray c in a fullray f is duped if there is a fullray g + // such that g contains c and g[:c] is a subset of f[:c]. int raynum, cellnum, curidx, testidx, testray, testcell; bool is_duplicate; @@ -2013,9 +2018,9 @@ static std::vector _find_nonduped_cellrays() { for (cellnum = 0; cellnum < raylengths[raynum]; ++cellnum) { - // is the cellray raynum[cellnum] duplicated? + // Is the cellray raynum[cellnum] duplicated? is_duplicate = false; - // XXX We should really check everything up to now + // XXX: We should really check everything up to now // completely, and all further rays to see if they're // proper subsets. const int curx = ray_coord_x[curidx + cellnum]; @@ -2023,26 +2028,27 @@ static std::vector _find_nonduped_cellrays() for (testidx = 0, testray = 0; testray < raynum; testidx += raylengths[testray++]) { - // scan ahead to see if there's an intersect - for ( testcell = 0; testcell < raylengths[raynum]; ++testcell ) + // Scan ahead to see if there's an intersect. + for (testcell = 0; testcell < raylengths[raynum]; ++testcell) { const int testx = ray_coord_x[testidx + testcell]; const int testy = ray_coord_y[testidx + testcell]; - // we can short-circuit sometimes - if ( testx > curx || testy > cury ) + // We can short-circuit sometimes. + if (testx > curx || testy > cury) break; - // bingo! - if ( testx == curx && testy == cury ) + + // Bingo! + if (testx == curx && testy == cury) { is_duplicate = _is_subset(testidx, curidx, testcell, cellnum); break; } } - if ( is_duplicate ) - break; // no point in checking further rays + if (is_duplicate) + break; // No point in checking further rays. } - if ( !is_duplicate ) + if (!is_duplicate) result.push_back(curidx + cellnum); } } @@ -2056,19 +2062,19 @@ static bool _register_ray( double accx, double accy, double slope ) int xpos[LOS_MAX_RANGE * 2 + 1], ypos[LOS_MAX_RANGE * 2 + 1]; int raylen = _shoot_ray( accx, accy, slope, LOS_MAX_RANGE, xpos, ypos ); - // early out if ray already exists - if ( _is_duplicate_ray(raylen, xpos, ypos) ) - return false; + // Early out if ray already exists. + if (_is_duplicate_ray(raylen, xpos, ypos)) + return (false); - // not duplicate, register - for ( int i = 0; i < raylen; ++i ) + // Not duplicate, register. + for (int i = 0; i < raylen; ++i) { - // create the cellrays + // Create the cellrays. ray_coord_x.push_back(xpos[i]); ray_coord_y.push_back(ypos[i]); } - // register the fullray + // Register the fullray. raylengths.push_back(raylen); ray_def ray; ray.accx = accx; @@ -2077,7 +2083,7 @@ static bool _register_ray( double accx, double accy, double slope ) ray.quadrant = 0; fullrays.push_back(ray); - return true; + return (true); } static void _create_blockrays() @@ -2816,7 +2822,7 @@ static bool _is_feature_fudged(int feature, int x, int y) case DNGN_EXIT_ABYSS: case DNGN_EXIT_PANDEMONIUM: case DNGN_RETURN_FROM_ZOT: - return true; + return (true); default: return (false); } @@ -3664,7 +3670,7 @@ bool magic_mapping(int map_radius, int proportion, bool suppress_msg, tile_clear_buf(); #endif - return true; + return (true); } // end magic_mapping() // Realize that this is simply a repackaged version of @@ -5136,30 +5142,38 @@ class _inline_layout : public _layout public: _inline_layout(coord_def termsz_, coord_def hudsz_) : _layout(termsz_, hudsz_) - { valid = _init(); } + { + valid = _init(); + } + bool _init() { // x: View gets leftover; then mlist; then hud gutter if (leftover_x() < 0) - return false; + return (false); _increment(viewsz.x, leftover_x(), Options.view_max_width); - if ((viewsz.x % 2) != 1) --viewsz.x; + + if ((viewsz.x % 2) != 1) + --viewsz.x; + mlistsz.x = hudsz.x; _increment(mlistsz.x, leftover_x(), MLIST_MAX_WIDTH); _increment(hud_gutter, leftover_x(), HUD_MAX_GUTTER); _increment(mlistsz.x, leftover_x(), INT_MAX); - msgsz.x = termsz.x-1; // Can't use last character + msgsz.x = termsz.x-1; // Can't use last character. - // y: View gets as much as it wants - // mlist tries to get at least its minimum - // msg expands as much as it wants - // mlist gets any leftovers + // y: View gets as much as it wants. + // mlist tries to get at least its minimum. + // msg expands as much as it wants. + // mlist gets any leftovers. if (leftover_y() < 0) - return false; + return (false); _increment(viewsz.y, leftover_leftcol_y(), Options.view_max_height); - if ((viewsz.y % 2) != 1) --viewsz.y; + if ((viewsz.y % 2) != 1) + --viewsz.y; + if (Options.classic_hud) { mlistsz.y = 0; @@ -5173,14 +5187,14 @@ class _inline_layout : public _layout _increment(mlistsz.y, leftover_rightcol_y(), INT_MAX); } - // Finish off by doing the positions + // Finish off by doing the positions. viewp = termp; msgp = termp + coord_def(0, std::max(viewsz.y, hudsz.y+mlistsz.y)); hudp = viewp + coord_def(viewsz.x+hud_gutter, 0); mlistp = hudp + coord_def(0, hudsz.y); _assert_validity(); - return true; + return (true); } int leftover_x() const @@ -5212,31 +5226,40 @@ class _mlist_col_layout : public _layout // take some for the view. If it makes the layout fail, that's fine. _increment(viewsz.x, MLIST_MIN_WIDTH/2, Options.view_max_width); - // x: View and mlist share leftover; then hud gutter - if (leftover_x() < 0) return false; + // x: View and mlist share leftover; then hud gutter. + if (leftover_x() < 0) + return (false); _increment(mlistsz.x, leftover_x()/2, MLIST_MAX_WIDTH); _increment(viewsz.x, leftover_x(), Options.view_max_width); - if ((viewsz.x % 2) != 1) --viewsz.x; + + if ((viewsz.x % 2) != 1) + --viewsz.x; + _increment(mlistsz.x, leftover_x(), MLIST_MAX_WIDTH); _increment(hud_gutter, leftover_x(), HUD_MAX_GUTTER); - msgsz.x = termsz.x-1; // Can't use last character + msgsz.x = termsz.x-1; // Can't use last character. + + // y: View gets leftover; then message. + if (leftover_y() < 0) + return (false); - // y: View gets leftover; then message - if (leftover_y() < 0) return false; _increment(viewsz.y, leftover_y(), Options.view_max_height); - if ((viewsz.y % 2) != 1) --viewsz.y; + + if ((viewsz.y % 2) != 1) + --viewsz.y; + _increment(msgsz.y, leftover_y(), INT_MAX); mlistsz.y = viewsz.y; - // Finish off by doing the positions + // Finish off by doing the positions. mlistp = termp; viewp = mlistp+ coord_def(mlistsz.x+MLIST_GUTTER, 0); msgp = termp + coord_def(0, viewsz.y); hudp = viewp + coord_def(viewsz.x+hud_gutter, 0); _assert_validity(); - return true; + return (true); } private: int leftover_x() const -- cgit v1.2.3-54-g00ecf