diff --git a/apps/openmw-mp/CMakeLists.txt b/apps/openmw-mp/CMakeLists.txt index b213a39ac..01ab959df 100644 --- a/apps/openmw-mp/CMakeLists.txt +++ b/apps/openmw-mp/CMakeLists.txt @@ -14,31 +14,6 @@ if(ENABLE_BREAKPAD) include_directories(${CMAKE_SOURCE_DIR}/extern/breakpad/src ${Breakpad_Headers}) endif(ENABLE_BREAKPAD) -option(BUILD_WITH_LUA "Enable Lua language" ON) -if(BUILD_WITH_LUA) - - find_package(LuaJit REQUIRED) - - MESSAGE(STATUS "Found LuaJit_LIBRARIES: ${LuaJit_LIBRARIES}") - MESSAGE(STATUS "Found LuaJit_INCLUDE_DIRS: ${LuaJit_INCLUDE_DIRS}") - - set(LuaScript_Sources - Script/LangLua/LangLua.cpp - Script/LangLua/LuaFunc.cpp) - set(LuaScript_Headers - Script/LangLua/LangLua.hpp) - - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DENABLE_LUA") - include_directories(SYSTEM ${LuaJit_INCLUDE_DIRS} SYSTEM ${CMAKE_SOURCE_DIR}/extern/LuaBridge) -endif(BUILD_WITH_LUA) - -set(NativeScript_Sources - Script/LangNative/LangNative.cpp - ) -set(NativeScript_Headers - Script/LangNative/LangNative.hpp - ) - # local files set(SERVER main.cpp @@ -48,8 +23,8 @@ set(SERVER Cell.cpp CellController.cpp Utils.cpp - Script/Script.cpp Script/ScriptFunction.cpp - Script/ScriptFunctions.cpp + Script/Plugin.cpp + Script/Callbacks.cpp Script/Functions/Actors.cpp Script/Functions/Objects.cpp Script/Functions/Miscellaneous.cpp Script/Functions/Worldstate.cpp @@ -60,20 +35,15 @@ set(SERVER Script/Functions/Positions.cpp Script/Functions/Quests.cpp Script/Functions/RecordsDynamic.cpp Script/Functions/Server.cpp Script/Functions/Settings.cpp Script/Functions/Shapeshift.cpp Script/Functions/Spells.cpp Script/Functions/Stats.cpp Script/Functions/Timer.cpp - Script/Functions/Public.cpp + Script/Functions/Public.cpp Script/FFI.cpp Script/API/TimerAPI.cpp Script/API/PublicFnAPI.cpp - ${LuaScript_Sources} - ${NativeScript_Sources} - ) set(SERVER_HEADER - Script/Types.hpp Script/Script.hpp Script/SystemInterface.hpp - Script/ScriptFunction.hpp Script/Platform.h Script/Language.hpp - Script/ScriptFunctions.hpp Script/API/TimerAPI.hpp Script/API/PublicFnAPI.hpp - ${LuaScript_Headers} - ${NativeScript_Headers} + Script/Types.hpp Script/Plugin.hpp Script/SystemInterface.hpp + Script/Platform.h + Script/Callbacks.hpp Script/API/TimerAPI.hpp Script/API/PublicFnAPI.hpp Script/FFI.hpp ) source_group(tes3mp-server FILES ${SERVER} ${SERVER_HEADER}) @@ -154,6 +124,8 @@ add_executable(tes3mp-server ${APPLE_BUNDLE_RESOURCES} ) +target_compile_definitions(tes3mp-server PRIVATE _HOST) + target_compile_options(tes3mp-server PRIVATE $<$:/permissive->) if (OPENMW_MP_BUILD) @@ -161,7 +133,7 @@ if (OPENMW_MP_BUILD) endif() set_target_properties(tes3mp-server PROPERTIES - CXX_STANDARD 14 + CXX_STANDARD 17 CXX_STANDARD_REQUIRED YES CXX_EXTENSIONS YES ) @@ -203,6 +175,11 @@ if (MSVC) add_definitions("-D_USE_MATH_DEFINES") endif (MSVC) + +find_package(LibFFI REQUIRED) +include_directories(SYSTEM ${LIBFFI_INCLUDE_DIR}) +target_link_libraries(tes3mp-server ${LIBFFI_LIBRARIES}) + if (ENABLE_PVS) pvs_studio_add_target(TARGET tes3mp-server.analyze ALL OUTPUT FORMAT errorfile diff --git a/apps/openmw-mp/Cell.cpp b/apps/openmw-mp/Cell.cpp index f6138251d..06e6ffcc1 100644 --- a/apps/openmw-mp/Cell.cpp +++ b/apps/openmw-mp/Cell.cpp @@ -8,7 +8,7 @@ #include #include "Player.hpp" -#include "Script/Script.hpp" +#include "Script/Plugin.hpp" using namespace std; @@ -34,7 +34,8 @@ void Cell::addPlayer(Player *player) if (it != end()) { - LOG_APPEND(Log::LOG_INFO, "- Attempt to add %s to Cell %s again was ignored", player->npc.mName.c_str(), getDescription().c_str()); + LOG_APPEND(Log::LOG_INFO, "- Attempt to add %s to Cell %s again was ignored", player->npc.mName.c_str(), + getDescription().c_str()); return; } @@ -48,9 +49,12 @@ void Cell::addPlayer(Player *player) LOG_APPEND(Log::LOG_INFO, "- Adding %s to Cell %s", player->npc.mName.c_str(), getDescription().c_str()); - Script::Call(player->getId(), getDescription().c_str()); - - players.push_back(player); + PlayerId id = player->getId(); + if (id != InvalidPID) + { + Plugin::Call(id, getDescription().c_str()); + players.push_back(player); + } } void Cell::removePlayer(Player *player, bool cleanPlayer) @@ -72,7 +76,7 @@ void Cell::removePlayer(Player *player, bool cleanPlayer) LOG_APPEND(Log::LOG_INFO, "- Removing %s from Cell %s", player->npc.mName.c_str(), getDescription().c_str()); - Script::Call(player->getId(), getDescription().c_str()); + Plugin::Call(player->getId(), getDescription().c_str()); players.erase(it); return; diff --git a/apps/openmw-mp/CellController.cpp b/apps/openmw-mp/CellController.cpp index bdb3c4a87..88eb73969 100644 --- a/apps/openmw-mp/CellController.cpp +++ b/apps/openmw-mp/CellController.cpp @@ -3,7 +3,7 @@ #include #include "Cell.hpp" #include "Player.hpp" -#include "Script/Script.hpp" +#include "Script/Plugin.hpp" using namespace std; @@ -123,7 +123,7 @@ void CellController::removeCell(Cell *cell) { if (*it != nullptr && *it == cell) { - Script::Call(cell->getDescription().c_str()); + Plugin::Call(cell->getDescription().c_str()); LOG_APPEND(Log::LOG_INFO, "- Removing %s from CellController", cell->getDescription().c_str()); delete *it; diff --git a/apps/openmw-mp/MasterClient.cpp b/apps/openmw-mp/MasterClient.cpp index 92d96dab3..85a609dde 100644 --- a/apps/openmw-mp/MasterClient.cpp +++ b/apps/openmw-mp/MasterClient.cpp @@ -105,7 +105,7 @@ void MasterClient::SetRuleValue(const std::string &key, double value) mutexData.unlock(); } -void MasterClient::PushPlugin(const Plugin &plugin) +void MasterClient::PushPlugin(const _Plugin &plugin) { mutexData.lock(); queryData.plugins.push_back(plugin); diff --git a/apps/openmw-mp/MasterClient.hpp b/apps/openmw-mp/MasterClient.hpp index b8b80be33..9420e217d 100644 --- a/apps/openmw-mp/MasterClient.hpp +++ b/apps/openmw-mp/MasterClient.hpp @@ -26,7 +26,7 @@ public: void SetModname(const std::string &hostname); void SetRuleString(const std::string &key, std::string value); void SetRuleValue(const std::string &key, double value); - void PushPlugin(const Plugin &plugin); + void PushPlugin(const _Plugin &plugin); bool Process(RakNet::Packet *packet); void Start(); diff --git a/apps/openmw-mp/Networking.cpp b/apps/openmw-mp/Networking.cpp index 36f700ff0..bb7af4af9 100644 --- a/apps/openmw-mp/Networking.cpp +++ b/apps/openmw-mp/Networking.cpp @@ -10,7 +10,7 @@ #include #include -#include