]> git.pond.sub.org Git - empserver/commitdiff
(populace): Remove parameter vec, work with sp->sct_item[] instead.
authorMarkus Armbruster <armbru@pond.sub.org>
Wed, 10 Mar 2004 17:59:37 +0000 (17:59 +0000)
committerMarkus Armbruster <armbru@pond.sub.org>
Wed, 10 Mar 2004 17:59:37 +0000 (17:59 +0000)
This is safe, because the only caller passed a copy of the latter
created with getvec(), and populace() doesn't change it.
(tax): Replace getvec() by direct, read-only item access.

include/prototypes.h
src/lib/update/populace.c
src/lib/update/prepare.c

index ed5cefa6d365072a17ac6a1915c71e035b30f6cb..ec0cdbe08f979439789e574a63bb757ea8597c2f 100644 (file)
@@ -595,8 +595,7 @@ extern int plague_people(struct natstr *, int *, u_short *, u_short *, int);
 /* plane.c */
 extern int prod_plane(int, int, int *, int);
 /* populace.c */
-extern void populace(struct natstr *, register struct sctstr *,
-                    register int *, int);
+extern void populace(struct natstr *, register struct sctstr *, int);
 extern int total_work(register int, register int, register int,
                      register int, register int);
 /* prepare.c */
index e4623dbff12719753133e3e43fb9946e46c755f8..586c4c5e07796b1050aa0b0aa99d2b802bd545dc 100644 (file)
 #include "lost.h"
 
 void
-populace(struct natstr *np, register struct sctstr *sp, register int *vec,
-        int etu)
+populace(struct natstr *np, register struct sctstr *sp, int etu)
 {
     float hap;
     float tech;
     float edu;
     float pct;
     int n;
+    int civ = sp->sct_item[I_CIVIL];
+    int mil = sp->sct_item[I_MILIT];
 
-    if (vec[I_CIVIL] == 0 && vec[I_MILIT] > 0) {
+    if (civ == 0 && mil > 0) {
        sp->sct_work = 100;
        sp->sct_loyal = 0;
        sp->sct_oldown = sp->sct_own;
     }
-    if (!vec[I_CIVIL] && !vec[I_MILIT] && !vec[I_UW] &&
-       !has_units(sp->sct_x, sp->sct_y, sp->sct_own, 0)) {
+    if (!civ && !mil && !sp->sct_item[I_UW]
+       && !has_units(sp->sct_x, sp->sct_y, sp->sct_own, 0)) {
        makelost(EF_SECTOR, sp->sct_own, 0, sp->sct_x, sp->sct_y);
        sp->sct_own = 0;
        sp->sct_oldown = 0;
@@ -93,7 +94,7 @@ populace(struct natstr *np, register struct sctstr *sp, register int *vec,
            n = 127;
        sp->sct_loyal = n;
     }
-    if (sp->sct_loyal > 65 && vec[I_MILIT] < vec[I_CIVIL] / 20) {
+    if (sp->sct_loyal > 65 && mil < civ / 20) {
        int work_red;
 
        work_red = sp->sct_loyal - (50 + (random() % 15));
index 07b08a751dde6eb388a2a9c51c47ef6d2080c307..e1b385f99c04bd724f23dce0b3e18de3722da014 100644 (file)
@@ -113,32 +113,28 @@ void
 tax(struct sctstr *sp, struct natstr *np, int etu, long *pop, int *civ_tax,
     int *uw_tax, int *mil_pay)
 {
-    int vec[I_MAX + 1];
-
     *civ_tax = 0;
     *uw_tax = 0;
     *mil_pay = 0;
-    if (getvec(VT_ITEM, vec, (s_char *)sp, EF_SECTOR) <= 0)
-       return;
 
     if (!player->simulation)
-       populace(np, sp, vec, etu);
-    *civ_tax = (int)(0.5 + vec[I_CIVIL] * sp->sct_effic *
+       populace(np, sp, etu);
+    *civ_tax = (int)(0.5 + sp->sct_item[I_CIVIL] * sp->sct_effic *
                     etu * money_civ / 100);
     /*
      * captured civs only pay 1/4 taxes
      */
     if (sp->sct_own != sp->sct_oldown)
        *civ_tax = *civ_tax / 4;
-    *uw_tax = (int)(0.5 + vec[I_UW] * sp->sct_effic *
+    *uw_tax = (int)(0.5 + sp->sct_item[I_UW] * sp->sct_effic *
                    etu * money_uw / 100);
-    *mil_pay = vec[I_MILIT] * etu * money_mil;
+    *mil_pay = sp->sct_item[I_MILIT] * etu * money_mil;
 
     /*
      * only non-captured civs add to census for nation
      */
     if (sp->sct_oldown == sp->sct_own)
-       *pop += vec[I_CIVIL];
+       *pop += sp->sct_item[I_CIVIL];
 }
 
 int