mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-14 19:51:29 +00:00
[Bug Fix] Fix Bot Group Loading (#2780)
* [Bots] Fix Bot Groups * unsigned.
This commit is contained in:
parent
4fe5522212
commit
cd63047e60
@ -7720,7 +7720,7 @@ void bot_subcommand_botgroup_list(Client *c, const Seperator *sep)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::list<std::pair<std::string, std::string>> botgroups_list;
|
std::list<std::pair<std::string, uint32>> botgroups_list;
|
||||||
if (!database.botdb.LoadBotGroupsListByOwnerID(c->CharacterID(), botgroups_list)) {
|
if (!database.botdb.LoadBotGroupsListByOwnerID(c->CharacterID(), botgroups_list)) {
|
||||||
c->Message(Chat::White, "Failed to load bot-group.");
|
c->Message(Chat::White, "Failed to load bot-group.");
|
||||||
return;
|
return;
|
||||||
@ -7733,17 +7733,17 @@ void bot_subcommand_botgroup_list(Client *c, const Seperator *sep)
|
|||||||
|
|
||||||
uint32 botgroup_count = 0;
|
uint32 botgroup_count = 0;
|
||||||
|
|
||||||
for (auto botgroups_iter : botgroups_list) {
|
for (const auto& [group_name, group_leader_id] : botgroups_list) {
|
||||||
c->Message(
|
c->Message(
|
||||||
Chat::White,
|
Chat::White,
|
||||||
fmt::format(
|
fmt::format(
|
||||||
"Bot-group {} | Name: {} | Leader: {}{} | {}",
|
"Bot-group {} | Name: {} | Leader: {}{} | {}",
|
||||||
(botgroup_count + 1),
|
(botgroup_count + 1),
|
||||||
botgroups_iter.first,
|
group_name,
|
||||||
botgroups_iter.second,
|
database.botdb.GetBotNameByID(group_leader_id),
|
||||||
database.botdb.IsBotGroupAutoSpawn(botgroups_iter.first) ? " (Auto Spawn)" : "",
|
database.botdb.IsBotGroupAutoSpawn(group_name) ? " (Auto Spawn)" : "",
|
||||||
Saylink::Silent(
|
Saylink::Silent(
|
||||||
fmt::format("^botgroupload {}", botgroups_iter.first),
|
fmt::format("^botgroupload {}", group_name),
|
||||||
"Load"
|
"Load"
|
||||||
)
|
)
|
||||||
).c_str()
|
).c_str()
|
||||||
|
|||||||
@ -2536,18 +2536,18 @@ bool BotDatabase::RemoveMemberFromBotGroup(const uint32 member_id)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BotDatabase::LoadBotGroupIDForLoadBotGroup(const uint32 owner_id, const std::string& group_name, uint32& botgroup_id)
|
bool BotDatabase::LoadBotGroupIDForLoadBotGroup(const uint32 owner_id, std::string_view group_name, uint32& botgroup_id)
|
||||||
{
|
{
|
||||||
if (!owner_id || group_name.empty()) {
|
if (!owner_id || group_name.empty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
query = fmt::format(
|
query = fmt::format(
|
||||||
"SELECT groups_index, group_name FROM "
|
"SELECT bg.groups_index, group_name FROM "
|
||||||
"bot_groups bg INNER JOIN bot_group_members bgm "
|
"bot_groups bg INNER JOIN bot_group_members bgm "
|
||||||
"ON bg.groups_index = bgm.groups_index "
|
"ON bg.groups_index = bgm.groups_index "
|
||||||
"WHERE bgm.bot_id IN "
|
"WHERE bgm.bot_id IN "
|
||||||
"(SELECT bot_id FROM bot_data WHERE WHERE owner_id = {})",
|
"(SELECT bot_id FROM bot_data WHERE owner_id = {})",
|
||||||
owner_id
|
owner_id
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -2606,7 +2606,7 @@ bool BotDatabase::LoadBotGroup(const std::string& group_name, std::map<uint32, s
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BotDatabase::LoadBotGroupsListByOwnerID(const uint32 owner_id, std::list<std::pair<std::string, std::string>>& botgroups_list)
|
bool BotDatabase::LoadBotGroupsListByOwnerID(const uint32 owner_id, std::list<std::pair<std::string, uint32>>& botgroups_list)
|
||||||
{
|
{
|
||||||
if (!owner_id) {
|
if (!owner_id) {
|
||||||
return false;
|
return false;
|
||||||
@ -2614,11 +2614,11 @@ bool BotDatabase::LoadBotGroupsListByOwnerID(const uint32 owner_id, std::list<st
|
|||||||
|
|
||||||
|
|
||||||
query = fmt::format(
|
query = fmt::format(
|
||||||
"SELECT group_name, group_leader_name FROM "
|
"SELECT group_name, group_leader_id FROM "
|
||||||
"bot_groups bg INNER JOIN bot_group_members bgm "
|
"bot_groups bg INNER JOIN bot_group_members bgm "
|
||||||
"ON bg.groups_index = bgm.groups_index "
|
"ON bg.groups_index = bgm.groups_index "
|
||||||
"WHERE bgm.bot_id IN "
|
"WHERE bgm.bot_id IN "
|
||||||
"(SELECT bot_id FROM bot_data WHERE WHERE owner_id = {})",
|
"(SELECT bot_id FROM bot_data WHERE owner_id = {})",
|
||||||
owner_id
|
owner_id
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -2632,7 +2632,7 @@ bool BotDatabase::LoadBotGroupsListByOwnerID(const uint32 owner_id, std::list<st
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (auto row : results) {
|
for (auto row : results) {
|
||||||
botgroups_list.push_back(std::pair<std::string, std::string>(row[0], row[1]));
|
botgroups_list.push_back(std::pair<std::string, uint32>(row[0], atoul(row[1])));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -3113,6 +3113,30 @@ bool BotDatabase::SaveBotArcherSetting(const uint32 bot_id, const bool bot_arche
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string BotDatabase::GetBotNameByID(const uint32 bot_id)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (!bot_id) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
query = fmt::format(
|
||||||
|
"SELECT `name` FROM `bot_data` WHERE `bot_id` = {}",
|
||||||
|
bot_id
|
||||||
|
);
|
||||||
|
auto results = database.QueryDatabase(query);
|
||||||
|
|
||||||
|
if (!results.Success()) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (results.RowCount() == 1) {
|
||||||
|
auto row = results.begin();
|
||||||
|
return row[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
/* fail::Bot functions */
|
/* fail::Bot functions */
|
||||||
const char* BotDatabase::fail::LoadBotsList() { return "Failed to bots list"; }
|
const char* BotDatabase::fail::LoadBotsList() { return "Failed to bots list"; }
|
||||||
const char* BotDatabase::fail::LoadOwnerID() { return "Failed to load owner ID"; }
|
const char* BotDatabase::fail::LoadOwnerID() { return "Failed to load owner ID"; }
|
||||||
@ -3178,3 +3202,4 @@ const char* BotDatabase::fail::DeleteHealRotation() { return "Failed to delete h
|
|||||||
const char* BotDatabase::fail::DeleteAllHealRotations() { return "Failed to delete all heal rotations"; }
|
const char* BotDatabase::fail::DeleteAllHealRotations() { return "Failed to delete all heal rotations"; }
|
||||||
|
|
||||||
/* fail::Bot miscellaneous functions */
|
/* fail::Bot miscellaneous functions */
|
||||||
|
const char* BotDatabase::fail::GetBotNameByID() { return "Failed to get bot name by bot ID"; }
|
||||||
|
|||||||
@ -164,10 +164,10 @@ public:
|
|||||||
bool AddMemberToBotGroup(const uint32 leader_id, const uint32 member_id);
|
bool AddMemberToBotGroup(const uint32 leader_id, const uint32 member_id);
|
||||||
bool RemoveMemberFromBotGroup(const uint32 member_id);
|
bool RemoveMemberFromBotGroup(const uint32 member_id);
|
||||||
|
|
||||||
bool LoadBotGroupIDForLoadBotGroup(const uint32 owner_id, const std::string& botgroup_name, uint32& botgroup_id);
|
bool LoadBotGroupIDForLoadBotGroup(const uint32 owner_id, std::string_view botgroup_name, uint32& botgroup_id);
|
||||||
bool LoadBotGroup(const std::string& botgroup_name, std::map<uint32, std::list<uint32>>& member_list);
|
bool LoadBotGroup(const std::string& botgroup_name, std::map<uint32, std::list<uint32>>& member_list);
|
||||||
|
|
||||||
bool LoadBotGroupsListByOwnerID(const uint32 owner_id, std::list<std::pair<std::string, std::string>>& botgroups_list);
|
bool LoadBotGroupsListByOwnerID(const uint32 owner_id, std::list<std::pair<std::string, uint32>>& botgroups_list);
|
||||||
|
|
||||||
|
|
||||||
/* Bot group functions */
|
/* Bot group functions */
|
||||||
@ -190,6 +190,7 @@ public:
|
|||||||
|
|
||||||
/* Bot miscellaneous functions */
|
/* Bot miscellaneous functions */
|
||||||
uint8 GetSpellCastingChance(uint8 spell_type_index, uint8 class_index, uint8 stance_index, uint8 conditional_index);
|
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);
|
uint16 GetRaceClassBitmask(uint16 bot_race);
|
||||||
|
|
||||||
@ -280,6 +281,7 @@ public:
|
|||||||
static const char* DeleteAllHealRotations();
|
static const char* DeleteAllHealRotations();
|
||||||
|
|
||||||
/* fail::Bot miscellaneous functions */
|
/* fail::Bot miscellaneous functions */
|
||||||
|
static const char* GetBotNameByID();
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user