update: Rearrange code to pay non-sector military
Split upd_slmilcosts() into prep_ships() and prep_lands(). Move the sanity check for dead ships and land units from prod_ships() and prod_lands() there. Move their call from prepare_sects() to its caller, along with pay_reserve(). Create prep_planes() for symmetry. Pilots are now paid at the same time as other military. Can matter only when the country goes broke during the update. Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
parent
7951e91e3f
commit
5df43a5b3f
7 changed files with 88 additions and 59 deletions
|
@ -54,6 +54,32 @@ static void landrepair(struct lndstr *, struct natstr *, struct bp *,
|
|||
int, struct budget *);
|
||||
static int feed_land(struct lndstr *, int);
|
||||
|
||||
void prep_lands(int etus, natid natnum)
|
||||
{
|
||||
int mil, i;
|
||||
double mil_pay;
|
||||
struct lndstr *lp;
|
||||
|
||||
for (i = 0; (lp = getlandp(i)); i++) {
|
||||
if (lp->lnd_own == 0)
|
||||
continue;
|
||||
if (lp->lnd_own != natnum)
|
||||
continue;
|
||||
if (CANT_HAPPEN(lp->lnd_effic < LAND_MINEFF)) {
|
||||
makelost(EF_LAND, lp->lnd_own, lp->lnd_uid,
|
||||
lp->lnd_x, lp->lnd_y);
|
||||
lp->lnd_own = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
mil = lp->lnd_item[I_MILIT];
|
||||
mil_pay = mil * etus * money_mil;
|
||||
nat_budget[natnum].mil.count += mil;
|
||||
nat_budget[natnum].mil.money += mil_pay;
|
||||
nat_budget[natnum].money += mil_pay;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
prod_land(int etus, int natnum, struct bp *bp, int build)
|
||||
/* build = 1, maintain = 0 */
|
||||
|
@ -67,13 +93,6 @@ prod_land(int etus, int natnum, struct bp *bp, int build)
|
|||
continue;
|
||||
if (lp->lnd_own != natnum)
|
||||
continue;
|
||||
if (lp->lnd_effic < LAND_MINEFF) {
|
||||
makelost(EF_LAND, lp->lnd_own, lp->lnd_uid,
|
||||
lp->lnd_x, lp->lnd_y);
|
||||
lp->lnd_own = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
sp = getsectp(lp->lnd_x, lp->lnd_y);
|
||||
if (sp->sct_type == SCT_SANCT)
|
||||
continue;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue