projects
/
open-adventure.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Another use of state_change().
[open-adventure.git]
/
actions.c
diff --git
a/actions.c
b/actions.c
index 5de7cb001e4a7b276ccc19c8f0e96bd05539e470..de888d4584d1f1528378324ff5b3f50f84e22d3c 100644
(file)
--- a/
actions.c
+++ b/
actions.c
@@
-1,5
+1,6
@@
#include <stdlib.h>
#include <stdbool.h>
#include <stdlib.h>
#include <stdbool.h>
+#include <string.h>
#include "advent.h"
#include "dungeon.h"
#include "advent.h"
#include "dungeon.h"
@@
-171,7
+172,7
@@
static int bigwords(token_t foo)
* Look up foo in special section of vocab to determine which word we've got.
* Last word zips the eggs back to the giant room (unless already there). */
{
* Look up foo in special section of vocab to determine which word we've got.
* Last word zips the eggs back to the giant room (unless already there). */
{
- char word[
6
];
+ char word[
TOKLEN+1
];
packed_to_token(foo, word);
int k = (int) get_special_vocab_id(word);
int spk = NOTHING_HAPPENS;
packed_to_token(foo, word);
int k = (int) get_special_vocab_id(word);
int spk = NOTHING_HAPPENS;
@@
-481,13
+482,12
@@
static int discard(token_t verb, token_t obj, bool just_do_it)
DESTROY(BIRD);
return GO_CLEAROBJ;
} else if (obj == BEAR && AT(TROLL)) {
DESTROY(BIRD);
return GO_CLEAROBJ;
} else if (obj == BEAR && AT(TROLL)) {
-
rspeak(TROLL_SCAMPERS
);
+
state_change(TROLL, TROLL_GONE
);
move(TROLL, LOC_NOWHERE);
move(TROLL + NOBJECTS, LOC_NOWHERE);
move(TROLL2, objects[TROLL].plac);
move(TROLL2 + NOBJECTS, objects[TROLL].fixd);
juggle(CHASM);
move(TROLL, LOC_NOWHERE);
move(TROLL + NOBJECTS, LOC_NOWHERE);
move(TROLL2, objects[TROLL].plac);
move(TROLL2 + NOBJECTS, objects[TROLL].fixd);
juggle(CHASM);
- game.prop[TROLL] = TROLL_GONE;
} else if (obj != VASE ||
game.loc == objects[PILLOW].plac) {
rspeak(OK_MAN);
} else if (obj != VASE ||
game.loc == objects[PILLOW].plac) {
rspeak(OK_MAN);
@@
-942,15
+942,15
@@
static int pour(token_t verb, token_t obj)
return GO_CLEAROBJ;
}
if (!AT(DOOR)) {
return GO_CLEAROBJ;
}
if (!AT(DOOR)) {
- if (obj != WATER) {
+ if (obj == WATER) {
+ /* cycle through the three plant states */
+ state_change(PLANT, MOD(game.prop[PLANT] + 1, 3));
+ game.prop[PLANT2] = game.prop[PLANT];
+ return GO_MOVE;
+ } else {
rspeak(SHAKING_LEAVES);
return GO_CLEAROBJ;
rspeak(SHAKING_LEAVES);
return GO_CLEAROBJ;
- }
- /* FIXME: Arithmetic on state numbers */
- pspeak(PLANT, look, game.prop[PLANT] + 3, true);
- game.prop[PLANT] = MOD(game.prop[PLANT] + 1, 3);
- game.prop[PLANT2] = game.prop[PLANT];
- return GO_MOVE;
+ }
} else {
state_change(DOOR, (obj == OIL) ?
DOOR_UNRUSTED :
} else {
state_change(DOOR, (obj == OIL) ?
DOOR_UNRUSTED :
@@
-983,7
+983,7
@@
static int read(struct command_t command)
}
if (DARK(game.loc)) {
}
if (DARK(game.loc)) {
-
rspeak(NO_SEE, command.wd1, command.wd1x
);
+
sspeak(NO_SEE, command.raw1
);
} else if (command.obj == OYSTER && !game.clshnt && game.closed) {
game.clshnt = yes(arbitrary_messages[CLUE_QUERY], arbitrary_messages[WAYOUT_CLUE], arbitrary_messages[OK_MAN]);
} else if (objects[command.obj].texts[0] == NULL ||
} else if (command.obj == OYSTER && !game.clshnt && game.closed) {
game.clshnt = yes(arbitrary_messages[CLUE_QUERY], arbitrary_messages[WAYOUT_CLUE], arbitrary_messages[OK_MAN]);
} else if (objects[command.obj].texts[0] == NULL ||
@@
-1037,13
+1037,13
@@
static int rub(token_t verb, token_t obj)
static int say(struct command_t *command)
/* Say. Echo WD2 (or WD1 if no WD2 (SAY WHAT?, etc.).) Magic words override. */
{
static int say(struct command_t *command)
/* Say. Echo WD2 (or WD1 if no WD2 (SAY WHAT?, etc.).) Magic words override. */
{
- long a = command->wd1
, b = command->wd1x
;
+ long a = command->wd1;
if (command->wd2 > 0) {
a = command->wd2;
if (command->wd2 > 0) {
a = command->wd2;
- b = command->wd2x;
command->wd1 = command->wd2;
command->wd1 = command->wd2;
+ strcpy(command->raw1, command->raw2);
}
}
- char word1[
6
];
+ char word1[
TOKLEN+1
];
packed_to_token(command->wd1, word1);
int wd = (int) get_vocab_id(word1);
/* FIXME: magic numbers */
packed_to_token(command->wd1, word1);
int wd = (int) get_vocab_id(word1);
/* FIXME: magic numbers */
@@
-1056,7
+1056,7
@@
static int say(struct command_t *command)
wordclear(&command->wd2);
return GO_LOOKUP;
}
wordclear(&command->wd2);
return GO_LOOKUP;
}
-
rspeak(OKEY_DOKEY, a, b
);
+
sspeak(OKEY_DOKEY, command->raw1
);
return GO_CLEAROBJ;
}
return GO_CLEAROBJ;
}
@@
-1240,7
+1240,7
@@
int action(struct command_t *command)
command->verb == INVENTORY) && command->wd2 <= 0)
/* FALL THROUGH */;
else {
command->verb == INVENTORY) && command->wd2 <= 0)
/* FALL THROUGH */;
else {
-
rspeak(NO_SEE, command->wd1, command->wd1x
);
+
sspeak(NO_SEE, command->raw1
);
return GO_CLEAROBJ;
}
return GO_CLEAROBJ;
}
@@
-1437,7
+1437,7
@@
int action(struct command_t *command)
}
case unknown:
/* Unknown verb, couldn't deduce object - might need hint */
}
case unknown:
/* Unknown verb, couldn't deduce object - might need hint */
-
rspeak(WHAT_DO, command->wd1, command->wd1x
);
+
sspeak(WHAT_DO, command->raw1
);
return GO_CHECKHINT;
default:
BUG(SPEECHPART_NOT_TRANSITIVE_OR_INTRANSITIVE_OR_UNKNOWN); // LCOV_EXCL_LINE
return GO_CHECKHINT;
default:
BUG(SPEECHPART_NOT_TRANSITIVE_OR_INTRANSITIVE_OR_UNKNOWN); // LCOV_EXCL_LINE