forked from mirror/openmw-tes3mp
[Server] Introduce MS VC++ 2017 support
This commit is contained in:
parent
6af2400752
commit
55cea491ca
5 changed files with 48 additions and 27 deletions
|
@ -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 $<$<CXX_COMPILER_ID:MSVC>:/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}
|
||||
|
|
|
@ -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<size_t... Indices>
|
||||
inline LuaFuctionData *LangLua::functions(indices<Indices...>)
|
||||
template<unsigned int I>
|
||||
struct C
|
||||
{
|
||||
constexpr C(LuaFuctionData *functions_)
|
||||
{
|
||||
functions_[I] = F_<I>::F;
|
||||
C<I - 1>::C(functions_);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<>
|
||||
struct C<0>
|
||||
{
|
||||
constexpr C(LuaFuctionData *functions_)
|
||||
{
|
||||
functions_[0] = F_<0>::F;
|
||||
}
|
||||
};
|
||||
|
||||
template<size_t LastI>
|
||||
LuaFuctionData *functions()
|
||||
{
|
||||
|
||||
static LuaFuctionData functions_[sizeof...(Indices)]{
|
||||
F_<Indices>::F...
|
||||
};
|
||||
static LuaFuctionData functions_[LastI];
|
||||
C<LastI - 1>::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<functions_n>{});
|
||||
LuaFuctionData *functions_ = functions<sizeof(ScriptFunctions::functions) / sizeof(ScriptFunctions::functions[0])>();
|
||||
|
||||
luabridge::Namespace tes3mp = luabridge::getGlobalNamespace(lua).beginNamespace("tes3mp");
|
||||
|
||||
|
|
|
@ -23,20 +23,8 @@ struct LuaFuctionData
|
|||
|
||||
class LangLua: public Language
|
||||
{
|
||||
private:
|
||||
template<std::size_t... Is>
|
||||
struct indices {};
|
||||
template<std::size_t N, std::size_t... Is>
|
||||
struct build_indices : build_indices<N-1, N-1, Is...> {};
|
||||
template<std::size_t... Is>
|
||||
struct build_indices<0, Is...> : indices<Is...> {};
|
||||
template<std::size_t N>
|
||||
using IndicesFor = build_indices<N>;
|
||||
|
||||
public:
|
||||
virtual lib_t GetInterface() override;
|
||||
template<std::size_t... Indices>
|
||||
static LuaFuctionData* functions(indices<Indices...>);
|
||||
lua_State *lua;
|
||||
public:
|
||||
LangLua();
|
||||
|
|
|
@ -30,6 +30,10 @@
|
|||
|
||||
#include <components/openmw-mp/Log.hpp>
|
||||
|
||||
#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<Function<void>>(ScriptFunctions::CreateTimerEx)},
|
||||
{"CreateTimerEx", ScriptFunctions::CreateTimerEx},
|
||||
{"MakePublic", ScriptFunctions::MakePublic},
|
||||
{"CallPublic", reinterpret_cast<Function<void>>(ScriptFunctions::CallPublic)},
|
||||
{"CallPublic", ScriptFunctions::CallPublic},
|
||||
|
||||
{"StartTimer", ScriptFunctions::StartTimer},
|
||||
{"StopTimer", ScriptFunctions::StopTimer},
|
||||
|
|
|
@ -102,10 +102,10 @@ struct CallbackIdentity
|
|||
|
||||
struct ScriptFunctionPointer : public ScriptIdentity
|
||||
{
|
||||
Function<void> addr;
|
||||
void *addr;
|
||||
|
||||
template<typename R, typename... Types>
|
||||
constexpr ScriptFunctionPointer(Function<R, Types...> addr) : ScriptIdentity(addr), addr(reinterpret_cast<Function<void>>(addr)) {}
|
||||
constexpr ScriptFunctionPointer(Function<R, Types...> addr) : ScriptIdentity(addr), addr(addr) {}
|
||||
};
|
||||
|
||||
struct ScriptFunctionData
|
||||
|
|
Loading…
Reference in a new issue