X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;f=misc.c;h=78cc5a30e5a13a5da4f68519e77bb1a30a52ee6b;hb=b5badcacc8f3518a9fbb1338bdfc8f3621d3b26b;hp=784eb7310f063ee3a700055a17590e4d83a13786;hpb=ef97d579ea8974bfd42b9c5b0d5c9d1983e99448;p=open-adventure.git diff --git a/misc.c b/misc.c index 784eb73..78cc5a3 100644 --- a/misc.c +++ b/misc.c @@ -171,8 +171,17 @@ void vspeak(const char* msg, bool blank, va_list ap) long previous_arg = 0; for (int i = 0; i < msglen; i++) { if (msg[i] != '%') { - *renderp++ = msg[i]; - size--; + /* Ugh. Least obtrusive way to deal with artifacts "on the floor" + * being dropped outside of both cave and building. */ + if (strncmp(msg + i, "floor", 5) == 0 && strchr(" .", msg[i+5]) && !INSIDE(game.loc)) { + strcpy(renderp, "ground"); + renderp += 6; + i += 4; + size -= 5; + } else { + *renderp++ = msg[i]; + size--; + } } else { long arg = va_arg(ap, long); if (arg == -1) @@ -352,7 +361,7 @@ char* get_input() bool silent_yes() { - bool outcome; + bool outcome = false; for (;;) { char* reply = get_input(); @@ -363,6 +372,11 @@ bool silent_yes() exit(EXIT_SUCCESS); // LCOV_EXCL_STOP } + if (strlen(reply) == 0) { + free(reply); + rspeak(PLEASE_ANSWER); + continue; + } char* firstword = (char*) xmalloc(strlen(reply) + 1); sscanf(reply, "%s", firstword); @@ -398,7 +412,7 @@ bool yes(const char* question, const char* yes_response, const char* no_response /* Print message X, wait for yes/no answer. If yes, print Y and return true; * if no, print Z and return false. */ { - bool outcome; + bool outcome = false; for (;;) { speak(question); @@ -412,6 +426,12 @@ bool yes(const char* question, const char* yes_response, const char* no_response // LCOV_EXCL_STOP } + if (strlen(reply) == 0) { + free(reply); + rspeak(PLEASE_ANSWER); + continue; + } + char* firstword = (char*) xmalloc(strlen(reply) + 1); sscanf(reply, "%s", firstword); @@ -560,7 +580,8 @@ void move(obj_t object, loc_t where) from = game.fixed[object - NOBJECTS]; else from = game.place[object]; - if (from != LOC_NOWHERE && from != CARRIED && !SPECIAL(from)) + /* (ESR) Used to check for !SPECIAL(from). I *think* that was wrong... */ + if (from != LOC_NOWHERE && from != CARRIED) carry(object, from); drop(object, where); }