Use NULL instead of (FOO *)0, it's easier to read.
This commit is contained in:
parent
3252f8a907
commit
21bf6b41d4
23 changed files with 75 additions and 79 deletions
|
@ -85,9 +85,9 @@ as_add_cachepath(struct as_data *adp)
|
||||||
/* Note we will only allocate this once. Afterwards, we just keep
|
/* Note we will only allocate this once. Afterwards, we just keep
|
||||||
* zeroing it since it's rather small and we don't need to re-allocate
|
* zeroing it since it's rather small and we don't need to re-allocate
|
||||||
* each time. */
|
* each time. */
|
||||||
if (fromhead == (struct as_frompath **)0) {
|
if (fromhead == NULL) {
|
||||||
fromhead = calloc(1, sizeof(struct as_frompath *) * WORLD_Y);
|
fromhead = calloc(1, sizeof(struct as_frompath *) * WORLD_Y);
|
||||||
if (fromhead == (struct as_frompath **)0)
|
if (fromhead == NULL)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,7 +143,7 @@ as_clear_cachepath(void)
|
||||||
int i, j;
|
int i, j;
|
||||||
|
|
||||||
/* Cache not used yet :) */
|
/* Cache not used yet :) */
|
||||||
if (fromhead == (struct as_frompath **)0)
|
if (fromhead == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (j = 0; j < WORLD_Y; j++) {
|
for (j = 0; j < WORLD_Y; j++) {
|
||||||
|
@ -181,7 +181,7 @@ as_find_cachepath(coord fx, coord fy, coord tx, coord ty)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
/* Do we have any cached? */
|
/* Do we have any cached? */
|
||||||
if (fromhead == (struct as_frompath **)0)
|
if (fromhead == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
/* Yes! */
|
/* Yes! */
|
||||||
|
|
|
@ -65,7 +65,7 @@ best(void)
|
||||||
if (s2.sct_own != player->cnum)
|
if (s2.sct_own != player->cnum)
|
||||||
continue;
|
continue;
|
||||||
s = BestLandPath(buf, &s1, &s2, &cost, MOB_ROAD);
|
s = BestLandPath(buf, &s1, &s2, &cost, MOB_ROAD);
|
||||||
if (s != (s_char *)0)
|
if (s)
|
||||||
pr("Best path from %s to %s is %s (cost %1.3f)\n",
|
pr("Best path from %s to %s is %s (cost %1.3f)\n",
|
||||||
xyas(s1.sct_x, s1.sct_y, player->cnum),
|
xyas(s1.sct_x, s1.sct_y, player->cnum),
|
||||||
xyas(s2.sct_x, s2.sct_y, player->cnum), s, cost);
|
xyas(s2.sct_x, s2.sct_y, player->cnum), s, cost);
|
||||||
|
|
|
@ -413,7 +413,7 @@ comm_bomb(struct emp_qelem *list, struct sctstr *target)
|
||||||
pr("some %s\n", ip->i_name);
|
pr("some %s\n", ip->i_name);
|
||||||
}
|
}
|
||||||
for (;;) {
|
for (;;) {
|
||||||
ip = whatitem((s_char *)0, "commodity to bomb? ");
|
ip = whatitem(NULL, "commodity to bomb? ");
|
||||||
if (player->aborted)
|
if (player->aborted)
|
||||||
return;
|
return;
|
||||||
if (!ip)
|
if (!ip)
|
||||||
|
|
|
@ -102,7 +102,7 @@ dist(void)
|
||||||
|
|
||||||
path = BestDistPath(buf, §, &dsect, &move_cost, MOB_ROAD);
|
path = BestDistPath(buf, §, &dsect, &move_cost, MOB_ROAD);
|
||||||
|
|
||||||
if (path == (s_char *)0) {
|
if (!path) {
|
||||||
pr("No owned path from %s to %s.\n",
|
pr("No owned path from %s to %s.\n",
|
||||||
xyas(dsect.sct_x, dsect.sct_y, player->cnum),
|
xyas(dsect.sct_x, dsect.sct_y, player->cnum),
|
||||||
xyas(sect.sct_x, sect.sct_y, player->cnum));
|
xyas(sect.sct_x, sect.sct_y, player->cnum));
|
||||||
|
|
|
@ -224,9 +224,9 @@ nav_map(int x, int y, int show_designations)
|
||||||
int i;
|
int i;
|
||||||
/* Note this is not re-entrant anyway, so we keep the buffers
|
/* Note this is not re-entrant anyway, so we keep the buffers
|
||||||
around */
|
around */
|
||||||
static u_char *bitmap = (u_char *)0;
|
static u_char *bitmap = NULL;
|
||||||
static s_char *wmapbuf = (s_char *)0;
|
static s_char *wmapbuf = NULL;
|
||||||
static s_char **wmap = (s_char **)0;
|
static s_char **wmap = NULL;
|
||||||
s_char what[64];
|
s_char what[64];
|
||||||
int changed = 0;
|
int changed = 0;
|
||||||
|
|
||||||
|
@ -244,7 +244,7 @@ nav_map(int x, int y, int show_designations)
|
||||||
wmap[i] = &wmapbuf[MAPWIDTH(1) * i];
|
wmap[i] = &wmapbuf[MAPWIDTH(1) * i];
|
||||||
} else if (wmap) {
|
} else if (wmap) {
|
||||||
free(wmap);
|
free(wmap);
|
||||||
wmap = (s_char **)0;
|
wmap = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!bitmap)
|
if (!bitmap)
|
||||||
|
|
|
@ -61,8 +61,8 @@ path(void)
|
||||||
s_char *pp, *p;
|
s_char *pp, *p;
|
||||||
/* Note this is not re-entrant anyway, so we keep the buffers
|
/* Note this is not re-entrant anyway, so we keep the buffers
|
||||||
around */
|
around */
|
||||||
static s_char *mapbuf = (s_char *)0;
|
static s_char *mapbuf = NULL;
|
||||||
static s_char **map = (s_char **)0;
|
static s_char **map = NULL;
|
||||||
double move_cost;
|
double move_cost;
|
||||||
s_char buf[1024];
|
s_char buf[1024];
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ path(void)
|
||||||
}
|
}
|
||||||
getsect(sect.sct_dist_x, sect.sct_dist_y, &dsect);
|
getsect(sect.sct_dist_x, sect.sct_dist_y, &dsect);
|
||||||
pp = BestDistPath(buf, §, &dsect, &move_cost, MOB_ROAD);
|
pp = BestDistPath(buf, §, &dsect, &move_cost, MOB_ROAD);
|
||||||
if (pp == (s_char *)0) {
|
if (!pp) {
|
||||||
pr("No path possible from %s to distribution sector %s\n",
|
pr("No path possible from %s to distribution sector %s\n",
|
||||||
xyas(sect.sct_x, sect.sct_y, player->cnum),
|
xyas(sect.sct_x, sect.sct_y, player->cnum),
|
||||||
xyas(dsect.sct_x, dsect.sct_y, player->cnum));
|
xyas(dsect.sct_x, dsect.sct_y, player->cnum));
|
||||||
|
@ -90,7 +90,7 @@ path(void)
|
||||||
map[i] = &mapbuf[MAPWIDTH(3) * i];
|
map[i] = &mapbuf[MAPWIDTH(3) * i];
|
||||||
} else if (map) {
|
} else if (map) {
|
||||||
free(map);
|
free(map);
|
||||||
map = (s_char **)0;
|
map = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!mapbuf || !map) {
|
if (!mapbuf || !map) {
|
||||||
|
|
|
@ -67,9 +67,9 @@ retr(void)
|
||||||
if (player->argp[2] != NULL)
|
if (player->argp[2] != NULL)
|
||||||
pq = getstarg(player->argp[2], "Retreat path? ", buf1);
|
pq = getstarg(player->argp[2], "Retreat path? ", buf1);
|
||||||
else
|
else
|
||||||
pq = (s_char *)0;
|
pq = NULL;
|
||||||
|
|
||||||
if (pq != (s_char *)0) {
|
if (pq != NULL) {
|
||||||
fl = getstarg(player->argp[3],
|
fl = getstarg(player->argp[3],
|
||||||
"Retreat conditions [i|t|s|h|b|d|u|c]? ", buf2);
|
"Retreat conditions [i|t|s|h|b|d|u|c]? ", buf2);
|
||||||
if (!fl)
|
if (!fl)
|
||||||
|
@ -129,7 +129,7 @@ retr(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rflags == -1)
|
if (rflags == -1)
|
||||||
pq = (s_char *)0;
|
pq = NULL;
|
||||||
|
|
||||||
zero = (rflags == -1);
|
zero = (rflags == -1);
|
||||||
if (zero)
|
if (zero)
|
||||||
|
@ -141,7 +141,7 @@ retr(void)
|
||||||
if (zero)
|
if (zero)
|
||||||
memset(ship.shp_rpath, 0, sizeof(ship.shp_rpath));
|
memset(ship.shp_rpath, 0, sizeof(ship.shp_rpath));
|
||||||
|
|
||||||
if (pq != (s_char *)0) {
|
if (pq != NULL) {
|
||||||
strncpy(ship.shp_rpath, pq, sizeof(ship.shp_rpath));
|
strncpy(ship.shp_rpath, pq, sizeof(ship.shp_rpath));
|
||||||
putship(ship.shp_uid, &ship);
|
putship(ship.shp_uid, &ship);
|
||||||
}
|
}
|
||||||
|
@ -215,8 +215,8 @@ lretr(void)
|
||||||
if (player->argp[2] != NULL)
|
if (player->argp[2] != NULL)
|
||||||
pq = getstarg(player->argp[2], "Retreat path? ", buf1);
|
pq = getstarg(player->argp[2], "Retreat path? ", buf1);
|
||||||
else
|
else
|
||||||
pq = (s_char *)0;
|
pq = NULL;
|
||||||
if (pq != (s_char *)0) {
|
if (pq != NULL) {
|
||||||
fl = getstarg(player->argp[3], "Retreat conditions [i|h|b|c]? ",
|
fl = getstarg(player->argp[3], "Retreat conditions [i|h|b|c]? ",
|
||||||
buf2);
|
buf2);
|
||||||
if (!fl)
|
if (!fl)
|
||||||
|
@ -256,7 +256,7 @@ lretr(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rflags == -1)
|
if (rflags == -1)
|
||||||
pq = (s_char *)0;
|
pq = NULL;
|
||||||
|
|
||||||
zero = (rflags == -1);
|
zero = (rflags == -1);
|
||||||
if (zero)
|
if (zero)
|
||||||
|
@ -268,7 +268,7 @@ lretr(void)
|
||||||
if (zero)
|
if (zero)
|
||||||
memset(land.lnd_rpath, 0, sizeof(land.lnd_rpath));
|
memset(land.lnd_rpath, 0, sizeof(land.lnd_rpath));
|
||||||
|
|
||||||
if (pq != (s_char *)0) {
|
if (pq != NULL) {
|
||||||
strncpy(land.lnd_rpath, pq, sizeof(land.lnd_rpath));
|
strncpy(land.lnd_rpath, pq, sizeof(land.lnd_rpath));
|
||||||
putland(land.lnd_uid, &land);
|
putland(land.lnd_uid, &land);
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,9 +67,9 @@ rout(void)
|
||||||
s_char buf1[1024];
|
s_char buf1[1024];
|
||||||
/* Note this is not re-entrant anyway, so we keep the buffers
|
/* Note this is not re-entrant anyway, so we keep the buffers
|
||||||
around */
|
around */
|
||||||
static s_char *mapbuf = (s_char *)0;
|
static s_char *mapbuf = NULL;
|
||||||
static s_char **map = (s_char **)0;
|
static s_char **map = NULL;
|
||||||
static s_char *buf = (s_char *)0;
|
static s_char *buf = NULL;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if ((ip = whatitem(player->argp[1], "What item? ")) == 0)
|
if ((ip = whatitem(player->argp[1], "What item? ")) == 0)
|
||||||
|
@ -98,7 +98,7 @@ rout(void)
|
||||||
map[i] = &mapbuf[MAPWIDTH(3) * i];
|
map[i] = &mapbuf[MAPWIDTH(3) * i];
|
||||||
} else if (map) {
|
} else if (map) {
|
||||||
free(map);
|
free(map);
|
||||||
map = (s_char **)0;
|
map = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!buf)
|
if (!buf)
|
||||||
|
|
|
@ -62,8 +62,8 @@ sct(void)
|
||||||
s_char buf[1024];
|
s_char buf[1024];
|
||||||
/* Note this is not re-entrant anyway, so we keep the buffers
|
/* Note this is not re-entrant anyway, so we keep the buffers
|
||||||
around */
|
around */
|
||||||
static s_char *mapbuf = (s_char *)0;
|
static s_char *mapbuf = NULL;
|
||||||
static s_char **map = (s_char **)0;
|
static s_char **map = NULL;
|
||||||
|
|
||||||
nsect = 0;
|
nsect = 0;
|
||||||
if (player->argp[1] == NULL) {
|
if (player->argp[1] == NULL) {
|
||||||
|
@ -90,7 +90,7 @@ sct(void)
|
||||||
map[i] = &mapbuf[MAPWIDTH(1) * i];
|
map[i] = &mapbuf[MAPWIDTH(1) * i];
|
||||||
} else if (map) {
|
} else if (map) {
|
||||||
free(map);
|
free(map);
|
||||||
map = (s_char **)0;
|
map = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!mapbuf || !map) {
|
if (!mapbuf || !map) {
|
||||||
|
|
|
@ -70,8 +70,8 @@ surv(void)
|
||||||
s_char *str;
|
s_char *str;
|
||||||
/* Note this is not re-entrant anyway, so we keep the buffers
|
/* Note this is not re-entrant anyway, so we keep the buffers
|
||||||
around */
|
around */
|
||||||
static s_char *mapbuf = (s_char *)0;
|
static s_char *mapbuf = NULL;
|
||||||
static s_char **map = (s_char **)0;
|
static s_char **map = NULL;
|
||||||
|
|
||||||
nsect = 0;
|
nsect = 0;
|
||||||
if ((ptr = getstarg(player->argp[1], "commodity or variable? ", buf)) == 0)
|
if ((ptr = getstarg(player->argp[1], "commodity or variable? ", buf)) == 0)
|
||||||
|
@ -109,7 +109,7 @@ surv(void)
|
||||||
map[i] = &mapbuf[MAPWIDTH(1) * i];
|
map[i] = &mapbuf[MAPWIDTH(1) * i];
|
||||||
} else if (map) {
|
} else if (map) {
|
||||||
free(map);
|
free(map);
|
||||||
map = (s_char **)0;
|
map = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!mapbuf || !map) {
|
if (!mapbuf || !map) {
|
||||||
|
|
|
@ -78,7 +78,7 @@ terr(void)
|
||||||
sprintf(prompt, "%s %d%% %s territory? ",
|
sprintf(prompt, "%s %d%% %s territory? ",
|
||||||
xyas(nstr.x, nstr.y, player->cnum),
|
xyas(nstr.x, nstr.y, player->cnum),
|
||||||
sect.sct_effic, dchr[sect.sct_type].d_name);
|
sect.sct_effic, dchr[sect.sct_type].d_name);
|
||||||
if ((p = getstarg((s_char *)0, prompt, buf)) == 0)
|
if ((p = getstarg(NULL, prompt, buf)) == 0)
|
||||||
return RET_FAIL;
|
return RET_FAIL;
|
||||||
if (!check_sect_ok(§))
|
if (!check_sect_ok(§))
|
||||||
return RET_FAIL;
|
return RET_FAIL;
|
||||||
|
|
|
@ -117,8 +117,8 @@ int dy[6] = { 0, -1, -1, 0, 1, 1 };
|
||||||
* would be slow. And, since world size only changes at init
|
* would be slow. And, since world size only changes at init
|
||||||
* time, we can do this safely.
|
* time, we can do this safely.
|
||||||
*/
|
*/
|
||||||
static unsigned int *mapbuf = (unsigned int *)0;
|
static unsigned int *mapbuf;
|
||||||
static unsigned int **mapindex = (unsigned int **)0;
|
static unsigned int **mapindex;
|
||||||
|
|
||||||
s_char *
|
s_char *
|
||||||
bestownedpath(s_char *bpath,
|
bestownedpath(s_char *bpath,
|
||||||
|
|
|
@ -66,9 +66,9 @@ draw_map(int bmap, s_char origin, int map_flags, struct nstr_sect *nsp)
|
||||||
int i;
|
int i;
|
||||||
/* Note this is not re-entrant anyway, so we keep the buffers
|
/* Note this is not re-entrant anyway, so we keep the buffers
|
||||||
around */
|
around */
|
||||||
static u_char *bitmap = (u_char *)0;
|
static u_char *bitmap = NULL;
|
||||||
static s_char *wmapbuf = (s_char *)0;
|
static s_char *wmapbuf = NULL;
|
||||||
static s_char **wmap = (s_char **)0;
|
static s_char **wmap = NULL;
|
||||||
|
|
||||||
if (!wmapbuf)
|
if (!wmapbuf)
|
||||||
wmapbuf = malloc((WORLD_Y * MAPWIDTH(1)) * sizeof(s_char));
|
wmapbuf = malloc((WORLD_Y * MAPWIDTH(1)) * sizeof(s_char));
|
||||||
|
@ -79,7 +79,7 @@ draw_map(int bmap, s_char origin, int map_flags, struct nstr_sect *nsp)
|
||||||
wmap[i] = &wmapbuf[MAPWIDTH(1) * i];
|
wmap[i] = &wmapbuf[MAPWIDTH(1) * i];
|
||||||
} else if (wmap) {
|
} else if (wmap) {
|
||||||
free(wmap);
|
free(wmap);
|
||||||
wmap = (s_char **)0;
|
wmap = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!bitmap)
|
if (!bitmap)
|
||||||
|
|
|
@ -88,7 +88,7 @@ bp_init(void)
|
||||||
if (bp->adp == NULL)
|
if (bp->adp == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (neighsects == (struct sctstr **)0)
|
if (neighsects == NULL)
|
||||||
neighsects = calloc(((WORLD_X * WORLD_Y) / 2) * 6,
|
neighsects = calloc(((WORLD_X * WORLD_Y) / 2) * 6,
|
||||||
sizeof(struct sctstr *));
|
sizeof(struct sctstr *));
|
||||||
|
|
||||||
|
@ -201,12 +201,12 @@ bp_neighbors(struct as_coord c, struct as_coord *cp, s_char *pp)
|
||||||
offset = (sy * WORLD_X + sx) / 2;
|
offset = (sy * WORLD_X + sx) / 2;
|
||||||
from = §p[offset];
|
from = §p[offset];
|
||||||
|
|
||||||
if (neighsects == (struct sctstr **)0)
|
if (neighsects == NULL)
|
||||||
ssp = (struct sctstr **)&tsp[0];
|
ssp = (struct sctstr **)&tsp[0];
|
||||||
else
|
else
|
||||||
ssp = (struct sctstr **)&neighsects[offset * 6];
|
ssp = (struct sctstr **)&neighsects[offset * 6];
|
||||||
for (q = 1; q <= 6; q++, ssp++) {
|
for (q = 1; q <= 6; q++, ssp++) {
|
||||||
if (*ssp == (struct sctstr *)0) {
|
if (*ssp == NULL) {
|
||||||
/* We haven't cached this neighbor yet */
|
/* We haven't cached this neighbor yet */
|
||||||
nx = x + diroff[q][0];
|
nx = x + diroff[q][0];
|
||||||
ny = y + diroff[q][1];
|
ny = y + diroff[q][1];
|
||||||
|
@ -360,7 +360,7 @@ BestLandPath(s_char *path,
|
||||||
*path = 0;
|
*path = 0;
|
||||||
*cost = 0.0;
|
*cost = 0.0;
|
||||||
if (best_path(from, to, path, mob_type) < 0)
|
if (best_path(from, to, path, mob_type) < 0)
|
||||||
return (s_char *)0;
|
return NULL;
|
||||||
*cost = pathcost(from, path, mob_type);
|
*cost = pathcost(from, path, mob_type);
|
||||||
length = strlen(path);
|
length = strlen(path);
|
||||||
path[length] = 'h';
|
path[length] = 'h';
|
||||||
|
|
|
@ -50,11 +50,11 @@ emp_insque(struct emp_qelem *elem, struct emp_qelem *queue)
|
||||||
void
|
void
|
||||||
emp_remque(struct emp_qelem *elem)
|
emp_remque(struct emp_qelem *elem)
|
||||||
{
|
{
|
||||||
if (elem == (struct emp_qelem *)0)
|
if (!elem)
|
||||||
return;
|
return;
|
||||||
if (elem->q_forw != (struct emp_qelem *)0)
|
if (elem->q_forw)
|
||||||
elem->q_forw->q_back = elem->q_back;
|
elem->q_forw->q_back = elem->q_back;
|
||||||
if (elem->q_back != (struct emp_qelem *)0)
|
if (elem->q_back)
|
||||||
elem->q_back->q_forw = elem->q_forw;
|
elem->q_back->q_forw = elem->q_forw;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2123,7 +2123,7 @@ take_casualty(int combat_mode, struct combat *off, struct emp_qelem *olist)
|
||||||
* Procedure: find the biggest unit remaining (in
|
* Procedure: find the biggest unit remaining (in
|
||||||
* terms of mil) and give it the casualties.
|
* terms of mil) and give it the casualties.
|
||||||
*/
|
*/
|
||||||
biggest = (struct emp_qelem *)0;
|
biggest = NULL;
|
||||||
biggest_mil = -1;
|
biggest_mil = -1;
|
||||||
for (qp = olist->q_forw; qp != olist; qp = qp->q_forw) {
|
for (qp = olist->q_forw; qp != olist; qp = qp->q_forw) {
|
||||||
llp = (struct llist *)qp;
|
llp = (struct llist *)qp;
|
||||||
|
@ -2133,7 +2133,7 @@ take_casualty(int combat_mode, struct combat *off, struct emp_qelem *olist)
|
||||||
biggest = qp;
|
biggest = qp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (biggest == (struct emp_qelem *)0)
|
if (biggest == NULL)
|
||||||
return CASUALTY_LUMP - to_take;
|
return CASUALTY_LUMP - to_take;
|
||||||
|
|
||||||
llp = (struct llist *)biggest;
|
llp = (struct llist *)biggest;
|
||||||
|
|
|
@ -85,9 +85,9 @@ move_ground(s_char *what, struct sctstr *start, struct sctstr *end,
|
||||||
pr("Looking for best path to %s\n", path);
|
pr("Looking for best path to %s\n", path);
|
||||||
path = BestLandPath(buf2, start, &ending_sect, &total_mcost,
|
path = BestLandPath(buf2, start, &ending_sect, &total_mcost,
|
||||||
MOB_ROAD);
|
MOB_ROAD);
|
||||||
if (exploring && (path != (s_char *)0)) /* take off the 'h' */
|
if (exploring && path) /* take off the 'h' */
|
||||||
*(path + strlen(path) - 1) = '\0';
|
path[strlen(path) - 1] = '\0';
|
||||||
if (path == (s_char *)0)
|
if (!path)
|
||||||
pr("No owned path exists!\n");
|
pr("No owned path exists!\n");
|
||||||
else {
|
else {
|
||||||
pr("Using best path '%s', movement cost %1.3f\n",
|
pr("Using best path '%s', movement cost %1.3f\n",
|
||||||
|
@ -111,11 +111,11 @@ move_ground(s_char *what, struct sctstr *start, struct sctstr *end,
|
||||||
for (;;) {
|
for (;;) {
|
||||||
oldx = curx;
|
oldx = curx;
|
||||||
oldy = cury;
|
oldy = cury;
|
||||||
if (movstr == 0 || *movstr == 0) {
|
if (!movstr || *movstr == 0) {
|
||||||
if (exploring) {
|
if (exploring) {
|
||||||
map(what, curx, cury, (s_char *)0);
|
map(what, curx, cury, NULL);
|
||||||
} else {
|
} else {
|
||||||
move_map(what, curx, cury, (s_char *)0);
|
move_map(what, curx, cury, NULL);
|
||||||
}
|
}
|
||||||
sprintf(prompt, "<%.1f: %c %s> ", mobility,
|
sprintf(prompt, "<%.1f: %c %s> ", mobility,
|
||||||
dchr[sect.sct_type].d_mnem,
|
dchr[sect.sct_type].d_mnem,
|
||||||
|
@ -128,17 +128,16 @@ move_ground(s_char *what, struct sctstr *start, struct sctstr *end,
|
||||||
MOB_ROAD);
|
MOB_ROAD);
|
||||||
} else {
|
} else {
|
||||||
pr("Invalid destination sector!\n");
|
pr("Invalid destination sector!\n");
|
||||||
movstr = (s_char *)0;
|
movstr = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (movstr == (s_char *)0) {
|
if (movstr == NULL) {
|
||||||
pr("Can't get to %s from here!\n",
|
pr("Can't get to %s from here!\n",
|
||||||
xyas(dx, dy, player->cnum));
|
xyas(dx, dy, player->cnum));
|
||||||
movstr = (s_char *)0;
|
|
||||||
} else {
|
} else {
|
||||||
if ((mv_cost * weight) > mobility) {
|
if ((mv_cost * weight) > mobility) {
|
||||||
pr("Not enough mobility to go all the way. Nothing moved.\n");
|
pr("Not enough mobility to go all the way. Nothing moved.\n");
|
||||||
movstr = (s_char *)0;
|
movstr = NULL;
|
||||||
} else {
|
} else {
|
||||||
pr("Using best path '%s', movement cost %1.3f\n",
|
pr("Using best path '%s', movement cost %1.3f\n",
|
||||||
movstr, mv_cost);
|
movstr, mv_cost);
|
||||||
|
@ -147,7 +146,7 @@ move_ground(s_char *what, struct sctstr *start, struct sctstr *end,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (movstr == 0 || *movstr == 0) {
|
if (!movstr || *movstr == 0) {
|
||||||
buf2[0] = dirch[DIR_STOP];
|
buf2[0] = dirch[DIR_STOP];
|
||||||
buf2[1] = 0;
|
buf2[1] = 0;
|
||||||
movstr = buf2;
|
movstr = buf2;
|
||||||
|
|
|
@ -199,8 +199,7 @@ s_commod(int own, int x, int y, i_type type, int total_wanted,
|
||||||
continue;
|
continue;
|
||||||
if (sect.sct_effic < 60)
|
if (sect.sct_effic < 60)
|
||||||
continue;
|
continue;
|
||||||
if (BestLandPath(buf, &dest, §, &move_cost, MOB_ROAD) ==
|
if (!BestLandPath(buf, &dest, §, &move_cost, MOB_ROAD))
|
||||||
(s_char *)0)
|
|
||||||
continue;
|
continue;
|
||||||
if (!opt_NOFOOD && type == I_FOOD) {
|
if (!opt_NOFOOD && type == I_FOOD) {
|
||||||
minimum = 2 + ((etu_per_update * eatrate)
|
minimum = 2 + ((etu_per_update * eatrate)
|
||||||
|
@ -275,8 +274,7 @@ s_commod(int own, int x, int y, i_type type, int total_wanted,
|
||||||
continue;
|
continue;
|
||||||
if (sect.sct_effic < 2)
|
if (sect.sct_effic < 2)
|
||||||
continue;
|
continue;
|
||||||
if (BestLandPath(buf, &dest, §, &move_cost, MOB_ROAD) ==
|
if (!BestLandPath(buf, &dest, §, &move_cost, MOB_ROAD))
|
||||||
(s_char *)0)
|
|
||||||
continue;
|
continue;
|
||||||
if (!opt_NOFOOD && type == I_FOOD)
|
if (!opt_NOFOOD && type == I_FOOD)
|
||||||
minimum = 2 + ((etu_per_update * eatrate)
|
minimum = 2 + ((etu_per_update * eatrate)
|
||||||
|
@ -351,8 +349,7 @@ s_commod(int own, int x, int y, i_type type, int total_wanted,
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
getsect(land.lnd_x, land.lnd_y, §);
|
getsect(land.lnd_x, land.lnd_y, §);
|
||||||
if (BestLandPath(buf, &dest, §, &move_cost, MOB_ROAD) ==
|
if (!BestLandPath(buf, &dest, §, &move_cost, MOB_ROAD))
|
||||||
(s_char *)0)
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if ((land.lnd_ship >= 0) && (sect.sct_type != SCT_HARBR))
|
if ((land.lnd_ship >= 0) && (sect.sct_type != SCT_HARBR))
|
||||||
|
|
|
@ -79,7 +79,7 @@ dodistribute(struct sctstr *sp, int imex, s_char *path, double dist_i_cost,
|
||||||
if ((sp->sct_dist_x == sp->sct_x) && (sp->sct_dist_y == sp->sct_y))
|
if ((sp->sct_dist_x == sp->sct_x) && (sp->sct_dist_y == sp->sct_y))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (path == (s_char *)0) {
|
if (!path) {
|
||||||
if (sp->sct_own != 0) {
|
if (sp->sct_own != 0) {
|
||||||
if (imex == EXPORT) /* only want this once */
|
if (imex == EXPORT) /* only want this once */
|
||||||
wu(0, sp->sct_own, "No path to dist sector for %s\n",
|
wu(0, sp->sct_own, "No path to dist sector for %s\n",
|
||||||
|
|
|
@ -80,12 +80,12 @@ finish_sects(int etu)
|
||||||
int n;
|
int n;
|
||||||
struct distinfo *infptr;
|
struct distinfo *infptr;
|
||||||
|
|
||||||
if (g_distptrs == (struct distinfo *)0) {
|
if (g_distptrs == NULL) {
|
||||||
logerror("First update since reboot, allocating buffer\n");
|
logerror("First update since reboot, allocating buffer\n");
|
||||||
/* Allocate the information buffer */
|
/* Allocate the information buffer */
|
||||||
g_distptrs = (struct distinfo *)(malloc((WORLD_X * WORLD_Y) *
|
g_distptrs = (struct distinfo *)(malloc((WORLD_X * WORLD_Y) *
|
||||||
sizeof(struct distinfo)));
|
sizeof(struct distinfo)));
|
||||||
if (g_distptrs == (struct distinfo *)0) {
|
if (g_distptrs == NULL) {
|
||||||
logerror("malloc failed in finish_sects.\n");
|
logerror("malloc failed in finish_sects.\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -191,7 +191,7 @@ assemble_dist_paths(struct distinfo *distptrs)
|
||||||
infptr = &distptrs[XYOFFSET(sp->sct_x, sp->sct_y)];
|
infptr = &distptrs[XYOFFSET(sp->sct_x, sp->sct_y)];
|
||||||
/* now, get the dist sector */
|
/* now, get the dist sector */
|
||||||
dist = getsectp(sp->sct_dist_x, sp->sct_dist_y);
|
dist = getsectp(sp->sct_dist_x, sp->sct_dist_y);
|
||||||
if (dist == (struct sctstr *)0) {
|
if (dist == NULL) {
|
||||||
logerror("Bad dist sect %d,%d for %d,%d !\n", sp->sct_dist_x,
|
logerror("Bad dist sect %d,%d for %d,%d !\n", sp->sct_dist_x,
|
||||||
sp->sct_dist_y, sp->sct_x, sp->sct_y);
|
sp->sct_dist_y, sp->sct_x, sp->sct_y);
|
||||||
continue;
|
continue;
|
||||||
|
@ -202,13 +202,13 @@ assemble_dist_paths(struct distinfo *distptrs)
|
||||||
path = BestDistPath(buf, dist, sp, &d, MOB_ROAD);
|
path = BestDistPath(buf, dist, sp, &d, MOB_ROAD);
|
||||||
|
|
||||||
/* Now, we have a path */
|
/* Now, we have a path */
|
||||||
if (path != (s_char *)0) {
|
if (path != NULL) {
|
||||||
#ifdef SAVE_FINISH_PATHS
|
#ifdef SAVE_FINISH_PATHS
|
||||||
int len;
|
int len;
|
||||||
/* Here we malloc a buffer and save it */
|
/* Here we malloc a buffer and save it */
|
||||||
len = strlen(path);
|
len = strlen(path);
|
||||||
infptr->path = malloc(len);
|
infptr->path = malloc(len);
|
||||||
if (infptr->path == (s_char *)0) {
|
if (infptr->path == NULL) {
|
||||||
logerror("malloc failed in assemble_dist_path!\n");
|
logerror("malloc failed in assemble_dist_path!\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -236,12 +236,12 @@ ReversePath(s_char *path)
|
||||||
static s_char new_path[512];
|
static s_char new_path[512];
|
||||||
int ind;
|
int ind;
|
||||||
|
|
||||||
if (path == (s_char *)0)
|
if (path == NULL)
|
||||||
return (s_char *)0;
|
return NULL;
|
||||||
|
|
||||||
ind = strlen(path);
|
ind = strlen(path);
|
||||||
if (ind == 0)
|
if (ind == 0)
|
||||||
return (s_char *)0;
|
return NULL;
|
||||||
|
|
||||||
if (path[ind - 1] == 'h')
|
if (path[ind - 1] == 'h')
|
||||||
ind--;
|
ind--;
|
||||||
|
|
|
@ -102,7 +102,7 @@ update_main(void *unused)
|
||||||
bp = calloc(WORLD_X * WORLD_Y * 7, sizeof(int));
|
bp = calloc(WORLD_X * WORLD_Y * 7, sizeof(int));
|
||||||
for (n = 0; n < MAXNOC; n++) {
|
for (n = 0; n < MAXNOC; n++) {
|
||||||
money[n] = 0;
|
money[n] = 0;
|
||||||
if ((np = getnatp(n)) == (struct natstr *)0)
|
if (!(np = getnatp(n)))
|
||||||
continue;
|
continue;
|
||||||
money[n] = np->nat_money;
|
money[n] = np->nat_money;
|
||||||
tpops[n] = count_pop(n);
|
tpops[n] = count_pop(n);
|
||||||
|
@ -118,7 +118,7 @@ update_main(void *unused)
|
||||||
|
|
||||||
memset(p_sect, 0, sizeof(p_sect));
|
memset(p_sect, 0, sizeof(p_sect));
|
||||||
mil_dbl_pay = 0;
|
mil_dbl_pay = 0;
|
||||||
if ((np = getnatp(x)) == (struct natstr *)0)
|
if (!(np = getnatp(x)))
|
||||||
continue;
|
continue;
|
||||||
if (np->nat_stat == STAT_SANCT) {
|
if (np->nat_stat == STAT_SANCT) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
|
|
@ -63,7 +63,7 @@ nxtitemp(struct nstr_item *np)
|
||||||
np->cur++;
|
np->cur++;
|
||||||
}
|
}
|
||||||
gp = ef_ptr(np->type, np->cur);
|
gp = ef_ptr(np->type, np->cur);
|
||||||
if (gp == (struct genitem *)0)
|
if (!gp)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
selected = 1;
|
selected = 1;
|
||||||
|
|
|
@ -103,7 +103,7 @@ prod_plane(int etus, int natnum, int *bp, int buildem)
|
||||||
}
|
}
|
||||||
|
|
||||||
onship = 0;
|
onship = 0;
|
||||||
shp = (struct shpstr *)0;
|
shp = NULL;
|
||||||
if (pp->pln_ship >= 0 && (buildem == 1)) {
|
if (pp->pln_ship >= 0 && (buildem == 1)) {
|
||||||
if (pp->pln_effic >= 80)
|
if (pp->pln_effic >= 80)
|
||||||
continue;
|
continue;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue