]> git.pond.sub.org Git - empserver/commitdiff
(att_prompt): Do the right thing when player aborts. Simplify.
authorMarkus Armbruster <armbru@pond.sub.org>
Mon, 17 Apr 2006 17:53:16 +0000 (17:53 +0000)
committerMarkus Armbruster <armbru@pond.sub.org>
Mon, 17 Apr 2006 17:53:16 +0000 (17:53 +0000)
src/lib/subs/attsub.c

index c82076e8d830642e44329f697a0ba085a5e76c68..7629c720b08713ff2d3756a6d858a55b916b6d5c 100644 (file)
@@ -916,37 +916,31 @@ ask_off(int combat_mode, struct combat *off, struct combat *def)
  * Which units would you like to attack with or move in with [ynYNq?]
  */
 
-static s_char
-att_prompt(s_char *prompt, s_char army)
+static char
+att_prompt(char *prompt, char army)
 {
-    s_char buf[1024];
-    s_char *p = buf;
+    char buf[1024];
+    char *p = buf;
 
     if (army == ' ')
        army = '~';
-    *buf = -2;
-    while (!p || (*p != 'y' && *p != 'n' && *p != 'Y' && *p != 'N')) {
-       if (p && *p == 'q') {
+    for (;;) {
+       p = getstring(prompt, buf);
+       if (player->aborted || (p && *p == 'q')) {
            abort_attack();
            return 'N';
        }
        if (!p || !*p)
            return 'n';
-       if (p && *p != -2)
-           pr("y - yes this unit\n"
-              "n - no this unit\n"
-              "Y - yes to all units in army '%c'\n"
-              "N - no to all units in army '%c'\n"
-              "q - quit\n"
-              "? - this help message\n\n",
-              army, army);
-       p = getstring(prompt, buf);
-       if (player->aborted) {
-           buf[0] = 'N';
-           p = buf;
-       }
+       if (tolower(*p) == 'y' || tolower(*p) == 'n')
+           return *p;
+       pr("y - yes this unit\n"
+          "n - no this unit\n"
+          "Y - yes to all units in army '%c'\n"
+          "N - no to all units in army '%c'\n"
+          "q - quit\n? - this help message\n\n",
+          army, army);
     }
-    return *p;
 }
 
 /* Ask the attacker which units they want to attack/assault/board with */