extern double food_needed(short *, int);
extern int famine_victims(short *, int);
/* land.c */
+extern void prep_lands(int, natid);
extern void prod_land(int, int, struct bp *, int);
/* main.c */
/* in server.h */
extern int plague_people(struct natstr *, short *, int *, int *, int);
extern void plague_report(natid, int, int, int, int, char *, char *);
/* plane.c */
+extern void prep_planes(int, natid);
extern void prod_plane(int, int, struct bp *, int);
/* populace.c */
extern void populace(struct sctstr *, int);
/* prepare.c */
extern void prepare_sects(int);
extern void tax(struct sctstr *, int);
-extern void upd_slmilcosts(int, natid);
extern void bank_income(struct sctstr *, int);
extern void pay_reserve(struct natstr *, int);
/* produce.c */
extern void decay_fallout(struct sctstr *, int);
extern void produce_sect(struct natstr *, int, struct bp *);
/* ship.c */
+extern void prep_ships(int, natid);
extern void prod_ship(int, int, struct bp *, int);
#endif
bank_income(sp, etu);
}
}
- upd_slmilcosts(etu, player->cnum);
+ prep_ships(etu, player->cnum);
+ prep_planes(etu, player->cnum);
+ prep_lands(etu, player->cnum);
pay_reserve(np, etu);
/* Maintain ships, planes and land units */
int, struct budget *);
static int feed_land(struct lndstr *, int);
-void
-prod_land(int etus, int natnum, struct bp *bp, int build)
- /* build = 1, maintain = 0 */
+void prep_lands(int etus, natid natnum)
{
+ int mil, i;
+ double mil_pay;
struct lndstr *lp;
- struct sctstr *sp;
- int i;
for (i = 0; (lp = getlandp(i)); i++) {
if (lp->lnd_own == 0)
continue;
if (lp->lnd_own != natnum)
continue;
- if (lp->lnd_effic < LAND_MINEFF) {
+ 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 */
+{
+ struct lndstr *lp;
+ struct sctstr *sp;
+ int i;
+
+ for (i = 0; (lp = getlandp(i)); i++) {
+ if (lp->lnd_own == 0)
+ continue;
+ if (lp->lnd_own != natnum)
+ continue;
sp = getsectp(lp->lnd_x, lp->lnd_y);
if (sp->sct_type == SCT_SANCT)
continue;
logerror("preparing sectors...");
prepare_sects(etu);
logerror("done preparing sectors.");
+ for (i = 0; i < MAXNOC; i++) {
+ prep_ships(etu, i);
+ prep_planes(etu, i);
+ prep_lands(etu, i);
+ pay_reserve(getnatp(i), etu);
+ }
+
logerror("producing for countries...");
for (i = 0; i < MAXNOC; i++) {
if (!(np = getnatp(i)))
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)
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);
}
}
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)
#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. */
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
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)
{
static void ship_produce(struct shpstr *, int, struct budget *);
static int feed_ship(struct shpstr *, int);
-void
-prod_ship(int etus, int natnum, struct bp *bp, int build)
- /* build = 1, maintain = 0 */
+void prep_ships(int etus, natid natnum)
{
+ int mil, i;
+ double mil_pay;
struct shpstr *sp;
- int i;
for (i = 0; (sp = getshipp(i)); i++) {
if (sp->shp_own == 0)
continue;
if (sp->shp_own != natnum)
continue;
- if (sp->shp_effic < SHIP_MINEFF) {
+ if (CANT_HAPPEN(sp->shp_effic < SHIP_MINEFF)) {
makelost(EF_SHIP, sp->shp_own, sp->shp_uid,
sp->shp_x, sp->shp_y);
sp->shp_own = 0;
continue;
}
+ mil = sp->shp_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_ship(int etus, int natnum, struct bp *bp, int build)
+ /* build = 1, maintain = 0 */
+{
+ struct shpstr *sp;
+ int i;
+
+ for (i = 0; (sp = getshipp(i)); i++) {
+ if (sp->shp_own == 0)
+ continue;
+ if (sp->shp_own != natnum)
+ continue;
upd_ship(sp, etus, bp, build);
}
}