From 399e049d87a0712c2baa4469d9ce799687b5b072 Mon Sep 17 00:00:00 2001 From: David Cernat Date: Fri, 27 Apr 2018 03:45:17 +0300 Subject: [PATCH] [Client] Fix logic for minimal size packets in LocalPlayer Previously, the index changes were not cleared at the start of their corresponding update functions, which in turn meant that an Attribute/Skill/StatsDynamic/Equipment packet received by a player from the server made that player send back the same packet, as the index changes from it were retained. Additionally, exchangeFullInfo was not set to false, thus sometimes leading to constant full exchanges of information. --- apps/openmw/mwmp/LocalPlayer.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/apps/openmw/mwmp/LocalPlayer.cpp b/apps/openmw/mwmp/LocalPlayer.cpp index dd1e0515a..e47cea911 100644 --- a/apps/openmw/mwmp/LocalPlayer.cpp +++ b/apps/openmw/mwmp/LocalPlayer.cpp @@ -194,6 +194,9 @@ bool LocalPlayer::hasFinishedCharGen() void LocalPlayer::updateStatsDynamic(bool forceUpdate) { + if (statsDynamicIndexChanges.size() > 0) + statsDynamicIndexChanges.clear(); + MWWorld::Ptr ptrPlayer = getPlayerPtr(); MWMechanics::CreatureStats *ptrCreatureStats = &ptrPlayer.getClass().getCreatureStats(ptrPlayer); @@ -231,9 +234,9 @@ void LocalPlayer::updateStatsDynamic(bool forceUpdate) magicka.writeState(creatureStats.mDynamic[1]); fatigue.writeState(creatureStats.mDynamic[2]); + exchangeFullInfo = false; getNetworking()->getPlayerPacket(ID_PLAYER_STATS_DYNAMIC)->setPlayer(this); getNetworking()->getPlayerPacket(ID_PLAYER_STATS_DYNAMIC)->Send(); - statsDynamicIndexChanges.clear(); } } @@ -243,6 +246,9 @@ void LocalPlayer::updateAttributes(bool forceUpdate) // overwritten by the werewolf ones if (isWerewolf) return; + if (attributeIndexChanges.size() > 0) + attributeIndexChanges.clear(); + MWWorld::Ptr ptrPlayer = getPlayerPtr(); const MWMechanics::NpcStats &ptrNpcStats = ptrPlayer.getClass().getNpcStats(ptrPlayer); @@ -261,9 +267,9 @@ void LocalPlayer::updateAttributes(bool forceUpdate) if (attributeIndexChanges.size() > 0) { + exchangeFullInfo = false; getNetworking()->getPlayerPacket(ID_PLAYER_ATTRIBUTE)->setPlayer(this); getNetworking()->getPlayerPacket(ID_PLAYER_ATTRIBUTE)->Send(); - attributeIndexChanges.clear(); } } @@ -273,6 +279,9 @@ void LocalPlayer::updateSkills(bool forceUpdate) // overwritten by the werewolf ones if (isWerewolf) return; + if (skillIndexChanges.size() > 0) + skillIndexChanges.clear(); + MWWorld::Ptr ptrPlayer = getPlayerPtr(); const MWMechanics::NpcStats &ptrNpcStats = ptrPlayer.getClass().getNpcStats(ptrPlayer); @@ -291,9 +300,9 @@ void LocalPlayer::updateSkills(bool forceUpdate) if (skillIndexChanges.size() > 0) { + exchangeFullInfo = false; getNetworking()->getPlayerPacket(ID_PLAYER_SKILL)->setPlayer(this); getNetworking()->getPlayerPacket(ID_PLAYER_SKILL)->Send(); - skillIndexChanges.clear(); } } @@ -432,6 +441,9 @@ void LocalPlayer::updateCell(bool forceUpdate) void LocalPlayer::updateEquipment(bool forceUpdate) { + if (equipmentIndexChanges.size() > 0) + equipmentIndexChanges.clear(); + MWWorld::Ptr ptrPlayer = getPlayerPtr(); MWWorld::InventoryStore &invStore = ptrPlayer.getClass().getInventoryStore(ptrPlayer); @@ -464,9 +476,9 @@ void LocalPlayer::updateEquipment(bool forceUpdate) if (equipmentIndexChanges.size() > 0) { + exchangeFullInfo = false; getNetworking()->getPlayerPacket(ID_PLAYER_EQUIPMENT)->setPlayer(this); getNetworking()->getPlayerPacket(ID_PLAYER_EQUIPMENT)->Send(); - equipmentIndexChanges.clear(); } }