diff options
author | Shauren <shauren.trinity@gmail.com> | 2014-09-30 22:48:04 +0200 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2014-09-30 22:48:04 +0200 |
commit | 46acf64d0f44956b0ceee8ff00721ae05f363dcc (patch) | |
tree | ea757dd3a4295a9f750904e6cfb92a7e069f69c2 | |
parent | faa4fc1b31a7625ddf67ad308a9c32e1233886e5 (diff) |
Core/GameObjects: Fixed possible crashes if transport objects don't have entries in TransportAnimation.dbc
-rw-r--r-- | src/server/game/Entities/GameObject/GameObject.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp index 5b4f6807a8a..2d06fe396b8 100644 --- a/src/server/game/Entities/GameObject/GameObject.cpp +++ b/src/server/game/Entities/GameObject/GameObject.cpp @@ -243,8 +243,9 @@ bool GameObject::Create(uint32 guidlow, uint32 name_id, Map* map, uint32 /*phase case GAMEOBJECT_TYPE_TRANSPORT: { m_goValue.Transport.AnimationInfo = sTransportMgr->GetTransportAnimInfo(goinfo->entry); - m_goValue.Transport.PathProgress = (getMSTime() / GetTransportPeriod()); - m_goValue.Transport.PathProgress *= GetTransportPeriod(); + m_goValue.Transport.PathProgress = getMSTime(); + if (m_goValue.Transport.AnimationInfo) + m_goValue.Transport.PathProgress -= m_goValue.Transport.PathProgress % GetTransportPeriod(); // align to period m_goValue.Transport.CurrentSeg = 0; m_goValue.Transport.StateUpdateTimer = 0; m_goValue.Transport.StopFrames = new std::vector<uint32>(); @@ -2129,7 +2130,9 @@ void GameObject::SetTransportState(GOState state, uint32 stopFrame /*= 0*/) if (state == GO_STATE_TRANSPORT_ACTIVE) { m_goValue.Transport.StateUpdateTimer = 0; - m_goValue.Transport.PathProgress = getMSTime() + m_goValue.Transport.StopFrames->at(GetGoState() - GO_STATE_TRANSPORT_STOPPED); + m_goValue.Transport.PathProgress = getMSTime(); + if (GetGoState() >= GO_STATE_TRANSPORT_STOPPED) + m_goValue.Transport.StopFrames->at(GetGoState() - GO_STATE_TRANSPORT_STOPPED); SetGoState(GO_STATE_TRANSPORT_ACTIVE); } else |