2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2000, Dave Pare, Jeff Bailey, Thomas Ruschak,
4 * Ken Stevens, Steve McClure
6 * This program 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 2 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, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * See the "LEGAL", "LICENSE", "CREDITS" and "README" files for all the
23 * related information and legal notices. It is expected that any future
24 * projects/authors will amend these files as needed.
28 * check.c: Check a sector, plane, land unit, ship or nuke
30 * Known contributors to this file:
47 #include "commodity.h"
53 /* Note that timestamps make things tricky. And, we don't
54 * really care about the timestamp, we just care about the rest
55 * of the structure. So, we make a copy, and zero the timestamps
56 * in both copies, and then compare. */
59 check_sect_ok(struct sctstr *sectp)
61 struct sctstr chksect;
64 getsect(sectp->sct_x, sectp->sct_y, &chksect);
65 memcpy(&tsect, sectp, sizeof(struct sctstr));
66 tsect.sct_timestamp = chksect.sct_timestamp = 0;
67 if (memcmp(&tsect, &chksect, sizeof(struct sctstr))) {
68 pr("Sector %s has changed!\n",
69 xyas(sectp->sct_x, sectp->sct_y, player->cnum));
76 check_ship_ok(struct shpstr *shipp)
78 struct shpstr chkship;
81 getship(shipp->shp_uid, &chkship);
82 memcpy(&tship, shipp, sizeof(struct shpstr));
83 tship.shp_timestamp = chkship.shp_timestamp = 0;
84 if (memcmp(&tship, &chkship, sizeof(struct shpstr))) {
85 pr("Ship #%d has changed!\n", shipp->shp_uid);
92 check_plane_ok(struct plnstr *planep)
94 struct plnstr chkplane;
97 getplane(planep->pln_uid, &chkplane);
98 memcpy(&tplane, planep, sizeof(struct plnstr));
99 tplane.pln_timestamp = chkplane.pln_timestamp = 0;
100 if (memcmp(&tplane, &chkplane, sizeof(struct plnstr))) {
101 pr("Plane #%d has changed!\n", planep->pln_uid);
108 check_land_ok(struct lndstr *landp)
110 struct lndstr chkland;
113 getland(landp->lnd_uid, &chkland);
114 memcpy(&tland, landp, sizeof(struct lndstr));
115 tland.lnd_timestamp = chkland.lnd_timestamp = 0;
116 if (memcmp(&tland, &chkland, sizeof(struct lndstr))) {
117 pr("Land unit #%d has changed!\n", landp->lnd_uid);
124 check_nuke_ok(struct nukstr *nukep)
126 struct nukstr chknuke;
129 getnuke(nukep->nuk_uid, &chknuke);
130 memcpy(&tnuke, nukep, sizeof(struct nukstr));
131 tnuke.nuk_timestamp = chknuke.nuk_timestamp = 0;
132 if (memcmp(&tnuke, &chknuke, sizeof(struct nukstr))) {
133 pr("Nuclear stockpile %d has changed!\n", nukep->nuk_uid);
140 check_loan_ok(struct lonstr *loanp)
142 struct lonstr chkloan;
144 getloan(loanp->l_uid, &chkloan);
145 if (memcmp(loanp, &chkloan, sizeof(struct lonstr))) {
146 pr("Loan %d has changed!\n", loanp->l_uid);
153 check_comm_ok(struct comstr *commp)
155 struct comstr chkcomm;
157 getcomm(commp->com_uid, &chkcomm);
158 if (memcmp(commp, &chkcomm, sizeof(struct comstr))) {
159 pr("Commodity %d has changed!\n", commp->com_uid);