summaryrefslogtreecommitdiff
path: root/src/char/char.c
diff options
context:
space:
mode:
authorultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2008-03-27 12:06:12 +0000
committerultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2008-03-27 12:06:12 +0000
commitb7bda5cccb691b35415a7aa1f51190c4ca487fc9 (patch)
tree66f63255ee81b51bda20c5e5d89fee29f0fab9d3 /src/char/char.c
parenta011f250a762ed62403cf25f61f52e7b35193aec (diff)
downloadhercules-b7bda5cccb691b35415a7aa1f51190c4ca487fc9.tar.gz
hercules-b7bda5cccb691b35415a7aa1f51190c4ca487fc9.tar.bz2
hercules-b7bda5cccb691b35415a7aa1f51190c4ca487fc9.tar.xz
hercules-b7bda5cccb691b35415a7aa1f51190c4ca487fc9.zip
Partial rewrite of the login server's auth system.
* replaced the cyclic, size-limited auth_fifo data structure with the more appropriate DBMap-based alternative (stops some erratic behavior) * added code to simulate the pseudo-status "online on login server" * auth data will now expire after 30 seconds instead of persisting * better-than-aegis handling of login cancellation (the server will wipe all previous auth data instead of making you wait for it to expire) * proper status message - no more generic "rejected from server", now you'll get "the server still recognizes your last connection" * fixed a typo in r10110 which caused disconnect timer removal to fail * split off some parsing code to login_auth_ok() and login_auth_failed() * extended the auth confirmation packet so that the login_id1/2 values are sent along with the associated account id (stops charserver from making wrong choices if two incoming sessions have the same account id) * fixed a bug in the disconnect part of the main charserver parsing loop, where a non-authed client would erase the online db entry for a client that's already online, thus bypassing any dual-login checks * added code to stop the waiting_disconnect timer when the associated online entry is removed right away, instead of doing checks later * removed code that would periodically wipe the online status of clients that are in the auth process (producing yet more erratic behavior) * commented out some TXT-only reconnect prevention code (bugreport:1281) git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@12441 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/char/char.c')
-rw-r--r--src/char/char.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/src/char/char.c b/src/char/char.c
index 2a9c00943..0acb967ad 100644
--- a/src/char/char.c
+++ b/src/char/char.c
@@ -2009,27 +2009,36 @@ int parse_fromlogin(int fd)
// acknowledgement of account authentication request
case 0x2713:
- if (RFIFOREST(fd) < 51)
+ if (RFIFOREST(fd) < 59)
return 0;
+ {
+ int account_id = RFIFOL(fd,2);
+ int login_id1 = RFIFOL(fd,6);
+ int login_id2 = RFIFOL(fd,10);
+ bool result = RFIFOB(fd,14);
+ const char* email = (const char*)RFIFOP(fd,15);
+ time_t connect_until = (time_t)RFIFOL(fd,55);
// find the session with this account id
- ARR_FIND( 0, fd_max, i, session[i] && (sd = (struct char_session_data*)session[i]->session_data) && sd->account_id == RFIFOL(fd,2) );
+ ARR_FIND( 0, fd_max, i, session[i] && (sd = (struct char_session_data*)session[i]->session_data) &&
+ sd->account_id == account_id && sd->login_id1 == login_id1 && sd->login_id2 == login_id2 );
if( i < fd_max )
{
- if( RFIFOB(fd,6) != 0 ) { // failure
+ if( result ) { // failure
WFIFOHEAD(i,3);
WFIFOW(i,0) = 0x6c;
WFIFOB(i,2) = 0x42;
WFIFOSET(i,3);
} else { // success
- memcpy(sd->email, RFIFOP(fd,7), 40);
+ memcpy(sd->email, email, 40);
if (e_mail_check(sd->email) == 0)
strncpy(sd->email, "a@a.com", 40); // default e-mail
- sd->connect_until_time = (time_t)RFIFOL(fd,47);
+ sd->connect_until_time = connect_until;
char_auth_ok(i, sd);
}
}
- RFIFOSKIP(fd,51);
+ }
+ RFIFOSKIP(fd,59);
break;
// Receiving of an e-mail/time limit from the login-server (answer of a request because a player comes back from map-server to char-server) by [Yor]
@@ -3223,12 +3232,12 @@ int parse_char(int fd)
if(session[fd]->flag.eof)
{
- if (sd != NULL)
+ if( sd != NULL && sd->auth )
{
struct online_char_data* data = (struct online_char_data*)idb_get(online_char_db, sd->account_id);
- if (!data || data->server == -1) //If it is not in any server, send it offline. [Skotlex]
+ if( data == NULL || data->server == -1) //If it is not in any server, send it offline. [Skotlex]
set_char_offline(99,sd->account_id);
- if (data && data->fd == fd)
+ if( data != NULL && data->fd == fd)
data->fd = -1;
}
do_close(fd);