#include "cmd-visual/cmd-draw.h"
#include "core/asking-player.h"
#include "core/player-redraw-types.h"
-#include "core/player-update-types.h"
#include "core/stuff-handler.h"
#include "core/window-redrawer.h"
#include "dungeon/quest.h"
#include "status/experience.h"
#include "system/angband-version.h"
#include "system/artifact-type-definition.h"
-#include "system/baseitem-info-definition.h"
+#include "system/baseitem-info.h"
#include "system/dungeon-info.h"
#include "system/floor-type-definition.h"
#include "system/grid-type-definition.h"
-#include "system/monster-type-definition.h"
-#include "system/object-type-definition.h"
+#include "system/item-entity.h"
+#include "system/monster-entity.h"
#include "system/player-type-definition.h"
+#include "system/redrawing-flags-updater.h"
#include "system/terrain-type-definition.h"
#include "target/grid-selector.h"
#include "term/screen-processor.h"
+#include "term/z-form.h"
#include "util/angband-files.h"
#include "util/bit-flags-calculator.h"
#include "util/enum-converter.h"
msg_print("You're fully cured by wizard command.");
}
-static std::optional<KIND_OBJECT_IDX> wiz_select_tval()
+static std::optional<short> wiz_select_tval()
{
- KIND_OBJECT_IDX list;
+ short list;
char ch;
for (list = 0; (list < 80) && (tvals[list].tval > ItemKindType::NONE); list++) {
auto row = 2 + (list % 20);
return std::nullopt;
}
- KIND_OBJECT_IDX selection;
+ short selection;
for (selection = 0; selection < max_num; selection++) {
if (listsym[selection] == ch) {
break;
return selection;
}
-static KIND_OBJECT_IDX wiz_select_sval(const ItemKindType tval, concptr tval_description)
+static short wiz_select_sval(const ItemKindType tval, concptr tval_description)
{
auto num = 0;
- KIND_OBJECT_IDX choice[80]{};
+ short choice[80]{};
char ch;
- for (const auto &k_ref : baseitems_info) {
+ for (const auto &baseitem : baseitems_info) {
if (num >= 80) {
break;
}
- if (k_ref.idx == 0 || k_ref.tval != tval) {
+ if ((baseitem.idx == 0) || baseitem.bi_key.tval() != tval) {
continue;
}
auto row = 2 + (num % 20);
auto col = _(30, 32) * (num / 20);
ch = listsym[num];
- const auto buf = strip_name(k_ref.idx);
+ const auto buf = strip_name(baseitem.idx);
prt(format("[%c] %s", ch, buf.data()), row, col);
- choice[num++] = k_ref.idx;
+ choice[num++] = baseitem.idx;
}
auto max_num = num;
return 0;
}
- KIND_OBJECT_IDX selection;
+ short selection;
for (selection = 0; selection < max_num; selection++) {
if (listsym[selection] == ch) {
break;
* @return ベースアイテムID
* @details
* by RAK, heavily modified by -Bernd-
- * This function returns the k_idx of an object type, or zero if failed
+ * This function returns the bi_id of an object type, or zero if failed
* List up to 50 choices in three columns
*/
-static KIND_OBJECT_IDX wiz_create_itemtype()
+static short wiz_create_itemtype()
{
term_clear();
auto selection = wiz_select_tval();
void wiz_create_item(PlayerType *player_ptr)
{
screen_save();
- OBJECT_IDX k_idx = wiz_create_itemtype();
+ const auto bi_id = wiz_create_itemtype();
screen_load();
- if (!k_idx) {
+ if (bi_id == 0) {
return;
}
- if (baseitems_info[k_idx].gen_flags.has(ItemGenerationTraitType::INSTA_ART)) {
- for (const auto &[a_idx, a_ref] : artifacts_info) {
- if ((a_idx == FixedArtifactId::NONE) || (a_ref.tval != baseitems_info[k_idx].tval) || (a_ref.sval != baseitems_info[k_idx].sval)) {
+ const auto &baseitem = baseitems_info[bi_id];
+ if (baseitem.gen_flags.has(ItemGenerationTraitType::INSTA_ART)) {
+ for (const auto &[a_idx, artifact] : artifacts_info) {
+ if ((a_idx == FixedArtifactId::NONE) || (artifact.bi_key != baseitem.bi_key)) {
continue;
}
}
}
- ObjectType forge;
- ObjectType *q_ptr;
- q_ptr = &forge;
- q_ptr->prep(k_idx);
- ItemMagicApplier(player_ptr, q_ptr, player_ptr->current_floor_ptr->dun_level, AM_NO_FIXED_ART).execute();
- (void)drop_near(player_ptr, q_ptr, -1, player_ptr->y, player_ptr->x);
+ ItemEntity item;
+ item.prep(bi_id);
+ ItemMagicApplier(player_ptr, &item, player_ptr->current_floor_ptr->dun_level, AM_NO_FIXED_ART).execute();
+ (void)drop_near(player_ptr, &item, -1, player_ptr->y, player_ptr->x);
msg_print("Allocated.");
}
*/
static std::string wiz_make_named_artifact_desc(PlayerType *player_ptr, FixedArtifactId a_idx)
{
- const auto &a_ref = artifacts_info.at(a_idx);
- ObjectType obj;
- obj.prep(lookup_kind(a_ref.tval, a_ref.sval));
- obj.fixed_artifact_idx = a_idx;
- object_known(&obj);
- char buf[MAX_NLEN];
- describe_flavor(player_ptr, buf, &obj, OD_NAME_ONLY);
-
- return buf;
+ const auto &artifact = ArtifactsInfo::get_instance().get_artifact(a_idx);
+ ItemEntity item;
+ item.prep(lookup_baseitem_id(artifact.bi_key));
+ item.fixed_artifact_idx = a_idx;
+ object_known(&item);
+ return describe_flavor(player_ptr, &item, OD_NAME_ONLY);
}
/**
put_str(ss.str().data(), i + 1, 15);
}
if (page_max > 1) {
- put_str(format("-- more (%d/%d) --", current_page + 1, page_max), page_item_count + 1, 15);
+ put_str(format("-- more (%lu/%lu) --", current_page + 1, page_max), page_item_count + 1, 15);
}
char cmd = ESCAPE;
const auto &[tval_list, name] = group_artifact;
std::vector<FixedArtifactId> a_idx_list;
for (auto tval : tval_list) {
- for (const auto &[a_idx, a_ref] : artifacts_info) {
- if (a_ref.tval == tval) {
+ for (const auto &[a_idx, artifact] : artifacts_info) {
+ if (artifact.bi_key.tval() == tval) {
a_idx_list.push_back(a_idx);
}
}
}
+
return a_idx_list;
}
return;
default:
if (auto idx = A2I(cmd); idx < group_artifact_list.size()) {
- const auto a_idx_list = wiz_collect_group_a_idx(group_artifact_list[idx]);
+ const auto &a_idx_list = wiz_collect_group_a_idx(group_artifact_list[idx]);
create_a_idx = wiz_select_named_artifact(player_ptr, a_idx_list);
}
+
+ break;
}
}
screen_load();
const auto a_idx = create_a_idx.value();
- const auto it = artifacts_info.find(a_idx);
- if (it == artifacts_info.end()) {
- msg_print("The specified artifact is obsoleted for now.");
- return;
- }
-
- auto &a_ref = it->second;
- if (a_ref.is_generated) {
+ const auto &artifact = ArtifactsInfo::get_instance().get_artifact(a_idx);
+ if (artifact.is_generated) {
msg_print("It's already allocated.");
return;
}
char tmp_val[160];
char ppp[80];
for (int i = 0; i < A_MAX; i++) {
- sprintf(ppp, "%s (3-%d): ", stat_names[i], player_ptr->stat_max_max[i]);
- sprintf(tmp_val, "%d", player_ptr->stat_max[i]);
+ strnfmt(ppp, sizeof(ppp), "%s (3-%d): ", stat_names[i], player_ptr->stat_max_max[i]);
+ strnfmt(tmp_val, sizeof(tmp_val), "%d", player_ptr->stat_max[i]);
if (!get_string(ppp, tmp_val, 3)) {
return;
}
player_ptr->stat_cur[i] = player_ptr->stat_max[i] = (BASE_STATUS)tmp_int;
}
- sprintf(tmp_val, "%d", PlayerSkill::weapon_exp_at(PlayerSkillRank::MASTER));
+ strnfmt(tmp_val, sizeof(tmp_val), "%d", PlayerSkill::weapon_exp_at(PlayerSkillRank::MASTER));
if (!get_string(_("熟練度: ", "Proficiency: "), tmp_val, 4)) {
return;
}
player_ptr->spell_exp[k] = std::min(PlayerSkill::spell_exp_at(PlayerSkillRank::EXPERT), tmp_s16b);
}
- sprintf(tmp_val, "%ld", (long)(player_ptr->au));
+ strnfmt(tmp_val, sizeof(tmp_val), "%ld", (long)(player_ptr->au));
if (!get_string("Gold: ", tmp_val, 9)) {
return;
}
}
player_ptr->au = tmp_long;
- sprintf(tmp_val, "%ld", (long)(player_ptr->max_exp));
+ strnfmt(tmp_val, sizeof(tmp_val), "%ld", (long)(player_ptr->max_exp));
if (!get_string("Experience: ", tmp_val, 9)) {
return;
}
note_spot(player_ptr, y, x);
lite_spot(player_ptr, y, x);
- player_ptr->update |= PU_FLOW;
+ RedrawingFlagsUpdater::get_instance().set_flag(StatusRedrawingFlag::FLOW);
}
/*!
}
while (true) {
- char ppp[80];
char tmp_val[160];
- sprintf(ppp, "Jump which dungeon : ");
- sprintf(tmp_val, "%d", player_ptr->dungeon_idx);
- if (!get_string(ppp, tmp_val, 2)) {
+ strnfmt(tmp_val, sizeof(tmp_val), "%d", player_ptr->dungeon_idx);
+ if (!get_string("Jump which dungeon : ", tmp_val, 2)) {
return false;
}
while (true) {
char ppp[80];
char tmp_val[160];
- sprintf(ppp, "Jump to level (0, %d-%d): ", min_depth, max_depth);
- sprintf(tmp_val, "%d", (int)player_ptr->current_floor_ptr->dun_level);
+ strnfmt(ppp, sizeof(ppp), "Jump to level (0, %d-%d): ", min_depth, max_depth);
+ strnfmt(tmp_val, sizeof(tmp_val), "%d", (int)player_ptr->current_floor_ptr->dun_level);
if (!get_string(ppp, tmp_val, 10)) {
return false;
}
*/
void wiz_learn_items_all(PlayerType *player_ptr)
{
- ObjectType forge;
- ObjectType *q_ptr;
- for (const auto &k_ref : baseitems_info) {
- if (k_ref.idx > 0 && k_ref.level <= command_arg) {
+ ItemEntity forge;
+ ItemEntity *q_ptr;
+ for (const auto &baseitem : baseitems_info) {
+ if (baseitem.idx > 0 && baseitem.level <= command_arg) {
q_ptr = &forge;
- q_ptr->prep(k_ref.idx);
+ q_ptr->prep(baseitem.idx);
object_aware(player_ptr, q_ptr);
}
}
player_ptr->prace = i2enum<PlayerRaceType>(val);
rp_ptr = &race_info[enum2i(player_ptr->prace)];
+ auto &rfu = RedrawingFlagsUpdater::get_instance();
+ const auto flags_srf = {
+ StatusRedrawingFlag::BONUS,
+ StatusRedrawingFlag::HP,
+ StatusRedrawingFlag::MP,
+ StatusRedrawingFlag::SPELLS,
+ };
player_ptr->window_flags |= PW_PLAYER;
- player_ptr->update |= PU_BONUS | PU_HP | PU_MANA | PU_SPELLS;
- player_ptr->redraw |= PR_BASIC | PR_HP | PR_MANA | PR_STATS;
+ rfu.set_flags(flags_srf);
+ player_ptr->redraw |= PR_BASIC | PR_HP | PR_MP | PR_ABILITY_SCORE;
handle_stuff(player_ptr);
}
cp_ptr = &class_info[val];
mp_ptr = &class_magics_info[val];
PlayerClass(player_ptr).init_specific_data();
+ auto &rfu = RedrawingFlagsUpdater::get_instance();
+ const auto flags_srf = {
+ StatusRedrawingFlag::BONUS,
+ StatusRedrawingFlag::HP,
+ StatusRedrawingFlag::MP,
+ StatusRedrawingFlag::SPELLS,
+ };
player_ptr->window_flags |= PW_PLAYER;
- player_ptr->update |= PU_BONUS | PU_HP | PU_MANA | PU_SPELLS;
- player_ptr->redraw |= PR_BASIC | PR_HP | PR_MANA | PR_STATS;
+ rfu.set_flags(flags_srf);
+ player_ptr->redraw |= PR_BASIC | PR_HP | PR_MP | PR_ABILITY_SCORE;
handle_stuff(player_ptr);
}
player_ptr->realm1 = static_cast<int16_t>(val1);
player_ptr->realm2 = static_cast<int16_t>(val2);
+ auto &rfu = RedrawingFlagsUpdater::get_instance();
+ const auto flags = {
+ StatusRedrawingFlag::BONUS,
+ StatusRedrawingFlag::HP,
+ StatusRedrawingFlag::MP,
+ StatusRedrawingFlag::SPELLS,
+ };
player_ptr->window_flags |= PW_PLAYER;
- player_ptr->update |= PU_BONUS | PU_HP | PU_MANA | PU_SPELLS;
+ rfu.set_flags(flags);
player_ptr->redraw |= PR_BASIC;
handle_stuff(player_ptr);
}
*/
void wiz_dump_options(void)
{
- char buf[1024];
- path_build(buf, sizeof(buf), ANGBAND_DIR_USER, "opt_info.txt");
- FILE *fff;
- fff = angband_fopen(buf, "a");
+ const auto &path = path_build(ANGBAND_DIR_USER, "opt_info.txt");
+ const auto &filename = path.string();
+ auto *fff = angband_fopen(path, FileOpenMode::APPEND);
if (fff == nullptr) {
- msg_format(_("ファイル %s を開けませんでした。", "Failed to open file %s."), buf);
+ msg_format(_("ファイル %s を開けませんでした。", "Failed to open file %s."), filename.data());
msg_print(nullptr);
return;
}
}
}
- char title[200];
- put_version(title);
- fprintf(fff, "[Option bits usage on %s\n]", title);
+ fprintf(fff, "[Option bits usage on %s\n]", get_version().data());
fputs("Set - Bit (Page) Option Name\n", fff);
fputs("------------------------------------------------\n", fff);
for (int i = 0; i < NUM_O_SET; i++) {
}
angband_fclose(fff);
- msg_format(_("オプションbit使用状況をファイル %s に書き出しました。", "Option bits usage dump saved to file %s."), buf);
+ msg_format(_("オプションbit使用状況をファイル %s に書き出しました。", "Option bits usage dump saved to file %s."), filename.data());
}
/*!
continue;
}
- if (record_named_pet && m_ptr->is_pet() && m_ptr->nickname) {
- GAME_TEXT m_name[MAX_NLEN];
-
- monster_desc(player_ptr, m_name, m_ptr, MD_INDEF_VISIBLE);
- exe_write_diary(player_ptr, DIARY_NAMED_PET, RECORD_NAMED_PET_WIZ_ZAP, m_name);
+ if (record_named_pet && m_ptr->is_named_pet()) {
+ const auto m_name = monster_desc(player_ptr, m_ptr, MD_INDEF_VISIBLE);
+ exe_write_diary(player_ptr, DIARY_NAMED_PET, RECORD_NAMED_PET_WIZ_ZAP, m_name.data());
}
delete_monster_idx(player_ptr, i);
continue;
}
- if (record_named_pet && m_ptr->is_pet() && m_ptr->nickname) {
- GAME_TEXT m_name[MAX_NLEN];
- monster_desc(player_ptr, m_name, m_ptr, MD_INDEF_VISIBLE);
- exe_write_diary(player_ptr, DIARY_NAMED_PET, RECORD_NAMED_PET_WIZ_ZAP, m_name);
+ if (record_named_pet && m_ptr->is_named_pet()) {
+ const auto m_name = monster_desc(player_ptr, m_ptr, MD_INDEF_VISIBLE);
+ exe_write_diary(player_ptr, DIARY_NAMED_PET, RECORD_NAMED_PET_WIZ_ZAP, m_name.data());
}
delete_monster_idx(player_ptr, i);
player_ptr->wild_mode = false;
player_ptr->leaving = true;
-
- exe_write_diary(player_ptr, DIARY_DESCRIPTION, 1, _(" しかし、生き返った。", " but revived."));
+ constexpr auto note = _(" しかし、生き返った。", " but revived.");
+ exe_write_diary(player_ptr, DIARY_DESCRIPTION, 1, note);
leave_floor(player_ptr);
}