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.
This commit is contained in:
Aleos 2023-01-03 16:22:30 -05:00 committed by GitHub
parent 936abe13eb
commit b867a2171f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 6 deletions

View File

@ -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

View File

@ -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);
}

View File

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

View File

@ -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;
}