diff --git a/CMakeLists.txt b/CMakeLists.txt index 133d9f7e6..5b9f5ad78 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -65,6 +65,7 @@ option(OPENMW_UNITY_BUILD "Use fewer compilation units to speed up compile time" # Apps and tools option(BUILD_OPENMW "build OpenMW" ON) +option(BUILD_OPENMW_MP "build OpenMW-MP" ON) option(BUILD_BSATOOL "build BSA extractor" ON) option(BUILD_ESMTOOL "build ESM inspector" ON) option(BUILD_LAUNCHER "build Launcher" ON) @@ -116,6 +117,9 @@ if (WIN32) option(USE_DEBUG_CONSOLE "whether a debug console should be enabled for debug builds, if false debug output is redirected to Visual Studio output" ON) endif() +find_package(RakNet REQUIRED) +include_directories(${RakNet_INCLUDES}) + if (NOT BUILD_LAUNCHER AND NOT BUILD_OPENCS AND NOT BUILD_WIZARD) set(USE_QT FALSE) else() @@ -328,6 +332,12 @@ endif (APPLE) # Other files +configure_file(${OpenMW_SOURCE_DIR}/files/tes3mp/tes3mp-client-default.cfg + "${OpenMW_BINARY_DIR}/tes3mp-client-default.cfg") + +configure_file(${OpenMW_SOURCE_DIR}/files/tes3mp/tes3mp-server-default.cfg + "${OpenMW_BINARY_DIR}/tes3mp-server-default.cfg") + configure_file(${OpenMW_SOURCE_DIR}/files/settings-default.cfg "${OpenMW_BINARY_DIR}/settings-default.cfg") @@ -433,6 +443,11 @@ IF(NOT WIN32 AND NOT APPLE) INSTALL(FILES "${OpenMW_BINARY_DIR}/resources/version" DESTINATION "${SYSCONFDIR}" COMPONENT "openmw") INSTALL(FILES "${OpenMW_BINARY_DIR}/gamecontrollerdb.txt" DESTINATION "${SYSCONFDIR}" COMPONENT "openmw") + INSTALL(FILES "${OpenMW_BINARY_DIR}/tes3mp-client-default" DESTINATION "${SYSCONFDIR}" COMPONENT "openmw") + INSTALL(FILES "${OpenMW_BINARY_DIR}/tes3mp-client.install" DESTINATION "${SYSCONFDIR}" RENAME "tes3mp-client.cfg" COMPONENT "openmw") + INSTALL(FILES "${OpenMW_BINARY_DIR}/tes3mp-server-default" DESTINATION "${SYSCONFDIR}" COMPONENT "openmw-mp") + INSTALL(FILES "${OpenMW_BINARY_DIR}/tes3mp-server.install" DESTINATION "${SYSCONFDIR}" RENAME "tes3mp-server.cfg" COMPONENT "openmw-mp") + IF(BUILD_OPENCS) INSTALL(FILES "${OpenMW_BINARY_DIR}/openmw-cs.cfg" DESTINATION "${SYSCONFDIR}" COMPONENT "opencs") ENDIF(BUILD_OPENCS) @@ -452,6 +467,7 @@ if(WIN32) "${OpenMW_SOURCE_DIR}/Docs/license/GPL3.txt" "${OpenMW_SOURCE_DIR}/Docs/license/DejaVu Font License.txt" "${OpenMW_BINARY_DIR}/settings-default.cfg" + "${OpenMW_BINARY_DIR}/tes3mp-client-default.cfg" "${OpenMW_BINARY_DIR}/gamecontrollerdb.txt" "${OpenMW_BINARY_DIR}/Release/openmw.exe" DESTINATION ".") @@ -555,6 +571,10 @@ add_subdirectory (components) #endif() # Apps and tools +if (BUILD_OPENMW_MP) + add_subdirectory( apps/openmw-mp ) +endif() + if (BUILD_OPENMW) add_subdirectory( apps/openmw ) endif() diff --git a/OpenMW-mp changelog b/OpenMW-mp changelog new file mode 100644 index 000000000..53753cc05 --- /dev/null +++ b/OpenMW-mp changelog @@ -0,0 +1,51 @@ +0.0.1b + Fixed NPC attack segfault + Movement interpolation + Lua-scripting + Chat + +0.0.1a + Combat animation + Synchronization of melee and ranged (bow, crossbow, throwable weapons) combat + Synchronization of health, mana, stamina (sic) and death + Synchronization of attributes and skills + +0.0.1 + Synchronization of racial features + Synchronization of position + Synchronization of the state (nothing/weapon/spell) + Synchronization of movement and jump animations + +To do: + +0.0.1b + Finish combat package (knockout, knockdown, spells and enchantments) + Improve position synchronization while being knocked out, knocked down or dying + Partial (unbreakable) items synchronization + Spells synchronization + +0.0.2 + Vampirism + Lycanthropy + Items synchronization + Locks synchronization + Opening doors + Opening locks + Activators interaction (hook?) + +0.0.2b + Code cleanup + +0.0.3 + Containers synchronization + Loot + Stealing from other players + Dropping/picking up items + +Future + Disableable console (~) + Client-side script functions for synchronization + Weather sync + Time sync + NPC sync + Trading diff --git a/TES3MPTeam.md b/TES3MPTeam.md new file mode 100644 index 000000000..2e06e3870 --- /dev/null +++ b/TES3MPTeam.md @@ -0,0 +1,25 @@ +Tes3mp Team +============ + +Programmers +----------- + + Stanislav (Koncord) Zhukov - The main loafer and part-time Project Leader + + +Testers: +-------- + + Volk Milit aka Ja'Virr-Dar - Team Manager, Debian Linux + Shnatsel - Debian Linux + Goodevil - Mint and Xubuntu Linux + + +Public Relations and Translations +--------------------------------- + + Volk Milit aka Ja'Virr-Dar - Public relations & News Writer + Shnatsel - Translator & News Writer + + +Thanks to developers of OpenMW. They do amazing things. diff --git a/apps/opencs/Networking.cpp b/apps/opencs/Networking.cpp new file mode 100644 index 000000000..c6fe34835 --- /dev/null +++ b/apps/opencs/Networking.cpp @@ -0,0 +1,90 @@ +#include "editor.hpp" + +#include +#include +#include + +#include +#include +#include + +#include "model/doc/messages.hpp" + +#include "model/world/universalid.hpp" + +#ifdef Q_OS_MAC +#include +#endif + +Q_DECLARE_METATYPE (std::string) + +class Application : public QApplication +{ + private: + + bool notify (QObject *receiver, QEvent *event) + { + try + { + return QApplication::notify (receiver, event); + } + catch (const std::exception& exception) + { + std::cerr << "An exception has been caught: " << exception.what() << std::endl; + } + + return false; + } + + public: + + Application (int& argc, char *argv[]) : QApplication (argc, argv) {} +}; + +int main(int argc, char *argv[]) +{ + #ifdef Q_OS_MAC + setenv("OSG_GL_TEXTURE_STORAGE", "OFF", 0); + #endif + + try + { + // To allow background thread drawing in OSG + QApplication::setAttribute(Qt::AA_X11InitThreads, true); + + Q_INIT_RESOURCE (resources); + + qRegisterMetaType ("std::string"); + qRegisterMetaType ("CSMWorld::UniversalId"); + qRegisterMetaType ("CSMDoc::Message"); + + Application application (argc, argv); + + #ifdef Q_OS_MAC + QDir dir(QCoreApplication::applicationDirPath()); + if (dir.dirName() == "MacOS") { + dir.cdUp(); + dir.cdUp(); + dir.cdUp(); + } + QDir::setCurrent(dir.absolutePath()); + #endif + + application.setWindowIcon (QIcon (":./openmw-cs.png")); + + CS::Editor editor; + + if(!editor.makeIPCServer()) + { + editor.connectToIPCServer(); + return 0; + } + return editor.run(); + } + catch (std::exception& e) + { + std::cerr << "ERROR: " << e.what() << std::endl; + return 0; + } + +} diff --git a/apps/openmw-mp/CMakeLists.txt b/apps/openmw-mp/CMakeLists.txt new file mode 100644 index 000000000..2219de99b --- /dev/null +++ b/apps/openmw-mp/CMakeLists.txt @@ -0,0 +1,124 @@ +project(openmw-mp) + +add_subdirectory(amx) + +option(BUILD_WITH_PAWN "Enable Pawn language" OFF) +if(BUILD_WITH_PAWN) + #set(Pawn_ROOT ${CMAKE_SOURCE_DIR}/external/pawn/) + set(Pawn_INCLUDES ${Pawn_ROOT}/include) + set(Pawn_LIBRARY ${Pawn_ROOT}/lib/libamx.a) + set(PawnScript_Sources + Script/LangPawn/LangPAWN.cpp + Script/LangPawn/PawnFunc.cpp) + set(PawnScript_Headers ${Pawn_INCLUDES} + Script/LangPawn/LangPAWN.hpp + ) + + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DENABLE_PAWN -DPAWN_CELL_SIZE=64") + #include_directories(${Pawn_INCLUDES}) + include_directories("./amx/linux") +endif(BUILD_WITH_PAWN) + +option(BUILD_WITH_LUA "Enable Terra/Lua language" ON) +if(BUILD_WITH_LUA) + #set(Terra_ROOT ${CMAKE_SOURCE_DIR}/external/terra/) + find_package(Terra REQUIRED) + set(LuaScript_Sources + Script/LangLua/LangLua.cpp + Script/LangLua/LuaFunc.cpp) + set(LuaScript_Headers ${Terra_INCLUDES} ${CMAKE_SOURCE_DIR}/extern/LuaBridge ${CMAKE_SOURCE_DIR}/extern/LuaBridge/detail + Script/LangLua/LangLua.hpp) + + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DENABLE_LUA") + include_directories(${Terra_INCLUDES} ${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 + Player.cpp + Networking.cpp + Utils.cpp + Script/Script.cpp Script/ScriptFunction.cpp + Script/ScriptFunctions.cpp + Script/Functions/Translocations.cpp Script/Functions/Stats.cpp Script/Functions/Items.cpp + Script/Functions/Timer.cpp Script/Functions/Chat.cpp + Script/API/TimerAPI.cpp Script/API/PublicFnAPI.cpp + ${PawnScript_Sources} + ${LuaScript_Sources} + ${NativeScript_Sources} + +) + +set(SERVER_HEADER + Script/Types.hpp Script/Script.hpp Script/SystemInterface.hpp + Script/ScriptFunction.hpp Script/Platform.hpp + Script/ScriptFunctions.hpp Script/API/TimerAPI.hpp Script/API/PublicFnAPI.hpp + ${PawnScript_Headers} + ${LuaScript_Headers} + ${NativeScript_Headers} +) +source_group(openmw-mp FILES ${SERVER} ${SERVER_HEADER}) + +include_directories("./") + +# Main executable + +add_executable(openmw-mp +${SERVER_FILES} +${SERVER} ${SERVER_HEADER} +${APPLE_BUNDLE_RESOURCES} +) +add_definitions(-std=gnu++11) + +target_link_libraries(openmw-mp + ${OSG_LIBRARIES} + ${OPENTHREADS_LIBRARIES} + ${OSGPARTICLE_LIBRARIES} + ${OSGUTIL_LIBRARIES} + ${OSGDB_LIBRARIES} + ${OSGVIEWER_LIBRARIES} + ${OSGGA_LIBRARIES} + ${Boost_SYSTEM_LIBRARY} + ${Boost_THREAD_LIBRARY} + ${Boost_FILESYSTEM_LIBRARY} + ${Boost_PROGRAM_OPTIONS_LIBRARY} + ${BULLET_LIBRARIES} + ${RakNet_LIBRARY} + components + amx + ${Terra_LIBRARY} + ${Pawn_LIBRARY} +) + +if (USE_SYSTEM_TINYXML) + target_link_libraries(openmw-mp ${TINYXML_LIBRARIES}) +endif() + +if (UNIX) + target_link_libraries(openmw-mp dl) + # Fix for not visible pthreads functions for linker with glibc 2.15 + if(NOT APPLE) + target_link_libraries(openmw-mp ${CMAKE_THREAD_LIBS_INIT}) + endif(NOT APPLE) +endif(UNIX) + +if (BUILD_WITH_CODE_COVERAGE) + add_definitions (--coverage) + target_link_libraries(openmw-mp gcov) +endif() + +if (MSVC) + # Debug version needs increased number of sections beyond 2^16 + if (CMAKE_CL_64) + set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /bigobj") + endif (CMAKE_CL_64) + add_definitions("-D_USE_MATH_DEFINES") +endif (MSVC) diff --git a/apps/openmw-mp/Networking.cpp b/apps/openmw-mp/Networking.cpp new file mode 100644 index 000000000..340f15084 --- /dev/null +++ b/apps/openmw-mp/Networking.cpp @@ -0,0 +1,394 @@ +// +// Created by koncord on 12.01.16. +// + +#include "Player.hpp" +#include +#include +#include +#include +#include