OSDN Git Service

Vanillaにならって、キャラクターの状態を表わすグローバル変数の多くを
[hengband/hengband.git] / src / wild.c
index b030e3a..8521d77 100644 (file)
@@ -25,7 +25,7 @@ static void perturb_point_mid(int x1, int x2, int x3, int x4,
         * tmp is a random int +/- rough
         */
        int tmp2 = rough*2 + 1;
-       int tmp = randint(tmp2) - (rough + 1);
+       int tmp = randint1(tmp2) - (rough + 1);
 
        int avg = ((x1 + x2 + x3 + x4) / 4) + tmp;
 
@@ -50,7 +50,7 @@ static void perturb_point_end(int x1, int x2, int x3,
         * tmp is a random int +/- rough
         */
        int tmp2 = rough * 2 + 1;
-       int tmp = rand_int(tmp2) - rough;
+       int tmp = randint0(tmp2) - rough;
 
        int avg = ((x1 + x2 + x3) / 3) + tmp;
 
@@ -428,7 +428,7 @@ 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);
@@ -474,10 +474,10 @@ void generate_wilderness_area(int terrain, u32b seed, bool border, bool corner)
         * ToDo: calculate the medium height of the adjacent
         * terrains for every corner.
         */
-       cave[1][1].feat = (byte)rand_int(table_size);
-       cave[MAX_HGT-2][1].feat = (byte)rand_int(table_size);
-       cave[1][MAX_WID-2].feat = (byte)rand_int(table_size);
-       cave[MAX_HGT-2][MAX_WID-2].feat = (byte)rand_int(table_size);
+       cave[1][1].feat = (byte)randint0(table_size);
+       cave[MAX_HGT-2][1].feat = (byte)randint0(table_size);
+       cave[1][MAX_WID-2].feat = (byte)randint0(table_size);
+       cave[MAX_HGT-2][MAX_WID-2].feat = (byte)randint0(table_size);
 
        if (!corner)
        {
@@ -528,10 +528,6 @@ static void generate_area(int y, int x, bool border, bool corner)
        /* Set the object generation level */
        object_level = base_level;
 
-#ifdef USE_SCRIPT
-       if (generate_wilderness_callback(y, x)) return;
-#endif /* USE_SCRIPT */
-
 
        /* Create the town */
        if (p_ptr->town_num)
@@ -609,7 +605,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;
 
@@ -643,20 +639,15 @@ static border_type border;
 void wilderness_gen(void)
 {
        int i, y, x, lim;
-       bool daytime;
        cave_type *c_ptr;
 
        /* Big town */
        cur_hgt = MAX_HGT;
        cur_wid = MAX_WID;
 
-       /* Determine number of panels */
-       max_panel_rows = (cur_hgt / SCREEN_HGT) * 2 - 2;
-       max_panel_cols = (cur_wid / SCREEN_WID) * 2 - 2;
-
        /* Assume illegal panel */
-       panel_row = max_panel_rows;
-       panel_col = max_panel_cols;
+       panel_row_min = cur_hgt;
+       panel_col_min = cur_wid;
 
        /* Init the wilderness */
 
@@ -761,13 +752,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++)
        {
@@ -776,7 +760,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);
@@ -789,7 +773,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))
@@ -902,7 +886,7 @@ 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;
@@ -918,13 +902,9 @@ void wilderness_gen_small()
        if (cur_hgt > MAX_HGT) cur_hgt = MAX_HGT;
        if (cur_wid > MAX_WID) cur_wid = MAX_WID;
 
-       /* Determine number of panels */
-       max_panel_rows = (cur_hgt / SCREEN_HGT) * 2 - 2;
-       max_panel_cols = (cur_wid / SCREEN_WID) * 2 - 2;
-
        /* Assume illegal panel */
-       panel_row = max_panel_rows;
-       panel_col = max_panel_cols;
+       panel_row_min = cur_hgt;
+       panel_col_min = cur_wid;
 
         /* Place the player */
         px = p_ptr->wilderness_x;
@@ -1097,18 +1077,13 @@ void seed_wilderness(void)
 {
        int x, y;
 
-#ifdef USE_SCRIPT
-       if (!wilderness_init_callback())
-#endif /* USE_SCRIPT */
+       /* Init wilderness seeds */
+       for (x = 0; x < max_wild_x; x++)
        {
-               /* Init wilderness seeds */
-               for (x = 0; x < max_wild_x; x++)
+               for (y = 0; y < max_wild_y; y++)
                {
-                       for (y = 0; y < max_wild_y; y++)
-                       {
-                               wilderness[y][x].seed = rand_int(0x10000000);
-                               wilderness[y][x].entrance = 0;
-                       }
+                       wilderness[y][x].seed = randint0(0x10000000);
+                       wilderness[y][x].entrance = 0;
                }
        }
 }
@@ -1143,6 +1118,7 @@ errr init_wilderness(void)
 bool change_wild_mode(void)
 {
        int i;
+       bool have_pet = FALSE;
 
        if (lite_town || vanilla_town)
        {
@@ -1160,6 +1136,7 @@ bool change_wild_mode(void)
                        monster_type *m_ptr = &m_list[i];
 
                        if (!m_ptr->r_idx) continue;
+                       if (is_pet(m_ptr) && i != p_ptr->riding) have_pet = TRUE;
                        if (m_ptr->csleep) continue;
                        if (m_ptr->cdis > MAX_SIGHT) continue;
                        if (!is_hostile(m_ptr)) continue;
@@ -1171,6 +1148,20 @@ bool change_wild_mode(void)
                        energy_use = 0;
                        return FALSE;
                }
+
+               if (have_pet)
+               {
+#ifdef JP
+                       if(!get_check_strict("¥Ú¥Ã¥È¤òÃÖ¤¤¤Æ¹­°è¥Þ¥Ã¥×¤ËÆþ¤ê¤Þ¤¹¤«¡©", CHECK_OKAY_CANCEL))
+#else
+                       if(!get_check_strict("Do you leave your pets behind? ", CHECK_OKAY_CANCEL))
+#endif
+                       {
+                               energy_use = 0;
+                               return FALSE;
+                       }
+               }
+                       
                energy_use = 1000;
        }