Skip to content

Commit

Permalink
Collision/GameObjects: Fixed LoS for all doors (open and closed). Loo…
Browse files Browse the repository at this point in the history
…ks like data0 for type 0 is in fact startClosed instead of startOpen

closes TrinityCore#5660
Signed-off-by: Subv <s.v.h21@hotmail.com>
  • Loading branch information
Subv committed Mar 17, 2012
1 parent 41cc704 commit 21ccfb8
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/server/game/Entities/GameObject/GameObject.cpp
Expand Up @@ -134,7 +134,8 @@ void GameObject::AddToWorld()

sObjectAccessor->AddObject(this);
bool startOpen = (GetGoType() == GAMEOBJECT_TYPE_DOOR || GetGoType() == GAMEOBJECT_TYPE_BUTTON ? GetGOInfo()->door.startOpen : false);
bool toggledState = (GetGOData() ? GetGOData()->go_state == GO_STATE_ACTIVE : false);
// The state can be changed after GameObject::Create but before GameObject::AddToWorld
bool toggledState = GetGoState() == GO_STATE_READY;
if (m_model)
GetMap()->Insert(*m_model);
if ((startOpen && !toggledState) || (!startOpen && toggledState))
Expand Down Expand Up @@ -1904,7 +1905,8 @@ void GameObject::SetLootState(LootState state, Unit* unit)
// startOpen determines whether we are going to add or remove the LoS on activation
bool startOpen = (GetGoType() == GAMEOBJECT_TYPE_DOOR || GetGoType() == GAMEOBJECT_TYPE_BUTTON ? GetGOInfo()->door.startOpen : false);

if (GetGOData() && GetGOData()->go_state == GO_NOT_READY)
// Use the current go state
if (GetGoState() == GO_STATE_ACTIVE)
startOpen = !startOpen;

if (state == GO_ACTIVATED || state == GO_JUST_DEACTIVATED)
Expand All @@ -1925,7 +1927,7 @@ void GameObject::SetGoState(GOState state)
// startOpen determines whether we are going to add or remove the LoS on activation
bool startOpen = (GetGoType() == GAMEOBJECT_TYPE_DOOR || GetGoType() == GAMEOBJECT_TYPE_BUTTON ? GetGOInfo()->door.startOpen : false);

if (GetGOData() && GetGOData()->go_state == GO_NOT_READY)
if (GetGOData() && GetGOData()->go_state == GO_STATE_READY)
startOpen = !startOpen;

if (state == GO_STATE_ACTIVE || state == GO_STATE_ACTIVE_ALTERNATIVE)
Expand Down

0 comments on commit 21ccfb8

Please sign in to comment.