]> git.pond.sub.org Git - empserver/commitdiff
New command show updates:
authorMarkus Armbruster <armbru@pond.sub.org>
Sun, 15 Jul 2007 13:34:22 +0000 (13:34 +0000)
committerMarkus Armbruster <armbru@pond.sub.org>
Sun, 15 Jul 2007 13:34:22 +0000 (13:34 +0000)
(show): New sub-command.
(player_coms): Update its c_form.
(show_updates, fmttime2822): New.

(vers): Show game_days and game_hours.

(upda): Mark obsolete and point to show updates.
(vers): Point to show rather than update.

Rewrite much of info zdone.

12 files changed:
include/prototypes.h
info/disable.t
info/enable.t
info/show.t
info/update.t
info/version.t
info/zdone.t
src/lib/commands/show.c
src/lib/commands/upda.c
src/lib/commands/vers.c
src/lib/player/empmod.c
src/lib/subs/show.c

index f1b6bb289e7e9496e0529c0b363ca672004cad01..4a381ba053c24b1f1a2ab8ec6ab7b00d5f2265cd 100644 (file)
@@ -655,6 +655,7 @@ extern void show_sect_stats(int);
 extern void show_sect_capab(int);
 extern void show_item(int);
 extern void show_news(int);
+extern void show_updates(int);
 /* shpsub.c */
 extern void shp_sel(struct nstr_item *, struct emp_qelem *);
 extern void shp_nav(struct emp_qelem *, double *, double *, int *, natid);
index 946933e2590738d5d6e04b97d8224ed99644bdbb..32196a2a3590250a6883f2e1aba11ccb5666a875 100644 (file)
@@ -2,8 +2,8 @@
 .NA disable "Disable Updates"
 .LV Expert
 .SY "disable"
-No updates will fire if you disable them.  "UPDATES ARE DISABLED" will
-show up in the output of the "update" command.
+No updates will fire if you disable them.  The \*Qshow updates\*U
+command will report the fact.
 .s1
 Disabling updates this way does not stop the Empire clock.  Stuff
 using the clock, like BTU growth, continues normally.  Should a
@@ -13,6 +13,6 @@ between updates.  This effectively stops the clock.
 .s1
 You should not use this command as a tool for implementing your update
 schedule!  Enabling and disabling updates by hand is far too error
-prone, and your players can't trust the update command to find out
+prone, and your players can't trust the show command to find out
 when the next update really is.  Use the update schedule file instead.
-.SA "update, disable, Time, Deity"
+.SA "disable, show, Time, Deity"
index 7c672d398ac39c911c65a130d78f824fcebeb9d2..390fd3b9dba93f6b377b57e1bd5b531cddd7d11a 100644 (file)
@@ -3,4 +3,4 @@
 .LV Expert
 .SY "enable"
 If updates have been disabled, then this will enable them again.
-.SA "update, enable, force, Deity"
+.SA "disable, show, force, Deity"
index 9156decc4862eb7340d26ec7a30d52dc5bb0613c..568250795b58513a3e532f3d39f8ff4ace806c36 100644 (file)
@@ -3,11 +3,12 @@
 .LV Basic
 .SY "show <land|nuke|plane|sector|ship> [b|s|c] [tech]"
 .SY "show <bridge|item|news|tower>"
+.SY "show <updates> [number]"
 The show command shows characteristics of sectors, units (ships,
 planes, land units and nukes), bridges (spans and towers), items and
-news.
+news, as well as information on updates.
 .s1
-The format of each output is more fully described in separate info
+Characteristics are more fully described in separate info
 pages (Ship-types, Nuke-types, etc.).
 .s1
 For sectors and units, a
@@ -35,4 +36,4 @@ Printing for tech level '325'
 75kt  fusion     3  90   3  320 106 $  20000 
 .FI
 .s1
