[Bots] Convert Bot Database Methods to Repositories (#4023)

* [Bots] Convert Bot Database Methods to Repositories

* Final push.

* Cleanup.

* Cleanup.

* Update bot_database.cpp

* Update bot_database.cpp

* Update bot_database.cpp

* Update bot_database.cpp

* Update bot_database.cpp
This commit is contained in:
Alex King
2024-01-28 21:23:31 -05:00
committed by GitHub
parent 7a770e0e08
commit ce907c9519
31 changed files with 3570 additions and 2679 deletions
+22 -132
View File
@@ -228,17 +228,10 @@ Bot::Bot(
strcpy(name, GetCleanName());
memset(&_botInspectMessage, 0, sizeof(InspectMessage_Struct));
if (!database.botdb.LoadInspectMessage(GetBotID(), _botInspectMessage) && bot_owner)
bot_owner->Message(Chat::White, "%s for '%s'", BotDatabase::fail::LoadInspectMessage(), GetCleanName());
std::string error_message;
database.botdb.LoadInspectMessage(GetBotID(), _botInspectMessage);
EquipBot(&error_message);
if (!error_message.empty()) {
if (bot_owner)
bot_owner->Message(Chat::White, error_message.c_str());
error_message.clear();
}
EquipBot();
if (GetClass() == Class::Rogue) {
m_evade_timer.Start();
@@ -252,17 +245,12 @@ Bot::Bot(
GenerateBaseStats();
bot_timers.clear();
if (!database.botdb.LoadTimers(this) && bot_owner) {
bot_owner->Message(Chat::White, "%s for '%s'", BotDatabase::fail::LoadTimers(), GetCleanName());
}
database.botdb.LoadTimers(this);
LoadAAs();
if (!database.botdb.LoadBuffs(this)) {
if (bot_owner) {
bot_owner->Message(Chat::White, "&s for '%s'", BotDatabase::fail::LoadBuffs(), GetCleanName());
}
} else {
if (database.botdb.LoadBuffs(this)) {
//reapply some buffs
uint32 buff_count = GetMaxBuffSlots();
for (uint32 j1 = 0; j1 < buff_count; j1++) {
@@ -1335,38 +1323,23 @@ bool Bot::Save()
if (!bot_owner)
return false;
std::string error_message;
if (!GetBotID()) { // New bot record
uint32 bot_id = 0;
if (!database.botdb.SaveNewBot(this, bot_id) || !bot_id) {
bot_owner->Message(Chat::White, "%s '%s'", BotDatabase::fail::SaveNewBot(), GetCleanName());
return false;
}
SetBotID(bot_id);
}
else { // Update existing bot record
if (!database.botdb.SaveBot(this)) {
bot_owner->Message(Chat::White, "%s '%s'", BotDatabase::fail::SaveBot(), GetCleanName());
return false;
}
}
// All of these continue to process if any fail
if (!database.botdb.SaveBuffs(this))
bot_owner->Message(Chat::White, "%s for '%s'", BotDatabase::fail::SaveBuffs(), GetCleanName());
if (!database.botdb.SaveTimers(this))
bot_owner->Message(Chat::White, "%s for '%s'", BotDatabase::fail::SaveTimers(), GetCleanName());
if (!database.botdb.SaveStance(this)) {
bot_owner->Message(
Chat::White,
fmt::format(
"Failed to save stance for '{}'.",
GetCleanName()
).c_str()
);
}
database.botdb.SaveBuffs(this);
database.botdb.SaveTimers(this);
database.botdb.SaveStance(this);
if (!SavePet())
bot_owner->Message(Chat::White, "Failed to save pet for '%s'", GetCleanName());
@@ -1382,7 +1355,6 @@ bool Bot::DeleteBot()
}
if (!database.botdb.DeleteHealRotation(GetBotID())) {
bot_owner->Message(Chat::White, "%s", BotDatabase::fail::DeleteHealRotation());
return false;
}
@@ -1413,65 +1385,23 @@ bool Bot::DeleteBot()
RemoveBotFromRaid(this);
}
std::string error_message;
if (!database.botdb.DeleteItems(GetBotID())) {
bot_owner->Message(
Chat::White,
fmt::format(
"{} for '{}'.",
BotDatabase::fail::DeleteItems(),
GetCleanName()
).c_str()
);
return false;
}
if (!database.botdb.DeleteTimers(GetBotID())) {
bot_owner->Message(
Chat::White,
fmt::format(
"{} for '{}'.",
BotDatabase::fail::DeleteTimers(),
GetCleanName()
).c_str()
);
return false;
}
if (!database.botdb.DeleteBuffs(GetBotID())) {
bot_owner->Message(
Chat::White,
fmt::format(
"{} for '{}'.",
BotDatabase::fail::DeleteBuffs(),
GetCleanName()
).c_str()
);
return false;
}
if (!database.botdb.DeleteStance(GetBotID())) {
bot_owner->Message(
Chat::White,
fmt::format(
"{} for '{}'.",
BotDatabase::fail::DeleteStance(),
GetCleanName()
).c_str()
);
return false;
}
if (!database.botdb.DeleteBot(GetBotID())) {
bot_owner->Message(
Chat::White,
fmt::format(
"{} '{}'",
BotDatabase::fail::DeleteBot(),
GetCleanName()
).c_str()
);
return false;
}
@@ -1511,20 +1441,16 @@ bool Bot::LoadPet()
}
}
std::string error_message;
uint32 pet_index = 0;
if (!database.botdb.LoadPetIndex(GetBotID(), pet_index)) {
bot_owner->Message(Chat::White, "%s for %s's pet", BotDatabase::fail::LoadPetIndex(), GetCleanName());
return false;
}
if (!pet_index)
return true;
uint32 saved_pet_spell_id = 0;
if (!database.botdb.LoadPetSpellID(GetBotID(), saved_pet_spell_id)) {
bot_owner->Message(Chat::White, "%s for %s's pet", BotDatabase::fail::LoadPetSpellID(), GetCleanName());
}
database.botdb.LoadPetSpellID(GetBotID(), saved_pet_spell_id);
if (!IsValidSpell(saved_pet_spell_id)) {
bot_owner->Message(Chat::White, "Invalid spell id for %s's pet", GetCleanName());
DeletePet();
@@ -1537,7 +1463,6 @@ bool Bot::LoadPet()
uint32 pet_spell_id = 0;
if (!database.botdb.LoadPetStats(GetBotID(), pet_name, pet_mana, pet_hp, pet_spell_id)) {
bot_owner->Message(Chat::White, "%s for %s's pet", BotDatabase::fail::LoadPetStats(), GetCleanName());
return false;
}
@@ -1551,13 +1476,11 @@ bool Bot::LoadPet()
SpellBuff_Struct pet_buffs[PET_BUFF_COUNT];
memset(pet_buffs, 0, (sizeof(SpellBuff_Struct) * PET_BUFF_COUNT));
if (!database.botdb.LoadPetBuffs(GetBotID(), pet_buffs))
bot_owner->Message(Chat::White, "%s for %s's pet", BotDatabase::fail::LoadPetBuffs(), GetCleanName());
database.botdb.LoadPetBuffs(GetBotID(), pet_buffs);
uint32 pet_items[EQ::invslot::EQUIPMENT_COUNT];
memset(pet_items, 0, (sizeof(uint32) * EQ::invslot::EQUIPMENT_COUNT));
if (!database.botdb.LoadPetItems(GetBotID(), pet_items))
bot_owner->Message(Chat::White, "%s for %s's pet", BotDatabase::fail::LoadPetItems(), GetCleanName());
database.botdb.LoadPetItems(GetBotID(), pet_items);
pet_inst->SetPetState(pet_buffs, pet_items);
pet_inst->CalcBonuses();
@@ -1596,17 +1519,12 @@ bool Bot::SavePet()
std::string pet_name_str = pet_name;
safe_delete_array(pet_name)
std::string error_message;
if (!database.botdb.SavePetStats(GetBotID(), pet_name_str, pet_inst->GetMana(), pet_inst->GetHP(), pet_inst->GetPetSpellID())) {
bot_owner->Message(Chat::White, "%s for %s's pet", BotDatabase::fail::SavePetStats(), GetCleanName());
return false;
}
if (!database.botdb.SavePetBuffs(GetBotID(), pet_buffs))
bot_owner->Message(Chat::White, "%s for %s's pet", BotDatabase::fail::SavePetBuffs(), GetCleanName());
if (!database.botdb.SavePetItems(GetBotID(), pet_items))
bot_owner->Message(Chat::White, "%s for %s's pet", BotDatabase::fail::SavePetItems(), GetCleanName());
database.botdb.SavePetBuffs(GetBotID(), pet_buffs);
database.botdb.SavePetItems(GetBotID(), pet_items);
return true;
}
@@ -1617,18 +1535,13 @@ bool Bot::DeletePet()
if (!bot_owner)
return false;
std::string error_message;
if (!database.botdb.DeletePetItems(GetBotID())) {
bot_owner->Message(Chat::White, "%s for %s's pet", BotDatabase::fail::DeletePetItems(), GetCleanName());
return false;
}
if (!database.botdb.DeletePetBuffs(GetBotID())) {
bot_owner->Message(Chat::White, "%s for %s's pet", BotDatabase::fail::DeletePetBuffs(), GetCleanName());
return false;
}
if (!database.botdb.DeletePetStats(GetBotID())) {
bot_owner->Message(Chat::White, "%s for %s's pet", BotDatabase::fail::DeletePetStats(), GetCleanName());
return false;
}
@@ -3379,29 +3292,26 @@ bool Bot::Spawn(Client* botCharacterOwner) {
}
// Deletes the inventory record for the specified item from the database for this bot.
void Bot::RemoveBotItemBySlot(uint16 slot_id, std::string *error_message)
void Bot::RemoveBotItemBySlot(uint16 slot_id)
{
if (!GetBotID()) {
return;
}
if (!database.botdb.DeleteItemBySlot(GetBotID(), slot_id)) {
*error_message = BotDatabase::fail::DeleteItemBySlot();
}
database.botdb.DeleteItemBySlot(GetBotID(), slot_id);
m_inv.DeleteItem(slot_id);
UpdateEquipmentLight();
}
// Retrieves all the inventory records from the database for this bot.
void Bot::GetBotItems(EQ::InventoryProfile &inv, std::string* error_message)
void Bot::GetBotItems(EQ::InventoryProfile &inv)
{
if (!GetBotID()) {
return;
}
if (!database.botdb.LoadItems(GetBotID(), inv)) {
*error_message = BotDatabase::fail::LoadItems();
return;
}
@@ -3732,7 +3642,7 @@ void Bot::BotRemoveEquipItem(uint16 slot_id)
}
}
void Bot::BotTradeAddItem(const EQ::ItemInstance* inst, uint16 slot_id, std::string* error_message, bool save_to_database)
void Bot::BotTradeAddItem(const EQ::ItemInstance* inst, uint16 slot_id, bool save_to_database)
{
if (!inst) {
return;
@@ -3740,7 +3650,6 @@ void Bot::BotTradeAddItem(const EQ::ItemInstance* inst, uint16 slot_id, std::str
if (save_to_database) {
if (!database.botdb.SaveItemBySlot(this, slot_id, inst)) {
*error_message = BotDatabase::fail::SaveItemBySlot();
return;
}
@@ -3848,21 +3757,7 @@ void Bot::RemoveBotItem(uint32 item_id) {
if (inst->GetID() == item_id) {
std::string error_message;
RemoveBotItemBySlot(slot_id, &error_message);
if (!error_message.empty()) {
if (GetOwner()) {
GetOwner()->CastToClient()->Message(
Chat::White,
fmt::format(
"Database Error: {}",
error_message
).c_str()
);
}
return;
}
RemoveBotItemBySlot(slot_id);
BotRemoveEquipItem(slot_id);
CalcBotStats(GetOwner()->CastToClient()->GetBotOption(Client::booStatsUpdate));
return;
@@ -5389,18 +5284,15 @@ bool Bot::IsBotAttackAllowed(Mob* attacker, Mob* target, bool& hasRuleDefined) {
return Result;
}
void Bot::EquipBot(std::string* error_message) {
GetBotItems(m_inv, error_message);
void Bot::EquipBot() {
GetBotItems(m_inv);
const EQ::ItemInstance* inst = nullptr;
const EQ::ItemData* item = nullptr;
for (int slot_id = EQ::invslot::EQUIPMENT_BEGIN; slot_id <= EQ::invslot::EQUIPMENT_END; ++slot_id) {
inst = GetBotItem(slot_id);
if (inst) {
item = inst->GetItem();
BotTradeAddItem(inst, slot_id, error_message, false);
if (!error_message->empty()) {
return;
}
BotTradeAddItem(inst, slot_id, false);
}
}
UpdateEquipmentLight();
@@ -8131,8 +8023,6 @@ bool Bot::DyeArmor(int16 slot_id, uint32 rgb, bool all_flag, bool save_flag)
save_slot = -2;
if (!database.botdb.SaveEquipmentColor(GetBotID(), save_slot, rgb)) {
if (GetBotOwner() && GetBotOwner()->IsClient())
GetBotOwner()->CastToClient()->Message(Chat::White, "%s", BotDatabase::fail::SaveEquipmentColor());
return false;
}
}
+5 -4
View File
@@ -386,8 +386,8 @@ public:
bool CheckDataBucket(std::string bucket_name, const std::string& bucket_value, uint8 bucket_comparison);
// Bot Equipment & Inventory Class Methods
void BotTradeAddItem(const EQ::ItemInstance* inst, uint16 slot_id, std::string* error_message, bool save_to_database = true);
void EquipBot(std::string* error_message);
void BotTradeAddItem(const EQ::ItemInstance* inst, uint16 slot_id, bool save_to_database = true);
void EquipBot();
bool CheckLoreConflict(const EQ::ItemData* item);
void UpdateEquipmentLight() override
{
@@ -704,7 +704,8 @@ public:
uint32 attack
);
void BotRemoveEquipItem(uint16 slot_id);
void RemoveBotItemBySlot(uint16 slot_id, std::string* error_message);
void RemoveBotItemBySlot(uint16 slot_id
);
void AddBotItem(
uint16 slot_id,
uint32 item_id,
@@ -938,7 +939,7 @@ private:
void SetReturningFlag(bool flag = true) { m_returning_flag = flag; }
// Private "Inventory" Methods
void GetBotItems(EQ::InventoryProfile &inv, std::string* error_message);
void GetBotItems(EQ::InventoryProfile &inv);
void BotAddEquipItem(uint16 slot_id, uint32 item_id);
// Private "Pet" Methods
+32 -108
View File
@@ -5843,7 +5843,7 @@ void bot_subcommand_bot_clone(Client *c, const Seperator *sep)
}
uint32 clone_id = 0;
if (!database.botdb.CreateCloneBot(c->CharacterID(), my_bot->GetBotID(), bot_name, clone_id) || !clone_id) {
if (!database.botdb.CreateCloneBot(my_bot->GetBotID(), bot_name, clone_id) || !clone_id) {
c->Message(
Chat::White,
fmt::format(
@@ -5875,7 +5875,7 @@ void bot_subcommand_bot_clone(Client *c, const Seperator *sep)
);
}
if (!database.botdb.CreateCloneBotInventory(c->CharacterID(), my_bot->GetBotID(), clone_id)) {
if (!database.botdb.CreateCloneBotInventory(my_bot->GetBotID(), clone_id)) {
c->Message(
Chat::White,
fmt::format(
@@ -6361,25 +6361,9 @@ void bot_subcommand_bot_dye_armor(Client *c, const Seperator *sep)
if (ab_type == ActionableBots::ABT_All) {
if (dye_all) {
if (!database.botdb.SaveAllArmorColors(c->CharacterID(), rgb_value)) {
c->Message(
Chat::White,
fmt::format(
"{}",
BotDatabase::fail::SaveAllArmorColors()
).c_str()
);
}
database.botdb.SaveAllArmorColors(c->CharacterID(), rgb_value);
} else {
if (!database.botdb.SaveAllArmorColorBySlot(c->CharacterID(), slot_id, rgb_value)) {
c->Message(
Chat::White,
fmt::format(
"{}",
BotDatabase::fail::SaveAllArmorColorBySlot()
).c_str()
);
}
database.botdb.SaveAllArmorColorBySlot(c->CharacterID(), slot_id, rgb_value);
}
}
}
@@ -6527,8 +6511,7 @@ void bot_subcommand_bot_follow_distance(Client *c, const Seperator *sep)
continue;
bot_iter->SetFollowDistance(bfd);
if (ab_type != ActionableBots::ABT_All && !database.botdb.SaveFollowDistance(c->CharacterID(), bot_iter->GetBotID(), bfd)) {
c->Message(Chat::White, "%s for '%s'", BotDatabase::fail::SaveFollowDistance(), bot_iter->GetCleanName());
if (ab_type != ActionableBots::ABT_All && !database.botdb.SaveFollowDistance(bot_iter->GetBotID(), bfd)) {
return;
}
@@ -6537,7 +6520,6 @@ void bot_subcommand_bot_follow_distance(Client *c, const Seperator *sep)
if (ab_type == ActionableBots::ABT_All) {
if (!database.botdb.SaveAllFollowDistances(c->CharacterID(), bfd)) {
c->Message(Chat::White, "%s", BotDatabase::fail::SaveAllFollowDistances());
return;
}
@@ -6706,7 +6688,6 @@ void bot_subcommand_bot_inspect_message(Client *c, const Seperator *sep)
memcpy(bot_message_struct, client_message_struct, sizeof(InspectMessage_Struct));
if (ab_type != ActionableBots::ABT_All && !database.botdb.SaveInspectMessage(bot_iter->GetBotID(), *bot_message_struct)) {
c->Message(Chat::White, "%s for '%s'", BotDatabase::fail::SaveInspectMessage(), bot_iter->GetCleanName());
return;
}
@@ -6720,7 +6701,6 @@ void bot_subcommand_bot_inspect_message(Client *c, const Seperator *sep)
memcpy(&bot_message_struct, client_message_struct, sizeof(InspectMessage_Struct));
if (!database.botdb.SaveAllInspectMessages(c->CharacterID(), bot_message_struct)) {
c->Message(Chat::White, "%s", BotDatabase::fail::SaveAllInspectMessages());
return;
}
@@ -6800,7 +6780,6 @@ void bot_subcommand_bot_list(Client *c, const Seperator *sep)
std::list<BotsAvailableList> bots_list;
if (!database.botdb.LoadBotsList(c->CharacterID(), bots_list, Account)) {
c->Message(Chat::White, "%s", BotDatabase::fail::LoadBotsList());
return;
}
@@ -6814,18 +6793,18 @@ void bot_subcommand_bot_list(Client *c, const Seperator *sep)
auto bot_number = 1;
for (auto bots_iter : bots_list) {
if (filter_mask) {
if ((filter_mask & MaskClass) && filter_value[FilterClass] != bots_iter.Class) {
if ((filter_mask & MaskClass) && filter_value[FilterClass] != bots_iter.class_) {
continue;
}
if ((filter_mask & MaskRace) && filter_value[FilterRace] != bots_iter.Race) {
if ((filter_mask & MaskRace) && filter_value[FilterRace] != bots_iter.race) {
continue;
}
if (filter_mask & MaskName) {
std::string name_criteria = sep->arg[name_criteria_arg];
std::transform(name_criteria.begin(), name_criteria.end(), name_criteria.begin(), ::tolower);
std::string name_check = bots_iter.Name;
std::string name_check = bots_iter.bot_name;
std::transform(name_check.begin(), name_check.end(), name_check.begin(), ::tolower);
if (name_check.find(name_criteria) == std::string::npos) {
continue;
@@ -6833,7 +6812,7 @@ void bot_subcommand_bot_list(Client *c, const Seperator *sep)
}
}
auto* bot = entity_list.GetBotByBotName(bots_iter.Name);
auto* bot = entity_list.GetBotByBotName(bots_iter.bot_name);
c->Message(
Chat::White,
@@ -6841,22 +6820,22 @@ void bot_subcommand_bot_list(Client *c, const Seperator *sep)
"Bot {} | {} is a Level {} {} {} {} owned by {}.",
bot_number,
(
(c->CharacterID() == bots_iter.Owner_ID && !bot) ?
(c->CharacterID() == bots_iter.owner_id && !bot) ?
Saylink::Silent(
fmt::format("^spawn {}", bots_iter.Name),
bots_iter.Name
fmt::format("^spawn {}", bots_iter.bot_name),
bots_iter.bot_name
) :
bots_iter.Name
bots_iter.bot_name
),
bots_iter.Level,
GetGenderName(bots_iter.Gender),
GetRaceIDName(bots_iter.Race),
GetClassIDName(bots_iter.Class),
bots_iter.Owner
bots_iter.level,
GetGenderName(bots_iter.gender),
GetRaceIDName(bots_iter.race),
GetClassIDName(bots_iter.class_),
bots_iter.owner_name
).c_str()
);
if (c->CharacterID() == bots_iter.Owner_ID) {
if (c->CharacterID() == bots_iter.owner_id) {
bots_owned++;
}
@@ -6975,10 +6954,7 @@ void bot_subcommand_bot_surname(Client *c, const Seperator *sep)
std::replace(bot_surname.begin(), bot_surname.end(), '_', ' ');
my_bot->SetSurname(bot_surname);
if (!database.botdb.SaveBot(my_bot)) {
c->Message(Chat::White, BotDatabase::fail::SaveBot());
}
else {
if (database.botdb.SaveBot(my_bot)) {
c->Message(Chat::White, "Bot Surname Saved.");
}
}
@@ -7003,10 +6979,7 @@ void bot_subcommand_bot_title(Client *c, const Seperator *sep)
std::replace(bot_title.begin(), bot_title.end(), '_', ' ');
my_bot->SetTitle(bot_title);
if (!database.botdb.SaveBot(my_bot)) {
c->Message(Chat::White, BotDatabase::fail::SaveBot());
}
else {
if (database.botdb.SaveBot(my_bot)) {
c->Message(Chat::White, "Bot Title Saved.");
}
}
@@ -7031,10 +7004,7 @@ void bot_subcommand_bot_suffix(Client *c, const Seperator *sep)
std::replace(bot_suffix.begin(), bot_suffix.end(), '_', ' ');
my_bot->SetSuffix(bot_suffix);
if (!database.botdb.SaveBot(my_bot)) {
c->Message(Chat::White, BotDatabase::fail::SaveBot());
}
else {
if (database.botdb.SaveBot(my_bot)) {
c->Message(Chat::White, "Bot Suffix Saved.");
}
}
@@ -7149,7 +7119,7 @@ void bot_subcommand_bot_spawn(Client *c, const Seperator *sep)
uint32 bot_id = 0;
uint8 bot_class = Class::None;
if (!database.botdb.LoadBotID(c->CharacterID(), bot_name, bot_id, bot_class)) {
if (!database.botdb.LoadBotID(bot_name, bot_id, bot_class)) {
c->Message(
Chat::White,
fmt::format(
@@ -7387,8 +7357,7 @@ void bot_subcommand_bot_stop_melee_level(Client *c, const Seperator *sep)
// [reset] falls through with initialization value
my_bot->SetStopMeleeLevel(sml);
if (!database.botdb.SaveStopMeleeLevel(c->CharacterID(), my_bot->GetBotID(), sml))
c->Message(Chat::White, "%s for '%s'", BotDatabase::fail::SaveStopMeleeLevel(), my_bot->GetCleanName());
database.botdb.SaveStopMeleeLevel(my_bot->GetBotID(), sml);
c->Message(Chat::White, "Successfully set stop melee level for %s to %u", my_bot->GetCleanName(), sml);
}
@@ -7587,8 +7556,7 @@ void bot_subcommand_bot_toggle_helm(Client *c, const Seperator *sep)
bot_iter->SetShowHelm(helm_state);
if (ab_type != ActionableBots::ABT_All) {
if (!database.botdb.SaveHelmAppearance(c->CharacterID(), bot_iter->GetBotID(), bot_iter->GetShowHelm())) {
c->Message(Chat::White, "%s for '%s'", bot_iter->GetCleanName());
if (!database.botdb.SaveHelmAppearance(bot_iter->GetBotID(), bot_iter->GetShowHelm())) {
return;
}
@@ -7608,12 +7576,10 @@ void bot_subcommand_bot_toggle_helm(Client *c, const Seperator *sep)
if (ab_type == ActionableBots::ABT_All) {
if (toggle_helm) {
if (!database.botdb.ToggleAllHelmAppearances(c->CharacterID()))
c->Message(Chat::White, "%s", BotDatabase::fail::ToggleAllHelmAppearances());
database.botdb.ToggleAllHelmAppearances(c->CharacterID());
}
else {
if (!database.botdb.SaveAllHelmAppearances(c->CharacterID(), helm_state))
c->Message(Chat::White, "%s", BotDatabase::fail::SaveAllHelmAppearances());
database.botdb.SaveAllHelmAppearances(c->CharacterID(), helm_state);
}
c->Message(Chat::White, "%s all of your bot show helm flags", toggle_helm ? "Toggled" : (helm_state ? "Set" : "Cleared"));
@@ -8357,8 +8323,7 @@ void bot_subcommand_heal_rotation_create(Client *c, const Seperator *sep)
bool member_fail = false;
bool target_fail = false;
if (!database.botdb.LoadHealRotation(creator_member, member_list, target_list, load_flag, member_fail, target_fail))
c->Message(Chat::White, "%s", BotDatabase::fail::LoadHealRotation());
database.botdb.LoadHealRotation(creator_member, member_list, target_list, load_flag, member_fail, target_fail);
if (!load_flag) {
c->Message(Chat::White, "Successfully added %s as a current member to a new Heal Rotation", creator_member->GetCleanName());
@@ -8387,9 +8352,6 @@ void bot_subcommand_heal_rotation_create(Client *c, const Seperator *sep)
c->Message(Chat::White, "Could not locate member with bot id '%u'", member_iter);
}
}
else {
c->Message(Chat::White, "%s", BotDatabase::fail::LoadHealRotationMembers());
}
if (!target_fail) {
for (auto target_iter : target_list) {
@@ -8406,9 +8368,6 @@ void bot_subcommand_heal_rotation_create(Client *c, const Seperator *sep)
c->Message(Chat::White, "Failed to add target '%s'", target_mob->GetCleanName());
}
}
else {
c->Message(Chat::White, "%s", BotDatabase::fail::LoadHealRotationTargets());
}
c->Message(Chat::White, "Successfully loaded %s's Heal Rotation", creator_member->GetCleanName());
}
@@ -8430,11 +8389,7 @@ void bot_subcommand_heal_rotation_delete(Client *c, const Seperator *sep)
}
if (all_flag) {
if (database.botdb.DeleteAllHealRotations(c->CharacterID()))
c->Message(Chat::White, "Succeeded in deleting all heal rotations");
else
c->Message(Chat::White, "%s", BotDatabase::fail::DeleteAllHealRotations());
database.botdb.DeleteAllHealRotations(c->CharacterID());
return;
}
@@ -8454,7 +8409,6 @@ void bot_subcommand_heal_rotation_delete(Client *c, const Seperator *sep)
}
if (!database.botdb.DeleteHealRotation(current_member->GetBotID())) {
c->Message(Chat::White, "%s", BotDatabase::fail::DeleteHealRotation());
return;
}
@@ -8741,7 +8695,6 @@ void bot_subcommand_heal_rotation_save(Client *c, const Seperator *sep)
bool member_fail = false;
bool target_fail = false;
if (!database.botdb.SaveHealRotation(current_member, member_fail, target_fail)) {
c->Message(Chat::White, "%s", BotDatabase::fail::SaveHealRotation());
return;
}
if (member_fail)
@@ -8997,15 +8950,7 @@ void bot_subcommand_inventory_list(Client *c, const Seperator *sep)
}
uint32 database_count = 0;
if (!database.botdb.QueryInventoryCount(my_bot->GetBotID(), database_count)) {
c->Message(
Chat::White,
fmt::format(
"{}",
BotDatabase::fail::QueryInventoryCount()
).c_str()
);
}
database.botdb.QueryInventoryCount(my_bot->GetBotID(), database_count);
if (inventory_count != database_count) {
c->Message(
@@ -9114,7 +9059,6 @@ void bot_subcommand_inventory_remove(Client *c, const Seperator *sep)
return;
}
std::string error_message;
if (itm) {
EQ::SayLinkEngine linker;
linker.SetLinkType(EQ::saylink::SayLinkItemInst);
@@ -9128,18 +9072,7 @@ void bot_subcommand_inventory_remove(Client *c, const Seperator *sep)
my_bot->SetBotArcherySetting(false, true);
}
my_bot->RemoveBotItemBySlot(slot_id, &error_message);
if (!error_message.empty()) {
c->Message(
Chat::White,
fmt::format(
"Database Error: {}",
error_message
).c_str()
);
return;
}
my_bot->RemoveBotItemBySlot(slot_id);
my_bot->BotRemoveEquipItem(slot_id);
my_bot->CalcBotStats(c->GetBotOption(Client::booStatsUpdate));
@@ -10671,16 +10604,7 @@ void bot_command_caster_range(Client* c, const Seperator* sep)
my_bot->SetBotCasterRange(crange);
++success_count;
if (!database.botdb.SaveBotCasterRange(c->CharacterID(), my_bot->GetBotID(), crange)) {
c->Message(
Chat::White,
fmt::format(
"{} for '{}'",
BotDatabase::fail::SaveBotCasterRange(),
my_bot->GetCleanName()
).c_str()
);
}
database.botdb.SaveBotCasterRange(my_bot->GetBotID(), crange);
}
}
if (!current_check) {
+1367 -1793
View File
File diff suppressed because it is too large Load Diff
+19 -43
View File
@@ -50,31 +50,28 @@ public:
/* Bot functions */
bool QueryNameAvailablity(const std::string& bot_name, bool& available_flag);
bool QueryBotCount(const uint32 owner_id, int class_id, uint32& bot_count, uint32& bot_class_count);
bool LoadBotsList(const uint32 owner_id, std::list<BotsAvailableList>& bots_list, bool ByAccount = false);
bool LoadBotsList(const uint32 owner_id, std::list<BotsAvailableList>& bots_list, bool by_account = false);
bool LoadOwnerID(const std::string& bot_name, uint32& owner_id);
bool LoadOwnerID(const uint32 bot_id, uint32& owner_id);
uint32 GetOwnerID(const uint32 bot_id);
bool LoadBotID(const uint32 owner_id, const std::string& bot_name, uint32& bot_id);
bool LoadBotID(const uint32 owner_id, const std::string& bot_name, uint32& bot_id, uint8& bot_class_id);
bool LoadBotID(const std::string& bot_name, uint32& bot_id, uint8& bot_class_id);
bool LoadBot(const uint32 bot_id, Bot*& loaded_bot);
bool SaveNewBot(Bot* bot_inst, uint32& bot_id);
bool SaveBot(Bot* bot_inst);
bool SaveNewBot(Bot* b, uint32& bot_id);
bool SaveBot(Bot* b);
bool DeleteBot(const uint32 bot_id);
bool LoadBuffs(Bot* bot_inst);
bool SaveBuffs(Bot* bot_inst);
bool LoadBuffs(Bot* b);
bool SaveBuffs(Bot* b);
bool DeleteBuffs(const uint32 bot_id);
bool LoadStance(const uint32 bot_id, int& bot_stance);
bool LoadStance(Bot* bot_inst, bool& stance_flag);
bool LoadStance(Bot* b, bool& stance_flag);
bool SaveStance(const uint32 bot_id, const int bot_stance);
bool SaveStance(Bot* bot_inst);
bool SaveStance(Bot* b);
bool DeleteStance(const uint32 bot_id);
bool LoadTimers(Bot* bot_inst);
bool SaveTimers(Bot* bot_inst);
bool LoadTimers(Bot* b);
bool SaveTimers(Bot* b);
bool DeleteTimers(const uint32 bot_id);
@@ -82,17 +79,14 @@ public:
bool QueryInventoryCount(const uint32 bot_id, uint32& item_count);
bool LoadItems(const uint32 bot_id, EQ::InventoryProfile &inventory_inst);
bool SaveItems(Bot* bot_inst);
bool DeleteItems(const uint32 bot_id);
bool LoadItemSlots(const uint32 bot_id, std::map<uint16, uint32>& m);
bool LoadItemBySlot(Bot* bot_inst);
bool LoadItemBySlot(const uint32 bot_id, const uint32 slot_id, uint32& item_id);
bool SaveItemBySlot(Bot* bot_inst, const uint32 slot_id, const EQ::ItemInstance* item_inst);
bool SaveItemBySlot(Bot* b, const uint32 slot_id, const EQ::ItemInstance* inst);
bool DeleteItemBySlot(const uint32 bot_id, const uint32 slot_id);
bool LoadEquipmentColor(const uint32 bot_id, const uint8 material_slot_id, uint32& rgb);
bool SaveEquipmentColor(const uint32 bot_id, const int16 slot_id, const uint32 rgb);
bool SaveEquipmentColor(const uint32 bot_id, const int16 slot_id, const uint32 color);
bool SaveExpansionBitmask(const uint32 bot_id, const int expansion_bitmask);
bool SaveEnforceSpellSetting(const uint32 bot_id, const bool enforce_spell_setting);
@@ -126,19 +120,18 @@ public:
bool SaveAllArmorColorBySlot(const uint32 owner_id, const int16 slot_id, const uint32 rgb_value);
bool SaveAllArmorColors(const uint32 owner_id, const uint32 rgb_value);
bool SaveHelmAppearance(const uint32 owner_id, const uint32 bot_id, const bool show_flag = true);
bool SaveHelmAppearance(const uint32 bot_id, const bool show_flag = true);
bool SaveAllHelmAppearances(const uint32 owner_id, const bool show_flag = true);
bool ToggleHelmAppearance(const uint32 owner_id, const uint32 bot_id);
bool ToggleAllHelmAppearances(const uint32 owner_id);
bool SaveFollowDistance(const uint32 owner_id, const uint32 bot_id, const uint32 follow_distance);
bool SaveFollowDistance(const uint32 bot_id, const uint32 follow_distance);
bool SaveAllFollowDistances(const uint32 owner_id, const uint32 follow_distance);
bool CreateCloneBot(const uint32 owner_id, const uint32 bot_id, const std::string& clone_name, uint32& clone_id);
bool CreateCloneBotInventory(const uint32 owner_id, const uint32 bot_id, const uint32 clone_id);
bool CreateCloneBot(const uint32 bot_id, const std::string& clone_name, uint32& clone_id);
bool CreateCloneBotInventory(const uint32 bot_id, const uint32 clone_id);
bool SaveStopMeleeLevel(const uint32 owner_id, const uint32 bot_id, const uint8 sml_value);
bool SaveStopMeleeLevel(const uint32 bot_id, const uint8 sml_value);
bool SaveBotArcherSetting(const uint32 bot_id, const bool bot_archer_setting);
@@ -146,7 +139,7 @@ public:
bool SaveOwnerOption(const uint32 owner_id, size_t type, const bool flag);
bool SaveOwnerOption(const uint32 owner_id, const std::pair<size_t, size_t> type, const std::pair<bool, bool> flag);
bool SaveBotCasterRange(const uint32 owner_id, const uint32 bot_id, const uint32 bot_caster_range_value);
bool SaveBotCasterRange(const uint32 bot_id, const uint32 bot_caster_range_value);
/* Bot group functions */
bool LoadGroupedBotsByGroupID(const uint32 owner_id, const uint32 group_id, std::list<uint32>& group_list);
@@ -164,16 +157,12 @@ public:
/* Bot miscellaneous functions */
uint8 GetSpellCastingChance(uint8 spell_type_index, uint8 class_index, uint8 stance_index, uint8 conditional_index);
std::string GetBotNameByID(const uint32 bot_id);
uint16 GetRaceClassBitmask(uint16 bot_race);
uint32 GetRaceClassBitmask(uint32 bot_race);
class fail {
public:
/* fail::Bot functions */
static const char* LoadBotsList();
static const char* LoadOwnerID();
static const char* LoadBotID();
static const char* LoadBot();
static const char* SaveNewBot();
static const char* SaveBot();
@@ -189,11 +178,9 @@ public:
/* fail::Bot inventory functions */
static const char* QueryInventoryCount();
static const char* LoadItems();
static const char* SaveItems();
static const char* DeleteItems();
static const char* SaveItemBySlot();
static const char* DeleteItemBySlot();
static const char* LoadEquipmentColor();
static const char* SaveEquipmentColor();
/* fail::Bot pet functions */
@@ -212,34 +199,23 @@ public:
/* fail::Bot command functions */
static const char* LoadInspectMessage();
static const char* SaveInspectMessage();
static const char* DeleteInspectMessage();
static const char* SaveAllInspectMessages();
static const char* DeleteAllInspectMessages();
static const char* SaveAllArmorColorBySlot();
static const char* SaveAllArmorColors();
static const char* SaveHelmAppearance();
static const char* SaveAllHelmAppearances();
static const char* ToggleHelmAppearance();
static const char* ToggleAllHelmAppearances();
static const char* SaveFollowDistance();
static const char* SaveAllFollowDistances();
static const char* SaveStopMeleeLevel();
static const char* SaveBotCasterRange();
/* fail::Bot group functions */
static const char* LoadGroupedBotsByGroupID();
/* fail::Bot heal rotation functions */
static const char* LoadHealRotationIDByBotID();
static const char* LoadHealRotation();
static const char* LoadHealRotationMembers();
static const char* LoadHealRotationTargets();
static const char* SaveHealRotation();
static const char* DeleteHealRotation();
static const char* DeleteAllHealRotations();
/* fail::Bot miscellaneous functions */
static const char* GetBotNameByID();
};
private:
+4 -4
View File
@@ -25,7 +25,7 @@
#include "quest_parser_collection.h"
#include "../common/data_verification.h"
std::vector<RaidMember> Raid::GetRaidGroupMembers(uint32 gid)
std::vector<RaidMember> Raid::GetRaidGroupMembers(uint32 gid)
{
std::vector<RaidMember> raid_group_members;
raid_group_members.clear();
@@ -126,9 +126,9 @@ void Raid::HandleOfflineBots(uint32 owner) {
}
for (const auto& b: bots_list) {
if (IsRaidMember(b.Name)) {
if (IsRaidMember(b.bot_name)) {
for (const auto& m: members) {
if (m.is_bot && strcmp(m.member_name, b.Name) == 0) {
if (m.is_bot && strcmp(m.member_name, b.bot_name) == 0) {
uint32 gid = GetGroup(m.member_name);
SendRaidGroupRemove(m.member_name, gid);
RemoveMember(m.member_name);
@@ -313,7 +313,7 @@ void Client::SpawnRaidBotsOnConnect(Raid* raid) {
if (strlen(m.member_name) != 0) {
for (const auto& b: bots_list) {
if (strcmp(m.member_name, b.Name) == 0) {
if (strcmp(m.member_name, b.bot_name) == 0) {
std::string buffer = "^spawn ";
buffer.append(m.member_name);
bot_command_real_dispatch(this, buffer.c_str());
+8 -8
View File
@@ -24,14 +24,14 @@
#include <sstream>
struct BotsAvailableList {
uint32 ID;
char Name[64];
uint16 Class;
uint8 Level;
uint16 Race;
uint8 Gender;
char Owner[64];
uint32 Owner_ID;
uint32 bot_id;
char bot_name[64];
uint16 class_;
uint8 level;
uint16 race;
uint8 gender;
char owner_name[64];
uint32 owner_id;
};
struct BotSpell {