]> git.pond.sub.org Git - empserver/blob - src/lib/commands/vers.c
Update copyright notice
[empserver] / src / lib / commands / vers.c
1 /*
2  *  Empire - A multi-player, client/server Internet based war game.
3  *  Copyright (C) 1986-2014, Dave Pare, Jeff Bailey, Thomas Ruschak,
4  *                Ken Stevens, Steve McClure, Markus Armbruster
5  *
6  *  Empire 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 3 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, see <http://www.gnu.org/licenses/>.
18  *
19  *  ---
20  *
21  *  See files README, COPYING and CREDITS in the root of the source
22  *  tree for related information and legal notices.  It is expected
23  *  that future projects/authors will amend these files as needed.
24  *
25  *  ---
26  *
27  *  vers.c: Print out the Empire version
28  *
29  *  Known contributors to this file:
30  *     Dave Pare
31  *     Jeff Bailey
32  *     Thomas Ruschak
33  *     Ken Stevens
34  *     Steve McClure
35  *     Ron Koenderink, 2005-2006
36  *     Markus Armbruster, 2005-2013
37  */
38
39 #include <config.h>
40
41 #include "commands.h"
42 #include "nuke.h"
43 #include "optlist.h"
44 #include "ship.h"
45 #include "version.h"
46
47 static int have_trade_ships(void);
48 static void show_custom(void);
49 static void show_opts(int val);
50 static char *prwrap(char *, char *, int *);
51
52 int
53 vers(void)
54 {
55     time_t now;
56
57     (void)time(&now);
58     pr("%s\n\n", version);
59     pr("The following parameters have been set for this game:\n");
60     pr("World size is %d by %d.\n", WORLD_X, WORLD_Y);
61     pr("There can be up to %d countries.\n", MAXNOC);
62     pr("By default, countries use %s coordinate system.\n",
63        (players_at_00) ? "the deity's" : "their own");
64     pr("\n");
65     pr("Use the 'show' command to find out the time of the next update.\n");
66     pr("The current time is %19.19s.\n", ctime(&now));
67     pr("An update consists of %d empire time units.\n", etu_per_update);
68     pr("Each country is allowed to be logged in %d minutes a day.\n",
69        m_m_p_d);
70     if (*game_days != 0)
71         pr("Game days are %s.\n", game_days);
72     if (*game_hours != 0)
73         pr("Game hours are %s.\n", game_hours);
74     pr("It takes %.2f civilians to produce a BTU in one time unit.\n",
75        (1.0 / (btu_build_rate * 100.0)));
76     pr("\n");
77
78     pr("A non-aggi, 100 fertility sector can grow %.2f food per etu.\n",
79        100.0 * fgrate);
80     pr("1000 civilians will harvest %.1f food per etu.\n",
81        1000.0 * fcrate);
82     pr("1000 civilians will give birth to %.1f babies per etu.\n",
83        1000.0 * obrate);
84     pr("1000 uncompensated workers will give birth to %.1f babies.\n",
85        1000.0 * uwbrate);
86     pr("In one time unit, 1000 people eat %.1f units of food.\n",
87        1000.0 * eatrate);
88     pr("1000 babies eat %.1f units of food becoming adults.\n",
89        1000.0 * babyeat);
90     if (opt_NOFOOD)
91         pr("No food is needed!\n");
92
93     pr("\n");
94
95     pr("Banks pay $%.2f in interest per 1000 gold bars per etu.\n",
96        bankint * 1000.0);
97     pr("1000 civilians generate $%.2f, uncompensated workers $%.2f each time unit.\n",
98        1000.0 * money_civ, 1000.0 * money_uw);
99     pr("1000 active military cost $%.2f, reserves cost $%.2f.\n",
100        -money_mil * 1000.0, -money_res * 1000.0);
101     if (rollover_avail_max)
102         pr("Up to %d avail can roll over an update.\n",
103            rollover_avail_max);
104     pr("Happiness p.e. requires 1 happy stroller per %d civ.\n",
105        (int)hap_cons / etu_per_update);
106     pr("Education p.e. requires 1 class of graduates per %d civ.\n",
107        (int)edu_cons / etu_per_update);
108     pr("Happiness is averaged over %d time units.\n", (int)hap_avg);
109     pr("Education is averaged over %d time units.\n", (int)edu_avg);
110     if (opt_ALL_BLEED == 0)
111         pr("The technology/research boost you get from your allies is %.2f%%.\n",
112            100.0 / ally_factor);
113     else
114         pr("The technology/research boost you get from the world is %.2f%%.\n",
115            100.0 / ally_factor);
116
117     pr("Nation levels (tech etc.) decline 1%% every %d time units.\n",
118        (int)(level_age_rate));
119
120     pr("Tech buildup is ");
121     if (tech_log_base <= 1.0) {
122         pr("not limited.\n");
123     }
124     if (tech_log_base > 1.0) {
125         pr("limited to logarithmic growth (base %.2f)", tech_log_base);
126         if (easy_tech == 0.0)
127             pr(".\n");
128         else
129             pr(" after %0.2f.\n", easy_tech);
130     }
131     pr("\n");
132     pr("\t\t\t\tSectors\tShips\tPlanes\tUnits\n");
133     pr("Maximum mobility\t\t%d\t%d\t%d\t%d\n",
134        sect_mob_max, ship_mob_max, plane_mob_max, land_mob_max);
135     pr("Max mob gain per update\t\t%d\t%d\t%d\t%d\n",
136        (int)(sect_mob_scale * (float)etu_per_update),
137        (int)(ship_mob_scale * (float)etu_per_update),
138        (int)(plane_mob_scale * (float)etu_per_update),
139        (int)(land_mob_scale * (float)etu_per_update));
140     pr("Max eff gain per update\t\t--\t%d\t%d\t%d\n",
141        MIN((int)(ship_grow_scale * (float)etu_per_update), 100),
142        MIN((int)(plane_grow_scale * (float)etu_per_update), 100),
143        MIN((int)(land_grow_scale * (float)etu_per_update), 100));
144     pr("Maintenance cost per update\t--\t%0.1f%%\t%0.1f%%\t%0.1f%%\n",
145        money_ship * -100.0 * etu_per_update,
146        money_plane * -100.0 * etu_per_update,
147        money_land * -100.0 * etu_per_update);
148     pr("Max interdiction range\t\t%d\t%d\t--\t%d\n",
149        fort_max_interdiction_range,
150        ship_max_interdiction_range,
151        land_max_interdiction_range);
152     pr("\n");
153     pr("The maximum amount of mobility used for land unit combat is %0.2f.\n",
154        combat_mob);
155     if (opt_MOB_ACCESS)
156         pr("The starting mobility when acquiring a sector or unit is %d.\n",
157            -(etu_per_update / sect_mob_neg_factor));
158     pr("\n");
159     pr("Ships on autonavigation may use %i cargo holds per ship.\n", TMAX);
160     if (have_trade_ships()) {
161         pr("Trade-ships that go at least %d sectors get a return of %.1f%% per sector.\n",
162            trade_1_dist, trade_1 * 100.0);
163         pr("Trade-ships that go at least %d sectors get a return of %.1f%% per sector.\n",
164            trade_2_dist, trade_2 * 100.0);
165         pr("Trade-ships that go at least %d sectors get a return of %.1f%% per sector.\n",
166            trade_3_dist, trade_3 * 100.0);
167         pr("Cashing in trade-ships with an ally nets you a %.1f%% bonus.\n",
168            trade_ally_bonus * 100.0);
169         pr("Cashing in trade-ships with an ally nets your ally a %.1f%% bonus.\n\n",
170            trade_ally_cut * 100.0);
171     }
172     if (opt_MARKET) {
173         pr("The tax you pay on selling things on the trading block is %.1f%%.\n",
174            (1.00 - tradetax) * 100.0);
175         pr("The tax you pay on buying commodities on the market is %.1f%%.\n",
176            (buytax - 1.00) * 100.0);
177         pr("The amount of time to bid on commodities is %d seconds.\n",
178            MARK_DELAY);
179         pr("The amount of time to bid on a unit is %d seconds.\n\n",
180            TRADE_DELAY);
181     }
182
183     if (!ef_nelem(EF_NUKE_CHR))
184         pr("Nukes are disabled.\n");
185     else if (drnuke_const > MIN_DRNUKE_CONST) {
186         pr("In order to build a nuke, you need %1.2f times the tech level in research.\n",
187            drnuke_const);
188         pr("\tExample: In order to build a 300 tech nuke, you need %d research.\n\n",
189            (int)(300.0 * drnuke_const));
190     }
191
192     pr("Fire ranges are scaled by %.2f.\n", fire_range_factor);
193     pr("Flak damage is scaled by %0.2f.\n", flakscale);
194     pr("Torpedo damage is 2d%d+%d.\n", torpedo_damage, torpedo_damage - 2);
195     pr("The attack factor for para & assault troops is %0.2f.\n",
196        assault_penalty);
197     pr("%.0f%% of fallout leaks into each surrounding sector.\n",
198        fallout_spread * 100.0 * MIN(24, etu_per_update));
199     pr("Fallout decays by %.0f%% per update.\n",
200        100.0 - (decay_per_etu + 6.0) * fallout_spread * MIN(24, etu_per_update) * 100.0);
201     pr("\n");
202     pr("Damage to\t\t\tSpills to\n");
203     pr("\t      Sector  People  Mater.   Ships  Planes  LandU.\n");
204     pr("Sector\t\t --\t%3.0f%%\t100%%\t  0%%\t%3.0f%%\t%3.0f%%\n",
205        people_damage * 100.0, unit_damage / 0.07, unit_damage * 100.0);
206     pr("People\t\t%3.0f%%\t --\t --\t --\t --\t --\n",
207        collateral_dam * 100.0);
208     pr("Materials\t%3.0f%%\t --\t --\t --\t --\t --\n",
209        collateral_dam * 100.0);
210     pr("Efficiency\t%3.0f%%\t --\t --\t --\t --\t --\n",
211        collateral_dam * 100.0);
212     pr("Ships\t\t%3.0f%%\t100%%\t100%%\t --\t  0%%\t  0%%\n",
213        collateral_dam * 100.0);
214     pr("Planes\t\t%3.0f%%\t  0%%\t  0%%\t --\t --\t --\n",
215        collateral_dam * 100.0);
216     pr("Land units\t%3.0f%%\t  0%%\t100%%\t --\t  0%%\t  0%%\n",
217        collateral_dam * 100.0);
218     pr("\n");
219     pr("You can have at most %d BTUs.\n", max_btus);
220     pr("%s are disconnected after %d minute%s of idle time.\n",
221        player->nstat & NONVIS ? "You" : "Players",
222        max_idle, splur(max_idle));
223     pr("%s are disconnected after %d minute%s of idle time.\n",
224        player->nstat & NONVIS ? "Visitors" : "You",
225        max_idle_visitor, splur(max_idle_visitor));
226     pr("\nOptions enabled in this game:\n");
227     show_opts(1);
228     pr("\n\nOptions disabled in this game:\n");
229     show_opts(0);
230     pr("\n\nSee \"info Options\" for a detailed list of options and descriptions.\n");
231     show_custom();
232     pr("\nThe person to annoy if something goes wrong is:\n\t%s <%s>.\n",
233        privname, privlog);
234     pr("\nYou can get your own copy of the source from "
235        "<http://www.wolfpackempire.com/>.\n\n");
236     pr("%s", legal);
237     return RET_OK;
238 }
239
240 static int
241 have_trade_ships(void)
242 {
243     int i;
244
245     for (i = ef_nelem(EF_SHIP_CHR) - 1; i >= 0; i--) {
246         if (mchr[i].m_flags & M_TRADE)
247             return 1;
248     }
249     return 0;
250 }
251
252 static void
253 show_custom(void)
254 {
255     char *sep;
256     int col, i;
257
258     sep = "\nCustomized in this game:\n\t";
259     col = 0;
260     for (i = 0; i < EF_MAX; i++) {
261         if (ef_flags(i) & EFF_CUSTOM)
262             sep = prwrap(sep, ef_nameof(i), &col);
263     }
264     if (*sep == ',')
265         pr("\nCheck \"show\" for details.\n");
266 }
267
268 static void
269 show_opts(int val)
270 {
271     char *sep;
272     int col;
273     struct keymatch *kp;
274
275     sep = "\t";
276     col = 0;
277     for (kp = configkeys; kp->km_key; kp++) {
278         if (!(kp->km_flags & KM_OPTION))
279             continue;
280         if (CANT_HAPPEN(kp->km_type != NSC_INT))
281             continue;
282         if (!*(int *)kp->km_data != !val)
283             continue;
284         sep = prwrap(sep, kp->km_key, &col);
285     }
286 }
287
288 static char *
289 prwrap(char *sep, char *it, int *col)
290 {
291     size_t len = strlen(it);
292
293     if (*col != 0 && *col + len > 70) {
294         sep = ",\n\t";
295         *col = 0;
296     }
297     pr("%s%s", sep, it);
298     sep = ", ";
299     *col += len + 2;
300     return sep;
301 }