Don't permit work command to spend more money than available
Stop work() when there's not enough money left for the current engineer.
This commit is contained in:
parent
ede42fb9ce
commit
3615cfc8ac
1 changed files with 12 additions and 3 deletions
|
@ -49,6 +49,8 @@ work(void)
|
||||||
int work_amt, eff_amt, w;
|
int work_amt, eff_amt, w;
|
||||||
char *p;
|
char *p;
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
|
double cost;
|
||||||
|
struct natstr *natp = getnatp(player->cnum);
|
||||||
|
|
||||||
if (!snxtitem(&ni, EF_LAND, player->argp[1], NULL))
|
if (!snxtitem(&ni, EF_LAND, player->argp[1], NULL))
|
||||||
return RET_SYN;
|
return RET_SYN;
|
||||||
|
@ -83,11 +85,18 @@ work(void)
|
||||||
prland(&land));
|
prland(&land));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
nunits++;
|
cost = 0.0;
|
||||||
eff_amt = ((6 * buildeff(§, w, &player->dolcost)) /
|
w = buildeff(§, w, &cost);
|
||||||
(land.lnd_effic / 100.0));
|
if (player->dolcost + cost > natp->nat_money) {
|
||||||
|
pr("You can't afford to work that much in %s!\n",
|
||||||
|
xyas(land.lnd_x, land.lnd_y, player->cnum));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
player->dolcost += cost;
|
||||||
|
eff_amt = ((6 * w) / (land.lnd_effic / 100.0));
|
||||||
land.lnd_mission = 0;
|
land.lnd_mission = 0;
|
||||||
land.lnd_mobil -= eff_amt;
|
land.lnd_mobil -= eff_amt;
|
||||||
|
nunits++;
|
||||||
pr("%s %s efficiency at %s to %d\n",
|
pr("%s %s efficiency at %s to %d\n",
|
||||||
prland(&land),
|
prland(&land),
|
||||||
sect.sct_type == sect.sct_newtype ? "raised" : "lowered",
|
sect.sct_type == sect.sct_newtype ? "raised" : "lowered",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue