From 8b519bf6e20a987c9544ef11f0df6467831cc069 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 31 Jul 2014 10:02:50 +0200 Subject: MojangAPI: Added a UseCachedOnly param to GetUUIDsFromPlayerNames(). --- src/Protocol/MojangAPI.cpp | 7 +++++-- src/Protocol/MojangAPI.h | 6 ++++-- 2 files changed, 9 insertions(+), 4 deletions(-) (limited to 'src/Protocol') diff --git a/src/Protocol/MojangAPI.cpp b/src/Protocol/MojangAPI.cpp index 5fbc5b476..71a5e53de 100644 --- a/src/Protocol/MojangAPI.cpp +++ b/src/Protocol/MojangAPI.cpp @@ -129,7 +129,7 @@ void cMojangAPI::Start(cIniFile & a_SettingsIni) -AStringVector cMojangAPI::GetUUIDsFromPlayerNames(const AStringVector & a_PlayerNames) +AStringVector cMojangAPI::GetUUIDsFromPlayerNames(const AStringVector & a_PlayerNames, bool a_UseOnlyCached) { // Convert all playernames to lowercase: AStringVector PlayerNames; @@ -140,7 +140,10 @@ AStringVector cMojangAPI::GetUUIDsFromPlayerNames(const AStringVector & a_Player } // for itr - a_PlayerNames[] // Request the cache to populate any names not yet contained: - CacheNamesToUUIDs(PlayerNames); + if (!a_UseOnlyCached) + { + CacheNamesToUUIDs(PlayerNames); + } // Retrieve from cache: size_t idx = 0; diff --git a/src/Protocol/MojangAPI.h b/src/Protocol/MojangAPI.h index c99f940ad..ac8995bb5 100644 --- a/src/Protocol/MojangAPI.h +++ b/src/Protocol/MojangAPI.h @@ -50,8 +50,10 @@ public: /** Converts the player names into UUIDs. a_PlayerName[idx] will be converted to UUID and returned as idx-th value The UUID will be empty on error. - Blocking operation, do not use in world-tick thread! */ - AStringVector GetUUIDsFromPlayerNames(const AStringVector & a_PlayerName); + If a_UseOnlyCached is true, only the cached values are returned. + If a_UseOnlyCached is false, the names not found in the cache are looked up online, which is a blocking + operation, do not use this in world-tick thread! */ + AStringVector GetUUIDsFromPlayerNames(const AStringVector & a_PlayerName, bool a_UseOnlyCached = false); // tolua_begin -- cgit v1.2.3