Clean up how quit and server shutdown trigger connection close

Simply set the player connection's EOF indicator.  Cleaner than
setting player->state to PS_SHUTDOWN from random places.

Move the assignment of PS_PLAYING from player_main() to its caller
play_cmd(), so that player->state is exclusively controlled in
login.c.
This commit is contained in:
Markus Armbruster 2012-01-29 10:44:28 +01:00
parent 0a7306a5ac
commit 8549efbc19
3 changed files with 7 additions and 7 deletions

View file

@ -59,7 +59,6 @@ player_main(struct player *p)
struct natstr *natp;
char buf[128];
p->state = PS_PLAYING;
player = p;
time(&player->curup);
update_timeused_login(player->curup);
@ -174,7 +173,6 @@ status(void)
time(&player->curup);
update_timeused(player->curup);
if (io_error(player->iop) || io_eof(player->iop)
|| player->state == PS_SHUTDOWN
|| !may_play_now(natp, player->curup))
return 0;
@ -284,7 +282,7 @@ show_motd(void)
int
quit(void)
{
player->state = PS_SHUTDOWN;
io_set_eof(player->iop);
return RET_OK;
}