00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #include <config.h>
00035
00036 #include "commands.h"
00037 #include "item.h"
00038 #include "path.h"
00039
00040 int
00041 deli(void)
00042 {
00043 struct sctstr sect;
00044 int dir, del;
00045 struct ichrstr *ich;
00046 int thresh;
00047 int sx, sy;
00048 struct nstr_sect nstr;
00049 char buf[1024];
00050 char prompt[128];
00051 char *p;
00052
00053 if ((ich = whatitem(player->argp[1], "deliver what? ")) == 0)
00054 return RET_SYN;
00055
00056
00057
00058
00059
00060
00061 if (!snxtsct(&nstr, player->argp[2]))
00062 return RET_SYN;
00063
00064 while (!player->aborted && nxtsct(&nstr, §) > 0) {
00065 if (!player->owner)
00066 continue;
00067
00068 del = sect.sct_del[ich->i_uid];
00069 thresh = del & ~0x7;
00070 dir = del & 0x7;
00071
00072 sprintf(prompt, "%s %s %s threshold or direction or 'query'? ",
00073 xyas(nstr.x, nstr.y, player->cnum),
00074 dchr[sect.sct_type].d_name, ich->i_name);
00075 if (!(p = getstarg(player->argp[3], prompt, buf)) || !*p)
00076 return RET_SYN;
00077 if (*p != 'q') {
00078 sprintf(prompt, "%s %s %s direction? ",
00079 xyas(nstr.x, nstr.y, player->cnum),
00080 dchr[sect.sct_type].d_name, ich->i_name);
00081 if (((*p >= '0') && (*p <= '9')) || *p == '+') {
00082 thresh = atoi(p) & ~0x7;
00083 if (*p == '+')
00084 p = NULL;
00085 else {
00086 p = getstarg(player->argp[4], prompt, buf);
00087 }
00088 }
00089 if (p && *p) {
00090 dir = chkdir(*p, DIR_STOP, DIR_LAST);
00091 if (dir < 0) {
00092 pr("'%c' is not a valid direction...\n", *p);
00093 direrr(NULL, NULL, NULL);
00094 return RET_SYN;
00095 }
00096 }
00097
00098 if (!check_sect_ok(§))
00099 continue;
00100
00101 thresh = MIN(thresh, ITEM_MAX) & ~7;
00102 del = thresh | dir;
00103 sect.sct_del[ich->i_uid] = del;
00104 putsect(§);
00105 }
00106
00107 if (!del)
00108 continue;
00109
00110 sx = diroff[dir][0] + sect.sct_x;
00111 sy = diroff[dir][1] + sect.sct_y;
00112 pr("Deliver %s from %s @ %s to %s",
00113 ich->i_name,
00114 dchr[sect.sct_type].d_name,
00115 xyas(sect.sct_x, sect.sct_y, player->cnum),
00116 xyas(sx, sy, player->cnum));
00117 if (!(del & ~0x7))
00118 pr("\n");
00119 else
00120 pr(" (cutoff %d)\n", thresh);
00121 }
00122
00123 return RET_OK;
00124 }