summaryrefslogtreecommitdiff
path: root/src/login/login.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/login/login.c')
-rw-r--r--src/login/login.c60
1 files changed, 33 insertions, 27 deletions
diff --git a/src/login/login.c b/src/login/login.c
index c12c9bde9..0488ae4ed 100644
--- a/src/login/login.c
+++ b/src/login/login.c
@@ -2,6 +2,18 @@
// See the LICENSE file
// Portions Copyright (c) Athena Dev Teams
+#define HERCULES_CORE
+
+#include "login.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "account.h"
+#include "ipban.h"
+#include "loginlog.h"
+#include "../common/HPM.h"
#include "../common/core.h"
#include "../common/db.h"
#include "../common/malloc.h"
@@ -12,15 +24,6 @@
#include "../common/strlib.h"
#include "../common/timer.h"
#include "../common/utils.h"
-#include "../common/HPM.h"
-#include "account.h"
-#include "ipban.h"
-#include "login.h"
-#include "loginlog.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
struct Login_Config login_config;
@@ -170,7 +173,7 @@ static int online_data_cleanup_sub(DBKey key, DBData *data, va_list ap)
static int online_data_cleanup(int tid, int64 tick, int id, intptr_t data) {
online_db->foreach(online_db, online_data_cleanup_sub);
return 0;
-}
+}
//--------------------------------------------------------------------
@@ -284,7 +287,7 @@ int lan_subnetcheck(uint32 ip)
}
//----------------------------------
-// Reading Lan Support configuration
+// Reading LAN Support configuration
//----------------------------------
int login_lan_config_read(const char *lancfgName)
{
@@ -721,13 +724,13 @@ int parse_fromchar(int fd)
RFIFOSKIP(fd,6);
if( !accounts->load_num(accounts, &acc, account_id) )
- ShowNotice("Char-server '%s': Error of UnBan request (account: %d not found, ip: %s).\n", server[id].name, account_id, ip);
+ ShowNotice("Char-server '%s': Error of Unban request (account: %d not found, ip: %s).\n", server[id].name, account_id, ip);
else
if( acc.unban_time == 0 )
- ShowNotice("Char-server '%s': Error of UnBan request (account: %d, no change for unban date, ip: %s).\n", server[id].name, account_id, ip);
+ ShowNotice("Char-server '%s': Error of Unban request (account: %d, no change for unban date, ip: %s).\n", server[id].name, account_id, ip);
else
{
- ShowNotice("Char-server '%s': UnBan request (account: %d, ip: %s).\n", server[id].name, account_id, ip);
+ ShowNotice("Char-server '%s': Unban request (account: %d, ip: %s).\n", server[id].name, account_id, ip);
acc.unban_time = 0;
accounts->save(accounts, &acc);
}
@@ -842,18 +845,20 @@ int parse_fromchar(int fd)
WFIFOHEAD(fd,183);
WFIFOW(fd,0) = 0x2737;
safestrncpy((char*)WFIFOP(fd,2), acc.userid, NAME_LENGTH);
- if (u_group >= acc.group_id) {
+ if (u_group >= acc.group_id)
safestrncpy((char*)WFIFOP(fd,26), acc.pass, 33);
- }
+ else
+ memset(WFIFOP(fd,26), '\0', 33);
safestrncpy((char*)WFIFOP(fd,59), acc.email, 40);
safestrncpy((char*)WFIFOP(fd,99), acc.last_ip, 16);
WFIFOL(fd,115) = acc.group_id;
safestrncpy((char*)WFIFOP(fd,119), acc.lastlogin, 24);
WFIFOL(fd,143) = acc.logincount;
WFIFOL(fd,147) = acc.state;
- if (u_group >= acc.group_id) {
+ if (u_group >= acc.group_id)
safestrncpy((char*)WFIFOP(fd,151), acc.pincode, 5);
- }
+ else
+ memset(WFIFOP(fd,151), '\0', 5);
safestrncpy((char*)WFIFOP(fd,156), acc.birthdate, 11);
WFIFOL(fd,167) = map_fd;
WFIFOL(fd,171) = u_fd;
@@ -909,7 +914,7 @@ int mmo_auth_new(const char* userid, const char* pass, const char sex, const cha
// check if the account doesn't exist already
if( accounts->load_str(accounts, &acc, userid) ) {
- ShowNotice("Attempt of creation of an already existant account (account: %s_%c, pass: %s, received pass: %s)\n", userid, sex, acc.pass, pass);
+ ShowNotice("Attempt of creation of an already existing account (account: %s_%c, pass: %s, received pass: %s)\n", userid, sex, acc.pass, pass);
return 1; // 1 = Incorrect Password
}
@@ -1042,8 +1047,9 @@ int mmo_auth(struct login_session_data* sd, bool isServer) {
for( i = 0; i < 16; i++ )
sprintf(&smd5[i * 2], "%02x", sd->client_hash[i]);
+ smd5[32] = '\0';
- ShowNotice("Invalid client hash (account: %s, pass: %s, sent md5: %d, ip: %s)\n", sd->userid, sd->passwd, smd5, ip);
+ ShowNotice("Invalid client hash (account: %s, pass: %s, sent md5: %s, ip: %s)\n", sd->userid, sd->passwd, smd5, ip);
return 5;
}
}
@@ -1101,12 +1107,12 @@ void login_auth_ok(struct login_session_data* sd)
WFIFOSET(fd,3);
return;
} else if( login_config.min_group_id_to_connect >= 0 && login_config.group_id_to_connect == -1 && sd->group_id < login_config.min_group_id_to_connect ) {
- ShowStatus("Connection refused: the minium group id required for connection is %d (account: %s, group: %d).\n", login_config.min_group_id_to_connect, sd->userid, sd->group_id);
+ ShowStatus("Connection refused: the minimum group id required for connection is %d (account: %s, group: %d).\n", login_config.min_group_id_to_connect, sd->userid, sd->group_id);
WFIFOHEAD(fd,3);
WFIFOW(fd,0) = 0x81;
WFIFOB(fd,2) = 1; // 01 = Server closed
WFIFOSET(fd,3);
- return;
+ return;
}
server_num = 0;
@@ -1306,7 +1312,7 @@ int parse_login(int fd)
// Perform ip-ban check
if( login_config.ipban && ipban_check(ipl) )
{
- ShowStatus("Connection refused: IP isn't authorised (deny/allow, ip: %s).\n", ip);
+ ShowStatus("Connection refused: IP isn't authorized (deny/allow, ip: %s).\n", ip);
login_log(ipl, "unknown", -3, "ip banned");
WFIFOHEAD(fd,23);
WFIFOW(fd,0) = 0x6a;
@@ -1689,8 +1695,7 @@ int login_config_read(const char* cfgName)
//--------------------------------------
// Function called at exit of the server
//--------------------------------------
-void do_final(void)
-{
+int do_final(void) {
int i;
struct client_hash_node *hn = login_config.client_hash_nodes;
@@ -1730,6 +1735,7 @@ void do_final(void)
}
ShowStatus("Finished.\n");
+ return EXIT_SUCCESS;
}
//------------------------------
@@ -1769,7 +1775,7 @@ int do_init(int argc, char** argv)
{
int i;
- // intialize engine (to accept config settings)
+ // initialize engine (to accept config settings)
account_engine[0].db = account_engine[0].constructor();
// read login-server configuration
@@ -1824,7 +1830,7 @@ int do_init(int argc, char** argv)
HPM->config_read(NULL, 0);
HPM->event(HPET_INIT);
- // server port open & binding
+ // server port open & binding
if( (login_fd = make_listen_bind(login_config.login_ip,login_config.login_port)) == -1 ) {
ShowFatalError("Failed to bind to port '"CL_WHITE"%d"CL_RESET"'\n",login_config.login_port);
exit(EXIT_FAILURE);