From a6ad8fb14c6bed68eb8b37750e1b2fea36a8c908 Mon Sep 17 00:00:00 2001 From: christos Date: Tue, 10 Nov 2020 22:42:19 +0000 Subject: Time warp forward 34 years so that it compiles (but not work) --- warp/bang.c | 34 ++++------ warp/bang.h | 8 +-- warp/config.H | 18 ++--- warp/config.h | 40 ++--------- warp/config.h.SH | 24 +++---- warp/init.c | 41 ++++++------ warp/init.h | 2 +- warp/intrp.c | 132 ++++++++++++++++-------------------- warp/intrp.h | 19 +++--- warp/move.c | 114 +++++++++++++++---------------- warp/move.h | 13 ++-- warp/object.c | 18 ++--- warp/object.h | 15 ++--- warp/play.c | 26 ++++---- warp/play.h | 4 +- warp/score.c | 200 ++++++++++++++++++++++++++----------------------------- warp/score.h | 12 ++-- warp/sig.c | 14 ++-- warp/sig.h | 13 ++-- warp/sm.c | 8 +-- warp/term.c | 199 ++++++++++++++++++++++++------------------------------ warp/term.h | 84 +++++++++++------------ warp/them.c | 35 +++++----- warp/them.h | 6 +- warp/us.c | 66 +++++++++--------- warp/us.h | 12 ++-- warp/util.c | 184 +++++++++----------------------------------------- warp/util.h | 29 ++++---- warp/version.c | 2 +- warp/version.h | 2 +- warp/warp.c | 77 ++++++++++----------- warp/warp.h | 102 +++++++++++----------------- warp/weapon.c | 118 +++++++++++++++----------------- warp/weapon.h | 10 +-- 34 files changed, 708 insertions(+), 973 deletions(-) diff --git a/warp/bang.c b/warp/bang.c index 88bf9c93..39da8285 100644 --- a/warp/bang.c +++ b/warp/bang.c @@ -26,17 +26,15 @@ #include "bang.h" void -bang_init() +bang_init(void) { ; } void -make_plink(y,x) -Reg1 int x; -Reg2 int y; +make_plink(int x, int y) { - Reg3 OBJECT *obj; + OBJECT *obj; move(y+1,x*2,0); beg_qwrite(); @@ -57,11 +55,7 @@ Reg2 int y; } void -make_blast(y,x,mass,size) -Reg1 int x; -Reg2 int y; -int size; -long mass; +make_blast(int x, int y, int size, long mass) { bangy[nxtbang] = y; bangx[nxtbang] = x; @@ -77,7 +71,7 @@ long mass; return; } else if (mass >= 0) { - Reg3 OBJECT *obj; + OBJECT *obj; move(y+1,x*2,0); beg_qwrite(); @@ -107,15 +101,15 @@ long mass; } void -do_bangs() +do_bangs(void) { - Reg1 int x; - Reg2 int y; - Reg3 int i; - Reg4 int j; - Reg7 int k; - Reg5 int lastxy; - Reg6 OBJECT *obj; + int x; + int y; + int i; + int j; + int k; + int lastxy; + OBJECT *obj; /* read blast list and update blast array */ assert(nxtbang >= 0 && nxtbang <= XSIZE * YSIZE); @@ -131,7 +125,7 @@ do_bangs() yblasted[yy[j] = (y+YSIZE00) % YSIZE] |= 1; xblasted[xx[j] = (x+XSIZE00) % XSIZE] |= 1; } - blasted = TRUE; + blasted = true; for (y=lastxy;y>=0;--y) { for (x=lastxy;x>=0;--x) { if (lastxy > 2) { diff --git a/warp/bang.h b/warp/bang.h index 1ee5b6bc..aa41defc 100644 --- a/warp/bang.h +++ b/warp/bang.h @@ -24,7 +24,7 @@ EXT int yy[MAXBDIST]; EXT int nxtbang; EXT bool banging; -void make_plink(); -void make_blast(); -void do_bangs(); -void bang_init(); +void bang_init(void); +void make_plink(int, int); +void make_blast(int, int, int, long); +void do_bangs(void); diff --git a/warp/config.H b/warp/config.H index 23bdf00c..e2004cb4 100644 --- a/warp/config.H +++ b/warp/config.H @@ -67,15 +67,15 @@ /* How many register declarations are paid attention to? */ -#define Reg1 register /**/ -#define Reg2 register /**/ -#define Reg3 register /**/ -#define Reg4 register /**/ -#define Reg5 register /**/ -#define Reg6 register /**/ -#define Reg7 /**/ -#define Reg8 /**/ -#define Reg9 /**/ +#define register /**/ +#define register /**/ +#define register /**/ +#define register /**/ +#define register /**/ +#define register /**/ +#define /**/ +#define /**/ +#define /**/ #define Reg10 /**/ #define Reg11 /**/ #define Reg12 /**/ diff --git a/warp/config.h b/warp/config.h index b2c1b68a..70f07296 100644 --- a/warp/config.h +++ b/warp/config.h @@ -3,7 +3,7 @@ * to find out if there is input pending on an IO channel. Generally * the routine is used only if FIONREAD and O_NDELAY aren't available. */ -#/*undef RDCHK /**/ +#undef RDCHK /**/ /* SCOREFULL: * This symbol, if defined, indicates that any scoreboard kept by the @@ -11,7 +11,7 @@ * to the user's login name. If the user can change his full name he * can enter multiple scores if this is defined. */ -#/*undef SCOREFULL /**/ +#undef SCOREFULL /**/ /* SIGNEDCHAR: * This symbol, if defined, indicates that characters are a signed type. @@ -25,7 +25,7 @@ * termio.h rather than sgtty.h. There are also differences in the * ioctl() calls that depend on the value of this symbol. */ -#/*undef TERMIO /**/ +#undef TERMIO /**/ /* USENDIR: * This symbol, if defined, indicates that the program should compile @@ -35,15 +35,15 @@ * This symbol, if defined, indicates that the program should include the * system's version of ndir.h, rather than the one with this package. */ -#/*undef USENDIR /**/ -#/*undef LIBNDIR /**/ +#undef USENDIR /**/ +#undef LIBNDIR /**/ #define LIBNDIR /* WHOAMI: * This symbol, if defined, indicates that the program may include * whoami.h. */ -#/*undef WHOAMI /**/ +#undef WHOAMI /**/ /* HOSTNAME: * This symbol contains name of the host the program is going to run on. @@ -77,7 +77,7 @@ */ #define PASSNAMES /* (undef to take name from ~/.fullname) */ #define BERKNAMES /* (that is, ":name,stuff:") */ -#/*undef USGNAMES /* (that is, ":stuff-name(stuff):") */ +#undef USGNAMES /* (that is, ":stuff-name(stuff):") */ /* PREFSHELL: * This symbol contains the full name of the preferred user shell on this @@ -91,32 +91,6 @@ */ #define RANDBITS 15 /**/ -/* Reg1: - * This symbol, along with Reg2, Reg3, etc. is either the word "register" - * or null, depending on whether the C compiler pays attention to this - * many register declarations. The intent is that you don't have to - * order your register declarations in the order of importance, so you - * can freely declare register variables in sub-blocks of code and as - * function parameters. Do not use Reg more than once per routine. - */ - -#define Reg1 register /**/ -#define Reg2 register /**/ -#define Reg3 register /**/ -#define Reg4 /**/ -#define Reg5 /**/ -#define Reg6 /**/ -#define Reg7 /**/ -#define Reg8 /**/ -#define Reg9 /**/ -#define Reg10 /**/ -#define Reg11 /**/ -#define Reg12 /**/ -#define Reg13 /**/ -#define Reg14 /**/ -#define Reg15 /**/ -#define Reg16 /**/ - /* ROOTID: * This symbol contains the uid of root, normally 0. */ diff --git a/warp/config.h.SH b/warp/config.h.SH index b0a07784..cb47e620 100644 --- a/warp/config.h.SH +++ b/warp/config.h.SH @@ -38,9 +38,9 @@ cat <config.h #$d_eunice VMS /**/ /* CHARSPRINTF: - * This symbol is defined if this system declares "char *sprintf()" in - * stdio.h. The trend seems to be to declare it as "int sprintf()". It - * is up to the package author to declare sprintf correctly based on the + * This symbol is defined if this system declares "char *snprintf()" in + * stdio.h. The trend seems to be to declare it as "int snprintf()". It + * is up to the package author to declare snprintf correctly based on the * symbol. */ #$d_charsprf CHARSPRINTF /**/ @@ -219,15 +219,15 @@ cat <config.h * function parameters. Do not use Reg more than once per routine. */ -#define Reg1 $reg1 /**/ -#define Reg2 $reg2 /**/ -#define Reg3 $reg3 /**/ -#define Reg4 $reg4 /**/ -#define Reg5 $reg5 /**/ -#define Reg6 $reg6 /**/ -#define Reg7 $reg7 /**/ -#define Reg8 $reg8 /**/ -#define Reg9 $reg9 /**/ +#define $reg1 /**/ +#define $reg2 /**/ +#define $reg3 /**/ +#define $reg4 /**/ +#define $reg5 /**/ +#define $reg6 /**/ +#define $reg7 /**/ +#define $reg8 /**/ +#define $reg9 /**/ #define Reg10 $reg10 /**/ #define Reg11 $reg11 /**/ #define Reg12 $reg12 /**/ diff --git a/warp/init.c b/warp/init.c index 401b5acc..fc9bea13 100644 --- a/warp/init.c +++ b/warp/init.c @@ -34,33 +34,33 @@ #include "init.h" void -initialize() +initialize(void) { - Reg1 int i; - Reg2 int x; - Reg3 int y; - Reg4 int dist; - Reg5 int ydist; - Reg6 int xdist; + int i; + int x; + int y; + int dist; + int ydist = 0; + int xdist = 0; long e; - int yoff, xoff, ypred, xpred; - Reg7 OBJECT *obj; + int yoff = 0, xoff = 0, ypred, xpred; + OBJECT *obj = NULL; char ch; FILE *mapfp = NULL; bool tmptholspec; int inhabjackpot; long inhenergy; int walksplit = 200; - static char *distname[] = + static const char *distname[] = {" #"," -"," \\"," /", " |"," *"," `"," '"}; - cloaking = madgorns = FALSE; + cloaking = madgorns = false; deados = madfriends = 0; curscore = possiblescore = 0L; yamblast = xamblast = ambsize = 0; if (smarts > 90) - massacre = TRUE; + massacre = true; scandist = (massacre?20:15); antibase = (smarts>60?1:(smarts>40?2:(smarts>25?4:100))); sm35 = (smarts>35?35:smarts); @@ -100,14 +100,15 @@ initialize() yblasted[y] = 0; for (x=0; x 85) inumstars = exdis(800) + rand_mod(100) + 1; else /* too few stars makes 50..85 too hard */ inumstars = exdis(700) + rand_mod(150-super*2) + 50+super*2; + } tmptholspec = (smarts > 15 && inumstars < 450 && ! rand_mod(90-sm80)); if (!klingspec) { inumenemies = rand_mod((smarts+1)/2) + 1; @@ -203,7 +204,7 @@ stars_again: if (debugging) printf(" P\r\n"); dist = 0; - Sprintf(spbuf,"smap.%d", + snprintf(spbuf, sizeof(spbuf), "smap.%d", (prescene>=0?prescene:rand_mod(MAPS)) ); if ((mapfp = fopen(spbuf,"r")) != NULL && fgets(spbuf,10,mapfp) != NULL ) { @@ -216,7 +217,7 @@ stars_again: xoff = rand_mod(XSIZE); /* how much to shift x */ } else { - prespec = FALSE; + prespec = false; prescene = -1; if (rand_mod(2)) goto scenario_again; @@ -356,7 +357,7 @@ stars_again: } } if (mapfp != NULL) - Fclose(mapfp); + fclose(mapfp); if (numcrushes) { do { x = rand_mod(XSIZE); @@ -515,7 +516,7 @@ stars_again: mvaddch(base->posy+1, base->posx*2, base->image); sleep(2); { - Reg7 OBJECT *curobj; + OBJECT *curobj; for (curobj = root.next; curobj != &root; curobj = curobj->next) { mvaddch(curobj->posy+1, curobj->posx*2, curobj->image); @@ -528,7 +529,7 @@ stars_again: whenok = 0; timer = 0; finish = 0; - bombed_out = FALSE; + bombed_out = false; if (ent) entmode = status = 0; else @@ -537,7 +538,7 @@ stars_again: else status = 3; - Sprintf(spbuf, + snprintf(spbuf, sizeof(spbuf), "%-4s E: %4d %2d B: %5d %3d Enemies: %-3d Stars: %-3d Stardate%5d.%1d %9ld", " ", 0, 0, 0, 0, 0, 0, smarts * 100, 0, 0L); mvaddstr(0,0,spbuf); diff --git a/warp/init.h b/warp/init.h index 5eca8c97..5e17bc99 100644 --- a/warp/init.h +++ b/warp/init.h @@ -6,4 +6,4 @@ * */ -void initialize(); +void initialize(void); diff --git a/warp/intrp.c b/warp/intrp.c index 0379d1be..5a370aba 100644 --- a/warp/intrp.c +++ b/warp/intrp.c @@ -23,30 +23,26 @@ char *hostname; #ifdef TILDENAME -static char *tildename = Nullch; -static char *tildedir = Nullch; +static char *tildename = NULL; +static char *tildedir = NULL; #endif -char *dointerp(); -char *getrealname(); +static char *getrealname(uid_t); #ifdef CONDSUB -char *skipinterp(); +static char *skipinterp(const char *, const char *); #endif -static void abort_interp(); +static void abort_interp(void); void -intrp_init(tcbuf) -char *tcbuf; +intrp_init(char *tcbuf) { - char *getlogin(); - /* get environmental stuff */ /* get home directory */ homedir = getenv("HOME"); - if (homedir == Nullch) + if (homedir == NULL) homedir = getenv("LOGDIR"); dotdir = getval("DOTDIR",homedir); @@ -54,10 +50,10 @@ char *tcbuf; /* get login name */ logname = getenv("USER"); - if (logname == Nullch) + if (logname == NULL) logname = getenv("LOGNAME"); #ifdef GETLOGIN - if (logname == Nullch) + if (logname == NULL) logname = savestr(getlogin()); #endif @@ -84,7 +80,7 @@ char *tcbuf; if (scorespec) /* that getwd below takes ~1/3 sec. */ return; /* and we do not need it for -s */ - (void) getwd(tcbuf); /* find working directory name */ + (void) getcwd(tcbuf, sizeof(tcbuf));/* find working directory name */ origdir = savestr(tcbuf); /* and remember it */ } @@ -93,12 +89,11 @@ char *tcbuf; /* Note that there is a 1-deep cache of ~name interpretation */ char * -filexp(s) -Reg1 char *s; +filexp(const char *s) { static char filename[CBUFLEN]; char scrbuf[CBUFLEN]; - Reg2 char *d; + char *d; #ifdef DEBUGGING if (debug & DEB_FILEXP) @@ -112,7 +107,7 @@ Reg1 char *s; s = filename; if (*s == '~') { /* does destination start with ~? */ if (!*(++s) || *s == '/') { - Sprintf(scrbuf,"%s%s",homedir,s); + snprintf(scrbuf, sizeof(scrbuf), "%s%s",homedir,s); /* swap $HOME for it */ #ifdef DEBUGGING if (debug & DEB_FILEXP) @@ -122,7 +117,7 @@ Reg1 char *s; } else { #ifdef TILDENAME - for (d=scrbuf; isalnum(*s); s++,d++) + for (d=scrbuf; isalnum((unsigned char)*s); s++,d++) *d = *s; *d = '\0'; if (tildedir && strEQ(tildename,scrbuf)) { @@ -139,13 +134,12 @@ Reg1 char *s; free(tildename); free(tildedir); } - tildedir = Nullch; + tildedir = NULL; tildename = savestr(scrbuf); { - struct passwd *getpwnam(); struct passwd *pwd = getpwnam(tildename); - Sprintf(scrbuf,"%s%s",pwd->pw_dir,s); + snprintf(scrbuf, sizeof(scrbuf), "%s%s",pwd->pw_dir,s); tildedir = savestr(pwd->pw_dir); strcpy(filename,scrbuf); endpwent(); @@ -170,7 +164,7 @@ Reg1 char *s; strcpy(d,s+2); else { *d++ = '{'; - for (s++; isalnum(*s); s++) *d++ = *s; + for (s++; isalnum((unsigned char)*s); s++) *d++ = *s; /* skip over token */ *d++ = '}'; strcpy(d,s); @@ -193,10 +187,8 @@ Reg1 char *s; #ifdef CONDSUB /* skip interpolations */ -char * -skipinterp(pattern,stoppers) -Reg1 char *pattern; -char *stoppers; +static char * +skipinterp(const char *pattern, const char *stoppers) { while (*pattern && (!stoppers || !index(stoppers,*pattern))) { @@ -253,7 +245,7 @@ char *stoppers; } } getout: - return pattern; /* where we left off */ + return __UNCONST(pattern); /* where we left off */ } #endif @@ -275,17 +267,13 @@ static char *mygets(char *str, size_t n) /* interpret interpolations */ char * -dointerp(dest,destsize,pattern,stoppers) -Reg1 char *dest; -Reg2 int destsize; -Reg3 char *pattern; -char *stoppers; +dointerp(char *dest, size_t destsize, const char *pattern, const char *stoppers) { - Reg4 char *s; - Reg5 int i; + char *s; + int i; char scrbuf[512]; - bool upper = FALSE; - bool lastcomp = FALSE; + bool upper = false; + bool lastcomp = false; int metabit = 0; while (*pattern && (!stoppers || !index(stoppers,*pattern))) { @@ -294,19 +282,19 @@ char *stoppers; printf("dointerp till %s at %s\r\n",stoppers?stoppers:"",pattern); #endif if (*pattern == '%' && pattern[1]) { - upper = FALSE; - lastcomp = FALSE; - for (s=Nullch; !s; ) { + upper = false; + lastcomp = false; + for (s=NULL; !s; ) { switch (*++pattern) { case '^': - upper = TRUE; + upper = true; break; case '_': - lastcomp = TRUE; + lastcomp = true; break; case '{': pattern = cpytill(scrbuf,pattern+1,'}'); - if (s = index(scrbuf,'-')) + if ((s = index(scrbuf,'-')) != NULL) *s++ = '\0'; else s = nullstr; @@ -331,7 +319,7 @@ char *stoppers; matched = strEQ(scrbuf+1,dest); } else - matched = instr(dest,scrbuf) != Nullch; + matched = instr(dest,scrbuf) != NULL; if (matched==(rch == '=')) { pattern = dointerp(dest,destsize,pattern+1,":)"); if (*pattern == ':') @@ -349,11 +337,11 @@ char *stoppers; #endif #ifdef BACKTICK case '`': { - FILE *pipefp, *popen(); + FILE *pipefp; pattern = dointerp(scrbuf,(sizeof scrbuf),pattern+1,"`"); pipefp = popen(scrbuf,"r"); - if (pipefp != Nullfp) { + if (pipefp != NULL) { int len; len = fread(scrbuf,sizeof(char),(sizeof scrbuf)-1, @@ -398,7 +386,7 @@ char *stoppers; break; case '$': s = scrbuf; - Sprintf(s,"%d",getpid()); + snprintf(scrbuf, sizeof(scrbuf), "%d",getpid()); break; case 'H': /* host name */ s = hostname; @@ -433,15 +421,15 @@ char *stoppers; char *t; if (s != scrbuf) { - Safecpy(scrbuf,s,(sizeof scrbuf)); + safecpy(scrbuf,s,(sizeof scrbuf)); s = scrbuf; } if (upper || !(t=rindex(s,'/'))) t = s; - while (*t && !isalpha(*t)) + while (*t && !isalpha((unsigned char)*t)) { t++; - if (islower(*t)) - *t = toupper(*t); + *t = toupper((unsigned char)*t); + } } i = metabit; /* maybe get into register */ if (s == dest) { @@ -476,7 +464,7 @@ char *stoppers; destsize++; } else - *dest++ = i & 037 | metabit; + *dest++ = (i & 037) | metabit; pattern++; } else if (*pattern == '\\' && pattern[1]) { @@ -491,7 +479,7 @@ char *stoppers; i <<= 3; i += *pattern++ - '0'; } - *dest++ = i & 0377 | metabit; + *dest++ = (i & 0377) | metabit; --pattern; } else if (i == 'b') @@ -514,16 +502,13 @@ char *stoppers; } *dest = '\0'; getout: - return pattern; /* where we left off */ + return __UNCONST(pattern); /* where we left off */ } void -interp(dest,destsize,pattern) -char *dest; -int destsize; -char *pattern; +interp(char *dest, size_t destsize, const char *pattern) { - (void) dointerp(dest,destsize,pattern,Nullch); + (void) dointerp(dest,destsize,pattern,NULL); #ifdef DEBUGGING if (debug & DEB_FILEXP) fputs(dest,stdout); @@ -533,9 +518,8 @@ char *pattern; /* get the person's real name from /etc/passwd */ /* (string is overwritten, so it must be copied) */ -char * -getrealname(uid) -int uid; +static char * +getrealname(uid_t uid) { char *s, *c; @@ -547,36 +531,36 @@ int uid; #ifdef BERKJUNK while (*s && !isalnum(*s) && *s != '&') s++; #endif - if ((c = index(s, ',')) != Nullch) + if ((c = index(s, ',')) != NULL) *c = '\0'; - if ((c = index(s, ';')) != Nullch) + if ((c = index(s, ';')) != NULL) *c = '\0'; s = cpytill(buf,s,'&'); if (*s == '&') { /* whoever thought this one up was */ c = buf + strlen(buf); /* in the middle of the night */ strcat(c,logname); /* before the morning after */ strcat(c,s+1); - if (islower(*c)) - *c = toupper(*c); /* gack and double gack */ + if (islower((unsigned char)*c)) + *c = toupper((unsigned char)*c); /* gack and double gack */ } #else - if ((c = index(s, '(')) != Nullch) + if ((c = index(s, '(')) != NULL) *c = '\0'; - if ((c = index(s, '-')) != Nullch) + if ((c = index(s, '-')) != NULL) s = c; strcpy(buf,tmpbuf); #endif endpwent(); return buf; /* return something static */ #else - if ((tmpfp=fopen(filexp(FULLNAMEFILE),"r")) != Nullfp) { - Fgets(buf,sizeof buf,tmpfp); - Fclose(tmpfp); + if ((tmpfp=fopen(filexp(FULLNAMEFILE),"r")) != NULL) { + fgets(buf,sizeof buf,tmpfp); + fclose(tmpfp); } else { resetty(); printf("What is your name? "); - Fgets(buf,(sizeof buf),stdin); + fgets(buf,(sizeof buf),stdin); crmode(); raw(); noecho(); @@ -588,7 +572,7 @@ int uid; if ((tmpfp = fopen(filexp(FULLNAMEFILE),"w")) == NULL) exit(1); fprintf(tmpfp, "%s\n", buf); - Fclose(tmpfp); + fclose(tmpfp); exit(0); } } @@ -598,7 +582,7 @@ int uid; } static void -abort_interp() +abort_interp(void) { fputs("\r\n% interp buffer overflow!\r\n",stdout); sig_catcher(0); diff --git a/warp/intrp.h b/warp/intrp.h index fd5c57ad..b6bfc627 100644 --- a/warp/intrp.h +++ b/warp/intrp.h @@ -9,15 +9,14 @@ * */ -EXT char *origdir INIT(Nullch); /* cwd when warp invoked */ -EXT char *homedir INIT(Nullch); /* login directory */ -EXT char *dotdir INIT(Nullch); /* where . files go */ -EXT char *logname INIT(Nullch); /* login id */ +EXT char *origdir INIT(NULL); /* cwd when warp invoked */ +EXT char *homedir INIT(NULL); /* login directory */ +EXT char *dotdir INIT(NULL); /* where . files go */ +EXT char *logname INIT(NULL); /* login id */ EXT char *hostname; /* host name */ -EXT char *realname INIT(Nullch); /* real name from /etc/passwd */ +EXT char *realname INIT(NULL); /* real name from /etc/passwd */ -void intrp_init(); -char *filexp(); -char *dointerp(); -void interp(); -char *getrealname(); +void intrp_init(char *); +char *filexp(const char *); +void interp(char *, size_t, const char *); +char *dointerp(char *, size_t, const char *, const char *); diff --git a/warp/move.c b/warp/move.c index f022e13b..363ad00a 100644 --- a/warp/move.c +++ b/warp/move.c @@ -28,18 +28,17 @@ #include "move.h" void -move_init() +move_init(void) { ; } void -bounce(obj) -Reg4 OBJECT *obj; +bounce(OBJECT *obj) { - Reg1 int x; - Reg2 int y; - Reg3 int count=0; + int x; + int y; + int count=0; y = (obj->posy - sgn(obj->vely) + YSIZE00) % YSIZE; x = (obj->posx - sgn(obj->velx) + XSIZE00) % XSIZE; @@ -66,12 +65,12 @@ Reg4 OBJECT *obj; } void -move_universe() +move_universe(void) { - Reg1 OBJECT *curobj; - Reg2 int x; - Reg3 int y; - Reg4 OBJECT *temp; + OBJECT *curobj; + int x; + int y; + OBJECT *temp; OBJECT *thenext; for (curobj = movers; curobj != &root; curobj = curobj->next) { @@ -128,7 +127,7 @@ move_universe() movers->prev = curobj; } } - if (temp = occupant[y][x]) { /* already occupied? */ + if ((temp = occupant[y][x]) != NULL) { /* already occupied? */ if (!temp->contend) { if (temp->type == Torp) { if (temp->image == '+') @@ -141,7 +140,7 @@ move_universe() } yblasted[y] |= 1; xblasted[x] |= 1; - blasted = TRUE; + blasted = true; curobj->contend = temp; occupant[y][x] = curobj; switch (curobj->type) { @@ -199,14 +198,14 @@ move_universe() blast[y][x] += 100000; yblasted[y] |= 1; xblasted[x] |= 1; - blasted = TRUE; + blasted = true; } } } if (blasted) { - Reg7 int minxblast = -1; - Reg8 int maxxblast = -2; - Reg5 long tmpblast; + int minxblast = -1; + int maxxblast = -2; + long tmpblast; blasted = numamoebas; for (x=0; ximage == '&') tmpblast >>= 1; else if (temp->type == Web) @@ -237,7 +236,7 @@ move_universe() yblasted[y] = 2; } if (tmpblast) { - Reg6 OBJECT *biggie = 0; + OBJECT *biggie = 0; blast[y][x] = 0; temp = occupant[y][x]; @@ -457,13 +456,13 @@ move_universe() numinhab--; /* FALL THROUGH */ case '*': - banging = TRUE; + banging = true; numstars--; break; case '|': case '-': case '/': case '\\': tmpblast = 100000; make_blast(y,x,curobj->mass,1); - banging = TRUE; + banging = true; deados = 0; break; case 'x': @@ -547,7 +546,7 @@ move_universe() do_bangs(); if (numcrushes && movers->type == Crusher) movers->vely = 0; - if (curobj = base) { + if ((curobj = base) != NULL) { char ch; curobj->velx = 0; @@ -563,7 +562,7 @@ move_universe() setimage(curobj, ch); } } - if (curobj = ent) { + if ((curobj = ent) != NULL) { char ch; if (entmode == 0) { @@ -606,15 +605,12 @@ move_universe() } int -lookaround(y, x, what) -Reg1 int y; -Reg2 int x; -Reg4 char what; +lookaround(int y, int x, char what) { - Reg3 OBJECT *obj; - Reg5 int count=0; - Reg6 int xp; - Reg7 int xm; + OBJECT *obj; + int count=0; + int xp; + int xm; if ((obj=occupant[y][xp=(x+XSIZE01)%XSIZE])&&obj->type == what) /* 0, 1 */ count++; @@ -636,45 +632,39 @@ Reg4 char what; } int -lookfor(y, x, what) -Reg1 int y; -Reg2 int x; -Reg4 char what; +lookfor(int y, int x, char what) { - Reg3 OBJECT *obj; - Reg5 int xp; - Reg6 int xm; + OBJECT *obj; + int xp; + int xm; - if ((obj=occupant[y][xp=(x+XSIZE01)%XSIZE])&&obj->type == what ||/* 0, 1 */ - (obj=occupant[y][xm=(x+XSIZE99)%XSIZE])&&obj->type == what ||/* 0, -1 */ - (obj=occupant[y=(y+YSIZE99)%YSIZE][xp])&&obj->type == what ||/* -1, 1 */ - (obj=occupant[y][x])&&obj->type == what ||/* -1, 0 */ - (obj=occupant[y][xm])&&obj->type == what ||/* -1,-1 */ - (obj=occupant[y=(y+2)%YSIZE][xp])&&obj->type == what ||/* 1, 1 */ - (obj=occupant[y][x])&&obj->type == what ||/* 1, 0 */ - (obj=occupant[y][xm])&&obj->type == what) /* 1, -1 */ + if (((obj=occupant[y][xp=(x+XSIZE01)%XSIZE])&&obj->type == what)||/* 0, 1 */ + ((obj=occupant[y][xm=(x+XSIZE99)%XSIZE])&&obj->type == what)||/* 0, -1 */ + ((obj=occupant[y=(y+YSIZE99)%YSIZE][xp])&&obj->type == what)||/* -1, 1 */ + ((obj=occupant[y][x])&&obj->type == what) ||/* -1, 0 */ + ((obj=occupant[y][xm])&&obj->type == what) ||/* -1,-1 */ + ((obj=occupant[y=(y+2)%YSIZE][xp])&&obj->type == what) ||/* 1, 1 */ + ((obj=occupant[y][x])&&obj->type == what) ||/* 1, 0 */ + ((obj=occupant[y][xm])&&obj->type == what)) /* 1, -1 */ return(1); return (0); } OBJECT* -lookimg(y, x, what) -Reg1 int y; -Reg2 int x; -Reg4 char what; +lookimg(int y, int x, char what) { - Reg3 OBJECT *obj; - Reg5 int xp; - Reg6 int xm; + OBJECT *obj; + int xp; + int xm; - if ((obj=occupant[y][xp=(x+XSIZE01)%XSIZE])&&obj->image==what ||/* 0, 1 */ - (obj=occupant[y][xm=(x+XSIZE99)%XSIZE])&&obj->image==what ||/* 0, -1 */ - (obj=occupant[y=(y+YSIZE99)%YSIZE][xp])&&obj->image==what ||/* -1, 1 */ - (obj=occupant[y][x])&&obj->image==what ||/* -1, 0 */ - (obj=occupant[y][xm])&&obj->image==what ||/* -1,-1 */ - (obj=occupant[y=(y+2)%YSIZE][xp])&&obj->image==what ||/* 1, 1 */ - (obj=occupant[y][x])&&obj->image==what ||/* 1, 0 */ - (obj=occupant[y][xm])&&obj->image==what) /* 1, -1 */ + if (((obj=occupant[y][xp=(x+XSIZE01)%XSIZE])&&obj->image==what)||/* 0, 1 */ + ((obj=occupant[y][xm=(x+XSIZE99)%XSIZE])&&obj->image==what)||/* 0, -1 */ + ((obj=occupant[y=(y+YSIZE99)%YSIZE][xp])&&obj->image==what)||/* -1, 1 */ + ((obj=occupant[y][x])&&obj->image==what) ||/* -1, 0 */ + ((obj=occupant[y][xm])&&obj->image==what) ||/* -1,-1 */ + ((obj=occupant[y=(y+2)%YSIZE][xp])&&obj->image==what) ||/* 1, 1 */ + ((obj=occupant[y][x])&&obj->image==what) ||/* 1, 0 */ + ((obj=occupant[y][xm])&&obj->image==what)) /* 1, -1 */ return obj; - return Null(OBJECT*); + return NULL; } diff --git a/warp/move.h b/warp/move.h index 51e614ad..6f6b86cd 100644 --- a/warp/move.h +++ b/warp/move.h @@ -6,9 +6,10 @@ * */ -void bounce(); -void move_universe(); -int lookaround(); -int lookfor(); -OBJECT *lookimg(); -void move_init(); +void move_init(void); +void bounce(OBJECT *); +void move_universe(void); +int lookaround(int, int, char); +int lookfor(int, int, char); +OBJECT *lookimg(int, int, char); + diff --git a/warp/object.c b/warp/object.c index cf17fde6..2f280118 100644 --- a/warp/object.c +++ b/warp/object.c @@ -12,20 +12,16 @@ #include "object.h" void -object_init() +object_init(void) { ; } OBJECT * -make_object(typ, img, py, px, vy, vx, energ, mas, where) -char typ; -char img; -int px, py, vx, vy; -long energ, mas; -OBJECT *where; +make_object(char typ, char img, int px, int py, int vx, int vy, long energ, + long mas, OBJECT *where) { - Reg1 OBJECT *obj; + OBJECT *obj; if (free_root.next == &free_root) #ifndef lint @@ -60,8 +56,7 @@ OBJECT *where; } void -unmake_object(curobj) -Reg1 OBJECT *curobj; +unmake_object(OBJECT *curobj) { curobj->prev->next = curobj->next; curobj->next->prev = curobj->prev; @@ -72,8 +67,7 @@ Reg1 OBJECT *curobj; } void -free_object(curobj) -Reg1 OBJECT *curobj; +free_object(OBJECT *curobj) { curobj->next = free_root.next; curobj->prev = &free_root; diff --git a/warp/object.h b/warp/object.h index a5d46731..5091a04f 100644 --- a/warp/object.h +++ b/warp/object.h @@ -22,12 +22,8 @@ #define Crusher 7 typedef struct object { - char posx, posy; -#ifdef SIGNEDCHAR - char velx, vely; -#else + short posx, posy; short velx, vely; -#endif struct object *next, *prev, *contend; long energy; long mass; @@ -64,8 +60,7 @@ EXT OBJECT *nuke; EXT OBJECT *occupant[YSIZE][XSIZE]; -OBJECT *make_object(); - -void unmake_object(); -void free_object(); -void object_init(); +void object_init(void); +OBJECT *make_object(char, char, int, int, int, int, long, long, OBJECT *); +void unmake_object(OBJECT *); +void free_object(OBJECT *); diff --git a/warp/play.c b/warp/play.c index 7c040497..a26f76c7 100644 --- a/warp/play.c +++ b/warp/play.c @@ -24,20 +24,20 @@ #include "play.h" void -play_init() +play_init(void) { ; } void -play() +play(void) { - bool done = FALSE; - Reg1 OBJECT *curobj; - Reg2 OBJECT *to; - Reg3 int i; - Reg4 int x; - Reg5 int y; + bool done = false; + OBJECT *curobj; + OBJECT *to; + int i; + int x; + int y; display_status(); #ifdef TIOCOUTQ @@ -48,7 +48,7 @@ play() do { timer++; nxtbang = 0; - banging = FALSE; + banging = false; display_status(); #ifdef TIOCOUTQ while (output_pending() > charsperhalfsec) @@ -69,7 +69,7 @@ play() ent->energy -= ent->energy/40; } else - cloaking = FALSE; + cloaking = false; cloaked = cloaking; } if (base) { @@ -138,6 +138,8 @@ play() possiblescore += 5000; } if (apolloflag & 2) { +/*###141 [cc] warning: array subscript has type 'char' [-Wchar-subscripts]%%%*/ +/*###141 [cc] warning: array subscript has type 'char' [-Wchar-subscripts]%%%*/ if (blast[realapollo->posy][realapollo->posx] <= 32000) bvely = bvelx = 0; realapollo->energy = 32000; @@ -152,7 +154,7 @@ play() if (aretorps) { aretorps = 0; for (i=0;i<2;i++) for (y=0;y<3;y++) for (x=0;x<3;x++) { - if (curobj = isatorp[i][y][x]) { + if ((curobj = isatorp[i][y][x]) != NULL) { to = occupant[(curobj->posy+curobj->vely+YSIZE00)%YSIZE] [(curobj->posx+curobj->velx+XSIZE00)%XSIZE]; if (to && !to->vely && !to->velx) { @@ -170,7 +172,7 @@ play() if (finish) { finish--; if (!finish && (!(numenemies || numos) || (!ent && !base))) { - done = TRUE; + done = true; timer -= 5; } } diff --git a/warp/play.h b/warp/play.h index 9971585b..d6b06a18 100644 --- a/warp/play.h +++ b/warp/play.h @@ -9,5 +9,5 @@ EXT int finish INIT(0); EXT int timer; -void play(); -void play_init(); +void play_init(void); +void play(void); diff --git a/warp/score.c b/warp/score.c index f36e6595..16272669 100644 --- a/warp/score.c +++ b/warp/score.c @@ -29,10 +29,10 @@ #include "score.h" void -score_init() +score_init(void) { - Reg1 char *s; - Reg2 int i; + char *s; + int i; FILE *savfil; #if 0 @@ -65,7 +65,7 @@ score_init() if (scorespec) wscore(); - Sprintf(savefilename, "save.%s", logname); + snprintf(savefilename, sizeof(savefilename), "save.%s", logname); savfil = experimenting ? NULL : fopen(savefilename,"r"); if (savfil != NULL && fgets(spbuf,100,savfil) != NULL) { @@ -89,7 +89,7 @@ That process does not seem to exist anymore, so you'll have to start the\r\n"); "last wave over.\r\n\n"); printf( " [type anything to continue]"); - Fflush(stdout); + fflush(stdout); eat_typeahead(); getcmd(tmpbuf); if (*tmpbuf == INTRCH) @@ -109,7 +109,7 @@ That process does not seem to exist anymore, so you'll have to start the\r\n"); } printf(" 2) Let me terminate the other game\r\n\n"); printf("What do you want to do? "); - Fflush(stdout); + fflush(stdout); eat_typeahead(); getcmd(tmpbuf); printf("\r\n"); @@ -122,7 +122,7 @@ That process does not seem to exist anymore, so you'll have to start the\r\n"); } printf( "Ok, hang on a few moments \r\n"); - Fclose(savfil); + fclose(savfil); if (kill(processnum, SIGQUIT)) { printf("Unable to kill process #%d!\r\n",processnum); roundsleep(2); @@ -138,11 +138,11 @@ That process does not seem to exist anymore, so you'll have to start the\r\n"); /* (warp ignores SIGINT) */ break; } - didkill++; + didkill = true; } savfil = fopen(savefilename,"r"); if (savfil != NULL) { - Fgets(spbuf,100,savfil); + fgets(spbuf,100,savfil); } } } @@ -170,35 +170,35 @@ That process does not seem to exist anymore, so you'll have to start the\r\n"); tholspec = (spbuf[46] == 't'); lowspeed = (spbuf[47] == 'l') || lowspeed; amoebaspec = (spbuf[48] == '&'); - Fclose(savfil); + fclose(savfil); } if (!ismarts) { ismarts = 1; clear(); - page(NEWSFILE,FALSE); + page(NEWSFILE,false); if (smarts) { printf("\r\nSaved game: SCORE DIFF CUMDIFF ENTERPRISES BASES WAVE"); printf("\r\n %7ld %2d %4d %1d %1d %3d", totalscore,smarts,cumsmarts,numents,numbases,wave); } printf("\r\nWould you like instructions? "); - Fflush(stdout); + fflush(stdout); eat_typeahead(); getcmd(buf); printf("\r\n"); if (*buf == INTRCH) finalize(0); if (*buf == 'Y' || *buf == 'y') { - page(HELPFILE,FALSE); + page(HELPFILE,false); printf("\r\nWould you like to play easy games for a while? "); - Fflush(stdout); + fflush(stdout); eat_typeahead(); getcmd(buf); printf("\r\n"); if (*buf == 'Y' || *buf == 'y') { - beginner = TRUE; - lowspeed = TRUE; + beginner = true; + lowspeed = true; } } } @@ -207,32 +207,32 @@ That process does not seem to exist anymore, so you'll have to start the\r\n"); } void -wscore() +wscore(void) { clear(); printf(" TOP WARPISTS\r\n\n"); printf("RANK WHO AKA SCORE DIFF CUMDIFF WHEN\r\n"); - page(SCOREBOARD,TRUE); + page(SCOREBOARD,true); printf(" [Type anything to continue]"); - Fflush(stdout); + fflush(stdout); getcmd(spbuf); if (*spbuf == INTRCH) finalize(0); clear(); printf(" TOP LOW-SPEED WARPISTS\r\n\n"); printf("RANK WHO AKA SCORE DIFF CUMDIFF WHEN\r\n"); - page(LSCOREBOARD,TRUE); + page(LSCOREBOARD,true); printf(" [Type anything to continue]"); - Fflush(stdout); + fflush(stdout); getcmd(spbuf); if (*spbuf == INTRCH) finalize(0); clear(); printf(" TOP FUNNY WARPISTS\r\n\n"); printf("RANK WHO AKA SCORE DIFF CUMDIFF WHEN\r\n"); - page(FSCOREBOARD,TRUE); + page(FSCOREBOARD,true); printf(" [Type anything to continue]"); - Fflush(stdout); + fflush(stdout); getcmd(spbuf); if (*spbuf == INTRCH) finalize(0); @@ -240,33 +240,33 @@ wscore() printf(" GAMES SAVED OR IN PROGRESS\r\n\n"); printf("WHO SCORE DF CDF E B WV FLAGS\r\n"); resetty(); - Sprintf(spbuf,"/bin/cat %ssave.*",SAVEDIR); + snprintf(spbuf, sizeof(spbuf), "/bin/cat %ssave.*",SAVEDIR); #ifndef lint - execl("/bin/sh", "sh", "-c", spbuf, 0); + execl("/bin/sh", "sh", "-c", spbuf, NULL); #endif finalize(1); } void -display_status() +display_status(void) { - Reg1 int tmp; - static char *status_names[] = {"Impl", "Warp", "Base", "****" }; + int tmp; + static const char *status_names[] = {"Impl", "Warp", "Base", "****" }; if (oldstatus != status) { - Sprintf(spbuf,"%-4s",status_names[status]); + snprintf(spbuf, sizeof(spbuf), "%-4s",status_names[status]); mvaddstr(0,0, spbuf); oldstatus = status; } if (ent) { if (ent->energy != oldeenergy) { oldeenergy = ent->energy; - Sprintf(spbuf,"%4ld",oldeenergy); + snprintf(spbuf, sizeof(spbuf), "%4ld",oldeenergy); mvaddstr(0,8, spbuf); } if (etorp != oldetorp) { - Sprintf(spbuf,"%2d",etorp); + snprintf(spbuf, sizeof(spbuf), "%2d",etorp); mvaddstr(0,13, spbuf); oldetorp = etorp; } @@ -281,11 +281,11 @@ display_status() if (base) { if (base->energy != oldbenergy) { oldbenergy = base->energy; - Sprintf(spbuf,"%5ld",oldbenergy); + snprintf(spbuf, sizeof(spbuf), "%5ld",oldbenergy); mvaddstr(0,19, spbuf); } if (btorp != oldbtorp) { - Sprintf(spbuf,"%3d",btorp); + snprintf(spbuf, sizeof(spbuf), "%3d",btorp); mvaddstr(0,25, spbuf); oldbtorp = btorp; } @@ -308,7 +308,7 @@ display_status() if (!--damflag[dam]) { olddamage = damage; damage--; - Sprintf(spbuf,"%s OK *** ",dammess[dam]); + snprintf(spbuf, sizeof(spbuf), "%s OK *** ",dammess[dam]); spbuf[15] = '\0'; mvaddstr(0,46,spbuf); } @@ -317,13 +317,13 @@ display_status() tmp = (34 - damflag[dam]) * 3 - rand_mod(3); if (tmp < 0) tmp = 0; - Sprintf(spbuf,"%d%% %s *** ",tmp,dammess[dam]); + snprintf(spbuf, sizeof(spbuf), "%d%% %s *** ",tmp,dammess[dam]); spbuf[15] = '\0'; mvaddstr(0,46,spbuf); } else if (dam != lastdam || !olddamage) { olddamage = damage; - Sprintf(spbuf,"NO %s *** ",dammess[dam]); + snprintf(spbuf, sizeof(spbuf), "NO %s *** ",dammess[dam]); spbuf[15] = '\0'; mvaddstr(0,46,spbuf); } @@ -334,56 +334,52 @@ display_status() status = entmode = 0; } tmp = damflag[dam] * damage; - Sprintf(spbuf,"%3d.%1d ETR",tmp/10,tmp%10); + snprintf(spbuf, sizeof(spbuf), "%3d.%1d ETR",tmp/10,tmp%10); mvaddstr(0,69,spbuf); lastdam = dam; } else { if (olddamage) { - Sprintf(spbuf,"Stars: %-3d Stardate",numstars); + snprintf(spbuf, sizeof(spbuf), "Stars: %-3d Stardate",numstars); mvaddstr(0,42,spbuf); lastdam = -1; olddamage = 0; oldcurscore = -1; } else if (numstars != oldstrs) { - Sprintf(spbuf,"%-3d",numstars); + snprintf(spbuf, sizeof(spbuf), "%-3d",numstars); mvaddstr(0,49, spbuf); } oldstrs = numstars; } if (numenemies != oldenemies) { - Sprintf(spbuf,"%-3d",numenemies); + snprintf(spbuf, sizeof(spbuf), "%-3d",numenemies); mvaddstr(0,38, spbuf); oldenemies = numenemies; } - if (tmp = timer%10) { - Sprintf(spbuf,"%1d",tmp); + if ((tmp = timer%10) != 0) { + snprintf(spbuf, sizeof(spbuf), "%1d",tmp); mvaddstr(0,67, spbuf); } else { - Sprintf(spbuf,"%5d.%1d",timer/10+smarts*100,tmp); + snprintf(spbuf, sizeof(spbuf), "%5d.%1d",timer/10+smarts*100,tmp); mvaddstr(0,61, spbuf); } if ((!damage || !damflag[dam]) && curscore != oldcurscore) { - Sprintf(spbuf,"%9ld",curscore); + snprintf(spbuf, sizeof(spbuf), "%9ld",curscore); mvaddstr(0,69, spbuf); oldcurscore = curscore; } } void -wavescore() +wavescore(void) { double power, effectscore, starscore, pi_over_2; long bonuses; long tmp; FILE *mapfp; int row; - double pow(); -#ifndef lint - double atan2(); -#endif clear(); if (curscore > possiblescore) @@ -402,99 +398,95 @@ wavescore() power += (350.0 - (double)inumstars) * ((double)inumenemies - 5.0); if (inumstars > 850 && inumenemies > 2) power += ((double)inumstars - 850.0) * ((double)inumenemies - 2.0); -#ifndef lint effectscore = ((double)curscore / possiblescore) * atan2(power, (double) timer + 1.0) / pi_over_2; -#else - effectscore = pi_over_2; -#endif if (inumstars) starscore = (double) numstars / (double) inumstars; else starscore = 1.0; wave++; - Sprintf(spbuf,"Wave = %d, Difficulty = %d, cumulative difficulty = %d", + snprintf(spbuf, sizeof(spbuf), "Wave = %d, Difficulty = %d, cumulative difficulty = %d", wave, smarts, cumsmarts); mvaddstr(1, 13+(smarts<10), spbuf); mvaddstr( 4, 68, " BONUS"); - Sprintf(spbuf,"Efficiency rating: %1.8f (diff=%0.2f,time=%d)", + snprintf(spbuf, sizeof(spbuf), "Efficiency rating: %1.8f (diff=%0.2f,time=%d)", effectscore, power, timer + 1); mvaddstr( 5,5, spbuf); if (effectscore < 0.8) bonuses = tmp = 0; else bonuses = tmp = (long) ((effectscore-0.8) * smarts * 1000); - Sprintf(spbuf, "%6ld", tmp); + snprintf(spbuf, sizeof(spbuf), "%6ld", tmp); mvaddstr( 5, 68, spbuf); - Sprintf(spbuf,"Star save ratio: %1.8f (%d/%d)", + snprintf(spbuf, sizeof(spbuf), "Star save ratio: %1.8f (%d/%d)", starscore, numstars, inumstars); mvaddstr( 6,5, spbuf); #ifndef lint bonuses += tmp = (long) (((double)curscore / possiblescore) * (starscore*starscore) * smarts * 20); #endif - Sprintf(spbuf, "%6ld", tmp); + snprintf(spbuf, sizeof(spbuf), "%6ld", tmp); mvaddstr( 6, 68, spbuf); row = 7; if (inuminhab != numinhab) { - Sprintf(spbuf, "Inhabited stars depopulated: %5d", inuminhab-numinhab); + snprintf(spbuf, sizeof(spbuf), "Inhabited stars depopulated: %5d", inuminhab-numinhab); mvaddstr(row,5, spbuf); bonuses += tmp = (long) (inuminhab-numinhab) * -500; - Sprintf(spbuf, "%6ld", tmp); + snprintf(spbuf, sizeof(spbuf), "%6ld", tmp); mvaddstr(row, 68, spbuf); row++; } if (inumfriends != numfriends) { - Sprintf(spbuf, "Friendly craft destroyed: %5d", + snprintf(spbuf, sizeof(spbuf), "Friendly craft destroyed: %5d", inumfriends-numfriends); mvaddstr(row,5, spbuf); bonuses += tmp = (long) (inumfriends-numfriends) * -250; - Sprintf(spbuf, "%6ld", tmp); + snprintf(spbuf, sizeof(spbuf), "%6ld", tmp); mvaddstr(row, 68, spbuf); row++; } if (deadmudds) { mvaddstr(row,5,"For destroying Harry Mudd:"); bonuses += tmp = (long) rand_mod(deadmudds * 20 + 1) - deadmudds*10; - Sprintf(spbuf, "%6ld", tmp); + snprintf(spbuf, sizeof(spbuf), "%6ld", tmp); mvaddstr(row, 68, spbuf); row++; } if (bombed_out) { mvaddstr(row,5, "For running away from reality:"); bonuses += tmp = (long) -possiblescore/2; - Sprintf(spbuf, "%6ld", tmp); + snprintf(spbuf, sizeof(spbuf), "%6ld", tmp); mvaddstr(row, 68, spbuf); row++; } if (row < 9) row++; - Sprintf(spbuf, "Enterprise: %-9s%5d remaining", + snprintf(spbuf, sizeof(spbuf), "Enterprise: %-9s%5d remaining", !ient?"":ent?"saved":"destroyed", numents); mvaddstr(row,5, spbuf); bonuses += tmp = ent && !bombed_out ? (smarts+1)*15 : 0; - Sprintf(spbuf, "%6ld", tmp); + snprintf(spbuf, sizeof(spbuf), "%6ld", tmp); mvaddstr(row, 68, spbuf); row++; - Sprintf(spbuf, "Base: %-9s %5d remaining", + snprintf(spbuf, sizeof(spbuf), "Base: %-9s %5d remaining", !ibase?"":base?"saved":"destroyed", numbases); mvaddstr(row,5, spbuf); bonuses += tmp = base && !bombed_out ? (smarts+1)*10 : 0; - Sprintf(spbuf, "%6ld", tmp); + snprintf(spbuf, sizeof(spbuf), "%6ld", tmp); mvaddstr(row, 68, spbuf); if (beginner) { mvaddstr(13+(row>11),19, "(Special games count only a tenth as much)"); curscore /= 10; bonuses /= 10; } - Sprintf(spbuf, "Previous point total:%10ld",lastscore); + snprintf(spbuf, sizeof(spbuf), "Previous point total:%10ld",lastscore); mvaddstr(15,24, spbuf); - Sprintf(spbuf, "Points this round: %10ld",curscore); + snprintf(spbuf, sizeof(spbuf), "Points this round: %10ld",curscore); mvaddstr(16,24, spbuf); - Sprintf(spbuf, "Bonuses: %10ld",bonuses); + snprintf(spbuf, sizeof(spbuf), "Bonuses: %10ld",bonuses); mvaddstr(17,24, spbuf); totalscore = lastscore + curscore + bonuses; - Sprintf(spbuf, "New point total: %10ld",totalscore); + snprintf(spbuf, sizeof(spbuf), "New point total: %10ld",totalscore); mvaddstr(18,24, spbuf); if (lastscore / ENTBOUNDARY < totalscore / ENTBOUNDARY) { mvaddstr(row-1,42,"+ 1 new"); @@ -515,9 +507,9 @@ wavescore() numbases--; } if (starscore < 0.8 && inumstars > 200 && numstars > 50) { - Sprintf(spbuf, "smap.%d",rand_mod(MAPS-PERMMAPS)+PERMMAPS); - if ((mapfp = fopen(spbuf,"w")) != NULL) { - Reg1 OBJECT *obj; + snprintf(spbuf, sizeof(spbuf), "smap.%d",rand_mod(MAPS-PERMMAPS)+PERMMAPS); + if ((mapfp = fopen(spbuf, "w")) != NULL) { + OBJECT *obj; fprintf(mapfp,"%d\n",numstars); for (obj = root.next; obj != &root; obj = obj->next) { @@ -525,20 +517,20 @@ wavescore() fprintf(mapfp,"%d %d\n",obj->posy,obj->posx); } } - Fclose(mapfp); + fclose(mapfp); } } } void -score() +score(void) { char tmp, *retval, cdate[30]; - Reg1 FILE *logfd; - Reg2 FILE *outfd; - Reg3 int i; + FILE *logfd; + FILE *outfd; + int i; time_t nowtime; - char *scoreboard; + const char *scoreboard; for (i=0; link(LOGFILE, LOCKFILE) == -1 && i<10; i++) sleep(1); @@ -548,7 +540,7 @@ score() fprintf(logfd, "%-24s%-9s%7ld%c%2d %4d %s", realname, logname, totalscore, c,smarts, cumsmarts, cdate); - Fclose(logfd); + fclose(logfd); } strcpy(cdate+11,cdate+20); if (beginner) @@ -559,7 +551,7 @@ score() scoreboard = SCOREBOARD; if (eaccess(scoreboard,0)) { if ((logfd = fopen(scoreboard,"w")) != NULL) - Fclose(logfd); + fclose(logfd); } if ((logfd = fopen(scoreboard,"r")) != NULL && (outfd = fopen(TMPSCOREBOARD,"w")) != NULL) { @@ -576,14 +568,14 @@ score() } if (i == 100) { mvaddstr(20,21, "You did not better your previous score"); - Fclose(outfd); + fclose(outfd); unlink(TMPSCOREBOARD); } else if (i < 20) { fprintf(outfd, "%-24s%-8s%8ld%c %2d %4d %s", realname, logname, totalscore, c,smarts, cumsmarts, cdate); i++; - Sprintf(spbuf, " Congratulations--you've placed %d%s", + snprintf(spbuf, sizeof(spbuf), " Congratulations--you've placed %d%s", i, i==1?"st":(i==2?"nd":(i==3?"rd":"th"))); if (retval != NULL) { if (strnNE(buf+COMPOFF,COMPNAME,COMPLEN)) { @@ -591,7 +583,7 @@ score() i++; } else - strcpy(spbuf,"Congratulations--you've bettered your score"); + strcpy(spbuf, "Congratulations--you've bettered your score"); while (i<20) { if (fgets(buf, 100, logfd) == NULL) break; @@ -602,8 +594,8 @@ score() } } mvaddstr(20,19, spbuf); - Fclose(logfd); - Fclose(outfd); + fclose(logfd); + fclose(outfd); while (unlink(scoreboard) == 0) ; link(TMPSCOREBOARD,scoreboard); @@ -612,11 +604,11 @@ score() } else { mvaddstr(20,22,"You did not place within the top 20"); - Fclose(outfd); + fclose(outfd); } } else { - Sprintf(spbuf,"(Cannot access %s file, error %d)", + snprintf(spbuf, sizeof(spbuf), "(Cannot access %s file, error %d)", (logfd==NULL?"log":"tmp"),errno); mvaddstr(20,22,spbuf); } @@ -625,7 +617,7 @@ score() mvaddstr(23,11, "[Hit space for scoreboard, 'r' for new game, 'q' to quit]"); unlink(LOCKFILE); - Fflush(stdout); + fflush(stdout); eat_typeahead(); do { getcmd(&tmp); @@ -633,7 +625,7 @@ score() if (index("qQr",tmp)) { justonemoretime = (tmp == 'r'); if (logfd != NULL) - Fclose(logfd); + fclose(logfd); } else { clear(); @@ -650,10 +642,10 @@ score() if (fgets(buf, 100, logfd) == NULL) break; buf[strlen(buf)-1] = '\0'; - Sprintf(spbuf, " %2d %s", i, buf); + snprintf(spbuf, sizeof(spbuf), " %2d %s", i, buf); mvaddstr(i+2,0, spbuf); } - Fclose(logfd); + fclose(logfd); } roundsleep(1); mvaddstr(23,25,"Would you like to play again?"); @@ -662,24 +654,24 @@ score() getcmd(&tmp); } while (tmp != INTRCH && tmp != BREAKCH && !index("nNyY \n\r",tmp)); if (tmp == 'n' || tmp == 'N' || tmp == INTRCH || tmp == BREAKCH) - justonemoretime = FALSE; + justonemoretime = false; } smarts = ismarts; totalscore = cumsmarts = wave = 0; numents = 5; numbases = 3; - apolspec = FALSE; - beginner = FALSE; - crushspec = FALSE; - gornspec = FALSE; + apolspec = false; + beginner = false; + crushspec = false; + gornspec = false; massacre = (ismarts >= 40); - romspec = FALSE; - tholspec = FALSE; + romspec = false; + tholspec = false; } void -save_game() +save_game(void) { FILE *savfil; @@ -690,7 +682,7 @@ save_game() printf("Cannot save game\r\n"); finalize(1); } - fprintf(savfil, "%-8s %10ld, %2d,%5d,%2d,%2d,%3d %c%c%c%c%c%c%c%c\n", + fprintf(savfil, "%-8s %10ld, %2d,%5d,%2d,%2d,%3d %c%c%c%c%c%c%c%c%c\n", logname, totalscore, smarts, cumsmarts, numents, numbases, wave, apolspec ? 'a' : ' ', beginner ? 'b' : ' ', @@ -702,7 +694,7 @@ save_game() lowspeed ? 'l' : ' ', amoebaspec ? '&' : ' ' ); - Fclose(savfil); + fclose(savfil); resetty(); if (panic) finalize(0); diff --git a/warp/score.h b/warp/score.h index 9a135d1e..2cab9825 100644 --- a/warp/score.h +++ b/warp/score.h @@ -41,9 +41,9 @@ EXT char longlognam[128]; EXT char c INIT(' '); -void score_init(); -void wscore(); -void display_status(); -void wavescore(); -void score(); -void save_game(); +void score_init(void); +void wscore(void); +void display_status(void); +void wavescore(void); +void score(void); +void save_game(void); diff --git a/warp/sig.c b/warp/sig.c index 18e64564..ca95175c 100644 --- a/warp/sig.c +++ b/warp/sig.c @@ -23,7 +23,7 @@ #include "sig.h" void -sig_init() +sig_init(void) { #ifdef lint ; @@ -72,7 +72,7 @@ cont_catcher(int x) #endif void -mytstp() +mytstp(void) { resetty(); #ifdef SIGTSTP @@ -94,8 +94,7 @@ mytstp() } void /* very much void */ -finalize(status) -int status; +finalize(int status) { if (bizarre) resetty(); @@ -113,7 +112,7 @@ void sig_catcher(int signo) { #ifdef VERBOSE - static char *signame[] = { + static const char *signame[] = { "", "HUP", "INT", @@ -180,7 +179,7 @@ sig_catcher(int signo) totalscore -= possiblescore / 2; } save_game(); - if (signo != SIGHUP && signo != SIGQUIT) + if (signo != SIGHUP && signo != SIGQUIT) { #ifdef VERBOSE IF(verbose) printf("\r\nCaught %s%s--%s\r\n", @@ -189,8 +188,9 @@ sig_catcher(int signo) ELSE #endif #ifdef TERSE - printf("\r\nSignal %d--bye bye\r\n",signo); + printf("\r\nsignal %d--bye bye\r\n",signo); #endif + } switch (signo) { case SIGBUS: case SIGILL: diff --git a/warp/sig.h b/warp/sig.h index d8537059..8f60329e 100644 --- a/warp/sig.h +++ b/warp/sig.h @@ -6,11 +6,12 @@ * */ -void sig_catcher(int); +void sig_init(void); +void mytstp(void); +void finalize(int status); +void sig_catcher(int signo); #ifdef SIGTSTP -void cont_catcher(int); -void stop_catcher(int); +void cont_catcher(int x); +void stop_catcher(int sig); #endif -void mytstp(); -void sig_init(); -void finalize(); +void sig_catcher(int); diff --git a/warp/sm.c b/warp/sm.c index 4bbe328f..69b10401 100644 --- a/warp/sm.c +++ b/warp/sm.c @@ -12,11 +12,11 @@ #include "config.h" int -main() +main(void) { char screen[23][90], buf[10]; - Reg1 int y; - Reg2 int x; + int y; + int x; int tmpy, tmpx; for (x=0; x<79; x++) @@ -45,7 +45,7 @@ main() } } else { - Reg3 int numstars = 0; + int numstars = 0; for (y=1; y<23; y++) { for (x=0; x<79; x++) diff --git a/warp/term.c b/warp/term.c index 76723df4..34851566 100644 --- a/warp/term.c +++ b/warp/term.c @@ -26,11 +26,11 @@ #include "INTERN.h" #include "term.h" -int typeahead = FALSE; +int typeahead = false; char tcarea[TCSIZE]; /* area for "compiled" termcap strings */ -/* guarantee capability pointer != Nullch */ +/* guarantee capability pointer != NULL */ /* (I believe terminfo will ignore the &tmpaddr argument.) */ #define Tgetstr(key) ((tstr = tgetstr(key,&tmpaddr)) ? tstr : nullstr) @@ -55,17 +55,17 @@ struct keymap { typedef struct keymap KEYMAP; -KEYMAP *topmap INIT(Null(KEYMAP*)); +KEYMAP *topmap INIT(NULL); -void mac_init(); -KEYMAP *newkeymap(); -void pushstring(); +void mac_init(char *); +static KEYMAP *newkeymap(void); +void pushstring(char *); #endif /* terminal initialization */ void -term_init() +term_init(void) { savetty(); /* remember current tty state */ @@ -112,12 +112,10 @@ term_init() /* set terminal characteristics */ void -term_set(tcbuf) -char *tcbuf; /* temp area for "uncompiled" termcap entry */ +term_set(char *tcbuf) /* temp area for "uncompiled" termcap entry */ { char *tmpaddr; /* must not be register */ - Reg1 char *tstr; - char *tgetstr(); + char *tstr; char *s; int retval; @@ -155,7 +153,7 @@ char *tcbuf; /* temp area for "uncompiled" termcap entry */ if (BC == nullstr) /* terminfo grok's 'bs' but not 'bc' */ BC = Tgetstr("le"); } else - BC = "\b"; /* make a backspace handy */ + BC = __UNCONST("\b"); /* make a backspace handy */ UP = Tgetstr("up"); /* move up a line */ ND = Tgetstr("nd"); /* non-destructive move cursor right */ DO = Tgetstr("do"); /* move cursor down */ @@ -189,15 +187,16 @@ char *tcbuf; /* temp area for "uncompiled" termcap entry */ XN = tgetflag("xn"); /* then eats next newline? */ VB = Tgetstr("vb"); if (!*VB) - VB = "\007"; + VB = __UNCONST("\007"); CR = Tgetstr("cr"); if (!*CR) { if (tgetflag("nc") && *UP) { - CR = safemalloc((MEM_SIZE)strlen(UP)+2); - Sprintf(CR,"%s\r",UP); + size_t l = strlen(UP) + 2; + CR = safemalloc(l); + snprintf(CR, l, "%s\r",UP); } else - CR = "\r"; + CR = __UNCONST("\r"); } if (LINES <= 0) LINES = 24; @@ -240,7 +239,7 @@ char *tcbuf; /* temp area for "uncompiled" termcap entry */ } if (!*DO) { /* not defined? */ - myDO = DO = "\n"; /* assume a newline */ + myDO = DO = __UNCONST("\n"); /* assume a newline */ DOsize = 1; } else { @@ -257,7 +256,7 @@ char *tcbuf; /* temp area for "uncompiled" termcap entry */ } } if (debugging) - Fgets(cmbuffer,(sizeof cmbuffer),stdin); + fgets(cmbuffer,(sizeof cmbuffer),stdin); CMsize = comp_tc(cmbuffer,tgoto(CM,20,20),0); if (PC != '\0') { @@ -273,13 +272,13 @@ char *tcbuf; /* temp area for "uncompiled" termcap entry */ ospeed == B600 ? 30 : /* speed is 300 (?) */ 15; - gfillen = ospeed >= B9600 ? (sizeof filler) : + gfillen = ospeed >= B9600 ? (int /*XXX: speed_t*/)(sizeof filler) : ospeed == B4800 ? 13 : ospeed == B2400 ? 7 : ospeed == B1200 ? 4 : - 1+BCsize; + (1+BCsize); if (ospeed < B2400) - lowspeed = TRUE; + lowspeed = true; strcpy(term,ttyname(2)); @@ -300,34 +299,30 @@ char *tcbuf; /* temp area for "uncompiled" termcap entry */ #ifdef PUSHBACK void -mac_init(tcbuf) -char *tcbuf; +mac_init(char *tcbuf) { char tmpbuf[1024]; tmpfp = fopen(filexp(getval("WARPMACRO",WARPMACRO)),"r"); - if (tmpfp != Nullfp) { - while (fgets(tcbuf,1024,tmpfp) != Nullch) { + if (tmpfp != NULL) { + while (fgets(tcbuf,1024,tmpfp) != NULL) { mac_line(tcbuf,tmpbuf,(sizeof tmpbuf)); } - Fclose(tmpfp); + fclose(tmpfp); } } void -mac_line(line,tmpbuf,tbsize) -char *line; -char *tmpbuf; -int tbsize; +mac_line(char *line, char *tmpbuf, size_t tbsize) { - Reg1 char *s; - Reg2 char *m; - Reg3 KEYMAP *curmap; - Reg4 int ch; - Reg5 int garbage = 0; - static char override[] = "\r\nkeymap overrides string\r\n"; - - if (topmap == Null(KEYMAP*)) + char *s; + char *m; + KEYMAP *curmap; + int ch; + int garbage = 0; + static const char override[] = "\r\nkeymap overrides string\r\n"; + + if (topmap == NULL) topmap = newkeymap(); if (*line == '#' || *line == '\n') return; @@ -339,7 +334,7 @@ int tbsize; while (*m == ' ' || *m == '\t') m++; for (s=tmpbuf,curmap=topmap; *s; s++) { ch = *s & 0177; - if (s[1] == '+' && isdigit(s[2])) { + if (s[1] == '+' && isdigit((unsigned char)s[2])) { s += 2; garbage = (*s & KM_GMASK) << KM_GSHIFT; } @@ -349,10 +344,10 @@ int tbsize; if ((curmap->km_type[ch] & KM_TMASK) == KM_STRING) { puts(override); free(curmap->km_ptr[ch].km_str); - curmap->km_ptr[ch].km_str = Nullch; + curmap->km_ptr[ch].km_str = NULL; } curmap->km_type[ch] = KM_KEYMAP + garbage; - if (curmap->km_ptr[ch].km_km == Null(KEYMAP*)) + if (curmap->km_ptr[ch].km_km == NULL) curmap->km_ptr[ch].km_km = newkeymap(); curmap = curmap->km_ptr[ch].km_km; } @@ -367,11 +362,11 @@ int tbsize; } } -KEYMAP* -newkeymap() +static KEYMAP* +newkeymap(void) { - Reg1 int i; - Reg2 KEYMAP *map; + int i; + KEYMAP *map; #ifndef lint map = (KEYMAP*)safemalloc(sizeof(KEYMAP)); @@ -379,7 +374,7 @@ newkeymap() map = Null(KEYMAP*); #endif /* lint */ for (i=127; i>=0; --i) { - map->km_ptr[i].km_km = Null(KEYMAP*); + map->km_ptr[i].km_km = NULL; map->km_type[i] = KM_NOTHIN; } return map; @@ -390,9 +385,7 @@ newkeymap() /* print out a file, stopping at form feeds */ void -page(filename,num) -char *filename; -bool num; +page(const char *filename, size_t num) { int linenum = 1; @@ -401,7 +394,7 @@ bool num; while (fgets(spbuf,(sizeof spbuf),tmpfp) != NULL) { if (*spbuf == '\f') { printf("[Type anything to continue] "); - Fflush(stdout); + fflush(stdout); getcmd(spbuf); printf("\r\n"); if (*spbuf == INTRCH) @@ -416,19 +409,17 @@ bool num; printf("%s\r",spbuf); } } - Fclose(tmpfp); + fclose(tmpfp); } } void -move(y, x, chadd) -int y, x; -int chadd; +move(int y, int x, int chadd) { - Reg1 int ydist; - Reg2 int xdist; - Reg3 int i; - Reg4 char *s; + int ydist; + int xdist; + int i; + char *s; ydist = y - real_y; xdist = x - real_x; @@ -466,9 +457,7 @@ int chadd; } void -do_tc(s,l) -char *s; -int l; +do_tc(const char *s, int l) { beg_qwrite(); tputs(s,l,cmstore); @@ -476,10 +465,7 @@ int l; } int -comp_tc(dest,s,l) -char *dest; -char *s; -int l; +comp_tc(char *dest, const char *s, int l) { maxcmstring = dest; tputs(s,l,cmstore); @@ -487,7 +473,7 @@ int l; } void -helper() +helper(void) { clear(); mvaddstr(0,4,"h or 4 left"); @@ -514,7 +500,7 @@ helper() mvaddstr(21,4,"Q exit this game."); mvaddstr(22,4,""); mvaddstr(23,4," [Hit space to continue]"); - Fflush(stdout); + fflush(stdout); do { getcmd(spbuf); } while (*spbuf != ' '); @@ -523,25 +509,25 @@ helper() } void -rewrite() +rewrite(void) { - Reg1 int x; - Reg2 int y; - Reg3 OBJECT *obj; + int x; + int y; + OBJECT *obj; clear(); for (y=0; yimage != ' ') mvaddc(y+1,x*2,obj->image); } } } - Sprintf(spbuf, - "%-4s E: %4d %2d B: %5d %3d Enemies: %-3d Stars: %-3d Stardate%5d.%1d %9ld", + snprintf(spbuf, sizeof(spbuf), + "%-4s E: %4d %2d B: %5d %3d Enemies: %-3d Stars: %-3d Stardate%5d.%1d %9ld", " ", 0, 0, 0, 0, 0, 0, timer/10+smarts*100, timer%10, 0L); mvaddstr(0,0,spbuf); oldeenergy = oldbenergy = oldcurscore = @@ -557,16 +543,16 @@ rewrite() } int -cmstore(ch) -Reg1 int ch; +cmstore(int ch) { *maxcmstring++ = ch; + return 0; } /* discard any characters typed ahead */ void -eat_typeahead() +eat_typeahead(void) { #ifdef PUSHBACK if (!typeahead && nextin==nextout) /* cancel only keyboard stuff */ @@ -576,7 +562,7 @@ eat_typeahead() { #ifdef PENDING while (input_pending()) - Read_tty(buf,sizeof(buf)); + read_tty(buf,sizeof(buf)); #else /* this is probably v7, with no rdchk() */ ioctl(_tty_ch,TIOCSETP,&_tty); #endif @@ -584,10 +570,10 @@ eat_typeahead() } void -settle_down() +settle_down(void) { dingaling(); - Fflush(stdout); + fflush(stdout); sleep(1); #ifdef PUSHBACK nextout = nextin; /* empty circlebuf */ @@ -599,13 +585,8 @@ settle_down() /* read a character from the terminal, with multi-character pushback */ int -read_tty(addr,size) -char *addr; -int size; /* ignored for now */ +read_tty(char *addr, ssize_t size) /* ignored for now */ { -#ifdef lint - size = size; -#endif if (nextout != nextin) { *addr = circlebuf[nextout++]; nextout %= PUSHSIZE; @@ -633,8 +614,8 @@ int size; /* ignored for now */ int circfill() { - Reg1 int howmany; - Reg2 int i; + int howmany; + int i; assert (nextin == nextout); howmany = read(devtty,circlebuf+nextin,metakey?1:PUSHSIZE-nextin); @@ -658,8 +639,7 @@ circfill() #endif /* PENDING */ void -pushchar(ch) -char ch; +pushchar(int ch) { nextout--; if (nextout < 0) @@ -682,7 +662,7 @@ int size; { if (is_input) { *addr = pending_ch; - is_input = FALSE; + is_input = false; return 1; } else { @@ -692,7 +672,7 @@ int size; if (metakey) { if (*addr & 0200) { pending_ch = *addr & 0177; - is_input = TRUE; + is_input = true; *addr = '\001'; } } @@ -705,9 +685,7 @@ int size; #endif /* PUSHBACK */ int -read_nd(buff, siz) -char *buff; -int siz; +read_nd(char *buff, size_t siz) { if (!input_pending()) return 0; @@ -719,24 +697,24 @@ int siz; /* get a character into a buffer */ void -getcmd(whatbuf) -Reg3 char *whatbuf; +getcmd(char *wbuf) { #ifdef PUSHBACK - Reg1 KEYMAP *curmap; - Reg2 int i; + KEYMAP *curmap; + int i; bool no_macros; int times = 0; /* loop detector */ char scrchar; + unsigned char *whatbuf = (void *)wbuf; tryagain: curmap = topmap; /* no_macros = (whatbuf != buf && nextin == nextout); */ - no_macros = FALSE; + no_macros = false; #endif for (;;) { errno = 0; - if (read_tty(whatbuf,1) < 0 && !errno) + if (read_tty(wbuf,1) < 0 && !errno) errno = EINTR; #ifdef read_tty if (metakey) { @@ -756,10 +734,10 @@ tryagain: *whatbuf &= 0177; goto got_canonical; } - if (curmap == Null(KEYMAP*)) + if (curmap == NULL) goto got_canonical; for (i = (curmap->km_type[*whatbuf] >> KM_GSHIFT) & KM_GMASK; i; --i){ - Read_tty(&scrchar,1); + read_tty(&scrchar,1); } switch (curmap->km_type[*whatbuf] & KM_TMASK) { case KM_NOTHIN: /* no entry? */ @@ -769,7 +747,7 @@ tryagain: goto tryagain; case KM_KEYMAP: /* another keymap? */ curmap = curmap->km_ptr[*whatbuf].km_km; - assert(curmap != Null(KEYMAP*)); + assert(curmap != NULL); break; case KM_STRING: /* a string? */ pushstring(curmap->km_ptr[*whatbuf].km_str); @@ -777,7 +755,7 @@ tryagain: fputs("\r\nmacro loop?\r\n",stdout); settle_down(); } - no_macros = FALSE; + no_macros = false; goto tryagain; } #else @@ -791,20 +769,19 @@ got_canonical: if (*whatbuf == '\r') *whatbuf = '\n'; #endif - if (whatbuf == buf) + if (wbuf == buf) whatbuf[1] = FINISHCMD; /* tell finish_command to work */ } #ifdef PUSHBACK void -pushstring(str) -char *str; +pushstring(char *str) { - Reg1 int i; + int i; char tmpbuf[PUSHSIZE]; - Reg2 char *s = tmpbuf; + char *s = tmpbuf; - assert(str != Nullch); + assert(str != NULL); interp(s,PUSHSIZE,str); for (i = strlen(s)-1; i >= 0; --i) { s[i] ^= 0200; diff --git a/warp/term.h b/warp/term.h index 1ae6f164..52ade745 100644 --- a/warp/term.h +++ b/warp/term.h @@ -42,8 +42,8 @@ #define mvaddstr(y,x,s) (move((y),(x),0), tmpstr = (s), \ tmplen = strlen(tmpstr), write(1, tmpstr, tmplen), real_x += tmplen) -EXT int tmplen; -EXT char *tmpstr; +EXT size_t tmplen; +EXT const char *tmpstr; /* EXT char tmpchr; */ /* The following macros are like the pseudo-curses macros above, but do @@ -131,7 +131,7 @@ EXT char INTRCH INIT('\03'); # endif /* RDCHK */ # endif /* FIONREAD */ # else /* PENDING */ - ??? warp will not work without PENDING +# ??? warp will not work without PENDING # ifndef lint # define input_pending() (nextin!=nextout) # else @@ -162,7 +162,7 @@ EXT char INTRCH INIT('\03'); ??? PENDING is not defined correctly in warp.h # endif EXT int devtty INIT(0); - EXT bool is_input INIT(FALSE); + EXT bool is_input INIT(false); EXT char pending_ch INIT(0); # ifndef lint # define input_pending() (is_input || \ @@ -175,7 +175,7 @@ EXT char INTRCH INIT('\03'); # else /* PENDING */ ??? warp will not work without PENDING # define read_tty(addr,size) read(0,addr,size) -# define input_pending() (FALSE) +# define input_pending() (false) # endif /* PENDING */ #endif /* PUSHBACK */ @@ -189,7 +189,7 @@ EXT int _res_flg INIT(0); #endif EXT int _tty_ch INIT(2); -EXT bool bizarre INIT(FALSE); /* do we need to restore terminal? */ +EXT bool bizarre INIT(false); /* do we need to restore terminal? */ /* terminal mode diddling routines */ @@ -245,29 +245,29 @@ EXT bool bizarre INIT(FALSE); /* do we need to restore terminal? */ */ #ifdef HAVETERMLIB -EXT char *BC INIT(Nullch); /* backspace character */ -EXT char *UP INIT(Nullch); /* move cursor up one line */ +EXT char *BC INIT(NULL); /* backspace character */ +EXT char *UP INIT(NULL); /* move cursor up one line */ EXT char *myUP; -EXT char *ND INIT(Nullch); /* non-destructive cursor right */ +EXT char *ND INIT(NULL); /* non-destructive cursor right */ EXT char *myND; -EXT char *DO INIT(Nullch); /* move cursor down one line */ +EXT char *DO INIT(NULL); /* move cursor down one line */ EXT char *myDO; -EXT char *CR INIT(Nullch); /* get to left margin, somehow */ -EXT char *VB INIT(Nullch); /* visible bell */ -EXT char *CL INIT(Nullch); /* home and clear screen */ -EXT char *CE INIT(Nullch); /* clear to end of line */ -EXT char *CM INIT(Nullch); /* cursor motion -- PWP */ -EXT char *HO INIT(Nullch); /* home cursor -- PWP */ -EXT char *CD INIT(Nullch); /* clear to end of display -- PWP */ -EXT char *SO INIT(Nullch); /* begin standout mode */ -EXT char *SE INIT(Nullch); /* end standout mode */ +EXT char *CR INIT(NULL); /* get to left margin, somehow */ +EXT char *VB INIT(NULL); /* visible bell */ +EXT char *CL INIT(NULL); /* home and clear screen */ +EXT char *CE INIT(NULL); /* clear to end of line */ +EXT char *CM INIT(NULL); /* cursor motion -- PWP */ +EXT char *HO INIT(NULL); /* home cursor -- PWP */ +EXT char *CD INIT(NULL); /* clear to end of display -- PWP */ +EXT char *SO INIT(NULL); /* begin standout mode */ +EXT char *SE INIT(NULL); /* end standout mode */ EXT int SG INIT(0); /* blanks left by SO and SE */ -EXT char *US INIT(Nullch); /* start underline mode */ -EXT char *UE INIT(Nullch); /* end underline mode */ -EXT char *UC INIT(Nullch); /* underline a character, if that's how it's done */ +EXT char *US INIT(NULL); /* start underline mode */ +EXT char *UE INIT(NULL); /* end underline mode */ +EXT char *UC INIT(NULL); /* underline a character, if that's how it's done */ EXT int UG INIT(0); /* blanks left by US and UE */ -EXT bool AM INIT(FALSE); /* does terminal have automatic margins? */ -EXT bool XN INIT(FALSE); /* does it eat 1st newline after automatic wrap? */ +EXT bool AM INIT(false); /* does terminal have automatic margins? */ +EXT bool XN INIT(false); /* does it eat 1st newline after automatic wrap? */ EXT char PC INIT(0); /* pad character for use by tputs() */ EXT short ospeed INIT(0); /* terminal output speed, for use by tputs() */ EXT int LINES INIT(0), COLS INIT(0); /* size of screen */ @@ -293,27 +293,27 @@ EXT char KILLCH; /* line delete character */ ???????? /* up to you */ #endif -void term_init(); -void term_set(); +void term_init(void); +void term_set(char *); #ifdef PUSHBACK -void pushchar(); -void mac_init(); -void mac_line(); +void pushchar(int); +void mac_init(char *); +void mac_line(char *, char *, size_t); #endif -void eat_typeahead(); -void settle_down(); +void page(const char *filename, size_t); +void move(int, int, int); +void do_tc(const char *, int); +int comp_tc(char *, const char *, int); +void helper(void); +void rewrite(void); +int cmstore(int); +void eat_typeahead(void); +void settle_down(void); #ifndef read_tty - int read_tty(); +int read_tty(char *, ssize_t); #endif -void getcmd(); - -int read_nd(); -void page(); -void move(); -void do_tc(); -int comp_tc(); -void helper(); -void rewrite(); -int cmstore(int); +int read_nd(char *, size_t); +void getcmd(char *); +void pushstring(char *); #endif diff --git a/warp/them.c b/warp/them.c index b6f37c41..085e92fb 100644 --- a/warp/them.c +++ b/warp/them.c @@ -35,20 +35,20 @@ #include "them.h" void -them_init() +them_init(void) { ; } void -their_smarts() +their_smarts(void) { - Reg1 OBJECT *curkl; - Reg2 OBJECT *obj; - Reg3 int prob; - Reg4 int count; - Reg5 int y; - Reg6 int x; + OBJECT *curkl; + OBJECT *obj = NULL; + int prob; + int count; + int y = 0; + int x = 0; if (numcrushes && (obj=movers)->type == Crusher) { if (numamoebas) { @@ -303,7 +303,7 @@ their_smarts() fire_torp(curkl,yyy,xxx); } else if (curkl->image == 'T' && (curkl->velx || curkl->vely)) { - Make_object(Web, + make_object(Web, curkl->vely? (curkl->velx? (curkl->velx==curkl->vely? @@ -319,7 +319,7 @@ their_smarts() curkl->posy,curkl->posx,0,0,32767L,32767L,&root); if (obj && obj->type == Web) { unmake_object(obj); - occupant[y][x] = Null(OBJECT*); + occupant[y][x] = NULL; } } } @@ -332,16 +332,11 @@ their_smarts() } void -modify_amoeba(y,x,where,ch,quant) -Reg1 int y; -Reg2 int x; -int where; -Reg6 int ch; -Reg7 int quant; +modify_amoeba(int y, int x, int where, int ch, int quant) { - Reg3 int dy; - Reg4 int dx; - Reg5 int count = 15; + int dy; + int dx; + int count = 15; if (!numamoebas) return; @@ -393,7 +388,7 @@ Reg7 int quant; ambsize++; yblasted[y] |= 2; xblasted[x] |= 2; - blasted = TRUE; + blasted = true; } else ambsize--; diff --git a/warp/them.h b/warp/them.h index 9a7e54c1..ba541626 100644 --- a/warp/them.h +++ b/warp/them.h @@ -6,6 +6,6 @@ * */ -void their_smarts(); -void modify_amoeba(); -void them_init(); +void them_init(void); +void their_smarts(void); +void modify_amoeba(int, int, int, int, int); diff --git a/warp/us.c b/warp/us.c index bd5b4efb..98cbab09 100644 --- a/warp/us.c +++ b/warp/us.c @@ -28,23 +28,22 @@ #include "us.h" void -us_init() +us_init(void) { ; } void -do_direction(dy,dx) -int dy, dx; +do_direction(int dy, int dx) { - Reg1 int decr; - Reg2 OBJECT *obj; + int decr; + OBJECT *obj; if (status < 2) { if (cloaking) { char ch; - cloaked = FALSE; + cloaked = false; ch = (ent->energy >= 500?'E':'e'); if (ch != ent->image) { setimage(ent, ch); @@ -107,14 +106,13 @@ int dy, dx; } void -ctrl_direction(dy,dx) -int dy, dx; +ctrl_direction(int dy, int dx) { if (status < 2) { if (cloaking) { char ch; - cloaked = FALSE; + cloaked = false; ch = (ent->energy >= 500?'E':'e'); if (ch != ent->image) { setimage(ent, ch); @@ -133,14 +131,13 @@ int dy, dx; } void -shift_direction(dy,dx) -int dy, dx; +shift_direction(int dy, int dx) { if (status < 2) { if (cloaking) { char ch; - cloaked = FALSE; + cloaked = false; ch = (ent->energy >= 500?'E':'e'); if (ch != ent->image) { setimage(ent, ch); @@ -159,22 +156,21 @@ int dy, dx; } void -get_commands(done) -bool *done; +get_commands(bool *done) { static char ch[80]; - Reg1 int i; - Reg2 int count; - Reg3 bool ctrla = FALSE; + int i; + int count; + bool ctrla = false; char numdestructs = 0, numzaps = 0; top: - while (count = read_nd(ch,(sizeof ch))) { + while ((count = read_nd(ch,(sizeof ch)))) { for (i=0; ienergy >= 250) - cloaking = TRUE; + cloaking = true; } break; case 'z': @@ -347,7 +343,7 @@ top: break; case 'd': if ((!damage || !damflag[NODESTRUCT]) && (base||ent)) { - Reg4 OBJECT *obj; + OBJECT *obj; int x, y; if (ent && !rand_mod(200)) { @@ -363,7 +359,7 @@ top: += 1; yblasted[y] |= 1; xblasted[x] |= 1; - blasted = TRUE; + blasted = true; obj->mass = (massacre?3000:4000); } } @@ -371,7 +367,7 @@ top: break; case 's': if ((!damage || !damflag[NODESTRUCT]) && (base||ent)) { - Reg4 OBJECT *obj; + OBJECT *obj; if (ent && !rand_mod(200)) { damage++; damflag[NODESTRUCT] = rand_mod(smarts+10)+2; @@ -386,7 +382,7 @@ top: } break; case '\001': - ctrla = TRUE; + ctrla = true; break; case '\002': case '\003': @@ -415,7 +411,7 @@ top: case '\032': ch[i] += 96; i--; - ctrla = TRUE; + ctrla = true; break; case '\033': tractor = 0; diff --git a/warp/us.h b/warp/us.h index 15c7db1b..04b6a093 100644 --- a/warp/us.h +++ b/warp/us.h @@ -37,7 +37,7 @@ EXT int damage INIT(0); EXT int olddamage INIT(-1); #ifdef DOINIT -char *dammess[MAXDAMAGE] = { +const char *dammess[MAXDAMAGE] = { "WARP", "IMPULSE", "PHASERS", @@ -54,8 +54,8 @@ extern char *dammess[]; extern char damflag[]; #endif -void do_direction(); -void ctrl_direction(); -void shift_direction(); -void get_commands(); -void us_init(); +void us_init(void); +void do_direction(int, int); +void ctrl_direction(int, int); +void shift_direction(int, int); +void get_commands(bool *); diff --git a/warp/util.c b/warp/util.c index 4f5d2960..53f5cccf 100644 --- a/warp/util.c +++ b/warp/util.c @@ -22,23 +22,18 @@ #include "util.h" void -util_init() +util_init(void) { ; } void -movc3(len,src,dest) +movc3(int len, char *src, char *dest) #ifdef vax -char *dest, *src; -int len; { asm("movc3 4(ap),*8(ap),*12(ap)"); } #else -Reg1 char *dest; -Reg2 char *src; -Reg3 int len; { if (dest <= src) { for (; len; len--) { @@ -56,20 +51,16 @@ Reg3 int len; #endif void -no_can_do(what) -char *what; +no_can_do(const char *what) { fprintf(stderr,"Sorry, your terminal is too %s to play warp.\r\n",what); finalize(1); } int -exdis(maxnum) -int maxnum; +exdis(int maxnum) { double temp, temp2; - double exp(); - double log(); temp = (double) maxnum; #ifndef lint @@ -92,34 +83,32 @@ static char nomem[] = "warp: out of memory!\r\n"; /* paranoid version of malloc */ -char * -safemalloc(size) -MEM_SIZE size; +void * +safemalloc(size_t size) { char *ptr; ptr = malloc(size?size:1); /* malloc(0) is NASTY on our system */ - if (ptr != Nullch) + if (ptr != NULL) return ptr; else { fputs(nomem,stdout); sig_catcher(0); } /*NOTREACHED*/ + return NULL; } /* safe version of string copy */ char * -safecpy(to,from,len) -char *to; -Reg2 char *from; -Reg1 int len; +safecpy(char *to, const char *from, size_t len) { - Reg3 char *dest = to; + char *dest = to; - if (from != Nullch) - for (len--; len && (*dest++ = *from++); len--) ; + if (from != NULL) + for (len--; len && (*dest++ = *from++); len--) + continue; *dest = '\0'; return to; } @@ -127,10 +116,7 @@ Reg1 int len; /* copy a string up to some (non-backslashed) delimiter, if any */ char * -cpytill(to,from,delim) -Reg2 char *to; -Reg1 char *from; -Reg3 int delim; +cpytill(char *to, const char *from, int delim) { for (; *from; from++,to++) { if (*from == '\\' && from[1] == delim) @@ -140,42 +126,40 @@ Reg3 int delim; *to = *from; } *to = '\0'; - return from; + return __UNCONST(from); } /* return ptr to little string in big string, NULL if not found */ char * -instr(big, little) -char *big, *little; +instr(const char *big, const char *little) { - Reg3 char *t; - Reg1 char *s; - Reg2 char *x; + const char *t; + const char *s; + const char *x; for (t = big; *t; t++) { for (x=t,s=little; *s; x++,s++) { if (!*x) - return Nullch; + return NULL; if (*s != *x) break; } if (!*s) - return t; + return __UNCONST(t); } - return Nullch; + return NULL; } /* effective access */ #ifdef SETUIDGID int -eaccess(filename, mod) -char *filename; -int mod; +eaccess(const char *filename, mode_t mod) { - int protection, euid; + mode_t protection; + uid_t euid; mod &= 7; /* remove extraneous garbage */ if (stat(filename, &filestat) < 0) @@ -194,132 +178,30 @@ int mod; } #endif -/* - * Get working directory - */ - -#ifdef GETWD -#define dot "." -#define dotdot ".." - -static char *name; - -static DIR *dirp; -static int off; -static struct stat d, dd; -static struct direct *dir; - -char * -getwd(np) -char *np; -{ - long rdev, rino; - - *np++ = '/'; - *np = 0; - name = np; - off = -1; - stat("/", &d); - rdev = d.st_dev; - rino = d.st_ino; - for (;;) { - stat(dot, &d); - if (d.st_ino==rino && d.st_dev==rdev) - goto done; - if ((dirp = opendir(dotdot)) == Null(DIR *)) - prexit("getwd: cannot open ..\r\n"); - stat(dotdot, &dd); - chdir(dotdot); - if(d.st_dev == dd.st_dev) { - if(d.st_ino == dd.st_ino) - goto done; - do - if ((dir = readdir(dirp)) == Null(struct direct *)) - prexit("getwd: read error in ..\r\n"); - while (dir->d_ino != d.st_ino); - } - else do { - if ((dir = readdir(dirp)) == Null(struct direct *)) - prexit("getwd: read error in ..\r\n"); - stat(dir->d_name, &dd); - } while(dd.st_ino != d.st_ino || dd.st_dev != d.st_dev); - cat(); - closedir(dirp); - } -done: - name--; - if (chdir(name) < 0) { - printf("getwd: can't cd back to %s\r\n",name); - sig_catcher(0); - } - return (name); -} - void -cat() -{ - Reg1 int i; - Reg2 int j; - - i = -1; - while (dir->d_name[++i] != 0); - if ((off+i+2) > 1024-1) - return; - for(j=off+1; j>=0; --j) - name[j+i+1] = name[j]; - if (off >= 0) - name[i] = '/'; - off=i+off+1; - name[off] = 0; - for(--i; i>=0; --i) - name[i] = dir->d_name[i]; -} - -void -prexit(cp) -char *cp; +prexit(const char *cp) { write(2, cp, strlen(cp)); sig_catcher(0); } -#else -char * -getwd(np) /* shorter but slower */ -char *np; -{ - FILE *popen(); - FILE *pipefp = popen("/bin/pwd","r"); - - if (pipefp == Nullfp) { - printf("Can't run /bin/pwd\r\n"); - finalize(1); - } - Fgets(np,512,pipefp); - np[strlen(np)-1] = '\0'; /* wipe out newline */ - pclose(pipefp); - return np; -} -#endif /* copy a string to a safe spot */ char * -savestr(str) -char *str; +savestr(const char *str) { - Reg1 char *newaddr = safemalloc((MEM_SIZE)(strlen(str)+1)); + char *newaddr = safemalloc((size_t)(strlen(str)+1)); - strcpy(newaddr,str); + strcpy(newaddr, str); return newaddr; } char * -getval(nam,def) -char *nam,*def; +getval(const char *nam, const char *def) { - char *val; + const char *val; - if ((val = getenv(nam)) == Nullch || !*val) + if ((val = getenv(nam)) == NULL || !*val) val = def; - return val; + return __UNCONST(val); } diff --git a/warp/util.h b/warp/util.h index 65381869..eca4cea9 100644 --- a/warp/util.h +++ b/warp/util.h @@ -15,7 +15,7 @@ #if RANDBITS == 15 /* 15 bits of rand()? */ #define RANDRAND 268435456.0 /* that's 2**28 */ #define HALFRAND 0x4000 /* that's 2**14 */ -int rand(); +int rand(void); #define myrand() (rand()&32767) #define rand_mod(m) ((int)((double)myrand() / 32768.0 * ((double)(m)))) /* pick number in 0..m-1 */ @@ -50,10 +50,6 @@ long rand(); EXT struct timeb timebuf; #define roundsleep(x) (ftime(&timebuf),sleep(timebuf.millitm > 500?x+1:x)) -void movc3(); -void no_can_do(); -int exdis(); - #define waiting 0 #ifdef NOTDEF @@ -69,16 +65,17 @@ EXT int len_last_line_got INIT(0); #define MD_FILE 1 #endif -void util_init(); -char *safemalloc(); -char *safecpy(); -char *cpytill(); -char *instr(); +void util_init(void); +void movc3(int, char *, char *); +void no_can_do(const char *); +int exdis(int); +void *safemalloc(size_t size); +char *safecpy(char *, const char *, size_t); +char *cpytill(char *, const char *, int); +char *instr(const char *, const char *); #ifdef SETUIDGID - int eaccess(); +int eaccess(const char *, mode_t); #endif -char *getwd(); -void cat(); -void prexit(); -char *savestr(); -char *getval(); +void prexit(const char *); +char *savestr(const char *); +char *getval(const char *, const char *); diff --git a/warp/version.c b/warp/version.c index 50c29cb6..db6faf5c 100644 --- a/warp/version.c +++ b/warp/version.c @@ -15,7 +15,7 @@ /* Print out the version number. */ void -version() +version(void) { extern char rcsid[]; diff --git a/warp/version.h b/warp/version.h index 961ec68c..bb16c5b7 100644 --- a/warp/version.h +++ b/warp/version.h @@ -6,4 +6,4 @@ * */ -void version(); +void version(void); diff --git a/warp/warp.c b/warp/warp.c index e2571775..f09de9dd 100644 --- a/warp/warp.c +++ b/warp/warp.c @@ -133,14 +133,10 @@ char rcsid[] = "@(#)Header: warp.c,v 7.0.1.3 86/12/12 17:07:44 lwall Exp"; #include "weapon.h" int -main(argc,argv) -int argc; -char *argv[]; +main(int argc, char *argv[]) { char tmp, *s, *tcbuf; - int i; - FILE *savfil; #if RANDBITS > 16 @@ -159,7 +155,6 @@ char *argv[]; exit(1); #endif #endif -rand_ok: #ifdef lint /* to suppress "defined but never used" */ # ifdef SIGTSTP @@ -174,22 +169,22 @@ rand_ok: for (s = argv[0]+1; *s != '\0'; s++) switch (*s) { case '&': - amoebaspec = TRUE; - beginner = TRUE; + amoebaspec = true; + beginner = true; break; case 'A': - apolspec = TRUE; - beginner = TRUE; + apolspec = true; + beginner = true; break; case 'b': - beginner = TRUE; + beginner = true; break; case 'C': - crushspec = TRUE; - beginner = TRUE; + crushspec = true; + beginner = true; break; case 'D': - debugging = TRUE; + debugging = true; #ifdef DEBUGGING debug = atoi(++s); #endif @@ -204,49 +199,49 @@ rand_ok: if (ismarts > 99) ismarts = 99; if (ismarts > 40) - beginner = TRUE; + beginner = true; s += strlen(s)-1; break; case 'E': - klingspec = TRUE; - beginner = TRUE; + klingspec = true; + beginner = true; s++; if (*s == '=') s++; inumenemies = atoi(s); s += strlen(s)-1; break; case 'F': - friendspec = TRUE; - beginner = TRUE; + friendspec = true; + beginner = true; s++; if (*s == '=') s++; inumfriends = atoi(s); s += strlen(s)-1; break; case 'G': - gornspec = TRUE; - beginner = TRUE; + gornspec = true; + beginner = true; break; case 'l': - lowspeed = TRUE; + lowspeed = true; break; case 'm': - metakey = TRUE; + metakey = true; break; case 'M': - massacre = TRUE; + massacre = true; break; case 'P': - piratespec = TRUE; - beginner = TRUE; + piratespec = true; + beginner = true; s++; if (*s == '=') s++; inumpirates = atoi(s); s += strlen(s)-1; break; case 'S': - prespec = TRUE; - beginner = TRUE; + prespec = true; + beginner = true; s++; if (*s == '=') s++; if (*s) @@ -256,26 +251,26 @@ rand_ok: s += strlen(s)-1; break; case 'R': - romspec = TRUE; - beginner = TRUE; + romspec = true; + beginner = true; break; case '*': - starspec = TRUE; - beginner = TRUE; + starspec = true; + beginner = true; s++; if (*s == '=') s++; inumstars = atoi(s); s += strlen(s)-1; break; case 's': - scorespec = TRUE; + scorespec = true; break; case 'T': - tholspec = TRUE; - beginner = TRUE; + tholspec = true; + beginner = true; break; case 'x': - experimenting = TRUE; + experimenting = true; break; case 'v': version(); @@ -303,7 +298,7 @@ rand_ok: intrp_init(tcbuf); if (chdir(warplib) < 0) - fprintf(stderr,nocd,warplib); + fprintf(stderr,NOCD,warplib); term_init(); @@ -326,7 +321,7 @@ rand_ok: srand(getpid()); do { - for (keepgoing = TRUE;;) { + for (keepgoing = true;;) { if (!experimenting) { if ((savfil = fopen(savefilename,"w")) == NULL) { resetty(); @@ -349,7 +344,7 @@ rand_ok: ); fprintf(savfil," running on %s, process #%d\n", term+5,getpid()); - Fclose(savfil); + fclose(savfil); } lastscore = totalscore; @@ -358,7 +353,7 @@ rand_ok: cumsmarts += smarts; wavescore(); if (numents<=0 && numbases<=0) - keepgoing = FALSE; + keepgoing = false; if (!keepgoing) break; do { if (experimenting) { @@ -370,7 +365,7 @@ rand_ok: "[Hit space to continue, 's' to save, 'q' to quit]"); } sleep(1); - Fflush(stdout); + fflush(stdout); eat_typeahead(); getcmd(&tmp); if (tmp == BREAKCH || tmp == INTRCH) { diff --git a/warp/warp.h b/warp/warp.h index 77035fdd..f8e54c76 100644 --- a/warp/warp.h +++ b/warp/warp.h @@ -15,17 +15,21 @@ #ifndef WARP_H #define WARP_H -extern int errno; - #include "config.h" /* generated by Configure script */ +#include +#include +#include +#include + #include +#include #include #include +#include #include -#include -#include #include +#include #include #include #include @@ -136,13 +140,6 @@ EXT char amb[YSIZE][XSIZE]; /* some handy defs */ -#define bool char -#define TRUE (1) -#define FALSE (0) -#define Null(t) ((t)0) -#define Nullch Null(char *) -#define Nullfp Null(FILE *) - #define Ctl(ch) (ch & 037) #define strNE(s1,s2) (strcmp(s1,s2)) @@ -201,8 +198,8 @@ EXT char amb[YSIZE][XSIZE]; # define ROOTID 0 /* uid of superuser */ #endif -# define sigset Signal -# define sigignore(sig) Signal(sig,SIG_IGN) +# define sigset signal +# define sigignore(sig) signal(sig,SIG_IGN) #ifndef LOGDIRFIELD # define LOGDIRFIELD 6 /* Which field (origin 1) is the */ @@ -299,8 +296,6 @@ EXT char amb[YSIZE][XSIZE]; /* typedefs */ -typedef unsigned int MEM_SIZE; /* for passing to malloc */ - /* *** end of the machine dependent stuff *** */ /* GLOBAL THINGS */ @@ -311,15 +306,9 @@ EXT struct stat filestat; /* various things of type char */ -char *index(); -char *rindex(); -char *getenv(); -char *strcat(); -char *strcpy(); - EXT char buf[LBUFLEN+1]; /* general purpose line buffer */ -EXT char *cwd INIT(Nullch); /* current working directory */ +EXT char *cwd INIT(NULL); /* current working directory */ /* switches */ @@ -330,13 +319,13 @@ EXT char *cwd INIT(Nullch); /* current working directory */ #ifdef VERBOSE # ifdef TERSE - EXT bool verbose INIT(TRUE); /* +t */ + EXT bool verbose INIT(true); /* +t */ # endif #endif /* miscellania */ -EXT FILE *tmpfp INIT(Nullfp); /* scratch fp */ +EXT FILE *tmpfp INIT(NULL); /* scratch fp */ #define NOMARKING 0 #define STANDOUT 1 @@ -349,38 +338,36 @@ EXT char readerr[] INIT("warp read error"); EXT char cantopen[] INIT("Can't open %s\r\n"); #ifdef VERBOSE - EXT char nocd[] INIT("Can't chdir to directory %s\r\n"); +#define NOCD "Can't chdir to directory %s\r\n" #else - EXT char nocd[] INIT("Can't find %s\r\n"); +#define NOCD "Can't find %s\r\n" #endif -extern int errno; - -EXT bool justonemoretime INIT(TRUE); -EXT bool keepgoing INIT(TRUE); - -EXT bool friendspec INIT(FALSE); -EXT bool piratespec INIT(FALSE); -EXT bool amoebaspec INIT(FALSE); -EXT bool starspec INIT(FALSE); -EXT bool klingspec INIT(FALSE); -EXT bool apolspec INIT(FALSE); -EXT bool crushspec INIT(FALSE); -EXT bool romspec INIT(FALSE); -EXT bool prespec INIT(FALSE); -EXT bool tholspec INIT(FALSE); -EXT bool gornspec INIT(FALSE); -EXT bool beginner INIT(FALSE); -EXT bool massacre INIT(FALSE); -EXT bool lowspeed INIT(FALSE); -EXT bool debugging INIT(FALSE); -EXT bool didkill INIT(FALSE); -EXT bool experimenting INIT(FALSE); -EXT bool scorespec INIT(FALSE); -EXT bool metakey INIT(FALSE); +EXT bool justonemoretime INIT(true); +EXT bool keepgoing INIT(true); + +EXT bool friendspec INIT(false); +EXT bool piratespec INIT(false); +EXT bool amoebaspec INIT(false); +EXT bool starspec INIT(false); +EXT bool klingspec INIT(false); +EXT bool apolspec INIT(false); +EXT bool crushspec INIT(false); +EXT bool romspec INIT(false); +EXT bool prespec INIT(false); +EXT bool tholspec INIT(false); +EXT bool gornspec INIT(false); +EXT bool beginner INIT(false); +EXT bool massacre INIT(false); +EXT bool lowspeed INIT(false); +EXT bool debugging INIT(false); +EXT bool didkill INIT(false); +EXT bool experimenting INIT(false); +EXT bool scorespec INIT(false); +EXT bool metakey INIT(false); EXT bool bombed_out; -EXT bool panic INIT(FALSE); +EXT int panic INIT(0); EXT bool madgorns; EXT int madfriends; @@ -436,17 +423,6 @@ EXT int yamblast; EXT int xamblast; EXT int ambsize; -EXT char spbuf[512]; - -#define Fclose (void)fclose -#define Fflush (void)fflush -#define Fgets (void)fgets -#define Sprintf (void)sprintf -#define Signal (void)signal -#define Safecpy (void)safecpy -#define Cpytill (void)cpytill -#define Tract (void)tract -#define Make_object (void)make_object -#define Read_tty (void)read_tty +EXT char spbuf[1024]; #endif diff --git a/warp/weapon.c b/warp/weapon.c index e61ffa39..0cf51f32 100644 --- a/warp/weapon.c +++ b/warp/weapon.c @@ -27,18 +27,15 @@ #include "weapon.h" void -weapon_init() +weapon_init(void) { ; } void -fire_torp(from, ydir, xdir) -Reg1 OBJECT *from; -Reg3 int ydir; -Reg4 int xdir; +fire_torp(OBJECT *from, int ydir, int xdir) { - Reg2 OBJECT *to; + OBJECT *to; if (from->type == Enemy || (from == ent && etorp > 0) || @@ -101,18 +98,17 @@ Reg4 int xdir; } void -attack(attackee) -Reg7 OBJECT *attackee; +attack(OBJECT *attackee) { - Reg1 int dx; - Reg2 int dy; - Reg3 int curx; - Reg4 int cury; - Reg5 int prob; - Reg6 OBJECT *obj; - Reg8 bool torps; - Reg9 bool webnear = FALSE; - Reg10 bool thru_stars; + int dx; + int dy; + int curx; + int cury; + int prob; + OBJECT *obj; + bool torps; + bool webnear = false; + bool thru_stars; int nukey; int nukex; int nukedist; @@ -129,22 +125,22 @@ Reg7 OBJECT *attackee; if (dx||dy) { cury = attackee->posy; curx = attackee->posx; - torps = thru_stars = FALSE; + torps = thru_stars = false; if (massacre || madgorns || !rand_mod(53-super) ) webnear += rand_mod(2); else - webnear = FALSE; + webnear = false; for (prob = scandist;prob;prob--) { cury = (cury + dy + YSIZE00) % YSIZE; curx = (curx + dx + XSIZE00) % XSIZE; - if (obj = occupant[cury][curx]) { + if ((obj = occupant[cury][curx]) != NULL) { switch (obj->image) { case 'P': case 'K': case 'R': case ' ': pot_shot: if (attackee == nuke) { if (rand_mod(2+scandist-prob) < rand_mod(smarts/40+1)) - Tract(nuke,dy,dx,rand_mod(3)?1:-1); + tract(nuke,dy,dx,rand_mod(3)?1:-1); } if (rand_mod(51 - sm50) <= prob) { switch (obj->strategy||thru_stars?0: @@ -213,7 +209,7 @@ Reg7 OBJECT *attackee; if (attackee == nuke) { if (rand_mod(2+scandist-prob) < rand_mod(smarts/40+1)) - Tract(nuke,dy,dx,rand_mod(3)?1:-1); + tract(nuke,dy,dx,rand_mod(3)?1:-1); goto bombout; } if (obj->strategy) { @@ -223,7 +219,7 @@ Reg7 OBJECT *attackee; } obj->strategy += (!torps && deados > 10); if (obj->strategy > 4) - madgorns = TRUE; + madgorns = true; if (!torps && obj->strategy > 5) { do { fire_phaser(obj, -dy, -dx); @@ -249,7 +245,7 @@ Reg7 OBJECT *attackee; if (attackee == nuke) { if (rand_mod(2+scandist-prob) < rand_mod(smarts/40+1)) - Tract(nuke,dy,dx,rand_mod(3)?1:-1); + tract(nuke,dy,dx,rand_mod(3)?1:-1); } if (thru_stars) goto bombout; @@ -273,7 +269,7 @@ Reg7 OBJECT *attackee; if (attackee == nuke) { if (rand_mod(2+scandist-prob) < rand_mod(smarts/40+1)) - Tract(nuke,dy,dx,rand_mod(3)?1:-1); + tract(nuke,dy,dx,rand_mod(3)?1:-1); if (rand_mod(2)) goto pot_shot; } @@ -290,45 +286,45 @@ Reg7 OBJECT *attackee; == attackee->posx && (obj->posy + obj->vely + YSIZE00)%YSIZE == attackee->posy ) { - Tract(nuke,dy,dx,-1); + tract(nuke,dy,dx,-1); } else while (!rand_mod(82-sm80)) - Tract(nuke,dy,dx,-1); + tract(nuke,dy,dx,-1); } else if (smarts > 60 || rand_mod(2+scandist-prob) < rand_mod(smarts/20+1)) - Tract(nuke,dy,dx,rand_mod(3)?1:-1); + tract(nuke,dy,dx,rand_mod(3)?1:-1); } - torps = FALSE; - thru_stars = FALSE; + torps = false; + thru_stars = false; break; case '|': case '-': case '/': case '\\': if (thru_stars) goto bombout; webnear = (scandist-prob < 3); - torps = FALSE; + torps = false; break; case 'x': if (attackee == nuke) { if (rand_mod(2+scandist-prob) < rand_mod(smarts/20+1)) - Tract(nuke,dy,dx,rand_mod(3)?1:-1); + tract(nuke,dy,dx,rand_mod(3)?1:-1); } if (thru_stars) goto bombout; - torps = TRUE; + torps = true; break; case 'o': case 'O': case '0': if (attackee == nuke) { if (rand_mod(2+scandist-prob) < rand_mod(smarts/20+1)) - Tract(nuke,dy,dx,rand_mod(3)?1:-1); + tract(nuke,dy,dx,rand_mod(3)?1:-1); } if (thru_stars) goto bombout; - torps = TRUE; + torps = true; if (rand_mod(99+3*scandist) < smarts+3*prob) { obj->vely = -dy + attackee->vely; obj->velx = -dx + attackee->velx; @@ -344,14 +340,14 @@ Reg7 OBJECT *attackee; } if (obj->image != '0') break; - /* DROP THROUGH! */ + /*FALLTHROUGH*/ case 'X': if (attackee == nuke) { if (rand_mod(2+scandist-prob) < rand_mod(smarts/20+1)) - Tract(nuke,dy,dx,rand_mod(3)?1:-1); + tract(nuke,dy,dx,rand_mod(3)?1:-1); } - torps = TRUE; + torps = true; if (thru_stars) goto bombout; if (prob == scandist) { @@ -362,13 +358,13 @@ Reg7 OBJECT *attackee; += (obj->image == '0' ? 2000 : 200); yblasted[y] |= 1; xblasted[x] |= 1; - blasted = TRUE; + blasted = true; } break; case 'A': if (attackee != nuke) { if (scandist-prob>1 && !rand_mod(51-super)) - Tract(obj,-dy,-dx,1); + tract(obj,-dy,-dx,1); } /* FALL THROUGH */ case '*': case '@': @@ -382,19 +378,20 @@ Reg7 OBJECT *attackee; if (smarts > 55 && scandist-prob > 8) { if (rand_mod(30+scandist-prob) < rand_mod(smarts/20+1)) - Tract(nuke,dy,dx,1); + tract(nuke,dy,dx,1); } } else if (obj->vely || obj->velx) { - Tract(nuke,dy,dx,1); /* for looks */ + tract(nuke,dy,dx,1); /* for looks */ obj->vely = obj->velx = 0; } } - if (!thru_stars) + if (!thru_stars) { if (rand_mod(97-sm95)) goto bombout; else - thru_stars = TRUE; + thru_stars = true; + } break; case '<': case '>': if (attackee == nuke) { @@ -402,7 +399,7 @@ Reg7 OBJECT *attackee; rand_mod(2+scandist-prob) < rand_mod(smarts/20+1) ) { nuke->mass += 10000; - Tract(nuke,dy,dx,-1); + tract(nuke,dy,dx,-1); nuke->mass -= 10000; } } @@ -411,7 +408,7 @@ Reg7 OBJECT *attackee; if (attackee == nuke) { if (rand_mod(2+scandist-prob) < rand_mod(smarts/40+1)) - Tract(nuke,dy,dx,rand_mod(3)?1:-1); + tract(nuke,dy,dx,rand_mod(3)?1:-1); } goto bombout; default: @@ -438,15 +435,12 @@ bombout: ; /* end of loop */ } void -fire_phaser(obj, dy, dx) -Reg7 OBJECT *obj; -Reg5 int dy; -Reg6 int dx; +fire_phaser(OBJECT *obj, int dy, int dx) { - Reg1 int y; - Reg2 int x; - Reg3 int skipping; - Reg4 int size=5000; + int y; + int x; + int skipping; + int size=5000; int decr = 50, oldy, oldx; static char curchar[] = "@* "; @@ -595,24 +589,20 @@ Reg6 int dx; blast[y][x] += size*smarts/25; yblasted[y] |= 1; xblasted[x] |= 1; - blasted = TRUE; + blasted = true; } } } } int -tract(obj, dy, dx, to_or_fro) -Reg7 OBJECT *obj; -Reg4 int dy; -Reg5 int dx; -int to_or_fro; +tract(OBJECT *obj, int dy, int dx, int to_or_fro) { - Reg1 int y; - Reg2 int x; - Reg3 int size=10; + int y; + int x; + int size=10; static char ch; - Reg6 OBJECT *tractee; + OBJECT *tractee; if (!dy) ch = '|'; diff --git a/warp/weapon.h b/warp/weapon.h index 6872bb72..fbfcecf0 100644 --- a/warp/weapon.h +++ b/warp/weapon.h @@ -15,8 +15,8 @@ EXT OBJECT *isatorp[2][3][3]; EXT int aretorps; -void fire_torp(); -void attack(); -void fire_phaser(); -int tract(); -void weapon_init(); +void weapon_init(void); +void fire_torp(OBJECT *, int, int); +void attack(OBJECT *); +void fire_phaser(OBJECT *, int, int); +int tract(OBJECT *, int, int, int); -- cgit v1.2.3-56-ge451