MojangAPI: Clarified the UUID conversion code.
This commit is contained in:
parent
426773df17
commit
85d64d291a
@ -233,9 +233,14 @@ bool cMojangAPI::SecureRequest(const AString & a_ServerName, const AString & a_R
|
||||
|
||||
AString cMojangAPI::MakeUUIDShort(const AString & a_UUID)
|
||||
{
|
||||
// Note: we only check the string's length, not the actual content
|
||||
switch (a_UUID.size())
|
||||
{
|
||||
case 32: return a_UUID;
|
||||
case 32:
|
||||
{
|
||||
// Already is a short UUID
|
||||
return a_UUID;
|
||||
}
|
||||
|
||||
case 36:
|
||||
{
|
||||
@ -260,12 +265,18 @@ AString cMojangAPI::MakeUUIDShort(const AString & a_UUID)
|
||||
|
||||
AString cMojangAPI::MakeUUIDDashed(const AString & a_UUID)
|
||||
{
|
||||
// Note: we only check the string's length, not the actual content
|
||||
switch (a_UUID.size())
|
||||
{
|
||||
case 36: return a_UUID;
|
||||
case 36:
|
||||
{
|
||||
// Already is a dashed UUID
|
||||
return a_UUID;
|
||||
}
|
||||
|
||||
case 32:
|
||||
{
|
||||
// Insert dashes at the proper positions:
|
||||
AString res;
|
||||
res.reserve(36);
|
||||
res.append(a_UUID, 0, 8);
|
||||
|
@ -36,11 +36,13 @@ public:
|
||||
// tolua_begin
|
||||
|
||||
/** Converts the given UUID to its short form (32 bytes, no dashes).
|
||||
Logs a warning and returns empty string if not a UUID. */
|
||||
Logs a warning and returns empty string if not a UUID.
|
||||
Note: only checks the string's length, not the actual content. */
|
||||
static AString MakeUUIDShort(const AString & a_UUID);
|
||||
|
||||
/** Converts the given UUID to its dashed form (36 bytes, 4 dashes).
|
||||
Logs a warning and returns empty string if not a UUID. */
|
||||
Logs a warning and returns empty string if not a UUID.
|
||||
Note: only checks the string's length, not the actual content. */
|
||||
static AString MakeUUIDDashed(const AString & a_UUID);
|
||||
|
||||
// tolua_end
|
||||
|
Loading…
Reference in New Issue
Block a user