Core/Common: Add macro ASSERT_WITH_SIDE_EFFECTS to be used when asserting conditions that have side effects

This commit is contained in:
jackpoz
2020-06-26 23:21:49 +02:00
parent 0a08027bd9
commit 49da3533cd
2 changed files with 6 additions and 4 deletions

View File

@@ -69,6 +69,8 @@ TC_COMMON_API std::string GetDebugInfo();
#define ASSERT_NODEBUGINFO WPAssert_NODEBUGINFO
#endif
#define ASSERT_WITH_SIDE_EFFECTS WPAssert
#define ABORT WPAbort
#define ABORT_MSG WPAbort_MSG

View File

@@ -6043,7 +6043,7 @@ void Unit::SetCharm(Unit* charm, bool apply)
{
if (GetTypeId() == TYPEID_PLAYER)
{
ASSERT(AddGuidValue(UNIT_FIELD_CHARM, charm->GetGUID()),
ASSERT_WITH_SIDE_EFFECTS(AddGuidValue(UNIT_FIELD_CHARM, charm->GetGUID()),
"Player %s is trying to charm unit %u, but it already has a charmed unit %s", GetName().c_str(), charm->GetEntry(), GetCharmedGUID().ToString().c_str());
m_charmed = charm;
@@ -6057,7 +6057,7 @@ void Unit::SetCharm(Unit* charm, bool apply)
// PvP, FFAPvP
charm->SetByteValue(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PVP_FLAG, GetByteValue(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PVP_FLAG));
ASSERT(charm->AddGuidValue(UNIT_FIELD_CHARMEDBY, GetGUID()),
ASSERT_WITH_SIDE_EFFECTS(charm->AddGuidValue(UNIT_FIELD_CHARMEDBY, GetGUID()),
"Unit %u is being charmed, but it already has a charmer %s", charm->GetEntry(), charm->GetCharmerGUID().ToString().c_str());
charm->m_charmer = this;
@@ -6076,12 +6076,12 @@ void Unit::SetCharm(Unit* charm, bool apply)
if (GetTypeId() == TYPEID_PLAYER)
{
ASSERT(RemoveGuidValue(UNIT_FIELD_CHARM, charm->GetGUID()),
ASSERT_WITH_SIDE_EFFECTS(RemoveGuidValue(UNIT_FIELD_CHARM, charm->GetGUID()),
"Player %s is trying to uncharm unit %u, but it has another charmed unit %s", GetName().c_str(), charm->GetEntry(), GetCharmedGUID().ToString().c_str());
m_charmed = nullptr;
}
ASSERT(charm->RemoveGuidValue(UNIT_FIELD_CHARMEDBY, GetGUID()),
ASSERT_WITH_SIDE_EFFECTS(charm->RemoveGuidValue(UNIT_FIELD_CHARMEDBY, GetGUID()),
"Unit %u is being uncharmed, but it has another charmer %s", charm->GetEntry(), charm->GetCharmerGUID().ToString().c_str());
charm->m_charmer = nullptr;