(tran_plane): Fix major, abusable bug: getsect() before move_ground(),
putsect() afterwards. This allowed two cooperating countries to duplicate items. (tran_plane): Don't report interdiction damage twice. (tran_plane): Simplify loop collecting planes.
This commit is contained in:
parent
d4fe345edb
commit
5bd904f825
1 changed files with 5 additions and 17 deletions
|
@ -101,15 +101,7 @@ tran_nuke(void)
|
||||||
pr("Not yours\n");
|
pr("Not yours\n");
|
||||||
return RET_FAIL;
|
return RET_FAIL;
|
||||||
}
|
}
|
||||||
#if 0
|
|
||||||
if (!snxtitem_xy(&nstr, EF_NUKE, sect.sct_x, sect.sct_y)) {
|
|
||||||
pr("There are no nukes in %s\n",
|
|
||||||
xyas(sect.sct_x, sect.sct_y, player->cnum));
|
|
||||||
return RET_FAIL;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
snxtitem_xy(&nstr, EF_NUKE, sect.sct_x, sect.sct_y);
|
snxtitem_xy(&nstr, EF_NUKE, sect.sct_x, sect.sct_y);
|
||||||
#endif
|
|
||||||
found = 0;
|
found = 0;
|
||||||
while (nxtitem(&nstr, &nuke)) {
|
while (nxtitem(&nstr, &nuke)) {
|
||||||
if (player->owner) {
|
if (player->owner) {
|
||||||
|
@ -203,14 +195,12 @@ tran_plane(void)
|
||||||
int dstx, dsty;
|
int dstx, dsty;
|
||||||
int mcost;
|
int mcost;
|
||||||
int weight, count;
|
int weight, count;
|
||||||
int first;
|
|
||||||
int type, dam;
|
int type, dam;
|
||||||
struct nstr_item nstr;
|
struct nstr_item nstr;
|
||||||
struct plnstr plane;
|
struct plnstr plane;
|
||||||
struct sctstr sect;
|
struct sctstr sect;
|
||||||
struct sctstr endsect;
|
struct sctstr endsect;
|
||||||
|
|
||||||
first = 1;
|
|
||||||
weight = 0;
|
weight = 0;
|
||||||
count = 0;
|
count = 0;
|
||||||
if (!snxtitem(&nstr, EF_PLANE, player->argp[2]))
|
if (!snxtitem(&nstr, EF_PLANE, player->argp[2]))
|
||||||
|
@ -238,10 +228,9 @@ tran_plane(void)
|
||||||
prplane(&plane));
|
prplane(&plane));
|
||||||
return RET_FAIL;
|
return RET_FAIL;
|
||||||
}
|
}
|
||||||
if (first == 1) {
|
if (count == 0) {
|
||||||
srcx = plane.pln_x;
|
srcx = plane.pln_x;
|
||||||
srcy = plane.pln_y;
|
srcy = plane.pln_y;
|
||||||
first = 0;
|
|
||||||
} else {
|
} else {
|
||||||
if (plane.pln_x != srcx || plane.pln_y != srcy) {
|
if (plane.pln_x != srcx || plane.pln_y != srcy) {
|
||||||
pr("All planes must be in the same sector.\n");
|
pr("All planes must be in the same sector.\n");
|
||||||
|
@ -251,8 +240,8 @@ tran_plane(void)
|
||||||
weight += plchr[type].pl_lcm + (plchr[type].pl_hcm * 2);
|
weight += plchr[type].pl_lcm + (plchr[type].pl_hcm * 2);
|
||||||
++count;
|
++count;
|
||||||
}
|
}
|
||||||
if (first == 1) {
|
if (count == 0) {
|
||||||
/* no planes */
|
pr("No planes\n");
|
||||||
return RET_FAIL;
|
return RET_FAIL;
|
||||||
}
|
}
|
||||||
if (!getsect(srcx, srcy, §) || !player->owner) {
|
if (!getsect(srcx, srcy, §) || !player->owner) {
|
||||||
|
@ -277,10 +266,8 @@ tran_plane(void)
|
||||||
while (nxtitem(&nstr, (s_char *)&plane)) {
|
while (nxtitem(&nstr, (s_char *)&plane)) {
|
||||||
if (!player->owner)
|
if (!player->owner)
|
||||||
continue;
|
continue;
|
||||||
if (dam) {
|
if (dam)
|
||||||
planedamage(&plane, dam);
|
planedamage(&plane, dam);
|
||||||
pr("\t%s takes %d\n", prplane(&plane), dam);
|
|
||||||
}
|
|
||||||
plane.pln_x = dstx;
|
plane.pln_x = dstx;
|
||||||
plane.pln_y = dsty;
|
plane.pln_y = dsty;
|
||||||
plane.pln_mission = 0;
|
plane.pln_mission = 0;
|
||||||
|
@ -290,6 +277,7 @@ tran_plane(void)
|
||||||
pr("Total movement cost = %d\n", mcost);
|
pr("Total movement cost = %d\n", mcost);
|
||||||
else
|
else
|
||||||
pr("No mobility used\n");
|
pr("No mobility used\n");
|
||||||
|
getsect(srcx, srcy, §);
|
||||||
sect.sct_mobil -= mcost;
|
sect.sct_mobil -= mcost;
|
||||||
if (sect.sct_mobil < 0)
|
if (sect.sct_mobil < 0)
|
||||||
sect.sct_mobil = 0;
|
sect.sct_mobil = 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue