Showing the changes to libraries/entities/src/EntityScriptingInterface.cpp (1 of 11 files). Show all
Unified · Split
| @@ -480,17 +480,11 @@ QUuid EntityScriptingInterface::addEntityInternal(const EntityItemProperties& pr · 479 unmodified lines | |||
| 480 | 480 | ||
| 481 | _activityTracking.addedEntityCount++; | 481 | _activityTracking.addedEntityCount++; |
| 482 | 482 | ||
| 483 | auto nodeList = DependencyManager::get<NodeList>(); | ||
| 484 | auto sessionID = nodeList->getSessionUUID(); | ||
| 485 | |||
| 486 | EntityItemProperties propertiesWithSimID = properties; | 483 | EntityItemProperties propertiesWithSimID = properties; |
| 487 | propertiesWithSimID.setEntityHostType(entityHostType); | 484 | propertiesWithSimID.setEntityHostType(entityHostType); |
| 488 | if (entityHostType == entity::HostType::AVATAR) { | 485 | if (entityHostType == entity::HostType::AVATAR) { |
| 489 | if (sessionID.isNull()) { | 486 | // only allow adding our own avatar entities from script |
| 490 | // null sessionID is unacceptable in this case | 487 | propertiesWithSimID.setOwningAvatarID(AVATAR_SELF_ID); |
| 491 | sessionID = AVATAR_SELF_ID; | ||
| 492 | } | ||
| 493 | propertiesWithSimID.setOwningAvatarID(sessionID); | ||
| 494 | } else if (entityHostType == entity::HostType::LOCAL) { | 488 | } else if (entityHostType == entity::HostType::LOCAL) { |
| 495 | // For now, local entities are always collisionless | 489 | // For now, local entities are always collisionless |
| 496 | // TODO: create a separate, local physics simulation that just handles local entities (and MyAvatar?) | 490 | // TODO: create a separate, local physics simulation that just handles local entities (and MyAvatar?) |
| @@ -498,6 +492,8 @@ QUuid EntityScriptingInterface::addEntityInternal(const EntityItemProperties& pr · 1 unmodified line | |||
| 498 | } | 492 | } |
| 499 | 493 | ||
| 500 | // the created time will be set in EntityTree::addEntity by recordCreationTime() | 494 | // the created time will be set in EntityTree::addEntity by recordCreationTime() |
| 495 | auto nodeList = DependencyManager::get<NodeList>(); | ||
| 496 | auto sessionID = nodeList->getSessionUUID(); | ||
| 501 | propertiesWithSimID.setLastEditedBy(sessionID); | 497 | propertiesWithSimID.setLastEditedBy(sessionID); |
| 502 | 498 | ||
| 503 | bool scalesWithParent = propertiesWithSimID.getScalesWithParent(); | 499 | bool scalesWithParent = propertiesWithSimID.getScalesWithParent(); |
| @@ -805,7 +801,7 @@ QUuid EntityScriptingInterface::editEntity(const QUuid& id, const EntityItemProp · 301 unmodified lines | |||
| 805 | return; | 801 | return; |
| 806 | } | 802 | } |
| 807 | 803 | ||
| 808 | if (entity->isAvatarEntity() && entity->getOwningAvatarID() != sessionID && entity->getOwningAvatarID() != AVATAR_SELF_ID) { | 804 | if (entity->isAvatarEntity() && !entity->isMyAvatarEntity()) { |
| 809 | // don't edit other avatar's avatarEntities | 805 | // don't edit other avatar's avatarEntities |
| 810 | properties = EntityItemProperties(); | 806 | properties = EntityItemProperties(); |
| 811 | return; | 807 | return; |
| @@ -978,10 +974,9 @@ void EntityScriptingInterface::deleteEntity(const QUuid& id) { · 166 unmodified lines | |||
| 978 | _entityTree->withWriteLock([&] { | 974 | _entityTree->withWriteLock([&] { |
| 979 | EntityItemPointer entity = _entityTree->findEntityByEntityItemID(entityID); | 975 | EntityItemPointer entity = _entityTree->findEntityByEntityItemID(entityID); |
| 980 | if (entity) { | 976 | if (entity) { |
| 981 | |||
| 982 | auto nodeList = DependencyManager::get<NodeList>(); | 977 | auto nodeList = DependencyManager::get<NodeList>(); |
| 983 | const QUuid myNodeID = nodeList->getSessionUUID(); | 978 | const QUuid myNodeID = nodeList->getSessionUUID(); |
| 984 | if (entity->isAvatarEntity() && entity->getOwningAvatarID() != myNodeID) { | 979 | if (entity->isAvatarEntity() && !entity->isMyAvatarEntity()) { |
| 985 | // don't delete other avatar's avatarEntities | 980 | // don't delete other avatar's avatarEntities |
| 986 | shouldSendDeleteToServer = false; | 981 | shouldSendDeleteToServer = false; |
| 987 | return; | 982 | return; |
| @@ -990,7 +985,7 @@ void EntityScriptingInterface::deleteEntity(const QUuid& id) { · 2 unmodified lines | |||
| 990 | if (entity->getLocked()) { | 985 | if (entity->getLocked()) { |
| 991 | shouldSendDeleteToServer = false; | 986 | shouldSendDeleteToServer = false; |
| 992 | } else { | 987 | } else { |
| 993 | // only delete local entities, server entities will round trip through the server filters | 988 | // only delete non-domain entities, domain entities will round trip through the server filters |
| 994 | if (!entity->isDomainEntity() || _entityTree->isServerlessMode()) { | 989 | if (!entity->isDomainEntity() || _entityTree->isServerlessMode()) { |
| 995 | shouldSendDeleteToServer = false; | 990 | shouldSendDeleteToServer = false; |
| 996 | _entityTree->deleteEntity(entityID); | 991 | _entityTree->deleteEntity(entityID); |
| @@ -1671,7 +1666,7 @@ bool EntityScriptingInterface::actionWorker(const QUuid& entityID, · 674 unmodified lines | |||
| 1671 | return; | 1666 | return; |
| 1672 | } | 1667 | } |
| 1673 | 1668 | ||
| 1674 | if (entity->isAvatarEntity() && entity->getOwningAvatarID() != myNodeID) { | 1669 | if (entity->isAvatarEntity() && !entity->isMyAvatarEntity()) { |
| 1675 | return; | 1670 | return; |
| 1676 | } | 1671 | } |
| 1677 | 1672 | ||