summaryrefslogtreecommitdiff
path: root/src/char
diff options
context:
space:
mode:
authorFlavioJS <FlavioJS@54d463be-8e91-2dee-dedb-b68131a5f0ec>2009-04-01 22:39:19 +0000
committerFlavioJS <FlavioJS@54d463be-8e91-2dee-dedb-b68131a5f0ec>2009-04-01 22:39:19 +0000
commitbd55cf078aeaae7929cfe5017e22fdf33616b769 (patch)
tree58e83a5a5fd263d38ec3e2c8d9f15c9a8caad31d /src/char
parentd1ad9a53e71f2b2cc51c82259e8a5e23b20c09b8 (diff)
downloadhercules-bd55cf078aeaae7929cfe5017e22fdf33616b769.tar.gz
hercules-bd55cf078aeaae7929cfe5017e22fdf33616b769.tar.bz2
hercules-bd55cf078aeaae7929cfe5017e22fdf33616b769.tar.xz
hercules-bd55cf078aeaae7929cfe5017e22fdf33616b769.zip
* Removed online_check config options. (always active now)
* Clarified char_maintenance config option. * Changed packet 0x2712. (added request_id) * Changed packet 0x2713. (added sex, request_id, version, clienttype; removed email, expiration time, gmlevel) * Delayed user count check and mmo_char_send006b to when the account data arrives. * Created auxiliary function MD5_Salt. (split from a future commit that was getting to big for my taste) git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@13652 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/char')
-rw-r--r--src/char/char.c101
1 files changed, 53 insertions, 48 deletions
diff --git a/src/char/char.c b/src/char/char.c
index 526a4e78c..25c5391ef 100644
--- a/src/char/char.c
+++ b/src/char/char.c
@@ -93,8 +93,6 @@ bool char_rename = true;
int log_char = 1; // loggin char or not [devil]
int log_inter = 1; // loggin inter or not [devil]
-static int online_check = 1; //If one, it won't let players connect when their account is already registered online and will send the relevant map server a kick user request. [Skotlex]
-
// Advanced subnet check [LuzZza]
struct s_subnet {
uint32 mask;
@@ -110,6 +108,8 @@ struct char_session_data {
char email[40]; // e-mail (default: a@a.com) by [Yor]
time_t expiration_time; // # of seconds 1/1/1970 (timestamp): Validity limit of the account (0 = unlimited)
int gmlevel;
+ uint32 version;
+ uint8 clienttype;
};
int char_id_count = START_CHAR_NUM;
@@ -197,7 +197,7 @@ void set_char_online(int map_id, int char_id, int account_id)
struct online_char_data* character;
character = (struct online_char_data*)idb_ensure(online_char_db, account_id, create_online_char_data);
- if (online_check && character->char_id != -1 && character->server > -1 && character->server != map_id && map_id != -3)
+ if( character->char_id != -1 && character->server > -1 && character->server != map_id && map_id != -3 )
{
//char == 99 <- Character logging in, so someone has logged in while one
//char is still on map-server, so kick him out, but don't print "error"
@@ -1878,16 +1878,8 @@ static int char_delete(struct mmo_charstatus *cs)
static void char_auth_ok(int fd, struct char_session_data *sd)
{
struct online_char_data* character;
- if (max_connect_user && count_users() >= max_connect_user && sd->gmlevel < gm_allow_level)
- {
- // refuse connection (over populated)
- WFIFOW(fd,0) = 0x6c;
- WFIFOW(fd,2) = 0;
- WFIFOSET(fd,3);
- return;
- }
- if( online_check && (character = (struct online_char_data*)idb_get(online_char_db, sd->account_id)) != NULL )
+ if( (character = (struct online_char_data*)idb_get(online_char_db, sd->account_id)) != NULL )
{ // check if character is not online already. [Skotlex]
if (character->server > -1)
{ //Character already online. KICK KICK KICK
@@ -1910,8 +1902,7 @@ static void char_auth_ok(int fd, struct char_session_data *sd)
}
if (login_fd > 0) {
- // request to login-server to obtain e-mail/time limit
- //FIXME: isn't this part of the auth_ok packet? [ultramage]
+ // request account data
WFIFOHEAD(login_fd,6);
WFIFOW(login_fd,0) = 0x2716;
WFIFOL(login_fd,2) = sd->account_id;
@@ -1924,8 +1915,7 @@ static void char_auth_ok(int fd, struct char_session_data *sd)
// set char online on charserver
set_char_online(-1, 99, sd->account_id);
- // send characters to player
- mmo_char_send006b(fd, sd);
+ // continues when account data is received...
}
int send_accounts_tologin(int tid, unsigned int tick, int id, intptr data);
@@ -1985,50 +1975,66 @@ int parse_fromlogin(int fd)
// acknowledgement of account authentication request
case 0x2713:
- if (RFIFOREST(fd) < 60)
+ if (RFIFOREST(fd) < 25)
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 expiration_time = (time_t)RFIFOL(fd,55);
- int gmlevel = RFIFOB(fd,59);
-
- // 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 == account_id && sd->login_id1 == login_id1 && sd->login_id2 == login_id2 );
- if( i < fd_max )
+ uint32 login_id1 = RFIFOL(fd,6);
+ uint32 login_id2 = RFIFOL(fd,10);
+ uint8 sex = RFIFOB(fd,14);
+ uint8 result = RFIFOB(fd,15);
+ int request_id = RFIFOL(fd,16);
+ uint32 version = RFIFOL(fd,20);
+ uint8 clienttype = RFIFOB(fd,24);
+ RFIFOSKIP(fd,25);
+
+ if( session_isActive(request_id) && (sd=(struct char_session_data*)session[request_id]->session_data) &&
+ !sd->auth && sd->account_id == account_id && sd->login_id1 == login_id1 && sd->login_id2 == login_id2 && sd->sex == sex )
{
- if( result ) { // failure
- WFIFOHEAD(i,3);
- WFIFOW(i,0) = 0x6c;
- WFIFOB(i,2) = 0x42;
- WFIFOSET(i,3);
- } else { // success
- memcpy(sd->email, email, 40);
- sd->expiration_time = expiration_time;
- sd->gmlevel = gmlevel;
- char_auth_ok(i, sd);
+ int client_fd = request_id;
+ sd->version = version;
+ sd->clienttype = clienttype;
+ switch( result )
+ {
+ case 0:// ok
+ char_auth_ok(client_fd, sd);
+ break;
+ case 1:// auth failed
+ WFIFOHEAD(client_fd,3);
+ WFIFOW(client_fd,0) = 0x6c;
+ WFIFOB(client_fd,2) = 0;// rejected from server
+ WFIFOSET(client_fd,3);
+ break;
}
}
}
- RFIFOSKIP(fd,60);
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]
- case 0x2717:
+ case 0x2717: // account data
if (RFIFOREST(fd) < 51)
return 0;
- // 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) );
+ // find the authenticated session with this account id
+ ARR_FIND( 0, fd_max, i, session[i] && (sd = (struct char_session_data*)session[i]->session_data) && sd->auth && sd->account_id == RFIFOL(fd,2) );
if( i < fd_max )
{
memcpy(sd->email, RFIFOP(fd,6), 40);
sd->expiration_time = (time_t)RFIFOL(fd,46);
sd->gmlevel = RFIFOB(fd,50);
+
+ // continued from char_auth_ok...
+ if( max_connect_user && count_users() >= max_connect_user && sd->gmlevel < gm_allow_level )
+ {
+ // refuse connection (over populated)
+ WFIFOW(i,0) = 0x6c;
+ WFIFOW(i,2) = 0;
+ WFIFOSET(i,3);
+ }
+ else
+ {
+ // send characters to player
+ mmo_char_send006b(i, sd);
+ }
}
RFIFOSKIP(fd,51);
break;
@@ -2696,7 +2702,7 @@ int parse_frommap(int fd)
aid = RFIFOL(fd,6+i*8);
cid = RFIFOL(fd,6+i*8+4);
character = (struct online_char_data*)idb_ensure(online_char_db, aid, create_online_char_data);
- if (online_check && character->server > -1 && character->server != id)
+ if( character->server > -1 && character->server != id )
{
ShowNotice("Set map user: Character (%d:%d) marked on map server %d, but map server %d claims to have (%d:%d) online!\n",
character->account_id, character->char_id, character->server, id, aid, cid);
@@ -3281,14 +3287,15 @@ int parse_char(int fd)
else
{// authentication not found (coming from login server)
if (login_fd > 0) { // don't send request if no login-server
- WFIFOHEAD(login_fd,19);
+ WFIFOHEAD(login_fd,23);
WFIFOW(login_fd,0) = 0x2712; // ask login-server to authentify an account
WFIFOL(login_fd,2) = sd->account_id;
WFIFOL(login_fd,6) = sd->login_id1;
WFIFOL(login_fd,10) = sd->login_id2;
WFIFOB(login_fd,14) = sd->sex;
WFIFOL(login_fd,15) = htonl(ipl);
- WFIFOSET(login_fd,19);
+ WFIFOL(login_fd,19) = fd;
+ WFIFOSET(login_fd,23);
} else { // if no login-server, we must refuse connection
WFIFOHEAD(fd,3);
WFIFOW(fd,0) = 0x6c;
@@ -4022,8 +4029,6 @@ int char_config_read(const char *cfgName)
gm_allow_level = atoi(w2);
if(gm_allow_level < 0)
gm_allow_level = 99;
- } else if (strcmpi(w1, "online_check") == 0) {
- online_check = config_switch(w2);
} else if (strcmpi(w1, "autosave_time") == 0) {
autosave_interval = atoi(w2)*1000;
if (autosave_interval <= 0)