Merge branch 'master' into Playerbot

This commit is contained in:
Yunfan Li
2023-08-24 22:07:53 +08:00
96 changed files with 3271 additions and 2541 deletions

View File

@@ -48,7 +48,7 @@ Pet::Pet(Player* owner, PetType type) : Guardian(nullptr, owner ? owner->GetGUID
m_loading(false),
m_petRegenTimer(PET_FOCUS_REGEN_INTERVAL),
m_tempspellTarget(nullptr),
m_tempoldTarget(nullptr),
m_tempoldTarget(),
m_tempspellIsPositive(false),
m_tempspell(0)
{
@@ -710,7 +710,11 @@ void Pet::Update(uint32 diff)
if (m_tempspell)
{
Unit* tempspellTarget = m_tempspellTarget;
Unit* tempoldTarget = m_tempoldTarget;
Unit* tempoldTarget = nullptr;
if (!m_tempoldTarget.IsEmpty())
tempoldTarget = ObjectAccessor::GetUnit(*this, m_tempoldTarget);
bool tempspellIsPositive = m_tempspellIsPositive;
uint32 tempspell = m_tempspell;
Unit* charmer = GetCharmerOrOwner();
@@ -783,7 +787,7 @@ void Pet::Update(uint32 diff)
}
}
m_tempoldTarget = nullptr;
m_tempoldTarget = ObjectGuid::Empty;
m_tempspellIsPositive = false;
}
}
@@ -793,7 +797,7 @@ void Pet::Update(uint32 diff)
{
m_tempspell = 0;
m_tempspellTarget = nullptr;
m_tempoldTarget = nullptr;
m_tempoldTarget = ObjectGuid::Empty;
m_tempspellIsPositive = false;
Unit* victim = charmer->GetVictim();
@@ -1218,11 +1222,11 @@ bool Guardian::InitStatsForLevel(uint8 petlevel)
}
case NPC_INFERNAL:
{
float highAmt = petlevel / 11.0f;
float lowAmt = petlevel / 12.0f;
SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, lowAmt * lowAmt * lowAmt);
SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, highAmt * highAmt * highAmt);
if (pInfo)
{
SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, float(pInfo->min_dmg));
SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, float(pInfo->max_dmg));
}
AddAura(SPELL_PET_AVOIDANCE, this);
AddAura(SPELL_WARLOCK_PET_SCALING_05, this);
AddAura(SPELL_INFERNAL_SCALING_01, this);
@@ -2414,7 +2418,7 @@ void Pet::SetDisplayId(uint32 modelId)
player->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_MODEL_ID);
}
void Pet::CastWhenWillAvailable(uint32 spellid, Unit* spellTarget, Unit* oldTarget, bool spellIsPositive)
void Pet::CastWhenWillAvailable(uint32 spellid, Unit* spellTarget, ObjectGuid oldTarget, bool spellIsPositive)
{
if (!spellid)
return;
@@ -2426,7 +2430,7 @@ void Pet::CastWhenWillAvailable(uint32 spellid, Unit* spellTarget, Unit* oldTarg
m_tempspell = spellid;
m_tempspellIsPositive = spellIsPositive;
if (oldTarget)
if (!oldTarget.IsEmpty())
m_tempoldTarget = oldTarget;
}
@@ -2435,7 +2439,7 @@ void Pet::ClearCastWhenWillAvailable()
m_tempspellIsPositive = false;
m_tempspell = 0;
m_tempspellTarget = nullptr;
m_tempoldTarget = nullptr;
m_tempoldTarget = ObjectGuid::Empty;
}
void Pet::RemoveSpellCooldown(uint32 spell_id, bool update /* = false */)

View File

