Simplify market time left handling in a few places
This commit is contained in:
parent
c5f76e5853
commit
375e5170e4
3 changed files with 14 additions and 24 deletions
|
@ -30,6 +30,7 @@
|
||||||
* Dave Pare, 1986
|
* Dave Pare, 1986
|
||||||
* Pat Loney, 1992
|
* Pat Loney, 1992
|
||||||
* Steve McClure, 1996-2000
|
* Steve McClure, 1996-2000
|
||||||
|
* Markus Armbruster, 2004-2013
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
@ -190,7 +191,6 @@ check_market(void)
|
||||||
int m;
|
int m;
|
||||||
int n;
|
int n;
|
||||||
time_t now;
|
time_t now;
|
||||||
double tleft;
|
|
||||||
double gain;
|
double gain;
|
||||||
double price;
|
double price;
|
||||||
|
|
||||||
|
@ -198,10 +198,7 @@ check_market(void)
|
||||||
if (comm.com_maxbidder == comm.com_owner || comm.com_owner == 0)
|
if (comm.com_maxbidder == comm.com_owner || comm.com_owner == 0)
|
||||||
continue;
|
continue;
|
||||||
(void)time(&now);
|
(void)time(&now);
|
||||||
tleft = MARK_DELAY / 3600.0 - (now - comm.com_markettime) / 3600.0;
|
if (comm.com_markettime + MARK_DELAY > now)
|
||||||
if (tleft < 0)
|
|
||||||
tleft = 0;
|
|
||||||
if (tleft > 0.0)
|
|
||||||
continue;
|
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;
|
continue;
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
* Dave Pare, 1986
|
* Dave Pare, 1986
|
||||||
* Pat Loney, 1992
|
* Pat Loney, 1992
|
||||||
* Steve McClure, 1996
|
* Steve McClure, 1996
|
||||||
|
* Markus Armbruster, 2004-2013
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
@ -70,15 +71,14 @@ mark(void)
|
||||||
static void
|
static void
|
||||||
pr_mark(struct comstr *comm)
|
pr_mark(struct comstr *comm)
|
||||||
{
|
{
|
||||||
time_t now;
|
time_t now, tleft;
|
||||||
double tleft;
|
|
||||||
|
|
||||||
(void)time(&now);
|
(void)time(&now);
|
||||||
tleft = MARK_DELAY / 3600.0 - (now - comm->com_markettime) / 3600.0;
|
tleft = comm->com_markettime + MARK_DELAY - now;
|
||||||
if (tleft < 0.0)
|
if (tleft < 0)
|
||||||
tleft = 0.0;
|
tleft = 0;
|
||||||
pr(" %3d $%12.2f %2d %5.2f hrs (%3d) %c %6d ",
|
pr(" %3d $%12.2f %2d %5.2f hrs (%3d) %c %6d ",
|
||||||
comm->com_uid, comm->com_price, comm->com_maxbidder, tleft,
|
comm->com_uid, comm->com_price, comm->com_maxbidder, tleft / 3600.0,
|
||||||
comm->com_owner, ichr[comm->com_type].i_mnem, comm->com_amount);
|
comm->com_owner, ichr[comm->com_type].i_mnem, comm->com_amount);
|
||||||
if (comm->com_owner == player->cnum || player->god)
|
if (comm->com_owner == player->cnum || player->god)
|
||||||
pr("%s", xyas(comm->sell_x, comm->sell_y, player->cnum));
|
pr("%s", xyas(comm->sell_x, comm->sell_y, player->cnum));
|
||||||
|
|
|
@ -69,9 +69,8 @@ trad(void)
|
||||||
struct trdstr tmpt;
|
struct trdstr tmpt;
|
||||||
union empobj_storage tg;
|
union empobj_storage tg;
|
||||||
double canspend;
|
double canspend;
|
||||||
time_t now;
|
time_t now, tleft;
|
||||||
int bid;
|
int bid;
|
||||||
double tleft;
|
|
||||||
double tally;
|
double tally;
|
||||||
int i;
|
int i;
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
|
@ -99,12 +98,11 @@ trad(void)
|
||||||
};
|
};
|
||||||
pr(" %3d ", ni.cur);
|
pr(" %3d ", ni.cur);
|
||||||
(void)time(&now);
|
(void)time(&now);
|
||||||
tleft =
|
tleft = trade.trd_markettime + TRADE_DELAY - now;
|
||||||
TRADE_DELAY / 3600.0 - (now - trade.trd_markettime) / 3600.0;
|
if (tleft < 0)
|
||||||
if (tleft < 0.0)
|
tleft = 0;
|
||||||
tleft = 0.0;
|
|
||||||
pr("$%7d %2d %5.2f hrs ",
|
pr("$%7d %2d %5.2f hrs ",
|
||||||
trade.trd_price, trade.trd_maxbidder, tleft);
|
trade.trd_price, trade.trd_maxbidder, tleft / 3600.0);
|
||||||
trade_desc(&tg.gen); /* XXX */
|
trade_desc(&tg.gen); /* XXX */
|
||||||
pr("\n");
|
pr("\n");
|
||||||
if (trade.trd_owner == player->cnum && !player->god)
|
if (trade.trd_owner == player->cnum && !player->god)
|
||||||
|
@ -281,7 +279,6 @@ check_trade(void)
|
||||||
struct trdstr trade;
|
struct trdstr trade;
|
||||||
union empobj_storage tg;
|
union empobj_storage tg;
|
||||||
time_t now;
|
time_t now;
|
||||||
double tleft;
|
|
||||||
int price;
|
int price;
|
||||||
int saveid;
|
int saveid;
|
||||||
natid seller;
|
natid seller;
|
||||||
|
@ -309,11 +306,7 @@ check_trade(void)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
(void)time(&now);
|
(void)time(&now);
|
||||||
tleft =
|
if (trade.trd_markettime + TRADE_DELAY > now)
|
||||||
TRADE_DELAY / 3600.0 - (now - trade.trd_markettime) / 3600.0;
|
|
||||||
if (tleft < 0.0)
|
|
||||||
tleft = 0.0;
|
|
||||||
if (tleft > 0.0)
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
saveid = trade.trd_unitid;
|
saveid = trade.trd_unitid;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue