refactor(Core): update getFaction to GetFaction and setFaction to SetFaction (#8708)

This commit is contained in:
Malcrom
2021-11-01 13:04:32 -03:00
committed by GitHub
parent 3396a9da87
commit f106de8788
129 changed files with 418 additions and 444 deletions
@@ -446,7 +446,7 @@ bool Creature::UpdateEntry(uint32 Entry, const CreatureData* data, bool changele
if (!GetCreatureAddon())
SetSheath(SHEATH_STATE_MELEE);
setFaction(cInfo->faction);
SetFaction(cInfo->faction);
uint32 npcflag, unit_flags, dynamicflags;
ObjectMgr::ChooseCreatureFlags(cInfo, npcflag, unit_flags, dynamicflags, data);
@@ -517,7 +517,7 @@ bool Creature::UpdateEntry(uint32 Entry, const CreatureData* data, bool changele
{
if (Player* owner = Creature::GetCharmerOrOwnerPlayerOrPlayerItself()) // this check comes in case we don't have a player
{
setFaction(owner->getFaction()); // vehicles should have same as owner faction
SetFaction(owner->GetFaction()); // vehicles should have same as owner faction
owner->VehicleSpellInitialize();
}
}
@@ -2280,7 +2280,7 @@ bool Creature::CanAssistTo(const Unit* u, const Unit* enemy, bool checkfaction /
// only from same creature faction
if (checkfaction)
{
if (getFaction() != u->getFaction())
if (GetFaction() != u->GetFaction())
return false;
}
else
@@ -2362,7 +2362,7 @@ void Creature::UpdateMoveInLineOfSightState()
}
bool nonHostile = true;
if (FactionTemplateEntry const* factionTemplate = sFactionTemplateStore.LookupEntry(getFaction()))
if (FactionTemplateEntry const* factionTemplate = sFactionTemplateStore.LookupEntry(GetFaction()))
if (factionTemplate->hostileMask || factionTemplate->enemyFaction[0] || factionTemplate->enemyFaction[1] || factionTemplate->enemyFaction[2] || factionTemplate->enemyFaction[3])
nonHostile = false;
@@ -199,7 +199,7 @@ void TempSummon::InitStats(uint32 duration)
{
if (IsTrigger() && m_spells[0])
{
setFaction(owner->getFaction());
SetFaction(owner->GetFaction());
SetLevel(owner->getLevel());
if (owner->GetTypeId() == TYPEID_PLAYER)
m_ControlledByPlayer = true;
@@ -227,9 +227,9 @@ void TempSummon::InitStats(uint32 duration)
}
if (m_Properties->Faction)
setFaction(m_Properties->Faction);
SetFaction(m_Properties->Faction);
else if (IsVehicle() && owner) // properties should be vehicle
setFaction(owner->getFaction());
SetFaction(owner->GetFaction());
}
void TempSummon::InitSummon()
@@ -320,7 +320,7 @@ void Minion::InitStats(uint32 duration)
Unit* owner = GetOwner();
SetCreatorGUID(owner->GetGUID());
setFaction(owner->getFaction());
SetFaction(owner->GetFaction());
owner->SetMinion(this, true);
}
@@ -2023,7 +2023,7 @@ void GameObject::CastSpell(Unit* target, uint32 spellId)
if (Unit* owner = GetOwner())
{
trigger->SetLevel(owner->getLevel(), false);
trigger->setFaction(owner->getFaction());
trigger->SetFaction(owner->GetFaction());
// needed for GO casts for proper target validation checks
trigger->SetOwnerGUID(owner->GetGUID());
// xinef: fixes some duel bugs with traps]
@@ -2042,7 +2042,7 @@ void GameObject::CastSpell(Unit* target, uint32 spellId)
else
{
// xinef: set faction of gameobject, if no faction - assume hostile
trigger->setFaction(GetTemplateAddon() && GetTemplateAddon()->faction ? GetTemplateAddon()->faction : 14);
trigger->SetFaction(GetTemplateAddon() && GetTemplateAddon()->faction ? GetTemplateAddon()->faction : 14);
// Set owner guid for target if no owner availble - needed by trigger auras
// - trigger gets despawned and there's no caster avalible (see AuraEffect::TriggerSpell())
// xinef: set proper orientation, fixes cast against stealthed targets
+1 -1
View File
@@ -2256,7 +2256,7 @@ Creature* WorldObject::SummonTrigger(float x, float y, float z, float ang, uint3
//summon->SetName(GetName());
if (setLevel && (GetTypeId() == TYPEID_PLAYER || GetTypeId() == TYPEID_UNIT))
{
summon->setFaction(((Unit*)this)->getFaction());
summon->SetFaction(((Unit*)this)->GetFaction());
summon->SetLevel(((Unit*)this)->getLevel());
}
+1 -1
View File
@@ -2231,7 +2231,7 @@ void Pet::HandleAsynchLoadFailed(AsynchPetSummon* info, Player* player, uint8 as
if (info->m_createdBySpell)
pet->SetUInt32Value(UNIT_CREATED_BY_SPELL, info->m_createdBySpell);
pet->SetCreatorGUID(player->GetGUID());
pet->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE, player->getFaction());
pet->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE, player->GetFaction());
pet->setPowerType(POWER_MANA);
pet->SetUInt32Value(UNIT_NPC_FLAGS, 0);
+10 -10
View File
@@ -517,7 +517,7 @@ bool Player::Create(ObjectGuid::LowType guidlow, CharacterCreateInfo* createInfo
m_realRace = createInfo->Race; // set real race flag
m_race = createInfo->Race; // set real race flag
setFactionForRace(createInfo->Race);
SetFactionForRace(createInfo->Race);
if (!IsValidGender(createInfo->Gender))
{
@@ -2060,7 +2060,7 @@ Creature* Player::GetNPCIfCanInteractWith(ObjectGuid guid, uint32 npcflagmask)
// xinef: not needed, CORRECTLY checked above including forced reputations etc
// not unfriendly
//if (FactionTemplateEntry const* factionTemplate = sFactionTemplateStore.LookupEntry(creature->getFaction()))
//if (FactionTemplateEntry const* factionTemplate = sFactionTemplateStore.LookupEntry(creature->GetFaction()))
// if (factionTemplate->faction)
// if (FactionEntry const* faction = sFactionStore.LookupEntry(factionTemplate->faction))
// if (faction->reputationListID >= 0 && GetReputationMgr().GetRank(faction) <= REP_UNFRIENDLY)
@@ -2150,14 +2150,14 @@ void Player::SetGameMaster(bool on)
{
m_ExtraFlags |= PLAYER_EXTRA_GM_ON;
if (AccountMgr::IsGMAccount(GetSession()->GetSecurity()))
setFaction(35);
SetFaction(FACTION_FRIENDLY);
SetFlag(PLAYER_FLAGS, PLAYER_FLAGS_GM);
SetFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_ALLOW_CHEAT_SPELLS);
if (Pet* pet = GetPet())
{
if (AccountMgr::IsGMAccount(GetSession()->GetSecurity()))
pet->setFaction(35);
pet->SetFaction(FACTION_FRIENDLY);
pet->getHostileRefMgr().setOnlineOfflineState(false);
}
@@ -2181,13 +2181,13 @@ void Player::SetGameMaster(bool on)
SetPhaseMask(newPhase, false);
m_ExtraFlags &= ~ PLAYER_EXTRA_GM_ON;
setFactionForRace(getRace(true));
SetFactionForRace(getRace(true));
RemoveFlag(PLAYER_FLAGS, PLAYER_FLAGS_GM);
RemoveFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_ALLOW_CHEAT_SPELLS);
if (Pet* pet = GetPet())
{
pet->setFaction(getFaction());
pet->SetFaction(GetFaction());
pet->getHostileRefMgr().setOnlineOfflineState(true);
}
@@ -5649,7 +5649,7 @@ TeamId Player::TeamIdForRace(uint8 race)
return TEAM_ALLIANCE;
}
void Player::setFactionForRace(uint8 race)
void Player::SetFactionForRace(uint8 race)
{
m_team = TeamIdForRace(race);
@@ -5659,7 +5659,7 @@ void Player::setFactionForRace(uint8 race)
return;
ChrRacesEntry const* rEntry = sChrRacesStore.LookupEntry(race);
setFaction(rEntry ? rEntry->FactionID : 0);
SetFaction(rEntry ? rEntry->FactionID : 0);
}
ReputationRank Player::GetReputationRank(uint32 faction) const
@@ -14442,7 +14442,7 @@ void Player::SetIsSpectator(bool on)
AddAura(SPECTATOR_SPELL_SPEED, this);
m_ExtraFlags |= PLAYER_EXTRA_SPECTATOR_ON;
AddUnitState(UNIT_STATE_ISOLATED);
//setFaction(1100);
//SetFaction(1100);
SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
RemoveByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP);
ResetContestedPvP();
@@ -14459,7 +14459,7 @@ void Player::SetIsSpectator(bool on)
if (!IsGameMaster())
{
//setFactionForRace(getRace());
//SetFactionForRace(getRace());
// restore FFA PvP Server state
// Xinef: it will be removed if necessery in UpdateArea called in WorldPortOpcode
+1 -1
View File
@@ -2048,7 +2048,7 @@ public:
static TeamId TeamIdForRace(uint8 race);
[[nodiscard]] TeamId GetTeamId(bool original = false) const { return original ? TeamIdForRace(getRace(true)) : m_team; };
void setFactionForRace(uint8 race);
void SetFactionForRace(uint8 race);
void setTeamId(TeamId teamid) { m_team = teamid; };
void InitDisplayIds();
@@ -5104,7 +5104,7 @@ bool Player::LoadFromDB(ObjectGuid playerGuid, CharacterDatabaseQueryHolder cons
//Need to call it to initialize m_team (m_team can be calculated from race)
//Other way is to saves m_team into characters table.
setFactionForRace(getRace(true));
SetFactionForRace(getRace(true));
// pussywizard: create empty instance bind containers if necessary
sInstanceSaveMgr->PlayerCreateBoundInstancesMaps(playerGuid);
+17 -17
View File
@@ -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))
+2 -2
View File
@@ -1596,8 +1596,8 @@ public:
virtual void SetSheath(SheathState sheathed) { SetByteValue(UNIT_FIELD_BYTES_2, 0, sheathed); }
// faction template id
[[nodiscard]] uint32 getFaction() const { return GetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE); }
void setFaction(uint32 faction);
[[nodiscard]] uint32 GetFaction() const { return GetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE); }
void SetFaction(uint32 faction);
[[nodiscard]] FactionTemplateEntry const* GetFactionTemplateEntry() const;
ReputationRank GetReactionTo(Unit const* target) const;