From c5f76e58534bd0760730863b729ce2bc3f054b76 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Mon, 14 Jan 2013 20:59:04 +0100 Subject: [PATCH] Fix extension of market bidding time when high bidder changes Lots stay on the market until there's a bid and bidding time expires. When the highest bidder changes, and less than five minutes of bidding time are left, it gets extended by five minutes (since 4.0.7, actually works since 4.0.9). Normally, this ensures that the competition has at least five minutes to react. Except when this is the first bid, bidding time may have expired already. If it expired less than five minutes ago, the competition still gets time to react, just less than it should. If it expired earlier, the sale is executed immediately for units. For commodities, the bidding time is set to expire in five minutes (since 4.2.0). Instead of extending bidding time by five minutes, set it to expire in five minutes, both for commodities and for units. --- src/lib/commands/buy.c | 12 +++--------- src/lib/commands/trad.c | 5 ++--- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/src/lib/commands/buy.c b/src/lib/commands/buy.c index e7a8ef705..f3c361510 100644 --- a/src/lib/commands/buy.c +++ b/src/lib/commands/buy.c @@ -161,16 +161,10 @@ buy(void) return RET_FAIL; if (bid > 0.04 + comm.com_price) { comm.com_price = bid; - /* Add five minutes to the time if less than 5 minutes */ time(&now); - if (((MARK_DELAY - (now - comm.com_markettime)) < 300) && - comm.com_maxbidder != player->cnum) { - comm.com_markettime += 300; - /* Special case - what if so much time has gone by? Well, - Just reset the markettime so that only 5 minutes are left */ - if ((MARK_DELAY - (now - comm.com_markettime)) < 0) - comm.com_markettime = (now - (MARK_DELAY - 300)); - } + if (comm.com_markettime + MARK_DELAY - now < minutes(5) && + comm.com_maxbidder != player->cnum) + comm.com_markettime = now + minutes(5) - MARK_DELAY; comm.com_maxbidder = player->cnum; comm.com_x = x; comm.com_y = y; diff --git a/src/lib/commands/trad.c b/src/lib/commands/trad.c index fa122e8b0..6a850568a 100644 --- a/src/lib/commands/trad.c +++ b/src/lib/commands/trad.c @@ -254,11 +254,10 @@ trad(void) return RET_OK; } if (bid > trade.trd_price) { - /* Add five minutes to the time if less than 5 minutes left. */ time(&now); - if (((TRADE_DELAY - (now - trade.trd_markettime)) < 300) && + if (trade.trd_markettime + TRADE_DELAY - now < minutes(5) && trade.trd_maxbidder != player->cnum) - trade.trd_markettime += 300; + trade.trd_markettime = now + minutes(5) - TRADE_DELAY; trade.trd_price = bid; trade.trd_maxbidder = player->cnum; trade.trd_x = sx; -- 2.43.0