#include "util/string-processor.h"
#include "view/display-messages.h"
#include <stdexcept>
+#include <string>
#include <string_view>
+#include <vector>
/*!
* @brief Load an autopick preference file
*/
static std::vector<concptr> read_text_lines(std::string_view filename)
{
- FILE *fff;
-
- int lines = 0;
char buf[1024];
-
path_build(buf, sizeof(buf), ANGBAND_DIR_USER, filename);
- fff = angband_fopen(buf, FileOpenMode::READ);
+ auto *fff = angband_fopen(buf, FileOpenMode::READ);
if (!fff) {
return {};
}
+ auto lines = 0;
std::vector<concptr> lines_list(MAX_LINES);
while (angband_fgets(fff, buf, sizeof(buf)) == 0) {
lines_list[lines++] = string_make(buf);
*/
static void prepare_default_pickpref(PlayerType *player_ptr)
{
- const concptr messages[] = { _("あなたは「自動拾いエディタ」を初めて起動しました。", "You have activated the Auto-Picker Editor for the first time."),
+ const std::vector<std::string> messages = { _("あなたは「自動拾いエディタ」を初めて起動しました。", "You have activated the Auto-Picker Editor for the first time."),
_("自動拾いのユーザー設定ファイルがまだ書かれていないので、", "Since user pref file for autopick is not yet created,"),
- _("基本的な自動拾い設定ファイルをlib/pref/picktype.prfからコピーします。", "the default setting is loaded from lib/pref/pickpref.prf ."), nullptr };
+ _("基本的な自動拾い設定ファイルをlib/pref/picktype.prfからコピーします。", "the default setting is loaded from lib/pref/pickpref.prf .") };
const auto filename = pickpref_filename(player_ptr, PT_DEFAULT);
- for (int i = 0; messages[i]; i++) {
- msg_print(messages[i]);
+ for (const auto &message : messages) {
+ msg_print(message);
}
msg_print(nullptr);
char buf[1024];
path_build(buf, sizeof(buf), ANGBAND_DIR_USER, filename);
- FILE *user_fp;
- user_fp = angband_fopen(buf, FileOpenMode::WRITE);
+ auto *user_fp = angband_fopen(buf, FileOpenMode::WRITE);
if (!user_fp) {
return;
}
fprintf(user_fp, "#***\n");
- for (int i = 0; messages[i]; i++) {
- fprintf(user_fp, "#*** %s\n", messages[i]);
+ for (const auto &message : messages) {
+ fprintf(user_fp, "#*** %s\n", message.data());
}
fprintf(user_fp, "#***\n\n\n");
path_build(buf, sizeof(buf), ANGBAND_DIR_PREF, filename);
- FILE *pref_fp;
- pref_fp = angband_fopen(buf, FileOpenMode::READ);
-
+ auto *pref_fp = angband_fopen(buf, FileOpenMode::READ);
if (!pref_fp) {
angband_fclose(user_fp);
return;
{
char buf[1024];
path_build(buf, sizeof(buf), ANGBAND_DIR_USER, filename);
- FILE *fff;
- fff = angband_fopen(buf, FileOpenMode::WRITE);
+ auto *fff = angband_fopen(buf, FileOpenMode::WRITE);
if (!fff) {
return false;
}
{
char pref_file[1024];
path_build(pref_file, sizeof(pref_file), ANGBAND_DIR_USER, pickpref_filename(player_ptr, PT_WITH_PNAME));
- FILE *pref_fff;
- pref_fff = angband_fopen(pref_file, FileOpenMode::READ);
-
+ auto *pref_fff = angband_fopen(pref_file, FileOpenMode::READ);
if (!pref_fff) {
path_build(pref_file, sizeof(pref_file), ANGBAND_DIR_USER, pickpref_filename(player_ptr, PT_DEFAULT));
pref_fff = angband_fopen(pref_file, FileOpenMode::READ);
}
char tmp_file[1024];
- FILE *tmp_fff;
- tmp_fff = angband_fopen_temp(tmp_file, sizeof(tmp_file));
+ auto *tmp_fff = angband_fopen_temp(tmp_file, sizeof(tmp_file));
if (!tmp_fff) {
fclose(pref_fff);
msg_format(_("一時ファイル %s を作成できませんでした。", "Failed to create temporary file %s."), tmp_file);
return false;
}
- bool autoregister = false;
- int num = 0;
+ auto autoregister = false;
+ auto num = 0;
char buf[1024];
while (true) {
if (angband_fgets(pref_fff, buf, sizeof(buf))) {
char buf[1024];
char pref_file[1024];
- FILE *pref_fff;
path_build(pref_file, sizeof(pref_file), ANGBAND_DIR_USER, pickpref_filename(player_ptr, PT_WITH_PNAME));
- pref_fff = angband_fopen(pref_file, FileOpenMode::READ);
-
+ auto *pref_fff = angband_fopen(pref_file, FileOpenMode::READ);
if (!pref_fff) {
path_build(pref_file, sizeof(pref_file), ANGBAND_DIR_USER, pickpref_filename(player_ptr, PT_DEFAULT));
pref_fff = angband_fopen(pref_file, FileOpenMode::READ);
*/
static void display_diary(PlayerType *player_ptr)
{
- std::stringstream file_name;
- file_name << _("playrecord-", "playrec-") << savefile_base << ".txt";
+ std::stringstream ss;
+ ss << _("playrecord-", "playrec-") << savefile_base << ".txt";
char buf[1024];
- path_build(buf, sizeof(buf), ANGBAND_DIR_USER, file_name.str());
+ path_build(buf, sizeof(buf), ANGBAND_DIR_USER, ss.str());
PlayerClass pc(player_ptr);
const auto max_subtitles = diary_subtitles.size();
term_xtra(TERM_XTRA_REACT, 0);
term_redraw();
} else if (i == '2') {
- static concptr mark = "Colors";
+ constexpr auto mark = "Colors";
prt(_("コマンド: カラーの設定をファイルに書き出します", "Command: Dump colors"), 8, 0);
prt(_("ファイル: ", "File: "), 10, 0);
strnfmt(tmp, sizeof(tmp), "%s.prf", player_ptr->base_name);
int gv = angband_color_table[i][2];
int bv = angband_color_table[i][3];
- concptr name = _("未知", "unknown");
+ auto name = _("未知", "unknown");
if (!kv && !rv && !gv && !bv) {
continue;
}
{
int day, hour, min;
extract_day_hour_min(player_ptr, &day, &hour, &min);
-
std::string desc = _("変な時刻だ。", "It is a strange time.");
-
std::string day_buf = (day < MAX_DAYS) ? std::to_string(day) : "*****";
-
- msg_format(_("%s日目, 時刻は%d:%02d %sです。", "This is day %s. The time is %d:%02d %s."), day_buf.data(), (hour % 12 == 0) ? 12 : (hour % 12), min,
- (hour < 12) ? "AM" : "PM");
-
+ constexpr auto mes = _("%s日目, 時刻は%d:%02d %sです。", "This is day %s. The time is %d:%02d %s.");
+ msg_format(mes, day_buf.data(), (hour % 12 == 0) ? 12 : (hour % 12), min, (hour < 12) ? "AM" : "PM");
char buf[1024];
if (!randint0(10) || player_ptr->effects()->hallucination()->is_hallucinated()) {
path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, _("timefun_j.txt", "timefun.txt"));
path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, _("timenorm_j.txt", "timenorm.txt"));
}
- FILE *fff;
- fff = angband_fopen(buf, FileOpenMode::READ);
-
+ auto *fff = angband_fopen(buf, FileOpenMode::READ);
if (!fff) {
return;
}
- int full = hour * 100 + min;
- int start = 9999;
- int end = -9999;
- int num = 0;
+ auto full = hour * 100 + min;
+ auto start = 9999;
+ auto end = -9999;
+ auto num = 0;
while (!angband_fgets(fff, buf, sizeof(buf))) {
if (!buf[0] || (buf[0] == '#')) {
continue;
*/
static void macro_dump(FILE **fpp, concptr fname)
{
- static concptr mark = "Macro Dump";
+ constexpr auto mark = "Macro Dump";
char buf[1024];
path_build(buf, sizeof(buf), ANGBAND_DIR_USER, fname);
if (!open_auto_dump(fpp, buf, mark)) {
auto_dump_printf(*fpp, _("\n# 自動マクロセーブ\n\n", "\n# Automatic macro dump\n\n"));
- for (int i = 0; i < macro__num; i++) {
+ for (auto i = 0; i < macro__num; i++) {
ascii_to_text(buf, macro__act[i], sizeof(buf));
auto_dump_printf(*fpp, "A:%s\n", buf);
ascii_to_text(buf, macro__pat[i], sizeof(buf));
static errr keymap_dump(concptr fname)
{
FILE *auto_dump_stream;
- static concptr mark = "Keymap Dump";
char key[1024];
char buf[1024];
BIT_FLAGS mode;
}
path_build(buf, sizeof(buf), ANGBAND_DIR_USER, fname);
+ constexpr auto mark = "Keymap Dump";
if (!open_auto_dump(&auto_dump_stream, buf, mark)) {
return -1;
}
{
TERM_LEN wid, hgt;
term_get_size(&wid, &hgt);
- FILE *fff;
- fff = angband_fopen(filename, FileOpenMode::WRITE);
+ auto *fff = angband_fopen(filename, FileOpenMode::WRITE);
if (!check_screen_html_can_open(fff, filename, message)) {
return;
}
char buf[2048];
path_build(buf, sizeof(buf), ANGBAND_DIR_USER, "htmldump.prf");
- FILE *tmpfff;
- tmpfff = angband_fopen(buf, FileOpenMode::READ);
+ auto *tmpfff = angband_fopen(buf, FileOpenMode::READ);
write_html_header(tmpfff, fff, buf, sizeof(buf));
screen_dump_lines(wid, hgt, fff);
write_html_footer(tmpfff, fff, buf, sizeof(buf));
static void do_cmd_save_screen_html(void)
{
char buf[1024], tmp[256] = "screen.html";
-
if (!get_string(_("ファイル名: ", "File name: "), tmp, 80)) {
return;
}
- path_build(buf, sizeof(buf), ANGBAND_DIR_USER, tmp);
+ path_build(buf, sizeof(buf), ANGBAND_DIR_USER, tmp);
msg_print(nullptr);
-
do_cmd_save_screen_html_aux(buf, 1);
}
{
TERM_COLOR a = 0;
auto c = ' ';
- FILE *fff;
char buf[1024];
path_build(buf, sizeof(buf), ANGBAND_DIR_USER, "dump.txt");
- fff = angband_fopen(buf, FileOpenMode::WRITE);
+ auto *fff = angband_fopen(buf, FileOpenMode::WRITE);
if (!check_screen_text_can_open(fff, buf)) {
return false;
}
*/
void do_cmd_load_screen(void)
{
- FILE *fff;
char buf[1024];
TERM_LEN wid, hgt;
term_get_size(&wid, &hgt);
path_build(buf, sizeof(buf), ANGBAND_DIR_USER, "dump.txt");
- fff = angband_fopen(buf, FileOpenMode::READ);
+ auto *fff = angband_fopen(buf, FileOpenMode::READ);
if (!fff) {
msg_format(_("%s を開くことができませんでした。", "Failed to open %s."), buf);
msg_print(nullptr);
break;
}
case '1': {
- static concptr mark = "Monster attr/chars";
prt(_("コマンド: モンスターの[色/文字]をファイルに書き出します", "Command: Dump monster attr/chars"), 15, 0);
prt(_("ファイル: ", "File: "), 17, 0);
strnfmt(tmp, sizeof(tmp), "%s.prf", player_ptr->base_name);
}
path_build(buf, sizeof(buf), ANGBAND_DIR_USER, tmp);
+ constexpr auto mark = "Monster attr/chars";
if (!open_auto_dump(&auto_dump_stream, buf, mark)) {
continue;
}
break;
}
case '2': {
- static concptr mark = "Object attr/chars";
prt(_("コマンド: アイテムの[色/文字]をファイルに書き出します", "Command: Dump object attr/chars"), 15, 0);
prt(_("ファイル: ", "File: "), 17, 0);
strnfmt(tmp, sizeof(tmp), "%s.prf", player_ptr->base_name);
}
path_build(buf, sizeof(buf), ANGBAND_DIR_USER, tmp);
+ constexpr auto mark = "Object attr/chars";
if (!open_auto_dump(&auto_dump_stream, buf, mark)) {
continue;
}
break;
}
case '3': {
- static concptr mark = "Feature attr/chars";
prt(_("コマンド: 地形の[色/文字]をファイルに書き出します", "Command: Dump feature attr/chars"), 15, 0);
prt(_("ファイル: ", "File: "), 17, 0);
strnfmt(tmp, sizeof(tmp), "%s.prf", player_ptr->base_name);
}
path_build(buf, sizeof(buf), ANGBAND_DIR_USER, tmp);
+ constexpr auto mark = "Feature attr/chars";
if (!open_auto_dump(&auto_dump_stream, buf, mark)) {
continue;
}
*/
void close_game(PlayerType *player_ptr)
{
- bool do_send = true;
handle_stuff(player_ptr);
msg_print(nullptr);
flush();
kingly(player_ptr);
}
+ auto do_send = true;
if (!cheat_save || get_check(_("死んだデータをセーブしますか? ", "Save death? "))) {
update_playtime();
w_ptr->sf_play_time += w_ptr->play_time;
screen_save();
char buf[1024], out_val[256];
path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw");
-
highscore_fd = fd_open(buf, O_RDONLY);
-
if (highscore_fd < 0) {
msg_print(_("スコア・ファイルが使用できません。", "Score file unavailable."));
msg_print(nullptr);
/* rr9: TODO - pluralize the race */
prt(std::string(_("最高の", "The Greatest of all the ")).append(race_info[race_num].title), 5, 15);
path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw");
-
highscore_fd = fd_open(buf, O_RDONLY);
-
if (highscore_fd < 0) {
msg_print(_("スコア・ファイルが使用できません。", "Score file unavailable."));
msg_print(nullptr);
{
char buf[1024];
path_build(buf, sizeof(buf), ANGBAND_DIR_EDIT, name);
- FILE *fp = angband_fopen(buf, FileOpenMode::READ);
+ auto *fp = angband_fopen(buf, FileOpenMode::READ);
if (fp == nullptr) {
return PARSE_ERROR_GENERIC;
}
if (err != 0) {
concptr oops = (((err > 0) && (err < PARSE_ERROR_MAX)) ? err_str[err] : "unknown");
- msg_format("Error %d (%s) at line %d of '%s'.", err, oops, num, name);
+ msg_format("Error %d (%s) at line %d of '%s'.", err, oops, num, name.data());
msg_format(_("'%s'を解析中。", "Parsing '%s'."), buf);
msg_print(nullptr);
}
*/
static void parse_quest_info_aux(std::string_view file_name, std::set<QuestId> &key_list_ref)
{
-
auto push_set = [&key_list_ref, &file_name](auto q, auto line) {
if (q == QuestId::NONE) {
return;
*/
void spoil_random_artifact(PlayerType *player_ptr, concptr fname)
{
- store_type *store_ptr;
- ItemEntity *q_ptr;
char buf[1024];
path_build(buf, sizeof(buf), ANGBAND_DIR_USER, fname);
spoiler_file = angband_fopen(buf, FileOpenMode::WRITE);
for (const auto &[tval_list, name] : group_artifact_list) {
for (auto tval : tval_list) {
for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
- q_ptr = &player_ptr->inventory_list[i];
+ auto *q_ptr = &player_ptr->inventory_list[i];
spoil_random_artifact_aux(player_ptr, q_ptr, tval);
}
for (int i = 0; i < INVEN_PACK; i++) {
- q_ptr = &player_ptr->inventory_list[i];
+ auto *q_ptr = &player_ptr->inventory_list[i];
spoil_random_artifact_aux(player_ptr, q_ptr, tval);
}
- store_ptr = &towns_info[1].store[enum2i(StoreSaleType::HOME)];
+ const auto *store_ptr = &towns_info[1].store[enum2i(StoreSaleType::HOME)];
for (int i = 0; i < store_ptr->stock_num; i++) {
- q_ptr = &store_ptr->stock[i];
+ auto *q_ptr = &store_ptr->stock[i];
spoil_random_artifact_aux(player_ptr, q_ptr, tval);
}
store_ptr = &towns_info[1].store[enum2i(StoreSaleType::MUSEUM)];
for (int i = 0; i < store_ptr->stock_num; i++) {
- q_ptr = &store_ptr->stock[i];
+ auto *q_ptr = &store_ptr->stock[i];
spoil_random_artifact_aux(player_ptr, q_ptr, tval);
}
}
{
char buf[1024];
path_build(buf, sizeof(buf), ANGBAND_DIR_USER, name);
- int fd = fd_open(buf, O_RDONLY);
+ auto fd = fd_open(buf, O_RDONLY);
if (fd >= 0) {
std::string query = _("現存するファイル ", "Replace existing file ");
query.append(buf).append(_(" に上書きしますか? ", "? "));
{
char buf[1024];
path_build(buf, sizeof(buf), ANGBAND_DIR_DATA, _("z_info_j.raw", "z_info.raw"));
- int fd = fd_open(buf, O_RDONLY);
-
+ auto fd = fd_open(buf, O_RDONLY);
uint32_t count = 0;
if (counts_seek(player_ptr, fd, where, false) || fd_read(fd, (char *)(&count), sizeof(uint32_t))) {
count = 0;
}
(void)fd_close(fd);
-
return count;
}
}
safe_setuid_grab(player_ptr);
- errr err = fd_lock(fd, F_WRLCK);
+ auto err = fd_lock(fd, F_WRLCK);
safe_setuid_drop();
if (err) {
return 1;
void read_dead_file(char *buf, size_t buf_size)
{
path_build(buf, buf_size, ANGBAND_DIR_FILE, _("dead_j.txt", "dead.txt"));
-
- FILE *fp;
- fp = angband_fopen(buf, FileOpenMode::READ);
+ auto *fp = angband_fopen(buf, FileOpenMode::READ);
if (!fp) {
return;
}
void set_proxy(char *default_url, int default_port)
{
char buf[1024];
- size_t len;
- FILE *fp;
- char *s;
-
path_build(buf, sizeof(buf), ANGBAND_DIR_PREF, "proxy.prf");
-
- /* ファイルから設定を読む。 */
- fp = angband_fopen(buf, FileOpenMode::READ);
-
+ auto *fp = angband_fopen(buf, FileOpenMode::READ);
if (!fp) {
- /* ファイルが存在しない場合はデフォルトを設定 */
proxy = default_url;
proxy_port = default_port;
return;
}
angband_fclose(fp);
-
- /* ポインタを用意。 */
- s = buf;
+ auto *s = buf;
/* "http://" から始まっている場合はその部分をカットする。 */
#if defined(WINDOWS)
#endif
/* 文字列の長さを調べ、必要なメモリを確保 */
- len = strlen(s);
+ auto len = strlen(s);
proxy = static_cast<char *>(malloc(len + 1));
/* ポート番号があるかどうかを調べ、あればproxy_portに設定。 */
errr err1 = 0;
if (!only_user_dir) {
path_build(buf, sizeof(buf), ANGBAND_DIR_PREF, name);
-
err1 = process_pref_file_aux(player_ptr, buf, PREF_TYPE_NORMAL);
if (err1 > 0) {
return err1;
strnfmt(filename, sizeof(filename), "%s.amv", player_ptr->base_name);
if (get_string(_("ムービー記録ファイル: ", "Movie file name: "), filename, 80)) {
char buf[1024];
- int fd;
-
path_build(buf, sizeof(buf), ANGBAND_DIR_USER, filename);
-
- fd = fd_open(buf, O_RDONLY);
-
- /* Existing file */
+ auto fd = fd_open(buf, O_RDONLY);
if (fd >= 0) {
(void)fd_close(fd);
-
- /* Build query */
std::string query = _("現存するファイルに上>書きしますか? (", "Replace existing file ");
query.append(buf);
query.append(_(")", "? "));
-
- /* Ask */
if (!get_check(query)) {
return;
}
#include "util/bit-flags-calculator.h"
#include "view/display-messages.h"
#include "world/world.h"
+#include <sstream>
bool write_level; //!< @todo *抹殺* したい…
*/
static bool open_diary_file(FILE **fff, bool *disable_diary)
{
- std::string file_name = _("playrecord-", "playrec-");
- file_name.append(savefile_base).append(".txt");
+ std::stringstream ss;
+ ss << _("playrecord-", "playrec-") << savefile_base << ".txt";
char buf[1024];
- path_build(buf, sizeof(buf), ANGBAND_DIR_USER, file_name);
+ path_build(buf, sizeof(buf), ANGBAND_DIR_USER, ss.str());
*fff = angband_fopen(buf, FileOpenMode::APPEND);
if (*fff) {
return true;
char buf[MAIN_WIN_MAX_PATH];
BYTE wid, hgt, twid, thgt, ox, oy;
- concptr name;
- concptr name_mask = nullptr;
+ std::string name;
+ std::string name_mask("");
infGraph.delete_bitmap();
path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_GRAF, name);
infGraph.hBitmap = read_graphic(buf);
if (!infGraph.hBitmap) {
- plog_fmt(_("ビットマップ '%s' を読み込めません。", "Cannot read bitmap file '%s'"), name);
+ plog_fmt(_("ビットマップ '%s' を読み込めません。", "Cannot read bitmap file '%s'"), name.data());
ANGBAND_GRAF = "ascii";
current_graphics_mode = graphics_mode::GRAPHICS_NONE;
return current_graphics_mode;
infGraph.OffsetX = ox;
infGraph.OffsetY = oy;
- if (name_mask) {
+ if (name_mask.empty()) {
path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_GRAF, name_mask);
infGraph.hBitmapMask = read_graphic(buf);
if (!infGraph.hBitmapMask) {
- plog_fmt(_("ビットマップ '%s' を読み込めません。", "Cannot read bitmap file '%s'"), name_mask);
+ plog_fmt(_("ビットマップ '%s' を読み込めません。", "Cannot read bitmap file '%s'"), name_mask.data());
ANGBAND_GRAF = "ascii";
current_graphics_mode = graphics_mode::GRAPHICS_NONE;
return current_graphics_mode;
guess_convert_to_system_encoding(buf, MAIN_WIN_MAX_PATH);
#endif
const int num = tokenize_whitespace(buf, SAMPLE_MAX, tokens);
- for (int j = 0; j < num; j++) {
+ for (auto j = 0; j < num; j++) {
path_build(path, MAIN_WIN_MAX_PATH, dir, tokens[j]);
if (check_file(path)) {
filenames->push_back(string_make(tokens[j]));
return 0;
} // now playing
- concptr filename = music_cfg_data->get_rand(type, val);
+ auto filename = music_cfg_data->get_rand(type, val);
if (!filename) {
return 1;
} // no setting
*/
errr play_sound(int val, int volume)
{
- concptr filename = sound_cfg_data->get_rand(TERM_XTRA_SOUND, val);
+ auto filename = sound_cfg_data->get_rand(TERM_XTRA_SOUND, val);
if (!filename) {
return 1;
}
char buf[MAIN_WIN_MAX_PATH];
path_build(buf, MAIN_WIN_MAX_PATH, ANGBAND_DIR_XTRA_SOUND, filename);
-
if (play_sound_impl(buf, volume)) {
return 0;
}
}
(void)fd_close(fd);
-
if (!no_term) {
term_clear();
-
path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, _("news_j.txt", "news.txt"));
- FILE *fp;
- fp = angband_fopen(buf, FileOpenMode::READ);
+ auto *fp = angband_fopen(buf, FileOpenMode::READ);
if (fp) {
int i = 0;
while (0 == angband_fgets(fp, buf, sizeof(buf))) {
}
if (is_modified || !savefile_base[0]) {
- concptr s = savefile;
+ auto s = savefile;
while (true) {
- concptr t;
- t = angband_strstr(s, PATH_SEP);
+ auto t = angband_strstr(s, PATH_SEP);
if (!t) {
break;
}
void path_build(char *buf, int max, const std::filesystem::path &path, std::string_view file)
{
if (file[0] == '~') {
- (void)strnfmt(buf, max, "%s", file);
+ (void)strnfmt(buf, max, "%s", file.data());
} else if (prefix(file, PATH_SEP)) {
- (void)strnfmt(buf, max, "%s", file);
+ (void)strnfmt(buf, max, "%s", file.data());
} else if (!path.string()[0]) {
- (void)strnfmt(buf, max, "%s", file);
+ (void)strnfmt(buf, max, "%s", file.data());
} else {
const auto &path_str = path.string();
- (void)strnfmt(buf, max, "%s%s%s", path_str.data(), PATH_SEP, file);
+ (void)strnfmt(buf, max, "%s%s%s", path_str.data(), PATH_SEP, file.data());
}
}
{
char buf[1024];
path_build(buf, sizeof(buf), ANGBAND_DIR_USER, "opt_info.txt");
- FILE *fff;
- fff = angband_fopen(buf, FileOpenMode::APPEND);
+ auto *fff = angband_fopen(buf, FileOpenMode::APPEND);
if (fff == nullptr) {
msg_format(_("ファイル %s を開けませんでした。", "Failed to open file %s."), buf);
msg_print(nullptr);
#include <array>
#include <iterator>
#include <set>
+#include <sstream>
#include <string>
static constexpr std::array<std::string_view, 6> wiz_spell_stat = { {
return SpoilerOutputResultType::FILE_OPEN_FAILED;
}
- spoil_out(std::string("Monster Spoilers for ").append(get_version()).append("\n"));
-
+ std::stringstream ss;
+ ss << "Monster Spoilers for " << get_version() << '\n';
+ spoil_out(ss.str());
spoil_out("------------------------------------------\n\n");
-
for (auto r_idx : get_mon_evol_roots()) {
auto r_ptr = &monraces_info[r_idx];
fprintf(spoiler_file, _("[%d]: %s (レベル%d, '%c')\n", "[%d]: %s (Level %d, '%c')\n"), enum2i(r_idx), r_ptr->name.data(), (int)r_ptr->level, r_ptr->d_char);
static SpoilerOutputResultType spoil_player_spell(concptr fname)
{
char buf[1024];
-
path_build(buf, sizeof buf, ANGBAND_DIR_USER, fname);
spoiler_file = angband_fopen(buf, FileOpenMode::WRITE);
if (!spoiler_file) {
PlayerType dummy_p;
dummy_p.lev = 1;
-
- for (int c = 0; c < PLAYER_CLASS_TYPE_MAX; c++) {
+ for (auto c = 0; c < PLAYER_CLASS_TYPE_MAX; c++) {
auto class_ptr = &class_info[c];
spoil_out(format("[[Class: %s]]\n", class_ptr->title));
auto magic_ptr = &class_magics_info[c];
- concptr book_name = "なし";
+ auto book_name = "なし";
if (magic_ptr->spell_book != ItemKindType::NONE) {
ItemEntity book;
auto o_ptr = &book;