]> git.pond.sub.org Git - empserver/blobdiff - src/lib/commands/vers.c
Remove option TRADESHIPS, customize table ship-chr instead
[empserver] / src / lib / commands / vers.c
index f33c89ee527b33e6d2932f5fc074ac7fa03c4c7a..31116dbc9fbd8ae9a96812ffcce81ba39c885d35 100644 (file)
@@ -1,11 +1,11 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2007, Dave Pare, Jeff Bailey, Thomas Ruschak,
- *                           Ken Stevens, Steve McClure
+ *  Copyright (C) 1986-2011, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *                Ken Stevens, Steve McClure, Markus Armbruster
  *
- *  This program is free software; you can redistribute it and/or modify
+ *  Empire is free software: you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
+ *  the Free Software Foundation, either version 3 of the License, or
  *  (at your option) any later version.
  *
  *  This program is distributed in the hope that it will be useful,
@@ -14,8 +14,7 @@
  *  GNU General Public License for more details.
  *
  *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *
  *  ---
  *
@@ -26,7 +25,7 @@
  *  ---
  *
  *  vers.c: Print out the Empire version
- * 
+ *
  *  Known contributors to this file:
  *     Dave Pare
  *     Jeff Bailey
@@ -34,7 +33,7 @@
  *     Ken Stevens
  *     Steve McClure
  *     Ron Koenderink, 2005-2006
- *     Markus Armbruster, 2005-2006
+ *     Markus Armbruster, 2005-2011
  */
 
 #include <config.h>
 #include "ship.h"
 #include "version.h"
 
+static int have_trade_ships(void);
 static void show_custom(void);
 static void show_opts(int val);
+static char *prwrap(char *, char *, int *);
 
 int
 vers(void)
@@ -61,13 +62,15 @@ vers(void)
     pr("By default, countries use %s coordinate system.\n",
        (players_at_00) ? "the deity's" : "their own");
     pr("\n");
-    pr("An Empire time unit is %d second%s long.\n",
-       s_p_etu, s_p_etu != 1 ? "s" : "");
-    pr("Use the 'update' command to find out the time of the next update.\n");
+    pr("Use the 'show' command to find out the time of the next update.\n");
     pr("The current time is %19.19s.\n", ctime(&now));
     pr("An update consists of %d empire time units.\n", etu_per_update);
     pr("Each country is allowed to be logged in %d minutes a day.\n",
        m_m_p_d);
+    if (*game_days != 0)
+       pr("Game days are %s\n", game_days);
+    if (*game_hours != 0)
+       pr("Game hours are %s\n", game_hours);
     pr("It takes %.2f civilians to produce a BTU in one time unit.\n",
        (1.0 / (btu_build_rate * 100.0)));
     pr("\n");
@@ -98,8 +101,6 @@ vers(void)
     if (rollover_avail_max)
        pr("Up to %d avail can roll over an update.\n",
           rollover_avail_max);
-    if (opt_SLOW_WAR)
-       pr("Declaring war will cost you $%i\n\n", War_Cost);
     pr("Happiness p.e. requires 1 happy stroller per %d civ.\n",
        (int)hap_cons / etu_per_update);
     pr("Education p.e. requires 1 class of graduates per %d civ.\n",
@@ -116,7 +117,7 @@ vers(void)
     pr("Nation levels (tech etc.) decline 1%% every %d time units.\n",
        (int)(level_age_rate));
 
-    pr("Tech Buildup is ");
+    pr("Tech buildup is ");
     if (tech_log_base <= 1.0) {
        pr("not limited\n");
     }
@@ -136,10 +137,6 @@ vers(void)
        (int)(ship_mob_scale * (float)etu_per_update),
        (int)(plane_mob_scale * (float)etu_per_update),
        (int)(land_mob_scale * (float)etu_per_update));
