From a68c70c900d0f3b3842d78af49423890f29af180 Mon Sep 17 00:00:00 2001 From: Howaner Date: Sat, 16 Aug 2014 18:44:14 +0200 Subject: Better OnPlayerMoving hook. --- src/Entities/Player.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/Entities') diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 4398a5bf3..ab4ff3161 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -225,16 +225,24 @@ void cPlayer::Tick(float a_Dt, cChunk & a_Chunk) SendExperience(); } + bool CanMove = true; if (!GetPosition().EqualsEps(m_LastPos, 0.01)) // Non negligible change in position from last tick? { // Apply food exhaustion from movement: ApplyFoodExhaustionFromMovement(); - cRoot::Get()->GetPluginManager()->CallHookPlayerMoving(*this); + if (cRoot::Get()->GetPluginManager()->CallHookPlayerMoving(*this, m_LastPos, GetPosition())) + { + CanMove = false; + TeleportToCoords(m_LastPos.x, m_LastPos.y, m_LastPos.z); + } m_ClientHandle->StreamChunks(); } - BroadcastMovementUpdate(m_ClientHandle); + if (CanMove) + { + BroadcastMovementUpdate(m_ClientHandle); + } if (m_Health > 0) // make sure player is alive { -- cgit v1.2.3 From 80559406f99bd32de066c8a80b9f920b8b57b8f1 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Sun, 17 Aug 2014 22:47:00 +0200 Subject: Player saving creates the "players" folder, if needed. Fixes #1268. --- src/Entities/Player.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/Entities') diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index ab4ff3161..0b13e62a9 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -1842,6 +1842,7 @@ bool cPlayer::LoadFromFile(const AString & a_FileName, cWorldPtr & a_World) bool cPlayer::SaveToDisk() { + cFile::CreateFolder(FILE_IO_PREFIX + AString("players/")); // Create the "players" folder, if it doesn't exist yet (#1268) cFile::CreateFolder(FILE_IO_PREFIX + AString("players/") + m_UUID.substr(0, 2)); // create the JSON data -- cgit v1.2.3 From e4fc05574bc4d888a8794d68c518e5242c494f69 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Mon, 18 Aug 2014 22:48:15 +0200 Subject: Player: Silenced a few type conversion warnings. --- src/Entities/Player.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/Entities') diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 0b13e62a9..32290885d 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -892,7 +892,7 @@ void cPlayer::KilledBy(TakeDamageInfo & a_TDI) Pickups.Add(cItem(E_ITEM_RED_APPLE)); } - m_Stats.AddValue(statItemsDropped, Pickups.Size()); + m_Stats.AddValue(statItemsDropped, (StatValue)Pickups.Size()); m_World->SpawnItemPickups(Pickups, GetPosX(), GetPosY(), GetPosZ(), 10); SaveToDisk(); // Save it, yeah the world is a tough place ! @@ -1618,7 +1618,7 @@ void cPlayer::TossPickup(const cItem & a_Item) void cPlayer::TossItems(const cItems & a_Items) { - m_Stats.AddValue(statItemsDropped, a_Items.Size()); + m_Stats.AddValue(statItemsDropped, (StatValue)a_Items.Size()); double vX = 0, vY = 0, vZ = 0; EulerToVector(-GetYaw(), GetPitch(), vZ, vX, vY); -- cgit v1.2.3