Don't use 0 as null pointer constant, part 1
Use NULL instead of 0, for clarity. Except in pointer comparisons; leave that to the next two commits.
This commit is contained in:
parent
a2ed975ec2
commit
615681ce16
51 changed files with 107 additions and 100 deletions
|
@ -47,16 +47,16 @@ nxtitemp(struct nstr_item *np)
|
|||
int selected;
|
||||
|
||||
if (np->sel == NS_UNDEF)
|
||||
return 0;
|
||||
return NULL;
|
||||
do {
|
||||
if (np->sel == NS_LIST) {
|
||||
np->index++;
|
||||
if (np->index >= np->size)
|
||||
return 0;
|
||||
return NULL;
|
||||
np->cur = np->list[np->index];
|
||||
} else if (np->sel == NS_CARGO) {
|
||||
if (np->next < 0)
|
||||
return 0;
|
||||
return NULL;
|
||||
np->cur = np->next;
|
||||
np->next = unit_cargo_next(np->type, np->next);
|
||||
} else {
|
||||
|
@ -64,7 +64,7 @@ nxtitemp(struct nstr_item *np)
|
|||
}
|
||||
gp = ef_ptr(np->type, np->cur);
|
||||
if (!gp)
|
||||
return 0;
|
||||
return NULL;
|
||||
|
||||
selected = 1;
|
||||
switch (np->sel) {
|
||||
|
@ -74,7 +74,7 @@ nxtitemp(struct nstr_item *np)
|
|||
break;
|
||||
case NS_DIST:
|
||||
if (CANT_HAPPEN(!(ef_flags(np->type) & EFF_XY)))
|
||||
return 0;
|
||||
return NULL;
|
||||
if (!xyinrange(gp->x, gp->y, &np->range)) {
|
||||
selected = 0;
|
||||
break;
|
||||
|
@ -85,25 +85,25 @@ nxtitemp(struct nstr_item *np)
|
|||
break;
|
||||
case NS_AREA:
|
||||
if (CANT_HAPPEN(!(ef_flags(np->type) & EFF_XY)))
|
||||
return 0;
|
||||
return NULL;
|
||||
if (!xyinrange(gp->x, gp->y, &np->range))
|
||||
selected = 0;
|
||||
break;
|
||||
case NS_XY:
|
||||
if (CANT_HAPPEN(!(ef_flags(np->type) & EFF_XY)))
|
||||
return 0;
|
||||
return NULL;
|
||||
if (xnorm(gp->x) != np->cx || ynorm(gp->y) != np->cy)
|
||||
selected = 0;
|
||||
break;
|
||||
case NS_GROUP:
|
||||
if (CANT_HAPPEN(!(ef_flags(np->type) & EFF_GROUP)))
|
||||
return 0;
|
||||
return NULL;
|
||||
if (np->group != gp->group)
|
||||
selected = 0;
|
||||
break;
|
||||
default:
|
||||
CANT_REACH();
|
||||
return 0;
|
||||
return NULL;
|
||||
}
|
||||
if (selected && np->ncond) {
|
||||
/* nstr_exec is expensive, so we do it last */
|
||||
|
|
|
@ -99,7 +99,7 @@ do_plague(struct sctstr *sp, struct natstr *np, int etu)
|
|||
}
|
||||
}
|
||||
if (sp->sct_item[I_CIVIL] == 0 && sp->sct_item[I_MILIT] == 0
|
||||
&& !has_units(sp->sct_x, sp->sct_y, sp->sct_own, 0)) {
|
||||
&& !has_units(sp->sct_x, sp->sct_y, sp->sct_own, NULL)) {
|
||||
makelost(EF_SECTOR, sp->sct_own, 0, sp->sct_x, sp->sct_y);
|
||||
sp->sct_own = 0;
|
||||
sp->sct_oldown = 0;
|
||||
|
|
|
@ -52,7 +52,7 @@ populace(struct natstr *np, struct sctstr *sp, int etu)
|
|||
sp->sct_oldown = sp->sct_own;
|
||||
}
|
||||
if (!civ && !mil && !sp->sct_item[I_UW]
|
||||
&& !has_units(sp->sct_x, sp->sct_y, sp->sct_own, 0)) {
|
||||
&& !has_units(sp->sct_x, sp->sct_y, sp->sct_own, NULL)) {
|
||||
makelost(EF_SECTOR, sp->sct_own, 0, sp->sct_x, sp->sct_y);
|
||||
sp->sct_own = 0;
|
||||
sp->sct_oldown = 0;
|
||||
|
|
|
@ -352,7 +352,7 @@ guerrilla(struct sctstr *sp)
|
|||
}
|
||||
domove:
|
||||
if (move && che > 0) {
|
||||
struct sctstr *nicest_sp = 0;
|
||||
struct sctstr *nicest_sp = NULL;
|
||||
if (convert)
|
||||
min_mil = 999;
|
||||
else
|
||||
|
|
|
@ -299,7 +299,7 @@ void
|
|||
sail_ship(natid cn)
|
||||
{
|
||||
struct shpstr *sp;
|
||||
struct fltheadstr *head = 0;
|
||||
struct fltheadstr *head = NULL;
|
||||
struct fltheadstr *fltp;
|
||||
int n;
|
||||
|
||||
|
|
|
@ -297,7 +297,7 @@ produce_sect(int natnum, int etu, struct bp *bp, long p_sect[][2])
|
|||
* they all starved or were plagued off.
|
||||
*/
|
||||
if (vec[I_CIVIL] == 0 && vec[I_MILIT] == 0 &&
|
||||
!has_units(sp->sct_x, sp->sct_y, sp->sct_own, 0)) {
|
||||
!has_units(sp->sct_x, sp->sct_y, sp->sct_own, NULL)) {
|
||||
if (!player->simulation) {
|
||||
makelost(EF_SECTOR, sp->sct_own, 0, sp->sct_x, sp->sct_y);
|
||||
sp->sct_own = 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue