diff --git a/src/lib/commands/edit.c b/src/lib/commands/edit.c index 1dd1e1eb..c3e04b68 100644 --- a/src/lib/commands/edit.c +++ b/src/lib/commands/edit.c @@ -430,40 +430,37 @@ warn_deprecated(char key) static int edit_sect(struct sctstr *sect, char op, int arg, char *p) { - natid newown, oldown; coord newx, newy; int new, old; int des; switch (op) { case 'o': - if (arg < 0) + if (arg < 0 || arg >= MAXNOC) return RET_SYN; - newown = (natid)LIMIT_TO(arg, 0, MAXNOC - 1); pr("Owner of %s changed from %s to %s.\n", xyas(sect->sct_x, sect->sct_y, player->cnum), - prnatid(sect->sct_own), prnatid(newown)); + prnatid(sect->sct_own), prnatid(arg)); if (sect->sct_own) { wu(player->cnum, sect->sct_own, "Sector %s lost to deity intervention\n", xyas(sect->sct_x, sect->sct_y, sect->sct_own)); } benefit(sect->sct_own, 0); - sect->sct_own = newown; - if (newown) { - wu(player->cnum, newown, + sect->sct_own = arg; + if (arg) { + wu(player->cnum, arg, "Sector %s gained from deity intervention\n", - xyas(sect->sct_x, sect->sct_y, newown)); + xyas(sect->sct_x, sect->sct_y, arg)); } - benefit(newown, 1); + benefit(arg, 1); break; case 'O': - if (arg < 0) + if (arg < 0 || arg >= MAXNOC) return RET_SYN; - oldown = (natid)LIMIT_TO(arg, 0, MAXNOC - 1); pr("Old owner of %s changed from %s to %s.\n", xyas(sect->sct_x, sect->sct_y, player->cnum), - prnatid(sect->sct_oldown), prnatid(oldown)); - sect->sct_oldown = oldown; + prnatid(sect->sct_oldown), prnatid(arg)); + sect->sct_oldown = arg; break; case 'e': new = LIMIT_TO(arg, 0, 100); @@ -520,13 +517,13 @@ edit_sect(struct sctstr *sect, char op, int arg, char *p) sect->sct_che = new; break; case 'X': - old = sect->sct_che_target; - new = LIMIT_TO(arg, 0, MAXNOC - 1); + if (arg < 0 || arg >= MAXNOC) + return RET_SYN; pr("Che target of %s changed from %s to %s.\n", xyas(sect->sct_x, sect->sct_y, player->cnum), - prnatid(old), prnatid(new)); - sect->sct_che_target = new; - if (new == 0) + prnatid(sect->sct_che_target), prnatid(arg)); + sect->sct_che_target = arg; + if (arg == 0) sect->sct_che = 0; break; case 'p': @@ -739,14 +736,16 @@ edit_ship(struct shpstr *ship, char op, int arg, char *p) ef_set_uid(EF_SHIP, ship, arg); break; case 'O': + if (arg < 0 || arg >= MAXNOC) + return RET_SYN; if (ship->shp_own) wu(player->cnum, ship->shp_own, "%s taken from you by deity intervention!\n", prship(ship)); - if (arg && arg < MAXNOC) { + if (arg) { wu(player->cnum, (natid)arg, "%s given to you by deity intervention!\n", prship(ship)); ship->shp_own = (natid)arg; - } else if (!arg) + } else ship->shp_effic = 0; break; case 'L': @@ -835,15 +834,16 @@ edit_land(struct lndstr *land, char op, int arg, char *p) ef_set_uid(EF_LAND, land, arg); break; case 'O': + if (arg < 0 || arg >= MAXNOC) + return RET_SYN; if (land->lnd_own) wu(player->cnum, land->lnd_own, "%s taken from you by deity intervention!\n", prland(land)); - - if (arg && arg < MAXNOC) { + if (arg) { wu(player->cnum, (natid)arg, "%s given to you by deity intervention!\n", prland(land)); land->lnd_own = (natid)arg; - } else if (!arg) + } else land->lnd_effic = 0; break; case 'L': @@ -949,15 +949,17 @@ edit_plane(struct plnstr *plane, char op, int arg, char *p) plane->pln_y = newy; break; case 'O': + if (arg < 0 || arg >= MAXNOC) + return RET_SYN; if (plane->pln_own) wu(player->cnum, plane->pln_own, "%s taken from you by deity intervention!\n", prplane(plane)); - if (arg && arg < MAXNOC) { + if (arg) { plane->pln_own = (natid)arg; wu(player->cnum, plane->pln_own, "%s given to you by deity intervention!\n", prplane(plane)); - } else if (!arg) + } else plane->pln_effic = 0; break; case 'e': diff --git a/tests/actofgod/actofgod.xdump b/tests/actofgod/actofgod.xdump index 51cb9152..b01245ce 100644 --- a/tests/actofgod/actofgod.xdump +++ b/tests/actofgod/actofgod.xdump @@ -361,8 +361,7 @@ actor action victim times duration time 0 42 2 38 0 0 0 42 1 39 0 0 0 44 1 58 0 0 -0 43 98 2 0 0 -0 44 98 1 0 0 +0 43 98 1 0 0 0 43 2 1 0 0 0 43 1 54 0 0 1 45 0 3 0 0 diff --git a/tests/actofgod/journal.log b/tests/actofgod/journal.log index e33d7b84..29091e1a 100644 --- a/tests/actofgod/journal.log +++ b/tests/actofgod/journal.log @@ -51,7 +51,7 @@ Play#0 output Play#0 6 0 640 Play#0 input edit l 3,7 o 99 Play#0 command edit - Play#0 output Play#0 1 Owner of 3,7 changed from 98 (#98) to 98 (#98). + Play#0 output Play#0 1 Usage: edit [ ]... Play#0 output Play#0 6 0 640 Play#0 input edit l 1,7 O 0 Play#0 command edit @@ -67,7 +67,7 @@ Play#0 output Play#0 6 0 640 Play#0 input edit l 3,7 O 99 Play#0 command edit - Play#0 output Play#0 1 Old owner of 3,7 changed from 98 (#98) to 98 (#98). + Play#0 output Play#0 1 Usage: edit [ ]... Play#0 output Play#0 6 0 640 Play#0 input edit l 1,7 X 0 Play#0 command edit @@ -75,7 +75,7 @@ Play#0 output Play#0 6 0 640 Play#0 input edit l 1,7 X -1 Play#0 command edit - Play#0 output Play#0 1 Che target of 1,7 changed from POGO (#0) to POGO (#0). + Play#0 output Play#0 1 Usage: edit [ ]... Play#0 output Play#0 6 0 640 Play#0 input edit l 3,7 X 98 Play#0 command edit @@ -83,7 +83,7 @@ Play#0 output Play#0 6 0 640 Play#0 input edit l 3,7 X 99 Play#0 command edit - Play#0 output Play#0 1 Che target of 3,7 changed from 98 (#98) to 98 (#98). + Play#0 output Play#0 1 Usage: edit [ ]... Play#0 output Play#0 6 0 640 Play#0 input edit l 5,7 o 2 Play#0 command edit @@ -788,12 +788,14 @@ Play#0 output Play#0 6 0 640 Play#0 input edit s 0 O -1 Play#0 command edit + Play#0 output Play#0 1 Usage: edit [ ]... Play#0 output Play#0 6 0 640 Play#0 input edit s 1 O 98 Play#0 command edit Play#0 output Play#0 6 0 640 Play#0 input edit s 1 O 99 Play#0 command edit + Play#0 output Play#0 1 Usage: edit [ ]... Play#0 output Play#0 6 0 640 Play#0 input edit s 2 O 2 Play#0 command edit @@ -821,12 +823,14 @@ Play#0 output Play#0 6 0 640 Play#0 input edit p 0 O -1 Play#0 command edit + Play#0 output Play#0 1 Usage: edit [ ]... Play#0 output Play#0 6 0 640 Play#0 input edit p 1 O 98 Play#0 command edit Play#0 output Play#0 6 0 640 Play#0 input edit p 1 O 99 Play#0 command edit + Play#0 output Play#0 1 Usage: edit [ ]... Play#0 output Play#0 6 0 640 Play#0 input edit p 2 O 2 Play#0 command edit @@ -854,12 +858,14 @@ Play#0 output Play#0 6 0 640 Play#0 input edit u 0 O -1 Play#0 command edit + Play#0 output Play#0 1 Usage: edit [ ]... Play#0 output Play#0 6 0 640 Play#0 input edit u 1 O 98 Play#0 command edit Play#0 output Play#0 6 0 640 Play#0 input edit u 1 O 99 Play#0 command edit + Play#0 output Play#0 1 Usage: edit [ ]... Play#0 output Play#0 6 0 640 Play#0 input edit u 2 O 2 Play#0 command edit @@ -1577,15 +1583,10 @@ Play#0 output Play#0 1 Play#0 output Play#0 1 > BULLETIN from POGO, (#0) dated Thu Jan 1 00:00:00 1970 Play#0 output Play#0 1 Sector 3,7 gained from deity intervention - Play#0 output Play#0 1 Sector 3,7 lost to deity intervention - Play#0 output Play#0 1 Sector 3,7 gained from deity intervention Play#0 output Play#0 1 Sector 9,7 gained from deity intervention Play#0 output Play#0 1 cs cargo ship (#1) given to you by deity intervention! - Play#0 output Play#0 1 cs cargo ship (#1) taken from you by deity intervention! Play#0 output Play#0 1 f1 Sopwith Camel #1 given to you by deity intervention! - Play#0 output Play#0 1 f1 Sopwith Camel #1 taken from you by deity intervention! Play#0 output Play#0 1 sup supply #1 given to you by deity intervention! - Play#0 output Play#0 1 sup supply #1 taken from you by deity intervention! Play#0 output Play#0 6 0 640 Play#0 input ctld Play#0 output Play#0 1 Bye-bye