/*
* Empire - A multi-player, client/server Internet based war game.
- * Copyright (C) 1986-2000, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ * Copyright (C) 1986-2004, Dave Pare, Jeff Bailey, Thomas Ruschak,
* Ken Stevens, Steve McClure
*
* This program is free software; you can redistribute it and/or modify
register int i;
register int val;
time_t now;
- s_char *p;
+ char *p;
struct lonstr loan;
struct sctstr sect;
coord x, y;
- long due;
- long last;
- long rdur;
- long xdur;
- double rate;
double owed;
double pay;
- s_char buf[1024];
+ char buf[1024];
if (!opt_LOANS) {
pr("Loans are not enabled.\n");
}
/* If we got here, we check to see if it's been defaulted on. We
already know it's owed to this player. */
- (void)time(&now);
- due = loan.l_duedate;
- if (now <= due) {
+ owed = loan_owed(&loan, time(&now));
+ if (now <= loan.l_duedate) {
pr("There has been no default on loan %d\n", arg);
return RET_FAIL;
}
- last = loan.l_lastpay;
- if (last < due && due < now) {
- rdur = due - last;
- xdur = now - due;
- } else if (due < last) {
- rdur = 0;
- xdur = now - last;
- }
- rate = loan.l_irate / (loan.l_ldur * 8.64e6);
-/* changed following to avoid overflow 3/27/89 bailey@math-cs.kent.edu
- owed = ((rdur * rate) + (xdur * rate * 2.0) + 1.0) * loan.l_amtdue;
- Begin overflow fix */
- owed = ((rdur * rate) + (xdur * rate * 2.0) + 1.0);
- if (((1 << 30) / owed) < loan.l_amtdue)
- owed = (1 << 30);
- else
- owed *= loan.l_amtdue;
-/* End overflow fix */
pr("You are owed $%.2f on that loan.\n", owed);
if (!(p = getstarg(player->argp[2],
"What sector do you wish to confiscate? ", buf)))
}
if (sect.sct_type == SCT_CAPIT || sect.sct_type == SCT_MOUNT)
caploss(§, sect.sct_own, "that was %s's capital!\n");
- sect.sct_item[I_MILIT] = 1; /* FIXME no where did this guy come from? */
+ sect.sct_item[I_MILIT] = 1; /* FIXME now where did this guy come from? */
/* Consider modifying takeover to take a "no che" argument and
putting using it here again. */
putsect(§);
nreport(player->cnum, N_SEIZE_SECT, loan.l_lonee, 1);
+ owed = loan_owed(&loan, time(&now));
if (pay >= owed) {
loan.l_ldur = 0;
nreport(loan.l_lonee, N_REPAY_LOAN, player->cnum, 1);