Does not change optimized code (gcc -O).
Spotted by the Clang Static Analyzer.
25 files changed:
if (nuk_on_plane(&plp->plane) >= 0)
hitchance = 100;
else {
if (nuk_on_plane(&plp->plane) >= 0)
hitchance = 100;
else {
continue;
if (changed_plane_aborts(plp))
continue;
continue;
if (changed_plane_aborts(plp))
continue;
if (nuk_on_plane(&plp->plane) >= 0)
hitchance = 100;
else {
if (nuk_on_plane(&plp->plane) >= 0)
hitchance = 100;
else {
if (nuk_on_plane(&plp->plane) >= 0)
hitchance = 100;
else {
if (nuk_on_plane(&plp->plane) >= 0)
hitchance = 100;
else {
return RET_SYN;
prdate();
(void)strcpy(dirstr, ". $");
return RET_SYN;
prdate();
(void)strcpy(dirstr, ". $");
for (n = 1; n <= 6; n++)
dirstr[n] = dirch[n];
nsect = 0;
for (n = 1; n <= 6; n++)
dirstr[n] = dirch[n];
nsect = 0;
return RET_SYN;
prdate();
(void)strcpy(dirstr, ". $");
return RET_SYN;
prdate();
(void)strcpy(dirstr, ". $");
for (n = 1; n <= 6; n++)
dirstr[n] = dirch[n];
nsect = 0;
for (n = 1; n <= 6; n++)
dirstr[n] = dirch[n];
nsect = 0;
return RET_SYN;
prdate();
(void)strcpy(dirstr, ". $");
return RET_SYN;
prdate();
(void)strcpy(dirstr, ". $");
for (n = 1; n <= 6; n++)
dirstr[n] = dirch[n];
nsect = 0;
for (n = 1; n <= 6; n++)
dirstr[n] = dirch[n];
nsect = 0;
for (n = 0; n < 5; n++) {
if ((scoop = head_findscoop(hist, maxcnum, &actor, &victim)) < 10)
break;
for (n = 0; n < 5; n++) {
if ((scoop = head_findscoop(hist, maxcnum, &actor, &victim)) < 10)
break;
- severity = head_printscoop(hist, actor, victim);
+ head_printscoop(hist, actor, victim);
hp = &hist[actor][victim];
severity = hp->h_recent - hp->h_past;
if (severity <= -scoop / 2 || severity >= scoop / 2) {
hp = &hist[actor][victim];
severity = hp->h_recent - hp->h_past;
if (severity <= -scoop / 2 || severity >= scoop / 2) {
coord fy;
coord x;
coord y;
coord fy;
coord x;
coord y;
int dam;
int totaldefdam = 0;
int vshipno;
int dam;
int totaldefdam = 0;
int vshipno;
- if ((mil = fship.shp_item[I_MILIT]) < 1) {
+ if (fship.shp_item[I_MILIT] < 1) {
pr("Not enough military for firing crew.\n");
continue;
}
pr("Not enough military for firing crew.\n");
continue;
}
if (twork > bwork) {
twork = bwork;
}
if (twork > bwork) {
twork = bwork;
}
bwork -= twork;
eff -= twork * 4;
if (eff <= 0) {
bwork -= twork;
eff -= twork * 4;
if (eff <= 0) {
if (twork > hcms)
twork = hcms;
}
if (twork > hcms)
twork = hcms;
}
eff += twork;
} else if (eff < 100) {
twork = 100 - eff;
eff += twork;
} else if (eff < 100) {
twork = 100 - eff;
if (twork > hcms)
twork = hcms;
}
if (twork > hcms)
twork = hcms;
}
orde(void)
{
int diffeachship = 0;
orde(void)
{
int diffeachship = 0;
- int orders, sub, level;
int scuttling = 0;
struct nstr_item nb;
struct shpstr ship;
int scuttling = 0;
struct nstr_item nb;
struct shpstr ship;
ship.shp_autonav &= ~AN_STANDBY;
break;
case 'd': /* declare path */
ship.shp_autonav &= ~AN_STANDBY;
break;
case 'd': /* declare path */
scuttling = 0;
/* Need location */
p = getstarg(player->argp[3], "Destination? ", buf);
scuttling = 0;
/* Need location */
p = getstarg(player->argp[3], "Destination? ", buf);
-
-
- if (!orders) {
- p = getstarg(player->argp[4], "Second dest? ", buf);
- if (!p)
- return RET_FAIL;
- if (!*p || !strcmp(p, "-")) {
- orders = 1;
- pr("A one-way order has been accepted.\n");
- } else if (!strncmp(p, "s", 1)) {
- if (opt_TRADESHIPS) {
- if (!(mchr[(int)ship.shp_type].m_flags & M_TRADE)) {
- pr("You can't auto-scuttle that ship!\n");
- return RET_SYN;
- }
- } else {
+ p = getstarg(player->argp[4], "Second dest? ", buf);
+ if (!p)
+ return RET_FAIL;
+ if (!*p || !strcmp(p, "-")) {
+ pr("A one-way order has been accepted.\n");
+ } else if (!strncmp(p, "s", 1)) {
+ if (opt_TRADESHIPS) {
+ if (!(mchr[(int)ship.shp_type].m_flags & M_TRADE)) {
pr("You can't auto-scuttle that ship!\n");
return RET_SYN;
}
pr("You can't auto-scuttle that ship!\n");
return RET_SYN;
}
- pr("A scuttle order has been accepted.\n");
- scuttling = 1;
- if (!sarg_xy(p, &p1x, &p1y))
- return RET_SYN;
- pr("A circular order has been accepted.\n");
+ pr("You can't auto-scuttle that ship!\n");
+ return RET_SYN;
+ pr("A scuttle order has been accepted.\n");
+ scuttling = 1;
+ } else {
+ if (!sarg_xy(p, &p1x, &p1y))
+ return RET_SYN;
+ pr("A circular order has been accepted.\n");
sub = sub - 1;;
if (ship.shp_autonav & AN_AUTONAV) {
sub = sub - 1;;
if (ship.shp_autonav & AN_AUTONAV) {
dest = getstarg(player->argp[4], "Start or End? ", buf);
dest = getstarg(player->argp[4], "Start or End? ", buf);
- if (orders) { /* before dest check */
- if (!dest)
- break;
- switch (*dest) {
- default:
- pr("You must enter 'start' or 'end'\n");
- return RET_SYN;
- case 'e':
- case 'E':
- i1 = whatitem(player->argp[5], "Commodity? ");
- if (!i1)
- break;
- else {
- p1 = getstarg(player->argp[6], "Amount? ",
- buf);
- if (!p1)
- return RET_SYN;
- level = atoi(p1);
- }
- if (level < 0) {
- level = 0; /* prevent negatives. */
- pr("You must use positive number! Level set to 0.\n");
- }
- ship.shp_tstart[sub] = i1->i_uid;
- ship.shp_lstart[sub] = level;
- pr("Order Set \n");
+ if (!dest)
+ break;
+ switch (*dest) {
+ default:
+ pr("You must enter 'start' or 'end'\n");
+ return RET_SYN;
+ case 'e':
+ case 'E':
+ i1 = whatitem(player->argp[5], "Commodity? ");
+ if (!i1)
- case 's':
- case 'S':
- i1 = whatitem(player->argp[5], "Commodity? ");
- if (!i1)
- break;
- else {
- p1 = getstarg(player->argp[6], "Amount? ",
- buf);
- if (!p1)
- return RET_SYN;
- level = atoi(p1);
- }
- if (level < 0) {
- level = 0;
- pr("You must use positive number! Level set to 0.\n");
- }
- ship.shp_tend[sub] = i1->i_uid;
- ship.shp_lend[sub] = level;
- pr("Order Set \n");
+ else {
+ p1 = getstarg(player->argp[6], "Amount? ",
+ buf);
+ if (!p1)
+ return RET_SYN;
+ level = atoi(p1);
+ }
+ if (level < 0) {
+ level = 0; /* prevent negatives. */
+ pr("You must use positive number! Level set to 0.\n");
+ }
+ ship.shp_tstart[sub] = i1->i_uid;
+ ship.shp_lstart[sub] = level;
+ pr("Order Set \n");
+ break;
+ case 's':
+ case 'S':
+ i1 = whatitem(player->argp[5], "Commodity? ");
+ if (!i1)
+ else {
+ p1 = getstarg(player->argp[6], "Amount? ",
+ buf);
+ if (!p1)
+ return RET_SYN;
+ level = atoi(p1);
+ }
+ if (level < 0) {
+ level = 0;
+ pr("You must use positive number! Level set to 0.\n");
+ ship.shp_tend[sub] = i1->i_uid;
+ ship.shp_lend[sub] = level;
+ pr("Order Set \n");
+ break;
}
} else
pr("You need to 'declare' a ship path first, see 'info order'\n");
}
} else
pr("You need to 'declare' a ship path first, see 'info order'\n");
struct ichrstr *ip;
struct comstr comm;
int number_set;
struct ichrstr *ip;
struct comstr comm;
int number_set;
int totalcom;
int amt;
int com;
int totalcom;
int amt;
int com;
pr("Sectors need at least 1 mobility to sell goods.\n");
return RET_FAIL;
}
pr("Sectors need at least 1 mobility to sell goods.\n");
return RET_FAIL;
}
p = getstarg(player->argp[3], "Quantity: ", buf);
if (!p || !*p)
return RET_SYN;
p = getstarg(player->argp[3], "Quantity: ", buf);
if (!p || !*p)
return RET_SYN;
int n, hcms, lcms;
int effdone = 0;
int n, hcms, lcms;
int effdone = 0;
if (sp->sct_type != sp->sct_newtype) {
/*
* Tear down existing sector.
if (sp->sct_type != sp->sct_newtype) {
/*
* Tear down existing sector.
routelen = 0; /* path length is now 0 */
mapindex[x][y] = 0; /* mark starting spot */
routelen = 0; /* path length is now 0 */
mapindex[x][y] = 0; /* mark starting spot */
- markedsectors = 1; /* source sector marked */
minx = x - 2; /* set X scan bounds */
maxx = x + 2;
miny = y - 1; /* set Y scan bounds */
minx = x - 2; /* set X scan bounds */
maxx = x + 2;
miny = y - 1; /* set Y scan bounds */
struct plist *interceptor;
struct emp_qelem *att;
struct emp_qelem *in;
struct plist *interceptor;
struct emp_qelem *att;
struct emp_qelem *in;
int more_att;
int more_int;
struct emp_qelem *att_next;
int more_att;
int more_int;
struct emp_qelem *att_next;
att_next = att->q_forw;
attacker = (struct plist *)att;
interceptor = (struct plist *)in;
att_next = att->q_forw;
attacker = (struct plist *)att;
interceptor = (struct plist *)in;
- nplanes = attacker->plane.pln_effic;
- if (nplanes > interceptor->plane.pln_effic)
- nplanes = interceptor->plane.pln_effic;
ac_dog(attacker, interceptor);
in = in_next;
att = att_next;
ac_dog(attacker, interceptor);
in = in_next;
att = att_next;
struct emp_qelem *next;
char msg[255];
struct emp_qelem *next;
char msg[255];
- plp = (struct plist *)list->q_forw;
-
for (qp = list->q_forw; qp != list; qp = next) {
next = qp->q_forw;
plp = (struct plist *)qp;
for (qp = list->q_forw; qp != list; qp = next) {
next = qp->q_forw;
plp = (struct plist *)qp;
{
struct shiplist *s;
int first;
{
struct shiplist *s;
int first;
struct shpstr ship;
s = head;
struct shpstr ship;
s = head;
while (s != NULL) {
getship(s->uid, &ship);
while (s != NULL) {
getship(s->uid, &ship);
- mp = &mchr[(int)ship.shp_type];
if (first) {
pr(" # player->owner eff type\n");
first = 0;
if (first) {
pr(" # player->owner eff type\n");
first = 0;
p = ptr;
while (--col >= 0)
*p++ = ' ';
p = ptr;
while (--col >= 0)
*p++ = ' ';
ptr += MAPWIDTH(size);
}
}
ptr += MAPWIDTH(size);
}
}
taken = llp->unit.land.lnd_item[I_MILIT];
/* Spies always die */
taken = llp->unit.land.lnd_item[I_MILIT];
/* Spies always die */
- if (((struct lchrstr *)llp->chrp)->l_flags & L_SPY) {
- eff_eq = 100;
+ if (((struct lchrstr *)llp->chrp)->l_flags & L_SPY)
llp->unit.land.lnd_effic = 0;
llp->unit.land.lnd_effic = 0;
eff_eq = ldround(cas * 100.0 /
((struct lchrstr *)llp->chrp)->l_item[I_MILIT], 1);
llp->unit.land.lnd_effic -= eff_eq;
eff_eq = ldround(cas * 100.0 /
((struct lchrstr *)llp->chrp)->l_item[I_MILIT], 1);
llp->unit.land.lnd_effic -= eff_eq;
/* move survivors to done */
for (qp = cur.q_back; qp != &cur; qp = next) {
next = qp->q_back;
/* move survivors to done */
for (qp = cur.q_back; qp != &cur; qp = next) {
next = qp->q_back;
- llp = (struct ulist *)qp;
emp_remque(qp);
emp_insque(qp, &done);
}
emp_remque(qp);
emp_insque(qp, &done);
}
switch (bmap) {
default:
CANT_REACH();
switch (bmap) {
default:
CANT_REACH();
/* fall through */
case 'b':
while (bmnxtsct(nsp) && !player->aborted) {
/* fall through */
case 'b':
while (bmnxtsct(nsp) && !player->aborted) {
if (!plp->load)
continue;
if (!plp->load)
continue;
if (plp->pcp->pl_flags & P_A) {
if (roll(100) > pln_identchance(pp, hardtarget, EF_SHIP)) {
wu(0, pp->pln_own,
if (plp->pcp->pl_flags & P_A) {
if (roll(100) > pln_identchance(pp, hardtarget, EF_SHIP)) {
wu(0, pp->pln_own,
int news_item)
{
struct plnstr *pp;
int news_item)
{
struct plnstr *pp;
struct emp_qelem *intlist;
struct emp_qelem intfoo;
struct emp_qelem *qp;
struct emp_qelem *intlist;
struct emp_qelem intfoo;
struct emp_qelem *qp;
pp = &ip->plane;
if (pp->pln_own != sp->sct_own)
continue;
pp = &ip->plane;
if (pp->pln_own != sp->sct_own)
continue;
if (mission_pln_equip(ip, NULL, 'i') < 0) {
emp_remque(qp);
free(qp);
if (mission_pln_equip(ip, NULL, 'i') < 0) {
emp_remque(qp);
free(qp);
next = qp->q_forw;
ip = (struct plist *)qp;
pp = &ip->plane;
next = qp->q_forw;
ip = (struct plist *)qp;
pp = &ip->plane;
if (mission_pln_equip(ip, NULL, 'i') < 0) {
emp_remque(qp);
free(qp);
if (mission_pln_equip(ip, NULL, 'i') < 0) {
emp_remque(qp);
free(qp);
qp = intlist->q_forw;
ip = (struct plist *)qp;
pp = &ip->plane;
qp = intlist->q_forw;
ip = (struct plist *)qp;
pp = &ip->plane;
mpr(msl->pln_own, "%s %s launched in defense!\n",
cname(pp->pln_own), def_name);
mpr(msl->pln_own, "%s %s launched in defense!\n",
cname(pp->pln_own), def_name);
if (sp->shp_own == 0)
return 0;
if (sp->shp_own == 0)
return 0;
if (sp->shp_effic < SHIP_MINEFF) {
wu(0, sp->shp_own,
"%s %s,\nbut it died in the attack, and so couldn't retreat!\n",
if (sp->shp_effic < SHIP_MINEFF) {
wu(0, sp->shp_own,
"%s %s,\nbut it died in the attack, and so couldn't retreat!\n",
if (lp->lnd_own == 0)
return 0;
if (lp->lnd_own == 0)
return 0;
if (lp->lnd_effic < LAND_MINEFF) {
wu(0, lp->lnd_own,
"%s %s,\nbut it died in the attack, and so couldn't retreat!\n",
if (lp->lnd_effic < LAND_MINEFF) {
wu(0, lp->lnd_own,
"%s %s,\nbut it died in the attack, and so couldn't retreat!\n",
* n: random number from -25:75 + (50 - loyalty)
*/
n = (50 - sp->sct_loyal) + ((random() % 100) - 25);
* n: random number from -25:75 + (50 - loyalty)
*/
n = (50 - sp->sct_loyal) + ((random() % 100) - 25);
if (n > 0 && sp->sct_own == sp->sct_oldown) {
che_count = (civ * n / 3000) + 5;
if (che_count * 2 > civ)
if (n > 0 && sp->sct_own == sp->sct_oldown) {
che_count = (civ * n / 3000) + 5;
if (che_count * 2 > civ)
int amt_dst;
int mobility;
double mcost;
int amt_dst;
int mobility;
double mcost;
int n;
if (dir <= 0 || dir > DIR_UL)
int n;
if (dir <= 0 || dir > DIR_UL)
ip->i_name, ownxy(from));
return 0;
}
ip->i_name, ownxy(from));
return 0;
}
- dp = &dchr[from->sct_type];
vtype = ip->i_uid;
mobility = from->sct_mobil / 2;
if (vtype == I_CIVIL) {
vtype = ip->i_uid;
mobility = from->sct_mobil / 2;
if (vtype == I_CIVIL) {
mlp->mobil = sp->shp_mobil;
emp_insque(&mlp->queue, &ship_list);
mlp->mobil = sp->shp_mobil;
emp_insque(&mlp->queue, &ship_list);
- quit = 1; /* setup loop, we want to check it 1 time. */
-
do {
if ((sp->shp_mobil > 0) && (!(sp->shp_autonav & AN_LOADING)) &&
(!(sp->shp_autonav & AN_STANDBY))) {
do {
if ((sp->shp_mobil > 0) && (!(sp->shp_autonav & AN_LOADING)) &&
(!(sp->shp_autonav & AN_STANDBY))) {
if (che > (civ + uw) * 3)
return;
che_uw = 0;
if (che > (civ + uw) * 3)
return;
che_uw = 0;
/* che due to civilian unrest */
n = 10 - (random() % 20);
che_civ = 3 + (civ * n / 500);
/* che due to civilian unrest */
n = 10 - (random() % 20);
che_civ = 3 + (civ * n / 500);
* guerrillas have to resort to blowing things up.
* Note this disrupts work in the sector.
*/
* guerrillas have to resort to blowing things up.
* Note this disrupts work in the sector.
*/
n = (random() % 10) + (random() % che);
if (n > 100)
n = 100;
n = (random() % 10) + (random() % che);
if (n > 100)
n = 100;
/* only military can work on a military boat */
if (mp->m_glim != 0)
wf = etus * ship->shp_item[I_MILIT] / 2;
/* only military can work on a military boat */
if (mp->m_glim != 0)
wf = etus * ship->shp_item[I_MILIT] / 2;
fprintf(script, "newcap %d %d,%d\n", c + 1, capx[c], capy[c]);
}
fprintf(script, "add %d visitor visitor v i\n", c + 1);
fprintf(script, "newcap %d %d,%d\n", c + 1, capx[c], capy[c]);
}
fprintf(script, "add %d visitor visitor v i\n", c + 1);
fclose(script);
return 0;
}
fclose(script);
return 0;
}