Indented with src/scripts/indent-emp.

This commit is contained in:
Markus Armbruster 2003-09-02 20:48:48 +00:00
parent 5f263a7753
commit 9b7adfbecc
437 changed files with 52211 additions and 51052 deletions

View file

@ -50,79 +50,79 @@ int
path(void)
{
struct nstr_sect ns;
struct natstr *natp;
struct range absrange;
struct range relrange;
struct sctstr sect, dsect;
coord cx, cy;
int i;
int y;
s_char *pp, *p, *BestDistPath();
/* Note this is not re-entrant anyway, so we keep the buffers
around */
static s_char *mapbuf = (s_char *)0;
static s_char **map = (s_char **)0;
double move_cost;
s_char buf[1024];
struct nstr_sect ns;
struct natstr *natp;
struct range absrange;
struct range relrange;
struct sctstr sect, dsect;
coord cx, cy;
int i;
int y;
s_char *pp, *p, *BestDistPath();
/* Note this is not re-entrant anyway, so we keep the buffers
around */
static s_char *mapbuf = (s_char *)0;
static s_char **map = (s_char **)0;
double move_cost;
s_char buf[1024];
if (!(p = getstarg(player->argp[1], "from sector : ", buf)) ||
!sarg_xy(p, &cx, &cy) ||
!getsect(cx, cy, &sect))
return RET_SYN;
if ((sect.sct_own != player->cnum) && !player->god){
pr("Not yours\n");
return RET_FAIL;
if (!(p = getstarg(player->argp[1], "from sector : ", buf)) ||
!sarg_xy(p, &cx, &cy) || !getsect(cx, cy, &sect))
return RET_SYN;
if ((sect.sct_own != player->cnum) && !player->god) {
pr("Not yours\n");
return RET_FAIL;
}
getsect(sect.sct_dist_x, sect.sct_dist_y, &dsect);
pp = BestDistPath(buf, &sect, &dsect, &move_cost, MOB_ROAD);
if (pp == (s_char *)0) {
pr("No path possible from %s to distribution sector %s\n",
xyas(sect.sct_x, sect.sct_y, player->cnum),
xyas(dsect.sct_x, dsect.sct_y, player->cnum));
return RET_FAIL;
}
if (!mapbuf)
mapbuf =
(s_char *)malloc((WORLD_Y * MAPWIDTH(3)) * sizeof(s_char));
if (!map) {
map = (s_char **)malloc(WORLD_Y * sizeof(s_char *));
if (map && mapbuf) {
for (i = 0; i < WORLD_Y; i++)
map[i] = &mapbuf[MAPWIDTH(3) * i];
} else if (map) {
free((s_char *)map);
map = (s_char **)0;
}
getsect(sect.sct_dist_x,sect.sct_dist_y,&dsect);
pp = BestDistPath(buf, &sect,&dsect,&move_cost,MOB_ROAD);
if (pp == (s_char *)0){
pr("No path possible from %s to distribution sector %s\n",
xyas(sect.sct_x,sect.sct_y,player->cnum),
xyas(dsect.sct_x,dsect.sct_y,player->cnum));
return RET_FAIL;
}
if (!mapbuf)
mapbuf = (s_char *)malloc((WORLD_Y*MAPWIDTH(3))*sizeof(s_char));
if (!map) {
map = (s_char **)malloc(WORLD_Y * sizeof(s_char *));
if (map && mapbuf) {
for (i = 0; i < WORLD_Y; i++)
map[i] = &mapbuf[MAPWIDTH(3) * i];
} else if (map) {
free((s_char *)map);
map = (s_char **)0;
}
}
if (!mapbuf || !map) {
pr("Memory error, tell the deity.\n");
logerror("malloc failed in path\n");
return RET_FAIL;
}
pathrange(cx, cy, pp, 1, &absrange);
snxtsct_area(&ns, &absrange);
natp = getnatp(player->cnum);
xyrelrange(natp, &absrange, &relrange);
blankfill((s_char *)mapbuf, &ns.range, 3);
while (*pp && (i = chkdir(*pp, DIR_STOP, DIR_LAST)) >= 0) {
bcopy(routech[i][0], &map[deltay(cy, ns.range.ly)]
[deltax(cx, ns.range.lx)*2], 3);
cx += diroff[i][0];
cy += diroff[i][1];
++pp;
}
border(&relrange, " ", " ");
while (nxtsct(&ns, &sect)) {
if (!player->owner)
continue;
map[ns.dy][ns.dx*2+1] = dchr[sect.sct_type].d_mnem;
}
for (y=ns.range.ly, i=0; i < ns.range.height; y++, i++) {
cy = yrel(natp, y);
pr("%4d %s %-4d\n", cy, map[i], cy);
if (y >= WORLD_Y)
y -= WORLD_Y;
}
border(&relrange, " ", " ");
return RET_OK;
}
if (!mapbuf || !map) {
pr("Memory error, tell the deity.\n");
logerror("malloc failed in path\n");
return RET_FAIL;
}
pathrange(cx, cy, pp, 1, &absrange);
snxtsct_area(&ns, &absrange);
natp = getnatp(player->cnum);
xyrelrange(natp, &absrange, &relrange);
blankfill((s_char *)mapbuf, &ns.range, 3);
while (*pp && (i = chkdir(*pp, DIR_STOP, DIR_LAST)) >= 0) {
bcopy(routech[i][0], &map[deltay(cy, ns.range.ly)]
[deltax(cx, ns.range.lx) * 2], 3);
cx += diroff[i][0];
cy += diroff[i][1];
++pp;
}
border(&relrange, " ", " ");
while (nxtsct(&ns, &sect)) {
if (!player->owner)
continue;
map[ns.dy][ns.dx * 2 + 1] = dchr[sect.sct_type].d_mnem;
}
for (y = ns.range.ly, i = 0; i < ns.range.height; y++, i++) {
cy = yrel(natp, y);
pr("%4d %s %-4d\n", cy, map[i], cy);
if (y >= WORLD_Y)
y -= WORLD_Y;
}
border(&relrange, " ", " ");
return RET_OK;
}