From 3ee907b3d4405c3d89ec2948dc2b99d798e98b9d Mon Sep 17 00:00:00 2001 From: j-p-e-g Date: Sun, 9 Nov 2008 22:08:22 +0000 Subject: Fix the ASSERT when undetected traps run out of ammo and display "You hear a click" instead of "The trap is out of ammo". Also, fix the miscolouring of the lua eating prompt. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@7428 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/dat/lua/eat.lua | 2 +- crawl-ref/source/itemname.cc | 2 +- crawl-ref/source/message.cc | 2 +- crawl-ref/source/state.cc | 1 - crawl-ref/source/traps.cc | 22 ++++++++++++++-------- 5 files changed, 17 insertions(+), 12 deletions(-) (limited to 'crawl-ref') diff --git a/crawl-ref/source/dat/lua/eat.lua b/crawl-ref/source/dat/lua/eat.lua index 4bd520b9e5..c29f043456 100644 --- a/crawl-ref/source/dat/lua/eat.lua +++ b/crawl-ref/source/dat/lua/eat.lua @@ -12,7 +12,7 @@ function prompt_eat(i) if item.quantity(i) > 1 then iname = "one of " .. iname end - crawl.formatted_mpr("Eat " .. iname .. "?", "prompt") + crawl.mpr("Eat " .. iname .. "?", "prompt") local res res = crawl.getch() diff --git a/crawl-ref/source/itemname.cc b/crawl-ref/source/itemname.cc index 7cb451f0bf..c8dee0bc45 100644 --- a/crawl-ref/source/itemname.cc +++ b/crawl-ref/source/itemname.cc @@ -2705,7 +2705,7 @@ const std::string get_message_colour_tags(item_def &item, // Order is important here. colour_off = ""; colour = "<" + colour + ">"; - item_name = colour + item_name + colour_off; + item_name = colour + item_name + colour_off; } return (item_name); diff --git a/crawl-ref/source/message.cc b/crawl-ref/source/message.cc index 989b9f2140..a685b0116f 100644 --- a/crawl-ref/source/message.cc +++ b/crawl-ref/source/message.cc @@ -1026,7 +1026,7 @@ void replay_messages(void) // Allow formatted output of tagged messages. formatted_string fs = formatted_string::parse_string(text, true); int curcol = 1; - for ( unsigned int j = 0; j < fs.ops.size(); ++j ) + for (unsigned int j = 0; j < fs.ops.size(); ++j) { switch ( fs.ops[j].type ) { diff --git a/crawl-ref/source/state.cc b/crawl-ref/source/state.cc index b1997ef4ba..91845abd51 100644 --- a/crawl-ref/source/state.cc +++ b/crawl-ref/source/state.cc @@ -142,7 +142,6 @@ void game_state::zero_turns_taken() bool interrupt_cmd_repeat( activity_interrupt_type ai, const activity_interrupt_data &at ) { - mpr("in interrupt_cmd_repeat"); if (crawl_state.cmd_repeat_start) return (false); diff --git a/crawl-ref/source/traps.cc b/crawl-ref/source/traps.cc index 826448d22f..c30381da63 100644 --- a/crawl-ref/source/traps.cc +++ b/crawl-ref/source/traps.cc @@ -48,16 +48,15 @@ bool trap_def::active() const bool trap_def::type_has_ammo() const { - bool rc = false; switch (this->type) { case TRAP_DART: case TRAP_ARROW: case TRAP_BOLT: case TRAP_NEEDLE: case TRAP_SPEAR: case TRAP_AXE: - rc = true; + return (true); default: break; } - return rc; + return (false); } void trap_def::message_trap_entry() @@ -79,6 +78,9 @@ void trap_def::disarm() void trap_def::destroy() { + if (!in_bounds(this->pos)) + ASSERT("trap position out of bounds!"); + grd(this->pos) = DNGN_FLOOR; this->ammo_qty = 0; this->pos = coord_def(-1,-1); @@ -376,6 +378,9 @@ void trap_def::trigger(actor& triggerer, bool flat_footed) if (you_trigger) this->message_trap_entry(); + // Store the position now in case it gets cleared inbetween. + const coord_def p(this->pos); + if (this->type_has_ammo()) this->shoot_ammo(triggerer, trig_knows); else switch (this->type) @@ -570,7 +575,7 @@ void trap_def::trigger(actor& triggerer, bool flat_footed) if (you_trigger) { mpr((trig_knows) ? "You enter the Zot trap." - : "Oh no! You have blundered into a Zot trap!"); + : "Oh no! You have blundered into a Zot trap!"); MiscastEffect( &you, ZOT_TRAP_MISCAST, SPTYP_RANDOM, 3, "a Zot trap" ); } @@ -648,10 +653,11 @@ void trap_def::trigger(actor& triggerer, bool flat_footed) if (you_trigger) { - learned_something_new(TUT_SEEN_TRAP, this->pos); + learned_something_new(TUT_SEEN_TRAP, p); - // Exercise T&D if the trap revealed itself. - if (!you_know && this->is_known()) + // Exercise T&D if the trap revealed itself, but not if it ran + // out of ammo. + if (!you_know && this->type != TRAP_UNASSIGNED && this->is_known()) exercise(SK_TRAPS_DOORS, ((coinflip()) ? 2 : 1)); } @@ -1095,7 +1101,7 @@ void trap_def::shoot_ammo(actor& act, bool was_known) { if (this->ammo_qty <= 0) { - if (act.atype() == ACT_PLAYER) + if (was_known && act.atype() == ACT_PLAYER) mpr("The trap is out of ammunition!"); else if (player_can_hear(this->pos) && see_grid(this->pos)) mpr("You hear a soft click."); -- cgit v1.2.3-54-g00ecf