OSDN Git Service

[Refactor] #37353 BIAS_* と artifact_bias_name を artifact.c/h へ移動。 / Move BIAS_* and...
[hengband/hengband.git] / src / floor-generate.c
index c98c180..e92bd4c 100644 (file)
  * Note that the dungeon generation routines are much different (2.7.5)\n
  * and perhaps "DUN_ROOMS" should be less than 50.\n
  *\n
- * XXX XXX XXX Note that it is possible to create a room which is only\n
+ * Note that it is possible to create a room which is only\n
  * connected to itself, because the "tunnel generation" code allows a\n
  * tunnel to leave a room, wander around, and then re-enter the room.\n
  *\n
- * XXX XXX XXX Note that it is possible to create a set of rooms which\n
+ * Note that it is possible to create a set of rooms which\n
  * are only connected to other rooms in that set, since there is nothing\n
  * explicit in the code to prevent this from happening.  But this is less\n
  * likely than the "isolated room" problem, because each room attempts to\n
@@ -93,7 +93,7 @@
  * but we must be careful not to allow, for example, the user to display\n
  * hidden traps in a different way from floors, or secret doors in a way\n
  * different from granite walls, or even permanent granite in a different\n
- * way from granite.  XXX XXX XXX\n
+ * way from granite.  \n
  */
 
 #include "angband.h"
 #include "rooms.h"
 #include "floor-streams.h"
 #include "trap.h"
+#include "monster.h"
+#include "quest.h"
 
 int dun_tun_rnd; 
 int dun_tun_chg;
