]> git.pond.sub.org Git - empserver/commitdiff
(prod): Round the final cost instead of truncating along the way.
authorMarkus Armbruster <armbru@pond.sub.org>
Sun, 21 May 2006 08:48:16 +0000 (08:48 +0000)
committerMarkus Armbruster <armbru@pond.sub.org>
Sun, 21 May 2006 08:48:16 +0000 (08:48 +0000)
(prod, produce): Simplify calculation TECH_POP cost factor slightly.

src/lib/commands/prod.c
src/lib/update/produce.c

index 6bb3aaf337c96eb684621f516750f06b082e54d3..73282c45ded478a7d730b2a369bba01e5eab6f35 100644 (file)
@@ -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]);
index 2c87e513cfb7f81dcdb2539097ef5ee45bb46ec5..939fc0ca77383476ae0cd811b3488b0a392dc967 100644 (file)
@@ -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;
        }
     }