(shp_maxno): Variable's value is well-known constant N_MAXSHIPS + 1.

Useless, remove.  Users changed to check mchr's sentinel, because
that's clearer than comparing the index to N_MAXSHIPS or sizeof(mchr)
/ sizeof(*mchr).

(mchr): Change sentinel's m_name to NULL.
This commit is contained in:
Markus Armbruster 2005-11-06 21:20:49 +00:00
parent 47192c9079
commit e23d8a8fac
5 changed files with 4 additions and 15 deletions

View file

@ -186,7 +186,6 @@ struct mchrstr {
(struct shpstr *) ef_ptr(EF_SHIP, n) (struct shpstr *) ef_ptr(EF_SHIP, n)
extern struct mchrstr mchr[N_MAXSHIPS + 1]; extern struct mchrstr mchr[N_MAXSHIPS + 1];
extern int shp_maxno;
struct mlist { struct mlist {
struct emp_qelem queue; /* list of ships */ struct emp_qelem queue; /* list of ships */

View file

@ -49,16 +49,14 @@ global_init(void)
init_pchr(); init_pchr();
init_mchr(); init_mchr();
init_plchr(); init_plchr();
/* the same thing should be done for units... */
} }
static void static void
init_mchr(void) init_mchr(void)
{ {
struct mchrstr *mp; struct mchrstr *mp;
int n;
for (mp = mchr, n = 0; n < shp_maxno; n++, mp++) { for (mp = mchr; mp->m_name; mp++) {
if (mp->m_nxlight) if (mp->m_nxlight)
mp->m_flags |= M_XLIGHT; mp->m_flags |= M_XLIGHT;
if (mp->m_nchoppers) if (mp->m_nchoppers)
@ -74,7 +72,6 @@ static void
init_plchr(void) init_plchr(void)
{ {
struct plchrstr *pp; struct plchrstr *pp;
int pcount;
for (pp = plchr; pp->pl_name; pp++) { for (pp = plchr; pp->pl_name; pp++) {
if (pp->pl_flags & P_M) if (pp->pl_flags & P_M)

View file

@ -205,8 +205,6 @@ struct mchrstr mchr[] = {
360, 1500, M_SUPPLY, 0, 2}, 360, 1500, M_SUPPLY, 0, 2},
{{0}, {{0},
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL,
0, 0, 0, 0, 0} 0, 0, 0, 0, 0}
}; };
int shp_maxno = (sizeof(mchr) / sizeof(struct mchrstr)) - 1;

View file

@ -93,25 +93,20 @@ make_new_list(int tlev, int type)
struct plchrstr *pp; struct plchrstr *pp;
struct lchrstr *lp; struct lchrstr *lp;
struct mchrstr *mp; struct mchrstr *mp;
int count;
lookup_list_cnt = 0; lookup_list_cnt = 0;
if (type == EF_PLANE) { if (type == EF_PLANE) {
for (pp = plchr; pp->pl_name; pp++) { for (pp = plchr; pp->pl_name; pp++) {
if (pp->pl_tech > tlev) if (pp->pl_tech > tlev)
continue; continue;
if (pp->pl_name == 0 || pp->pl_name[0] == '\0')
continue;
lookup_list[lookup_list_cnt].l_u.pp = pp; lookup_list[lookup_list_cnt].l_u.pp = pp;
lookup_list[lookup_list_cnt].tech = pp->pl_tech; lookup_list[lookup_list_cnt].tech = pp->pl_tech;
lookup_list_cnt++; lookup_list_cnt++;
} }
} else if (type == EF_SHIP) { } else if (type == EF_SHIP) {
for (mp = mchr, count = 0; count < shp_maxno; count++, mp++) { for (mp = mchr; mp->m_name; mp++) {
if (mp->m_tech > tlev) if (mp->m_tech > tlev)
continue; continue;
if (mp->m_name == 0 || mp->m_name[0] == '\0')
continue;
lookup_list[lookup_list_cnt].l_u.mp = mp; lookup_list[lookup_list_cnt].l_u.mp = mp;
lookup_list[lookup_list_cnt].tech = mp->m_tech; lookup_list[lookup_list_cnt].tech = mp->m_tech;
lookup_list_cnt++; lookup_list_cnt++;

View file

@ -511,7 +511,7 @@ nullify_objects(void)
/* Fix up the military values */ /* Fix up the military values */
lchr[i].l_mil = lchr[i].l_item[I_MILIT]; lchr[i].l_mil = lchr[i].l_item[I_MILIT];
} }
for (i = 0; i < shp_maxno; i++) { for (i = 0; i < mchr[i].m_name; i++) {
if (opt_NO_HCMS) if (opt_NO_HCMS)
mchr[i].m_hcm = 0; mchr[i].m_hcm = 0;
if (opt_NO_LCMS) if (opt_NO_LCMS)