diff options
author | LogicParrot <LogicParrot@users.noreply.github.com> | 2016-04-13 14:56:39 +0200 |
---|---|---|
committer | LogicParrot <LogicParrot@users.noreply.github.com> | 2016-04-13 14:56:39 +0200 |
commit | a717fb91b02c826471e45d45d4b428db84832eb6 (patch) | |
tree | eded0f3a6350c3f55cdb18cfbb98cffe18b2b04d /src | |
parent | Merge pull request #3137 from cuberite/issue3136 (diff) | |
parent | Fix occasional freeze bug (diff) | |
download | cuberite-a717fb91b02c826471e45d45d4b428db84832eb6.tar cuberite-a717fb91b02c826471e45d45d4b428db84832eb6.tar.gz cuberite-a717fb91b02c826471e45d45d4b428db84832eb6.tar.bz2 cuberite-a717fb91b02c826471e45d45d4b428db84832eb6.tar.lz cuberite-a717fb91b02c826471e45d45d4b428db84832eb6.tar.xz cuberite-a717fb91b02c826471e45d45d4b428db84832eb6.tar.zst cuberite-a717fb91b02c826471e45d45d4b428db84832eb6.zip |
Diffstat (limited to 'src')
-rw-r--r-- | src/Entities/Player.cpp | 71 | ||||
-rw-r--r-- | src/Entities/Player.h | 10 |
2 files changed, 42 insertions, 39 deletions
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 48ba2a3cc..735446729 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -65,6 +65,7 @@ cPlayer::cPlayer(cClientHandlePtr a_Client, const AString & a_PlayerName) : m_GameMode(eGameMode_NotSet), m_IP(""), m_ClientHandle(a_Client), + m_IsFrozen(false), m_NormalMaxSpeed(1.0), m_SprintingMaxSpeed(1.3), m_FlyingMaxSpeed(1.0), @@ -1759,41 +1760,6 @@ void cPlayer::TossItems(const cItems & a_Items) -void cPlayer::FreezeInternal(const Vector3d & a_Location, bool a_ManuallyFrozen) -{ - SetSpeed(0, 0, 0); - SetPosition(a_Location); - m_IsFrozen = true; - m_IsManuallyFrozen = a_ManuallyFrozen; - - double NormalMaxSpeed = GetNormalMaxSpeed(); - double SprintMaxSpeed = GetSprintingMaxSpeed(); - double FlyingMaxpeed = GetFlyingMaxSpeed(); - bool IsFlying = m_IsFlying; - - // Set the client-side speed to 0 - m_NormalMaxSpeed = 0; - m_SprintingMaxSpeed = 0; - m_FlyingMaxSpeed = 0; - m_IsFlying = true; - - // Send the client its fake speed and max speed of 0 - GetClientHandle()->SendPlayerMoveLook(); - GetClientHandle()->SendPlayerAbilities(); - GetClientHandle()->SendPlayerMaxSpeed(); - GetClientHandle()->SendEntityVelocity(*this); - - // Keep the server side speed variables as they were in the first place - m_NormalMaxSpeed = NormalMaxSpeed; - m_SprintingMaxSpeed = SprintMaxSpeed; - m_FlyingMaxSpeed = FlyingMaxpeed; - m_IsFlying = IsFlying; -} - - - - - bool cPlayer::DoMoveToWorld(cWorld * a_World, bool a_ShouldSendRespawn, Vector3d a_NewPosition) { ASSERT(a_World != nullptr); @@ -2546,3 +2512,38 @@ AString cPlayer::GetUUIDFileName(const AString & a_UUID) res.append(".json"); return res; } + + + + + +void cPlayer::FreezeInternal(const Vector3d & a_Location, bool a_ManuallyFrozen) +{ + SetSpeed(0, 0, 0); + SetPosition(a_Location); + m_IsFrozen = true; + m_IsManuallyFrozen = a_ManuallyFrozen; + + double NormalMaxSpeed = GetNormalMaxSpeed(); + double SprintMaxSpeed = GetSprintingMaxSpeed(); + double FlyingMaxpeed = GetFlyingMaxSpeed(); + bool IsFlying = m_IsFlying; + + // Set the client-side speed to 0 + m_NormalMaxSpeed = 0; + m_SprintingMaxSpeed = 0; + m_FlyingMaxSpeed = 0; + m_IsFlying = true; + + // Send the client its fake speed and max speed of 0 + GetClientHandle()->SendPlayerMoveLook(); + GetClientHandle()->SendPlayerAbilities(); + GetClientHandle()->SendPlayerMaxSpeed(); + GetClientHandle()->SendEntityVelocity(*this); + + // Keep the server side speed variables as they were in the first place + m_NormalMaxSpeed = NormalMaxSpeed; + m_SprintingMaxSpeed = SprintMaxSpeed; + m_FlyingMaxSpeed = FlyingMaxpeed; + m_IsFlying = IsFlying; +} diff --git a/src/Entities/Player.h b/src/Entities/Player.h index f04bcdd39..2f1e892dc 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -693,11 +693,13 @@ protected: /** Tosses a list of items. */ void TossItems(const cItems & a_Items); - /** Pins the player to a_Location until Unfreeze() is called. - If ManuallyFrozen is false, the player will unfreeze when the chunk is loaded. */ - void FreezeInternal(const Vector3d & a_Location, bool a_ManuallyFrozen); - /** Returns the filename for the player data based on the UUID given. This can be used both for online and offline UUIDs. */ AString GetUUIDFileName(const AString & a_UUID); + +private: + + /** Pins the player to a_Location until Unfreeze() is called. + If ManuallyFrozen is false, the player will unfreeze when the chunk is loaded. */ + void FreezeInternal(const Vector3d & a_Location, bool a_ManuallyFrozen); } ; // tolua_export |