diff options
author | Tiger Wang <ziwei.tiger@hotmail.co.uk> | 2014-06-22 16:05:02 +0200 |
---|---|---|
committer | Tiger Wang <ziwei.tiger@hotmail.co.uk> | 2014-06-22 16:05:02 +0200 |
commit | c13cffcd30da6b7f4e040de935d5958a30326f8c (patch) | |
tree | 7967052d180cad38d4c10981241f9b98ec5000b9 | |
parent | Fixed another daylight sensor bug (diff) | |
parent | Fixed missing break (diff) | |
download | cuberite-c13cffcd30da6b7f4e040de935d5958a30326f8c.tar cuberite-c13cffcd30da6b7f4e040de935d5958a30326f8c.tar.gz cuberite-c13cffcd30da6b7f4e040de935d5958a30326f8c.tar.bz2 cuberite-c13cffcd30da6b7f4e040de935d5958a30326f8c.tar.lz cuberite-c13cffcd30da6b7f4e040de935d5958a30326f8c.tar.xz cuberite-c13cffcd30da6b7f4e040de935d5958a30326f8c.tar.zst cuberite-c13cffcd30da6b7f4e040de935d5958a30326f8c.zip |
Diffstat (limited to '')
-rw-r--r-- | CONTRIBUTORS | 4 | ||||
-rw-r--r-- | MCServer/Plugins/APIDump/APIDesc.lua | 3 | ||||
-rw-r--r-- | src/ClientHandle.cpp | 29 | ||||
-rw-r--r-- | src/ClientHandle.h | 11 | ||||
-rw-r--r-- | src/Simulator/IncrementalRedstoneSimulator.cpp | 6 |
5 files changed, 47 insertions, 6 deletions
diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 50c8dbfb8..09515aa6b 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -1,6 +1,6 @@ Many people have contributed to MCServer, and this list attempts to broadcast at least some of them. -BasedDoge - Donated AlchemistVillage prefabs +BasedDoge (Donated AlchemistVillage prefabs) bearbin (Alexander Harkness) derouinw Diusrex @@ -27,6 +27,6 @@ tonibm19 UltraCoderRU worktycho xoft -Yeeeeezus - Donated AlchemistVillage prefabs +Yeeeeezus (Donated AlchemistVillage prefabs) Please add yourself to this list if you contribute to MCServer. diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 19ca971e2..06e333cf9 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -523,13 +523,16 @@ end Functions = { + GenerateOfflineUUID = { Params = "Username", Return = "string", Notes = "(STATIC) Generates an UUID based on the player name provided. This is used for the offline (non-auth) mode, when there's no UUID source. Each username generates a unique and constant UUID, so that when the player reconnects with the same name, their UUID is the same. Returns a 36-char UUID (with dashes)." }, GetLocale = { Params = "", Return = "Locale", Notes = "Returns the locale string that the client sends as part of the protocol handshake. Can be used to provide localized strings." }, GetPing = { Params = "", Return = "number", Notes = "Returns the ping time, in ms" }, GetPlayer = { Params = "", Return = "{{cPlayer|cPlayer}}", Notes = "Returns the player object connected to this client. Note that this may be nil, for example if the player object is not yet spawned." }, GetUniqueID = { Params = "", Return = "number", Notes = "Returns the UniqueID of the client used to identify the client in the server" }, + GetUUID = { Params = "", Return = "string", Notes = "Returns the authentication-based UUID of the client. This UUID should be used to identify the player when persisting any player-related data." }, GetUsername = { Params = "", Return = "string", Notes = "Returns the username that the client has provided" }, GetViewDistance = { Params = "", Return = "number", Notes = "Returns the viewdistance (number of chunks loaded for the player in each direction)" }, HasPluginChannel = { Params = "ChannelName", Return = "bool", Notes = "Returns true if the client has registered to receive messages on the specified plugin channel." }, + IsUUIDOnline = { Params = "UUID", Return = "bool", Notes = "(STATIC) Returns true if the UUID is generated by online auth, false if it is an offline-generated UUID. We use Version-3 UUIDs for offline UUIDs, online UUIDs are Version-4, thus we can tell them apart. Accepts both 32-char and 36-char UUIDs (with and without dashes). If the string given is not a valid UUID, returns false."}, Kick = { Params = "Reason", Return = "", Notes = "Kicks the user with the specified reason" }, SendPluginMessage = { Params = "Channel, Message", Return = "", Notes = "Sends the plugin message on the specified channel." }, SetLocale = { Params = "Locale", Return = "", Notes = "Sets the locale that MCServer keeps on record. Initially the locale is initialized in protocol handshake, this function allows plugins to override the stored value (but only server-side and only until the user disconnects)." }, diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index ade7e20ac..46083a8f1 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -232,6 +232,9 @@ AString cClientHandle::FormatMessageType(bool ShouldAppendChatPrefixes, eMessage AString cClientHandle::GenerateOfflineUUID(const AString & a_Username) { + // Online UUIDs are always version 4 (random) + // We use Version 3 (MD5 hash) UUIDs for the offline UUIDs + // This guarantees that they will never collide with an online UUID and can be distinguished. // Proper format for a version 3 UUID is: // xxxxxxxx-xxxx-3xxx-yxxx-xxxxxxxxxxxx where x is any hexadecimal digit and y is one of 8, 9, A, or B @@ -254,6 +257,32 @@ AString cClientHandle::GenerateOfflineUUID(const AString & a_Username) +bool cClientHandle::IsUUIDOnline(const AString & a_UUID) +{ + // Online UUIDs are always version 4 (random) + // We use Version 3 (MD5 hash) UUIDs for the offline UUIDs + // This guarantees that they will never collide with an online UUID and can be distinguished. + // The version-specifying char is at pos #12 of raw UUID, pos #14 in dashed-UUID. + switch (a_UUID.size()) + { + case 32: + { + // This is the UUID format without dashes, the version char is at pos #12: + return (a_UUID[12] == '4'); + } + case 36: + { + // This is the UUID format with dashes, the version char is at pos #14: + return (a_UUID[14] == '4'); + } + } + return false; +} + + + + + void cClientHandle::Kick(const AString & a_Reason) { if (m_State >= csAuthenticating) // Don't log pings diff --git a/src/ClientHandle.h b/src/ClientHandle.h index 0d883f3af..3e18cbdad 100644 --- a/src/ClientHandle.h +++ b/src/ClientHandle.h @@ -63,7 +63,7 @@ public: const AString & GetIPString(void) const { return m_IPString; } - cPlayer* GetPlayer() { return m_Player; } // tolua_export + cPlayer * GetPlayer(void) { return m_Player; } // tolua_export const AString & GetUUID(void) const { return m_UUID; } // tolua_export void SetUUID(const AString & a_UUID) { m_UUID = a_UUID; } @@ -76,9 +76,16 @@ public: /** Generates an UUID based on the player name provided. This is used for the offline (non-auth) mode, when there's no UUID source. - Each username generates a unique and constant UUID, so that when the player reconnects with the same name, their UUID is the same. */ + Each username generates a unique and constant UUID, so that when the player reconnects with the same name, their UUID is the same. + Returns a 36-char UUID (with dashes). */ static AString GenerateOfflineUUID(const AString & a_Username); // tolua_export + /** Returns true if the UUID is generated by online auth, false if it is an offline-generated UUID. + We use Version-3 UUIDs for offline UUIDs, online UUIDs are Version-4, thus we can tell them apart. + Accepts both 32-char and 36-char UUIDs (with and without dashes). + If the string given is not a valid UUID, returns false. */ + static bool IsUUIDOnline(const AString & a_UUID); // tolua_export + /** Formats the type of message with the proper color and prefix for sending to the client. **/ static AString FormatMessageType(bool ShouldAppendChatPrefixes, eMessageType a_ChatPrefix, const AString & a_AdditionalData); diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp index a54867171..1de0d2c34 100644 --- a/src/Simulator/IncrementalRedstoneSimulator.cpp +++ b/src/Simulator/IncrementalRedstoneSimulator.cpp @@ -348,6 +348,7 @@ void cIncrementalRedstoneSimulator::SimulateChunk(float a_Dt, int a_ChunkX, int case E_BLOCK_REDSTONE_REPEATER_ON: { HandleRedstoneRepeater(dataitr->x, dataitr->y, dataitr->z, dataitr->Data); + break; } case E_BLOCK_REDSTONE_TORCH_OFF: case E_BLOCK_REDSTONE_TORCH_ON: @@ -763,7 +764,7 @@ void cIncrementalRedstoneSimulator::HandleRedstoneRepeater(int a_RelBlockX, int void cIncrementalRedstoneSimulator::HandleRedstoneRepeaterDelays() { - for (RepeatersDelayList::iterator itr = m_RepeatersDelayList->begin(); itr != m_RepeatersDelayList->end(); itr++) + for (RepeatersDelayList::iterator itr = m_RepeatersDelayList->begin(); itr != m_RepeatersDelayList->end();) { if (itr->a_ElapsedTicks >= itr->a_DelayTicks) // Has the elapsed ticks reached the target ticks? @@ -809,7 +810,7 @@ void cIncrementalRedstoneSimulator::HandleRedstoneRepeaterDelays() { m_Chunk->SetBlock(RelBlockX, RelBlockY, RelBlockZ, E_BLOCK_REDSTONE_REPEATER_OFF, Meta); } - m_RepeatersDelayList->erase(itr); + itr = m_RepeatersDelayList->erase(itr); } else { @@ -818,6 +819,7 @@ void cIncrementalRedstoneSimulator::HandleRedstoneRepeaterDelays() // I am confounded to say why. Perhaps optimisation failure. LOGD("Incremented a repeater @ {%i %i %i} | Elapsed ticks: %i | Target delay: %i", itr->a_RelBlockPos.x, itr->a_RelBlockPos.y, itr->a_RelBlockPos.z, itr->a_ElapsedTicks, itr->a_DelayTicks); itr->a_ElapsedTicks++; + itr++; } } } |