diff --git a/apps/openmw-mp/CMakeLists.txt b/apps/openmw-mp/CMakeLists.txt index 80e0f8d0c..99d96e910 100644 --- a/apps/openmw-mp/CMakeLists.txt +++ b/apps/openmw-mp/CMakeLists.txt @@ -29,7 +29,7 @@ if(BUILD_WITH_LUA) Script/LangLua/LangLua.hpp) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DENABLE_LUA") - include_directories(${LuaJit_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/extern/LuaBridge) + include_directories(SYSTEM ${LuaJit_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/extern/LuaBridge) endif(BUILD_WITH_LUA) set(NativeScript_Sources @@ -152,7 +152,17 @@ add_executable(tes3mp-server ${PROCESSORS_ACTOR} ${PROCESSORS_PLAYER} ${PROCESSORS_OBJECT} ${PROCESSORS_WORLDSTATE} ${PROCESSORS} ${APPLE_BUNDLE_RESOURCES} ) -add_definitions(-std=gnu++14 -Wno-ignored-qualifiers) + +target_compile_options(tes3mp-server PRIVATE $<$:/permissive->) +set_target_properties(tes3mp-server PROPERTIES + CXX_STANDARD 14 + CXX_STANDARD_REQUIRED YES + CXX_EXTENSIONS YES +) + +if (UNIX) + target_compile_options(tes3mp-server PRIVATE -Wno-ignored-qualifiers) +endif() target_link_libraries(tes3mp-server #${Boost_SYSTEM_LIBRARY} diff --git a/apps/openmw-mp/Script/LangLua/LangLua.cpp b/apps/openmw-mp/Script/LangLua/LangLua.cpp index b3f840a66..4632c1e56 100644 --- a/apps/openmw-mp/Script/LangLua/LangLua.cpp +++ b/apps/openmw-mp/Script/LangLua/LangLua.cpp @@ -107,18 +107,37 @@ template<> struct F_<1> { static constexpr LuaFuctionData F{"CreateTimerEx", Lan template<> struct F_<2> { static constexpr LuaFuctionData F{"MakePublic", LangLua::MakePublic}; }; template<> struct F_<3> { static constexpr LuaFuctionData F{"CallPublic", LangLua::CallPublic}; }; -template -inline LuaFuctionData *LangLua::functions(indices) +template +struct C +{ + constexpr C(LuaFuctionData *functions_) + { + functions_[I] = F_::F; + C::C(functions_); + } +}; + + +template<> +struct C<0> +{ + constexpr C(LuaFuctionData *functions_) + { + functions_[0] = F_<0>::F; + } +}; + +template +LuaFuctionData *functions() { - static LuaFuctionData functions_[sizeof...(Indices)]{ - F_::F... - }; + static LuaFuctionData functions_[LastI]; + C::C(functions_); static_assert( - sizeof(functions_) / sizeof(functions_[0]) == - sizeof(ScriptFunctions::functions) / sizeof(ScriptFunctions::functions[0]), - "Not all functions have been mapped to Lua"); + sizeof(functions_) / sizeof(functions_[0]) == + sizeof(ScriptFunctions::functions) / sizeof(ScriptFunctions::functions[0]), + "Not all functions have been mapped to Lua"); return functions_; } @@ -133,7 +152,7 @@ void LangLua::LoadProgram(const char *filename) constexpr auto functions_n = sizeof(ScriptFunctions::functions) / sizeof(ScriptFunctions::functions[0]); - LuaFuctionData *functions_ = functions(IndicesFor{}); + LuaFuctionData *functions_ = functions(); luabridge::Namespace tes3mp = luabridge::getGlobalNamespace(lua).beginNamespace("tes3mp"); diff --git a/apps/openmw-mp/Script/LangLua/LangLua.hpp b/apps/openmw-mp/Script/LangLua/LangLua.hpp index 1f81093f6..adf0cc2b6 100644 --- a/apps/openmw-mp/Script/LangLua/LangLua.hpp +++ b/apps/openmw-mp/Script/LangLua/LangLua.hpp @@ -23,20 +23,8 @@ struct LuaFuctionData class LangLua: public Language { -private: - template - struct indices {}; - template - struct build_indices : build_indices {}; - template - struct build_indices<0, Is...> : indices {}; - template - using IndicesFor = build_indices; - public: virtual lib_t GetInterface() override; - template - static LuaFuctionData* functions(indices); lua_State *lua; public: LangLua(); diff --git a/apps/openmw-mp/Script/ScriptFunctions.hpp b/apps/openmw-mp/Script/ScriptFunctions.hpp index 1c337f102..6cd590a8f 100644 --- a/apps/openmw-mp/Script/ScriptFunctions.hpp +++ b/apps/openmw-mp/Script/ScriptFunctions.hpp @@ -30,6 +30,10 @@ #include +#ifndef __PRETTY_FUNCTION__ +#define __PRETTY_FUNCTION__ __FUNCTION__ +#endif + #define GET_PLAYER(pid, pl, retvalue) \ pl = Players::getPlayer(pid); \ if (player == 0) {\ @@ -116,9 +120,9 @@ public: static constexpr ScriptFunctionData functions[]{ {"CreateTimer", ScriptFunctions::CreateTimer}, - {"CreateTimerEx", reinterpret_cast>(ScriptFunctions::CreateTimerEx)}, + {"CreateTimerEx", ScriptFunctions::CreateTimerEx}, {"MakePublic", ScriptFunctions::MakePublic}, - {"CallPublic", reinterpret_cast>(ScriptFunctions::CallPublic)}, + {"CallPublic", ScriptFunctions::CallPublic}, {"StartTimer", ScriptFunctions::StartTimer}, {"StopTimer", ScriptFunctions::StopTimer}, diff --git a/apps/openmw-mp/Script/Types.hpp b/apps/openmw-mp/Script/Types.hpp index 88f4ce834..84ac651db 100644 --- a/apps/openmw-mp/Script/Types.hpp +++ b/apps/openmw-mp/Script/Types.hpp @@ -102,10 +102,10 @@ struct CallbackIdentity struct ScriptFunctionPointer : public ScriptIdentity { - Function addr; + void *addr; template - constexpr ScriptFunctionPointer(Function addr) : ScriptIdentity(addr), addr(reinterpret_cast>(addr)) {} + constexpr ScriptFunctionPointer(Function addr) : ScriptIdentity(addr), addr(addr) {} }; struct ScriptFunctionData