From 622526c4d928a403580a5f70183f7585f6317970 Mon Sep 17 00:00:00 2001 From: deskull Date: Fri, 13 Sep 2019 09:11:02 +0900 Subject: [PATCH] =?utf8?q?[Refactor]=20#38997=20fill=5Ftreasure()=20?= =?utf8?q?=E3=81=AB=20floor=5Ftype=20*=20=E5=BC=95=E6=95=B0=E3=82=92?= =?utf8?q?=E8=BF=BD=E5=8A=A0=EF=BC=8E=20/=20Add=20floor=5Ftype=20*=20argum?= =?utf8?q?ent=20to=20fill=5Ftreasure().?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/rooms-vault.c | 14 +++++++------- src/rooms.c | 36 ++++++++++++++++++------------------ src/rooms.h | 5 ++++- 3 files changed, 29 insertions(+), 26 deletions(-) diff --git a/src/rooms-vault.c b/src/rooms-vault.c index 831602078..c8f326def 100644 --- a/src/rooms-vault.c +++ b/src/rooms-vault.c @@ -165,7 +165,7 @@ static void build_bubble_vault(POSITION x0, POSITION y0, POSITION xsize, POSITIO } /* Fill with monsters and treasure, low difficulty */ - fill_treasure(x0 - xhsize + 1, x0 - xhsize + xsize - 2, y0 - yhsize + 1, y0 - yhsize + ysize - 2, randint1(5)); + fill_treasure(current_floor_ptr, x0 - xhsize + 1, x0 - xhsize + xsize - 2, y0 - yhsize + 1, y0 - yhsize + ysize - 2, randint1(5)); } /* Create a random vault that looks like a collection of overlapping rooms */ @@ -213,7 +213,7 @@ static void build_room_vault(POSITION x0, POSITION y0, POSITION xsize, POSITION } /* Fill with monsters and treasure, high difficulty */ - fill_treasure(x0 - xhsize + 1, x0 - xhsize + xsize - 2, y0 - yhsize + 1, y0 - yhsize + ysize - 2, randint1(5) + 5); + fill_treasure(current_floor_ptr, x0 - xhsize + 1, x0 - xhsize + xsize - 2, y0 - yhsize + 1, y0 - yhsize + ysize - 2, randint1(5) + 5); } @@ -264,7 +264,7 @@ static void build_cave_vault(POSITION x0, POSITION y0, POSITION xsiz, POSITION y } /* Fill with monsters and treasure, low difficulty */ - fill_treasure(x0 - xhsize + 1, x0 - xhsize + xsize - 1, y0 - yhsize + 1, y0 - yhsize + ysize - 1, randint1(5)); + fill_treasure(current_floor_ptr, x0 - xhsize + 1, x0 - xhsize + xsize - 1, y0 - yhsize + 1, y0 - yhsize + ysize - 1, randint1(5)); } @@ -918,7 +918,7 @@ static void build_target_vault(POSITION x0, POSITION y0, POSITION xsize, POSITIO add_door(x0, y0 - y); /* Fill with stuff - medium difficulty */ - fill_treasure(x0 - rad, x0 + rad, y0 - rad, y0 + rad, randint1(3) + 3); + fill_treasure(current_floor_ptr, x0 - rad, x0 + rad, y0 - rad, y0 + rad, randint1(3) + 3); } @@ -1010,7 +1010,7 @@ static void build_elemental_vault(POSITION x0, POSITION y0, POSITION xsiz, POSIT } /* Fill with monsters and treasure, low difficulty */ - fill_treasure(x0 - xhsize + 1, x0 - xhsize + xsize - 1, + fill_treasure(current_floor_ptr, x0 - xhsize + 1, x0 - xhsize + xsize - 1, y0 - yhsize + 1, y0 - yhsize + ysize - 1, randint1(5)); } #endif /* ALLOW_CAVERNS_AND_LAKES */ @@ -1135,7 +1135,7 @@ static void build_mini_c_vault(POSITION x0, POSITION y0, POSITION xsize, POSITIO } /* Fill with monsters and treasure, highest difficulty */ - fill_treasure(x1, x2, y1, y2, 10); + fill_treasure(current_floor_ptr, x1, x2, y1, y2, 10); C_KILL(visited, num_vertices, int); } @@ -1178,7 +1178,7 @@ static void build_castle_vault(POSITION x0, POSITION y0, POSITION xsize, POSITIO build_recursive_room(x1, y1, x2, y2, randint1(5)); /* Fill with monsters and treasure, low difficulty */ - fill_treasure(x1, x2, y1, y2, randint1(3)); + fill_treasure(current_floor_ptr, x1, x2, y1, y2, randint1(3)); } diff --git a/src/rooms.c b/src/rooms.c index 81f007d4d..be5197c30 100644 --- a/src/rooms.c +++ b/src/rooms.c @@ -1379,7 +1379,7 @@ void build_lake(int type) /* * Routine that fills the empty areas of a room with treasure and monsters. */ -void fill_treasure(POSITION x1, POSITION x2, POSITION y1, POSITION y2, int difficulty) +void fill_treasure(floor_type *floor_ptr, POSITION x1, POSITION x2, POSITION y1, POSITION y2, int difficulty) { POSITION x, y, cx, cy, size; s32b value; @@ -1410,28 +1410,28 @@ void fill_treasure(POSITION x1, POSITION x2, POSITION y1, POSITION y2, int diffi if (value < 0) { /* Meanest monster + treasure */ - current_floor_ptr->monster_level = current_floor_ptr->base_level + 40; + floor_ptr->monster_level = floor_ptr->base_level + 40; place_monster(y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP)); - current_floor_ptr->monster_level = current_floor_ptr->base_level; - current_floor_ptr->object_level = current_floor_ptr->base_level + 20; + floor_ptr->monster_level = floor_ptr->base_level; + floor_ptr->object_level = floor_ptr->base_level + 20; place_object(y, x, AM_GOOD); - current_floor_ptr->object_level = current_floor_ptr->base_level; + floor_ptr->object_level = floor_ptr->base_level; } else if (value < 5) { /* Mean monster +treasure */ - current_floor_ptr->monster_level = current_floor_ptr->base_level + 20; + floor_ptr->monster_level = floor_ptr->base_level + 20; place_monster(y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP)); - current_floor_ptr->monster_level = current_floor_ptr->base_level; - current_floor_ptr->object_level = current_floor_ptr->base_level + 10; + floor_ptr->monster_level = floor_ptr->base_level; + floor_ptr->object_level = floor_ptr->base_level + 10; place_object(y, x, AM_GOOD); - current_floor_ptr->object_level = current_floor_ptr->base_level; + floor_ptr->object_level = floor_ptr->base_level; } else if (value < 10) { - current_floor_ptr->monster_level = current_floor_ptr->base_level + 9; + floor_ptr->monster_level = floor_ptr->base_level + 9; place_monster(y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP)); - current_floor_ptr->monster_level = current_floor_ptr->base_level; + floor_ptr->monster_level = floor_ptr->base_level; } else if (value < 17) { @@ -1459,9 +1459,9 @@ void fill_treasure(POSITION x1, POSITION x2, POSITION y1, POSITION y2, int diffi else if (value < 30) { /* Monster and trap */ - current_floor_ptr->monster_level = current_floor_ptr->base_level + 5; + floor_ptr->monster_level = floor_ptr->base_level + 5; place_monster(y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP)); - current_floor_ptr->monster_level = current_floor_ptr->base_level; + floor_ptr->monster_level = floor_ptr->base_level; place_trap(y, x); } else if (value < 40) @@ -1469,15 +1469,15 @@ void fill_treasure(POSITION x1, POSITION x2, POSITION y1, POSITION y2, int diffi /* Monster or object */ if (randint0(100) < 50) { - current_floor_ptr->monster_level = current_floor_ptr->base_level + 3; + floor_ptr->monster_level = floor_ptr->base_level + 3; place_monster(y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP)); - current_floor_ptr->monster_level = current_floor_ptr->base_level; + floor_ptr->monster_level = floor_ptr->base_level; } if (randint0(100) < 50) { - current_floor_ptr->object_level = current_floor_ptr->base_level + 7; + floor_ptr->object_level = floor_ptr->base_level + 7; place_object(y, x, 0L); - current_floor_ptr->object_level = current_floor_ptr->base_level; + floor_ptr->object_level = floor_ptr->base_level; } } else if (value < 50) @@ -1746,7 +1746,7 @@ void build_maze_vault(POSITION x0, POSITION y0, POSITION xsize, POSITION ysize, r_visit(y1, x1, y2, x2, randint0(num_vertices), 0, visited); /* Fill with monsters and treasure, low difficulty */ - if (is_vault) fill_treasure(x1, x2, y1, y2, randint1(5)); + if (is_vault) fill_treasure(current_floor_ptr, x1, x2, y1, y2, randint1(5)); C_KILL(visited, num_vertices, int); } diff --git a/src/rooms.h b/src/rooms.h index 3bd220dcc..24c2e2c1f 100644 --- a/src/rooms.h +++ b/src/rooms.h @@ -9,6 +9,9 @@ * are included in all such copies. Other copyrights may also apply.