config: Generalize sector build materials storage
Sectors require lcms and hcms to build. The build materials are exposed as sect-chr columns lcms, hcms (struct dchrstr members d_lcms, d_hcms). They are per point per point of efficiency. In contrast, unit build materials are defined for 100%. We want to define build materials for 100% now, for flexibility and consistency, and we want to optionally support more build materials in the future. Replace d_lcms and d_hcms by array member d_mat[], and replace selectors lcms and hcms by selectors l_build and h_build. This is an xdump compatibility break. To provide the customary grace period, we'd have to make selectors lcms and hcms virtual instead, with value l_build / 100 and h_build / 100 rounded up, and deprecate them. Deities would have to avoid l_build and h_build values that aren't multiples of 100 for this to work fully. But we're not bothering with maintaining xdump compatibility in this release. Provide selectors for all other item types, to help clients prepare for future additional materials. Use CA_DUMP_ONLY to keep them out of configuration tables until they actually work. Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
parent
826fcf009b
commit
bb9619c053
6 changed files with 93 additions and 101 deletions
|
@ -50,7 +50,7 @@ buildeff(struct sctstr *sp)
|
|||
int work_cost = 0;
|
||||
int avail = sp->sct_avail;
|
||||
int buildeff_work = avail / 2;
|
||||
int cost, n, hcms, lcms, neweff, desig;
|
||||
int cost, n, neweff, desig;
|
||||
|
||||
cost = 0;
|
||||
neweff = sp->sct_effic;
|
||||
|
@ -78,28 +78,11 @@ buildeff(struct sctstr *sp)
|
|||
work_cost = 100 - neweff;
|
||||
if (work_cost > buildeff_work)
|
||||
work_cost = buildeff_work;
|
||||
|
||||
if (dchr[desig].d_lcms > 0) {
|
||||
lcms = sp->sct_item[I_LCM];
|
||||
lcms /= dchr[desig].d_lcms;
|
||||
if (work_cost > lcms)
|
||||
work_cost = lcms;
|
||||
}
|
||||
if (dchr[desig].d_hcms > 0) {
|
||||
hcms = sp->sct_item[I_HCM];
|
||||
hcms /= dchr[desig].d_hcms;
|
||||
if (work_cost > hcms)
|
||||
work_cost = hcms;
|
||||
}
|
||||
work_cost = get_materials(sp, dchr[sp->sct_type].d_mat, work_cost);
|
||||
|
||||
neweff += work_cost;
|
||||
cost += (work_cost * dchr[desig].d_cost + 99) / 100;
|
||||
buildeff_work -= work_cost;
|
||||
|
||||
if ((dchr[desig].d_lcms > 0) || (dchr[desig].d_hcms > 0)) {
|
||||
sp->sct_item[I_LCM] -= work_cost * dchr[desig].d_lcms;
|
||||
sp->sct_item[I_HCM] -= work_cost * dchr[desig].d_hcms;
|
||||
}
|
||||
}
|
||||
|
||||
sp->sct_effic = neweff;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue