extern void finish_sects(int);
/* human.c */
extern int do_feed(register struct sctstr *, register struct natstr *,
- int *, int *, int *, int);
-extern int feed_people(register int *, int, int *);
+ short *, int *, int *, int);
+extern int feed_people(short *, int, int *);
/* land.c */
extern int prod_land(int, int, int *, int);
extern int feed_land(struct lndstr *, int, int *, int);
extern void prepare_sects(int, int *);
extern int bank_income(struct sctstr *, int);
/* produce.c */
-extern int produce(struct natstr *, struct sctstr *, int *, int, int,
+extern int produce(struct natstr *, struct sctstr *, short *, int, int,
int, int *, int *);
/* removewants.c */
extern int update_removewants(void);
struct nstr_sect nstr;
struct sctstr sect;
int nsect = 0;
- int vec[I_MAX + 1], s, needed;
+ int s, needed;
if (!snxtsct(&nstr, range))
return;
if (sect.sct_type == SCT_SANCT)
continue;
- getvec(VT_ITEM, vec, (s_char *)§, EF_SECTOR);
/* This next 2 lines were added to overcompensate for the needy */
- if (vec[I_FOOD])
- vec[I_FOOD]--;
- s = feed_people(vec, etu_per_update, &needed);
+ if (sect.sct_item[I_FOOD])
+ sect.sct_item[I_FOOD]--;
+ s = feed_people(sect.sct_item, etu_per_update, &needed);
if (s == 0)
continue;
static int grow_people(struct sctstr *, register int,
register struct natstr *, int *, int,
- register int *);
-static int growfood(struct sctstr *, register int *, int, int);
+ short *);
+static int growfood(struct sctstr *, short *, int, int);
static void starvation(struct sctstr *);
static void trunc_people(struct sctstr *, register struct natstr *,
- register int *);
+ short *);
/*
* feed the individual sector
*
*/
int
-do_feed(register struct sctstr *sp, register struct natstr *np, int *vec,
+do_feed(struct sctstr *sp, struct natstr *np, short *vec,
int *workp, int *bp, int etu)
{
int people;
}
static int
-growfood(struct sctstr *sp, register int *vec, int work, int etu)
+growfood(struct sctstr *sp, short *vec, int work, int etu)
{
double food_fertil;
double food_workers;
vec[I_FOOD] += (int)food;
if (vec[I_FOOD] == 0)
vec[I_FOOD] = 1;
- if (vec[I_FOOD] > 9999)
- vec[I_FOOD] = 9999;
+ if (vec[I_FOOD] > ITEM_MAX)
+ vec[I_FOOD] = ITEM_MAX;
work_used = (int)food / fcrate;
return work_used;
}
* returns the number who starved, if any.
*/
int
-feed_people(register int *vec, int etu, int *needed)
+feed_people(short *vec, int etu, int *needed)
{
double food_eaten;
int ifood_eaten;
*/
static void
trunc_people(struct sctstr *sp, register struct natstr *np,
- register int *vec)
+ short *vec)
{
int maxpop = max_pop(np->nat_level[NAT_RLEV], sp);
static int
grow_people(struct sctstr *sp, register int etu,
register struct natstr *np, int *workp, int sctwork,
- register int *vec)
+ short *vec)
{
int newciv;
int newuw;
#include "optlist.h"
#include "budg.h"
-static void materials_charge(struct pchrstr *, register int *,
- register int);
-static int materials_cost(struct pchrstr *, register int *, int *);
+static void materials_charge(struct pchrstr *, short *, int);
+static int materials_cost(struct pchrstr *, short *, int *);
s_char *levelnames[] =
{ "Technology", "Research", "Education", "Happiness" };
int
-produce(struct natstr *np, struct sctstr *sp, int *vec, int work,
+produce(struct natstr *np, struct sctstr *sp, short *vec, int work,
int desig, int neweff, int *cost, int *amount)
{
register struct pchrstr *product;
}
static int
-materials_cost(struct pchrstr *product, register int *vec, int *costp)
+materials_cost(struct pchrstr *product, short *vec, int *costp)
{
register u_char *vp;
register u_short *ap;
}
static void
-materials_charge(struct pchrstr *product, register int *vec,
- register int count)
+materials_charge(struct pchrstr *product, short *vec, int count)
{
register u_char *vp;
register u_short *ap;
*/
static int
upd_buildeff(struct natstr *np, register struct sctstr *sp, int *workp,
- int *vec, int etu, int *desig, int sctwork, int *cost)
+ short *vec, int etu, int *desig, int sctwork, int *cost)
{
register int work_cost = 0;
int buildeff_work = (int)(*workp / 2);
* some mil initially.
*/
static int
-enlist(register int *vec, int etu, int *cost)
+enlist(short *vec, int etu, int *cost)
{
int maxmil;
int enlisted;
{
register struct sctstr *sp;
register struct natstr *np;
- int vec[I_MAX + 1];
+ short buf[I_MAX + 1];
+ short *vec;
int work, cost, ecost, pcost, sctwork;
int n, desig, maxpop, neweff, amount;
p_sect[SCT_CAPIT][1] += etu;
}
- if (getvec(VT_ITEM, vec, (s_char *)sp, EF_SECTOR) <= 0)
- continue;
+ if (player->simulation) {
+ /* work on a copy, which will be discarded */
+ memcpy(buf, sp->sct_item, sizeof(buf));
+ vec = buf;
+ } else
+ vec = sp->sct_item;
+
/* If everybody is dead, the sector reverts to unowned.
* This is also checked at the end of the production in
* they all starved or were plagued off.
bp_clear_cachepath();
if (sp->sct_off || np->nat_money < 0) {
- if (!player->simulation) {
- putvec(VT_ITEM, vec, (s_char *)sp, EF_SECTOR);
+ if (!player->simulation)
sp->sct_off = 0;
- }
continue;
}
if ((np->nat_priorities[sp->sct_type] == 0) &&
((pchr[dchr[sp->sct_type].d_prd].p_cost != 0) ||
(sp->sct_type == SCT_ENLIST))) {
if (!player->simulation) {
- putvec(VT_ITEM, vec, (s_char *)sp, EF_SECTOR);
logerror("Skipping %s production for country %s\n",
dchr[sp->sct_type].d_name, np->nat_cnam);
}
if ((sp->sct_effic < 100 || sp->sct_type != sp->sct_newtype) &&
np->nat_money > 0) {
- neweff =
- upd_buildeff(np, sp, &work, vec, etu, &desig, sctwork,
- &cost);
+ neweff = upd_buildeff(np, sp, &work, vec, etu, &desig, sctwork,
+ &cost);
pt_bg_nmbr(bp, sp, I_LCM, vec[I_LCM]);
pt_bg_nmbr(bp, sp, I_HCM, vec[I_HCM]);
p_sect[SCT_EFFIC][0]++;
p_sect[SCT_EFFIC][1] += cost;
if (!player->simulation) {
np->nat_money -= cost;
- /* No longer tear down infrastructure
- if (sp->sct_type != desig) {
- sp->sct_road = 0;
- sp->sct_defense = 0;
- } else if (neweff < sp->sct_effic) {
- sp->sct_road -= (sp->sct_road * (sp->sct_effic - neweff) / 100.0);
- sp->sct_defense -= (sp->sct_defense * (sp->sct_effic - neweff) / 100.0);
- if (sp->sct_road < 0)
- sp->sct_road = 0;
- if (sp->sct_defense < 0)
- sp->sct_defense = 0;
- }
- */
sp->sct_type = desig;
sp->sct_effic = neweff;
if (!opt_DEFENSE_INFRA)
((pchr[dchr[desig].d_prd].p_cost != 0) ||
(desig == SCT_ENLIST))) {
if (!player->simulation) {
- putvec(VT_ITEM, vec, (s_char *)sp, EF_SECTOR);
logerror("Skipping %s production for country %s\n",
dchr[sp->sct_type].d_name, np->nat_cnam);
}
vec[I_CIVIL] = maxpop;
if (vec[I_UW] > maxpop)
vec[I_UW] = maxpop;
- putvec(VT_ITEM, vec, (s_char *)sp, EF_SECTOR);
sp->sct_avail = work;
np->nat_money -= pcost;
}