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.
int get_materials(struct sctstr *, struct bp *, int *, int);
-extern long money[MAXNOC];
+extern int money[MAXNOC];
extern int pops[MAXNOC];
-extern long sea_money[MAXNOC];
-extern long lnd_money[MAXNOC];
-extern long air_money[MAXNOC];
+extern int sea_money[MAXNOC];
+extern int lnd_money[MAXNOC];
+extern int air_money[MAXNOC];
extern int tpops[MAXNOC];
extern float levels[MAXNOC][4];
*
* Known contributors to this file:
* Marc Olzheim, 2004
- * Markus Armbruster, 2004-2012
+ * Markus Armbruster, 2004-2013
*/
/*
"Players have their coordinate system at deity 0,0 (0 - no, 1 - yes)")
EMPCFBOTH("at_least_one_100", at_least_one_100, int, NSC_INT, KM_INTERNAL,
"Initialize new countries with at least one sector with 100 of all resource")
-EMPCFBOTH("start_cash", start_cash, long, NSC_LONG, KM_INTERNAL,
+EMPCFBOTH("start_cash", start_cash, int, NSC_INT, KM_INTERNAL,
"Starting cash for new countries")
EMPCF_COMMENT("\n\n### Technology/Research/Education/Happiness")
signed char l_status; /* loan status */
int l_irate; /* interest rate */
int l_ldur; /* intended duration */
- long l_amtpaid; /* amount paid so far */
- long l_amtdue; /* amount still owed */
+ int l_amtpaid; /* amount paid so far */
+ int l_amtdue; /* amount still owed */
time_t l_lastpay; /* date of most recent payment */
time_t l_duedate; /* date after which interest doubles, etc */
};
short nat_btu; /* bureaucratic time units */
short nat_access; /* The tick when BTUs were last updated */
int nat_reserve; /* military reserves */
- long nat_money; /* moola */
+ int 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 */
time_t nat_newstim; /* date news last read */
extern void do_fallout(struct sctstr *, int);
extern void spread_fallout(struct sctstr *, int);
extern void decay_fallout(struct sctstr *, int);
-extern void produce_sect(int, int, struct bp *, long [][2]);
+extern void produce_sect(int, int, struct bp *, int[][2]);
/* ship.c */
extern int prod_ship(int, int, struct bp *, int);
/* end of part matching struct empobj */
short trd_type;
int trd_unitid;
- long trd_price;
+ int trd_price;
int trd_maxbidder;
time_t trd_markettime;
coord trd_x; /* destination for teleporting trade */
#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,
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;
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];
}
}
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];
}
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));
}
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,
} 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),
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);
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;
}
* Chad Zabel, 1994
* Steve McClure, 1998-2000
* Ron Koenderink, 2003-2009
- * Markus Armbruster, 2003-2011
+ * Markus Armbruster, 2003-2013
*/
#include <config.h>
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: ");
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;
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)
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))
struct natstr *loaner;
int loan_num;
int payment;
- long newdue;
+ int newdue;
char *cp;
time_t now;
char buf[1024];
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;
struct natstr *natp;
struct natstr *oldie;
double owed;
- long payment;
+ int payment;
char buf[1024];
if (!opt_LOANS) {
}
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;
"%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);
}
* Dave Pare, 1986
* Pat Loney, 1992
* Steve McClure, 1996-2000
+ * Markus Armbruster, 2004-2013
*/
#include <config.h>
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");
int n;
int tlev;
int avail, cost;
- long cash;
+ int cash;
if (!snxtitem(&ni, EF_LAND, player->argp[2], NULL))
return RET_SYN;
int n;
int tlev;
int avail, cost;
- long cash;
+ int cash;
if (!snxtitem(&ni, EF_SHIP, player->argp[2], NULL))
return RET_SYN;
int n;
int tlev;
int avail, cost;
- long cash;
+ int cash;
if (!snxtitem(&ni, EF_PLANE, player->argp[2], NULL))
return RET_SYN;
EF_AGREEMENT_STATUS, 0},
{"irate", fldoff(l_irate), NSC_INT, 0, NULL, EF_BAD, 0},
{"ldur", fldoff(l_ldur), NSC_INT, 0, NULL, EF_BAD, 0},
- {"amtpaid", fldoff(l_amtpaid), NSC_LONG, 0, NULL, EF_BAD, 0},
- {"amtdue", fldoff(l_amtdue), NSC_LONG, 0, NULL, EF_BAD, 0},
+ {"amtpaid", fldoff(l_amtpaid), NSC_INT, 0, NULL, EF_BAD, 0},
+ {"amtdue", fldoff(l_amtdue), NSC_INT, 0, NULL, EF_BAD, 0},
{"lastpay", fldoff(l_lastpay), NSC_TIME, 0, NULL, EF_BAD, 0},
{"duedate", fldoff(l_duedate), NSC_TIME, 0, NULL, EF_BAD, 0},
{NULL, 0, NSC_NOTYPE, 0, NULL, EF_BAD, 0}
{"type", fldoff(trd_type), NSC_CHAR, 0, NULL, EF_TABLE, 0},
/* unitid's ca_table given by type, but can't express that: */
{"unitid", fldoff(trd_unitid), NSC_INT, 0, NULL, EF_BAD, 0},
- {"price", fldoff(trd_price), NSC_LONG, 0, NULL, EF_BAD, 0},
+ {"price", fldoff(trd_price), NSC_INT, 0, NULL, EF_BAD, 0},
{"maxbidder", fldoff(trd_maxbidder), NSC_INT, 0, NULL, EF_NATION, 0},
{"markettime", fldoff(trd_markettime), NSC_TIME, 0, NULL, EF_BAD, 0},
/* should let maxbidder access xloc, yloc, but can't express that: */
{"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_INT, 0, NULL, EF_BAD, 0},
- {"money", fldoff(nat_money), NSC_LONG, 0, NULL, EF_BAD, 0},
+ {"money", fldoff(nat_money), NSC_INT, 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},
{"newstim", fldoff(nat_newstim), NSC_TIME, 0, NULL, EF_BAD, 0},
* Known contributors to this file:
* Ken Stevens, 1995
* Steve McClure, 1996
- * Markus Armbruster, 2004-2012
+ * Markus Armbruster, 2004-2013
*/
#include <config.h>
int torpedo_damage = 40; /* damage is X + 1dX + 1dX, so 40+1d40+1d40 */
-long start_cash = 25000;
+int start_cash = 25000;
/* initial levels */
float start_education = 0.0;
*
* Known contributors to this file:
* Steve McClure, 2000
- * Markus Armbruster, 2007-2008
+ * Markus Armbruster, 2007-2013
*/
#include <config.h>
struct natstr *natp;
struct lonstr loan;
struct comstr comm;
- long lose;
- long gain;
+ int lose, gain;
char *verb;
int loan_num, comm_num;
verb = sp->sct_own ? "sacked" : "obliterated";
wu(0, coun, "* %s just %s your capital! *\n",
cname(player->cnum), verb);
- wu(0, coun, "You lost $%ld and they gained $%ld\n", lose, gain);
+ wu(0, coun, "You lost $%d and they gained $%d\n", lose, gain);
wu(0, coun, "You need to use 'capital' to activate a new capital.\n");
- wu(0, 0, "%s just %s %s's capital and gained $%ld\n",
+ wu(0, 0, "%s just %s %s's capital and gained $%d\n",
cname(player->cnum), verb, cname(coun), gain);
if (opt_LOANS && sp->sct_own) {
pr("\nLoan #%d from %s to", n, cname(loan->l_loner));
pr(" %s\n", cname(loan->l_lonee));
if (loan->l_status == LS_PROPOSED) {
- pr("(proposed) principal=$%ld interest rate=%d%%",
+ pr("(proposed) principal=$%d interest rate=%d%%",
loan->l_amtdue, loan->l_irate);
pr(" duration(days)=%d\n", loan->l_ldur);
if (loan->l_duedate < now) {
return 1;
}
- pr("Amount paid to date $%ld\n", loan->l_amtpaid);
+ pr("Amount paid to date $%d\n", loan->l_amtpaid);
pr("Amount due (if paid now) $%.2f", loan_owed(loan, now));
if (now <= loan->l_duedate) {
pr(" (if paid on due date) $%.2f\n",
#include "unit.h"
#include "update.h"
-long money[MAXNOC];
+int money[MAXNOC];
int pops[MAXNOC];
-long sea_money[MAXNOC];
-long lnd_money[MAXNOC];
-long air_money[MAXNOC];
+int sea_money[MAXNOC];
+int lnd_money[MAXNOC];
+int air_money[MAXNOC];
int tpops[MAXNOC];
void
logerror("done preparing sectors.");
logerror("producing for countries...");
for (i = 0; i < MAXNOC; i++) {
- long p_sect[SCT_BUDG_MAX+1][2];
+ int p_sect[SCT_BUDG_MAX+1][2];
memset(p_sect, 0, sizeof(p_sect));
if (!(np = getnatp(i)))
if ((sea_money[n] != 0) || (air_money[n] != 0) ||
(lnd_money[n] != 0))
wu(0, n,
- "Army delta $%ld, Navy delta $%ld, Air force delta $%ld\n",
+ "Army delta $%d, Navy delta $%d, Air force delta $%d\n",
lnd_money[n], sea_money[n], air_money[n]);
- wu(0, n, "money delta was $%ld for this update\n",
+ wu(0, n, "money delta was $%d for this update\n",
np->nat_money - money[n]);
if (opt_LOSE_CONTACT) {
for (cn = 1; cn < MAXNOC; cn++) {
* Known contributors to this file:
* Dave Pare, 1986
* Steve McClure, 1996
- * Markus Armbruster, 2004-2010
+ * Markus Armbruster, 2004-2013
*/
#include <config.h>
* Produce for a specific nation
*/
void
-produce_sect(int natnum, int etu, struct bp *bp, long p_sect[][2])
+produce_sect(int natnum, int etu, struct bp *bp, int p_sect[][2])
{
struct sctstr *sp;
struct natstr *np;
"owner" 5 0 0 9
"type" 4 0 0 27
"unitid" 8 0 0 -1
-"price" 1 0 0 -1
+"price" 8 0 0 -1
"maxbidder" 8 0 0 9
"markettime" 12 0 0 -1
"xloc" 9 1 0 -1
"btu" 6 1 0 -1
"access" 6 1 0 -1
"milreserve" 8 1 0 -1
-"money" 1 1 0 -1
+"money" 8 1 0 -1
"login" 12 1 0 -1
"logout" 12 1 0 -1
"newstim" 12 1 0 -1
"status" 4 0 0 30
"irate" 8 0 0 -1
"ldur" 8 0 0 -1
-"amtpaid" 1 0 0 -1
-"amtdue" 1 0 0 -1
+"amtpaid" 8 0 0 -1
+"amtdue" 8 0 0 -1
"lastpay" 12 0 0 -1
"duedate" 12 0 0 -1
/10
"btu" 6 0 0 -1
"access" 6 0 0 -1
"milreserve" 8 0 0 -1
-"money" 1 0 0 -1
+"money" 8 0 0 -1
"login" 12 0 0 -1
"logout" 12 0 0 -1
"newstim" 12 0 0 -1
"owner" 5 0 0 9
"type" 4 0 0 27
"unitid" 8 0 0 -1
-"price" 1 0 0 -1
+"price" 8 0 0 -1
"maxbidder" 8 0 0 9
"markettime" 12 0 0 -1
/7
"status" 4 0 0 30
"irate" 8 0 0 -1
"ldur" 8 0 0 -1
-"amtpaid" 1 0 0 -1
-"amtdue" 1 0 0 -1
+"amtpaid" 8 0 0 -1
+"amtdue" 8 0 0 -1
"lastpay" 12 0 0 -1
"duedate" 12 0 0 -1
/10
"btu" 6 0 0 -1
"access" 6 0 0 -1
"milreserve" 8 0 0 -1
-"money" 1 0 0 -1
+"money" 8 0 0 -1
"login" 12 0 0 -1
"logout" 12 0 0 -1
"newstim" 12 0 0 -1