(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
|
@ -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