summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin <Kevin@54d463be-8e91-2dee-dedb-b68131a5f0ec>2008-04-04 07:19:47 +0000
committerKevin <Kevin@54d463be-8e91-2dee-dedb-b68131a5f0ec>2008-04-04 07:19:47 +0000
commit210c7db380e555a76f06124056a79631cefaaae2 (patch)
tree4a94fea2d6254a611fc3ec0d6a08421e770c3cc5
parent44256c0db4fb625cef5f08a5530cfae74158cb85 (diff)
downloadhercules-210c7db380e555a76f06124056a79631cefaaae2.tar.gz
hercules-210c7db380e555a76f06124056a79631cefaaae2.tar.bz2
hercules-210c7db380e555a76f06124056a79631cefaaae2.tar.xz
hercules-210c7db380e555a76f06124056a79631cefaaae2.zip
Bug fixes for Auth Glitch and Map server crash through script warp when changing map servers.
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@12473 54d463be-8e91-2dee-dedb-b68131a5f0ec
-rw-r--r--Changelog-Trunk.txt9
-rw-r--r--src/char_sql/char.c19
-rw-r--r--src/map/chrif.c4
-rw-r--r--src/map/pc.c4
4 files changed, 28 insertions, 8 deletions
diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt
index 9267eb3d9..e162e620b 100644
--- a/Changelog-Trunk.txt
+++ b/Changelog-Trunk.txt
@@ -3,6 +3,15 @@ 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/04
+ * Bug fixes for Auth Glitch and Map server crash through script warp when
+ - changing map servers.
+ * When char receives the request to go back to char selection it sets
+ - the character as "at char select" in the online_char_db, and
+ - set_char_offline now deletes the entry in the online_char_db unless
+ - the user is at the character screen (to prevent unecessary callocs/frees.
+ * Script warp was just a simple misplacement of a free statement, freeing the
+ - users session data before the scripting subsystem was finished with it. [Kevin]
2008/04/03
* More login server work
- Renamed 'connect_until_time' to 'expiration_time'
diff --git a/src/char_sql/char.c b/src/char_sql/char.c
index 854dea5f6..4d557ba29 100644
--- a/src/char_sql/char.c
+++ b/src/char_sql/char.c
@@ -233,7 +233,7 @@ 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)
+ if (online_check && 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"
@@ -294,13 +294,17 @@ void set_char_offline(int char_id, int account_id)
{ //We don't free yet to avoid aCalloc/aFree spamming during char change. [Skotlex]
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 user is NOT at char screen, delete entry [Kevin]
+ if(character->char_id != -1)
+ {
+ idb_remove(online_char_db, account_id);
+ }
}
if (login_fd > 0 && !session[login_fd]->flag.eof)
@@ -2394,6 +2398,10 @@ int parse_frommap(int fd)
auth_fifo[auth_fifo_pos].expiration_time = 0; // unlimited/unknown time by default (not display in map-server)
auth_fifo[auth_fifo_pos].ip = ntohl(RFIFOL(fd,14));
auth_fifo_pos++;
+
+ //Set char to "@ char select" in online db [Kevin]
+ set_char_online(-3, 99, RFIFOL(fd,2));
+
WFIFOHEAD(fd,7);
WFIFOW(fd,0) = 0x2b03;
WFIFOL(fd,2) = RFIFOL(fd,2);
@@ -2827,7 +2835,8 @@ int parse_char(int fd)
{ // already authed client
struct online_char_data* data = (struct online_char_data*)idb_get(online_char_db, sd->account_id);
if( data == NULL || data->server == -1) //If it is not in any server, send it offline. [Skotlex]
- set_char_offline(99,sd->account_id);
+ //send -1 as char id (99 means at char select) [Kevin]
+ set_char_offline(-1,sd->account_id);
if( data != NULL && data->fd == fd)
data->fd = -1;
}
diff --git a/src/map/chrif.c b/src/map/chrif.c
index 583c22ad6..36f57a892 100644
--- a/src/map/chrif.c
+++ b/src/map/chrif.c
@@ -400,8 +400,12 @@ int chrif_changemapserverack(int account_id, int login_id1, int login_id2, int c
} else
clif_changemapserver(node->sd, map_index, x, y, ntohl(ip), ntohs(port));
+ //Free session data from this map server [Kevin]
+ unit_free_pc(sd);
+
//Player has been saved already, remove him from memory. [Skotlex]
chrif_auth_delete(account_id, char_id, ST_MAPCHANGE);
+
return 0;
}
diff --git a/src/map/pc.c b/src/map/pc.c
index acc8af40c..e55ae2014 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -3594,9 +3594,7 @@ int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y
pc_clean_skilltree(sd);
chrif_save(sd,2);
chrif_changemapserver(sd, ip, (short)port);
- //It is important to invoke remove_map separately from unit_free before
- //saving so that the data saved corresponds to that AFTER warping.
- unit_free_pc(sd);
+
return 0;
}