-    pr("Mission mobility cost\t\t--\t%d\t%d\t%d\n",
-       ldround((mission_mob_cost * (double)ship_mob_max), 1),
-       ldround((mission_mob_cost * (double)plane_mob_max), 1),
-       ldround((mission_mob_cost * (double)land_mob_max), 1));
     pr("Max eff gain per update\t\t--\t%d\t%d\t%d\n",
        MIN((int)(ship_grow_scale * (float)etu_per_update), 100),
        MIN((int)(plane_grow_scale * (float)etu_per_update), 100),
@@ -156,14 +153,11 @@ vers(void)
     pr("The maximum amount of mobility used for land unit combat is %0.2f.\n",
        combat_mob);
     if (opt_MOB_ACCESS)
-        pr("The starting mobility when acquiring a sector or unit is %d.\n",
+       pr("The starting mobility when acquiring a sector or unit is %d.\n",
           -(etu_per_update / sect_mob_neg_factor));
     pr("\n");
-    if (opt_FUEL)
-       pr("For ships and land units, fuelu makes %d mobility.\n\n",
-          fuel_mult);
     pr("Ships on autonavigation may use %i cargo holds per ship.\n", TMAX);
-    if (opt_TRADESHIPS) {
+    if (have_trade_ships()) {
        pr("Trade-ships that go at least %d sectors get a return of %.1f%% per sector.\n",
           trade_1_dist, trade_1 * 100.0);
        pr("Trade-ships that go at least %d sectors get a return of %.1f%% per sector.\n",
@@ -205,7 +199,7 @@ vers(void)
     pr("Fallout decays by %.0f%% per update\n",
        100.0 - (decay_per_etu + 6.0) * fallout_spread * MIN(24, etu_per_update) * 100.0);
     pr("\n");
-    pr ("Damage to\t\t\tSpills to\n");
+    pr("Damage to\t\t\tSpills to\n");
     pr("\t      Sector  People  Mater.   Ships  Planes  LandU.\n");
     pr("Sector\t\t --\t%3.0f%%\t100%%\t  0%%\t%3.0f%%\t%3.0f%%\n",
        people_damage * 100.0, unit_damage / 0.07, unit_damage * 100.0);
@@ -224,9 +218,9 @@ vers(void)
     pr("\n");
     pr("You can have at most %d BTUs.\n", max_btus);
     pr("You are disconnected after %d minutes of idle time.\n", max_idle);
-    pr("\nOptions enabled in this game:\n        ");
+    pr("\nOptions enabled in this game:\n");
     show_opts(1);
-    pr("\n\nOptions disabled in this game:\n        ");
+    pr("\n\nOptions disabled in this game:\n");
     show_opts(0);
     pr("\n\nSee \"info Options\" for a detailed list of options and descriptions.\n");
     show_custom();
@@ -238,18 +232,29 @@ vers(void)
     return RET_OK;
 }
 
+static int
+have_trade_ships(void)
+{
+    int i;
+
+    for (i = ef_nelem(EF_SHIP_CHR) - 1; i >= 0; i--) {
+       if (mchr[i].m_flags & M_TRADE)
+           return 1;
+    }
+    return 0;
+}
+
 static void
 show_custom(void)
 {
-    char *sep = "\nCustomized in this game:\n        ";
-    int i;
+    char *sep;
+    int col, i;
 
-    /* TODO wrap long lines */
+    sep = "\nCustomized in this game:\n\t";
+    col = 0;
     for (i = 0; i < EF_MAX; i++) {
-       if (ef_flags(i) & EFF_CUSTOM) {
-           pr("%s%s", sep, ef_nameof(i));
-           sep = ", ";
-       }
+       if (ef_flags(i) & EFF_CUSTOM)
+           sep = prwrap(sep, ef_nameof(i), &col);
     }
     if (*sep == ',')
        pr("\nCheck \"show\" for details.\n");
@@ -258,11 +263,11 @@ show_custom(void)
 static void
 show_opts(int val)
 {
-    int col;
     char *sep;
+    int col;
     struct keymatch *kp;
 
-    sep = "";
+    sep = "\t";
     col = 0;
     for (kp = configkeys; kp->km_key; kp++) {
        if (!(kp->km_flags & KM_OPTION))
@@ -271,13 +276,21 @@ show_opts(int val)
            continue;
        if (!*(int *)kp->km_data != !val)
            continue;
-       col += strlen(sep) + strlen(kp->km_key);
-       if (col > 70) {
-           pr(",\n        ");
-           sep = "";
-           col = strlen(kp->km_key);
-       }
-       pr("%s%s", sep, kp->km_key);
-       sep = ", ";
+       sep = prwrap(sep, kp->km_key, &col);
+    }
+}
+
+static char *
+prwrap(char *sep, char *it, int *col)
+{
+    size_t len = strlen(it);
+
+    if (*col != 0 && *col + len > 70) {
+       sep = ",\n\t";
+       *col = 0;
     }
+    pr("%s%s", sep, it);
+    sep = ", ";
+    *col += len + 2;
+    return sep;
 }