From bf46960dc344b5bb82f5468f2a3c62b6ac911a33 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Tue, 18 Dec 2018 12:03:21 -0800 Subject: [PATCH] fix timing on startNearGrab entity-method call for cloned entities. Don't allow grabbing of other's equipped or worn entities --- .../controllerModules/nearGrabEntity.js | 1 + .../libraries/controllerDispatcherUtils.js | 21 +++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/scripts/system/controllers/controllerModules/nearGrabEntity.js b/scripts/system/controllers/controllerModules/nearGrabEntity.js index bb74c59691..60a5781ca4 100644 --- a/scripts/system/controllers/controllerModules/nearGrabEntity.js +++ b/scripts/system/controllers/controllerModules/nearGrabEntity.js @@ -185,6 +185,7 @@ Script.include("/~/system/libraries/controllers.js"); var cloneID = cloneEntity(targetProps); if (cloneID !== null) { var cloneProps = Entities.getEntityProperties(cloneID, DISPATCHER_PROPERTIES); + cloneProps.id = cloneID; this.grabbing = true; this.targetEntityID = cloneID; this.startNearGrabEntity(cloneProps); diff --git a/scripts/system/libraries/controllerDispatcherUtils.js b/scripts/system/libraries/controllerDispatcherUtils.js index 0b1d17c266..e8d15c9b59 100644 --- a/scripts/system/libraries/controllerDispatcherUtils.js +++ b/scripts/system/libraries/controllerDispatcherUtils.js @@ -32,6 +32,7 @@ getEnabledModuleByName:true, getGrabbableData:true, isAnothersAvatarEntity:true, + isAnothersChildEntity:true, entityIsGrabbable:true, entityIsDistanceGrabbable:true, getControllerJointIndexCacheTime:true, @@ -302,11 +303,31 @@ isAnothersAvatarEntity = function (iaaeProps) { return true; }; +isAnothersChildEntity = function (iaceProps) { + while (iaceProps.parentID && iaceProps.parentID !== Uuid.NULL) { + if (Entities.getNestableType(iaceProps.parentID) == "avatar") { + if (iaceProps.parentID == MyAvatar.SELF_ID || iaceProps.parentID == MyAvatar.sessionUUID) { + return false; // not another's, it's mine. + } + return true; + } + // Entities.getNestableType(iaceProps.parentID) == "entity") { + var parentProps = Entities.getEntityProperties(iaceProps.parentID, DISPATCHER_PROPERTIES); + if (!parentProps) { + break; + } + parentProps.id = iaceProps.parentID; + iaceProps = parentProps; + } + return false; +}; + entityIsGrabbable = function (eigProps) { var grabbable = getGrabbableData(eigProps).grabbable; if (!grabbable || eigProps.locked || isAnothersAvatarEntity(eigProps) || + isAnothersChildEntity(eigProps) || FORBIDDEN_GRAB_TYPES.indexOf(eigProps.type) >= 0) { return false; }