#define SHP_BLD_WORK(lcm, hcm) (20 + (lcm) + 2 * (hcm))
/* return codes from shp_check_nav */
-#define CN_NAVIGABLE (0)
-#define CN_LANDLOCKED (1)
-#define CN_CONSTRUCTION (2)
-#define CN_ERROR (-1)
+#define CN_NAVIGABLE 0
+#define CN_LANDLOCKED 1
+#define CN_CONSTRUCTION 2
+#define CN_ERROR -1
enum {
SHP_AIROPS_EFF = 50, /* min. efficiency for air ops */
/* Is the cache on? if not, return NULL */
if (as_cachepath_on == 0)
- return (NULL);
+ return NULL;
/* Do we have any cached? */
if (fromhead == (struct as_frompath **)0)
- return (NULL);
+ return NULL;
/* Yes! */
for (from = fromhead[fy]; from; from = from->next) {
if (from->x == fx) {
for (to = from->tolist[ty]; to; to = to->next) {
if (to->x == tx)
- return (to->path);
+ return to->path;
}
}
}
- return (NULL);
+ return NULL;
}
diff = (*n1)->lbcost - (*n2)->lbcost;
if (diff < -0.0001)
- return (-1);
+ return -1;
if (diff > 0.0001)
- return (1);
+ return 1;
/* equal, check secondary cost */
diff = (*n1)->seccost - (*n2)->seccost;
if (diff < -0.0001)
- return (-1);
+ return -1;
if (diff > 0.0001)
- return (1);
- return (0);
+ return 1;
+ return 0;
}
i = (*adp->neighbor) (head->np->c, adp->neighbor_coords,
adp->userdata);
if (i == 0)
- return (NULL);
+ return NULL;
/*
* Get rid of neighbors that are more costly than ones we already have,
* and sort the rest into an array of as_nodes.
*/
i = as_winnow(adp, adp->neighbor_coords, i);
if (i < 0)
- return (NULL);
+ return NULL;
if (i > 1)
qsort(adp->neighbor_nodes, i,
sizeof(*adp->neighbor_nodes), as_costcomp);
adp->tried->np->flags |= AS_TRIED;
head = as_merge(adp, head, adp->neighbor_nodes);
- return (head);
+ return head;
}
for (hp = adp->hashtab[hashval]; hp; hp = hp->next)
if (hp->c.x == c.x && hp->c.y == c.y)
- return (hp->qp);
+ return hp->qp;
- return (NULL);
+ return NULL;
}
/*
adp->seccost = seccostfunc;
adp->userdata = userdata;
- return (adp);
+ return adp;
}
np->step++;
}
- return (head);
+ return head;
}
#ifdef DEBUG
fprintf(stderr, "Failed\n");
#endif /* DEBUG */
- return (-1);
+ return -1;
}
as_makepath(adp);
}
#endif /* DEBUG */
- return (0);
+ return 0;
}
/*
#endif /* DEBUG */
if (qp->np->flags & AS_TRIED) {
/* should "never happen" */
- return (0);
+ return 0;
}
/*
* The neighbor is better than a previously visited coordinate;
np = as_newnode(adp->head->np, *cp, inclbcost, lbcost,
knowncost, seccost);
if (np == NULL)
- return (0);
+ return 0;
if (fix_pointer) {
#ifdef DEBUG
fprintf(stderr, "Fixing pointer for %d, %d\n",
}
adp->neighbor_nodes[i] = NULL;
- return (i);
+ return i;
}
np->step = backp->step;
np->back = backp;
- return (np);
+ return np;
}
/* check that last one! */
if (todelete)
free(todelete);
- return (nship);
+ return nship;
}
if (player->argp[2]) {
cost = do_desi(natp, player->argp[1], player->argp[2], cash, 0);
if (cost < 0)
- return (int)(-cost);
+ return (int)-cost;
if (chkmoney(cost, cash, player->argp[3]))
return RET_SYN;
}
errcheck(int num, int min, int max)
{
if (num < min)
- return (min);
+ return min;
else if (num > max)
- return (max);
- return (num);
+ return max;
+ return num;
}
static int
load_spy = 1;
}
}
- if ((!load_spy) &&
+ if (!load_spy &&
(sp->shp_nland >= mchr[(int)sp->shp_type].m_nland)) {
if (noisy) {
if (mchr[(int)sp->shp_type].m_nland)
land.lnd_x, land.lnd_y);
}
- land.lnd_ship = (-1);
+ land.lnd_ship = -1;
sp->shp_nland--;
putland(land.lnd_uid, &land);
putship(sp->shp_uid, sp);
land.lnd_own = sectp->sct_own;
makenotlost(EF_LAND, land.lnd_own, land.lnd_uid, land.lnd_x,
land.lnd_y);
- land.lnd_land = (-1);
+ land.lnd_land = -1;
lp->lnd_nland--;
putland(land.lnd_uid, &land);
putland(lp->lnd_uid, lp);
emp_initque(&fired);
emp_initque(&defended);
- type = (-1);
+ type = -1;
while ((type != EF_SECTOR) && (type != EF_SHIP) && (type != EF_LAND)) {
if (!(p = getstarg(player->argp[1],
"Firing from ship(s), sect(s), or land unit(s)? ",
emp_insque(&fp->queue, al);
}
- return (dam);
+ return dam;
}
static void
}
}
- return ((*nfiring) == 0 ? 0 : (dam / (*nfiring)));
+ return *nfiring == 0 ? 0 : dam / *nfiring;
}
static void
int nships;
struct nstr_item ni;
struct shpstr ship;
- int isfleet = 0, rflags = (-2), zero;
+ int isfleet = 0;
+ int rflags = -2;
+ int zero;
unsigned int x;
s_char buf1[1024];
s_char buf2[1024];
int nunits;
struct nstr_item ni;
struct lndstr land;
- int isarmy = 0, rflags = (-2), zero;
+ int isarmy = 0;
+ int rflags = -2;
+ int zero;
s_char buf1[1024];
s_char buf2[1024];
unsigned int x;
return RET_SYN;
cp = player->argp[2];
if ((*player->argp[0] == 'q') /*qsail command */ ||(cp && *cp == 'q')) {
- return (show_sail(&nstr));
+ return show_sail(&nstr);
} else if (*player->argp[0] == 'u' /*unsail command */
|| (cp && *cp == '-')) {
- return (cmd_unsail_ship(&nstr));
+ return cmd_unsail_ship(&nstr);
} else
- return (cmd_sail_ship(&nstr));
+ return cmd_sail_ship(&nstr);
}
/* check that last one! */
if (todelete)
free(todelete);
- return (nsat);
+ return nsat;
}
if (*game_hours != 0)
pr("Game hours are: %s\n", game_hours);
- return (0);
+ return 0;
} else {
time_t now;
time_t upd_time;
mapbuf = malloc((WORLD_X * WORLD_Y) *
sizeof(unsigned int));
if (!mapbuf)
- return ((s_char *)0);
+ return NULL;
if (!mapindex) {
mapindex = malloc(WORLD_X * sizeof(unsigned int *));
if (mapindex) {
}
}
if (!mapindex)
- return ((s_char *)0);
+ return NULL;
bpath[0] = 0;
if (0 != (restr2 = (*terrain == 'R')))
}
if (!valid(x, y) || !valid(ex, ey))
- return ((s_char *)0);
+ return NULL;
if (restr2 && (!owned_and_navigable(bigmap, x, y, terrain, own) ||
!owned_and_navigable(bigmap, x, y, terrain, own)))
- return ((s_char *)0);
+ return NULL;
for (i = 0; i < WORLD_X; i++)
for (j = 0; j < WORLD_Y; j++)
} while (markedsectors);
bpath[0] = 0;
- return ((s_char *)0); /* no route possible */
+ return NULL; /* no route possible */
}
/* return TRUE if sector is passable */
/* No terrain to check? Everything is navigable! (this
probably means we are flying) */
if (!(*terrain))
- return (1);
+ return 1;
/* Are we checking this map? */
if (map) {
since otherwise we'll never venture anywhere */
mapspot = map[sctoff(x, y)];
if (mapspot == ' ' || mapspot == 0)
- return (1);
+ return 1;
/* Now, is it marked with a 'x' or 'X'? If so, avoid it! */
if (mapspot == 'x' || mapspot == 'X')
- return (0);
+ return 0;
} else {
/* We don't know what it is since we have no map, so return ok! */
- return (1);
+ return 1;
}
/* Now, check this bmap entry to see if it is one of the
}
if (negate && *t) {
/* We found it, so we say it's bad since we are negating */
- return (0);
+ return 0;
} else if (!negate && !*t) {
/* We didn't find it, so we say it's bad since we aren't negating */
- return (0);
+ return 0;
}
/* According to our bmap, this sector is ok so far. */
/* We can't sail through deity sectors, but we can sail
through any ocean */
if (rel < FRIENDLY && sect->sct_type != SCT_WATER)
- return (0);
+ return 0;
}
}
/* Ok, now, check these two sector types */
/* check for bad harbors. */
if (c == 'h' && sect->sct_effic < 2)
- return (0);
+ return 0;
/* check for bad bridges */
if (c == '=' && sect->sct_effic < 60)
- return (0);
+ return 0;
/* Woo-hoo, it's ok! */
- return (1);
+ return 1;
}
logerror("ef_ptr: (%s) only valid for EFF_MEM entries", ep->file);
return NULL;
}
- return (ep->cache + ep->size * id);
+ return ep->cache + ep->size * id;
}
/*
cp[n].y = sy;
n++;
}
- return (n);
+ return n;
}
/*
offset = (sy * WORLD_X + sx) / 2;
ts = (struct sctstr *)(ep->cache + ep->size * offset);
cost = sector_mcost(ts, bp->bp_mobtype);
- return (cost);
+ return cost;
}
/*
static double
bp_realcost(struct as_coord from, struct as_coord to, s_char *pp)
{
- return (bp_lbcost(from, to, pp));
+ return bp_lbcost(from, to, pp);
}
/*
/* need to make sector database available to bestpath */
map = ef_ptr(EF_BMAP, owner);
- return (bestownedpath(path, map, fx, fy, tx, ty, ".=h", owner));
+ return bestownedpath(path, map, fx, fy, tx, ty, ".=h", owner);
}
s_char *
BestAirPath(s_char *path, int fx, int fy, int tx, int ty)
{
- return (bestownedpath(path, 0, fx, fy, tx, ty, "", -1));
+ return bestownedpath(path, 0, fx, fy, tx, ty, "", -1);
/* return (bestpath(path, fx, fy, tx, ty, "")); */
}
}
*want = totwant;
*pop = totpop;
- return (whichwants);
+ return whichwants;
}
static int
if (0 == update_wantmin) {
logerror("no demand update allowed, wantmin = 0");
- return (0);
+ return 0;
}
demand_update_want(&want, &pop, 0);
if (want < update_wantmin) {
logerror("no demand update, want = %d, min = %d",
want, update_wantmin);
- return (0);
+ return 0;
}
time(&now);
if (!demand_update_time(&now)) {
logerror("no demand update, not within hours allowed.");
- return (0);
+ return 0;
}
if (veto) {
logerror("no demand update, %d has missed more than %d updates",
veto - 1, update_missed);
- return (0);
+ return 0;
}
- return (1);
+ return 1;
}
/* Check if enough countries want an update,
{
if (UDDEM_COMSET != update_demandpolicy) {
logerror("no demand update, not policy.");
- return (0);
+ return 0;
}
- return (demand_check());
+ return demand_check();
}
/* Is it time for a regular or scheduled update?
{
if (opt_BLITZ && update_policy == UDP_BLITZ) {
logerror("BLITZ Update.");
- return (1);
+ return 1;
}
if (UDP_NORMAL == update_policy) {
logerror("Regular update, etu type.");
- return (1);
+ return 1;
}
if (UDP_TIMES == update_policy) {
if (scheduled_update_time(now)) {
logerror("Scheduled update.");
- return (1);
+ return 1;
}
}
if (opt_DEMANDUPDATE) {
if (demand_check()) {
logerror("Demand update, at check time.");
- return (1);
+ return 1;
}
}
- return (0);
+ return 0;
}
/* Return the time, and delta seconds, of the next update.
int
io_conn(struct iop *iop)
{
- return (iop->flags & IO_CONN);
+ return iop->flags & IO_CONN;
}
int
io_error(struct iop *iop)
{
- return (iop->flags & IO_ERROR);
+ return iop->flags & IO_ERROR;
}
int
io_eof(struct iop *iop)
{
- return (iop->flags & IO_EOF);
+ return iop->flags & IO_EOF;
}
int
s_char *
plur(int n, s_char *no, s_char *yes)
{
- return (n == 1 ? no : yes);
+ return n == 1 ? no : yes;
}
s_char *
splur(int n)
{
- return (n == 1 ? "" : "s");
+ return n == 1 ? "" : "s";
}
s_char *
esplur(int n)
{
- return (n == 1 ? "" : "es");
+ return n == 1 ? "" : "es";
}
s_char *
iesplur(int n)
{
- return (n == 1 ? "y" : "ies");
+ return n == 1 ? "y" : "ies";
}
register int r11;
r11 = (m >> 1) + n;
- return (r11 / m * m);
+ return r11 / m * m;
}
int
int f4;
f4 = ac / 2.0 + a4;
- return (f4 / ac * ac);
+ return f4 / ac * ac;
}
x = -x;
if (y < 0)
y = -y;
- return ((x * 10 + y) % tsize);
+ return (x * 10 + y) % tsize;
}
unsigned long stackp;
if (!(newp = malloc(sizeof(struct lwpProc))))
- return (0);
+ return 0;
if (flags & LWP_STACKCHECK) {
/* Add a 1K buffer on each side of the stack */
size += 2 * LWP_REDZONE;
size += LWP_EXTRASTACK;
size += sizeof(stkalign_t);
if (!(s = malloc(size)))
- return (0);
+ return 0;
newp->flags = flags;
newp->name = strdup(name);
newp->desc = strdup(desc);
lwpInitContext(newp, sp); /* architecture-dependent: from arch.c */
#endif /* UCONTEXT */
lwpReschedule();
- return (newp);
+ return newp;
}
void
{
if (!p)
p = LwpCurrent;
- return (p->ud);
+ return p->ud;
}
/*
lwpStatus(LwpCurrent, "resetting priority (%d -> %d)", old, new);
if (new < old)
lwpYield();
- return (old);
+ return old;
}
/*
pri = 1;
/* *LwpContextPtr = 0; */
if (!(LwpCurrent = calloc(1, sizeof(struct lwpProc))))
- return (0);
+ return 0;
if (!(stack = malloc(64)))
- return (0);
+ return 0;
if (LWP_MAX_PRIO <= pri)
pri = LWP_MAX_PRIO - 1;
if (LwpMaxpri < pri)
sel = lwpCreate(0, lwpSelect, 16384, flags, "EventHandler",
"Select (main loop) Event Handler", 0, 0, 0);
lwpInitSelect(sel);
- return (LwpCurrent);
+ return LwpCurrent;
}
/* lwpStackCheckInit
if ((head = q->head) && !(q->head = head->next))
q->tail = 0;
- return (head);
+ return head;
}
void
struct lwpSem *new;
if (!(new = malloc(sizeof(struct lwpSem))))
- return (0);
+ return 0;
new->name = strdup(name);
new->count = count;
new->q.head = new->q.tail = 0;
- return (new);
+ return new;
}
/*
}
if (QEMPTY(olist))
- return (CASUALTY_LUMP - to_take);
+ return CASUALTY_LUMP - to_take;
/*
* Need to take some casualties from attacking units
}
}
if (biggest == (struct emp_qelem *)0)
- return (CASUALTY_LUMP - to_take);
+ return CASUALTY_LUMP - to_take;
llp = (struct llist *)biggest;
cas = lnd_take_casualty(combat_mode, llp, to_take);
- return (CASUALTY_LUMP - (to_take - cas));
+ return CASUALTY_LUMP - (to_take - cas);
}
/* Send reacting defense units back to where they came from (at no mob cost) */
if (off->shp_mcp->m_flags & M_LAND) {
if (llp->lcp->l_flags & L_MARINE)
llp->land.lnd_mobil -=
- ((float)etu_per_update * land_mob_scale * 0.5);
+ (float)etu_per_update * land_mob_scale * 0.5;
else
- llp->land.lnd_mobil -= ((float)etu_per_update
- * land_mob_scale);
+ llp->land.lnd_mobil -= (float)etu_per_update * land_mob_scale;
} else {
if (llp->lcp->l_flags & L_MARINE)
llp->land.lnd_mobil = 0;
else
- llp->land.lnd_mobil = (((float)etu_per_update
- * land_mob_scale) * (-1));
+ llp->land.lnd_mobil = -(float)etu_per_update * land_mob_scale;
}
break;
case A_BOARD:
}
}
}
- return (int)100 - (eff * 100);
+ return (int)100 - eff * 100;
}
int
f = r - ((int)r);
if (chance(f))
- return (((int)r) + 1);
+ return ((int)r) + 1;
else
- return ((int)r);
+ return (int)r;
}
if (value < 1.0 && men > 0 && !(lcp->l_flags & L_SPY))
return 1;
- return (int)(value);
+ return (int)value;
}
int
s_char orig;
int mob;
-
-
taken = lnd_getmil(&(llp->land));
/* Spies always die */
if (llp->lcp->l_flags & L_SPY) {
orig = llp->land.lnd_mobil;
llp->land.lnd_mobil = (s_char)mob;
if (llp->land.lnd_mobil > orig)
- llp->land.lnd_mobil = (-127);
+ llp->land.lnd_mobil = -127;
sprintf(buf, "retreats at %d%% efficiency to %s!",
llp->land.lnd_effic,
xyas(bx, by, llp->land.lnd_own));
lnd_spyval(struct lndstr *lp)
{
if (lchr[(int)lp->lnd_type].l_flags & L_RECON)
- return (lp->lnd_spy * (lp->lnd_effic / 100.0)) + 2;
+ return lp->lnd_spy * (lp->lnd_effic / 100.0) + 2;
else
- return (lp->lnd_spy * (lp->lnd_effic / 100.0));
+ return lp->lnd_spy * (lp->lnd_effic / 100.0);
}
int
if (icount == 0) {
if (sect.sct_own != 0)
mpr(sect.sct_own, "No %ss launched to intercept.\n", def_name);
- return (destroyed);
+ return destroyed;
}
/* attempt to destroy incoming missile */
free(qp);
}
if (destroyed)
- return (destroyed);
+ return destroyed;
if (icount) {
mpr(bombown, "%s made it through %s defenses!\n", att_name,
def_name);
mpr(sect.sct_own, "%s made it through %s defenses!\n",
att_name, def_name);
}
- return (destroyed);
+ return destroyed;
}
/* Keep launching missiles on list until mindam damage has been done */
x = 0;
while (conditions[x].code) {
if (conditions[x].code == code)
- return (x);
+ return x;
x++;
}
- return (x);
+ return x;
}
int
*counter = *counter - left;
if (updating_mob)
- return (newetus);
+ return newetus;
return 0;
}
above = logx(above_easy + 1.0, logbase);
if (above > 250)
above = 250;
- return ((above) < 0) ? easy : (easy + above);
+ return above < 0 ? easy : easy + above;
} else
return level;
}
if (np->curdist > np->dist)
continue;
}
- return (getsectp(np->x, np->y));
+ return getsectp(np->x, np->y);
}
/*NOTREACHED*/
}
totalmil += mil;
}
mil_pay = totalmil * etu * money_mil;
- return (mil_pay);
+ return mil_pay;
}
int
s_char *cp;
if (sp->shp_own == 0)
- return (0);
+ return 0;
wu(0, sp->shp_own,
"Ship #%d, following #%d, which you don't own.\n",
sp->shp_uid, ap->shp_uid);
- return (0);
+ return 0;
}
/* Not a follower. */
if (ap->shp_path[0] != 'f')
wu(0, sp->shp_own,
"Ship #%d, following #%d, which you don't own.\n",
sp->shp_uid, follow);
- return (0);
+ return 0;
}
/* This should prevent infinite loops. */
wu(0, sp->shp_own,
"Ship #%d, too many follows (circular follow?).\n",
sp->shp_uid);
- return (0);
+ return 0;
}
for (stop = 0, cp = ap->shp_path; (!stop) && (*cp); cp++) {
/* if this ship is not sailing anywhere then ignore it. */
if (!*ap->shp_path)
- return (0);
+ return 0;
/* Find the fleet structure we belong to. */
for (fltp = (*head); (fltp && fltp->leader != follow);
"Ship %d not in same sector as its sailing fleet\n",
sp->shp_uid);
fltp->real_q = LEADER_WRONGSECT;
- return (0);
+ return 0;
}
this = malloc(sizeof(*this));
default:
wu(0, fltp->own, "Your fleet lead by %d is trapped by land.\n",
fltp->leader);
- return (0);
+ return 0;
}
for (fe = fltp->head; fe; fe = fe->next) {
sp = getshipp(fe->num);
}
}
if (error)
- return (0);
+ return 0;
sp = getshipp(fltp->leader);
own = sp->shp_own;
fltp_to_list(fltp, &ship_list); /* hack -KHS 1995 */
struct sctstr **sects;
struct sctstr *sectsbuf;
int fl_status; /* is anything wrong? */
-#define STATUS_NO_ROOM (1) /* there was no room to grow */
+#define STATUS_NO_ROOM 1 /* there was no room to grow */
#define NUMTRIES 10 /* keep trying to grow this many times */
const char *numletter =