More boolification.

Constants and formals have been converted, but not globals yet.
This commit is contained in:
Eric S. Raymond 2017-05-18 17:28:18 -04:00
parent 23f2dbe814
commit 17ad4891ee
4 changed files with 42 additions and 53 deletions

29
init.c
View file

@ -5,9 +5,6 @@
#include <stdio.h>
#include <stdbool.h>
#define TRUE (0==0)
#define FALSE (0!=0)
/*
* INITIALISATION
*/
@ -234,7 +231,7 @@ L1005: LINUSE=KK;
if(LNLENG < LNPOSN)BUG(1);
L1006: KK=KK+1;
if(KK >= LINSIZ)BUG(2);
LINES[KK]=GETTXT(FALSE,FALSE,FALSE,KK);
LINES[KK]=GETTXT(false,false,false,KK);
if(LINES[KK] != -1) goto L1006;
LINES[LINUSE]=KK;
if(LOC == OLDLOC) goto L1005;
@ -306,7 +303,7 @@ L1040: J=10000;
L1043: KTAB[TABNDX]=GETNUM(1);
if(KTAB[TABNDX] == -1) goto L1002;
J=J+7;
L1042: ATAB[TABNDX]=GETTXT(TRUE,TRUE,TRUE,0)+J*J;
L1042: ATAB[TABNDX]=GETTXT(true,true,true,0)+J*J;
} /* end loop */
BUG(4);
@ -427,7 +424,7 @@ L1200: TALLY=TALLY-PROP[I];
* I. HINTED(I) IS TRUE IFF HINT I HAS BEEN USED. */
/* 1300 */ for (I=1; I<=HNTMAX; I++) {
HINTED[I]=FALSE;
HINTED[I]=false;
L1300: HINTLC[I]=0;
} /* end loop */
@ -528,7 +525,7 @@ L1300: HINTLC[I]=0;
CHLOC=114;
CHLOC2=140;
/* 1700 */ for (I=1; I<=6; I++) {
L1700: DSEEN[I]=FALSE;
L1700: DSEEN[I]=false;
} /* end loop */
DFLAG=0;
DLOC[1]=19;
@ -566,7 +563,7 @@ L1700: DSEEN[I]=FALSE;
THRESH= -1;
if(TRNVLS > 0)THRESH=MOD(TRNVAL[1],100000)+1;
TRNLUZ=0;
LMWARN=FALSE;
LMWARN=false;
IGO=0;
IWEST=0;
KNFLOC=0;
@ -584,11 +581,11 @@ L1800: {long x = 2*I+81; if(RTEXT[x] != 0)MAXDIE=I+1;}
CLOCK2=50;
CONDS=SETBIT(11);
SAVED=0;
CLOSNG=FALSE;
PANIC=FALSE;
CLOSED=FALSE;
CLSHNT=FALSE;
NOVICE=FALSE;
CLOSNG=false;
PANIC=false;
CLOSED=false;
CLSHNT=false;
NOVICE=false;
SETUP=1;
/* if we can ever think of how, we should save it at this point */
@ -646,8 +643,8 @@ static bool quick_init(void) {
f = NULL;
if(adv)f = fopen(adv,READ_MODE);
if(f == NULL)f = fopen("adventure.data",READ_MODE);
if(f == NULL)return(FALSE);
init_reading = TRUE;
if(f == NULL)return(false);
init_reading = true;
init_cksum = 1;
quick_io();
if(fread(&K,4,1,f) == 1) init_cksum -= K; else init_cksum = 1;
@ -660,7 +657,7 @@ static void quick_save(void) {
printf("Writing adventure.data...\n");
f = fopen("adventure.data",WRITE_MODE);
if(f == NULL){printf("Can't open file!\n"); return;}
init_reading = FALSE;
init_reading = false;
init_cksum = 1;
quick_io();
fwrite(&init_cksum,4,1,f);

28
main.c
View file

@ -5,14 +5,12 @@
*/
#include <stdlib.h>
#include <stdio.h>
#include <stdbool.h>
#include "main.h"
#include "misc.h"
#define TRUE (0==0)
#define FALSE (0!=0)
long ABB[186], ATAB[331], ATLOC[186], BLKLIN = TRUE, DFLAG,
long ABB[186], ATAB[331], ATLOC[186], BLKLIN = true, DFLAG,
DLOC[7], FIXED[101], HOLDNG,
KTAB[331], *LINES, LINK[201], LNLENG, LNPOSN,
PARMS[26], PLACE[101], PTEXT[101], RTEXT[278],
@ -40,7 +38,7 @@ long ABBNUM, ACTSPK[36], AMBER, ATTACK, AXE, BACK, BATTER, BEAR, BIRD, BLOOD, BO
TRNDEX, TRNLUZ, TRNSIZ = 5, TRNVAL[6], TRNVLS, TROLL, TROLL2, TRVS,
TRVSIZ = 885, TTEXT[6], TURNS, URN, V1, V2, VASE, VEND, VERB,
VOLCAN, VRBSIZ = 35, VRSION = 25, WATER, WD1, WD1X, WD2, WD2X,
WZDARK = FALSE, ZZWORD;
WZDARK = false, ZZWORD;
extern void initialise();
extern void score(long);
@ -77,7 +75,7 @@ int main(int argc, char *argv[]) {
LINES = (long *)calloc(LINSIZ+1,sizeof(long));
if(!LINES){
printf("Not enough memory!\n");
exit(FALSE);
exit(1);
}
MAP2[1] = 0;
@ -90,7 +88,7 @@ int main(int argc, char *argv[]) {
* RERUN, WE COME HERE AND TELL THE PLAYER TO RUN A FRESH COPY. */
RSPEAK(201);
exit(FALSE);
exit(0);
@ -111,7 +109,7 @@ L2: if(!OUTSID(NEWLOC) || NEWLOC == 0 || !CLOSNG) goto L71;
RSPEAK(130);
NEWLOC=LOC;
if(!PANIC)CLOCK2=15;
PANIC=TRUE;
PANIC=true;
/* SEE IF A DWARF HAS SEEN HIM AND HAS COME FROM WHERE HE WANTS TO GO. IF SO,
* THE DWARF'S BLOCKING HIS WAY. IF COMING FROM PLACE FORBIDDEN TO PIRATE
@ -226,7 +224,7 @@ L6023: /*etc*/ ;
} /* end loop */
L6024: DLOC[6]=CHLOC;
ODLOC[6]=CHLOC;
DSEEN[6]=FALSE;
DSEEN[6]=false;
goto L6030;
L6025: RSPEAK(186);
@ -590,7 +588,7 @@ L25: K=MOD(IABS(TRAVEL[KK]),1000);
L30: if(DETAIL < 3)RSPEAK(15);
DETAIL=DETAIL+1;
WZDARK=FALSE;
WZDARK=false;
ABB[LOC]=0;
goto L2;
@ -769,7 +767,7 @@ L41000: if(TALLY == 1 && PROP[JADE] < 0) goto L40010;
L10000: PROP[GRATE]=0;
PROP[FISSUR]=0;
/* 10010 */ for (I=1; I<=6; I++) {
DSEEN[I]=FALSE;
DSEEN[I]=false;
L10010: DLOC[I]=0;
} /* end loop */
MOVE(TROLL,0);
@ -784,7 +782,7 @@ L10010: DLOC[I]=0;
FIXED[AXE]=0;
RSPEAK(129);
CLOCK1= -1;
CLOSNG=TRUE;
CLOSNG=true;
goto L19999;
/* ONCE HE'S PANICKED, AND CLOCK2 HAS RUN OUT, WE COME HERE TO SET UP THE
@ -829,7 +827,7 @@ L11010: if(TOTING(I))DSTROY(I);
} /* end loop */
RSPEAK(132);
CLOSED=TRUE;
CLOSED=true;
goto L2;
/* ANOTHER WAY WE CAN FORCE AN END TO THINGS IS BY HAVING THE LAMP GIVE OUT.
@ -842,11 +840,11 @@ L12000: RSPEAK(188);
PROP[BATTER]=1;
if(TOTING(BATTER))DROP(BATTER,LOC);
LIMIT=LIMIT+2500;
LMWARN=FALSE;
LMWARN=false;
goto L19999;
L12200: if(LMWARN || !HERE(LAMP)) goto L19999;
LMWARN=TRUE;
LMWARN=true;
SPK=187;
if(PLACE[BATTER] == 0)SPK=183;
if(PROP[BATTER] == 1)SPK=189;

33
misc.c
View file

@ -4,9 +4,6 @@
#include "misc.h"
#include "funcs.h"
#define TRUE (0==0)
#define FALSE (0!=0)
/* hack to ignore GCC Unused Result */
#define IGNORE(r) do{if(r){}}while(0)
@ -106,7 +103,7 @@ L380: SHFTXT(LNPOSN+2,-2);
goto L32;
L40: if(BLANK)TYPE0();
BLANK=FALSE;
BLANK=false;
TYPE();
K=L+1;
if(LINES[K] >= 0) goto L10;
@ -185,17 +182,17 @@ long JUNK;
L10: if(BLKLIN)TYPE0();
MAPLIN(FALSE);
WORD1=GETTXT(TRUE,TRUE,TRUE,0);
MAPLIN(false);
WORD1=GETTXT(true,true,true,0);
if(BLKLIN && WORD1 < 0) goto L10;
WORD1X=GETTXT(FALSE,TRUE,TRUE,0);
L12: JUNK=GETTXT(FALSE,TRUE,TRUE,0);
WORD1X=GETTXT(false,true,true,0);
L12: JUNK=GETTXT(false,true,true,0);
if(JUNK > 0) goto L12;
WORD2=GETTXT(TRUE,TRUE,TRUE,0);
WORD2X=GETTXT(FALSE,TRUE,TRUE,0);
L22: JUNK=GETTXT(FALSE,TRUE,TRUE,0);
WORD2=GETTXT(true,true,true,0);
WORD2X=GETTXT(false,true,true,0);
L22: JUNK=GETTXT(false,true,true,0);
if(JUNK > 0) goto L22;
if(GETTXT(TRUE,TRUE,TRUE,0) <= 0)return;
if(GETTXT(true,true,true,0) <= 0)return;
RSPEAK(53);
goto L10;
}
@ -221,10 +218,10 @@ L1: RSPEAK(X);
if(REPLY == MAKEWD(1415) || REPLY == MAKEWD(14)) goto L20;
RSPEAK(185);
goto L1;
L10: YES=TRUE;
L10: YES=true;
RSPEAK(Y);
return(YES);
L20: YES=FALSE;
L20: YES=false;
RSPEAK(Z);
return(YES);
}
@ -520,7 +517,7 @@ L10: STATE=OP;
L13: CKSUM=BUF[0];
return;
L15: SAVEIO(1,TRUE,BUF);
L15: SAVEIO(1,true,BUF);
HASH=MOD(1234L*5678L-BUF[0],1048576L);
goto L13;
@ -528,7 +525,7 @@ L30: if(N == 250)SAVEIO(1,STATE > 0,BUF);
N=MOD(N,250)+1;
if(STATE > 0) goto L32;
N--; BUF[N]=CKSUM; N++;
SAVEIO(1,FALSE,BUF);
SAVEIO(1,false,BUF);
L32: N--; WORD=BUF[N]-CKSUM; N++;
SAVEIO(-1,STATE > 0,BUF);
STATE=0;
@ -846,7 +843,7 @@ void fBUG(NUM)long NUM; {
printf("Fatal error %ld. See source code for interpretation.\n",
NUM);
exit(FALSE);
exit(0);
}
@ -899,7 +896,7 @@ long I, VAL; static FILE *OPENED = NULL;
L15: if(!OPENED){
OPENED=fopen("adventure.text","r" /* NOT binary */);
if(!OPENED){printf("Can't read adventure.text!\n"); exit(FALSE);}
if(!OPENED){printf("Can't read adventure.text!\n"); exit(0);}
}
IGNORE(fgets(INLINE+1,100,OPENED));

View file

@ -3,9 +3,6 @@
#include "main.h"
#include "share.h"
#define TRUE (0==0)
#define FALSE (0!=0)
/*
* SCORING AND WRAP-UP
*/
@ -115,6 +112,6 @@ L20210: SPEAK(CTEXT[I]);
SETPRM(1,I,I);
SPK=263;
L25000: RSPEAK(SPK);
exit(FALSE);
exit(0);
}