OSDN Git Service

[Refactor] #38997 calc_android_exp() に player_type * 引数を追加.
[hengband/hengband.git] / src / files.c
index 405fecd..1f4a655 100644 (file)
@@ -23,6 +23,7 @@
 
 #include "bldg.h"
 
+#include "cmd-magiceat.h"
 #include "cmd-dump.h"
 #include "world.h"
 #include "player-race.h"
@@ -149,11 +150,11 @@ void safe_setuid_grab(void)
 
 #  ifdef SAFE_SETUID_POSIX
 
-       if (setuid(player_euid) != 0)
+       if (setuid(p_ptr->player_egid) != 0)
        {
                quit(_("setuid(): 正しく許可が取れません!", "setuid(): cannot set permissions correctly!"));
        }
-       if (setgid(player_egid) != 0)
+       if (setgid(p_ptr->player_egid) != 0)
        {
                quit(_("setgid(): 正しく許可が取れません!", "setgid(): cannot set permissions correctly!"));
        }
@@ -1273,8 +1274,6 @@ errr process_pref_file(concptr name)
        char buf[1024];
 
        errr err1, err2;
-
-       /* Build the filename */
        path_build(buf, sizeof(buf), ANGBAND_DIR_PREF, name);
 
        /* Process the system pref file */
@@ -1283,8 +1282,6 @@ errr process_pref_file(concptr name)
        /* Stop at parser errors, but not at non-existing file */
        if (err1 > 0) return err1;
 
-
-       /* Build the filename */
        path_build(buf, sizeof(buf), ANGBAND_DIR_USER, name);
        
        /* Process the user pref file */
@@ -1369,8 +1366,6 @@ errr check_time_init(void)
 
        char    buf[1024];
 
-
-       /* Build the filename */
        path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, "time.txt");
 
        /* Open the file */
@@ -1495,8 +1490,6 @@ errr check_load_init(void)
        char    temphost[MAXHOSTNAMELEN+1];
        char    thishost[MAXHOSTNAMELEN+1];
 
-
-       /* Build the filename */
        path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, "load.txt");
 
        /* Open the "load" file */
@@ -2742,7 +2735,7 @@ static void tim_player_flags(BIT_FLAGS flgs[TR_FLAG_SIZE])
        if (IS_FAST() || p_ptr->slow)
                add_flag(flgs, TR_SPEED);
 
-       if (IS_OPPOSE_ACID() && !(p_ptr->special_defense & DEFENSE_ACID) && !(prace_is_(RACE_YEEK) && (p_ptr->lev > 19)))
+       if (IS_OPPOSE_ACID() && !(p_ptr->special_defense & DEFENSE_ACID) && !(PRACE_IS_(p_ptr, RACE_YEEK) && (p_ptr->lev > 19)))
                add_flag(flgs, TR_RES_ACID);
        if (IS_OPPOSE_ELEC() && !(p_ptr->special_defense & DEFENSE_ELEC))
                add_flag(flgs, TR_RES_ELEC);
@@ -2941,13 +2934,13 @@ static void player_immunity(BIT_FLAGS flgs[TR_FLAG_SIZE])
        for (i = 0; i < TR_FLAG_SIZE; i++)
                flgs[i] = 0L;
 
-       if (prace_is_(RACE_SPECTRE))
+       if (PRACE_IS_(p_ptr, RACE_SPECTRE))
                add_flag(flgs, TR_RES_NETHER);
-       if (p_ptr->mimic_form == MIMIC_VAMPIRE || prace_is_(RACE_VAMPIRE))
+       if (p_ptr->mimic_form == MIMIC_VAMPIRE || PRACE_IS_(p_ptr, RACE_VAMPIRE))
                add_flag(flgs, TR_RES_DARK);
        if (p_ptr->mimic_form == MIMIC_DEMON_LORD)
                add_flag(flgs, TR_RES_FIRE);
-       else if (prace_is_(RACE_YEEK) && p_ptr->lev > 19)
+       else if (PRACE_IS_(p_ptr, RACE_YEEK) && p_ptr->lev > 19)
                add_flag(flgs, TR_RES_ACID);
 }
 
@@ -3000,11 +2993,11 @@ static void player_vuln_flags(BIT_FLAGS flgs[TR_FLAG_SIZE])
                add_flag(flgs, TR_RES_FIRE);
                add_flag(flgs, TR_RES_COLD);
        }
