Fix extra prompt after abort due to misuse of snxtitem()
The old code used getstarg() to get an argument with a different prompt than snxtitem() uses, then passed the value to snxtitem() unchecked. If the player aborts, getstarg() returns a null pointer, and snxtitem() prompts again. Affected: * load/lload plane/land third argument; load_plane_ship(), load_land_ship(), load_plane_land(), load_land_land() * bomb, drop, fly, paradrop, recon and sweep second argument; get_planes() * tend and ltend second and fourth argument; ltend(), tend(), tend_land() * mission second argument; mission() Fix by making snxtitem() taking a prompt argument, null pointer requests the old prompt. Use that to simplify multifire() and torp(). Change the other callers to pass NULL.
This commit is contained in:
parent
9f4ce71a54
commit
3cc8de8aef
67 changed files with 108 additions and 113 deletions
|
@ -70,12 +70,9 @@ int
|
|||
get_planes(struct nstr_item *ni_bomb, struct nstr_item *ni_esc,
|
||||
char *input_bomb, char *input_esc)
|
||||
{
|
||||
char buf[1024];
|
||||
|
||||
if (!snxtitem(ni_bomb, EF_PLANE, input_bomb))
|
||||
if (!snxtitem(ni_bomb, EF_PLANE, input_bomb, NULL))
|
||||
return -1;
|
||||
if (!snxtitem(ni_esc, EF_PLANE,
|
||||
getstarg(input_esc, "escort(s)? ", buf))) {
|
||||
if (!snxtitem(ni_esc, EF_PLANE, input_esc, "escort(s)? ")) {
|
||||
if (player->aborted)
|
||||
return -1;
|
||||
pr("No escorts...\n");
|
||||
|
|
|
@ -145,7 +145,7 @@ satmap(int x, int y, int eff, int range, int flags, int type)
|
|||
if ((type == EF_BAD || type == EF_SHIP) &&
|
||||
(flags & P_S || flags & P_I)) {
|
||||
if (type == EF_SHIP)
|
||||
snxtitem(&ni, EF_SHIP, selection);
|
||||
snxtitem(&ni, EF_SHIP, selection, NULL);
|
||||
else
|
||||
snxtitem_dist(&ni, EF_SHIP, x, y, range);
|
||||
|
||||
|
@ -190,7 +190,7 @@ satmap(int x, int y, int eff, int range, int flags, int type)
|
|||
if ((type == EF_BAD || type == EF_LAND) &&
|
||||
(flags & P_S || flags & P_I)) {
|
||||
if (type == EF_LAND)
|
||||
snxtitem(&ni, EF_LAND, selection);
|
||||
snxtitem(&ni, EF_LAND, selection, NULL);
|
||||
else
|
||||
snxtitem_dist(&ni, EF_LAND, x, y, range);
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@
|
|||
* instead.
|
||||
*/
|
||||
int
|
||||
snxtitem(struct nstr_item *np, int type, char *str)
|
||||
snxtitem(struct nstr_item *np, int type, char *str, char *prompt)
|
||||
{
|
||||
struct range range;
|
||||
int list[NS_LSIZE];
|
||||
|
@ -59,13 +59,16 @@ snxtitem(struct nstr_item *np, int type, char *str)
|
|||
coord cx, cy;
|
||||
int dist;
|
||||
int flags;
|
||||
char prompt[128];
|
||||
char promptbuf[128];
|
||||
char buf[1024];
|
||||
|
||||
np->type = EF_BAD;
|
||||
np->sel = NS_UNDEF;
|
||||
if (str == 0) {
|
||||
sprintf(prompt, "%s(s)? ", ef_nameof(type));
|
||||
if (!prompt) {
|
||||
sprintf(promptbuf, "%s(s)? ", ef_nameof(type));
|
||||
prompt = promptbuf;
|
||||
}
|
||||
str = getstring(prompt, buf);
|
||||
if (str == 0)
|
||||
return 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue