Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 7 additions & 0 deletions include/mc_cpp/crypto/rsa.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <mc_cpp/crypto/rsa.hpp>
#include <openssl/pem.h>
#include <iostream>
#include <cstdio>

namespace mc {
auto generateRSAKeyPair(const size_t bits) -> EVP_PKEY* {
Expand All @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion include/mc_cpp/registry/registries/biomes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int>(yLevel - SEA_LEVEL, 0, UINT8_MAX);
return isGrass ? biomeGrassColors [biomeType + UINT8_MAX * y]
: biomeFoliageColors[biomeType + UINT8_MAX * y];
}
Expand Down