aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ScriptEngine')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs81
1 files changed, 42 insertions, 39 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index ca240f5..cfcbae3 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -421,15 +421,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
421 return LSL_Vector.Norm(v); 421 return LSL_Vector.Norm(v);
422 } 422 }
423 423
424 public LSL_Float llVecDist(LSL_Vector a, LSL_Vector b) 424 private double vecDist(LSL_Vector a, LSL_Vector b)
425 { 425 {
426 m_host.AddScriptLPS(1);
427 double dx = a.x - b.x; 426 double dx = a.x - b.x;
428 double dy = a.y - b.y; 427 double dy = a.y - b.y;
429 double dz = a.z - b.z; 428 double dz = a.z - b.z;
430 return Math.Sqrt(dx * dx + dy * dy + dz * dz); 429 return Math.Sqrt(dx * dx + dy * dy + dz * dz);
431 } 430 }
432 431
432 public LSL_Float llVecDist(LSL_Vector a, LSL_Vector b)
433 {
434 m_host.AddScriptLPS(1);
435 return vecDist(a, b);
436 }
437
433 //Now we start getting into quaternions which means sin/cos, matrices and vectors. ckrinke 438 //Now we start getting into quaternions which means sin/cos, matrices and vectors. ckrinke
434 439
435 /// <summary> 440 /// <summary>
@@ -1242,6 +1247,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1242 } 1247 }
1243 } 1248 }
1244 1249
1250 private bool isPhysical(){
1251 return ((m_host.GetEffectiveObjectFlags() & (uint)PrimFlags.Physics) == (uint)PrimFlags.Physics);
1252 }
1253
1245 public LSL_Integer llGetStatus(int status) 1254 public LSL_Integer llGetStatus(int status)
1246 { 1255 {
1247 m_host.AddScriptLPS(1); 1256 m_host.AddScriptLPS(1);
@@ -1249,11 +1258,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1249 switch (status) 1258 switch (status)
1250 { 1259 {
1251 case ScriptBaseClass.STATUS_PHYSICS: 1260 case ScriptBaseClass.STATUS_PHYSICS:
1252 if ((m_host.GetEffectiveObjectFlags() & (uint)PrimFlags.Physics) == (uint)PrimFlags.Physics) 1261 return isPhysical() ? 1 : 0;
1253 {
1254 return 1;
1255 }
1256 return 0;
1257 1262
1258 case ScriptBaseClass.STATUS_PHANTOM: 1263 case ScriptBaseClass.STATUS_PHANTOM:
1259 if ((m_host.GetEffectiveObjectFlags() & (uint)PrimFlags.Phantom) == (uint)PrimFlags.Phantom) 1264 if ((m_host.GetEffectiveObjectFlags() & (uint)PrimFlags.Phantom) == (uint)PrimFlags.Phantom)
@@ -1943,42 +1948,40 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1943 return 0; 1948 return 0;
1944 } 1949 }
1945 // END WORK AROUND 1950 // END WORK AROUND
1946 else{ 1951 else if ( // this is not part of the workaround if-block because it's not related to the workaround.
1947 LSL_List parcelID = new LSL_List(ScriptBaseClass.PARCEL_DETAILS_ID); 1952 isPhysical() ||
1948 Vector3 objectPos = m_host.ParentGroup.RootPart.AbsolutePosition; 1953 m_host.ParentGroup.IsAttachment || // return FALSE if attachment
1949 string parcelA = llGetParcelDetails(new LSL_Vector(objectPos.X, objectPos.X, objectPos.X), parcelID).Data[0].ToString(); 1954 (
1950 string parcelB = llGetParcelDetails(pos, parcelID).Data[0].ToString(); 1955 pos.x < -10.0 || // return FALSE if more than 10 meters into a west-adjacent region.
1951 bool sameParcel = parcelA == parcelB; 1956 pos.x > (Constants.RegionSize + 10) || // return FALSE if more than 10 meters into a east-adjacent region.
1952 int objectPrimCount = m_host.ParentGroup.PrimCount; 1957 pos.y < -10.0 || // return FALSE if more than 10 meters into a south-adjacent region.
1953 LSL_Integer destParcelPrimCount = llGetParcelPrimCount(pos, ScriptBaseClass.PARCEL_COUNT_TOTAL, 0); 1958 pos.y > (Constants.RegionSize + 10) || // return FALSE if more than 10 meters into a north-adjacent region.
1954 LSL_Integer max = llGetParcelMaxPrims(pos, 0); 1959 pos.z > 4096 // return FALSE if altitude than 4096m
1955 if ( 1960 )
1956 llGetStatus((int)PrimFlags.Physics) == 1 || // return FALSE if physical. 1961 )
1957 m_host.ParentGroup.IsAttachment || // return FALSE if attachment 1962 {
1958 ( 1963 return 0;
1959 pos.x < -10.0 || // return FALSE if more than 10 meters into a west-adjacent region. 1964 }
1960 pos.x > (Constants.RegionSize + 10) || // return FALSE if more than 10 meters into a east-adjacent region. 1965
1961 pos.y < -10.0 || // return FALSE if more than 10 meters into a south-adjacent region. 1966 // if we reach this point, then the object is not physical, it's not an attachment, and the destination is within the valid range.
1962 pos.y > (Constants.RegionSize + 10) || // return FALSE if more than 10 meters into a north-adjacent region. 1967 // this could possibly be done in the above else-if block, but we're doing the check here to keep the code easier to read.
1963 pos.z > 4096 // return FALSE if altitude than 4096m
1964 ) ||
1965 // BEGIN RELIANCE ON WORK AROUND
1966 // this check will only work if pos is within the region bounds.
1967 (
1968 !sameParcel && // if it's moving within the same parcel we do not need to check if the destination parcel will exceed capacity if the object is moved.
1969 (destParcelPrimCount + objectPrimCount) > max
1970 )
1971 // END RELIANCE ON WORK-AROUND
1972 ){
1973 return 0;
1974 }
1975 1968
1976 SetPos(m_host.ParentGroup.RootPart, pos, false); 1969 Vector3 objectPos = m_host.ParentGroup.RootPart.AbsolutePosition;
1970 LandData here = World.GetLandData((float)objectPos.X, (float)objectPos.Y);
1971 LandData there = World.GetLandData((float)pos.x, (float)pos.y);
1977 1972
1978 return llVecDist(pos, llGetRootPosition()) <= 0.1 ? 1 : 0; 1973 // we're only checking prim limits if it's moving to a different parcel under the assumption that if the object got onto the parcel without exceeding the prim limits.
1974
1975 bool sameParcel = here.GlobalID == there.GlobalID;
1976
1977 if (!sameParcel && !World.Permissions.CanRezObject(m_host.ParentGroup.PrimCount, m_host.ParentGroup.OwnerID, new Vector3((float)pos.x, (float)pos.y, (float)pos.z)))
1978 {
1979 return 0;
1979 } 1980 }
1980 1981
1981 return 0; 1982 SetPos(m_host.ParentGroup.RootPart, pos, false);
1983
1984 return vecDist(pos, llGetRootPosition()) <= 0.1 ? 1 : 0;
1982 } 1985 }
1983 1986
1984 // Capped movemment if distance > 10m (http://wiki.secondlife.com/wiki/LlSetPos) 1987 // Capped movemment if distance > 10m (http://wiki.secondlife.com/wiki/LlSetPos)