aboutsummaryrefslogtreecommitdiff
path: root/src/server/game
diff options
context:
space:
mode:
authorlinencloth <none@none>2010-11-16 01:13:04 +0100
committerlinencloth <none@none>2010-11-16 01:13:04 +0100
commit8fae0c176d73a1606f26a5b0d7fc44f7a23ba49c (patch)
tree5504659fc056351c6ed350368afc7ea0a9d1a5db /src/server/game
parent57c76407b05a919bad20008ffbfc1590a044d2ad (diff)
Core/Units: Rename and change Get/SetVisibility to use a bool value instead of an unnecessary enum
Also replace some SetVisibility hacks to directly call UpdateObjectVisibility --HG-- branch : trunk
Diffstat (limited to 'src/server/game')
-rwxr-xr-xsrc/server/game/AI/CoreAI/CombatAI.cpp6
-rwxr-xr-xsrc/server/game/AI/EventAI/CreatureEventAI.cpp2
-rw-r--r--src/server/game/AI/SmartScripts/SmartAI.cpp4
-rw-r--r--src/server/game/AI/SmartScripts/SmartScript.cpp2
-rwxr-xr-xsrc/server/game/Entities/Creature/Creature.cpp2
-rwxr-xr-xsrc/server/game/Entities/GameObject/GameObject.cpp2
-rwxr-xr-xsrc/server/game/Entities/Player/Player.cpp4
-rwxr-xr-xsrc/server/game/Entities/Unit/Unit.cpp8
-rwxr-xr-xsrc/server/game/Entities/Unit/Unit.h10
-rwxr-xr-xsrc/server/game/Grids/Notifiers/GridNotifiers.h2
-rwxr-xr-xsrc/server/game/Spells/Auras/SpellAuraEffects.cpp4
-rwxr-xr-xsrc/server/game/Spells/Spell.cpp2
12 files changed, 21 insertions, 27 deletions
diff --git a/src/server/game/AI/CoreAI/CombatAI.cpp b/src/server/game/AI/CoreAI/CombatAI.cpp
index 9ae9f14d118..f54daa9367f 100755
--- a/src/server/game/AI/CoreAI/CombatAI.cpp
+++ b/src/server/game/AI/CoreAI/CombatAI.cpp
@@ -265,7 +265,7 @@ AOEAI::AOEAI(Creature *c) : CreatureAI(c)
if (!me->m_spells[0])
sLog.outError("AOEAI set for creature (entry = %u) with spell1=0. AI will do nothing", me->GetEntry());
- me->SetVisibility(VISIBILITY_ON);//visible to see all spell anims
+ me->SetVisible(true);//visible to see all spell anims
me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);//can't be targeted
me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_ATTACKABLE_1);//can't be damaged
me->SetDisplayId(11686);//invisible model,around a size of a player
@@ -308,7 +308,7 @@ void VehicleAI::UpdateAI(const uint32 diff)
if (m_DismissTimer < diff)
{
m_DoDismiss = false;
- me->SetVisibility(VISIBILITY_OFF);
+ me->SetVisible(false);
me->ForcedDespawn();
}else m_DismissTimer -= diff;
}
@@ -316,7 +316,7 @@ void VehicleAI::UpdateAI(const uint32 diff)
void VehicleAI::Reset()
{
- me->SetVisibility(VISIBILITY_ON);
+ me->SetVisible(true);
m_vehicle->Reset();
}
diff --git a/src/server/game/AI/EventAI/CreatureEventAI.cpp b/src/server/game/AI/EventAI/CreatureEventAI.cpp
index 43cee18ae01..e69deffff52 100755
--- a/src/server/game/AI/EventAI/CreatureEventAI.cpp
+++ b/src/server/game/AI/EventAI/CreatureEventAI.cpp
@@ -781,7 +781,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
me->SetPhaseMask(action.raw.param1, true);
break;
case ACTION_T_SET_VISIBILITY:
- me->SetVisibility(UnitVisibility(action.raw.param1));
+ me->SetVisible(bool(action.raw.param1));
break;
case ACTION_T_SET_ACTIVE:
me->setActive(action.raw.param1 ? true : false);
diff --git a/src/server/game/AI/SmartScripts/SmartAI.cpp b/src/server/game/AI/SmartScripts/SmartAI.cpp
index fbc0e563cd5..4fb4cbdcc53 100644
--- a/src/server/game/AI/SmartScripts/SmartAI.cpp
+++ b/src/server/game/AI/SmartScripts/SmartAI.cpp
@@ -79,7 +79,7 @@ void SmartAI::UpdateDespawn(const uint32 diff)
{
if (mDespawnState == 2)
{
- me->SetVisibility(VISIBILITY_OFF);
+ me->SetVisible(false);
mDespawnTime = 5000;
mDespawnState++;
}
@@ -544,7 +544,7 @@ void SmartAI::JustRespawned()
mDespawnTime = 0;
mDespawnState = 0;
mEscortState = SMART_ESCORT_NONE;
- me->SetVisibility(VISIBILITY_ON);
+ me->SetVisible(true);
if (me->getFaction() != me->GetCreatureInfo()->faction_A)
me->RestoreFaction();
GetScript()->ProcessEventsFor(SMART_EVENT_RESPAWN);
diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp
index 6e330105e07..700eb6c311a 100644
--- a/src/server/game/AI/SmartScripts/SmartScript.cpp
+++ b/src/server/game/AI/SmartScripts/SmartScript.cpp
@@ -681,7 +681,7 @@ void SmartScript::ProcessAction(SmartScriptHolder &e, Unit* unit, uint32 var0, u
case SMART_ACTION_SET_VISIBILITY:
{
if (me)
- me->SetVisibility(e.action.visibility.state ? VISIBILITY_ON : VISIBILITY_OFF);
+ me->SetVisible(e.action.visibility.state ? true : false);
break;
}
case SMART_ACTION_SET_ACTIVE:
diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp
index 1a37d5a71a8..01ad4fd12da 100755
--- a/src/server/game/Entities/Creature/Creature.cpp
+++ b/src/server/game/Entities/Creature/Creature.cpp
@@ -814,7 +814,7 @@ bool Creature::Create(uint32 guidlow, Map *map, uint32 phaseMask, uint32 Entry,
}
if (Entry == VISUAL_WAYPOINT)
- SetVisibility(VISIBILITY_OFF);
+ SetVisible(false);
return bResult;
}
diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp
index bb79c2e0ea4..4a1521264e5 100755
--- a/src/server/game/Entities/GameObject/GameObject.cpp
+++ b/src/server/game/Entities/GameObject/GameObject.cpp
@@ -1598,7 +1598,7 @@ void GameObject::CastSpell(Unit* target, uint32 spellId)
Creature *trigger = SummonTrigger(GetPositionX(), GetPositionY(), GetPositionZ(), 0, 1);
if (!trigger) return;
- trigger->SetVisibility(VISIBILITY_OFF); //should this be true?
+ trigger->SetVisible(false); //should this be true?
if (Unit *owner = GetOwner())
{
trigger->setFaction(owner->getFaction());
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
index 17a98548ddc..454001f3bd5 100755
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -20520,7 +20520,7 @@ bool Player::IsVisibleGloballyFor(Player* u) const
return true;
// Visible units, always are visible for all players
- if (GetVisibility() == VISIBILITY_ON)
+ if (IsVisible())
return true;
// GMs are visible for higher gms (or players are visible for gms)
@@ -20528,7 +20528,7 @@ bool Player::IsVisibleGloballyFor(Player* u) const
return GetSession()->GetSecurity() <= u->GetSession()->GetSecurity();
// non faction visibility non-breakable for non-GMs
- if (GetVisibility() == VISIBILITY_OFF)
+ if (!IsVisible())
return false;
// non-gm stealth/invisibility not hide from global player lists
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp
index 7c833b31a96..b3754da5142 100755
--- a/src/server/game/Entities/Unit/Unit.cpp
+++ b/src/server/game/Entities/Unit/Unit.cpp
@@ -12140,9 +12140,9 @@ bool Unit::isAlwaysDetectableFor(WorldObject const* seer) const
return false;
}
-void Unit::SetVisibility(UnitVisibility x)
+void Unit::SetVisible(bool x)
{
- if (x == VISIBILITY_OFF)
+ if (!x)
m_serverSideVisibility.SetValue(SERVERSIDE_VISIBILITY_GM, SEC_GAMEMASTER);
else
m_serverSideVisibility.SetValue(SERVERSIDE_VISIBILITY_GM, SEC_PLAYER);
@@ -14700,13 +14700,13 @@ void Unit::SetContestedPvP(Player *attackedPlayer)
player->addUnitState(UNIT_STAT_ATTACK_PLAYER);
player->SetFlag(PLAYER_FLAGS, PLAYER_FLAGS_CONTESTED_PVP);
// call MoveInLineOfSight for nearby contested guards
- player->SetVisibility(player->GetVisibility());
+ UpdateObjectVisibility();
}
if (!hasUnitState(UNIT_STAT_ATTACK_PLAYER))
{
addUnitState(UNIT_STAT_ATTACK_PLAYER);
// call MoveInLineOfSight for nearby contested guards
- SetVisibility(GetVisibility());
+ UpdateObjectVisibility();
}
}
diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h
index e777370d81b..5c8406da59e 100755
--- a/src/server/game/Entities/Unit/Unit.h
+++ b/src/server/game/Entities/Unit/Unit.h
@@ -540,12 +540,6 @@ enum DamageEffectType
SELF_DAMAGE = 5
};
-enum UnitVisibility
-{
- VISIBILITY_OFF = 0,
- VISIBILITY_ON = 1
-};
-
// Value masks for UNIT_FIELD_FLAGS
enum UnitFlags
{
@@ -1763,8 +1757,8 @@ class Unit : public WorldObject
void SetFacingToObject(WorldObject* pObject);
// Visibility system
- UnitVisibility GetVisibility() const { return (m_serverSideVisibility.GetValue(SERVERSIDE_VISIBILITY_GM) > SEC_PLAYER) ? VISIBILITY_OFF : VISIBILITY_ON; }
- void SetVisibility(UnitVisibility x);
+ bool IsVisible() const { return (m_serverSideVisibility.GetValue(SERVERSIDE_VISIBILITY_GM) > SEC_PLAYER) ? false : true; }
+ void SetVisible(bool x);
// common function for visibility checks for player/creatures with detection code
diff --git a/src/server/game/Grids/Notifiers/GridNotifiers.h b/src/server/game/Grids/Notifiers/GridNotifiers.h
index f0a6337ec52..6bb392a51b8 100755
--- a/src/server/game/Grids/Notifiers/GridNotifiers.h
+++ b/src/server/game/Grids/Notifiers/GridNotifiers.h
@@ -1144,7 +1144,7 @@ namespace Trinity
AllFriendlyCreaturesInGrid(Unit const* obj) : pUnit(obj) {}
bool operator() (Unit* u)
{
- if (u->isAlive() && u->GetVisibility() == VISIBILITY_ON && u->IsFriendlyTo(pUnit))
+ if (u->isAlive() && u->IsVisible() && u->IsFriendlyTo(pUnit))
return true;
return false;
diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp
index 10b2283b415..4c6609fc0f6 100755
--- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp
+++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp
@@ -2924,8 +2924,8 @@ void AuraEffect::HandlePhase(AuraApplication const * aurApp, uint8 mode, bool ap
target->SetPhaseMask(PHASEMASK_NORMAL, false);
// need triggering visibility update base at phase update of not GM invisible (other GMs anyway see in any phases)
- if (target->GetVisibility() != VISIBILITY_OFF)
- target->SetVisibility(target->GetVisibility());
+ if (!target->IsVisible())
+ target->UpdateObjectVisibility();
}
/**********************/
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp
index 4573f0357f2..a8d1a44528a 100755
--- a/src/server/game/Spells/Spell.cpp
+++ b/src/server/game/Spells/Spell.cpp
@@ -6574,7 +6574,7 @@ bool Spell::CheckTarget(Unit* target, uint32 eff)
//Check player targets and remove if in GM mode or GM invisibility (for not self casting case)
if (target != m_caster && target->GetTypeId() == TYPEID_PLAYER)
{
- if (target->ToPlayer()->GetVisibility() == VISIBILITY_OFF)
+ if (!target->ToPlayer()->IsVisible())
return false;
if (target->ToPlayer()->isGameMaster() && !IsPositiveSpell(m_spellInfo->Id))