From 5dabef2707a826e50cd5ed2b2034b3c691d244ce Mon Sep 17 00:00:00 2001 From: Markus Uhlin Date: Mon, 29 Apr 2024 22:51:50 +0200 Subject: Reformatted process_input() --- FICS/command.c | 81 +++++++++++++++++++++++++++++++--------------------------- 1 file changed, 44 insertions(+), 37 deletions(-) (limited to 'FICS') diff --git a/FICS/command.c b/FICS/command.c index 1063e92..f543160 100644 --- a/FICS/command.c +++ b/FICS/command.c @@ -866,48 +866,55 @@ PRIVATE int process_prompt(int p, char *command) } /* Return 1 to disconnect */ -PUBLIC int process_input(int fd, char *com_string) +PUBLIC int +process_input(int fd, char *com_string) { - int p = player_find(fd); - int retval = 0; + int p = player_find(fd); + int retval = 0; - if (p < 0) { - fprintf(stderr, "FICS: Input from a player not in array!\n"); - return -1; - } + if (p < 0) { + fprintf(stderr, "FICS: Input from a player not in array!\n"); + return -1; + } - commanding_player = p; - parray[p].last_command_time = time(0); + commanding_player = p; + parray[p].last_command_time = time(0); + + switch (parray[p].status) { + case PLAYER_EMPTY: + fprintf(stderr, "FICS: Command from an empty player!\n"); + break; + case PLAYER_NEW: + fprintf(stderr, "FICS: Command from a new player!\n"); + break; + case PLAYER_INQUEUE: + // Ignore input from player in queue + break; + case PLAYER_LOGIN: + retval = process_login(p, com_string); + + if (retval == COM_LOGOUT && com_string != NULL) { + fprintf(stderr, "%s tried to log in and failed.\n", + com_string); + } - switch (parray[p].status) { - case PLAYER_EMPTY: - fprintf(stderr, "FICS: Command from an empty player!\n"); - break; - case PLAYER_NEW: - fprintf(stderr, "FICS: Command from a new player!\n"); - break; - case PLAYER_INQUEUE: - /* Ignore input from player in queue */ - break; - case PLAYER_LOGIN: - retval = process_login(p, com_string); - if (retval == COM_LOGOUT && com_string != NULL) - fprintf (stderr, "%s tried to log in and failed.\n", com_string); - break; - case PLAYER_PASSWORD: - retval = process_password(p, com_string); - break; - case PLAYER_PROMPT: - parray[p].busy[0] = '\0'; - /* added this to stop buggy admin levels; shane */ - if (parray[p].adminLevel < 10) - parray[p].adminLevel = 0; - retval = process_prompt(p, com_string); - break; - } + break; + case PLAYER_PASSWORD: + retval = process_password(p, com_string); + break; + case PLAYER_PROMPT: + parray[p].busy[0] = '\0'; - commanding_player = -1; - return retval; + // added this to stop buggy admin levels; shane + if (parray[p].adminLevel < 10) + parray[p].adminLevel = 0; + + retval = process_prompt(p, com_string); + break; + } + + commanding_player = -1; + return retval; } PUBLIC int -- cgit v1.2.3