]> git.pond.sub.org Git - empserver/commitdiff
Fix load, unload, lload, lunload not to give away civilians
authorMarkus Armbruster <armbru@pond.sub.org>
Sun, 4 Jan 2009 10:59:10 +0000 (11:59 +0100)
committerMarkus Armbruster <armbru@pond.sub.org>
Tue, 6 Jan 2009 17:48:04 +0000 (18:48 +0100)
The game generally doesn't let you give away civilians.  But the check
in load_comm_ok() for that compared the sector old owner to the player
instead of the ship's or land unit's owner, which is incorrect for
foreign ships or land units.  Fix that.

Also make fix the message there not to assume that the civilians are
owned by the player.  This can't currently happen, but will when these
commands support use by deities properly.

src/lib/commands/load.c

index a549edc852f282e30873998f15926f343e89e008..746a4bb03990f134c36e939859ab503b181cd18b 100644 (file)
@@ -322,13 +322,15 @@ lload(void)
 }
 
 static int
-load_comm_ok(struct sctstr *sectp, i_type item, int move_amt)
+load_comm_ok(struct sctstr *sectp, natid unit_own,
+            i_type item, int move_amt)
 {
     if (!move_amt)
        return 0;
-    if (sectp->sct_oldown != player->cnum && item == I_CIVIL) {
+    if (sectp->sct_oldown != unit_own && item == I_CIVIL) {
        pr("%s civilians refuse to %s at %s!\n",
-          move_amt < 0 ? "Your" : "Foreign",
+          (move_amt < 0 ? unit_own : sectp->sct_oldown) == player->cnum
+          ? "Your" : "Foreign",
           move_amt < 0 ? "disembark" : "board",
           xyas(sectp->sct_x, sectp->sct_y, player->cnum));
        return 0;
@@ -691,7 +693,7 @@ load_comm_ship(struct sctstr *sectp, struct shpstr *sp,
        move_amt = sect_amt;
     if (move_amt < sect_amt - ITEM_MAX)
        move_amt = sect_amt - ITEM_MAX;
-    if (!load_comm_ok(sectp, item, move_amt))
+    if (!load_comm_ok(sectp, sp->shp_own, item, move_amt))
        return RET_OK;
     if (!want_to_abandon(sectp, item, move_amt, 0))
        return RET_FAIL;
@@ -864,7 +866,7 @@ load_comm_land(struct sctstr *sectp, struct lndstr *lp,
        move_amt = sect_amt;
     if (move_amt < sect_amt - ITEM_MAX)
        move_amt = sect_amt - ITEM_MAX;
-    if (!load_comm_ok(sectp, item, move_amt))
+    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",