From 173d629a2374eb0b55821e0cf972dcd7ae34c2da Mon Sep 17 00:00:00 2001 From: haranp Date: Mon, 15 Sep 2008 14:25:08 +0000 Subject: Fix 2082716: clean colour tags from dumps. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@6934 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/dungeon.cc | 33 +++++++++++++++------------------ crawl-ref/source/message.cc | 13 ++++++------- 2 files changed, 21 insertions(+), 25 deletions(-) (limited to 'crawl-ref/source') diff --git a/crawl-ref/source/dungeon.cc b/crawl-ref/source/dungeon.cc index 7094d221a1..f6cc5ddabd 100644 --- a/crawl-ref/source/dungeon.cc +++ b/crawl-ref/source/dungeon.cc @@ -2447,48 +2447,45 @@ static bool _shaft_is_in_corridor(const coord_def& c) static void _place_traps(int level_number) { - int i; - int num_traps = num_traps_for_place(level_number); + const int num_traps = num_traps_for_place(level_number); ASSERT(num_traps >= 0); ASSERT(num_traps <= MAX_TRAPS); - for (i = 0; i < num_traps; i++) + for (int i = 0; i < num_traps; i++) { - // Traps can be placed in vaults. - if (env.trap[i].type != TRAP_UNASSIGNED) + trap_struct& ts(env.trap[i]); + if (ts.type != TRAP_UNASSIGNED) continue; int tries = 200; do { - env.trap[i].pos.x = random2(GXM); - env.trap[i].pos.y = random2(GYM); + ts.pos.x = random2(GXM); + ts.pos.y = random2(GYM); } - while (grd(env.trap[i].pos) != DNGN_FLOOR + while (in_bounds(ts.pos) + && grd(ts.pos) != DNGN_FLOOR && --tries > 0); if (tries <= 0) break; - trap_type &trap_type = env.trap[i].type; - trap_type = random_trap_for_place(level_number); - - if (trap_type == TRAP_SHAFT && level_number <= 7) + ts.type = random_trap_for_place(level_number); + if (ts.type == TRAP_SHAFT && level_number <= 7) { // Disallow shaft construction in corridors! - if ( _shaft_is_in_corridor(env.trap[i].pos) ) + if ( _shaft_is_in_corridor(ts.pos) ) { // Choose again! - trap_type = random_trap_for_place(level_number); + ts.type = random_trap_for_place(level_number); // If we get shaft a second time, turn it into an alarm trap. - if (trap_type == TRAP_SHAFT) - trap_type = TRAP_ALARM; + if (ts.type == TRAP_SHAFT) + ts.type = TRAP_ALARM; } } - - grd(env.trap[i].pos) = DNGN_UNDISCOVERED_TRAP; + grd(ts.pos) = DNGN_UNDISCOVERED_TRAP; } } diff --git a/crawl-ref/source/message.cc b/crawl-ref/source/message.cc index 62867c7dcd..b480ca392d 100644 --- a/crawl-ref/source/message.cc +++ b/crawl-ref/source/message.cc @@ -897,13 +897,12 @@ static bool is_channel_dumpworthy(msg_channel_type channel) std::string get_last_messages(int mcount) { if (mcount <= 0) - return std::string(); + return ""; if (mcount > NUM_STORED_MESSAGES) mcount = NUM_STORED_MESSAGES; - bool full_buffer - = (Store_Message[ NUM_STORED_MESSAGES - 1 ].text.length() == 0); + bool full_buffer = (Store_Message[NUM_STORED_MESSAGES - 1].text.empty()); int initial = Next_Message - mcount; if (initial < 0 || initial > NUM_STORED_MESSAGES) initial = full_buffer ? initial + NUM_STORED_MESSAGES : 0; @@ -914,9 +913,9 @@ std::string get_last_messages(int mcount) { const message_item &msg = Store_Message[i]; - if (msg.text.length() && is_channel_dumpworthy(msg.channel)) + if (!msg.text.empty() && is_channel_dumpworthy(msg.channel)) { - text += msg.text; + text += formatted_string::parse_string(msg.text).tostring(); text += EOL; count++; } @@ -973,7 +972,7 @@ void replay_messages(void) const int num_lines = get_number_of_lines(); - if (Store_Message[ NUM_STORED_MESSAGES - 1 ].text.length() == 0) + if (Store_Message[NUM_STORED_MESSAGES - 1].text.empty()) { full_buffer = false; first_message = 0; @@ -1022,7 +1021,7 @@ void replay_messages(void) textcolor( colour ); - std::string text = Store_Message[ line ].text; + std::string text = Store_Message[line].text; // Allow formatted output of tagged messages. formatted_string fs = formatted_string::parse_string(text, true); -- cgit v1.2.3-54-g00ecf