From: Eric S. Raymond Date: Sat, 10 Jun 2017 16:38:40 +0000 (-0400) Subject: Use C idioms for increment/decrement. X-Git-Tag: 1.1~453 X-Git-Url: https://jxself.org/git/?p=open-adventure.git;a=commitdiff_plain;h=e6f183ba7f4e0d7e12d7cdc848d204e308840f9c Use C idioms for increment/decrement. --- diff --git a/actions.c b/actions.c index 4a545c3..3ef9289 100644 --- a/actions.c +++ b/actions.c @@ -752,7 +752,7 @@ static int rub(token_t obj) DSTROY(URN); DROP(AMBER,game.loc); game.prop[AMBER]=1; - game.tally=game.tally-1; + --game.tally; DROP(CAVITY,game.loc); SPK=216; return(2011); @@ -842,7 +842,7 @@ static int throw(FILE *cmdin, long verb, long obj) game.dseen[i]=false; game.dloc[i]=0; SPK=47; - game.dkill=game.dkill+1; + ++game.dkill; if (game.dkill == 1)SPK=149; return throw_support(SPK); @@ -875,7 +875,7 @@ static int wave(token_t obj) if (SPK == 206 && game.loc == game.place[STEPS] && game.prop[JADE] < 0) { DROP(JADE,game.loc); game.prop[JADE]=0; - game.tally=game.tally-1; + --game.tally; SPK=208; return(2011); } else { diff --git a/main.c b/main.c index 31eaf46..42fa5e1 100644 --- a/main.c +++ b/main.c @@ -509,7 +509,7 @@ static bool playermove(FILE *cmdin, token_t verb) K2=KK; } if (TRAVEL[KK] >= 0) { - KK=KK+1; + ++KK; goto L21; } KK=K2; @@ -531,7 +531,7 @@ static bool playermove(FILE *cmdin, token_t verb) * (though it may "now" be dark) so he won't fall into a * pit while staring into the gloom. */ if (game.detail < 3)RSPEAK(15); - game.detail=game.detail+1; + ++game.detail; game.wzdark=false; game.abbrev[game.loc]=0; return true; @@ -563,7 +563,7 @@ L9: RSPEAK(SPK); return true; } - KK=KK+1; + ++KK; } LL=LL/1000; @@ -582,7 +582,7 @@ L11: L12: do { if (TRAVEL[KK] < 0)BUG(25); - KK=KK+1; + ++KK; game.newloc=labs(TRAVEL[KK])/1000; } while (game.newloc == LL); @@ -726,7 +726,7 @@ L2000: if (game.loc == 0) * get full score. */ if (DARK(0)) goto L2012; - game.abbrev[game.loc]=game.abbrev[game.loc]+1; + ++game.abbrev[game.loc]; i=game.atloc[game.loc]; L2004: if (i == 0) goto L2012; obj=i; @@ -736,7 +736,7 @@ L2004: if (i == 0) goto L2012; if (game.closed) goto L2008; game.prop[obj]=0; if (obj == RUG || obj == CHAIN)game.prop[obj]=1; - game.tally=game.tally-1; + --game.tally; /* Note: There used to be a test here to see whether the player had blown it * so badly that he could never ever see the remaining treasures, and if so * the lamp was zapped to 35 turns. But the tests were too simple-minded; @@ -772,7 +772,7 @@ L2600: if (COND[game.loc] >= game.conds) { continue; if (!CNDBIT(game.loc,hint+10)) game.hintlc[hint]= -1; - game.hintlc[hint] = game.hintlc[hint]+1; + ++game.hintlc[hint]; if (game.hintlc[hint] >= HINTS[hint][1]) dohint(cmdin, hint); } @@ -803,22 +803,25 @@ L2603: if (game.closed) { * going on. If pos, make neg. If neg, he skipped a word, * so make it zero. */ L2607: game.foobar=(game.foobar>0 ? -game.foobar : 0); - game.turns=game.turns+1; + ++game.turns; if (game.turns == game.thresh) { SPEAK(TTEXT[game.trndex]); game.trnluz=game.trnluz+TRNVAL[game.trndex]/100000; - game.trndex=game.trndex+1; - game.thresh= -1; + ++game.trndex; + game.thresh = -1; if (game.trndex <= TRNVLS) game.thresh=MOD(TRNVAL[game.trndex],100000)+1; } if (VERB == SAY && WD2 > 0)VERB=0; if (VERB == SAY) goto L4090; - if (game.tally == 0 && INDEEP(game.loc) && game.loc != 33)game.clock1=game.clock1-1; + if (game.tally == 0 && INDEEP(game.loc) && game.loc != 33) + --game.clock1; if (game.clock1 == 0) goto L10000; - if (game.clock1 < 0)game.clock2=game.clock2-1; + if (game.clock1 < 0) + --game.clock2; if (game.clock2 == 0) goto L11000; - if (game.prop[LAMP] == 1)game.limit=game.limit-1; + if (game.prop[LAMP] == 1) + --game.limit; if (game.limit <= 30 && HERE(BATTER) && game.prop[BATTER] == 0 && HERE(LAMP)) goto L12000; if (game.limit == 0) goto L12400; @@ -835,8 +838,8 @@ L19999: K=43; L2610: if (V1 == 1000+CAGE && V2 == 1000+BIRD && HERE(CAGE) && HERE(BIRD)) WD1=MAKEWD(301200308); L2620: if (WD1 == MAKEWD(23051920)) { - game.iwest=game.iwest+1; - if (game.iwest == 10)RSPEAK(17); + ++game.iwest; + if (game.iwest == 10)RSPEAK(17); } if (WD1 == MAKEWD( 715) && WD2 != 0) { if (++IGO == 10) @@ -987,7 +990,7 @@ L11000: game.prop[BOTTLE]=PUT(BOTTLE,115,1); PUT(GRATE,116,0); PUT(SIGN,116,0); - OBJTXT[SIGN]=OBJTXT[SIGN]+1; + ++OBJTXT[SIGN]; game.prop[SNAKE]=PUT(SNAKE,116,1); game.prop[BIRD]=PUT(BIRD,116,1); game.prop[CAGE]=PUT(CAGE,116,0); diff --git a/misc.c b/misc.c index 546cf48..95b90ca 100644 --- a/misc.c +++ b/misc.c @@ -28,7 +28,7 @@ void SPEAK(vocab_t msg) nparms=1; do { nxt=labs(LINES[msg])-1; - msg=msg+1; + ++msg; LNLENG=0; LNPOSN=1; state=0; @@ -71,7 +71,7 @@ void SPEAK(vocab_t msg) if (PARMS[nparms+1] < 0) casemake=0; PUTTXT(PARMS[nparms],&state,casemake); - nparms=nparms+1; + ++nparms; } ++nparms; continue; @@ -254,7 +254,7 @@ long GETTXT(bool skip, bool onewrd, bool upper) return(text); if ((!skip) || INLINE[LNPOSN] != 0) break; - LNPOSN=LNPOSN+1; + ++LNPOSN; } text=0; @@ -268,7 +268,7 @@ long GETTXT(bool skip, bool onewrd, bool upper) if (upper && current >= 37) current=current-26; text=text+current; - LNPOSN=LNPOSN+1; + ++LNPOSN; continue; } if (splitting != LNPOSN) { @@ -279,7 +279,7 @@ long GETTXT(bool skip, bool onewrd, bool upper) text=text+current-PERCENT; splitting = -1; - LNPOSN=LNPOSN+1; + ++LNPOSN; } return text; @@ -342,7 +342,7 @@ void PUTTXT(token_t word, long *state, long casemake) *state=*state+byte; if (*state < alph2 && *state >= alph1)*state=*state-26*casemake; INLINE[LNPOSN]=*state; - LNPOSN=LNPOSN+1; + ++LNPOSN; *state=0; } } @@ -464,7 +464,7 @@ void CARRY(long object, long where) if (game.place[object] == -1) return; game.place[object]= -1; - game.holdng=game.holdng+1; + ++game.holdng; } if (game.atloc[where] == object) { game.atloc[where]=game.link[object]; diff --git a/score.c b/score.c index 3c94f83..b1e0d7a 100644 --- a/score.c +++ b/score.c @@ -38,10 +38,10 @@ void score(long mode) if(i == CHEST)k=14; if(i > CHEST)k=16; if(game.prop[i] >= 0) - score=score+2; + score += 2; if(game.place[i] == 3 && game.prop[i] == 0) - score=score+k-2; - mxscor=mxscor+k; + score += k-2; + mxscor += k; } } @@ -51,34 +51,34 @@ void score(long mode) * indicates whether he reached the endgame. And if he got as far as * "cave closed" (indicated by "game.closed"), then bonus is zero for * mundane exits or 133, 134, 135 if he blew it (so to speak). */ - score=score+(MAXDIE-game.numdie)*10; - mxscor=mxscor+MAXDIE*10; - if(mode == 0)score=score+4; - mxscor=mxscor+4; - if(game.dflag != 0)score=score+25; - mxscor=mxscor+25; - if(game.closng)score=score+25; - mxscor=mxscor+25; + score += (MAXDIE-game.numdie)*10; + mxscor += MAXDIE*10; + if(mode == 0)score += 4; + mxscor += 4; + if(game.dflag != 0)score += 25; + mxscor += 25; + if(game.closng)score += 25; + mxscor += 25; if(game.closed) { if(game.bonus == 0) - score=score+10; + score += 10; if(game.bonus == 135) - score=score+25; + score += 25; if(game.bonus == 134) - score=score+30; + score += 30; if(game.bonus == 133) - score=score+45; + score += 45; } - mxscor=mxscor+45; + mxscor += 45; /* Did he come to Witt's End as he should? */ if(game.place[MAGZIN] == 108) - score=score+1; - mxscor=mxscor+1; + score += 1; + mxscor += 1; /* Round it off. */ - score=score+2; - mxscor=mxscor+2; + score += 2; + mxscor += 2; /* Deduct for hints/turns/saves. Hints < 4 are special; see database desc. */ for (i=1; i<=HNTMAX; i++) { @@ -86,9 +86,9 @@ void score(long mode) score=score-HINTS[i][2]; } if(game.novice) - score=score-5; + score -= 5; if(game.clshnt) - score=score-10; + score -= 10; score=score-game.trnluz-game.saved; /* Return to score command if that's where we came from. */