]> git.pond.sub.org Git - empserver/commitdiff
Fix pre-tax unit market price loss of precision
authorMarkus Armbruster <armbru@pond.sub.org>
Mon, 14 Jan 2013 19:52:04 +0000 (20:52 +0100)
committerMarkus Armbruster <armbru@pond.sub.org>
Wed, 8 May 2013 04:57:55 +0000 (06:57 +0200)
check_trade() converts the price to float, which can lose precision,
although only for ridiculously high prices.  Has been broken since
4.0.0 introduced the market.

Avoid the conversion.  Bulletins now show pre-tax price as $N instead
of $N.00.

src/lib/commands/trad.c

index a53da4d1ec12f15e1f919d5cdddd3daaeeee00c6..fa122e8b0d11e629bc414a964f0bdf7f0ba3c2f1 100644 (file)
@@ -283,7 +283,7 @@ check_trade(void)
     union empobj_storage tg;
     time_t now;
     double tleft;
-    float price;
+    int price;
     int saveid;
     natid seller;
 
@@ -338,7 +338,7 @@ check_trade(void)
            wu(0, seller,
               "   Your item was taken off the market.\n");
            wu(0, trade.trd_maxbidder,
-              "You tried to buy %s #%d from %s for $%.2f\n",
+              "You tried to buy %s #%d from %s for $%d\n",
               trade_nameof(&trade, &tg.gen), saveid, cname(seller),
               price);
            wu(0, trade.trd_maxbidder, "but couldn't afford it.\n");
@@ -403,7 +403,7 @@ check_trade(void)
           cname(trade.trd_maxbidder), trade_nameof(&trade, &tg.gen),
           saveid, price * tradetax);
        wu(0, trade.trd_maxbidder,
-          "The bidding is over & you bought %s #%d from %s for $%.2f\n",
+          "The bidding is over & you bought %s #%d from %s for $%d\n",
           trade_nameof(&trade, &tg.gen), saveid, cname(seller),
           price);
     }