summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/char/char.c6
-rw-r--r--src/char_sql/char.c6
2 files changed, 8 insertions, 4 deletions
diff --git a/src/char/char.c b/src/char/char.c
index f2910751f..4c4379074 100644
--- a/src/char/char.c
+++ b/src/char/char.c
@@ -198,7 +198,8 @@ void set_char_charselect(int account_id)
character = (struct online_char_data*)idb_ensure(online_char_db, account_id, create_online_char_data);
if( character->server > -1 )
- server[character->server].users--;
+ if( server[character->server].users > 0 ) // Prevent this value from going negative.
+ server[character->server].users--;
character->char_id = -1;
character->server = -1;
@@ -258,7 +259,8 @@ void set_char_offline(int char_id, int account_id)
if ((character = (struct online_char_data*)idb_get(online_char_db, account_id)) != NULL)
{ //We don't free yet to avoid aCalloc/aFree spamming during char change. [Skotlex]
if( character->server > -1 )
- server[character->server].users--;
+ if( server[character->server].users > 0 ) // Prevent this value from going negative.
+ server[character->server].users--;
if(character->waiting_disconnect != -1){
delete_timer(character->waiting_disconnect, chardb_waiting_disconnect);
diff --git a/src/char_sql/char.c b/src/char_sql/char.c
index ee1e08bdb..9fc4aea99 100644
--- a/src/char_sql/char.c
+++ b/src/char_sql/char.c
@@ -212,7 +212,8 @@ void set_char_charselect(int account_id)
character = (struct online_char_data*)idb_ensure(online_char_db, account_id, create_online_char_data);
if( character->server > -1 )
- server[character->server].users--;
+ if( server[character->server].users > 0 ) // Prevent this value from going negative.
+ server[character->server].users--;
character->char_id = -1;
character->server = -1;
@@ -300,7 +301,8 @@ void set_char_offline(int char_id, int account_id)
if ((character = (struct online_char_data*)idb_get(online_char_db, account_id)) != NULL)
{ //We don't free yet to avoid aCalloc/aFree spamming during char change. [Skotlex]
if( character->server > -1 )
- server[character->server].users--;
+ if( server[character->server].users > 0 ) // Prevent this value from going negative.
+ server[character->server].users--;
if(character->waiting_disconnect != -1){
delete_timer(character->waiting_disconnect, chardb_waiting_disconnect);