@@ -96,7 +96,7 @@ public:
void LearnPetPassives();
void CastPetAuras(bool current);
void CastWhenWillAvailable(uint32 spellid, Unit* spellTarget, Unit* oldTarget, bool spellIsPositive = false);
void CastWhenWillAvailable(uint32 spellid, Unit* spellTarget, ObjectGuid oldTarget, bool spellIsPositive = false);
void ClearCastWhenWillAvailable();
void RemoveSpellCooldown(uint32 spell_id, bool update /* = false */);
@@ -157,10 +157,10 @@ protected:
std::unique_ptr<DeclinedName> m_declinedname;
Unit* m_tempspellTarget;
Unit* m_tempoldTarget;
bool m_tempspellIsPositive;
uint32 m_tempspell;
Unit* m_tempspellTarget;
ObjectGuid m_tempoldTarget;
bool m_tempspellIsPositive;
uint32 m_tempspell;
private:
void SaveToDB(uint32, uint8, uint32) override // override of Creature::SaveToDB - must not be called

View File

@@ -39,6 +39,8 @@ MotionTransport::MotionTransport() : Transport(), _transportInfo(nullptr), _isMo
MotionTransport::~MotionTransport()
{
HashMapHolder<MotionTransport>::Remove(this);
ASSERT(_passengers.empty());
UnloadStaticPassengers();
}

View File

@@ -388,22 +388,19 @@ bool Vehicle::AddPassenger(Unit* unit, int8 seatId)
&& unit->GetTypeId() == TYPEID_PLAYER
&& seat->second.SeatInfo->m_flags & VEHICLE_SEAT_FLAG_CAN_CONTROL)
{
try
// Removed try catch + ABORT() here, and make it as simple condition check.
if (!_me->SetCharmedBy(unit, CHARM_TYPE_VEHICLE))
{
if (!_me->SetCharmedBy(unit, CHARM_TYPE_VEHICLE))
ABORT();
}
catch (...)
{
LOG_INFO("vehicles", "CRASH! Try-catch in Unit::SetCharmedBy()!");
LOG_INFO("vehicles", "CRASH! Try-catch in Unit::SetCharmedBy(). not null: {}", _me ? 1 : 0);
// I assume SetCharmedBy should always be true.
// If not, let's log some debug info.
LOG_INFO("vehicles", "Crash recovered in Unit::SetCharmedBy(). not null: {}", _me ? 1 : 0);
if (!_me)
return false;
LOG_INFO("vehicles", "CRASH! Try-catch in Unit::SetCharmedBy(). Is: {}!", _me->IsInWorld());
LOG_INFO("vehicles", "CRASH! Try-catch in Unit::SetCharmedBy(). Is2: {}!", _me->IsDuringRemoveFromWorld());
LOG_INFO("vehicles", "CRASH! Try-catch in Unit::SetCharmedBy(). Unit {}!", _me->GetName());
LOG_INFO("vehicles", "CRASH! Try-catch in Unit::SetCharmedBy(). typeid: {}!", _me->GetTypeId());
LOG_INFO("vehicles", "CRASH! Try-catch in Unit::SetCharmedBy(). Unit {}, typeid: {}, in world: {}, duringremove: {} has wrong CharmType! Charmer {}, typeid: {}, in world: {}, duringremove: {}.", _me->GetName(), _me->GetTypeId(), _me->IsInWorld(), _me->IsDuringRemoveFromWorld(), unit->GetName(), unit->GetTypeId(), unit->IsInWorld(), unit->IsDuringRemoveFromWorld());
LOG_INFO("vehicles", "Crash recovered in Unit::SetCharmedBy(). Is: {}!", _me->IsInWorld());
LOG_INFO("vehicles", "Crash recovered in Unit::SetCharmedBy(). Is2: {}!", _me->IsDuringRemoveFromWorld());
LOG_INFO("vehicles", "Crash recovered in Unit::SetCharmedBy(). Unit {}!", _me->GetName());
LOG_INFO("vehicles", "Crash recovered in Unit::SetCharmedBy(). typeid: {}!", _me->GetTypeId());
LOG_INFO("vehicles", "Crash recovered in Unit::SetCharmedBy(). Unit {}, typeid: {}, in world: {}, duringremove: {} has wrong CharmType! Charmer {}, typeid: {}, in world: {}, duringremove: {}.", _me->GetName(), _me->GetTypeId(), _me->IsInWorld(), _me->IsDuringRemoveFromWorld(), unit->GetName(), unit->GetTypeId(), unit->IsInWorld(), unit->IsDuringRemoveFromWorld());
return false;
}
}