forked from teamnwah/openmw-tes3coop
Merge pull request #430 from TES3MP/0.6.3 while resolving conflicts
# Conflicts: # apps/openmw-mp/Networking.cpp # apps/openmw-mp/Networking.hpp # components/CMakeLists.txt
This commit is contained in:
commit
8a393d2984
33 changed files with 413 additions and 78 deletions
31
.travis.yml
31
.travis.yml
|
@ -1,7 +1,3 @@
|
||||||
os:
|
|
||||||
- linux
|
|
||||||
# - osx
|
|
||||||
osx_image: xcode8.3
|
|
||||||
language: cpp
|
language: cpp
|
||||||
sudo: required
|
sudo: required
|
||||||
dist: trusty
|
dist: trusty
|
||||||
|
@ -10,6 +6,7 @@ branches:
|
||||||
- master
|
- master
|
||||||
- coverity_scan
|
- coverity_scan
|
||||||
- /openmw-.*$/
|
- /openmw-.*$/
|
||||||
|
- /^[0-9]+\.[0-9]+\.[0-9]+.*$/
|
||||||
env:
|
env:
|
||||||
global:
|
global:
|
||||||
# The next declaration is the encrypted COVERITY_SCAN_TOKEN, created
|
# The next declaration is the encrypted COVERITY_SCAN_TOKEN, created
|
||||||
|
@ -20,22 +17,25 @@ addons:
|
||||||
apt:
|
apt:
|
||||||
sources:
|
sources:
|
||||||
- sourceline: 'ppa:openmw/openmw'
|
- sourceline: 'ppa:openmw/openmw'
|
||||||
|
- sourceline: 'ppa:rakhimov/boost'
|
||||||
- ubuntu-toolchain-r-test
|
- ubuntu-toolchain-r-test
|
||||||
- llvm-toolchain-precise-3.6
|
- llvm-toolchain-precise-3.8
|
||||||
packages: [
|
packages: [
|
||||||
# Dev
|
# Dev
|
||||||
cmake, clang-3.6, libunshield-dev, libtinyxml-dev,
|
cmake, clang-3.8, libunshield-dev, libtinyxml-dev,
|
||||||
g++-6,
|
g++-6,
|
||||||
# Tests
|
# Tests
|
||||||
libgtest-dev, google-mock,
|
libgtest-dev, google-mock,
|
||||||
# Boost
|
# 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
|
# FFmpeg
|
||||||
libavcodec-dev, libavformat-dev, libavutil-dev, libswscale-dev,
|
libavcodec-dev, libavformat-dev, libavutil-dev, libswscale-dev,
|
||||||
# Audio & Video
|
# Audio & Video
|
||||||
libsdl2-dev, qtbase5-dev, libopenal-dev,
|
libsdl2-dev, qtbase5-dev, libopenal-dev,
|
||||||
# The other ones from OpenMW ppa
|
# 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:
|
coverity_scan:
|
||||||
|
@ -50,10 +50,21 @@ matrix:
|
||||||
include:
|
include:
|
||||||
- os: linux
|
- os: linux
|
||||||
env:
|
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
|
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:
|
allow_failures:
|
||||||
- env: ANALYZE="scan-build-3.6 --use-cc clang-3.6 --use-c++ clang++-3.6 "
|
- 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"
|
||||||
|
|
||||||
before_install:
|
before_install:
|
||||||
- ./CI/before_install.${TRAVIS_OS_NAME}.sh
|
- ./CI/before_install.${TRAVIS_OS_NAME}.sh
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
#!/bin/sh
|
#!/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-
|
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
|
# build libgtest & libgtest_main
|
||||||
sudo mkdir /usr/src/gtest/build
|
sudo mkdir /usr/src/gtest/build
|
||||||
|
@ -15,10 +18,16 @@ cd ~/
|
||||||
git clone https://github.com/TES3MP/RakNet
|
git clone https://github.com/TES3MP/RakNet
|
||||||
cd RakNet
|
cd RakNet
|
||||||
cmake . -DRAKNET_ENABLE_DLL=OFF -DRAKNET_ENABLE_SAMPLES=OFF -DCMAKE_BUILD_TYPE=Release
|
cmake . -DRAKNET_ENABLE_DLL=OFF -DRAKNET_ENABLE_SAMPLES=OFF -DCMAKE_BUILD_TYPE=Release
|
||||||
mkdir ./lib
|
make -j3
|
||||||
make -j3 install
|
|
||||||
cp ./Lib/RakNetLibStatic/libRakNetLibStatic.a ./lib
|
|
||||||
cd ..
|
|
||||||
|
|
||||||
|
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
|
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
|
unzip terra-Linux-x86_64-332a506.zip
|
||||||
|
|
|
@ -3,15 +3,40 @@
|
||||||
free -m
|
free -m
|
||||||
mkdir build
|
mkdir build
|
||||||
cd build
|
cd build
|
||||||
export CODE_COVERAGE=1
|
|
||||||
|
# Set up compilers
|
||||||
|
if [ ! -z "${MATRIX_CC}" ]; then
|
||||||
|
eval "${MATRIX_CC}"
|
||||||
|
fi
|
||||||
|
|
||||||
export RAKNET_ROOT=~/RakNet
|
export RAKNET_ROOT=~/RakNet
|
||||||
export Terra_ROOT=~/terra-Linux-x86_64-332a506
|
export Terra_ROOT=~/terra-Linux-x86_64-332a506
|
||||||
export BUILD_SERVER=OFF
|
|
||||||
if [ "${CC}" = "clang" ]; then export CODE_COVERAGE=0;
|
export CODE_COVERAGE=0
|
||||||
else
|
if [ ! -z "${ANALYZE}" ]; then
|
||||||
export COMPILER_NAME=gcc
|
CODE_COVERAGE=1
|
||||||
export CXX=g++-6
|
|
||||||
export CC=gcc-6
|
|
||||||
export BUILD_SERVER=ON
|
|
||||||
fi
|
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
|
||||||
|
|
|
@ -372,9 +372,9 @@ if (NOT WIN32 AND NOT APPLE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# CXX Compiler settings
|
# 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)
|
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 )
|
add_definitions( -DBOOST_NO_CXX11_SCOPED_ENUMS=ON )
|
||||||
|
|
||||||
if (APPLE)
|
if (APPLE)
|
||||||
|
@ -904,4 +904,3 @@ if (DOXYGEN_FOUND)
|
||||||
WORKING_DIRECTORY ${OpenMW_BINARY_DIR}
|
WORKING_DIRECTORY ${OpenMW_BINARY_DIR}
|
||||||
COMMENT "Generating documentation for the github-pages at ${DOXYGEN_PAGES_OUTPUT_DIR}" VERBATIM)
|
COMMENT "Generating documentation for the github-pages at ${DOXYGEN_PAGES_OUTPUT_DIR}" VERBATIM)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
|
|
@ -1368,13 +1368,15 @@ QVariant CSMWorld::CreatureAttackRefIdAdapter::getNestedData (const RefIdColumn
|
||||||
|
|
||||||
const ESM::Creature& creature = record.get();
|
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");
|
throw std::runtime_error ("index out of range");
|
||||||
|
|
||||||
if (subColIndex == 0)
|
if (subColIndex == 0)
|
||||||
return subRowIndex + 1;
|
return subRowIndex + 1;
|
||||||
else if (subColIndex < 3) // 1 or 2
|
else if (subColIndex == 1 || subColIndex == 2)
|
||||||
return creature.mData.mAttack[(subRowIndex * 2) + (subColIndex - 1)];
|
return creature.mData.mAttack[(subRowIndex * 2) + (subColIndex - 1)];
|
||||||
|
else
|
||||||
|
throw std::runtime_error ("index out of range");
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSMWorld::CreatureAttackRefIdAdapter::setNestedData (const RefIdColumn *column,
|
void CSMWorld::CreatureAttackRefIdAdapter::setNestedData (const RefIdColumn *column,
|
||||||
|
|
|
@ -94,7 +94,7 @@ set(PROCESSORS_PLAYER
|
||||||
|
|
||||||
source_group(tes3mp-server\\processors\\player FILES ${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/ProcessorContainer.hpp processors/object/ProcessorDoorState.hpp
|
||||||
processors/object/ProcessorMusicPlay.hpp processors/object/ProcessorObjectAnimPlay.hpp
|
processors/object/ProcessorMusicPlay.hpp processors/object/ProcessorObjectAnimPlay.hpp
|
||||||
processors/object/ProcessorObjectDelete.hpp processors/object/ProcessorObjectLock.hpp
|
processors/object/ProcessorObjectDelete.hpp processors/object/ProcessorObjectLock.hpp
|
||||||
|
@ -107,13 +107,14 @@ set(PROCESSORS_WORLD
|
||||||
processors/object/ProcessorScriptGlobalFloat.hpp processors/object/ProcessorVideoPlay.hpp
|
processors/object/ProcessorScriptGlobalFloat.hpp processors/object/ProcessorVideoPlay.hpp
|
||||||
)
|
)
|
||||||
|
|
||||||
source_group(tes3mp-server\\processors\\world FILES ${PROCESSORS_WORLD})
|
source_group(tes3mp-server\\processors\\object FILES ${PROCESSORS_OBJECT})
|
||||||
|
|
||||||
set(PROCESSORS
|
set(PROCESSORS
|
||||||
processors/ProcessorInitializer.cpp
|
processors/ProcessorInitializer.cpp
|
||||||
processors/PlayerProcessor.cpp
|
processors/PlayerProcessor.cpp
|
||||||
processors/ActorProcessor.cpp
|
processors/ActorProcessor.cpp
|
||||||
processors/ObjectProcessor.cpp
|
processors/ObjectProcessor.cpp
|
||||||
|
processors/WorldstateProcessor.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
source_group(tes3mp-server\\processors FILES ${PROCESSORS})
|
source_group(tes3mp-server\\processors FILES ${PROCESSORS})
|
||||||
|
@ -124,7 +125,7 @@ include_directories("./")
|
||||||
|
|
||||||
add_executable(tes3mp-server
|
add_executable(tes3mp-server
|
||||||
${SERVER} ${SERVER_HEADER}
|
${SERVER} ${SERVER_HEADER}
|
||||||
${PROCESSORS_ACTOR} ${PROCESSORS_PLAYER} ${PROCESSORS_WORLD} ${PROCESSORS}
|
${PROCESSORS_ACTOR} ${PROCESSORS_PLAYER} ${PROCESSORS_OBJECT} ${PROCESSORS}
|
||||||
${APPLE_BUNDLE_RESOURCES}
|
${APPLE_BUNDLE_RESOURCES}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include "processors/PlayerProcessor.hpp"
|
#include "processors/PlayerProcessor.hpp"
|
||||||
#include "processors/ActorProcessor.hpp"
|
#include "processors/ActorProcessor.hpp"
|
||||||
#include "processors/ObjectProcessor.hpp"
|
#include "processors/ObjectProcessor.hpp"
|
||||||
|
#include "processors/WorldstateProcessor.hpp"
|
||||||
|
|
||||||
#include "Networking.hpp"
|
#include "Networking.hpp"
|
||||||
#include "MasterClient.hpp"
|
#include "MasterClient.hpp"
|
||||||
|
@ -44,6 +45,7 @@ Networking::Networking(RakNet::RakPeerInterface *peer) : mclient(nullptr)
|
||||||
playerPacketController = make_unique<PlayerPacketController>(peer);
|
playerPacketController = make_unique<PlayerPacketController>(peer);
|
||||||
actorPacketController = make_unique<ActorPacketController>(peer);
|
actorPacketController = make_unique<ActorPacketController>(peer);
|
||||||
objectPacketController = make_unique<ObjectPacketController>(peer);
|
objectPacketController = make_unique<ObjectPacketController>(peer);
|
||||||
|
worldstatePacketController = make_unique<WorldstatePacketController>(peer);
|
||||||
|
|
||||||
// Set send stream
|
// Set send stream
|
||||||
playerPacketController->SetStream(nullptr, &bsOut);
|
playerPacketController->SetStream(nullptr, &bsOut);
|
||||||
|
@ -183,6 +185,18 @@ void Networking::processObjectPacket(RakNet::Packet *packet)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Networking::processWorldstatePacket(RakNet::Packet *packet)
|
||||||
|
{
|
||||||
|
auto player = Players::getPlayerByGUID(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]);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
bool Networking::update(RakNet::Packet *packet)
|
bool Networking::update(RakNet::Packet *packet)
|
||||||
{
|
{
|
||||||
auto player = Players::getPlayerByGUID(packet->guid);
|
auto player = Players::getPlayerByGUID(packet->guid);
|
||||||
|
@ -269,6 +283,11 @@ bool Networking::update(RakNet::Packet *packet)
|
||||||
objectPacketController->SetStream(&bsIn, nullptr);
|
objectPacketController->SetStream(&bsIn, nullptr);
|
||||||
processObjectPacket(packet);
|
processObjectPacket(packet);
|
||||||
}
|
}
|
||||||
|
else if (worldstatePacketController->ContainsPacket(packet->data[0]))
|
||||||
|
{
|
||||||
|
worldstatePacketController->SetStream(&bsIn, nullptr);
|
||||||
|
processWorldstatePacket(packet);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Unhandled RakNet packet with identifier %i has arrived", (int) packet->data[0]);
|
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Unhandled RakNet packet with identifier %i has arrived", (int) packet->data[0]);
|
||||||
|
@ -348,6 +367,11 @@ ObjectPacketController *Networking::getObjectPacketController() const
|
||||||
return objectPacketController.get();
|
return objectPacketController.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WorldstatePacketController *Networking::getWorldstatePacketController() const
|
||||||
|
{
|
||||||
|
return worldstatePacketController.get();
|
||||||
|
}
|
||||||
|
|
||||||
BaseActorList *Networking::getLastActorList()
|
BaseActorList *Networking::getLastActorList()
|
||||||
{
|
{
|
||||||
return &baseActorList;
|
return &baseActorList;
|
||||||
|
@ -358,6 +382,11 @@ BaseObjectList *Networking::getLastObjectList()
|
||||||
return &baseObjectList;
|
return &baseObjectList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BaseWorldstate *Networking::getLastWorldstate()
|
||||||
|
{
|
||||||
|
return &baseWorldstate;
|
||||||
|
}
|
||||||
|
|
||||||
int Networking::getCurrentMpNum()
|
int Networking::getCurrentMpNum()
|
||||||
{
|
{
|
||||||
return currentMpNum;
|
return currentMpNum;
|
||||||
|
|
|
@ -1,13 +1,10 @@
|
||||||
//
|
|
||||||
// Created by koncord on 12.01.16.
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef OPENMW_NETWORKING_HPP
|
#ifndef OPENMW_NETWORKING_HPP
|
||||||
#define OPENMW_NETWORKING_HPP
|
#define OPENMW_NETWORKING_HPP
|
||||||
|
|
||||||
#include <components/openmw-mp/Controllers/PlayerPacketController.hpp>
|
#include <components/openmw-mp/Controllers/PlayerPacketController.hpp>
|
||||||
#include <components/openmw-mp/Controllers/ActorPacketController.hpp>
|
#include <components/openmw-mp/Controllers/ActorPacketController.hpp>
|
||||||
#include <components/openmw-mp/Controllers/ObjectPacketController.hpp>
|
#include <components/openmw-mp/Controllers/ObjectPacketController.hpp>
|
||||||
|
#include <components/openmw-mp/Controllers/WorldstatePacketController.hpp>
|
||||||
#include <components/openmw-mp/Packets/PacketPreInit.hpp>
|
#include <components/openmw-mp/Packets/PacketPreInit.hpp>
|
||||||
#include <apps/openmw-mp/Script/LuaState.hpp>
|
#include <apps/openmw-mp/Script/LuaState.hpp>
|
||||||
|
|
||||||
|
@ -39,6 +36,7 @@ namespace mwmp
|
||||||
void processPlayerPacket(RakNet::Packet *packet);
|
void processPlayerPacket(RakNet::Packet *packet);
|
||||||
void processActorPacket(RakNet::Packet *packet);
|
void processActorPacket(RakNet::Packet *packet);
|
||||||
void processObjectPacket(RakNet::Packet *packet);
|
void processObjectPacket(RakNet::Packet *packet);
|
||||||
|
void processWorldstatePacket(RakNet::Packet *packet);
|
||||||
bool update(RakNet::Packet *packet);
|
bool update(RakNet::Packet *packet);
|
||||||
|
|
||||||
unsigned short numberOfConnections() const;
|
unsigned short numberOfConnections() const;
|
||||||
|
@ -52,11 +50,13 @@ namespace mwmp
|
||||||
PlayerPacketController *getPlayerPacketController() const;
|
PlayerPacketController *getPlayerPacketController() const;
|
||||||
ActorPacketController *getActorPacketController() const;
|
ActorPacketController *getActorPacketController() const;
|
||||||
ObjectPacketController *getObjectPacketController() const;
|
ObjectPacketController *getObjectPacketController() const;
|
||||||
|
WorldstatePacketController *getWorldstatePacketController() const;
|
||||||
|
|
||||||
LuaState &getState() {return luaState;}
|
LuaState &getState() {return luaState;}
|
||||||
|
|
||||||
BaseActorList *getLastActorList();
|
BaseActorList *getLastActorList();
|
||||||
BaseObjectList *getLastObjectList();
|
BaseObjectList *getLastObjectList();
|
||||||
|
BaseWorldstate *getLastWorldstate();
|
||||||
|
|
||||||
int getCurrentMpNum();
|
int getCurrentMpNum();
|
||||||
void setCurrentMpNum(int value);
|
void setCurrentMpNum(int value);
|
||||||
|
@ -91,10 +91,12 @@ namespace mwmp
|
||||||
|
|
||||||
BaseActorList baseActorList;
|
BaseActorList baseActorList;
|
||||||
BaseObjectList baseObjectList;
|
BaseObjectList baseObjectList;
|
||||||
|
BaseWorldstate baseWorldstate;
|
||||||
|
|
||||||
std::unique_ptr<PlayerPacketController> playerPacketController;
|
std::unique_ptr<PlayerPacketController> playerPacketController;
|
||||||
std::unique_ptr<ActorPacketController> actorPacketController;
|
std::unique_ptr<ActorPacketController> actorPacketController;
|
||||||
std::unique_ptr<ObjectPacketController> objectPacketController;
|
std::unique_ptr<ObjectPacketController> objectPacketController;
|
||||||
|
std::unique_ptr<WorldstatePacketController> worldstatePacketController;
|
||||||
|
|
||||||
bool running;
|
bool running;
|
||||||
int exitCode;
|
int exitCode;
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
// Created by koncord on 03.04.17.
|
// Created by koncord on 03.04.17.
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef OPENMW_WORLDPROCESSOR_HPP
|
#ifndef OPENMW_OBJECTPROCESSOR_HPP
|
||||||
#define OPENMW_WORLDPROCESSOR_HPP
|
#define OPENMW_OBJECTPROCESSOR_HPP
|
||||||
|
|
||||||
|
|
||||||
#include <components/openmw-mp/Base/BasePacketProcessor.hpp>
|
#include <components/openmw-mp/Base/BasePacketProcessor.hpp>
|
||||||
|
@ -24,4 +24,4 @@ namespace mwmp
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif //OPENMW_WORLDPROCESSOR_HPP
|
#endif //OPENMW_OBJECTPROCESSOR_HPP
|
||||||
|
|
40
apps/openmw-mp/processors/WorldstateProcessor.cpp
Normal file
40
apps/openmw-mp/processors/WorldstateProcessor.cpp
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
#include "WorldstateProcessor.hpp"
|
||||||
|
#include "Networking.hpp"
|
||||||
|
|
||||||
|
using namespace mwmp;
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
typename BasePacketProcessor<T>::processors_t BasePacketProcessor<T>::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])
|
||||||
|
{
|
||||||
|
auto player = Players::getPlayerByGUID(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;
|
||||||
|
}
|
22
apps/openmw-mp/processors/WorldstateProcessor.hpp
Normal file
22
apps/openmw-mp/processors/WorldstateProcessor.hpp
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
#ifndef OPENMW_BASEWORLDSTATEPROCESSOR_HPP
|
||||||
|
#define OPENMW_BASEWORLDSTATEPROCESSOR_HPP
|
||||||
|
|
||||||
|
#include <components/openmw-mp/Base/BasePacketProcessor.hpp>
|
||||||
|
#include <components/openmw-mp/Packets/BasePacket.hpp>
|
||||||
|
#include <components/openmw-mp/Packets/Worldstate/WorldstatePacket.hpp>
|
||||||
|
#include <components/openmw-mp/NetworkMessages.hpp>
|
||||||
|
#include "Players.hpp"
|
||||||
|
|
||||||
|
namespace mwmp
|
||||||
|
{
|
||||||
|
class WorldstateProcessor : public BasePacketProcessor<WorldstateProcessor>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
virtual void Do(WorldstatePacket &packet, Player &player, BaseWorldstate &worldstate);
|
||||||
|
|
||||||
|
static bool Process(RakNet::Packet &packet, BaseWorldstate &worldstate) noexcept;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif //OPENMW_BASEWORLDSTATEPROCESSOR_HPP
|
|
@ -104,7 +104,8 @@ add_openmw_dir (mwmp Main Networking LocalPlayer DedicatedPlayer PlayerList Loca
|
||||||
add_openmw_dir (mwmp/GUI GUIChat GUILogin PlayerMarkerCollection GUIDialogList TextInputDialog GUICustomWindow
|
add_openmw_dir (mwmp/GUI GUIChat GUILogin PlayerMarkerCollection GUIDialogList TextInputDialog GUICustomWindow
|
||||||
)
|
)
|
||||||
|
|
||||||
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
|
add_openmw_dir (mwmp/processors/actor ProcessorActorAI ProcessorActorAnimFlags ProcessorActorAnimPlay ProcessorActorAttack
|
||||||
|
|
|
@ -325,7 +325,10 @@ namespace MWClass
|
||||||
// add reach and attack speed for melee weapon
|
// add reach and attack speed for melee weapon
|
||||||
if (ref->mBase->mData.mType < 9 && Settings::Manager::getBool("show melee info", "Game"))
|
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<ESM::GameSetting>().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}");
|
text += MWGui::ToolTips::getPercentString(ref->mBase->mData.mSpeed, "#{sAttributeSpeed}");
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,7 @@
|
||||||
#include "processors/PlayerProcessor.hpp"
|
#include "processors/PlayerProcessor.hpp"
|
||||||
#include "processors/ObjectProcessor.hpp"
|
#include "processors/ObjectProcessor.hpp"
|
||||||
#include "processors/ActorProcessor.hpp"
|
#include "processors/ActorProcessor.hpp"
|
||||||
|
#include "processors/WorldstateProcessor.hpp"
|
||||||
#include "GUIController.hpp"
|
#include "GUIController.hpp"
|
||||||
#include "CellController.hpp"
|
#include "CellController.hpp"
|
||||||
|
|
||||||
|
@ -198,7 +199,7 @@ string listComparison(PacketPreInit::PluginContainer checksums, PacketPreInit::P
|
||||||
}
|
}
|
||||||
|
|
||||||
Networking::Networking(): peer(RakNet::RakPeerInterface::GetInstance()), playerPacketController(peer),
|
Networking::Networking(): peer(RakNet::RakPeerInterface::GetInstance()), playerPacketController(peer),
|
||||||
actorPacketController(peer), objectPacketController(peer)
|
actorPacketController(peer), objectPacketController(peer), worldstatePacketController(peer)
|
||||||
{
|
{
|
||||||
|
|
||||||
RakNet::SocketDescriptor sd;
|
RakNet::SocketDescriptor sd;
|
||||||
|
@ -209,6 +210,7 @@ Networking::Networking(): peer(RakNet::RakPeerInterface::GetInstance()), playerP
|
||||||
playerPacketController.SetStream(0, &bsOut);
|
playerPacketController.SetStream(0, &bsOut);
|
||||||
actorPacketController.SetStream(0, &bsOut);
|
actorPacketController.SetStream(0, &bsOut);
|
||||||
objectPacketController.SetStream(0, &bsOut);
|
objectPacketController.SetStream(0, &bsOut);
|
||||||
|
worldstatePacketController.SetStream(0, &bsOut);
|
||||||
|
|
||||||
connected = 0;
|
connected = 0;
|
||||||
ProcessorInitializer();
|
ProcessorInitializer();
|
||||||
|
@ -435,6 +437,11 @@ void Networking::receiveMessage(RakNet::Packet *packet)
|
||||||
if (!ObjectProcessor::Process(*packet, objectList))
|
if (!ObjectProcessor::Process(*packet, objectList))
|
||||||
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Unhandled ObjectPacket with identifier %i has arrived", (int) packet->data[0]);
|
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Unhandled ObjectPacket with identifier %i has arrived", (int) 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)
|
PlayerPacket *Networking::getPlayerPacket(RakNet::MessageID id)
|
||||||
|
@ -452,6 +459,11 @@ ObjectPacket *Networking::getObjectPacket(RakNet::MessageID id)
|
||||||
return objectPacketController.GetPacket(id);
|
return objectPacketController.GetPacket(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WorldstatePacket *Networking::getWorldstatePacket(RakNet::MessageID id)
|
||||||
|
{
|
||||||
|
return worldstatePacketController.GetPacket(id);
|
||||||
|
}
|
||||||
|
|
||||||
LocalPlayer *Networking::getLocalPlayer()
|
LocalPlayer *Networking::getLocalPlayer()
|
||||||
{
|
{
|
||||||
return mwmp::Main::get().getLocalPlayer();
|
return mwmp::Main::get().getLocalPlayer();
|
||||||
|
@ -467,6 +479,11 @@ ObjectList *Networking::getObjectList()
|
||||||
return &objectList;
|
return &objectList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BaseWorldstate *Networking::getWorldstate()
|
||||||
|
{
|
||||||
|
return &worldstate;
|
||||||
|
}
|
||||||
|
|
||||||
bool Networking::isConnected()
|
bool Networking::isConnected()
|
||||||
{
|
{
|
||||||
return connected;
|
return connected;
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#include <components/openmw-mp/Controllers/PlayerPacketController.hpp>
|
#include <components/openmw-mp/Controllers/PlayerPacketController.hpp>
|
||||||
#include <components/openmw-mp/Controllers/ActorPacketController.hpp>
|
#include <components/openmw-mp/Controllers/ActorPacketController.hpp>
|
||||||
#include <components/openmw-mp/Controllers/ObjectPacketController.hpp>
|
#include <components/openmw-mp/Controllers/ObjectPacketController.hpp>
|
||||||
|
#include <components/openmw-mp/Controllers/WorldstatePacketController.hpp>
|
||||||
|
|
||||||
#include <components/files/collections.hpp>
|
#include <components/files/collections.hpp>
|
||||||
|
|
||||||
|
@ -34,6 +35,7 @@ namespace mwmp
|
||||||
PlayerPacket *getPlayerPacket(RakNet::MessageID id);
|
PlayerPacket *getPlayerPacket(RakNet::MessageID id);
|
||||||
ActorPacket *getActorPacket(RakNet::MessageID id);
|
ActorPacket *getActorPacket(RakNet::MessageID id);
|
||||||
ObjectPacket *getObjectPacket(RakNet::MessageID id);
|
ObjectPacket *getObjectPacket(RakNet::MessageID id);
|
||||||
|
WorldstatePacket *getWorldstatePacket(RakNet::MessageID id);
|
||||||
|
|
||||||
RakNet::SystemAddress serverAddress()
|
RakNet::SystemAddress serverAddress()
|
||||||
{
|
{
|
||||||
|
@ -45,6 +47,7 @@ namespace mwmp
|
||||||
LocalPlayer *getLocalPlayer();
|
LocalPlayer *getLocalPlayer();
|
||||||
ActorList *getActorList();
|
ActorList *getActorList();
|
||||||
ObjectList *getObjectList();
|
ObjectList *getObjectList();
|
||||||
|
BaseWorldstate *getWorldstate();
|
||||||
|
|
||||||
std::string getNetworkStatistics();
|
std::string getNetworkStatistics();
|
||||||
|
|
||||||
|
@ -57,9 +60,11 @@ namespace mwmp
|
||||||
PlayerPacketController playerPacketController;
|
PlayerPacketController playerPacketController;
|
||||||
ActorPacketController actorPacketController;
|
ActorPacketController actorPacketController;
|
||||||
ObjectPacketController objectPacketController;
|
ObjectPacketController objectPacketController;
|
||||||
|
WorldstatePacketController worldstatePacketController;
|
||||||
|
|
||||||
ActorList actorList;
|
ActorList actorList;
|
||||||
ObjectList objectList;
|
ObjectList objectList;
|
||||||
|
BaseWorldstate worldstate;
|
||||||
|
|
||||||
void receiveMessage(RakNet::Packet *packet);
|
void receiveMessage(RakNet::Packet *packet);
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#ifndef OPENMW_WORLDEVENT_HPP
|
#ifndef OPENMW_OBJECTLIST_HPP
|
||||||
#define OPENMW_WORLDEVENT_HPP
|
#define OPENMW_OBJECTLIST_HPP
|
||||||
|
|
||||||
#include <components/openmw-mp/Base/BaseObject.hpp>
|
#include <components/openmw-mp/Base/BaseObject.hpp>
|
||||||
#include "../mwworld/cellstore.hpp"
|
#include "../mwworld/cellstore.hpp"
|
||||||
|
@ -89,4 +89,4 @@ namespace mwmp
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif //OPENMW_WORLDEVENT_HPP
|
#endif //OPENMW_OBJECTLIST_HPP
|
||||||
|
|
|
@ -1,9 +1,5 @@
|
||||||
//
|
#ifndef OPENMW_OBJECTPROCESSSOR_HPP
|
||||||
// Created by koncord on 16.04.17.
|
#define OPENMW_OBJECTPROCESSSOR_HPP
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef OPENMW_WORLDPROCESSSOR_HPP
|
|
||||||
#define OPENMW_WORLDPROCESSSOR_HPP
|
|
||||||
|
|
||||||
#include <components/openmw-mp/Log.hpp>
|
#include <components/openmw-mp/Log.hpp>
|
||||||
#include <components/openmw-mp/NetworkMessages.hpp>
|
#include <components/openmw-mp/NetworkMessages.hpp>
|
||||||
|
@ -25,4 +21,4 @@ namespace mwmp
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif //OPENMW_WORLDPROCESSSOR_HPP
|
#endif //OPENMW_OBJECTPROCESSSOR_HPP
|
||||||
|
|
|
@ -1,11 +1,6 @@
|
||||||
//
|
|
||||||
// Created by koncord on 31.03.17.
|
|
||||||
//
|
|
||||||
|
|
||||||
#include "ProcessorInitializer.hpp"
|
#include "ProcessorInitializer.hpp"
|
||||||
|
|
||||||
#include "PlayerProcessor.hpp"
|
#include "PlayerProcessor.hpp"
|
||||||
|
|
||||||
#include "player/ProcessorChatMessage.hpp"
|
#include "player/ProcessorChatMessage.hpp"
|
||||||
#include "player/ProcessorGUIMessageBox.hpp"
|
#include "player/ProcessorGUIMessageBox.hpp"
|
||||||
#include "player/ProcessorGUIWindow.hpp"
|
#include "player/ProcessorGUIWindow.hpp"
|
||||||
|
@ -81,6 +76,7 @@
|
||||||
#include "object/ProcessorScriptGlobalFloat.hpp"
|
#include "object/ProcessorScriptGlobalFloat.hpp"
|
||||||
#include "object/ProcessorVideoPlay.hpp"
|
#include "object/ProcessorVideoPlay.hpp"
|
||||||
|
|
||||||
|
#include "ActorProcessor.hpp"
|
||||||
#include "actor/ProcessorActorAI.hpp"
|
#include "actor/ProcessorActorAI.hpp"
|
||||||
#include "actor/ProcessorActorAnimFlags.hpp"
|
#include "actor/ProcessorActorAnimFlags.hpp"
|
||||||
#include "actor/ProcessorActorAnimPlay.hpp"
|
#include "actor/ProcessorActorAnimPlay.hpp"
|
||||||
|
@ -96,6 +92,8 @@
|
||||||
#include "actor/ProcessorActorStatsDynamic.hpp"
|
#include "actor/ProcessorActorStatsDynamic.hpp"
|
||||||
#include "actor/ProcessorActorTest.hpp"
|
#include "actor/ProcessorActorTest.hpp"
|
||||||
|
|
||||||
|
#include "WorldstateProcessor.hpp"
|
||||||
|
|
||||||
using namespace mwmp;
|
using namespace mwmp;
|
||||||
|
|
||||||
void ProcessorInitializer()
|
void ProcessorInitializer()
|
||||||
|
|
40
apps/openmw/mwmp/processors/WorldstateProcessor.cpp
Normal file
40
apps/openmw/mwmp/processors/WorldstateProcessor.cpp
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
#include "../Networking.hpp"
|
||||||
|
#include "WorldstateProcessor.hpp"
|
||||||
|
#include "../Main.hpp"
|
||||||
|
|
||||||
|
using namespace mwmp;
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
typename BasePacketProcessor<T>::processors_t BasePacketProcessor<T>::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;
|
||||||
|
}
|
22
apps/openmw/mwmp/processors/WorldstateProcessor.hpp
Normal file
22
apps/openmw/mwmp/processors/WorldstateProcessor.hpp
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
#ifndef OPENMW_WORLDSTATEPROCESSOR_HPP
|
||||||
|
#define OPENMW_WORLDSTATEPROCESSOR_HPP
|
||||||
|
|
||||||
|
#include <components/openmw-mp/Log.hpp>
|
||||||
|
#include <components/openmw-mp/NetworkMessages.hpp>
|
||||||
|
#include <components/openmw-mp/Packets/Worldstate/WorldstatePacket.hpp>
|
||||||
|
#include "BaseClientPacketProcessor.hpp"
|
||||||
|
|
||||||
|
namespace mwmp
|
||||||
|
{
|
||||||
|
class WorldstateProcessor : public BasePacketProcessor<WorldstateProcessor>, public BaseClientPacketProcessor
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual void Do(WorldstatePacket &packet, BaseWorldstate &worldstate) = 0;
|
||||||
|
|
||||||
|
static bool Process(RakNet::Packet &packet, BaseWorldstate &worldstate);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif //OPENMW_WORLDSTATEPROCESSOR_HPP
|
|
@ -148,7 +148,7 @@ namespace MWRender
|
||||||
{
|
{
|
||||||
for (int cellX=0; cellX<mCellSize; ++cellX)
|
for (int cellX=0; cellX<mCellSize; ++cellX)
|
||||||
{
|
{
|
||||||
int vertexX = static_cast<int>(float(cellX)/float(mCellSize) * 9);
|
int vertexX = static_cast<int>(float(cellX) / float(mCellSize) * 9);
|
||||||
int vertexY = static_cast<int>(float(cellY) / float(mCellSize) * 9);
|
int vertexY = static_cast<int>(float(cellY) / float(mCellSize) * 9);
|
||||||
|
|
||||||
int texelX = (x-mMinX) * mCellSize + cellX;
|
int texelX = (x-mMinX) * mCellSize + cellX;
|
||||||
|
@ -158,9 +158,9 @@ namespace MWRender
|
||||||
|
|
||||||
float y2 = 0;
|
float y2 = 0;
|
||||||
if (land && (land->mDataTypes & ESM::Land::DATA_WNAM))
|
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
|
else
|
||||||
y2 = (SCHAR_MIN << 4) / 2048.f;
|
y2 = SCHAR_MIN / 128.f;
|
||||||
if (y2 < 0)
|
if (y2 < 0)
|
||||||
{
|
{
|
||||||
r = static_cast<unsigned char>(14 * y2 + 38);
|
r = static_cast<unsigned char>(14 * y2 + 38);
|
||||||
|
|
|
@ -951,10 +951,11 @@ std::pair<Sound_Handle,size_t> OpenAL_Output::loadSound(const std::string &fname
|
||||||
getALError();
|
getALError();
|
||||||
|
|
||||||
std::vector<char> data;
|
std::vector<char> data;
|
||||||
ALenum format;
|
ALenum format = AL_NONE;
|
||||||
int srate;
|
int srate = 0;
|
||||||
|
|
||||||
try {
|
try
|
||||||
|
{
|
||||||
DecoderPtr decoder = mManager.getDecoder();
|
DecoderPtr decoder = mManager.getDecoder();
|
||||||
// Workaround: Bethesda at some point converted some of the files to mp3, but the references were kept as .wav.
|
// Workaround: Bethesda at some point converted some of the files to mp3, but the references were kept as .wav.
|
||||||
if(decoder->mResourceMgr->exists(fname))
|
if(decoder->mResourceMgr->exists(fname))
|
||||||
|
@ -974,7 +975,8 @@ std::pair<Sound_Handle,size_t> OpenAL_Output::loadSound(const std::string &fname
|
||||||
format = getALFormat(chans, type);
|
format = getALFormat(chans, type);
|
||||||
if(format) decoder->readAll(data);
|
if(format) decoder->readAll(data);
|
||||||
}
|
}
|
||||||
catch(std::exception &e) {
|
catch(std::exception &e)
|
||||||
|
{
|
||||||
std::cerr<< "Failed to load audio from "<<fname<<": "<<e.what() <<std::endl;
|
std::cerr<< "Failed to load audio from "<<fname<<": "<<e.what() <<std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -150,11 +150,11 @@ add_component_dir (openmw-mp
|
||||||
)
|
)
|
||||||
|
|
||||||
add_component_dir (openmw-mp/Base
|
add_component_dir (openmw-mp/Base
|
||||||
BaseActor BaseObjectList BaseNetCreature BasePacketProcessor BasePlayer BaseStructs
|
BaseActor BaseObjectList BaseNetCreature BasePacketProcessor BasePlayer BaseStructs BaseWorldstate
|
||||||
)
|
)
|
||||||
|
|
||||||
add_component_dir (openmw-mp/Controllers
|
add_component_dir (openmw-mp/Controllers
|
||||||
PlayerPacketController ActorPacketController ObjectPacketController PacketController
|
PlayerPacketController ActorPacketController ObjectPacketController PacketController WorldstatePacketController
|
||||||
)
|
)
|
||||||
|
|
||||||
add_component_dir(openmw-mp/Master
|
add_component_dir(openmw-mp/Master
|
||||||
|
@ -197,6 +197,10 @@ add_component_dir (openmw-mp/Packets/Object
|
||||||
PacketScriptMemberFloat PacketScriptGlobalShort PacketScriptGlobalFloat
|
PacketScriptMemberFloat PacketScriptGlobalShort PacketScriptGlobalFloat
|
||||||
)
|
)
|
||||||
|
|
||||||
|
add_component_dir (openmw-mp/Packets/Worldstate
|
||||||
|
WorldstatePacket
|
||||||
|
)
|
||||||
|
|
||||||
add_component_dir (fallback
|
add_component_dir (fallback
|
||||||
fallback validate
|
fallback validate
|
||||||
)
|
)
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#define OPENMW_BASESTRUCTS_HPP
|
#define OPENMW_BASESTRUCTS_HPP
|
||||||
|
|
||||||
#include <components/esm/statstate.hpp>
|
#include <components/esm/statstate.hpp>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include <RakNetTypes.h>
|
#include <RakNetTypes.h>
|
||||||
|
|
||||||
|
|
26
components/openmw-mp/Base/BaseWorldstate.hpp
Normal file
26
components/openmw-mp/Base/BaseWorldstate.hpp
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
#ifndef OPENMW_BASEWORLDSTATE_HPP
|
||||||
|
#define OPENMW_BASEWORLDSTATE_HPP
|
||||||
|
|
||||||
|
#include <components/openmw-mp/Base/BaseStructs.hpp>
|
||||||
|
|
||||||
|
#include <RakNetTypes.h>
|
||||||
|
|
||||||
|
namespace mwmp
|
||||||
|
{
|
||||||
|
|
||||||
|
class BaseWorldstate
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
BaseWorldstate()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
RakNet::RakNetGUID guid;
|
||||||
|
|
||||||
|
bool isValid;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif //OPENMW_BASEWORLDSTATE_HPP
|
|
@ -1,5 +1,5 @@
|
||||||
#ifndef OPENMW_WORLDPACKETCONTROLLER_HPP
|
#ifndef OPENMW_OBJECTPACKETCONTROLLER_HPP
|
||||||
#define OPENMW_WORLDPACKETCONTROLLER_HPP
|
#define OPENMW_OBJECTPACKETCONTROLLER_HPP
|
||||||
|
|
||||||
|
|
||||||
#include "../Packets/Object/ObjectPacket.hpp"
|
#include "../Packets/Object/ObjectPacket.hpp"
|
||||||
|
@ -14,4 +14,4 @@ namespace mwmp
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif //OPENMW_WORLDPACKETCONTROLLER_HPP
|
#endif //OPENMW_OBJECTPACKETCONTROLLER_HPP
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
#include "WorldstatePacketController.hpp"
|
||||||
|
|
||||||
|
mwmp::WorldstatePacketController::WorldstatePacketController(RakNet::RakPeerInterface *peer)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
#ifndef OPENMW_WORLDSTATEPACKETCONTROLLER_HPP
|
||||||
|
#define OPENMW_WORLDSTATEPACKETCONTROLLER_HPP
|
||||||
|
|
||||||
|
|
||||||
|
#include "../Packets/Worldstate/WorldstatePacket.hpp"
|
||||||
|
#include "BasePacketController.hpp"
|
||||||
|
|
||||||
|
namespace mwmp
|
||||||
|
{
|
||||||
|
class WorldstatePacketController: public BasePacketController<WorldstatePacket>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
WorldstatePacketController(RakNet::RakPeerInterface *peer);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif //OPENMW_WORLDSTATEPACKETCONTROLLER_HPP
|
|
@ -116,8 +116,9 @@ enum OrderingChannel
|
||||||
CHANNEL_SYSTEM = 0,
|
CHANNEL_SYSTEM = 0,
|
||||||
CHANNEL_ACTOR,
|
CHANNEL_ACTOR,
|
||||||
CHANNEL_PLAYER,
|
CHANNEL_PLAYER,
|
||||||
CHANNEL_WORLDEVENT,
|
CHANNEL_OBJECT,
|
||||||
CHANNEL_MASTER
|
CHANNEL_MASTER,
|
||||||
|
CHANNEL_WORLDSTATE
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ ObjectPacket::ObjectPacket(RakNet::RakPeerInterface *peer) : BasePacket(peer)
|
||||||
packetID = 0;
|
packetID = 0;
|
||||||
priority = HIGH_PRIORITY;
|
priority = HIGH_PRIORITY;
|
||||||
reliability = RELIABLE_ORDERED;
|
reliability = RELIABLE_ORDERED;
|
||||||
orderChannel = CHANNEL_WORLDEVENT;
|
orderChannel = CHANNEL_OBJECT;
|
||||||
this->peer = peer;
|
this->peer = peer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#ifndef OPENMW_WORLDPACKET_HPP
|
#ifndef OPENMW_OBJECTPACKET_HPP
|
||||||
#define OPENMW_WORLDPACKET_HPP
|
#define OPENMW_OBJECTPACKET_HPP
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <RakNetTypes.h>
|
#include <RakNetTypes.h>
|
||||||
|
@ -32,4 +32,4 @@ namespace mwmp
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif //OPENMW_WORLDPACKET_HPP
|
#endif //OPENMW_OBJECTPACKET_HPP
|
||||||
|
|
26
components/openmw-mp/Packets/Worldstate/WorldstatePacket.cpp
Normal file
26
components/openmw-mp/Packets/Worldstate/WorldstatePacket.cpp
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
#include <components/openmw-mp/NetworkMessages.hpp>
|
||||||
|
#include <PacketPriority.h>
|
||||||
|
#include <RakPeer.h>
|
||||||
|
#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;
|
||||||
|
}
|
||||||
|
|
||||||
|
void WorldstatePacket::setWorldstate(BaseWorldstate *worldstate)
|
||||||
|
{
|
||||||
|
this->worldstate = worldstate;
|
||||||
|
guid = worldstate->guid;
|
||||||
|
}
|
||||||
|
|
||||||
|
BaseWorldstate *WorldstatePacket::getWorldstate()
|
||||||
|
{
|
||||||
|
return worldstate;
|
||||||
|
}
|
30
components/openmw-mp/Packets/Worldstate/WorldstatePacket.hpp
Normal file
30
components/openmw-mp/Packets/Worldstate/WorldstatePacket.hpp
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
#ifndef OPENMW_WORLDSTATEPACKET_HPP
|
||||||
|
#define OPENMW_WORLDSTATEPACKET_HPP
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <RakNetTypes.h>
|
||||||
|
#include <BitStream.h>
|
||||||
|
#include <PacketPriority.h>
|
||||||
|
#include <components/openmw-mp/Base/BaseWorldstate.hpp>
|
||||||
|
|
||||||
|
#include <components/openmw-mp/Packets/BasePacket.hpp>
|
||||||
|
|
||||||
|
namespace mwmp
|
||||||
|
{
|
||||||
|
class WorldstatePacket : public BasePacket
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
WorldstatePacket(RakNet::RakPeerInterface *peer);
|
||||||
|
|
||||||
|
~WorldstatePacket() override = default;
|
||||||
|
|
||||||
|
void setWorldstate(BaseWorldstate *worldstate);
|
||||||
|
BaseWorldstate *getWorldstate();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
BaseWorldstate *worldstate;
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif //OPENMW_WORLDSTATEPACKET_HPP
|
Loading…
Reference in a new issue