-       if (prace_is_(RACE_ANDROID))
+       if (PRACE_IS_(p_ptr, RACE_ANDROID))
                add_flag(flgs, TR_RES_ELEC);
-       if (prace_is_(RACE_ENT))
+       if (PRACE_IS_(p_ptr, RACE_ENT))
                add_flag(flgs, TR_RES_FIRE);
-       if (prace_is_(RACE_VAMPIRE) || prace_is_(RACE_S_FAIRY) ||
+       if (PRACE_IS_(p_ptr, RACE_VAMPIRE) || PRACE_IS_(p_ptr, RACE_S_FAIRY) ||
            (p_ptr->mimic_form == MIMIC_VAMPIRE))
                add_flag(flgs, TR_RES_LITE);
 }
@@ -3093,12 +3086,12 @@ static void display_flag_aux(TERM_LEN row, TERM_LEN col, concptr header,
                }
                else if (flag1 == TR_LITE_1)
                {
-                       if (have_dark_flag(flgs))
+                       if (HAVE_DARK_FLAG(flgs))
                        {
                                c_put_str(TERM_L_DARK, "+", row, col);
                                header_color = TERM_WHITE;
                        }
-                       else if (have_lite_flag(flgs))
+                       else if (HAVE_LITE_FLAG(flgs))
                        {
                                c_put_str(TERM_WHITE, "+", row, col);
                                header_color = TERM_WHITE;
@@ -3613,7 +3606,7 @@ static void display_player_stat_info(void)
                if ((p_ptr->stat_max[i] > 18) && (p_ptr->stat_top[i] <= 18))
                        e_adj = p_ptr->stat_top[i] - (p_ptr->stat_max[i] - 19) / 10 - 19;
 
-               if (prace_is_(RACE_ENT))
+               if (PRACE_IS_(p_ptr, RACE_ENT))
                {
                        switch (i)
                        {
@@ -5050,8 +5043,6 @@ errr file_character(concptr name)
        int             fd = -1;
        FILE            *fff = NULL;
        char            buf[1024];
-
-       /* Build the filename */
        path_build(buf, sizeof(buf), ANGBAND_DIR_USER, name);
 
        /* File type is "TEXT" */
@@ -5299,22 +5290,14 @@ bool show_file(bool show_version, concptr name, concptr what, int line, BIT_FLAG
        Term_get_size(&wid, &hgt);
        rows = hgt - 4;
 
-       /* Wipe finder */
        strcpy(finder_str, "");
-
-       /* Wipe shower */
        strcpy(shower_str, "");
-
-       /* Wipe caption */
        strcpy(caption, "");
-
-       /* Wipe the hooks */
        for (i = 0; i < 68; i++)
        {
                hook[i][0] = '\0';
        }
 
-       /* Copy the filename */
        strcpy(filename, name);
 
        n = strlen(filename);
@@ -5333,7 +5316,6 @@ bool show_file(bool show_version, concptr name, concptr what, int line, BIT_FLAG
        /* Redirect the name */
        name = filename;
 
-       /* Hack */
        if (what)
        {
                /* Caption */
@@ -5351,8 +5333,6 @@ bool show_file(bool show_version, concptr name, concptr what, int line, BIT_FLAG
        {
                /* Caption */
                sprintf(caption, _("ヘルプ・ファイル'%s'", "Help file '%s'"), name);
-
-               /* Build the filename */
                path_build(path, sizeof(path), ANGBAND_DIR_HELP, name);
 
                /* Open the file */
@@ -5364,8 +5344,6 @@ bool show_file(bool show_version, concptr name, concptr what, int line, BIT_FLAG
        {
                /* Caption */
                sprintf(caption, _("スポイラー・ファイル'%s'", "Info file '%s'"), name);
-
-               /* Build the filename */
                path_build(path, sizeof(path), ANGBAND_DIR_INFO, name);
 
                /* Open the file */
@@ -5375,7 +5353,6 @@ bool show_file(bool show_version, concptr name, concptr what, int line, BIT_FLAG
        /* Look in "info" */
        if (!fff)
        {
-               /* Build the filename */
                path_build(path, sizeof(path), ANGBAND_DIR, name);
 
                for (i = 0; path[i]; i++)
@@ -5743,8 +5720,6 @@ bool show_file(bool show_version, concptr name, concptr what, int line, BIT_FLAG
 
                        if (!get_string(_("ファイル名: ", "File name: "), xtmp, 80)) continue;
                        my_fclose(fff);
-
-                       /* Build the filename */
                        path_build(buff, sizeof(buff), ANGBAND_DIR_USER, xtmp);
 
                        /* Hack -- Re-Open the file */
@@ -5946,14 +5921,12 @@ void process_player_name(bool sf)
                strcpy(savefile_base, p_ptr->base_name);
 
 #ifdef SAVEFILE_USE_UID
-               /* Rename the savefile, using the player_uid and p_ptr->base_name */
-               (void)sprintf(temp, "%d.%s", player_uid, p_ptr->base_name);
+               /* Rename the savefile, using the p_ptr->player_uid and p_ptr->base_name */
+               (void)sprintf(temp, "%d.%s", p_ptr->player_uid, p_ptr->base_name);
 #else
                /* Rename the savefile, using the p_ptr->base_name */
                (void)sprintf(temp, "%s", p_ptr->base_name);
 #endif
-
-               /* Build the filename */
                path_build(savefile, sizeof(savefile), ANGBAND_DIR_SAVE, temp);
        }
 
@@ -6147,8 +6120,6 @@ static void make_bones(void)
 
                        /* "Bones" name */
                        sprintf(tmp, "bone.%03d", current_floor_ptr->dun_level);
-
-                       /* Build the filename */
                        path_build(str, sizeof(str), ANGBAND_DIR_BONE, tmp);
 
                        /* Attempt to open the bones file */
@@ -6225,8 +6196,6 @@ void print_tomb(void)
                int    extra_line = 0;
 #endif
                Term_clear();
-
-               /* Build the filename */
                path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, _("dead_j.txt", "dead.txt"));
 
                /* Open the News file */
@@ -6496,7 +6465,7 @@ void show_info(void)
        if (p_ptr->equip_cnt)
        {
                Term_clear();
-               (void)show_equip(0, USE_FULL);
+               (void)show_equip(0, USE_FULL, 0);
                prt(_("装備していたアイテム: -続く-", "You are using: -more-"), 0, 0);
 
                if (inkey() == ESCAPE) return;
@@ -6506,7 +6475,7 @@ void show_info(void)
        if (p_ptr->inven_cnt)
        {
                Term_clear();
-               (void)show_inven(0, USE_FULL);
+               (void)show_inven(0, USE_FULL, 0);
                prt(_("持っていたアイテム: -続く-", "You are carrying: -more-"), 0, 0);
 
                if (inkey() == ESCAPE) return;
@@ -6619,8 +6588,6 @@ errr get_rnd_line(concptr file_name, int entry, char *output)
        int     counter, test;
        int     line_num = 0;
 
-
-       /* Build the filename */
        path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, file_name);
 
        /* Open the file */
@@ -6748,8 +6715,6 @@ errr process_autopick_file(concptr name)
        char buf[1024];
 
        errr err = 0;
-
-       /* Build the filename */
        path_build(buf, sizeof(buf), ANGBAND_DIR_USER, name);
 
        err = process_pref_file_aux(buf, PREF_TYPE_AUTOPICK);
@@ -6769,8 +6734,6 @@ errr process_histpref_file(concptr name)
        char buf[1024];
        errr err = 0;
        bool old_character_xtra = current_world_ptr->character_xtra;
-
-       /* Build the filename */
        path_build(buf, sizeof(buf), ANGBAND_DIR_USER, name);
 
        /* Hack -- prevent modification birth options in this file */
@@ -6798,7 +6761,7 @@ static errr counts_seek(int fd, u32b where, bool flag)
        int i;
 
 #ifdef SAVEFILE_USE_UID
-       (void)sprintf(temp1, "%d.%s.%d%d%d", player_uid, savefile_base, p_ptr->pclass, p_ptr->pseikaku, p_ptr->age);
+       (void)sprintf(temp1, "%d.%s.%d%d%d", p_ptr->player_uid, savefile_base, p_ptr->pclass, p_ptr->pseikaku, p_ptr->age);
 #else
        (void)sprintf(temp1, "%s.%d%d%d", savefile_base, p_ptr->pclass, p_ptr->pseikaku, p_ptr->age);
 #endif