/*
* Empire - A multi-player, client/server Internet based war game.
- * Copyright (C) 1986-2016, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ * Copyright (C) 1986-2017, Dave Pare, Jeff Bailey, Thomas Ruschak,
* Ken Stevens, Steve McClure, Markus Armbruster
*
* Empire is free software: you can redistribute it and/or modify
#include <config.h>
#include "chance.h"
-#include "file.h"
#include "item.h"
#include "nat.h"
#include "optlist.h"
#include "prototypes.h"
#include "update.h"
+static void tax(struct sctstr *, int);
+static void bank_income(struct sctstr *, int);
+
void
-prepare_sects(int etu)
+prepare_sects(int etu, struct bp *bp)
{
- struct sctstr *sp;
+ struct sctstr *sp, scratch_sect;
int n;
-/* Process all the fallout. */
- if (opt_FALLOUT) {
- if (!player->simulation) {
- /* First, we determine which sectors to process fallout in */
- for (n = 0; NULL != (sp = getsectid(n)); n++)
- sp->sct_updated = sp->sct_fallout != 0;
- /* Next, we process the fallout there */
- for (n = 0; NULL != (sp = getsectid(n)); n++)
- if (sp->sct_updated)
- do_fallout(sp, etu);
- /* Next, we spread the fallout */
- for (n = 0; NULL != (sp = getsectid(n)); n++)
- if (sp->sct_updated)
- spread_fallout(sp, etu);
- /* Next, we decay the fallout */
- for (n = 0; NULL != (sp = getsectid(n)); n++)
- if (sp->sct_fallout)
- decay_fallout(sp, etu);
- }
- }
- for (n = 0; NULL != (sp = getsectid(n)); n++) {
- sp->sct_updated = 0;
+ if (!player->simulation)
+ fallout(etu);
- if (sp->sct_type == SCT_WATER)
+ for (n = 0; NULL != (sp = getsectid(n)); n++) {
+ if (bp_skip_sect(bp, sp))
continue;
- if (getnatp(sp->sct_own)->nat_stat == STAT_SANCT)
+ bp_set_from_sect(bp, sp);
+ if (sp->sct_type == SCT_WATER || sp->sct_type == SCT_SANCT)
continue;
/*
if (running_test_suite)
seed_prng(sp->sct_uid);
- guerrilla(sp);
- do_plague(sp, etu);
- populace(sp, etu);
+ if (player->simulation) {
+ /* work on a copy, which will be discarded */
+ scratch_sect = *sp;
+ sp = &scratch_sect;
+ }
+
+ if (!player->simulation) {
+ guerrilla(sp);
+ populace(sp, etu);
+ }
tax(sp, etu);
- if (sp->sct_type == SCT_BANK)
- bank_income(sp, etu);
+ bank_income(sp, etu);
+ do_feed(sp, getnatp(sp->sct_own), etu, 0);
+ if (!player->simulation)
+ do_plague(sp, etu);
+ check_pop_loss(sp);
+ bp_set_from_sect(bp, sp);
}
}
-void
+static void
tax(struct sctstr *sp, int etu)
{
struct budget *budget = &nat_budget[sp->sct_own];
budget->money += mil_pay;
}
-void
+static void
bank_income(struct sctstr *sp, int etu)
{
double income;
+ if (sp->sct_type != SCT_BANK)
+ return;
+
income = sp->sct_item[I_BAR] * etu * bankint * sp->sct_effic / 100;
nat_budget[sp->sct_own].bars.count += sp->sct_item[I_BAR];
nat_budget[sp->sct_own].bars.money += income;