2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2007, 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 * init_nats.c: Initialize country and nation file stuff
30 * Known contributors to this file:
42 #include "prototypes.h"
45 static int nat_cap(int);
50 static int nstat[] = {
51 /* must match nat_status */
52 0, VIS, VIS, SANCT, NORM, GOD
56 np = getnatp(player->cnum);
59 player->nstat = nstat[np->nat_stat];
60 player->god = np->nat_stat == STAT_GOD;
61 player->map = ef_ptr(EF_MAP, player->cnum);
62 player->bmap = ef_ptr(EF_BMAP, player->cnum);
64 putcontact(np, player->cnum, FOUND_SPY);
66 if (np->nat_money <= 0)
69 player->nstat |= MONEY;
72 if (nat_cap(np->nat_btu) < 0)
86 np = getnatp(player->cnum);
87 if (!getsect(np->nat_xcap, np->nat_ycap, §)) {
88 CANT_HAPPEN("read cap");
91 if (np->nat_stat >= STAT_ACTIVE) {
93 player->nstat &= ~CAP;
98 if ((player->nstat & CAP) || player->god) {
99 d = (double)(player->curup - np->nat_last_login) / s_p_etu;
102 civ = sect.sct_item[I_CIVIL];
105 eff = sect.sct_effic * sect.sct_work / 100.0;
106 if (eff < 0.5 || sect.sct_type == SCT_MOUNT)
108 delta = roundavg(d * civ * eff * btu_build_rate);
110 if (delta + btu > max_btus)
111 np->nat_btu = max_btus;
113 np->nat_btu += delta;
115 if (np->nat_stat == STAT_VIS)
116 np->nat_btu = max_btus;