/*
* Empire - A multi-player, client/server Internet based war game.
- * Copyright (C) 1986-2011, 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
* Dave Pare, 1986
* Pat Loney, 1992
* Steve McClure, 1996-2000
+ * Markus Armbruster, 2004-2021
*/
#include <config.h>
+#include "chance.h"
#include "commands.h"
#include "commodity.h"
#include "item.h"
-#include "land.h"
-#include "loan.h"
#include "news.h"
#include "optlist.h"
-#include "plane.h"
-#include "ship.h"
#include "trade.h"
/*
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,
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;
}
}
}
}
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");
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");
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;
- /* Add five minutes to the time if less than 5 minutes */
time(&now);
- if (((MARK_DELAY - (now - comm.com_markettime)) < 300) &&
- comm.com_maxbidder != player->cnum) {
- comm.com_markettime += 300;
- /* Special case - what if so much time has gone by? Well,
- Just reset the markettime so that only 5 minutes are left */
- if ((MARK_DELAY - (now - comm.com_markettime)) < 0)
- comm.com_markettime = (now - (MARK_DELAY - 300));
- }
+ if (comm.com_markettime + MARK_DELAY - now < minutes(5) &&
+ comm.com_maxbidder != player->cnum)
+ comm.com_markettime = now + minutes(5) - MARK_DELAY;
comm.com_maxbidder = player->cnum;
comm.com_x = x;
comm.com_y = y;
int m;
int n;
time_t now;
- double tleft;
double gain;
double price;
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;