Wipe orders when ship, plane, land unit or nuke changes owner
Use new unit_wipe_orders() for violent takeover (takeover_unit() on behalf of assault, attack, board, lboard, paradrop and pboard), and peaceful takeover (unit_give_away() on behalf of arm, disarm, load, unload, lload, lunload, scrap, scuttle, tend, trade). Before, takeover_unit() cleared only group, mission and ship retreat orders, and unit_give_away() only group and mission. Orders that weren't cleared: * Mission op area (visible in xdump) * Ship autonav orders * Ship sail path including ship to follow and mobility quota * Plane range limit * Land unit retreat orders and retreat percentage
This commit is contained in:
parent
5f6e27ff80
commit
e7ce50405e
4 changed files with 57 additions and 8 deletions
|
@ -59,3 +59,4 @@ extern void unit_view(struct emp_qelem *);
|
|||
extern void unit_update_cargo(struct empobj *);
|
||||
extern void unit_drop_cargo(struct empobj *, natid);
|
||||
extern void unit_give_away(struct empobj *, natid, natid);
|
||||
extern void unit_wipe_orders(struct empobj *);
|
||||
|
|
|
@ -372,8 +372,6 @@ check_trade(void)
|
|||
tg.plane.pln_land = -1;
|
||||
break;
|
||||
case EF_SHIP:
|
||||
tg.ship.shp_rflags = 0;
|
||||
memset(tg.ship.shp_rpath, 0, sizeof(tg.ship.shp_rpath));
|
||||
break;
|
||||
case EF_LAND:
|
||||
tg.land.lnd_x = trade.trd_x;
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
#include "prototypes.h"
|
||||
#include "sect.h"
|
||||
#include "ship.h"
|
||||
#include "unit.h"
|
||||
#include "xy.h"
|
||||
|
||||
static void takeover_unit(struct empobj *, natid);
|
||||
|
@ -231,14 +232,11 @@ takeover_unit(struct empobj *unit, natid newown)
|
|||
unit->own = newown;
|
||||
if (opt_MARKET)
|
||||
trdswitchown(unit->ef_type, unit, newown);
|
||||
unit->group = 0;
|
||||
unit->mission = 0;
|
||||
unit_wipe_orders(unit);
|
||||
|
||||
switch (unit->ef_type) {
|
||||
case EF_SHIP:
|
||||
sp = (struct shpstr *)unit;
|
||||
sp->shp_rflags = 0;
|
||||
memset(sp->shp_rpath, 0, sizeof(sp->shp_rpath));
|
||||
break;
|
||||
case EF_PLANE:
|
||||
pp = (struct plnstr *)unit;
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
#include "empobj.h"
|
||||
#include "file.h"
|
||||
#include "player.h"
|
||||
#include "optlist.h"
|
||||
#include "prototypes.h"
|
||||
#include "unit.h"
|
||||
|
||||
|
@ -299,8 +300,7 @@ unit_give_away(struct empobj *unit, natid recipient, natid giver)
|
|||
}
|
||||
|
||||
unit->own = recipient;
|
||||
unit->mission = 0;
|
||||
unit->group = 0;
|
||||
unit_wipe_orders(unit);
|
||||
|
||||
for (type = EF_PLANE; type <= EF_NUKE; type++) {
|
||||
snxtitem_cargo(&ni, type, unit->ef_type, unit->uid);
|
||||
|
@ -310,3 +310,55 @@ unit_give_away(struct empobj *unit, natid recipient, natid giver)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Wipe orders and such from UNIT.
|
||||
*/
|
||||
void
|
||||
unit_wipe_orders(struct empobj *unit)
|
||||
{
|
||||
struct shpstr *sp;
|
||||
struct plnstr *pp;
|
||||
struct lndstr *lp;
|
||||
int i;
|
||||
|
||||
unit->group = 0;
|
||||
unit->opx = unit->opy = 0;
|
||||
unit->mission = 0;
|
||||
unit->radius = 0;
|
||||
|
||||
switch (unit->ef_type) {
|
||||
case EF_SHIP:
|
||||
sp = (struct shpstr *)unit;
|
||||
sp->shp_destx[0] = sp->shp_desty[0] = 0;
|
||||
sp->shp_destx[1] = sp->shp_desty[1] = 0;
|
||||
for (i = 0; i < TMAX; ++i) {
|
||||
sp->shp_tstart[i] = I_NONE;
|
||||
sp->shp_tend[i] = I_NONE;
|
||||
sp->shp_lstart[i] = 0;
|
||||
sp->shp_lend[i] = 0;
|
||||
}
|
||||
sp->shp_autonav = 0;
|
||||
sp->shp_mobquota = 0;
|
||||
sp->shp_path[0] = 0;
|
||||
sp->shp_follow = sp->shp_uid;
|
||||
sp->shp_rflags = 0;
|
||||
sp->shp_rpath[0] = 0;
|
||||
break;
|
||||
case EF_PLANE:
|
||||
pp = (struct plnstr *)unit;
|
||||
pp->pln_range = pln_range_max(pp);
|
||||
break;
|
||||
case EF_LAND:
|
||||
lp = (struct lndstr *)unit;
|
||||
lp->lnd_retreat = morale_base;
|
||||
lp->lnd_rflags = 0;
|
||||
lp->lnd_rpath[0] = 0;
|
||||
lp->lnd_rad_max = 0;
|
||||
break;
|
||||
case EF_NUKE:
|
||||
break;
|
||||
default:
|
||||
CANT_REACH();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue