diff options
author | madmaxoft <github@xoft.cz> | 2014-07-17 10:06:13 +0200 |
---|---|---|
committer | madmaxoft <github@xoft.cz> | 2014-07-17 10:06:13 +0200 |
commit | e66b81b3951680511f2bfffd12c8f96dbbb5865a (patch) | |
tree | 5a5bcdad7cc8b70b65bc60a1a3d8f6eb7a85501a /src/Entities | |
parent | Merge remote-tracking branch 'origin/master' into potions (diff) | |
parent | Another fix for excessive food drain (diff) | |
download | cuberite-e66b81b3951680511f2bfffd12c8f96dbbb5865a.tar cuberite-e66b81b3951680511f2bfffd12c8f96dbbb5865a.tar.gz cuberite-e66b81b3951680511f2bfffd12c8f96dbbb5865a.tar.bz2 cuberite-e66b81b3951680511f2bfffd12c8f96dbbb5865a.tar.lz cuberite-e66b81b3951680511f2bfffd12c8f96dbbb5865a.tar.xz cuberite-e66b81b3951680511f2bfffd12c8f96dbbb5865a.tar.zst cuberite-e66b81b3951680511f2bfffd12c8f96dbbb5865a.zip |
Diffstat (limited to 'src/Entities')
-rw-r--r-- | src/Entities/Player.cpp | 13 | ||||
-rw-r--r-- | src/Entities/Player.h | 2 |
2 files changed, 12 insertions, 3 deletions
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 23fd6522a..0bfceec17 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -129,7 +129,7 @@ cPlayer::~cPlayer(void) if (!cRoot::Get()->GetPluginManager()->CallHookPlayerDestroyed(*this)) { cRoot::Get()->BroadcastChatLeave(Printf("%s has left the game", GetName().c_str())); - LOGINFO("Player %s has left the game.", GetName().c_str()); + LOGINFO("Player %s has left the game", GetName().c_str()); } LOGD("Deleting cPlayer \"%s\" at %p, ID %d", GetName().c_str(), this, GetUniqueID()); @@ -1784,7 +1784,7 @@ bool cPlayer::LoadFromFile(const AString & a_FileName) cStatSerializer StatSerializer(cRoot::Get()->GetDefaultWorld()->GetName(), GetName(), &m_Stats); StatSerializer.Load(); - LOGD("Player \"%s\" was read from file \"%s\", spawning at {%.2f, %.2f, %.2f} in world \"%s\"", + LOGD("Player %s was read from file \"%s\", spawning at {%.2f, %.2f, %.2f} in world \"%s\"", GetName().c_str(), a_FileName.c_str(), GetPosX(), GetPosY(), GetPosZ(), m_LoadedWorldName.c_str() ); @@ -2110,6 +2110,8 @@ void cPlayer::ApplyFoodExhaustionFromMovement() { return; } + + // If we have just teleported, apply no exhaustion if (m_bIsTeleporting) { m_bIsTeleporting = false; @@ -2121,6 +2123,13 @@ void cPlayer::ApplyFoodExhaustionFromMovement() { return; } + + // Process exhaustion every two ticks as that is how frequently m_LastPos is updated + // Otherwise, we apply exhaustion for a 'movement' every tick, one of which is an already processed value + if (GetWorld()->GetWorldAge() % 2 != 0) + { + return; + } // Calculate the distance travelled, update the last pos: Vector3d Movement(GetPosition() - m_LastPos); diff --git a/src/Entities/Player.h b/src/Entities/Player.h index 5aebe861a..5c367e3c8 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -447,7 +447,7 @@ protected: double m_FoodSaturationLevel; /** Count-up to the healing or damaging action, based on m_FoodLevel */ - int m_FoodTickTimer; + int m_FoodTickTimer; /** A "buffer" which adds up hunger before it is substracted from m_FoodSaturationLevel or m_FoodLevel. Each action adds a little */ double m_FoodExhaustionLevel; |