- tmoney = natp->nat_money;
- if (tmoney <= 0)
- monleft = price;
- if (tmoney < price && tmoney > 0) {
- monleft = price - (tmoney - 1);
- tmoney = 1;
- price = price - monleft;
- } else if (tmoney > 0) {
- monleft = 0;
- tmoney = tmoney - price;
- }
-
- /* Subtract the amount of money that needs to come out in a loan. */
- subleft = monleft;
-
- if (opt_LOANS) {
- /* Try to make a loan for the rest from the owner. */
- if (monleft > 0 && tmoney > 0) {
- if ((float)((float)price / (float)(price + monleft)) < 0.1) {
- wu(0, comm.com_maxbidder,
- "You need at least 10 percent down to purchase something on credit.\n");
- } else {
- couval = get_couval(comm.com_maxbidder);
- outstanding = get_outstand(comm.com_maxbidder);
- couval = couval - outstanding;
- if (couval > monleft) {
- /* Make the loan */
- foundloan = 0;
- for (j = 0; getloan(j, &loan); j++) {
- if (loan.l_status != LS_FREE)
- continue;
- foundloan = 1;
- break;
- }
- if (!foundloan)
- ef_extend(EF_LOAN, 1);
- loan.l_status = LS_SIGNED;
- loan.l_loner = comm.com_owner;
- loan.l_lonee = comm.com_maxbidder;
- loan.l_irate = 25;
- loan.l_ldur = 4;
- loan.l_amtpaid = 0;
- loan.l_amtdue = monleft;
- time(&loan.l_lastpay);
- loan.l_duedate =
- (loan.l_ldur * SECS_PER_DAY) + loan.l_lastpay;
- loan.l_uid = j;
- if (!putloan(j, &loan))
- logerror("Error writing to the loan file.\n");
- else
- monleft = 0;
- nreport(comm.com_maxbidder, N_FIN_TROUBLE,
- comm.com_owner, 1);
- wu(0, comm.com_maxbidder,
- "You just took loan #%d for $%.2f to cover the cost of your purchase.\n",
- j, loan.l_amtdue);
- wu(0, comm.com_owner,
- "You just extended loan #%d to %s to help with the purchase cose.\n",
- j, cname(comm.com_maxbidder));
- } else {
- nreport(comm.com_maxbidder, N_CREDIT_JUNK,
- comm.com_owner, 1);
- wu(0, comm.com_maxbidder,
- "You don't have enough credit to get a loan.\n");
- wu(0, comm.com_owner,
- "You just turned down a loan to %s.\n",
- cname(comm.com_maxbidder));
- }
- }
- }
- }
-
- if (monleft > 0) {