OSDN Git Service

Extend features of tiling. (separation of Cell size and Tile size / add offset position.)
[hengband/hengband.git] / src / wild.c
index 528ca5c..dc29212 100644 (file)
@@ -1,19 +1,23 @@
-/* File: wild.c */
-
-/*
- * 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.  Other copyrights may also apply.
+/*!
+ * @file wild.c
+ * @brief ¹ÓÌî¥Þ¥Ã¥×¤ÎÀ¸À®¤È¥ë¡¼¥ë´ÉÍý / Wilderness generation
+ * @date 2014/02/13
+ * @author
+ * Copyright (c) 1989 James E. Wilson, Robert A. Koeneke\n
+ * This software may be copied and distributed for educational, research, and\n
+ * not for profit purposes provided that this copyright and statement are\n
+ * included in all such copies.\n
+ * 2013 Deskull rearranged comment for Doxygen.
  */
 
-/* Purpose: Wilderness generation */
-
 #include "angband.h"
 
-
+/*!
+ * @brief ÃÏ·ÁÀ¸À®³ÎΨ¤ò·è¤á¤ëÍ×ÁÇ100¤ÎÇÛÎó¤ò³ÎΨ¥Æ¡¼¥Ö¥ë¤«¤éºîÀ®¤¹¤ë
+ * @param feat_type Èó°ìÍͳÎΨ¤òºÆ¸½¤¹¤ë¤¿¤á¤ÎÍ×ÁÇ¿ô100¤ÎÇÛÎó
+ * @param prob ¸µ¤Î³ÎΨ¥Æ¡¼¥Ö¥ë
+ * @return ¤Ê¤·
+ */
 static void set_floor_and_wall_aux(s16b feat_type[100], feat_prob prob[DUNGEON_FEAT_PROB_NUM])
 {
        int lim[DUNGEON_FEAT_PROB_NUM], cur = 0, i;
@@ -31,8 +35,11 @@ static void set_floor_and_wall_aux(s16b feat_type[100], feat_prob prob[DUNGEON_F
        }
 }
 
-/*
- * Fill the arrays of floors and walls in the good proportions
+/*!
+ * @brief ¥À¥ó¥¸¥ç¥ó¤ÎÃÏ·Á¤ò»ØÄê³ÎΨ¤Ë±þ¤¸¤Æ³Æ¥Þ¥¹¤Ø¥é¥ó¥À¥à¤ËÉߤ­µÍ¤á¤ë
+ * / Fill the arrays of floors and walls in the good proportions
+ * @param type ¥À¥ó¥¸¥ç¥óID
+ * @return ¤Ê¤·
  */
 void set_floor_and_wall(byte type)
 {
@@ -54,8 +61,18 @@ void set_floor_and_wall(byte type)
 }
 
 
-/*
- * Helper for plasma generation.
+/*!
+ * @brief ¥×¥é¥º¥Þ¥Õ¥é¥¯¥¿¥ëŪÃÏ·ÁÀ¸À®¤ÎºÆµ¢Ãæ´Ö½èÍý
+ * / Helper for plasma generation.
+ * @param x1 º¸¾åü¤Î¿¼¤ß
+ * @param x2 ±¦¾åü¤Î¿¼¤ß
+ * @param x3 º¸²¼Ã¼¤Î¿¼¤ß
+ * @param x4 ±¦²¼Ã¼¤Î¿¼¤ß
+ * @param xmid Ãæ±ûºÂɸX
+ * @param ymid Ãæ±ûºÂɸY
+ * @param rough ¥é¥ó¥À¥àÉý
+ * @param depth_max ¿¼¤ß¤ÎºÇÂçÃÍ
+ * @return ¤Ê¤·
  */
 static void perturb_point_mid(int x1, int x2, int x3, int x4,
                          int xmid, int ymid, int rough, int depth_max)
@@ -82,6 +99,18 @@ static void perturb_point_mid(int x1, int x2, int x3, int x4,
 }
 
 
+/*!
+ * @brief ¥×¥é¥º¥Þ¥Õ¥é¥¯¥¿¥ëŪÃÏ·ÁÀ¸À®¤ÎºÆµ¢Ëöü½èÍý
+ * / Helper for plasma generation.
+ * @param x1 Ãæ´ÖËöüÉô1¤Î½Å¤ß
+ * @param x2 Ãæ´ÖËöüÉô2¤Î½Å¤ß
+ * @param x3 Ãæ´ÖËöüÉô3¤Î½Å¤ß
+ * @param xmid ºÇ½ªËöüÉôºÂɸX
+ * @param ymid ºÇ½ªËöüÉôºÂɸY
+ * @param rough ¥é¥ó¥À¥àÉý
+ * @param depth_max ¿¼¤ß¤ÎºÇÂçÃÍ
+ * @return ¤Ê¤·
+ */
 static void perturb_point_end(int x1, int x2, int x3,
                          int xmid, int ymid, int rough, int depth_max)
 {
@@ -106,12 +135,24 @@ static void perturb_point_end(int x1, int x2, int x3,
 }
 
 
-/*
+/*!
+ * @brief ¥×¥é¥º¥Þ¥Õ¥é¥¯¥¿¥ëŪÃÏ·ÁÀ¸À®¤Î³«»Ï½èÍý
+ * / Helper for plasma generation.
+ * @param x1 ½èÍýÈϰϤκ¸¾åXºÂɸ
+ * @param y1 ½èÍýÈϰϤκ¸¾åYºÂɸ
+ * @param x2 ½èÍýÈϰϤᦲ¼XºÂɸ
+ * @param y2 ½èÍýÈϰϤᦲ¼YºÂɸ
+ * @param depth_max ¿¼¤ß¤ÎºÇÂçÃÍ
+ * @param rough ¥é¥ó¥À¥àÉý
+ * @return ¤Ê¤·
+ * @details
+ * <pre>
  * A generic function to generate the plasma fractal.
  * Note that it uses ``cave_feat'' as temporary storage.
  * The values in ``cave_feat'' after this function
  * are NOT actual features; They are raw heights which
  * need to be converted to features.
+ * </pre>
  */
 static void plasma_recursive(int x1, int y1, int x2, int y2,
                             int depth_max, int rough)
@@ -154,12 +195,20 @@ static void plasma_recursive(int x1, int y1, int x2, int y2,
  */
 static s16b terrain_table[MAX_WILDERNESS][MAX_FEAT_IN_TERRAIN];
 
-
+/*!
+ * @brief ¹ÓÌî¥Õ¥í¥¢À¸À®¤Î¥µ¥Ö¥ë¡¼¥Á¥ó
+ * @param terrain ¹ÓÌîÃÏ·ÁID
+ * @param seed Íð¿ô¤Î¸ÇÄꥷ¡¼¥É
+ * @param border Ì¤»ÈÍÑ
+ * @param corner ¹­°è¥Þ¥Ã¥×¤Î³ÑÉôʬ¤È¤·¤Æ¤ÎÀ¸À®¤Ê¤é¤ÐTRUE
+ * @return ¤Ê¤·
+ */
 static void generate_wilderness_area(int terrain, u32b seed, bool border, bool corner)
 {
        int x1, y1;
        int table_size = sizeof(terrain_table[0]) / sizeof(s16b);
        int roughness = 1; /* The roughness of the level. */
+       u32b state_backup[4];
 
        /* Unused */
        (void)border;
@@ -181,11 +230,11 @@ static void generate_wilderness_area(int terrain, u32b seed, bool border, bool c
        }
 
 
-       /* Hack -- Use the "simple" RNG */
-       Rand_quick = TRUE;
+       /* Hack -- Backup the RNG state */
+       Rand_state_backup(state_backup);
 
-       /* Hack -- Induce consistant town layout */
-       Rand_value = seed;
+       /* Hack -- Induce consistant flavors */
+       Rand_state_init(seed);
 
        if (!corner)
        {
@@ -242,21 +291,29 @@ static void generate_wilderness_area(int terrain, u32b seed, bool border, bool c
                cave[MAX_HGT - 2][MAX_WID - 2].feat = terrain_table[terrain][cave[MAX_HGT - 2][MAX_WID - 2].feat];
        }
 
-       /* Use the complex RNG */
-       Rand_quick = FALSE;
+       /* Hack -- Restore the RNG state */
+       Rand_state_restore(state_backup);
 }
 
 
 
-/*
+/*!
+ * @brief ¹ÓÌî¥Õ¥í¥¢À¸À®¤Î¥á¥¤¥ó¥ë¡¼¥Á¥ó /
  * Load a town or generate a terrain level using "plasma" fractals.
- *
+ * @param y ¹­°è¥Þ¥Ã¥×YºÂɸ
+ * @param x ¹­°è¥Þ¥Ã¥×YºÂɸ
+ * @param border ¹­°è¥Þ¥Ã¥×¤ÎÊÕÉôʬ¤È¤·¤Æ¤ÎÀ¸À®¤Ê¤é¤ÐTRUE
+ * @param corner ¹­°è¥Þ¥Ã¥×¤Î³ÑÉôʬ¤È¤·¤Æ¤ÎÀ¸À®¤Ê¤é¤ÐTRUE
+ * @return ¤Ê¤·
+ * @details
+ * <pre>
  * x and y are the coordinates of the area in the wilderness.
  * Border and corner are optimization flags to speed up the
  * generation of the fractal terrain.
  * If border is set then only the border of the terrain should
  * be generated (for initializing the border structure).
  * If corner is set then only the corners of the area are needed.
+ * </pre>
  */
 static void generate_area(int y, int x, bool border, bool corner)
 {
@@ -357,12 +414,13 @@ static void generate_area(int y, int x, bool border, bool corner)
        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;
+               u32b state_backup[4];
 
-               /* Hack -- Use the "simple" RNG */
-               Rand_quick = TRUE;
+               /* Hack -- Backup the RNG state */
+               Rand_state_backup(state_backup);
 
-               /* Hack -- Induce consistant town layout */
-               Rand_value = wilderness[y][x].seed;
+               /* Hack -- Induce consistant flavors */
+               Rand_state_init(wilderness[y][x].seed);
 
                dy = rand_range(6, cur_hgt - 6);
                dx = rand_range(6, cur_wid - 6);
@@ -370,8 +428,8 @@ static void generate_area(int y, int x, bool border, bool corner)
                cave[dy][dx].feat = feat_entrance;
                cave[dy][dx].special = wilderness[y][x].entrance;
 
-               /* Use the complex RNG */
-               Rand_quick = FALSE;
+               /* Hack -- Restore the RNG state */
+               Rand_state_restore(state_backup);
        }
 }
 
@@ -382,8 +440,10 @@ static void generate_area(int y, int x, bool border, bool corner)
 static border_type border;
 
 
-/*
+/*!
+ * @brief ¹­°è¥Þ¥Ã¥×¤ÎÀ¸À® /
  * Build the wilderness area outside of the town.
+ * @return ¤Ê¤·
  */
 void wilderness_gen(void)
 {
@@ -628,9 +688,10 @@ void wilderness_gen(void)
 
 static s16b conv_terrain2feat[MAX_WILDERNESS];
 
-/*
- * Build the wilderness area.
- * -DG-
+/*!
+ * @brief ¹­°è¥Þ¥Ã¥×¤ÎÀ¸À®(´Ê°×½èÍýÈÇ) /
+ * Build the wilderness area. -DG-
+ * @return ¤Ê¤·
  */
 void wilderness_gen_small()
 {
@@ -699,8 +760,17 @@ struct wilderness_grid
 static wilderness_grid w_letter[255];
 
 
-/*
+/*!
+ * @brief w_info.txt¤Î¥Ç¡¼¥¿²òÀÏ /
  * Parse a sub-file of the "extra info"
+ * @param buf Æɤ߼è¤Ã¤¿¥Ç¡¼¥¿¹Ô¤Î¥Ð¥Ã¥Õ¥¡
+ * @param ymin Ì¤»ÈÍÑ
+ * @param xmin ¹­°èÃÏ·Á¥Þ¥Ã¥×¤òÆɤ߹þ¤ß¤¿¤¤xºÂɸ¤Î³«»Ï°ÌÃÖ
+ * @param ymax Ì¤»ÈÍÑ
+ * @param xmax ¹­°èÃÏ·Á¥Þ¥Ã¥×¤òÆɤ߹þ¤ß¤¿¤¤xºÂɸ¤Î½ªÎ»°ÌÃÖ
+ * @param y ¹­°è¥Þ¥Ã¥×¤Î¹â¤µ¤òÊÖ¤¹»²¾È¥Ý¥¤¥ó¥¿
+ * @param x ¹­°è¥Þ¥Ã¥×¤ÎÉý¤òÊÖ¤¹»²¾È¥Ý¥¤¥ó¥¿
+ * @return ¤Ê¤·
  */
 errr parse_line_wilderness(char *buf, int ymin, int xmin, int ymax, int xmax, int *y, int *x)
 {
@@ -843,8 +913,11 @@ errr parse_line_wilderness(char *buf, int ymin, int xmin, int ymax, int xmax, in
 }
 
 
-/*
+
+/*!
+ * @brief ¥²¡¼¥à³«»Ï»þ¤Ë³Æ¹ÓÌî¥Õ¥í¥¢¤ÎÍð¿ô¥·¡¼¥É¤ò»ØÄꤹ¤ë /
  * Generate the random seeds for the wilderness
+ * @return ¤Ê¤·
  */
 void seed_wilderness(void)
 {
@@ -867,8 +940,11 @@ void seed_wilderness(void)
  */
 typedef wilderness_type *wilderness_type_ptr;
 
-/*
+
+/*!
+ * @brief ¥²¡¼¥à³«»Ï»þ¤Î¹ÓÌî½é´ü²½¥á¥¤¥ó¥ë¡¼¥Á¥ó /
  * Initialize wilderness array
+ * @return ¥¨¥é¡¼¥³¡¼¥É
  */
 errr init_wilderness(void)
 {
@@ -887,7 +963,14 @@ errr init_wilderness(void)
        return 0;
 }
 
-
+/*!
+ * @brief ¹ÓÌî¤ÎÃÏÀªÀßÄê¤ò½é´ü²½¤¹¤ë /
+ * Initialize wilderness array
+ * @param terrain ½é´ü²½¤·¤¿¤¤ÃÏÀªID
+ * @param feat_global ´ðËÜŪ¤ÊÃÏ·ÁID
+ * @param fmt ÃÏÀªÆâ¤ÎÃÏ·Á¿ô¤ò»²¾È¤¹¤ë¤¿¤á¤ÎÆȼ«¥Õ¥©¡¼¥Þ¥Ã¥È
+ * @return ¤Ê¤·
+ */
 static void init_terrain_table(int terrain, s16b feat_global, cptr fmt, ...)
 {
        va_list vp;
@@ -937,8 +1020,10 @@ static void init_terrain_table(int terrain, s16b feat_global, cptr fmt, ...)
 }
 
 
-/*
+/*!
+ * @brief ¹ÓÌî¤ÎÃÏÀªÀßÄêÁ´ÂΤò½é´ü²½¤¹¤ë¥á¥¤¥ó¥ë¡¼¥Á¥ó /
  * Initialize arrays for wilderness terrains
+ * @return ¤Ê¤·
  */
 void init_wilderness_terrains(void)
 {
@@ -1015,7 +1100,11 @@ void init_wilderness_terrains(void)
                feat_mountain, MAX_FEAT_IN_TERRAIN - 8);
 }
 
-
+/*!
+ * @brief ¹ÓÌ¤é¹­°è¥Þ¥Ã¥×¤Ø¤ÎÀÚ¤êÂؤ¨½èÍý /
+ * Initialize arrays for wilderness terrains
+ * @return ÀÚ¤êÂؤ¨¤¬¹Ô¤ï¤ì¤¿¾ì¹ç¤ÏTRUE¤òÊÖ¤¹¡£
+ */
 bool change_wild_mode(void)
 {
        int i;