Use prototypes and bools.

This commit is contained in:
Eric S. Raymond 2017-05-18 09:06:32 -04:00
parent c9e9b64575
commit b38c11abef
7 changed files with 22 additions and 25 deletions

View file

@ -1,12 +1,10 @@
#include <stdlib.h>
#include <stdbool.h>
#include "misc.h"
#include "main.h"
#include "share.h"
#include "funcs.h"
#define TRUE (0==0)
#define FALSE (0!=0)
/* This stuff was broken off as part of an effort to get the main program
* to compile without running out of memory. We're called with a number
* that says what label the caller wanted to "goto", and we return a
@ -16,7 +14,7 @@
/* ANALYSE A VERB. REMEMBER WHAT IT WAS, GO BACK FOR OBJECT IF SECOND WORD
* UNLESS VERB IS "SAY", WHICH SNARFS ARBITRARY SECOND WORD. */
int action(STARTAT)long STARTAT; {
int action(long STARTAT) {
switch(STARTAT) {
case 4000: goto L4000;
case 4090: goto L4090;
@ -125,7 +123,7 @@ L8010: if(ATLOC[LOC] == 0 || LINK[ATLOC[LOC]] != 0 || ATDWRF(LOC) > 0) return(80
/* TRANSITIVE CARRY/DROP ARE IN SEPARATE FILE. */
L9010: return(carry());
L9020: return(discard(FALSE));
L9020: return(discard(false));
/* SAY. ECHO WD2 (OR WD1 IF NO WD2 (SAY WHAT?, ETC.).) MAGIC WORDS OVERRIDE. */
@ -165,7 +163,7 @@ L9040: if(OBJ == CLAM || OBJ == OYSTER) goto L9046;
if(!CLOSNG) goto L9043;
K=130;
if(!PANIC)CLOCK2=15;
PANIC=TRUE;
PANIC=true;
return(2010);
L9043: K=34+PROP[GRATE];
@ -372,9 +370,9 @@ L8200: SPK=98;
/* 8201 */ for (I=1; I<=100; I++) {
if(I == BEAR || !TOTING(I)) goto L8201;
if(SPK == 98)RSPEAK(99);
BLKLIN=FALSE;
BLKLIN=false;
PSPEAK(I,-1);
BLKLIN=TRUE;
BLKLIN=true;
SPK=0;
L8201: /*etc*/ ;
} /* end loop */
@ -520,7 +518,7 @@ L8305: DATIME(I,K);
ZZWORD=RNDVOC(3,ZZWORD-MESH*2)+MESH*2;
if(KK > 0) return(8);
RSPEAK(266);
exit(FALSE);
exit(0);
/* RESUME. READ A SUSPENDED GAME BACK FROM A FILE. */
@ -536,7 +534,7 @@ L8312: SETPRM(1,K/10,MOD(K,10));
return(2000);
L8318: RSPEAK(270);
exit(FALSE);
exit(0);
/* FLY. SNIDE REMARKS UNLESS HOVERING RUG IS HERE. */

View file

@ -3,14 +3,11 @@
#include "share.h"
#include "funcs.h"
#define TRUE (0==0)
#define FALSE (0!=0)
/* CARRY AN OBJECT. SPECIAL CASES FOR BIRD AND CAGE (IF BIRD IN CAGE, CAN'T
* TAKE ONE WITHOUT THE OTHER). LIQUIDS ALSO SPECIAL, SINCE THEY DEPEND ON
* STATUS OF BOTTLE. ALSO VARIOUS SIDE EFFECTS, ETC. */
int carry() {
int carry(void) {
if(TOTING(OBJ)) return(2011);
SPK=25;
if(OBJ == PLANT && PROP[PLANT] <= 0)SPK=115;
@ -60,7 +57,7 @@ L9015: SPK=238;
* BIRD (MIGHT ATTACK SNAKE OR DRAGON) AND CAGE (MIGHT CONTAIN BIRD) AND VASE.
* DROP COINS AT VENDING MACHINE FOR EXTRA BATTERIES. */
int discard(just_do_it)long just_do_it; {
int discard(bool just_do_it) {
if(just_do_it) goto L9021;
if(TOTING(ROD2) && OBJ == ROD && !TOTING(ROD))OBJ=ROD2;
if(!TOTING(OBJ)) return(2011);
@ -206,7 +203,7 @@ L9128: RSPEAK(SPK);
if(DLOC[I] != LOC) goto L9129;
K=K+1;
DLOC[I]=61;
DSEEN[I]=FALSE;
DSEEN[I]=false;
L9129: /*etc*/ ;
} /* end loop */
SPK=SPK+1+1/K;
@ -222,7 +219,7 @@ int throw() {
if(!TOTING(OBJ)) return(2011);
if(OBJ >= 50 && OBJ <= MAXTRS && AT(TROLL)) goto L9178;
if(OBJ == FOOD && HERE(BEAR)) goto L9177;
if(OBJ != AXE) return(discard(FALSE));
if(OBJ != AXE) return(discard(false));
I=ATDWRF(LOC);
if(I > 0) goto L9172;
SPK=152;
@ -237,7 +234,7 @@ int throw() {
L9172: SPK=48;
if(RAN(7) < DFLAG) goto L9175;
DSEEN[I]=FALSE;
DSEEN[I]=false;
DLOC[I]=0;
SPK=47;
DKILL=DKILL+1;
@ -337,7 +334,7 @@ L9222: SPK=29;
RSPEAK(145);
PROP[VASE]=2;
FIXED[VASE]= -1;
return(discard(TRUE));
return(discard(true));
L9224: SPK=213;
if(PROP[URN] != 0) return(2011);

View file

@ -30,7 +30,7 @@ static int GOTX = 0, GOTY;
#define _TIME_
#include "time.h"
fDATIME(X,Y)long *X, *Y; {
fDATIME(long *X,long *Y) {
time(X); time(Y);
*Y /= 2;
/* it would be even better if the two numbers were totally
@ -41,7 +41,7 @@ fDATIME(X,Y)long *X, *Y; {
#ifndef _TIME_
#include "sys/time.h"
void fDATIME(X,Y)long *X, *Y; {
void fDATIME(long *X, long *Y) {
struct timeval now;
gettimeofday(&now, 0);
*X = now.tv_sec;

View file

@ -1,3 +1,5 @@
#include <stdbool.h>
/* STATEMENT FUNCTIONS
*
* AT(OBJ) = TRUE IF ON EITHER SIDE OF TWO-PLACED OBJECT
@ -35,7 +37,7 @@
#define OUTSID(LOC) ((LOC) <= 8 || FOREST(LOC) || (LOC) == PLAC[SAPPH] || (LOC) == 180 || (LOC) == 182)
#define INDEEP(LOC) ((LOC) >= 15 && !OUTSID(LOC) && (LOC) != 179)
extern int carry(void), discard(long), attack(void), throw(void), feed(void), fill(void);
extern int carry(void), discard(bool), attack(void), throw(void), feed(void), fill(void);
void score(long);

2
init.c
View file

@ -172,7 +172,7 @@ static void quick_save(void);
static int finish_init(void);
static void quick_io(void);
void initialise() {
void initialise(void) {
printf("Initialising...\n");
if(!quick_init()){raw_init(); report(); quick_save();}
finish_init();

2
main.c
View file

@ -48,7 +48,7 @@ extern int action(long);
* MAIN PROGRAM
*/
int main() {
int main(int argc, char *argv[]) {
/* ADVENTURE (REV 2: 20 TREASURES) */

View file

@ -10,7 +10,7 @@
* SCORING AND WRAP-UP
*/
void score(MODE)long MODE; {
void score(long MODE) {
/* <0 if scoring, >0 if quitting, =0 if died or won */
/* THE PRESENT SCORING ALGORITHM IS AS FOLLOWS: