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 <armbru@pond.sub.org>
This commit is contained in:
Markus Armbruster 2018-05-10 11:15:29 +02:00
parent 6bcd72e241
commit 85d8e7fcb1

View file

@ -283,13 +283,13 @@ check_trade(void)
continue; continue;
if (!trade_getitem(&trade, &tg)) if (!trade_getitem(&trade, &tg))
continue; continue;
if (tg.gen.own == 0) { /*
trade.trd_owner = 0; * FIXME We fail to delete trades right away when the thing on
puttrade(n, &trade); * sale dies. Instead, we delete it here. Doesn't work if it
continue; * 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) { if (tg.gen.own != trade.trd_owner) {
logerror("Something weird, tg.gen.own != trade.trd_owner!\n");
trade.trd_owner = 0; trade.trd_owner = 0;
puttrade(n, &trade); puttrade(n, &trade);
continue; continue;