From fd2d026fd1c99f603db826e5ecab98e4910b91f8 Mon Sep 17 00:00:00 2001 From: YONETANI Tomokazu Date: Sun, 22 May 2005 03:37:05 +0000 Subject: [PATCH] More -Wwrite-strings cleanup and make sure you can actually play it. --- games/hack/def.func_tab.h | 3 ++- games/hack/def.objclass.h | 5 +++-- games/hack/def.permonst.h | 4 +++- games/hack/hack.Decl.c | 4 ++-- games/hack/hack.apply.c | 5 ++--- games/hack/hack.c | 4 +--- games/hack/hack.do.c | 3 +-- games/hack/hack.do_name.c | 7 ++++--- games/hack/hack.do_wear.c | 3 +-- games/hack/hack.eat.c | 8 +++----- games/hack/hack.end.c | 22 ++++++++++++---------- games/hack/hack.engrave.c | 3 +-- games/hack/hack.fight.c | 4 ++-- games/hack/hack.h | 14 ++++++++++---- games/hack/hack.invent.c | 5 ++--- games/hack/hack.main.c | 11 ++++------- games/hack/hack.mon.c | 6 +++--- games/hack/hack.o_init.c | 8 +++++--- games/hack/hack.objnam.c | 14 +++++++------- games/hack/hack.potion.c | 7 +++---- games/hack/hack.pri.c | 5 ++--- games/hack/hack.rip.c | 23 +++++++++++++---------- games/hack/hack.shk.c | 4 ++-- games/hack/hack.shknam.c | 22 +++++++++++----------- games/hack/hack.steal.c | 3 +-- games/hack/hack.termcap.c | 39 ++++++++++++++++++++------------------- games/hack/hack.timeout.c | 4 ++-- games/hack/hack.trap.c | 4 ++-- games/hack/hack.unix.c | 6 ++++-- games/hack/hack.wield.c | 7 ++++--- games/hack/hack.zap.c | 12 +++++------- 31 files changed, 137 insertions(+), 132 deletions(-) diff --git a/games/hack/def.func_tab.h b/games/hack/def.func_tab.h index 63f74d2ef6..9e4c1b1e58 100644 --- a/games/hack/def.func_tab.h +++ b/games/hack/def.func_tab.h @@ -1,5 +1,6 @@ /* 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 $ */ struct func_tab { char f_char; @@ -9,7 +10,7 @@ struct func_tab { extern struct func_tab cmdlist[]; struct ext_func_tab { - char *ef_txt; + const char *ef_txt; int (*ef_funct)(); }; diff --git a/games/hack/def.objclass.h b/games/hack/def.objclass.h index 9e17de237e..d513d5abbc 100644 --- a/games/hack/def.objclass.h +++ b/games/hack/def.objclass.h @@ -1,11 +1,12 @@ /* 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 $ */ /* definition of a class of objects */ struct objclass { - char *oc_name; /* actual name */ - char *oc_descr; /* description when name unknown */ + const char *oc_name; /* actual name */ + const char *oc_descr; /* description when name unknown */ char *oc_uname; /* called by user */ Bitfield(oc_name_known,1); Bitfield(oc_merge,1); /* merge otherwise equal objects */ diff --git a/games/hack/def.permonst.h b/games/hack/def.permonst.h index b19efc6ae4..74eb9f8910 100644 --- a/games/hack/def.permonst.h +++ b/games/hack/def.permonst.h @@ -1,8 +1,10 @@ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* def.permonst.h - version 1.0.2 */ +/* $DragonFly: src/games/hack/def.permonst.h,v 1.2 2005/05/22 03:37:05 y0netan1 Exp $ */ struct permonst { - char *mname,mlet; + const char *mname; + char mlet; schar mlevel,mmove,ac,damn,damd; unsigned pxlth; }; diff --git a/games/hack/hack.Decl.c b/games/hack/hack.Decl.c index 532a0c6a95..ddcf9307ac 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.2 2004/11/06 12:29:17 eirikn Exp $ */ +/* $DragonFly: src/games/hack/hack.Decl.c,v 1.3 2005/05/22 03:37:05 y0netan1 Exp $ */ #include "hack.h" char nul[40]; /* contains zeros */ @@ -27,7 +27,7 @@ struct monst youmonst; /* dummy; used as return value for boomhit */ xchar dlevel = 1; xchar xupstair, yupstair, xdnstair, ydnstair; -char *save_cm = 0, *killer, *nomovemsg; +const char *save_cm, *killer, *nomovemsg; long moves = 1; long wailmsg = 0; diff --git a/games/hack/hack.apply.c b/games/hack/hack.apply.c index 494c49e176..e8b026dc29 100644 --- a/games/hack/hack.apply.c +++ b/games/hack/hack.apply.c @@ -1,7 +1,7 @@ /* 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.2 2003/06/17 04:25:24 dillon Exp $ */ +/* $DragonFly: src/games/hack/hack.apply.c,v 1.3 2005/05/22 03:37:05 y0netan1 Exp $ */ #include "hack.h" #include "def.edog.h" @@ -10,7 +10,6 @@ static struct monst *bchit(); extern struct obj *addinv(); extern struct trap *maketrap(); extern int (*occupation)(); -extern char *occtxt; extern char quitchars[]; extern char pl_character[]; @@ -277,7 +276,7 @@ dig() { } } else if(dig_effort > 100) { - char *digtxt; + const char *digtxt; struct obj *obj; lev = &levl[dpx][dpy]; diff --git a/games/hack/hack.c b/games/hack/hack.c index 80b53e5a69..251cde7081 100644 --- a/games/hack/hack.c +++ b/games/hack/hack.c @@ -1,14 +1,12 @@ /* 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.3 2004/11/06 12:29:17 eirikn Exp $ */ +/* $DragonFly: src/games/hack/hack.c,v 1.4 2005/05/22 03:37:05 y0netan1 Exp $ */ #include "hack.h" #include extern char news0(); -extern char *nomovemsg; -extern char *exclam(); extern struct obj *addinv(); extern boolean hmon(); diff --git a/games/hack/hack.do.c b/games/hack/hack.do.c index 2bd8dd4525..5dfdaf30df 100644 --- a/games/hack/hack.do.c +++ b/games/hack/hack.do.c @@ -1,7 +1,7 @@ /* 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.3 2004/11/06 12:29:17 eirikn Exp $ */ +/* $DragonFly: src/games/hack/hack.do.c,v 1.4 2005/05/22 03:37:05 y0netan1 Exp $ */ /* Contains code for 'd', 'D' (drop), '>', '<' (up, down) and 't' (throw) */ @@ -12,7 +12,6 @@ extern boolean hmon(); extern boolean level_exists[]; extern struct monst youmonst; extern char *Doname(); -extern char *nomovemsg; static int drop(); diff --git a/games/hack/hack.do_name.c b/games/hack/hack.do_name.c index ef23208f1b..e136f2e8e3 100644 --- a/games/hack/hack.do_name.c +++ b/games/hack/hack.do_name.c @@ -1,7 +1,7 @@ /* 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.2 2003/06/17 04:25:24 dillon Exp $ */ +/* $DragonFly: src/games/hack/hack.do_name.c,v 1.3 2005/05/22 03:37:05 y0netan1 Exp $ */ #include "hack.h" #include @@ -179,7 +179,8 @@ struct obj *obj; *str1 = str; } -char *ghostnames[] = { /* these names should have length < PL_NSIZ */ +/* these names should have length < PL_NSIZ */ +const char *ghostnames[] = { "adri", "andries", "andreas", "bert", "david", "dirk", "emile", "frans", "fred", "greg", "hether", "jay", "john", "jon", "kay", "kenny", "maud", "michiel", "mike", "peter", "robert", "ron", @@ -196,7 +197,7 @@ extern char *shkname(); } switch(mtmp->data->mlet) { case ' ': - { char *gn = (char *) mtmp->mextra; + { const char *gn = (const char *)mtmp->mextra; if(!*gn) { /* might also look in scorefile */ gn = ghostnames[rn2(SIZE(ghostnames))]; if(!rn2(2)) (void) diff --git a/games/hack/hack.do_wear.c b/games/hack/hack.do_wear.c index 4d6849e358..bb3cee61f4 100644 --- a/games/hack/hack.do_wear.c +++ b/games/hack/hack.do_wear.c @@ -1,11 +1,10 @@ /* 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.3 2004/11/06 12:29:17 eirikn Exp $ */ +/* $DragonFly: src/games/hack/hack.do_wear.c,v 1.4 2005/05/22 03:37:05 y0netan1 Exp $ */ #include "hack.h" #include -extern char *nomovemsg; extern char quitchars[]; extern char *Doname(); diff --git a/games/hack/hack.eat.c b/games/hack/hack.eat.c index d7a9ac083e..1146c7e19d 100644 --- a/games/hack/hack.eat.c +++ b/games/hack/hack.eat.c @@ -1,14 +1,12 @@ /* 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.3 2004/11/06 12:29:17 eirikn Exp $ */ +/* $DragonFly: src/games/hack/hack.eat.c,v 1.4 2005/05/22 03:37:05 y0netan1 Exp $ */ #include "hack.h" char POISONOUS[] = "ADKSVabhks"; -extern char *nomovemsg; extern int (*afternmv)(); extern int (*occupation)(); -extern char *occtxt; extern struct obj *splitobj(), *addinv(); /* hunger texts used on bottom line (each 8 chars long) */ @@ -20,7 +18,7 @@ extern struct obj *splitobj(), *addinv(); #define FAINTED 5 #define STARVED 6 -char *hu_stat[] = { +const char *hu_stat[] = { "Satiated", " ", "Hungry ", @@ -36,7 +34,7 @@ init_uhunger(){ } #define TTSZ SIZE(tintxts) -struct { char *txt; int nut; } 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, diff --git a/games/hack/hack.end.c b/games/hack/hack.end.c index c283aac064..315225e8cf 100644 --- a/games/hack/hack.end.c +++ b/games/hack/hack.end.c @@ -1,14 +1,15 @@ /* 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.3 2004/11/06 12:29:17 eirikn Exp $ */ +/* $DragonFly: src/games/hack/hack.end.c,v 1.4 2005/05/22 03:37:05 y0netan1 Exp $ */ #include "hack.h" #include #include #define Sprintf (void) sprintf extern char plname[], pl_character[]; -extern char *itoa(), *ordin(), *eos(); +extern char *itoa(), *eos(); +static const char *ordin(int); xchar maxdlevel = 1; @@ -65,8 +66,8 @@ static char buf[BUFSZ]; /* called with arg "died", "drowned", "escaped", "quit", "choked", "panicked", "burned", "starved" or "tricked" */ /* Be careful not to call panic from here! */ -done(st1) -char *st1; +void +done(const char *st1) { #ifdef WIZARD @@ -221,8 +222,8 @@ topten(){ int rank, rank0 = -1, rank1 = 0; int occ_cnt = PERSMAX; struct toptenentry *t0, *t1, *tprev; - char *recfile = RECORD; - char *reclock = "record_lock"; + const char *recfile = RECORD; + const char *reclock = "record_lock"; int sleepct = 300; FILE *rfile; int flg = 0; @@ -459,9 +460,10 @@ static char buf[12]; return(buf); } -char * -ordin(n) int n; { -int d = n%10; +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"); } @@ -510,7 +512,7 @@ prscore(argc,argv) int argc; char **argv; { int playerct; int rank; struct toptenentry *t1, *t2; - char *recfile = RECORD; + const char *recfile = RECORD; FILE *rfile; int flg = 0; int i; diff --git a/games/hack/hack.engrave.c b/games/hack/hack.engrave.c index cdf0ca0ab8..21a8fa6a8e 100644 --- a/games/hack/hack.engrave.c +++ b/games/hack/hack.engrave.c @@ -1,11 +1,10 @@ /* 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.2 2003/06/17 04:25:24 dillon Exp $ */ +/* $DragonFly: src/games/hack/hack.engrave.c,v 1.3 2005/05/22 03:37:05 y0netan1 Exp $ */ #include "hack.h" -extern char *nomovemsg; extern char nul[]; extern struct obj zeroobj; struct engr { diff --git a/games/hack/hack.fight.c b/games/hack/hack.fight.c index d51226170f..306c058ffb 100644 --- a/games/hack/hack.fight.c +++ b/games/hack/hack.fight.c @@ -1,11 +1,11 @@ /* 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.3 2004/11/06 12:29:17 eirikn Exp $ */ +/* $DragonFly: src/games/hack/hack.fight.c,v 1.4 2005/05/22 03:37:05 y0netan1 Exp $ */ #include "hack.h" extern struct permonst li_dog, dog, la_dog; -extern char *exclam(), *xname(); +extern char *xname(); extern struct obj *mkobj_at(); static boolean far_noise; diff --git a/games/hack/hack.h b/games/hack/hack.h index f1eb65f54b..8e63ae8d52 100644 --- a/games/hack/hack.h +++ b/games/hack/hack.h @@ -1,6 +1,6 @@ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* hack.h - version 1.0.3 */ -/* $DragonFly: src/games/hack/hack.h,v 1.2 2004/11/06 12:29:17 eirikn Exp $ */ +/* $DragonFly: src/games/hack/hack.h,v 1.3 2005/05/22 03:37:05 y0netan1 Exp $ */ #include "config.h" #include @@ -111,7 +111,7 @@ struct you { #define Stoned u.uprops[STONED].p_flgs #define PROP(x) (x-RIN_ADORNMENT) /* convert ring to index in uprops */ unsigned umconf:1; - char *usick_cause; + const char *usick_cause; struct prop uprops[LAST_RING+10]; unsigned uswallow:1; /* set if swallowed by a monster */ @@ -130,7 +130,7 @@ struct you { extern struct you u; -extern char *traps[]; +extern const char *traps[]; extern char *monnam(), *Monnam(), *amonnam(), *Amonnam(), *doname(), *aobjnam(); extern char readchar(); @@ -141,7 +141,7 @@ extern xchar curx,cury; /* cursor location on screen */ extern coord bhitpos; /* place where thrown weapon falls to the ground */ extern xchar seehx,seelx,seehy,seely; /* where to see*/ -extern char *save_cm,*killer; +extern const char *save_cm, *killer, *nomovemsg; extern xchar dlevel, maxdlevel; /* dungeon level */ @@ -152,6 +152,12 @@ 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))) diff --git a/games/hack/hack.invent.c b/games/hack/hack.invent.c index eac4100c2c..e01324053a 100644 --- a/games/hack/hack.invent.c +++ b/games/hack/hack.invent.c @@ -1,7 +1,7 @@ /* 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.3 2004/11/06 12:29:17 eirikn Exp $ */ +/* $DragonFly: src/games/hack/hack.invent.c,v 1.4 2005/05/22 03:37:05 y0netan1 Exp $ */ #include "hack.h" #include @@ -705,7 +705,7 @@ dotypeinv () /* free after Robert Viduya */ dolook() { struct obj *otmp, *otmp0; struct gold *gold; - char *verb = Blind ? "feel" : "see"; + const char *verb = Blind ? "feel" : "see"; int ct = 0; if(!u.uswallow) { @@ -791,7 +791,6 @@ merged(otmp,obj,lose) struct obj *otmp, *obj; { * [Bug: d$ and pickup still tell you how much it was.] */ extern int (*occupation)(); -extern char *occtxt; static long goldcounted; countgold(){ diff --git a/games/hack/hack.main.c b/games/hack/hack.main.c index a22d335f85..5cbf8e53e3 100644 --- a/games/hack/hack.main.c +++ b/games/hack/hack.main.c @@ -1,7 +1,7 @@ /* 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.2 2003/06/17 04:25:24 dillon Exp $ */ +/* $DragonFly: src/games/hack/hack.main.c,v 1.3 2005/05/22 03:37:05 y0netan1 Exp $ */ #include #include @@ -21,7 +21,7 @@ extern char genocided[60], fut_geno[]; int (*afternmv)(); int (*occupation)(); -char *occtxt; /* defined when occupation != NULL */ +const char *occtxt; void done1(); void hangup(); @@ -35,11 +35,10 @@ char SAVEF[PL_NSIZ + 11] = "save/"; /* save/99999player */ char *hname; /* name of the game (argv[0] of call) */ char obuf[BUFSIZ]; /* BUFSIZ is defined in stdio.h */ -extern char *nomovemsg; extern long wailmsg; #ifdef CHDIR -static void chdirx(); +static void chdirx(const char *, boolean); #endif main(argc,argv) @@ -451,9 +450,7 @@ char *s; #ifdef CHDIR static void -chdirx(dir, wr) -char *dir; -boolean wr; +chdirx(const char *dir, boolean wr) { #ifdef SECURE diff --git a/games/hack/hack.mon.c b/games/hack/hack.mon.c index 503f24e3e7..1dd9e519cd 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.3 2004/11/06 12:29:17 eirikn Exp $ */ +/* $DragonFly: src/games/hack/hack.mon.c,v 1.4 2005/05/22 03:37:05 y0netan1 Exp $ */ #include "hack.h" #include "hack.mfndpos.h" @@ -16,7 +16,7 @@ extern struct obj *mkobj_at(); int warnlevel; /* used by movemon and dochugw */ long lastwarntime; int lastwarnlev; -char *warnings[] = { +static const char *warnings[] = { "white", "pink", "red", "ruby", "purple", "black" }; @@ -81,7 +81,7 @@ movemon() warnlevel = SIZE(warnings)-1; if(warnlevel >= 0) if(warnlevel > lastwarnlev || moves > lastwarntime + 5){ - char *rr; + const char *rr; switch(Warning & (LEFT_RING | RIGHT_RING)){ case LEFT_RING: rr = "Your left ring glows"; diff --git a/games/hack/hack.o_init.c b/games/hack/hack.o_init.c index 99b013c2fb..8e43d368aa 100644 --- a/games/hack/hack.o_init.c +++ b/games/hack/hack.o_init.c @@ -1,7 +1,7 @@ /* 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.2 2003/06/17 04:25:24 dillon Exp $ */ +/* $DragonFly: src/games/hack/hack.o_init.c,v 1.3 2005/05/22 03:37:05 y0netan1 Exp $ */ #include #include "config.h" /* for typedefs */ @@ -19,8 +19,10 @@ char ch; } init_objects(){ -int i, j, first, last, sum, end; -char let, *tmp; + int i, j, first, last, sum, end; + char let; + const char *tmp; + /* init base; if probs given check that they add up to 100, otherwise compute probs; shuffle descriptions */ end = SIZE(objects); diff --git a/games/hack/hack.objnam.c b/games/hack/hack.objnam.c index b4e04bd8fb..6490512fb7 100644 --- a/games/hack/hack.objnam.c +++ b/games/hack/hack.objnam.c @@ -1,7 +1,7 @@ /* 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.2 2003/06/17 04:25:24 dillon Exp $ */ +/* $DragonFly: src/games/hack/hack.objnam.c,v 1.3 2005/05/22 03:37:05 y0netan1 Exp $ */ #include "hack.h" #define Sprintf (void) sprintf @@ -36,8 +36,8 @@ int otyp; { static char buf[BUFSZ]; struct objclass *ocl = &objects[otyp]; -char *an = ocl->oc_name; -char *dn = ocl->oc_descr; +const char *an = ocl->oc_name; +const char *dn = ocl->oc_descr; char *un = ocl->oc_uname; int nn = ocl->oc_name_known; switch(ocl->oc_olet) { @@ -88,8 +88,8 @@ struct obj *obj; static char bufr[BUFSZ]; char *buf = &(bufr[PREFIX]); /* leave room for "17 -3 " */ int nn = objects[obj->otyp].oc_name_known; -char *an = objects[obj->otyp].oc_name; -char *dn = objects[obj->otyp].oc_descr; +const char *an = objects[obj->otyp].oc_name; +const char *dn = objects[obj->otyp].oc_descr; char *un = objects[obj->otyp].oc_uname; int pl = (obj->quan != 1); if(!obj->dknown && !Blind) obj->dknown = 1; /* %% doesnt belong here */ @@ -333,7 +333,7 @@ struct obj *obj; return(s); } -char *wrp[] = { "wand", "ring", "potion", "scroll", "gem" }; +static const char *wrp[] = { "wand", "ring", "potion", "scroll", "gem" }; char wrpsym[] = { WAND_SYM, RING_SYM, POTION_SYM, SCROLL_SYM, GEM_SYM }; struct obj * @@ -497,7 +497,7 @@ srch: i = 1; if(let) i = bases[letindex(let)]; while(i <= NROFOBJECTS && (!let || objects[i].oc_olet == let)){ - char *zn = objects[i].oc_name; + const char *zn = objects[i].oc_name; if(!zn) goto nxti; if(an && strcmp(an, zn)) diff --git a/games/hack/hack.potion.c b/games/hack/hack.potion.c index 3756d99563..2e8702318e 100644 --- a/games/hack/hack.potion.c +++ b/games/hack/hack.potion.c @@ -1,11 +1,10 @@ /* 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.2 2003/06/17 04:25:24 dillon Exp $ */ +/* $DragonFly: src/games/hack/hack.potion.c,v 1.3 2005/05/22 03:37:05 y0netan1 Exp $ */ #include "hack.h" extern int float_down(); -extern char *nomovemsg; extern struct monst youmonst; extern struct monst *makemon(); @@ -220,7 +219,7 @@ char *txt; useup(obj); } -char *bottlenames[] = { +static const char *bottlenames[] = { "bottle", "phial", "flagon", "carafe", "flask", "jar", "vial" }; @@ -229,7 +228,7 @@ struct monst *mon; struct obj *obj; { extern char *xname(); - char *botlnam = bottlenames[rn2(SIZE(bottlenames))]; + const char *botlnam = bottlenames[rn2(SIZE(bottlenames))]; boolean uclose, isyou = (mon == &youmonst); if(isyou) { diff --git a/games/hack/hack.pri.c b/games/hack/hack.pri.c index 35cd9c1a3f..aab15d4c06 100644 --- a/games/hack/hack.pri.c +++ b/games/hack/hack.pri.c @@ -1,18 +1,17 @@ /* 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.3 2004/11/06 12:29:17 eirikn Exp $ */ +/* $DragonFly: src/games/hack/hack.pri.c,v 1.4 2005/05/22 03:37:05 y0netan1 Exp $ */ #include "hack.h" #include xchar scrlx, scrhx, scrly, scrhy; /* corners of new area on screen */ -extern char *hu_stat[]; /* in eat.c */ extern char *CD; swallowed() { - char *ulook = "|@|"; + char ulook[] = {"|@|"}; ulook[1] = u.usym; cls(); diff --git a/games/hack/hack.rip.c b/games/hack/hack.rip.c index 6af6345832..b77305568c 100644 --- a/games/hack/hack.rip.c +++ b/games/hack/hack.rip.c @@ -1,14 +1,15 @@ /* 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.2 2003/06/17 04:25:24 dillon Exp $ */ +/* $DragonFly: src/games/hack/hack.rip.c,v 1.3 2005/05/22 03:37:05 y0netan1 Exp $ */ #include #include "hack.h" +static void center(int , const char *); extern char plname[]; -static char *rip[] = { +static char rip[][60] = { " ----------", " / \\", " / REST \\", @@ -23,14 +24,13 @@ static char *rip[] = { " | 1001 |", " *| * * * | *", " _________)/\\\\_//(\\/(/\\)/\\//\\/|_)_______\n", -0 }; +static const int n_rips = sizeof(rip) / sizeof(rip[0]); outrip(){ - char **dp = rip; char *dpx; char buf[BUFSZ]; - int x,y; + int i, x, y; cls(); (void) strcpy(buf, plname); @@ -57,9 +57,9 @@ outrip(){ center(9, buf); (void) sprintf(buf, "%4d", getyear()); center(11, buf); - for(y=8; *dp; y++,dp++){ + for(y = 8, i = 0; i < n_rips; y++, i++){ x = 0; - dpx = *dp; + dpx = rip[i]; while(dpx[x]) { while(dpx[x] == ' ') x++; curs(x,y); @@ -75,9 +75,12 @@ outrip(){ getret(); } -center(line, text) int line; char *text; { -char *ip,*op; - ip = text; +static void +center(int line, const char *text) +{ + const char *ip = text; + char *op; + op = &rip[line][28 - ((strlen(text)+1)/2)]; while(*ip) *op++ = *ip++; } diff --git a/games/hack/hack.shk.c b/games/hack/hack.shk.c index b2fd5d75c7..7d0a5b9cc7 100644 --- a/games/hack/hack.shk.c +++ b/games/hack/hack.shk.c @@ -1,7 +1,7 @@ /* 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.4 2005/05/07 18:03:39 corecode Exp $ */ +/* $DragonFly: src/games/hack/hack.shk.c,v 1.5 2005/05/22 03:37:05 y0netan1 Exp $ */ #include "hack.h" #ifdef QUEST @@ -58,7 +58,7 @@ char shtypes[] = { /* 8 shoptypes: 7 specialized, 1 mixed */ POTION_SYM, ARMOR_SYM, 0 }; -static char *shopnam[] = { +static const char *shopnam[] = { "engagement ring", "walking cane", "antique weapon", "delicatessen", "second hand book", "liquor", "used armor", "assorted antiques" diff --git a/games/hack/hack.shknam.c b/games/hack/hack.shknam.c index a63abcd57a..9293a6f112 100644 --- a/games/hack/hack.shknam.c +++ b/games/hack/hack.shknam.c @@ -1,11 +1,11 @@ /* 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.2 2003/06/17 04:25:24 dillon Exp $ */ +/* $DragonFly: src/games/hack/hack.shknam.c,v 1.3 2005/05/22 03:37:05 y0netan1 Exp $ */ #include "hack.h" -char *shkliquors[] = { +static const char *shkliquors[] = { /* Ukraine */ "Njezjin", "Tsjernigof", "Gomel", "Ossipewsk", "Gorlowka", /* N. Russia */ @@ -20,7 +20,7 @@ char *shkliquors[] = { 0 }; -char *shkbooks[] = { +static const char *shkbooks[] = { /* Eire */ "Skibbereen", "Kanturk", "Rath Luirc", "Ennistymon", "Lahinch", "Loughrea", "Croagh", "Maumakeogh", "Ballyjamesduff", @@ -32,7 +32,7 @@ char *shkbooks[] = { 0 }; -char *shkarmors[] = { +static const char *shkarmors[] = { /* Turquie */ "Demirci", "Kalecik", "Boyabai", "Yildizeli", "Gaziantep", "Siirt", "Akhalataki", "Tirebolu", "Aksaray", "Ermenak", @@ -43,7 +43,7 @@ char *shkarmors[] = { 0 }; -char *shkwands[] = { +static const char *shkwands[] = { /* Wales */ "Yr Wyddgrug", "Trallwng", "Mallwyd", "Pontarfynach", "Rhaeader", "Llandrindod", "Llanfair-ym-muallt", @@ -57,7 +57,7 @@ char *shkwands[] = { 0 }; -char *shkrings[] = { +static const char *shkrings[] = { /* Hollandse familienamen */ "Feyfer", "Flugi", "Gheel", "Havic", "Haynin", "Hoboken", "Imbyze", "Juyn", "Kinsky", "Massis", "Matray", "Moy", @@ -70,7 +70,7 @@ char *shkrings[] = { 0 }; -char *shkfoods[] = { +static const char *shkfoods[] = { /* Indonesia */ "Djasinga", "Tjibarusa", "Tjiwidej", "Pengalengan", "Bandjar", "Parbalingga", "Bojolali", "Sarangan", @@ -82,7 +82,7 @@ char *shkfoods[] = { 0 }; -char *shkweapons[] = { +static const char *shkweapons[] = { /* Perigord */ "Voulgezac", "Rouffiac", "Lerignac", "Touverac", "Guizengeard", "Melac", "Neuvicq", "Vanzac", "Picq", "Urignac", "Corignac", @@ -93,7 +93,7 @@ char *shkweapons[] = { 0 }; -char *shkgeneral[] = { +static const char *shkgeneral[] = { /* Suriname */ "Hebiwerie", "Possogroenoe", "Asidonhopo", "Manlobbi", "Adjama", "Pakka Pakka", "Kabalebo", "Wonotobo", @@ -113,7 +113,7 @@ char *shkgeneral[] = { struct shk_nx { char x; - char **xn; + const char **xn; } shk_nx[] = { { POTION_SYM, shkliquors }, { SCROLL_SYM, shkbooks }, @@ -127,7 +127,7 @@ struct shk_nx { findname(nampt, let) char *nampt; char let; { struct shk_nx *p = shk_nx; -char **q; +const char **q; int i; while(p->x && p->x != let) p++; q = p->xn; diff --git a/games/hack/hack.steal.c b/games/hack/hack.steal.c index e80299a0e7..148ad1e7fd 100644 --- a/games/hack/hack.steal.c +++ b/games/hack/hack.steal.c @@ -1,7 +1,7 @@ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* hack.steal.c - version 1.0.3 */ /* $FreeBSD: src/games/hack/hack.steal.c,v 1.4 1999/11/16 10:26:38 marcel Exp $ */ -/* $DragonFly: src/games/hack/hack.steal.c,v 1.2 2003/06/17 04:25:24 dillon Exp $ */ +/* $DragonFly: src/games/hack/hack.steal.c,v 1.3 2005/05/22 03:37:05 y0netan1 Exp $ */ #include "hack.h" @@ -113,7 +113,6 @@ struct monst *mtmp; (void) armoroff(otmp); otmp->cursed = curssv; if(multi < 0){ - extern char *nomovemsg; extern int (*afternmv)(); /* multi = 0; diff --git a/games/hack/hack.termcap.c b/games/hack/hack.termcap.c index ee94f8d227..bf6690d91e 100644 --- a/games/hack/hack.termcap.c +++ b/games/hack/hack.termcap.c @@ -1,7 +1,7 @@ /* 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.3 2005/05/07 18:05:14 corecode Exp $ */ +/* $DragonFly: src/games/hack/hack.termcap.c,v 1.4 2005/05/22 03:37:05 y0netan1 Exp $ */ #include #include @@ -32,46 +32,47 @@ startup() error("Can't get TERM."); if(tgetent(tptr, term) < 1) error("Unknown terminal type: %s.", term); - if(tgetflag("NP") || tgetflag("nx")) + if (tgetflag(__DECONST(char *, "NP")) || + tgetflag(__DECONST(char *, "nx"))) flags.nonull = 1; - if(pc = tgetstr("pc", &tbufptr)) + if(pc = tgetstr(__DECONST(char *, "pc"), &tbufptr)) tcPC = *pc; - if(!(tcBC = tgetstr("bc", &tbufptr))) { - if(!tgetflag("bs")) + if(!(tcBC = tgetstr(__DECONST(char *, "bc"), &tbufptr))) { + if(!tgetflag(__DECONST(char *, "bs"))) error("Terminal must backspace."); tcBC = tbufptr; tbufptr += 2; *tcBC = '\b'; } - HO = tgetstr("ho", &tbufptr); - CO = tgetnum("co"); - LI = tgetnum("li"); + HO = tgetstr(__DECONST(char *, "ho"), &tbufptr); + CO = tgetnum(__DECONST(char *, "co")); + LI = tgetnum(__DECONST(char *, "li")); if(CO < COLNO || LI < ROWNO+2) setclipped(); - if(!(CL = tgetstr("cl", &tbufptr))) + if(!(CL = tgetstr(__DECONST(char *, "cl"), &tbufptr))) error("Hack needs CL."); - ND = tgetstr("nd", &tbufptr); - if(tgetflag("os")) + ND = tgetstr(__DECONST(char *, "nd"), &tbufptr); + if(tgetflag(__DECONST(char *, "os"))) error("Hack can't have OS."); - CE = tgetstr("ce", &tbufptr); - tcUP = tgetstr("up", &tbufptr); + CE = tgetstr(__DECONST(char *, "ce"), &tbufptr); + tcUP = tgetstr(__DECONST(char *, "up"), &tbufptr); /* It seems that xd is no longer supported, and we should use a linefeed instead; unfortunately this requires resetting CRMOD, and many output routines will have to be modified slightly. Let's leave that till the next release. */ - XD = tgetstr("xd", &tbufptr); + XD = tgetstr(__DECONST(char *, "xd"), &tbufptr); /* not: XD = tgetstr("do", &tbufptr); */ - if(!(CM = tgetstr("cm", &tbufptr))) { + if(!(CM = tgetstr(__DECONST(char *, "cm"), &tbufptr))) { if(!tcUP && !HO) error("Hack needs CM or UP or HO."); printf("Playing hack on terminals without cm is suspect...\n"); getret(); } - SO = tgetstr("so", &tbufptr); - SE = tgetstr("se", &tbufptr); - SG = tgetnum("sg"); /* -1: not fnd; else # of spaces left by so */ + SO = tgetstr(__DECONST(char *, "so"), &tbufptr); + SE = tgetstr(__DECONST(char *, "se"), &tbufptr); + SG = tgetnum(__DECONST(char *, "sg")); if(!SO || !SE || (SG > 0)) SO = SE = 0; - CD = tgetstr("cd", &tbufptr); + CD = tgetstr(__DECONST(char *, "cd"), &tbufptr); set_whole_screen(); /* uses LI and CD */ if(tbufptr-tbuf > sizeof(tbuf)) error("TERMCAP entry too big...\n"); free(tptr); diff --git a/games/hack/hack.timeout.c b/games/hack/hack.timeout.c index 0f73efb74c..c7ef62c173 100644 --- a/games/hack/hack.timeout.c +++ b/games/hack/hack.timeout.c @@ -1,7 +1,7 @@ /* 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.2 2003/06/17 04:25:24 dillon Exp $ */ +/* $DragonFly: src/games/hack/hack.timeout.c,v 1.3 2005/05/22 03:37:05 y0netan1 Exp $ */ #include "hack.h" @@ -43,7 +43,7 @@ struct prop *upp; } /* He is being petrified - dialogue by inmet!tower */ -char *stoned_texts[] = { +static const char *stoned_texts[] = { "You are slowing down.", /* 5 */ "Your limbs are stiffening.", /* 4 */ "Your limbs have turned to stone.", /* 3 */ diff --git a/games/hack/hack.trap.c b/games/hack/hack.trap.c index f7e5dcca41..6c9d959f33 100644 --- a/games/hack/hack.trap.c +++ b/games/hack/hack.trap.c @@ -1,7 +1,7 @@ /* 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.3 2004/11/06 12:29:17 eirikn Exp $ */ +/* $DragonFly: src/games/hack/hack.trap.c,v 1.4 2005/05/22 03:37:05 y0netan1 Exp $ */ #include "hack.h" @@ -9,7 +9,7 @@ extern struct monst *makemon(); char vowels[] = "aeiou"; -char *traps[] = { +const char *traps[] = { " bear trap", "n arrow trap", " dart trap", diff --git a/games/hack/hack.unix.c b/games/hack/hack.unix.c index 1e51bf1aa2..a9d0c810c5 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.4 2005/04/29 09:22:57 joerg Exp $ */ +/* $DragonFly: src/games/hack/hack.unix.c,v 1.5 2005/05/22 03:37:05 y0netan1 Exp $ */ /* This file collects some Unix dependencies; hack.pager.c contains some more */ @@ -83,7 +83,9 @@ midnight() struct stat buf, hbuf; -gethdate(name) char *name; { +void +gethdate(const char *name) +{ /* old version - for people short of space */ char *np; diff --git a/games/hack/hack.wield.c b/games/hack/hack.wield.c index efecbef75e..965114d7c6 100644 --- a/games/hack/hack.wield.c +++ b/games/hack/hack.wield.c @@ -1,7 +1,7 @@ /* 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.2 2003/06/17 04:25:24 dillon Exp $ */ +/* $DragonFly: src/games/hack/hack.wield.c,v 1.3 2005/05/22 03:37:05 y0netan1 Exp $ */ #include "hack.h" extern struct obj zeroobj; @@ -60,8 +60,9 @@ chwepon(otmp,amount) struct obj *otmp; int amount; { -char *color = (amount < 0) ? "black" : "green"; -char *time; + const char *color = (amount < 0) ? "black" : "green"; + const char *time; + if(!uwep || uwep->olet != WEAPON_SYM) { strange_feeling(otmp, (amount > 0) ? "Your hands twitch." diff --git a/games/hack/hack.zap.c b/games/hack/hack.zap.c index 0a8fe830f4..d4c5c9afa2 100644 --- a/games/hack/hack.zap.c +++ b/games/hack/hack.zap.c @@ -1,16 +1,15 @@ /* 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.3 2004/11/06 12:29:17 eirikn Exp $ */ +/* $DragonFly: src/games/hack/hack.zap.c,v 1.4 2005/05/22 03:37:05 y0netan1 Exp $ */ #include "hack.h" extern struct obj *mkobj_at(); extern struct monst *makemon(), *mkmon_at(), youmonst; struct monst *bhit(); -char *exclam(); -char *fl[]= { +static const char *fl[]= { "magic missile", "bolt of fire", "sleep ray", @@ -260,9 +259,8 @@ dozap() return(1); } -char * -exclam(force) -int force; +const char * +exclam(int force) { /* force == 0 occurs e.g. with sleep ray */ /* note that large force is usual with wands so that !! would @@ -401,7 +399,7 @@ xchar sx,sy; int dx,dy; { int abstype = abs(type); - char *fltxt = (type == -1) ? "blaze of fire" : fl[abstype]; + const char *fltxt = (type == -1) ? "blaze of fire" : fl[abstype]; struct rm *lev; xchar range; struct monst *mon; -- 2.41.0