summaryrefslogtreecommitdiff
path: root/src/char_sql/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_sql/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_sql/char.c')
-rw-r--r--src/char_sql/char.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/src/char_sql/char.c b/src/char_sql/char.c
index f3a25f5fe..917d0ae93 100644
--- a/src/char_sql/char.c
+++ b/src/char_sql/char.c
@@ -1710,25 +1710,34 @@ 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);
- sd->connect_until_time = (time_t)RFIFOL(fd,47);
+ memcpy(sd->email, email, 40);
+ sd->connect_until_time = connect_until;
char_auth_ok(i, sd);
}
}
- RFIFOSKIP(fd,51);
+ }
+ RFIFOSKIP(fd,59);
break;
// acknowledgement of e-mail/limited time request
@@ -2855,12 +2864,12 @@ int parse_char(int fd)
if(session[fd]->flag.eof)
{
- if (sd != NULL)
+ if( sd != NULL && sd->auth )
{ // already authed client
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);