mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-17 03:08:26 +00:00
Updated Command Update code to report after each process handling rather than at the end
This commit is contained in:
+23
-15
@@ -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()
|
||||
|
||||
+2
-1
@@ -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();
|
||||
|
||||
|
||||
|
||||
+23
-15
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user