diff --git a/include/nat.h b/include/nat.h index cd0aa6eb..7916f9f4 100644 --- a/include/nat.h +++ b/include/nat.h @@ -65,8 +65,8 @@ struct natstr { char nat_cnam[20]; /* country name */ char nat_pnam[20]; /* representative */ char nat_hostaddr[32]; /* host addr of last user */ - char nat_hostname[512]; /* hostname of last user */ - char nat_userid[32]; /* userid of last user */ + char nat_hostname[512]; /* hostname of last user, may be empty */ + char nat_userid[32]; /* userid of last user, may be empty */ coord nat_xstart, nat_ystart; /* cap location at start */ coord nat_xcap, nat_ycap; /* cap location in abs coords */ coord nat_xorg, nat_yorg; /* origin location in abs coords */ @@ -79,8 +79,8 @@ struct natstr { short nat_btu; /* bureaucratic time units */ long nat_reserve; /* military reserves */ long nat_money; /* moola */ - time_t nat_last_login; /* time of last login */ - time_t nat_last_logout; /* time of last logout */ + time_t nat_last_login; /* time of last login, 0 menas never */ + time_t nat_last_logout; /* time of last logout, 0 means never */ time_t nat_newstim; /* date news last read */ time_t nat_annotim; /* date annos last read */ float nat_level[4]; /* technology, etc */ diff --git a/src/lib/commands/add.c b/src/lib/commands/add.c index cbdceba6..3d9fa859 100644 --- a/src/lib/commands/add.c +++ b/src/lib/commands/add.c @@ -214,8 +214,7 @@ add(void) natp->nat_dayno = 0; natp->nat_minused = 0; memset(natp->nat_b, 0, sizeof(natp->nat_b)); - (void)time(&natp->nat_last_login); - (void)time(&natp->nat_last_logout); + natp->nat_last_login = natp->nat_last_login = 0; natp->nat_money = 0; natp->nat_level[NAT_TLEV] = start_technology; natp->nat_level[NAT_RLEV] = start_research; diff --git a/src/lib/player/player.c b/src/lib/player/player.c index 9f10d5c8..00879d86 100644 --- a/src/lib/player/player.c +++ b/src/lib/player/player.c @@ -93,34 +93,21 @@ player_main(struct player *p) pr("Time exceeded today\n"); return; } - if ((*natp->nat_hostaddr && - *player->hostaddr && - strcmp(natp->nat_hostaddr, player->hostaddr)) || - (*natp->nat_userid && - *player->userid && strcmp(natp->nat_userid, player->userid))) { - if (natp->nat_stat != VIS) { - pr("Last connection from: %s", ctime(&natp->nat_last_login)); - pr(" to: %s", natp->nat_last_login < - natp->nat_last_logout ? ctime(&natp-> - nat_last_logout) : "?"); - pr(" by: %s@%s\n", - *natp->nat_userid ? natp->nat_userid : "nobody", - *natp->nat_hostname ? natp->nat_hostname - : *natp->nat_hostaddr ? natp->nat_hostaddr : "nowhere"); - } + if (natp->nat_stat != VIS + && natp->nat_last_login + && (strcmp(natp->nat_hostaddr, player->hostaddr) + || strcmp(natp->nat_userid, player->userid))) { + pr("Last connection from: %s", ctime(&natp->nat_last_login)); + pr(" to: %s", + natp->nat_last_login <= natp->nat_last_logout + ? ctime(&natp->nat_last_logout) : "?"); + pr(" by: %s@%s\n", + natp->nat_userid, + *natp->nat_hostname ? natp->nat_hostname : natp->nat_hostaddr); } - if (*player->userid) - strcpy(natp->nat_userid, player->userid); - else - strcpy(natp->nat_userid, "nobody"); - - if (*player->hostname) - strcpy(natp->nat_hostname, player->hostname); - else - strcpy(natp->nat_hostname, "nowhere"); - - if (*player->hostaddr) - strcpy(natp->nat_hostaddr, player->hostaddr); + strcpy(natp->nat_userid, player->userid); + strcpy(natp->nat_hostname, player->hostname); + strcpy(natp->nat_hostaddr, player->hostaddr); time(&natp->nat_last_login); putnat(natp);