Don't store ship stats in struct shpstr

New shp_armor(), shp_speed(), shp_visib(), shp_frnge(), shp_glim()
replace the struct shpstr members with the same names.
This commit is contained in:
Markus Armbruster 2008-03-04 21:15:59 +01:00
parent ffc5d0cfd7
commit f86d726406
13 changed files with 73 additions and 45 deletions

View file

@ -161,9 +161,9 @@ look_ship(struct shpstr *lookship)
continue;
tmcp = &mchr[(int)sp->shp_type];
if (smcp->m_flags & M_SUB)
vrange = (int)(sp->shp_visib * range / 30.0);
vrange = (int)(shp_visib(sp) * range / 30.0);
else
vrange = (int)(sp->shp_visib * range / 20.0);
vrange = (int)(shp_visib(sp) * range / 20.0);
getsect(sp->shp_x, sp->shp_y, &sect);
if (sect.sct_type != SCT_WATER)
vrange = MAX(1, vrange);

View file

@ -183,7 +183,7 @@ multifire(void)
pr("Not enough mil on ship #%d\n", item.ship.shp_uid);
continue;
}
if (item.ship.shp_glim == 0) {
if (mchr[item.ship.shp_type].m_glim == 0) {
pr("Ships %d cannot fire guns!\n", item.ship.shp_uid);
continue;
}

View file

@ -354,19 +354,19 @@ sdump(void)
pr(" %d", ship.shp_item[I_RAD]);
break;
case 27:
pr(" %d", ship.shp_armor);
pr(" %d", shp_armor(&ship));
break;
case 28:
pr(" %d", ship.shp_speed);
pr(" %d", shp_speed(&ship));
break;
case 29:
pr(" %d", ship.shp_visib);
pr(" %d", shp_visib(&ship));
break;
case 30:
pr(" %d", ship.shp_frnge);
pr(" %d", shp_frnge(&ship));
break;
case 31:
pr(" %d", ship.shp_glim);
pr(" %d", shp_glim(&ship));
break;
case 32:
/*

View file

@ -56,7 +56,7 @@ sona(void)
struct mchrstr *tmcp;
struct nstr_sect ns;
int range;
int pingrange;
int visib, pingrange;
int srange;
int vrange;
int dist;
@ -147,7 +147,8 @@ sona(void)
if (targ.shp_own == player->cnum || targ.shp_own == 0)
continue;
tmcp = &mchr[(int)targ.shp_type];
pingrange = MIN(7, MAX(targ.shp_visib, 10) * range / 10);
visib = shp_visib(&targ);
pingrange = MIN(7, MAX(visib, 10) * range / 10);
vrange = pingrange * ship.shp_effic / 200;
dist = mapdist(targ.shp_x, targ.shp_y, ship.shp_x, ship.shp_y);
pingrange = (MAX(pingrange, 2) * targ.shp_effic) / 100;
@ -173,11 +174,11 @@ sona(void)
continue;
if (tmcp->m_flags & M_SUB &&
getrel(getnatp(targ.shp_own), player->cnum) < FRIENDLY) {
if (mcp->m_vrnge + targ.shp_visib < 8)
if (mcp->m_vrnge + visib < 8)
pr("Sonar detects sub #%d @ %s\n",
targ.shp_uid,
xyas(targ.shp_x, targ.shp_y, player->cnum));
else if (mcp->m_vrnge + targ.shp_visib < 10)
else if (mcp->m_vrnge + visib < 10)
pr("Sonar detects %s @ %s\n",
prship(&targ),
xyas(targ.shp_x, targ.shp_y, player->cnum));
@ -190,8 +191,8 @@ sona(void)
cname(targ.shp_own), prship(&targ),
xyas(targ.shp_x, targ.shp_y, player->cnum));
if (targ.shp_visib > vis[y][x]) {
vis[y][x] = targ.shp_visib;
if (visib > vis[y][x]) {
vis[y][x] = visib;
/* &~0x20 makes it a cap letter */
rad[y][x] = (*mchr[(int)targ.shp_type].m_name) & ~0x20;
}
@ -224,7 +225,7 @@ plane_sona(struct emp_qelem *plane_list, int x, int y,
struct plist *ip;
struct sctstr sect;
int found = 0;
int range, i;
int range, i, vis;
int pingrange;
int vrange;
int dist;
@ -252,7 +253,8 @@ plane_sona(struct emp_qelem *plane_list, int x, int y,
if (roll(100) > pln_identchance(pp, shp_hardtarget(targ),
EF_SHIP))
continue;
pingrange = MAX(targ->shp_visib, 10) * range / 10;
vis = shp_visib(targ);
pingrange = MAX(vis, 10) * range / 10;
vrange = pingrange * (pp->pln_effic / 200.0);
dist = mapdist(targ->shp_x, targ->shp_y, x, y);
pingrange = (MAX(pingrange, 2) * targ->shp_effic);

View file

@ -63,8 +63,8 @@ sstat(void)
pr(" %3d%% %4d %3d %3d %3d %3d %3d",
ship.shp_effic,
ship.shp_tech,
ship.shp_armor,
ship.shp_speed, ship.shp_visib, ship.shp_frnge, ship.shp_glim);
shp_armor(&ship), shp_speed(&ship), shp_visib(&ship),
shp_frnge(&ship), shp_glim(&ship));
pr("\n");
}
if (nships == 0) {