summaryrefslogtreecommitdiffstats
path: root/crawl-ref
diff options
context:
space:
mode:
authorharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2008-10-11 15:50:46 +0000
committerharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2008-10-11 15:50:46 +0000
commit6f8e75f0aaf3f8f4c038bc4765a60dcf48fe57ca (patch)
tree4bc32a2e87d8f7d7648a1059710a3cff82d1e4fe /crawl-ref
parent670cdde1fae7896c45aeaed440dcfd2d19470f3e (diff)
downloadcrawl-ref-6f8e75f0aaf3f8f4c038bc4765a60dcf48fe57ca.tar.gz
crawl-ref-6f8e75f0aaf3f8f4c038bc4765a60dcf48fe57ca.zip
Fix 2041934: auto-swapping rings and amulets was taking twice as long
as manually swapping (two double-speed turns plus one bogus normal-speed turn.) This also applied to weapon swapping after butchery. This fix is rather hackish, better solutions appreciated. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@7213 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref')
-rw-r--r--crawl-ref/source/acr.cc3
-rw-r--r--crawl-ref/source/beam.cc2
-rw-r--r--crawl-ref/source/delay.cc38
-rw-r--r--crawl-ref/source/fight.cc8
-rw-r--r--crawl-ref/source/food.cc18
-rw-r--r--crawl-ref/source/item_use.cc3
6 files changed, 38 insertions, 34 deletions
diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc
index 0d8d9afdee..3ffbe4947f 100644
--- a/crawl-ref/source/acr.cc
+++ b/crawl-ref/source/acr.cc
@@ -1492,7 +1492,8 @@ static void _input()
if (you_are_delayed())
{
- _world_reacts();
+ if (you.time_taken)
+ _world_reacts();
return;
}
diff --git a/crawl-ref/source/beam.cc b/crawl-ref/source/beam.cc
index 7c378bc163..2b562da889 100644
--- a/crawl-ref/source/beam.cc
+++ b/crawl-ref/source/beam.cc
@@ -3465,7 +3465,7 @@ static int _affect_player( bolt &beam, item_def *item )
else if (_beam_is_blockable(beam))
{
// Non-beams can be blocked or dodged.
- if (you.equip[EQ_SHIELD] != -1
+ if (you.shield()
&& !beam.aimed_at_feet
&& player_shield_class() > 0)
{
diff --git a/crawl-ref/source/delay.cc b/crawl-ref/source/delay.cc
index 45ec98497d..10148064e7 100644
--- a/crawl-ref/source/delay.cc
+++ b/crawl-ref/source/delay.cc
@@ -873,6 +873,15 @@ void handle_delay( void )
mprf(MSGCH_MULTITURN_ACTION, "You continue bottling blood from "
"the corpse.");
break;
+
+ case DELAY_JEWELLERY_ON:
+ case DELAY_WEAPON_SWAP:
+ // These are 1-turn delays where the time cost is handled
+ // in _finish_delay().
+ // FIXME: get rid of this hack!
+ you.time_taken = 0;
+ break;
+
case DELAY_MEMORISE:
mpr("You continue memorising.", MSGCH_MULTITURN_ACTION);
break;
@@ -926,15 +935,15 @@ static void _finish_delay(const delay_queue_item &delay)
switch (delay.type)
{
case DELAY_WEAPON_SWAP:
- weapon_switch( delay.parm1 );
+ weapon_switch(delay.parm1);
break;
case DELAY_JEWELLERY_ON:
- puton_ring( delay.parm1, false );
+ puton_ring(delay.parm1, false);
break;
case DELAY_ARMOUR_ON:
- _armour_wear_effects( delay.parm1 );
+ _armour_wear_effects(delay.parm1);
break;
case DELAY_ARMOUR_OFF:
@@ -942,8 +951,7 @@ static void _finish_delay(const delay_queue_item &delay)
mprf("You finish taking off %s.",
you.inv[delay.parm1].name(DESC_NOCAP_YOUR).c_str());
- const equipment_type slot =
- get_armour_slot( you.inv[delay.parm1] );
+ const equipment_type slot = get_armour_slot(you.inv[delay.parm1]);
if (slot == EQ_BODY_ARMOUR)
{
@@ -954,28 +962,12 @@ static void _finish_delay(const delay_queue_item &delay)
switch (slot)
{
case EQ_SHIELD:
- if (delay.parm1 == you.equip[EQ_SHIELD])
- you.equip[EQ_SHIELD] = -1;
- break;
-
case EQ_CLOAK:
- if (delay.parm1 == you.equip[EQ_CLOAK])
- you.equip[EQ_CLOAK] = -1;
- break;
-
case EQ_HELMET:
- if (delay.parm1 == you.equip[EQ_HELMET])
- you.equip[EQ_HELMET] = -1;
- break;
-
case EQ_GLOVES:
- if (delay.parm1 == you.equip[EQ_GLOVES])
- you.equip[EQ_GLOVES] = -1;
- break;
-
case EQ_BOOTS:
- if (delay.parm1 == you.equip[EQ_BOOTS])
- you.equip[EQ_BOOTS] = -1;
+ if (delay.parm1 == you.equip[slot])
+ you.equip[slot] = -1;
break;
default:
diff --git a/crawl-ref/source/fight.cc b/crawl-ref/source/fight.cc
index 6518045d02..314b1bad7f 100644
--- a/crawl-ref/source/fight.cc
+++ b/crawl-ref/source/fight.cc
@@ -57,11 +57,9 @@
#include "view.h"
#include "xom.h"
-#define HIT_WEAK 7
-#define HIT_MED 18
-#define HIT_STRONG 36
-// ... was 5, 12, 21
-// how these are used will be replaced by a function in a second ... :P {dlb}
+const int HIT_WEAK = 7;
+const int HIT_MED = 18;
+const int HIT_STRONG = 36;
static void stab_message(monsters *defender, int stab_bonus);
diff --git a/crawl-ref/source/food.cc b/crawl-ref/source/food.cc
index e42bb09e33..0bb334ea60 100644
--- a/crawl-ref/source/food.cc
+++ b/crawl-ref/source/food.cc
@@ -131,7 +131,7 @@ void weapon_switch( int targ )
if (targ == -1) // Unarmed Combat.
{
// Already unarmed?
- if (you.equip[EQ_WEAPON] == -1)
+ if (!you.weapon())
return;
mpr( "You switch back to your bare hands." );
@@ -156,7 +156,7 @@ void weapon_switch( int targ )
// Well yeah, but that's because interacting with the wielding
// code is a mess... this whole function's purpose was to
// isolate this hack until there's a proper way to do things. -- bwr
- if (you.equip[EQ_WEAPON] != -1)
+ if (you.weapon())
unwield_item(false);
you.equip[EQ_WEAPON] = targ;
@@ -168,13 +168,25 @@ void weapon_switch( int targ )
if (Options.chunks_autopickup || you.species == SP_VAMPIRE)
autopickup();
+ // Same amount of time as normal wielding.
+ // FIXME: this duplicated code is begging for a bug.
+ if (you.weapon())
+ {
+ you.time_taken /= 2;
+ }
+ else // swapping to empty hands is faster
+ {
+ you.time_taken *= 3;
+ you.time_taken /= 10;
+ }
+
you.turn_is_over = true;
}
// Look for a butchering implement. If fallback is true,
// prompt the user if no obvious options exist.
// Returns whether a weapon was switched.
-static int _find_butchering_implement(int &butcher_tool)
+static bool _find_butchering_implement(int &butcher_tool)
{
// When berserk, you can't change weapons. Sanity check!
if (!can_wield(NULL, true))
diff --git a/crawl-ref/source/item_use.cc b/crawl-ref/source/item_use.cc
index 7ed6249e18..8d64311eb0 100644
--- a/crawl-ref/source/item_use.cc
+++ b/crawl-ref/source/item_use.cc
@@ -309,6 +309,7 @@ bool wield_weapon(bool auto_wield, int slot, bool show_weff_messages)
canned_msg(MSG_EMPTY_HANDED);
+ // Switching to bare hands is extra fast.
you.turn_is_over = true;
you.time_taken *= 3;
you.time_taken /= 10;
@@ -3158,7 +3159,7 @@ bool puton_item(int item_slot, bool prompt_finger)
jewellery_wear_effects( you.inv[item_slot] );
// Putting on jewellery is as fast as wielding weapons.
- you.time_taken = you.time_taken * 5 / 10;
+ you.time_taken /= 2;
you.turn_is_over = true;
return (true);