Core/Units: fixed a crash that happened when despawning a pet while having units with no ownerguid stored in m_controlled

* minor fixups for vehicle energy power regeneration
* do not set ownerguids for summon vehicles
This commit is contained in:
Ovahlord committed 2020-04-29 14:27:27 +02:00
1 parent bedd554c79
commit 298c2593df
6 files changed
+10 -11

No files matched your search

@@ -239,6 +239,8 @@ void Creature::AddToWorld()
TC_LOG_DEBUG("entities.unit", "Adding creature %u with entry %u and DBGUID %u to world in map %u", GetGUID().GetCounter(), GetEntry(), m_spawnId, GetMap()->GetId());
UpdatePowerRegeneration(GetPowerType());
Unit::AddToWorld();
SearchFormation();
AIM_Initialize();
@@ -247,8 +249,6 @@ void Creature::AddToWorld()
if (GetZoneScript())
GetZoneScript()->OnCreatureCreate(this);
UpdatePowerRegeneration(GetPowerType());
}
}
@@ -194,7 +194,7 @@ void TempSummon::InitStats(uint32 duration)
owner->m_SummonSlot[slot] = GetGUID();
}
if (m_Properties->Control == SUMMON_CATEGORY_ALLY || m_Properties->Control == SUMMON_CATEGORY_PET || m_Properties->Control == SUMMON_CATEGORY_VEHICLE)
if (m_Properties->Control != SUMMON_CATEGORY_WILD)
{
if (!m_Properties->Faction)
SetFaction(owner->GetFaction());
@@ -317,10 +317,10 @@ void Minion::InitStats(uint32 duration)
TempSummon::InitStats(duration);
SetReactState(REACT_PASSIVE);
// Only controlable guardians and companions get a owner guid
if (HasUnitTypeMask(UNIT_MASK_CONTROLABLE_GUARDIAN) || (m_Properties && m_Properties->Title == AsUnderlyingType(SummonTitle::Companion)))
// Controlable guardians and minions shall receive a summoner guid
if ((IsMinion() || IsControlableGuardian()) && !IsTotem() && !IsVehicle())
GetOwner()->SetMinion(this, true);
else if (!HasUnitTypeMask(UNIT_MASK_PET | UNIT_MASK_HUNTER_PET))
else if (!IsPet() && !IsHunterPet())
{
GetOwner()->m_Controlled.insert(this);
@@ -345,9 +345,9 @@ void Minion::RemoveFromWorld()
Unit* owner = GetOwner();
if (HasUnitTypeMask(UNIT_MASK_CONTROLABLE_GUARDIAN) || (m_Properties && m_Properties->Title == AsUnderlyingType(SummonTitle::Companion)))
if ((IsMinion() || IsControlableGuardian()) && !IsTotem() && !IsVehicle())
owner->SetMinion(this, false);
else if (!HasUnitTypeMask(UNIT_MASK_PET | UNIT_MASK_HUNTER_PET))
else if (!IsPet() && !IsHunterPet())
{
if (owner->m_Controlled.find(this) != owner->m_Controlled.end())
owner->m_Controlled.erase(this);
+1 -1
View File
@@ -6226,7 +6226,7 @@ void Unit::SetMinion(Minion* minion, bool apply)
continue;
//ASSERT((*itr)->GetOwnerGUID() == GetGUID());
if (controlled->GetOwnerGUID() != GetGUID())
if (controlled->GetOwnerOrCreatorGUID() != GetGUID())
{
OutDebugInfo();
controlled->OutDebugInfo();
+1
View File
@@ -1068,6 +1068,7 @@ class TC_GAME_API Unit : public WorldObject
bool IsHunterPet() const{ return (m_unitTypeMask & UNIT_MASK_HUNTER_PET) != 0; }
bool IsTotem() const { return (m_unitTypeMask & UNIT_MASK_TOTEM) != 0; }
bool IsVehicle() const { return (m_unitTypeMask & UNIT_MASK_VEHICLE) != 0; }
bool IsControlableGuardian() const { return (m_unitTypeMask & UNIT_MASK_CONTROLABLE_GUARDIAN) != 0; }
uint8 getLevel() const { return uint8(GetUInt32Value(UNIT_FIELD_LEVEL)); }
uint8 getLevelForTarget(WorldObject const* /*target*/) const override { return getLevel(); }
@@ -93,7 +93,6 @@ void Vehicle::Install()
case POWER_ELECTRICAL_ENERGY:
case POWER_ARCANE_ENERGY_2:
case POWER_FUEL:
case POWER_SUN_POWER:
case POWER_TWILIGHT_ENERGY:
case POWER_PYRITE:
_me->SetFullPower(POWER_ENERGY);
@@ -293,7 +293,6 @@ struct npc_brazie_the_bonatist_vehicle : public VehicleAI
{
PhasingHandler::AddPhase(passenger, PHASE_ID_QUEST, true);
passenger->CastSpell(passenger, SPELL_PROGRESS_BAR, true);
me->SetPower(POWER_ENERGY, 0);
SetupSpawns();
}
else