Rewrite accounting of play time

Replace daychange() and gettimeleft() by update_timeused_login(),
update_timeused() and enforce_minimum_session_time().  The new
code doesn't assume the day is always 24 hours long which can
occur when transitioning into or out of DST and such.  Logging
in after more a multiple of 128 days now resets nat_timeused
properly.

Fix nat_timeused calculation on midnight rollover to include
the time since midnight.

struct natstr member nat_dayno and struct player member timeleft
are now unused, remove them.
This commit is contained in:
Ron Koenderink 2008-11-15 13:08:19 -06:00
parent f46dc55254
commit 875a80d14f
8 changed files with 69 additions and 74 deletions

View file

@ -95,7 +95,6 @@ struct natstr {
char nat_userid[32]; /* userid of last user, may be empty */
coord nat_xcap, nat_ycap; /* cap location in abs coords */
coord nat_xorg, nat_yorg; /* origin location in abs coords */
signed char nat_dayno; /* day of the year mod 128 */
signed char nat_update; /* Want an update or not. */
unsigned short nat_tgms; /* # of telegrams to be announced */
unsigned short nat_ann; /* # of annos pending */

View file

@ -67,8 +67,7 @@ struct player {
char *argp[128]; /* arguments, ASCII, valid if command */
char *condarg; /* conditional, ASCII, valid if command */
char *comtail[128]; /* start of args in combuf[] */
time_t lasttime; /* when timeleft was last debited */
int timeleft;
time_t lasttime; /* when nat_timeused was last updated */
int btused;
int god;
int owner;

View file

@ -367,8 +367,9 @@ extern int getcommand(char *);
extern void init_player_commands(void);
extern void log_last_commands(void);
extern int gamedown(void);
extern void daychange(time_t);
extern int gettimeleft(time_t, int);
extern void update_timeused_login(time_t now);
extern void update_timeused(time_t now);
extern void enforce_minimum_session_time(void);
/* more under Commands */
/* empmod.c */
/* init_nats.c */