OSDN Git Service

Leon氏の勧めに従って、Vanillaのコードと同様に各ソースファイルの頭の
[hengband/hengband.git] / src / wild.c
index 224f2a7..a34d5b0 100644 (file)
@@ -1,20 +1,61 @@
 /* File: wild.c */
 
-/* Purpose: Wilderness generation */
-
 /*
- * Copyright (c) 1989, 1999 James E. Wilson, Robert A. Koeneke,
+ * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke,
  * Robert Ruehlmann
  *
- * This software may be copied and distributed for educational, research, and
- * not for profit purposes provided that this copyright and statement are
- * included in all such copies.
+ * This software may be copied and distributed for educational, research,
+ * and not for profit purposes provided that this copyright and statement
+ * are included in all such copies.  Other copyrights may also apply.
  */
 
+/* Purpose: Wilderness generation */
+
 #include "angband.h"
 
 
 /*
+ * Fill the arrays of floors and walls in the good proportions
+ */
+void set_floor_and_wall(byte type)
+{
+       static byte cur_type = 255;
+       int i;
+
+       /* Already filled */
+       if (cur_type == type) return;
+
+       cur_type = type;
+
+       for (i = 0; i < 100; i++)
+       {
+               int lim1, lim2, lim3;
+
+               lim1 = d_info[type].floor_percent1;
+               lim2 = lim1 + d_info[type].floor_percent2;
+               lim3 = lim2 + d_info[type].floor_percent3;
+
+               if (i < lim1)
+                       floor_type[i] = d_info[type].floor1;
+               else if (i < lim2)
+                       floor_type[i] = d_info[type].floor2;
+               else if (i < lim3)
+                       floor_type[i] = d_info[type].floor3;
+
+               lim1 = d_info[type].fill_percent1;
+               lim2 = lim1 + d_info[type].fill_percent2;
+               lim3 = lim2 + d_info[type].fill_percent3;
+               if (i < lim1)
+                       fill_type[i] = d_info[type].fill_type1;
+               else if (i < lim2)
+                       fill_type[i] = d_info[type].fill_type2;
+               else if (i < lim3)
+                       fill_type[i] = d_info[type].fill_type3;
+       }
+}
+
+
+/*
  * Helper for plasma generation.
  */
 static void perturb_point_mid(int x1, int x2, int x3, int x4,
@@ -428,12 +469,15 @@ static int terrain_table[MAX_WILDERNESS][18] =
 };
 
 
-void generate_wilderness_area(int terrain, u32b seed, bool border, bool corner)
+static void generate_wilderness_area(int terrain, u32b seed, bool border, bool corner)
 {
        int x1, y1;
        int table_size = sizeof(terrain_table[0]) / sizeof(int);
        int roughness = 1; /* The roughness of the level. */
 
+       /* Unused */
+       (void)border;
+
        /* The outer wall is easy */
        if (terrain == TERRAIN_EDGE)
        {
@@ -541,7 +585,7 @@ static void generate_area(int y, int x, bool border, bool corner)
                else
                        init_flags = INIT_CREATE_DUNGEON;
 
-               process_dungeon_file("t_info_j.txt", 0, 0, MAX_HGT, MAX_WID);
+               process_dungeon_file("t_info.txt", 0, 0, MAX_HGT, MAX_WID);
 
                if (!corner && !border) p_ptr->visit |= (1L << (p_ptr->town_num - 1));
        }
@@ -605,7 +649,7 @@ static void generate_area(int y, int x, bool border, bool corner)
                }
        }
 
