X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=src%2Fwild.c;h=3804b8088f1c93d0d899a912987f9ab51f6634fa;hb=refs%2Fheads%2Fmaster;hp=4e75f8ccdf190d5dbce7208f94786b1117ef5669;hpb=3105a430691933b1c8563e598aee962d34c8ae48;p=hengband%2Fhengband.git diff --git a/src/wild.c b/src/wild.c deleted file mode 100644 index 4e75f8ccd..000000000 --- a/src/wild.c +++ /dev/null @@ -1,1190 +0,0 @@ -/*! - * @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. - */ - -#include "angband.h" -#include "wild.h" -#include "world.h" -#include "monster.h" -#include "realm-hex.h" -#include "player-status.h" -#include "grid.h" - - /* - * Wilderness - */ -wilderness_type **wilderness; - - -/*! - * @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; - - lim[0] = prob[0].percent; - for (i = 1; i < DUNGEON_FEAT_PROB_NUM; i++) lim[i] = lim[i - 1] + prob[i].percent; - - /* Paranoia */ - if (lim[DUNGEON_FEAT_PROB_NUM - 1] < 100) lim[DUNGEON_FEAT_PROB_NUM - 1] = 100; - - for (i = 0; i < 100; i++) - { - while (i == lim[cur]) cur++; - feat_type[i] = prob[cur].feat; - } -} - -/*! - * @brief ãã³ã¸ã§ã³ã®å°å½¢ãæå®ç¢ºçã«å¿ãã¦åãã¹ã¸ã©ã³ãã ã«æ·ãè©°ãã - * / Fill the arrays of floors and walls in the good proportions - * @param type ãã³ã¸ã§ã³ID - * @return ãªã - */ -void set_floor_and_wall(DUNGEON_IDX type) -{ - DUNGEON_IDX cur_type = 255; - dungeon_type *d_ptr; - - /* Already filled */ - if (cur_type == type) return; - - cur_type = type; - d_ptr = &d_info[type]; - - set_floor_and_wall_aux(feat_ground_type, d_ptr->floor); - set_floor_and_wall_aux(feat_wall_type, d_ptr->fill); - - feat_wall_outer = d_ptr->outer_wall; - feat_wall_inner = d_ptr->inner_wall; - feat_wall_solid = d_ptr->outer_wall; -} - - -/*! - * @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(FEAT_IDX x1, FEAT_IDX x2, FEAT_IDX x3, FEAT_IDX x4, POSITION xmid, POSITION ymid, FEAT_IDX rough, FEAT_IDX depth_max) -{ - /* - * Average the four corners & perturb it a bit. - * tmp is a random int +/- rough - */ - FEAT_IDX tmp2 = rough*2 + 1; - FEAT_IDX tmp = randint1(tmp2) - (rough + 1); - - FEAT_IDX avg = ((x1 + x2 + x3 + x4) / 4) + tmp; - - /* Division always rounds down, so we round up again */ - if (((x1 + x2 + x3 + x4) % 4) > 1) - avg++; - - /* Normalize */ - if (avg < 0) avg = 0; - if (avg > depth_max) avg = depth_max; - - /* Set the new value. */ - current_floor_ptr->grid_array[ymid][xmid].feat = (FEAT_IDX)avg; -} - - -/*! - * @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(FEAT_IDX x1, FEAT_IDX x2, FEAT_IDX x3, POSITION xmid, POSITION ymid, FEAT_IDX rough, FEAT_IDX depth_max) -{ - /* - * Average the three corners & perturb it a bit. - * tmp is a random int +/- rough - */ - FEAT_IDX tmp2 = rough * 2 + 1; - FEAT_IDX tmp = randint0(tmp2) - rough; - - FEAT_IDX avg = ((x1 + x2 + x3) / 3) + tmp; - - /* Division always rounds down, so we round up again */ - if ((x1 + x2 + x3) % 3) avg++; - - /* Normalize */ - if (avg < 0) avg = 0; - if (avg > depth_max) avg = depth_max; - - /* Set the new value. */ - current_floor_ptr->grid_array[ymid][xmid].feat = (FEAT_IDX)avg; -} - - -/*! - * @brief ãã©ãºããã©ã¯ã¿ã«çå°å½¢çæã®éå§å¦ç - * / Helper for plasma generation. - * @param x1 å¦çç¯å²ã®å·¦ä¸Xåº§æ¨ - * @param y1 å¦çç¯å²ã®å·¦ä¸Yåº§æ¨ - * @param x2 å¦çç¯å²ã®å³ä¸Xåº§æ¨ - * @param y2 å¦çç¯å²ã®å³ä¸Yåº§æ¨ - * @param depth_max æ·±ã¿ã®æå¤§å¤ - * @param rough ã©ã³ãã å¹ - * @return ãªã - * @details - *
- * 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. - *- */ -static void plasma_recursive(POSITION x1, POSITION y1, POSITION x2, POSITION y2, FEAT_IDX depth_max, FEAT_IDX rough) -{ - /* Find middle */ - POSITION xmid = (x2 - x1) / 2 + x1; - POSITION ymid = (y2 - y1) / 2 + y1; - - /* Are we done? */ - if (x1 + 1 == x2) return; - - perturb_point_mid(current_floor_ptr->grid_array[y1][x1].feat, current_floor_ptr->grid_array[y2][x1].feat, current_floor_ptr->grid_array[y1][x2].feat, - current_floor_ptr->grid_array[y2][x2].feat, xmid, ymid, rough, depth_max); - - perturb_point_end(current_floor_ptr->grid_array[y1][x1].feat, current_floor_ptr->grid_array[y1][x2].feat, current_floor_ptr->grid_array[ymid][xmid].feat, - xmid, y1, rough, depth_max); - - perturb_point_end(current_floor_ptr->grid_array[y1][x2].feat, current_floor_ptr->grid_array[y2][x2].feat, current_floor_ptr->grid_array[ymid][xmid].feat, - x2, ymid, rough, depth_max); - - perturb_point_end(current_floor_ptr->grid_array[y2][x2].feat, current_floor_ptr->grid_array[y2][x1].feat, current_floor_ptr->grid_array[ymid][xmid].feat, - xmid, y2, rough, depth_max); - - perturb_point_end(current_floor_ptr->grid_array[y2][x1].feat, current_floor_ptr->grid_array[y1][x1].feat, current_floor_ptr->grid_array[ymid][xmid].feat, - x1, ymid, rough, depth_max); - - - /* Recurse the four quadrants */ - plasma_recursive(x1, y1, xmid, ymid, depth_max, rough); - plasma_recursive(xmid, y1, x2, ymid, depth_max, rough); - plasma_recursive(x1, ymid, xmid, y2, depth_max, rough); - plasma_recursive(xmid, ymid, x2, y2, depth_max, rough); -} - - -#define MAX_FEAT_IN_TERRAIN 18 - -/* - * The default table in terrain level generation. - */ -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) -{ - POSITION x1, y1; - int table_size = sizeof(terrain_table[0]) / sizeof(s16b); - FEAT_IDX roughness = 1; /* The roughness of the level. */ - u32b state_backup[4]; - - /* Unused */ - (void)border; - - /* The outer wall is easy */ - if (terrain == TERRAIN_EDGE) - { - /* Create level background */ - for (y1 = 0; y1 < MAX_HGT; y1++) - { - for (x1 = 0; x1 < MAX_WID; x1++) - { - current_floor_ptr->grid_array[y1][x1].feat = feat_permanent; - } - } - - /* We are done already */ - return; - } - - - /* Hack -- Backup the RNG state */ - Rand_state_backup(state_backup); - - /* Hack -- Induce consistant flavors */ - Rand_state_set(seed); - - if (!corner) - { - /* Create level background */ - for (y1 = 0; y1 < MAX_HGT; y1++) - { - for (x1 = 0; x1 < MAX_WID; x1++) - { - current_floor_ptr->grid_array[y1][x1].feat = table_size / 2; - } - } - } - - /* - * Initialize the four corners - * ToDo: calculate the medium height of the adjacent - * terrains for every corner. - */ - current_floor_ptr->grid_array[1][1].feat = (s16b)randint0(table_size); - current_floor_ptr->grid_array[MAX_HGT-2][1].feat = (s16b)randint0(table_size); - current_floor_ptr->grid_array[1][MAX_WID-2].feat = (s16b)randint0(table_size); - current_floor_ptr->grid_array[MAX_HGT-2][MAX_WID-2].feat = (s16b)randint0(table_size); - - if (!corner) - { - /* Hack -- preserve four corners */ - s16b north_west = current_floor_ptr->grid_array[1][1].feat; - s16b south_west = current_floor_ptr->grid_array[MAX_HGT - 2][1].feat; - s16b north_east = current_floor_ptr->grid_array[1][MAX_WID - 2].feat; - s16b south_east = current_floor_ptr->grid_array[MAX_HGT - 2][MAX_WID - 2].feat; - - /* x1, y1, x2, y2, num_depths, roughness */ - plasma_recursive(1, 1, MAX_WID-2, MAX_HGT-2, table_size-1, roughness); - - /* Hack -- copyback four corners */ - current_floor_ptr->grid_array[1][1].feat = north_west; - current_floor_ptr->grid_array[MAX_HGT - 2][1].feat = south_west; - current_floor_ptr->grid_array[1][MAX_WID - 2].feat = north_east; - current_floor_ptr->grid_array[MAX_HGT - 2][MAX_WID - 2].feat = south_east; - - for (y1 = 1; y1 < MAX_HGT - 1; y1++) - { - for (x1 = 1; x1 < MAX_WID - 1; x1++) - { - current_floor_ptr->grid_array[y1][x1].feat = terrain_table[terrain][current_floor_ptr->grid_array[y1][x1].feat]; - } - } - } - else /* Hack -- only four corners */ - { - current_floor_ptr->grid_array[1][1].feat = terrain_table[terrain][current_floor_ptr->grid_array[1][1].feat]; - current_floor_ptr->grid_array[MAX_HGT - 2][1].feat = terrain_table[terrain][current_floor_ptr->grid_array[MAX_HGT - 2][1].feat]; - current_floor_ptr->grid_array[1][MAX_WID - 2].feat = terrain_table[terrain][current_floor_ptr->grid_array[1][MAX_WID - 2].feat]; - current_floor_ptr->grid_array[MAX_HGT - 2][MAX_WID - 2].feat = terrain_table[terrain][current_floor_ptr->grid_array[MAX_HGT - 2][MAX_WID - 2].feat]; - } - - /* 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 åºåXåº§æ¨ - * @param border åºåãããã®è¾ºé¨åã¨ãã¦ã®çæãªãã°TRUE - * @param corner åºåãããã®è§é¨åã¨ãã¦ã®çæãªãã°TRUE - * @return ãªã - * @details - *
- * 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. - *- */ -static void generate_area(POSITION y, POSITION x, bool border, bool corner) -{ - POSITION x1, y1; - - /* Number of the town (if any) */ - p_ptr->town_num = wilderness[y][x].town; - - /* Set the base level */ - current_floor_ptr->base_level = wilderness[y][x].level; - - /* Set the dungeon level */ - current_floor_ptr->dun_level = 0; - - /* Set the monster generation level */ - current_floor_ptr->monster_level = current_floor_ptr->base_level; - - /* Set the object generation level */ - current_floor_ptr->object_level = current_floor_ptr->base_level; - - - /* Create the town */ - if (p_ptr->town_num) - { - /* Reset the buildings */ - init_buildings(); - - /* Initialize the town */ - if (border | corner) - init_flags = INIT_CREATE_DUNGEON | INIT_ONLY_FEATURES; - else - init_flags = INIT_CREATE_DUNGEON; - - process_dungeon_file("t_info.txt", 0, 0, MAX_HGT, MAX_WID); - - if (!corner && !border) p_ptr->visit |= (1L << (p_ptr->town_num - 1)); - } - else - { - int terrain = wilderness[y][x].terrain; - u32b seed = wilderness[y][x].seed; - - generate_wilderness_area(terrain, seed, border, corner); - } - - if (!corner && !wilderness[y][x].town) - { - /* - * Place roads in the wilderness - * ToDo: make the road a bit more interresting - */ - if (wilderness[y][x].road) - { - current_floor_ptr->grid_array[MAX_HGT/2][MAX_WID/2].feat = feat_floor; - - if (wilderness[y-1][x].road) - { - /* North road */ - for (y1 = 1; y1 < MAX_HGT/2; y1++) - { - x1 = MAX_WID/2; - current_floor_ptr->grid_array[y1][x1].feat = feat_floor; - } - } - - if (wilderness[y+1][x].road) - { - /* North road */ - for (y1 = MAX_HGT/2; y1 < MAX_HGT - 1; y1++) - { - x1 = MAX_WID/2; - current_floor_ptr->grid_array[y1][x1].feat = feat_floor; - } - } - - if (wilderness[y][x+1].road) - { - /* East road */ - for (x1 = MAX_WID/2; x1 < MAX_WID - 1; x1++) - { - y1 = MAX_HGT/2; - current_floor_ptr->grid_array[y1][x1].feat = feat_floor; - } - } - - if (wilderness[y][x-1].road) - { - /* West road */ - for (x1 = 1; x1 < MAX_WID/2; x1++) - { - y1 = MAX_HGT/2; - current_floor_ptr->grid_array[y1][x1].feat = feat_floor; - } - } - } - } - - 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 -- Backup the RNG state */ - Rand_state_backup(state_backup); - - /* Hack -- Induce consistant flavors */ - Rand_state_set(wilderness[y][x].seed); - - dy = rand_range(6, current_floor_ptr->height - 6); - dx = rand_range(6, current_floor_ptr->width - 6); - - current_floor_ptr->grid_array[dy][dx].feat = feat_entrance; - current_floor_ptr->grid_array[dy][dx].special = wilderness[y][x].entrance; - - /* Hack -- Restore the RNG state */ - Rand_state_restore(state_backup); - } -} - - -/* - * Border of the wilderness area - */ -static border_type border; - - -/*! - * @brief åºåãããã®çæ / - * Build the wilderness area outside of the town. - * @return ãªã - */ -void wilderness_gen(void) -{ - int i, lim; - POSITION y, x; - grid_type *g_ptr; - feature_type *f_ptr; - - /* Big town */ - current_floor_ptr->height = MAX_HGT; - current_floor_ptr->width = MAX_WID; - - /* Assume illegal panel */ - panel_row_min = current_floor_ptr->height; - panel_col_min = current_floor_ptr->width; - - /* Init the wilderness */ - - 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; - get_mon_num_prep(get_monster_hook(), NULL); - - /* North border */ - generate_area(y - 1, x, TRUE, FALSE); - - for (i = 1; i < MAX_WID - 1; i++) - { - border.north[i] = current_floor_ptr->grid_array[MAX_HGT - 2][i].feat; - } - - /* South border */ - generate_area(y + 1, x, TRUE, FALSE); - - for (i = 1; i < MAX_WID - 1; i++) - { - border.south[i] = current_floor_ptr->grid_array[1][i].feat; - } - - /* West border */ - generate_area(y, x - 1, TRUE, FALSE); - - for (i = 1; i < MAX_HGT - 1; i++) - { - border.west[i] = current_floor_ptr->grid_array[i][MAX_WID - 2].feat; - } - - /* East border */ - generate_area(y, x + 1, TRUE, FALSE); - - for (i = 1; i < MAX_HGT - 1; i++) - { - border.east[i] = current_floor_ptr->grid_array[i][1].feat; - } - - /* North west corner */ - generate_area(y - 1, x - 1, FALSE, TRUE); - border.north_west = current_floor_ptr->grid_array[MAX_HGT - 2][MAX_WID - 2].feat; - - /* North east corner */ - generate_area(y - 1, x + 1, FALSE, TRUE); - border.north_east = current_floor_ptr->grid_array[MAX_HGT - 2][1].feat; - - /* South west corner */ - generate_area(y + 1, x - 1, FALSE, TRUE); - border.south_west = current_floor_ptr->grid_array[1][MAX_WID - 2].feat; - - /* South east corner */ - generate_area(y + 1, x + 1, FALSE, TRUE); - border.south_east = current_floor_ptr->grid_array[1][1].feat; - - - /* Create terrain of the current area */ - generate_area(y, x, FALSE, FALSE); - - - /* Special boundary walls -- North */ - for (i = 0; i < MAX_WID; i++) - { - current_floor_ptr->grid_array[0][i].feat = feat_permanent; - current_floor_ptr->grid_array[0][i].mimic = border.north[i]; - } - - /* Special boundary walls -- South */ - for (i = 0; i < MAX_WID; i++) - { - current_floor_ptr->grid_array[MAX_HGT - 1][i].feat = feat_permanent; - current_floor_ptr->grid_array[MAX_HGT - 1][i].mimic = border.south[i]; - } - - /* Special boundary walls -- West */ - for (i = 0; i < MAX_HGT; i++) - { - current_floor_ptr->grid_array[i][0].feat = feat_permanent; - current_floor_ptr->grid_array[i][0].mimic = border.west[i]; - } - - /* Special boundary walls -- East */ - for (i = 0; i < MAX_HGT; i++) - { - current_floor_ptr->grid_array[i][MAX_WID - 1].feat = feat_permanent; - current_floor_ptr->grid_array[i][MAX_WID - 1].mimic = border.east[i]; - } - - /* North west corner */ - current_floor_ptr->grid_array[0][0].mimic = border.north_west; - - /* North east corner */ - current_floor_ptr->grid_array[0][MAX_WID - 1].mimic = border.north_east; - - /* South west corner */ - current_floor_ptr->grid_array[MAX_HGT - 1][0].mimic = border.south_west; - - /* South east corner */ - current_floor_ptr->grid_array[MAX_HGT - 1][MAX_WID - 1].mimic = border.south_east; - - /* Light up or darken the area */ - for (y = 0; y < current_floor_ptr->height; y++) - { - for (x = 0; x < current_floor_ptr->width; x++) - { - g_ptr = ¤t_floor_ptr->grid_array[y][x]; - - if (is_daytime()) - { - /* Assume lit */ - g_ptr->info |= (CAVE_GLOW); - - /* Hack -- Memorize lit grids if allowed */ - if (view_perma_grids) g_ptr->info |= (CAVE_MARK); - } - else - { - /* Feature code (applying "mimic" field) */ - f_ptr = &f_info[get_feat_mimic(g_ptr)]; - - if (!is_mirror_grid(g_ptr) && !have_flag(f_ptr->flags, FF_QUEST_ENTER) && - !have_flag(f_ptr->flags, FF_ENTRANCE)) - { - /* Assume dark */ - g_ptr->info &= ~(CAVE_GLOW); - - /* Darken "boring" features */ - if (!have_flag(f_ptr->flags, FF_REMEMBER)) - { - /* Forget the grid */ - g_ptr->info &= ~(CAVE_MARK); - } - } - else if (have_flag(f_ptr->flags, FF_ENTRANCE)) - { - /* Assume lit */ - g_ptr->info |= (CAVE_GLOW); - - /* Hack -- Memorize lit grids if allowed */ - if (view_perma_grids) g_ptr->info |= (CAVE_MARK); - } - } - } - } - - if (p_ptr->teleport_town) - { - for (y = 0; y < current_floor_ptr->height; y++) - { - for (x = 0; x < current_floor_ptr->width; x++) - { - g_ptr = ¤t_floor_ptr->grid_array[y][x]; - - /* Seeing true feature code (ignore mimic) */ - f_ptr = &f_info[g_ptr->feat]; - - if (have_flag(f_ptr->flags, FF_BLDG)) - { - if ((f_ptr->subtype == 4) || ((p_ptr->town_num == 1) && (f_ptr->subtype == 0))) - { - if (g_ptr->m_idx) delete_monster_idx(g_ptr->m_idx); - p_ptr->oldpy = y; - p_ptr->oldpx = x; - } - } - } - } - p_ptr->teleport_town = FALSE; - } - - else if (p_ptr->leaving_dungeon) - { - for (y = 0; y < current_floor_ptr->height; y++) - { - for (x = 0; x < current_floor_ptr->width; x++) - { - g_ptr = ¤t_floor_ptr->grid_array[y][x]; - - if (cave_have_flag_grid(g_ptr, FF_ENTRANCE)) - { - if (g_ptr->m_idx) delete_monster_idx(g_ptr->m_idx); - p_ptr->oldpy = y; - p_ptr->oldpx = x; - } - } - } - p_ptr->teleport_town = FALSE; - } - - player_place(p_ptr->oldpy, p_ptr->oldpx); - /* p_ptr->leaving_dungeon = FALSE;*/ - - lim = (generate_encounter == TRUE) ? 40 : MIN_M_ALLOC_TN; - - /* Make some residents */ - for (i = 0; i < lim; i++) - { - BIT_FLAGS 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, mode); - } - - if(generate_encounter) p_ptr->ambush_flag = TRUE; - generate_encounter = FALSE; - - /* 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_q_idx; i++) - { - if (quest[i].status == QUEST_STATUS_REWARDED) - quest[i].status = QUEST_STATUS_FINISHED; - } -} - - -static s16b conv_terrain2feat[MAX_WILDERNESS]; - -/*! - * @brief åºåãããã®çæ(ç°¡æå¦çç) / - * Build the wilderness area. -DG- - * @return ãªã - */ -void wilderness_gen_small(void) -{ - int i, j; - - /* To prevent stupid things */ - for (i = 0; i < MAX_WID; i++) - for (j = 0; j < MAX_HGT; j++) - { - current_floor_ptr->grid_array[j][i].feat = feat_permanent; - } - - /* Init the wilderness */ - 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 < 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)) - { - current_floor_ptr->grid_array[j][i].feat = (s16b)feat_town; - current_floor_ptr->grid_array[j][i].special = (s16b)wilderness[j][i].town; - } - else if (wilderness[j][i].road) current_floor_ptr->grid_array[j][i].feat = feat_floor; - else if (wilderness[j][i].entrance && (p_ptr->total_winner || !(d_info[wilderness[j][i].entrance].flags1 & DF1_WINNER))) - { - current_floor_ptr->grid_array[j][i].feat = feat_entrance; - current_floor_ptr->grid_array[j][i].special = (byte)wilderness[j][i].entrance; - } - else current_floor_ptr->grid_array[j][i].feat = conv_terrain2feat[wilderness[j][i].terrain]; - - current_floor_ptr->grid_array[j][i].info |= (CAVE_GLOW | CAVE_MARK); - } - - 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; - - /* Assume illegal panel */ - panel_row_min = current_floor_ptr->height; - panel_col_min = current_floor_ptr->width; - - /* Place the player */ - p_ptr->x = p_ptr->wilderness_x; - p_ptr->y = p_ptr->wilderness_y; - - p_ptr->town_num = 0; -} - - -typedef struct wilderness_grid wilderness_grid; - -struct wilderness_grid -{ - int terrain; /* Terrain type */ - TOWN_IDX town; /* Town number */ - DEPTH level; /* Level of the wilderness */ - byte road; /* Road */ - char name[32]; /* Name of the town/wilderness */ -}; - - -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) -{ - int i, num; - char *zz[33]; - - /* Unused */ - (void)ymin; - (void)ymax; - - /* Paranoia */ - if (!(buf[0] == 'W')) return (PARSE_ERROR_GENERIC); - - switch (buf[2]) - { - /* Process "W:F: