Represent logged in time in seconds rather than minutes

This simplifies things.  In particular, it gets rid of random rounding
in getcommand(), which created a variation in the nightly build
depending on whether the update starts before or after the deity logs
out.

Replace struct natstr member nat_minused by nat_timeused, and update
cou_ca[] accordingly (this affects xdump nat).  Replace player member
minleft by timeleft, and getminleft() by gettimeleft().  Update
getcommand(), daychange(), player_main(), status() accordingly, taking
care not to change player output.  Change edit country key 'u' to work
in seconds.
This commit is contained in:
Ron Koenderink 2008-10-28 08:48:25 -06:00
parent 436328f641
commit 14319b89ec
10 changed files with 40 additions and 42 deletions

View file

@ -78,7 +78,7 @@ getcommand(char *combufp)
player_commands_index, player->cnum);
do {
prprompt(natp->nat_minused, natp->nat_btu);
prprompt(natp->nat_timeused / 60, natp->nat_btu);
buf[0] = 0;
if (recvclient(buf, 1024) < 0) {
return -1;
@ -223,23 +223,23 @@ daychange(time_t now)
tm = localtime(&now);
if ((tm->tm_yday % 128) != natp->nat_dayno) {
natp->nat_dayno = tm->tm_yday % 128;
natp->nat_minused = 0;
natp->nat_timeused = 0;
}
}
int
getminleft(time_t now, int mpd)
gettimeleft(time_t now, int mpd)
{
struct tm *tm;
int nminleft;
int nsecleft;
struct natstr *natp;
int n;
tm = localtime(&now);
natp = getnatp(player->cnum);
nminleft = mpd - natp->nat_minused;
n = 60 * 24 - (tm->tm_min + tm->tm_hour * 60);
if (n < nminleft)
nminleft = n;
return nminleft;
nsecleft = mpd * 60 - natp->nat_timeused;
n = 60 * 60 * 24 - (tm->tm_sec + tm->tm_min * 60 + tm->tm_hour * 3600);
if (n < nsecleft)
nsecleft = n;
return nsecleft;
}