(deli): Partial rewrite for clarity, motivated by a `might be used
unitialized' warning. Funcional change: you can now change direction without threshold (matches documentation, clarify it anyway). Change prompt for the third argument to reflect that. Also provide context when prompting for the fourth argument; this is sorely needed we didn't prompt for the third argument.
This commit is contained in:
parent
cb23a7e5b0
commit
c5915737b6
2 changed files with 35 additions and 20 deletions
|
@ -1,7 +1,10 @@
|
||||||
.TH Command DELIVER
|
.TH Command DELIVER
|
||||||
.NA deliver "Establish delivery routes for shells, ore, etc"
|
.NA deliver "Establish delivery routes for shells, ore, etc"
|
||||||
.LV Expert
|
.LV Expert
|
||||||
.SY "deliver <COMM> <SECTS> [q|<THRESH>] [<DIR>]"
|
.SY "deliver <COMM> <SECTS> <THRESH> <DIR>"
|
||||||
|
.SY "deliver <COMM> <SECTS> +<THRESH>"
|
||||||
|
.SY "deliver <COMM> <SECTS> <DIR>"
|
||||||
|
.SY "deliver <COMM> <SECTS> q"
|
||||||
.s1
|
.s1
|
||||||
An example of using deliver in addition to distribute is where
|
An example of using deliver in addition to distribute is where
|
||||||
you may have a mine which uses distribute to get its food
|
you may have a mine which uses distribute to get its food
|
||||||
|
|
|
@ -49,7 +49,7 @@ deli(void)
|
||||||
struct sctstr sect;
|
struct sctstr sect;
|
||||||
register int dir, del;
|
register int dir, del;
|
||||||
register struct ichrstr *ich;
|
register struct ichrstr *ich;
|
||||||
register int thresh = -1;
|
register int thresh;
|
||||||
int i_del;
|
int i_del;
|
||||||
int sx, sy;
|
int sx, sy;
|
||||||
int status;
|
int status;
|
||||||
|
@ -73,27 +73,37 @@ deli(void)
|
||||||
while (nxtsct(&nstr, §) > 0) {
|
while (nxtsct(&nstr, §) > 0) {
|
||||||
if (!player->owner)
|
if (!player->owner)
|
||||||
continue;
|
continue;
|
||||||
sprintf(prompt, "%s %s 'query' or %s threshold? ",
|
|
||||||
|
del = getvar(i_del, (s_char *)§, EF_SECTOR);
|
||||||
|
thresh = del & ~0x7;
|
||||||
|
dir = del & 0x7;
|
||||||
|
|
||||||
|
sprintf(prompt, "%s %s %s threshold or direction or 'query'? ",
|
||||||
xyas(nstr.x, nstr.y, player->cnum),
|
xyas(nstr.x, nstr.y, player->cnum),
|
||||||
dchr[sect.sct_type].d_name, ich->i_name);
|
dchr[sect.sct_type].d_name, ich->i_name);
|
||||||
if (!(p = getstarg(player->argp[3], prompt, buf)) || !*p)
|
if (!(p = getstarg(player->argp[3], prompt, buf)) || !*p)
|
||||||
return RET_SYN;
|
return RET_SYN;
|
||||||
del = getvar(i_del, (s_char *)§, EF_SECTOR);
|
if (*p != 'q') {
|
||||||
if (((*p >= '0') && (*p <= '9')) || *p == '+') {
|
sprintf(prompt, "%s %s %s direction? ",
|
||||||
thresh = atoi(p) & ~0x7;
|
xyas(nstr.x, nstr.y, player->cnum),
|
||||||
if (*p == '+'
|
dchr[sect.sct_type].d_name, ich->i_name);
|
||||||
|| !(p = getstarg(player->argp[4], "Direction? ", buf))
|
if (((*p >= '0') && (*p <= '9')) || *p == '+') {
|
||||||
|| !*p)
|
thresh = atoi(p) & ~0x7;
|
||||||
dir = del & 0x7;
|
if (*p == '+')
|
||||||
else if ((dir = chkdir(*p, DIR_STOP, DIR_LAST)) < 0)
|
p = NULL;
|
||||||
return RET_SYN;
|
else {
|
||||||
} else if (*p != 'q')
|
p = getstarg(player->argp[4], prompt, buf);
|
||||||
return RET_SYN;
|
}
|
||||||
|
}
|
||||||
|
if (p && *p) {
|
||||||
|
dir = chkdir(*p, DIR_STOP, DIR_LAST);
|
||||||
|
if (dir < 0)
|
||||||
|
return RET_SYN;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!check_sect_ok(§))
|
||||||
|
continue;
|
||||||
|
|
||||||
if (!check_sect_ok(§))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (thresh >= 0) {
|
|
||||||
del = thresh + dir;
|
del = thresh + dir;
|
||||||
status = putvar(i_del, del, (s_char *)§, EF_SECTOR);
|
status = putvar(i_del, del, (s_char *)§, EF_SECTOR);
|
||||||
if (status < 0) {
|
if (status < 0) {
|
||||||
|
@ -106,9 +116,10 @@ deli(void)
|
||||||
} else
|
} else
|
||||||
putsect(§);
|
putsect(§);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!del)
|
if (!del)
|
||||||
continue;
|
continue;
|
||||||
dir = del & 0x7;
|
|
||||||
sx = diroff[dir][0] + sect.sct_x;
|
sx = diroff[dir][0] + sect.sct_x;
|
||||||
sy = diroff[dir][1] + sect.sct_y;
|
sy = diroff[dir][1] + sect.sct_y;
|
||||||
pr("Deliver %s from %s @ %s to %s",
|
pr("Deliver %s from %s @ %s to %s",
|
||||||
|
@ -119,7 +130,8 @@ deli(void)
|
||||||
if (!(del & ~0x7))
|
if (!(del & ~0x7))
|
||||||
pr("\n");
|
pr("\n");
|
||||||
else
|
else
|
||||||
pr(" (cutoff %d)\n", del & ~0x7);
|
pr(" (cutoff %d)\n", thresh);
|
||||||
}
|
}
|
||||||
|
|
||||||
return RET_OK;
|
return RET_OK;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue