diff --git a/src-server/ll/api/Versions.cpp b/src-server/ll/api/Versions.cpp index 419d36ac27..9896e36913 100644 --- a/src-server/ll/api/Versions.cpp +++ b/src-server/ll/api/Versions.cpp @@ -9,14 +9,14 @@ data::Version getGameVersion() { auto info = Common::getBuildInfo(); auto v = data::Version{info.mBuildId}; v.preRelease = data::PreRelease{}; - v.preRelease->values.emplace_back((uint16_t)SharedConstants::RevisionVersion); - v.preRelease->values.emplace_back((uint16_t)SharedConstants::NetworkProtocolVersion); + v.preRelease->values.emplace_back((uint16_t)SharedConstants::RevisionVersion()); + v.preRelease->values.emplace_back((uint16_t)SharedConstants::NetworkProtocolVersion()); v.build = info.mCommitId.substr(0, std::min(info.mCommitId.size(), (size_t)7)); return v; }(); return ver; } -int getNetworkProtocolVersion() { return SharedConstants::NetworkProtocolVersion; } +int getNetworkProtocolVersion() { return SharedConstants::NetworkProtocolVersion(); } } // namespace ll diff --git a/src-server/ll/api/event/player/PlayerChatEvent.cpp b/src-server/ll/api/event/player/PlayerChatEvent.cpp index 3e4d78129d..a9b24eb529 100644 --- a/src-server/ll/api/event/player/PlayerChatEvent.cpp +++ b/src-server/ll/api/event/player/PlayerChatEvent.cpp @@ -25,7 +25,7 @@ LL_TYPE_INSTANCE_HOOK( PlayerSendMessageEventHook, HookPriority::Normal, ServerNetworkHandler, - &ServerNetworkHandler::handle, + &ServerNetworkHandler::handle$, void, NetworkIdentifier const& identifier, TextPacket const& packet diff --git a/src-server/ll/api/event/player/PlayerJoinEvent.cpp b/src-server/ll/api/event/player/PlayerJoinEvent.cpp index c2a098f60a..dd57caa96f 100644 --- a/src-server/ll/api/event/player/PlayerJoinEvent.cpp +++ b/src-server/ll/api/event/player/PlayerJoinEvent.cpp @@ -11,7 +11,7 @@ LL_TYPE_INSTANCE_HOOK( PlayerJoinEventHook, HookPriority::Normal, ServerNetworkHandler, - &ServerNetworkHandler::handle, + &ServerNetworkHandler::handle$, void, NetworkIdentifier const& identifier, SetLocalPlayerAsInitializedPacket const& packet diff --git a/src-server/ll/api/event/player/PlayerSneakAndSprintEvent.cpp b/src-server/ll/api/event/player/PlayerSneakAndSprintEvent.cpp index c60bfe674e..6dc08bcd6b 100644 --- a/src-server/ll/api/event/player/PlayerSneakAndSprintEvent.cpp +++ b/src-server/ll/api/event/player/PlayerSneakAndSprintEvent.cpp @@ -12,7 +12,7 @@ LL_TYPE_INSTANCE_HOOK( PlayerActionEventHook, HookPriority::Normal, ServerNetworkHandler, - &ServerNetworkHandler::handle, + &ServerNetworkHandler::handle$, void, NetworkIdentifier const& id, PlayerActionPacket const& packet diff --git a/src-server/ll/api/event/player/PlayerSwingEvent.cpp b/src-server/ll/api/event/player/PlayerSwingEvent.cpp index 9679274ab9..ca02667147 100644 --- a/src-server/ll/api/event/player/PlayerSwingEvent.cpp +++ b/src-server/ll/api/event/player/PlayerSwingEvent.cpp @@ -11,7 +11,7 @@ LL_TYPE_INSTANCE_HOOK( PlayerSwingEventHook, HookPriority::Normal, ServerNetworkHandler, - &ServerNetworkHandler::handle, + &ServerNetworkHandler::handle$, void, NetworkIdentifier const& id, AnimatePacket const& packet diff --git a/src-server/ll/api/service/TargetedBedrock.cpp b/src-server/ll/api/service/TargetedBedrock.cpp index aa440cbd0d..be70e5229b 100644 --- a/src-server/ll/api/service/TargetedBedrock.cpp +++ b/src-server/ll/api/service/TargetedBedrock.cpp @@ -2,6 +2,7 @@ #include "ll/api/memory/Hook.h" +#include "mc/common/IMinecraftApp.h" #include "mc/deps/ecs/systems/EntitySystemsCollection.h" #include "mc/deps/raknet/RakPeer.h" #include "mc/deps/raknet/RakPeerInterface.h" @@ -52,7 +53,7 @@ LL_TYPE_INSTANCE_HOOK(MinecraftInit, HookPriority::High, Minecraft, &Minecraft:: minecraft = this; origin(); } -LL_INSTANCE_HOOK(MinecraftDestructor, HookPriority::High, "??1Minecraft@@UEAA@XZ", void) { +LL_TYPE_INSTANCE_HOOK(MinecraftDestructor, HookPriority::High, Minecraft, &Minecraft::dtor$, void) { minecraft = nullptr; origin(); } @@ -73,7 +74,13 @@ LL_TYPE_INSTANCE_HOOK( unhook(); origin(a1, a2); } -LL_INSTANCE_HOOK(ServerNetworkHandlerDestructor, HookPriority::High, "??1ServerNetworkHandler@@UEAA@XZ", void) { +LL_TYPE_INSTANCE_HOOK( + ServerNetworkHandlerDestructor, + HookPriority::High, + ServerNetworkHandler, + &ServerNetworkHandler::dtor$, + void +) { serverNetworkHandler = nullptr; origin(); } @@ -81,16 +88,19 @@ LL_INSTANCE_HOOK(ServerNetworkHandlerDestructor, HookPriority::High, "??1ServerN // NetworkSystem static std::atomic networkSystem; -LL_INSTANCE_HOOK( +LL_TYPE_INSTANCE_HOOK( NetworkSystemConstructor, HookPriority::High, - "??0NetworkSystem@@IEAA@$$QEAUDependencies@0@@Z", - NetworkSystem*, + NetworkSystem, + &NetworkSystem::ctor$, + void*, struct NetworkSystem::Dependencies&& dependencies ) { - return networkSystem = origin(std::move(dependencies)); + auto res = origin(std::move(dependencies)); + networkSystem = this; + return res; } -LL_INSTANCE_HOOK(NetworkSystemDestructor, HookPriority::High, "??1NetworkSystem@@MEAA@XZ", void) { +LL_TYPE_INSTANCE_HOOK(NetworkSystemDestructor, HookPriority::High, NetworkSystem, &NetworkSystem::dtor$, void) { networkSystem = nullptr; origin(); } @@ -106,10 +116,10 @@ LL_TYPE_INSTANCE_HOOK( void, ServerInstance& ins ) { - level = ll::service::getMinecraft()->getLevel(); + level = getMinecraft()->getLevel(); origin(ins); } -LL_INSTANCE_HOOK(LevelDestructor, HookPriority::High, "??1Level@@UEAA@XZ", void) { +LL_TYPE_INSTANCE_HOOK(LevelDestructor, HookPriority::High, Level, &Level::dtor$, void) { level = nullptr; origin(); } @@ -117,13 +127,15 @@ LL_INSTANCE_HOOK(LevelDestructor, HookPriority::High, "??1Level@@UEAA@XZ", void) // RakNet::RakPeer static std::atomic rakPeer; -LL_INSTANCE_HOOK(RakNetRakPeerConstructor, HookPriority::High, "??0RakPeer@RakNet@@QEAA@XZ", RakNet::RakPeer*) { +LL_TYPE_INSTANCE_HOOK(RakNetRakPeerConstructor, HookPriority::High, RakNet::RakPeer, &RakNet::RakPeer::ctor$, void*) { unhook(); - return rakPeer = origin(); + auto res = origin(); + rakPeer = this; + return res; } -LL_INSTANCE_HOOK(RakNetRakPeerDestructor, HookPriority::High, "??1RakPeer@RakNet@@UEAA@XZ", void) { - if ((void*)this == (void*)ll::service::getRakPeer()) rakPeer = nullptr; +LL_TYPE_INSTANCE_HOOK(RakNetRakPeerDestructor, HookPriority::High, RakNet::RakPeer, &RakNet::RakPeer::dtor$, void) { + if ((void*)this == (void*)getRakPeer()) rakPeer = nullptr; origin(); } @@ -140,7 +152,13 @@ LL_TYPE_INSTANCE_HOOK( resourcePackRepository = this; origin(); } -LL_INSTANCE_HOOK(ResourcePackRepositoryDestructor, HookPriority::High, "??1ResourcePackRepository@@QEAA@XZ", void) { +LL_TYPE_INSTANCE_HOOK( + ResourcePackRepositoryDestructor, + HookPriority::High, + ResourcePackRepository, + &ResourcePackRepository::dtor$, + void +) { resourcePackRepository = nullptr; origin(); } @@ -152,13 +170,15 @@ LL_TYPE_INSTANCE_HOOK( CommandRegistryConstructor, HookPriority::High, CommandRegistry, - "??0CommandRegistry@@QEAA@_N@Z", - CommandRegistry*, + &CommandRegistry::ctor$, + void*, bool eduMode ) { - return commandRegistry = origin(eduMode); + auto res = origin(eduMode); + commandRegistry = this; + return res; } -LL_INSTANCE_HOOK(CommandRegistryDestructor, HookPriority::High, "??1CommandRegistry@@QEAA@XZ", void) { +LL_TYPE_INSTANCE_HOOK(CommandRegistryDestructor, HookPriority::High, CommandRegistry, &CommandRegistry::dtor$, void) { commandRegistry = nullptr; origin(); } @@ -166,10 +186,20 @@ LL_INSTANCE_HOOK(CommandRegistryDestructor, HookPriority::High, "??1CommandRegis // ServerInstance static std::atomic serverInstance; -LL_TYPE_INSTANCE_HOOK(ServerInstanceConstructor, HookPriority::High, ServerInstance, "??0ServerInstance@@QEAA@AEAVIMinecraftApp@@AEBV?$not_null@V?$NonOwnerPointer@VServerInstanceEventCoordinator@@@Bedrock@@@gsl@@@Z", ServerInstance*) { - return serverInstance = origin(); +LL_TYPE_INSTANCE_HOOK( + ServerInstanceConstructor, + HookPriority::High, + ServerInstance, + &ServerInstance::ctor$, + void*, + IMinecraftApp& app, + Bedrock::NotNullNonOwnerPtr const& coordinator +) { + auto res = origin(app, coordinator); + serverInstance = this; + return res; } -LL_INSTANCE_HOOK(ServerInstanceDestructor, HookPriority::High, "??1ServerInstance@@UEAA@XZ", void) { +LL_TYPE_INSTANCE_HOOK(ServerInstanceDestructor, HookPriority::High, ServerInstance, &ServerInstance::dtor$, void) { serverInstance = nullptr; origin(); } diff --git a/src-server/ll/core/main_win.cpp b/src-server/ll/core/main_win.cpp index 23cc694acc..d3a57d5c48 100644 --- a/src-server/ll/core/main_win.cpp +++ b/src-server/ll/core/main_win.cpp @@ -127,8 +127,8 @@ BOOL WINAPI ConsoleExitHandler(DWORD CEvent) { case CTRL_C_EVENT: case CTRL_CLOSE_EVENT: case CTRL_SHUTDOWN_EVENT: { - if (StopCommand::mServer) { - StopCommand::mServer->requestServerShutdown(""); + if (StopCommand::mServer()) { + StopCommand::mServer()->requestServerShutdown(""); } else { std::terminate(); } @@ -144,7 +144,7 @@ void unixSignalHandler(int signum) { switch (signum) { case SIGINT: case SIGTERM: { - if (StopCommand::mServer) StopCommand::mServer->requestServerShutdown(""); + if (StopCommand::mServer()) StopCommand::mServer()->requestServerShutdown(""); else std::terminate(); break; } @@ -194,7 +194,7 @@ void leviLaminaMain() { mod::ModRegistrar::getInstance().loadAllMods(); } -LL_AUTO_STATIC_HOOK(LeviLaminaMainHook, HookPriority::High, "main", int, int argc, char* argv[]) { +LL_AUTO_STATIC_HOOK(LeviLaminaMainHook, HookPriority::High, "main"_sym, int, int argc, char* argv[]) { #if defined(LL_DEBUG) static stacktrace_utils::SymbolLoader symbols{}; diff --git a/src-test/client/jsonUITest.cpp b/src-test/client/jsonUITest.cpp index 5fe6e61ba5..2592adb055 100644 --- a/src-test/client/jsonUITest.cpp +++ b/src-test/client/jsonUITest.cpp @@ -34,9 +34,7 @@ LL_AUTO_TYPE_INSTANCE_HOOK( TESTAAAA, HookPriority::Normal, Item, - "?appendFormattedHovertext@Item@@UEBAXAEBVItemStackBase@@AEAVLevel@@AEAV?$basic_string@DU?$char_traits@D@std@@" - "V?$" - "allocator@D@2@@std@@_N@Z", + &Item::appendFormattedHovertext$, void, class ItemStackBase const& stack, Level& level, diff --git a/src-test/server/Packet_test.cpp b/src-test/server/Packet_test.cpp index 4e1cc28597..4bc826b15e 100644 --- a/src-test/server/Packet_test.cpp +++ b/src-test/server/Packet_test.cpp @@ -14,6 +14,8 @@ #include "magic_enum.hpp" +using namespace ll::literals; + template <> struct magic_enum::customize::enum_range { static constexpr int min = 0; @@ -124,7 +126,7 @@ void autoGenerate() { } } -LL_AUTO_STATIC_HOOK(GeneratePacketHook, HookPriority::Normal, "main", int, int a, char* c) { +LL_AUTO_STATIC_HOOK(GeneratePacketHook, HookPriority::Normal, "main"_sym, int, int a, char* c) { autoGenerate(); return origin(a, c); } diff --git a/src-test/server/TestNbt.cpp b/src-test/server/TestNbt.cpp index 3707024877..de581d9db7 100644 --- a/src-test/server/TestNbt.cpp +++ b/src-test/server/TestNbt.cpp @@ -187,6 +187,6 @@ LL_AUTO_TYPE_INSTANCE_HOOK(NbtTest, HookPriority::Normal, ServerInstance, &Serve ->toSnbt(SnbtFormat::PrettyConsolePrint) ); - ll::getLogger().debug("signature {}", "48 8D 05 ? ? ? ? E8"_sigv.toString(false, false)); - ll::getLogger().debug("resolve {}", "48 8D 05 ? ? ? ? E8"_sigv.resolve()); + ll::getLogger().debug("signature {}", "48 8D 05 ? ? ? ? E8"_sig.toString(false, false)); + ll::getLogger().debug("resolve {}", "48 8D 05 ? ? ? ? E8"_sig.resolve()); } diff --git a/src/ll/api/base/Alias.h b/src/ll/api/base/Alias.h new file mode 100644 index 0000000000..8f956728b5 --- /dev/null +++ b/src/ll/api/base/Alias.h @@ -0,0 +1,14 @@ +#pragma once + +namespace ll { +template +struct CArray { + using type = T[N]; +}; +template +struct CArray { + using type = T[]; +}; +template +using CArrayT = typename CArray::type; +} // namespace ll diff --git a/src/ll/api/event/command/ExecuteCommandEvent.cpp b/src/ll/api/event/command/ExecuteCommandEvent.cpp index bc90cf45d8..95a8ad52a1 100644 --- a/src/ll/api/event/command/ExecuteCommandEvent.cpp +++ b/src/ll/api/event/command/ExecuteCommandEvent.cpp @@ -40,7 +40,7 @@ LL_TYPE_INSTANCE_HOOK( auto event = ExecutingCommandEvent{*this, context, suppressOutput}; EventBus::getInstance().publish(event); if (event.isCancelled()) { - return MCRESULT_CommandsDisabled; + return MCRESULT_CommandsDisabled(); } return origin(context, suppressOutput); } diff --git a/src/ll/api/event/entity/MobDieEvent.cpp b/src/ll/api/event/entity/MobDieEvent.cpp index 76514735aa..3ac3437518 100644 --- a/src/ll/api/event/entity/MobDieEvent.cpp +++ b/src/ll/api/event/entity/MobDieEvent.cpp @@ -14,14 +14,7 @@ void MobDieEvent::serialize(CompoundTag& nbt) const { ActorDamageSource const& MobDieEvent::source() const { return mSource; } -LL_TYPE_INSTANCE_HOOK( - MobDieEventHook, - HookPriority::Normal, - Mob, - "?die@Mob@@UEAAXAEBVActorDamageSource@@@Z", - void, - ActorDamageSource const& source -) { +LL_TYPE_INSTANCE_HOOK(MobDieEventHook, HookPriority::Normal, Mob, &Mob::die$, void, ActorDamageSource const& source) { auto ev = MobDieEvent(*this, source); EventBus::getInstance().publish(ev); return origin(source); diff --git a/src/ll/api/event/player/PlayerAddExperienceEvent.cpp b/src/ll/api/event/player/PlayerAddExperienceEvent.cpp index 8e72172bd6..ea345a57cc 100644 --- a/src/ll/api/event/player/PlayerAddExperienceEvent.cpp +++ b/src/ll/api/event/player/PlayerAddExperienceEvent.cpp @@ -22,7 +22,7 @@ LL_TYPE_INSTANCE_HOOK( PlayerAddExperienceEventHook, HookPriority::Normal, Player, - "?addExperience@Player@@UEAAXH@Z", + &Player::addExperience$, void, int exp ) { diff --git a/src/ll/api/event/player/PlayerAttackEvent.cpp b/src/ll/api/event/player/PlayerAttackEvent.cpp index 3116eebead..29d252f7e5 100644 --- a/src/ll/api/event/player/PlayerAttackEvent.cpp +++ b/src/ll/api/event/player/PlayerAttackEvent.cpp @@ -20,7 +20,7 @@ LL_TYPE_INSTANCE_HOOK( PlayerAttackEventHook, HookPriority::Normal, Player, - "?attack@Player@@UEAA_NAEAVActor@@AEBW4ActorDamageCause@@@Z", + &Player::attack$, bool, Actor& ac, ActorDamageCause const& cause diff --git a/src/ll/api/event/player/PlayerDieEvent.cpp b/src/ll/api/event/player/PlayerDieEvent.cpp index 791cd97201..dabf6944b7 100644 --- a/src/ll/api/event/player/PlayerDieEvent.cpp +++ b/src/ll/api/event/player/PlayerDieEvent.cpp @@ -17,7 +17,7 @@ LL_TYPE_INSTANCE_HOOK( PlayerDieEventHook, HookPriority::Normal, Player, - "?die@Player@@UEAAXAEBVActorDamageSource@@@Z", + &Player::die$, void, ActorDamageSource const& source ) { diff --git a/src/ll/api/event/player/PlayerInteractBlockEvent.cpp b/src/ll/api/event/player/PlayerInteractBlockEvent.cpp index 667b0b88e0..d0f2e0e067 100644 --- a/src/ll/api/event/player/PlayerInteractBlockEvent.cpp +++ b/src/ll/api/event/player/PlayerInteractBlockEvent.cpp @@ -29,7 +29,7 @@ LL_TYPE_INSTANCE_HOOK( PlayerInteractBlockEventHook, HookPriority::Normal, GameMode, - "?useItemOn@GameMode@@UEAA?AVInteractionResult@@AEAVItemStack@@AEBVBlockPos@@EAEBVVec3@@PEBVBlock@@@Z", + &GameMode::useItemOn$, InteractionResult, ItemStack& item, BlockPos const& blockPos, diff --git a/src/ll/api/event/player/PlayerPlaceBlockEvent.cpp b/src/ll/api/event/player/PlayerPlaceBlockEvent.cpp index e3d53ffb18..db74d4f6ef 100644 --- a/src/ll/api/event/player/PlayerPlaceBlockEvent.cpp +++ b/src/ll/api/event/player/PlayerPlaceBlockEvent.cpp @@ -29,7 +29,7 @@ LL_TYPE_INSTANCE_HOOK( PlayerPlacingBlockEventHook, HookPriority::Normal, BlockSource, - "?checkBlockPermissions@BlockSource@@UEAA_NAEAVActor@@AEBVBlockPos@@EAEBVItemStackBase@@_N@Z", + &BlockSource::checkBlockPermissions$, bool, Actor& actor, BlockPos const& blockpos, diff --git a/src/ll/api/event/player/PlayerRespawnEvent.cpp b/src/ll/api/event/player/PlayerRespawnEvent.cpp index 2f4af5cb34..799b8e142d 100644 --- a/src/ll/api/event/player/PlayerRespawnEvent.cpp +++ b/src/ll/api/event/player/PlayerRespawnEvent.cpp @@ -4,7 +4,7 @@ namespace ll::event::inline player { -LL_TYPE_INSTANCE_HOOK(PlayerRespawnEventHook, HookPriority::Normal, Player, "?respawn@Player@@UEAAXXZ", void) { +LL_TYPE_INSTANCE_HOOK(PlayerRespawnEventHook, HookPriority::Normal, Player, &Player::respawn$, void) { // If the player returns from end or just joins server, his health will > 0 if (this->getHealth() <= 0) { EventBus::getInstance().publish(PlayerRespawnEvent(*this)); diff --git a/src/ll/api/event/world/FireSpreadEvent.cpp b/src/ll/api/event/world/FireSpreadEvent.cpp index dd014db145..e70bb97035 100644 --- a/src/ll/api/event/world/FireSpreadEvent.cpp +++ b/src/ll/api/event/world/FireSpreadEvent.cpp @@ -20,7 +20,7 @@ LL_TYPE_INSTANCE_HOOK( FireSpreadEventHook1, HookPriority::Normal, FireBlock, - "?onPlace@FireBlock@@UEBAXAEAVBlockSource@@AEBVBlockPos@@@Z", + &FireBlock::onPlace$, void, BlockSource& blockSource, BlockPos const& blockPos @@ -34,7 +34,7 @@ LL_TYPE_INSTANCE_HOOK( FireSpreadEventHook2, HookPriority::Normal, FireBlock, - "?mayPlace@FireBlock@@UEBA_NAEAVBlockSource@@AEBVBlockPos@@@Z", + &FireBlock::mayPlace$, bool, BlockSource& blockSource, BlockPos const& blockPos diff --git a/src/ll/api/i18n/I18n.h b/src/ll/api/i18n/I18n.h index e3f03a8791..51d8329987 100644 --- a/src/ll/api/i18n/I18n.h +++ b/src/ll/api/i18n/I18n.h @@ -57,8 +57,8 @@ namespace ll::i18n::detail { template struct TrStrOut; #ifndef LL_I18N_COLLECT_STRINGS_CUSTOM - template - struct TrStrOut { +template +struct TrStrOut { static inline int _ = [] { fmt::print("\"{0}\": \"{0}\", // at {1}\n", str.sv(), str.loc().toString()); return 0; diff --git a/src/ll/api/memory/Hook.h b/src/ll/api/memory/Hook.h index 0d6003c293..d9bb4ecad8 100644 --- a/src/ll/api/memory/Hook.h +++ b/src/ll/api/memory/Hook.h @@ -63,12 +63,6 @@ constexpr FuncPtr resolveIdentifier(T identifier) { return toFuncPtr(identifier); } -// TODO: remove in release -template -constexpr FuncPtr resolveIdentifier(std::string_view identifier) { - return SymbolView{identifier}.resolve(); -} - template constexpr FuncPtr resolveIdentifier(SignatureView identifier) { return identifier.resolve(); @@ -165,7 +159,7 @@ struct LL_EBO Hook {}; if constexpr (::ll::memory::virtualDetector()) { \ static_assert( \ ::ll::traits::always_false, \ - #IDENTIFIER " is a virtual function, you need use prefix $ workaround to hook it." \ + #IDENTIFIER " is a virtual function, you need use suffix $ workaround to hook it." \ ); \ } \ } \ diff --git a/src/ll/api/memory/Signature.h b/src/ll/api/memory/Signature.h index 083d9eb1a2..075d1a0465 100644 --- a/src/ll/api/memory/Signature.h +++ b/src/ll/api/memory/Signature.h @@ -158,11 +158,11 @@ inline void* signatureAddressCache = signatureCache.view().resolve(); namespace ll::inline literals::inline memory_literals { template -consteval memory::SignatureView operator""_sigv() noexcept { +consteval memory::SignatureView operator""_sig() noexcept { return memory::signatureCache.view(); } template -constexpr void* operator""_sig() noexcept { +constexpr void* operator""_sigp() noexcept { return memory::signatureAddressCache; } } // namespace ll::inline literals::inline memory_literals diff --git a/src/ll/api/memory/Symbol.h b/src/ll/api/memory/Symbol.h index b3262c894d..efdea36e6c 100644 --- a/src/ll/api/memory/Symbol.h +++ b/src/ll/api/memory/Symbol.h @@ -78,11 +78,11 @@ inline void* symbolAddressCache = symbol.view().resolve(); namespace ll::inline literals::inline memory_literals { template -consteval memory::SymbolView operator""_symv() noexcept { +consteval memory::SymbolView operator""_sym() noexcept { return symbol.view(); } template -constexpr void* operator""_sym() noexcept { +constexpr void* operator""_symp() noexcept { return memory::symbolAddressCache; } } // namespace ll::inline literals::inline memory_literals diff --git a/src/mc/_HeaderOutputPredefine.h b/src/mc/_HeaderOutputPredefine.h index 5dbf69fb5e..11187cf544 100644 --- a/src/mc/_HeaderOutputPredefine.h +++ b/src/mc/_HeaderOutputPredefine.h @@ -98,6 +98,7 @@ #include "rapidjson/stringbuffer.h" #include "rapidjson/writer.h" +#include "ll/api/base/Alias.h" #include "ll/api/base/StdInt.h" #include "ll/api/memory/Memory.h" @@ -153,16 +154,4 @@ using http_wstring = std::basic_string, class namespace asio::ssl { class verify_context; } -namespace ll { -template -struct CArray { - using type = T[N]; -}; -template -struct CArray { - using type = T[]; -}; -template -using CArrayT = typename CArray::type; -} // namespace ll // clang-format on diff --git a/src/mc/deps/core/utility/MCRESULT.h b/src/mc/deps/core/utility/MCRESULT.h index 8048e0bd16..6d98b20cac 100644 --- a/src/mc/deps/core/utility/MCRESULT.h +++ b/src/mc/deps/core/utility/MCRESULT.h @@ -22,54 +22,54 @@ struct MCRESULT { // NOLINTEND }; -MCAPI extern struct MCRESULT const MCRESULT_NoTargetsFound; +MCAPI MCRESULT const& MCRESULT_NoTargetsFound(); -MCAPI extern struct MCRESULT const MCRESULT_CommandExecIncomplete; +MCAPI MCRESULT const& MCRESULT_CommandExecIncomplete(); -MCAPI extern struct MCRESULT const MCRESULT_InvalidCommandCall; +MCAPI MCRESULT const& MCRESULT_InvalidCommandCall(); -MCAPI extern struct MCRESULT const MCRESULT_AllTargetsWillFail; +MCAPI MCRESULT const& MCRESULT_AllTargetsWillFail(); -MCAPI extern struct MCRESULT const MCRESULT_NoChatPermissions; +MCAPI MCRESULT const& MCRESULT_NoChatPermissions(); -MCAPI extern struct MCRESULT const MCRESULT_ChatMuted; +MCAPI MCRESULT const& MCRESULT_ChatMuted(); -MCAPI extern struct MCRESULT const MCRESULT_TooManyPendingRequests; +MCAPI MCRESULT const& MCRESULT_TooManyPendingRequests(); -MCAPI extern struct MCRESULT const MCRESULT_ExpectedRequestMsg; +MCAPI MCRESULT const& MCRESULT_ExpectedRequestMsg(); -MCAPI extern struct MCRESULT const MCRESULT_MustSpecifyVersion; +MCAPI MCRESULT const& MCRESULT_MustSpecifyVersion(); -MCAPI extern struct MCRESULT const MCRESULT_CommandsDisabled; +MCAPI MCRESULT const& MCRESULT_CommandsDisabled(); -MCAPI extern struct MCRESULT const MCRESULT_NotEnoughPermissions; +MCAPI MCRESULT const& MCRESULT_NotEnoughPermissions(); -MCAPI extern struct MCRESULT const MCRESULT_MalformedRequest; +MCAPI MCRESULT const& MCRESULT_MalformedRequest(); -MCAPI extern struct MCRESULT const MCRESULT_CommandStepDone; +MCAPI MCRESULT const& MCRESULT_CommandStepDone(); -MCAPI extern struct MCRESULT const MCRESULT_CommandRequestInitiated; +MCAPI MCRESULT const& MCRESULT_CommandRequestInitiated(); -MCAPI extern struct MCRESULT const MCRESULT_FailedToParseCommand; +MCAPI MCRESULT const& MCRESULT_FailedToParseCommand(); -MCAPI extern struct MCRESULT const MCRESULT_NewCommandVersionAvailable; +MCAPI MCRESULT const& MCRESULT_NewCommandVersionAvailable(); -MCAPI extern struct MCRESULT const MCRESULT_ExecutionFail; +MCAPI MCRESULT const& MCRESULT_ExecutionFail(); -MCAPI extern struct MCRESULT const MCRESULT_Success; +MCAPI MCRESULT const& MCRESULT_Success(); -MCAPI extern struct MCRESULT const MCRESULT_InvalidCommandContext; +MCAPI MCRESULT const& MCRESULT_InvalidCommandContext(); -MCAPI extern struct MCRESULT const MCRESULT_CommandStepFail; +MCAPI MCRESULT const& MCRESULT_CommandStepFail(); -MCAPI extern struct MCRESULT const MCRESULT_CommandNotFound; +MCAPI MCRESULT const& MCRESULT_CommandNotFound(); -MCAPI extern struct MCRESULT const MCRESULT_CommandVersionMismatch; +MCAPI MCRESULT const& MCRESULT_CommandVersionMismatch(); -MCAPI extern struct MCRESULT const MCRESULT_InvalidOverloadSyntax; +MCAPI MCRESULT const& MCRESULT_InvalidOverloadSyntax(); -MCAPI extern struct MCRESULT const MCRESULT_VersionMismatch; +MCAPI MCRESULT const& MCRESULT_VersionMismatch(); -MCAPI extern struct MCRESULT const MCRESULT_EncryptionRequired; +MCAPI MCRESULT const& MCRESULT_EncryptionRequired(); -MCAPI extern struct MCRESULT const MCRESULT_FailWithoutFailMsg; +MCAPI MCRESULT const& MCRESULT_FailWithoutFailMsg(); diff --git a/src/mc/deps/core/utility/typeid_t.cpp b/src/mc/deps/core/utility/typeid_t.cpp index 491a3d8583..c6a0704527 100644 --- a/src/mc/deps/core/utility/typeid_t.cpp +++ b/src/mc/deps/core/utility/typeid_t.cpp @@ -8,20 +8,20 @@ using namespace ll::literals; template <> std::atomic_ushort& Bedrock::typeid_t::_getCounter() { return *(std::atomic_ushort*)"?storage@?1??_getCounter@?$typeid_t@VCommandRegistry@@@Bedrock@@CAAEAU?$atomic@G@std@" - "@XZ@4U45@A"_sym; + "@XZ@4U45@A"_symp; } #define LL_TYPEID_STORAGE_SYMBOL(TYPE, SYMBOL) \ template <> \ Bedrock::typeid_t Bedrock::type_id() { \ static auto* id = \ (Bedrock::typeid_t*)"?id@?1???$type_id@VCommandRegistry@@" SYMBOL \ - "@Bedrock@@YA?AV?$typeid_t@VCommandRegistry@@@1@XZ@4V21@A"_sigv \ + "@Bedrock@@YA?AV?$typeid_t@VCommandRegistry@@@1@XZ@4V21@A"_sig \ \ \ .resolve(true); \ if (!id) { \ static auto* fn = (Bedrock::typeid_t(*)() \ - ) "??$type_id@VCommandRegistry@@" SYMBOL "@Bedrock@@YA?AV?$typeid_t@VCommandRegistry@@@0@XZ"_sigv \ + ) "??$type_id@VCommandRegistry@@" SYMBOL "@Bedrock@@YA?AV?$typeid_t@VCommandRegistry@@@0@XZ"_sig \ \ \ .resolve(); \ diff --git a/src/mc/network/NetworkIdentifier.cpp b/src/mc/network/NetworkIdentifier.cpp index dc482f95e0..1cef8ddd2d 100644 --- a/src/mc/network/NetworkIdentifier.cpp +++ b/src/mc/network/NetworkIdentifier.cpp @@ -8,7 +8,7 @@ std::string NetworkIdentifier::getIPAndPort() const { return ll::service::getRakPeer() .and_then([&](auto& peer) -> std::optional { auto address = peer.GetSystemAddressFromGuid(mGuid); - if (address != RakNet::UNASSIGNED_SYSTEM_ADDRESS) { + if (address != RakNet::UNASSIGNED_SYSTEM_ADDRESS()) { return address; } return std::nullopt; diff --git a/src/mc/server/AllowListEntry.h b/src/mc/server/AllowListEntry.h index 420c4bc8bc..2e0fe66970 100644 --- a/src/mc/server/AllowListEntry.h +++ b/src/mc/server/AllowListEntry.h @@ -18,12 +18,7 @@ class AllowListEntry : public ::IJsonSerializable { std::string mXuid; // 56 bool mIgnoresPlayerLimit; // 88 - AllowListEntry( - std::string name, - std::string xuid, - mce::UUID uuid = mce::UUID::EMPTY, - bool ignoresPlayerLimit = false - ) + AllowListEntry(std::string name, std::string xuid, mce::UUID uuid = {}, bool ignoresPlayerLimit = false) : mName(std::move(name)), mUuid(uuid), mXuid(std::move(xuid)), diff --git a/src/mc/server/ServerInstance.h b/src/mc/server/ServerInstance.h index 79c0ba81ec..7e1c8d170e 100644 --- a/src/mc/server/ServerInstance.h +++ b/src/mc/server/ServerInstance.h @@ -23,13 +23,16 @@ namespace cereal { struct ReflectionCtx; } namespace mce { class UUID; } // clang-format on +class IMinecraftApp; +class ServerInstanceEventCoordinator; + class ServerInstance : public ::Bedrock::EnableNonOwnerReferences, public ::AppPlatformListener, public ::GameCallbacks, public ::Core::StorageAreaStateListener { public: std::chrono::steady_clock::time_point mLastSyncTime; - class IMinecraftApp const& mApp; + IMinecraftApp const& mApp; std::unique_ptr mMinecraft; // other... diff --git a/src/mc/server/commands/CommandContext.h b/src/mc/server/commands/CommandContext.h index bc6375d85d..06fac6f481 100644 --- a/src/mc/server/commands/CommandContext.h +++ b/src/mc/server/commands/CommandContext.h @@ -14,7 +14,7 @@ class CommandContext { [[nodiscard]] explicit CommandContext(std::string command, Args&&... args) : mCommand(std::move(command)), mOrigin(std::make_unique(std::forward(args)...)), - mVersion(CommandVersion::CurrentVersion) {} + mVersion(CommandVersion::CurrentVersion()) {} public: // NOLINTBEGIN @@ -22,7 +22,7 @@ class CommandContext { CommandContext( std::string const& command, std::unique_ptr origin, - int version = CommandVersion::CurrentVersion + int version = CommandVersion::CurrentVersion() ); MCAPI class CommandOrigin const& getCommandOrigin() const; diff --git a/src/mc/world/Container.cpp b/src/mc/world/Container.cpp index 4f1141cf26..47a10aae75 100644 --- a/src/mc/world/Container.cpp +++ b/src/mc/world/Container.cpp @@ -3,7 +3,7 @@ optional_ref Container::getItemNonConst(int index) { auto& item = getItem(index); - if (&item != &ItemStack::EMPTY_ITEM) { + if (&item != &ItemStack::EMPTY_ITEM()) { return const_cast(item); } return std::nullopt;