浏览代码

Remove old boost includes and defines

Ivan Savenko 7 月之前
父节点
当前提交
7a3e1409d0

+ 2 - 23
Global.h

@@ -150,43 +150,22 @@ static_assert(sizeof(bool) == 1, "Bool needs to be 1 byte in size.");
 // For versions TBB 2021.7 and later this define is not required
 #define TBB_PREVIEW_TASK_GROUP_EXTENSIONS 1
 
-//The only available version is 3, as of Boost 1.50
 #include <boost/version.hpp>
 
+// As of Boost 1.50+, the only available version is 3,
+// Version 4 has been added in Boost 1.77
 #define BOOST_FILESYSTEM_VERSION 3
-#if BOOST_VERSION > 105000
-#  define BOOST_THREAD_VERSION 3
-#endif
 #if BOOST_VERSION == 107400
 #  define BOOST_ALLOW_DEPRECATED_HEADERS
 #endif
-#define BOOST_THREAD_DONT_PROVIDE_THREAD_DESTRUCTOR_CALLS_TERMINATE_IF_JOINABLE 1
-//need to link boost thread dynamically to avoid https://stackoverflow.com/questions/35978572/boost-thread-interupt-does-not-work-when-crossing-a-dll-boundary
-//for example VCAI::finish() may freeze on thread join after interrupt when linking this statically
-#ifndef BOOST_THREAD_USE_DLL
-#  define BOOST_THREAD_USE_DLL
-#endif
-#define BOOST_BIND_NO_PLACEHOLDERS
-
-#if BOOST_VERSION >= 106600
-#define BOOST_ASIO_ENABLE_OLD_SERVICES
-#endif
 
-#include <boost/algorithm/hex.hpp>
 #include <boost/algorithm/string.hpp>
-#include <boost/crc.hpp>
-#include <boost/current_function.hpp>
 #include <boost/container/small_vector.hpp>
 #include <boost/container/static_vector.hpp>
 #include <boost/filesystem.hpp>
 #include <boost/filesystem/fstream.hpp>
 #include <boost/filesystem/path.hpp>
 #include <boost/format.hpp>
-#include <boost/functional/hash.hpp>
-#include <boost/lexical_cast.hpp>
-#ifdef VCMI_WINDOWS
-#include <boost/locale/generator.hpp>
-#endif
 #include <boost/logic/tribool.hpp>
 #include <boost/multi_array.hpp>
 #include <boost/range/adaptor/filtered.hpp>

+ 2 - 0
client/CPlayerInterface.cpp

@@ -108,6 +108,8 @@
 
 #include "../lib/texts/TextOperations.h"
 
+#include <boost/lexical_cast.hpp>
+
 // The macro below is used to mark functions that are called by client when game state changes.
 // They all assume that interface mutex is locked.
 #define EVENT_HANDLER_CALLED_BY_CLIENT

+ 2 - 0
client/CServerHandler.cpp

@@ -58,6 +58,8 @@
 
 #include <vcmi/events/EventBus.h>
 
