From 6e86b230120776a7da4727dd1aedeca6b91e3169 Mon Sep 17 00:00:00 2001 From: SignpostMarv Date: Fri, 24 Aug 2012 17:44:39 +0100 Subject: [PATCH 1/2] implementing PRIM_LINK_TARGET on GetPrimParams ala SetPrimParams --- .../Shared/Api/Implementation/LSL_Api.cs | 58 +++++++++++++++---- .../Shared/Api/Implementation/OSSL_Api.cs | 13 ++++- 2 files changed, 60 insertions(+), 11 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 0f0eac6b9e..b001c51606 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -7913,7 +7913,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api LSL_List result = new LSL_List(); - GetPrimParams(m_host, rules, ref result); + LSL_List remaining = GetPrimParams(m_host, rules, ref result); + + while (remaining != null && remaining.Length > 2) + { + int linknumber = remaining.GetLSLIntegerItem(0); + rules = remaining.GetSublist(1, -1); + List parts = GetLinkParts(linknumber); + + foreach (SceneObjectPart part in parts) + remaining = GetPrimParams(part, rules, ref result); + } return result; } @@ -7925,16 +7935,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api List parts = GetLinkParts(linknumber); LSL_List res = new LSL_List(); + LSL_List remaining = null; foreach (SceneObjectPart part in parts) { - GetPrimParams(part, rules, ref res); + remaining = GetPrimParams(part, rules, ref res); + } + + while (remaining != null && remaining.Length > 2) + { + linknumber = remaining.GetLSLIntegerItem(0); + rules = remaining.GetSublist(1, -1); + parts = GetLinkParts(linknumber); + + foreach (SceneObjectPart part in parts) + remaining = GetPrimParams(part, rules, ref res); } return res; } - public void GetPrimParams(SceneObjectPart part, LSL_List rules, ref LSL_List res) + public LSL_List GetPrimParams(SceneObjectPart part, LSL_List rules, ref LSL_List res) { int idx=0; while (idx < rules.Length) @@ -8080,7 +8101,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_TEXTURE: if (remain < 1) - return; + return null; int face = (int)rules.GetLSLIntegerItem(idx++); Primitive.TextureEntry tex = part.Shape.Textures; @@ -8120,7 +8141,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_COLOR: if (remain < 1) - return; + return null; face=(int)rules.GetLSLIntegerItem(idx++); @@ -8149,7 +8170,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_BUMP_SHINY: if (remain < 1) - return; + return null; face=(int)rules.GetLSLIntegerItem(idx++); @@ -8180,7 +8201,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_FULLBRIGHT: if (remain < 1) - return; + return null; face=(int)rules.GetLSLIntegerItem(idx++); @@ -8222,7 +8243,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_TEXGEN: if (remain < 1) - return; + return null; face=(int)rules.GetLSLIntegerItem(idx++); @@ -8263,7 +8284,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_GLOW: if (remain < 1) - return; + return null; face=(int)rules.GetLSLIntegerItem(idx++); @@ -8315,8 +8336,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api 0 )); break; + case (int)ScriptBaseClass.PRIM_LINK_TARGET: + if(remain < 3) + return null; + + return rules.GetSublist(idx, -1); } } + + return null; } public LSL_List llGetPrimMediaParams(int face, LSL_List rules) @@ -10762,7 +10790,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (obj != null && obj.OwnerID != m_host.OwnerID) { - GetPrimParams(obj, rules, ref result); + LSL_List remaining = GetPrimParams(obj, rules, ref result); + + while (remaining != null && remaining.Length > 2) + { + int linknumber = remaining.GetLSLIntegerItem(0); + rules = remaining.GetSublist(1, -1); + List parts = GetLinkParts(linknumber); + + foreach (SceneObjectPart part in parts) + remaining = GetPrimParams(part, rules, ref result); + } } return result; diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 927f37c6f2..1afa4fbc20 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -2250,10 +2250,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // on the ILSL_Api interface. LSL_Api LSL_Api = (LSL_Api)m_LSL_Api; LSL_List retVal = new LSL_List(); + LSL_List remaining = null; List parts = LSL_Api.GetLinkParts(linknumber); foreach (SceneObjectPart part in parts) { - LSL_Api.GetPrimParams(part, rules, ref retVal); + remaining = LSL_Api.GetPrimParams(part, rules, ref retVal); + } + + while (remaining != null && remaining.Length > 2) + { + linknumber = remaining.GetLSLIntegerItem(0); + rules = remaining.GetSublist(1, -1); + parts = LSL_Api.GetLinkParts(linknumber); + + foreach (SceneObjectPart part in parts) + remaining = LSL_Api.GetPrimParams(part, rules, ref retVal); } return retVal; } From 6ea95a329451c803048f179abb4b4ea5014dd7b1 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 25 Aug 2012 17:32:00 +0100 Subject: [PATCH 2/2] Fix and refactor region registration. Reorder checks to short-curcuit expensive and destructive ones. Properly fix region reservation and authentication. Make region moves and flags preservation work again as intended. Prevent failes reservation take-over from damging reservation data. --- OpenSim/Services/GridService/GridService.cs | 63 +++++++++++---------- 1 file changed, 33 insertions(+), 30 deletions(-) diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index aab403a203..5bdea06847 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -137,9 +137,14 @@ namespace OpenSim.Services.GridService if (regionInfos.RegionID == UUID.Zero) return "Invalid RegionID - cannot be zero UUID"; - // This needs better sanity testing. What if regionInfo is registering in - // overlapping coords? RegionData region = m_Database.Get(regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID); + if ((region != null) && (region.RegionID != regionInfos.RegionID)) + { + m_log.WarnFormat("[GRID SERVICE]: Region {0} tried to register in coordinates {1}, {2} which are already in use in scope {3}.", + regionInfos.RegionID, regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID); + return "Region overlaps another region"; + } + if (region != null) { // There is a preexisting record @@ -176,32 +181,7 @@ namespace OpenSim.Services.GridService } } - if ((region != null) && (region.RegionID != regionInfos.RegionID)) - { - m_log.WarnFormat("[GRID SERVICE]: Region {0} tried to register in coordinates {1}, {2} which are already in use in scope {3}.", - regionInfos.RegionID, regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID); - return "Region overlaps another region"; - } - - if ((region != null) && (region.RegionID == regionInfos.RegionID) && - ((region.posX != regionInfos.RegionLocX) || (region.posY != regionInfos.RegionLocY))) - { - if ((Convert.ToInt32(region.Data["flags"]) & (int)OpenSim.Data.RegionFlags.NoMove) != 0) - return "Can't move this region"; - - // Region reregistering in other coordinates. Delete the old entry - m_log.DebugFormat("[GRID SERVICE]: Region {0} ({1}) was previously registered at {2}-{3}. Deleting old entry.", - regionInfos.RegionName, regionInfos.RegionID, regionInfos.RegionLocX, regionInfos.RegionLocY); - - try - { - m_Database.Delete(regionInfos.RegionID); - } - catch (Exception e) - { - m_log.DebugFormat("[GRID SERVICE]: Database exception: {0}", e); - } - } + // If we get here, the destination is clear. Now for the real check. if (!m_AllowDuplicateNames) { @@ -220,6 +200,31 @@ namespace OpenSim.Services.GridService } } + // If there is an old record for us, delete it if it is elsewhere. + region = m_Database.Get(regionInfos.RegionID, scopeID); + if ((region != null) && (region.RegionID == regionInfos.RegionID) && + ((region.posX != regionInfos.RegionLocX) || (region.posY != regionInfos.RegionLocY))) + { + if ((Convert.ToInt32(region.Data["flags"]) & (int)OpenSim.Data.RegionFlags.NoMove) != 0) + return "Can't move this region"; + + if ((Convert.ToInt32(region.Data["flags"]) & (int)OpenSim.Data.RegionFlags.LockedOut) != 0) + return "Region locked out"; + + // Region reregistering in other coordinates. Delete the old entry + m_log.DebugFormat("[GRID SERVICE]: Region {0} ({1}) was previously registered at {2}-{3}. Deleting old entry.", + regionInfos.RegionName, regionInfos.RegionID, regionInfos.RegionLocX, regionInfos.RegionLocY); + + try + { + m_Database.Delete(regionInfos.RegionID); + } + catch (Exception e) + { + m_log.DebugFormat("[GRID SERVICE]: Database exception: {0}", e); + } + } + // Everything is ok, let's register RegionData rdata = RegionInfo2RegionData(regionInfos); rdata.ScopeID = scopeID; @@ -227,8 +232,6 @@ namespace OpenSim.Services.GridService if (region != null) { int oldFlags = Convert.ToInt32(region.Data["flags"]); - if ((oldFlags & (int)OpenSim.Data.RegionFlags.LockedOut) != 0) - return "Region locked out"; oldFlags &= ~(int)OpenSim.Data.RegionFlags.Reservation;