diff --git a/CMakeLists.txt b/CMakeLists.txt index 8c7b4df..7dc7bdf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,9 +13,17 @@ file(GLOB_RECURSE LIBS "include/*.hpp" "include/*.h" "include/*.cpp" "include/*. include_directories(mc_cpp ${CMAKE_CURRENT_SOURCE_DIR}/include) find_package(Boost REQUIRED COMPONENTS iostreams) -link_libraries(z crypto) if(WIN32) - link_libraries(ws2_32) + # Bare `z`/`crypto` are Unix `-l` names that don't resolve on Windows: the + # crypto import lib is libcrypto.lib (not crypto.lib), and the provider's lib + # dir generally isn't on the linker's search path (so even a correctly-named + # zlib import lib wouldn't be found by bare name). find_package imported + # targets supply the resolved paths and correct names. + find_package(ZLIB REQUIRED) + find_package(OpenSSL REQUIRED) + link_libraries(ZLIB::ZLIB OpenSSL::Crypto ws2_32) +else() + link_libraries(z crypto) endif() include(FetchContent) diff --git a/include/mc_cpp/crypto/rsa.cpp b/include/mc_cpp/crypto/rsa.cpp index b77d2ea..0e4bd55 100644 --- a/include/mc_cpp/crypto/rsa.cpp +++ b/include/mc_cpp/crypto/rsa.cpp @@ -1,6 +1,7 @@ #include #include #include +#include namespace mc { auto generateRSAKeyPair(const size_t bits) -> EVP_PKEY* { @@ -27,7 +28,13 @@ namespace mc { } auto loadRSAPrivateKey(const std::filesystem::path &filepath) -> EVP_PKEY* { +#ifdef _WIN32 + // path::c_str() is const wchar_t* on Windows; _wfopen keeps Unicode paths intact + // (a narrow fopen would go through the lossy ANSI code page). + auto *fp = _wfopen(filepath.c_str(), L"rb"); +#else auto *fp = fopen(filepath.c_str(), "rb"); +#endif if (!fp) return nullptr; diff --git a/include/mc_cpp/registry/registries/biomes.cpp b/include/mc_cpp/registry/registries/biomes.cpp index bce6930..87f2ff0 100644 --- a/include/mc_cpp/registry/registries/biomes.cpp +++ b/include/mc_cpp/registry/registries/biomes.cpp @@ -33,7 +33,7 @@ namespace mc { // biome overrides only store y = 0 as they don't depend on y return isGrass ? biomeGrassColors[biomeType] : biomeFoliageColors[biomeType]; - const auto y = std::clamp(yLevel - SEA_LEVEL, 0, UINT8_MAX); + const auto y = std::clamp(yLevel - SEA_LEVEL, 0, UINT8_MAX); return isGrass ? biomeGrassColors [biomeType + UINT8_MAX * y] : biomeFoliageColors[biomeType + UINT8_MAX * y]; }