OSDN Git Service
(root)
/
hengbandforosx
/
hengbandosx.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
b6f6b2d
)
[Refactor] inven_item_increase
author
Habu
<habu1010+github@gmail.com>
Fri, 21 Jun 2024 14:16:10 +0000
(23:16 +0900)
committer
Habu
<habu1010+github@gmail.com>
Fri, 21 Jun 2024 14:16:10 +0000
(23:16 +0900)
反対の手を算出するためにenumの足し算をするという小賢しいテクニックが
使用されており、可読性が低下しているので意図をそのまま表したコードに
修正する。
src/inventory/inventory-object.cpp
patch
|
blob
|
history
diff --git
a/src/inventory/inventory-object.cpp
b/src/inventory/inventory-object.cpp
index
0b70cca
..
ef67806
100644
(file)
--- a/
src/inventory/inventory-object.cpp
+++ b/
src/inventory/inventory-object.cpp
@@
-73,7
+73,8
@@
void inven_item_increase(PlayerType *player_ptr, INVENTORY_IDX i_idx, ITEM_NUMBE
return;
}
- if (has_melee_weapon(player_ptr, enum2i(INVEN_MAIN_HAND + INVEN_SUB_HAND) - i_idx)) {
+ const auto opposite_hand = (i_idx == INVEN_MAIN_HAND) ? INVEN_SUB_HAND : INVEN_MAIN_HAND;
+ if (has_melee_weapon(player_ptr, enum2i(opposite_hand))) {
return;
}