Core/GameObject: save spawn GOState and reset to it instead of toggling from whatever current state we have

Prevents exploit of SMART_ACTION_ACTIVATE_GOBJECT

(cherry picked from commit be3199314a)
This commit is contained in:
ariel-
2016-08-28 05:25:09 -03:00
committed by joschiwald
parent 54b038fe2f
commit 8a3f053a2f
2 changed files with 7 additions and 1 deletions

View File

@@ -53,6 +53,7 @@ GameObject::GameObject() : WorldObject(false), MapObject(),
m_usetimes = 0;
m_spellId = 0;
m_cooldownTime = 0;
m_prevGoState = GO_STATE_ACTIVE;
m_goInfo = nullptr;
m_goData = nullptr;
m_packedRotation = 0;
@@ -260,6 +261,7 @@ bool GameObject::Create(uint32 name_id, Map* map, uint32 /*phaseMask*/, Position
m_model = CreateModel();
// GAMEOBJECT_BYTES_1, index at 0, 1, 2 and 3
SetGoType(GameobjectTypes(goinfo->type));
m_prevGoState = go_state;
SetGoState(go_state);
SetGoArtKit(artKit);
@@ -1197,7 +1199,9 @@ void GameObject::ResetDoorOrButton()
if (m_lootState == GO_READY || m_lootState == GO_JUST_DEACTIVATED)
return;
SwitchDoorOrButton(false);
RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_IN_USE);
SetGoState(m_prevGoState);
SetLootState(GO_JUST_DEACTIVATED);
m_cooldownTime = 0;
}