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 * nat.c: Misc. accesses on the nation file
30 * Known contributors to this file:
42 /* must follow nation relation defines in nat.h */
43 "At War", "Sitzkrieg", "Mobilizing", "Hostile", "Neutral", "Friendly",
52 if ((np = getnatp(n)) == 0)
58 relatename(struct natstr *np, natid other)
60 return relates[getrel(np, other)];
64 rejectname(struct natstr *np, natid other)
66 static char *rejects[] = {
67 /* must follow reject flags defined in nat.h */
86 return rejects[getrejects(other, np)];
90 natstate(struct natstr *np)
92 static char *stnam[] = {
93 /* must match nat_status */
94 "FREE", "VISITOR", "VISITOR", "SANCTUARY", "ACTIVE", "DEITY"
96 return stnam[np->nat_stat];
99 /* This returns the relations that np has with them */
101 getrel(struct natstr *np, natid them)
103 return np->nat_relate[them];
107 getrejects(natid them, struct natstr *np)
109 return np->nat_rejects[them];
113 agecontact(struct natstr *np)
117 for (them = 1; them < MAXNOC; ++them) {
118 if (them != np->nat_cnum && np->nat_contact[them]) {
119 --np->nat_contact[them];
125 getcontact(struct natstr *np, natid them)
127 return np->nat_contact[them];
131 putrel(struct natstr *np, natid them, int relate)
133 np->nat_relate[them] = relate;
137 putreject(struct natstr *np, natid them, int how, int what)
140 np->nat_rejects[them] |= what;
142 np->nat_rejects[them] &= what;
146 putcontact(struct natstr *np, natid them, int contact)
148 if (CANT_HAPPEN(contact < 0))
150 if (CANT_HAPPEN(contact > 255))
153 if (np->nat_contact[them] < contact)
154 np->nat_contact[them] = contact;
158 influx(struct natstr *np)
162 getsect(np->nat_xcap, np->nat_ycap, §);
163 if (sect.sct_own != np->nat_cnum ||
164 (sect.sct_type != SCT_CAPIT && sect.sct_type != SCT_MOUNT &&
165 sect.sct_type != SCT_SANCT) ||
166 (np->nat_flags & NF_SACKED))