(att_prompt): Do the right thing when player aborts. Simplify.

This commit is contained in:
Markus Armbruster 2006-04-17 17:53:16 +00:00
parent 6fee3f4535
commit d852f05a2a

View 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?] * Which units would you like to attack with or move in with [ynYNq?]
*/ */
static s_char static char
att_prompt(s_char *prompt, s_char army) att_prompt(char *prompt, char army)
{ {
s_char buf[1024]; char buf[1024];
s_char *p = buf; char *p = buf;
if (army == ' ') if (army == ' ')
army = '~'; army = '~';
*buf = -2; for (;;) {
while (!p || (*p != 'y' && *p != 'n' && *p != 'Y' && *p != 'N')) { p = getstring(prompt, buf);
if (p && *p == 'q') { if (player->aborted || (p && *p == 'q')) {
abort_attack(); abort_attack();
return 'N'; return 'N';
} }
if (!p || !*p) if (!p || !*p)
return 'n'; return 'n';
if (p && *p != -2) if (tolower(*p) == 'y' || tolower(*p) == 'n')
pr("y - yes this unit\n" return *p;
"n - no this unit\n" pr("y - yes this unit\n"
"Y - yes to all units in army '%c'\n" "n - no this unit\n"
"N - no to all units in army '%c'\n" "Y - yes to all units in army '%c'\n"
"q - quit\n" "N - no to all units in army '%c'\n"
"? - this help message\n\n", "q - quit\n? - this help message\n\n",
army, army); army, army);
p = getstring(prompt, buf);
if (player->aborted) {
buf[0] = 'N';
p = buf;
}
} }
return *p;
} }
/* Ask the attacker which units they want to attack/assault/board with */ /* Ask the attacker which units they want to attack/assault/board with */