From 85d8e7fcb1817aaba396344db5633e53ddb76d2f Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Thu, 10 May 2018 11:15:29 +0200 Subject: [PATCH] market: Simplify check for dead trades and document how it fails 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 --- src/lib/commands/trad.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/lib/commands/trad.c b/src/lib/commands/trad.c index 597cc3c85..b681d5fbd 100644 --- a/src/lib/commands/trad.c +++ b/src/lib/commands/trad.c @@ -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; -- 2.43.0