2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2020, Dave Pare, Jeff Bailey, Thomas Ruschak,
4 * Ken Stevens, Steve McClure, Markus Armbruster
6 * Empire is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 * See files README, COPYING and CREDITS in the root of the source
22 * tree for related information and legal notices. It is expected
23 * that future projects/authors will amend these files as needed.
27 * nuke.c: Nuke post-read and pre-write data massage
29 * Known contributors to this file:
32 * Markus Armbruster, 2006-2011
41 #include "prototypes.h"
44 nuk_postread(int n, void *ptr)
46 struct nukstr *np = ptr;
48 if (np->nuk_uid != n) {
49 logerror("nuk_postread: Error - %d != %d, zeroing.\n",
51 memset(np, 0, sizeof(struct nukstr));
53 player->owner = (player->god || np->nuk_own == player->cnum);
57 nuk_prewrite(int n, void *old, void *new)
59 struct nukstr *oldnp = old;
60 struct nukstr *np = new;
61 natid own = np->nuk_effic == 0 ? 0 : np->nuk_own;
62 int plane = np->nuk_plane;
64 /* Be careful with writing to *np, in case oldnp == np */
71 if (oldnp->nuk_plane != plane)
72 nuk_carrier_change(np, EF_PLANE, oldnp->nuk_plane, plane);
74 if (oldnp->nuk_own != own)
75 lost_and_found(EF_NUKE, oldnp->nuk_own, own,
76 np->nuk_uid, np->nuk_x, np->nuk_y);
79 np->nuk_plane = plane;
83 prnuke(struct nukstr *np)
85 return prbuf("%s warhead #%d",
86 nchr[(int)np->nuk_type].n_name, np->nuk_uid);