config: Generalize infrastructure build materials storage
Infrastructure requires lcms and hcms to build. The build materials are exposed as infrastructure columns lcms, hcms (struct sctintrins members in_lcms, in_hcms). They are per point of efficiency. In contrast, sector and 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 members in_lcms and in_hcms by array in_mat[], and provide selectors l_build and h_build. Additionally provide selectors for all other item types, with value zero, 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
c8b51ec1a8
commit
5d3abc9917
8 changed files with 52 additions and 50 deletions
|
@ -49,10 +49,8 @@ improve(void)
|
|||
int type;
|
||||
int value;
|
||||
int ovalue;
|
||||
int maxup, lim;
|
||||
int maxup, i, lim;
|
||||
struct natstr *natp;
|
||||
int lneeded;
|
||||
int hneeded;
|
||||
int wanted;
|
||||
|
||||
p = getstarg(player->argp[1],
|
||||
|
@ -104,26 +102,6 @@ improve(void)
|
|||
maxup = wanted;
|
||||
if (!maxup)
|
||||
continue;
|
||||
lneeded = incp->in_lcms * maxup;
|
||||
if (sect.sct_item[I_LCM] < lneeded) {
|
||||
lneeded = sect.sct_item[I_LCM];
|
||||
maxup = lneeded / incp->in_lcms;
|
||||
if (maxup <= 0) {
|
||||
pr("Not enough lcms in %s\n",
|
||||
xyas(sect.sct_x, sect.sct_y, player->cnum));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
hneeded = incp->in_hcms * maxup;
|
||||
if (sect.sct_item[I_HCM] < hneeded) {
|
||||
hneeded = sect.sct_item[I_HCM];
|
||||
maxup = hneeded / incp->in_hcms;
|
||||
if (maxup <= 0) {
|
||||
pr("Not enough hcms in %s\n",
|
||||
xyas(sect.sct_x, sect.sct_y, player->cnum));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
lim = (sect. sct_mobil - 1) * 100 / incp->in_bmobil;
|
||||
if (lim <= 0) {
|
||||
|
@ -134,6 +112,21 @@ improve(void)
|
|||
if (maxup > lim)
|
||||
maxup = lim;
|
||||
|
||||
for (i = I_NONE + 1; i <= I_MAX; i++) {
|
||||
if (!incp->in_mat[i])
|
||||
continue;
|
||||
lim = sect.sct_item[i] * 100 / incp->in_mat[i];
|
||||
if (lim <= 0) {
|
||||
pr("Not enough %s in %s\n",
|
||||
ichr[i].i_name,
|
||||
xyas(sect.sct_x, sect.sct_y, player->cnum));
|
||||
}
|
||||
if (maxup > lim)
|
||||
maxup = lim;
|
||||
}
|
||||
if (maxup <= 0)
|
||||
continue;
|
||||
|
||||
natp = getnatp(player->cnum);
|
||||
lim = (natp->nat_money - player->dolcost) * 100 / incp->in_cost;
|
||||
if (lim <= 0) {
|
||||
|
@ -144,10 +137,8 @@ improve(void)
|
|||
if (maxup > lim)
|
||||
maxup = lim;
|
||||
|
||||
lneeded = incp->in_lcms * maxup;
|
||||
hneeded = incp->in_hcms * maxup;
|
||||
sect.sct_item[I_LCM] -= lneeded;
|
||||
sect.sct_item[I_HCM] -= hneeded;
|
||||
for (i = I_NONE + 1; i <= I_MAX; i++)
|
||||
sect.sct_item[i] -= roundavg(maxup * incp->in_mat[i] / 100.0);
|
||||
sect.sct_mobil -= roundavg(maxup * incp->in_bmobil / 100.0);
|
||||
player->dolcost += maxup * incp->in_cost / 100.0;
|
||||
ovalue = value;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue