diff options
Diffstat (limited to 'src')
-rwxr-xr-x | src/server/game/Entities/GameObject/GameObject.cpp | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp index e686e46c41d..6ef62519f40 100755 --- a/src/server/game/Entities/GameObject/GameObject.cpp +++ b/src/server/game/Entities/GameObject/GameObject.cpp @@ -133,13 +133,13 @@ void GameObject::AddToWorld() m_zoneScript->OnGameObjectCreate(this); sObjectAccessor->AddObject(this); - bool startOpen = (GetGoType() == GAMEOBJECT_TYPE_DOOR || GetGoType() == GAMEOBJECT_TYPE_BUTTON ? GetGOInfo()->door.startOpen : false); + // The state can be changed after GameObject::Create but before GameObject::AddToWorld - bool toggledState = GetGoType() == GAMEOBJECT_TYPE_CHEST ? getLootState () == GO_READY : GetGoState() != GO_STATE_READY; + bool toggledState = GetGoType() == GAMEOBJECT_TYPE_CHEST ? getLootState () == GO_READY : GetGoState() == GO_STATE_READY; if (m_model) GetMap()->InsertGameObjectModel(*m_model); - EnableCollision(startOpen ^ toggledState); + EnableCollision(toggledState); WorldObject::AddToWorld(); } } @@ -1926,14 +1926,12 @@ void GameObject::SetLootState(LootState state, Unit* unit) sScriptMgr->OnGameObjectLootStateChanged(this, state, unit); if (m_model) { - // 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); - + bool collision = false; // Use the current go state if ((GetGoState() != GO_STATE_READY && (state == GO_ACTIVATED || state == GO_JUST_DEACTIVATED)) || state == GO_READY) - startOpen = !startOpen; + collision = !collision; - EnableCollision(startOpen); + EnableCollision(collision); } } @@ -1947,12 +1945,11 @@ void GameObject::SetGoState(GOState state) return; // 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 (state != GO_STATE_READY) - startOpen = !startOpen; + bool collision = false; + if (state == GO_STATE_READY) + collision = !collision; - EnableCollision(startOpen); + EnableCollision(collision); } } |