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 * init_nats.c: Initialize country and nation file stuff
30 * Known contributors to this file:
35 #include "prototypes.h"
52 if ((np = getnatp(player->cnum)) == 0)
54 player->nstat = np->nat_stat;
55 player->god = np->nat_stat & STAT_GOD;
56 player->map = ef_ptr(EF_MAP, player->cnum);
57 player->bmap = ef_ptr(EF_BMAP, player->cnum);
59 putcontact(np, player->cnum, FOUND_SPY);
61 if (np->nat_money <= 0)
64 player->nstat |= MONEY;
67 if (nat_cap(np->nat_btu) < 0)
77 extern float btu_build_rate;
84 np = getnatp(player->cnum);
85 if (!getsect(np->nat_xcap, np->nat_ycap, §)) {
86 logerror("can't read %s's cap @ %d,%d",
87 np->nat_cnam, np->nat_xcap, np->nat_ycap);
90 if ((player->nstat & NORM) == NORM) {
91 if (player->owner && (sect.sct_type == SCT_CAPIT ||
92 sect.sct_type == SCT_MOUNT ||
93 sect.sct_type == SCT_SANCT))
96 player->nstat &= ~CAP;
97 /* Ok, has the country owner reset his capital yet after it was sacked? */
98 if (np->nat_flags & NF_SACKED)
99 player->nstat &= ~CAP; /* No capital yet */
102 if ((player->nstat & CAP) || player->god) {
103 d = (double) (player->curup - np->nat_last_login) / s_p_etu;
106 civ = getvar(V_CIVIL, (caddr_t)§, EF_SECTOR);
109 if ((sect.sct_effic) && (sect.sct_type != SCT_MOUNT))
110 delta=roundavg(d*civ*sect.sct_effic*btu_build_rate);
111 else /* Assume 1/2% efficiency minimum */
112 delta=roundavg(d*civ*btu_build_rate/2.0);
114 delta = max_btus - btu;
115 if (delta + btu > max_btus)
116 delta = max_btus - btu;
118 delta = max_btus - btu;
120 delta = max_btus - btu;
123 /* set date if BTUs made */
124 np->nat_btu += delta;
127 np->nat_btu = max_btus;
129 if (np->nat_stat == VIS)
130 np->nat_btu = max_btus;