Browse Source

Fixed EXP bug and added failsafe to family check functions (#3350)

Fixes #3349
Gustavo Brigo 6 years ago
parent
commit
952ac43e59
1 changed files with 4 additions and 0 deletions
  1. 4 0
      src/char/char.cpp

+ 4 - 0
src/char/char.cpp

@@ -1888,6 +1888,8 @@ int char_married(int pl1, int pl2)
 
 
 int char_child(int parent_id, int child_id)
 int char_child(int parent_id, int child_id)
 {
 {
+	if( parent_id == 0 || child_id == 0) //Failsafe, avoild querys and fix EXP bug dividing with lower level chars
+		return 0;
 	if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `child` FROM `%s` WHERE `char_id` = '%d'", schema_config.char_db, parent_id) )
 	if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `child` FROM `%s` WHERE `char_id` = '%d'", schema_config.char_db, parent_id) )
 		Sql_ShowDebug(sql_handle);
 		Sql_ShowDebug(sql_handle);
 	else if( SQL_SUCCESS == Sql_NextRow(sql_handle) )
 	else if( SQL_SUCCESS == Sql_NextRow(sql_handle) )
@@ -1907,6 +1909,8 @@ int char_child(int parent_id, int child_id)
 
 
 int char_family(int cid1, int cid2, int cid3)
 int char_family(int cid1, int cid2, int cid3)
 {
 {
+	if ( cid1 == 0 || cid2 == 0 || cid3 == 0 ) //Failsafe, and avoid querys where there is no sense to keep executing if any of the inputs are 0
+		return 0;
 	if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `char_id`,`partner_id`,`child` FROM `%s` WHERE `char_id` IN ('%d','%d','%d')", schema_config.char_db, cid1, cid2, cid3) )
 	if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `char_id`,`partner_id`,`child` FROM `%s` WHERE `char_id` IN ('%d','%d','%d')", schema_config.char_db, cid1, cid2, cid3) )
 		Sql_ShowDebug(sql_handle);
 		Sql_ShowDebug(sql_handle);
 	else while( SQL_SUCCESS == Sql_NextRow(sql_handle) )
 	else while( SQL_SUCCESS == Sql_NextRow(sql_handle) )