2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2008, 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 files README, COPYING and CREDITS in the root of the source
23 * tree for related information and legal notices. It is expected
24 * that future 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:
36 #include "commodity.h"
46 #include "prototypes.h"
52 /* Note that timestamps make things tricky. And, we don't
53 * really care about the timestamp, we just care about the rest
54 * of the structure. So, we make a copy, and zero the timestamps
55 * in both copies, and then compare. */
58 check_sect_ok(struct sctstr *sectp)
60 struct sctstr chksect;
63 getsect(sectp->sct_x, sectp->sct_y, &chksect);
64 memcpy(&tsect, sectp, sizeof(struct sctstr));
65 tsect.sct_timestamp = chksect.sct_timestamp = 0;
66 if (memcmp(&tsect, &chksect, sizeof(struct sctstr))) {
67 pr("Sector %s has changed!\n",
68 xyas(sectp->sct_x, sectp->sct_y, player->cnum));
75 check_ship_ok(struct shpstr *shipp)
77 struct shpstr chkship;
80 getship(shipp->shp_uid, &chkship);
81 memcpy(&tship, shipp, sizeof(struct shpstr));
82 tship.shp_timestamp = chkship.shp_timestamp = 0;
83 if (memcmp(&tship, &chkship, sizeof(struct shpstr))) {
84 pr("Ship #%d has changed!\n", shipp->shp_uid);
91 check_plane_ok(struct plnstr *planep)
93 struct plnstr chkplane;
96 getplane(planep->pln_uid, &chkplane);
97 memcpy(&tplane, planep, sizeof(struct plnstr));
98 tplane.pln_timestamp = chkplane.pln_timestamp = 0;
99 if (memcmp(&tplane, &chkplane, sizeof(struct plnstr))) {
100 pr("Plane #%d has changed!\n", planep->pln_uid);
107 check_land_ok(struct lndstr *landp)
109 struct lndstr chkland;
112 getland(landp->lnd_uid, &chkland);
113 memcpy(&tland, landp, sizeof(struct lndstr));
114 tland.lnd_timestamp = chkland.lnd_timestamp = 0;
115 if (memcmp(&tland, &chkland, sizeof(struct lndstr))) {
116 pr("Land unit #%d has changed!\n", landp->lnd_uid);
123 check_nuke_ok(struct nukstr *nukep)
125 struct nukstr chknuke;
128 getnuke(nukep->nuk_uid, &chknuke);
129 memcpy(&tnuke, nukep, sizeof(struct nukstr));
130 tnuke.nuk_timestamp = chknuke.nuk_timestamp = 0;
131 if (memcmp(&tnuke, &chknuke, sizeof(struct nukstr))) {
132 pr("Nuke %d has changed!\n", nukep->nuk_uid);
139 check_loan_ok(struct lonstr *loanp)
141 struct lonstr chkloan;
143 getloan(loanp->l_uid, &chkloan);
144 if (memcmp(loanp, &chkloan, sizeof(struct lonstr))) {
145 pr("Loan %d has changed!\n", loanp->l_uid);
152 check_comm_ok(struct comstr *commp)
154 struct comstr chkcomm;
156 getcomm(commp->com_uid, &chkcomm);
157 if (memcmp(commp, &chkcomm, sizeof(struct comstr))) {
158 pr("Commodity %d has changed!\n", commp->com_uid);
165 check_trade_ok(struct trdstr *tp)
167 struct trdstr chktrade;
169 gettrade(tp->trd_uid, &chktrade);
170 if (memcmp(tp, &chktrade, sizeof(struct trdstr))) {
171 pr("Trade lot #%d has changed!\n", tp->trd_uid);