]> git.pond.sub.org Git - empserver/blobdiff - src/lib/commands/buy.c
buy: Fix bogus error when lot gets reused at the last prompt
[empserver] / src / lib / commands / buy.c
index 3b24033e2ca91c1bf0569ca850ebf3743b9a4edd..72afa28c20e10c86349a77d15dfadd1a31864f9d 100644 (file)
@@ -30,7 +30,7 @@
  *     Dave Pare, 1986
  *     Pat Loney, 1992
  *     Steve McClure, 1996-2000
- *     Markus Armbruster, 2004-2018
+ *     Markus Armbruster, 2004-2021
  */
 
 #include <config.h>
@@ -101,6 +101,8 @@ buy(void)
     bid = atof(p);
     if (bid <= 0)
        return RET_FAIL;
+    if (!check_comm_ok(&comm))
+       return RET_FAIL;
     if (natp->nat_money < bid * comm.com_amount * buytax) {
        pr("This purchase would cost %.2f, %.2f more than you have.\n",
           bid * comm.com_amount * buytax,
@@ -126,7 +128,6 @@ buy(void)
        }
     }
     canspend = natp->nat_money - tally;
-    check_comm_ok(&comm);
     if (bid * comm.com_amount * buytax > canspend) {
        pr("You have overextended yourself in the market\n");
        pr("You can not bid on the current items at that price.\n");
@@ -140,6 +141,8 @@ buy(void)
        pr("Could not access sector");
        return RET_FAIL;
     }
+    if (!check_comm_ok(&comm))
+       return RET_FAIL;
     if ((sect.sct_type != SCT_WAREH && sect.sct_type != SCT_HARBR) ||
        sect.sct_own != player->cnum) {
        pr("The destination sector is not one of your warehouses.\n");
@@ -160,8 +163,6 @@ buy(void)
        pr("You don't have that much to spend!\n");
        return RET_FAIL;
     }
-    if (!check_comm_ok(&comm))
-       return RET_FAIL;
     if (bid > 0.04 + comm.com_price) {
        comm.com_price = bid;
        time(&now);