Replace getvec() by direct, read-only item access in some cases where

that's obviously correct.
This commit is contained in:
Markus Armbruster 2004-03-05 10:38:58 +00:00
parent 99bfa19a92
commit b1461faea5
23 changed files with 164 additions and 222 deletions

View file

@ -785,7 +785,6 @@ lnd_list(struct emp_qelem *land_list)
struct emp_qelem *next;
struct llist *llp;
struct lndstr *lnd;
int vec[I_MAX + 1];
pr("lnd# land type x,y a eff sh gun xl mu tech retr fuel\n");
@ -798,9 +797,8 @@ lnd_list(struct emp_qelem *land_list)
prxy("%4d,%-4d ", lnd->lnd_x, lnd->lnd_y, llp->land.lnd_own);
pr("%1c", lnd->lnd_army);
pr("%4d%%", lnd->lnd_effic);
getvec(VT_ITEM, vec, (s_char *)lnd, EF_LAND);
pr("%4d", vec[I_SHELL]);
pr("%4d", vec[I_GUN]);
pr("%4d", lnd->lnd_item[I_SHELL]);
pr("%4d", lnd->lnd_item[I_GUN]);
count_land_planes(lnd);
pr("%3d", lnd->lnd_nxlight);
pr("%4d", lnd->lnd_mobil);

View file

@ -55,7 +55,6 @@ move_ground(s_char *what, struct sctstr *start, struct sctstr *end,
{
struct sctstr sect, ending_sect;
struct sctstr next, dsect;
int vec[I_MAX + 1];
coord curx, cury, oldx, oldy;
coord tmpx, tmpy;
coord dx, dy;
@ -191,9 +190,10 @@ move_ground(s_char *what, struct sctstr *start, struct sctstr *end,
*movstr = 0;
continue;
}
getvec(VT_ITEM, vec, (s_char *)&next, EF_SECTOR);
sect_mcost = sector_mcost(&next, MOB_ROAD);
if ((!player->owner && (!exploring || vec[I_MILIT] || vec[I_CIVIL]))
if ((!player->owner && (!exploring
|| next.sct_item[I_MILIT]
|| next.sct_item[I_CIVIL]))
|| sect_mcost == -1.0) {
/* already-owned, or prohibited terrain */
pr("You can't go there...\n");
@ -258,7 +258,6 @@ move_map(s_char *what, coord curx, coord cury, s_char *arg)
s_char range[128];
s_char view[7];
int i;
int vec[I_MAX + 1];
int changed = 0;
np = getnatp(player->cnum);
@ -295,13 +294,13 @@ move_map(s_char *what, coord curx, coord cury, s_char *arg)
writemap(player->cnum);
if (!getsect(curx, cury, &sect))
return RET_FAIL;
getvec(VT_ITEM, vec, (s_char *)&sect, EF_SECTOR);
pr(" %c %c eff mob civ mil uw food work avail\n",
view[0], view[1]);
pr(" %c %c %c %3d %3d %4d %4d %4d %4d %3d %3d\n",
view[2], view[3], view[4],
sect.sct_effic, sect.sct_mobil, vec[I_CIVIL], vec[I_MILIT],
vec[I_UW], vec[I_FOOD], sect.sct_work, sect.sct_avail);
sect.sct_effic, sect.sct_mobil,
sect.sct_item[I_CIVIL], sect.sct_item[I_MILIT], sect.sct_item[I_UW],
sect.sct_item[I_FOOD], sect.sct_work, sect.sct_avail);
pr(" %c %c\n", view[5], view[6]);
return RET_OK;
}

View file

@ -146,7 +146,6 @@ retreat_ship1(struct shpstr *sp, s_char code, int orig)
int shells;
double mobcost;
struct mchrstr *mcp;
int vec[I_MAX + 1];
int time_to_stop;
sp->shp_mission = 0;
@ -178,8 +177,7 @@ retreat_ship1(struct shpstr *sp, s_char code, int orig)
}
}
/* check crew - uws don't count */
getvec(VT_ITEM, vec, (s_char *)sp, EF_SHIP);
if (vec[I_MILIT] == 0 && vec[I_CIVIL] == 0) {
if (sp->shp_item[I_MILIT] == 0 && sp->shp_item[I_CIVIL] == 0) {
wu(0, sp->shp_own,
"%s %s,\nbut had no crew, and couldn't retreat!\n", prship(sp),
conditions[findcondition(code)].desc[orig]);

View file

@ -283,13 +283,11 @@ sathead(void)
void
satdisp(struct sctstr *sp, int acc, int showstuff)
{
int vec[I_MAX + 1], first;
int first;
struct nstr_item ni;
struct shpstr ship;
struct lndstr land;
if (getvec(VT_ITEM, vec, (caddr_t)sp, EF_SECTOR) < 0)
return;
prxy("%4d,%-4d ", sp->sct_x, sp->sct_y, player->cnum);
pr("%c %3d %3d %3d %3d %3d %4d %4d %4d %4d %4d %4d %5d\n",
dchr[sp->sct_type].d_mnem,
@ -297,10 +295,13 @@ satdisp(struct sctstr *sp, int acc, int showstuff)
roundintby((int)sp->sct_road, acc / 2),
roundintby((int)sp->sct_rail, acc / 2),
roundintby((int)sp->sct_defense, acc / 2),
roundintby(vec[I_CIVIL], acc), roundintby(vec[I_MILIT], acc),
roundintby(vec[I_SHELL], acc), roundintby(vec[I_GUN], acc),
roundintby(vec[I_IRON], acc), roundintby(vec[I_PETROL], acc),
roundintby(vec[I_FOOD], acc));
roundintby(sp->sct_item[I_CIVIL], acc),
roundintby(sp->sct_item[I_MILIT], acc),
roundintby(sp->sct_item[I_SHELL], acc),
roundintby(sp->sct_item[I_GUN], acc),
roundintby(sp->sct_item[I_IRON], acc),
roundintby(sp->sct_item[I_PETROL], acc),
roundintby(sp->sct_item[I_FOOD], acc));
map_set(player->cnum, sp->sct_x, sp->sct_y, dchr[sp->sct_type].d_mnem,
0);
if (!showstuff)