cleanly log failed entity adds, and tell the client to delete his copy

This commit is contained in:
howard-stearns 2017-01-31 16:05:38 -08:00
parent 2fc6b4b0af
commit e42853a96c

View file

@ -1111,7 +1111,15 @@ int EntityTree::processEditPacketData(ReceivedMessage& message, const unsigned c
endUpdate = usecTimestampNow(); endUpdate = usecTimestampNow();
_totalUpdates++; _totalUpdates++;
} else if (message.getType() == PacketType::EntityAdd) { } else if (message.getType() == PacketType::EntityAdd) {
if (senderNode->getCanRez() || senderNode->getCanRezTmp()) { bool failedAdd = !allowed;
if (!allowed) {
qCDebug(entities) << "Filtered entity add. ID:" << entityItemID;
} else if (!senderNode->getCanRez() && !senderNode->getCanRezTmp()) {
failedAdd = true;
qCDebug(entities) << "User without 'rez rights' [" << senderNode->getUUID()
<< "] attempted to add an entity ID:" << entityItemID;
} else {
// this is a new entity... assign a new entityID // this is a new entity... assign a new entityID
properties.setCreated(properties.getLastEdited()); properties.setCreated(properties.getLastEdited());
properties.setLastEditedBy(senderNode->getUUID()); properties.setLastEditedBy(senderNode->getUUID());
@ -1126,7 +1134,7 @@ int EntityTree::processEditPacketData(ReceivedMessage& message, const unsigned c
startLogging = usecTimestampNow(); startLogging = usecTimestampNow();
if (wantEditLogging()) { if (wantEditLogging()) {
qCDebug(entities) << "User [" << senderNode->getUUID() << "] added entity. ID:" qCDebug(entities) << "User [" << senderNode->getUUID() << "] added entity. ID:"
<< newEntity->getEntityItemID(); << newEntity->getEntityItemID();
qCDebug(entities) << " properties:" << properties; qCDebug(entities) << " properties:" << properties;
} }
if (wantTerseEditLogging()) { if (wantTerseEditLogging()) {
@ -1136,10 +1144,14 @@ int EntityTree::processEditPacketData(ReceivedMessage& message, const unsigned c
} }
endLogging = usecTimestampNow(); endLogging = usecTimestampNow();
} else {
failedAdd = true;
qCDebug(entities) << "Add entity failed ID:" << entityItemID;
} }
} else { }
qCDebug(entities) << "User without 'rez rights' [" << senderNode->getUUID() if (failedAdd) { // Let client know it failed, so that they don't have an entity that no one else sees.
<< "] attempted to add an entity."; QWriteLocker locker(&_recentlyDeletedEntitiesLock);
_recentlyDeletedEntityItemIDs.insert(usecTimestampNow(), entityItemID);
} }
} else { } else {
static QString repeatedMessage = static QString repeatedMessage =