]> git.pond.sub.org Git - empserver/commitdiff
edit: Don't permit putting a land unit or plane on two carriers
authorMarkus Armbruster <armbru@pond.sub.org>
Wed, 16 Jan 2013 20:07:21 +0000 (21:07 +0100)
committerMarkus Armbruster <armbru@pond.sub.org>
Thu, 6 Jun 2013 17:52:26 +0000 (19:52 +0200)
Only one of struct lndstr members lnd_ship, lnd_land may be
non-negative.  When a deity screws that up, the server oopses.  Be
nice: when setting one, zap the other.

Same for struct plnstr members pln_ship, pln_land.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
src/lib/commands/edit.c
tests/actofgod/actofgod.xdump
tests/actofgod/server.log

index c8b494f414c8b8e778f883c3ed944a74370f0fdb..f003514f7d091ec108dae2f4480640059ffc2a4b 100644 (file)
@@ -852,6 +852,8 @@ edit_land(struct lndstr *land, char op, int arg, char *p)
     case 'Y':
        if (arg < -1 || arg >= ef_nelem(EF_LAND))
            return RET_SYN;
+       if (arg >= 0 && arg != land->lnd_land)
+           land->lnd_ship = -1;
        land->lnd_land = arg;
        break;
     case 'U':
@@ -901,6 +903,8 @@ edit_land(struct lndstr *land, char op, int arg, char *p)
     case 'S':
        if (arg < -1 || arg >= ef_nelem(EF_SHIP))
            return RET_SYN;
+       if (arg >= 0 && arg != land->lnd_ship)
+           land->lnd_land = -1;
        land->lnd_ship = arg;
        break;
     case 'Z':
@@ -1027,11 +1031,15 @@ edit_plane(struct plnstr *plane, char op, int arg, char *p)
     case 's':
        if (arg < -1 || arg >= ef_nelem(EF_SHIP))
            return RET_SYN;
+       if (arg >= 0 && arg != plane->pln_ship)
+           plane->pln_land = -1;
        plane->pln_ship = arg;
        break;
     case 'y':
        if (arg < -1 || arg >= ef_nelem(EF_LAND))
            return RET_SYN;
+       if (arg >= 0 && arg != plane->pln_land)
+           plane->pln_ship = -1;
        plane->pln_land = arg;
        break;
     case 'f':
index df98f2db0806f64cd7f120b5b412203761cfd5b7..ac03677cb63e8fb78a8e25d471ba4e4241bb93cc 100644 (file)
@@ -252,7 +252,7 @@ uid owner xloc yloc type effic mobil off tech opx opy mission radius wing range
 1 98 1 -1 0 10 0 0 100 0 0 none 0 "" 9 0 -1 -1 () 0 0.00000
 2 2 3 -1 0 10 -127 0 50 0 0 none 0 "" 0 0 -1 -1 (airburst) 0 0.00000
 3 3 1 -1 0 10 -127 0 50 0 0 none 0 "a" 0 0 3 -1 () 0 0.00000
-4 3 1 -1 0 100 127 0 32767 0 0 none 0 "" 18 0 4 -1 () 0 0.00000
+4 3 1 -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
 7 0 0 0 0 0 0 0 0 0 0 none 0 "" 0 0 -1 -1 () 0 0.00000
@@ -305,7 +305,7 @@ uid owner xloc yloc type effic mobil off tech opx opy mission radius army ship h
 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 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 1 -1 6 100 127 0 32767 0 0 none 0 "" 4 127 100 () "" 0 25 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
+4 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 4 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
 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
index ad2aae2fef5c9e665c2920c78bd6b7d3657e45ff..299fdaaa40f3971f0767938d4a3ab36bc1315d9c 100644 (file)
@@ -10,8 +10,6 @@ tester@127.0.0.1 logged in as country #0
 Oops: id < 0 in ../src/lib/common/file.c:973
 Oops: id < 0 in ../src/lib/common/file.c:973
 Oops: id < 0 in ../src/lib/common/file.c:973
-Oops: ship >= 0 && land >= 0 in ../src/lib/subs/plane.c:77
-Oops: ship >= 0 && land >= 0 in ../src/lib/subs/land.c:78
 tester@127.0.0.1 logged out, country #0
 Shutdown commencing (cleaning up threads.)
 Server shutting down on signal 15