From 54563d8dea86ca1e022f3aafa791908e8bcc4912 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Sun, 27 Apr 2008 22:15:38 +0000 Subject: [PATCH] * Patch from XenReborn to make remove-region work properly without needing to do a change-region first. Careful though. I still suggest you do a change-region first. * Patch from Melanie to implement touch_end. * Thanks XenReborn!. Thanks Melanie! --- CONTRIBUTORS.txt | 1 + OpenSim/Region/Application/OpenSimMain.cs | 51 ++++++++++++++++- .../Region/Environment/Scenes/InnerScene.cs | 3 +- .../Scenes/Scene.PacketHandlers.cs | 55 +++++++++++++++---- OpenSim/Region/Environment/Scenes/Scene.cs | 1 + .../Region/Environment/Scenes/SceneEvents.cs | 12 ++++ .../Region/Environment/Scenes/SceneManager.cs | 15 ++++- .../Common/ScriptEngineBase/EventManager.cs | 10 ++++ 8 files changed, 131 insertions(+), 17 deletions(-) diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt index adbe8cb64e..5c004fa5ef 100644 --- a/CONTRIBUTORS.txt +++ b/CONTRIBUTORS.txt @@ -52,6 +52,7 @@ Patches * A_Biondi * lulurun * Melanie Thielker +* John R Sohn(XenReborn) LSL Devs diff --git a/OpenSim/Region/Application/OpenSimMain.cs b/OpenSim/Region/Application/OpenSimMain.cs index 20945784ad..b322f6d6f7 100644 --- a/OpenSim/Region/Application/OpenSimMain.cs +++ b/OpenSim/Region/Application/OpenSimMain.cs @@ -212,7 +212,7 @@ namespace OpenSim if (config != null) { config.Set("accounts_authenticate", false); - config.Set("welcome_message", "Welcome to OpenSim"); + config.Set("welcome_message", "Welcome to Krynn"); config.Set("inventory_plugin", "OpenSim.Data.SQLite.dll"); config.Set("inventory_source", ""); config.Set("userDatabase_plugin", "OpenSim.Data.SQLite.dll"); @@ -978,18 +978,63 @@ namespace OpenSim CreateRegion(new RegionInfo(cmdparams[0], "Regions/" + cmdparams[1],false), true); break; case "remove-region": + string regName = CombineParams(cmdparams, 0); - + + Console.WriteLine("Trying to kill: " + regName); Scene killScene; - if (m_sceneManager.TryGetScene(regName, out killScene)) + + /* if (m_sceneManager.TryGetScene(regName, out killScene)) { + Console.WriteLine("Returned object ID: ", killScene.RegionInfo.RegionID.ToString()); + Console.WriteLine("Returned object Name: ", killScene.RegionInfo.RegionName); + + + if (killScene == null) + { + Console.WriteLine("Returned object is null!"); + } + if (m_sceneManager.CurrentScene.RegionInfo.RegionID == killScene.RegionInfo.RegionID) { m_sceneManager.TrySetCurrentScene(".."); } + m_regionData.Remove(killScene.RegionInfo); m_sceneManager.CloseScene(killScene); + + + }*/ + + + /// note from John R Sohn aka XenReborn (irc.freenode.net) + /// the trygetscene function does not work + /// when debugging it i noticed it did indeed find the region by name + /// but the OUT parameter "scene" return an empty object + /// hence the reason it threw an exception + /// when the server code in this block tried to kill it + /// i know its not supposed to work that way... but it seems.. + /// that it is.. given a flaw in the langauge or concurrency error.. + /// i have no idea, but for some reason, performing the search here + /// locally does work, as does dynamically killing the region + /// however on server restart, the region returns, i dunno if this was + /// intentional or not.... i suggest creating a seperate function + /// which will permanently remove all data relating to the region + /// as an administrative option... maybe something like "Purge Region" + /// + /// i made editations with debug console output in above commented code.. + /// and the trygetscene(string,out scene) function to show whats happening. + + for (int x = 0; x < m_sceneManager.Scenes.Count; x++) + { + if (m_sceneManager.Scenes[x].RegionInfo.RegionName.CompareTo(regName) == 0) + { + killScene = m_sceneManager.Scenes[x]; + m_regionData.Remove(killScene.RegionInfo); + m_sceneManager.CloseScene(killScene); + } } + break; case "exit": diff --git a/OpenSim/Region/Environment/Scenes/InnerScene.cs b/OpenSim/Region/Environment/Scenes/InnerScene.cs index 104ae485d1..d00f601079 100644 --- a/OpenSim/Region/Environment/Scenes/InnerScene.cs +++ b/OpenSim/Region/Environment/Scenes/InnerScene.cs @@ -324,8 +324,7 @@ namespace OpenSim.Region.Environment.Scenes // Calls attach with a Zero position AttachObject(remoteClient, objectLocalID, AttachmentPt, rot, LLVector3.Zero); } - public void RezSingleAttachment(IClientAPI remoteClient, LLUUID itemID, uint AttachmentPt, - uint ItemFlags, uint NextOwnerMask) + public void RezSingleAttachment(IClientAPI remoteClient, LLUUID itemID, uint AttachmentPt,uint ItemFlags, uint NextOwnerMask) { SceneObjectGroup objatt = m_parentScene.RezObject(remoteClient, itemID, LLVector3.Zero, LLVector3.Zero, LLUUID.Zero, (byte)1, true, (uint)(PermissionMask.Copy | PermissionMask.Move | PermissionMask.Modify | PermissionMask.Transfer), diff --git a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs index 5e0b8ba403..71b27164e7 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs @@ -146,6 +146,41 @@ namespace OpenSim.Region.Environment.Scenes List EntitieList = GetEntities(); + foreach (EntityBase ent in EntitieList) + { + if (ent is SceneObjectGroup) + { + SceneObjectGroup obj = ent as SceneObjectGroup; + if (obj != null) + { + // Is this prim part of the group + if (obj.HasChildPrim(localID)) + { + // Currently only grab/touch for the single prim + // the client handles rez correctly + obj.ObjectGrabHandler(localID, offsetPos, remoteClient); + + SceneObjectPart part = obj.GetChildPart(localID); + + // If the touched prim handles touches, deliver it + // If not, deliver to root prim + if ((part.ObjectFlags & (uint)LLObject.ObjectFlags.Touch) != 0) + EventManager.TriggerObjectGrab(part.LocalId, part.OffsetPosition, remoteClient); + else + EventManager.TriggerObjectGrab(obj.RootPart.LocalId, part.OffsetPosition, remoteClient); + + return; + } + } + } + } + } + + public virtual void ProcessObjectDeGrab(uint localID, IClientAPI remoteClient) + { + + List EntitieList = GetEntities(); + foreach (EntityBase ent in EntitieList) { if (ent is SceneObjectGroup) @@ -155,18 +190,18 @@ namespace OpenSim.Region.Environment.Scenes // Is this prim part of the group if (obj.HasChildPrim(localID)) { - // Currently only grab/touch for the single prim - // the client handles rez correctly - obj.ObjectGrabHandler(localID, offsetPos, remoteClient); - - // trigger event, one for each prim part in the group - // so that a touch to a non-root prim in a group will still - // trigger a touch_start for a script in the root prim - foreach (SceneObjectPart part in obj.Children.Values) + SceneObjectPart part=obj.GetChildPart(localID); + if (part != null) { - EventManager.TriggerObjectGrab(part.LocalId, part.OffsetPosition, remoteClient); - } + // If the touched prim handles touches, deliver it + // If not, deliver to root prim + if ((part.ObjectFlags & (uint)LLObject.ObjectFlags.Touch) != 0) + EventManager.TriggerObjectDeGrab(part.LocalId, remoteClient); + else + EventManager.TriggerObjectDeGrab(obj.RootPart.LocalId, remoteClient); + return; + } return; } } diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index f94aec74a4..a517e69ce7 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -1617,6 +1617,7 @@ namespace OpenSim.Region.Environment.Scenes client.OnMoveTaskItem += MoveTaskInventoryItem; client.OnGrabObject += ProcessObjectGrab; + client.OnDeGrabObject += ProcessObjectDeGrab; client.OnMoneyTransferRequest += ProcessMoneyTransferRequest; client.OnParcelBuy += ProcessParcelBuy; client.OnAvatarPickerRequest += ProcessAvatarPickerRequest; diff --git a/OpenSim/Region/Environment/Scenes/SceneEvents.cs b/OpenSim/Region/Environment/Scenes/SceneEvents.cs index 74554c3554..769817ea6d 100644 --- a/OpenSim/Region/Environment/Scenes/SceneEvents.cs +++ b/OpenSim/Region/Environment/Scenes/SceneEvents.cs @@ -83,10 +83,12 @@ namespace OpenSim.Region.Environment.Scenes public event OnShutdownDelegate OnShutdown; public delegate void ObjectGrabDelegate(uint localID, LLVector3 offsetPos, IClientAPI remoteClient); + public delegate void ObjectDeGrabDelegate(uint localID, IClientAPI remoteClient); public delegate void OnPermissionErrorDelegate(LLUUID user, string reason); public event ObjectGrabDelegate OnObjectGrab; + public event ObjectDeGrabDelegate OnObjectDeGrab; public event OnPermissionErrorDelegate OnPermissionError; @@ -247,6 +249,7 @@ namespace OpenSim.Region.Environment.Scenes private OnParcelPrimCountAddDelegate handlerParcelPrimCountAdd = null; //OnParcelPrimCountAdd; private OnShutdownDelegate handlerShutdown = null; //OnShutdown; private ObjectGrabDelegate handlerObjectGrab = null; //OnObjectGrab; + private ObjectDeGrabDelegate handlerObjectDeGrab = null; //OnObjectDeGrab; private NewRezScript handlerRezScript = null; //OnRezScript; private RemoveScript handlerRemoveScript = null; //OnRemoveScript; private SceneGroupMoved handlerSceneGroupMove = null; //OnSceneGroupMove; @@ -386,6 +389,15 @@ namespace OpenSim.Region.Environment.Scenes } } + public void TriggerObjectDeGrab(uint localID, IClientAPI remoteClient) + { + handlerObjectDeGrab = OnObjectDeGrab; + if (handlerObjectDeGrab != null) + { + handlerObjectDeGrab(localID, remoteClient); + } + } + public void TriggerRezScript(uint localID, LLUUID itemID, string script) { handlerRezScript = OnRezScript; diff --git a/OpenSim/Region/Environment/Scenes/SceneManager.cs b/OpenSim/Region/Environment/Scenes/SceneManager.cs index 2dfea2ac0d..4ded1a72c9 100644 --- a/OpenSim/Region/Environment/Scenes/SceneManager.cs +++ b/OpenSim/Region/Environment/Scenes/SceneManager.cs @@ -268,15 +268,26 @@ namespace OpenSim.Region.Environment.Scenes public bool TryGetScene(string regionName, out Scene scene) { + scene = null; + foreach (Scene mscene in m_localScenes) { - if (String.Compare(mscene.RegionInfo.RegionName, regionName, true) == 0) + Console.Write("Region tested: " + mscene.RegionInfo.RegionName+" With ID: "+mscene.RegionInfo.RegionID.ToString()); + + + bool b = String.Compare(mscene.RegionInfo.RegionName.Trim(), regionName.Trim(), true) == 0; + + Console.WriteLine(" <==> Result: " + b.ToString()); + + if (b) { + + Console.WriteLine("FOUND assigning region to out parameter"); scene = mscene; return true; } } - scene = null; + return false; } diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventManager.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventManager.cs index ce9f4450ad..cbc94e295d 100644 --- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventManager.cs +++ b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventManager.cs @@ -67,6 +67,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase { myScriptEngine.Log.Info("[" + myScriptEngine.ScriptEngineName + "]: Hooking up to server events"); myScriptEngine.World.EventManager.OnObjectGrab += touch_start; + myScriptEngine.World.EventManager.OnObjectDeGrab += touch_end; myScriptEngine.World.EventManager.OnRezScript += OnRezScript; myScriptEngine.World.EventManager.OnRemoveScript += OnRemoveScript; myScriptEngine.World.EventManager.OnScriptChangedEvent += changed; @@ -117,6 +118,15 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase myScriptEngine.m_EventQueueManager.AddToObjectQueue(localID, "touch_start", detstruct, new object[] { (int)1 }); } + public void touch_end(uint localID, IClientAPI remoteClient) + { + // Add to queue for all scripts in ObjectID object + EventQueueManager.Queue_llDetectParams_Struct detstruct = new EventQueueManager.Queue_llDetectParams_Struct(); + detstruct._key = new LSL_Types.key[1]; + detstruct._key[0] = new LSL_Types.key(remoteClient.AgentId.ToString()); + myScriptEngine.m_EventQueueManager.AddToObjectQueue(localID, "touch_end", detstruct, new object[] { (int)1 }); + } + public void OnRezScript(uint localID, LLUUID itemID, string script) { Console.WriteLine("OnRezScript localID: " + localID + " LLUID: " + itemID.ToString() + " Size: " +