[Crash] Fix crash with uninitialized item instance, and Bot timeout (#3296)

This commit is contained in:
Aeadoin
2023-04-15 13:12:48 -04:00
committed by GitHub
parent 4320c1429e
commit 7523c972fa
3 changed files with 29 additions and 83 deletions
+4 -5
View File
@@ -3002,24 +3002,23 @@ void Mob::AddToHateList(Mob* other, int64 hate /*= 0*/, int64 damage /*= 0*/, bo
// if other is a bot, add the bots client to the hate list
if (RuleB(Bots, Enabled)) {
while (other->IsBot()) {
if (other->IsBot()) {
auto other_ = other->CastToBot();
if (!other_ || !other_->GetBotOwner()) {
break;
return;
}
auto owner_ = other_->GetBotOwner()->CastToClient();
if (!owner_ || owner_->IsDead() ||
!owner_->InZone()) { // added isdead and inzone checks to avoid issues in AddAutoXTarget(...) below
break;
return;
}
if (owner_->GetFeigned()) {
AddFeignMemory(owner_);
}
else if (!hate_list.IsEntOnHateList(owner_)) {
hate_list.AddEntToHateList(owner_, 0, 0, false, true);
owner_->AddAutoXTarget(this); // this was being called on dead/out-of-zone clients
}