More monster location sanity checks
Placing a monster over already existing one will now complain. Define EXTRA_SANITY_CHECKS to check monster removal too.
This commit is contained in:
@@ -629,8 +629,19 @@ extern dlevel_t level; /* structure describing the current level */
|
|||||||
#define MON_BURIED_AT(x, y) \
|
#define MON_BURIED_AT(x, y) \
|
||||||
(level.monsters[x][y] != (struct monst *) 0 \
|
(level.monsters[x][y] != (struct monst *) 0 \
|
||||||
&& (level.monsters[x][y])->mburied)
|
&& (level.monsters[x][y])->mburied)
|
||||||
|
#if EXTRA_SANITY_CHECKS
|
||||||
|
#define place_worm_seg(m, x, y) do { \
|
||||||
|
if (level.monsters[x][y] && level.monsters[x][y] != m) impossible("place_worm_seg over mon"); \
|
||||||
|
level.monsters[x][y] = m; \
|
||||||
|
} while(0)
|
||||||
|
#define remove_monster(x, y) do { \
|
||||||
|
if (!level.monsters[x][y]) impossible("no monster to remove"); \
|
||||||
|
level.monsters[x][y] = (struct monst *) 0; \
|
||||||
|
} while(0)
|
||||||
|
#else
|
||||||
#define place_worm_seg(m, x, y) level.monsters[x][y] = m
|
#define place_worm_seg(m, x, y) level.monsters[x][y] = m
|
||||||
#define remove_monster(x, y) level.monsters[x][y] = (struct monst *) 0
|
#define remove_monster(x, y) level.monsters[x][y] = (struct monst *) 0
|
||||||
|
#endif
|
||||||
#define m_at(x, y) (MON_AT(x, y) ? level.monsters[x][y] : (struct monst *) 0)
|
#define m_at(x, y) (MON_AT(x, y) ? level.monsters[x][y] : (struct monst *) 0)
|
||||||
#define m_buried_at(x, y) \
|
#define m_buried_at(x, y) \
|
||||||
(MON_BURIED_AT(x, y) ? level.monsters[x][y] : (struct monst *) 0)
|
(MON_BURIED_AT(x, y) ? level.monsters[x][y] : (struct monst *) 0)
|
||||||
|
|||||||
+6
-2
@@ -336,19 +336,21 @@ register int tx, ty; /* destination of mail daemon */
|
|||||||
else if (fx == u.ux && fy == u.uy)
|
else if (fx == u.ux && fy == u.uy)
|
||||||
verbalize("Excuse me.");
|
verbalize("Excuse me.");
|
||||||
|
|
||||||
|
if (mon)
|
||||||
|
remove_monster(fx, fy);
|
||||||
place_monster(md, fx, fy); /* put md down */
|
place_monster(md, fx, fy); /* put md down */
|
||||||
newsym(fx, fy); /* see it */
|
newsym(fx, fy); /* see it */
|
||||||
flush_screen(0); /* make sure md shows up */
|
flush_screen(0); /* make sure md shows up */
|
||||||
delay_output(); /* wait a little bit */
|
delay_output(); /* wait a little bit */
|
||||||
|
|
||||||
/* Remove md from the dungeon. Restore original mon, if necessary. */
|
/* Remove md from the dungeon. Restore original mon, if necessary. */
|
||||||
|
remove_monster(fx, fy);
|
||||||
if (mon) {
|
if (mon) {
|
||||||
if ((mon->mx != fx) || (mon->my != fy))
|
if ((mon->mx != fx) || (mon->my != fy))
|
||||||
place_worm_seg(mon, fx, fy);
|
place_worm_seg(mon, fx, fy);
|
||||||
else
|
else
|
||||||
place_monster(mon, fx, fy);
|
place_monster(mon, fx, fy);
|
||||||
} else
|
}
|
||||||
remove_monster(fx, fy);
|
|
||||||
newsym(fx, fy);
|
newsym(fx, fy);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -357,9 +359,11 @@ register int tx, ty; /* destination of mail daemon */
|
|||||||
* very unlikely). If one exists, then have the md leave in disgust.
|
* very unlikely). If one exists, then have the md leave in disgust.
|
||||||
*/
|
*/
|
||||||
if ((mon = m_at(fx, fy)) != 0) {
|
if ((mon = m_at(fx, fy)) != 0) {
|
||||||
|
remove_monster(fx, fy);
|
||||||
place_monster(md, fx, fy); /* display md with text below */
|
place_monster(md, fx, fy); /* display md with text below */
|
||||||
newsym(fx, fy);
|
newsym(fx, fy);
|
||||||
verbalize("This place's too crowded. I'm outta here.");
|
verbalize("This place's too crowded. I'm outta here.");
|
||||||
|
remove_monster(fx, fy);
|
||||||
|
|
||||||
if ((mon->mx != fx) || (mon->my != fy)) /* put mon back */
|
if ((mon->mx != fx) || (mon->my != fy)) /* put mon back */
|
||||||
place_worm_seg(mon, fx, fy);
|
place_worm_seg(mon, fx, fy);
|
||||||
|
|||||||
@@ -725,6 +725,7 @@ register struct attack *mattk;
|
|||||||
* but don't leave it on the screen. Move the aggressor to the
|
* but don't leave it on the screen. Move the aggressor to the
|
||||||
* defender's position.
|
* defender's position.
|
||||||
*/
|
*/
|
||||||
|
remove_monster(dx, dy);
|
||||||
remove_monster(ax, ay);
|
remove_monster(ax, ay);
|
||||||
place_monster(magr, dx, dy);
|
place_monster(magr, dx, dy);
|
||||||
newsym(ax, ay); /* erase old position */
|
newsym(ax, ay); /* erase old position */
|
||||||
|
|||||||
@@ -536,6 +536,11 @@ skip_lots:
|
|||||||
saveobjchn(fd, level.buriedobjlist, mode);
|
saveobjchn(fd, level.buriedobjlist, mode);
|
||||||
saveobjchn(fd, billobjs, mode);
|
saveobjchn(fd, billobjs, mode);
|
||||||
if (release_data(mode)) {
|
if (release_data(mode)) {
|
||||||
|
int x,y;
|
||||||
|
|
||||||
|
for (y = 0; y < ROWNO; y++)
|
||||||
|
for (x = 0; x < COLNO; x++)
|
||||||
|
level.monsters[x][y] = 0;
|
||||||
fmon = 0;
|
fmon = 0;
|
||||||
ftrap = 0;
|
ftrap = 0;
|
||||||
fobj = 0;
|
fobj = 0;
|
||||||
|
|||||||
@@ -704,6 +704,8 @@ int x, y;
|
|||||||
(mon == u.usteed) ? "steed" : "defunct monster");
|
(mon == u.usteed) ? "steed" : "defunct monster");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (level.monsters[x][y])
|
||||||
|
impossible("placing monster over another?");
|
||||||
mon->mx = x, mon->my = y;
|
mon->mx = x, mon->my = y;
|
||||||
level.monsters[x][y] = mon;
|
level.monsters[x][y] = mon;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -383,6 +383,7 @@ struct obj *weap;
|
|||||||
|
|
||||||
/* Sometimes the tail end dies. */
|
/* Sometimes the tail end dies. */
|
||||||
if (!new_worm) {
|
if (!new_worm) {
|
||||||
|
place_worm_seg(worm, x, y); /* place the "head" segment back */
|
||||||
if (context.mon_moving) {
|
if (context.mon_moving) {
|
||||||
if (canspotmon(worm))
|
if (canspotmon(worm))
|
||||||
pline("Part of %s tail has been cut off.",
|
pline("Part of %s tail has been cut off.",
|
||||||
|
|||||||
Reference in New Issue
Block a user