From 9852076590a30e84217f005b6ade0e5e0a4333b2 Mon Sep 17 00:00:00 2001 From: David Cernat Date: Mon, 10 Apr 2017 18:24:30 +0300 Subject: [PATCH] [Client] Send all NPC data to newly arriving players --- apps/openmw/mwmp/DedicatedPlayer.cpp | 17 +++++++++++++---- apps/openmw/mwmp/LocalActor.cpp | 2 +- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/apps/openmw/mwmp/DedicatedPlayer.cpp b/apps/openmw/mwmp/DedicatedPlayer.cpp index 2de818fae..d367e1076 100644 --- a/apps/openmw/mwmp/DedicatedPlayer.cpp +++ b/apps/openmw/mwmp/DedicatedPlayer.cpp @@ -2,7 +2,8 @@ // Created by koncord on 02.01.16. // -#include "DedicatedPlayer.hpp" +#include +#include #include "../mwbase/environment.hpp" @@ -24,16 +25,16 @@ #include "../mwworld/action.hpp" #include "../mwworld/cellstore.hpp" #include "../mwworld/customdata.hpp" +#include "../mwworld/inventorystore.hpp" #include "../mwworld/player.hpp" #include "../mwworld/worldimp.hpp" +#include "DedicatedPlayer.hpp" #include "Main.hpp" #include "GUIController.hpp" #include "CellController.hpp" -#include "../mwworld/inventorystore.hpp" -#include -#include + using namespace mwmp; using namespace std; @@ -495,6 +496,14 @@ void DedicatedPlayer::updateCell() // update has been called ptr.getBase()->canChangeCell = true; updatePtr(world->moveObject(ptr, cellStore, position.pos[0], position.pos[1], position.pos[2])); + + // If this player is now in a cell that is active for us, we should send them all + // NPC data in that cell + if (MWBase::Environment::get().getWorld()->isCellActive(cellStore)) + { + if (Main::get().getCellController()->isActiveCell(cell)) + Main::get().getCellController()->getCell(cell)->updateLocal(true); + } } diff --git a/apps/openmw/mwmp/LocalActor.cpp b/apps/openmw/mwmp/LocalActor.cpp index 3506ba51b..c5c4580f0 100644 --- a/apps/openmw/mwmp/LocalActor.cpp +++ b/apps/openmw/mwmp/LocalActor.cpp @@ -36,7 +36,7 @@ void LocalActor::updatePosition(bool forceUpdate) bool posIsChanging = (direction.pos[0] != 0 || direction.pos[1] != 0 || direction.pos[2] != 0 || direction.rot[0] != 0 || direction.rot[1] != 0 || direction.rot[2] != 0); - if (posIsChanging || posWasChanged) + if (posIsChanging || posWasChanged || forceUpdate) { posWasChanged = posIsChanging;