/* Each cost is per point of efficency */
struct sctintrins {
char *in_name;
- unsigned char in_lcms; /* construction materials */
- unsigned char in_hcms;
+ short in_mat[I_MAX+1]; /* materials to build 100% */
+ /* non-zero only for I_LCM and I_HCM */
short in_bmobil; /* mobility to build 100% */
int in_cost; /* cost to build 100% */
unsigned char in_enable; /* enabled iff non-zero */
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],
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) {
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) {
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;
/* no need for uid as long as it's not referenced from other tables */
{"name", fldoff(in_name), NSC_STRING, 0, NULL, EF_BAD, 0,
CA_DUMP_CONST},
- {"lcms", fldoff(in_lcms), NSC_UCHAR, 0, NULL, EF_BAD, 0, CA_DUMP},
- {"hcms", fldoff(in_hcms), NSC_UCHAR, 0, NULL, EF_BAD, 0, CA_DUMP},
+ NSC_MVEC(fldoff(in_mat), CA_DUMP_ONLY, CA_DUMP_ONLY, CA_DUMP_ONLY),
{"bmobil", fldoff(in_bmobil), NSC_SHORT, 0, NULL, EF_BAD, 0, CA_DUMP},
{"cost", fldoff(in_cost), NSC_INT, 0, NULL, EF_BAD, 0, CA_DUMP},
{"enable", fldoff(in_enable), NSC_UCHAR, 0, NULL, EF_BAD, 0, CA_DUMP},
# econfig key custom_tables.
config infrastructure
-name lcm hcm bmob cost enab
-"road network" 2 2 100 200 1
-"rail network" 1 1 100 100 1
-"defense factor" 1 1 100 100 0
+name l_b h_b bmob cost enab
+"road network" 200 200 100 200 1
+"rail network" 100 100 100 100 1
+"defense factor" 100 100 100 100 0
/config
"infrastructure type lcm hcm mobil $\n");
pr("%-23.23s %4d %4d %5d %5d\n",
intrchr[i].in_name,
- intrchr[i].in_lcms * 100, intrchr[i].in_hcms * 100,
+ intrchr[i].in_mat[I_LCM], intrchr[i].in_mat[I_HCM],
intrchr[i].in_bmobil, intrchr[i].in_cost);
first = 0;
}
config infrastructure
-name lcms hcms bmobil cost enable
+name l_b h_b bmobil cost enable
"lala" 1 1 1 1 1
# value for field 1 must be "road network"
config infrastructure
-name lcm hcm bmob cost enab
-"road network" 2 2 100 200 1
-"rail network" 1 1 100 100 1
-"defense factor" 1 1 100 100 0
+name l_b h_b bmob cost enab
+"road network" 200 200 100 200 1
+"rail network" 100 100 100 100 1
+"defense factor" 100 100 100 100 0
/con
# malformed table footer
Play#0 command xdump
Play#0 output Play#0 1 XDUMP meta infrastructure 0
Play#0 output Play#0 1 "name" 3 0 0 -1
- Play#0 output Play#0 1 "lcms" 1 0 0 -1
- Play#0 output Play#0 1 "hcms" 1 0 0 -1
+ Play#0 output Play#0 1 "c_build" 1 0 0 -1
+ Play#0 output Play#0 1 "m_build" 1 0 0 -1
+ Play#0 output Play#0 1 "s_build" 1 0 0 -1
+ Play#0 output Play#0 1 "g_build" 1 0 0 -1
+ Play#0 output Play#0 1 "p_build" 1 0 0 -1
+ Play#0 output Play#0 1 "i_build" 1 0 0 -1
+ Play#0 output Play#0 1 "d_build" 1 0 0 -1
+ Play#0 output Play#0 1 "b_build" 1 0 0 -1
+ Play#0 output Play#0 1 "f_build" 1 0 0 -1
+ Play#0 output Play#0 1 "o_build" 1 0 0 -1
+ Play#0 output Play#0 1 "l_build" 1 0 0 -1
+ Play#0 output Play#0 1 "h_build" 1 0 0 -1
+ Play#0 output Play#0 1 "u_build" 1 0 0 -1
+ Play#0 output Play#0 1 "r_build" 1 0 0 -1
Play#0 output Play#0 1 "bmobil" 1 0 0 -1
Play#0 output Play#0 1 "cost" 1 0 0 -1
Play#0 output Play#0 1 "enable" 1 0 0 -1
- Play#0 output Play#0 1 /6
+ Play#0 output Play#0 1 /18
Play#0 output Play#0 6 0 640
Play#0 input xdump meta 25
Play#0 command xdump
Play#0 input xdump infrastructure *
Play#0 command xdump
Play#0 output Play#0 1 XDUMP infrastructure 0
- Play#0 output Play#0 1 "road\\040network" 2 2 100 200 1
- Play#0 output Play#0 1 "rail\\040network" 1 1 100 100 0
- Play#0 output Play#0 1 "defense\\040factor" 1 1 100 100 0
+ Play#0 output Play#0 1 "road\\040network" 0 0 0 0 0 0 0 0 0 0 200 200 0 0 100 200 1
+ Play#0 output Play#0 1 "rail\\040network" 0 0 0 0 0 0 0 0 0 0 100 100 0 0 100 100 0
+ Play#0 output Play#0 1 "defense\\040factor" 0 0 0 0 0 0 0 0 0 0 100 100 0 0 100 100 0
Play#0 output Play#0 1 /3
Play#0 output Play#0 6 0 640
Play#0 input xdump updates *
Play#1 input xdump infrastructure *
Play#1 command xdump
Play#1 output Play#1 1 XDUMP infrastructure 0
- Play#1 output Play#1 1 "road\\040network" 2 2 100 200 1
- Play#1 output Play#1 1 "rail\\040network" 1 1 100 100 0
- Play#1 output Play#1 1 "defense\\040factor" 1 1 100 100 0
+ Play#1 output Play#1 1 "road\\040network" 0 0 0 0 0 0 0 0 0 0 200 200 0 0 100 200 1
+ Play#1 output Play#1 1 "rail\\040network" 0 0 0 0 0 0 0 0 0 0 100 100 0 0 100 100 0
+ Play#1 output Play#1 1 "defense\\040factor" 0 0 0 0 0 0 0 0 0 0 100 100 0 0 100 100 0
Play#1 output Play#1 1 /3
Play#1 output Play#1 6 0 0
Play#1 input xdump updates *