Update EntityScriptingInterface::deleteEntity to not delete when known entity is locked

This commit is contained in:
Ryan Huffman 2015-01-27 10:24:28 -08:00
parent 4c10f6f23b
commit 86f7c28ee9

View file

@ -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 we have a local entity tree set, then also update it.
if (_entityTree) { if (_entityTree) {
_entityTree->lockForWrite(); _entityTree->lockForWrite();
_entityTree->deleteEntity(entityID);
EntityItem* entity = const_cast<EntityItem*>(_entityTree->findEntityByEntityItemID(actualID));
if (entity) {
if (entity->getLocked()) {
shouldDelete = false;
} else {
_entityTree->deleteEntity(entityID);
}
}
_entityTree->unlock(); _entityTree->unlock();
} }
// if at this point, we know the id, send the update to the entity server // if at this point, we know the id, and we should still delete the entity, send the update to the entity server
if (entityID.isKnownID) { if (shouldDelete && entityID.isKnownID) {
getEntityPacketSender()->queueEraseEntityMessage(entityID); getEntityPacketSender()->queueEraseEntityMessage(entityID);
} }
} }