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

@ -38,19 +38,16 @@
#include "chance.h"
#include "file.h"
#include "item.h"
#include "land.h"
#include "nat.h"
#include "optlist.h"
#include "player.h"
#include "prototypes.h"
#include "ship.h"
#include "update.h"
void
prepare_sects(int etu)
{
struct sctstr *sp;
struct natstr *np;
int n;
/* Process all the fallout. */
@ -96,10 +93,6 @@ prepare_sects(int etu)
if (sp->sct_type == SCT_BANK)
bank_income(sp, etu);
}
for (n = 0; NULL != (np = getnatp(n)); n++) {
upd_slmilcosts(etu, np->nat_cnum);
pay_reserve(np, etu);
}
}
void
@ -128,34 +121,6 @@ tax(struct sctstr *sp, int etu)
budget->money += mil_pay;
}
void
upd_slmilcosts(int etu, natid n)
{
struct shpstr *sp;
struct lndstr *lp;
int mil, i;
double mil_pay;
mil = 0;
for (i = 0; (sp = getshipp(i)); i++) {
if (!sp->shp_own || sp->shp_own != n)
continue;
mil += sp->shp_item[I_MILIT];
}
for (i = 0; (lp = getlandp(i)); i++) {
if (!lp->lnd_own || lp->lnd_own != n)
continue;
mil += lp->lnd_item[I_MILIT];
}
mil_pay = mil * etu * money_mil;
nat_budget[n].mil.count += mil;
nat_budget[n].mil.money += mil_pay;
nat_budget[n].money += mil_pay;
}
void
bank_income(struct sctstr *sp, int etu)
{