From e2103d0beaf5ed5e4de1ef219b3de9792b819090 Mon Sep 17 00:00:00 2001 From: Kyle Cooley Date: Thu, 4 Jan 2018 21:40:17 -0500 Subject: [PATCH 1/3] Clean up find file for LuaJit, add one for Sol2 --- apps/openmw-mp/CMakeLists.txt | 7 +++---- cmake/FindLuaJit.cmake | 26 +++++++++----------------- cmake/FindSol2.cmake | 11 +++++++++++ 3 files changed, 23 insertions(+), 21 deletions(-) create mode 100644 cmake/FindSol2.cmake diff --git a/apps/openmw-mp/CMakeLists.txt b/apps/openmw-mp/CMakeLists.txt index 520d38c01..ec0280b0e 100644 --- a/apps/openmw-mp/CMakeLists.txt +++ b/apps/openmw-mp/CMakeLists.txt @@ -17,11 +17,11 @@ endif(ENABLE_BREAKPAD) find_package(LuaJit REQUIRED) +find_package(Sol2 REQUIRED) -set(LuaScript_Headers ${LUA_INCLUDE_DIR} ${CMAKE_SOURCE_DIR}/extern/sol/sol.hpp) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DENABLE_LUA") -include_directories(${LUA_INCLUDE_DIR} ${LUAJIT_INCLUDE_DIR} ${CMAKE_SOURCE_DIR}/extern/sol) +include_directories(${LuaJit_INCLUDE_DIR} ${Sol2_INCLUDE_DIR}) # local files @@ -145,8 +145,7 @@ target_link_libraries(tes3mp-server #${Boost_PROGRAM_OPTIONS_LIBRARY} ${RakNet_LIBRARY} components - ${LUA_LIBRARIES} - ${LUAJIT_LIBRARY} + ${LuaJit_LIBRARIES} ${Breakpad_Library} ) diff --git a/cmake/FindLuaJit.cmake b/cmake/FindLuaJit.cmake index de3fb8ab6..c05c3a809 100644 --- a/cmake/FindLuaJit.cmake +++ b/cmake/FindLuaJit.cmake @@ -1,22 +1,14 @@ -include(LibFindMacros) - -# Use pkg-config to get hints about paths -libfind_pkg_check_modules(LUAJIT_PKGCONF luajit) +# Once found, defines: +# LuaJit_FOUND +# LuaJit_INCLUDE_DIRS +# LuaJit_LIBRARIES -find_path(LUAJIT_INCLUDE_DIR - NAMES luajit.h - PATHS ${LUAJIT_PKGCONF_INCLUDE_DIRS} - ) - -find_library(LUAJIT_LIBRARY - NAMES luajit-5.1 luajit - PATHS ${LUAJIT_PKGCONF_LIBRARY_DIRS} - ) +include(LibFindMacros) -set(LUAJIT_PROCESS_INCLUDES LUAJIT_INCLUDE_DIR) -set(LUAJIT_PROCESS_LIBS LUAJIT_LIBRARY) +libfind_pkg_detect(LuaJit luajit + FIND_PATH luajit.h + FIND_LIBRARY NAMES luajit-5.1 luajit +) libfind_process(LuaJit) -set(LUA_LIBRARY LUAJIT_LIBRARY) -set(LUA_INCLUDE_DIR LUAJIT_INCLUDE_DIR) \ No newline at end of file diff --git a/cmake/FindSol2.cmake b/cmake/FindSol2.cmake new file mode 100644 index 000000000..68a6a3447 --- /dev/null +++ b/cmake/FindSol2.cmake @@ -0,0 +1,11 @@ +# Once found, defines: +# Sol2_FOUND +# Sol2_INCLUDE_DIRS + +include(LibFindMacros) + +libfind_pkg_detect(Sol2 sol2 + FIND_PATH sol.hpp +) +libfind_process(Sol2) + From fcd4d8b842338ac30453d46665bcc4a627dae1d3 Mon Sep 17 00:00:00 2001 From: Kyle Cooley Date: Thu, 4 Jan 2018 21:41:00 -0500 Subject: [PATCH 2/3] Fix build for gcc-5.4.0 --- apps/openmw/mwmp/DedicatedActor.cpp | 8 ++++---- components/openmw-mp/Base/BasePacketProcessor.hpp | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/apps/openmw/mwmp/DedicatedActor.cpp b/apps/openmw/mwmp/DedicatedActor.cpp index 302da0b82..b49cc6dce 100644 --- a/apps/openmw/mwmp/DedicatedActor.cpp +++ b/apps/openmw/mwmp/DedicatedActor.cpp @@ -227,9 +227,9 @@ void DedicatedActor::playSound() bool DedicatedActor::hasItem(std::string refId, int charge) { - for (const auto &ptr : ptr.getClass().getInventoryStore(ptr)) + for (const auto &item : ptr.getClass().getInventoryStore(ptr)) { - if (::Misc::StringUtils::ciEqual(ptr.getCellRef().getRefId(), refId) && ptr.getCellRef().getCharge() == charge) + if (::Misc::StringUtils::ciEqual(item.getCellRef().getRefId(), refId) && item.getCellRef().getCharge() == charge) return true; } @@ -238,9 +238,9 @@ bool DedicatedActor::hasItem(std::string refId, int charge) void DedicatedActor::equipItem(std::string refId, int charge) { - for (const auto &ptr : ptr.getClass().getInventoryStore(ptr)) + for (const auto &item : ptr.getClass().getInventoryStore(ptr)) { - if (::Misc::StringUtils::ciEqual(ptr.getCellRef().getRefId(), refId) && ptr.getCellRef().getCharge() == charge) + if (::Misc::StringUtils::ciEqual(item.getCellRef().getRefId(), refId) && item.getCellRef().getCharge() == charge) { std::shared_ptr action = ptr.getClass().use(ptr); action->execute(this->ptr); diff --git a/components/openmw-mp/Base/BasePacketProcessor.hpp b/components/openmw-mp/Base/BasePacketProcessor.hpp index 88dd641b2..120c4e140 100644 --- a/components/openmw-mp/Base/BasePacketProcessor.hpp +++ b/components/openmw-mp/Base/BasePacketProcessor.hpp @@ -8,6 +8,7 @@ #include #include #include +#include #define BPP_INIT(packet_id) packetID = packet_id; strPacketID = #packet_id; className = typeid(this).name(); avoidReading = false; @@ -38,7 +39,7 @@ public: throw std::logic_error("processor " + p.second->strPacketID + " already registered. Check " + processor->className + " and " + p.second->className); } - processors.insert(typename processors_t::value_type(processor->GetPacketID(), std::move(processor))); + processors.emplace(processor->GetPacketID(), std::unique_ptr(processor)); } protected: unsigned char packetID; From 7248a5d037adcdd99f1b9cee4e99f47114c7c57b Mon Sep 17 00:00:00 2001 From: Kyle Cooley Date: Fri, 5 Jan 2018 20:25:57 -0500 Subject: [PATCH 3/3] Remove some duplication, standardize sol2 header inclusion --- CMakeLists.txt | 10 ++++++++++ apps/master/CMakeLists.txt | 7 ++----- apps/master/MasterServer.hpp | 2 +- apps/master/main.cpp | 2 +- apps/openmw-mp/CMakeLists.txt | 6 ------ components/CMakeLists.txt | 4 ++-- 6 files changed, 16 insertions(+), 15 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4cef919a8..fb1e681f6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -140,6 +140,16 @@ endif() find_package(RakNet REQUIRED) include_directories(${RakNet_INCLUDES}) +if (BUILD_OPENMW_MP OR BUILD_MASTER) + find_package(LuaJit REQUIRED) + find_package(Sol2 REQUIRED) + include_directories(${LuaJit_INCLUDE_DIRS} ${Sol2_INCLUDE_DIRS}) +endif() +if (BUILD_MASTER) + find_package(OpenSSL REQUIRED) + include_directories(${OpenSSL_INCLUDE_DIRS}) +endif() + # Dependencies if (USE_QT) message(STATUS "Using Qt${DESIRED_QT_VERSION}") diff --git a/apps/master/CMakeLists.txt b/apps/master/CMakeLists.txt index 204dfa12c..e92bd7a2b 100644 --- a/apps/master/CMakeLists.txt +++ b/apps/master/CMakeLists.txt @@ -3,15 +3,12 @@ project(masterserver) #set(CMAKE_CXX_STANDARD 14) add_definitions(-std=gnu++14) -find_package(LuaJit REQUIRED) -find_package(OpenSSL REQUIRED) - -include_directories("./" ${LUAJIT_INCLUDE_DIR} ${CMAKE_SOURCE_DIR}/extern/sol ${OPENSSL_INCLUDE_DIR}) +include_directories("./") set(SOURCE_FILES main.cpp MasterServer.cpp MasterServer.hpp RestServer.cpp RestServer.hpp AdminRest.cpp) add_executable(masterserver ${SOURCE_FILES}) -target_link_libraries(masterserver ${RakNet_LIBRARY} ${LUAJIT_LIBRARY} ${OPENSSL_LIBRARIES} components) +target_link_libraries(masterserver ${RakNet_LIBRARY} ${LuaJit_LIBRARIES} ${OPENSSL_LIBRARIES} components) option(BUILD_MASTER_TEST "build master server test program" OFF) diff --git a/apps/master/MasterServer.hpp b/apps/master/MasterServer.hpp index 0d219e3cc..7b093d20c 100644 --- a/apps/master/MasterServer.hpp +++ b/apps/master/MasterServer.hpp @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include class MasterServer diff --git a/apps/master/main.cpp b/apps/master/main.cpp index 938e379a2..aa81f57c6 100644 --- a/apps/master/main.cpp +++ b/apps/master/main.cpp @@ -1,7 +1,7 @@ #include #include #include -#include +#include #include "MasterServer.hpp" #include "RestServer.hpp" #include "AdminRest.hpp" diff --git a/apps/openmw-mp/CMakeLists.txt b/apps/openmw-mp/CMakeLists.txt index ec0280b0e..fc92445a8 100644 --- a/apps/openmw-mp/CMakeLists.txt +++ b/apps/openmw-mp/CMakeLists.txt @@ -16,13 +16,7 @@ endif(ENABLE_BREAKPAD) -find_package(LuaJit REQUIRED) -find_package(Sol2 REQUIRED) - - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DENABLE_LUA") -include_directories(${LuaJit_INCLUDE_DIR} ${Sol2_INCLUDE_DIR}) - # local files set(SERVER diff --git a/components/CMakeLists.txt b/components/CMakeLists.txt index 85491274f..cbb77bec3 100644 --- a/components/CMakeLists.txt +++ b/components/CMakeLists.txt @@ -207,7 +207,7 @@ add_component_dir (fallback set (ESM_UI ${CMAKE_SOURCE_DIR}/files/ui/contentselector.ui ) -IF(BUILD_OPENMW OR BUILD_OPENCS) +IF(BUILD_OPENMW OR BUILD_OPENCS OR BUILD_BROWSER) if (USE_QT) add_component_qt_dir (contentselector model/modelitem model/esmfile @@ -234,7 +234,7 @@ if (USE_QT) QT5_WRAP_CPP(MOC_SRCS ${COMPONENT_MOC_FILES}) endif() endif() -ENDIF(BUILD_OPENMW OR BUILD_OPENCS) +ENDIF(BUILD_OPENMW OR BUILD_OPENCS OR BUILD_BROWSER) if (CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") if("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64" AND NOT APPLE)