From 604c4c45890bcb83510730b69e2fa4963a1f0824 Mon Sep 17 00:00:00 2001 From: Polonkai Gergely Date: Fri, 23 Mar 2012 16:10:07 +0000 Subject: [PATCH] Now setting client->authenticated to TRUE upon successful login Also reformatted long code lines --- src/networking.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/networking.c b/src/networking.c index 6db7355..fb30bb3 100644 --- a/src/networking.c +++ b/src/networking.c @@ -118,18 +118,28 @@ wmud_client_callback(GSocket *client, GIOCondition condition, wmudClient *client { if (wmud_player_auth(client_data)) { - wmud_client_send(client_data, "%c%c%cLogin successful.\r\n", TELNET_IAC, TELNET_WILL, TELNET_ECHO); + wmud_client_send(client_data, "%c%c%cLogin" + " successful.\r\n", TELNET_IAC, + TELNET_WILL, TELNET_ECHO); + client_data->authenticated = TRUE; /* TODO: Send fail count if non-zero */ client_data->state = WMUD_CLIENT_STATE_MENU; } else { - wmud_client_send(client_data, "%c%c%cThis password doesn't seem to be valid. Let's try it again...\r\nBy what name would you like to be called? ", TELNET_IAC, TELNET_WILL, TELNET_ECHO); + wmud_client_send(client_data, "%c%c%cThis" + " password doesn't seem to be valid." + " Let's try it again...\r\nBy what" + " name would you like to be called? ", + TELNET_IAC, TELNET_WILL, TELNET_ECHO); client_data->state = WMUD_CLIENT_STATE_FRESH; client_data->login_try_count++; - if (client_data->login_try_count > 3) + if (client_data->login_try_count == 3) { - wmud_client_send(client_data, "You are trying these bad passwords for too many times. Please stop that!\r\n"); + wmud_client_send(client_data, "You are" + " trying these bad passwords for" + " too many times. Please stop" + " that!\r\n"); wmud_client_close(client_data, TRUE); /* TODO: Increase IP fail count, and ban IP if it's too high */ } @@ -139,7 +149,8 @@ wmud_client_callback(GSocket *client, GIOCondition condition, wmudClient *client } else { - wmud_client_send(client_data, "Empty passwords are not valid.\r\nTry again: "); + wmud_client_send(client_data, "\r\nEmpty passwords are" + " not valid.\r\nTry again: "); } break; case WMUD_CLIENT_STATE_MENU: