summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/misc.cc
diff options
context:
space:
mode:
authorharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2007-06-20 09:31:46 +0000
committerharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2007-06-20 09:31:46 +0000
commit2d4c05e46de7f35c454f1dfbf3892ad589038a58 (patch)
treed284c887ec6d5746b181e336aedb49f514eb07b7 /crawl-ref/source/misc.cc
parentb31de410dd1c21ca6e63d823ecd2619b6bfa7299 (diff)
downloadcrawl-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/misc.cc')
-rw-r--r--crawl-ref/source/misc.cc160
1 files changed, 83 insertions, 77 deletions
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)
{