mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-14 17:49:10 +00:00
refactor(Core): update getFaction to GetFaction and setFaction to SetFaction (#8708)
This commit is contained in:
@@ -9413,7 +9413,7 @@ void Unit::setPowerType(Powers new_powertype)
|
||||
|
||||
FactionTemplateEntry const* Unit::GetFactionTemplateEntry() const
|
||||
{
|
||||
FactionTemplateEntry const* entry = sFactionTemplateStore.LookupEntry(getFaction());
|
||||
FactionTemplateEntry const* entry = sFactionTemplateStore.LookupEntry(GetFaction());
|
||||
if (!entry)
|
||||
{
|
||||
static ObjectGuid guid; // prevent repeating spam same faction problem
|
||||
@@ -9421,11 +9421,11 @@ FactionTemplateEntry const* Unit::GetFactionTemplateEntry() const
|
||||
if (GetGUID() != guid)
|
||||
{
|
||||
if (Player const* player = ToPlayer())
|
||||
LOG_ERROR("entities.unit", "Player %s has invalid faction (faction template id) #%u", player->GetName().c_str(), getFaction());
|
||||
LOG_ERROR("entities.unit", "Player %s has invalid faction (faction template id) #%u", player->GetName().c_str(), GetFaction());
|
||||
else if (Creature const* creature = ToCreature())
|
||||
LOG_ERROR("entities.unit", "Creature (template id: %u) has invalid faction (faction template id) #%u", creature->GetCreatureTemplate()->Entry, getFaction());
|
||||
LOG_ERROR("entities.unit", "Creature (template id: %u) has invalid faction (faction template id) #%u", creature->GetCreatureTemplate()->Entry, GetFaction());
|
||||
else
|
||||
LOG_ERROR("entities.unit", "Unit (name=%s, type=%u) has invalid faction (faction template id) #%u", GetName().c_str(), uint32(GetTypeId()), getFaction());
|
||||
LOG_ERROR("entities.unit", "Unit (name=%s, type=%u) has invalid faction (faction template id) #%u", GetName().c_str(), uint32(GetTypeId()), GetFaction());
|
||||
|
||||
guid = GetGUID();
|
||||
}
|
||||
@@ -9433,7 +9433,7 @@ FactionTemplateEntry const* Unit::GetFactionTemplateEntry() const
|
||||
return entry;
|
||||
}
|
||||
|
||||
void Unit::setFaction(uint32 faction)
|
||||
void Unit::SetFaction(uint32 faction)
|
||||
{
|
||||
SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE, faction);
|
||||
if (GetTypeId() == TYPEID_UNIT)
|
||||
@@ -16519,7 +16519,7 @@ Pet* Unit::CreateTamedPetFrom(uint32 creatureEntry, uint32 spell_id)
|
||||
bool Unit::InitTamedPet(Pet* pet, uint8 level, uint32 spell_id)
|
||||
{
|
||||
pet->SetCreatorGUID(GetGUID());
|
||||
pet->setFaction(getFaction());
|
||||
pet->SetFaction(GetFaction());
|
||||
pet->SetUInt32Value(UNIT_CREATED_BY_SPELL, spell_id);
|
||||
|
||||
if (GetTypeId() == TYPEID_PLAYER)
|
||||
@@ -17497,8 +17497,8 @@ bool Unit::SetCharmedBy(Unit* charmer, CharmType type, AuraApplication const* au
|
||||
if (aurApp && aurApp->GetRemoveMode())
|
||||
return false;
|
||||
|
||||
_oldFactionId = getFaction();
|
||||
setFaction(charmer->getFaction());
|
||||
_oldFactionId = GetFaction();
|
||||
SetFaction(charmer->GetFaction());
|
||||
|
||||
// Set charmed
|
||||
charmer->SetCharm(this, true);
|
||||
@@ -17592,7 +17592,7 @@ bool Unit::SetCharmedBy(Unit* charmer, CharmType type, AuraApplication const* au
|
||||
creature->RefreshSwimmingFlag();
|
||||
|
||||
if (GetTypeId() == TYPEID_PLAYER)
|
||||
sScriptMgr->OnPlayerBeingCharmed(ToPlayer(), charmer, _oldFactionId, charmer->getFaction());
|
||||
sScriptMgr->OnPlayerBeingCharmed(ToPlayer(), charmer, _oldFactionId, charmer->GetFaction());
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -17622,7 +17622,7 @@ void Unit::RemoveCharmedBy(Unit* charmer)
|
||||
|
||||
if (_oldFactionId)
|
||||
{
|
||||
setFaction(_oldFactionId);
|
||||
SetFaction(_oldFactionId);
|
||||
_oldFactionId = 0;
|
||||
}
|
||||
else
|
||||
@@ -17741,20 +17741,20 @@ void Unit::RemoveCharmedBy(Unit* charmer)
|
||||
void Unit::RestoreFaction()
|
||||
{
|
||||
if (GetTypeId() == TYPEID_PLAYER)
|
||||
ToPlayer()->setFactionForRace(getRace());
|
||||
ToPlayer()->SetFactionForRace(getRace());
|
||||
else
|
||||
{
|
||||
if (HasUnitTypeMask(UNIT_MASK_MINION))
|
||||
{
|
||||
if (Unit* owner = GetOwner())
|
||||
{
|
||||
setFaction(owner->getFaction());
|
||||
SetFaction(owner->GetFaction());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (CreatureTemplate const* cinfo = ToCreature()->GetCreatureTemplate()) // normal creature
|
||||
setFaction(cinfo->faction);
|
||||
SetFaction(cinfo->faction);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17831,7 +17831,7 @@ bool Unit::IsInPartyWith(Unit const* unit) const
|
||||
return u1->ToPlayer()->IsInSameGroupWith(u2->ToPlayer());
|
||||
// Xinef: we assume that npcs with the same faction are in party
|
||||
else if (u1->GetTypeId() == TYPEID_UNIT && u2->GetTypeId() == TYPEID_UNIT && !u1->IsControlledByPlayer() && !u2->IsControlledByPlayer())
|
||||
return u1->getFaction() == u2->getFaction();
|
||||
return u1->GetFaction() == u2->GetFaction();
|
||||
// Xinef: creature type_flag should work for party check only if player group is not a raid
|
||||
else if ((u2->GetTypeId() == TYPEID_PLAYER && u1->GetTypeId() == TYPEID_UNIT && (u1->ToCreature()->GetCreatureTemplate()->type_flags & CREATURE_TYPE_FLAG_TREAT_AS_RAID_UNIT) && u2->ToPlayer()->GetGroup() && !u2->ToPlayer()->GetGroup()->isRaidGroup()) ||
|
||||
(u1->GetTypeId() == TYPEID_PLAYER && u2->GetTypeId() == TYPEID_UNIT && (u2->ToCreature()->GetCreatureTemplate()->type_flags & CREATURE_TYPE_FLAG_TREAT_AS_RAID_UNIT) && u1->ToPlayer()->GetGroup() && !u1->ToPlayer()->GetGroup()->isRaidGroup()))
|
||||
@@ -17854,7 +17854,7 @@ bool Unit::IsInRaidWith(Unit const* unit) const
|
||||
return u1->ToPlayer()->IsInSameRaidWith(u2->ToPlayer());
|
||||
// Xinef: we assume that npcs with the same faction are in party
|
||||
else if (u1->GetTypeId() == TYPEID_UNIT && u2->GetTypeId() == TYPEID_UNIT && !u1->IsControlledByPlayer() && !u2->IsControlledByPlayer())
|
||||
return u1->getFaction() == u2->getFaction();
|
||||
return u1->GetFaction() == u2->GetFaction();
|
||||
else if ((u2->GetTypeId() == TYPEID_PLAYER && u1->GetTypeId() == TYPEID_UNIT && u1->ToCreature()->GetCreatureTemplate()->type_flags & CREATURE_TYPE_FLAG_TREAT_AS_RAID_UNIT) ||
|
||||
(u1->GetTypeId() == TYPEID_PLAYER && u2->GetTypeId() == TYPEID_UNIT && u2->ToCreature()->GetCreatureTemplate()->type_flags & CREATURE_TYPE_FLAG_TREAT_AS_RAID_UNIT))
|
||||
return true;
|
||||
@@ -19903,7 +19903,7 @@ void Unit::BuildValuesUpdate(uint8 updateType, ByteBuffer* data, Player* target)
|
||||
fieldBuffer << (m_uint32Values[UNIT_FIELD_BYTES_2] & ((UNIT_BYTE2_FLAG_SANCTUARY /*| UNIT_BYTE2_FLAG_AURAS | UNIT_BYTE2_FLAG_UNK5*/) << 8)); // this flag is at uint8 offset 1 !!
|
||||
else
|
||||
// pretend that all other HOSTILE players have own faction, to allow follow, heal, rezz (trade wont work)
|
||||
fieldBuffer << uint32(target->getFaction());
|
||||
fieldBuffer << uint32(target->GetFaction());
|
||||
}
|
||||
else
|
||||
fieldBuffer << m_uint32Values[index];
|
||||
@@ -19914,7 +19914,7 @@ void Unit::BuildValuesUpdate(uint8 updateType, ByteBuffer* data, Player* target)
|
||||
if (index == UNIT_FIELD_BYTES_2)
|
||||
fieldBuffer << (m_uint32Values[index] & 0xFFFFF2FF); // clear UNIT_BYTE2_FLAG_PVP, UNIT_BYTE2_FLAG_FFA_PVP, UNIT_BYTE2_FLAG_SANCTUARY
|
||||
else
|
||||
fieldBuffer << (uint32)target->getFaction();
|
||||
fieldBuffer << (uint32)target->GetFaction();
|
||||
}
|
||||
else
|
||||
if (!sScriptMgr->IsCustomBuildValuesUpdate(this, updateType, fieldBuffer, target, index))
|
||||
|
||||
Reference in New Issue
Block a user