-#include "cmd-io/cmd-lore.h"
+#include "cmd-io/cmd-lore.h"
#include "core/asking-player.h"
#include "core/stuff-handler.h"
#include "game-option/cheat-options.h"
#include "monster-race/monster-race.h"
#include "monster-race/race-flags1.h"
#include "monster-race/race-flags7.h"
-#include "system/monster-race-definition.h"
+#include "system/monster-race-info.h"
#include "system/player-type-definition.h"
#include "term/gameterm.h"
#include "term/screen-processor.h"
#include "term/term-color-types.h"
+#include "term/z-form.h"
#include "util/int-char-converter.h"
#include "util/sort.h"
#include "util/string-processor.h"
/*!
* @brief モンスターの思い出を見るコマンドのメインルーチン
* Identify a character, allow recall of monsters
- * @param player_ptr ã\83\97ã\83¬ã\83¼ヤーへの参照ポインタ
+ * @param player_ptr ã\83\97ã\83¬ã\82¤ヤーへの参照ポインタ
* @details
* <pre>
* Several "special" responses recall "multiple" monsters:
* Note that the player ghosts are ignored.
* </pre>
*/
-void do_cmd_query_symbol(player_type *creature_ptr)
+void do_cmd_query_symbol(PlayerType *player_ptr)
{
- MONRACE_IDX i;
- int n;
- MONRACE_IDX r_idx;
- char sym, query;
- char buf[256];
-
- bool all = FALSE;
- bool uniq = FALSE;
- bool norm = FALSE;
- bool ride = FALSE;
- char temp[MAX_MONSTER_NAME] = "";
-
- bool recall = FALSE;
-
- u16b why = 0;
- MONRACE_IDX *who;
-
- if (!get_com(_("知りたい文字を入力して下さい(記号 or ^A全,^Uユ,^N非ユ,^R乗馬,^M名前): ",
- "Enter character to be identified(^A:All,^U:Uniqs,^N:Non uniqs,^M:Name): "),
- &sym, FALSE))
+ bool all = false;
+ bool uniq = false;
+ bool norm = false;
+ bool ride = false;
+ bool recall = false;
+
+ uint16_t why = 0;
+
+ constexpr auto prompt = _("知りたい文字を入力して下さい(記号 or ^A全,^Uユ,^N非ユ,^R乗馬,^M名前): ",
+ "Enter character to be identified(^A:All,^U:Uniqs,^N:Non uniqs,^M:Name): ");
+ const auto symbol = input_command(prompt);
+ if (!symbol) {
return;
+ }
- for (i = 0; ident_info[i]; ++i) {
- if (sym == ident_info[i][0])
+ int ident_i;
+ for (ident_i = 0; ident_info[ident_i]; ++ident_i) {
+ if (symbol == ident_info[ident_i][0]) {
break;
+ }
}
- if (sym == KTRL('A')) {
- all = TRUE;
- strcpy(buf, _("全モンスターのリスト", "Full monster list."));
- } else if (sym == KTRL('U')) {
- all = uniq = TRUE;
- strcpy(buf, _("ユニーク・モンスターのリスト", "Unique monster list."));
- } else if (sym == KTRL('N')) {
- all = norm = TRUE;
- strcpy(buf, _("ユニーク外モンスターのリスト", "Non-unique monster list."));
- } else if (sym == KTRL('R')) {
- all = ride = TRUE;
- strcpy(buf, _("乗馬可能モンスターのリスト", "Ridable monster list."));
- } else if (sym == KTRL('M')) {
- all = TRUE;
- if (!get_string(_("名前(英語の場合小文字で可)", "Enter name:"), temp, 70)) {
- temp[0] = 0;
+ std::string buf;
+ std::string monster_name("");
+ if (symbol == KTRL('A')) {
+ all = true;
+ buf = _("全モンスターのリスト", "Full monster list.");
+ } else if (symbol == KTRL('U')) {
+ all = uniq = true;
+ buf = _("ユニーク・モンスターのリスト", "Unique monster list.");
+ } else if (symbol == KTRL('N')) {
+ all = norm = true;
+ buf = _("ユニーク外モンスターのリスト", "Non-unique monster list.");
+ } else if (symbol == KTRL('R')) {
+ all = ride = true;
+ buf = _("乗馬可能モンスターのリスト", "Ridable monster list.");
+ } else if (symbol == KTRL('M')) {
+ all = true;
+ const auto monster_name_opt = input_string(_("名前(英語の場合小文字で可)", "Enter name:"), MAX_MONSTER_NAME);
+ if (!monster_name_opt) {
return;
}
- sprintf(buf, _("名前:%sにマッチ", "Monsters' names with \"%s\""), temp);
- } else if (ident_info[i]) {
- sprintf(buf, "%c - %s.", sym, ident_info[i] + 2);
+
+ monster_name = *monster_name_opt;
+ buf = format(_("名前:%sにマッチ", "Monsters' names with \"%s\""), monster_name.data());
+ } else if (ident_info[ident_i]) {
+ buf = format("%c - %s.", *symbol, ident_info[ident_i] + 2);
} else {
- sprintf(buf, "%c - %s", sym, _("無効な文字", "Unknown Symbol"));
+ buf = format("%c - %s", *symbol, _("無効な文字", "Unknown Symbol"));
}
prt(buf, 0, 0);
- C_MAKE(who, max_r_idx, MONRACE_IDX);
- for (n = 0, i = 1; i < max_r_idx; i++) {
- monster_race *r_ptr = &r_info[i];
- if (!cheat_know && !r_ptr->r_sights)
+ std::vector<MonsterRaceId> monraces;
+ for (const auto &[monrace_id, monrace] : monraces_info) {
+ if (!cheat_know && !monrace.r_sights) {
continue;
+ }
- if (norm && (r_ptr->flags1 & (RF1_UNIQUE)))
+ if (norm && monrace.kind_flags.has(MonsterKindType::UNIQUE)) {
continue;
+ }
- if (uniq && !(r_ptr->flags1 & (RF1_UNIQUE)))
+ if (uniq && monrace.kind_flags.has_not(MonsterKindType::UNIQUE)) {
continue;
+ }
- if (ride && !(r_ptr->flags7 & (RF7_RIDING)))
+ if (ride && monrace.misc_flags.has_not(MonsterMiscType::RIDING)) {
continue;
+ }
- if (temp[0]) {
- TERM_LEN xx;
- char temp2[MAX_MONSTER_NAME];
-
- for (xx = 0; temp[xx] && xx < MAX_MONSTER_NAME; xx++) {
+ if (!monster_name.empty()) {
+ for (size_t xx = 0; xx < monster_name.length(); xx++) {
#ifdef JP
- if (iskanji(temp[xx])) {
+ if (iskanji(monster_name[xx])) {
xx++;
continue;
}
#endif
- if (isupper(temp[xx]))
- temp[xx] = (char)tolower(temp[xx]);
+ if (isupper(monster_name[xx])) {
+ monster_name[xx] = (char)tolower(monster_name[xx]);
+ }
}
#ifdef JP
- strcpy(temp2, r_ptr->E_name.c_str());
+ auto temp2(monrace.E_name);
#else
- strcpy(temp2, r_ptr->name.c_str());
+ auto temp2(monrace.name);
#endif
- for (xx = 0; temp2[xx] && xx < MAX_MONSTER_NAME; xx++)
- if (isupper(temp2[xx]))
+ for (size_t xx = 0; xx < temp2.length(); xx++) {
+ if (isupper(temp2[xx])) {
temp2[xx] = (char)tolower(temp2[xx]);
+ }
+ }
#ifdef JP
- if (angband_strstr(temp2, temp) || angband_strstr(r_ptr->name.c_str(), temp))
+ if (str_find(temp2, monster_name) || str_find(monrace.name, monster_name))
#else
- if (angband_strstr(temp2, temp))
+ if (str_find(temp2, monster_name))
#endif
- who[n++] = i;
+ monraces.push_back(monrace_id);
}
- else if (all || (r_ptr->d_char == sym))
- who[n++] = i;
+ else if (all || (monrace.d_char == symbol)) {
+ monraces.push_back(monrace_id);
+ }
}
- if (!n) {
- C_KILL(who, max_r_idx, MONRACE_IDX);
+ if (monraces.empty()) {
return;
}
put_str(_("思い出を見ますか? (k:殺害順/y/n): ", "Recall details? (k/y/n): "), 0, _(36, 40));
- query = inkey();
+ auto query = inkey();
prt(buf, 0, 0);
why = 2;
- ang_sort(creature_ptr, who, &why, n, ang_sort_comp_hook, ang_sort_swap_hook);
+ ang_sort(player_ptr, monraces.data(), &why, monraces.size(), ang_sort_comp_hook, ang_sort_swap_hook);
if (query == 'k') {
why = 4;
query = 'y';
}
if (query != 'y') {
- C_KILL(who, max_r_idx, MONRACE_IDX);
return;
}
if (why == 4) {
- ang_sort(creature_ptr, who, &why, n, ang_sort_comp_hook, ang_sort_swap_hook);
+ ang_sort(player_ptr, monraces.data(), &why, monraces.size(), ang_sort_comp_hook, ang_sort_swap_hook);
}
- i = n - 1;
- while (TRUE) {
- r_idx = who[i];
- monster_race_track(creature_ptr, r_idx);
- handle_stuff(creature_ptr);
- while (TRUE) {
+ auto i = monraces.size() - 1;
+ while (true) {
+ auto r_idx = monraces[i];
+ monster_race_track(player_ptr, r_idx);
+ handle_stuff(player_ptr);
+ while (true) {
if (recall) {
screen_save();
- screen_roff(creature_ptr, who[i], MONSTER_LORE_NORMAL);
+ screen_roff(player_ptr, monraces[i], MONSTER_LORE_NORMAL);
}
roff_top(r_idx);
screen_load();
}
- if (query != 'r')
+ if (query != 'r') {
break;
+ }
recall = !recall;
}
- if (query == ESCAPE)
+ if (query == ESCAPE) {
break;
+ }
if (query == '-') {
- if (++i == n) {
+ if (++i == monraces.size()) {
i = 0;
- if (!expand_list)
+ if (!expand_list) {
break;
+ }
}
} else {
if (i-- == 0) {
- i = n - 1;
- if (!expand_list)
+ i = monraces.size() - 1;
+ if (!expand_list) {
break;
+ }
}
}
}
- C_KILL(who, max_r_idx, MONRACE_IDX);
prt(buf, 0, 0);
}