refactored fallback_handler() to use command_t, isolating from side effects
[open-adventure.git] / misc.c
diff --git a/misc.c b/misc.c
index 784eb7310f063ee3a700055a17590e4d83a13786..e9d833e30ef3d547bd741ff927f4fba104282316 100644 (file)
--- a/misc.c
+++ b/misc.c
@@ -352,7 +352,7 @@ char* get_input()
 
 bool silent_yes()
 {
-    bool outcome;
+    bool outcome = false;
 
     for (;;) {
         char* reply = get_input();
@@ -363,6 +363,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 +403,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 +417,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 +571,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);
 }