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 * main.c: World update main function
30 * Known contributors to this file:
39 #include "empthread.h"
47 long sea_money[MAXNOC];
48 long lnd_money[MAXNOC];
49 long air_money[MAXNOC];
55 int etu = etu_per_update;
63 logerror("production update (%d etus)", etu);
66 /* First, make sure all mobility is updated correctly. */
78 * set up all the variables which get used in the
79 * sector production routine (for producing education,
80 * happiness, and printing out the state of the nation)
82 memset(pops, 0, sizeof(pops));
83 memset(air_money, 0, sizeof(air_money));
84 memset(sea_money, 0, sizeof(sea_money));
85 memset(lnd_money, 0, sizeof(lnd_money));
87 for (n = 0; n < MAXNOC; n++) {
89 if (!(np = getnatp(n)))
91 money[n] = np->nat_money;
92 tpops[n] = count_pop(n);
95 logerror("preparing sectors...");
96 prepare_sects(etu, bp);
97 logerror("done preparing sectors.");
98 logerror("producing for countries...");
99 for (x = 0; x < MAXNOC; x++) {
100 long p_sect[SCT_TYPE_MAX+2][2];
102 memset(p_sect, 0, sizeof(p_sect));
103 if (!(np = getnatp(x)))
105 if (np->nat_stat == STAT_SANCT) {
107 logerror("Country %i is in sanctuary and did not update", x);
111 np->nat_money += (int)(np->nat_reserve * money_res * etu);
114 prod_ship(etu, x, bp, 0);
115 prod_plane(etu, x, bp, 0);
116 prod_land(etu, x, bp, 0);
118 /* produce all sects */
119 produce_sect(x, etu, bp, p_sect);
122 prod_ship(etu, x, bp, 1);
123 prod_plane(etu, x, bp, 1);
124 prod_land(etu, x, bp, 1);
126 logerror("done producing for countries.");
134 /* Update war declarations */
135 /* MOBILIZATION->SITZKRIEG->AT_WAR */
136 for (cn = 1; cn < MAXNOC; cn++) {
137 if ((cnp = getnatp(cn)) == 0)
139 for (cn2 = 1; cn2 < MAXNOC; cn2++) {
142 rel = getrel(cnp, cn2);
143 if (rel == MOBILIZATION) {
145 setrel(cn, cn2, rel);
146 } else if (rel == SITZKRIEG) {
148 setrel(cn, cn2, rel);
153 /* Only update mobility for non-MOB_ACCESS here, since it doesn't
154 get done for MOB_ACCESS anyway during the update */
155 if (!opt_MOB_ACCESS) {
161 if (opt_DEMANDUPDATE)
162 update_removewants();
163 /* flush all mem file objects to disk */
169 delete_old_announcements();
171 /* Clear all the telegram flags */
172 for (cn = 0; cn < MAXNOC; cn++)
173 clear_telegram_is_new(cn);
174 logerror("End update");