diff --git a/include/prototypes.h b/include/prototypes.h index 91957604..3f6fa495 100644 --- a/include/prototypes.h +++ b/include/prototypes.h @@ -704,7 +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 *, short *, int, int, +extern int produce(struct natstr *, struct sctstr *, int, int, int, int *, int *); extern int prod_materials_cost(struct pchrstr *, short[], int *); extern int prod_resource_limit(struct pchrstr *, unsigned char *); diff --git a/src/lib/update/produce.c b/src/lib/update/produce.c index 796509e3..3fc74a4a 100644 --- a/src/lib/update/produce.c +++ b/src/lib/update/produce.c @@ -27,7 +27,7 @@ * produce.c: Produce goodies * * Known contributors to this file: - * Markus Armbruster, 2004-2013 + * Markus Armbruster, 2004-2016 */ #include @@ -45,7 +45,7 @@ static char *levelnames[] = { }; int -produce(struct natstr *np, struct sctstr *sp, short *vec, int work, +produce(struct natstr *np, struct sctstr *sp, int work, int desig, int neweff, int *cost, int *amount) { struct pchrstr *product; @@ -72,7 +72,8 @@ produce(struct natstr *np, struct sctstr *sp, short *vec, int work, *amount = 0; *cost = 0; - material_limit = prod_materials_cost(product, vec, &unit_work); + material_limit = prod_materials_cost(product, sp->sct_item, + &unit_work); if (material_limit <= 0) return 0; @@ -122,8 +123,8 @@ produce(struct natstr *np, struct sctstr *sp, short *vec, int work, actual = 999; material_consume = roundavg(actual / prodeff); } - if (vec[item] + actual > ITEM_MAX) { - actual = ITEM_MAX - vec[item]; + if (sp->sct_item[item] + actual > ITEM_MAX) { + actual = ITEM_MAX - sp->sct_item[item]; material_consume = roundavg(actual / prodeff); if (material_consume < 0) material_consume = 0; @@ -132,13 +133,13 @@ produce(struct natstr *np, struct sctstr *sp, short *vec, int work, "%s production backlog in %s\n", product->p_name, ownxy(sp)); } - vec[item] += actual; + sp->sct_item[item] += actual; } /* * Reset produced amount by commodity production ratio */ if (!player->simulation) { - materials_charge(product, vec, material_consume); + materials_charge(product, sp->sct_item, material_consume); if (resource && product->p_nrdep != 0) { /* * lower natural resource in sector depending on diff --git a/src/lib/update/sect.c b/src/lib/update/sect.c index d9dd1c76..fe8bb582 100644 --- a/src/lib/update/sect.c +++ b/src/lib/update/sect.c @@ -335,7 +335,7 @@ produce_sect(struct natstr *np, int etu, struct bp *bp, int p_sect[][2]) if (neweff >= 60) { if (np->nat_money >= 0 && dchr[desig].d_prd >= 0) - work -= produce(np, sp, sp->sct_item, work, desig, neweff, + work -= produce(np, sp, work, desig, neweff, &pcost, &amount); bp_put_items(bp, sp); }