From 7f6b09dce82be5c2a881c075ca76c5ac8f84ad52 Mon Sep 17 00:00:00 2001 From: Desour Date: Sat, 25 Mar 2023 19:48:50 +0100 Subject: [PATCH] Use json forward-declarations --- src/client/client.cpp | 1 + src/cmake_config.h.in | 1 + src/content/mods.h | 2 +- src/convert_json.cpp | 6 ++++-- src/convert_json.h | 2 +- src/database/database-files.cpp | 4 ++-- src/database/database-files.h | 2 +- src/json-forwards.h | 31 +++++++++++++++++++++++++++++++ src/serverenvironment.cpp | 1 + src/serverlist.h | 4 ++-- src/tool.cpp | 1 + src/tool.h | 2 +- 12 files changed, 47 insertions(+), 10 deletions(-) create mode 100644 src/json-forwards.h diff --git a/src/client/client.cpp b/src/client/client.cpp index b2d71d057..763feecd5 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -22,6 +22,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include #include #include +#include #include "client.h" #include "network/clientopcodes.h" #include "network/connection.h" diff --git a/src/cmake_config.h.in b/src/cmake_config.h.in index 19fb6d4a1..b52d6fa8e 100644 --- a/src/cmake_config.h.in +++ b/src/cmake_config.h.in @@ -27,6 +27,7 @@ #cmakedefine01 USE_PROMETHEUS #cmakedefine01 USE_SPATIAL #cmakedefine01 USE_SYSTEM_GMP +#cmakedefine01 USE_SYSTEM_JSONCPP #cmakedefine01 USE_REDIS #cmakedefine01 HAVE_ENDIAN_H #cmakedefine01 CURSES_HAVE_CURSES_H diff --git a/src/content/mods.h b/src/content/mods.h index fb714ca75..ce844397a 100644 --- a/src/content/mods.h +++ b/src/content/mods.h @@ -25,7 +25,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include #include #include -#include +#include "json-forwards.h" #include #include "util/basic_macros.h" #include "config.h" diff --git a/src/convert_json.cpp b/src/convert_json.cpp index 686113fa8..2e169c8b9 100644 --- a/src/convert_json.cpp +++ b/src/convert_json.cpp @@ -17,12 +17,14 @@ with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include "convert_json.h" + +#include + #include #include #include -#include "convert_json.h" - void fastWriteJson(const Json::Value &value, std::ostream &to) { Json::StreamWriterBuilder builder; diff --git a/src/convert_json.h b/src/convert_json.h index d1d487e77..fdc68ccee 100644 --- a/src/convert_json.h +++ b/src/convert_json.h @@ -19,7 +19,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #pragma once -#include +#include "json-forwards.h" #include void fastWriteJson(const Json::Value &value, std::ostream &to); diff --git a/src/database/database-files.cpp b/src/database/database-files.cpp index 5b41f6c19..4357b5ea4 100644 --- a/src/database/database-files.cpp +++ b/src/database/database-files.cpp @@ -17,15 +17,15 @@ with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include -#include "convert_json.h" #include "database-files.h" +#include "convert_json.h" #include "remoteplayer.h" #include "settings.h" #include "porting.h" #include "filesys.h" #include "server/player_sao.h" #include "util/string.h" +#include // !!! WARNING !!! // This backend is intended to be used on Minetest 0.4.16 only for the transition backend diff --git a/src/database/database-files.h b/src/database/database-files.h index 09116b2b4..61a8fd9a2 100644 --- a/src/database/database-files.h +++ b/src/database/database-files.h @@ -26,7 +26,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "database.h" #include #include -#include +#include // for Json::Value class PlayerDatabaseFiles : public PlayerDatabase { diff --git a/src/json-forwards.h b/src/json-forwards.h new file mode 100644 index 000000000..f2c9c9c9e --- /dev/null +++ b/src/json-forwards.h @@ -0,0 +1,31 @@ +/* +Minetest +Copyright (C) 2023 DS + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along +with this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#pragma once + +#include "config.h" + +#if USE_SYSTEM_JSONCPP +#include +#include +#include +#include +#else +#include +#endif diff --git a/src/serverenvironment.cpp b/src/serverenvironment.cpp index b01b4cebd..bb0ef41c4 100644 --- a/src/serverenvironment.cpp +++ b/src/serverenvironment.cpp @@ -18,6 +18,7 @@ with this program; if not, write to the Free Software Foundation, Inc., */ #include +#include #include "serverenvironment.h" #include "settings.h" #include "log.h" diff --git a/src/serverlist.h b/src/serverlist.h index 4a0bd5efa..1466eeaf6 100644 --- a/src/serverlist.h +++ b/src/serverlist.h @@ -17,10 +17,10 @@ with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include #include "config.h" #include "content/mods.h" -#include +#include "json-forwards.h" +#include #pragma once diff --git a/src/tool.cpp b/src/tool.cpp index 8b5db095f..220df24ac 100644 --- a/src/tool.cpp +++ b/src/tool.cpp @@ -26,6 +26,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "convert_json.h" #include "util/serialize.h" #include "util/numeric.h" +#include void ToolGroupCap::toJson(Json::Value &object) const { diff --git a/src/tool.h b/src/tool.h index c2444a834..8a22fca7b 100644 --- a/src/tool.h +++ b/src/tool.h @@ -23,7 +23,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include #include #include "itemgroup.h" -#include +#include "json-forwards.h" struct ItemDefinition;