Fix cargo giveaway in load, lload, unload, lunload and tend
Use unit_give_away() in gift(). This fixes a number of bugs: * Nukes on planes weren't given away along with the plane. * Likewise for land units on land units (can't happen in the stock game). * Mission was not cleared by unload land/plane, lunload land/plane, and lload plane, except for planes on land units. * Wing and army were never cleared. It also happens to suppress information on planes given away along with their land unit carriers. Shrug.
This commit is contained in:
parent
d2b1bef0f5
commit
8cf32c4854
2 changed files with 5 additions and 78 deletions
|
@ -44,6 +44,7 @@
|
||||||
#include "plague.h"
|
#include "plague.h"
|
||||||
#include "plane.h"
|
#include "plane.h"
|
||||||
#include "ship.h"
|
#include "ship.h"
|
||||||
|
#include "unit.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The values 1 and -1 are important below, don't change them.
|
* The values 1 and -1 are important below, don't change them.
|
||||||
|
@ -312,11 +313,9 @@ lload(void)
|
||||||
void
|
void
|
||||||
gift(natid givee, natid giver, void *ptr, char *mesg)
|
gift(natid givee, natid giver, void *ptr, char *mesg)
|
||||||
{
|
{
|
||||||
struct empobj *gen = ptr;
|
|
||||||
|
|
||||||
if (giver != givee)
|
if (giver != givee)
|
||||||
wu(0, givee, "%s %s %s\n", cname(giver), obj_nameof(gen), mesg);
|
wu(0, givee, "%s %s %s\n", cname(giver), obj_nameof(ptr), mesg);
|
||||||
gen->own = givee;
|
unit_give_away(ptr, givee, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -441,7 +440,6 @@ load_plane_ship(struct sctstr *sectp, struct shpstr *sp, int noisy,
|
||||||
sprintf(buf, "loaded on your %s at %s",
|
sprintf(buf, "loaded on your %s at %s",
|
||||||
prship(sp), xyas(sp->shp_x, sp->shp_y, sp->shp_own));
|
prship(sp), xyas(sp->shp_x, sp->shp_y, sp->shp_own));
|
||||||
gift(sp->shp_own, player->cnum, &pln, buf);
|
gift(sp->shp_own, player->cnum, &pln, buf);
|
||||||
pln.pln_mission = 0;
|
|
||||||
putplane(pln.pln_uid, &pln);
|
putplane(pln.pln_uid, &pln);
|
||||||
} else {
|
} else {
|
||||||
pln.pln_ship = -1;
|
pln.pln_ship = -1;
|
||||||
|
@ -466,9 +464,8 @@ static int
|
||||||
load_land_ship(struct sctstr *sectp, struct shpstr *sp, int noisy,
|
load_land_ship(struct sctstr *sectp, struct shpstr *sp, int noisy,
|
||||||
int load_unload, int *nshipsp)
|
int load_unload, int *nshipsp)
|
||||||
{
|
{
|
||||||
struct nstr_item pni, ni;
|
struct nstr_item ni;
|
||||||
struct lndstr land;
|
struct lndstr land;
|
||||||
struct plnstr plane;
|
|
||||||
int loaded = 0;
|
int loaded = 0;
|
||||||
char *p;
|
char *p;
|
||||||
char prompt[512];
|
char prompt[512];
|
||||||
|
@ -596,22 +593,10 @@ load_land_ship(struct sctstr *sectp, struct shpstr *sp, int noisy,
|
||||||
gift(sp->shp_own, player->cnum, &land, buf);
|
gift(sp->shp_own, player->cnum, &land, buf);
|
||||||
land.lnd_ship = sp->shp_uid;
|
land.lnd_ship = sp->shp_uid;
|
||||||
land.lnd_harden = 0;
|
land.lnd_harden = 0;
|
||||||
land.lnd_mission = 0;
|
|
||||||
resupply_all(&land);
|
resupply_all(&land);
|
||||||
putland(land.lnd_uid, &land);
|
putland(land.lnd_uid, &land);
|
||||||
if (!has_supply(&land))
|
if (!has_supply(&land))
|
||||||
pr("WARNING: %s is out of supply!\n", prland(&land));
|
pr("WARNING: %s is out of supply!\n", prland(&land));
|
||||||
snxtitem_xy(&pni, EF_PLANE, land.lnd_x, land.lnd_y);
|
|
||||||
while (nxtitem(&pni, &plane)) {
|
|
||||||
if (plane.pln_flags & PLN_LAUNCHED)
|
|
||||||
continue;
|
|
||||||
if (plane.pln_land != land.lnd_uid)
|
|
||||||
continue;
|
|
||||||
sprintf(buf, "loaded on %s", prship(sp));
|
|
||||||
gift(sp->shp_own, player->cnum, &plane, buf);
|
|
||||||
plane.pln_mission = 0;
|
|
||||||
putplane(plane.pln_uid, &plane);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
sprintf(buf, "unloaded in your %s at %s",
|
sprintf(buf, "unloaded in your %s at %s",
|
||||||
dchr[sectp->sct_type].d_name,
|
dchr[sectp->sct_type].d_name,
|
||||||
|
@ -622,25 +607,6 @@ load_land_ship(struct sctstr *sectp, struct shpstr *sp, int noisy,
|
||||||
gift(sectp->sct_own, player->cnum, &land, buf);
|
gift(sectp->sct_own, player->cnum, &land, buf);
|
||||||
land.lnd_ship = -1;
|
land.lnd_ship = -1;
|
||||||
putland(land.lnd_uid, &land);
|
putland(land.lnd_uid, &land);
|
||||||
|
|
||||||
/* Spies are unloaded quietly, others aren't, and
|
|
||||||
in the off chance they can carry a plane (missile?)
|
|
||||||
they are quietly unloaded too. */
|
|
||||||
if (!(lchr[(int)land.lnd_type].l_flags & L_SPY)) {
|
|
||||||
snxtitem_xy(&pni, EF_PLANE, land.lnd_x, land.lnd_y);
|
|
||||||
while (nxtitem(&pni, &plane)) {
|
|
||||||
if (plane.pln_flags & PLN_LAUNCHED)
|
|
||||||
continue;
|
|
||||||
if (plane.pln_land != land.lnd_uid)
|
|
||||||
continue;
|
|
||||||
sprintf(buf, "unloaded at %s",
|
|
||||||
xyas(plane.pln_x, plane.pln_y,
|
|
||||||
sectp->sct_own));
|
|
||||||
gift(sectp->sct_own, player->cnum, &plane, buf);
|
|
||||||
plane.pln_mission = 0;
|
|
||||||
putplane(plane.pln_uid, &plane);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
pr("%s %s %s at %s.\n",
|
pr("%s %s %s at %s.\n",
|
||||||
prland(&land),
|
prland(&land),
|
||||||
|
@ -926,9 +892,8 @@ static int
|
||||||
load_land_land(struct sctstr *sectp, struct lndstr *lp, int noisy,
|
load_land_land(struct sctstr *sectp, struct lndstr *lp, int noisy,
|
||||||
int load_unload, int *nunitsp)
|
int load_unload, int *nunitsp)
|
||||||
{
|
{
|
||||||
struct nstr_item pni, ni;
|
struct nstr_item ni;
|
||||||
struct lndstr land;
|
struct lndstr land;
|
||||||
struct plnstr plane;
|
|
||||||
int loaded = 0;
|
int loaded = 0;
|
||||||
char *p;
|
char *p;
|
||||||
char prompt[512];
|
char prompt[512];
|
||||||
|
@ -1022,22 +987,10 @@ load_land_land(struct sctstr *sectp, struct lndstr *lp, int noisy,
|
||||||
gift(lp->lnd_own, player->cnum, &land, buf);
|
gift(lp->lnd_own, player->cnum, &land, buf);
|
||||||
land.lnd_land = lp->lnd_uid;
|
land.lnd_land = lp->lnd_uid;
|
||||||
land.lnd_harden = 0;
|
land.lnd_harden = 0;
|
||||||
land.lnd_mission = 0;
|
|
||||||
resupply_all(&land);
|
resupply_all(&land);
|
||||||
putland(land.lnd_uid, &land);
|
putland(land.lnd_uid, &land);
|
||||||
if (!has_supply(&land))
|
if (!has_supply(&land))
|
||||||
pr("WARNING: %s is out of supply!\n", prland(&land));
|
pr("WARNING: %s is out of supply!\n", prland(&land));
|
||||||
snxtitem_xy(&pni, EF_PLANE, land.lnd_x, land.lnd_y);
|
|
||||||
while (nxtitem(&pni, &plane)) {
|
|
||||||
if (plane.pln_flags & PLN_LAUNCHED)
|
|
||||||
continue;
|
|
||||||
if (plane.pln_land != land.lnd_uid)
|
|
||||||
continue;
|
|
||||||
sprintf(buf, "loaded on %s", prland(lp));
|
|
||||||
gift(lp->lnd_own, player->cnum, &plane, buf);
|
|
||||||
plane.pln_mission = 0;
|
|
||||||
putplane(plane.pln_uid, &plane);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
sprintf(buf, "unloaded in your %s at %s",
|
sprintf(buf, "unloaded in your %s at %s",
|
||||||
dchr[sectp->sct_type].d_name,
|
dchr[sectp->sct_type].d_name,
|
||||||
|
@ -1045,18 +998,6 @@ load_land_land(struct sctstr *sectp, struct lndstr *lp, int noisy,
|
||||||
gift(sectp->sct_own, player->cnum, &land, buf);
|
gift(sectp->sct_own, player->cnum, &land, buf);
|
||||||
land.lnd_land = -1;
|
land.lnd_land = -1;
|
||||||
putland(land.lnd_uid, &land);
|
putland(land.lnd_uid, &land);
|
||||||
snxtitem_xy(&pni, EF_PLANE, land.lnd_x, land.lnd_y);
|
|
||||||
while (nxtitem(&pni, &plane)) {
|
|
||||||
if (plane.pln_flags & PLN_LAUNCHED)
|
|
||||||
continue;
|
|
||||||
if (plane.pln_land != land.lnd_uid)
|
|
||||||
continue;
|
|
||||||
sprintf(buf, "unloaded at %s",
|
|
||||||
xyas(plane.pln_x, plane.pln_y, sectp->sct_own));
|
|
||||||
gift(sectp->sct_own, player->cnum, &plane, buf);
|
|
||||||
plane.pln_mission = 0;
|
|
||||||
putplane(plane.pln_uid, &plane);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
pr("%s %s %s at %s.\n",
|
pr("%s %s %s at %s.\n",
|
||||||
prland(&land),
|
prland(&land),
|
||||||
|
|
|
@ -207,8 +207,6 @@ tend_land(struct shpstr *tenderp, char *units)
|
||||||
struct nstr_item targets;
|
struct nstr_item targets;
|
||||||
struct shpstr target;
|
struct shpstr target;
|
||||||
struct lndstr land;
|
struct lndstr land;
|
||||||
struct plnstr plane;
|
|
||||||
struct nstr_item pni;
|
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
|
|
||||||
if (!snxtitem(&lni, EF_LAND, units, NULL))
|
if (!snxtitem(&lni, EF_LAND, units, NULL))
|
||||||
|
@ -277,22 +275,10 @@ tend_land(struct shpstr *tenderp, char *units)
|
||||||
gift(target.shp_own, player->cnum, &land, buf);
|
gift(target.shp_own, player->cnum, &land, buf);
|
||||||
land.lnd_ship = target.shp_uid;
|
land.lnd_ship = target.shp_uid;
|
||||||
land.lnd_harden = 0;
|
land.lnd_harden = 0;
|
||||||
land.lnd_mission = 0;
|
|
||||||
putland(land.lnd_uid, &land);
|
putland(land.lnd_uid, &land);
|
||||||
expose_ship(tenderp, &target);
|
expose_ship(tenderp, &target);
|
||||||
putship(target.shp_uid, &target);
|
putship(target.shp_uid, &target);
|
||||||
putship(tenderp->shp_uid, tenderp);
|
putship(tenderp->shp_uid, tenderp);
|
||||||
snxtitem_xy(&pni, EF_PLANE, land.lnd_x, land.lnd_y);
|
|
||||||
while (nxtitem(&pni, &plane)) {
|
|
||||||
if (plane.pln_flags & PLN_LAUNCHED)
|
|
||||||
continue;
|
|
||||||
if (plane.pln_land != land.lnd_uid)
|
|
||||||
continue;
|
|
||||||
sprintf(buf, "loaded on %s", prship(&target));
|
|
||||||
gift(target.shp_own, player->cnum, &plane, buf);
|
|
||||||
plane.pln_mission = 0;
|
|
||||||
putplane(plane.pln_uid, &plane);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue