From: Peter Avalos Date: Mon, 21 Aug 2006 19:45:32 +0000 (+0000) Subject: -WARNS6 cleanup (7422 warnings) X-Git-Tag: v2.0.1~4511 X-Git-Url: https://gitweb.dragonflybsd.org/~uqs/games.git/commitdiff_plain/c7106d58626b3ef4b9efa87163437a679c2288f9 -WARNS6 cleanup (7422 warnings) -ANSI function declarations -staticize functions -use stdbool.h where needed -remove (void) casts for unchecked function returns -put extern function declarations and variables in hack.h -remove code that was previously commented out -rename local variables where needed that were colliding with globals -use variable argument lists from stdarg.h -add DragonFly keyword --- diff --git a/games/hack/Makefile b/games/hack/Makefile index 30adc58967..737d83f259 100644 --- a/games/hack/Makefile +++ b/games/hack/Makefile @@ -1,6 +1,6 @@ # @(#)Makefile 8.1 (Berkeley) 5/31/93 # $FreeBSD: src/games/hack/Makefile,v 1.20.2.4 2002/08/07 16:31:41 ru Exp $ -# $DragonFly: src/games/hack/Makefile,v 1.4 2005/05/07 18:02:35 corecode Exp $ +# $DragonFly: src/games/hack/Makefile,v 1.5 2006/08/21 19:45:32 pavalos Exp $ PROG= hack SRCS= alloc.c hack.Decl.c hack.apply.c hack.bones.c hack.c hack.cmd.c \ @@ -16,8 +16,8 @@ SRCS= alloc.c hack.Decl.c hack.apply.c hack.bones.c hack.c hack.cmd.c \ hack.wizard.c hack.worm.c hack.worn.c hack.zap.c rnd.c \ hack.onames.h MAN= hack.6 -DPADD= ${LIBTERMCAP} ${LIBCOMPAT} -LDADD= -ltermcap -lcompat +DPADD= ${LIBTERMCAP} +LDADD= -ltermcap CFLAGS+= -I${.CURDIR} -I. FILES= rumors help hh data FILESMODE_rumors= 440 @@ -25,6 +25,7 @@ FILESGRP= ${BINGRP} FILESDIR= /var/games/hackdir HIDEGAME=hidegame CLEANFILES=hack.onames.h makedefs.nx makedefs.no +WARNS?= 6 build-tools: makedefs.nx diff --git a/games/hack/alloc.c b/games/hack/alloc.c index 4ec9166abb..c97b5c3ffb 100644 --- a/games/hack/alloc.c +++ b/games/hack/alloc.c @@ -1,8 +1,8 @@ /* alloc.c - version 1.0.2 */ /* $FreeBSD: src/games/hack/alloc.c,v 1.4 1999/11/16 02:57:01 billf Exp $ */ -/* $DragonFly: src/games/hack/alloc.c,v 1.3 2004/11/06 12:29:17 eirikn Exp $ */ +/* $DragonFly: src/games/hack/alloc.c,v 1.4 2006/08/21 19:45:32 pavalos Exp $ */ -#include +#include "hack.h" #ifdef LINT @@ -13,9 +13,9 @@ "ftell defined (in ) but never used" from lint */ -#include long * -alloc(n) unsigned n; { +alloc(size_t n) +{ long dummy = ftell(stderr); if(n) dummy = 0; /* make sure arg is used */ return(&dummy); @@ -23,27 +23,14 @@ long dummy = ftell(stderr); #else -long * -alloc(lth) -unsigned lth; +void * +alloc(size_t lth) { - char *ptr; + void *ptr; - if(!(ptr = malloc(lth))) + if((ptr = malloc(lth)) == NULL) panic("Cannot get %d bytes", lth); - return((long *) ptr); -} - -long * -enlarge(ptr,lth) -char *ptr; -unsigned lth; -{ - char *nptr; - - if(!(nptr = realloc(ptr,lth))) - panic("Cannot reallocate %d bytes", lth); - return((long *) nptr); + return(ptr); } #endif /* LINT */ diff --git a/games/hack/config.h b/games/hack/config.h index eae98486bd..c11fe3498a 100644 --- a/games/hack/config.h +++ b/games/hack/config.h @@ -1,7 +1,8 @@ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* config.h - version 1.0.3 */ -/* $DragonFly: src/games/hack/config.h,v 1.2 2004/11/06 12:29:17 eirikn Exp $ */ +/* $DragonFly: src/games/hack/config.h,v 1.3 2006/08/21 19:45:32 pavalos Exp $ */ +#include #include "pathnames.h" #ifndef CONFIG /* make sure the compiler doesnt see the typedefs twice */ @@ -105,7 +106,7 @@ * will do when you have signed characters; otherwise use * typedef short int schar; */ -typedef char schar; +typedef short schar; /* * small unsigned integers (8 bits suffice - but 7 bits do not) @@ -122,7 +123,7 @@ typedef unsigned char uchar; * since otherwise comparisons with signed quantities are done incorrectly */ typedef schar xchar; -typedef xchar boolean; /* 0 or 1 */ +typedef bool boolean; /* 0 or 1 */ #define TRUE 1 #define FALSE 0 diff --git a/games/hack/def.func_tab.h b/games/hack/def.func_tab.h index 9e4c1b1e58..ceb952c52e 100644 --- a/games/hack/def.func_tab.h +++ b/games/hack/def.func_tab.h @@ -1,17 +1,13 @@ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* def.func_tab.h - version 1.0.2 */ -/* $DragonFly: src/games/hack/def.func_tab.h,v 1.2 2005/05/22 03:37:05 y0netan1 Exp $ */ +/* $DragonFly: src/games/hack/def.func_tab.h,v 1.3 2006/08/21 19:45:32 pavalos Exp $ */ struct func_tab { char f_char; - int (*f_funct)(); + int (*f_funct)(void); }; -extern struct func_tab cmdlist[]; - struct ext_func_tab { const char *ef_txt; - int (*ef_funct)(); + int (*ef_funct)(void); }; - -extern struct ext_func_tab extcmdlist[]; diff --git a/games/hack/def.gen.h b/games/hack/def.gen.h index f1e44fc989..5eda06fffd 100644 --- a/games/hack/def.gen.h +++ b/games/hack/def.gen.h @@ -1,5 +1,6 @@ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* def.gen.h version 1.0.1: added ONCE flag */ +/* $DragonFly: src/games/hack/def.gen.h,v 1.2 2006/08/21 19:45:32 pavalos Exp $ */ struct gen { struct gen *ngen; @@ -11,5 +12,4 @@ struct gen { #define ONCE 0100 }; extern struct gen *fgold, *ftrap; -struct gen *g_at(); #define newgen() (struct gen *) alloc(sizeof(struct gen)) diff --git a/games/hack/def.gold.h b/games/hack/def.gold.h index 8088908835..9bef52ddf1 100644 --- a/games/hack/def.gold.h +++ b/games/hack/def.gold.h @@ -1,5 +1,6 @@ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* def.gold.h - version 1.0.2 */ +/* $DragonFly: src/games/hack/def.gold.h,v 1.2 2006/08/21 19:45:32 pavalos Exp $ */ struct gold { struct gold *ngold; @@ -8,5 +9,4 @@ struct gold { }; extern struct gold *fgold; -struct gold *g_at(); #define newgold() (struct gold *) alloc(sizeof(struct gold)) diff --git a/games/hack/def.monst.h b/games/hack/def.monst.h index 8f48ac71b4..703f0fc772 100644 --- a/games/hack/def.monst.h +++ b/games/hack/def.monst.h @@ -1,6 +1,6 @@ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* def.monst.h - version 1.0.2 */ -/* $DragonFly: src/games/hack/def.monst.h,v 1.2 2004/11/06 12:29:17 eirikn Exp $ */ +/* $DragonFly: src/games/hack/def.monst.h,v 1.3 2006/08/21 19:45:32 pavalos Exp $ */ struct monst { struct monst *nmon; @@ -50,7 +50,6 @@ struct monst { extern struct monst *fmon; extern struct monst *fallen_down; -struct monst *m_at(); /* these are in mspeed */ #define MSLOW 1 /* slow monster */ diff --git a/games/hack/def.objclass.h b/games/hack/def.objclass.h index d513d5abbc..2bc5784c24 100644 --- a/games/hack/def.objclass.h +++ b/games/hack/def.objclass.h @@ -1,7 +1,9 @@ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* def.objclass.h - version 1.0.3 */ -/* $DragonFly: src/games/hack/def.objclass.h,v 1.2 2005/05/22 03:37:05 y0netan1 Exp $ */ +/* $DragonFly: src/games/hack/def.objclass.h,v 1.3 2006/08/21 19:45:32 pavalos Exp $ */ +#ifndef _DEF_OBJCLASS_H_ +#define _DEF_OBJCLASS_H_ /* definition of a class of objects */ struct objclass { @@ -59,3 +61,4 @@ extern struct objclass objects[]; * hack.invent.c: if(index("!%?[)=*(0/\"", sym)){ * hack.invent.c: || index("%?!*",otmp->olet))){ */ +#endif /* _DEF_OBJCLASS_H_ */ diff --git a/games/hack/def.objects.h b/games/hack/def.objects.h index 9d21be6f2d..35d8b3eb7e 100644 --- a/games/hack/def.objects.h +++ b/games/hack/def.objects.h @@ -1,7 +1,9 @@ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* def.objects.h - version 1.0.3 */ +/* $DragonFly: src/games/hack/def.objects.h,v 1.2 2006/08/21 19:45:32 pavalos Exp $ */ /* objects have letter " % ) ( 0 _ ` [ ! ? / = * */ +#include #include "config.h" #include "def.objclass.h" diff --git a/games/hack/def.trap.h b/games/hack/def.trap.h index 26946add76..27fa67bd17 100644 --- a/games/hack/def.trap.h +++ b/games/hack/def.trap.h @@ -1,5 +1,6 @@ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* def.trap.h - version 1.0.2 */ +/* $DragonFly: src/games/hack/def.trap.h,v 1.2 2006/08/21 19:45:32 pavalos Exp $ */ struct trap { struct trap *ntrap; @@ -10,7 +11,6 @@ struct trap { }; extern struct trap *ftrap; -struct trap *t_at(); #define newtrap() (struct trap *) alloc(sizeof(struct trap)) /* various kinds of traps */ diff --git a/games/hack/hack.Decl.c b/games/hack/hack.Decl.c index ddcf9307ac..fc78113436 100644 --- a/games/hack/hack.Decl.c +++ b/games/hack/hack.Decl.c @@ -1,6 +1,6 @@ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* hack.Decl.c - version 1.0.3 */ -/* $DragonFly: src/games/hack/hack.Decl.c,v 1.3 2005/05/22 03:37:05 y0netan1 Exp $ */ +/* $DragonFly: src/games/hack/hack.Decl.c,v 1.4 2006/08/21 19:45:32 pavalos Exp $ */ #include "hack.h" char nul[40]; /* contains zeros */ @@ -11,7 +11,6 @@ boolean in_mklev, restoring; struct rm levl[COLNO][ROWNO]; /* level map */ #ifndef QUEST -#include "def.mkroom.h" struct mkroom rooms[MAXNROFROOMS+1]; coord doors[DOORMAX]; #endif /* QUEST */ diff --git a/games/hack/hack.apply.c b/games/hack/hack.apply.c index e8b026dc29..04989ae4ee 100644 --- a/games/hack/hack.apply.c +++ b/games/hack/hack.apply.c @@ -1,22 +1,26 @@ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* hack.apply.c - version 1.0.3 */ /* $FreeBSD: src/games/hack/hack.apply.c,v 1.4.2.1 2001/02/18 02:20:07 kris Exp $ */ -/* $DragonFly: src/games/hack/hack.apply.c,v 1.3 2005/05/22 03:37:05 y0netan1 Exp $ */ +/* $DragonFly: src/games/hack/hack.apply.c,v 1.4 2006/08/21 19:45:32 pavalos Exp $ */ #include "hack.h" #include "def.edog.h" -#include "def.mkroom.h" -static struct monst *bchit(); -extern struct obj *addinv(); -extern struct trap *maketrap(); -extern int (*occupation)(); extern char quitchars[]; -extern char pl_character[]; -static void use_camera(), use_ice_box(), use_whistle(), use_magic_whistle(); -static int use_pick_axe(); +static void use_camera(struct obj *); +static bool in_ice_box(struct obj *); +static bool ck_ice_box(struct obj *); +static int out_ice_box(struct obj *); +static void use_ice_box(struct obj *); +static struct monst *bchit(int, int, int, char); +static void use_whistle(struct obj *); +static void use_magic_whistle(struct obj *); +static bool dig(void); +static int use_pick_axe(struct obj *); -doapply() { +int +doapply(void) +{ struct obj *obj; int res = 1; @@ -63,9 +67,9 @@ doapply() { return(res); } -/* ARGSUSED */ static void -use_camera(obj) /* */ struct obj *obj; { +use_camera(__unused struct obj *obj) +{ struct monst *mtmp; if(!getdir(1)){ /* ask: in what direction? */ flags.move = multi = 0; @@ -80,7 +84,7 @@ struct monst *mtmp; (u.dz > 0) ? "floor" : "ceiling"); return; } - if(mtmp = bchit(u.dx, u.dy, COLNO, '!')) { + if((mtmp = bchit(u.dx, u.dy, COLNO, '!'))) { if(mtmp->msleep){ mtmp->msleep = 0; pline("The flash awakens %s.", monnam(mtmp)); /* a3 */ @@ -111,8 +115,9 @@ struct monst *mtmp; static struct obj *current_ice_box; /* a local variable of use_ice_box, to be used by its local procedures in/ck_ice_box */ -static -in_ice_box(obj) struct obj *obj; { +static bool +in_ice_box(struct obj *obj) +{ if(obj == current_ice_box || (Punished && (obj == uball || obj == uchain))){ pline("You must be kidding."); @@ -142,13 +147,15 @@ in_ice_box(obj) struct obj *obj; { return(1); } -static -ck_ice_box(obj) struct obj *obj; { +static bool +ck_ice_box(struct obj *obj) +{ return(obj->o_cnt_id == current_ice_box->o_id); } -static -out_ice_box(obj) struct obj *obj; { +static int +out_ice_box(struct obj *obj) +{ struct obj *otmp; if(obj == fcobj) fcobj = fcobj->nobj; else { @@ -158,11 +165,13 @@ struct obj *otmp; } current_ice_box->owt -= obj->owt; obj->age = moves - obj->age; /* simulated point of time */ - (void) addinv(obj); + addinv(obj); + return(0); } static void -use_ice_box(obj) struct obj *obj; { +use_ice_box(struct obj *obj) +{ int cnt = 0; struct obj *otmp; current_ice_box = obj; /* for use by in/out_ice_box */ @@ -184,9 +193,9 @@ struct obj *otmp; flags.move = multi = 0; } -static -struct monst * -bchit(ddx,ddy,range,sym) int ddx,ddy,range; char sym; { +static struct monst * +bchit(int ddx, int ddy, int range, char sym) +{ struct monst *mtmp = (struct monst *) 0; int bchx = u.ux, bchy = u.uy; @@ -194,7 +203,7 @@ bchit(ddx,ddy,range,sym) int ddx,ddy,range; char sym; { while(range--) { bchx += ddx; bchy += ddy; - if(mtmp = m_at(bchx,bchy)) + if((mtmp = m_at(bchx,bchy))) break; if(!ZAP_POS(levl[bchx][bchy].typ)) { bchx -= ddx; @@ -207,9 +216,9 @@ bchit(ddx,ddy,range,sym) int ddx,ddy,range; char sym; { return(mtmp); } -/* ARGSUSED */ static void -use_whistle(obj) struct obj *obj; { +use_whistle(__unused struct obj *obj) +{ struct monst *mtmp = fmon; pline("You produce a high whistling sound."); while(mtmp) { @@ -223,9 +232,9 @@ struct monst *mtmp = fmon; } } -/* ARGSUSED */ static void -use_magic_whistle(obj) struct obj *obj; { +use_magic_whistle(__unused struct obj *obj) +{ struct monst *mtmp = fmon; pline("You produce a strange whistling sound."); while(mtmp) { @@ -239,8 +248,9 @@ static uchar dig_level; static coord dig_pos; static boolean dig_down; -static -dig() { +static bool +dig(void) +{ struct rm *lev; int dpx = dig_pos.x, dpy = dig_pos.y; @@ -280,7 +290,7 @@ dig() { struct obj *obj; lev = &levl[dpx][dpy]; - if(obj = sobj_at(ENORMOUS_ROCK, dpx, dpy)) { + if((obj = sobj_at(ENORMOUS_ROCK, dpx, dpy))) { fracture_rock(obj); digtxt = "The rock falls apart."; } else if(!lev->typ || lev->typ == SCORR) { @@ -311,11 +321,14 @@ dig() { } /* When will hole be finished? Very rough indication used by shopkeeper. */ -holetime() { +int +holetime(void) +{ return( (occupation == dig) ? (250 - dig_effort)/20 : -1); } -dighole() +void +dighole(void) { struct trap *ttmp = t_at(u.ux, u.uy); @@ -341,12 +354,10 @@ dighole() } } -static -use_pick_axe(obj) -struct obj *obj; +static int +use_pick_axe(struct obj *obj) { char dirsyms[12]; - extern char sdir[]; char *dsp = dirsyms, *sdp = sdir; struct monst *mtmp; struct rm *lev; @@ -364,7 +375,7 @@ struct obj *obj; res = 1; } while(*sdp) { - (void) movecmd(*sdp); /* sets u.dx and u.dy and u.dz */ + movecmd(*sdp); /* sets u.dx and u.dy and u.dz */ rx = u.ux + u.dx; ry = u.uy + u.dy; if(u.dz > 0 || (u.dz == 0 && isok(rx, ry) && diff --git a/games/hack/hack.bones.c b/games/hack/hack.bones.c index a55ecf9d9f..f8d633443a 100644 --- a/games/hack/hack.bones.c +++ b/games/hack/hack.bones.c @@ -1,18 +1,16 @@ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* hack.bones.c - version 1.0.3 */ /* $FreeBSD: src/games/hack/hack.bones.c,v 1.4 1999/11/16 10:26:35 marcel Exp $ */ -/* $DragonFly: src/games/hack/hack.bones.c,v 1.3 2004/11/06 12:29:17 eirikn Exp $ */ +/* $DragonFly: src/games/hack/hack.bones.c,v 1.4 2006/08/21 19:45:32 pavalos Exp $ */ #include "hack.h" -extern char plname[PL_NSIZ]; -extern long somegold(); -extern struct monst *makemon(); -extern struct permonst pm_ghost; char bones[] = "bones_xx"; /* save bones and possessions of a deceased adventurer */ -savebones(){ +void +savebones(void) +{ int fd; struct obj *otmp; struct trap *ttmp; @@ -22,7 +20,7 @@ struct monst *mtmp; bones[6] = '0' + (dlevel/10); bones[7] = '0' + (dlevel%10); if((fd = open(bones,0)) >= 0){ - (void) close(fd); + close(fd); return; } /* drop everything; the corpse's possessions are usually cursed */ @@ -45,7 +43,7 @@ struct monst *mtmp; mtmp->mx = u.ux; mtmp->my = u.uy; mtmp->msleep = 1; - (void) strcpy((char *) mtmp->mextra, plname); + strcpy((char *) mtmp->mextra, plname); mkgold(somegold() + d(dlevel,30), u.ux, u.uy); for(mtmp = fmon; mtmp; mtmp = mtmp->nmon){ mtmp->m_id = 0; @@ -71,10 +69,12 @@ struct monst *mtmp; } if((fd = creat(bones, FMASK)) < 0) return; savelev(fd,dlevel); - (void) close(fd); + close(fd); } -getbones(){ +int +getbones(void) +{ int fd,x,y,ok; if(rn2(3)) return(0); /* only once in three times do we find bones */ bones[6] = '0' + dlevel/10; @@ -85,7 +85,7 @@ int fd,x,y,ok; for(x = 0; x < COLNO; x++) for(y = 0; y < ROWNO; y++) levl[x][y].seen = levl[x][y].new = 0; } - (void) close(fd); + close(fd); #ifdef WIZARD if(!wizard) /* duvel!frans: don't remove bones while debugging */ #endif /* WiZARD */ diff --git a/games/hack/hack.c b/games/hack/hack.c index 251cde7081..d2490c41e0 100644 --- a/games/hack/hack.c +++ b/games/hack/hack.c @@ -1,30 +1,27 @@ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* hack.c - version 1.0.3 */ /* $FreeBSD: src/games/hack/hack.c,v 1.4 1999/11/16 10:26:35 marcel Exp $ */ -/* $DragonFly: src/games/hack/hack.c,v 1.4 2005/05/22 03:37:05 y0netan1 Exp $ */ +/* $DragonFly: src/games/hack/hack.c,v 1.5 2006/08/21 19:45:32 pavalos Exp $ */ #include "hack.h" -#include -extern char news0(); -extern struct obj *addinv(); -extern boolean hmon(); +static void movobj(struct obj *, int, int); +#ifdef QUEST +static bool rroom(int, int); +#endif +static int inv_cnt(void); /* called on movement: 1. when throwing ball+chain far away 2. when teleporting 3. when walking out of a lit room */ -unsee() { +void +unsee(void) +{ int x,y; struct rm *lev; -/* - if(u.udispl){ - u.udispl = 0; - newsym(u.udisx, u.udisy); - } -*/ #ifndef QUEST if(seehx){ seehx = 0; @@ -50,7 +47,8 @@ unsee() { in hack.do.c: seeoff(1) - go up or down the stairs in hack.trap.c:seeoff(1) - fall through trapdoor */ -seeoff(mode) /* 1 to redo @, 0 to leave them */ +void +seeoff(bool mode) /* 1 to redo @, 0 to leave them */ { /* 1 means misc movement, 0 means blindness */ int x,y; struct rm *lev; @@ -75,12 +73,13 @@ seeoff(mode) /* 1 to redo @, 0 to leave them */ } } -domove() +void +domove(void) { xchar oldx,oldy; - struct monst *mtmp; + struct monst *mtmp = NULL; struct rm *tmpr,*ust; - struct trap *trap; + struct trap *trap = NULL; struct obj *otmp; u_wipe_engr(rnd(5)); @@ -154,7 +153,7 @@ domove() nomul(0); return; } - while(otmp = sobj_at(ENORMOUS_ROCK, u.ux+u.dx, u.uy+u.dy)) { + while((otmp = sobj_at(ENORMOUS_ROCK, u.ux+u.dx, u.uy+u.dy))) { xchar rx = u.ux+2*u.dx, ry = u.uy+2*u.dy; struct trap *ttmp; nomul(0); @@ -166,7 +165,7 @@ domove() pline("Perhaps that's why you cannot move it."); goto cannot_push; } - if(ttmp = t_at(rx,ry)) + if((ttmp = t_at(rx,ry))) switch(ttmp->ttyp) { case PIT: pline("You push the rock into a pit!"); @@ -190,7 +189,6 @@ domove() } otmp->ox = rx; otmp->oy = ry; - /* pobj(otmp); */ if(cansee(rx,ry)) atl(rx,ry,otmp->olet); if(Invisible) newsym(u.ux+u.dx, u.uy+u.dy); @@ -260,12 +258,6 @@ domove() if(tmpr->typ == POOL && !Levitation) drown(); /* not necessarily fatal */ -/* - if(u.udispl) { - u.udispl = 0; - newsym(oldx,oldy); - } -*/ if(!Blind) { #ifdef QUEST setsee(); @@ -302,13 +294,12 @@ domove() } if(!flags.nopick) pickup(1); if(trap) dotrap(trap); /* fall into pit, arrow trap, etc. */ - (void) inshop(); + inshop(); if(!Blind) read_engr_at(u.ux,u.uy); } -movobj(obj, ox, oy) -struct obj *obj; -int ox, oy; +static void +movobj(struct obj *obj, int ox, int oy) { /* Some dirty programming to get display right */ freeobj(obj); @@ -319,7 +310,9 @@ int ox, oy; obj->oy = oy; } -dopickup(){ +int +dopickup(void) +{ if(!g_at(u.ux,u.uy) && !o_at(u.ux,u.uy)) { pline("There is nothing here to pick up."); return(0); @@ -332,14 +325,15 @@ dopickup(){ return(1); } -pickup(all) +void +pickup(int all) { struct gold *gold; struct obj *obj, *obj2; int wt; if(Levitation) return; - while(gold = g_at(u.ux,u.uy)) { + while((gold = g_at(u.ux,u.uy))) { pline("%ld gold piece%s.", gold->amount, plur(gold->amount)); u.ugold += gold->amount; flags.botl = 1; @@ -406,7 +400,6 @@ pickup(all) if(wt > 0) { if(obj->quan > 1) { /* see how many we can lift */ - extern struct obj *splitobj(); int savequan = obj->quan; int iw = inv_weight(); int qq; @@ -422,7 +415,7 @@ pickup(all) pline("You can only carry %s of the %s lying here.", (qq == 1) ? "one" : "some", doname(obj)); - (void) splitobj(obj, qq); + splitobj(obj, qq); /* note: obj2 is set already, so we'll never * encounter the other half; if it should be * otherwise then write @@ -464,14 +457,14 @@ pickup(all) /* stop running if we see something interesting */ /* turn around a corner if that is the only way we can proceed */ /* do not turn left or right twice */ -lookaround(){ +void +lookaround(void) +{ int x,y,i,x0,y0,m0,i0 = 9; int corrct = 0, noturn = 0; struct monst *mtmp; -#ifdef lint /* suppress "used before set" message */ - x0 = y0 = 0; -#endif /* lint */ + x0 = y0 = m0 = 0; if(Blind || flags.run == 0) return; if(flags.run == 1 && levl[u.ux][u.uy].typ == ROOM) return; #ifdef QUEST @@ -559,7 +552,9 @@ struct monst *mtmp; /* something like lookaround, but we are not running */ /* react only to monsters that might hit us */ -monster_nearby() { +bool +monster_nearby(void) +{ int x,y; struct monst *mtmp; if(!Blind) @@ -575,7 +570,9 @@ struct monst *mtmp; } #ifdef QUEST -cansee(x,y) xchar x,y; { +bool +cansee(xchar x, xchar y) +{ int dx,dy,adx,ady,sdx,sdy,dmax,d; if(Blind) return(0); if(!isok(x,y)) return(0); @@ -609,13 +606,17 @@ int dx,dy,adx,ady,sdx,sdy,dmax,d; } } -rroom(x,y) int x,y; { +static bool +rroom(int x, int y) +{ return(IS_ROOM(levl[u.ux+x][u.uy+y].typ)); } #else -cansee(x,y) xchar x,y; { +bool +cansee(xchar x, xchar y) +{ if(Blind || u.uswallow) return(0); if(dist(x,y) < 3) return(1); if(levl[x][y].lit && seelx <= x && x <= seehx && seely <= y && @@ -624,12 +625,15 @@ cansee(x,y) xchar x,y; { } #endif /* QUEST */ -sgn(a) int a; { +int +sgn(int a) +{ return((a > 0) ? 1 : (a == 0) ? 0 : -1); } #ifdef QUEST -setsee() +void +setsee(void) { x,y; @@ -646,7 +650,8 @@ setsee() #else -setsee() +void +setsee(void) { int x,y; @@ -679,15 +684,16 @@ setsee() } #endif /* QUEST */ -nomul(nval) -int nval; +void +nomul(int nval) { if(multi < 0) return; multi = nval; flags.mv = flags.run = 0; } -abon() +int +abon(void) { if(u.ustr == 3) return(-3); else if(u.ustr < 6) return(-2); @@ -698,7 +704,8 @@ abon() else return(3); } -dbon() +int +dbon(void) { if(u.ustr < 6) return(-1); else if(u.ustr < 16) return(0); @@ -710,8 +717,8 @@ dbon() else return(6); } -losestr(num) /* may kill you; cause may be poison or monster like 'A' */ -int num; +void +losestr(int num) /* may kill you; cause may be poison or monster like 'A' */ { u.ustr -= num; while(u.ustr < 3) { @@ -722,9 +729,8 @@ int num; flags.botl = 1; } -losehp(n,knam) -int n; -char *knam; +void +losehp(int n, const char *knam) { u.uhp -= n; if(u.uhp > u.uhpmax) @@ -736,9 +742,8 @@ char *knam; } } -losehp_m(n,mtmp) -int n; -struct monst *mtmp; +void +losehp_m(int n, struct monst *mtmp) { u.uhp -= n; flags.botl = 1; @@ -746,10 +751,10 @@ struct monst *mtmp; done_in_by(mtmp); } -losexp() /* hit by V or W */ +void +losexp(void) /* hit by V or W */ { int num; - extern long newuexp(); if(u.ulevel > 1) pline("Goodbye level %u.", u.ulevel--); @@ -762,7 +767,9 @@ losexp() /* hit by V or W */ flags.botl = 1; } -inv_weight(){ +int +inv_weight(void) +{ struct obj *otmp = invent; int wt = (u.ugold + 500)/1000; int carrcap; @@ -781,7 +788,9 @@ int carrcap; return(wt - carrcap); } -inv_cnt(){ +static int +inv_cnt(void) +{ struct obj *otmp = invent; int ct = 0; while(otmp){ @@ -792,7 +801,7 @@ int ct = 0; } long -newuexp() +newuexp(void) { return(10*(1L << (u.ulevel-1))); } diff --git a/games/hack/hack.cmd.c b/games/hack/hack.cmd.c index ef1fd7e3b8..cee0571433 100644 --- a/games/hack/hack.cmd.c +++ b/games/hack/hack.cmd.c @@ -1,98 +1,93 @@ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* hack.cmd.c - version 1.0.3 */ /* $FreeBSD: src/games/hack/hack.cmd.c,v 1.4 1999/11/16 10:26:35 marcel Exp $ */ -/* $DragonFly: src/games/hack/hack.cmd.c,v 1.3 2004/11/06 12:29:17 eirikn Exp $ */ +/* $DragonFly: src/games/hack/hack.cmd.c,v 1.4 2006/08/21 19:45:32 pavalos Exp $ */ #include "hack.h" #include "def.func_tab.h" -int doredraw(),doredotopl(),dodrop(),dodrink(),doread(),dosearch(),dopickup(), -doversion(),doweararm(),dowearring(),doremarm(),doremring(),dopay(),doapply(), -dosave(),dowield(),ddoinv(),dozap(),ddocall(),dowhatis(),doengrave(),dotele(), -dohelp(),doeat(),doddrop(),do_mname(),doidtrap(),doprwep(),doprarm(), -doprring(),doprgold(),dodiscovered(),dotypeinv(),dolook(),doset(), -doup(), dodown(), done1(), donull(), dothrow(), doextcmd(), dodip(), dopray(); -#ifdef SHELL -int dosh(); -#endif /* SHELL */ -#ifdef SUSPEND -int dosuspend(); -#endif /* SUSPEND */ +static int doextcmd(void); +static char lowc(char); +static char unctrl(char); +#ifdef QUEST +static bool isroom(int, int); +#endif +static int done2(void); struct func_tab cmdlist[]={ - '\020', doredotopl, - '\022', doredraw, - '\024', dotele, + { '\020', doredotopl }, + { '\022', doredraw }, + { '\024', dotele }, #ifdef SUSPEND - '\032', dosuspend, + { '\032', dosuspend }, #endif /* SUSPEND */ - 'a', doapply, + { 'a', doapply }, /* 'A' : UNUSED */ /* 'b', 'B' : go sw */ - 'c', ddocall, - 'C', do_mname, - 'd', dodrop, - 'D', doddrop, - 'e', doeat, - 'E', doengrave, + { 'c', ddocall }, + { 'C', do_mname }, + { 'd', dodrop }, + { 'D', doddrop }, + { 'e', doeat }, + { 'E', doengrave }, /* 'f', 'F' : multiple go (might become 'fight') */ /* 'g', 'G' : UNUSED */ /* 'h', 'H' : go west */ - 'I', dotypeinv, /* Robert Viduya */ - 'i', ddoinv, + { 'I', dotypeinv }, /* Robert Viduya */ + { 'i', ddoinv }, /* 'j', 'J', 'k', 'K', 'l', 'L', 'm', 'M', 'n', 'N' : move commands */ /* 'o', doopen, */ - 'O', doset, - 'p', dopay, - 'P', dowearring, - 'q', dodrink, - 'Q', done1, - 'r', doread, - 'R', doremring, - 's', dosearch, - 'S', dosave, - 't', dothrow, - 'T', doremarm, + { 'O', doset }, + { 'p', dopay }, + { 'P', dowearring }, + { 'q', dodrink }, + { 'Q', done2 }, + { 'r', doread }, + { 'R', doremring }, + { 's', dosearch }, + { 'S', dosave }, + { 't', dothrow }, + { 'T', doremarm }, /* 'u', 'U' : go ne */ - 'v', doversion, + { 'v', doversion }, /* 'V' : UNUSED */ - 'w', dowield, - 'W', doweararm, + { 'w', dowield }, + { 'W', doweararm }, /* 'x', 'X' : UNUSED */ /* 'y', 'Y' : go nw */ - 'z', dozap, + { 'z', dozap }, /* 'Z' : UNUSED */ - '<', doup, - '>', dodown, - '/', dowhatis, - '?', dohelp, + { '<', doup }, + { '>', dodown }, + { '/', dowhatis }, + { '?', dohelp }, #ifdef SHELL - '!', dosh, + { '!', dosh }, #endif /* SHELL */ - '.', donull, - ' ', donull, - ',', dopickup, - ':', dolook, - '^', doidtrap, - '\\', dodiscovered, /* Robert Viduya */ - WEAPON_SYM, doprwep, - ARMOR_SYM, doprarm, - RING_SYM, doprring, - '$', doprgold, - '#', doextcmd, - 0,0,0 + { '.', donull }, + { ' ', donull }, + { ',', dopickup }, + { ':', dolook }, + { '^', doidtrap }, + { '\\', dodiscovered }, /* Robert Viduya */ + { WEAPON_SYM, doprwep }, + { ARMOR_SYM, doprarm }, + { RING_SYM, doprring }, + { '$', doprgold }, + { '#', doextcmd }, + { 0, 0 } }; struct ext_func_tab extcmdlist[] = { - "dip", dodip, - "pray", dopray, - (char *) 0, donull + { "dip", dodip }, + { "pray", dopray }, + { (char *) 0, donull } }; -extern char *parse(), lowc(), unctrl(), quitchars[]; +extern char quitchars[]; -rhack(cmd) -char *cmd; +void +rhack(const char *cmd) { struct func_tab *tlist = cmdlist; boolean firsttime = FALSE; @@ -172,7 +167,7 @@ char *cmd; } { char expcmd[10]; char *cp = expcmd; - while(*cmd && cp-expcmd < sizeof(expcmd)-2) { + while(*cmd && cp-expcmd < (int)sizeof(expcmd)-2) { if(*cmd >= 040 && *cmd < 0177) *cp++ = *cmd++; else { @@ -186,7 +181,8 @@ char *cmd; multi = flags.move = 0; } -doextcmd() /* here after # - now read a full-word command */ +static int +doextcmd(void) /* here after # - now read a full-word command */ { char buf[BUFSZ]; struct ext_func_tab *efp = extcmdlist; @@ -205,16 +201,14 @@ doextcmd() /* here after # - now read a full-word command */ return(0); } -char -lowc(sym) -char sym; +static char +lowc(char sym) { return( (sym >= 'A' && sym <= 'Z') ? sym+'a'-'A' : sym ); } -char -unctrl(sym) -char sym; +static char +unctrl(char sym) { return( (sym >= ('A' & 037) && sym <= ('Z' & 037)) ? sym + 0140 : sym ); } @@ -225,8 +219,8 @@ schar xdir[10] = { -1,-1, 0, 1, 1, 1, 0,-1, 0, 0 }; schar ydir[10] = { 0,-1,-1,-1, 0, 1, 1, 1, 0, 0 }; schar zdir[10] = { 0, 0, 0, 0, 0, 0, 0, 0, 1,-1 }; -movecmd(sym) /* also sets u.dz, but returns false for <> */ -char sym; +bool +movecmd(char sym) /* also sets u.dz, but returns false for <> */ { char *dp; @@ -238,8 +232,8 @@ char sym; return(!u.dz); } -getdir(s) -boolean s; +bool +getdir(bool s) { char dirsym; @@ -255,7 +249,8 @@ boolean s; return(1); } -confdir() +void +confdir(void) { int x = rn2(8); u.dx = xdir[x]; @@ -263,7 +258,9 @@ confdir() } #ifdef QUEST -finddir(){ +void +finddir(void) +{ int i, ui = u.di; for(i = 0; i <= 8; i++){ if(flags.run & 1) ui++; else ui += 7; @@ -271,7 +268,7 @@ int i, ui = u.di; if(i == 8){ pline("Not near a wall."); flags.move = multi = 0; - return(0); + return; } if(!isroom(u.ux+xdir[ui], u.uy+ydir[ui])) break; @@ -282,7 +279,7 @@ int i, ui = u.di; if(i == 8){ pline("Not near a room."); flags.move = multi = 0; - return(0); + return; } if(isroom(u.ux+xdir[ui], u.uy+ydir[ui])) break; @@ -292,13 +289,28 @@ int i, ui = u.di; u.dy = ydir[ui]; } -isroom(x,y) x,y; { /* what about POOL? */ +static bool +isroom(int x, int y) +{ /* what about POOL? */ return(isok(x,y) && (levl[x][y].typ == ROOM || (levl[x][y].typ >= LDOOR && flags.run >= 6))); } #endif /* QUEST */ -isok(x,y) int x,y; { +bool +isok(int x, int y) +{ /* x corresponds to curx, so x==1 is the first column. Ach. %% */ return(x >= 1 && x <= COLNO-1 && y >= 0 && y <= ROWNO-1); } + +/* + * done2 is a function that fits into cmdlist[] (int func(void)) + * and calls done1 which discards its argument. + */ +static int +done2(void) +{ + done1(0); + return(0); +} diff --git a/games/hack/hack.do.c b/games/hack/hack.do.c index 5dfdaf30df..6584eeb9db 100644 --- a/games/hack/hack.do.c +++ b/games/hack/hack.do.c @@ -1,26 +1,26 @@ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* hack.do.c - version 1.0.3 */ /* $FreeBSD: src/games/hack/hack.do.c,v 1.4 1999/11/16 10:26:36 marcel Exp $ */ -/* $DragonFly: src/games/hack/hack.do.c,v 1.4 2005/05/22 03:37:05 y0netan1 Exp $ */ +/* $DragonFly: src/games/hack/hack.do.c,v 1.5 2006/08/21 19:45:32 pavalos Exp $ */ /* Contains code for 'd', 'D' (drop), '>', '<' (up, down) and 't' (throw) */ #include "hack.h" -extern struct obj *splitobj(), *addinv(); -extern boolean hmon(); -extern boolean level_exists[]; extern struct monst youmonst; -extern char *Doname(); -static int drop(); +static int drop(struct obj *); +static void dropy(struct obj *); -dodrop() { +int +dodrop(void) +{ return(drop(getobj("0$#", "drop"))); } static int -drop(obj) struct obj *obj; { +drop(struct obj *obj) +{ if(!obj) return(0); if(obj->olet == '$') { /* pseudo object */ long amount = OGOLD(obj); @@ -53,15 +53,15 @@ drop(obj) struct obj *obj; { } /* Called in several places - should not produce texts */ -dropx(obj) -struct obj *obj; +void +dropx(struct obj *obj) { freeinv(obj); dropy(obj); } -dropy(obj) -struct obj *obj; +static void +dropy(struct obj *obj) { if(obj->otyp == CRYSKNIFE) obj->otyp = WORM_TOOTH; @@ -75,11 +75,14 @@ struct obj *obj; } /* drop several things */ -doddrop() { +int +doddrop(void) +{ return(ggetobj("drop", drop, 0)); } -dodown() +int +dodown(void) { if(u.ux != xdnstair || u.uy != ydnstair) { pline("You can't go down here."); @@ -98,7 +101,8 @@ dodown() return(1); } -doup() +int +doup(void) { if(u.ux != xupstair || u.uy != yupstair) { pline("You can't go up here."); @@ -117,9 +121,8 @@ doup() return(1); } -goto_level(newlevel, at_stairs) -int newlevel; -boolean at_stairs; +void +goto_level(int newlevel, boolean at_stairs) { int fd; boolean up = (newlevel < dlevel); @@ -152,10 +155,10 @@ boolean at_stairs; u.uswldtim = u.uswallow = 0; flags.nscrinh = 1; u.ux = FAR; /* hack */ - (void) inshop(); /* probably was a trapdoor */ + inshop(); /* probably was a trapdoor */ savelev(fd,dlevel); - (void) close(fd); + close(fd); dlevel = newlevel; if(maxdlevel < dlevel) @@ -165,15 +168,13 @@ boolean at_stairs; if(!level_exists[dlevel]) mklev(); else { - extern int hackpid; - if((fd = open(lock,0)) < 0) { pline("Cannot open %s .", lock); pline("Probably someone removed it."); done("tricked"); } getlev(fd, hackpid, dlevel); - (void) close(fd); + close(fd); } if(at_stairs) { @@ -223,12 +224,12 @@ boolean at_stairs; } selftouch("Falling, you"); } - (void) inshop(); + inshop(); initrack(); losedogs(); { struct monst *mtmp; - if(mtmp = m_at(u.ux, u.uy)) mnexto(mtmp); /* riv05!a3 */ + if((mtmp = m_at(u.ux, u.uy))) mnexto(mtmp); /* riv05!a3 */ } flags.nscrinh = 0; setsee(); @@ -238,18 +239,22 @@ boolean at_stairs; read_engr_at(u.ux,u.uy); } -donull() { +int +donull(void) +{ return(1); /* Do nothing, but let other things happen */ } -dopray() { +int +dopray(void) +{ nomovemsg = "You finished your prayer."; nomul(-3); return(1); } -struct monst *bhit(), *boomhit(); -dothrow() +int +dothrow(void) { struct obj *obj; struct monst *mon; @@ -277,7 +282,7 @@ dothrow() setuwep((struct obj *) 0); } else if(obj->quan > 1) - (void) splitobj(obj, 1); + splitobj(obj, 1); freeinv(obj); if(u.uswallow) { mon = u.ustuck; @@ -314,7 +319,7 @@ dothrow() } else if(obj->otyp == BOOMERANG) { mon = boomhit(u.dx, u.dy); if(mon == &youmonst) { /* the thing was caught */ - (void) addinv(obj); + addinv(obj); return(1); } } else { @@ -323,8 +328,8 @@ dothrow() mon = bhit(u.dx, u.dy, (obj->otyp == ICE_BOX) ? 1 : (!Punished || obj != uball) ? 8 : !u.ustuck ? 5 : 1, - obj->olet, - (int (*)()) 0, (int (*)()) 0, obj); + obj->olet, (void (*)(struct monst *, struct obj *)) 0, + (bool (*)(struct obj *, struct obj *)) 0, obj); } if(mon) { /* awake monster if sleeping */ @@ -431,7 +436,7 @@ dothrow() u.ux = uchain->ox = bhitpos.x - u.dx; u.uy = uchain->oy = bhitpos.y - u.dy; setsee(); - (void) inshop(); + inshop(); } if(cansee(bhitpos.x, bhitpos.y)) prl(bhitpos.x,bhitpos.y); return(1); @@ -440,7 +445,8 @@ dothrow() /* split obj so that it gets size num */ /* remainder is put in the object structure delivered by this call */ struct obj * -splitobj(obj, num) struct obj *obj; int num; { +splitobj(struct obj *obj, int num) +{ struct obj *otmp; otmp = newobj(0); *otmp = *obj; /* copies whole structure */ @@ -455,11 +461,9 @@ struct obj *otmp; return(otmp); } -more_experienced(exp,rexp) -int exp, rexp; +void +more_experienced(int exp, int rexp) { - extern char pl_character[]; - u.uexp += exp; u.urexp += 4*exp + rexp; if(exp) flags.botl = 1; @@ -467,9 +471,8 @@ int exp, rexp; flags.beginner = 0; } -set_wounded_legs(side, timex) -long side; -int timex; +void +set_wounded_legs(long side, int timex) { if(!Wounded_legs || (Wounded_legs & TIMEOUT)) Wounded_legs |= side + timex; @@ -477,7 +480,8 @@ int timex; Wounded_legs |= side; } -heal_legs() +void +heal_legs(void) { if(Wounded_legs) { if((Wounded_legs & BOTH_SIDES) == BOTH_SIDES) diff --git a/games/hack/hack.do_name.c b/games/hack/hack.do_name.c index e136f2e8e3..202d7fe0f7 100644 --- a/games/hack/hack.do_name.c +++ b/games/hack/hack.do_name.c @@ -1,18 +1,19 @@ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* hack.do_name.c - version 1.0.3 */ /* $FreeBSD: src/games/hack/hack.do_name.c,v 1.5 1999/11/16 10:26:36 marcel Exp $ */ -/* $DragonFly: src/games/hack/hack.do_name.c,v 1.3 2005/05/22 03:37:05 y0netan1 Exp $ */ +/* $DragonFly: src/games/hack/hack.do_name.c,v 1.4 2006/08/21 19:45:32 pavalos Exp $ */ #include "hack.h" -#include -extern char plname[]; + +static void do_oname(struct obj *); +static char *xmonnam(struct monst *, int); +static char *lmonnam(struct monst *); +static char *visctrl(char); coord -getpos(force,goal) int force; char *goal; { +getpos(int force, const char *goal) +{ int cx,cy,i,c; -extern char sdir[]; /* defined in hack.c */ -extern schar xdir[], ydir[]; /* idem */ -extern char *visctrl(); /* see below */ coord cc; pline("(For instructions type a ?)"); cx = u.ux; @@ -46,12 +47,13 @@ coord cc; return(cc); } -do_mname(){ +int +do_mname(void) +{ char buf[BUFSZ]; coord cc; int cx,cy,lth,i; struct monst *mtmp, *mtmp2; -extern char *lmonnam(); cc = getpos(0, "the monster you want to name"); cx = cc.x; cy = cc.y; @@ -85,10 +87,10 @@ extern char *lmonnam(); } mtmp2 = newmonst(mtmp->mxlth + lth); *mtmp2 = *mtmp; - for(i=0; imxlth; i++) + for(i=0; (unsigned)imxlth; i++) ((char *) mtmp2->mextra)[i] = ((char *) mtmp->mextra)[i]; mtmp2->mnamelth = lth; - (void) strcpy(NAME(mtmp2), buf); + strcpy(NAME(mtmp2), buf); replmon(mtmp,mtmp2); return(1); } @@ -98,7 +100,9 @@ extern char *lmonnam(); * when there might be pointers around in unknown places. For now: only * when obj is in the inventory. */ -do_oname(obj) struct obj *obj; { +static void +do_oname(struct obj *obj) +{ struct obj *otmp, *otmp2; int lth; char buf[BUFSZ]; @@ -115,7 +119,7 @@ char buf[BUFSZ]; otmp2 = newobj(lth); *otmp2 = *obj; otmp2->onamelth = lth; - (void) strcpy(ONAME(otmp2), buf); + strcpy(ONAME(otmp2), buf); setworn((struct obj *) 0, obj->owornmask); setworn(otmp2, otmp2->owornmask); @@ -135,7 +139,8 @@ char buf[BUFSZ]; free((char *) obj); /* let us hope nobody else saved a pointer */ } -ddocall() +int +ddocall(void) { struct obj *obj; @@ -154,13 +159,12 @@ ddocall() return(0); } -docall(obj) -struct obj *obj; +void +docall(struct obj *obj) { char buf[BUFSZ]; struct obj otemp; char **str1; - extern char *xname(); char *str; otemp = *obj; @@ -173,7 +177,7 @@ struct obj *obj; if(!*buf || *buf == '\033') return; str = newstring(strlen(buf)+1); - (void) strcpy(str,buf); + strcpy(str,buf); str1 = &(objects[obj->otyp].oc_uname); if(*str1) free(*str1); *str1 = str; @@ -187,12 +191,12 @@ const char *ghostnames[] = { "tom", "wilmar" }; -char * -xmonnam(mtmp, vb) struct monst *mtmp; int vb; { +static char * +xmonnam(struct monst *mtmp, int vb) +{ static char buf[BUFSZ]; /* %% */ -extern char *shkname(); if(mtmp->mnamelth && !vb) { - (void) strcpy(buf, NAME(mtmp)); + strcpy(buf, NAME(mtmp)); return(buf); } switch(mtmp->data->mlet) { @@ -203,61 +207,60 @@ extern char *shkname(); if(!rn2(2)) (void) strcpy((char *) mtmp->mextra, !rn2(5) ? plname : gn); } - (void) sprintf(buf, "%s's ghost", gn); + sprintf(buf, "%s's ghost", gn); } break; case '@': if(mtmp->isshk) { - (void) strcpy(buf, shkname(mtmp)); + strcpy(buf, shkname(mtmp)); break; } /* fall into next case */ default: - (void) sprintf(buf, "the %s%s", + sprintf(buf, "the %s%s", mtmp->minvis ? "invisible " : "", mtmp->data->mname); } if(vb && mtmp->mnamelth) { - (void) strcat(buf, " called "); - (void) strcat(buf, NAME(mtmp)); + strcat(buf, " called "); + strcat(buf, NAME(mtmp)); } return(buf); } -char * -lmonnam(mtmp) struct monst *mtmp; { +static char * +lmonnam(struct monst *mtmp) +{ return(xmonnam(mtmp, 1)); } char * -monnam(mtmp) struct monst *mtmp; { +monnam(struct monst *mtmp) +{ return(xmonnam(mtmp, 0)); } char * -Monnam(mtmp) struct monst *mtmp; { +Monnam(struct monst *mtmp) +{ char *bp = monnam(mtmp); if('a' <= *bp && *bp <= 'z') *bp += ('A' - 'a'); return(bp); } char * -amonnam(mtmp,adj) -struct monst *mtmp; -char *adj; +amonnam(struct monst *mtmp, const char *adj) { char *bp = monnam(mtmp); static char buf[BUFSZ]; /* %% */ if(!strncmp(bp, "the ", 4)) bp += 4; - (void) sprintf(buf, "the %s %s", adj, bp); + sprintf(buf, "the %s %s", adj, bp); return(buf); } char * -Amonnam(mtmp, adj) -struct monst *mtmp; -char *adj; +Amonnam(struct monst *mtmp, const char *adj) { char *bp = amonnam(mtmp,adj); @@ -266,7 +269,8 @@ char *adj; } char * -Xmonnam(mtmp) struct monst *mtmp; { +Xmonnam(struct monst *mtmp) +{ char *bp = Monnam(mtmp); if(!strncmp(bp, "The ", 4)) { bp += 2; @@ -275,9 +279,8 @@ char *bp = Monnam(mtmp); return(bp); } -char * -visctrl(c) -char c; +static char * +visctrl(char c) { static char ccc[3]; if(c < 040) { diff --git a/games/hack/hack.do_wear.c b/games/hack/hack.do_wear.c index bb3cee61f4..beb9d67fc9 100644 --- a/games/hack/hack.do_wear.c +++ b/games/hack/hack.do_wear.c @@ -1,18 +1,24 @@ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* hack.do_wear.c - version 1.0.3 */ /* $FreeBSD: src/games/hack/hack.do_wear.c,v 1.3 1999/11/16 02:57:03 billf Exp $ */ -/* $DragonFly: src/games/hack/hack.do_wear.c,v 1.4 2005/05/22 03:37:05 y0netan1 Exp $ */ +/* $DragonFly: src/games/hack/hack.do_wear.c,v 1.5 2006/08/21 19:45:32 pavalos Exp $ */ #include "hack.h" -#include extern char quitchars[]; -extern char *Doname(); -off_msg(otmp) struct obj *otmp; { +static void off_msg(struct obj *); +static int dorr(struct obj *); +static bool cursed(struct obj *); + +static void +off_msg(struct obj *otmp) +{ pline("You were wearing %s.", doname(otmp)); } -doremarm() { +int +doremarm(void) +{ struct obj *otmp; if(!uarm && !uarmh && !uarms && !uarmg) { pline("Not wearing any armor."); @@ -32,11 +38,13 @@ doremarm() { pline("You seem not able to take off the gloves while holding your weapon."); return(0); } - (void) armoroff(otmp); + armoroff(otmp); return(1); } -doremring() { +int +doremring(void) +{ if(!uleft && !uright){ pline("Not wearing any ring."); return(0); @@ -59,24 +67,26 @@ doremring() { case 'R': return(dorr(uright)); case '?': - (void) doprring(); + doprring(); /* might look at morc here %% */ } } /* NOTREACHED */ -#ifdef lint return(0); -#endif /* lint */ } -dorr(otmp) struct obj *otmp; { +static int +dorr(struct obj *otmp) +{ if(cursed(otmp)) return(0); ringoff(otmp); off_msg(otmp); return(1); } -cursed(otmp) struct obj *otmp; { +static bool +cursed(struct obj *otmp) +{ if(otmp->cursed){ pline("You can't. It appears to be cursed."); return(1); @@ -84,7 +94,10 @@ cursed(otmp) struct obj *otmp; { return(0); } -armoroff(otmp) struct obj *otmp; { + +bool +armoroff(struct obj *otmp) +{ int delay = -objects[otmp->otyp].oc_delay; if(cursed(otmp)) return(0); setworn((struct obj *) 0, otmp->owornmask & W_ARMOR); @@ -106,7 +119,9 @@ int delay = -objects[otmp->otyp].oc_delay; return(1); } -doweararm() { +int +doweararm(void) +{ struct obj *otmp; int delay; int err = 0; @@ -165,7 +180,9 @@ doweararm() { return(1); } -dowearring() { +int +dowearring(void) +{ struct obj *otmp; long mask = 0; long oldprop; @@ -234,8 +251,8 @@ dowearring() { return(1); } -ringoff(obj) -struct obj *obj; +void +ringoff(struct obj *obj) { long mask; mask = obj->owornmask & W_RING; @@ -270,7 +287,9 @@ long mask; } } -find_ac(){ +void +find_ac(void) +{ int uac = 10; if(uarm) uac -= ARM_BONUS(uarm); if(uarm2) uac -= ARM_BONUS(uarm2); @@ -285,7 +304,9 @@ int uac = 10; } } -glibr(){ +void +glibr(void) +{ struct obj *otmp; int xfl = 0; if(!uarmg) if(uleft || uright) { @@ -312,7 +333,8 @@ int xfl = 0; } struct obj * -some_armor(){ +some_armor(void) +{ struct obj *otmph = uarm; if(uarmh && (!otmph || !rn2(4))) otmph = uarmh; if(uarmg && (!otmph || !rn2(4))) otmph = uarmg; @@ -320,7 +342,9 @@ struct obj *otmph = uarm; return(otmph); } -corrode_armor(){ +void +corrode_armor(void) +{ struct obj *otmph = some_armor(); if(otmph){ if(otmph->rustfree || diff --git a/games/hack/hack.dog.c b/games/hack/hack.dog.c index 93e41e26e1..b5f97c0b22 100644 --- a/games/hack/hack.dog.c +++ b/games/hack/hack.dog.c @@ -1,13 +1,11 @@ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* hack.dog.c - version 1.0.3 */ /* $FreeBSD: src/games/hack/hack.dog.c,v 1.3 1999/11/16 02:57:03 billf Exp $ */ -/* $DragonFly: src/games/hack/hack.dog.c,v 1.3 2004/11/06 12:29:17 eirikn Exp $ */ +/* $DragonFly: src/games/hack/hack.dog.c,v 1.4 2006/08/21 19:45:32 pavalos Exp $ */ #include "hack.h" #include "hack.mfndpos.h" -extern struct monst *makemon(); #include "def.edog.h" -#include "def.mkroom.h" struct permonst li_dog = { "little dog", 'd',2,18,6,1,6,sizeof(struct edog) }; @@ -16,14 +14,20 @@ struct permonst dog = struct permonst la_dog = { "large dog", 'd',6,15,4,2,4,sizeof(struct edog) }; +static void initedog(struct monst *); +static xchar dogfood(struct obj *); -makedog(){ +void +makedog(void) +{ struct monst *mtmp = makemon(&li_dog,u.ux,u.uy); if(!mtmp) return; /* dogs were genocided */ initedog(mtmp); } -initedog(mtmp) struct monst *mtmp; { +static void +initedog(struct monst *mtmp) +{ mtmp->mtame = mtmp->mpeaceful = 1; EDOG(mtmp)->hungrytime = 1000 + moves; EDOG(mtmp)->eattime = 0; @@ -38,15 +42,17 @@ struct monst *mydogs = 0; struct monst *fallen_down = 0; /* monsters that fell through a trapdoor */ /* they will appear on the next level @ goes to, even if he goes up! */ -losedogs(){ +void +losedogs(void) +{ struct monst *mtmp; - while(mtmp = mydogs){ + while((mtmp = mydogs)){ mydogs = mtmp->nmon; mtmp->nmon = fmon; fmon = mtmp; mnexto(mtmp); } - while(mtmp = fallen_down){ + while((mtmp = fallen_down)){ fallen_down = mtmp->nmon; mtmp->nmon = fmon; fmon = mtmp; @@ -54,7 +60,9 @@ struct monst *mtmp; } } -keepdogs(){ +void +keepdogs(void) +{ struct monst *mtmp; for(mtmp = fmon; mtmp; mtmp = mtmp->nmon) if(dist(mtmp->mx,mtmp->my) < 3 && follower(mtmp) @@ -68,7 +76,9 @@ struct monst *mtmp; } } -fall_down(mtmp) struct monst *mtmp; { +void +fall_down(struct monst *mtmp) +{ relmon(mtmp); mtmp->nmon = fallen_down; fallen_down = mtmp; @@ -84,7 +94,9 @@ fall_down(mtmp) struct monst *mtmp; { #define APPORT 4 #define POISON 5 #define UNDEF 6 -dogfood(obj) struct obj *obj; { +static xchar +dogfood(struct obj *obj) +{ switch(obj->olet) { case FOOD_SYM: return( @@ -106,9 +118,11 @@ dogfood(obj) struct obj *obj; { } /* return 0 (no move), 1 (move) or 2 (dead) */ -dog_move(mtmp, after) struct monst *mtmp; { +int +dog_move(struct monst *mtmp, int after) +{ int nx,ny,omx,omy,appr,nearer,j; -int udist,chi,i,whappr; +int udist,chi = 0,i,whappr; struct monst *mtmp2; struct permonst *mdat = mtmp->data; struct edog *edog = EDOG(mtmp); @@ -154,21 +168,21 @@ int info[9]; /* Note: if apport == 1 then our behaviour is independent of udist */ if(mtmp->minvent){ if(!rn2(udist) || !rn2((int) edog->apport)) - if(rn2(10) < edog->apport){ + if(rn2(10) < (int)edog->apport){ relobj(mtmp, (int) mtmp->minvis); if(edog->apport > 1) edog->apport--; edog->dropdist = udist; /* hpscdi!jon */ edog->droptime = moves; } } else { - if(obj = o_at(omx,omy)) if(!index("0_", obj->olet)){ + if((obj = o_at(omx,omy))) if(!index("0_", obj->olet)){ if((otyp = dogfood(obj)) <= CADAVER){ nix = omx; niy = omy; goto eatobj; } if(obj->owt < 10*mtmp->data->mlevel) - if(rn2(20) < edog->apport+3) + if(rn2(20) < (int)edog->apport+3) if(rn2(udist) || !rn2((int) edog->apport)){ freeobj(obj); unpobj(obj); @@ -181,9 +195,7 @@ int info[9]; /* first we look for food */ gtyp = UNDEF; /* no goal as yet */ -#ifdef LINT gx = gy = 0; /* suppress 'used before set' message */ -#endif /* LINT */ for(obj = fobj; obj; obj = obj->nobj) { otyp = dogfood(obj); if(otyp > gtyp || otyp == UNDEF) continue; @@ -199,7 +211,7 @@ int info[9]; } else if(gtyp == UNDEF && dogroom >= 0 && uroom == dogroom && - !mtmp->minvent && edog->apport > rn2(8)){ + !mtmp->minvent && (int)edog->apport > rn2(8)){ gx = obj->ox; gy = obj->oy; gtyp = APPORT; @@ -255,7 +267,6 @@ int info[9]; if(mtmp->mconf) appr = 0; if(gx == u.ux && gy == u.uy && (dogroom != uroom || dogroom < 0)){ - extern coord *gettrack(); coord *cp; cp = gettrack(omx,omy); if(cp){ @@ -350,7 +361,7 @@ int info[9]; newdogpos: if(nix != omx || niy != omy){ if(info[chi] & ALLOW_U){ - (void) hitu(mtmp, d(mdat->damn, mdat->damd)+1); + hitu(mtmp, d(mdat->damn, mdat->damd)+1); return(0); } mtmp->mx = nix; @@ -366,7 +377,9 @@ newdogpos: } /* return roomnumber or -1 */ -inroom(x,y) xchar x,y; { +int +inroom(xchar x, xchar y) +{ #ifndef QUEST struct mkroom *croom = &rooms[0]; while(croom->hx >= 0){ @@ -379,9 +392,8 @@ inroom(x,y) xchar x,y; { return(-1); /* not in room or on door */ } -tamedog(mtmp, obj) -struct monst *mtmp; -struct obj *obj; +bool +tamedog(struct monst *mtmp, struct obj *obj) { struct monst *mtmp2; @@ -408,7 +420,7 @@ struct obj *obj; mtmp2 = newmonst(sizeof(struct edog) + mtmp->mnamelth); *mtmp2 = *mtmp; mtmp2->mxlth = sizeof(struct edog); - if(mtmp->mnamelth) (void) strcpy(NAME(mtmp2), NAME(mtmp)); + if(mtmp->mnamelth) strcpy(NAME(mtmp2), NAME(mtmp)); initedog(mtmp2); replmon(mtmp,mtmp2); return(1); diff --git a/games/hack/hack.eat.c b/games/hack/hack.eat.c index 1146c7e19d..ff985cacaf 100644 --- a/games/hack/hack.eat.c +++ b/games/hack/hack.eat.c @@ -1,13 +1,16 @@ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* hack.eat.c - version 1.0.3 */ /* $FreeBSD: src/games/hack/hack.eat.c,v 1.4 1999/11/16 10:26:36 marcel Exp $ */ -/* $DragonFly: src/games/hack/hack.eat.c,v 1.4 2005/05/22 03:37:05 y0netan1 Exp $ */ +/* $DragonFly: src/games/hack/hack.eat.c,v 1.5 2006/08/21 19:45:32 pavalos Exp $ */ #include "hack.h" char POISONOUS[] = "ADKSVabhks"; -extern int (*afternmv)(); -extern int (*occupation)(); -extern struct obj *splitobj(), *addinv(); + +static bool opentin(void); +static void Meatdone(void); +static void unfaint(void); +static void newuhs(bool); +static int eatcorpse(struct obj *); /* hunger texts used on bottom line (each 8 chars long) */ #define SATIATED 0 @@ -28,19 +31,21 @@ const char *hu_stat[] = { "Starved " }; -init_uhunger(){ +void +init_uhunger(void) +{ u.uhunger = 900; u.uhs = NOT_HUNGRY; } #define TTSZ SIZE(tintxts) struct { const char *txt; int nut; } tintxts[] = { - "It contains first quality peaches - what a surprise!", 40, - "It contains salmon - not bad!", 60, - "It contains apple juice - perhaps not what you hoped for.", 20, - "It contains some nondescript substance, tasting awfully.", 500, - "It contains rotten meat. You vomit.", -50, - "It turns out to be empty.", 0 + { "It contains first quality peaches - what a surprise!", 40 }, + { "It contains salmon - not bad!", 60 }, + { "It contains apple juice - perhaps not what you hoped for.", 20 }, + { "It contains some nondescript substance, tasting awfully.", 500 }, + { "It contains rotten meat. You vomit.", -50 }, + { "It turns out to be empty.", 0 } }; static struct { @@ -48,7 +53,9 @@ static struct { int usedtime, reqtime; } tin; -opentin(){ +static bool +opentin(void) +{ int r; if(!carried(tin.tin)) /* perhaps it was stolen? */ @@ -81,12 +88,16 @@ opentin(){ return(0); } -Meatdone(){ +static void +Meatdone(void) +{ u.usym = '@'; prme(); } -doeat(){ +int +doeat(void) +{ struct obj *otmp; struct objclass *ftmp; int tmp; @@ -102,7 +113,7 @@ doeat(){ (otmp->quan == 1) ? "it" : "one"); if(readchar() == 'y') { if(otmp->quan != 1) - (void) splitobj(otmp, 1); + splitobj(otmp, 1); freeobj(otmp); otmp = addinv(otmp); addtobill(otmp); @@ -139,7 +150,6 @@ gotit: pline("The tin slips out of your hands."); if(otmp->quan > 1) { struct obj *obj; - extern struct obj *splitobj(); obj = splitobj(otmp, 1); if(otmp == uwep) setuwep(obj); @@ -250,7 +260,7 @@ gotit: eatx: if(multi<0 && !nomovemsg){ static char msgbuf[BUFSZ]; - (void) sprintf(msgbuf, "You finished eating the %s.", + sprintf(msgbuf, "You finished eating the %s.", ftmp->oc_name); nomovemsg = msgbuf; } @@ -259,7 +269,9 @@ eatx: } /* called in hack.main.c */ -gethungry(){ +void +gethungry(void) +{ --u.uhunger; if(moves % 2) { if(Regeneration) u.uhunger--; @@ -276,23 +288,31 @@ gethungry(){ } /* called after vomiting and after performing feats of magic */ -morehungry(num) int num; { +void +morehungry(int num) +{ u.uhunger -= num; newuhs(TRUE); } /* called after eating something (and after drinking fruit juice) */ -lesshungry(num) int num; { +void +lesshungry(int num) +{ u.uhunger += num; newuhs(FALSE); } -unfaint(){ +static void +unfaint(void) +{ u.uhs = FAINTING; flags.botl = 1; } -newuhs(incr) boolean incr; { +static void +newuhs(bool incr) +{ int newhs, h = u.uhunger; newhs = (h > 1000) ? SATIATED : @@ -352,14 +372,16 @@ newuhs(incr) boolean incr; { #define CORPSE_I_TO_C(otyp) (char) ((otyp >= DEAD_ACID_BLOB)\ ? 'a' + (otyp - DEAD_ACID_BLOB)\ : '@' + (otyp - DEAD_HUMAN)) -poisonous(otmp) -struct obj *otmp; +bool +poisonous(struct obj *otmp) { return(index(POISONOUS, CORPSE_I_TO_C(otmp->otyp)) != 0); } /* returns 1 if some text was printed */ -eatcorpse(otmp) struct obj *otmp; { +static int +eatcorpse(struct obj *otmp) +{ char let = CORPSE_I_TO_C(otmp->otyp); int tp = 0; if(let != 'a' && moves > otmp->age + 50 + rn2(100)) { diff --git a/games/hack/hack.end.c b/games/hack/hack.end.c index 315225e8cf..5a96e476dc 100644 --- a/games/hack/hack.end.c +++ b/games/hack/hack.end.c @@ -1,27 +1,49 @@ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* hack.end.c - version 1.0.3 */ /* $FreeBSD: src/games/hack/hack.end.c,v 1.4 1999/11/16 10:26:36 marcel Exp $ */ -/* $DragonFly: src/games/hack/hack.end.c,v 1.4 2005/05/22 03:37:05 y0netan1 Exp $ */ +/* $DragonFly: src/games/hack/hack.end.c,v 1.5 2006/08/21 19:45:32 pavalos Exp $ */ #include "hack.h" -#include -#include #define Sprintf (void) sprintf -extern char plname[], pl_character[]; -extern char *itoa(), *eos(); -static const char *ordin(int); + +#define newttentry() (struct toptenentry *) alloc(sizeof(struct toptenentry)) +#define NAMSZ 8 +#define DTHSZ 40 +#define PERSMAX 1 +#define POINTSMIN 1 /* must be > 0 */ +#define ENTRYMAX 100 /* must be >= 10 */ +#define PERS_IS_UID /* delete for PERSMAX per name; now per uid */ +struct toptenentry { + struct toptenentry *tt_next; + long int points; + int level,maxlvl,hp,maxhp; + int uid; + char plchar; + char sex; + char name[NAMSZ+1]; + char death[DTHSZ+1]; + char date[7]; /* yymmdd */ +} *tt_head; + +static void done_intr(int); +static void done_hangup(int); +static void topten(void); +static void outheader(void); +static int outentry(int, struct toptenentry *, int); +static char *itoa(int); +static const char *ordin(int); xchar maxdlevel = 1; void -done1() +done1(__unused int unused) { - (void) signal(SIGINT,SIG_IGN); + signal(SIGINT,SIG_IGN); pline("Really quit?"); if(readchar() != 'y') { - (void) signal(SIGINT,done1); + signal(SIGINT,done1); clrlin(); - (void) fflush(stdout); + fflush(stdout); if(multi > 0) nomul(0); return; } @@ -32,21 +54,25 @@ done1() int done_stopprint; int done_hup; -void -done_intr(){ +static void +done_intr(__unused int unused) +{ done_stopprint++; - (void) signal(SIGINT, SIG_IGN); - (void) signal(SIGQUIT, SIG_IGN); + signal(SIGINT, SIG_IGN); + signal(SIGQUIT, SIG_IGN); } -void -done_hangup(){ +static void +done_hangup(__unused int unused) +{ done_hup++; - (void) signal(SIGHUP, SIG_IGN); - done_intr(); + signal(SIGHUP, SIG_IGN); + done_intr(0); } -done_in_by(mtmp) struct monst *mtmp; { +void +done_in_by(struct monst *mtmp) +{ static char buf[BUFSZ]; pline("You die ..."); if(mtmp->data->mlet == ' '){ @@ -82,9 +108,9 @@ done(const char *st1) return; } #endif /* WIZARD */ - (void) signal(SIGINT, done_intr); - (void) signal(SIGQUIT, done_intr); - (void) signal(SIGHUP, done_hangup); + signal(SIGINT, done_intr); + signal(SIGQUIT, done_intr); + signal(SIGHUP, done_hangup); if(*st1 == 'q' && u.uhp < 1){ st1 = "died"; killer = "quit while already on Charon's boat"; @@ -121,7 +147,6 @@ done(const char *st1) u.urexp += 1000*((maxdlevel > 30) ? 10 : maxdlevel - 20); } if(*st1 == 'e') { - extern struct monst *mydogs; struct monst *mtmp; struct obj *otmp; int i; @@ -198,26 +223,9 @@ done(const char *st1) exit(0); } -#define newttentry() (struct toptenentry *) alloc(sizeof(struct toptenentry)) -#define NAMSZ 8 -#define DTHSZ 40 -#define PERSMAX 1 -#define POINTSMIN 1 /* must be > 0 */ -#define ENTRYMAX 100 /* must be >= 10 */ -#define PERS_IS_UID /* delete for PERSMAX per name; now per uid */ -struct toptenentry { - struct toptenentry *tt_next; - long int points; - int level,maxlvl,hp,maxhp; - int uid; - char plchar; - char sex; - char name[NAMSZ+1]; - char death[DTHSZ+1]; - char date[7]; /* yymmdd */ -} *tt_head; - -topten(){ +static void +topten(void) +{ int uid = getuid(); int rank, rank0 = -1, rank1 = 0; int occ_cnt = PERSMAX; @@ -227,7 +235,6 @@ topten(){ int sleepct = 300; FILE *rfile; int flg = 0; - extern char *getdate(); #define HUP if(!done_hup) while(link(recfile, reclock) == -1) { HUP perror(reclock); @@ -238,14 +245,14 @@ topten(){ } HUP printf("Waiting for access to record file. (%d)\n", sleepct); - HUP (void) fflush(stdout); + HUP fflush(stdout); sleep(1); } if(!(rfile = fopen(recfile,"r"))){ HUP puts("Cannot open record file!"); goto unlock; } - HUP (void) putchar('\n'); + HUP putchar('\n'); /* create a new 'topten' entry */ t0 = newttentry(); @@ -257,11 +264,11 @@ topten(){ t0->plchar = pl_character[0]; t0->sex = (flags.female ? 'F' : 'M'); t0->uid = uid; - (void) strncpy(t0->name, plname, NAMSZ); + strncpy(t0->name, plname, NAMSZ); (t0->name)[NAMSZ] = 0; - (void) strncpy(t0->death, killer, DTHSZ); + strncpy(t0->death, killer, DTHSZ); (t0->death)[DTHSZ] = 0; - (void) strcpy(t0->date, getdate()); + strcpy(t0->date, getdate()); /* assure minimum number of points */ if(t0->points < POINTSMIN) @@ -318,7 +325,7 @@ topten(){ } } if(flg) { /* rewrite record file */ - (void) fclose(rfile); + fclose(rfile); if(!(rfile = fopen(recfile,"w"))){ HUP puts("Cannot write record file\n"); goto unlock; @@ -343,8 +350,8 @@ topten(){ t1->hp, t1->maxhp, t1->points, t1->plchar, t1->sex, t1->name, t1->death); if(done_stopprint) continue; - if(rank > flags.end_top && - (rank < rank0-flags.end_around || rank > rank0+flags.end_around) + if(rank > (int)flags.end_top && + (rank < rank0-(int)flags.end_around || rank > rank0+(int)flags.end_around) && (!flags.end_own || #ifdef PERS_IS_UID t1->uid != t0->uid )) @@ -352,42 +359,45 @@ topten(){ strncmp(t1->name, t0->name, NAMSZ))) #endif /* PERS_IS_UID */ continue; - if(rank == rank0-flags.end_around && - rank0 > flags.end_top+flags.end_around+1 && + if(rank == rank0-(int)flags.end_around && + rank0 > (int)flags.end_top+(int)flags.end_around+1 && !flags.end_own) - (void) putchar('\n'); + putchar('\n'); if(rank != rank0) - (void) outentry(rank, t1, 0); + outentry(rank, t1, 0); else if(!rank1) - (void) outentry(rank, t1, 1); + outentry(rank, t1, 1); else { int t0lth = outentry(0, t0, -1); int t1lth = outentry(rank, t1, t0lth); if(t1lth > t0lth) t0lth = t1lth; - (void) outentry(0, t0, t0lth); + outentry(0, t0, t0lth); } } if(rank0 >= rank) if(!done_stopprint) - (void) outentry(0, t0, 1); - (void) fclose(rfile); + outentry(0, t0, 1); + fclose(rfile); unlock: - (void) unlink(reclock); + unlink(reclock); } -outheader() { +static void +outheader(void) +{ char linebuf[BUFSZ]; char *bp; - (void) strcpy(linebuf, "Number Points Name"); + strcpy(linebuf, "Number Points Name"); bp = eos(linebuf); while(bp < linebuf + COLNO - 9) *bp++ = ' '; - (void) strcpy(bp, "Hp [max]"); + strcpy(bp, "Hp [max]"); puts(linebuf); } /* so>0: standout line; so=0: ordinary line; so<0: no output, return lth */ -int -outentry(rank,t1,so) struct toptenentry *t1; { -boolean quit = FALSE, killed = FALSE, starv = FALSE; +static int +outentry(int rank, struct toptenentry *t1, int so) +{ +boolean quit = FALSE, dead = FALSE, starv = FALSE; char linebuf[BUFSZ]; linebuf[0] = 0; if(rank) Sprintf(eos(linebuf), "%3d", rank); @@ -414,14 +424,14 @@ char linebuf[BUFSZ]; (t1->sex == 'F') ? "her" : "his"); else if(!strncmp(t1->death,"starv",5)) Sprintf(eos(linebuf), "starved to death"), starv = TRUE; - else Sprintf(eos(linebuf), "was killed"), killed = TRUE; + else Sprintf(eos(linebuf), "was killed"), dead = TRUE; Sprintf(eos(linebuf), " on%s level %d", - (killed || starv) ? "" : " dungeon", t1->level); + (dead || starv) ? "" : " dungeon", t1->level); if(t1->maxlvl != t1->level) Sprintf(eos(linebuf), " [max %d]", t1->maxlvl); if(quit && t1->death[4]) Sprintf(eos(linebuf), t1->death + 4); } - if(killed) Sprintf(eos(linebuf), " by %s%s", + if(dead) Sprintf(eos(linebuf), " by %s%s", (!strncmp(t1->death, "trick", 5) || !strncmp(t1->death, "the ", 4)) ? "" : index(vowels,*t1->death) ? "an " : "a ", @@ -435,7 +445,7 @@ char linebuf[BUFSZ]; hppos = COLNO - 7 - strlen(hpbuf); if(bp <= linebuf + hppos) { while(bp < linebuf + hppos) *bp++ = ' '; - (void) strcpy(bp, hpbuf); + strcpy(bp, hpbuf); Sprintf(eos(bp), " [%d]", t1->maxhp); } } @@ -448,13 +458,14 @@ char linebuf[BUFSZ]; standoutbeg(); fputs(linebuf,stdout); standoutend(); - (void) putchar('\n'); + putchar('\n'); } return(strlen(linebuf)); } -char * -itoa(a) int a; { +static char * +itoa(int a) +{ static char buf[12]; Sprintf(buf,"%d",a); return(buf); @@ -463,39 +474,43 @@ static char buf[12]; static const char * ordin(int n) { - int d = n % 10; - return((d==0 || d>3 || n/10==1) ? "th" : (d==1) ? "st" : - (d==2) ? "nd" : "rd"); + int d1 = n % 10; + return((d1==0 || d1>3 || n/10==1) ? "th" : (d1==1) ? "st" : + (d1==2) ? "nd" : "rd"); } -clearlocks(){ +void +clearlocks(void) +{ int x; - (void) signal(SIGHUP,SIG_IGN); + signal(SIGHUP,SIG_IGN); for(x = maxdlevel; x >= 0; x--) { glo(x); - (void) unlink(lock); /* not all levels need be present */ + unlink(lock); /* not all levels need be present */ } } #ifdef NOSAVEONHANGUP -hangup() +void +hangup(__unused int unused) { - (void) signal(SIGINT, SIG_IGN); + signal(SIGINT, SIG_IGN); clearlocks(); exit(1); } #endif /* NOSAVEONHANGUP */ char * -eos(s) -char *s; +eos(char *s) { while(*s) s++; return(s); } /* it is the callers responsibility to check that there is room for c */ -charcat(s,c) char *s, c; { +void +charcat(char *s, char c) +{ while(*s) s++; *s++ = c; *s = 0; @@ -506,9 +521,10 @@ charcat(s,c) char *s, c; { * requested. Otherwise, find scores for the current player (and list them * if argc == -1). */ -prscore(argc,argv) int argc; char **argv; { - extern char *hname; - char **players; +void +prscore(int argc, char **argv) +{ + char **players = NULL; int playerct; int rank; struct toptenentry *t1, *t2; @@ -584,7 +600,7 @@ prscore(argc,argv) int argc; char **argv; { } t1 = t1->tt_next = newttentry(); } - (void) fclose(rfile); + fclose(rfile); if(!flg) { if(outflg) { printf("Cannot find any entries for "); @@ -617,7 +633,7 @@ prscore(argc,argv) int argc; char **argv; { (digit(players[i][0]) && rank <= atoi(players[i]))){ outwithit: if(outflg) - (void) outentry(rank, t1, 0); + outentry(rank, t1, 0); #ifdef nonsense total_score += t1->points; if(totcharct < sizeof(totchars)-1) diff --git a/games/hack/hack.engrave.c b/games/hack/hack.engrave.c index 21a8fa6a8e..5e5121d3f9 100644 --- a/games/hack/hack.engrave.c +++ b/games/hack/hack.engrave.c @@ -1,7 +1,7 @@ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* hack.engrave.c - version 1.0.3 */ /* $FreeBSD: src/games/hack/hack.engrave.c,v 1.4 1999/11/16 02:57:04 billf Exp $ */ -/* $DragonFly: src/games/hack/hack.engrave.c,v 1.3 2005/05/22 03:37:05 y0netan1 Exp $ */ +/* $DragonFly: src/games/hack/hack.engrave.c,v 1.4 2006/08/21 19:45:32 pavalos Exp $ */ #include "hack.h" @@ -19,8 +19,12 @@ struct engr { #define BURN 3 } *head_engr; -struct engr * -engr_at(x,y) xchar x,y; { +static struct engr *engr_at(xchar, xchar); +static void del_engr(struct engr *); + +static struct engr * +engr_at(xchar x, xchar y) +{ struct engr *ep = head_engr; while(ep) { if(x == ep->engr_x && y == ep->engr_y) @@ -30,15 +34,14 @@ struct engr *ep = head_engr; return((struct engr *) 0); } -sengr_at(s,x,y) char *s; xchar x,y; { +bool +sengr_at(const char *s, xchar x, xchar y) +{ struct engr *ep = engr_at(x,y); char *t; int n; if(ep && ep->engr_time <= moves) { t = ep->engr_txt; -/* - if(!strcmp(s,t)) return(1); -*/ n = strlen(s); while(*t) { if(!strncmp(s,t,n)) return(1); @@ -48,14 +51,16 @@ int n; return(0); } -u_wipe_engr(cnt) -int cnt; +void +u_wipe_engr(int cnt) { if(!u.uswallow && !Levitation) wipe_engr_at(u.ux, u.uy, cnt); } -wipe_engr_at(x,y,cnt) xchar x,y,cnt; { +void +wipe_engr_at(xchar x, xchar y, xchar cnt) +{ struct engr *ep = engr_at(x,y); int lth,pos; char ch; @@ -80,7 +85,9 @@ char ch; } } -read_engr_at(x,y) int x,y; { +void +read_engr_at(int x, int y) +{ struct engr *ep = engr_at(x,y); if(ep && ep->engr_txt[0]) { switch(ep->engr_type) { @@ -100,13 +107,12 @@ struct engr *ep = engr_at(x,y); } } -make_engr_at(x,y,s) -int x,y; -char *s; +void +make_engr_at(int x, int y, const char *s) { struct engr *ep; - if(ep = engr_at(x,y)) + if((ep = engr_at(x,y))) del_engr(ep); ep = (struct engr *) alloc((unsigned)(sizeof(struct engr) + strlen(s) + 1)); @@ -115,13 +121,15 @@ char *s; ep->engr_x = x; ep->engr_y = y; ep->engr_txt = (char *)(ep + 1); - (void) strcpy(ep->engr_txt, s); + strcpy(ep->engr_txt, s); ep->engr_time = 0; ep->engr_type = DUST; ep->engr_lth = strlen(s) + 1; } -doengrave(){ +int +doengrave(void) +{ int len; char *sp; struct engr *ep, *oep = engr_at(u.ux,u.uy); @@ -243,11 +251,11 @@ struct obj *otmp; sp = (char *)(ep + 1); /* (char *)ep + sizeof(struct engr) */ ep->engr_txt = sp; if(oep) { - (void) strcpy(sp, oep->engr_txt); - (void) strcat(sp, buf); + strcpy(sp, oep->engr_txt); + strcat(sp, buf); del_engr(oep); } else - (void) strcpy(sp, buf); + strcpy(sp, buf); ep->engr_lth = len+1; ep->engr_type = type; ep->engr_time = moves-multi; @@ -258,7 +266,9 @@ struct obj *otmp; return(1); } -save_engravings(fd) int fd; { +void +save_engravings(int fd) +{ struct engr *ep = head_engr; while(ep) { if(!ep->engr_lth || !ep->engr_txt[0]){ @@ -273,7 +283,9 @@ struct engr *ep = head_engr; head_engr = 0; } -rest_engravings(fd) int fd; { +void +rest_engravings(int fd) +{ struct engr *ep; unsigned lth; head_engr = 0; @@ -288,7 +300,9 @@ unsigned lth; } } -del_engr(ep) struct engr *ep; { +static void +del_engr(struct engr *ep) +{ struct engr *ept; if(ep == head_engr) head_engr = ep->nxt_engr; diff --git a/games/hack/hack.fight.c b/games/hack/hack.fight.c index 306c058ffb..23cd22de12 100644 --- a/games/hack/hack.fight.c +++ b/games/hack/hack.fight.c @@ -1,20 +1,22 @@ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* hack.fight.c - version 1.0.3 */ /* $FreeBSD: src/games/hack/hack.fight.c,v 1.5 1999/11/16 10:26:36 marcel Exp $ */ -/* $DragonFly: src/games/hack/hack.fight.c,v 1.4 2005/05/22 03:37:05 y0netan1 Exp $ */ +/* $DragonFly: src/games/hack/hack.fight.c,v 1.5 2006/08/21 19:45:32 pavalos Exp $ */ #include "hack.h" extern struct permonst li_dog, dog, la_dog; -extern char *xname(); -extern struct obj *mkobj_at(); static boolean far_noise; static long noisetime; +static void monstone(struct monst *); + /* hitmm returns 0 (miss), 1 (hit), or 2 (kill) */ -hitmm(magr,mdef) struct monst *magr,*mdef; { +int +hitmm(struct monst *magr, struct monst *mdef) +{ struct permonst *pa = magr->data, *pd = mdef->data; -int hit; +int ht; schar tmp; boolean vis; if(index("Eauy", pa->mlet)) return(0); @@ -24,15 +26,15 @@ boolean vis; tmp += 4; if(mdef->msleep) mdef->msleep = 0; } - hit = (tmp > rnd(20)); - if(hit) mdef->msleep = 0; + ht = (tmp > rnd(20)); + if(ht) mdef->msleep = 0; vis = (cansee(magr->mx,magr->my) && cansee(mdef->mx,mdef->my)); if(vis){ char buf[BUFSZ]; if(mdef->mimic) seemimic(mdef); if(magr->mimic) seemimic(magr); - (void) sprintf(buf,"%s %s", Monnam(magr), - hit ? "hits" : "misses"); + sprintf(buf,"%s %s", Monnam(magr), + ht ? "hits" : "misses"); pline("%s %s.", buf, monnam(mdef)); } else { boolean far = (dist(magr->mx, magr->my) > 15); @@ -43,14 +45,14 @@ boolean vis; far ? " in the distance" : ""); } } - if(hit){ + if(ht){ if(magr->data->mlet == 'c' && !magr->cham) { magr->mhpmax += 3; if(vis) pline("%s is turned to stone!", Monnam(mdef)); else if(mdef->mtame) pline("You have a peculiarly sad feeling for a moment, then it passes."); monstone(mdef); - hit = 2; + ht = 2; } else if((mdef->mhp -= d(pa->damn,pa->damd)) < 1) { magr->mhpmax += 1 + rn2(pd->mlevel+1); @@ -62,17 +64,19 @@ boolean vis; else if(mdef->mtame) pline("You have a sad feeling for a moment, then it passes."); mondied(mdef); - hit = 2; + ht = 2; } } - return(hit); + return(ht); } /* drop (perhaps) a cadaver and remove monster */ -mondied(mdef) struct monst *mdef; { +void +mondied(struct monst *mdef) +{ struct permonst *pd = mdef->data; if(letter(pd->mlet) && rn2(3)){ - (void) mkobj_at(pd->mlet,mdef->mx,mdef->my); + mkobj_at(pd->mlet,mdef->mx,mdef->my); if(cansee(mdef->mx,mdef->my)){ unpmon(mdef); atl(mdef->mx,mdef->my,fobj->olet); @@ -83,8 +87,9 @@ struct permonst *pd = mdef->data; } /* drop a rock and remove monster */ -monstone(mdef) struct monst *mdef; { - extern char mlarge[]; +static void +monstone(struct monst *mdef) +{ if(index(mlarge, mdef->data->mlet)) mksobj_at(ENORMOUS_ROCK, mdef->mx, mdef->my); else @@ -96,8 +101,9 @@ monstone(mdef) struct monst *mdef; { mondead(mdef); } - -fightm(mtmp) struct monst *mtmp; { +int +fightm(struct monst *mtmp) +{ struct monst *mon; for(mon = fmon; mon; mon = mon->nmon) if(mon != mtmp) { if(DIST(mon->mx,mon->my,mtmp->mx,mtmp->my) < 3) @@ -108,9 +114,8 @@ struct monst *mon; } /* u is hit by sth, but not a monster */ -thitu(tlev,dam,name) -int tlev,dam; -char *name; +bool +thitu(int tlev, int dam, const char *name) { char buf[BUFSZ]; setan(name,buf); @@ -128,14 +133,12 @@ char buf[BUFSZ]; char mlarge[] = "bCDdegIlmnoPSsTUwY',&"; -boolean -hmon(mon,obj,thrown) /* return TRUE if mon still alive */ -struct monst *mon; -struct obj *obj; -int thrown; +/* return TRUE if mon still alive */ +bool +hmon(struct monst *mon, struct obj *obj, int thrown) { int tmp; - boolean hittxt = FALSE; + bool hittxt = FALSE; if(!obj){ tmp = rnd(2); /* attack with bare hands */ @@ -249,8 +252,8 @@ int thrown; /* try to attack; return FALSE if monster evaded */ /* u.dx and u.dy must be set */ -attack(mtmp) -struct monst *mtmp; +bool +attack(struct monst *mtmp) { schar tmp; boolean malive = TRUE; diff --git a/games/hack/hack.h b/games/hack/hack.h index 8e63ae8d52..598c57685d 100644 --- a/games/hack/hack.h +++ b/games/hack/hack.h @@ -1,9 +1,16 @@ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* hack.h - version 1.0.3 */ -/* $DragonFly: src/games/hack/hack.h,v 1.3 2005/05/22 03:37:05 y0netan1 Exp $ */ +/* $DragonFly: src/games/hack/hack.h,v 1.4 2006/08/21 19:45:32 pavalos Exp $ */ #include "config.h" +#include +#include +#include +#include +#include +#include #include +#include #ifndef BSD #define index strchr @@ -23,6 +30,8 @@ typedef struct { #include "def.trap.h" #include "def.obj.h" #include "def.flag.h" +#include "def.mkroom.h" +#include "def.wseg.h" #define plur(x) (((x) == 1) ? "" : "s") @@ -32,11 +41,8 @@ typedef struct { #include "def.rm.h" #include "def.permonst.h" -extern long *alloc(); - extern xchar xdnstair, ydnstair, xupstair, yupstair; /* stairs up and down. */ -extern xchar dlevel; #define newstring(x) (char *) alloc((unsigned)(x)) #include "hack.onames.h" @@ -47,7 +53,6 @@ extern struct obj *invent, *uwep, *uarm, *uarm2, *uarmh, *uarms, *uarmg, *uleft, *uright, *fcobj; extern struct obj *uchain; /* defined iff PUNISHED */ extern struct obj *uball; /* defined if PUNISHED */ -struct obj *o_at(), *getobj(), *sobj_at(); struct prop { #define TIMEOUT 007777 /* mask */ @@ -58,7 +63,7 @@ struct prop { #define RIGHT_SIDE RIGHT_RING #define BOTH_SIDES (LEFT_SIDE | RIGHT_SIDE) long p_flgs; - int (*p_tofn)(); /* called after timeout */ + void (*p_tofn)(void); /* called after timeout */ }; struct you { @@ -131,9 +136,6 @@ struct you { extern struct you u; extern const char *traps[]; -extern char *monnam(), *Monnam(), *amonnam(), *Amonnam(), - *doname(), *aobjnam(); -extern char readchar(); extern char vowels[]; extern xchar curx,cury; /* cursor location on screen */ @@ -149,19 +151,564 @@ extern long moves; extern int multi; - extern char lock[]; extern const char *occtxt; extern const char *hu_stat[]; -const char *exclam(int); -void gethdate(const char *); -void done(const char *); - #define DIST(x1,y1,x2,y2) (((x1)-(x2))*((x1)-(x2)) + ((y1)-(y2))*((y1)-(y2))) #define PL_CSIZ 20 /* sizeof pl_character */ #define MAX_CARR_CAP 120 /* so that boulders can be heavier */ #define MAXLEVEL 40 #define FAR (COLNO+2) /* position outside screen */ + +extern schar xdir[], ydir[]; +extern int hackpid, locknum, doorindex, done_stopprint; +extern char mlarge[], pl_character[PL_CSIZ], genocided[60], fut_geno[60]; +extern char *hname, morc, plname[PL_NSIZ], sdir[]; +extern boolean level_exists[], restoring, in_mklev; +extern struct permonst pm_eel, pm_ghost; +extern void (*afternmv)(void); +extern struct monst *mydogs; +extern bool (*occupation)(void); + +/* Non-static function prototypes */ + +/* alloc.c */ +void *alloc(size_t); + +/* hack.apply.c */ +int doapply(void); +int holetime(void); +void dighole(void); + +/* hack.bones.c */ +void savebones(void); +int getbones(void); + +/* hack.c */ +void unsee(void); +void seeoff(bool); +void domove(void); +int dopickup(void); +void pickup(int); +void lookaround(void); +bool monster_nearby(void); +bool cansee(xchar, xchar); +int sgn(int); +void setsee(void); +void nomul(int); +int abon(void); +int dbon(void); +void losestr(int); +void losehp(int, const char *); +void losehp_m(int, struct monst *); +void losexp(void); +int inv_weight(void); +long newuexp(void); + +/* hack.cmd.c */ +void rhack(const char *); +bool movecmd(char); +bool getdir(bool); +void confdir(void); +#ifdef QUEST +void finddir(void); +#endif +bool isok(int, int); + +/* hack.do.c */ +int dodrop(void); +void dropx(struct obj *); +int doddrop(void); +int dodown(void); +int doup(void); +void goto_level(int, bool); +int donull(void); +int dopray(void); +int dothrow(void); +struct obj *splitobj(struct obj *, int); +void more_experienced(int, int); +void set_wounded_legs(long, int); +void heal_legs(void); + +/* hack.do_name.c */ +coord getpos(int, const char *); +int do_mname(void); +int ddocall(void); +void docall(struct obj *); +char *monnam(struct monst *); +char *Monnam(struct monst *); +char *amonnam(struct monst *, const char *); +char *Amonnam(struct monst *, const char *); +char *Xmonnam(struct monst *); + +/* hack.do_wear.c */ +int doremarm(void); +int doremring(void); +bool armoroff(struct obj *); +int doweararm(void); +int dowearring(void); +void ringoff(struct obj *); +void find_ac(void); +void glibr(void); +struct obj *some_armor(void); +void corrode_armor(void); + +/* hack.dog.c */ +void makedog(void); +void losedogs(void); +void keepdogs(void); +void fall_down(struct monst *); +int dog_move(struct monst *, int); +int inroom(xchar, xchar); +bool tamedog(struct monst *, struct obj *); + +/* hack.eat.c */ +void init_uhunger(void); +int doeat(void); +void gethungry(void); +void morehungry(int); +void lesshungry(int); +bool poisonous(struct obj *); + +/* hack.end.c */ +void done1(int); +void done_in_by(struct monst *); +void done(const char *); +void clearlocks(void); +#ifdef NOSAVEONHANGUP +void hangup(int); +#endif +char *eos(char *); +void charcat(char *, char); +void prscore(int, char **); + +/* hack.engrave.c */ +bool sengr_at(const char *, xchar, xchar); +void u_wipe_engr(int); +void wipe_engr_at(xchar, xchar, xchar); +void read_engr_at(int, int); +void make_engr_at(int, int, const char *); +int doengrave(void); +void save_engravings(int); +void rest_engravings(int); + +/* hack.fight.c */ +int hitmm(struct monst *, struct monst *); +void mondied(struct monst *); +int fightm(struct monst *); +bool thitu(int, int, const char *); +bool hmon(struct monst *, struct obj *, int); +bool attack(struct monst *); + +/* hack.invent.c */ +struct obj *addinv(struct obj *); +void useup(struct obj *); +void freeinv(struct obj *); +void delobj(struct obj *); +void freeobj(struct obj *); +void freegold(struct gold *); +void deltrap(struct trap *); +struct monst *m_at(int, int); +struct obj *o_at(int, int); +struct obj *sobj_at(int, int, int); +bool carried(struct obj *); +bool carrying(int); +struct obj *o_on(unsigned int, struct obj *); +struct trap *t_at(int, int); +struct gold *g_at(int, int); +struct obj *getobj(const char *, const char *); +int ggetobj(const char *, int (*)(struct obj *), int); +int askchain(struct obj *, char *, int, int (*)(struct obj *), + bool (*)(struct obj *), int); +void prinv(struct obj *); +int ddoinv(void); +int dotypeinv(void); +int dolook(void); +void stackobj(struct obj *); +int doprgold(void); +int doprwep(void); +int doprarm(void); +int doprring(void); +bool digit(char); + +/* hack.ioctl.c */ +void getioctls(void); +void setioctls(void); +#ifdef SUSPEND +int dosuspend(void); +#endif + +/* hack.lev.c */ +void savelev(int, xchar); +void bwrite(int, char *, unsigned int); +void saveobjchn(int, struct obj *); +void savemonchn(int, struct monst *); +void getlev(int, int, xchar); +void mread(int, char *, unsigned int); +void mklev(void); + +/* hack.main.c */ +void glo(int); +void askname(void); +void impossible(const char *, ...); +void stop_occupation(void); + +/* hack.makemon.c */ +struct monst *makemon(struct permonst *, int, int); +coord enexto(xchar, xchar); +bool goodpos(int, int); +void rloc(struct monst *); +struct monst *mkmon_at(char, int, int); + +/* hack.mhitu.c */ +bool mhitu(struct monst *); +bool hitu(struct monst *, int); + +/* hack.mklev.c */ +void makelevel(void); +void mktrap(int, int, struct mkroom *); + +/* hack.mkmaze.c */ +void makemaz(void); +coord mazexy(void); + +/* hack.mkobj.c */ +struct obj *mkobj_at(int, int, int); +void mksobj_at(int, int, int); +struct obj *mkobj(int); +struct obj *mksobj(int); +bool letter(char); +int weight(struct obj *); +void mkgold(long, int, int); + +/* hack.mkshop.c */ +#ifndef QUEST +void mkshop(void); +void mkzoo(int); +void mkswamp(void); +#endif + +/* hack.mon.c */ +void movemon(void); +void justswld(struct monst *, const char *); +void youswld(struct monst *, int, int, const char *); +bool dochug(struct monst *); +int m_move(struct monst *, int); +int mfndpos(struct monst *, coord *, int *, int); +int dist(int, int); +void poisoned(const char *, const char *); +void mondead(struct monst *); +void replmon(struct monst *, struct monst *); +void relmon(struct monst *); +void monfree(struct monst *); +void unstuck(struct monst *); +void killed(struct monst *); +void kludge(const char *, const char *); +void rescham(void); +bool newcham(struct monst *, struct permonst *); +void mnexto(struct monst *); +void setmangry(struct monst *); +bool canseemon(struct monst *); + +/* hack.o_init.c */ +int letindex(char); +void init_objects(void); +int probtype(char); +void oinit(void); +void savenames(int); +void restnames(int); +int dodiscovered(void); + +/* hack.objnam.c */ +char *typename(int); +char *xname(struct obj *); +char *doname(struct obj *); +void setan(const char *, char *); +char *aobjnam(struct obj *, const char *); +char *Doname(struct obj *); +struct obj *readobjnam(char *); + +/* hack.options.c */ +void initoptions(void); +int doset(void); + +/* hack.pager.c */ +int dowhatis(void); +void set_whole_screen(void); +#ifdef NEWS +bool readnews(void); +#endif +void set_pager(int); +bool page_line(const char *); +void cornline(int, const char *); +int dohelp(void); +bool page_file(const char *, bool); +#ifdef UNIX +#ifdef SHELL +int dosh(void); +#endif /* SHELL */ +bool child(bool); +#endif /* UNIX */ + +/* hack.potion.c */ +int dodrink(void); +void pluslvl(void); +void strange_feeling(struct obj *, const char *); +void potionhit(struct monst *, struct obj *); +void potionbreathe(struct obj *); +int dodip(void); + +/* hack.pri.c */ +void swallowed(void); +void panic(const char *, ...); +void atl(int, int, char); +void on_scr(int, int); +void tmp_at(schar, schar); +void Tmp_at(schar, schar); +void setclipped(void); +void at(xchar, xchar, char); +void prme(void); +int doredraw(void); +void docrt(void); +void docorner(int, int); +void curs_on_u(void); +void pru(void); +void prl(int, int); +char news0(xchar, xchar); +void newsym(int, int); +void mnewsym(int, int); +void nosee(int, int); +#ifndef QUEST +void prl1(int, int); +void nose1(int, int); +#endif +bool vism_at(int, int); +void unpobj(struct obj *); +void seeobjs(void); +void seemons(void); +void pmon(struct monst *); +void unpmon(struct monst *); +void nscr(void); +void bot(void); +#ifdef WAN_PROBING +void mstatusline(struct monst *); +#endif +void cls(void); + +/* hack.read.c */ +int doread(void); +int identify(struct obj *); +void litroom(bool); + +/* hack.rip.c */ +void outrip(void); + +/* hack.rumors.c */ +void outrumor(void); + +/* hack.save.c */ +int dosave(void); +#ifndef NOSAVEONHANGUP +void hangup(int); +#endif +bool dorecover(int); +struct obj *restobjchn(int); +struct monst *restmonchn(int); + +/* hack.search.c */ +int findit(void); +int dosearch(void); +int doidtrap(void); +void wakeup(struct monst *); +void seemimic(struct monst *); + +/* hack.shk.c */ +#ifdef QUEST +void obfree(struct obj *, struct obj *); +int inshop(void); +void shopdig(void); +void addtobill(void); +void subfrombill(void); +void splitbill(void); +int dopay(void); +void paybill(void); +int doinvbill(void); +void shkdead(void); +int shkcatch(void); +int shk_move(void); +void replshk(struct monst *, struct monst *); +const char *shkname(void); +#else +char *shkname(struct monst *); +void shkdead(struct monst *); +void replshk(struct monst *, struct monst *); +int inshop(void); +void obfree(struct obj *, struct obj *); +int dopay(void); +void paybill(void); +void addtobill(struct obj *); +void splitbill(struct obj *, struct obj *); +void subfrombill(struct obj *); +int doinvbill(int); +bool shkcatch(struct obj *); +int shk_move(struct monst *); +void shopdig(int); +#endif +bool online(int, int); +bool follower(struct monst *); + +/* hack.shknam.c */ +void findname(char *, char); + +/* hack.steal.c */ +long somegold(void); +void stealgold(struct monst *); +bool steal(struct monst *); +void mpickobj(struct monst *, struct obj *); +bool stealamulet(struct monst *); +void relobj(struct monst *, int); + +/* hack.termcap.c */ +void startup(void); +void start_screen(void); +void end_screen(void); +void curs(int, int); +void cl_end(void); +void clear_screen(void); +void home(void); +void standoutbeg(void); +void standoutend(void); +void backsp(void); +void bell(void); +void cl_eos(void); + +/* hack.timeout.c */ +void p_timeout(void); + +/* hack.topl.c */ +int doredotopl(void); +void remember_topl(void); +void addtopl(const char *); +void more(void); +void cmore(const char *); +void clrlin(void); +void pline(const char *, ...); +void vpline(const char *, va_list); +void putsym(char); +void putstr(const char *); + +/* hack.track.c */ +void initrack(void); +void settrack(void); +coord *gettrack(int, int); + +/* hack.trap.c */ +struct trap *maketrap(int, int, int); +void dotrap(struct trap *); +int mintrap(struct monst *); +void selftouch(const char *); +void float_up(void); +void float_down(void); +void tele(void); +int dotele(void); +void placebc(int); +void unplacebc(void); +void level_tele(void); +void drown(void); + +/* hack.tty.c */ +void gettty(void); +void settty(const char *); +void setftty(void); +void error(const char *, ...); +void getlin(char *); +void getret(void); +void cgetret(const char *); +void xwaitforspace(const char *); +char *parse(void); +char readchar(void); +void end_of_input(void); + +/* hack.u_init.c */ +void u_init(void); +void plnamesuffix(void); + +/* hack.unix.c */ +void setrandom(void); +int getyear(void); +char *getdate(void); +int phase_of_the_moon(void); +bool night(void); +bool midnight(void); +void gethdate(const char *); +bool uptodate(int); +void getlock(void); +#ifdef MAIL +void getmailstatus(void); +void ckmailstatus(void); +void readmail(void); +#endif +void regularize(char *); + +/* hack.vault.c */ +void setgd(void); +int gd_move(void); +void replgd(struct monst *, struct monst *); +void invault(void); +#ifdef QUEST +void gddead(struct monst *); +#else +void gddead(void); +#endif + +/* hack.version.c */ +int doversion(void); + +/* hack.wield.c */ +void setuwep(struct obj *); +int dowield(void); +void corrode_weapon(void); +bool chwepon(struct obj *, int); + +/* hack.wizard.c */ +void amulet(void); +bool wiz_hit(struct monst *); +void inrange(struct monst *); + +/* hack.worm.c */ +#ifndef NOWORM +bool getwn(struct monst *); +void initworm(struct monst *); +void worm_move(struct monst *); +void worm_nomove(struct monst *); +void wormdead(struct monst *); +void wormhit(struct monst *); +void wormsee(unsigned int); +void pwseg(struct wseg *); +void cutworm(struct monst *, xchar, xchar, uchar); +#endif + +/* hack.worn.c */ +void setworn(struct obj *, long); +void setnotworn(struct obj *); + +/* hack.zap.c */ +int dozap(void); +const char *exclam(int); +void hit(const char *, struct monst *, const char *); +void miss(const char *, struct monst *); +struct monst *bhit(int, int, int, char, + void (*)(struct monst *, struct obj *), + bool (*)(struct obj *, struct obj *), struct obj *); +struct monst *boomhit(int, int); +void buzz(int, xchar, xchar, int, int); +void fracture_rock(struct obj *); + +/* rnd.c */ +int rn1(int, int); +int rn2(int); +int rnd(int); +int d(int, int); diff --git a/games/hack/hack.invent.c b/games/hack/hack.invent.c index e01324053a..c02d57eb0a 100644 --- a/games/hack/hack.invent.c +++ b/games/hack/hack.invent.c @@ -1,27 +1,30 @@ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* hack.invent.c - version 1.0.3 */ /* $FreeBSD: src/games/hack/hack.invent.c,v 1.4 1999/11/16 10:26:36 marcel Exp $ */ -/* $DragonFly: src/games/hack/hack.invent.c,v 1.4 2005/05/22 03:37:05 y0netan1 Exp $ */ +/* $DragonFly: src/games/hack/hack.invent.c,v 1.5 2006/08/21 19:45:32 pavalos Exp $ */ #include "hack.h" -#include -extern struct obj *splitobj(); extern struct obj zeroobj; -extern char morc; extern char quitchars[]; -static char *xprname(); + +static void assigninvlet(struct obj *); +static struct obj *mkgoldobj(long); +static bool ckunpaid(struct obj *); +static char obj_to_let(struct obj *); +static char *xprname(struct obj *, char); +static void doinv(char *); +static bool merged(struct obj *, struct obj *, bool); +static bool countgold(void); #ifndef NOWORM -#include "def.wseg.h" extern struct wseg *wsegs[32]; #endif /* NOWORM */ #define NOINVSYM '#' static int lastinvnr = 51; /* 0 ... 51 */ -static -assigninvlet(otmp) -struct obj *otmp; +static void +assigninvlet(struct obj *otmp) { boolean inuse[52]; int i; @@ -47,8 +50,7 @@ struct obj *otmp; } struct obj * -addinv(obj) -struct obj *obj; +addinv(struct obj *obj) { struct obj *otmp; @@ -94,8 +96,8 @@ struct obj *obj; return(obj); } -useup(obj) -struct obj *obj; +void +useup(struct obj *obj) { if(obj->quan > 1){ obj->quan--; @@ -107,8 +109,8 @@ struct obj *obj; } } -freeinv(obj) -struct obj *obj; +void +freeinv(struct obj *obj) { struct obj *otmp; @@ -122,14 +124,18 @@ struct obj *obj; } /* destroy object in fobj chain (if unpaid, it remains on the bill) */ -delobj(obj) struct obj *obj; { +void +delobj(struct obj *obj) +{ freeobj(obj); unpobj(obj); obfree(obj, (struct obj *) 0); } /* unlink obj from chain starting with fobj */ -freeobj(obj) struct obj *obj; { +void +freeobj(struct obj *obj) +{ struct obj *otmp; if(obj == fobj) fobj = fobj->nobj; @@ -141,7 +147,9 @@ freeobj(obj) struct obj *obj; { } /* Note: freegold throws away its argument! */ -freegold(gold) struct gold *gold; { +void +freegold(struct gold *gold) +{ struct gold *gtmp; if(gold == fgold) fgold = gold->ngold; @@ -153,8 +161,8 @@ freegold(gold) struct gold *gold; { free((char *) gold); } -deltrap(trap) -struct trap *trap; +void +deltrap(struct trap *trap) { struct trap *ttmp; @@ -170,8 +178,7 @@ struct trap *trap; struct wseg *m_atseg; struct monst * -m_at(x,y) -int x,y; +m_at(int x, int y) { struct monst *mtmp; #ifndef NOWORM @@ -196,8 +203,7 @@ int x,y; } struct obj * -o_at(x,y) -int x,y; +o_at(int x, int y) { struct obj *otmp; @@ -207,8 +213,7 @@ int x,y; } struct obj * -sobj_at(n,x,y) -int n,x,y; +sobj_at(int n, int x, int y) { struct obj *otmp; @@ -218,15 +223,17 @@ int n,x,y; return(0); } -carried(obj) struct obj *obj; { +bool +carried(struct obj *obj) +{ struct obj *otmp; for(otmp = invent; otmp; otmp = otmp->nobj) if(otmp == obj) return(1); return(0); } -carrying(type) -int type; +bool +carrying(int type) { struct obj *otmp; @@ -237,7 +244,8 @@ int type; } struct obj * -o_on(id, objchn) unsigned int id; struct obj *objchn; { +o_on(unsigned int id, struct obj *objchn) +{ while(objchn) { if(objchn->o_id == id) return(objchn); objchn = objchn->nobj; @@ -246,8 +254,7 @@ o_on(id, objchn) unsigned int id; struct obj *objchn; { } struct trap * -t_at(x,y) -int x,y; +t_at(int x, int y) { struct trap *trap = ftrap; while(trap) { @@ -258,8 +265,7 @@ int x,y; } struct gold * -g_at(x,y) -int x,y; +g_at(int x, int y) { struct gold *gold = fgold; while(gold) { @@ -270,9 +276,8 @@ int x,y; } /* make dummy object structure containing gold - for temporary use only */ -struct obj * -mkgoldobj(q) -long q; +static struct obj * +mkgoldobj(long q) { struct obj *otmp; @@ -292,8 +297,7 @@ long q; * &zeroobj explicitly no object (as in w-). */ struct obj * -getobj(let,word) -char *let,*word; +getobj(const char *let, const char *word) { struct obj *otmp; char ilet,ilet1,ilet2; @@ -336,12 +340,12 @@ char *let,*word; } bp[foo] = 0; if(foo == 0 && bp > buf && bp[-1] == ' ') *--bp = 0; - (void) strcpy(lets, bp); /* necessary since we destroy buf */ + strcpy(lets, bp); /* necessary since we destroy buf */ if(foo > 5) { /* compactify string */ foo = foo2 = 1; ilet2 = bp[0]; ilet1 = bp[1]; - while(ilet = bp[++foo2] = bp[++foo]){ + while((ilet = bp[++foo2] = bp[++foo])){ if(ilet == ilet1+1){ if(ilet1 == ilet2+1) bp[foo2 - 1] = ilet1 = '-'; @@ -438,15 +442,16 @@ char *let,*word; return(otmp); } -ckunpaid(otmp) struct obj *otmp; { +static bool +ckunpaid(struct obj *otmp) +{ return( otmp->unpaid ); } /* interactive version of getobj - used for Drop and Identify */ /* return the number of times fn was called successfully */ -ggetobj(word, fn, max) -char *word; -int (*fn)(), max; +int +ggetobj(const char *word, int (*fn)(struct obj *), int max) { char buf[BUFSZ]; char *ip; @@ -454,7 +459,7 @@ char sym; int oletct = 0, iletct = 0; boolean allflag = FALSE; char olets[20], ilets[20]; -int (*ckfn)() = (int (*)()) 0; +bool (*ckfn)(struct obj *) = (bool (*)()) 0; xchar allowgold = (u.ugold && !strcmp(word, "drop")) ? 1 : 0; /* BAH */ if(!invent && !allowgold){ pline("You have nothing to %s.", word); @@ -487,7 +492,7 @@ xchar allowgold = (u.ugold && !strcmp(word, "drop")) ? 1 : 0; /* BAH */ } ip = buf; olets[0] = 0; - while(sym = *ip++){ + while((sym = *ip++)){ if(sym == ' ') continue; if(sym == '$') { if(allowgold == 1) @@ -519,12 +524,9 @@ xchar allowgold = (u.ugold && !strcmp(word, "drop")) ? 1 : 0; /* BAH */ * If allflag then no questions are asked. Max gives the max nr of * objects to be treated. Return the number of objects treated. */ -askchain(objchn, olets, allflag, fn, ckfn, max) -struct obj *objchn; -char *olets; -int allflag; -int (*fn)(), (*ckfn)(); -int max; +int +askchain(struct obj *objchn, char *olets, int allflag, + int (*fn)(struct obj *), bool (*ckfn)(struct obj *), int max) { struct obj *otmp, *otmp2; char sym, ilet; @@ -560,8 +562,9 @@ ret: return(cnt); } -obj_to_let(obj) /* should of course only be called for things in invent */ -struct obj *obj; +/* should of course only be called for things in invent */ +static char +obj_to_let(struct obj *obj) { struct obj *otmp; char ilet; @@ -574,26 +577,25 @@ struct obj *obj; return(otmp ? ilet : NOINVSYM); } -prinv(obj) -struct obj *obj; +void +prinv(struct obj *obj) { pline(xprname(obj, obj_to_let(obj))); } static char * -xprname(obj,let) -struct obj *obj; -char let; +xprname(struct obj *obj, char let) { static char li[BUFSZ]; - (void) sprintf(li, "%c - %s.", + sprintf(li, "%c - %s.", flags.invlet_constant ? obj->invlet : let, doname(obj)); return(li); } -ddoinv() +int +ddoinv(void) { doinv((char *) 0); return(0); @@ -601,8 +603,8 @@ ddoinv() /* called with 0 or "": all objects in inventory */ /* otherwise: all objects with (serial) letter in lets */ -doinv(lets) -char *lets; +static void +doinv(char *lets) { struct obj *otmp; char ilet; @@ -630,7 +632,8 @@ char *lets; cornline(2, any); } -dotypeinv () /* free after Robert Viduya */ +int +dotypeinv(void) /* free after Robert Viduya */ /* Changed to one type only, so he doesnt have to type cr */ { char c, ilet; @@ -673,7 +676,7 @@ dotypeinv () /* free after Robert Viduya */ if(c == 'x' || c == 'X') { if(billx) - (void) doinvbill(1); + doinvbill(1); else pline("No used-up objects on the shopping bill."); return(0); @@ -702,9 +705,11 @@ dotypeinv () /* free after Robert Viduya */ } /* look at what is here */ -dolook() { - struct obj *otmp, *otmp0; - struct gold *gold; +int +dolook(void) +{ + struct obj *otmp, *otmp0 = NULL; + struct gold *gold = NULL; const char *verb = Blind ? "feel" : "see"; int ct = 0; @@ -742,7 +747,7 @@ dolook() { if(gold) { char gbuf[30]; - (void) sprintf(gbuf, "%ld gold piece%s", + sprintf(gbuf, "%ld gold piece%s", gold->amount, plur(gold->amount)); if(!ct++) pline("You %s here %s.", verb, gbuf); @@ -759,7 +764,9 @@ dolook() { return(!!Blind); } -stackobj(obj) struct obj *obj; { +void +stackobj(struct obj *obj) +{ struct obj *otmp = fobj; for(otmp = fobj; otmp; otmp = otmp->nobj) if(otmp != obj) if(otmp->ox == obj->ox && otmp->oy == obj->oy && @@ -768,7 +775,9 @@ struct obj *otmp = fobj; } /* merge obj with otmp and delete obj if types agree */ -merged(otmp,obj,lose) struct obj *otmp, *obj; { +static bool +merged(struct obj *otmp, struct obj *obj, bool lose) +{ if(obj->otyp == otmp->otyp && obj->unpaid == otmp->unpaid && obj->spe == otmp->spe && @@ -790,10 +799,11 @@ merged(otmp,obj,lose) struct obj *otmp, *obj; { * it may take a while before you have counted it all. * [Bug: d$ and pickup still tell you how much it was.] */ -extern int (*occupation)(); static long goldcounted; -countgold(){ +static bool +countgold(void) +{ if((goldcounted += 100*(u.ulevel + 1)) >= u.ugold) { long eps = 0; if(!rn2(2)) eps = rnd((int) (u.ugold/100 + 1)); @@ -804,7 +814,9 @@ countgold(){ return(1); /* continue */ } -doprgold(){ +int +doprgold(void) +{ if(!u.ugold) pline("You do not carry any gold."); else if(u.ugold <= 500) @@ -820,13 +832,17 @@ doprgold(){ /* --- end of gold counting section --- */ -doprwep(){ +int +doprwep(void) +{ if(!uwep) pline("You are empty handed."); else prinv(uwep); return(0); } -doprarm(){ +int +doprarm(void) +{ if(!uarm && !uarmg && !uarms && !uarmh) pline("You are not wearing any armor."); else { @@ -844,7 +860,9 @@ doprarm(){ return(0); } -doprring(){ +int +doprring(void) +{ if(!uleft && !uright) pline("You are not wearing any rings."); else { @@ -859,6 +877,8 @@ doprring(){ return(0); } -digit(c) char c; { +bool +digit(char c) +{ return(c >= '0' && c <= '9'); } diff --git a/games/hack/hack.ioctl.c b/games/hack/hack.ioctl.c index e28fb0960c..c4b5439bb7 100644 --- a/games/hack/hack.ioctl.c +++ b/games/hack/hack.ioctl.c @@ -1,13 +1,12 @@ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* hack.ioctl.c - version 1.0.2 */ /* $FreeBSD: src/games/hack/hack.ioctl.c,v 1.2 1999/09/12 07:01:23 marcel Exp $ - $DragonFly: src/games/hack/hack.ioctl.c,v 1.3 2004/11/06 12:29:17 eirikn Exp $ + $DragonFly: src/games/hack/hack.ioctl.c,v 1.4 2006/08/21 19:45:32 pavalos Exp $ This cannot be part of hack.tty.c (as it was earlier) since on some systems (e.g. MUNIX) the include files and define the same constants, and the C preprocessor complains. */ -#include -#include "config.h" +#include "hack.h" #ifdef BSD #include struct ltchars ltchars, ltchars0; @@ -16,31 +15,37 @@ struct ltchars ltchars, ltchars0; struct termio termio; #endif /* BSD */ -getioctls() { +void +getioctls(void) +{ #ifdef BSD - (void) ioctl(fileno(stdin), (int) TIOCGLTC, (char *) <chars); - (void) ioctl(fileno(stdin), (int) TIOCSLTC, (char *) <chars0); + ioctl(fileno(stdin), (int) TIOCGLTC, (char *) <chars); + ioctl(fileno(stdin), (int) TIOCSLTC, (char *) <chars0); #else - (void) ioctl(fileno(stdin), (int) TCGETA, &termio); + ioctl(fileno(stdin), (int) TCGETA, &termio); #endif /* BSD */ } -setioctls() { +void +setioctls(void) +{ #ifdef BSD - (void) ioctl(fileno(stdin), (int) TIOCSLTC, (char *) <chars); + ioctl(fileno(stdin), (int) TIOCSLTC, (char *) <chars); #else - (void) ioctl(fileno(stdin), (int) TCSETA, &termio); + ioctl(fileno(stdin), (int) TCSETA, &termio); #endif /* BSD */ } #ifdef SUSPEND /* implies BSD */ #include -dosuspend() { +int +dosuspend(void) +{ #ifdef SIGTSTP if(signal(SIGTSTP, SIG_IGN) == SIG_DFL) { settty((char *) 0); - (void) signal(SIGTSTP, SIG_DFL); - (void) kill(0, SIGTSTP); + signal(SIGTSTP, SIG_DFL); + kill(0, SIGTSTP); gettty(); setftty(); docrt(); diff --git a/games/hack/hack.lev.c b/games/hack/hack.lev.c index dfa82344c1..148cef38b9 100644 --- a/games/hack/hack.lev.c +++ b/games/hack/hack.lev.c @@ -1,31 +1,25 @@ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* hack.lev.c - version 1.0.3 */ /* $FreeBSD: src/games/hack/hack.lev.c,v 1.4 1999/11/16 10:26:36 marcel Exp $ */ -/* $DragonFly: src/games/hack/hack.lev.c,v 1.3 2004/11/06 12:29:17 eirikn Exp $ */ +/* $DragonFly: src/games/hack/hack.lev.c,v 1.4 2006/08/21 19:45:32 pavalos Exp $ */ #include "hack.h" -#include "def.mkroom.h" -#include -extern struct monst *restmonchn(); -extern struct obj *restobjchn(); extern struct obj *billobjs; -extern char *itoa(); extern char SAVEF[]; -extern int hackpid; -extern xchar dlevel; extern char nul[]; #ifndef NOWORM -#include "def.wseg.h" extern struct wseg *wsegs[32], *wheads[32]; extern long wgrowtime[32]; #endif /* NOWORM */ boolean level_exists[MAXLEVEL+1]; -savelev(fd,lev) -int fd; -xchar lev; +static void savegoldchn(int, struct gold *); +static void savetrapchn(int, struct trap *); + +void +savelev(int fd, xchar lev) { #ifndef NOWORM struct wseg *wtmp, *wtmp2; @@ -72,19 +66,16 @@ xchar lev; #endif /* NOWORM */ } -bwrite(fd,loc,num) -int fd; -char *loc; -unsigned num; +void +bwrite(int fd, char *loc, unsigned int num) { /* lint wants the 3rd arg of write to be an int; lint -p an unsigned */ - if(write(fd, loc, (int) num) != num) + if(write(fd, loc, (int) num) != (int)num) panic("cannot write %u bytes to file #%d", num, fd); } -saveobjchn(fd,otmp) -int fd; -struct obj *otmp; +void +saveobjchn(int fd, struct obj *otmp) { struct obj *otmp2; unsigned xl; @@ -101,9 +92,8 @@ struct obj *otmp; bwrite(fd, (char *) &minusone, sizeof(int)); } -savemonchn(fd,mtmp) -int fd; -struct monst *mtmp; +void +savemonchn(int fd, struct monst *mtmp) { struct monst *mtmp2; unsigned xl; @@ -124,9 +114,8 @@ struct monst *mtmp; bwrite(fd, (char *) &minusone, sizeof(int)); } -savegoldchn(fd,gold) -int fd; -struct gold *gold; +static void +savegoldchn(int fd, struct gold *gold) { struct gold *gold2; while(gold) { @@ -138,9 +127,8 @@ struct gold *gold; bwrite(fd, nul, sizeof(struct gold)); } -savetrapchn(fd,trap) -int fd; -struct trap *trap; +static void +savetrapchn(int fd, struct trap *trap) { struct trap *trap2; while(trap) { @@ -152,9 +140,8 @@ struct trap *trap; bwrite(fd, nul, sizeof(struct trap)); } -getlev(fd,pid,lev) -int fd,pid; -xchar lev; +void +getlev(int fd, int pid, xchar lev) { struct gold *gold; struct trap *trap; @@ -190,7 +177,6 @@ xchar lev; /* regenerate animals while on another level */ { long tmoves = (moves > omoves) ? moves-omoves : 0; struct monst *mtmp, *mtmp2; - extern char genocided[]; for(mtmp = fmon; mtmp; mtmp = mtmp2) { long newhp; /* tmoves may be very large */ @@ -256,29 +242,25 @@ xchar lev; #endif /* NOWORM */ } -mread(fd, buf, len) -int fd; -char *buf; -unsigned len; +void +mread(int fd, char *buf, unsigned int len) { int rlen; - extern boolean restoring; rlen = read(fd, buf, (int) len); - if(rlen != len){ + if(rlen != (int)len){ pline("Read %d instead of %u bytes.\n", rlen, len); if(restoring) { - (void) unlink(SAVEF); + unlink(SAVEF); error("Error restoring old game."); } panic("Error reading level file."); } } -mklev() +void +mklev(void) { - extern boolean in_mklev; - if(getbones()) return; in_mklev = TRUE; diff --git a/games/hack/hack.main.c b/games/hack/hack.main.c index 5cbf8e53e3..5a42a893e0 100644 --- a/games/hack/hack.main.c +++ b/games/hack/hack.main.c @@ -1,12 +1,9 @@ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* hack.main.c - version 1.0.3 */ /* $FreeBSD: src/games/hack/hack.main.c,v 1.9 1999/11/16 10:26:36 marcel Exp $ */ -/* $DragonFly: src/games/hack/hack.main.c,v 1.3 2005/05/22 03:37:05 y0netan1 Exp $ */ +/* $DragonFly: src/games/hack/hack.main.c,v 1.4 2006/08/21 19:45:32 pavalos Exp $ */ -#include -#include -#include -#include +#include #include "hack.h" #ifdef QUEST @@ -15,16 +12,10 @@ #define gamename "hack" #endif -extern char plname[PL_NSIZ], pl_character[PL_CSIZ]; -extern struct permonst mons[CMNUM+2]; -extern char genocided[60], fut_geno[]; - -int (*afternmv)(); -int (*occupation)(); +void (*afternmv)(void); +bool (*occupation)(void); const char *occtxt; -void done1(); -void hangup(); int hackpid; /* current pid */ int locknum; /* max num of players */ @@ -38,12 +29,11 @@ char obuf[BUFSIZ]; /* BUFSIZ is defined in stdio.h */ extern long wailmsg; #ifdef CHDIR -static void chdirx(const char *, boolean); +static void chdirx(const char *, bool); #endif -main(argc,argv) -int argc; -char *argv[]; +int +main(int argc, char *argv[]) { int fd; #ifdef CHDIR @@ -93,11 +83,11 @@ char *argv[]; initoptions(); if(!*plname && (s = getenv("USER"))) - (void) strncpy(plname, s, sizeof(plname)-1); + strncpy(plname, s, sizeof(plname)-1); if(!*plname && (s = getenv("LOGNAME"))) - (void) strncpy(plname, s, sizeof(plname)-1); + strncpy(plname, s, sizeof(plname)-1); if(!*plname && (s = getlogin())) - (void) strncpy(plname, s, sizeof(plname)-1); + strncpy(plname, s, sizeof(plname)-1); } /* @@ -124,7 +114,7 @@ char *argv[]; cls(); u.uhp = 1; /* prevent RIP on early quits */ u.ux = FAR; /* prevent nscr() */ - (void) signal(SIGHUP, hangup); + signal(SIGHUP, hangup); /* * Find the creation date of this game, @@ -148,10 +138,7 @@ char *argv[]; switch(argv[0][1]){ #ifdef WIZARD case 'D': -/* if(!strcmp(getlogin(), WIZARD)) */ wizard = TRUE; -/* else - printf("Sorry.\n"); */ break; #endif #ifdef NEWS @@ -161,20 +148,18 @@ char *argv[]; #endif case 'u': if(argv[0][2]) - (void) strncpy(plname, argv[0]+2, sizeof(plname)-1); + strncpy(plname, argv[0]+2, sizeof(plname)-1); else if(argc > 1) { argc--; argv++; - (void) strncpy(plname, argv[0], sizeof(plname)-1); + strncpy(plname, argv[0], sizeof(plname)-1); } else printf("Player name expected after -u\n"); break; default: /* allow -T for Tourist, etc. */ - (void) strncpy(pl_character, argv[0]+1, + strncpy(pl_character, argv[0]+1, sizeof(pl_character)-1); - - /* printf("Unknown option: %s\n", *argv); */ } } @@ -192,7 +177,7 @@ char *argv[]; getmailstatus(); #endif #ifdef WIZARD - if(wizard) (void) strcpy(plname, "wizard"); else + if(wizard) strcpy(plname, "wizard"); else #endif if(!*plname || !strncmp(plname, "player", 4) || !strncmp(plname, "games", 4)) @@ -207,23 +192,23 @@ char *argv[]; * check for multiple games under the same name * (if !locknum) or check max nr of players (otherwise) */ - (void) signal(SIGQUIT,SIG_IGN); - (void) signal(SIGINT,SIG_IGN); + signal(SIGQUIT,SIG_IGN); + signal(SIGINT,SIG_IGN); if(!locknum) - (void) strcpy(lock,plname); + strcpy(lock,plname); getlock(); /* sets lock if locknum != 0 */ #ifdef WIZARD } else { char *sfoo; - (void) strcpy(lock,plname); - if(sfoo = getenv("MAGIC")) + strcpy(lock,plname); + if((sfoo = getenv("MAGIC"))) while(*sfoo) { switch(*sfoo++) { - case 'n': (void) srandom(*sfoo++); + case 'n': srandom(*sfoo++); break; } } - if(sfoo = getenv("GENOCIDED")){ + if((sfoo = getenv("GENOCIDED"))){ if(*sfoo == '!'){ struct permonst *pm = mons; char *gp = genocided; @@ -235,19 +220,19 @@ char *argv[]; } *gp = 0; } else - (void) strncpy(genocided, sfoo, sizeof(genocided)-1); - (void) strcpy(fut_geno, genocided); + strncpy(genocided, sfoo, sizeof(genocided)-1); + strcpy(fut_geno, genocided); } } #endif setftty(); - (void) sprintf(SAVEF, "save/%d%s", getuid(), plname); + sprintf(SAVEF, "save/%d%s", getuid(), plname); regularize(SAVEF+5); /* avoid . or / in name */ if((fd = open(SAVEF,0)) >= 0 && (uptodate(fd) || unlink(SAVEF) == 666)) { - (void) signal(SIGINT,done1); + signal(SIGINT,done1); pline("Restoring old save file..."); - (void) fflush(stdout); + fflush(stdout); if(!dorecover(fd)) goto not_recovered; pline("Hello %s, welcome to %s!", plname, gamename); @@ -262,16 +247,16 @@ not_recovered: init_objects(); u_init(); - (void) signal(SIGINT,done1); + signal(SIGINT,done1); mklev(); u.ux = xupstair; u.uy = yupstair; - (void) inshop(); + inshop(); setsee(); flags.botlx = 1; makedog(); { struct monst *mtmp; - if(mtmp = m_at(u.ux, u.uy)) mnexto(mtmp); /* riv05!a3 */ + if((mtmp = m_at(u.ux, u.uy))) mnexto(mtmp); /* riv05!a3 */ } seemons(); #ifdef NEWS @@ -305,13 +290,12 @@ not_recovered: if(moves%2 == 0 || (!(Fast & ~INTRINSIC) && (!Fast || rn2(3)))) { - extern struct monst *makemon(); movemon(); if(!rn2(70)) - (void) makemon((struct permonst *)0, 0, 0); + makemon((struct permonst *)0, 0, 0); } if(Glib) glibr(); - timeout(); + p_timeout(); ++moves; if(flags.time) flags.botl = 1; if(u.uhp < 1) { @@ -340,7 +324,7 @@ not_recovered: } } if(Teleportation && !rn2(85)) tele(); - if(Searching && multi >= 0) (void) dosearch(); + if(Searching && multi >= 0) dosearch(); gethungry(); invault(); amulet(); @@ -400,12 +384,12 @@ not_recovered: rhack((char *) 0); } if(multi && multi%7 == 0) - (void) fflush(stdout); + fflush(stdout); } } -glo(foo) -int foo; +void +glo(int foo) { /* construct the string xlock.n */ char *tf; @@ -420,10 +404,12 @@ int foo; * explicitly (-w implies wizard) or by askname. * It may still contain a suffix denoting pl_character. */ -askname(){ +void +askname(void) +{ int c,ct; printf("\nWho are you? "); - (void) fflush(stdout); + fflush(stdout); ct = 0; while((c = getchar()) != '\n'){ if(c == EOF) error("End of input\n"); @@ -434,23 +420,26 @@ int c,ct; } if(c != '-') if(c < 'A' || (c > 'Z' && c < 'a') || c > 'z') c = '_'; - if(ct < sizeof(plname)-1) plname[ct++] = c; + if(ct < (int)sizeof(plname)-1) plname[ct++] = c; } plname[ct] = 0; if(ct == 0) askname(); } /*VARARGS1*/ -impossible(s,x1,x2) -char *s; +void +impossible(const char *s, ...) { - pline(s,x1,x2); + va_list ap; + va_start(ap, s); + vpline(s, ap); + va_end(ap); pline("Program in disorder - perhaps you'd better Quit."); } #ifdef CHDIR static void -chdirx(const char *dir, boolean wr) +chdirx(const char *dir, bool wr) { #ifdef SECURE @@ -486,12 +475,13 @@ chdirx(const char *dir, boolean wr) printf("Warning: cannot write %s/%s", dir, RECORD); getret(); } else - (void) close(fd); + close(fd); } } #endif -stop_occupation() +void +stop_occupation(void) { if(occupation) { pline("You stop %s.", occtxt); diff --git a/games/hack/hack.makemon.c b/games/hack/hack.makemon.c index 02f689ebc5..9a510e4523 100644 --- a/games/hack/hack.makemon.c +++ b/games/hack/hack.makemon.c @@ -1,12 +1,9 @@ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* hack.makemon.c - version 1.0.2 */ /* $FreeBSD: src/games/hack/hack.makemon.c,v 1.4 1999/11/16 10:26:36 marcel Exp $ */ -/* $DragonFly: src/games/hack/hack.makemon.c,v 1.3 2004/11/06 12:29:17 eirikn Exp $ */ +/* $DragonFly: src/games/hack/hack.makemon.c,v 1.4 2006/08/21 19:45:32 pavalos Exp $ */ #include "hack.h" -extern char fut_geno[]; -extern char *index(); -extern struct obj *mkobj_at(); struct monst zeromonst; /* @@ -18,13 +15,11 @@ struct monst zeromonst; * note that in this case we return only one of them (the one at [x,y]). */ struct monst * -makemon(ptr,x,y) -struct permonst *ptr; +makemon(struct permonst *ptr, int x, int y) { struct monst *mtmp; int tmp, ct; boolean anything = (!ptr); - extern boolean in_mklev; if(x != 0 || y != 0) if(m_at(x,y)) return((struct monst *) 0); if(ptr){ @@ -48,7 +43,7 @@ struct permonst *ptr; gotmon: mtmp = newmonst(ptr->pxlth); *mtmp = zeromonst; /* clear all entries in structure */ - for(ct = 0; ct < ptr->pxlth; ct++) + for(ct = 0; (unsigned)ct < ptr->pxlth; ct++) ((char *) &(mtmp->mextra[0]))[ct] = 0; mtmp->nmon = fmon; fmon = mtmp; @@ -75,11 +70,11 @@ gotmon: mtmp->mhide = mtmp->mundetected = 1; if(in_mklev) if(mtmp->mx && mtmp->my) - (void) mkobj_at(0, mtmp->mx, mtmp->my); + mkobj_at(0, mtmp->mx, mtmp->my); } if(ptr->mlet == ':') { mtmp->cham = 1; - (void) newcham(mtmp, &mons[dlevel+14+rn2(CMNUM-14-dlevel)]); + newcham(mtmp, &mons[dlevel+14+rn2(CMNUM-14-dlevel)]); } if(ptr->mlet == 'I' || ptr->mlet == ';') mtmp->minvis = 1; @@ -93,14 +88,13 @@ gotmon: #endif /* NOWORM */ if(anything) if(ptr->mlet == 'O' || ptr->mlet == 'k') { - coord enexto(); coord mm; int cnt = rnd(10); mm.x = x; mm.y = y; while(cnt--) { mm = enexto(mm.x, mm.y); - (void) makemon(ptr, mm.x, mm.y); + makemon(ptr, mm.x, mm.y); } } @@ -108,8 +102,7 @@ gotmon: } coord -enexto(xx,yy) -xchar xx,yy; +enexto(xchar xx, xchar yy) { xchar x,y; coord foo[15], *tfoo; @@ -148,7 +141,8 @@ foofull: return( foo[rn2(tfoo-foo)] ); } -goodpos(x,y) /* used only in mnexto and rloc */ +bool +goodpos(int x, int y) /* used only in mnexto and rloc */ { return( ! (x < 1 || x > COLNO-2 || y < 1 || y > ROWNO-2 || @@ -158,8 +152,8 @@ goodpos(x,y) /* used only in mnexto and rloc */ )); } -rloc(mtmp) -struct monst *mtmp; +void +rloc(struct monst *mtmp) { int tx,ty; char ch = mtmp->data->mlet; @@ -184,9 +178,7 @@ struct monst *mtmp; } struct monst * -mkmon_at(let,x,y) -char let; -int x,y; +mkmon_at(char let, int x, int y) { int ct; struct permonst *ptr; diff --git a/games/hack/hack.mhitu.c b/games/hack/hack.mhitu.c index c50fd4eab8..a1622c12fe 100644 --- a/games/hack/hack.mhitu.c +++ b/games/hack/hack.mhitu.c @@ -1,17 +1,16 @@ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* hack.mhitu.c - version 1.0.3 */ /* $FreeBSD: src/games/hack/hack.mhitu.c,v 1.4 1999/11/16 10:26:36 marcel Exp $ */ -/* $DragonFly: src/games/hack/hack.mhitu.c,v 1.3 2004/11/06 12:29:17 eirikn Exp $ */ +/* $DragonFly: src/games/hack/hack.mhitu.c,v 1.4 2006/08/21 19:45:32 pavalos Exp $ */ #include "hack.h" -extern struct monst *makemon(); /* * mhitu: monster hits you * returns 1 if monster dies (e.g. 'y', 'F'), 0 otherwise */ -mhitu(mtmp) -struct monst *mtmp; +bool +mhitu(struct monst *mtmp) { struct permonst *mdat = mtmp->data; int tmp, ctmp; @@ -75,13 +74,13 @@ struct monst *mtmp; break; case '&': if(!mtmp->cham && !mtmp->mcan && !rn2(13)) { - (void) makemon(PM_DEMON,u.ux,u.uy); + makemon(PM_DEMON,u.ux,u.uy); } else { - (void) hitu(mtmp,d(2,6)); - (void) hitu(mtmp,d(2,6)); - (void) hitu(mtmp,rnd(3)); - (void) hitu(mtmp,rnd(3)); - (void) hitu(mtmp,rn1(4,2)); + hitu(mtmp,d(2,6)); + hitu(mtmp,d(2,6)); + hitu(mtmp,rnd(3)); + hitu(mtmp,rnd(3)); + hitu(mtmp,rn1(4,2)); } break; case ',': @@ -114,7 +113,7 @@ struct monst *mtmp; } break; case 'C': - (void) hitu(mtmp,rnd(6)); + hitu(mtmp,rnd(6)); break; case 'c': if(!rn2(5)) { @@ -122,26 +121,24 @@ struct monst *mtmp; if(ctmp || !rn2(20) || (flags.moonphase == NEW_MOON && !carrying(DEAD_LIZARD))) { Stoned = 5; - /* pline("You get turned to stone!"); */ - /* done_in_by(mtmp); */ } } break; case 'D': if(rn2(6) || mtmp->mcan) { - (void) hitu(mtmp,d(3,10)); - (void) hitu(mtmp,rnd(8)); - (void) hitu(mtmp,rnd(8)); + hitu(mtmp,d(3,10)); + hitu(mtmp,rnd(8)); + hitu(mtmp,rnd(8)); break; } kludge("%s breathes fire!","The dragon"); buzz(-1,mtmp->mx,mtmp->my,u.ux-mtmp->mx,u.uy-mtmp->my); break; case 'd': - (void) hitu(mtmp,d(2, (flags.moonphase == FULL_MOON) ? 3 : 4)); + hitu(mtmp,d(2, (flags.moonphase == FULL_MOON) ? 3 : 4)); break; case 'e': - (void) hitu(mtmp,d(3,6)); + hitu(mtmp,d(3,6)); break; case 'F': if(mtmp->mcan) break; @@ -177,8 +174,8 @@ struct monst *mtmp; tmp = hitu(mtmp,rnd(3)); tmp &= hitu(mtmp,rnd(3)); if(tmp){ - (void) hitu(mtmp,rnd(4)); - (void) hitu(mtmp,rnd(4)); + hitu(mtmp,rnd(4)); + hitu(mtmp,rnd(4)); } break; case 'k': @@ -209,8 +206,8 @@ struct monst *mtmp; flags.botl = 1; if(!rn2(50)) rloc(mtmp); } else { - (void) hitu(mtmp,d(2,6)); - (void) hitu(mtmp,d(2,6)); + hitu(mtmp,d(2,6)); + hitu(mtmp,d(2,6)); } break; case 'o': @@ -229,11 +226,11 @@ struct monst *mtmp; if(ctmp && !rn2(4)) justswld(mtmp,"The purple worm"); else - (void) hitu(mtmp,d(2,4)); + hitu(mtmp,d(2,4)); break; case 'Q': - (void) hitu(mtmp,rnd(2)); - (void) hitu(mtmp,rnd(2)); + hitu(mtmp,rnd(2)); + hitu(mtmp,rnd(2)); break; case 'R': if(tmp && uarmh && !uarmh->rustfree && @@ -257,12 +254,12 @@ struct monst *mtmp; if(tmp && !rn2(8)) { poisoned("scorpion's sting",mdat->mname); } - (void) hitu(mtmp,rnd(8)); - (void) hitu(mtmp,rnd(8)); + hitu(mtmp,rnd(8)); + hitu(mtmp,rnd(8)); break; case 'T': - (void) hitu(mtmp,rnd(6)); - (void) hitu(mtmp,rnd(6)); + hitu(mtmp,rnd(6)); + hitu(mtmp,rnd(6)); break; case 't': if(!rn2(5)) rloc(mtmp); @@ -271,8 +268,8 @@ struct monst *mtmp; mtmp->mflee = 1; break; case 'U': - (void) hitu(mtmp,d(3,4)); - (void) hitu(mtmp,d(3,4)); + hitu(mtmp,d(3,4)); + hitu(mtmp,d(3,4)); break; case 'v': if(ctmp && !u.ustuck) u.ustuck = mtmp; @@ -290,9 +287,9 @@ struct monst *mtmp; #endif /* NOWORM */ break; case 'X': - (void) hitu(mtmp,rnd(5)); - (void) hitu(mtmp,rnd(5)); - (void) hitu(mtmp,rnd(5)); + hitu(mtmp,rnd(5)); + hitu(mtmp,rnd(5)); + hitu(mtmp,rnd(5)); break; case 'x': { long side = rn2(2) ? RIGHT_SIDE : LEFT_SIDE; @@ -312,18 +309,18 @@ struct monst *mtmp; } return(1); case 'Y': - (void) hitu(mtmp,rnd(6)); + hitu(mtmp,rnd(6)); break; } if(u.uhp < 1) done_in_by(mtmp); return(0); } -hitu(mtmp,dam) -struct monst *mtmp; -int dam; +bool +hitu(struct monst *mtmp, int dam) { - int tmp, res; + bool res; + int tmp; nomul(0); if(u.uswallow) return(0); @@ -332,8 +329,7 @@ int dam; mtmp->mundetected = 0; if(!Blind) { struct obj *obj; - extern char * Xmonnam(); - if(obj = o_at(mtmp->mx,mtmp->my)) + if((obj = o_at(mtmp->mx,mtmp->my))) pline("%s was hidden under %s!", Xmonnam(mtmp), doname(obj)); } diff --git a/games/hack/hack.mklev.c b/games/hack/hack.mklev.c index 2c2efe414f..1ea8096003 100644 --- a/games/hack/hack.mklev.c +++ b/games/hack/hack.mklev.c @@ -1,21 +1,13 @@ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* hack.mklev.c - version 1.0.3 */ /* $FreeBSD: src/games/hack/hack.mklev.c,v 1.6 1999/11/16 10:26:36 marcel Exp $ */ -/* $DragonFly: src/games/hack/hack.mklev.c,v 1.3 2004/11/06 12:29:17 eirikn Exp $ */ - -#include -#include +/* $DragonFly: src/games/hack/hack.mklev.c,v 1.4 2006/08/21 19:45:32 pavalos Exp $ */ #include "hack.h" -extern struct monst *makemon(); -extern struct obj *mkobj_at(); -extern struct trap *maketrap(); - #define somex() ((random()%(croom->hx-croom->lx+1))+croom->lx) #define somey() ((random()%(croom->hy-croom->ly+1))+croom->ly) -#include "def.mkroom.h" #define XLIM 4 /* define minimum required space around a room */ #define YLIM 3 boolean secret; /* TRUE while making a vault: increase [XY]LIM */ @@ -24,7 +16,6 @@ int smeq[MAXNROFROOMS+1]; coord doors[DOORMAX]; int doorindex; struct rm zerorm; -int comp(); schar nxcor; boolean goldseen; int nroom; @@ -38,7 +29,23 @@ struct rectangle { int rscnt,rsmax; /* 0..rscnt-1: currently under consideration */ /* rscnt..rsmax: discarded */ -makelevel() +static bool makerooms(void); +static void addrs(int, int, int, int); +static void addrsx(int, int, int, int, bool); +static int comp(const void *, const void *); +static coord finddpos(int, int, int, int); +static bool okdoor(int, int); +static void dodoor(int, int, struct mkroom *); +static void dosdoor(int, int, struct mkroom *, int); +static bool maker(schar, schar, schar, schar); +static void makecorridors(void); +static void join(int, int); +static void make_niches(void); +static void makevtele(void); +static void makeniche(bool); + +void +makelevel(void) { struct mkroom *croom, *troom; unsigned tryct; @@ -61,7 +68,7 @@ makelevel() /* construct the rooms */ nroom = 0; secret = FALSE; - (void) makerooms(); + makerooms(); /* construct stairs (up and down in different rooms if possible) */ croom = &rooms[rn2(nroom)]; @@ -87,7 +94,7 @@ makelevel() avoided: maybe the player fell through a trapdoor while a monster was on the stairs. Conclusion: we have to check for monsters on the stairs anyway. */ - if(!rn2(3)) (void) + if(!rn2(3)) makemon((struct permonst *) 0, somex(), somey()); /* put traps and mimics inside */ @@ -95,14 +102,14 @@ makelevel() while(!rn2(8-(dlevel/6))) mktrap(0,0,croom); if(!goldseen && !rn2(3)) mkgold(0L,somex(),somey()); if(!rn2(3)) { - (void) mkobj_at(0, somex(), somey()); + mkobj_at(0, somex(), somey()); tryct = 0; while(!rn2(5)) { if(++tryct > 100){ printf("tryct overflow4\n"); break; } - (void) mkobj_at(0, somex(), somey()); + mkobj_at(0, somex(), somey()); } } } @@ -141,7 +148,9 @@ makelevel() #endif /* QUEST */ } -makerooms() { +static bool +makerooms(void) +{ struct rectangle *rsp; int lx, ly, hx, hy, lowx, lowy, hix, hiy, dx, dy; int tryct = 0, xlim, ylim; @@ -213,8 +222,8 @@ int tryct = 0, xlim, ylim; return(0); /* failed to make vault - very strange */ } -addrs(lowx,lowy,hix,hiy) -int lowx,lowy,hix,hiy; +static void +addrs(int lowx, int lowy, int hix, int hiy) { struct rectangle *rsp; int lx,ly,hx,hy,xlim,ylim; @@ -249,9 +258,9 @@ int lowx,lowy,hix,hiy; } } -addrsx(lx,ly,hx,hy,discarded) -int lx,ly,hx,hy; -boolean discarded; /* piece of a discarded area */ +/* discarded = piece of a discarded area */ +static void +addrsx(int lx, int ly, int hx, int hy, bool discarded) { struct rectangle *rsp; @@ -281,15 +290,19 @@ boolean discarded; /* piece of a discarded area */ rsp->rhy = hy; } -comp(x,y) -struct mkroom *x,*y; +static int +comp(const void *vx, const void *vy) { + const struct mkroom *x, *y; + x = vx; + y = vy; if(x->lx < y->lx) return(-1); return(x->lx > y->lx); } -coord -finddpos(xl,yl,xh,yh) { +static coord +finddpos(int xl, int yl, int xh, int yh) +{ coord ff; int x,y; @@ -315,8 +328,8 @@ gotit: } /* see whether it is allowable to create a door at [x,y] */ -okdoor(x,y) -int x,y; +static bool +okdoor(int x, int y) { if(levl[x-1][y].typ == DOOR || levl[x+1][y].typ == DOOR || levl[x][y+1].typ == DOOR || levl[x][y-1].typ == DOOR || @@ -328,9 +341,8 @@ int x,y; return(1); } -dodoor(x,y,aroom) -int x,y; -struct mkroom *aroom; +static void +dodoor(int x, int y, struct mkroom *aroom) { if(doorindex >= DOORMAX) { impossible("DOORMAX exceeded?"); @@ -341,10 +353,8 @@ struct mkroom *aroom; dosdoor(x,y,aroom,rn2(8) ? DOOR : SDOOR); } -dosdoor(x,y,aroom,type) -int x,y; -struct mkroom *aroom; -int type; +static void +dosdoor(int x, int y, struct mkroom *aroom, int type) { struct mkroom *broom; int tmp; @@ -366,8 +376,8 @@ int type; } /* Only called from makerooms() */ -maker(lowx,ddx,lowy,ddy) -schar lowx,ddx,lowy,ddy; +static bool +maker(schar lowx, schar ddx, schar lowy, schar ddy) { struct mkroom *croom; int x, y, hix = lowx+ddx, hiy = lowy+ddy; @@ -443,7 +453,9 @@ chk: return(1); } -makecorridors() { +static void +makecorridors(void) +{ int a,b; nxcor = 0; @@ -465,8 +477,8 @@ makecorridors() { } } -join(a,b) -int a,b; +static void +join(int a, int b) { coord cc,tt; int tx, ty, xx, yy; @@ -536,7 +548,7 @@ int a,b; crm->typ = CORR; crm->scrsym = CORR_SYM; if(nxcor && !rn2(50)) - (void) mkobj_at(ROCK_SYM, xx, yy); + mkobj_at(ROCK_SYM, xx, yy); } else { crm->typ = SCORR; crm->scrsym = ' '; @@ -606,19 +618,21 @@ int a,b; smeq[a] = smeq[b]; } -make_niches() +static void +make_niches(void) { int ct = rnd(nroom/2 + 1); while(ct--) makeniche(FALSE); } -makevtele() +static void +makevtele(void) { makeniche(TRUE); } -makeniche(with_trap) -boolean with_trap; +static void +makeniche(bool with_trap) { struct mkroom *aroom; struct rm *rm; @@ -658,7 +672,7 @@ boolean with_trap; dosdoor(xx, yy, aroom, rn2(5) ? SDOOR : DOOR); else { mksobj_at(SCR_TELEPORTATION, xx, yy+dy); - if(!rn2(3)) (void) mkobj_at(0, xx, yy+dy); + if(!rn2(3)) mkobj_at(0, xx, yy+dy); } } return; @@ -666,14 +680,12 @@ boolean with_trap; } /* make a trap somewhere (in croom if mazeflag = 0) */ -mktrap(num,mazeflag,croom) -int num,mazeflag; -struct mkroom *croom; +void +mktrap(int num, int mazeflag, struct mkroom *croom) { struct trap *ttmp; int kind,nopierc,nomimic,fakedoor,fakegold,tryct = 0; xchar mx,my; - extern char fut_geno[]; if(!num || num >= TRAPNUM) { nopierc = (dlevel < 4) ? 1 : 0; @@ -705,7 +717,6 @@ struct mkroom *croom; mx = somex(); } } else if(mazeflag) { - extern coord mazexy(); coord mm; mm = mazexy(); mx = mm.x; @@ -715,7 +726,7 @@ struct mkroom *croom; my = somey(); } } while(m_at(mx,my) || levl[mx][my].typ == STAIRS); - if(mtmp = makemon(PM_MIMIC,mx,my)) { + if((mtmp = makemon(PM_MIMIC,mx,my))) { mtmp->mimic = 1; mtmp->mappearance = fakegold ? '$' : fakedoor ? '+' : @@ -729,7 +740,6 @@ struct mkroom *croom; if(++tryct > 200) return; if(mazeflag){ - extern coord mazexy(); coord mm; mm = mazexy(); mx = mm.x; diff --git a/games/hack/hack.mkmaze.c b/games/hack/hack.mkmaze.c index 7e27df9df0..24c24940cb 100644 --- a/games/hack/hack.mkmaze.c +++ b/games/hack/hack.mkmaze.c @@ -1,18 +1,19 @@ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* hack.mkmaze.c - version 1.0.2 */ /* $FreeBSD: src/games/hack/hack.mkmaze.c,v 1.4 1999/11/16 10:26:37 marcel Exp $ */ -/* $DragonFly: src/games/hack/hack.mkmaze.c,v 1.2 2003/06/17 04:25:24 dillon Exp $ */ +/* $DragonFly: src/games/hack/hack.mkmaze.c,v 1.3 2006/08/21 19:45:32 pavalos Exp $ */ #include "hack.h" -#include "def.mkroom.h" /* not really used */ -extern struct monst *makemon(); extern struct permonst pm_wizard; -extern struct obj *mkobj_at(); -extern coord mazexy(); struct permonst hell_hound = { "hell hound", 'd', 12, 14, 2, 3, 6, 0 }; -makemaz() +static void walkfrom(int, int); +static void move(int *, int *, int); +static bool okay(int, int, int); + +void +makemaz(void) { int x,y; int zx,zy; @@ -33,12 +34,12 @@ makemaz() (y == zy-1 || y == zy+1 || x == zx-1 || x == zx+2) ? HWALL: ROOM; } - (void) mkobj_at(AMULET_SYM, zx, zy); + mkobj_at(AMULET_SYM, zx, zy); flags.made_amulet = 1; walkfrom(zx+4, zy); - if(mtmp = makemon(&hell_hound, zx, zy)) + if((mtmp = makemon(&hell_hound, zx, zy))) mtmp->msleep = 1; - if(mtmp = makemon(PM_WIZARD, zx+1, zy)) { + if((mtmp = makemon(PM_WIZARD, zx+1, zy))) { mtmp->msleep = 1; flags.no_of_wizards = 1; } @@ -47,8 +48,8 @@ makemaz() zx = mm.x; zy = mm.y; walkfrom(zx,zy); - (void) mksobj_at(WAN_WISHING, zx, zy); - (void) mkobj_at(ROCK_SYM, zx, zy); /* put a rock on top of it */ + mksobj_at(WAN_WISHING, zx, zy); + mkobj_at(ROCK_SYM, zx, zy); /* put a rock on top of it */ } for(x = 2; x < COLNO-1; x++) @@ -64,17 +65,17 @@ makemaz() } for(x = rn1(8,11); x; x--) { mm = mazexy(); - (void) mkobj_at(rn2(2) ? GEM_SYM : 0, mm.x, mm.y); + mkobj_at(rn2(2) ? GEM_SYM : 0, mm.x, mm.y); } for(x = rn1(10,2); x; x--) { mm = mazexy(); - (void) mkobj_at(ROCK_SYM, mm.x, mm.y); + mkobj_at(ROCK_SYM, mm.x, mm.y); } mm = mazexy(); - (void) makemon(PM_MINOTAUR, mm.x, mm.y); + makemon(PM_MINOTAUR, mm.x, mm.y); for(x = rn1(5,7); x; x--) { mm = mazexy(); - (void) makemon((struct permonst *) 0, mm.x, mm.y); + makemon((struct permonst *) 0, mm.x, mm.y); } for(x = rn1(6,7); x; x--) { mm = mazexy(); @@ -88,7 +89,9 @@ makemaz() xdnstair = ydnstair = 0; } -walkfrom(x,y) int x,y; { +static void +walkfrom(int x, int y) +{ int q,a,dir; int dirs[4]; levl[x][y].typ = ROOM; @@ -105,9 +108,8 @@ int dirs[4]; } } -move(x,y,dir) -int *x, *y; -int dir; +static void +move(int *x, int *y, int dir) { switch(dir){ case 0: --(*y); break; @@ -117,9 +119,8 @@ int dir; } } -okay(x,y,dir) -int x,y; -int dir; +static bool +okay(int x, int y, int dir) { move(&x,&y,dir); move(&x,&y,dir); @@ -130,7 +131,8 @@ int dir; } coord -mazexy(){ +mazexy(void) +{ coord mm; mm.x = 3 + 2*rn2(COLNO/2 - 2); mm.y = 3 + 2*rn2(ROWNO/2 - 2); diff --git a/games/hack/hack.mkobj.c b/games/hack/hack.mkobj.c index 2c5a1a133a..c24018837e 100644 --- a/games/hack/hack.mkobj.c +++ b/games/hack/hack.mkobj.c @@ -1,16 +1,14 @@ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* hack.mkobj.c - version 1.0.3 */ /* $FreeBSD: src/games/hack/hack.mkobj.c,v 1.5 1999/11/16 10:26:37 marcel Exp $ */ -/* $DragonFly: src/games/hack/hack.mkobj.c,v 1.3 2004/11/06 12:29:17 eirikn Exp $ */ +/* $DragonFly: src/games/hack/hack.mkobj.c,v 1.4 2006/08/21 19:45:32 pavalos Exp $ */ #include "hack.h" char mkobjstr[] = "))[[!!!!????%%%%/=**))[[!!!!????%%%%/=**(%"; -struct obj *mkobj(), *mksobj(); struct obj * -mkobj_at(let,x,y) -int let,x,y; +mkobj_at(int let, int x, int y) { struct obj *otmp = mkobj(let); otmp->ox = x; @@ -20,8 +18,8 @@ int let,x,y; return(otmp); } -mksobj_at(otyp,x,y) -int otyp,x,y; +void +mksobj_at(int otyp, int x, int y) { struct obj *otmp = mksobj(otyp); otmp->ox = x; @@ -31,7 +29,8 @@ int otyp,x,y; } struct obj * -mkobj(let) { +mkobj(int let) +{ if(!let) let = mkobjstr[rn2(sizeof(mkobjstr) - 1)]; return( @@ -47,8 +46,7 @@ mkobj(let) { struct obj zeroobj; struct obj * -mksobj(otyp) -int otyp; +mksobj(int otyp) { struct obj *otmp; char let = objects[otyp].oc_olet; @@ -119,24 +117,26 @@ int otyp; return(otmp); } -letter(c) { +bool +letter(char c) +{ return(('@' <= c && c <= 'Z') || ('a' <= c && c <= 'z')); } -weight(obj) -struct obj *obj; +int +weight(struct obj *obj) { int wt = objects[obj->otyp].oc_weight; return(wt ? wt*obj->quan : (obj->quan + 1)/2); } -mkgold(num,x,y) -long num; +void +mkgold(long num, int x, int y) { struct gold *gold; long amount = (num ? num : 1 + (rnd(dlevel+2) * rnd(30))); - if(gold = g_at(x,y)) + if((gold = g_at(x,y))) gold->amount += amount; else { gold = newgold(); diff --git a/games/hack/hack.mkshop.c b/games/hack/hack.mkshop.c index 7f70dfea71..8c62b6633b 100644 --- a/games/hack/hack.mkshop.c +++ b/games/hack/hack.mkshop.c @@ -1,21 +1,27 @@ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* hack.mkshop.c - version 1.0.3 */ /* $FreeBSD: src/games/hack/hack.mkshop.c,v 1.4 1999/11/16 10:26:37 marcel Exp $ */ -/* $DragonFly: src/games/hack/hack.mkshop.c,v 1.3 2004/11/06 12:29:17 eirikn Exp $ */ +/* $DragonFly: src/games/hack/hack.mkshop.c,v 1.4 2006/08/21 19:45:32 pavalos Exp $ */ #ifndef QUEST #include "hack.h" -#include "def.mkroom.h" #include "def.eshk.h" -#include #define ESHK ((struct eshk *)(&(shk->mextra[0]))) -extern struct monst *makemon(); -extern struct obj *mkobj_at(); extern int nroom; extern char shtypes[]; /* = "=/)%?!["; 8 types: 7 specialized, 1 mixed */ schar shprobs[] = { 3,3,5,5,10,10,14,50 }; /* their probabilities */ -mkshop(){ +static struct permonst *morguemon(void); +static bool nexttodoor(int, int); +static bool has_dnstairs(struct mkroom *); +static bool has_upstairs(struct mkroom *); +static bool isbig(struct mkroom *); +static int dist2(int, int, int, int); +static int sq(int); + +void +mkshop(void) +{ struct mkroom *sroom; int sh,sx,sy,i = -1; char let; @@ -60,9 +66,9 @@ gottype: continue; if( #ifdef WIZARD - (wizard && getenv("SHOPTYPE") && sroom->doorct != 0) || + ((wizard && getenv("SHOPTYPE") && sroom->doorct != 0)) || #endif /* WIZARD */ - sroom->doorct <= 2 && sroom->doorct > 0) break; + (sroom->doorct <= 2 && sroom->doorct > 0)) break; } if(i < 0) { /* shoptype not yet determined */ @@ -86,7 +92,6 @@ gottype: /* This is said to happen sometimes, but I've never seen it. */ if(wizard) { int j = sroom->doorct; - extern int doorindex; pline("Where is shopdoor?"); pline("Room at (%d,%d),(%d,%d).", sroom->lx, sroom->ly, @@ -131,19 +136,18 @@ gottype: (let && rn2(10) < dlevel) ? let : ']'; continue; } - (void) mkobj_at(let, sx, sy); + mkobj_at(let, sx, sy); } } -mkzoo(type) -int type; +void +mkzoo(int type) { struct mkroom *sroom; struct monst *mon; int sh,sx,sy,i; int goldlim = 500 * dlevel; int moct = 0; - struct permonst *morguemon(); i = nroom; for(sroom = &rooms[rn2(nroom)]; ; sroom++) { @@ -194,10 +198,9 @@ int type; } } -struct permonst * -morguemon() +static struct permonst * +morguemon(void) { - extern struct permonst pm_ghost; int i = rn2(100), hd = rn2(dlevel); if(hd > 10 && i < 10) return(PM_DEMON); @@ -205,11 +208,11 @@ morguemon() return((i < 40) ? PM_GHOST : (i < 60) ? PM_WRAITH : PM_ZOMBIE); } -mkswamp() /* Michiel Huisjes & Fred de Wilde */ +void +mkswamp(void) /* Michiel Huisjes & Fred de Wilde */ { struct mkroom *sroom; int sx,sy,i,eelct = 0; - extern struct permonst pm_eel; for(i=0; i<5; i++) { /* 5 tries */ sroom = &rooms[rn2(nroom)]; @@ -226,15 +229,15 @@ mkswamp() /* Michiel Huisjes & Fred de Wilde */ levl[sx][sy].typ = POOL; levl[sx][sy].scrsym = POOL_SYM; if(!eelct || !rn2(4)) { - (void) makemon(PM_EEL, sx, sy); + makemon(PM_EEL, sx, sy); eelct++; } } } } -nexttodoor(sx,sy) -int sx,sy; +static bool +nexttodoor(int sx, int sy) { int dx,dy; struct rm *lev; @@ -245,32 +248,36 @@ int sx,sy; return(0); } -has_dnstairs(sroom) -struct mkroom *sroom; +static bool +has_dnstairs(struct mkroom *sroom) { return(sroom->lx <= xdnstair && xdnstair <= sroom->hx && sroom->ly <= ydnstair && ydnstair <= sroom->hy); } -has_upstairs(sroom) -struct mkroom *sroom; +static bool +has_upstairs(struct mkroom *sroom) { return(sroom->lx <= xupstair && xupstair <= sroom->hx && sroom->ly <= yupstair && yupstair <= sroom->hy); } -isbig(sroom) -struct mkroom *sroom; +static bool +isbig(struct mkroom *sroom) { int area = (sroom->hx - sroom->lx) * (sroom->hy - sroom->ly); return( area > 20 ); } -dist2(x0,y0,x1,y1){ +static int +dist2(int x0, int y0, int x1, int y1) +{ return((x0-x1)*(x0-x1) + (y0-y1)*(y0-y1)); } -sq(a) int a; { +static int +sq(int a) +{ return(a*a); } #endif /* QUEST */ diff --git a/games/hack/hack.mon.c b/games/hack/hack.mon.c index 1dd9e519cd..024e22dddf 100644 --- a/games/hack/hack.mon.c +++ b/games/hack/hack.mon.c @@ -1,7 +1,7 @@ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* hack.mon.c - version 1.0.3 */ /* $FreeBSD: src/games/hack/hack.mon.c,v 1.5 1999/11/16 10:26:37 marcel Exp $ */ -/* $DragonFly: src/games/hack/hack.mon.c,v 1.4 2005/05/22 03:37:05 y0netan1 Exp $ */ +/* $DragonFly: src/games/hack/hack.mon.c,v 1.5 2006/08/21 19:45:32 pavalos Exp $ */ #include "hack.h" #include "hack.mfndpos.h" @@ -10,9 +10,6 @@ #define NULL (char *) 0 #endif -extern struct monst *makemon(); -extern struct obj *mkobj_at(); - int warnlevel; /* used by movemon and dochugw */ long lastwarntime; int lastwarnlev; @@ -20,7 +17,14 @@ static const char *warnings[] = { "white", "pink", "red", "ruby", "purple", "black" }; -movemon() +static int dochugw(struct monst *); +static void mpickgold(struct monst *); +static void mpickgems(struct monst *); +static void dmonsfree(void); +static bool ishuman(struct monst *); + +void +movemon(void) { struct monst *mtmp; int fr; @@ -104,9 +108,8 @@ movemon() dmonsfree(); /* remove all dead monsters */ } -justswld(mtmp,name) -struct monst *mtmp; -char *name; +void +justswld(struct monst *mtmp, const char *name) { mtmp->mx = u.ux; @@ -121,15 +124,13 @@ char *name; swallowed(); } -youswld(mtmp,dam,die,name) -struct monst *mtmp; -int dam,die; -char *name; +void +youswld(struct monst *mtmp, int dam, int die, const char *name) { if(mtmp != u.ustuck) return; kludge("%s digests you!",name); u.uhp -= dam; - if(u.uswldtim++ >= die){ /* a3 */ + if((int)u.uswldtim++ >= die){ /* a3 */ pline("It totally digests you!"); u.uhp = -1; } @@ -137,12 +138,14 @@ char *name; /* flags.botlx = 1; */ /* should we show status line ? */ } -dochugw(mtmp) struct monst *mtmp; { +static int +dochugw(struct monst *mtmp) +{ int x = mtmp->mx; int y = mtmp->my; -int d = dochug(mtmp); +int d1 = dochug(mtmp); int dd; - if(!d) /* monster still alive */ + if(!d1) /* monster still alive */ if(Warning) if(!mtmp->mpeaceful) if(mtmp->data->mlevel > warnlevel) @@ -150,18 +153,18 @@ int dd; if(dd < 100) if(!canseemon(mtmp)) warnlevel = mtmp->data->mlevel; - return(d); + return(d1); } /* returns 1 if monster died moving, 0 otherwise */ -dochug(mtmp) -struct monst *mtmp; +bool +dochug(struct monst *mtmp) { struct permonst *mdat; - int tmp, nearby, scared; + int tmp = 0, nearby, scared; if(mtmp->cham && !rn2(6)) - (void) newcham(mtmp, &mons[dlevel+14+rn2(CMNUM-14-dlevel)]); + newcham(mtmp, &mons[dlevel+14+rn2(CMNUM-14-dlevel)]); mdat = mtmp->data; if(mdat->mlevel < 0) panic("bad monster %c (%d)",mdat->mlet,mdat->mlevel); @@ -236,14 +239,14 @@ struct monst *mtmp; return(tmp == 2); } -m_move(mtmp,after) -struct monst *mtmp; +int +m_move(struct monst *mtmp, int after) { struct monst *mtmp2; int nx,ny,omx,omy,appr,nearer,cnt,i,j; xchar gx,gy,nix,niy,chcnt; schar chi; - boolean likegold, likegems, likeobjs; + boolean likegold = 0, likegems = 0, likeobjs; char msym = mtmp->data->mlet; schar mmoved = 0; /* not strictly nec.: chi >= 0 will do */ coord poss[9]; @@ -327,7 +330,6 @@ not_special: */ if(msym == '@' || ('a' <= msym && msym <= 'z')) { - extern coord *gettrack(); coord *cp; schar mroom; mroom = inroom(omx,omy); @@ -418,7 +420,7 @@ not_special: return(0); } if(info[chi] & ALLOW_U){ - (void) hitu(mtmp, d(mtmp->data->damn, mtmp->data->damd)+1); + hitu(mtmp, d(mtmp->data->damn, mtmp->data->damd)+1); return(0); } mtmp->mx = nix; @@ -450,9 +452,11 @@ postmov: return(mmoved); } -mpickgold(mtmp) struct monst *mtmp; { +static void +mpickgold(struct monst *mtmp) +{ struct gold *gold; - while(gold = g_at(mtmp->mx, mtmp->my)){ + while((gold = g_at(mtmp->mx, mtmp->my))){ mtmp->mgold += gold->amount; freegold(gold); if(levl[mtmp->mx][mtmp->my].scrsym == '$') @@ -460,7 +464,9 @@ struct gold *gold; } } -mpickgems(mtmp) struct monst *mtmp; { +static void +mpickgems(struct monst *mtmp) +{ struct obj *otmp; for(otmp = fobj; otmp; otmp = otmp->nobj) if(otmp->olet == GEM_SYM) @@ -475,10 +481,8 @@ struct obj *otmp; } /* return number of acceptable neighbour positions */ -mfndpos(mon,poss,info,flag) -struct monst *mon; -coord poss[9]; -int info[9], flag; +int +mfndpos(struct monst *mon, coord poss[9], int info[9], int flag) { int x,y,nx,ny,cnt = 0,ntyp; struct monst *mtmp; @@ -505,7 +509,7 @@ nexttry: /* eels prefer the water, but if there is no water nearby, if(nx == u.ux && ny == u.uy){ if(!(flag & ALLOW_U)) continue; info[cnt] = ALLOW_U; - } else if(mtmp = m_at(nx,ny)){ + } else if((mtmp = m_at(nx,ny))){ if(!(flag & ALLOW_M)) continue; info[cnt] = ALLOW_M; if(mtmp->mtame){ @@ -552,12 +556,14 @@ nexttry: /* eels prefer the water, but if there is no water nearby, return(cnt); } -dist(x,y) int x,y; { +int +dist(int x, int y) +{ return((x-u.ux)*(x-u.ux) + (y-u.uy)*(y-u.uy)); } -poisoned(string, pname) -char *string, *pname; +void +poisoned(const char *string, const char *pname) { int i; @@ -582,8 +588,8 @@ char *string, *pname; } } -mondead(mtmp) -struct monst *mtmp; +void +mondead(struct monst *mtmp) { relobj(mtmp,1); unpmon(mtmp); @@ -598,8 +604,8 @@ struct monst *mtmp; } /* called when monster is moved to larger structure */ -replmon(mtmp,mtmp2) -struct monst *mtmp, *mtmp2; +void +replmon(struct monst *mtmp, struct monst *mtmp2) { relmon(mtmp); monfree(mtmp); @@ -610,8 +616,8 @@ struct monst *mtmp, *mtmp2; if(mtmp2->isgd) replgd(mtmp,mtmp2); } -relmon(mon) -struct monst *mon; +void +relmon(struct monst *mon) { struct monst *mtmp; @@ -626,21 +632,25 @@ struct monst *mon; available shortly after their demise */ struct monst *fdmon; /* chain of dead monsters, need not to be saved */ -monfree(mtmp) struct monst *mtmp; { +void +monfree(struct monst *mtmp) +{ mtmp->nmon = fdmon; fdmon = mtmp; } -dmonsfree(){ +static void +dmonsfree(void) +{ struct monst *mtmp; - while(mtmp = fdmon){ + while((mtmp = fdmon)){ fdmon = mtmp->nmon; free((char *) mtmp); } } -unstuck(mtmp) -struct monst *mtmp; +void +unstuck(struct monst *mtmp) { if(u.ustuck == mtmp) { if(u.uswallow){ @@ -654,15 +664,15 @@ struct monst *mtmp; } } -killed(mtmp) -struct monst *mtmp; +void +killed(struct monst *mtmp) { #ifdef lint #define NEW_SCORING + int tmp2; #endif /* lint */ - int tmp,tmp2,nk,x,y; + int tmp,nk,x,y; struct permonst *mdat; - extern long newuexp(); if(mtmp->cham) mtmp->data = PM_CHAMELEON; mdat = mtmp->data; @@ -681,7 +691,6 @@ struct monst *mtmp; nk = 1; /* in case we cannot find it in mons */ tmp = mdat - mons; /* index in mons array (if not 'd', '@', ...) */ if(tmp >= 0 && tmp < CMNUM+2) { - extern char fut_geno[]; u.nr_killed[tmp]++; if((nk = u.nr_killed[tmp]) > MAXMONNO && !index(fut_geno, mdat->mlet)) @@ -762,8 +771,8 @@ struct monst *mtmp; } } -kludge(str,arg) -char *str,*arg; +void +kludge(const char *str, const char *arg) { if(Blind) { if(*str == '%') pline(str,"It"); @@ -771,21 +780,22 @@ char *str,*arg; } else pline(str,arg); } -rescham() /* force all chameleons to become normal */ +void +rescham(void) /* force all chameleons to become normal */ { struct monst *mtmp; for(mtmp = fmon; mtmp; mtmp = mtmp->nmon) if(mtmp->cham) { mtmp->cham = 0; - (void) newcham(mtmp, PM_CHAMELEON); + newcham(mtmp, PM_CHAMELEON); } } -newcham(mtmp,mdat) /* make a chameleon look like a new monster */ - /* returns 1 if the monster actually changed */ -struct monst *mtmp; -struct permonst *mdat; +/* make a chameleon look like a new monster */ +/* returns 1 if the monster actually changed */ +bool +newcham(struct monst *mtmp, struct permonst *mdat) { int mhp, hpn, hpd; @@ -822,10 +832,10 @@ struct permonst *mdat; return(1); } -mnexto(mtmp) /* Make monster mtmp next to you (if possible) */ -struct monst *mtmp; +/* Make monster mtmp next to you (if possible) */ +void +mnexto(struct monst *mtmp) { - extern coord enexto(); coord mm; mm = enexto(u.ux, u.uy); mtmp->mx = mm.x; @@ -833,11 +843,15 @@ struct monst *mtmp; pmon(mtmp); } -ishuman(mtmp) struct monst *mtmp; { +static bool +ishuman(struct monst *mtmp) +{ return(mtmp->data->mlet == '@'); } -setmangry(mtmp) struct monst *mtmp; { +void +setmangry(struct monst *mtmp) +{ if(!mtmp->mpeaceful) return; if(mtmp->mtame) return; mtmp->mpeaceful = 0; @@ -846,8 +860,8 @@ setmangry(mtmp) struct monst *mtmp; { /* not one hundred procent correct: now a snake may hide under an invisible object */ -canseemon(mtmp) -struct monst *mtmp; +bool +canseemon(struct monst *mtmp) { return((!mtmp->minvis || See_invisible) && (!mtmp->mhide || !o_at(mtmp->mx,mtmp->my)) diff --git a/games/hack/hack.monst.c b/games/hack/hack.monst.c index bcfa3ede7f..bf6470bd85 100644 --- a/games/hack/hack.monst.c +++ b/games/hack/hack.monst.c @@ -1,10 +1,9 @@ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* hack.monst.c - version 1.0.2 */ -/* $DragonFly: src/games/hack/hack.monst.c,v 1.2 2004/11/06 12:29:17 eirikn Exp $ */ +/* $DragonFly: src/games/hack/hack.monst.c,v 1.3 2006/08/21 19:45:32 pavalos Exp $ */ #include "hack.h" #include "def.eshk.h" -extern char plname[PL_NSIZ]; struct permonst mons[CMNUM+2] = { { "bat", 'B',1,22,8,1,4,0 }, diff --git a/games/hack/hack.o_init.c b/games/hack/hack.o_init.c index 8e43d368aa..77c2bf97de 100644 --- a/games/hack/hack.o_init.c +++ b/games/hack/hack.o_init.c @@ -1,16 +1,17 @@ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* hack.o_init.c - version 1.0.3 */ /* $FreeBSD: src/games/hack/hack.o_init.c,v 1.6 1999/11/16 10:26:37 marcel Exp $ */ -/* $DragonFly: src/games/hack/hack.o_init.c,v 1.3 2005/05/22 03:37:05 y0netan1 Exp $ */ +/* $DragonFly: src/games/hack/hack.o_init.c,v 1.4 2006/08/21 19:45:32 pavalos Exp $ */ -#include -#include "config.h" /* for typedefs */ #include "def.objects.h" -#include "hack.onames.h" /* for LAST_GEM */ -extern char *index(); +#include "hack.h" + +static void setgemprobs(void); +static bool interesting_to_discover(int); int -letindex(let) char let; { +letindex(char let) +{ int i = 0; char ch; while((ch = obj_symbols[i++]) != 0) @@ -18,7 +19,9 @@ char ch; return(0); } -init_objects(){ +void +init_objects(void) +{ int i, j, first, last, sum, end; char let; const char *tmp; @@ -67,7 +70,9 @@ init_objects(){ } } -probtype(let) char let; { +int +probtype(char let) +{ int i = bases[letindex(let)]; int prob = rn2(100); while((prob -= objects[i].oc_prob) >= 0) i++; @@ -76,10 +81,10 @@ int prob = rn2(100); return(i); } -setgemprobs() +static void +setgemprobs(void) { int j,first; - extern xchar dlevel; first = bases[letindex(GEM_SYM)]; @@ -95,14 +100,15 @@ setgemprobs() objects[j].oc_prob = (20+j-first)/(LAST_GEM-first); } -oinit() /* level dependent initialization */ +void +oinit(void) /* level dependent initialization */ { setgemprobs(); } -extern long *alloc(); - -savenames(fd) int fd; { +void +savenames(int fd) +{ int i; unsigned len; bwrite(fd, (char *) bases, sizeof bases); @@ -119,7 +125,9 @@ unsigned len; } } -restnames(fd) int fd; { +void +restnames(int fd) +{ int i; unsigned len; mread(fd, (char *) bases, sizeof bases); @@ -131,9 +139,9 @@ unsigned len; } } -dodiscovered() /* free after Robert Viduya */ +int +dodiscovered(void) /* free after Robert Viduya */ { - extern char *typename(); int i, end; int ct = 0; @@ -155,8 +163,8 @@ dodiscovered() /* free after Robert Viduya */ return(0); } -interesting_to_discover(i) -int i; +static bool +interesting_to_discover(int i) { return( objects[i].oc_uname != NULL || diff --git a/games/hack/hack.objnam.c b/games/hack/hack.objnam.c index 6490512fb7..99e9112322 100644 --- a/games/hack/hack.objnam.c +++ b/games/hack/hack.objnam.c @@ -1,38 +1,41 @@ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* hack.objnam.c - version 1.0.2 */ /* $FreeBSD: src/games/hack/hack.objnam.c,v 1.3 1999/11/16 02:57:08 billf Exp $ */ -/* $DragonFly: src/games/hack/hack.objnam.c,v 1.3 2005/05/22 03:37:05 y0netan1 Exp $ */ +/* $DragonFly: src/games/hack/hack.objnam.c,v 1.4 2006/08/21 19:45:32 pavalos Exp $ */ #include "hack.h" #define Sprintf (void) sprintf #define Strcat (void) strcat #define Strcpy (void) strcpy #define PREFIX 15 -extern char *eos(); extern int bases[]; -char * -strprepend(s,pref) char *s, *pref; { +static char *strprepend(char *, char *); +static char *sitoa(int); + +static char * +strprepend(char *s, char *pref) +{ int i = strlen(pref); if(i > PREFIX) { pline("WARNING: prefix too short."); return(s); } s -= i; - (void) strncpy(s, pref, i); /* do not copy trailing 0 */ + strncpy(s, pref, i); /* do not copy trailing 0 */ return(s); } -char * -sitoa(a) int a; { +static char * +sitoa(int a) +{ static char buf[13]; Sprintf(buf, (a < 0) ? "%d" : "+%d", a); return(buf); } char * -typename(otyp) -int otyp; +typename(int otyp) { static char buf[BUFSZ]; struct objclass *ocl = &objects[otyp]; @@ -82,8 +85,7 @@ int nn = ocl->oc_name_known; } char * -xname(obj) -struct obj *obj; +xname(struct obj *obj) { static char bufr[BUFSZ]; char *buf = &(bufr[PREFIX]); /* leave room for "17 -3 " */ @@ -242,8 +244,7 @@ nopl: } char * -doname(obj) -struct obj *obj; +doname(struct obj *obj) { char prefix[PREFIX]; char *bp = xname(obj); @@ -290,8 +291,8 @@ char *bp = xname(obj); } /* used only in hack.fight.c (thitu) */ -setan(str,buf) -char *str,*buf; +void +setan(const char *str, char *buf) { if(index(vowels,*str)) Sprintf(buf, "an %s", str); @@ -300,7 +301,8 @@ char *str,*buf; } char * -aobjnam(otmp,verb) struct obj *otmp; char *verb; { +aobjnam(struct obj *otmp, const char *verb) +{ char *bp = xname(otmp); char prefix[PREFIX]; if(otmp->quan != 1) { @@ -324,8 +326,7 @@ char prefix[PREFIX]; } char * -Doname(obj) -struct obj *obj; +Doname(struct obj *obj) { char *s = doname(obj); @@ -337,20 +338,19 @@ static const char *wrp[] = { "wand", "ring", "potion", "scroll", "gem" }; char wrpsym[] = { WAND_SYM, RING_SYM, POTION_SYM, SCROLL_SYM, GEM_SYM }; struct obj * -readobjnam(bp) char *bp; { +readobjnam(char *bp) +{ char *p; int i; int cnt, spe, spesgn, typ, heavy; char let; char *un, *dn, *an; -/* int the = 0; char *oname = 0; */ cnt = spe = spesgn = typ = heavy = 0; let = 0; an = dn = un = 0; for(p = bp; *p; p++) if('A' <= *p && *p <= 'Z') *p += 'a'-'A'; if(!strncmp(bp, "the ", 4)){ -/* the = 1; */ bp += 4; } else if(!strncmp(bp, "an ", 3)){ cnt = 1; @@ -395,7 +395,6 @@ char *un, *dn, *an; */ for(p = bp; *p; p++) if(!strncmp(p, " named ", 7)) { *p = 0; -/* oname = p+7; */ } for(p = bp; *p; p++) if(!strncmp(p, " called ", 8)) { *p = 0; @@ -410,7 +409,7 @@ char *un, *dn, *an; if(cnt != 1) { /* find "cloves of garlic", "worthless pieces of blue glass" */ for(p = bp; *p; p++) if(!strncmp(p, "s of ", 5)){ - while(*p = p[1]) p++; + while((*p = p[1])) p++; goto sing; } /* remove -s or -es (boxes) or -ies (rubies, zruties) */ @@ -461,7 +460,7 @@ sing: an = bp; goto srch; } - for(i = 0; i < sizeof(wrpsym); i++) { + for(i = 0; (unsigned)i < sizeof(wrpsym); i++) { int j = strlen(wrp[i]); if(!strncmp(bp, wrp[i], j)){ let = wrpsym[i]; @@ -516,7 +515,6 @@ any: typ = probtype(let); typfnd: { struct obj *otmp; - extern struct obj *mksobj(); let = objects[typ].oc_olet; otmp = mksobj(typ); if(heavy) diff --git a/games/hack/hack.options.c b/games/hack/hack.options.c index 0bd918b8a9..fc0dc51f8b 100644 --- a/games/hack/hack.options.c +++ b/games/hack/hack.options.c @@ -1,14 +1,14 @@ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* hack.options.c - version 1.0.3 */ /* $FreeBSD: src/games/hack/hack.options.c,v 1.5 1999/11/16 02:57:08 billf Exp $ */ -/* $DragonFly: src/games/hack/hack.options.c,v 1.2 2003/06/17 04:25:24 dillon Exp $ */ +/* $DragonFly: src/games/hack/hack.options.c,v 1.3 2006/08/21 19:45:32 pavalos Exp $ */ -#include -#include "config.h" #include "hack.h" -extern char *eos(); -initoptions() +static void parseoptions(char *, bool); + +void +initoptions(void) { char *opts; @@ -20,23 +20,22 @@ initoptions() flags.end_around = 4; flags.female = FALSE; /* players are usually male */ - if(opts = getenv("HACKOPTIONS")) + if((opts = getenv("HACKOPTIONS"))) parseoptions(opts,TRUE); } -parseoptions(opts, from_env) -char *opts; -boolean from_env; +static void +parseoptions(char *opts, bool from_env) { char *op,*op2; unsigned num; boolean negated; - if(op = index(opts, ',')) { + if((op = index(opts, ','))) { *op++ = 0; parseoptions(op, from_env); } - if(op = index(opts, ' ')) { + if((op = index(opts, ' '))) { op2 = op; while(*op++) if(*op != ' ') *op2++ = *op; @@ -98,14 +97,13 @@ boolean from_env; /* name:string */ if(!strncmp(opts,"name",4)) { - extern char plname[PL_NSIZ]; if(!from_env) { pline("The playername can be set only from HACKOPTIONS."); return; } op = index(opts,':'); if(!op) goto bad; - (void) strncpy(plname, op+1, sizeof(plname)-1); + strncpy(plname, op+1, sizeof(plname)-1); return; } @@ -173,26 +171,27 @@ bad: getret(); } -doset() +int +doset(void) { char buf[BUFSZ]; pline("What options do you want to set? "); getlin(buf); if(!buf[0] || buf[0] == '\033') { - (void) strcpy(buf,"HACKOPTIONS="); - (void) strcat(buf, flags.female ? "female," : "male,"); - if(flags.standout) (void) strcat(buf,"standout,"); - if(flags.nonull) (void) strcat(buf,"nonull,"); - if(flags.nonews) (void) strcat(buf,"nonews,"); - if(flags.time) (void) strcat(buf,"time,"); - if(flags.notombstone) (void) strcat(buf,"notombstone,"); + strcpy(buf,"HACKOPTIONS="); + strcat(buf, flags.female ? "female," : "male,"); + if(flags.standout) strcat(buf,"standout,"); + if(flags.nonull) strcat(buf,"nonull,"); + if(flags.nonews) strcat(buf,"nonews,"); + if(flags.time) strcat(buf,"time,"); + if(flags.notombstone) strcat(buf,"notombstone,"); if(flags.no_rest_on_space) - (void) strcat(buf,"!rest_on_space,"); + strcat(buf,"!rest_on_space,"); if(flags.end_top != 5 || flags.end_around != 4 || flags.end_own){ - (void) sprintf(eos(buf), "endgame: %u topscores/%u around me", + sprintf(eos(buf), "endgame: %u topscores/%u around me", flags.end_top, flags.end_around); - if(flags.end_own) (void) strcat(buf, "/own scores"); + if(flags.end_own) strcat(buf, "/own scores"); } else { char *eop = eos(buf); if(*--eop == ',') *eop = 0; diff --git a/games/hack/hack.pager.c b/games/hack/hack.pager.c index 42d1d4036e..7c411066e3 100644 --- a/games/hack/hack.pager.c +++ b/games/hack/hack.pager.c @@ -1,7 +1,7 @@ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* hack.pager.c - version 1.0.3 */ /* $FreeBSD: src/games/hack/hack.pager.c,v 1.7 1999/11/16 02:57:09 billf Exp $ */ -/* $DragonFly: src/games/hack/hack.pager.c,v 1.3 2004/11/06 12:29:17 eirikn Exp $ */ +/* $DragonFly: src/games/hack/hack.pager.c,v 1.4 2006/08/21 19:45:32 pavalos Exp $ */ /* This file contains the command routine dowhatis() and a pager. */ /* Also readmail() and doshell(), and generally the things that @@ -9,21 +9,20 @@ #include #include -#include -#include -#include #include "hack.h" extern int CO, LI; /* usually COLNO and ROWNO+2 */ extern char *CD; extern char quitchars[]; -void done1(); -dowhatis() +static void intruph(int); +static void page_more(FILE *, int); + +int +dowhatis(void) { FILE *fp; char bufr[BUFSZ+6]; char *buf = &bufr[6], *ep, q; - extern char readchar(); if(!(fp = fopen(DATAFILE, "r"))) pline("Cannot open data file!"); @@ -40,7 +39,7 @@ dowhatis() if(buf[1] == '\t'){ buf = bufr; buf[0] = q; - (void) strncpy(buf+1, " ", 7); + strncpy(buf+1, " ", 7); } pline(buf); if(ep[-1] == ';') { @@ -50,11 +49,11 @@ dowhatis() return(0); } } - (void) fclose(fp); /* kopper@psuvax1 */ + fclose(fp); /* kopper@psuvax1 */ return(0); } pline("I've never heard of such things."); - (void) fclose(fp); + fclose(fp); } return(0); } @@ -62,15 +61,16 @@ dowhatis() /* make the paging of a file interruptible */ static int got_intrup; -void -intruph(){ +static void +intruph(__unused int unused) +{ got_intrup++; } /* simple pager, also used from dohelp() */ -page_more(fp,strip) -FILE *fp; -int strip; /* nr of chars to be stripped from each line (0 or 1) */ +/* strip = nr of chars to be stripped from each line (0 or 1) */ +static void +page_more(FILE *fp, int strip) { char *bufr, *ep; sig_t prevsig = signal(SIGINT, intruph); @@ -90,20 +90,24 @@ int strip; /* nr of chars to be stripped from each line (0 or 1) */ set_pager(1); ret: free(bufr); - (void) fclose(fp); - (void) signal(SIGINT, prevsig); + fclose(fp); + signal(SIGINT, prevsig); got_intrup = 0; } static boolean whole_screen = TRUE; #define PAGMIN 12 /* minimum # of lines for page below level map */ -set_whole_screen() { /* called in termcap as soon as LI is known */ +void +set_whole_screen(void) /* called in termcap as soon as LI is known */ +{ whole_screen = (LI-ROWNO-2 <= PAGMIN || !CD); } #ifdef NEWS -readnews() { +bool +readnews(void) +{ int ret; whole_screen = TRUE; /* force a docrt(), our first */ @@ -113,8 +117,8 @@ readnews() { } #endif /* NEWS */ -set_pager(mode) -int mode; /* 0: open 1: wait+close 2: close */ +void +set_pager(int mode) /* 0: open 1: wait+close 2: close */ { static boolean so; if(mode == 0) { @@ -143,11 +147,9 @@ int mode; /* 0: open 1: wait+close 2: close */ } } -page_line(s) /* returns 1 if we should quit */ -char *s; +bool +page_line(const char *s) /* returns 1 if we should quit */ { - extern char morc; - if(cury == LI-1) { if(!*s) return(0); /* suppress blank lines at top */ @@ -181,9 +183,8 @@ char *s; * cornline(3, 0) : cleanup */ -cornline(mode, text) -int mode; -char *text; +void +cornline(int mode, const char *text) { static struct line { struct line *next_line; @@ -216,7 +217,7 @@ char *text; alloc((unsigned)(len + sizeof(struct line) + 1)); tl->next_line = 0; tl->line_text = (char *)(tl + 1); - (void) strcpy(tl->line_text, text); + strcpy(tl->line_text, text); if(!texthead) texthead = tl; else @@ -272,13 +273,14 @@ char *text; } cleanup: - while(tl = texthead) { + while((tl = texthead)) { texthead = tl->next_line; free((char *) tl); } } -dohelp() +int +dohelp(void) { char c; @@ -286,13 +288,13 @@ dohelp() while (((c = readchar ()) != 'l') && (c != 's') && !index(quitchars,c)) bell (); if (!index(quitchars, c)) - (void) page_file((c == 'l') ? HELP : SHELP, FALSE); + page_file((c == 'l') ? HELP : SHELP, FALSE); return(0); } -page_file(fnam, silent) /* return: 0 - cannot open fnam; 1 - otherwise */ -char *fnam; -boolean silent; +/* return: 0 - cannot open fnam; 1 - otherwise */ +bool +page_file(const char *fnam, bool silent) { #ifdef DEF_PAGER /* this implies that UNIX is defined */ { @@ -310,7 +312,7 @@ boolean silent; /* Now that child() does a setuid(getuid()) and a chdir(), we may not be able to open file fnam anymore, so make it stdin. */ - (void) close(0); + close(0); if(dup(fd)) { if(!silent) printf("Cannot open %s as stdin.\n", fnam); } else { @@ -319,7 +321,7 @@ boolean silent; } exit(1); } - (void) close(fd); + close(fd); } #else /* DEF_PAGER */ { @@ -341,10 +343,12 @@ boolean silent; #ifdef UNIX #ifdef SHELL -dosh(){ +int +dosh(void) +{ char *str; if(child(0)) { - if(str = getenv("SHELL")) + if((str = getenv("SHELL"))) execl(str, str, (char *) 0); else execl("/bin/sh", "sh", (char *) 0); @@ -374,7 +378,9 @@ union wait { /* used only for the cast (union wait *) 0 */ #endif /* BSD */ #endif /* NOWAITINCLUDE */ -child(wt) { +bool +child(bool wt) +{ int status; int f; @@ -384,7 +390,7 @@ child(wt) { /* revoke */ setgid(getgid()); #ifdef CHDIR - (void) chdir(getenv("HOME")); + chdir(getenv("HOME")); #endif /* CHDIR */ return(1); } @@ -393,14 +399,14 @@ child(wt) { return(0); } /* fork succeeded; wait for child to exit */ - (void) signal(SIGINT,SIG_IGN); - (void) signal(SIGQUIT,SIG_IGN); - (void) wait(&status); + signal(SIGINT,SIG_IGN); + signal(SIGQUIT,SIG_IGN); + wait(&status); gettty(); setftty(); - (void) signal(SIGINT,done1); + signal(SIGINT,done1); #ifdef WIZARD - if(wizard) (void) signal(SIGQUIT,SIG_DFL); + if(wizard) signal(SIGQUIT,SIG_DFL); #endif /* WIZARD */ if(wt) getret(); docrt(); diff --git a/games/hack/hack.potion.c b/games/hack/hack.potion.c index 2e8702318e..6245cf2fe6 100644 --- a/games/hack/hack.potion.c +++ b/games/hack/hack.potion.c @@ -1,14 +1,16 @@ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* hack.potion.c - version 1.0.3 */ /* $FreeBSD: src/games/hack/hack.potion.c,v 1.5 1999/11/16 10:26:37 marcel Exp $ */ -/* $DragonFly: src/games/hack/hack.potion.c,v 1.3 2005/05/22 03:37:05 y0netan1 Exp $ */ +/* $DragonFly: src/games/hack/hack.potion.c,v 1.4 2006/08/21 19:45:32 pavalos Exp $ */ #include "hack.h" -extern int float_down(); extern struct monst youmonst; -extern struct monst *makemon(); -dodrink() { +static void ghost_from_bottle(void); + +int +dodrink(void) +{ struct obj *otmp,*objs; struct monst *mtmp; int unkn = 0, nothing = 0; @@ -189,7 +191,8 @@ use_it: return(1); } -pluslvl() +void +pluslvl(void) { int num; @@ -198,17 +201,14 @@ pluslvl() u.uhpmax += num; u.uhp += num; if(u.ulevel < 14) { - extern long newuexp(); - u.uexp = newuexp()+1; pline("Welcome to experience level %u.", ++u.ulevel); } flags.botl = 1; } -strange_feeling(obj,txt) -struct obj *obj; -char *txt; +void +strange_feeling(struct obj *obj, const char *txt) { if(flags.beginner) pline("You have a strange feeling for a moment, then it passes."); @@ -223,11 +223,9 @@ static const char *bottlenames[] = { "bottle", "phial", "flagon", "carafe", "flask", "jar", "vial" }; -potionhit(mon, obj) -struct monst *mon; -struct obj *obj; +void +potionhit(struct monst *mon, struct obj *obj) { - extern char *xname(); const char *botlnam = bottlenames[rn2(SIZE(bottlenames))]; boolean uclose, isyou = (mon == &youmonst); @@ -295,8 +293,8 @@ struct obj *obj; obfree(obj, Null(obj)); } -potionbreathe(obj) -struct obj *obj; +void +potionbreathe(struct obj *obj) { switch(obj->otyp) { case POT_RESTORE_STRENGTH: @@ -354,7 +352,9 @@ struct obj *obj; * -- If the flask is small, can one dip a large object? Does it magically * -- become a jug? Etc. */ -dodip(){ +int +dodip(void) +{ struct obj *potion, *obj; if(!(obj = getobj("#", "dip"))) @@ -372,8 +372,9 @@ dodip(){ return(1); } -ghost_from_bottle(){ - extern struct permonst pm_ghost; +static void +ghost_from_bottle(void) +{ struct monst *mtmp; if(!(mtmp = makemon(PM_GHOST,u.ux,u.uy))){ diff --git a/games/hack/hack.pri.c b/games/hack/hack.pri.c index aab15d4c06..f18317ad35 100644 --- a/games/hack/hack.pri.c +++ b/games/hack/hack.pri.c @@ -1,15 +1,21 @@ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* hack.pri.c - version 1.0.3 */ /* $FreeBSD: src/games/hack/hack.pri.c,v 1.5 1999/11/16 10:26:37 marcel Exp $ */ -/* $DragonFly: src/games/hack/hack.pri.c,v 1.4 2005/05/22 03:37:05 y0netan1 Exp $ */ +/* $DragonFly: src/games/hack/hack.pri.c,v 1.5 2006/08/21 19:45:32 pavalos Exp $ */ #include "hack.h" -#include +#include xchar scrlx, scrhx, scrly, scrhy; /* corners of new area on screen */ extern char *CD; -swallowed() +#ifdef NEWSCR +static void pobj(struct obj *); +#endif +static void cornbot(int); + +void +swallowed(void) { char ulook[] = {"|@|"}; ulook[1] = u.usym; @@ -33,14 +39,18 @@ swallowed() /*VARARGS1*/ boolean panicking; -panic(str,a1,a2,a3,a4,a5,a6) -char *str; +void +panic(const char *str, ...) { + va_list ap; + if(panicking++) exit(1); /* avoid loops - this should never happen*/ home(); puts(" Suddenly, the dungeon collapses."); fputs(" ERROR: ", stdout); - printf(str,a1,a2,a3,a4,a5,a6); + va_start(ap, str); + vprintf(str, ap); + va_end(ap); #ifdef DEBUG #ifdef UNIX if(!fork()) @@ -51,8 +61,8 @@ char *str; done("panicked"); } -atl(x,y,ch) -int x,y; +void +atl(int x, int y, char ch) { struct rm *crm = &levl[x][y]; @@ -66,8 +76,8 @@ int x,y; on_scr(x,y); } -on_scr(x,y) -int x,y; +void +on_scr(int x, int y) { if(x < scrlx) scrlx = x; if(x > scrhx) scrhx = x; @@ -82,7 +92,9 @@ int x,y; (-2,let)-change let */ -tmp_at(x,y) schar x,y; { +void +tmp_at(schar x, schar y) +{ static schar prevx, prevy; static char let; if((int)x == -2){ /* change let call */ @@ -110,7 +122,9 @@ static char let; } /* like the previous, but the symbols are first erased on completion */ -Tmp_at(x,y) schar x,y; { +void +Tmp_at(schar x, schar y) +{ static char let; static xchar cnt; static coord tc[COLNO]; /* but watch reflecting beams! */ @@ -146,14 +160,15 @@ int xx,yy; } } -setclipped(){ +void +setclipped(void) +{ error("Hack needs a screen of size at least %d by %d.\n", ROWNO+2, COLNO); } -at(x,y,ch) -xchar x,y; -char ch; +void +at(xchar x, xchar y, char ch) { #ifndef lint /* if xchar is unsigned, lint will complain about if(x < 0) */ @@ -168,21 +183,25 @@ char ch; } y += 2; curs(x,y); - (void) putchar(ch); + putchar(ch); curx++; } -prme(){ +void +prme(void) +{ if(!Invisible) at(u.ux,u.uy,u.usym); } -doredraw() +int +doredraw(void) { docrt(); return(0); } -docrt() +void +docrt(void) { int x,y; struct rm *room; @@ -221,7 +240,9 @@ docrt() bot(); } -docorner(xmin,ymax) int xmin,ymax; { +void +docorner(int xmin, int ymax) +{ int x,y; struct rm *room; struct monst *mtmp; @@ -261,16 +282,18 @@ docorner(xmin,ymax) int xmin,ymax; { } } -curs_on_u(){ +void +curs_on_u(void) +{ curs(u.ux, u.uy+2); } -pru() +void +pru(void) { if(u.udispl && (Invisible || u.udisx != u.ux || u.udisy != u.uy)) - /* if(! levl[u.udisx][u.udisy].new) */ - if(!vism_at(u.udisx, u.udisy)) - newsym(u.udisx, u.udisy); + if(!vism_at(u.udisx, u.udisy)) + newsym(u.udisx, u.udisy); if(Invisible) { u.udispl = 0; prl(u.ux,u.uy); @@ -285,12 +308,12 @@ pru() } #ifndef NOWORM -#include "def.wseg.h" extern struct wseg *m_atseg; #endif /* NOWORM */ /* print a position that is visible for @ */ -prl(x,y) +void +prl(int x, int y) { struct rm *room; struct monst *mtmp; @@ -332,8 +355,7 @@ prl(x,y) } char -news0(x,y) -xchar x,y; +news0(xchar x, xchar y) { struct obj *otmp; struct trap *ttmp; @@ -370,27 +392,22 @@ xchar x,y; if(room->lit || cansee(x,y) || Blind) tmp = '.'; else tmp = ' '; break; -/* - case POOL: - tmp = POOL_SYM; - break; -*/ default: tmp = ERRCHAR; } return(tmp); } -newsym(x,y) -int x,y; +void +newsym(int x, int y) { atl(x,y,news0(x,y)); } /* used with wand of digging (or pick-axe): fill scrsym and force display */ /* also when a POOL evaporates */ -mnewsym(x,y) -int x,y; +void +mnewsym(int x, int y) { struct rm *room; char newscrsym; @@ -405,8 +422,8 @@ int x,y; } } -nosee(x,y) -int x,y; +void +nosee(int x, int y) { struct rm *room; @@ -420,8 +437,8 @@ int x,y; } #ifndef QUEST -prl1(x,y) -int x,y; +void +prl1(int x, int y) { if(u.dx) { if(u.dy) { @@ -442,8 +459,8 @@ int x,y; } } -nose1(x,y) -int x,y; +void +nose1(int x, int y) { if(u.dx) { if(u.dy) { @@ -465,8 +482,8 @@ int x,y; } #endif /* QUEST */ -vism_at(x,y) -int x,y; +bool +vism_at(int x, int y) { struct monst *mtmp; @@ -478,7 +495,9 @@ int x,y; } #ifdef NEWSCR -pobj(obj) struct obj *obj; { +static void +pobj(struct obj *obj) +{ int show = (!obj->oinvis || See_invisible) && cansee(obj->ox,obj->oy); if(obj->odispl){ @@ -497,18 +516,16 @@ int show = (!obj->oinvis || See_invisible) && } #endif /* NEWSCR */ -unpobj(obj) struct obj *obj; { -/* if(obj->odispl){ - if(!vism_at(obj->odx, obj->ody)) - newsym(obj->odx, obj->ody); - obj->odispl = 0; - } -*/ +void +unpobj(struct obj *obj) +{ if(!vism_at(obj->ox,obj->oy)) newsym(obj->ox,obj->oy); } -seeobjs(){ +void +seeobjs(void) +{ struct obj *obj, *obj2; for(obj = fobj; obj; obj = obj2) { obj2 = obj->nobj; @@ -524,7 +541,9 @@ struct obj *obj, *obj2; } } -seemons(){ +void +seemons(void) +{ struct monst *mtmp; for(mtmp = fmon; mtmp; mtmp = mtmp->nmon){ if(mtmp->data->mlet == ';') @@ -537,7 +556,9 @@ struct monst *mtmp; } } -pmon(mon) struct monst *mon; { +void +pmon(struct monst *mon) +{ int show = (Blind && Telepat) || canseemon(mon); if(mon->mdispl){ if(mon->mdx != mon->mx || mon->mdy != mon->my || !show) @@ -554,14 +575,17 @@ int show = (Blind && Telepat) || canseemon(mon); } } -unpmon(mon) struct monst *mon; { +void +unpmon(struct monst *mon) +{ if(mon->mdispl){ newsym(mon->mdx, mon->mdy); mon->mdispl = 0; } } -nscr() +void +nscr(void) { int x,y; struct rm *room; @@ -581,46 +605,47 @@ nscr() /* 100 suffices for bot(); no relation with COLNO */ char oldbot[100], newbot[100]; -cornbot(lth) -int lth; + +static void +cornbot(int lth) { - if(lth < sizeof(oldbot)) { + if(lth < (int)sizeof(oldbot)) { oldbot[lth] = 0; flags.botl = 1; } } -bot() +void +bot(void) { char *ob = oldbot, *nb = newbot; int i; -extern char *eos(); if(flags.botlx) *ob = 0; flags.botl = flags.botlx = 0; #ifdef GOLD_ON_BOTL - (void) sprintf(newbot, + sprintf(newbot, "Level %-2d Gold %-5lu Hp %3d(%d) Ac %-2d Str ", dlevel, u.ugold, u.uhp, u.uhpmax, u.uac); #else - (void) sprintf(newbot, + sprintf(newbot, "Level %-2d Hp %3d(%d) Ac %-2d Str ", dlevel, u.uhp, u.uhpmax, u.uac); #endif /* GOLD_ON_BOTL */ if(u.ustr>18) { if(u.ustr>117) - (void) strcat(newbot,"18/**"); + strcat(newbot,"18/**"); else - (void) sprintf(eos(newbot), "18/%02d",u.ustr-18); + sprintf(eos(newbot), "18/%02d",u.ustr-18); } else - (void) sprintf(eos(newbot), "%-2d ",u.ustr); + sprintf(eos(newbot), "%-2d ",u.ustr); #ifdef EXP_ON_BOTL - (void) sprintf(eos(newbot), " Exp %2d/%-5lu ", u.ulevel,u.uexp); + sprintf(eos(newbot), " Exp %2d/%-5lu ", u.ulevel,u.uexp); #else - (void) sprintf(eos(newbot), " Exp %2u ", u.ulevel); + sprintf(eos(newbot), " Exp %2u ", u.ulevel); #endif /* EXP_ON_BOTL */ - (void) strcat(newbot, hu_stat[u.uhs]); + strcat(newbot, hu_stat[u.uhs]); if(flags.time) - (void) sprintf(eos(newbot), " %ld", moves); + sprintf(eos(newbot), " %ld", moves); if(strlen(newbot) >= COLNO) { char *bp0, *bp1; bp0 = bp1 = newbot; @@ -632,17 +657,19 @@ extern char *eos(); for(i = 1; idata->mlevel, mtmp->mgold, mtmp->mhp, mtmp->mhpmax, @@ -650,7 +677,9 @@ mstatusline(mtmp) struct monst *mtmp; { } #endif /* WAN_PROBING */ -cls(){ +void +cls(void) +{ if(flags.toplin == 1) more(); flags.toplin = 0; diff --git a/games/hack/hack.read.c b/games/hack/hack.read.c index cd23f0aecd..8c898b7229 100644 --- a/games/hack/hack.read.c +++ b/games/hack/hack.read.c @@ -1,19 +1,18 @@ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* hack.read.c - version 1.0.3 */ /* $FreeBSD: src/games/hack/hack.read.c,v 1.6 1999/11/16 10:26:37 marcel Exp $ */ -/* $DragonFly: src/games/hack/hack.read.c,v 1.3 2004/11/06 12:29:17 eirikn Exp $ */ +/* $DragonFly: src/games/hack/hack.read.c,v 1.4 2006/08/21 19:45:32 pavalos Exp $ */ #include "hack.h" -extern struct monst *makemon(); -extern struct obj *mkobj_at(); -int identify(); +static bool monstersym(char); -doread() { +int +doread(void) +{ struct obj *scroll; boolean confused = (Confusion != 0); boolean known = FALSE; - extern struct obj *some_armor(); scroll = getobj("?", "read"); if(!scroll) return(0); @@ -147,7 +146,7 @@ doread() { if(!rn2(73)) cnt += rnd(4); if(confused) cnt += 12; while(cnt--) - (void) makemon(confused ? PM_ACID_BLOB : + makemon(confused ? PM_ACID_BLOB : (struct permonst *) 0, u.ux, u.uy); break; } @@ -175,12 +174,12 @@ doread() { struct monst *mtmp; for(i = -bd; i <= bd; i++) for(j = -bd; j <= bd; j++) - if(mtmp = m_at(u.ux+i, u.uy+j)) - (void) tamedog(mtmp, (struct obj *) 0); + if((mtmp = m_at(u.ux+i, u.uy+j))) + tamedog(mtmp, (struct obj *) 0); break; } case SCR_GENOCIDE: - { extern char genocided[], fut_geno[]; + { char buf[BUFSZ]; struct monst *mtmp, *mtmp2; @@ -374,7 +373,7 @@ doread() { break; } case SCR_FIRE: - { int num; + { int num = 0; struct monst *mtmp; known = TRUE; @@ -437,8 +436,8 @@ doread() { return(1); } -identify(otmp) /* also called by newmail() */ -struct obj *otmp; +int +identify(struct obj *otmp) /* also called by newmail() */ { objects[otmp->otyp].oc_name_known = 1; otmp->known = otmp->dknown = 1; @@ -446,8 +445,8 @@ struct obj *otmp; return(1); } -litroom(on) -boolean on; +void +litroom(bool on) { int num,zx,zy; @@ -521,11 +520,10 @@ do_it: } /* Test whether we may genocide all monsters with symbol ch */ -monstersym(ch) /* arnold@ucsfcgl */ -char ch; +static bool +monstersym(char ch) /* arnold@ucsfcgl */ { struct permonst *mp; - extern struct permonst pm_eel; /* * can't genocide certain monsters diff --git a/games/hack/hack.rip.c b/games/hack/hack.rip.c index b77305568c..a5541b832e 100644 --- a/games/hack/hack.rip.c +++ b/games/hack/hack.rip.c @@ -1,13 +1,11 @@ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* hack.rip.c - version 1.0.2 */ /* $FreeBSD: src/games/hack/hack.rip.c,v 1.4 1999/11/16 10:26:37 marcel Exp $ */ -/* $DragonFly: src/games/hack/hack.rip.c,v 1.3 2005/05/22 03:37:05 y0netan1 Exp $ */ +/* $DragonFly: src/games/hack/hack.rip.c,v 1.4 2006/08/21 19:45:32 pavalos Exp $ */ -#include #include "hack.h" -static void center(int , const char *); -extern char plname[]; +static void center(int, const char *); static char rip[][60] = { " ----------", @@ -27,23 +25,25 @@ static char rip[][60] = { }; static const int n_rips = sizeof(rip) / sizeof(rip[0]); -outrip(){ +void +outrip(void) +{ char *dpx; char buf[BUFSZ]; - int i, x, y; + int j, x, y; cls(); - (void) strcpy(buf, plname); + strcpy(buf, plname); buf[16] = 0; center(6, buf); - (void) sprintf(buf, "%ld AU", u.ugold); + sprintf(buf, "%ld AU", u.ugold); center(7, buf); - (void) sprintf(buf, "killed by%s", + sprintf(buf, "killed by%s", !strncmp(killer, "the ", 4) ? "" : !strcmp(killer, "starvation") ? "" : index(vowels, *killer) ? " an" : " a"); center(8, buf); - (void) strcpy(buf, killer); + strcpy(buf, killer); if(strlen(buf) > 16) { int i,i0,i1; i0 = i1 = 0; @@ -55,20 +55,19 @@ outrip(){ buf[i0] = 0; } center(9, buf); - (void) sprintf(buf, "%4d", getyear()); + sprintf(buf, "%4d", getyear()); center(11, buf); - for(y = 8, i = 0; i < n_rips; y++, i++){ + for(y = 8, j = 0; j < n_rips; y++, j++){ x = 0; - dpx = rip[i]; + dpx = rip[j]; while(dpx[x]) { while(dpx[x] == ' ') x++; curs(x,y); while(dpx[x] && dpx[x] != ' '){ - extern int done_stopprint; if(done_stopprint) return; curx++; - (void) putchar(dpx[x++]); + putchar(dpx[x++]); } } } diff --git a/games/hack/hack.rumors.c b/games/hack/hack.rumors.c index 98654a9c23..a251e14693 100644 --- a/games/hack/hack.rumors.c +++ b/games/hack/hack.rumors.c @@ -1,18 +1,22 @@ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* hack.rumors.c - version 1.0.3 */ /* $FreeBSD: src/games/hack/hack.rumors.c,v 1.3 1999/11/16 02:57:10 billf Exp $ */ -/* $DragonFly: src/games/hack/hack.rumors.c,v 1.2 2003/06/17 04:25:24 dillon Exp $ */ +/* $DragonFly: src/games/hack/hack.rumors.c,v 1.3 2006/08/21 19:45:32 pavalos Exp $ */ -#include #include "hack.h" /* for RUMORFILE and BSD (index) */ #define CHARSZ 8 /* number of bits in a char */ -extern long *alloc(); -extern char *index(); int n_rumors = 0; int n_used_rumors = -1; char *usedbits; -init_rumors(rumf) FILE *rumf; { +static void init_rumors(FILE *); +static bool skipline(FILE *); +static void outline(FILE *); +static bool used(int); + +static void +init_rumors(FILE *rumf) +{ int i; n_used_rumors = 0; while(skipline(rumf)) n_rumors++; @@ -22,7 +26,9 @@ int i; for( ; i>=0; i--) usedbits[i] = 0; } -skipline(rumf) FILE *rumf; { +static bool +skipline(FILE *rumf) +{ char line[COLNO]; while(1) { if(!fgets(line, sizeof(line), rumf)) return(0); @@ -30,7 +36,9 @@ char line[COLNO]; } } -outline(rumf) FILE *rumf; { +static void +outline(FILE *rumf) +{ char line[COLNO]; char *ep; if(!fgets(line, sizeof(line), rumf)) return; @@ -39,7 +47,9 @@ char *ep; pline(line); } -outrumor(){ +void +outrumor(void) +{ int rn,i; FILE *rumf; if(n_rumors <= n_used_rumors || @@ -49,7 +59,7 @@ FILE *rumf; rn = rn2(n_rumors - n_used_rumors); i = 0; while(rn || used(i)) { - (void) skipline(rumf); + skipline(rumf); if(!used(i)) rn--; i++; } @@ -57,9 +67,11 @@ FILE *rumf; n_used_rumors++; outline(rumf); none: - (void) fclose(rumf); + fclose(rumf); } -used(i) int i; { +static bool +used(int i) +{ return(usedbits[i/CHARSZ] & (1 << (i % CHARSZ))); } diff --git a/games/hack/hack.save.c b/games/hack/hack.save.c index 145b7ad53a..23f91004fa 100644 --- a/games/hack/hack.save.c +++ b/games/hack/hack.save.c @@ -1,46 +1,45 @@ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* hack.save.c - version 1.0.3 */ /* $FreeBSD: src/games/hack/hack.save.c,v 1.4 1999/11/16 10:26:37 marcel Exp $ */ -/* $DragonFly: src/games/hack/hack.save.c,v 1.3 2004/11/06 12:29:17 eirikn Exp $ */ +/* $DragonFly: src/games/hack/hack.save.c,v 1.4 2006/08/21 19:45:32 pavalos Exp $ */ #include "hack.h" -extern char genocided[60]; /* defined in Decl.c */ -extern char fut_geno[60]; /* idem */ -#include -#include extern char SAVEF[], nul[]; -extern char pl_character[PL_CSIZ]; -extern struct obj *restobjchn(); -extern struct monst *restmonchn(); -dosave(){ +static bool dosave0(int); + +int +dosave(void) +{ if(dosave0(0)) { settty("Be seeing you ...\n"); exit(0); } -#ifdef lint return(0); -#endif /* lint */ } #ifndef NOSAVEONHANGUP -hangup(){ - (void) dosave0(1); +void +hangup(__unused int unused) +{ + dosave0(1); exit(1); } #endif /* NOSAVEONHANGUP */ /* returns 1 if save successful */ -dosave0(hu) int hu; { +static bool +dosave0(int hu) +{ int fd, ofd; int tmp; /* not ! */ - (void) signal(SIGHUP, SIG_IGN); - (void) signal(SIGINT, SIG_IGN); + signal(SIGHUP, SIG_IGN); + signal(SIGINT, SIG_IGN); if((fd = creat(SAVEF, FMASK)) < 0) { if(!hu) pline("Cannot open save file. (Continue or Quit)"); - (void) unlink(SAVEF); /* ab@unido */ + unlink(SAVEF); /* ab@unido */ return(0); } if(flags.moonphase == FULL_MOON) /* ut-sally!fletcher */ @@ -63,40 +62,36 @@ dosave0(hu) int hu; { bwrite(fd, (char *) fut_geno, sizeof fut_geno); savenames(fd); for(tmp = 1; tmp <= maxdlevel; tmp++) { - extern int hackpid; - extern boolean level_exists[]; - if(tmp == dlevel || !level_exists[tmp]) continue; glo(tmp); if((ofd = open(lock, 0)) < 0) { if(!hu) pline("Error while saving: cannot read %s.", lock); - (void) close(fd); - (void) unlink(SAVEF); + close(fd); + unlink(SAVEF); if(!hu) done("tricked"); return(0); } getlev(ofd, hackpid, tmp); - (void) close(ofd); + close(ofd); bwrite(fd, (char *) &tmp, sizeof tmp); /* level number */ savelev(fd,tmp); /* actual level */ - (void) unlink(lock); + unlink(lock); } - (void) close(fd); + close(fd); glo(dlevel); - (void) unlink(lock); /* get rid of current level --jgm */ + unlink(lock); /* get rid of current level --jgm */ glo(0); - (void) unlink(lock); + unlink(lock); return(1); } -dorecover(fd) -int fd; +bool +dorecover(int fd) { int nfd; int tmp; /* not a ! */ unsigned mid; /* idem */ struct obj *otmp; - extern boolean restoring; restoring = TRUE; getlev(fd, 0, 0); @@ -107,9 +102,9 @@ int fd; fcobj = restobjchn(fd); fallen_down = restmonchn(fd); mread(fd, (char *) &tmp, sizeof tmp); - if(tmp != getuid()) { /* strange ... */ - (void) close(fd); - (void) unlink(SAVEF); + if(tmp != (int)getuid()) { /* strange ... */ + close(fd); + unlink(SAVEF); puts("Saved game was not yours."); restoring = FALSE; return(0); @@ -133,12 +128,12 @@ int fd; if((nfd = creat(lock, FMASK)) < 0) panic("Cannot open temp file %s!\n", lock); savelev(nfd,tmp); - (void) close(nfd); + close(nfd); } - (void) lseek(fd, (off_t)0, 0); + lseek(fd, (off_t)0, 0); getlev(fd, 0, 0); - (void) close(fd); - (void) unlink(SAVEF); + close(fd); + unlink(SAVEF); if(Punished) { for(otmp = fobj; otmp; otmp = otmp->nobj) if(otmp->olet == CHAIN_SYM) goto chainfnd; @@ -172,16 +167,13 @@ int fd; } struct obj * -restobjchn(fd) -int fd; +restobjchn(int fd) { struct obj *otmp, *otmp2; struct obj *first = 0; int xl; -#ifdef lint /* suppress "used before set" warning from lint */ otmp2 = 0; -#endif /* lint */ while(1) { mread(fd, (char *) &xl, sizeof(xl)); if(xl == -1) break; @@ -200,8 +192,7 @@ int fd; } struct monst * -restmonchn(fd) -int fd; +restmonchn(int fd) { struct monst *mtmp, *mtmp2; struct monst *first = 0; @@ -213,10 +204,8 @@ int fd; mread(fd, (char *)&monbegin, sizeof(monbegin)); differ = (char *)(&mons[0]) - (char *)(monbegin); -#ifdef lint /* suppress "used before set" warning from lint */ mtmp2 = 0; -#endif /* lint */ while(1) { mread(fd, (char *) &xl, sizeof(xl)); if(xl == -1) break; diff --git a/games/hack/hack.search.c b/games/hack/hack.search.c index 03e6c18da5..a86217da1a 100644 --- a/games/hack/hack.search.c +++ b/games/hack/hack.search.c @@ -1,13 +1,12 @@ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* hack.search.c - version 1.0.3 */ /* $FreeBSD: src/games/hack/hack.search.c,v 1.3 1999/11/16 02:57:11 billf Exp $ */ -/* $DragonFly: src/games/hack/hack.search.c,v 1.2 2003/06/17 04:25:24 dillon Exp $ */ +/* $DragonFly: src/games/hack/hack.search.c,v 1.3 2006/08/21 19:45:32 pavalos Exp $ */ #include "hack.h" -extern struct monst *makemon(); - -findit() /* returns number of things found */ +int +findit(void) /* returns number of things found */ { int num; xchar zx,zy; @@ -31,9 +30,9 @@ findit() /* returns number of things found */ levl[zx][zy].typ = CORR; atl(zx, zy, CORR_SYM); num++; - } else if(ttmp = t_at(zx, zy)) { + } else if((ttmp = t_at(zx, zy))) { if(ttmp->ttyp == PIERC){ - (void) makemon(PM_PIERCER, zx, zy); + makemon(PM_PIERCER, zx, zy); num++; deltrap(ttmp); } else if(!ttmp->tseen) { @@ -42,7 +41,7 @@ findit() /* returns number of things found */ atl(zx,zy,'^'); num++; } - } else if(mtmp = m_at(zx,zy)) if(mtmp->mimic){ + } else if((mtmp = m_at(zx,zy))) if(mtmp->mimic){ seemimic(mtmp); num++; } @@ -50,7 +49,8 @@ findit() /* returns number of things found */ return(num); } -dosearch() +int +dosearch(void) { xchar x,y; struct trap *trap; @@ -75,7 +75,7 @@ dosearch() nomul(0); } else { /* Be careful not to find anything in an SCORR or SDOOR */ - if(mtmp = m_at(x,y)) if(mtmp->mimic){ + if((mtmp = m_at(x,y))) if(mtmp->mimic){ seemimic(mtmp); pline("You find a mimic."); return(1); @@ -87,7 +87,7 @@ dosearch() pline("You find a%s.", traps[trap->ttyp]); if(trap->ttyp == PIERC) { deltrap(trap); - (void) makemon(PM_PIERCER,x,y); + makemon(PM_PIERCER,x,y); return(1); } trap->tseen = 1; @@ -98,7 +98,9 @@ dosearch() return(1); } -doidtrap() { +int +doidtrap(void) +{ struct trap *trap; int x,y; if(!getdir(1)) return(0); @@ -116,8 +118,8 @@ int x,y; return(0); } -wakeup(mtmp) -struct monst *mtmp; +void +wakeup(struct monst *mtmp) { mtmp->msleep = 0; setmangry(mtmp); @@ -125,8 +127,8 @@ struct monst *mtmp; } /* NOTE: we must check if(mtmp->mimic) before calling this routine */ -seemimic(mtmp) -struct monst *mtmp; +void +seemimic(struct monst *mtmp) { mtmp->mimic = 0; mtmp->mappearance = 0; diff --git a/games/hack/hack.shk.c b/games/hack/hack.shk.c index 7d0a5b9cc7..c409a9cbaf 100644 --- a/games/hack/hack.shk.c +++ b/games/hack/hack.shk.c @@ -1,42 +1,99 @@ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* hack.shk.c - version 1.0.3 */ /* $FreeBSD: src/games/hack/hack.shk.c,v 1.5 1999/11/16 10:26:37 marcel Exp $ */ -/* $DragonFly: src/games/hack/hack.shk.c,v 1.5 2005/05/22 03:37:05 y0netan1 Exp $ */ +/* $DragonFly: src/games/hack/hack.shk.c,v 1.6 2006/08/21 19:45:32 pavalos Exp $ */ #include "hack.h" #ifdef QUEST int shlevel = 0; struct monst *shopkeeper = 0; struct obj *billobjs = 0; -obfree(obj,merge) struct obj *obj, *merge; { + +void +obfree(struct obj *obj, struct obj *merge) +{ free((char *) obj); } -inshop(){ return(0); } -shopdig(){} -addtobill(){} -subfrombill(){} -splitbill(){} -dopay(){ return(0); } -paybill(){} -doinvbill(){ return(0); } -shkdead(){} -shkcatch(){ return(0); } -shk_move(){ return(0); } -replshk(mtmp,mtmp2) struct monst *mtmp, *mtmp2; {} -char *shkname(){ return(""); } + +int +inshop(void) +{ + return(0); +} + +void +shopdig(void) +{ +} + +void +addtobill(void) +{ +} + +void +subfrombill(void) +{ +} + +void +splitbill(void) +{ +} + +int +dopay(void) +{ + return(0); +} + +void +paybill(void) +{ +} + +int +doinvbill(void) +{ + return(0); +} + +void +shkdead(void) +{ +} + +int +shkcatch(void) +{ + return(0); +} + +int +shk_move(void) +{ + return(0); +} + +void +replshk(struct monst *mtmp, struct monst *mtmp2) +{ +} + +const char * +shkname(void) +{ + return(""); +} #else /* QUEST */ #include "hack.mfndpos.h" -#include "def.mkroom.h" #include "def.eshk.h" #define ESHK(mon) ((struct eshk *)(&(mon->mextra[0]))) #define NOTANGRY(mon) mon->mpeaceful #define ANGRY(mon) !NOTANGRY(mon) -extern char plname[], *xname(); -extern struct obj *o_on(), *bp_to_obj(); - /* Descriptor of current shopkeeper. Note that the bill need not be per-shopkeeper, since it is valid only when in a shop. */ static struct monst *shopkeeper = 0; @@ -64,17 +121,24 @@ static const char *shopnam[] = { "used armor", "assorted antiques" }; +static void setpaid(void); +static void addupbill(void); +static void findshk(int); +static struct bill_x *onbill(struct obj *); +static void pay(long, struct monst *); +static int dopayobj(struct bill_x *); +static struct obj *bp_to_obj(struct bill_x *); +static int getprice(struct obj *); +static int realhunger(void); + char * -shkname(mtmp) /* called in do_name.c */ -struct monst *mtmp; +shkname(struct monst *mtmp) /* called in do_name.c */ { return(ESHK(mtmp)->shknam); } -static void setpaid(); - -shkdead(mtmp) /* called in mon.c */ -struct monst *mtmp; +void +shkdead(struct monst *mtmp) /* called in mon.c */ { struct eshk *eshk = ESHK(mtmp); @@ -87,8 +151,8 @@ struct monst *mtmp; } } -replshk(mtmp,mtmp2) -struct monst *mtmp, *mtmp2; +void +replshk(struct monst *mtmp, struct monst *mtmp2) { if(mtmp == shopkeeper) { shopkeeper = mtmp2; @@ -97,8 +161,9 @@ struct monst *mtmp, *mtmp2; } static void -setpaid(){ /* caller has checked that shopkeeper exists */ +setpaid(void) /* caller has checked that shopkeeper exists */ /* either we paid or left the shop or he just died */ +{ struct obj *obj; struct monst *mtmp; for(obj = invent; obj; obj = obj->nobj) @@ -113,16 +178,17 @@ struct monst *mtmp; for(mtmp = fallen_down; mtmp; mtmp = mtmp->nmon) for(obj = mtmp->minvent; obj; obj = obj->nobj) obj->unpaid = 0; - while(obj = billobjs){ + while((obj = billobjs)){ billobjs = obj->nobj; free((char *) obj); } ESHK(shopkeeper)->billct = 0; } -static -addupbill(){ /* delivers result in total */ +static void +addupbill(void) /* delivers result in total */ /* caller has checked that shopkeeper exists */ +{ int ct = ESHK(shopkeeper)->billct; struct bill_x *bp = bill; total = 0; @@ -132,9 +198,9 @@ struct bill_x *bp = bill; } } -static void findshk(int); - -inshop(){ +int +inshop(void) +{ int roomno = inroom(u.ux,u.uy); /* Did we just leave a shop? */ @@ -200,7 +266,7 @@ int roomno = inroom(u.ux,u.uy); /* He seems to be new here */ ESHK(shopkeeper)->visitct = 0; ESHK(shopkeeper)->following = 0; - (void) strncpy(ESHK(shopkeeper)->customer,plname,PL_NSIZ); + strncpy(ESHK(shopkeeper)->customer,plname,PL_NSIZ); NOTANGRY(shopkeeper) = 1; } if(!ESHK(shopkeeper)->following) { @@ -230,8 +296,7 @@ int roomno = inroom(u.ux,u.uy); } static void -findshk(roomno) -int roomno; +findshk(int roomno) { struct monst *mtmp; for(mtmp = fmon; mtmp; mtmp = mtmp->nmon) @@ -253,7 +318,8 @@ struct monst *mtmp; } static struct bill_x * -onbill(obj) struct obj *obj; { +onbill(struct obj *obj) +{ struct bill_x *bp; if(!shopkeeper) return(0); for(bp = bill; bp < &bill[ESHK(shopkeeper)->billct]; bp++) @@ -266,7 +332,9 @@ struct bill_x *bp; } /* called with two args on merge */ -obfree(obj,merge) struct obj *obj, *merge; { +void +obfree(struct obj *obj, struct obj *merge) +{ struct bill_x *bp = onbill(obj); struct bill_x *bpm; if(bp) { @@ -292,10 +360,8 @@ struct bill_x *bpm; free((char *) obj); } -static -pay(tmp,shkp) -long tmp; -struct monst *shkp; +static void +pay(long tmp, struct monst *shkp) { long robbed = ESHK(shkp)->robbed; @@ -309,16 +375,16 @@ struct monst *shkp; } } -static int dopayobj(struct bill_x *); - -dopay(){ +int +dopay(void) +{ long ltmp; struct bill_x *bp; struct monst *shkp; int pass, tmp; multi = 0; - (void) inshop(); + inshop(); for(shkp = fmon; shkp; shkp = shkp->nmon) if(shkp->isshk && dist(shkp->mx,shkp->my) < 3) break; @@ -427,8 +493,9 @@ int pass, tmp; /* return 1 if paid successfully */ /* 0 if not enough money */ /* -1 if object could not be found (but was paid) */ -static -dopayobj(bp) struct bill_x *bp; { +static int +dopayobj(struct bill_x *bp) +{ struct obj *obj; long ltmp; @@ -472,7 +539,9 @@ long ltmp; } /* routine called after dying (or quitting) with nonempty bill */ -paybill(){ +void +paybill(void) +{ if(shlevel == dlevel && shopkeeper && ESHK(shopkeeper)->billct){ addupbill(); if(total > u.ugold){ @@ -491,9 +560,8 @@ paybill(){ } /* find obj on one of the lists */ -struct obj * -bp_to_obj(bp) -struct bill_x *bp; +static struct obj * +bp_to_obj(struct bill_x *bp) { struct obj *obj; struct monst *mtmp; @@ -505,19 +573,19 @@ struct bill_x *bp; !(obj = o_on(id, fobj)) && !(obj = o_on(id, fcobj))) { for(mtmp = fmon; mtmp; mtmp = mtmp->nmon) - if(obj = o_on(id, mtmp->minvent)) + if((obj = o_on(id, mtmp->minvent))) break; for(mtmp = fallen_down; mtmp; mtmp = mtmp->nmon) - if(obj = o_on(id, mtmp->minvent)) + if((obj = o_on(id, mtmp->minvent))) break; } return(obj); } -static int getprice(); - /* called in hack.c when we pickup an object */ -addtobill(obj) struct obj *obj; { +void +addtobill(struct obj *obj) +{ struct bill_x *bp; if(!inshop() || (u.ux == ESHK(shopkeeper)->shk.x && u.uy == ESHK(shopkeeper)->shk.y) || @@ -537,7 +605,9 @@ struct bill_x *bp; obj->unpaid = 1; } -splitbill(obj,otmp) struct obj *obj, *otmp; { +void +splitbill(struct obj *obj, struct obj *otmp) +{ /* otmp has been split off from obj */ struct bill_x *bp; int tmp; @@ -554,7 +624,6 @@ int tmp; } bp->bquan -= otmp->quan; - /* addtobill(otmp); */ if(ESHK(shopkeeper)->billct == BILLSZ) otmp->unpaid = 0; else { tmp = bp->price; @@ -567,7 +636,9 @@ int tmp; } } -subfrombill(obj) struct obj *obj; { +void +subfrombill(struct obj *obj) +{ long ltmp; int tmp; struct obj *otmp; @@ -630,8 +701,8 @@ pline("Thank you for your contribution to restock this recently plundered shop." plur(ltmp)); } -doinvbill(mode) -int mode; /* 0: deliver count 1: paged */ +int +doinvbill(int mode) /* 0: deliver count 1: paged */ { struct bill_x *bp; struct obj *obj; @@ -673,17 +744,17 @@ int mode; /* 0: deliver count 1: paged */ thisused = bp->price * uquan; totused += thisused; obj->quan = uquan; /* cheat doname */ - (void) sprintf(buf, "x - %s", doname(obj)); + sprintf(buf, "x - %s", doname(obj)); obj->quan = oquan; /* restore value */ for(cnt = 0; buf[cnt]; cnt++); while(cnt < 50) buf[cnt++] = ' '; - (void) sprintf(&buf[cnt], " %5ld zorkmids", thisused); + sprintf(&buf[cnt], " %5ld zorkmids", thisused); if(page_line(buf)) goto quit; } } - (void) sprintf(buf, "Total:%50ld zorkmids", totused); + sprintf(buf, "Total:%50ld zorkmids", totused); if(page_line("") || page_line(buf)) goto quit; set_pager(1); @@ -693,10 +764,10 @@ quit: return(0); } -static int realhunger(void); -static -getprice(obj) struct obj *obj; { +static int +getprice(struct obj *obj) +{ int tmp, ac; switch(obj->olet){ case AMULET_SYM: @@ -752,8 +823,9 @@ int tmp, ac; return(tmp); } -static -realhunger(){ /* not completely foolproof */ +static int +realhunger(void) /* not completely foolproof */ +{ int tmp = u.uhunger; struct obj *otmp = invent; while(otmp){ @@ -764,8 +836,8 @@ struct obj *otmp = invent; return((tmp <= 0) ? 1 : tmp); } -shkcatch(obj) -struct obj *obj; +bool +shkcatch(struct obj *obj) { struct monst *shkp = shopkeeper; @@ -785,8 +857,8 @@ struct obj *obj; /* * shk_move: return 1: he moved 0: he didnt -1: let m_move do it */ -shk_move(shkp) -struct monst *shkp; +int +shk_move(struct monst *shkp) { struct monst *mtmp; struct permonst *mdat = shkp->data; @@ -795,7 +867,7 @@ struct monst *shkp; int udist; int z; schar shkroom,chi,chcnt,cnt; - boolean uondoor, satdoor, avoid, badinv; + boolean uondoor = 0, satdoor, avoid = 0, badinv; coord poss[9]; int info[9]; struct obj *ib = 0; @@ -805,7 +877,7 @@ struct monst *shkp; if((udist = dist(omx,omy)) < 3) { if(ANGRY(shkp)) { - (void) hitu(shkp, d(mdat->damn, mdat->damd)+1); + hitu(shkp, d(mdat->damn, mdat->damd)+1); return(0); } if(ESHK(shkp)->following) { @@ -931,7 +1003,7 @@ struct monst *shkp; hitmm(mtmp,shkp) == 2) return(2); return(0); } else if(info[chi] & ALLOW_U){ - (void) hitu(shkp, d(mdat->damn, mdat->damd)+1); + hitu(shkp, d(mdat->damn, mdat->damd)+1); return(0); } shkp->mx = nix; @@ -947,8 +1019,8 @@ struct monst *shkp; } /* He is digging in the shop. */ -shopdig(fall) -int fall; +void +shopdig(int fall) { if(!fall) { if(u.utraptype == TT_PIT) @@ -972,14 +1044,16 @@ int fall; } #endif /* QUEST */ -online(x,y) { +bool +online(int x, int y) +{ return(x==u.ux || y==u.uy || (x-u.ux)*(x-u.ux) == (y-u.uy)*(y-u.uy)); } /* Does this monster follow me downstairs? */ -follower(mtmp) -struct monst *mtmp; +bool +follower(struct monst *mtmp) { return( mtmp->mtame || index("1TVWZi&, ", mtmp->data->mlet) #ifndef QUEST diff --git a/games/hack/hack.shknam.c b/games/hack/hack.shknam.c index 9293a6f112..55ab703012 100644 --- a/games/hack/hack.shknam.c +++ b/games/hack/hack.shknam.c @@ -1,7 +1,7 @@ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* hack.shknam.c - version 1.0.2 */ /* $FreeBSD: src/games/hack/hack.shknam.c,v 1.3 1999/11/16 02:57:11 billf Exp $ */ -/* $DragonFly: src/games/hack/hack.shknam.c,v 1.3 2005/05/22 03:37:05 y0netan1 Exp $ */ +/* $DragonFly: src/games/hack/hack.shknam.c,v 1.4 2006/08/21 19:45:32 pavalos Exp $ */ #include "hack.h" @@ -125,7 +125,9 @@ struct shk_nx { { 0, shkgeneral } }; -findname(nampt, let) char *nampt; char let; { +void +findname(char *nampt, char let) +{ struct shk_nx *p = shk_nx; const char **q; int i; @@ -134,9 +136,9 @@ int i; for(i=0; i 10000) ? rnd(10000) : rnd((int) u.ugold) ); } -stealgold(mtmp) struct monst *mtmp; { +void +stealgold(struct monst *mtmp) +{ struct gold *gold = g_at(u.ux, u.uy); long tmp; if(gold && ( !u.ugold || gold->amount > u.ugold || !rn2(5))) { @@ -37,7 +42,10 @@ long tmp; /* steal armor after he finishes taking it off */ unsigned stealoid; /* object to be stolen */ unsigned stealmid; /* monster doing the stealing */ -stealarm(){ + +static void +stealarm(void) +{ struct monst *mtmp; struct obj *otmp; @@ -62,8 +70,8 @@ stealarm(){ /* returns 1 when something was stolen */ /* (or at least, when N should flee now) */ /* avoid stealing the object stealoid */ -steal(mtmp) -struct monst *mtmp; +bool +steal(struct monst *mtmp) { struct obj *otmp; int tmp; @@ -110,15 +118,9 @@ struct monst *mtmp; (otmp == uarmg) ? "gloves" : (otmp == uarmh) ? "helmet" : "armor"); named++; - (void) armoroff(otmp); + armoroff(otmp); otmp->cursed = curssv; if(multi < 0){ - extern int (*afternmv)(); - /* - multi = 0; - nomovemsg = 0; - afternmv = 0; - */ stealoid = otmp->o_id; stealmid = mtmp->m_id; afternmv = stealarm; @@ -149,16 +151,15 @@ struct monst *mtmp; return((multi < 0) ? 0 : 1); } -mpickobj(mtmp,otmp) -struct monst *mtmp; -struct obj *otmp; +void +mpickobj(struct monst *mtmp, struct obj *otmp) { otmp->nobj = mtmp->minvent; mtmp->minvent = otmp; } -stealamulet(mtmp) -struct monst *mtmp; +bool +stealamulet(struct monst *mtmp) { struct obj *otmp; @@ -176,9 +177,8 @@ struct monst *mtmp; } /* release the objects the killed animal has stolen */ -relobj(mtmp,show) -struct monst *mtmp; -int show; +void +relobj(struct monst *mtmp, int show) { struct obj *otmp, *otmp2; diff --git a/games/hack/hack.termcap.c b/games/hack/hack.termcap.c index bf6690d91e..ca06296c49 100644 --- a/games/hack/hack.termcap.c +++ b/games/hack/hack.termcap.c @@ -1,15 +1,10 @@ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* hack.termcap.c - version 1.0.3 */ /* $FreeBSD: src/games/hack/hack.termcap.c,v 1.10 1999/11/16 10:26:38 marcel Exp $ */ -/* $DragonFly: src/games/hack/hack.termcap.c,v 1.4 2005/05/22 03:37:05 y0netan1 Exp $ */ +/* $DragonFly: src/games/hack/hack.termcap.c,v 1.5 2006/08/21 19:45:32 pavalos Exp $ */ -#include #include -#include -#include -#include "config.h" /* for ROWNO and COLNO */ -#include "def.flag.h" /* for flags.nonull */ -extern long *alloc(); +#include "hack.h" static char tbuf[512]; static char *HO, *CL, *CE, *tcUP, *CM, *ND, *XD, *tcBC, *SO, *SE, *TI, *TE; @@ -19,7 +14,13 @@ static char tcPC = '\0'; char *CD; /* tested in pri.c: docorner() */ int CO, LI; /* used in pri.c and whatis.c */ -startup() +static void nocmov(int, int); +static void cmov(int, int); +static int xputc(int); +static int xputs(char *); + +void +startup(void) { char *term; char *tptr; @@ -35,7 +36,7 @@ startup() if (tgetflag(__DECONST(char *, "NP")) || tgetflag(__DECONST(char *, "nx"))) flags.nonull = 1; - if(pc = tgetstr(__DECONST(char *, "pc"), &tbufptr)) + if((pc = tgetstr(__DECONST(char *, "pc"), &tbufptr))) tcPC = *pc; if(!(tcBC = tgetstr(__DECONST(char *, "bc"), &tbufptr))) { if(!tgetflag(__DECONST(char *, "bs"))) @@ -74,28 +75,27 @@ startup() if(!SO || !SE || (SG > 0)) SO = SE = 0; CD = tgetstr(__DECONST(char *, "cd"), &tbufptr); set_whole_screen(); /* uses LI and CD */ - if(tbufptr-tbuf > sizeof(tbuf)) error("TERMCAP entry too big...\n"); + if(tbufptr-tbuf > (int)sizeof(tbuf)) error("TERMCAP entry too big...\n"); free(tptr); } -start_screen() +void +start_screen(void) { xputs(TI); xputs(VS); } -end_screen() +void +end_screen(void) { xputs(VE); xputs(TE); } -/* Cursor movements */ -extern xchar curx, cury; - -curs(x, y) -int x, y; /* not xchar: perhaps xchar is unsigned and - curx-x would be unsigned as well */ +/* not xchar: perhaps xchar is unsigned and curx-x would be unsigned as well */ +void +curs(int x, int y) { if (y == cury && x == curx) @@ -107,7 +107,7 @@ int x, y; /* not xchar: perhaps xchar is unsigned and if(abs(cury-y) <= 3 && abs(curx-x) <= 3) nocmov(x, y); else if((x <= 3 && abs(cury-y)<= 3) || (!CM && x y) { if(tcUP) { @@ -161,23 +162,29 @@ nocmov(x, y) } } -cmov(x, y) -int x, y; +static void +cmov(int x, int y) { xputs(tgoto(CM, x-1, y-1)); cury = y; curx = x; } -xputc(c) char c; { - (void) fputc(c, stdout); +static int +xputc(int c) +{ + return(fputc(c, stdout)); } -xputs(s) char *s; { - tputs(s, 1, xputc); +static int +xputs(char *s) +{ + return(tputs(s, 1, xputc)); } -cl_end() { +void +cl_end(void) +{ if(CE) xputs(CE); else { /* no-CE fix - free after Harold Rynes */ @@ -193,12 +200,15 @@ cl_end() { } } -clear_screen() { +void +clear_screen(void) +{ xputs(CL); curx = cury = 1; } -home() +void +home(void) { if(HO) xputs(HO); @@ -209,61 +219,34 @@ home() curx = cury = 1; } -standoutbeg() +void +standoutbeg(void) { if(SO) xputs(SO); } -standoutend() +void +standoutend(void) { if(SE) xputs(SE); } -backsp() +void +backsp(void) { xputs(tcBC); curx--; } -bell() +void +bell(void) { - (void) putchar('\007'); /* curx does not change */ - (void) fflush(stdout); -} - -static short tmspc10[] = { /* from termcap */ - 0, 2000, 1333, 909, 743, 666, 500, 333, 166, 83, 55, 41, 20, 10, 5, 3, 2, 1 -}; - -#if 0 -delay_output() { - /* delay 50 ms - could also use a 'nap'-system call */ - /* BUG: if the padding character is visible, as it is on the 5620 - then this looks terrible. */ - if(!flags.nonull) - tputs("50", 1, xputc); - - /* cbosgd!cbcephus!pds for SYS V R2 */ - /* is this terminfo, or what? */ - /* tputs("$<50>", 1, xputc); */ - else { - (void) fflush(stdout); - usleep(50*1000); - } - else if(ospeed > 0 || ospeed < SIZE(tmspc10)) if(CM) { - /* delay by sending cm(here) an appropriate number of times */ - int cmlen = strlen(tgoto(CM, curx-1, cury-1)); - int i = 500 + tmspc10[ospeed]/2; - - while(i > 0) { - cmov(curx, cury); - i -= cmlen*tmspc10[ospeed]; - } - } + putchar('\007'); /* curx does not change */ + fflush(stdout); } -#endif /* 0 */ -cl_eos() /* free after Robert Viduya */ +void +cl_eos(void) /* free after Robert Viduya */ { /* must only be called with curx = 1 */ if(CD) diff --git a/games/hack/hack.timeout.c b/games/hack/hack.timeout.c index c7ef62c173..22b1b3a4c8 100644 --- a/games/hack/hack.timeout.c +++ b/games/hack/hack.timeout.c @@ -1,11 +1,15 @@ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* hack.timeout.c - version 1.0.3 */ /* $FreeBSD: src/games/hack/hack.timeout.c,v 1.3 1999/11/16 02:57:12 billf Exp $ */ -/* $DragonFly: src/games/hack/hack.timeout.c,v 1.3 2005/05/22 03:37:05 y0netan1 Exp $ */ +/* $DragonFly: src/games/hack/hack.timeout.c,v 1.4 2006/08/21 19:45:32 pavalos Exp $ */ #include "hack.h" -timeout(){ +static void stoned_dialogue(void); + +void +p_timeout(void) +{ struct prop *upp; if(Stoned) stoned_dialogue(); for(upp = u.uprops; upp < u.uprops+SIZE(u.uprops); upp++) @@ -51,7 +55,8 @@ static const char *stoned_texts[] = { "You are a statue." /* 1 */ }; -stoned_dialogue() +static void +stoned_dialogue(void) { long i = (Stoned & TIMEOUT); diff --git a/games/hack/hack.topl.c b/games/hack/hack.topl.c index 1a73ceb018..6b3d8016f0 100644 --- a/games/hack/hack.topl.c +++ b/games/hack/hack.topl.c @@ -1,11 +1,9 @@ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* hack.topl.c - version 1.0.2 */ /* $FreeBSD: src/games/hack/hack.topl.c,v 1.3 1999/11/16 02:57:12 billf Exp $ */ -/* $DragonFly: src/games/hack/hack.topl.c,v 1.2 2003/06/17 04:25:24 dillon Exp $ */ +/* $DragonFly: src/games/hack/hack.topl.c,v 1.3 2006/08/21 19:45:32 pavalos Exp $ */ #include "hack.h" -#include -extern char *eos(); extern int CO; char toplines[BUFSZ]; @@ -17,19 +15,26 @@ struct topl { } *old_toplines, *last_redone_topl; #define OTLMAX 20 /* max nr of old toplines remembered */ -doredotopl(){ +static void redotoplin(void); +static void xmore(const char *); + +int +doredotopl(void) +{ if(last_redone_topl) last_redone_topl = last_redone_topl->next_topl; if(!last_redone_topl) last_redone_topl = old_toplines; if(last_redone_topl){ - (void) strcpy(toplines, last_redone_topl->topl_text); + strcpy(toplines, last_redone_topl->topl_text); } redotoplin(); return(0); } -redotoplin() { +static void +redotoplin(void) +{ home(); if(index(toplines, '\n')) cl_end(); putstr(toplines); @@ -41,7 +46,9 @@ redotoplin() { more(); } -remember_topl() { +void +remember_topl(void) +{ struct topl *tl; int cnt = OTLMAX; if(last_redone_topl && @@ -53,7 +60,7 @@ int cnt = OTLMAX; alloc((unsigned)(strlen(toplines) + sizeof(struct topl) + 1)); tl->next_topl = old_toplines; tl->topl_text = (char *)(tl + 1); - (void) strcpy(tl->topl_text, toplines); + strcpy(tl->topl_text, toplines); old_toplines = tl; while(cnt && tl){ cnt--; @@ -65,17 +72,19 @@ int cnt = OTLMAX; } } -addtopl(s) char *s; { +void +addtopl(const char *s) +{ curs(tlx,tly); - if(tlx + strlen(s) > CO) putsym('\n'); + if(tlx + (int)strlen(s) > CO) putsym('\n'); putstr(s); tlx = curx; tly = cury; flags.toplin = 1; } -xmore(s) -char *s; /* allowed chars besides space/return */ +static void +xmore(const char *s) /* allowed chars besides space/return */ { if(flags.toplin) { curs(tlx, tly); @@ -97,17 +106,21 @@ char *s; /* allowed chars besides space/return */ flags.toplin = 0; } -more(){ +void +more(void) +{ xmore(""); } -cmore(s) -char *s; +void +cmore(const char *s) { xmore(s); } -clrlin(){ +void +clrlin(void) +{ if(flags.toplin) { home(); cl_end(); @@ -117,17 +130,26 @@ clrlin(){ flags.toplin = 0; } +void +pline(const char *line, ...) +{ + va_list ap; + va_start(ap, line); + vpline(line, ap); + va_end(ap); +} + /*VARARGS1*/ -pline(line,arg1,arg2,arg3,arg4,arg5,arg6) -char *line,*arg1,*arg2,*arg3,*arg4,*arg5,*arg6; +void +vpline(const char *line, va_list ap) { char pbuf[BUFSZ]; char *bp = pbuf, *tl; int n,n0; if(!line || !*line) return; - if(!index(line, '%')) (void) strcpy(pbuf,line); else - (void) sprintf(pbuf,line,arg1,arg2,arg3,arg4,arg5,arg6); + if(!index(line, '%')) strcpy(pbuf,line); else + vsprintf(pbuf, line, ap); if(flags.toplin == 1 && !strcmp(pbuf, toplines)) return; nscr(); /* %% */ @@ -135,10 +157,10 @@ char *line,*arg1,*arg2,*arg3,*arg4,*arg5,*arg6; /* But messages like "You die..." deserve their own line */ n0 = strlen(bp); if(flags.toplin == 1 && tly == 1 && - n0 + strlen(toplines) + 3 < CO-8 && /* leave room for --More-- */ + n0 + (int)strlen(toplines) + 3 < CO-8 && /* room for --More-- */ strncmp(bp, "You ", 4)) { - (void) strcat(toplines, " "); - (void) strcat(toplines, bp); + strcat(toplines, " "); + strcat(toplines, bp); tlx += 2; addtopl(bp); return; @@ -156,7 +178,7 @@ char *line,*arg1,*arg2,*arg3,*arg4,*arg5,*arg6; if(!letter(bp[n])) n0 = n; if(!n0) n0 = CO-2; } - (void) strncpy((tl = eos(toplines)), bp, n0); + strncpy((tl = eos(toplines)), bp, n0); tl[n0] = 0; bp += n0; @@ -165,12 +187,14 @@ char *line,*arg1,*arg2,*arg3,*arg4,*arg5,*arg6; tl[--n0] = 0; n0 = strlen(bp); - if(n0 && tl[0]) (void) strcat(tl, "\n"); + if(n0 && tl[0]) strcat(tl, "\n"); } redotoplin(); } -putsym(c) char c; { +void +putsym(char c) +{ switch(c) { case '\b': backsp(); @@ -186,9 +210,11 @@ putsym(c) char c; { else curx++; } - (void) putchar(c); + putchar(c); } -putstr(s) char *s; { +void +putstr(const char *s) +{ while(*s) putsym(*s++); } diff --git a/games/hack/hack.track.c b/games/hack/hack.track.c index 0aead5e4e8..ba09139447 100644 --- a/games/hack/hack.track.c +++ b/games/hack/hack.track.c @@ -1,7 +1,7 @@ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* hack.track.c - version 1.0.2 */ /* $FreeBSD: src/games/hack/hack.track.c,v 1.4 1999/11/16 10:26:38 marcel Exp $ */ -/* $DragonFly: src/games/hack/hack.track.c,v 1.2 2003/06/17 04:25:24 dillon Exp $ */ +/* $DragonFly: src/games/hack/hack.track.c,v 1.3 2006/08/21 19:45:32 pavalos Exp $ */ #include "hack.h" @@ -11,12 +11,16 @@ coord utrack[UTSZ]; int utcnt = 0; int utpnt = 0; -initrack(){ +void +initrack(void) +{ utcnt = utpnt = 0; } /* add to track */ -settrack(){ +void +settrack(void) +{ if(utcnt < UTSZ) utcnt++; if(utpnt == UTSZ) utpnt = 0; utrack[utpnt].x = u.ux; @@ -25,16 +29,17 @@ settrack(){ } coord * -gettrack(x,y) int x,y; { -int i,cnt,dist; +gettrack(int x, int y) +{ +int i,cnt,dst; coord tc; cnt = utcnt; for(i = utpnt-1; cnt--; i--){ if(i == -1) i = UTSZ-1; tc = utrack[i]; - dist = (x-tc.x)*(x-tc.x) + (y-tc.y)*(y-tc.y); - if(dist < 3) - return(dist ? &(utrack[i]) : 0); + dst = (x-tc.x)*(x-tc.x) + (y-tc.y)*(y-tc.y); + if(dst < 3) + return(dst ? &(utrack[i]) : 0); } return(0); } diff --git a/games/hack/hack.trap.c b/games/hack/hack.trap.c index 6c9d959f33..f92c4c421b 100644 --- a/games/hack/hack.trap.c +++ b/games/hack/hack.trap.c @@ -1,12 +1,10 @@ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* hack.trap.c - version 1.0.3 */ /* $FreeBSD: src/games/hack/hack.trap.c,v 1.5 1999/11/16 10:26:38 marcel Exp $ */ -/* $DragonFly: src/games/hack/hack.trap.c,v 1.4 2005/05/22 03:37:05 y0netan1 Exp $ */ +/* $DragonFly: src/games/hack/hack.trap.c,v 1.5 2006/08/21 19:45:32 pavalos Exp $ */ #include "hack.h" -extern struct monst *makemon(); - char vowels[] = "aeiou"; const char *traps[] = { @@ -21,9 +19,12 @@ const char *traps[] = { " mimic" }; +static void vtele(void); +static void teleds(int, int); +static bool teleok(int, int); + struct trap * -maketrap(x,y,typ) -int x,y,typ; +maketrap(int x, int y, int typ) { struct trap *ttmp; @@ -38,7 +39,9 @@ int x,y,typ; return(ttmp); } -dotrap(trap) struct trap *trap; { +void +dotrap(struct trap *trap) +{ int ttype = trap->ttyp; nomul(0); @@ -67,7 +70,7 @@ dotrap(trap) struct trap *trap; { if(uarmh) pline("Its blow glances off your helmet."); else - (void) thitu(3,d(4,6),"falling piercer"); + thitu(3,d(4,6),"falling piercer"); } break; case ARROW_TRAP: @@ -137,7 +140,9 @@ if(uarmh) pline("Fortunately, you are wearing a helmet!"); } } -mintrap(mtmp) struct monst *mtmp; { +int +mintrap(struct monst *mtmp) +{ struct trap *trap = t_at(mtmp->mx, mtmp->my); int wasintrap = mtmp->mtrapped; @@ -148,7 +153,6 @@ mintrap(mtmp) struct monst *mtmp; { } else { int tt = trap->ttyp; int in_sight = cansee(mtmp->mx,mtmp->my); - extern char mlarge[]; if(mtmp->mtrapseen & (1 << tt)) { /* he has been in such a trap - perhaps he escapes */ @@ -227,7 +231,9 @@ pline("A trap door in the ceiling opens and a rock hits %s!", monnam(mtmp)); return(mtmp->mtrapped); } -selftouch(arg) char *arg; { +void +selftouch(const char *arg) +{ if(uwep && uwep->otyp == DEAD_COCKATRICE){ pline("%s touch the dead cockatrice.", arg); pline("You turn to stone."); @@ -236,7 +242,9 @@ selftouch(arg) char *arg; { } } -float_up(){ +void +float_up(void) +{ if(u.utrap) { if(u.utraptype == TT_PIT) { u.utrap = 0; @@ -248,10 +256,12 @@ float_up(){ pline("You start to float in the air!"); } -float_down(){ +void +float_down(void) +{ struct trap *trap; pline("You float gently to the ground."); - if(trap = t_at(u.ux,u.uy)) + if((trap = t_at(u.ux,u.uy))) switch(trap->ttyp) { case PIERC: break; @@ -264,8 +274,9 @@ float_down(){ pickup(1); } -vtele() { -#include "def.mkroom.h" +static void +vtele(void) +{ struct mkroom *croom; for(croom = &rooms[0]; croom->hx >= 0; croom++) if(croom->rtype == VAULT) { @@ -281,8 +292,9 @@ vtele() { tele(); } -tele() { - extern coord getpos(); +void +tele(void) +{ coord cc; int nux,nuy; @@ -304,8 +316,8 @@ tele() { teleds(nux, nuy); } -teleds(nux, nuy) -int nux,nuy; +static void +teleds(int nux, int nuy) { if(Punished) unplacebc(); unsee(); @@ -322,21 +334,23 @@ int nux,nuy; nomul(0); if(levl[nux][nuy].typ == POOL && !Levitation) drown(); - (void) inshop(); + inshop(); pickup(1); if(!Blind) read_engr_at(u.ux,u.uy); } -teleok(x,y) int x,y; { /* might throw him into a POOL */ +static bool +teleok(int x, int y) /* might throw him into a POOL */ +{ return( isok(x,y) && !IS_ROCK(levl[x][y].typ) && !m_at(x,y) && !sobj_at(ENORMOUS_ROCK,x,y) && !t_at(x,y) ); /* Note: gold is permitted (because of vaults) */ } -dotele() { - extern char pl_character[]; - +int +dotele(void) +{ if( #ifdef WIZARD !wizard && @@ -355,7 +369,9 @@ dotele() { return(1); } -placebc(attach) int attach; { +void +placebc(int attach) +{ if(!uchain || !uball){ impossible("Where are your chain and ball??"); return; @@ -372,7 +388,9 @@ placebc(attach) int attach; { } } -unplacebc(){ +void +unplacebc(void) +{ if(!carried(uball)){ freeobj(uball); unpobj(uball); @@ -381,7 +399,9 @@ unplacebc(){ unpobj(uchain); } -level_tele() { +void +level_tele(void) +{ int newlevel; if(Teleport_control) { char buf[BUFSZ]; @@ -427,7 +447,8 @@ int newlevel; goto_level(newlevel, FALSE); /* calls done("escaped") if newlevel==0 */ } -drown() +void +drown(void) { pline("You fall into a pool!"); pline("You can't swim!"); @@ -441,7 +462,7 @@ drown() /* we should perhaps merge these scrolls ? */ pline("You attempt a teleport spell."); /* utcsri!carroll */ - (void) dotele(); + dotele(); if(levl[u.ux][u.uy].typ != POOL) return; } pline("You drown ..."); diff --git a/games/hack/hack.tty.c b/games/hack/hack.tty.c index 7df19ff2e1..92152063a0 100644 --- a/games/hack/hack.tty.c +++ b/games/hack/hack.tty.c @@ -32,7 +32,7 @@ * * @(#)hack.tty.c 8.1 (Berkeley) 5/31/93 * $FreeBSD: src/games/hack/hack.tty.c,v 1.6.2.1 2000/07/20 10:35:07 kris Exp $ - * $DragonFly: src/games/hack/hack.tty.c,v 1.3 2004/11/06 12:29:17 eirikn Exp $ + * $DragonFly: src/games/hack/hack.tty.c,v 1.4 2006/08/21 19:45:32 pavalos Exp $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ @@ -41,7 +41,6 @@ arnold@ucsf-cgl, wcs@bo95b, cbcephus!pds and others. */ #include "hack.h" -#include /* * The distinctions here are not BSD - rest but rather USG - rest, as @@ -91,30 +90,28 @@ #define CBRKMASK CBREAK #define CBRKON /* empty */ #define OSPEED(x) (x).sg_ospeed -#define GTTY(x) (gtty(0, x)) -#define STTY(x) (stty(0, x)) +#define GTTY(x) (ioctl(0, TIOCGETP, x)) +#define STTY(x) (ioctl(0, TIOCSETP, x)) #endif /* USG */ -#if 0 -extern short ospeed; -#endif static char erase_char, kill_char; static boolean settty_needed = FALSE; struct termstruct inittyb, curttyb; +static void setctty(void); + /* * Get initial state of terminal, set ospeed (for termcap routines) * and switch off tab expansion if necessary. * Called by startup() in termcap.c and after returning from ! or ^Z */ -gettty(){ +void +gettty(void) +{ if(GTTY(&inittyb) < 0) perror("Hack (gettty)"); curttyb = inittyb; -#if 0 - ospeed = OSPEED(inittyb); -#endif erase_char = inittyb.erase_sym; kill_char = inittyb.kill_sym; getioctls(); @@ -128,11 +125,13 @@ gettty(){ } /* reset terminal to original state */ -settty(s) char *s; { +void +settty(const char *s) +{ clear_screen(); end_screen(); if(s) printf("%s", s); - (void) fflush(stdout); + fflush(stdout); if(STTY(&inittyb) < 0) perror("Hack (settty)"); flags.echo = (inittyb.echoflgs & ECHO) ? ON : OFF; @@ -140,13 +139,16 @@ settty(s) char *s; { setioctls(); } -setctty(){ +static void +setctty(void) +{ if(STTY(&curttyb) < 0) perror("Hack (setctty)"); } - -setftty(){ +void +setftty(void) +{ int ef = 0; /* desired value of flags & ECHO */ int cf = CBRKON(CBRKMASK); /* desired value of flags & CBREAK */ int change = 0; @@ -155,7 +157,6 @@ int change = 0; /* Should use (ECHO|CRMOD) here instead of ECHO */ if((curttyb.echoflgs & ECHO) != ef){ curttyb.echoflgs &= ~ECHO; -/* curttyb.echoflgs |= ef; */ change++; } if((curttyb.cbrkflgs & CBRKMASK) != cf){ @@ -177,10 +178,15 @@ int change = 0; /* fatal error */ /*VARARGS1*/ -error(s,x,y) char *s; { +void +error(const char *s, ...) +{ + va_list ap; if(settty_needed) settty((char *) 0); - printf(s,x,y); + va_start(ap, s); + vprintf(s, ap); + va_end(ap); putchar('\n'); exit(1); } @@ -191,15 +197,15 @@ error(s,x,y) char *s; { * Reading can be interrupted by an escape ('\033') - now the * resulting string is "\033". */ -getlin(bufp) -char *bufp; +void +getlin(char *bufp) { char *obufp = bufp; int c; flags.toplin = 2; /* nonempty, no --More-- required */ for(;;) { - (void) fflush(stdout); + fflush(stdout); if((c = getchar()) == EOF) { *bufp = 0; return; @@ -236,12 +242,14 @@ char *bufp; } } -getret() { +void +getret(void) +{ cgetret(""); } -cgetret(s) -char *s; +void +cgetret(const char *s) { putsym('\n'); if(flags.standout) @@ -256,8 +264,8 @@ char *s; char morc; /* tell the outside world what char he used */ -xwaitforspace(s) -char *s; /* chars allowed besides space or return */ +void +xwaitforspace(const char *s) /* chars allowed besides space or return */ { int c; @@ -276,7 +284,7 @@ int c; } char * -parse() +parse(void) { static char inputline[COLNO]; int foo; @@ -307,10 +315,11 @@ parse() } char -readchar() { +readchar(void) +{ int sym; - (void) fflush(stdout); + fflush(stdout); if((sym = getchar()) == EOF) #ifdef NR_OF_EOFS { /* @@ -334,7 +343,8 @@ readchar() { return((char) sym); } -end_of_input() +void +end_of_input(void) { settty("End of input?\n"); clearlocks(); diff --git a/games/hack/hack.u_init.c b/games/hack/hack.u_init.c index 8c9f1ee760..5b83a20e25 100644 --- a/games/hack/hack.u_init.c +++ b/games/hack/hack.u_init.c @@ -1,19 +1,13 @@ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* hack.u_init.c - version 1.0.3 */ /* $FreeBSD: src/games/hack/hack.u_init.c,v 1.4 1999/11/16 02:57:13 billf Exp $ */ -/* $DragonFly: src/games/hack/hack.u_init.c,v 1.4 2005/05/22 01:28:15 y0netan1 Exp $ */ +/* $DragonFly: src/games/hack/hack.u_init.c,v 1.5 2006/08/21 19:45:32 pavalos Exp $ */ #include "hack.h" -#include -#include -#include #define Strcpy (void) strcpy #define Strcat (void) strcat #define UNDEF_TYP 0 #define UNDEF_SPE '\177' -extern struct obj *addinv(); -extern char *eos(); -extern char plname[]; struct you zerou; char pl_character[PL_CSIZ]; @@ -98,17 +92,24 @@ struct trobj Wizard[] = { { 0, 0, 0, 0, 0 } }; -u_init(){ +static void ini_inv(struct trobj *); +#ifdef WIZARD +static void wiz_inv(void); +#endif +static int role_index(char); + +void +u_init(void) +{ int i; char exper = 'y', pc; -extern char readchar(); if(flags.female) /* should have been set in HACKOPTIONS */ strlcpy(roles[4], "Cave-woman", sizeof(roles[4])); for(i = 0; i < NR_OF_ROLES; i++) rolesyms[i] = roles[i][0]; rolesyms[i] = 0; - if(pc = pl_character[0]) { + if((pc = pl_character[0])) { if('a' <= pc && pc <= 'z') pc += 'A'-'a'; if((i = role_index(pc)) >= 0) goto got_suffix; /* implies experienced */ @@ -141,11 +142,11 @@ extern char readchar(); } printf("? [%s] ", rolesyms); - while(pc = readchar()) { + while((pc = readchar())) { if('a' <= pc && pc <= 'z') pc += 'A'-'a'; if((i = role_index(pc)) >= 0) { printf("%c\n", pc); /* echo */ - (void) fflush(stdout); /* should be seen */ + fflush(stdout); /* should be seen */ break; } if(pc == '\n') @@ -167,8 +168,8 @@ beginner: roles[i]); getret(); /* give him some feedback in case mklev takes much time */ - (void) putchar('\n'); - (void) fflush(stdout); + putchar('\n'); + fflush(stdout); } if(exper) { roles[i][0] = pc; @@ -176,7 +177,7 @@ beginner: got_suffix: - (void) strncpy(pl_character, roles[i], PL_CSIZ-1); + strncpy(pl_character, roles[i], PL_CSIZ-1); pl_character[PL_CSIZ-1] = 0; flags.beginner = 1; u = zerou; @@ -241,9 +242,9 @@ got_suffix: } find_ac(); if(!rn2(20)) { - int d = rn2(7) - 2; /* biased variation */ - u.ustr += d; - u.ustrmax += d; + int d1 = rn2(7) - 2; /* biased variation */ + u.ustr += d1; + u.ustrmax += d1; } #ifdef WIZARD @@ -255,9 +256,10 @@ got_suffix: u.ustr++, u.ustrmax++; } -ini_inv(trop) struct trobj *trop; { +static void +ini_inv(struct trobj *trop) +{ struct obj *obj; -extern struct obj *mkobj(); while(trop->trolet) { obj = mkobj(trop->trolet); obj->known = trop->trknown; @@ -311,7 +313,9 @@ extern struct obj *mkobj(); } #ifdef WIZARD -wiz_inv(){ +static void +wiz_inv(void) +{ struct trobj *trop = &Extra_objs[0]; char *ep = getenv("INVENT"); int type; @@ -337,9 +341,11 @@ int type; } #endif /* WIZARD */ -plnamesuffix() { +void +plnamesuffix(void) +{ char *p; - if(p = rindex(plname, '-')) { + if((p = rindex(plname, '-'))) { *p = 0; pl_character[0] = p[1]; pl_character[1] = 0; @@ -350,13 +356,13 @@ char *p; } } -role_index(pc) -char pc; +static int +role_index(char pc) { /* must be called only from u_init() */ /* so that rolesyms[] is defined */ char *cp; - if(cp = index(rolesyms, pc)) + if((cp = index(rolesyms, pc))) return(cp - rolesyms); return(-1); } diff --git a/games/hack/hack.unix.c b/games/hack/hack.unix.c index ba8ec7a0ae..20f12ce9a7 100644 --- a/games/hack/hack.unix.c +++ b/games/hack/hack.unix.c @@ -1,7 +1,7 @@ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* hack.unix.c - version 1.0.3 */ /* $FreeBSD: src/games/hack/hack.unix.c,v 1.8 1999/11/16 02:57:13 billf Exp $ */ -/* $DragonFly: src/games/hack/hack.unix.c,v 1.6 2006/01/22 03:43:37 swildner Exp $ */ +/* $DragonFly: src/games/hack/hack.unix.c,v 1.7 2006/08/21 19:45:32 pavalos Exp $ */ /* This file collects some Unix dependencies; hack.pager.c contains some more */ @@ -14,47 +14,54 @@ * - determination of what files are "very old" */ -#include #include -#include #include "hack.h" /* mainly for index() which depends on BSD */ #include /* for time_t and stat */ #include #include -setrandom() +static struct tm *getlt(void); +static bool veryold(int); +#ifdef MAIL +static void newmail(void); +static void mdrush(struct monst *, bool); +#endif + +void +setrandom(void) { - (void) srandomdev(); + srandomdev(); } -struct tm * -getlt() +static struct tm * +getlt(void) { time_t date; - struct tm *localtime(); - (void) time(&date); + time(&date); return(localtime(&date)); } -getyear() +int +getyear(void) { return(1900 + getlt()->tm_year); } char * -getdate() +getdate(void) { static char datestr[7]; struct tm *lt = getlt(); - (void) snprintf(datestr, sizeof(datestr), "%02d%02d%02d", + snprintf(datestr, sizeof(datestr), "%02d%02d%02d", lt->tm_year % 100, lt->tm_mon + 1, lt->tm_mday); return(datestr); } -phase_of_the_moon() /* 0-7, with 0: new, 4: full */ +int +phase_of_the_moon(void) /* 0-7, with 0: new, 4: full */ { /* moon period: 29.5306 days */ /* year: 365.2422 days */ struct tm *lt = getlt(); @@ -69,14 +76,16 @@ phase_of_the_moon() /* 0-7, with 0: new, 4: full */ return( (((((diy + epact) * 6) + 11) % 177) / 22) & 7 ); } -night() +bool +night(void) { int hour = getlt()->tm_hour; return(hour < 6 || hour > 21); } -midnight() +bool +midnight(void) { return(getlt()->tm_hour == 0); } @@ -93,44 +102,11 @@ char *np; if(stat(name, &hbuf)) error("Cannot get status of %s.", (np = rindex(name, '/')) ? np+1 : name); -#if 0 -/* version using PATH from: seismo!gregc@ucsf-cgl.ARPA (Greg Couch) */ - - -/* - * The problem with #include is that this include file - * does not exist on all systems, and moreover, that it sometimes includes - * again, so that the compiler sees these typedefs twice. - */ -#define MAXPATHLEN 1024 - -char *np, *path; -char filename[MAXPATHLEN+1]; - if (index(name, '/') != NULL || (path = getenv("PATH")) == NULL) - path = ""; - - for (;;) { - if ((np = index(path, ':')) == NULL) - np = path + strlen(path); /* point to end str */ - if (np - path <= 1) /* %% */ - (void) strcpy(filename, name); - else { - (void) strncpy(filename, path, np - path); - filename[np - path] = '/'; - (void) strcpy(filename + (np - path) + 1, name); - } - if (stat(filename, &hbuf) == 0) - return; - if (*np == '\0') - break; - path = np + 1; - } - error("Cannot get status of %s.", - (np = rindex(name, '/')) ? np+1 : name); -#endif } -uptodate(fd) { +bool +uptodate(int fd) +{ if(fstat(fd, &buf)) { pline("Cannot get status of saved level? "); return(0); @@ -143,13 +119,15 @@ uptodate(fd) { } /* see whether we should throw away this xlock file */ -veryold(fd) { +static bool +veryold(int fd) +{ int i; time_t date; if(fstat(fd, &buf)) return(0); /* cannot get status */ if(buf.st_size != sizeof(int)) return(0); /* not an xlock file */ - (void) time(&date); + time(&date); if(date - buf.st_mtime < 3L*24L*60L*60L) { /* recent */ int lockedpid; /* should be the same size as hackpid */ @@ -164,22 +142,22 @@ veryold(fd) { if(!(kill(lockedpid, 0) == -1 && errno == ESRCH)) return(0); } - (void) close(fd); + close(fd); for(i = 1; i <= MAXLEVEL; i++) { /* try to remove all */ glo(i); - (void) unlink(lock); + unlink(lock); } glo(0); if(unlink(lock)) return(0); /* cannot remove it */ return(1); /* success! */ } -getlock() +void +getlock(void) { - extern int hackpid, locknum; int i = 0, fd; - (void) fflush(stdout); + fflush(stdout); /* we ignore QUIT and INT at this point */ if (link(HLOCK, LLOCK) == -1) { @@ -215,16 +193,16 @@ getlock() if((fd = open(lock, 0)) == -1) { if(errno == ENOENT) goto gotlock; /* no such file */ perror(lock); - (void) unlink(LLOCK); + unlink(LLOCK); error("Cannot open %s", lock); } if(veryold(fd)) /* if true, this closes fd and unlinks lock */ goto gotlock; - (void) close(fd); + close(fd); } while(i < locknum); - (void) unlink(LLOCK); + unlink(LLOCK); error(locknum ? "Too many hacks running now." : "There is a game in progress under your name."); gotlock: @@ -281,7 +259,9 @@ static struct stat omstat,nmstat; static char *mailbox; static long laststattime; -getmailstatus() { +void +getmailstatus(void) +{ if(!(mailbox = getenv("MAIL"))) return; if(stat(mailbox, &omstat)){ @@ -294,7 +274,9 @@ getmailstatus() { } } -ckmailstatus() { +void +ckmailstatus(void) +{ if(!mailbox #ifdef MAILCKFREQ || moves < laststattime + MAILCKFREQ @@ -316,13 +298,12 @@ ckmailstatus() { } } -newmail() { +static void +newmail(void) +{ /* produce a scroll of mail */ struct obj *obj; struct monst *md; - extern char plname[]; - extern struct obj *mksobj(), *addinv(); - extern struct monst *makemon(); extern struct permonst pm_mail_daemon; obj = mksobj(SCR_MAIL); @@ -341,13 +322,12 @@ newmail() { } obj = addinv(obj); - (void) identify(obj); /* set known and do prinv() */ + identify(obj); /* set known and do prinv() */ } /* make md run through the cave */ -mdrush(md,away) -struct monst *md; -boolean away; +static void +mdrush(struct monst *md, bool away) { int uroom = inroom(u.ux, u.uy); if(uroom >= 0) { @@ -398,7 +378,9 @@ boolean away; pmon(md); } -readmail() { +void +readmail(void) +{ #ifdef DEF_MAILREADER /* This implies that UNIX is defined */ char *mr = 0; more(); @@ -409,7 +391,7 @@ readmail() { exit(1); } #else /* DEF_MAILREADER */ - (void) page_file(mailbox, FALSE); + page_file(mailbox, FALSE); #endif /* DEF_MAILREADER */ /* get new stat; not entirely correct: there is a small time window where we do not see new mail */ @@ -417,8 +399,8 @@ readmail() { } #endif /* MAIL */ -regularize(s) /* normalize file name - we don't like ..'s or /'s */ -char *s; +void +regularize(char *s) /* normalize file name - we don't like ..'s or /'s */ { char *lp; diff --git a/games/hack/hack.vault.c b/games/hack/hack.vault.c index 866efeca5d..7f48113540 100644 --- a/games/hack/hack.vault.c +++ b/games/hack/hack.vault.c @@ -1,21 +1,38 @@ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* hack.vault.c - version 1.0.2 */ /* $FreeBSD: src/games/hack/hack.vault.c,v 1.4 1999/11/16 10:26:38 marcel Exp $ */ -/* $DragonFly: src/games/hack/hack.vault.c,v 1.3 2004/11/06 12:29:17 eirikn Exp $ */ +/* $DragonFly: src/games/hack/hack.vault.c,v 1.4 2006/08/21 19:45:32 pavalos Exp $ */ #include "hack.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(void) +{ +} -#else +int +gd_move(void) +{ + return(2); +} + +void +gddead(struct monst *mtmp) +{ +} + +void +replgd(struct monst *mtmp, struct monst *mtmp2) +{ +} +void +invault(void) +{ +} + +#else -#include "def.mkroom.h" -extern struct monst *makemon(); #define FCSIZ (ROWNO+COLNO) struct fakecorridor { xchar fx,fy,ftyp; @@ -35,8 +52,11 @@ static struct monst *guard; static int gdlevel; #define EGD ((struct egd *)(&(guard->mextra[0]))) -static -restfakecorr() +static void restfakecorr(void); +static bool goldincorridor(void); + +static void +restfakecorr(void) { int fcx,fcy,fcbeg; struct rm *crm; @@ -58,8 +78,8 @@ restfakecorr() guard = 0; } -static -goldincorridor() +static bool +goldincorridor(void) { int fci; @@ -69,7 +89,9 @@ goldincorridor() return(0); } -setgd(){ +void +setgd(void) +{ struct monst *mtmp; for(mtmp = fmon; mtmp; mtmp = mtmp->nmon) if(mtmp->isgd){ guard = mtmp; @@ -79,7 +101,9 @@ struct monst *mtmp; guard = 0; } -invault(){ +void +invault(void) +{ int tmp = inroom(u.ux, u.uy); if(tmp < 0 || rooms[tmp].rtype != VAULT) { u.uinvault = 0; @@ -163,7 +187,9 @@ fnd: } } -gd_move(){ +int +gd_move(void) +{ int x,y,dx,dy,gx,gy,nx,ny,typ; struct fakecorridor *fcp; struct rm *crm; @@ -247,12 +273,14 @@ newpos: return(1); } -gddead(){ +void +gddead(void) +{ guard = 0; } -replgd(mtmp,mtmp2) -struct monst *mtmp, *mtmp2; +void +replgd(struct monst *mtmp, struct monst *mtmp2) { if(mtmp == guard) guard = mtmp2; diff --git a/games/hack/hack.version.c b/games/hack/hack.version.c index 15b7f03952..7c0d80ccc4 100644 --- a/games/hack/hack.version.c +++ b/games/hack/hack.version.c @@ -1,11 +1,14 @@ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* hack.version.c - version 1.0.3 */ /* $FreeBSD: src/games/hack/hack.version.c,v 1.3 1999/08/27 23:29:05 peter Exp $ */ -/* $DragonFly: src/games/hack/hack.version.c,v 1.3 2004/11/06 12:29:17 eirikn Exp $ */ +/* $DragonFly: src/games/hack/hack.version.c,v 1.4 2006/08/21 19:45:32 pavalos Exp $ */ #include "date.h" +#include "hack.h" -doversion(){ +int +doversion(void) +{ pline("%s 1.0.3 - last edit %s.", ( #ifdef QUEST "Quest" diff --git a/games/hack/hack.wield.c b/games/hack/hack.wield.c index 965114d7c6..5b0538bbee 100644 --- a/games/hack/hack.wield.c +++ b/games/hack/hack.wield.c @@ -1,16 +1,19 @@ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* hack.wield.c - version 1.0.3 */ /* $FreeBSD: src/games/hack/hack.wield.c,v 1.4 1999/11/16 10:26:38 marcel Exp $ */ -/* $DragonFly: src/games/hack/hack.wield.c,v 1.3 2005/05/22 03:37:05 y0netan1 Exp $ */ +/* $DragonFly: src/games/hack/hack.wield.c,v 1.4 2006/08/21 19:45:32 pavalos Exp $ */ #include "hack.h" extern struct obj zeroobj; -setuwep(obj) struct obj *obj; { +void +setuwep(struct obj *obj) +{ setworn(obj, W_WEP); } -dowield() +int +dowield(void) { struct obj *wep; int res = 0; @@ -46,7 +49,9 @@ dowield() return(res); } -corrode_weapon(){ +void +corrode_weapon(void) +{ if(!uwep || uwep->olet != WEAPON_SYM) return; /* %% */ if(uwep->rustfree) pline("Your %s not affected.", aobjnam(uwep, "are")); @@ -56,12 +61,11 @@ corrode_weapon(){ } } -chwepon(otmp,amount) -struct obj *otmp; -int amount; +bool +chwepon(struct obj *otmp, int amount) { const char *color = (amount < 0) ? "black" : "green"; - const char *time; + const char *ltime; if(!uwep || uwep->olet != WEAPON_SYM) { strange_feeling(otmp, @@ -93,9 +97,9 @@ int amount; return(1); } if(!rn2(6)) amount *= 2; - time = (amount*amount == 1) ? "moment" : "while"; + ltime = (amount*amount == 1) ? "moment" : "while"; pline("Your %s %s for a %s.", - aobjnam(uwep, "glow"), color, time); + aobjnam(uwep, "glow"), color, ltime); uwep->spe += amount; if(amount > 0) uwep->cursed = 0; return(1); diff --git a/games/hack/hack.wizard.c b/games/hack/hack.wizard.c index 25d45e3986..f3a04c37b9 100644 --- a/games/hack/hack.wizard.c +++ b/games/hack/hack.wizard.c @@ -1,21 +1,25 @@ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* hack.wizard.c - version 1.0.3 */ /* $FreeBSD: src/games/hack/hack.wizard.c,v 1.3 1999/11/16 02:57:14 billf Exp $ */ -/* $DragonFly: src/games/hack/hack.wizard.c,v 1.2 2003/06/17 04:25:24 dillon Exp $ */ +/* $DragonFly: src/games/hack/hack.wizard.c,v 1.3 2006/08/21 19:45:32 pavalos Exp $ */ /* wizard code - inspired by rogue code from Merlyn Leroy (digi-g!brian) */ #include "hack.h" extern struct permonst pm_wizard; -extern struct monst *makemon(); #define WIZSHOT 6 /* one chance in WIZSHOT that wizard will try magic */ #define BOLT_LIM 8 /* from this distance D and 1 will try to hit you */ char wizapp[] = "@DNPTUVXcemntx"; +static void aggravate(void); +static void clonewiz(struct monst *); + /* If he has found the Amulet, make the wizard appear after some time */ -amulet(){ +void +amulet(void) +{ struct obj *otmp; struct monst *mtmp; @@ -35,8 +39,8 @@ amulet(){ } } -wiz_hit(mtmp) -struct monst *mtmp; +bool +wiz_hit(struct monst *mtmp) { /* if we have stolen or found the amulet, we disappear */ if(mtmp->minvent && mtmp->minvent->olet == AMULET_SYM && @@ -74,15 +78,15 @@ hithim: - amulet is on level 26 again. */ if(hitu(mtmp, d(mtmp->data->damn,mtmp->data->damd)) && !rn2(20) && stealamulet(mtmp)) - ; + return(0); } else inrange(mtmp); /* try magic */ return(0); } -inrange(mtmp) -struct monst *mtmp; +void +inrange(struct monst *mtmp) { schar tx,ty; @@ -133,7 +137,7 @@ struct monst *mtmp; case 0: /* create a nasty monster from a deep level */ /* (for the moment, 'nasty' is not implemented) */ - (void) makemon((struct permonst *)0, u.ux, u.uy); + makemon((struct permonst *)0, u.ux, u.uy); break; case 1: pline("\"Destroy the thief, my pets!\""); @@ -166,7 +170,8 @@ struct monst *mtmp; } } -aggravate() +static void +aggravate(void) { struct monst *mtmp; @@ -177,12 +182,12 @@ aggravate() } } -clonewiz(mtmp) -struct monst *mtmp; +static void +clonewiz(struct monst *mtmp) { struct monst *mtmp2; - if(mtmp2 = makemon(PM_WIZARD, mtmp->mx, mtmp->my)) { + if((mtmp2 = makemon(PM_WIZARD, mtmp->mx, mtmp->my))) { flags.no_of_wizards = 2; unpmon(mtmp2); mtmp2->mappearance = wizapp[rn2(sizeof(wizapp)-1)]; diff --git a/games/hack/hack.worm.c b/games/hack/hack.worm.c index 7c1eb919ed..1db4e7c6b3 100644 --- a/games/hack/hack.worm.c +++ b/games/hack/hack.worm.c @@ -1,17 +1,20 @@ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* hack.worm.c - version 1.0.2 */ /* $FreeBSD: src/games/hack/hack.worm.c,v 1.4 1999/11/16 10:26:38 marcel Exp $ */ -/* $DragonFly: src/games/hack/hack.worm.c,v 1.3 2004/11/06 12:29:17 eirikn Exp $ */ +/* $DragonFly: src/games/hack/hack.worm.c,v 1.4 2006/08/21 19:45:32 pavalos Exp $ */ #include "hack.h" #ifndef NOWORM -#include "def.wseg.h" struct wseg *wsegs[32]; /* linked list, tail first */ struct wseg *wheads[32]; long wgrowtime[32]; -getwn(mtmp) struct monst *mtmp; { +static void remseg(struct wseg *); + +bool +getwn(struct monst *mtmp) +{ int tmp; for(tmp=1; tmp<32; tmp++) if(!wsegs[tmp]) { mtmp->wormno = tmp; @@ -21,7 +24,9 @@ int tmp; } /* called to initialize a worm unless cut in half */ -initworm(mtmp) struct monst *mtmp; { +void +initworm(struct monst *mtmp) +{ struct wseg *wtmp; int tmp = mtmp->wormno; if(!tmp) return; @@ -29,18 +34,18 @@ int tmp = mtmp->wormno; wgrowtime[tmp] = 0; wtmp->wx = mtmp->mx; wtmp->wy = mtmp->my; -/* wtmp->wdispl = 0; */ wtmp->nseg = 0; } -worm_move(mtmp) struct monst *mtmp; { +void +worm_move(struct monst *mtmp) +{ struct wseg *wtmp, *whd; int tmp = mtmp->wormno; wtmp = newseg(); wtmp->wx = mtmp->mx; wtmp->wy = mtmp->my; wtmp->nseg = 0; -/* wtmp->wdispl = 0; */ (whd = wheads[tmp])->nseg = wtmp; wheads[tmp] = wtmp; if(cansee(whd->wx,whd->wy)){ @@ -60,7 +65,9 @@ int tmp = mtmp->wormno; remseg(whd); } -worm_nomove(mtmp) struct monst *mtmp; { +void +worm_nomove(struct monst *mtmp) +{ int tmp; struct wseg *wtmp; tmp = mtmp->wormno; @@ -72,7 +79,9 @@ struct wseg *wtmp; mtmp->mhp -= 3; /* mhpmax not changed ! */ } -wormdead(mtmp) struct monst *mtmp; { +void +wormdead(struct monst *mtmp) +{ int tmp = mtmp->wormno; struct wseg *wtmp, *wtmp2; if(!tmp) return; @@ -84,15 +93,19 @@ struct wseg *wtmp, *wtmp2; wsegs[tmp] = 0; } -wormhit(mtmp) struct monst *mtmp; { +void +wormhit(struct monst *mtmp) +{ int tmp = mtmp->wormno; struct wseg *wtmp; if(!tmp) return; /* worm without tail */ for(wtmp = wsegs[tmp]; wtmp; wtmp = wtmp->nseg) - (void) hitu(mtmp,1); + hitu(mtmp,1); } -wormsee(tmp) unsigned tmp; { +void +wormsee(unsigned int tmp) +{ struct wseg *wtmp = wsegs[tmp]; if(!wtmp) panic("wormsee: wtmp==0"); for(; wtmp->nseg; wtmp = wtmp->nseg) @@ -102,17 +115,18 @@ struct wseg *wtmp = wsegs[tmp]; } } -pwseg(wtmp) struct wseg *wtmp; { +void +pwseg(struct wseg *wtmp) +{ if(!wtmp->wdispl){ atl(wtmp->wx, wtmp->wy, '~'); wtmp->wdispl = 1; } } -cutworm(mtmp,x,y,weptyp) -struct monst *mtmp; -xchar x,y; -uchar weptyp; /* uwep->otyp or 0 */ +void +cutworm(struct monst *mtmp, xchar x, xchar y, uchar weptyp) +/* weptyp: uwep->otyp or 0 */ { struct wseg *wtmp, *wtmp2; struct monst *mtmp2; @@ -177,7 +191,9 @@ uchar weptyp; /* uwep->otyp or 0 */ panic("Cannot find worm segment"); } -remseg(wtmp) struct wseg *wtmp; { +static void +remseg(struct wseg *wtmp) +{ if(wtmp->wdispl) newsym(wtmp->wx, wtmp->wy); free((char *) wtmp); diff --git a/games/hack/hack.worn.c b/games/hack/hack.worn.c index 730546712c..50f3ba12ce 100644 --- a/games/hack/hack.worn.c +++ b/games/hack/hack.worn.c @@ -1,7 +1,7 @@ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* hack.worn.c - version 1.0.2 */ /* $FreeBSD: src/games/hack/hack.worn.c,v 1.3 1999/11/16 02:57:14 billf Exp $ */ -/* $DragonFly: src/games/hack/hack.worn.c,v 1.2 2003/06/17 04:25:24 dillon Exp $ */ +/* $DragonFly: src/games/hack/hack.worn.c,v 1.3 2006/08/21 19:45:32 pavalos Exp $ */ #include "hack.h" @@ -22,9 +22,8 @@ struct worn { { 0, 0 } }; -setworn(obj, mask) -struct obj *obj; -long mask; +void +setworn(struct obj *obj, long mask) { struct worn *wp; struct obj *oobj; @@ -51,7 +50,9 @@ long mask; } /* called e.g. when obj is destroyed */ -setnotworn(obj) struct obj *obj; { +void +setnotworn(struct obj *obj) +{ struct worn *wp; for(wp = worn; wp->w_mask; wp++) diff --git a/games/hack/hack.zap.c b/games/hack/hack.zap.c index d4c5c9afa2..3e6306e3b0 100644 --- a/games/hack/hack.zap.c +++ b/games/hack/hack.zap.c @@ -1,13 +1,11 @@ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* hack.zap.c - version 1.0.3 */ /* $FreeBSD: src/games/hack/hack.zap.c,v 1.4 1999/11/16 10:26:38 marcel Exp $ */ -/* $DragonFly: src/games/hack/hack.zap.c,v 1.4 2005/05/22 03:37:05 y0netan1 Exp $ */ +/* $DragonFly: src/games/hack/hack.zap.c,v 1.5 2006/08/21 19:45:32 pavalos Exp $ */ #include "hack.h" -extern struct obj *mkobj_at(); -extern struct monst *makemon(), *mkmon_at(), youmonst; -struct monst *bhit(); +extern struct monst youmonst; static const char *fl[]= { "magic missile", @@ -17,11 +15,18 @@ static const char *fl[]= { "death ray" }; +static void bhitm(struct monst *, struct obj *); +static bool bhito(struct obj *, struct obj *); +static char dirlet(int, int); +static int zhit(struct monst *, int); +static bool revive(struct obj *); +static void rloco(struct obj *); +static void burn_scrolls(void); + /* Routines for IMMEDIATE wands. */ /* bhitm: monster mtmp was hit by the effect of wand otmp */ -bhitm(mtmp, otmp) -struct monst *mtmp; -struct obj *otmp; +static void +bhitm(struct monst *mtmp, struct obj *otmp) { wakeup(mtmp); switch(otmp->otyp) { @@ -69,8 +74,10 @@ struct obj *otmp; } } -bhito(obj, otmp) /* object obj was hit by the effect of wand otmp */ -struct obj *obj, *otmp; /* returns TRUE if sth was done */ +static bool +bhito(struct obj *obj, struct obj *otmp) + /* object obj was hit by the effect of wand otmp */ + /* returns TRUE if sth was done */ { int res = TRUE; @@ -119,7 +126,8 @@ struct obj *obj, *otmp; /* returns TRUE if sth was done */ return(res); } -dozap() +int +dozap(void) { struct obj *obj; xchar zx,zy; @@ -142,10 +150,10 @@ dozap() if(u.dz > 0) { struct obj *otmp = o_at(u.ux, u.uy); if(otmp) - (void) bhito(otmp, obj); + bhito(otmp, obj); } } else - (void) bhit(u.dx,u.dy,rn1(8,6),0,bhitm,bhito,obj); + bhit(u.dx,u.dy,rn1(8,6),0,bhitm,bhito,obj); } else { switch(obj->otyp){ case WAN_LIGHT: @@ -158,13 +166,12 @@ dozap() { int cnt = 1; if(!rn2(23)) cnt += rn2(7) + 1; while(cnt--) - (void) makemon((struct permonst *) 0, u.ux, u.uy); + makemon((struct permonst *) 0, u.ux, u.uy); } break; case WAN_WISHING: { char buf[BUFSZ]; struct obj *otmp; - extern struct obj *readobjnam(), *addinv(); if(u.uluck + rn2(5) < 0) { pline("Unfortunately, nothing happens."); break; @@ -268,18 +275,16 @@ exclam(int force) return( (force < 0) ? "?" : (force <= 4) ? "." : "!" ); } -hit(str,mtmp,force) -char *str; -struct monst *mtmp; -char *force; /* usually either "." or "!" */ +void +hit(const char *str, struct monst *mtmp, const char *force) + /* force: usually either "." or "!" */ { if(!cansee(mtmp->mx,mtmp->my)) pline("The %s hits it.", str); else pline("The %s hits %s%s", str, monnam(mtmp), force); } -miss(str,mtmp) -char *str; -struct monst *mtmp; +void +miss(const char *str, struct monst *mtmp) { if(!cansee(mtmp->mx,mtmp->my)) pline("The %s misses it.",str); else pline("The %s misses %s.",str,monnam(mtmp)); @@ -293,12 +298,15 @@ struct monst *mtmp; these an argument function is called. */ /* check !u.uswallow before calling bhit() */ +/* ddx, ddy, range: direction and range + * sym: symbol displayed on path + * fhitm, fhito: fns called when mon/obj hit + * obj: 2nd arg to fhitm/fhito + */ struct monst * -bhit(ddx,ddy,range,sym,fhitm,fhito,obj) -int ddx,ddy,range; /* direction and range */ -char sym; /* symbol displayed on path */ -int (*fhitm)(), (*fhito)(); /* fns called when mon/obj hit */ -struct obj *obj; /* 2nd arg to fhitm/fhito */ +bhit(int ddx, int ddy, int range, char sym, + void (*fhitm)(struct monst *, struct obj *), + bool (*fhito)(struct obj *, struct obj *), struct obj *obj) { struct monst *mtmp; struct obj *otmp; @@ -312,7 +320,7 @@ struct obj *obj; /* 2nd arg to fhitm/fhito */ bhitpos.x += ddx; bhitpos.y += ddy; typ = levl[bhitpos.x][bhitpos.y].typ; - if(mtmp = m_at(bhitpos.x,bhitpos.y)){ + if((mtmp = m_at(bhitpos.x,bhitpos.y))){ if(sym) { tmp_at(-1, -1); /* close call */ return(mtmp); @@ -339,11 +347,11 @@ struct obj *obj; /* 2nd arg to fhitm/fhito */ } struct monst * -boomhit(dx,dy) { +boomhit(int dx, int dy) +{ int i, ct; struct monst *mtmp; char sym = ')'; - extern schar xdir[], ydir[]; bhitpos.x = u.ux; bhitpos.y = u.uy; @@ -358,7 +366,7 @@ boomhit(dx,dy) { dy = ydir[i]; bhitpos.x += dx; bhitpos.y += dy; - if(mtmp = m_at(bhitpos.x, bhitpos.y)){ + if((mtmp = m_at(bhitpos.x, bhitpos.y))){ tmp_at(-1,-1); return(mtmp); } @@ -369,7 +377,7 @@ boomhit(dx,dy) { } if(bhitpos.x == u.ux && bhitpos.y == u.uy) { /* ct == 9 */ if(rn2(20) >= 10+u.ulevel){ /* we hit ourselves */ - (void) thitu(10, rnd(10), "boomerang"); + thitu(10, rnd(10), "boomerang"); break; } else { /* we catch it */ tmp_at(-1,-1); @@ -384,8 +392,9 @@ boomhit(dx,dy) { return(0); } -char -dirlet(dx,dy) int dx,dy; { +static char +dirlet(int dx, int dy) +{ return (dx == dy) ? '\\' : (dx && dy) ? '/' : dx ? '-' : '|'; } @@ -393,10 +402,8 @@ dirlet(dx,dy) int dx,dy; { /* type == -1: monster spitting fire at you */ /* type == -1,-2,-3: bolts sent out by wizard */ /* called with dx = dy = 0 with vertical bolts */ -buzz(type,sx,sy,dx,dy) -int type; -xchar sx,sy; -int dx,dy; +void +buzz(int type, xchar sx, xchar sy, int dx, int dy) { int abstype = abs(type); const char *fltxt = (type == -1) ? "blaze of fire" : fl[abstype]; @@ -540,9 +547,8 @@ int dx,dy; Tmp_at(-1,-1); } -zhit(mon,type) /* returns damage to mon */ -struct monst *mon; -int type; +static int +zhit(struct monst *mon, int type) /* returns damage to mon */ { int tmp = 0; @@ -576,10 +582,10 @@ int type; #define CORPSE_I_TO_C(otyp) (char) ((otyp >= DEAD_ACID_BLOB)\ ? 'a' + (otyp - DEAD_ACID_BLOB)\ : '@' + (otyp - DEAD_HUMAN)) -revive(obj) -struct obj *obj; +static bool +revive(struct obj *obj) { - struct monst *mtmp; + struct monst *mtmp = NULL; if(obj->olet == FOOD_SYM && obj->otyp > CORPSE) { /* do not (yet) revive shopkeepers */ @@ -591,8 +597,8 @@ struct obj *obj; return(!!mtmp); /* TRUE if some monster created */ } -rloco(obj) -struct obj *obj; +static void +rloco(struct obj *obj) { int tx,ty,otx,oty; @@ -608,10 +614,10 @@ struct obj *obj; newsym(otx,oty); } -fracture_rock(obj) /* fractured by pick-axe or wand of striking */ -struct obj *obj; /* no texts here! */ +void +fracture_rock(struct obj *obj) /* fractured by pick-axe or wand of striking */ + /* no texts here! */ { - /* unpobj(obj); */ obj->otyp = ROCK; obj->quan = 7 + rn2(60); obj->owt = weight(obj); @@ -620,7 +626,8 @@ struct obj *obj; /* no texts here! */ prl(obj->ox,obj->oy); } -burn_scrolls() +static void +burn_scrolls(void) { struct obj *obj, *obj2; int cnt = 0; diff --git a/games/hack/makedefs.c b/games/hack/makedefs.c index 1ac535bb98..c4e3048332 100644 --- a/games/hack/makedefs.c +++ b/games/hack/makedefs.c @@ -1,10 +1,14 @@ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* makedefs.c - version 1.0.2 */ /* $FreeBSD: src/games/hack/makedefs.c,v 1.4 1999/11/16 02:57:15 billf Exp $ */ -/* $DragonFly: src/games/hack/makedefs.c,v 1.2 2003/06/17 04:25:24 dillon Exp $ */ +/* $DragonFly: src/games/hack/makedefs.c,v 1.3 2006/08/21 19:45:32 pavalos Exp $ */ +#include +#include #include +#include #include +#include /* construct definitions of object constants */ #define LINSZ 1000 @@ -13,15 +17,22 @@ int fd; char string[STRSZ]; -main(argc, argv) - int argc; - char **argv; +static void readline(void); +static char nextchar(void); +static bool skipuntil(const char *); +static bool getentry(void); +static void capitalize(char *); +static bool letter(char); +static bool digit(char); + +int +main(int argc, char **argv) { -int index = 0; +int idx = 0; int propct = 0; char *sp; if (argc != 2) { - (void)fprintf(stderr, "usage: makedefs file\n"); + fprintf(stderr, "usage: makedefs file\n"); exit(1); } if ((fd = open(argv[1], 0)) < 0) { @@ -31,7 +42,7 @@ char *sp; skipuntil("objects[] = {"); while(getentry()) { if(!*string){ - index++; + idx++; continue; } for(sp = string; *sp; sp++) @@ -45,22 +56,24 @@ char *sp; for(sp = string; *sp; sp++) capitalize(sp); /* avoid trouble with stupid C preprocessors */ if(!strncmp(string, "WORTHLESS_PIECE_OF_", 19)) - printf("/* #define %s %d */\n", string, index); + printf("/* #define %s %d */\n", string, idx); else - printf("#define %s %d\n", string, index); - index++; + printf("#define %s %d\n", string, idx); + idx++; } printf("\n#define CORPSE DEAD_HUMAN\n"); printf("#define LAST_GEM (JADE+1)\n"); printf("#define LAST_RING %d\n", propct); - printf("#define NROFOBJECTS %d\n", index-1); + printf("#define NROFOBJECTS %d\n", idx-1); exit(0); } char line[LINSZ], *lp = line, *lp0 = line, *lpe = line; int eof; -readline(){ +static void +readline(void) +{ int n = read(fd, lp0, (line+LINSZ)-lp0); if(n < 0){ printf("Input error.\n"); @@ -70,8 +83,9 @@ int n = read(fd, lp0, (line+LINSZ)-lp0); lpe = lp0+n; } -char -nextchar(){ +static char +nextchar(void) +{ if(lp == lpe){ readline(); lp = lp0; @@ -79,15 +93,18 @@ nextchar(){ return((lp == lpe) ? 0 : *lp++); } -skipuntil(s) char *s; { -char *sp0, *sp1; +static bool +skipuntil(const char *s) +{ +const char *sp0; +char *sp1; loop: while(*s != nextchar()) if(eof) { printf("Cannot skipuntil %s\n", s); exit(1); } - if(strlen(s) > lpe-lp+1){ + if((int)strlen(s) > lpe-lp+1){ char *lp1, *lp2; lp2 = lp; lp1 = lp = lp0; @@ -96,7 +113,7 @@ loop: lp0 = lp1; readline(); lp0 = lp2; - if(strlen(s) > lpe-lp+1) { + if((int)strlen(s) > lpe-lp+1) { printf("error in skipuntil"); exit(1); } @@ -111,7 +128,9 @@ loop: goto loop; } -getentry(){ +static bool +getentry(void) +{ int inbraces = 0, inparens = 0, stringseen = 0, commaseen = 0; int prefix = 0; char ch; @@ -138,7 +157,7 @@ char identif[NSZ], *ip; !strcmp(identif, "RING") || !strcmp(identif, "POTION") || !strcmp(identif, "SCROLL")) - (void) strncpy(string, identif, 3), + strncpy(string, identif, 3), string[3] = '_', prefix = 4; } @@ -213,15 +232,21 @@ char identif[NSZ], *ip; } } -capitalize(sp) char *sp; { +static void +capitalize(char *sp) +{ if('a' <= *sp && *sp <= 'z') *sp += 'A'-'a'; } -letter(ch) char ch; { +static bool +letter(char ch) +{ return( ('a' <= ch && ch <= 'z') || ('A' <= ch && ch <= 'Z') ); } -digit(ch) char ch; { +static bool +digit(char ch) +{ return( '0' <= ch && ch <= '9' ); } diff --git a/games/hack/rnd.c b/games/hack/rnd.c index eb10fa6d06..adf8d4cd71 100644 --- a/games/hack/rnd.c +++ b/games/hack/rnd.c @@ -1,31 +1,31 @@ /* rnd.c - version 1.0.2 */ /* $FreeBSD: src/games/hack/rnd.c,v 1.5 1999/11/16 10:26:38 marcel Exp $ */ -/* $DragonFly: src/games/hack/rnd.c,v 1.2 2003/06/17 04:25:24 dillon Exp $ */ +/* $DragonFly: src/games/hack/rnd.c,v 1.3 2006/08/21 19:45:32 pavalos Exp $ */ -#include +#include "hack.h" #define RND(x) (random() % x) -rn1(x,y) -int x,y; +int +rn1(int x, int y) { return(RND(x)+y); } -rn2(x) -int x; +int +rn2(int x) { return(RND(x)); } -rnd(x) -int x; +int +rnd(int x) { return(RND(x)+1); } -d(n,x) -int n,x; +int +d(int n, int x) { int tmp = n;