Fixed IsRaidMemberBot to remove memory leak

Fixed altcombat crash though RaidMainAssist (428) needs fixing
This commit is contained in:
neckkola
2022-02-07 21:35:53 -04:00
parent 2b625bb347
commit deb4f10ea8
2 changed files with 29 additions and 6 deletions
+4
View File
@@ -428,6 +428,10 @@ void Bot::AI_Process_Raid()
auto assist_mob = raid->GetRaidMainAssistOneByName(this->GetName());
bool find_target = true;
if (!assist_mob) {
bot_owner->Message(Chat::Yellow, "Assist Mob is nullptr");
}
if (assist_mob) {
if (assist_mob->GetTarget()) {
+25 -6
View File
@@ -1546,12 +1546,30 @@ void Raid::SendAllRaidLeadershipAA()
bool Raid::IsRaidMemberBot(Client* client)
{
if (client->CastToBot()->GetBotID() == 0) {
return false;
std::string query = StringFormat("SELECT mob_type FROM vw_bot_character_mobs WHERE name = '%s' LIMIT 1",
client->GetCleanName());
auto results = database.QueryDatabase(query);
if (!results.Success())
return true; //return true to avoid sending a packet to a non-existant client as a failsafe
if (results.RowCount() == 0) {
LogError(
"Error getting B/C info for character name [{}] for IsRaidMemberBot. Error [{}]",
client->GetCleanName(),
results.ErrorMessage().c_str()
);
return true;//return true to avoid sending a packet to a non-existant client as a failsafe
}
else
{
return true;
auto row = results.begin();
const char* c = "C";
const char* b = "B";
if (strcmp(row[0], c) == 0) {
return false; // client is a client
}
else if (strcmp(row[0], b) == 0) {
return true; // client is actually a bot
}
}
void Raid::LockRaid(bool lockFlag)
@@ -2036,9 +2054,10 @@ Mob* Raid::GetRaidMainAssistOneByName(const char* name)
Raid* raid = entity_list.GetRaidByBotName(name);
std::vector<RaidMember> raid_members = raid->GetMembers();
for (RaidMember& iter : raid_members)
for (RaidMember iter : raid_members)
{
if (iter.IsRaidMainAssistOne)
return iter.member->CastToMob();
}
return nullptr;
}