]> git.pond.sub.org Git - empserver/commitdiff
Fix loopholes that let you load and unload foreign commodities
authorMarkus Armbruster <armbru@pond.sub.org>
Sun, 4 Jan 2009 11:00:45 +0000 (12:00 +0100)
committerMarkus Armbruster <armbru@pond.sub.org>
Tue, 6 Jan 2009 17:48:04 +0000 (18:48 +0100)
The Chainsaw 3 feature to let you load/unload to a specific amount
through a negative amount argument created loopholes: it let you load
your ships in friendly sectors with the unload command, and unload
friendly ships with the load command.  Likewise for land units, with
allied instead of friendly, of course.

Empire 4.0.0 fixed that for the case of loading a land unit from an
allied sector.  Get rid of that check, and fix it for good in
load_comm_ok().

src/lib/commands/load.c

index 746a4bb03990f134c36e939859ab503b181cd18b..d1db6534cf96c425f65f1131fc13bd59ef355701 100644 (file)
@@ -327,6 +327,10 @@ load_comm_ok(struct sctstr *sectp, natid unit_own,
 {
     if (!move_amt)
        return 0;
+    if (move_amt < 0 && !player->god && unit_own != player->cnum)
+       return 0;
+    if (move_amt > 0 && !player->god && sectp->sct_own != player->cnum)
+       return 0;
     if (sectp->sct_oldown != unit_own && item == I_CIVIL) {
        pr("%s civilians refuse to %s at %s!\n",
           (move_amt < 0 ? unit_own : sectp->sct_oldown) == player->cnum
@@ -868,11 +872,6 @@ load_comm_land(struct sctstr *sectp, struct lndstr *lp,
        move_amt = sect_amt - ITEM_MAX;
     if (!load_comm_ok(sectp, lp->lnd_own, item, move_amt))
        return RET_OK;
-    if (sectp->sct_own != player->cnum && move_amt > 0) {
-       pr("Sector %s is not yours.\n",
-          xyas(lp->lnd_x, lp->lnd_y, player->cnum));
-       return RET_FAIL;
-    }
     sectp->sct_item[item] = sect_amt - move_amt;
     lp->lnd_item[item] = land_amt + move_amt;