diff options
author | haranp <haranp@c06c8d41-db1a-0410-9941-cceddc491573> | 2007-06-20 09:31:46 +0000 |
---|---|---|
committer | haranp <haranp@c06c8d41-db1a-0410-9941-cceddc491573> | 2007-06-20 09:31:46 +0000 |
commit | 2d4c05e46de7f35c454f1dfbf3892ad589038a58 (patch) | |
tree | d284c887ec6d5746b181e336aedb49f514eb07b7 /crawl-ref/source | |
parent | b31de410dd1c21ca6e63d823ecd2619b6bfa7299 (diff) | |
download | crawl-ref-2d4c05e46de7f35c454f1dfbf3892ad589038a58.tar.gz crawl-ref-2d4c05e46de7f35c454f1dfbf3892ad589038a58.zip |
More minor cleanups.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1608 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source')
-rw-r--r-- | crawl-ref/source/effects.cc | 30 | ||||
-rw-r--r-- | crawl-ref/source/it_use3.cc | 7 | ||||
-rw-r--r-- | crawl-ref/source/mapdef.cc | 2 | ||||
-rw-r--r-- | crawl-ref/source/misc.cc | 160 | ||||
-rw-r--r-- | crawl-ref/source/misc.h | 4 | ||||
-rw-r--r-- | crawl-ref/source/monplace.cc | 2 | ||||
-rw-r--r-- | crawl-ref/source/monplace.h | 2 | ||||
-rw-r--r-- | crawl-ref/source/mstuff2.cc | 9 | ||||
-rw-r--r-- | crawl-ref/source/spl-book.cc | 12 |
9 files changed, 111 insertions, 117 deletions
diff --git a/crawl-ref/source/effects.cc b/crawl-ref/source/effects.cc index a37f635f4d..f3661b0f4c 100644 --- a/crawl-ref/source/effects.cc +++ b/crawl-ref/source/effects.cc @@ -378,14 +378,13 @@ void mons_direct_effect(struct bolt &pbolt, int i) void random_uselessness(unsigned char ru, unsigned char sc_read_2) { - char wc[30]; int temp_rand = 0; // probability determination {dlb} switch (ru) { case 0: - weird_colours(random2(256), wc); - mprf("The dust glows a %s colour!", wc); + msg::stream << "The dust glows a " << weird_colours(random2(256)) + << " colour!" << std::endl; break; case 1: @@ -396,10 +395,9 @@ void random_uselessness(unsigned char ru, unsigned char sc_read_2) case 2: if (you.equip[EQ_WEAPON] != -1) { - weird_colours(random2(256), wc); - mprf("%s glows %s for a moment.", - you.inv[you.equip[EQ_WEAPON]].name(DESC_CAP_YOUR).c_str(), - wc); + msg::stream << you.inv[you.equip[EQ_WEAPON]].name(DESC_CAP_YOUR) + << " glows " << weird_colours(random2(256)) + << " for a moment." << std::endl; } else { @@ -481,7 +479,6 @@ bool acquirement(object_class_type force_class, int agent) unsigned char type_wanted = OBJ_RANDOM; unsigned char unique = 1; - unsigned char acqc = 0; const int max_has_value = 100; FixedVector< int, max_has_value > already_has; @@ -490,8 +487,7 @@ bool acquirement(object_class_type force_class, int agent) char best_any = 99; unsigned char keyin; - for (acqc = 0; acqc < max_has_value; acqc++) - already_has[acqc] = 0; + already_has.init(0); int spell_skills = 0; for (int i = SK_SPELLCASTING; i <= SK_POISON_MAGIC; i++) @@ -530,7 +526,7 @@ bool acquirement(object_class_type force_class, int agent) else class_wanted = force_class; - for (acqc = 0; acqc < ENDOFPACK; acqc++) + for (int acqc = 0; acqc < ENDOFPACK; acqc++) { if (is_valid_item( you.inv[acqc] ) && you.inv[acqc].base_type == class_wanted) @@ -1200,19 +1196,19 @@ bool acquirement(object_class_type force_class, int agent) || thing.sub_type == BOOK_MINOR_MAGIC_II || thing.sub_type == BOOK_MINOR_MAGIC_III) { - you.had_book[ BOOK_MINOR_MAGIC_I ] = 1; - you.had_book[ BOOK_MINOR_MAGIC_II ] = 1; - you.had_book[ BOOK_MINOR_MAGIC_III ] = 1; + you.had_book[ BOOK_MINOR_MAGIC_I ] = true; + you.had_book[ BOOK_MINOR_MAGIC_II ] = true; + you.had_book[ BOOK_MINOR_MAGIC_III ] = true; } else if (thing.sub_type == BOOK_CONJURATIONS_I || thing.sub_type == BOOK_CONJURATIONS_II) { - you.had_book[ BOOK_CONJURATIONS_I ] = 1; - you.had_book[ BOOK_CONJURATIONS_II ] = 1; + you.had_book[ BOOK_CONJURATIONS_I ] = true; + you.had_book[ BOOK_CONJURATIONS_II ] = true; } else { - you.had_book[ thing.sub_type ] = 1; + you.had_book[ thing.sub_type ] = true; } } else if (thing.base_type == OBJ_JEWELLERY) diff --git a/crawl-ref/source/it_use3.cc b/crawl-ref/source/it_use3.cc index 9e4b6defa5..ee168bf1ee 100644 --- a/crawl-ref/source/it_use3.cc +++ b/crawl-ref/source/it_use3.cc @@ -798,11 +798,8 @@ void tome_of_power(char sc_read_2) spell_type spell_casted = SPELL_NO_SPELL; struct bolt beam; - - char wc[40]; - weird_writing( wc ); - - mprf("The book opens to a page covered in %s.", wc); + msg::stream << "The book opens to a page covered in " + << weird_writing() << '.' << std::endl; you.turn_is_over = true; diff --git a/crawl-ref/source/mapdef.cc b/crawl-ref/source/mapdef.cc index 13d4b68532..a6b49c49c5 100644 --- a/crawl-ref/source/mapdef.cc +++ b/crawl-ref/source/mapdef.cc @@ -956,7 +956,7 @@ int mons_list::fix_demon(int demon) const demon = -100 - demon; if (demon == DEMON_RANDOM) demon = random2(DEMON_RANDOM); - return (summon_any_demon( demon )); + return (summon_any_demon( static_cast<demon_class_type>(demon) )); } mons_spec mons_list::pick_monster(mons_spec_slot &slot) diff --git a/crawl-ref/source/misc.cc b/crawl-ref/source/misc.cc index 0d611e1d58..269fe2bcbb 100644 --- a/crawl-ref/source/misc.cc +++ b/crawl-ref/source/misc.cc @@ -1465,61 +1465,64 @@ void disarm_trap( struct dist &disa ) exercise(SK_TRAPS_DOORS, 1 + random2(5) + (you.your_level / 5)); } // end disarm_trap() -void weird_writing(char stringy[40]) +std::string weird_writing() { - int temp_rand = 0; // for probability determinations {dlb} + int temp_rand; // for probability determinations {dlb} + std::string result; temp_rand = random2(15); - - // you'll see why later on {dlb} - strcpy(stringy, (temp_rand == 0) ? "writhing" : - (temp_rand == 1) ? "bold" : - (temp_rand == 2) ? "faint" : - (temp_rand == 3) ? "spidery" : - (temp_rand == 4) ? "blocky" : - (temp_rand == 5) ? "angular" : - (temp_rand == 6) ? "shimmering" : - (temp_rand == 7) ? "glowing" : ""); - - if (temp_rand < 8) - strcat(stringy, " "); // see above for reasoning {dlb} + result = + (temp_rand == 0) ? "writhing" : + (temp_rand == 1) ? "bold" : + (temp_rand == 2) ? "faint" : + (temp_rand == 3) ? "spidery" : + (temp_rand == 4) ? "blocky" : + (temp_rand == 5) ? "angular" : + (temp_rand == 6) ? "shimmering" : + (temp_rand == 7) ? "glowing" + : ""; + + if (!result.empty()) + result += ' '; temp_rand = random2(14); - strcat(stringy, (temp_rand == 0) ? "yellow" : - (temp_rand == 1) ? "brown" : - (temp_rand == 2) ? "black" : - (temp_rand == 3) ? "purple" : - (temp_rand == 4) ? "orange" : - (temp_rand == 5) ? "lime-green" : - (temp_rand == 6) ? "blue" : - (temp_rand == 7) ? "grey" : - (temp_rand == 8) ? "silver" : - (temp_rand == 9) ? "gold" : - (temp_rand == 10) ? "umber" : - (temp_rand == 11) ? "charcoal" : - (temp_rand == 12) ? "pastel" : - (temp_rand == 13) ? "mauve" - : "colourless"); - - strcat(stringy, " "); + result += + (temp_rand == 0) ? "yellow" : + (temp_rand == 1) ? "brown" : + (temp_rand == 2) ? "black" : + (temp_rand == 3) ? "purple" : + (temp_rand == 4) ? "orange" : + (temp_rand == 5) ? "lime-green" : + (temp_rand == 6) ? "blue" : + (temp_rand == 7) ? "grey" : + (temp_rand == 8) ? "silver" : + (temp_rand == 9) ? "gold" : + (temp_rand == 10) ? "umber" : + (temp_rand == 11) ? "charcoal" : + (temp_rand == 12) ? "pastel" : + (temp_rand == 13) ? "mauve" + : "colourless"; + + result += ' '; temp_rand = random2(14); - strcat(stringy, (temp_rand == 0) ? "writing" : - (temp_rand == 1) ? "scrawl" : - (temp_rand == 2) ? "sigils" : - (temp_rand == 3) ? "runes" : - (temp_rand == 4) ? "hieroglyphics" : - (temp_rand == 5) ? "scrawl" : - (temp_rand == 6) ? "print-out" : - (temp_rand == 7) ? "binary code" : - (temp_rand == 8) ? "glyphs" : - (temp_rand == 9) ? "symbols" - : "text"); + result += + (temp_rand == 0) ? "writing" : + (temp_rand == 1) ? "scrawl" : + (temp_rand == 2) ? "sigils" : + (temp_rand == 3) ? "runes" : + (temp_rand == 4) ? "hieroglyphics" : + (temp_rand == 5) ? "scrawl" : + (temp_rand == 6) ? "print-out" : + (temp_rand == 7) ? "binary code" : + (temp_rand == 8) ? "glyphs" : + (temp_rand == 9) ? "symbols" + : "text"; - return; -} // end weird_writing() + return result; +} // returns true if we manage to scramble free. bool fall_into_a_pool( int entry_x, int entry_y, bool allow_shift, @@ -1635,47 +1638,50 @@ bool scramble(void) return true; } // end scramble() -void weird_colours(unsigned char coll, char wc[30]) +std::string weird_colours(unsigned char coll) { unsigned char coll_div16 = coll / 16; // conceivable max is then 16 {dlb} + std::string result; // Must start with a consonant! - strcpy(wc, (coll_div16 == 0 || coll_div16 == 7) ? "brilliant" : - (coll_div16 == 1 || coll_div16 == 8) ? "pale" : - (coll_div16 == 2 || coll_div16 == 9) ? "mottled" : - (coll_div16 == 3 || coll_div16 == 10) ? "shimmering" : - (coll_div16 == 4 || coll_div16 == 11) ? "bright" : - (coll_div16 == 5 || coll_div16 == 12) ? "dark" : - (coll_div16 == 6 || coll_div16 == 13) ? "shining" - : "faint"); - - strcat(wc, " "); + result = + (coll_div16 == 0 || coll_div16 == 7) ? "brilliant" : + (coll_div16 == 1 || coll_div16 == 8) ? "pale" : + (coll_div16 == 2 || coll_div16 == 9) ? "mottled" : + (coll_div16 == 3 || coll_div16 == 10) ? "shimmering" : + (coll_div16 == 4 || coll_div16 == 11) ? "bright" : + (coll_div16 == 5 || coll_div16 == 12) ? "dark" : + (coll_div16 == 6 || coll_div16 == 13) ? "shining" + : "faint"; + + result += ' '; while (coll > 17) coll -= 10; - strcat(wc, (coll == 0) ? "red" : - (coll == 1) ? "purple" : - (coll == 2) ? "green" : - (coll == 3) ? "orange" : - (coll == 4) ? "magenta" : - (coll == 5) ? "black" : - (coll == 6) ? "grey" : - (coll == 7) ? "silver" : - (coll == 8) ? "gold" : - (coll == 9) ? "pink" : - (coll == 10) ? "yellow" : - (coll == 11) ? "white" : - (coll == 12) ? "brown" : - (coll == 13) ? "aubergine" : - (coll == 14) ? "ochre" : - (coll == 15) ? "leaf green" : - (coll == 16) ? "mauve" : - (coll == 17) ? "azure" - : "colourless"); + result += + (coll == 0) ? "red" : + (coll == 1) ? "purple" : + (coll == 2) ? "green" : + (coll == 3) ? "orange" : + (coll == 4) ? "magenta" : + (coll == 5) ? "black" : + (coll == 6) ? "grey" : + (coll == 7) ? "silver" : + (coll == 8) ? "gold" : + (coll == 9) ? "pink" : + (coll == 10) ? "yellow" : + (coll == 11) ? "white" : + (coll == 12) ? "brown" : + (coll == 13) ? "aubergine" : + (coll == 14) ? "ochre" : + (coll == 15) ? "leaf green" : + (coll == 16) ? "mauve" : + (coll == 17) ? "azure" + : "colourless"; - return; -} // end weird_colours() + return result; +} bool go_berserk(bool intentional) { diff --git a/crawl-ref/source/misc.h b/crawl-ref/source/misc.h index e945411e0d..ef30f7d1a2 100644 --- a/crawl-ref/source/misc.h +++ b/crawl-ref/source/misc.h @@ -115,14 +115,14 @@ void up_stairs(void); /* *********************************************************************** * called from: acr - effects * *********************************************************************** */ -void weird_colours(unsigned char coll, char wc[30]); +std::string weird_colours(unsigned char coll); // last updated 12may2000 {dlb} /* *********************************************************************** * called from: it_use3 * *********************************************************************** */ -void weird_writing(char stringy[40]); +std::string weird_writing(); // last updated 3jun2000 {dlb} diff --git a/crawl-ref/source/monplace.cc b/crawl-ref/source/monplace.cc index 463217bd98..955e7776c4 100644 --- a/crawl-ref/source/monplace.cc +++ b/crawl-ref/source/monplace.cc @@ -1470,7 +1470,7 @@ bool empty_surrounds(int emx, int emy, unsigned char spc_wanted, return (good_count > 0); } // end empty_surrounds() -int summon_any_demon(char demon_class) +int summon_any_demon(demon_class_type demon_class) { int summoned; // error trapping {dlb} int temp_rand; // probability determination {dlb} diff --git a/crawl-ref/source/monplace.h b/crawl-ref/source/monplace.h index 3347a05d89..786ce7ac8b 100644 --- a/crawl-ref/source/monplace.h +++ b/crawl-ref/source/monplace.h @@ -66,7 +66,7 @@ bool empty_surrounds( int emx, int emy, unsigned char spc_wanted, int radius, /* *********************************************************************** * called from: ability - acr - items - maps - mstuff2 - spell - spells * *********************************************************************** */ -int summon_any_demon( char demon_class ); +int summon_any_demon( demon_class_type demon_class ); // last update 13mar2001 {gdl} diff --git a/crawl-ref/source/mstuff2.cc b/crawl-ref/source/mstuff2.cc index 474dd88ab7..41edcb93c0 100644 --- a/crawl-ref/source/mstuff2.cc +++ b/crawl-ref/source/mstuff2.cc @@ -1977,14 +1977,9 @@ static int monster_abjuration(bool friendly, int pow, bool test) bool silver_statue_effects(monsters *mons) { - if ((mons_player_visible(mons) || one_chance_in(3)) - && !one_chance_in(3)) + if ((mons_player_visible(mons) || one_chance_in(3)) && !one_chance_in(3)) { - char wc[30]; - - weird_colours( random2(256), wc ); - std::string msg = "'s eyes glow "; - msg += wc; + const std::string msg = "'s eyes glow " + weird_colours(random2(256)); simple_monster_message(mons, msg.c_str(), MSGCH_WARN); create_monster( summon_any_demon((coinflip() ? DEMON_COMMON diff --git a/crawl-ref/source/spl-book.cc b/crawl-ref/source/spl-book.cc index f904ee2a70..02bb77e9af 100644 --- a/crawl-ref/source/spl-book.cc +++ b/crawl-ref/source/spl-book.cc @@ -1028,21 +1028,21 @@ unsigned char read_book( item_def &book, int action ) if (book.base_type == OBJ_BOOKS) { - you.had_book[ book.sub_type ] = 1; + you.had_book[ book.sub_type ] = true; if ( book.sub_type == BOOK_MINOR_MAGIC_I || book.sub_type == BOOK_MINOR_MAGIC_II || book.sub_type == BOOK_MINOR_MAGIC_III) { - you.had_book[BOOK_MINOR_MAGIC_I] = 1; - you.had_book[BOOK_MINOR_MAGIC_II] = 1; - you.had_book[BOOK_MINOR_MAGIC_III] = 1; + you.had_book[BOOK_MINOR_MAGIC_I] = true; + you.had_book[BOOK_MINOR_MAGIC_II] = true; + you.had_book[BOOK_MINOR_MAGIC_III] = true; } else if (book.sub_type == BOOK_CONJURATIONS_I || book.sub_type == BOOK_CONJURATIONS_II) { - you.had_book[BOOK_CONJURATIONS_I] = 1; - you.had_book[BOOK_CONJURATIONS_II] = 1; + you.had_book[BOOK_CONJURATIONS_I] = true; + you.had_book[BOOK_CONJURATIONS_II] = true; } } |