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 * plane.c: Plane post-read and pre-write data massage
30 * Known contributors to this file:
45 #include "prototypes.h"
49 pln_postread(int n, s_char *ptr)
51 struct plnstr *pp = (struct plnstr *) ptr;
52 struct shpstr theship;
53 struct lndstr theland;
55 if (pp->pln_uid != n) {
56 logerror("pln_postread: Error - %d != %d, zeroing.\n", pp->pln_uid, n);
57 bzero(ptr, sizeof(struct plnstr));
60 if (pp->pln_ship >= 0 && pp->pln_own && pp->pln_effic >= PLANE_MINEFF) {
61 if (getship(pp->pln_ship, &theship) &&
62 (theship.shp_effic >= SHIP_MINEFF)) {
63 /* wooof! Carriers are a pain */
66 * If the plane is on a mission centered
67 * on it's loc, the op-area travels with
70 if ((pp->pln_opx == pp->pln_x) &&
71 (pp->pln_opy == pp->pln_y)){
72 pp->pln_opx = theship.shp_x;
73 pp->pln_opy = theship.shp_y;
76 if (pp->pln_x != theship.shp_x || pp->pln_y != theship.shp_y)
77 time(&pp->pln_timestamp);
78 pp->pln_x = theship.shp_x;
79 pp->pln_y = theship.shp_y;
82 if (pp->pln_land >= 0 && pp->pln_own && pp->pln_effic >= PLANE_MINEFF) {
83 if (getland(pp->pln_land, &theland) &&
84 (theland.lnd_effic >= LAND_MINEFF)) {
85 /* wooof! Units are a pain, too */
88 * If the plane is on a mission centered
89 * on it's loc, the op-area travels with
92 if ((pp->pln_opx == pp->pln_x) &&
93 (pp->pln_opy == pp->pln_y)){
94 pp->pln_opx = theland.lnd_x;
95 pp->pln_opy = theland.lnd_y;
98 if (pp->pln_x != theland.lnd_x || pp->pln_y != theland.lnd_y)
99 time(&pp->pln_timestamp);
100 pp->pln_x = theland.lnd_x;
101 pp->pln_y = theland.lnd_y;
104 player->owner = (player->god || pp->pln_own == player->cnum);
112 pln_prewrite(int n, s_char *ptr)
114 struct plnstr *pp = (struct plnstr *) ptr;
117 if (pp->pln_effic < PLANE_MINEFF) {
119 makelost(EF_PLANE, pp->pln_own, pp->pln_uid, pp->pln_x, pp->pln_y);
123 pp->ef_type = EF_PLANE;
126 time(&pp->pln_timestamp);
134 pln_init(int n, s_char *ptr)
136 struct plnstr *pp = (struct plnstr *) ptr;
138 pp->ef_type = EF_PLANE;
144 prplane(struct plnstr *pp)
146 return prbuf("%s #%d", plchr[(int)pp->pln_type].pl_name, pp->pln_uid);