Use the raw buffer in tr command structure for editing.
This fixes some minor bugs. Unknown words are no longer truncated nor uppercased on echo.
This commit is contained in:
parent
854e21a1af
commit
a768555312
13 changed files with 40 additions and 26 deletions
|
@ -983,7 +983,7 @@ static int read(struct command_t command)
|
|||
}
|
||||
|
||||
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 ||
|
||||
|
@ -1240,7 +1240,7 @@ int action(struct command_t *command)
|
|||
command->verb == INVENTORY) && command->wd2 <= 0)
|
||||
/* FALL THROUGH */;
|
||||
else {
|
||||
rspeak(NO_SEE, command->wd1, command->wd1x);
|
||||
sspeak(NO_SEE, command->raw1);
|
||||
return GO_CLEAROBJ;
|
||||
}
|
||||
|
||||
|
@ -1437,7 +1437,7 @@ int action(struct command_t *command)
|
|||
}
|
||||
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
|
||||
|
|
1
advent.h
1
advent.h
|
@ -199,6 +199,7 @@ extern bool wordeq(token_t, token_t);
|
|||
extern bool wordempty(token_t);
|
||||
extern void wordclear(token_t *);
|
||||
extern void speak(const char*, ...);
|
||||
extern void sspeak(long msg, ...);
|
||||
extern void pspeak(vocab_t, enum speaktype, int, bool, ...);
|
||||
extern void rspeak(vocab_t, ...);
|
||||
extern void echo_input(FILE*, const char*, const char*);
|
||||
|
|
|
@ -3116,9 +3116,9 @@ arbitrary_messages: !!omap
|
|||
- ONE_HIT: 'One of them gets you!'
|
||||
- NONE_HIT: 'None of them hits you!'
|
||||
- DONT_KNOW: 'Sorry, I don''t know the word "%s".'
|
||||
- WHAT_DO: 'What do you want to do with the %L%L?' # FIXME: %L%L should become %L once parsing no longer depends on packed tokens
|
||||
- NO_SEE: 'I see no %L%L here.' # FIXME: %L%L should become %L once parsing no longer depends on packed tokens
|
||||
- DO_WHAT: '%C what?'
|
||||
- WHAT_DO: 'What do you want to do with the %s?'
|
||||
- NO_SEE: 'I see no %s here.'
|
||||
- DO_WHAT: '%s what?'
|
||||
- OKEY_DOKEY: 'Okay, "%s".'
|
||||
- GARNERED_POINTS: 'You have garnered %d out of a possible %d points, using %d turn%S.'
|
||||
- SUSPEND_WARNING: |-
|
||||
|
|
10
main.c
10
main.c
|
@ -20,6 +20,7 @@
|
|||
#include <getopt.h>
|
||||
#include <signal.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include "advent.h"
|
||||
#include "dungeon.h"
|
||||
|
||||
|
@ -1101,7 +1102,6 @@ L2607:
|
|||
}
|
||||
if (V1 == ENTER && command.wd2 > 0) {
|
||||
command.wd1 = command.wd2;
|
||||
command.wd1x = command.wd2x;
|
||||
wordclear(&command.wd2);
|
||||
} else {
|
||||
/* FIXME: Magic numbers related to vocabulary */
|
||||
|
@ -1130,7 +1130,7 @@ Lookup:
|
|||
/* Gee, I don't understand. */
|
||||
if (fallback_handler(inputbuf))
|
||||
continue;
|
||||
rspeak(DONT_KNOW, command.wd1, command.wd1x);
|
||||
sspeak(DONT_KNOW, command.raw1);
|
||||
goto L2600;
|
||||
}
|
||||
/* FIXME: magic numbers related to vocabulary */
|
||||
|
@ -1174,13 +1174,15 @@ Laction:
|
|||
case GO_WORD2:
|
||||
/* Get second word for analysis. */
|
||||
command.wd1 = command.wd2;
|
||||
command.wd1x = command.wd2x;
|
||||
strcpy(command.raw1, command.raw2);
|
||||
wordclear(&command.wd2);
|
||||
command.raw2[0] = '\0';
|
||||
goto L2620;
|
||||
case GO_UNKNOWN:
|
||||
/* Random intransitive verbs come here. Clear obj just in case
|
||||
* (see attack()). */
|
||||
rspeak(DO_WHAT, command.wd1, command.wd1x);
|
||||
command.raw1[0] = toupper(command.raw1[0]);
|
||||
sspeak(DO_WHAT, command.raw1);
|
||||
command.obj = 0;
|
||||
goto L2600;
|
||||
case GO_DWARFWAKE:
|
||||
|
|
14
misc.c
14
misc.c
|
@ -127,9 +127,7 @@ void tokenize(char* raw, struct command_t *cmd)
|
|||
|
||||
// pack the substrings
|
||||
cmd->wd1 = token_to_packed(chunk_data[0]);
|
||||
cmd->wd1x = token_to_packed(chunk_data[1]);
|
||||
cmd->wd2 = token_to_packed(chunk_data[2]);
|
||||
cmd->wd2x = token_to_packed(chunk_data[3]);
|
||||
}
|
||||
|
||||
/* Hide the fact that wods are corrently packed longs */
|
||||
|
@ -149,7 +147,7 @@ void wordclear(token_t *v)
|
|||
*v = 0;
|
||||
}
|
||||
|
||||
/* I/O routines (speak, pspeak, rspeak, get_input, yes) */
|
||||
/* I/O routines (speak, pspeak, rspeak, sspeak, get_input, yes) */
|
||||
|
||||
void vspeak(const char* msg, bool blank, va_list ap)
|
||||
{
|
||||
|
@ -253,6 +251,16 @@ void speak(const char* msg, ...)
|
|||
va_end(ap);
|
||||
}
|
||||
|
||||
void sspeak(const long msg, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, msg);
|
||||
fputc('\n', stdout);
|
||||
vprintf(arbitrary_messages[msg], ap);
|
||||
fputc('\n', stdout);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
void pspeak(vocab_t msg, enum speaktype mode, int skip, bool blank, ...)
|
||||
/* Find the skip+1st message from msg and print it. Modes are:
|
||||
* feel = for inventory, what you can touch
|
||||
|
|
|
@ -52,6 +52,9 @@ Bug fixes:
|
|||
|
||||
* Attempting to extinguish an unlit urn caused it to lose its oil.
|
||||
|
||||
* Unrecognized words are no longer truncated to 5 characters and
|
||||
uppercased when they are echoed.
|
||||
|
||||
By default, advent issues "> " as a command prompt. This feature
|
||||
became common in many variants after the original 350-point version,
|
||||
but was never backported into Crowther & Woods's main line before now.
|
||||
|
|
|
@ -251,7 +251,7 @@ Nothing happens.
|
|||
|
||||
> find bar
|
||||
|
||||
Sorry, I don't know the word "BAR".
|
||||
Sorry, I don't know the word "bar".
|
||||
|
||||
> carry
|
||||
|
||||
|
@ -388,7 +388,7 @@ you come to it. To get the full description, say "look".
|
|||
|
||||
> frob grate
|
||||
|
||||
Sorry, I don't know the word "FROB".
|
||||
Sorry, I don't know the word "frob".
|
||||
|
||||
> read grate
|
||||
|
||||
|
|
|
@ -617,7 +617,7 @@ A formidable ogre bars the northern exit.
|
|||
|
||||
> attack
|
||||
|
||||
Attac what?
|
||||
Attack what?
|
||||
|
||||
> kill ogre
|
||||
|
||||
|
@ -1606,7 +1606,7 @@ You can't carry anything more. You'll have to drop something first.
|
|||
|
||||
> pour bottle
|
||||
|
||||
Bottl what?
|
||||
Bottle what?
|
||||
|
||||
> n
|
||||
|
||||
|
|
|
@ -208,7 +208,7 @@ OK
|
|||
|
||||
> ew
|
||||
|
||||
Sorry, I don't know the word "EW".
|
||||
Sorry, I don't know the word "ew".
|
||||
|
||||
> w
|
||||
|
||||
|
|
|
@ -10,19 +10,19 @@ down a gully.
|
|||
|
||||
i
|
||||
|
||||
Sorry, I don't know the word "I".
|
||||
Sorry, I don't know the word "i".
|
||||
|
||||
l
|
||||
|
||||
Sorry, I don't know the word "L".
|
||||
Sorry, I don't know the word "l".
|
||||
|
||||
x
|
||||
|
||||
Sorry, I don't know the word "X".
|
||||
Sorry, I don't know the word "x".
|
||||
|
||||
z
|
||||
|
||||
Sorry, I don't know the word "Z".
|
||||
Sorry, I don't know the word "z".
|
||||
|
||||
quit
|
||||
|
||||
|
|
|
@ -2021,7 +2021,7 @@ The urn is now dark.
|
|||
|
||||
> extinguish
|
||||
|
||||
Extin what?
|
||||
Extinguish what?
|
||||
|
||||
> look
|
||||
|
||||
|
|
|
@ -298,7 +298,7 @@ section of wall, revealing a dark passage leading south.
|
|||
|
||||
> attack
|
||||
|
||||
Attac what?
|
||||
Attack what?
|
||||
|
||||
> attack machine
|
||||
|
||||
|
|
|
@ -162,11 +162,11 @@ Wake what?
|
|||
|
||||
> quit nagging
|
||||
|
||||
Sorry, I don't know the word "NAGGI".
|
||||
Sorry, I don't know the word "nagging".
|
||||
|
||||
> nothing doing
|
||||
|
||||
Sorry, I don't know the word "DOING".
|
||||
Sorry, I don't know the word "doing".
|
||||
|
||||
> e
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue