[Bug Fix] HasPet() Zone Crashes (#2744)

* [Bug Fixes] Fix for HasPet() Zone Crashes

* HasPets const

* Remove checking This

* formatting
This commit is contained in:
Aeadoin 2023-01-15 17:16:17 -05:00 committed by GitHub
parent 00658632de
commit 7fa421d848
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 1 deletions

View File

@ -1052,7 +1052,7 @@ public:
inline uint16 GetOwnerID() const { return ownerid; }
inline virtual bool HasOwner() { if(GetOwnerID()==0){return false;} return( entity_list.GetMob(GetOwnerID()) != 0); }
inline virtual bool IsPet() { return(HasOwner() && !IsMerc()); }
inline bool HasPet() const { if(GetPetID()==0){return false;} return (entity_list.GetMob(GetPetID()) != 0);}
bool HasPet() const;
inline bool HasTempPetsActive() const { return(hasTempPet); }
inline void SetTempPetsActive(bool i) { hasTempPet = i; }
inline int16 GetTempPetCount() const { return count_TempPet; }

View File

@ -529,6 +529,23 @@ Mob* Mob::GetPet() {
return(tmp);
}
bool Mob::HasPet() const {
if (GetPetID() == 0) {
return false;
}
const auto m = entity_list.GetMob(GetPetID());
if (!m) {
return false;
}
if (m->GetOwnerID() != GetID()) {
return false;
}
return true;
}
void Mob::SetPet(Mob* newpet) {
Mob* oldpet = GetPet();
if (oldpet) {