LuaMenu: load LuaSocket socket.lua from the base VFS#3078
Conversation
CLuaMenu::InitLuaSocket looked for a bare 'socket.lua' in the default VFS (SPRING_VFS_RAW_FIRST), which never resolved: the file actually ships in springcontent.sdz at LuaSocket/socket.lua. As a result the menu/lobby's LuaSocket layer failed to initialise and logged 'Error loading socket.lua', so Chobby could not connect to multiplayer servers. Load it from SPRING_VFS_BASE using the correct LuaSocket/socket.lua path, with a FileExists guard, exactly matching the working CLuaUI::InitLuaSocket. This is a general VFS-path bug, not platform-specific. Ported from ExaDev/RecoilEngine e9ca215.
sprunk
left a comment
There was a problem hiding this comment.
The function seems to be the same in LuaUI and LuaMenu now so should probably be extracted into /rts/Lua/LuaLibs.cpp as something like LuaLibs::OpenLuaSocket.
|
@sprunk The shared body ends with As both Something like this: |
|
Sounds okay. Being in |
CLuaUI and CLuaMenu had identical InitLuaSocket bodies after beyond-all-reason#3078. Commonise as a protected CLuaHandle::InitLuaSocket so both inherit a single source of truth, per sprunk's review on beyond-all-reason#3078. A free LuaLibs::OpenLuaSocket would require making the privileged CLuaHandle::LoadCode public (templating a free function does not grant access to a protected member), so the protected-member form sprunk also OK'd is used instead.
What
CLuaMenu::InitLuaSocketloaded a bare"socket.lua"from the default VFS(
SPRING_VFS_RAW_FIRST). That path never resolves: the file actually ships inspringcontent.sdzatLuaSocket/socket.lua. So the menu/lobby's LuaSocketlayer never initialised, logged
Error loading socket.lua, and Chobby couldnot connect to multiplayer servers.
It now loads
LuaSocket/socket.luafromSPRING_VFS_BASEwith aFileExistsguard, exactly matching the already-correct
CLuaUI::InitLuaSocket.Why this is cross-platform
This is a general VFS-path bug, not platform-specific. The lookup fails on every
platform because the requested path/mode never matched the file's actual
location in the base content; it merely surfaced first during macOS lobby
testing. The fix brings the menu's socket init in line with the in-game UI's,
which has always used the correct path and mode.
Verification
engine-headlessbuilds on macOS with the change (LuaMenu.cpprecompiled,spring-headlesslinked). Building alone does not exercise the runtime path;functional verification (lobby connecting to a multiplayer server via Chobby)
is recommended. The mechanism is straightforward:
socket.luanow resolvesfrom the base VFS, so
luaopen_socket_coreplus the Lua wrapper initialise.Provenance
Ported from
e9ca2151b5in ExaDev/RecoilEngine.AI disclosure
Diagnosis and patch prepared with AI assistance (Claude). The change is a small,
verbatim alignment with existing
CLuaUI::InitLuaSocket; reviewed and builtlocally by a human.