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:
Markus Armbruster 2016-06-22 20:49:57 +02:00
parent 7951e91e3f
commit 5df43a5b3f
7 changed files with 88 additions and 59 deletions

View file

@ -49,12 +49,11 @@ static void upd_plane(struct plnstr *, int, struct bp *, int);
static void planerepair(struct plnstr *, struct natstr *, struct bp *,
int, struct budget *);
void
prod_plane(int etus, int natnum, struct bp *bp, int buildem)
/* Build = 1, maintain =0 */
void prep_planes(int etus, natid natnum)
{
int mil, i;
double mil_pay;
struct plnstr *pp;
int i;
for (i = 0; (pp = getplanep(i)); i++) {
if (pp->pln_own == 0)
@ -68,6 +67,26 @@ prod_plane(int etus, int natnum, struct bp *bp, int buildem)
continue;
}
mil = plchr[pp->pln_type].pl_mat[I_MILIT];
/* flight pay is 5x the pay received by other military */
mil_pay = mil * etus * money_mil * 5;
nat_budget[natnum].bm[BUDG_PLN_MAINT].money += mil_pay;
nat_budget[natnum].money += mil_pay;
}
}
void
prod_plane(int etus, int natnum, struct bp *bp, int buildem)
/* Build = 1, maintain =0 */
{
struct plnstr *pp;
int i;
for (i = 0; (pp = getplanep(i)); i++) {
if (pp->pln_own == 0)
continue;
if (pp->pln_own != natnum)
continue;
upd_plane(pp, etus, bp, buildem);
}
}
@ -105,10 +124,6 @@ upd_plane(struct plnstr *pp, int etus, struct bp *bp, int build)
budget->bm[BUDG_PLN_MAINT].money -= cost;
budget->money -= cost;
}
/* flight pay is 5x the pay received by other military */
cost = etus * pcp->pl_mat[I_MILIT] * -money_mil * 5;
budget->bm[BUDG_PLN_MAINT].money -= cost;
budget->money -= cost;
if (pln_is_in_orbit(pp) && !(pp->pln_flags & PLN_SYNCHRONOUS)) {
if (!player->simulation)