(ef_byname_from): New.

(set, mission, multifire, fuel, cons_choose, cede): Use it instead of
ef_byname().  Remove the hacks to map unwanted results to wanted
results.  The hacks in set() were broken: bad input made the code cast
arbitrary items to union trdgenstr, with potentially disastrous
consequences.  Closes #906483 and #906486.

(set): Less cryptic prompt and diagnostics.
This commit is contained in:
Markus Armbruster 2005-10-27 21:33:17 +00:00
parent 2df98825e9
commit 2fc1e74a72
8 changed files with 54 additions and 30 deletions

View file

@ -55,6 +55,7 @@ static void grab_ship(struct shpstr *, natid);
int
cede(void)
{
static int sct_or_shp[] = { EF_SECTOR, EF_SHIP, EF_BAD };
natid to;
int n;
int is_sector = 0, is_ship = 0;
@ -83,13 +84,8 @@ cede(void)
return RET_FAIL;
if (strlen(p) > 4)
p[2] = 0;
type = ef_byname(p);
if (type == EF_SECTOR)
is_ship = 0;
else if (type == EF_SHIP)
is_sector = 0;
else {
type = ef_byname_from(p, sct_or_shp);
if (type < 0) {
pr("Please type 'se' or 'sh'!\n");
return RET_FAIL;
}