diff --git a/src/ll/api/dimension/CustomDimensionManager.cpp b/src/ll/api/dimension/CustomDimensionManager.cpp index fa40185964..ada584f716 100644 --- a/src/ll/api/dimension/CustomDimensionManager.cpp +++ b/src/ll/api/dimension/CustomDimensionManager.cpp @@ -45,13 +45,12 @@ LL_TYPE_STATIC_HOOK( VanillaDimensionsFromSerializedIntHook, HookPriority::Normal, VanillaDimensions, - "?fromSerializedInt@VanillaDimensions@@SA?AV?$Result@V?$AutomaticID@VDimension@@H@@Verror_code@std@@@Bedrock@@$$" - "QEAV?$Result@HVerror_code@std@@@3@@Z", + VanillaDimensions::fromSerializedInt, Bedrock::Result, - Bedrock::Result& dim + Bedrock::Result&& dim ) { if (!dim || *dim <= 2) { - return origin(dim); + return origin(std::move(dim)); } return *dim; }; @@ -60,7 +59,7 @@ LL_TYPE_STATIC_HOOK( VanillaDimensionsFromSerializedIntHookI, HookPriority::Normal, VanillaDimensions, - "?fromSerializedInt@VanillaDimensions@@SA?AV?$AutomaticID@VDimension@@H@@H@Z", + VanillaDimensions::fromSerializedInt, DimensionType, int dimId ) { @@ -130,7 +129,8 @@ CustomDimensionManager::CustomDimensionManager() : impl(std::make_unique() name, Impl::DimensionInfo{ info.dimId, - *CompoundTag::fromBinaryNbt(string_utils::decompress(base64_utils::decode(info.base64Nbt)))} + *CompoundTag::fromBinaryNbt(string_utils::decompress(base64_utils::decode(info.base64Nbt))) + } ); } impl->mNewDimensionId += static_cast(impl->customDimensionMap.size()); @@ -206,7 +206,8 @@ DimensionType CustomDimensionManager::addDimension( dimName, CustomDimensionConfig::Config::Info{ info.id, - base64_utils::encode(string_utils::compress(info.nbt.toBinaryNbt()))} + base64_utils::encode(string_utils::compress(info.nbt.toBinaryNbt())) + } ); CustomDimensionConfig::saveConfigFile(); } diff --git a/src/ll/api/event/player/PlayerChatEvent.cpp b/src/ll/api/event/player/PlayerChatEvent.cpp index 465b29e1ef..ab90cef1f1 100644 --- a/src/ll/api/event/player/PlayerChatEvent.cpp +++ b/src/ll/api/event/player/PlayerChatEvent.cpp @@ -25,7 +25,7 @@ LL_TYPE_INSTANCE_HOOK( PlayerSendMessageEventHook, HookPriority::Normal, ServerNetworkHandler, - "?handle@ServerNetworkHandler@@UEAAXAEBVNetworkIdentifier@@AEBVTextPacket@@@Z", + &ServerNetworkHandler::handle, void, NetworkIdentifier const& identifier, TextPacket const& packet diff --git a/src/ll/api/event/player/PlayerSneakAndSprintEvent.cpp b/src/ll/api/event/player/PlayerSneakAndSprintEvent.cpp index 619d5b35f8..4720610902 100644 --- a/src/ll/api/event/player/PlayerSneakAndSprintEvent.cpp +++ b/src/ll/api/event/player/PlayerSneakAndSprintEvent.cpp @@ -12,7 +12,7 @@ LL_TYPE_INSTANCE_HOOK( PlayerActionEventHook, HookPriority::Normal, ServerNetworkHandler, - "?handle@ServerNetworkHandler@@UEAAXAEBVNetworkIdentifier@@AEBVPlayerActionPacket@@@Z", + &ServerNetworkHandler::handle, void, NetworkIdentifier const& id, PlayerActionPacket const& packet diff --git a/src/ll/api/memory/Hook.h b/src/ll/api/memory/Hook.h index 3910be32ff..fb4e02e9ec 100644 --- a/src/ll/api/memory/Hook.h +++ b/src/ll/api/memory/Hook.h @@ -203,7 +203,7 @@ struct __declspec(empty_bases) Hook {}; if constexpr (::ll::memory::virtualDetector<_OriginFuncType, IDENTIFIER>()) { \ static_assert( \ ::ll::concepts::always_false, \ - #IDENTIFIER " is a virtual function, for now you can't use function pointer to hook it." \ + #IDENTIFIER " is a virtual function, you need use prefix $ workaround to hook it." \ ); \ } \ } \ diff --git a/src/ll/api/reflection/Reflection.h b/src/ll/api/reflection/Reflection.h index 72c8983652..63a99ae075 100644 --- a/src/ll/api/reflection/Reflection.h +++ b/src/ll/api/reflection/Reflection.h @@ -31,49 +31,49 @@ concept Reflectable = is_reflectable_v; template inline constexpr auto const name_array_v = boost::pfr::names_as_array>(); -template -constexpr auto makeSequenceTupleFromTieTuple(const T& t, std::index_sequence) noexcept { - return boost::pfr::detail::sequence_tuple::make_sequence_tuple(boost::pfr::detail::sequence_tuple::get(t)...); -} +// template +// constexpr auto makeSequenceTupleFromTieTuple(const T& t, std::index_sequence) noexcept { +// return boost::pfr::detail::sequence_tuple::make_sequence_tuple(boost::pfr::detail::sequence_tuple::get(t)...); +// } -template < - typename U, - typename S = decltype(makeSequenceTupleFromTieTuple( - boost::pfr::detail::tie_as_tuple(boost::pfr::detail::fake_object), - boost::pfr::detail::make_index_sequence>() - ))> -struct OffsetGetter { - using this_t = OffsetGetter; +// template < +// typename U, +// typename S = decltype(makeSequenceTupleFromTieTuple( +// boost::pfr::detail::tie_as_tuple(boost::pfr::detail::fake_object), +// boost::pfr::detail::make_index_sequence>() +// ))> +// struct OffsetGetter { +// using this_t = OffsetGetter; - static_assert( - sizeof(U) == sizeof(S), - "Member sequence does not indicate correct size for struct type! Maybe the user-provided type is not a " - "SimpleAggregate?" - ); - static_assert(alignof(U) == alignof(S), " Member sequence does not indicate correct alignment for struct type!"); +// static_assert( +// sizeof(U) == sizeof(S), +// "Member sequence does not indicate correct size for struct type! Maybe the user-provided type is not a " +// "SimpleAggregate?" +// ); +// static_assert(alignof(U) == alignof(S), " Member sequence does not indicate correct alignment for struct type!"); - // Get offset of idx'th member - // Idea: Layout object has the same offsets as instance of S, so if S and U are layout compatible, then these offset - // calculations are correct. - template - static consteval std::ptrdiff_t offset() noexcept { -#if defined(__INTELLISENSE__) || defined(__clangd__) || defined(__clang__) - return 0; // TODO: fix this -#else - constexpr boost::pfr::detail::tuple_of_aligned_storage_t layout{}; - return (&boost::pfr::detail::sequence_tuple::get(layout).storage_) - - (&boost::pfr::detail::sequence_tuple::get<0>(layout).storage_); -#endif - } -}; +// // Get offset of idx'th member +// // Idea: Layout object has the same offsets as instance of S, so if S and U are layout compatible, then these offset +// // calculations are correct. +// template +// static consteval std::ptrdiff_t offset() noexcept { +// #if defined(__INTELLISENSE__) || defined(__clangd__) || defined(__clang__) +// return 0; // TODO: fix this +// #else +// constexpr boost::pfr::detail::tuple_of_aligned_storage_t layout{}; +// return (&boost::pfr::detail::sequence_tuple::get(layout).storage_) +// - (&boost::pfr::detail::sequence_tuple::get<0>(layout).storage_); +// #endif +// } +// }; -template -consteval auto makeOffsetArrayImpl(std::index_sequence) { - return boost::pfr::detail::make_stdarray((OffsetGetter::template offset())...); -} -template -inline constexpr auto const offset_array_v = - makeOffsetArrayImpl(std::make_index_sequence>()); +// template +// consteval auto makeOffsetArrayImpl(std::index_sequence) { +// return boost::pfr::detail::make_stdarray((OffsetGetter::template offset())...); +// } +// template +// inline constexpr auto const offset_array_v = +// makeOffsetArrayImpl(std::make_index_sequence>()); template constexpr void forEachMember(T&& value, F&& func) { diff --git a/src/ll/core/dimension/FakeDimensionId.cpp b/src/ll/core/dimension/FakeDimensionId.cpp index fbc5aff39c..42604a23ca 100644 --- a/src/ll/core/dimension/FakeDimensionId.cpp +++ b/src/ll/core/dimension/FakeDimensionId.cpp @@ -320,10 +320,10 @@ LL_TYPE_INSTANCE_HOOK( ServerNetworkHandlerPlayerActionPacketHandler, HookPriority::Normal, ServerNetworkHandler, - "?handle@ServerNetworkHandler@@UEAAXAEBVNetworkIdentifier@@AEBVPlayerActionPacket@@@Z", + &ServerNetworkHandler::handle, void, - NetworkIdentifier const& netId, - PlayerActionPacket& packet + NetworkIdentifier const& netId, + PlayerActionPacket const& packet ) { auto player = getServerPlayer(netId, packet.mClientSubId); auto uuid = player->getUuid(); @@ -352,8 +352,7 @@ LL_TYPE_INSTANCE_HOOK( LevelrequestPlayerChangeDimensionHandler, HookPriority::Normal, Level, - "?requestPlayerChangeDimension@Level@@UEAAXAEAVPlayer@@V?$unique_ptr@VChangeDimensionRequest@@U?$default_delete@" - "VChangeDimensionRequest@@@std@@@std@@@Z", + &Level::requestPlayerChangeDimension, void, Player& player, std::unique_ptr changeRequest diff --git a/src/ll/test/ConfigTest.cpp b/src/ll/test/ConfigTest.cpp index 73597722f3..0628bfa3dd 100644 --- a/src/ll/test/ConfigTest.cpp +++ b/src/ll/test/ConfigTest.cpp @@ -160,7 +160,7 @@ LL_AUTO_TYPE_INSTANCE_HOOK(ConfigTest, HookPriority::Normal, ServerInstance, &Se ll::logger.debug("789\xDB\xFE"); ll::logger.debug("789\xDB\xFE"); - ll::logger.debug("{}", ll::reflection::offset_array_v>); + // ll::logger.debug("{}", ll::reflection::offset_array_v>); #if !(defined(__INTELLISENSE__) || defined(__clangd__) || defined(__clang__)) myTypeList1::push_back();