]> git.pond.sub.org Git - empserver/commitdiff
Fix extension of market bidding time when high bidder changes
authorMarkus Armbruster <armbru@pond.sub.org>
Mon, 14 Jan 2013 19:59:04 +0000 (20:59 +0100)
committerMarkus Armbruster <armbru@pond.sub.org>
Wed, 8 May 2013 04:57:55 +0000 (06:57 +0200)
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
src/lib/commands/trad.c

index e7a8ef7057469d425baac69ded89fd8e22e4b735..f3c36151055df31b75511c48d0992e9b174d2794 100644 (file)
@@ -161,16 +161,10 @@ buy(void)
        return RET_FAIL;
     if (bid > 0.04 + comm.com_price) {
        comm.com_price = bid;
        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);
        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;
        comm.com_maxbidder = player->cnum;
        comm.com_x = x;
        comm.com_y = y;
index fa122e8b0d11e629bc414a964f0bdf7f0ba3c2f1..6a850568a76796dd151c2613100bb0804e4f891a 100644 (file)
@@ -254,11 +254,10 @@ trad(void)
        return RET_OK;
     }
     if (bid > trade.trd_price) {
        return RET_OK;
     }
     if (bid > trade.trd_price) {
-       /* Add five minutes to the time if less than 5 minutes left. */
        time(&now);
        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_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;
        trade.trd_price = bid;
        trade.trd_maxbidder = player->cnum;
        trade.trd_x = sx;