]> git.pond.sub.org Git - empserver/commitdiff
Fix cargo list shutdown oops
authorMarkus Armbruster <armbru@pond.sub.org>
Sun, 14 Sep 2008 13:37:26 +0000 (09:37 -0400)
committerMarkus Armbruster <armbru@pond.sub.org>
Sun, 14 Sep 2008 14:21:26 +0000 (10:21 -0400)
EF_PLANE is closed before EF_LAND: if a land unit carries a plane, the
plane goes away before its carrier, and unit_onresize() oopses.  Fix
by not checking cargo list consistency there when the file is already
gone.

unit_cargo_init() has a similar issue, at least theoretically: it
rebuilds cargo lists one after the other.  Zap them all first.

src/lib/common/cargo.c

index 0dc371278365835aa9aa50bc0392efab21b7fa38..2b53bd2bbf7cff3714607a64af4d3011ca39016f 100644 (file)
@@ -235,10 +235,9 @@ unit_cargo_init(void)
     struct lndstr *lp;
     struct nukstr *np;
 
-    for (i = EF_SHIP; i <= EF_NUKE; i++) {
-       nclink[i] = 0;
+    memset(nclink, 0, sizeof(nclink));
+    for (i = EF_SHIP; i <= EF_NUKE; i++)
        unit_onresize(i);
-    }
 
     for (i = 0; (pp = getplanep(i)); i++) {
        if (!pp->pln_own)
@@ -285,7 +284,8 @@ unit_onresize(int type)
        clink_init(&cl[i]);
     clink[type] = cl;
     nclink[type] = n;
-    clink_check(type);
+    if (ef_flags(type) & EFF_MEM)
+       clink_check(type);
     return 0;
 }