From 5db17187cd811bcdf1c2b977134607c594accefd Mon Sep 17 00:00:00 2001 From: Hourier Date: Sat, 4 Jul 2020 19:55:52 +0900 Subject: [PATCH] [Refactor] #40467 Changed names of static variables in load.c/save.c/init.c/wizard-spoiler.c for preparing refactoring load.c --- src/main/init.c | 36 ++++++------ src/savedata/load.c | 136 ++++++++++++++++++++------------------------ src/savedata/save.c | 48 ++++++++-------- src/wizard/wizard-spoiler.c | 110 +++++++++++++++++------------------ 4 files changed, 159 insertions(+), 171 deletions(-) diff --git a/src/main/init.c b/src/main/init.c index 09d3f44eb..b1fbd8e5d 100644 --- a/src/main/init.c +++ b/src/main/init.c @@ -1188,7 +1188,7 @@ static errr init_alloc(void) * Hack -- take notes on line 23 * @return なし */ -static void note(concptr str) +static void init_note(concptr str) { Term_erase(0, 23, 255); Term_putstr(20, 23, -1, TERM_WHITE, str); @@ -1369,12 +1369,12 @@ void init_angband(player_type *player_ptr, void(*process_autopick_file_command)( /*** Initialize some arrays ***/ /* Initialize misc. values */ - note(_("[変数を初期化しています...(その他)", "[Initializing values... (misc)]")); + init_note(_("[変数を初期化しています...(その他)", "[Initializing values... (misc)]")); if (init_misc(player_ptr)) quit(_("その他の変数を初期化できません", "Cannot initialize misc. values")); /* Initialize feature info */ #ifdef JP - note("[データの初期化中... (地形)]"); + init_note("[データの初期化中... (地形)]"); if (init_f_info(player_ptr)) quit("地形初期化不能"); if (init_feat_variables()) quit("地形初期化不能"); #else @@ -1384,26 +1384,26 @@ void init_angband(player_type *player_ptr, void(*process_autopick_file_command)( #endif /* Initialize object info */ - note(_("[データの初期化中... (アイテム)]", "[Initializing arrays... (objects)]")); + init_note(_("[データの初期化中... (アイテム)]", "[Initializing arrays... (objects)]")); if (init_k_info(player_ptr)) quit(_("アイテム初期化不能", "Cannot initialize objects")); /* Initialize artifact info */ - note(_("[データの初期化中... (伝説のアイテム)]", "[Initializing arrays... (artifacts)]")); + init_note(_("[データの初期化中... (伝説のアイテム)]", "[Initializing arrays... (artifacts)]")); if (init_a_info(player_ptr)) quit(_("伝説のアイテム初期化不能", "Cannot initialize artifacts")); /* Initialize ego-item info */ - note(_("[データの初期化中... (名のあるアイテム)]", "[Initializing arrays... (ego-items)]")); + init_note(_("[データの初期化中... (名のあるアイテム)]", "[Initializing arrays... (ego-items)]")); if (init_e_info(player_ptr)) quit(_("名のあるアイテム初期化不能", "Cannot initialize ego-items")); /* Initialize monster info */ - note(_("[データの初期化中... (モンスター)]", "[Initializing arrays... (monsters)]")); + init_note(_("[データの初期化中... (モンスター)]", "[Initializing arrays... (monsters)]")); if (init_r_info(player_ptr)) quit(_("モンスター初期化不能", "Cannot initialize monsters")); /* Initialize dungeon info */ - note(_("[データの初期化中... (ダンジョン)]", "[Initializing arrays... (dungeon)]")); + init_note(_("[データの初期化中... (ダンジョン)]", "[Initializing arrays... (dungeon)]")); if (init_d_info(player_ptr)) quit(_("ダンジョン初期化不能", "Cannot initialize dungeon")); { for (int i = 1; i < current_world_ptr->max_d_idx; i++) @@ -1412,45 +1412,45 @@ void init_angband(player_type *player_ptr, void(*process_autopick_file_command)( } /* Initialize magic info */ - note(_("[データの初期化中... (魔法)]", "[Initializing arrays... (magic)]")); + init_note(_("[データの初期化中... (魔法)]", "[Initializing arrays... (magic)]")); if (init_m_info(player_ptr)) quit(_("魔法初期化不能", "Cannot initialize magic")); /* Initialize weapon_exp info */ - note(_("[データの初期化中... (熟練度)]", "[Initializing arrays... (skill)]")); + init_note(_("[データの初期化中... (熟練度)]", "[Initializing arrays... (skill)]")); if (init_s_info(player_ptr)) quit(_("熟練度初期化不能", "Cannot initialize skill")); /* Initialize wilderness array */ - note(_("[配列を初期化しています... (荒野)]", "[Initializing arrays... (wilderness)]")); + init_note(_("[配列を初期化しています... (荒野)]", "[Initializing arrays... (wilderness)]")); if (init_wilderness()) quit(_("荒野を初期化できません", "Cannot initialize wilderness")); /* Initialize town array */ - note(_("[配列を初期化しています... (街)]", "[Initializing arrays... (towns)]")); + init_note(_("[配列を初期化しています... (街)]", "[Initializing arrays... (towns)]")); if (init_towns()) quit(_("街を初期化できません", "Cannot initialize towns")); /* Initialize building array */ - note(_("[配列を初期化しています... (建物)]", "[Initializing arrays... (buildings)]")); + init_note(_("[配列を初期化しています... (建物)]", "[Initializing arrays... (buildings)]")); if (init_buildings()) quit(_("建物を初期化できません", "Cannot initialize buildings")); /* Initialize quest array */ - note(_("[配列を初期化しています... (クエスト)]", "[Initializing arrays... (quests)]")); + init_note(_("[配列を初期化しています... (クエスト)]", "[Initializing arrays... (quests)]")); if (init_quests()) quit(_("クエストを初期化できません", "Cannot initialize quests")); /* Initialize vault info */ if (init_v_info(player_ptr)) quit(_("vault 初期化不能", "Cannot initialize vaults")); /* Initialize some other arrays */ - note(_("[データの初期化中... (その他)]", "[Initializing arrays... (other)]")); + init_note(_("[データの初期化中... (その他)]", "[Initializing arrays... (other)]")); if (init_other(player_ptr)) quit(_("その他のデータ初期化不能", "Cannot initialize other stuff")); /* Initialize some other arrays */ - note(_("[データの初期化中... (アロケーション)]", "[Initializing arrays... (alloc)]")); + init_note(_("[データの初期化中... (アロケーション)]", "[Initializing arrays... (alloc)]")); if (init_alloc()) quit(_("アロケーション・スタッフ初期化不能", "Cannot initialize alloc stuff")); /*** Load default user pref files ***/ /* Initialize feature info */ - note(_("[ユーザー設定ファイルを初期化しています...]", "[Initializing user pref files...]")); + init_note(_("[ユーザー設定ファイルを初期化しています...]", "[Initializing user pref files...]")); /* Access the "basic" pref file */ strcpy(buf, "pref.prf"); @@ -1464,7 +1464,7 @@ void init_angband(player_type *player_ptr, void(*process_autopick_file_command)( /* Process that file */ process_pref_file(player_ptr, buf, process_autopick_file_command); - note(_("[初期化終了]", "[Initialization complete]")); + init_note(_("[初期化終了]", "[Initialization complete]")); } diff --git a/src/savedata/load.c b/src/savedata/load.c index aef1b6ac2..6f7f6d599 100644 --- a/src/savedata/load.c +++ b/src/savedata/load.c @@ -96,35 +96,23 @@ /* Old hidden trap flag */ static const BIT_FLAGS CAVE_TRAP = 0x8000; -/* Old quests */ -#define OLD_QUEST_WATER_CAVE 18 +static const int OLD_QUEST_WATER_CAVE = 18; // 湖の洞窟. +static const int QUEST_OLD_CASTLE = 27; // 古い城. +static const int QUEST_ROYAL_CRYPT = 28; // 王家の墓. -/* Quest constants */ -#define QUEST_OLD_CASTLE 27 -#define QUEST_ROYAL_CRYPT 28 +static FILE *loading_savefile; -/* - * Local "savefile" pointer - */ -static FILE *fff; - -/* - * Hack -- old "encryption" byte - */ -static byte xor_byte; +/* Old "encryption" byte */ +static byte load_xor_byte; -/* - * Hack -- simple "checksum" on the actual values - */ +/* Simple "checksum" on the actual values */ static u32b v_check = 0L; -/* - * Hack -- simple "checksum" on the encoded bytes - */ +/* Simple "checksum" on the encoded bytes */ static u32b x_check = 0L; /* - * Hack -- Japanese Kanji code + * Japanese Kanji code * 0: Unknown * 1: ASCII * 2: EUC @@ -139,7 +127,7 @@ static byte kanji_code = 0; * @details * Avoid the top two lines, to avoid interference with "msg_print()". */ -static void note(concptr msg) +static void load_note(concptr msg) { static TERM_LEN y = 2; prt(msg, y, 0); @@ -158,12 +146,12 @@ static void note(concptr msg) */ static byte sf_get(void) { - byte c = getc(fff) & 0xFF; - byte v = c ^ xor_byte; - xor_byte = c; + byte c = getc(loading_savefile) & 0xFF; + byte v = c ^ load_xor_byte; + load_xor_byte = c; v_check += v; - x_check += xor_byte; + x_check += load_xor_byte; return v; } @@ -273,7 +261,7 @@ static void strip_bytes(int n) } /*! - * @brief アイテムオブジェクト1件を読み込む(変愚ver1.5.0以前) / Read an object (Old method) + * @brief アイテムオブジェクト1件を読み込む(変愚ver1.5.0以前) / Read an object (Old method) * @param o_ptr アイテムオブジェクト読み取り先ポインタ * @return なし * @details @@ -2185,7 +2173,7 @@ static errr rd_inventory(player_type *player_ptr) } if (player_ptr->inven_cnt == INVEN_PACK) { - note(_("持ち物の中のアイテムが多すぎる!", "Too many items in the inventory")); + load_note(_("持ち物の中のアイテムが多すぎる!", "Too many items in the inventory")); return (54); } @@ -2430,14 +2418,14 @@ static errr rd_dungeon_old(player_type *player_ptr) u16b limit; rd_u16b(&limit); if (limit > current_world_ptr->max_o_idx) { - note(format(_("アイテムの配列が大きすぎる(%d)!", "Too many (%d) object entries!"), limit)); + load_note(format(_("アイテムの配列が大きすぎる(%d)!", "Too many (%d) object entries!"), limit)); return (151); } for (int i = 1; i < limit; i++) { OBJECT_IDX o_idx = o_pop(floor_ptr); if (i != o_idx) { - note(format(_("アイテム配置エラー (%d <> %d)", "Object allocation error (%d <> %d)"), i, o_idx)); + load_note(format(_("アイテム配置エラー (%d <> %d)", "Object allocation error (%d <> %d)"), i, o_idx)); return (152); } @@ -2460,7 +2448,7 @@ static errr rd_dungeon_old(player_type *player_ptr) rd_u16b(&limit); if (limit > current_world_ptr->max_m_idx) { - note(format(_("モンスターの配列が大きすぎる(%d)!", "Too many (%d) monster entries!"), limit)); + load_note(format(_("モンスターの配列が大きすぎる(%d)!", "Too many (%d) monster entries!"), limit)); return (161); } @@ -2469,7 +2457,7 @@ static errr rd_dungeon_old(player_type *player_ptr) monster_type *m_ptr; m_idx = m_pop(floor_ptr); if (i != m_idx) { - note(format(_("モンスター配置エラー (%d <> %d)", "Monster allocation error (%d <> %d)"), i, m_idx)); + load_note(format(_("モンスター配置エラー (%d <> %d)", "Monster allocation error (%d <> %d)"), i, m_idx)); return (162); } @@ -2765,31 +2753,31 @@ static errr rd_dungeon(player_type *player_ptr) switch (err) { case 151: - note(_("アイテムの配列が大きすぎる!", "Too many object entries!")); + load_note(_("アイテムの配列が大きすぎる!", "Too many object entries!")); break; case 152: - note(_("アイテム配置エラー", "Object allocation error")); + load_note(_("アイテム配置エラー", "Object allocation error")); break; case 161: - note(_("モンスターの配列が大きすぎる!", "Too many monster entries!")); + load_note(_("モンスターの配列が大きすぎる!", "Too many monster entries!")); break; case 162: - note(_("モンスター配置エラー", "Monster allocation error")); + load_note(_("モンスター配置エラー", "Monster allocation error")); break; case 171: - note(_("保存されたフロアのダンジョンデータが壊れています!", "Dungeon data of saved floors are broken!")); + load_note(_("保存されたフロアのダンジョンデータが壊れています!", "Dungeon data of saved floors are broken!")); break; case 182: - note(_("テンポラリ・ファイルを作成できません!", "Failed to make temporary files!")); + load_note(_("テンポラリ・ファイルを作成できません!", "Failed to make temporary files!")); break; case 183: - note(_("Error 183", "Error 183")); + load_note(_("Error 183", "Error 183")); break; } @@ -2807,7 +2795,7 @@ static errr rd_savefile_new_aux(player_type *creature_ptr) u32b o_x_check, o_v_check; strip_bytes(4); - xor_byte = current_world_ptr->sf_extra; + load_xor_byte = current_world_ptr->sf_extra; v_check = 0L; x_check = 0L; @@ -2817,7 +2805,7 @@ static errr rd_savefile_new_aux(player_type *creature_ptr) rd_byte(¤t_world_ptr->h_ver_minor); rd_byte(¤t_world_ptr->h_ver_major); - note(format(_("バージョン %d.%d.%d.%d のセーブ・ファイルをロード中...", "Loading a %d.%d.%d.%d savefile..."), + load_note(format(_("バージョン %d.%d.%d.%d のセーブ・ファイルをロード中...", "Loading a %d.%d.%d.%d savefile..."), (current_world_ptr->h_ver_major > 9) ? current_world_ptr->h_ver_major - 10 : current_world_ptr->h_ver_major, current_world_ptr->h_ver_minor, current_world_ptr->h_ver_patch, current_world_ptr->h_ver_extra)); @@ -2838,15 +2826,15 @@ static errr rd_savefile_new_aux(player_type *creature_ptr) rd_randomizer(); if (arg_fiddle) - note(_("乱数情報をロードしました", "Loaded Randomizer Info")); + load_note(_("乱数情報をロードしました", "Loaded Randomizer Info")); rd_options(); if (arg_fiddle) - note(_("オプションをロードしました", "Loaded Option Flags")); + load_note(_("オプションをロードしました", "Loaded Option Flags")); rd_messages(); if (arg_fiddle) - note(_("メッセージをロードしました", "Loaded Messages")); + load_note(_("メッセージをロードしました", "Loaded Messages")); /* ランダムクエストのモンスターを確定するために試行する回数 / Maximum number of tries for selection of a proper quest monster */ const int MAX_TRIES = 100; @@ -2862,7 +2850,7 @@ static errr rd_savefile_new_aux(player_type *creature_ptr) rd_u16b(&tmp16u); if (tmp16u > max_r_idx) { - note(format(_("モンスターの種族が多すぎる(%u)!", "Too many (%u) monster races!"), tmp16u)); + load_note(format(_("モンスターの種族が多すぎる(%u)!", "Too many (%u) monster races!"), tmp16u)); return (21); } @@ -2871,11 +2859,11 @@ static errr rd_savefile_new_aux(player_type *creature_ptr) } if (arg_fiddle) - note(_("モンスターの思い出をロードしました", "Loaded Monster Memory")); + load_note(_("モンスターの思い出をロードしました", "Loaded Monster Memory")); rd_u16b(&tmp16u); if (tmp16u > max_k_idx) { - note(format(_("アイテムの種類が多すぎる(%u)!", "Too many (%u) object kinds!"), tmp16u)); + load_note(format(_("アイテムの種類が多すぎる(%u)!", "Too many (%u) object kinds!"), tmp16u)); return (22); } @@ -2886,7 +2874,7 @@ static errr rd_savefile_new_aux(player_type *creature_ptr) k_ptr->tried = (tmp8u & 0x02) ? TRUE : FALSE; } if (arg_fiddle) - note(_("アイテムの記録をロードしました", "Loaded Object Memory")); + load_note(_("アイテムの記録をロードしました", "Loaded Object Memory")); /* 2.1.3 or newer version */ { @@ -2897,7 +2885,7 @@ static errr rd_savefile_new_aux(player_type *creature_ptr) rd_u16b(&max_towns_load); if (max_towns_load > max_towns) { - note(format(_("町が多すぎる(%u)!", "Too many (%u) towns!"), max_towns_load)); + load_note(format(_("町が多すぎる(%u)!", "Too many (%u) towns!"), max_towns_load)); return (23); } @@ -2909,7 +2897,7 @@ static errr rd_savefile_new_aux(player_type *creature_ptr) } if (max_quests_load > max_q_idx) { - note(format(_("クエストが多すぎる(%u)!", "Too many (%u) quests!"), max_quests_load)); + load_note(format(_("クエストが多すぎる(%u)!", "Too many (%u) quests!"), max_quests_load)); return (23); } @@ -3011,7 +2999,7 @@ static errr rd_savefile_new_aux(player_type *creature_ptr) rd_s32b(&wild_y_size); if ((wild_x_size > current_world_ptr->max_wild_x) || (wild_y_size > current_world_ptr->max_wild_y)) { - note(format(_("荒野が大きすぎる(%u/%u)!", "Wilderness is too big (%u/%u)!"), wild_x_size, wild_y_size)); + load_note(format(_("荒野が大きすぎる(%u/%u)!", "Wilderness is too big (%u/%u)!"), wild_x_size, wild_y_size)); return (23); } @@ -3023,11 +3011,11 @@ static errr rd_savefile_new_aux(player_type *creature_ptr) } if (arg_fiddle) - note(_("クエスト情報をロードしました", "Loaded Quests")); + load_note(_("クエスト情報をロードしました", "Loaded Quests")); rd_u16b(&tmp16u); if (tmp16u > max_a_idx) { - note(format(_("伝説のアイテムが多すぎる(%u)!", "Too many (%u) artifacts!"), tmp16u)); + load_note(format(_("伝説のアイテムが多すぎる(%u)!", "Too many (%u) artifacts!"), tmp16u)); return (24); } @@ -3049,18 +3037,18 @@ static errr rd_savefile_new_aux(player_type *creature_ptr) } if (arg_fiddle) - note(_("伝説のアイテムをロードしました", "Loaded Artifacts")); + load_note(_("伝説のアイテムをロードしました", "Loaded Artifacts")); rd_extra(creature_ptr); if (creature_ptr->energy_need < -999) creature_ptr->timewalk = TRUE; if (arg_fiddle) - note(_("特別情報をロードしました", "Loaded extra information")); + load_note(_("特別情報をロードしました", "Loaded extra information")); rd_u16b(&tmp16u); if (tmp16u > PY_MAX_LEVEL) { - note(format(_("ヒットポイント配列が大きすぎる(%u)!", "Too many (%u) hitpoint entries!"), tmp16u)); + load_note(format(_("ヒットポイント配列が大きすぎる(%u)!", "Too many (%u) hitpoint entries!"), tmp16u)); return (25); } @@ -3128,7 +3116,7 @@ static errr rd_savefile_new_aux(player_type *creature_ptr) } if (rd_inventory(creature_ptr)) { - note(_("持ち物情報を読み込むことができません", "Unable to read inventory")); + load_note(_("持ち物情報を読み込むことができません", "Unable to read inventory")); return (21); } @@ -3200,9 +3188,9 @@ static errr rd_savefile_new_aux(player_type *creature_ptr) } if (!creature_ptr->is_dead) { - note(_("ダンジョン復元中...", "Restoring Dungeon...")); + load_note(_("ダンジョン復元中...", "Restoring Dungeon...")); if (rd_dungeon(creature_ptr)) { - note(_("ダンジョンデータ読み込み失敗", "Error reading dungeon data")); + load_note(_("ダンジョンデータ読み込み失敗", "Error reading dungeon data")); return (34); } @@ -3227,14 +3215,14 @@ static errr rd_savefile_new_aux(player_type *creature_ptr) n_v_check = v_check; rd_u32b(&o_v_check); if (o_v_check != n_v_check) { - note(_("チェックサムがおかしい", "Invalid checksum")); + load_note(_("チェックサムがおかしい", "Invalid checksum")); return 11; } n_x_check = x_check; rd_u32b(&o_x_check); if (o_x_check != n_x_check) { - note(_("エンコードされたチェックサムがおかしい", "Invalid encoded checksum")); + load_note(_("エンコードされたチェックサムがおかしい", "Invalid encoded checksum")); return 11; } @@ -3249,15 +3237,15 @@ static errr rd_savefile_new_aux(player_type *creature_ptr) errr rd_savefile_new(player_type *player_ptr) { safe_setuid_grab(player_ptr); - fff = angband_fopen(savefile, "rb"); + loading_savefile = angband_fopen(savefile, "rb"); safe_setuid_drop(); - if (!fff) + if (!loading_savefile) return -1; errr err = rd_savefile_new_aux(player_ptr); - if (ferror(fff)) + if (ferror(loading_savefile)) err = -1; - angband_fclose(fff); + angband_fclose(loading_savefile); return err; } @@ -3272,7 +3260,7 @@ static bool load_floor_aux(player_type *player_ptr, saved_floor_type *sf_ptr) u32b n_x_check, n_v_check; u32b o_x_check, o_v_check; - xor_byte = 0; + load_xor_byte = 0; byte tmp8u; rd_byte(&tmp8u); @@ -3339,8 +3327,8 @@ bool load_floor(player_type *player_ptr, saved_floor_type *sf_ptr, BIT_FLAGS mod byte old_h_ver_patch = 0; byte old_h_ver_extra = 0; if (mode & SLF_SECOND) { - old_fff = fff; - old_xor_byte = xor_byte; + old_fff = loading_savefile; + old_xor_byte = load_xor_byte; old_v_check = v_check; old_x_check = x_check; old_h_ver_major = current_world_ptr->h_ver_major; @@ -3353,18 +3341,18 @@ bool load_floor(player_type *player_ptr, saved_floor_type *sf_ptr, BIT_FLAGS mod sprintf(floor_savefile, "%s.F%02d", savefile, (int)sf_ptr->savefile_id); safe_setuid_grab(player_ptr); - fff = angband_fopen(floor_savefile, "rb"); + loading_savefile = angband_fopen(floor_savefile, "rb"); safe_setuid_drop(); bool is_save_successful = TRUE; - if (!fff) + if (!loading_savefile) is_save_successful = FALSE; if (is_save_successful) { is_save_successful = load_floor_aux(player_ptr, sf_ptr); - if (ferror(fff)) + if (ferror(loading_savefile)) is_save_successful = FALSE; - angband_fclose(fff); + angband_fclose(loading_savefile); safe_setuid_grab(player_ptr); if (!(mode & SLF_NO_KILL)) @@ -3374,8 +3362,8 @@ bool load_floor(player_type *player_ptr, saved_floor_type *sf_ptr, BIT_FLAGS mod } if (mode & SLF_SECOND) { - fff = old_fff; - xor_byte = old_xor_byte; + loading_savefile = old_fff; + load_xor_byte = old_xor_byte; v_check = old_v_check; x_check = old_x_check; current_world_ptr->h_ver_major = old_h_ver_major; diff --git a/src/savedata/save.c b/src/savedata/save.c index 6a612e1be..cf91a1972 100644 --- a/src/savedata/save.c +++ b/src/savedata/save.c @@ -51,8 +51,8 @@ * Some "local" parameters, used to help write savefiles */ -static FILE *fff; /* Current save "file" */ -static byte xor_byte; /* Simple encryption */ +static FILE *saving_savefile; /* Current save "file" */ +static byte save_xor_byte; /* Simple encryption */ static u32b v_stamp = 0L; /* A simple "checksum" on the actual values */ static u32b x_stamp = 0L; /* A simple "checksum" on the encoded bytes */ @@ -64,12 +64,12 @@ static u32b x_stamp = 0L; /* A simple "checksum" on the encoded bytes */ static void sf_put(byte v) { /* Encode the value, write a character */ - xor_byte ^= v; - (void)putc((int)xor_byte, fff); + save_xor_byte ^= v; + (void)putc((int)save_xor_byte, saving_savefile); /* Maintain the checksum info */ v_stamp += v; - x_stamp += xor_byte; + x_stamp += save_xor_byte; } /*! @@ -1223,13 +1223,13 @@ static bool wr_savefile_new(player_type *player_ptr) /*** Actually write the file ***/ /* Dump the file header */ - xor_byte = 0; + save_xor_byte = 0; wr_byte(FAKE_VER_MAJOR); - xor_byte = 0; + save_xor_byte = 0; wr_byte(FAKE_VER_MINOR); - xor_byte = 0; + save_xor_byte = 0; wr_byte(FAKE_VER_PATCH); - xor_byte = 0; + save_xor_byte = 0; /* Initial value of xor_byte */ byte tmp8u = (byte)Rand_external(256); @@ -1458,7 +1458,7 @@ static bool wr_savefile_new(player_type *player_ptr) /* Write the "encoded checksum" */ wr_u32b(x_stamp); - if (ferror(fff) || (fflush(fff) == EOF)) + if (ferror(saving_savefile) || (fflush(saving_savefile) == EOF)) return FALSE; return TRUE; } @@ -1484,7 +1484,7 @@ static bool save_player_aux(player_type *player_ptr, char *name) safe_setuid_drop(); bool is_save_successful = FALSE; - fff = NULL; + saving_savefile = NULL; if (fd >= 0) { /* Close the "fd" */ (void)fd_close(fd); @@ -1493,19 +1493,19 @@ static bool save_player_aux(player_type *player_ptr, char *name) safe_setuid_grab(player_ptr); /* Open the savefile */ - fff = angband_fopen(name, "wb"); + saving_savefile = angband_fopen(name, "wb"); /* Drop permissions */ safe_setuid_drop(); /* Successful open */ - if (fff) { + if (saving_savefile) { /* Write the savefile */ if (wr_savefile_new(player_ptr)) is_save_successful = TRUE; /* Attempt to close it */ - if (angband_fclose(fff)) + if (angband_fclose(saving_savefile)) is_save_successful = FALSE; } @@ -1769,7 +1769,7 @@ static bool save_floor_aux(player_type *player_ptr, saved_floor_type *sf_ptr) /*** Actually write the file ***/ /* Initial value of xor_byte */ byte tmp8u = (byte)randint0(256); - xor_byte = 0; + save_xor_byte = 0; wr_byte(tmp8u); /* Reset the checksum */ @@ -1788,7 +1788,7 @@ static bool save_floor_aux(player_type *player_ptr, saved_floor_type *sf_ptr) /* Write the "encoded checksum" */ wr_u32b(x_stamp); - if (ferror(fff) || (fflush(fff) == EOF)) + if (ferror(saving_savefile) || (fflush(saving_savefile) == EOF)) return FALSE; return TRUE; } @@ -1814,8 +1814,8 @@ bool save_floor(player_type *player_ptr, saved_floor_type *sf_ptr, BIT_FLAGS mod /* We have one file already opened */ else { /* Backup original values */ - old_fff = fff; - old_xor_byte = xor_byte; + old_fff = saving_savefile; + old_xor_byte = save_xor_byte; old_v_stamp = v_stamp; old_x_stamp = x_stamp; } @@ -1835,7 +1835,7 @@ bool save_floor(player_type *player_ptr, saved_floor_type *sf_ptr, BIT_FLAGS mod /* Attempt to save the player */ /* No file yet */ - fff = NULL; + saving_savefile = NULL; /* Grab permissions */ safe_setuid_grab(player_ptr); @@ -1855,19 +1855,19 @@ bool save_floor(player_type *player_ptr, saved_floor_type *sf_ptr, BIT_FLAGS mod safe_setuid_grab(player_ptr); /* Open the savefile */ - fff = angband_fopen(floor_savefile, "wb"); + saving_savefile = angband_fopen(floor_savefile, "wb"); /* Drop permissions */ safe_setuid_drop(); /* Successful open */ - if (fff) { + if (saving_savefile) { /* Write the savefile */ if (save_floor_aux(player_ptr, sf_ptr)) is_save_successful = TRUE; /* Attempt to close it */ - if (angband_fclose(fff)) + if (angband_fclose(saving_savefile)) is_save_successful = FALSE; } @@ -1889,8 +1889,8 @@ bool save_floor(player_type *player_ptr, saved_floor_type *sf_ptr, BIT_FLAGS mod /* We have one file already opened */ else { /* Restore original values */ - fff = old_fff; - xor_byte = old_xor_byte; + saving_savefile = old_fff; + save_xor_byte = old_xor_byte; v_stamp = old_v_stamp; x_stamp = old_x_stamp; } diff --git a/src/wizard/wizard-spoiler.c b/src/wizard/wizard-spoiler.c index f2dd83ce4..0998e3b7c 100644 --- a/src/wizard/wizard-spoiler.c +++ b/src/wizard/wizard-spoiler.c @@ -102,7 +102,7 @@ typedef struct obj_desc_list { /* * The spoiler file being created */ -static FILE *fff = NULL; +static FILE *spoiler_file = NULL; /*! * @brief シンボル職の記述名を返す / @@ -253,16 +253,16 @@ static void spoil_obj_desc(player_type *player_ptr, concptr fname) char dam[80]; path_build(buf, sizeof(buf), ANGBAND_DIR_USER, fname); - fff = angband_fopen(buf, "w"); + spoiler_file = angband_fopen(buf, "w"); - if (!fff) { + if (!spoiler_file) { msg_print("Cannot create spoiler file."); return; } - fprintf(fff, "Spoiler File -- Basic Items (Hengband %d.%d.%d.%d)\n\n\n", FAKE_VER_MAJOR - 10, FAKE_VER_MINOR, FAKE_VER_PATCH, FAKE_VER_EXTRA); - fprintf(fff, "%-37s%8s%7s%5s %40s%9s\n", "Description", "Dam/AC", "Wgt", "Lev", "Chance", "Cost"); - fprintf(fff, "%-37s%8s%7s%5s %40s%9s\n", "-------------------------------------", "------", "---", "---", "----------------", "----"); + fprintf(spoiler_file, "Spoiler File -- Basic Items (Hengband %d.%d.%d.%d)\n\n\n", FAKE_VER_MAJOR - 10, FAKE_VER_MINOR, FAKE_VER_PATCH, FAKE_VER_EXTRA); + fprintf(spoiler_file, "%-37s%8s%7s%5s %40s%9s\n", "Description", "Dam/AC", "Wgt", "Lev", "Chance", "Cost"); + fprintf(spoiler_file, "%-37s%8s%7s%5s %40s%9s\n", "-------------------------------------", "------", "---", "---", "----------------", "----"); for (i = 0; TRUE; i++) { if (group_item[i].name) { if (n) { @@ -288,12 +288,12 @@ static void spoil_obj_desc(player_type *player_ptr, concptr fname) } } - fprintf(fff, "\n\n%s\n\n", group_item[group_start].name); + fprintf(spoiler_file, "\n\n%s\n\n", group_item[group_start].name); for (s = 0; s < n; s++) { DEPTH e; PRICE v; kind_info(player_ptr, buf, dam, wgt, chance, &e, &v, who[s]); - fprintf(fff, " %-35s%8s%7s%5d %-40s%9ld\n", buf, dam, wgt, (int)e, chance, (long)(v)); + fprintf(spoiler_file, " %-35s%8s%7s%5d %-40s%9ld\n", buf, dam, wgt, (int)e, chance, (long)(v)); } n = 0; @@ -314,7 +314,7 @@ static void spoil_obj_desc(player_type *player_ptr, concptr fname) } } - if (ferror(fff) || angband_fclose(fff)) { + if (ferror(spoiler_file) || angband_fclose(spoiler_file)) { msg_print("Cannot close spoiler file."); return; } @@ -332,7 +332,7 @@ static void spoil_obj_desc(player_type *player_ptr, concptr fname) static void spoiler_out_n_chars(int n, char c) { while (--n >= 0) - fputc(c, fff); + fputc(c, spoiler_file); } /*! @@ -351,9 +351,9 @@ static void spoiler_blanklines(int n) { spoiler_out_n_chars(n, '\n'); } */ static void spoiler_underline(concptr str) { - fprintf(fff, "%s\n", str); + fprintf(spoiler_file, "%s\n", str); spoiler_out_n_chars(strlen(str), '-'); - fprintf(fff, "\n"); + fprintf(spoiler_file, "\n"); } /*! @@ -689,10 +689,10 @@ static void spoiler_outlist(concptr header, concptr *list, char separator) } else { if (line_len > 1 && line[line_len - 1] == ' ' && line[line_len - 2] == LIST_SEP) { line[line_len - 2] = '\0'; - fprintf(fff, "%s\n", line); + fprintf(spoiler_file, "%s\n", line); sprintf(line, "%s%s", INDENT1, buf); } else { - fprintf(fff, "%s\n", line); + fprintf(spoiler_file, "%s\n", line); sprintf(line, "%s%s", INDENT2, buf); } @@ -703,7 +703,7 @@ static void spoiler_outlist(concptr header, concptr *list, char separator) break; } - fprintf(fff, "%s\n", line); + fprintf(spoiler_file, "%s\n", line); } /*! @@ -716,7 +716,7 @@ static void spoiler_print_art(obj_desc_list *art_ptr) { pval_info_type *pval_ptr = &art_ptr->pval_info; char buf[80]; - fprintf(fff, "%s\n", art_ptr->description); + fprintf(spoiler_file, "%s\n", art_ptr->description); if (pval_ptr->pval_desc[0]) { sprintf(buf, _("%sの修正:", "%s to"), pval_ptr->pval_desc); spoiler_outlist(buf, pval_ptr->pval_affects, ITEM_SEP); @@ -730,12 +730,12 @@ static void spoiler_print_art(obj_desc_list *art_ptr) spoiler_outlist("", art_ptr->misc_magic, LIST_SEP); if (art_ptr->addition[0]) - fprintf(fff, _("%s追加: %s\n", "%sAdditional %s\n"), INDENT1, art_ptr->addition); + fprintf(spoiler_file, _("%s追加: %s\n", "%sAdditional %s\n"), INDENT1, art_ptr->addition); if (art_ptr->activation) - fprintf(fff, _("%s発動: %s\n", "%sActivates for %s\n"), INDENT1, art_ptr->activation); + fprintf(spoiler_file, _("%s発動: %s\n", "%sActivates for %s\n"), INDENT1, art_ptr->activation); - fprintf(fff, "%s%s\n\n", INDENT1, art_ptr->misc_desc); + fprintf(spoiler_file, "%s%s\n\n", INDENT1, art_ptr->misc_desc); } /*! @@ -785,9 +785,9 @@ static void spoil_artifact(player_type *player_ptr, concptr fname) char buf[1024]; path_build(buf, sizeof(buf), ANGBAND_DIR_USER, fname); - fff = angband_fopen(buf, "w"); + spoiler_file = angband_fopen(buf, "w"); - if (!fff) { + if (!spoiler_file) { msg_print("Cannot create spoiler file."); return; } @@ -815,7 +815,7 @@ static void spoil_artifact(player_type *player_ptr, concptr fname) } } - if (ferror(fff) || angband_fclose(fff)) { + if (ferror(spoiler_file) || angband_fclose(spoiler_file)) { msg_print("Cannot close spoiler file."); return; } @@ -843,17 +843,17 @@ static void spoil_mon_desc(player_type *player_ptr, concptr fname) char hp[80]; char exp[80]; path_build(buf, sizeof(buf), ANGBAND_DIR_USER, fname); - fff = angband_fopen(buf, "w"); - if (!fff) { + spoiler_file = angband_fopen(buf, "w"); + if (!spoiler_file) { msg_print("Cannot create spoiler file."); return; } C_MAKE(who, max_r_idx, MONRACE_IDX); - fprintf(fff, "Monster Spoilers for Hengband Version %d.%d.%d\n", FAKE_VER_MAJOR - 10, FAKE_VER_MINOR, FAKE_VER_PATCH); - fprintf(fff, "------------------------------------------\n\n"); - fprintf(fff, " %-38.38s%4s%4s%4s%7s%5s %11.11s\n", "Name", "Lev", "Rar", "Spd", "Hp", "Ac", "Visual Info"); - fprintf(fff, "%-42.42s%4s%4s%4s%7s%5s %11.11s\n", "--------", "---", "---", "---", "--", "--", "-----------"); + fprintf(spoiler_file, "Monster Spoilers for Hengband Version %d.%d.%d\n", FAKE_VER_MAJOR - 10, FAKE_VER_MINOR, FAKE_VER_PATCH); + fprintf(spoiler_file, "------------------------------------------\n\n"); + fprintf(spoiler_file, " %-38.38s%4s%4s%4s%7s%5s %11.11s\n", "Name", "Lev", "Rar", "Spd", "Hp", "Ac", "Visual Info"); + fprintf(spoiler_file, "%-42.42s%4s%4s%4s%7s%5s %11.11s\n", "--------", "---", "---", "---", "--", "--", "-----------"); for (i = 1; i < max_r_idx; i++) { monster_race *r_ptr = &r_info[i]; if (r_ptr->name) @@ -886,12 +886,12 @@ static void spoil_mon_desc(player_type *player_ptr, concptr fname) sprintf(exp, "%ld", (long)(r_ptr->mexp)); sprintf(exp, "%s '%c'", attr_to_text(r_ptr), r_ptr->d_char); - fprintf(fff, "%-42.42s%4s%4s%4s%7s%5s %11.11s\n", nam, lev, rar, spd, hp, ac, exp); + fprintf(spoiler_file, "%-42.42s%4s%4s%4s%7s%5s %11.11s\n", nam, lev, rar, spd, hp, ac, exp); } - fprintf(fff, "\n"); + fprintf(spoiler_file, "\n"); C_KILL(who, max_r_idx, s16b); - if (ferror(fff) || angband_fclose(fff)) { + if (ferror(spoiler_file) || angband_fclose(spoiler_file)) { msg_print("Cannot close spoiler file."); return; } @@ -921,7 +921,7 @@ static void spoil_out(concptr str) static bool waiting_output = FALSE; if (!str) { if (waiting_output) { - fputs(roff_waiting_buf, fff); + fputs(roff_waiting_buf, spoiler_file); waiting_output = FALSE; } @@ -931,10 +931,10 @@ static void spoil_out(concptr str) roff_p--; if (roff_p == roff_buf) - fprintf(fff, "\n"); + fprintf(spoiler_file, "\n"); else { *(roff_p + 1) = '\0'; - fprintf(fff, "%s\n\n", roff_buf); + fprintf(spoiler_file, "%s\n\n", roff_buf); } roff_p = roff_buf; @@ -962,9 +962,9 @@ static void spoil_out(concptr str) #endif if (waiting_output) { - fputs(roff_waiting_buf, fff); + fputs(roff_waiting_buf, spoiler_file); if (!wrap) - fputc('\n', fff); + fputc('\n', spoiler_file); waiting_output = FALSE; } @@ -1027,7 +1027,7 @@ static void spoil_out(concptr str) } if (!waiting_output) - fprintf(fff, "%s\n", roff_buf); + fprintf(spoiler_file, "%s\n", roff_buf); else strcpy(roff_waiting_buf, roff_buf); @@ -1088,8 +1088,8 @@ static void spoil_mon_info(player_type *player_ptr, concptr fname) u16b why = 2; MONRACE_IDX *who; path_build(buf, sizeof(buf), ANGBAND_DIR_USER, fname); - fff = angband_fopen(buf, "w"); - if (!fff) { + spoiler_file = angband_fopen(buf, "w"); + if (!spoiler_file) { msg_print("Cannot create spoiler file."); return; } @@ -1151,7 +1151,7 @@ static void spoil_mon_info(player_type *player_ptr, concptr fname) } C_KILL(who, max_r_idx, s16b); - if (ferror(fff) || angband_fclose(fff)) { + if (ferror(spoiler_file) || angband_fclose(spoiler_file)) { msg_print("Cannot close spoiler file."); return; } @@ -1219,8 +1219,8 @@ static void spoil_mon_evol(player_type *player_ptr, concptr fname) int **evol_tree, i, j, n, r_idx; int *evol_tree_zero; /* For C_KILL() */ path_build(buf, sizeof buf, ANGBAND_DIR_USER, fname); - fff = angband_fopen(buf, "w"); - if (!fff) { + spoiler_file = angband_fopen(buf, "w"); + if (!spoiler_file) { msg_print("Cannot create spoiler file."); return; } @@ -1272,20 +1272,20 @@ static void spoil_mon_evol(player_type *player_ptr, concptr fname) continue; r_ptr = &r_info[r_idx]; - fprintf(fff, _("[%d]: %s (レベル%d, '%c')\n", "[%d]: %s (Level %d, '%c')\n"), r_idx, r_name + r_ptr->name, (int)r_ptr->level, r_ptr->d_char); + fprintf(spoiler_file, _("[%d]: %s (レベル%d, '%c')\n", "[%d]: %s (Level %d, '%c')\n"), r_idx, r_name + r_ptr->name, (int)r_ptr->level, r_ptr->d_char); for (n = 1; r_ptr->next_exp; n++) { - fprintf(fff, "%*s-(%ld)-> ", n * 2, "", (long int)r_ptr->next_exp); - fprintf(fff, "[%d]: ", r_ptr->next_r_idx); + fprintf(spoiler_file, "%*s-(%ld)-> ", n * 2, "", (long int)r_ptr->next_exp); + fprintf(spoiler_file, "[%d]: ", r_ptr->next_r_idx); r_ptr = &r_info[r_ptr->next_r_idx]; - fprintf(fff, _("%s (レベル%d, '%c')\n", "%s (Level %d, '%c')\n"), r_name + r_ptr->name, (int)r_ptr->level, r_ptr->d_char); + fprintf(spoiler_file, _("%s (レベル%d, '%c')\n", "%s (Level %d, '%c')\n"), r_name + r_ptr->name, (int)r_ptr->level, r_ptr->d_char); } - fputc('\n', fff); + fputc('\n', spoiler_file); } C_KILL(evol_tree_zero, max_r_idx * (MAX_EVOL_DEPTH + 1), int); C_KILL(evol_tree, max_r_idx, int *); - if (ferror(fff) || angband_fclose(fff)) { + if (ferror(spoiler_file) || angband_fclose(spoiler_file)) { msg_print("Cannot close spoiler file."); return; } @@ -1372,9 +1372,9 @@ static void spoiler_print_randart(object_type *o_ptr, obj_desc_list *art_ptr) { pval_info_type *pval_ptr = &art_ptr->pval_info; char buf[80]; - fprintf(fff, "%s\n", art_ptr->description); + fprintf(spoiler_file, "%s\n", art_ptr->description); if (!object_is_fully_known(o_ptr)) { - fprintf(fff, _("%s不明\n", "%sUnknown\n"), INDENT1); + fprintf(spoiler_file, _("%s不明\n", "%sUnknown\n"), INDENT1); } else { if (pval_ptr->pval_desc[0]) { sprintf(buf, _("%sの修正:", "%s to"), pval_ptr->pval_desc); @@ -1388,11 +1388,11 @@ static void spoiler_print_randart(object_type *o_ptr, obj_desc_list *art_ptr) spoiler_outlist(_("維持:", "Sustain"), art_ptr->sustains, ITEM_SEP); spoiler_outlist("", art_ptr->misc_magic, LIST_SEP); if (art_ptr->activation) { - fprintf(fff, _("%s発動: %s\n", "%sActivates for %s\n"), INDENT1, art_ptr->activation); + fprintf(spoiler_file, _("%s発動: %s\n", "%sActivates for %s\n"), INDENT1, art_ptr->activation); } } - fprintf(fff, "%s%s\n\n", INDENT1, art_ptr->misc_desc); + fprintf(spoiler_file, "%s%s\n\n", INDENT1, art_ptr->misc_desc); } /*! @@ -1425,8 +1425,8 @@ void spoil_random_artifact(player_type *creature_ptr, concptr fname) object_type *q_ptr; char buf[1024]; path_build(buf, sizeof(buf), ANGBAND_DIR_USER, fname); - fff = angband_fopen(buf, "w"); - if (!fff) { + spoiler_file = angband_fopen(buf, "w"); + if (!spoiler_file) { msg_print("Cannot create list file."); return; } @@ -1457,7 +1457,7 @@ void spoil_random_artifact(player_type *creature_ptr, concptr fname) } } - if (ferror(fff) || angband_fclose(fff)) { + if (ferror(spoiler_file) || angband_fclose(spoiler_file)) { msg_print("Cannot close list file."); return; } -- 2.11.0