mirror of
https://github.com/mangosfour/server.git
synced 2025-12-15 01:37:00 +00:00
[9186] Templated functions for apply some code to all controlled units.
Also fix some related problems with not updates totems/etc
This commit is contained in:
parent
7272b52daf
commit
6704929d56
7 changed files with 165 additions and 76 deletions
|
|
@ -2200,6 +2200,27 @@ void Player::SetInWater(bool apply)
|
|||
getHostileRefManager().updateThreatTables();
|
||||
}
|
||||
|
||||
struct SetGameMasterOnHelper
|
||||
{
|
||||
explicit SetGameMasterOnHelper() {}
|
||||
void operator()(Unit* unit) const
|
||||
{
|
||||
unit->setFaction(35);
|
||||
unit->getHostileRefManager().setOnlineOfflineState(false);
|
||||
}
|
||||
};
|
||||
|
||||
struct SetGameMasterOffHelper
|
||||
{
|
||||
explicit SetGameMasterOffHelper(uint32 _faction) : faction(_faction) {}
|
||||
void operator()(Unit* unit) const
|
||||
{
|
||||
unit->setFaction(faction);
|
||||
unit->getHostileRefManager().setOnlineOfflineState(true);
|
||||
}
|
||||
uint32 faction;
|
||||
};
|
||||
|
||||
void Player::SetGameMaster(bool on)
|
||||
{
|
||||
if(on)
|
||||
|
|
@ -2208,16 +2229,7 @@ void Player::SetGameMaster(bool on)
|
|||
setFaction(35);
|
||||
SetFlag(PLAYER_FLAGS, PLAYER_FLAGS_GM);
|
||||
|
||||
if (Pet* pet = GetPet())
|
||||
{
|
||||
pet->setFaction(35);
|
||||
pet->getHostileRefManager().setOnlineOfflineState(false);
|
||||
}
|
||||
|
||||
for (int8 i = 0; i < MAX_TOTEM; ++i)
|
||||
if(m_TotemSlot[i])
|
||||
if(Creature *totem = GetMap()->GetCreature(m_TotemSlot[i]))
|
||||
totem->setFaction(35);
|
||||
CallForAllControlledUnits(SetGameMasterOnHelper(),true,true,true,false);
|
||||
|
||||
RemoveByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP);
|
||||
ResetContestedPvP();
|
||||
|
|
@ -2237,16 +2249,7 @@ void Player::SetGameMaster(bool on)
|
|||
setFactionForRace(getRace());
|
||||
RemoveFlag(PLAYER_FLAGS, PLAYER_FLAGS_GM);
|
||||
|
||||
if (Pet* pet = GetPet())
|
||||
{
|
||||
pet->setFaction(getFaction());
|
||||
pet->getHostileRefManager().setOnlineOfflineState(true);
|
||||
}
|
||||
|
||||
for (int8 i = 0; i < MAX_TOTEM; ++i)
|
||||
if(m_TotemSlot[i])
|
||||
if(Creature *totem = GetMap()->GetCreature(m_TotemSlot[i]))
|
||||
totem->setFaction(getFaction());
|
||||
CallForAllControlledUnits(SetGameMasterOffHelper(getFaction()),true,true,true,false);
|
||||
|
||||
// restore FFA PvP Server state
|
||||
if(sWorld.IsFFAPvPRealm())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue