Skip to content

Commit

Permalink
Merge branch 'develop' into macos-develop
Browse files Browse the repository at this point in the history
  • Loading branch information
backwardsEric committed Nov 9, 2024
2 parents 90d866b + efc136b commit f2fa637
Show file tree
Hide file tree
Showing 33 changed files with 347 additions and 379 deletions.
2 changes: 1 addition & 1 deletion src/autopick/autopick-destroyer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ static bool is_opt_confirm_destroy(PlayerType *player_ptr, ItemEntity *o_ptr)
}

if (leave_worth) {
if (o_ptr->get_price() > 0) {
if (o_ptr->calc_price() > 0) {
return false;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/autopick/autopick-matcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ bool is_autopick_match(PlayerType *player_ptr, const ItemEntity *o_ptr, const au
}
}

if (entry.has(FLG_WORTHLESS) && (o_ptr->get_price() > 0)) {
if (entry.has(FLG_WORTHLESS) && (o_ptr->calc_price() > 0)) {
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/cmd-item/cmd-destroy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ using SelectionResult = std::tuple<ItemEntity *, short, int>;

static bool check_destory_item(PlayerType *player_ptr, const ItemEntity &destroying_item, short i_idx)
{
if (!confirm_destroy && (destroying_item.get_price() <= 0)) {
if (!confirm_destroy && (destroying_item.calc_price() <= 0)) {
return true;
}

Expand Down
14 changes: 7 additions & 7 deletions src/cmd-item/cmd-equipment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
/*!
* @brief 装備時にアイテムを呪う処理
*/
static void do_curse_on_equip(OBJECT_IDX slot, ItemEntity *o_ptr, PlayerType *player_ptr)
static void do_curse_on_equip(OBJECT_IDX slot, ItemEntity &item, PlayerType *player_ptr)
{
auto &rfu = RedrawingFlagsUpdater::get_instance();
if (set_anubis_and_chariot(player_ptr) && ((slot == INVEN_MAIN_HAND) || (slot == INVEN_SUB_HAND))) {
Expand All @@ -75,16 +75,16 @@ static void do_curse_on_equip(OBJECT_IDX slot, ItemEntity *o_ptr, PlayerType *pl
return;
}

auto should_curse = o_ptr->get_flags().has(TR_PERSISTENT_CURSE) || o_ptr->curse_flags.has(CurseTraitType::PERSISTENT_CURSE);
should_curse &= o_ptr->curse_flags.has_not(CurseTraitType::HEAVY_CURSE);
auto should_curse = item.get_flags().has(TR_PERSISTENT_CURSE) || item.curse_flags.has(CurseTraitType::PERSISTENT_CURSE);
should_curse &= item.curse_flags.has_not(CurseTraitType::HEAVY_CURSE);
if (!should_curse) {
return;
}

const auto item_name = describe_flavor(player_ptr, *o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
o_ptr->curse_flags.set(CurseTraitType::HEAVY_CURSE);
const auto item_name = describe_flavor(player_ptr, item, (OD_OMIT_PREFIX | OD_NAME_ONLY));
item.curse_flags.set(CurseTraitType::HEAVY_CURSE);
msg_format(_("悪意に満ちた黒いオーラが%sをとりまいた...", "There is a malignant black aura surrounding your %s..."), item_name.data());
o_ptr->feeling = FEEL_NONE;
item.feeling = FEEL_NONE;
rfu.set_flag(StatusRecalculatingFlag::BONUS);
}

Expand Down Expand Up @@ -336,7 +336,7 @@ void do_cmd_wield(PlayerType *player_ptr)
o_ptr->ident |= (IDENT_SENSE);
}

do_curse_on_equip(slot, o_ptr, player_ptr);
do_curse_on_equip(slot, *o_ptr, player_ptr);
if (o_ptr->is_specific_artifact(FixedArtifactId::STONEMASK)) {
auto is_specific_race = pr.equals(PlayerRaceType::VAMPIRE);
is_specific_race |= pr.equals(PlayerRaceType::ANDROID);
Expand Down
66 changes: 33 additions & 33 deletions src/effect/effect-item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,20 +56,20 @@ bool affect_item(PlayerType *player_ptr, MONSTER_IDX src_idx, POSITION r, POSITI

processed_list.insert(this_o_idx);

auto *o_ptr = &player_ptr->current_floor_ptr->o_list[this_o_idx];
bool ignore = false;
bool do_kill = false;
auto &item = player_ptr->current_floor_ptr->o_list[this_o_idx];
auto ignore = false;
auto do_kill = false;
concptr note_kill = nullptr;

#ifdef JP
#else
bool plural = (o_ptr->number > 1);
bool plural = (item.number > 1);
#endif
const auto flags = o_ptr->get_flags();
bool is_fixed_or_random_artifact = o_ptr->is_fixed_or_random_artifact();
const auto flags = item.get_flags();
bool is_fixed_or_random_artifact = item.is_fixed_or_random_artifact();
switch (typ) {
case AttributeType::ACID: {
if (BreakerAcid().hates(o_ptr)) {
if (BreakerAcid().hates(&item)) {
do_kill = true;
note_kill = _("融けてしまった!", (plural ? " melt!" : " melts!"));
if (flags.has(TR_IGNORE_ACID)) {
Expand All @@ -80,7 +80,7 @@ bool affect_item(PlayerType *player_ptr, MONSTER_IDX src_idx, POSITION r, POSITI
break;
}
case AttributeType::ELEC: {
if (BreakerElec().hates(o_ptr)) {
if (BreakerElec().hates(&item)) {
do_kill = true;
note_kill = _("壊れてしまった!", (plural ? " are destroyed!" : " is destroyed!"));
if (flags.has(TR_IGNORE_ELEC)) {
Expand All @@ -91,7 +91,7 @@ bool affect_item(PlayerType *player_ptr, MONSTER_IDX src_idx, POSITION r, POSITI
break;
}
case AttributeType::FIRE: {
if (BreakerFire().hates(o_ptr)) {
if (BreakerFire().hates(&item)) {
do_kill = true;
note_kill = _("燃えてしまった!", (plural ? " burn up!" : " burns up!"));
if (flags.has(TR_IGNORE_FIRE)) {
Expand All @@ -102,7 +102,7 @@ bool affect_item(PlayerType *player_ptr, MONSTER_IDX src_idx, POSITION r, POSITI
break;
}
case AttributeType::COLD: {
if (BreakerCold().hates(o_ptr)) {
if (BreakerCold().hates(&item)) {
note_kill = _("砕け散ってしまった!", (plural ? " shatter!" : " shatters!"));
do_kill = true;
if (flags.has(TR_IGNORE_COLD)) {
Expand All @@ -113,15 +113,15 @@ bool affect_item(PlayerType *player_ptr, MONSTER_IDX src_idx, POSITION r, POSITI
break;
}
case AttributeType::PLASMA: {
if (BreakerFire().hates(o_ptr)) {
if (BreakerFire().hates(&item)) {
do_kill = true;
note_kill = _("燃えてしまった!", (plural ? " burn up!" : " burns up!"));
if (flags.has(TR_IGNORE_FIRE)) {
ignore = true;
}
}

if (BreakerElec().hates(o_ptr)) {
if (BreakerElec().hates(&item)) {
ignore = false;
do_kill = true;
note_kill = _("壊れてしまった!", (plural ? " are destroyed!" : " is destroyed!"));
Expand All @@ -133,15 +133,15 @@ bool affect_item(PlayerType *player_ptr, MONSTER_IDX src_idx, POSITION r, POSITI
break;
}
case AttributeType::METEOR: {
if (BreakerFire().hates(o_ptr)) {
if (BreakerFire().hates(&item)) {
do_kill = true;
note_kill = _("燃えてしまった!", (plural ? " burn up!" : " burns up!"));
if (flags.has(TR_IGNORE_FIRE)) {
ignore = true;
}
}

if (BreakerCold().hates(o_ptr)) {
if (BreakerCold().hates(&item)) {
ignore = false;
do_kill = true;
note_kill = _("砕け散ってしまった!", (plural ? " shatter!" : " shatters!"));
Expand All @@ -156,7 +156,7 @@ bool affect_item(PlayerType *player_ptr, MONSTER_IDX src_idx, POSITION r, POSITI
case AttributeType::SHARDS:
case AttributeType::FORCE:
case AttributeType::SOUND: {
if (BreakerCold().hates(o_ptr)) {
if (BreakerCold().hates(&item)) {
note_kill = _("砕け散ってしまった!", (plural ? " shatter!" : " shatters!"));
do_kill = true;
}
Expand All @@ -180,14 +180,14 @@ bool affect_item(PlayerType *player_ptr, MONSTER_IDX src_idx, POSITION r, POSITI
note_kill = _("壊れてしまった!", (plural ? " are destroyed!" : " is destroyed!"));
if (flags.has(TR_RES_CHAOS)) {
ignore = true;
} else if (o_ptr->bi_key == BaseitemKey(ItemKindType::SCROLL, SV_SCROLL_CHAOS)) {
} else if (item.bi_key == BaseitemKey(ItemKindType::SCROLL, SV_SCROLL_CHAOS)) {
ignore = true;
}
break;
}
case AttributeType::HOLY_FIRE:
case AttributeType::HELL_FIRE: {
if (o_ptr->is_cursed()) {
if (item.is_cursed()) {
do_kill = true;
note_kill = _("壊れてしまった!", (plural ? " are destroyed!" : " is destroyed!"));
}
Expand All @@ -200,31 +200,31 @@ bool affect_item(PlayerType *player_ptr, MONSTER_IDX src_idx, POSITION r, POSITI
break;
}
case AttributeType::IDENTIFY: {
identify_item(player_ptr, o_ptr);
identify_item(player_ptr, &item);
autopick_alter_item(player_ptr, (-this_o_idx), false);
break;
}
case AttributeType::KILL_TRAP:
case AttributeType::KILL_DOOR: {
if (o_ptr->bi_key.tval() != ItemKindType::CHEST) {
if (item.bi_key.tval() != ItemKindType::CHEST) {
break;
}

if (o_ptr->pval <= 0) {
if (item.pval <= 0) {
break;
}

o_ptr->pval = (0 - o_ptr->pval);
o_ptr->mark_as_known();
if (known && o_ptr->marked.has(OmType::FOUND)) {
item.pval = (0 - item.pval);
item.mark_as_known();
if (known && item.marked.has(OmType::FOUND)) {
msg_print(_("カチッと音がした!", "Click!"));
is_item_affected = true;
}

break;
}
case AttributeType::ANIM_DEAD: {
if (o_ptr->bi_key.tval() != ItemKindType::MONSTER_REMAINS) {
if (item.bi_key.tval() != ItemKindType::MONSTER_REMAINS) {
break;
}

Expand All @@ -233,9 +233,9 @@ bool affect_item(PlayerType *player_ptr, MONSTER_IDX src_idx, POSITION r, POSITI
mode |= PM_FORCE_PET;
}

for (int i = 0; i < o_ptr->number; i++) {
const auto &monrace = o_ptr->get_monrace();
const auto sval = *o_ptr->bi_key.sval();
for (int i = 0; i < item.number; i++) {
const auto &monrace = item.get_monrace();
const auto sval = *item.bi_key.sval();
if (((sval == SV_CORPSE) && (randint1(100) > 80)) || ((sval == SV_SKELETON) && (randint1(100) > 60))) {
if (!note_kill) {
note_kill = _("灰になった。", (plural ? " become dust." : " becomes dust."));
Expand All @@ -262,25 +262,25 @@ bool affect_item(PlayerType *player_ptr, MONSTER_IDX src_idx, POSITION r, POSITI
}

std::string item_name("");
if (known && o_ptr->marked.has(OmType::FOUND)) {
if (known && item.marked.has(OmType::FOUND)) {
is_item_affected = true;
item_name = describe_flavor(player_ptr, *o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
item_name = describe_flavor(player_ptr, item, (OD_OMIT_PREFIX | OD_NAME_ONLY));
}

if ((is_fixed_or_random_artifact || ignore)) {
if (known && o_ptr->marked.has(OmType::FOUND)) {
if (known && item.marked.has(OmType::FOUND)) {
msg_format(_("%sは影響を受けない!", (plural ? "The %s are unaffected!" : "The %s is unaffected!")), item_name.data());
}

continue;
}

if (known && o_ptr->marked.has(OmType::FOUND) && note_kill) {
if (known && item.marked.has(OmType::FOUND) && note_kill) {
msg_format(_("%sは%s", "The %s%s"), item_name.data(), note_kill);
}

const auto bi_id = o_ptr->bi_id;
const auto is_potion = o_ptr->is_potion();
const auto bi_id = item.bi_id;
const auto is_potion = item.is_potion();
delete_object_idx(player_ptr, this_o_idx);
if (is_potion) {
(void)potion_smash_effect(player_ptr, src_idx, y, x, bi_id);
Expand Down
19 changes: 9 additions & 10 deletions src/floor/floor-object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,12 @@ static errr get_obj_index_prep(void)
* @param player_ptr プレイヤーへの参照ポインタ
* @param o_ptr デバッグ出力するオブジェクトの構造体参照ポインタ
*/
static void object_mention(PlayerType *player_ptr, ItemEntity *o_ptr)
static void object_mention(PlayerType *player_ptr, ItemEntity &item)
{
object_aware(player_ptr, o_ptr);
o_ptr->mark_as_known();

o_ptr->ident |= (IDENT_FULL_KNOWN);
const auto item_name = describe_flavor(player_ptr, *o_ptr, 0);
object_aware(player_ptr, &item);
item.mark_as_known();
item.ident |= (IDENT_FULL_KNOWN);
const auto item_name = describe_flavor(player_ptr, item, 0);
msg_format_wizard(player_ptr, CHEAT_OBJECT, _("%sを生成しました。", "%s was generated."), item_name.data());
}

Expand Down Expand Up @@ -143,7 +142,7 @@ bool make_object(PlayerType *player_ptr, ItemEntity *j_ptr, BIT_FLAGS mode, std:
ItemMagicApplier(player_ptr, j_ptr, floor_ptr->object_level, mode).execute();
set_ammo_quantity(j_ptr);
if (cheat_peek) {
object_mention(player_ptr, j_ptr);
object_mention(player_ptr, *j_ptr);
}

return true;
Expand Down Expand Up @@ -587,10 +586,10 @@ void floor_item_charges(FloorType *floor_ptr, INVENTORY_IDX i_idx)
*/
void floor_item_describe(PlayerType *player_ptr, INVENTORY_IDX i_idx)
{
auto *o_ptr = &player_ptr->current_floor_ptr->o_list[i_idx];
const auto item_name = describe_flavor(player_ptr, *o_ptr, 0);
const auto &item = player_ptr->current_floor_ptr->o_list[i_idx];
const auto item_name = describe_flavor(player_ptr, item, 0);
#ifdef JP
if (o_ptr->number <= 0) {
if (item.number <= 0) {
msg_format("床上には、もう%sはない。", item_name.data());
} else {
msg_format("床上には、まだ %sがある。", item_name.data());
Expand Down
10 changes: 5 additions & 5 deletions src/floor/floor-streams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -351,16 +351,16 @@ void build_streamer(PlayerType *player_ptr, FEAT_IDX feat, int chance)

/* Scan all objects in the grid */
for (const auto this_o_idx : grid.o_idx_list) {
auto *o_ptr = &floor.o_list[this_o_idx];
auto &item = floor.o_list[this_o_idx];

/* Hack -- Preserve unknown artifacts */
if (o_ptr->is_fixed_artifact()) {
o_ptr->get_fixed_artifact().is_generated = false;
if (item.is_fixed_artifact()) {
item.get_fixed_artifact().is_generated = false;
if (cheat_peek) {
const auto item_name = describe_flavor(player_ptr, *o_ptr, (OD_NAME_ONLY | OD_STORE));
const auto item_name = describe_flavor(player_ptr, item, (OD_NAME_ONLY | OD_STORE));
msg_format(_("伝説のアイテム (%s) はストリーマーにより削除された。", "Artifact (%s) was deleted by streamer."), item_name.data());
}
} else if (cheat_peek && o_ptr->is_random_artifact()) {
} else if (cheat_peek && item.is_random_artifact()) {
msg_print(_("ランダム・アーティファクトの1つはストリーマーにより削除された。", "One of the random artifacts was deleted by streamer."));
}
}
Expand Down
17 changes: 8 additions & 9 deletions src/floor/object-scanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ COMMAND_CODE show_floor_items(PlayerType *player_ptr, int target_item, POSITION
{
COMMAND_CODE i, m;
int j, k, l;
ItemEntity *o_ptr;
COMMAND_CODE out_index[23]{};
TERM_COLOR out_color[23]{};
std::array<std::string, 23> descriptions{};
Expand All @@ -117,12 +116,12 @@ COMMAND_CODE show_floor_items(PlayerType *player_ptr, int target_item, POSITION
const auto &[wid, hgt] = term_get_size();
auto len = std::max((*min_width), 20);
floor_num = scan_floor_items(player_ptr, floor_list, y, x, SCAN_FLOOR_ITEM_TESTER | SCAN_FLOOR_ONLY_MARKED, item_tester);
auto *floor_ptr = player_ptr->current_floor_ptr;
auto &floor = *player_ptr->current_floor_ptr;
for (k = 0, i = 0; i < floor_num && i < 23; i++) {
o_ptr = &floor_ptr->o_list[floor_list[i]];
const auto item_name = describe_flavor(player_ptr, *o_ptr, 0);
const auto &item = floor.o_list[floor_list[i]];
const auto item_name = describe_flavor(player_ptr, item, 0);
out_index[k] = i;
const auto tval = o_ptr->bi_key.tval();
const auto tval = item.bi_key.tval();
out_color[k] = tval_to_attr[enum2i(tval) & 0x7F];
descriptions[k] = item_name;
l = descriptions[k].length() + 5;
Expand All @@ -147,10 +146,10 @@ COMMAND_CODE show_floor_items(PlayerType *player_ptr, int target_item, POSITION

*min_width = len;
int col = (len > wid - 4) ? 0 : (wid - len - 1);
prepare_label_string_floor(floor_ptr, floor_label, floor_list, floor_num);
prepare_label_string_floor(&floor, floor_label, floor_list, floor_num);
for (j = 0; j < k; j++) {
m = floor_list[out_index[j]];
o_ptr = &floor_ptr->o_list[m];
const auto &item = floor.o_list[m];
prt("", j + 1, col ? col - 2 : col);
std::string head;
if (use_menu && target_item) {
Expand All @@ -166,8 +165,8 @@ COMMAND_CODE show_floor_items(PlayerType *player_ptr, int target_item, POSITION

put_str(head, j + 1, col);
c_put_str(out_color[j], descriptions[j], j + 1, col + 3);
if (show_weights && (o_ptr->bi_key.tval() != ItemKindType::GOLD)) {
int wgt = o_ptr->weight * o_ptr->number;
if (show_weights && (item.bi_key.tval() != ItemKindType::GOLD)) {
int wgt = item.weight * item.number;
const auto weight = format(_("%3d.%1d kg", "%3d.%1d lb"), _(lb_to_kg_integer(wgt), wgt / 10), _(lb_to_kg_fraction(wgt), wgt % 10));
prt(weight, j + 1, wid - 9);
}
Expand Down
Loading

0 comments on commit f2fa637

Please sign in to comment.