]> git.pond.sub.org Git - empserver/blobdiff - src/lib/commands/trad.c
Update copyright notice
[empserver] / src / lib / commands / trad.c
index 75773d06e154278622feaf1c0b969eb9ae154b4c..74fff15de85c5e623c88e7658fcb686e5aa0f5a2 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2006, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *  Copyright (C) 1986-2008, Dave Pare, Jeff Bailey, Thomas Ruschak,
  *                           Ken Stevens, Steve McClure
  *
  *  This program is free software; you can redistribute it and/or modify
 #include <config.h>
 
 #include <ctype.h>
-#include "misc.h"
-#include "sect.h"
-#include "nat.h"
+#include "commands.h"
+#include "commodity.h"
+#include "empobj.h"
+#include "land.h"
+#include "loan.h"
 #include "news.h"
-#include "ship.h"
 #include "nuke.h"
-#include "land.h"
+#include "optlist.h"
 #include "plane.h"
+#include "ship.h"
 #include "trade.h"
-#include "xy.h"
-#include "nsc.h"
-#include "file.h"
-#include "player.h"
-#include "commodity.h"
-#include "loan.h"
-#include "commands.h"
-#include "optlist.h"
 
 /*
  * format: trade
@@ -294,8 +288,6 @@ check_trade(void)
     struct trdstr trade;
     union empobj_storage tg;
     time_t now;
-    double subleft;
-    double monleft;
     double tleft;
     float price;
     int saveid;
@@ -336,23 +328,9 @@ check_trade(void)
            continue;
        }
 
-       monleft = 0;
        price = trade.trd_price;
        natp = getnatp(trade.trd_maxbidder);
-       if (natp->nat_money <= 0)
-           monleft = price;
-       if (natp->nat_money < price && natp->nat_money > 0) {
-           monleft = price - (natp->nat_money - 1);
-           natp->nat_money = 1;
-           price = price - monleft;
-       } else if (natp->nat_money > 0) {
-           monleft = 0;
-           natp->nat_money -= price;
-       }
-
-       subleft = monleft;
-
-       if (monleft > 0) {
+       if (natp->nat_money < price) {
            nreport(trade.trd_maxbidder, N_WELCH_DEAL, trade.trd_owner, 1);
            wu(0, trade.trd_owner,
               "%s tried to buy a %s #%d from you for $%.2f\n",
@@ -364,20 +342,20 @@ check_trade(void)
            wu(0, trade.trd_maxbidder,
               "You tried to buy %s #%d from %s for $%.2f\n",
               trade_nameof(&trade, &tg), saveid, cname(trade.trd_owner),
-              price * tradetax);
+              price);
            wu(0, trade.trd_maxbidder, "but couldn't afford it.\n");
            continue;
        }
 
 /* If we get this far, the sale will go through. */
-/* Only pay tax on the part you actually get cash for.  As a break,
-   we don't tax the part you have to give a loan on. */
 
+       natp->nat_money -= price;
        putnat(natp);
+
        natp = getnatp(trade.trd_owner);
-       /* Make sure we subtract the extra amount */
-       natp->nat_money += (roundavg(price * tradetax) - subleft);
+       natp->nat_money += roundavg(price * tradetax);
        putnat(natp);
+
        switch (trade.trd_type) {
        case EF_NUKE:
            tg.nuke.nuk_x = trade.trd_x;
@@ -402,12 +380,12 @@ check_trade(void)
            /* no cheap version of fly */
            if (opt_MOB_ACCESS) {
                tg.plane.pln_mobil = -(etu_per_update / sect_mob_neg_factor);
+               game_tick_to_now(&tg.plane.pln_access);
            } else {
                tg.plane.pln_mobil = 0;
            }
            tg.plane.pln_mission = 0;
            tg.plane.pln_harden = 0;
-           time(&tg.plane.pln_access);
            tg.plane.pln_ship = -1;
            tg.plane.pln_land = -1;
            break;
@@ -432,11 +410,11 @@ check_trade(void)
            /* no cheap version of fly */
            if (opt_MOB_ACCESS) {
                tg.land.lnd_mobil = -(etu_per_update / sect_mob_neg_factor);
+               game_tick_to_now(&tg.land.lnd_access);
            } else {
                tg.land.lnd_mobil = 0;
            }
            tg.land.lnd_harden = 0;
-           time(&tg.land.lnd_access);
            tg.land.lnd_mission = 0;
            /* Drop any land units this unit was carrying */
            snxtitem_xy(&ni, EF_LAND, tg.land.lnd_x, tg.land.lnd_y);