+#include <boost/lexical_cast.hpp>
+
 CServerHandler::~CServerHandler()
 {
 	if (serverRunner)

+ 2 - 0
client/mainmenu/CMainMenu.cpp

@@ -62,6 +62,8 @@
 #include "../../lib/GameLibrary.h"
 #include "../../lib/json/JsonUtils.h"
 
+#include <boost/lexical_cast.hpp>
+
 ISelectionScreenInfo * SEL = nullptr;
 
 CMenuScreen::CMenuScreen(const JsonNode & configNode)

+ 2 - 0
client/render/Colors.cpp

@@ -13,6 +13,8 @@
 
 #include "../../lib/json/JsonNode.h"
 
+#include <boost/algorithm/hex.hpp>
+
 const ColorRGBA Colors::YELLOW = { 229, 215, 123, ColorRGBA::ALPHA_OPAQUE };
 const ColorRGBA Colors::WHITE = { 255, 243, 222, ColorRGBA::ALPHA_OPAQUE };
 const ColorRGBA Colors::WHITE_TRUE = { 255, 255, 255, ColorRGBA::ALPHA_OPAQUE };

+ 2 - 0
client/widgets/CTextInput.cpp

@@ -22,6 +22,8 @@
 
 #include "../../lib/texts/TextOperations.h"
 
+#include <boost/lexical_cast.hpp>
+
 std::list<CFocusable *> CFocusable::focusables;
 CFocusable * CFocusable::inputWithFocus;
 

+ 2 - 0
client/windows/GUIClasses.cpp

@@ -64,6 +64,8 @@
 #include "../lib/CSkillHandler.h"
 #include "../lib/CSoundBase.h"
 
+#include <boost/lexical_cast.hpp>
+
 CRecruitmentWindow::CCreatureCard::CCreatureCard(CRecruitmentWindow * window, const CCreature * crea, int totalAmount)
 	: CIntObject(LCLICK | SHOW_POPUP),
 	parent(window),

+ 2 - 2
lib/CRandomGenerator.cpp

@@ -34,8 +34,8 @@ void CRandomGenerator::setSeed(int seed)
 void CRandomGenerator::resetSeed()
 {
 	logRng->trace("CRandomGenerator::resetSeed");
-	boost::hash<std::string> stringHash;
-	auto threadIdHash = stringHash(boost::lexical_cast<std::string>(std::this_thread::get_id()));
+	std::hash<std::thread::id> hasher;
+	auto threadIdHash = hasher(std::this_thread::get_id());
 	setSeed(static_cast<int>(threadIdHash * std::time(nullptr)));
 }
 

+ 1 - 0
lib/CThreadHelper.cpp

@@ -20,6 +20,7 @@
 #endif
 
 #include <tbb/task_arena.h>
+#include <boost/lexical_cast.hpp>
 
 VCMI_LIB_NAMESPACE_BEGIN
 

+ 2 - 0
lib/filesystem/CInputStream.h

@@ -11,6 +11,8 @@
 
 #include "CStream.h"
 
+#include <boost/crc.hpp>
+
 VCMI_LIB_NAMESPACE_BEGIN
 
 /**

+ 2 - 0
lib/json/JsonNode.cpp

@@ -15,6 +15,8 @@
 #include "JsonWriter.h"
 #include "filesystem/Filesystem.h"
 
+#include <boost/lexical_cast.hpp>
+
 // to avoid duplicating const and non-const code
 template<typename Node>
 Node & resolvePointer(Node & in, const std::string & pointer)

+ 2 - 0
lib/mapObjects/ObjectTemplate.cpp

@@ -21,6 +21,8 @@
 #include "../mapObjectConstructors/CRewardableConstructor.h"
 #include "../modding/IdentifierStorage.h"
 
+#include <boost/lexical_cast.hpp>
+
 VCMI_LIB_NAMESPACE_BEGIN
 
 static bool isOnVisitableFromTopList(Obj identifier, int type)

+ 2 - 0
lib/mapping/MapEditUtils.cpp

@@ -17,6 +17,8 @@
 #include "CMap.h"
 #include "CMapOperation.h"
 
+#include <boost/lexical_cast.hpp>
+
 VCMI_LIB_NAMESPACE_BEGIN
 
 MapRect::MapRect() : x(0), y(0), z(0), width(0), height(0)

+ 1 - 1
lib/network/NetworkDefines.h

@@ -15,7 +15,7 @@
 
 VCMI_LIB_NAMESPACE_BEGIN
 
-#if BOOST_VERSION >= 108700
+#if BOOST_VERSION >= 106600
 using NetworkContext = boost::asio::io_context;
 #else
 using NetworkContext = boost::asio::io_service;

+ 3 - 0
lib/rmg/CRmgTemplate.cpp

@@ -21,6 +21,9 @@
 #include "../modding/ModScope.h"
 #include "../serializer/JsonSerializeFormat.h"
 
+#include <boost/lexical_cast.hpp>
+
+
 VCMI_LIB_NAMESPACE_BEGIN
 
 namespace

+ 4 - 3
lib/texts/TextOperations.cpp

@@ -317,10 +317,11 @@ DLL_LINKAGE bool TextOperations::compareLocalizedStrings(std::string_view str1,
 
 std::optional<int> TextOperations::textSearchSimilarityScore(const std::string & s, const std::string & t)
 {
-	static const std::locale loc = boost::locale::generator().generate(getLocaleName());
+	static const std::locale loc(getLocaleName());
+	static const std::collate<char> & col = std::use_facet<std::collate<char>>(loc);
 
-	auto haystack = boost::locale::to_lower(t, loc);
-	auto needle = boost::locale::to_lower(s, loc);
+	auto haystack = col.transform(t.data(), t.data() + t.size());
+	auto needle = col.transform(s.data(), s.data() + s.size());
 
 	// 0 - Best possible match: text starts with the search string
 	if(haystack.rfind(needle, 0) == 0)

+ 2 - 0
server/CGameHandler.cpp

@@ -88,6 +88,8 @@
 #include <vcmi/events/GenericEvents.h>
 #include <vcmi/events/AdventureEvents.h>
 
+#include <boost/lexical_cast.hpp>
+
 #define COMPLAIN_RET_IF(cond, txt) do {if (cond){complain(txt); return;}} while(0)
 #define COMPLAIN_RET_FALSE_IF(cond, txt) do {if (cond){complain(txt); return false;}} while(0)
 #define COMPLAIN_RET(txt) {complain(txt); return false;}

+ 2 - 0
server/battles/BattleResultProcessor.cpp

@@ -31,6 +31,8 @@
 
 #include <vstd/RNG.h>
 
+#include <boost/lexical_cast.hpp>
+
 BattleResultProcessor::BattleResultProcessor(BattleProcessor * owner, CGameHandler * newGameHandler)
 //	: owner(owner)
 	: gameHandler(newGameHandler)