mirror of
https://github.com/EQEmu/Server.git
synced 2026-03-24 07:32:40 +00:00
[Bug Fix] Fix Bot Group Loading (#2366)
* [Bug Fix] Fix Bot Group Loading There were some weird cases where this code would falsely say a bot group did not exist and this would disallow summoning this botgroup as well as deleting it. * Typo.
This commit is contained in:
parent
25c6b055a4
commit
6232a64cdb
@ -7020,19 +7020,7 @@ void bot_subcommand_botgroup_create(Client *c, const Seperator *sep)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool extant_flag = false;
|
if (database.botdb.QueryBotGroupExistence(botgroup_name)) {
|
||||||
if (!database.botdb.QueryBotGroupExistence(botgroup_name, extant_flag)) {
|
|
||||||
c->Message(
|
|
||||||
Chat::White,
|
|
||||||
fmt::format(
|
|
||||||
"Failed to query bot-group existence for '{}'.",
|
|
||||||
botgroup_name
|
|
||||||
).c_str()
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (extant_flag) {
|
|
||||||
c->Message(
|
c->Message(
|
||||||
Chat::White,
|
Chat::White,
|
||||||
fmt::format(
|
fmt::format(
|
||||||
@ -7360,8 +7348,7 @@ void bot_subcommand_botgroup_load(Client *c, const Seperator *sep)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool extant_flag = false;
|
if (!database.botdb.QueryBotGroupExistence(botgroup_name)) {
|
||||||
if (!database.botdb.QueryBotGroupExistence(botgroup_name, extant_flag)) {
|
|
||||||
c->Message(
|
c->Message(
|
||||||
Chat::White,
|
Chat::White,
|
||||||
fmt::format(
|
fmt::format(
|
||||||
@ -7372,17 +7359,6 @@ void bot_subcommand_botgroup_load(Client *c, const Seperator *sep)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!extant_flag) {
|
|
||||||
c->Message(
|
|
||||||
Chat::White,
|
|
||||||
fmt::format(
|
|
||||||
"Bot-group {} does not exist.",
|
|
||||||
botgroup_name
|
|
||||||
).c_str()
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto* owner_group = c->GetGroup();
|
auto* owner_group = c->GetGroup();
|
||||||
if (owner_group) {
|
if (owner_group) {
|
||||||
std::list<Client*> member_list;
|
std::list<Client*> member_list;
|
||||||
|
|||||||
@ -2328,7 +2328,7 @@ bool BotDatabase::SaveOwnerOption(const uint32 owner_id, const std::pair<size_t,
|
|||||||
|
|
||||||
|
|
||||||
/* Bot bot-group functions */
|
/* Bot bot-group functions */
|
||||||
bool BotDatabase::QueryBotGroupExistence(const std::string& group_name, bool& extant_flag)
|
bool BotDatabase::QueryBotGroupExistence(const std::string& group_name)
|
||||||
{
|
{
|
||||||
if (group_name.empty()) {
|
if (group_name.empty()) {
|
||||||
return false;
|
return false;
|
||||||
@ -2340,16 +2340,10 @@ bool BotDatabase::QueryBotGroupExistence(const std::string& group_name, bool& ex
|
|||||||
);
|
);
|
||||||
|
|
||||||
auto results = database.QueryDatabase(query);
|
auto results = database.QueryDatabase(query);
|
||||||
if (!results.Success()) {
|
if (!results.Success() || !results.RowCount()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!results.RowCount()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
extant_flag = true;
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2541,15 +2535,10 @@ bool BotDatabase::CreateBotGroup(const std::string& group_name, const uint32 lea
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool extant_flag = false;
|
if (QueryBotGroupExistence(group_name)) {
|
||||||
if (!QueryBotGroupExistence(group_name, extant_flag)) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (extant_flag) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
query = fmt::format(
|
query = fmt::format(
|
||||||
"INSERT INTO `bot_groups` (`group_leader_id`, `group_name`) VALUES ({}, '{}')",
|
"INSERT INTO `bot_groups` (`group_leader_id`, `group_name`) VALUES ({}, '{}')",
|
||||||
leader_id,
|
leader_id,
|
||||||
|
|||||||
@ -145,7 +145,7 @@ public:
|
|||||||
bool SaveOwnerOption(const uint32 owner_id, const std::pair<size_t, size_t> type, const std::pair<bool, bool> flag);
|
bool SaveOwnerOption(const uint32 owner_id, const std::pair<size_t, size_t> type, const std::pair<bool, bool> flag);
|
||||||
|
|
||||||
/* Bot bot-group functions */
|
/* Bot bot-group functions */
|
||||||
bool QueryBotGroupExistence(const std::string& botgroup_name, bool& extant_flag);
|
bool QueryBotGroupExistence(const std::string& botgroup_name);
|
||||||
|
|
||||||
bool LoadBotGroupIDByBotGroupName(const std::string& botgroup_name, uint32& botgroup_id);
|
bool LoadBotGroupIDByBotGroupName(const std::string& botgroup_name, uint32& botgroup_id);
|
||||||
bool LoadBotGroupIDByLeaderID(const uint32 leader_id, uint32& botgroup_id);
|
bool LoadBotGroupIDByLeaderID(const uint32 leader_id, uint32& botgroup_id);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user