split code that sends edits via avatar-mixer out of queueEditEntityMessage

This commit is contained in:
Seth Alves 2016-05-10 15:37:54 -07:00
parent 1e849956c9
commit 4b13fd969e
3 changed files with 51 additions and 32 deletions

View file

@ -183,7 +183,6 @@ void Avatar::updateAvatarEntities() {
// - setAvatarEntityData saves the bytes and sets _avatarEntityDataChanged = true
// - (My)Avatar::simulate notices _avatarEntityDataChanged and here we are...
const static quint64 refreshTime = 3 * USECS_PER_SECOND;
if (!_avatarEntityDataChanged) {
return;
}

View file

@ -36,14 +36,16 @@ void EntityEditPacketSender::adjustEditPacketForClockSkew(PacketType type, QByte
}
}
void EntityEditPacketSender::queueEditEntityMessage(PacketType type,
void EntityEditPacketSender::queueEditAvatarEntityMessage(PacketType type,
EntityTreePointer entityTree,
EntityItemID entityItemID,
const EntityItemProperties& properties) {
if (!_shouldSend) {
return; // bail early
}
if (properties.getClientOnly()) {
assert(properties.getClientOnly());
// this is an avatar-based entity. update our avatar-data rather than sending to the entity-server
assert(_myAvatar);
@ -76,6 +78,20 @@ void EntityEditPacketSender::queueEditEntityMessage(PacketType type,
QByteArray binaryProperties = jsonProperties.toBinaryData();
_myAvatar->updateAvatarEntity(entityItemID, binaryProperties);
return;
}
void EntityEditPacketSender::queueEditEntityMessage(PacketType type,
EntityTreePointer entityTree,
EntityItemID entityItemID,
const EntityItemProperties& properties) {
if (!_shouldSend) {
return; // bail early
}
if (properties.getClientOnly()) {
queueEditAvatarEntityMessage(type, entityTree, entityItemID, properties);
return;
}
QByteArray bufferOut(NLPacket::maxPayloadSize(type), 0);

View file

@ -27,6 +27,10 @@ public:
AvatarData* getMyAvatar() { return _myAvatar; }
void clearAvatarEntity(QUuid entityID) { assert(_myAvatar); _myAvatar->clearAvatarEntity(entityID); }
void queueEditAvatarEntityMessage(PacketType type, EntityTreePointer entityTree,
EntityItemID entityItemID, const EntityItemProperties& properties);
/// Queues an array of several voxel edit messages. Will potentially send a pending multi-command packet. Determines
/// which voxel-server node or nodes the packet should be sent to. Can be called even before voxel servers are known, in
/// which case up to MaxPendingMessages will be buffered and processed when voxel servers are known.