]> git.pond.sub.org Git - empserver/commitdiff
Fix relation checks in load, unload, lload, lunload
authorMarkus Armbruster <armbru@pond.sub.org>
Sun, 4 Jan 2009 09:49:17 +0000 (10:49 +0100)
committerMarkus Armbruster <armbru@pond.sub.org>
Tue, 6 Jan 2009 13:59:01 +0000 (14:59 +0100)
The check for ship owner's relations to the player was backward: it
checked the player's relations to the ship's owner instead.  Abusable:
you could load and unload any ship by declaring friendly to its owner.
Broken since Chainsaw let you load and unload friendly ships.

The check for land unit owner's relations to the player was similarly
backward, similarly abusable, and also broken since day one.

lload and lunload checked sector owner's relations to the land unit's
owner instead of to the player.  Harmless, because the two must be the
same to reach the check.

src/lib/commands/load.c

index 625c0237e9c94d07095733596163639b070d4bca..74a26e76025babd73e2e56bd9b0fa1c01e7e8af4 100644 (file)
@@ -126,7 +126,7 @@ load(void)
        if (ship.shp_own != player->cnum) {
            if (!noisy)
                continue;
-           if (getrel(getnatp(player->cnum), ship.shp_own) < FRIENDLY)
+           if (getrel(getnatp(ship.shp_own), player->cnum) < FRIENDLY)
                continue;
        }
        if (!getsect(ship.shp_x, ship.shp_y, &sect))    /* XXX */
@@ -250,7 +250,7 @@ lload(void)
            continue;
 
        if (player->cnum != land.lnd_own &&
-           getrel(getnatp(player->cnum), land.lnd_own) != ALLIED)
+           getrel(getnatp(land.lnd_own), player->cnum) != ALLIED)
            continue;
 
        if (!getsect(land.lnd_x, land.lnd_y, &sect))    /* XXX */
@@ -266,7 +266,7 @@ lload(void)
        }
 
        if (sect.sct_own != player->cnum &&
-           getrel(getnatp(sect.sct_own), land.lnd_own) != ALLIED) {
+           getrel(getnatp(sect.sct_own), player->cnum) != ALLIED) {
            pr("Sector %s is not yours.\n",
               xyas(land.lnd_x, land.lnd_y, player->cnum));
            continue;