Pārlūkot izejas kodu

Adds char_server config for clearing parties (#7523)

* Adds a character server config to clear empty parties at start up.
* The commented code was hidden in the source and is pretty useless unless you are digging for it.
Aleos 2 gadi atpakaļ
vecāks
revīzija
b867a2171f
4 mainītis faili ar 16 papildinājumiem un 6 dzēšanām
  1. 3 0
      conf/char_athena.conf
  2. 4 0
      src/char/char.cpp
  3. 1 0
      src/char/char.hpp
  4. 8 6
      src/char/int_party.cpp

+ 3 - 0
conf/char_athena.conf

@@ -198,6 +198,9 @@ char_del_restriction: 3
 // Uncomment to customize the restriction
 //allowed_job_flag: 3
 
+// Should parties that don't have any members be cleared from the party_db table at start up?
+clear_parties: no
+
 // Folder that contains the database files.
 db_path: db
 

+ 4 - 0
src/char/char.cpp

@@ -2822,6 +2822,8 @@ void char_set_defaults(){
 #else
 	charserv_config.allowed_job_flag = 1;
 #endif
+
+	charserv_config.clear_parties = 0;
 }
 
 /**
@@ -3109,6 +3111,8 @@ bool char_config_read(const char* cfgName, bool normal){
 			charserv_config.mail_return_empty = config_switch(w2);
 		} else if (strcmpi(w1, "allowed_job_flag") == 0) {
 			charserv_config.allowed_job_flag = atoi(w2);
+		} else if (strcmpi(w1, "clear_parties") == 0) {
+			charserv_config.clear_parties = config_switch(w2);
 		} else if (strcmpi(w1, "import") == 0) {
 			char_config_read(w2, normal);
 		}

+ 1 - 0
src/char/char.hpp

@@ -206,6 +206,7 @@ struct CharServ_Config {
 	int mail_return_empty;
 
 	int allowed_job_flag;
+	int clear_parties;
 };
 extern struct CharServ_Config charserv_config;
 

+ 8 - 6
src/char/int_party.cpp

@@ -268,12 +268,14 @@ int inter_party_sql_init(void)
 		exit(EXIT_FAILURE);
 	}
 
-	/* Uncomment the following if you want to do a party_db cleanup (remove parties with no members) on startup.[Skotlex]
-	ShowStatus("cleaning party table...\n");
-	if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` USING `%s` LEFT JOIN `%s` ON `%s`.leader_id =`%s`.account_id AND `%s`.leader_char = `%s`.char_id WHERE `%s`.account_id IS NULL",
-		party_db, party_db, char_db, party_db, char_db, party_db, char_db, char_db) )
-		Sql_ShowDebug(sql_handle);
-	*/
+	// Remove parties with no members on startup from party_db. [Skotlex]
+	if (charserv_config.clear_parties) {
+		ShowStatus("Cleaning party table...\n");
+		if (SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` USING `%s` LEFT JOIN `%s` ON `%s`.leader_id =`%s`.account_id AND `%s`.leader_char = `%s`.char_id WHERE `%s`.account_id IS NULL",
+								   schema_config.party_db, schema_config.party_db, schema_config.char_db, schema_config.party_db, schema_config.char_db, schema_config.party_db, schema_config.char_db, schema_config.char_db))
+			Sql_ShowDebug(sql_handle);
+	}
+
 	return 0;
 }