Cleaned up auth system after change back to map server request.
- Created function set_char_charselect to get rid of some of the "special case" variables. - Removed code that involved the char server sending auth data at char select. - Changed char select code to update the instance of the char data in the DB to fix map/sex info not being propagated to auth request. git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@12658 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
parent
7f18ba579a
commit
679e600fcc
@ -3,7 +3,12 @@ Date Added
|
||||
AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO INTO TRUNK.
|
||||
IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
|
||||
|
||||
2008/04/25
|
||||
2008/04/26
|
||||
* Cleaned up auth system after change back to map server request.
|
||||
- Created function set_char_charselect to get rid of some of the "special case" variables.
|
||||
- Removed code that involved the char server sending auth data at char select.
|
||||
- Changed char select code to update the instance of the char data in the DB
|
||||
to fix map/sex info not being propagated to auth request. [Kevin]
|
||||
* Rev. 12657 Added WoE SE castles to castles.txt in save-tmpl. [L0ne_W0lf]
|
||||
2008/04/25
|
||||
* Updated item_db.sql to latest
|
||||
|
@ -213,9 +213,37 @@ static void* create_online_char_data(DBKey key, va_list args)
|
||||
return character;
|
||||
}
|
||||
|
||||
void set_char_charselect(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( character->server > -1 )
|
||||
server[character->server].users--;
|
||||
|
||||
character->char_id = -1;
|
||||
character->server = -1;
|
||||
|
||||
if(character->waiting_disconnect != -1) {
|
||||
delete_timer(character->waiting_disconnect, chardb_waiting_disconnect);
|
||||
character->waiting_disconnect = -1;
|
||||
}
|
||||
|
||||
if (login_fd > 0 && !session[login_fd]->flag.eof)
|
||||
{
|
||||
WFIFOHEAD(login_fd,6);
|
||||
WFIFOW(login_fd,0) = 0x272c;
|
||||
WFIFOL(login_fd,2) = account_id;
|
||||
WFIFOSET(login_fd,6);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void set_char_online(int map_id, int char_id, int account_id)
|
||||
{
|
||||
struct online_char_data* character;
|
||||
struct mmo_charstatus *cp;
|
||||
|
||||
if ( char_id != 99 ) {
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `online`='1' WHERE `char_id`='%d'", char_db, char_id) )
|
||||
@ -223,20 +251,14 @@ void set_char_online(int map_id, int char_id, int account_id)
|
||||
}
|
||||
|
||||
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 (online_check && character->char_id != -1 && character->server > -1 && character->server != map_id)
|
||||
{
|
||||
//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"
|
||||
//as this is normal behaviour. [Skotlex]
|
||||
if (char_id != 99)
|
||||
ShowNotice("set_char_online: Character %d:%d marked in map server %d, but map server %d claims to have (%d:%d) online!\n",
|
||||
character->account_id, character->char_id, character->server, map_id, account_id, char_id);
|
||||
//char == 99 Won't happen anymore, call set_char_charselect to set user "on char server"
|
||||
ShowNotice("set_char_online: Character %d:%d marked in map server %d, but map server %d claims to have (%d:%d) online!\n",
|
||||
character->account_id, character->char_id, character->server, map_id, account_id, char_id);
|
||||
mapif_disconnectplayer(server[character->server].fd, character->account_id, character->char_id, 2);
|
||||
}
|
||||
|
||||
character->char_id = (char_id==99)?-1:char_id;
|
||||
character->server = (char_id==99)?-1:map_id;
|
||||
|
||||
if( character->server > -1 )
|
||||
server[character->server].users++;
|
||||
|
||||
@ -244,12 +266,11 @@ void set_char_online(int map_id, int char_id, int account_id)
|
||||
delete_timer(character->waiting_disconnect, chardb_waiting_disconnect);
|
||||
character->waiting_disconnect = -1;
|
||||
}
|
||||
if (char_id != 99)
|
||||
{ //Set char online in guild cache. If char is in memory, use the guild id on it, otherwise seek it.
|
||||
struct mmo_charstatus *cp;
|
||||
cp = (struct mmo_charstatus*)idb_get(char_db_,char_id);
|
||||
inter_guild_CharOnline(char_id, cp?cp->guild_id:-1);
|
||||
}
|
||||
|
||||
//Set char online in guild cache. If char is in memory, use the guild id on it, otherwise seek it.
|
||||
cp = (struct mmo_charstatus*)idb_get(char_db_,char_id);
|
||||
inter_guild_CharOnline(char_id, cp?cp->guild_id:-1);
|
||||
|
||||
if (login_fd > 0 && !session[login_fd]->flag.eof)
|
||||
{
|
||||
WFIFOHEAD(login_fd,6);
|
||||
@ -1641,7 +1662,7 @@ static void char_auth_ok(int fd, struct char_session_data *sd)
|
||||
sd->auth = true;
|
||||
|
||||
// set char online on charserver
|
||||
set_char_online(-1, 99, sd->account_id);
|
||||
set_char_charselect(sd->account_id);
|
||||
|
||||
// send characters to player
|
||||
mmo_char_send006b(fd, sd);
|
||||
@ -2400,7 +2421,7 @@ int parse_frommap(int fd)
|
||||
idb_put(auth_db, account_id, node);
|
||||
|
||||
//Set char to "@ char select" in online db [Kevin]
|
||||
set_char_online(-3, 99, account_id);
|
||||
set_char_charselect(account_id);
|
||||
|
||||
WFIFOHEAD(fd,7);
|
||||
WFIFOW(fd,0) = 0x2b03;
|
||||
@ -3007,6 +3028,7 @@ int parse_char(int fd)
|
||||
FIFOSD_CHECK(3);
|
||||
{
|
||||
struct mmo_charstatus char_dat;
|
||||
struct mmo_charstatus * cp;
|
||||
char* data;
|
||||
int char_id;
|
||||
uint32 subnet_map_ip;
|
||||
@ -3029,7 +3051,10 @@ int parse_char(int fd)
|
||||
char_id = atoi(data);
|
||||
Sql_FreeResult(sql_handle);
|
||||
mmo_char_fromsql(char_id, &char_dat, true);
|
||||
char_dat.sex = sd->sex;
|
||||
|
||||
//Have to switch over to the DB instance otherwise data won't propagate [Kevin]
|
||||
cp = (struct mmo_charstatus *)idb_get(char_db_, char_id);
|
||||
cp->sex = sd->sex;
|
||||
|
||||
if (log_char) {
|
||||
char esc_name[NAME_LENGTH*2+1];
|
||||
@ -3058,23 +3083,23 @@ int parse_char(int fd)
|
||||
break;
|
||||
}
|
||||
if ((i = search_mapserver((j=mapindex_name2id(MAP_PRONTERA)),-1,-1)) >= 0) {
|
||||
char_dat.last_point.x = 273;
|
||||
char_dat.last_point.y = 354;
|
||||
cp->last_point.x = 273;
|
||||
cp->last_point.y = 354;
|
||||
} else if ((i = search_mapserver((j=mapindex_name2id(MAP_GEFFEN)),-1,-1)) >= 0) {
|
||||
char_dat.last_point.x = 120;
|
||||
char_dat.last_point.y = 100;
|
||||
cp->last_point.x = 120;
|
||||
cp->last_point.y = 100;
|
||||
} else if ((i = search_mapserver((j=mapindex_name2id(MAP_MORROC)),-1,-1)) >= 0) {
|
||||
char_dat.last_point.x = 160;
|
||||
char_dat.last_point.y = 94;
|
||||
cp->last_point.x = 160;
|
||||
cp->last_point.y = 94;
|
||||
} else if ((i = search_mapserver((j=mapindex_name2id(MAP_ALBERTA)),-1,-1)) >= 0) {
|
||||
char_dat.last_point.x = 116;
|
||||
char_dat.last_point.y = 57;
|
||||
cp->last_point.x = 116;
|
||||
cp->last_point.y = 57;
|
||||
} else if ((i = search_mapserver((j=mapindex_name2id(MAP_PAYON)),-1,-1)) >= 0) {
|
||||
char_dat.last_point.x = 87;
|
||||
char_dat.last_point.y = 117;
|
||||
cp->last_point.x = 87;
|
||||
cp->last_point.y = 117;
|
||||
} else if ((i = search_mapserver((j=mapindex_name2id(MAP_IZLUDE)),-1,-1)) >= 0) {
|
||||
char_dat.last_point.x = 94;
|
||||
char_dat.last_point.y = 103;
|
||||
cp->last_point.x = 94;
|
||||
cp->last_point.y = 103;
|
||||
} else {
|
||||
ShowInfo("Connection Closed. No map server available that has a major city, and unable to find map-server for '%s'.\n", mapindex_id2name(char_dat.last_point.map));
|
||||
WFIFOHEAD(fd,3);
|
||||
@ -3084,7 +3109,7 @@ int parse_char(int fd)
|
||||
break;
|
||||
}
|
||||
ShowWarning("Unable to find map-server for '%s', sending to major city '%s'.\n", mapindex_id2name(char_dat.last_point.map), mapindex_id2name(j));
|
||||
char_dat.last_point.map = j;
|
||||
cp->last_point.map = j;
|
||||
}
|
||||
|
||||
//Send NEW auth packet [Kevin]
|
||||
@ -3105,8 +3130,8 @@ int parse_char(int fd)
|
||||
//Send player to map
|
||||
WFIFOHEAD(fd,28);
|
||||
WFIFOW(fd,0) = 0x71;
|
||||
WFIFOL(fd,2) = char_dat.char_id;
|
||||
mapindex_getmapname_ext(mapindex_id2name(char_dat.last_point.map), (char*)WFIFOP(fd,6));
|
||||
WFIFOL(fd,2) = cp->char_id;
|
||||
mapindex_getmapname_ext(mapindex_id2name(cp->last_point.map), (char*)WFIFOP(fd,6));
|
||||
|
||||
// Advanced subnet check [LuzZza]
|
||||
subnet_map_ip = lan_subnetcheck(ipl);
|
||||
@ -3114,24 +3139,10 @@ int parse_char(int fd)
|
||||
WFIFOW(fd,26) = ntows(htons(server[i].port)); // [!] LE byte order here [!]
|
||||
WFIFOSET(fd,28);
|
||||
|
||||
#if 0
|
||||
// The server must request it [FlavioJS]
|
||||
//Send auth ok to map server
|
||||
WFIFOHEAD(map_fd,20 + sizeof(struct mmo_charstatus));
|
||||
WFIFOW(map_fd,0) = 0x2afd;
|
||||
WFIFOW(map_fd,2) = 20 + sizeof(struct mmo_charstatus);
|
||||
WFIFOL(map_fd,4) = sd->account_id;
|
||||
WFIFOL(map_fd,8) = sd->login_id1;
|
||||
WFIFOL(map_fd,16) = sd->login_id2;
|
||||
WFIFOL(map_fd,12) = (unsigned long)sd->expiration_time;
|
||||
memcpy(WFIFOP(map_fd,20), &char_dat, sizeof(struct mmo_charstatus));
|
||||
WFIFOSET(map_fd, WFIFOW(map_fd,2));
|
||||
#endif
|
||||
|
||||
// create temporary auth entry
|
||||
CREATE(node, struct auth_node, 1);
|
||||
node->account_id = sd->account_id;
|
||||
node->char_id = char_dat.char_id;
|
||||
node->char_id = cp->char_id;
|
||||
node->login_id1 = sd->login_id1;
|
||||
node->login_id2 = sd->login_id2;
|
||||
node->sex = sd->sex;
|
||||
|
@ -516,7 +516,7 @@ void chrif_authreq(struct map_session_data *sd)
|
||||
struct auth_node *node= chrif_search(sd->bl.id);
|
||||
|
||||
if(!node) {
|
||||
//data from char server has not arrived yet.
|
||||
//request data from char server and store current auth info
|
||||
WFIFOHEAD(char_fd,19);
|
||||
WFIFOW(char_fd,0) = 0x2b26;
|
||||
WFIFOL(char_fd,2) = sd->status.account_id;
|
||||
@ -527,30 +527,10 @@ void chrif_authreq(struct map_session_data *sd)
|
||||
WFIFOSET(char_fd,19);
|
||||
chrif_sd_to_auth(sd, ST_LOGIN);
|
||||
return;
|
||||
}
|
||||
|
||||
if(node->state == ST_LOGIN &&
|
||||
node->char_dat &&
|
||||
node->account_id == sd->status.account_id &&
|
||||
node->char_id == sd->status.char_id &&
|
||||
node->login_id1 == sd->login_id1)
|
||||
{ //auth ok
|
||||
if (!pc_authok(sd, node->login_id2, node->expiration_time, node->char_dat))
|
||||
{
|
||||
chrif_char_offline(sd); //Set client offline
|
||||
chrif_auth_delete(node->account_id, node->char_id, ST_LOGIN);
|
||||
}
|
||||
else {
|
||||
//char_dat no longer needed, but player auth is not completed yet.
|
||||
aFree(node->char_dat);
|
||||
node->char_dat = NULL;
|
||||
node->sd = sd;
|
||||
chrif_char_online(sd); //Set client online
|
||||
}
|
||||
} else { //auth failed
|
||||
} else { //char already online? kick connect request and tell char server that this person is online
|
||||
//This case shouldn't happen in an ideal system
|
||||
pc_authfail(sd);
|
||||
chrif_char_offline(sd); //Set client offline
|
||||
chrif_auth_delete(sd->status.account_id, sd->status.char_id, ST_LOGIN);
|
||||
chrif_char_online(sd);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -613,20 +593,6 @@ void chrif_authok(int fd)
|
||||
//discard the older one and keep the new one.
|
||||
chrif_auth_delete(node->account_id, node->char_id, ST_LOGIN);
|
||||
}
|
||||
|
||||
// Awaiting for client to connect.
|
||||
node = ers_alloc(auth_db_ers, struct auth_node);
|
||||
memset(node, 0, sizeof(struct auth_node));
|
||||
node->char_dat = (struct mmo_charstatus *) aMalloc(sizeof(struct mmo_charstatus));
|
||||
|
||||
node->account_id=account_id;
|
||||
node->char_id=char_id;
|
||||
node->login_id1=login_id1;
|
||||
node->expiration_time=expiration_time;
|
||||
node->login_id2=login_id2;
|
||||
memcpy(node->char_dat,status,sizeof(struct mmo_charstatus));
|
||||
node->node_created=gettick();
|
||||
idb_put(auth_db, account_id, node);
|
||||
}
|
||||
|
||||
// client authentication failed
|
||||
@ -658,6 +624,8 @@ void chrif_authfail(int fd)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//This can still happen (client times out while waiting for char to confirm auth data)
|
||||
int auth_db_cleanup_sub(DBKey key,void *data,va_list ap)
|
||||
{
|
||||
struct auth_node *node=(struct auth_node*)data;
|
||||
|
Loading…
x
Reference in New Issue
Block a user