]> git.pond.sub.org Git - empserver/commitdiff
Fix fire command to detect when the firing object changes
authorMarkus Armbruster <armbru@pond.sub.org>
Sun, 4 May 2008 14:44:26 +0000 (16:44 +0200)
committerMarkus Armbruster <armbru@pond.sub.org>
Sun, 4 May 2008 14:44:26 +0000 (16:44 +0200)
multifire() failed to take into account that the firing firing sector,
ship or land unit can change while it is getting the target argument.
It thus clobbered any updates made to the firing object while it was
sleeping for the target argument.  Abusable.  Broken when Chainsaw
introduced MULTIFIRE.

src/lib/commands/mfir.c

index 4d3fd893bf2efd9145b0aa88c9bfb8e7572fb537..58542b49a041a40da6e37ff59e62c1410eea41be 100644 (file)
@@ -253,6 +253,8 @@ multifire(void)
            y = vsect.sct_y;
        }
        if (type == EF_SHIP) {
+           if (!check_ship_ok(&fship))
+               return RET_FAIL;
            if (fship.shp_own != player->cnum) {
                pr("Not your ship!\n");
                continue;
@@ -305,6 +307,8 @@ multifire(void)
                putship(fship.shp_uid, &fship);
            }
        } else if (type == EF_LAND) {
+           if (!check_land_ok(&fland))
+               return RET_FAIL;
            if (fland.lnd_own != player->cnum) {
                pr("Not your unit!\n");
                continue;
@@ -349,6 +353,8 @@ multifire(void)
                    dam = ldround(dam / 2.0, 1);
            }
        } else {
+           if (!check_sect_ok(&fsect))
+               return RET_FAIL;
            fx = fsect.sct_x;
            fy = fsect.sct_y;
            if (fsect.sct_own != player->cnum ||