#define ATTRIBUTE(attrs)
#endif
-/* This uses a lot of thread stack with some versions of GNU libc,
- which can lead to nasty heap smashes (observed with 2.2.93).
- Disabled for now, until we readjust thread stack sizes. */
+/*
+ * This uses a lot of thread stack with some versions of GNU libc,
+ * which can lead to nasty heap smashes (observed with 2.2.93).
+ * Disabled for now, until we readjust thread stack sizes.
+ */
#if 0
#define RESOLVE_IPADDRESS /* resolve ip addresses into hostnames */
#endif
/* radmap.c */
extern int deltx(struct range *, coord);
- /* Prototype include a typedef name.
- It should be moved after the typedef declaration */
extern int delty(struct range *, coord);
- /* Prototype include a typedef name.
- It should be moved after the typedef declaration */
extern void radmap(int, int, int, int, double);
extern void radmapnopr(int, int, int, int, double);
extern void radmapupd(int, int, int, int, int, double);
struct qelem queue; /* list of ioqueue elements */
int nbytes; /* number of data bytes present */
int offset; /* offset into current entry */
- char *data; /* pointer to start */
+ char *data; /* pointer to start */
};
void ioq_init(struct ioqueue *ioq, int bsize);
/* copies 4k at a time to the socket */
while (termio(fd, sock, auxfi)) /*do copy */
;
- /* Some platforms don't send the eof (cntl-D) at the end of
- copying a file. If emp_client hangs at the end of an
- execute, include the following line and notify wolfpack
- of the platform you are using.
- sendeof(sock);
+ /*
+ * Some platforms don't send the eof (cntl-D) at the end of
+ * copying a file. If emp_client hangs at the end of an
+ * execute, include the following line and notify wolfpack
+ * of the platform you are using.
+ * sendeof(sock);
*/
close(fd);
free(tag);
void
as_reset(struct as_data *adp)
{
-
as_free_queue(adp->head);
adp->head = NULL;
as_free_queue(adp->tried);
if (lp->lnd_own != player->cnum)
continue;
- wu(0, to, "\t%s ceded to you by %s\n", prland(lp),
- cname(player->cnum));
+ wu(0, to, "\t%s ceded to you by %s\n",
+ prland(lp), cname(player->cnum));
makelost(EF_LAND, lp->lnd_own, lp->lnd_uid, lp->lnd_x, lp->lnd_y);
makenotlost(EF_LAND, to, lp->lnd_uid, lp->lnd_x, lp->lnd_y);
lp->lnd_own = to;
/*
* Military units count according to the number of
- * mil in them. (i.e. attack/defense modified don't
+ * mil in them. (i.e. attack/defense modifier don't
* count.
*/
snxtitem_xy(&ni, EF_LAND, sect.sct_x, sect.sct_y);
if (!player->owner)
continue;
if (ship.shp_x != x || ship.shp_y != y) {
- pr("Ship #%d not in same sector as #%d\n", ship.shp_uid,
- leader);
+ pr("Ship #%d not in same sector as #%d\n",
+ ship.shp_uid, leader);
continue;
}
if (ship.shp_uid == leader) {
civ = sect.sct_item[I_CIVIL];
mil = sect.sct_item[I_MILIT];
if (civ)
- pr("with %s%d civ ", player->owner ? "" : "approx ",
+ pr("with %s%d civ ",
+ player->owner ? "" : "approx ",
player->owner ? civ : roundintby(civ, 10));
if (mil)
- pr("with %s%d mil ", player->owner ? "" : "approx ",
+ pr("with %s%d mil ",
+ player->owner ? "" : "approx ",
player->owner ? mil : roundintby(mil, 10));
pr("@ %s\n", xyas(x, y, player->cnum));
if (opt_HIDDEN) {
continue;
}
if (fship.shp_effic < 60) {
- pr("Ship #%d is crippled (%d%%)\n", fshipno,
- fship.shp_effic);
+ pr("Ship #%d is crippled (%d%%)\n",
+ fshipno, fship.shp_effic);
continue;
}
range = effrange(fship.shp_frnge, fship.shp_tech);
}
amt_src = start.sct_item[vtype];
if (amt_src < amount) {
- pr("Only %d %s left in %s!\n", amt_src,
- ip->i_name, xyas(start.sct_x, start.sct_y, player->cnum));
+ pr("Only %d %s left in %s!\n",
+ amt_src, ip->i_name,
+ xyas(start.sct_x, start.sct_y, player->cnum));
amount = amt_src;
amt_src = 0;
} else
if (ship.shp_autonav & AN_AUTONAV) {
/* Destination 1 */
- prxy(" %3d,%-3d", ship.shp_destx[1],
- ship.shp_desty[1], player->cnum);
+ prxy(" %3d,%-3d",
+ ship.shp_destx[1], ship.shp_desty[1], player->cnum);
/* Destination 2 */
if ((ship.shp_destx[1] != ship.shp_destx[0])
|| (ship.shp_desty[1] != ship.shp_desty[0])) {
- prxy(" %3d,%-3d", ship.shp_destx[0],
- ship.shp_desty[0], player->cnum);
+ prxy(" %3d,%-3d",
+ ship.shp_destx[0], ship.shp_desty[0], player->cnum);
} else
pr(" ");
continue;
plane.pln_range = (plane.pln_range_max < i) ?
plane.pln_range_max : i;
- pr("Plane %d range changed to %d\n", plane.pln_uid,
- plane.pln_range);
+ pr("Plane %d range changed to %d\n",
+ plane.pln_uid, plane.pln_range);
putplane(plane.pln_uid, &plane);
}
if ((i = atoi(p)) < 0)
continue;
land.lnd_rad_max = (i < land.lnd_rad) ? i : land.lnd_rad;
- pr("%s reaction radius changed to %d\n", prland(&land),
- land.lnd_rad_max);
+ pr("%s reaction radius changed to %d\n",
+ prland(&land), land.lnd_rad_max);
putland(land.lnd_uid, &land);
}
prship(&targ),
xyas(targ.shp_x, targ.shp_y, player->cnum));
else
- pr("Sonar detects %s %s @ %s\n", cname(targ.shp_own),
- prship(&targ),
+ pr("Sonar detects %s %s @ %s\n",
+ cname(targ.shp_own), prship(&targ),
xyas(targ.shp_x, targ.shp_y, player->cnum));
} else
- pr("Sonar detects %s %s @ %s\n", cname(targ.shp_own),
- prship(&targ),
+ pr("Sonar detects %s %s @ %s\n",
+ cname(targ.shp_own), prship(&targ),
xyas(targ.shp_x, targ.shp_y, player->cnum));
if (targ.shp_visib > vis[y][x]) {
prship(targ),
xyas(targ->shp_x, targ->shp_y, pp->pln_own));
else
- mpr(pp->pln_own, "%s %s @ %s\n", cname(targ->shp_own),
- prship(targ),
+ mpr(pp->pln_own, "%s %s @ %s\n",
+ cname(targ->shp_own), prship(targ),
xyas(targ->shp_x, targ->shp_y, pp->pln_own));
}
}
continue;
}
if ((mchr[(int)sub.shp_type].m_flags & M_TORP) == 0) {
- pr("Ship # %d: A %s can't fire torpedoes!\n", sub.shp_uid,
- mchr[(int)sub.shp_type].m_name);
+ pr("Ship # %d: A %s can't fire torpedoes!\n",
+ sub.shp_uid, mchr[(int)sub.shp_type].m_name);
continue;
}
shells = sub.shp_item[I_SHELL];
TRADE_DELAY / 3600.0 - (now - trade.trd_markettime) / 3600.0;
if (tleft < 0.0)
tleft = 0.0;
- pr("$%7ld %2d %5.2f hrs ", trade.trd_price,
- trade.trd_maxbidder, tleft);
+ pr("$%7ld %2d %5.2f hrs ",
+ trade.trd_price, trade.trd_maxbidder, tleft);
(void)trade_desc(&trade, &tg); /* XXX */
pr("\n");
if (trade.trd_owner == player->cnum && !player->god)
continue;
}
if (land.lnd_tech >= tlev) {
- pr("%s tech: %d, yours is only %d\n", prland(&land),
- land.lnd_tech, tlev);
+ pr("%s tech: %d, yours is only %d\n",
+ prland(&land), land.lnd_tech, tlev);
continue;
}
cost = lp->l_cost * UPGR_COST / 100;
putland(land.lnd_uid, &land);
putsect(§);
player->dolcost += cost;
- pr("%s upgraded to tech %d, at a cost of %d\n", prland(&land),
- land.lnd_tech, cost);
+ pr("%s upgraded to tech %d, at a cost of %d\n",
+ prland(&land), land.lnd_tech, cost);
if (land.lnd_own != player->cnum)
wu(0, land.lnd_own,
"%s upgraded by %s to tech %d, at a cost of %d\n",
continue;
}
if (ship.shp_tech >= tlev) {
- pr("%s tech: %d, yours is only %d\n", prship(&ship),
- ship.shp_tech, tlev);
+ pr("%s tech: %d, yours is only %d\n",
+ prship(&ship), ship.shp_tech, tlev);
continue;
}
cost = mp->m_cost * UPGR_COST / 100;
putship(ship.shp_uid, &ship);
putsect(§);
player->dolcost += cost;
- pr("%s upgraded to tech %d, at a cost of %d\n", prship(&ship),
- ship.shp_tech, cost);
+ pr("%s upgraded to tech %d, at a cost of %d\n",
+ prship(&ship), ship.shp_tech, cost);
if (ship.shp_own != player->cnum)
wu(0, ship.shp_own,
"%s upgraded by %s to tech %d, at a cost of %d\n",
continue;
}
if (plane.pln_tech >= tlev) {
- pr("%s tech: %d, yours is only %d\n", prplane(&plane),
- plane.pln_tech, tlev);
+ pr("%s tech: %d, yours is only %d\n",
+ prplane(&plane), plane.pln_tech, tlev);
continue;
}
cost = pp->pl_cost * UPGR_COST / 100;
putplane(plane.pln_uid, &plane);
putsect(§);
player->dolcost += cost;
- pr("%s upgraded to tech %d, at a cost of %d\n", prplane(&plane),
- plane.pln_tech, cost);
+ pr("%s upgraded to tech %d, at a cost of %d\n",
+ prplane(&plane), plane.pln_tech, cost);
if (plane.pln_own != player->cnum)
wu(0, plane.pln_own,
"%s upgraded by %s to tech %d, at a cost of %d\n",
return 1;
}
-/* Check if enough countries want an update,
+/*
+ * Check if enough countries want an update,
* and if demand updates are allowed now.
*/
int
return demand_check();
}
-/* Is it time for a regular or scheduled update?
+/*
+ * Is it time for a regular or scheduled update?
* As well, if none of the above, check to see if
* a demand update can occur.
*/
return 0;
}
-/* Return the time, and delta seconds, of the next update.
+/*
+ * Return the time, and delta seconds, of the next update.
* If the policy is no regular updates, return the time of
* the next possible check.
*/
pThread = malloc(sizeof(*pThread));
if (!pThread) {
- logerror("not enough memory to create thread: %s (%s)", name,
- desc);
+ logerror("not enough memory to create thread: %s (%s)",
+ name, desc);
return NULL;
}
memset(pThread, 0, sizeof(*pThread));
pThread->ulThreadID = _beginthread(empth_threadMain, size, pThread);
if (pThread->ulThreadID == -1) {
- logerror("can not create thread: %s (%s): %s", name, desc,
- strerror(errno));
+ logerror("can not create thread: %s (%s): %s",
+ name, desc, strerror(errno));
goto bad;
}
*/
static pthread_mutex_t mtx_ctxsw;
-static void empth_status(char *format, ...) ATTRIBUTE((format (printf, 1, 2)));
+static void empth_status(char *format, ...)
+ ATTRIBUTE((format (printf, 1, 2)));
static void empth_alarm(int sig);
static void *
empth_t *ctx;
struct sigaction act;
-
pthread_key_create(&ctx_key, NULL);
pthread_mutex_init(&mtx_ctxsw, NULL);
ctx = malloc(sizeof(empth_t));
if (!ctx) {
- logerror("not enough memory to create thread: %s (%s)", name,
- desc);
+ logerror("not enough memory to create thread: %s (%s)",
+ name, desc);
return NULL;
}
ctx->name = strdup(name);
eno = pthread_attr_init(&attr);
if (eno) {
- logerror("can not create thread attribute %s (%s): %s", name, desc,
- strerror(eno));
+ logerror("can not create thread attribute %s (%s): %s",
+ name, desc, strerror(eno));
goto bad;
}
if (size < PTHREAD_STACK_MIN)
eno = pthread_create(&t, &attr, empth_start, ctx);
if (eno) {
- logerror("can not create thread: %s (%s): %s", name, desc,
- strerror(eno));
+ logerror("can not create thread: %s (%s): %s",
+ name, desc, strerror(eno));
goto bad;
}
empth_status("new thread id is %ld", (long)t);
empth_select(s, EMPTH_FD_READ);
len = player_addrlen;
ns = accept(s, sap, &len);
- /* FIXME accept() can block on some systems (RST after select() reported s ready) */
+ /* FIXME accept() can block on some systems (RST after select() reports ready) */
if (ns < 0) {
logerror("new socket accept");
continue;
oesc);
gotilist[cn]++;
}
- PR(plane_owner, "Flying over %s ships in %s\n", cname(cn),
- xyas(x, y, plane_owner));
+ PR(plane_owner, "Flying over %s ships in %s\n",
+ cname(cn), xyas(x, y, plane_owner));
/* This makes going for ships in harbors tough */
if (!evaded) {
/* We already fired flak up above. Now we intercept again if we haven't already */
}
if (icount == 0)
return;
- PR(plane_owner, "%d %s fighter%s rising to intercept!\n", icount,
- cname(def_own), icount == 1 ? " is" : "s are");
- PR(def_own, "%d fighter%s intercepting %s planes!\n", icount,
- icount == 1 ? " is" : "s are", cname(plane_owner));
+ PR(plane_owner, "%d %s fighter%s rising to intercept!\n",
+ icount, cname(def_own), icount == 1 ? " is" : "s are");
+ PR(def_own, "%d fighter%s intercepting %s planes!\n",
+ icount, icount == 1 ? " is" : "s are", cname(plane_owner));
ac_combat_headers(plane_owner, def_own);
ac_airtoair(esc_list, &int_list);
ac_airtoair(bomb_list, &int_list);
}
if (off && def->sct_dcp->d_mcst <= 0) {
- pr("You can't %s a %s sector!\n", att_mode[combat_mode],
- def->sct_dcp->d_name);
+ pr("You can't %s a %s sector!\n",
+ att_mode[combat_mode], def->sct_dcp->d_name);
return abort_attack();
}
if (!off || off->relations_checked)
if (looping && cash > 0 && player->dolcost > cash / 2 && *warnedp < 1) {
*warnedp = 1;
pr("WARNING. You have just spent over half of your money.\n");
- pr("You started with $%ld and now you only have $%ld left\n", cash,
- cash - (long)player->dolcost);
+ pr("You started with $%ld and now you only have $%ld left\n",
+ cash, cash - (long)player->dolcost);
}
return 0;
}
break;
else if (dir == DIR_VIEW) {
pr("%d%% %s with %d civilians.\n", sect.sct_effic,
- dchr[sect.sct_type].d_name,
- sect.sct_item[I_CIVIL]);
+ dchr[sect.sct_type].d_name, sect.sct_item[I_CIVIL]);
continue;
}
/*
if (!destroyed &&
msl_hit(pp, hardtarget, EF_PLANE, news_item, news_item,
att_name, x, y, bombown)) {
- mpr(bombown, "%s destroyed by %s %s!\n", att_name,
- cname(pp->pln_own), def_name);
+ mpr(bombown, "%s destroyed by %s %s!\n",
+ att_name, cname(pp->pln_own), def_name);
if (sect.sct_own)
mpr(sect.sct_own, "%s %s intercepted!\n", who, att_name);
if (sect.sct_own != pp->pln_own)
if (destroyed)
return destroyed;
if (icount) {
- mpr(bombown, "%s made it through %s defenses!\n", att_name,
- def_name);
+ mpr(bombown, "%s made it through %s defenses!\n",
+ att_name, def_name);
if (sect.sct_own)
mpr(sect.sct_own, "%s made it through %s defenses!\n",
att_name, def_name);
struct plnstr plane;
if (np->nuk_uid != n) {
- logerror("nuk_postread: Error - %d != %d, zeroing.\n", np->nuk_uid,
- n);
+ logerror("nuk_postread: Error - %d != %d, zeroing.\n",
+ np->nuk_uid, n);
memset(np, 0, sizeof(struct nukstr));
}
struct lndstr theland;
if (pp->pln_uid != n) {
- logerror("pln_postread: Error - %d != %d, zeroing.\n", pp->pln_uid,
- n);
+ logerror("pln_postread: Error - %d != %d, zeroing.\n",
+ pp->pln_uid, n);
memset(pp, 0, sizeof(struct plnstr));
}
pr("\t%s cannot land on ship #%d! %s aborts!\n",
prplane(&plp->plane), cno, prplane(&plp->plane));
else if (!put_plane_on_ship(&plp->plane, &ship))
- pr("\tNo room on ship #%d! %s aborts!\n", cno,
- prplane(&plp->plane));
+ pr("\tNo room on ship #%d! %s aborts!\n",
+ cno, prplane(&plp->plane));
else {
if (plp->plane.pln_own != ship.shp_own) {
/* plp->plane.pln_own = ship.shp_own;*/
- wu(0, ship.shp_own,
- "%s %s lands on your %s\n",
- cname(player->cnum),
- prplane(&plp->plane), prship(&ship));
+ wu(0, ship.shp_own, "%s %s lands on your %s\n",
+ cname(player->cnum), prplane(&plp->plane),
+ prship(&ship));
}
}
} else {
if (addendum && us == player->cnum && !update_pending)
pr("%s\n", addendum);
- mpr(us, "Diplomatic relations with %s %s to \"%s\".\n", themname,
- whichway, relates[rel]);
+ mpr(us, "Diplomatic relations with %s %s to \"%s\".\n",
+ themname, whichway, relates[rel]);
if (!(getrejects(us, themnp) & REJ_TELE))
mpr(them,
"Country %s (#%d) has %s their relations with you to \"%s\"!\n",
}
if (orig) {
- wu(0, sp->shp_own, "%s %s, and retreated to %s\n", prship(sp),
- conditions[findcondition(code)].desc[orig],
+ wu(0, sp->shp_own, "%s %s, and retreated to %s\n",
+ prship(sp), conditions[findcondition(code)].desc[orig],
xyas(sp->shp_x, sp->shp_y, sp->shp_own));
} else {
wu(0, sp->shp_own, "%s %s, and ended up at %s\n",
}
range = range * (eff / 100.0);
- pr("%s efficiency %d%%, max range %d\n", xyas(x, y, player->cnum),
- eff, range);
+ pr("%s efficiency %d%%, max range %d\n",
+ xyas(x, y, player->cnum), eff, range);
memset(noise, 0, sizeof(noise));
if (eff < 100) {
pr("Some noise on the transmission...\n");
first = 0;
}
- pr("\t%4d %4d %-16.16s ", land.lnd_own, land.lnd_uid,
- lchr[(int)land.lnd_type].l_name);
+ pr("\t%4d %4d %-16.16s ",
+ land.lnd_own, land.lnd_uid, lchr[(int)land.lnd_type].l_name);
prxy("%4d,%-4d ", land.lnd_x, land.lnd_y, player->cnum);
pr("%3d%%\n", land.lnd_effic);
}
struct shpstr *sp = ptr;
if (sp->shp_uid != n) {
- logerror("shp_postread: Error - %d != %d, zeroing.\n", sp->shp_uid,
- n);
+ logerror("shp_postread: Error - %d != %d, zeroing.\n",
+ sp->shp_uid, n);
memset(sp, 0, sizeof(struct shpstr));
}
pr("Infrastructure building - adding 1 point of efficiency costs:\n");
pr(" type lcms hcms mobility $$$$\n");
for (x = 0; intrchr[x].in_name; x++) {
- pr("%-20s %4d %4d %8d %4d\n", intrchr[x].in_name,
- intrchr[x].in_lcms, intrchr[x].in_hcms,
+ pr("%-20s %4d %4d %8d %4d\n",
+ intrchr[x].in_name, intrchr[x].in_lcms, intrchr[x].in_hcms,
intrchr[x].in_mcost, intrchr[x].in_dcost);
}
}
j = dchr[x].d_prd;
- pr("%c %-23s %-7s ", dchr[x].d_mnem, dchr[x].d_name,
- pchr[j].p_sname);
+ pr("%c %-23s %-7s ",
+ dchr[x].d_mnem, dchr[x].d_name, pchr[j].p_sname);
(void)CANT_HAPPEN(MAXPRCON > 3); /* output has only three columns */
for (i = 0; i < 3; i++) {
if (i < MAXPRCON
}
getsect(sp->shp_x, sp->shp_y, §);
if (sect.sct_type != SCT_WATER)
- pr(" in a %s %s", cname(sect.sct_own),
- dchr[sect.sct_type].d_name);
+ pr(" in a %s %s",
+ cname(sect.sct_own), dchr[sect.sct_type].d_name);
else
pr(" at sea");
break;
sp->shp_autonav &= ~AN_SCUTTLE;
if (!(sectp = getsectp(sp->shp_x, sp->shp_y))) {
- wu(0, 0, "bad sector (%d,%d) ship %d\n", sp->shp_x, sp->shp_y,
- sp->shp_uid);
+ wu(0, 0, "bad sector (%d,%d) ship %d\n",
+ sp->shp_x, sp->shp_y, sp->shp_uid);
return;
}
if (sectp->sct_type != SCT_HARBR || sectp->sct_effic < 2) {
} else if (shutdown_pending == 1) {
pr_wall("%sServer shutting down in 1 minute!\n", header);
} else if (shutdown_pending <= 5) {
- pr_wall("%sServer shutting down in %d minutes!\n", header,
- shutdown_pending);
+ pr_wall("%sServer shutting down in %d minutes!\n",
+ header, shutdown_pending);
} else if (shutdown_pending <= 60
&& shutdown_pending % 10 == 0) {
pr_wall("%sThe server will be shutting down in %d minutes!\n",