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 * land.c: Land unit post-read and pre-write
30 * Known contributors to this file:
42 #include "prototypes.h"
46 lnd_postread(int n, void *ptr)
48 struct lndstr *llp = ptr;
50 if (llp->lnd_uid != n) {
51 logerror("lnd_postread: Error - %d != %d, zeroing.\n",
53 memset(llp, 0, sizeof(struct lndstr));
58 player->owner = (player->god || llp->lnd_own == player->cnum);
62 lnd_prewrite(int n, void *old, void *new)
64 struct lndstr *oldlp = old;
65 struct lndstr *llp = new;
66 natid own = llp->lnd_own;
68 if (llp->lnd_own && llp->lnd_effic < LAND_MINEFF) {
70 llp->lnd_ship = llp->lnd_land = -1;
72 item_prewrite(llp->lnd_item);
75 if (CANT_HAPPEN(llp->lnd_ship >= 0 && llp->lnd_land >= 0))
77 if (oldlp->lnd_ship != llp->lnd_ship)
78 lnd_carrier_change(llp, EF_SHIP, oldlp->lnd_ship, llp->lnd_ship);
79 if (oldlp->lnd_land != llp->lnd_land)
80 lnd_carrier_change(llp, EF_LAND, oldlp->lnd_land, llp->lnd_land);
82 /* We've avoided assigning to llp->lnd_own, in case oldsp == sp */
83 if (oldlp->lnd_own != own)
84 lost_and_found(EF_LAND, oldlp->lnd_own, own,
85 llp->lnd_uid, llp->lnd_x, llp->lnd_y);
88 if (!own || llp->lnd_x != oldlp->lnd_x || llp->lnd_y != oldlp->lnd_y)
89 unit_update_cargo((struct empobj *)llp);
95 struct lndstr *lp = ptr;
97 lp->lnd_ship = lp->lnd_land = -1;
101 prland(struct lndstr *lp)
103 return prbuf("%s #%d", lchr[(int)lp->lnd_type].l_name, lp->lnd_uid);