From 86f7c28ee93151d4f713a3540a913c040d00e3b9 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Tue, 27 Jan 2015 10:24:28 -0800 Subject: [PATCH] Update EntityScriptingInterface::deleteEntity to not delete when known entity is locked --- .../entities/src/EntityScriptingInterface.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/libraries/entities/src/EntityScriptingInterface.cpp b/libraries/entities/src/EntityScriptingInterface.cpp index 6226012052..166e6d2819 100644 --- a/libraries/entities/src/EntityScriptingInterface.cpp +++ b/libraries/entities/src/EntityScriptingInterface.cpp @@ -144,15 +144,26 @@ void EntityScriptingInterface::deleteEntity(EntityItemID entityID) { } } + bool shouldDelete = true; + // If we have a local entity tree set, then also update it. if (_entityTree) { _entityTree->lockForWrite(); - _entityTree->deleteEntity(entityID); + + EntityItem* entity = const_cast(_entityTree->findEntityByEntityItemID(actualID)); + if (entity) { + if (entity->getLocked()) { + shouldDelete = false; + } else { + _entityTree->deleteEntity(entityID); + } + } + _entityTree->unlock(); } - // if at this point, we know the id, send the update to the entity server - if (entityID.isKnownID) { + // if at this point, we know the id, and we should still delete the entity, send the update to the entity server + if (shouldDelete && entityID.isKnownID) { getEntityPacketSender()->queueEraseEntityMessage(entityID); } }