From: Markus Armbruster Date: Sun, 29 Dec 2013 12:52:37 +0000 (+0100) Subject: edit: Add editing of ship, plane and land unit type X-Git-Tag: v4.3.33~330 X-Git-Url: http://git.pond.sub.org/?p=empserver;a=commitdiff_plain;h=6b0b6f174b692d4bb098f37d1fbc90df2dbc6757 edit: Add editing of ship, plane and land unit type Signed-off-by: Markus Armbruster --- diff --git a/src/lib/commands/edit.c b/src/lib/commands/edit.c index 92aa4b581..ee38a1543 100644 --- a/src/lib/commands/edit.c +++ b/src/lib/commands/edit.c @@ -252,6 +252,7 @@ print_plane(struct plnstr *plane) { pr("%s %s\n", prnatid(plane->pln_own), prplane(plane)); pr("UID : %d\t\t", plane->pln_uid); + pr("Type : %s\n", plchr[plane->pln_type].pl_name); pr("Owner : %d\t\t", plane->pln_own); pr("Location : %s\n", xyas(plane->pln_x, plane->pln_y, player->cnum)); @@ -269,7 +270,8 @@ static void print_land(struct lndstr *land) { pr("%s %s\n", prnatid(land->lnd_own), prland(land)); - pr("UID : %d\n", land->lnd_uid); + pr("UID : %d\t\t", land->lnd_uid); + pr("Type : %s\n", lchr[land->lnd_type].l_name); pr("Owner : %d\n", land->lnd_own); pr("Location : %s\n", xyas(land->lnd_x, land->lnd_y, player->cnum)); pr("Efficiency : %d\t", land->lnd_effic); @@ -304,7 +306,8 @@ static void print_ship(struct shpstr *ship) { pr("%s %s\n", prnatid(ship->shp_own), prship(ship)); - pr("UID : %d\n", ship->shp_uid); + pr("UID : %d\t\t\t", ship->shp_uid); + pr("Type : %s\n", mchr[ship->shp_type].m_name); pr("Owner : %d\t\t\t", ship->shp_own); pr("Location : %s\n", xyas(ship->shp_x, ship->shp_y, player->cnum)); pr("Tech : %d\t\t\t", ship->shp_tech); @@ -836,6 +839,17 @@ edit_item(struct empobj *unit, short item[], struct ichrstr *ip, int arg, item[ip->i_uid] = arg; } +static void +limit_item(struct empobj *unit, short item[], short lim[]) +{ + i_type it; + + for (it = I_NONE + 1; it <= I_MAX; it++) { + if (item[it] > lim[it]) + edit_item(unit, item, &ichr[it], item[it], lim); + } +} + static int edit_ship(struct shpstr *ship, char *key, char *p) { @@ -851,6 +865,21 @@ edit_ship(struct shpstr *ship, char *key, char *p) case 'F': return edit_unit((struct empobj *)ship, key, p, SHIP_MINEFF, "fleet", 0); + case 't': + arg = ef_elt_byname(EF_SHIP_CHR, p); + if (arg < 0) { + pr("%s: invalid ship type\n", p); + return RET_FAIL; + } + divine_unit_change((struct empobj *)ship, "Type", + arg != ship->shp_type, 0, + "to %s", mchr[arg].m_name); + ship->shp_type = arg; + limit_item((struct empobj *)ship, ship->shp_item, mchr[arg].m_item); + if (ship->shp_tech >= mchr[arg].m_tech) + break; + arg = mchr[arg].m_tech; + /* fall through */ case 'T': arg = LIMIT_TO(arg, mcp->m_tech, SHRT_MAX); divine_unit_change((struct empobj *)ship, "Tech level", @@ -923,6 +952,21 @@ edit_land(struct lndstr *land, char *key, char *p) return edit_unit((struct empobj *)land, key, p, LAND_MINEFF, "army", land->lnd_ship >= 0 || land->lnd_land >= 0); + case 'T': + arg = ef_elt_byname(EF_LAND_CHR, p); + if (arg < 0) { + pr("%s: invalid land unit type\n", p); + return RET_FAIL; + } + divine_unit_change((struct empobj *)land, "Type", + arg != land->lnd_type, 0, + "to %s", lchr[arg].l_name); + land->lnd_type = arg; + limit_item((struct empobj *)land, land->lnd_item, lchr[arg].l_item); + if (land->lnd_tech >= lchr[arg].l_tech) + break; + arg = lchr[arg].l_tech; + /* fall through */ case 't': arg = LIMIT_TO(arg, lcp->l_tech, SHRT_MAX); divine_unit_change((struct empobj *)land, "Tech level", @@ -1025,6 +1069,20 @@ edit_plane(struct plnstr *plane, char *key, char *p) return edit_unit((struct empobj *)plane, key, p, PLANE_MINEFF, "wing", plane->pln_ship >= 0 || plane->pln_land >= 0); + case 'T': + arg = ef_elt_byname(EF_PLANE_CHR, p); + if (arg < 0) { + pr("%s: invalid plane type\n", p); + return RET_FAIL; + } + divine_unit_change((struct empobj *)plane, "Type", + arg != plane->pln_type, 0, + "to %s", plchr[arg].pl_name); + plane->pln_type = arg; + if (plane->pln_tech >= plchr[arg].pl_tech) + break; + arg = plchr[arg].pl_tech; + /* fall through */ case 't': arg = LIMIT_TO(arg, pcp->pl_tech, SHRT_MAX); divine_unit_change((struct empobj *)plane, "Tech level", diff --git a/tests/actofgod/actofgod.xdump b/tests/actofgod/actofgod.xdump index b808384cf..5a0903ae5 100644 --- a/tests/actofgod/actofgod.xdump +++ b/tests/actofgod/actofgod.xdump @@ -201,7 +201,7 @@ uid owner xloc yloc type effic mobil off tech opx opy mission radius fleet xstar 3 3 1 -1 2 20 -127 0 20 0 0 none 0 "a" 0 0 0 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 0 "" 3 "" 1 -1 3 (injured) "jj" 4 3 1 -1 2 100 127 0 32767 0 0 none 0 "" 0 0 0 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 50 0 0 0 0 0 0 0 0 0 0 0 0 exposed 32767 0 0 "" 4 "" 1 -1 3 () "" 5 3 1 -1 2 100 127 0 32767 0 0 none 0 "" 0 0 0 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 50 0 0 0 0 0 0 0 0 0 0 0 0 exposed 32767 0 0 "" 3 "" 1 -1 3 () "" -6 0 0 0 0 0 0 0 0 0 0 none 0 "" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 0 "" 0 "" 0 0 0 () "" +6 1 0 0 10 20 0 0 50 0 0 none 0 "" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 5 0 0 0 0 0 0 0 0 0 0 healthy 0 0 0 "" 0 "" 0 0 0 () "" 7 0 0 0 0 0 0 0 0 0 0 none 0 "" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 0 "" 0 "" 0 0 0 () "" 8 0 0 0 0 0 0 0 0 0 0 none 0 "" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 0 "" 0 "" 0 0 0 () "" 9 0 0 0 0 0 0 0 0 0 0 none 0 "" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 0 "" 0 "" 0 0 0 () "" @@ -254,7 +254,7 @@ uid owner xloc yloc type effic mobil off tech opx opy mission radius wing range 3 3 1 -1 0 10 -127 0 50 0 0 none 0 "a" 0 0 3 -1 () 0 0.00000 4 3 3 -1 0 100 127 0 32767 0 0 none 0 "" 18 0 -1 4 () 0 0.00000 5 3 1 -1 0 100 127 0 32767 0 0 none 0 "" 18 0 -1 -1 () 0 0.00000 -6 0 0 0 0 0 0 0 0 0 0 none 0 "" 0 0 -1 -1 () 0 0.00000 +6 1 0 0 9 10 0 0 90 0 0 none 0 "" 0 0 -1 -1 () 0 0.00000 7 0 0 0 0 0 0 0 0 0 0 none 0 "" 0 0 -1 -1 () 0 0.00000 8 0 0 0 0 0 0 0 0 0 0 none 0 "" 0 0 -1 -1 () 0 0.00000 9 0 0 0 0 0 0 0 0 0 0 none 0 "" 0 0 -1 -1 () 0 0.00000 @@ -307,7 +307,7 @@ uid owner xloc yloc type effic mobil off tech opx opy mission radius army ship h 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 -6 0 0 0 0 0 0 0 0 0 0 none 0 "" -1 0 0 () "" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0 +6 1 0 0 11 10 0 0 100 0 0 none 0 "" -1 0 0 () "" 0 0 0 10 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0 7 0 0 0 0 0 0 0 0 0 0 none 0 "" -1 0 0 () "" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0 8 0 0 0 0 0 0 0 0 0 0 none 0 "" -1 0 0 () "" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0 9 0 0 0 0 0 0 0 0 0 0 none 0 "" -1 0 0 () "" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0 @@ -367,9 +367,9 @@ actor action victim times duration time 0 44 1 32 0 0 0 43 2 5 0 0 0 44 3 22 0 0 -0 43 1 73 0 0 -0 42 1 4 0 0 -1 45 0 1 0 0 +0 43 1 79 0 0 +0 42 1 6 0 0 +1 45 0 3 0 0 0 43 3 33 0 0 0 44 2 6 0 0 0 42 3 4 0 0 diff --git a/tests/actofgod/geninput.pl b/tests/actofgod/geninput.pl index 56bb4bd33..a003c504c 100755 --- a/tests/actofgod/geninput.pl +++ b/tests/actofgod/geninput.pl @@ -248,6 +248,9 @@ for my $ef ('ship', 'plane', 'land') { edit($ef, 3, $key, '1,-1'); } +# ship: type +edit('ship', 6, 't', 'lc', 'O', 1, 't', 'lc', 't', 'hc', 'g', 8, 't', 'lc'); + # ship: effic mobil tech pstage ptime milit edit_int('ship', 2, ( ['E', 0, 100], @@ -258,6 +261,9 @@ edit_int('ship', 2, ( ['m', 0, 50], )); +# plane: type +edit('plane', 6, 'T', 'mb', 'O', 1, 'T', 'mb', 'T', 'hb', 'T', 'mb'); + # plane: effic mobil range tech edit_int('plane', 2, ( ['e', 0, 100], @@ -266,6 +272,10 @@ edit_int('plane', 2, ( ['t', 50, 32767], )); +# land: type +edit('land', 6, 'T', 'art', 'O', 1, 'T', 'art', 'T', 'hat', 'g', 12, + 'T', 'art'); + # land: effic mobil tech harden retreat milit edit_int('land', 2, ( ['e', 0, 100], diff --git a/tests/actofgod/journal.log b/tests/actofgod/journal.log index a36565ee1..a5e2caf79 100644 --- a/tests/actofgod/journal.log +++ b/tests/actofgod/journal.log @@ -985,6 +985,19 @@ Play#0 command edit Play#0 output Play#0 1 Location of sup supply #3 changed from 1,-1 to 1,-1 Play#0 output Play#0 6 0 640 + Play#0 input edit s 6 t lc O 1 t lc t hc g 8 t lc + Play#0 command edit + Play#0 output Play#0 1 Type of fb fishing boat (#6) changed to lc light cruiser + Play#0 output Play#0 1 Tech level of lc light cruiser (#6) changed from 0 to 45 + Play#0 output Play#0 1 Owner of lc light cruiser (#6) changed from POGO (#0) to 1 (#1) + Play#0 output Play#0 1 Efficiency of lc light cruiser (#6) changed from 0 to 20 + Play#0 output Play#0 1 Type of lc light cruiser (#6) unchanged + Play#0 output Play#0 1 Type of lc light cruiser (#6) changed to hc heavy cruiser + Play#0 output Play#0 1 Tech level of hc heavy cruiser (#6) changed from 45 to 50 + Play#0 output Play#0 1 guns of hc heavy cruiser (#6) changed from 0 to 8 + Play#0 output Play#0 1 Type of hc heavy cruiser (#6) changed to lc light cruiser + Play#0 output Play#0 1 guns of lc light cruiser (#6) changed from 8 to 5 + Play#0 output Play#0 6 0 640 Play#0 input edit s 2 E 0 Play#0 command edit Play#0 output Play#0 1 Efficiency of cs cargo ship (#2) unchanged @@ -1081,6 +1094,17 @@ Play#0 command edit Play#0 output Play#0 1 military of cs cargo ship (#5) changed from 0 to 50 Play#0 output Play#0 6 0 640 + Play#0 input edit p 6 T mb O 1 T mb T hb T mb + Play#0 command edit + Play#0 output Play#0 1 Type of f1 Sopwith Camel #6 changed to mb medium bomber + Play#0 output Play#0 1 Tech level of mb medium bomber #6 changed from 0 to 80 + Play#0 output Play#0 1 Owner of mb medium bomber #6 changed from POGO (#0) to 1 (#1) + Play#0 output Play#0 1 Efficiency of mb medium bomber #6 changed from 0 to 10 + Play#0 output Play#0 1 Type of mb medium bomber #6 unchanged + Play#0 output Play#0 1 Type of mb medium bomber #6 changed to hb B-26B Marauder + Play#0 output Play#0 1 Tech level of hb B-26B Marauder #6 changed from 80 to 90 + Play#0 output Play#0 1 Type of hb B-26B Marauder #6 changed to mb medium bomber + Play#0 output Play#0 6 0 640 Play#0 input edit p 2 e 0 Play#0 command edit Play#0 output Play#0 1 Efficiency of f1 Sopwith Camel #2 unchanged @@ -1145,6 +1169,19 @@ Play#0 command edit Play#0 output Play#0 1 Tech level of f1 Sopwith Camel #5 changed from 100 to 32767 Play#0 output Play#0 6 0 640 + Play#0 input edit u 6 T art O 1 T art T hat g 12 T art + Play#0 command edit + Play#0 output Play#0 1 Type of cav cavalry #6 changed to art artillery + Play#0 output Play#0 1 Tech level of art artillery #6 changed from 0 to 35 + Play#0 output Play#0 1 Owner of art artillery #6 changed from POGO (#0) to 1 (#1) + Play#0 output Play#0 1 Efficiency of art artillery #6 changed from 0 to 10 + Play#0 output Play#0 1 Type of art artillery #6 unchanged + Play#0 output Play#0 1 Type of art artillery #6 changed to hat hvy artillery + Play#0 output Play#0 1 Tech level of hat hvy artillery #6 changed from 35 to 100 + Play#0 output Play#0 1 guns of hat hvy artillery #6 changed from 0 to 12 + Play#0 output Play#0 1 Type of hat hvy artillery #6 changed to art artillery + Play#0 output Play#0 1 guns of art artillery #6 changed from 12 to 10 + Play#0 output Play#0 6 0 640 Play#0 input edit u 2 e 0 Play#0 command edit Play#0 output Play#0 1 Efficiency of sup supply #2 unchanged @@ -1351,7 +1388,7 @@ Play#0 input edit s 0 Play#0 command edit Play#0 output Play#0 1 POGO (#0) cs cargo ship (#0) - Play#0 output Play#0 1 UID : 0 + Play#0 output Play#0 1 UID : 0 Type : cs cargo ship Play#0 output Play#0 1 Owner : 0 Location : 1,-1 Play#0 output Play#0 1 Tech : 100 Efficiency : 0 Play#0 output Play#0 1 Mobility : 0 Fleet : @@ -1375,7 +1412,7 @@ Play#0 input edit s 0 Play#0 command edit Play#0 output Play#0 1 POGO (#0) cs cargo ship (#0) - Play#0 output Play#0 1 UID : 0 + Play#0 output Play#0 1 UID : 0 Type : cs cargo ship Play#0 output Play#0 1 Owner : 0 Location : 1,-1 Play#0 output Play#0 1 Tech : 100 Efficiency : 0 Play#0 output Play#0 1 Mobility : 2 Fleet : @@ -1396,7 +1433,8 @@ Play#0 input edit p 0 Play#0 command edit Play#0 output Play#0 1 POGO (#0) f1 Sopwith Camel #0 - Play#0 output Play#0 1 UID : 0 Owner : 0 Location : 1,-1 + Play#0 output Play#0 1 UID : 0 Type : f1 Sopwith Camel + Play#0 output Play#0 1 Owner : 0 Location : 1,-1 Play#0 output Play#0 1 Efficiency : 0 Mobility : 0 Play#0 output Play#0 1 Tech : 100 Wing : Play#0 output Play#0 1 Range : 9 Flags : 0 @@ -1413,7 +1451,7 @@ Play#0 input edit u 0 Play#0 command edit Play#0 output Play#0 1 POGO (#0) sup supply #0 - Play#0 output Play#0 1 UID : 0 + Play#0 output Play#0 1 UID : 0 Type : sup supply Play#0 output Play#0 1 Owner : 0 Play#0 output Play#0 1 Location : 1,-1 Play#0 output Play#0 1 Efficiency : 0 Mobility : 0 @@ -1737,6 +1775,22 @@ Play#0 output Play#0 1 POGO gave you 1 civilians in 8,6 Play#0 output Play#0 1 POGO gave you 9997 civilians in 6,6 Play#0 output Play#0 1 POGO stole 1 civilians from 8,6 + Play#0 output Play#0 1 lc light cruiser (#6) given to you by an act of POGO! + Play#0 output Play#0 1 Type of lc light cruiser (#6) changed to hc heavy cruiser by an act of POGO + Play#0 output Play#0 1 Tech level of hc heavy cruiser (#6) changed from 45 to 50 by an act of POGO + Play#0 output Play#0 1 POGO gave you 8 guns in hc heavy cruiser (#6) + Play#0 output Play#0 1 Type of hc heavy cruiser (#6) changed to lc light cruiser by an act of POGO + Play#0 output Play#0 1 POGO stole 3 guns from lc light cruiser (#6) + Play#0 output Play#0 1 mb medium bomber #6 given to you by an act of POGO! + Play#0 output Play#0 1 Type of mb medium bomber #6 changed to hb B-26B Marauder by an act of POGO + Play#0 output Play#0 1 Tech level of hb B-26B Marauder #6 changed from 80 to 90 by an act of POGO + Play#0 output Play#0 1 Type of hb B-26B Marauder #6 changed to mb medium bomber by an act of POGO + Play#0 output Play#0 1 art artillery #6 given to you by an act of POGO! + Play#0 output Play#0 1 Type of art artillery #6 changed to hat hvy artillery by an act of POGO + Play#0 output Play#0 1 Tech level of hat hvy artillery #6 changed from 35 to 100 by an act of POGO + Play#0 output Play#0 1 POGO gave you 12 guns in hat hvy artillery #6 + Play#0 output Play#0 1 Type of hat hvy artillery #6 changed to art artillery by an act of POGO + Play#0 output Play#0 1 POGO stole 2 guns from art artillery #6 Play#0 output Play#0 1 Money changed from 0 to -2147483648 by an act of POGO! Play#0 output Play#0 1 Technology changed from 0.00 to 3.14 by an act of POGO! Play#0 output Play#0 1 Research changed from 0.00 to 3.14 by an act of POGO!