diff --git a/include/item.h b/include/item.h index 2aa7d28c..1df09527 100644 --- a/include/item.h +++ b/include/item.h @@ -27,7 +27,7 @@ * item.h: Definitions for item characteristics stuff * * Known contributors to this file: - * + * Markus Armbruster, 2004-2016 */ #ifndef ITEM_H @@ -70,6 +70,7 @@ typedef enum { struct ichrstr { char i_mnem; /* usually the initial letter */ i_type i_uid; /* index in ichr[] */ + int i_power; /* power value of 1000 items */ int i_value; /* mortgage value */ int i_sell; /* can this be sold? */ int i_lbs; /* how hard to move */ diff --git a/src/lib/commands/powe.c b/src/lib/commands/powe.c index f14cffe5..3603df00 100644 --- a/src/lib/commands/powe.c +++ b/src/lib/commands/powe.c @@ -358,17 +358,11 @@ power_tech_factor(float tech) static float item_power(short item[]) { - static float pow_denom[I_MAX + 1] = { - 10, 10, 12.5, 2.5, 500, 100, 5, 1, 0, 10, 10, 5, 0, 0 - }; - float p; - int i; + int pow, i; - p = 0.0; - for (i = I_NONE + 1; i <= I_MAX; i++) { - if (pow_denom[i]) - p += item[i] / pow_denom[i]; - } + pow = 0; + for (i = I_NONE + 1; i <= I_MAX; i++) + pow += item[i] * ichr[i].i_power; - return p; + return pow / 1000.0; } diff --git a/src/lib/common/nsc.c b/src/lib/common/nsc.c index 6c5102a5..e02d0a5c 100644 --- a/src/lib/common/nsc.c +++ b/src/lib/common/nsc.c @@ -99,6 +99,7 @@ struct castr ichr_ca[] = { {"uid", fldoff(i_uid), NSC_SITYPE(i_type), 0, NULL, EF_ITEM, 0}, {"name", fldoff(i_name), NSC_STRING, 0, NULL, EF_BAD, 0}, {"mnem", fldoff(i_mnem), NSC_STRINGY, 1, NULL, EF_BAD, NSC_CONST}, + {"power", fldoff(i_power), NSC_INT, 0, NULL, EF_BAD, 0}, {"value", fldoff(i_value), NSC_INT, 0, NULL, EF_BAD, 0}, {"sell", fldoff(i_sell), NSC_INT, 0, NULL, EF_BAD, 0}, {"lbs", fldoff(i_lbs), NSC_INT, 0, NULL, EF_BAD, 0}, diff --git a/src/lib/global/item.config b/src/lib/global/item.config index 14aa7503..ecce9e67 100644 --- a/src/lib/global/item.config +++ b/src/lib/global/item.config @@ -27,7 +27,7 @@ # item.config: Item characteristics # # Known contributors to this file: -# Markus Armbruster, 2006-2012 +# Markus Armbruster, 2006-2016 # # Derived from item.c; no known contributors. # @@ -43,19 +43,19 @@ # econfig key custom_tables. config item # ineff norm ware urban bank -uid mnem val sell lbs pkg(0) pkg(1) pkg(2) pkg(3) pkg(4) melt name - 0 "c" 1 0 1 1 10 10 10 10 4 "civilians" - 1 "m" 0 1 1 1 1 1 1 1 20 "military" - 2 "s" 5 1 1 1 1 10 1 1 80 "shells" - 3 "g" 60 1 10 1 1 10 1 1 100 "guns" - 4 "p" 4 1 1 1 1 10 1 1 50 "petrol" - 5 "i" 2 1 1 1 1 10 1 1 100 "iron ore" - 6 "d" 20 1 5 1 1 10 1 1 100 "dust (gold)" - 7 "b" 280 1 50 1 1 5 1 4 200 "bars of gold" - 8 "f" 0 1 1 1 1 10 1 1 2 "food" - 9 "o" 8 1 1 1 1 10 1 1 50 "oil" - 10 "l" 2 1 1 1 1 10 1 1 100 "light products" - 11 "h" 4 1 1 1 1 10 1 1 100 "heavy products" - 12 "u" 1 1 2 1 1 2 1 1 2 "uncompensated workers" - 13 "r" 150 1 8 1 1 10 1 1 1000 "radioactive materials" +uid mnem pow val sell lbs pkg(0) pkg(1) pkg(2) pkg(3) pkg(4) melt name + 0 "c" 100 1 0 1 1 10 10 10 10 4 "civilians" + 1 "m" 100 0 1 1 1 1 1 1 1 20 "military" + 2 "s" 80 5 1 1 1 1 10 1 1 80 "shells" + 3 "g" 400 60 1 10 1 1 10 1 1 100 "guns" + 4 "p" 2 4 1 1 1 1 10 1 1 50 "petrol" + 5 "i" 10 2 1 1 1 1 10 1 1 100 "iron ore" + 6 "d" 200 20 1 5 1 1 10 1 1 100 "dust (gold)" + 7 "b" 1000 280 1 50 1 1 5 1 4 200 "bars of gold" + 8 "f" 0 0 1 1 1 1 10 1 1 2 "food" + 9 "o" 100 8 1 1 1 1 10 1 1 50 "oil" + 10 "l" 100 2 1 1 1 1 10 1 1 100 "light products" + 11 "h" 200 4 1 1 1 1 10 1 1 100 "heavy products" + 12 "u" 0 1 1 2 1 1 2 1 1 2 "uncompensated workers" + 13 "r" 0 150 1 8 1 1 10 1 1 1000 "radioactive materials" /config diff --git a/tests/empdump/errors.err b/tests/empdump/errors.err index 1593ec4b..8544c3c6 100644 --- a/tests/empdump/errors.err +++ b/tests/empdump/errors.err @@ -86,6 +86,7 @@ tests/empdump/xundump-errors/fld-malstr:2: malformed string in field 1 tests/empdump/xundump-errors/fld-many:2: too many fields, expected only 6 tests/empdump/xundump-errors/fld-miss:2: field 'name' missing tests/empdump/xundump-errors/fld-miss:2: field 'mnem' missing +tests/empdump/xundump-errors/fld-miss:2: field 'power' missing tests/empdump/xundump-errors/fld-miss:2: field 'value' missing tests/empdump/xundump-errors/fld-miss:2: field 'sell' missing tests/empdump/xundump-errors/fld-miss:2: field 'lbs' missing diff --git a/tests/version/journal.log b/tests/version/journal.log index f580c261..7daffb45 100644 --- a/tests/version/journal.log +++ b/tests/version/journal.log @@ -952,12 +952,13 @@ Play#0 output Play#0 1 "uid" 4 0 0 16 Play#0 output Play#0 1 "name" 3 0 0 -1 Play#0 output Play#0 1 "mnem" 13 4 1 -1 + Play#0 output Play#0 1 "power" 8 0 0 -1 Play#0 output Play#0 1 "value" 8 0 0 -1 Play#0 output Play#0 1 "sell" 8 0 0 -1 Play#0 output Play#0 1 "lbs" 8 0 0 -1 Play#0 output Play#0 1 "pkg" 8 0 5 -1 Play#0 output Play#0 1 "melt_denom" 8 0 0 -1 - Play#0 output Play#0 1 /8 + Play#0 output Play#0 1 /9 Play#0 output Play#0 6 0 640 Play#0 input xdump meta 17 Play#0 command xdump @@ -1451,20 +1452,20 @@ Play#0 input xdump item * Play#0 command xdump Play#0 output Play#0 1 XDUMP item 0 - Play#0 output Play#0 1 0 "civilians" "c" 1 0 1 1 10 10 10 10 4 - Play#0 output Play#0 1 1 "military" "m" 0 1 1 1 1 1 1 1 20 - Play#0 output Play#0 1 2 "shells" "s" 5 1 1 1 1 10 1 1 80 - Play#0 output Play#0 1 3 "guns" "g" 60 1 10 1 1 10 1 1 100 - Play#0 output Play#0 1 4 "petrol" "p" 4 1 1 1 1 10 1 1 50 - Play#0 output Play#0 1 5 "iron\\040ore" "i" 2 1 1 1 1 10 1 1 100 - Play#0 output Play#0 1 6 "dust\\040(gold)" "d" 20 1 5 1 1 10 1 1 100 - Play#0 output Play#0 1 7 "bars\\040of\\040gold" "b" 280 1 50 1 1 5 1 4 200 - Play#0 output Play#0 1 8 "food" "f" 0 1 1 1 1 10 1 1 2 - Play#0 output Play#0 1 9 "oil" "o" 8 1 1 1 1 10 1 1 50 - Play#0 output Play#0 1 10 "light\\040products" "l" 2 1 1 1 1 10 1 1 100 - Play#0 output Play#0 1 11 "heavy\\040products" "h" 4 1 1 1 1 10 1 1 100 - Play#0 output Play#0 1 12 "uncompensated\\040workers" "u" 1 1 2 1 1 2 1 1 2 - Play#0 output Play#0 1 13 "radioactive\\040materials" "r" 150 1 8 1 1 10 1 1 1000 + Play#0 output Play#0 1 0 "civilians" "c" 100 1 0 1 1 10 10 10 10 4 + Play#0 output Play#0 1 1 "military" "m" 100 0 1 1 1 1 1 1 1 20 + Play#0 output Play#0 1 2 "shells" "s" 80 5 1 1 1 1 10 1 1 80 + Play#0 output Play#0 1 3 "guns" "g" 400 60 1 10 1 1 10 1 1 100 + Play#0 output Play#0 1 4 "petrol" "p" 2 4 1 1 1 1 10 1 1 50 + Play#0 output Play#0 1 5 "iron\\040ore" "i" 10 2 1 1 1 1 10 1 1 100 + Play#0 output Play#0 1 6 "dust\\040(gold)" "d" 200 20 1 5 1 1 10 1 1 100 + Play#0 output Play#0 1 7 "bars\\040of\\040gold" "b" 1000 280 1 50 1 1 5 1 4 200 + Play#0 output Play#0 1 8 "food" "f" 0 0 1 1 1 1 10 1 1 2 + Play#0 output Play#0 1 9 "oil" "o" 100 8 1 1 1 1 10 1 1 50 + Play#0 output Play#0 1 10 "light\\040products" "l" 100 2 1 1 1 1 10 1 1 100 + Play#0 output Play#0 1 11 "heavy\\040products" "h" 200 4 1 1 1 1 10 1 1 100 + Play#0 output Play#0 1 12 "uncompensated\\040workers" "u" 0 1 1 2 1 1 2 1 1 2 + Play#0 output Play#0 1 13 "radioactive\\040materials" "r" 0 150 1 8 1 1 10 1 1 1000 Play#0 output Play#0 1 /14 Play#0 output Play#0 6 0 640 Play#0 input xdump product * @@ -2172,20 +2173,20 @@ Play#1 input xdump item * Play#1 command xdump Play#1 output Play#1 1 XDUMP item 0 - Play#1 output Play#1 1 0 "civilians" "c" 1 0 1 1 10 10 10 10 4 - Play#1 output Play#1 1 1 "military" "m" 0 1 1 1 1 1 1 1 20 - Play#1 output Play#1 1 2 "shells" "s" 5 1 1 1 1 10 1 1 80 - Play#1 output Play#1 1 3 "guns" "g" 60 1 10 1 1 10 1 1 100 - Play#1 output Play#1 1 4 "petrol" "p" 4 1 1 1 1 10 1 1 50 - Play#1 output Play#1 1 5 "iron\\040ore" "i" 2 1 1 1 1 10 1 1 100 - Play#1 output Play#1 1 6 "dust\\040(gold)" "d" 20 1 5 1 1 10 1 1 100 - Play#1 output Play#1 1 7 "bars\\040of\\040gold" "b" 280 1 50 1 1 5 1 4 200 - Play#1 output Play#1 1 8 "food" "f" 0 1 1 1 1 10 1 1 2 - Play#1 output Play#1 1 9 "oil" "o" 8 1 1 1 1 10 1 1 50 - Play#1 output Play#1 1 10 "light\\040products" "l" 2 1 1 1 1 10 1 1 100 - Play#1 output Play#1 1 11 "heavy\\040products" "h" 4 1 1 1 1 10 1 1 100 - Play#1 output Play#1 1 12 "uncompensated\\040workers" "u" 1 1 2 1 1 2 1 1 2 - Play#1 output Play#1 1 13 "radioactive\\040materials" "r" 150 1 8 1 1 10 1 1 1000 + Play#1 output Play#1 1 0 "civilians" "c" 100 1 0 1 1 10 10 10 10 4 + Play#1 output Play#1 1 1 "military" "m" 100 0 1 1 1 1 1 1 1 20 + Play#1 output Play#1 1 2 "shells" "s" 80 5 1 1 1 1 10 1 1 80 + Play#1 output Play#1 1 3 "guns" "g" 400 60 1 10 1 1 10 1 1 100 + Play#1 output Play#1 1 4 "petrol" "p" 2 4 1 1 1 1 10 1 1 50 + Play#1 output Play#1 1 5 "iron\\040ore" "i" 10 2 1 1 1 1 10 1 1 100 + Play#1 output Play#1 1 6 "dust\\040(gold)" "d" 200 20 1 5 1 1 10 1 1 100 + Play#1 output Play#1 1 7 "bars\\040of\\040gold" "b" 1000 280 1 50 1 1 5 1 4 200 + Play#1 output Play#1 1 8 "food" "f" 0 0 1 1 1 1 10 1 1 2 + Play#1 output Play#1 1 9 "oil" "o" 100 8 1 1 1 1 10 1 1 50 + Play#1 output Play#1 1 10 "light\\040products" "l" 100 2 1 1 1 1 10 1 1 100 + Play#1 output Play#1 1 11 "heavy\\040products" "h" 200 4 1 1 1 1 10 1 1 100 + Play#1 output Play#1 1 12 "uncompensated\\040workers" "u" 0 1 1 2 1 1 2 1 1 2 + Play#1 output Play#1 1 13 "radioactive\\040materials" "r" 0 150 1 8 1 1 10 1 1 1000 Play#1 output Play#1 1 /14 Play#1 output Play#1 6 0 0 Play#1 input xdump product *