@@ -145,7 +147,6 @@ static int next_to_walls(POSITION y, POSITION x)
  */
 static bool alloc_stairs_aux(POSITION y, POSITION x, int walls)
 {
-       /* Access the grid */
        cave_type *c_ptr = &cave[y][x];
 
        /* Require "naked" floor grid */
@@ -184,7 +185,7 @@ static bool alloc_stairs(IDX feat, int num, int walls)
        }
        else if (have_flag(f_ptr->flags, FF_MORE))
        {
-               int q_idx = quest_number(dun_level);
+               QUEST_IDX q_idx = quest_number(dun_level);
 
                /* No downstairs on quest levels */
                if (dun_level > 1 && q_idx)
@@ -212,7 +213,7 @@ static bool alloc_stairs(IDX feat, int num, int walls)
        {
                while (TRUE)
                {
-                       int y = 0, x = 0;
+                       POSITION y, x = 0;
                        cave_type *c_ptr;
 
                        int candidates = 0;
@@ -259,8 +260,6 @@ static bool alloc_stairs(IDX feat, int num, int walls)
 
                                if (!pick) break;
                        }
-
-                       /* Access the grid */
                        c_ptr = &cave[y][x];
 
                        /* Clear possible garbage of hidden trap */
@@ -288,7 +287,8 @@ static bool alloc_stairs(IDX feat, int num, int walls)
  */
 static void alloc_object(int set, EFFECT_ID typ, int num)
 {
-       int y = 0, x = 0, k;
+       POSITION y = 0, x = 0;
+       int k;
        int dummy = 0;
        cave_type *c_ptr;
 
@@ -305,7 +305,6 @@ static void alloc_object(int set, EFFECT_ID typ, int num)
 
                        dummy++;
 
-                       /* Location */
                        y = randint0(cur_hgt);
                        x = randint0(cur_wid);
 
@@ -600,8 +599,6 @@ static bool cave_gen(void)
 
        /* Fill the arrays of floors and walls in the good proportions */
        set_floor_and_wall(dungeon_type);
-
-       /* Prepare allocation table */
        get_mon_num_prep(get_monster_hook(), NULL);
 
        /* Randomize the dungeon creation values */
@@ -714,20 +711,43 @@ static bool cave_gen(void)
                /* Hack -- Add some rivers */
                if (one_in_(3) && (randint1(dun_level) > 5))
                {
-                       IDX feat1 = 0, feat2 = 0;
+                       FEAT_IDX feat1 = 0, feat2 = 0;
 
-                       /* Choose water or lava */
+                       /* Choose water mainly */
                        if ((randint1(MAX_DEPTH * 2) - 1 > dun_level) && (d_info[dungeon_type].flags1 & DF1_WATER_RIVER))
                        {
                                feat1 = feat_deep_water;
                                feat2 = feat_shallow_water;
                        }
-                       else if  (d_info[dungeon_type].flags1 & DF1_LAVA_RIVER)
+                       else /* others */
                        {
-                               feat1 = feat_deep_lava;
-                               feat2 = feat_shallow_lava;
+                               FEAT_IDX select_deep_feat[10];
+                               FEAT_IDX select_shallow_feat[10];
+                               int select_id_max = 0, selected;
+
+                               if (d_info[dungeon_type].flags1 & DF1_LAVA_RIVER)
+                               {
+                                       select_deep_feat[select_id_max] = feat_deep_lava;
+                                       select_shallow_feat[select_id_max] = feat_shallow_lava;
+                                       select_id_max++;
+                               }
+                               if (d_info[dungeon_type].flags1 & DF1_POISONOUS_RIVER)
+                               {
+                                       select_deep_feat[select_id_max] = feat_deep_poisonous_puddle;
+                                       select_shallow_feat[select_id_max] = feat_shallow_poisonous_puddle;
+                                       select_id_max++;
+                               }
+                               if (d_info[dungeon_type].flags1 & DF1_ACID_RIVER)
+                               {
+                                       select_deep_feat[select_id_max] = feat_deep_acid_puddle;
+                                       select_shallow_feat[select_id_max] = feat_shallow_acid_puddle;
+                                       select_id_max++;
+                               }
+
+                               selected = randint0(select_id_max);
+                               feat1 = select_deep_feat[selected];
+                               feat2 = select_shallow_feat[selected];
                        }
-                       else feat1 = 0;
 
                        if (feat1)
                        {
@@ -792,12 +812,8 @@ static bool cave_gen(void)
                        {
                                cave_type *c_ptr;
                                feature_type *f_ptr;
-
-                               /* Access the grid */
                                y = dun->tunn[j].y;
                                x = dun->tunn[j].x;
-
-                               /* Access the grid */
                                c_ptr = &cave[y][x];
                                f_ptr = &f_info[c_ptr->feat];
 
@@ -815,12 +831,8 @@ static bool cave_gen(void)
                        for (j = 0; j < dun->wall_n; j++)
                        {
                                cave_type *c_ptr;
-
-                               /* Access the grid */
                                y = dun->wall[j].y;
                                x = dun->wall[j].x;
-
-                               /* Access the grid */
                                c_ptr = &cave[y][x];
 
                                /* Clear mimic type */
@@ -981,7 +993,7 @@ static bool cave_gen(void)
  */
 static void build_arena(void)
 {
-       int yval, y_height, y_depth, xval, x_left, x_right;
+       POSITION yval, y_height, y_depth, xval, x_left, x_right;
        register int i, j;
 
        yval = SCREEN_HGT / 2;
@@ -1038,9 +1050,9 @@ static void build_arena(void)
  */
 static void arena_gen(void)
 {
-       int y, x;
-       int qy = 0;
-       int qx = 0;
+       POSITION y, x;
+       POSITION qy = 0;
+       POSITION qx = 0;
 
        /* Smallest area */
        cur_hgt = SCREEN_HGT;
@@ -1086,7 +1098,7 @@ static void arena_gen(void)
  */
 static void build_battle(void)
 {
-       int yval, y_height, y_depth, xval, x_left, x_right;
+       POSITION yval, y_height, y_depth, xval, x_left, x_right;
        register int i, j;
 
        yval = SCREEN_HGT / 2;
@@ -1149,10 +1161,10 @@ static void build_battle(void)
  */
 static void battle_gen(void)
 {
-       int y, x;
+       POSITION y, x;
        MONSTER_IDX i;
-       int qy = 0;
-       int qx = 0;
+       POSITION qy = 0;
+       POSITION qx = 0;
 
        /* Start with solid walls */
        for (y = 0; y < MAX_HGT; y++)
@@ -1181,8 +1193,7 @@ static void battle_gen(void)
 
        for(i = 0; i < 4; i++)
        {
-               place_monster_aux(0, p_ptr->y + 8 + (i/2)*4, p_ptr->x - 2 + (i%2)*4, battle_mon[i],
-                                 (PM_NO_KAGE | PM_NO_PET));
+               place_monster_aux(0, p_ptr->y + 8 + (i/2)*4, p_ptr->x - 2 + (i%2)*4, battle_mon[i], (PM_NO_KAGE | PM_NO_PET));
                set_friendly(&m_list[cave[p_ptr->y+8+(i/2)*4][p_ptr->x-2+(i%2)*4].m_idx]);
        }
        for(i = 1; i < m_max; i++)
@@ -1191,11 +1202,8 @@ static void battle_gen(void)
 
                if (!m_ptr->r_idx) continue;
 
-               /* Hack -- Detect monster */
                m_ptr->mflag2 |= (MFLAG2_MARK | MFLAG2_SHOW);
-
-               /* Update the monster */
-               update_mon(i, FALSE);
+               update_monster(i, FALSE);
        }
 }
 
@@ -1207,7 +1215,6 @@ static void quest_gen(void)
 {
        POSITION x, y;
 
-
        /* Start with perm walls */
        for (y = 0; y < cur_hgt; y++)
        {
@@ -1224,8 +1231,6 @@ static void quest_gen(void)
        monster_level = base_level;
 
        if (record_stair) do_cmd_write_nikki(NIKKI_TO_QUEST, p_ptr->inside_quest, NULL);
-
-       /* Prepare allocation table */
        get_mon_num_prep(get_monster_hook(), NULL);
 
        init_flags = INIT_CREATE_DUNGEON;
@@ -1237,7 +1242,7 @@ static void quest_gen(void)
  * @brief ダンジョン時のランダムフロア生成 / Make a real level
  * @return フロアの生成に成功したらTRUE
  */
-static bool level_gen(cptr *why)
+static bool level_gen(concptr *why)
 {
        int level_height, level_width;
 
@@ -1264,8 +1269,7 @@ static bool level_gen(cptr *why)
                                level_height = randint1(MAX_HGT/SCREEN_HGT);
                                level_width = randint1(MAX_WID/SCREEN_WID);
                        }
-                       while ((level_height == MAX_HGT/SCREEN_HGT) &&
-                                  (level_width == MAX_WID/SCREEN_WID));
+                       while ((level_height == MAX_HGT/SCREEN_HGT) && (level_width == MAX_WID/SCREEN_WID));
                }
 
                cur_hgt = level_height * SCREEN_HGT;
@@ -1293,12 +1297,7 @@ static bool level_gen(cptr *why)
        /* Make a dungeon */
        if (!cave_gen())
        {
-#ifdef JP
-*why = "ダンジョン生成に失敗";
-#else
-               *why = "could not place player";
-#endif
-
+               *why = _("ダンジョン生成に失敗", "could not place player");
                return FALSE;
        }
        else return TRUE;
@@ -1366,26 +1365,12 @@ void clear_cave(void)
                for (x = 0; x < MAX_WID; x++)
                {
                        cave_type *c_ptr = &cave[y][x];
-
-                       /* No flags */
                        c_ptr->info = 0;
-
-                       /* No features */
                        c_ptr->feat = 0;
-
-                       /* No objects */
                        c_ptr->o_idx = 0;
-
-                       /* No monsters */
                        c_ptr->m_idx = 0;
-
-                       /* No special */
                        c_ptr->special = 0;
-
-                       /* No mimic */
                        c_ptr->mimic = 0;
-
-                       /* No flow */
                        c_ptr->cost = 0;
                        c_ptr->dist = 0;
                        c_ptr->when = 0;
@@ -1423,7 +1408,7 @@ void generate_cave(void)
        {
                bool okay = TRUE;
 
-               cptr why = NULL;
+               concptr why = NULL;
 
                /* Clear and empty the cave */
                clear_cave();
@@ -1465,47 +1450,22 @@ void generate_cave(void)
                /* Prevent object over-flow */
                if (o_max >= max_o_idx)
                {
-                       /* Message */
-#ifdef JP
-why = "アイテムが多すぎる";
-#else
-                       why = "too many objects";
-#endif
-
-
-                       /* Message */
+                       why = _("アイテムが多すぎる", "too many objects");
                        okay = FALSE;
                }
                /* Prevent monster over-flow */
                else if (m_max >= max_m_idx)
                {
-                       /* Message */
-#ifdef JP
-why = "モンスターが多すぎる";
-#else
-                       why = "too many monsters";
-#endif
-
-
-                       /* Message */
+                       why = _("モンスターが多すぎる", "too many monsters");
                        okay = FALSE;
                }
 
                /* Accept */
                if (okay) break;
 
-               /* Message */
-#ifdef JP
-if (why) msg_format("生成やり直し(%s)", why);
-#else
-               if (why) msg_format("Generation restarted (%s)", why);
-#endif
-
+               if (why) msg_format(_("生成やり直し(%s)", "Generation restarted (%s)"), why);
 
-               /* Wipe the objects */
                wipe_o_list();
-
-               /* Wipe the monsters */
                wipe_m_list();
        }
 
@@ -1555,10 +1515,10 @@ if (why) msg_format("生成やり直し(%s)", why);
 */
 bool build_tunnel(POSITION row1, POSITION col1, POSITION row2, POSITION col2)
 {
-       int y, x;
+       POSITION y, x;
        POSITION tmp_row, tmp_col;
-       int row_dir, col_dir;
-       int start_row, start_col;
+       POSITION row_dir, col_dir;
+       POSITION start_row, start_col;
        int main_loop_count = 0;
 
        bool door_flag = FALSE;