X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=src%2Ffloor-streams.c;h=90c496b206316229e4e2db4c256db460ca2b13ba;hb=cfd7ea37c987ee6a6b90bdef086ffdf7f1ef4789;hp=226c64a71f7694035a36b153e7ba2360e5016694;hpb=aa2a23ea768c9bd91b80a66f6c72d73d9bf6e82e;p=hengband%2Fhengband.git diff --git a/src/floor-streams.c b/src/floor-streams.c index 226c64a71..90c496b20 100644 --- a/src/floor-streams.c +++ b/src/floor-streams.c @@ -18,7 +18,9 @@ #include "angband.h" #include "util.h" +#include "artifact.h" #include "floor-generate.h" +#include "dungeon.h" #include "floor.h" #include "floor-streams.h" #include "grid.h" @@ -26,6 +28,8 @@ #include "feature.h" #include "object-flavor.h" #include "object-hook.h" +#include "spells.h" +#include "spells-floor.h" /*! @@ -40,7 +44,7 @@ * @param width 基本幅 * @return なし */ -static void recursive_river(POSITION x1, POSITION y1, POSITION x2, POSITION y2, FEAT_IDX feat1, FEAT_IDX feat2, POSITION width) +static void recursive_river(floor_type *floor_ptr, POSITION x1, POSITION y1, POSITION x2, POSITION y2, FEAT_IDX feat1, FEAT_IDX feat2, POSITION width) { POSITION dx, dy, length, l, x, y; POSITION changex, changey; @@ -79,20 +83,20 @@ static void recursive_river(POSITION x1, POSITION y1, POSITION x2, POSITION y2, changey = 0; } - if (!in_bounds(y1 + dy + changey, x1 + dx + changex)) + if (!in_bounds(floor_ptr, y1 + dy + changey, x1 + dx + changex)) { changex = 0; changey = 0; } /* construct river out of two smaller ones */ - recursive_river(x1, y1, x1 + dx + changex, y1 + dy + changey, feat1, feat2, width); - recursive_river(x1 + dx + changex, y1 + dy + changey, x2, y2, feat1, feat2, width); + recursive_river(floor_ptr, x1, y1, x1 + dx + changex, y1 + dy + changey, feat1, feat2, width); + recursive_river(floor_ptr, x1 + dx + changex, y1 + dy + changey, x2, y2, feat1, feat2, width); /* Split the river some of the time - junctions look cool */ if (one_in_(DUN_WAT_CHG) && (width > 0)) { - recursive_river(x1 + dx + changex, y1 + dy + changey, + recursive_river(floor_ptr, x1 + dx + changex, y1 + dy + changey, x1 + 8 * (dx + changex), y1 + 8 * (dy + changey), feat1, feat2, width - 1); } @@ -113,9 +117,9 @@ static void recursive_river(POSITION x1, POSITION y1, POSITION x2, POSITION y2, { for (tx = x - width - 1; tx <= x + width + 1; tx++) { - if (!in_bounds2(ty, tx)) continue; + if (!in_bounds2(floor_ptr, ty, tx)) continue; - g_ptr = ¤t_floor_ptr->grid_array[ty][tx]; + g_ptr = &floor_ptr->grid_array[ty][tx]; if (g_ptr->feat == feat1) continue; if (g_ptr->feat == feat2) continue; @@ -140,7 +144,7 @@ static void recursive_river(POSITION x1, POSITION y1, POSITION x2, POSITION y2, /* Lava terrain glows */ if (have_flag(f_info[feat1].flags, FF_LAVA)) { - if (!(d_info[p_ptr->dungeon_idx].flags1 & DF1_DARKNESS)) g_ptr->info |= CAVE_GLOW; + if (!(d_info[floor_ptr->dungeon_idx].flags1 & DF1_DARKNESS)) g_ptr->info |= CAVE_GLOW; } /* Hack -- don't teleport here */ @@ -162,7 +166,7 @@ static void recursive_river(POSITION x1, POSITION y1, POSITION x2, POSITION y2, * @param feat2 境界部地形ID * @return なし */ -void add_river(FEAT_IDX feat1, FEAT_IDX feat2) +void add_river(floor_type *floor_ptr, FEAT_IDX feat1, FEAT_IDX feat2) { POSITION y2, x2; POSITION y1 = 0, x1 = 0; @@ -170,8 +174,8 @@ void add_river(FEAT_IDX feat1, FEAT_IDX feat2) /* Hack -- Choose starting point */ - y2 = randint1(current_floor_ptr->height / 2 - 2) + current_floor_ptr->height / 2; - x2 = randint1(current_floor_ptr->width / 2 - 2) + current_floor_ptr->width / 2; + y2 = randint1(floor_ptr->height / 2 - 2) + floor_ptr->height / 2; + x2 = randint1(floor_ptr->width / 2 - 2) + floor_ptr->width / 2; /* Hack -- Choose ending point somewhere on boundary */ switch(randint1(4)) @@ -179,7 +183,7 @@ void add_river(FEAT_IDX feat1, FEAT_IDX feat2) case 1: { /* top boundary */ - x1 = randint1(current_floor_ptr->width-2)+1; + x1 = randint1(floor_ptr->width-2)+1; y1 = 1; break; } @@ -187,27 +191,27 @@ void add_river(FEAT_IDX feat1, FEAT_IDX feat2) { /* left boundary */ x1 = 1; - y1 = randint1(current_floor_ptr->height-2)+1; + y1 = randint1(floor_ptr->height-2)+1; break; } case 3: { /* right boundary */ - x1 = current_floor_ptr->width-1; - y1 = randint1(current_floor_ptr->height-2)+1; + x1 = floor_ptr->width-1; + y1 = randint1(floor_ptr->height-2)+1; break; } case 4: { /* bottom boundary */ - x1 = randint1(current_floor_ptr->width-2)+1; - y1 = current_floor_ptr->height-1; + x1 = randint1(floor_ptr->width-2)+1; + y1 = floor_ptr->height-1; break; } } wid = randint1(DUN_WAT_RNG); - recursive_river(x1, y1, x2, y2, feat1, feat2, wid); + recursive_river(floor_ptr, x1, y1, x2, y2, feat1, feat2, wid); /* Hack - Save the location as a "room" */ if (dun->cent_n < CENT_MAX) @@ -222,6 +226,7 @@ void add_river(FEAT_IDX feat1, FEAT_IDX feat2) /*! * @brief ダンジョンの壁部にストリーマー(地質の変化)を与える / * Places "streamers" of rock through dungeon + * @param player_ptr プレーヤーへの参照ポインタ * @param feat ストリーマー地形ID * @param chance 生成密度 * @return なし @@ -233,7 +238,7 @@ void add_river(FEAT_IDX feat1, FEAT_IDX feat2) * hidden gold types are currently unused. * */ -void build_streamer(FEAT_IDX feat, int chance) +void build_streamer(player_type *player_ptr, FEAT_IDX feat, int chance) { int i; POSITION y, x, tx, ty; @@ -248,8 +253,9 @@ void build_streamer(FEAT_IDX feat, int chance) bool streamer_may_have_gold = have_flag(streamer_ptr->flags, FF_MAY_HAVE_GOLD); /* Hack -- Choose starting point */ - y = rand_spread(current_floor_ptr->height / 2, current_floor_ptr->height / 6); - x = rand_spread(current_floor_ptr->width / 2, current_floor_ptr->width / 6); + floor_type *floor_ptr = player_ptr->current_floor_ptr; + y = rand_spread(floor_ptr->height / 2, floor_ptr->height / 6); + x = rand_spread(floor_ptr->width / 2, floor_ptr->width / 6); /* Choose a random compass direction */ dir = randint0(8); @@ -265,14 +271,14 @@ void build_streamer(FEAT_IDX feat, int chance) int d = DUN_STR_RNG; /* Pick a nearby grid */ - while (1) + while (TRUE) { ty = rand_spread(y, d); tx = rand_spread(x, d); - if (!in_bounds2(ty, tx)) continue; + if (!in_bounds2(floor_ptr, ty, tx)) continue; break; } - g_ptr = ¤t_floor_ptr->grid_array[ty][tx]; + g_ptr = &floor_ptr->grid_array[ty][tx]; f_ptr = &f_info[g_ptr->feat]; if (have_flag(f_ptr->flags, FF_MOVE) && (have_flag(f_ptr->flags, FF_WATER) || have_flag(f_ptr->flags, FF_LAVA))) @@ -288,10 +294,10 @@ void build_streamer(FEAT_IDX feat, int chance) if (is_closed_door(g_ptr->feat)) continue; } - if (g_ptr->m_idx && !(have_flag(streamer_ptr->flags, FF_PLACE) && monster_can_cross_terrain(feat, &r_info[current_floor_ptr->m_list[g_ptr->m_idx].r_idx], 0))) + if (g_ptr->m_idx && !(have_flag(streamer_ptr->flags, FF_PLACE) && monster_can_cross_terrain(feat, &r_info[floor_ptr->m_list[g_ptr->m_idx].r_idx], 0))) { /* Delete the monster (if any) */ - delete_monster(ty, tx); + delete_monster(player_ptr, ty, tx); } if (g_ptr->o_idx && !have_flag(streamer_ptr->flags, FF_DROP)) @@ -301,7 +307,7 @@ void build_streamer(FEAT_IDX feat, int chance) /* Scan all objects in the grid */ for (this_o_idx = g_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx) { - object_type *o_ptr = ¤t_floor_ptr->o_list[this_o_idx]; + object_type *o_ptr = &floor_ptr->o_list[this_o_idx]; next_o_idx = o_ptr->next_o_idx; /* Hack -- Preserve unknown artifacts */ @@ -325,7 +331,7 @@ void build_streamer(FEAT_IDX feat, int chance) } } - delete_object(ty, tx); + delete_object(floor_ptr, ty, tx); } /* Clear previous contents, add proper vein type */ @@ -339,14 +345,14 @@ void build_streamer(FEAT_IDX feat, int chance) /* Hack -- Add some known treasure */ if (one_in_(chance)) { - cave_alter_feat(ty, tx, FF_MAY_HAVE_GOLD); + cave_alter_feat(player_ptr, ty, tx, FF_MAY_HAVE_GOLD); } /* Hack -- Add some hidden treasure */ else if (one_in_(chance / 4)) { - cave_alter_feat(ty, tx, FF_MAY_HAVE_GOLD); - cave_alter_feat(ty, tx, FF_ENSECRET); + cave_alter_feat(player_ptr, ty, tx, FF_MAY_HAVE_GOLD); + cave_alter_feat(player_ptr, ty, tx, FF_ENSECRET); } } } @@ -368,7 +374,7 @@ void build_streamer(FEAT_IDX feat, int chance) } /* Quit before leaving the dungeon */ - if (!in_bounds(y, x)) break; + if (!in_bounds(floor_ptr, y, x)) break; } } @@ -385,18 +391,19 @@ void build_streamer(FEAT_IDX feat, int chance) * This happens in real world lava tubes. * */ -void place_trees(POSITION x, POSITION y) +void place_trees(player_type *player_ptr, POSITION x, POSITION y) { int i, j; grid_type *g_ptr; /* place trees/ rubble in ovalish distribution */ + floor_type *floor_ptr = player_ptr->current_floor_ptr; for (i = x - 3; i < x + 4; i++) { for (j = y - 3; j < y + 4; j++) { - if (!in_bounds(j, i)) continue; - g_ptr = ¤t_floor_ptr->grid_array[j][i]; + if (!in_bounds(floor_ptr, j, i)) continue; + g_ptr = &floor_ptr->grid_array[j][i]; if (g_ptr->info & CAVE_ICKY) continue; if (g_ptr->o_idx) continue; @@ -411,18 +418,18 @@ void place_trees(POSITION x, POSITION y) if ((distance(j, i, y, x) > 1) || (randint1(100) < 25)) { if (randint1(100) < 75) - current_floor_ptr->grid_array[j][i].feat = feat_tree; + floor_ptr->grid_array[j][i].feat = feat_tree; } else { - current_floor_ptr->grid_array[j][i].feat = feat_rubble; + floor_ptr->grid_array[j][i].feat = feat_rubble; } /* Clear garbage of hidden trap or door */ g_ptr->mimic = 0; /* Light area since is open above */ - if (!(d_info[p_ptr->dungeon_idx].flags1 & DF1_DARKNESS)) current_floor_ptr->grid_array[j][i].info |= (CAVE_GLOW | CAVE_ROOM); + if (!(d_info[player_ptr->dungeon_idx].flags1 & DF1_DARKNESS)) floor_ptr->grid_array[j][i].info |= (CAVE_GLOW | CAVE_ROOM); } } } @@ -431,7 +438,7 @@ void place_trees(POSITION x, POSITION y) if (!ironman_downward && one_in_(3)) { /* up stair */ - current_floor_ptr->grid_array[y][x].feat = feat_up_stair; + floor_ptr->grid_array[y][x].feat = feat_up_stair; } } @@ -441,21 +448,19 @@ void place_trees(POSITION x, POSITION y) * Build a destroyed level * @return なし */ -void destroy_level(void) +void destroy_level(player_type *player_ptr) { - POSITION y1, x1; - int n; - - /* Note destroyed levels */ msg_print_wizard(CHEAT_DUNGEON, _("階に*破壊*の痕跡を生成しました。", "Destroyed Level.")); /* Drop a few epi-centers (usually about two) */ - for (n = 0; n < randint1(5); n++) + POSITION y1, x1; + floor_type *floor_ptr = player_ptr->current_floor_ptr; + for (int n = 0; n < randint1(5); n++) { /* Pick an epi-center */ - x1 = rand_range(5, current_floor_ptr->width - 1 - 5); - y1 = rand_range(5, current_floor_ptr->height - 1 - 5); + x1 = rand_range(5, floor_ptr->width - 1 - 5); + y1 = rand_range(5, floor_ptr->height - 1 - 5); - (void)destroy_area(y1, x1, 15, TRUE); + (void)destroy_area(player_ptr, y1, x1, 15, TRUE); } }