From 324e52fa9db9f269dc1a70f4844ba56d8b2b8457 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Sat, 13 May 2006 13:41:02 +0000 Subject: [PATCH] (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). --- src/lib/subs/nuke.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/lib/subs/nuke.c b/src/lib/subs/nuke.c index fd460d17..18cf0485 100644 --- a/src/lib/subs/nuke.c +++ b/src/lib/subs/nuke.c @@ -48,12 +48,25 @@ int nuk_postread(int n, void *ptr) { struct nukstr *np = ptr; + struct plnstr plane; if (np->nuk_uid != n) { logerror("nuk_postread: Error - %d != %d, zeroing.\n", np->nuk_uid, n); 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); return 1; } @@ -64,6 +77,14 @@ nuk_prewrite(int n, void *ptr) struct nukstr *np = ptr; 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->nuk_uid = n;