From bce206e6dc9a29063669bf36bb8e910ea187f83b Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 15 Aug 2020 04:53:30 +0100 Subject: [PATCH] change a few more --- .../Shared/Api/Implementation/LSL_Api.cs | 222 +++++++++--------- .../Shared/Api/Interface/ILSL_Api.cs | 6 +- .../Shared/Api/Runtime/LSL_Stub.cs | 6 +- 3 files changed, 123 insertions(+), 111 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 0301d30b22..bbf3f68d91 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -5091,39 +5091,40 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return ""; } - public LSL_Key llRequestInventoryData(string name) + //bad if lm is HG + public LSL_Key llRequestInventoryData(LSL_String name) { m_host.AddScriptLPS(1); - foreach (TaskInventoryItem item in m_host.Inventory.GetInventoryItems()) + Action act = eventID => { - if (item.Type == 3 && item.Name == name) + string reply = String.Empty; + foreach (TaskInventoryItem item in m_host.Inventory.GetInventoryItems()) { - UUID tid = m_AsyncCommands.DataserverPlugin.RegisterRequest(m_host.LocalId, - m_item.ItemID, item.AssetID.ToString()); - - Vector3 region = new Vector3(World.RegionInfo.WorldLocX, World.RegionInfo.WorldLocY, 0); - - World.AssetService.Get(item.AssetID.ToString(), this, - delegate(string i, object sender, AssetBase a) + if (item.Type == 3 && item.Name == name) + { + AssetBase a = World.AssetService.Get(item.AssetID.ToString()); + if(a != null) { AssetLandmark lm = new AssetLandmark(a); - - float rx = (uint)(lm.RegionHandle >> 32); - float ry = (uint)lm.RegionHandle; - region = lm.Position + new Vector3(rx, ry, 0) - region; - - string reply = region.ToString(); - m_AsyncCommands.DataserverPlugin.DataserverReply(i.ToString(),reply); - }); - - ScriptSleep(m_sleepMsOnRequestInventoryData); - return tid.ToString(); + if(lm != null) + { + float rx = (uint)(lm.RegionHandle >> 32); + float ry = (uint)lm.RegionHandle; + Vector3 region = new Vector3(World.RegionInfo.WorldLocX, World.RegionInfo.WorldLocY, 0); + region = lm.Position + new Vector3(rx, ry, 0) - region; + reply = region.ToString(); + } + } + break; + } } - } + m_AsyncCommands.DataserverPlugin.DataserverReply(eventID, reply); + }; - ScriptSleep(m_sleepMsOnRequestInventoryData); - return String.Empty; + UUID tid = m_AsyncCommands.DataserverPlugin.RegisterRequest(m_host.LocalId, + m_item.ItemID, UUID.Random().ToString(), act); + return tid.ToString(); } public void llSetDamage(double damage) @@ -13005,93 +13006,104 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); - string reply = String.Empty; - - GridRegion info; - if (World.RegionInfo.RegionName == simulator) - info = new GridRegion(World.RegionInfo); - else - info = World.GridService.GetRegionByName(m_ScriptEngine.World.RegionInfo.ScopeID, simulator); - - switch (data) { - case ScriptBaseClass.DATA_SIM_POS: - if (info == null) - { + string lreply = String.Empty; + GridRegion linfo = new GridRegion(World.RegionInfo); + switch (data) + { + case ScriptBaseClass.DATA_SIM_POS: + { + lreply = new LSL_Vector( + linfo.RegionLocX, + linfo.RegionLocY, + 0).ToString(); + } + break; + case ScriptBaseClass.DATA_SIM_STATUS: + lreply = "up"; // Duh! + break; + case ScriptBaseClass.DATA_SIM_RATING: + int access = linfo.Maturity; + if (access == 0) + lreply = "PG"; + else if (access == 1) + lreply = "MATURE"; + else if (access == 2) + lreply = "ADULT"; + else + lreply = "UNKNOWN"; + break; + case ScriptBaseClass.DATA_SIM_RELEASE: + lreply = "OpenSim"; + break; + default: ScriptSleep(m_sleepMsOnRequestSimulatorData); - return UUID.Zero.ToString(); - } + return UUID.Zero.ToString(); // Raise no event + } + string lrq = UUID.Random().ToString(); + UUID ltid = m_AsyncCommands.DataserverPlugin.RegisterRequest(m_host.LocalId, m_item.ItemID, lrq); - bool isHypergridRegion = false; + m_AsyncCommands.DataserverPlugin.DataserverReply(lrq, lreply); - if (World.RegionInfo.RegionName != simulator && info.RegionSecret != "") - { - // Hypergrid is currently placing real destination region co-ords into RegionSecret. - // But other code can also use this field for a genuine RegionSecret! Therefore, if - // anything is present we need to disambiguate. - // - // FIXME: Hypergrid should be storing this data in a different field. - RegionFlags regionFlags - = (RegionFlags)m_ScriptEngine.World.GridService.GetRegionFlags( - info.ScopeID, info.RegionID); - isHypergridRegion = (regionFlags & RegionFlags.Hyperlink) != 0; - } - - if (isHypergridRegion) - { - Utils.LongToUInts(Convert.ToUInt64(info.RegionSecret), out uint rx, out uint ry); - - reply = new LSL_Vector( - rx, - ry, - 0).ToString(); - } - else - { - // Local grid co-oridnates - reply = new LSL_Vector( - info.RegionLocX, - info.RegionLocY, - 0).ToString(); - } - break; - case ScriptBaseClass.DATA_SIM_STATUS: - if (info != null) - reply = "up"; // Duh! - else - reply = "unknown"; - break; - case ScriptBaseClass.DATA_SIM_RATING: - if (info == null) - { - ScriptSleep(m_sleepMsOnRequestSimulatorData); - return UUID.Zero.ToString(); - } - int access = info.Maturity; - if (access == 0) - reply = "PG"; - else if (access == 1) - reply = "MATURE"; - else if (access == 2) - reply = "ADULT"; - else - reply = "UNKNOWN"; - break; - case ScriptBaseClass.DATA_SIM_RELEASE: - reply = "OpenSim"; - break; - default: - ScriptSleep(m_sleepMsOnRequestSimulatorData); - return UUID.Zero.ToString(); // Raise no event + ScriptSleep(m_sleepMsOnRequestSimulatorData); + return ltid.ToString(); } - UUID rq = UUID.Random(); - UUID tid = m_AsyncCommands. - DataserverPlugin.RegisterRequest(m_host.LocalId, m_item.ItemID, rq.ToString()); + Action act = eventID => + { + GridRegion info = World.GridService.GetRegionByName(m_ScriptEngine.World.RegionInfo.ScopeID, simulator); + string reply = "unknown"; + if (info != null) + { + switch (data) + { + case ScriptBaseClass.DATA_SIM_POS: + // Hypergrid is currently placing real destination region co-ords into RegionSecret. + // But other code can also use this field for a genuine RegionSecret! Therefore, if + // anything is present we need to disambiguate. + // + // FIXME: Hypergrid should be storing this data in a different field. + RegionFlags regionFlags = (RegionFlags)m_ScriptEngine.World.GridService.GetRegionFlags( + info.ScopeID, info.RegionID); - m_AsyncCommands. - DataserverPlugin.DataserverReply(rq.ToString(), reply); + if ((regionFlags & RegionFlags.Hyperlink) != 0) + { + Utils.LongToUInts(Convert.ToUInt64(info.RegionSecret), out uint rx, out uint ry); + reply = new LSL_Vector(rx, ry, 0).ToString(); + } + else + { + // Local grid co-oridnates + reply = new LSL_Vector(info.RegionLocX, info.RegionLocY, 0).ToString(); + } + break; + case ScriptBaseClass.DATA_SIM_STATUS: + reply = "up"; // Duh! + break; + case ScriptBaseClass.DATA_SIM_RATING: + int access = info.Maturity; + if (access == 0) + reply = "PG"; + else if (access == 1) + reply = "MATURE"; + else if (access == 2) + reply = "ADULT"; + else + reply = "UNKNOWN"; + break; + case ScriptBaseClass.DATA_SIM_RELEASE: + reply = "OpenSim"; + break; + default: + break; + } + } + m_AsyncCommands.DataserverPlugin.DataserverReply(eventID, reply); + }; + + UUID tid = m_AsyncCommands.DataserverPlugin.RegisterRequest( + m_host.LocalId, m_item.ItemID, UUID.Random().ToString(), act); ScriptSleep(m_sleepMsOnRequestSimulatorData); return tid.ToString(); @@ -15257,7 +15269,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return Name2Username(llKey2Name(id)); } - public LSL_String llRequestUsername(LSL_Key id) + public LSL_Key llRequestUsername(LSL_Key id) { m_host.AddScriptLPS(1); if (!UUID.TryParse(id, out UUID key) || key == UUID.Zero) @@ -15314,7 +15326,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return String.Empty; } - public LSL_String llRequestDisplayName(LSL_Key id) + public LSL_Key llRequestDisplayName(LSL_Key id) { m_host.AddScriptLPS(1); if (!UUID.TryParse(id, out UUID key) || key == UUID.Zero) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs index a4f49d5d35..f6afd1db74 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs @@ -233,9 +233,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces LSL_String llIntegerToBase64(int number); LSL_String llKey2Name(LSL_Key id); LSL_String llGetUsername(LSL_Key id); - LSL_String llRequestUsername(LSL_Key id); + LSL_Key llRequestUsername(LSL_Key id); LSL_String llGetDisplayName(LSL_Key id); - LSL_String llRequestDisplayName(LSL_Key id); + LSL_Key llRequestDisplayName(LSL_Key id); void llLinkParticleSystem(int linknum, LSL_List rules); void llLinkSitTarget(LSL_Integer link, LSL_Vector offset, LSL_Rotation rot); LSL_String llList2CSV(LSL_List src); @@ -309,7 +309,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces void llRemoveInventory(string item); void llRemoveVehicleFlags(int flags); LSL_Key llRequestAgentData(string id, int data); - LSL_Key llRequestInventoryData(string name); + LSL_Key llRequestInventoryData(LSL_String name); void llRequestPermissions(string agent, int perm); LSL_Key llRequestSecureURL(); LSL_Key llRequestSimulatorData(string simulator, int data); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs index ddac45e9bc..31c06dca22 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs @@ -961,7 +961,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase return m_LSL_Functions.llGetUsername(id); } - public LSL_String llRequestUsername(LSL_Key id) + public LSL_Key llRequestUsername(LSL_Key id) { return m_LSL_Functions.llRequestUsername(id); } @@ -971,7 +971,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase return m_LSL_Functions.llGetDisplayName(id); } - public LSL_String llRequestDisplayName(LSL_Key id) + public LSL_Key llRequestDisplayName(LSL_Key id) { return m_LSL_Functions.llRequestDisplayName(id); } @@ -1341,7 +1341,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase return m_LSL_Functions.llRequestAgentData(id, data); } - public LSL_Key llRequestInventoryData(string name) + public LSL_Key llRequestInventoryData(LSL_String name) { return m_LSL_Functions.llRequestInventoryData(name); }