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);
-void bp_put_items(struct bp *, struct sctstr *);
-int bp_get_avail(struct bp *, struct sctstr *);
-void bp_put_avail(struct bp *, struct sctstr *, int);
void bp_to_sect(struct bp *, struct sctstr *);
extern int money[MAXNOC];
BP_LCM, BP_HCM, BP_NONE, BP_NONE
};
-/*
- * Return the item value tracked in @bp for sector @sp's item @comm.
- * @comm must be a tracked item type.
- */
-int
-bp_get_item(struct bp *bp, struct sctstr *sp, i_type comm)
-{
- enum bp_item_idx idx = bud_key[comm];
-
- if (CANT_HAPPEN(idx < 0) || !bp)
- return sp->sct_item[comm];
- return bp[sp->sct_uid].bp_item[idx];
-}
-
-/*
- * Set item value tracked in @bp for sector @sp's item @comm to @amount.
- */
-void
-bp_put_item(struct bp *bp, struct sctstr *sp, i_type comm, int amount)
-{
- enum bp_item_idx idx = bud_key[comm];
-
- if (bp && idx >= 0)
- bp[sp->sct_uid].bp_item[idx] = amount;
-}
-
-/* Set the item values tracked in @bp from sector @sp. */
+/* Set the values tracked in @bp for sector @sp to the values in @sp. */
void
-bp_put_items(struct bp *bp, struct sctstr *sp)
+bp_set_from_sect(struct bp *bp, struct sctstr *sp)
{
- enum bp_item_idx idx;
i_type i;
+ enum bp_item_idx idx;
if (!bp)
return;
-
for (i = I_NONE + 1; i <= I_MAX; i++) {
idx = bud_key[i];
if (idx >= 0)
bp[sp->sct_uid].bp_item[idx] = sp->sct_item[i];
}
-}
-
-/* Return avail tracked in @bp for sector @sp. */
-int
-bp_get_avail(struct bp *bp, struct sctstr *sp)
-{
- return bp ? bp[sp->sct_uid].bp_avail : sp->sct_avail;
-}
-
-/* Set avail tracked in @bp for sector @sp to @amount. */
-void
-bp_put_avail(struct bp *bp, struct sctstr *sp, int amount)
-{
- if (bp)
- bp[sp->sct_uid].bp_avail = amount;
-}
-
-/* Set the values tracked in @bp for sector @sp to the values in @sp. */
-void
-bp_set_from_sect(struct bp *bp, struct sctstr *sp)
-{
- bp_put_items(bp, sp);
- bp_put_avail(bp, sp, sp->sct_avail);
+ bp[sp->sct_uid].bp_avail = sp->sct_avail;
}
/* Copy the values tracked in @bp for sector @sp back to @sp. */
}
work = do_feed(sp, np, etu, 0);
- bp_put_items(bp, sp);
- if (sp->sct_off || np->nat_money < 0)
+ if (sp->sct_off || np->nat_money < 0) {
+ bp_set_from_sect(bp, sp);
continue;
+ }
sp->sct_avail = work;
amount = 0;
if ((sp->sct_effic < 100 || sp->sct_type != sp->sct_newtype) &&
np->nat_money >= 0) {
cost = buildeff(sp);
- bp_put_items(bp, sp);
p_sect[SCT_EFFIC][0]++;
p_sect[SCT_EFFIC][1] += cost;
if (!player->simulation)
p_sect[sp->sct_type][1] += ecost;
if (!player->simulation)
np->nat_money -= ecost;
- bp_put_items(bp, sp);
}
/*
if (sp->sct_effic >= 60) {
if (np->nat_money >= 0 && dchr[sp->sct_type].d_prd >= 0)
amount = produce(np, sp, &pcost);
- bp_put_items(bp, sp);
}
- bp_put_avail(bp, sp, sp->sct_avail);
+ bp_set_from_sect(bp, sp);
p_sect[sp->sct_type][0] += amount;
p_sect[sp->sct_type][1] += pcost;
if (!player->simulation)