Use int instead of long for money
Code dealing with money mixes int and long pretty haphazardly. Harmless, because practical amounts of money fit into int on any machine capable of running the server. Clean up anyway.
This commit is contained in:
parent
5ed02791f5
commit
5f46ced826
24 changed files with 73 additions and 73 deletions
|
@ -42,7 +42,7 @@
|
|||
#include "optlist.h"
|
||||
#include "product.h"
|
||||
|
||||
static void calc_all(long (*p_sect)[2], int *taxes, int *Ncivs,
|
||||
static void calc_all(int (*p_sect)[2], int *taxes, int *Ncivs,
|
||||
int *Nuws, int *bars, int *Nbars, int *mil,
|
||||
int *ships, int *sbuild, int *nsbuild, int *smaint,
|
||||
int *units, int *lbuild, int *nlbuild, int *lmaint,
|
||||
|
@ -53,7 +53,7 @@ int
|
|||
budg(void)
|
||||
{
|
||||
int i;
|
||||
long p_sect[SCT_BUDG_MAX+1][2];
|
||||
int p_sect[SCT_BUDG_MAX+1][2];
|
||||
int taxes, Ncivs, Nuws, bars, Nbars, mil;
|
||||
int ships, sbuild, nsbuild, smaint;
|
||||
int units, lbuild, nlbuild, lmaint;
|
||||
|
@ -84,12 +84,12 @@ budg(void)
|
|||
continue;
|
||||
pr("%-17s\t\t", dchr[i].d_name);
|
||||
if (i == SCT_ENLIST)
|
||||
pr("%ld mil \t", p_sect[i][0]);
|
||||
pr("%d mil \t", p_sect[i][0]);
|
||||
else if (dchr[i].d_prd >= 0)
|
||||
pr("%ld %-7s\t", p_sect[i][0], pchr[dchr[i].d_prd].p_sname);
|
||||
pr("%d %-7s\t", p_sect[i][0], pchr[dchr[i].d_prd].p_sname);
|
||||
else
|
||||
pr("\t\t");
|
||||
pr("\t\t%8ld\n", p_sect[i][1]);
|
||||
pr("\t\t%8d\n", p_sect[i][1]);
|
||||
expenses += p_sect[i][1];
|
||||
}
|
||||
|
||||
|
@ -129,16 +129,16 @@ budg(void)
|
|||
}
|
||||
|
||||
if (p_sect[SCT_EFFIC][1]) {
|
||||
sprintf(buf, "%ld sector%s",
|
||||
sprintf(buf, "%d sector%s",
|
||||
p_sect[SCT_EFFIC][0], splur(p_sect[SCT_EFFIC][0]));
|
||||
pr("Sector building\t\t\t%-16s\t\t%8ld\n",
|
||||
pr("Sector building\t\t\t%-16s\t\t%8d\n",
|
||||
buf, p_sect[SCT_EFFIC][1]);
|
||||
expenses += p_sect[SCT_EFFIC][1];
|
||||
}
|
||||
if (p_sect[SCT_MAINT][0]) {
|
||||
sprintf(buf, "%ld sector%s",
|
||||
sprintf(buf, "%d sector%s",
|
||||
p_sect[SCT_MAINT][0], splur(p_sect[SCT_MAINT][0]));
|
||||
pr("Sector maintenance\t\t%-16s\t\t%8ld\n",
|
||||
pr("Sector maintenance\t\t%-16s\t\t%8d\n",
|
||||
buf, p_sect[SCT_MAINT][1]);
|
||||
expenses += p_sect[SCT_MAINT][1];
|
||||
}
|
||||
|
@ -159,7 +159,7 @@ budg(void)
|
|||
pr("Income from bars\t\t%-32s%+8d\n", in, bars);
|
||||
}
|
||||
pr("Total income%s\n", dotsprintf(buf, "%+60d", income));
|
||||
pr("Balance forward\t\t\t\t\t\t %10ld\n", np->nat_money);
|
||||
pr("Balance forward\t\t\t\t\t\t %10d\n", np->nat_money);
|
||||
pr("Estimated delta\t\t\t\t\t\t %+10d\n", income - expenses);
|
||||
pr("Estimated new treasury%s\n",
|
||||
dotsprintf(buf, "%50d", np->nat_money + income - expenses));
|
||||
|
@ -172,7 +172,7 @@ budg(void)
|
|||
}
|
||||
|
||||
static void
|
||||
calc_all(long p_sect[][2],
|
||||
calc_all(int p_sect[][2],
|
||||
int *taxes, int *Ncivs, int *Nuws, int *bars, int *Nbars, int *mil,
|
||||
int *ships, int *sbuild, int *nsbuild, int *smaint,
|
||||
int *units, int *lbuild, int *nlbuild, int *lmaint,
|
||||
|
|
|
@ -136,9 +136,9 @@ coll(void)
|
|||
} else {
|
||||
(void)time(&loan.l_lastpay);
|
||||
owed -= pay;
|
||||
loan.l_amtdue = (long)owed;
|
||||
loan.l_amtdue = (int)owed;
|
||||
pay += loan.l_amtpaid;
|
||||
loan.l_amtpaid = pay;
|
||||
loan.l_amtpaid = (int)pay;
|
||||
wu(0, loan.l_lonee,
|
||||
"%s seized %s in partial payment of loan %d.\n",
|
||||
cname(player->cnum),
|
||||
|
|
|
@ -222,7 +222,7 @@ loan_accept(struct ltcomstr *ltcp)
|
|||
pr("%s no longer has the funds.\n", cname(ltcp->proposer));
|
||||
if (lp->l_amtdue <= 0)
|
||||
return RET_FAIL;
|
||||
pr("You may borrow $%ld at the same terms.\n", lp->l_amtdue);
|
||||
pr("You may borrow $%d at the same terms.\n", lp->l_amtdue);
|
||||
}
|
||||
lender->nat_money -= lp->l_amtdue;
|
||||
putnat(lender);
|
||||
|
@ -236,7 +236,7 @@ loan_accept(struct ltcomstr *ltcp)
|
|||
return RET_FAIL;
|
||||
}
|
||||
accpt(ltcp);
|
||||
pr("You are now $%ld richer (sort of).\n", lp->l_amtdue);
|
||||
pr("You are now $%d richer (sort of).\n", lp->l_amtdue);
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
* Chad Zabel, 1994
|
||||
* Steve McClure, 1998-2000
|
||||
* Ron Koenderink, 2003-2009
|
||||
* Markus Armbruster, 2003-2011
|
||||
* Markus Armbruster, 2003-2013
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
@ -302,7 +302,7 @@ prnat(struct natstr *np)
|
|||
pr("Research <R>: %.2f\n", np->nat_level[NAT_RLEV]);
|
||||
pr("Education <E>: %.2f\t\t", np->nat_level[NAT_ELEV]);
|
||||
pr("Happiness <H>: %.2f\n", np->nat_level[NAT_HLEV]);
|
||||
pr("Money <M>: $%6ld\n", np->nat_money);
|
||||
pr("Money <M>: $%6d\n", np->nat_money);
|
||||
pr("Telegrams <t>: %6d\n", np->nat_tgms);
|
||||
if (opt_HIDDEN) {
|
||||
pr("Countries contacted: ");
|
||||
|
@ -709,9 +709,9 @@ docountry(char op, int arg, char *p, struct natstr *np)
|
|||
np->nat_timeused = arg;
|
||||
break;
|
||||
case 'M':
|
||||
pr("Money changed from %ld to %d\n", np->nat_money, arg);
|
||||
pr("Money changed from %d to %d\n", np->nat_money, arg);
|
||||
wu(player->cnum, nat,
|
||||
"Money changed from %ld to %d by divine intervention.\n",
|
||||
"Money changed from %d to %d by divine intervention.\n",
|
||||
np->nat_money, arg);
|
||||
np->nat_money = arg;
|
||||
break;
|
||||
|
|
|
@ -66,7 +66,7 @@ fina(void)
|
|||
pr(" %-2d (%3d) %-8.8s (%3d) %-8.8s ", ni.cur,
|
||||
loan.l_loner, cname(loan.l_loner),
|
||||
loan.l_lonee, cname(loan.l_lonee));
|
||||
pr("%3d%% %3d %5ld %7.0f",
|
||||
pr("%3d%% %3d %5d %7.0f",
|
||||
loan.l_irate, loan.l_ldur, loan.l_amtpaid,
|
||||
ceil(loan_owed(&loan, now)));
|
||||
if (now > loan.l_duedate)
|
||||
|
|
|
@ -51,7 +51,7 @@ hard(void)
|
|||
struct nstr_item ni;
|
||||
struct sctstr sect;
|
||||
char buf[1024];
|
||||
long cash;
|
||||
int cash;
|
||||
struct natstr *natp;
|
||||
|
||||
if (!snxtitem(&ni, EF_PLANE, player->argp[1], NULL))
|
||||
|
|
|
@ -46,7 +46,7 @@ repa(void)
|
|||
struct natstr *loaner;
|
||||
int loan_num;
|
||||
int payment;
|
||||
long newdue;
|
||||
int newdue;
|
||||
char *cp;
|
||||
time_t now;
|
||||
char buf[1024];
|
||||
|
@ -75,13 +75,13 @@ repa(void)
|
|||
if (payment <= 0)
|
||||
return RET_SYN;
|
||||
|
||||
newdue = (long)ceil(loan_owed(&loan, time(&now)) - payment);
|
||||
newdue = (int)ceil(loan_owed(&loan, time(&now)) - payment);
|
||||
if (newdue < 0) {
|
||||
pr("You don't owe that much.\n");
|
||||
return RET_FAIL;
|
||||
}
|
||||
if (natp->nat_money < payment) {
|
||||
pr("You only have $%ld.\n", natp->nat_money);
|
||||
pr("You only have $%d.\n", natp->nat_money);
|
||||
return RET_FAIL;
|
||||
}
|
||||
player->dolcost += payment;
|
||||
|
|
|
@ -48,7 +48,7 @@ shark(void)
|
|||
struct natstr *natp;
|
||||
struct natstr *oldie;
|
||||
double owed;
|
||||
long payment;
|
||||
int payment;
|
||||
char buf[1024];
|
||||
|
||||
if (!opt_LOANS) {
|
||||
|
@ -78,7 +78,7 @@ shark(void)
|
|||
}
|
||||
pr("That loan is worth $%.2f.\n", owed);
|
||||
natp = getnatp(player->cnum);
|
||||
payment = (long)ceil(owed * (1.0 + loan.l_irate / 100.0));
|
||||
payment = (int)ceil(owed * (1.0 + loan.l_irate / 100.0));
|
||||
if (payment > natp->nat_money - 100.0) {
|
||||
pr("You do not have enough to cover that loan\n");
|
||||
return RET_FAIL;
|
||||
|
@ -87,7 +87,7 @@ shark(void)
|
|||
"%s bought loan #%d. You now owe him!\n",
|
||||
cname(player->cnum), arg);
|
||||
wu(0, loan.l_loner,
|
||||
"%s bought loan #%d out from under you for %ld\n",
|
||||
"%s bought loan #%d out from under you for %d\n",
|
||||
cname(player->cnum), arg, payment);
|
||||
pr("You now own loan #%d. Go break some legs.\n", arg);
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
* Dave Pare, 1986
|
||||
* Pat Loney, 1992
|
||||
* Steve McClure, 1996-2000
|
||||
* Markus Armbruster, 2004-2013
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
@ -102,7 +103,7 @@ trad(void)
|
|||
TRADE_DELAY / 3600.0 - (now - trade.trd_markettime) / 3600.0;
|
||||
if (tleft < 0.0)
|
||||
tleft = 0.0;
|
||||
pr("$%7ld %2d %5.2f hrs ",
|
||||
pr("$%7d %2d %5.2f hrs ",
|
||||
trade.trd_price, trade.trd_maxbidder, tleft);
|
||||
trade_desc(&tg.gen); /* XXX */
|
||||
pr("\n");
|
||||
|
|
|
@ -83,7 +83,7 @@ lupgr(void)
|
|||
int n;
|
||||
int tlev;
|
||||
int avail, cost;
|
||||
long cash;
|
||||
int cash;
|
||||
|
||||
if (!snxtitem(&ni, EF_LAND, player->argp[2], NULL))
|
||||
return RET_SYN;
|
||||
|
@ -163,7 +163,7 @@ supgr(void)
|
|||
int n;
|
||||
int tlev;
|
||||
int avail, cost;
|
||||
long cash;
|
||||
int cash;
|
||||
|
||||
if (!snxtitem(&ni, EF_SHIP, player->argp[2], NULL))
|
||||
return RET_SYN;
|
||||
|
@ -242,7 +242,7 @@ pupgr(void)
|
|||
int n;
|
||||
int tlev;
|
||||
int avail, cost;
|
||||
long cash;
|
||||
int cash;
|
||||
|
||||
if (!snxtitem(&ni, EF_PLANE, player->argp[2], NULL))
|
||||
return RET_SYN;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue