Skip to content

Commit

Permalink
Fixed LuaInterpreter compilation with default options turned off
Browse files Browse the repository at this point in the history
  • Loading branch information
DarkWanderer committed Dec 31, 2024
1 parent 6a0d8c7 commit a414111
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
19 changes: 12 additions & 7 deletions Src/Module/LuaScript/LuaInterpreter/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ set(BUILD_OUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/out)
add_library(LuaInterpreter SHARED
Interpreter.cpp
lua_vessel_mtd.cpp
lua_xrsound.cpp
)

target_include_directories(LuaInterpreter
Expand All @@ -21,18 +20,24 @@ target_link_libraries(LuaInterpreter
${ORBITER_LIB}
${ORBITER_SDK_LIB}
lua::lib
XRSound_lib
)

add_dependencies(LuaInterpreter
${OrbiterTgt}
Orbitersdk
D3D9Client
D3D9Client_Interface
XRSound_lib
XRSound_assets
)

if(ORBITER_BUILD_D3D9CLIENT)
add_dependencies(LuaInterpreter D3D9Client D3D9Client_Interface)
endif()

if(ORBITER_BUILD_XRSOUND)
add_dependencies(LuaInterpreter XRSound_lib XRSound_assets)
target_link_libraries(LuaInterpreter XRSound_lib)
target_compile_definitions(LuaInterpreter PRIVATE ENABLE_XRSOUND)
target_sources(LuaInterpreter PRIVATE lua_xrsound.cpp)
endif()

set_target_properties(LuaInterpreter
PROPERTIES
FOLDER Modules/Lua
Expand Down Expand Up @@ -85,4 +90,4 @@ install(TARGETS LuaInterpreter
)
install(FILES $<TARGET_LINKER_FILE:LuaInterpreter>
DESTINATION ${ORBITER_INSTALL_SDK_DIR}/lib/Lua
)
)
4 changes: 4 additions & 0 deletions Src/Module/LuaScript/LuaInterpreter/Interpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,9 @@ void Interpreter::Initialise ()
LoadSketchpadAPI (); // load Sketchpad methods
LoadAnnotationAPI (); // load screen annotation methods
LoadVesselStatusAPI ();
#ifdef ENABLE_XRSOUND
LoadXRSoundAPI ();
#endif
LoadStartupScript (); // load default initialisation script
}

Expand Down Expand Up @@ -1055,12 +1057,14 @@ void Interpreter::LoadAPI ()
};
luaL_openlib (L, "term", termLib, 0);

#ifdef ENABLE_XRSOUND
// Load XRSound library
static const struct luaL_reg XRSoundLib[] = {
{"create_instance", xrsound_create_instance},
{NULL, NULL}
};
luaL_openlib (L, "xrsound", XRSoundLib, 0);
#endif // ENABLE_XRSOUND

// Set up global tables of constants

Expand Down
2 changes: 2 additions & 0 deletions Src/Module/LuaScript/LuaInterpreter/Interpreter.h
Original file line number Diff line number Diff line change
Expand Up @@ -1114,6 +1114,7 @@ class INTERPRETERLIB Interpreter {
// -------------------------------------------
// XRSound
// -------------------------------------------
#ifdef ENABLE_XRSOUND
virtual void LoadXRSoundAPI ();
static int lua_isxrsound(lua_State *L, int idx);
static XRSound *lua_toxrsound(lua_State *L, int idx);
Expand All @@ -1137,6 +1138,7 @@ class INTERPRETERLIB Interpreter {
static int xrsound_set_playposition(lua_State *L);
static int xrsound_get_playposition(lua_State *L);
static int xrsound_collect(lua_State *L);
#endif

private:
HANDLE hExecMutex; // flow control synchronisation
Expand Down

0 comments on commit a414111

Please sign in to comment.