]> git.pond.sub.org Git - empserver/commitdiff
Use int instead of long for military reserves
authorMarkus Armbruster <armbru@pond.sub.org>
Sun, 13 Jan 2013 15:13:15 +0000 (16:13 +0100)
committerMarkus Armbruster <armbru@pond.sub.org>
Wed, 8 May 2013 04:57:54 +0000 (06:57 +0200)
Code dealing with reserves mixes int and long pretty haphazardly.
Harmless, because practical reserves fit easily on any machine capable
of running the server.  Clean up anyway.

include/nat.h
src/lib/commands/budg.c
src/lib/commands/demo.c
src/lib/commands/edit.c
src/lib/commands/enli.c
src/lib/commands/nati.c
src/lib/common/nsc.c
tests/smoke/smoke.out

index 3243d2aec820c5a22dbbb6b5a8c83e55c5d4d7ce..fc7f6aeab3b0ca15923ee799eea5bfba31a958c9 100644 (file)
@@ -105,7 +105,7 @@ struct natstr {
     int nat_timeused;          /* number of seconds used today */
     short nat_btu;             /* bureaucratic time units */
     short nat_access;          /* The tick when BTUs were last updated */
-    long nat_reserve;          /* military reserves */
+    int nat_reserve;           /* military reserves */
     long nat_money;            /* moola */
     time_t nat_last_login;     /* time of last login, 0 menas never */
     time_t nat_last_logout;    /* time of last logout, 0 means never */
index df2b9d38170009d8d5c70fb50bcf4c82d21646e9..3f1dd758eb6c1c3988636e0f63b70b37723d43ce 100644 (file)
@@ -144,7 +144,7 @@ budg(void)
     }
     if (mil) {
        n = (mil - np->nat_reserve * money_res * etu) / (etu * money_mil);
-       sprintf(in, "%d mil, %d res", n, (int)np->nat_reserve);
+       sprintf(in, "%d mil, %d res", n, np->nat_reserve);
        pr("Military payroll\t\t%-32s%8d\n", in, -mil);
        expenses -= mil;
     }
index afb0fdaf60add678de5a0b946e0fe3a40590a16a..f4e430e99e644aca189b4d54a325946e690b6e4e 100644 (file)
@@ -105,7 +105,7 @@ demo(void)
     }
     pr("Total new civilians : %d\n", mil_demob);
     if (*p == 'y')
