]> git.pond.sub.org Git - empserver/blobdiff - src/lib/commands/buy.c
Update copyright notice
[empserver] / src / lib / commands / buy.c
index f3c36151055df31b75511c48d0992e9b174d2794..3b24033e2ca91c1bf0569ca850ebf3743b9a4edd 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2013, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *  Copyright (C) 1986-2021, Dave Pare, Jeff Bailey, Thomas Ruschak,
  *                Ken Stevens, Steve McClure, Markus Armbruster
  *
  *  Empire is free software: you can redistribute it and/or modify
@@ -30,6 +30,7 @@
  *     Dave Pare, 1986
  *     Pat Loney, 1992
  *     Steve McClure, 1996-2000
+ *     Markus Armbruster, 2004-2018
  */
 
 #include <config.h>
@@ -111,8 +112,10 @@ buy(void)
     this part up.*/
     tally = 0.0;
     for (n = 0; gettrade(n, &tmpt); n++) {
+       if (!tmpt.trd_owner)
+           continue;
        if (tmpt.trd_maxbidder == player->cnum &&
-           tmpt.trd_unitid >= 0 && tmpt.trd_owner != player->cnum) {
+           tmpt.trd_owner != player->cnum) {
            tally += tmpt.trd_price * tradetax;
        }
     }
@@ -190,7 +193,6 @@ check_market(void)
     int m;
     int n;
     time_t now;
-    double tleft;
     double gain;
     double price;
 
@@ -198,10 +200,7 @@ check_market(void)
        if (comm.com_maxbidder == comm.com_owner || comm.com_owner == 0)
            continue;
        (void)time(&now);
-       tleft = MARK_DELAY / 3600.0 - (now - comm.com_markettime) / 3600.0;
-       if (tleft < 0)
-           tleft = 0;
-       if (tleft > 0.0)
+       if (comm.com_markettime + MARK_DELAY > now)
            continue;
        if (CANT_HAPPEN(comm.com_type <= I_NONE || comm.com_type > I_MAX))
            continue;