]> git.pond.sub.org Git - empserver/commitdiff
edit: Implement editing bars on ships and land units
authorMarkus Armbruster <armbru@pond.sub.org>
Sun, 27 Aug 2017 11:28:20 +0000 (13:28 +0200)
committerMarkus Armbruster <armbru@pond.sub.org>
Tue, 5 Jan 2021 06:23:45 +0000 (07:23 +0100)
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>
src/lib/commands/edit.c
tests/actofgod/final.xdump
tests/actofgod/geninput.pl
tests/actofgod/journal.log

index 33da32cb615c9ffe0691e2dcaed14aed3241ac13..781246480265e6892c67d6919ee1e75f1baed1f7 100644 (file)
@@ -267,9 +267,9 @@ print_plane(struct plnstr *plane)
 static void
 print_items(short item[])
 {
-    pr("  civ  mil   uw food   sh  gun  pet iron dust  oil  lcm  hcm  rad\n"
-       "    c    m    u    f    s    g    p    i    d    o    l    h    r\n"
-       "%5d%5d%5d%5d%5d%5d%5d%5d%5d%5d%5d%5d%5d\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    B    o    l    h    r\n"
+       "%5d%5d%5d%5d%5d%5d%5d%5d%5d%5d%5d%5d%5d%5d\n",
        item[I_CIVIL],
        item[I_MILIT],
        item[I_UW],
@@ -279,6 +279,7 @@ print_items(short item[])
        item[I_PETROL],
        item[I_IRON],
        item[I_DUST],
+       item[I_BAR],
        item[I_OIL],
        item[I_LCM],
        item[I_HCM],
@@ -849,6 +850,17 @@ edit_item(struct empobj *unit, short item[], struct ichrstr *ip, int 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
 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 'i':
     case 'd':
+    case 'B':
     case 'o':
     case 'l':
     case 'h':
     case 'r':
-       edit_item((struct empobj *)ship, ship->shp_item, item_by_name(key),
-                 arg, mcp->m_item);
+       edit_unit_item((struct empobj *)ship, ship->shp_item, key, arg,
+                      mcp->m_item);
        break;
     default:
        pr("huh? (%s)\n", key);
@@ -1065,12 +1078,13 @@ edit_land(struct lndstr *land, char *key, char *p)
     case 'p':
     case 'i':
     case 'd':
+    case 'B':
     case 'o':
     case 'l':
     case 'h':
     case 'r':
-       edit_item((struct empobj *)land, land->lnd_item, item_by_name(key),
-                 arg, lcp->l_item);
+       edit_unit_item((struct empobj *)land, land->lnd_item, key, arg,
+                      lcp->l_item);
        break;
     default:
        pr("huh? (%s)\n", key);
index 198c9af1aeff604e9d36af0ba0bc1347edfeb012..bef7475ed1c18fd44be6d2cfc109263a7956f357 100644 (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
 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
-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
 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
@@ -224,7 +224,7 @@ actor action victim times duration time
 0 43 3 38 0 0
 0 44 2 7 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 44 1 1 0 0
 0 43 2 4 0 0
index 7f822358c77211a42e9e43012fc3f9613921b78f..0a18cf19cf6d366393b493c7766db84279a8b2ff 100755 (executable)
@@ -309,7 +309,7 @@ for my $ef ('ship', 'land') {
 
 # items
 for my $ef ('ship', 'land') {
-    for my $key (split(//, 'cmsgpidfolhur')) {
+    for my $key (split(//, 'cmsgpidBfolhur')) {
        edit($ef, 2, $key, 1);
     }
 }
index 32175423630eb0224c9e201b3f7661e98ee5cc3e..531bc62e764333739b5ba1d9e6af46de29826e9d 100644 (file)
     Play#0 command edit
     Play#0 output Play#0 1 dust (gold) of cs   cargo ship (#2) unchanged
     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 command edit
     Play#0 output Play#0 1 food of cs   cargo ship (#2) changed from 0 to 1
     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 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 command edit
     Play#0 output Play#0 1 food of sup  supply #2 changed from 0 to 1
     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 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     c    m    u    f    s    g    p    i    d    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   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    B    o    l    h    r
+    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 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 <M>: 2             Fleet <F>:
     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   civ  mil   uw food   sh  gun  pet iron dust  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     0    1    0    1    0    0    0    0    0    0    0    0    0
+    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    B    o    l    h    r
+    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 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 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 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     c    m    u    f    s    g    p    i    d    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   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    B    o    l    h    r
+    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 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 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 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 light products in sup  supply #2
     Play#0 output Play#0 1 POGO gave you 1 heavy products in sup  supply #2