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 * land.c: Land unit post-read and pre-write
30 * Known contributors to this file:
45 #include "prototypes.h"
49 lnd_postread(int n, s_char *ptr)
51 struct lndstr *llp = (struct lndstr *)ptr;
52 struct shpstr theship;
53 struct lndstr theland;
55 if (llp->lnd_uid != n) {
56 logerror("lnd_postread: Error - %d != %d, zeroing.\n",
58 bzero(ptr, sizeof(struct lndstr));
60 if (llp->lnd_ship >= 0 && llp->lnd_own
61 && llp->lnd_effic >= LAND_MINEFF) {
62 if (getship(llp->lnd_ship, &theship)
63 && (theship.shp_effic >= SHIP_MINEFF)) {
64 /* wooof! Carriers are a pain */
65 if (llp->lnd_mission) {
67 * If the unit is on a mission centered
68 * on it's loc, the op-area travels with
71 if ((llp->lnd_opx == llp->lnd_x) &&
72 (llp->lnd_opy == llp->lnd_y)) {
73 llp->lnd_opx = theship.shp_x;
74 llp->lnd_opy = theship.shp_y;
77 if (llp->lnd_x != theship.shp_x || llp->lnd_y != theship.shp_y)
78 time(&llp->lnd_timestamp);
79 llp->lnd_x = theship.shp_x;
80 llp->lnd_y = theship.shp_y;
83 if (llp->lnd_land >= 0 && llp->lnd_own
84 && llp->lnd_effic >= LAND_MINEFF) {
85 if (getland(llp->lnd_land, &theland)
86 && (theland.lnd_effic >= LAND_MINEFF)) {
87 /* wooof! Carriers are a pain */
88 if (llp->lnd_mission) {
90 * If the unit is on a mission centered
91 * on it's loc, the op-area travels with
94 if ((llp->lnd_opx == llp->lnd_x) &&
95 (llp->lnd_opy == llp->lnd_y)) {
96 llp->lnd_opx = theland.lnd_x;
97 llp->lnd_opy = theland.lnd_y;
100 if (llp->lnd_x != theland.lnd_x || llp->lnd_y != theland.lnd_y)
101 time(&llp->lnd_timestamp);
102 llp->lnd_x = theland.lnd_x;
103 llp->lnd_y = theland.lnd_y;
109 player->owner = (player->god || llp->lnd_own == player->cnum);
115 lnd_prewrite(int n, s_char *ptr)
117 struct lndstr *llp = (struct lndstr *)ptr;
123 llp->ef_type = EF_LAND;
126 time(&llp->lnd_timestamp);
128 if (llp->lnd_own && llp->lnd_effic < LAND_MINEFF) {
129 makelost(EF_LAND, llp->lnd_own, llp->lnd_uid, llp->lnd_x,
135 for (i = 0; NULL != (lp = getlandp(i)); i++) {
136 if (lp->lnd_own && lp->lnd_land == n) {
137 mpr(lp->lnd_own, "%s MIA!\n", prland(lp));
138 makelost(EF_LAND, lp->lnd_own, lp->lnd_uid, lp->lnd_x,
144 putland(lp->lnd_uid, lp);
147 for (i = 0; NULL != (pp = getplanep(i)); i++) {
148 if (pp->pln_own && pp->pln_land == n) {
149 mpr(pp->pln_own, "%s MIA!\n", prplane(pp));
150 makelost(EF_PLANE, pp->pln_own, pp->pln_uid, pp->pln_x,
156 putplane(pp->pln_uid, pp);
166 lnd_init(int n, s_char *ptr)
168 struct lndstr *lp = (struct lndstr *)ptr;
170 lp->ef_type = EF_LAND;
176 prland(struct lndstr *lp)
178 return prbuf("%s #%d", lchr[(int)lp->lnd_type].l_name, lp->lnd_uid);