• R/O
  • HTTP
  • SSH
  • HTTPS

hengband: Commit

変愚蛮怒のメインリポジトリです


Commit MetaInfo

Revisione7d5efcb10efe53e64bab679f1ba4ac55d06ac0b (tree)
Time2019-08-18 23:59:35
Authordeskull <deskull@user...>
Commiterdeskull

Log Message

[Refactor] #38997 cave_gen() に floor_type * 引数を追加.

Change Summary

Incremental Difference

--- a/src/floor-generate.c
+++ b/src/floor-generate.c
@@ -571,16 +571,16 @@ static void gen_caverns_and_lakes(void)
571571 * @details Note that "dun_body" adds about 4000 bytes of memory to the stack.
572572 * @return ダンジョン生成が全て無事に成功したらTRUEを返す。
573573 */
574-static bool cave_gen(void)
574+static bool cave_gen(floor_type *floor_ptr)
575575 {
576576 int i, k;
577577 POSITION y, x;
578578 dun_data dun_body;
579579
580- current_floor_ptr->lite_n = 0;
581- current_floor_ptr->mon_lite_n = 0;
582- current_floor_ptr->redraw_n = 0;
583- current_floor_ptr->view_n = 0;
580+ floor_ptr->lite_n = 0;
581+ floor_ptr->mon_lite_n = 0;
582+ floor_ptr->redraw_n = 0;
583+ floor_ptr->view_n = 0;
584584
585585 /* Global data */
586586 dun = &dun_body;
@@ -602,8 +602,8 @@ static bool cave_gen(void)
602602 dun_tun_jct = rand_range(DUN_TUN_JCT_MIN, DUN_TUN_JCT_MAX);
603603
604604 /* Actual maximum number of rooms on this level */
605- dun->row_rooms = current_floor_ptr->height / BLOCK_HGT;
606- dun->col_rooms = current_floor_ptr->width / BLOCK_WID;
605+ dun->row_rooms = floor_ptr->height / BLOCK_HGT;
606+ dun->col_rooms = floor_ptr->width / BLOCK_WID;
607607
608608 /* Initialize the room table */
609609 for (y = 0; y < dun->row_rooms; y++)
@@ -627,34 +627,34 @@ static bool cave_gen(void)
627627 if (dun->empty_level)
628628 {
629629 /* Start with floors */
630- for (y = 0; y < current_floor_ptr->height; y++)
630+ for (y = 0; y < floor_ptr->height; y++)
631631 {
632- for (x = 0; x < current_floor_ptr->width; x++)
632+ for (x = 0; x < floor_ptr->width; x++)
633633 {
634634 place_floor_bold(y, x);
635635 }
636636 }
637637
638638 /* Special boundary walls -- Top and bottom */
639- for (x = 0; x < current_floor_ptr->width; x++)
639+ for (x = 0; x < floor_ptr->width; x++)
640640 {
641641 place_extra_bold(0, x);
642- place_extra_bold(current_floor_ptr->height - 1, x);
642+ place_extra_bold(floor_ptr->height - 1, x);
643643 }
644644
645645 /* Special boundary walls -- Left and right */
646- for (y = 1; y < (current_floor_ptr->height - 1); y++)
646+ for (y = 1; y < (floor_ptr->height - 1); y++)
647647 {
648648 place_extra_bold(y, 0);
649- place_extra_bold(y, current_floor_ptr->width - 1);
649+ place_extra_bold(y, floor_ptr->width - 1);
650650 }
651651 }
652652 else
653653 {
654654 /* Start with walls */
655- for (y = 0; y < current_floor_ptr->height; y++)
655+ for (y = 0; y < floor_ptr->height; y++)
656656 {
657- for (x = 0; x < current_floor_ptr->width; x++)
657+ for (x = 0; x < floor_ptr->width; x++)
658658 {
659659 place_extra_bold(y, x);
660660 }
@@ -667,7 +667,7 @@ static bool cave_gen(void)
667667 /* Build maze */
668668 if (d_info[p_ptr->dungeon_idx].flags1 & DF1_MAZE)
669669 {
670- build_maze_vault(current_floor_ptr->width/2-1, current_floor_ptr->height/2-1, current_floor_ptr->width-4, current_floor_ptr->height-4, FALSE);
670+ build_maze_vault(floor_ptr->width/2-1, floor_ptr->height/2-1, floor_ptr->width-4, floor_ptr->height-4, FALSE);
671671
672672 /* Place 3 or 4 down stairs near some walls */
673673 if (!alloc_stairs(feat_down_stair, rand_range(2, 3), 3)) return FALSE;
@@ -688,11 +688,11 @@ static bool cave_gen(void)
688688
689689
690690 /* Make a hole in the dungeon roof sometimes at level 1 */
691- if (current_floor_ptr->dun_level == 1)
691+ if (floor_ptr->dun_level == 1)
692692 {
693693 while (one_in_(DUN_MOS_DEN))
694694 {
695- place_trees(randint1(current_floor_ptr->width - 2), randint1(current_floor_ptr->height - 2));
695+ place_trees(randint1(floor_ptr->width - 2), randint1(floor_ptr->height - 2));
696696 }
697697 }
698698
@@ -700,12 +700,12 @@ static bool cave_gen(void)
700700 if (dun->destroyed) destroy_level();
701701
702702 /* Hack -- Add some rivers */
703- if (one_in_(3) && (randint1(current_floor_ptr->dun_level) > 5))
703+ if (one_in_(3) && (randint1(floor_ptr->dun_level) > 5))
704704 {
705705 FEAT_IDX feat1 = 0, feat2 = 0;
706706
707707 /* Choose water mainly */
708- if ((randint1(MAX_DEPTH * 2) - 1 > current_floor_ptr->dun_level) && (d_info[p_ptr->dungeon_idx].flags1 & DF1_WATER_RIVER))
708+ if ((randint1(MAX_DEPTH * 2) - 1 > floor_ptr->dun_level) && (d_info[p_ptr->dungeon_idx].flags1 & DF1_WATER_RIVER))
709709 {
710710 feat1 = feat_deep_water;
711711 feat2 = feat_shallow_water;
@@ -793,7 +793,7 @@ static bool cave_gen(void)
793793 dun->wall_n = 0;
794794
795795 /* Connect the room to the previous room */
796- if (randint1(current_floor_ptr->dun_level) > d_info[p_ptr->dungeon_idx].tunnel_percent)
796+ if (randint1(floor_ptr->dun_level) > d_info[p_ptr->dungeon_idx].tunnel_percent)
797797 {
798798 /* make cavelike tunnel */
799799 (void)build_tunnel2(dun->cent[i].x, dun->cent[i].y, x, y, 2, 2);
@@ -813,7 +813,7 @@ static bool cave_gen(void)
813813 feature_type *f_ptr;
814814 y = dun->tunn[j].y;
815815 x = dun->tunn[j].x;
816- g_ptr = &current_floor_ptr->grid_array[y][x];
816+ g_ptr = &floor_ptr->grid_array[y][x];
817817 f_ptr = &f_info[g_ptr->feat];
818818
819819 /* Clear previous contents (if not a lake), add a floor */
@@ -832,7 +832,7 @@ static bool cave_gen(void)
832832 grid_type *g_ptr;
833833 y = dun->wall[j].y;
834834 x = dun->wall[j].x;
835- g_ptr = &current_floor_ptr->grid_array[y][x];
835+ g_ptr = &floor_ptr->grid_array[y][x];
836836
837837 /* Clear mimic type */
838838 g_ptr->mimic = 0;
@@ -896,17 +896,17 @@ static bool cave_gen(void)
896896 }
897897
898898 /* Special boundary walls -- Top and bottom */
899- for (x = 0; x < current_floor_ptr->width; x++)
899+ for (x = 0; x < floor_ptr->width; x++)
900900 {
901- place_bound_perm_wall(&current_floor_ptr->grid_array[0][x]);
902- place_bound_perm_wall(&current_floor_ptr->grid_array[current_floor_ptr->height - 1][x]);
901+ place_bound_perm_wall(&floor_ptr->grid_array[0][x]);
902+ place_bound_perm_wall(&floor_ptr->grid_array[floor_ptr->height - 1][x]);
903903 }
904904
905905 /* Special boundary walls -- Left and right */
906- for (y = 1; y < (current_floor_ptr->height - 1); y++)
906+ for (y = 1; y < (floor_ptr->height - 1); y++)
907907 {
908- place_bound_perm_wall(&current_floor_ptr->grid_array[y][0]);
909- place_bound_perm_wall(&current_floor_ptr->grid_array[y][current_floor_ptr->width - 1]);
908+ place_bound_perm_wall(&floor_ptr->grid_array[y][0]);
909+ place_bound_perm_wall(&floor_ptr->grid_array[y][floor_ptr->width - 1]);
910910 }
911911
912912 /* Determine the character location */
@@ -915,7 +915,7 @@ static bool cave_gen(void)
915915 if (!place_quest_monsters()) return FALSE;
916916
917917 /* Basic "amount" */
918- k = (current_floor_ptr->dun_level / 3);
918+ k = (floor_ptr->dun_level / 3);
919919 if (k > 10) k = 10;
920920 if (k < 2) k = 2;
921921
@@ -923,12 +923,12 @@ static bool cave_gen(void)
923923 i = d_info[p_ptr->dungeon_idx].min_m_alloc_level;
924924
925925 /* To make small levels a bit more playable */
926- if (current_floor_ptr->height < MAX_HGT || current_floor_ptr->width < MAX_WID)
926+ if (floor_ptr->height < MAX_HGT || floor_ptr->width < MAX_WID)
927927 {
928928 int small_tester = i;
929929
930- i = (i * current_floor_ptr->height) / MAX_HGT;
931- i = (i * current_floor_ptr->width) / MAX_WID;
930+ i = (i * floor_ptr->height) / MAX_HGT;
931+ i = (i * floor_ptr->width) / MAX_WID;
932932 i += 1;
933933
934934 if (i > small_tester) i = small_tester;
@@ -952,10 +952,10 @@ static bool cave_gen(void)
952952 if (!(d_info[p_ptr->dungeon_idx].flags1 & DF1_NO_CAVE)) alloc_object(ALLOC_SET_CORR, ALLOC_TYP_RUBBLE, randint1(k));
953953
954954 /* Mega Hack -- No object at first level of deeper dungeon */
955- if (p_ptr->enter_dungeon && current_floor_ptr->dun_level > 1)
955+ if (p_ptr->enter_dungeon && floor_ptr->dun_level > 1)
956956 {
957957 /* No stair scum! */
958- current_floor_ptr->object_level = 1;
958+ floor_ptr->object_level = 1;
959959 }
960960
961961 /* Put some objects in rooms */
@@ -966,19 +966,19 @@ static bool cave_gen(void)
966966 alloc_object(ALLOC_SET_BOTH, ALLOC_TYP_GOLD, randnor(DUN_AMT_GOLD, 3));
967967
968968 /* Set back to default */
969- current_floor_ptr->object_level = current_floor_ptr->base_level;
969+ floor_ptr->object_level = floor_ptr->base_level;
970970
971971 /* Put the Guardian */
972972 if (!alloc_guardian(TRUE)) return FALSE;
973973
974- if (dun->empty_level && (!one_in_(DARK_EMPTY) || (randint1(100) > current_floor_ptr->dun_level)) && !(d_info[p_ptr->dungeon_idx].flags1 & DF1_DARKNESS))
974+ if (dun->empty_level && (!one_in_(DARK_EMPTY) || (randint1(100) > floor_ptr->dun_level)) && !(d_info[p_ptr->dungeon_idx].flags1 & DF1_DARKNESS))
975975 {
976- /* Lite the current_floor_ptr->grid_array */
977- for (y = 0; y < current_floor_ptr->height; y++)
976+ /* Lite the floor_ptr->grid_array */
977+ for (y = 0; y < floor_ptr->height; y++)
978978 {
979- for (x = 0; x < current_floor_ptr->width; x++)
979+ for (x = 0; x < floor_ptr->width; x++)
980980 {
981- current_floor_ptr->grid_array[y][x].info |= (CAVE_GLOW);
981+ floor_ptr->grid_array[y][x].info |= (CAVE_GLOW);
982982 }
983983 }
984984 }
@@ -1294,7 +1294,7 @@ static bool level_gen(concptr *why)
12941294 }
12951295
12961296 /* Make a dungeon */
1297- if (!cave_gen())
1297+ if (!cave_gen(current_floor_ptr))
12981298 {
12991299 *why = _("ダンジョン生成に失敗", "could not place player");
13001300 return FALSE;
--- a/src/floor.h
+++ b/src/floor.h
@@ -81,6 +81,7 @@
8181
8282
8383 typedef struct {
84+ DUNGEON_IDX dungeon_idx;
8485 grid_type *grid_array[MAX_HGT];
8586 DEPTH dun_level; /*!< 現在の実ダンジョン階層base_levelの参照元となる / Current dungeon level */
8687 DEPTH base_level; /*!< 基本生成レベル、後述のobject_level, monster_levelの参照元となる / Base dungeon level */
Show on old repository browser