2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2000, Dave Pare, Jeff Bailey, Thomas Ruschak,
4 * Ken Stevens, Steve McClure
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * See the "LEGAL", "LICENSE", "CREDITS" and "README" files for all the
23 * related information and legal notices. It is expected that any future
24 * projects/authors will amend these files as needed.
28 * coll.c: Collet on a loan
30 * Known contributors to this file:
32 * Steve McClure, 1996-2000
70 pr("Loans are not enabled.\n");
73 if ((arg = onearg(player->argp[1], "Collect on loan #")) < 0)
75 /* Check if it's a valid loan. That means, is it a valid loan,
76 owed to this player, with a valid duration and it's been signed. */
77 if (!getloan(arg, &loan) || (loan.l_loner != player->cnum) ||
78 (loan.l_ldur == 0) || (loan.l_status != LS_SIGNED)) {
79 pr("You aren't owed anything on that loan...\n");
82 /* If we got here, we check to see if it's been defaulted on. We
83 already know it's owed to this player. */
87 pr("There has been no default on loan %d\n", arg);
90 last = loan.l_lastpay;
91 if (last < due && due < now) {
94 } else if (due < last) {
98 rate = loan.l_irate / (loan.l_ldur * 8.64e6);
100 /* changed following to avoid overflow 3/27/89 bailey@math-cs.kent.edu
101 owed = ((rdur * rate) + (xdur * rate * 2.0) + 1.0) * loan.l_amtdue;
102 Begin overflow fix */
103 owed = ((rdur * rate) + (xdur * rate * 2.0) + 1.0);
104 if (((1 << 30) / owed) < loan.l_amtdue)
107 owed *= loan.l_amtdue;
108 /* End overflow fix */
109 pr("You are owed $%.2f on that loan.\n", owed);
110 if (!(p = getstarg(player->argp[2],
111 "What sector do you wish to confiscate? ", buf)))
113 if (!check_loan_ok(&loan))
115 if (!sarg_xy(p, &x, &y) || !getsect(x, y, §))
117 if (!neigh(x, y, player->cnum)) {
118 pr("You are not adjacent to %s\n", xyas(x, y, player->cnum));
121 if (sect.sct_own != loan.l_lonee) {
122 pr("%s is not owned by %s.\n",
123 xyas(x, y, player->cnum), cname(loan.l_lonee));
126 pay = dchr[sect.sct_type].d_value * ((float)sect.sct_effic + 100.0);
127 for (i = 0; ichr[i].i_name; i++) {
128 if (ichr[i].i_value == 0 || ichr[i].i_vtype == 0)
130 val = sect.sct_item[ichr[i].i_vtype];
131 pay += val * ichr[i].i_value;
133 pr("That sector (and its contents) is valued at $%.2f\n", pay);
134 if (pay > owed * 1.2) {
135 pr("That is more than is owed!\n");
138 if (sect.sct_type == SCT_CAPIT || sect.sct_type == SCT_MOUNT)
139 caploss(§, sect.sct_own, "that was %s's capital!\n");
140 sect.sct_item[I_MILIT] = 1; /* FIXME no where did this guy come from? */
142 /* Consider modifying takeover to take a "no che" argument and
143 putting using it here again. */
144 /* (void) takeover(§, player->cnum);*/
145 makelost(EF_SECTOR, sect.sct_own, 0, sect.sct_x, sect.sct_y);
146 makenotlost(EF_SECTOR, player->cnum, 0, sect.sct_x, sect.sct_y);
147 sect.sct_own = player->cnum;
149 memset(sect.sct_dist, 0, sizeof(sect.sct_dist));
150 memset(sect.sct_del, 0, sizeof(sect.sct_del));
152 sect.sct_dist_x = sect.sct_x;
153 sect.sct_dist_y = sect.sct_y;
156 nreport(player->cnum, N_SEIZE_SECT, loan.l_lonee, 1);
159 nreport(loan.l_lonee, N_REPAY_LOAN, player->cnum, 1);
161 "%s seized %s to satisfy loan #%d\n",
163 xyas(sect.sct_x, sect.sct_y, loan.l_lonee), arg);
164 pr("That loan is now considered repaid.\n");
166 (void)time(&loan.l_lastpay);
168 loan.l_amtdue = (long)owed;
169 pay += loan.l_amtpaid;
170 loan.l_amtpaid = pay;
172 "%s seized %s in partial payment of loan %d.\n",
174 xyas(sect.sct_x, sect.sct_y, loan.l_lonee), arg);
175 pr("You are still owed $%.2f on loan %d.\n", owed, arg);