diff options
author | Melanie | 2012-02-23 00:08:31 +0100 |
---|---|---|
committer | Melanie | 2012-02-23 00:08:31 +0100 |
commit | c0b8f3d0bcc71d31cd92bb47e10a7d6a96d7900e (patch) | |
tree | 8ab6a1a778808090f5be5a50093517553c200780 /OpenSim/Region/ScriptEngine/Shared/Api/Implementation | |
parent | Count agents for LSL instead of relying on SceneGraph to have the correct (diff) | |
download | opensim-SC-c0b8f3d0bcc71d31cd92bb47e10a7d6a96d7900e.zip opensim-SC-c0b8f3d0bcc71d31cd92bb47e10a7d6a96d7900e.tar.gz opensim-SC-c0b8f3d0bcc71d31cd92bb47e10a7d6a96d7900e.tar.bz2 opensim-SC-c0b8f3d0bcc71d31cd92bb47e10a7d6a96d7900e.tar.xz |
Add permission checks to scripted object movements, which didn't respect bans
and parcel settings until now. Add llSetRegionPos() function according to
LL spec
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 54 |
1 files changed, 53 insertions, 1 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index a7341a9..d0430f4 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -2177,6 +2177,54 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2177 | return real_vec; | 2177 | return real_vec; |
2178 | } | 2178 | } |
2179 | 2179 | ||
2180 | public LSL_Integer llSetRegionPos(LSL_Vector pos) | ||
2181 | { | ||
2182 | return new LSL_Integer(SetRegionPos(m_host, pos)); | ||
2183 | } | ||
2184 | |||
2185 | protected int SetRegionPos(SceneObjectPart part, LSL_Vector targetPos) | ||
2186 | { | ||
2187 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
2188 | return 0; | ||
2189 | |||
2190 | SceneObjectGroup grp = part.ParentGroup; | ||
2191 | |||
2192 | if (grp.IsAttachment) | ||
2193 | return 0; | ||
2194 | |||
2195 | if (grp.RootPart.PhysActor != null && grp.RootPart.PhysActor.IsPhysical) | ||
2196 | return 0; | ||
2197 | |||
2198 | if (targetPos.x < -10.0f || targetPos.x >= (float)Constants.RegionSize || targetPos.y < -10.0f || targetPos.y >= (float)Constants.RegionSize || targetPos.z < 0 || targetPos.z >= 4096.0f) | ||
2199 | return 0; | ||
2200 | |||
2201 | float constrainedX = (float)targetPos.x; | ||
2202 | float constrainedY = (float)targetPos.y; | ||
2203 | |||
2204 | if (constrainedX < 0.0f) | ||
2205 | constrainedX = 0.0f; | ||
2206 | if (constrainedY < 0.0f) | ||
2207 | constrainedY = 0.0f; | ||
2208 | if (constrainedX >= (float)Constants.RegionSize) | ||
2209 | constrainedX = (float)Constants.RegionSize - 0.1f; | ||
2210 | if (constrainedY >= (float)Constants.RegionSize) | ||
2211 | constrainedY = (float)Constants.RegionSize -0.1f; | ||
2212 | |||
2213 | float ground = World.GetGroundHeight(constrainedX, constrainedY); | ||
2214 | |||
2215 | if (targetPos.z < ground) | ||
2216 | targetPos.z = ground; | ||
2217 | |||
2218 | Vector3 dest = new Vector3((float)targetPos.x, (float)targetPos.y, (float)targetPos.z); | ||
2219 | |||
2220 | if (!World.Permissions.CanObjectEntry(grp.UUID, false, dest)) | ||
2221 | return 0; | ||
2222 | |||
2223 | grp.UpdateGroupPosition(dest); | ||
2224 | |||
2225 | return 1; | ||
2226 | } | ||
2227 | |||
2180 | protected void SetPos(SceneObjectPart part, LSL_Vector targetPos) | 2228 | protected void SetPos(SceneObjectPart part, LSL_Vector targetPos) |
2181 | { | 2229 | { |
2182 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | 2230 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) |
@@ -2185,11 +2233,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2185 | LSL_Vector currentPos = GetPartLocalPos(part); | 2233 | LSL_Vector currentPos = GetPartLocalPos(part); |
2186 | LSL_Vector toPos = GetSetPosTarget(part, targetPos, currentPos); | 2234 | LSL_Vector toPos = GetSetPosTarget(part, targetPos, currentPos); |
2187 | 2235 | ||
2236 | |||
2188 | if (part.ParentGroup.RootPart == part) | 2237 | if (part.ParentGroup.RootPart == part) |
2189 | { | 2238 | { |
2190 | SceneObjectGroup parent = part.ParentGroup; | 2239 | SceneObjectGroup parent = part.ParentGroup; |
2240 | Vector3 dest = new Vector3((float)toPos.x, (float)toPos.y, (float)toPos.z); | ||
2241 | if (!World.Permissions.CanObjectEntry(parent.UUID, false, dest)) | ||
2242 | return; | ||
2191 | Util.FireAndForget(delegate(object x) { | 2243 | Util.FireAndForget(delegate(object x) { |
2192 | parent.UpdateGroupPosition(new Vector3((float)toPos.x, (float)toPos.y, (float)toPos.z)); | 2244 | parent.UpdateGroupPosition(dest); |
2193 | }); | 2245 | }); |
2194 | } | 2246 | } |
2195 | else | 2247 | else |