From 994c1d68d101cb0796457123deac5c973e912d9d Mon Sep 17 00:00:00 2001 From: haranp Date: Mon, 6 Oct 2008 11:59:08 +0000 Subject: Fix 2148551: items not uppercased. Other minor fixes. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@7157 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/beam.cc | 46 +++++++++++++++++---------------------- crawl-ref/source/directn.cc | 52 +++++++++++++++++++++------------------------ crawl-ref/source/ouch.cc | 10 +++++++++ crawl-ref/source/ouch.h | 34 ++--------------------------- 4 files changed, 55 insertions(+), 87 deletions(-) (limited to 'crawl-ref') diff --git a/crawl-ref/source/beam.cc b/crawl-ref/source/beam.cc index 539e532440..d3ff91f6b6 100644 --- a/crawl-ref/source/beam.cc +++ b/crawl-ref/source/beam.cc @@ -1482,10 +1482,7 @@ static void _zappy( zap_type z_type, int power, bolt &pbolt ) } if (wearing_amulet(AMU_INACCURACY)) - { - pbolt.hit -= 5; - pbolt.hit = std::max(0, pbolt.hit); - } + pbolt.hit = std::max(0, pbolt.hit - 5); } // Affect monster in wall unless it can shield itself using the wall. @@ -3144,7 +3141,7 @@ static int _affect_wall(bolt &beam, const coord_def& p) else { mpr("The statue screams as its substance crumbles away!", - MSGCH_SOUND); + MSGCH_SOUND); } } else if (see_grid(p)) @@ -3195,11 +3192,8 @@ static int _affect_place_clouds(bolt &beam, const coord_def& p) || (env.cloud[clouty].type == CLOUD_FIRE && beam.flavour == BEAM_COLD)) { - if (!silenced(p) - && !silenced(you.pos())) - { + if (player_can_hear(p)) mpr("You hear a sizzling sound!", MSGCH_SOUND); - } delete_cloud( clouty ); return (5); @@ -3340,11 +3334,6 @@ static void _affect_place_explosion_clouds(bolt &beam, const coord_def& p) } } -static int _beam_ouch_agent(const bolt &beam) -{ - return YOU_KILL(beam.thrower) ? 0 : beam.beam_source; -} - // A little helper function to handle the calling of ouch()... static void _beam_ouch(int dam, bolt &beam) { @@ -4028,7 +4017,8 @@ static int _affect_player( bolt &beam, item_def *item ) { if (x_chance_in_y(90 - 3 * player_AC(), 100)) { - curare_hits_player( _beam_ouch_agent(beam), 1 + random2(3) ); + curare_hits_player(actor_to_death_source(beam.agent()), + 1 + random2(3)); was_affected = true; } } @@ -5029,7 +5019,7 @@ static void _explosion1(bolt &pbolt) mpr(seeMsg); else { - if (silenced(p) || silenced(you.pos())) + if (!player_can_hear(p)) pbolt.msg_generated = false; else mpr(hearMsg, MSGCH_SOUND); @@ -5317,7 +5307,7 @@ static void _explosion_map( bolt &beam, const coord_def& p, int count, int dir, int r ) { // Check to see out of range. - if (p.x*p.x + p.y*p.y > r*r + r) + if (p.abs() > r*(r+1)) return; // Check count. @@ -5334,19 +5324,22 @@ static void _explosion_map( bolt &beam, const coord_def& p, if (is_sanctuary(loc)) return; - // Check to see if we're blocked by something specifically, we're blocked - // by WALLS. Not statues, idols, etc. const dungeon_feature_type dngn_feat = grd(loc); - // Special case: Explosion originates from rock/statue - // (e.g. Lee's rapid deconstruction) - in this case, ignore - // solid cells at the center of the explosion. - if (dngn_feat <= DNGN_MAXWALL - && (p.x != 0 || p.y != 0) && !_affects_wall(beam, dngn_feat)) + // Check to see if we're blocked by something specifically, we're + // blocked by WALLS. Not statues, idols, etc. Special case: + // Explosion originates from rock/statue (e.g. Lee's rapid + // deconstruction) - in this case, ignore solid cells at the + // center of the explosion. + + if (grid_is_wall(dngn_feat) + || dngn_feat == DNGN_SECRET_DOOR + || dngn_feat == DNGN_CLOSED_DOOR) { - return; + if (!(_affects_wall(beam, dngn_feat) && p.origin())) + return; } - + // Hmm, I think we're ok. explode_map(p + coord_def(9,9)) = true; @@ -5446,7 +5439,6 @@ bolt::bolt() : range(0), type('*'), ench_power(0), hit(0), thrower(KILL_MISC), ex_size(0), beam_source(MHITNOT), name(), is_beam(false), is_explosion(false), is_big_cloud(false), -// is_launched(false), aimed_at_spot(false), aux_source(), affects_nothing(false), obvious_effect(false), effect_known(true), fr_count(0), foe_count(0), fr_power(0), diff --git a/crawl-ref/source/directn.cc b/crawl-ref/source/directn.cc index 5372642ed8..7cd259a322 100644 --- a/crawl-ref/source/directn.cc +++ b/crawl-ref/source/directn.cc @@ -447,34 +447,30 @@ static void _describe_monster(const monsters *mon); void full_describe_view() { const coord_def start = view2grid(coord_def(1,1)); - const coord_def end(start.x + crawl_view.viewsz.x, - start.y + crawl_view.viewsz.y); + const coord_def end = start + crawl_view.viewsz - coord_def(1,1); std::vector list_mons; std::vector list_items; - coord_def p; - // Iterate over viewport and get all the items in view. // FIXME: This includes unknown stashes. I guess for stashes never // seen before I could simply only add the top item (though I don't // know how to do that) but what about stashes that changed since // you last saw them? Just list the old content? - for (p.x = start.x; p.x < end.x; p.x++) - for (p.y = start.y; p.y < end.y; p.y++) + for (rectangle_iterator ri(start, end); ri; ++ri) + { + if (!in_bounds(*ri) || !see_grid(*ri)) + continue; + + const int oid = igrd(*ri); + + if (oid != NON_ITEM) { - if (!in_bounds(p.x,p.y) || !see_grid(p.x,p.y)) - continue; - - const int oid = igrd(p); - - if (oid != NON_ITEM) - { - std::vector items; - item_list_on_square( items, oid, true ); - list_items.insert(list_items.end(), items.begin(), items.end()); - } + std::vector items; + item_list_on_square( items, oid, true ); + list_items.insert(list_items.end(), items.begin(), items.end()); } + } // Get monsters via the monster_pane_info, sorted by difficulty. std::vector mons; @@ -484,7 +480,7 @@ void full_describe_view() for (unsigned int i = 0; i < mons.size(); i++) list_mons.push_back(mons[i].m_mon); - if (!list_mons.size() && !list_items.size()) + if (list_mons.empty() && list_items.empty()) { mprf("Neither monsters nor items are visible."); return; @@ -551,8 +547,7 @@ void full_describe_view() { if (j == 0) { - str = prefix + str; - me = new MenuEntry(uppercase_first(str), MEL_ITEM, 1, letter); + me = new MenuEntry(prefix + str, MEL_ITEM, 1, letter); me->data = (void*) list_mons[i]; me->tag = "m"; me->quantity = 1; // Hack to make monsters selectable. @@ -583,16 +578,17 @@ void full_describe_view() unsigned short glyph_col; get_item_glyph( list_items[i], &glyph_char, &glyph_col ); - std::string col_string = colour_to_str(glyph_col); - std::string prefix = "(<" + col_string + ">" - + (char)glyph_char - + ") "; + const std::string col_string = colour_to_str(glyph_col); + const std::string prefix = "(<" + col_string + ">" + + static_cast(glyph_char) + + ") "; - std::string str = prefix + list_items[i]->name(DESC_PLAIN); + const std::string str = prefix + + uppercase_first(list_items[i]->name(DESC_PLAIN)); - MenuEntry *me = new MenuEntry(uppercase_first(str), - MEL_ITEM, 1, letter); - me->data = (void*) list_items[i]; + MenuEntry *me = new MenuEntry(str, MEL_ITEM, 1, letter); + me->data = reinterpret_cast( + const_cast(list_items[i])); me->tag = "i"; me->quantity = 2; // Hack to make items selectable. desc_menu.add_entry(me); diff --git a/crawl-ref/source/ouch.cc b/crawl-ref/source/ouch.cc index 6fb5819f63..06e68a04ae 100644 --- a/crawl-ref/source/ouch.cc +++ b/crawl-ref/source/ouch.cc @@ -1094,3 +1094,13 @@ void end_game( scorefile_entry &se ) get_ch(); end(0); } + +int actor_to_death_source(const actor* agent) +{ + if (agent->atype() == ACT_PLAYER) + return (NON_MONSTER); + else if (agent->atype() == ACT_MONSTER) + return (dynamic_cast(agent)->mindex()); + else + return (NON_MONSTER); +} diff --git a/crawl-ref/source/ouch.h b/crawl-ref/source/ouch.h index eef415e6ca..b9f0627aa3 100644 --- a/crawl-ref/source/ouch.h +++ b/crawl-ref/source/ouch.h @@ -56,48 +56,18 @@ enum kill_method_type NUM_KILLBY }; - -// last updated 12may2000 {dlb} -/* *********************************************************************** - * called from: bang - beam - effects - spells - * *********************************************************************** */ int check_your_resists(int hurted, beam_type flavour); - - -// last updated 12may2000 {dlb} -/* *********************************************************************** - * called from: fight - * *********************************************************************** */ void splash_with_acid(char acid_strength); - - -// last updated 12may2000 {dlb} -/* *********************************************************************** - * called from: fight - * *********************************************************************** */ void weapon_acid(char acid_strength); +class actor; +int actor_to_death_source(const actor* agent); -// last updated 12may2000 {dlb} -/* *********************************************************************** - * called from: acr - bang - beam - command - effects - fight - misc - - * ouch - output - religion - spells - spells2 - spells4 - * *********************************************************************** */ void ouch(int dam, int death_source, kill_method_type death_type, const char *aux = NULL, bool see_source = true); -// last updated 12may2000 {dlb} -/* *********************************************************************** - * called from: decks - ouch - * *********************************************************************** */ void lose_level(void); - - -// last updated 12may2000 {dlb} -/* *********************************************************************** - * called from: decks - fight - item_use - ouch - religion - spells - * *********************************************************************** */ void drain_exp(bool announce_full = true); void expose_items_to_element(beam_type flavour, const coord_def& where, -- cgit v1.2.3-54-g00ecf