]> git.pond.sub.org Git - empserver/blob - src/lib/commands/nati.c
Import of Empire 4.2.12
[empserver] / src / lib / commands / nati.c
1 /*
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
5  *
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.
10  *
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.
15  *
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
19  *
20  *  ---
21  *
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.
25  *
26  *  ---
27  *
28  *  nati.c: List nation information
29  * 
30  *  Known contributors to this file:
31  *     
32  */
33
34 #include "misc.h"
35 #include "player.h"
36 #include "var.h"
37 #include "nat.h"
38 #include "sect.h"
39 #include "file.h"
40 #include "xy.h"
41 #include "optlist.h"
42 #include "commands.h"
43
44 int
45 nati(void)
46 {
47         extern  int etu_per_update;
48         extern  double obrate, uwbrate;
49         struct  natstr *natp;
50         struct  sctstr sect;
51         float   hap;
52         int     mil;
53         int     civ;
54         int     poplimit, safepop, uwpop;
55         double pfac;
56
57         if ((natp = getnatp(player->cnum)) == 0) {
58                 pr("Bad country number %d\n", player->cnum);
59                 return RET_SYN;
60         }
61         pr("\n(#%i) %s Nation Report\t", player->cnum, cname(player->cnum));
62         prdate();
63         pr("Nation status is %s", natstate(natp));
64         pr("     Bureaucratic Time Units: %d\n", natp->nat_btu);
65         if (natp->nat_stat & STAT_INUSE) {
66                 getsect(natp->nat_xcap, natp->nat_ycap, &sect);
67                 if (!player->owner || (sect.sct_type != SCT_CAPIT &&
68                     sect.sct_type != SCT_MOUNT &&
69                     sect.sct_type != SCT_SANCT))
70                         pr("No capital. (was at %s)\n",
71                                 xyas(sect.sct_x, sect.sct_y, player->cnum));
72                 else {
73                         civ = getvar(V_CIVIL, (s_char *)&sect, EF_SECTOR);
74                         mil = getvar(V_MILIT, (s_char *)&sect, EF_SECTOR);
75                         pr("%d%% eff %s at %s has %d civilian%s & %d military\n",
76                                sect.sct_effic,
77                                (sect.sct_type == SCT_CAPIT ? "capital" : "mountain capital"),
78                                xyas(sect.sct_x, sect.sct_y, player->cnum), civ,
79                                splur(civ), mil);
80                 }
81         }
82         pr(" The treasury has $%.2f", (double) natp->nat_money);
83         pr("     Military reserves: %d\n", natp->nat_reserve);
84         pr("Education..........%6.2f       Happiness.......%6.2f\n",
85                 (double) natp->nat_level[NAT_ELEV],
86                 (double) natp->nat_level[NAT_HLEV]);
87         pr("Technology.........%6.2f       Research........%6.2f\n",
88                 (double) natp->nat_level[NAT_TLEV],
89                 (double) natp->nat_level[NAT_RLEV]);
90         pr("Technology factor :%6.2f%%", tfact(player->cnum, 100.));
91
92         if (opt_NO_PLAGUE) 
93                 pfac = 0.0;
94         else 
95                 pfac = ((double) natp->nat_level[NAT_TLEV] + 100.) /
96                         ((double) natp->nat_level[NAT_RLEV] + 100.);
97         pr("     Plague factor : %6.2f%%\n", pfac);
98         pr("\n");
99
100         poplimit = 999;
101         if (opt_RES_POP)
102                 poplimit = max_pop(natp->nat_level[NAT_RLEV], 0);
103         pr("Max population : %d\n", poplimit);
104
105         safepop = (int)((double)poplimit/(1.0 + obrate*(double)etu_per_update));
106         uwpop = (int)((double)poplimit/(1.0 + uwbrate*(double)etu_per_update));
107         safepop++;
108         if (((double)safepop*(1.0 + obrate*(double)etu_per_update)) > ((double)poplimit+0.0000001))
109                 safepop--;
110         uwpop++;
111         if (((double)uwpop*(1.0 + uwbrate*(double)etu_per_update)) > ((double)poplimit+0.0000001))
112                 uwpop--;
113
114         pr("Max safe population for civs/uws: %d/%d\n",safepop,uwpop);
115
116         hap = ((natp->nat_level[NAT_TLEV]-40)/40.0 +
117                         natp->nat_level[NAT_ELEV]/3.0);
118
119         if (hap > 0.0)
120                 pr("Happiness needed is %f\n",hap);
121         else
122                 pr("No happiness needed\n");
123
124         return RET_OK;
125 }