(add): Initialize nat_last_login and nat_last_logout to zero rather
than current time. Nation addition time is irrelevant. (natstr): Document zero nat_last_login, nat_last_login mean never logged in/out. (player_main): Test nat_last_login zero instead of nat_hostaddr empty. (player_main): Assign nat_userid, nat_hostname, nat_hostaddr straight from player. The last connection's host is now shown as dotted quads instead of nowhere when the name isn't known. (natstr): Document that nat_userid, nat_hostname may be empty. (player_main): Simplify printing last connection address: nat_hostaddr can't be empty here; don't bother to substitute "nobody" for empty user.
This commit is contained in:
parent
95d2b48ee2
commit
f94f81ee16
3 changed files with 19 additions and 33 deletions
|
@ -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 */
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue