(fill_update_array, bp_set_from_sect): Rename.
(gt_bg_nmbr, pt_bg_nmbr, bp_get_item, bp_get_avail, bp_put_item,
bp_put_avail): Separate accessor functions for item and avail.
#define SCT_EFFIC (SCT_TYPE_MAX + 1)
-struct bp *alloc_bp(void);
-void fill_update_array(struct bp *, struct sctstr *);
-int gt_bg_nmbr(struct bp *, struct sctstr *, i_type);
-void pt_bg_nmbr(struct bp *, struct sctstr *, i_type, int);
+struct bp *bp_alloc(void);
+void bp_set_from_sect(struct bp *, struct sctstr *);
+int bp_get_item(struct bp *, struct sctstr *, i_type);
+void bp_put_item(struct bp *, struct sctstr *, i_type, int);
+int bp_get_avail(struct bp *, struct sctstr *);
+void bp_put_avail(struct bp *, struct sctstr *, int);
+
int get_materials(struct sctstr *, struct bp *, int *, int);
extern long money[MAXNOC];
*planes = *pbuild = *npbuild = *pmaint = 0;
np = getnatp(player->cnum);
- bp = alloc_bp();
+ bp = bp_alloc();
for (n = 0; NULL != (sp = getsectid(n)); n++) {
- fill_update_array(bp, sp);
+ bp_set_from_sect(bp, sp);
if (sp->sct_own == player->cnum) {
sp->sct_updated = 0;
tax(sp, np, etu, &pop, &civ_tax, &uw_tax, &mil_pay);
#include "update.h"
struct bp {
- int val[7];
+ int val[6];
+ int avail;
};
-static int bud_key[I_MAX + 2] =
- { 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 5, 6, 0, 0, 7 };
+static int bud_key[I_MAX + 1] =
+ { 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 5, 6, 0, 0 };
static struct bp *
bp_ref(struct bp *bp, struct sctstr *sp)
}
int
-gt_bg_nmbr(struct bp *bp, struct sctstr *sp, i_type comm)
+bp_get_item(struct bp *bp, struct sctstr *sp, i_type comm)
{
int cm;
}
void
-pt_bg_nmbr(struct bp *bp, struct sctstr *sp, i_type comm, int amount)
+bp_put_item(struct bp *bp, struct sctstr *sp, i_type comm, int amount)
{
int cm;
bp_ref(bp, sp)->val[cm - 1] = amount;
}
+int
+bp_get_avail(struct bp *bp, struct sctstr *sp)
+{
+ return bp_ref(bp, sp)->avail;
+}
+
+void
+bp_put_avail(struct bp *bp, struct sctstr *sp, int amount)
+{
+ bp_ref(bp, sp)->avail = amount;
+}
+
void
-fill_update_array(struct bp *bp, struct sctstr *sp)
+bp_set_from_sect(struct bp *bp, struct sctstr *sp)
{
int k;
struct bp *p = bp_ref(bp, sp);
if ((k = bud_key[i]) != 0)
p->val[k - 1] = sp->sct_item[i];
}
- p->val[bud_key[I_MAX + 1] - 1] = sp->sct_avail;
+ p->avail = sp->sct_avail;
}
struct bp *
-alloc_bp(void)
+bp_alloc(void)
{
return calloc(WORLD_X * WORLD_Y, sizeof(struct bp));
}
/* need to grow "emergency rations" */
work_avail -= 2 * growfood(sp, vec, work_avail / 2, etu);
/* It's twice as hard to grow those than norm */
- pt_bg_nmbr(bp, sp, I_MAX + 1, work_avail);
+ bp_put_avail(bp, sp, work_avail);
if (!player->simulation)
sp->sct_avail = work_avail;
}
/* Here is where we truncate extra people, always */
trunc_people(sp, np, vec);
- pt_bg_nmbr(bp, sp, I_CIVIL, vec[I_CIVIL]);
- pt_bg_nmbr(bp, sp, I_UW, vec[I_UW]);
- pt_bg_nmbr(bp, sp, I_MILIT, vec[I_MILIT]);
+ bp_put_item(bp, sp, I_CIVIL, vec[I_CIVIL]);
+ bp_put_item(bp, sp, I_UW, vec[I_UW]);
+ bp_put_item(bp, sp, I_MILIT, vec[I_MILIT]);
*workp = work_avail;
return sctwork;
}
if (!player->simulation)
avail = sp->sct_avail * 100;
else
- avail = gt_bg_nmbr(bp, sp, I_MAX + 1) * 100;
+ avail = bp_get_avail(bp, sp) * 100;
w_p_eff = LND_BLD_WORK(lp->l_lcm, lp->l_hcm);
delta = roundavg((double)avail / w_p_eff);
if (!player->simulation)
sp->sct_avail = avail / 100;
else
- pt_bg_nmbr(bp, sp, I_MAX + 1, avail / 100);
+ bp_put_avail(bp, sp, avail / 100);
if (build < 0)
logerror("land unit %d building %d ! \n", land->lnd_uid, build);
memset(air_money, 0, sizeof(air_money));
memset(sea_money, 0, sizeof(sea_money));
memset(lnd_money, 0, sizeof(lnd_money));
- bp = alloc_bp();
+ bp = bp_alloc();
for (n = 0; n < MAXNOC; n++) {
money[n] = 0;
if (!(np = getnatp(n)))
for (i = I_NONE + 1; i <= I_MAX; i++) {
if (mvec[i] == 0)
continue;
- amt = gt_bg_nmbr(bp, sp, i);
+ amt = bp_get_item(bp, sp, i);
if (amt * 100 < mvec[i] * pct)
pct = amt * 100 / mvec[i];
}
for (i = I_NONE + 1; i <= I_MAX; i++) {
if (mvec[i] == 0)
continue;
- amt = gt_bg_nmbr(bp, sp, i);
+ amt = bp_get_item(bp, sp, i);
amt -= roundavg(mvec[i] * pct / 100.0);
if (CANT_HAPPEN(amt < 0))
amt = 0;
- pt_bg_nmbr(bp, sp, i, amt);
+ bp_put_item(bp, sp, i, amt);
if (!player->simulation)
sp->sct_item[i] = amt;
}
if (!player->simulation)
avail = sp->sct_avail * 100;
else
- avail = gt_bg_nmbr(bp, sp, I_MAX + 1) * 100;
+ avail = bp_get_avail(bp, sp) * 100;
if (carrier)
avail += etus * carrier->shp_item[I_MILIT] / 2;
if (!player->simulation)
avail = (sp->sct_avail * 100 - used) / 100;
else
- avail = (gt_bg_nmbr(bp, sp, I_MAX + 1) * 100 - used) / 100;
+ avail = (bp_get_avail(bp, sp) * 100 - used) / 100;
if (avail < 0)
avail = 0;
if (!player->simulation)
sp->sct_avail = avail;
else
- pt_bg_nmbr(bp, sp, I_MAX + 1, avail);
+ bp_put_avail(bp, sp, avail);
if (sp->sct_type != SCT_AIRPT)
build /= 3;
if (sp->sct_type == SCT_WATER)
continue;
- fill_update_array(bp, sp);
+ bp_set_from_sect(bp, sp);
np = getnatp(sp->sct_own);
#ifdef DEBUG
np->nat_money > 0) {
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]);
+ bp_put_item(bp, sp, I_LCM, vec[I_LCM]);
+ bp_put_item(bp, sp, I_HCM, vec[I_HCM]);
p_sect[SCT_EFFIC][0]++;
p_sect[SCT_EFFIC][1] += cost;
if (!player->simulation) {
&pcost, &amount);
}
- pt_bg_nmbr(bp, sp, I_MAX + 1, work);
+ bp_put_avail(bp, sp, work);
p_sect[desig][0] += amount;
p_sect[desig][1] += pcost;
if (!player->simulation) {
if (!player->simulation)
avail = wf + sp->sct_avail * 100;
else
- avail = wf + gt_bg_nmbr(bp, sp, I_MAX + 1) * 100;
+ avail = wf + bp_get_avail(bp, sp) * 100;
}
w_p_eff = SHP_BLD_WORK(mp->m_lcm, mp->m_hcm);
if (!player->simulation)
avail = (sp->sct_avail * 100 + wf) / 100;
else
- avail = (gt_bg_nmbr(bp, sp, I_MAX + 1) * 100 + wf) / 100;
+ avail = (bp_get_avail(bp, sp) * 100 + wf) / 100;
if (avail < 0)
avail = 0;
if (!player->simulation)
sp->sct_avail = avail;
else
- pt_bg_nmbr(bp, sp, I_MAX + 1, avail);
+ bp_put_avail(bp, sp, avail);
}
if (sp->sct_type != SCT_HARBR)
if ((build + ship->shp_effic) > 80) {