diff options
author | LogicParrot <LogicParrot@users.noreply.github.com> | 2017-08-27 08:13:40 +0200 |
---|---|---|
committer | LogicParrot <LogicParrot@users.noreply.github.com> | 2017-08-27 08:13:40 +0200 |
commit | e274d0dd8a6eefeb6e84272ffd09ac55b2c08900 (patch) | |
tree | 377f52ed5738810c157e631ec31f626fbe5acef6 /src/Entities | |
parent | d (diff) | |
parent | Implement anvil chunk sparsing (diff) | |
download | cuberite-e274d0dd8a6eefeb6e84272ffd09ac55b2c08900.tar cuberite-e274d0dd8a6eefeb6e84272ffd09ac55b2c08900.tar.gz cuberite-e274d0dd8a6eefeb6e84272ffd09ac55b2c08900.tar.bz2 cuberite-e274d0dd8a6eefeb6e84272ffd09ac55b2c08900.tar.lz cuberite-e274d0dd8a6eefeb6e84272ffd09ac55b2c08900.tar.xz cuberite-e274d0dd8a6eefeb6e84272ffd09ac55b2c08900.tar.zst cuberite-e274d0dd8a6eefeb6e84272ffd09ac55b2c08900.zip |
Diffstat (limited to '')
-rw-r--r-- | src/Entities/Entity.cpp | 4 | ||||
-rw-r--r-- | src/Entities/Player.cpp | 13 | ||||
-rw-r--r-- | src/Entities/Player.h | 16 |
3 files changed, 17 insertions, 16 deletions
diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index 4f35315f7..347c0ec91 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -56,8 +56,8 @@ cEntity::cEntity(eEntityType a_EntityType, double a_X, double a_Y, double a_Z, d m_TicksSinceLastVoidDamage(0), m_IsSwimming(false), m_IsSubmerged(false), - m_AirLevel(0), - m_AirTickTimer(0), + m_AirLevel(MAX_AIR_LEVEL), + m_AirTickTimer(DROWNING_TICKS), m_TicksAlive(0), m_IsTicking(false), m_ParentChunk(nullptr), diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 60da8c758..fb2274cad 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -84,7 +84,7 @@ cPlayer::cPlayer(cClientHandlePtr a_Client, const AString & a_PlayerName) : m_bIsInBed(false), m_TicksUntilNextSave(PLAYER_INVENTORY_SAVE_INTERVAL), m_bIsTeleporting(false), - m_UUID((a_Client != nullptr) ? a_Client->GetUUID() : ""), + m_UUID((a_Client != nullptr) ? a_Client->GetUUID() : cUUID{}), m_CustomName(""), m_SkinParts(0), m_MainHand(mhRight) @@ -2077,7 +2077,7 @@ bool cPlayer::LoadFromDisk(cWorldPtr & a_World) } // Load from the offline UUID file, if allowed: - AString OfflineUUID = cClientHandle::GenerateOfflineUUID(GetName()); + cUUID OfflineUUID = cClientHandle::GenerateOfflineUUID(GetName()); const char * OfflineUsage = " (unused)"; if (cRoot::Get()->GetServer()->ShouldLoadOfflinePlayerData()) { @@ -2105,7 +2105,7 @@ bool cPlayer::LoadFromDisk(cWorldPtr & a_World) // None of the files loaded successfully LOG("Player data file not found for %s (%s, offline %s%s), will be reset to defaults.", - GetName().c_str(), m_UUID.c_str(), OfflineUUID.c_str(), OfflineUsage + GetName().c_str(), m_UUID.ToShortString().c_str(), OfflineUUID.ToShortString().c_str(), OfflineUsage ); if (a_World == nullptr) @@ -2220,7 +2220,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)); + cFile::CreateFolder(FILE_IO_PREFIX + AString("players/") + m_UUID.ToShortString().substr(0, 2)); // create the JSON data Json::Value JSON_PlayerPosition; @@ -2879,10 +2879,9 @@ void cPlayer::RemoveClientHandle(void) -AString cPlayer::GetUUIDFileName(const AString & a_UUID) +AString cPlayer::GetUUIDFileName(const cUUID & a_UUID) { - AString UUID = cMojangAPI::MakeUUIDDashed(a_UUID); - ASSERT(UUID.length() == 36); + AString UUID = a_UUID.ToLongString(); AString res("players/"); res.append(UUID, 0, 2); diff --git a/src/Entities/Player.h b/src/Entities/Player.h index 5b0aa84a8..5c08151c8 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -8,6 +8,8 @@ #include "../Statistics.h" +#include "../UUID.h" + @@ -488,14 +490,14 @@ public: /** Whether placing the given blocks would intersect any entitiy */ bool DoesPlacingBlocksIntersectEntity(const sSetBlockVector & a_Blocks); + /** Returns the UUID that has been read from the client, or nil if not available. */ + const cUUID & GetUUID(void) const { return m_UUID; } // Exported in ManualBindings.cpp + // tolua_begin /** Returns wheter the player can fly or not. */ virtual bool CanFly(void) const { return m_CanFly; } - /** Returns the UUID (short format) that has been read from the client, or empty string if not available. */ - const AString & GetUUID(void) const { return m_UUID; } - /** (Re)loads the rank and permissions from the cRankManager. Expects the m_UUID member to be valid. Loads the m_Rank, m_Permissions, m_MsgPrefix, m_MsgSuffix and m_MsgNameColorCode members. */ @@ -694,9 +696,9 @@ protected: */ bool m_bIsTeleporting; - /** The short UUID (no dashes) of the player, as read from the ClientHandle. - If no ClientHandle is given, the UUID is initialized to empty. */ - AString m_UUID; + /** The UUID of the player, as read from the ClientHandle. + If no ClientHandle is given, the UUID is nil. */ + cUUID m_UUID; AString m_CustomName; @@ -731,7 +733,7 @@ protected: /** 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); + AString GetUUIDFileName(const cUUID & a_UUID); private: |