Change map terrain changing from macro to function
The function handles setting lava lit, and removing ice melt timers.
This commit is contained in:
@@ -1347,6 +1347,8 @@ extern boolean litstate_rnd(int);
|
|||||||
|
|
||||||
/* ### mkmaze.c ### */
|
/* ### mkmaze.c ### */
|
||||||
|
|
||||||
|
extern boolean set_levltyp(xchar, xchar, schar);
|
||||||
|
extern boolean set_levltyp_lit(xchar, xchar, schar, schar);
|
||||||
extern void create_maze(int, int, boolean);
|
extern void create_maze(int, int, boolean);
|
||||||
extern void wallification(int, int, int, int);
|
extern void wallification(int, int, int, int);
|
||||||
extern void fix_wall_spines(int, int, int, int);
|
extern void fix_wall_spines(int, int, int, int);
|
||||||
|
|||||||
@@ -233,6 +233,13 @@ struct rm {
|
|||||||
Bitfield(candig, 1); /* Exception to Can_dig_down; was a trapdoor */
|
Bitfield(candig, 1); /* Exception to Can_dig_down; was a trapdoor */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* light states for terrain replacements, for set_levltyp_lit */
|
||||||
|
#define SET_LIT_RANDOM -1
|
||||||
|
#define SET_LIT_NOCHANGE -2
|
||||||
|
|
||||||
|
#define CAN_OVERWRITE_TERRAIN(ttyp) \
|
||||||
|
(iflags.debug_overwrite_stairs || !((ttyp) == LADDER || (ttyp) == STAIRS))
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Add wall angle viewing by defining "modes" for each wall type. Each
|
* Add wall angle viewing by defining "modes" for each wall type. Each
|
||||||
* mode describes which parts of a wall are finished (seen as as wall)
|
* mode describes which parts of a wall are finished (seen as as wall)
|
||||||
|
|||||||
@@ -63,11 +63,6 @@ enum lvlinit_types {
|
|||||||
#define SEL_GRADIENT_RADIAL 0
|
#define SEL_GRADIENT_RADIAL 0
|
||||||
#define SEL_GRADIENT_SQUARE 1
|
#define SEL_GRADIENT_SQUARE 1
|
||||||
|
|
||||||
/* light states for terrain replacements, specifically for SET_TYPLIT
|
|
||||||
* (not used for init_level) */
|
|
||||||
#define SET_LIT_RANDOM -1
|
|
||||||
#define SET_LIT_NOCHANGE -2
|
|
||||||
|
|
||||||
#define SP_COORD_IS_RANDOM 0x01000000L
|
#define SP_COORD_IS_RANDOM 0x01000000L
|
||||||
/* Humidity flags for get_location() and friends, used with
|
/* Humidity flags for get_location() and friends, used with
|
||||||
* SP_COORD_PACK_RANDOM() */
|
* SP_COORD_PACK_RANDOM() */
|
||||||
@@ -198,24 +193,4 @@ struct mapfragment {
|
|||||||
char *data;
|
char *data;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define CAN_OVERWRITE_TERRAIN(ttyp) \
|
|
||||||
(iflags.debug_overwrite_stairs || !((ttyp) == LADDER || (ttyp) == STAIRS))
|
|
||||||
|
|
||||||
#define SET_TYPLIT(x, y, ttyp, llit) \
|
|
||||||
do { \
|
|
||||||
if ((x) >= 1 && (y) >= 0 && (x) < COLNO && (y) < ROWNO) { \
|
|
||||||
if ((ttyp) < MAX_TYPE \
|
|
||||||
&& CAN_OVERWRITE_TERRAIN(levl[(x)][(y)].typ)) \
|
|
||||||
levl[(x)][(y)].typ = (ttyp); \
|
|
||||||
if ((ttyp) == LAVAPOOL) \
|
|
||||||
levl[(x)][(y)].lit = 1; \
|
|
||||||
else if ((schar)(llit) != SET_LIT_NOCHANGE) { \
|
|
||||||
if ((schar)(llit) == SET_LIT_RANDOM) \
|
|
||||||
levl[(x)][(y)].lit = rn2(2); \
|
|
||||||
else \
|
|
||||||
levl[(x)][(y)].lit = (llit); \
|
|
||||||
} \
|
|
||||||
} \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#endif /* SP_LEV_H */
|
#endif /* SP_LEV_H */
|
||||||
|
|||||||
+2
-1
@@ -1446,7 +1446,8 @@ make_grave(int x, int y, const char *str)
|
|||||||
if ((levl[x][y].typ != ROOM && levl[x][y].typ != GRAVE) || t_at(x, y))
|
if ((levl[x][y].typ != ROOM && levl[x][y].typ != GRAVE) || t_at(x, y))
|
||||||
return;
|
return;
|
||||||
/* Make the grave */
|
/* Make the grave */
|
||||||
levl[x][y].typ = GRAVE;
|
if (!set_levltyp(x, y, GRAVE))
|
||||||
|
return;
|
||||||
/* Engrave the headstone */
|
/* Engrave the headstone */
|
||||||
del_engr_at(x, y);
|
del_engr_at(x, y);
|
||||||
if (!str)
|
if (!str)
|
||||||
|
|||||||
+9
-9
@@ -620,7 +620,7 @@ makeniche(int trap_type)
|
|||||||
else {
|
else {
|
||||||
/* inaccessible niches occasionally have iron bars */
|
/* inaccessible niches occasionally have iron bars */
|
||||||
if (!rn2(5) && IS_WALL(levl[xx][yy].typ)) {
|
if (!rn2(5) && IS_WALL(levl[xx][yy].typ)) {
|
||||||
levl[xx][yy].typ = IRONBARS;
|
(void) set_levltyp(xx, yy, IRONBARS);
|
||||||
if (rn2(3))
|
if (rn2(3))
|
||||||
(void) mkcorpstat(CORPSE, (struct monst *) 0,
|
(void) mkcorpstat(CORPSE, (struct monst *) 0,
|
||||||
mkclass(S_HUMAN, 0), xx,
|
mkclass(S_HUMAN, 0), xx,
|
||||||
@@ -1271,8 +1271,8 @@ place_branch(branch *br, /* branch to place */
|
|||||||
: !br->end1_up;
|
: !br->end1_up;
|
||||||
|
|
||||||
stairway_add(x, y, goes_up, FALSE, dest);
|
stairway_add(x, y, goes_up, FALSE, dest);
|
||||||
|
(void) set_levltyp(x, y, STAIRS);
|
||||||
levl[x][y].ladder = goes_up ? LA_UP : LA_DOWN;
|
levl[x][y].ladder = goes_up ? LA_UP : LA_DOWN;
|
||||||
levl[x][y].typ = STAIRS;
|
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* Set made_branch to TRUE even if we didn't make a stairwell (i.e.
|
* Set made_branch to TRUE even if we didn't make a stairwell (i.e.
|
||||||
@@ -1635,10 +1635,7 @@ mkstairs(xchar x, xchar y,
|
|||||||
dest.dlevel = u.uz.dlevel + (up ? -1 : 1);
|
dest.dlevel = u.uz.dlevel + (up ? -1 : 1);
|
||||||
stairway_add(x, y, up ? TRUE : FALSE, FALSE, &dest);
|
stairway_add(x, y, up ? TRUE : FALSE, FALSE, &dest);
|
||||||
|
|
||||||
if (levl[x][y].typ == ICE)
|
(void) set_levltyp(x,y, STAIRS);
|
||||||
spot_stop_timers(x, y, MELT_ICE_AWAY);
|
|
||||||
|
|
||||||
levl[x][y].typ = STAIRS;
|
|
||||||
levl[x][y].ladder = up ? LA_UP : LA_DOWN;
|
levl[x][y].ladder = up ? LA_UP : LA_DOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1733,7 +1730,8 @@ mkfount(int mazeflag, struct mkroom *croom)
|
|||||||
} while (occupied(m.x, m.y) || bydoor(m.x, m.y));
|
} while (occupied(m.x, m.y) || bydoor(m.x, m.y));
|
||||||
|
|
||||||
/* Put a fountain at m.x, m.y */
|
/* Put a fountain at m.x, m.y */
|
||||||
levl[m.x][m.y].typ = FOUNTAIN;
|
if (!set_levltyp(m.x, m.y, FOUNTAIN))
|
||||||
|
return;
|
||||||
/* Is it a "blessed" fountain? (affects drinking from fountain) */
|
/* Is it a "blessed" fountain? (affects drinking from fountain) */
|
||||||
if (!rn2(7))
|
if (!rn2(7))
|
||||||
levl[m.x][m.y].blessedftn = 1;
|
levl[m.x][m.y].blessedftn = 1;
|
||||||
@@ -1764,7 +1762,8 @@ mksink(struct mkroom *croom)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
/* Put a sink at m.x, m.y */
|
/* Put a sink at m.x, m.y */
|
||||||
levl[m.x][m.y].typ = SINK;
|
if (!set_levltyp(m.x, m.y, SINK))
|
||||||
|
return;
|
||||||
|
|
||||||
g.level.flags.nsinks++;
|
g.level.flags.nsinks++;
|
||||||
}
|
}
|
||||||
@@ -1782,7 +1781,8 @@ mkaltar(struct mkroom *croom)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
/* Put an altar at m.x, m.y */
|
/* Put an altar at m.x, m.y */
|
||||||
levl[m.x][m.y].typ = ALTAR;
|
if (!set_levltyp(m.x, m.y, ALTAR))
|
||||||
|
return;
|
||||||
|
|
||||||
/* -1 - A_CHAOTIC, 0 - A_NEUTRAL, 1 - A_LAWFUL */
|
/* -1 - A_CHAOTIC, 0 - A_NEUTRAL, 1 - A_LAWFUL */
|
||||||
al = rn2((int) A_LAWFUL + 2) - 1;
|
al = rn2((int) A_LAWFUL + 2) - 1;
|
||||||
|
|||||||
@@ -67,6 +67,52 @@ is_solid(int x, int y)
|
|||||||
return (boolean) (!isok(x, y) || IS_STWALL(levl[x][y].typ));
|
return (boolean) (!isok(x, y) || IS_STWALL(levl[x][y].typ));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* set map terrain type, handling lava lit, ice melt timers, etc */
|
||||||
|
boolean
|
||||||
|
set_levltyp(xchar x, xchar y, schar typ)
|
||||||
|
{
|
||||||
|
if (isok(x, y)) {
|
||||||
|
if ((typ < MAX_TYPE) && CAN_OVERWRITE_TERRAIN(levl[x][y].typ)) {
|
||||||
|
boolean was_ice = (levl[x][y].typ == ICE);
|
||||||
|
|
||||||
|
levl[x][y].typ = typ;
|
||||||
|
|
||||||
|
if (typ == LAVAPOOL)
|
||||||
|
levl[x][y].lit = 1;
|
||||||
|
|
||||||
|
if (was_ice && typ != ICE)
|
||||||
|
spot_stop_timers(x, y, MELT_ICE_AWAY);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
#ifdef EXTRA_SANITY_CHECKS
|
||||||
|
} else {
|
||||||
|
impossible("set_levltyp(%i,%i,%i) !isok", x, y, typ);
|
||||||
|
#endif /*EXTRA_SANITY_CHECKS*/
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* set map terrain type and light state */
|
||||||
|
boolean
|
||||||
|
set_levltyp_lit(xchar x, xchar y, schar typ, schar lit)
|
||||||
|
{
|
||||||
|
boolean ret = set_levltyp(x, y, typ);
|
||||||
|
|
||||||
|
if (ret && isok(x, y)) {
|
||||||
|
/* LAVAPOOL handled in set_levltyp */
|
||||||
|
if ((typ != LAVAPOOL) && (lit != SET_LIT_NOCHANGE)) {
|
||||||
|
#ifdef EXTRA_SANITY_CHECKS
|
||||||
|
if (lit < SET_LIT_NOCHANGE || lit > 1)
|
||||||
|
impossible("set_levltyp_lit(%i,%i,%i,%i)", x, y, typ, lit);
|
||||||
|
#endif /*EXTRA_SANITY_CHECKS*/
|
||||||
|
if (lit == SET_LIT_RANDOM)
|
||||||
|
lit = rn2(2);
|
||||||
|
levl[x][y].lit = lit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Return 1 (not TRUE - we're doing bit vectors here) if we want to extend
|
* Return 1 (not TRUE - we're doing bit vectors here) if we want to extend
|
||||||
* a wall spine in the (dx,dy) direction. Return 0 otherwise.
|
* a wall spine in the (dx,dy) direction. Return 0 otherwise.
|
||||||
|
|||||||
+14
-13
@@ -329,7 +329,8 @@ lvlfill_solid(schar filling, schar lit)
|
|||||||
|
|
||||||
for (x = 2; x <= g.x_maze_max; x++)
|
for (x = 2; x <= g.x_maze_max; x++)
|
||||||
for (y = 0; y <= g.y_maze_max; y++) {
|
for (y = 0; y <= g.y_maze_max; y++) {
|
||||||
SET_TYPLIT(x, y, filling, lit);
|
if (!set_levltyp_lit(x, y, filling, lit))
|
||||||
|
continue;
|
||||||
/* TODO: consolidate this w lspo_map ? */
|
/* TODO: consolidate this w lspo_map ? */
|
||||||
levl[x][y].flags = 0;
|
levl[x][y].flags = 0;
|
||||||
levl[x][y].horizontal = 0;
|
levl[x][y].horizontal = 0;
|
||||||
@@ -350,7 +351,7 @@ lvlfill_swamp(schar fg, schar bg, schar lit)
|
|||||||
for (y = 0; y <= g.y_maze_max; y += 2) {
|
for (y = 0; y <= g.y_maze_max; y += 2) {
|
||||||
int c = 0;
|
int c = 0;
|
||||||
|
|
||||||
SET_TYPLIT(x, y, fg, lit);
|
(void) set_levltyp_lit(x, y, fg, lit);
|
||||||
if (levl[x + 1][y].typ == bg)
|
if (levl[x + 1][y].typ == bg)
|
||||||
++c;
|
++c;
|
||||||
if (levl[x][y + 1].typ == bg)
|
if (levl[x][y + 1].typ == bg)
|
||||||
@@ -360,13 +361,13 @@ lvlfill_swamp(schar fg, schar bg, schar lit)
|
|||||||
if (c == 3) {
|
if (c == 3) {
|
||||||
switch (rn2(3)) {
|
switch (rn2(3)) {
|
||||||
case 0:
|
case 0:
|
||||||
SET_TYPLIT(x + 1,y, fg, lit);
|
(void) set_levltyp_lit(x + 1,y, fg, lit);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
SET_TYPLIT(x, y + 1, fg, lit);
|
(void) set_levltyp_lit(x, y + 1, fg, lit);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
SET_TYPLIT(x + 1, y + 1, fg, lit);
|
(void) set_levltyp_lit(x + 1, y + 1, fg, lit);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@@ -1664,7 +1665,8 @@ create_door(room_door *dd, struct mkroom *broom)
|
|||||||
impossible("create_door: Can't find a proper place!");
|
impossible("create_door: Can't find a proper place!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
levl[x][y].typ = (dd->secret ? SDOOR : DOOR);
|
if (!set_levltyp(x, y, (dd->secret ? SDOOR : DOOR)))
|
||||||
|
return;
|
||||||
levl[x][y].doormask = dd->mask;
|
levl[x][y].doormask = dd->mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2278,7 +2280,6 @@ create_altar(altar* a, struct mkroom* croom)
|
|||||||
xchar x = -1, y = -1;
|
xchar x = -1, y = -1;
|
||||||
unsigned int amask;
|
unsigned int amask;
|
||||||
boolean croom_is_temple = TRUE;
|
boolean croom_is_temple = TRUE;
|
||||||
int oldtyp;
|
|
||||||
|
|
||||||
if (croom) {
|
if (croom) {
|
||||||
get_free_room_loc(&x, &y, croom, a->coord);
|
get_free_room_loc(&x, &y, croom, a->coord);
|
||||||
@@ -2293,13 +2294,11 @@ create_altar(altar* a, struct mkroom* croom)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* check for existing features */
|
/* check for existing features */
|
||||||
oldtyp = levl[x][y].typ;
|
if (!set_levltyp(x, y, ALTAR))
|
||||||
if (!CAN_OVERWRITE_TERRAIN(oldtyp))
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
amask = sp_amask_to_amask(a->sp_amask);
|
amask = sp_amask_to_amask(a->sp_amask);
|
||||||
|
|
||||||
levl[x][y].typ = ALTAR;
|
|
||||||
levl[x][y].altarmask = amask;
|
levl[x][y].altarmask = amask;
|
||||||
|
|
||||||
if (a->shrine < 0)
|
if (a->shrine < 0)
|
||||||
@@ -4801,7 +4800,9 @@ sel_set_ter(int x, int y, genericptr_t arg)
|
|||||||
terrain terr;
|
terrain terr;
|
||||||
|
|
||||||
terr = *(terrain *) arg;
|
terr = *(terrain *) arg;
|
||||||
SET_TYPLIT(x, y, terr.ter, terr.tlit);
|
if (!set_levltyp_lit(x, y, terr.ter, terr.tlit))
|
||||||
|
return;
|
||||||
|
/* TODO: move this below into set_levltyp? */
|
||||||
/* handle doors and secret doors */
|
/* handle doors and secret doors */
|
||||||
if (levl[x][y].typ == SDOOR || IS_DOOR(levl[x][y].typ)) {
|
if (levl[x][y].typ == SDOOR || IS_DOOR(levl[x][y].typ)) {
|
||||||
if (levl[x][y].typ == SDOOR)
|
if (levl[x][y].typ == SDOOR)
|
||||||
@@ -5167,10 +5168,10 @@ lspo_replace_terrain(lua_State *L)
|
|||||||
if (selection_getpoint(x, y,sel)) {
|
if (selection_getpoint(x, y,sel)) {
|
||||||
if (mf) {
|
if (mf) {
|
||||||
if (mapfrag_match(mf, x, y) && (rn2(100)) < chance)
|
if (mapfrag_match(mf, x, y) && (rn2(100)) < chance)
|
||||||
SET_TYPLIT(x, y, totyp, tolit);
|
(void) set_levltyp_lit(x, y, totyp, tolit);
|
||||||
} else {
|
} else {
|
||||||
if (levl[x][y].typ == fromtyp && rn2(100) < chance)
|
if (levl[x][y].typ == fromtyp && rn2(100) < chance)
|
||||||
SET_TYPLIT(x, y, totyp, tolit);
|
(void) set_levltyp_lit(x, y, totyp, tolit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
-8
@@ -348,7 +348,6 @@ maketrap(int x, int y, int typ)
|
|||||||
boolean oldplace;
|
boolean oldplace;
|
||||||
struct trap *ttmp;
|
struct trap *ttmp;
|
||||||
struct rm *lev = &levl[x][y];
|
struct rm *lev = &levl[x][y];
|
||||||
boolean was_ice = (lev->typ == ICE);
|
|
||||||
|
|
||||||
if ((ttmp = t_at(x, y)) != 0) {
|
if ((ttmp = t_at(x, y)) != 0) {
|
||||||
if (undestroyable_trap(ttmp->ttyp))
|
if (undestroyable_trap(ttmp->ttyp))
|
||||||
@@ -447,21 +446,19 @@ maketrap(int x, int y, int typ)
|
|||||||
: 0L);
|
: 0L);
|
||||||
lev->doormask = 0; /* subsumes altarmask, icedpool... */
|
lev->doormask = 0; /* subsumes altarmask, icedpool... */
|
||||||
if (IS_ROOM(lev->typ)) /* && !IS_AIR(lev->typ) */
|
if (IS_ROOM(lev->typ)) /* && !IS_AIR(lev->typ) */
|
||||||
lev->typ = ROOM;
|
(void) set_levltyp(x, y, ROOM);
|
||||||
/*
|
/*
|
||||||
* some cases which can happen when digging
|
* some cases which can happen when digging
|
||||||
* down while phazing thru solid areas
|
* down while phazing thru solid areas
|
||||||
*/
|
*/
|
||||||
else if (lev->typ == STONE || lev->typ == SCORR)
|
else if (lev->typ == STONE || lev->typ == SCORR)
|
||||||
lev->typ = CORR;
|
(void) set_levltyp(x, y, CORR);
|
||||||
else if (IS_WALL(lev->typ) || lev->typ == SDOOR)
|
else if (IS_WALL(lev->typ) || lev->typ == SDOOR)
|
||||||
lev->typ = g.level.flags.is_maze_lev ? ROOM
|
(void) set_levltyp(x, y, g.level.flags.is_maze_lev ? ROOM
|
||||||
: g.level.flags.is_cavernous_lev ? CORR
|
: g.level.flags.is_cavernous_lev ? CORR
|
||||||
: DOOR;
|
: DOOR);
|
||||||
|
|
||||||
unearth_objs(x, y);
|
unearth_objs(x, y);
|
||||||
if (was_ice && lev->typ != ICE)
|
|
||||||
spot_stop_timers(x, y, MELT_ICE_AWAY);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user