From 4cc0216e0a38aaf2fb9fc0939eb59156a155e08e Mon Sep 17 00:00:00 2001 From: David Cernat Date: Sun, 19 Nov 2017 00:59:32 +0200 Subject: [PATCH] [Server] Send cell changes before position changes, and prioritize both Previously, a script changing a player's cell and position at the same time would end up sending a position packet first and then a cell change packet that overrode the former, with the player ending up at the center of the destination cell instead of at the correct position. --- apps/openmw-mp/Player.cpp | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/apps/openmw-mp/Player.cpp b/apps/openmw-mp/Player.cpp index 111747618..cda59e711 100644 --- a/apps/openmw-mp/Player.cpp +++ b/apps/openmw-mp/Player.cpp @@ -123,6 +123,22 @@ void Player::update() packet->Send(true); } + // Make sure we send a cell change before we send the position so the position isn't overridden + if (cellAPI.isChangedCell()) + { + auto packet = mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_CELL_CHANGE); + packet->setPlayer(this); + packet->Send(/*toOthers*/ false); + cellAPI.resetChangedCell(); + } + + if (positionChanged) + { + auto packet = plPCtrl->GetPacket(ID_PLAYER_POSITION); + packet->setPlayer(basePlayer); + packet->Send(false); + } + // The character class can override values from below on the client, so send it first cClass.update(); @@ -142,13 +158,6 @@ void Player::update() packet->Send(true); } - if (positionChanged) - { - auto packet = plPCtrl->GetPacket(ID_PLAYER_POSITION); - packet->setPlayer(basePlayer); - packet->Send(false); - } - if (attributesChanged) { auto packet = plPCtrl->GetPacket(ID_PLAYER_ATTRIBUTE); @@ -190,20 +199,11 @@ void Player::update() changedMap = false; } - if (cellAPI.isChangedCell()) - { - auto packet = mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_CELL_CHANGE); - packet->setPlayer(this); - packet->Send(/*toOthers*/ false); - cellAPI.resetChangedCell(); - } - settings.update(); books.update(); gui.update(); dialogue.update(); factions.update(); - cellAPI.update(); quests.update(); spells.update();