]> git.pond.sub.org Git - empserver/commitdiff
update: Drop unnecessary "not simulation" guards
authorMarkus Armbruster <armbru@pond.sub.org>
Fri, 3 Jun 2016 21:09:56 +0000 (23:09 +0200)
committerMarkus Armbruster <armbru@pond.sub.org>
Sun, 6 Aug 2017 17:59:57 +0000 (19:59 +0200)
Since changing *sp is safe now, we can update sp->sct_work,
sp->sct_loyal, sp->sct-che unconditionally in do_feed(), and likewise
sp->sct_item and sp's resource in produce().

Output of budget in smoke test and update test changes slightly,
because it now executes more code, and the PRNs this consumes affect
random rounding.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
src/lib/update/human.c
src/lib/update/produce.c
tests/update/journal.log

index c0f272ed3265cee3825193399cdf7577cc7ecb6b..f86541010ecc0e8f4c7f60e40e7ba7a96fc2bbc5 100644 (file)
@@ -91,8 +91,8 @@ do_feed(struct sctstr *sp, struct natstr *np, int *workp, int etu)
                    if (starved > 25)
                        nreport(sp->sct_own, N_DIE_FAMINE, 0, 1);
                }
-               sp->sct_loyal += roll(8) + 1;
            }
+           sp->sct_loyal += roll(8) + 1;
            sctwork = 0;
        } else {
            sctwork = sp->sct_work;
@@ -109,8 +109,7 @@ do_feed(struct sctstr *sp, struct natstr *np, int *workp, int etu)
                                             maxworkers));
            /* FIXME restores work charged for growfood() */
            /* age che */
-           if (!player->simulation)
-               sp->sct_che = age_people(sp->sct_che, etu);
+           sp->sct_che = age_people(sp->sct_che, etu);
        }
        if (manna)
            /* Take away food we conjured up */
index 3fc74a4a118f0bb2bba4aa3fbd761d892b0ee2e8..b931a4fc87c9c1cc03f67d7e1d188ccdc9deda69 100644 (file)
@@ -138,19 +138,17 @@ produce(struct natstr *np, struct sctstr *sp, int work,
     /*
      * Reset produced amount by commodity production ratio
      */
-    if (!player->simulation) {
-       materials_charge(product, sp->sct_item, material_consume);
-       if (resource && product->p_nrdep != 0) {
-           /*
-            * lower natural resource in sector depending on
-            * amount produced
-            */
-           val = *resource - roundavg(product->p_nrdep *
-                                      material_consume / 100.0);
-           if (val < 0)
-               val = 0;
-           *resource = val;
-       }
+    materials_charge(product, sp->sct_item, material_consume);
+    if (resource && product->p_nrdep != 0) {
+       /*
+        * lower natural resource in sector depending on
+        * amount produced
+        */
+       val = *resource - roundavg(product->p_nrdep *
+                                  material_consume / 100.0);
+       if (val < 0)
+           val = 0;
+       *resource = val;
     }
     *amount = actual;
     *cost = product->p_cost * material_consume;
index b491b21c6b863aa786df2fa6a864240add53bfb1..4d32fcfd16809b92849f5ca405f667893b01b0bd 100644 (file)
@@ -23,9 +23,9 @@
     Play#1 input budget
     Play#1 command budget
     Play#1 output Play#1 1 Sector Type                 Production                          Cost
-    Play#1 output Play#1 1 uranium mine                318 rad                              740
+    Play#1 output Play#1 1 uranium mine                317 rad                              740
     Play#1 output Play#1 1 park                        78 happy                             702
-    Play#1 output Play#1 1 defense plant               13 guns                              420
+    Play#1 output Play#1 1 defense plant               12 guns                              420
     Play#1 output Play#1 1 shell industry              156 shells                           528
     Play#1 output Play#1 1 technical center            5 tech                              2700
     Play#1 output Play#1 1 research lab                6 medical                            900
     Play#1 output Play#1 1 bank                        41 bars                              410
     Play#1 output Play#1 1 refinery                    2581 petrol                          291
     Play#1 output Play#1 1 enlistment center           75 mil                               225
-    Play#1 output Play#1 1 Ship building                       12 ships                            1531
+    Play#1 output Play#1 1 Ship building                       13 ships                            1536
     Play#1 output Play#1 1 Ship maintenance            32 ships                            2202
-    Play#1 output Play#1 1 Plane building                      13 planes                           1932
+    Play#1 output Play#1 1 Plane building                      13 planes                           1936
     Play#1 output Play#1 1 Plane maintenance           20 planes                           1004
     Play#1 output Play#1 1 Unit building                       6 units                             2300
     Play#1 output Play#1 1 Unit maintenance            16 units                             510
     Play#1 output Play#1 1 Sector building                     40 sectors                           773
     Play#1 output Play#1 1 Sector maintenance          2 sectors                            120
     Play#1 output Play#1 1 Military payroll            1155 mil, 0 res                     5777
-    Play#1 output Play#1 1 Total expenses.....................................................24667
+    Play#1 output Play#1 1 Total expenses.....................................................24676
     Play#1 output Play#1 1 Income from taxes           26911 civs, 9007 uws              +12625
     Play#1 output Play#1 1 Total income......................................................+12625
     Play#1 output Play#1 1 Balance forward                                                        25000
-    Play#1 output Play#1 1 Estimated delta                                                       -12042
-    Play#1 output Play#1 1 Estimated new treasury.............................................12958
+    Play#1 output Play#1 1 Estimated delta                                                       -12051
+    Play#1 output Play#1 1 Estimated new treasury.............................................12949
     Play#1 output Play#1 6 0 99
     Play#1 input neweff * ?newd#-
     Play#1 command neweff