Преглед изворни кода

Prevented online user count from going negative. (bugreport:3913)

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@14186 54d463be-8e91-2dee-dedb-b68131a5f0ec
Paradox924X пре 15 година
родитељ
комит
92ed65fd9a
3 измењених фајлова са 10 додато и 4 уклоњено
  1. 2 0
      Changelog-Trunk.txt
  2. 4 2
      src/char/char.c
  3. 4 2
      src/char_sql/char.c

+ 2 - 0
Changelog-Trunk.txt

@@ -3,6 +3,8 @@ 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.
 
+2009/12/03
+	* Prevented online user count from going negative. (bugreport:3913) [Paradox924X]
 2009/12/02
 	* Rev. 14183 Semi-revert of 14182, moved ALL_WEWISH up under SA_GRAVITY instead, as I hadn't noticed it does exactly what the new case did. [L0ne_W0lf]
 	* Rev. 14182 Added skill ALL_WEWISH. This skill in older clients plays a song, however in current clients it does not. The effect (AL_ANGELUS) still shows. [L0ne_W0lf]

+ 4 - 2
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);

+ 4 - 2
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);