[Bots] Save Bot Toggle Archer Setting between Loads. (#2612)

* [Bots] Save Bot Toggle Archer Setting between Loads.

* [Bots] Save Bot Toggle Archer Setting between Loads.

* Typo
This commit is contained in:
Aeadoin
2022-12-04 13:23:25 -05:00
committed by GitHub
parent 7abc084cd1
commit 7e0fe93039
9 changed files with 80 additions and 21 deletions
+25 -1
View File
@@ -410,7 +410,8 @@ bool BotDatabase::LoadBot(const uint32 bot_id, Bot*& loaded_bot)
" `follow_distance`," // 26
" `stop_melee_level`," // 27
" `expansion_bitmask`," // 28
" `enforce_spell_settings`" // 29
" `enforce_spell_settings`," // 29
" `archery_setting`" // 30
" FROM `bot_data`"
" WHERE `bot_id` = {}"
" LIMIT 1",
@@ -511,6 +512,8 @@ bool BotDatabase::LoadBot(const uint32 bot_id, Bot*& loaded_bot)
loaded_bot->SetExpansionBitmask(eb, false);
loaded_bot->SetBotEnforceSpellSetting((std::stoi(row[29]) > 0 ? true : false));
loaded_bot->SetBotArcherySetting((std::stoi(row[30]) > 0 ? true : false));
}
return true;
@@ -3302,6 +3305,27 @@ bool BotDatabase::SaveEnforceSpellSetting(const uint32 bot_id, const bool enforc
return true;
}
bool BotDatabase::SaveBotArcherSetting(const uint32 bot_id, const bool bot_archer_setting)
{
if (!bot_id) {
return false;
}
query = fmt::format(
"UPDATE `bot_data`"
"SET `archery_setting` = {} "
"WHERE `bot_id` = {}",
(bot_archer_setting ? 1 : 0),
bot_id
);
auto results = database.QueryDatabase(query);
if (!results.Success()) {
return false;
}
return true;
}
/* fail::Bot functions */
const char* BotDatabase::fail::LoadBotsList() { return "Failed to bots list"; }
const char* BotDatabase::fail::LoadOwnerID() { return "Failed to load owner ID"; }