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 | 481 | _activityTracking.addedEntityCount++; |
| 482 | 482 | |
| 483 | − auto nodeList = DependencyManager::get<NodeList>(); | |
| 484 | − auto sessionID = nodeList->getSessionUUID(); | |
| 485 | − | |
| 486 | 483 | EntityItemProperties propertiesWithSimID = properties; |
| 487 | 484 | propertiesWithSimID.setEntityHostType(entityHostType); |
| 488 | 485 | if (entityHostType == entity::HostType::AVATAR) { |
| 489 | − if (sessionID.isNull()) { | |
| 490 | − // null sessionID is unacceptable in this case | |
| 491 | − sessionID = AVATAR_SELF_ID; | |
| 492 | − } | |
| 493 | − propertiesWithSimID.setOwningAvatarID(sessionID); | |
| 486 | + // only allow adding our own avatar entities from script | |
| 487 | + propertiesWithSimID.setOwningAvatarID(AVATAR_SELF_ID); | |
| 494 | 488 | } else if (entityHostType == entity::HostType::LOCAL) { |
| 495 | 489 | // For now, local entities are always collisionless |
| 496 | 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 | 494 | // the created time will be set in EntityTree::addEntity by recordCreationTime() |
| 495 | + auto nodeList = DependencyManager::get<NodeList>(); | |
| 496 | + auto sessionID = nodeList->getSessionUUID(); | |
| 501 | 497 | propertiesWithSimID.setLastEditedBy(sessionID); |
| 502 | 498 | |
| 503 | 499 | bool scalesWithParent = propertiesWithSimID.getScalesWithParent(); |
| @@ -805,7 +801,7 @@ QUuid EntityScriptingInterface::editEntity(const QUuid& id, const EntityItemProp · 301 unmodified lines | ||
| 805 | 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 | 805 | // don't edit other avatar's avatarEntities |
| 810 | 806 | properties = EntityItemProperties(); |
| 811 | 807 | return; |
| @@ -978,10 +974,9 @@ void EntityScriptingInterface::deleteEntity(const QUuid& id) { · 166 unmodified lines | ||
| 978 | 974 | _entityTree->withWriteLock([&] { |
| 979 | 975 | EntityItemPointer entity = _entityTree->findEntityByEntityItemID(entityID); |
| 980 | 976 | if (entity) { |
| 981 | − | |
| 982 | 977 | auto nodeList = DependencyManager::get<NodeList>(); |
| 983 | 978 | const QUuid myNodeID = nodeList->getSessionUUID(); |
| 984 | − if (entity->isAvatarEntity() && entity->getOwningAvatarID() != myNodeID) { | |
| 979 | + if (entity->isAvatarEntity() && !entity->isMyAvatarEntity()) { | |
| 985 | 980 | // don't delete other avatar's avatarEntities |
| 986 | 981 | shouldSendDeleteToServer = false; |
| 987 | 982 | return; |
| @@ -990,7 +985,7 @@ void EntityScriptingInterface::deleteEntity(const QUuid& id) { · 2 unmodified lines | ||
| 990 | 985 | if (entity->getLocked()) { |
| 991 | 986 | shouldSendDeleteToServer = false; |
| 992 | 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 | 989 | if (!entity->isDomainEntity() || _entityTree->isServerlessMode()) { |
| 995 | 990 | shouldSendDeleteToServer = false; |
| 996 | 991 | _entityTree->deleteEntity(entityID); |
| @@ -1671,7 +1666,7 @@ bool EntityScriptingInterface::actionWorker(const QUuid& entityID, · 674 unmodified lines | ||
| 1671 | 1666 | return; |
| 1672 | 1667 | } |
| 1673 | 1668 | |
| 1674 | − if (entity->isAvatarEntity() && entity->getOwningAvatarID() != myNodeID) { | |
| 1669 | + if (entity->isAvatarEntity() && !entity->isMyAvatarEntity()) { | |
| 1675 | 1670 | return; |
| 1676 | 1671 | } |
| 1677 | 1672 | |