From 84e7d0704483ce39bbdeacd5e676168db6fa664f Mon Sep 17 00:00:00 2001 From: christos Date: Sun, 19 Oct 1997 16:56:41 +0000 Subject: WARNsify... --- hack/hack.vault.c | 378 +++++++++++++++++++++++++++++++----------------------- 1 file changed, 217 insertions(+), 161 deletions(-) (limited to 'hack/hack.vault.c') diff --git a/hack/hack.vault.c b/hack/hack.vault.c index 4564d974..8717674f 100644 --- a/hack/hack.vault.c +++ b/hack/hack.vault.c @@ -1,59 +1,82 @@ +/* $NetBSD: hack.vault.c,v 1.4 1997/10/19 16:59:23 christos Exp $ */ + /* * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ +#include #ifndef lint -static char rcsid[] = "$NetBSD: hack.vault.c,v 1.3 1995/03/23 08:31:59 cgd Exp $"; -#endif /* not lint */ +__RCSID("$NetBSD: hack.vault.c,v 1.4 1997/10/19 16:59:23 christos Exp $"); +#endif /* not lint */ -#include "hack.h" +#include "hack.h" +#include "extern.h" #ifdef QUEST -setgd(/* mtmp */) /* struct monst *mtmp; */ {} -gd_move() { return(2); } -gddead(mtmp) struct monst *mtmp; {} -replgd(mtmp,mtmp2) struct monst *mtmp, *mtmp2; {} -invault(){} +void +setgd( /* mtmp */ ) +{ /* struct monst *mtmp; */ +} +int +gd_move() { + return (2); +} +void +gddead() +{ +} +void +replgd(mtmp, mtmp2) + struct monst *mtmp, *mtmp2; +{ +} +void +invault() +{ +} #else #include "def.mkroom.h" -extern struct monst *makemon(); #define FCSIZ (ROWNO+COLNO) struct fakecorridor { - xchar fx,fy,ftyp; + xchar fx, fy, ftyp; }; struct egd { - int fcbeg, fcend; /* fcend: first unused pos */ - xchar gdx, gdy; /* goal of guard's walk */ - unsigned gddone:1; + int fcbeg, fcend; /* fcend: first unused pos */ + xchar gdx, gdy; /* goal of guard's walk */ + unsigned gddone:1; struct fakecorridor fakecorr[FCSIZ]; }; static struct permonst pm_guard = - { "guard", '@', 12, 12, -1, 4, 10, sizeof(struct egd) }; +{"guard", '@', 12, 12, -1, 4, 10, sizeof(struct egd)}; static struct monst *guard; -static int gdlevel; +static int gdlevel; #define EGD ((struct egd *)(&(guard->mextra[0]))) -static +static void restfakecorr __P((void)); +static int goldincorridor __P((void)); + +static void restfakecorr() { - register fcx,fcy,fcbeg; - register struct rm *crm; + int fcx, fcy, fcbeg; + struct rm *crm; - while((fcbeg = EGD->fcbeg) < EGD->fcend) { + 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)) + 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; - if(!crm->typ) crm->seen = 0; - newsym(fcx,fcy); + if (!crm->typ) + crm->seen = 0; + newsym(fcx, fcy); EGD->fcbeg++; } /* it seems he left the corridor - let the guard disappear */ @@ -61,169 +84,197 @@ restfakecorr() guard = 0; } -static +static int goldincorridor() { - register int fci; + int fci; - for(fci = EGD->fcbeg; fci < EGD->fcend; fci++) - if(g_at(EGD->fakecorr[fci].fx, EGD->fakecorr[fci].fy)) - return(1); - return(0); + for (fci = EGD->fcbeg; fci < EGD->fcend; fci++) + if (g_at(EGD->fakecorr[fci].fx, EGD->fakecorr[fci].fy)) + return (1); + return (0); } -setgd(){ -register struct monst *mtmp; - for(mtmp = fmon; mtmp; mtmp = mtmp->nmon) if(mtmp->isgd){ - guard = mtmp; - gdlevel = dlevel; - return; - } +void +setgd() +{ + struct monst *mtmp; + for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) + if (mtmp->isgd) { + guard = mtmp; + gdlevel = dlevel; + return; + } guard = 0; } -invault(){ -register tmp = inroom(u.ux, u.uy); - if(tmp < 0 || rooms[tmp].rtype != VAULT) { - u.uinvault = 0; - return; - } - if(++u.uinvault % 50 == 0 && (!guard || gdlevel != dlevel)) { - char buf[BUFSZ]; - register x,y,dd,gx,gy; - - /* first find the goal for the guard */ - for(dd = 1; (dd < ROWNO || dd < COLNO); dd++) { - for(y = u.uy-dd; y <= u.uy+dd; y++) { - if(y < 0 || y > ROWNO-1) continue; - for(x = u.ux-dd; x <= u.ux+dd; x++) { - if(y != u.uy-dd && y != u.uy+dd && x != u.ux-dd) - x = u.ux+dd; - if(x < 0 || x > COLNO-1) continue; - if(levl[x][y].typ == CORR) goto fnd; - } - } +void +invault() +{ + int tmp = inroom(u.ux, u.uy); + if (tmp < 0 || rooms[tmp].rtype != VAULT) { + u.uinvault = 0; + return; } - impossible("Not a single corridor on this level??"); - tele(); - return; -fnd: - gx = x; gy = y; + if (++u.uinvault % 50 == 0 && (!guard || gdlevel != dlevel)) { + char buf[BUFSZ]; + int x, y, dd, gx, gy; - /* next find a good place for a door in the wall */ - x = u.ux; y = u.uy; - while(levl[x][y].typ == ROOM) { - register int dx,dy; + /* first find the goal for the guard */ + for (dd = 1; (dd < ROWNO || dd < COLNO); dd++) { + for (y = u.uy - dd; y <= u.uy + dd; y++) { + if (y < 0 || y > ROWNO - 1) + continue; + for (x = u.ux - dd; x <= u.ux + dd; x++) { + if (y != u.uy - dd && y != u.uy + dd && x != u.ux - dd) + x = u.ux + dd; + if (x < 0 || x > COLNO - 1) + continue; + if (levl[x][y].typ == CORR) + goto fnd; + } + } + } + impossible("Not a single corridor on this level??"); + tele(); + return; +fnd: + gx = x; + gy = y; - dx = (gx > x) ? 1 : (gx < x) ? -1 : 0; - dy = (gy > y) ? 1 : (gy < y) ? -1 : 0; - if(abs(gx-x) >= abs(gy-y)) - x += dx; - else - y += dy; - } + /* next find a good place for a door in the wall */ + x = u.ux; + y = u.uy; + while (levl[x][y].typ == ROOM) { + int dx, dy; - /* make something interesting happen */ - if(!(guard = makemon(&pm_guard,x,y))) return; - guard->isgd = guard->mpeaceful = 1; - EGD->gddone = 0; - gdlevel = dlevel; - if(!cansee(guard->mx, guard->my)) { - mondead(guard); - guard = 0; - return; - } + dx = (gx > x) ? 1 : (gx < x) ? -1 : 0; + dy = (gy > y) ? 1 : (gy < y) ? -1 : 0; + if (abs(gx - x) >= abs(gy - y)) + x += dx; + else + y += dy; + } - pline("Suddenly one of the Vault's guards enters!"); - pmon(guard); - do { - pline("\"Hello stranger, who are you?\" - "); - getlin(buf); - } while (!letter(buf[0])); + /* make something interesting happen */ + if (!(guard = makemon(&pm_guard, x, y))) + return; + guard->isgd = guard->mpeaceful = 1; + EGD->gddone = 0; + gdlevel = dlevel; + if (!cansee(guard->mx, guard->my)) { + mondead(guard); + guard = 0; + return; + } + pline("Suddenly one of the Vault's guards enters!"); + pmon(guard); + do { + pline("\"Hello stranger, who are you?\" - "); + getlin(buf); + } while (!letter(buf[0])); - if(!strcmp(buf, "Croesus") || !strcmp(buf, "Kroisos")) { - pline("\"Oh, yes - of course. Sorry to have disturbed you.\""); - mondead(guard); - guard = 0; - return; - } - clrlin(); - pline("\"I don't know you.\""); - if(!u.ugold) - pline("\"Please follow me.\""); - else { - pline("\"Most likely all that gold was stolen from this vault.\""); - pline("\"Please drop your gold (say d$ ) and follow me.\""); + if (!strcmp(buf, "Croesus") || !strcmp(buf, "Kroisos")) { + pline("\"Oh, yes - of course. Sorry to have disturbed you.\""); + mondead(guard); + guard = 0; + return; + } + clrlin(); + pline("\"I don't know you.\""); + if (!u.ugold) + pline("\"Please follow me.\""); + else { + 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; + levl[x][y].typ = DOOR; + EGD->fcend = 1; } - 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; - } } -gd_move(){ -register int x,y,dx,dy,gx,gy,nx,ny,typ; -register struct fakecorridor *fcp; -register struct rm *crm; - if(!guard || gdlevel != dlevel){ +int +gd_move() +{ + int x, y, dx, dy, gx, gy, nx, ny, typ; + struct fakecorridor *fcp; + struct rm *crm; + if (!guard || gdlevel != dlevel) { impossible("Where is the guard?"); - return(2); /* died */ + return (2); /* died */ } - if(u.ugold || goldincorridor()) - return(0); /* didnt move */ - if(dist(guard->mx,guard->my) > 1 || EGD->gddone) { + if (u.ugold || goldincorridor()) + return (0); /* didnt move */ + if (dist(guard->mx, guard->my) > 1 || EGD->gddone) { restfakecorr(); - return(0); /* didnt move */ + return (0); /* didnt move */ } x = guard->mx; y = guard->my; /* look around (hor & vert only) for accessible places */ - for(nx = x-1; nx <= x+1; nx++) for(ny = y-1; ny <= y+1; ny++) { - if(nx == x || ny == y) if(nx != x || ny != y) - if(isok(nx,ny)) - if(!IS_WALL(typ = (crm = &levl[nx][ny])->typ) && typ != POOL) { - register int i; - 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; - /* seems we found a good place to leave him alone */ - EGD->gddone = 1; - if(ACCESSIBLE(typ)) goto newpos; - crm->typ = (typ == SCORR) ? CORR : DOOR; - goto proceed; - } - nextnxy: ; - } + for (nx = x - 1; nx <= x + 1; nx++) + for (ny = y - 1; ny <= y + 1; ny++) { + if (nx == x || ny == y) + if (nx != x || ny != y) + 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) + goto nextnxy; + if ((i = inroom(nx, ny)) >= 0 && rooms[i].rtype == VAULT) + goto nextnxy; + /* + * seems we found a + * good place to + * leave him alone + */ + EGD->gddone = 1; + if (ACCESSIBLE(typ)) + goto newpos; + crm->typ = (typ == SCORR) ? CORR : DOOR; + goto proceed; + } + nextnxy: ; + } nx = x; ny = y; 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)) nx += dx; else ny += dy; + if (abs(gx - x) >= abs(gy - y)) + nx += dx; + else + ny += dy; - while((typ = (crm = &levl[nx][ny])->typ) != 0) { - /* in view of the above we must have IS_WALL(typ) or typ == POOL */ - /* must be a wall here */ - if(isok(nx+nx-x,ny+ny-y) && typ != POOL && - ZAP_POS(levl[nx+nx-x][ny+ny-y].typ)){ + while ((typ = (crm = &levl[nx][ny])->typ) != 0) { + /* + * in view of the above we must have IS_WALL(typ) or typ == + * POOL + */ + /* must be a wall here */ + if (isok(nx + nx - x, ny + ny - y) && typ != POOL && + ZAP_POS(levl[nx + nx - x][ny + ny - y].typ)) { crm->typ = DOOR; goto proceed; } - if(dy && nx != x) { - nx = x; ny = y+dy; + if (dy && nx != x) { + nx = x; + ny = y + dy; continue; } - if(dx && ny != y) { - ny = y; nx = x+dx; dy = 0; + if (dx && ny != y) { + ny = y; + nx = x + dx; + dy = 0; continue; } /* I don't like this, but ... */ @@ -232,33 +283,38 @@ register struct rm *crm; } crm->typ = CORR; proceed: - if(cansee(nx,ny)) { - mnewsym(nx,ny); - prl(nx,ny); + if (cansee(nx, ny)) { + mnewsym(nx, ny); + prl(nx, ny); } fcp = &(EGD->fakecorr[EGD->fcend]); - if(EGD->fcend++ == FCSIZ) panic("fakecorr overflow"); + if (EGD->fcend++ == FCSIZ) + panic("fakecorr overflow"); fcp->fx = nx; fcp->fy = ny; fcp->ftyp = typ; newpos: - if(EGD->gddone) nx = ny = 0; + if (EGD->gddone) + nx = ny = 0; guard->mx = nx; guard->my = ny; pmon(guard); restfakecorr(); - return(1); + return (1); } -gddead(){ +void +gddead() +{ guard = 0; } -replgd(mtmp,mtmp2) -register struct monst *mtmp, *mtmp2; +void +replgd(mtmp, mtmp2) + struct monst *mtmp, *mtmp2; { - if(mtmp == guard) + if (mtmp == guard) guard = mtmp2; } -#endif QUEST +#endif /* QUEST */ -- cgit v1.2.3-56-ge451