Use NULL instead of 0, for clarity. Except in pointer comparisons;
leave that to the next two commits.
51 files changed:
obfuscates the purpose, and narrow variables could even overflow.
Just assign 1. A lot of cleanup remains to be done there.
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
Type casts
Casting pointers to and from `void *' clutters the code and serves no
#include <unistd.h>
#include "misc.h"
#include <unistd.h>
#include "misc.h"
-static char *smso = 0;
-static char *rmso = 0;
+static char *smso;
+static char *rmso;
return RET_SYN;
if (!sarg_xy(p, &def->x, &def->y))
return RET_SYN;
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))
if (att_abort(A_ASSAULT, off, def)) {
pr("Assault aborted\n");
att_empty_attack(A_ASSAULT, 0, def);
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 */
}
/* If we're assaulting our own sector, end here */
if (att_abort(A_ASSAULT, off, def)) {
pr("Assault aborted\n");
att_empty_attack(A_ASSAULT, 0, def);
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);
return RET_SYN;
if (!sarg_xy(p, &def->x, &def->y))
return RET_SYN;
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 */
return RET_FAIL;
/* Show what we're attacking, and check treaties */
/* Ask about offensive support */
att_ask_support(2, &fort_sup, &ship_sup, &land_sup, &plane_sup);
/* 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;
}
att_empty_attack(A_ATTACK, 0, def);
return RET_OK;
}
if (att_abort(A_ATTACK, off, def)) {
pr("Attack aborted\n");
att_empty_attack(A_ATTACK, 0, 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);
}
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);
}
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);
if (att_abort(A_BOARD, off, def)) {
pr("Board aborted\n");
att_empty_attack(A_BOARD, 0, 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);
}
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);
}
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);
(void)pathtoxy(flightpath, &tx, &ty, fcost);
pr("target sector is %s\n", xyas(tx, ty, player->cnum));
getsect(tx, ty, &target);
(void)pathtoxy(flightpath, &tx, &ty, fcost);
pr("target sector is %s\n", xyas(tx, ty, player->cnum));
getsect(tx, ty, &target);
ap_to_target = strlen(flightpath);
if (flightpath[ap_to_target - 1] == 'h')
ap_to_target--;
ap_to_target = strlen(flightpath);
if (flightpath[ap_to_target - 1] == 'h')
ap_to_target--;
if ((val = chkdir(*p, DIR_FIRST, DIR_LAST)) < 0) {
pr("'%c' is not a valid direction...\n", *p);
if ((val = chkdir(*p, DIR_FIRST, DIR_LAST)) < 0) {
pr("'%c' is not a valid direction...\n", *p);
+ direrr(NULL, NULL, NULL);
return 0;
}
newx = sp->sct_x + diroff[val][0];
return 0;
}
newx = sp->sct_x + diroff[val][0];
if ((val = chkdir(*p, DIR_FIRST, DIR_LAST)) < 0) {
pr("'%c' is not a valid direction...\n", *p);
if ((val = chkdir(*p, DIR_FIRST, DIR_LAST)) < 0) {
pr("'%c' is not a valid direction...\n", *p);
+ direrr(NULL, NULL, NULL);
return 0;
}
newx = sp->sct_x + diroff[val][0];
return 0;
}
newx = sp->sct_x + diroff[val][0];
if (!snxtsct(&nstr, player->argp[1]))
return RET_SYN;
for (i = 0; i < TSIZE; i++)
if (!snxtsct(&nstr, player->argp[1]))
return RET_SYN;
for (i = 0; i < TSIZE; i++)
cp = malloc(sizeof(*cp));
snxtitem_all(&ni, EF_SHIP);
while (nxtitem(&ni, &cp->c_shp)) {
cp = malloc(sizeof(*cp));
snxtitem_all(&ni, EF_SHIP);
while (nxtitem(&ni, &cp->c_shp)) {
showship(struct coast **cpp, int x, int y)
{
struct coast *cp;
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;
struct coast **prev;
int nship = 0;
cp = *cpp;
prev = cpp;
do {
/* we delete it, we free it. */
if (todelete) {
free(todelete);
cp = *cpp;
prev = cpp;
do {
/* we delete it, we free it. */
if (todelete) {
free(todelete);
}
if (cp->c_shp.shp_x != x || cp->c_shp.shp_y != y) {
prev = &(*prev)->c_next;
}
if (cp->c_shp.shp_x != x || cp->c_shp.shp_y != y) {
prev = &(*prev)->c_next;
pr("Only exploring with %d.\n", amount);
}
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;
}
pr("Explore cancelled.\n");
return RET_FAIL;
}
time(&now);
tm = localtime(&now);
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)
if (other->state != PS_PLAYING)
continue;
if (to && other->cnum != to->nat_cnum)
if (att_abort(A_LBOARD, off, def)) {
pr("Land unit boarding aborted\n");
att_empty_attack(A_LBOARD, 0, 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);
}
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);
}
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);
load_unload, atoi(p));
if (!load_comm_ok(sectp, sp->shp_own, item, move_amt))
return RET_OK;
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;
return RET_FAIL;
if (!still_ok_ship(sectp, sp))
return RET_SYN;
- if (!istest && !want_to_abandon(§, vtype, amount, 0)) {
+ if (!istest && !want_to_abandon(§, vtype, amount, NULL)) {
pr("Move cancelled.\n");
return RET_FAIL;
}
pr("Move cancelled.\n");
return RET_FAIL;
}
att_combat_init(def, EF_SECTOR);
def->x = x;
def->y = 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 */
return RET_FAIL;
/* Show what we're air-assaulting, and check treaties */
int saw = 0;
play_header();
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)
saw += play_list(joe);
}
if (player->god || opt_BLITZ)
/*
* now arm and equip the bombers, transports, whatever.
*/
/*
* 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;
}
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)) {
ac_encounter(&bomb_list, &esc_list, ax, ay, flightpath,
*player->argp[0] == 's' ? PM_R | PM_S : PM_R);
if (QEMPTY(&bomb_list)) {
if (!snxtsct(&nstr, player->argp[1]))
return RET_SYN;
for (i = 0; i < TSIZE; i++)
if (!snxtsct(&nstr, player->argp[1]))
return RET_SYN;
for (i = 0; i < TSIZE; i++)
skyp = malloc(sizeof(*skyp));
snxtitem_all(&ni, EF_PLANE);
while (nxtitem(&ni, &skyp->s_sat)) {
skyp = malloc(sizeof(*skyp));
snxtitem_all(&ni, EF_PLANE);
while (nxtitem(&ni, &skyp->s_sat)) {
showsat(struct sky **skypp, int x, int y)
{
struct sky *skyp;
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;
struct sky **prev;
struct plchrstr *pcp;
char *name;
int nsat = 0;
skyp = *skypp;
prev = skypp;
do {
/* we delete it, we free it. */
if (todelete) {
free(todelete);
skyp = *skypp;
prev = skypp;
do {
/* we delete it, we free it. */
if (todelete) {
free(todelete);
}
if (skyp->s_sat.pln_x != x || skyp->s_sat.pln_y != y) {
prev = &(*prev)->s_next;
}
if (skyp->s_sat.pln_x != x || skyp->s_sat.pln_y != y) {
prev = &(*prev)->s_next;
pr("%7s", "");
if (def->sct_type != SCT_MOUNT)
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;
else
r_total = 0.0;
def->own = 0;
struct keymatch *kp;
if (command == 0 || *command == 0)
struct keymatch *kp;
if (command == 0 || *command == 0)
for (kp = tbl; kp->km_key != 0; kp++) {
if (strcmp(kp->km_key, command) == 0)
return kp;
for (kp = tbl; kp->km_key != 0; kp++) {
if (strcmp(kp->km_key, command) == 0)
return kp;
struct natstr *np;
if ((np = getnatp(n)) == 0)
struct natstr *np;
if ((np = getnatp(n)) == 0)
int n = 0, q;
struct sctstr *sp, *from, **ssp;
/* Six pointers, just in case our cache isn't there */
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;
int sx, sy, offset;
x = c.x;
if (!iop)
return NULL;
iop->fd = fd;
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;
iop->flags = 0;
iop->input_timeout = timeout;
iop->bufsize = bufsize;
{
if (!flags)
flags = empth_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);
ioq->list.nbytes = 0;
ioq->list.offset = 0;
ioq->list.size = 0;
ioq->list.nbytes = 0;
ioq->list.offset = 0;
ioq->list.size = 0;
ioq->bufsize = size;
ioq->cc = 0;
return ioq;
ioq->bufsize = size;
ioq->cc = 0;
return ioq;
} else {
lwpDestroy(nextp);
}
} else {
lwpDestroy(nextp);
}
pri = LWP_MAX_PRIO - 1;
if (LwpMaxpri < pri)
LwpMaxpri = pri;
pri = LWP_MAX_PRIO - 1;
if (LwpMaxpri < pri)
LwpMaxpri = pri;
+ 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++)
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 */
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;
}
lwpInitSelect(sel);
return LwpCurrent;
}
#include "lwp.h"
#include "lwpint.h"
#include "lwp.h"
#include "lwpint.h"
struct lwpProc *head;
if ((head = q->head) && !(q->head = head->next))
struct lwpProc *head;
if ((head = q->head) && !(q->head = head->next))
else
q->tail->next = p;
q->tail = p;
else
q->tail->next = p;
q->tail = p;
FD_ZERO(&LwpReadfds);
FD_ZERO(&LwpWritefds);
LwpFdwait = calloc(FD_SETSIZE, sizeof(struct lwpProc *));
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;
FD_CLR(proc->fd, &LwpReadfds);
FD_CLR(proc->fd, &LwpWritefds);
LwpNfds--;
FD_CLR(proc->fd, &LwpReadfds);
FD_CLR(proc->fd, &LwpWritefds);
LwpNfds--;
- LwpFdwait[proc->fd] = 0;
+ LwpFdwait[proc->fd] = NULL;
proc->fd = -1;
lwpReady(proc);
}
proc->fd = -1;
lwpReady(proc);
}
if (LwpDelayq.head) {
now = time(NULL);
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");
while (NULL != (proc = lwpGetFirst(&LwpDelayq))) {
if (now >= proc->runtime) {
lwpStatus(proc, "sleep done");
va_start(ap, format);
if (proc->flags & LWP_PRINT) {
if (startTime.tv_sec == 0)
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) {
sec = tv.tv_sec - startTime.tv_sec;
msec = (tv.tv_usec - startTime.tv_usec) / 1000;
if (msec < 0) {
if (lp->iop) {
/* it's a real player */
io_close(lp->iop);
if (lp->iop) {
/* it's a real player */
io_close(lp->iop);
}
free(lp);
/* XXX may need to free bigmap here */
}
free(lp);
/* XXX may need to free bigmap here */
else
lp = (struct player *)lp->queue.q_forw;
if (&lp->queue == &Players)
else
lp = (struct player *)lp->queue.q_forw;
if (&lp->queue == &Players)
else
lp = (struct player *)lp->queue.q_back;
if (&lp->queue == &Players)
else
lp = (struct player *)lp->queue.q_back;
if (&lp->queue == &Players)
{"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},
{"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},
{"quit", 0, quit_cmd, 0, 0},
{"sanc", 0, sanc_cmd, 0, 0},
{"user name", 0, user_cmd, 0, 0},
{"quit", 0, quit_cmd, 0, 0},
{"sanc", 0, sanc_cmd, 0, 0},
{"user name", 0, user_cmd, 0, 0},
&& pp->pln_radius < mapdist(x, y, pp->pln_opx, pp->pln_opy))
continue;
if (CANT_HAPPEN(pp->pln_flags & PLN_LAUNCHED)
&& 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;
emp_remque(dqp);
free(dqp);
continue;
&& pp->pln_radius < mapdist(x, y, pp->pln_opx, pp->pln_opy))
continue;
if (CANT_HAPPEN(pp->pln_flags & PLN_LAUNCHED)
&& 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;
emp_remque(qp);
free(qp);
continue;
sprintf(prompt, "Number of mil from %s (max %d) : ",
prcom(0, off), mob_support);
}
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;
abort_attack();
if (att_abort(combat_mode, off, def))
return 0;
for (qp = olist->q_forw; qp != olist; qp = next) {
next = qp->q_forw;
llp = (struct ulist *)qp;
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;
continue;
if (combat_mode == A_ATTACK) {
w = -1;
emp_remque((struct emp_qelem *)llp);
free(llp);
} else
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);
{
int n;
int occuppied = 0;
{
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;
char buf[1024];
struct sctstr sect;
struct shpstr ship;
*buf = '\0';
if (input == 0 || *input == 0) {
if (getstring(prompt, buf) == 0)
*buf = '\0';
if (input == 0 || *input == 0) {
if (getstring(prompt, buf) == 0)
} else {
strcpy(buf, input);
}
} else {
strcpy(buf, input);
}
for (i = DIR_FIRST; i <= DIR_LAST; i++) {
getsect(x + diroff[i][0], y + diroff[i][1], §);
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))
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);
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);
/* Split off the escorts at this base into e */
divide(&escorts, &e, air->x, air->y);
/* 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;
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))
pp = BestAirPath(buf, air->x, air->y, x, y);
if (CANT_HAPPEN(!pp))
memset(&pl, 0, sizeof(struct plist));
pl.pcp = plchr + pp->pln_type;
pl.plane = *pp;
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);
if (pp->pln_own != sect.sct_own)
continue;
pcp = ip->pcp;
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;
emp_remque(qp);
free(qp);
continue;
ip = (struct plist *)qp;
pp = &ip->plane;
pcp = ip->pcp;
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;
emp_remque(qp);
free(qp);
continue;
next = qp->q_back;
plp = (struct plist *)qp;
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)) {
if (msl_hit(&plp->plane,
hardtarget, type, news_item, snews_item,
whatp, x, y, victim)) {
va_start(ap, format);
(void)vsprintf(buf + n, format, ap);
va_end(ap);
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);
if (p->state != PS_PLAYING)
continue;
pr_player(p, C_FLASH, buf);
char *whichway;
int n_up = 0;
int n_down = 0;
char *whichway;
int n_up = 0;
int n_down = 0;
int theirrel;
if (rel < AT_WAR)
int theirrel;
if (rel < AT_WAR)
struct emp_qelem *qp;
struct emp_qelem *next;
struct ulist *mlp;
struct emp_qelem *qp;
struct emp_qelem *next;
struct ulist *mlp;
+ struct ulist *mvs = NULL;
for (qp = list->q_back; qp != list; qp = next) {
next = qp->q_back;
for (qp = list->q_back; qp != list; qp = next) {
next = qp->q_back;
return NULL;
if (!sarg_xy(buf, &destx, &desty))
return NULL;
if (!sarg_xy(buf, &destx, &desty))
if (!together) {
pr("Cannot go to a destination sector if not all starting in the same sector\n");
if (!together) {
pr("Cannot go to a destination sector if not all starting in the same sector\n");
}
if (!getsect(destx, desty, &d_sect)) {
pr("%d,%d is not a sector\n", destx, desty);
}
if (!getsect(destx, desty, &d_sect)) {
pr("%d,%d is not a sector\n", destx, desty);
}
if (unit->ef_type == EF_SHIP) {
cp = BestShipPath(buf, unit->x, unit->y,
}
if (unit->ef_type == EF_SHIP) {
cp = BestShipPath(buf, unit->x, unit->y,
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));
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));
}
} else {
getsect(unit->x, unit->y, §);
}
} else {
getsect(unit->x, unit->y, §);
mtype == MOB_RAIL ? "railway" : "path",
xyas(unit->x, unit->y, player->cnum),
xyas(d_sect.sct_x, d_sect.sct_y, player->cnum));
mtype == MOB_RAIL ? "railway" : "path",
xyas(unit->x, unit->y, player->cnum),
xyas(d_sect.sct_x, d_sect.sct_y, player->cnum));
}
pr("Using path '%s'\n", cp);
}
}
pr("Using path '%s'\n", cp);
}
p = getstarg(input, prompt, buf);
if (p == 0 || *p == 0)
p = getstarg(input, prompt, buf);
if (p == 0 || *p == 0)
ip = item_by_name(p);
if (!ip)
pr("Unrecognized item \"%c\"\n", *p);
ip = item_by_name(p);
if (!ip)
pr("Unrecognized item \"%c\"\n", *p);
if (*str == ip->i_mnem)
return ip;
}
if (*str == ip->i_mnem)
return ip;
}
int selected;
if (np->sel == NS_UNDEF)
int selected;
if (np->sel == NS_UNDEF)
do {
if (np->sel == NS_LIST) {
np->index++;
if (np->index >= np->size)
do {
if (np->sel == NS_LIST) {
np->index++;
if (np->index >= np->size)
np->cur = np->list[np->index];
} else if (np->sel == NS_CARGO) {
if (np->next < 0)
np->cur = np->list[np->index];
} else if (np->sel == NS_CARGO) {
if (np->next < 0)
np->cur = np->next;
np->next = unit_cargo_next(np->type, np->next);
} else {
np->cur = np->next;
np->next = unit_cargo_next(np->type, np->next);
} else {
}
gp = ef_ptr(np->type, np->cur);
if (!gp)
}
gp = ef_ptr(np->type, np->cur);
if (!gp)
selected = 1;
switch (np->sel) {
selected = 1;
switch (np->sel) {
break;
case NS_DIST:
if (CANT_HAPPEN(!(ef_flags(np->type) & EFF_XY)))
break;
case NS_DIST:
if (CANT_HAPPEN(!(ef_flags(np->type) & EFF_XY)))
if (!xyinrange(gp->x, gp->y, &np->range)) {
selected = 0;
break;
if (!xyinrange(gp->x, gp->y, &np->range)) {
selected = 0;
break;
break;
case NS_AREA:
if (CANT_HAPPEN(!(ef_flags(np->type) & EFF_XY)))
break;
case NS_AREA:
if (CANT_HAPPEN(!(ef_flags(np->type) & EFF_XY)))
if (!xyinrange(gp->x, gp->y, &np->range))
selected = 0;
break;
case NS_XY:
if (CANT_HAPPEN(!(ef_flags(np->type) & EFF_XY)))
if (!xyinrange(gp->x, gp->y, &np->range))
selected = 0;
break;
case NS_XY:
if (CANT_HAPPEN(!(ef_flags(np->type) & EFF_XY)))
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)))
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)))
if (np->group != gp->group)
selected = 0;
break;
default:
CANT_REACH();
if (np->group != gp->group)
selected = 0;
break;
default:
CANT_REACH();
}
if (selected && np->ncond) {
/* nstr_exec is expensive, so we do it last */
}
if (selected && np->ncond) {
/* nstr_exec is expensive, so we do it last */
}
}
if (sp->sct_item[I_CIVIL] == 0 && sp->sct_item[I_MILIT] == 0
}
}
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;
makelost(EF_SECTOR, sp->sct_own, 0, sp->sct_x, sp->sct_y);
sp->sct_own = 0;
sp->sct_oldown = 0;
sp->sct_oldown = sp->sct_own;
}
if (!civ && !mil && !sp->sct_item[I_UW]
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;
makelost(EF_SECTOR, sp->sct_own, 0, sp->sct_x, sp->sct_y);
sp->sct_own = 0;
sp->sct_oldown = 0;
}
domove:
if (move && che > 0) {
}
domove:
if (move && che > 0) {
- struct sctstr *nicest_sp = 0;
+ struct sctstr *nicest_sp = NULL;
if (convert)
min_mil = 999;
else
if (convert)
min_mil = 999;
else
sail_ship(natid cn)
{
struct shpstr *sp;
sail_ship(natid cn)
{
struct shpstr *sp;
- struct fltheadstr *head = 0;
+ struct fltheadstr *head = NULL;
struct fltheadstr *fltp;
int n;
struct fltheadstr *fltp;
int n;
* they all starved or were plagued off.
*/
if (vec[I_CIVIL] == 0 && vec[I_MILIT] == 0 &&
* 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;
if (!player->simulation) {
makelost(EF_SECTOR, sp->sct_own, 0, sp->sct_x, sp->sct_y);
sp->sct_own = 0;
if (journal_startup() < 0)
exit(1);
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();
market_init();
update_init();
logerror("Shutdown commencing (cleaning up threads.)");
play_wrlock_wanted = 1;
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");
if (p->state != PS_PLAYING)
continue;
pr_flash(p, "Server shutting down...\n");
struct player *p;
play_wrlock_wanted = 1;
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) {
if (p->state != PS_PLAYING)
continue;
if (p->command) {