(nuk_postread): Update nuke location to match that of the plane

carrying it.  This is required since arming doesn't remove nukes from
the nuke file anymore (arm.c rev. 1.15).

(nuk_prewrite): Properly destroy nuke.  This is required since nuke
file contains individual nukes instead of stockpiles (nuke.h
rev. 1.19).
This commit is contained in:
Markus Armbruster 2006-05-13 13:41:02 +00:00
parent f70b64d91b
commit 324e52fa9d

View file

@ -48,12 +48,25 @@ int
nuk_postread(int n, void *ptr) nuk_postread(int n, void *ptr)
{ {
struct nukstr *np = ptr; struct nukstr *np = ptr;
struct plnstr plane;
if (np->nuk_uid != n) { if (np->nuk_uid != n) {
logerror("nuk_postread: Error - %d != %d, zeroing.\n", np->nuk_uid, logerror("nuk_postread: Error - %d != %d, zeroing.\n", np->nuk_uid,
n); n);
memset(np, 0, sizeof(struct nukstr)); memset(np, 0, sizeof(struct nukstr));
} }
if (np->nuk_plane >= 0 && np->nuk_own && np->nuk_effic >= 0) {
if (getplane(np->nuk_plane, &plane)
&& plane.pln_effic >= PLANE_MINEFF) {
if (np->nuk_x != plane.pln_x || np->nuk_y != plane.pln_y) {
time(&np->nuk_timestamp);
np->nuk_x = plane.pln_x;
np->nuk_y = plane.pln_y;
}
}
}
player->owner = (player->god || np->nuk_own == player->cnum); player->owner = (player->god || np->nuk_own == player->cnum);
return 1; return 1;
} }
@ -64,6 +77,14 @@ nuk_prewrite(int n, void *ptr)
struct nukstr *np = ptr; struct nukstr *np = ptr;
struct nukstr nuke; struct nukstr nuke;
if (np->nuk_effic == 0) {
if (np->nuk_own)
makelost(EF_NUKE, np->nuk_own, np->nuk_uid,
np->nuk_x, np->nuk_y);
np->nuk_own = 0;
np->nuk_effic = 0;
}
np->ef_type = EF_NUKE; np->ef_type = EF_NUKE;
np->nuk_uid = n; np->nuk_uid = n;