From 9f746fe84b3b5c4afbb796f9361e63f107a4e7df Mon Sep 17 00:00:00 2001 From: "Guilherme G. Menaldo" Date: Sun, 17 Dec 2023 22:01:34 -0300 Subject: [PATCH 1/2] Add more details when char-server fails to connect - login-server now records details for failure due to account ID range and wrong sex - char-server now informs about the Account ID range --- src/char/char.c | 2 +- src/login/login.c | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/char/char.c b/src/char/char.c index 442c742e6c0..8626353dc24 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -2414,7 +2414,7 @@ static int char_parse_fromlogin_connection_state(int fd) case 1: // Invalid username/password ShowError("Can not connect to login-server.\n"); ShowError("The server communication passwords (default s1/p1) are probably invalid.\n"); - ShowError("Also, please make sure your login db has the correct communication username/passwords and the gender of the account is S.\n"); + ShowError("Also, please make sure your login db has the correct communication username/passwords, the gender of the account is S and its id is between 0 and (MAX_SERVERS - 1).\n"); ShowError("The communication passwords are set in /conf/map/map-server.conf and /conf/char/char-server.conf\n"); sockt->eof(fd); return 1; diff --git a/src/login/login.c b/src/login/login.c index ac35874bc49..9b99acd4899 100644 --- a/src/login/login.c +++ b/src/login/login.c @@ -1504,11 +1504,14 @@ static void login_parse_request_connection(int fd, struct login_session_data* sd if (!sockt->allowed_ip_check(ipl)) { ShowNotice("Connection of the char-server '%s' REFUSED (IP not allowed).\n", server_name); login->char_server_connection_status(fd, sd, 2); + } else if (sd->sex != 'S') { + ShowNotice("Connection of the char-server '%s' REFUSED (Account sex must be 'S').\n", server_name); + login->char_server_connection_status(fd, sd, 1); + } else if (sd->account_id < 0 || sd->account_id >= ARRAYLENGTH(login->dbs->server)) { + ShowNotice("Connection of the char-server '%s' REFUSED (Account ID must be between 0 and %d).\n", server_name, ARRAYLENGTH(login->dbs->server) - 1); + login->char_server_connection_status(fd, sd, 1); } else if (core->runflag == LOGINSERVER_ST_RUNNING && result == -1 && - sd->sex == 'S' && - sd->account_id >= 0 && - sd->account_id < ARRAYLENGTH(login->dbs->server) && !sockt->session_is_valid(login->dbs->server[sd->account_id].fd)) { ShowStatus("Connection of the char-server '%s' accepted.\n", server_name); From 9fbd1b6141a2eb46e8d41d5aefe381abe8c7aa54 Mon Sep 17 00:00:00 2001 From: "Guilherme G. Menaldo" Date: Sun, 17 Dec 2023 23:35:02 -0300 Subject: [PATCH 2/2] Fix warning due to parameter order in aCalloc call the first parameter is the number of entries, the 2nd is the size of the structure --- src/char/char.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/char/char.c b/src/char/char.c index 8626353dc24..1a65a38daff 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -6096,7 +6096,7 @@ static void char_ensure_online_char_data(struct online_char_data *character) { nullpo_retv(character); if (character->data == NULL) { - character->data = aCalloc(sizeof(struct online_char_data2), 1); + character->data = aCalloc(1, sizeof(struct online_char_data2)); } }