]> git.pond.sub.org Git - empserver/commitdiff
market: Simplify check for dead trades and document how it fails
authorMarkus Armbruster <armbru@pond.sub.org>
Thu, 10 May 2018 09:15:29 +0000 (11:15 +0200)
committerMarkus Armbruster <armbru@pond.sub.org>
Tue, 5 Jan 2021 06:25:18 +0000 (07:25 +0100)
We fail to delete trades right away when the unit on sale dies.
Instead, we delete trades of the dead whenever we look at the market.
Doesn't work when new builds reuse the IDs of such dead.  If the new
unit's owner differs from the dead one's, we still delete the trade,
and log "Something weird".  If they are the same, the newly built unit
takes the dead one's place on the market.  Has been that way since the
market was added in 4.0.0.

I can't fix this right now, so mark as FIXME, and drop the logerror().
The first of the two trade deletions is now redundant, so drop that,
too.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
src/lib/commands/trad.c

index 597cc3c85e7dcab8669f641bfd0afb034658c5a1..b681d5fbd2413ba790931a0777773a3f41c38a7a 100644 (file)
@@ -283,13 +283,13 @@ check_trade(void)
            continue;
        if (!trade_getitem(&trade, &tg))
            continue;
-       if (tg.gen.own == 0) {
-           trade.trd_owner = 0;
-           puttrade(n, &trade);
-           continue;
-       }
+       /*
+        * FIXME We fail to delete trades right away when the thing on
+        * sale dies.  Instead, we delete it here.  Doesn't work if it
+        * has been rebuilt by the same owner; in that case, the new
+        * one takes the dead one's place on the market.
+        */
        if (tg.gen.own != trade.trd_owner) {
-           logerror("Something weird, tg.gen.own != trade.trd_owner!\n");
            trade.trd_owner = 0;
            puttrade(n, &trade);
            continue;