Attached Files |
ring-swap.patch [^] (4,079 bytes) 2014-02-21 05:26 [Show Content] [Hide Content]From 7ff552e0c214e2147ca7c2c440611d56601ea62a Mon Sep 17 00:00:00 2001
From: Sage <SageBasilMint@gmail.com>
Date: Thu, 20 Feb 2014 19:40:45 -0800
Subject: [PATCH] When swapping rings, automatically remove the one that
doesn't match.
Example: If you're wearing rF+ and MR, and you're swapping to rF+,
MR is automatically removed. Similar to automatically removing a ring
when swapping if both rings you are wearing are identical.
---
crawl-ref/source/item_use.cc | 46 ++++++++++++++++++++++++++++++++----------
1 file changed, 35 insertions(+), 11 deletions(-)
diff --git a/crawl-ref/source/item_use.cc b/crawl-ref/source/item_use.cc
index 749c019..e86bae9 100644
--- a/crawl-ref/source/item_use.cc
+++ b/crawl-ref/source/item_use.cc
@@ -76,6 +76,7 @@ static bool _safe_to_remove_or_wear(const item_def &item, bool remove,
bool quiet = false);
static bool _two_targeted_scrolls_identified();
static bool _one_targeted_scroll_tried();
+static bool _rings_match(item_def* ring1, item_def* ring2);
// Rather messy - we've gathered all the can't-wield logic from wield_weapon()
// here.
@@ -1220,6 +1221,16 @@ bool safe_to_remove(const item_def &item, bool quiet)
return true;
}
+static bool _rings_match(item_def *ring1, item_def *ring2)
+{
+ ASSERT(ring1->base_type == OBJ_JEWELLERY && ring2->base_type == OBJ_JEWELLERY);
+
+ return !(ring1->sub_type != ring2->sub_type
+ || ring1->plus != ring2->plus
+ || ring1->plus2 != ring2->plus2
+ || is_artefact(*ring1) || is_artefact(*ring2));
+}
+
// Assumptions:
// you.inv[ring_slot] is a valid ring.
// EQ_LEFT_RING and EQ_RIGHT_RING are both occupied, and ring_slot is not
@@ -1235,7 +1246,9 @@ static bool _swap_rings(int ring_slot)
int melded = 0; // Both melded rings and unavailable slots.
int available = 0;
bool all_same = true;
+ bool swap_and_worn_match = false;
item_def* first_ring = NULL;
+ item_def* swap_ring = &you.inv[ring_slot];
for (vector<equipment_type>::iterator eq_it = ring_types.begin();
eq_it != ring_types.end();
++eq_it)
@@ -1246,24 +1259,34 @@ static bool _swap_rings(int ring_slot)
else if (ring != NULL)
{
if (first_ring == NULL)
+ {
first_ring = ring;
- else if (all_same)
+ //If neither worn ring matches swap_ring,
+ //Unwanted is reassigned later.
+ if (!_rings_match(first_ring, swap_ring))
+ unwanted = you.equip[*eq_it];
+ else
+ swap_and_worn_match = true;
+ }
+ else
{
- if (ring->sub_type != first_ring->sub_type
- || ring->plus != first_ring->plus
- || ring->plus2 != first_ring->plus2
- || is_artefact(*ring))
- {
- all_same = false;
- }
+ if (all_same)
+ all_same = _rings_match(ring, first_ring);
+
+ if (!_rings_match(ring, swap_ring))
+ unwanted = you.equip[*eq_it];
+ else
+ swap_and_worn_match = true;
}
+
if (ring->cursed())
cursed++;
else
{
available++;
- unwanted = you.equip[*eq_it];
+ if (!swap_and_worn_match)
+ unwanted = you.equip[*eq_it];
}
}
}
@@ -1293,8 +1316,9 @@ static bool _swap_rings(int ring_slot)
// multiple available rings.
else if (available > 1)
{
- // Don't prompt if all the rings are the same
- if (!all_same)
+ // Don't prompt if all the rings are the same, or if a ring
+ // you're wearing and the ring you're swapping to match
+ if (!all_same && !swap_and_worn_match)
unwanted = _prompt_ring_to_remove(ring_slot);
// Cancelled:
--
1.7.9.5
ring-swap-update.patch [^] (4,212 bytes) 2014-02-21 12:29 [Show Content] [Hide Content]From 2c19ad185b29f601e51ab33cc4b33cd32794d17a Mon Sep 17 00:00:00 2001
From: Sage <SageBasilMint@gmail.com>
Date: Fri, 21 Feb 2014 00:36:57 -0800
Subject: [PATCH] Better ring swapping.
When putting on a ring and you are already wearing as many rings as you
can, if the ring you are putting on matches a ring you are already
wearing, a ring that doesn't match is removed without prompting.
---
crawl-ref/source/item_use.cc | 48 ++++++++++++++++++++++++++++++++----------
1 file changed, 37 insertions(+), 11 deletions(-)
diff --git a/crawl-ref/source/item_use.cc b/crawl-ref/source/item_use.cc
index 749c019..d278237 100644
--- a/crawl-ref/source/item_use.cc
+++ b/crawl-ref/source/item_use.cc
@@ -76,6 +76,7 @@ static bool _safe_to_remove_or_wear(const item_def &item, bool remove,
bool quiet = false);
static bool _two_targeted_scrolls_identified();
static bool _one_targeted_scroll_tried();
+static bool _rings_match(item_def* ring1, item_def* ring2);
// Rather messy - we've gathered all the can't-wield logic from wield_weapon()
// here.
@@ -1220,6 +1221,16 @@ bool safe_to_remove(const item_def &item, bool quiet)
return true;
}
+static bool _rings_match(item_def *ring1, item_def *ring2)
+{
+ ASSERT(ring1->base_type == OBJ_JEWELLERY && ring2->base_type == OBJ_JEWELLERY);
+
+ return !(ring1->sub_type != ring2->sub_type
+ || ring1->plus != ring2->plus
+ || ring1->plus2 != ring2->plus2
+ || is_artefact(*ring1) || is_artefact(*ring2));
+}
+
// Assumptions:
// you.inv[ring_slot] is a valid ring.
// EQ_LEFT_RING and EQ_RIGHT_RING are both occupied, and ring_slot is not
@@ -1235,7 +1246,9 @@ static bool _swap_rings(int ring_slot)
int melded = 0; // Both melded rings and unavailable slots.
int available = 0;
bool all_same = true;
+ bool swap_and_worn_match = false;
item_def* first_ring = NULL;
+ item_def* swap_ring = &you.inv[ring_slot];
for (vector<equipment_type>::iterator eq_it = ring_types.begin();
eq_it != ring_types.end();
++eq_it)
@@ -1246,28 +1259,40 @@ static bool _swap_rings(int ring_slot)
else if (ring != NULL)
{
if (first_ring == NULL)
+ {
first_ring = ring;
- else if (all_same)
+ //If neither worn ring matches swap_ring,
+ //Unwanted is reassigned later.
+ if (!_rings_match(first_ring, swap_ring))
+ unwanted = you.equip[*eq_it];
+ else
+ swap_and_worn_match = true;
+ }
+ else
{
- if (ring->sub_type != first_ring->sub_type
- || ring->plus != first_ring->plus
- || ring->plus2 != first_ring->plus2
- || is_artefact(*ring))
- {
- all_same = false;
- }
+ if (all_same)
+ all_same = _rings_match(ring, first_ring);
+
+ if (!_rings_match(ring, swap_ring))
+ unwanted = you.equip[*eq_it];
+ else
+ swap_and_worn_match = true;
}
+
if (ring->cursed())
cursed++;
else
{
available++;
- unwanted = you.equip[*eq_it];
+ if (!swap_and_worn_match)
+ unwanted = you.equip[*eq_it];
}
}
}
+ if (all_same)
+ unwanted = you.equip[EQ_LEFT_RING];
// We can't put a ring on, because we're wearing all cursed ones.
if (melded == num_rings)
{
@@ -1293,8 +1318,9 @@ static bool _swap_rings(int ring_slot)
// multiple available rings.
else if (available > 1)
{
- // Don't prompt if all the rings are the same
- if (!all_same)
+ // Don't prompt if all the rings are the same, or if a ring
+ // you're wearing and the ring you're swapping to match
+ if (!all_same && !swap_and_worn_match)
unwanted = _prompt_ring_to_remove(ring_slot);
// Cancelled:
--
1.7.9.5
ring-swap-initfile-update.patch [^] (5,963 bytes) 2014-02-21 13:21 [Show Content] [Hide Content]From 6c8fde09c9f6277236bb1151cc9b6c8f556784ae Mon Sep 17 00:00:00 2001
From: Sage <SageBasilMint@gmail.com>
Date: Fri, 21 Feb 2014 00:36:57 -0800
Subject: [PATCH] Better ring swapping.
When putting on a ring and you are already wearing as many rings as you
can, if the ring you are putting on matches a ring you are already
wearing, a ring that doesn't match is removed without prompting.
Additionally, there is now a new initfile option, bool fast_ring_swap,
which defaults to false. True makes it so that the above feature
functions, as well as the auto-swap when you are wearing two identical
rings; false disables both features.
---
crawl-ref/source/initfile.cc | 2 ++
crawl-ref/source/item_use.cc | 48 ++++++++++++++++++++++++++++++++----------
crawl-ref/source/options.h | 5 +++++
3 files changed, 44 insertions(+), 11 deletions(-)
diff --git a/crawl-ref/source/initfile.cc b/crawl-ref/source/initfile.cc
index 9e685a5..ef0e412 100644
--- a/crawl-ref/source/initfile.cc
+++ b/crawl-ref/source/initfile.cc
@@ -881,6 +881,7 @@ void game_options::reset_options()
#endif
use_fake_player_cursor = true;
show_player_species = false;
+ fast_ring_swap = false;
explore_stop = (ES_ITEM | ES_STAIR | ES_PORTAL | ES_BRANCH
| ES_SHOP | ES_ALTAR | ES_RUNED_DOOR
@@ -3123,6 +3124,7 @@ void game_options::read_option_line(const string &str, bool runscript)
else BOOL_OPTION(use_fake_cursor);
else BOOL_OPTION(use_fake_player_cursor);
else BOOL_OPTION(show_player_species);
+ else BOOL_OPTION(fast_ring_swap);
else if (key == "force_more_message")
{
if (plain)
diff --git a/crawl-ref/source/item_use.cc b/crawl-ref/source/item_use.cc
index 749c019..7f8bad9 100644
--- a/crawl-ref/source/item_use.cc
+++ b/crawl-ref/source/item_use.cc
@@ -76,6 +76,7 @@ static bool _safe_to_remove_or_wear(const item_def &item, bool remove,
bool quiet = false);
static bool _two_targeted_scrolls_identified();
static bool _one_targeted_scroll_tried();
+static bool _rings_match(item_def* ring1, item_def* ring2);
// Rather messy - we've gathered all the can't-wield logic from wield_weapon()
// here.
@@ -1220,6 +1221,16 @@ bool safe_to_remove(const item_def &item, bool quiet)
return true;
}
+static bool _rings_match(item_def *ring1, item_def *ring2)
+{
+ ASSERT(ring1->base_type == OBJ_JEWELLERY && ring2->base_type == OBJ_JEWELLERY);
+
+ return !(ring1->sub_type != ring2->sub_type
+ || ring1->plus != ring2->plus
+ || ring1->plus2 != ring2->plus2
+ || is_artefact(*ring1) || is_artefact(*ring2));
+}
+
// Assumptions:
// you.inv[ring_slot] is a valid ring.
// EQ_LEFT_RING and EQ_RIGHT_RING are both occupied, and ring_slot is not
@@ -1235,7 +1246,9 @@ static bool _swap_rings(int ring_slot)
int melded = 0; // Both melded rings and unavailable slots.
int available = 0;
bool all_same = true;
+ bool swap_and_worn_match = false;
item_def* first_ring = NULL;
+ item_def* swap_ring = &you.inv[ring_slot];
for (vector<equipment_type>::iterator eq_it = ring_types.begin();
eq_it != ring_types.end();
++eq_it)
@@ -1246,28 +1259,40 @@ static bool _swap_rings(int ring_slot)
else if (ring != NULL)
{
if (first_ring == NULL)
+ {
first_ring = ring;
- else if (all_same)
+ //If neither worn ring matches swap_ring,
+ //Unwanted is reassigned later.
+ if (!_rings_match(first_ring, swap_ring))
+ unwanted = you.equip[*eq_it];
+ else
+ swap_and_worn_match = true;
+ }
+ else
{
- if (ring->sub_type != first_ring->sub_type
- || ring->plus != first_ring->plus
- || ring->plus2 != first_ring->plus2
- || is_artefact(*ring))
- {
- all_same = false;
- }
+ if (all_same)
+ all_same = _rings_match(ring, first_ring);
+
+ if (!_rings_match(ring, swap_ring))
+ unwanted = you.equip[*eq_it];
+ else
+ swap_and_worn_match = true;
}
+
if (ring->cursed())
cursed++;
else
{
available++;
- unwanted = you.equip[*eq_it];
+ if (!swap_and_worn_match)
+ unwanted = you.equip[*eq_it];
}
}
}
+ if (all_same)
+ unwanted = you.equip[EQ_LEFT_RING];
// We can't put a ring on, because we're wearing all cursed ones.
if (melded == num_rings)
{
@@ -1293,8 +1318,9 @@ static bool _swap_rings(int ring_slot)
// multiple available rings.
else if (available > 1)
{
- // Don't prompt if all the rings are the same
- if (!all_same)
+ // Don't prompt if all the rings are the same, or if a ring
+ // you're wearing and the ring you're swapping to match
+ if (!Options.fast_ring_swap || !all_same && !swap_and_worn_match)
unwanted = _prompt_ring_to_remove(ring_slot);
// Cancelled:
diff --git a/crawl-ref/source/options.h b/crawl-ref/source/options.h
index af827ae..7a6b26f 100644
--- a/crawl-ref/source/options.h
+++ b/crawl-ref/source/options.h
@@ -364,6 +364,11 @@ public:
bool show_player_species;
+ // If you are wearing two identical rings, or you are
+ // wearing a ring identical to the one you're swapping
+ // to, the correct ring is removed without prompting.
+ bool fast_ring_swap;
+
int level_map_cursor_step; // The cursor increment in the level
// map.
--
1.7.9.5
|