/*
* Empire - A multi-player, client/server Internet based war game.
- * Copyright (C) 1986-2008, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ * Copyright (C) 1986-2010, Dave Pare, Jeff Bailey, Thomas Ruschak,
* Ken Stevens, Steve McClure
*
* This program is free software; you can redistribute it and/or modify
* ---
*
* login.c: Allow the player to login
- *
+ *
* Known contributors to this file:
* Dave Pare, 1994
* Steve McClure, 2000
- * Markus Armbruster, 2004-2008
+ * Markus Armbruster, 2004-2009
+ * Ron Koenderink, 2005-2009
*/
#include <config.h>
{"quit", 0, quit_cmd, 0, 0},
{"sanc", 0, sanc_cmd, 0, 0},
{"user name", 0, user_cmd, 0, 0},
- {0, 0, 0, 0, 0}
+ {NULL, 0, NULL, 0, 0}
};
/*ARGSUSED*/
char space[128];
int ac;
int cmd;
+ int res;
player->proc = empth_self();
pr_id(player, C_INIT, "Empire server ready\n");
- while (!io_eof(player->iop) && !io_error(player->iop)
- && player->state != PS_SHUTDOWN) {
- io_output(player->iop, IO_WAIT);
+ while (player->state != PS_SHUTDOWN) {
+ io_output(player->iop, 1);
if (io_gets(player->iop, buf, sizeof(buf)) < 0) {
- io_input(player->iop, IO_WAIT);
+ res = io_input(player->iop, 1);
+ if (res <= 0) {
+ if (res == 0 && !io_eof(player->iop))
+ pr_id(player, C_DATA, "idle connection terminated\n");
+ break;
+ }
continue;
}
ac = parse(buf, space, player->argp, NULL, NULL, NULL);
+ if (ac <= 0) {
+ pr_id(player, C_BADCMD, "Can't parse command\n");
+ continue;
+ }
cmd = comtch(player->argp[0], login_coms, 0);
if (cmd < 0) {
pr_id(player, C_BADCMD, "Command %s not found\n", player->argp[0]);
player->state = PS_SHUTDOWN;
if (!io_eof(player->iop)) {
pr_id(player, C_EXIT, "so long...\n");
- io_noblocking(player->iop, 0);
- while (io_output(player->iop, IO_WAIT) > 0) ;
+ while (io_output(player->iop, 1) > 0) ;
}
player_delete(player);
empth_exit();