Remove a bunch of redundant casts.

This commit is contained in:
Markus Armbruster 2005-06-12 06:31:48 +00:00
parent ee6d72f3b8
commit 4f59fc9967
125 changed files with 417 additions and 432 deletions

View file

@ -143,7 +143,7 @@ add(void)
if (p == 0)
return RET_OK;
snxtitem_all(&ni, EF_LAND);
while (nxtitem(&ni, (s_char *)&land)) {
while (nxtitem(&ni, &land)) {
if (land.lnd_own == coun) {
makelost(EF_LAND, land.lnd_own, land.lnd_uid, land.lnd_x,
land.lnd_y);

View file

@ -101,7 +101,7 @@ arm(void)
nuketype = i;
nukenum = -1;
snxtitem_all(&ni, EF_NUKE);
while (nxtitem(&ni, (s_char *)&nuke)) {
while (nxtitem(&ni, &nuke)) {
if (nuke.nuk_own != player->cnum)
continue;
if (nuke.nuk_x != pl.pln_x || nuke.nuk_y != pl.pln_y)

View file

@ -94,7 +94,7 @@ boar(void)
/* Look for land units with mobility */
snxtitem_xy(&ni, EF_LAND, off->x, off->y);
foundland = 0;
while (nxtitem(&ni, (s_char *)&land)) {
while (nxtitem(&ni, &land)) {
if (land.lnd_own != player->cnum)
continue;
if (land.lnd_ship >= 0)

View file

@ -241,7 +241,7 @@ calc_all(long p_sect[][2],
*planes = *pbuild = *npbuild = *pmaint = 0;
np = getnatp(player->cnum);
bp = (int *)calloc(WORLD_X * WORLD_Y * 8, sizeof(int));
bp = calloc(WORLD_X * WORLD_Y * 8, sizeof(int));
for (n = 0; NULL != (sp = getsectid(n)); n++) {
fill_update_array(bp, sp);
if (sp->sct_own == player->cnum) {

View file

@ -387,7 +387,7 @@ build_ship(struct sctstr *sp, struct mchrstr *mp,
player->dolcost += cost;
cash -= cost;
snxtitem_all(&nstr, EF_SHIP);
while (nxtitem(&nstr, (s_char *)&ship)) {
while (nxtitem(&nstr, &ship)) {
if (ship.shp_own == 0) {
freeship++;
break;
@ -527,7 +527,7 @@ build_land(struct sctstr *sp, struct lchrstr *lp,
player->dolcost += cost;
cash -= cost;
snxtitem_all(&nstr, EF_LAND);
while (nxtitem(&nstr, (s_char *)&land)) {
while (nxtitem(&nstr, &land)) {
if (land.lnd_own == 0) {
freeland++;
break;
@ -848,7 +848,7 @@ build_plane(struct sctstr *sp, struct plchrstr *pp,
cash -= cost;
snxtitem_all(&nstr, EF_PLANE);
freeplane = 0;
while (nxtitem(&nstr, (s_char *)&plane)) {
while (nxtitem(&nstr, &plane)) {
if (plane.pln_own == 0) {
freeplane++;
break;

View file

@ -51,7 +51,7 @@ carg(void)
if (!snxtitem(&ni, EF_SHIP, player->argp[1]))
return RET_SYN;
nships = 0;
while (nxtitem(&ni, (s_char *)&ship)) {
while (nxtitem(&ni, &ship)) {
if (ship.shp_own == 0)
continue;
if ((player->cnum != ship.shp_own) && !player->god)
@ -104,7 +104,7 @@ lcarg(void)
if (!snxtitem(&ni, EF_LAND, player->argp[1]))
return RET_SYN;
nunits = 0;
while (nxtitem(&ni, (s_char *)&land)) {
while (nxtitem(&ni, &land)) {
if (!land.lnd_own)
continue;
if ((player->cnum != land.lnd_own) && !player->god)

View file

@ -158,7 +158,7 @@ cede_sect(struct nstr_sect *ns, natid to)
bad = 0;
}
snxtitem_all(&ni, EF_SHIP);
while (nxtitem(&ni, (s_char *)&ship)) {
while (nxtitem(&ni, &ship)) {
if ((ship.shp_own == to) &&
((ship.shp_x == sect.sct_x) && (ship.shp_y == sect.sct_y)))
bad = 0;
@ -300,14 +300,14 @@ cede_ship(struct nstr_item *ni, natid to)
int nships = 0;
int bad = 0;
while (nxtitem(ni, (s_char *)&ship)) {
while (nxtitem(ni, &ship)) {
if (!player->owner || ship.shp_own == 0)
continue;
bad = 1;
snxtitem_xy(&tni, EF_SHIP, ship.shp_x, ship.shp_y);
while (nxtitem(&tni, (s_char *)&tship) && bad)
while (nxtitem(&tni, &tship) && bad)
if (tship.shp_own == to)
bad = 0;

View file

@ -76,9 +76,9 @@ coas(void)
return RET_SYN;
for (i = 0; i < TSIZE; i++)
list[i] = 0;
cp = (struct coast *)malloc(sizeof(*cp));
cp = malloc(sizeof(*cp));
snxtitem_all(&ni, EF_SHIP);
while (nxtitem(&ni, (s_char *)&cp->c_shp)) {
while (nxtitem(&ni, &cp->c_shp)) {
if (cp->c_shp.shp_own == 0 || cp->c_shp.shp_own == player->cnum)
continue;
/*
@ -94,11 +94,11 @@ coas(void)
cp->c_number = i;
cp->c_next = list[n];
list[n] = cp;
cp = (struct coast *)malloc(sizeof(*cp));
cp = malloc(sizeof(*cp));
nship++;
}
/* get that last one! */
free((s_char *)cp);
free(cp);
pr("- = [ Coastwatch report for %s ] = -\n", cname(player->cnum));
pr(" Country Ship Location\n");
tech = tfact(player->cnum, 1.0);
@ -134,7 +134,7 @@ coas(void)
for (i = 0; i < TSIZE; i++) {
while (NULL != (cp = list[i])) {
list[i] = cp->c_next;
free((s_char *)cp);
free(cp);
}
}
return RET_OK;
@ -154,7 +154,7 @@ showship(struct coast **cpp, int x, int y)
do {
/* we delete it, we free it. */
if (todelete) {
free((s_char *)todelete);
free(todelete);
todelete = 0;
}
if (cp->c_shp.shp_x != x || cp->c_shp.shp_y != y) {
@ -173,6 +173,6 @@ showship(struct coast **cpp, int x, int y)
} while (NULL != (cp = cp->c_next));
/* check that last one! */
if (todelete)
free((s_char *)todelete);
free(todelete);
return (nship);
}

View file

@ -218,7 +218,7 @@ loan_accept(struct ltcomstr *ltcp)
}
/* check to see if a loan already exists */
snxtitem_all(&nstr, EF_LOAN);
while (nxtitem(&nstr, (s_char *)&loan)) {
while (nxtitem(&nstr, &loan)) {
if (loan.l_status == LS_SIGNED && loan.l_lonee == lp->l_loner
&& (loan.l_loner == lp->l_lonee)) {
pr("He already owes you money - make him repay his loan!\n");
@ -240,7 +240,7 @@ loan_accept(struct ltcomstr *ltcp)
(void)time(&lp->l_lastpay);
lp->l_duedate = lp->l_ldur * 86400 + lp->l_lastpay;
lp->l_status = LS_SIGNED;
if (!putloan(ltcp->num, (s_char *)lp)) {
if (!putloan(ltcp->num, lp)) {
pr("Problem writing lp->to disk; get help!\n");
return RET_FAIL;
}

View file

@ -97,7 +97,7 @@ do_conv(struct nstr_sect nstr, int uwtoconvert, int for_real)
* count.
*/
snxtitem_xy(&ni, EF_LAND, sect.sct_x, sect.sct_y);
while (nxtitem(&ni, (s_char *)&land)) {
while (nxtitem(&ni, &land)) {
mil += lnd_getmil(&land);
/* mil += (lnd_getmil(&land) *
((double)land.lnd_effic/100.0));*/

View file

@ -57,7 +57,7 @@ coun(void)
if (!snxtitem(&ni, EF_NATION, player->argp[1]))
return RET_SYN;
first = 1;
while (nxtitem(&ni, (s_char *)&nat)) {
while (nxtitem(&ni, &nat)) {
if ((nat.nat_stat & STAT_INUSE) == 0)
continue;
if (((nat.nat_stat & GOD) != GOD) && !player->god)

View file

@ -99,7 +99,7 @@ decl(void)
}
natp = getnatp(who);
while (nxtitem(&ni, (s_char *)&nat)) {
while (nxtitem(&ni, &nat)) {
if (!(nat.nat_stat & STAT_INUSE))
continue;
if (player->cnum == (natid)ni.cur)

View file

@ -148,7 +148,7 @@ drop(void)
&& ip->i_vtype == I_SHELL)
pln_mine(&bomb_list, &target);
else
pln_dropoff(&bomb_list, ip, tx, ty, (s_char *)&target, EF_SECTOR);
pln_dropoff(&bomb_list, ip, tx, ty, &target, EF_SECTOR);
}
pln_put(&bomb_list);
pln_put(&esc_list);

View file

@ -72,7 +72,7 @@ foll(void)
}
x = ship.shp_x;
y = ship.shp_y;
while (nxtitem(&nstr, (s_char *)&ship)) {
while (nxtitem(&nstr, &ship)) {
if (!player->owner)
continue;
if (ship.shp_x != x || ship.shp_y != y) {

View file

@ -59,7 +59,7 @@ fort(void)
if (fort_amt > land_mob_max)
fort_amt = land_mob_max;
nunits = 0;
while (nxtitem(&ni, (s_char *)&land)) {
while (nxtitem(&ni, &land)) {
if (!player->owner || land.lnd_own == 0)
continue;
if (land.lnd_type < 0 || land.lnd_type > lnd_maxno) {

View file

@ -102,7 +102,7 @@ fuel(void)
return RET_FAIL;
}
while (nxtitem(&ni, (s_char *)&item)) {
while (nxtitem(&ni, &item)) {
fueled = 0;
if (type == EF_SHIP) {
if (item.ship.shp_own != player->cnum) {
@ -222,7 +222,7 @@ fuel(void)
if (!check_ship_ok(&item.ship))
continue;
if (!nxtitem(&tender, (s_char *)&item2))
if (!nxtitem(&tender, &item2))
continue;
if (!(mchr[(int)item2.ship.shp_type].m_flags & M_OILER)) {
@ -384,7 +384,7 @@ fuel(void)
if (!check_land_ok(&item.land))
continue;
if (!nxtitem(&ltender, (s_char *)&item2))
if (!nxtitem(&ltender, &item2))
continue;
if (!(lchr[(int)item2.land.lnd_type].l_flags & L_SUPPLY)) {

View file

@ -71,7 +71,7 @@ hard(void)
return RET_SYN;
natp = getnatp(player->cnum);
cash = natp->nat_money;
while (nxtitem(&ni, (s_char *)&pln)) {
while (nxtitem(&ni, &pln)) {
if (!player->owner)
continue;
pcp = &plchr[(int)pln.pln_type];

View file

@ -93,7 +93,7 @@ head(void)
memset(hist, 0, sizeof(hist));
snxtitem_all(&nstr, EF_NEWS);
maxcnum = 0;
while (nxtitem(&nstr, (s_char *)&news)) {
while (nxtitem(&nstr, &news)) {
news_age = now - news.nws_when;
if (news_age > news_per)
continue;

View file

@ -199,9 +199,9 @@ apro(void)
return RET_SYS;
}
fbuf = (s_char *)malloc(256);
lbuf = (s_char *)malloc(256);
lbp = (s_char *)malloc(256);
fbuf = malloc(256);
lbuf = malloc(256);
lbp = malloc(256);
/*
* lower case search string into lbp
@ -434,9 +434,9 @@ apro(void)
return RET_SYS;
}
fbuf = (s_char *)malloc(256);
lbuf = (s_char *)malloc(256);
lbp = (s_char *)malloc(256);
fbuf = malloc(256);
lbuf = malloc(256);
lbp = malloc(256);
/*
* lower case search string into lbp

View file

@ -51,7 +51,7 @@ land(void)
return RET_SYN;
nunits = 0;
while (nxtitem(&ni, (s_char *)&land)) {
while (nxtitem(&ni, &land)) {
if (land.lnd_own == 0)
continue;
if (!player->owner && !player->god)

View file

@ -70,7 +70,7 @@ laun(void)
if (!snxtitem(&nstr, EF_PLANE, player->argp[1]))
return RET_SYN;
while (nxtitem(&nstr, (s_char *)&plane)) {
while (nxtitem(&nstr, &plane)) {
if (plane.pln_own != player->cnum)
continue;
pcp = &plchr[(int)plane.pln_type];

View file

@ -289,7 +289,7 @@ ldump(void)
pr("\n");
np = getnatp(player->cnum);
while (nxtitem(&ni, (s_char *)&land)) {
while (nxtitem(&ni, &land)) {
if (land.lnd_own == 0)
continue;
if (!player->owner && !player->god)

View file

@ -56,7 +56,7 @@ ledg(void)
return RET_SYN;
pr("\n... %s Ledger ...\n", cname(player->cnum));
nloan = 0;
while (nxtitem(&nstr, (s_char *)&loan)) {
while (nxtitem(&nstr, &loan)) {
if (disloan(nstr.cur, &loan) > 0)
nloan++;
}

View file

@ -112,7 +112,7 @@ load(void)
load_unload = **player->argp == 'l' ? LOAD : UNLOAD;
nships = 0;
while (nxtitem(&nbst, (s_char *)&ship)) {
while (nxtitem(&nbst, &ship)) {
if (!ship.shp_own)
continue;
if (!player->owner && (load_unload == UNLOAD)) {
@ -250,7 +250,7 @@ lload(void)
load_unload = *(*player->argp + 1) == 'l' ? LOAD : UNLOAD;
nunits = 0;
while (nxtitem(&nbst, (s_char *)&land)) {
while (nxtitem(&nbst, &land)) {
if (land.lnd_own == 0)
continue;
@ -402,7 +402,7 @@ load_plane_ship(struct sctstr *sectp, struct shpstr *sp, int noisy,
if (p && *p)
noisy &= isdigit(*p);
while (nxtitem(&ni, (s_char *)&pln)) {
while (nxtitem(&ni, &pln)) {
if (pln.pln_own != player->cnum)
continue;
if (!(plchr[(int)pln.pln_type].pl_flags & P_L)
@ -547,7 +547,7 @@ load_land_ship(struct sctstr *sectp, struct shpstr *sp, int noisy,
if (p && *p)
noisy &= isdigit(*p);
while (nxtitem(&ni, (s_char *)&land)) {
while (nxtitem(&ni, &land)) {
if (land.lnd_own != player->cnum)
continue;
@ -656,7 +656,7 @@ load_land_ship(struct sctstr *sectp, struct shpstr *sp, int noisy,
pr("WARNING: %s is out of supply!\n", prland(&land));
putship(sp->shp_uid, sp);
snxtitem_xy(&pni, EF_PLANE, land.lnd_x, land.lnd_y);
while (nxtitem(&pni, (s_char *)&plane)) {
while (nxtitem(&pni, &plane)) {
if (plane.pln_flags & PLN_LAUNCHED)
continue;
if (plane.pln_land != land.lnd_uid)
@ -698,7 +698,7 @@ load_land_ship(struct sctstr *sectp, struct shpstr *sp, int noisy,
they are quietly unloaded too. */
if (!(lchr[(int)land.lnd_type].l_flags & L_SPY)) {
snxtitem_xy(&pni, EF_PLANE, land.lnd_x, land.lnd_y);
while (nxtitem(&pni, (s_char *)&plane)) {
while (nxtitem(&pni, &plane)) {
if (plane.pln_flags & PLN_LAUNCHED)
continue;
if (plane.pln_land != land.lnd_uid)
@ -857,7 +857,7 @@ load_plane_land(struct sctstr *sectp, struct lndstr *lp, int noisy,
return 0;
}
while (nxtitem(&ni, (s_char *)&pln)) {
while (nxtitem(&ni, &pln)) {
if (pln.pln_own != player->cnum)
continue;
@ -1059,7 +1059,7 @@ load_land_land(struct sctstr *sectp, struct lndstr *lp, int noisy,
if (p && *p)
noisy &= isdigit(*p);
while (nxtitem(&ni, (s_char *)&land)) {
while (nxtitem(&ni, &land)) {
if (land.lnd_own != player->cnum)
continue;
@ -1136,7 +1136,7 @@ load_land_land(struct sctstr *sectp, struct lndstr *lp, int noisy,
pr("WARNING: %s is out of supply!\n", prland(&land));
putland(lp->lnd_uid, lp);
snxtitem_xy(&pni, EF_PLANE, land.lnd_x, land.lnd_y);
while (nxtitem(&pni, (s_char *)&plane)) {
while (nxtitem(&pni, &plane)) {
if (plane.pln_flags & PLN_LAUNCHED)
continue;
if (plane.pln_land != land.lnd_uid)
@ -1168,7 +1168,7 @@ load_land_land(struct sctstr *sectp, struct lndstr *lp, int noisy,
putland(land.lnd_uid, &land);
putland(lp->lnd_uid, lp);
snxtitem_xy(&pni, EF_PLANE, land.lnd_x, land.lnd_y);
while (nxtitem(&pni, (s_char *)&plane)) {
while (nxtitem(&pni, &plane)) {
if (plane.pln_flags & PLN_LAUNCHED)
continue;
if (plane.pln_land != land.lnd_uid)

View file

@ -63,13 +63,13 @@ look(void)
if (!snxtitem(&ni, EF_SHIP, player->argp[1]))
return RET_SYN;
if ((bitmap = (u_char *)malloc((WORLD_X * WORLD_Y) / 8)) == 0) {
if ((bitmap = malloc((WORLD_X * WORLD_Y) / 8)) == 0) {
logerror("malloc failed in look\n");
pr("Memory error. Tell the deity.\n");
return RET_FAIL;
}
memset(bitmap, 0, (WORLD_X * WORLD_Y) / 8);
while (nxtitem(&ni, (s_char *)&myship)) {
while (nxtitem(&ni, &myship)) {
if (!player->owner)
continue;
look_ship(&myship);
@ -107,7 +107,7 @@ look(void)
}
if (changed)
writemap(player->cnum);
free((s_char *)bitmap);
free(bitmap);
return RET_OK;
}
@ -188,13 +188,13 @@ llook(void)
if (!snxtitem(&ni, EF_LAND, player->argp[1]))
return RET_SYN;
if ((bitmap = (u_char *)malloc((WORLD_X * WORLD_Y) / 8)) == 0) {
if ((bitmap = malloc((WORLD_X * WORLD_Y) / 8)) == 0) {
logerror("malloc failed in llook\n");
pr("Memory error. Tell the deity.\n");
return RET_FAIL;
}
memset(bitmap, 0, (WORLD_X * WORLD_Y) / 8);
while (nxtitem(&ni, (s_char *)&myland)) {
while (nxtitem(&ni, &myland)) {
if (!player->owner)
continue;
if (myland.lnd_ship >= 0)
@ -241,7 +241,7 @@ llook(void)
}
if (changed)
writemap(player->cnum);
free((s_char *)bitmap);
free(bitmap);
return RET_OK;
}

View file

@ -60,7 +60,7 @@ lost(void)
if (player->god)
pr("owner ");
pr("type id x y timestamp\n");
while (nxtitem(&ni, (s_char *)&lost)) {
while (nxtitem(&ni, &lost)) {
if (lost.lost_owner == 0)
continue;
if (lost.lost_owner != player->cnum && !player->god)

View file

@ -49,7 +49,7 @@ lsta(void)
return RET_SYN;
nunits = 0;
while (nxtitem(&ni, (s_char *)&land)) {
while (nxtitem(&ni, &land)) {
if (!player->owner || land.lnd_own == 0)
continue;
if (land.lnd_type < 0 || land.lnd_type > lnd_maxno) {

View file

@ -74,7 +74,7 @@ ltend(void)
if (!snxtitem(&tenders, EF_SHIP,
getstarg(player->argp[2], "Tender(s)? ", buf)))
return RET_SYN;
while (nxtitem(&tenders, (s_char *)&tender)) {
while (nxtitem(&tenders, &tender)) {
if (!player->owner)
continue;
if ((p =
@ -103,7 +103,7 @@ ltend(void)
if (!check_ship_ok(&tender))
return RET_FAIL;
total = 0;
while (nxtitem(&targets, (s_char *)&target)) {
while (nxtitem(&targets, &target)) {
if (!player->owner)
continue;

View file

@ -158,7 +158,7 @@ multifire(void)
pr("Fire aborted.\n");
return RET_OK;
}
while (nxtitem(&nbst, (s_char *)&item)) {
while (nxtitem(&nbst, &item)) {
attacker = orig_attacker;
if (attacker == targ_unit) {
if (!getland(item.land.lnd_uid, &fland))
@ -674,7 +674,7 @@ defend(struct emp_qelem *al, struct emp_qelem *dl, enum targ_type target,
(dam = quiet_bigdef(attacker, dl, vict, aown, fx, fy, &nfiring))) {
if (nfiring > *nd)
*nd = nfiring;
fp = (struct flist *)malloc(sizeof(struct flist));
fp = malloc(sizeof(struct flist));
memset(fp, 0, sizeof(struct flist));
fp->defdam = dam;
fp->victim = vict;
@ -742,7 +742,7 @@ do_defdam(struct emp_qelem *list, double odds)
xyas(fp->x, fp->y, vict), dam);
}
emp_remque(&fp->queue);
free((s_char *)fp);
free(fp);
}
}
@ -813,7 +813,7 @@ quiet_bigdef(int attacker, struct emp_qelem *list, natid own, natid aown,
continue;
(*nfiring)++;
fp = (struct flist *)malloc(sizeof(struct flist));
fp = malloc(sizeof(struct flist));
memset(fp, 0, sizeof(struct flist));
fp->type = targ_ship;
fp->uid = ship.shp_uid;
@ -844,7 +844,7 @@ quiet_bigdef(int attacker, struct emp_qelem *list, natid own, natid aown,
if (nshot == 0)
continue;
(*nfiring)++;
fp = (struct flist *)malloc(sizeof(struct flist));
fp = malloc(sizeof(struct flist));
memset(fp, 0, sizeof(struct flist));
fp->type = targ_ship;
fp->uid = ship.shp_uid;
@ -897,7 +897,7 @@ quiet_bigdef(int attacker, struct emp_qelem *list, natid own, natid aown,
land.lnd_ammo, shell);
(*nfiring)++;
fp = (struct flist *)malloc(sizeof(struct flist));
fp = malloc(sizeof(struct flist));
memset(fp, 0, sizeof(struct flist));
fp->type = targ_unit;
fp->uid = land.lnd_uid;
@ -950,7 +950,7 @@ quiet_bigdef(int attacker, struct emp_qelem *list, natid own, natid aown,
if (gun == 0 || firing.sct_item[I_MILIT] < 5 || shell == 0)
continue;
(*nfiring)++;
fp = (struct flist *)malloc(sizeof(struct flist));
fp = malloc(sizeof(struct flist));
memset(fp, 0, sizeof(struct flist));
fp->x = firing.sct_x;
fp->y = firing.sct_y;
@ -1021,7 +1021,7 @@ use_ammo(struct emp_qelem *list)
putland(land.lnd_uid, &land);
emp_remque(&fp->queue);
free((s_char *)fp);
free(fp);
}
}

View file

@ -62,7 +62,7 @@ mine(void)
"Drop how many mines from each ship? ");
if (mines <= 0)
return RET_SYN;
while (nxtitem(&ni, (s_char *)&ship)) {
while (nxtitem(&ni, &ship)) {
if (!player->owner)
continue;
mp = &mchr[(int)ship.shp_type];
@ -107,7 +107,7 @@ landmine(void)
if (!snxtitem(&ni, EF_LAND, player->argp[1]))
return RET_SYN;
while (nxtitem(&ni, (s_char *)&land)) {
while (nxtitem(&ni, &land)) {
if (!player->owner)
continue;
lp = &lchr[(int)land.lnd_type];

View file

@ -190,7 +190,7 @@ mission(void)
size = max(sizeof(struct lndstr), sizeof(struct plnstr));
size = max(size, sizeof(struct shpstr));
block = (s_char *)malloc(size);
block = malloc(size);
switch (type) {
case EF_SHIP:
mobmax = ship_mob_max;

View file

@ -72,7 +72,7 @@ mobq(void)
pr("warning: %d less than optimal\n", mobquota);
}
}
while (nxtitem(&nstr, (s_char *)&ship)) {
while (nxtitem(&nstr, &ship)) {
if (!player->owner)
continue;
if (!oldmq)

View file

@ -54,7 +54,7 @@ morale(void)
if (!snxtitem(&np, EF_LAND, player->argp[1]))
return RET_SYN;
while (!player->aborted && nxtitem(&np, (s_char *)&land)) {
while (!player->aborted && nxtitem(&np, &land)) {
if (!player->owner || land.lnd_own == 0)
continue;
natp = getnatp(land.lnd_own);

View file

@ -57,7 +57,7 @@ name(void)
}
if (!snxtitem(&nb, EF_SHIP, player->argp[1]))
return RET_SYN;
while (nxtitem(&nb, (s_char *)&ship)) {
while (nxtitem(&nb, &ship)) {
if (!player->owner)
continue;
p = getstarg(player->argp[2], "Name? ", buf);

View file

@ -237,20 +237,19 @@ nav_map(int x, int y, int show_designations)
if (!snxtsct(&ns, what))
return RET_FAIL;
if (!wmapbuf)
wmapbuf =
(s_char *)malloc((WORLD_Y * MAPWIDTH(1)) * sizeof(s_char));
wmapbuf = malloc((WORLD_Y * MAPWIDTH(1)) * sizeof(s_char));
if (!wmap) {
wmap = (s_char **)malloc(WORLD_Y * sizeof(s_char *));
wmap = malloc(WORLD_Y * sizeof(s_char *));
if (wmap && wmapbuf) {
for (i = 0; i < WORLD_Y; i++)
wmap[i] = &wmapbuf[MAPWIDTH(1) * i];
} else if (wmap) {
free((s_char *)wmap);
free(wmap);
wmap = (s_char **)0;
}
}
if (!bitmap)
bitmap = (u_char *)malloc((WORLD_X * WORLD_Y) / 8);
bitmap = malloc((WORLD_X * WORLD_Y) / 8);
if (!wmapbuf || !wmap || !bitmap) {
pr("Memory error, tell the deity.\n");
logerror("malloc failed in navi\n");

View file

@ -59,7 +59,7 @@ ndump(void)
pr("own ");
pr("id x y num type\n");
nnukes = 0;
while (nxtitem(&nstr, (s_char *)&nuk)) {
while (nxtitem(&nstr, &nuk)) {
if (!player->god && !player->owner)
continue;
if (nuk.nuk_own == 0)

View file

@ -229,14 +229,14 @@ isok(int x, int y)
nmin = ngold = noil = nur = 0;
navail = nfree = nowned = 0;
if ((map = (s_char *)malloc((WORLD_X * WORLD_Y) / 2)) == 0) {
if ((map = malloc((WORLD_X * WORLD_Y) / 2)) == 0) {
logerror("malloc failed in isok\n");
pr("Memory error. Tell the deity.\n");
return 0;
}
memset(map, 0, (WORLD_X * WORLD_Y) / 2);
ok(map, x, y);
free((s_char *)map);
free(map);
if (nfree < 5)
return 0;
pr("Cap at %s; owned sectors: %d, free sectors: %d, avail: %d\n",
@ -261,7 +261,7 @@ ok(s_char *map, int x, int y)
id = sctoff(x, y);
if (map[id])
return;
if (!ef_read(EF_SECTOR, id, (s_char *)&sect))
if (!ef_read(EF_SECTOR, id, &sect))
return;
if (sect.sct_type == SCT_WATER || sect.sct_type == SCT_BSPAN)
return;
@ -302,7 +302,7 @@ deity_build_land(int type, coord x, coord y, natid own, int tlev)
natp = getnatp(own);
snxtitem_all(&nstr, EF_LAND);
while (nxtitem(&nstr, (s_char *)&land)) {
while (nxtitem(&nstr, &land)) {
if (land.lnd_own == 0) {
extend = 0;
break;

View file

@ -89,7 +89,7 @@ news(void)
then = now - days(3);
*/
pr("\nThe details of Empire news since %s", ctime(&then));
while (nxtitem(&nstr, (s_char *)&nws)) {
while (nxtitem(&nstr, &nws)) {
if (nws.nws_when < then)
continue;
if (opt_HIDDEN) {
@ -106,7 +106,7 @@ news(void)
continue;
pr("\n\t === %s ===\n", page_headings[page]);
snxtitem_rewind(&nstr);
while (nxtitem(&nstr, (s_char *)&nws)) {
while (nxtitem(&nstr, &nws)) {
if (rpt[(int)nws.nws_vrb].r_newspage != page)
continue;
if (nws.nws_when < then)

View file

@ -55,7 +55,7 @@ nuke(void)
if (!snxtitem(&nstr, EF_NUKE, player->argp[1]))
return RET_SYN;
while (nxtitem(&nstr, (s_char *)&nuk)) {
while (nxtitem(&nstr, &nuk)) {
if (!player->god && !player->owner)
continue;
if (nuk.nuk_own == 0)

View file

@ -135,7 +135,7 @@ do_treaty(void)
}
(void)time(&now);
snxtitem_all(&nstr, EF_TREATY);
while (nxtitem(&nstr, (s_char *)&trty)) {
while (nxtitem(&nstr, &trty)) {
if (trty.trt_status == TS_FREE) {
break;
}
@ -212,7 +212,7 @@ do_loan(void)
if (irate < 5)
return RET_FAIL;
snxtitem_all(&nstr, EF_LOAN);
while (nxtitem(&nstr, (s_char *)&loan)) {
while (nxtitem(&nstr, &loan)) {
if ((loan.l_status == LS_SIGNED) && (loan.l_lonee == player->cnum)
&& (loan.l_loner == recipient)) {
pr("You already owe HIM money - how about repaying your loan?\n");
@ -220,7 +220,7 @@ do_loan(void)
}
}
snxtitem_all(&nstr, EF_LOAN);
while (nxtitem(&nstr, (s_char *)&loan)) {
while (nxtitem(&nstr, &loan)) {
if (loan.l_status == LS_FREE)
break;
}

View file

@ -83,7 +83,7 @@ orde(void)
if (!snxtitem(&nb, EF_SHIP, player->argp[1]))
return RET_SYN;
while (!player->aborted && nxtitem(&nb, (s_char *)(&ship))) {
while (!player->aborted && nxtitem(&nb, (&ship))) {
if (!player->owner || ship.shp_own == 0)
continue;
if (ship.shp_type < 0 || ship.shp_type > shp_maxno) {
@ -370,7 +370,7 @@ qorde(void)
if (!snxtitem(&nb, EF_SHIP, player->argp[1]))
return RET_SYN;
while (nxtitem(&nb, (s_char *)(&ship))) {
while (nxtitem(&nb, (&ship))) {
if (!player->owner || ship.shp_own == 0)
continue;
if (ship.shp_type < 0 || ship.shp_type > shp_maxno) {
@ -444,7 +444,7 @@ sorde(void)
if (!snxtitem(&nb, EF_SHIP, player->argp[1]))
return RET_SYN;
while (nxtitem(&nb, (s_char *)(&ship))) {
while (nxtitem(&nb, (&ship))) {
if (!player->owner || ship.shp_own == 0)
continue;
if (ship.shp_type < 0 || ship.shp_type > shp_maxno) {

View file

@ -80,15 +80,14 @@ path(void)
return RET_FAIL;
}
if (!mapbuf)
mapbuf =
(s_char *)malloc((WORLD_Y * MAPWIDTH(3)) * sizeof(s_char));
mapbuf = malloc((WORLD_Y * MAPWIDTH(3)) * sizeof(s_char));
if (!map) {
map = (s_char **)malloc(WORLD_Y * sizeof(s_char *));
map = malloc(WORLD_Y * sizeof(s_char *));
if (map && mapbuf) {
for (i = 0; i < WORLD_Y; i++)
map[i] = &mapbuf[MAPWIDTH(3) * i];
} else if (map) {
free((s_char *)map);
free(map);
map = (s_char **)0;
}
}

View file

@ -61,7 +61,7 @@ payo(void)
return RET_SYN;
nships = 0;
while (nxtitem(&ni, (s_char *)&ship)) {
while (nxtitem(&ni, &ship)) {
if (!player->owner || ship.shp_own == 0)
continue;
if (ship.shp_type < 0 || ship.shp_type > shp_maxno) {

View file

@ -46,7 +46,7 @@ pboa(void)
if (!snxtitem(&np, EF_PLANE, player->argp[1]))
return RET_SYN;
while (nxtitem(&np, (s_char *)&plane)) {
while (nxtitem(&np, &plane)) {
getsect(plane.pln_x, plane.pln_y, &sect);
if (sect.sct_own != player->cnum)
continue;

View file

@ -200,7 +200,7 @@ pdump(void)
nplanes = 0;
natp = getnatp(player->cnum);
while (nxtitem(&np, (s_char *)&plane)) {
while (nxtitem(&np, &plane)) {
if (!player->owner || plane.pln_own == 0)
continue;
nplanes++;

View file

@ -51,7 +51,7 @@ plan(void)
if (!snxtitem(&np, EF_PLANE, player->argp[1]))
return RET_SYN;
nplanes = 0;
while (nxtitem(&np, (s_char *)&plane)) {
while (nxtitem(&np, &plane)) {
if (!player->owner || plane.pln_own == 0)
continue;
if (nplanes++ == 0) {

View file

@ -124,7 +124,7 @@ powe(void)
if (!power_generated) {
snxtitem_all(&ni, EF_POWER);
if (!nxtitem(&ni, (s_char *)&pow)) {
if (!nxtitem(&ni, &pow)) {
pr("Power for this game has not been built yet. Type 'power new' to build it.\n");
return RET_FAIL;
}
@ -134,7 +134,7 @@ powe(void)
pr(" as of %s\n sects eff civ", ctime(&pow_time));
pr(" mil shell gun pet iron dust oil pln ship unit money\n");
snxtitem_all(&ni, EF_POWER);
while ((nxtitem(&ni, (s_char *)&pow)) && num > 0) {
while ((nxtitem(&ni, &pow)) && num > 0) {
if (pow.p_nation == 0 || pow.p_power <= 0.0)
continue;
if (opt_HIDDEN) {
@ -251,7 +251,7 @@ gen_power(void)
addtopow(sect.sct_item, pow);
}
snxtitem_all(&ni, EF_LAND);
while (nxtitem(&ni, (s_char *)&land)) {
while (nxtitem(&ni, &land)) {
if (land.lnd_own == 0)
continue;
pow = &powbuf[land.lnd_own];
@ -262,7 +262,7 @@ gen_power(void)
pow->p_units += 1.0;
}
snxtitem_all(&ni, EF_SHIP);
while (nxtitem(&ni, (s_char *)&ship)) {
while (nxtitem(&ni, &ship)) {
if (ship.shp_own == 0)
continue;
pow = &powbuf[ship.shp_own];
@ -273,7 +273,7 @@ gen_power(void)
pow->p_ships += 1.0;
}
snxtitem_all(&ni, EF_PLANE);
while (nxtitem(&ni, (s_char *)&plane)) {
while (nxtitem(&ni, &plane)) {
if (plane.pln_own == 0)
continue;
pow = &powbuf[plane.pln_own];

View file

@ -49,7 +49,7 @@ pstat(void)
if (!snxtitem(&np, EF_PLANE, player->argp[1]))
return RET_SYN;
nplanes = 0;
while (nxtitem(&np, (s_char *)&plane)) {
while (nxtitem(&np, &plane)) {
if (!player->owner || plane.pln_own == 0)
continue;
if (plane.pln_type < 0 || plane.pln_type > pln_maxno) {

View file

@ -94,7 +94,7 @@ rada(void)
pr("Specify at least one ship\n");
return RET_SYN;
}
while (nxtitem(&ni, (s_char *)&ship)) {
while (nxtitem(&ni, &ship)) {
if (!player->owner)
continue;
if (mchr[(int)ship.shp_type].m_flags & M_SONAR)
@ -117,7 +117,7 @@ rada(void)
pr("Specify at least one unit\n");
return RET_SYN;
}
while (nxtitem(&ni, (s_char *)&land)) {
while (nxtitem(&ni, &land)) {
if (!player->owner)
continue;
if (!(lchr[(int)land.lnd_type].l_flags & L_RADAR)) {

View file

@ -50,7 +50,7 @@ range(void)
if (!snxtitem(&np, EF_PLANE, player->argp[1]))
return RET_SYN;
while (nxtitem(&np, (s_char *)&plane)) {
while (nxtitem(&np, &plane)) {
if (!player->owner || plane.pln_own == 0)
continue;
p = getstarg(player->argp[2], "New range? ", buf);
@ -82,7 +82,7 @@ lrange(void)
if (!snxtitem(&np, EF_LAND, player->argp[1]))
return RET_SYN;
while (nxtitem(&np, (s_char *)&land)) {
while (nxtitem(&np, &land)) {
if (!player->owner || land.lnd_own == 0)
continue;
lcp = &lchr[(int)land.lnd_type];

View file

@ -117,7 +117,7 @@ rea(void)
lastdate = 0;
lastcnum = -1;
lasttype = -1;
while (fread((s_char *)&tgm, sizeof(tgm), 1, telfp) == 1) {
while (fread(&tgm, sizeof(tgm), 1, telfp) == 1) {
readit = 1;
if (tgm.tel_length < 0) {
logerror("bad telegram file header in %s", mbox);

View file

@ -86,7 +86,7 @@ reje(void)
}
if (!snxtitem(&ni, EF_NATION, player->argp[3]))
return RET_SYN;
while (nxtitem(&ni, (s_char *)&nat)) {
while (nxtitem(&ni, &nat)) {
#if 0
if ((nat.nat_stat & STAT_NORM) == 0) {
pr("You may not reject/accept stuff from %s\nbecause they are not a normal country.\n", nat.nat_cnam);

View file

@ -88,7 +88,7 @@ repo(void)
} else {
first = 1;
}
while (nxtitem(&ni, (s_char *)&nat)) {
while (nxtitem(&ni, &nat)) {
if (!(nat.nat_stat & STAT_INUSE))
continue;
if (opt_HIDDEN) {

View file

@ -132,7 +132,7 @@ retr(void)
if (zero)
rflags = 0;
while (nxtitem(&ni, (s_char *)&ship)) {
while (nxtitem(&ni, &ship)) {
if (!player->owner || ship.shp_own == 0)
continue;
if (ship.shp_type < 0 || ship.shp_type > shp_maxno) {
@ -261,7 +261,7 @@ lretr(void)
if (zero)
rflags = 0;
while (nxtitem(&ni, (s_char *)&land)) {
while (nxtitem(&ni, &land)) {
if (!player->owner || land.lnd_own == 0)
continue;
if (land.lnd_type < 0 || land.lnd_type > lnd_maxno) {

View file

@ -88,20 +88,19 @@ rout(void)
} else if (!snxtsct(&ns, str))
return RET_FAIL;
if (!mapbuf)
mapbuf =
(s_char *)malloc((WORLD_Y * MAPWIDTH(3)) * sizeof(s_char));
mapbuf = malloc((WORLD_Y * MAPWIDTH(3)) * sizeof(s_char));
if (!map) {
map = (s_char **)malloc(WORLD_Y * sizeof(s_char *));
map = malloc(WORLD_Y * sizeof(s_char *));
if (map && mapbuf) {
for (i = 0; i < WORLD_Y; i++)
map[i] = &mapbuf[MAPWIDTH(3) * i];
} else if (map) {
free((s_char *)map);
free(map);
map = (s_char **)0;
}
}
if (!buf)
buf = (s_char *)malloc((MAPWIDTH(3) + 12) * sizeof(s_char));
buf = malloc((MAPWIDTH(3) + 12) * sizeof(s_char));
if (!mapbuf || !map || !buf) {
pr("Memory error, tell the deity.\n");
logerror("malloc failed in rout\n");

View file

@ -49,7 +49,7 @@ sabo(void)
if (!snxtitem(&ni, EF_LAND, player->argp[1]))
return RET_SYN;
while (nxtitem(&ni, (s_char *)&land)) {
while (nxtitem(&ni, &land)) {
if (!player->owner)
continue;
if (!(lchr[(int)land.lnd_type].l_flags & L_SPY)) {

View file

@ -48,7 +48,7 @@ show_sail(struct nstr_item *nstr)
int count = 0;
struct shpstr ship;
while (nxtitem(nstr, (s_char *)&ship)) {
while (nxtitem(nstr, &ship)) {
if (!player->owner || ship.shp_own == 0)
continue;
if (ship.shp_type < 0 || ship.shp_type > shp_maxno) {
@ -100,7 +100,7 @@ cmd_unsail_ship(struct nstr_item *nstr)
struct shpstr ship;
int count = 0;
while (nxtitem(nstr, (s_char *)&ship)) {
while (nxtitem(nstr, &ship)) {
if (!player->owner || ship.shp_own == 0)
continue;
if (ship.shp_type < 0 || ship.shp_type > shp_maxno) {
@ -124,7 +124,7 @@ cmd_sail_ship(struct nstr_item *nstr)
struct shpstr ship;
char navpath[MAX_PATH_LEN];
while (!player->aborted && nxtitem(nstr, (s_char *)&ship)) {
while (!player->aborted && nxtitem(nstr, &ship)) {
if (!player->owner || ship.shp_own == 0)
continue;
if (ship.shp_type < 0 || ship.shp_type > shp_maxno) {

View file

@ -136,7 +136,7 @@ scra(void)
if (!confirm(y_or_n))
return RET_FAIL;
}
while (nxtitem(&ni, (s_char *)&item)) {
while (nxtitem(&ni, &item)) {
if (!player->owner)
continue;
@ -192,7 +192,7 @@ scra(void)
sect.sct_item[I_HCM] += mp->m_hcm * 2 / 3 * eff;
getsect(item.ship.shp_x, item.ship.shp_y, &sect2);
snxtitem_all(&ni2, EF_PLANE);
while (nxtitem(&ni2, (s_char *)&plane)) {
while (nxtitem(&ni2, &plane)) {
if (plane.pln_own == 0)
continue;
if (plane.pln_ship == item.ship.shp_uid) {
@ -214,11 +214,11 @@ scra(void)
plane.pln_own = sect2.sct_own;
makenotlost(EF_PLANE, plane.pln_own, plane.pln_uid,
plane.pln_x, plane.pln_y);
putplane(plane.pln_uid, (s_char *)&plane);
putplane(plane.pln_uid, &plane);
}
}
snxtitem_all(&ni2, EF_LAND);
while (nxtitem(&ni2, (s_char *)&land)) {
while (nxtitem(&ni2, &land)) {
if (land.lnd_own == 0)
continue;
if (land.lnd_ship == item.ship.shp_uid) {
@ -240,13 +240,13 @@ scra(void)
land.lnd_own = sect2.sct_own;
makenotlost(EF_LAND, land.lnd_own, land.lnd_uid,
land.lnd_x, land.lnd_y);
putland(land.lnd_uid, (s_char *)&land);
putland(land.lnd_uid, &land);
}
}
makelost(EF_SHIP, item.ship.shp_own, item.ship.shp_uid,
item.ship.shp_x, item.ship.shp_y);
item.ship.shp_own = 0;
putship(item.ship.shp_uid, (s_char *)&item.ship);
putship(item.ship.shp_uid, &item.ship);
} else if (type == EF_LAND) {
eff = ((float)item.land.lnd_effic / 100.0);
lp = &lchr[(int)item.land.lnd_type];
@ -259,7 +259,7 @@ scra(void)
getsect(item.land.lnd_x, item.land.lnd_y, &sect2);
snxtitem_all(&ni2, EF_LAND);
while (nxtitem(&ni2, (s_char *)&land)) {
while (nxtitem(&ni2, &land)) {
if (land.lnd_own == 0)
continue;
if (land.lnd_land == item.land.lnd_uid) {
@ -281,12 +281,12 @@ scra(void)
land.lnd_own = sect2.sct_own;
makenotlost(EF_LAND, land.lnd_own, land.lnd_uid,
land.lnd_x, land.lnd_y);
putland(land.lnd_uid, (s_char *)&land);
putland(land.lnd_uid, &land);
}
}
snxtitem_all(&ni2, EF_PLANE);
while (nxtitem(&ni2, (s_char *)&plane)) {
while (nxtitem(&ni2, &plane)) {
if (plane.pln_own == 0)
continue;
if (plane.pln_land == item.land.lnd_uid) {
@ -308,13 +308,13 @@ scra(void)
plane.pln_own = sect2.sct_own;
makenotlost(EF_PLANE, plane.pln_own, plane.pln_uid,
plane.pln_x, plane.pln_y);
putplane(plane.pln_uid, (s_char *)&plane);
putplane(plane.pln_uid, &plane);
}
}
makelost(EF_LAND, item.land.lnd_own, item.land.lnd_uid,
item.land.lnd_x, item.land.lnd_y);
item.land.lnd_own = 0;
putland(item.land.lnd_uid, (s_char *)&item.land);
putland(item.land.lnd_uid, &item.land);
} else {
eff = ((float)item.land.lnd_effic / 100.0);
pp = &plchr[(int)item.plane.pln_type];
@ -325,7 +325,7 @@ scra(void)
makelost(EF_PLANE, item.plane.pln_own, item.plane.pln_uid,
item.plane.pln_x, item.plane.pln_y);
item.plane.pln_own = 0;
putplane(item.plane.pln_uid, (s_char *)&item.plane);
putplane(item.plane.pln_uid, &item.plane);
}
pr(" scrapped in %s\n",
xyas(sect.sct_x, sect.sct_y, player->cnum));

View file

@ -203,7 +203,7 @@ scut(void)
if (!confirm(y_or_n))
return RET_FAIL;
}
while (nxtitem(&ni, (s_char *)&item)) {
while (nxtitem(&ni, &item)) {
if (!player->owner)
continue;
if (opt_MARKET) {
@ -241,7 +241,7 @@ scut(void)
makelost(EF_PLANE, item.plane.pln_own, item.plane.pln_uid,
item.plane.pln_x, item.plane.pln_y);
item.plane.pln_own = 0;
putplane(item.plane.pln_uid, (s_char *)&item.plane);
putplane(item.plane.pln_uid, &item.plane);
}
pr(" scuttled in %s\n",
xyas(item.ship.shp_x, item.ship.shp_y, player->cnum));
@ -260,7 +260,7 @@ scuttle_ship(struct shpstr *sp)
getsect(sp->shp_x, sp->shp_y, &sect);
snxtitem_all(&ni, EF_PLANE);
while (nxtitem(&ni, (s_char *)&plane)) {
while (nxtitem(&ni, &plane)) {
if (plane.pln_own == 0)
continue;
if (plane.pln_ship == sp->shp_uid) {
@ -278,11 +278,11 @@ scuttle_ship(struct shpstr *sp)
plane.pln_uid, sp->shp_uid,
xyas(plane.pln_x, plane.pln_y, plane.pln_own));
}
putplane(plane.pln_uid, (s_char *)&plane);
putplane(plane.pln_uid, &plane);
}
}
snxtitem_all(&ni, EF_LAND);
while (nxtitem(&ni, (s_char *)&land)) {
while (nxtitem(&ni, &land)) {
if (land.lnd_own == 0)
continue;
if (land.lnd_ship == sp->shp_uid) {
@ -292,7 +292,7 @@ scuttle_ship(struct shpstr *sp)
"Land unit %d transferred off ship %d to %s\n",
land.lnd_uid, sp->shp_uid,
xyas(land.lnd_x, land.lnd_y, land.lnd_own));
putland(land.lnd_uid, (s_char *)&land);
putland(land.lnd_uid, &land);
} else
scuttle_land(&land);
}
@ -312,7 +312,7 @@ scuttle_land(struct lndstr *lp)
getsect(lp->lnd_x, lp->lnd_y, &sect);
snxtitem_all(&ni, EF_PLANE);
while (nxtitem(&ni, (s_char *)&plane)) {
while (nxtitem(&ni, &plane)) {
if (plane.pln_own == 0)
continue;
if (plane.pln_land == lp->lnd_uid) {
@ -330,11 +330,11 @@ scuttle_land(struct lndstr *lp)
plane.pln_uid, lp->lnd_uid,
xyas(plane.pln_x, plane.pln_y, plane.pln_own));
}
putplane(plane.pln_uid, (s_char *)&plane);
putplane(plane.pln_uid, &plane);
}
}
snxtitem_all(&ni, EF_LAND);
while (nxtitem(&ni, (s_char *)&land)) {
while (nxtitem(&ni, &land)) {
if (land.lnd_own == 0)
continue;
if (land.lnd_land == lp->lnd_uid) {
@ -344,7 +344,7 @@ scuttle_land(struct lndstr *lp)
"Land unit %d transferred off unit %d to %s\n",
land.lnd_uid, lp->lnd_uid,
xyas(land.lnd_x, land.lnd_y, land.lnd_own));
putland(land.lnd_uid, (s_char *)&land);
putland(land.lnd_uid, &land);
} else
scuttle_land(&land);
}

View file

@ -264,7 +264,7 @@ sdump(void)
nships = 0;
np = getnatp(player->cnum);
while (nxtitem(&ni, (s_char *)&ship)) {
while (nxtitem(&ni, &ship)) {
if (!player->owner || ship.shp_own == 0)
continue;
if (ship.shp_type < 0 || ship.shp_type > shp_maxno) {

View file

@ -80,15 +80,14 @@ sct(void)
} else if (!snxtsct(&ns, str))
return RET_SYN;
if (!mapbuf)
mapbuf =
(s_char *)malloc((WORLD_Y * MAPWIDTH(1)) * sizeof(s_char));
mapbuf = malloc((WORLD_Y * MAPWIDTH(1)) * sizeof(s_char));
if (!map) {
map = (s_char **)malloc(WORLD_Y * sizeof(s_char *));
map = malloc(WORLD_Y * sizeof(s_char *));
if (map && mapbuf) {
for (i = 0; i < WORLD_Y; i++)
map[i] = &mapbuf[MAPWIDTH(1) * i];
} else if (map) {
free((s_char *)map);
free(map);
map = (s_char **)0;
}
}

View file

@ -90,7 +90,7 @@ set(void)
type = EF_LAND;
if (!snxtitem(&ni, type, player->argp[2]))
return RET_SYN;
while (nxtitem(&ni, (char *)&item)) {
while (nxtitem(&ni, &item)) {
if (!player->owner && !player->god)
continue;
getsect(item.gen.trg_x, item.gen.trg_y, &sect);
@ -113,7 +113,7 @@ set(void)
foundslot = -1;
freeslot = -1;
snxtitem_all(&ni_trade, EF_TRADE);
while (nxtitem(&ni_trade, (char *)&trade)) {
while (nxtitem(&ni_trade, &trade)) {
if (trade.trd_owner == 0)
freeslot = ni_trade.cur;
if (trade.trd_unitid == ni.cur && trade.trd_type == type) {

View file

@ -52,7 +52,7 @@ shi(void)
return RET_SYN;
nships = 0;
while (nxtitem(&ni, (s_char *)&ship)) {
while (nxtitem(&ni, &ship)) {
if (!player->owner || ship.shp_own == 0)
continue;
if (ship.shp_type < 0 || ship.shp_type > shp_maxno) {

View file

@ -80,7 +80,7 @@ shoo(void)
mil = sect.sct_item[I_MILIT];
nsec = 0;
snxtitem_xy(&ni, EF_LAND, sect.sct_x, sect.sct_y);
while (nxtitem(&ni, (s_char *)&land)) {
while (nxtitem(&ni, &land)) {
mil += total_mil(&land);
if (lchr[(int)land.lnd_type].l_flags & L_SECURITY) {

View file

@ -74,9 +74,9 @@ skyw(void)
return RET_SYN;
for (i = 0; i < TSIZE; i++)
list[i] = 0;
skyp = (struct sky *)malloc(sizeof(*skyp));
skyp = malloc(sizeof(*skyp));
snxtitem_all(&ni, EF_PLANE);
while (nxtitem(&ni, (s_char *)&skyp->s_sat)) {
while (nxtitem(&ni, &skyp->s_sat)) {
if (!skyp->s_sat.pln_own)
continue;
if (!(skyp->s_sat.pln_flags & PLN_LAUNCHED))
@ -86,11 +86,11 @@ skyw(void)
skyp->s_spotted = 0;
skyp->s_next = list[n];
list[n] = skyp;
skyp = (struct sky *)malloc(sizeof(*skyp));
skyp = malloc(sizeof(*skyp));
nsat++;
}
/* get that last one! */
free((s_char *)skyp);
free(skyp);
pr("- = [ Skywatch report for %s ] = -\n", cname(player->cnum));
pr(" %18s%20s %s\n", "Country", "Satellite", "Location");
tech = tfact(player->cnum, 1.0);
@ -126,7 +126,7 @@ skyw(void)
for (i = 0; i < TSIZE; i++) {
while (NULL != (skyp = list[i])) {
list[i] = skyp->s_next;
free((s_char *)skyp);
free(skyp);
}
}
return RET_OK;
@ -148,7 +148,7 @@ showsat(struct sky **skypp, int x, int y)
do {
/* we delete it, we free it. */
if (todelete) {
free((s_char *)todelete);
free(todelete);
todelete = 0;
}
if (skyp->s_sat.pln_x != x || skyp->s_sat.pln_y != y) {
@ -170,6 +170,6 @@ showsat(struct sky **skypp, int x, int y)
} while (NULL != (skyp = skyp->s_next));
/* check that last one! */
if (todelete)
free((s_char *)todelete);
free(todelete);
return (nsat);
}

View file

@ -80,30 +80,28 @@ sona(void)
if (!snxtitem(&ni, EF_SHIP, player->argp[1]))
return RET_SYN;
if (!radbuf)
radbuf =
(s_char *)malloc((WORLD_Y * (WORLD_X + 1)) * sizeof(s_char));
radbuf = malloc((WORLD_Y * (WORLD_X + 1)) * sizeof(s_char));
if (!visbuf)
visbuf =
(s_char *)malloc((WORLD_Y * (WORLD_X + 1)) * sizeof(s_char));
visbuf = malloc((WORLD_Y * (WORLD_X + 1)) * sizeof(s_char));
if (!rad) {
rad = (s_char **)malloc(WORLD_Y * sizeof(s_char *));
rad = malloc(WORLD_Y * sizeof(s_char *));
if (rad && radbuf) {
for (x = 0; x < WORLD_Y; x++) {
rad[x] = &radbuf[(WORLD_X + 1) * x];
}
} else if (rad) {
free((s_char *)rad);
free(rad);
rad = (s_char **)0;
}
}
if (!vis) {
vis = (s_char **)malloc(WORLD_Y * sizeof(s_char *));
vis = malloc(WORLD_Y * sizeof(s_char *));
if (vis && visbuf) {
for (x = 0; x < WORLD_Y; x++) {
vis[x] = &visbuf[(WORLD_X + 1) * x];
}
} else if (vis) {
free((s_char *)vis);
free(vis);
vis = (s_char **)0;
}
}
@ -112,7 +110,7 @@ sona(void)
logerror("malloc failed in sona\n");
return RET_FAIL;
}
while (nxtitem(&ni, (s_char *)&ship)) {
while (nxtitem(&ni, &ship)) {
if (!player->owner)
continue;
mcp = &mchr[(int)ship.shp_type];

View file

@ -99,7 +99,7 @@ spy(void)
* set up all the goodies we need later
* 6 = neighbors, 2 = x,y
*/
table = (coord *)malloc((nsects + 1) * 6 * 2 * sizeof(coord));
table = malloc((nsects + 1) * 6 * 2 * sizeof(coord));
memset(table, 0, (nsects + 1) * 6 * 2 * sizeof(coord));
pr("SPY report\n");
prdate();
@ -111,7 +111,7 @@ spy(void)
nrecon = 0;
nunits = 0;
snxtitem_xy(&ni, EF_LAND, from.sct_x, from.sct_y);
while (nxtitem(&ni, (s_char *)&land)) {
while (nxtitem(&ni, &land)) {
nunits++;
if (lchr[(int)land.lnd_type].l_flags & L_RECON)
nrecon++;
@ -208,7 +208,7 @@ spy(void)
if (changed)
writemap(player->cnum);
player->btused += btucost;
free((s_char *)table);
free(table);
return RET_OK;
}
@ -275,7 +275,7 @@ num_units(int x, int y)
int n = 0;
snxtitem_xy(&ni, EF_LAND, x, y);
while (nxtitem(&ni, (s_char *)&land)) {
while (nxtitem(&ni, &land)) {
if ((land.lnd_own == player->cnum) || (land.lnd_own == 0))
continue;
if (land.lnd_ship >= 0 || land.lnd_land >= 0)
@ -294,7 +294,7 @@ prunits(int x, int y)
s_char report[128];
snxtitem_xy(&ni, EF_LAND, x, y);
while (nxtitem(&ni, (s_char *)&land)) {
while (nxtitem(&ni, &land)) {
if (land.lnd_own == player->cnum || land.lnd_own == 0)
continue;
if (land.lnd_ship >= 0 || land.lnd_land >= 0)
@ -330,7 +330,7 @@ prplanes(int x, int y)
s_char report[128];
snxtitem_xy(&ni, EF_PLANE, x, y);
while (nxtitem(&ni, (s_char *)&plane)) {
while (nxtitem(&ni, &plane)) {
if (plane.pln_own == player->cnum || plane.pln_own == 0)
continue;
if (plane.pln_ship >= 0 || plane.pln_land >= 0)

View file

@ -49,7 +49,7 @@ sstat(void)
return RET_SYN;
nships = 0;
while (nxtitem(&ni, (s_char *)&ship)) {
while (nxtitem(&ni, &ship)) {
if (!player->owner || ship.shp_own == 0)
continue;
if (ship.shp_type < 0 || ship.shp_type > shp_maxno) {

View file

@ -126,7 +126,7 @@ units_in_sector(struct combat *def)
struct lndstr land;
snxtitem_xy(&ni, EF_LAND, def->x, def->y);
while (nxtitem(&ni, (s_char *)&land)) {
while (nxtitem(&ni, &land)) {
if (land.lnd_own == 0)
continue;
if (land.lnd_own != def->own)

View file

@ -166,7 +166,7 @@ starv_ships(s_char *range)
if (!snxtitem(&ni, EF_SHIP, range))
return;
while (nxtitem(&ni, (s_char *)&ship)) {
while (nxtitem(&ni, &ship)) {
if (!player->owner || !ship.shp_own)
continue;
@ -214,7 +214,7 @@ starv_units(s_char *range)
if (!snxtitem(&ni, EF_LAND, range))
return;
while (nxtitem(&ni, (s_char *)&land)) {
while (nxtitem(&ni, &land)) {
if (!player->owner || !land.lnd_own)
continue;

View file

@ -49,7 +49,7 @@ supp(void)
return RET_SYN;
nunits = 0;
while (nxtitem(&ni, (s_char *)&land)) {
while (nxtitem(&ni, &land)) {
if (!player->owner || land.lnd_own == 0)
continue;
nunits++;

View file

@ -106,7 +106,7 @@ surv(void)
for (i = 0; i < WORLD_Y; i++)
map[i] = &mapbuf[MAPWIDTH(1) * i];
} else if (map) {
free((s_char *)map);
free(map);
map = (s_char **)0;
}
}

View file

@ -90,7 +90,7 @@ tend(void)
getstarg(player->argp[2], "Tender(s)? ", buf)))
return RET_SYN;
while (nxtitem(&tenders, (s_char *)&tender)) {
while (nxtitem(&tenders, &tender)) {
if (!player->owner)
continue;
if (type == EF_LAND) {
@ -211,7 +211,7 @@ tend_land(struct shpstr *tenderp, s_char *units)
if (!snxtitem(&lni, EF_LAND, units))
return RET_SYN;
while (nxtitem(&lni, (s_char *)&land)) {
while (nxtitem(&lni, &land)) {
if (!player->owner)
continue;
if (land.lnd_ship != tenderp->shp_uid) {
@ -272,7 +272,7 @@ tend_land(struct shpstr *tenderp, s_char *units)
count_units(tenderp);
putship(tenderp->shp_uid, tenderp);
snxtitem_xy(&pni, EF_PLANE, land.lnd_x, land.lnd_y);
while (nxtitem(&pni, (s_char *)&plane)) {
while (nxtitem(&pni, &plane)) {
if (plane.pln_flags & PLN_LAUNCHED)
continue;
if (plane.pln_land != land.lnd_uid)

View file

@ -81,7 +81,7 @@ torp(void)
return RET_SYN;
if (!snxtitem(&nbst, EF_SHIP, sav))
return RET_SYN;
while (nxtitem(&nbst, (s_char *)&sub)) {
while (nxtitem(&nbst, &sub)) {
if (sub.shp_own != player->cnum)
continue;
if ((mchr[(int)sub.shp_type].m_flags & M_TORP) == 0)
@ -102,7 +102,7 @@ torp(void)
}
pr("%d ships are eligible to torp\n", ntorping);
snxtitem(&nbst, EF_SHIP, sav);
while (nxtitem(&nbst, (s_char *)&sub)) {
while (nxtitem(&nbst, &sub)) {
if (!sub.shp_own)
continue;
if (sub.shp_own != player->cnum) {

View file

@ -95,7 +95,7 @@ trad(void)
pr(" --- -------- -- --------- ----- -------------------------\n");
snxtitem_all(&ni, EF_TRADE);
while (nxtitem(&ni, (char *)&trade)) {
while (nxtitem(&ni, &trade)) {
if (trade.trd_owner == 0)
continue;
if (!trade_getitem(&trade, &tg)) {
@ -512,7 +512,7 @@ check_trade(void)
tg.lnd.lnd_mission = 0;
/* Drop any land units this unit was carrying */
snxtitem_xy(&ni, EF_LAND, tg.lnd.lnd_x, tg.lnd.lnd_y);
while (nxtitem(&ni, (s_char *)&land)) {
while (nxtitem(&ni, &land)) {
if (land.lnd_land != tg.lnd.lnd_uid)
continue;
land.lnd_land = -1;
@ -523,7 +523,7 @@ check_trade(void)
}
/* Drop any planes this unit was carrying */
snxtitem_xy(&ni, EF_PLANE, tg.lnd.lnd_x, tg.lnd.lnd_y);
while (nxtitem(&ni, (s_char *)&plane)) {
while (nxtitem(&ni, &plane)) {
if (plane.pln_flags & PLN_LAUNCHED)
continue;
if (plane.pln_land != land.lnd_uid)
@ -541,7 +541,7 @@ check_trade(void)
logerror("Bad trade type %d in trade\n", trade.trd_type);
break;
}
if (!ef_write(trade.trd_type, saveid, (char *)&tg)) {
if (!ef_write(trade.trd_type, saveid, &tg)) {
logerror("Couldn't write unit to disk; seek help.\n");
continue;
}

View file

@ -208,7 +208,7 @@ tran_plane(void)
* No one could seriously want to move planes in parallel from
* several sectors!
*/
while (nxtitem(&nstr, (s_char *)&plane)) {
while (nxtitem(&nstr, &plane)) {
if (!player->owner)
continue;
type = plane.pln_type;
@ -260,7 +260,7 @@ tran_plane(void)
dstx = endsect.sct_x;
dsty = endsect.sct_y;
snxtitem_rewind(&nstr);
while (nxtitem(&nstr, (s_char *)&plane)) {
while (nxtitem(&nstr, &plane)) {
if (!player->owner)
continue;
if (dam)

View file

@ -51,7 +51,7 @@ trea(void)
return RET_SYN;
pr("\t... %s Treaty Report ...\n", cname(player->cnum));
ntreaty = 0;
while (nxtitem(&nstr, (s_char *)&treaty)) {
while (nxtitem(&nstr, &treaty)) {
if (distrea(nstr.cur, &treaty) > 0)
ntreaty++;
}

View file

@ -98,7 +98,7 @@ lupgr(void)
cash = natp->nat_money;
tlev = (int)natp->nat_level[NAT_TLEV];
n = 0;
while (nxtitem(&ni, (s_char *)&land)) {
while (nxtitem(&ni, &land)) {
if (land.lnd_own == 0)
continue;
getsect(land.lnd_x, land.lnd_y, &sect);
@ -181,7 +181,7 @@ supgr(void)
cash = natp->nat_money;
tlev = (int)natp->nat_level[NAT_TLEV];
n = 0;
while (nxtitem(&ni, (s_char *)&ship)) {
while (nxtitem(&ni, &ship)) {
if (ship.shp_own == 0)
continue;
getsect(ship.shp_x, ship.shp_y, &sect);
@ -263,7 +263,7 @@ pupgr(void)
cash = natp->nat_money;
tlev = (int)natp->nat_level[NAT_TLEV];
n = 0;
while (nxtitem(&ni, (s_char *)&plane)) {
while (nxtitem(&ni, &plane)) {
if (plane.pln_own == 0)
continue;
getsect(plane.pln_x, plane.pln_y, &sect);

View file

@ -67,7 +67,7 @@ work(void)
return RET_FAIL;
}
nunits = 0;
while (nxtitem(&ni, (s_char *)&land)) {
while (nxtitem(&ni, &land)) {
if (!player->owner || land.lnd_own == 0)
continue;
if (land.lnd_type < 0 || land.lnd_type > lnd_maxno) {