summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2009-10-15 13:19:32 +0000
committerultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2009-10-15 13:19:32 +0000
commit1b29fa27c742bc23a4f258c71f81a22cffe5150a (patch)
tree54af8927c56cc23df3769160fd20c3e11da47569 /src
parent9d880966eee1a66368a736286f1f2377af4e46b0 (diff)
downloadhercules-1b29fa27c742bc23a4f258c71f81a22cffe5150a.tar.gz
hercules-1b29fa27c742bc23a4f258c71f81a22cffe5150a.tar.bz2
hercules-1b29fa27c742bc23a4f258c71f81a22cffe5150a.tar.xz
hercules-1b29fa27c742bc23a4f258c71f81a22cffe5150a.zip
Ported over several TXT online code fixes from charmerge (autotrading chars couldn't be kicked due to a missing update).
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@14091 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src')
-rw-r--r--src/char/char.c49
1 files changed, 35 insertions, 14 deletions
diff --git a/src/char/char.c b/src/char/char.c
index ecf8c8b4b..1311147ae 100644
--- a/src/char/char.c
+++ b/src/char/char.c
@@ -192,6 +192,33 @@ 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) = 0x272b;
+ 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;
@@ -199,15 +226,15 @@ 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( 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);
+ 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);
}
+ //Update state data
+ character->char_id = char_id;
+ character->server = map_id;
+
if( character->server > -1 )
server[character->server].users++;
@@ -216,12 +243,6 @@ void set_char_online(int map_id, int char_id, int account_id)
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)
{
WFIFOHEAD(login_fd,6);
@@ -1916,7 +1937,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);
// continues when account data is received...
}
@@ -2764,7 +2785,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;