[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.
pull/413/head
David Cernat 7 years ago
parent 66d5109509
commit 399e049d87

@ -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();
}
}

Loading…
Cancel
Save