From b691c43c44ff180d10e7d4a9afc83b98551ff586 Mon Sep 17 00:00:00 2001 From: daoge_cmd <3523206925@qq.com> Date: Sun, 1 Mar 2026 12:16:08 +0800 Subject: Initial commit --- Minecraft.Client/PSVita/PSVita_PlayerUID.cpp | 217 +++++++++++++++++++++++++++ 1 file changed, 217 insertions(+) create mode 100644 Minecraft.Client/PSVita/PSVita_PlayerUID.cpp (limited to 'Minecraft.Client/PSVita/PSVita_PlayerUID.cpp') diff --git a/Minecraft.Client/PSVita/PSVita_PlayerUID.cpp b/Minecraft.Client/PSVita/PSVita_PlayerUID.cpp new file mode 100644 index 00000000..a678d0a0 --- /dev/null +++ b/Minecraft.Client/PSVita/PSVita_PlayerUID.cpp @@ -0,0 +1,217 @@ +#include "stdafx.h" +#include "PSVita_PlayerUID.h" +#include "..\Minecraft.World\StringHelpers.h" + +// taken from Boost, there is no TR1 equivalent +template +inline void hash_combine(std::size_t& seed, T const& v) +{ + hash hasher; + seed ^= hasher(v) + 0x9e3779b9 + (seed<<6) + (seed>>2); +} + +std::size_t PlayerUID::Hash::operator()(const PlayerUID& k) const +{ + // now only hashing against the local ID, as this is now unique across the network too. + std::size_t seed = 0; + hash_combine(seed, k.m_userID); + for(int i=0; i(macDigit); + } + + // parse the userID + wstring userIDDigits = fromString.substr(15,8); + m_userID = _fromString(userIDDigits); + + // finally, the onlineID, if there is one + wstring onlineID = fromString.substr(24); + if(onlineID.size() > 0) + { + wcstombs(m_onlineID, onlineID.c_str(), 16); + m_bSignedIntoPSN = true; + } + else + { + m_onlineID[0] = 0; + m_bSignedIntoPSN = false; + } +} + + +bool PlayerUID::operator==(const PlayerUID& rhs) const +{ + // comparing online IDs + if(isSignedIntoPSN() && rhs.isSignedIntoPSN()) + { + return (strcmp(m_onlineID, rhs.m_onlineID) == 0); + } + // comparing offline IDs + if(m_userID != rhs.m_userID) + return false; + for(int i=0; i