diff options
| author | Eblo <7004497+Eblo@users.noreply.github.com> | 2025-10-26 11:34:29 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-10-26 11:34:29 -0400 |
| commit | fb5064a0607b80b3b7ab28336d80485a71f92e05 (patch) | |
| tree | 09c8e01d2befe7f39725bf1cbcecc07aafbf8784 | |
| parent | e180e4666c06dc0d75d9d4bd247815184b9317cc (diff) | |
Remove boost dependency (#1298)
* Remove boost dependency
* Convert check pools to vectors
* Convert checks and region collections to ordered
| -rw-r--r-- | Dockerfile | 1 | ||||
| -rw-r--r-- | docs/BUILDING.md | 12 | ||||
| -rw-r--r-- | mm/2s2h/Rando/Logic/FrenchVanilla.cpp | 7 | ||||
| -rw-r--r-- | mm/2s2h/Rando/Logic/GlitchlessLogic.cpp | 14 | ||||
| -rw-r--r-- | mm/2s2h/Rando/Logic/Logic.cpp | 4 | ||||
| -rw-r--r-- | mm/2s2h/Rando/Logic/Logic.h | 20 | ||||
| -rw-r--r-- | mm/2s2h/Rando/Logic/NearlyNoLogic.cpp | 9 | ||||
| -rw-r--r-- | mm/2s2h/Rando/Logic/NoLogic.cpp | 6 | ||||
| -rw-r--r-- | mm/2s2h/Rando/MiscBehavior/OnFileCreate.cpp | 12 | ||||
| -rw-r--r-- | mm/2s2h/Rando/StaticData/StaticData.h | 4 | ||||
| -rw-r--r-- | mm/2s2h/ShipUtils.cpp | 49 | ||||
| -rw-r--r-- | mm/2s2h/ShipUtils.h | 3 | ||||
| -rw-r--r-- | mm/CMakeLists.txt | 27 | ||||
| -rw-r--r-- | mm/include/boost_custom/container_hash/detail/hash_mix_32.hpp | 47 | ||||
| -rw-r--r-- | mm/include/boost_custom/container_hash/detail/hash_range_32.hpp | 128 | ||||
| -rw-r--r-- | mm/include/boost_custom/container_hash/hash_32.hpp | 188 | ||||
| -rw-r--r-- | mm/include/boost_custom/container_hash/hash_fwd_32.hpp | 25 | ||||
| -rw-r--r-- | mm/include/boost_custom/container_hash/version.hpp | 11 |
18 files changed, 83 insertions, 484 deletions
diff --git a/Dockerfile b/Dockerfile index 6e7477887..e9be1601a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,7 +23,6 @@ RUN apt-get install -y \ zlib1g-dev:i386 \ libbz2-dev:i386 \ libpng-dev:i386 \ - libboost-dev:i386 \ libgles2-mesa-dev RUN apt-get install -y \ diff --git a/docs/BUILDING.md b/docs/BUILDING.md index 34775cdd2..e81cb5478 100644 --- a/docs/BUILDING.md +++ b/docs/BUILDING.md @@ -89,26 +89,26 @@ C:\Program Files\CMake\bin\cmake.exe --build build-cmake --target ExtractAssetHe #### Debian/Ubuntu ```sh # using gcc -apt-get install gcc g++ git cmake ninja-build lsb-release libsdl2-dev libpng-dev libsdl2-net-dev libzip-dev zipcmp zipmerge ziptool nlohmann-json3-dev libtinyxml2-dev libspdlog-dev libboost-dev libopengl-dev +apt-get install gcc g++ git cmake ninja-build lsb-release libsdl2-dev libpng-dev libsdl2-net-dev libzip-dev zipcmp zipmerge ziptool nlohmann-json3-dev libtinyxml2-dev libspdlog-dev libopengl-dev # or using clang -apt-get install clang git cmake ninja-build lsb-release libsdl2-dev libpng-dev libsdl2-net-dev libzip-dev zipcmp zipmerge ziptool nlohmann-json3-dev libtinyxml2-dev libspdlog-dev libboost-dev libopengl-dev +apt-get install clang git cmake ninja-build lsb-release libsdl2-dev libpng-dev libsdl2-net-dev libzip-dev zipcmp zipmerge ziptool nlohmann-json3-dev libtinyxml2-dev libspdlog-dev libopengl-dev ``` #### Arch ```sh # using gcc -pacman -S gcc git cmake ninja lsb-release sdl2 libpng libzip nlohmann-json tinyxml2 spdlog sdl2_net boost +pacman -S gcc git cmake ninja lsb-release sdl2 libpng libzip nlohmann-json tinyxml2 spdlog sdl2_net # or using clang -pacman -S clang git cmake ninja lsb-release sdl2 libpng libzip nlohmann-json tinyxml2 spdlog sdl2_net boost +pacman -S clang git cmake ninja lsb-release sdl2 libpng libzip nlohmann-json tinyxml2 spdlog sdl2_net ``` #### Fedora ```sh # using gcc -dnf install gcc gcc-c++ git cmake ninja-build lsb_release SDL2-devel libpng-devel libzip-devel libzip-tools nlohmann-json-devel tinyxml2-devel spdlog-devel boost-devel +dnf install gcc gcc-c++ git cmake ninja-build lsb_release SDL2-devel libpng-devel libzip-devel libzip-tools nlohmann-json-devel tinyxml2-devel spdlog-devel # or using clang -dnf install clang git cmake ninja-build lsb_release SDL2-devel libpng-devel libzip-devel libzip-tools nlohmann-json-devel tinyxml2-devel spdlog-devel boost-devel +dnf install clang git cmake ninja-build lsb_release SDL2-devel libpng-devel libzip-devel libzip-tools nlohmann-json-devel tinyxml2-devel spdlog-devel ``` #### openSUSE ```sh diff --git a/mm/2s2h/Rando/Logic/FrenchVanilla.cpp b/mm/2s2h/Rando/Logic/FrenchVanilla.cpp index 328163694..621e8dee3 100644 --- a/mm/2s2h/Rando/Logic/FrenchVanilla.cpp +++ b/mm/2s2h/Rando/Logic/FrenchVanilla.cpp @@ -29,14 +29,13 @@ struct RandoPoolPlacement { RandoItemId placedItemId; }; -void ApplyFrenchVanillaLogicToSaveContext(std::unordered_map<RandoCheckId, bool>& checkPool, - std::vector<RandoItemId>& itemPool) { +void ApplyFrenchVanillaLogicToSaveContext(std::vector<RandoCheckId>& checkPool, std::vector<RandoItemId>& itemPool) { uint64_t tick = GetUnixTimestamp(); std::set<RandoCheckId> allChecksThatAreInLogic; std::set<RandoCheckId> allChecksThatHaveBeenReachedAtLeastOnce; // Used across all iterations - std::unordered_map<RandoCheckId, RandoPoolEntry> currentCheckPool; + std::map<RandoCheckId, RandoPoolEntry> currentCheckPool; std::set<RandoRegionId> currentReachableRegions = { RR_MAX }; std::set<std::pair<RandoEvent, std::function<bool()>>*> currentEventsTriggered; @@ -56,7 +55,7 @@ void ApplyFrenchVanillaLogicToSaveContext(std::unordered_map<RandoCheckId, bool> for (auto& [randoRegionId, randoRegion] : Rando::Logic::Regions) { for (auto& [randoCheckId, _] : randoRegion.checks) { auto& randoStaticCheck = Rando::StaticData::Checks[randoCheckId]; - bool isShuffled = checkPool.find(randoCheckId) != checkPool.end(); + bool isShuffled = std::find(checkPool.begin(), checkPool.end(), randoCheckId) != checkPool.end(); allChecksThatAreInLogic.insert(randoCheckId); currentCheckPool[randoCheckId] = { diff --git a/mm/2s2h/Rando/Logic/GlitchlessLogic.cpp b/mm/2s2h/Rando/Logic/GlitchlessLogic.cpp index 338733c4e..940fe3ad6 100644 --- a/mm/2s2h/Rando/Logic/GlitchlessLogic.cpp +++ b/mm/2s2h/Rando/Logic/GlitchlessLogic.cpp @@ -15,15 +15,14 @@ namespace Rando { namespace Logic { -void ApplyGlitchlessLogicToSaveContext(std::unordered_map<RandoCheckId, bool>& checkPool, - std::vector<RandoItemId>& itemPool) { +void ApplyGlitchlessLogicToSaveContext(std::vector<RandoCheckId>& checkPool, std::vector<RandoItemId>& itemPool) { uint64_t tick = GetUnixTimestamp(); SaveContext copiedSaveContext; memcpy(&copiedSaveContext, &gSaveContext, sizeof(SaveContext)); std::set<RandoRegionId> regionsInLogic = { RR_MAX }; - std::unordered_map<RandoCheckId, bool> checksInLogic; + std::map<RandoCheckId, bool> checksInLogic; std::set<std::pair<RandoEvent, std::function<bool()>>*> eventsInLogic; RandoCheckId checkWithJunk = RC_UNKNOWN; @@ -44,7 +43,7 @@ void ApplyGlitchlessLogicToSaveContext(std::unordered_map<RandoCheckId, bool>& c SPDLOG_ERROR("Items/Checks: {}/{}", itemPool.size(), checkPool.size()); // Log out the checks that are still in the pool - for (auto& [randoCheckId, _] : checkPool) { + for (auto& randoCheckId : checkPool) { SPDLOG_ERROR("Check still in pool: {}", Rando::StaticData::Checks[randoCheckId].name); } // Log out the items that are still in the pool @@ -90,9 +89,12 @@ void ApplyGlitchlessLogicToSaveContext(std::unordered_map<RandoCheckId, bool>& c // Apply any new checks for (auto& [randoCheckId, checkLogic] : randoRegion.checks) { if (checksInLogic.find(randoCheckId) == checksInLogic.end() && checkLogic.first()) { - bool isShuffled = checkPool.find(randoCheckId) != checkPool.end(); + auto it = std::find(checkPool.begin(), checkPool.end(), randoCheckId); + bool isShuffled = it != checkPool.end(); checksInLogic.insert({ randoCheckId, isShuffled }); - checkPool.erase(randoCheckId); + if (isShuffled) { + checkPool.erase(it); + } RandoItemId randoItemId; diff --git a/mm/2s2h/Rando/Logic/Logic.cpp b/mm/2s2h/Rando/Logic/Logic.cpp index 80f10ff03..b76397557 100644 --- a/mm/2s2h/Rando/Logic/Logic.cpp +++ b/mm/2s2h/Rando/Logic/Logic.cpp @@ -7,10 +7,10 @@ namespace Rando { namespace Logic { -std::unordered_map<RandoRegionId, RandoRegion> Regions = {}; +std::map<RandoRegionId, RandoRegion> Regions = {}; RandoRegionId GetRegionIdFromEntrance(s32 entrance) { - static std::unordered_map<s32, RandoRegionId> entranceToRegionId; + static std::map<s32, RandoRegionId> entranceToRegionId; if (entranceToRegionId.empty()) { for (auto& [randoRegionId, randoRegion] : Regions) { for (auto& [_, regionExit] : randoRegion.exits) { diff --git a/mm/2s2h/Rando/Logic/Logic.h b/mm/2s2h/Rando/Logic/Logic.h index aeec62449..adde65a4c 100644 --- a/mm/2s2h/Rando/Logic/Logic.h +++ b/mm/2s2h/Rando/Logic/Logic.h @@ -5,7 +5,6 @@ #include "2s2h/GameInteractor/GameInteractor.h" #include "2s2h/ShipUtils.h" -#include <unordered_map> #include <set> #include <cassert> @@ -20,13 +19,10 @@ namespace Logic { void FindReachableRegions(RandoRegionId currentRegion, std::set<RandoRegionId>& reachableRegions); RandoRegionId GetRegionIdFromEntrance(s32 entrance); -void ApplyFrenchVanillaLogicToSaveContext(std::unordered_map<RandoCheckId, bool>& checkPool, - std::vector<RandoItemId>& itemPool); -void ApplyGlitchlessLogicToSaveContext(std::unordered_map<RandoCheckId, bool>& checkPool, - std::vector<RandoItemId>& itemPool); -void ApplyNearlyNoLogicToSaveContext(std::unordered_map<RandoCheckId, bool>& checkPool, - std::vector<RandoItemId>& itemPool); -void ApplyNoLogicToSaveContext(std::unordered_map<RandoCheckId, bool>& checkPool, std::vector<RandoItemId>& itemPool); +void ApplyFrenchVanillaLogicToSaveContext(std::vector<RandoCheckId>& checkPool, std::vector<RandoItemId>& itemPool); +void ApplyGlitchlessLogicToSaveContext(std::vector<RandoCheckId>& checkPool, std::vector<RandoItemId>& itemPool); +void ApplyNearlyNoLogicToSaveContext(std::vector<RandoCheckId>& checkPool, std::vector<RandoItemId>& itemPool); +void ApplyNoLogicToSaveContext(std::vector<RandoCheckId>& checkPool, std::vector<RandoItemId>& itemPool); struct RandoRegionExit { s32 returnEntrance; @@ -37,14 +33,14 @@ struct RandoRegionExit { struct RandoRegion { const char* name = ""; SceneId sceneId; - std::unordered_map<RandoCheckId, std::pair<std::function<bool()>, std::string>> checks; - std::unordered_map<s32, RandoRegionExit> exits; - std::unordered_map<RandoRegionId, std::pair<std::function<bool()>, std::string>> connections; + std::map<RandoCheckId, std::pair<std::function<bool()>, std::string>> checks; + std::map<s32, RandoRegionExit> exits; + std::map<RandoRegionId, std::pair<std::function<bool()>, std::string>> connections; std::vector<std::pair<RandoEvent, std::function<bool()>>> events; std::set<s32> oneWayEntrances; }; -extern std::unordered_map<RandoRegionId, RandoRegion> Regions; +extern std::map<RandoRegionId, RandoRegion> Regions; // TODO: This may not stay here #define IS_DEKU (GET_PLAYER_FORM == PLAYER_FORM_DEKU) diff --git a/mm/2s2h/Rando/Logic/NearlyNoLogic.cpp b/mm/2s2h/Rando/Logic/NearlyNoLogic.cpp index c1af5a468..fd3b7df21 100644 --- a/mm/2s2h/Rando/Logic/NearlyNoLogic.cpp +++ b/mm/2s2h/Rando/Logic/NearlyNoLogic.cpp @@ -9,16 +9,15 @@ namespace Rando { namespace Logic { -void ApplyNearlyNoLogicToSaveContext(std::unordered_map<RandoCheckId, bool>& checkPool, - std::vector<RandoItemId>& itemPool) { +void ApplyNearlyNoLogicToSaveContext(std::vector<RandoCheckId>& checkPool, std::vector<RandoItemId>& itemPool) { for (size_t i = 0; i < itemPool.size(); i++) { std::swap(itemPool[i], itemPool[Ship_Random(0, itemPool.size() - 1)]); } - std::unordered_map<RandoItemId, RandoCheckId> importantItems; + std::map<RandoItemId, RandoCheckId> importantItems; std::vector<RandoCheckId> safeChecks; - std::unordered_map<RandoItemId, std::vector<SceneId>> itemToSceneBlacklist = { + std::map<RandoItemId, std::vector<SceneId>> itemToSceneBlacklist = { { RI_MASK_DEKU, { SCENE_MITURIN, SCENE_MITURIN_BS, SCENE_LAST_DEKU, SCENE_LAST_GORON, SCENE_LAST_ZORA, SCENE_LAST_LINK, SCENE_SOUGEN, SCENE_LAST_BS } }, @@ -43,7 +42,7 @@ void ApplyNearlyNoLogicToSaveContext(std::unordered_map<RandoCheckId, bool>& che { SCENE_LAST_DEKU, SCENE_LAST_GORON, SCENE_LAST_ZORA, SCENE_LAST_LINK, SCENE_SOUGEN, SCENE_LAST_BS } }, }; - for (auto& [randoCheckId, _] : checkPool) { + for (auto& randoCheckId : checkPool) { if (randoCheckId == RC_UNKNOWN) { continue; } diff --git a/mm/2s2h/Rando/Logic/NoLogic.cpp b/mm/2s2h/Rando/Logic/NoLogic.cpp index e820c9176..e4604fcff 100644 --- a/mm/2s2h/Rando/Logic/NoLogic.cpp +++ b/mm/2s2h/Rando/Logic/NoLogic.cpp @@ -9,9 +9,9 @@ namespace Rando { namespace Logic { -void ApplyNoLogicToSaveContext(std::unordered_map<RandoCheckId, bool>& checkPool, std::vector<RandoItemId>& itemPool) { +void ApplyNoLogicToSaveContext(std::vector<RandoCheckId>& checkPool, std::vector<RandoItemId>& itemPool) { std::vector<RandoItemId> junkPool; - for (auto& [randoCheckId, _] : checkPool) { + for (auto& randoCheckId : checkPool) { if (RANDO_SAVE_CHECKS[randoCheckId].skipped) { uint32_t index = 0; for (auto& item : itemPool) { @@ -29,7 +29,7 @@ void ApplyNoLogicToSaveContext(std::unordered_map<RandoCheckId, bool>& checkPool std::swap(itemPool[i], itemPool[Ship_Random(0, itemPool.size() - 1)]); } - for (auto& [randoCheckId, _] : checkPool) { + for (auto& randoCheckId : checkPool) { if (randoCheckId == RC_UNKNOWN) { continue; } diff --git a/mm/2s2h/Rando/MiscBehavior/OnFileCreate.cpp b/mm/2s2h/Rando/MiscBehavior/OnFileCreate.cpp index f264bf407..f3c6484d7 100644 --- a/mm/2s2h/Rando/MiscBehavior/OnFileCreate.cpp +++ b/mm/2s2h/Rando/MiscBehavior/OnFileCreate.cpp @@ -1,7 +1,7 @@ #include "MiscBehavior.h" #include "Rando/Spoiler/Spoiler.h" #include "Rando/Logic/Logic.h" -#include <boost_custom/container_hash/hash_32.hpp> +#include "2s2h/ShipUtils.h" #include "public/bridge/consolevariablebridge.h" #include <spdlog/spdlog.h> @@ -49,7 +49,7 @@ void Rando::MiscBehavior::OnFileCreate(s16 fileNum) { hadInputSeed = false; } - uint32_t finalSeed = boost::hash_32<std::string>{}(inputSeed); + uint32_t finalSeed = Ship_Hash(inputSeed); Ship_Random_Seed(finalSeed); // Persist options to the save @@ -96,7 +96,7 @@ void Rando::MiscBehavior::OnFileCreate(s16 fileNum) { } } - std::unordered_map<RandoCheckId, bool> checkPool; + std::vector<RandoCheckId> checkPool; std::vector<RandoItemId> itemPool; // Create Excluded Checks List to eliminate excluded checks from the pool @@ -119,7 +119,7 @@ void Rando::MiscBehavior::OnFileCreate(s16 fileNum) { } // Skip checks that are already in the pool - if (checkPool.find(randoCheckId) != checkPool.end()) { + if (std::find(checkPool.begin(), checkPool.end(), randoCheckId) != checkPool.end()) { continue; } @@ -217,12 +217,12 @@ void Rando::MiscBehavior::OnFileCreate(s16 fileNum) { RANDO_SAVE_CHECKS[randoCheckId].randoItemId = RI_JUNK; RANDO_SAVE_CHECKS[randoCheckId].skipped = true; - checkPool.insert({ randoCheckId, true }); + checkPool.emplace_back(randoCheckId); continue; } } - checkPool.insert({ randoCheckId, true }); + checkPool.emplace_back(randoCheckId); itemPool.push_back(randoStaticCheck.randoItemId); } } diff --git a/mm/2s2h/Rando/StaticData/StaticData.h b/mm/2s2h/Rando/StaticData/StaticData.h index 050d5e1ec..b072f31f3 100644 --- a/mm/2s2h/Rando/StaticData/StaticData.h +++ b/mm/2s2h/Rando/StaticData/StaticData.h @@ -69,8 +69,8 @@ struct RandoStaticRegion { RandoRegionId randoRegionId; const char* name; SceneId sceneId; - std::unordered_map<RandoCheckId, std::function<bool()>> checks; - std::unordered_map<RandoRegionId, std::function<bool()>> regions; + std::map<RandoCheckId, std::function<bool()>> checks; + std::map<RandoRegionId, std::function<bool()>> regions; }; extern std::map<RandoRegionId, RandoStaticRegion> Regions; diff --git a/mm/2s2h/ShipUtils.cpp b/mm/2s2h/ShipUtils.cpp index 758121cc1..878f65bcc 100644 --- a/mm/2s2h/ShipUtils.cpp +++ b/mm/2s2h/ShipUtils.cpp @@ -1,11 +1,10 @@ #include "ShipUtils.h" #include "assets/2s2h_assets.h" #include <string> +#include <bit> #include <random> #include <vector> -#include <boost/random/mersenne_twister.hpp> -#include <boost/random/uniform_int_distribution.hpp> -#include <boost_custom/container_hash/hash_32.hpp> +#include <cassert> #include "public/bridge/consolevariablebridge.h" #include "Context.h" #include "Window.h" @@ -205,20 +204,50 @@ extern "C" TexturePtr Ship_GetCharFontTextureNES(u8 character) { } static bool seeded = false; -static boost::random::mt19937 generator; +static uint64_t state = 0; +const uint64_t multiplier = 6364136223846793005ULL; +const uint64_t increment = 11634580027462260723ULL; -extern "C" void Ship_Random_Seed(u32 seed) { +extern "C" void Ship_Random_Seed(u64 seed) { seeded = true; - generator = boost::random::mt19937{ seed }; + state = seed; } -extern "C" s32 Ship_Random(s32 min, s32 max) { +uint32_t next32() { if (!seeded) { - const auto seed = static_cast<uint32_t>(std::random_device{}()); + uint64_t seed = static_cast<uint64_t>(std::random_device{}()); Ship_Random_Seed(seed); } - boost::random::uniform_int_distribution<uint32_t> distribution(min, max - 1); - return distribution(generator); + state = state * multiplier + increment; + uint32_t xorshifted = static_cast<uint32_t>(((state >> 18) ^ state) >> 27); + uint32_t rot = static_cast<int>(state >> 59); + return std::rotr(xorshifted, rot); +} + +extern "C" s32 Ship_Random(s32 min, s32 max) { + if (min == max) { + return min; + } + assert(max > min); + uint32_t n = max - min; + uint32_t cutoff = UINT32_MAX - UINT32_MAX % static_cast<uint32_t>(n); + for (;;) { + uint32_t r = next32(); + if (r <= cutoff) { + return min + r % n; + } + } +} + +extern uint32_t Ship_Hash(std::string str) { + // FNV-1a + const size_t len = str.size(); + uint32_t hval = 0x811c9dc5; + for (size_t pos = 0; pos < len; pos++) { + hval ^= (uint32_t)str[pos]; + hval *= 0x01000193; + } + return hval; } void LoadGuiTextures() { diff --git a/mm/2s2h/ShipUtils.h b/mm/2s2h/ShipUtils.h index db1c13ff0..11008f2e2 100644 --- a/mm/2s2h/ShipUtils.h +++ b/mm/2s2h/ShipUtils.h @@ -21,6 +21,7 @@ extern std::array<const char*, 11> digitList; extern std::string Ship_FormatTimeDisplay(uint32_t value); extern std::map<uint32_t, ImVec4> itemColorMap; extern ImVec4 Ship_GetItemColorTint(uint32_t itemId); +extern uint32_t Ship_Hash(std::string str); extern "C" { #endif @@ -37,7 +38,7 @@ bool Ship_IsCStringEmpty(const char* str); void Ship_CreateQuadVertexGroup(Vtx* vtxList, s32 xStart, s32 yStart, s32 width, s32 height, u8 flippedH); f32 Ship_GetCharFontWidthNES(u8 character); TexturePtr Ship_GetCharFontTextureNES(u8 character); -void Ship_Random_Seed(u32 seed); +void Ship_Random_Seed(u64 seed); s32 Ship_Random(s32 min, s32 max); #ifdef __cplusplus diff --git a/mm/CMakeLists.txt b/mm/CMakeLists.txt index 69ebe18eb..436be6d31 100644 --- a/mm/CMakeLists.txt +++ b/mm/CMakeLists.txt @@ -218,32 +218,6 @@ if (CMAKE_SYSTEM_NAME STREQUAL "Windows") set_target_properties(${PROJECT_NAME} PROPERTIES MSVC_RUNTIME_LIBRARY ${MSVC_RUNTIME_LIBRARY_STR}) endif() ################################################################################ -# Find/download Boost -################################################################################ -include(FetchContent) -FetchContent_Declare( - Boost - URL https://archives.boost.io/release/1.81.0/source/boost_1_81_0.tar.gz - URL_HASH SHA256=205666dea9f6a7cfed87c7a6dfbeb52a2c1b9de55712c9c1a87735d7181452b6 - SOURCE_SUBDIR "null" # Set to a nonexistent directory so boost is not built (we don't need to build it) - DOWNLOAD_EXTRACT_TIMESTAMP false # supress timestamp warning, not needed since the url wont change -) - -set(Boost_NO_BOOST_CMAKE false) -set(BOOST_INCLUDEDIR ${FETCHCONTENT_BASE_DIR}/boost-src) # Location where FetchContent stores the source -message("Searching for Boost installation") -find_package(Boost) - -if (NOT ${Boost_FOUND}) - message("Boost not found. Downloading now...") - FetchContent_MakeAvailable(Boost) - message("Boost downloaded to " ${FETCHCONTENT_BASE_DIR}/boost-src) - set(BOOST-INCLUDE ${FETCHCONTENT_BASE_DIR}/boost-src) -else() - message("Boost found in " ${Boost_INCLUDE_DIRS}) - set(BOOST-INCLUDE ${Boost_INCLUDE_DIRS}) -endif() -################################################################################ # Compile definitions ################################################################################ find_package(SDL2) @@ -289,7 +263,6 @@ target_include_directories(${PROJECT_NAME} PRIVATE assets ${CMAKE_CURRENT_SOURCE_DIR}/2s2h/ ${SDL2-INCLUDE} ${SDL2-NET-INCLUDE} - ${BOOST-INCLUDE} ${CMAKE_CURRENT_SOURCE_DIR}/assets/ ${dr_libs_SOURCE_DIR} . diff --git a/mm/include/boost_custom/container_hash/detail/hash_mix_32.hpp b/mm/include/boost_custom/container_hash/detail/hash_mix_32.hpp deleted file mode 100644 index 95cfdcd77..000000000 --- a/mm/include/boost_custom/container_hash/detail/hash_mix_32.hpp +++ /dev/null @@ -1,47 +0,0 @@ -// 32 bit implementation based off of Boost hash - -#ifndef BOOST_HASH_DETAIL_HASH_MIX_32_HPP -#define BOOST_HASH_DETAIL_HASH_MIX_32_HPP - -#include <boost/cstdint.hpp> -#include <cstddef> -#include <climits> - -namespace boost -{ -namespace hash_detail -{ - -template<uint32_t Bits> struct hash_mix_impl_32; - -// hash_mix for 32 bit -// -// We use the "best xmxmx" implementation from -// https://github.com/skeeto/hash-prospector/issues/19 - -template<> struct hash_mix_impl_32<32> -{ - inline static boost::uint32_t fn( boost::uint32_t x ) - { - boost::uint32_t const m1 = 0x21f0aaad; - boost::uint32_t const m2 = 0x735a2d97; - - x ^= x >> 16; - x *= m1; - x ^= x >> 15; - x *= m2; - x ^= x >> 15; - - return x; - } -}; - -inline uint32_t hash_mix_32( uint32_t v ) -{ - return hash_mix_impl_32<32>::fn( v ); -} - -} // namespace hash_detail -} // namespace boost - -#endif // #ifndef BOOST_HASH_DETAIL_HASH_MIX_32_HPP diff --git a/mm/include/boost_custom/container_hash/detail/hash_range_32.hpp b/mm/include/boost_custom/container_hash/detail/hash_range_32.hpp deleted file mode 100644 index cfa0a2a2d..000000000 --- a/mm/include/boost_custom/container_hash/detail/hash_range_32.hpp +++ /dev/null @@ -1,128 +0,0 @@ -// 32 bit implementation based off of Boost hash -// Only implementing 32 bit version of char based ranges - -#ifndef BOOST_HASH_DETAIL_HASH_RANGE_32_HPP -#define BOOST_HASH_DETAIL_HASH_RANGE_32_HPP - -#include <boost_custom/container_hash/hash_fwd_32.hpp> -#include <boost_custom/container_hash/version.hpp> - -#if BOOST_VERSION_HAS_HASH_RANGE -#include <boost/container_hash/detail/hash_range.hpp> -#else -#include <boost/type_traits/integral_constant.hpp> -#include <boost/type_traits/enable_if.hpp> -#include <boost/type_traits/is_same.hpp> -#include <boost/cstdint.hpp> -#include <cstddef> -#include <climits> -#include <iterator> -#endif // #if BOOST_VERSION_HAS_HASH_RANGE - -namespace boost -{ -namespace hash_detail -{ - -#if !BOOST_VERSION_HAS_HASH_RANGE - -template<class T> struct is_char_type: public boost::false_type {}; - -#if CHAR_BIT == 8 - -template<> struct is_char_type<char>: public boost::true_type {}; -template<> struct is_char_type<signed char>: public boost::true_type {}; -template<> struct is_char_type<unsigned char>: public boost::true_type {}; - -#if defined(__cpp_char8_t) && __cpp_char8_t >= 201811L -template<> struct is_char_type<char8_t>: public boost::true_type {}; -#endif - -#if defined(__cpp_lib_byte) && __cpp_lib_byte >= 201603L -template<> struct is_char_type<std::byte>: public boost::true_type {}; -#endif - -#endif - -#endif // #if !BOOST_VERSION_HAS_HASH_RANGE - -#if BOOST_USE_STD_TYPES -#define BOOST_ENABLE_IF std::enable_if -#define BOOST_IS_SAME std::is_same -#else -#define BOOST_ENABLE_IF boost::enable_if_ -#define BOOST_IS_SAME is_same -#endif - -template<class It> -inline typename BOOST_ENABLE_IF< - is_char_type<typename std::iterator_traits<It>::value_type>::value && - BOOST_IS_SAME<typename std::iterator_traits<It>::iterator_category, std::random_access_iterator_tag>::value, -std::size_t>::type - hash_range_32( uint32_t seed, It first, It last ) -{ - std::size_t n = static_cast<std::size_t>( last - first ); - - for( ; n >= 4; first += 4, n -= 4 ) - { - // clang 5+, gcc 5+ figure out this pattern and use a single mov on x86 - // gcc on s390x and power BE even knows how to use load-reverse - - boost::uint32_t w = - static_cast<boost::uint32_t>( static_cast<unsigned char>( first[0] ) ) | - static_cast<boost::uint32_t>( static_cast<unsigned char>( first[1] ) ) << 8 | - static_cast<boost::uint32_t>( static_cast<unsigned char>( first[2] ) ) << 16 | - static_cast<boost::uint32_t>( static_cast<unsigned char>( first[3] ) ) << 24; - - hash_combine_32( seed, w ); - } - - { - // add a trailing suffix byte of 0x01 because otherwise sequences of - // trailing zeroes are indistinguishable from end of string - - boost::uint32_t w = 0x01u; - - switch( n ) - { - case 1: - - w = - static_cast<boost::uint32_t>( static_cast<unsigned char>( first[0] ) ) | - 0x0100u; - - break; - - case 2: - - w = - static_cast<boost::uint32_t>( static_cast<unsigned char>( first[0] ) ) | - static_cast<boost::uint32_t>( static_cast<unsigned char>( first[1] ) ) << 8 | - 0x010000u; - - break; - - case 3: - - w = - static_cast<boost::uint32_t>( static_cast<unsigned char>( first[0] ) ) | - static_cast<boost::uint32_t>( static_cast<unsigned char>( first[1] ) ) << 8 | - static_cast<boost::uint32_t>( static_cast<unsigned char>( first[2] ) ) << 16 | - 0x01000000u; - - break; - } - - hash_combine_32( seed, w ); - } - - return seed; -} - -} // namespace hash_detail -} // namespace boost - -#undef BOOST_ENABLE_IF -#undef BOOST_IS_SAME - -#endif // #ifndef BOOST_HASH_DETAIL_HASH_RANGE_32_HPP diff --git a/mm/include/boost_custom/container_hash/hash_32.hpp b/mm/include/boost_custom/container_hash/hash_32.hpp deleted file mode 100644 index eaf459a34..000000000 --- a/mm/include/boost_custom/container_hash/hash_32.hpp +++ /dev/null @@ -1,188 +0,0 @@ -// 32 bit implementation based off of Boost hash -// Only implementing 32 bit versions integral and string based hashes - -#ifndef BOOST_FUNCTIONAL_HASH_HASH_32_HPP -#define BOOST_FUNCTIONAL_HASH_HASH_32_HPP - -#include <boost/container_hash/hash.hpp> -#include <boost_custom/container_hash/hash_fwd_32.hpp> -#include <boost_custom/container_hash/detail/hash_mix_32.hpp> -#include <boost_custom/container_hash/detail/hash_range_32.hpp> -#include <boost_custom/container_hash/version.hpp> - -#if !BOOST_VERSION_HAS_HASH_RANGE -#include <boost/type_traits/is_unsigned.hpp> -#include <boost/type_traits/make_unsigned.hpp> - -#if BOOST_WORKAROUND(__GNUC__, < 3) \ - && !defined(__SGI_STL_PORT) && !defined(_STLPORT_VERSION) -#define BOOST_HASH_CHAR_TRAITS string_char_traits -#else -#define BOOST_HASH_CHAR_TRAITS char_traits -#endif - -#endif // #if !BOOST_VERSION_HAS_HASH_RANGE - -#if BOOST_USE_STD_TYPES -#define BOOST_ENABLE_IF std::enable_if -#define BOOST_IS_INTEGRAL hash_detail::is_integral -#define BOOST_IS_UNSIGNED is_unsigned -#define BOOST_MAKE_UNSIGNED make_unsigned -#else -#define BOOST_ENABLE_IF boost::enable_if_ -#define BOOST_IS_INTEGRAL boost::is_integral -#define BOOST_IS_UNSIGNED boost::is_unsigned -#define BOOST_MAKE_UNSIGNED boost::make_unsigned -#endif - -namespace boost -{ - - // - // boost::hash_value - // - - // integral types - - namespace hash_detail - { - template<class T, - bool bigger_than_size_t = (sizeof(T) > sizeof(uint32_t)), - bool is_unsigned = BOOST_IS_UNSIGNED<T>::value, - std::size_t size_t_bits = sizeof(uint32_t) * CHAR_BIT, - std::size_t type_bits = sizeof(T) * CHAR_BIT> - struct hash_integral_impl_32; - - template<class T, bool is_unsigned, std::size_t size_t_bits, std::size_t type_bits> struct hash_integral_impl_32<T, false, is_unsigned, size_t_bits, type_bits> - { - static uint32_t fn( T v ) - { - return static_cast<uint32_t>( v ); - } - }; - - template<class T, std::size_t size_t_bits, std::size_t type_bits> struct hash_integral_impl_32<T, true, false, size_t_bits, type_bits> - { - static uint32_t fn( T v ) - { - typedef typename BOOST_MAKE_UNSIGNED<T>::type U; - - if( v >= 0 ) - { - return hash_integral_impl_32<U>::fn( static_cast<U>( v ) ); - } - else - { - return ~hash_integral_impl_32<U>::fn( static_cast<U>( ~static_cast<U>( v ) ) ); - } - } - }; - - template<class T> struct hash_integral_impl_32<T, true, true, 32, 64> - { - static uint32_t fn( T v ) - { - uint32_t seed = 0; - - seed = static_cast<uint32_t>( v >> 32 ) + hash_detail::hash_mix_32( seed ); - seed = static_cast<uint32_t>( v ) + hash_detail::hash_mix_32( seed ); - - return seed; - } - }; - - template<class T> struct hash_integral_impl_32<T, true, true, 32, 128> - { - static uint32_t fn( T v ) - { - uint32_t seed = 0; - - seed = static_cast<uint32_t>( v >> 96 ) + hash_detail::hash_mix_32( seed ); - seed = static_cast<uint32_t>( v >> 64 ) + hash_detail::hash_mix_32( seed ); - seed = static_cast<uint32_t>( v >> 32 ) + hash_detail::hash_mix_32( seed ); - seed = static_cast<uint32_t>( v ) + hash_detail::hash_mix_32( seed ); - - return seed; - } - }; - - } // namespace hash_detail - - template <typename T> - typename BOOST_ENABLE_IF<BOOST_IS_INTEGRAL<T>::value, uint32_t>::type - hash_value_32( T v ) - { - return hash_detail::hash_integral_impl_32<T>::fn( v ); - } - - // contiguous ranges (string, vector, array) -#if BOOST_VERSION_HAS_HASH_RANGE - template <typename T> - typename BOOST_ENABLE_IF<container_hash::is_contiguous_range<T>::value, uint32_t>::type - hash_value_32( T const& v ) - { - return boost::hash_range_32( v.data(), v.data() + v.size() ); - } -#else - template <class Ch, class A> - inline uint32_t hash_value_32( - std::basic_string<Ch, std::BOOST_HASH_CHAR_TRAITS<Ch>, A> const& v) - { - return boost::hash_range_32( v.data(), v.data() + v.size() ); - } -#endif - - // - // boost::hash_combine - // - - template <class T> - inline void hash_combine_32( uint32_t& seed, T const& v ) - { - seed = boost::hash_detail::hash_mix_32( seed + 0x9e3779b9 + boost::hash_32<T>()( v ) ); - } - - // - // boost::hash_range - // - - template <class It> - inline void hash_range_32( uint32_t& seed, It first, It last ) - { - seed = hash_detail::hash_range_32( seed, first, last ); - } - - template <class It> - inline uint32_t hash_range_32( It first, It last ) - { - uint32_t seed = 0; - - hash_range_32( seed, first, last ); - - return seed; - } - - // - // boost::hash - // - - template <class T> struct hash_32 - { - typedef T argument_type; - typedef uint32_t result_type; - - uint32_t operator()( T const& val ) const - { - return hash_value_32( val ); - } - }; - -} // namespace boost - -#undef BOOST_HASH_CHAR_TRAITS -#undef BOOST_ENABLE_IF -#undef BOOST_IS_INTEGRAL -#undef BOOST_IS_UNSIGNED -#undef BOOST_MAKE_UNSIGNED - -#endif // #ifndef BOOST_FUNCTIONAL_HASH_HASH_32_HPP diff --git a/mm/include/boost_custom/container_hash/hash_fwd_32.hpp b/mm/include/boost_custom/container_hash/hash_fwd_32.hpp deleted file mode 100644 index 2ad101f2b..000000000 --- a/mm/include/boost_custom/container_hash/hash_fwd_32.hpp +++ /dev/null @@ -1,25 +0,0 @@ -// 32 bit implementation based off of Boost hash - -#ifndef BOOST_FUNCTIONAL_HASH_FWD_32_HPP -#define BOOST_FUNCTIONAL_HASH_FWD_32_HPP - -#include <boost/container_hash/hash_fwd.hpp> - -namespace boost -{ - -namespace container_hash -{ - -} // namespace container_hash - -template<class T> struct hash_32; - -template<class T> void hash_combine_32( uint32_t& seed, T const& v ); - -template<class It> void hash_range_32( uint32_t&, It, It ); -template<class It> uint32_t hash_range_32( It, It ); - -} // namespace boost - -#endif // #ifndef BOOST_FUNCTIONAL_HASH_FWD_32_HPP diff --git a/mm/include/boost_custom/container_hash/version.hpp b/mm/include/boost_custom/container_hash/version.hpp deleted file mode 100644 index 3863b507c..000000000 --- a/mm/include/boost_custom/container_hash/version.hpp +++ /dev/null @@ -1,11 +0,0 @@ - -#ifndef BOOST_CONTAINER_HASH_VERSION_HPP -#define BOOST_CONTAINER_HASH_VERSION_HPP - -#include <boost/version.hpp> - -#define BOOST_VERSION_HAS_HASH_RANGE ((BOOST_VERSION / 100 % 1000) >= 81) - -#define BOOST_USE_STD_TYPES ((BOOST_VERSION / 100 % 1000) >= 84) - -#endif // #ifndef BOOST_CONTAINER_HASH_VERSION_HPP |
