Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions src/char/char.c
Original file line number Diff line number Diff line change
Expand Up @@ -2302,19 +2302,29 @@ static void char_ping_login_server(int fd)

static int char_parse_fromlogin_connection_state(int fd)
{
if (RFIFOB(fd,2)) {
//printf("connect login server error : %d\n", RFIFOB(fd,2));
switch (RFIFOB(fd,2)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about adding a default: case here, to catch any other values (futureproofing, or customized login server error codes)?

case 0:
ShowStatus("Connected to login-server (connection #%d).\n", fd);
loginif->on_ready();
break;
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("The communication passwords are set in /conf/map/map-server.conf and /conf/char/char-server.conf\n");
sockt->eof(fd);
return 1;
} else {
ShowStatus("Connected to login-server (connection #%d).\n", fd);
loginif->on_ready();
case 2: // IP not allowed
ShowError("Can not connect to login-server.\n");
ShowError("Please make sure your IP is allowed in conf/network.conf\n");
sockt->eof(fd);
return 1;
default:
ShowError("Invalid response from the login-server. Error code: %d\n", (int)RFIFOB(fd,2));
sockt->eof(fd);
return 1;
}
RFIFOSKIP(fd,3);
RFIFOSKIP(fd, 3);
return 0;
}

Expand Down
15 changes: 8 additions & 7 deletions src/login/login.c
Original file line number Diff line number Diff line change
Expand Up @@ -1438,13 +1438,16 @@ static void login_parse_request_connection(int fd, struct login_session_data* sd
loginlog->log(sockt->session[fd]->client_addr, sd->userid, 100, message);

result = login->mmo_auth(sd, true);
if (core->runflag == LOGINSERVER_ST_RUNNING &&

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 (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) &&
sockt->allowed_ip_check(ipl))
!sockt->session_is_valid(login->dbs->server[sd->account_id].fd))
{
ShowStatus("Connection of the char-server '%s' accepted.\n", server_name);
safestrncpy(login->dbs->server[sd->account_id].name, server_name, sizeof(login->dbs->server[sd->account_id].name));
Expand All @@ -1461,11 +1464,9 @@ static void login_parse_request_connection(int fd, struct login_session_data* sd

// send connection success
login->char_server_connection_status(fd, sd, 0);
}
else
{
} else {
ShowNotice("Connection of the char-server '%s' REFUSED.\n", server_name);
login->char_server_connection_status(fd, sd, 3);
login->char_server_connection_status(fd, sd, 1);
}
}

Expand Down