From 74b8b9932d968b7ddc7f9a615e7e8279a8e609be Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Sun, 13 Jan 2013 16:13:15 +0100 Subject: [PATCH] Use int instead of long for military reserves 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 | 2 +- src/lib/commands/budg.c | 2 +- src/lib/commands/demo.c | 2 +- src/lib/commands/edit.c | 6 +++--- src/lib/commands/enli.c | 4 ++-- src/lib/commands/nati.c | 2 +- src/lib/common/nsc.c | 2 +- tests/smoke/smoke.out | 6 +++--- 8 files changed, 13 insertions(+), 13 deletions(-) diff --git a/include/nat.h b/include/nat.h index 3243d2aec..fc7f6aeab 100644 --- a/include/nat.h +++ b/include/nat.h @@ -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 */ diff --git a/src/lib/commands/budg.c b/src/lib/commands/budg.c index df2b9d381..3f1dd758e 100644 --- a/src/lib/commands/budg.c +++ b/src/lib/commands/budg.c @@ -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; } diff --git a/src/lib/commands/demo.c b/src/lib/commands/demo.c index afb0fdaf6..f4e430e99 100644 --- a/src/lib/commands/demo.c +++ b/src/lib/commands/demo.c @@ -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; diff --git a/src/lib/commands/edit.c b/src/lib/commands/edit.c index 04f07371c..1801c19af 100644 --- a/src/lib/commands/edit.c +++ b/src/lib/commands/edit.c @@ -291,7 +291,7 @@ prnat(struct natstr *np) pr("Name : %-20s\t", np->nat_cnam); pr("Representative : %-20s\n", np->nat_pnam); pr("BTUs : %3d\t\t\t", np->nat_btu); - pr("Reserves : %5ld\n", np->nat_reserve); + pr("Reserves : %5d\n", np->nat_reserve); pr("Capital : %s\t\t", xyas(np->nat_xcap, np->nat_ycap, player->cnum)); pr("Origin : %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; diff --git a/src/lib/commands/enli.c b/src/lib/commands/enli.c index 7986ed52b..7e72549bf 100644 --- a/src/lib/commands/enli.c +++ b/src/lib/commands/enli.c @@ -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); diff --git a/src/lib/commands/nati.c b/src/lib/commands/nati.c index 8c9d63a79..f222e9cac 100644 --- a/src/lib/commands/nati.c +++ b/src/lib/commands/nati.c @@ -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", diff --git a/src/lib/common/nsc.c b/src/lib/common/nsc.c index a03d573f7..643d688d3 100644 --- a/src/lib/common/nsc.c +++ b/src/lib/common/nsc.c @@ -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}, diff --git a/tests/smoke/smoke.out b/tests/smoke/smoke.out index 0dfa98b6e..835d4b6b0 100644 --- a/tests/smoke/smoke.out +++ b/tests/smoke/smoke.out @@ -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 -- 2.43.0