summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt23
m---------lib/SQLiteCpp0
m---------lib/TCLAP0
m---------lib/jsoncpp0
m---------lib/lua0
m---------lib/mbedtls0
m---------lib/sqlite0
-rw-r--r--src/Bindings/CMakeLists.txt2
-rw-r--r--src/Bindings/LuaJson.cpp7
-rw-r--r--src/BlockEntities/CMakeLists.txt2
-rw-r--r--src/BlockTypePalette.cpp6
-rw-r--r--src/Blocks/CMakeLists.txt2
-rw-r--r--src/CMakeLists.txt6
-rw-r--r--src/CompositeChat.cpp6
-rw-r--r--src/Entities/CMakeLists.txt2
-rw-r--r--src/Entities/Player.cpp14
-rw-r--r--src/Items/CMakeLists.txt2
-rw-r--r--src/JsonUtils.cpp43
-rw-r--r--src/JsonUtils.h17
-rw-r--r--src/Mobs/CMakeLists.txt2
-rw-r--r--src/Protocol/Authenticator.cpp4
-rw-r--r--src/Protocol/CMakeLists.txt2
-rw-r--r--src/Protocol/MojangAPI.cpp22
-rw-r--r--src/Protocol/ProtocolRecognizer.cpp4
-rw-r--r--src/Protocol/Protocol_1_10.cpp4
-rw-r--r--src/Protocol/Protocol_1_11.cpp7
-rw-r--r--src/Protocol/Protocol_1_12.cpp10
-rw-r--r--src/Protocol/Protocol_1_13.cpp4
-rw-r--r--src/Protocol/Protocol_1_8.cpp13
-rw-r--r--src/Protocol/Protocol_1_9.cpp23
-rw-r--r--src/RankManager.cpp2
-rw-r--r--src/Simulator/CMakeLists.txt2
-rw-r--r--src/UI/CMakeLists.txt2
-rw-r--r--src/WorldStorage/CMakeLists.txt2
-rw-r--r--src/WorldStorage/StatSerializer.cpp7
-rwxr-xr-xsrc/WorldStorage/WSSAnvil.cpp4
-rw-r--r--tests/BlockTypeRegistry/CMakeLists.txt6
-rw-r--r--tests/CompositeChat/CMakeLists.txt4
-rw-r--r--tests/Generating/CMakeLists.txt2
39 files changed, 154 insertions, 104 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 237257590..15f1a3e95 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -188,7 +188,7 @@ set(SQLITECPP_RUN_CPPCHECK OFF CACHE BOOL "Run cppcheck C++ static analysis t
set(SQLITECPP_RUN_DOXYGEN OFF CACHE BOOL "Run Doxygen C++ documentation tool." FORCE)
set(SQLITECPP_BUILD_EXAMPLES OFF CACHE BOOL "Build examples." FORCE)
set(SQLITECPP_BUILD_TESTS OFF CACHE BOOL "Build and run tests." FORCE)
-set(SQLITECPP_INTERNAL_SQLITE OFF CACHE BOOL "Add the internal SQLite3 source to the project." FORCE)
+set(SQLITECPP_INTERNAL_SQLITE ON CACHE BOOL "Add the internal SQLite3 source to the project." FORCE)
set(SQLITE_ENABLE_COLUMN_METADATA OFF CACHE BOOL "" FORCE)
# Set options for LibEvent, disable all their tests and benchmarks:
@@ -251,29 +251,26 @@ endif()
# Include all the libraries:
-add_subdirectory(lib/jsoncpp/)
+add_subdirectory(lib/jsoncpp/ EXCLUDE_FROM_ALL)
add_subdirectory(lib/zlib/)
add_subdirectory(lib/lua/)
add_subdirectory(lib/tolua++/ EXCLUDE_FROM_ALL)
-add_subdirectory(lib/sqlite/)
add_subdirectory(lib/SQLiteCpp/)
+add_subdirectory(lib/sqlite/)
add_subdirectory(lib/expat/)
add_subdirectory(lib/luaexpat/)
add_subdirectory(lib/libevent/ EXCLUDE_FROM_ALL)
add_subdirectory(lib/fmt)
-# Add proper include directories so that SQLiteCpp can find SQLite3:
-get_property(SQLITECPP_INCLUDES DIRECTORY "lib/SQLiteCpp/" PROPERTY INCLUDE_DIRECTORIES)
-set(SQLITECPP_INCLUDES "${SQLITECPP_INCLUDES}" "${CMAKE_CURRENT_SOURCE_DIR}/lib/sqlite/")
-set_property(DIRECTORY lib/SQLiteCpp/ PROPERTY INCLUDE_DIRECTORIES "${SQLITECPP_INCLUDES}")
-set_property(TARGET SQLiteCpp PROPERTY INCLUDE_DIRECTORIES "${SQLITECPP_INCLUDES}")
-
# Add proper includes for LibEvent's event-config.h header:
include_directories(SYSTEM ${LIBEVENT_INCLUDE_DIRS})
-# Prettify jsoncpp_lib_static name in VS solution explorer
-set_property(TARGET jsoncpp_lib_static PROPERTY PROJECT_LABEL "jsoncpp")
+# Prettify jsoncpp_lib name in VS solution explorer
+set_property(TARGET jsoncpp_lib PROPERTY PROJECT_LABEL "jsoncpp")
+# jsoncpp uses these for ccache support, clashing with our method
+set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "")
+set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK "")
if (WIN32)
add_subdirectory(lib/luaproxy/)
@@ -306,13 +303,13 @@ if (MSVC)
event_extra_static
expat
fmt
- jsoncpp_lib_static
+ jsoncpp_lib
lua
luaexpat
mbedcrypto
mbedtls
mbedx509
- sqlite
+ lsqlite
SQLiteCpp
tolualib
zlib
diff --git a/lib/SQLiteCpp b/lib/SQLiteCpp
-Subproject 1c83894db9deeea32418089e2ffd0c5d3af85b8
+Subproject 829d549af3a11e24fcb0b99090837dac9a9aae4
diff --git a/lib/TCLAP b/lib/TCLAP
-Subproject 12cee38782897cfe60a1611615c200c45cd99ea
+Subproject ec3ddcfe41b0544a4551a57439b6b3682fe3147
diff --git a/lib/jsoncpp b/lib/jsoncpp
-Subproject d5ba7e7332ca05aa0a9740b497f914be2718177
+Subproject d2e6a971f4544c55b8e3b25cf96db266971b778
diff --git a/lib/lua b/lib/lua
-Subproject b4e10cdc437bea82cec9a5da3056ac209bf2386
+Subproject 6d57f1c3c4face973f0405b2a3c0fb8471a79d9
diff --git a/lib/mbedtls b/lib/mbedtls
-Subproject f2a597fa3dd1c7b15e0fee62f6932b253295803
+Subproject ac15f842a5bb8d4cbceb7175c5d7ab50d96173c
diff --git a/lib/sqlite b/lib/sqlite
-Subproject 3ca24a24687eb82c576838ba783c838006004ef
+Subproject 9a17fd73198c645c924996c0aee7836f51bcf7b
diff --git a/src/Bindings/CMakeLists.txt b/src/Bindings/CMakeLists.txt
index 76a912d2b..f5896f02d 100644
--- a/src/Bindings/CMakeLists.txt
+++ b/src/Bindings/CMakeLists.txt
@@ -169,5 +169,5 @@ endif()
if(NOT MSVC)
add_library(Bindings ${SRCS} ${HDRS})
- target_link_libraries(Bindings fmt::fmt lua sqlite tolualib mbedtls HTTPServer)
+ target_link_libraries(Bindings fmt::fmt lua lsqlite tolualib mbedtls HTTPServer SQLiteCpp)
endif()
diff --git a/src/Bindings/LuaJson.cpp b/src/Bindings/LuaJson.cpp
index ef042d44d..1cd88cf96 100644
--- a/src/Bindings/LuaJson.cpp
+++ b/src/Bindings/LuaJson.cpp
@@ -9,6 +9,7 @@
#include "LuaState.h"
#include "tolua++/include/tolua++.h"
#include "json/json.h"
+#include "../JsonUtils.h"
@@ -295,10 +296,10 @@ static int tolua_cJson_Parse(lua_State * a_LuaState)
// Parse the string:
Json::Value root;
- Json::Reader reader;
- if (!reader.parse(input, root, false))
+ AString ParseError;
+ if (!JsonUtils::ParseString(input, root, &ParseError))
{
- L.Push(cLuaState::Nil, Printf("Parsing Json failed: %s", reader.getFormattedErrorMessages().c_str()));
+ L.Push(cLuaState::Nil, Printf("Parsing Json failed: %s", ParseError));
return 2;
}
diff --git a/src/BlockEntities/CMakeLists.txt b/src/BlockEntities/CMakeLists.txt
index 859b845e6..6e88ef128 100644
--- a/src/BlockEntities/CMakeLists.txt
+++ b/src/BlockEntities/CMakeLists.txt
@@ -45,5 +45,5 @@ SET (HDRS
if(NOT MSVC)
add_library(BlockEntities ${SRCS} ${HDRS})
- target_link_libraries(BlockEntities fmt::fmt)
+ target_link_libraries(BlockEntities fmt::fmt SQLiteCpp)
endif()
diff --git a/src/BlockTypePalette.cpp b/src/BlockTypePalette.cpp
index b452023c4..7759505cf 100644
--- a/src/BlockTypePalette.cpp
+++ b/src/BlockTypePalette.cpp
@@ -1,7 +1,7 @@
#include "Globals.h"
#include "BlockTypePalette.h"
#include "json/value.h"
-#include "json/reader.h"
+#include "JsonUtils.h"
@@ -170,10 +170,8 @@ void BlockTypePalette::loadFromJsonString(const AString & aJsonPalette)
{
// Parse the string into JSON object:
Json::Value root;
- Json::CharReaderBuilder builder;
- std::unique_ptr<Json::CharReader> reader(builder.newCharReader());
std::string errs;
- if (!reader->parse(aJsonPalette.data(), aJsonPalette.data() + aJsonPalette.size(), &root, &errs))
+ if (!JsonUtils::ParseString(aJsonPalette, root, &errs))
{
throw LoadFailedException(errs);
}
diff --git a/src/Blocks/CMakeLists.txt b/src/Blocks/CMakeLists.txt
index dea14b7f1..9d9f07b52 100644
--- a/src/Blocks/CMakeLists.txt
+++ b/src/Blocks/CMakeLists.txt
@@ -108,5 +108,5 @@ SET (HDRS
if(NOT MSVC)
add_library(Blocks ${SRCS} ${HDRS})
- target_link_libraries(Blocks fmt::fmt)
+ target_link_libraries(Blocks fmt::fmt SQLiteCpp)
endif()
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 43327d197..2ee723227 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -47,6 +47,7 @@ SET (SRCS
Inventory.cpp
Item.cpp
ItemGrid.cpp
+ JsonUtils.cpp
LightingThread.cpp
LineBlockTracer.cpp
LinearInterpolation.cpp
@@ -126,6 +127,7 @@ SET (HDRS
Item.h
ItemGrid.h
LazyArray.h
+ JsonUtils.h
LightingThread.h
LineBlockTracer.h
LinearInterpolation.h
@@ -171,8 +173,6 @@ file(WRITE "${CMAKE_BINARY_DIR}/include/Globals.h"
"/* This file allows Globals.h to be included with an absolute path */\n#include \"${PROJECT_SOURCE_DIR}/Globals.h\"\n")
include_directories("${CMAKE_BINARY_DIR}/include")
-include_directories ("${CMAKE_CURRENT_SOURCE_DIR}/../lib/sqlite")
-include_directories ("${CMAKE_CURRENT_SOURCE_DIR}/../lib/SQLiteCpp/include")
include_directories (SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/../lib/TCLAP/include")
configure_file("BuildInfo.h.cmake" "${CMAKE_BINARY_DIR}/include/BuildInfo.h")
@@ -439,7 +439,7 @@ if (${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
add_flags_lnk(-L/usr/ports/devel)
endif()
-target_link_libraries(${CMAKE_PROJECT_NAME} luaexpat jsoncpp_lib_static mbedtls zlib sqlite lua SQLiteCpp event_core event_extra fmt::fmt)
+target_link_libraries(${CMAKE_PROJECT_NAME} luaexpat jsoncpp_lib mbedtls zlib lsqlite lua SQLiteCpp event_core event_extra fmt::fmt)
# Create a folder for Bindings' documentation:
FILE(MAKE_DIRECTORY "Bindings/docs")
diff --git a/src/CompositeChat.cpp b/src/CompositeChat.cpp
index e5f4d83e6..fefc0a60c 100644
--- a/src/CompositeChat.cpp
+++ b/src/CompositeChat.cpp
@@ -6,6 +6,7 @@
#include "Globals.h"
#include "CompositeChat.h"
#include "ClientHandle.h"
+#include "JsonUtils.h"
@@ -408,11 +409,10 @@ AString cCompositeChat::CreateJsonString(bool a_ShouldUseChatPrefixes) const
#if 1
// Serialize as machine-readable string (no whitespace):
- Json::FastWriter writer;
- return writer.write(msg);
+ return JsonUtils::WriteFastString(msg);
#else
// Serialize as human-readable string (pretty-printed):
- return msg.toStyledString();
+ return JsonUtils::WriteStyledString(msg);
#endif
}
diff --git a/src/Entities/CMakeLists.txt b/src/Entities/CMakeLists.txt
index 4c1190800..1a6e78af5 100644
--- a/src/Entities/CMakeLists.txt
+++ b/src/Entities/CMakeLists.txt
@@ -59,5 +59,5 @@ SET (HDRS
if(NOT MSVC)
add_library(Entities ${SRCS} ${HDRS})
- target_link_libraries(Entities fmt::fmt WorldStorage)
+ target_link_libraries(Entities fmt::fmt WorldStorage SQLiteCpp)
endif()
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index f82b23e6b..b38e987bd 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -28,6 +28,7 @@
#include "../Blocks/ChunkInterface.h"
#include "../IniFile.h"
+#include "../JsonUtils.h"
#include "json/json.h"
// 6000 ticks or 5 minutes
@@ -2196,10 +2197,13 @@ bool cPlayer::LoadFromFile(const AString & a_FileName, cWorldPtr & a_World)
// Parse the JSON format:
Json::Value root;
- Json::Reader reader;
- if (!reader.parse(buffer, root, false))
+ AString ParseError;
+ if (!JsonUtils::ParseString(buffer, root, &ParseError))
{
- LOGWARNING("Cannot parse player data in file \"%s\"", a_FileName.c_str());
+ FLOGWARNING(
+ "Cannot parse player data in file \"{0}\":\n {1}",
+ a_FileName, ParseError
+ );
return false;
}
@@ -2369,9 +2373,7 @@ bool cPlayer::SaveToDisk()
root["gamemode"] = static_cast<int>(eGameMode_NotSet);
}
- Json::StyledWriter writer;
- std::string JsonData = writer.write(root);
-
+ auto JsonData = JsonUtils::WriteStyledString(root);
AString SourceFile = GetUUIDFileName(m_UUID);
cFile f;
diff --git a/src/Items/CMakeLists.txt b/src/Items/CMakeLists.txt
index 6620f9c6b..9deec08c7 100644
--- a/src/Items/CMakeLists.txt
+++ b/src/Items/CMakeLists.txt
@@ -65,5 +65,5 @@ SET (HDRS
if(NOT MSVC)
add_library(Items ${SRCS} ${HDRS})
- target_link_libraries(Items fmt::fmt)
+ target_link_libraries(Items fmt::fmt SQLiteCpp)
endif()
diff --git a/src/JsonUtils.cpp b/src/JsonUtils.cpp
new file mode 100644
index 000000000..6c70e70d3
--- /dev/null
+++ b/src/JsonUtils.cpp
@@ -0,0 +1,43 @@
+#include "Globals.h"
+
+#include "JsonUtils.h"
+#include "json/json.h"
+
+#include <sstream>
+
+
+namespace JsonUtils
+{
+
+AString WriteFastString(const Json::Value & a_Root)
+{
+ Json::StreamWriterBuilder Builder;
+ Builder["commentStyle"] = "None";
+ Builder["indentation"] = "";
+ return Json::writeString(Builder, a_Root);
+}
+
+
+
+
+
+AString WriteStyledString(const Json::Value & a_Root)
+{
+ Json::StreamWriterBuilder Builder;
+ return Json::writeString(Builder, a_Root);
+}
+
+
+
+
+
+bool ParseString(const AString & a_JsonStr, Json::Value & a_Root, AString * a_ErrorMsg)
+{
+ Json::CharReaderBuilder Builder;
+ std::unique_ptr<Json::CharReader> Reader(Builder.newCharReader());
+
+ const char * Doc = a_JsonStr.data();
+ return Reader->parse(Doc, Doc + a_JsonStr.size(), &a_Root, a_ErrorMsg);
+}
+
+} // namespace JsonUtils
diff --git a/src/JsonUtils.h b/src/JsonUtils.h
new file mode 100644
index 000000000..d315dbed8
--- /dev/null
+++ b/src/JsonUtils.h
@@ -0,0 +1,17 @@
+#pragma once
+
+// fwd:
+namespace Json
+{
+class Value;
+}
+
+namespace JsonUtils
+{
+
+AString WriteFastString(const Json::Value & a_Root);
+AString WriteStyledString(const Json::Value & a_Root);
+
+bool ParseString(const AString & a_JsonStr, Json::Value & a_Root, AString * a_ErrorMsg = nullptr);
+
+}
diff --git a/src/Mobs/CMakeLists.txt b/src/Mobs/CMakeLists.txt
index 579ba8938..aada8f3a8 100644
--- a/src/Mobs/CMakeLists.txt
+++ b/src/Mobs/CMakeLists.txt
@@ -84,5 +84,5 @@ SET (HDRS
if(NOT MSVC)
add_library(Mobs ${SRCS} ${HDRS})
- target_link_libraries(Mobs fmt::fmt)
+ target_link_libraries(Mobs fmt::fmt SQLiteCpp)
endif()
diff --git a/src/Protocol/Authenticator.cpp b/src/Protocol/Authenticator.cpp
index 85c5c920a..995ba1394 100644
--- a/src/Protocol/Authenticator.cpp
+++ b/src/Protocol/Authenticator.cpp
@@ -9,6 +9,7 @@
#include "../UUID.h"
#include "../IniFile.h"
+#include "../JsonUtils.h"
#include "json/json.h"
#include "../mbedTLS++/BlockingSslClientSocket.h"
@@ -185,8 +186,7 @@ bool cAuthenticator::AuthWithYggdrasil(AString & a_UserName, const AString & a_S
return false;
}
Json::Value root;
- Json::Reader reader;
- if (!reader.parse(Response, root, false))
+ if (!JsonUtils::ParseString(Response, root))
{
LOGWARNING("cAuthenticator: Cannot parse received data (authentication) to JSON!");
return false;
diff --git a/src/Protocol/CMakeLists.txt b/src/Protocol/CMakeLists.txt
index f2169ce86..0f22e531f 100644
--- a/src/Protocol/CMakeLists.txt
+++ b/src/Protocol/CMakeLists.txt
@@ -35,5 +35,5 @@ SET (HDRS
if (NOT MSVC)
add_library(Protocol ${SRCS} ${HDRS})
- target_link_libraries(Protocol fmt::fmt)
+ target_link_libraries(Protocol fmt::fmt SQLiteCpp)
endif()
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;
}
diff --git a/src/Protocol/ProtocolRecognizer.cpp b/src/Protocol/ProtocolRecognizer.cpp
index ddc1aaf93..73f8e0ff1 100644
--- a/src/Protocol/ProtocolRecognizer.cpp
+++ b/src/Protocol/ProtocolRecognizer.cpp
@@ -19,6 +19,7 @@
#include "../Server.h"
#include "../World.h"
#include "../ChatColor.h"
+#include "../JsonUtils.h"
#include "../Bindings/PluginManager.h"
@@ -1222,8 +1223,7 @@ void cProtocolRecognizer::HandlePacketStatusRequest(void)
ResponseValue["favicon"] = Printf("data:image/png;base64,%s", Favicon.c_str());
}
- Json::FastWriter Writer;
- AString Response = Writer.write(ResponseValue);
+ AString Response = JsonUtils::WriteFastString(ResponseValue);
cPacketizer Pkt(*this, pktStatusResponse);
Pkt.WriteString(Response);
diff --git a/src/Protocol/Protocol_1_10.cpp b/src/Protocol/Protocol_1_10.cpp
index 83df39a6c..1ab412839 100644
--- a/src/Protocol/Protocol_1_10.cpp
+++ b/src/Protocol/Protocol_1_10.cpp
@@ -16,6 +16,7 @@ Implements the 1.10 protocol classes:
#include "../Root.h"
#include "../Server.h"
#include "../ClientHandle.h"
+#include "../JsonUtils.h"
#include "../WorldStorage/FastNBT.h"
@@ -375,8 +376,7 @@ void cProtocol_1_10_0::HandlePacketStatusRequest(cByteBuffer & a_ByteBuffer)
ResponseValue["favicon"] = Printf("data:image/png;base64,%s", Favicon.c_str());
}
- Json::FastWriter Writer;
- AString Response = Writer.write(ResponseValue);
+ AString Response = JsonUtils::WriteFastString(ResponseValue);
cPacketizer Pkt(*this, pktStatusResponse);
Pkt.WriteString(Response);
diff --git a/src/Protocol/Protocol_1_11.cpp b/src/Protocol/Protocol_1_11.cpp
index b12b45814..785b8f271 100644
--- a/src/Protocol/Protocol_1_11.cpp
+++ b/src/Protocol/Protocol_1_11.cpp
@@ -41,6 +41,7 @@ Implements the 1.11 protocol classes:
#include "../Server.h"
#include "../ClientHandle.h"
#include "../CompositeChat.h"
+#include "../JsonUtils.h"
#include "../Bindings/PluginManager.h"
@@ -642,9 +643,8 @@ void cProtocol_1_11_0::HandlePacketStatusRequest(cByteBuffer & a_ByteBuffer)
}
// Serialize the response into a packet:
- Json::FastWriter Writer;
cPacketizer Pkt(*this, pktStatusResponse);
- Pkt.WriteString(Writer.write(ResponseValue));
+ Pkt.WriteString(JsonUtils::WriteFastString(ResponseValue));
}
@@ -1265,7 +1265,6 @@ void cProtocol_1_11_1::HandlePacketStatusRequest(cByteBuffer & a_ByteBuffer)
}
// Serialize the response into a packet:
- Json::FastWriter Writer;
cPacketizer Pkt(*this, pktStatusResponse);
- Pkt.WriteString(Writer.write(ResponseValue));
+ Pkt.WriteString(JsonUtils::WriteFastString(ResponseValue));
}
diff --git a/src/Protocol/Protocol_1_12.cpp b/src/Protocol/Protocol_1_12.cpp
index d2e7b2071..dba85435b 100644
--- a/src/Protocol/Protocol_1_12.cpp
+++ b/src/Protocol/Protocol_1_12.cpp
@@ -26,6 +26,7 @@ Implements the 1.12 protocol classes:
#include "../Server.h"
#include "../ClientHandle.h"
#include "../Bindings/PluginManager.h"
+#include "../JsonUtils.h"
@@ -361,9 +362,8 @@ void cProtocol_1_12::HandlePacketStatusRequest(cByteBuffer & a_ByteBuffer)
}
// Serialize the response into a packet:
- Json::FastWriter Writer;
cPacketizer Pkt(*this, pktStatusResponse);
- Pkt.WriteString(Writer.write(ResponseValue));
+ Pkt.WriteString(JsonUtils::WriteFastString(ResponseValue));
}
@@ -1220,9 +1220,8 @@ void cProtocol_1_12_1::HandlePacketStatusRequest(cByteBuffer & a_ByteBuffer)
}
// Serialize the response into a packet:
- Json::FastWriter Writer;
cPacketizer Pkt(*this, pktStatusResponse);
- Pkt.WriteString(Writer.write(ResponseValue));
+ Pkt.WriteString(JsonUtils::WriteFastString(ResponseValue));
}
@@ -1378,9 +1377,8 @@ void cProtocol_1_12_2::HandlePacketStatusRequest(cByteBuffer & a_ByteBuffer)
}
// Serialize the response into a packet:
- Json::FastWriter Writer;
cPacketizer Pkt(*this, pktStatusResponse);
- Pkt.WriteString(Writer.write(ResponseValue));
+ Pkt.WriteString(JsonUtils::WriteFastString(ResponseValue));
}
diff --git a/src/Protocol/Protocol_1_13.cpp b/src/Protocol/Protocol_1_13.cpp
index e7de8158d..fc048fe70 100644
--- a/src/Protocol/Protocol_1_13.cpp
+++ b/src/Protocol/Protocol_1_13.cpp
@@ -27,6 +27,7 @@ Implements the 1.13 protocol classes:
#include "../Root.h"
#include "../Server.h"
#include "../World.h"
+#include "../JsonUtils.h"
#include "../Bindings/PluginManager.h"
@@ -253,9 +254,8 @@ void cProtocol_1_13::HandlePacketStatusRequest(cByteBuffer & a_ByteBuffer)
}
// Serialize the response into a packet:
- Json::FastWriter Writer;
cPacketizer Pkt(*this, pktStatusResponse);
- Pkt.WriteString(Writer.write(ResponseValue));
+ Pkt.WriteString(JsonUtils::WriteFastString(ResponseValue));
}
diff --git a/src/Protocol/Protocol_1_8.cpp b/src/Protocol/Protocol_1_8.cpp
index cc108fb69..9f149f643 100644
--- a/src/Protocol/Protocol_1_8.cpp
+++ b/src/Protocol/Protocol_1_8.cpp
@@ -24,6 +24,7 @@ Implements the 1.8 protocol classes:
#include "../Statistics.h"
#include "../UUID.h"
#include "../World.h"
+#include "../JsonUtils.h"
#include "../WorldStorage/FastNBT.h"
#include "../WorldStorage/EnchantmentSerializer.h"
@@ -138,8 +139,7 @@ cProtocol_1_8_0::cProtocol_1_8_0(cClientHandle * a_Client, const AString & a_Ser
m_Client->SetUUID(UUID);
Json::Value root;
- Json::Reader reader;
- if (!reader.parse(Params[3], root))
+ if (!JsonUtils::ParseString(Params[3], root))
{
LOGERROR("Unable to parse player properties: '%s'", Params[3]);
}
@@ -1561,13 +1561,12 @@ void cProtocol_1_8_0::SendUpdateSign(int a_BlockX, int a_BlockY, int a_BlockZ, c
cPacketizer Pkt(*this, pktUpdateSign);
Pkt.WritePosition64(a_BlockX, a_BlockY, a_BlockZ);
- Json::StyledWriter JsonWriter;
AString Lines[] = { a_Line1, a_Line2, a_Line3, a_Line4 };
for (size_t i = 0; i < ARRAYCOUNT(Lines); i++)
{
Json::Value RootValue;
RootValue["text"] = Lines[i];
- Pkt.WriteString(JsonWriter.write(RootValue).c_str());
+ Pkt.WriteString(JsonUtils::WriteFastString(RootValue));
}
}
@@ -2275,8 +2274,7 @@ void cProtocol_1_8_0::HandlePacketStatusRequest(cByteBuffer & a_ByteBuffer)
ResponseValue["favicon"] = Printf("data:image/png;base64,%s", Favicon.c_str());
}
- Json::FastWriter Writer;
- AString Response = Writer.write(ResponseValue);
+ auto Response = JsonUtils::WriteFastString(ResponseValue);
cPacketizer Pkt(*this, pktStatusResponse);
Pkt.WriteString(Response);
@@ -2741,11 +2739,10 @@ void cProtocol_1_8_0::HandlePacketUpdateSign(cByteBuffer & a_ByteBuffer)
AString Lines[4];
Json::Value root;
- Json::Reader reader;
for (int i = 0; i < 4; i++)
{
HANDLE_READ(a_ByteBuffer, ReadVarUTF8String, AString, Line);
- if (reader.parse(Line, root, false))
+ if (JsonUtils::ParseString(Line, root))
{
Lines[i] = root.asString();
}
diff --git a/src/Protocol/Protocol_1_9.cpp b/src/Protocol/Protocol_1_9.cpp
index ff62df242..49d5e876b 100644
--- a/src/Protocol/Protocol_1_9.cpp
+++ b/src/Protocol/Protocol_1_9.cpp
@@ -27,7 +27,7 @@ Implements the 1.9 protocol classes:
#include "../StringCompression.h"
#include "../CompositeChat.h"
#include "../Statistics.h"
-#include "../World.h"
+#include "../JsonUtils.h"
#include "../WorldStorage/FastNBT.h"
@@ -702,8 +702,7 @@ void cProtocol_1_9_0::HandlePacketStatusRequest(cByteBuffer & a_ByteBuffer)
ResponseValue["favicon"] = Printf("data:image/png;base64,%s", Favicon.c_str());
}
- Json::FastWriter Writer;
- AString Response = Writer.write(ResponseValue);
+ auto Response = JsonUtils::WriteFastString(ResponseValue);
cPacketizer Pkt(*this, pktStatusResponse);
Pkt.WriteString(Response);
@@ -2281,8 +2280,7 @@ void cProtocol_1_9_1::HandlePacketStatusRequest(cByteBuffer & a_ByteBuffer)
ResponseValue["favicon"] = Printf("data:image/png;base64,%s", Favicon.c_str());
}
- Json::FastWriter Writer;
- AString Response = Writer.write(ResponseValue);
+ AString Response = JsonUtils::WriteFastString(ResponseValue);
cPacketizer Pkt(*this, pktStatusResponse);
Pkt.WriteString(Response);
@@ -2339,8 +2337,7 @@ void cProtocol_1_9_2::HandlePacketStatusRequest(cByteBuffer & a_ByteBuffer)
ResponseValue["favicon"] = Printf("data:image/png;base64,%s", Favicon.c_str());
}
- Json::FastWriter Writer;
- AString Response = Writer.write(ResponseValue);
+ AString Response = JsonUtils::WriteFastString(ResponseValue);
cPacketizer Pkt(*this, pktStatusResponse);
Pkt.WriteString(Response);
@@ -2397,8 +2394,7 @@ void cProtocol_1_9_4::HandlePacketStatusRequest(cByteBuffer & a_ByteBuffer)
ResponseValue["favicon"] = Printf("data:image/png;base64,%s", Favicon.c_str());
}
- Json::FastWriter Writer;
- AString Response = Writer.write(ResponseValue);
+ AString Response = JsonUtils::WriteFastString(ResponseValue);
cPacketizer Pkt(*this, pktStatusResponse);
Pkt.WriteString(Response);
@@ -2439,19 +2435,18 @@ void cProtocol_1_9_4::SendUpdateSign(int a_BlockX, int a_BlockY, int a_BlockZ, c
Writer.AddInt("z", a_BlockZ);
Writer.AddString("id", "Sign");
- Json::StyledWriter JsonWriter;
Json::Value Line1;
Line1["text"] = a_Line1;
- Writer.AddString("Text1", JsonWriter.write(Line1));
+ Writer.AddString("Text1", JsonUtils::WriteFastString(Line1));
Json::Value Line2;
Line2["text"] = a_Line2;
- Writer.AddString("Text2", JsonWriter.write(Line2));
+ Writer.AddString("Text2", JsonUtils::WriteFastString(Line2));
Json::Value Line3;
Line3["text"] = a_Line3;
- Writer.AddString("Text3", JsonWriter.write(Line3));
+ Writer.AddString("Text3", JsonUtils::WriteFastString(Line3));
Json::Value Line4;
Line4["text"] = a_Line4;
- Writer.AddString("Text4", JsonWriter.write(Line4));
+ Writer.AddString("Text4", JsonUtils::WriteFastString(Line4));
Writer.Finish();
Pkt.WriteBuf(Writer.GetResult().data(), Writer.GetResult().size());
diff --git a/src/RankManager.cpp b/src/RankManager.cpp
index f4f594c17..1f90f6aae 100644
--- a/src/RankManager.cpp
+++ b/src/RankManager.cpp
@@ -16,7 +16,7 @@
// cRankManager:
cRankManager::cRankManager(void) :
- m_DB("Ranks.sqlite", SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE),
+ m_DB("Ranks.sqlite", SQLite::OPEN_READWRITE | SQLite::OPEN_CREATE),
m_IsInitialized(false),
m_MojangAPI(nullptr)
{
diff --git a/src/Simulator/CMakeLists.txt b/src/Simulator/CMakeLists.txt
index c8514d91d..a8efc988c 100644
--- a/src/Simulator/CMakeLists.txt
+++ b/src/Simulator/CMakeLists.txt
@@ -28,5 +28,5 @@ SET (HDRS
if(NOT MSVC)
add_library(Simulator ${SRCS} ${HDRS})
- target_link_libraries(Simulator fmt::fmt)
+ target_link_libraries(Simulator fmt::fmt SQLiteCpp)
endif()
diff --git a/src/UI/CMakeLists.txt b/src/UI/CMakeLists.txt
index 28a99b6ed..16c70f6fe 100644
--- a/src/UI/CMakeLists.txt
+++ b/src/UI/CMakeLists.txt
@@ -35,5 +35,5 @@ SET (HDRS
if(NOT MSVC)
add_library(UI ${SRCS} ${HDRS})
- target_link_libraries(UI fmt::fmt)
+ target_link_libraries(UI fmt::fmt SQLiteCpp)
endif()
diff --git a/src/WorldStorage/CMakeLists.txt b/src/WorldStorage/CMakeLists.txt
index a0875e351..341d88e68 100644
--- a/src/WorldStorage/CMakeLists.txt
+++ b/src/WorldStorage/CMakeLists.txt
@@ -27,5 +27,5 @@ SET (HDRS
if(NOT MSVC)
add_library(WorldStorage ${SRCS} ${HDRS})
- target_link_libraries(WorldStorage fmt::fmt OSSupport)
+ target_link_libraries(WorldStorage fmt::fmt OSSupport SQLiteCpp)
endif()
diff --git a/src/WorldStorage/StatSerializer.cpp b/src/WorldStorage/StatSerializer.cpp
index 2bc4b783f..b9f188c11 100644
--- a/src/WorldStorage/StatSerializer.cpp
+++ b/src/WorldStorage/StatSerializer.cpp
@@ -6,6 +6,7 @@
#include "StatSerializer.h"
#include "../Statistics.h"
+#include "../JsonUtils.h"
@@ -44,9 +45,8 @@ bool cStatSerializer::Load(void)
}
Json::Value Root;
- Json::Reader Reader;
- if (Reader.parse(Data, Root, false))
+ if (JsonUtils::ParseString(Data, Root))
{
return LoadStatFromJSON(Root);
}
@@ -69,8 +69,7 @@ bool cStatSerializer::Save(void)
return false;
}
- Json::StyledWriter Writer;
- AString JsonData = Writer.write(Root);
+ AString JsonData = JsonUtils::WriteStyledString(Root);
File.Write(JsonData.data(), JsonData.size());
File.Close();
diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp
index 22564248a..060d1f4df 100755
--- a/src/WorldStorage/WSSAnvil.cpp
+++ b/src/WorldStorage/WSSAnvil.cpp
@@ -16,6 +16,7 @@
#include "../SetChunkData.h"
#include "../Root.h"
#include "../BlockType.h"
+#include "../JsonUtils.h"
#include "../BlockEntities/BeaconEntity.h"
#include "../BlockEntities/BedEntity.h"
@@ -830,8 +831,7 @@ AString cWSSAnvil::DecodeSignLine(const AString & a_Line)
// Try to parse the JSON:
Json::Value root;
- Json::Reader reader;
- if (!reader.parse(a_Line, root, false) || !root.isObject())
+ if (!JsonUtils::ParseString(a_Line, root) || !root.isObject())
{
return a_Line;
}
diff --git a/tests/BlockTypeRegistry/CMakeLists.txt b/tests/BlockTypeRegistry/CMakeLists.txt
index 8118bc93c..1b2749722 100644
--- a/tests/BlockTypeRegistry/CMakeLists.txt
+++ b/tests/BlockTypeRegistry/CMakeLists.txt
@@ -26,11 +26,12 @@ add_executable(BlockTypePaletteTest
../TestHelpers.h
${CMAKE_SOURCE_DIR}/src/BlockState.cpp
${CMAKE_SOURCE_DIR}/src/BlockTypePalette.cpp
+ ${CMAKE_SOURCE_DIR}/src/JsonUtils.cpp
${CMAKE_SOURCE_DIR}/src/StringUtils.cpp
${CMAKE_SOURCE_DIR}/src/OSSupport/CriticalSection.cpp
${CMAKE_SOURCE_DIR}/src/OSSupport/File.cpp
)
-target_link_libraries(BlockTypePaletteTest fmt::fmt jsoncpp_lib_static)
+target_link_libraries(BlockTypePaletteTest fmt::fmt jsoncpp_lib)
# BlockTypeRegistryTest: Verify that the BlockTypeRegistry class works as intended:
add_executable(BlockTypeRegistryTest
@@ -50,11 +51,12 @@ add_executable(PalettedBlockAreaTest
${CMAKE_SOURCE_DIR}/src/BlockTypeRegistry.cpp
${CMAKE_SOURCE_DIR}/src/BlockTypePalette.cpp
${CMAKE_SOURCE_DIR}/src/Cuboid.cpp
+ ${CMAKE_SOURCE_DIR}/src/JsonUtils.cpp
${CMAKE_SOURCE_DIR}/src/PalettedBlockArea.cpp
${CMAKE_SOURCE_DIR}/src/StringUtils.cpp
${CMAKE_SOURCE_DIR}/src/OSSupport/CriticalSection.cpp
)
-target_link_libraries(PalettedBlockAreaTest fmt::fmt jsoncpp_lib_static)
+target_link_libraries(PalettedBlockAreaTest fmt::fmt jsoncpp_lib)
# Extra files for BlockTypePalette test:
file (COPY
diff --git a/tests/CompositeChat/CMakeLists.txt b/tests/CompositeChat/CMakeLists.txt
index 03a100d91..626a146f8 100644
--- a/tests/CompositeChat/CMakeLists.txt
+++ b/tests/CompositeChat/CMakeLists.txt
@@ -10,12 +10,14 @@ add_definitions(-DTEST_GLOBALS=1)
set (SHARED_SRCS
${CMAKE_SOURCE_DIR}/src/CompositeChat.cpp
+ ${CMAKE_SOURCE_DIR}/src/JsonUtils.cpp
${CMAKE_SOURCE_DIR}/src/StringUtils.cpp
)
set (SHARED_HDRS
../TestHelpers.h
${CMAKE_SOURCE_DIR}/src/CompositeChat.h
+ ${CMAKE_SOURCE_DIR}/src/JsonUtils.h
${CMAKE_SOURCE_DIR}/src/StringUtils.h
)
@@ -28,7 +30,7 @@ set (SRCS
source_group("Shared" FILES ${SHARED_SRCS} ${SHARED_HDRS})
source_group("Sources" FILES ${SRCS})
add_executable(CompositeChat-exe ${SRCS} ${SHARED_SRCS} ${SHARED_HDRS})
-target_link_libraries(CompositeChat-exe jsoncpp_lib_static fmt::fmt)
+target_link_libraries(CompositeChat-exe jsoncpp_lib fmt::fmt)
add_test(NAME CompositeChat-test COMMAND CompositeChat-exe)
diff --git a/tests/Generating/CMakeLists.txt b/tests/Generating/CMakeLists.txt
index cf8e2faa0..b7ce70e13 100644
--- a/tests/Generating/CMakeLists.txt
+++ b/tests/Generating/CMakeLists.txt
@@ -161,7 +161,7 @@ add_library(GeneratorTestingSupport STATIC
${GENERATING_HDRS}
${STUBS}
)
-target_link_libraries(GeneratorTestingSupport tolualib zlib fmt::fmt jsoncpp_lib_static)
+target_link_libraries(GeneratorTestingSupport tolualib zlib fmt::fmt jsoncpp_lib)
source_group("Stubs" FILES ${STUBS})
source_group("Generating" FILES ${GENERATING_HDRS} ${GENERATING_SRCS})