From 494b10b97ed3e31b2b7073f5c5fc90a4ce542a28 Mon Sep 17 00:00:00 2001 From: David Cernat Date: Sat, 18 Nov 2017 01:47:18 +0200 Subject: [PATCH] [Server] Send player packets in a more appropriate order Previously, the fact that a character class packet got sent after a dynamic stats packet caused the dynamic stats to get overridden on the client by the class change. --- apps/openmw-mp/Player.cpp | 49 +++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/apps/openmw-mp/Player.cpp b/apps/openmw-mp/Player.cpp index ac3d22f86..03e1d5dbf 100644 --- a/apps/openmw-mp/Player.cpp +++ b/apps/openmw-mp/Player.cpp @@ -112,37 +112,40 @@ void Player::update() { auto plPCtrl = mwmp::Networking::get().getPlayerPacketController(); - if (inventory.isEquipmentChanged()) + if (baseInfoChanged) { - auto packet = plPCtrl->GetPacket(ID_PLAYER_EQUIPMENT); - packet->setPlayer(this); + auto packet = plPCtrl->GetPacket(ID_PLAYER_BASEINFO); + packet->setPlayer(basePlayer); packet->Send(false); packet->Send(true); - inventory.resetEquipmentFlag(); } - if (inventory.inventoryChangeType() != 0) + // The character class can override values from below on the client, so send it first + cClass.update(); + + if (statsChanged) { - auto packet = plPCtrl->GetPacket(ID_PLAYER_EQUIPMENT); - packet->setPlayer(this); - packet->Send(/*toOthers*/ false); - inventory.resetInventoryFlag(); + auto packet = plPCtrl->GetPacket(ID_PLAYER_STATS_DYNAMIC); + packet->setPlayer(basePlayer); + packet->Send(false); + packet->Send(true); } - if (attributesChanged) + if (positionChanged) { - auto packet = plPCtrl->GetPacket(ID_PLAYER_ATTRIBUTE); + auto packet = plPCtrl->GetPacket(ID_PLAYER_POSITION); packet->setPlayer(basePlayer); packet->Send(false); - packet->Send(true); } - if (statsChanged) + + if (attributesChanged) { - auto packet = plPCtrl->GetPacket(ID_PLAYER_STATS_DYNAMIC); + auto packet = plPCtrl->GetPacket(ID_PLAYER_ATTRIBUTE); packet->setPlayer(basePlayer); packet->Send(false); packet->Send(true); } + if (skillsChanged) { auto packet = plPCtrl->GetPacket(ID_PLAYER_SKILL); @@ -150,19 +153,22 @@ void Player::update() packet->Send(false); packet->Send(true); } - if (baseInfoChanged) + + if (inventory.isEquipmentChanged()) { - auto packet = plPCtrl->GetPacket(ID_PLAYER_BASEINFO); - packet->setPlayer(basePlayer); + auto packet = plPCtrl->GetPacket(ID_PLAYER_EQUIPMENT); + packet->setPlayer(this); packet->Send(false); packet->Send(true); + inventory.resetEquipmentFlag(); } - if (positionChanged) + if (inventory.inventoryChangeType() != 0) { - auto packet = plPCtrl->GetPacket(ID_PLAYER_POSITION); - packet->setPlayer(basePlayer); - packet->Send(false); + auto packet = plPCtrl->GetPacket(ID_PLAYER_EQUIPMENT); + packet->setPlayer(this); + packet->Send(/*toOthers*/ false); + inventory.resetInventoryFlag(); } if (changedMap) @@ -181,7 +187,6 @@ void Player::update() cellAPI.resetChangedCell(); } - cClass.update(); settings.update(); books.update(); gui.update();