2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2011, 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
42 #include "prototypes.h"
45 nuk_postread(int n, void *ptr)
47 struct nukstr *np = ptr;
49 if (np->nuk_uid != n) {
50 logerror("nuk_postread: Error - %d != %d, zeroing.\n",
52 memset(np, 0, sizeof(struct nukstr));
54 player->owner = (player->god || np->nuk_own == player->cnum);
58 nuk_prewrite(int n, void *old, void *new)
60 struct nukstr *oldnp = old;
61 struct nukstr *np = new;
62 natid own = np->nuk_effic == 0 ? 0 : np->nuk_own;
63 int plane = np->nuk_plane;
65 /* Be careful with writing to *np, in case oldnp == np */
72 if (oldnp->nuk_plane != plane)
73 nuk_carrier_change(np, EF_PLANE, oldnp->nuk_plane, plane);
75 if (oldnp->nuk_own != own)
76 lost_and_found(EF_NUKE, oldnp->nuk_own, own,
77 np->nuk_uid, np->nuk_x, np->nuk_y);
80 np->nuk_plane = plane;
84 prnuke(struct nukstr *np)
86 return prbuf("%s warhead #%d",
87 nchr[(int)np->nuk_type].n_name, np->nuk_uid);