diff --git a/libraries/entities/src/EntityEditPacketSender.cpp b/libraries/entities/src/EntityEditPacketSender.cpp index e94725782d..8d03ca0fcb 100644 --- a/libraries/entities/src/EntityEditPacketSender.cpp +++ b/libraries/entities/src/EntityEditPacketSender.cpp @@ -21,7 +21,7 @@ void EntityEditPacketSender::adjustEditPacketForClockSkew(PacketType type, unsigned char* editBuffer, size_t length, int clockSkew) { - if (type == PacketTypeEntityAddOrEdit) { + if (type == PacketTypeEntityAdd || type == PacketTypeEntityEdit) { EntityItem::adjustEditPacketForClockSkew(editBuffer, length, clockSkew); } } diff --git a/libraries/entities/src/EntityScriptingInterface.cpp b/libraries/entities/src/EntityScriptingInterface.cpp index 9231867e0e..351bbc3643 100644 --- a/libraries/entities/src/EntityScriptingInterface.cpp +++ b/libraries/entities/src/EntityScriptingInterface.cpp @@ -92,7 +92,7 @@ QUuid EntityScriptingInterface::addEntity(const EntityItemProperties& properties // queue the packet if (success) { - queueEntityMessage(PacketTypeEntityAddOrEdit, id, propertiesWithSimID); + queueEntityMessage(PacketTypeEntityAdd, id, propertiesWithSimID); } return id; @@ -144,12 +144,12 @@ QUuid EntityScriptingInterface::editEntity(QUuid id, const EntityItemProperties& entity->setLastBroadcast(usecTimestampNow()); modifiedProperties.setType(entity->getType()); bidForSimulationOwnership(modifiedProperties); - queueEntityMessage(PacketTypeEntityAddOrEdit, entityID, modifiedProperties); + queueEntityMessage(PacketTypeEntityEdit, entityID, modifiedProperties); return id; } } - queueEntityMessage(PacketTypeEntityAddOrEdit, entityID, properties); + queueEntityMessage(PacketTypeEntityEdit, entityID, properties); return id; } diff --git a/libraries/entities/src/EntityTree.cpp b/libraries/entities/src/EntityTree.cpp index 1a8a13e246..e1e4bd6095 100644 --- a/libraries/entities/src/EntityTree.cpp +++ b/libraries/entities/src/EntityTree.cpp @@ -65,7 +65,8 @@ void EntityTree::eraseAllOctreeElements(bool createNewRoot) { bool EntityTree::handlesEditPacketType(PacketType packetType) const { // we handle these types of "edit" packets switch (packetType) { - case PacketTypeEntityAddOrEdit: + case PacketTypeEntityAdd: + case PacketTypeEntityEdit: case PacketTypeEntityErase: return true; default: @@ -559,20 +560,19 @@ int EntityTree::processEditPacketData(PacketType packetType, const unsigned char break; } - case PacketTypeEntityAddOrEdit: { + case PacketTypeEntityAdd: + case PacketTypeEntityEdit: { EntityItemID entityItemID; EntityItemProperties properties; bool validEditPacket = EntityItemProperties::decodeEntityEditPacket(editData, maxLength, - processedBytes, entityItemID, properties); + processedBytes, entityItemID, properties); // If we got a valid edit packet, then it could be a new entity or it could be an update to // an existing entity... handle appropriately if (validEditPacket) { // search for the entity by EntityItemID EntityItem* existingEntity = findEntityByEntityItemID(entityItemID); - - // If this is a knownID, then it should exist in our tree - if (existingEntity) { + if (existingEntity && packetType == PacketTypeEntityEdit) { // if the EntityItem exists, then update it if (wantEditLogging()) { qCDebug(entities) << "User [" << senderNode->getUUID() << "] editing entity. ID:" << entityItemID; @@ -580,7 +580,7 @@ int EntityTree::processEditPacketData(PacketType packetType, const unsigned char } updateEntity(entityItemID, properties, senderNode); existingEntity->markAsChangedOnServer(); - } else { + } else if (packetType == PacketTypeEntityAdd) { if (senderNode->getCanRez()) { // this is a new entity... assign a new entityID if (wantEditLogging()) { @@ -599,8 +599,11 @@ int EntityTree::processEditPacketData(PacketType packetType, const unsigned char } } else { - qCDebug(entities) << "User without 'rez rights' [" << senderNode->getUUID() << "] attempted to add an entity."; + qCDebug(entities) << "User without 'rez rights' [" << senderNode->getUUID() + << "] attempted to add an entity."; } + } else { + qCDebug(entities) << "Add or Edit failed." << packetType << existingEntity; } } break; @@ -1009,7 +1012,7 @@ bool EntityTree::sendEntitiesOperation(OctreeElement* element, void* extraData) properties.markAllChanged(); // so the entire property set is considered new, since we're making a new entity // queue the packet to send to the server - args->packetSender->queueEditEntityMessage(PacketTypeEntityAddOrEdit, newID, properties); + args->packetSender->queueEditEntityMessage(PacketTypeEntityAdd, newID, properties); // also update the local tree instantly (note: this is not our tree, but an alternate tree) if (args->localTree) { diff --git a/libraries/networking/src/PacketHeaders.cpp b/libraries/networking/src/PacketHeaders.cpp index cc373a59ee..6a5b703a29 100644 --- a/libraries/networking/src/PacketHeaders.cpp +++ b/libraries/networking/src/PacketHeaders.cpp @@ -70,7 +70,8 @@ PacketVersion versionForPacketType(PacketType packetType) { return 1; case PacketTypeStopNode: return 1; - case PacketTypeEntityAddOrEdit: + case PacketTypeEntityAdd: + case PacketTypeEntityEdit: case PacketTypeEntityData: return VERSION_NO_ENTITY_ID_SWAP; case PacketTypeEntityErase: @@ -117,7 +118,6 @@ QString nameForPacketType(PacketType packetType) { PACKET_TYPE_NAME_LOOKUP(PacketTypeNodeJsonStats); PACKET_TYPE_NAME_LOOKUP(PacketTypeEntityQuery); PACKET_TYPE_NAME_LOOKUP(PacketTypeEntityData); - PACKET_TYPE_NAME_LOOKUP(PacketTypeEntityAddOrEdit); PACKET_TYPE_NAME_LOOKUP(PacketTypeEntityErase); PACKET_TYPE_NAME_LOOKUP(PacketTypeOctreeDataNack); PACKET_TYPE_NAME_LOOKUP(PacketTypeStopNode); @@ -128,6 +128,8 @@ QString nameForPacketType(PacketType packetType) { PACKET_TYPE_NAME_LOOKUP(PacketTypeIceServerHeartbeatResponse); PACKET_TYPE_NAME_LOOKUP(PacketTypeUnverifiedPing); PACKET_TYPE_NAME_LOOKUP(PacketTypeUnverifiedPingReply); + PACKET_TYPE_NAME_LOOKUP(PacketTypeEntityAdd); + PACKET_TYPE_NAME_LOOKUP(PacketTypeEntityEdit); default: return QString("Type: ") + QString::number((int)packetType); } diff --git a/libraries/networking/src/PacketHeaders.h b/libraries/networking/src/PacketHeaders.h index 1adfcf5ca8..9568abb2cb 100644 --- a/libraries/networking/src/PacketHeaders.h +++ b/libraries/networking/src/PacketHeaders.h @@ -68,9 +68,9 @@ enum PacketType { PacketTypeNodeJsonStats, PacketTypeEntityQuery, // 40 PacketTypeEntityData, - PacketTypeEntityAddOrEdit, - PacketTypeEntityErase, UNUSED_11, + PacketTypeEntityErase, + UNUSED_12, PacketTypeOctreeDataNack, // 45 PacketTypeStopNode, PacketTypeAudioEnvironment, @@ -79,7 +79,9 @@ enum PacketType { PacketTypeIceServerHeartbeat, // 50 PacketTypeIceServerHeartbeatResponse, PacketTypeUnverifiedPing, - PacketTypeUnverifiedPingReply + PacketTypeUnverifiedPingReply, + PacketTypeEntityAdd, + PacketTypeEntityEdit }; typedef char PacketVersion; diff --git a/libraries/physics/src/EntityMotionState.cpp b/libraries/physics/src/EntityMotionState.cpp index 9bba80054f..18651a7ac5 100644 --- a/libraries/physics/src/EntityMotionState.cpp +++ b/libraries/physics/src/EntityMotionState.cpp @@ -433,7 +433,7 @@ void EntityMotionState::sendUpdate(OctreeEditPacketSender* packetSender, const Q qCDebug(physics) << "EntityMotionState::sendUpdate()... calling queueEditEntityMessage()..."; #endif - entityPacketSender->queueEditEntityMessage(PacketTypeEntityAddOrEdit, id, properties); + entityPacketSender->queueEditEntityMessage(PacketTypeEntityEdit, id, properties); _entity->setLastBroadcast(usecTimestampNow()); } else { #ifdef WANT_DEBUG