-       pr("Military reserve stands at %ld (up %d)\n",
+       pr("Military reserve stands at %d (up %d)\n",
           natp->nat_reserve + reserves, reserves);
     if (reserves > 0) {
        natp->nat_reserve += reserves;
index 04f07371ce285fff1af0bea06073c16e8fb1a1b8..1801c19af75917fae122204a5b6453a0ec79155f 100644 (file)
@@ -291,7 +291,7 @@ prnat(struct natstr *np)
     pr("Name <n>: %-20s\t", np->nat_cnam);
     pr("Representative <r>: %-20s\n", np->nat_pnam);
     pr("BTUs <b>: %3d\t\t\t", np->nat_btu);
-    pr("Reserves <m>: %5ld\n", np->nat_reserve);
+    pr("Reserves <m>: %5d\n", np->nat_reserve);
     pr("Capital <c>: %s\t\t",
        xyas(np->nat_xcap, np->nat_ycap, player->cnum));
     pr("Origin <o>: %3s\n",
@@ -674,10 +674,10 @@ docountry(char op, int arg, char *p, struct natstr *np)
        break;
     case 'm':
        benefit(nat, np->nat_reserve < arg);
-       pr("Military reserves changed from %ld to %d\n",
+       pr("Military reserves changed from %d to %d\n",
           np->nat_reserve, arg);
        wu(player->cnum, nat,
-          "Military reserves changed from %ld to %d by divine intervention.\n",
+          "Military reserves changed from %d to %d by divine intervention.\n",
           np->nat_reserve, arg);
        np->nat_reserve = arg;
        break;
index 7986ed52bcae97b79b5110b59239d303e6daba65..7e72549bfcbbc03b33ba0386e471d39b8741c632 100644 (file)
@@ -47,7 +47,7 @@ enli(void)
     int newmil;
     int milwant;
     int totalmil;
-    long reserve;
+    int reserve;
     char *p;
     int quota;
     char prompt[128];
@@ -123,7 +123,7 @@ enli(void)
        }
     }
     pr("Total new enlistment : %d\n", totalmil);
-    pr("Military reserves stand at %ld\n", reserve);
+    pr("Military reserves stand at %d\n", reserve);
     if (totalmil) {
        natp->nat_reserve -= totalmil;
        putnat(natp);
index 8c9d63a79245049c9e5ad65dca47ef38c786fb08..f222e9cac3ef0ca9f0b04ea466c881d232083302 100644 (file)
@@ -79,7 +79,7 @@ nati(void)
        }
     }
     pr(" The treasury has $%.2f", (double)natp->nat_money);
-    pr("     Military reserves: %ld\n", natp->nat_reserve);
+    pr("     Military reserves: %d\n", natp->nat_reserve);
     pr("Education..........%6.2f       Happiness.......%6.2f\n",
        natp->nat_level[NAT_ELEV], natp->nat_level[NAT_HLEV]);
     pr("Technology.........%6.2f       Research........%6.2f\n",
index a03d573f7876a53b6617cd5520267408a4de9d8b..643d688d3ba8417aa1f1327601973d5a7b7b34e3 100644 (file)
@@ -574,7 +574,7 @@ struct castr cou_ca[] = {
     {"timeused", fldoff(nat_timeused), NSC_INT, 0, NULL, EF_BAD, 0},
     {"btu", fldoff(nat_btu), NSC_SHORT, 0, NULL, EF_BAD, 0},
     {"access", fldoff(nat_access), NSC_SHORT, 0, NULL, EF_BAD, 0},
-    {"milreserve", fldoff(nat_reserve), NSC_LONG, 0, NULL, EF_BAD, 0},
+    {"milreserve", fldoff(nat_reserve), NSC_INT, 0, NULL, EF_BAD, 0},
     {"money", fldoff(nat_money), NSC_LONG, 0, NULL, EF_BAD, 0},
     {"login", fldoff(nat_last_login), NSC_TIME, 0, NULL, EF_BAD, 0},
     {"logout", fldoff(nat_last_logout), NSC_TIME, 0, NULL, EF_BAD, 0},
index 0dfa98b6ed6884984baae9c4f228ee1f3964396a..835d4b6b0d314412bb59734c7b8c4edbb3c70153 100644 (file)
@@ -268,7 +268,7 @@ Player 00 Turn 00 starting
 "timeused" 8 1 0 -1
 "btu" 6 1 0 -1
 "access" 6 1 0 -1
-"milreserve" 1 1 0 -1
+"milreserve" 8 1 0 -1
 "money" 1 1 0 -1
 "login" 12 1 0 -1
 "logout" 12 1 0 -1
@@ -757,7 +757,7 @@ Player 00 Turn 00 starting
 "timeused" 8 0 0 -1
 "btu" 6 0 0 -1
 "access" 6 0 0 -1
-"milreserve" 1 0 0 -1
+"milreserve" 8 0 0 -1
 "money" 1 0 0 -1
 "login" 12 0 0 -1
 "logout" 12 0 0 -1
@@ -1644,7 +1644,7 @@ CENSUS                   del dst
 "timeused" 8 0 0 -1
 "btu" 6 0 0 -1
 "access" 6 0 0 -1
-"milreserve" 1 0 0 -1
+"milreserve" 8 0 0 -1
 "money" 1 0 0 -1
 "login" 12 0 0 -1
 "logout" 12 0 0 -1