extern struct player *player; /* current player's context */
extern char *praddr(struct player *);
extern void player_main(struct player *);
+extern void make_stale_if_command_arg(char *);
/* more under Commands */
/* recvclient.c */
extern int recvclient(char *, int);
return 1;
}
+/* Is ARG one of the player's last command's arguments? */
+static int
+is_command_arg(char *arg)
+{
+ int i;
+
+ for (i = 1; i < 128 && player->argp[i]; i++) {
+ if (arg == player->argp[i])
+ return 1;
+ }
+ return 0;
+}
+
+/*
+ * Make all objects stale if ARG is one of the player's command arguments.
+ * See ef_make_stale() for what "making stale" means.
+ * Useful for functions that prompt for missing arguments.
+ * These can yield the processor, so we'd like to call ef_make_stale()
+ * there. Except that leads to false positives when the caller passes
+ * an argument that is never null, and relies on the fact that the
+ * function doesn't yield then. We can't know that in general. But
+ * we do know in the common special case of command arguments.
+ */
+void
+make_stale_if_command_arg(char *arg)
+{
+ if (is_command_arg(arg))
+ ef_make_stale();
+}
+
/*
* XXX This whole mess should be redone; execute block should
* start with "exec start", and should end with "exec end".
#include <string.h>
#include "misc.h"
+#include "prototypes.h"
/*
* Get string argument.
return NULL;
} else {
strcpy(buf, input);
+ make_stale_if_command_arg(input);
}
return buf;
}
if (!arg || !*arg) {
if (!(arg = getstring(prompt, buf)))
return -1;
- }
+ } else
+ make_stale_if_command_arg(arg);
n = atoi(arg);
if (n < 0)
return -1;
str = getstring(prompt, buf);
if (!str)
return 0;
- }
+ } else
+ make_stale_if_command_arg(str);
if (*str == 0) {
- /* empty string passed by player */
return 0;
}
if (type == EF_NATION && isalpha(*str)) {
/*
* setup the nstr_sect structure for sector selection.
- * can select on either NS_ALL, NS_AREA, or NS_RANGE
+ * can select on either NS_ALL, NS_AREA, or NS_DIST
* iterate thru the "condarg" string looking
* for arguments to compile into the nstr.
* Using this function for anything but command arguments is usually
if (!str || !*str) {
if (!(str = getstring("(sects)? ", buf)))
return 0;
- }
+ } else
+ make_stale_if_command_arg(str);
switch (sarg_type(str)) {
case NS_AREA:
if (!sarg_area(str, &range))