]> git.pond.sub.org Git - empserver/blobdiff - src/lib/update/produce.c
Rearrange produce() and prod() a bit to make them more similar
[empserver] / src / lib / update / produce.c
index 2085c36e03a792a04de9d98747f9dbd67a492929..2483aca1fcc183c6bc16c13955d87d7f7168f9dd 100644 (file)
@@ -75,29 +75,27 @@ produce(struct natstr *np, struct sctstr *sp, short *vec, int work,
     material_limit = prod_materials_cost(product, vec, &unit_work);
     if (material_limit <= 0)
        return 0;
-    /*
-     * calculate production efficiency.
-     */
+
+    /* sector p.e. */
     p_e = neweff / 100.0;
     if (resource) {
        unit_work++;
        p_e *= *resource / 100.0;
     }
-    /*
-     * determine number that can be made with
-     * the available workforce
-     */
     if (unit_work == 0)
        unit_work = 1;
-    material_consume = material_limit;
+
     worker_limit = roundavg(work * p_e / unit_work);
+    res_limit = prod_resource_limit(product, resource);
+
+    material_consume = res_limit;
     if (material_consume > worker_limit)
        material_consume = worker_limit;
-    res_limit = prod_resource_limit(product, resource);
-    if (material_consume > res_limit)
-       material_consume = res_limit;
+    if (material_consume > material_limit)
+       material_consume = material_limit;
     if (material_consume == 0)
        return 0;
+
     prodeff = prod_eff(desig, np->nat_level[product->p_nlndx]);
     if (prodeff <= 0.0 && !player->simulation) {
        wu(0, sp->sct_own,