]> git.pond.sub.org Git - empserver/blobdiff - src/lib/commands/mark.c
Update copyright notice
[empserver] / src / lib / commands / mark.c
index 9bcaf85c25a75b853c0b4f9037b7d2aeeb0aba36..a1a777fabd61856a07e0fa5630f8733b320553ba 100644 (file)
@@ -1,11 +1,11 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2004, Dave Pare, Jeff Bailey, Thomas Ruschak,
- *                           Ken Stevens, Steve McClure
+ *  Copyright (C) 1986-2018, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *                Ken Stevens, Steve McClure, Markus Armbruster
  *
- *  This program is free software; you can redistribute it and/or modify
+ *  Empire is free software: you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
+ *  the Free Software Foundation, either version 3 of the License, or
  *  (at your option) any later version.
  *
  *  This program is distributed in the hope that it will be useful,
  *  GNU General Public License for more details.
  *
  *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *
  *  ---
  *
- *  See the "LEGAL", "LICENSE", "CREDITS" and "README" files for all the
- *  related information and legal notices. It is expected that any future
- *  projects/authors will amend these files as needed.
+ *  See files README, COPYING and CREDITS in the root of the source
+ *  tree for related information and legal notices.  It is expected
+ *  that future projects/authors will amend these files as needed.
  *
  *  ---
  *
  *  mark.c: Display report for commodities
- * 
+ *
  *  Known contributors to this file:
  *     Dave Pare, 1986
  *     Pat Loney, 1992
  *     Steve McClure, 1996
+ *     Markus Armbruster, 2004-2013
  */
 
-#include "misc.h"
-#include "nat.h"
-#include "item.h"
-#include "commodity.h"
-#include "player.h"
-#include "file.h"
+#include <config.h>
+
 #include "commands.h"
+#include "commodity.h"
+#include "item.h"
 #include "optlist.h"
 
 int
@@ -54,7 +52,7 @@ mark(void)
        return RET_FAIL;
     }
 
-    if (player->argp[1] && player->argp[1]) {
+    if (player->argp[1]) {
        p = getstarg(player->argp[1], "What commodity (or 'all')? ", buf);
        if (!p)
            return RET_SYN;
@@ -64,7 +62,7 @@ mark(void)
            ip = item_by_name(p);
            if (!ip)
                return RET_SYN;
-           return display_mark(ip->i_vtype, 0);
+           return display_mark(ip->i_uid, 0);
        }
     }
     return display_mark(I_NONE, 1);
@@ -73,18 +71,15 @@ mark(void)
 static void
 pr_mark(struct comstr *comm)
 {
-    time_t now;
-    double tleft;
+    time_t now, tleft;
 
     (void)time(&now);
-    tleft = MARK_DELAY / 3600.0 - (now - comm->com_markettime) / 3600.0;
-    if (tleft < 0.0)
-       tleft = 0.0;
+    tleft = comm->com_markettime + MARK_DELAY - now;
+    if (tleft < 0)
+       tleft = 0;
     pr(" %3d  $%12.2f  %2d  %5.2f hrs  (%3d)   %c    %6d  ",
-       comm->com_uid,
-       comm->com_price,
-       comm->com_maxbidder,
-       tleft, comm->com_owner, ichr[comm->com_type].i_mnem, comm->com_amount);
+       comm->com_uid, comm->com_price, comm->com_maxbidder, tleft / 3600.0,
+       comm->com_owner, ichr[comm->com_type].i_mnem, comm->com_amount);
     if (comm->com_owner == player->cnum || player->god)
        pr("%s", xyas(comm->sell_x, comm->sell_y, player->cnum));
     pr("\n");
@@ -100,7 +95,7 @@ display_mark(i_type only_itype, int only_cheapest)
     int cheapest_items[I_MAX + 1];
     i_type i;
 
-    /* Execute trades so report lists only lots that are still available.  */
+    /* Execute trades so report lists only lots that are still available. */
     check_market();
     check_trade();
 
@@ -115,8 +110,7 @@ display_mark(i_type only_itype, int only_cheapest)
        for (sellers = 0; getcomm(sellers, &comm); sellers++) {
            if (comm.com_owner == 0)
                continue;
-           if (CANT_HAPPEN(comm.com_type <= I_NONE
-                               || comm.com_type > I_MAX))
+           if (CANT_HAPPEN(comm.com_type <= I_NONE || comm.com_type > I_MAX))
                continue;
            if (cheapest_items[comm.com_type] != -1) {
                getcomm(cheapest_items[comm.com_type], &comm2);