#include "game-option/game-play-options.h"
#include "io/input-key-acceptor.h"
#include "lore/lore-store.h"
+#include "lore/lore-util.h"
#include "monster-race/monster-race.h"
#include "monster-race/race-flags1.h"
+#include "system/monster-race-info.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 施設でモンスターの情報を知るメインルーチン / research_mon -KMW-
- * @param player_ptr ã\83\97ã\83¬ã\83¼ヤーへの参照ポインタ
+ * @param player_ptr ã\83\97ã\83¬ã\82¤ヤーへの参照ポインタ
* @return 常にTRUEを返す。
* @todo 返り値が意味不明なので直した方が良いかもしれない。
*/
-bool research_mon(player_type *player_ptr)
+bool research_mon(PlayerType *player_ptr)
{
- char buf[256];
bool notpicked;
- bool recall = FALSE;
- u16b why = 0;
- MONSTER_IDX *who;
+ bool recall = false;
+ uint16_t why = 0;
- bool all = FALSE;
- bool uniq = FALSE;
- bool norm = FALSE;
+ bool all = false;
+ bool uniq = false;
+ bool norm = false;
char temp[MAX_MONSTER_NAME] = "";
- static int old_sym = '\0';
- static IDX old_i = 0;
screen_save();
char sym;
if (!get_com(
_("モンスターの文字を入力して下さい(記号 or ^A全,^Uユ,^N非ユ,^M名前):", "Enter character to be identified(^A:All,^U:Uniqs,^N:Non uniqs,^M:Name): "),
- &sym, FALSE))
+ &sym, false))
{
screen_load();
- return FALSE;
+ return false;
}
- IDX i;
- for (i = 0; ident_info[i]; ++i) {
- if (sym == ident_info[i][0])
+ IDX ident_i;
+ for (ident_i = 0; ident_info[ident_i]; ++ident_i) {
+ if (sym == ident_info[ident_i][0]) {
break;
+ }
}
/* XTRA HACK WHATSEARCH */
+ std::string buf;
if (sym == KTRL('A')) {
- all = TRUE;
- strcpy(buf, _("全モンスターのリスト", "Full monster list."));
+ all = true;
+ buf = _("全モンスターのリスト", "Full monster list.");
} else if (sym == KTRL('U')) {
- all = uniq = TRUE;
- strcpy(buf, _("ユニーク・モンスターのリスト", "Unique monster list."));
+ all = uniq = true;
+ buf = _("ユニーク・モンスターのリスト", "Unique monster list.");
} else if (sym == KTRL('N')) {
- all = norm = TRUE;
- strcpy(buf, _("ユニーク外モンスターのリスト", "Non-unique monster list."));
+ all = norm = true;
+ buf = _("ユニーク外モンスターのリスト", "Non-unique monster list.");
} else if (sym == KTRL('M')) {
- all = TRUE;
+ all = true;
if (!get_string(_("名前(英語の場合小文字で可)", "Enter name:"), temp, 70)) {
temp[0] = 0;
screen_load();
- return FALSE;
+ return false;
}
- sprintf(buf, _("名前:%sにマッチ", "Monsters' names with \"%s\""), temp);
- } else if (ident_info[i]) {
- sprintf(buf, "%c - %s.", sym, ident_info[i] + 2);
+ buf = format(_("名前:%sにマッチ", "Monsters' names with \"%s\""), temp);
+ } else if (ident_info[ident_i]) {
+ buf = format("%c - %s.", sym, ident_info[ident_i] + 2);
} else {
- sprintf(buf, "%c - %s", sym, _("無効な文字", "Unknown Symbol"));
+ buf = format("%c - %s", sym, _("無効な文字", "Unknown Symbol"));
}
/* Display the result */
prt(buf, 16, 10);
/* Allocate the "who" array */
- C_MAKE(who, max_r_idx, MONRACE_IDX);
+ std::vector<MonsterRaceId> who;
/* Collect matching monsters */
- int n = 0;
- for (i = 1; i < max_r_idx; i++) {
- monster_race *r_ptr = &r_info[i];
-
+ for (const auto &[r_idx, r_ref] : monraces_info) {
/* Empty monster */
- if (r_ptr->name.empty())
+ if (!MonsterRace(r_ref.idx).is_valid() || r_ref.name.empty()) {
continue;
+ }
/* XTRA HACK WHATSEARCH */
/* Require non-unique monsters if needed */
- if (norm && (r_ptr->flags1 & (RF1_UNIQUE)))
+ if (norm && r_ref.kind_flags.has(MonsterKindType::UNIQUE)) {
continue;
+ }
/* Require unique monsters if needed */
- if (uniq && !(r_ptr->flags1 & (RF1_UNIQUE)))
+ if (uniq && r_ref.kind_flags.has_not(MonsterKindType::UNIQUE)) {
continue;
+ }
/* 名前検索 */
if (temp[0]) {
continue;
}
#endif
- if (isupper(temp[xx]))
+ if (isupper(temp[xx])) {
temp[xx] = (char)tolower(temp[xx]);
+ }
}
- char temp2[MAX_MONSTER_NAME];
-#ifdef JP
- strcpy(temp2, r_ptr->E_name.c_str());
-#else
- strcpy(temp2, r_ptr->name.c_str());
-#endif
- for (int xx = 0; temp2[xx] && xx < 80; xx++) {
- if (isupper(temp2[xx]))
- temp2[xx] = (char)tolower(temp2[xx]);
+ std::string temp2 = _(r_ref.E_name, r_ref.name);
+ for (auto &ch : temp2) {
+ if (isupper(ch)) {
+ ch = static_cast<char>(tolower(ch));
+ }
}
#ifdef JP
- if (angband_strstr(temp2, temp) || angband_strstr(r_ptr->name.c_str(), temp))
+ if (angband_strstr(temp2.data(), temp) || angband_strstr(r_ref.name.data(), temp))
#else
- if (angband_strstr(temp2, temp))
+ if (angband_strstr(temp2.data(), temp))
#endif
- who[n++] = i;
- } else if (all || (r_ptr->d_char == sym)) {
- who[n++] = i;
+ who.push_back(r_ref.idx);
+ } else if (all || (r_ref.d_char == sym)) {
+ who.push_back(r_ref.idx);
}
}
- if (n == 0) {
- C_KILL(who, max_r_idx, MONRACE_IDX);
+ if (who.empty()) {
screen_load();
- return FALSE;
+ return false;
}
why = 2;
char query = 'y';
if (why) {
- ang_sort(player_ptr, who, &why, n, ang_sort_comp_hook, ang_sort_swap_hook);
+ ang_sort(player_ptr, who.data(), &why, who.size(), ang_sort_comp_hook, ang_sort_swap_hook);
}
- if (old_sym == sym && old_i < n)
+ uint i;
+ static int old_sym = '\0';
+ static uint old_i = 0;
+ if (old_sym == sym && old_i < who.size()) {
i = old_i;
- else
- i = n - 1;
+ } else {
+ i = who.size() - 1;
+ }
- notpicked = TRUE;
- MONRACE_IDX r_idx;
+ notpicked = true;
while (notpicked) {
- r_idx = who[i];
+ auto r_idx = who[i];
roff_top(r_idx);
term_addstr(-1, TERM_WHITE, _(" ['r'思い出, ' 'で続行, ESC]", " [(r)ecall, ESC, space to continue]"));
- while (TRUE) {
+ while (true) {
if (recall) {
lore_do_probe(player_ptr, r_idx);
monster_race_track(player_ptr, r_idx);
handle_stuff(player_ptr);
screen_roff(player_ptr, r_idx, MONSTER_LORE_RESEARCH);
- notpicked = FALSE;
+ notpicked = false;
old_sym = sym;
old_i = i;
}
query = inkey();
- if (query != 'r')
+ if (query != 'r') {
break;
+ }
recall = !recall;
}
- if (query == ESCAPE)
+ if (query == ESCAPE) {
break;
+ }
if (query == '-') {
- if (++i == n) {
+ if (++i == who.size()) {
i = 0;
- if (!expand_list)
+ if (!expand_list) {
break;
+ }
}
continue;
}
if (i-- == 0) {
- i = n - 1;
- if (!expand_list)
+ i = who.size() - 1;
+ if (!expand_list) {
break;
+ }
}
}
- C_KILL(who, max_r_idx, MONRACE_IDX);
screen_load();
return !notpicked;
}