/*
* Empire - A multi-player, client/server Internet based war game.
- * Copyright (C) 1986-2011, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ * Copyright (C) 1986-2014, Dave Pare, Jeff Bailey, Thomas Ruschak,
* Ken Stevens, Steve McClure, Markus Armbruster
*
* Empire is free software: you can redistribute it and/or modify
*
* Known contributors to this file:
* Dave Pare, 1989
- * Markus Armbruster, 2006-2009
+ * Markus Armbruster, 2006-2011
*/
#include <config.h>
/*
* 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
struct range range;
struct natstr *natp;
coord cx, cy;
- int dist, n;
+ int dist;
char buf[1024];
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))
default:
return 0;
}
- if (!player->condarg)
- return 1;
- n = nstr_comp(np->cond, sizeof(np->cond) / sizeof(*np->cond),
- EF_SECTOR, player->condarg);
- np->ncond = n >= 0 ? n : 0;
- return n >= 0;
+ return snxtsct_use_condarg(np);
}
void
np->dy = 0;
}
+int
+snxtsct_use_condarg(struct nstr_sect *np)
+{
+ int n;
+
+ if (!player->condarg)
+ return 1;
+ n = nstr_comp(np->cond, sizeof(np->cond) / sizeof(*np->cond),
+ EF_SECTOR, player->condarg);
+ if (n < 0)
+ return 0;
+ np->ncond = n;
+ return 1;
+}
+
void
snxtsct_rewind(struct nstr_sect *np)
{