]> git.pond.sub.org Git - empserver/commitdiff
(shp_maxno): Variable's value is well-known constant N_MAXSHIPS + 1.
authorMarkus Armbruster <armbru@pond.sub.org>
Sun, 6 Nov 2005 21:20:49 +0000 (21:20 +0000)
committerMarkus Armbruster <armbru@pond.sub.org>
Sun, 6 Nov 2005 21:20:49 +0000 (21:20 +0000)
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.

include/ship.h
src/lib/global/init.c
src/lib/global/ship.c
src/lib/subs/show.c
src/server/main.c

index 3891141b82ab3375fc43afd6faed8b8f059a4839..e3e1112d55dade458b649c67c1179dadef4f4fa1 100644 (file)
@@ -186,7 +186,6 @@ struct mchrstr {
        (struct shpstr *) ef_ptr(EF_SHIP, n)
 
 extern struct mchrstr mchr[N_MAXSHIPS + 1];
-extern int shp_maxno;
 
 struct mlist {
     struct emp_qelem queue;    /* list of ships */
index dc523542919406191e7586f215e07c616a1aa54d..2d5d9076c0b0bcd951843323be4719f50686c102 100644 (file)
@@ -49,16 +49,14 @@ global_init(void)
     init_pchr();
     init_mchr();
     init_plchr();
-    /* the same thing should be done for units... */
 }
 
 static void
 init_mchr(void)
 {
     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)
            mp->m_flags |= M_XLIGHT;
        if (mp->m_nchoppers)
@@ -74,7 +72,6 @@ static void
 init_plchr(void)
 {
     struct plchrstr *pp;
-    int pcount;
 
     for (pp = plchr; pp->pl_name; pp++) {
        if (pp->pl_flags & P_M)
index 73600378d02f56eabad66346b071f19f68f2d564..d10403091f9ced603f2f67eadcf349923bf1e2ee 100644 (file)
@@ -205,8 +205,6 @@ struct mchrstr mchr[] = {
      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, NULL,
      0, 0, 0, 0, 0}
 };
-
-int shp_maxno = (sizeof(mchr) / sizeof(struct mchrstr)) - 1;
index 842143bc33acf99defae6b7edc2e4413fc0ef752..c9be221f5d7c1f106d10d2b99017f551396cc64e 100644 (file)
@@ -93,25 +93,20 @@ make_new_list(int tlev, int type)
     struct plchrstr *pp;
     struct lchrstr *lp;
     struct mchrstr *mp;
-    int count;
 
     lookup_list_cnt = 0;
     if (type == EF_PLANE) {
        for (pp = plchr; pp->pl_name; pp++) {
            if (pp->pl_tech > tlev)
                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].tech = pp->pl_tech;
            lookup_list_cnt++;
        }
     } 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)
                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].tech = mp->m_tech;
            lookup_list_cnt++;
index aa53e27e71a5cdce6a80039f173c34fc2ef8ce32..a479d4c55b01a0c9b2ce5e381b6171d156189a95 100644 (file)
@@ -511,7 +511,7 @@ nullify_objects(void)
        /* Fix up the military values */
        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)
            mchr[i].m_hcm = 0;
        if (opt_NO_LCMS)