From a78f71ff99d8e15e341140912861f1fa8748e15a Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Sun, 4 Jan 2009 12:00:45 +0100 Subject: [PATCH] Fix loopholes that let you load and unload foreign commodities 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 | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/lib/commands/load.c b/src/lib/commands/load.c index 746a4bb0..d1db6534 100644 --- a/src/lib/commands/load.c +++ b/src/lib/commands/load.c @@ -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;