[Cleanup] Remove possible dereferenced nullptrs in bot.cpp (#3241)

# Notes
- Possible dereferenced nullptrs based on logic.
This commit is contained in:
Alex King 2023-04-03 16:30:46 -04:00 committed by GitHub
parent cb129efcad
commit c9f27d6f90
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4533,8 +4533,10 @@ bool Bot::Death(Mob *killerMob, int64 damage, uint16 spell_id, EQ::skills::Skill
give_exp_client = give_exp->CastToClient();
bool IsLdonTreasure = (GetClass() == LDON_TREASURE);
if (entity_list.GetCorpseByID(GetID()))
entity_list.GetCorpseByID(GetID())->Depop();
const auto c = entity_list.GetCorpseByID(GetID());
if (c) {
c->Depop();
}
if (HasRaid()) {
if (auto raid = entity_list.GetRaidByBotName(GetName()); raid) {
@ -6831,8 +6833,11 @@ Bot* Bot::GetBotByBotClientOwnerAndBotName(Client* c, const std::string& botName
void Bot::ProcessBotGroupInvite(Client* c, std::string const& botName) {
if (c && !c->HasRaid()) {
Bot* invitedBot = GetBotByBotClientOwnerAndBotName(c, botName);
if (!invitedBot) {
return;
}
if (invitedBot && !invitedBot->HasGroup() && !invitedBot->HasRaid()) {
if (!invitedBot->HasGroup() && !invitedBot->HasRaid()) {
if (!c->IsGrouped()) {
auto g = new Group(c);
if (AddBotToGroup(invitedBot, g)) {