-       if (wilderness[y][x].entrance && !wilderness[y][x].town && (total_winner || !(d_info[wilderness[y][x].entrance].flags1 & DF1_WINNER)))
+       if (wilderness[y][x].entrance && !wilderness[y][x].town && (p_ptr->total_winner || !(d_info[wilderness[y][x].entrance].flags1 & DF1_WINNER)))
        {
                int dy, dx;
 
@@ -613,7 +657,7 @@ static void generate_area(int y, int x, bool border, bool corner)
                Rand_quick = TRUE;
 
                /* Hack -- Induce consistant town layout */
-                Rand_value = wilderness[y][x].seed;
+               Rand_value = wilderness[y][x].seed;
 
                dy = rand_range(6, cur_hgt - 6);
                dx = rand_range(6, cur_wid - 6);
@@ -639,10 +683,9 @@ static border_type border;
 void wilderness_gen(void)
 {
        int i, y, x, lim;
-       bool daytime;
        cave_type *c_ptr;
 
-       /* Big town */
+       /* Big town */
        cur_hgt = MAX_HGT;
        cur_wid = MAX_WID;
 
@@ -652,7 +695,7 @@ void wilderness_gen(void)
 
        /* Init the wilderness */
 
-       process_dungeon_file("w_info_j.txt", 0, 0, max_wild_y, max_wild_x);
+       process_dungeon_file("w_info.txt", 0, 0, max_wild_y, max_wild_x);
 
        x = p_ptr->wilderness_x;
        y = p_ptr->wilderness_y;
@@ -753,13 +796,6 @@ void wilderness_gen(void)
        /* South east corner */
        cave[MAX_HGT - 1][MAX_WID - 1].mimic = border.south_east;
 
-
-       /* Day time */
-       if ((turn % (20L * TOWN_DAWN)) < ((20L * TOWN_DAWN) / 2))
-               daytime = TRUE;
-       else
-               daytime = FALSE;
-
        /* Light up or darken the area */
        for (y = 0; y < cur_hgt; y++)
        {
@@ -768,7 +804,7 @@ void wilderness_gen(void)
                        /* Get the cave grid */
                        c_ptr = &cave[y][x];
 
-                       if (daytime)
+                       if (is_daytime())
                        {
                                /* Assume lit */
                                c_ptr->info |= (CAVE_GLOW);
@@ -781,7 +817,7 @@ void wilderness_gen(void)
                                /* Darken "boring" features */
                                if ((c_ptr->feat <= FEAT_INVIS) ||
                                    ((c_ptr->feat >= FEAT_DEEP_WATER) &&
-                                       (c_ptr->feat <= FEAT_TREES) &&
+                                       (c_ptr->feat <= FEAT_MOUNTAIN) &&
                                     (c_ptr->feat != FEAT_MUSEUM)) ||
                                    (x == 0) || (x == cur_wid-1) ||
                                    (y == 0) || (y == cur_hgt-1))
@@ -844,18 +880,20 @@ void wilderness_gen(void)
        /* Make some residents */
        for (i = 0; i < lim; i++)
        {
+               u32b mode = 0;
+
+               if (!(generate_encounter || (one_in_(2) && (!p_ptr->town_num))))
+                       mode |= PM_ALLOW_SLEEP;
+
                /* Make a resident */
-               (void)alloc_monster(generate_encounter ? 0 : 3, (bool)!(generate_encounter || (one_in_(2) && (!p_ptr->town_num))));
+               (void)alloc_monster(generate_encounter ? 0 : 3, mode);
        }
 
        if(generate_encounter) ambush_flag = TRUE;
        generate_encounter = FALSE;
 
-       for (i = 0; i < 100; i++)
-       {
-               floor_type[i] = FEAT_FLOOR;
-               fill_type[i] = FEAT_WALL_EXTRA;
-       }
+       /* Fill the arrays of floors and walls in the good proportions */
+       set_floor_and_wall(0);
 
        /* Set rewarded quests to finished */
        for (i = 0; i < max_quests; i++)
@@ -872,21 +910,21 @@ void wilderness_gen(void)
  */
 void wilderness_gen_small()
 {
-        int i, j;
+       int i, j;
 
-        /* To prevent stupid things */
-        for (i = 0; i < MAX_WID; i++)
-        for (j = 0; j < MAX_HGT; j++)
+       /* To prevent stupid things */
+       for (i = 0; i < MAX_WID; i++)
+       for (j = 0; j < MAX_HGT; j++)
        {
-                cave[j][i].feat = FEAT_PERM_SOLID;
+               cave[j][i].feat = FEAT_PERM_SOLID;
        }
 
        /* Init the wilderness */
-       process_dungeon_file("w_info_j.txt", 0, 0, max_wild_y, max_wild_x);
+       process_dungeon_file("w_info.txt", 0, 0, max_wild_y, max_wild_x);
 
-        /* Fill the map */
-        for (i = 0; i < max_wild_x; i++)
-        for (j = 0; j < max_wild_y; j++)
+       /* Fill the map */
+       for (i = 0; i < max_wild_x; i++)
+       for (j = 0; j < max_wild_y; j++)
        {
                if (wilderness[j][i].town && (wilderness[j][i].town != NO_TOWN))
                {
@@ -894,18 +932,18 @@ void wilderness_gen_small()
                        cave[j][i].special = wilderness[j][i].town;
                }
                else if (wilderness[j][i].road) cave[j][i].feat = FEAT_FLOOR;
-               else if (wilderness[j][i].entrance && (total_winner || !(d_info[wilderness[j][i].entrance].flags1 & DF1_WINNER)))
+               else if (wilderness[j][i].entrance && (p_ptr->total_winner || !(d_info[wilderness[j][i].entrance].flags1 & DF1_WINNER)))
                {
                        cave[j][i].feat = FEAT_ENTRANCE;
                        cave[j][i].special = (byte)wilderness[j][i].entrance;
                }
-                else cave[j][i].feat = conv_terrain2feat[wilderness[j][i].terrain];
+               else cave[j][i].feat = conv_terrain2feat[wilderness[j][i].terrain];
 
-                cave[j][i].info |= (CAVE_GLOW | CAVE_MARK);
+               cave[j][i].info |= (CAVE_GLOW | CAVE_MARK);
        }
 
-       cur_hgt = (max_wild_y / SCREEN_HGT + 1) * SCREEN_HGT;
-       cur_wid = (max_wild_x / SCREEN_WID + 1) * SCREEN_WID;
+       cur_hgt = (s16b) max_wild_y;
+       cur_wid = (s16b) max_wild_x;
 
        if (cur_hgt > MAX_HGT) cur_hgt = MAX_HGT;
        if (cur_wid > MAX_WID) cur_wid = MAX_WID;
@@ -914,9 +952,9 @@ void wilderness_gen_small()
        panel_row_min = cur_hgt;
        panel_col_min = cur_wid;
 
-        /* Place the player */
-        px = p_ptr->wilderness_x;
-        py = p_ptr->wilderness_y;
+       /* Place the player */
+       px = p_ptr->wilderness_x;
+       py = p_ptr->wilderness_y;
 
        p_ptr->town_num = 0;
 }
@@ -945,6 +983,9 @@ errr parse_line_wilderness(char *buf, int ymin, int xmin, int ymax, int xmax, in
        int i, num;
        char *zz[33];
 
+       /* Unused */
+       (void)ymin;
+       (void)ymax;
 
        /* Paranoia */
        if (!(buf[0] == 'W')) return (PARSE_ERROR_GENERIC);
@@ -1160,9 +1201,9 @@ bool change_wild_mode(void)
                if (have_pet)
                {
 #ifdef JP
-                       if(!get_check_strict("¥Ú¥Ã¥È¤òÃÖ¤¤¤Æ¹­°è¥Þ¥Ã¥×¤ËÆþ¤ê¤Þ¤¹¤«¡©", 1))
+                       if(!get_check_strict("¥Ú¥Ã¥È¤òÃÖ¤¤¤Æ¹­°è¥Þ¥Ã¥×¤ËÆþ¤ê¤Þ¤¹¤«¡©", CHECK_OKAY_CANCEL))
 #else
-                       if(!get_check_strict("Do you leave your pets behind? ", 1))
+                       if(!get_check_strict("Do you leave your pets behind? ", CHECK_OKAY_CANCEL))
 #endif
                        {
                                energy_use = 0;