Unify all special level filling options
The existing system was a confusing mess of competing names (filled, needfill, prefilled, etc) that had varying semantics, with prefilled being the worst offender as it meant at least three different things in various contexts. This commit unifies everything in the code under "needfill", and everything in Lua under "filled", which defaults to 0 everywhere. This also removes the second argument to fill_special_room; that function now just checks the needfill of the room it's passed. As before, a filled == 2 value is used for a special room to indicate that the room should set the appropriate level flag, but shouldn't actually be stocked with anything (for instance, King Arthur's throne room); the difference is that this now comes directly from the lua script instead of being manipulated within sp_lev.c. The prefilled argument had one use case that is occasionally used in the level files: if the level designer had specified an ordinary region with prefilled = 1, it would become a room to control monster arrivals on a level -- monsters that arrive within the bounds of a room are supposed to stay there. However, not all of the places where the comments indicated this was being used were using it correctly; I tested this by letting a few monsters fall through the knox portal (they're supposed to be constrained to the entry room) and waiting a hundred turns, then going through the portal; they were not constrained to the room and had "wandered" through its walls. Instead of trying to maintain this special case, I have added an optional "arrival_room" boolean argument to des.region, which forces it to create a room for the purposes of constraining monster arrival. I have gone through and replaced occurrences of prefilled in lua files with the appropriate filled option (or arrival, as needed). In some cases, that resulted in questionable regions such as a filled ordinary area in a non-themeroom (I just dropped the filled=1), or an area which didn't do anything, not even lighting (which I deleted).
This commit is contained in:
committed by
Pasi Kallinen
parent
f57588cef1
commit
0fef8fce9f
@@ -757,7 +757,7 @@ struct mkroom *croom;
|
||||
fill_ordinary_room(croom->sbrooms[x]);
|
||||
}
|
||||
|
||||
if (!croom->needfill)
|
||||
if (croom->needfill != FILL_NORMAL)
|
||||
return;
|
||||
|
||||
/* put a sleeping monster inside */
|
||||
@@ -916,7 +916,7 @@ makelevel()
|
||||
TRUE, VAULT, FALSE);
|
||||
g.level.flags.has_vault = 1;
|
||||
++room_threshold;
|
||||
fill_special_room(&g.rooms[g.nroom - 1], FALSE);
|
||||
fill_special_room(&g.rooms[g.nroom - 1]);
|
||||
mk_knox_portal(g.vault_x + w, g.vault_y + h);
|
||||
if (!g.level.flags.noteleport && !rn2(3))
|
||||
makevtele();
|
||||
|
||||
52
src/sp_lev.c
52
src/sp_lev.c
@@ -1042,10 +1042,10 @@ fill_special_rooms()
|
||||
|
||||
for (tmpi = 0; tmpi < g.nroom; tmpi++) {
|
||||
if (g.rooms[tmpi].needfill)
|
||||
fill_special_room(&g.rooms[tmpi], (g.rooms[tmpi].needfill == 2));
|
||||
fill_special_room(&g.rooms[tmpi]);
|
||||
for (m = 0; m < g.rooms[tmpi].nsubrooms; m++)
|
||||
if (g.rooms[tmpi].sbrooms[m]->needfill)
|
||||
fill_special_room(g.rooms[tmpi].sbrooms[m], FALSE);
|
||||
fill_special_room(g.rooms[tmpi].sbrooms[m]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2682,14 +2682,14 @@ corridor *c;
|
||||
* Fill a room (shop, zoo, etc...) with appropriate stuff.
|
||||
*/
|
||||
void
|
||||
fill_special_room(croom, prefilled)
|
||||
fill_special_room(croom)
|
||||
struct mkroom *croom;
|
||||
boolean prefilled;
|
||||
{
|
||||
if (!croom || croom->rtype == OROOM || croom->rtype == THEMEROOM)
|
||||
if (!croom || croom->rtype == OROOM || croom->rtype == THEMEROOM
|
||||
|| croom->needfill == FILL_NONE)
|
||||
return;
|
||||
|
||||
if (!prefilled) {
|
||||
if (croom->needfill == FILL_NORMAL) {
|
||||
int x, y;
|
||||
|
||||
/* Shop ? */
|
||||
@@ -2770,7 +2770,7 @@ struct mkroom *mkr;
|
||||
#else
|
||||
topologize(aroom); /* set roomno */
|
||||
#endif
|
||||
aroom->needfill = r->filled;
|
||||
aroom->needfill = r->needfill;
|
||||
aroom->needjoining = r->joined;
|
||||
return aroom;
|
||||
}
|
||||
@@ -3831,7 +3831,8 @@ lua_State *L;
|
||||
tmproom.rtype = get_table_roomtype_opt(L, "type", OROOM);
|
||||
tmproom.chance = get_table_int_opt(L, "chance", 100);
|
||||
tmproom.rlit = get_table_int_opt(L, "lit", -1);
|
||||
tmproom.filled = get_table_int_opt(L, "filled", g.in_mk_themerooms ? 0 : 1);
|
||||
/* theme rooms default to unfilled */
|
||||
tmproom.needfill = get_table_int_opt(L, "filled", g.in_mk_themerooms ? 0 : 1);
|
||||
tmproom.joined = get_table_int_opt(L, "joined", 1);
|
||||
|
||||
if (!g.coder->failed_room[g.coder->n_subroom - 1]) {
|
||||
@@ -5599,7 +5600,7 @@ genericptr_t arg;
|
||||
}
|
||||
|
||||
/* region(selection, lit); */
|
||||
/* region({ x1=NN, y1=NN, x2=NN, y2=NN, lit=BOOL, type=ROOMTYPE, joined=BOOL, irregular=BOOL, prefilled=BOOL [ , contents = FUNCTION ] }); */
|
||||
/* region({ x1=NN, y1=NN, x2=NN, y2=NN, lit=BOOL, type=ROOMTYPE, joined=BOOL, irregular=BOOL, filled=NN [ , contents = FUNCTION ] }); */
|
||||
/* region({ region={x1,y1, x2,y2}, type="ordinary" }); */
|
||||
int
|
||||
lspo_region(L)
|
||||
@@ -5607,9 +5608,9 @@ lua_State *L;
|
||||
{
|
||||
xchar dx1, dy1, dx2, dy2;
|
||||
register struct mkroom *troom;
|
||||
boolean prefilled = FALSE, room_not_needed,
|
||||
boolean do_arrival_room = FALSE, room_not_needed,
|
||||
irregular = FALSE, joined = TRUE;
|
||||
int rtype = OROOM, rlit = 1;
|
||||
int rtype = OROOM, rlit = 1, needfill = 0;
|
||||
int argc = lua_gettop(L);
|
||||
|
||||
create_des_coder();
|
||||
@@ -5617,13 +5618,12 @@ lua_State *L;
|
||||
if (argc <= 1) {
|
||||
lcheck_param_table(L);
|
||||
|
||||
/* TODO: check the prefilled, what was the default in lev_comp? */
|
||||
/* "unfilled" == 0, "filled" == 1, missing = "filled" */
|
||||
|
||||
/* TODO: "unfilled" ==> prefilled=1 */
|
||||
prefilled = get_table_boolean_opt(L, "prefilled", 0);
|
||||
/* TODO: "unfilled" ==> filled=0, "filled" ==> filled=1, and
|
||||
* "lvflags_only" ==> filled=2, probably in a get_table_needfill_opt */
|
||||
needfill = get_table_int_opt(L, "filled", 0);
|
||||
irregular = get_table_boolean_opt(L, "irregular", 0);
|
||||
joined = get_table_boolean_opt(L, "joined", 1);
|
||||
do_arrival_room = get_table_boolean_opt(L, "arrival_room", 0);
|
||||
rtype = get_table_roomtype_opt(L, "type", OROOM);
|
||||
rlit = get_table_int_opt(L, "lit", -1);
|
||||
dx1 = get_table_int_opt(L, "x1", -1); /* TODO: area */
|
||||
@@ -5668,10 +5668,16 @@ lua_State *L;
|
||||
get_location(&dx1, &dy1, ANY_LOC, (struct mkroom *) 0);
|
||||
get_location(&dx2, &dy2, ANY_LOC, (struct mkroom *) 0);
|
||||
|
||||
/* for an ordinary room, `prefilled' is a flag to force
|
||||
an actual room to be created (such rooms are used to
|
||||
control placement of migrating monster arrivals) */
|
||||
room_not_needed = (rtype == OROOM && !irregular && !prefilled && !g.in_mk_themerooms);
|
||||
/* Many regions are simple, rectangular areas that just need to set lighting
|
||||
* in an area. In that case, we don't need to do anything complicated by
|
||||
* creating a room. The exceptions are:
|
||||
* - Special rooms (which usually need to be filled).
|
||||
* - Irregular regions (more convenient to use the room-making code).
|
||||
* - Themed room regions (which often have contents).
|
||||
* - When a room is desired to constrain the arrival of migrating monsters
|
||||
* (see the mon_arrive function for details).
|
||||
*/
|
||||
room_not_needed = (rtype == OROOM && !irregular && !do_arrival_room && !g.in_mk_themerooms);
|
||||
if (room_not_needed || g.nroom >= MAXNROFROOMS) {
|
||||
region tmpregion;
|
||||
if (!room_not_needed)
|
||||
@@ -5689,8 +5695,7 @@ lua_State *L;
|
||||
troom = &g.rooms[g.nroom];
|
||||
|
||||
/* mark rooms that must be filled, but do it later */
|
||||
if (rtype != OROOM)
|
||||
troom->needfill = (prefilled ? 2 : 1);
|
||||
troom->needfill = needfill;
|
||||
|
||||
troom->needjoining = joined;
|
||||
|
||||
@@ -5711,9 +5716,6 @@ lua_State *L;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (g.in_mk_themerooms && prefilled)
|
||||
troom->needfill = 1;
|
||||
|
||||
if (!room_not_needed) {
|
||||
if (g.coder->n_subroom > 1)
|
||||
impossible("region as subroom");
|
||||
|
||||
Reference in New Issue
Block a user