From e6634ed26c50e99f6ccd285235fe477cb4168b06 Mon Sep 17 00:00:00 2001 From: peterbell10 Date: Sat, 9 May 2020 15:51:15 +0100 Subject: Update submodules (#4727) Closes #4708 This updates jsoncpp, mbedtls, TCLAP and SQLiteCpp to their latest stable release. A few additional changes were needed: * jsoncpp deprecated Reader, FastWriter and StyledWriter which I've replaced with some helper functions in JsonUtils.cpp * SQLiteCpp changed how it builds with external sqlite libraries, now expecting them to be installed. The simplest path was to remove sqlite from cuberite's submodule and just use SQLiteCpp's internal version. --- src/Protocol/MojangAPI.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'src/Protocol/MojangAPI.cpp') diff --git a/src/Protocol/MojangAPI.cpp b/src/Protocol/MojangAPI.cpp index be6ee35e2..8a3868ecc 100644 --- a/src/Protocol/MojangAPI.cpp +++ b/src/Protocol/MojangAPI.cpp @@ -8,6 +8,7 @@ #include "SQLiteCpp/Database.h" #include "SQLiteCpp/Statement.h" #include "../IniFile.h" +#include "../JsonUtils.h" #include "json/json.h" #include "../mbedTLS++/BlockingSslClientSocket.h" #include "../mbedTLS++/SslConfig.h" @@ -514,7 +515,7 @@ void cMojangAPI::LoadCachesFromDisk(void) try { // Open up the SQLite DB: - SQLite::Database db("MojangAPI.sqlite", SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE); + SQLite::Database db("MojangAPI.sqlite", SQLite::OPEN_READWRITE | SQLite::OPEN_CREATE); db.exec("CREATE TABLE IF NOT EXISTS PlayerNameToUUID (PlayerName, UUID, DateTime)"); db.exec("CREATE TABLE IF NOT EXISTS UUIDToProfile (UUID, PlayerName, Textures, TexturesSignature, DateTime)"); @@ -572,7 +573,7 @@ void cMojangAPI::SaveCachesToDisk(void) try { // Open up the SQLite DB: - SQLite::Database db("MojangAPI.sqlite", SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE); + SQLite::Database db("MojangAPI.sqlite", SQLite::OPEN_READWRITE | SQLite::OPEN_CREATE); db.exec("CREATE TABLE IF NOT EXISTS PlayerNameToUUID (PlayerName, UUID, DateTime)"); db.exec("CREATE TABLE IF NOT EXISTS UUIDToProfile (UUID, PlayerName, Textures, TexturesSignature, DateTime)"); @@ -670,8 +671,7 @@ void cMojangAPI::QueryNamesToUUIDs(AStringVector & a_NamesToQuery) root.append(req); } // for itr - a_PlayerNames[] a_NamesToQuery.erase(a_NamesToQuery.begin(), itr); - Json::FastWriter Writer; - AString RequestBody = Writer.write(root); + auto RequestBody = JsonUtils::WriteFastString(root); // Create the HTTP request: AString Request; @@ -712,11 +712,11 @@ void cMojangAPI::QueryNamesToUUIDs(AStringVector & a_NamesToQuery) Response.erase(0, idxHeadersEnd + 4); // Parse the returned string into Json: - Json::Reader reader; - if (!reader.parse(Response, root, false) || !root.isArray()) + AString ParseError; + if (!JsonUtils::ParseString(Response, root, &ParseError) || !root.isArray()) { - LOGWARNING("%s failed: Cannot parse received data (NameToUUID) to JSON: \"%s\"", __FUNCTION__, reader.getFormattedErrorMessages().c_str()); - LOGD("Response body:\n%s", CreateHexDump(HexDump, Response.data(), Response.size(), 16).c_str()); + LOGWARNING("%s failed: Cannot parse received data (NameToUUID) to JSON: \"%s\"", __FUNCTION__, ParseError); + LOGD("Response body:\n%s", CreateHexDump(HexDump, Response.data(), Response.size(), 16)); continue; } @@ -822,11 +822,11 @@ void cMojangAPI::QueryUUIDToProfile(const cUUID & a_UUID) Response.erase(0, idxHeadersEnd + 4); // Parse the returned string into Json: - Json::Reader reader; Json::Value root; - if (!reader.parse(Response, root, false) || !root.isObject()) + AString ParseError; + if (!JsonUtils::ParseString(Response, root, &ParseError) || !root.isObject()) { - LOGWARNING("%s failed: Cannot parse received data (NameToUUID) to JSON: \"%s\"", __FUNCTION__, reader.getFormattedErrorMessages().c_str()); + LOGWARNING("%s failed: Cannot parse received data (NameToUUID) to JSON: \"%s\"", __FUNCTION__, ParseError); LOGD("Response body:\n%s", CreateHexDump(HexDump, Response.data(), Response.size(), 16).c_str()); return; } -- cgit v1.2.3