split entity-add and entity-edit messages

This commit is contained in:
Seth Alves 2015-05-20 14:52:03 -07:00
parent 124ff68cee
commit 4a59dc24c5
6 changed files with 26 additions and 19 deletions

View file

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

View file

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

View file

@ -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) {

View file

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

View file

@ -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;

View file

@ -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