update: Drop produce() return value and parameters work, amount
Since changing *sp is safe now, we can move the update of sp->sct_avail into produce(). This frees the return value; use it to return the amount produced. Drop the parameters. Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
parent
688c8b736b
commit
0efa8fa7a1
3 changed files with 10 additions and 13 deletions
|
@ -704,8 +704,7 @@ extern int upd_slmilcosts(natid, int);
|
|||
extern void prepare_sects(int, struct bp *);
|
||||
extern int bank_income(struct sctstr *, int);
|
||||
/* produce.c */
|
||||
extern int produce(struct natstr *, struct sctstr *, int, int,
|
||||
int, int *, int *);
|
||||
extern int produce(struct natstr *, struct sctstr *, int, int, int *);
|
||||
extern int prod_materials_cost(struct pchrstr *, short[], int *);
|
||||
extern int prod_resource_limit(struct pchrstr *, unsigned char *);
|
||||
extern double prod_eff(int, float);
|
||||
|
|
|
@ -45,8 +45,8 @@ static char *levelnames[] = {
|
|||
};
|
||||
|
||||
int
|
||||
produce(struct natstr *np, struct sctstr *sp, int work,
|
||||
int desig, int neweff, int *cost, int *amount)
|
||||
produce(struct natstr *np, struct sctstr *sp,
|
||||
int desig, int neweff, int *cost)
|
||||
{
|
||||
struct pchrstr *product;
|
||||
double p_e;
|
||||
|
@ -69,7 +69,6 @@ produce(struct natstr *np, struct sctstr *sp, int work,
|
|||
resource = (unsigned char *)sp + product->p_nrndx;
|
||||
else
|
||||
resource = NULL;
|
||||
*amount = 0;
|
||||
*cost = 0;
|
||||
|
||||
material_limit = prod_materials_cost(product, sp->sct_item,
|
||||
|
@ -86,7 +85,7 @@ produce(struct natstr *np, struct sctstr *sp, int work,
|
|||
if (unit_work == 0)
|
||||
unit_work = 1;
|
||||
|
||||
worker_limit = work * p_e / unit_work;
|
||||
worker_limit = sp->sct_avail * p_e / unit_work;
|
||||
res_limit = prod_resource_limit(product, resource);
|
||||
|
||||
material_consume = res_limit;
|
||||
|
@ -150,7 +149,6 @@ produce(struct natstr *np, struct sctstr *sp, int work,
|
|||
val = 0;
|
||||
*resource = val;
|
||||
}
|
||||
*amount = actual;
|
||||
*cost = product->p_cost * material_consume;
|
||||
|
||||
if (opt_TECH_POP) {
|
||||
|
@ -161,11 +159,12 @@ produce(struct natstr *np, struct sctstr *sp, int work,
|
|||
}
|
||||
|
||||
if (CANT_HAPPEN(p_e <= 0.0))
|
||||
return 0;
|
||||
return actual;
|
||||
work_used = roundavg(unit_work * material_consume / p_e);
|
||||
if (CANT_HAPPEN(work_used > work))
|
||||
return work;
|
||||
return work_used;
|
||||
if (CANT_HAPPEN(work_used > sp->sct_avail))
|
||||
work_used = sp->sct_avail;
|
||||
sp->sct_avail -= work_used;
|
||||
return actual;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -328,8 +328,7 @@ produce_sect(struct natstr *np, int etu, struct bp *bp, int p_sect[][2])
|
|||
|
||||
if (sp->sct_effic >= 60) {
|
||||
if (np->nat_money >= 0 && dchr[desig].d_prd >= 0)
|
||||
sp->sct_avail -= produce(np, sp, sp->sct_avail, desig,
|
||||
sp->sct_effic, &pcost, &amount);
|
||||
amount = produce(np, sp, desig, sp->sct_effic, &pcost);
|
||||
bp_put_items(bp, sp);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue