summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@hotmail.co.uk>2014-07-02 19:46:13 +0200
committerTiger Wang <ziwei.tiger@hotmail.co.uk>2014-07-02 19:46:13 +0200
commitc1ae5513ec9e9cc3aac641b793a77f3ef4c14bda (patch)
tree1624effc95b97caa3778b6311849a1433bc844fa /src
parentRedstone simulator is alerted to lever unpowering (diff)
downloadcuberite-c1ae5513ec9e9cc3aac641b793a77f3ef4c14bda.tar
cuberite-c1ae5513ec9e9cc3aac641b793a77f3ef4c14bda.tar.gz
cuberite-c1ae5513ec9e9cc3aac641b793a77f3ef4c14bda.tar.bz2
cuberite-c1ae5513ec9e9cc3aac641b793a77f3ef4c14bda.tar.lz
cuberite-c1ae5513ec9e9cc3aac641b793a77f3ef4c14bda.tar.xz
cuberite-c1ae5513ec9e9cc3aac641b793a77f3ef4c14bda.tar.zst
cuberite-c1ae5513ec9e9cc3aac641b793a77f3ef4c14bda.zip
Diffstat (limited to '')
-rw-r--r--src/Entities/Player.cpp10
-rw-r--r--src/Entities/Player.h5
2 files changed, 14 insertions, 1 deletions
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index daf1ef2cc..66791eb7c 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -71,6 +71,7 @@ cPlayer::cPlayer(cClientHandle* a_Client, const AString & a_PlayerName)
, m_FloaterID(-1)
, m_Team(NULL)
, m_TicksUntilNextSave(PLAYER_INVENTORY_SAVE_INTERVAL)
+ , m_bIsTeleporting(false)
{
LOGD("Created a player object for \"%s\" @ \"%s\" at %p, ID %d",
a_PlayerName.c_str(), a_Client->GetIPString().c_str(),
@@ -225,7 +226,7 @@ void cPlayer::Tick(float a_Dt, cChunk & a_Chunk)
SendExperience();
}
- if (GetPosition() != m_LastPos) // Change in position from last tick?
+ if (!GetPosition().EqualsEps(m_LastPos, 0.01)) // Non negligible change in position from last tick?
{
// Apply food exhaustion from movement:
ApplyFoodExhaustionFromMovement();
@@ -970,6 +971,7 @@ void cPlayer::Respawn(void)
// Reset food level:
m_FoodLevel = MAX_FOOD_LEVEL;
m_FoodSaturationLevel = 5;
+ m_FoodExhaustionLevel = 0;
// Reset Experience
m_CurrentXp = 0;
@@ -1226,6 +1228,7 @@ void cPlayer::TeleportToCoords(double a_PosX, double a_PosY, double a_PosZ)
SetPosition(a_PosX, a_PosY, a_PosZ);
m_LastGroundHeight = (float)a_PosY;
m_LastJumpHeight = (float)a_PosY;
+ m_bIsTeleporting = true;
m_World->BroadcastTeleportEntity(*this, GetClientHandle());
m_ClientHandle->SendPlayerMoveLook();
@@ -2079,6 +2082,11 @@ void cPlayer::ApplyFoodExhaustionFromMovement()
{
return;
}
+ if (m_bIsTeleporting)
+ {
+ m_bIsTeleporting = false;
+ return;
+ }
// If riding anything, apply no food exhaustion
if (m_AttachedTo != NULL)
diff --git a/src/Entities/Player.h b/src/Entities/Player.h
index 2f7957f16..9e443b468 100644
--- a/src/Entities/Player.h
+++ b/src/Entities/Player.h
@@ -546,6 +546,11 @@ protected:
Default save interval is #defined in PLAYER_INVENTORY_SAVE_INTERVAL */
unsigned int m_TicksUntilNextSave;
+ /** Flag used by food handling system to determine whether a teleport has just happened
+ Will not apply food penalties if found to be true; will set to false after processing
+ */
+ bool m_bIsTeleporting;
+
} ; // tolua_export