Fix entity properties sometimes being resent

When writing entity properties to a packet, we start off with a list of
requested properties (`requestedProperties`) and keep track of which properties
didn't fit (`propertiesDidntFit`) the packet, which is intialized to
requestedProperties. As we pack the properties, we remove them from
propertiesDidntFit if they didn't need to be written or were able to be
packed. At the end we store propertiesDidntFit, and use it in the future
as our requestedProperties when we try to pack more data into a packet.

The bug: because of the order in which propertiesDidntFit is
initialized, it ended up always being the list of all properties for
that entity. This typically wasn't an issue because we usually go
through and try to append all of the properties, and if we don't need to
append them (because they aren't in requestedProperties)
we remove them from our propertiesDidntFit list. When we
don't have enough remaining space in the current packet for even the
entity header, which is fairly small, we don't bother trying to append
any of the properties. When this happens, propertiesDidntFit contains
the full list of properties, which we save for the next pass through the
entity, and use as our requestedProperties, causing us to resend entity
data again. In the worst case we never end up sending all of the
entity's data.
This commit is contained in:
Ryan Huffman 2017-07-25 10:59:03 -07:00
parent 2446fcde8e
commit 6817cf9db4

View file

@ -182,7 +182,6 @@ OctreeElement::AppendState EntityItem::appendEntityData(OctreePacketData* packet
EntityPropertyFlags propertyFlags(PROP_LAST_ITEM);
EntityPropertyFlags requestedProperties = getEntityProperties(params);
EntityPropertyFlags propertiesDidntFit = requestedProperties;
// If we are being called for a subsequent pass at appendEntityData() that failed to completely encode this item,
// then our entityTreeElementExtraEncodeData should include data about which properties we need to append.
@ -190,6 +189,8 @@ OctreeElement::AppendState EntityItem::appendEntityData(OctreePacketData* packet
requestedProperties = entityTreeElementExtraEncodeData->entities.value(getEntityItemID());
}
EntityPropertyFlags propertiesDidntFit = requestedProperties;
LevelDetails entityLevel = packetData->startLevel();
quint64 lastEdited = getLastEdited();