]> git.pond.sub.org Git - empserver/blob - src/lib/commands/vers.c
d314f58ab332d7f70d840d8f3923d79f2f2fa769
[empserver] / src / lib / commands / vers.c
1 /*
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
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 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.
25  *
26  *  ---
27  *
28  *  vers.c: Print out the Empire version
29  * 
30  *  Known contributors to this file:
31  *     Dave Pare
32  *     Jeff Bailey
33  *     Thomas Ruschak
34  *     Ken Stevens
35  *     Steve McClure
36  *     Ron Koenderink, 2005-2006
37  *     Markus Armbruster, 2005-2007
38  */
39
40 #include <config.h>
41
42 #include "commands.h"
43 #include "nuke.h"
44 #include "optlist.h"
45 #include "ship.h"
46 #include "version.h"
47
48 static void show_custom(void);
49 static void show_opts(int val);
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     if (opt_SLOW_WAR)
104         pr("Declaring war will cost you $%i\n\n", War_Cost);
105     pr("Happiness p.e. requires 1 happy stroller per %d civ.\n",
106        (int)hap_cons / etu_per_update);
107     pr("Education p.e. requires 1 class of graduates per %d civ.\n",
108        (int)edu_cons / etu_per_update);
109     pr("Happiness is averaged over %d time units.\n", (int)hap_avg);
110     pr("Education is averaged over %d time units.\n", (int)edu_avg);
111     if (opt_ALL_BLEED == 0)
112         pr("The technology/research boost you get from your allies is %.2f%%.\n",
113            100.0 / ally_factor);
114     else
115         pr("The technology/research boost you get from the world is %.2f%%.\n",
116            100.0 / ally_factor);
117
118     pr("Nation levels (tech etc.) decline 1%% every %d time units.\n",
119        (int)(level_age_rate));
120
121     pr("Tech Buildup is ");
122     if (tech_log_base <= 1.0) {
123         pr("not limited\n");
124     }
125     if (tech_log_base > 1.0) {
126         pr("limited to logarithmic growth (base %.2f)", tech_log_base);
127         if (easy_tech == 0.0)
128             pr(".\n");
129         else
130             pr(" after %0.2f.\n", easy_tech);
131     }
132     pr("\n");
133     pr("\t\t\t\tSectors\tShips\tPlanes\tUnits\n");
134     pr("Maximum mobility\t\t%d\t%d\t%d\t%d\n",
135        sect_mob_max, ship_mob_max, plane_mob_max, land_mob_max);
136     pr("Max mob gain per update\t\t%d\t%d\t%d\t%d\n",
137        (int)(sect_mob_scale * (float)etu_per_update),
138        (int)(ship_mob_scale * (float)etu_per_update),
139        (int)(plane_mob_scale * (float)etu_per_update),
140        (int)(land_mob_scale * (float)etu_per_update));
141     pr("Mission mobility cost\t\t--\t%d\t%d\t%d\n",
142        ldround((mission_mob_cost * (double)ship_mob_max), 1),
143        ldround((mission_mob_cost * (double)plane_mob_max), 1),
144        ldround((mission_mob_cost * (double)land_mob_max), 1));
145     pr("Max eff gain per update\t\t--\t%d\t%d\t%d\n",
146        MIN((int)(ship_grow_scale * (float)etu_per_update), 100),
147        MIN((int)(plane_grow_scale * (float)etu_per_update), 100),
148        MIN((int)(land_grow_scale * (float)etu_per_update), 100));
149     pr("Maintenance cost per update\t--\t%0.1f%%\t%0.1f%%\t%0.1f%%\n",
150        money_ship * -100.0 * etu_per_update,
151        money_plane * -100.0 * etu_per_update,
152        money_land * -100.0 * etu_per_update);
153     pr("Max interdiction range\t\t%d\t%d\t--\t%d\n",
154        fort_max_interdiction_range,
155        ship_max_interdiction_range,
156        land_max_interdiction_range);
157     pr("\n");
158     pr("The maximum amount of mobility used for land unit combat is %0.2f.\n",
159        combat_mob);
160     if (opt_MOB_ACCESS)
161         pr("The starting mobility when acquiring a sector or unit is %d.\n",
162            -(etu_per_update / sect_mob_neg_factor));
163     pr("\n");
164     if (opt_FUEL)
165         pr("For ships and land units, fuelu makes %d mobility.\n\n",
166            fuel_mult);
167     pr("Ships on autonavigation may use %i cargo holds per ship.\n", TMAX);
168     if (opt_TRADESHIPS) {
169         pr("Trade-ships that go at least %d sectors get a return of %.1f%% per sector.\n",
170            trade_1_dist, trade_1 * 100.0);
171         pr("Trade-ships that go at least %d sectors get a return of %.1f%% per sector.\n",
172            trade_2_dist, trade_2 * 100.0);
173         pr("Trade-ships that go at least %d sectors get a return of %.1f%% per sector.\n",
174            trade_3_dist, trade_3 * 100.0);
175         pr("Cashing in trade-ships with an ally nets you a %.1f%% bonus.\n",
176            trade_ally_bonus * 100.0);
177         pr("Cashing in trade-ships with an ally nets your ally a %.1f%% bonus.\n\n",
178            trade_ally_cut * 100.0);
179     }
180     if (opt_MARKET) {
181         pr("The tax you pay on selling things on the trading block is %.1f%%\n",
182            (1.00 - tradetax) * 100.0);
183         pr("The tax you pay on buying commodities on the market is %.1f%%\n",
184            (buytax - 1.00) * 100.0);
185         pr("The amount of time to bid on commodities is %d seconds.\n",
186            MARK_DELAY);
187         pr("The amount of time to bid on a unit is %d seconds.\n\n",
188            TRADE_DELAY);
189     }
190
191     if (!ef_nelem(EF_NUKE_CHR))
192         pr("Nukes are disabled.\n");
193     else if (drnuke_const > MIN_DRNUKE_CONST) {
194         pr("In order to build a nuke, you need %1.2f times the tech level in research\n",
195            drnuke_const);
196         pr("\tExample: In order to build a 300 tech nuke, you need %d research\n\n",
197            (int)(300.0 * drnuke_const));
198     }
199
200     pr("Fire ranges are scaled by %.2f.\n", fire_range_factor);
201     pr("Flak damage is scaled by %0.2f.\n", flakscale);
202     pr("Torpedo damage is 2d%d+%d.\n", torpedo_damage, torpedo_damage - 2);
203     pr("The attack factor for para & assault troops is %0.2f.\n",
204        assault_penalty);
205     pr("%.0f%% of fallout leaks into each surrounding sector.\n",
206        fallout_spread * 100.0 * MIN(24, etu_per_update));
207     pr("Fallout decays by %.0f%% per update\n",
208        100.0 - (decay_per_etu + 6.0) * fallout_spread * MIN(24, etu_per_update) * 100.0);
209     pr("\n");
210     pr ("Damage to\t\t\tSpills to\n");
211     pr("\t      Sector  People  Mater.   Ships  Planes  LandU.\n");
212     pr("Sector\t\t --\t%3.0f%%\t100%%\t  0%%\t%3.0f%%\t%3.0f%%\n",
213        people_damage * 100.0, unit_damage / 0.07, unit_damage * 100.0);
214     pr("People\t\t%3.0f%%\t --\t --\t --\t --\t --\n",
215        collateral_dam * 100.0);
216     pr("Materials\t%3.0f%%\t --\t --\t --\t --\t --\n",
217        collateral_dam * 100.0);
218     pr("Efficiency\t%3.0f%%\t --\t --\t --\t --\t --\n",
219        collateral_dam * 100.0);
220     pr("Ships\t\t%3.0f%%\t100%%\t100%%\t --\t  0%%\t  0%%\n",
221        collateral_dam * 100.0);
222     pr("Planes\t\t%3.0f%%\t  0%%\t  0%%\t --\t --\t --\n",
223        collateral_dam * 100.0);
224     pr("Land units\t%3.0f%%\t  0%%\t100%%\t --\t  0%%\t  0%%\n",
225        collateral_dam * 100.0);
226     pr("\n");
227     pr("You can have at most %d BTUs.\n", max_btus);
228     pr("You are disconnected after %d minutes of idle time.\n", max_idle);
229     pr("\nOptions enabled in this game:\n        ");
230     show_opts(1);
231     pr("\n\nOptions disabled in this game:\n        ");
232     show_opts(0);
233     pr("\n\nSee \"info Options\" for a detailed list of options and descriptions.\n");
234     show_custom();
235     pr("\nThe person to annoy if something goes wrong is:\n\t%s\n\t(%s).\n",
236        privname, privlog);
237     pr("\nYou can get your own copy of the source from "
238        "http://www.wolfpackempire.com/\n\n");
239     pr("%s", legal);
240     return RET_OK;
241 }
242
243 static void
244 show_custom(void)
245 {
246     char *sep = "\nCustomized in this game:\n        ";
247     int i;
248
249     /* TODO wrap long lines */
250     for (i = 0; i < EF_MAX; i++) {
251         if (ef_flags(i) & EFF_CUSTOM) {
252             pr("%s%s", sep, ef_nameof(i));
253             sep = ", ";
254         }
255     }
256     if (*sep == ',')
257         pr("\nCheck \"show\" for details.\n");
258 }
259
260 static void
261 show_opts(int val)
262 {
263     int col;
264     char *sep;
265     struct keymatch *kp;
266
267     sep = "";
268     col = 0;
269     for (kp = configkeys; kp->km_key; kp++) {
270         if (!(kp->km_flags & KM_OPTION))
271             continue;
272         if (CANT_HAPPEN(kp->km_type != NSC_INT))
273             continue;
274         if (!*(int *)kp->km_data != !val)
275             continue;
276         col += strlen(sep) + strlen(kp->km_key);
277         if (col > 70) {
278             pr(",\n        ");
279             sep = "";
280             col = strlen(kp->km_key);
281         }
282         pr("%s%s", sep, kp->km_key);
283         sep = ", ";
284     }
285 }