From 29955df947dc4d6841f69d2f4f0c14d7993e8c7c Mon Sep 17 00:00:00 2001 From: foxtacles Date: Sun, 1 Mar 2026 18:21:15 -0800 Subject: [PATCH] Export MultiplayerExt symbols accessed from isle executable (#1) * Export MultiplayerExt symbols accessed from isle executable When lego1 is built as a shared library (DLL), symbols used by the isle executable through the Extension::Call() template need to be exported. Add LEGO1_EXPORT to MultiplayerExt::enabled and MultiplayerExt::CheckRejected() which are referenced from isleapp.cpp via the template instantiation. https://claude.ai/code/session_01HHMmowothg25fephi6iidq * Use inline const instead of constexpr for extension function pointers constexpr cannot be used with dllimport function addresses since they are resolved at load time through the IAT, not at compile time. Change to inline const which preserves the single-definition semantics (via inline) while allowing runtime initialization of the function pointers. https://claude.ai/code/session_01HHMmowothg25fephi6iidq * Fix multiplayer extension link errors across DLL boundary When lego1 is a shared library, Extension::Call() instantiated from isle.exe references MultiplayerExt::enabled and CheckRejected() which are not exported. Instead of exporting internal symbols (which also breaks constexpr with dllimport), add an exported IsMultiplayerRejected() wrapper that keeps the Extension::Call() instantiation inside lego1. https://claude.ai/code/session_01HHMmowothg25fephi6iidq * Guard IsMultiplayerRejected with EXTENSIONS ifdef extensions.cpp is only compiled when ISLE_EXTENSIONS is ON, so the wrapper function and its call site need #ifdef EXTENSIONS guards for targets like x86 MSVC where extensions are disabled. https://claude.ai/code/session_01HHMmowothg25fephi6iidq * Move IsMultiplayerRejected definition to multiplayer.cpp The function is declared in multiplayer.h and belongs with the rest of the multiplayer extension code, not in the general extensions.cpp file. https://claude.ai/code/session_01HHMmowothg25fephi6iidq --------- Co-authored-by: Claude --- ISLE/isleapp.cpp | 5 +++-- extensions/include/extensions/multiplayer.h | 2 ++ extensions/src/multiplayer.cpp | 6 ++++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/ISLE/isleapp.cpp b/ISLE/isleapp.cpp index ac33af6b..87147982 100644 --- a/ISLE/isleapp.cpp +++ b/ISLE/isleapp.cpp @@ -37,7 +37,6 @@ #include "viewmanager/viewmanager.h" #include -#include #include #include #include @@ -1297,10 +1296,12 @@ inline bool IsleApp::Tick() return true; } - if (Extension::Call(CheckRejected).value_or(FALSE)) { +#ifdef EXTENSIONS + if (Extensions::IsMultiplayerRejected()) { g_closed = TRUE; return true; } +#endif if (!TickleManager()) { return true; diff --git a/extensions/include/extensions/multiplayer.h b/extensions/include/extensions/multiplayer.h index 21cd94d0..840f8359 100644 --- a/extensions/include/extensions/multiplayer.h +++ b/extensions/include/extensions/multiplayer.h @@ -45,6 +45,8 @@ class MultiplayerExt { }; #ifdef EXTENSIONS +LEGO1_EXPORT bool IsMultiplayerRejected(); + constexpr auto HandleWorldEnable = &MultiplayerExt::HandleWorldEnable; constexpr auto HandleEntityNotify = &MultiplayerExt::HandleEntityNotify; constexpr auto CheckRejected = &MultiplayerExt::CheckRejected; diff --git a/extensions/src/multiplayer.cpp b/extensions/src/multiplayer.cpp index 285ce04b..05cf9a79 100644 --- a/extensions/src/multiplayer.cpp +++ b/extensions/src/multiplayer.cpp @@ -1,5 +1,6 @@ #include "extensions/multiplayer.h" +#include "extensions/extensions.h" #include "extensions/multiplayer/networkmanager.h" #include "extensions/multiplayer/networktransport.h" #include "extensions/multiplayer/protocol.h" @@ -118,3 +119,8 @@ Multiplayer::NetworkManager* MultiplayerExt::GetNetworkManager() { return s_networkManager; } + +bool Extensions::IsMultiplayerRejected() +{ + return Extension::Call(CheckRejected).value_or(FALSE); +}