mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-11 16:51:29 +00:00
Updated Command Update code to report after each process handling rather than at the end
This commit is contained in:
parent
a428eb61a1
commit
fec567c2f3
@ -1470,10 +1470,8 @@ bool SharedDatabase::GetCommandSettings(std::map<std::string, std::pair<uint8, s
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SharedDatabase::UpdateCommandSettings(const std::vector<std::pair<std::string, uint8>> &injected, const std::vector<std::string> &orphaned)
|
||||
bool SharedDatabase::UpdateInjectedCommandSettings(const std::vector<std::pair<std::string, uint8>> &injected)
|
||||
{
|
||||
bool return_value = true;
|
||||
|
||||
if (injected.size()) {
|
||||
|
||||
std::string query = fmt::format(
|
||||
@ -1486,7 +1484,7 @@ bool SharedDatabase::UpdateCommandSettings(const std::vector<std::pair<std::stri
|
||||
);
|
||||
|
||||
if (!QueryDatabase(query).Success()) {
|
||||
return_value = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
Log(Logs::General,
|
||||
@ -1497,6 +1495,11 @@ bool SharedDatabase::UpdateCommandSettings(const std::vector<std::pair<std::stri
|
||||
);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SharedDatabase::UpdateOrphanedCommandSettings(const std::vector<std::string> &orphaned)
|
||||
{
|
||||
if (orphaned.size()) {
|
||||
|
||||
std::string query = fmt::format(
|
||||
@ -1505,7 +1508,7 @@ bool SharedDatabase::UpdateCommandSettings(const std::vector<std::pair<std::stri
|
||||
);
|
||||
|
||||
if (!QueryDatabase(query).Success()) {
|
||||
return_value = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
Log(Logs::General,
|
||||
@ -1516,7 +1519,7 @@ bool SharedDatabase::UpdateCommandSettings(const std::vector<std::pair<std::stri
|
||||
);
|
||||
}
|
||||
|
||||
return return_value;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SharedDatabase::LoadSkillCaps(const std::string &prefix) {
|
||||
|
||||
@ -71,7 +71,8 @@ class SharedDatabase : public Database
|
||||
void LoadCharacterInspectMessage(uint32 character_id, InspectMessage_Struct* message);
|
||||
void SaveCharacterInspectMessage(uint32 character_id, const InspectMessage_Struct* message);
|
||||
bool GetCommandSettings(std::map<std::string, std::pair<uint8, std::vector<std::string>>> &command_settings);
|
||||
bool UpdateCommandSettings(const std::vector<std::pair<std::string, uint8>> &injected, const std::vector<std::string> &orphaned);
|
||||
bool UpdateInjectedCommandSettings(const std::vector<std::pair<std::string, uint8>> &injected);
|
||||
bool UpdateOrphanedCommandSettings(const std::vector<std::string> &orphaned);
|
||||
uint32 GetTotalTimeEntitledOnAccount(uint32 AccountID);
|
||||
void SetMailKey(int CharID, int IPAddress, int MailKey);
|
||||
std::string GetMailKey(int CharID, bool key_only = false);
|
||||
|
||||
@ -1429,6 +1429,26 @@ int bot_command_init(void)
|
||||
std::vector<std::pair<std::string, uint8>> injected_bot_command_settings;
|
||||
std::vector<std::string> orphaned_bot_command_settings;
|
||||
|
||||
for (auto bcs_iter : bot_command_settings) {
|
||||
|
||||
auto bcl_iter = bot_command_list.find(bcs_iter.first);
|
||||
if (bcl_iter == bot_command_list.end()) {
|
||||
|
||||
orphaned_bot_command_settings.push_back(bcs_iter.first);
|
||||
Log(Logs::General,
|
||||
Logs::Status,
|
||||
"Bot Command '%s' no longer exists... Deleting orphaned entry from `bot_command_settings` table...",
|
||||
bcs_iter.first.c_str()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (orphaned_bot_command_settings.size()) {
|
||||
if (!database.botdb.UpdateOrphanedBotCommandSettings(orphaned_bot_command_settings)) {
|
||||
Log(Logs::General, Logs::Zone_Server, "Failed to process 'Orphaned Bot Commands' update operation.");
|
||||
}
|
||||
}
|
||||
|
||||
auto working_bcl = bot_command_list;
|
||||
for (auto working_bcl_iter : working_bcl) {
|
||||
|
||||
@ -1493,23 +1513,11 @@ int bot_command_init(void)
|
||||
}
|
||||
}
|
||||
|
||||
for (auto bcs_iter : bot_command_settings) {
|
||||
|
||||
auto bcl_iter = bot_command_list.find(bcs_iter.first);
|
||||
if (bcl_iter == bot_command_list.end()) {
|
||||
|
||||
orphaned_bot_command_settings.push_back(bcs_iter.first);
|
||||
Log(Logs::General,
|
||||
Logs::Status,
|
||||
"Bot Command '%s' no longer exists... Deleting orphaned entry from `bot_command_settings` table...",
|
||||
bcs_iter.first.c_str()
|
||||
);
|
||||
if (injected_bot_command_settings.size()) {
|
||||
if (!database.botdb.UpdateInjectedBotCommandSettings(injected_bot_command_settings)) {
|
||||
Log(Logs::General, Logs::Zone_Server, "Failed to process 'Injected Bot Commands' update operation.");
|
||||
}
|
||||
}
|
||||
|
||||
if (injected_bot_command_settings.size() || orphaned_bot_command_settings.size()) {
|
||||
database.botdb.UpdateBotCommandSettings(injected_bot_command_settings, orphaned_bot_command_settings);
|
||||
}
|
||||
|
||||
bot_command_dispatch = bot_command_real_dispatch;
|
||||
|
||||
|
||||
@ -54,10 +54,8 @@ bool BotDatabase::LoadBotCommandSettings(std::map<std::string, std::pair<uint8,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BotDatabase::UpdateBotCommandSettings(const std::vector<std::pair<std::string, uint8>> &injected, const std::vector<std::string> &orphaned)
|
||||
bool BotDatabase::UpdateInjectedBotCommandSettings(const std::vector<std::pair<std::string, uint8>> &injected)
|
||||
{
|
||||
bool return_value = true;
|
||||
|
||||
if (injected.size()) {
|
||||
|
||||
query = fmt::format(
|
||||
@ -70,7 +68,7 @@ bool BotDatabase::UpdateBotCommandSettings(const std::vector<std::pair<std::stri
|
||||
);
|
||||
|
||||
if (!database.QueryDatabase(query).Success()) {
|
||||
return_value = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
Log(Logs::General,
|
||||
@ -81,6 +79,11 @@ bool BotDatabase::UpdateBotCommandSettings(const std::vector<std::pair<std::stri
|
||||
);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BotDatabase::UpdateOrphanedBotCommandSettings(const std::vector<std::string> &orphaned)
|
||||
{
|
||||
if (orphaned.size()) {
|
||||
|
||||
query = fmt::format(
|
||||
@ -89,7 +92,7 @@ bool BotDatabase::UpdateBotCommandSettings(const std::vector<std::pair<std::stri
|
||||
);
|
||||
|
||||
if (!database.QueryDatabase(query).Success()) {
|
||||
return_value = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
Log(Logs::General,
|
||||
@ -100,7 +103,7 @@ bool BotDatabase::UpdateBotCommandSettings(const std::vector<std::pair<std::stri
|
||||
);
|
||||
}
|
||||
|
||||
return return_value;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BotDatabase::LoadBotSpellCastingChances()
|
||||
|
||||
@ -43,7 +43,8 @@ class BotDatabase
|
||||
{
|
||||
public:
|
||||
bool LoadBotCommandSettings(std::map<std::string, std::pair<uint8, std::vector<std::string>>> &bot_command_settings);
|
||||
bool UpdateBotCommandSettings(const std::vector<std::pair<std::string, uint8>> &injected, const std::vector<std::string> &orphaned);
|
||||
bool UpdateInjectedBotCommandSettings(const std::vector<std::pair<std::string, uint8>> &injected);
|
||||
bool UpdateOrphanedBotCommandSettings(const std::vector<std::string> &orphaned);
|
||||
bool LoadBotSpellCastingChances();
|
||||
|
||||
|
||||
|
||||
@ -456,6 +456,26 @@ int command_init(void)
|
||||
std::vector<std::pair<std::string, uint8>> injected_command_settings;
|
||||
std::vector<std::string> orphaned_command_settings;
|
||||
|
||||
for (auto cs_iter : command_settings) {
|
||||
|
||||
auto cl_iter = commandlist.find(cs_iter.first);
|
||||
if (cl_iter == commandlist.end()) {
|
||||
|
||||
orphaned_command_settings.push_back(cs_iter.first);
|
||||
Log(Logs::General,
|
||||
Logs::Status,
|
||||
"Command '%s' no longer exists... Deleting orphaned entry from `command_settings` table...",
|
||||
cs_iter.first.c_str()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (orphaned_command_settings.size()) {
|
||||
if (!database.UpdateOrphanedCommandSettings(orphaned_command_settings)) {
|
||||
Log(Logs::General, Logs::Zone_Server, "Failed to process 'Orphaned Commands' update operation.");
|
||||
}
|
||||
}
|
||||
|
||||
auto working_cl = commandlist;
|
||||
for (auto working_cl_iter : working_cl) {
|
||||
|
||||
@ -520,24 +540,12 @@ int command_init(void)
|
||||
}
|
||||
}
|
||||
|
||||
for (auto cs_iter : command_settings) {
|
||||
|
||||
auto cl_iter = commandlist.find(cs_iter.first);
|
||||
if (cl_iter == commandlist.end()) {
|
||||
|
||||
orphaned_command_settings.push_back(cs_iter.first);
|
||||
Log(Logs::General,
|
||||
Logs::Status,
|
||||
"Command '%s' no longer exists... Deleting orphaned entry from `command_settings` table...",
|
||||
cs_iter.first.c_str()
|
||||
);
|
||||
if (injected_command_settings.size()) {
|
||||
if (!database.UpdateInjectedCommandSettings(injected_command_settings)) {
|
||||
Log(Logs::General, Logs::Zone_Server, "Failed to process 'Injected Commands' update operation.");
|
||||
}
|
||||
}
|
||||
|
||||
if (injected_command_settings.size() || orphaned_command_settings.size()) {
|
||||
database.UpdateCommandSettings(injected_command_settings, orphaned_command_settings);
|
||||
}
|
||||
|
||||
command_dispatch = command_realdispatch;
|
||||
|
||||
return commandcount;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user