summaryrefslogtreecommitdiffstats
path: root/hack/hack.vault.c
diff options
context:
space:
mode:
Diffstat (limited to 'hack/hack.vault.c')
-rw-r--r--hack/hack.vault.c60
1 files changed, 32 insertions, 28 deletions
diff --git a/hack/hack.vault.c b/hack/hack.vault.c
index 482b0207..cbbf1fc8 100644
--- a/hack/hack.vault.c
+++ b/hack/hack.vault.c
@@ -1,4 +1,4 @@
-/* $NetBSD: hack.vault.c,v 1.8 2009/06/07 18:30:39 dholland Exp $ */
+/* $NetBSD: hack.vault.c,v 1.9 2011/08/16 09:26:22 christos Exp $ */
/*
* Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica,
@@ -63,7 +63,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: hack.vault.c,v 1.8 2009/06/07 18:30:39 dholland Exp $");
+__RCSID("$NetBSD: hack.vault.c,v 1.9 2011/08/16 09:26:22 christos Exp $");
#endif /* not lint */
#include "hack.h"
@@ -116,7 +116,6 @@ static const struct permonst pm_guard =
static struct monst *guard;
static int gdlevel;
-#define EGD ((struct egd *)(&(guard->mextra[0])))
static void restfakecorr(void);
static int goldincorridor(void);
@@ -126,19 +125,20 @@ restfakecorr(void)
{
int fcx, fcy, fcbeg;
struct rm *crm;
+ struct egd *egd = monster_private(guard);
- while ((fcbeg = EGD->fcbeg) < EGD->fcend) {
- fcx = EGD->fakecorr[fcbeg].fx;
- fcy = EGD->fakecorr[fcbeg].fy;
+ while ((fcbeg = egd->fcbeg) < egd->fcend) {
+ fcx = egd->fakecorr[fcbeg].fx;
+ fcy = egd->fakecorr[fcbeg].fy;
if ((u.ux == fcx && u.uy == fcy) || cansee(fcx, fcy) ||
m_at(fcx, fcy))
return;
crm = &levl[fcx][fcy];
- crm->typ = EGD->fakecorr[fcbeg].ftyp;
+ crm->typ = egd->fakecorr[fcbeg].ftyp;
if (!crm->typ)
crm->seen = 0;
newsym(fcx, fcy);
- EGD->fcbeg++;
+ egd->fcbeg++;
}
/* it seems he left the corridor - let the guard disappear */
mondead(guard);
@@ -149,9 +149,10 @@ static int
goldincorridor(void)
{
int fci;
+ struct egd *egd = monster_private(guard);
- for (fci = EGD->fcbeg; fci < EGD->fcend; fci++)
- if (g_at(EGD->fakecorr[fci].fx, EGD->fakecorr[fci].fy))
+ for (fci = egd->fcbeg; fci < egd->fcend; fci++)
+ if (g_at(egd->fakecorr[fci].fx, egd->fakecorr[fci].fy))
return (1);
return (0);
}
@@ -173,6 +174,7 @@ void
invault(void)
{
int tmp = inroom(u.ux, u.uy);
+ struct egd *egd;
if (tmp < 0 || rooms[tmp].rtype != VAULT) {
u.uinvault = 0;
return;
@@ -221,7 +223,8 @@ fnd:
if (!(guard = makemon(&pm_guard, x, y)))
return;
guard->isgd = guard->mpeaceful = 1;
- EGD->gddone = 0;
+ egd = monster_private(guard);
+ egd->gddone = 0;
gdlevel = dlevel;
if (!cansee(guard->mx, guard->my)) {
mondead(guard);
@@ -249,14 +252,14 @@ fnd:
pline("\"Most likely all that gold was stolen from this vault.\"");
pline("\"Please drop your gold (say d$ ) and follow me.\"");
}
- EGD->gdx = gx;
- EGD->gdy = gy;
- EGD->fcbeg = 0;
- EGD->fakecorr[0].fx = x;
- EGD->fakecorr[0].fy = y;
- EGD->fakecorr[0].ftyp = levl[x][y].typ;
+ egd->gdx = gx;
+ egd->gdy = gy;
+ egd->fcbeg = 0;
+ egd->fakecorr[0].fx = x;
+ egd->fakecorr[0].fy = y;
+ egd->fakecorr[0].ftyp = levl[x][y].typ;
levl[x][y].typ = DOOR;
- EGD->fcend = 1;
+ egd->fcend = 1;
}
}
@@ -266,13 +269,14 @@ gd_move(void)
int x, y, dx, dy, gx, gy, nx, ny, typ;
struct fakecorridor *fcp;
struct rm *crm;
+ struct egd *egd = monster_private(guard);
if (!guard || gdlevel != dlevel) {
impossible("Where is the guard?");
return (2); /* died */
}
if (u.ugold || goldincorridor())
return (0); /* didnt move */
- if (dist(guard->mx, guard->my) > 1 || EGD->gddone) {
+ if (dist(guard->mx, guard->my) > 1 || egd->gddone) {
restfakecorr();
return (0); /* didnt move */
}
@@ -286,9 +290,9 @@ gd_move(void)
if (isok(nx, ny))
if (!IS_WALL(typ = (crm = &levl[nx][ny])->typ) && typ != POOL) {
int i;
- for (i = EGD->fcbeg; i < EGD->fcend; i++)
- if (EGD->fakecorr[i].fx == nx &&
- EGD->fakecorr[i].fy == ny)
+ for (i = egd->fcbeg; i < egd->fcend; i++)
+ if (egd->fakecorr[i].fx == nx &&
+ egd->fakecorr[i].fy == ny)
goto nextnxy;
if ((i = inroom(nx, ny)) >= 0 && rooms[i].rtype == VAULT)
goto nextnxy;
@@ -297,7 +301,7 @@ gd_move(void)
* good place to
* leave him alone
*/
- EGD->gddone = 1;
+ egd->gddone = 1;
if (ACCESSIBLE(typ))
goto newpos;
crm->typ = (typ == SCORR) ? CORR : DOOR;
@@ -307,8 +311,8 @@ gd_move(void)
}
nx = x;
ny = y;
- gx = EGD->gdx;
- gy = EGD->gdy;
+ gx = egd->gdx;
+ gy = egd->gdy;
dx = (gx > x) ? 1 : (gx < x) ? -1 : 0;
dy = (gy > y) ? 1 : (gy < y) ? -1 : 0;
if (abs(gx - x) >= abs(gy - y))
@@ -348,14 +352,14 @@ proceed:
mnewsym(nx, ny);
prl(nx, ny);
}
- fcp = &(EGD->fakecorr[EGD->fcend]);
- if (EGD->fcend++ == FCSIZ)
+ fcp = &(egd->fakecorr[egd->fcend]);
+ if (egd->fcend++ == FCSIZ)
panic("fakecorr overflow");
fcp->fx = nx;
fcp->fy = ny;
fcp->ftyp = typ;
newpos:
- if (EGD->gddone)
+ if (egd->gddone)
nx = ny = 0;
guard->mx = nx;
guard->my = ny;