From d7ce0c1ce8c4d9118d1340e48424ad9deae0da09 Mon Sep 17 00:00:00 2001 From: shennetsind Date: Sat, 16 Feb 2013 18:39:14 -0200 Subject: Fixed Bug #7070 Character's online states are now updated as soon as they attempt a char select, instead of at the end of the procedure. This improves reliability with 3rd party software e.g. control panels. Signed-off-by: shennetsind --- src/char/char.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src/char') diff --git a/src/char/char.c b/src/char/char.c index effcd6c31..8b75f6394 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -3768,7 +3768,18 @@ int parse_char(int fd) char_id = atoi(data); Sql_FreeResult(sql_handle); - mmo_char_fromsql(char_id, &char_dat, true); + + /* set char as online prior to loading its data so 3rd party applications will realise the sql data is not reliable */ + set_char_online(-2,char_id,sd->account_id); + if( !mmo_char_fromsql(char_id, &char_dat, true) ) { /* failed? set it back offline */ + set_char_offline(char_id, sd->account_id); + /* failed to load something. REJECT! */ + WFIFOHEAD(fd,3); + WFIFOW(fd,0) = 0x6c; + WFIFOB(fd,2) = 0; + WFIFOSET(fd,3); + break;/* jump off this boat */ + } //Have to switch over to the DB instance otherwise data won't propagate [Kevin] cd = (struct mmo_charstatus *)idb_get(char_db_, char_id); @@ -3867,8 +3878,6 @@ int parse_char(int fd) node->ip = ipl; idb_put(auth_db, sd->account_id, node); - set_char_online(-2,node->char_id,sd->account_id); - } break; -- cgit v1.2.3-60-g2f50