-.SA "Ship-types, Nuke-types, Plane-types, Unit-types, Sector-types, Ships, Planes, LandUnits, Nukes, Bridges, Item-types, newspaper"
+.SA "Ship-types, Nuke-types, Plane-types, Unit-types, Sector-types, Ships, Planes, LandUnits, Nukes, Bridges, Item-types, newspaper, Updates"
index bb7d0e56f39e1223c5121d93ceecb3bc7f0b2165..9874439e452ee124bc677059fbce775556599ccb 100644 (file)
@@ -5,4 +5,4 @@
 The update command shows you when the next update will occur, and
 describes the current update policies.
 .sp
-.SA "zdone, Updates"
+.SA "show, zdone, Obsolete"
index fc71850dbedef15581f4f76a7e5ccd27b6e70b81..9eeb62197647cad9acb4d112817fef38d67dc92f 100644 (file)
@@ -19,8 +19,7 @@ World size is 64 by 32.
 There can be up to 99 countries.
 By default, countries use their own coordinate system.
 
-An Empire time unit is 10 seconds long.
-Use the 'update' command to find out the time of the next update.
+Use the 'show' command to find out the time of the next update.
 The current time is Tue Jul 10 23:09:03.
 An update consists of 60 empire time units.
 Each country is allowed to be logged in 1440 minutes a day.
index d37a2f73662a7d93d85c87e2a327f014dfbaf87e..7f8e77404b5fca5b923a7ca55c6ca7812deba42e 100644 (file)
@@ -11,20 +11,25 @@ for an update.
 .s1
 "check" checks to see what your zdone state is.
 .s1
-The command will also show you how many countries want
-an update.  There are 3 possible update policies which could
-be set in this game.  The update policy is shown in the update command.
+The command will also show you how many countries want an update.  The
+number of ready countries required for a demand update to happen is
+configurable, and may be seen in the \*Qshow updates\*U command.
 .s1
-Your zdone state is cleared when an update occurs.
+There are three possible update policies which could be set in this
+game:
 .s1
 1. No demand updates.  If so, then this command is useless.
 .s1
-2. Updates occur upon demand, right after the last person sets
-zdone.  The threshold at which a demand update occurs is configurable,
-and may be seen in the update command.
+2. Demand updates occur right after the last required country sets
+zdone.
+.s1
+3. Demand updates occur according to the update schedule.  If enough
+countries have set zdone by the scheduled time, then an update will
+occur.  The update schedule may be seen in the \*Qshow updates\*U
+command.
+.s1
+Your zdone state is cleared when an update occurs.
 .s1
-3. Demand updates occur at specific times.  If enough countries
-have set zdone at one of those times, then an update will occur.
-The times may be seen in the update command.
+The \*Qshow updates\*U command shows update policy and schedule.
 .sp
-.SA "update, Playing"
+.SA "show, Updates"
index 3e40dc7fbb01bf6dc21aca92803cfdfa0e17b022..71b57c12e4c872f1395b7bc4cfd3548aa4faaf42 100644 (file)
@@ -51,7 +51,7 @@ show(void)
     int rlev;
 
     if (!(p = getstarg(player->argp[1],
-                      "Describe what (plane, nuke, bridge, ship, sect, land unit, tower, item)? ",
+                      "Show what (bridge, item, land, nuke, plane, sect, ship, tower, updates)?",
                       buf))
        || !*p)
        return RET_SYN;
@@ -113,9 +113,13 @@ show(void)
            cfunc = show_ship_capab;
        }
        break;
+    case 'u':
+       show_updates(player->argp[2] ? atoi(player->argp[2]) : 8);
+       return RET_OK;
     default:
        return RET_SYN;
     }
+
     if (!(p = getstarg(player->argp[2],
                       "Build, stats, or capability data (b,s,c)? ", buf))
        || !*p)
index cf1dde74f5b6d1a19c7ab49f979fb9b997a2b05c..7d9f18b3d9f20af3ad669d616c65f850ec7000be 100644 (file)
@@ -95,5 +95,7 @@ upda(void)
     if (*game_hours != 0)
        pr("Game hours are: %s\n", game_hours);
 
+    pr("\nThis command is obsolete and will go away in a future version.\n"
+       "Please use \"show updates\".");
     return 0;
 }
