New command show updates:

(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.
This commit is contained in:
Markus Armbruster 2007-07-15 13:34:22 +00:00
parent 87eeea32c9
commit a57645340c
12 changed files with 111 additions and 26 deletions

View 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)

View 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;
}

View 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");

View 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},

View file

@ -32,13 +32,14 @@
* 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"
@ -50,8 +51,11 @@
#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;
}