From fd2775d9e80469e7afaffba69c761b3772cfeed0 Mon Sep 17 00:00:00 2001 From: DarthArgus Date: Fri, 11 May 2018 16:46:50 +0000 Subject: [PATCH] this should make things display properly again --- .../src/shared/ClientConnection.cpp | 6 ++--- external/3rd/library/webAPI/webAPI.cpp | 23 +++++++++++++++++-- external/3rd/library/webAPI/webAPI.h | 7 ++++-- 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/engine/server/application/LoginServer/src/shared/ClientConnection.cpp b/engine/server/application/LoginServer/src/shared/ClientConnection.cpp index d955e5eb..8b43f6d8 100755 --- a/engine/server/application/LoginServer/src/shared/ClientConnection.cpp +++ b/engine/server/application/LoginServer/src/shared/ClientConnection.cpp @@ -161,7 +161,7 @@ void ClientConnection::validateClient(const std::string &id, const std::string & StationId user_id; StationId parent_id; - std::unordered_map childAccounts; + std::unordered_map childAccounts; if (!authURL.empty()) { // create the object @@ -184,8 +184,8 @@ void ClientConnection::validateClient(const std::string &id, const std::string & childAccounts = api.getStringMap("subAccounts"); if (!ConfigLoginServer::getUseOldSuidGenerator()) { - user_id = static_cast(api.getNullableValue("user_id")); - parent_id = static_cast(api.getNullableValue("parent_id")); + user_id = static_cast(api.getNullableValue("user_id")); + parent_id = static_cast(api.getNullableValue("parent_id")); } else { if (parentAccount.length() > MAX_ACCOUNT_NAME_LENGTH) { parentAccount.resize(MAX_ACCOUNT_NAME_LENGTH); diff --git a/external/3rd/library/webAPI/webAPI.cpp b/external/3rd/library/webAPI/webAPI.cpp index b03ea28c..faf7d11b 100644 --- a/external/3rd/library/webAPI/webAPI.cpp +++ b/external/3rd/library/webAPI/webAPI.cpp @@ -72,7 +72,26 @@ std::unordered_map webAPI::getStringMap(const std::string &slo return ret; } -bool webAPI::submit(const int &reqType, const int &getPost, const int &respType) { +std::unordered_map webAPI::getStringMap64(const std::string &slot) { + std::unordered_map ret = std::unordered_map(); + + if (!responseData.empty() && !slot.empty() && responseData.count(slot) && !responseData[slot].is_null()) { + + nlohmann::json j = responseData[slot]; + + for (nlohmann::json::iterator it = j.begin(); it != j.end(); ++it) { + std::string tmp(it.key()); + int64_t k = strtoll(tmp.c_str(), nullptr, 10); + std::string val = it.value(); + + ret.insert({k, val}); + } + } + + return ret; +} + +bool webAPI::submit(const int32_t &reqType, const int32_t &getPost, const int32_t &respType) { if (reqType == DTYPE::JSON) // json request { if (!requestData.empty()) { @@ -93,7 +112,7 @@ bool webAPI::submit(const int &reqType, const int &getPost, const int &respType) return false; } -bool webAPI::fetch(const int &getPost, const int &mimeType) // 0 for json 1 for string +bool webAPI::fetch(const int32_t &getPost, const int32_t &mimeType) // 0 for json 1 for string { bool fetchStatus = false; diff --git a/external/3rd/library/webAPI/webAPI.h b/external/3rd/library/webAPI/webAPI.h index 501c18cb..2209b8f5 100644 --- a/external/3rd/library/webAPI/webAPI.h +++ b/external/3rd/library/webAPI/webAPI.h @@ -49,7 +49,7 @@ namespace StellaBellum { // submits the request bool - submit(const int &reqType = DTYPE::JSON, const int &getPost = HTTP::POST, const int &respType = DTYPE::JSON); + submit(const int32_t &reqType = DTYPE::JSON, const int32_t &getPost = HTTP::POST, const int32_t &respType = DTYPE::JSON); // set the endpoint after object creation...or change the target if needed bool setEndpoint(const std::string endpoint); @@ -66,6 +66,9 @@ namespace StellaBellum { // get a vector of strings from a given slot std::unordered_map getStringMap(const std::string &slot); + // get a 64 bit keyed vector of strings from a given slot + std::unordered_map getStringMap64(const std::string &slot); + // set json key and value for request template bool addJsonData(const std::string &key, const T &value) { if (!key.empty() && @@ -104,7 +107,7 @@ namespace StellaBellum { std::string uri; // fetcher - returns raw response direct from remote - bool fetch(const int &getPost = HTTP::POST, const int &mimeType = DTYPE::JSON); + bool fetch(const int32_t &getPost = HTTP::POST, const int32_t &mimeType = DTYPE::JSON); // cURL writeback callback static size_t writeCallback(void *contents, size_t size, size_t nmemb, void *userp);