From cf5bd0dca7f07e47b26569098deca46b18ea7e2f Mon Sep 17 00:00:00 2001 From: Kyle Cooley Date: Thu, 10 May 2018 16:59:41 -0400 Subject: [PATCH 01/11] Travis: use qt5, newer boost libraries, callff, gcc/clang builds... --- .travis.yml | 31 +++++++++++++++++---------- CI/before_install.linux.sh | 21 +++++++++++++------ CI/before_script.linux.sh | 43 ++++++++++++++++++++++++++++++-------- 3 files changed, 69 insertions(+), 26 deletions(-) diff --git a/.travis.yml b/.travis.yml index a833f721a..8c3e9305f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,3 @@ -os: - - linux -# - osx -osx_image: xcode8.3 language: cpp sudo: required dist: trusty @@ -10,6 +6,7 @@ branches: - master - coverity_scan - /openmw-.*$/ + - /^[0-9]+\.[0-9]+\.[0-9]+.*$/ env: global: # The next declaration is the encrypted COVERITY_SCAN_TOKEN, created @@ -20,22 +17,25 @@ addons: apt: sources: - sourceline: 'ppa:openmw/openmw' + - sourceline: 'ppa:rakhimov/boost' - ubuntu-toolchain-r-test - - llvm-toolchain-precise-3.6 + - llvm-toolchain-precise-3.8 packages: [ # Dev - cmake, clang-3.6, libunshield-dev, libtinyxml-dev, + cmake, clang-3.8, libunshield-dev, libtinyxml-dev, g++-6, # Tests libgtest-dev, google-mock, # Boost - libboost-filesystem-dev, libboost-program-options-dev, libboost-system-dev, + libboost-filesystem1.61-dev, libboost-program-options1.61-dev, libboost-system1.61-dev, # FFmpeg libavcodec-dev, libavformat-dev, libavutil-dev, libswscale-dev, # Audio & Video libsdl2-dev, qtbase5-dev, libopenal-dev, # The other ones from OpenMW ppa - libbullet-dev, libswresample-dev, libopenscenegraph-3.4-dev, libmygui-dev + libbullet-dev, libswresample-dev, libopenscenegraph-3.4-dev, libmygui-dev, + # tes3mp stuff + libboost1.61-dev, libqt5opengl5-dev ] coverity_scan: @@ -50,12 +50,21 @@ matrix: include: - os: linux env: - ANALYZE="scan-build-3.6 --use-cc clang-3.6 --use-c++ clang++-3.6 " + - ANALYZE="scan-build-3.8 --use-cc clang-3.8 --use-c++ clang++-3.8 " + - MATRIX_CC="CC=clang-3.8 && CXX=clang++-3.8" compiler: clang + - os: linux + env: + - MATRIX_CC="CC=gcc-6 && CXX=g++-6" + - os: linux + env: + - MATRIX_CC="CC=clang-3.8 && CXX=clang++-3.8" allow_failures: - - env: ANALYZE="scan-build-3.6 --use-cc clang-3.6 --use-c++ clang++-3.6 " + - env: + - ANALYZE="scan-build-3.8 --use-cc clang-3.8 --use-c++ clang++-3.8 " + - MATRIX_CC="CC=clang-3.8 && CXX=clang++-3.8" -before_install: +before_install: - ./CI/before_install.${TRAVIS_OS_NAME}.sh before_script: ./CI/before_script.${TRAVIS_OS_NAME}.sh script: diff --git a/CI/before_install.linux.sh b/CI/before_install.linux.sh index f4b448900..e2313b443 100755 --- a/CI/before_install.linux.sh +++ b/CI/before_install.linux.sh @@ -1,7 +1,10 @@ #!/bin/sh echo -n | openssl s_client -connect scan.coverity.com:443 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' | sudo tee -a /etc/ssl/certs/ca- -sudo ln -s /usr/bin/clang-3.6 /usr/local/bin/clang -sudo ln -s /usr/bin/clang++-3.6 /usr/local/bin/clang++ + +# Set up compilers +if [ ! -z "${MATRIX_CC}" ]; then + eval "${MATRIX_CC}" +fi # build libgtest & libgtest_main sudo mkdir /usr/src/gtest/build @@ -15,10 +18,16 @@ cd ~/ git clone https://github.com/TES3MP/RakNet cd RakNet cmake . -DRAKNET_ENABLE_DLL=OFF -DRAKNET_ENABLE_SAMPLES=OFF -DCMAKE_BUILD_TYPE=Release -mkdir ./lib -make -j3 install -cp ./Lib/RakNetLibStatic/libRakNetLibStatic.a ./lib -cd .. +make -j3 + +cd ~/ +git clone https://github.com/Koncord/CallFF +cd CallFF +mkdir build +cd build +cmake ../ +make -j3 +cd ~/ wget https://github.com/zdevito/terra/releases/download/release-2016-03-25/terra-Linux-x86_64-332a506.zip unzip terra-Linux-x86_64-332a506.zip diff --git a/CI/before_script.linux.sh b/CI/before_script.linux.sh index efdf28c6c..f1ba38415 100755 --- a/CI/before_script.linux.sh +++ b/CI/before_script.linux.sh @@ -3,15 +3,40 @@ free -m mkdir build cd build -export CODE_COVERAGE=1 + +# Set up compilers +if [ ! -z "${MATRIX_CC}" ]; then + eval "${MATRIX_CC}" +fi + export RAKNET_ROOT=~/RakNet export Terra_ROOT=~/terra-Linux-x86_64-332a506 -export BUILD_SERVER=OFF -if [ "${CC}" = "clang" ]; then export CODE_COVERAGE=0; -else - export COMPILER_NAME=gcc - export CXX=g++-6 - export CC=gcc-6 - export BUILD_SERVER=ON + +export CODE_COVERAGE=0 +if [ ! -z "${ANALYZE}" ]; then + CODE_COVERAGE=1 fi -${ANALYZE}cmake .. -DBUILD_OPENMW_MP=${BUILD_SERVER} -DBUILD_WITH_CODE_COVERAGE=${CODE_COVERAGE} -DBUILD_BSATOOL=OFF -DBUILD_ESMTOOL=OFF -DBUILD_ESSIMPORTER=OFF -DBUILD_LAUNCHER=OFF -DBUILD_MWINIIMPORTER=OFF -DBUILD_MYGUI_PLUGIN=OFF -DBUILD_OPENCS=OFF -DBUILD_WIZARD=OFF -DBUILD_BROWSER=OFF -DBUILD_UNITTESTS=1 -DCMAKE_INSTALL_PREFIX=/usr -DBINDIR=/usr/games -DCMAKE_BUILD_TYPE="None" -DUSE_SYSTEM_TINYXML=TRUE -DRakNet_LIBRARY_RELEASE=~/RakNet/lib/libRakNetLibStatic.a -DRakNet_LIBRARY_DEBUG=~/RakNet/lib/libRakNetLibStatic.a + +${ANALYZE}cmake .. \ + -DDESIRED_QT_VERSION=5 \ + -DBUILD_OPENMW_MP=ON \ + -DBUILD_BROWSER=ON \ + -DBUILD_MASTER=ON \ + -DBUILD_WITH_CODE_COVERAGE=${CODE_COVERAGE} \ + -DBUILD_BSATOOL=OFF \ + -DBUILD_ESMTOOL=OFF \ + -DBUILD_ESSIMPORTER=OFF \ + -DBUILD_LAUNCHER=OFF \ + -DBUILD_MWINIIMPORTER=OFF \ + -DBUILD_MYGUI_PLUGIN=OFF \ + -DBUILD_OPENCS=OFF \ + -DBUILD_WIZARD=OFF \ + -DBUILD_UNITTESTS=1 \ + -DCMAKE_INSTALL_PREFIX=/usr \ + -DBINDIR=/usr/games \ + -DCMAKE_BUILD_TYPE="None" \ + -DUSE_SYSTEM_TINYXML=TRUE \ + -DRakNet_LIBRARY_RELEASE=~/RakNet/lib/libRakNetLibStatic.a \ + -DRakNet_LIBRARY_DEBUG=~/RakNet/lib/libRakNetLibStatic.a \ + -DCallFF_INCLUDES=~/CallFF/include \ + -DCallFF_LIBRARY=~/CallFF/build/src/libcallff.a From 6c7d73af7fd3d2f83067dad6e1b25848fac63953 Mon Sep 17 00:00:00 2001 From: Kyle Cooley Date: Thu, 10 May 2018 19:01:22 -0400 Subject: [PATCH 02/11] Bump c++ standard version to 14 --- CMakeLists.txt | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 72392e77a..9ce0d41bd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -361,9 +361,9 @@ if (NOT WIN32 AND NOT APPLE) endif() # CXX Compiler settings -set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD 14) if (CMAKE_CXX_COMPILER_ID STREQUAL GNU OR CMAKE_CXX_COMPILER_ID STREQUAL Clang) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wundef -Wno-unused-parameter -std=c++11 -pedantic -Wno-long-long") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wundef -Wno-unused-parameter -pedantic -Wno-long-long") add_definitions( -DBOOST_NO_CXX11_SCOPED_ENUMS=ON ) if (APPLE) @@ -507,7 +507,7 @@ if(WIN32) INSTALL(DIRECTORY "${OpenMW_BINARY_DIR}/Debug/resources" DESTINATION "." CONFIGURATIONS Debug) INSTALL(DIRECTORY "${OpenMW_BINARY_DIR}/Release/resources" DESTINATION "." CONFIGURATIONS Release;RelWithDebInfo;MinSizeRel) - + FILE(GLOB plugin_dir_debug "${OpenMW_BINARY_DIR}/Debug/osgPlugins-*") FILE(GLOB plugin_dir_release "${OpenMW_BINARY_DIR}/Release/osgPlugins-*") INSTALL(DIRECTORY ${plugin_dir_debug} DESTINATION "." CONFIGURATIONS Debug) @@ -893,4 +893,3 @@ if (DOXYGEN_FOUND) WORKING_DIRECTORY ${OpenMW_BINARY_DIR} COMMENT "Generating documentation for the github-pages at ${DOXYGEN_PAGES_OUTPUT_DIR}" VERBATIM) endif () - From d78ae4bab460ceb1cc297409194d3ea920cf0798 Mon Sep 17 00:00:00 2001 From: Kyle Cooley Date: Thu, 10 May 2018 21:19:41 -0400 Subject: [PATCH 03/11] Allow the clang build to fail for now --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 8c3e9305f..ec76dcd1f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -60,6 +60,8 @@ matrix: env: - MATRIX_CC="CC=clang-3.8 && CXX=clang++-3.8" allow_failures: + - env: + - MATRIX_CC="CC=clang-3.8 && CXX=clang++-3.8" - env: - ANALYZE="scan-build-3.8 --use-cc clang-3.8 --use-c++ clang++-3.8 " - MATRIX_CC="CC=clang-3.8 && CXX=clang++-3.8" From 6a3ff5ed81dadd8057f59c8fd9e502a537421d6a Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Wed, 16 May 2018 10:10:42 +0400 Subject: [PATCH 04/11] Fix compiler warning in getNestedData --- apps/opencs/model/world/refidadapterimp.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/opencs/model/world/refidadapterimp.cpp b/apps/opencs/model/world/refidadapterimp.cpp index ba67b4e14..46d1e5748 100644 --- a/apps/opencs/model/world/refidadapterimp.cpp +++ b/apps/opencs/model/world/refidadapterimp.cpp @@ -1368,13 +1368,15 @@ QVariant CSMWorld::CreatureAttackRefIdAdapter::getNestedData (const RefIdColumn const ESM::Creature& creature = record.get(); - if (subRowIndex < 0 || subRowIndex > 2 || subColIndex < 0 || subColIndex > 2) + if (subRowIndex < 0 || subRowIndex > 2) throw std::runtime_error ("index out of range"); if (subColIndex == 0) return subRowIndex + 1; - else if (subColIndex < 3) // 1 or 2 + else if (subColIndex == 1 || subColIndex == 2) return creature.mData.mAttack[(subRowIndex * 2) + (subColIndex - 1)]; + else + throw std::runtime_error ("index out of range"); } void CSMWorld::CreatureAttackRefIdAdapter::setNestedData (const RefIdColumn *column, From 164e3d12feb079f1d043aea51a7075a013c0834f Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Wed, 16 May 2018 11:18:22 +0400 Subject: [PATCH 05/11] Display weapon reach on tooltips in feet. --- apps/openmw/mwclass/weapon.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwclass/weapon.cpp b/apps/openmw/mwclass/weapon.cpp index 9fb4a9767..e59567aac 100644 --- a/apps/openmw/mwclass/weapon.cpp +++ b/apps/openmw/mwclass/weapon.cpp @@ -325,7 +325,10 @@ namespace MWClass // add reach and attack speed for melee weapon if (ref->mBase->mData.mType < 9 && Settings::Manager::getBool("show melee info", "Game")) { - text += MWGui::ToolTips::getPercentString(ref->mBase->mData.mReach, "#{sRange}"); + // 64 game units = 1 yard = 3 ft, display value in feet + const float combatDistance = store.get().find("fCombatDistance")->getFloat() * ref->mBase->mData.mReach; + text += MWGui::ToolTips::getWeightString(combatDistance*3/64, "#{sRange}"); + text += " #{sFeet}"; text += MWGui::ToolTips::getPercentString(ref->mBase->mData.mSpeed, "#{sAttributeSpeed}"); } From df459199dd2bfedbc6580d009b3e85c13e85509e Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Wed, 16 May 2018 12:59:05 +0400 Subject: [PATCH 06/11] Avoid left shift of negative value --- apps/openmw/mwrender/globalmap.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/openmw/mwrender/globalmap.cpp b/apps/openmw/mwrender/globalmap.cpp index 24f6de6ce..af2bb101a 100644 --- a/apps/openmw/mwrender/globalmap.cpp +++ b/apps/openmw/mwrender/globalmap.cpp @@ -125,7 +125,7 @@ namespace MWRender { for (int cellX=0; cellX(float(cellX)/float(mCellSize) * 9); + int vertexX = static_cast(float(cellX) / float(mCellSize) * 9); int vertexY = static_cast(float(cellY) / float(mCellSize) * 9); int texelX = (x-mMinX) * mCellSize + cellX; @@ -135,9 +135,9 @@ namespace MWRender float y2 = 0; if (land && (land->mDataTypes & ESM::Land::DATA_WNAM)) - y2 = (land->mWnam[vertexY * 9 + vertexX] << 4) / 2048.f; + y2 = land->mWnam[vertexY * 9 + vertexX] / 128.f; else - y2 = (SCHAR_MIN << 4) / 2048.f; + y2 = SCHAR_MIN / 128.f; if (y2 < 0) { r = static_cast(14 * y2 + 38); From e5db5e2651c9843843524aba28c5a8450b2d1b54 Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Wed, 16 May 2018 16:13:22 +0400 Subject: [PATCH 07/11] Fix 'maybe-uninitialized' warning in openal_output --- apps/openmw/mwsound/openal_output.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/apps/openmw/mwsound/openal_output.cpp b/apps/openmw/mwsound/openal_output.cpp index 829c001e5..a8a541704 100644 --- a/apps/openmw/mwsound/openal_output.cpp +++ b/apps/openmw/mwsound/openal_output.cpp @@ -951,10 +951,11 @@ std::pair OpenAL_Output::loadSound(const std::string &fname getALError(); std::vector data; - ALenum format; + ALenum format = AL_NONE; int srate; - try { + try + { DecoderPtr decoder = mManager.getDecoder(); // Workaround: Bethesda at some point converted some of the files to mp3, but the references were kept as .wav. if(decoder->mResourceMgr->exists(fname)) @@ -974,7 +975,8 @@ std::pair OpenAL_Output::loadSound(const std::string &fname format = getALFormat(chans, type); if(format) decoder->readAll(data); } - catch(std::exception &e) { + catch(std::exception &e) + { std::cerr<< "Failed to load audio from "< Date: Wed, 16 May 2018 16:34:58 +0400 Subject: [PATCH 08/11] Initialize srate variable in openal_output --- apps/openmw/mwsound/openal_output.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/openmw/mwsound/openal_output.cpp b/apps/openmw/mwsound/openal_output.cpp index a8a541704..31d46ce31 100644 --- a/apps/openmw/mwsound/openal_output.cpp +++ b/apps/openmw/mwsound/openal_output.cpp @@ -952,7 +952,7 @@ std::pair OpenAL_Output::loadSound(const std::string &fname std::vector data; ALenum format = AL_NONE; - int srate; + int srate = 0; try { From 049d0d9ba795cc252964c5af815c2c7c4089fbf2 Mon Sep 17 00:00:00 2001 From: David Cernat Date: Thu, 17 May 2018 00:08:37 +0300 Subject: [PATCH 09/11] [General] Fix remaining references to world packets/events --- apps/openmw-mp/CMakeLists.txt | 6 +++--- apps/openmw/mwmp/ObjectList.hpp | 6 +++--- apps/openmw/mwmp/processors/ObjectProcessor.hpp | 10 +++------- .../openmw-mp/Controllers/ObjectPacketController.hpp | 6 +++--- components/openmw-mp/NetworkMessages.hpp | 2 +- components/openmw-mp/Packets/Object/ObjectPacket.cpp | 2 +- components/openmw-mp/Packets/Object/ObjectPacket.hpp | 6 +++--- 7 files changed, 17 insertions(+), 21 deletions(-) diff --git a/apps/openmw-mp/CMakeLists.txt b/apps/openmw-mp/CMakeLists.txt index 6e9a5f4a6..304034cda 100644 --- a/apps/openmw-mp/CMakeLists.txt +++ b/apps/openmw-mp/CMakeLists.txt @@ -144,7 +144,7 @@ set(PROCESSORS_PLAYER source_group(tes3mp-server\\processors\\player FILES ${PROCESSORS_PLAYER}) -set(PROCESSORS_WORLD +set(PROCESSORS_OBJECT processors/object/ProcessorContainer.hpp processors/object/ProcessorDoorState.hpp processors/object/ProcessorMusicPlay.hpp processors/object/ProcessorObjectAnimPlay.hpp processors/object/ProcessorObjectDelete.hpp processors/object/ProcessorObjectLock.hpp @@ -157,7 +157,7 @@ set(PROCESSORS_WORLD processors/object/ProcessorScriptGlobalFloat.hpp processors/object/ProcessorVideoPlay.hpp ) -source_group(tes3mp-server\\processors\\world FILES ${PROCESSORS_WORLD}) +source_group(tes3mp-server\\processors\\world FILES ${PROCESSORS_OBJECT}) set(PROCESSORS processors/ProcessorInitializer.cpp @@ -174,7 +174,7 @@ include_directories("./") add_executable(tes3mp-server ${SERVER} ${SERVER_HEADER} - ${PROCESSORS_ACTOR} ${PROCESSORS_PLAYER} ${PROCESSORS_WORLD} ${PROCESSORS} + ${PROCESSORS_ACTOR} ${PROCESSORS_PLAYER} ${PROCESSORS_OBJECT} ${PROCESSORS} ${APPLE_BUNDLE_RESOURCES} ) add_definitions(-std=gnu++14 -Wno-ignored-qualifiers) diff --git a/apps/openmw/mwmp/ObjectList.hpp b/apps/openmw/mwmp/ObjectList.hpp index 29fcc65b7..abbdbac96 100644 --- a/apps/openmw/mwmp/ObjectList.hpp +++ b/apps/openmw/mwmp/ObjectList.hpp @@ -1,5 +1,5 @@ -#ifndef OPENMW_WORLDEVENT_HPP -#define OPENMW_WORLDEVENT_HPP +#ifndef OPENMW_OBJECTLIST_HPP +#define OPENMW_OBJECTLIST_HPP #include #include "../mwworld/cellstore.hpp" @@ -90,4 +90,4 @@ namespace mwmp }; } -#endif //OPENMW_WORLDEVENT_HPP +#endif //OPENMW_OBJECTLIST_HPP diff --git a/apps/openmw/mwmp/processors/ObjectProcessor.hpp b/apps/openmw/mwmp/processors/ObjectProcessor.hpp index 8179a9271..56dbf46c3 100644 --- a/apps/openmw/mwmp/processors/ObjectProcessor.hpp +++ b/apps/openmw/mwmp/processors/ObjectProcessor.hpp @@ -1,9 +1,5 @@ -// -// Created by koncord on 16.04.17. -// - -#ifndef OPENMW_WORLDPROCESSSOR_HPP -#define OPENMW_WORLDPROCESSSOR_HPP +#ifndef OPENMW_OBJECTPROCESSSOR_HPP +#define OPENMW_OBJECTPROCESSSOR_HPP #include #include @@ -25,4 +21,4 @@ namespace mwmp } -#endif //OPENMW_WORLDPROCESSSOR_HPP +#endif //OPENMW_OBJECTPROCESSSOR_HPP diff --git a/components/openmw-mp/Controllers/ObjectPacketController.hpp b/components/openmw-mp/Controllers/ObjectPacketController.hpp index 230f270ea..3492e0f43 100644 --- a/components/openmw-mp/Controllers/ObjectPacketController.hpp +++ b/components/openmw-mp/Controllers/ObjectPacketController.hpp @@ -1,5 +1,5 @@ -#ifndef OPENMW_WORLDPACKETCONTROLLER_HPP -#define OPENMW_WORLDPACKETCONTROLLER_HPP +#ifndef OPENMW_OBJECTPACKETCONTROLLER_HPP +#define OPENMW_OBJECTPACKETCONTROLLER_HPP #include @@ -24,4 +24,4 @@ namespace mwmp }; } -#endif //OPENMW_WORLDPACKETCONTROLLER_HPP +#endif //OPENMW_OBJECTPACKETCONTROLLER_HPP diff --git a/components/openmw-mp/NetworkMessages.hpp b/components/openmw-mp/NetworkMessages.hpp index 925b245db..0f4de487f 100644 --- a/components/openmw-mp/NetworkMessages.hpp +++ b/components/openmw-mp/NetworkMessages.hpp @@ -115,7 +115,7 @@ enum OrderingChannel CHANNEL_SYSTEM = 0, CHANNEL_ACTOR, CHANNEL_PLAYER, - CHANNEL_WORLDEVENT, + CHANNEL_OBJECT, CHANNEL_MASTER }; diff --git a/components/openmw-mp/Packets/Object/ObjectPacket.cpp b/components/openmw-mp/Packets/Object/ObjectPacket.cpp index 87cc30bf7..c979d0d25 100644 --- a/components/openmw-mp/Packets/Object/ObjectPacket.cpp +++ b/components/openmw-mp/Packets/Object/ObjectPacket.cpp @@ -11,7 +11,7 @@ ObjectPacket::ObjectPacket(RakNet::RakPeerInterface *peer) : BasePacket(peer) packetID = 0; priority = HIGH_PRIORITY; reliability = RELIABLE_ORDERED; - orderChannel = CHANNEL_WORLDEVENT; + orderChannel = CHANNEL_OBJECT; this->peer = peer; } diff --git a/components/openmw-mp/Packets/Object/ObjectPacket.hpp b/components/openmw-mp/Packets/Object/ObjectPacket.hpp index 226b961ea..898ef39d5 100644 --- a/components/openmw-mp/Packets/Object/ObjectPacket.hpp +++ b/components/openmw-mp/Packets/Object/ObjectPacket.hpp @@ -1,5 +1,5 @@ -#ifndef OPENMW_WORLDPACKET_HPP -#define OPENMW_WORLDPACKET_HPP +#ifndef OPENMW_OBJECTPACKET_HPP +#define OPENMW_OBJECTPACKET_HPP #include #include @@ -32,4 +32,4 @@ namespace mwmp }; } -#endif //OPENMW_WORLDPACKET_HPP +#endif //OPENMW_OBJECTPACKET_HPP From e8b22a2e5e430234b487d6f836a8901387378b72 Mon Sep 17 00:00:00 2001 From: David Cernat Date: Fri, 18 May 2018 05:06:19 +0300 Subject: [PATCH 10/11] [Server] Use correct source group for ObjectProcessors --- apps/openmw-mp/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/openmw-mp/CMakeLists.txt b/apps/openmw-mp/CMakeLists.txt index 304034cda..6da3aa52a 100644 --- a/apps/openmw-mp/CMakeLists.txt +++ b/apps/openmw-mp/CMakeLists.txt @@ -157,7 +157,7 @@ set(PROCESSORS_OBJECT processors/object/ProcessorScriptGlobalFloat.hpp processors/object/ProcessorVideoPlay.hpp ) -source_group(tes3mp-server\\processors\\world FILES ${PROCESSORS_OBJECT}) +source_group(tes3mp-server\\processors\\object FILES ${PROCESSORS_OBJECT}) set(PROCESSORS processors/ProcessorInitializer.cpp From 43a944ddaf341d22f65e13dbdca86e7079aa8df3 Mon Sep 17 00:00:00 2001 From: David Cernat Date: Fri, 18 May 2018 06:40:28 +0300 Subject: [PATCH 11/11] [General] Add and implement new Worldstate packet type --- apps/openmw-mp/CMakeLists.txt | 1 + apps/openmw-mp/Networking.cpp | 29 ++++++++++++++ apps/openmw-mp/Networking.hpp | 10 +++-- .../processors/WorldstateProcessor.cpp | 40 +++++++++++++++++++ .../processors/WorldstateProcessor.hpp | 22 ++++++++++ apps/openmw/CMakeLists.txt | 3 +- apps/openmw/mwmp/Networking.cpp | 19 ++++++++- apps/openmw/mwmp/Networking.hpp | 5 +++ .../mwmp/processors/ProcessorInitializer.cpp | 8 ++-- .../mwmp/processors/WorldstateProcessor.cpp | 40 +++++++++++++++++++ .../mwmp/processors/WorldstateProcessor.hpp | 22 ++++++++++ components/CMakeLists.txt | 8 +++- components/openmw-mp/Base/BaseWorldstate.hpp | 26 ++++++++++++ .../WorldstatePacketController.cpp | 36 +++++++++++++++++ .../WorldstatePacketController.hpp | 27 +++++++++++++ components/openmw-mp/NetworkMessages.hpp | 3 +- .../Packets/Worldstate/WorldstatePacket.cpp | 31 ++++++++++++++ .../Packets/Worldstate/WorldstatePacket.hpp | 30 ++++++++++++++ 18 files changed, 346 insertions(+), 14 deletions(-) create mode 100644 apps/openmw-mp/processors/WorldstateProcessor.cpp create mode 100644 apps/openmw-mp/processors/WorldstateProcessor.hpp create mode 100644 apps/openmw/mwmp/processors/WorldstateProcessor.cpp create mode 100644 apps/openmw/mwmp/processors/WorldstateProcessor.hpp create mode 100644 components/openmw-mp/Base/BaseWorldstate.hpp create mode 100644 components/openmw-mp/Controllers/WorldstatePacketController.cpp create mode 100644 components/openmw-mp/Controllers/WorldstatePacketController.hpp create mode 100644 components/openmw-mp/Packets/Worldstate/WorldstatePacket.cpp create mode 100644 components/openmw-mp/Packets/Worldstate/WorldstatePacket.hpp diff --git a/apps/openmw-mp/CMakeLists.txt b/apps/openmw-mp/CMakeLists.txt index 6da3aa52a..0c8974878 100644 --- a/apps/openmw-mp/CMakeLists.txt +++ b/apps/openmw-mp/CMakeLists.txt @@ -164,6 +164,7 @@ set(PROCESSORS processors/PlayerProcessor.cpp processors/ActorProcessor.cpp processors/ObjectProcessor.cpp + processors/WorldstateProcessor.cpp ) source_group(tes3mp-server\\processors FILES ${PROCESSORS}) diff --git a/apps/openmw-mp/Networking.cpp b/apps/openmw-mp/Networking.cpp index e740dc3f8..f6e7f6016 100644 --- a/apps/openmw-mp/Networking.cpp +++ b/apps/openmw-mp/Networking.cpp @@ -26,6 +26,7 @@ #include "processors/PlayerProcessor.hpp" #include "processors/ActorProcessor.hpp" #include "processors/ObjectProcessor.hpp" +#include "processors/WorldstateProcessor.hpp" using namespace mwmp; using namespace std; @@ -46,6 +47,7 @@ Networking::Networking(RakNet::RakPeerInterface *peer) : mclient(nullptr) playerPacketController = new PlayerPacketController(peer); actorPacketController = new ActorPacketController(peer); objectPacketController = new ObjectPacketController(peer); + worldstatePacketController = new WorldstatePacketController(peer); // Set send stream playerPacketController->SetStream(0, &bsOut); @@ -193,6 +195,18 @@ void Networking::processObjectPacket(RakNet::Packet *packet) } +void Networking::processWorldstatePacket(RakNet::Packet *packet) +{ + Player *player = Players::getPlayer(packet->guid); + + if (!player->isHandshaked() || player->getLoadState() != Player::POSTLOADED) + return; + + if (!WorldstateProcessor::Process(*packet, baseWorldstate)) + LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Unhandled WorldstatePacket with identifier %i has arrived", packet->data[0]); + +} + void Networking::update(RakNet::Packet *packet) { Player *player = Players::getPlayer(packet->guid); @@ -280,6 +294,11 @@ void Networking::update(RakNet::Packet *packet) objectPacketController->SetStream(&bsIn, 0); processObjectPacket(packet); } + else if (worldstatePacketController->ContainsPacket(packet->data[0])) + { + worldstatePacketController->SetStream(&bsIn, 0); + processWorldstatePacket(packet); + } else LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Unhandled RakNet packet with identifier %i has arrived", packet->data[0]); } @@ -357,6 +376,11 @@ ObjectPacketController *Networking::getObjectPacketController() const return objectPacketController; } +WorldstatePacketController *Networking::getWorldstatePacketController() const +{ + return worldstatePacketController; +} + BaseActorList *Networking::getLastActorList() { return &baseActorList; @@ -367,6 +391,11 @@ BaseObjectList *Networking::getLastObjectList() return &baseObjectList; } +BaseWorldstate *Networking::getLastWorldstate() +{ + return &baseWorldstate; +} + int Networking::getCurrentMpNum() { return currentMpNum; diff --git a/apps/openmw-mp/Networking.hpp b/apps/openmw-mp/Networking.hpp index 81cd5cb73..d378dced5 100644 --- a/apps/openmw-mp/Networking.hpp +++ b/apps/openmw-mp/Networking.hpp @@ -1,13 +1,10 @@ -// -// Created by koncord on 12.01.16. -// - #ifndef OPENMW_NETWORKING_HPP #define OPENMW_NETWORKING_HPP #include #include #include +#include #include #include "Player.hpp" @@ -31,6 +28,7 @@ namespace mwmp void processPlayerPacket(RakNet::Packet *packet); void processActorPacket(RakNet::Packet *packet); void processObjectPacket(RakNet::Packet *packet); + void processWorldstatePacket(RakNet::Packet *packet); void update(RakNet::Packet *packet); unsigned short numberOfConnections() const; @@ -44,9 +42,11 @@ namespace mwmp PlayerPacketController *getPlayerPacketController() const; ActorPacketController *getActorPacketController() const; ObjectPacketController *getObjectPacketController() const; + WorldstatePacketController *getWorldstatePacketController() const; BaseActorList *getLastActorList(); BaseObjectList *getLastObjectList(); + BaseWorldstate *getLastWorldstate(); int getCurrentMpNum(); void setCurrentMpNum(int value); @@ -76,10 +76,12 @@ namespace mwmp BaseActorList baseActorList; BaseObjectList baseObjectList; + BaseWorldstate baseWorldstate; PlayerPacketController *playerPacketController; ActorPacketController *actorPacketController; ObjectPacketController *objectPacketController; + WorldstatePacketController *worldstatePacketController; bool running; int exitCode; diff --git a/apps/openmw-mp/processors/WorldstateProcessor.cpp b/apps/openmw-mp/processors/WorldstateProcessor.cpp new file mode 100644 index 000000000..cbe4e010b --- /dev/null +++ b/apps/openmw-mp/processors/WorldstateProcessor.cpp @@ -0,0 +1,40 @@ +#include "WorldstateProcessor.hpp" +#include "Networking.hpp" + +using namespace mwmp; + +template +typename BasePacketProcessor::processors_t BasePacketProcessor::processors; + +void WorldstateProcessor::Do(WorldstatePacket &packet, Player &player, BaseWorldstate &worldstate) +{ + packet.Send(true); +} + +bool WorldstateProcessor::Process(RakNet::Packet &packet, BaseWorldstate &worldstate) noexcept +{ + worldstate.guid = packet.guid; + + for (auto &processor : processors) + { + if (processor.first == packet.data[0]) + { + Player *player = Players::getPlayer(packet.guid); + WorldstatePacket *myPacket = Networking::get().getWorldstatePacketController()->GetPacket(packet.data[0]); + + myPacket->setWorldstate(&worldstate); + worldstate.isValid = true; + + if (!processor.second->avoidReading) + myPacket->Read(); + + if (worldstate.isValid) + processor.second->Do(*myPacket, *player, worldstate); + else + LOG_MESSAGE_SIMPLE(Log::LOG_ERROR, "Received %s that failed integrity check and was ignored!", processor.second->strPacketID.c_str()); + + return true; + } + } + return false; +} diff --git a/apps/openmw-mp/processors/WorldstateProcessor.hpp b/apps/openmw-mp/processors/WorldstateProcessor.hpp new file mode 100644 index 000000000..316744dde --- /dev/null +++ b/apps/openmw-mp/processors/WorldstateProcessor.hpp @@ -0,0 +1,22 @@ +#ifndef OPENMW_BASEWORLDSTATEPROCESSOR_HPP +#define OPENMW_BASEWORLDSTATEPROCESSOR_HPP + +#include +#include +#include +#include +#include "Player.hpp" + +namespace mwmp +{ + class WorldstateProcessor : public BasePacketProcessor + { + public: + + virtual void Do(WorldstatePacket &packet, Player &player, BaseWorldstate &worldstate); + + static bool Process(RakNet::Packet &packet, BaseWorldstate &worldstate) noexcept; + }; +} + +#endif //OPENMW_BASEWORLDSTATEPROCESSOR_HPP diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index de991998c..10384e004 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -104,7 +104,8 @@ add_openmw_dir (mwmp Main Networking LocalPlayer DedicatedPlayer PlayerList Loca add_openmw_dir (mwmp/GUI GUIChat GUILogin PlayerMarkerCollection GUIDialogList TextInputDialog ) -add_openmw_dir(mwmp/processors BaseClientPacketProcessor PlayerProcessor ObjectProcessor ActorProcessor ProcessorInitializer +add_openmw_dir(mwmp/processors BaseClientPacketProcessor PlayerProcessor ObjectProcessor ActorProcessor WorldstateProcessor + ProcessorInitializer ) add_openmw_dir (mwmp/processors/actor ProcessorActorAI ProcessorActorAnimFlags ProcessorActorAnimPlay ProcessorActorAttack diff --git a/apps/openmw/mwmp/Networking.cpp b/apps/openmw/mwmp/Networking.cpp index 5e3a0d34c..0d13ce95f 100644 --- a/apps/openmw/mwmp/Networking.cpp +++ b/apps/openmw/mwmp/Networking.cpp @@ -39,6 +39,7 @@ #include "processors/PlayerProcessor.hpp" #include "processors/ObjectProcessor.hpp" #include "processors/ActorProcessor.hpp" +#include "processors/WorldstateProcessor.hpp" #include "GUIController.hpp" #include "CellController.hpp" @@ -197,7 +198,7 @@ string listComparison(PacketPreInit::PluginContainer checksums, PacketPreInit::P } Networking::Networking(): peer(RakNet::RakPeerInterface::GetInstance()), playerPacketController(peer), - actorPacketController(peer), objectPacketController(peer) + actorPacketController(peer), objectPacketController(peer), worldstatePacketController(peer) { RakNet::SocketDescriptor sd; @@ -208,6 +209,7 @@ Networking::Networking(): peer(RakNet::RakPeerInterface::GetInstance()), playerP playerPacketController.SetStream(0, &bsOut); actorPacketController.SetStream(0, &bsOut); objectPacketController.SetStream(0, &bsOut); + worldstatePacketController.SetStream(0, &bsOut); connected = 0; ProcessorInitializer(); @@ -433,6 +435,11 @@ void Networking::receiveMessage(RakNet::Packet *packet) if (!ObjectProcessor::Process(*packet, objectList)) LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Unhandled ObjectPacket with identifier %i has arrived", packet->data[0]); } + else if (worldstatePacketController.ContainsPacket(packet->data[0])) + { + if (!WorldstateProcessor::Process(*packet, worldstate)) + LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Unhandled WorldstatePacket with identifier %i has arrived", packet->data[0]); + } } PlayerPacket *Networking::getPlayerPacket(RakNet::MessageID id) @@ -450,6 +457,11 @@ ObjectPacket *Networking::getObjectPacket(RakNet::MessageID id) return objectPacketController.GetPacket(id); } +WorldstatePacket *Networking::getWorldstatePacket(RakNet::MessageID id) +{ + return worldstatePacketController.GetPacket(id); +} + LocalPlayer *Networking::getLocalPlayer() { return mwmp::Main::get().getLocalPlayer(); @@ -465,6 +477,11 @@ ObjectList *Networking::getObjectList() return &objectList; } +BaseWorldstate *Networking::getWorldstate() +{ + return &worldstate; +} + bool Networking::isConnected() { return connected; diff --git a/apps/openmw/mwmp/Networking.hpp b/apps/openmw/mwmp/Networking.hpp index c16c2cc28..fa8a83be8 100644 --- a/apps/openmw/mwmp/Networking.hpp +++ b/apps/openmw/mwmp/Networking.hpp @@ -16,6 +16,7 @@ #include #include #include +#include #include @@ -34,6 +35,7 @@ namespace mwmp PlayerPacket *getPlayerPacket(RakNet::MessageID id); ActorPacket *getActorPacket(RakNet::MessageID id); ObjectPacket *getObjectPacket(RakNet::MessageID id); + WorldstatePacket *getWorldstatePacket(RakNet::MessageID id); RakNet::SystemAddress serverAddress() { @@ -45,6 +47,7 @@ namespace mwmp LocalPlayer *getLocalPlayer(); ActorList *getActorList(); ObjectList *getObjectList(); + BaseWorldstate *getWorldstate(); private: bool connected; @@ -55,9 +58,11 @@ namespace mwmp PlayerPacketController playerPacketController; ActorPacketController actorPacketController; ObjectPacketController objectPacketController; + WorldstatePacketController worldstatePacketController; ActorList actorList; ObjectList objectList; + BaseWorldstate worldstate; void receiveMessage(RakNet::Packet *packet); diff --git a/apps/openmw/mwmp/processors/ProcessorInitializer.cpp b/apps/openmw/mwmp/processors/ProcessorInitializer.cpp index 2b66ed3e4..38cbc0a9c 100644 --- a/apps/openmw/mwmp/processors/ProcessorInitializer.cpp +++ b/apps/openmw/mwmp/processors/ProcessorInitializer.cpp @@ -1,11 +1,6 @@ -// -// Created by koncord on 31.03.17. -// - #include "ProcessorInitializer.hpp" #include "PlayerProcessor.hpp" - #include "player/ProcessorChatMessage.hpp" #include "player/ProcessorGUIMessageBox.hpp" #include "player/ProcessorHandshake.hpp" @@ -80,6 +75,7 @@ #include "object/ProcessorScriptGlobalFloat.hpp" #include "object/ProcessorVideoPlay.hpp" +#include "ActorProcessor.hpp" #include "actor/ProcessorActorAI.hpp" #include "actor/ProcessorActorAnimFlags.hpp" #include "actor/ProcessorActorAnimPlay.hpp" @@ -95,6 +91,8 @@ #include "actor/ProcessorActorStatsDynamic.hpp" #include "actor/ProcessorActorTest.hpp" +#include "WorldstateProcessor.hpp" + using namespace mwmp; void ProcessorInitializer() diff --git a/apps/openmw/mwmp/processors/WorldstateProcessor.cpp b/apps/openmw/mwmp/processors/WorldstateProcessor.cpp new file mode 100644 index 000000000..684e7d355 --- /dev/null +++ b/apps/openmw/mwmp/processors/WorldstateProcessor.cpp @@ -0,0 +1,40 @@ +#include "../Networking.hpp" +#include "WorldstateProcessor.hpp" +#include "../Main.hpp" + +using namespace mwmp; + +template +typename BasePacketProcessor::processors_t BasePacketProcessor::processors; + +bool WorldstateProcessor::Process(RakNet::Packet &packet, BaseWorldstate &worldstate) +{ + RakNet::BitStream bsIn(&packet.data[1], packet.length, false); + bsIn.Read(guid); + worldstate.guid = guid; + + WorldstatePacket *myPacket = Main::get().getNetworking()->getWorldstatePacket(packet.data[0]); + myPacket->SetReadStream(&bsIn); + + for (auto &processor : processors) + { + if (processor.first == packet.data[0]) + { + myGuid = Main::get().getLocalPlayer()->guid; + request = packet.length == myPacket->headerSize(); + + worldstate.isValid = true; + + if (!request && !processor.second->avoidReading) + myPacket->Read(); + + if (worldstate.isValid) + processor.second->Do(*myPacket, worldstate); + else + LOG_MESSAGE_SIMPLE(Log::LOG_ERROR, "Received %s that failed integrity check and was ignored!", processor.second->strPacketID.c_str()); + + return true; + } + } + return false; +} diff --git a/apps/openmw/mwmp/processors/WorldstateProcessor.hpp b/apps/openmw/mwmp/processors/WorldstateProcessor.hpp new file mode 100644 index 000000000..77a888e0d --- /dev/null +++ b/apps/openmw/mwmp/processors/WorldstateProcessor.hpp @@ -0,0 +1,22 @@ +#ifndef OPENMW_WORLDSTATEPROCESSOR_HPP +#define OPENMW_WORLDSTATEPROCESSOR_HPP + +#include +#include +#include +#include "BaseClientPacketProcessor.hpp" + +namespace mwmp +{ + class WorldstateProcessor : public BasePacketProcessor, public BaseClientPacketProcessor + { + public: + virtual void Do(WorldstatePacket &packet, BaseWorldstate &worldstate) = 0; + + static bool Process(RakNet::Packet &packet, BaseWorldstate &worldstate); + }; +} + + + +#endif //OPENMW_WORLDSTATEPROCESSOR_HPP diff --git a/components/CMakeLists.txt b/components/CMakeLists.txt index 2eb4b5e5d..3516104ed 100644 --- a/components/CMakeLists.txt +++ b/components/CMakeLists.txt @@ -150,11 +150,11 @@ add_component_dir (openmw-mp ) add_component_dir (openmw-mp/Base - BaseActor BaseObjectList BasePacketProcessor BasePlayer BaseStructs + BaseActor BaseObjectList BasePacketProcessor BasePlayer BaseStructs BaseWorldstate ) add_component_dir (openmw-mp/Controllers - PlayerPacketController ActorPacketController ObjectPacketController + PlayerPacketController ActorPacketController ObjectPacketController WorldstatePacketController ) add_component_dir(openmw-mp/Master @@ -196,6 +196,10 @@ add_component_dir (openmw-mp/Packets/Object PacketScriptMemberFloat PacketScriptGlobalShort PacketScriptGlobalFloat ) +add_component_dir (openmw-mp/Packets/Worldstate + WorldstatePacket + ) + add_component_dir (fallback fallback validate ) diff --git a/components/openmw-mp/Base/BaseWorldstate.hpp b/components/openmw-mp/Base/BaseWorldstate.hpp new file mode 100644 index 000000000..a823066f0 --- /dev/null +++ b/components/openmw-mp/Base/BaseWorldstate.hpp @@ -0,0 +1,26 @@ +#ifndef OPENMW_BASEWORLDSTATE_HPP +#define OPENMW_BASEWORLDSTATE_HPP + +#include + +#include + +namespace mwmp +{ + + class BaseWorldstate + { + public: + + BaseWorldstate() + { + + } + + RakNet::RakNetGUID guid; + + bool isValid; + }; +} + +#endif //OPENMW_BASEWORLDSTATE_HPP diff --git a/components/openmw-mp/Controllers/WorldstatePacketController.cpp b/components/openmw-mp/Controllers/WorldstatePacketController.cpp new file mode 100644 index 000000000..44d83c5c1 --- /dev/null +++ b/components/openmw-mp/Controllers/WorldstatePacketController.cpp @@ -0,0 +1,36 @@ +#include "WorldstatePacketController.hpp" + +template +inline void AddPacket(mwmp::WorldstatePacketController::packets_t *packets, RakNet::RakPeerInterface *peer) +{ + T *packet = new T(peer); + typedef mwmp::WorldstatePacketController::packets_t::value_type value_t; + packets->insert(value_t(packet->GetPacketID(), value_t::second_type(packet))); +} + +mwmp::WorldstatePacketController::WorldstatePacketController(RakNet::RakPeerInterface *peer) +{ + +} + + +mwmp::WorldstatePacket *mwmp::WorldstatePacketController::GetPacket(RakNet::MessageID id) +{ + return packets[(unsigned char)id].get(); +} + +void mwmp::WorldstatePacketController::SetStream(RakNet::BitStream *inStream, RakNet::BitStream *outStream) +{ + for(const auto &packet : packets) + packet.second->SetStreams(inStream, outStream); +} + +bool mwmp::WorldstatePacketController::ContainsPacket(RakNet::MessageID id) +{ + for(const auto &packet : packets) + { + if (packet.first == id) + return true; + } + return false; +} diff --git a/components/openmw-mp/Controllers/WorldstatePacketController.hpp b/components/openmw-mp/Controllers/WorldstatePacketController.hpp new file mode 100644 index 000000000..256c1fcd7 --- /dev/null +++ b/components/openmw-mp/Controllers/WorldstatePacketController.hpp @@ -0,0 +1,27 @@ +#ifndef OPENMW_WORLDSTATEPACKETCONTROLLER_HPP +#define OPENMW_WORLDSTATEPACKETCONTROLLER_HPP + + +#include +#include "../Packets/Worldstate/WorldstatePacket.hpp" +#include +#include + +namespace mwmp +{ + class WorldstatePacketController + { + public: + WorldstatePacketController(RakNet::RakPeerInterface *peer); + WorldstatePacket *GetPacket(RakNet::MessageID id); + void SetStream(RakNet::BitStream *inStream, RakNet::BitStream *outStream); + + bool ContainsPacket(RakNet::MessageID id); + + typedef std::unordered_map > packets_t; + private: + packets_t packets; + }; +} + +#endif //OPENMW_WORLDSTATEPACKETCONTROLLER_HPP diff --git a/components/openmw-mp/NetworkMessages.hpp b/components/openmw-mp/NetworkMessages.hpp index 0f4de487f..7bf23145b 100644 --- a/components/openmw-mp/NetworkMessages.hpp +++ b/components/openmw-mp/NetworkMessages.hpp @@ -116,7 +116,8 @@ enum OrderingChannel CHANNEL_ACTOR, CHANNEL_PLAYER, CHANNEL_OBJECT, - CHANNEL_MASTER + CHANNEL_MASTER, + CHANNEL_WORLDSTATE }; diff --git a/components/openmw-mp/Packets/Worldstate/WorldstatePacket.cpp b/components/openmw-mp/Packets/Worldstate/WorldstatePacket.cpp new file mode 100644 index 000000000..328eae26d --- /dev/null +++ b/components/openmw-mp/Packets/Worldstate/WorldstatePacket.cpp @@ -0,0 +1,31 @@ +#include +#include +#include +#include "WorldstatePacket.hpp" + +using namespace mwmp; + +WorldstatePacket::WorldstatePacket(RakNet::RakPeerInterface *peer) : BasePacket(peer) +{ + packetID = 0; + priority = HIGH_PRIORITY; + reliability = RELIABLE_ORDERED; + orderChannel = CHANNEL_WORLDSTATE; + this->peer = peer; +} + +WorldstatePacket::~WorldstatePacket() +{ + +} + +void WorldstatePacket::setWorldstate(BaseWorldstate *worldstate) +{ + this->worldstate = worldstate; + guid = worldstate->guid; +} + +BaseWorldstate *WorldstatePacket::getWorldstate() +{ + return worldstate; +} diff --git a/components/openmw-mp/Packets/Worldstate/WorldstatePacket.hpp b/components/openmw-mp/Packets/Worldstate/WorldstatePacket.hpp new file mode 100644 index 000000000..f961dd82e --- /dev/null +++ b/components/openmw-mp/Packets/Worldstate/WorldstatePacket.hpp @@ -0,0 +1,30 @@ +#ifndef OPENMW_WORLDSTATEPACKET_HPP +#define OPENMW_WORLDSTATEPACKET_HPP + +#include +#include +#include +#include +#include + +#include + +namespace mwmp +{ + class WorldstatePacket : public BasePacket + { + public: + WorldstatePacket(RakNet::RakPeerInterface *peer); + + ~WorldstatePacket(); + + void setWorldstate(BaseWorldstate *worldstate); + BaseWorldstate *getWorldstate(); + + protected: + BaseWorldstate *worldstate; + + }; +} + +#endif //OPENMW_WORLDSTATEPACKET_HPP