]> git.pond.sub.org Git - empserver/commitdiff
Disable some incorrect uses of supply_commod()
authorMarkus Armbruster <armbru@pond.sub.org>
Thu, 24 Apr 2008 18:18:23 +0000 (20:18 +0200)
committerMarkus Armbruster <armbru@pike.pond.sub.org>
Wed, 7 May 2008 08:33:42 +0000 (10:33 +0200)
Because supply_commod() updates supply sources it used, the caller
must not cache objects that could be supply sources across a supply
call.  This is very easy to get wrong.

ac_doflak() supplies flak shells if the sector hasn't enough for its
guns.  It caches the sector that receives them.  If the sector has
some shells, but not enough, it supplies them to itself, causing it to
be updated from within supply_commod().  ac_doflak() then adds the
supplied shells to its cached sector, then writes that back.  This
doubles shells already there, and triggers a a seqno mismatch oops.

shp_missile_defense() has similar problems, only for ships.

Disable ac_doflak() and shp_missile_defense() for now, to at least
reduce the oopsing to manageable levels.

Most likely other calls of supply_commod() are also wrong.  Many of
them can't be just disabled, because supply is too relevant to
gameplay there.

src/lib/subs/aircombat.c
src/lib/subs/shpsub.c

index 11616ee916fcc0ee0140783c7982045297710855..106b797755c36e773eea550511a0093709a42a22 100644 (file)
@@ -770,12 +770,18 @@ ac_doflak(struct emp_qelem *list, struct sctstr *from)
 
     gun = MIN(FLAK_GUN_MAX, from->sct_item[I_GUN]);
     shell = from->sct_item[I_SHELL];
+#if 0
+    /*
+     * FIXME can supply from itself, causing seqno mismatch oops
+     * further down
+     */
     if (gun > shell * 2) {
        shell += supply_commod(from->sct_own, from->sct_x, from->sct_y,
                               I_SHELL, (gun + 1) / 2 - shell);
        from->sct_item[I_SHELL] = shell;
        putsect(from);
     }
+#endif
     if (gun > shell * 2)
        gun = shell * 2;
 
index 7ceebb7a00cc10b1ff845c89218639dbd3ec0ffe..bcdd5869b383c9270810d5c833b23fcf530a0fcb 100644 (file)
@@ -867,12 +867,18 @@ shp_missile_defense(coord dx, coord dy, natid bombown, int hardtarget)
        shell = ship.shp_item[I_SHELL];
        if (ship.shp_item[I_MILIT] < 1) /* do we have mil? */
            continue;
+#if 0
+       /*
+        * FIXME can supply from itself, causing seqno mismatch oops
+        * further down
+        */
        if (shell < 2) {        /* do we need shells */
            shell += supply_commod(ship.shp_own, ship.shp_x, ship.shp_y,
                                   I_SHELL, 2);
            if (shell < 2)
                continue;
        }
+#endif
        if (ship.shp_item[I_GUN] < 1)   /* we need at least 1 gun */
            continue;