From 739b5ac6fb59d8209c2822541ada2c51f03c352d Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Sun, 21 May 2006 08:48:16 +0000 Subject: [PATCH] (prod): Round the final cost instead of truncating along the way. (prod, produce): Simplify calculation TECH_POP cost factor slightly. --- src/lib/commands/prod.c | 8 ++++---- src/lib/update/produce.c | 3 +-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/lib/commands/prod.c b/src/lib/commands/prod.c index 6bb3aaf3..73282c45 100644 --- a/src/lib/commands/prod.c +++ b/src/lib/commands/prod.c @@ -78,7 +78,7 @@ prod(void) int work; int totpop; int act; /* actual production */ - int cost; + double cost; int i; int max; /* production w/infinite materials */ int nsect; @@ -250,12 +250,12 @@ prod(void) } else mtake = take = 0.0; - cost = (int)(take * (double)pp->p_cost); + cost = take * pp->p_cost; if (opt_TECH_POP) { if (pp->p_level == NAT_TLEV) { totpop = count_pop(sect.sct_own); if (totpop > 50000) - cost = (int)((double)cost * (double)totpop / 50000.0); + cost *= totpop / 50000.0; } } @@ -333,7 +333,7 @@ prod(void) } pr(" %.2f", prodeff); - pr(" $%-5d", cost); + pr(" $%-5.0f", cost); for (i = 0; i < 3; i++) { if (i < MAXPRCON && cmnem[i]) pr("%4d%c", cuse[i], cmnem[i]); diff --git a/src/lib/update/produce.c b/src/lib/update/produce.c index 2c87e513..939fc0ca 100644 --- a/src/lib/update/produce.c +++ b/src/lib/update/produce.c @@ -165,8 +165,7 @@ produce(struct natstr *np, struct sctstr *sp, short *vec, int work, if (opt_TECH_POP) { if (product->p_level == NAT_TLEV) { if (tpops[sp->sct_own] > 50000) - *cost = - (double)*cost * (double)tpops[sp->sct_own] / 50000.0; + *cost *= tpops[sp->sct_own] / 50000.0; } }