feat(Core): Added ABORT() macro to prevent the usage of ASSERT(false) as a quick hack to crash the core misusing assert (#2273)

This commit is contained in:
Viste
2019-09-26 10:51:34 +03:00
committed by Stoabrogga
parent 58f3cfe387
commit 854b426978
28 changed files with 127 additions and 74 deletions
@@ -389,7 +389,7 @@ void Puppet::InitSummon()
else
{
sLog->outMisc("Puppet::InitSummon (B1)");
//ASSERT(false); // ZOMG!
//ABORT(); // ZOMG!
}
}
}
@@ -700,7 +700,7 @@ class GameObject : public WorldObject, public GridObject<GameObject>, public Mov
// Owner already found and different than expected owner - remove object from old owner
if (owner && GetOwnerGUID() && GetOwnerGUID() != owner)
{
ASSERT(false);
ABORT();
}
m_spawnedByDefault = false; // all object with owner is despawned after delay
SetUInt64Value(OBJECT_FIELD_CREATED_BY, owner);
+1 -1
View File
@@ -1036,7 +1036,7 @@ Item* Item::CreateItem(uint32 item, uint32 count, Player const* player)
delete pItem;
}
else
ASSERT(false);
ABORT();
return NULL;
}
+4 -4
View File
@@ -92,7 +92,7 @@ WorldObject::~WorldObject()
if (GetTypeId() == TYPEID_CORPSE)
{
sLog->outCrash("Object::~Object Corpse guid=" UI64FMTD ", type=%d, entry=%u deleted but still in map!!", GetGUID(), ((Corpse*)this)->GetType(), GetEntry());
ASSERT(false);
ABORT();
}
ResetMap();
}
@@ -105,14 +105,14 @@ Object::~Object()
sLog->outCrash("Object::~Object - guid=" UI64FMTD ", typeid=%d, entry=%u deleted but still in world!!", GetGUID(), GetTypeId(), GetEntry());
if (isType(TYPEMASK_ITEM))
sLog->outCrash("Item slot %u", ((Item*)this)->GetSlot());
ASSERT(false);
ABORT();
RemoveFromWorld();
}
if (m_objectUpdated)
{
sLog->outCrash("Object::~Object - guid=" UI64FMTD ", typeid=%d, entry=%u deleted but still in update list!!", GetGUID(), GetTypeId(), GetEntry());
ASSERT(false);
ABORT();
sObjectAccessor->RemoveUpdateObject(this);
}
@@ -2059,7 +2059,7 @@ void WorldObject::SetMap(Map* map)
if (m_currMap)
{
sLog->outCrash("WorldObject::SetMap: obj %u new map %u %u, old map %u %u", (uint32)GetTypeId(), map->GetId(), map->GetInstanceId(), m_currMap->GetId(), m_currMap->GetInstanceId());
ASSERT(false);
ABORT();
}
m_currMap = map;
m_mapId = map->GetId();
+2 -2
View File
@@ -180,11 +180,11 @@ class Pet : public Guardian
private:
void SaveToDB(uint32, uint8, uint32) // override of Creature::SaveToDB - must not be called
{
ASSERT(false);
ABORT();
}
void DeleteFromDB() // override of Creature::DeleteFromDB - must not be called
{
ASSERT(false);
ABORT();
}
};
#endif
+4 -4
View File
@@ -3890,7 +3890,7 @@ bool Player::_addSpell(uint32 spellId, uint8 addSpecMask, bool temporary)
{
sLog->outString("TRYING TO LEARN SPELL WITH EFFECT LEARN: %u, PLAYER: %u", spellId, GetGUIDLow());
return false;
//ASSERT(false);
//ABORT();
}
else if (const SpellInfo* learnSpell = sSpellMgr->GetSpellInfo(spellInfo->Effects[i].TriggerSpell))
_addSpell(learnSpell->Id, SPEC_MASK_ALL, true);
@@ -3943,7 +3943,7 @@ bool Player::_addSpell(uint32 spellId, uint8 addSpecMask, bool temporary)
sLog->outString("TRYING TO LEARN SPELL WITH EFFECT LEARN 2: %u, PLAYER: %u", spellId, GetGUIDLow());
m_spells.erase(spellInfo->Id); // mem leak, but should never happen
return false;
//ASSERT(false);
//ABORT();
}
// pussywizard: cast passive spells (including all talents without SPELL_EFFECT_LEARN_SPELL) with additional checks
else if (spellInfo->IsPassive() || (spellInfo->HasAttribute(SPELL_ATTR0_HIDDEN_CLIENTSIDE) && spellInfo->Stances))
@@ -20905,7 +20905,7 @@ void Player::StopCastingCharm()
if (charm->GetCharmerGUID())
{
sLog->outCrash("Charmed unit has charmer guid " UI64FMTD, charm->GetCharmerGUID());
ASSERT(false);
ABORT();
}
else
SetCharm(charm, false);
@@ -24521,7 +24521,7 @@ void Player::SetBattlegroundOrBattlefieldRaid(Group *group, int8 subgroup)
if (GetGroup() && (GetGroup()->isBGGroup() || GetGroup()->isBFGroup()))
{
sLog->outMisc("Player::SetBattlegroundOrBattlefieldRaid - current group is %s group!", (GetGroup()->isBGGroup() ? "BG" : "BF"));
//ASSERT(false); // pussywizard: origanal group can never be bf/bg group
//ABORT(); // pussywizard: origanal group can never be bf/bg group
}
SetOriginalGroup(GetGroup(), GetSubGroup());
+7 -7
View File
@@ -4052,7 +4052,7 @@ void Unit::_UnapplyAura(AuraApplication * aurApp, AuraRemoveMode removeMode)
else
++iter;
}
ASSERT(false);
ABORT();
}
void Unit::_RemoveNoStackAurasDueToAura(Aura* aura)
@@ -4145,7 +4145,7 @@ void Unit::RemoveOwnedAura(Aura* aura, AuraRemoveMode removeMode)
}
}
ASSERT(false);
ABORT();
}
Aura* Unit::GetOwnedAura(uint32 spellId, uint64 casterGUID, uint64 itemCasterGUID, uint8 reqEffMask, Aura* except) const
@@ -9895,7 +9895,7 @@ void Unit::SetMinion(Minion *minion, bool apply)
{
OutDebugInfo();
(*itr)->OutDebugInfo();
ASSERT(false);
ABORT();
}
ASSERT((*itr)->GetTypeId() == TYPEID_UNIT);
@@ -14377,7 +14377,7 @@ void Unit::RemoveFromWorld()
if (GetCharmerGUID())
{
sLog->outCrash("Unit %u has charmer guid when removed from world", GetEntry());
ASSERT(false);
ABORT();
}
if (Unit* owner = GetOwner())
@@ -14387,7 +14387,7 @@ void Unit::RemoveFromWorld()
if (HasUnitTypeMask(UNIT_MASK_MINION|UNIT_MASK_GUARDIAN))
owner->SetMinion((Minion*)this, false);
sLog->outString("Unit %u is in controlled list of %u when removed from world", GetEntry(), owner->GetEntry());
//ASSERT(false);
//ABORT();
}
}
@@ -17151,7 +17151,7 @@ void Unit::RemoveCharmedBy(Unit* charmer)
{
// sLog->outCrash("Unit::RemoveCharmedBy: this: " UI64FMTD " true charmer: " UI64FMTD " false charmer: " UI64FMTD,
// GetGUID(), GetCharmerGUID(), charmer->GetGUID());
// ASSERT(false);
// ABORT();
return;
}
@@ -18260,7 +18260,7 @@ void Unit::ChangeSeat(int8 seatId, bool next)
m_vehicle->RemovePassenger(this);
if (!m_vehicle->AddPassenger(this, seatId))
ASSERT(false);
ABORT();
}
void Unit::ExitVehicle(Position const* /*exitPosition*/)
+1 -1
View File
@@ -1327,7 +1327,7 @@ class SafeUnitPointer
{
public:
explicit SafeUnitPointer(Unit* defVal) : ptr(defVal), defaultValue(defVal) {}
SafeUnitPointer(const SafeUnitPointer& /*p*/) { ASSERT(false); }
SafeUnitPointer(const SafeUnitPointer& /*p*/) { ABORT(); }
void Initialize(Unit* defVal) { defaultValue = defVal; ptr = defVal; }
~SafeUnitPointer();
void SetPointedTo(Unit* u);
+1 -1
View File
@@ -390,7 +390,7 @@ bool Vehicle::AddPassenger(Unit* unit, int8 seatId)
try
{
if (!_me->SetCharmedBy(unit, CHARM_TYPE_VEHICLE))
ASSERT(false);
ABORT();
}
catch (...)
{