From af32304af042eb5a44d20fe30d81cb8f46638ee8 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Tue, 4 Oct 2005 07:20:37 +0000 Subject: [PATCH] (get_assembly_point): Close loophole that allowed players to find all unowned sectors. The assembly point must now be owned or allied, or have an owned or allied ship. Info pages didn't match the old rule. Fix them to match the new rule. --- info/Commands/bomb.t | 3 ++- info/Commands/drop.t | 3 ++- info/Commands/fly.t | 3 ++- info/Commands/paradrop.t | 3 ++- info/Commands/recon.t | 3 ++- info/Commands/sweep.t | 3 ++- src/lib/subs/plnsub.c | 24 +++++++++++++++++++----- 7 files changed, 31 insertions(+), 11 deletions(-) diff --git a/info/Commands/bomb.t b/info/Commands/bomb.t index 1f93461c..fe14ca1e 100644 --- a/info/Commands/bomb.t +++ b/info/Commands/bomb.t @@ -31,7 +31,8 @@ Only missiles in hardened silos can avoid damage from a nuclear mission. .s1 represents an assembly point, where all of the planes in the mission meet before proceeding on to the target sector. -The assembly point must be owned by you, and must not be more than +The assembly point must be owned by you or an ally, or you or an ally +must have a ship there. It must not be more than four sectors away from any of the planes selected for the mission. .s1 Route is a normal empire path specification. You may also give a diff --git a/info/Commands/drop.t b/info/Commands/drop.t index 56837b52..d3db42df 100644 --- a/info/Commands/drop.t +++ b/info/Commands/drop.t @@ -17,7 +17,8 @@ To be selected, escorts must have fuel and mobility. .s1 represents an assembly point, where all of the planes in the mission meet before proceeding on to the target sector. -The assembly point must be owned by you, and must not be more than +The assembly point must be owned by you or an ally, or you or an ally +must have a ship there. It must not be more than four sectors away from any of the planes selected for the mission. .s1 is the name of a commodity which is to be carried along diff --git a/info/Commands/fly.t b/info/Commands/fly.t index a9db8527..09339679 100644 --- a/info/Commands/fly.t +++ b/info/Commands/fly.t @@ -16,7 +16,8 @@ To be selected, escorts must have fuel and mobility. .s1 represents an assembly point, where all of the planes in the mission meet before proceeding on to the target sector. -The assembly point must be owned by you, and must not be more than +The assembly point must be owned by you or an ally, or you or an ally +must have a ship there. It must not be more than four sectors away from any of the planes selected for the mission. .s1 is the name of a commodity which is to be carried along diff --git a/info/Commands/paradrop.t b/info/Commands/paradrop.t index 0987aa57..ba6e9dbf 100644 --- a/info/Commands/paradrop.t +++ b/info/Commands/paradrop.t @@ -19,7 +19,8 @@ To be selected, escorts must have fuel and mobility. .s1 represents an assembly point, where all of the planes in the mission meet before proceeding on to the target sector. -The assembly point must be owned by you, and must not be more than +The assembly point must be owned by you or an ally, or you or an ally +must have a ship there. It must not be more than four sectors away from any of the planes selected for the mission. .s1 Route is a normal empire path specification. You may also give a diff --git a/info/Commands/recon.t b/info/Commands/recon.t index 95029df3..2164ad39 100644 --- a/info/Commands/recon.t +++ b/info/Commands/recon.t @@ -18,7 +18,8 @@ To be selected, escorts must have fuel and mobility. .s1 represents an assembly point, where all of the planes in the mission meet before proceeding on to the target sector. -The assembly point must be owned by you, and must not be more than +The assembly point must be owned by you or an ally, or you or an ally +must have a ship there. It must not be more than four sectors away from any of the planes selected for the mission. .s1 Route is a normal empire path specification. You may also give a diff --git a/info/Commands/sweep.t b/info/Commands/sweep.t index 3da46222..e8e022fe 100644 --- a/info/Commands/sweep.t +++ b/info/Commands/sweep.t @@ -17,7 +17,8 @@ To be selected, escorts must have fuel and mobility. .s1 represents an assembly point, where all of the planes in the mission meet before proceeding on to the target sector. -The assembly point must be owned by you, and must not be more than +The assembly point must be owned by you or an ally, or you or an ally +must have a ship there. It must not be more than four sectors away from any of the planes selected for the mission. .s1 Route is a normal empire path specification. You may also give a diff --git a/src/lib/subs/plnsub.c b/src/lib/subs/plnsub.c index 7371f184..6d7006b2 100644 --- a/src/lib/subs/plnsub.c +++ b/src/lib/subs/plnsub.c @@ -64,18 +64,32 @@ get_assembly_point(char *input, struct sctstr *ap_sect, char *buf) { char *p; coord x, y; + struct nstr_item ni; + struct shpstr ship; p = getstarg(input, "assembly point? ", buf); if (!p || *p == 0) return NULL; if (!sarg_xy(p, &x, &y) || !getsect(x, y, ap_sect)) return NULL; - if (ap_sect->sct_own && ap_sect->sct_own != player->cnum && - getrel(getnatp(ap_sect->sct_own), player->cnum) != ALLIED) { - pr("Assembly point not owned by you or an ally!\n"); - return NULL; + + /* over own or allied sector is fine */ + if (ap_sect->sct_own == player->cnum + || getrel(getnatp(ap_sect->sct_own), player->cnum) == ALLIED) + return ap_sect; + + /* over own or allied ship is fine */ + snxtitem_xy(&ni, EF_SHIP, x, y); + while (nxtitem(&ni, &ship)) { + if (ship.shp_effic < SHIP_MINEFF || ship.shp_own == 0) + continue; + if (ship.shp_own == player->cnum + || getrel(getnatp(ship.shp_own), player->cnum) == ALLIED) + return ap_sect; } - return ap_sect; + + pr("Assembly point not owned by you or an ally!\n"); + return NULL; } int