From d82ee4ebd849c7bfebb8d9998604e63767849efb Mon Sep 17 00:00:00 2001 From: haranp Date: Tue, 15 May 2007 20:12:11 +0000 Subject: Minor cleanups. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1477 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/acr.cc | 3 ++- crawl-ref/source/clua.cc | 6 ++--- crawl-ref/source/files.cc | 16 +++++------- crawl-ref/source/invent.cc | 26 +++---------------- crawl-ref/source/mon-pick.cc | 2 -- crawl-ref/source/ouch.cc | 3 ++- crawl-ref/source/spells1.cc | 5 ++-- crawl-ref/source/spells3.cc | 3 ++- crawl-ref/source/spells4.cc | 32 +++++++++++++---------- crawl-ref/source/spells4.h | 2 +- crawl-ref/source/spl-cast.cc | 62 +++++++++++++++++++++++++++----------------- 11 files changed, 79 insertions(+), 81 deletions(-) (limited to 'crawl-ref') diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc index 0fa011d87d..ea93668845 100644 --- a/crawl-ref/source/acr.cc +++ b/crawl-ref/source/acr.cc @@ -2015,7 +2015,8 @@ static void decrement_durations() you.confusing_touch--; else if (you.confusing_touch == 1) { - mprf(MSGCH_DURATION, "Your %s stop glowing.", your_hand(true) ); + msg::streams(MSGCH_DURATION) << "Your " << your_hand(true) + << " stop glowing." << std::endl; you.confusing_touch = 0; } diff --git a/crawl-ref/source/clua.cc b/crawl-ref/source/clua.cc index 86ff09945d..9a1b16aab2 100644 --- a/crawl-ref/source/clua.cc +++ b/crawl-ref/source/clua.cc @@ -1112,10 +1112,10 @@ static int l_item_subtype(lua_State *ls) const char *s = NULL; if (item->base_type == OBJ_JEWELLERY) { - if (item->sub_type < AMU_RAGE) - s = ring_types[item->sub_type]; - else + if (jewellery_is_amulet(*item)) s = amulet_types[ item->sub_type - AMU_RAGE ]; + else + s = ring_types[item->sub_type]; } if (s) diff --git a/crawl-ref/source/files.cc b/crawl-ref/source/files.cc index ce75807379..cba3fc8936 100644 --- a/crawl-ref/source/files.cc +++ b/crawl-ref/source/files.cc @@ -848,9 +848,11 @@ static void clear_env_map() static void clear_clouds() { + for (int clouty = 0; clouty < MAX_CLOUDS; ++clouty) + delete_cloud( clouty ); for (int i = 0; i < GXM; i++) for (int j = 0; j < GYM; j++) - env.cgrid[i][j] = EMPTY_CLOUD; + ASSERT(env.cgrid[i][j] == EMPTY_CLOUD); } static void grab_followers(std::vector& followers) @@ -917,15 +919,10 @@ void load( int stair_taken, load_mode_type load_mode, bool was_a_labyrinth, you.prev_targ = MHITNOT; - // Don't delete clouds just because the player saved and restarted. + // We clear twice - on save and on load. + // Once would be enough... if (load_mode != LOAD_RESTART_GAME) - { - // XXX XXX FIXME shouldn't this just go into clear_clouds()? - for (int clouty = 0; clouty < MAX_CLOUDS; ++clouty) - delete_cloud( clouty ); - - ASSERT( env.cloud_no == 0 ); - } + clear_clouds(); // This block is to grab followers and save the old level to disk. if (load_mode == LOAD_ENTER_LEVEL) @@ -992,6 +989,7 @@ void load( int stair_taken, load_mode_type load_mode, bool was_a_labyrinth, if (just_created_level) clear_env_map(); + // Here's the second cloud clearing, on load (see above) if (load_mode != LOAD_RESTART_GAME) clear_clouds(); diff --git a/crawl-ref/source/invent.cc b/crawl-ref/source/invent.cc index d45051a80d..121768c4d7 100644 --- a/crawl-ref/source/invent.cc +++ b/crawl-ref/source/invent.cc @@ -61,33 +61,13 @@ std::string InvTitle::get_text() const InvEntry::InvEntry( const item_def &i ) : MenuEntry( "", MEL_ITEM ), item( &i ) { data = const_cast( item ); - - if (i.base_type == OBJ_GOLD) - { - // XXX XXX FIXME XXX XXX Why the special-casing? - char buf[ITEMNAME_SIZE]; - snprintf(buf, sizeof buf, "%d gold piece%s", i.quantity, - (i.quantity > 1? "s" : "")); - text = buf; - } - else - { - text = i.name(in_inventory(i)? DESC_INVENTORY_EQUIP : DESC_NOCAP_A, - false); - } + text = i.name(DESC_NOCAP_A, false); if (i.base_type != OBJ_GOLD && in_inventory(i)) - { - // FIXME: This is HORRIBLE! We're skipping the inventory letter prefix - // which looks like this: "a - ". - text = text.substr( 4 ); add_hotkey(index_to_letter( i.link )); - } else - { - // Dummy hotkey for gold or non-inventory items. - add_hotkey(' '); - } + add_hotkey(' '); // dummy hotkey + add_class_hotkeys(i); quantity = i.quantity; diff --git a/crawl-ref/source/mon-pick.cc b/crawl-ref/source/mon-pick.cc index e2c10ccacc..7e1343b71f 100644 --- a/crawl-ref/source/mon-pick.cc +++ b/crawl-ref/source/mon-pick.cc @@ -371,8 +371,6 @@ bool mons_pan(int mcls) // malign beings case MONS_EFREET: case MONS_RAKSHASA: - //case MONS_RAKSHASA_FAKE: //jmf: FIXME: really create these? - // I'm guessing not -- bwr // golems case MONS_CLAY_GOLEM: case MONS_CRYSTAL_GOLEM: diff --git a/crawl-ref/source/ouch.cc b/crawl-ref/source/ouch.cc index fdac3faa45..0c3721f596 100644 --- a/crawl-ref/source/ouch.cc +++ b/crawl-ref/source/ouch.cc @@ -28,6 +28,7 @@ #include #include +#include #include #include #include @@ -307,7 +308,7 @@ void weapon_acid( char acid_strength ) if (hand_thing == -1) { - mprf("Your %s burn!", your_hand(true) ); + msg::stream << "Your " << your_hand(true) << " burn!" << std::endl; ouch( roll_dice( 1, acid_strength ), 0, KILLED_BY_ACID ); } else if (random2(20) <= acid_strength) diff --git a/crawl-ref/source/spells1.cc b/crawl-ref/source/spells1.cc index 459c4e2c1f..43f5dcb3df 100644 --- a/crawl-ref/source/spells1.cc +++ b/crawl-ref/source/spells1.cc @@ -21,6 +21,7 @@ #include #include #include +#include #include "externs.h" @@ -1089,8 +1090,8 @@ void cast_ring_of_flames(int power) void cast_confusing_touch(int power) { - mprf("Your %s begin to glow %s.", - your_hand(true), (you.confusing_touch ? "brighter" : "red") ); + msg::stream << "Your " << your_hand(true) << " begin to glow " + << (you.confusing_touch ? "brighter" : "red") << std::endl; you.confusing_touch += 5 + (random2(power) / 5); diff --git a/crawl-ref/source/spells3.cc b/crawl-ref/source/spells3.cc index 6043c1a759..a9f5d591a3 100644 --- a/crawl-ref/source/spells3.cc +++ b/crawl-ref/source/spells3.cc @@ -18,6 +18,7 @@ #include #include #include +#include #include "externs.h" @@ -475,7 +476,7 @@ failed_spell: if ( wpn != -1 ) mpr("Your weapon vibrates crazily for a second."); else - mprf(MSGCH_PLAIN, "Your %s twitch.", your_hand(true)); + msg::stream <<"Your " << your_hand(true) << " twitch" << std::endl; } // end dancing_weapon() static bool monster_on_level(int monster) diff --git a/crawl-ref/source/spells4.cc b/crawl-ref/source/spells4.cc index 15068e46f8..f298b40b3b 100644 --- a/crawl-ref/source/spells4.cc +++ b/crawl-ref/source/spells4.cc @@ -15,6 +15,7 @@ #include "AppHdr.h" #include +#include #include #include "externs.h" @@ -34,6 +35,7 @@ #include "items.h" #include "invent.h" #include "makeitem.h" +#include "message.h" #include "misc.h" #include "monplace.h" #include "monstuff.h" @@ -72,10 +74,9 @@ void do_monster_rot(int mon); //jmf: FIXME: put somewhere else (misc.cc?) // A feeble attempt at Nethack-like completeness for cute messages. -const char *your_hand( bool plural ) +std::string your_hand( bool plural ) { - static char hand_buff[80]; - + std::string result; switch (you.attribute[ATTR_TRANSFORMATION]) { default: @@ -84,33 +85,33 @@ const char *your_hand( bool plural ) case TRAN_STATUE: if (you.species == SP_TROLL || you.species == SP_GHOUL) { - strcpy(hand_buff, "claw"); + result = "claw"; break; } // or fall-through case TRAN_ICE_BEAST: case TRAN_LICH: - strcpy(hand_buff, "hand"); + result = "hand"; break; case TRAN_SPIDER: - strcpy(hand_buff, "front leg"); + result = "front leg"; break; case TRAN_SERPENT_OF_HELL: case TRAN_DRAGON: - strcpy(hand_buff, "foreclaw"); + result = "foreclaw"; break; case TRAN_BLADE_HANDS: - strcpy(hand_buff, "scythe-like blade"); + result = "scythe-like blade"; break; case TRAN_AIR: - strcpy(hand_buff, "misty tendril"); + result = "misty tendril"; break; } if (plural) - strcat(hand_buff, "s"); + result += 's'; - return (hand_buff); + return result; } // I need to make some debris for metal, crystal and stone. @@ -668,7 +669,8 @@ void cast_sticks_to_snakes(int pow) if (weapon == -1) { - mprf("Your %s feel slithery!", your_hand(true)); + msg::stream << "Your " << your_hand(true) << " feel slithery!" + << std::endl; return; } @@ -765,7 +767,8 @@ void cast_sticks_to_snakes(int pow) } else { - mprf("Your %s feel slithery!", your_hand(true)); + msg::stream << "Your " << your_hand(true) << " feel slithery!" + << std::endl; } } // end cast_sticks_to_snakes() @@ -1879,7 +1882,8 @@ void cast_evaporate(int pow) if (potion == -1) { - mprf("Wisps of steam play over your %s!", your_hand(true) ); + msg::stream << "Wisps of steam play over your " << your_hand(true) + << std::endl; return; } else if (you.inv[potion].base_type != OBJ_POTIONS) diff --git a/crawl-ref/source/spells4.h b/crawl-ref/source/spells4.h index 004ce8085f..17ad71f76e 100644 --- a/crawl-ref/source/spells4.h +++ b/crawl-ref/source/spells4.h @@ -16,7 +16,7 @@ #include "externs.h" -const char *your_hand(bool plural); +std::string your_hand(bool plural); bool backlight_monsters(int x, int y, int pow, int garbage); int make_a_normal_cloud(int x, int y, int pow, cloud_type ctype, kill_category); diff --git a/crawl-ref/source/spl-cast.cc b/crawl-ref/source/spl-cast.cc index 6314f979a8..8119a2654b 100644 --- a/crawl-ref/source/spl-cast.cc +++ b/crawl-ref/source/spl-cast.cc @@ -1954,15 +1954,15 @@ bool miscast_effect( unsigned int sp_type, int mag_pow, int mag_fail, switch (random2(10)) { case 0: - mprf("Sparks fly from your %s!", your_hand(true) ); + msg::stream << "Sparks fly from your " << your_hand(true) + << '!' << std::endl; break; - case 1: mpr("The air around you crackles with energy!"); break; - case 2: - mprf("Wisps of smoke drift from your %s.", your_hand(true)); + msg::stream << "Wisps of smoke drift from your " + << your_hand(true) << '.' << std::endl; break; case 3: mpr("You feel a strange surge of energy!"); @@ -1994,7 +1994,8 @@ bool miscast_effect( unsigned int sp_type, int mag_pow, int mag_fail, switch (random2(2)) { case 0: - mprf("Smoke pours from your %s!", your_hand(true)); + msg::stream << "Smoke pours from your " << your_hand(true) + << '!' << std::endl; big_cloud( CLOUD_GREY_SMOKE, KC_YOU, you.x_pos, you.y_pos, 20, 7 + random2(7) ); @@ -2076,7 +2077,8 @@ bool miscast_effect( unsigned int sp_type, int mag_pow, int mag_fail, switch (random2(10)) { case 0: - mprf("Your %s glow momentarily.", your_hand(true) ); + msg::stream << "Your " << your_hand(true) + << " glow momentarily." << std::endl; break; case 1: mpr("The air around you crackles with energy!"); @@ -2751,7 +2753,8 @@ bool miscast_effect( unsigned int sp_type, int mag_pow, int mag_fail, switch (random2(10)) { case 0: - mprf("Your %s glow momentarily.", your_hand(true)); + msg::stream << "Your " << your_hand(true) + << " glow momentarily." << std::endl; break; case 1: mpr("The air around you crackles with energy!"); @@ -2854,13 +2857,15 @@ bool miscast_effect( unsigned int sp_type, int mag_pow, int mag_fail, switch (random2(10)) { case 0: - mprf("Sparks fly from your %s!", your_hand(true)); + msg::stream << "Sparks fly from your " << your_hand(true) + << '!' << std::endl; break; case 1: mpr("The air around you burns with energy!"); break; case 2: - mprf("Wisps of smoke drift from your %s.", your_hand(true)); + msg::stream << "Wisps of smoke drift from your " + << your_hand(true) << '.' << std::endl; break; case 3: mpr("You feel a strange surge of energy!"); @@ -2894,7 +2899,8 @@ bool miscast_effect( unsigned int sp_type, int mag_pow, int mag_fail, switch (random2(2)) { case 0: - mprf("Smoke pours from your %s!", your_hand(true) ); + msg::stream << "Smoke pours from your " + << your_hand(true) << "!" << std::endl; big_cloud( random_smoke_type(), KC_YOU, you.x_pos, you.y_pos, 20, 7 + random2(7) ); break; @@ -3000,14 +3006,15 @@ bool miscast_effect( unsigned int sp_type, int mag_pow, int mag_fail, mpr("A chill runs through your body."); break; case 2: - mprf("Wisps of condensation drift from your %s.", - your_hand(true)); + msg::stream << "Wisps of condensation drift from your " + << your_hand(true) << "." << std::endl; break; case 3: mpr("You feel a strange surge of energy!"); break; case 4: - mprf("Your %s feel numb with cold.", your_hand(true)); + msg::stream << "Your " << your_hand(true) + << " feel numb with cold." << std::endl; break; case 5: mpr("A chill runs through your body."); @@ -3093,7 +3100,8 @@ bool miscast_effect( unsigned int sp_type, int mag_pow, int mag_fail, expose_player_to_element(BEAM_COLD, 9); break; case 1: - mprf("Freezing gasses pour from your %s!", your_hand(true)); + msg::stream << "Freezing gasses pour from your " + << your_hand(true) << "!" << std::endl; big_cloud(CLOUD_COLD, KC_YOU, you.x_pos, you.y_pos, 20, 8 + random2(4)); break; @@ -3116,7 +3124,8 @@ bool miscast_effect( unsigned int sp_type, int mag_pow, int mag_fail, mpr("You are showered with tiny particles of grit."); break; case 2: - mprf("Sand pours from your %s.", your_hand(true)); + msg::stream << "Sand pours from your " + << your_hand(true) << "." << std::endl; break; case 3: mpr("You feel a surge of energy from the ground."); @@ -3220,7 +3229,8 @@ bool miscast_effect( unsigned int sp_type, int mag_pow, int mag_fail, mpr("You feel momentarily weightless."); break; case 2: - mprf("Wisps of vapour drift from your %s.", your_hand(true)); + msg::stream << "Wisps of vapour drift from your " + << your_hand(true) << "." << std::endl; break; case 3: mpr("You feel a strange surge of energy!"); @@ -3229,8 +3239,8 @@ bool miscast_effect( unsigned int sp_type, int mag_pow, int mag_fail, mpr("You feel electric!"); break; case 5: - mprf("Sparks of electricity dance between your %s.", - your_hand(true)); + msg::stream << "Sparks of electricity dance between your " + << your_hand(true) << "." << std::endl; break; case 6: mpr("You are blasted with air!"); @@ -3275,7 +3285,8 @@ bool miscast_effect( unsigned int sp_type, int mag_pow, int mag_fail, KILLED_BY_WILD_MAGIC, cause); break; case 1: - mprf("Noxious gasses pour from your %s!", your_hand(true)); + msg::stream << "Noxious gasses pour from your " + << your_hand(true) << "!" << std::endl; big_cloud(CLOUD_STINK, KC_YOU, you.x_pos, you.y_pos, 20, 9 + random2(4)); break; @@ -3306,7 +3317,8 @@ bool miscast_effect( unsigned int sp_type, int mag_pow, int mag_fail, explosion(beam); break; case 1: - mprf("Venomous gasses pour from your %s!", your_hand(true)); + msg::stream << "Venomous gasses pour from your " + << your_hand(true) << "!" << std::endl; big_cloud( CLOUD_POISON, KC_YOU, you.x_pos, you.y_pos, 20, 8 + random2(5) ); break; @@ -3328,8 +3340,8 @@ bool miscast_effect( unsigned int sp_type, int mag_pow, int mag_fail, mpr("You feel slightly ill."); break; case 2: - mprf("Wisps of poison gas drift from your %s.", - your_hand(true)); + msg::stream << "Wisps of poison gas drift from your " + << your_hand(true) << "." << std::endl; break; case 3: mpr("You feel a strange surge of energy!"); @@ -3373,7 +3385,8 @@ bool miscast_effect( unsigned int sp_type, int mag_pow, int mag_fail, break; case 1: - mprf("Noxious gasses pour from your %s!", your_hand(true) ); + msg::stream << "Noxious gasses pour from your " + << your_hand(true) << "!" << std::endl; place_cloud(CLOUD_STINK, you.x_pos, you.y_pos, 2 + random2(4), KC_YOU); break; @@ -3425,7 +3438,8 @@ bool miscast_effect( unsigned int sp_type, int mag_pow, int mag_fail, poison_player( 10 + random2avg(19, 2) ); break; case 1: - mprf("Venomous gasses pour from your %s!", your_hand(true)); + msg::stream << "Venomous gasses pour from your " + << your_hand(true) << "!" << std::endl; big_cloud(CLOUD_POISON, KC_YOU, you.x_pos, you.y_pos, 20, 7 + random2(7)); break; -- cgit v1.2.3-54-g00ecf