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