projects
/
open-adventure.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Use C idioms for increment/decrement.
[open-adventure.git]
/
main.c
diff --git
a/main.c
b/main.c
index fd84ca7894b16961f1e46b5546c679f034dd66ca..42fa5e1123b389c90e72033d31b849da7b593732 100644
(file)
--- a/
main.c
+++ b/
main.c
@@
-11,6
+11,7
@@
#include <time.h>
#include "advent.h"
#include "database.h"
#include <time.h>
#include "advent.h"
#include "database.h"
+#include "linenoise/linenoise.h"
struct game_t game;
struct game_t game;
@@
-82,6
+83,8
@@
case 'l':
}
}
}
}
+ linenoiseHistorySetMaxLen(350);
+
/* Logical variables:
*
* game.closed says whether we're all the way closed
/* Logical variables:
*
* game.closed says whether we're all the way closed
@@
-506,7
+509,7
@@
static bool playermove(FILE *cmdin, token_t verb)
K2=KK;
}
if (TRAVEL[KK] >= 0) {
K2=KK;
}
if (TRAVEL[KK] >= 0) {
-
KK=KK+1
;
+
++KK
;
goto L21;
}
KK=K2;
goto L21;
}
KK=K2;
@@
-528,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);
* (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;
game.wzdark=false;
game.abbrev[game.loc]=0;
return true;
@@
-560,7
+563,7
@@
L9:
RSPEAK(SPK);
return true;
}
RSPEAK(SPK);
return true;
}
-
KK=KK+1
;
+
++KK
;
}
LL=LL/1000;
}
LL=LL/1000;
@@
-579,7
+582,7
@@
L11:
L12:
do {
if (TRAVEL[KK] < 0)BUG(25);
L12:
do {
if (TRAVEL[KK] < 0)BUG(25);
-
KK=KK+1
;
+
++KK
;
game.newloc=labs(TRAVEL[KK])/1000;
} while
(game.newloc == LL);
game.newloc=labs(TRAVEL[KK])/1000;
} while
(game.newloc == LL);
@@
-659,6
+662,7
@@
static bool do_command(FILE *cmdin)
long KQ, VERB, KK, V1, V2;
long obj, i;
static long IGO = 0;
long KQ, VERB, KK, V1, V2;
long obj, i;
static long IGO = 0;
+ enum speechpart part;
/* Can't leave cave once it's closing (except by main office). */
if (OUTSID(game.newloc) && game.newloc != 0 && game.closng) {
/* Can't leave cave once it's closing (except by main office). */
if (OUTSID(game.newloc) && game.newloc != 0 && game.closng) {
@@
-722,7
+726,7
@@
L2000: if (game.loc == 0)
* get full score. */
if (DARK(0)) goto L2012;
* 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;
i=game.atloc[game.loc];
L2004: if (i == 0) goto L2012;
obj=i;
@@
-732,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;
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;
/* 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;
@@
-768,7
+772,7
@@
L2600: if (COND[game.loc] >= game.conds) {
continue;
if (!CNDBIT(game.loc,hint+10))
game.hintlc[hint]= -1;
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);
}
if (game.hintlc[hint] >= HINTS[hint][1])
dohint(cmdin, hint);
}
@@
-799,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);
* 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;
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.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) 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.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;
if (game.limit <= 30 && HERE(BATTER) && game.prop[BATTER] == 0 && HERE(LAMP))
goto L12000;
if (game.limit == 0) goto L12400;
@@
-831,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)) {
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)
}
if (WD1 == MAKEWD( 715) && WD2 != 0) {
if (++IGO == 10)
@@
-868,11
+875,11
@@
L3000: SETPRM(1,WD1,WD1X);
/* Verb and object analysis moved to separate module. */
/* Verb and object analysis moved to separate module. */
-L4000:
i=4000
; VERB=K; goto Laction;
-L4090:
i=4090
; goto Laction;
-L5000:
i=5000
; obj = K;
+L4000:
part=intransitive
; VERB=K; goto Laction;
+L4090:
part=transitive
; goto Laction;
+L5000:
part=unknown
; obj = K;
Laction:
Laction:
- switch (action(cmdin,
i
, VERB, obj)) {
+ switch (action(cmdin,
part
, VERB, obj)) {
case 2: return true;
case 8: goto L8;
case 2000: goto L2000;
case 2: return true;
case 8: goto L8;
case 2000: goto L2000;
@@
-983,7
+990,7
@@
L11000: game.prop[BOTTLE]=PUT(BOTTLE,115,1);
PUT(GRATE,116,0);
PUT(SIGN,116,0);
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);
game.prop[SNAKE]=PUT(SNAKE,116,1);
game.prop[BIRD]=PUT(BIRD,116,1);
game.prop[CAGE]=PUT(CAGE,116,0);