index 81846e049d6a6cc1d60e26eefd2bd697c37c3036..e345bb0bd0c58fe98a56be62739179f8eb97d45c 100644 (file)
@@ -61,11 +61,15 @@ vers(void)
     pr("By default, countries use %s coordinate system.\n",
        (players_at_00) ? "the deity's" : "their own");
     pr("\n");
-    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");
index d2fcc12c35183b465a062856dd487e585118c97a..ef75bad3f947d5ccfcd676e6b6372fb22e068bb0 100644 (file)
@@ -229,7 +229,9 @@ struct cmndstr player_coms[] = {
     {"shark <LOAN>", 25, shark, C_MOD, NORM + MONEY + CAP},
     {"ship <SHIPS>", 0, shi, 0, NORM},
     {"shoot <c|u> <SECTS> <NUMBER>", 3, shoo, C_MOD, NORM + MONEY + CAP},
-    {"show <TYPE|\"bridge\"|\"tower\"> <\"build\"|\"stats\"|\"cap\"> [<tech>]",
+    {"show <TYPE> <\"build\"|\"stats\"|\"cap\"> [<tech>]\n"
+     "\tshow <bridge|tower>\n"
+     "\tshow updates [<NUM>]>",
      0, show, 0, VIS},
     {"shutdown <minutes> <disable update?>", 0, shut, 0, GOD},
     {"sinfrastructure <SECTS>", 0, sinfra, 0, VIS},
index f0f82f2572831a9f55103f2ba00c59a446263419..5de8127b2dae7d11ad44311a1a588965a6274d0e 100644 (file)
  *     Jeff Bailey, 1990
  *     Steve McClure, 1996
  *     Ron Koenderink, 2005
- *     Markus Armbruster, 2006
+ *     Markus Armbruster, 2006-2007
  */
 
 #include <config.h>
 
 #include <math.h>
 #include "file.h"
+#include "game.h"
 #include "item.h"
 #include "land.h"
 #include "nat.h"
 #include "product.h"
 #include "prototypes.h"
 #include "sect.h"
+#include "server.h"
 #include "ship.h"
 
+static char *fmttime2822(time_t);
+
 struct look_list {
     union {
        struct lchrstr *lp;
@@ -654,3 +658,66 @@ show_news(int tlev)
            pr("    %s\n", rpt[i].r_newstory[j]);
     }
 }
+
+/*
+ * Show update policy and up to N scheduled updates.
+ */
+void
+show_updates(int n)
+{
+    struct gamestr *game = game_tick_tick();
+    int demand = 0;
+    int i;
+
+    pr("%s, Turn %d, ETU %d\n", fmttime2822(time(NULL)),
+       game->game_turn, game->game_tick);
+
+    if (update_time[0]) {
+       if (update_demand == UPD_DEMAND_SCHED) {
+           pr("Demand updates occur according to schedule:\n");
+           demand = 1;
+       } else
+           pr("Updates occur according to schedule:\n");
+       for (i = 0; i < n && update_time[i]; i++)
+           pr("%3d.  %s\n", game->game_turn + i,
+              fmttime2822(update_time[i]));
+       if (update_window) {
+           pr("Updates occur within %d seconds after the scheduled time\n",
+              update_window);
+       }
+    } else
+       pr("There are no updates scheduled.\n");
+
+    if (update_demand == UPD_DEMAND_ASYNC) {
+       pr("Demand updates occur right after the demand is set.\n");
+       if (*update_demandtimes != 0) {
+           pr("Demand updates are allowed during: %s\n",
+              update_demandtimes);
+       }
+       demand = 1;
+    }
+
+    if (demand) {
+       pr("Demand updates require %d country(s) to want one.\n",
+          update_wantmin);
+    }
+
+    if (updates_disabled())
+       pr("\nUPDATES ARE DISABLED!\n");
+}
+
+/*
+ * Return T formatted according to RFC 2822.
+ * The return value is statically allocated and overwritten on
+ * subsequent calls.
+ */
+static char *
+fmttime2822(time_t t)
+{
+    static char buf[32];
+    int n = strftime(buf, sizeof(buf), "%a, %d %b %Y %T %z",
+                    localtime(&t));
+    if (CANT_HAPPEN(n == 0))
+       buf[0] = 0;
+    return buf;
+}