edit: Implement editing bars on ships and land units

The edit command doesn't support editing bars on ships and land units.
Has always been that way.  The stock game's ships have always been
unable to load bars.  Not the case for land units.

Unfortunately, the obvious key 'b' for bars was burned on plague time
in 4.0.17.  Use key 'B' instead.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
Markus Armbruster 2017-08-27 13:28:20 +02:00
parent 647dc66a40
commit 16e565ed5f
4 changed files with 42 additions and 19 deletions

View file

@ -267,9 +267,9 @@ print_plane(struct plnstr *plane)
static void static void
print_items(short item[]) print_items(short item[])
{ {
pr(" civ mil uw food sh gun pet iron dust oil lcm hcm rad\n" pr(" civ mil uw food sh gun pet iron dust bar oil lcm hcm rad\n"
" c m u f s g p i d o l h r\n" " c m u f s g p i d B o l h r\n"
"%5d%5d%5d%5d%5d%5d%5d%5d%5d%5d%5d%5d%5d\n", "%5d%5d%5d%5d%5d%5d%5d%5d%5d%5d%5d%5d%5d%5d\n",
item[I_CIVIL], item[I_CIVIL],
item[I_MILIT], item[I_MILIT],
item[I_UW], item[I_UW],
@ -279,6 +279,7 @@ print_items(short item[])
item[I_PETROL], item[I_PETROL],
item[I_IRON], item[I_IRON],
item[I_DUST], item[I_DUST],
item[I_BAR],
item[I_OIL], item[I_OIL],
item[I_LCM], item[I_LCM],
item[I_HCM], item[I_HCM],
@ -849,6 +850,17 @@ edit_item(struct empobj *unit, short item[], struct ichrstr *ip, int arg,
item[ip->i_uid] = arg; item[ip->i_uid] = arg;
} }
static void
edit_unit_item(struct empobj *unit, short item[], char *key, int arg,
short lim[])
{
char lowkey[2];
lowkey[0] = tolower(*key);
lowkey[1] = 0;
edit_item(unit, item, item_by_name(lowkey), arg, lim);
}
static void static void
limit_item(struct empobj *unit, short item[], short lim[]) limit_item(struct empobj *unit, short item[], short lim[])
{ {
@ -934,12 +946,13 @@ edit_ship(struct shpstr *ship, char *key, char *p)
case 'p': case 'p':
case 'i': case 'i':
case 'd': case 'd':
case 'B':
case 'o': case 'o':
case 'l': case 'l':
case 'h': case 'h':
case 'r': case 'r':
edit_item((struct empobj *)ship, ship->shp_item, item_by_name(key), edit_unit_item((struct empobj *)ship, ship->shp_item, key, arg,
arg, mcp->m_item); mcp->m_item);
break; break;
default: default:
pr("huh? (%s)\n", key); pr("huh? (%s)\n", key);
@ -1065,12 +1078,13 @@ edit_land(struct lndstr *land, char *key, char *p)
case 'p': case 'p':
case 'i': case 'i':
case 'd': case 'd':
case 'B':
case 'o': case 'o':
case 'l': case 'l':
case 'h': case 'h':
case 'r': case 'r':
edit_item((struct empobj *)land, land->lnd_item, item_by_name(key), edit_unit_item((struct empobj *)land, land->lnd_item, key, arg,
arg, lcp->l_item); lcp->l_item);
break; break;
default: default:
pr("huh? (%s)\n", key); pr("huh? (%s)\n", key);

View file

@ -195,7 +195,7 @@ config land
uid owner xloc yloc type effic mobil off tech opx opy mission radius army ship harden retreat rflags rpath civil milit shell gun petrol iron dust bar food oil lcm hcm uw rad pstage ptime land access uid owner xloc yloc type effic mobil off tech opx opy mission radius army ship harden retreat rflags rpath civil milit shell gun petrol iron dust bar food oil lcm hcm uw rad pstage ptime land access
0 0 1 -1 6 0 2 0 100 0 0 none 0 "" -1 0 42 () "" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0 0 0 1 -1 6 0 2 0 100 0 0 none 0 "" -1 0 42 () "" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
1 98 1 -1 6 10 0 0 100 0 0 none 0 "" -1 0 42 () "" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0 1 98 1 -1 6 10 0 0 100 0 0 none 0 "" -1 0 42 () "" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
2 2 3 -1 6 10 -127 0 50 0 0 none 0 "" -1 0 0 (group) "" 0 1 1 1 1 1 1 0 1 0 1 1 0 0 healthy 0 -1 0 2 2 3 -1 6 10 -127 0 50 0 0 none 0 "" -1 0 0 (group) "" 0 1 1 1 1 1 1 1 1 0 1 1 0 0 healthy 0 -1 0
3 3 1 -1 6 10 -127 0 50 0 0 none 0 "a" 3 0 0 (injured) "jj" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0 3 3 1 -1 6 10 -127 0 50 0 0 none 0 "a" 3 0 0 (injured) "jj" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
4 3 3 -1 6 100 127 0 32767 0 0 none 0 "" 2 127 100 () "" 0 25 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0 4 3 3 -1 6 100 127 0 32767 0 0 none 0 "" 2 127 100 () "" 0 25 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
5 3 1 -1 6 100 127 0 32767 0 0 none 0 "" -1 127 100 () "" 0 25 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0 5 3 1 -1 6 100 127 0 32767 0 0 none 0 "" -1 127 100 () "" 0 25 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
@ -224,7 +224,7 @@ actor action victim times duration time
0 43 3 38 0 0 0 43 3 38 0 0
0 44 2 7 0 0 0 44 2 7 0 0
0 42 3 4 0 0 0 42 3 4 0 0
0 42 2 17 0 0 0 42 2 18 0 0
0 43 4 2 0 0 0 43 4 2 0 0
0 44 1 1 0 0 0 44 1 1 0 0
0 43 2 4 0 0 0 43 2 4 0 0

View file

@ -309,7 +309,7 @@ for my $ef ('ship', 'land') {
# items # items
for my $ef ('ship', 'land') { for my $ef ('ship', 'land') {
for my $key (split(//, 'cmsgpidfolhur')) { for my $key (split(//, 'cmsgpidBfolhur')) {
edit($ef, 2, $key, 1); edit($ef, 2, $key, 1);
} }
} }

View file

@ -1508,6 +1508,10 @@
Play#0 command edit Play#0 command edit
Play#0 output Play#0 1 dust (gold) of cs cargo ship (#2) unchanged Play#0 output Play#0 1 dust (gold) of cs cargo ship (#2) unchanged
Play#0 output Play#0 6 0 640 Play#0 output Play#0 6 0 640
Play#0 input edit s 2 B 1
Play#0 command edit
Play#0 output Play#0 1 bars of gold of cs cargo ship (#2) unchanged
Play#0 output Play#0 6 0 640
Play#0 input edit s 2 f 1 Play#0 input edit s 2 f 1
Play#0 command edit Play#0 command edit
Play#0 output Play#0 1 food of cs cargo ship (#2) changed from 0 to 1 Play#0 output Play#0 1 food of cs cargo ship (#2) changed from 0 to 1
@ -1560,6 +1564,10 @@
Play#0 command edit Play#0 command edit
Play#0 output Play#0 1 dust (gold) of sup supply #2 changed from 0 to 1 Play#0 output Play#0 1 dust (gold) of sup supply #2 changed from 0 to 1
Play#0 output Play#0 6 0 640 Play#0 output Play#0 6 0 640
Play#0 input edit u 2 B 1
Play#0 command edit
Play#0 output Play#0 1 bars of gold of sup supply #2 changed from 0 to 1
Play#0 output Play#0 6 0 640
Play#0 input edit u 2 f 1 Play#0 input edit u 2 f 1
Play#0 command edit Play#0 command edit
Play#0 output Play#0 1 food of sup supply #2 changed from 0 to 1 Play#0 output Play#0 1 food of sup supply #2 changed from 0 to 1
@ -1647,9 +1655,9 @@
Play#0 output Play#0 1 Mobility <M>: 0 Fleet <F>: Play#0 output Play#0 1 Mobility <M>: 0 Fleet <F>:
Play#0 output Play#0 1 Retreat path <R>: '' Retreat Flags <W>: 0 Play#0 output Play#0 1 Retreat path <R>: '' Retreat Flags <W>: 0
Play#0 output Play#0 1 Plague Stage <a>: 0 Plague Time <b>: 0 Play#0 output Play#0 1 Plague Stage <a>: 0 Plague Time <b>: 0
Play#0 output Play#0 1 civ mil uw food sh gun pet iron dust oil lcm hcm rad Play#0 output Play#0 1 civ mil uw food sh gun pet iron dust bar oil lcm hcm rad
Play#0 output Play#0 1 c m u f s g p i d o l h r Play#0 output Play#0 1 c m u f s g p i d B o l h r
Play#0 output Play#0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 Play#0 output Play#0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Play#0 output Play#0 4 %c xxxxx -- thing value : Play#0 output Play#0 4 %c xxxxx -- thing value :
Play#0 input M 2 Play#0 input M 2
Play#0 output Play#0 1 Mobility of cs cargo ship (#0) changed from 0 to 2 Play#0 output Play#0 1 Mobility of cs cargo ship (#0) changed from 0 to 2
@ -1671,9 +1679,9 @@
Play#0 output Play#0 1 Mobility <M>: 2 Fleet <F>: Play#0 output Play#0 1 Mobility <M>: 2 Fleet <F>:
Play#0 output Play#0 1 Retreat path <R>: '' Retreat Flags <W>: 0 Play#0 output Play#0 1 Retreat path <R>: '' Retreat Flags <W>: 0
Play#0 output Play#0 1 Plague Stage <a>: 0 Plague Time <b>: 0 Play#0 output Play#0 1 Plague Stage <a>: 0 Plague Time <b>: 0
Play#0 output Play#0 1 civ mil uw food sh gun pet iron dust oil lcm hcm rad Play#0 output Play#0 1 civ mil uw food sh gun pet iron dust bar oil lcm hcm rad
Play#0 output Play#0 1 c m u f s g p i d o l h r Play#0 output Play#0 1 c m u f s g p i d B o l h r
Play#0 output Play#0 1 0 1 0 1 0 0 0 0 0 0 0 0 0 Play#0 output Play#0 1 0 1 0 1 0 0 0 0 0 0 0 0 0 0
Play#0 output Play#0 4 %c xxxxx -- thing value : Play#0 output Play#0 4 %c xxxxx -- thing value :
Play#0 input R n Play#0 input R n
Play#0 output Play#0 1 Retreat path of cs cargo ship (#0) changed from to n Play#0 output Play#0 1 Retreat path of cs cargo ship (#0) changed from to n
@ -1712,9 +1720,9 @@
Play#0 output Play#0 1 Fortification <F>: 0 Land unit <Y>: -1 Play#0 output Play#0 1 Fortification <F>: 0 Land unit <Y>: -1
Play#0 output Play#0 1 Ship <S>: -1 Retreat percentage <Z>: 42 Play#0 output Play#0 1 Ship <S>: -1 Retreat percentage <Z>: 42
Play#0 output Play#0 1 Retreat path <R>: '' Retreat Flags <W>: 0 Play#0 output Play#0 1 Retreat path <R>: '' Retreat Flags <W>: 0
Play#0 output Play#0 1 civ mil uw food sh gun pet iron dust oil lcm hcm rad Play#0 output Play#0 1 civ mil uw food sh gun pet iron dust bar oil lcm hcm rad
Play#0 output Play#0 1 c m u f s g p i d o l h r Play#0 output Play#0 1 c m u f s g p i d B o l h r
Play#0 output Play#0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 Play#0 output Play#0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Play#0 output Play#0 4 %c xxxxx -- thing value : Play#0 output Play#0 4 %c xxxxx -- thing value :
Play#0 input M 2 Play#0 input M 2
Play#0 output Play#0 1 Mobility of sup supply #0 changed from 0 to 2 Play#0 output Play#0 1 Mobility of sup supply #0 changed from 0 to 2
@ -2120,6 +2128,7 @@
Play#0 output Play#0 1 POGO gave you 1 petrol in sup supply #2 Play#0 output Play#0 1 POGO gave you 1 petrol in sup supply #2
Play#0 output Play#0 1 POGO gave you 1 iron ore in sup supply #2 Play#0 output Play#0 1 POGO gave you 1 iron ore in sup supply #2
Play#0 output Play#0 1 POGO gave you 1 dust (gold) in sup supply #2 Play#0 output Play#0 1 POGO gave you 1 dust (gold) in sup supply #2
Play#0 output Play#0 1 POGO gave you 1 bars of gold in sup supply #2
Play#0 output Play#0 1 POGO gave you 1 food in sup supply #2 Play#0 output Play#0 1 POGO gave you 1 food in sup supply #2
Play#0 output Play#0 1 POGO gave you 1 light products in sup supply #2 Play#0 output Play#0 1 POGO gave you 1 light products in sup supply #2
Play#0 output Play#0 1 POGO gave you 1 heavy products in sup supply #2 Play#0 output Play#0 1 POGO gave you 1 heavy products in sup supply #2