diff options
author | SignpostMarv | 2012-07-12 15:57:22 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2012-07-14 01:45:34 +0100 |
commit | b6cd3b625ebffb45febf922a941fae337e3c1652 (patch) | |
tree | 680e4f15f9461cfc825e3f3ffdb12f58fa63ba27 /OpenSim/Region/ScriptEngine/Shared | |
parent | Implementation of llSetRegionPos(). Does not implement failure on object entr... (diff) | |
download | opensim-SC-b6cd3b625ebffb45febf922a941fae337e3c1652.zip opensim-SC-b6cd3b625ebffb45febf922a941fae337e3c1652.tar.gz opensim-SC-b6cd3b625ebffb45febf922a941fae337e3c1652.tar.bz2 opensim-SC-b6cd3b625ebffb45febf922a941fae337e3c1652.tar.xz |
adding workaround for silent failure if position is outside the bounds of a region, implementing parcel prim count check.
Signed-off-by: SignpostMarv <github@signpostmarv.name>
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 54 |
1 files changed, 41 insertions, 13 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index b209e23..8163267 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -1932,23 +1932,51 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1932 | public LSL_Integer llSetRegionPos(LSL_Vector pos) | 1932 | public LSL_Integer llSetRegionPos(LSL_Vector pos) |
1933 | { | 1933 | { |
1934 | m_host.AddScriptLPS(1); | 1934 | m_host.AddScriptLPS(1); |
1935 | if ( | 1935 | |
1936 | llGetStatus((int)PrimFlags.Physics) == 1 || // return FALSE if physical. | 1936 | // BEGIN WORKAROUND |
1937 | m_host.ParentGroup.IsAttachment || // return FALSE if attachment | 1937 | // IF YOU GET REGION CROSSINGS WORKING WITH THIS FUNCTION, REPLACE THE WORKAROUND. |
1938 | ( | 1938 | // |
1939 | pos.x < -10.0 || // return FALSE if more than 10 meters into a west-adjacent region. | 1939 | // This workaround is to prevent silent failure of this function. |
1940 | pos.x > (Constants.RegionSize + 10) || // return FALSE if more than 10 meters into a east-adjacent region. | 1940 | // According to the specification on the SL Wiki, providing a position outside of the |
1941 | pos.y < -10.0 || // return FALSE if more than 10 meters into a south-adjacent region. | 1941 | if (pos.x < 0 || pos.x > Constants.RegionSize || pos.y < 0 || pos.y > Constants.RegionSize) |
1942 | pos.y > (Constants.RegionSize + 10) || // return FALSE if more than 10 meters into a north-adjacent region. | 1942 | { |
1943 | pos.z > 4096 // return FALSE if altitude than 4096m | ||
1944 | ) | ||
1945 | ){ | ||
1946 | return 0; | 1943 | return 0; |
1947 | } | 1944 | } |
1945 | // END WORK AROUND | ||
1946 | else{ | ||
1947 | LSL_List parcelID = new LSL_List(ScriptBaseClass.PARCEL_DETAILS_ID); | ||
1948 | Vector3 objectPos = m_host.ParentGroup.RootPart.AbsolutePosition; | ||
1949 | bool sameParcel = | ||
1950 | llGetParcelDetails(new LSL_Vector(pos.x, pos.y, pos.z), parcelID).Data[0] == | ||
1951 | llGetParcelDetails(pos, parcelID).Data[0] | ||
1952 | ; | ||
1953 | if ( | ||
1954 | llGetStatus((int)PrimFlags.Physics) == 1 || // return FALSE if physical. | ||
1955 | m_host.ParentGroup.IsAttachment || // return FALSE if attachment | ||
1956 | ( | ||
1957 | pos.x < -10.0 || // return FALSE if more than 10 meters into a west-adjacent region. | ||
1958 | pos.x > (Constants.RegionSize + 10) || // return FALSE if more than 10 meters into a east-adjacent region. | ||
1959 | pos.y < -10.0 || // return FALSE if more than 10 meters into a south-adjacent region. | ||
1960 | pos.y > (Constants.RegionSize + 10) || // return FALSE if more than 10 meters into a north-adjacent region. | ||
1961 | pos.z > 4096 // return FALSE if altitude than 4096m | ||
1962 | ) || | ||
1963 | // BEGIN RELIANCE ON WORK AROUND | ||
1964 | // this check will only work if pos is within the region bounds. | ||
1965 | ( | ||
1966 | !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. | ||
1967 | (llGetParcelPrimCount(pos, ScriptBaseClass.PARCEL_COUNT_TOTAL, 0) + m_host.ParentGroup.PrimCount) > llGetParcelMaxPrims(pos, 0) | ||
1968 | ) | ||
1969 | // END RELIANCE ON WORK-AROUND | ||
1970 | ){ | ||
1971 | return 0; | ||
1972 | } | ||
1973 | |||
1974 | SetPos(m_host.ParentGroup.RootPart, pos, false); | ||
1948 | 1975 | ||
1949 | SetPos(m_host.ParentGroup.RootPart, pos, false); | 1976 | return llVecDist(pos, llGetRootPosition()) <= 0.1 ? 1 : 0; |
1977 | } | ||
1950 | 1978 | ||
1951 | return llVecDist(pos, llGetRootPosition()) <= 0.1 ? 1 : 0; | 1979 | return 0; |
1952 | } | 1980 | } |
1953 | 1981 | ||
1954 | // Capped movemment if distance > 10m (http://wiki.secondlife.com/wiki/LlSetPos) | 1982 | // Capped movemment if distance > 10m (http://wiki.secondlife.com/wiki/LlSetPos) |