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
|
@ -288,6 +288,10 @@ Do not use increment operators to set a variable to logical true! It
|
|||
obfuscates the purpose, and narrow variables could even overflow.
|
||||
Just assign 1. A lot of cleanup remains to be done there.
|
||||
|
||||
Null pointer constant
|
||||
|
||||
Please use NULL for clarity, not just 0.
|
||||
|
||||
Type casts
|
||||
|
||||
Casting pointers to and from `void *' clutters the code and serves no
|
||||
|
|
|
@ -42,8 +42,8 @@
|
|||
#include <unistd.h>
|
||||
#include "misc.h"
|
||||
|
||||
static char *smso = 0;
|
||||
static char *rmso = 0;
|
||||
static char *smso;
|
||||
static char *rmso;
|
||||
|
||||
void
|
||||
getsose(void)
|
||||
|
|
|
@ -74,7 +74,7 @@ assa(void)
|
|||
return RET_SYN;
|
||||
if (!sarg_xy(p, &def->x, &def->y))
|
||||
return RET_SYN;
|
||||
if (att_abort(A_ASSAULT, 0, def))
|
||||
if (att_abort(A_ASSAULT, NULL, def))
|
||||
return RET_FAIL;
|
||||
|
||||
/*
|
||||
|
@ -110,7 +110,7 @@ assa(void)
|
|||
if (att_abort(A_ASSAULT, off, def)) {
|
||||
pr("Assault aborted\n");
|
||||
att_empty_attack(A_ASSAULT, 0, def);
|
||||
return att_free_lists(&olist, 0);
|
||||
return att_free_lists(&olist, NULL);
|
||||
}
|
||||
|
||||
/* If we're assaulting our own sector, end here */
|
||||
|
@ -127,7 +127,7 @@ assa(void)
|
|||
if (att_abort(A_ASSAULT, off, def)) {
|
||||
pr("Assault aborted\n");
|
||||
att_empty_attack(A_ASSAULT, 0, def);
|
||||
return att_free_lists(&olist, 0);
|
||||
return att_free_lists(&olist, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -73,7 +73,7 @@ atta(void)
|
|||
return RET_SYN;
|
||||
if (!sarg_xy(p, &def->x, &def->y))
|
||||
return RET_SYN;
|
||||
if (att_abort(A_ATTACK, 0, def))
|
||||
if (att_abort(A_ATTACK, NULL, def))
|
||||
return RET_FAIL;
|
||||
|
||||
/* Show what we're attacking, and check treaties */
|
||||
|
@ -84,7 +84,7 @@ atta(void)
|
|||
/* Ask about offensive support */
|
||||
|
||||
att_ask_support(2, &fort_sup, &ship_sup, &land_sup, &plane_sup);
|
||||
if (att_abort(A_ATTACK, 0, def)) {
|
||||
if (att_abort(A_ATTACK, NULL, def)) {
|
||||
att_empty_attack(A_ATTACK, 0, def);
|
||||
return RET_OK;
|
||||
}
|
||||
|
@ -110,14 +110,14 @@ atta(void)
|
|||
if (att_abort(A_ATTACK, off, def)) {
|
||||
pr("Attack aborted\n");
|
||||
att_empty_attack(A_ATTACK, 0, def);
|
||||
return att_free_lists(&olist, 0);
|
||||
return att_free_lists(&olist, NULL);
|
||||
}
|
||||
|
||||
ototal = att_get_offense(A_ATTACK, off, &olist, def);
|
||||
if (att_abort(A_ATTACK, off, def)) {
|
||||
pr("Attack aborted\n");
|
||||
att_empty_attack(A_ATTACK, 0, def);
|
||||
return att_free_lists(&olist, 0);
|
||||
return att_free_lists(&olist, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -136,14 +136,14 @@ boar(void)
|
|||
if (att_abort(A_BOARD, off, def)) {
|
||||
pr("Board aborted\n");
|
||||
att_empty_attack(A_BOARD, 0, def);
|
||||
return att_free_lists(&olist, 0);
|
||||
return att_free_lists(&olist, NULL);
|
||||
}
|
||||
|
||||
ototal = att_get_offense(A_BOARD, off, &olist, def);
|
||||
if (att_abort(A_BOARD, off, def)) {
|
||||
pr("Board aborted\n");
|
||||
att_empty_attack(A_BOARD, 0, def);
|
||||
return att_free_lists(&olist, 0);
|
||||
return att_free_lists(&olist, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -122,7 +122,7 @@ bomb(void)
|
|||
(void)pathtoxy(flightpath, &tx, &ty, fcost);
|
||||
pr("target sector is %s\n", xyas(tx, ty, player->cnum));
|
||||
getsect(tx, ty, &target);
|
||||
ip = 0;
|
||||
ip = NULL;
|
||||
ap_to_target = strlen(flightpath);
|
||||
if (flightpath[ap_to_target - 1] == 'h')
|
||||
ap_to_target--;
|
||||
|
|
|
@ -540,7 +540,7 @@ build_bridge(struct sctstr *sp, short *vec)
|
|||
|
||||
if ((val = chkdir(*p, DIR_FIRST, DIR_LAST)) < 0) {
|
||||
pr("'%c' is not a valid direction...\n", *p);
|
||||
direrr(0, 0, 0);
|
||||
direrr(NULL, NULL, NULL);
|
||||
return 0;
|
||||
}
|
||||
newx = sp->sct_x + diroff[val][0];
|
||||
|
@ -816,7 +816,7 @@ build_tower(struct sctstr *sp, short *vec)
|
|||
|
||||
if ((val = chkdir(*p, DIR_FIRST, DIR_LAST)) < 0) {
|
||||
pr("'%c' is not a valid direction...\n", *p);
|
||||
direrr(0, 0, 0);
|
||||
direrr(NULL, NULL, NULL);
|
||||
return 0;
|
||||
}
|
||||
newx = sp->sct_x + diroff[val][0];
|
||||
|
|
|
@ -70,7 +70,7 @@ coas(void)
|
|||
if (!snxtsct(&nstr, player->argp[1]))
|
||||
return RET_SYN;
|
||||
for (i = 0; i < TSIZE; i++)
|
||||
list[i] = 0;
|
||||
list[i] = NULL;
|
||||
cp = malloc(sizeof(*cp));
|
||||
snxtitem_all(&ni, EF_SHIP);
|
||||
while (nxtitem(&ni, &cp->c_shp)) {
|
||||
|
@ -139,18 +139,18 @@ static int
|
|||
showship(struct coast **cpp, int x, int y)
|
||||
{
|
||||
struct coast *cp;
|
||||
struct coast *todelete = 0;
|
||||
struct coast *todelete = NULL;
|
||||
struct coast **prev;
|
||||
int nship = 0;
|
||||
|
||||
prev = 0;
|
||||
prev = NULL;
|
||||
cp = *cpp;
|
||||
prev = cpp;
|
||||
do {
|
||||
/* we delete it, we free it. */
|
||||
if (todelete) {
|
||||
free(todelete);
|
||||
todelete = 0;
|
||||
todelete = NULL;
|
||||
}
|
||||
if (cp->c_shp.shp_x != x || cp->c_shp.shp_y != y) {
|
||||
prev = &(*prev)->c_next;
|
||||
|
|
|
@ -119,7 +119,7 @@ explore(void)
|
|||
pr("Only exploring with %d.\n", amount);
|
||||
}
|
||||
|
||||
if (!want_to_abandon(§, vtype, amount, 0)) {
|
||||
if (!want_to_abandon(§, vtype, amount, NULL)) {
|
||||
pr("Explore cancelled.\n");
|
||||
return RET_FAIL;
|
||||
}
|
||||
|
|
|
@ -124,7 +124,7 @@ sendmessage(struct natstr *us, struct natstr *to, char *message, int verbose)
|
|||
|
||||
time(&now);
|
||||
tm = localtime(&now);
|
||||
for (other = player_next(0); other != 0; other = player_next(other)) {
|
||||
for (other = player_next(NULL); other; other = player_next(other)) {
|
||||
if (other->state != PS_PLAYING)
|
||||
continue;
|
||||
if (to && other->cnum != to->nat_cnum)
|
||||
|
|
|
@ -107,14 +107,14 @@ lboa(void)
|
|||
if (att_abort(A_LBOARD, off, def)) {
|
||||
pr("Land unit boarding aborted\n");
|
||||
att_empty_attack(A_LBOARD, 0, def);
|
||||
return att_free_lists(&olist, 0);
|
||||
return att_free_lists(&olist, NULL);
|
||||
}
|
||||
|
||||
ototal = att_get_offense(A_LBOARD, off, &olist, def);
|
||||
if (att_abort(A_LBOARD, off, def)) {
|
||||
pr("Land unit boarding aborted\n");
|
||||
att_empty_attack(A_LBOARD, 0, def);
|
||||
return att_free_lists(&olist, 0);
|
||||
return att_free_lists(&olist, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -706,7 +706,7 @@ load_comm_ship(struct sctstr *sectp, struct shpstr *sp,
|
|||
load_unload, atoi(p));
|
||||
if (!load_comm_ok(sectp, sp->shp_own, item, move_amt))
|
||||
return RET_OK;
|
||||
if (!want_to_abandon(sectp, item, move_amt, 0))
|
||||
if (!want_to_abandon(sectp, item, move_amt, NULL))
|
||||
return RET_FAIL;
|
||||
if (!still_ok_ship(sectp, sp))
|
||||
return RET_SYN;
|
||||
|
|
|
@ -140,7 +140,7 @@ move(void)
|
|||
}
|
||||
}
|
||||
|
||||
if (!istest && !want_to_abandon(§, vtype, amount, 0)) {
|
||||
if (!istest && !want_to_abandon(§, vtype, amount, NULL)) {
|
||||
pr("Move cancelled.\n");
|
||||
return RET_FAIL;
|
||||
}
|
||||
|
|
|
@ -128,7 +128,7 @@ paradrop(struct emp_qelem *list, coord x, coord y)
|
|||
att_combat_init(def, EF_SECTOR);
|
||||
def->x = x;
|
||||
def->y = y;
|
||||
if (att_abort(A_PARA, 0, def))
|
||||
if (att_abort(A_PARA, NULL, def))
|
||||
return RET_FAIL;
|
||||
|
||||
/* Show what we're air-assaulting, and check treaties */
|
||||
|
|
|
@ -47,7 +47,7 @@ play(void)
|
|||
int saw = 0;
|
||||
|
||||
play_header();
|
||||
for (joe = player_prev(0); joe; joe = player_prev(joe)) {
|
||||
for (joe = player_prev(NULL); joe; joe = player_prev(joe)) {
|
||||
saw += play_list(joe);
|
||||
}
|
||||
if (player->god || opt_BLITZ)
|
||||
|
|
|
@ -97,12 +97,12 @@ reco(void)
|
|||
/*
|
||||
* now arm and equip the bombers, transports, whatever.
|
||||
*/
|
||||
pln_arm(&bomb_list, ap_to_target, 'r', 0, P_S | P_I);
|
||||
pln_arm(&bomb_list, ap_to_target, 'r', NULL, P_S | P_I);
|
||||
if (QEMPTY(&bomb_list)) {
|
||||
pr("No planes could be equipped for the mission.\n");
|
||||
return RET_FAIL;
|
||||
}
|
||||
pln_arm(&esc_list, ap_to_target, 'r', 0, P_F | P_ESC);
|
||||
pln_arm(&esc_list, ap_to_target, 'r', NULL, P_F | P_ESC);
|
||||
ac_encounter(&bomb_list, &esc_list, ax, ay, flightpath,
|
||||
*player->argp[0] == 's' ? PM_R | PM_S : PM_R);
|
||||
if (QEMPTY(&bomb_list)) {
|
||||
|
|
|
@ -68,7 +68,7 @@ skyw(void)
|
|||
if (!snxtsct(&nstr, player->argp[1]))
|
||||
return RET_SYN;
|
||||
for (i = 0; i < TSIZE; i++)
|
||||
list[i] = 0;
|
||||
list[i] = NULL;
|
||||
skyp = malloc(sizeof(*skyp));
|
||||
snxtitem_all(&ni, EF_PLANE);
|
||||
while (nxtitem(&ni, &skyp->s_sat)) {
|
||||
|
@ -131,20 +131,20 @@ static int
|
|||
showsat(struct sky **skypp, int x, int y)
|
||||
{
|
||||
struct sky *skyp;
|
||||
struct sky *todelete = 0;
|
||||
struct sky *todelete = NULL;
|
||||
struct sky **prev;
|
||||
struct plchrstr *pcp;
|
||||
char *name;
|
||||
int nsat = 0;
|
||||
|
||||
prev = 0;
|
||||
prev = NULL;
|
||||
skyp = *skypp;
|
||||
prev = skypp;
|
||||
do {
|
||||
/* we delete it, we free it. */
|
||||
if (todelete) {
|
||||
free(todelete);
|
||||
todelete = 0;
|
||||
todelete = NULL;
|
||||
}
|
||||
if (skyp->s_sat.pln_x != x || skyp->s_sat.pln_y != y) {
|
||||
prev = &(*prev)->s_next;
|
||||
|
|
|
@ -82,7 +82,7 @@ stre(void)
|
|||
pr("%7s", "");
|
||||
|
||||
if (def->sct_type != SCT_MOUNT)
|
||||
r_total = att_reacting_units(def, 0, 0, &dummy, 9999999);
|
||||
r_total = att_reacting_units(def, NULL, 0, &dummy, 9999999);
|
||||
else
|
||||
r_total = 0.0;
|
||||
def->own = 0;
|
||||
|
|
|
@ -154,7 +154,7 @@ keylookup(char *command, struct keymatch *tbl)
|
|||
struct keymatch *kp;
|
||||
|
||||
if (command == 0 || *command == 0)
|
||||
return 0;
|
||||
return NULL;
|
||||
for (kp = tbl; kp->km_key != 0; kp++) {
|
||||
if (strcmp(kp->km_key, command) == 0)
|
||||
return kp;
|
||||
|
|
|
@ -50,7 +50,7 @@ cname(natid n)
|
|||
struct natstr *np;
|
||||
|
||||
if ((np = getnatp(n)) == 0)
|
||||
return 0;
|
||||
return NULL;
|
||||
return np->nat_cnam;
|
||||
}
|
||||
|
||||
|
|
|
@ -185,7 +185,7 @@ bp_neighbors(struct as_coord c, struct as_coord *cp, void *pp)
|
|||
int n = 0, q;
|
||||
struct sctstr *sp, *from, **ssp;
|
||||
/* Six pointers, just in case our cache isn't there */
|
||||
struct sctstr *tsp[] = { 0, 0, 0, 0, 0, 0 };
|
||||
struct sctstr *tsp[] = { NULL, NULL, NULL, NULL, NULL, NULL };
|
||||
int sx, sy, offset;
|
||||
|
||||
x = c.x;
|
||||
|
|
|
@ -82,8 +82,8 @@ io_open(int fd, int flags, int bufsize, struct timeval timeout)
|
|||
if (!iop)
|
||||
return NULL;
|
||||
iop->fd = fd;
|
||||
iop->input = 0;
|
||||
iop->output = 0;
|
||||
iop->input = NULL;
|
||||
iop->output = NULL;
|
||||
iop->flags = 0;
|
||||
iop->input_timeout = timeout;
|
||||
iop->bufsize = bufsize;
|
||||
|
|
|
@ -65,7 +65,7 @@ empth_create(void (*entry)(void *), int size, int flags,
|
|||
{
|
||||
if (!flags)
|
||||
flags = empth_flags;
|
||||
return lwpCreate(1, entry, size, flags, name, 0, 0, ud);
|
||||
return lwpCreate(1, entry, size, flags, name, 0, NULL, ud);
|
||||
}
|
||||
|
||||
empth_t *
|
||||
|
|
|
@ -62,7 +62,7 @@ ioq_create(int size)
|
|||
ioq->list.nbytes = 0;
|
||||
ioq->list.offset = 0;
|
||||
ioq->list.size = 0;
|
||||
ioq->list.data = 0;
|
||||
ioq->list.data = NULL;
|
||||
ioq->bufsize = size;
|
||||
ioq->cc = 0;
|
||||
return ioq;
|
||||
|
|
|
@ -98,7 +98,7 @@ lwpReschedule(void)
|
|||
} else {
|
||||
lwpDestroy(nextp);
|
||||
}
|
||||
nextp = 0;
|
||||
nextp = NULL;
|
||||
}
|
||||
if (nextp)
|
||||
break;
|
||||
|
@ -315,18 +315,19 @@ lwpInitSystem(int pri, void **ctxptr, int flags, sigset_t *waitset)
|
|||
pri = LWP_MAX_PRIO - 1;
|
||||
if (LwpMaxpri < pri)
|
||||
LwpMaxpri = pri;
|
||||
LwpCurrent->next = 0;
|
||||
LwpCurrent->next = NULL;
|
||||
LwpCurrent->sbtm = stack; /* dummy stack for "main" */
|
||||
LwpCurrent->pri = pri;
|
||||
LwpCurrent->dead = 0;
|
||||
LwpCurrent->flags = flags & ~LWP_STACKCHECK;
|
||||
LwpCurrent->name = "Main";
|
||||
for (i = LWP_MAX_PRIO, q = LwpSchedQ; i--; q++)
|
||||
q->head = q->tail = 0;
|
||||
LwpDeadQ.head = LwpDeadQ.tail = 0;
|
||||
q->head = q->tail = NULL;
|
||||
LwpDeadQ.head = LwpDeadQ.tail = NULL;
|
||||
lwpInitSigWait(waitset);
|
||||
/* must be lower in priority than us for this to work right */
|
||||
sel = lwpCreate(0, lwpSelect, 16384, flags, "EventHandler", 0, 0, 0);
|
||||
sel = lwpCreate(0, lwpSelect, 16384, flags, "EventHandler", 0,
|
||||
NULL, NULL);
|
||||
lwpInitSelect(sel);
|
||||
return LwpCurrent;
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
|
||||
#include <config.h>
|
||||
|
||||
#include <stddef.h>
|
||||
#include "lwp.h"
|
||||
#include "lwpint.h"
|
||||
|
||||
|
@ -43,7 +44,7 @@ lwpGetFirst(struct lwpQueue *q)
|
|||
struct lwpProc *head;
|
||||
|
||||
if ((head = q->head) && !(q->head = head->next))
|
||||
q->tail = 0;
|
||||
q->tail = NULL;
|
||||
return head;
|
||||
}
|
||||
|
||||
|
@ -55,5 +56,5 @@ lwpAddTail(struct lwpQueue *q, struct lwpProc *p)
|
|||
else
|
||||
q->tail->next = p;
|
||||
q->tail = p;
|
||||
p->next = 0;
|
||||
p->next = NULL;
|
||||
}
|
||||
|
|
|
@ -73,8 +73,8 @@ lwpInitSelect(struct lwpProc *proc)
|
|||
FD_ZERO(&LwpReadfds);
|
||||
FD_ZERO(&LwpWritefds);
|
||||
LwpFdwait = calloc(FD_SETSIZE, sizeof(struct lwpProc *));
|
||||
LwpDelayq.head = 0;
|
||||
LwpDelayq.tail = 0;
|
||||
LwpDelayq.head = NULL;
|
||||
LwpDelayq.tail = NULL;
|
||||
LwpSelProc = proc;
|
||||
}
|
||||
|
||||
|
@ -141,7 +141,7 @@ lwpWakeupFd(struct lwpProc *proc)
|
|||
FD_CLR(proc->fd, &LwpReadfds);
|
||||
FD_CLR(proc->fd, &LwpWritefds);
|
||||
LwpNfds--;
|
||||
LwpFdwait[proc->fd] = 0;
|
||||
LwpFdwait[proc->fd] = NULL;
|
||||
proc->fd = -1;
|
||||
lwpReady(proc);
|
||||
}
|
||||
|
@ -158,7 +158,7 @@ lwpWakeupSleep(void)
|
|||
|
||||
if (LwpDelayq.head) {
|
||||
now = time(NULL);
|
||||
save.tail = save.head = 0;
|
||||
save.tail = save.head = NULL;
|
||||
while (NULL != (proc = lwpGetFirst(&LwpDelayq))) {
|
||||
if (now >= proc->runtime) {
|
||||
lwpStatus(proc, "sleep done");
|
||||
|
|
|
@ -51,8 +51,8 @@ lwpStatus(struct lwpProc *proc, char *format, ...)
|
|||
va_start(ap, format);
|
||||
if (proc->flags & LWP_PRINT) {
|
||||
if (startTime.tv_sec == 0)
|
||||
gettimeofday(&startTime, 0);
|
||||
gettimeofday(&tv, 0);
|
||||
gettimeofday(&startTime, NULL);
|
||||
gettimeofday(&tv, NULL);
|
||||
sec = tv.tv_sec - startTime.tv_sec;
|
||||
msec = (tv.tv_usec - startTime.tv_usec) / 1000;
|
||||
if (msec < 0) {
|
||||
|
|
|
@ -107,7 +107,7 @@ player_delete(struct player *lp)
|
|||
if (lp->iop) {
|
||||
/* it's a real player */
|
||||
io_close(lp->iop);
|
||||
lp->iop = 0;
|
||||
lp->iop = NULL;
|
||||
}
|
||||
free(lp);
|
||||
/* XXX may need to free bigmap here */
|
||||
|
@ -122,7 +122,7 @@ player_next(struct player *lp)
|
|||
else
|
||||
lp = (struct player *)lp->queue.q_forw;
|
||||
if (&lp->queue == &Players)
|
||||
return 0;
|
||||
return NULL;
|
||||
return lp;
|
||||
}
|
||||
|
||||
|
@ -134,7 +134,7 @@ player_prev(struct player *lp)
|
|||
else
|
||||
lp = (struct player *)lp->queue.q_back;
|
||||
if (&lp->queue == &Players)
|
||||
return 0;
|
||||
return NULL;
|
||||
return lp;
|
||||
}
|
||||
|
||||
|
|
|
@ -279,5 +279,5 @@ struct cmndstr player_coms[] = {
|
|||
{"work <LAND UNITS> <AMOUNT>", 1, work, C_MOD, NORM + MONEY + CAP},
|
||||
{"xdump [\"meta\"] <TYPE> [<RECORDS>]", 0, xdump, 0, VIS},
|
||||
{"zdone <y|n|c>", 0, zdon, C_MOD, NORM},
|
||||
{0, 0, 0, 0, 0}
|
||||
{NULL, 0, NULL, 0, 0}
|
||||
};
|
||||
|
|
|
@ -69,7 +69,7 @@ static struct cmndstr login_coms[] = {
|
|||
{"quit", 0, quit_cmd, 0, 0},
|
||||
{"sanc", 0, sanc_cmd, 0, 0},
|
||||
{"user name", 0, user_cmd, 0, 0},
|
||||
{0, 0, 0, 0, 0}
|
||||
{NULL, 0, NULL, 0, 0}
|
||||
};
|
||||
|
||||
/*ARGSUSED*/
|
||||
|
|
|
@ -295,7 +295,7 @@ sam_intercept(struct emp_qelem *att_list, struct emp_qelem *def_list,
|
|||
&& pp->pln_radius < mapdist(x, y, pp->pln_opx, pp->pln_opy))
|
||||
continue;
|
||||
if (CANT_HAPPEN(pp->pln_flags & PLN_LAUNCHED)
|
||||
|| mission_pln_equip(dplp, 0, P_F, 0) < 0) {
|
||||
|| mission_pln_equip(dplp, NULL, P_F, 0) < 0) {
|
||||
emp_remque(dqp);
|
||||
free(dqp);
|
||||
continue;
|
||||
|
@ -369,7 +369,7 @@ ac_intercept(struct emp_qelem *bomb_list, struct emp_qelem *esc_list,
|
|||
&& pp->pln_radius < mapdist(x, y, pp->pln_opx, pp->pln_opy))
|
||||
continue;
|
||||
if (CANT_HAPPEN(pp->pln_flags & PLN_LAUNCHED)
|
||||
|| mission_pln_equip(plp, 0, P_F, 0) < 0) {
|
||||
|| mission_pln_equip(plp, NULL, P_F, 0) < 0) {
|
||||
emp_remque(qp);
|
||||
free(qp);
|
||||
continue;
|
||||
|
|
|
@ -912,7 +912,7 @@ ask_off(int combat_mode, struct combat *off, struct combat *def)
|
|||
sprintf(prompt, "Number of mil from %s (max %d) : ",
|
||||
prcom(0, off), mob_support);
|
||||
}
|
||||
if ((attacking_mil = onearg(0, prompt)) < 0)
|
||||
if ((attacking_mil = onearg(NULL, prompt)) < 0)
|
||||
abort_attack();
|
||||
if (att_abort(combat_mode, off, def))
|
||||
return 0;
|
||||
|
@ -1271,7 +1271,8 @@ get_ototal(int combat_mode, struct combat *off, struct emp_qelem *olist,
|
|||
for (qp = olist->q_forw; qp != olist; qp = next) {
|
||||
next = qp->q_forw;
|
||||
llp = (struct ulist *)qp;
|
||||
if (check && !get_land(combat_mode, 0, llp->unit.land.lnd_uid, llp, 0))
|
||||
if (check &&
|
||||
!get_land(combat_mode, NULL, llp->unit.land.lnd_uid, llp, 0))
|
||||
continue;
|
||||
if (combat_mode == A_ATTACK) {
|
||||
w = -1;
|
||||
|
@ -1448,7 +1449,7 @@ put_land(struct emp_qelem *list)
|
|||
emp_remque((struct emp_qelem *)llp);
|
||||
free(llp);
|
||||
} else
|
||||
get_land(A_ATTACK, 0, llp->unit.land.lnd_uid, llp, 0);
|
||||
get_land(A_ATTACK, NULL, llp->unit.land.lnd_uid, llp, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2181,7 +2182,7 @@ take_def(int combat_mode, struct emp_qelem *list, struct combat *off,
|
|||
{
|
||||
int n;
|
||||
int occuppied = 0;
|
||||
struct ulist *llp, *delete_me = 0;
|
||||
struct ulist *llp, *delete_me = NULL;
|
||||
char buf[1024];
|
||||
struct sctstr sect;
|
||||
struct shpstr ship;
|
||||
|
|
|
@ -48,7 +48,7 @@ getstarg(char *input, char *prompt, char *buf)
|
|||
*buf = '\0';
|
||||
if (input == 0 || *input == 0) {
|
||||
if (getstring(prompt, buf) == 0)
|
||||
return 0;
|
||||
return NULL;
|
||||
} else {
|
||||
strcpy(buf, input);
|
||||
}
|
||||
|
|
|
@ -254,7 +254,7 @@ adj_units(coord x, coord y, natid own)
|
|||
|
||||
for (i = DIR_FIRST; i <= DIR_LAST; i++) {
|
||||
getsect(x + diroff[i][0], y + diroff[i][1], §);
|
||||
if (has_units(sect.sct_x, sect.sct_y, own, 0))
|
||||
if (has_units(sect.sct_x, sect.sct_y, own, NULL))
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
|
|
|
@ -989,7 +989,7 @@ lnd_mar_one_sector(struct emp_qelem *list, int dir, natid actor,
|
|||
pr("%s was shot and killed.\n", prland(&llp->unit.land));
|
||||
llp->unit.land.lnd_effic = 0;
|
||||
putland(llp->unit.land.lnd_uid, &llp->unit.land);
|
||||
lnd_delete(llp, 0);
|
||||
lnd_delete(llp, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -610,12 +610,12 @@ perform_mission(coord x, coord y, natid victim, struct emp_qelem *list,
|
|||
/* Split off the escorts at this base into e */
|
||||
divide(&escorts, &e, air->x, air->y);
|
||||
|
||||
mission_pln_arm(&b, air->x, air->y, 2 * md, 'p', 0, 0);
|
||||
mission_pln_arm(&b, air->x, air->y, 2 * md, 'p', NULL, 0);
|
||||
|
||||
if (QEMPTY(&b))
|
||||
continue;
|
||||
|
||||
mission_pln_arm(&e, air->x, air->y, 2 * md, 'p', 0, P_F | P_ESC);
|
||||
mission_pln_arm(&e, air->x, air->y, 2 * md, 'p', NULL, P_F | P_ESC);
|
||||
|
||||
pp = BestAirPath(buf, air->x, air->y, x, y);
|
||||
if (CANT_HAPPEN(!pp))
|
||||
|
|
|
@ -61,7 +61,7 @@ msl_equip(struct plnstr *pp, char mission)
|
|||
memset(&pl, 0, sizeof(struct plist));
|
||||
pl.pcp = plchr + pp->pln_type;
|
||||
pl.plane = *pp;
|
||||
return mission_pln_equip(&pl, 0, 0, mission);
|
||||
return mission_pln_equip(&pl, NULL, 0, mission);
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -271,7 +271,7 @@ msl_intercept(coord x, coord y, natid bombown, int hardtarget,
|
|||
if (pp->pln_own != sect.sct_own)
|
||||
continue;
|
||||
pcp = ip->pcp;
|
||||
if (mission_pln_equip(ip, 0, 0, 'i') < 0) {
|
||||
if (mission_pln_equip(ip, NULL, 0, 'i') < 0) {
|
||||
emp_remque(qp);
|
||||
free(qp);
|
||||
continue;
|
||||
|
@ -290,7 +290,7 @@ msl_intercept(coord x, coord y, natid bombown, int hardtarget,
|
|||
ip = (struct plist *)qp;
|
||||
pp = &ip->plane;
|
||||
pcp = ip->pcp;
|
||||
if (mission_pln_equip(ip, 0, 0, 'i') < 0) {
|
||||
if (mission_pln_equip(ip, NULL, 0, 'i') < 0) {
|
||||
emp_remque(qp);
|
||||
free(qp);
|
||||
continue;
|
||||
|
@ -401,7 +401,7 @@ msl_launch_mindam(struct emp_qelem *list, coord x, coord y, int hardtarget,
|
|||
next = qp->q_back;
|
||||
plp = (struct plist *)qp;
|
||||
|
||||
if (mission_pln_equip(plp, 0, 0, 'p') >= 0) {
|
||||
if (mission_pln_equip(plp, NULL, 0, 'p') >= 0) {
|
||||
if (msl_hit(&plp->plane,
|
||||
hardtarget, type, news_item, snews_item,
|
||||
whatp, x, y, victim)) {
|
||||
|
|
|
@ -201,7 +201,7 @@ pr_wall(char *format, ...)
|
|||
va_start(ap, format);
|
||||
(void)vsprintf(buf + n, format, ap);
|
||||
va_end(ap);
|
||||
for (p = player_next(0); p; p = player_next(p)) {
|
||||
for (p = player_next(NULL); p; p = player_next(p)) {
|
||||
if (p->state != PS_PLAYING)
|
||||
continue;
|
||||
pr_player(p, C_FLASH, buf);
|
||||
|
|
|
@ -52,7 +52,7 @@ setrel(natid us, natid them, int rel)
|
|||
char *whichway;
|
||||
int n_up = 0;
|
||||
int n_down = 0;
|
||||
char *addendum = 0;
|
||||
char *addendum = NULL;
|
||||
int theirrel;
|
||||
|
||||
if (rel < AT_WAR)
|
||||
|
|
|
@ -423,7 +423,7 @@ most_valuable_ship(struct emp_qelem *list)
|
|||
struct emp_qelem *qp;
|
||||
struct emp_qelem *next;
|
||||
struct ulist *mlp;
|
||||
struct ulist *mvs = 0;
|
||||
struct ulist *mvs = NULL;
|
||||
|
||||
for (qp = list->q_back; qp != list; qp = next) {
|
||||
next = qp->q_back;
|
||||
|
|
|
@ -147,14 +147,14 @@ unit_path(int together, struct empobj *unit, char *buf)
|
|||
return NULL;
|
||||
|
||||
if (!sarg_xy(buf, &destx, &desty))
|
||||
return 0;
|
||||
return NULL;
|
||||
if (!together) {
|
||||
pr("Cannot go to a destination sector if not all starting in the same sector\n");
|
||||
return 0;
|
||||
return NULL;
|
||||
}
|
||||
if (!getsect(destx, desty, &d_sect)) {
|
||||
pr("%d,%d is not a sector\n", destx, desty);
|
||||
return 0;
|
||||
return NULL;
|
||||
}
|
||||
if (unit->ef_type == EF_SHIP) {
|
||||
cp = BestShipPath(buf, unit->x, unit->y,
|
||||
|
@ -162,7 +162,7 @@ unit_path(int together, struct empobj *unit, char *buf)
|
|||
if (!cp || unit->mobil <= 0) {
|
||||
pr("Can't get to '%s' right now.\n",
|
||||
xyas(d_sect.sct_x, d_sect.sct_y, player->cnum));
|
||||
return 0;
|
||||
return NULL;
|
||||
}
|
||||
} else {
|
||||
getsect(unit->x, unit->y, §);
|
||||
|
@ -173,7 +173,7 @@ unit_path(int together, struct empobj *unit, char *buf)
|
|||
mtype == MOB_RAIL ? "railway" : "path",
|
||||
xyas(unit->x, unit->y, player->cnum),
|
||||
xyas(d_sect.sct_x, d_sect.sct_y, player->cnum));
|
||||
return 0;
|
||||
return NULL;
|
||||
}
|
||||
pr("Using path '%s'\n", cp);
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ whatitem(char *input, char *prompt)
|
|||
|
||||
p = getstarg(input, prompt, buf);
|
||||
if (p == 0 || *p == 0)
|
||||
return 0;
|
||||
return NULL;
|
||||
ip = item_by_name(p);
|
||||
if (!ip)
|
||||
pr("Unrecognized item \"%c\"\n", *p);
|
||||
|
@ -69,5 +69,5 @@ item_by_name(char *str)
|
|||
if (*str == ip->i_mnem)
|
||||
return ip;
|
||||
}
|
||||
return 0;
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -382,7 +382,7 @@ start_server(int flags)
|
|||
if (journal_startup() < 0)
|
||||
exit(1);
|
||||
|
||||
empth_create(player_accept, 50 * 1024, flags, "AcceptPlayers", 0);
|
||||
empth_create(player_accept, 50 * 1024, flags, "AcceptPlayers", NULL);
|
||||
|
||||
market_init();
|
||||
update_init();
|
||||
|
@ -422,7 +422,7 @@ shutdwn(int sig)
|
|||
logerror("Shutdown commencing (cleaning up threads.)");
|
||||
|
||||
play_wrlock_wanted = 1;
|
||||
for (p = player_next(0); p != 0; p = player_next(p)) {
|
||||
for (p = player_next(NULL); p != 0; p = player_next(p)) {
|
||||
if (p->state != PS_PLAYING)
|
||||
continue;
|
||||
pr_flash(p, "Server shutting down...\n");
|
||||
|
|
|
@ -194,7 +194,7 @@ update_run(void)
|
|||
struct player *p;
|
||||
|
||||
play_wrlock_wanted = 1;
|
||||
for (p = player_next(0); p != 0; p = player_next(p)) {
|
||||
for (p = player_next(NULL); p != 0; p = player_next(p)) {
|
||||
if (p->state != PS_PLAYING)
|
||||
continue;
|
||||
if (p->command) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue