OSDN Git Service

[Refactor] #38995 world_type 構造体を作成し、 max_wild_x/y を取り込む。 / Create world_type structu...
authordeskull <deskull@users.sourceforge.jp>
Wed, 27 Feb 2019 23:10:53 +0000 (08:10 +0900)
committerdeskull <deskull@users.sourceforge.jp>
Wed, 27 Feb 2019 23:10:53 +0000 (08:10 +0900)
src/bldg.c
src/cmd4.c
src/dungeon.c
src/externs.h
src/files.c
src/init1.c
src/load.c
src/save.c
src/types.h
src/variable.c
src/wild.c

index 8673295..769690c 100644 (file)
@@ -3699,9 +3699,9 @@ bool tele_town(void)
                break;
        }
 
-       for (y = 0; y < max_wild_y; y++)
+       for (y = 0; y < current_world_ptr->max_wild_y; y++)
        {
-               for (x = 0; x < max_wild_x; x++)
+               for (x = 0; x < current_world_ptr->max_wild_x; x++)
                {
                        if(wilderness[y][x].town == (i-'a'+1))
                        {
index d6cd31c..e45a429 100644 (file)
@@ -8083,7 +8083,7 @@ static void do_cmd_knowledge_home(void)
        GAME_TEXT o_name[MAX_NLEN];
        concptr         paren = ")";
 
-       process_dungeon_file("w_info.txt", 0, 0, max_wild_y, max_wild_x);
+       process_dungeon_file("w_info.txt", 0, 0, current_world_ptr->max_wild_y, current_world_ptr->max_wild_x);
 
        /* Open a new file */
        fff = my_fopen_temp(file_name, 1024);
index 613132c..79bc6f6 100644 (file)
@@ -5825,7 +5825,7 @@ void play_game(bool new_game)
                highscore_fd = fd_open(buf, O_RDWR);
 
                /* 町名消失バグ対策(#38205) Init the wilderness */
-               process_dungeon_file("w_info.txt", 0, 0, max_wild_y, max_wild_x);
+               process_dungeon_file("w_info.txt", 0, 0, current_world_ptr->max_wild_y, current_world_ptr->max_wild_x);
 
                /* Handle score, show Top scores */
                success = send_world_score(TRUE);
@@ -6012,7 +6012,7 @@ void play_game(bool new_game)
        {
                /* Init the wilderness */
 
-               process_dungeon_file("w_info.txt", 0, 0, max_wild_y, max_wild_x);
+               process_dungeon_file("w_info.txt", 0, 0, current_world_ptr->max_wild_y, current_world_ptr->max_wild_x);
 
                /* Init the town */
                init_flags = INIT_ONLY_BUILDINGS;
index a7bbcba..6e14c01 100644 (file)
@@ -258,6 +258,7 @@ extern byte angband_color_table[256][4];
 extern const concptr angband_sound_name[SOUND_MAX];
 extern const concptr angband_music_basic_name[MUSIC_BASIC_MAX];
 extern floor_type *current_floor_ptr;
+extern world_type *current_world_ptr;
 extern saved_floor_type saved_floors[MAX_SAVED_FLOORS];
 extern FLOOR_IDX max_floor_id;
 extern u32b saved_floor_file_sign;
@@ -336,8 +337,6 @@ extern FEAT_IDX max_f_idx;
 extern ARTIFACT_IDX max_a_idx;
 extern EGO_IDX max_e_idx;
 extern DUNGEON_IDX max_d_idx;
-extern POSITION max_wild_x;
-extern POSITION max_wild_y;
 extern quest_type *quest;
 extern char quest_text[10][80];
 extern int quest_text_line;
index f80b927..a1c24ac 100644 (file)
@@ -4896,7 +4896,7 @@ static void dump_aux_home_museum(FILE *fff)
        store_type  *st_ptr;
 
        /* Do we need it?? */
-       /* process_dungeon_file("w_info.txt", 0, 0, max_wild_y, max_wild_x); */
+       /* process_dungeon_file("w_info.txt", 0, 0, current_world_ptr->max_wild_y, current_world_ptr->max_wild_x); */
 
        /* Print the home */
        st_ptr = &town_info[1].store[STORE_HOME];
index 08bcfbd..a73a429 100644 (file)
@@ -4391,10 +4391,10 @@ static errr process_dungeon_file_aux(char *buf, int ymin, int xmin, int ymax, in
                        {
                                /* Maximum wild_x_size */
                                if (zz[0][1] == 'X')
-                                       max_wild_x = atoi(zz[1]);
+                                       current_world_ptr->max_wild_x = atoi(zz[1]);
                                /* Maximum wild_y_size */
                                if (zz[0][1] == 'Y')
-                                       max_wild_y = atoi(zz[1]);
+                                       current_world_ptr->max_wild_y = atoi(zz[1]);
                        }
 
                        return (0);
index 6424fa7..aef1ce2 100644 (file)
@@ -3707,7 +3707,7 @@ static errr rd_savefile_new_aux(void)
                rd_s32b(&wild_y_size);
 
                /* Incompatible save files */
-               if ((wild_x_size > max_wild_x) || (wild_y_size > max_wild_y))
+               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));
                        return (23);
index 032d047..b75627a 100644 (file)
@@ -1411,13 +1411,13 @@ static bool wr_savefile_new(void)
        wr_byte(p_ptr->wild_mode);
        wr_byte(ambush_flag);
 
-       wr_s32b(max_wild_x);
-       wr_s32b(max_wild_y);
+       wr_s32b(current_world_ptr->max_wild_x);
+       wr_s32b(current_world_ptr->max_wild_y);
 
        /* Dump the wilderness seeds */
-       for (i = 0; i < max_wild_x; i++)
+       for (i = 0; i < current_world_ptr->max_wild_x; i++)
        {
-               for (j = 0; j < max_wild_y; j++)
+               for (j = 0; j < current_world_ptr->max_wild_y; j++)
                {
                        wr_u32b(wilderness[j][i].seed);
                }
index 14bea7b..8d5c844 100644 (file)
@@ -1895,3 +1895,10 @@ typedef struct {
 
 } floor_type;
 
+typedef struct {
+       /*
+        * Maximum size of the wilderness
+        */
+       POSITION max_wild_x;
+       POSITION max_wild_y;
+} world_type;
index 0481b1c..153cb94 100644 (file)
@@ -461,8 +461,6 @@ const concptr angband_music_basic_name[MUSIC_BASIC_MAX] =
 floor_type floor;
 floor_type *current_floor_ptr = &floor;
 
-
-
 /*
  * The array of saved floors
  */
@@ -475,6 +473,10 @@ saved_floor_type saved_floors[MAX_SAVED_FLOORS];
 FLOOR_IDX max_floor_id;
 
 
+world_type world;
+world_type *current_world_ptr = &world;
+
+
 /*
  * Sign for current process used in temporal files.
  * Actually it is the start time of current process.
@@ -754,11 +756,7 @@ EGO_IDX max_e_idx;
  */
 DUNGEON_IDX max_d_idx;
 
-/*
- * Maximum size of the wilderness
- */
-POSITION max_wild_x;
-POSITION max_wild_y;
+
 
 /*
  * Quest info
index 5064911..0cb2a8f 100644 (file)
@@ -464,7 +464,7 @@ void wilderness_gen(void)
 
        /* Init the wilderness */
 
-       process_dungeon_file("w_info.txt", 0, 0, max_wild_y, max_wild_x);
+       process_dungeon_file("w_info.txt", 0, 0, current_world_ptr->max_wild_y, current_world_ptr->max_wild_x);
 
        x = p_ptr->wilderness_x;
        y = p_ptr->wilderness_y;
@@ -703,11 +703,11 @@ void wilderness_gen_small(void)
        }
 
        /* Init the wilderness */
-       process_dungeon_file("w_info.txt", 0, 0, max_wild_y, max_wild_x);
+       process_dungeon_file("w_info.txt", 0, 0, current_world_ptr->max_wild_y, current_world_ptr->max_wild_x);
 
        /* Fill the map */
-       for (i = 0; i < max_wild_x; i++)
-       for (j = 0; j < max_wild_y; j++)
+       for (i = 0; i < current_world_ptr->max_wild_x; i++)
+       for (j = 0; j < current_world_ptr->max_wild_y; j++)
        {
                if (wilderness[j][i].town && (wilderness[j][i].town != NO_TOWN))
                {
@@ -725,8 +725,8 @@ void wilderness_gen_small(void)
                current_floor_ptr->grid_array[j][i].info |= (CAVE_GLOW | CAVE_MARK);
        }
 
-       current_floor_ptr->height = (s16b) max_wild_y;
-       current_floor_ptr->width = (s16b) max_wild_x;
+       current_floor_ptr->height = (s16b) current_world_ptr->max_wild_y;
+       current_floor_ptr->width = (s16b) current_world_ptr->max_wild_x;
 
        if (current_floor_ptr->height > MAX_HGT) current_floor_ptr->height = MAX_HGT;
        if (current_floor_ptr->width > MAX_WID) current_floor_ptr->width = MAX_WID;
@@ -872,9 +872,9 @@ errr parse_line_wilderness(char *buf, int ymin, int xmin, int ymax, int xmax, in
                                p_ptr->wilderness_x = atoi(zz[1]);
                                
                                if ((p_ptr->wilderness_x < 1) ||
-                                   (p_ptr->wilderness_x > max_wild_x) ||
+                                   (p_ptr->wilderness_x > current_world_ptr->max_wild_x) ||
                                    (p_ptr->wilderness_y < 1) ||
-                                   (p_ptr->wilderness_y > max_wild_y))
+                                   (p_ptr->wilderness_y > current_world_ptr->max_wild_y))
                                {
                                        return (PARSE_ERROR_OUT_OF_BOUNDS);
                                }
@@ -917,9 +917,9 @@ void seed_wilderness(void)
        POSITION x, y;
 
        /* Init wilderness seeds */
-       for (x = 0; x < max_wild_x; x++)
+       for (x = 0; x < current_world_ptr->max_wild_x; x++)
        {
-               for (y = 0; y < max_wild_y; y++)
+               for (y = 0; y < current_world_ptr->max_wild_y; y++)
                {
                        wilderness[y][x].seed = randint0(0x10000000);
                        wilderness[y][x].entrance = 0;
@@ -944,12 +944,12 @@ errr init_wilderness(void)
        int i;
 
        /* Allocate the wilderness (two-dimension array) */
-       C_MAKE(wilderness, max_wild_y, wilderness_type_ptr);
-       C_MAKE(wilderness[0], max_wild_x * max_wild_y, wilderness_type);
+       C_MAKE(wilderness, current_world_ptr->max_wild_y, wilderness_type_ptr);
+       C_MAKE(wilderness[0], current_world_ptr->max_wild_x * current_world_ptr->max_wild_y, wilderness_type);
 
        /* Init the other pointers */
-       for (i = 1; i < max_wild_y; i++)
-               wilderness[i] = wilderness[0] + i * max_wild_x;
+       for (i = 1; i < current_world_ptr->max_wild_y; i++)
+               wilderness[i] = wilderness[0] + i * current_world_ptr->max_wild_x;
 
        generate_encounter = FALSE;