extern int load_comm_ok(struct sctstr *, natid, i_type, int);
extern void gift(natid, natid, void *, char *);
extern int display_mark(i_type, int);
-extern int count_pop(int);
extern int line_of_sight(char **rad, int ax, int ay, int bx, int by);
extern void plane_sona(struct emp_qelem *, int, int, struct shiplist **);
extern char *prsub(struct shpstr *);
/* main.c */
extern struct budget nat_budget[MAXNOC];
-extern int tpops[MAXNOC];
/* nat.c */
extern float levels[MAXNOC][4];
bank_income(sp, etu);
}
}
- tpops[player->cnum] = budget->oldowned_civs;
upd_slmilcosts(etu, player->cnum);
pay_reserve(np, etu);
#include <math.h>
#include "commands.h"
#include "item.h"
+#include "land.h"
#include "optlist.h"
#include "product.h"
+#include "ship.h"
#include "update.h"
static void prprod(struct sctstr *, double, double, char,
double, double, double, char[], int[], int[], int);
-int
-count_pop(int n)
+static int
+count_pop(void)
{
+ /* FIXME don't duplicate the update's workings, use its code */
int i;
int pop = 0;
- struct sctstr *sp;
+ struct sctstr *sectp;
+ struct shpstr *sp;
+ struct lndstr *lp;
+
+ for (i = 0; (sectp = getsectid(i)); i++) {
+ if (sectp->sct_own == player->cnum) {
+ if (sectp->sct_own == sectp->sct_oldown)
+ pop += sectp->sct_item[I_CIVIL];
+ }
+ }
- for (i = 0; NULL != (sp = getsectid(i)); i++) {
- if (sp->sct_own != n)
- continue;
- if (sp->sct_oldown != n)
- continue;
- pop += sp->sct_item[I_CIVIL];
+ for (i = 0; (sp = getshipp(i)); i++) {
+ if (sp->shp_own == player->cnum)
+ pop += sp->shp_item[I_CIVIL];
+ }
+
+ for (i = 0; (lp = getlandp(i)); i++) {
+ if (lp->lnd_own == player->cnum)
+ pop += lp->lnd_item[I_CIVIL];
}
+
return pop;
}
struct pchrstr *pp;
double p_e;
double prodeff;
- int totpop;
+ int totpop = -1;
double cost;
int i;
int nsect;
cost = take * pp->p_cost;
if (opt_TECH_POP) {
if (pp->p_level == NAT_TLEV) {
- totpop = count_pop(sect.sct_own);
+ if (totpop < 0)
+ totpop = count_pop();
if (totpop > 50000)
cost *= totpop / 50000.0;
}
#include "update.h"
struct budget nat_budget[MAXNOC];
-int tpops[MAXNOC];
void
update_main(void)
if (!(np = getnatp(n)))
continue;
nat_budget[n].start_money = nat_budget[n].money = np->nat_money;
- tpops[n] = count_pop(n);
}
logerror("preparing sectors...");
cost = product->p_cost * output / prodeff;
if (opt_TECH_POP) {
if (product->p_level == NAT_TLEV) {
- if (tpops[sp->sct_own] > 50000)
- cost *= tpops[sp->sct_own] / 50000.0;
+ if (budget->oldowned_civs > 50000)
+ cost *= budget->oldowned_civs / 50000.0;
}
}