From 3a64522267352d1c68ef99ac76c65bd3c4f9eaf1 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 4 Jan 2012 21:40:15 +0000 Subject: Minor formatting changes and commented out log lines for future debugging of image manager (udp texture fetch). No significant functional changes. --- OpenSim/Region/ClientStack/Linden/UDP/J2KImage.cs | 24 +++++--- .../Region/ClientStack/Linden/UDP/LLClientView.cs | 2 +- .../ClientStack/Linden/UDP/LLImageManager.cs | 72 ++++++++++++++++++---- .../Agent/TextureSender/J2KDecoderModule.cs | 4 ++ 4 files changed, 80 insertions(+), 22 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ClientStack/Linden/UDP/J2KImage.cs b/OpenSim/Region/ClientStack/Linden/UDP/J2KImage.cs index cb9692a..185a909 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/J2KImage.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/J2KImage.cs @@ -102,7 +102,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP { m_currentPacket = 2; } - + while (sendMore && packetsSent < packetsToSend && m_currentPacket <= m_stopPacket) { sendMore = SendPacket(client); @@ -114,17 +114,19 @@ namespace OpenSim.Region.ClientStack.LindenUDP return (m_currentPacket > m_stopPacket); } + /// + /// This is where we decide what we need to update + /// and assign the real discardLevel and packetNumber + /// assuming of course that the connected client might be bonkers + /// public void RunUpdate() { - //This is where we decide what we need to update - //and assign the real discardLevel and packetNumber - //assuming of course that the connected client might be bonkers - if (!HasAsset) { if (!m_assetRequested) { m_assetRequested = true; +// m_log.DebugFormat("[J2KIMAGE]: Requesting asset {0}", TextureID); AssetService.Get(TextureID.ToString(), this, AssetReceived); } } @@ -137,6 +139,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP { //Request decode m_decodeRequested = true; + +// m_log.DebugFormat("[J2KIMAGE]: Requesting decode of asset {0}", TextureID); + // Do we have a jpeg decoder? if (J2KDecoder != null) { @@ -149,7 +154,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP // Send it off to the jpeg decoder J2KDecoder.BeginDecode(TextureID, m_asset, J2KDecodedCallback); } - } else { @@ -328,14 +332,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP { if (m_currentPacket == 0) return 0; + if (m_currentPacket == 1) return FIRST_PACKET_SIZE; int result = FIRST_PACKET_SIZE + ((int)m_currentPacket - 2) * IMAGE_PACKET_SIZE; + if (result < 0) - { result = FIRST_PACKET_SIZE; - } + return result; } @@ -374,7 +379,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP { UUID assetID = UUID.Zero; if (asset != null) + { assetID = asset.FullID; + } else if ((InventoryAccessModule != null) && (sender != InventoryAccessModule)) { // Unfortunately we need this here, there's no other way. @@ -395,7 +402,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP } AssetDataCallback(assetID, asset); - } } } diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index fe28ba3..eb1a50e 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -577,7 +577,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// Add a handler for the given packet type. /// /// - /// The packet is handled on its own thread. If packets must be handled in the order in which thye + /// The packet is handled on its own thread. If packets must be handled in the order in which they /// are received then please use the synchronous version of this method. /// /// diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLImageManager.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLImageManager.cs index e3a881f..3e31b7d 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLImageManager.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLImageManager.cs @@ -84,7 +84,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// public void EnqueueReq(TextureRequestArgs newRequest) { - //Make sure we're not shutting down.. if (!m_shuttingdown) { J2KImage imgrequest; @@ -99,19 +98,23 @@ namespace OpenSim.Region.ClientStack.LindenUDP { //m_log.Debug("[TEX]: (CAN) ID=" + newRequest.RequestedAssetID); - try + try { lock (m_syncRoot) - m_priorityQueue.Delete(imgrequest.PriorityQueueHandle); + m_priorityQueue.Delete(imgrequest.PriorityQueueHandle); } catch (Exception) { } } else { +// m_log.DebugFormat( +// "[LL IMAGE MANAGER]: Received duplicate of existing request for {0}, start packet {1} from {2}", +// newRequest.RequestedAssetID, newRequest.PacketNumber, m_client.Name); + //m_log.DebugFormat("[TEX]: (UPD) ID={0}: D={1}, S={2}, P={3}", // newRequest.RequestedAssetID, newRequest.DiscardLevel, newRequest.PacketNumber, newRequest.Priority); - //Check the packet sequence to make sure this isn't older than + //Check the packet sequence to make sure this isn't older than //one we've already received if (newRequest.requestSequence > imgrequest.LastSequence) { @@ -126,11 +129,34 @@ namespace OpenSim.Region.ClientStack.LindenUDP //Update the requested priority imgrequest.Priority = newRequest.Priority; + UpdateImageInQueue(imgrequest); - //Run an update imgrequest.RunUpdate(); + +// J2KImage imgrequest2 = new J2KImage(this); +// imgrequest2.J2KDecoder = m_j2kDecodeModule; +// imgrequest2.AssetService = m_assetCache; +// imgrequest2.AgentID = m_client.AgentId; +// imgrequest2.InventoryAccessModule = m_client.Scene.RequestModuleInterface(); +// imgrequest2.DiscardLevel = newRequest.DiscardLevel; +// imgrequest2.StartPacket = Math.Max(1, newRequest.PacketNumber); +// imgrequest2.Priority = newRequest.Priority; +// imgrequest2.TextureID = newRequest.RequestedAssetID; +// imgrequest2.Priority = newRequest.Priority; +// +// //Add this download to the priority queue +// AddImageToQueue(imgrequest2); +// +// imgrequest2.RunUpdate(); + } +// else +// { +// m_log.DebugFormat( +// "[LL IMAGE MANAGER]: Ignoring duplicate of existing request for {0} (sequence {1}) from {2} as its request sequence {3} is not greater", +// newRequest.RequestedAssetID, imgrequest.LastSequence, m_client.Name, newRequest.requestSequence); +// } } } else @@ -142,6 +168,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP } else { +// m_log.DebugFormat( +// "[LL IMAGE MANAGER]: Received request for {0}, start packet {1} from {2}", +// newRequest.RequestedAssetID, newRequest.PacketNumber, m_client.Name); + //m_log.DebugFormat("[TEX]: (NEW) ID={0}: D={1}, S={2}, P={3}", // newRequest.RequestedAssetID, newRequest.DiscardLevel, newRequest.PacketNumber, newRequest.Priority); @@ -159,7 +189,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP //Add this download to the priority queue AddImageToQueue(imgrequest); - //Run an update imgrequest.RunUpdate(); } } @@ -176,7 +205,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP // If null was returned, the texture priority queue is currently empty if (image == null) - return false; + break; if (image.IsDecoded) { @@ -194,10 +223,17 @@ namespace OpenSim.Region.ClientStack.LindenUDP // written. Undecoded textures should not be going into the priority // queue, because a high priority undecoded texture will clog up the // pipeline for a client - return true; +// m_log.DebugFormat( +// "[LL IMAGE MANAGER]: Exiting image queue processing early on encountering undecoded image {0}", +// image.TextureID); + + break; } } +// if (packetsSent != 0) +// m_log.DebugFormat("[LL IMAGE MANAGER]: Processed {0} packets from image queue", packetsSent); + return m_priorityQueue.Count > 0; } @@ -219,7 +255,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP { if (m_priorityQueue.Count > 0) { - try { image = m_priorityQueue.FindMax(); } + try + { + image = m_priorityQueue.FindMax(); + } catch (Exception) { } } } @@ -232,7 +271,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP lock (m_syncRoot) { - try { m_priorityQueue.Add(ref image.PriorityQueueHandle, image); } + try + { + m_priorityQueue.Add(ref image.PriorityQueueHandle, image); + } catch (Exception) { } } } @@ -241,7 +283,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP { lock (m_syncRoot) { - try { m_priorityQueue.Delete(image.PriorityQueueHandle); } + try + { + m_priorityQueue.Delete(image.PriorityQueueHandle); + } catch (Exception) { } } } @@ -250,7 +295,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP { lock (m_syncRoot) { - try { m_priorityQueue.Replace(image.PriorityQueueHandle, image); } + try + { + m_priorityQueue.Replace(image.PriorityQueueHandle, image); + } catch (Exception) { image.PriorityQueueHandle = null; diff --git a/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs b/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs index 7dd9087..14dee84 100644 --- a/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs +++ b/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs @@ -103,6 +103,10 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender // If it's cached, return the cached results if (m_decodedCache.TryGetValue(assetID, out result)) { +// m_log.DebugFormat( +// "[J2KDecoderModule]: Returning existing cached {0} layers j2k decode for {1}", +// result.Length, assetID); + callback(assetID, result); } else -- cgit v1.1 From 0634c3850563fc38a4026f70a7bfd64a05198fa3 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 4 Jan 2012 22:22:46 +0000 Subject: Separate out rebake request code from cache validation code AvatarFactoryModule. This allows some logic simplification and allows an external caller to manually request rebakes even if textures are uploaded (future command). --- .../Avatar/AvatarFactory/AvatarFactoryModule.cs | 72 ++++++++++++---------- .../Framework/Interfaces/IAvatarFactoryModule.cs | 22 +++++++ 2 files changed, 63 insertions(+), 31 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs index e8aee3e..d64a0c1 100644 --- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs @@ -156,7 +156,8 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory changed = sp.Appearance.SetTextureEntries(textureEntry) || changed; // WriteBakedTexturesReport(sp, m_log.DebugFormat); - ValidateBakedTextureCache(sp, false); + if (!ValidateBakedTextureCache(sp)) + RequestRebake(sp, true); // This appears to be set only in the final stage of the appearance // update transaction. In theory, we should be able to do an immediate @@ -251,15 +252,6 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory } /// - /// Check for the existence of the baked texture assets. - /// - /// - public bool ValidateBakedTextureCache(IScenePresence sp) - { - return ValidateBakedTextureCache(sp, true); - } - - /// /// Queue up a request to send appearance. /// /// @@ -292,17 +284,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory } } - #endregion - - #region AvatarFactoryModule private methods - - /// - /// Check for the existence of the baked texture assets. Request a rebake - /// unless checkonly is true. - /// - /// - /// - private bool ValidateBakedTextureCache(IScenePresence sp, bool checkonly) + public bool ValidateBakedTextureCache(IScenePresence sp) { bool defonly = true; // are we only using default textures @@ -330,16 +312,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory defonly = false; // found a non-default texture reference if (m_scene.AssetService.Get(face.TextureID.ToString()) == null) - { - if (checkonly) - return false; - - m_log.DebugFormat( - "[AVFACTORY]: Missing baked texture {0} ({1}) for {2}, requesting rebake.", - face.TextureID, idx, sp.Name); - - sp.ControllingClient.SendRebakeAvatarTextures(face.TextureID); - } + return false; } m_log.DebugFormat("[AVFACTORY]: Completed texture check for {0}", sp.UUID); @@ -348,6 +321,43 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory return (defonly ? false : true); } + public void RequestRebake(IScenePresence sp, bool missingTexturesOnly) + { + for (int i = 0; i < AvatarAppearance.BAKE_INDICES.Length; i++) + { + int idx = AvatarAppearance.BAKE_INDICES[i]; + Primitive.TextureEntryFace face = sp.Appearance.Texture.FaceTextures[idx]; + + // if there is no texture entry, skip it + if (face == null) + continue; + +// m_log.DebugFormat( +// "[AVFACTORY]: Looking for texture {0}, id {1} for {2} {3}", +// face.TextureID, idx, client.Name, client.AgentId); + + // if the texture is one of the "defaults" then skip it + // this should probably be more intelligent (skirt texture doesnt matter + // if the avatar isnt wearing a skirt) but if any of the main baked + // textures is default then the rest should be as well + if (face.TextureID == UUID.Zero || face.TextureID == AppearanceManager.DEFAULT_AVATAR_TEXTURE) + continue; + + if (missingTexturesOnly && m_scene.AssetService.Get(face.TextureID.ToString()) != null) + continue; + else + m_log.DebugFormat( + "[AVFACTORY]: Missing baked texture {0} ({1}) for {2}, requesting rebake.", + face.TextureID, idx, sp.Name); + + sp.ControllingClient.SendRebakeAvatarTextures(face.TextureID); + } + } + + #endregion + + #region AvatarFactoryModule private methods + private Dictionary GetBakedTextureFaces(ScenePresence sp) { if (sp.IsChildAgent) diff --git a/OpenSim/Region/Framework/Interfaces/IAvatarFactoryModule.cs b/OpenSim/Region/Framework/Interfaces/IAvatarFactoryModule.cs index 8670229..04df9c3 100644 --- a/OpenSim/Region/Framework/Interfaces/IAvatarFactoryModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IAvatarFactoryModule.cs @@ -61,7 +61,29 @@ namespace OpenSim.Region.Framework.Interfaces /// true if a valid agent was found, false otherwise bool SaveBakedTextures(UUID agentId); + /// + /// Validate that OpenSim can find the baked textures need to display a given avatar + /// + /// + /// + /// + /// true if all the baked textures referenced by the texture IDs exist or the appearance is only using default textures. false otherwise. + /// bool ValidateBakedTextureCache(IScenePresence sp); + + /// + /// Request a rebake of textures for an avatar. + /// + /// + /// This will send the request to the viewer, since it's there that the rebake is done. + /// + /// Avatar to rebake. + /// + /// If true, only request a rebake for the textures that are missing. + /// If false then we request a rebake of all textures for which we already have references. + /// + void RequestRebake(IScenePresence sp, bool missingTexturesOnly); + void QueueAppearanceSend(UUID agentid); void QueueAppearanceSave(UUID agentid); -- cgit v1.1 From 8fb70a2058e98dea63e7ee7c5b55532668fccd38 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 4 Jan 2012 22:45:07 +0000 Subject: Add "appearance rebake" command to ask a specific viewer to rebake textures from the server end. This is not as useful as it sounds, since you can only request rebakes for texture IDs already received. In other words, if the viewer has never sent the server this information (which happens quite often) then it will have no effect. Nonetheless, this is useful for diagnostic/debugging purposes. --- .../Avatar/AvatarFactory/AvatarFactoryModule.cs | 15 ++++++-- .../Avatar/Appearance/AppearanceInfoModule.cs | 40 +++++++++++++++++++++- 2 files changed, 51 insertions(+), 4 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs index d64a0c1..9df0592 100644 --- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs @@ -343,12 +343,21 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory if (face.TextureID == UUID.Zero || face.TextureID == AppearanceManager.DEFAULT_AVATAR_TEXTURE) continue; - if (missingTexturesOnly && m_scene.AssetService.Get(face.TextureID.ToString()) != null) - continue; + if (missingTexturesOnly) + { + if (m_scene.AssetService.Get(face.TextureID.ToString()) != null) + continue; + else + m_log.DebugFormat( + "[AVFACTORY]: Missing baked texture {0} ({1}) for {2}, requesting rebake.", + face.TextureID, idx, sp.Name); + } else + { m_log.DebugFormat( - "[AVFACTORY]: Missing baked texture {0} ({1}) for {2}, requesting rebake.", + "[AVFACTORY]: Requesting rebake of {0} ({1}) for {2}.", face.TextureID, idx, sp.Name); + } sp.ControllingClient.SendRebakeAvatarTextures(face.TextureID); } diff --git a/OpenSim/Region/OptionalModules/Avatar/Appearance/AppearanceInfoModule.cs b/OpenSim/Region/OptionalModules/Avatar/Appearance/AppearanceInfoModule.cs index 1ce24f1..7e15718 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Appearance/AppearanceInfoModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Appearance/AppearanceInfoModule.cs @@ -114,6 +114,16 @@ namespace OpenSim.Region.OptionalModules.Avatar.Appearance "Send appearance data for each avatar in the simulator to other viewers.", "Optionally, you can specify that only a particular avatar's appearance data is sent.", HandleSendAppearanceCommand); + + scene.AddCommand( + this, "appearance rebake", + "appearance rebake ", + "Send a request to the user's viewer for it to rebake and reupload its appearance textures.", + "This is currently done for all baked texture references previously received, whether the simulator can find the asset or not." + + "\nThis will only work for texture ids that the viewer has already uploaded." + + "\nIf the viewer has not yet sent the server any texture ids then nothing will happen" + + "\nsince requests can only be made for ids that the client has already sent us", + HandleRebakeAppearanceCommand); } private void HandleSendAppearanceCommand(string module, string[] cmd) @@ -210,6 +220,34 @@ namespace OpenSim.Region.OptionalModules.Avatar.Appearance } } } - } + } + + private void HandleRebakeAppearanceCommand(string module, string[] cmd) + { + if (cmd.Length != 4) + { + MainConsole.Instance.OutputFormat("Usage: appearance rebake "); + return; + } + + string firstname = cmd[2]; + string lastname = cmd[3]; + + lock (m_scenes) + { + foreach (Scene scene in m_scenes.Values) + { + ScenePresence sp = scene.GetScenePresence(firstname, lastname); + if (sp != null && !sp.IsChildAgent) + { + MainConsole.Instance.OutputFormat( + "Requesting rebake of uploaded textures for {0}", + sp.Name, scene.RegionInfo.RegionName); + + scene.AvatarFactory.RequestRebake(sp, false); + } + } + } + } } } \ No newline at end of file -- cgit v1.1 From 97ba3c93467e865d0434c0b2f0f775efdc0c354a Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 5 Jan 2012 08:11:52 +0000 Subject: Small fix to GetWorldPosition to get closer to Avination sit behavior --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index aea47e6..51d3586 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -1960,19 +1960,13 @@ namespace OpenSim.Region.Framework.Scenes public Vector3 GetWorldPosition() { Quaternion parentRot = ParentGroup.RootPart.RotationOffset; - Vector3 axPos = OffsetPosition; - axPos *= parentRot; Vector3 translationOffsetPosition = axPos; - -// m_log.DebugFormat("[SCENE OBJECT PART]: Found group pos {0} for part {1}", GroupPosition, Name); - - Vector3 worldPos = GroupPosition + translationOffsetPosition; - -// m_log.DebugFormat("[SCENE OBJECT PART]: Found world pos {0} for part {1}", worldPos, Name); - - return worldPos; + if(_parentID == 0) + return GroupPosition; + else + return ParentGroup.AbsolutePosition + translationOffsetPosition; } /// -- cgit v1.1 From da6c816204eb3364a4527bc086d27e79cd2af0e5 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 5 Jan 2012 17:10:38 +0000 Subject: Commenting out DataSnapShot message "Registering service discovery capability" for now. Please uncomment if/when needed. --- OpenSim/Region/DataSnapshot/DataRequestHandler.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/DataSnapshot/DataRequestHandler.cs b/OpenSim/Region/DataSnapshot/DataRequestHandler.cs index b760454..93648d6 100644 --- a/OpenSim/Region/DataSnapshot/DataRequestHandler.cs +++ b/OpenSim/Region/DataSnapshot/DataRequestHandler.cs @@ -67,7 +67,7 @@ namespace OpenSim.Region.DataSnapshot public void OnRegisterCaps(UUID agentID, Caps caps) { - m_log.Info("[DATASNAPSHOT]: Registering service discovery capability for " + agentID); +// m_log.InfoFormat("[DATASNAPSHOT]: Registering service discovery capability for {0}", agentID); string capsBase = "/CAPS/" + caps.CapsObjectPath; caps.RegisterHandler("PublicSnapshotDataInfo", new RestStreamHandler("POST", capsBase + m_discoveryPath, OnDiscoveryAttempt)); -- cgit v1.1 From c201b54b8524033310c59fe353616e84616a542e Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 5 Jan 2012 19:40:54 +0000 Subject: Improve "app rebake" command to return a better message if no uploaded texture ids were available for the rebake request --- OpenSim/Region/ClientStack/Linden/UDP/LLImageManager.cs | 12 ++++++------ .../CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs | 7 ++++++- OpenSim/Region/Framework/Interfaces/IAvatarFactoryModule.cs | 5 ++++- .../Avatar/Appearance/AppearanceInfoModule.cs | 13 +++++++++---- 4 files changed, 25 insertions(+), 12 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLImageManager.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLImageManager.cs index 3e31b7d..b53f0af 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLImageManager.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLImageManager.cs @@ -107,9 +107,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP } else { -// m_log.DebugFormat( -// "[LL IMAGE MANAGER]: Received duplicate of existing request for {0}, start packet {1} from {2}", -// newRequest.RequestedAssetID, newRequest.PacketNumber, m_client.Name); + m_log.DebugFormat( + "[LL IMAGE MANAGER]: Received duplicate of existing request for {0}, start packet {1} from {2}", + newRequest.RequestedAssetID, newRequest.PacketNumber, m_client.Name); //m_log.DebugFormat("[TEX]: (UPD) ID={0}: D={1}, S={2}, P={3}", // newRequest.RequestedAssetID, newRequest.DiscardLevel, newRequest.PacketNumber, newRequest.Priority); @@ -168,9 +168,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP } else { -// m_log.DebugFormat( -// "[LL IMAGE MANAGER]: Received request for {0}, start packet {1} from {2}", -// newRequest.RequestedAssetID, newRequest.PacketNumber, m_client.Name); + m_log.DebugFormat( + "[LL IMAGE MANAGER]: Received request for {0}, start packet {1} from {2}", + newRequest.RequestedAssetID, newRequest.PacketNumber, m_client.Name); //m_log.DebugFormat("[TEX]: (NEW) ID={0}: D={1}, S={2}, P={3}", // newRequest.RequestedAssetID, newRequest.DiscardLevel, newRequest.PacketNumber, newRequest.Priority); diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs index 9df0592..d68d28c 100644 --- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs @@ -321,8 +321,10 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory return (defonly ? false : true); } - public void RequestRebake(IScenePresence sp, bool missingTexturesOnly) + public int RequestRebake(IScenePresence sp, bool missingTexturesOnly) { + int texturesRebaked = 0; + for (int i = 0; i < AvatarAppearance.BAKE_INDICES.Length; i++) { int idx = AvatarAppearance.BAKE_INDICES[i]; @@ -359,8 +361,11 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory face.TextureID, idx, sp.Name); } + texturesRebaked++; sp.ControllingClient.SendRebakeAvatarTextures(face.TextureID); } + + return texturesRebaked; } #endregion diff --git a/OpenSim/Region/Framework/Interfaces/IAvatarFactoryModule.cs b/OpenSim/Region/Framework/Interfaces/IAvatarFactoryModule.cs index 04df9c3..39a760c 100644 --- a/OpenSim/Region/Framework/Interfaces/IAvatarFactoryModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IAvatarFactoryModule.cs @@ -82,7 +82,10 @@ namespace OpenSim.Region.Framework.Interfaces /// If true, only request a rebake for the textures that are missing. /// If false then we request a rebake of all textures for which we already have references. /// - void RequestRebake(IScenePresence sp, bool missingTexturesOnly); + /// + /// Number of rebake requests made. This will depend upon whether we've previously received texture IDs. + /// + int RequestRebake(IScenePresence sp, bool missingTexturesOnly); void QueueAppearanceSend(UUID agentid); void QueueAppearanceSave(UUID agentid); diff --git a/OpenSim/Region/OptionalModules/Avatar/Appearance/AppearanceInfoModule.cs b/OpenSim/Region/OptionalModules/Avatar/Appearance/AppearanceInfoModule.cs index 7e15718..39cd4c9 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Appearance/AppearanceInfoModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Appearance/AppearanceInfoModule.cs @@ -240,11 +240,16 @@ namespace OpenSim.Region.OptionalModules.Avatar.Appearance ScenePresence sp = scene.GetScenePresence(firstname, lastname); if (sp != null && !sp.IsChildAgent) { - MainConsole.Instance.OutputFormat( - "Requesting rebake of uploaded textures for {0}", - sp.Name, scene.RegionInfo.RegionName); + int rebakesRequested = scene.AvatarFactory.RequestRebake(sp, false); - scene.AvatarFactory.RequestRebake(sp, false); + if (rebakesRequested > 0) + MainConsole.Instance.OutputFormat( + "Requesting rebake of {0} uploaded textures for {1} in {2}", + rebakesRequested, sp.Name, scene.RegionInfo.RegionName); + else + MainConsole.Instance.OutputFormat( + "No texture IDs available for rebake request for {0} in {1}", + sp.Name, scene.RegionInfo.RegionName); } } } -- cgit v1.1 From 50e459d265ab2a25d41afee82e475a530f0cfd5a Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 5 Jan 2012 19:44:06 +0000 Subject: recomment log messages I accidentally left uncommented --- OpenSim/Region/ClientStack/Linden/UDP/LLImageManager.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLImageManager.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLImageManager.cs index b53f0af..3e31b7d 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLImageManager.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLImageManager.cs @@ -107,9 +107,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP } else { - m_log.DebugFormat( - "[LL IMAGE MANAGER]: Received duplicate of existing request for {0}, start packet {1} from {2}", - newRequest.RequestedAssetID, newRequest.PacketNumber, m_client.Name); +// m_log.DebugFormat( +// "[LL IMAGE MANAGER]: Received duplicate of existing request for {0}, start packet {1} from {2}", +// newRequest.RequestedAssetID, newRequest.PacketNumber, m_client.Name); //m_log.DebugFormat("[TEX]: (UPD) ID={0}: D={1}, S={2}, P={3}", // newRequest.RequestedAssetID, newRequest.DiscardLevel, newRequest.PacketNumber, newRequest.Priority); @@ -168,9 +168,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP } else { - m_log.DebugFormat( - "[LL IMAGE MANAGER]: Received request for {0}, start packet {1} from {2}", - newRequest.RequestedAssetID, newRequest.PacketNumber, m_client.Name); +// m_log.DebugFormat( +// "[LL IMAGE MANAGER]: Received request for {0}, start packet {1} from {2}", +// newRequest.RequestedAssetID, newRequest.PacketNumber, m_client.Name); //m_log.DebugFormat("[TEX]: (NEW) ID={0}: D={1}, S={2}, P={3}", // newRequest.RequestedAssetID, newRequest.DiscardLevel, newRequest.PacketNumber, newRequest.Priority); -- cgit v1.1 From f2ff6d5186420ed4bbf7379ad6dc92f46b7907a9 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 5 Jan 2012 20:31:46 +0000 Subject: Move asset commands from AssetService to AssetServerConnector so that we can harmonise the same commands on the simulator side. No functional change. --- .../Server/Handlers/Asset/AssetServerConnector.cs | 127 ++++++++++++++++++++- OpenSim/Services/AssetService/AssetService.cs | 124 +------------------- 2 files changed, 129 insertions(+), 122 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs b/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs index df571fa..9960228 100644 --- a/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs +++ b/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs @@ -26,7 +26,11 @@ */ using System; +using System.IO; using Nini.Config; +using OpenMetaverse; +using OpenSim.Framework; +using OpenSim.Framework.Console; using OpenSim.Server.Base; using OpenSim.Services.Interfaces; using OpenSim.Framework.Servers.HttpServer; @@ -67,6 +71,127 @@ namespace OpenSim.Server.Handlers.Asset server.AddStreamHandler(new AssetServerGetHandler(m_AssetService)); server.AddStreamHandler(new AssetServerPostHandler(m_AssetService)); server.AddStreamHandler(new AssetServerDeleteHandler(m_AssetService, allowDelete)); + + MainConsole.Instance.Commands.AddCommand("kfs", false, + "show digest", + "show digest ", + "Show asset digest", + HandleShowDigest); + + MainConsole.Instance.Commands.AddCommand("kfs", false, + "delete asset", + "delete asset ", + "Delete asset from database", + HandleDeleteAsset); + + MainConsole.Instance.Commands.AddCommand("kfs", false, + "dump asset", + "dump asset ", + "Dump asset to a file", + "The filename is the same as the ID given.", + HandleDumpAsset); + } + + void HandleDeleteAsset(string module, string[] args) + { + if (args.Length < 3) + { + MainConsole.Instance.Output("Syntax: delete asset "); + return; + } + + AssetBase asset = m_AssetService.Get(args[2]); + + if (asset == null || asset.Data.Length == 0) + { + MainConsole.Instance.Output("Asset not found"); + return; + } + + m_AssetService.Delete(args[2]); + + //MainConsole.Instance.Output("Asset deleted"); + // TODO: Implement this + + MainConsole.Instance.Output("Asset deletion not supported by database"); + } + + void HandleDumpAsset(string module, string[] args) + { + if (args.Length < 3) + { + MainConsole.Instance.Output("Usage is dump asset "); + return; + } + + UUID assetId; + string rawAssetId = args[2]; + + if (!UUID.TryParse(rawAssetId, out assetId)) + { + MainConsole.Instance.OutputFormat("ERROR: {0} is not a valid ID format", rawAssetId); + return; + } + + AssetBase asset = m_AssetService.Get(assetId.ToString()); + if (asset == null) + { + MainConsole.Instance.OutputFormat("ERROR: No asset found with ID {0}", assetId); + return; + } + + string fileName = rawAssetId; + + using (FileStream fs = new FileStream(fileName, FileMode.CreateNew)) + { + using (BinaryWriter bw = new BinaryWriter(fs)) + { + bw.Write(asset.Data); + } + } + + MainConsole.Instance.OutputFormat("Asset dumped to file {0}", fileName); + } + + void HandleShowDigest(string module, string[] args) + { + if (args.Length < 3) + { + MainConsole.Instance.Output("Syntax: show digest "); + return; + } + + AssetBase asset = m_AssetService.Get(args[2]); + + if (asset == null || asset.Data.Length == 0) + { + MainConsole.Instance.Output("Asset not found"); + return; + } + + int i; + + MainConsole.Instance.OutputFormat("Name: {0}", asset.Name); + MainConsole.Instance.OutputFormat("Description: {0}", asset.Description); + MainConsole.Instance.OutputFormat("Type: {0} (type number = {1})", (AssetType)asset.Type, asset.Type); + MainConsole.Instance.OutputFormat("Content-type: {0}", asset.Metadata.ContentType); + MainConsole.Instance.OutputFormat("Flags: {0}", asset.Metadata.Flags); + + for (i = 0 ; i < 5 ; i++) + { + int off = i * 16; + if (asset.Data.Length <= off) + break; + int len = 16; + if (asset.Data.Length < off + len) + len = asset.Data.Length - off; + + byte[] line = new byte[len]; + Array.Copy(asset.Data, off, line, 0, len); + + string text = BitConverter.ToString(line); + MainConsole.Instance.Output(String.Format("{0:x4}: {1}", off, text)); + } } } -} +} \ No newline at end of file diff --git a/OpenSim/Services/AssetService/AssetService.cs b/OpenSim/Services/AssetService/AssetService.cs index b3af8e3..4f4cbf6 100644 --- a/OpenSim/Services/AssetService/AssetService.cs +++ b/OpenSim/Services/AssetService/AssetService.cs @@ -32,7 +32,6 @@ using System.Reflection; using Nini.Config; using log4net; using OpenSim.Framework; -using OpenSim.Framework.Console; using OpenSim.Data; using OpenSim.Services.Interfaces; using OpenMetaverse; @@ -53,23 +52,6 @@ namespace OpenSim.Services.AssetService { m_RootInstance = this; - MainConsole.Instance.Commands.AddCommand("kfs", false, - "show digest", - "show digest ", - "Show asset digest", HandleShowDigest); - - MainConsole.Instance.Commands.AddCommand("kfs", false, - "delete asset", - "delete asset ", - "Delete asset from database", HandleDeleteAsset); - - MainConsole.Instance.Commands.AddCommand("kfs", false, - "dump asset", - "dump asset ", - "Dump asset to a file", - "The filename is the same as the ID given.", - HandleDumpAsset); - if (m_AssetLoader != null) { IConfig assetConfig = config.Configs["AssetService"]; @@ -218,111 +200,11 @@ namespace OpenSim.Services.AssetService return m_Database.Delete(id); } else - m_log.DebugFormat("[ASSET SERVICE]: Request to delete asset {0}, but flags are not Maptile", id); - - return false; - } - - void HandleDumpAsset(string module, string[] args) - { - if (args.Length < 3) - { - MainConsole.Instance.Output("Usage is dump asset "); - return; - } - - string rawAssetId = args[2]; - UUID assetId; - - if (!UUID.TryParse(rawAssetId, out assetId)) - { - MainConsole.Instance.OutputFormat("ERROR: {0} is not a valid ID format", rawAssetId); - return; - } - - AssetBase asset = m_Database.GetAsset(assetId); - if (asset == null) - { - MainConsole.Instance.OutputFormat("ERROR: No asset found with ID {0}", assetId); - return; - } - - string fileName = rawAssetId; - - using (FileStream fs = new FileStream(fileName, FileMode.CreateNew)) - { - using (BinaryWriter bw = new BinaryWriter(fs)) - { - bw.Write(asset.Data); - } - } - - MainConsole.Instance.OutputFormat("Asset dumped to file {0}", fileName); - } - - void HandleShowDigest(string module, string[] args) - { - if (args.Length < 3) - { - MainConsole.Instance.Output("Syntax: show digest "); - return; - } - - AssetBase asset = Get(args[2]); - - if (asset == null || asset.Data.Length == 0) - { - MainConsole.Instance.Output("Asset not found"); - return; - } - - int i; - - MainConsole.Instance.OutputFormat("Name: {0}", asset.Name); - MainConsole.Instance.OutputFormat("Description: {0}", asset.Description); - MainConsole.Instance.OutputFormat("Type: {0} (type number = {1})", (AssetType)asset.Type, asset.Type); - MainConsole.Instance.OutputFormat("Content-type: {0}", asset.Metadata.ContentType); - MainConsole.Instance.OutputFormat("Flags: {0}", asset.Metadata.Flags); - - for (i = 0 ; i < 5 ; i++) { - int off = i * 16; - if (asset.Data.Length <= off) - break; - int len = 16; - if (asset.Data.Length < off + len) - len = asset.Data.Length - off; - - byte[] line = new byte[len]; - Array.Copy(asset.Data, off, line, 0, len); - - string text = BitConverter.ToString(line); - MainConsole.Instance.Output(String.Format("{0:x4}: {1}", off, text)); - } - } - - void HandleDeleteAsset(string module, string[] args) - { - if (args.Length < 3) - { - MainConsole.Instance.Output("Syntax: delete asset "); - return; - } - - AssetBase asset = Get(args[2]); - - if (asset == null || asset.Data.Length == 0) - { - MainConsole.Instance.Output("Asset not found"); - return; + m_log.DebugFormat("[ASSET SERVICE]: Request to delete asset {0}, but flags are not Maptile", id); } - Delete(args[2]); - - //MainConsole.Instance.Output("Asset deleted"); - // TODO: Implement this - - MainConsole.Instance.Output("Asset deletion not supported by database"); + return false; } } -} +} \ No newline at end of file -- cgit v1.1 From 7319ba62dd1791a3dade5b5453e369d955de48a2 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 5 Jan 2012 20:51:49 +0000 Subject: Move simulator asset info commands to an optional module from the connector. Make them conform with service side commands. This stops them appearing twice when Hypergrid is enabled. --- .../OptionalModules/Asset/AssetInfoModule.cs | 134 +++++++++++++++++++++ .../Minimodule/Interfaces/IInventoryItem.cs | 5 +- .../Connectors/Asset/AssetServiceConnector.cs | 45 +------ 3 files changed, 138 insertions(+), 46 deletions(-) create mode 100644 OpenSim/Region/OptionalModules/Asset/AssetInfoModule.cs (limited to 'OpenSim') diff --git a/OpenSim/Region/OptionalModules/Asset/AssetInfoModule.cs b/OpenSim/Region/OptionalModules/Asset/AssetInfoModule.cs new file mode 100644 index 0000000..9ea6343 --- /dev/null +++ b/OpenSim/Region/OptionalModules/Asset/AssetInfoModule.cs @@ -0,0 +1,134 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using System.IO; +using System.Reflection; +using System.Text; +using log4net; +using Mono.Addins; +using Nini.Config; +using OpenMetaverse; +using OpenSim.Framework; +using OpenSim.Framework.Console; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.Framework.Scenes; + +namespace OpenSim.Region.OptionalModules.Asset +{ + /// + /// A module that just holds commands for inspecting assets. + /// + [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "AssetInfoModule")] + public class AssetInfoModule : ISharedRegionModule + { +// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + private Scene m_scene; + + public string Name { get { return "Asset Information Module"; } } + + public Type ReplaceableInterface { get { return null; } } + + public void Initialise(IConfigSource source) + { +// m_log.DebugFormat("[ASSET INFO MODULE]: INITIALIZED MODULE"); + } + + public void PostInitialise() + { +// m_log.DebugFormat("[ASSET INFO MODULE]: POST INITIALIZED MODULE"); + } + + public void Close() + { +// m_log.DebugFormat("[ASSET INFO MODULE]: CLOSED MODULE"); + } + + public void AddRegion(Scene scene) + { +// m_log.DebugFormat("[ASSET INFO MODULE]: REGION {0} ADDED", scene.RegionInfo.RegionName); + } + + public void RemoveRegion(Scene scene) + { +// m_log.DebugFormat("[ASSET INFO MODULE]: REGION {0} REMOVED", scene.RegionInfo.RegionName); + } + + public void RegionLoaded(Scene scene) + { +// m_log.DebugFormat("[ASSET INFO MODULE]: REGION {0} LOADED", scene.RegionInfo.RegionName); + + if (m_scene == null) + m_scene = scene; + + MainConsole.Instance.Commands.AddCommand( + "asset", false, "dump asset", + "dump asset ", + "Dump an asset", + HandleDumpAsset); + } + + void HandleDumpAsset(string module, string[] args) + { + if (args.Length < 3) + { + MainConsole.Instance.Output("Usage is dump asset "); + return; + } + + UUID assetId; + string rawAssetId = args[2]; + + if (!UUID.TryParse(rawAssetId, out assetId)) + { + MainConsole.Instance.OutputFormat("ERROR: {0} is not a valid ID format", rawAssetId); + return; + } + + AssetBase asset = m_scene.AssetService.Get(assetId.ToString()); + if (asset == null) + { + MainConsole.Instance.OutputFormat("ERROR: No asset found with ID {0}", assetId); + return; + } + + string fileName = rawAssetId; + + using (FileStream fs = new FileStream(fileName, FileMode.CreateNew)) + { + using (BinaryWriter bw = new BinaryWriter(fs)) + { + bw.Write(asset.Data); + } + } + + MainConsole.Instance.OutputFormat("Asset dumped to file {0}", fileName); + } + } +} \ No newline at end of file diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IInventoryItem.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IInventoryItem.cs index 16cd7e4..a8e545c 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IInventoryItem.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IInventoryItem.cs @@ -30,8 +30,7 @@ using OpenMetaverse; using OpenMetaverse.Assets; namespace OpenSim.Region.OptionalModules.Scripting.Minimodule -{ - +{ /// /// This implements the methods needed to operate on individual inventory items. /// @@ -39,6 +38,6 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { int Type { get; } UUID AssetID { get; } - T RetrieveAsset() where T : Asset, new(); + T RetrieveAsset() where T : OpenMetaverse.Assets.Asset, new(); } } diff --git a/OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs b/OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs index d7b2ff8..e4c3eaf 100644 --- a/OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs +++ b/OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs @@ -86,11 +86,8 @@ namespace OpenSim.Services.Connectors m_log.Error("[ASSET CONNECTOR]: No Server URI named in section AssetService"); throw new Exception("Asset connector init error"); } - m_ServerURI = serviceURI; - MainConsole.Instance.Commands.AddCommand("asset", false, "dump asset", - "dump asset ", - "dump one cached asset", HandleDumpAsset); + m_ServerURI = serviceURI; } protected void SetCache(IImprovedAssetCache cache) @@ -328,43 +325,5 @@ namespace OpenSim.Services.Connectors } return false; } - - private void HandleDumpAsset(string module, string[] args) - { - if (args.Length != 4) - { - MainConsole.Instance.Output("Syntax: dump asset "); - return; - } - - UUID assetID; - - if (!UUID.TryParse(args[2], out assetID)) - { - MainConsole.Instance.Output("Invalid asset ID"); - return; - } - - if (m_Cache == null) - { - MainConsole.Instance.Output("Instance uses no cache"); - return; - } - - AssetBase asset = m_Cache.Get(assetID.ToString()); - - if (asset == null) - { - MainConsole.Instance.Output("Asset not found in cache"); - return; - } - - string fileName = args[3]; - - FileStream fs = File.Create(fileName); - fs.Write(asset.Data, 0, asset.Data.Length); - - fs.Close(); - } } -} +} \ No newline at end of file -- cgit v1.1 From 5b160f5b7b2abf41e518e3974098b1bc82268c2a Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 5 Jan 2012 20:56:29 +0000 Subject: Rename 'show digest' console command to 'show asset' --- OpenSim/Server/Handlers/Asset/AssetServerConnector.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim') diff --git a/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs b/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs index 9960228..61718f1 100644 --- a/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs +++ b/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs @@ -157,7 +157,7 @@ namespace OpenSim.Server.Handlers.Asset { if (args.Length < 3) { - MainConsole.Instance.Output("Syntax: show digest "); + MainConsole.Instance.Output("Syntax: show asset "); return; } -- cgit v1.1 From f06acc0a854980fd66426103892742580e057974 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 5 Jan 2012 21:05:10 +0000 Subject: Add size and temporary information to "show asset" command --- OpenSim/Server/Handlers/Asset/AssetServerConnector.cs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'OpenSim') diff --git a/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs b/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs index 61718f1..5dcb33b 100644 --- a/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs +++ b/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs @@ -175,6 +175,8 @@ namespace OpenSim.Server.Handlers.Asset MainConsole.Instance.OutputFormat("Description: {0}", asset.Description); MainConsole.Instance.OutputFormat("Type: {0} (type number = {1})", (AssetType)asset.Type, asset.Type); MainConsole.Instance.OutputFormat("Content-type: {0}", asset.Metadata.ContentType); + MainConsole.Instance.OutputFormat("Size: {0} bytes", asset.Data.Length); + MainConsole.Instance.OutputFormat("Temporary: {0}", asset.Temporary ? "yes" : "no"); MainConsole.Instance.OutputFormat("Flags: {0}", asset.Metadata.Flags); for (i = 0 ; i < 5 ; i++) -- cgit v1.1 From da0fc3c8f572adba69e52e1d7f528946ab1f6f23 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 5 Jan 2012 21:11:32 +0000 Subject: Make "show asset" command available simulator side. Actually make the service command be "show asset" instead of "show digest" this time. Last time I accidnetally just changed the usage message. --- .../OptionalModules/Asset/AssetInfoModule.cs | 51 ++++++++++++++++++++++ .../Server/Handlers/Asset/AssetServerConnector.cs | 10 ++--- 2 files changed, 56 insertions(+), 5 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/OptionalModules/Asset/AssetInfoModule.cs b/OpenSim/Region/OptionalModules/Asset/AssetInfoModule.cs index 9ea6343..a5207eb 100644 --- a/OpenSim/Region/OptionalModules/Asset/AssetInfoModule.cs +++ b/OpenSim/Region/OptionalModules/Asset/AssetInfoModule.cs @@ -88,6 +88,14 @@ namespace OpenSim.Region.OptionalModules.Asset m_scene = scene; MainConsole.Instance.Commands.AddCommand( + "asset", + false, + "show asset", + "show asset ", + "Show asset information", + HandleShowAsset); + + MainConsole.Instance.Commands.AddCommand( "asset", false, "dump asset", "dump asset ", "Dump an asset", @@ -130,5 +138,48 @@ namespace OpenSim.Region.OptionalModules.Asset MainConsole.Instance.OutputFormat("Asset dumped to file {0}", fileName); } + + void HandleShowAsset(string module, string[] args) + { + if (args.Length < 3) + { + MainConsole.Instance.Output("Syntax: show asset "); + return; + } + + AssetBase asset = m_scene.AssetService.Get(args[2]); + + if (asset == null || asset.Data.Length == 0) + { + MainConsole.Instance.Output("Asset not found"); + return; + } + + int i; + + MainConsole.Instance.OutputFormat("Name: {0}", asset.Name); + MainConsole.Instance.OutputFormat("Description: {0}", asset.Description); + MainConsole.Instance.OutputFormat("Type: {0} (type number = {1})", (AssetType)asset.Type, asset.Type); + MainConsole.Instance.OutputFormat("Content-type: {0}", asset.Metadata.ContentType); + MainConsole.Instance.OutputFormat("Size: {0} bytes", asset.Data.Length); + MainConsole.Instance.OutputFormat("Temporary: {0}", asset.Temporary ? "yes" : "no"); + MainConsole.Instance.OutputFormat("Flags: {0}", asset.Metadata.Flags); + + for (i = 0 ; i < 5 ; i++) + { + int off = i * 16; + if (asset.Data.Length <= off) + break; + int len = 16; + if (asset.Data.Length < off + len) + len = asset.Data.Length - off; + + byte[] line = new byte[len]; + Array.Copy(asset.Data, off, line, 0, len); + + string text = BitConverter.ToString(line); + MainConsole.Instance.Output(String.Format("{0:x4}: {1}", off, text)); + } + } } } \ No newline at end of file diff --git a/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs b/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs index 5dcb33b..9b80245 100644 --- a/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs +++ b/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs @@ -73,10 +73,10 @@ namespace OpenSim.Server.Handlers.Asset server.AddStreamHandler(new AssetServerDeleteHandler(m_AssetService, allowDelete)); MainConsole.Instance.Commands.AddCommand("kfs", false, - "show digest", - "show digest ", - "Show asset digest", - HandleShowDigest); + "show asset", + "show asset ", + "Show asset information", + HandleShowAsset); MainConsole.Instance.Commands.AddCommand("kfs", false, "delete asset", @@ -153,7 +153,7 @@ namespace OpenSim.Server.Handlers.Asset MainConsole.Instance.OutputFormat("Asset dumped to file {0}", fileName); } - void HandleShowDigest(string module, string[] args) + void HandleShowAsset(string module, string[] args) { if (args.Length < 3) { -- cgit v1.1 From 5ea9740f1b2cc98601cfb15c19e190471c4c42ed Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 5 Jan 2012 22:40:49 +0000 Subject: Add a "j2k decode" region console command that allows a manual request for a JPEG2000 decode of an asset For debugging purposes. --- .../Agent/TextureSender/J2KDecoderModule.cs | 18 +-- OpenSim/Region/Framework/Interfaces/IJ2KDecoder.cs | 9 +- .../Agent/TextureSender/J2KDecoderCommandModule.cs | 145 +++++++++++++++++++++ 3 files changed, 163 insertions(+), 9 deletions(-) create mode 100644 OpenSim/Region/OptionalModules/Agent/TextureSender/J2KDecoderCommandModule.cs (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs b/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs index 14dee84..349d3ac 100644 --- a/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs +++ b/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs @@ -137,14 +137,9 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender } } - /// - /// Provides a synchronous decode so that caller can be assured that this executes before the next line - /// - /// - /// - public void Decode(UUID assetID, byte[] j2kData) + public bool Decode(UUID assetID, byte[] j2kData) { - DoJ2KDecode(assetID, j2kData); + return DoJ2KDecode(assetID, j2kData); } #endregion IJ2KDecoder @@ -154,11 +149,13 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender /// /// UUID of Asset /// JPEG2000 data - private void DoJ2KDecode(UUID assetID, byte[] j2kData) + private bool DoJ2KDecode(UUID assetID, byte[] j2kData) { // m_log.DebugFormat( // "[J2KDecoderModule]: Doing J2K decoding of {0} bytes for asset {1}", j2kData.Length, assetID); + bool decodedSuccessfully = true; + //int DecodeTime = 0; //DecodeTime = Environment.TickCount; OpenJPEG.J2KLayerInfo[] layers; @@ -196,6 +193,7 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender catch (Exception ex) { m_log.Warn("[J2KDecoderModule]: CSJ2K threw an exception decoding texture " + assetID + ": " + ex.Message); + decodedSuccessfully = false; } } else @@ -204,6 +202,7 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender if (!OpenJPEG.DecodeLayerBoundaries(j2kData, out layers, out components)) { m_log.Warn("[J2KDecoderModule]: OpenJPEG failed to decode texture " + assetID); + decodedSuccessfully = false; } } @@ -212,6 +211,7 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender m_log.Warn("[J2KDecoderModule]: Failed to decode layer data for texture " + assetID + ", guessing sane defaults"); // Layer decoding completely failed. Guess at sane defaults for the layer boundaries layers = CreateDefaultLayers(j2kData.Length); + decodedSuccessfully = false; } // Cache Decoded layers @@ -231,6 +231,8 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender m_notifyList.Remove(assetID); } } + + return decodedSuccessfully; } private OpenJPEG.J2KLayerInfo[] CreateDefaultLayers(int j2kLength) diff --git a/OpenSim/Region/Framework/Interfaces/IJ2KDecoder.cs b/OpenSim/Region/Framework/Interfaces/IJ2KDecoder.cs index 856eb11..0964276 100644 --- a/OpenSim/Region/Framework/Interfaces/IJ2KDecoder.cs +++ b/OpenSim/Region/Framework/Interfaces/IJ2KDecoder.cs @@ -35,6 +35,13 @@ namespace OpenSim.Region.Framework.Interfaces public interface IJ2KDecoder { void BeginDecode(UUID assetID, byte[] j2kData, DecodedCallback callback); - void Decode(UUID assetID, byte[] j2kData); + + /// + /// Provides a synchronous decode so that caller can be assured that this executes before the next line + /// + /// + /// + /// true if decode was successful. false otherwise. + bool Decode(UUID assetID, byte[] j2kData); } } diff --git a/OpenSim/Region/OptionalModules/Agent/TextureSender/J2KDecoderCommandModule.cs b/OpenSim/Region/OptionalModules/Agent/TextureSender/J2KDecoderCommandModule.cs new file mode 100644 index 0000000..b224132 --- /dev/null +++ b/OpenSim/Region/OptionalModules/Agent/TextureSender/J2KDecoderCommandModule.cs @@ -0,0 +1,145 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using System.IO; +using System.Reflection; +using System.Text; +using log4net; +using Mono.Addins; +using Nini.Config; +using OpenMetaverse; +using OpenSim.Framework; +using OpenSim.Framework.Console; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.Framework.Scenes; + +namespace OpenSim.Region.OptionalModules.Agent.TextureSender +{ + /// + /// Commands for the J2KDecoder module. For debugging purposes. + /// + /// + /// Placed here so that they can be removed if not required and to keep the J2KDecoder module itself simple. + /// + [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "J2KDecoderCommandModule")] + public class J2KDecoderCommandModule : ISharedRegionModule + { +// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + private Scene m_scene; + + public string Name { get { return "Asset Information Module"; } } + + public Type ReplaceableInterface { get { return null; } } + + public void Initialise(IConfigSource source) + { +// m_log.DebugFormat("[J2K DECODER COMMAND MODULE]: INITIALIZED MODULE"); + } + + public void PostInitialise() + { +// m_log.DebugFormat("[J2K DECODER COMMAND MODULE]: POST INITIALIZED MODULE"); + } + + public void Close() + { +// m_log.DebugFormat("[J2K DECODER COMMAND MODULE]: CLOSED MODULE"); + } + + public void AddRegion(Scene scene) + { +// m_log.DebugFormat("[J2K DECODER COMMAND MODULE]: REGION {0} ADDED", scene.RegionInfo.RegionName); + } + + public void RemoveRegion(Scene scene) + { +// m_log.DebugFormat("[J2K DECODER COMMAND MODULE]: REGION {0} REMOVED", scene.RegionInfo.RegionName); + } + + public void RegionLoaded(Scene scene) + { +// m_log.DebugFormat("[J2K DECODER COMMAND MODULE]: REGION {0} LOADED", scene.RegionInfo.RegionName); + + if (m_scene == null) + m_scene = scene; + + MainConsole.Instance.Commands.AddCommand( + "j2k", + false, + "j2k decode", + "j2k decode ", + "Do JPEG2000 decoding of an asset.", + "This is for debugging purposes. The asset id given must contain JPEG2000 data.", + HandleDecode); + } + + void HandleDecode(string module, string[] args) + { + if (args.Length < 3) + { + MainConsole.Instance.Output("Usage is j2k decode "); + return; + } + + UUID assetId; + string rawAssetId = args[2]; + + if (!UUID.TryParse(rawAssetId, out assetId)) + { + MainConsole.Instance.OutputFormat("ERROR: {0} is not a valid ID format", rawAssetId); + return; + } + + AssetBase asset = m_scene.AssetService.Get(assetId.ToString()); + if (asset == null) + { + MainConsole.Instance.OutputFormat("ERROR: No asset found with ID {0}", assetId); + return; + } + + if (asset.Type != (sbyte)AssetType.Texture) + { + MainConsole.Instance.OutputFormat("ERROR: Asset {0} is not a texture type", assetId); + return; + } + + IJ2KDecoder decoder = m_scene.RequestModuleInterface(); + if (decoder == null) + { + MainConsole.Instance.OutputFormat("ERROR: No IJ2KDecoder module available"); + return; + } + + if (decoder.Decode(assetId, asset.Data)) + MainConsole.Instance.OutputFormat("Successfully decoded asset {0}", assetId); + else + MainConsole.Instance.OutputFormat("Decode of asset {0} failed", assetId); } + } +} \ No newline at end of file -- cgit v1.1 From 2b4edd659f59a0db4e8d81924de0312799d4f744 Mon Sep 17 00:00:00 2001 From: BlueWall Date: Thu, 5 Jan 2012 17:53:03 -0500 Subject: Adding empty ISearchModule interface --- OpenSim/Framework/ISearchModule.cs | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 OpenSim/Framework/ISearchModule.cs (limited to 'OpenSim') diff --git a/OpenSim/Framework/ISearchModule.cs b/OpenSim/Framework/ISearchModule.cs new file mode 100644 index 0000000..64bf72c --- /dev/null +++ b/OpenSim/Framework/ISearchModule.cs @@ -0,0 +1,36 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using OpenMetaverse; + +namespace OpenSim.Framework +{ + public interface ISearchModule + { + + } +} -- cgit v1.1 From b86e7715a8d8f081fa9452d92a9d8f6d52867a12 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 5 Jan 2012 22:54:33 +0000 Subject: Improve "j2k decode" command to tell us how many layers and components were decoded, instead of just success/failure --- .../Agent/TextureSender/J2KDecoderModule.cs | 21 ++++++++++++++++----- OpenSim/Region/Framework/Interfaces/IJ2KDecoder.cs | 10 ++++++++++ .../Agent/TextureSender/J2KDecoderCommandModule.cs | 16 +++++++++++++--- 3 files changed, 39 insertions(+), 8 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs b/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs index 349d3ac..a1a2501 100644 --- a/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs +++ b/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs @@ -133,13 +133,20 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender // Do Decode! if (decode) - DoJ2KDecode(assetID, j2kData); + Decode(assetID, j2kData); } } public bool Decode(UUID assetID, byte[] j2kData) { - return DoJ2KDecode(assetID, j2kData); + OpenJPEG.J2KLayerInfo[] layers; + int components; + return Decode(assetID, j2kData, out layers, out components); + } + + public bool Decode(UUID assetID, byte[] j2kData, out OpenJPEG.J2KLayerInfo[] layers, out int components) + { + return DoJ2KDecode(assetID, j2kData, out layers, out components); } #endregion IJ2KDecoder @@ -149,7 +156,10 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender /// /// UUID of Asset /// JPEG2000 data - private bool DoJ2KDecode(UUID assetID, byte[] j2kData) + /// layer data + /// number of components + /// true if decode was successful. false otherwise. + private bool DoJ2KDecode(UUID assetID, byte[] j2kData, out OpenJPEG.J2KLayerInfo[] layers, out int components) { // m_log.DebugFormat( // "[J2KDecoderModule]: Doing J2K decoding of {0} bytes for asset {1}", j2kData.Length, assetID); @@ -158,7 +168,9 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender //int DecodeTime = 0; //DecodeTime = Environment.TickCount; - OpenJPEG.J2KLayerInfo[] layers; + + // We don't get this from CSJ2K. Is it relevant? + components = 0; if (!TryLoadCacheForAsset(assetID, out layers)) { @@ -198,7 +210,6 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender } else { - int components; if (!OpenJPEG.DecodeLayerBoundaries(j2kData, out layers, out components)) { m_log.Warn("[J2KDecoderModule]: OpenJPEG failed to decode texture " + assetID); diff --git a/OpenSim/Region/Framework/Interfaces/IJ2KDecoder.cs b/OpenSim/Region/Framework/Interfaces/IJ2KDecoder.cs index 0964276..46d03b3 100644 --- a/OpenSim/Region/Framework/Interfaces/IJ2KDecoder.cs +++ b/OpenSim/Region/Framework/Interfaces/IJ2KDecoder.cs @@ -43,5 +43,15 @@ namespace OpenSim.Region.Framework.Interfaces /// /// true if decode was successful. false otherwise. bool Decode(UUID assetID, byte[] j2kData); + + /// + /// Provides a synchronous decode so that caller can be assured that this executes before the next line + /// + /// + /// + /// layer data + /// number of components + /// true if decode was successful. false otherwise. + bool Decode(UUID assetID, byte[] j2kData, out OpenJPEG.J2KLayerInfo[] layers, out int components); } } diff --git a/OpenSim/Region/OptionalModules/Agent/TextureSender/J2KDecoderCommandModule.cs b/OpenSim/Region/OptionalModules/Agent/TextureSender/J2KDecoderCommandModule.cs index b224132..439096a 100644 --- a/OpenSim/Region/OptionalModules/Agent/TextureSender/J2KDecoderCommandModule.cs +++ b/OpenSim/Region/OptionalModules/Agent/TextureSender/J2KDecoderCommandModule.cs @@ -34,6 +34,7 @@ using log4net; using Mono.Addins; using Nini.Config; using OpenMetaverse; +using OpenMetaverse.Imaging; using OpenSim.Framework; using OpenSim.Framework.Console; using OpenSim.Region.Framework.Interfaces; @@ -137,9 +138,18 @@ namespace OpenSim.Region.OptionalModules.Agent.TextureSender return; } - if (decoder.Decode(assetId, asset.Data)) - MainConsole.Instance.OutputFormat("Successfully decoded asset {0}", assetId); + OpenJPEG.J2KLayerInfo[] layers; + int components; + if (decoder.Decode(assetId, asset.Data, out layers, out components)) + { + MainConsole.Instance.OutputFormat( + "Successfully decoded asset {0} with {1} layers and {2} components", + assetId, layers.Length, components); + } else - MainConsole.Instance.OutputFormat("Decode of asset {0} failed", assetId); } + { + MainConsole.Instance.OutputFormat("Decode of asset {0} failed", assetId); + } + } } } \ No newline at end of file -- cgit v1.1 From fbb2a7e90d28bb6a522b4e203e53e1c81cbf25e5 Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 6 Jan 2012 17:37:22 +0000 Subject: Add ThreatLevel.NoAccess to OSSL. This allows to enable OSSL without enabling any methods, even those without threat, automatically. It is for use with setups wanting to allow only specific methods to specific users. --- OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 5 ++++- OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 503b5d0..bb0ba3d 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -157,6 +157,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api string risk = m_ScriptEngine.Config.GetString("OSFunctionThreatLevel", "VeryLow"); switch (risk) { + case "NoAccess": + m_MaxThreatLevel = ThreatLevel.NoAccess; + break; case "None": m_MaxThreatLevel = ThreatLevel.None; break; @@ -2619,4 +2622,4 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return date.ToString("yyyy-MM-ddTHH:mm:ss.fffffffZ"); } } -} \ No newline at end of file +} diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index 00ca070..f5ee733 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs @@ -42,6 +42,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces { public enum ThreatLevel { + NoAccess = -1, None = 0, Nuisance = 1, VeryLow = 2, -- cgit v1.1 From f8c15d38a614ca7fcfc78a0c2883831ea6cf8137 Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 6 Jan 2012 17:43:35 +0000 Subject: If dragging a script that is no copy from prim inventory into agent inventory, stop it first in scene. If deleting from prims, move to trash rather then making it poof. --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 55 +++++++++++++++------- 1 file changed, 39 insertions(+), 16 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index b62023b..2444367 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -979,25 +979,40 @@ namespace OpenSim.Region.Framework.Scenes public void RemoveTaskInventory(IClientAPI remoteClient, UUID itemID, uint localID) { SceneObjectPart part = GetSceneObjectPart(localID); - if (part == null) - return; + SceneObjectGroup group = null; + if (part != null) + { + group = part.ParentGroup; + } + if (part != null && group != null) + { + if (!Permissions.CanEditObjectInventory(part.UUID, remoteClient.AgentId)) + return; - SceneObjectGroup group = part.ParentGroup; - if (!Permissions.CanEditObjectInventory(part.UUID, remoteClient.AgentId)) - return; - - TaskInventoryItem item = group.GetInventoryItem(localID, itemID); - if (item == null) - return; + TaskInventoryItem item = group.GetInventoryItem(localID, itemID); + if (item == null) + return; - if (item.Type == 10) - { - part.RemoveScriptEvents(itemID); - EventManager.TriggerRemoveScript(localID, itemID); + InventoryFolderBase destFolder = InventoryService.GetFolderForType(remoteClient.AgentId, AssetType.TrashFolder); + + // Move the item to trash. If this is a copiable item, only + // a copy will be moved and we will still need to delete + // the item from the prim. If it was no copy, is will be + // deleted by this method. + MoveTaskInventoryItem(remoteClient, destFolder.ID, part, itemID); + + if (group.GetInventoryItem(localID, itemID) != null) + { + if (item.Type == 10) + { + part.RemoveScriptEvents(itemID); + EventManager.TriggerRemoveScript(localID, itemID); + } + + group.RemoveInventoryItem(localID, itemID); + } + part.SendPropertiesToClient(remoteClient); } - - group.RemoveInventoryItem(localID, itemID); - part.SendPropertiesToClient(remoteClient); } private InventoryItemBase CreateAgentInventoryItemFromTask(UUID destAgent, SceneObjectPart part, UUID itemId) @@ -1058,7 +1073,15 @@ namespace OpenSim.Region.Framework.Scenes if (!Permissions.BypassPermissions()) { if ((taskItem.CurrentPermissions & (uint)PermissionMask.Copy) == 0) + { + if (taskItem.Type == 10) + { + part.RemoveScriptEvents(itemId); + EventManager.TriggerRemoveScript(part.LocalId, itemId); + } + part.Inventory.RemoveInventoryItem(itemId); + } } return agentItem; -- cgit v1.1 From 7661a0b2a913a7637cb8ba8310be370594901485 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 6 Jan 2012 20:20:11 +0000 Subject: Implement the FetchInventory2 capability. This accompanies the existing FetchInventoryDescendents2 capability. Not yet enabled by default. You can enable this by setting Cap_FetchInventory2 = "localhost" in the [ClientStack.LindenCaps] section of OpenSim.ini Enabling both FetchInventory2 and FetchInventoryDescendents2 improves the situation with properly fetching attachments and hud objects Probably because viewers are never expecting the odd situation where FetchInventoryDescendents2 is present but not FetchInventory2 However, for some reason attachments and hud objects occasionally fail to appear, though their status is correct in inventory For attachments, focussing on the avatar makes them appear. Hud objects have to be reattached. --- .../FetchInventory2/FetchInventory2Handler.cs | 148 ++++++++++++++++++++ .../FetchInventory2ServerConnector.cs | 70 ++++++++++ .../WebFetchInvDescHandler.cs | 2 +- OpenSim/Capabilities/LLSDInventoryItem.cs | 9 +- .../Linden/Caps/FetchInventory2Module.cs | 151 +++++++++++++++++++++ 5 files changed, 378 insertions(+), 2 deletions(-) create mode 100644 OpenSim/Capabilities/Handlers/FetchInventory2/FetchInventory2Handler.cs create mode 100644 OpenSim/Capabilities/Handlers/FetchInventory2/FetchInventory2ServerConnector.cs create mode 100644 OpenSim/Region/ClientStack/Linden/Caps/FetchInventory2Module.cs (limited to 'OpenSim') diff --git a/OpenSim/Capabilities/Handlers/FetchInventory2/FetchInventory2Handler.cs b/OpenSim/Capabilities/Handlers/FetchInventory2/FetchInventory2Handler.cs new file mode 100644 index 0000000..717a097 --- /dev/null +++ b/OpenSim/Capabilities/Handlers/FetchInventory2/FetchInventory2Handler.cs @@ -0,0 +1,148 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Reflection; +using log4net; +using Nini.Config; +using OpenMetaverse; +using OpenMetaverse.StructuredData; +using OpenSim.Framework; +using OpenSim.Framework.Capabilities; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Framework.Servers.HttpServer; +using OpenSim.Services.Interfaces; +using Caps = OpenSim.Framework.Capabilities.Caps; +using OSDArray = OpenMetaverse.StructuredData.OSDArray; +using OSDMap = OpenMetaverse.StructuredData.OSDMap; + +namespace OpenSim.Capabilities.Handlers +{ + public class FetchInventory2Handler + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + private IInventoryService m_inventoryService; + + public FetchInventory2Handler(IInventoryService invService) + { + m_inventoryService = invService; + } + + public string FetchInventoryRequest(string request, string path, string param, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) + { +// m_log.DebugFormat("[FETCH INVENTORY HANDLER]: Received FetchInventory capabilty request"); + + OSDMap requestmap = (OSDMap)OSDParser.DeserializeLLSDXml(Utils.StringToBytes(request)); + OSDArray itemsRequested = (OSDArray)requestmap["items"]; + + string reply; + LLSDFetchInventory llsdReply = new LLSDFetchInventory(); + + foreach (OSDMap osdItemId in itemsRequested) + { + UUID itemId = osdItemId["item_id"].AsUUID(); + + InventoryItemBase item = m_inventoryService.GetItem(new InventoryItemBase(itemId)); + + if (item != null) + { + // We don't know the agent that this request belongs to so we'll use the agent id of the item + // which will be the same for all items. + llsdReply.agent_id = item.Owner; + + llsdReply.items.Array.Add(ConvertInventoryItem(item)); + } + } + + reply = LLSDHelpers.SerialiseLLSDReply(llsdReply); + + return reply; + } + + /// + /// Convert an internal inventory item object into an LLSD object. + /// + /// + /// + private LLSDInventoryItem ConvertInventoryItem(InventoryItemBase invItem) + { + LLSDInventoryItem llsdItem = new LLSDInventoryItem(); + llsdItem.asset_id = invItem.AssetID; + llsdItem.created_at = invItem.CreationDate; + llsdItem.desc = invItem.Description; + llsdItem.flags = (int)invItem.Flags; + llsdItem.item_id = invItem.ID; + llsdItem.name = invItem.Name; + llsdItem.parent_id = invItem.Folder; + + try + { + llsdItem.type = Utils.AssetTypeToString((AssetType)invItem.AssetType); + llsdItem.inv_type = Utils.InventoryTypeToString((InventoryType)invItem.InvType); + } + catch (Exception e) + { + m_log.ErrorFormat( + "[WEB FETCH INV DESC HANDLER]: Problem setting asset {0} inventory {1} types while converting inventory item {2}: {3}", + invItem.AssetType, invItem.InvType, invItem.Name, e.Message); + } + + llsdItem.permissions = new LLSDPermissions(); + llsdItem.permissions.creator_id = invItem.CreatorIdAsUuid; + llsdItem.permissions.base_mask = (int)invItem.CurrentPermissions; + llsdItem.permissions.everyone_mask = (int)invItem.EveryOnePermissions; + llsdItem.permissions.group_id = invItem.GroupID; + llsdItem.permissions.group_mask = (int)invItem.GroupPermissions; + llsdItem.permissions.is_owner_group = invItem.GroupOwned; + llsdItem.permissions.next_owner_mask = (int)invItem.NextPermissions; + llsdItem.permissions.owner_id = invItem.Owner; + llsdItem.permissions.owner_mask = (int)invItem.CurrentPermissions; + llsdItem.sale_info = new LLSDSaleInfo(); + llsdItem.sale_info.sale_price = invItem.SalePrice; + switch (invItem.SaleType) + { + default: + llsdItem.sale_info.sale_type = "not"; + break; + case 1: + llsdItem.sale_info.sale_type = "original"; + break; + case 2: + llsdItem.sale_info.sale_type = "copy"; + break; + case 3: + llsdItem.sale_info.sale_type = "contents"; + break; + } + + return llsdItem; + } + } +} diff --git a/OpenSim/Capabilities/Handlers/FetchInventory2/FetchInventory2ServerConnector.cs b/OpenSim/Capabilities/Handlers/FetchInventory2/FetchInventory2ServerConnector.cs new file mode 100644 index 0000000..0ba8931 --- /dev/null +++ b/OpenSim/Capabilities/Handlers/FetchInventory2/FetchInventory2ServerConnector.cs @@ -0,0 +1,70 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using Nini.Config; +using OpenSim.Server.Base; +using OpenSim.Services.Interfaces; +using OpenSim.Framework.Servers.HttpServer; +using OpenSim.Server.Handlers.Base; +using OpenMetaverse; + +namespace OpenSim.Capabilities.Handlers +{ + public class FetchInventory2ServerConnector : ServiceConnector + { + private IInventoryService m_InventoryService; + private string m_ConfigName = "CapsService"; + + public FetchInventory2ServerConnector(IConfigSource config, IHttpServer server, string configName) + : base(config, server, configName) + { + if (configName != String.Empty) + m_ConfigName = configName; + + IConfig serverConfig = config.Configs[m_ConfigName]; + if (serverConfig == null) + throw new Exception(String.Format("No section '{0}' in config file", m_ConfigName)); + + string invService = serverConfig.GetString("InventoryService", String.Empty); + + if (invService == String.Empty) + throw new Exception("No InventoryService in config file"); + + Object[] args = new Object[] { config }; + m_InventoryService = ServerUtils.LoadPlugin(invService, args); + + if (m_InventoryService == null) + throw new Exception(String.Format("Failed to load InventoryService from {0}; config is {1}", invService, m_ConfigName)); + + FetchInventory2Handler fiHandler = new FetchInventory2Handler(m_InventoryService); + IRequestHandler reqHandler + = new RestStreamHandler("POST", "/CAPS/FetchInventory/", fiHandler.FetchInventoryRequest); + server.AddStreamHandler(reqHandler); + } + } +} diff --git a/OpenSim/Capabilities/Handlers/WebFetchInventoryDescendents/WebFetchInvDescHandler.cs b/OpenSim/Capabilities/Handlers/WebFetchInventoryDescendents/WebFetchInvDescHandler.cs index 3ce4e66..8b44f72 100644 --- a/OpenSim/Capabilities/Handlers/WebFetchInventoryDescendents/WebFetchInvDescHandler.cs +++ b/OpenSim/Capabilities/Handlers/WebFetchInventoryDescendents/WebFetchInvDescHandler.cs @@ -245,7 +245,7 @@ namespace OpenSim.Capabilities.Handlers // containingFolder.Name, containingFolder.ID, agentID); version = containingFolder.Version; -// + // if (fetchItems) // { // List linkedItemsToAdd = new List(); diff --git a/OpenSim/Capabilities/LLSDInventoryItem.cs b/OpenSim/Capabilities/LLSDInventoryItem.cs index cce18d7..426a6cb 100644 --- a/OpenSim/Capabilities/LLSDInventoryItem.cs +++ b/OpenSim/Capabilities/LLSDInventoryItem.cs @@ -95,4 +95,11 @@ namespace OpenSim.Framework.Capabilities public UUID owner_id; public int version; } -} + + [OSDMap] + public class LLSDFetchInventory + { + public UUID agent_id; + public OSDArray items = new OSDArray(); + } +} \ No newline at end of file diff --git a/OpenSim/Region/ClientStack/Linden/Caps/FetchInventory2Module.cs b/OpenSim/Region/ClientStack/Linden/Caps/FetchInventory2Module.cs new file mode 100644 index 0000000..14501c7 --- /dev/null +++ b/OpenSim/Region/ClientStack/Linden/Caps/FetchInventory2Module.cs @@ -0,0 +1,151 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections; +using System.Reflection; +using log4net; +using Nini.Config; +using Mono.Addins; +using OpenMetaverse; +using OpenSim.Framework; +using OpenSim.Framework.Servers.HttpServer; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Services.Interfaces; +using Caps = OpenSim.Framework.Capabilities.Caps; +using OpenSim.Capabilities.Handlers; + +namespace OpenSim.Region.ClientStack.Linden +{ + /// + /// This module implements both WebFetchInventoryDescendents and FetchInventoryDescendents2 capabilities. + /// + [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] + public class FetchInventory2Module : INonSharedRegionModule + { +// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + public bool Enabled { get; private set; } + + private Scene m_scene; + + private IInventoryService m_inventoryService; + + private string m_fetchInventory2Url; + + private FetchInventory2Handler m_fetchHandler; + + #region ISharedRegionModule Members + + public void Initialise(IConfigSource source) + { + IConfig config = source.Configs["ClientStack.LindenCaps"]; + if (config == null) + return; + + m_fetchInventory2Url = config.GetString("Cap_FetchInventory2", string.Empty); + + if (m_fetchInventory2Url != string.Empty) + Enabled = true; + } + + public void AddRegion(Scene s) + { + if (!Enabled) + return; + + m_scene = s; + } + + public void RemoveRegion(Scene s) + { + if (!Enabled) + return; + + m_scene.EventManager.OnRegisterCaps -= RegisterCaps; + m_scene = null; + } + + public void RegionLoaded(Scene s) + { + if (!Enabled) + return; + + m_inventoryService = m_scene.InventoryService; + + // We'll reuse the same handler for all requests. + if (m_fetchInventory2Url == "localhost") + m_fetchHandler = new FetchInventory2Handler(m_inventoryService); + + m_scene.EventManager.OnRegisterCaps += RegisterCaps; + } + + public void PostInitialise() {} + + public void Close() {} + + public string Name { get { return "FetchInventory2Module"; } } + + public Type ReplaceableInterface + { + get { return null; } + } + + #endregion + + private void RegisterCaps(UUID agentID, Caps caps) + { + RegisterFetchCap(agentID, caps, "FetchInventory2", m_fetchInventory2Url); + } + + private void RegisterFetchCap(UUID agentID, Caps caps, string capName, string url) + { + string capUrl; + + if (url == "localhost") + { + capUrl = "/CAPS/" + UUID.Random(); + + IRequestHandler reqHandler + = new RestStreamHandler("POST", capUrl, m_fetchHandler.FetchInventoryRequest); + + caps.RegisterHandler(capName, reqHandler); + } + else + { + capUrl = url; + + caps.RegisterHandler(capName, capUrl); + } + +// m_log.DebugFormat( +// "[FETCH INVENTORY2 MODULE]: Registered capability {0} at {1} in region {2} for {3}", +// capName, capUrl, m_scene.RegionInfo.RegionName, agentID); + } + } +} -- cgit v1.1 From eb9bf717264083ad76022dff6a2284ad9393ac38 Mon Sep 17 00:00:00 2001 From: John Cochran Date: Tue, 3 Jan 2012 11:38:38 -0600 Subject: Replaced llRot2Euler function. The original function suffered from unexpected results due to rounding errors. An error of only 1 or 2 ulps would cause the code to not detect a singularity at Y rotation +/- PI/2 and take the non-singularity code path. The replacement code does not suffer from wildly inaccurate results at the +/- PI/2 singularity. The check in the code for the singularity isn't strictly needed, but gives more consistent results At the singularity, the X and Z rotations add. The if check simply forces the X rotation to be zero so the entirety of the X+Z rotation is carried by Z. Additionally, the test code has been updated to include test cases that caused the old code to fail. The test algorithm is also updated to perform a more meaningful test. The original code checked if the values against expected values. This could fail at +/- PI rotations since a rotation around an axis by PI causes the identical effect as a rotation by -PI. The new test code checks that the returned angles can be used to recreate a quaternion that causes the same rotation. --- .../Shared/Api/Implementation/LSL_Api.cs | 31 +++---- .../ScriptEngine/Shared/Tests/LSL_ApiTest.cs | 97 ++++++++++++++++++---- 2 files changed, 92 insertions(+), 36 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 443e7a5..d6316b2 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -468,26 +468,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api //Now we start getting into quaternions which means sin/cos, matrices and vectors. ckrinke - // Old implementation of llRot2Euler. Normalization not required as Atan2 function will - // only return values >= -PI (-180 degrees) and <= PI (180 degrees). - + // Using algorithm based off http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToEuler/quat_2_euler_paper_ver2-1.pdf + // to avoid issues with singularity and rounding with Y rotation of +/- PI/2 public LSL_Vector llRot2Euler(LSL_Rotation r) { - m_host.AddScriptLPS(1); - //This implementation is from http://lslwiki.net/lslwiki/wakka.php?wakka=LibraryRotationFunctions. ckrinke - LSL_Rotation t = new LSL_Rotation(r.x * r.x, r.y * r.y, r.z * r.z, r.s * r.s); - double m = (t.x + t.y + t.z + t.s); - if (m == 0) return new LSL_Vector(); - double n = 2 * (r.y * r.s + r.x * r.z); - double p = m * m - n * n; - if (p > 0) - return new LSL_Vector(Math.Atan2(2.0 * (r.x * r.s - r.y * r.z), (-t.x - t.y + t.z + t.s)), - Math.Atan2(n, Math.Sqrt(p)), - Math.Atan2(2.0 * (r.z * r.s - r.x * r.y), (t.x - t.y - t.z + t.s))); - else if (n > 0) - return new LSL_Vector(0.0, Math.PI * 0.5, Math.Atan2((r.z * r.s + r.x * r.y), 0.5 - t.x - t.z)); - else - return new LSL_Vector(0.0, -Math.PI * 0.5, Math.Atan2((r.z * r.s + r.x * r.y), 0.5 - t.x - t.z)); + LSL_Vector v = new LSL_Vector(0.0, 0.0, 1.0) * r; // Z axis unit vector unaffected by Z rotation component of r. + double m = LSL_Vector.Mag(v); // Just in case v isn't normalized, need magnitude for Asin() operation later. + if (m == 0.0) return new LSL_Vector(); + double x = Math.Atan2(-v.y, v.z); + double sin = v.x / m; + if (sin < -0.999999 || sin > 0.999999) x = 0.0; // Force X rotation to 0 at the singularities. + double y = Math.Asin(sin); + // Rotate X axis unit vector by r and unwind the X and Y rotations leaving only the Z rotation + v = new LSL_Vector(1.0, 0.0, 0.0) * ((r * new LSL_Rotation(Math.Sin(-x / 2.0), 0.0, 0.0, Math.Cos(-x / 2.0))) * new LSL_Rotation(0.0, Math.Sin(-y / 2.0), 0.0, Math.Cos(-y / 2.0))); + double z = Math.Atan2(v.y, v.x); + return new LSL_Vector(x, y, z); } /* From wiki: diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs index 0cbad41..7594691 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs @@ -142,30 +142,91 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests public void TestllRot2Euler() { // 180, 90 and zero degree rotations. - CheckllRot2Euler(new LSL_Types.Quaternion(1.0f, 0.0f, 0.0f, 0.0f), new LSL_Types.Vector3(Math.PI, 0.0f, 0.0f)); - CheckllRot2Euler(new LSL_Types.Quaternion(0.0f, 1.0f, 0.0f, 0.0f), new LSL_Types.Vector3(Math.PI, 0.0f, Math.PI)); - CheckllRot2Euler(new LSL_Types.Quaternion(0.0f, 0.0f, 1.0f, 0.0f), new LSL_Types.Vector3(0.0f, 0.0f, Math.PI)); - CheckllRot2Euler(new LSL_Types.Quaternion(0.0f, 0.0f, 0.0f, 1.0f), new LSL_Types.Vector3(0.0f, 0.0f, 0.0f)); - CheckllRot2Euler(new LSL_Types.Quaternion(-0.5f, -0.5f, 0.5f, 0.5f), new LSL_Types.Vector3(0, -Math.PI / 2.0f, Math.PI / 2.0f)); - CheckllRot2Euler(new LSL_Types.Quaternion(-0.707107f, 0.0f, 0.0f, -0.707107f), new LSL_Types.Vector3(Math.PI / 2.0f, 0.0f, 0.0f)); + CheckllRot2Euler(new LSL_Types.Quaternion(0.0f, 0.0f, 0.0f, 1.0f)); + CheckllRot2Euler(new LSL_Types.Quaternion(0.0f, 0.0f, 0.707107f, 0.707107f)); + CheckllRot2Euler(new LSL_Types.Quaternion(0.0f, 0.0f, 1.0f, 0.0f)); + CheckllRot2Euler(new LSL_Types.Quaternion(0.0f, 0.0f, 0.707107f, -0.707107f)); + CheckllRot2Euler(new LSL_Types.Quaternion(0.707107f, 0.0f, 0.0f, 0.707107f)); + CheckllRot2Euler(new LSL_Types.Quaternion(0.5f, -0.5f, 0.5f, 0.5f)); + CheckllRot2Euler(new LSL_Types.Quaternion(0.0f, -0.707107f, 0.707107f, 0.0f)); + CheckllRot2Euler(new LSL_Types.Quaternion(-0.5f, -0.5f, 0.5f, -0.5f)); + CheckllRot2Euler(new LSL_Types.Quaternion(1.0f, 0.0f, 0.0f, 0.0f)); + CheckllRot2Euler(new LSL_Types.Quaternion(0.707107f, -0.707107f, 0.0f, 0.0f)); + CheckllRot2Euler(new LSL_Types.Quaternion(0.0f, -1.0f, 0.0f, 0.0f)); + CheckllRot2Euler(new LSL_Types.Quaternion(-0.707107f, -0.707107f, 0.0f, 0.0f)); + CheckllRot2Euler(new LSL_Types.Quaternion(0.707107f, 0.0f, 0.0f, -0.707107f)); + CheckllRot2Euler(new LSL_Types.Quaternion(0.5f, -0.5f, -0.5f, -0.5f)); + CheckllRot2Euler(new LSL_Types.Quaternion(0.0f, -0.707107f, -0.707107f, 0.0f)); + CheckllRot2Euler(new LSL_Types.Quaternion(-0.5f, -0.5f, -0.5f, 0.5f)); + CheckllRot2Euler(new LSL_Types.Quaternion(0.0f, -0.707107f, 0.0f, 0.707107f)); + CheckllRot2Euler(new LSL_Types.Quaternion(-0.5f, -0.5f, 0.5f, 0.5f)); + CheckllRot2Euler(new LSL_Types.Quaternion(-0.707107f, 0.0f, 0.707107f, 0.0f)); + CheckllRot2Euler(new LSL_Types.Quaternion(-0.5f, 0.5f, 0.5f, -0.5f)); + CheckllRot2Euler(new LSL_Types.Quaternion(0.0f, -0.707107f, 0.0f, -0.707107f)); + CheckllRot2Euler(new LSL_Types.Quaternion(-0.5f, -0.5f, -0.5f, -0.5f)); + CheckllRot2Euler(new LSL_Types.Quaternion(-0.707107f, 0.0f, -0.707107f, 0.0f)); + CheckllRot2Euler(new LSL_Types.Quaternion(-0.5f, 0.5f, -0.5f, 0.5f)); + // A couple of messy rotations. - CheckllRot2Euler(new LSL_Types.Quaternion(1.0f, 5.651f, -3.1f, 67.023f), new LSL_Types.Vector3(0.037818f, 0.166447f, -0.095595f)); - CheckllRot2Euler(new LSL_Types.Quaternion(0.719188f, -0.408934f, -0.363998f, -0.427841f), new LSL_Types.Vector3(-1.954769f, -0.174533f, 1.151917f)); + CheckllRot2Euler(new LSL_Types.Quaternion(1.0f, 5.651f, -3.1f, 67.023f)); + CheckllRot2Euler(new LSL_Types.Quaternion(0.719188f, -0.408934f, -0.363998f, -0.427841f)); + + // Some deliberately malicious rotations (intended on provoking singularity errors) + // The "f" suffexes are deliberately omitted. + CheckllRot2Euler(new LSL_Types.Quaternion(0.50001f, 0.50001f, 0.50001f, 0.50001f)); + // More malice. The "f" suffixes are deliberately omitted. + CheckllRot2Euler(new LSL_Types.Quaternion(-0.701055, 0.092296, 0.701055, -0.092296)); + CheckllRot2Euler(new LSL_Types.Quaternion(-0.183005, -0.683010, 0.183005, 0.683010)); + CheckllRot2Euler(new LSL_Types.Quaternion(-0.430460, -0.560982, 0.430460, 0.560982)); + CheckllRot2Euler(new LSL_Types.Quaternion(-0.701066, 0.092301, -0.701066, 0.092301)); + CheckllRot2Euler(new LSL_Types.Quaternion(-0.183013, -0.683010, 0.183013, 0.683010)); + CheckllRot2Euler(new LSL_Types.Quaternion(-0.183005, -0.683014, -0.183005, -0.683014)); + CheckllRot2Euler(new LSL_Types.Quaternion(-0.353556, 0.612375, 0.353556, -0.612375)); + CheckllRot2Euler(new LSL_Types.Quaternion(0.353554, -0.612385, -0.353554, 0.612385)); + CheckllRot2Euler(new LSL_Types.Quaternion(-0.560989, 0.430450, 0.560989, -0.430450)); + CheckllRot2Euler(new LSL_Types.Quaternion(-0.183013, 0.683009, -0.183013, 0.683009)); + CheckllRot2Euler(new LSL_Types.Quaternion(0.430457, -0.560985, -0.430457, 0.560985)); + CheckllRot2Euler(new LSL_Types.Quaternion(0.353552, 0.612360, -0.353552, -0.612360)); + CheckllRot2Euler(new LSL_Types.Quaternion(-0.499991, 0.500003, 0.499991, -0.500003)); + CheckllRot2Euler(new LSL_Types.Quaternion(-0.353555, -0.612385, -0.353555, -0.612385)); + CheckllRot2Euler(new LSL_Types.Quaternion(0.701066, -0.092301, -0.701066, 0.092301)); + CheckllRot2Euler(new LSL_Types.Quaternion(-0.499991, 0.500007, 0.499991, -0.500007)); + CheckllRot2Euler(new LSL_Types.Quaternion(-0.683002, 0.183016, -0.683002, 0.183016)); + CheckllRot2Euler(new LSL_Types.Quaternion(0.430458, 0.560982, 0.430458, 0.560982)); + CheckllRot2Euler(new LSL_Types.Quaternion(0.499991, -0.500003, -0.499991, 0.500003)); + CheckllRot2Euler(new LSL_Types.Quaternion(-0.183009, 0.683011, -0.183009, 0.683011)); + CheckllRot2Euler(new LSL_Types.Quaternion(0.560975, -0.430457, 0.560975, -0.430457)); + CheckllRot2Euler(new LSL_Types.Quaternion(0.701055, 0.092300, 0.701055, 0.092300)); + CheckllRot2Euler(new LSL_Types.Quaternion(-0.560990, 0.430459, -0.560990, 0.430459)); + CheckllRot2Euler(new LSL_Types.Quaternion(-0.092302, -0.701059, -0.092302, -0.701059)); } - private void CheckllRot2Euler(LSL_Types.Quaternion rot, LSL_Types.Vector3 eulerCheck) + // Testing Rot2Euler this way instead of comparing against expected angles because + // 1. There are several ways to get to the original Quaternion. For example a rotation + // of PI and -PI will give the same result. But PI and -PI aren't equal. + // 2. This method checks to see if the calculated angles from a quaternion can be used + // to create a new quaternion to produce the same rotation. + // However, can't compare the newly calculated quaternion against the original because + // once again, there are multiple quaternions that give the same result. For instance + // == <-X, -Y, -Z, -S>. Additionally, the magnitude of S can be changed + // and will still result in the same rotation if the values for X, Y, Z are also changed + // to compensate. + // However, if two quaternions represent the same rotation, then multiplying the first + // quaternion by the conjugate of the second, will give a third quaternion representing + // a zero rotation. This can be tested for by looking at the X, Y, Z values which should + // be zero. + private void CheckllRot2Euler(LSL_Types.Quaternion rot) { // Call LSL function to convert quaternion rotaion to euler radians. LSL_Types.Vector3 eulerCalc = m_lslApi.llRot2Euler(rot); - // Check upper and lower bounds of x, y and z. - // This type of check is performed as opposed to comparing for equal numbers, in order to allow slight - // differences in accuracy. - Assert.Greater(eulerCalc.x, eulerCheck.x - ANGLE_ACCURACY_IN_RADIANS, "TestllRot2Euler X lower bounds check fail"); - Assert.Less(eulerCalc.x, eulerCheck.x + ANGLE_ACCURACY_IN_RADIANS, "TestllRot2Euler X upper bounds check fail"); - Assert.Greater(eulerCalc.y, eulerCheck.y - ANGLE_ACCURACY_IN_RADIANS, "TestllRot2Euler Y lower bounds check fail"); - Assert.Less(eulerCalc.y, eulerCheck.y + ANGLE_ACCURACY_IN_RADIANS, "TestllRot2Euler Y upper bounds check fail"); - Assert.Greater(eulerCalc.z, eulerCheck.z - ANGLE_ACCURACY_IN_RADIANS, "TestllRot2Euler Z lower bounds check fail"); - Assert.Less(eulerCalc.z, eulerCheck.z + ANGLE_ACCURACY_IN_RADIANS, "TestllRot2Euler Z upper bounds check fail"); + // Now use the euler radians to recalculate a new quaternion rotation + LSL_Types.Quaternion newRot = m_lslApi.llEuler2Rot(eulerCalc); + // Multiple original quaternion by conjugate of quaternion calculated with angles. + LSL_Types.Quaternion check = rot * new LSL_Types.Quaternion(-newRot.x, -newRot.y, -newRot.z, newRot.s); + + Assert.AreEqual(0.0, check.x, VECTOR_COMPONENT_ACCURACY, "TestllRot2Euler X bounds check fail"); + Assert.AreEqual(0.0, check.y, VECTOR_COMPONENT_ACCURACY, "TestllRot2Euler Y bounds check fail"); + Assert.AreEqual(0.0, check.z, VECTOR_COMPONENT_ACCURACY, "TestllRot2Euler Z bounds check fail"); } [Test] -- cgit v1.1 From 8c445dac6778aa2fcfc42736a563e8de101bd817 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 6 Jan 2012 21:12:22 +0000 Subject: Add script instruction count back to llRot2Euler. Other minor formatting/doc changes. --- .../Shared/Api/Implementation/LSL_Api.cs | 14 +++++++-- .../ScriptEngine/Shared/Tests/LSL_ApiTest.cs | 34 +++++++++++++--------- 2 files changed, 32 insertions(+), 16 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index d6316b2..a35e75f 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -468,10 +468,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api //Now we start getting into quaternions which means sin/cos, matrices and vectors. ckrinke - // Using algorithm based off http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToEuler/quat_2_euler_paper_ver2-1.pdf - // to avoid issues with singularity and rounding with Y rotation of +/- PI/2 + /// + /// Convert an LSL rotation to a Euler vector. + /// + /// + /// Using algorithm based off http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToEuler/quat_2_euler_paper_ver2-1.pdf + /// to avoid issues with singularity and rounding with Y rotation of +/- PI/2 + /// + /// + /// public LSL_Vector llRot2Euler(LSL_Rotation r) { + m_host.AddScriptLPS(1); + LSL_Vector v = new LSL_Vector(0.0, 0.0, 1.0) * r; // Z axis unit vector unaffected by Z rotation component of r. double m = LSL_Vector.Mag(v); // Just in case v isn't normalized, need magnitude for Asin() operation later. if (m == 0.0) return new LSL_Vector(); @@ -482,6 +491,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // Rotate X axis unit vector by r and unwind the X and Y rotations leaving only the Z rotation v = new LSL_Vector(1.0, 0.0, 0.0) * ((r * new LSL_Rotation(Math.Sin(-x / 2.0), 0.0, 0.0, Math.Cos(-x / 2.0))) * new LSL_Rotation(0.0, Math.Sin(-y / 2.0), 0.0, Math.Cos(-y / 2.0))); double z = Math.Atan2(v.y, v.x); + return new LSL_Vector(x, y, z); } diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs index 7594691..99c1cf4 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs @@ -201,20 +201,26 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests CheckllRot2Euler(new LSL_Types.Quaternion(-0.092302, -0.701059, -0.092302, -0.701059)); } - // Testing Rot2Euler this way instead of comparing against expected angles because - // 1. There are several ways to get to the original Quaternion. For example a rotation - // of PI and -PI will give the same result. But PI and -PI aren't equal. - // 2. This method checks to see if the calculated angles from a quaternion can be used - // to create a new quaternion to produce the same rotation. - // However, can't compare the newly calculated quaternion against the original because - // once again, there are multiple quaternions that give the same result. For instance - // == <-X, -Y, -Z, -S>. Additionally, the magnitude of S can be changed - // and will still result in the same rotation if the values for X, Y, Z are also changed - // to compensate. - // However, if two quaternions represent the same rotation, then multiplying the first - // quaternion by the conjugate of the second, will give a third quaternion representing - // a zero rotation. This can be tested for by looking at the X, Y, Z values which should - // be zero. + /// + /// Check an llRot2Euler conversion. + /// + /// + /// Testing Rot2Euler this way instead of comparing against expected angles because + /// 1. There are several ways to get to the original Quaternion. For example a rotation + /// of PI and -PI will give the same result. But PI and -PI aren't equal. + /// 2. This method checks to see if the calculated angles from a quaternion can be used + /// to create a new quaternion to produce the same rotation. + /// However, can't compare the newly calculated quaternion against the original because + /// once again, there are multiple quaternions that give the same result. For instance + /// == <-X, -Y, -Z, -S>. Additionally, the magnitude of S can be changed + /// and will still result in the same rotation if the values for X, Y, Z are also changed + /// to compensate. + /// However, if two quaternions represent the same rotation, then multiplying the first + /// quaternion by the conjugate of the second, will give a third quaternion representing + /// a zero rotation. This can be tested for by looking at the X, Y, Z values which should + /// be zero. + /// + /// private void CheckllRot2Euler(LSL_Types.Quaternion rot) { // Call LSL function to convert quaternion rotaion to euler radians. -- cgit v1.1 From ff5a83d192105e4674cff261b13a447ff0d1e478 Mon Sep 17 00:00:00 2001 From: John Cochran Date: Thu, 5 Jan 2012 07:37:08 -0600 Subject: Fixed llAngleBetween() to allow denormal rotations --- .../Shared/Api/Implementation/LSL_Api.cs | 14 ++++--- .../ScriptEngine/Shared/Tests/LSL_ApiTest.cs | 47 +++++++++++++++------- 2 files changed, 41 insertions(+), 20 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index a35e75f..d6de39f 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -4698,15 +4698,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return (double)Math.Asin(val); } - // Xantor 30/apr/2008 + // jcochran 5/jan/2012 public LSL_Float llAngleBetween(LSL_Rotation a, LSL_Rotation b) { m_host.AddScriptLPS(1); - double angle = Math.Acos(a.x * b.x + a.y * b.y + a.z * b.z + a.s * b.s) * 2; - if (angle < 0) angle = -angle; - if (angle > Math.PI) return (Math.PI * 2 - angle); - return angle; + double aa = (a.x * a.x + a.y * a.y + a.z * a.z + a.s * a.s); + double bb = (b.x * b.x + b.y * b.y + b.z * b.z + b.s * b.s); + double aa_bb = aa * bb; + if (aa_bb == 0) return 0.0; + double ab = (a.x * b.x + a.y * b.y + a.z * b.z + a.s * b.s); + double quotient = (ab * ab) / aa_bb; + if (quotient >= 1.0) return 0.0; + return Math.Acos(2 * quotient - 1); } public LSL_String llGetInventoryKey(string name) diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs index 99c1cf4..3baa723 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs @@ -75,32 +75,49 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests [Test] public void TestllAngleBetween() { - CheckllAngleBetween(new Vector3(1, 0, 0), 0); - CheckllAngleBetween(new Vector3(1, 0, 0), 90); - CheckllAngleBetween(new Vector3(1, 0, 0), 180); + CheckllAngleBetween(new Vector3(1, 0, 0), 0, 1, 1); + CheckllAngleBetween(new Vector3(1, 0, 0), 90, 1, 1); + CheckllAngleBetween(new Vector3(1, 0, 0), 180, 1, 1); - CheckllAngleBetween(new Vector3(0, 1, 0), 0); - CheckllAngleBetween(new Vector3(0, 1, 0), 90); - CheckllAngleBetween(new Vector3(0, 1, 0), 180); + CheckllAngleBetween(new Vector3(0, 1, 0), 0, 1, 1); + CheckllAngleBetween(new Vector3(0, 1, 0), 90, 1, 1); + CheckllAngleBetween(new Vector3(0, 1, 0), 180, 1, 1); - CheckllAngleBetween(new Vector3(0, 0, 1), 0); - CheckllAngleBetween(new Vector3(0, 0, 1), 90); - CheckllAngleBetween(new Vector3(0, 0, 1), 180); + CheckllAngleBetween(new Vector3(0, 0, 1), 0, 1, 1); + CheckllAngleBetween(new Vector3(0, 0, 1), 90, 1, 1); + CheckllAngleBetween(new Vector3(0, 0, 1), 180, 1, 1); - CheckllAngleBetween(new Vector3(1, 1, 1), 0); - CheckllAngleBetween(new Vector3(1, 1, 1), 90); - CheckllAngleBetween(new Vector3(1, 1, 1), 180); + CheckllAngleBetween(new Vector3(1, 1, 1), 0, 1, 1); + CheckllAngleBetween(new Vector3(1, 1, 1), 90, 1, 1); + CheckllAngleBetween(new Vector3(1, 1, 1), 180, 1, 1); + + CheckllAngleBetween(new Vector3(1, 0, 0), 0, 1.6f, 1.8f); + CheckllAngleBetween(new Vector3(1, 0, 0), 90, 0.3f, 3.9f); + CheckllAngleBetween(new Vector3(1, 0, 0), 180, 8.8f, 7.4f); + + CheckllAngleBetween(new Vector3(0, 1, 0), 0, 9.8f, -9.4f); + CheckllAngleBetween(new Vector3(0, 1, 0), 90, 8.4f, -8.2f); + CheckllAngleBetween(new Vector3(0, 1, 0), 180, 0.4f, -5.8f); + + CheckllAngleBetween(new Vector3(0, 0, 1), 0, -6.8f, 3.4f); + CheckllAngleBetween(new Vector3(0, 0, 1), 90, -3.6f, 5.6f); + CheckllAngleBetween(new Vector3(0, 0, 1), 180, -3.8f, 1.1f); + + CheckllAngleBetween(new Vector3(1, 1, 1), 0, -7.7f, -2.0f); + CheckllAngleBetween(new Vector3(1, 1, 1), 90, -3.0f, -9.1f); + CheckllAngleBetween(new Vector3(1, 1, 1), 180, -7.9f, -8.0f); } - private void CheckllAngleBetween(Vector3 axis,float originalAngle) + private void CheckllAngleBetween(Vector3 axis,float originalAngle, float denorm1, float denorm2) { Quaternion rotation1 = Quaternion.CreateFromAxisAngle(axis, 0); Quaternion rotation2 = Quaternion.CreateFromAxisAngle(axis, ToRadians(originalAngle)); + rotation1 *= denorm1; + rotation2 *= denorm2; double deducedAngle = FromLslFloat(m_lslApi.llAngleBetween(ToLslQuaternion(rotation2), ToLslQuaternion(rotation1))); - Assert.Greater(deducedAngle, ToRadians(originalAngle) - ANGLE_ACCURACY_IN_RADIANS); - Assert.Less(deducedAngle, ToRadians(originalAngle) + ANGLE_ACCURACY_IN_RADIANS); + Assert.That(deducedAngle, Is.EqualTo(ToRadians(originalAngle)).Within(ANGLE_ACCURACY_IN_RADIANS), "TestllAngleBetween check fail"); } #region Conversions to and from LSL_Types -- cgit v1.1 From 3073370d0e1b2bca2f8b61d03824e8d39b674b04 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 6 Jan 2012 22:29:27 +0000 Subject: Allow RemoteAdmin to deal with all the different kinds of region id parameter that have been used in different methods. See http://opensimulator.org/mantis/view.php?id=5814 Thanks Michelle Argus! --- .../RemoteController/RemoteAdminPlugin.cs | 406 ++++++++++----------- 1 file changed, 191 insertions(+), 215 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs index 7106e6a..7f1a0ed 100644 --- a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs +++ b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs @@ -257,17 +257,13 @@ namespace OpenSim.ApplicationPlugins.RemoteController { m_log.Info("[RADMIN]: Request to restart Region."); - CheckStringParameters(requestData, responseData, new string[] {"regionID"}); + CheckRegionParams(requestData, responseData); - UUID regionID = new UUID((string) requestData["regionID"]); - - Scene rebootedScene; + Scene rebootedScene = null; + GetSceneFromRegionParams(requestData, responseData, out rebootedScene); responseData["success"] = false; responseData["accepted"] = true; - if (!m_application.SceneManager.TryGetScene(regionID, out rebootedScene)) - throw new Exception("region not found"); - responseData["rebooting"] = true; IRestartModule restartModule = rebootedScene.RequestModuleInterface(); @@ -329,14 +325,15 @@ namespace OpenSim.ApplicationPlugins.RemoteController // } CheckStringParameters(requestData, responseData, new string[] {"filename", "regionid"}); + CheckRegionParams(requestData, responseData); - string file = (string) requestData["filename"]; - UUID regionID = (UUID) (string) requestData["regionid"]; - m_log.InfoFormat("[RADMIN]: Terrain Loading: {0}", file); + Scene scene = null; + GetSceneFromRegionParams(requestData, responseData, out scene); + string file = (string)requestData["filename"]; responseData["accepted"] = true; - LoadHeightmap(file, regionID); + LoadHeightmap(file, scene.RegionInfo.RegionID); responseData["success"] = true; @@ -353,18 +350,16 @@ namespace OpenSim.ApplicationPlugins.RemoteController // m_log.DebugFormat("[RADMIN]: Save Terrain: XmlRpc {0}", request.ToString()); CheckStringParameters(requestData, responseData, new string[] { "filename", "regionid" }); + CheckRegionParams(requestData, responseData); + + Scene region = null; + GetSceneFromRegionParams(requestData, responseData, out region); string file = (string)requestData["filename"]; - UUID regionID = (UUID)(string)requestData["regionid"]; m_log.InfoFormat("[RADMIN]: Terrain Saving: {0}", file); responseData["accepted"] = true; - Scene region = null; - - if (!m_application.SceneManager.TryGetScene(regionID, out region)) - throw new Exception("1: unable to get a scene with that name"); - ITerrainModule terrainModule = region.RequestModuleInterface(); if (null == terrainModule) throw new Exception("terrain module not available"); @@ -732,7 +727,8 @@ namespace OpenSim.ApplicationPlugins.RemoteController responseData["success"] = true; responseData["region_name"] = region.RegionName; - responseData["region_uuid"] = region.RegionID.ToString(); + responseData["region_id"] = region.RegionID.ToString(); + responseData["region_uuid"] = region.RegionID.ToString(); //Deprecate July 2012 m_log.Info("[RADMIN]: CreateRegion: request complete"); } @@ -774,16 +770,16 @@ namespace OpenSim.ApplicationPlugins.RemoteController lock (m_requestLock) { CheckStringParameters(requestData, responseData, new string[] {"region_name"}); + CheckRegionParams(requestData, responseData); Scene scene = null; - string regionName = (string) requestData["region_name"]; - if (!m_application.SceneManager.TryGetScene(regionName, out scene)) - throw new Exception(String.Format("region \"{0}\" does not exist", regionName)); + GetSceneFromRegionParams(requestData, responseData, out scene); m_application.RemoveRegion(scene, true); responseData["success"] = true; - responseData["region_name"] = regionName; + responseData["region_name"] = scene.RegionInfo.RegionName; + responseData["region_id"] = scene.RegionInfo.RegionID; m_log.Info("[RADMIN]: DeleteRegion: request complete"); } @@ -823,44 +819,21 @@ namespace OpenSim.ApplicationPlugins.RemoteController Hashtable responseData = (Hashtable)response.Value; Hashtable requestData = (Hashtable)request.Params[0]; - Scene scene = null; lock (m_requestLock) { - if (requestData.ContainsKey("region_id") && - !String.IsNullOrEmpty((string) requestData["region_id"])) - { - // Region specified by UUID - UUID regionID = (UUID) (string) requestData["region_id"]; - if (!m_application.SceneManager.TryGetScene(regionID, out scene)) - throw new Exception(String.Format("region \"{0}\" does not exist", regionID)); - - m_application.CloseRegion(scene); + CheckRegionParams(requestData, responseData); - responseData["success"] = true; - responseData["region_id"] = regionID; - - response.Value = responseData; - } - else if ( - requestData.ContainsKey("region_name") - && !String.IsNullOrEmpty((string) requestData["region_name"])) - { - // Region specified by name + Scene scene = null; + GetSceneFromRegionParams(requestData, responseData, out scene); - string regionName = (string) requestData["region_name"]; - if (!m_application.SceneManager.TryGetScene(regionName, out scene)) - throw new Exception(String.Format("region \"{0}\" does not exist", regionName)); + m_application.CloseRegion(scene); - m_application.CloseRegion(scene); + responseData["success"] = true; + responseData["region_name"] = scene.RegionInfo.RegionName; + responseData["region_id"] = scene.RegionInfo.RegionID; - responseData["success"] = true; - responseData["region_name"] = regionName; - } - else - { - throw new Exception("no region specified"); - } + response.Value = responseData; m_log.Info("[RADMIN]: CloseRegion: request complete"); } @@ -907,12 +880,10 @@ namespace OpenSim.ApplicationPlugins.RemoteController lock (m_requestLock) { - CheckStringParameters(requestData, responseData, new string[] {"region_name"}); + CheckRegionParams(requestData, responseData); Scene scene = null; - string regionName = (string) requestData["region_name"]; - if (!m_application.SceneManager.TryGetScene(regionName, out scene)) - throw new Exception(String.Format("region \"{0}\" does not exist", regionName)); + GetSceneFromRegionParams(requestData, responseData, out scene); // Modify access scene.RegionInfo.EstateSettings.PublicAccess = @@ -942,7 +913,8 @@ namespace OpenSim.ApplicationPlugins.RemoteController } responseData["success"] = true; - responseData["region_name"] = regionName; + responseData["region_name"] = scene.RegionInfo.RegionName; + responseData["region_id"] = scene.RegionInfo.RegionID; m_log.Info("[RADMIN]: ModifyRegion: request complete"); } @@ -1338,22 +1310,12 @@ namespace OpenSim.ApplicationPlugins.RemoteController try { CheckStringParameters(requestData, responseData, new string[] {"filename"}); + CheckRegionParams(requestData, responseData); - string filename = (string) requestData["filename"]; Scene scene = null; - if (requestData.Contains("region_uuid")) - { - UUID region_uuid = (UUID) (string) requestData["region_uuid"]; - if (!m_application.SceneManager.TryGetScene(region_uuid, out scene)) - throw new Exception(String.Format("failed to switch to region {0}", region_uuid.ToString())); - } - else if (requestData.Contains("region_name")) - { - string region_name = (string) requestData["region_name"]; - if (!m_application.SceneManager.TryGetScene(region_name, out scene)) - throw new Exception(String.Format("failed to switch to region {0}", region_name)); - } - else throw new Exception("neither region_name nor region_uuid given"); + GetSceneFromRegionParams(requestData, responseData, out scene); + + string filename = (string) requestData["filename"]; bool mergeOar = false; bool skipAssets = false; @@ -1434,22 +1396,12 @@ namespace OpenSim.ApplicationPlugins.RemoteController try { CheckStringParameters(requestData, responseData, new string[] {"filename"}); + CheckRegionParams(requestData, responseData); - string filename = (string)requestData["filename"]; Scene scene = null; - if (requestData.Contains("region_uuid")) - { - UUID region_uuid = (UUID) (string) requestData["region_uuid"]; - if (!m_application.SceneManager.TryGetScene(region_uuid, out scene)) - throw new Exception(String.Format("failed to switch to region {0}", region_uuid.ToString())); - } - else if (requestData.Contains("region_name")) - { - string region_name = (string) requestData["region_name"]; - if (!m_application.SceneManager.TryGetScene(region_name, out scene)) - throw new Exception(String.Format("failed to switch to region {0}", region_name)); - } - else throw new Exception("neither region_name nor region_uuid given"); + GetSceneFromRegionParams(requestData, responseData, out scene); + + string filename = (string)requestData["filename"]; Dictionary options = new Dictionary(); @@ -1521,25 +1473,12 @@ namespace OpenSim.ApplicationPlugins.RemoteController try { CheckStringParameters(requestData, responseData, new string[] {"filename"}); + CheckRegionParams(requestData, responseData); - string filename = (string) requestData["filename"]; - if (requestData.Contains("region_uuid")) - { - UUID region_uuid = (UUID) (string) requestData["region_uuid"]; - if (!m_application.SceneManager.TrySetCurrentScene(region_uuid)) - throw new Exception(String.Format("failed to switch to region {0}", region_uuid.ToString())); - - m_log.InfoFormat("[RADMIN]: Switched to region {0}", region_uuid.ToString()); - } - else if (requestData.Contains("region_name")) - { - string region_name = (string) requestData["region_name"]; - if (!m_application.SceneManager.TrySetCurrentScene(region_name)) - throw new Exception(String.Format("failed to switch to region {0}", region_name)); + Scene scene = null; + GetSceneFromRegionParams(requestData, responseData, out scene); - m_log.InfoFormat("[RADMIN]: Switched to region {0}", region_name); - } - else throw new Exception("neither region_name nor region_uuid given"); + string filename = (string) requestData["filename"]; responseData["switched"] = true; @@ -1587,23 +1526,12 @@ namespace OpenSim.ApplicationPlugins.RemoteController try { CheckStringParameters(requestData, responseData, new string[] {"filename"}); + CheckRegionParams(requestData, responseData); + + Scene scene = null; + GetSceneFromRegionParams(requestData, responseData, out scene); string filename = (string) requestData["filename"]; - if (requestData.Contains("region_uuid")) - { - UUID region_uuid = (UUID) (string) requestData["region_uuid"]; - if (!m_application.SceneManager.TrySetCurrentScene(region_uuid)) - throw new Exception(String.Format("failed to switch to region {0}", region_uuid.ToString())); - m_log.InfoFormat("[RADMIN]: Switched to region {0}", region_uuid.ToString()); - } - else if (requestData.Contains("region_name")) - { - string region_name = (string) requestData["region_name"]; - if (!m_application.SceneManager.TrySetCurrentScene(region_name)) - throw new Exception(String.Format("failed to switch to region {0}", region_name)); - m_log.InfoFormat("[RADMIN]: Switched to region {0}", region_name); - } - else throw new Exception("neither region_name nor region_uuid given"); responseData["switched"] = true; @@ -1647,33 +1575,15 @@ namespace OpenSim.ApplicationPlugins.RemoteController Hashtable responseData = (Hashtable)response.Value; Hashtable requestData = (Hashtable)request.Params[0]; - responseData["success"] = true; - - if (requestData.Contains("region_uuid")) - { - UUID region_uuid = (UUID) (string) requestData["region_uuid"]; - if (!m_application.SceneManager.TrySetCurrentScene(region_uuid)) - throw new Exception(String.Format("failed to switch to region {0}", region_uuid.ToString())); - - m_log.InfoFormat("[RADMIN]: Switched to region {0}", region_uuid.ToString()); - } - else if (requestData.Contains("region_name")) - { - string region_name = (string) requestData["region_name"]; - if (!m_application.SceneManager.TrySetCurrentScene(region_name)) - throw new Exception(String.Format("failed to switch to region {0}", region_name)); + CheckRegionParams(requestData, responseData); - m_log.InfoFormat("[RADMIN]: Switched to region {0}", region_name); - } - else - { - throw new Exception("neither region_name nor region_uuid given"); - } + Scene scene = null; + GetSceneFromRegionParams(requestData, responseData, out scene); - Scene scene = m_application.SceneManager.CurrentScene; int health = scene.GetHealth(); responseData["health"] = health; + responseData["success"] = true; m_log.Info("[RADMIN]: Query XML Administrator Request complete"); } @@ -1700,24 +1610,11 @@ namespace OpenSim.ApplicationPlugins.RemoteController responseData["success"] = true; - if (requestData.Contains("region_uuid")) - { - UUID region_uuid = (UUID) (string) requestData["region_uuid"]; - if (!m_application.SceneManager.TrySetCurrentScene(region_uuid)) - throw new Exception(String.Format("failed to switch to region {0}", region_uuid.ToString())); - m_log.InfoFormat("[RADMIN]: Switched to region {0}", region_uuid.ToString()); - } - else if (requestData.Contains("region_name")) - { - string region_name = (string) requestData["region_name"]; - if (!m_application.SceneManager.TrySetCurrentScene(region_name)) - throw new Exception(String.Format("failed to switch to region {0}", region_name)); + CheckRegionParams(requestData, responseData); - m_log.InfoFormat("[RADMIN]: Switched to region {0}", region_name); - } - else throw new Exception("neither region_name nor region_uuid given"); + Scene scene = null; + GetSceneFromRegionParams(requestData, responseData, out scene); - Scene scene = m_application.SceneManager.CurrentScene; scene.RegionInfo.EstateSettings.EstateAccess = new UUID[]{}; if (scene.RegionInfo.Persistent) @@ -1733,32 +1630,17 @@ namespace OpenSim.ApplicationPlugins.RemoteController Hashtable responseData = (Hashtable)response.Value; Hashtable requestData = (Hashtable)request.Params[0]; - if (requestData.Contains("region_uuid")) - { - UUID region_uuid = (UUID) (string) requestData["region_uuid"]; - if (!m_application.SceneManager.TrySetCurrentScene(region_uuid)) - throw new Exception(String.Format("failed to switch to region {0}", region_uuid.ToString())); - m_log.InfoFormat("[RADMIN]: Switched to region {0}", region_uuid.ToString()); - } - else if (requestData.Contains("region_name")) - { - string region_name = (string) requestData["region_name"]; - if (!m_application.SceneManager.TrySetCurrentScene(region_name)) - throw new Exception(String.Format("failed to switch to region {0}", region_name)); - m_log.InfoFormat("[RADMIN]: Switched to region {0}", region_name); - } - else - { - throw new Exception("neither region_name nor region_uuid given"); - } + CheckRegionParams(requestData, responseData); + + Scene scene = null; + GetSceneFromRegionParams(requestData, responseData, out scene); int addedUsers = 0; if (requestData.Contains("users")) { - UUID scopeID = m_application.SceneManager.CurrentOrFirstScene.RegionInfo.ScopeID; - IUserAccountService userService = m_application.SceneManager.CurrentOrFirstScene.UserAccountService; - Scene scene = m_application.SceneManager.CurrentScene; + UUID scopeID = scene.RegionInfo.ScopeID; + IUserAccountService userService = scene.UserAccountService; Hashtable users = (Hashtable) requestData["users"]; List uuids = new List(); foreach (string name in users.Values) @@ -1797,32 +1679,18 @@ namespace OpenSim.ApplicationPlugins.RemoteController Hashtable responseData = (Hashtable)response.Value; Hashtable requestData = (Hashtable)request.Params[0]; - responseData["success"] = true; + CheckRegionParams(requestData, responseData); - if (requestData.Contains("region_uuid")) - { - UUID region_uuid = (UUID) (string) requestData["region_uuid"]; - if (!m_application.SceneManager.TrySetCurrentScene(region_uuid)) - throw new Exception(String.Format("failed to switch to region {0}", region_uuid.ToString())); - m_log.InfoFormat("[RADMIN]: Switched to region {0}", region_uuid.ToString()); - } - else if (requestData.Contains("region_name")) - { - string region_name = (string) requestData["region_name"]; - if (!m_application.SceneManager.TrySetCurrentScene(region_name)) - throw new Exception(String.Format("failed to switch to region {0}", region_name)); - m_log.InfoFormat("[RADMIN]: Switched to region {0}", region_name); - } - else throw new Exception("neither region_name nor region_uuid given"); + Scene scene = null; + GetSceneFromRegionParams(requestData, responseData, out scene); int removedUsers = 0; if (requestData.Contains("users")) { - UUID scopeID = m_application.SceneManager.CurrentOrFirstScene.RegionInfo.ScopeID; - IUserAccountService userService = m_application.SceneManager.CurrentOrFirstScene.UserAccountService; + UUID scopeID = scene.RegionInfo.ScopeID; + IUserAccountService userService = scene.UserAccountService; //UserProfileCacheService ups = m_application.CommunicationsManager.UserProfileCacheService; - Scene scene = m_application.SceneManager.CurrentScene; Hashtable users = (Hashtable) requestData["users"]; List uuids = new List(); foreach (string name in users.Values) @@ -1849,6 +1717,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController } responseData["removed"] = removedUsers; + responseData["success"] = true; m_log.Info("[RADMIN]: Access List Remove Request complete"); } @@ -1860,32 +1729,18 @@ namespace OpenSim.ApplicationPlugins.RemoteController Hashtable responseData = (Hashtable)response.Value; Hashtable requestData = (Hashtable)request.Params[0]; - responseData["success"] = true; + CheckRegionParams(requestData, responseData); - if (requestData.Contains("region_uuid")) - { - UUID region_uuid = (UUID) (string) requestData["region_uuid"]; - if (!m_application.SceneManager.TrySetCurrentScene(region_uuid)) - throw new Exception(String.Format("failed to switch to region {0}", region_uuid.ToString())); - m_log.InfoFormat("[RADMIN]: Switched to region {0}", region_uuid.ToString()); - } - else if (requestData.Contains("region_name")) - { - string region_name = (string) requestData["region_name"]; - if (!m_application.SceneManager.TrySetCurrentScene(region_name)) - throw new Exception(String.Format("failed to switch to region {0}", region_name)); - m_log.InfoFormat("[RADMIN]: Switched to region {0}", region_name); - } - else throw new Exception("neither region_name nor region_uuid given"); + Scene scene = null; + GetSceneFromRegionParams(requestData, responseData, out scene); - Scene scene = m_application.SceneManager.CurrentScene; UUID[] accessControlList = scene.RegionInfo.EstateSettings.EstateAccess; Hashtable users = new Hashtable(); foreach (UUID user in accessControlList) { - UUID scopeID = m_application.SceneManager.CurrentOrFirstScene.RegionInfo.ScopeID; - UserAccount account = m_application.SceneManager.CurrentOrFirstScene.UserAccountService.GetUserAccount(scopeID, user); + UUID scopeID = scene.RegionInfo.ScopeID; + UserAccount account = scene.UserAccountService.GetUserAccount(scopeID, user); if (account != null) { users[user.ToString()] = account.FirstName + " " + account.LastName; @@ -1893,6 +1748,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController } responseData["users"] = users; + responseData["success"] = true; m_log.Info("[RADMIN]: Access List List Request complete"); } @@ -2010,6 +1866,126 @@ namespace OpenSim.ApplicationPlugins.RemoteController } } + private void CheckRegionParams(Hashtable requestData, Hashtable responseData) + { + //Checks if region parameters exist and gives exeption if no parameters are given + if ((requestData.ContainsKey("region_id") && !String.IsNullOrEmpty((string)requestData["region_id"])) || + (requestData.ContainsKey("region_name") && !String.IsNullOrEmpty((string)requestData["region_name"]))) + { + return; + } + #region Deprecate July 2012 + //region_ID, regionid, region_uuid will be deprecated in July 2012!!!!!! + else if (requestData.ContainsKey("regionid") && + !String.IsNullOrEmpty((string)requestData["regionid"])) + { + m_log.WarnFormat("[RADMIN]: Use of parameter regionid will be deprecated as of July 2012. Use region_id instead"); + } + else if (requestData.ContainsKey("region_ID") && + !String.IsNullOrEmpty((string)requestData["region_ID"])) + { + m_log.WarnFormat("[RADMIN]: Use of parameter region_ID will be deprecated as of July 2012. Use region_id instead"); + } + else if (requestData.ContainsKey("regionID") && + !String.IsNullOrEmpty((string)requestData["regionID"])) + { + m_log.WarnFormat("[RADMIN]: Use of parameter regionID will be deprecated as of July 2012. Use region_id instead"); + } + else if (requestData.ContainsKey("region_uuid") && + !String.IsNullOrEmpty((string)requestData["region_uuid"])) + { + m_log.WarnFormat("[RADMIN]: Use of parameter region_uuid will be deprecated as of July 2012. Use region_id instead"); + } + #endregion + else + { + responseData["accepted"] = false; + throw new Exception("no region_name or region_id given"); + } + } + + private void GetSceneFromRegionParams(Hashtable requestData, Hashtable responseData, out Scene scene) + { + scene = null; + + if (requestData.ContainsKey("region_id") && + !String.IsNullOrEmpty((string)requestData["region_id"])) + { + UUID regionID = (UUID)(string)requestData["region_id"]; + if (!m_application.SceneManager.TryGetScene(regionID, out scene)) + { + responseData["error"] = String.Format("Region ID {0} not found", regionID); + throw new Exception(String.Format("Region ID {0} not found", regionID)); + } + } + #region Deprecate July 2012 + else if (requestData.ContainsKey("regionid") && + !String.IsNullOrEmpty((string)requestData["regionid"])) + { + m_log.WarnFormat("[RADMIN]: Use of parameter regionid will be deprecated as of July 2012. Use region_id instead"); + + UUID regionID = (UUID)(string)requestData["regionid"]; + if (!m_application.SceneManager.TryGetScene(regionID, out scene)) + { + responseData["error"] = String.Format("Region ID {0} not found", regionID); + throw new Exception(String.Format("Region ID {0} not found", regionID)); + } + } + else if (requestData.ContainsKey("region_ID") && + !String.IsNullOrEmpty((string)requestData["region_ID"])) + { + m_log.WarnFormat("[RADMIN]: Use of parameter region_ID will be deprecated as of July 2012. Use region_id instead"); + + UUID regionID = (UUID)(string)requestData["region_ID"]; + if (!m_application.SceneManager.TryGetScene(regionID, out scene)) + { + responseData["error"] = String.Format("Region ID {0} not found", regionID); + throw new Exception(String.Format("Region ID {0} not found", regionID)); + } + } + else if (requestData.ContainsKey("regionID") && + !String.IsNullOrEmpty((string)requestData["regionID"])) + { + m_log.WarnFormat("[RADMIN]: Use of parameter regionID will be deprecated as of July 2012. Use region_id instead"); + + UUID regionID = (UUID)(string)requestData["regionID"]; + if (!m_application.SceneManager.TryGetScene(regionID, out scene)) + { + responseData["error"] = String.Format("Region ID {0} not found", regionID); + throw new Exception(String.Format("Region ID {0} not found", regionID)); + } + } + else if (requestData.ContainsKey("region_uuid") && + !String.IsNullOrEmpty((string)requestData["region_uuid"])) + { + m_log.WarnFormat("[RADMIN]: Use of parameter region_uuid will be deprecated as of July 2012. Use region_id instead"); + + UUID regionID = (UUID)(string)requestData["region_uuid"]; + if (!m_application.SceneManager.TryGetScene(regionID, out scene)) + { + responseData["error"] = String.Format("Region ID {0} not found", regionID); + throw new Exception(String.Format("Region ID {0} not found", regionID)); + } + } + #endregion + else if (requestData.ContainsKey("region_name") && + !String.IsNullOrEmpty((string)requestData["region_name"])) + { + string regionName = (string)requestData["region_name"]; + if (!m_application.SceneManager.TryGetScene(regionName, out scene)) + { + responseData["error"] = String.Format("Region {0} not found", regionName); + throw new Exception(String.Format("Region {0} not found", regionName)); + } + } + else + { + responseData["error"] = "no region_name or region_id given"; + throw new Exception("no region_name or region_id given"); + } + return; + } + private bool GetBoolean(Hashtable requestData, string tag, bool defaultValue) { // If an access value has been provided, apply it. -- cgit v1.1 From 7518b075b76fea062971a9e5fb716118130ebe43 Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 6 Jan 2012 22:35:06 +0000 Subject: Add osNpcCreateOwned to create an owned NPC. Those can be sensed only by the owner, can be destroyed only by the owner and only the owner can save their appearance. Added "NPC" as a flag to llSensor to sense NPCs and exclude them from "AGENT" results. --- OpenSim/Region/Framework/Interfaces/INPCModule.cs | 13 +++++++--- .../Region/OptionalModules/World/NPC/NPCAvatar.cs | 9 ++++++- .../Region/OptionalModules/World/NPC/NPCModule.cs | 28 ++++++++++++++++++---- .../World/NPC/Tests/NPCModuleTests.cs | 10 ++++---- .../Shared/Api/Implementation/OSSL_Api.cs | 25 +++++++++++++++---- .../Api/Implementation/Plugins/SensorRepeat.cs | 20 +++++++++++++++- .../ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | 1 + .../Shared/Api/Runtime/LSL_Constants.cs | 1 + .../ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | 7 +++++- 9 files changed, 94 insertions(+), 20 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Interfaces/INPCModule.cs b/OpenSim/Region/Framework/Interfaces/INPCModule.cs index b65f82c..cac8479 100644 --- a/OpenSim/Region/Framework/Interfaces/INPCModule.cs +++ b/OpenSim/Region/Framework/Interfaces/INPCModule.cs @@ -42,7 +42,7 @@ namespace OpenSim.Region.Framework.Interfaces /// /// The avatar appearance to use for the new NPC. /// The UUID of the ScenePresence created. - UUID CreateNPC(string firstname, string lastname, Vector3 position, Scene scene, AvatarAppearance appearance); + UUID CreateNPC(string firstname, string lastname, Vector3 position, UUID owner, Scene scene, AvatarAppearance appearance); /// /// Check if the agent is an NPC. @@ -117,6 +117,13 @@ namespace OpenSim.Region.Framework.Interfaces /// The UUID of the NPC /// /// True if the operation succeeded, false if there was no such agent or the agent was not an NPC - bool DeleteNPC(UUID agentID, Scene scene); + bool DeleteNPC(UUID agentID, UUID CallerID, Scene scene); + + /// + /// Get the owner of a NPC + /// + /// The UUID of the NPC + /// UUID of owner if the NPC exists, UUID.Zero if there was no such agent, the agent is unowned or the agent was not an NPC + UUID GetOwner(UUID agentID); } -} \ No newline at end of file +} diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs index 84055cc..5f4f937 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs @@ -42,13 +42,15 @@ namespace OpenSim.Region.OptionalModules.World.NPC private readonly Vector3 m_startPos; private readonly UUID m_uuid = UUID.Random(); private readonly Scene m_scene; + private readonly UUID m_ownerID; - public NPCAvatar(string firstname, string lastname, Vector3 position, Scene scene) + public NPCAvatar(string firstname, string lastname, Vector3 position, UUID ownerID, Scene scene) { m_firstname = firstname; m_lastname = lastname; m_startPos = position; m_scene = scene; + m_ownerID = ownerID; } public IScene Scene @@ -56,6 +58,11 @@ namespace OpenSim.Region.OptionalModules.World.NPC get { return m_scene; } } + public UUID OwnerID + { + get { return m_ownerID; } + } + public ISceneAgent SceneAgent { get { throw new NotImplementedException(); } } public void Say(string message) diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index 56ff367..e874417 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs @@ -91,9 +91,9 @@ namespace OpenSim.Region.OptionalModules.World.NPC } public UUID CreateNPC( - string firstname, string lastname, Vector3 position, Scene scene, AvatarAppearance appearance) + string firstname, string lastname, Vector3 position, UUID owner, Scene scene, AvatarAppearance appearance) { - NPCAvatar npcAvatar = new NPCAvatar(firstname, lastname, position, scene); + NPCAvatar npcAvatar = new NPCAvatar(firstname, lastname, position, owner, scene); npcAvatar.CircuitCode = (uint)Util.RandomClass.Next(0, int.MaxValue); m_log.DebugFormat( @@ -234,12 +234,30 @@ namespace OpenSim.Region.OptionalModules.World.NPC return false; } - public bool DeleteNPC(UUID agentID, Scene scene) + public UUID GetOwner(UUID agentID) { lock (m_avatars) { - if (m_avatars.ContainsKey(agentID)) + NPCAvatar av; + if (m_avatars.TryGetValue(agentID, out av)) { + return av.OwnerID; + } + } + + return UUID.Zero; + } + + public bool DeleteNPC(UUID agentID, UUID callerID, Scene scene) + { + lock (m_avatars) + { + NPCAvatar av; + if (m_avatars.TryGetValue(agentID, out av)) + { + if (av.OwnerID != UUID.Zero && callerID != UUID.Zero && av.OwnerID != callerID) + return false; + scene.RemoveClient(agentID, false); m_avatars.Remove(agentID); @@ -268,4 +286,4 @@ namespace OpenSim.Region.OptionalModules.World.NPC get { return true; } } } -} \ No newline at end of file +} diff --git a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs index 9c66b25..571d33d 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs @@ -109,7 +109,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests afm.SetAppearance(sp, originalTe, null); INPCModule npcModule = scene.RequestModuleInterface(); - UUID npcId = npcModule.CreateNPC("John", "Smith", new Vector3(128, 128, 30), scene, sp.Appearance); + UUID npcId = npcModule.CreateNPC("John", "Smith", new Vector3(128, 128, 30), UUID.Zero, scene, sp.Appearance); ScenePresence npc = scene.GetScenePresence(npcId); @@ -137,7 +137,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests am.RezSingleAttachmentFromInventory(sp, attItemId, (uint)AttachmentPoint.Chest); INPCModule npcModule = scene.RequestModuleInterface(); - UUID npcId = npcModule.CreateNPC("John", "Smith", new Vector3(128, 128, 30), scene, sp.Appearance); + UUID npcId = npcModule.CreateNPC("John", "Smith", new Vector3(128, 128, 30), UUID.Zero, scene, sp.Appearance); ScenePresence npc = scene.GetScenePresence(npcId); @@ -169,7 +169,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests Vector3 startPos = new Vector3(128, 128, 30); INPCModule npcModule = scene.RequestModuleInterface(); - UUID npcId = npcModule.CreateNPC("John", "Smith", startPos, scene, sp.Appearance); + UUID npcId = npcModule.CreateNPC("John", "Smith", startPos, UUID.Zero, scene, sp.Appearance); ScenePresence npc = scene.GetScenePresence(npcId); Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos)); @@ -240,7 +240,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests Vector3 startPos = new Vector3(128, 128, 30); INPCModule npcModule = scene.RequestModuleInterface(); - UUID npcId = npcModule.CreateNPC("John", "Smith", startPos, scene, sp.Appearance); + UUID npcId = npcModule.CreateNPC("John", "Smith", startPos, UUID.Zero, scene, sp.Appearance); ScenePresence npc = scene.GetScenePresence(npcId); SceneObjectPart part = SceneHelpers.AddSceneObject(scene); @@ -273,7 +273,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests Vector3 startPos = new Vector3(1, 1, 1); INPCModule npcModule = scene.RequestModuleInterface(); - UUID npcId = npcModule.CreateNPC("John", "Smith", startPos, scene, sp.Appearance); + UUID npcId = npcModule.CreateNPC("John", "Smith", startPos, UUID.Zero, scene, sp.Appearance); ScenePresence npc = scene.GetScenePresence(npcId); SceneObjectPart part = SceneHelpers.AddSceneObject(scene); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index bb0ba3d..c1a700a 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -2067,10 +2067,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return retVal; } + public LSL_Key osNpcCreateOwned(string firstname, string lastname, LSL_Vector position, string notecard) + { + CheckThreatLevel(ThreatLevel.High, "osNpcCreateOwned"); + return NpcCreate(firstname, lastname, position, notecard, true); + } + public LSL_Key osNpcCreate(string firstname, string lastname, LSL_Vector position, string notecard) { - CheckThreatLevel(ThreatLevel.High, "osNpcCreate"); + CheckThreatLevel(ThreatLevel.High, "osNpcCreated"); + return NpcCreate(firstname, lastname, position, notecard, false); + } + private LSL_Key NpcCreate(string firstname, string lastname, LSL_Vector position, string notecard, bool owned) + { INPCModule module = World.RequestModuleInterface(); if (module != null) { @@ -2099,11 +2109,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (appearance == null) return new LSL_Key(UUID.Zero.ToString()); + UUID ownerID = UUID.Zero; + if (owned) + ownerID = m_host.OwnerID; UUID x = module.CreateNPC(firstname, lastname, new Vector3((float) position.x, (float) position.y, (float) position.z), - World, - appearance); + ownerID, + World,appearance); return new LSL_Key(x.ToString()); } @@ -2132,6 +2145,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (!npcModule.IsNPC(npcId, m_host.ParentGroup.Scene)) return new LSL_Key(UUID.Zero.ToString()); + UUID ownerID = npcModule.GetOwner(npcId); + if (ownerID != UUID.Zero && ownerID != m_host.OwnerID) + return new LSL_Key(UUID.Zero.ToString()); + return SaveAppearanceToNotecard(npcId, notecard); } @@ -2311,7 +2328,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api INPCModule module = World.RequestModuleInterface(); if (module != null) { - module.DeleteNPC(new UUID(npc.m_string), World); + module.DeleteNPC(new UUID(npc.m_string), m_host.OwnerID, World); } } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs index 3eeb23d..7d7813d 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs @@ -26,10 +26,13 @@ */ using System; +using System.Reflection; using System.Collections.Generic; using OpenMetaverse; using OpenSim.Framework; +using log4net; +using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; using OpenSim.Region.ScriptEngine.Shared; using OpenSim.Region.ScriptEngine.Shared.Api; @@ -51,6 +54,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins private const int AGENT = 1; private const int AGENT_BY_USERNAME = 0x10; + private const int NPC = 0x20; private const int ACTIVE = 2; private const int PASSIVE = 4; private const int SCRIPTED = 8; @@ -203,7 +207,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins List sensedEntities = new List(); // Is the sensor type is AGENT and not SCRIPTED then include agents - if ((ts.type & (AGENT | AGENT_BY_USERNAME)) != 0 && (ts.type & SCRIPTED) == 0) + if ((ts.type & (AGENT | AGENT_BY_USERNAME | NPC)) != 0 && (ts.type & SCRIPTED) == 0) { sensedEntities.AddRange(doAgentSensor(ts)); } @@ -413,6 +417,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins private List doAgentSensor(SenseRepeatClass ts) { + INPCModule npcModule = m_CmdManager.m_ScriptEngine.World.RequestModuleInterface(); + List sensedEntities = new List(); // If nobody about quit fast @@ -441,6 +447,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins Action senseEntity = new Action(delegate(ScenePresence presence) { + if ((ts.type & NPC) == 0 && presence.PresenceType == PresenceType.Npc) + return; + if ((ts.type & AGENT) == 0 && presence.PresenceType == PresenceType.User) + return; + if (presence.IsDeleted || presence.IsChildAgent || presence.GodLevel > 0.0) return; @@ -452,6 +463,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins toRegionPos = presence.AbsolutePosition; dis = Math.Abs(Util.GetDistanceTo(toRegionPos, fromRegionPos)); + if (presence.PresenceType == PresenceType.Npc && npcModule != null) + { + UUID npcOwner = npcModule.GetOwner(presence.UUID); + if (npcOwner != UUID.Zero && npcOwner != SensePoint.OwnerID) + return; + } + // are they in range if (dis <= ts.range) { diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index f5ee733..1380ed4 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs @@ -172,6 +172,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces LSL_List osGetLinkPrimitiveParams(int linknumber, LSL_List rules); key osNpcCreate(string user, string name, vector position, string notecard); + key osNpcCreateOwned(string user, string name, vector position, string notecard); LSL_Key osNpcSaveAppearance(key npc, string notecard); void osNpcLoadAppearance(key npc, string notecard); vector osNpcGetPos(key npc); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs index fd08373..b58cf57 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs @@ -52,6 +52,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase public const int AGENT = 1; public const int AGENT_BY_LEGACY_NAME = 1; public const int AGENT_BY_USERNAME = 0x10; + public const int NPC = 0x20; public const int ACTIVE = 2; public const int PASSIVE = 4; public const int SCRIPTED = 8; diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs index 0d7d5ea..6572def 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs @@ -488,6 +488,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase return m_OSSL_Functions.osNpcCreate(user, name, position, cloneFrom); } + public key osNpcCreateOwned(string user, string name, vector position, key cloneFrom) + { + return m_OSSL_Functions.osNpcCreateOwned(user, name, position, cloneFrom); + } + public key osNpcSaveAppearance(key npc, string notecard) { return m_OSSL_Functions.osNpcSaveAppearance(npc, notecard); @@ -818,4 +823,4 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase return m_OSSL_Functions.osUnixTimeToTimestamp(time); } } -} \ No newline at end of file +} -- cgit v1.1 From 966899249327f4055c6f1492447d665eb42d09d9 Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 6 Jan 2012 22:59:08 +0000 Subject: Add osNpcPlayAnimation and osNpcStopAnimation which respect ownership as well --- .../Shared/Api/Implementation/OSSL_Api.cs | 44 ++++++++++++++++++++++ .../ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | 2 + .../ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | 10 +++++ 3 files changed, 56 insertions(+) (limited to 'OpenSim') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index c1a700a..efb77ae 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -888,6 +888,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { CheckThreatLevel(ThreatLevel.VeryHigh, "osAvatarPlayAnimation"); + AvatarPlayAnimation(avatar, animation); + } + + private void AvatarPlayAnimation(string avatar, string animation) + { UUID avatarID = (UUID)avatar; m_host.AddScriptLPS(1); @@ -921,6 +926,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { CheckThreatLevel(ThreatLevel.VeryHigh, "osAvatarStopAnimation"); + AvatarStopAnimation(avatar, animation); + } + + private void AvatarStopAnimation(string avatar, string animation) + { UUID avatarID = (UUID)avatar; m_host.AddScriptLPS(1); @@ -2332,6 +2342,40 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } } + public void osNpcPlayAnimation(LSL_Key npc, string animation) + { + CheckThreatLevel(ThreatLevel.High, "osPlayAnimation"); + + INPCModule module = World.RequestModuleInterface(); + if (module != null) + { + UUID npcID = new UUID(npc.m_string); + if (module.IsNPC(npcID)) + { + UUID ownerID = module.GetOwner(npcID); + if (ownerID == UUID.Zero || ownerID == m_host.OwnerID) + AvatarPlayAnimation(npcID.ToString(), animation); + } + } + } + + public void osNpcStopAnimation(LSL_Key npc, string animation) + { + CheckThreatLevel(ThreatLevel.High, "osNpcStopAnimation"); + + INPCModule module = World.RequestModuleInterface(); + if (module != null) + { + UUID npcID = new UUID(npc.m_string); + if (module.IsNPC(npcID)) + { + UUID ownerID = module.GetOwner(npcID); + if (ownerID == UUID.Zero || ownerID == m_host.OwnerID) + AvatarStopAnimation(npcID.ToString(), animation); + } + } + } + /// /// Save the current appearance of the script owner permanently to the named notecard. /// diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index 1380ed4..d5e085d 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs @@ -185,6 +185,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces void osNpcSit(key npc, key target, int options); void osNpcStand(LSL_Key npc); void osNpcRemove(key npc); + public void osNpcPlayAnimation(LSL_Key npc, string animation); + public void osNpcStopAnimation(LSL_Key npc, string animation); LSL_Key osOwnerSaveAppearance(string notecard); LSL_Key osAgentSaveAppearance(key agentId, string notecard); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs index 6572def..a94392a 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs @@ -553,6 +553,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase m_OSSL_Functions.osNpcRemove(npc); } + public void osNpcPlayAnimation(LSL_Key npc, string animation) + { + m_OSSL_Functions.osNpcPlayAnimation(npc, animation); + } + + public void osNpcStopAnimation(LSL_Key npc, string animation) + { + m_OSSL_Functions.osNpcStopAnimation(npc, animation); + } + public LSL_Key osOwnerSaveAppearance(string notecard) { return m_OSSL_Functions.osOwnerSaveAppearance(notecard); -- cgit v1.1 From 679d155a397567765d142e793a68679957866a6f Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 6 Jan 2012 22:33:51 +0100 Subject: Fix some syntax issues --- OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 4 ++-- OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index efb77ae..b3477ac 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -2350,7 +2350,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (module != null) { UUID npcID = new UUID(npc.m_string); - if (module.IsNPC(npcID)) + if (module.IsNPC(npcID, m_host.ParentGroup.Scene)) { UUID ownerID = module.GetOwner(npcID); if (ownerID == UUID.Zero || ownerID == m_host.OwnerID) @@ -2367,7 +2367,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (module != null) { UUID npcID = new UUID(npc.m_string); - if (module.IsNPC(npcID)) + if (module.IsNPC(npcID, m_host.ParentGroup.Scene)) { UUID ownerID = module.GetOwner(npcID); if (ownerID == UUID.Zero || ownerID == m_host.OwnerID) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index d5e085d..f92f51f 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs @@ -185,8 +185,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces void osNpcSit(key npc, key target, int options); void osNpcStand(LSL_Key npc); void osNpcRemove(key npc); - public void osNpcPlayAnimation(LSL_Key npc, string animation); - public void osNpcStopAnimation(LSL_Key npc, string animation); + void osNpcPlayAnimation(LSL_Key npc, string animation); + void osNpcStopAnimation(LSL_Key npc, string animation); LSL_Key osOwnerSaveAppearance(string notecard); LSL_Key osAgentSaveAppearance(key agentId, string notecard); -- cgit v1.1 From c5c079f6aa731ae6505299c11792f4d1d6ea3e88 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 7 Jan 2012 00:17:40 +0000 Subject: Fix bug where tapping home to stop falling would stop any avatar movement other than falling again. Addresses http://opensimulator.org/mantis/view.php?id=5839 --- .../Framework/Scenes/Animation/ScenePresenceAnimator.cs | 13 ++++++------- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 6 ++++-- 2 files changed, 10 insertions(+), 9 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs index eda085f..ff5f731 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs @@ -223,7 +223,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation m_animTickFall = 0; m_animTickJump = 0; m_jumping = false; - m_falling = true; + m_falling = false; m_jumpVelocity = 0f; actor.Selected = false; m_fallHeight = actor.Position.Z; // save latest flying height @@ -238,10 +238,8 @@ namespace OpenSim.Region.Framework.Scenes.Animation } else if (move.Z < 0f) { - if (actor != null && actor.IsColliding) - { + if (actor != null && actor.IsColliding) return "LAND"; - } else return "HOVER_DOWN"; } @@ -260,7 +258,8 @@ namespace OpenSim.Region.Framework.Scenes.Animation float fallElapsed = (float)(Environment.TickCount - m_animTickFall); float fallVelocity = (actor != null) ? actor.Velocity.Z : 0.0f; - if (!m_jumping && (fallVelocity < -3.0f) ) m_falling = true; + if (!m_jumping && (fallVelocity < -3.0f)) + m_falling = true; if (m_animTickFall == 0 || (fallVelocity >= 0.0f)) { @@ -297,9 +296,9 @@ namespace OpenSim.Region.Framework.Scenes.Animation return "PREJUMP"; } - if(m_jumping) + if (m_jumping) { - if ( (jumptime > (JUMP_PERIOD * 1.5f)) && actor.IsColliding) + if ((jumptime > (JUMP_PERIOD * 1.5f)) && actor.IsColliding) { // end jumping m_jumping = false; diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 42cd4be..8ebb7a6 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1274,8 +1274,8 @@ namespace OpenSim.Region.Framework.Scenes public void HandleAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData) { // m_log.DebugFormat( -// "[SCENE PRESENCE]: In {0} received agent update from {1}", -// Scene.RegionInfo.RegionName, remoteClient.Name); +// "[SCENE PRESENCE]: In {0} received agent update from {1}, flags {2}", +// Scene.RegionInfo.RegionName, remoteClient.Name, agentData.ControlFlags); if (IsChildAgent) { @@ -2312,6 +2312,8 @@ namespace OpenSim.Region.Framework.Scenes /// The vector in which to move. This is relative to the rotation argument public void AddNewMovement(Vector3 vec) { +// m_log.DebugFormat("[SCENE PRESENCE]: Adding new movement {0} for {1}", vec, Name); + Vector3 direc = vec * Rotation; direc.Normalize(); -- cgit v1.1 From ba163ab05b2f05bf9a316a5f209f64992d4f9a22 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 7 Jan 2012 00:29:55 +0000 Subject: Add method doc to SPA.Falling and use automatic private get property --- .../Scenes/Animation/ScenePresenceAnimator.cs | 27 +++++++++++----------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs index ff5f731..3584cda 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs @@ -61,11 +61,12 @@ namespace OpenSim.Region.Framework.Scenes.Animation public bool m_jumping = false; public float m_jumpVelocity = 0f; // private int m_landing = 0; - public bool Falling - { - get { return m_falling; } - } - private bool m_falling = false; + + /// + /// Is the avatar falling? + /// + public bool Falling { get; private set; } + private float m_fallHeight; /// @@ -223,7 +224,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation m_animTickFall = 0; m_animTickJump = 0; m_jumping = false; - m_falling = false; + Falling = false; m_jumpVelocity = 0f; actor.Selected = false; m_fallHeight = actor.Position.Z; // save latest flying height @@ -259,7 +260,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation float fallVelocity = (actor != null) ? actor.Velocity.Z : 0.0f; if (!m_jumping && (fallVelocity < -3.0f)) - m_falling = true; + Falling = true; if (m_animTickFall == 0 || (fallVelocity >= 0.0f)) { @@ -289,7 +290,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation // Start jumping, prejump m_animTickFall = 0; m_jumping = true; - m_falling = false; + Falling = false; actor.Selected = true; // borrowed for jumping flag m_animTickJump = Environment.TickCount; m_jumpVelocity = 0.35f; @@ -302,7 +303,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation { // end jumping m_jumping = false; - m_falling = false; + Falling = false; actor.Selected = false; // borrowed for jumping flag m_jumpVelocity = 0f; m_animTickFall = Environment.TickCount; @@ -329,7 +330,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation if (CurrentMovementAnimation == "FALLDOWN") { - m_falling = false; + Falling = false; m_animTickFall = Environment.TickCount; // TODO: SOFT_LAND support float fallHeight = m_fallHeight - actor.Position.Z; @@ -363,7 +364,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation if (move.X != 0f || move.Y != 0f) { m_fallHeight = actor.Position.Z; // save latest flying height - m_falling = false; + Falling = false; // Walking / crouchwalking / running if (move.Z < 0f) return "CROUCHWALK"; @@ -374,7 +375,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation } else if (!m_jumping) { - m_falling = false; + Falling = false; // Not walking if (move.Z < 0) return "CROUCH"; @@ -387,7 +388,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation } #endregion Ground Movement - m_falling = false; + Falling = false; return CurrentMovementAnimation; } -- cgit v1.1 From f4231f06283dedc4ee9e898f969700d991575558 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 7 Jan 2012 00:32:32 +0000 Subject: minor: remove mono compiler warning --- OpenSim/Services/Connectors/Hypergrid/HeloServiceConnector.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim') diff --git a/OpenSim/Services/Connectors/Hypergrid/HeloServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/HeloServiceConnector.cs index c030bca..5c50936 100644 --- a/OpenSim/Services/Connectors/Hypergrid/HeloServiceConnector.cs +++ b/OpenSim/Services/Connectors/Hypergrid/HeloServiceConnector.cs @@ -66,7 +66,7 @@ namespace OpenSim.Services.Connectors m_ServerURI = m_ServerURI.TrimEnd('/') + "/helo/"; } } - catch (UriFormatException e) + catch (UriFormatException) { m_log.WarnFormat("[HELO SERVICE]: Malformed URL {0}", serverURI); } -- cgit v1.1 From 58cb7cd084c0ccaec753d1c508ebaa4529834b24 Mon Sep 17 00:00:00 2001 From: nebadon Date: Fri, 6 Jan 2012 23:07:48 -0700 Subject: fix a typo "osNpcCreated" to "osNpcCreate" in OSSL threat level check --- OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index b3477ac..59107de 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -2085,7 +2085,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Key osNpcCreate(string firstname, string lastname, LSL_Vector position, string notecard) { - CheckThreatLevel(ThreatLevel.High, "osNpcCreated"); + CheckThreatLevel(ThreatLevel.High, "osNpcCreate"); return NpcCreate(firstname, lastname, position, notecard, false); } -- cgit v1.1 From 6f19e231b69377e312425bfae284cc8de40ce0fb Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 7 Jan 2012 12:06:21 +0100 Subject: Don't try to save a NPCs attachment states on NPC delete --- .../Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 280fdc7..2142d02 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -462,6 +462,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments /// private void UpdateKnownItem(IScenePresence sp, SceneObjectGroup grp) { + // Saving attachments for NPCs messes them up for the real owner! + INPCModule module = m_scene.RequestModuleInterface(); + if (module != null) + { + if (module.IsNPC(sp.UUID, m_scene)) + return; + } + if (grp.HasGroupChanged || grp.ContainsScripts()) { m_log.DebugFormat( -- cgit v1.1 From 32eb7ddc37d61e5615be33a8a1adfd15445f1f33 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 7 Jan 2012 12:29:59 +0100 Subject: Fix threat level setting on osNpcPlayAnimation --- OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 59107de..e2a045b 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -2344,7 +2344,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osNpcPlayAnimation(LSL_Key npc, string animation) { - CheckThreatLevel(ThreatLevel.High, "osPlayAnimation"); + CheckThreatLevel(ThreatLevel.High, "osNpcPlayAnimation"); INPCModule module = World.RequestModuleInterface(); if (module != null) -- cgit v1.1 From 266167f5a390e089f7f79d73bdaad4c853d04daa Mon Sep 17 00:00:00 2001 From: BlueWall Date: Sun, 8 Jan 2012 17:41:47 -0500 Subject: Fix teleport routing Route non-owner avatars according to land settings --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 8ebb7a6..afd4813 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1180,6 +1180,23 @@ namespace OpenSim.Region.Framework.Scenes client.Name, Scene.RegionInfo.RegionName, AbsolutePosition); Vector3 look = Velocity; + + // Place avatar according to parcel owner teleport routing... + ILandObject land = Scene.LandChannel.GetLandObject(AbsolutePosition.X, AbsolutePosition.Y); + + if (land != null) + { + // Land owner should be able to land anywhere, others honor settings + if (land.LandData.OwnerID != client.AgentId) + { + if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) + { + AbsolutePosition = land.LandData.UserLocation; + look = land.LandData.UserLookAt; + } + } + } + if ((look.X == 0) && (look.Y == 0) && (look.Z == 0)) { look = new Vector3(0.99f, 0.042f, 0); -- cgit v1.1 From 44cde8d5c6dbb2a7dc55bc13d55264241e7cfa81 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 8 Jan 2012 23:36:49 +0000 Subject: Update teleport routing to match Avination --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 74 +++++++++++++++++++----- 1 file changed, 58 insertions(+), 16 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index afd4813..b861c28 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -892,6 +892,8 @@ namespace OpenSim.Region.Framework.Scenes pos.Y = crossedBorder.BorderLine.Z - 1; } + CheckAndAdjustLandingPoint(ref pos); + if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) { m_log.WarnFormat( @@ -1056,6 +1058,7 @@ namespace OpenSim.Region.Framework.Scenes bool isFlying = Flying; RemoveFromPhysicalScene(); Velocity = Vector3.Zero; + CheckLandingPoint(ref pos); AbsolutePosition = pos; AddToPhysicalScene(isFlying); @@ -1066,6 +1069,7 @@ namespace OpenSim.Region.Framework.Scenes { bool isFlying = Flying; RemoveFromPhysicalScene(); + CheckLandingPoint(ref pos); AbsolutePosition = pos; AddToPhysicalScene(isFlying); @@ -1181,22 +1185,6 @@ namespace OpenSim.Region.Framework.Scenes Vector3 look = Velocity; - // Place avatar according to parcel owner teleport routing... - ILandObject land = Scene.LandChannel.GetLandObject(AbsolutePosition.X, AbsolutePosition.Y); - - if (land != null) - { - // Land owner should be able to land anywhere, others honor settings - if (land.LandData.OwnerID != client.AgentId) - { - if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) - { - AbsolutePosition = land.LandData.UserLocation; - look = land.LandData.UserLookAt; - } - } - } - if ((look.X == 0) && (look.Y == 0) && (look.Z == 0)) { look = new Vector3(0.99f, 0.042f, 0); @@ -3820,5 +3808,59 @@ namespace OpenSim.Region.Framework.Scenes m_reprioritization_called = false; } } + + private void CheckLandingPoint(ref Vector3 pos) + { + // Never constrain lures + if ((TeleportFlags & TeleportFlags.ViaLure) != 0) + return; + + if (m_scene.RegionInfo.EstateSettings.AllowDirectTeleport) + return; + + ILandObject land = m_scene.LandChannel.GetLandObject(pos.X, pos.Y); + + if (land.LandData.LandingType == (byte)LandingType.LandingPoint && + land.LandData.UserLocation != Vector3.Zero && + land.LandData.OwnerID != m_uuid && + (!m_scene.Permissions.IsGod(m_uuid)) && + (!m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid))) + { + float curr = Vector3.Distance(AbsolutePosition, pos); + if (Vector3.Distance(land.LandData.UserLocation, pos) < curr) + pos = land.LandData.UserLocation; + else + ControllingClient.SendAlertMessage("Can't teleport closer to destination"); + } + } + + private void CheckAndAdjustLandingPoint(ref Vector3 pos) + { + ILandObject land = m_scene.LandChannel.GetLandObject(pos.X, pos.Y); + if (land != null) + { + // If we come in via login, landmark or map, we want to + // honor landing points. If we come in via Lure, we want + // to ignore them. + if ((m_teleportFlags & (TeleportFlags.ViaLogin | TeleportFlags.ViaRegionID)) == (TeleportFlags.ViaLogin | TeleportFlags.ViaRegionID) || + (m_teleportFlags & TeleportFlags.ViaLandmark) != 0 || + (m_teleportFlags & TeleportFlags.ViaLocation) != 0) + { + // Don't restrict gods, estate managers, or land owners to + // the TP point. This behaviour mimics agni. + if (land.LandData.LandingType == (byte)LandingType.LandingPoint && + land.LandData.UserLocation != Vector3.Zero && + GodLevel < 200 && + ((land.LandData.OwnerID != m_uuid && + (!m_scene.Permissions.IsGod(m_uuid)) && + (!m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid))) || (m_teleportFlags & TeleportFlags.ViaLocation) != 0)) + { + pos = land.LandData.UserLocation; + } + } + + land.SendLandUpdateToClient(ControllingClient); + } + } } } -- cgit v1.1 From 1ebd79e4134f524f02f9c51f6b143b081eae60f4 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 9 Jan 2012 00:54:59 +0000 Subject: Add the HG case to landing point checks --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index b861c28..164833c 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3842,7 +3842,7 @@ namespace OpenSim.Region.Framework.Scenes // If we come in via login, landmark or map, we want to // honor landing points. If we come in via Lure, we want // to ignore them. - if ((m_teleportFlags & (TeleportFlags.ViaLogin | TeleportFlags.ViaRegionID)) == (TeleportFlags.ViaLogin | TeleportFlags.ViaRegionID) || + if ((m_teleportFlags & (TeleportFlags.ViaLogin | TeleportFlags.ViaHGLogin | TeleportFlags.ViaRegionID)) == (TeleportFlags.ViaLogin | TeleportFlags.ViaHGLogin | TeleportFlags.ViaRegionID) || (m_teleportFlags & TeleportFlags.ViaLandmark) != 0 || (m_teleportFlags & TeleportFlags.ViaLocation) != 0) { -- cgit v1.1 From 0e855fea7c8fa6e193bc840bc1710a7ff1947625 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 9 Jan 2012 01:05:19 +0000 Subject: Fix a build break --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 164833c..5695c08 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3842,7 +3842,7 @@ namespace OpenSim.Region.Framework.Scenes // If we come in via login, landmark or map, we want to // honor landing points. If we come in via Lure, we want // to ignore them. - if ((m_teleportFlags & (TeleportFlags.ViaLogin | TeleportFlags.ViaHGLogin | TeleportFlags.ViaRegionID)) == (TeleportFlags.ViaLogin | TeleportFlags.ViaHGLogin | TeleportFlags.ViaRegionID) || + if ((m_teleportFlags & (TeleportFlags.ViaLogin | (TeleportFlags)Constants.TeleportFlags.ViaHGLogin | TeleportFlags.ViaRegionID)) == (TeleportFlags.ViaLogin | (TeleportFlags)Constants.TeleportFlags.ViaHGLogin | TeleportFlags.ViaRegionID) || (m_teleportFlags & TeleportFlags.ViaLandmark) != 0 || (m_teleportFlags & TeleportFlags.ViaLocation) != 0) { -- cgit v1.1 From 34c42cdab026e5931ebad139b0b4fd959b99bf00 Mon Sep 17 00:00:00 2001 From: BlueWall Date: Mon, 9 Jan 2012 01:37:28 -0500 Subject: Fix HG teleport routing Needed to breakout the ViaHGLogin check to it's own section. For some reason it would not factor in when combined with the other teleport flag types. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 5695c08..6990be1 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3842,9 +3842,11 @@ namespace OpenSim.Region.Framework.Scenes // If we come in via login, landmark or map, we want to // honor landing points. If we come in via Lure, we want // to ignore them. - if ((m_teleportFlags & (TeleportFlags.ViaLogin | (TeleportFlags)Constants.TeleportFlags.ViaHGLogin | TeleportFlags.ViaRegionID)) == (TeleportFlags.ViaLogin | (TeleportFlags)Constants.TeleportFlags.ViaHGLogin | TeleportFlags.ViaRegionID) || + if ((m_teleportFlags & (TeleportFlags.ViaLogin | TeleportFlags.ViaRegionID)) == + (TeleportFlags.ViaLogin | TeleportFlags.ViaRegionID) || (m_teleportFlags & TeleportFlags.ViaLandmark) != 0 || - (m_teleportFlags & TeleportFlags.ViaLocation) != 0) + (m_teleportFlags & TeleportFlags.ViaLocation) != 0 || + ((m_teleportFlags & (TeleportFlags)Constants.TeleportFlags.ViaHGLogin) == (TeleportFlags)Constants.TeleportFlags.ViaHGLogin)) { // Don't restrict gods, estate managers, or land owners to // the TP point. This behaviour mimics agni. -- cgit v1.1 From 43145c7f673fa038b7e3bfec468e229064c909b7 Mon Sep 17 00:00:00 2001 From: BlueWall Date: Mon, 9 Jan 2012 13:07:02 -0500 Subject: Debugging HG teleport routing Add some temporary debugging to the teleport routing to get a better view of what happens when HG jumps are made. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 6990be1..e3a7f3b 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3836,6 +3836,24 @@ namespace OpenSim.Region.Framework.Scenes private void CheckAndAdjustLandingPoint(ref Vector3 pos) { + // Some debugging help to show all the TeleportFlags we have... + bool HG = false; + if((m_teleportFlags & (TeleportFlags)Constants.TeleportFlags.ViaHGLogin) == (TeleportFlags)Constants.TeleportFlags.ViaHGLogin) + HG = true; + + m_log.InfoFormat("[SCENE PRESENCE]: TELEPORT ******************"); + + for (uint i = 0; i <= 30 ; i++) + { + if((m_teleportFlags & (TeleportFlags)i) == (TeleportFlags)i) + if (HG == false) + m_log.InfoFormat("[SCENE PRESENCE]: Teleport Flags include {0}", ((TeleportFlags) i).ToString()); + else + m_log.InfoFormat("[SCENE PRESENCE]: HG Teleport Flags include {0}", ((TeleportFlags)i).ToString()); + } + + m_log.InfoFormat("[SCENE PRESENCE]: TELEPORT ******************"); + ILandObject land = m_scene.LandChannel.GetLandObject(pos.X, pos.Y); if (land != null) { -- cgit v1.1 From 3640afdd955e971502437b5663fe09199ba9ba5d Mon Sep 17 00:00:00 2001 From: BlueWall Date: Mon, 9 Jan 2012 14:31:22 -0500 Subject: Fix teleport routing for incoming HG+Owner Incoming HG owner/estate manager, etc. is routed according to the rules defined for teleports within the local grid. Left some commented debugging code inside so we can test other cases. Will remove when tings are settled in. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 37 ++++++++++++------------ 1 file changed, 19 insertions(+), 18 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index e3a7f3b..8a49f2c 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3836,23 +3836,23 @@ namespace OpenSim.Region.Framework.Scenes private void CheckAndAdjustLandingPoint(ref Vector3 pos) { - // Some debugging help to show all the TeleportFlags we have... - bool HG = false; - if((m_teleportFlags & (TeleportFlags)Constants.TeleportFlags.ViaHGLogin) == (TeleportFlags)Constants.TeleportFlags.ViaHGLogin) - HG = true; - - m_log.InfoFormat("[SCENE PRESENCE]: TELEPORT ******************"); - - for (uint i = 0; i <= 30 ; i++) - { - if((m_teleportFlags & (TeleportFlags)i) == (TeleportFlags)i) - if (HG == false) - m_log.InfoFormat("[SCENE PRESENCE]: Teleport Flags include {0}", ((TeleportFlags) i).ToString()); - else - m_log.InfoFormat("[SCENE PRESENCE]: HG Teleport Flags include {0}", ((TeleportFlags)i).ToString()); - } - - m_log.InfoFormat("[SCENE PRESENCE]: TELEPORT ******************"); +// // Some temporary debugging help to show all the TeleportFlags we have... +// bool HG = false; +// if((m_teleportFlags & (TeleportFlags)Constants.TeleportFlags.ViaHGLogin) == (TeleportFlags)Constants.TeleportFlags.ViaHGLogin) +// HG = true; +// +// m_log.InfoFormat("[SCENE PRESENCE]: TELEPORT ******************"); +// +// for (uint i = 0; i <= 30 ; i++) +// { +// if((m_teleportFlags & (TeleportFlags)i) == (TeleportFlags)i) +// if (HG == false) +// m_log.InfoFormat("[SCENE PRESENCE]: Teleport Flags include {0}", ((TeleportFlags) i).ToString()); +// else +// m_log.InfoFormat("[SCENE PRESENCE]: HG Teleport Flags include {0}", ((TeleportFlags)i).ToString()); +// } +// +// m_log.InfoFormat("[SCENE PRESENCE]: TELEPORT ******************"); ILandObject land = m_scene.LandChannel.GetLandObject(pos.X, pos.Y); if (land != null) @@ -3873,7 +3873,8 @@ namespace OpenSim.Region.Framework.Scenes GodLevel < 200 && ((land.LandData.OwnerID != m_uuid && (!m_scene.Permissions.IsGod(m_uuid)) && - (!m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid))) || (m_teleportFlags & TeleportFlags.ViaLocation) != 0)) + (!m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid))) || (m_teleportFlags & TeleportFlags.ViaLocation) != 0) || + ((m_teleportFlags & (TeleportFlags)Constants.TeleportFlags.ViaHGLogin) == (TeleportFlags)Constants.TeleportFlags.ViaHGLogin)) { pos = land.LandData.UserLocation; } -- cgit v1.1 From 95345521f0316fb1800b7579c65a535ee1d8f495 Mon Sep 17 00:00:00 2001 From: BlueWall Date: Mon, 9 Jan 2012 17:04:34 -0500 Subject: TP Routing debug Fix test to checking against bitfield instead of int --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 8a49f2c..0837679 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3836,15 +3836,18 @@ namespace OpenSim.Region.Framework.Scenes private void CheckAndAdjustLandingPoint(ref Vector3 pos) { -// // Some temporary debugging help to show all the TeleportFlags we have... + // Some temporary debugging help to show all the TeleportFlags we have... // bool HG = false; // if((m_teleportFlags & (TeleportFlags)Constants.TeleportFlags.ViaHGLogin) == (TeleportFlags)Constants.TeleportFlags.ViaHGLogin) // HG = true; // // m_log.InfoFormat("[SCENE PRESENCE]: TELEPORT ******************"); // -// for (uint i = 0; i <= 30 ; i++) +// uint i = 0u; +// for (int x = 0; x <= 30 ; x++, i = 1u << x) // { +// i = 1u << x; +// // if((m_teleportFlags & (TeleportFlags)i) == (TeleportFlags)i) // if (HG == false) // m_log.InfoFormat("[SCENE PRESENCE]: Teleport Flags include {0}", ((TeleportFlags) i).ToString()); -- cgit v1.1 From b3a12167d6dd9cbd21c57ca103d8c3f60ba93e73 Mon Sep 17 00:00:00 2001 From: BlueWall Date: Mon, 9 Jan 2012 17:54:35 -0500 Subject: Use our TeleportFlags Switch to our TeleportFlags enum instead of LibOMV because we need to define a type for HG Logins. Also moved some debugging in ScenePresence into a function to make it simpler to enable/disable. --- OpenSim/Region/Framework/Scenes/Scene.cs | 4 +- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 48 ++++++++++++++---------- 2 files changed, 30 insertions(+), 22 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 027ec96..5e1c768 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -2528,7 +2528,7 @@ namespace OpenSim.Region.Framework.Scenes sp = m_sceneGraph.CreateAndAddChildScenePresence(client, aCircuit.Appearance, type); m_eventManager.TriggerOnNewPresence(sp); - sp.TeleportFlags = (TeleportFlags)aCircuit.teleportFlags; + sp.TeleportFlags = (TPFlags)aCircuit.teleportFlags; // The first agent upon login is a root agent by design. // For this agent we will have to rez the attachments. @@ -3333,7 +3333,7 @@ namespace OpenSim.Region.Framework.Scenes { // Let the SP know how we got here. This has a lot of interesting // uses down the line. - sp.TeleportFlags = (TeleportFlags)teleportFlags; + sp.TeleportFlags = (TPFlags)teleportFlags; if (sp.IsChildAgent) { diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 0837679..d58484e 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -40,6 +40,7 @@ using OpenSim.Region.Framework.Scenes.Types; using OpenSim.Region.Physics.Manager; using GridRegion = OpenSim.Services.Interfaces.GridRegion; using OpenSim.Services.Interfaces; +using TeleportFlags = OpenSim.Framework.Constants.TeleportFlags; namespace OpenSim.Region.Framework.Scenes { @@ -3836,30 +3837,11 @@ namespace OpenSim.Region.Framework.Scenes private void CheckAndAdjustLandingPoint(ref Vector3 pos) { - // Some temporary debugging help to show all the TeleportFlags we have... -// bool HG = false; -// if((m_teleportFlags & (TeleportFlags)Constants.TeleportFlags.ViaHGLogin) == (TeleportFlags)Constants.TeleportFlags.ViaHGLogin) -// HG = true; -// -// m_log.InfoFormat("[SCENE PRESENCE]: TELEPORT ******************"); -// -// uint i = 0u; -// for (int x = 0; x <= 30 ; x++, i = 1u << x) -// { -// i = 1u << x; -// -// if((m_teleportFlags & (TeleportFlags)i) == (TeleportFlags)i) -// if (HG == false) -// m_log.InfoFormat("[SCENE PRESENCE]: Teleport Flags include {0}", ((TeleportFlags) i).ToString()); -// else -// m_log.InfoFormat("[SCENE PRESENCE]: HG Teleport Flags include {0}", ((TeleportFlags)i).ToString()); -// } -// -// m_log.InfoFormat("[SCENE PRESENCE]: TELEPORT ******************"); ILandObject land = m_scene.LandChannel.GetLandObject(pos.X, pos.Y); if (land != null) { + TeleportFlagsDebug(); // If we come in via login, landmark or map, we want to // honor landing points. If we come in via Lure, we want // to ignore them. @@ -3886,5 +3868,31 @@ namespace OpenSim.Region.Framework.Scenes land.SendLandUpdateToClient(ControllingClient); } } + + private void TeleportFlagsDebug() { + + // Some temporary debugging help to show all the TeleportFlags we have... + bool HG = false; + if((m_teleportFlags & TeleportFlags.ViaHGLogin) == TeleportFlags.ViaHGLogin) + HG = true; + + m_log.InfoFormat("[SCENE PRESENCE]: TELEPORT ******************"); + + uint i = 0u; + for (int x = 0; x <= 30 ; x++, i = 1u << x) + { + i = 1u << x; + + if((m_teleportFlags & (TeleportFlags)i) == (TeleportFlags)i) + if (HG == false) + m_log.InfoFormat("[SCENE PRESENCE]: Teleport Flags include {0}", ((TeleportFlags) i).ToString()); + else + m_log.InfoFormat("[SCENE PRESENCE]: HG Teleport Flags include {0}", ((TeleportFlags)i).ToString()); + } + + m_log.InfoFormat("[SCENE PRESENCE]: TELEPORT ******************"); + + } + } } -- cgit v1.1 From 707c8c6f2b7671c0a439a28921daeac8e7219639 Mon Sep 17 00:00:00 2001 From: BlueWall Date: Mon, 9 Jan 2012 18:19:55 -0500 Subject: Add some run-time debugging support Add configuration option - DEBUG to enable debugging methods. This is temporary for helping users testing teleport routing be able to report back the data with the test cases. We can remove when finished with this, or leave it if it proves to be useful. Users: set DEBUG = true in OpenSim.ini to get more information from teleport routing. The default is false. It presently prints the TeleportFlags value. --- OpenSim/Region/Framework/Scenes/Scene.cs | 3 +++ OpenSim/Region/Framework/Scenes/ScenePresence.cs | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 5e1c768..ed6f68a 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -65,6 +65,7 @@ namespace OpenSim.Region.Framework.Scenes #region Fields public bool EmergencyMonitoring = false; + public bool DEBUG = false; public SynchronizeSceneHandler SynchronizeScene; public SimStatsReporter StatsReporter; @@ -650,6 +651,8 @@ namespace OpenSim.Region.Framework.Scenes // IConfig startupConfig = m_config.Configs["Startup"]; + DEBUG = startupConfig.GetBoolean("DEBUG", false); + m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance",m_defaultDrawDistance); m_useBackup = startupConfig.GetBoolean("UseSceneBackup", m_useBackup); if (!m_useBackup) diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index d58484e..1869417 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3841,7 +3841,9 @@ namespace OpenSim.Region.Framework.Scenes ILandObject land = m_scene.LandChannel.GetLandObject(pos.X, pos.Y); if (land != null) { - TeleportFlagsDebug(); + if (Scene.DEBUG) + TeleportFlagsDebug(); + // If we come in via login, landmark or map, we want to // honor landing points. If we come in via Lure, we want // to ignore them. -- cgit v1.1 From a22d0dcab91607017e2f054b68c113294d04c821 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 10 Jan 2012 09:58:53 -0800 Subject: HG Friends: fixed bug introduced by 571efeddb20f38bb4164074b3c217be5387ca2e0 (r/17672) --- OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs index a77646c..9c53fc4 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs @@ -496,13 +496,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends string agentFriendService = string.Empty; string friendFriendService = string.Empty; - if (agentIsLocal) + if (agentClient != null) { agentClientCircuit = ((Scene)(agentClient.Scene)).AuthenticateHandler.GetAgentCircuitData(agentClient.CircuitCode); agentUUI = Util.ProduceUserUniversalIdentifier(agentClientCircuit); agentFriendService = agentClientCircuit.ServiceURLs["FriendsServerURI"].ToString(); } - if (friendIsLocal) + if (friendClient != null) { friendClientCircuit = ((Scene)(friendClient.Scene)).AuthenticateHandler.GetAgentCircuitData(friendClient.CircuitCode); friendUUI = Util.ProduceUserUniversalIdentifier(friendClientCircuit); -- cgit v1.1 From d67e8291c86beb5c3c8e8b11a7f95b49c834c779 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 10 Jan 2012 18:41:07 +0000 Subject: Add "app find " command to find the appearance using a particular baked texture, if any. This is for debugging to relate texture console entries back to particular users on the simulator end. --- .../Avatar/Appearance/AppearanceInfoModule.cs | 50 ++++++++++++++++++++++ 1 file changed, 50 insertions(+) (limited to 'OpenSim') diff --git a/OpenSim/Region/OptionalModules/Avatar/Appearance/AppearanceInfoModule.cs b/OpenSim/Region/OptionalModules/Avatar/Appearance/AppearanceInfoModule.cs index 39cd4c9..2369d94 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Appearance/AppearanceInfoModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Appearance/AppearanceInfoModule.cs @@ -27,6 +27,7 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Reflection; using System.Text; using log4net; @@ -124,6 +125,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.Appearance + "\nIf the viewer has not yet sent the server any texture ids then nothing will happen" + "\nsince requests can only be made for ids that the client has already sent us", HandleRebakeAppearanceCommand); + + scene.AddCommand( + this, "appearance find", + "appearance find ", + "Find out which avatar uses the given asset as a baked texture, if any.", + "You can specify just the beginning of the uuid, e.g. 2008a8d. A longer UUID must be in dashed format.", + HandleFindAppearanceCommand); } private void HandleSendAppearanceCommand(string module, string[] cmd) @@ -254,5 +262,47 @@ namespace OpenSim.Region.OptionalModules.Avatar.Appearance } } } + + protected void HandleFindAppearanceCommand(string module, string[] cmd) + { + if (cmd.Length != 3) + { + MainConsole.Instance.OutputFormat("Usage: appearance find "); + return; + } + + string rawUuid = cmd[2]; + + HashSet matchedAvatars = new HashSet(); + + lock (m_scenes) + { + foreach (Scene scene in m_scenes.Values) + { + scene.ForEachRootScenePresence( + sp => + { + Dictionary bakedFaces = scene.AvatarFactory.GetBakedTextureFaces(sp.UUID); + foreach (Primitive.TextureEntryFace face in bakedFaces.Values) + { + if (face != null && face.TextureID.ToString().StartsWith(rawUuid)) + matchedAvatars.Add(sp); + } + }); + } + } + + if (matchedAvatars.Count == 0) + { + MainConsole.Instance.OutputFormat("{0} did not match any baked avatar textures in use", rawUuid); + } + else + { + MainConsole.Instance.OutputFormat( + "{0} matched {1}", + rawUuid, + string.Join(", ", matchedAvatars.ToList().ConvertAll(sp => sp.Name).ToArray())); + } + } } } \ No newline at end of file -- cgit v1.1 From 3deb52d3996b45228c2301ecc7445514099f3b13 Mon Sep 17 00:00:00 2001 From: BlueWall Date: Tue, 10 Jan 2012 13:41:35 -0500 Subject: Teleport Debugging Move setting from ini to existing facitilies - thanks justincc toggle with console command: debug teleport --- OpenSim/Region/Application/OpenSim.cs | 17 +++++++++++++++++ OpenSim/Region/Framework/Scenes/Scene.cs | 2 -- 2 files changed, 17 insertions(+), 2 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs index 3a1a8c7..867e36d 100644 --- a/OpenSim/Region/Application/OpenSim.cs +++ b/OpenSim/Region/Application/OpenSim.cs @@ -250,6 +250,8 @@ namespace OpenSim + "If level <= 0 then no extra http logging is done.\n", Debug); + m_console.Commands.AddCommand("region", false, "debug teleport", "debug teleport", "Toggle teleport route debugging", Debug); + m_console.Commands.AddCommand("region", false, "debug scene", "debug scene ", "Turn on scene debugging", Debug); @@ -948,6 +950,21 @@ namespace OpenSim break; + case "teleport": + foreach(Scene s in m_sceneManager.Scenes) + { + if (s.DEBUG) + { + s.DEBUG = false; + MainConsole.Instance.Output("Teleport debugging is disabled!"); + } + else{ + s.DEBUG = true; + MainConsole.Instance.Output("Teleport debugging is enabled!"); + } + } + break; + default: MainConsole.Instance.Output("Unknown debug command"); break; diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index ed6f68a..f03c345 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -651,8 +651,6 @@ namespace OpenSim.Region.Framework.Scenes // IConfig startupConfig = m_config.Configs["Startup"]; - DEBUG = startupConfig.GetBoolean("DEBUG", false); - m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance",m_defaultDrawDistance); m_useBackup = startupConfig.GetBoolean("UseSceneBackup", m_useBackup); if (!m_useBackup) -- cgit v1.1 From a3bb1a81de9f39b126a04afb984483f7e4a4aa24 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 10 Jan 2012 18:47:30 +0000 Subject: correct very minor typo in "debug scene" help --- OpenSim/Region/Application/OpenSim.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs index 867e36d..832d93c 100644 --- a/OpenSim/Region/Application/OpenSim.cs +++ b/OpenSim/Region/Application/OpenSim.cs @@ -253,7 +253,7 @@ namespace OpenSim m_console.Commands.AddCommand("region", false, "debug teleport", "debug teleport", "Toggle teleport route debugging", Debug); m_console.Commands.AddCommand("region", false, "debug scene", - "debug scene ", + "debug scene ", "Turn on scene debugging", Debug); m_console.Commands.AddCommand("region", false, "change region", -- cgit v1.1 From 18497cef73c5dc5609caebe59fb7980e2542574d Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 10 Jan 2012 18:54:20 +0000 Subject: Add avatar names to appearance log messages --- .../Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs index d68d28c..8d503bd 100644 --- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs @@ -149,7 +149,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory // Process the baked texture array if (textureEntry != null) { - m_log.InfoFormat("[AVFACTORY]: received texture update for {0}", sp.UUID); + m_log.InfoFormat("[AVFACTORY]: Received texture update for {0} {1}", sp.Name, sp.UUID); // WriteBakedTexturesReport(sp, m_log.DebugFormat); @@ -315,7 +315,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory return false; } - m_log.DebugFormat("[AVFACTORY]: Completed texture check for {0}", sp.UUID); + m_log.DebugFormat("[AVFACTORY]: Completed texture check for {0} {1}", sp.Name, sp.UUID); // If we only found default textures, then the appearance is not cached return (defonly ? false : true); @@ -626,4 +626,4 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory outputAction("{0} baked appearance texture is {1}", sp.Name, bakedTextureValid ? "OK" : "corrupt"); } } -} +} \ No newline at end of file -- cgit v1.1 From 7b84942f868a0c0d54a9ccb3627434cbf0e91417 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 10 Jan 2012 11:10:47 -0800 Subject: HG landing points: this hopefully fixes some confusion that was making HG avies always land in 0,0 --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 1869417..3c9bde8 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3851,17 +3851,18 @@ namespace OpenSim.Region.Framework.Scenes (TeleportFlags.ViaLogin | TeleportFlags.ViaRegionID) || (m_teleportFlags & TeleportFlags.ViaLandmark) != 0 || (m_teleportFlags & TeleportFlags.ViaLocation) != 0 || - ((m_teleportFlags & (TeleportFlags)Constants.TeleportFlags.ViaHGLogin) == (TeleportFlags)Constants.TeleportFlags.ViaHGLogin)) + (m_teleportFlags & Constants.TeleportFlags.ViaHGLogin) != 0) { // Don't restrict gods, estate managers, or land owners to // the TP point. This behaviour mimics agni. if (land.LandData.LandingType == (byte)LandingType.LandingPoint && land.LandData.UserLocation != Vector3.Zero && GodLevel < 200 && - ((land.LandData.OwnerID != m_uuid && - (!m_scene.Permissions.IsGod(m_uuid)) && - (!m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid))) || (m_teleportFlags & TeleportFlags.ViaLocation) != 0) || - ((m_teleportFlags & (TeleportFlags)Constants.TeleportFlags.ViaHGLogin) == (TeleportFlags)Constants.TeleportFlags.ViaHGLogin)) + ((land.LandData.OwnerID != m_uuid && + !m_scene.Permissions.IsGod(m_uuid) && + !m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid)) || + (m_teleportFlags & TeleportFlags.ViaLocation) != 0 || + (m_teleportFlags & Constants.TeleportFlags.ViaHGLogin) != 0)) { pos = land.LandData.UserLocation; } -- cgit v1.1 From ef074deb52de617743ad50ea29e286dd9c66722d Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 10 Jan 2012 21:30:12 +0000 Subject: Add "show image queue " region console command This is so that we can inspect the image download queue (texture download via udp) for debugging purposes. --- .../Region/ClientStack/Linden/UDP/LLClientView.cs | 14 ++-- .../ClientStack/Linden/UDP/LLImageManager.cs | 10 +++ .../Agent/UDP/Linden/LindenUDPInfoModule.cs | 89 +++++++++++++++++++++- 3 files changed, 107 insertions(+), 6 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index eb1a50e..1e72aa2 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -304,6 +304,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); protected static Dictionary PacketHandlers = new Dictionary(); //Global/static handlers for all clients + /// + /// Handles UDP texture download. + /// + public LLImageManager ImageManager { get; private set; } + private readonly LLUDPServer m_udpServer; private readonly LLUDPClient m_udpClient; private readonly UUID m_sessionId; @@ -348,7 +353,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP protected Dictionary m_packetHandlers = new Dictionary(); protected Dictionary m_genericPacketHandlers = new Dictionary(); //PauPaw:Local Generic Message handlers protected Scene m_scene; - private LLImageManager m_imageManager; protected string m_firstName; protected string m_lastName; protected Thread m_clientThread; @@ -459,7 +463,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP m_assetService = m_scene.RequestModuleInterface(); m_GroupsModule = scene.RequestModuleInterface(); - m_imageManager = new LLImageManager(this, m_assetService, Scene.RequestModuleInterface()); + ImageManager = new LLImageManager(this, m_assetService, Scene.RequestModuleInterface()); m_channelVersion = Util.StringToBytes256(scene.GetSimulatorVersion()); m_agentId = agentId; m_sessionId = sessionId; @@ -499,7 +503,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP IsActive = false; // Shutdown the image manager - m_imageManager.Close(); + ImageManager.Close(); // Fire the callback for this connection closing if (OnConnectionClosed != null) @@ -3939,7 +3943,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } if ((categories & ThrottleOutPacketTypeFlags.Texture) != 0) - m_imageManager.ProcessImageQueue(m_udpServer.TextureSendLimit); + ImageManager.ProcessImageQueue(m_udpServer.TextureSendLimit); } public void SendAssetUploadCompleteMessage(sbyte AssetType, bool Success, UUID AssetFullID) @@ -7470,7 +7474,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP if ((ImageType)block.Type == ImageType.Baked) args.Priority *= 2.0f; - m_imageManager.EnqueueReq(args); + ImageManager.EnqueueReq(args); } return true; diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLImageManager.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLImageManager.cs index 3e31b7d..db428f1 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLImageManager.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLImageManager.cs @@ -245,6 +245,16 @@ namespace OpenSim.Region.ClientStack.LindenUDP m_shuttingdown = true; } + /// + /// Returns an array containing all the images in the queue. + /// + /// + public J2KImage[] GetImages() + { + lock (m_priorityQueue) + return m_priorityQueue.ToArray(); + } + #region Priority Queue Helpers private J2KImage GetHighestPriorityImage() diff --git a/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs b/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs index c754019..16f6821 100644 --- a/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs +++ b/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs @@ -95,7 +95,13 @@ namespace OpenSim.Region.CoreModules.UDP.Linden "Show queue data for each client", "Without the 'full' option, only root agents are shown." + " With the 'full' option child agents are also shown.", - ShowQueuesReport); + ShowQueuesReport); + + scene.AddCommand( + this, "show image queue", + "show image queue ", + "Show the image queue (textures downloaded via UDP) for a particular client.", + ShowImageQueuesReport); scene.AddCommand( this, "show throttles", @@ -135,6 +141,11 @@ namespace OpenSim.Region.CoreModules.UDP.Linden { MainConsole.Instance.Output(GetQueuesReport(cmd)); } + + protected void ShowImageQueuesReport(string module, string[] cmd) + { + MainConsole.Instance.Output(GetImageQueuesReport(cmd)); + } protected void ShowThrottlesReport(string module, string[] cmd) { @@ -240,6 +251,82 @@ namespace OpenSim.Region.CoreModules.UDP.Linden return report.ToString(); } + + /// + /// Generate an image queue report + /// + /// + /// + private string GetImageQueuesReport(string[] showParams) + { + if (showParams.Length < 5 || showParams.Length > 6) + { + MainConsole.Instance.OutputFormat("Usage: show image queue [full]"); + return ""; + } + + string firstName = showParams[3]; + string lastName = showParams[4]; + + bool showChildAgents = showParams.Length == 6; + + List foundAgents = new List(); + + lock (m_scenes) + { + foreach (Scene scene in m_scenes.Values) + { + ScenePresence sp = scene.GetScenePresence(firstName, lastName); + if (sp != null && (showChildAgents || !sp.IsChildAgent)) + foundAgents.Add(sp); + } + } + + if (foundAgents.Count == 0) + { + MainConsole.Instance.OutputFormat("No agents found for {0} {1}", firstName, lastName); + return ""; + } + + StringBuilder report = new StringBuilder(); + + foreach (ScenePresence agent in foundAgents) + { + LLClientView client = agent.ControllingClient as LLClientView; + + if (client == null) + { + MainConsole.Instance.OutputFormat("This command is only supported for LLClientView"); + return ""; + } + + J2KImage[] images = client.ImageManager.GetImages(); + + report.AppendFormat( + "In region {0} ({1} agent)\n", + agent.Scene.RegionInfo.RegionName, agent.IsChildAgent ? "child" : "root"); + report.AppendFormat("Images in queue: {0}\n", images.Length); + + if (images.Length > 0) + { + report.AppendFormat( + "{0,-36} {1,-8} {2,-9} {3,-9} {4,-9} {5,-7}\n", + "Texture ID", + "Last Seq", + "Priority", + "Start Pkt", + "Has Asset", + "Decoded"); + + foreach (J2KImage image in images) + report.AppendFormat( + "{0,36} {1,8} {2,9} {3,10} {4,9} {5,7}\n", + image.TextureID, image.LastSequence, image.Priority, image.StartPacket, image.HasAsset, image.IsDecoded); + } + } + + return report.ToString(); + } /// /// Generate UDP Queue data report for each client -- cgit v1.1 From 5002f06d24d3e9fde5d38ba8ee7e37bc9c139f89 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 10 Jan 2012 21:36:35 +0000 Subject: rename "show image queue" to "show image queues" in line with other udp info commands. Eliminate redundant one line methods --- .../Agent/UDP/Linden/LindenUDPInfoModule.cs | 37 +++++----------------- 1 file changed, 8 insertions(+), 29 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs b/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs index 16f6821..58b9b9f 100644 --- a/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs +++ b/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs @@ -87,7 +87,7 @@ namespace OpenSim.Region.CoreModules.UDP.Linden "Show priority queue data for each client", "Without the 'full' option, only root agents are shown." + " With the 'full' option child agents are also shown.", - ShowPQueuesReport); + (mod, cmd) => MainConsole.Instance.Output(GetPQueuesReport(cmd))); scene.AddCommand( this, "show queues", @@ -95,13 +95,13 @@ namespace OpenSim.Region.CoreModules.UDP.Linden "Show queue data for each client", "Without the 'full' option, only root agents are shown." + " With the 'full' option child agents are also shown.", - ShowQueuesReport); + (mod, cmd) => MainConsole.Instance.Output(GetQueuesReport(cmd))); scene.AddCommand( - this, "show image queue", - "show image queue ", - "Show the image queue (textures downloaded via UDP) for a particular client.", - ShowImageQueuesReport); + this, "show image queues", + "show image queues ", + "Show the image queues (textures downloaded via UDP) for a particular client.", + (mod, cmd) => MainConsole.Instance.Output(GetImageQueuesReport(cmd))); scene.AddCommand( this, "show throttles", @@ -109,7 +109,7 @@ namespace OpenSim.Region.CoreModules.UDP.Linden "Show throttle settings for each client and for the server overall", "Without the 'full' option, only root agents are shown." + " With the 'full' option child agents are also shown.", - ShowThrottlesReport); + (mod, cmd) => MainConsole.Instance.Output(GetThrottlesReport(cmd))); scene.AddCommand( this, "emergency-monitoring", @@ -130,26 +130,6 @@ namespace OpenSim.Region.CoreModules.UDP.Linden public void RegionLoaded(Scene scene) { // m_log.DebugFormat("[LINDEN UDP INFO MODULE]: REGION {0} LOADED", scene.RegionInfo.RegionName); - } - - protected void ShowPQueuesReport(string module, string[] cmd) - { - MainConsole.Instance.Output(GetPQueuesReport(cmd)); - } - - protected void ShowQueuesReport(string module, string[] cmd) - { - MainConsole.Instance.Output(GetQueuesReport(cmd)); - } - - protected void ShowImageQueuesReport(string module, string[] cmd) - { - MainConsole.Instance.Output(GetImageQueuesReport(cmd)); - } - - protected void ShowThrottlesReport(string module, string[] cmd) - { - MainConsole.Instance.Output(GetThrottlesReport(cmd)); } protected void EmergencyMonitoring(string module, string[] cmd) @@ -177,7 +157,6 @@ namespace OpenSim.Region.CoreModules.UDP.Linden entry.Length > maxLength ? entry.Substring(0, maxLength) : entry, ""); } - /// /// Generate UDP Queue data report for each client @@ -261,7 +240,7 @@ namespace OpenSim.Region.CoreModules.UDP.Linden { if (showParams.Length < 5 || showParams.Length > 6) { - MainConsole.Instance.OutputFormat("Usage: show image queue [full]"); + MainConsole.Instance.OutputFormat("Usage: show image queues [full]"); return ""; } -- cgit v1.1 From 53fb20880c4cdf72b4f28fd9a458f8f224766a7c Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 10 Jan 2012 22:02:35 +0000 Subject: minor: Fix wrong column length in image queues report --- .../Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs b/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs index 58b9b9f..db70e56 100644 --- a/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs +++ b/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs @@ -289,7 +289,7 @@ namespace OpenSim.Region.CoreModules.UDP.Linden if (images.Length > 0) { report.AppendFormat( - "{0,-36} {1,-8} {2,-9} {3,-9} {4,-9} {5,-7}\n", + "{0,-36} {1,-8} {2,-10} {3,-9} {4,-9} {5,-7}\n", "Texture ID", "Last Seq", "Priority", @@ -299,7 +299,7 @@ namespace OpenSim.Region.CoreModules.UDP.Linden foreach (J2KImage image in images) report.AppendFormat( - "{0,36} {1,8} {2,9} {3,10} {4,9} {5,7}\n", + "{0,36} {1,8} {2,10} {3,10} {4,9} {5,7}\n", image.TextureID, image.LastSequence, image.Priority, image.StartPacket, image.HasAsset, image.IsDecoded); } } -- cgit v1.1 From 5f7e392c7cc9410262dfb3333d9b60f6ff26eb79 Mon Sep 17 00:00:00 2001 From: Mic Bowman Date: Tue, 10 Jan 2012 16:26:01 -0800 Subject: Add a check to see if an asset exists before recreating it while loading an archive. This does add an extra roundtrip to the asset server if loading new assets but it protects against overwriting (and potentially corrupting) existing assets. --- OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs index 587d260..edc5ba4 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs @@ -404,6 +404,12 @@ namespace OpenSim.Region.CoreModules.World.Archiver string extension = filename.Substring(i); string uuid = filename.Remove(filename.Length - extension.Length); + if (m_scene.AssetService.GetMetadata(uuid) != null) + { + // m_log.DebugFormat("[ARCHIVER]: found existing asset {0}",uuid); + return true; + } + if (ArchiveConstants.EXTENSION_TO_ASSET_TYPE.ContainsKey(extension)) { sbyte assetType = ArchiveConstants.EXTENSION_TO_ASSET_TYPE[extension]; -- cgit v1.1 From 38db87475528f48752623fcb7e8b40ef728f50e9 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 11 Jan 2012 14:33:26 +0000 Subject: If deserializing a scene object fails during IAR load then ignore the object rather than halting the IAR load with an exception. --- .../Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs | 5 ++++- .../Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs index 6b24718..ee10d04 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs @@ -493,7 +493,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver } else { - sceneObjects.Add(SceneObjectSerializer.FromOriginalXmlFormat(xmlData)); + SceneObjectGroup deserializedObject = SceneObjectSerializer.FromOriginalXmlFormat(xmlData); + + if (deserializedObject != null) + sceneObjects.Add(deserializedObject); } foreach (SceneObjectGroup sog in sceneObjects) diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index bca49f7..38d1231 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs @@ -54,7 +54,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization /// Deserialize a scene object from the original xml format /// /// - /// + /// The scene object deserialized. Null on failure. public static SceneObjectGroup FromOriginalXmlFormat(string xmlData) { //m_log.DebugFormat("[SOG]: Starting deserialization of SOG"); -- cgit v1.1 From 6214e6a217cfe206e127739b141bdcceb253c98d Mon Sep 17 00:00:00 2001 From: Bo Iwu Date: Thu, 12 Jan 2012 17:43:20 +0100 Subject: Allow update of stored entries within User Management Module-this is needed for proper work of HG friends. See http://opensimulator.org/mantis/view.php?id=5847 --- .../UserManagement/UserManagementModule.cs | 100 +++++++++++---------- 1 file changed, 52 insertions(+), 48 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs index 37292d6..2ad30a0 100644 --- a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs +++ b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs @@ -423,58 +423,62 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement AddUser(uuid, profileURL + ";" + first + " " + last); } - public void AddUser(UUID id, string creatorData) + public void AddUser (UUID id, string creatorData) { - lock (m_UserCache) - { - if (m_UserCache.ContainsKey(id)) - return; - } - -// m_log.DebugFormat("[USER MANAGEMENT MODULE]: Adding user with id {0}, craetorData {1}", id, creatorData); - - UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount(m_Scenes[0].RegionInfo.ScopeID, id); - - if (account != null) - { - AddUser(id, account.FirstName, account.LastName); - } - else - { - UserData user = new UserData(); - user.Id = id; - user.Flags = -1; - user.Created = -1; - - if (creatorData != null && creatorData != string.Empty) - { - //creatorData = ; - - string[] parts = creatorData.Split(';'); - if (parts.Length >= 1) - { - user.HomeURL = parts[0]; - try - { - Uri uri = new Uri(parts[0]); - user.LastName = "@" + uri.Authority; - } - catch (UriFormatException) - { - m_log.DebugFormat("[SCENE]: Unable to parse Uri {0}", parts[0]); - user.LastName = "@unknown"; - } + UserData oldUser; + //lock the whole block - prevent concurrent update + lock (m_UserCache) { + m_UserCache.TryGetValue (id, out oldUser); + if (oldUser != null) { + if (creatorData == null || creatorData == String.Empty) { + //ignore updates without creator data + return; + } + //try update unknown users + //and creator's home URL's + if ((oldUser.FirstName == "Unknown" && !creatorData.Contains ("Unknown")) || (oldUser.HomeURL != null && !creatorData.StartsWith (oldUser.HomeURL))) { + m_UserCache.Remove (id); +// m_log.DebugFormat("[USER MANAGEMENT MODULE]: Re-adding user with id {0}, creatorData [{1}] and old HomeURL {2}", id, creatorData,oldUser.HomeURL); + } else { + //we have already a valid user within the cache + return; } - if (parts.Length >= 2) - user.FirstName = parts[1].Replace(' ', '.'); } - else - { - user.FirstName = "Unknown"; - user.LastName = "User"; +// m_log.DebugFormat("[USER MANAGEMENT MODULE]: Adding user with id {0}, creatorData {1}", id, creatorData); + + UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount (m_Scenes[0].RegionInfo.ScopeID, id); + + if (account != null) { + AddUser (id, account.FirstName, account.LastName); + } else { + UserData user = new UserData (); + user.Id = id; + user.Flags = -1; + user.Created = -1; + + if (creatorData != null && creatorData != string.Empty) { + //creatorData = ; + + string[] parts = creatorData.Split (';'); + if (parts.Length >= 1) { + user.HomeURL = parts[0]; + try { + Uri uri = new Uri (parts[0]); + user.LastName = "@" + uri.Authority; + } catch (UriFormatException) { + m_log.DebugFormat ("[SCENE]: Unable to parse Uri {0}", parts[0]); + user.LastName = "@unknown"; + } + } + if (parts.Length >= 2) + user.FirstName = parts[1].Replace (' ', '.'); + } else { + user.FirstName = "Unknown"; + user.LastName = "User"; + } + + AddUserInternal (user); } - - AddUserInternal(user); } } -- cgit v1.1 From 8bdd80abfa3830142b16615d97d555dad417e08d Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 12 Jan 2012 09:56:35 -0800 Subject: HG: normalize all externalized user ULRs to be the Home URL, i.e. the location of the user's UAS. This corrects an earlier design which had some cases pointing to the profile server. WARNING: CONFIGURATION CHANGES in both the sims (*Common.ini) and the Robust configs (Robust.HG.ini). Please check diff of the example files, but basically all vars that were pointing to profile should point to the UAS instead and should be called HomeURI. --- .../Serialization/External/ExternalRepresentationUtils.cs | 8 ++++---- .../CoreModules/Framework/InventoryAccess/HGAssetMapper.cs | 10 +++++----- .../Framework/InventoryAccess/HGInventoryAccessModule.cs | 9 ++++++--- OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs | 8 ++++++-- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 4 ++-- .../Framework/Scenes/Serialization/SceneObjectSerializer.cs | 8 ++++---- OpenSim/Services/HypergridService/HGAssetService.cs | 11 +++++++---- OpenSim/Services/HypergridService/HGInventoryService.cs | 9 ++++++--- 8 files changed, 40 insertions(+), 27 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/Serialization/External/ExternalRepresentationUtils.cs b/OpenSim/Framework/Serialization/External/ExternalRepresentationUtils.cs index 6e8c2ee..7447ac2 100644 --- a/OpenSim/Framework/Serialization/External/ExternalRepresentationUtils.cs +++ b/OpenSim/Framework/Serialization/External/ExternalRepresentationUtils.cs @@ -44,13 +44,13 @@ namespace OpenSim.Framework.Serialization.External /// with creator data added to it. /// /// The SceneObjectPart represented in XML2 - /// The URL of the profile service for the creator + /// The URL of the user agents service (home) for the creator /// The service for retrieving user account information /// The scope of the user account information (Grid ID) /// The SceneObjectPart represented in XML2 - public static string RewriteSOP(string xml, string profileURL, IUserAccountService userService, UUID scopeID) + public static string RewriteSOP(string xml, string homeURL, IUserAccountService userService, UUID scopeID) { - if (xml == string.Empty || profileURL == string.Empty || userService == null) + if (xml == string.Empty || homeURL == string.Empty || userService == null) return xml; XmlDocument doc = new XmlDocument(); @@ -83,7 +83,7 @@ namespace OpenSim.Framework.Serialization.External if (!hasCreatorData && creator != null) { XmlElement creatorData = doc.CreateElement("CreatorData"); - creatorData.InnerText = profileURL + "/" + creator.PrincipalID + ";" + creator.FirstName + " " + creator.LastName; + creatorData.InnerText = homeURL + ";" + creator.FirstName + " " + creator.LastName; sop.AppendChild(creatorData); } } diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs index d20c9eb..eaadc1b 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs @@ -55,16 +55,16 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess // private Dictionary m_inventoryServers = new Dictionary(); private Scene m_scene; - private string m_ProfileServerURI; + private string m_HomeURI; #endregion #region Constructor - public HGAssetMapper(Scene scene, string profileURL) + public HGAssetMapper(Scene scene, string homeURL) { m_scene = scene; - m_ProfileServerURI = profileURL; + m_HomeURI = homeURL; } #endregion @@ -150,7 +150,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess UUID.TryParse(meta.CreatorID, out uuid); UserAccount creator = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, uuid); if (creator != null) - meta.CreatorID = m_ProfileServerURI + "/" + meta.CreatorID + ";" + creator.FirstName + " " + creator.LastName; + meta.CreatorID = m_HomeURI + ";" + creator.FirstName + " " + creator.LastName; } } @@ -193,7 +193,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess if (!hasCreatorData && creator != null) { XmlElement creatorData = doc.CreateElement("CreatorData"); - creatorData.InnerText = m_ProfileServerURI + "/" + creator.PrincipalID + ";" + creator.FirstName + " " + creator.LastName; + creatorData.InnerText = m_HomeURI + ";" + creator.FirstName + " " + creator.LastName; sop.AppendChild(creatorData); } } diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs index bf24ebc..0c4ff7f 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs @@ -54,7 +54,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess get { return m_assMapper; } } - private string m_ProfileServerURI; + private string m_HomeURI; private bool m_OutboundPermission; private string m_ThisGatekeeper; @@ -84,7 +84,10 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess IConfig thisModuleConfig = source.Configs["HGInventoryAccessModule"]; if (thisModuleConfig != null) { - m_ProfileServerURI = thisModuleConfig.GetString("ProfileServerURI", string.Empty); + // legacy configuration [obsolete] + m_HomeURI = thisModuleConfig.GetString("ProfileServerURI", string.Empty); + // preferred + m_HomeURI = thisModuleConfig.GetString("HomeURI", m_HomeURI); m_OutboundPermission = thisModuleConfig.GetBoolean("OutboundPermission", true); m_ThisGatekeeper = thisModuleConfig.GetString("Gatekeeper", string.Empty); } @@ -100,7 +103,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess return; base.AddRegion(scene); - m_assMapper = new HGAssetMapper(scene, m_ProfileServerURI); + m_assMapper = new HGAssetMapper(scene, m_HomeURI); scene.EventManager.OnNewInventoryItemUploadComplete += UploadInventoryItem; } diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs index f44a3ba..0707cbe 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs @@ -125,8 +125,12 @@ namespace OpenSim.Region.CoreModules.World.Archiver Dictionary options = new Dictionary(); OptionSet ops = new OptionSet(); -// ops.Add("v|version=", delegate(string v) { options["version"] = v; }); - ops.Add("p|profile=", delegate(string v) { options["profile"] = v; }); + + // legacy argument [obsolete] + ops.Add("p|profile=", delegate(string v) { Console.WriteLine("\n WARNING: -profile option is obsolete and it will not work. Use -home instead.\n"); }); + // preferred + ops.Add("h|home=", delegate(string v) { options["home"] = v; }); + ops.Add("noassets", delegate(string v) { options["noassets"] = v != null; }); ops.Add("perm=", delegate(string v) { options["checkPermissions"] = v; }); diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 51d3586..e9c33eb 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -394,7 +394,7 @@ namespace OpenSim.Region.Framework.Scenes private string m_creatorData = string.Empty; /// - /// Data about the creator in the form profile_url;name + /// Data about the creator in the form home_url;name /// public string CreatorData { @@ -405,7 +405,7 @@ namespace OpenSim.Region.Framework.Scenes /// /// Used by the DB layer to retrieve / store the entire user identification. /// The identification can either be a simple UUID or a string of the form - /// uuid[;profile_url[;name]] + /// uuid[;home_url[;name]] /// public string CreatorIdentification { diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index 38d1231..7c60ddd 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs @@ -1134,12 +1134,12 @@ namespace OpenSim.Region.Framework.Scenes.Serialization if (sop.CreatorData != null && sop.CreatorData != string.Empty) writer.WriteElementString("CreatorData", sop.CreatorData); - else if (options.ContainsKey("profile")) + else if (options.ContainsKey("home")) { if (m_UserManagement == null) m_UserManagement = sop.ParentGroup.Scene.RequestModuleInterface(); string name = m_UserManagement.GetUserName(sop.CreatorID); - writer.WriteElementString("CreatorData", (string)options["profile"] + "/" + sop.CreatorID + ";" + name); + writer.WriteElementString("CreatorData", (string)options["home"] + ";" + name); } WriteUUID(writer, "FolderID", sop.FolderID, options); @@ -1282,12 +1282,12 @@ namespace OpenSim.Region.Framework.Scenes.Serialization if (item.CreatorData != null && item.CreatorData != string.Empty) writer.WriteElementString("CreatorData", item.CreatorData); - else if (options.ContainsKey("profile")) + else if (options.ContainsKey("home")) { if (m_UserManagement == null) m_UserManagement = scene.RequestModuleInterface(); string name = m_UserManagement.GetUserName(item.CreatorID); - writer.WriteElementString("CreatorData", (string)options["profile"] + "/" + item.CreatorID + ";" + name); + writer.WriteElementString("CreatorData", (string)options["home"] + ";" + name); } writer.WriteElementString("Description", item.Description); diff --git a/OpenSim/Services/HypergridService/HGAssetService.cs b/OpenSim/Services/HypergridService/HGAssetService.cs index e518329..22e233a 100644 --- a/OpenSim/Services/HypergridService/HGAssetService.cs +++ b/OpenSim/Services/HypergridService/HGAssetService.cs @@ -53,7 +53,7 @@ namespace OpenSim.Services.HypergridService LogManager.GetLogger( MethodBase.GetCurrentMethod().DeclaringType); - private string m_ProfileServiceURL; + private string m_HomeURL; private IUserAccountService m_UserAccountService; private UserAccountCache m_Cache; @@ -74,7 +74,10 @@ namespace OpenSim.Services.HypergridService if (m_UserAccountService == null) throw new Exception(String.Format("Unable to create UserAccountService from {0}", userAccountsDll)); - m_ProfileServiceURL = assetConfig.GetString("ProfileServerURI", string.Empty); + // legacy configuration [obsolete] + m_HomeURL = assetConfig.GetString("ProfileServerURI", string.Empty); + // Preferred + m_HomeURL = assetConfig.GetString("HomeURI", m_HomeURL); m_Cache = UserAccountCache.CreateUserAccountCache(m_UserAccountService); } @@ -134,13 +137,13 @@ namespace OpenSim.Services.HypergridService UserAccount creator = m_Cache.GetUser(meta.CreatorID); if (creator != null) - meta.CreatorID = m_ProfileServiceURL + "/" + meta.CreatorID + ";" + creator.FirstName + " " + creator.LastName; + meta.CreatorID = meta.CreatorID + ";" + m_HomeURL + "/" + creator.FirstName + " " + creator.LastName; } protected byte[] AdjustIdentifiers(byte[] data) { string xml = Utils.BytesToString(data); - return Utils.StringToBytes(ExternalRepresentationUtils.RewriteSOP(xml, m_ProfileServiceURL, m_Cache, UUID.Zero)); + return Utils.StringToBytes(ExternalRepresentationUtils.RewriteSOP(xml, m_HomeURL, m_Cache, UUID.Zero)); } } diff --git a/OpenSim/Services/HypergridService/HGInventoryService.cs b/OpenSim/Services/HypergridService/HGInventoryService.cs index 4eb61ba..daf8c3a 100644 --- a/OpenSim/Services/HypergridService/HGInventoryService.cs +++ b/OpenSim/Services/HypergridService/HGInventoryService.cs @@ -55,7 +55,7 @@ namespace OpenSim.Services.HypergridService protected new IXInventoryData m_Database; - private string m_ProfileServiceURL; + private string m_HomeURL; private IUserAccountService m_UserAccountService; private UserAccountCache m_Cache; @@ -100,7 +100,10 @@ namespace OpenSim.Services.HypergridService if (m_UserAccountService == null) throw new Exception(String.Format("Unable to create UserAccountService from {0}", userAccountsDll)); - m_ProfileServiceURL = invConfig.GetString("ProfileServerURI", string.Empty); + // legacy configuration [obsolete] + m_HomeURL = invConfig.GetString("ProfileServerURI", string.Empty); + // Preferred + m_HomeURL = invConfig.GetString("HomeURI", m_HomeURL); m_Cache = UserAccountCache.CreateUserAccountCache(m_UserAccountService); } @@ -321,7 +324,7 @@ namespace OpenSim.Services.HypergridService // Adjust the creator data if (user != null && it != null && (it.CreatorData == null || it.CreatorData == string.Empty)) - it.CreatorData = m_ProfileServiceURL + "/" + it.CreatorId + ";" + user.FirstName + " " + user.LastName; + it.CreatorData = m_HomeURL + ";" + user.FirstName + " " + user.LastName; return it; } -- cgit v1.1 From b47c0d7e51bdb4d4bfa34f0952593f94c657d19c Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 12 Jan 2012 18:14:19 +0000 Subject: refactor: Move existing npc owner checks to NPCModule.CheckPermissions() methods and expose on interface for external calls. --- OpenSim/Region/Framework/Interfaces/INPCModule.cs | 8 ++++ .../Region/OptionalModules/World/NPC/NPCModule.cs | 49 ++++++++++++++++------ .../Shared/Api/Implementation/OSSL_Api.cs | 6 +-- 3 files changed, 45 insertions(+), 18 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Interfaces/INPCModule.cs b/OpenSim/Region/Framework/Interfaces/INPCModule.cs index cac8479..3ec1bda 100644 --- a/OpenSim/Region/Framework/Interfaces/INPCModule.cs +++ b/OpenSim/Region/Framework/Interfaces/INPCModule.cs @@ -53,6 +53,14 @@ namespace OpenSim.Region.Framework.Interfaces bool IsNPC(UUID agentID, Scene scene); /// + /// Check if the caller has permission to manipulate the given NPC. + /// + /// + /// + /// true if they do, false if they don't or if there's no NPC with the given ID. + bool CheckPermissions(UUID npcID, UUID callerID); + + /// /// Set the appearance for an NPC. /// /// diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index e874417..8f9b513 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs @@ -56,6 +56,24 @@ namespace OpenSim.Region.OptionalModules.World.NPC } } + public void PostInitialise() + { + } + + public void Close() + { + } + + public string Name + { + get { return "NPCModule"; } + } + + public bool IsSharedModule + { + get { return true; } + } + public bool IsNPC(UUID agentId, Scene scene) { // FIXME: This implementation could not just use the ScenePresence.PresenceType (and callers could inspect @@ -255,7 +273,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC NPCAvatar av; if (m_avatars.TryGetValue(agentID, out av)) { - if (av.OwnerID != UUID.Zero && callerID != UUID.Zero && av.OwnerID != callerID) + if (!CheckPermissions(av, callerID)); return false; scene.RemoveClient(agentID, false); @@ -268,22 +286,27 @@ namespace OpenSim.Region.OptionalModules.World.NPC return false; } - public void PostInitialise() - { - } - - public void Close() - { - } - - public string Name + public bool CheckPermissions(UUID npcID, UUID callerID) { - get { return "NPCModule"; } + lock (m_avatars) + { + NPCAvatar av; + if (m_avatars.TryGetValue(npcID, out av)) + return CheckPermissions(av, callerID); + else + return false; + } } - public bool IsSharedModule + /// + /// Check if the caller has permission to manipulate the given NPC. + /// + /// + /// + /// true if they do, false if they don't. + private bool CheckPermissions(NPCAvatar av, UUID callerID) { - get { return true; } + return callerID == UUID.Zero || av.OwnerID == UUID.Zero || av.OwnerID == callerID; } } } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index e2a045b..1d7a210 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -2152,11 +2152,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (!UUID.TryParse(npc.m_string, out npcId)) return new LSL_Key(UUID.Zero.ToString()); - if (!npcModule.IsNPC(npcId, m_host.ParentGroup.Scene)) - return new LSL_Key(UUID.Zero.ToString()); - - UUID ownerID = npcModule.GetOwner(npcId); - if (ownerID != UUID.Zero && ownerID != m_host.OwnerID) + if (!npcModule.CheckPermissions(npcId, m_host.OwnerID)) return new LSL_Key(UUID.Zero.ToString()); return SaveAppearanceToNotecard(npcId, notecard); -- cgit v1.1 From cadd645076eacd6bd0b70a665ed3f5157cd6e5d3 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 12 Jan 2012 10:22:52 -0800 Subject: Renamed one var and deleted commented code. No functional changes. --- .../UserManagement/UserManagementModule.cs | 35 ++-------------------- .../Region/Framework/Interfaces/IUserManagement.cs | 2 +- 2 files changed, 3 insertions(+), 34 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs index 2ad30a0..80ab30c 100644 --- a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs +++ b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs @@ -413,14 +413,13 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement user.Id = uuid; user.FirstName = first; user.LastName = last; - // user.ProfileURL = we should initialize this to the default AddUserInternal(user); } - public void AddUser(UUID uuid, string first, string last, string profileURL) + public void AddUser(UUID uuid, string first, string last, string homeURL) { - AddUser(uuid, profileURL + ";" + first + " " + last); + AddUser(uuid, homeURL + ";" + first + " " + last); } public void AddUser (UUID id, string creatorData) @@ -492,36 +491,6 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement // user.Id, user.FirstName, user.LastName, user.HomeURL); } - //public void AddUser(UUID uuid, string userData) - //{ - // if (m_UserCache.ContainsKey(uuid)) - // return; - - // UserData user = new UserData(); - // user.Id = uuid; - - // // userData = ; - // string[] parts = userData.Split(';'); - // if (parts.Length >= 1) - // user.ProfileURL = parts[0].Trim(); - // if (parts.Length >= 2) - // { - // string[] name = parts[1].Trim().Split(' '); - // if (name.Length >= 1) - // user.FirstName = name[0]; - // if (name.Length >= 2) - // user.LastName = name[1]; - // else - // user.LastName = "?"; - // } - - // lock (m_UserCache) - // m_UserCache.Add(uuid, user); - - // m_log.DebugFormat("[USER MANAGEMENT MODULE]: Added user {0} {1} {2} {3}", user.Id, user.FirstName, user.LastName, user.ProfileURL); - - //} - public bool IsLocalGridUser(UUID uuid) { UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount(m_Scenes[0].RegionInfo.ScopeID, uuid); diff --git a/OpenSim/Region/Framework/Interfaces/IUserManagement.cs b/OpenSim/Region/Framework/Interfaces/IUserManagement.cs index 54dfaf4..4f62e28 100644 --- a/OpenSim/Region/Framework/Interfaces/IUserManagement.cs +++ b/OpenSim/Region/Framework/Interfaces/IUserManagement.cs @@ -50,7 +50,7 @@ namespace OpenSim.Region.Framework.Interfaces /// /// /// - void AddUser(UUID uuid, string firstName, string lastName, string profileURL); + void AddUser(UUID uuid, string firstName, string lastName, string homeURL); bool IsLocalGridUser(UUID uuid); } -- cgit v1.1 From ba3491c76e2d7cc7187a025dccd782790929f0b7 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 12 Jan 2012 19:06:46 +0000 Subject: Add permissions checks for owned avatars to all other osNpc* functions. This is being done outside the npc module since the check is meaningless for region module callers, who can fake any id that they like. --- OpenSim/Region/Framework/Interfaces/INPCModule.cs | 2 +- .../Region/OptionalModules/World/NPC/NPCModule.cs | 5 +- .../Shared/Api/Implementation/OSSL_Api.cs | 70 +++++++++++++++------- 3 files changed, 52 insertions(+), 25 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Interfaces/INPCModule.cs b/OpenSim/Region/Framework/Interfaces/INPCModule.cs index 3ec1bda..c50e734 100644 --- a/OpenSim/Region/Framework/Interfaces/INPCModule.cs +++ b/OpenSim/Region/Framework/Interfaces/INPCModule.cs @@ -125,7 +125,7 @@ namespace OpenSim.Region.Framework.Interfaces /// The UUID of the NPC /// /// True if the operation succeeded, false if there was no such agent or the agent was not an NPC - bool DeleteNPC(UUID agentID, UUID CallerID, Scene scene); + bool DeleteNPC(UUID agentID, Scene scene); /// /// Get the owner of a NPC diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index 8f9b513..d90309f 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs @@ -266,16 +266,13 @@ namespace OpenSim.Region.OptionalModules.World.NPC return UUID.Zero; } - public bool DeleteNPC(UUID agentID, UUID callerID, Scene scene) + public bool DeleteNPC(UUID agentID, Scene scene) { lock (m_avatars) { NPCAvatar av; if (m_avatars.TryGetValue(agentID, out av)) { - if (!CheckPermissions(av, callerID)); - return false; - scene.RemoveClient(agentID, false); m_avatars.Remove(agentID); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 1d7a210..509bbec 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -2173,6 +2173,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (!UUID.TryParse(npc.m_string, out npcId)) return; + if (!npcModule.CheckPermissions(npcId, m_host.OwnerID)) + return; + string appearanceSerialized = LoadNotecard(notecard); OSDMap appearanceOsd = (OSDMap)OSDParser.DeserializeLLSDXml(appearanceSerialized); // OSD a = OSDParser.DeserializeLLSDXml(appearanceSerialized); @@ -2196,7 +2199,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (!UUID.TryParse(npc.m_string, out npcId)) return new LSL_Vector(0, 0, 0); - if (!npcModule.IsNPC(npcId, m_host.ParentGroup.Scene)) + if (!npcModule.CheckPermissions(npcId, m_host.OwnerID)) return new LSL_Vector(0, 0, 0); Vector3 pos = World.GetScenePresence(npcId).AbsolutePosition; @@ -2216,6 +2219,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api UUID npcId; if (!UUID.TryParse(npc.m_string, out npcId)) return; + + if (!module.CheckPermissions(npcId, m_host.OwnerID)) + return; Vector3 pos = new Vector3((float) position.x, (float) position.y, (float) position.z); module.MoveToTarget(npcId, World, pos, false, true); @@ -2233,6 +2239,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (!UUID.TryParse(npc.m_string, out npcId)) return; + if (!module.CheckPermissions(npcId, m_host.OwnerID)) + return; + Vector3 pos = new Vector3((float)target.x, (float)target.y, (float)target.z); module.MoveToTarget( new UUID(npc.m_string), @@ -2254,7 +2263,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (!UUID.TryParse(npc.m_string, out npcId)) return new LSL_Rotation(Quaternion.Identity.X, Quaternion.Identity.Y, Quaternion.Identity.Z, Quaternion.Identity.W); - if (!npcModule.IsNPC(npcId, m_host.ParentGroup.Scene)) + if (!npcModule.CheckPermissions(npcId, m_host.OwnerID)) return new LSL_Rotation(Quaternion.Identity.X, Quaternion.Identity.Y, Quaternion.Identity.Z, Quaternion.Identity.W); ScenePresence sp = World.GetScenePresence(npcId); @@ -2277,7 +2286,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (!UUID.TryParse(npc.m_string, out npcId)) return; - if (!npcModule.IsNPC(npcId, m_host.ParentGroup.Scene)) + if (!npcModule.CheckPermissions(npcId, m_host.OwnerID)) return; ScenePresence sp = World.GetScenePresence(npcId); @@ -2291,7 +2300,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api INPCModule module = World.RequestModuleInterface(); if (module != null) - module.StopMoveToTarget(new UUID(npc.m_string), World); + { + UUID npcId = new UUID(npc.m_string); + + if (!module.CheckPermissions(npcId, m_host.OwnerID)) + return; + + module.StopMoveToTarget(npcId, World); + } } public void osNpcSay(LSL_Key npc, string message) @@ -2301,7 +2317,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api INPCModule module = World.RequestModuleInterface(); if (module != null) { - module.Say(new UUID(npc.m_string), World, message); + UUID npcId = new UUID(npc.m_string); + + if (!module.CheckPermissions(npcId, m_host.OwnerID)) + return; + + module.Say(npcId, World, message); } } @@ -2312,7 +2333,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api INPCModule module = World.RequestModuleInterface(); if (module != null) { - module.Sit(new UUID(npc.m_string), new UUID(target.m_string), World); + UUID npcId = new UUID(npc.m_string); + + if (!module.CheckPermissions(npcId, m_host.OwnerID)) + return; + + module.Sit(npcId, new UUID(target.m_string), World); } } @@ -2323,7 +2349,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api INPCModule module = World.RequestModuleInterface(); if (module != null) { - module.Stand(new UUID(npc.m_string), World); + UUID npcId = new UUID(npc.m_string); + + if (!module.CheckPermissions(npcId, m_host.OwnerID)) + return; + + module.Stand(npcId, World); } } @@ -2334,7 +2365,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api INPCModule module = World.RequestModuleInterface(); if (module != null) { - module.DeleteNPC(new UUID(npc.m_string), m_host.OwnerID, World); + UUID npcId = new UUID(npc.m_string); + + if (!module.CheckPermissions(npcId, m_host.OwnerID)) + return; + + module.DeleteNPC(npcId, World); } } @@ -2346,12 +2382,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (module != null) { UUID npcID = new UUID(npc.m_string); - if (module.IsNPC(npcID, m_host.ParentGroup.Scene)) - { - UUID ownerID = module.GetOwner(npcID); - if (ownerID == UUID.Zero || ownerID == m_host.OwnerID) - AvatarPlayAnimation(npcID.ToString(), animation); - } + + if (module.CheckPermissions(npcID, m_host.OwnerID)) + AvatarPlayAnimation(npcID.ToString(), animation); } } @@ -2363,12 +2396,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (module != null) { UUID npcID = new UUID(npc.m_string); - if (module.IsNPC(npcID, m_host.ParentGroup.Scene)) - { - UUID ownerID = module.GetOwner(npcID); - if (ownerID == UUID.Zero || ownerID == m_host.OwnerID) - AvatarStopAnimation(npcID.ToString(), animation); - } + + if (module.CheckPermissions(npcID, m_host.OwnerID)) + AvatarPlayAnimation(npcID.ToString(), animation); } } -- cgit v1.1 From d27dd3714f77aa37db1eeb241401270163cd236d Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 12 Jan 2012 19:19:34 +0000 Subject: Allow all NPCs to show up on sensors as all osNpc* script methods now check for ownership permission before executing. As per #opensim-dev irc discussion. --- .../Shared/Api/Implementation/Plugins/SensorRepeat.cs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs index 7d7813d..8356dce 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs @@ -463,12 +463,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins toRegionPos = presence.AbsolutePosition; dis = Math.Abs(Util.GetDistanceTo(toRegionPos, fromRegionPos)); - if (presence.PresenceType == PresenceType.Npc && npcModule != null) - { - UUID npcOwner = npcModule.GetOwner(presence.UUID); - if (npcOwner != UUID.Zero && npcOwner != SensePoint.OwnerID) - return; - } + // Disabled for now since all osNpc* methods check for appropriate ownership permission. + // Perhaps could be re-enabled as an NPC setting at some point since being able to make NPCs not + // sensed might be useful. +// if (presence.PresenceType == PresenceType.Npc && npcModule != null) +// { +// UUID npcOwner = npcModule.GetOwner(presence.UUID); +// if (npcOwner != UUID.Zero && npcOwner != SensePoint.OwnerID) +// return; +// } // are they in range if (dis <= ts.range) -- cgit v1.1 From c4972e773465172d33d72f94d3f5e37cec1b8831 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 12 Jan 2012 19:37:30 +0000 Subject: Add osNpcCreate(string firstname, string lastname, LSL_Vector position, string notecard, int options) variant. This will be documented soon. Options can currently be OS_NPC_CREATE_OWNED - creates a 'creator owned' avatar that will only respond to osNpc* functions made by scripts owned by the npc creator OS_NPC_NOT_OWNED - creates an avatar which will respond to any osNpc* functions that a caller has permission to make (through the usual OSSL permission mechanisms). options is being added to provide better scope for future extensibility without having to add more functions The original non-options osNpcCreate() function will continue to exist. --- OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 6 ++++++ OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | 1 + OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs | 3 +++ OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | 5 +++++ 4 files changed, 15 insertions(+) (limited to 'OpenSim') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 509bbec..25e4789 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -2089,6 +2089,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return NpcCreate(firstname, lastname, position, notecard, false); } + public LSL_Key osNpcCreate(string firstname, string lastname, LSL_Vector position, string notecard, int options) + { + CheckThreatLevel(ThreatLevel.High, "osNpcCreate"); + return NpcCreate(firstname, lastname, position, notecard, (options & ScriptBaseClass.OS_NPC_NOT_OWNED) == 0); + } + private LSL_Key NpcCreate(string firstname, string lastname, LSL_Vector position, string notecard, bool owned) { INPCModule module = World.RequestModuleInterface(); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index f92f51f..ddfc20d 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs @@ -172,6 +172,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces LSL_List osGetLinkPrimitiveParams(int linknumber, LSL_List rules); key osNpcCreate(string user, string name, vector position, string notecard); + key osNpcCreate(string user, string name, vector position, string notecard, int options); key osNpcCreateOwned(string user, string name, vector position, string notecard); LSL_Key osNpcSaveAppearance(key npc, string notecard); void osNpcLoadAppearance(key npc, string notecard); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs index b58cf57..176dc56 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs @@ -606,6 +606,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase public const int OS_NPC_SIT_NOW = 0; + public const int OS_NPC_CREATOR_OWNED = 0x1; + public const int OS_NPC_NOT_OWNED = 0x2; + public const string URL_REQUEST_GRANTED = "URL_REQUEST_GRANTED"; public const string URL_REQUEST_DENIED = "URL_REQUEST_DENIED"; diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs index a94392a..ceccceb 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs @@ -488,6 +488,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase return m_OSSL_Functions.osNpcCreate(user, name, position, cloneFrom); } + public key osNpcCreate(string user, string name, vector position, key cloneFrom, int options) + { + return m_OSSL_Functions.osNpcCreate(user, name, position, cloneFrom, options); + } + public key osNpcCreateOwned(string user, string name, vector position, key cloneFrom) { return m_OSSL_Functions.osNpcCreateOwned(user, name, position, cloneFrom); -- cgit v1.1 From 1ac5aa68087910dbb3cdfc141d77a95eb89177fa Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 12 Jan 2012 20:47:19 +0000 Subject: Add remove test for unowned avatars --- .../World/NPC/Tests/NPCModuleTests.cs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'OpenSim') diff --git a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs index 571d33d..d21d601 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs @@ -119,6 +119,26 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests } [Test] + public void TestRemove() + { + TestHelpers.InMethod(); +// log4net.Config.XmlConfigurator.Configure(); + + ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1)); +// ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId); + + Vector3 startPos = new Vector3(128, 128, 30); + INPCModule npcModule = scene.RequestModuleInterface(); + UUID npcId = npcModule.CreateNPC("John", "Smith", startPos, UUID.Zero, scene, sp.Appearance); + + npcModule.DeleteNPC(npcId, scene); + + ScenePresence deletedNpc = scene.GetScenePresence(npcId); + + Assert.That(deletedNpc, Is.Null); + } + + [Test] public void TestAttachments() { TestHelpers.InMethod(); -- cgit v1.1 From caa207f59f5c7e9160715172e22bd59659abbeb4 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 12 Jan 2012 21:03:54 +0000 Subject: Add ossl level test for removing an unowned npc --- .../ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs | 115 +++++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs (limited to 'OpenSim') diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs new file mode 100644 index 0000000..c4832c9 --- /dev/null +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs @@ -0,0 +1,115 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using System.Reflection; +using System.Text; +using log4net; +using Nini.Config; +using NUnit.Framework; +using OpenMetaverse; +using OpenMetaverse.Assets; +using OpenMetaverse.StructuredData; +using OpenSim.Framework; +using OpenSim.Region.CoreModules.Avatar.AvatarFactory; +using OpenSim.Region.OptionalModules.World.NPC; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Region.ScriptEngine.Shared; +using OpenSim.Region.ScriptEngine.Shared.Api; +using OpenSim.Region.ScriptEngine.Shared.ScriptBase; +using OpenSim.Services.Interfaces; +using OpenSim.Tests.Common; +using OpenSim.Tests.Common.Mock; + +namespace OpenSim.Region.ScriptEngine.Shared.Tests +{ + /// + /// Tests for OSSL NPC API + /// + [TestFixture] + public class OSSL_NpcApiAppearanceTest + { + protected Scene m_scene; + protected XEngine.XEngine m_engine; + + [SetUp] + public void SetUp() + { + IConfigSource initConfigSource = new IniConfigSource(); + IConfig config = initConfigSource.AddConfig("XEngine"); + config.Set("Enabled", "true"); + config.Set("AllowOSFunctions", "true"); + config.Set("OSFunctionThreatLevel", "Severe"); + config = initConfigSource.AddConfig("NPC"); + config.Set("Enabled", "true"); + + m_scene = SceneHelpers.SetupScene(); + SceneHelpers.SetupSceneModules(m_scene, initConfigSource, new AvatarFactoryModule(), new NPCModule()); + + m_engine = new XEngine.XEngine(); + m_engine.Initialise(initConfigSource); + m_engine.AddRegion(m_scene); + } + + /// + /// Test creation of an NPC where the appearance data comes from an avatar already in the region. + /// + [Test] + public void TestOsNpcRemove() + { + TestHelpers.InMethod(); +// log4net.Config.XmlConfigurator.Configure(); + + // Store an avatar with a different height from default in a notecard. + UUID userId = TestHelpers.ParseTail(0x1); + float newHeight = 1.9f; + + ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId); + sp.Appearance.AvatarHeight = newHeight; + SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId); + SceneObjectPart part = so.RootPart; + m_scene.AddSceneObject(so); + + OSSL_Api osslApi = new OSSL_Api(); + osslApi.Initialize(m_engine, part, part.LocalId, part.UUID); + + string notecardName = "appearanceNc"; + osslApi.osOwnerSaveAppearance(notecardName); + + string npcRaw + = osslApi.osNpcCreate( + "Jane", "Doe", new LSL_Types.Vector3(128, 128, 128), notecardName, ScriptBaseClass.OS_NPC_NOT_OWNED); + + osslApi.osNpcRemove(npcRaw); + + UUID npcId = new UUID(npcRaw); + ScenePresence npc = m_scene.GetScenePresence(npcId); + Assert.That(npc, Is.Null); + } + } +} \ No newline at end of file -- cgit v1.1 From beab155434b1ea4338004496fd35df2a22170960 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 12 Jan 2012 22:35:11 +0000 Subject: Add api level test for removing an owned npc --- .../ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs | 57 +++++++++++++++++++++- 1 file changed, 55 insertions(+), 2 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs index c4832c9..f0b28b2 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs @@ -77,10 +77,63 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests } /// - /// Test creation of an NPC where the appearance data comes from an avatar already in the region. + /// Test removal of an owned NPC. /// [Test] - public void TestOsNpcRemove() + public void TestOsNpcRemoveOwned() + { + TestHelpers.InMethod(); +// log4net.Config.XmlConfigurator.Configure(); + + // Store an avatar with a different height from default in a notecard. + UUID userId = TestHelpers.ParseTail(0x1); + UUID otherUserId = TestHelpers.ParseTail(0x2); + float newHeight = 1.9f; + + SceneHelpers.AddScenePresence(m_scene, otherUserId); + + ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId); + sp.Appearance.AvatarHeight = newHeight; + + SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId); + SceneObjectPart part = so.RootPart; + m_scene.AddSceneObject(so); + + SceneObjectGroup otherSo = SceneHelpers.CreateSceneObject(1, otherUserId); + SceneObjectPart otherPart = otherSo.RootPart; + m_scene.AddSceneObject(otherSo); + + OSSL_Api osslApi = new OSSL_Api(); + osslApi.Initialize(m_engine, part, part.LocalId, part.UUID); + + OSSL_Api otherOsslApi = new OSSL_Api(); + otherOsslApi.Initialize(m_engine, otherPart, otherPart.LocalId, otherPart.UUID); + + string notecardName = "appearanceNc"; + osslApi.osOwnerSaveAppearance(notecardName); + + string npcRaw + = osslApi.osNpcCreate( + "Jane", "Doe", new LSL_Types.Vector3(128, 128, 128), notecardName, ScriptBaseClass.OS_NPC_CREATOR_OWNED); + + otherOsslApi.osNpcRemove(npcRaw); + + // Should still be around + UUID npcId = new UUID(npcRaw); + ScenePresence npc = m_scene.GetScenePresence(npcId); + Assert.That(npc, Is.Not.Null); + + osslApi.osNpcRemove(npcRaw); + + npc = m_scene.GetScenePresence(npcId); + + } + + /// + /// Test removal of an unowned NPC. + /// + [Test] + public void TestOsNpcRemoveUnowned() { TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); -- cgit v1.1 From 47377f17c626515747f507014301c6c101791014 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 12 Jan 2012 23:46:43 +0000 Subject: Add missing assert to confirm owner delete succeeded to the end of TestOsNpcRemoveOwned() --- OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'OpenSim') diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs index f0b28b2..9d9fc51 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs @@ -127,6 +127,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests npc = m_scene.GetScenePresence(npcId); + // Now the owner deleted it and it's gone + Assert.That(npc, Is.Null); } /// -- cgit v1.1 From 6e7154d55c4b5ab8dacd2bcbce3b5408470b7f48 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 13 Jan 2012 00:00:18 +0000 Subject: Removing osNpcCreateOwned(). Please use osNpcCreate(string user, string name, vector position, string notecard, int options) instead with option OS_NPC_CREATOR_OWNED Please note that correct option name is OS_NPC_CREATOR_OWNED not OS_NPC_CREATE_OWNED as mistakenly put in a previous commit. --- OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 6 ------ OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | 1 - OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | 5 ----- 3 files changed, 12 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 25e4789..2c35f58 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -2077,12 +2077,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return retVal; } - public LSL_Key osNpcCreateOwned(string firstname, string lastname, LSL_Vector position, string notecard) - { - CheckThreatLevel(ThreatLevel.High, "osNpcCreateOwned"); - return NpcCreate(firstname, lastname, position, notecard, true); - } - public LSL_Key osNpcCreate(string firstname, string lastname, LSL_Vector position, string notecard) { CheckThreatLevel(ThreatLevel.High, "osNpcCreate"); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index ddfc20d..af6be5f 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs @@ -173,7 +173,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces key osNpcCreate(string user, string name, vector position, string notecard); key osNpcCreate(string user, string name, vector position, string notecard, int options); - key osNpcCreateOwned(string user, string name, vector position, string notecard); LSL_Key osNpcSaveAppearance(key npc, string notecard); void osNpcLoadAppearance(key npc, string notecard); vector osNpcGetPos(key npc); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs index ceccceb..0c05ea4 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs @@ -493,11 +493,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase return m_OSSL_Functions.osNpcCreate(user, name, position, cloneFrom, options); } - public key osNpcCreateOwned(string user, string name, vector position, key cloneFrom) - { - return m_OSSL_Functions.osNpcCreateOwned(user, name, position, cloneFrom); - } - public key osNpcSaveAppearance(key npc, string notecard) { return m_OSSL_Functions.osNpcSaveAppearance(npc, notecard); -- cgit v1.1 From 3b59af222580e6d6e1a938ab622961285bd6903c Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 13 Jan 2012 00:03:39 +0000 Subject: Change the default osNpcCreate() to create an 'owned' npc rather than an 'unowned' one. An owned NPC is one that only the original creator can manipulate and delete. An unowned NPC is one that anybody with access to the osNpc* methods and knowledge of the avatar id can manipulate. This is to correct an oversight I made in the original reimplementation where I mistakenly assumed that avatar IDs could be treated as private. I am not anticipating that many people were deliberately making use of unowned npcs due to their insecure nature. If you do need an unowned NPC please call the new overloaded osCreateNpc() function with the option OS_NPC_NOT_OWNED. --- OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 2c35f58..40d9d6f 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -2080,7 +2080,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Key osNpcCreate(string firstname, string lastname, LSL_Vector position, string notecard) { CheckThreatLevel(ThreatLevel.High, "osNpcCreate"); - return NpcCreate(firstname, lastname, position, notecard, false); + return NpcCreate(firstname, lastname, position, notecard, true); } public LSL_Key osNpcCreate(string firstname, string lastname, LSL_Vector position, string notecard, int options) -- cgit v1.1 From d40ec1c346d4b5f5999218bf1cbffe9cee1ea992 Mon Sep 17 00:00:00 2001 From: BlueWall Date: Thu, 12 Jan 2012 20:49:50 -0500 Subject: Move some interfaces to a more apropriate place --- OpenSim/Framework/IProfileModule.cs | 37 ---------------------- OpenSim/Framework/ISearchModule.cs | 36 --------------------- .../Region/Framework/Interfaces/IProfileModule.cs | 37 ++++++++++++++++++++++ .../Region/Framework/Interfaces/ISearchModule.cs | 36 +++++++++++++++++++++ 4 files changed, 73 insertions(+), 73 deletions(-) delete mode 100644 OpenSim/Framework/IProfileModule.cs delete mode 100644 OpenSim/Framework/ISearchModule.cs create mode 100644 OpenSim/Region/Framework/Interfaces/IProfileModule.cs create mode 100644 OpenSim/Region/Framework/Interfaces/ISearchModule.cs (limited to 'OpenSim') diff --git a/OpenSim/Framework/IProfileModule.cs b/OpenSim/Framework/IProfileModule.cs deleted file mode 100644 index ef03d4a..0000000 --- a/OpenSim/Framework/IProfileModule.cs +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using OpenMetaverse; - -namespace OpenSim.Framework -{ - public interface IProfileModule - { - void RequestAvatarProperties(IClientAPI remoteClient, UUID avatarID); - - } -} diff --git a/OpenSim/Framework/ISearchModule.cs b/OpenSim/Framework/ISearchModule.cs deleted file mode 100644 index 64bf72c..0000000 --- a/OpenSim/Framework/ISearchModule.cs +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using OpenMetaverse; - -namespace OpenSim.Framework -{ - public interface ISearchModule - { - - } -} diff --git a/OpenSim/Region/Framework/Interfaces/IProfileModule.cs b/OpenSim/Region/Framework/Interfaces/IProfileModule.cs new file mode 100644 index 0000000..ef03d4a --- /dev/null +++ b/OpenSim/Region/Framework/Interfaces/IProfileModule.cs @@ -0,0 +1,37 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using OpenMetaverse; + +namespace OpenSim.Framework +{ + public interface IProfileModule + { + void RequestAvatarProperties(IClientAPI remoteClient, UUID avatarID); + + } +} diff --git a/OpenSim/Region/Framework/Interfaces/ISearchModule.cs b/OpenSim/Region/Framework/Interfaces/ISearchModule.cs new file mode 100644 index 0000000..64bf72c --- /dev/null +++ b/OpenSim/Region/Framework/Interfaces/ISearchModule.cs @@ -0,0 +1,36 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using OpenMetaverse; + +namespace OpenSim.Framework +{ + public interface ISearchModule + { + + } +} -- cgit v1.1 From c5594e839e55beb72f9132ebe29a877f62f99138 Mon Sep 17 00:00:00 2001 From: BlueWall Date: Thu, 12 Jan 2012 21:19:31 -0500 Subject: Undo some prior work Move some added fuctions out of core into the addon module to keep things clean --- .../UserManagement/UserManagementModule.cs | 93 ---------------------- .../Region/Framework/Interfaces/IUserManagement.cs | 3 - 2 files changed, 96 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs index 80ab30c..bbdf92a 100644 --- a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs +++ b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs @@ -50,9 +50,6 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement public string LastName { get; set; } public string HomeURL { get; set; } public Dictionary ServerURLs { get; set; } - public string Title { get; set; } - public int Flags { get; set; } - public int Created { get; set; } } public class UserManagementModule : ISharedRegionModule, IUserManagement @@ -284,94 +281,6 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement return string.Empty; } - public int GetUserFlags(UUID userID) - { - UserData userdata; - lock (m_UserCache) - m_UserCache.TryGetValue(userID, out userdata); - - if (userdata.Flags == -1) - GetUserInfo(userID); - - if (userdata.Flags != -1) - return userdata.Flags; - - return 0; - } - - public int GetUserCreated(UUID userID) - { - UserData userdata; - lock (m_UserCache) - m_UserCache.TryGetValue(userID, out userdata); - - if (userdata.Flags == -1) - GetUserInfo(userID); - - if (userdata.Created != -1) - return userdata.Created; - - return 0; - } - - public string GetUserTitle(UUID userID) - { - UserData userdata; - lock (m_UserCache) - m_UserCache.TryGetValue(userID, out userdata); - - if (userdata.Flags == -1) - GetUserInfo(userID); - - if (userdata.Created != -1) - return userdata.Title; - - return string.Empty; - } - - // This will cache the user data - // Change this to return bool - private bool GetUserInfo(UUID userID) - { - UserData userdata; - lock (m_UserCache) - m_UserCache.TryGetValue(userID, out userdata); - - if (userdata != null) - { -// m_log.DebugFormat("[USER MANAGEMENT MODULE]: Requested url type {0} for {1}", serverType, userID); - - if (userdata.Flags >= 0) - { - // This is already populated - return true; - } - - if (userdata.HomeURL != null && userdata.HomeURL != string.Empty) - { - m_log.DebugFormat( - "[USER MANAGEMENT MODULE]: Requesting user flags from '{0}' for {1}", - userdata.HomeURL, userID); - - UserAgentServiceConnector uConn = new UserAgentServiceConnector(userdata.HomeURL); - Dictionary info = uConn.GetUserInfo(userID); - - // Pull our data now - if (info["result"].ToString() == "success") - { - userdata.Flags = (int)info["user_flags"]; - userdata.Created = (int)info["user_created"]; - userdata.Title = (string)info["user_title"]; - - return true; - } - } - } - - return false; - } - - public string GetUserUUI(UUID userID) { UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount(m_Scenes[0].RegionInfo.ScopeID, userID); @@ -452,8 +361,6 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement } else { UserData user = new UserData (); user.Id = id; - user.Flags = -1; - user.Created = -1; if (creatorData != null && creatorData != string.Empty) { //creatorData = ; diff --git a/OpenSim/Region/Framework/Interfaces/IUserManagement.cs b/OpenSim/Region/Framework/Interfaces/IUserManagement.cs index 4f62e28..bfb8369 100644 --- a/OpenSim/Region/Framework/Interfaces/IUserManagement.cs +++ b/OpenSim/Region/Framework/Interfaces/IUserManagement.cs @@ -14,9 +14,6 @@ namespace OpenSim.Region.Framework.Interfaces string GetUserHomeURL(UUID uuid); string GetUserUUI(UUID uuid); string GetUserServerURL(UUID uuid, string serverType); - int GetUserFlags(UUID userID); - int GetUserCreated(UUID userID); - string GetUserTitle(UUID userID); /// /// Add a user. -- cgit v1.1 From 57ba9ef5ad05d2479a5bfb188d8a2827e63f0f0f Mon Sep 17 00:00:00 2001 From: BlueWall Date: Fri, 13 Jan 2012 11:35:44 -0500 Subject: Update RegionReadyModule Fix triggering of alerts when rezzing first script to an empty region, add login disable when loading oars. --- .../CoreModules/World/Archiver/ArchiverModule.cs | 10 +++- .../Framework/Interfaces/IRegionReadyModule.cs | 38 +++++++++++++++ .../RegionReadyModule/RegionReadyModule.cs | 57 +++++++++++++++++++--- 3 files changed, 98 insertions(+), 7 deletions(-) create mode 100644 OpenSim/Region/Framework/Interfaces/IRegionReadyModule.cs (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs index 0707cbe..a945fc2 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs @@ -98,6 +98,14 @@ namespace OpenSim.Region.CoreModules.World.Archiver OptionSet options = new OptionSet().Add("m|merge", delegate (string v) { mergeOar = v != null; }); options.Add("s|skip-assets", delegate (string v) { skipAssets = v != null; }); + + // Send a message to the region ready module + IRegionReadyModule rready = m_scene.RequestModuleInterface(); + + if (rready != null) + { + rready.OarLoadingAlert("load"); + } List mainParams = options.Parse(cmdparams); @@ -125,7 +133,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver Dictionary options = new Dictionary(); OptionSet ops = new OptionSet(); - + // legacy argument [obsolete] ops.Add("p|profile=", delegate(string v) { Console.WriteLine("\n WARNING: -profile option is obsolete and it will not work. Use -home instead.\n"); }); // preferred diff --git a/OpenSim/Region/Framework/Interfaces/IRegionReadyModule.cs b/OpenSim/Region/Framework/Interfaces/IRegionReadyModule.cs new file mode 100644 index 0000000..aa4a757 --- /dev/null +++ b/OpenSim/Region/Framework/Interfaces/IRegionReadyModule.cs @@ -0,0 +1,38 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +using System; + +namespace OpenSim.Region.Framework.Interfaces +{ + public interface IRegionReadyModule + { + void OarLoadingAlert(string msg); + } +} + diff --git a/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs b/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs index 4c4f5fb..f5d4da8 100644 --- a/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs @@ -44,12 +44,13 @@ using OpenSim.Region.Framework.Scenes; namespace OpenSim.Region.OptionalModules.Scripting.RegionReady { - public class RegionReadyModule : INonSharedRegionModule + public class RegionReadyModule : IRegionReadyModule, INonSharedRegionModule { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private IConfig m_config = null; + private bool m_ScriptRez; private bool m_firstEmptyCompileQueue; private bool m_oarFileLoading; private bool m_lastOarLoadedOk; @@ -93,14 +94,17 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady if (!m_enabled) return; + m_scene = scene; + + m_scene.RegisterModuleInterface(this); + + m_ScriptRez = false; m_firstEmptyCompileQueue = true; m_oarFileLoading = false; m_lastOarLoadedOk = true; - m_scene = scene; - - m_scene.EventManager.OnEmptyScriptCompileQueue += OnEmptyScriptCompileQueue; m_scene.EventManager.OnOarFileLoaded += OnOarFileLoaded; + m_scene.EventManager.OnRezScript += OnRezScript; m_scene.EventManager.OnLoginsEnabled += OnLoginsEnabled; m_log.DebugFormat("[RegionReady]: Enabled for region {0}", scene.RegionInfo.RegionName); @@ -118,6 +122,16 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady } } + void OnRezScript (uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine, int stateSource) + { + if (!m_ScriptRez) + { + m_ScriptRez = true; + m_scene.EventManager.OnEmptyScriptCompileQueue += OnEmptyScriptCompileQueue; + m_scene.EventManager.OnRezScript -= OnRezScript; + } + } + public void RemoveRegion(Scene scene) { if (!m_enabled) @@ -125,6 +139,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady m_scene.EventManager.OnEmptyScriptCompileQueue -= OnEmptyScriptCompileQueue; m_scene.EventManager.OnOarFileLoaded -= OnOarFileLoaded; + m_scene.EventManager.OnLoginsEnabled -= OnLoginsEnabled; if(m_uri != string.Empty) { @@ -148,9 +163,12 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady } #endregion - + + void OnEmptyScriptCompileQueue(int numScriptsFailed, string message) { + m_log.InfoFormat("[RegionReady]: Script compile queue empty!"); + if (m_firstEmptyCompileQueue || m_oarFileLoading) { OSChatMessage c = new OSChatMessage(); @@ -197,6 +215,10 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady } } + // This will be triggerd by Scene if we have no scripts + // m_ScriptsRezzing will be false if there were none + // else it will be true and we should wait on the + // empty compile queue void OnLoginsEnabled(string regionName) { if (m_disable_logins == true) @@ -205,7 +227,12 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady { m_scene.LoginsDisabled = false; m_scene.LoginLock = false; - m_log.InfoFormat("[RegionReady]: Logins enabled for {0}", m_scene.RegionInfo.RegionName); + + m_scene.EventManager.OnEmptyScriptCompileQueue -= OnEmptyScriptCompileQueue; + + m_log.InfoFormat("[RegionReady]: Logins enabled for {0}, Oar {1}", + m_scene.RegionInfo.RegionName, m_oarFileLoading.ToString()); + if ( m_uri != string.Empty ) { RRAlert("enabled"); @@ -214,6 +241,24 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady } } + public void OarLoadingAlert(string msg) + { + if (msg == "load") + { + m_scene.EventManager.OnEmptyScriptCompileQueue += OnEmptyScriptCompileQueue; + m_scene.EventManager.OnOarFileLoaded += OnOarFileLoaded; + m_scene.EventManager.OnLoginsEnabled += OnLoginsEnabled; + m_scene.EventManager.OnRezScript += OnRezScript; + m_oarFileLoading = true; + m_firstEmptyCompileQueue = true; + // Will need some controls around this + m_scene.LoginsDisabled = true; + m_scene.LoginLock = true; + RRAlert("loading oar"); + RRAlert("disabled"); + } + } + public void RRAlert(string status) { string request_method = "POST"; -- cgit v1.1 From adea92f8b70ffc94d9dcfe775af08effaecc41ca Mon Sep 17 00:00:00 2001 From: Mic Bowman Date: Fri, 13 Jan 2012 11:37:17 -0800 Subject: Fix llRotLookAt and llLookAt for non-physical objects. Per conversation with Melanie and Nebadon, SL behavior seems to be that non physical objects snap to the request rotation. --- .../Shared/Api/Implementation/LSL_Api.cs | 30 +++++++++++++++++----- 1 file changed, 23 insertions(+), 7 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index d6de39f..30145c7 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -2861,11 +2861,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // we need to convert from a vector describing // the angles of rotation in radians into rotation value - LSL_Types.Quaternion rot = llEuler2Rot(angle); - Quaternion rotation = new Quaternion((float)rot.x, (float)rot.y, (float)rot.z, (float)rot.s); - m_host.startLookAt(rotation, (float)damping, (float)strength); - // Orient the object to the angle calculated - //llSetRot(rot); + LSL_Rotation rot = llEuler2Rot(angle); + + // Per discussion with Melanie, for non-physical objects llLookAt appears to simply + // set the rotation of the object, copy that behavior + if (m_host.PhysActor == null || !m_host.PhysActor.IsPhysical) + { + llSetRot(rot); + } + else + { + m_host.startLookAt(Rot2Quaternion(rot), (float)damping, (float)strength); + } } public void llStopLookAt() @@ -3241,8 +3248,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llRotLookAt(LSL_Rotation target, double strength, double damping) { m_host.AddScriptLPS(1); - Quaternion rot = new Quaternion((float)target.x, (float)target.y, (float)target.z, (float)target.s); - m_host.RotLookAt(rot, (float)strength, (float)damping); + + // Per discussion with Melanie, for non-physical objects llLookAt appears to simply + // set the rotation of the object, copy that behavior + if (m_host.PhysActor == null || !m_host.PhysActor.IsPhysical) + { + llSetLocalRot(target); + } + else + { + m_host.RotLookAt(Rot2Quaternion(target), (float)damping, (float)strength); + } } public LSL_Integer llStringLength(string str) -- cgit v1.1 From 02d6b033d0858ed955e711f4a3958d41c464f977 Mon Sep 17 00:00:00 2001 From: Bo Iwu Date: Fri, 13 Jan 2012 22:41:38 +0100 Subject: Fix improper code formatting introduced in 6214e6a217cf Signed-off-by: BlueWall --- .../UserManagement/UserManagementModule.cs | 64 ++++++++++++++-------- 1 file changed, 40 insertions(+), 24 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs index bbdf92a..b4f6b5a 100644 --- a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs +++ b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs @@ -335,54 +335,70 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement { UserData oldUser; //lock the whole block - prevent concurrent update - lock (m_UserCache) { + lock (m_UserCache) + { m_UserCache.TryGetValue (id, out oldUser); - if (oldUser != null) { - if (creatorData == null || creatorData == String.Empty) { + if (oldUser != null) + { + if (creatorData == null || creatorData == String.Empty) + { //ignore updates without creator data return; } //try update unknown users //and creator's home URL's - if ((oldUser.FirstName == "Unknown" && !creatorData.Contains ("Unknown")) || (oldUser.HomeURL != null && !creatorData.StartsWith (oldUser.HomeURL))) { + if ((oldUser.FirstName == "Unknown" && !creatorData.Contains ("Unknown")) || (oldUser.HomeURL != null && !creatorData.StartsWith (oldUser.HomeURL))) + { m_UserCache.Remove (id); -// m_log.DebugFormat("[USER MANAGEMENT MODULE]: Re-adding user with id {0}, creatorData [{1}] and old HomeURL {2}", id, creatorData,oldUser.HomeURL); - } else { +// m_log.DebugFormat("[USER MANAGEMENT MODULE]: Re-adding user with id {0}, creatorData [{1}] and old HomeURL {2}", id, creatorData,oldUser.HomeURL); + } + else + { //we have already a valid user within the cache return; } } -// m_log.DebugFormat("[USER MANAGEMENT MODULE]: Adding user with id {0}, creatorData {1}", id, creatorData); - - UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount (m_Scenes[0].RegionInfo.ScopeID, id); - - if (account != null) { +// m_log.DebugFormat("[USER MANAGEMENT MODULE]: Adding user with id {0}, creatorData {1}", id, creatorData); + + UserAccount account = m_Scenes [0].UserAccountService.GetUserAccount (m_Scenes [0].RegionInfo.ScopeID, id); + + if (account != null) + { AddUser (id, account.FirstName, account.LastName); - } else { + } + else + { UserData user = new UserData (); user.Id = id; - - if (creatorData != null && creatorData != string.Empty) { + + if (creatorData != null && creatorData != string.Empty) + { //creatorData = ; - + string[] parts = creatorData.Split (';'); - if (parts.Length >= 1) { - user.HomeURL = parts[0]; - try { - Uri uri = new Uri (parts[0]); + if (parts.Length >= 1) + { + user.HomeURL = parts [0]; + try + { + Uri uri = new Uri (parts [0]); user.LastName = "@" + uri.Authority; - } catch (UriFormatException) { - m_log.DebugFormat ("[SCENE]: Unable to parse Uri {0}", parts[0]); + } + catch (UriFormatException) + { + m_log.DebugFormat ("[SCENE]: Unable to parse Uri {0}", parts [0]); user.LastName = "@unknown"; } } if (parts.Length >= 2) - user.FirstName = parts[1].Replace (' ', '.'); - } else { + user.FirstName = parts [1].Replace (' ', '.'); + } + else + { user.FirstName = "Unknown"; user.LastName = "User"; } - + AddUserInternal (user); } } -- cgit v1.1 From e1a2c44ebe8f10cf00a14578e44b000ff16b68df Mon Sep 17 00:00:00 2001 From: Mic Bowman Date: Fri, 13 Jan 2012 14:48:56 -0800 Subject: Cleaned up the LookAt code in SOP and SOG. Added support for incrementally rotating physical objects. This does not use physics. Currently the rate of change is determined as 1 / (PI * Strength). --- .../Region/Framework/Scenes/SceneObjectGroup.cs | 6 -- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 69 ++++++++++------------ .../Shared/Api/Implementation/LSL_Api.cs | 8 +-- 3 files changed, 34 insertions(+), 49 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 8860764..cad09b8 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -1613,12 +1613,6 @@ namespace OpenSim.Region.Framework.Scenes RootPart.PhysActor.PIDActive = false; } - public void stopLookAt() - { - if (RootPart.PhysActor != null) - RootPart.PhysActor.APIDActive = false; - } - /// /// Uses a PID to attempt to clamp the object on the Z axis at the given height over tau seconds. /// diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index e9c33eb..ad3bcd5 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -217,11 +217,10 @@ namespace OpenSim.Region.Framework.Scenes public Quaternion SpinOldOrientation = Quaternion.Identity; - public Quaternion m_APIDTarget = Quaternion.Identity; - - public float m_APIDDamp = 0; - - public float m_APIDStrength = 0; + protected int m_APIDIterations = 0; + protected Quaternion m_APIDTarget = Quaternion.Identity; + protected float m_APIDDamp = 0; + protected float m_APIDStrength = 0; /// /// This part's inventory @@ -563,22 +562,21 @@ namespace OpenSim.Region.Framework.Scenes } } - - public Quaternion APIDTarget + protected Quaternion APIDTarget { get { return m_APIDTarget; } set { m_APIDTarget = value; } } - public float APIDDamp + protected float APIDDamp { get { return m_APIDDamp; } set { m_APIDDamp = value; } } - public float APIDStrength + protected float APIDStrength { get { return m_APIDStrength; } set { m_APIDStrength = value; } @@ -2697,11 +2695,6 @@ namespace OpenSim.Region.Framework.Scenes public void RotLookAt(Quaternion target, float strength, float damping) { - rotLookAt(target, strength, damping); - } - - public void rotLookAt(Quaternion target, float strength, float damping) - { if (ParentGroup.IsAttachment) { /* @@ -2716,17 +2709,26 @@ namespace OpenSim.Region.Framework.Scenes APIDDamp = damping; APIDStrength = strength; APIDTarget = target; + + if (APIDStrength <= 0) + { + m_log.WarnFormat("[SceneObjectPart] Invalid rotation strength {0}",APIDStrength); + return; + } + + m_APIDIterations = 1 + (int)(Math.PI * APIDStrength); } + + // Necessary to get the lookat deltas applied + ParentGroup.QueueForUpdateCheck(); } - public void startLookAt(Quaternion rot, float damp, float strength) + public void StartLookAt(Quaternion target, float strength, float damping) { - APIDDamp = damp; - APIDStrength = strength; - APIDTarget = rot; + RotLookAt(target,strength,damping); } - public void stopLookAt() + public void StopLookAt() { APIDTarget = Quaternion.Identity; } @@ -3417,13 +3419,6 @@ namespace OpenSim.Region.Framework.Scenes } } - public void StopLookAt() - { - ParentGroup.stopLookAt(); - - ParentGroup.ScheduleGroupForTerseUpdate(); - } - /// /// Set the text displayed for this part. /// @@ -4731,24 +4726,20 @@ namespace OpenSim.Region.Framework.Scenes { if (APIDTarget != Quaternion.Identity) { - if (Single.IsNaN(APIDTarget.W) == true) + if (m_APIDIterations <= 1) { + UpdateRotation(APIDTarget); APIDTarget = Quaternion.Identity; return; } - Quaternion rot = RotationOffset; - Quaternion dir = (rot - APIDTarget); - float speed = ((APIDStrength / APIDDamp) * (float)(Math.PI / 180.0f)); - if (dir.Z > speed) - { - rot.Z -= speed; - } - if (dir.Z < -speed) - { - rot.Z += speed; - } - rot.Normalize(); + + Quaternion rot = Quaternion.Slerp(RotationOffset,APIDTarget,1.0f/(float)m_APIDIterations); UpdateRotation(rot); + + m_APIDIterations--; + + // This ensures that we'll check this object on the next iteration + ParentGroup.QueueForUpdateCheck(); } } catch (Exception ex) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 30145c7..ab175ba 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -2865,13 +2865,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // Per discussion with Melanie, for non-physical objects llLookAt appears to simply // set the rotation of the object, copy that behavior - if (m_host.PhysActor == null || !m_host.PhysActor.IsPhysical) + if (strength == 0 || m_host.PhysActor == null || !m_host.PhysActor.IsPhysical) { llSetRot(rot); } else { - m_host.startLookAt(Rot2Quaternion(rot), (float)damping, (float)strength); + m_host.StartLookAt(Rot2Quaternion(rot), (float)strength, (float)damping); } } @@ -3251,13 +3251,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // Per discussion with Melanie, for non-physical objects llLookAt appears to simply // set the rotation of the object, copy that behavior - if (m_host.PhysActor == null || !m_host.PhysActor.IsPhysical) + if (strength == 0 || m_host.PhysActor == null || !m_host.PhysActor.IsPhysical) { llSetLocalRot(target); } else { - m_host.RotLookAt(Rot2Quaternion(target), (float)damping, (float)strength); + m_host.RotLookAt(Rot2Quaternion(target), (float)strength, (float)damping); } } -- cgit v1.1 From b5bb559cc020df0b2e7d77a46f7d47a8fed1bc9f Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 14 Jan 2012 00:23:11 +0000 Subject: Register the UrlModule for script engine events OnScriptRemoved and OnObjectRemoved just once in the UrlModule itself, rather than repeatedly for every script. Doing this in every script is unnecessary since the event trigger is parameterized by the item id. All that would happen is 2000 scripts would trigger 1999 unnecessary calls, and a large number of initialized scripts may eventually trigger a StackOverflowException. Registration moved to UrlModule so that the handler is registered for all script engine implementations. This required moving the OnScriptRemoved and OnObjectRemoved events (only used by UrlModule in core) from IScriptEngine to IScriptModule to avoid circular references. --- OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs | 9 ++++++++- OpenSim/Region/Framework/Interfaces/IScriptModule.cs | 13 +++++++++++++ OpenSim/Region/ScriptEngine/Interfaces/IScriptEngine.cs | 7 ------- .../ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 5 ----- 4 files changed, 21 insertions(+), 13 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs index 67d99e0..93e75b3 100644 --- a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs @@ -131,6 +131,12 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp public void RegionLoaded(Scene scene) { + IScriptModule[] scriptModules = scene.RequestModuleInterfaces(); + foreach (IScriptModule scriptModule in scriptModules) + { + scriptModule.OnScriptRemoved += ScriptRemoved; + scriptModule.OnObjectRemoved += ObjectRemoved; + } } public void RemoveRegion(Scene scene) @@ -160,7 +166,6 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp urlData.url = url; urlData.urlcode = urlcode; urlData.requests = new Dictionary(); - m_UrlMap[url] = urlData; @@ -276,6 +281,8 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp public void ScriptRemoved(UUID itemID) { +// m_log.DebugFormat("[URL MODULE]: Removing script {0}", itemID); + lock (m_UrlMap) { List removeURLs = new List(); diff --git a/OpenSim/Region/Framework/Interfaces/IScriptModule.cs b/OpenSim/Region/Framework/Interfaces/IScriptModule.cs index 950e4b0..18c45dd 100644 --- a/OpenSim/Region/Framework/Interfaces/IScriptModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IScriptModule.cs @@ -31,8 +31,21 @@ using OpenMetaverse; namespace OpenSim.Region.Framework.Interfaces { + public delegate void ScriptRemoved(UUID script); + public delegate void ObjectRemoved(UUID prim); + public interface IScriptModule: INonSharedRegionModule { + /// + /// Triggered when a script is removed from the script module. + /// + event ScriptRemoved OnScriptRemoved; + + /// + /// Triggered when an object is removed via the script module. + /// + event ObjectRemoved OnObjectRemoved; + string ScriptEngineName { get; } string GetXMLState(UUID itemID); diff --git a/OpenSim/Region/ScriptEngine/Interfaces/IScriptEngine.cs b/OpenSim/Region/ScriptEngine/Interfaces/IScriptEngine.cs index 581a9a9..17c2708 100644 --- a/OpenSim/Region/ScriptEngine/Interfaces/IScriptEngine.cs +++ b/OpenSim/Region/ScriptEngine/Interfaces/IScriptEngine.cs @@ -42,10 +42,6 @@ namespace OpenSim.Region.ScriptEngine.Interfaces /// An interface for a script API module to communicate with /// the engine it's running under /// - - public delegate void ScriptRemoved(UUID script); - public delegate void ObjectRemoved(UUID prim); - public interface IScriptEngine { /// @@ -57,9 +53,6 @@ namespace OpenSim.Region.ScriptEngine.Interfaces IScriptModule ScriptModule { get; } - event ScriptRemoved OnScriptRemoved; - event ObjectRemoved OnObjectRemoved; - /// /// Post an event to a single script /// diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index ab175ba..fb930e0 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -126,11 +126,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_TransferModule = m_ScriptEngine.World.RequestModuleInterface(); m_UrlModule = m_ScriptEngine.World.RequestModuleInterface(); - if (m_UrlModule != null) - { - m_ScriptEngine.OnScriptRemoved += m_UrlModule.ScriptRemoved; - m_ScriptEngine.OnObjectRemoved += m_UrlModule.ObjectRemoved; - } AsyncCommands = new AsyncCommandManager(ScriptEngine); } -- cgit v1.1 From 82f0e193494e939d34950dda3dd108c5cfc26124 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 14 Jan 2012 00:44:19 +0000 Subject: Extend scripts show command to accept a single item UUID parameter to display one script's status Usage is now scripts show [] --- OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 87 ++++++++++++++------------ 1 file changed, 47 insertions(+), 40 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 12e1a78..c9bbf0e 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -273,11 +273,13 @@ namespace OpenSim.Region.ScriptEngine.XEngine } MainConsole.Instance.Commands.AddCommand( - "scripts", false, "scripts show", "scripts show", "Show script information", - "Show information on all scripts known to the script engine", HandleShowScripts); + "scripts", false, "scripts show", "scripts show []", "Show script information", + "Show information on all scripts known to the script engine." + + "If a is given then only information on that script will be shown.", + HandleShowScripts); MainConsole.Instance.Commands.AddCommand( - "scripts", false, "show scripts", "show scripts", "Show script information", + "scripts", false, "show scripts", "show scripts []", "Show script information", "Synonym for scripts show command", HandleShowScripts); MainConsole.Instance.Commands.AddCommand( @@ -308,43 +310,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine (module, cmdparams) => HandleScriptsAction(cmdparams, HandleStartScript)); } - public void HandleShowScripts(string module, string[] cmdparams) - { - lock (m_Scripts) - { - MainConsole.Instance.OutputFormat( - "Showing {0} scripts in {1}", m_Scripts.Count, m_Scene.RegionInfo.RegionName); - - foreach (IScriptInstance instance in m_Scripts.Values) - { - SceneObjectPart sop = m_Scene.GetSceneObjectPart(instance.ObjectID); - string status; - - if (instance.ShuttingDown) - { - status = "shutting down"; - } - else if (instance.Suspended) - { - status = "suspended"; - } - else if (!instance.Running) - { - status = "stopped"; - } - else - { - status = "running"; - } - - MainConsole.Instance.OutputFormat( - "{0}.{1}, item UUID {2}, prim UUID {3} @ {4} ({5})", - instance.PrimName, instance.ScriptName, instance.ItemID, instance.ObjectID, - sop.AbsolutePosition, status); - } - } - } - /// /// Parse the raw item id into a script instance from the command params if it's present. /// @@ -394,6 +359,48 @@ namespace OpenSim.Region.ScriptEngine.XEngine } } + public void HandleShowScripts(string module, string[] cmdparams) + { + if (cmdparams.Length == 2) + { + lock (m_Scripts) + { + MainConsole.Instance.OutputFormat( + "Showing {0} scripts in {1}", m_Scripts.Count, m_Scene.RegionInfo.RegionName); + } + } + + HandleScriptsAction(cmdparams, HandleShowScript); + } + + private void HandleShowScript(IScriptInstance instance) + { + SceneObjectPart sop = m_Scene.GetSceneObjectPart(instance.ObjectID); + string status; + + if (instance.ShuttingDown) + { + status = "shutting down"; + } + else if (instance.Suspended) + { + status = "suspended"; + } + else if (!instance.Running) + { + status = "stopped"; + } + else + { + status = "running"; + } + + MainConsole.Instance.OutputFormat( + "{0}.{1}, item UUID {2}, prim UUID {3} @ {4} ({5})", + instance.PrimName, instance.ScriptName, instance.ItemID, instance.ObjectID, + sop.AbsolutePosition, status); + } + private void HandleSuspendScript(IScriptInstance instance) { if (!instance.Suspended) -- cgit v1.1 From ec299bfa878498713e4538f825fd3a2ca92cd125 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 14 Jan 2012 05:28:57 +0100 Subject: Allow SmtpClients and other SSL users to work with our cert handler installed --- .../Scripting/HttpRequest/ScriptsHttpRequests.cs | 34 ++++++++++++++++------ 1 file changed, 25 insertions(+), 9 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs index 8fb5d75..d328eb3 100644 --- a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs +++ b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs @@ -29,6 +29,7 @@ using System; using System.Collections.Generic; using System.IO; using System.Net; +using System.Net.Mail; using System.Net.Security; using System.Text; using System.Threading; @@ -111,21 +112,36 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest X509Chain chain, SslPolicyErrors sslPolicyErrors) { - HttpWebRequest Request = (HttpWebRequest)sender; - - if (Request.Headers.Get("NoVerifyCert") != null) + // If this is a web request we need to check the headers first + // We may want to ignore SSL + if (sender is HttpWebRequest) { + HttpWebRequest Request = (HttpWebRequest)sender; + ServicePoint sp = Request.ServicePoint; + + // We don't case about encryption, get out of here + if (Request.Headers.Get("NoVerifyCert") != null) + { + return true; + } + + // If there was an upstream cert verification error, bail + if ((((int)sslPolicyErrors) & ~4) != 0) + return false; + + // Check for policy and execute it if defined + if (ServicePointManager.CertificatePolicy != null) + { + return ServicePointManager.CertificatePolicy.CheckValidationResult (sp, certificate, Request, 0); + } + return true; } - + + // If it's not HTTP, trust .NET to check it if ((((int)sslPolicyErrors) & ~4) != 0) return false; - if (ServicePointManager.CertificatePolicy != null) - { - ServicePoint sp = Request.ServicePoint; - return ServicePointManager.CertificatePolicy.CheckValidationResult (sp, certificate, Request, 0); - } return true; } #region IHttpRequestModule Members -- cgit v1.1 From 43173f1b0d80eee8589b9e506a5fdb5cfe92cc06 Mon Sep 17 00:00:00 2001 From: nebadon Date: Sat, 14 Jan 2012 18:36:46 -0700 Subject: commented out redundant land owner checks for osTeleportAgent there is no need for these checks just use Allow_osTeleportAgent = PARCEL_OWNER also increased function to severe threat level to make it harder to accidently enable it for everyone. --- .../Shared/Api/Implementation/OSSL_Api.cs | 38 ++++++++++++++-------- 1 file changed, 24 insertions(+), 14 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 40d9d6f..fc478ab 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -739,7 +739,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { // High because there is no security check. High griefer potential // - CheckThreatLevel(ThreatLevel.High, "osTeleportAgent"); + CheckThreatLevel(ThreatLevel.Severe, "osTeleportAgent"); TeleportAgent(agent, regionName, position, lookat, false); } @@ -756,11 +756,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { // For osTeleportAgent, agent must be over owners land to avoid abuse // For osTeleportOwner, this restriction isn't necessary - if (relaxRestrictions || - m_host.OwnerID - == World.LandChannel.GetLandObject( - presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID) - { + + // commented out because its redundant and uneeded please remove eventually. + // if (relaxRestrictions || + // m_host.OwnerID + // == World.LandChannel.GetLandObject( + // presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID) + // { + // We will launch the teleport on a new thread so that when the script threads are terminated // before teleport in ScriptInstance.GetXMLState(), we don't end up aborting the one doing the teleporting. Util.FireAndForget( @@ -769,7 +772,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api new Vector3((float)lookat.x, (float)lookat.y, (float)lookat.z), (uint)TPFlags.ViaLocation)); ScriptSleep(5000); - } + + // } + } } } @@ -778,7 +783,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { // High because there is no security check. High griefer potential // - CheckThreatLevel(ThreatLevel.High, "osTeleportAgent"); + CheckThreatLevel(ThreatLevel.Severe, "osTeleportAgent"); TeleportAgent(agent, regionX, regionY, position, lookat, false); } @@ -797,11 +802,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { // For osTeleportAgent, agent must be over owners land to avoid abuse // For osTeleportOwner, this restriction isn't necessary - if (relaxRestrictions || - m_host.OwnerID - == World.LandChannel.GetLandObject( - presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID) - { + + // commented out because its redundant and uneeded please remove eventually. + // if (relaxRestrictions || + // m_host.OwnerID + // == World.LandChannel.GetLandObject( + // presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID) + // { + // We will launch the teleport on a new thread so that when the script threads are terminated // before teleport in ScriptInstance.GetXMLState(), we don't end up aborting the one doing the teleporting. Util.FireAndForget( @@ -810,7 +818,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api new Vector3((float)lookat.x, (float)lookat.y, (float)lookat.z), (uint)TPFlags.ViaLocation)); ScriptSleep(5000); - } + + // } + } } } -- cgit v1.1 From 2e4fbe6b176a2c4b65b819eae6e58f1510dcc95f Mon Sep 17 00:00:00 2001 From: Mic Bowman Date: Sat, 14 Jan 2012 23:43:21 -0800 Subject: protect the region ready alerts for loading oarfiles if no post URI is set --- .../Scripting/RegionReadyModule/RegionReadyModule.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs b/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs index f5d4da8..feef49b 100644 --- a/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs @@ -254,8 +254,11 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady // Will need some controls around this m_scene.LoginsDisabled = true; m_scene.LoginLock = true; - RRAlert("loading oar"); - RRAlert("disabled"); + if ( m_uri != string.Empty ) + { + RRAlert("loading oar"); + RRAlert("disabled"); + } } } -- cgit v1.1 From 82ad9d4e04867b23b4c824c4eca7402bf476f0b7 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 16 Jan 2012 22:58:58 +0000 Subject: Remove monocov and other obsolete nant build targets. monocov was a code coverage attempt 3 years ago which no longer works. other removed targets have been commented out or unused for a very long time --- OpenSim/Framework/IClientAPI.cs | 8 ++++++++ OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs | 15 ++++++++++----- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 +- 3 files changed, 19 insertions(+), 6 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs index 258b3eb..29a69c3 100644 --- a/OpenSim/Framework/IClientAPI.cs +++ b/OpenSim/Framework/IClientAPI.cs @@ -1074,7 +1074,15 @@ namespace OpenSim.Framework void SendWindData(Vector2[] windSpeeds); void SendCloudData(float[] cloudCover); + /// + /// Sent when an agent completes its movement into a region. + /// + /// + /// This packet marks completion of the arrival of a root avatar in a region, whether through login, region + /// crossing or direct teleport. + /// void MoveAgentIntoRegion(RegionInfo regInfo, Vector3 pos, Vector3 look); + void InformClientOfNeighbour(ulong neighbourHandle, IPEndPoint neighbourExternalEndPoint); /// diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index 1e72aa2..2553b3a 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -762,9 +762,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP OutPacket(handshake, ThrottleOutPacketType.Task); } - /// - /// - /// public void MoveAgentIntoRegion(RegionInfo regInfo, Vector3 pos, Vector3 look) { AgentMovementCompletePacket mov = (AgentMovementCompletePacket)PacketPool.Instance.GetPacket(PacketType.AgentMovementComplete); @@ -3480,6 +3477,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP public void SendAppearance(UUID agentID, byte[] visualParams, byte[] textureEntry) { + m_log.DebugFormat( + "[LLCLIENTVIEW]: Sending avatar appearance for {0} with {1} bytes to {2} {3}", + agentID, textureEntry.Length, Name, AgentId); + AvatarAppearancePacket avp = (AvatarAppearancePacket)PacketPool.Instance.GetPacket(PacketType.AvatarAppearance); // TODO: don't create new blocks if recycling an old packet avp.VisualParam = new AvatarAppearancePacket.VisualParamBlock[218]; @@ -3501,7 +3502,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP public void SendAnimations(UUID[] animations, int[] seqs, UUID sourceAgentId, UUID[] objectIDs) { - //m_log.DebugFormat("[CLIENT]: Sending animations to {0}", Name); +// m_log.DebugFormat("[LLCLIENTVIEW]: Sending animations for {0} to {1}", sourceAgentId, Name); AvatarAnimationPacket ani = (AvatarAnimationPacket)PacketPool.Instance.GetPacket(PacketType.AvatarAnimation); // TODO: don't create new blocks if recycling an old packet @@ -3536,6 +3537,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// public void SendAvatarDataImmediate(ISceneEntity avatar) { + m_log.DebugFormat( + "[LLCLIENTVIEW]: Sending immediate object update for avatar {0} {1} to {2} {3}", + avatar.Name, avatar.UUID, Name, AgentId); + ScenePresence presence = avatar as ScenePresence; if (presence == null) return; @@ -3545,7 +3550,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP objupdate.RegionData.RegionHandle = presence.RegionHandle; objupdate.RegionData.TimeDilation = ushort.MaxValue; - + objupdate.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1]; objupdate.ObjectData[0] = CreateAvatarUpdateBlock(presence); diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 3c9bde8..230cf91 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1212,7 +1212,7 @@ namespace OpenSim.Region.Framework.Scenes m_callbackURI = null; } - //m_log.DebugFormat("[SCENE PRESENCE] Completed movement"); + m_log.DebugFormat("[SCENE PRESENCE] Completed movement"); ControllingClient.MoveAgentIntoRegion(m_scene.RegionInfo, AbsolutePosition, look); ValidateAndSendAppearanceAndAgentData(); -- cgit v1.1 From 59a0c50d48100527d00ea87935fdc24055249ba5 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 16 Jan 2012 23:04:08 +0000 Subject: Comment out noisy log lines I accidentally included in the nant build target adjustment commit. Left in the method doc. --- OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs | 12 ++++++------ OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index 2553b3a..4ba441e 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -3477,9 +3477,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP public void SendAppearance(UUID agentID, byte[] visualParams, byte[] textureEntry) { - m_log.DebugFormat( - "[LLCLIENTVIEW]: Sending avatar appearance for {0} with {1} bytes to {2} {3}", - agentID, textureEntry.Length, Name, AgentId); +// m_log.DebugFormat( +// "[LLCLIENTVIEW]: Sending avatar appearance for {0} with {1} bytes to {2} {3}", +// agentID, textureEntry.Length, Name, AgentId); AvatarAppearancePacket avp = (AvatarAppearancePacket)PacketPool.Instance.GetPacket(PacketType.AvatarAppearance); // TODO: don't create new blocks if recycling an old packet @@ -3537,9 +3537,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// public void SendAvatarDataImmediate(ISceneEntity avatar) { - m_log.DebugFormat( - "[LLCLIENTVIEW]: Sending immediate object update for avatar {0} {1} to {2} {3}", - avatar.Name, avatar.UUID, Name, AgentId); +// m_log.DebugFormat( +// "[LLCLIENTVIEW]: Sending immediate object update for avatar {0} {1} to {2} {3}", +// avatar.Name, avatar.UUID, Name, AgentId); ScenePresence presence = avatar as ScenePresence; if (presence == null) diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 230cf91..c66f30e 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1212,7 +1212,7 @@ namespace OpenSim.Region.Framework.Scenes m_callbackURI = null; } - m_log.DebugFormat("[SCENE PRESENCE] Completed movement"); +// m_log.DebugFormat("[SCENE PRESENCE] Completed movement"); ControllingClient.MoveAgentIntoRegion(m_scene.RegionInfo, AbsolutePosition, look); ValidateAndSendAppearanceAndAgentData(); -- cgit v1.1 From e13a17cc0c8514bc673d5ba39c86d23451278389 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 16 Jan 2012 02:19:19 +0100 Subject: Allow retrival of multiple user records in one operation, analog to presence --- .../GridUser/LocalGridUserServiceConnector.cs | 4 ++ .../GridUser/RemoteGridUserServiceConnector.cs | 5 ++ .../Handlers/GridUser/GridUserServerPostHandler.cs | 42 +++++++++++++++ .../GridUser/GridUserServiceConnector.cs | 60 ++++++++++++++++++++++ .../SimianGrid/SimianPresenceServiceConnector.cs | 4 ++ OpenSim/Services/Interfaces/IGridUserService.cs | 3 +- .../Services/UserAccountService/GridUserService.cs | 12 ++++- 7 files changed, 128 insertions(+), 2 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/LocalGridUserServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/LocalGridUserServiceConnector.cs index 985acec..90fe69e 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/LocalGridUserServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/LocalGridUserServiceConnector.cs @@ -171,6 +171,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.GridUser { return m_GridUserService.GetGridUserInfo(userID); } + public GridUserInfo[] GetGridUserInfo(string[] userID) + { + return m_GridUserService.GetGridUserInfo(userID); + } #endregion diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/RemoteGridUserServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/RemoteGridUserServiceConnector.cs index 95b3591..badb552 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/RemoteGridUserServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/RemoteGridUserServiceConnector.cs @@ -147,6 +147,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.GridUser return m_RemoteConnector.GetGridUserInfo(userID); } + public GridUserInfo[] GetGridUserInfo(string[] userID) + { + return m_RemoteConnector.GetGridUserInfo(userID); + } + #endregion } diff --git a/OpenSim/Server/Handlers/GridUser/GridUserServerPostHandler.cs b/OpenSim/Server/Handlers/GridUser/GridUserServerPostHandler.cs index 4c0d52e..bf21255 100644 --- a/OpenSim/Server/Handlers/GridUser/GridUserServerPostHandler.cs +++ b/OpenSim/Server/Handlers/GridUser/GridUserServerPostHandler.cs @@ -88,6 +88,8 @@ namespace OpenSim.Server.Handlers.GridUser return SetPosition(request); case "getgriduserinfo": return GetGridUserInfo(request); + case "getgriduserinfos": + return GetGridUserInfos(request); } m_log.DebugFormat("[GRID USER HANDLER]: unknown method request: {0}", method); } @@ -193,6 +195,46 @@ namespace OpenSim.Server.Handlers.GridUser } + byte[] GetGridUserInfos(Dictionary request) + { + + string[] userIDs; + + if (!request.ContainsKey("AgentIDs")) + { + m_log.DebugFormat("[GRID USER HANDLER]: GetGridUserInfos called without required uuids argument"); + return FailureResult(); + } + + if (!(request["AgentIDs"] is List)) + { + m_log.DebugFormat("[GRID USER HANDLER]: GetGridUserInfos input argument was of unexpected type {0}", request["uuids"].GetType().ToString()); + return FailureResult(); + } + + userIDs = ((List)request["AgentIDs"]).ToArray(); + + GridUserInfo[] pinfos = m_GridUserService.GetGridUserInfo(userIDs); + + Dictionary result = new Dictionary(); + if ((pinfos == null) || ((pinfos != null) && (pinfos.Length == 0))) + result["result"] = "null"; + else + { + int i = 0; + foreach (GridUserInfo pinfo in pinfos) + { + Dictionary rinfoDict = pinfo.ToKeyValuePairs(); + result["griduser" + i] = rinfoDict; + i++; + } + } + + string xmlString = ServerUtils.BuildXmlResponse(result); + UTF8Encoding encoding = new UTF8Encoding(); + return encoding.GetBytes(xmlString); + } + private bool UnpackArgs(Dictionary request, out string user, out UUID region, out Vector3 position, out Vector3 lookAt) { user = string.Empty; diff --git a/OpenSim/Services/Connectors/GridUser/GridUserServiceConnector.cs b/OpenSim/Services/Connectors/GridUser/GridUserServiceConnector.cs index 738cc06..aa98b5d 100644 --- a/OpenSim/Services/Connectors/GridUser/GridUserServiceConnector.cs +++ b/OpenSim/Services/Connectors/GridUser/GridUserServiceConnector.cs @@ -223,5 +223,65 @@ namespace OpenSim.Services.Connectors } + public GridUserInfo[] GetGridUserInfo(string[] userIDs) + { + Dictionary sendData = new Dictionary(); + //sendData["SCOPEID"] = scopeID.ToString(); + sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString(); + sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString(); + sendData["METHOD"] = "getgriduserinfos"; + + sendData["AgentIDs"] = new List(userIDs); + + string reply = string.Empty; + string reqString = ServerUtils.BuildQueryString(sendData); + //m_log.DebugFormat("[PRESENCE CONNECTOR]: queryString = {0}", reqString); + try + { + reply = SynchronousRestFormsRequester.MakeRequest("POST", + m_ServerURI + "/griduser", + reqString); + if (reply == null || (reply != null && reply == string.Empty)) + { + m_log.DebugFormat("[GRID USER CONNECTOR]: GetGridUserInfo received null or empty reply"); + return null; + } + } + catch (Exception e) + { + m_log.DebugFormat("[GRID USER CONNECTOR]: Exception when contacting grid user server: {0}", e.Message); + } + + List rinfos = new List(); + + Dictionary replyData = ServerUtils.ParseXmlResponse(reply); + + if (replyData != null) + { + if (replyData.ContainsKey("result") && + (replyData["result"].ToString() == "null" || replyData["result"].ToString() == "Failure")) + { + return new GridUserInfo[0]; + } + + Dictionary.ValueCollection pinfosList = replyData.Values; + //m_log.DebugFormat("[PRESENCE CONNECTOR]: GetAgents returned {0} elements", pinfosList.Count); + foreach (object griduser in pinfosList) + { + if (griduser is Dictionary) + { + GridUserInfo pinfo = new GridUserInfo((Dictionary)griduser); + rinfos.Add(pinfo); + } + else + m_log.DebugFormat("[GRID USER CONNECTOR]: GetGridUserInfo received invalid response type {0}", + griduser.GetType()); + } + } + else + m_log.DebugFormat("[GRID USER CONNECTOR]: GetGridUserInfo received null response"); + + return rinfos.ToArray(); + } } } diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs index 678f738..ca1b64f 100644 --- a/OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs +++ b/OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs @@ -472,6 +472,10 @@ namespace OpenSim.Services.Connectors.SimianGrid return false; } + public GridUserInfo[] GetGridUserInfo(string[] userIDs) + { + return new GridUserInfo[0]; + } #endregion Helpers } } diff --git a/OpenSim/Services/Interfaces/IGridUserService.cs b/OpenSim/Services/Interfaces/IGridUserService.cs index 6613ae7..0a52bfa 100644 --- a/OpenSim/Services/Interfaces/IGridUserService.cs +++ b/OpenSim/Services/Interfaces/IGridUserService.cs @@ -131,5 +131,6 @@ namespace OpenSim.Services.Interfaces bool SetLastPosition(string userID, UUID sessionID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt); GridUserInfo GetGridUserInfo(string userID); + GridUserInfo[] GetGridUserInfo(string[] userID); } -} \ No newline at end of file +} diff --git a/OpenSim/Services/UserAccountService/GridUserService.cs b/OpenSim/Services/UserAccountService/GridUserService.cs index 9b18915..ac3d8fd 100644 --- a/OpenSim/Services/UserAccountService/GridUserService.cs +++ b/OpenSim/Services/UserAccountService/GridUserService.cs @@ -73,6 +73,16 @@ namespace OpenSim.Services.UserAccountService return info; } + public GridUserInfo[] GetGridUserInfo(string[] userIDs) + { + List ret = new List(); + + foreach (string id in userIDs) + ret.Add(GetGridUserInfo(id)); + + return ret.ToArray(); + } + public GridUserInfo LoggedIn(string userID) { m_log.DebugFormat("[GRID USER SERVICE]: User {0} is online", userID); @@ -156,4 +166,4 @@ namespace OpenSim.Services.UserAccountService return m_Database.Store(d); } } -} \ No newline at end of file +} -- cgit v1.1 From ef5575be1b7e8122883773c799ddc522ed80c156 Mon Sep 17 00:00:00 2001 From: BlueWall Date: Tue, 17 Jan 2012 21:09:46 -0500 Subject: Add json handler for GridInfo --- OpenSim/Server/Handlers/Grid/GridInfoHandlers.cs | 15 +++++++++++++++ OpenSim/Server/Handlers/Grid/GridInfoServerInConnector.cs | 2 ++ 2 files changed, 17 insertions(+) (limited to 'OpenSim') diff --git a/OpenSim/Server/Handlers/Grid/GridInfoHandlers.cs b/OpenSim/Server/Handlers/Grid/GridInfoHandlers.cs index 645a77f..bfcddca 100644 --- a/OpenSim/Server/Handlers/Grid/GridInfoHandlers.cs +++ b/OpenSim/Server/Handlers/Grid/GridInfoHandlers.cs @@ -37,6 +37,7 @@ using Nini.Config; using Nwc.XmlRpc; using OpenSim.Framework; using OpenSim.Framework.Servers.HttpServer; +using OpenMetaverse.StructuredData; namespace OpenSim.Server.Handlers.Grid { @@ -142,5 +143,19 @@ namespace OpenSim.Server.Handlers.Grid return sb.ToString(); } + + public string JsonGetGridInfoMethod(string request, string path, string param, + IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) + { + + OSDMap map = new OSDMap(); + + foreach (string k in _info.Keys) + { + map[k] = OSD.FromString(_info[k].ToString()); + } + + return OSDParser.SerializeJsonString(map).ToString(); + } } } diff --git a/OpenSim/Server/Handlers/Grid/GridInfoServerInConnector.cs b/OpenSim/Server/Handlers/Grid/GridInfoServerInConnector.cs index 8472d34..f9b5915 100644 --- a/OpenSim/Server/Handlers/Grid/GridInfoServerInConnector.cs +++ b/OpenSim/Server/Handlers/Grid/GridInfoServerInConnector.cs @@ -48,6 +48,8 @@ namespace OpenSim.Server.Handlers.Grid server.AddStreamHandler(new RestStreamHandler("GET", "/get_grid_info", handlers.RestGetGridInfoMethod)); + server.AddStreamHandler(new RestStreamHandler("GET", "/json_grid_info", + handlers.JsonGetGridInfoMethod)); server.AddXmlRPCHandler("get_grid_info", handlers.XmlRpcGridInfoMethod); } -- cgit v1.1 From 9ed9720861ef3b63b1fca75c843a509ee3239b17 Mon Sep 17 00:00:00 2001 From: BlueWall Date: Tue, 17 Jan 2012 22:07:40 -0500 Subject: Update osGetGrid**** functions The osGetGrid**** functions will now get the grid settings from the GridInfoService. Set the GridInfoURI in your ./bin/config-include/GridCommon.ini [GridInfo] section. --- .../Shared/Api/Implementation/OSSL_Api.cs | 72 +++++++++++++++++++++- 1 file changed, 69 insertions(+), 3 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index fc478ab..c7a62b3 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -1944,6 +1944,54 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } } + private enum InfoType + { + Nick, + Name, + Login + }; + + private string GridUserInfo(InfoType type) + { + string retval = String.Empty; + IConfigSource config = m_ScriptEngine.ConfigSource; + string url = config.Configs["GridInfo"].GetString("GridInfoURI", String.Empty); + + if (String.IsNullOrEmpty(url)) + return "Configuration Error!"; + + string verb ="/json_grid_info"; + OSDMap json = new OSDMap(); + + OSDMap info = WebUtil.GetFromService(String.Format("{0}{1}",url,verb), 3000); + + if (info["Success"] != true) + return "Get GridInfo Failed!"; + + json = (OSDMap)OSDParser.DeserializeJson(info["_RawResult"].AsString()); + + switch (type) + { + case InfoType.Nick: + retval = json["gridnick"]; + break; + + case InfoType.Name: + retval = json["gridname"]; + break; + + case InfoType.Login: + retval = json["login"]; + break; + + default: + retval = "error"; + break; + } + + return retval; + } + /// /// Get the nickname of this grid, as set in the [GridInfo] config section. /// @@ -1957,10 +2005,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { CheckThreatLevel(ThreatLevel.Moderate, "osGetGridNick"); m_host.AddScriptLPS(1); - string nick = "hippogrid"; + + string nick = String.Empty; IConfigSource config = m_ScriptEngine.ConfigSource; + if (config.Configs["GridInfo"] != null) nick = config.Configs["GridInfo"].GetString("gridnick", nick); + + if (String.IsNullOrEmpty(nick)) + nick = GridUserInfo(InfoType.Nick); + return nick; } @@ -1968,10 +2022,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { CheckThreatLevel(ThreatLevel.Moderate, "osGetGridName"); m_host.AddScriptLPS(1); - string name = "the lost continent of hippo"; + + string name = String.Empty; IConfigSource config = m_ScriptEngine.ConfigSource; + if (config.Configs["GridInfo"] != null) name = config.Configs["GridInfo"].GetString("gridname", name); + + if (String.IsNullOrEmpty(name)) + name = GridUserInfo(InfoType.Name); + return name; } @@ -1979,10 +2039,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { CheckThreatLevel(ThreatLevel.Moderate, "osGetGridLoginURI"); m_host.AddScriptLPS(1); - string loginURI = "http://127.0.0.1:9000/"; + + string loginURI = String.Empty; IConfigSource config = m_ScriptEngine.ConfigSource; + if (config.Configs["GridInfo"] != null) loginURI = config.Configs["GridInfo"].GetString("login", loginURI); + + if (String.IsNullOrEmpty(loginURI)) + loginURI = GridUserInfo(InfoType.Login); + return loginURI; } -- cgit v1.1 From ba7d8cedeca1440fe4d4166308fec56fbbcdac19 Mon Sep 17 00:00:00 2001 From: BlueWall Date: Tue, 17 Jan 2012 22:38:36 -0500 Subject: Add function osGetGridCustom Add function osGetGridCustom to take an argument for the GridInfo kpv to retrieve from the GridInfoService --- .../Shared/Api/Implementation/OSSL_Api.cs | 29 +++++++++++++++++++++- .../ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | 1 + .../ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | 5 ++++ 3 files changed, 34 insertions(+), 1 deletion(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index c7a62b3..c682fda 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -1948,11 +1948,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { Nick, Name, - Login + Login, + Custom }; private string GridUserInfo(InfoType type) { + return GridUserInfo(type, ""); + } + + private string GridUserInfo(InfoType type, string key) + { string retval = String.Empty; IConfigSource config = m_ScriptEngine.ConfigSource; string url = config.Configs["GridInfo"].GetString("GridInfoURI", String.Empty); @@ -1984,6 +1990,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api retval = json["login"]; break; + case InfoType.Custom: + retval = json[key]; + break; + default: retval = "error"; break; @@ -2052,6 +2062,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return loginURI; } + public string osGetGridCustom(string key) + { + CheckThreatLevel(ThreatLevel.Moderate, "osGetGridCustom"); + m_host.AddScriptLPS(1); + + string retval = String.Empty; + IConfigSource config = m_ScriptEngine.ConfigSource; + + if (config.Configs["GridInfo"] != null) + retval = config.Configs["GridInfo"].GetString(key, retval); + + if (String.IsNullOrEmpty(retval)) + retval = GridUserInfo(InfoType.Custom, key); + + return retval; + } + public LSL_String osFormatString(string str, LSL_List strings) { CheckThreatLevel(ThreatLevel.Low, "osFormatString"); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index af6be5f..c1c4511 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs @@ -160,6 +160,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces string osGetGridNick(); string osGetGridName(); string osGetGridLoginURI(); + string osGetGridCustom(string key); LSL_String osFormatString(string str, LSL_List strings); LSL_List osMatchString(string src, string pattern, int start); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs index 0c05ea4..fc83786 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs @@ -452,6 +452,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase return m_OSSL_Functions.osGetGridLoginURI(); } + public string osGetGridCustom(string key) + { + return m_OSSL_Functions.osGetGridCustom(key); + } + public LSL_String osFormatString(string str, LSL_List strings) { return m_OSSL_Functions.osFormatString(str, strings); -- cgit v1.1 From eea726d74ecafb9383d2ae7ec257d1fc5b6782b0 Mon Sep 17 00:00:00 2001 From: BlueWall Date: Wed, 18 Jan 2012 20:30:57 -0500 Subject: RegionReady: Back out some of the oar monitoring for the time being. Need to find a better way to get feedback. Will re-visit this soon. --- OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs | 2 ++ .../Scripting/RegionReadyModule/RegionReadyModule.cs | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs index a945fc2..0b22598 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs @@ -100,12 +100,14 @@ namespace OpenSim.Region.CoreModules.World.Archiver options.Add("s|skip-assets", delegate (string v) { skipAssets = v != null; }); // Send a message to the region ready module + /* bluewall* Disable this for the time being IRegionReadyModule rready = m_scene.RequestModuleInterface(); if (rready != null) { rready.OarLoadingAlert("load"); } + */ List mainParams = options.Parse(cmdparams); diff --git a/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs b/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs index feef49b..d2810be 100644 --- a/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs @@ -243,6 +243,10 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady public void OarLoadingAlert(string msg) { + // Let's bypass this for now until some better feedback can be established + // + return; + if (msg == "load") { m_scene.EventManager.OnEmptyScriptCompileQueue += OnEmptyScriptCompileQueue; @@ -251,7 +255,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady m_scene.EventManager.OnRezScript += OnRezScript; m_oarFileLoading = true; m_firstEmptyCompileQueue = true; - // Will need some controls around this + m_scene.LoginsDisabled = true; m_scene.LoginLock = true; if ( m_uri != string.Empty ) -- cgit v1.1 From bf9ce4709faa22c23411ade380e77a699a29ce51 Mon Sep 17 00:00:00 2001 From: BlueWall Date: Thu, 19 Jan 2012 13:48:31 -0500 Subject: Add fetching of SRV_HomeURI to "/json_grid_info" Make SRV_HomeURI available on the GridInfoService through the "/json_grid_info" URI. This i s mainly to service OSSL, but can be seen externally via the URI. --- OpenSim/Server/Handlers/Grid/GridInfoHandlers.cs | 37 +++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) (limited to 'OpenSim') diff --git a/OpenSim/Server/Handlers/Grid/GridInfoHandlers.cs b/OpenSim/Server/Handlers/Grid/GridInfoHandlers.cs index bfcddca..67472e3 100644 --- a/OpenSim/Server/Handlers/Grid/GridInfoHandlers.cs +++ b/OpenSim/Server/Handlers/Grid/GridInfoHandlers.cs @@ -44,7 +44,7 @@ namespace OpenSim.Server.Handlers.Grid public class GridInfoHandlers { private static readonly ILog _log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - + private IConfigSource m_Config; private Hashtable _info = new Hashtable(); /// @@ -60,6 +60,7 @@ namespace OpenSim.Server.Handlers.Grid /// public GridInfoHandlers(IConfigSource configSource) { + m_Config = configSource; loadGridInfo(configSource); } @@ -144,9 +145,38 @@ namespace OpenSim.Server.Handlers.Grid return sb.ToString(); } + /// + /// Get GridInfo in json format: Used bu the OSSL osGetGrid* + /// Adding the SRV_HomeIRI to the kvp returned for use in scripts + /// + /// + /// json string + /// + /// + /// Request. + /// + /// + /// /json_grid_info + /// + /// + /// Parameter. + /// + /// + /// Http request. + /// + /// + /// Http response. + /// public string JsonGetGridInfoMethod(string request, string path, string param, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { + string HomeURI = String.Empty; + IConfig cfg = m_Config.Configs["LoginService"]; + + if (null != cfg) + { + HomeURI = cfg.GetString("SRV_HomeURI", HomeURI); + } OSDMap map = new OSDMap(); @@ -155,6 +185,11 @@ namespace OpenSim.Server.Handlers.Grid map[k] = OSD.FromString(_info[k].ToString()); } + if (!String.IsNullOrEmpty(HomeURI)) + { + map["HomeURI"] = OSD.FromString(HomeURI); + } + return OSDParser.SerializeJsonString(map).ToString(); } } -- cgit v1.1 From edb2e4c5b3d5ed5d75edf1b6efbfd8bffe427e13 Mon Sep 17 00:00:00 2001 From: BlueWall Date: Thu, 19 Jan 2012 13:55:53 -0500 Subject: Change URI to lowercase to match existing --- OpenSim/Server/Handlers/Grid/GridInfoHandlers.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim') diff --git a/OpenSim/Server/Handlers/Grid/GridInfoHandlers.cs b/OpenSim/Server/Handlers/Grid/GridInfoHandlers.cs index 67472e3..965a54e 100644 --- a/OpenSim/Server/Handlers/Grid/GridInfoHandlers.cs +++ b/OpenSim/Server/Handlers/Grid/GridInfoHandlers.cs @@ -187,7 +187,7 @@ namespace OpenSim.Server.Handlers.Grid if (!String.IsNullOrEmpty(HomeURI)) { - map["HomeURI"] = OSD.FromString(HomeURI); + map["home"] = OSD.FromString(HomeURI); } return OSDParser.SerializeJsonString(map).ToString(); -- cgit v1.1 From 9356963bd36e5c3b8c2b27bfcc2efa60ffbd02d6 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 19 Jan 2012 19:00:11 +0000 Subject: Add basic request and send image regression tests for LLImageManager --- OpenSim/Region/ClientStack/Linden/UDP/J2KImage.cs | 6 +- .../ClientStack/Linden/UDP/LLImageManager.cs | 6 +- .../Linden/UDP/Tests/LLImageManagerTests.cs | 92 +++++++++++++++++++++ .../Linden/UDP/Tests/Resources/4-tile2.jp2 | Bin 0 -> 24410 bytes .../World/Archiver/Tests/ArchiverTests.cs | 2 +- OpenSim/Tests/Common/Mock/TestClient.cs | 13 +-- 6 files changed, 107 insertions(+), 12 deletions(-) create mode 100644 OpenSim/Region/ClientStack/Linden/UDP/Tests/LLImageManagerTests.cs create mode 100644 OpenSim/Region/ClientStack/Linden/UDP/Tests/Resources/4-tile2.jp2 (limited to 'OpenSim') diff --git a/OpenSim/Region/ClientStack/Linden/UDP/J2KImage.cs b/OpenSim/Region/ClientStack/Linden/UDP/J2KImage.cs index 185a909..bbd2c43 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/J2KImage.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/J2KImage.cs @@ -82,7 +82,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// Maximum number of packets to send during this call /// Number of packets sent during this call /// True if the transfer completes at the current discard level, otherwise false - public bool SendPackets(LLClientView client, int packetsToSend, out int packetsSent) + public bool SendPackets(IClientAPI client, int packetsToSend, out int packetsSent) { packetsSent = 0; @@ -212,7 +212,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } } - private bool SendFirstPacket(LLClientView client) + private bool SendFirstPacket(IClientAPI client) { if (client == null) return false; @@ -247,7 +247,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP return false; } - private bool SendPacket(LLClientView client) + private bool SendPacket(IClientAPI client) { if (client == null) return false; diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLImageManager.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLImageManager.cs index db428f1..30d3712 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLImageManager.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLImageManager.cs @@ -55,16 +55,16 @@ namespace OpenSim.Region.ClientStack.LindenUDP private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private bool m_shuttingdown; private AssetBase m_missingImage; - private LLClientView m_client; //Client we're assigned to + private IClientAPI m_client; //Client we're assigned to private IAssetService m_assetCache; //Asset Cache private IJ2KDecoder m_j2kDecodeModule; //Our J2K module private C5.IntervalHeap m_priorityQueue = new C5.IntervalHeap(10, new J2KImageComparer()); private object m_syncRoot = new object(); - public LLClientView Client { get { return m_client; } } + public IClientAPI Client { get { return m_client; } } public AssetBase MissingImage { get { return m_missingImage; } } - public LLImageManager(LLClientView client, IAssetService pAssetCache, IJ2KDecoder pJ2kDecodeModule) + public LLImageManager(IClientAPI client, IAssetService pAssetCache, IJ2KDecoder pJ2kDecodeModule) { m_client = client; m_assetCache = pAssetCache; diff --git a/OpenSim/Region/ClientStack/Linden/UDP/Tests/LLImageManagerTests.cs b/OpenSim/Region/ClientStack/Linden/UDP/Tests/LLImageManagerTests.cs new file mode 100644 index 0000000..bdc9c7d --- /dev/null +++ b/OpenSim/Region/ClientStack/Linden/UDP/Tests/LLImageManagerTests.cs @@ -0,0 +1,92 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.IO; +using System.Net; +using System.Reflection; +using log4net.Config; +using Nini.Config; +using NUnit.Framework; +using OpenMetaverse; +using OpenMetaverse.Packets; +using OpenSim.Framework; +using OpenSim.Region.CoreModules.Agent.TextureSender; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Tests.Common; +using OpenSim.Tests.Common.Mock; + +namespace OpenSim.Region.ClientStack.LindenUDP.Tests +{ + [TestFixture] + public class LLImageManagerTests + { + [Test] + public void TestRequestAndSendImage() + { + TestHelpers.InMethod(); +// XmlConfigurator.Configure(); + + UUID imageId = TestHelpers.ParseTail(0x1); + string creatorId = TestHelpers.ParseTail(0x2).ToString(); + UUID userId = TestHelpers.ParseTail(0x3); + + J2KDecoderModule j2kdm = new J2KDecoderModule(); + + Scene scene = SceneHelpers.SetupScene(); + SceneHelpers.SetupSceneModules(scene, j2kdm); + + TestClient tc = new TestClient(SceneHelpers.GenerateAgentData(userId), scene); + LLImageManager llim = new LLImageManager(tc, scene.AssetService, j2kdm); + + using ( + Stream resource + = GetType().Assembly.GetManifestResourceStream( + "OpenSim.Region.ClientStack.LindenUDP.Tests.Resources.4-tile2.jp2")) + { + using (BinaryReader br = new BinaryReader(resource)) + { + AssetBase asset = new AssetBase(imageId, "Test Image", (sbyte)AssetType.Texture, creatorId); + asset.Data = br.ReadBytes(99999999); + scene.AssetService.Store(asset); + } + } + + TextureRequestArgs args = new TextureRequestArgs(); + args.RequestedAssetID = TestHelpers.ParseTail(0x1); + args.DiscardLevel = 0; + args.PacketNumber = 1; + args.Priority = 5; + args.requestSequence = 1; + + llim.EnqueueReq(args); + llim.ProcessImageQueue(20); + + Assert.That(tc.SentImageDataPackets.Count, Is.EqualTo(1)); + } + } +} \ No newline at end of file diff --git a/OpenSim/Region/ClientStack/Linden/UDP/Tests/Resources/4-tile2.jp2 b/OpenSim/Region/ClientStack/Linden/UDP/Tests/Resources/4-tile2.jp2 new file mode 100644 index 0000000..8c63104 Binary files /dev/null and b/OpenSim/Region/ClientStack/Linden/UDP/Tests/Resources/4-tile2.jp2 differ diff --git a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs index e798e5e..eec3c1b 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs @@ -344,7 +344,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests { using (BinaryReader br = new BinaryReader(resource)) { - // FIXME: Use the inspector insteadthere are so many forums and lists already, though admittedly none of them are suitable for cross virtual-enivornemnt discussion + // FIXME: Use the inspector instead soundData = br.ReadBytes(99999999); UUID soundUuid = UUID.Parse("00000000-0000-0000-0000-000000000001"); string soundAssetFileName diff --git a/OpenSim/Tests/Common/Mock/TestClient.cs b/OpenSim/Tests/Common/Mock/TestClient.cs index 37b90e1..2fc6572 100644 --- a/OpenSim/Tests/Common/Mock/TestClient.cs +++ b/OpenSim/Tests/Common/Mock/TestClient.cs @@ -44,9 +44,6 @@ namespace OpenSim.Tests.Common.Mock { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - // Mock testing variables - public List sentdatapkt = new List(); - public List sentpktpkt = new List(); EventWaitHandle wh = new EventWaitHandle (false, EventResetMode.AutoReset, "Crossing"); // TODO: This is a really nasty (and temporary) means of telling the test client which scene to invoke setup @@ -61,6 +58,9 @@ namespace OpenSim.Tests.Common.Mock public List ReceivedOnlineNotifications { get; private set; } public List ReceivedFriendshipTerminations { get; private set; } + public List SentImageDataPackets { get; private set; } + public List SentImagePacketPackets { get; private set; } + // disable warning: public events, part of the public API #pragma warning disable 67 @@ -452,6 +452,9 @@ namespace OpenSim.Tests.Common.Mock ReceivedOfflineNotifications = new List(); ReceivedOnlineNotifications = new List(); ReceivedFriendshipTerminations = new List(); + + SentImageDataPackets = new List(); + SentImagePacketPackets = new List(); } /// @@ -804,7 +807,7 @@ namespace OpenSim.Tests.Common.Mock im.ImageData.Data = ImageData; im.ImageID.Codec = imageCodec; im.Header.Zerocoded = true; - sentdatapkt.Add(im); + SentImageDataPackets.Add(im); } public void SendImageNextPart(ushort partNumber, UUID imageUuid, byte[] imageData) @@ -814,7 +817,7 @@ namespace OpenSim.Tests.Common.Mock im.ImageID.Packet = partNumber; im.ImageID.ID = imageUuid; im.ImageData.Data = imageData; - sentpktpkt.Add(im); + SentImagePacketPackets.Add(im); } public void SendImageNotFound(UUID imageid) -- cgit v1.1 From 8f871cca10274325bf90054d75019a865fc50216 Mon Sep 17 00:00:00 2001 From: BlueWall Date: Thu, 19 Jan 2012 14:21:12 -0500 Subject: Add osGetGridHomeURI function Add osGetHomeURI function to the family of osGetGrid* functions. Returns the SRV_HomeURI setting from the [LoginService] configuration. --- .../Shared/Api/Implementation/OSSL_Api.cs | 22 ++++++++++++++++++++++ .../ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | 1 + .../ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | 5 +++++ 3 files changed, 28 insertions(+) (limited to 'OpenSim') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index c682fda..7792ab5 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -1949,6 +1949,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api Nick, Name, Login, + Home, Custom }; @@ -1990,6 +1991,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api retval = json["login"]; break; + case InfoType.Home: + retval = json["home"]; + break; + case InfoType.Custom: retval = json[key]; break; @@ -2062,6 +2067,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return loginURI; } + public string osGetGridHomeURI() + { + CheckThreatLevel(ThreatLevel.Moderate, "osGetGridHomeURI"); + m_host.AddScriptLPS(1); + + string HomeURI = String.Empty; + IConfigSource config = m_ScriptEngine.ConfigSource; + + if (config.Configs["LoginService"] != null) + HomeURI = config.Configs["LoginService"].GetString("SRV_HomeURI", HomeURI); + + if (String.IsNullOrEmpty(HomeURI)) + HomeURI = GridUserInfo(InfoType.Home); + + return HomeURI; + } + public string osGetGridCustom(string key) { CheckThreatLevel(ThreatLevel.Moderate, "osGetGridCustom"); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index c1c4511..0f8cbdc 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs @@ -160,6 +160,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces string osGetGridNick(); string osGetGridName(); string osGetGridLoginURI(); + string osGetGridHomeURI(); string osGetGridCustom(string key); LSL_String osFormatString(string str, LSL_List strings); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs index fc83786..02efecf 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs @@ -452,6 +452,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase return m_OSSL_Functions.osGetGridLoginURI(); } + public string osGetGridHomeURI() + { + return m_OSSL_Functions.osGetGridHomeURI(); + } + public string osGetGridCustom(string key) { return m_OSSL_Functions.osGetGridCustom(key); -- cgit v1.1 From c92a9a664035ad4c36a0ac905751d105770dca51 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 19 Jan 2012 19:49:06 +0000 Subject: Add "image queues clear " console command This allows a way to manually clear pending image queue requests for debug purposes --- .../ClientStack/Linden/UDP/LLImageManager.cs | 20 ++++++ .../Agent/UDP/Linden/LindenUDPInfoModule.cs | 75 +++++++++++++++++----- 2 files changed, 80 insertions(+), 15 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLImageManager.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLImageManager.cs index 30d3712..7bfb844 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLImageManager.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLImageManager.cs @@ -246,6 +246,26 @@ namespace OpenSim.Region.ClientStack.LindenUDP } /// + /// Clear the image queue. + /// + /// The number of requests cleared. + public int ClearImageQueue() + { + int requestsDeleted; + + lock (m_priorityQueue) + { + requestsDeleted = m_priorityQueue.Count; + + // Surprisingly, there doesn't seem to be a clear method at this time. + while (!m_priorityQueue.IsEmpty) + m_priorityQueue.DeleteMax(); + } + + return requestsDeleted; + } + + /// /// Returns an array containing all the images in the queue. /// /// diff --git a/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs b/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs index db70e56..95aa864 100644 --- a/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs +++ b/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs @@ -79,7 +79,19 @@ namespace OpenSim.Region.CoreModules.UDP.Linden // m_log.DebugFormat("[LINDEN UDP INFO MODULE]: REGION {0} ADDED", scene.RegionInfo.RegionName); lock (m_scenes) - m_scenes[scene.RegionInfo.RegionID] = scene; + m_scenes[scene.RegionInfo.RegionID] = scene; + + scene.AddCommand( + this, "image queues clear", + "image queues clear ", + "Clear the image queues (textures downloaded via UDP) for a particular client.", + (mod, cmd) => MainConsole.Instance.Output(HandleImageQueuesClear(cmd))); + + scene.AddCommand( + this, "show image queues", + "image queues show ", + "Show the image queues (textures downloaded via UDP) for a particular client.", + (mod, cmd) => MainConsole.Instance.Output(GetImageQueuesReport(cmd))); scene.AddCommand( this, "show pqueues", @@ -116,7 +128,7 @@ namespace OpenSim.Region.CoreModules.UDP.Linden "emergency-monitoring", "Go on/off emergency monitoring mode", "Go on/off emergency monitoring mode", - EmergencyMonitoring); + HandleEmergencyMonitoring); } public void RemoveRegion(Scene scene) @@ -132,7 +144,49 @@ namespace OpenSim.Region.CoreModules.UDP.Linden // m_log.DebugFormat("[LINDEN UDP INFO MODULE]: REGION {0} LOADED", scene.RegionInfo.RegionName); } - protected void EmergencyMonitoring(string module, string[] cmd) + protected string HandleImageQueuesClear(string[] cmd) + { + if (cmd.Length != 5) + return "Usage: image queues clear "; + + string firstName = cmd[3]; + string lastName = cmd[4]; + + List foundAgents = new List(); + + lock (m_scenes) + { + foreach (Scene scene in m_scenes.Values) + { + ScenePresence sp = scene.GetScenePresence(firstName, lastName); + if (sp != null) + foundAgents.Add(sp); + } + } + + if (foundAgents.Count == 0) + return string.Format("No agents found for {0} {1}", firstName, lastName); + + StringBuilder report = new StringBuilder(); + + foreach (ScenePresence agent in foundAgents) + { + LLClientView client = agent.ControllingClient as LLClientView; + + if (client == null) + return "This command is only supported for LLClientView"; + + int requestsDeleted = client.ImageManager.ClearImageQueue(); + + report.AppendFormat( + "In region {0} ({1} agent) cleared {2} requests\n", + agent.Scene.RegionInfo.RegionName, agent.IsChildAgent ? "child" : "root", requestsDeleted); + } + + return report.ToString(); + } + + protected void HandleEmergencyMonitoring(string module, string[] cmd) { bool mode = true; if (cmd.Length == 1 || (cmd.Length > 1 && cmd[1] == "on")) @@ -239,10 +293,7 @@ namespace OpenSim.Region.CoreModules.UDP.Linden private string GetImageQueuesReport(string[] showParams) { if (showParams.Length < 5 || showParams.Length > 6) - { - MainConsole.Instance.OutputFormat("Usage: show image queues [full]"); - return ""; - } + return "Usage: show image queues [full]"; string firstName = showParams[3]; string lastName = showParams[4]; @@ -262,10 +313,7 @@ namespace OpenSim.Region.CoreModules.UDP.Linden } if (foundAgents.Count == 0) - { - MainConsole.Instance.OutputFormat("No agents found for {0} {1}", firstName, lastName); - return ""; - } + return string.Format("No agents found for {0} {1}", firstName, lastName); StringBuilder report = new StringBuilder(); @@ -274,10 +322,7 @@ namespace OpenSim.Region.CoreModules.UDP.Linden LLClientView client = agent.ControllingClient as LLClientView; if (client == null) - { - MainConsole.Instance.OutputFormat("This command is only supported for LLClientView"); - return ""; - } + return "This command is only supported for LLClientView"; J2KImage[] images = client.ImageManager.GetImages(); -- cgit v1.1 From 381f74276b94f9f635b08c4bccf3040fce5d59fb Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 19 Jan 2012 21:14:09 +0000 Subject: Add LLImageManager regression test for discard case --- .../Linden/UDP/Tests/LLImageManagerTests.cs | 53 ++++++++++++++++++++++ 1 file changed, 53 insertions(+) (limited to 'OpenSim') diff --git a/OpenSim/Region/ClientStack/Linden/UDP/Tests/LLImageManagerTests.cs b/OpenSim/Region/ClientStack/Linden/UDP/Tests/LLImageManagerTests.cs index bdc9c7d..118333c 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/Tests/LLImageManagerTests.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/Tests/LLImageManagerTests.cs @@ -88,5 +88,58 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests Assert.That(tc.SentImageDataPackets.Count, Is.EqualTo(1)); } + + [Test] + public void TestRequestAndDiscardImage() + { + TestHelpers.InMethod(); +// XmlConfigurator.Configure(); + + UUID imageId = TestHelpers.ParseTail(0x1); + string creatorId = TestHelpers.ParseTail(0x2).ToString(); + UUID userId = TestHelpers.ParseTail(0x3); + + J2KDecoderModule j2kdm = new J2KDecoderModule(); + + Scene scene = SceneHelpers.SetupScene(); + SceneHelpers.SetupSceneModules(scene, j2kdm); + + TestClient tc = new TestClient(SceneHelpers.GenerateAgentData(userId), scene); + LLImageManager llim = new LLImageManager(tc, scene.AssetService, j2kdm); + + using ( + Stream resource + = GetType().Assembly.GetManifestResourceStream( + "OpenSim.Region.ClientStack.LindenUDP.Tests.Resources.4-tile2.jp2")) + { + using (BinaryReader br = new BinaryReader(resource)) + { + AssetBase asset = new AssetBase(imageId, "Test Image", (sbyte)AssetType.Texture, creatorId); + asset.Data = br.ReadBytes(99999999); + scene.AssetService.Store(asset); + } + } + + TextureRequestArgs args = new TextureRequestArgs(); + args.RequestedAssetID = imageId; + args.DiscardLevel = 0; + args.PacketNumber = 1; + args.Priority = 5; + args.requestSequence = 1; + llim.EnqueueReq(args); + + // Now create a discard request + TextureRequestArgs discardArgs = new TextureRequestArgs(); + discardArgs.RequestedAssetID = imageId; + discardArgs.DiscardLevel = -1; + discardArgs.PacketNumber = 1; + discardArgs.Priority = 0; + discardArgs.requestSequence = 2; + llim.EnqueueReq(discardArgs); + + llim.ProcessImageQueue(20); + + Assert.That(tc.SentImageDataPackets.Count, Is.EqualTo(0)); + } } } \ No newline at end of file -- cgit v1.1 From 503faaea62502e1e86fc11bee1a322e060836f62 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 19 Jan 2012 21:23:40 +0000 Subject: refactor: separate out common parts of LLImageManagerTests --- .../Linden/UDP/Tests/LLImageManagerTests.cs | 88 ++++++++++------------ 1 file changed, 40 insertions(+), 48 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ClientStack/Linden/UDP/Tests/LLImageManagerTests.cs b/OpenSim/Region/ClientStack/Linden/UDP/Tests/LLImageManagerTests.cs index 118333c..f176964 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/Tests/LLImageManagerTests.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/Tests/LLImageManagerTests.cs @@ -45,24 +45,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests [TestFixture] public class LLImageManagerTests { - [Test] - public void TestRequestAndSendImage() - { - TestHelpers.InMethod(); -// XmlConfigurator.Configure(); - - UUID imageId = TestHelpers.ParseTail(0x1); - string creatorId = TestHelpers.ParseTail(0x2).ToString(); - UUID userId = TestHelpers.ParseTail(0x3); - - J2KDecoderModule j2kdm = new J2KDecoderModule(); - - Scene scene = SceneHelpers.SetupScene(); - SceneHelpers.SetupSceneModules(scene, j2kdm); - - TestClient tc = new TestClient(SceneHelpers.GenerateAgentData(userId), scene); - LLImageManager llim = new LLImageManager(tc, scene.AssetService, j2kdm); + private AssetBase m_testImageAsset; + private LLImageManager llim; + private TestClient tc; + [TestFixtureSetUp] + public void FixtureInit() + { using ( Stream resource = GetType().Assembly.GetManifestResourceStream( @@ -70,14 +59,42 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests { using (BinaryReader br = new BinaryReader(resource)) { - AssetBase asset = new AssetBase(imageId, "Test Image", (sbyte)AssetType.Texture, creatorId); - asset.Data = br.ReadBytes(99999999); - scene.AssetService.Store(asset); + m_testImageAsset + = new AssetBase( + TestHelpers.ParseTail(0x1), + "Test Image", + (sbyte)AssetType.Texture, + TestHelpers.ParseTail(0x2).ToString()); + + m_testImageAsset.Data = br.ReadBytes(99999999); } } + } + + [SetUp] + public void SetUp() + { + UUID userId = TestHelpers.ParseTail(0x3); + + J2KDecoderModule j2kdm = new J2KDecoderModule(); + + Scene scene = SceneHelpers.SetupScene(); + SceneHelpers.SetupSceneModules(scene, j2kdm); + + scene.AssetService.Store(m_testImageAsset); + + tc = new TestClient(SceneHelpers.GenerateAgentData(userId), scene); + llim = new LLImageManager(tc, scene.AssetService, j2kdm); + } + + [Test] + public void TestRequestAndSendImage() + { + TestHelpers.InMethod(); +// XmlConfigurator.Configure(); TextureRequestArgs args = new TextureRequestArgs(); - args.RequestedAssetID = TestHelpers.ParseTail(0x1); + args.RequestedAssetID = m_testImageAsset.FullID; args.DiscardLevel = 0; args.PacketNumber = 1; args.Priority = 5; @@ -95,33 +112,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests TestHelpers.InMethod(); // XmlConfigurator.Configure(); - UUID imageId = TestHelpers.ParseTail(0x1); - string creatorId = TestHelpers.ParseTail(0x2).ToString(); - UUID userId = TestHelpers.ParseTail(0x3); - - J2KDecoderModule j2kdm = new J2KDecoderModule(); - - Scene scene = SceneHelpers.SetupScene(); - SceneHelpers.SetupSceneModules(scene, j2kdm); - - TestClient tc = new TestClient(SceneHelpers.GenerateAgentData(userId), scene); - LLImageManager llim = new LLImageManager(tc, scene.AssetService, j2kdm); - - using ( - Stream resource - = GetType().Assembly.GetManifestResourceStream( - "OpenSim.Region.ClientStack.LindenUDP.Tests.Resources.4-tile2.jp2")) - { - using (BinaryReader br = new BinaryReader(resource)) - { - AssetBase asset = new AssetBase(imageId, "Test Image", (sbyte)AssetType.Texture, creatorId); - asset.Data = br.ReadBytes(99999999); - scene.AssetService.Store(asset); - } - } - TextureRequestArgs args = new TextureRequestArgs(); - args.RequestedAssetID = imageId; + args.RequestedAssetID = m_testImageAsset.FullID; args.DiscardLevel = 0; args.PacketNumber = 1; args.Priority = 5; @@ -130,7 +122,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests // Now create a discard request TextureRequestArgs discardArgs = new TextureRequestArgs(); - discardArgs.RequestedAssetID = imageId; + discardArgs.RequestedAssetID = m_testImageAsset.FullID; discardArgs.DiscardLevel = -1; discardArgs.PacketNumber = 1; discardArgs.Priority = 0; -- cgit v1.1 From d38e2c0c91b684d54974865d3ac2fb88c3354c21 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 19 Jan 2012 21:57:12 +0000 Subject: Add image not in database test for LLImageManager --- OpenSim/Region/ClientStack/Linden/UDP/J2KImage.cs | 3 ++ .../ClientStack/Linden/UDP/LLImageManager.cs | 29 +++++++++++++------ .../Linden/UDP/Tests/LLImageManagerTests.cs | 33 ++++++++++++++++++---- OpenSim/Tests/Common/Mock/TestClient.cs | 6 ++++ 4 files changed, 58 insertions(+), 13 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ClientStack/Linden/UDP/J2KImage.cs b/OpenSim/Region/ClientStack/Linden/UDP/J2KImage.cs index bbd2c43..8dd76d8 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/J2KImage.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/J2KImage.cs @@ -377,6 +377,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP private void AssetReceived(string id, Object sender, AssetBase asset) { +// m_log.DebugFormat( +// "[J2KIMAGE]: Received asset {0} ({1} bytes)", id, asset != null ? asset.Data.Length.ToString() : "n/a"); + UUID assetID = UUID.Zero; if (asset != null) { diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLImageManager.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLImageManager.cs index 7bfb844..a48251f 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLImageManager.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLImageManager.cs @@ -55,18 +55,29 @@ namespace OpenSim.Region.ClientStack.LindenUDP private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private bool m_shuttingdown; private AssetBase m_missingImage; - private IClientAPI m_client; //Client we're assigned to - private IAssetService m_assetCache; //Asset Cache - private IJ2KDecoder m_j2kDecodeModule; //Our J2K module + private IAssetService m_assetCache; + private IJ2KDecoder m_j2kDecodeModule; + + /// + /// Priority queue for determining which image to send first. + /// private C5.IntervalHeap m_priorityQueue = new C5.IntervalHeap(10, new J2KImageComparer()); + + /// + /// Used to control thread access to the priority queue. + /// private object m_syncRoot = new object(); - public IClientAPI Client { get { return m_client; } } + /// + /// Client served by this image manager + /// + public IClientAPI Client { get; private set; } + public AssetBase MissingImage { get { return m_missingImage; } } public LLImageManager(IClientAPI client, IAssetService pAssetCache, IJ2KDecoder pJ2kDecodeModule) { - m_client = client; + Client = client; m_assetCache = pAssetCache; if (pAssetCache != null) @@ -90,7 +101,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP // Do a linear search for this texture download lock (m_syncRoot) + { m_priorityQueue.Find(delegate(J2KImage img) { return img.TextureID == newRequest.RequestedAssetID; }, out imgrequest); + } if (imgrequest != null) { @@ -178,8 +191,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP imgrequest = new J2KImage(this); imgrequest.J2KDecoder = m_j2kDecodeModule; imgrequest.AssetService = m_assetCache; - imgrequest.AgentID = m_client.AgentId; - imgrequest.InventoryAccessModule = m_client.Scene.RequestModuleInterface(); + imgrequest.AgentID = Client.AgentId; + imgrequest.InventoryAccessModule = Client.Scene.RequestModuleInterface(); imgrequest.DiscardLevel = newRequest.DiscardLevel; imgrequest.StartPacket = Math.Max(1, newRequest.PacketNumber); imgrequest.Priority = newRequest.Priority; @@ -210,7 +223,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP if (image.IsDecoded) { int sent; - bool imageDone = image.SendPackets(m_client, packetsToSend - packetsSent, out sent); + bool imageDone = image.SendPackets(Client, packetsToSend - packetsSent, out sent); packetsSent += sent; // If the send is complete, destroy any knowledge of this transfer diff --git a/OpenSim/Region/ClientStack/Linden/UDP/Tests/LLImageManagerTests.cs b/OpenSim/Region/ClientStack/Linden/UDP/Tests/LLImageManagerTests.cs index f176964..1b68d68 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/Tests/LLImageManagerTests.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/Tests/LLImageManagerTests.cs @@ -46,6 +46,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests public class LLImageManagerTests { private AssetBase m_testImageAsset; + private Scene scene; private LLImageManager llim; private TestClient tc; @@ -78,21 +79,21 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests J2KDecoderModule j2kdm = new J2KDecoderModule(); - Scene scene = SceneHelpers.SetupScene(); + scene = SceneHelpers.SetupScene(); SceneHelpers.SetupSceneModules(scene, j2kdm); - scene.AssetService.Store(m_testImageAsset); - tc = new TestClient(SceneHelpers.GenerateAgentData(userId), scene); llim = new LLImageManager(tc, scene.AssetService, j2kdm); } [Test] - public void TestRequestAndSendImage() + public void TestSendImage() { TestHelpers.InMethod(); // XmlConfigurator.Configure(); + scene.AssetService.Store(m_testImageAsset); + TextureRequestArgs args = new TextureRequestArgs(); args.RequestedAssetID = m_testImageAsset.FullID; args.DiscardLevel = 0; @@ -107,11 +108,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests } [Test] - public void TestRequestAndDiscardImage() + public void TestDiscardImage() { TestHelpers.InMethod(); // XmlConfigurator.Configure(); + scene.AssetService.Store(m_testImageAsset); + TextureRequestArgs args = new TextureRequestArgs(); args.RequestedAssetID = m_testImageAsset.FullID; args.DiscardLevel = 0; @@ -133,5 +136,25 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests Assert.That(tc.SentImageDataPackets.Count, Is.EqualTo(0)); } + + [Test] + public void TestMissingImage() + { + TestHelpers.InMethod(); +// XmlConfigurator.Configure(); + + TextureRequestArgs args = new TextureRequestArgs(); + args.RequestedAssetID = m_testImageAsset.FullID; + args.DiscardLevel = 0; + args.PacketNumber = 1; + args.Priority = 5; + args.requestSequence = 1; + + llim.EnqueueReq(args); + llim.ProcessImageQueue(20); + + Assert.That(tc.SentImageDataPackets.Count, Is.EqualTo(0)); + Assert.That(tc.SentImageNotInDatabasePackets.Count, Is.EqualTo(1)); + } } } \ No newline at end of file diff --git a/OpenSim/Tests/Common/Mock/TestClient.cs b/OpenSim/Tests/Common/Mock/TestClient.cs index 2fc6572..fad757a 100644 --- a/OpenSim/Tests/Common/Mock/TestClient.cs +++ b/OpenSim/Tests/Common/Mock/TestClient.cs @@ -60,6 +60,7 @@ namespace OpenSim.Tests.Common.Mock public List SentImageDataPackets { get; private set; } public List SentImagePacketPackets { get; private set; } + public List SentImageNotInDatabasePackets { get; private set; } // disable warning: public events, part of the public API #pragma warning disable 67 @@ -455,6 +456,7 @@ namespace OpenSim.Tests.Common.Mock SentImageDataPackets = new List(); SentImagePacketPackets = new List(); + SentImageNotInDatabasePackets = new List(); } /// @@ -822,6 +824,10 @@ namespace OpenSim.Tests.Common.Mock public void SendImageNotFound(UUID imageid) { + ImageNotInDatabasePacket p = new ImageNotInDatabasePacket(); + p.ImageID.ID = imageid; + + SentImageNotInDatabasePackets.Add(p); } public void SendShutdownConnectionNotice() -- cgit v1.1 From ea72428c9d3fa27ab43bb3e0b2e297bf3b22861e Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 19 Jan 2012 23:09:16 +0000 Subject: Allow a viewer UDP image request retry to trigger another asset fetch if an existing fetch hasn't responded before a timeout. This is to stop a high priority image/texture request from blocking the entire download queue if its asset fetch got dropped for some reason. --- OpenSim/Region/ClientStack/Linden/UDP/J2KImage.cs | 32 ++++++++++++++++++++-- .../ClientStack/Linden/UDP/LLImageManager.cs | 6 ++-- 2 files changed, 32 insertions(+), 6 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ClientStack/Linden/UDP/J2KImage.cs b/OpenSim/Region/ClientStack/Linden/UDP/J2KImage.cs index 8dd76d8..afbe56b 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/J2KImage.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/J2KImage.cs @@ -45,6 +45,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP private const int IMAGE_PACKET_SIZE = 1000; private const int FIRST_PACKET_SIZE = 600; + /// + /// If we've requested an asset but not received it in this ticks timeframe, then allow a duplicate + /// request from the client to trigger a fresh asset request. + /// + /// + /// There are 10,000 ticks in a millisecond + /// + private const int ASSET_REQUEST_TIMEOUT = 100000000; + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); public uint LastSequence; @@ -57,8 +66,22 @@ namespace OpenSim.Region.ClientStack.LindenUDP public UUID AgentID; public IInventoryAccessModule InventoryAccessModule; private OpenJPEG.J2KLayerInfo[] m_layers; + + /// + /// Has this request decoded the asset data? + /// public bool IsDecoded { get; private set; } + + /// + /// Has this request received the required asset data? + /// public bool HasAsset { get; private set; } + + /// + /// Time in milliseconds at which the asset was requested. + /// + public long AssetRequestTime { get; private set; } + public C5.IPriorityQueueHandle PriorityQueueHandle; private uint m_currentPacket; @@ -123,10 +146,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP { if (!HasAsset) { - if (!m_assetRequested) + if (!m_assetRequested || DateTime.UtcNow.Ticks > AssetRequestTime + ASSET_REQUEST_TIMEOUT) { +// m_log.DebugFormat( +// "[J2KIMAGE]: Requesting asset {0} from request in packet {1}, already requested? {2}, due to timeout? {3}", +// TextureID, LastSequence, m_assetRequested, DateTime.UtcNow.Ticks > AssetRequestTime + ASSET_REQUEST_TIMEOUT); + m_assetRequested = true; -// m_log.DebugFormat("[J2KIMAGE]: Requesting asset {0}", TextureID); + AssetRequestTime = DateTime.UtcNow.Ticks; + AssetService.Get(TextureID.ToString(), this, AssetReceived); } } diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLImageManager.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLImageManager.cs index a48251f..073c357 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLImageManager.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLImageManager.cs @@ -101,9 +101,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP // Do a linear search for this texture download lock (m_syncRoot) - { m_priorityQueue.Find(delegate(J2KImage img) { return img.TextureID == newRequest.RequestedAssetID; }, out imgrequest); - } if (imgrequest != null) { @@ -124,8 +122,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP // "[LL IMAGE MANAGER]: Received duplicate of existing request for {0}, start packet {1} from {2}", // newRequest.RequestedAssetID, newRequest.PacketNumber, m_client.Name); - //m_log.DebugFormat("[TEX]: (UPD) ID={0}: D={1}, S={2}, P={3}", - // newRequest.RequestedAssetID, newRequest.DiscardLevel, newRequest.PacketNumber, newRequest.Priority); +// m_log.DebugFormat("[TEX]: (UPD) ID={0}: D={1}, S={2}, P={3}", +// newRequest.RequestedAssetID, newRequest.DiscardLevel, newRequest.PacketNumber, newRequest.Priority); //Check the packet sequence to make sure this isn't older than //one we've already received -- cgit v1.1 From b6f3de5028ab9a288f60b020a0dffda079dc550d Mon Sep 17 00:00:00 2001 From: BlueWall Date: Fri, 20 Jan 2012 23:50:37 -0500 Subject: Telehub Support: Support for viewer side of telehub management. Can manupulate Telehubs and SpawnPoints from the viewer estate managemnt tools. This is a work in progress and does not yet persist or affect teleport routing. --- OpenSim/Framework/IClientAPI.cs | 5 + .../Region/ClientStack/Linden/UDP/LLClientView.cs | 39 ++++++- .../World/Estate/EstateManagementModule.cs | 65 ++++++++++- .../CoreModules/World/Estate/TelehubManager.cs | 130 +++++++++++++++++++++ .../Server/IRCClientView.cs | 6 + .../Region/OptionalModules/World/NPC/NPCAvatar.cs | 5 + OpenSim/Tests/Common/Mock/TestClient.cs | 5 + 7 files changed, 251 insertions(+), 4 deletions(-) create mode 100644 OpenSim/Region/CoreModules/World/Estate/TelehubManager.cs (limited to 'OpenSim') diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs index 29a69c3..1326fe9 100644 --- a/OpenSim/Framework/IClientAPI.cs +++ b/OpenSim/Framework/IClientAPI.cs @@ -358,6 +358,8 @@ namespace OpenSim.Framework public delegate void EstateChangeInfo(IClientAPI client, UUID invoice, UUID senderID, UInt32 param1, UInt32 param2); + public delegate void EstateManageTelehub(IClientAPI client, UUID invoice, UUID senderID, string cmd, UInt32 param1); + public delegate void RequestTerrain(IClientAPI remoteClient, string clientFileName); public delegate void BakeTerrain(IClientAPI remoteClient); @@ -769,6 +771,7 @@ namespace OpenSim.Framework event ModifyTerrain OnModifyTerrain; event BakeTerrain OnBakeTerrain; event EstateChangeInfo OnEstateChangeInfo; + event EstateManageTelehub OnEstateManageTelehub; // [Obsolete("LLClientView Specific.")] event SetAppearance OnSetAppearance; // [Obsolete("LLClientView Specific - Replace and rename OnAvatarUpdate. Difference from SetAppearance?")] @@ -1141,6 +1144,8 @@ namespace OpenSim.Framework void SendTaskInventory(UUID taskID, short serial, byte[] fileName); + void SendTelehubInfo(UUID ObjectID, string ObjectName, Vector3 ObjectPos, Quaternion ObjectRot, List SpawnPoint); + /// /// Used by the server to inform the client of new inventory items and folders. /// diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index 4ba441e..a94fb20 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -219,6 +219,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP public event BakeTerrain OnBakeTerrain; public event RequestTerrain OnUploadTerrain; public event EstateChangeInfo OnEstateChangeInfo; + public event EstateManageTelehub OnEstateManageTelehub; public event EstateRestartSimRequest OnEstateRestartSimRequest; public event EstateChangeCovenantRequest OnEstateChangeCovenantRequest; public event UpdateEstateAccessDeltaRequest OnUpdateEstateAccessDeltaRequest; @@ -4482,6 +4483,23 @@ namespace OpenSim.Region.ClientStack.LindenUDP OutPacket(packet, ThrottleOutPacketType.Task); } + public void SendTelehubInfo(UUID ObjectID, string ObjectName, Vector3 ObjectPos, Quaternion ObjectRot, List SpawnPoint) + { + TelehubInfoPacket packet = (TelehubInfoPacket)PacketPool.Instance.GetPacket(PacketType.TelehubInfo); + packet.TelehubBlock.ObjectID = ObjectID; + packet.TelehubBlock.ObjectName = Utils.StringToBytes(ObjectName); + packet.TelehubBlock.TelehubPos = ObjectPos; + packet.TelehubBlock.TelehubRot = ObjectRot; + + packet.SpawnPointBlock = new TelehubInfoPacket.SpawnPointBlockBlock[SpawnPoint.Count]; + for (int n = 0; n < SpawnPoint.Count; n++) + { + packet.SpawnPointBlock[n] = new TelehubInfoPacket.SpawnPointBlockBlock{SpawnPointPos = SpawnPoint[n]}; + } + + OutPacket(packet, ThrottleOutPacketType.Task); + } + #endregion #region Land Data Sending Methods @@ -8920,7 +8938,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP private bool HandleEstateOwnerMessage(IClientAPI sender, Packet Pack) { EstateOwnerMessagePacket messagePacket = (EstateOwnerMessagePacket)Pack; - //m_log.Debug(messagePacket.ToString()); + // m_log.InfoFormat("[LLCLIENTVIEW]: Packet: {0}", Utils.BytesToString(messagePacket.MethodData.Method)); GodLandStatRequest handlerLandStatRequest; #region Packet Session and User Check @@ -9219,6 +9237,23 @@ namespace OpenSim.Region.ClientStack.LindenUDP } return true; + case "telehub": + if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false)) + { + UUID invoice = messagePacket.MethodData.Invoice; + UUID SenderID = messagePacket.AgentData.AgentID; + UInt32 param1 = Convert.ToUInt32(Utils.BytesToString(messagePacket.ParamList[1].Parameter)); + + string command = (string)Utils.BytesToString(messagePacket.ParamList[0].Parameter); + + EstateManageTelehub handlerEstateManageTelehub = OnEstateManageTelehub; + if (handlerEstateManageTelehub != null) + { + handlerEstateManageTelehub(this, invoice, SenderID, command, param1); + } + } + return true; + default: m_log.Error("EstateOwnerMessage: Unknown method requested\n" + messagePacket); return true; @@ -9230,8 +9265,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP //lsrp.RequestData.ReportType; // 1 = colliders, 0 = scripts //lsrp.RequestData.RequestFlags; //lsrp.RequestData.Filter; - -// return true; } private bool HandleRequestRegionInfo(IClientAPI sender, Packet Pack) diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs index 58d9455..0d4df6c 100644 --- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs @@ -53,6 +53,7 @@ namespace OpenSim.Region.CoreModules.World.Estate protected EstateManagementCommands m_commands; private EstateTerrainXferHandler TerrainUploader; + private TelehubManager m_Telehub; public event ChangeDelegate OnRegionInfoChange; public event ChangeDelegate OnEstateInfoChange; @@ -599,6 +600,65 @@ namespace OpenSim.Region.CoreModules.World.Estate } } + private void handleOnEstateManageTelehub (IClientAPI client, UUID invoice, UUID senderID, string cmd, uint param1) + { + uint ObjectLocalID; + SceneObjectPart part; + // UUID EstateID = Scene.RegionInfo.EstateSettings.EstateID; + TelehubManager.Telehub telehub; + + switch (cmd) + { + case "info ui": + // Send info: + if (m_Telehub.HasTelehub) + { + telehub = m_Telehub.TelehubVals(); + client.SendTelehubInfo(telehub.ObjectID, telehub.ObjectName, telehub.ObjectPosition, + telehub.ObjectRotation, telehub.SpawnPoint); + } + else + { + return; + } + break; + + case "connect": + // Add the Telehub + part = Scene.GetSceneObjectPart((uint)param1); + telehub = m_Telehub.Connect(part); + client.SendTelehubInfo(telehub.ObjectID, telehub.ObjectName, telehub.ObjectPosition, + telehub.ObjectRotation, telehub.SpawnPoint); + break; + + case "delete": + // Disconnect Telehub + part = Scene.GetSceneObjectPart((uint)param1); + telehub = m_Telehub.DisConnect(part); + client.SendTelehubInfo(telehub.ObjectID, telehub.ObjectName, telehub.ObjectPosition, + telehub.ObjectRotation, telehub.SpawnPoint); + break; + + case "spawnpoint add": + // Add SpawnPoint to the Telehub + part = Scene.GetSceneObjectPart((uint)param1); + telehub = m_Telehub.AddSpawnPoint(part.AbsolutePosition); + client.SendTelehubInfo(telehub.ObjectID, telehub.ObjectName, telehub.ObjectPosition, + telehub.ObjectRotation, telehub.SpawnPoint); + break; + + case "spawnpoint remove": + // Remove SpawnPoint from Telehub + telehub = m_Telehub.RemoveSpawnPoint((int)param1); + client.SendTelehubInfo(telehub.ObjectID, telehub.ObjectName, telehub.ObjectPosition, + telehub.ObjectRotation, telehub.SpawnPoint); + break; + + default: + break; + } + } + private void SendSimulatorBlueBoxMessage( IClientAPI remote_client, UUID invoice, UUID senderID, UUID sessionID, string senderName, string message) { @@ -1055,7 +1115,9 @@ namespace OpenSim.Region.CoreModules.World.Estate Scene.RegisterModuleInterface(this); Scene.EventManager.OnNewClient += EventManager_OnNewClient; Scene.EventManager.OnRequestChangeWaterHeight += changeWaterHeight; - + + m_Telehub = new TelehubManager(scene); + m_commands = new EstateManagementCommands(this); m_commands.Initialise(); } @@ -1109,6 +1171,7 @@ namespace OpenSim.Region.CoreModules.World.Estate client.OnEstateRestartSimRequest += handleEstateRestartSimRequest; client.OnEstateChangeCovenantRequest += handleChangeEstateCovenantRequest; client.OnEstateChangeInfo += handleEstateChangeInfo; + client.OnEstateManageTelehub += handleOnEstateManageTelehub; client.OnUpdateEstateAccessDeltaRequest += handleEstateAccessDeltaRequest; client.OnSimulatorBlueBoxMessageRequest += SendSimulatorBlueBoxMessage; client.OnEstateBlueBoxMessageRequest += SendEstateBlueBoxMessage; diff --git a/OpenSim/Region/CoreModules/World/Estate/TelehubManager.cs b/OpenSim/Region/CoreModules/World/Estate/TelehubManager.cs new file mode 100644 index 0000000..c99c9ba --- /dev/null +++ b/OpenSim/Region/CoreModules/World/Estate/TelehubManager.cs @@ -0,0 +1,130 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using OpenMetaverse; +using System.Collections.Generic; +using OpenSim.Framework; +using OpenSim.Region.Framework.Scenes; + +namespace OpenSim.Region.CoreModules.World.Estate +{ + public class TelehubManager + { + public struct Telehub + { + public UUID ObjectID; + public string ObjectName; + public Vector3 ObjectPosition; + public Quaternion ObjectRotation; + public List SpawnPoint; + }; + + private UUID ObjectID; + private string ObjectName; + private Vector3 ObjectPosition; + Quaternion ObjectRotation; + List SpawnPoint = new List(); + UUID EstateID; + bool m_HasTelehub = false; + Scene m_Scene; + // This will get an option... + Vector3 InitialSpawnPoint = new Vector3(0.0f,0.0f,-3.0f); + + public bool HasTelehub + { + get { return m_HasTelehub; } + } + + public TelehubManager(Scene scene) + { + m_Scene = scene; + } + + // Fill our Telehub struct with values + public Telehub TelehubVals() + { + Telehub telehub = new Telehub(); + + telehub.ObjectID = ObjectID; + telehub.ObjectName = ObjectName; + telehub.ObjectPosition = ObjectPosition; + telehub.ObjectRotation = ObjectRotation; + telehub.SpawnPoint = SpawnPoint; + return telehub; + } + + // Connect the Telehub + public Telehub Connect(SceneObjectPart part) + { + ObjectID = part.UUID; + ObjectName = part.Name; + ObjectPosition = part.AbsolutePosition; + ObjectRotation = part.GetWorldRotation(); + // Clear this for now + SpawnPoint.Clear(); + SpawnPoint.Add(InitialSpawnPoint); + m_HasTelehub = true; + + return TelehubVals(); + } + + // Disconnect the Telehub + public Telehub DisConnect(SceneObjectPart part) + { + ObjectID = UUID.Zero; + ObjectName = String.Empty; + ObjectPosition = Vector3.Zero; + ObjectRotation = Quaternion.Identity; + SpawnPoint.Clear(); + m_HasTelehub = false; + + return TelehubVals(); + } + + // Add a SpawnPoint to the Telehub + public Telehub AddSpawnPoint(Vector3 point) + { + float dist = (float) Util.GetDistanceTo(ObjectPosition, point); + + Vector3 nvec = Util.GetNormalizedVector(point - ObjectPosition); + + Vector3 spoint = nvec * dist; + + SpawnPoint.Add(spoint); + return TelehubVals(); + } + + // Remove a SpawnPoint from the Telehub + public Telehub RemoveSpawnPoint(int spawnpoint) + { + SpawnPoint.RemoveAt(spawnpoint); + + return TelehubVals(); + } + } +} \ No newline at end of file diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs index 32de85f..bbf3729 100644 --- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs +++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs @@ -658,6 +658,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server public event ModifyTerrain OnModifyTerrain; public event BakeTerrain OnBakeTerrain; public event EstateChangeInfo OnEstateChangeInfo; + public event EstateManageTelehub OnEstateManageTelehub; public event SetAppearance OnSetAppearance; public event AvatarNowWearing OnAvatarNowWearing; public event RezSingleAttachmentFromInv OnRezSingleAttachmentFromInv; @@ -1530,6 +1531,11 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server } + public void SendTelehubInfo(UUID ObjectID, string ObjectName, Vector3 ObjectPos, Quaternion ObjectRot, List SpawnPoint) + { + + } + public void SendMapItemReply(mapItemReply[] replies, uint mapitemtype, uint flags) { diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs index 5f4f937..6a6c4c3 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs @@ -32,6 +32,7 @@ using OpenMetaverse; using OpenMetaverse.Packets; using OpenSim.Framework; using OpenSim.Region.Framework.Scenes; +using OpenSim.Region.CoreModules.World.Estate; namespace OpenSim.Region.OptionalModules.World.NPC { @@ -334,6 +335,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC public event EstateTeleportOneUserHomeRequest OnEstateTeleportOneUserHomeRequest; public event EstateTeleportAllUsersHomeRequest OnEstateTeleportAllUsersHomeRequest; public event EstateChangeInfo OnEstateChangeInfo; + public event EstateManageTelehub OnEstateManageTelehub; public event ScriptReset OnScriptReset; public event GetScriptRunning OnGetScriptRunning; public event SetScriptRunning OnSetScriptRunning; @@ -923,6 +925,9 @@ namespace OpenSim.Region.OptionalModules.World.NPC public void SendEstateCovenantInformation(UUID covenant) { } + public void SendTelehubInfo(UUID ObjectID, string ObjectName, Vector3 ObjectPos, Quaternion ObjectRot, List SpawnPoint) + { + } public void SendDetailedEstateData(UUID invoice, string estateName, uint estateID, uint parentEstate, uint estateFlags, uint sunPosition, UUID covenant, string abuseEmail, UUID estateOwner) { } diff --git a/OpenSim/Tests/Common/Mock/TestClient.cs b/OpenSim/Tests/Common/Mock/TestClient.cs index 2fc6572..8a71dfd 100644 --- a/OpenSim/Tests/Common/Mock/TestClient.cs +++ b/OpenSim/Tests/Common/Mock/TestClient.cs @@ -193,6 +193,7 @@ namespace OpenSim.Tests.Common.Mock public event RegionInfoRequest OnRegionInfoRequest; public event EstateCovenantRequest OnEstateCovenantRequest; public event EstateChangeInfo OnEstateChangeInfo; + public event EstateManageTelehub OnEstateManageTelehub; public event ObjectDuplicateOnRay OnObjectDuplicateOnRay; @@ -945,6 +946,10 @@ namespace OpenSim.Tests.Common.Mock { } + public void SendTelehubInfo(UUID ObjectID, string ObjectName, Vector3 ObjectPos, Quaternion ObjectRot, List SpawnPoint) + { + } + public void SendEstateList(UUID invoice, int code, UUID[] Data, uint estateID) { } -- cgit v1.1 From 32d58d6e3e9a0ea1bfa808567d0f64c0652f8a85 Mon Sep 17 00:00:00 2001 From: BlueWall Date: Sat, 21 Jan 2012 23:26:27 -0500 Subject: Telehub Support: Telehub settings now persist to the database and are saved across sim restarts. So-far this only works on MySQL. this is a work in progress, teleport routing is not yet implemented. --- OpenSim/Data/MySQL/MySQLEstateData.cs | 66 ++++++++- .../Data/MySQL/Resources/EstateStore.migrations | 21 +++ OpenSim/Framework/EstateSettings.cs | 150 +++++++++++++++++++++ .../Region/ClientStack/Linden/UDP/LLClientView.cs | 14 +- .../World/Estate/EstateManagementModule.cs | 50 ++++--- .../CoreModules/World/Estate/TelehubManager.cs | 111 ++++++++------- 6 files changed, 341 insertions(+), 71 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Data/MySQL/MySQLEstateData.cs b/OpenSim/Data/MySQL/MySQLEstateData.cs index 3d647ca..a357268 100644 --- a/OpenSim/Data/MySQL/MySQLEstateData.cs +++ b/OpenSim/Data/MySQL/MySQLEstateData.cs @@ -157,6 +157,7 @@ namespace OpenSim.Data.MySQL DoCreate(es); LoadBanList(es); + LoadSpawnPoints(es); es.EstateManagers = LoadUUIDList(es.EstateID, "estate_managers"); es.EstateAccess = LoadUUIDList(es.EstateID, "estate_users"); @@ -210,7 +211,7 @@ namespace OpenSim.Data.MySQL } LoadBanList(es); - + LoadSpawnPoints(es); es.EstateManagers = LoadUUIDList(es.EstateID, "estate_managers"); es.EstateAccess = LoadUUIDList(es.EstateID, "estate_users"); es.EstateGroups = LoadUUIDList(es.EstateID, "estate_groups"); @@ -297,11 +298,74 @@ namespace OpenSim.Data.MySQL } SaveBanList(es); + SaveSpawnPoints(es); SaveUUIDList(es.EstateID, "estate_managers", es.EstateManagers); SaveUUIDList(es.EstateID, "estate_users", es.EstateAccess); SaveUUIDList(es.EstateID, "estate_groups", es.EstateGroups); } + private void LoadSpawnPoints(EstateSettings es) + { + es.ClearSpawnPoints(); + + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); + + using (MySqlCommand cmd = dbcon.CreateCommand()) + { + uint EstateID = es.EstateID; + cmd.CommandText = "select PointX, PointY, PointZ from spawn_points where EstateID = ?EstateID"; + cmd.Parameters.AddWithValue("?EstateID", es.EstateID); + + using (IDataReader r = cmd.ExecuteReader()) + { + while (r.Read()) + { + Vector3 point = new Vector3(); + + point.X = (float)r["PointX"]; + point.Y = (float)r["PointY"]; + point.Z = (float)r["PointZ"]; + + es.AddSpawnPoint(point); + } + } + } + } + } + + private void SaveSpawnPoints(EstateSettings es) + { + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); + + using (MySqlCommand cmd = dbcon.CreateCommand()) + { + cmd.CommandText = "delete from spawn_points where EstateID = ?EstateID"; + cmd.Parameters.AddWithValue("?EstateID", es.EstateID.ToString()); + + cmd.ExecuteNonQuery(); + + cmd.Parameters.Clear(); + + cmd.CommandText = "insert into spawn_points (EstateID, PointX, PointY, PointZ) values ( ?EstateID, ?PointX, ?PointY,?PointZ)"; + + foreach (Vector3 p in es.SpawnPoints()) + { + cmd.Parameters.AddWithValue("?EstateID", es.EstateID.ToString()); + cmd.Parameters.AddWithValue("?PointX", p.X); + cmd.Parameters.AddWithValue("?PointY", p.Y); + cmd.Parameters.AddWithValue("?PointZ", p.Z); + + cmd.ExecuteNonQuery(); + cmd.Parameters.Clear(); + } + } + } + } + private void LoadBanList(EstateSettings es) { es.ClearBans(); diff --git a/OpenSim/Data/MySQL/Resources/EstateStore.migrations b/OpenSim/Data/MySQL/Resources/EstateStore.migrations index df82a2e..591295b 100644 --- a/OpenSim/Data/MySQL/Resources/EstateStore.migrations +++ b/OpenSim/Data/MySQL/Resources/EstateStore.migrations @@ -78,4 +78,25 @@ ALTER TABLE estate_settings AUTO_INCREMENT = 100; COMMIT; +:VERSION 33 #--------------------- ( Supporting Telehubs +BEGIN; +CREATE TABLE IF NOT EXISTS `spawn_points` ( + `EstateID` varchar(36) COLLATE utf8_unicode_ci NOT NULL, + `PointX` float NOT NULL, + `PointY` float NOT NULL, + `PointZ` float NOT NULL, + KEY `EstateID` (`EstateID`) +) ENGINE=Innodb; + +ALTER TABLE `estate_settings` ADD COLUMN `TelehubObject` varchar(36) NOT NULL; +ALTER TABLE `estate_settings` ADD COLUMN `TelehubName` varchar(255) NOT NULL; +ALTER TABLE `estate_settings` ADD COLUMN `TelehubEnabled` tinyint(4) NOT NULL; +ALTER TABLE `estate_settings` ADD COLUMN `TelehubPosX` float NOT NULL; +ALTER TABLE `estate_settings` ADD COLUMN `TelehubPosY` float NOT NULL; +ALTER TABLE `estate_settings` ADD COLUMN `TelehubPosZ` float NOT NULL; +ALTER TABLE `estate_settings` ADD COLUMN `TelehubRotX` float NOT NULL; +ALTER TABLE `estate_settings` ADD COLUMN `TelehubRotY` float NOT NULL; +ALTER TABLE `estate_settings` ADD COLUMN `TelehubRotZ` float NOT NULL; +ALTER TABLE `estate_settings` ADD COLUMN `TelehubRotW` float NOT NULL; +COMMIT; \ No newline at end of file diff --git a/OpenSim/Framework/EstateSettings.cs b/OpenSim/Framework/EstateSettings.cs index 2a495b0..9bdeab8 100644 --- a/OpenSim/Framework/EstateSettings.cs +++ b/OpenSim/Framework/EstateSettings.cs @@ -373,5 +373,155 @@ namespace OpenSim.Framework return l_EstateAccess.Contains(user); } + + // Telehub support + private bool m_TelehubEnabled = false; + public bool HasTelehub + { + get { return m_TelehubEnabled; } + set { m_TelehubEnabled = value; } + } + + // Connected Telehub object + private UUID m_TelehubObject; + public UUID TelehubObject + { + get + { + if (HasTelehub) + { + return m_TelehubObject; + } + else + { + return UUID.Zero; + } + } + set + { + m_TelehubObject = value; + } + } + + // Connected Telehub name + private string m_TelehubName; + public string TelehubName + { + get + { + if (HasTelehub) + { + return m_TelehubName; + } + else + { + return String.Empty; + } + } + set + { + m_TelehubName = value; + } + } + + // Connected Telehub position + private float m_TelehubPosX; + private float m_TelehubPosY; + private float m_TelehubPosZ; + public Vector3 TelehubPos + { + get + { + if (HasTelehub) + { + Vector3 Pos = new Vector3(m_TelehubPosX, m_TelehubPosY, m_TelehubPosZ); + return Pos; + } + else + { + return Vector3.Zero; + } + } + set + { + + m_TelehubPosX = value.X; + m_TelehubPosY = value.Y; + m_TelehubPosZ = value.Z; + } + } + + // Connected Telehub rotation + private float m_TelehubRotX; + private float m_TelehubRotY; + private float m_TelehubRotZ; + private float m_TelehubRotW; + public Quaternion TelehubRot + { + get + { + if (HasTelehub) + { + Quaternion quat = new Quaternion(); + + quat.X = m_TelehubRotX; + quat.Y = m_TelehubRotY; + quat.Z = m_TelehubRotZ; + quat.W = m_TelehubRotW; + + return quat; + } + else + { + // What else to do?? + Quaternion quat = new Quaternion(); + + quat.X = m_TelehubRotX; + quat.X = m_TelehubRotY; + quat.X = m_TelehubRotZ; + quat.X = m_TelehubRotW; + + return quat; + } + } + set + { + m_TelehubRotX = value.X; + m_TelehubRotY = value.Y; + m_TelehubRotZ = value.Z; + m_TelehubRotW = value.W; + } + } + + // Our Connected Telehub's SpawnPoints + public List l_SpawnPoints = new List(); + + // Add a SpawnPoint + // ** These are not region coordinates ** + // They are relative to the Telehub coordinates + // + public void AddSpawnPoint(Vector3 point) + { + l_SpawnPoints.Add(point); + } + + // Remove a SpawnPoint + public void RemoveSpawnPoint(int point_index) + { + l_SpawnPoints.RemoveAt(point_index); + } + + // Return the List of SpawnPoints + public List SpawnPoints() + { + return l_SpawnPoints; + + } + + // Clear the SpawnPoints List of all entries + public void ClearSpawnPoints() + { + l_SpawnPoints.Clear(); + } } } diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index a94fb20..29ad966 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -9242,10 +9242,22 @@ namespace OpenSim.Region.ClientStack.LindenUDP { UUID invoice = messagePacket.MethodData.Invoice; UUID SenderID = messagePacket.AgentData.AgentID; - UInt32 param1 = Convert.ToUInt32(Utils.BytesToString(messagePacket.ParamList[1].Parameter)); + UInt32 param1 = 0u; string command = (string)Utils.BytesToString(messagePacket.ParamList[0].Parameter); + if (command != "info ui") + { + try + { + param1 = Convert.ToUInt32(Utils.BytesToString(messagePacket.ParamList[1].Parameter)); + } + catch (Exception ex) + { + + } + } + EstateManageTelehub handlerEstateManageTelehub = OnEstateManageTelehub; if (handlerEstateManageTelehub != null) { diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs index 0d4df6c..6a02ffe 100644 --- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs @@ -53,7 +53,7 @@ namespace OpenSim.Region.CoreModules.World.Estate protected EstateManagementCommands m_commands; private EstateTerrainXferHandler TerrainUploader; - private TelehubManager m_Telehub; + public TelehubManager m_Telehub; public event ChangeDelegate OnRegionInfoChange; public event ChangeDelegate OnEstateInfoChange; @@ -600,22 +600,20 @@ namespace OpenSim.Region.CoreModules.World.Estate } } - private void handleOnEstateManageTelehub (IClientAPI client, UUID invoice, UUID senderID, string cmd, uint param1) + public void handleOnEstateManageTelehub (IClientAPI client, UUID invoice, UUID senderID, string cmd, uint param1) { uint ObjectLocalID; SceneObjectPart part; - // UUID EstateID = Scene.RegionInfo.EstateSettings.EstateID; - TelehubManager.Telehub telehub; switch (cmd) { case "info ui": // Send info: - if (m_Telehub.HasTelehub) + if (Scene.RegionInfo.EstateSettings.HasTelehub) { - telehub = m_Telehub.TelehubVals(); - client.SendTelehubInfo(telehub.ObjectID, telehub.ObjectName, telehub.ObjectPosition, - telehub.ObjectRotation, telehub.SpawnPoint); + EstateSettings settings = this.Scene.RegionInfo.EstateSettings; + client.SendTelehubInfo(settings.TelehubObject, settings.TelehubName, settings.TelehubPos, + settings.TelehubRot, settings.SpawnPoints()); } else { @@ -626,32 +624,44 @@ namespace OpenSim.Region.CoreModules.World.Estate case "connect": // Add the Telehub part = Scene.GetSceneObjectPart((uint)param1); - telehub = m_Telehub.Connect(part); - client.SendTelehubInfo(telehub.ObjectID, telehub.ObjectName, telehub.ObjectPosition, - telehub.ObjectRotation, telehub.SpawnPoint); + if (m_Telehub.Connect(part)) + { + EstateSettings settings = this.Scene.RegionInfo.EstateSettings; + client.SendTelehubInfo(settings.TelehubObject, settings.TelehubName, settings.TelehubPos, + settings.TelehubRot, settings.SpawnPoints()); + } break; case "delete": // Disconnect Telehub part = Scene.GetSceneObjectPart((uint)param1); - telehub = m_Telehub.DisConnect(part); - client.SendTelehubInfo(telehub.ObjectID, telehub.ObjectName, telehub.ObjectPosition, - telehub.ObjectRotation, telehub.SpawnPoint); + if (m_Telehub.DisConnect(part)) + { + EstateSettings settings = this.Scene.RegionInfo.EstateSettings; + client.SendTelehubInfo(settings.TelehubObject, settings.TelehubName, settings.TelehubPos, + settings.TelehubRot, settings.SpawnPoints()); + } break; case "spawnpoint add": // Add SpawnPoint to the Telehub part = Scene.GetSceneObjectPart((uint)param1); - telehub = m_Telehub.AddSpawnPoint(part.AbsolutePosition); - client.SendTelehubInfo(telehub.ObjectID, telehub.ObjectName, telehub.ObjectPosition, - telehub.ObjectRotation, telehub.SpawnPoint); + if( m_Telehub.AddSpawnPoint(part.AbsolutePosition)) + { + EstateSettings settings = this.Scene.RegionInfo.EstateSettings; + client.SendTelehubInfo(settings.TelehubObject, settings.TelehubName, settings.TelehubPos, + settings.TelehubRot, settings.SpawnPoints()); + } break; case "spawnpoint remove": // Remove SpawnPoint from Telehub - telehub = m_Telehub.RemoveSpawnPoint((int)param1); - client.SendTelehubInfo(telehub.ObjectID, telehub.ObjectName, telehub.ObjectPosition, - telehub.ObjectRotation, telehub.SpawnPoint); + if (m_Telehub.RemoveSpawnPoint((int)param1)) + { + EstateSettings settings = this.Scene.RegionInfo.EstateSettings; + client.SendTelehubInfo(settings.TelehubObject, settings.TelehubName, settings.TelehubPos, + settings.TelehubRot, settings.SpawnPoints()); + } break; default: diff --git a/OpenSim/Region/CoreModules/World/Estate/TelehubManager.cs b/OpenSim/Region/CoreModules/World/Estate/TelehubManager.cs index c99c9ba..309ef13 100644 --- a/OpenSim/Region/CoreModules/World/Estate/TelehubManager.cs +++ b/OpenSim/Region/CoreModules/World/Estate/TelehubManager.cs @@ -35,14 +35,6 @@ namespace OpenSim.Region.CoreModules.World.Estate { public class TelehubManager { - public struct Telehub - { - public UUID ObjectID; - public string ObjectName; - public Vector3 ObjectPosition; - public Quaternion ObjectRotation; - public List SpawnPoint; - }; private UUID ObjectID; private string ObjectName; @@ -52,8 +44,9 @@ namespace OpenSim.Region.CoreModules.World.Estate UUID EstateID; bool m_HasTelehub = false; Scene m_Scene; + EstateSettings m_EstateSettings; // This will get an option... - Vector3 InitialSpawnPoint = new Vector3(0.0f,0.0f,-3.0f); + Vector3 InitialSpawnPoint = new Vector3(0.0f,0.0f,0.0f); public bool HasTelehub { @@ -63,68 +56,88 @@ namespace OpenSim.Region.CoreModules.World.Estate public TelehubManager(Scene scene) { m_Scene = scene; + m_EstateSettings = m_Scene.RegionInfo.EstateSettings; } // Fill our Telehub struct with values - public Telehub TelehubVals() - { - Telehub telehub = new Telehub(); - - telehub.ObjectID = ObjectID; - telehub.ObjectName = ObjectName; - telehub.ObjectPosition = ObjectPosition; - telehub.ObjectRotation = ObjectRotation; - telehub.SpawnPoint = SpawnPoint; - return telehub; - } +// public Telehub TelehubVals() +// { +// // Telehub telehub = new Telehub(); +// EstateSettings telehub = m_EstateSettings; +// +// telehub.TelehubObject = ObjectID; +// telehub.TelehubName = ObjectName; +// telehub.TelehubPos = ObjectPosition; +// telehub.TelehubRot = ObjectRotation; +// telehub. = SpawnPoint; +// return telehub; +// } // Connect the Telehub - public Telehub Connect(SceneObjectPart part) + public bool Connect(SceneObjectPart part) { - ObjectID = part.UUID; - ObjectName = part.Name; - ObjectPosition = part.AbsolutePosition; - ObjectRotation = part.GetWorldRotation(); - // Clear this for now - SpawnPoint.Clear(); - SpawnPoint.Add(InitialSpawnPoint); - m_HasTelehub = true; + m_EstateSettings.ClearSpawnPoints(); - return TelehubVals(); + m_EstateSettings.TelehubObject = part.UUID; + m_EstateSettings.TelehubName = part.Name; + m_EstateSettings.TelehubPos = part.AbsolutePosition; + m_EstateSettings.TelehubRot = part.GetWorldRotation(); + + // Clear this for now + m_EstateSettings.AddSpawnPoint(InitialSpawnPoint); + m_EstateSettings.HasTelehub = true; + m_EstateSettings.Save(); + return true; } - // Disconnect the Telehub - public Telehub DisConnect(SceneObjectPart part) + // Disconnect the Telehub: Clear it out for now, look at just disableing + public bool DisConnect(SceneObjectPart part) { - ObjectID = UUID.Zero; - ObjectName = String.Empty; - ObjectPosition = Vector3.Zero; - ObjectRotation = Quaternion.Identity; - SpawnPoint.Clear(); - m_HasTelehub = false; - - return TelehubVals(); + bool result = false; + + try{ + m_EstateSettings.TelehubObject = UUID.Zero; + m_EstateSettings.TelehubName = String.Empty; + m_EstateSettings.TelehubPos = Vector3.Zero; + // This is probably wrong! But, HasTelehub will block access + m_EstateSettings.TelehubRot = Quaternion.Identity; + m_EstateSettings.ClearSpawnPoints(); + m_EstateSettings.HasTelehub = false; + m_EstateSettings.Save(); + result = true; + } + catch (Exception ex) + { + result = false; + } + finally + { + + } + + return result; } // Add a SpawnPoint to the Telehub - public Telehub AddSpawnPoint(Vector3 point) + public bool AddSpawnPoint(Vector3 point) { - float dist = (float) Util.GetDistanceTo(ObjectPosition, point); - - Vector3 nvec = Util.GetNormalizedVector(point - ObjectPosition); + float dist = (float) Util.GetDistanceTo(m_EstateSettings.TelehubPos, point); + Vector3 nvec = Util.GetNormalizedVector(point - m_EstateSettings.TelehubPos); Vector3 spoint = nvec * dist; - SpawnPoint.Add(spoint); - return TelehubVals(); + m_EstateSettings.AddSpawnPoint(spoint); + m_EstateSettings.Save(); + return true; } // Remove a SpawnPoint from the Telehub - public Telehub RemoveSpawnPoint(int spawnpoint) + public bool RemoveSpawnPoint(int spawnpoint) { - SpawnPoint.RemoveAt(spawnpoint); + m_EstateSettings.RemoveSpawnPoint(spawnpoint); + m_EstateSettings.Save(); - return TelehubVals(); + return true; } } } \ No newline at end of file -- cgit v1.1 From 68365c20c0b3a3164881398f3bc3710f7960c52d Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 22 Jan 2012 11:36:04 +0000 Subject: Move Telehub tables and data from EstateSettings to RegionSettings. This is damage control es EstateSettings is not the place this can be put. EstateSettings is nt unique to a region and therefore would introduce a hard limit of one telehub per estate, completely shutting off the option of having SL style telehubs, e.g. one per region. Whole estate teleport routing can still be implemented id desiresd, this way all options are open while the other way most options get closed off. --- OpenSim/Data/MySQL/MySQLEstateData.cs | 65 --------- OpenSim/Data/MySQL/MySQLSimulationData.cs | 70 ++++++++++ .../Data/MySQL/Resources/EstateStore.migrations | 21 --- .../Data/MySQL/Resources/RegionStore.migrations | 26 +++- OpenSim/Framework/EstateSettings.cs | 150 --------------------- OpenSim/Framework/RegionSettings.cs | 150 +++++++++++++++++++++ .../World/Estate/EstateManagementModule.cs | 12 +- .../CoreModules/World/Estate/TelehubManager.cs | 46 +++---- 8 files changed, 273 insertions(+), 267 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Data/MySQL/MySQLEstateData.cs b/OpenSim/Data/MySQL/MySQLEstateData.cs index a357268..3dd46cb 100644 --- a/OpenSim/Data/MySQL/MySQLEstateData.cs +++ b/OpenSim/Data/MySQL/MySQLEstateData.cs @@ -157,7 +157,6 @@ namespace OpenSim.Data.MySQL DoCreate(es); LoadBanList(es); - LoadSpawnPoints(es); es.EstateManagers = LoadUUIDList(es.EstateID, "estate_managers"); es.EstateAccess = LoadUUIDList(es.EstateID, "estate_users"); @@ -211,7 +210,6 @@ namespace OpenSim.Data.MySQL } LoadBanList(es); - LoadSpawnPoints(es); es.EstateManagers = LoadUUIDList(es.EstateID, "estate_managers"); es.EstateAccess = LoadUUIDList(es.EstateID, "estate_users"); es.EstateGroups = LoadUUIDList(es.EstateID, "estate_groups"); @@ -298,74 +296,11 @@ namespace OpenSim.Data.MySQL } SaveBanList(es); - SaveSpawnPoints(es); SaveUUIDList(es.EstateID, "estate_managers", es.EstateManagers); SaveUUIDList(es.EstateID, "estate_users", es.EstateAccess); SaveUUIDList(es.EstateID, "estate_groups", es.EstateGroups); } - private void LoadSpawnPoints(EstateSettings es) - { - es.ClearSpawnPoints(); - - using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) - { - dbcon.Open(); - - using (MySqlCommand cmd = dbcon.CreateCommand()) - { - uint EstateID = es.EstateID; - cmd.CommandText = "select PointX, PointY, PointZ from spawn_points where EstateID = ?EstateID"; - cmd.Parameters.AddWithValue("?EstateID", es.EstateID); - - using (IDataReader r = cmd.ExecuteReader()) - { - while (r.Read()) - { - Vector3 point = new Vector3(); - - point.X = (float)r["PointX"]; - point.Y = (float)r["PointY"]; - point.Z = (float)r["PointZ"]; - - es.AddSpawnPoint(point); - } - } - } - } - } - - private void SaveSpawnPoints(EstateSettings es) - { - using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) - { - dbcon.Open(); - - using (MySqlCommand cmd = dbcon.CreateCommand()) - { - cmd.CommandText = "delete from spawn_points where EstateID = ?EstateID"; - cmd.Parameters.AddWithValue("?EstateID", es.EstateID.ToString()); - - cmd.ExecuteNonQuery(); - - cmd.Parameters.Clear(); - - cmd.CommandText = "insert into spawn_points (EstateID, PointX, PointY, PointZ) values ( ?EstateID, ?PointX, ?PointY,?PointZ)"; - - foreach (Vector3 p in es.SpawnPoints()) - { - cmd.Parameters.AddWithValue("?EstateID", es.EstateID.ToString()); - cmd.Parameters.AddWithValue("?PointX", p.X); - cmd.Parameters.AddWithValue("?PointY", p.Y); - cmd.Parameters.AddWithValue("?PointZ", p.Z); - - cmd.ExecuteNonQuery(); - cmd.Parameters.Clear(); - } - } - } - } - private void LoadBanList(EstateSettings es) { es.ClearBans(); diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index 6d14b82..3883e24 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs @@ -846,6 +846,8 @@ namespace OpenSim.Data.MySQL } } + LoadSpawnPoints(rs); + return rs; } @@ -1017,6 +1019,7 @@ namespace OpenSim.Data.MySQL } } } + SaveSpawnPoints(rs); } public List LoadLandObjects(UUID regionUUID) @@ -1828,5 +1831,72 @@ namespace OpenSim.Data.MySQL } } } + + private void LoadSpawnPoints(RegionSettings rs) + { + rs.ClearSpawnPoints(); + + lock (m_dbLock) + { + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); + + using (MySqlCommand cmd = dbcon.CreateCommand()) + { + cmd.CommandText = "select PointX, PointY, PointZ from spawn_points where RegionID = ?RegionID"; + cmd.Parameters.AddWithValue("?RegionID", rs.RegionUUID.ToString()); + + using (IDataReader r = cmd.ExecuteReader()) + { + while (r.Read()) + { + Vector3 point = new Vector3(); + + point.X = (float)r["PointX"]; + point.Y = (float)r["PointY"]; + point.Z = (float)r["PointZ"]; + + rs.AddSpawnPoint(point); + } + } + } + } + } + } + + private void SaveSpawnPoints(RegionSettings rs) + { + lock (m_dbLock) + { + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); + + using (MySqlCommand cmd = dbcon.CreateCommand()) + { + cmd.CommandText = "delete from spawn_points where RegionID = ?RegionID"; + cmd.Parameters.AddWithValue("?RegionID", rs.RegionUUID.ToString()); + + cmd.ExecuteNonQuery(); + + cmd.Parameters.Clear(); + + cmd.CommandText = "insert into spawn_points (RegionID, PointX, PointY, PointZ) values ( ?EstateID, ?PointX, ?PointY,?PointZ)"; + + foreach (Vector3 p in rs.SpawnPoints()) + { + cmd.Parameters.AddWithValue("?EstateID", rs.RegionUUID.ToString()); + cmd.Parameters.AddWithValue("?PointX", p.X); + cmd.Parameters.AddWithValue("?PointY", p.Y); + cmd.Parameters.AddWithValue("?PointZ", p.Z); + + cmd.ExecuteNonQuery(); + cmd.Parameters.Clear(); + } + } + } + } + } } } diff --git a/OpenSim/Data/MySQL/Resources/EstateStore.migrations b/OpenSim/Data/MySQL/Resources/EstateStore.migrations index 591295b..df82a2e 100644 --- a/OpenSim/Data/MySQL/Resources/EstateStore.migrations +++ b/OpenSim/Data/MySQL/Resources/EstateStore.migrations @@ -78,25 +78,4 @@ ALTER TABLE estate_settings AUTO_INCREMENT = 100; COMMIT; -:VERSION 33 #--------------------- ( Supporting Telehubs -BEGIN; -CREATE TABLE IF NOT EXISTS `spawn_points` ( - `EstateID` varchar(36) COLLATE utf8_unicode_ci NOT NULL, - `PointX` float NOT NULL, - `PointY` float NOT NULL, - `PointZ` float NOT NULL, - KEY `EstateID` (`EstateID`) -) ENGINE=Innodb; - -ALTER TABLE `estate_settings` ADD COLUMN `TelehubObject` varchar(36) NOT NULL; -ALTER TABLE `estate_settings` ADD COLUMN `TelehubName` varchar(255) NOT NULL; -ALTER TABLE `estate_settings` ADD COLUMN `TelehubEnabled` tinyint(4) NOT NULL; -ALTER TABLE `estate_settings` ADD COLUMN `TelehubPosX` float NOT NULL; -ALTER TABLE `estate_settings` ADD COLUMN `TelehubPosY` float NOT NULL; -ALTER TABLE `estate_settings` ADD COLUMN `TelehubPosZ` float NOT NULL; -ALTER TABLE `estate_settings` ADD COLUMN `TelehubRotX` float NOT NULL; -ALTER TABLE `estate_settings` ADD COLUMN `TelehubRotY` float NOT NULL; -ALTER TABLE `estate_settings` ADD COLUMN `TelehubRotZ` float NOT NULL; -ALTER TABLE `estate_settings` ADD COLUMN `TelehubRotW` float NOT NULL; -COMMIT; \ No newline at end of file diff --git a/OpenSim/Data/MySQL/Resources/RegionStore.migrations b/OpenSim/Data/MySQL/Resources/RegionStore.migrations index 987625b..ce66cfb 100644 --- a/OpenSim/Data/MySQL/Resources/RegionStore.migrations +++ b/OpenSim/Data/MySQL/Resources/RegionStore.migrations @@ -841,4 +841,28 @@ alter table regionban ENGINE = MyISAM; alter table regionsettings ENGINE = MyISAM; alter table terrain ENGINE = MyISAM; -COMMIT; \ No newline at end of file +COMMIT; + +:VERSION 39 #--------------- Telehub support + +BEGIN; +CREATE TABLE IF NOT EXISTS `spawn_points` ( + `RegionID` varchar(36) COLLATE utf8_unicode_ci NOT NULL, + `PointX` float NOT NULL, + `PointY` float NOT NULL, + `PointZ` float NOT NULL, + KEY `EstateID` (`EstateID`) +) ENGINE=Innodb; + +ALTER TABLE `regionsettings` ADD COLUMN `TelehubObject` varchar(36) NOT NULL; +ALTER TABLE `regionsettings` ADD COLUMN `TelehubName` varchar(255) NOT NULL; +ALTER TABLE `regionsettings` ADD COLUMN `TelehubEnabled` tinyint(4) NOT NULL; +ALTER TABLE `regionsettings` ADD COLUMN `TelehubPosX` float NOT NULL; +ALTER TABLE `regionsettings` ADD COLUMN `TelehubPosY` float NOT NULL; +ALTER TABLE `regionsettings` ADD COLUMN `TelehubPosZ` float NOT NULL; +ALTER TABLE `regionsettings` ADD COLUMN `TelehubRotX` float NOT NULL; +ALTER TABLE `regionsettings` ADD COLUMN `TelehubRotY` float NOT NULL; +ALTER TABLE `regionsettings` ADD COLUMN `TelehubRotZ` float NOT NULL; +ALTER TABLE `regionsettings` ADD COLUMN `TelehubRotW` float NOT NULL; +COMMIT; + diff --git a/OpenSim/Framework/EstateSettings.cs b/OpenSim/Framework/EstateSettings.cs index 9bdeab8..2a495b0 100644 --- a/OpenSim/Framework/EstateSettings.cs +++ b/OpenSim/Framework/EstateSettings.cs @@ -373,155 +373,5 @@ namespace OpenSim.Framework return l_EstateAccess.Contains(user); } - - // Telehub support - private bool m_TelehubEnabled = false; - public bool HasTelehub - { - get { return m_TelehubEnabled; } - set { m_TelehubEnabled = value; } - } - - // Connected Telehub object - private UUID m_TelehubObject; - public UUID TelehubObject - { - get - { - if (HasTelehub) - { - return m_TelehubObject; - } - else - { - return UUID.Zero; - } - } - set - { - m_TelehubObject = value; - } - } - - // Connected Telehub name - private string m_TelehubName; - public string TelehubName - { - get - { - if (HasTelehub) - { - return m_TelehubName; - } - else - { - return String.Empty; - } - } - set - { - m_TelehubName = value; - } - } - - // Connected Telehub position - private float m_TelehubPosX; - private float m_TelehubPosY; - private float m_TelehubPosZ; - public Vector3 TelehubPos - { - get - { - if (HasTelehub) - { - Vector3 Pos = new Vector3(m_TelehubPosX, m_TelehubPosY, m_TelehubPosZ); - return Pos; - } - else - { - return Vector3.Zero; - } - } - set - { - - m_TelehubPosX = value.X; - m_TelehubPosY = value.Y; - m_TelehubPosZ = value.Z; - } - } - - // Connected Telehub rotation - private float m_TelehubRotX; - private float m_TelehubRotY; - private float m_TelehubRotZ; - private float m_TelehubRotW; - public Quaternion TelehubRot - { - get - { - if (HasTelehub) - { - Quaternion quat = new Quaternion(); - - quat.X = m_TelehubRotX; - quat.Y = m_TelehubRotY; - quat.Z = m_TelehubRotZ; - quat.W = m_TelehubRotW; - - return quat; - } - else - { - // What else to do?? - Quaternion quat = new Quaternion(); - - quat.X = m_TelehubRotX; - quat.X = m_TelehubRotY; - quat.X = m_TelehubRotZ; - quat.X = m_TelehubRotW; - - return quat; - } - } - set - { - m_TelehubRotX = value.X; - m_TelehubRotY = value.Y; - m_TelehubRotZ = value.Z; - m_TelehubRotW = value.W; - } - } - - // Our Connected Telehub's SpawnPoints - public List l_SpawnPoints = new List(); - - // Add a SpawnPoint - // ** These are not region coordinates ** - // They are relative to the Telehub coordinates - // - public void AddSpawnPoint(Vector3 point) - { - l_SpawnPoints.Add(point); - } - - // Remove a SpawnPoint - public void RemoveSpawnPoint(int point_index) - { - l_SpawnPoints.RemoveAt(point_index); - } - - // Return the List of SpawnPoints - public List SpawnPoints() - { - return l_SpawnPoints; - - } - - // Clear the SpawnPoints List of all entries - public void ClearSpawnPoints() - { - l_SpawnPoints.Clear(); - } } } diff --git a/OpenSim/Framework/RegionSettings.cs b/OpenSim/Framework/RegionSettings.cs index 673cf20..a2dd64f 100644 --- a/OpenSim/Framework/RegionSettings.cs +++ b/OpenSim/Framework/RegionSettings.cs @@ -26,6 +26,7 @@ */ using System; +using System.Collections.Generic; using System.IO; using OpenMetaverse; @@ -397,5 +398,154 @@ namespace OpenSim.Framework set { m_LoadedCreationID = value; } } + // Telehub support + private bool m_TelehubEnabled = false; + public bool HasTelehub + { + get { return m_TelehubEnabled; } + set { m_TelehubEnabled = value; } + } + + // Connected Telehub object + private UUID m_TelehubObject; + public UUID TelehubObject + { + get + { + if (HasTelehub) + { + return m_TelehubObject; + } + else + { + return UUID.Zero; + } + } + set + { + m_TelehubObject = value; + } + } + + // Connected Telehub name + private string m_TelehubName; + public string TelehubName + { + get + { + if (HasTelehub) + { + return m_TelehubName; + } + else + { + return String.Empty; + } + } + set + { + m_TelehubName = value; + } + } + + // Connected Telehub position + private float m_TelehubPosX; + private float m_TelehubPosY; + private float m_TelehubPosZ; + public Vector3 TelehubPos + { + get + { + if (HasTelehub) + { + Vector3 Pos = new Vector3(m_TelehubPosX, m_TelehubPosY, m_TelehubPosZ); + return Pos; + } + else + { + return Vector3.Zero; + } + } + set + { + + m_TelehubPosX = value.X; + m_TelehubPosY = value.Y; + m_TelehubPosZ = value.Z; + } + } + + // Connected Telehub rotation + private float m_TelehubRotX; + private float m_TelehubRotY; + private float m_TelehubRotZ; + private float m_TelehubRotW; + public Quaternion TelehubRot + { + get + { + if (HasTelehub) + { + Quaternion quat = new Quaternion(); + + quat.X = m_TelehubRotX; + quat.Y = m_TelehubRotY; + quat.Z = m_TelehubRotZ; + quat.W = m_TelehubRotW; + + return quat; + } + else + { + // What else to do?? + Quaternion quat = new Quaternion(); + + quat.X = m_TelehubRotX; + quat.X = m_TelehubRotY; + quat.X = m_TelehubRotZ; + quat.X = m_TelehubRotW; + + return quat; + } + } + set + { + m_TelehubRotX = value.X; + m_TelehubRotY = value.Y; + m_TelehubRotZ = value.Z; + m_TelehubRotW = value.W; + } + } + + // Our Connected Telehub's SpawnPoints + public List l_SpawnPoints = new List(); + + // Add a SpawnPoint + // ** These are not region coordinates ** + // They are relative to the Telehub coordinates + // + public void AddSpawnPoint(Vector3 point) + { + l_SpawnPoints.Add(point); + } + + // Remove a SpawnPoint + public void RemoveSpawnPoint(int point_index) + { + l_SpawnPoints.RemoveAt(point_index); + } + + // Return the List of SpawnPoints + public List SpawnPoints() + { + return l_SpawnPoints; + + } + + // Clear the SpawnPoints List of all entries + public void ClearSpawnPoints() + { + l_SpawnPoints.Clear(); + } } } diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs index 6a02ffe..cdcea65 100644 --- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs @@ -609,9 +609,9 @@ namespace OpenSim.Region.CoreModules.World.Estate { case "info ui": // Send info: - if (Scene.RegionInfo.EstateSettings.HasTelehub) + if (Scene.RegionInfo.RegionSettings.HasTelehub) { - EstateSettings settings = this.Scene.RegionInfo.EstateSettings; + RegionSettings settings = this.Scene.RegionInfo.RegionSettings; client.SendTelehubInfo(settings.TelehubObject, settings.TelehubName, settings.TelehubPos, settings.TelehubRot, settings.SpawnPoints()); } @@ -626,7 +626,7 @@ namespace OpenSim.Region.CoreModules.World.Estate part = Scene.GetSceneObjectPart((uint)param1); if (m_Telehub.Connect(part)) { - EstateSettings settings = this.Scene.RegionInfo.EstateSettings; + RegionSettings settings = this.Scene.RegionInfo.RegionSettings; client.SendTelehubInfo(settings.TelehubObject, settings.TelehubName, settings.TelehubPos, settings.TelehubRot, settings.SpawnPoints()); } @@ -637,7 +637,7 @@ namespace OpenSim.Region.CoreModules.World.Estate part = Scene.GetSceneObjectPart((uint)param1); if (m_Telehub.DisConnect(part)) { - EstateSettings settings = this.Scene.RegionInfo.EstateSettings; + RegionSettings settings = this.Scene.RegionInfo.RegionSettings; client.SendTelehubInfo(settings.TelehubObject, settings.TelehubName, settings.TelehubPos, settings.TelehubRot, settings.SpawnPoints()); } @@ -648,7 +648,7 @@ namespace OpenSim.Region.CoreModules.World.Estate part = Scene.GetSceneObjectPart((uint)param1); if( m_Telehub.AddSpawnPoint(part.AbsolutePosition)) { - EstateSettings settings = this.Scene.RegionInfo.EstateSettings; + RegionSettings settings = this.Scene.RegionInfo.RegionSettings; client.SendTelehubInfo(settings.TelehubObject, settings.TelehubName, settings.TelehubPos, settings.TelehubRot, settings.SpawnPoints()); } @@ -658,7 +658,7 @@ namespace OpenSim.Region.CoreModules.World.Estate // Remove SpawnPoint from Telehub if (m_Telehub.RemoveSpawnPoint((int)param1)) { - EstateSettings settings = this.Scene.RegionInfo.EstateSettings; + RegionSettings settings = this.Scene.RegionInfo.RegionSettings; client.SendTelehubInfo(settings.TelehubObject, settings.TelehubName, settings.TelehubPos, settings.TelehubRot, settings.SpawnPoints()); } diff --git a/OpenSim/Region/CoreModules/World/Estate/TelehubManager.cs b/OpenSim/Region/CoreModules/World/Estate/TelehubManager.cs index 309ef13..ee77ae1 100644 --- a/OpenSim/Region/CoreModules/World/Estate/TelehubManager.cs +++ b/OpenSim/Region/CoreModules/World/Estate/TelehubManager.cs @@ -44,7 +44,6 @@ namespace OpenSim.Region.CoreModules.World.Estate UUID EstateID; bool m_HasTelehub = false; Scene m_Scene; - EstateSettings m_EstateSettings; // This will get an option... Vector3 InitialSpawnPoint = new Vector3(0.0f,0.0f,0.0f); @@ -56,7 +55,6 @@ namespace OpenSim.Region.CoreModules.World.Estate public TelehubManager(Scene scene) { m_Scene = scene; - m_EstateSettings = m_Scene.RegionInfo.EstateSettings; } // Fill our Telehub struct with values @@ -76,17 +74,17 @@ namespace OpenSim.Region.CoreModules.World.Estate // Connect the Telehub public bool Connect(SceneObjectPart part) { - m_EstateSettings.ClearSpawnPoints(); + m_Scene.RegionInfo.RegionSettings.ClearSpawnPoints(); - m_EstateSettings.TelehubObject = part.UUID; - m_EstateSettings.TelehubName = part.Name; - m_EstateSettings.TelehubPos = part.AbsolutePosition; - m_EstateSettings.TelehubRot = part.GetWorldRotation(); + m_Scene.RegionInfo.RegionSettings.TelehubObject = part.UUID; + m_Scene.RegionInfo.RegionSettings.TelehubName = part.Name; + m_Scene.RegionInfo.RegionSettings.TelehubPos = part.AbsolutePosition; + m_Scene.RegionInfo.RegionSettings.TelehubRot = part.GetWorldRotation(); // Clear this for now - m_EstateSettings.AddSpawnPoint(InitialSpawnPoint); - m_EstateSettings.HasTelehub = true; - m_EstateSettings.Save(); + m_Scene.RegionInfo.RegionSettings.AddSpawnPoint(InitialSpawnPoint); + m_Scene.RegionInfo.RegionSettings.HasTelehub = true; + m_Scene.RegionInfo.RegionSettings.Save(); return true; } @@ -96,14 +94,14 @@ namespace OpenSim.Region.CoreModules.World.Estate bool result = false; try{ - m_EstateSettings.TelehubObject = UUID.Zero; - m_EstateSettings.TelehubName = String.Empty; - m_EstateSettings.TelehubPos = Vector3.Zero; + m_Scene.RegionInfo.RegionSettings.TelehubObject = UUID.Zero; + m_Scene.RegionInfo.RegionSettings.TelehubName = String.Empty; + m_Scene.RegionInfo.RegionSettings.TelehubPos = Vector3.Zero; // This is probably wrong! But, HasTelehub will block access - m_EstateSettings.TelehubRot = Quaternion.Identity; - m_EstateSettings.ClearSpawnPoints(); - m_EstateSettings.HasTelehub = false; - m_EstateSettings.Save(); + m_Scene.RegionInfo.RegionSettings.TelehubRot = Quaternion.Identity; + m_Scene.RegionInfo.RegionSettings.ClearSpawnPoints(); + m_Scene.RegionInfo.RegionSettings.HasTelehub = false; + m_Scene.RegionInfo.RegionSettings.Save(); result = true; } catch (Exception ex) @@ -122,22 +120,22 @@ namespace OpenSim.Region.CoreModules.World.Estate public bool AddSpawnPoint(Vector3 point) { - float dist = (float) Util.GetDistanceTo(m_EstateSettings.TelehubPos, point); - Vector3 nvec = Util.GetNormalizedVector(point - m_EstateSettings.TelehubPos); + float dist = (float) Util.GetDistanceTo(m_Scene.RegionInfo.RegionSettings.TelehubPos, point); + Vector3 nvec = Util.GetNormalizedVector(point - m_Scene.RegionInfo.RegionSettings.TelehubPos); Vector3 spoint = nvec * dist; - m_EstateSettings.AddSpawnPoint(spoint); - m_EstateSettings.Save(); + m_Scene.RegionInfo.RegionSettings.AddSpawnPoint(spoint); + m_Scene.RegionInfo.RegionSettings.Save(); return true; } // Remove a SpawnPoint from the Telehub public bool RemoveSpawnPoint(int spawnpoint) { - m_EstateSettings.RemoveSpawnPoint(spawnpoint); - m_EstateSettings.Save(); + m_Scene.RegionInfo.RegionSettings.RemoveSpawnPoint(spawnpoint); + m_Scene.RegionInfo.RegionSettings.Save(); return true; } } -} \ No newline at end of file +} -- cgit v1.1 From 24b20f6e4b98b5d7049d2db77d8701529eab75ca Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 22 Jan 2012 15:35:14 +0000 Subject: Change the key name I missed in last commit --- OpenSim/Data/MySQL/Resources/RegionStore.migrations | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim') diff --git a/OpenSim/Data/MySQL/Resources/RegionStore.migrations b/OpenSim/Data/MySQL/Resources/RegionStore.migrations index ce66cfb..3132148 100644 --- a/OpenSim/Data/MySQL/Resources/RegionStore.migrations +++ b/OpenSim/Data/MySQL/Resources/RegionStore.migrations @@ -851,7 +851,7 @@ CREATE TABLE IF NOT EXISTS `spawn_points` ( `PointX` float NOT NULL, `PointY` float NOT NULL, `PointZ` float NOT NULL, - KEY `EstateID` (`EstateID`) + KEY `RegionID` (`RegionID`) ) ENGINE=Innodb; ALTER TABLE `regionsettings` ADD COLUMN `TelehubObject` varchar(36) NOT NULL; -- cgit v1.1 From 1cd26ba85ee50c3b1dea8e3519670866985548fd Mon Sep 17 00:00:00 2001 From: BlueWall Date: Sun, 22 Jan 2012 11:46:16 -0500 Subject: Hooking up new telehub data to the database --- OpenSim/Data/MySQL/MySQLSimulationData.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'OpenSim') diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index 3883e24..a2d5435 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs @@ -1299,6 +1299,20 @@ namespace OpenSim.Data.MySQL newSettings.LoadedCreationID = (String) row["loaded_creation_id"]; newSettings.TerrainImageID = DBGuid.FromDB(row["map_tile_ID"]); + newSettings.HasTelehub = Convert.ToBoolean(row["TelehubEnabled"]); + newSettings.TelehubObject = DBGuid.FromDB(row["TelehubObject"]); + newSettings.TelehubName = (string) row["TelehubName"]; + newSettings.TelehubPos = new Vector3 ( + Convert.ToSingle(row["TelehubPosX"]), + Convert.ToSingle(row["TelehubPosY"]), + Convert.ToSingle(row["TelehubPosZ"]) + ); + newSettings.TelehubRot = new Quaternion ( + Convert.ToSingle(row["TelehubRotX"]), + Convert.ToSingle(row["TelehubRotY"]), + Convert.ToSingle(row["TelehubRotZ"]), + Convert.ToSingle(row["TelehubRotW"]) + ); return newSettings; } -- cgit v1.1 From 74c1ed77a44c96aed5c0b2c0eb828e6383792bfc Mon Sep 17 00:00:00 2001 From: BlueWall Date: Sun, 22 Jan 2012 14:51:15 -0500 Subject: Finish connecting Telehub to database --- OpenSim/Data/MySQL/MySQLSimulationData.cs | 22 ++++++++++++-- OpenSim/Framework/RegionSettings.cs | 50 ++++--------------------------- 2 files changed, 25 insertions(+), 47 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index a2d5435..a48b91b 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs @@ -996,7 +996,11 @@ namespace OpenSim.Data.MySQL "use_estate_sun, fixed_sun, sun_position, " + "covenant, Sandbox, sunvectorx, sunvectory, " + "sunvectorz, loaded_creation_datetime, " + - "loaded_creation_id, map_tile_ID) values (?RegionUUID, ?BlockTerraform, " + + "loaded_creation_id, map_tile_ID, " + + "TelehubEnabled, TelehubObject, TelehubName, " + + "TelehubPosX, TelehubPosY, TelehubPosZ, " + + "TelehubRotX, TelehubRotY, TelehubRotZ, TelehubRotW) " + + "values (?RegionUUID, ?BlockTerraform, " + "?BlockFly, ?AllowDamage, ?RestrictPushing, " + "?AllowLandResell, ?AllowLandJoinDivide, " + "?BlockShowInSearch, ?AgentLimit, ?ObjectBonus, " + @@ -1011,7 +1015,10 @@ namespace OpenSim.Data.MySQL "?SunPosition, ?Covenant, ?Sandbox, " + "?SunVectorX, ?SunVectorY, ?SunVectorZ, " + "?LoadedCreationDateTime, ?LoadedCreationID, " + - "?TerrainImageID)"; + "?TerrainImageID, " + + "?TelehubEnabled, ?TelehubObject, ?TelehubName, " + + "?TelehubPosX, ?TelehubPosY, ?TelehubPosZ, " + + "?TelehubRotX, ?TelehubRotY, ?TelehubRotZ, ?TelehubRotW )"; FillRegionSettingsCommand(cmd, rs); @@ -1643,7 +1650,16 @@ namespace OpenSim.Data.MySQL cmd.Parameters.AddWithValue("LoadedCreationDateTime", settings.LoadedCreationDateTime); cmd.Parameters.AddWithValue("LoadedCreationID", settings.LoadedCreationID); cmd.Parameters.AddWithValue("TerrainImageID", settings.TerrainImageID); - + cmd.Parameters.AddWithValue("TelehubEnabled", settings.HasTelehub); + cmd.Parameters.AddWithValue("TelehubObject", settings.TelehubObject); + cmd.Parameters.AddWithValue("TelehubName", settings.TelehubName); + cmd.Parameters.AddWithValue("TelehubPosX", settings.TelehubPos.X); + cmd.Parameters.AddWithValue("TelehubPosY", settings.TelehubPos.Y); + cmd.Parameters.AddWithValue("TelehubPosZ", settings.TelehubPos.Z); + cmd.Parameters.AddWithValue("TelehubRotX", settings.TelehubRot.X); + cmd.Parameters.AddWithValue("TelehubRotY", settings.TelehubRot.Y); + cmd.Parameters.AddWithValue("TelehubRotZ", settings.TelehubRot.Z); + cmd.Parameters.AddWithValue("TelehubRotW", settings.TelehubRot.W); } /// diff --git a/OpenSim/Framework/RegionSettings.cs b/OpenSim/Framework/RegionSettings.cs index a2dd64f..9b5bbf2 100644 --- a/OpenSim/Framework/RegionSettings.cs +++ b/OpenSim/Framework/RegionSettings.cs @@ -449,17 +449,14 @@ namespace OpenSim.Framework } // Connected Telehub position - private float m_TelehubPosX; - private float m_TelehubPosY; - private float m_TelehubPosZ; + private Vector3 m_TelehubPos; public Vector3 TelehubPos { get { if (HasTelehub) { - Vector3 Pos = new Vector3(m_TelehubPosX, m_TelehubPosY, m_TelehubPosZ); - return Pos; + return m_TelehubPos; } else { @@ -468,53 +465,18 @@ namespace OpenSim.Framework } set { - - m_TelehubPosX = value.X; - m_TelehubPosY = value.Y; - m_TelehubPosZ = value.Z; + m_TelehubPos = value; } } // Connected Telehub rotation - private float m_TelehubRotX; - private float m_TelehubRotY; - private float m_TelehubRotZ; - private float m_TelehubRotW; + private Quaternion m_TelehubRot; public Quaternion TelehubRot { get - { - if (HasTelehub) - { - Quaternion quat = new Quaternion(); - - quat.X = m_TelehubRotX; - quat.Y = m_TelehubRotY; - quat.Z = m_TelehubRotZ; - quat.W = m_TelehubRotW; - - return quat; - } - else - { - // What else to do?? - Quaternion quat = new Quaternion(); - - quat.X = m_TelehubRotX; - quat.X = m_TelehubRotY; - quat.X = m_TelehubRotZ; - quat.X = m_TelehubRotW; - - return quat; - } - } + { return m_TelehubRot; } set - { - m_TelehubRotX = value.X; - m_TelehubRotY = value.Y; - m_TelehubRotZ = value.Z; - m_TelehubRotW = value.W; - } + { m_TelehubRot = value; } } // Our Connected Telehub's SpawnPoints -- cgit v1.1 From 7c404375c7eeecc09228d49cca4d0fe162712a8c Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 22 Jan 2012 23:20:10 +0000 Subject: Fix up some parameter naming --- OpenSim/Data/MySQL/MySQLSimulationData.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index a48b91b..b94f6ac 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs @@ -1912,11 +1912,11 @@ namespace OpenSim.Data.MySQL cmd.Parameters.Clear(); - cmd.CommandText = "insert into spawn_points (RegionID, PointX, PointY, PointZ) values ( ?EstateID, ?PointX, ?PointY,?PointZ)"; + cmd.CommandText = "insert into spawn_points (RegionID, PointX, PointY, PointZ) values ( ?RegionID, ?PointX, ?PointY,?PointZ)"; foreach (Vector3 p in rs.SpawnPoints()) { - cmd.Parameters.AddWithValue("?EstateID", rs.RegionUUID.ToString()); + cmd.Parameters.AddWithValue("?RegionID", rs.RegionUUID.ToString()); cmd.Parameters.AddWithValue("?PointX", p.X); cmd.Parameters.AddWithValue("?PointY", p.Y); cmd.Parameters.AddWithValue("?PointZ", p.Z); -- cgit v1.1 From 39c9b656c871bf0eaba104f197a902123d7d9428 Mon Sep 17 00:00:00 2001 From: BlueWall Date: Mon, 23 Jan 2012 09:42:15 -0500 Subject: Cleanup unused parts, add some error handling --- .../CoreModules/World/Estate/TelehubManager.cs | 105 ++++++++++----------- 1 file changed, 52 insertions(+), 53 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/World/Estate/TelehubManager.cs b/OpenSim/Region/CoreModules/World/Estate/TelehubManager.cs index ee77ae1..68b4ba5 100644 --- a/OpenSim/Region/CoreModules/World/Estate/TelehubManager.cs +++ b/OpenSim/Region/CoreModules/World/Estate/TelehubManager.cs @@ -35,83 +35,66 @@ namespace OpenSim.Region.CoreModules.World.Estate { public class TelehubManager { - - private UUID ObjectID; - private string ObjectName; - private Vector3 ObjectPosition; - Quaternion ObjectRotation; - List SpawnPoint = new List(); - UUID EstateID; - bool m_HasTelehub = false; Scene m_Scene; - // This will get an option... - Vector3 InitialSpawnPoint = new Vector3(0.0f,0.0f,0.0f); - - public bool HasTelehub - { - get { return m_HasTelehub; } - } public TelehubManager(Scene scene) { m_Scene = scene; } - // Fill our Telehub struct with values -// public Telehub TelehubVals() -// { -// // Telehub telehub = new Telehub(); -// EstateSettings telehub = m_EstateSettings; -// -// telehub.TelehubObject = ObjectID; -// telehub.TelehubName = ObjectName; -// telehub.TelehubPos = ObjectPosition; -// telehub.TelehubRot = ObjectRotation; -// telehub. = SpawnPoint; -// return telehub; -// } - // Connect the Telehub public bool Connect(SceneObjectPart part) { - m_Scene.RegionInfo.RegionSettings.ClearSpawnPoints(); + bool result = false; - m_Scene.RegionInfo.RegionSettings.TelehubObject = part.UUID; - m_Scene.RegionInfo.RegionSettings.TelehubName = part.Name; - m_Scene.RegionInfo.RegionSettings.TelehubPos = part.AbsolutePosition; - m_Scene.RegionInfo.RegionSettings.TelehubRot = part.GetWorldRotation(); + if (m_Scene.RegionInfo.RegionSettings.HasTelehub) + return result; - // Clear this for now - m_Scene.RegionInfo.RegionSettings.AddSpawnPoint(InitialSpawnPoint); - m_Scene.RegionInfo.RegionSettings.HasTelehub = true; - m_Scene.RegionInfo.RegionSettings.Save(); - return true; + try + { + m_Scene.RegionInfo.RegionSettings.ClearSpawnPoints(); + + m_Scene.RegionInfo.RegionSettings.TelehubObject = part.UUID; + m_Scene.RegionInfo.RegionSettings.TelehubName = part.Name; + m_Scene.RegionInfo.RegionSettings.TelehubPos = part.AbsolutePosition; + m_Scene.RegionInfo.RegionSettings.TelehubRot = part.GetWorldRotation(); + m_Scene.RegionInfo.RegionSettings.AddSpawnPoint(new Vector3(0.0f,0.0f,0.0f)); + m_Scene.RegionInfo.RegionSettings.HasTelehub = true; + m_Scene.RegionInfo.RegionSettings.Save(); + + result = true; + } + catch (Exception ex) + { + result = false; + } + + return result; } - // Disconnect the Telehub: Clear it out for now, look at just disableing + // Disconnect the Telehub: public bool DisConnect(SceneObjectPart part) { bool result = false; - try{ + if (!m_Scene.RegionInfo.RegionSettings.HasTelehub) + return result; + + try + { m_Scene.RegionInfo.RegionSettings.TelehubObject = UUID.Zero; m_Scene.RegionInfo.RegionSettings.TelehubName = String.Empty; m_Scene.RegionInfo.RegionSettings.TelehubPos = Vector3.Zero; - // This is probably wrong! But, HasTelehub will block access - m_Scene.RegionInfo.RegionSettings.TelehubRot = Quaternion.Identity; m_Scene.RegionInfo.RegionSettings.ClearSpawnPoints(); m_Scene.RegionInfo.RegionSettings.HasTelehub = false; m_Scene.RegionInfo.RegionSettings.Save(); + result = true; } catch (Exception ex) { result = false; } - finally - { - - } return result; } @@ -119,19 +102,35 @@ namespace OpenSim.Region.CoreModules.World.Estate // Add a SpawnPoint to the Telehub public bool AddSpawnPoint(Vector3 point) { + bool result = false; - float dist = (float) Util.GetDistanceTo(m_Scene.RegionInfo.RegionSettings.TelehubPos, point); - Vector3 nvec = Util.GetNormalizedVector(point - m_Scene.RegionInfo.RegionSettings.TelehubPos); - Vector3 spoint = nvec * dist; + if (!m_Scene.RegionInfo.RegionSettings.HasTelehub) + return result; - m_Scene.RegionInfo.RegionSettings.AddSpawnPoint(spoint); - m_Scene.RegionInfo.RegionSettings.Save(); - return true; + try + { + float dist = (float) Util.GetDistanceTo(m_Scene.RegionInfo.RegionSettings.TelehubPos, point); + Vector3 nvec = Util.GetNormalizedVector(point - m_Scene.RegionInfo.RegionSettings.TelehubPos); + Vector3 spoint = nvec * dist; + + m_Scene.RegionInfo.RegionSettings.AddSpawnPoint(spoint); + m_Scene.RegionInfo.RegionSettings.Save(); + result = true; + } + catch (Exception ex) + { + result = false; + } + + return result; } // Remove a SpawnPoint from the Telehub public bool RemoveSpawnPoint(int spawnpoint) { + if (!m_Scene.RegionInfo.RegionSettings.HasTelehub) + return false; + m_Scene.RegionInfo.RegionSettings.RemoveSpawnPoint(spawnpoint); m_Scene.RegionInfo.RegionSettings.Save(); -- cgit v1.1 From 9cfc43005d8d906083b176a2961aa3892193dcb4 Mon Sep 17 00:00:00 2001 From: BlueWall Date: Mon, 23 Jan 2012 10:28:18 -0500 Subject: Cleanup --- OpenSim/Region/CoreModules/World/Estate/TelehubManager.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/World/Estate/TelehubManager.cs b/OpenSim/Region/CoreModules/World/Estate/TelehubManager.cs index 68b4ba5..9b92df9 100644 --- a/OpenSim/Region/CoreModules/World/Estate/TelehubManager.cs +++ b/OpenSim/Region/CoreModules/World/Estate/TelehubManager.cs @@ -109,10 +109,13 @@ namespace OpenSim.Region.CoreModules.World.Estate try { - float dist = (float) Util.GetDistanceTo(m_Scene.RegionInfo.RegionSettings.TelehubPos, point); - Vector3 nvec = Util.GetNormalizedVector(point - m_Scene.RegionInfo.RegionSettings.TelehubPos); + Vector3 thPos = m_Scene.RegionInfo.RegionSettings.TelehubPos; + Quaternion thRot = m_Scene.RegionInfo.RegionSettings.TelehubRot; + + float dist = (float) Util.GetDistanceTo(thPos, point); + Vector3 nvec = Util.GetNormalizedVector(point - thPos); Vector3 spoint = nvec * dist; - + m_Scene.RegionInfo.RegionSettings.AddSpawnPoint(spoint); m_Scene.RegionInfo.RegionSettings.Save(); result = true; -- cgit v1.1 From 6a85abbd14f36f9d1f1035820730f3e8cd395987 Mon Sep 17 00:00:00 2001 From: BlueWall Date: Mon, 23 Jan 2012 14:53:25 -0500 Subject: Add update to Telehub position and rotation before adding SpawnPoints --- OpenSim/Region/CoreModules/World/Estate/TelehubManager.cs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/World/Estate/TelehubManager.cs b/OpenSim/Region/CoreModules/World/Estate/TelehubManager.cs index 9b92df9..2d7d0ee 100644 --- a/OpenSim/Region/CoreModules/World/Estate/TelehubManager.cs +++ b/OpenSim/Region/CoreModules/World/Estate/TelehubManager.cs @@ -109,11 +109,18 @@ namespace OpenSim.Region.CoreModules.World.Estate try { - Vector3 thPos = m_Scene.RegionInfo.RegionSettings.TelehubPos; - Quaternion thRot = m_Scene.RegionInfo.RegionSettings.TelehubRot; + // Need to update the position in case the Telehubn has been moved + UUID TelehubID = m_Scene.RegionInfo.RegionSettings.TelehubObject; + SceneObjectPart part = m_Scene.GetSceneObjectPart(TelehubID); - float dist = (float) Util.GetDistanceTo(thPos, point); - Vector3 nvec = Util.GetNormalizedVector(point - thPos); + Vector3 TelehubPos = part.AbsolutePosition; + Quaternion TelehubRot = part.GetWorldRotation(); + + m_Scene.RegionInfo.RegionSettings.TelehubPos = TelehubPos; + m_Scene.RegionInfo.RegionSettings.TelehubRot = TelehubRot; + + float dist = (float) Util.GetDistanceTo(TelehubPos, point); + Vector3 nvec = Util.GetNormalizedVector(point - TelehubPos); Vector3 spoint = nvec * dist; m_Scene.RegionInfo.RegionSettings.AddSpawnPoint(spoint); -- cgit v1.1 From 48379e644206bf59e5e2059902f1d7dfd1be5e94 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 23 Jan 2012 21:23:55 +0000 Subject: IMPORTANT!!!!! Please READ. DO NOT Use this version or any before it since the Telehub commits! They will eat your babies and corrupt your database while they munch. DO NOT use anything from the first Telehub commit to this one. FIRST GOOD COMMIT is the one FOLLOWING this one. You have been warned. --- OpenSim/Data/MySQL/Resources/RegionStore.migrations | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Data/MySQL/Resources/RegionStore.migrations b/OpenSim/Data/MySQL/Resources/RegionStore.migrations index 3132148..720e200 100644 --- a/OpenSim/Data/MySQL/Resources/RegionStore.migrations +++ b/OpenSim/Data/MySQL/Resources/RegionStore.migrations @@ -848,21 +848,12 @@ COMMIT; BEGIN; CREATE TABLE IF NOT EXISTS `spawn_points` ( `RegionID` varchar(36) COLLATE utf8_unicode_ci NOT NULL, - `PointX` float NOT NULL, - `PointY` float NOT NULL, - `PointZ` float NOT NULL, + `Yaw` float NOT NULL, + `Pitch` float NOT NULL, + `Distance` float NOT NULL, KEY `RegionID` (`RegionID`) ) ENGINE=Innodb; ALTER TABLE `regionsettings` ADD COLUMN `TelehubObject` varchar(36) NOT NULL; -ALTER TABLE `regionsettings` ADD COLUMN `TelehubName` varchar(255) NOT NULL; -ALTER TABLE `regionsettings` ADD COLUMN `TelehubEnabled` tinyint(4) NOT NULL; -ALTER TABLE `regionsettings` ADD COLUMN `TelehubPosX` float NOT NULL; -ALTER TABLE `regionsettings` ADD COLUMN `TelehubPosY` float NOT NULL; -ALTER TABLE `regionsettings` ADD COLUMN `TelehubPosZ` float NOT NULL; -ALTER TABLE `regionsettings` ADD COLUMN `TelehubRotX` float NOT NULL; -ALTER TABLE `regionsettings` ADD COLUMN `TelehubRotY` float NOT NULL; -ALTER TABLE `regionsettings` ADD COLUMN `TelehubRotZ` float NOT NULL; -ALTER TABLE `regionsettings` ADD COLUMN `TelehubRotW` float NOT NULL; COMMIT; -- cgit v1.1 From 87799c1f3ddfbc4b0994cac4e54498520899e4d4 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 24 Jan 2012 00:32:10 +0000 Subject: Change Telehubs to store only the data that is really needed and not additional redundant information. --- OpenSim/Data/MySQL/MySQLSimulationData.cs | 53 +++------- OpenSim/Framework/RegionSettings.cs | 116 ++++++++------------- .../World/Estate/EstateManagementModule.cs | 78 ++++++++------ .../CoreModules/World/Estate/TelehubManager.cs | 70 ++++--------- 4 files changed, 123 insertions(+), 194 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index b94f6ac..ebb41a5 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs @@ -997,9 +997,7 @@ namespace OpenSim.Data.MySQL "covenant, Sandbox, sunvectorx, sunvectory, " + "sunvectorz, loaded_creation_datetime, " + "loaded_creation_id, map_tile_ID, " + - "TelehubEnabled, TelehubObject, TelehubName, " + - "TelehubPosX, TelehubPosY, TelehubPosZ, " + - "TelehubRotX, TelehubRotY, TelehubRotZ, TelehubRotW) " + + "TelehubObject) " + "values (?RegionUUID, ?BlockTerraform, " + "?BlockFly, ?AllowDamage, ?RestrictPushing, " + "?AllowLandResell, ?AllowLandJoinDivide, " + @@ -1015,10 +1013,7 @@ namespace OpenSim.Data.MySQL "?SunPosition, ?Covenant, ?Sandbox, " + "?SunVectorX, ?SunVectorY, ?SunVectorZ, " + "?LoadedCreationDateTime, ?LoadedCreationID, " + - "?TerrainImageID, " + - "?TelehubEnabled, ?TelehubObject, ?TelehubName, " + - "?TelehubPosX, ?TelehubPosY, ?TelehubPosZ, " + - "?TelehubRotX, ?TelehubRotY, ?TelehubRotZ, ?TelehubRotW )"; + "?TerrainImageID) "; FillRegionSettingsCommand(cmd, rs); @@ -1306,20 +1301,7 @@ namespace OpenSim.Data.MySQL newSettings.LoadedCreationID = (String) row["loaded_creation_id"]; newSettings.TerrainImageID = DBGuid.FromDB(row["map_tile_ID"]); - newSettings.HasTelehub = Convert.ToBoolean(row["TelehubEnabled"]); newSettings.TelehubObject = DBGuid.FromDB(row["TelehubObject"]); - newSettings.TelehubName = (string) row["TelehubName"]; - newSettings.TelehubPos = new Vector3 ( - Convert.ToSingle(row["TelehubPosX"]), - Convert.ToSingle(row["TelehubPosY"]), - Convert.ToSingle(row["TelehubPosZ"]) - ); - newSettings.TelehubRot = new Quaternion ( - Convert.ToSingle(row["TelehubRotX"]), - Convert.ToSingle(row["TelehubRotY"]), - Convert.ToSingle(row["TelehubRotZ"]), - Convert.ToSingle(row["TelehubRotW"]) - ); return newSettings; } @@ -1650,16 +1632,7 @@ namespace OpenSim.Data.MySQL cmd.Parameters.AddWithValue("LoadedCreationDateTime", settings.LoadedCreationDateTime); cmd.Parameters.AddWithValue("LoadedCreationID", settings.LoadedCreationID); cmd.Parameters.AddWithValue("TerrainImageID", settings.TerrainImageID); - cmd.Parameters.AddWithValue("TelehubEnabled", settings.HasTelehub); cmd.Parameters.AddWithValue("TelehubObject", settings.TelehubObject); - cmd.Parameters.AddWithValue("TelehubName", settings.TelehubName); - cmd.Parameters.AddWithValue("TelehubPosX", settings.TelehubPos.X); - cmd.Parameters.AddWithValue("TelehubPosY", settings.TelehubPos.Y); - cmd.Parameters.AddWithValue("TelehubPosZ", settings.TelehubPos.Z); - cmd.Parameters.AddWithValue("TelehubRotX", settings.TelehubRot.X); - cmd.Parameters.AddWithValue("TelehubRotY", settings.TelehubRot.Y); - cmd.Parameters.AddWithValue("TelehubRotZ", settings.TelehubRot.Z); - cmd.Parameters.AddWithValue("TelehubRotW", settings.TelehubRot.W); } /// @@ -1874,20 +1847,20 @@ namespace OpenSim.Data.MySQL using (MySqlCommand cmd = dbcon.CreateCommand()) { - cmd.CommandText = "select PointX, PointY, PointZ from spawn_points where RegionID = ?RegionID"; + cmd.CommandText = "select Yaw, Pitch, Distance from spawn_points where RegionID = ?RegionID"; cmd.Parameters.AddWithValue("?RegionID", rs.RegionUUID.ToString()); using (IDataReader r = cmd.ExecuteReader()) { while (r.Read()) { - Vector3 point = new Vector3(); + SpawnPoint sp = new SpawnPoint(); - point.X = (float)r["PointX"]; - point.Y = (float)r["PointY"]; - point.Z = (float)r["PointZ"]; + sp.Yaw = (float)r["Yaw"]; + sp.Pitch = (float)r["Pitch"]; + sp.Distance = (float)r["Distance"]; - rs.AddSpawnPoint(point); + rs.AddSpawnPoint(sp); } } } @@ -1912,14 +1885,14 @@ namespace OpenSim.Data.MySQL cmd.Parameters.Clear(); - cmd.CommandText = "insert into spawn_points (RegionID, PointX, PointY, PointZ) values ( ?RegionID, ?PointX, ?PointY,?PointZ)"; + cmd.CommandText = "insert into spawn_points (RegionID, Yaw, Pitch, Distance) values ( ?RegionID, ?Yaw, ?Pitch, ?Distance)"; - foreach (Vector3 p in rs.SpawnPoints()) + foreach (SpawnPoint p in rs.SpawnPoints()) { cmd.Parameters.AddWithValue("?RegionID", rs.RegionUUID.ToString()); - cmd.Parameters.AddWithValue("?PointX", p.X); - cmd.Parameters.AddWithValue("?PointY", p.Y); - cmd.Parameters.AddWithValue("?PointZ", p.Z); + cmd.Parameters.AddWithValue("?Yaw", p.Yaw); + cmd.Parameters.AddWithValue("?Pitch", p.Pitch); + cmd.Parameters.AddWithValue("?Distance", p.Distance); cmd.ExecuteNonQuery(); cmd.Parameters.Clear(); diff --git a/OpenSim/Framework/RegionSettings.cs b/OpenSim/Framework/RegionSettings.cs index 9b5bbf2..0a59f43 100644 --- a/OpenSim/Framework/RegionSettings.cs +++ b/OpenSim/Framework/RegionSettings.cs @@ -32,6 +32,47 @@ using OpenMetaverse; namespace OpenSim.Framework { + public struct SpawnPoint + { + public float Yaw; + public float Pitch; + public float Distance; + + public void SetLocation(Vector3 pos, Quaternion rot, Vector3 point) + { + // The point is an absolute position, so we need the relative + // location to the spawn point + Vector3 offset = pos - point; + Distance = Vector3.Mag(offset); + + // Next we need to rotate this vector into the spawn point's + // coordinate system + offset = offset * rot; + + Vector3 dir = Vector3.Normalize(offset); + + // Get the bearing (yaw) + Yaw = (float)Math.Atan2(dir.Y, dir.X); + + // Get the elevation (pitch) + Pitch = (float)-Math.Atan2(dir.Z, Math.Sqrt(dir.X * dir.X + dir.Y * dir.Y)); + } + + public Vector3 GetLocation(Vector3 pos, Quaternion rot) + { + Quaternion y = Quaternion.CreateFromEulers(0, 0, Yaw); + Quaternion p = Quaternion.CreateFromEulers(0, Pitch, 0); + + Vector3 dir = new Vector3(1, 0, 0) * p * y; + Vector3 offset = dir * (float)Distance; + + rot.W = -rot.W; + offset *= rot; + + return pos + offset; + } + } + public class RegionSettings { public delegate void SaveDelegate(RegionSettings rs); @@ -398,28 +439,13 @@ namespace OpenSim.Framework set { m_LoadedCreationID = value; } } - // Telehub support - private bool m_TelehubEnabled = false; - public bool HasTelehub - { - get { return m_TelehubEnabled; } - set { m_TelehubEnabled = value; } - } - // Connected Telehub object private UUID m_TelehubObject; public UUID TelehubObject { get { - if (HasTelehub) - { - return m_TelehubObject; - } - else - { - return UUID.Zero; - } + return m_TelehubObject; } set { @@ -427,66 +453,14 @@ namespace OpenSim.Framework } } - // Connected Telehub name - private string m_TelehubName; - public string TelehubName - { - get - { - if (HasTelehub) - { - return m_TelehubName; - } - else - { - return String.Empty; - } - } - set - { - m_TelehubName = value; - } - } - - // Connected Telehub position - private Vector3 m_TelehubPos; - public Vector3 TelehubPos - { - get - { - if (HasTelehub) - { - return m_TelehubPos; - } - else - { - return Vector3.Zero; - } - } - set - { - m_TelehubPos = value; - } - } - - // Connected Telehub rotation - private Quaternion m_TelehubRot; - public Quaternion TelehubRot - { - get - { return m_TelehubRot; } - set - { m_TelehubRot = value; } - } - // Our Connected Telehub's SpawnPoints - public List l_SpawnPoints = new List(); + public List l_SpawnPoints = new List(); // Add a SpawnPoint // ** These are not region coordinates ** // They are relative to the Telehub coordinates // - public void AddSpawnPoint(Vector3 point) + public void AddSpawnPoint(SpawnPoint point) { l_SpawnPoints.Add(point); } @@ -498,7 +472,7 @@ namespace OpenSim.Framework } // Return the List of SpawnPoints - public List SpawnPoints() + public List SpawnPoints() { return l_SpawnPoints; diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs index cdcea65..2789d5f 100644 --- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs @@ -609,59 +609,37 @@ namespace OpenSim.Region.CoreModules.World.Estate { case "info ui": // Send info: - if (Scene.RegionInfo.RegionSettings.HasTelehub) - { - RegionSettings settings = this.Scene.RegionInfo.RegionSettings; - client.SendTelehubInfo(settings.TelehubObject, settings.TelehubName, settings.TelehubPos, - settings.TelehubRot, settings.SpawnPoints()); - } - else - { - return; - } + SendTelehubInfo(client); break; case "connect": // Add the Telehub part = Scene.GetSceneObjectPart((uint)param1); - if (m_Telehub.Connect(part)) - { - RegionSettings settings = this.Scene.RegionInfo.RegionSettings; - client.SendTelehubInfo(settings.TelehubObject, settings.TelehubName, settings.TelehubPos, - settings.TelehubRot, settings.SpawnPoints()); - } + if (part == null) + return; + SceneObjectGroup grp = part.ParentGroup; + + if (m_Telehub.Connect(grp)) + SendTelehubInfo(client); break; case "delete": // Disconnect Telehub - part = Scene.GetSceneObjectPart((uint)param1); - if (m_Telehub.DisConnect(part)) - { - RegionSettings settings = this.Scene.RegionInfo.RegionSettings; - client.SendTelehubInfo(settings.TelehubObject, settings.TelehubName, settings.TelehubPos, - settings.TelehubRot, settings.SpawnPoints()); - } + if (m_Telehub.Disconnect()) + SendTelehubInfo(client); break; case "spawnpoint add": // Add SpawnPoint to the Telehub part = Scene.GetSceneObjectPart((uint)param1); if( m_Telehub.AddSpawnPoint(part.AbsolutePosition)) - { - RegionSettings settings = this.Scene.RegionInfo.RegionSettings; - client.SendTelehubInfo(settings.TelehubObject, settings.TelehubName, settings.TelehubPos, - settings.TelehubRot, settings.SpawnPoints()); - } + SendTelehubInfo(client); break; case "spawnpoint remove": // Remove SpawnPoint from Telehub if (m_Telehub.RemoveSpawnPoint((int)param1)) - { - RegionSettings settings = this.Scene.RegionInfo.RegionSettings; - client.SendTelehubInfo(settings.TelehubObject, settings.TelehubName, settings.TelehubPos, - settings.TelehubRot, settings.SpawnPoints()); - } + SendTelehubInfo(client); break; default: @@ -1316,5 +1294,39 @@ namespace OpenSim.Region.CoreModules.World.Estate if (onmessage != null) onmessage(Scene.RegionInfo.RegionID, fromID, fromName, message); } + + + private void SendTelehubInfo(IClientAPI client) + { + RegionSettings settings = + this.Scene.RegionInfo.RegionSettings; + + SceneObjectGroup telehub = null; + if (settings.TelehubObject != UUID.Zero && + (telehub = Scene.GetSceneObjectGroup(settings.TelehubObject)) != null) + { + List spawnPoints = new List(); + + foreach (SpawnPoint sp in settings.SpawnPoints()) + { + spawnPoints.Add(sp.GetLocation(telehub.AbsolutePosition, telehub.GroupRotation)); + } + + client.SendTelehubInfo(settings.TelehubObject, + telehub.Name, + telehub.AbsolutePosition, + telehub.GroupRotation, + spawnPoints); + } + else + { + client.SendTelehubInfo(UUID.Zero, + String.Empty, + Vector3.Zero, + Quaternion.Identity, + new List()); + } + } } } + diff --git a/OpenSim/Region/CoreModules/World/Estate/TelehubManager.cs b/OpenSim/Region/CoreModules/World/Estate/TelehubManager.cs index 2d7d0ee..3eb7efa 100644 --- a/OpenSim/Region/CoreModules/World/Estate/TelehubManager.cs +++ b/OpenSim/Region/CoreModules/World/Estate/TelehubManager.cs @@ -43,102 +43,72 @@ namespace OpenSim.Region.CoreModules.World.Estate } // Connect the Telehub - public bool Connect(SceneObjectPart part) + public bool Connect(SceneObjectGroup grp) { - bool result = false; - - if (m_Scene.RegionInfo.RegionSettings.HasTelehub) - return result; - try { m_Scene.RegionInfo.RegionSettings.ClearSpawnPoints(); - m_Scene.RegionInfo.RegionSettings.TelehubObject = part.UUID; - m_Scene.RegionInfo.RegionSettings.TelehubName = part.Name; - m_Scene.RegionInfo.RegionSettings.TelehubPos = part.AbsolutePosition; - m_Scene.RegionInfo.RegionSettings.TelehubRot = part.GetWorldRotation(); - m_Scene.RegionInfo.RegionSettings.AddSpawnPoint(new Vector3(0.0f,0.0f,0.0f)); - m_Scene.RegionInfo.RegionSettings.HasTelehub = true; + m_Scene.RegionInfo.RegionSettings.TelehubObject = grp.UUID; m_Scene.RegionInfo.RegionSettings.Save(); - - result = true; } catch (Exception ex) { - result = false; + return false; } - return result; + return true; } // Disconnect the Telehub: - public bool DisConnect(SceneObjectPart part) + public bool Disconnect() { - bool result = false; - - if (!m_Scene.RegionInfo.RegionSettings.HasTelehub) - return result; + if (m_Scene.RegionInfo.RegionSettings.TelehubObject == UUID.Zero) + return false; try { m_Scene.RegionInfo.RegionSettings.TelehubObject = UUID.Zero; - m_Scene.RegionInfo.RegionSettings.TelehubName = String.Empty; - m_Scene.RegionInfo.RegionSettings.TelehubPos = Vector3.Zero; m_Scene.RegionInfo.RegionSettings.ClearSpawnPoints(); - m_Scene.RegionInfo.RegionSettings.HasTelehub = false; m_Scene.RegionInfo.RegionSettings.Save(); - - result = true; } catch (Exception ex) { - result = false; + return false; } - return result; + return true; } // Add a SpawnPoint to the Telehub public bool AddSpawnPoint(Vector3 point) { - bool result = false; + if (m_Scene.RegionInfo.RegionSettings.TelehubObject == UUID.Zero) + return false; - if (!m_Scene.RegionInfo.RegionSettings.HasTelehub) - return result; + SceneObjectGroup grp = m_Scene.GetSceneObjectGroup(m_Scene.RegionInfo.RegionSettings.TelehubObject); + if (grp == null) + return false; try { - // Need to update the position in case the Telehubn has been moved - UUID TelehubID = m_Scene.RegionInfo.RegionSettings.TelehubObject; - SceneObjectPart part = m_Scene.GetSceneObjectPart(TelehubID); - - Vector3 TelehubPos = part.AbsolutePosition; - Quaternion TelehubRot = part.GetWorldRotation(); - - m_Scene.RegionInfo.RegionSettings.TelehubPos = TelehubPos; - m_Scene.RegionInfo.RegionSettings.TelehubRot = TelehubRot; - - float dist = (float) Util.GetDistanceTo(TelehubPos, point); - Vector3 nvec = Util.GetNormalizedVector(point - TelehubPos); - Vector3 spoint = nvec * dist; - - m_Scene.RegionInfo.RegionSettings.AddSpawnPoint(spoint); + SpawnPoint sp = new SpawnPoint(); + sp.SetLocation(grp.AbsolutePosition, grp.GroupRotation, point); + m_Scene.RegionInfo.RegionSettings.AddSpawnPoint(sp); m_Scene.RegionInfo.RegionSettings.Save(); - result = true; } catch (Exception ex) { - result = false; + return false; } - return result; + return true; } // Remove a SpawnPoint from the Telehub public bool RemoveSpawnPoint(int spawnpoint) { - if (!m_Scene.RegionInfo.RegionSettings.HasTelehub) + if (m_Scene.RegionInfo.RegionSettings.TelehubObject == UUID.Zero) return false; m_Scene.RegionInfo.RegionSettings.RemoveSpawnPoint(spawnpoint); -- cgit v1.1 From 7bb01a17eee0a35271c312379be9e528338ec08c Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 24 Jan 2012 00:38:00 +0000 Subject: Add a forgotten parameter --- OpenSim/Data/MySQL/MySQLSimulationData.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim') diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index ebb41a5..31d17f1 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs @@ -1013,7 +1013,7 @@ namespace OpenSim.Data.MySQL "?SunPosition, ?Covenant, ?Sandbox, " + "?SunVectorX, ?SunVectorY, ?SunVectorZ, " + "?LoadedCreationDateTime, ?LoadedCreationID, " + - "?TerrainImageID) "; + "?TerrainImageID, ?TelehubObject) "; FillRegionSettingsCommand(cmd, rs); -- cgit v1.1 From c0e1784e86f3539656f4bc71aaddfc1df3d12d20 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 24 Jan 2012 01:17:41 +0000 Subject: Correct a coordinate to make the viewer like it --- OpenSim/Framework/RegionSettings.cs | 4 ++-- OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/RegionSettings.cs b/OpenSim/Framework/RegionSettings.cs index 0a59f43..399c795 100644 --- a/OpenSim/Framework/RegionSettings.cs +++ b/OpenSim/Framework/RegionSettings.cs @@ -58,7 +58,7 @@ namespace OpenSim.Framework Pitch = (float)-Math.Atan2(dir.Z, Math.Sqrt(dir.X * dir.X + dir.Y * dir.Y)); } - public Vector3 GetLocation(Vector3 pos, Quaternion rot) + public Vector3 GetLocation(Quaternion rot) { Quaternion y = Quaternion.CreateFromEulers(0, 0, Yaw); Quaternion p = Quaternion.CreateFromEulers(0, Pitch, 0); @@ -69,7 +69,7 @@ namespace OpenSim.Framework rot.W = -rot.W; offset *= rot; - return pos + offset; + return offset; } } diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs index 2789d5f..1855aea 100644 --- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs @@ -1309,7 +1309,7 @@ namespace OpenSim.Region.CoreModules.World.Estate foreach (SpawnPoint sp in settings.SpawnPoints()) { - spawnPoints.Add(sp.GetLocation(telehub.AbsolutePosition, telehub.GroupRotation)); + spawnPoints.Add(sp.GetLocation(telehub.GroupRotation)); } client.SendTelehubInfo(settings.TelehubObject, -- cgit v1.1 From 0d2e02efb1da5cba09a8cf306b83e5789529601c Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 24 Jan 2012 01:29:50 +0000 Subject: Reverse the spawn point distance vector --- OpenSim/Framework/RegionSettings.cs | 6 +++--- OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/RegionSettings.cs b/OpenSim/Framework/RegionSettings.cs index 399c795..9ffde03 100644 --- a/OpenSim/Framework/RegionSettings.cs +++ b/OpenSim/Framework/RegionSettings.cs @@ -42,7 +42,7 @@ namespace OpenSim.Framework { // The point is an absolute position, so we need the relative // location to the spawn point - Vector3 offset = pos - point; + Vector3 offset = point - pos; Distance = Vector3.Mag(offset); // Next we need to rotate this vector into the spawn point's @@ -58,7 +58,7 @@ namespace OpenSim.Framework Pitch = (float)-Math.Atan2(dir.Z, Math.Sqrt(dir.X * dir.X + dir.Y * dir.Y)); } - public Vector3 GetLocation(Quaternion rot) + public Vector3 GetLocation(Vector3 pos, Quaternion rot) { Quaternion y = Quaternion.CreateFromEulers(0, 0, Yaw); Quaternion p = Quaternion.CreateFromEulers(0, Pitch, 0); @@ -69,7 +69,7 @@ namespace OpenSim.Framework rot.W = -rot.W; offset *= rot; - return offset; + return pos + offset; } } diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs index 1855aea..20f3903 100644 --- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs @@ -1309,7 +1309,7 @@ namespace OpenSim.Region.CoreModules.World.Estate foreach (SpawnPoint sp in settings.SpawnPoints()) { - spawnPoints.Add(sp.GetLocation(telehub.GroupRotation)); + spawnPoints.Add(sp.GetLocation(Vector3.Zero, telehub.GroupRotation)); } client.SendTelehubInfo(settings.TelehubObject, -- cgit v1.1 From a4977bbe190fb6c1eb5c45247b9222c719118fd4 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 24 Jan 2012 01:48:38 +0100 Subject: Simplify and streamline telehub editing code. Verify rotations and fix spwan point positioning on rotated telehubs. --- OpenSim/Framework/RegionSettings.cs | 2 +- .../World/Estate/EstateManagementModule.cs | 19 +++--- .../CoreModules/World/Estate/TelehubManager.cs | 69 +++++++--------------- 3 files changed, 31 insertions(+), 59 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/RegionSettings.cs b/OpenSim/Framework/RegionSettings.cs index 9ffde03..e115432 100644 --- a/OpenSim/Framework/RegionSettings.cs +++ b/OpenSim/Framework/RegionSettings.cs @@ -47,6 +47,7 @@ namespace OpenSim.Framework // Next we need to rotate this vector into the spawn point's // coordinate system + rot.W = -rot.W; offset = offset * rot; Vector3 dir = Vector3.Normalize(offset); @@ -66,7 +67,6 @@ namespace OpenSim.Framework Vector3 dir = new Vector3(1, 0, 0) * p * y; Vector3 offset = dir * (float)Distance; - rot.W = -rot.W; offset *= rot; return pos + offset; diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs index 20f3903..2e1487f 100644 --- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs @@ -608,8 +608,6 @@ namespace OpenSim.Region.CoreModules.World.Estate switch (cmd) { case "info ui": - // Send info: - SendTelehubInfo(client); break; case "connect": @@ -619,32 +617,31 @@ namespace OpenSim.Region.CoreModules.World.Estate return; SceneObjectGroup grp = part.ParentGroup; - if (m_Telehub.Connect(grp)) - SendTelehubInfo(client); + m_Telehub.Connect(grp); break; case "delete": // Disconnect Telehub - if (m_Telehub.Disconnect()) - SendTelehubInfo(client); + m_Telehub.Disconnect(); break; case "spawnpoint add": // Add SpawnPoint to the Telehub part = Scene.GetSceneObjectPart((uint)param1); - if( m_Telehub.AddSpawnPoint(part.AbsolutePosition)) - SendTelehubInfo(client); + if (part == null) + return; + m_Telehub.AddSpawnPoint(part.AbsolutePosition); break; case "spawnpoint remove": // Remove SpawnPoint from Telehub - if (m_Telehub.RemoveSpawnPoint((int)param1)) - SendTelehubInfo(client); + m_Telehub.RemoveSpawnPoint((int)param1); break; default: break; } + SendTelehubInfo(client); } private void SendSimulatorBlueBoxMessage( @@ -1309,7 +1306,7 @@ namespace OpenSim.Region.CoreModules.World.Estate foreach (SpawnPoint sp in settings.SpawnPoints()) { - spawnPoints.Add(sp.GetLocation(Vector3.Zero, telehub.GroupRotation)); + spawnPoints.Add(sp.GetLocation(Vector3.Zero, Quaternion.Identity)); } client.SendTelehubInfo(settings.TelehubObject, diff --git a/OpenSim/Region/CoreModules/World/Estate/TelehubManager.cs b/OpenSim/Region/CoreModules/World/Estate/TelehubManager.cs index 3eb7efa..8bc831f 100644 --- a/OpenSim/Region/CoreModules/World/Estate/TelehubManager.cs +++ b/OpenSim/Region/CoreModules/World/Estate/TelehubManager.cs @@ -26,15 +26,19 @@ */ using System; +using System.Reflection; using OpenMetaverse; using System.Collections.Generic; using OpenSim.Framework; using OpenSim.Region.Framework.Scenes; +using log4net; namespace OpenSim.Region.CoreModules.World.Estate { public class TelehubManager { + // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + Scene m_Scene; public TelehubManager(Scene scene) @@ -43,78 +47,49 @@ namespace OpenSim.Region.CoreModules.World.Estate } // Connect the Telehub - public bool Connect(SceneObjectGroup grp) + public void Connect(SceneObjectGroup grp) { - try - { - m_Scene.RegionInfo.RegionSettings.ClearSpawnPoints(); - - m_Scene.RegionInfo.RegionSettings.TelehubObject = grp.UUID; - m_Scene.RegionInfo.RegionSettings.Save(); - } - catch (Exception ex) - { - return false; - } + m_Scene.RegionInfo.RegionSettings.ClearSpawnPoints(); - return true; + m_Scene.RegionInfo.RegionSettings.TelehubObject = grp.UUID; + m_Scene.RegionInfo.RegionSettings.Save(); } // Disconnect the Telehub: - public bool Disconnect() + public void Disconnect() { if (m_Scene.RegionInfo.RegionSettings.TelehubObject == UUID.Zero) - return false; + return; - try - { - m_Scene.RegionInfo.RegionSettings.TelehubObject = UUID.Zero; - m_Scene.RegionInfo.RegionSettings.ClearSpawnPoints(); - m_Scene.RegionInfo.RegionSettings.Save(); - } - catch (Exception ex) - { - return false; - } - - return true; + m_Scene.RegionInfo.RegionSettings.TelehubObject = UUID.Zero; + m_Scene.RegionInfo.RegionSettings.ClearSpawnPoints(); + m_Scene.RegionInfo.RegionSettings.Save(); } // Add a SpawnPoint to the Telehub - public bool AddSpawnPoint(Vector3 point) + public void AddSpawnPoint(Vector3 point) { if (m_Scene.RegionInfo.RegionSettings.TelehubObject == UUID.Zero) - return false; + return; SceneObjectGroup grp = m_Scene.GetSceneObjectGroup(m_Scene.RegionInfo.RegionSettings.TelehubObject); if (grp == null) - return false; + return; - try - { - SpawnPoint sp = new SpawnPoint(); - sp.SetLocation(grp.AbsolutePosition, grp.GroupRotation, point); - m_Scene.RegionInfo.RegionSettings.AddSpawnPoint(sp); - m_Scene.RegionInfo.RegionSettings.Save(); - } - catch (Exception ex) - { - return false; - } - - return true; + SpawnPoint sp = new SpawnPoint(); + sp.SetLocation(grp.AbsolutePosition, grp.GroupRotation, point); + m_Scene.RegionInfo.RegionSettings.AddSpawnPoint(sp); + m_Scene.RegionInfo.RegionSettings.Save(); } // Remove a SpawnPoint from the Telehub - public bool RemoveSpawnPoint(int spawnpoint) + public void RemoveSpawnPoint(int spawnpoint) { if (m_Scene.RegionInfo.RegionSettings.TelehubObject == UUID.Zero) - return false; + return; m_Scene.RegionInfo.RegionSettings.RemoveSpawnPoint(spawnpoint); m_Scene.RegionInfo.RegionSettings.Save(); - - return true; } } } -- cgit v1.1 From 855d3a3ba5cdbd45997abac0f744488854583443 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 24 Jan 2012 04:06:37 +0000 Subject: Teleport routing, part 1 --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 53 ++++++++++++++++++++++++ 1 file changed, 53 insertions(+) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index c66f30e..5c56150 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3835,8 +3835,61 @@ namespace OpenSim.Region.Framework.Scenes } } + private void CheckAndAdjustTelehub(SceneObjectGroup telehub, ref Vector3 pos) + { + if ((m_teleportFlags & (TeleportFlags.ViaLogin | TeleportFlags.ViaRegionID)) == + (TeleportFlags.ViaLogin | TeleportFlags.ViaRegionID) || + (m_teleportFlags & TeleportFlags.ViaLandmark) != 0 || + (m_teleportFlags & TeleportFlags.ViaLocation) != 0 || + (m_teleportFlags & Constants.TeleportFlags.ViaHGLogin) != 0) + { + if (GodLevel < 200 && + ((!m_scene.Permissions.IsGod(m_uuid) && + !m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid)) || + (m_teleportFlags & TeleportFlags.ViaLocation) != 0 || + (m_teleportFlags & Constants.TeleportFlags.ViaHGLogin) != 0)) + { + SpawnPoint[] spawnPoints = m_scene.RegionInfo.RegionSettings.SpawnPoints().ToArray(); + if (spawnPoints.Length == 0) + return; + + float distance = 9999; + int closest = -1; + + for (int i = 0 ; i < spawnPoints.Length ; i++) + { + Vector3 spawnPosition = spawnPoints[i].GetLocation(telehub.AbsolutePosition, telehub.GroupRotation); + Vector3 offset = spawnPosition - pos; + float d = Vector3.Mag(offset); + if (d >= distance) + continue; + ILandObject land = m_scene.LandChannel.GetLandObject(spawnPosition.X, spawnPosition.Y); + if (land == null) + continue; + if (land.IsEitherBannedOrRestricted(UUID)) + continue; + distance = d; + closest = i; + } + if (closest == -1) + return; + + pos = spawnPoints[closest].GetLocation(telehub.AbsolutePosition, telehub.GroupRotation); + } + } + } + private void CheckAndAdjustLandingPoint(ref Vector3 pos) { + SceneObjectGroup telehub = null; + if (m_scene.RegionInfo.RegionSettings.TelehubObject != UUID.Zero && (telehub = m_scene.GetSceneObjectGroup(m_scene.RegionInfo.RegionSettings.TelehubObject)) != null) + { + if (!m_scene.RegionInfo.EstateSettings.AllowDirectTeleport) + { + CheckAndAdjustTelehub(telehub, ref pos); + return; + } + } ILandObject land = m_scene.LandChannel.GetLandObject(pos.X, pos.Y); if (land != null) -- cgit v1.1 From 8b035dc3c7ec88ec2c715ebaad9c3de5a34078b5 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 24 Jan 2012 18:46:24 +0000 Subject: Restrict accessible of ODECharacter Shell and Body. Add method doc and some error log lines. --- OpenSim/Region/Physics/OdePlugin/ODECharacter.cs | 37 +++++++++++++++++------- OpenSim/Region/Physics/OdePlugin/OdeScene.cs | 2 +- 2 files changed, 27 insertions(+), 12 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs index 68999fc..c6e8286 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs @@ -134,9 +134,18 @@ namespace OpenSim.Region.Physics.OdePlugin | CollisionCategories.Body | CollisionCategories.Character | CollisionCategories.Land); - internal IntPtr Body = IntPtr.Zero; + /// + /// Body for dynamics simulation + /// + internal IntPtr Body { get; private set; } + private OdeScene _parent_scene; - internal IntPtr Shell = IntPtr.Zero; + + /// + /// Collision geometry + /// + internal IntPtr Shell { get; private set; } + private IntPtr Amotor = IntPtr.Zero; private d.Mass ShellMass; @@ -1018,6 +1027,13 @@ namespace OpenSim.Region.Physics.OdePlugin /// private void CreateOdeStructures(float npositionX, float npositionY, float npositionZ, float tensor) { + if (!(Shell == IntPtr.Zero && Body == IntPtr.Zero && Amotor == IntPtr.Zero)) + { + m_log.ErrorFormat( + "[ODE CHARACTER]: Creating ODE structures for {0} even though some already exist. Shell = {1}, Body = {2}, Amotor = {3}", + Name, Shell, Body, Amotor); + } + int dAMotorEuler = 1; // _parent_scene.waitForSpaceUnlock(_parent_scene.space); if (CAPSULE_LENGTH <= 0) @@ -1135,6 +1151,14 @@ namespace OpenSim.Region.Physics.OdePlugin /// internal void DestroyOdeStructures() { + // Create avatar capsule and related ODE data + if (Shell == IntPtr.Zero || Body == IntPtr.Zero || Amotor == IntPtr.Zero) + { + m_log.ErrorFormat( + "[ODE CHARACTER]: Destroying ODE structures for {0} even though some are already null. Shell = {1}, Body = {2}, Amotor = {3}", + Name, Shell, Body, Amotor); + } + // destroy avatar capsule and related ODE data if (Amotor != IntPtr.Zero) { @@ -1260,15 +1284,6 @@ namespace OpenSim.Region.Physics.OdePlugin { if (m_tainted_isPhysical) { - // Create avatar capsule and related ODE data - if (!(Shell == IntPtr.Zero && Body == IntPtr.Zero && Amotor == IntPtr.Zero)) - { - m_log.Warn("[ODE CHARACTER]: re-creating the following avatar ODE data for " + Name + ", even though it already exists - " - + (Shell!=IntPtr.Zero ? "Shell ":"") - + (Body!=IntPtr.Zero ? "Body ":"") - + (Amotor!=IntPtr.Zero ? "Amotor ":"")); - } - CreateOdeStructures(_position.X, _position.Y, _position.Z, m_tensor); _parent_scene.AddCharacter(this); } diff --git a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs index 228eca9..37daf46 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs +++ b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs @@ -1525,7 +1525,7 @@ namespace OpenSim.Region.Physics.OdePlugin chr.CollidingGround = false; chr.CollidingObj = false; - // test the avatar's geometry for collision with the space + // Test the avatar's geometry for collision with the space // This will return near and the space that they are the closest to // And we'll run this again against the avatar and the space segment // This will return with a bunch of possible objects in the space segment -- cgit v1.1 From 7e76397a264042e772855be5245b64b35336744a Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 24 Jan 2012 20:54:35 +0000 Subject: minor: correct text and usage for "image queues show" reigon console command. --- .../Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs b/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs index 95aa864..261029c 100644 --- a/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs +++ b/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs @@ -88,7 +88,7 @@ namespace OpenSim.Region.CoreModules.UDP.Linden (mod, cmd) => MainConsole.Instance.Output(HandleImageQueuesClear(cmd))); scene.AddCommand( - this, "show image queues", + this, "image queues show", "image queues show ", "Show the image queues (textures downloaded via UDP) for a particular client.", (mod, cmd) => MainConsole.Instance.Output(GetImageQueuesReport(cmd))); @@ -293,7 +293,7 @@ namespace OpenSim.Region.CoreModules.UDP.Linden private string GetImageQueuesReport(string[] showParams) { if (showParams.Length < 5 || showParams.Length > 6) - return "Usage: show image queues [full]"; + return "Usage: image queues show [full]"; string firstName = showParams[3]; string lastName = showParams[4]; -- cgit v1.1 From 488fe0ae9c8cadd1abe4a643f61a6a9c7e18e34d Mon Sep 17 00:00:00 2001 From: Dan Lake Date: Tue, 24 Jan 2012 13:41:26 -0800 Subject: Removed unused events in SceneGraph: OnObjectCreate, OnObjectRemove, OnObjectDuplicate --- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 13 ------------- 1 file changed, 13 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 1e2901b..1af8346 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -60,10 +60,6 @@ namespace OpenSim.Region.Framework.Scenes protected internal event PhysicsCrash UnRecoverableError; private PhysicsCrash handlerPhysicsCrash = null; - public event ObjectDuplicateDelegate OnObjectDuplicate; - public event ObjectCreateDelegate OnObjectCreate; - public event ObjectDeleteDelegate OnObjectRemove; - #endregion #region Fields @@ -404,9 +400,6 @@ namespace OpenSim.Region.Framework.Scenes if (attachToBackup) sceneObject.AttachToBackup(); - if (OnObjectCreate != null) - OnObjectCreate(sceneObject); - lock (SceneObjectGroupsByFullID) SceneObjectGroupsByFullID[sceneObject.UUID] = sceneObject; @@ -455,9 +448,6 @@ namespace OpenSim.Region.Framework.Scenes if ((grp.RootPart.Flags & PrimFlags.Physics) == PrimFlags.Physics) RemovePhysicalPrim(grp.PrimCount); } - - if (OnObjectRemove != null) - OnObjectRemove(Entities[uuid]); lock (SceneObjectGroupsByFullID) SceneObjectGroupsByFullID.Remove(grp.UUID); @@ -1979,9 +1969,6 @@ namespace OpenSim.Region.Framework.Scenes // required for physics to update it's position copy.AbsolutePosition = copy.AbsolutePosition; - if (OnObjectDuplicate != null) - OnObjectDuplicate(original, copy); - return copy; } } -- cgit v1.1 From e8f1e7e96e59ede55dbeb949b28980c4be1dd456 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 24 Jan 2012 22:03:30 +0000 Subject: Comment out inventory statistics section from periodic stats, since this only contained the now uncollected and irrelevant inventory cache number. --- .../Framework/Statistics/SimExtraStatsCollector.cs | 29 +++++++++++----------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/Statistics/SimExtraStatsCollector.cs b/OpenSim/Framework/Statistics/SimExtraStatsCollector.cs index 5449757..3035a62 100644 --- a/OpenSim/Framework/Statistics/SimExtraStatsCollector.cs +++ b/OpenSim/Framework/Statistics/SimExtraStatsCollector.cs @@ -148,7 +148,8 @@ namespace OpenSim.Framework.Statistics /// cover situations where the inventory service accepts the request but never returns any data, since /// we do not yet timeout this situation. /// - public long InventoryServiceRetrievalFailures { get { return inventoryServiceRetrievalFailures; } } + /// Commented out because we do not cache inventory at this point +// public long InventoryServiceRetrievalFailures { get { return inventoryServiceRetrievalFailures; } } /// /// Retrieve the total frame time (in ms) of the last frame @@ -219,10 +220,10 @@ namespace OpenSim.Framework.Statistics assetServiceRequestFailures++; } - public void AddInventoryServiceRetrievalFailure() - { - inventoryServiceRetrievalFailures++; - } +// public void AddInventoryServiceRetrievalFailure() +// { +// inventoryServiceRetrievalFailures++; +// } /// /// Register as a packet queue stats provider @@ -328,13 +329,13 @@ Asset service request failures: {3}" + Environment.NewLine, "Abnormal client thread terminations: {0}" + Environment.NewLine, abnormalClientThreadTerminations)); - sb.Append(Environment.NewLine); - sb.Append("INVENTORY STATISTICS"); - sb.Append(Environment.NewLine); - sb.Append( - string.Format( - "Initial inventory caching failures: {0}" + Environment.NewLine, - InventoryServiceRetrievalFailures)); +// sb.Append(Environment.NewLine); +// sb.Append("INVENTORY STATISTICS"); +// sb.Append(Environment.NewLine); +// sb.Append( +// string.Format( +// "Initial inventory caching failures: {0}" + Environment.NewLine, +// InventoryServiceRetrievalFailures)); sb.Append(Environment.NewLine); sb.Append("FRAME STATISTICS"); @@ -399,8 +400,8 @@ Asset service request failures: {3}" + Environment.NewLine, AssetServiceRequestFailures)); args["abnormalClientThreadTerminations"] = OSD.FromString (String.Format ("{0:0.##}", abnormalClientThreadTerminations)); - args["InventoryServiceRetrievalFailures"] = OSD.FromString (String.Format ("{0:0.##}", - InventoryServiceRetrievalFailures)); +// args["InventoryServiceRetrievalFailures"] = OSD.FromString (String.Format ("{0:0.##}", +// InventoryServiceRetrievalFailures)); args["Dilatn"] = OSD.FromString (String.Format ("{0:0.##}", timeDilation)); args["SimFPS"] = OSD.FromString (String.Format ("{0:0.##}", simFps)); args["PhyFPS"] = OSD.FromString (String.Format ("{0:0.##}", physicsFps)); -- cgit v1.1 From 5e445aaf7b134f51bfdb78a965e55395eca8bad9 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 24 Jan 2012 22:09:13 +0000 Subject: Fix "Abnormal client thread terminations" stat in period CONNECTION STATISTICS to count the number of times clients are disconnected due to ack timeouts. This has been broken for a long period and would only ever show 0. --- OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'OpenSim') diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs index 5610c09..7b1aa2c 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs @@ -492,6 +492,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP if ((Environment.TickCount & Int32.MaxValue) - udpClient.TickLastPacketReceived > 1000 * 60) { m_log.Warn("[LLUDPSERVER]: Ack timeout, disconnecting " + udpClient.AgentID); + StatsManager.SimExtraStats.AddAbnormalClientThreadTermination(); RemoveClient(udpClient); return; -- cgit v1.1 From dc329202ef577d8c544eecd156ba496d7e680f0a Mon Sep 17 00:00:00 2001 From: BlueWall Date: Tue, 24 Jan 2012 17:11:35 -0500 Subject: Put Telehubs on the map --- .../CoreModules/World/WorldMap/WorldMapModule.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs index 9b0e2ff..2f723ef 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs @@ -1250,6 +1250,24 @@ namespace OpenSim.Region.CoreModules.World.WorldMap responsemap["7"] = responsearr; } + if (m_scene.RegionInfo.RegionSettings.TelehubObject != UUID.Zero) + { + SceneObjectPart sop = m_scene.GetSceneObjectPart(m_scene.RegionInfo.RegionSettings.TelehubObject); + + OSDArray responsearr = new OSDArray(); + OSDMap responsemapdata = new OSDMap(); + responsemapdata["X"] = OSD.FromInteger((int)(xstart + sop.AbsolutePosition.X)); + responsemapdata["Y"] = OSD.FromInteger((int)(ystart + sop.AbsolutePosition.Y)); + // responsemapdata["Z"] = OSD.FromInteger((int)m_scene.GetGroundHeight(x,y)); + responsemapdata["ID"] = OSD.FromUUID(sop.UUID); + responsemapdata["Name"] = OSD.FromString(sop.Name); + responsemapdata["Extra"] = OSD.FromInteger(0); // color (unused) + responsemapdata["Extra2"] = OSD.FromInteger(0); // 0 = telehub / 1 = infohub + responsearr.Add(responsemapdata); + + responsemap["1"] = responsearr; + } + return responsemap; } -- cgit v1.1 From 09baa3e679e9f3719a7fa533a31ebe2a2e75743a Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 24 Jan 2012 22:14:21 +0000 Subject: Comment out asset statistics section from periodic stats as these have not been recorded for a very long time. Some might make a comeback in the future but others are of dubious usefuless for health check purposes, or the complexity of collection outweighs their usefulness. Some data is available via other means (e.g. "fcache status"). --- .../Framework/Statistics/SimExtraStatsCollector.cs | 217 +++++++++++---------- 1 file changed, 109 insertions(+), 108 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/Statistics/SimExtraStatsCollector.cs b/OpenSim/Framework/Statistics/SimExtraStatsCollector.cs index 3035a62..a506e3b 100644 --- a/OpenSim/Framework/Statistics/SimExtraStatsCollector.cs +++ b/OpenSim/Framework/Statistics/SimExtraStatsCollector.cs @@ -42,15 +42,15 @@ namespace OpenSim.Framework.Statistics { private long abnormalClientThreadTerminations; - private long assetsInCache; - private long texturesInCache; - private long assetCacheMemoryUsage; - private long textureCacheMemoryUsage; - private TimeSpan assetRequestTimeAfterCacheMiss; - private long blockedMissingTextureRequests; +// private long assetsInCache; +// private long texturesInCache; +// private long assetCacheMemoryUsage; +// private long textureCacheMemoryUsage; +// private TimeSpan assetRequestTimeAfterCacheMiss; +// private long blockedMissingTextureRequests; - private long assetServiceRequestFailures; - private long inventoryServiceRetrievalFailures; +// private long assetServiceRequestFailures; +// private long inventoryServiceRetrievalFailures; private volatile float timeDilation; private volatile float simFps; @@ -79,27 +79,27 @@ namespace OpenSim.Framework.Statistics /// public long AbnormalClientThreadTerminations { get { return abnormalClientThreadTerminations; } } - /// - /// These statistics are being collected by push rather than pull. Pull would be simpler, but I had the - /// notion of providing some flow statistics (which pull wouldn't give us). Though admittedly these - /// haven't yet been implemented... - /// - public long AssetsInCache { get { return assetsInCache; } } - - /// - /// Currently unused - /// - public long TexturesInCache { get { return texturesInCache; } } - - /// - /// Currently misleading since we can't currently subtract removed asset memory usage without a performance hit - /// - public long AssetCacheMemoryUsage { get { return assetCacheMemoryUsage; } } - - /// - /// Currently unused - /// - public long TextureCacheMemoryUsage { get { return textureCacheMemoryUsage; } } +// /// +// /// These statistics are being collected by push rather than pull. Pull would be simpler, but I had the +// /// notion of providing some flow statistics (which pull wouldn't give us). Though admittedly these +// /// haven't yet been implemented... +// /// +// public long AssetsInCache { get { return assetsInCache; } } +// +// /// +// /// Currently unused +// /// +// public long TexturesInCache { get { return texturesInCache; } } +// +// /// +// /// Currently misleading since we can't currently subtract removed asset memory usage without a performance hit +// /// +// public long AssetCacheMemoryUsage { get { return assetCacheMemoryUsage; } } +// +// /// +// /// Currently unused +// /// +// public long TextureCacheMemoryUsage { get { return textureCacheMemoryUsage; } } public float TimeDilation { get { return timeDilation; } } public float SimFps { get { return simFps; } } @@ -123,25 +123,25 @@ namespace OpenSim.Framework.Statistics public float ActiveScripts { get { return activeScripts; } } public float ScriptLinesPerSecond { get { return scriptLinesPerSecond; } } - /// - /// This is the time it took for the last asset request made in response to a cache miss. - /// - public TimeSpan AssetRequestTimeAfterCacheMiss { get { return assetRequestTimeAfterCacheMiss; } } - - /// - /// Number of persistent requests for missing textures we have started blocking from clients. To some extent - /// this is just a temporary statistic to keep this problem in view - the root cause of this lies either - /// in a mishandling of the reply protocol, related to avatar appearance or may even originate in graphics - /// driver bugs on clients (though this seems less likely). - /// - public long BlockedMissingTextureRequests { get { return blockedMissingTextureRequests; } } - - /// - /// Record the number of times that an asset request has failed. Failures are effectively exceptions, such as - /// request timeouts. If an asset service replies that a particular asset cannot be found, this is not counted - /// as a failure - /// - public long AssetServiceRequestFailures { get { return assetServiceRequestFailures; } } +// /// +// /// This is the time it took for the last asset request made in response to a cache miss. +// /// +// public TimeSpan AssetRequestTimeAfterCacheMiss { get { return assetRequestTimeAfterCacheMiss; } } +// +// /// +// /// Number of persistent requests for missing textures we have started blocking from clients. To some extent +// /// this is just a temporary statistic to keep this problem in view - the root cause of this lies either +// /// in a mishandling of the reply protocol, related to avatar appearance or may even originate in graphics +// /// driver bugs on clients (though this seems less likely). +// /// +// public long BlockedMissingTextureRequests { get { return blockedMissingTextureRequests; } } +// +// /// +// /// Record the number of times that an asset request has failed. Failures are effectively exceptions, such as +// /// request timeouts. If an asset service replies that a particular asset cannot be found, this is not counted +// /// as a failure +// /// +// public long AssetServiceRequestFailures { get { return assetServiceRequestFailures; } } /// /// Number of known failures to retrieve avatar inventory from the inventory service. This does not @@ -172,53 +172,53 @@ namespace OpenSim.Framework.Statistics abnormalClientThreadTerminations++; } - public void AddAsset(AssetBase asset) - { - assetsInCache++; - //assetCacheMemoryUsage += asset.Data.Length; - } - - public void RemoveAsset(UUID uuid) - { - assetsInCache--; - } - - public void AddTexture(AssetBase image) - { - if (image.Data != null) - { - texturesInCache++; - - // This could have been a pull stat, though there was originally a nebulous idea to measure flow rates - textureCacheMemoryUsage += image.Data.Length; - } - } - - /// - /// Signal that the asset cache has been cleared. - /// - public void ClearAssetCacheStatistics() - { - assetsInCache = 0; - assetCacheMemoryUsage = 0; - texturesInCache = 0; - textureCacheMemoryUsage = 0; - } - - public void AddAssetRequestTimeAfterCacheMiss(TimeSpan ts) - { - assetRequestTimeAfterCacheMiss = ts; - } - - public void AddBlockedMissingTextureRequest() - { - blockedMissingTextureRequests++; - } - - public void AddAssetServiceRequestFailure() - { - assetServiceRequestFailures++; - } +// public void AddAsset(AssetBase asset) +// { +// assetsInCache++; +// //assetCacheMemoryUsage += asset.Data.Length; +// } +// +// public void RemoveAsset(UUID uuid) +// { +// assetsInCache--; +// } +// +// public void AddTexture(AssetBase image) +// { +// if (image.Data != null) +// { +// texturesInCache++; +// +// // This could have been a pull stat, though there was originally a nebulous idea to measure flow rates +// textureCacheMemoryUsage += image.Data.Length; +// } +// } +// +// /// +// /// Signal that the asset cache has been cleared. +// /// +// public void ClearAssetCacheStatistics() +// { +// assetsInCache = 0; +// assetCacheMemoryUsage = 0; +// texturesInCache = 0; +// textureCacheMemoryUsage = 0; +// } +// +// public void AddAssetRequestTimeAfterCacheMiss(TimeSpan ts) +// { +// assetRequestTimeAfterCacheMiss = ts; +// } +// +// public void AddBlockedMissingTextureRequest() +// { +// blockedMissingTextureRequests++; +// } +// +// public void AddAssetServiceRequestFailure() +// { +// assetServiceRequestFailures++; +// } // public void AddInventoryServiceRetrievalFailure() // { @@ -291,8 +291,8 @@ namespace OpenSim.Framework.Statistics public override string Report() { StringBuilder sb = new StringBuilder(Environment.NewLine); - sb.Append("ASSET STATISTICS"); - sb.Append(Environment.NewLine); +// sb.Append("ASSET STATISTICS"); +// sb.Append(Environment.NewLine); /* sb.Append( @@ -308,7 +308,8 @@ Asset service request failures: {6}"+ Environment.NewLine, BlockedMissingTextureRequests, AssetServiceRequestFailures)); */ - + + /* sb.Append( string.Format( @"Asset cache contains {0,6} assets @@ -319,7 +320,7 @@ Asset service request failures: {3}" + Environment.NewLine, assetRequestTimeAfterCacheMiss.Milliseconds / 1000.0, BlockedMissingTextureRequests, AssetServiceRequestFailures)); - + */ sb.Append(Environment.NewLine); sb.Append("CONNECTION STATISTICS"); @@ -391,15 +392,15 @@ Asset service request failures: {3}" + Environment.NewLine, public override string XReport(string uptime, string version) { OSDMap args = new OSDMap(30); - args["AssetsInCache"] = OSD.FromString (String.Format ("{0:0.##}", AssetsInCache)); - args["TimeAfterCacheMiss"] = OSD.FromString (String.Format ("{0:0.##}", - assetRequestTimeAfterCacheMiss.Milliseconds / 1000.0)); - args["BlockedMissingTextureRequests"] = OSD.FromString (String.Format ("{0:0.##}", - BlockedMissingTextureRequests)); - args["AssetServiceRequestFailures"] = OSD.FromString (String.Format ("{0:0.##}", - AssetServiceRequestFailures)); - args["abnormalClientThreadTerminations"] = OSD.FromString (String.Format ("{0:0.##}", - abnormalClientThreadTerminations)); +// args["AssetsInCache"] = OSD.FromString (String.Format ("{0:0.##}", AssetsInCache)); +// args["TimeAfterCacheMiss"] = OSD.FromString (String.Format ("{0:0.##}", +// assetRequestTimeAfterCacheMiss.Milliseconds / 1000.0)); +// args["BlockedMissingTextureRequests"] = OSD.FromString (String.Format ("{0:0.##}", +// BlockedMissingTextureRequests)); +// args["AssetServiceRequestFailures"] = OSD.FromString (String.Format ("{0:0.##}", +// AssetServiceRequestFailures)); +// args["abnormalClientThreadTerminations"] = OSD.FromString (String.Format ("{0:0.##}", +// abnormalClientThreadTerminations)); // args["InventoryServiceRetrievalFailures"] = OSD.FromString (String.Format ("{0:0.##}", // InventoryServiceRetrievalFailures)); args["Dilatn"] = OSD.FromString (String.Format ("{0:0.##}", timeDilation)); -- cgit v1.1 From 2d0412d366c1c243cc3abfe753f21d59b4c55473 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 24 Jan 2012 22:35:55 +0000 Subject: Make errors reported by OpenSim when it halts because it can't find certain config sections or files a bit more user friendly. --- OpenSim/Region/Application/ConfigurationLoader.cs | 19 ++++++------------- OpenSim/Region/Application/OpenSimBase.cs | 6 +++--- OpenSim/Server/Base/ServicesServerBase.cs | 7 +++---- 3 files changed, 12 insertions(+), 20 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Application/ConfigurationLoader.cs b/OpenSim/Region/Application/ConfigurationLoader.cs index 4a7c8b0..8d95c41 100644 --- a/OpenSim/Region/Application/ConfigurationLoader.cs +++ b/OpenSim/Region/Application/ConfigurationLoader.cs @@ -107,15 +107,13 @@ namespace OpenSim } else { - m_log.ErrorFormat("Master ini file {0} not found", masterFilePath); + m_log.ErrorFormat("Master ini file {0} not found", Path.GetFullPath(masterFilePath)); Environment.Exit(1); } } } - - string iniFileName = - startupConfig.GetString("inifile", "OpenSim.ini"); + string iniFileName = startupConfig.GetString("inifile", "OpenSim.ini"); if (IsUri(iniFileName)) { @@ -131,8 +129,7 @@ namespace OpenSim if (!File.Exists(Application.iniFilePath)) { iniFileName = "OpenSim.xml"; - Application.iniFilePath = Path.GetFullPath( - Path.Combine(Util.configDir(), iniFileName)); + Application.iniFilePath = Path.GetFullPath(Path.Combine(Util.configDir(), iniFileName)); } if (File.Exists(Application.iniFilePath)) @@ -142,15 +139,12 @@ namespace OpenSim } } - string iniDirName = - startupConfig.GetString("inidirectory", "config"); - string iniDirPath = - Path.Combine(Util.configDir(), iniDirName); + string iniDirName = startupConfig.GetString("inidirectory", "config"); + string iniDirPath = Path.Combine(Util.configDir(), iniDirName); if (Directory.Exists(iniDirPath)) { - m_log.InfoFormat("Searching folder {0} for config ini files", - iniDirPath); + m_log.InfoFormat("Searching folder {0} for config ini files", iniDirPath); string[] fileEntries = Directory.GetFiles(iniDirName); foreach (string filePath in fileEntries) @@ -172,7 +166,6 @@ namespace OpenSim if (sources.Count == 0) { m_log.FatalFormat("[CONFIG]: Could not load any configuration"); - m_log.FatalFormat("[CONFIG]: Did you copy the OpenSimDefaults.ini.example file to OpenSimDefaults.ini?"); Environment.Exit(1); } diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs index 9f9b4f0..a680a59 100644 --- a/OpenSim/Region/Application/OpenSimBase.cs +++ b/OpenSim/Region/Application/OpenSimBase.cs @@ -202,16 +202,16 @@ namespace OpenSim // Load the simulation data service IConfig simDataConfig = m_config.Source.Configs["SimulationDataStore"]; if (simDataConfig == null) - throw new Exception("Configuration file is missing the [SimulationDataStore] section"); + throw new Exception("Configuration file is missing the [SimulationDataStore] section. Have you copied OpenSim.ini.example to OpenSim.ini to reference config-include/ files?"); string module = simDataConfig.GetString("LocalServiceModule", String.Empty); if (String.IsNullOrEmpty(module)) - throw new Exception("Configuration file is missing the LocalServiceModule parameter in the [SimulationDataStore] section"); + throw new Exception("Configuration file is missing the LocalServiceModule parameter in the [SimulationDataStore] section."); m_simulationDataService = ServerUtils.LoadPlugin(module, new object[] { m_config.Source }); // Load the estate data service IConfig estateDataConfig = m_config.Source.Configs["EstateDataStore"]; if (estateDataConfig == null) - throw new Exception("Configuration file is missing the [EstateDataStore] section"); + throw new Exception("Configuration file is missing the [EstateDataStore] section. Have you copied OpenSim.ini.example to OpenSim.ini to reference config-include/ files?"); module = estateDataConfig.GetString("LocalServiceModule", String.Empty); if (String.IsNullOrEmpty(module)) throw new Exception("Configuration file is missing the LocalServiceModule parameter in the [EstateDataStore] section"); diff --git a/OpenSim/Server/Base/ServicesServerBase.cs b/OpenSim/Server/Base/ServicesServerBase.cs index aeba35f..a6f4e47 100644 --- a/OpenSim/Server/Base/ServicesServerBase.cs +++ b/OpenSim/Server/Base/ServicesServerBase.cs @@ -126,11 +126,10 @@ namespace OpenSim.Server.Base m_Config = new IniConfigSource(iniFile); } } - catch (Exception) + catch (Exception e) { - System.Console.WriteLine("Error reading from config source {0}", - iniFile); - Thread.CurrentThread.Abort(); + System.Console.WriteLine("Error reading from config source. {0}", e.Message); + Environment.Exit(1); } // Merge the configuration from the command line into the -- cgit v1.1 From 3d1f43046dd4d33c54e31ab103cd0866c8f417ac Mon Sep 17 00:00:00 2001 From: Dan Lake Date: Tue, 24 Jan 2012 17:05:53 -0800 Subject: Removed unused delegates in SceneGraph: ObjectDuplicateDelegate, ObjectCreateDelegate, ObjectDeleteDelegate --- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 6 ------ 1 file changed, 6 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 1af8346..7f18140 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -41,12 +41,6 @@ namespace OpenSim.Region.Framework.Scenes { public delegate void PhysicsCrash(); - public delegate void ObjectDuplicateDelegate(EntityBase original, EntityBase clone); - - public delegate void ObjectCreateDelegate(EntityBase obj); - - public delegate void ObjectDeleteDelegate(EntityBase obj); - /// /// This class used to be called InnerScene and may not yet truly be a SceneGraph. The non scene graph components /// should be migrated out over time. -- cgit v1.1 From 7c514fe155d6e0546f43c978804abadf11076777 Mon Sep 17 00:00:00 2001 From: BlueWall Date: Tue, 24 Jan 2012 21:33:11 -0500 Subject: Telehub map items displayed --- .../CoreModules/World/WorldMap/WorldMapModule.cs | 54 ++++++++++++++++++++-- 1 file changed, 51 insertions(+), 3 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs index 2f723ef..81b433f 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs @@ -373,7 +373,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap public virtual void HandleMapItemRequest(IClientAPI remoteClient, uint flags, uint EstateID, bool godlike, uint itemtype, ulong regionhandle) { -// m_log.DebugFormat("[WORLD MAP]: Handle MapItem request {0} {1}", regionhandle, itemtype); + m_log.DebugFormat("[WORLD MAP]: Handle MapItem request {0} {1}", regionhandle, itemtype); lock (m_rootAgents) { @@ -429,7 +429,8 @@ namespace OpenSim.Region.CoreModules.World.WorldMap // ensures that the blockingqueue doesn't get borked if the GetAgents() timing changes. RequestMapItems("",remoteClient.AgentId,flags,EstateID,godlike,itemtype,regionhandle); } - } else if (itemtype == 7) // Service 7 (MAP_ITEM_LAND_FOR_SALE) + } + else if (itemtype == 7) // Service 7 (MAP_ITEM_LAND_FOR_SALE) { if (regionhandle == 0 || regionhandle == m_scene.RegionInfo.RegionHandle) { @@ -481,6 +482,32 @@ namespace OpenSim.Region.CoreModules.World.WorldMap RequestMapItems("",remoteClient.AgentId,flags,EstateID,godlike,itemtype,regionhandle); } } + else if (itemtype == 1) // Service 1 (MAP_ITEM_TELEHUB) + { + if (regionhandle == 0 || regionhandle == m_scene.RegionInfo.RegionHandle) + { + List mapitems = new List(); + mapItemReply mapitem = new mapItemReply(); + + SceneObjectPart sop = m_scene.GetSceneObjectPart(m_scene.RegionInfo.RegionSettings.TelehubObject); + + mapitem = new mapItemReply(); + mapitem.x = (uint)(xstart + sop.AbsolutePosition.X); + mapitem.y = (uint)(ystart + sop.AbsolutePosition.Y); + mapitem.id = UUID.Zero; + mapitem.name = sop.Name; + mapitem.Extra = 0; // color (not used) + mapitem.Extra2 = 0; // 0 = telehub / 1 = infohub + mapitems.Add(mapitem); + + remoteClient.SendMapItemReply(mapitems.ToArray(), itemtype, flags); + } + else + { + // Remote Map Item Request + RequestMapItems("",remoteClient.AgentId,flags,EstateID,godlike,itemtype,regionhandle); + } + } } private int nAsyncRequests = 0; @@ -620,6 +647,28 @@ namespace OpenSim.Region.CoreModules.World.WorldMap } av.ControllingClient.SendMapItemReply(returnitems.ToArray(), itemtype, mrs.flags); } + + // Service 1 (MAP_ITEM_TELEHUB) + itemtype = 1; + + if (response.ContainsKey(itemtype.ToString())) + { + List returnitems = new List(); + OSDArray itemarray = (OSDArray)response[itemtype.ToString()]; + for (int i = 0; i < itemarray.Count; i++) + { + OSDMap mapitem = (OSDMap)itemarray[i]; + mapItemReply mi = new mapItemReply(); + mi.x = (uint)mapitem["X"].AsInteger(); + mi.y = (uint)mapitem["Y"].AsInteger(); + mi.id = mapitem["ID"].AsUUID(); + mi.Extra = mapitem["Extra"].AsInteger(); + mi.Extra2 = mapitem["Extra2"].AsInteger(); + mi.name = mapitem["Name"].AsString(); + returnitems.Add(mi); + } + av.ControllingClient.SendMapItemReply(returnitems.ToArray(), itemtype, mrs.flags); + } } } } @@ -1258,7 +1307,6 @@ namespace OpenSim.Region.CoreModules.World.WorldMap OSDMap responsemapdata = new OSDMap(); responsemapdata["X"] = OSD.FromInteger((int)(xstart + sop.AbsolutePosition.X)); responsemapdata["Y"] = OSD.FromInteger((int)(ystart + sop.AbsolutePosition.Y)); - // responsemapdata["Z"] = OSD.FromInteger((int)m_scene.GetGroundHeight(x,y)); responsemapdata["ID"] = OSD.FromUUID(sop.UUID); responsemapdata["Name"] = OSD.FromString(sop.Name); responsemapdata["Extra"] = OSD.FromInteger(0); // color (unused) -- cgit v1.1 From f84b69cad11fefa5f6615ed97170b8c12de2f3b4 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 25 Jan 2012 15:00:06 +0000 Subject: Change the WorldMapModule to use SOG rather than SOP for the telehub ans cover a potential nullref --- .../CoreModules/World/WorldMap/WorldMapModule.cs | 28 ++++++++++++---------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs index 2f723ef..af9c650 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs @@ -1252,20 +1252,22 @@ namespace OpenSim.Region.CoreModules.World.WorldMap if (m_scene.RegionInfo.RegionSettings.TelehubObject != UUID.Zero) { - SceneObjectPart sop = m_scene.GetSceneObjectPart(m_scene.RegionInfo.RegionSettings.TelehubObject); - - OSDArray responsearr = new OSDArray(); - OSDMap responsemapdata = new OSDMap(); - responsemapdata["X"] = OSD.FromInteger((int)(xstart + sop.AbsolutePosition.X)); - responsemapdata["Y"] = OSD.FromInteger((int)(ystart + sop.AbsolutePosition.Y)); - // responsemapdata["Z"] = OSD.FromInteger((int)m_scene.GetGroundHeight(x,y)); - responsemapdata["ID"] = OSD.FromUUID(sop.UUID); - responsemapdata["Name"] = OSD.FromString(sop.Name); - responsemapdata["Extra"] = OSD.FromInteger(0); // color (unused) - responsemapdata["Extra2"] = OSD.FromInteger(0); // 0 = telehub / 1 = infohub - responsearr.Add(responsemapdata); + SceneObjectGroup sog = m_scene.GetSceneObjectGroup(m_scene.RegionInfo.RegionSettings.TelehubObject); + if (sog != null) + { + OSDArray responsearr = new OSDArray(); + OSDMap responsemapdata = new OSDMap(); + responsemapdata["X"] = OSD.FromInteger((int)(xstart + sog.AbsolutePosition.X)); + responsemapdata["Y"] = OSD.FromInteger((int)(ystart + sog.AbsolutePosition.Y)); + // responsemapdata["Z"] = OSD.FromInteger((int)m_scene.GetGroundHeight(x,y)); + responsemapdata["ID"] = OSD.FromUUID(sog.UUID); + responsemapdata["Name"] = OSD.FromString(sog.Name); + responsemapdata["Extra"] = OSD.FromInteger(0); // color (unused) + responsemapdata["Extra2"] = OSD.FromInteger(0); // 0 = telehub / 1 = infohub + responsearr.Add(responsemapdata); - responsemap["1"] = responsearr; + responsemap["1"] = responsearr; + } } return responsemap; -- cgit v1.1 From e20cf3789bc8bbcda86c8e9067fbe8ecdb3046ac Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 25 Jan 2012 19:31:50 +0000 Subject: Serialize calls to ODE Collide() function across OdeScene instances to prevent ODE crashes on simulators running more than one region. It turns out that calls to Collide() are not thread-safe even for objects in different ODE physics worlds due to ODE static caches. For simulators running multiple regions, not serializing calls from different scene loops will sooner or later cause OpenSim to crash with a native stack trace referencing OBBCollider. This affects the default OPCODE collider but not GIMPACT. However, GIMPACT fails for other reasons under some current simulator loads. ODE provides a thread local storage option, but as of ODE r1755 (and r1840) DLLs compiled with this crash OpenSim immediately. --- OpenSim/Region/Physics/OdePlugin/ODECharacter.cs | 3 +++ OpenSim/Region/Physics/OdePlugin/OdeScene.cs | 30 +++++++++++++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs index c6e8286..7c1c046 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs @@ -1048,6 +1048,7 @@ namespace OpenSim.Region.Physics.OdePlugin CAPSULE_RADIUS = 0.01f; } +// lock (OdeScene.UniversalColliderSyncObject) Shell = d.CreateCapsule(_parent_scene.space, CAPSULE_RADIUS, CAPSULE_LENGTH); d.GeomSetCategoryBits(Shell, (int)m_collisionCategories); @@ -1179,7 +1180,9 @@ namespace OpenSim.Region.Physics.OdePlugin if (Shell != IntPtr.Zero) { +// lock (OdeScene.UniversalColliderSyncObject) d.GeomDestroy(Shell); + _parent_scene.geom_name_map.Remove(Shell); _parent_scene.actor_name_map.Remove(Shell); diff --git a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs index 37daf46..4530c09 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs +++ b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs @@ -105,6 +105,32 @@ namespace OpenSim.Region.Physics.OdePlugin private readonly ILog m_log; // private Dictionary m_storedCollisions = new Dictionary(); + /// + /// Provide a sync object so that only one thread calls d.Collide() at a time across all OdeScene instances. + /// + /// + /// With ODE as of r1755 (though also tested on r1860), only one thread can call d.Collide() at a + /// time, even where physics objects are in entirely different ODE worlds. This is because generating contacts + /// uses a static cache at the ODE level. + /// + /// Without locking, simulators running multiple regions will eventually crash with a native stack trace similar + /// to + /// + /// mono() [0x489171] + /// mono() [0x4d154f] + /// /lib/x86_64-linux-gnu/libpthread.so.0(+0xfc60) [0x7f6ded592c60] + /// .../opensim/bin/libode-x86_64.so(_ZN6Opcode11OBBCollider8_CollideEPKNS_14AABBNoLeafNodeE+0xd7a) [0x7f6dd822628a] + /// + /// ODE provides an experimental option to cache in thread local storage but compiling ODE with this option + /// causes OpenSimulator to immediately crash with a native stack trace similar to + /// + /// mono() [0x489171] + /// mono() [0x4d154f] + /// /lib/x86_64-linux-gnu/libpthread.so.0(+0xfc60) [0x7f03c9849c60] + /// .../opensim/bin/libode-x86_64.so(_Z12dCollideCCTLP6dxGeomS0_iP12dContactGeomi+0x92) [0x7f03b44bcf82] + /// + internal static Object UniversalColliderSyncObject = new Object(); + private Random fluidRandomizer = new Random(Environment.TickCount); private const uint m_regionWidth = Constants.RegionSize; @@ -799,7 +825,9 @@ namespace OpenSim.Region.Physics.OdePlugin if (b1 != IntPtr.Zero && b2 != IntPtr.Zero && d.AreConnectedExcluding(b1, b2, d.JointType.Contact)) return; - count = d.Collide(g1, g2, contacts.Length, contacts, d.ContactGeom.SizeOf); + lock (OdeScene.UniversalColliderSyncObject) + count = d.Collide(g1, g2, contacts.Length, contacts, d.ContactGeom.SizeOf); + if (count > contacts.Length) m_log.Error("[ODE SCENE]: Got " + count + " contacts when we asked for a maximum of " + contacts.Length); } -- cgit v1.1 From 82c3d0cf89427b2ed3be892b7b9af3ee06d65e52 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 25 Jan 2012 20:36:51 +0000 Subject: minor: stop the WebStatsModule logging UPDATE or INSERT every time it updates bin/LocalUserStatistics.db --- OpenSim/Region/UserStatistics/WebStatsModule.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/UserStatistics/WebStatsModule.cs b/OpenSim/Region/UserStatistics/WebStatsModule.cs index fca9fd0..24a9418 100644 --- a/OpenSim/Region/UserStatistics/WebStatsModule.cs +++ b/OpenSim/Region/UserStatistics/WebStatsModule.cs @@ -442,7 +442,7 @@ namespace OpenSim.Region.UserStatistics public string ViewerStatsReport(string request, string path, string param, UUID agentID, Caps caps) { - //m_log.Debug(request); +// m_log.DebugFormat("[WEB STATS MODULE]: Received viewer starts report from {0}", agentID); UpdateUserStats(ParseViewerStats(request,agentID), dbConn); @@ -655,13 +655,13 @@ namespace OpenSim.Region.UserStatistics updatecmd.Parameters.Add(new SqliteParameter(":session_key", uid.session_data.session_id.ToString())); updatecmd.Parameters.Add(new SqliteParameter(":agent_key", uid.session_data.agent_id.ToString())); updatecmd.Parameters.Add(new SqliteParameter(":region_key", uid.session_data.region_id.ToString())); - m_log.Debug("UPDATE"); +// m_log.Debug("UPDATE"); int result = updatecmd.ExecuteNonQuery(); if (result == 0) { - m_log.Debug("INSERT"); +// m_log.Debug("INSERT"); updatecmd.CommandText = SQL_STATS_TABLE_INSERT; try { -- cgit v1.1 From 8f53c768f53478ff3e0c27198b257bb27be16259 Mon Sep 17 00:00:00 2001 From: Pixel Tomsen Date: Wed, 25 Jan 2012 21:31:18 +0100 Subject: llGetParcelMusicURL implementation http://wiki.secondlife.com/wiki/LlGetParcelMusicURL Signed-off-by: BlueWall --- OpenSim/Framework/ILandObject.cs | 6 ++++++ OpenSim/Region/CoreModules/World/Land/LandObject.cs | 11 ++++++++++- .../Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 12 ++++++++++++ OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs | 1 + OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs | 5 +++++ 5 files changed, 34 insertions(+), 1 deletion(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/ILandObject.cs b/OpenSim/Framework/ILandObject.cs index 0316944..f75a990 100644 --- a/OpenSim/Framework/ILandObject.cs +++ b/OpenSim/Framework/ILandObject.cs @@ -130,5 +130,11 @@ namespace OpenSim.Framework /// /// void SetMusicUrl(string url); + + /// + /// Get the music url for this land parcel + /// + /// The music url. + string GetMusicUrl(); } } diff --git a/OpenSim/Region/CoreModules/World/Land/LandObject.cs b/OpenSim/Region/CoreModules/World/Land/LandObject.cs index 0da0de3..79b13c3 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandObject.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandObject.cs @@ -1094,7 +1094,16 @@ namespace OpenSim.Region.CoreModules.World.Land LandData.MusicURL = url; SendLandUpdateToAvatarsOverMe(); } - + + /// + /// Get the music url for this land parcel + /// + /// The music url. + public string GetMusicUrl() + { + return LandData.MusicURL; + } + #endregion } } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index fb930e0..330c65d 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -7566,6 +7566,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api ScriptSleep(2000); } + public LSL_String llGetParcelMusicURL() + { + m_host.AddScriptLPS(1); + + ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y); + + if (land.LandData.OwnerID != m_host.OwnerID) + return String.Empty; + + return land.GetMusicUrl(); + } + public LSL_Vector llGetRootPosition() { m_host.AddScriptLPS(1); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs index 62e2854..282443b 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs @@ -161,6 +161,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces LSL_List llGetParcelDetails(LSL_Vector pos, LSL_List param); LSL_Integer llGetParcelFlags(LSL_Vector pos); LSL_Integer llGetParcelMaxPrims(LSL_Vector pos, int sim_wide); + LSL_String llGetParcelMusicURL(); LSL_Integer llGetParcelPrimCount(LSL_Vector pos, int category, int sim_wide); LSL_List llGetParcelPrimOwners(LSL_Vector pos); LSL_Integer llGetPermissions(); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs index 508f33b..9733683 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs @@ -649,6 +649,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase return m_LSL_Functions.llGetParcelMaxPrims(pos, sim_wide); } + public LSL_String llGetParcelMusicURL() + { + return m_LSL_Functions.llGetParcelMusicURL(); + } + public LSL_Integer llGetParcelPrimCount(LSL_Vector pos, int category, int sim_wide) { return m_LSL_Functions.llGetParcelPrimCount(pos, category, sim_wide); -- cgit v1.1 From e9de7e7107f4a52a944a06e20db0f29d0d6d37d3 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Wed, 25 Jan 2012 14:40:38 -0800 Subject: Update BulletSim.dll with some interface changes and tuning (see opensim-libs). Change BSScene to use new interface. --- OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | 33 ++++++++++++++++++---- .../Region/Physics/BulletSPlugin/BulletSimAPI.cs | 4 +++ 2 files changed, 31 insertions(+), 6 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs index 7704002..e9a849c 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs @@ -72,6 +72,8 @@ public class BSScene : PhysicsScene, IPhysicsParameters private bool m_initialized = false; + private int m_detailedStatsStep = 0; + public IMesher mesher; private float m_meshLOD; public float MeshLOD @@ -192,6 +194,8 @@ public class BSScene : PhysicsScene, IPhysicsParameters m_meshLOD = 8f; m_sculptLOD = 32f; + m_detailedStatsStep = 0; // disabled + m_maxSubSteps = 10; m_fixedTimeStep = 1f / 60f; m_maxCollisionsPerFrame = 2048; @@ -209,8 +213,9 @@ public class BSScene : PhysicsScene, IPhysicsParameters parms.deactivationTime = 0.2f; parms.linearSleepingThreshold = 0.8f; parms.angularSleepingThreshold = 1.0f; - parms.ccdMotionThreshold = 0.5f; // set to zero to disable - parms.ccdSweptSphereRadius = 0.2f; + parms.ccdMotionThreshold = 0.0f; // set to zero to disable + parms.ccdSweptSphereRadius = 0.0f; + parms.contactProcessingThreshold = 0.1f; parms.terrainFriction = 0.5f; parms.terrainHitFraction = 0.8f; @@ -231,6 +236,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters _meshSculptedPrim = pConfig.GetBoolean("MeshSculptedPrim", _meshSculptedPrim); _forceSimplePrimMeshing = pConfig.GetBoolean("ForceSimplePrimMeshing", _forceSimplePrimMeshing); + m_detailedStatsStep = pConfig.GetInt("DetailedStatsStep", m_detailedStatsStep); m_meshLOD = pConfig.GetFloat("MeshLevelOfDetail", m_meshLOD); m_sculptLOD = pConfig.GetFloat("SculptLevelOfDetail", m_sculptLOD); @@ -253,6 +259,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters parms.angularSleepingThreshold = pConfig.GetFloat("AngularSleepingThreshold", parms.angularSleepingThreshold); parms.ccdMotionThreshold = pConfig.GetFloat("CcdMotionThreshold", parms.ccdMotionThreshold); parms.ccdSweptSphereRadius = pConfig.GetFloat("CcdSweptSphereRadius", parms.ccdSweptSphereRadius); + parms.contactProcessingThreshold = pConfig.GetFloat("ContactProcessingThreshold", parms.contactProcessingThreshold); parms.terrainFriction = pConfig.GetFloat("TerrainFriction", parms.terrainFriction); parms.terrainHitFraction = pConfig.GetFloat("TerrainHitFraction", parms.terrainHitFraction); @@ -398,6 +405,14 @@ public class BSScene : PhysicsScene, IPhysicsParameters } } + if (m_detailedStatsStep > 0) + { + if ((m_simulationStep % m_detailedStatsStep) == 0) + { + BulletSimAPI.DumpBulletStatistics(); + } + } + // TODO: FIX THIS: fps calculation wrong. This calculation always returns about 1 in normal operation. return timeStep / (numSubSteps * m_fixedTimeStep) * 1000f; } @@ -671,6 +686,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters new PhysParameterEntry("MaxSubStep", "In simulation step, maximum number of substeps"), new PhysParameterEntry("FixedTimeStep", "In simulation step, seconds of one substep (1/60)"), new PhysParameterEntry("MaxObjectMass", "Maximum object mass (10000.01)"), + new PhysParameterEntry("DetailedStats", "Frames between outputting detailed phys stats. Zero is off"), new PhysParameterEntry("DefaultFriction", "Friction factor used on new objects"), new PhysParameterEntry("DefaultDensity", "Density for new objects" ), @@ -685,6 +701,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters new PhysParameterEntry("AngularSleepingThreshold", "Seconds to measure angular movement before considering static" ), // new PhysParameterEntry("CcdMotionThreshold", "" ), // new PhysParameterEntry("CcdSweptSphereRadius", "" ), + new PhysParameterEntry("ContactProcessingThreshold", "Distance between contacts before doing collision check" ), new PhysParameterEntry("TerrainFriction", "Factor to reduce movement against terrain surface" ), new PhysParameterEntry("TerrainHitFraction", "Distance to measure hit collisions" ), @@ -715,6 +732,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters string lparm = parm.ToLower(); switch (lparm) { + case "detailedstats": m_detailedStatsStep = (int)val; break; case "meshlod": m_meshLOD = (int)val; break; case "sculptlod": m_sculptLOD = (int)val; break; case "maxsubstep": m_maxSubSteps = (int)val; break; @@ -725,7 +743,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters case "defaultdensity": m_params[0].defaultDensity = val; break; case "defaultrestitution": m_params[0].defaultRestitution = val; break; case "collisionmargin": m_params[0].collisionMargin = val; break; - case "gravity": m_params[0].gravity = val; TaintedUpdateParameter(lparm, PhysParameterEntry.APPLY_TO_NONE, val); break; + case "gravity": m_params[0].gravity = val; TaintedUpdateParameter(lparm, PhysParameterEntry.APPLY_TO_NONE, val); break; case "lineardamping": UpdateParameterPrims(ref m_params[0].linearDamping, lparm, localID, val); break; case "angulardamping": UpdateParameterPrims(ref m_params[0].angularDamping, lparm, localID, val); break; @@ -734,6 +752,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters case "angularsleepingthreshold": UpdateParameterPrims(ref m_params[0].angularDamping, lparm, localID, val); break; case "ccdmotionthreshold": UpdateParameterPrims(ref m_params[0].ccdMotionThreshold, lparm, localID, val); break; case "ccdsweptsphereradius": UpdateParameterPrims(ref m_params[0].ccdSweptSphereRadius, lparm, localID, val); break; + case "contactprocessingthreshold": UpdateParameterPrims(ref m_params[0].contactProcessingThreshold, lparm, localID, val); break; // set a terrain physical feature and cause terrain to be recalculated case "terrainfriction": m_params[0].terrainFriction = val; TaintedUpdateParameter("terrain", 0, val); break; @@ -741,10 +760,10 @@ public class BSScene : PhysicsScene, IPhysicsParameters case "terrainrestitution": m_params[0].terrainRestitution = val; TaintedUpdateParameter("terrain", 0, val); break; // set an avatar physical feature and cause avatar(s) to be recalculated case "avatarfriction": UpdateParameterAvatars(ref m_params[0].avatarFriction, "avatar", localID, val); break; - case "avatardensity": UpdateParameterAvatars(ref m_params[0].avatarDensity, "avatar", localID, val); break; + case "avatardensity": UpdateParameterAvatars(ref m_params[0].avatarDensity, "avatar", localID, val); break; case "avatarrestitution": UpdateParameterAvatars(ref m_params[0].avatarRestitution, "avatar", localID, val); break; - case "avatarcapsuleradius": UpdateParameterAvatars(ref m_params[0].avatarCapsuleRadius, "avatar", localID, val); break; - case "avatarcapsuleheight": UpdateParameterAvatars(ref m_params[0].avatarCapsuleHeight, "avatar", localID, val); break; + case "avatarcapsuleradius": UpdateParameterAvatars(ref m_params[0].avatarCapsuleRadius, "avatar", localID, val); break; + case "avatarcapsuleheight": UpdateParameterAvatars(ref m_params[0].avatarCapsuleHeight, "avatar", localID, val); break; default: ret = false; break; } @@ -816,6 +835,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters bool ret = true; switch (parm.ToLower()) { + case "detailedstats": val = (int)m_detailedStatsStep; break; case "meshlod": val = (float)m_meshLOD; break; case "sculptlod": val = (float)m_sculptLOD; break; case "maxsubstep": val = (float)m_maxSubSteps; break; @@ -835,6 +855,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters case "angularsleepingthreshold": val = m_params[0].angularDamping; break; case "ccdmotionthreshold": val = m_params[0].ccdMotionThreshold; break; case "ccdsweptsphereradius": val = m_params[0].ccdSweptSphereRadius; break; + case "contactprocessingthreshold": val = m_params[0].contactProcessingThreshold; break; case "terrainfriction": val = m_params[0].terrainFriction; break; case "terrainhitfraction": val = m_params[0].terrainHitFraction; break; diff --git a/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs b/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs index a610c8d..d12bd7d 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs @@ -122,6 +122,7 @@ public struct ConfigurationParameters public float angularSleepingThreshold; public float ccdMotionThreshold; public float ccdSweptSphereRadius; + public float contactProcessingThreshold; public float terrainFriction; public float terrainHitFraction; @@ -248,6 +249,9 @@ public static extern RaycastHit RayTest(uint worldID, uint id, Vector3 from, Vec [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] public static extern Vector3 RecoverFromPenetration(uint worldID, uint id); +[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] +public static extern void DumpBulletStatistics(); + // Log a debug message [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate void DebugLogCallback([MarshalAs(UnmanagedType.LPStr)]string msg); -- cgit v1.1 From d0536256635008bdeb1a5ded1b06c5f84f02975e Mon Sep 17 00:00:00 2001 From: nebadon Date: Wed, 25 Jan 2012 15:59:07 -0700 Subject: Update save oar and save iar help responses to reflect new -h|--home switches which replace -p|--profile ie: "save oar --home=http://hg.osgrid.org:80 region.oar" --- OpenSim/Region/Application/OpenSim.cs | 4 ++-- .../CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs index 832d93c..8683476 100644 --- a/OpenSim/Region/Application/OpenSim.cs +++ b/OpenSim/Region/Application/OpenSim.cs @@ -291,10 +291,10 @@ namespace OpenSim m_console.Commands.AddCommand("region", false, "save oar", //"save oar [-v|--version=] [-p|--profile=] []", - "save oar [-p|--profile=] [--noassets] [--perm=] []", + "save oar [-h|--home=] [--noassets] [--perm=] []", "Save a region's data to an OAR archive.", // "-v|--version= generates scene objects as per older versions of the serialization (e.g. -v=0)" + Environment.NewLine - "-p|--profile= adds the url of the profile service to the saved user information." + Environment.NewLine + "-h|--home= adds the url of the profile service to the saved user information." + Environment.NewLine + "--noassets stops assets being saved to the OAR." + Environment.NewLine + "--perm stops objects with insufficient permissions from being saved to the OAR." + Environment.NewLine + " can contain one or more of these characters: \"C\" = Copy, \"T\" = Transfer" + Environment.NewLine diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs index e0b02aa..150d913 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs @@ -122,12 +122,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver scene.AddCommand( this, "save iar", - "save iar [--p|-profile=] [--noassets] [] [--v|-verbose]", + "save iar [-h|--home=] [--noassets] [] [--v|-verbose]", "Save user inventory archive (IAR).", " is the user's first name." + Environment.NewLine + " is the user's last name." + Environment.NewLine + " is the path inside the user's inventory for the folder/item to be saved." + Environment.NewLine - + "-p|--profile= adds the url of the profile service to the saved user information." + Environment.NewLine + + "-h|--home= adds the url of the profile service to the saved user information." + Environment.NewLine + "-c|--creators preserves information about foreign creators." + Environment.NewLine + "-v|--verbose extra debug messages." + Environment.NewLine + "--noassets stops assets being saved to the IAR." -- cgit v1.1 From 2de3a1b9dad25855cb18a29f2c43ad67cfb0730c Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 25 Jan 2012 23:22:07 +0000 Subject: refactor: decompose most of RezScript() into RezScriptFromAgentInventory(), RezNewScript() and rename one RezScript() to RezScriptFromPrim() --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 174 +++++++++++---------- .../Shared/Api/Implementation/LSL_Api.cs | 3 +- 2 files changed, 97 insertions(+), 80 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 2444367..f4f37ac 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -1560,104 +1560,120 @@ namespace OpenSim.Region.Framework.Scenes /// Rez a script into a prim's inventory, either ex nihilo or from an existing avatar inventory /// /// - /// + /// + /// /// public void RezScript(IClientAPI remoteClient, InventoryItemBase itemBase, UUID transactionID, uint localID) { - UUID itemID = itemBase.ID; + if (itemBase.ID != UUID.Zero) + RezScriptFromAgentInventory(remoteClient, itemBase.ID, localID); + else + RezNewScript(remoteClient, itemBase); + } + + /// + /// Rez a script into a prim from an agent inventory. + /// + /// + /// + /// + public void RezScriptFromAgentInventory(IClientAPI remoteClient, UUID fromItemID, uint localID) + { UUID copyID = UUID.Random(); + InventoryItemBase item = new InventoryItemBase(fromItemID, remoteClient.AgentId); + item = InventoryService.GetItem(item); - if (itemID != UUID.Zero) // transferred from an avatar inventory to the prim's inventory + // Try library + // XXX clumsy, possibly should be one call + if (null == item && LibraryService != null && LibraryService.LibraryRootFolder != null) { - InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); - item = InventoryService.GetItem(item); - - // Try library - // XXX clumsy, possibly should be one call - if (null == item && LibraryService != null && LibraryService.LibraryRootFolder != null) - { - item = LibraryService.LibraryRootFolder.FindItem(itemID); - } + item = LibraryService.LibraryRootFolder.FindItem(fromItemID); + } - if (item != null) + if (item != null) + { + SceneObjectPart part = GetSceneObjectPart(localID); + if (part != null) { - SceneObjectPart part = GetSceneObjectPart(localID); - if (part != null) - { - if (!Permissions.CanEditObjectInventory(part.UUID, remoteClient.AgentId)) - return; + if (!Permissions.CanEditObjectInventory(part.UUID, remoteClient.AgentId)) + return; - part.ParentGroup.AddInventoryItem(remoteClient, localID, item, copyID); - // TODO: switch to posting on_rez here when scripts - // have state in inventory - part.Inventory.CreateScriptInstance(copyID, 0, false, DefaultScriptEngine, 0); + part.ParentGroup.AddInventoryItem(remoteClient, localID, item, copyID); + // TODO: switch to posting on_rez here when scripts + // have state in inventory + part.Inventory.CreateScriptInstance(copyID, 0, false, DefaultScriptEngine, 0); - // m_log.InfoFormat("[PRIMINVENTORY]: " + - // "Rezzed script {0} into prim local ID {1} for user {2}", - // item.inventoryName, localID, remoteClient.Name); - part.SendPropertiesToClient(remoteClient); - part.ParentGroup.ResumeScripts(); - } - else - { - m_log.ErrorFormat( - "[PRIM INVENTORY]: " + - "Could not rez script {0} into prim local ID {1} for user {2}" - + " because the prim could not be found in the region!", - item.Name, localID, remoteClient.Name); - } + // m_log.InfoFormat("[PRIMINVENTORY]: " + + // "Rezzed script {0} into prim local ID {1} for user {2}", + // item.inventoryName, localID, remoteClient.Name); + part.SendPropertiesToClient(remoteClient); + part.ParentGroup.ResumeScripts(); } else { m_log.ErrorFormat( - "[PRIM INVENTORY]: Could not find script inventory item {0} to rez for {1}!", - itemID, remoteClient.Name); + "[PRIM INVENTORY]: " + + "Could not rez script {0} into prim local ID {1} for user {2}" + + " because the prim could not be found in the region!", + item.Name, localID, remoteClient.Name); } } - else // script has been rezzed directly into a prim's inventory + else { - SceneObjectPart part = GetSceneObjectPart(itemBase.Folder); - if (part == null) - return; + m_log.ErrorFormat( + "[PRIM INVENTORY]: Could not find script inventory item {0} to rez for {1}!", + fromItemID, remoteClient.Name); + } + } - if (!Permissions.CanCreateObjectInventory( - itemBase.InvType, part.UUID, remoteClient.AgentId)) - return; + /// + /// Rez a new script from nothing. + /// + /// + /// + public void RezNewScript(IClientAPI remoteClient, InventoryItemBase itemBase) + { + SceneObjectPart part = GetSceneObjectPart(itemBase.Folder); + if (part == null) + return; - AssetBase asset = CreateAsset(itemBase.Name, itemBase.Description, (sbyte)itemBase.AssetType, - Encoding.ASCII.GetBytes("default\n{\n state_entry()\n {\n llSay(0, \"Script running\");\n }\n}"), - remoteClient.AgentId); - AssetService.Store(asset); - - TaskInventoryItem taskItem = new TaskInventoryItem(); - - taskItem.ResetIDs(itemBase.Folder); - taskItem.ParentID = itemBase.Folder; - taskItem.CreationDate = (uint)itemBase.CreationDate; - taskItem.Name = itemBase.Name; - taskItem.Description = itemBase.Description; - taskItem.Type = itemBase.AssetType; - taskItem.InvType = itemBase.InvType; - taskItem.OwnerID = itemBase.Owner; - taskItem.CreatorID = itemBase.CreatorIdAsUuid; - taskItem.BasePermissions = itemBase.BasePermissions; - taskItem.CurrentPermissions = itemBase.CurrentPermissions; - taskItem.EveryonePermissions = itemBase.EveryOnePermissions; - taskItem.GroupPermissions = itemBase.GroupPermissions; - taskItem.NextPermissions = itemBase.NextPermissions; - taskItem.GroupID = itemBase.GroupID; - taskItem.GroupPermissions = 0; - taskItem.Flags = itemBase.Flags; - taskItem.PermsGranter = UUID.Zero; - taskItem.PermsMask = 0; - taskItem.AssetID = asset.FullID; - - part.Inventory.AddInventoryItem(taskItem, false); - part.SendPropertiesToClient(remoteClient); + if (!Permissions.CanCreateObjectInventory( + itemBase.InvType, part.UUID, remoteClient.AgentId)) + return; - part.Inventory.CreateScriptInstance(taskItem, 0, false, DefaultScriptEngine, 0); - part.ParentGroup.ResumeScripts(); - } + AssetBase asset = CreateAsset(itemBase.Name, itemBase.Description, (sbyte)itemBase.AssetType, + Encoding.ASCII.GetBytes("default\n{\n state_entry()\n {\n llSay(0, \"Script running\");\n }\n}"), + remoteClient.AgentId); + AssetService.Store(asset); + + TaskInventoryItem taskItem = new TaskInventoryItem(); + + taskItem.ResetIDs(itemBase.Folder); + taskItem.ParentID = itemBase.Folder; + taskItem.CreationDate = (uint)itemBase.CreationDate; + taskItem.Name = itemBase.Name; + taskItem.Description = itemBase.Description; + taskItem.Type = itemBase.AssetType; + taskItem.InvType = itemBase.InvType; + taskItem.OwnerID = itemBase.Owner; + taskItem.CreatorID = itemBase.CreatorIdAsUuid; + taskItem.BasePermissions = itemBase.BasePermissions; + taskItem.CurrentPermissions = itemBase.CurrentPermissions; + taskItem.EveryonePermissions = itemBase.EveryOnePermissions; + taskItem.GroupPermissions = itemBase.GroupPermissions; + taskItem.NextPermissions = itemBase.NextPermissions; + taskItem.GroupID = itemBase.GroupID; + taskItem.GroupPermissions = 0; + taskItem.Flags = itemBase.Flags; + taskItem.PermsGranter = UUID.Zero; + taskItem.PermsMask = 0; + taskItem.AssetID = asset.FullID; + + part.Inventory.AddInventoryItem(taskItem, false); + part.SendPropertiesToClient(remoteClient); + + part.Inventory.CreateScriptInstance(taskItem, 0, false, DefaultScriptEngine, 0); + part.ParentGroup.ResumeScripts(); } /// @@ -1666,7 +1682,7 @@ namespace OpenSim.Region.Framework.Scenes /// /// /// - public void RezScript(UUID srcId, SceneObjectPart srcPart, UUID destId, int pin, int running, int start_param) + public void RezScriptFromPrim(UUID srcId, SceneObjectPart srcPart, UUID destId, int pin, int running, int start_param) { TaskInventoryItem srcTaskItem = srcPart.Inventory.GetInventoryItem(srcId); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 330c65d..6fa812d 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -6603,7 +6603,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } // the rest of the permission checks are done in RezScript, so check the pin there as well - World.RezScript(srcId, m_host, destId, pin, running, start_param); + World.RezScriptFromPrim(srcId, m_host, destId, pin, running, start_param); + // this will cause the delay even if the script pin or permissions were wrong - seems ok ScriptSleep(3000); } -- cgit v1.1 From 55c6cbabfd04599030548983f376f60acdf607e7 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 26 Jan 2012 00:10:37 +0000 Subject: refactor: change RezScriptFromAgentInventory(), RezNewScript() and AddInventoryItem() to accept an agent id rather than a full IClientAPI. This stops some code having to make spurious client == null checks and reduces regression test complexity. --- OpenSim/Data/Tests/RegionTests.cs | 12 +++--- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 50 +++++++++++++--------- .../Framework/Scenes/SceneObjectGroup.Inventory.cs | 15 ++----- 3 files changed, 40 insertions(+), 37 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Data/Tests/RegionTests.cs b/OpenSim/Data/Tests/RegionTests.cs index 1b93176..1d806fc 100644 --- a/OpenSim/Data/Tests/RegionTests.cs +++ b/OpenSim/Data/Tests/RegionTests.cs @@ -685,7 +685,7 @@ namespace OpenSim.Data.Tests SceneObjectGroup sog = GetMySOG("object1"); InventoryItemBase i = NewItem(item1, zero, zero, itemname1, zero); - Assert.That(sog.AddInventoryItem(null, sog.RootPart.LocalId, i, zero), Is.True); + Assert.That(sog.AddInventoryItem(zero, sog.RootPart.LocalId, i, zero), Is.True); TaskInventoryItem t = sog.GetInventoryItem(sog.RootPart.LocalId, item1); Assert.That(t.Name, Is.EqualTo(itemname1), "Assert.That(t.Name, Is.EqualTo(itemname1))"); @@ -762,7 +762,7 @@ namespace OpenSim.Data.Tests i.CreationDate = creationd; SceneObjectGroup sog = GetMySOG("object1"); - Assert.That(sog.AddInventoryItem(null, sog.RootPart.LocalId, i, zero), Is.True); + Assert.That(sog.AddInventoryItem(zero, sog.RootPart.LocalId, i, zero), Is.True); TaskInventoryItem t = sog.GetInventoryItem(sog.RootPart.LocalId, id); Assert.That(t.Name, Is.EqualTo(name), "Assert.That(t.Name, Is.EqualTo(name))"); @@ -807,10 +807,10 @@ namespace OpenSim.Data.Tests SceneObjectGroup sog = FindSOG("object1", region1); - Assert.That(sog.AddInventoryItem(null, sog.RootPart.LocalId, ib1, zero), Is.True); - Assert.That(sog.AddInventoryItem(null, sog.RootPart.LocalId, ib2, zero), Is.True); - Assert.That(sog.AddInventoryItem(null, sog.RootPart.LocalId, ib3, zero), Is.True); - Assert.That(sog.AddInventoryItem(null, sog.RootPart.LocalId, ib4, zero), Is.True); + Assert.That(sog.AddInventoryItem(zero, sog.RootPart.LocalId, ib1, zero), Is.True); + Assert.That(sog.AddInventoryItem(zero, sog.RootPart.LocalId, ib2, zero), Is.True); + Assert.That(sog.AddInventoryItem(zero, sog.RootPart.LocalId, ib3, zero), Is.True); + Assert.That(sog.AddInventoryItem(zero, sog.RootPart.LocalId, ib4, zero), Is.True); TaskInventoryItem t1 = sog.GetInventoryItem(sog.RootPart.LocalId, i1); Assert.That(t1.Name, Is.EqualTo(ib1.Name), "Assert.That(t1.Name, Is.EqualTo(ib1.Name))"); diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index f4f37ac..9293aeb 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -1444,7 +1444,7 @@ namespace OpenSim.Region.Framework.Scenes // If we've found the item in the user's inventory or in the library if (item != null) { - part.ParentGroup.AddInventoryItem(remoteClient, primLocalID, item, copyID); + part.ParentGroup.AddInventoryItem(remoteClient.AgentId, primLocalID, item, copyID); m_log.InfoFormat( "[PRIM INVENTORY]: Update with item {0} requested of prim {1} for {2}", item.Name, primLocalID, remoteClient.Name); @@ -1565,22 +1565,28 @@ namespace OpenSim.Region.Framework.Scenes /// public void RezScript(IClientAPI remoteClient, InventoryItemBase itemBase, UUID transactionID, uint localID) { + SceneObjectPart partWhereRezzed; + if (itemBase.ID != UUID.Zero) - RezScriptFromAgentInventory(remoteClient, itemBase.ID, localID); + partWhereRezzed = RezScriptFromAgentInventory(remoteClient.AgentId, itemBase.ID, localID); else - RezNewScript(remoteClient, itemBase); + partWhereRezzed = RezNewScript(remoteClient.AgentId, itemBase); + + if (partWhereRezzed != null) + partWhereRezzed.SendPropertiesToClient(remoteClient); } /// /// Rez a script into a prim from an agent inventory. /// - /// + /// /// /// - public void RezScriptFromAgentInventory(IClientAPI remoteClient, UUID fromItemID, uint localID) + /// The part where the script was rezzed if successful. False otherwise. + public SceneObjectPart RezScriptFromAgentInventory(UUID agentID, UUID fromItemID, uint localID) { UUID copyID = UUID.Random(); - InventoryItemBase item = new InventoryItemBase(fromItemID, remoteClient.AgentId); + InventoryItemBase item = new InventoryItemBase(fromItemID, agentID); item = InventoryService.GetItem(item); // Try library @@ -1595,10 +1601,10 @@ namespace OpenSim.Region.Framework.Scenes SceneObjectPart part = GetSceneObjectPart(localID); if (part != null) { - if (!Permissions.CanEditObjectInventory(part.UUID, remoteClient.AgentId)) - return; + if (!Permissions.CanEditObjectInventory(part.UUID, agentID)) + return null; - part.ParentGroup.AddInventoryItem(remoteClient, localID, item, copyID); + part.ParentGroup.AddInventoryItem(agentID, localID, item, copyID); // TODO: switch to posting on_rez here when scripts // have state in inventory part.Inventory.CreateScriptInstance(copyID, 0, false, DefaultScriptEngine, 0); @@ -1606,8 +1612,9 @@ namespace OpenSim.Region.Framework.Scenes // m_log.InfoFormat("[PRIMINVENTORY]: " + // "Rezzed script {0} into prim local ID {1} for user {2}", // item.inventoryName, localID, remoteClient.Name); - part.SendPropertiesToClient(remoteClient); part.ParentGroup.ResumeScripts(); + + return part; } else { @@ -1615,15 +1622,17 @@ namespace OpenSim.Region.Framework.Scenes "[PRIM INVENTORY]: " + "Could not rez script {0} into prim local ID {1} for user {2}" + " because the prim could not be found in the region!", - item.Name, localID, remoteClient.Name); + item.Name, localID, agentID); } } else { m_log.ErrorFormat( "[PRIM INVENTORY]: Could not find script inventory item {0} to rez for {1}!", - fromItemID, remoteClient.Name); + fromItemID, agentID); } + + return null; } /// @@ -1631,19 +1640,20 @@ namespace OpenSim.Region.Framework.Scenes /// /// /// - public void RezNewScript(IClientAPI remoteClient, InventoryItemBase itemBase) + /// The part where the script was rezzed if successful. False otherwise. + public SceneObjectPart RezNewScript(UUID agentID, InventoryItemBase itemBase) { + // The part ID is the folder ID! SceneObjectPart part = GetSceneObjectPart(itemBase.Folder); if (part == null) - return; + return null; - if (!Permissions.CanCreateObjectInventory( - itemBase.InvType, part.UUID, remoteClient.AgentId)) - return; + if (!Permissions.CanCreateObjectInventory(itemBase.InvType, part.UUID, agentID)) + return null; AssetBase asset = CreateAsset(itemBase.Name, itemBase.Description, (sbyte)itemBase.AssetType, Encoding.ASCII.GetBytes("default\n{\n state_entry()\n {\n llSay(0, \"Script running\");\n }\n}"), - remoteClient.AgentId); + agentID); AssetService.Store(asset); TaskInventoryItem taskItem = new TaskInventoryItem(); @@ -1670,10 +1680,10 @@ namespace OpenSim.Region.Framework.Scenes taskItem.AssetID = asset.FullID; part.Inventory.AddInventoryItem(taskItem, false); - part.SendPropertiesToClient(remoteClient); - part.Inventory.CreateScriptInstance(taskItem, 0, false, DefaultScriptEngine, 0); part.ParentGroup.ResumeScripts(); + + return part; } /// diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs index 905ecc9..f173c95 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs @@ -83,13 +83,12 @@ namespace OpenSim.Region.Framework.Scenes /// /// Add an inventory item from a user's inventory to a prim in this scene object. /// - /// The client adding the item. + /// The agent adding the item. /// The local ID of the part receiving the add. /// The user inventory item being added. /// The item UUID that should be used by the new item. /// - public bool AddInventoryItem(IClientAPI remoteClient, uint localID, - InventoryItemBase item, UUID copyItemID) + public bool AddInventoryItem(UUID agentID, uint localID, InventoryItemBase item, UUID copyItemID) { // m_log.DebugFormat( // "[PRIM INVENTORY]: Adding inventory item {0} from {1} to part with local ID {2}", @@ -111,9 +110,7 @@ namespace OpenSim.Region.Framework.Scenes taskItem.Type = item.AssetType; taskItem.InvType = item.InvType; - if (remoteClient != null && - remoteClient.AgentId != part.OwnerID && - m_scene.Permissions.PropagatePermissions()) + if (agentID != part.OwnerID && m_scene.Permissions.PropagatePermissions()) { taskItem.BasePermissions = item.BasePermissions & item.NextPermissions; @@ -148,11 +145,7 @@ namespace OpenSim.Region.Framework.Scenes // taskItem.SaleType = item.SaleType; taskItem.CreationDate = (uint)item.CreationDate; - bool addFromAllowedDrop = false; - if (remoteClient != null) - { - addFromAllowedDrop = remoteClient.AgentId != part.OwnerID; - } + bool addFromAllowedDrop = agentID != part.OwnerID; part.Inventory.AddInventoryItem(taskItem, addFromAllowedDrop); -- cgit v1.1 From 13d9b64b1d8f7be77e6eaf17f7f85c1c43d6a9ff Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 26 Jan 2012 00:28:51 +0000 Subject: Re-enable error logging associated with assembly and script loading failure in ScriptInstance. Swallowing exceptions just leads to more mysterious failures later on. --- .../ScriptEngine/Shared/Instance/ScriptInstance.cs | 28 +++++++++++++++------- 1 file changed, 19 insertions(+), 9 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index f9d6eee..9b93135 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs @@ -55,7 +55,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance { public class ScriptInstance : MarshalByRefObject, IScriptInstance { -// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private IScriptEngine m_Engine; private IScriptWorkItem m_CurrentResult = null; @@ -109,7 +109,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance private Dictionary m_Apis = new Dictionary(); // Script state - private string m_State="default"; + private string m_State = "default"; public Object[] PluginData = new Object[0]; @@ -127,6 +127,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance m_minEventDelay = value; else m_minEventDelay = 0.0; + m_eventDelayTicks = (long)(m_minEventDelay * 10000000L); m_nextEventTimeTicks = DateTime.Now.Ticks; } @@ -296,9 +297,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance //RemotingServices.GetLifetimeService(m_Script as ScriptBaseClass); // lease.Register(this); } - catch (Exception) + catch (Exception e) { - // m_log.ErrorFormat("[Script] Error loading assembly {0}\n"+e.ToString(), assembly); + m_log.ErrorFormat( + "[SCRIPT INSTANCE]: Error loading assembly {0}. Exception {1}{2}", + assembly, e.Message, e.StackTrace); } try @@ -313,9 +316,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance part.SetScriptEvents(m_ItemID, (int)m_Script.GetStateEventFlags(State)); } - catch (Exception) + catch (Exception e) { - // m_log.Error("[Script] Error loading script instance\n"+e.ToString()); + m_log.ErrorFormat( + "[SCRIPT INSTANCE]: Error loading script instance from assembly {0}. Exception {1}{2}", + assembly, e.Message, e.StackTrace); + return; } @@ -377,12 +383,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance } else { - // m_log.Error("[Script] Unable to load script state: Memory limit exceeded"); + m_log.ErrorFormat( + "[SCRIPT INSTANCE]: Unable to load script state from assembly {0}: Memory limit exceeded", + assembly); } } - catch (Exception) + catch (Exception e) { - // m_log.ErrorFormat("[Script] Unable to load script state from xml: {0}\n"+e.ToString(), xml); + m_log.ErrorFormat( + "[SCRIPT INSTANCE]: Unable to load script state from assembly {0}. XML is {1}. Exception {2}{3}", + assembly, xml, e.Message, e.StackTrace); } } // else -- cgit v1.1 From 093469c33c2e2ac10d41cf4daadac3c7fd7ff40c Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 26 Jan 2012 01:16:03 +0000 Subject: Add basic TestAddScript() regression test --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 11 ++++ .../Scenes/Tests/SceneObjectScriptTests.cs | 76 ++++++++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100644 OpenSim/Region/Framework/Scenes/Tests/SceneObjectScriptTests.cs (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 9293aeb..f344dcc 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -1646,10 +1646,21 @@ namespace OpenSim.Region.Framework.Scenes // The part ID is the folder ID! SceneObjectPart part = GetSceneObjectPart(itemBase.Folder); if (part == null) + { +// m_log.DebugFormat( +// "[SCENE INVENTORY]: Could not find part with id {0} for {1} to rez new script", +// itemBase.Folder, agentID); + return null; + } if (!Permissions.CanCreateObjectInventory(itemBase.InvType, part.UUID, agentID)) + { +// m_log.DebugFormat( +// "[SCENE INVENTORY]: No permission to create new script in {0} for {1}", part.Name, agentID); + return null; + } AssetBase asset = CreateAsset(itemBase.Name, itemBase.Description, (sbyte)itemBase.AssetType, Encoding.ASCII.GetBytes("default\n{\n state_entry()\n {\n llSay(0, \"Script running\");\n }\n}"), diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectScriptTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectScriptTests.cs new file mode 100644 index 0000000..6f99abd --- /dev/null +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectScriptTests.cs @@ -0,0 +1,76 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using System.Reflection; +using NUnit.Framework; +using OpenMetaverse; +using OpenSim.Framework; +using OpenSim.Framework.Communications; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Tests.Common; +using OpenSim.Tests.Common.Mock; + +namespace OpenSim.Region.Framework.Scenes.Tests +{ + [TestFixture] + public class SceneObjectScriptTests + { + [Test] + public void TestAddScript() + { + TestHelpers.InMethod(); +// log4net.Config.XmlConfigurator.Configure(); + + UUID userId = TestHelpers.ParseTail(0x1); + UUID itemId = TestHelpers.ParseTail(0x2); + string itemName = "Test Script Item"; + + Scene scene = SceneHelpers.SetupScene(); + SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId); + scene.AddNewSceneObject(so, true); + + InventoryItemBase itemTemplate = new InventoryItemBase(); + itemTemplate.Name = itemName; + itemTemplate.Folder = so.UUID; + itemTemplate.InvType = (int)InventoryType.LSL; + + SceneObjectPart partWhereScriptAdded = scene.RezNewScript(userId, itemTemplate); + + Assert.That(partWhereScriptAdded, Is.Not.Null); + + IEntityInventory primInventory = partWhereScriptAdded.Inventory; + Assert.That(primInventory.GetInventoryList().Count, Is.EqualTo(1)); + Assert.That(primInventory.ContainsScripts(), Is.True); + + IList primItems = primInventory.GetInventoryItems(itemName); + Assert.That(primItems.Count, Is.EqualTo(1)); + } + } +} \ No newline at end of file -- cgit v1.1 From a6abecf5fa5de0a78b1d77ef0aee1efafb255a2f Mon Sep 17 00:00:00 2001 From: BlueWall Date: Thu, 26 Jan 2012 00:33:34 -0500 Subject: Change references from sop to sog and add protection from null ref I had code made additions to the map module that was based on the earlier work that I did before Melanie made improvements. Updating the new code to incorporate the same changes. --- .../CoreModules/World/WorldMap/WorldMapModule.cs | 24 ++++++++++++---------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs index 1a9313b..4ae96f0 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs @@ -489,18 +489,20 @@ namespace OpenSim.Region.CoreModules.World.WorldMap List mapitems = new List(); mapItemReply mapitem = new mapItemReply(); - SceneObjectPart sop = m_scene.GetSceneObjectPart(m_scene.RegionInfo.RegionSettings.TelehubObject); - - mapitem = new mapItemReply(); - mapitem.x = (uint)(xstart + sop.AbsolutePosition.X); - mapitem.y = (uint)(ystart + sop.AbsolutePosition.Y); - mapitem.id = UUID.Zero; - mapitem.name = sop.Name; - mapitem.Extra = 0; // color (not used) - mapitem.Extra2 = 0; // 0 = telehub / 1 = infohub - mapitems.Add(mapitem); + SceneObjectGroup sog = m_scene.GetSceneObjectGroup(m_scene.RegionInfo.RegionSettings.TelehubObject); + if (sog != null) + { + mapitem = new mapItemReply(); + mapitem.x = (uint)(xstart + sog.AbsolutePosition.X); + mapitem.y = (uint)(ystart + sog.AbsolutePosition.Y); + mapitem.id = UUID.Zero; + mapitem.name = sog.Name; + mapitem.Extra = 0; // color (not used) + mapitem.Extra2 = 0; // 0 = telehub / 1 = infohub + mapitems.Add(mapitem); - remoteClient.SendMapItemReply(mapitems.ToArray(), itemtype, flags); + remoteClient.SendMapItemReply(mapitems.ToArray(), itemtype, flags); + } } else { -- cgit v1.1 From da720ce9be7d050ad2ff26c97490ebd4e17be2cc Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 26 Jan 2012 10:21:45 +0000 Subject: Support rejecting a teleport if a user is banned in all parcels that have spawn points --- OpenSim/Region/Framework/Scenes/Scene.cs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index f03c345..984058c 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -5067,6 +5067,36 @@ namespace OpenSim.Region.Framework.Scenes } } + if (position == Vector3.Zero) // Teleport + { + if (!RegionInfo.EstateSettings.AllowDirectTeleport) + { + SceneObjectGroup telehub; + if (RegionInfo.RegionSettings.TelehubObject != UUID.Zero && (telehub = GetSceneObjectGroup(RegionInfo.RegionSettings.TelehubObject)) != null) + { + List spawnPoints = RegionInfo.RegionSettings.SpawnPoints(); + bool banned = true; + foreach (SpawnPoint sp in spawnPoints) + { + Vector3 spawnPoint = sp.GetLocation(telehub.AbsolutePosition, telehub.GroupRotation); + ILandObject land = LandChannel.GetLandObject(spawnPoint.X, spawnPoint.Y); + if (land == null) + continue; + if (land.IsEitherBannedOrRestricted(agentID)) + continue; + banned = false; + break; + } + + if (banned) + { + reason = "No suitable landing point found"; + return false; + } + } + } + } + reason = String.Empty; return true; } -- cgit v1.1 From 616373db169fbfc06652fb3f2d40b531426f6dd3 Mon Sep 17 00:00:00 2001 From: PixelTomsen Date: Thu, 26 Jan 2012 21:53:42 +0100 Subject: llManageEstateAccess implementation http://wiki.secondlife.com/wiki/LlManageEstateAccess Signed-off-by: BlueWall --- OpenSim/Framework/EstateSettings.cs | 6 ++ .../Shared/Api/Implementation/LSL_Api.cs | 69 ++++++++++++++++++++++ .../ScriptEngine/Shared/Api/Interface/ILSL_Api.cs | 1 + .../Shared/Api/Runtime/LSL_Constants.cs | 8 +++ .../ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs | 5 ++ 5 files changed, 89 insertions(+) (limited to 'OpenSim') diff --git a/OpenSim/Framework/EstateSettings.cs b/OpenSim/Framework/EstateSettings.cs index 2a495b0..98604f2 100644 --- a/OpenSim/Framework/EstateSettings.cs +++ b/OpenSim/Framework/EstateSettings.cs @@ -373,5 +373,11 @@ namespace OpenSim.Framework return l_EstateAccess.Contains(user); } + + public bool GroupAccess(UUID groupID) + { + return l_EstateGroups.Contains(groupID); + } + } } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 6fa812d..fb5fd45 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -10646,6 +10646,75 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return list; } + public LSL_Integer llManageEstateAccess(int action, string avatar) + { + m_host.AddScriptLPS(1); + EstateSettings estate = World.RegionInfo.EstateSettings; + bool isAccount = false; + bool isGroup = false; + + if (!estate.IsEstateOwner(m_host.OwnerID) || !estate.IsEstateManager(m_host.OwnerID)) + return 0; + + UUID id = new UUID(); + if (!UUID.TryParse(avatar, out id)) + return 0; + + UserAccount account = World.UserAccountService.GetUserAccount(World.RegionInfo.ScopeID, id); + isAccount = account != null ? true : false; + if (!isAccount) + { + IGroupsModule groups = World.RequestModuleInterface(); + if (groups != null) + { + GroupRecord group = groups.GetGroupRecord(id); + isGroup = group != null ? true : false; + if (!isGroup) + return 0; + } + else + return 0; + } + + switch (action) + { + case ScriptBaseClass.ESTATE_ACCESS_ALLOWED_AGENT_ADD: + if (!isAccount) return 0; + if (estate.HasAccess(id)) return 1; + if (estate.IsBanned(id)) + estate.RemoveBan(id); + estate.AddEstateUser(id); + break; + case ScriptBaseClass.ESTATE_ACCESS_ALLOWED_AGENT_REMOVE: + if (!isAccount || !estate.HasAccess(id)) return 0; + estate.RemoveEstateUser(id); + break; + case ScriptBaseClass.ESTATE_ACCESS_ALLOWED_GROUP_ADD: + if (!isGroup) return 0; + if (estate.GroupAccess(id)) return 1; + estate.AddEstateGroup(id); + break; + case ScriptBaseClass.ESTATE_ACCESS_ALLOWED_GROUP_REMOVE: + if (!isGroup || !estate.GroupAccess(id)) return 0; + estate.RemoveEstateGroup(id); + break; + case ScriptBaseClass.ESTATE_ACCESS_BANNED_AGENT_ADD: + if (!isAccount) return 0; + if (estate.IsBanned(id)) return 1; + EstateBan ban = new EstateBan(); + ban.EstateID = estate.EstateID; + ban.BannedUserID = id; + estate.AddBan(ban); + break; + case ScriptBaseClass.ESTATE_ACCESS_BANNED_AGENT_REMOVE: + if (!isAccount || !estate.IsBanned(id)) return 0; + estate.RemoveBan(id); + break; + default: return 0; + } + return 1; + } + #region Not Implemented // // Listing the unimplemented lsl functions here, please move diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs index 282443b..b66537f 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs @@ -242,6 +242,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces void llLoopSound(string sound, double volume); void llLoopSoundMaster(string sound, double volume); void llLoopSoundSlave(string sound, double volume); + LSL_Integer llManageEstateAccess(int action, string avatar); void llMakeExplosion(int particles, double scale, double vel, double lifetime, double arc, string texture, LSL_Vector offset); void llMakeFire(int particles, double scale, double vel, double lifetime, double arc, string texture, LSL_Vector offset); void llMakeFountain(int particles, double scale, double vel, double lifetime, double arc, int bounce, string texture, LSL_Vector offset, double bounce_offset); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs index 176dc56..ab2c543 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs @@ -432,6 +432,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase public const int REGION_FLAG_ALLOW_DIRECT_TELEPORT = 0x100000; // region allows direct teleports public const int REGION_FLAG_RESTRICT_PUSHOBJECT = 0x400000; // region restricts llPushObject + //llManageEstateAccess + public const int ESTATE_ACCESS_ALLOWED_AGENT_ADD = 0; + public const int ESTATE_ACCESS_ALLOWED_AGENT_REMOVE = 1; + public const int ESTATE_ACCESS_ALLOWED_GROUP_ADD = 2; + public const int ESTATE_ACCESS_ALLOWED_GROUP_REMOVE = 3; + public const int ESTATE_ACCESS_BANNED_AGENT_ADD = 4; + public const int ESTATE_ACCESS_BANNED_AGENT_REMOVE = 5; + public static readonly LSLInteger PAY_HIDE = new LSLInteger(-1); public static readonly LSLInteger PAY_DEFAULT = new LSLInteger(-2); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs index 9733683..840d3a4 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs @@ -1054,6 +1054,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase m_LSL_Functions.llLoopSoundSlave(sound, volume); } + public LSL_Integer llManageEstateAccess(int action, string avatar) + { + return m_LSL_Functions.llManageEstateAccess(action, avatar); + } + public void llMakeExplosion(int particles, double scale, double vel, double lifetime, double arc, string texture, LSL_Vector offset) { m_LSL_Functions.llMakeExplosion(particles, scale, vel, lifetime, arc, texture, offset); -- cgit v1.1 From 91ac21b9ec36d698bfaa7ecf6e8d981562ddb4c1 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 26 Jan 2012 17:00:58 -0800 Subject: HG Inventoty: Guard against items not found. --- OpenSim/Services/HypergridService/HGInventoryService.cs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Services/HypergridService/HGInventoryService.cs b/OpenSim/Services/HypergridService/HGInventoryService.cs index daf8c3a..41d5a7a 100644 --- a/OpenSim/Services/HypergridService/HGInventoryService.cs +++ b/OpenSim/Services/HypergridService/HGInventoryService.cs @@ -319,13 +319,14 @@ namespace OpenSim.Services.HypergridService public override InventoryItemBase GetItem(InventoryItemBase item) { InventoryItemBase it = base.GetItem(item); + if (it != null) + { + UserAccount user = m_Cache.GetUser(it.CreatorId); - UserAccount user = m_Cache.GetUser(it.CreatorId); - - // Adjust the creator data - if (user != null && it != null && (it.CreatorData == null || it.CreatorData == string.Empty)) - it.CreatorData = m_HomeURL + ";" + user.FirstName + " " + user.LastName; - + // Adjust the creator data + if (user != null && it != null && (it.CreatorData == null || it.CreatorData == string.Empty)) + it.CreatorData = m_HomeURL + ";" + user.FirstName + " " + user.LastName; + } return it; } -- cgit v1.1 From 9939f94f08b33e3dd9eeea65b730f0ddc80275a5 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 27 Jan 2012 23:05:48 +0000 Subject: Implement osNpcGetOwner(key npc):key. This returns the owner for an 'owned' NPC, the npc's own key for an 'unowned' NPC and NULL_KEY is the input key was not an npc. llGetOwnerKey() could also be extended but this does not allow one to distinguish between an unowned NPC and some other result (e.g. 'no such object' if NULL_KEY is the return. Also, any future extensions to LSL functions by Linden Lab are unpredictable and OpenSim-specific extensions could clash. --- OpenSim/Region/Framework/Interfaces/INPCModule.cs | 2 +- .../Shared/Api/Implementation/OSSL_Api.cs | 21 ++++++++++ .../ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | 48 +++++++++++++--------- .../ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | 5 +++ 4 files changed, 56 insertions(+), 20 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Interfaces/INPCModule.cs b/OpenSim/Region/Framework/Interfaces/INPCModule.cs index c50e734..b428c40 100644 --- a/OpenSim/Region/Framework/Interfaces/INPCModule.cs +++ b/OpenSim/Region/Framework/Interfaces/INPCModule.cs @@ -134,4 +134,4 @@ namespace OpenSim.Region.Framework.Interfaces /// UUID of owner if the NPC exists, UUID.Zero if there was no such agent, the agent is unowned or the agent was not an NPC UUID GetOwner(UUID agentID); } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 7792ab5..ba96ad8 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -2313,6 +2313,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } } + public LSL_Key osNpcGetOwner(LSL_Key npc) + { + CheckThreatLevel(ThreatLevel.None, "osNpcGetOwner"); + + INPCModule npcModule = World.RequestModuleInterface(); + if (npcModule != null) + { + UUID npcId; + if (UUID.TryParse(npc.m_string, out npcId)) + { + UUID owner = npcModule.GetOwner(npcId); + if (owner != UUID.Zero) + return new LSL_Key(owner.ToString()); + else + return npc; + } + } + + return new LSL_Key(UUID.Zero.ToString()); + } + public LSL_Vector osNpcGetPos(LSL_Key npc) { CheckThreatLevel(ThreatLevel.High, "osNpcGetPos"); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index 0f8cbdc..ee48ec4 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs @@ -173,25 +173,35 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces LSL_List osGetLinkPrimitiveParams(int linknumber, LSL_List rules); - key osNpcCreate(string user, string name, vector position, string notecard); - key osNpcCreate(string user, string name, vector position, string notecard, int options); - LSL_Key osNpcSaveAppearance(key npc, string notecard); - void osNpcLoadAppearance(key npc, string notecard); - vector osNpcGetPos(key npc); - void osNpcMoveTo(key npc, vector position); - void osNpcMoveToTarget(key npc, vector target, int options); - rotation osNpcGetRot(key npc); - void osNpcSetRot(LSL_Key npc, rotation rot); - void osNpcStopMoveToTarget(LSL_Key npc); - void osNpcSay(key npc, string message); - void osNpcSit(key npc, key target, int options); - void osNpcStand(LSL_Key npc); - void osNpcRemove(key npc); - void osNpcPlayAnimation(LSL_Key npc, string animation); - void osNpcStopAnimation(LSL_Key npc, string animation); - - LSL_Key osOwnerSaveAppearance(string notecard); - LSL_Key osAgentSaveAppearance(key agentId, string notecard); + key osNpcCreate(string user, string name, vector position, string notecard); + key osNpcCreate(string user, string name, vector position, string notecard, int options); + LSL_Key osNpcSaveAppearance(key npc, string notecard); + void osNpcLoadAppearance(key npc, string notecard); + vector osNpcGetPos(key npc); + void osNpcMoveTo(key npc, vector position); + void osNpcMoveToTarget(key npc, vector target, int options); + + /// + /// Get the owner of the NPC + /// + /// + /// + /// The owner of the NPC for an owned NPC. The NPC's agent id for an unowned NPC. UUID.Zero if the key is not an npc. + /// + LSL_Key osNpcGetOwner(key npc); + + rotation osNpcGetRot(key npc); + void osNpcSetRot(LSL_Key npc, rotation rot); + void osNpcStopMoveToTarget(LSL_Key npc); + void osNpcSay(key npc, string message); + void osNpcSit(key npc, key target, int options); + void osNpcStand(LSL_Key npc); + void osNpcRemove(key npc); + void osNpcPlayAnimation(LSL_Key npc, string animation); + void osNpcStopAnimation(LSL_Key npc, string animation); + + LSL_Key osOwnerSaveAppearance(string notecard); + LSL_Key osAgentSaveAppearance(key agentId, string notecard); key osGetMapTexture(); key osGetRegionMapTexture(string regionName); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs index 02efecf..38a814d 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs @@ -513,6 +513,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase m_OSSL_Functions.osNpcLoadAppearance(npc, notecard); } + public LSL_Key osNpcGetOwner(LSL_Key npc) + { + return m_OSSL_Functions.osNpcGetOwner(npc); + } + public vector osNpcGetPos(LSL_Key npc) { return m_OSSL_Functions.osNpcGetPos(npc); -- cgit v1.1 From 7c1d075a5a72dd9411e40676054b648b26f116a6 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 27 Jan 2012 23:17:13 +0000 Subject: Implement osIsNpc(key npc):integer. This return TRUE if the given key belongs to an NPC in the region. FALSE if not or if the NPC module isn't present. --- .../ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 17 +++++++++++++++++ .../ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | 7 +++++++ .../Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | 5 +++++ 3 files changed, 29 insertions(+) (limited to 'OpenSim') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index ba96ad8..034d545 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -2202,6 +2202,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return retVal; } + public LSL_Integer osIsNpc(LSL_Key npc) + { + CheckThreatLevel(ThreatLevel.None, "osIsNpc"); + m_host.AddScriptLPS(1); + + INPCModule module = World.RequestModuleInterface(); + if (module != null) + { + UUID npcId; + if (UUID.TryParse(npc.m_string, out npcId)) + if (module.IsNPC(npcId, World)) + return ScriptBaseClass.TRUE; + } + + return ScriptBaseClass.FALSE; + } + public LSL_Key osNpcCreate(string firstname, string lastname, LSL_Vector position, string notecard) { CheckThreatLevel(ThreatLevel.High, "osNpcCreate"); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index ee48ec4..dbc1dfc 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs @@ -173,6 +173,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces LSL_List osGetLinkPrimitiveParams(int linknumber, LSL_List rules); + /// + /// Check if the given key is an npc + /// + /// + /// TRUE if the key belongs to an npc in the scene. FALSE otherwise. + LSL_Integer osIsNpc(LSL_Key npc); + key osNpcCreate(string user, string name, vector position, string notecard); key osNpcCreate(string user, string name, vector position, string notecard, int options); LSL_Key osNpcSaveAppearance(key npc, string notecard); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs index 38a814d..cc8d417 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs @@ -493,6 +493,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase return m_OSSL_Functions.osGetLinkPrimitiveParams(linknumber, rules); } + public LSL_Integer osIsNpc(LSL_Key npc) + { + return m_OSSL_Functions.osIsNpc(npc); + } + public key osNpcCreate(string user, string name, vector position, key cloneFrom) { return m_OSSL_Functions.osNpcCreate(user, name, position, cloneFrom); -- cgit v1.1 From 31b87ff07b7442e2fc74936e4da0084118123285 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 27 Jan 2012 23:24:49 +0000 Subject: Increment LPS script stat for OSSL functions that were not already doing this --- .../Shared/Api/Implementation/OSSL_Api.cs | 43 +++++++++++++++++++++- 1 file changed, 41 insertions(+), 2 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 034d545..a2f5c92 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -416,6 +416,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Integer osSetTerrainHeight(int x, int y, double val) { CheckThreatLevel(ThreatLevel.High, "osSetTerrainHeight"); + return SetTerrainHeight(x, y, val); } @@ -423,12 +424,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { CheckThreatLevel(ThreatLevel.High, "osTerrainSetHeight"); OSSLDeprecated("osTerrainSetHeight", "osSetTerrainHeight"); + return SetTerrainHeight(x, y, val); } private LSL_Integer SetTerrainHeight(int x, int y, double val) { m_host.AddScriptLPS(1); + if (x > ((int)Constants.RegionSize - 1) || x < 0 || y > ((int)Constants.RegionSize - 1) || y < 0) OSSLError("osSetTerrainHeight: Coordinate out of bounds"); @@ -468,6 +471,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osTerrainFlush() { CheckThreatLevel(ThreatLevel.VeryLow, "osTerrainFlush"); + m_host.AddScriptLPS(1); ITerrainModule terrainModule = World.RequestModuleInterface(); if (terrainModule != null) terrainModule.TaintTerrain(); @@ -884,6 +888,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // threat level is None as we could get this information with an // in-world script as well, just not as efficient CheckThreatLevel(ThreatLevel.None, "osGetAgents"); + m_host.AddScriptLPS(1); LSL_List result = new LSL_List(); World.ForEachRootScenePresence(delegate(ScenePresence sp) @@ -1164,6 +1169,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // should be removed // CheckThreatLevel(ThreatLevel.High, "osSetStateEvents"); + m_host.AddScriptLPS(1); m_host.SetScriptEvents(m_itemID, events); } @@ -1511,7 +1517,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.AddScriptLPS(1); - ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y); @@ -1572,6 +1577,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // CheckThreatLevel(ThreatLevel.High,"osGetSimulatorVersion"); m_host.AddScriptLPS(1); + return m_ScriptEngine.World.GetSimulatorVersion(); } @@ -1909,6 +1915,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public string osAvatarName2Key(string firstname, string lastname) { CheckThreatLevel(ThreatLevel.Low, "osAvatarName2Key"); + m_host.AddScriptLPS(1); UserAccount account = World.UserAccountService.GetUserAccount(World.RegionInfo.ScopeID, firstname, lastname); if (null == account) @@ -1924,6 +1931,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public string osKey2Name(string id) { CheckThreatLevel(ThreatLevel.Low, "osKey2Name"); + m_host.AddScriptLPS(1); + UUID key = new UUID(); if (UUID.TryParse(id, out key)) @@ -2222,12 +2231,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Key osNpcCreate(string firstname, string lastname, LSL_Vector position, string notecard) { CheckThreatLevel(ThreatLevel.High, "osNpcCreate"); + m_host.AddScriptLPS(1); + return NpcCreate(firstname, lastname, position, notecard, true); } public LSL_Key osNpcCreate(string firstname, string lastname, LSL_Vector position, string notecard, int options) { CheckThreatLevel(ThreatLevel.High, "osNpcCreate"); + m_host.AddScriptLPS(1); + return NpcCreate(firstname, lastname, position, notecard, (options & ScriptBaseClass.OS_NPC_NOT_OWNED) == 0); } @@ -2285,6 +2298,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Key osNpcSaveAppearance(LSL_Key npc, string notecard) { CheckThreatLevel(ThreatLevel.High, "osNpcSaveAppearance"); + m_host.AddScriptLPS(1); INPCModule npcModule = World.RequestModuleInterface(); @@ -2306,6 +2320,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osNpcLoadAppearance(LSL_Key npc, string notecard) { CheckThreatLevel(ThreatLevel.High, "osNpcLoadAppearance"); + m_host.AddScriptLPS(1); INPCModule npcModule = World.RequestModuleInterface(); @@ -2333,6 +2348,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Key osNpcGetOwner(LSL_Key npc) { CheckThreatLevel(ThreatLevel.None, "osNpcGetOwner"); + m_host.AddScriptLPS(1); INPCModule npcModule = World.RequestModuleInterface(); if (npcModule != null) @@ -2354,6 +2370,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Vector osNpcGetPos(LSL_Key npc) { CheckThreatLevel(ThreatLevel.High, "osNpcGetPos"); + m_host.AddScriptLPS(1); INPCModule npcModule = World.RequestModuleInterface(); if (npcModule != null) @@ -2375,6 +2392,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osNpcMoveTo(LSL_Key npc, LSL_Vector position) { CheckThreatLevel(ThreatLevel.High, "osNpcMoveTo"); + m_host.AddScriptLPS(1); INPCModule module = World.RequestModuleInterface(); if (module != null) @@ -2394,6 +2412,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osNpcMoveToTarget(LSL_Key npc, LSL_Vector target, int options) { CheckThreatLevel(ThreatLevel.High, "osNpcMoveToTarget"); + m_host.AddScriptLPS(1); INPCModule module = World.RequestModuleInterface(); if (module != null) @@ -2418,6 +2437,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Rotation osNpcGetRot(LSL_Key npc) { CheckThreatLevel(ThreatLevel.High, "osNpcGetRot"); + m_host.AddScriptLPS(1); INPCModule npcModule = World.RequestModuleInterface(); if (npcModule != null) @@ -2441,6 +2461,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osNpcSetRot(LSL_Key npc, LSL_Rotation rotation) { CheckThreatLevel(ThreatLevel.High, "osNpcSetRot"); + m_host.AddScriptLPS(1); INPCModule npcModule = World.RequestModuleInterface(); if (npcModule != null) @@ -2460,6 +2481,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osNpcStopMoveToTarget(LSL_Key npc) { CheckThreatLevel(ThreatLevel.VeryLow, "osNpcStopMoveTo"); + m_host.AddScriptLPS(1); INPCModule module = World.RequestModuleInterface(); if (module != null) @@ -2476,6 +2498,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osNpcSay(LSL_Key npc, string message) { CheckThreatLevel(ThreatLevel.High, "osNpcSay"); + m_host.AddScriptLPS(1); INPCModule module = World.RequestModuleInterface(); if (module != null) @@ -2492,6 +2515,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osNpcSit(LSL_Key npc, LSL_Key target, int options) { CheckThreatLevel(ThreatLevel.High, "osNpcSit"); + m_host.AddScriptLPS(1); INPCModule module = World.RequestModuleInterface(); if (module != null) @@ -2508,6 +2532,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osNpcStand(LSL_Key npc) { CheckThreatLevel(ThreatLevel.High, "osNpcStand"); + m_host.AddScriptLPS(1); INPCModule module = World.RequestModuleInterface(); if (module != null) @@ -2524,6 +2549,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osNpcRemove(LSL_Key npc) { CheckThreatLevel(ThreatLevel.High, "osNpcRemove"); + m_host.AddScriptLPS(1); INPCModule module = World.RequestModuleInterface(); if (module != null) @@ -2540,6 +2566,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osNpcPlayAnimation(LSL_Key npc, string animation) { CheckThreatLevel(ThreatLevel.High, "osNpcPlayAnimation"); + m_host.AddScriptLPS(1); INPCModule module = World.RequestModuleInterface(); if (module != null) @@ -2554,6 +2581,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osNpcStopAnimation(LSL_Key npc, string animation) { CheckThreatLevel(ThreatLevel.High, "osNpcStopAnimation"); + m_host.AddScriptLPS(1); INPCModule module = World.RequestModuleInterface(); if (module != null) @@ -2573,6 +2601,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Key osOwnerSaveAppearance(string notecard) { CheckThreatLevel(ThreatLevel.High, "osOwnerSaveAppearance"); + m_host.AddScriptLPS(1); return SaveAppearanceToNotecard(m_host.OwnerID, notecard); } @@ -2580,6 +2609,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Key osAgentSaveAppearance(LSL_Key avatarId, string notecard) { CheckThreatLevel(ThreatLevel.VeryHigh, "osAgentSaveAppearance"); + m_host.AddScriptLPS(1); return SaveAppearanceToNotecard(avatarId, notecard); } @@ -2630,6 +2660,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Key osGetMapTexture() { CheckThreatLevel(ThreatLevel.None, "osGetMapTexture"); + m_host.AddScriptLPS(1); + return m_ScriptEngine.World.RegionInfo.RegionSettings.TerrainImageID.ToString(); } @@ -2641,6 +2673,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Key osGetRegionMapTexture(string regionName) { CheckThreatLevel(ThreatLevel.High, "osGetRegionMapTexture"); + m_host.AddScriptLPS(1); + Scene scene = m_ScriptEngine.World; UUID key = UUID.Zero; GridRegion region; @@ -2706,6 +2740,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osKickAvatar(string FirstName,string SurName,string alert) { CheckThreatLevel(ThreatLevel.Severe, "osKickAvatar"); + m_host.AddScriptLPS(1); + if (World.Permissions.CanRunConsoleCommand(m_host.OwnerID)) { World.ForEachRootScenePresence(delegate(ScenePresence sp) @@ -2840,6 +2876,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_List osGetAvatarList() { CheckThreatLevel(ThreatLevel.None, "osGetAvatarList"); + m_host.AddScriptLPS(1); LSL_List result = new LSL_List(); World.ForEachRootScenePresence(delegate (ScenePresence avatar) @@ -2864,6 +2901,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_String osUnixTimeToTimestamp(long time) { CheckThreatLevel(ThreatLevel.VeryLow, "osUnixTimeToTimestamp"); + m_host.AddScriptLPS(1); + long baseTicks = 621355968000000000; long tickResolution = 10000000; long epochTicks = (time * tickResolution) + baseTicks; @@ -2872,4 +2911,4 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return date.ToString("yyyy-MM-ddTHH:mm:ss.fffffffZ"); } } -} +} \ No newline at end of file -- cgit v1.1 From 7837c611fb483dc776b531306d3d791e8f177aab Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 28 Jan 2012 00:00:12 +0000 Subject: Add OS_NPC_SENSE_AS_AGENT option to osNpcCreate(). This allows NPCs to be sensed as agents by LSL sensors rather than as a specific NPC type (which is currently an OpenSimulator-only extension). Wiki doc on this and other recent NPC functions will follow soon --- OpenSim/Region/Framework/Interfaces/INPCModule.cs | 34 +++++++++++++++++++++- .../Region/OptionalModules/World/NPC/NPCAvatar.cs | 9 ++++-- .../Region/OptionalModules/World/NPC/NPCModule.cs | 21 +++++++++++-- .../World/NPC/Tests/NPCModuleTests.cs | 12 ++++---- .../Shared/Api/Implementation/OSSL_Api.cs | 14 ++++++--- .../Api/Implementation/Plugins/SensorRepeat.cs | 9 ++++-- .../Shared/Api/Runtime/LSL_Constants.cs | 1 + 7 files changed, 83 insertions(+), 17 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Interfaces/INPCModule.cs b/OpenSim/Region/Framework/Interfaces/INPCModule.cs index b428c40..2731291 100644 --- a/OpenSim/Region/Framework/Interfaces/INPCModule.cs +++ b/OpenSim/Region/Framework/Interfaces/INPCModule.cs @@ -31,6 +31,19 @@ using OpenSim.Region.Framework.Scenes; namespace OpenSim.Region.Framework.Interfaces { + /// + /// Temporary interface. More methods to come at some point to make NPCs more object oriented rather than + /// controlling purely through module level interface calls (e.g. sit/stand). + /// + public interface INPC + { + /// + /// Should this NPC be sensed by LSL sensors as an 'agent' (interpreted here to mean a normal user) + /// rather than an OpenSim specific NPC extension? + /// + bool SenseAsAgent { get; } + } + public interface INPCModule { /// @@ -39,10 +52,21 @@ namespace OpenSim.Region.Framework.Interfaces /// /// /// + /// + /// Make the NPC show up as an agent on LSL sensors. The default is that they + /// show up as the NPC type instead, but this is currently an OpenSim-only extension. + /// /// /// The avatar appearance to use for the new NPC. /// The UUID of the ScenePresence created. - UUID CreateNPC(string firstname, string lastname, Vector3 position, UUID owner, Scene scene, AvatarAppearance appearance); + UUID CreateNPC( + string firstname, + string lastname, + Vector3 position, + UUID owner, + bool senseAsAgent, + Scene scene, + AvatarAppearance appearance); /// /// Check if the agent is an NPC. @@ -53,6 +77,14 @@ namespace OpenSim.Region.Framework.Interfaces bool IsNPC(UUID agentID, Scene scene); /// + /// Get the NPC. This is not currently complete - manipulation of NPCs still occurs through the region interface + /// + /// + /// + /// The NPC. null if it does not exist. + INPC GetNPC(UUID agentID, Scene scene); + + /// /// Check if the caller has permission to manipulate the given NPC. /// /// diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs index 6a6c4c3..6d40a92 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs @@ -31,13 +31,16 @@ using System.Net; using OpenMetaverse; using OpenMetaverse.Packets; using OpenSim.Framework; +using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; using OpenSim.Region.CoreModules.World.Estate; namespace OpenSim.Region.OptionalModules.World.NPC { - public class NPCAvatar : IClientAPI + public class NPCAvatar : IClientAPI, INPC { + public bool SenseAsAgent { get; set; } + private readonly string m_firstname; private readonly string m_lastname; private readonly Vector3 m_startPos; @@ -45,13 +48,15 @@ namespace OpenSim.Region.OptionalModules.World.NPC private readonly Scene m_scene; private readonly UUID m_ownerID; - public NPCAvatar(string firstname, string lastname, Vector3 position, UUID ownerID, Scene scene) + public NPCAvatar( + string firstname, string lastname, Vector3 position, UUID ownerID, bool senseAsAgent, Scene scene) { m_firstname = firstname; m_lastname = lastname; m_startPos = position; m_scene = scene; m_ownerID = ownerID; + SenseAsAgent = senseAsAgent; } public IScene Scene diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index d90309f..3831d7a 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs @@ -109,9 +109,15 @@ namespace OpenSim.Region.OptionalModules.World.NPC } public UUID CreateNPC( - string firstname, string lastname, Vector3 position, UUID owner, Scene scene, AvatarAppearance appearance) + string firstname, + string lastname, + Vector3 position, + UUID owner, + bool senseAsAgent, + Scene scene, + AvatarAppearance appearance) { - NPCAvatar npcAvatar = new NPCAvatar(firstname, lastname, position, owner, scene); + NPCAvatar npcAvatar = new NPCAvatar(firstname, lastname, position, owner, senseAsAgent, scene); npcAvatar.CircuitCode = (uint)Util.RandomClass.Next(0, int.MaxValue); m_log.DebugFormat( @@ -266,6 +272,17 @@ namespace OpenSim.Region.OptionalModules.World.NPC return UUID.Zero; } + public INPC GetNPC(UUID agentID, Scene scene) + { + lock (m_avatars) + { + if (m_avatars.ContainsKey(agentID)) + return m_avatars[agentID]; + else + return null; + } + } + public bool DeleteNPC(UUID agentID, Scene scene) { lock (m_avatars) diff --git a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs index d21d601..d507822 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs @@ -109,7 +109,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests afm.SetAppearance(sp, originalTe, null); INPCModule npcModule = scene.RequestModuleInterface(); - UUID npcId = npcModule.CreateNPC("John", "Smith", new Vector3(128, 128, 30), UUID.Zero, scene, sp.Appearance); + UUID npcId = npcModule.CreateNPC("John", "Smith", new Vector3(128, 128, 30), UUID.Zero, true, scene, sp.Appearance); ScenePresence npc = scene.GetScenePresence(npcId); @@ -129,7 +129,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests Vector3 startPos = new Vector3(128, 128, 30); INPCModule npcModule = scene.RequestModuleInterface(); - UUID npcId = npcModule.CreateNPC("John", "Smith", startPos, UUID.Zero, scene, sp.Appearance); + UUID npcId = npcModule.CreateNPC("John", "Smith", startPos, UUID.Zero, true, scene, sp.Appearance); npcModule.DeleteNPC(npcId, scene); @@ -157,7 +157,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests am.RezSingleAttachmentFromInventory(sp, attItemId, (uint)AttachmentPoint.Chest); INPCModule npcModule = scene.RequestModuleInterface(); - UUID npcId = npcModule.CreateNPC("John", "Smith", new Vector3(128, 128, 30), UUID.Zero, scene, sp.Appearance); + UUID npcId = npcModule.CreateNPC("John", "Smith", new Vector3(128, 128, 30), UUID.Zero, true, scene, sp.Appearance); ScenePresence npc = scene.GetScenePresence(npcId); @@ -189,7 +189,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests Vector3 startPos = new Vector3(128, 128, 30); INPCModule npcModule = scene.RequestModuleInterface(); - UUID npcId = npcModule.CreateNPC("John", "Smith", startPos, UUID.Zero, scene, sp.Appearance); + UUID npcId = npcModule.CreateNPC("John", "Smith", startPos, UUID.Zero, true, scene, sp.Appearance); ScenePresence npc = scene.GetScenePresence(npcId); Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos)); @@ -260,7 +260,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests Vector3 startPos = new Vector3(128, 128, 30); INPCModule npcModule = scene.RequestModuleInterface(); - UUID npcId = npcModule.CreateNPC("John", "Smith", startPos, UUID.Zero, scene, sp.Appearance); + UUID npcId = npcModule.CreateNPC("John", "Smith", startPos, UUID.Zero, true, scene, sp.Appearance); ScenePresence npc = scene.GetScenePresence(npcId); SceneObjectPart part = SceneHelpers.AddSceneObject(scene); @@ -293,7 +293,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests Vector3 startPos = new Vector3(1, 1, 1); INPCModule npcModule = scene.RequestModuleInterface(); - UUID npcId = npcModule.CreateNPC("John", "Smith", startPos, UUID.Zero, scene, sp.Appearance); + UUID npcId = npcModule.CreateNPC("John", "Smith", startPos, UUID.Zero, true, scene, sp.Appearance); ScenePresence npc = scene.GetScenePresence(npcId); SceneObjectPart part = SceneHelpers.AddSceneObject(scene); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index a2f5c92..b1583eb 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -2233,7 +2233,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api CheckThreatLevel(ThreatLevel.High, "osNpcCreate"); m_host.AddScriptLPS(1); - return NpcCreate(firstname, lastname, position, notecard, true); + return NpcCreate(firstname, lastname, position, notecard, false, true); } public LSL_Key osNpcCreate(string firstname, string lastname, LSL_Vector position, string notecard, int options) @@ -2241,10 +2241,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api CheckThreatLevel(ThreatLevel.High, "osNpcCreate"); m_host.AddScriptLPS(1); - return NpcCreate(firstname, lastname, position, notecard, (options & ScriptBaseClass.OS_NPC_NOT_OWNED) == 0); + return NpcCreate( + firstname, lastname, position, notecard, + (options & ScriptBaseClass.OS_NPC_NOT_OWNED) == 0, + (options & ScriptBaseClass.OS_NPC_SENSE_AS_AGENT) == 0); } - private LSL_Key NpcCreate(string firstname, string lastname, LSL_Vector position, string notecard, bool owned) + private LSL_Key NpcCreate( + string firstname, string lastname, LSL_Vector position, string notecard, bool owned, bool senseAsAgent) { INPCModule module = World.RequestModuleInterface(); if (module != null) @@ -2281,7 +2285,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api lastname, new Vector3((float) position.x, (float) position.y, (float) position.z), ownerID, - World,appearance); + senseAsAgent, + World, + appearance); return new LSL_Key(x.ToString()); } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs index 8356dce..3e0e452 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs @@ -447,9 +447,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins Action senseEntity = new Action(delegate(ScenePresence presence) { - if ((ts.type & NPC) == 0 && presence.PresenceType == PresenceType.Npc) + if ((ts.type & NPC) == 0 + && presence.PresenceType == PresenceType.Npc + && !npcModule.GetNPC(presence.UUID, presence.Scene).SenseAsAgent) return; - if ((ts.type & AGENT) == 0 && presence.PresenceType == PresenceType.User) + + if ((ts.type & AGENT) == 0 + && (presence.PresenceType == PresenceType.User + || npcModule.GetNPC(presence.UUID, presence.Scene).SenseAsAgent)) return; if (presence.IsDeleted || presence.IsChildAgent || presence.GodLevel > 0.0) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs index ab2c543..a69b4cb 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs @@ -616,6 +616,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase public const int OS_NPC_CREATOR_OWNED = 0x1; public const int OS_NPC_NOT_OWNED = 0x2; + public const int OS_NPC_SENSE_AS_AGENT = 0x4; public const string URL_REQUEST_GRANTED = "URL_REQUEST_GRANTED"; public const string URL_REQUEST_DENIED = "URL_REQUEST_DENIED"; -- cgit v1.1 From 7352aea9ac82c0c1a580ffd00d4436a8ea98f2b6 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 28 Jan 2012 00:18:12 +0000 Subject: Remove IClientAPI from the money module. It was only used to pass in the agent id anyway --- OpenSim/Framework/IMoneyModule.cs | 4 ++-- OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 4 ++-- .../Linden/Caps/NewFileAgentInventoryVariablePriceModule.cs | 4 ++-- .../CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs | 2 +- OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs | 2 +- OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs | 4 ++-- 6 files changed, 10 insertions(+), 10 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/IMoneyModule.cs b/OpenSim/Framework/IMoneyModule.cs index 3d4873d..1e09728 100644 --- a/OpenSim/Framework/IMoneyModule.cs +++ b/OpenSim/Framework/IMoneyModule.cs @@ -36,8 +36,8 @@ namespace OpenSim.Framework int amount); int GetBalance(UUID agentID); - bool UploadCovered(IClientAPI client, int amount); - bool AmountCovered(IClientAPI client, int amount); + bool UploadCovered(UUID agentID, int amount); + bool AmountCovered(UUID agentID, int amount); void ApplyCharge(UUID agentID, int amount, string text); void ApplyUploadCharge(UUID agentID, int amount, string text); diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index 2347cf2..7bc59fc 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -366,7 +366,7 @@ namespace OpenSim.Region.ClientStack.Linden if (mm != null) { - if (!mm.UploadCovered(client, mm.UploadCharge)) + if (!mm.UploadCovered(client.AgentId, mm.UploadCharge)) { if (client != null) client.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false); @@ -1018,4 +1018,4 @@ namespace OpenSim.Region.ClientStack.Linden fs.Close(); } } -} \ No newline at end of file +} diff --git a/OpenSim/Region/ClientStack/Linden/Caps/NewFileAgentInventoryVariablePriceModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/NewFileAgentInventoryVariablePriceModule.cs index b2f04f9..aed03b3 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/NewFileAgentInventoryVariablePriceModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/NewFileAgentInventoryVariablePriceModule.cs @@ -147,7 +147,7 @@ namespace OpenSim.Region.ClientStack.Linden { if (m_scene.TryGetClient(agentID, out client)) { - if (!mm.UploadCovered(client, mm.UploadCharge)) + if (!mm.UploadCovered(client.AgentId, mm.UploadCharge)) { if (client != null) client.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false); @@ -268,4 +268,4 @@ namespace OpenSim.Region.ClientStack.Linden } } -} \ No newline at end of file +} diff --git a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs index a28d5d7..95e3aec 100644 --- a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs +++ b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs @@ -246,7 +246,7 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction if (mm != null) { - if (!mm.UploadCovered(remoteClient, mm.UploadCharge)) + if (!mm.UploadCovered(remoteClient.AgentId, mm.UploadCharge)) { remoteClient.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false); return; diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs index 740dbdd..b60cd42 100644 --- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs @@ -713,7 +713,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups if (money != null) { // do the transaction, that is if the agent has got sufficient funds - if (!money.AmountCovered(remoteClient, money.GroupCreationCharge)) { + if (!money.AmountCovered(remoteClient.AgentId, money.GroupCreationCharge)) { remoteClient.SendCreateGroupReply(UUID.Zero, false, "You have got issuficient funds to create a group."); return UUID.Zero; } diff --git a/OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs b/OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs index 8fc50ff..9c838d0 100644 --- a/OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs +++ b/OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs @@ -775,11 +775,11 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule // Please do not refactor these to be just one method // Existing implementations need the distinction // - public bool UploadCovered(IClientAPI client, int amount) + public bool UploadCovered(UUID agentID, int amount) { return true; } - public bool AmountCovered(IClientAPI client, int amount) + public bool AmountCovered(UUID agentID, int amount) { return true; } -- cgit v1.1 From deeb7287a204af34caa24e7b221222de2fb3583b Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 28 Jan 2012 00:39:53 +0000 Subject: Comment out xfer section in Scene.UpdateTaskInventory() which was causing spurious errors and "script saved" messages when script properties were changed. Viewers since at least Linden Lab 1.23 use the script upload capability to save script changes. It's unknown whether the commented out code was working for very old viewers or not. Code is commented out to reduce complexity and so that useful error messages don't need to be removed. If there is a substantial population using extremely old viewers that can't upgrade to a newer version 1 viewer (e.g. 1.23) or similar TPV then this can be revisited. --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 33 +++++++++++++--------- 1 file changed, 20 insertions(+), 13 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index f344dcc..dd3208a 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -1472,20 +1472,27 @@ namespace OpenSim.Region.Framework.Scenes // m_log.DebugFormat( // "[PRIM INVENTORY]: Updating item {0} in {1} for UpdateTaskInventory()", // currentItem.Name, part.Name); - - IAgentAssetTransactions agentTransactions = this.RequestModuleInterface(); - if (agentTransactions != null) - { - agentTransactions.HandleTaskItemUpdateFromTransaction( - remoteClient, part, transactionID, currentItem); - if ((InventoryType)itemInfo.InvType == InventoryType.Notecard) - remoteClient.SendAgentAlertMessage("Notecard saved", false); - else if ((InventoryType)itemInfo.InvType == InventoryType.LSL) - remoteClient.SendAgentAlertMessage("Script saved", false); - else - remoteClient.SendAgentAlertMessage("Item saved", false); - } + // Viewers from at least Linden Lab 1.23 onwards use a capability to update script contents rather + // than UDP. With viewers from at least 1.23 onwards, changing properties on scripts (e.g. renaming) causes + // this to spew spurious errors and "thing saved" messages. + // Rather than retaining complexity in the code and removing useful error messages, I'm going to + // comment this section out. If this was still working for very old viewers and there is + // a large population using them which cannot upgrade to 1.23 or derivatives then we can revisit + // this - justincc +// IAgentAssetTransactions agentTransactions = this.RequestModuleInterface(); +// if (agentTransactions != null) +// { +// agentTransactions.HandleTaskItemUpdateFromTransaction( +// remoteClient, part, transactionID, currentItem); +// +// if ((InventoryType)itemInfo.InvType == InventoryType.Notecard) +// remoteClient.SendAgentAlertMessage("Notecard saved", false); +// else if ((InventoryType)itemInfo.InvType == InventoryType.LSL) +// remoteClient.SendAgentAlertMessage("Script saved", false); +// else +// remoteClient.SendAgentAlertMessage("Item saved", false); +// } // Base ALWAYS has move currentItem.BasePermissions |= (uint)PermissionMask.Move; -- cgit v1.1 From 154ba0124aaf0836ee50bce81a3441be6d11f06a Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 28 Jan 2012 02:21:41 +0000 Subject: Add experimental --publish option to "save oar" so that OARs reloaded to the same grid don't have the publisher as owner. --- OpenSim/Region/Application/OpenSim.cs | 8 ++- .../World/Archiver/ArchiveReadRequest.cs | 16 ++--- .../Archiver/ArchiveWriteRequestPreparation.cs | 3 - .../CoreModules/World/Archiver/ArchiverModule.cs | 1 + .../World/Archiver/Tests/ArchiverTests.cs | 83 +++++++++++++++++++++- .../Region/Framework/Scenes/SceneObjectGroup.cs | 6 ++ .../Scenes/Serialization/SceneObjectSerializer.cs | 20 ++++-- 7 files changed, 116 insertions(+), 21 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs index 8683476..145875b 100644 --- a/OpenSim/Region/Application/OpenSim.cs +++ b/OpenSim/Region/Application/OpenSim.cs @@ -291,12 +291,16 @@ namespace OpenSim m_console.Commands.AddCommand("region", false, "save oar", //"save oar [-v|--version=] [-p|--profile=] []", - "save oar [-h|--home=] [--noassets] [--perm=] []", + "save oar [-h|--home=] [--noassets] [--publish] [--perm=] []", "Save a region's data to an OAR archive.", // "-v|--version= generates scene objects as per older versions of the serialization (e.g. -v=0)" + Environment.NewLine "-h|--home= adds the url of the profile service to the saved user information." + Environment.NewLine + "--noassets stops assets being saved to the OAR." + Environment.NewLine - + "--perm stops objects with insufficient permissions from being saved to the OAR." + Environment.NewLine + + "--publish saves an OAR stripped of owner and last owner information." + Environment.NewLine + + " on reload, the estate owner will be the owner of all objects" + Environment.NewLine + + " this is useful if you're making oars generally available that might be reloaded to the same grid from which you published" + Environment.NewLine + + " this option is EXPERIMENTAL" + Environment.NewLine + + "--perm= stops objects with insufficient permissions from being saved to the OAR." + Environment.NewLine + " can contain one or more of these characters: \"C\" = Copy, \"T\" = Transfer" + Environment.NewLine + "The OAR path must be a filesystem path." + " If this is not given then the oar is saved to region.oar in the current directory.", diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs index edc5ba4..a6dbaba 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs @@ -116,6 +116,9 @@ namespace OpenSim.Region.CoreModules.World.Archiver m_merge = merge; m_skipAssets = skipAssets; m_requestId = requestId; + + // Zero can never be a valid user id + m_validUserUuids[UUID.Zero] = false; } public ArchiveReadRequest(Scene scene, Stream loadStream, bool merge, bool skipAssets, Guid requestId) @@ -125,6 +128,9 @@ namespace OpenSim.Region.CoreModules.World.Archiver m_merge = merge; m_skipAssets = skipAssets; m_requestId = requestId; + + // Zero can never be a valid user id + m_validUserUuids[UUID.Zero] = false; } /// @@ -368,16 +374,10 @@ namespace OpenSim.Region.CoreModules.World.Archiver if (!m_validUserUuids.ContainsKey(uuid)) { UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, uuid); - if (account != null) - m_validUserUuids.Add(uuid, true); - else - m_validUserUuids.Add(uuid, false); + m_validUserUuids.Add(uuid, account != null); } - if (m_validUserUuids[uuid]) - return true; - else - return false; + return m_validUserUuids[uuid]; } /// diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs index b895afe..ffcf063 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs @@ -282,10 +282,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver // always (incorrectly) includes the Copy bit set in this case. But that's a mistake: the viewer // does NOT show that the object has Everyone-Copy permissions, and doesn't allow it to be copied. if (permissionClass != PermissionClass.Owner) - { canTransfer |= (obj.EveryoneMask & (uint)PermissionMask.Copy) != 0; - } - bool partPermitted = true; if (checkPermissions.Contains("C") && !canCopy) diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs index 0b22598..f5a5a8d 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs @@ -142,6 +142,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver ops.Add("h|home=", delegate(string v) { options["home"] = v; }); ops.Add("noassets", delegate(string v) { options["noassets"] = v != null; }); + ops.Add("publish", v => options["wipe-owners"] = v != null); ops.Add("perm=", delegate(string v) { options["checkPermissions"] = v; }); List mainParams = ops.Parse(cmdparams); diff --git a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs index eec3c1b..63f1363 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs @@ -248,9 +248,6 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests Dictionary options = new Dictionary(); options.Add("noassets", true); m_archiverModule.ArchiveRegion(archiveWriteStream, requestId, options); - //AssetServerBase assetServer = (AssetServerBase)scene.CommsManager.AssetCache.AssetServer; - //while (assetServer.HasWaitingRequests()) - // assetServer.ProcessNextRequest(); // Don't wait for completion - with --noassets save oar happens synchronously // Monitor.Wait(this, 60000); @@ -410,6 +407,86 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests } /// + /// Test loading an OpenSim Region Archive saved with the --publish option. + /// + [Test] + public void TestLoadPublishedOar() + { + TestHelpers.InMethod(); +// log4net.Config.XmlConfigurator.Configure(); + + SceneObjectPart part1 = CreateSceneObjectPart1(); + SceneObjectGroup sog1 = new SceneObjectGroup(part1); + m_scene.AddNewSceneObject(sog1, false); + + SceneObjectPart part2 = CreateSceneObjectPart2(); + + AssetNotecard nc = new AssetNotecard(); + nc.BodyText = "Hello World!"; + nc.Encode(); + UUID ncAssetUuid = new UUID("00000000-0000-0000-1000-000000000000"); + UUID ncItemUuid = new UUID("00000000-0000-0000-1100-000000000000"); + AssetBase ncAsset + = AssetHelpers.CreateAsset(ncAssetUuid, AssetType.Notecard, nc.AssetData, UUID.Zero); + m_scene.AssetService.Store(ncAsset); + SceneObjectGroup sog2 = new SceneObjectGroup(part2); + TaskInventoryItem ncItem + = new TaskInventoryItem { Name = "ncItem", AssetID = ncAssetUuid, ItemID = ncItemUuid }; + part2.Inventory.AddInventoryItem(ncItem, true); + + m_scene.AddNewSceneObject(sog2, false); + + MemoryStream archiveWriteStream = new MemoryStream(); + m_scene.EventManager.OnOarFileSaved += SaveCompleted; + + Guid requestId = new Guid("00000000-0000-0000-0000-808080808080"); + + lock (this) + { + m_archiverModule.ArchiveRegion( + archiveWriteStream, requestId, new Dictionary() { { "wipe-owners", Boolean.TrueString } }); + + Monitor.Wait(this, 60000); + } + + Assert.That(m_lastRequestId, Is.EqualTo(requestId)); + + byte[] archive = archiveWriteStream.ToArray(); + MemoryStream archiveReadStream = new MemoryStream(archive); + + { + UUID estateOwner = TestHelpers.ParseTail(0x4747); + UUID objectOwner = TestHelpers.ParseTail(0x15); + + // Reload to new scene + ArchiverModule archiverModule = new ArchiverModule(); + SerialiserModule serialiserModule = new SerialiserModule(); + TerrainModule terrainModule = new TerrainModule(); + + TestScene scene2 = SceneHelpers.SetupScene(); + SceneHelpers.SetupSceneModules(scene2, archiverModule, serialiserModule, terrainModule); + + // Make sure there's a valid owner for the owner we saved (this should have been wiped if the code is + // behaving correctly + UserAccountHelpers.CreateUserWithInventory(scene2, objectOwner); + + scene2.RegionInfo.EstateSettings.EstateOwner = estateOwner; + + lock (this) + { + scene2.EventManager.OnOarFileLoaded += LoadCompleted; + archiverModule.DearchiveRegion(archiveReadStream); + } + + Assert.That(m_lastErrorMessage, Is.Null); + + SceneObjectGroup loadedSog = scene2.GetSceneObjectGroup(part1.Name); + Assert.That(loadedSog.OwnerID, Is.EqualTo(estateOwner)); + Assert.That(loadedSog.LastOwnerID, Is.EqualTo(estateOwner)); + } + } + + /// /// Test loading the region settings of an OpenSim Region Archive. /// [Test] diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index cad09b8..739c5fa 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -441,6 +441,12 @@ namespace OpenSim.Region.Framework.Scenes } } + public UUID LastOwnerID + { + get { return m_rootPart.LastOwnerID; } + set { m_rootPart.LastOwnerID = value; } + } + public UUID OwnerID { get { return m_rootPart.OwnerID; } diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index 7c60ddd..3a08271 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs @@ -1192,8 +1192,13 @@ namespace OpenSim.Region.Framework.Scenes.Serialization writer.WriteElementString("ObjectSaleType", sop.ObjectSaleType.ToString()); writer.WriteElementString("OwnershipCost", sop.OwnershipCost.ToString()); WriteUUID(writer, "GroupID", sop.GroupID, options); - WriteUUID(writer, "OwnerID", sop.OwnerID, options); - WriteUUID(writer, "LastOwnerID", sop.LastOwnerID, options); + + UUID ownerID = options.ContainsKey("wipe-owners") ? UUID.Zero : sop.OwnerID; + WriteUUID(writer, "OwnerID", ownerID, options); + + UUID lastOwnerID = options.ContainsKey("wipe-owners") ? UUID.Zero : sop.LastOwnerID; + WriteUUID(writer, "LastOwnerID", lastOwnerID, options); + writer.WriteElementString("BaseMask", sop.BaseMask.ToString()); writer.WriteElementString("OwnerMask", sop.OwnerMask.ToString()); writer.WriteElementString("GroupMask", sop.GroupMask.ToString()); @@ -1277,7 +1282,6 @@ namespace OpenSim.Region.Framework.Scenes.Serialization writer.WriteElementString("BasePermissions", item.BasePermissions.ToString()); writer.WriteElementString("CreationDate", item.CreationDate.ToString()); - WriteUUID(writer, "CreatorID", item.CreatorID, options); if (item.CreatorData != null && item.CreatorData != string.Empty) @@ -1298,10 +1302,16 @@ namespace OpenSim.Region.Framework.Scenes.Serialization writer.WriteElementString("InvType", item.InvType.ToString()); WriteUUID(writer, "ItemID", item.ItemID, options); WriteUUID(writer, "OldItemID", item.OldItemID, options); - WriteUUID(writer, "LastOwnerID", item.LastOwnerID, options); + + UUID lastOwnerID = options.ContainsKey("wipe-owners") ? UUID.Zero : item.LastOwnerID; + WriteUUID(writer, "LastOwnerID", lastOwnerID, options); + writer.WriteElementString("Name", item.Name); writer.WriteElementString("NextPermissions", item.NextPermissions.ToString()); - WriteUUID(writer, "OwnerID", item.OwnerID, options); + + UUID ownerID = options.ContainsKey("wipe-owners") ? UUID.Zero : item.OwnerID; + WriteUUID(writer, "OwnerID", ownerID, options); + writer.WriteElementString("CurrentPermissions", item.CurrentPermissions.ToString()); WriteUUID(writer, "ParentID", item.ParentID, options); WriteUUID(writer, "ParentPartID", item.ParentPartID, options); -- cgit v1.1 From 2ef9fd05fa7abaf06f971f0e0945cbcbe828f318 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 28 Jan 2012 02:45:13 +0000 Subject: Add an overloaded SceneObjectPart.UpdateTextureEntry(Primitive.TextureEntry texEntry) for region modules --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index ad3bcd5..36d3588 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -4520,10 +4520,18 @@ namespace OpenSim.Region.Framework.Scenes /// /// Update the texture entry for this part. /// - /// - public void UpdateTextureEntry(byte[] textureEntry) + /// + public void UpdateTextureEntry(byte[] serializedTextureEntry) + { + UpdateTextureEntry(new Primitive.TextureEntry(serializedTextureEntry, 0, serializedTextureEntry.Length)); + } + + /// + /// Update the texture entry for this part. + /// + /// + public void UpdateTextureEntry(Primitive.TextureEntry newTex) { - Primitive.TextureEntry newTex = new Primitive.TextureEntry(textureEntry, 0, textureEntry.Length); Primitive.TextureEntry oldTex = Shape.Textures; Changed changeFlags = 0; @@ -4555,7 +4563,7 @@ namespace OpenSim.Region.Framework.Scenes break; } - m_shape.TextureEntry = textureEntry; + m_shape.TextureEntry = newTex.GetBytes(); if (changeFlags != 0) TriggerScriptChangedEvent(changeFlags); UpdateFlag = UpdateRequired.FULL; -- cgit v1.1 From 2e31f12cf48deaa8ed98c35207e8e288a30d0841 Mon Sep 17 00:00:00 2001 From: Bo Iwu Date: Sat, 28 Jan 2012 11:11:15 +0100 Subject: Send CHANGED_TELEPORT during local TP again - partially revert cf73afec356eed30e169be3ce71edad89b4fdb37 Signed-off-by: BlueWall --- .../CoreModules/Framework/EntityTransfer/EntityTransferModule.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index cbef6ce..928bcd0 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs @@ -208,8 +208,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer foreach (SceneObjectGroup grp in sp.GetAttachments()) { - if (grp.IsDeleted) - sp.Scene.EventManager.TriggerOnScriptChangedEvent(grp.LocalId, (uint)Changed.TELEPORT); + sp.Scene.EventManager.TriggerOnScriptChangedEvent(grp.LocalId, (uint)Changed.TELEPORT); } } else // Another region possibly in another simulator -- cgit v1.1 From ae057a7589c3c2fa5f12e028db8ddc3e7832e92c Mon Sep 17 00:00:00 2001 From: BlueWall Date: Sat, 28 Jan 2012 10:36:39 -0500 Subject: Adding our parcel's generated id to map packets --- OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs index 4ae96f0..eac2743 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs @@ -464,7 +464,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap mapitem.x = (uint)(xstart + x); mapitem.y = (uint)(ystart + y); // mapitem.z = (uint)m_scene.GetGroundHeight(x,y); - mapitem.id = UUID.Zero; + mapitem.id = parcel.GlobalID; mapitem.name = parcel.Name; mapitem.Extra = parcel.Area; mapitem.Extra2 = parcel.SalePrice; @@ -1291,7 +1291,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap responsemapdata["X"] = OSD.FromInteger((int)(xstart + x)); responsemapdata["Y"] = OSD.FromInteger((int)(ystart + y)); // responsemapdata["Z"] = OSD.FromInteger((int)m_scene.GetGroundHeight(x,y)); - responsemapdata["ID"] = OSD.FromUUID(UUID.Zero); + responsemapdata["ID"] = OSD.FromUUID(parcel.GlobalID); responsemapdata["Name"] = OSD.FromString(parcel.Name); responsemapdata["Extra"] = OSD.FromInteger(parcel.Area); responsemapdata["Extra2"] = OSD.FromInteger(parcel.SalePrice); -- cgit v1.1 From e8b688b61f53e770ad2fbe3764f75e615e9b2bf8 Mon Sep 17 00:00:00 2001 From: PixelTomsen Date: Sun, 29 Jan 2012 20:15:43 +0100 Subject: Fix:Get embedded objects in notecard http://opensimulator.org/mantis/view.php?id=2607 Signed-off-by: nebadon --- .../Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 71 ++++++++++++++++++++++ 1 file changed, 71 insertions(+) (limited to 'OpenSim') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index 7bc59fc..cf0c28b 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -94,6 +94,7 @@ namespace OpenSim.Region.ClientStack.Linden private static readonly string m_notecardUpdatePath = "0004/"; private static readonly string m_notecardTaskUpdatePath = "0005/"; // private static readonly string m_fetchInventoryPath = "0006/"; + private static readonly string m_copyFromNotecardPath = "0007/"; // private static readonly string m_remoteParcelRequestPath = "0009/";// This is in the LandManagementModule. @@ -180,6 +181,7 @@ namespace OpenSim.Region.ClientStack.Linden m_HostCapsObj.RegisterHandler("UpdateNotecardAgentInventory", req); m_HostCapsObj.RegisterHandler("UpdateScriptAgentInventory", req); m_HostCapsObj.RegisterHandler("UpdateScriptAgent", req); + m_HostCapsObj.RegisterHandler("CopyInventoryFromNotecard", new RestStreamHandler("POST", capsBase + m_copyFromNotecardPath, CopyInventoryFromNotecard)); // As of RC 1.22.9 of the Linden client this is // supported @@ -723,6 +725,75 @@ namespace OpenSim.Region.ClientStack.Linden return LLSDHelpers.SerialiseLLSDReply(uploadResponse); } + + /// + /// Called by the CopyInventoryFromNotecard caps handler. + /// + /// + /// + /// + public string CopyInventoryFromNotecard(string request, string path, string param, + IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) + { + Hashtable response = new Hashtable(); + response["int_response_code"] = 404; + response["content_type"] = "text/plain"; + response["keepalive"] = false; + response["str_response_string"] = ""; + + try + { + OSDMap content = (OSDMap)OSDParser.DeserializeLLSDXml(request); + UUID objectID = content["object-id"].AsUUID(); + UUID notecardID = content["notecard-id"].AsUUID(); + UUID folderID = content["folder-id"].AsUUID(); + UUID itemID = content["item-id"].AsUUID(); + + // m_log.InfoFormat("[CAPS]: CopyInventoryFromNotecard, FolderID:{0}, ItemID:{1}, NotecardID:{2}, ObjectID:{3}", folderID, itemID, notecardID, objectID); + + if (objectID != UUID.Zero) + { + SceneObjectPart part = m_Scene.GetSceneObjectPart(objectID); + if (part != null) + { + TaskInventoryItem taskItem = part.Inventory.GetInventoryItem(notecardID); + if (!m_Scene.Permissions.CanCopyObjectInventory(notecardID, objectID, m_HostCapsObj.AgentID)) + { + return LLSDHelpers.SerialiseLLSDReply(response); + } + } + } + + InventoryItemBase item = null; + InventoryItemBase copyItem = null; + IClientAPI client = null; + + m_Scene.TryGetClient(m_HostCapsObj.AgentID, out client); + item = m_Scene.InventoryService.GetItem(new InventoryItemBase(itemID)); + if (item != null) + { + copyItem = m_Scene.GiveInventoryItem(m_HostCapsObj.AgentID, item.Owner, itemID, folderID); + if (copyItem != null && client != null) + { + m_log.InfoFormat("[CAPS]: CopyInventoryFromNotecard, ItemID:{0}, FolderID:{1}", copyItem.ID, copyItem.Folder); + client.SendBulkUpdateInventory(copyItem); + } + } + else + { + m_log.ErrorFormat("[CAPS]: CopyInventoryFromNotecard - Failed to retrieve item {0} from notecard {1}", itemID, notecardID); + if (client != null) + client.SendAlertMessage("Failed to retrieve item"); + } + } + catch (Exception e) + { + m_log.ErrorFormat("[CAPS]: CopyInventoryFromNotecard : {0}", e.ToString()); + } + + response["int_response_code"] = 200; + return LLSDHelpers.SerialiseLLSDReply(response); + } } public class AssetUploader -- cgit v1.1 From 5e60afe5ed6368ef94a15907a6c2042923f7b5f1 Mon Sep 17 00:00:00 2001 From: Garmin Kawaguichi Date: Sun, 29 Jan 2012 21:39:30 +0100 Subject: Fix llEdgeOfWorld functionality - see mantis http://opensimulator.org/mantis/view.php?id=5865 Signed-off-by: nebadon --- OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index fb5fd45..50fe218 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -5506,7 +5506,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api foreach (GridRegion sri in neighbors) { - if (sri.RegionLocX == neighborX && sri.RegionLocY == neighborY) + if (sri.RegionCoordX == neighborX && sri.RegionCoordY == neighborY) return 0; } -- cgit v1.1 From 3de534896efe4014f50b03624d3b9db82cd92cae Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 30 Jan 2012 16:22:21 +0000 Subject: Add ParcelImageID to RegionSettings so we can have that overlay. Warning: Contains a Migration. Warning: May contain nuts. --- OpenSim/Data/MySQL/MySQLSimulationData.cs | 6 ++++-- OpenSim/Data/MySQL/Resources/RegionStore.migrations | 6 ++++++ OpenSim/Framework/RegionSettings.cs | 8 ++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index 31d17f1..3123edf 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs @@ -997,7 +997,7 @@ namespace OpenSim.Data.MySQL "covenant, Sandbox, sunvectorx, sunvectory, " + "sunvectorz, loaded_creation_datetime, " + "loaded_creation_id, map_tile_ID, " + - "TelehubObject) " + + "TelehubObject, parcel_tile_ID) " + "values (?RegionUUID, ?BlockTerraform, " + "?BlockFly, ?AllowDamage, ?RestrictPushing, " + "?AllowLandResell, ?AllowLandJoinDivide, " + @@ -1013,7 +1013,7 @@ namespace OpenSim.Data.MySQL "?SunPosition, ?Covenant, ?Sandbox, " + "?SunVectorX, ?SunVectorY, ?SunVectorZ, " + "?LoadedCreationDateTime, ?LoadedCreationID, " + - "?TerrainImageID, ?TelehubObject) "; + "?TerrainImageID, ?TelehubObject, ?ParcelImageID) "; FillRegionSettingsCommand(cmd, rs); @@ -1301,6 +1301,7 @@ namespace OpenSim.Data.MySQL newSettings.LoadedCreationID = (String) row["loaded_creation_id"]; newSettings.TerrainImageID = DBGuid.FromDB(row["map_tile_ID"]); + newSettings.ParcelImageID = DBGuid.FromDB(row["parcel_tile_ID"]); newSettings.TelehubObject = DBGuid.FromDB(row["TelehubObject"]); return newSettings; @@ -1632,6 +1633,7 @@ namespace OpenSim.Data.MySQL cmd.Parameters.AddWithValue("LoadedCreationDateTime", settings.LoadedCreationDateTime); cmd.Parameters.AddWithValue("LoadedCreationID", settings.LoadedCreationID); cmd.Parameters.AddWithValue("TerrainImageID", settings.TerrainImageID); + cmd.Parameters.AddWithValue("ParcelImageID", settings.ParcelImageID); cmd.Parameters.AddWithValue("TelehubObject", settings.TelehubObject); } diff --git a/OpenSim/Data/MySQL/Resources/RegionStore.migrations b/OpenSim/Data/MySQL/Resources/RegionStore.migrations index 720e200..f9b5737 100644 --- a/OpenSim/Data/MySQL/Resources/RegionStore.migrations +++ b/OpenSim/Data/MySQL/Resources/RegionStore.migrations @@ -857,3 +857,9 @@ CREATE TABLE IF NOT EXISTS `spawn_points` ( ALTER TABLE `regionsettings` ADD COLUMN `TelehubObject` varchar(36) NOT NULL; COMMIT; +:VERSION 40 #---------------- Parcels for sale + +BEGIN; +ALTER TABLE `regionsettings` ADD COLUMN `parcel_tile_ID` char(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000'; +COMMIT; + diff --git a/OpenSim/Framework/RegionSettings.cs b/OpenSim/Framework/RegionSettings.cs index e115432..91e07df 100644 --- a/OpenSim/Framework/RegionSettings.cs +++ b/OpenSim/Framework/RegionSettings.cs @@ -373,6 +373,14 @@ namespace OpenSim.Framework set { m_SunVector = value; } } + private UUID m_ParcelImageID; + + public UUID ParcelImageID + { + get { return m_ParcelImageID; } + set { m_ParcelImageID = value; } + } + private UUID m_TerrainImageID; public UUID TerrainImageID -- cgit v1.1 From 00d1c88c59c10aa8d34fa36910cf0f1f0e9878b8 Mon Sep 17 00:00:00 2001 From: BlueWall Date: Mon, 30 Jan 2012 11:49:22 -0500 Subject: Pickup map overlay tile from RegionSettings.ParcelImageID --- OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs index eac2743..bbf6b05 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs @@ -1026,7 +1026,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap protected void MapBlockFromGridRegion(MapBlockData block, GridRegion r) { block.Access = r.Access; - block.MapImageId = r.TerrainImage; + block.MapImageId = m_scene.RegionInfo.RegionSettings.ParcelImageID; block.Name = r.RegionName; block.X = (ushort)(r.RegionLocX / Constants.RegionSize); block.Y = (ushort)(r.RegionLocY / Constants.RegionSize); -- cgit v1.1 From 54e6b2402c280b775c3ad8cba04e118bd8b57bda Mon Sep 17 00:00:00 2001 From: BlueWall Date: Mon, 30 Jan 2012 12:39:08 -0500 Subject: Revert "Pickup map overlay tile from RegionSettings.ParcelImageID" This reverts commit 00d1c88c59c10aa8d34fa36910cf0f1f0e9878b8. Need to dig a little deeper to see exactly how V1 viewers are using this --- OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs index bbf6b05..eac2743 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs @@ -1026,7 +1026,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap protected void MapBlockFromGridRegion(MapBlockData block, GridRegion r) { block.Access = r.Access; - block.MapImageId = m_scene.RegionInfo.RegionSettings.ParcelImageID; + block.MapImageId = r.TerrainImage; block.Name = r.RegionName; block.X = (ushort)(r.RegionLocX / Constants.RegionSize); block.Y = (ushort)(r.RegionLocY / Constants.RegionSize); -- cgit v1.1 From 9d93c4808e0a0171bcb43fc551f3fb37b684c499 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 30 Jan 2012 19:21:58 +0000 Subject: lock SceneObjectGroupsByFullID in SceneGraph.ForEachSOG() to stop failure if SceneObjectGroupsByFullID is updated elsewhere at the same time. --- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 7f18140..36a454e 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -1137,8 +1137,10 @@ namespace OpenSim.Region.Framework.Scenes /// protected internal void ForEachSOG(Action action) { - // FIXME: Need to lock here, really. - List objlist = new List(SceneObjectGroupsByFullID.Values); + List objlist; + lock (SceneObjectGroupsByFullID) + objlist = new List(SceneObjectGroupsByFullID.Values); + foreach (SceneObjectGroup obj in objlist) { try @@ -1147,7 +1149,7 @@ namespace OpenSim.Region.Framework.Scenes } catch (Exception e) { - // Catch it and move on. This includes situations where splist has inconsistent info + // Catch it and move on. This includes situations where objlist has inconsistent info m_log.WarnFormat( "[SCENEGRAPH]: Problem processing action in ForEachSOG: {0} {1}", e.Message, e.StackTrace); } @@ -1382,10 +1384,10 @@ namespace OpenSim.Region.Framework.Scenes /// /// Update the texture entry of the given prim. /// - /// + /// /// A texture entry is an object that contains details of all the textures of the prim's face. In this case, /// the texture is given in its byte serialized form. - /// + /// /// /// /// -- cgit v1.1 From df9c35bc0f12cfd64414c5cf1c4a7f135884f2ee Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 30 Jan 2012 19:46:55 +0000 Subject: Some plumbing for map overlays --- .../CoreModules/World/WorldMap/WorldMapModule.cs | 35 ++++++++++++---------- 1 file changed, 20 insertions(+), 15 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs index bbf6b05..103d128 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs @@ -955,8 +955,8 @@ namespace OpenSim.Region.CoreModules.World.WorldMap { List response = new List(); - // this should return one mapblock at most. - // (diva note: why?? in that case we should GetRegionByPosition) + // this should return one mapblock at most. It is triggered by a click + // on an unloaded square. // But make sure: Look whether the one we requested is in there List regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID, minX * (int)Constants.RegionSize, @@ -973,7 +973,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap { // found it => add it to response MapBlockData block = new MapBlockData(); - MapBlockFromGridRegion(block, r); + MapBlockFromGridRegion(block, r, flag); response.Add(block); break; } @@ -989,10 +989,8 @@ namespace OpenSim.Region.CoreModules.World.WorldMap block.Access = 254; // means 'simulator is offline' response.Add(block); } - if ((flag & 2) == 2) // V2 !!! - remoteClient.SendMapBlock(response, 2); - else - remoteClient.SendMapBlock(response, 0); + // The lower 16 bits are an unsigned int16 + remoteClient.SendMapBlock(response, flags & 0xffff); } else { @@ -1012,21 +1010,28 @@ namespace OpenSim.Region.CoreModules.World.WorldMap foreach (GridRegion r in regions) { MapBlockData block = new MapBlockData(); - MapBlockFromGridRegion(block, r); + MapBlockFromGridRegion(block, r, flag); mapBlocks.Add(block); } - if ((flag & 2) == 2) // V2 !!! - remoteClient.SendMapBlock(mapBlocks, 2); - else - remoteClient.SendMapBlock(mapBlocks, 0); + remoteClient.SendMapBlock(mapBlocks, flag & 0xffff); return mapBlocks; } - protected void MapBlockFromGridRegion(MapBlockData block, GridRegion r) + protected void MapBlockFromGridRegion(MapBlockData block, GridRegion r, uint flag) { block.Access = r.Access; - block.MapImageId = m_scene.RegionInfo.RegionSettings.ParcelImageID; + switch (flag & 0xffff) + { + case 0: + block.MapImageId = m_scene.RegionInfo.RegionSettings.ParcelImageID; + break; + case 2: + block.MapImageId = m_scene.RegionInfo.RegionSettings.ParcelImageID; + break; + default: + block.MapImageId = UUID.Zero; + } block.Name = r.RegionName; block.X = (ushort)(r.RegionLocX / Constants.RegionSize); block.Y = (ushort)(r.RegionLocY / Constants.RegionSize); @@ -1160,7 +1165,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap foreach (GridRegion r in regions) { MapBlockData mapBlock = new MapBlockData(); - MapBlockFromGridRegion(mapBlock, r); + MapBlockFromGridRegion(mapBlock, r, 0); AssetBase texAsset = m_scene.AssetService.Get(mapBlock.MapImageId.ToString()); if (texAsset != null) -- cgit v1.1 From bde2ff5e78360061be89e4c5717f4d67248d9185 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 30 Jan 2012 20:11:47 +0000 Subject: Next step for world map overlays --- OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs | 5 +++-- OpenSim/Services/Interfaces/IGridService.cs | 9 ++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs index 103d128..c81eeeb 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs @@ -263,7 +263,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap foreach (GridRegion r in regions) { MapBlockData block = new MapBlockData(); - MapBlockFromGridRegion(block, r); + MapBlockFromGridRegion(block, r, 0); mapBlocks.Add(block); } avatarPresence.ControllingClient.SendMapBlock(mapBlocks, 0); @@ -990,7 +990,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap response.Add(block); } // The lower 16 bits are an unsigned int16 - remoteClient.SendMapBlock(response, flags & 0xffff); + remoteClient.SendMapBlock(response, flag & 0xffff); } else { @@ -1031,6 +1031,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap break; default: block.MapImageId = UUID.Zero; + break; } block.Name = r.RegionName; block.X = (ushort)(r.RegionLocX / Constants.RegionSize); diff --git a/OpenSim/Services/Interfaces/IGridService.cs b/OpenSim/Services/Interfaces/IGridService.cs index 7137f9a..d809996 100644 --- a/OpenSim/Services/Interfaces/IGridService.cs +++ b/OpenSim/Services/Interfaces/IGridService.cs @@ -190,6 +190,7 @@ namespace OpenSim.Services.Interfaces public UUID ScopeID = UUID.Zero; public UUID TerrainImage = UUID.Zero; + public UUID ParcelImage = UUID.Zero; public byte Access; public int Maturity; public string RegionSecret = string.Empty; @@ -236,6 +237,7 @@ namespace OpenSim.Services.Interfaces RegionID = ConvertFrom.RegionID; ServerURI = ConvertFrom.ServerURI; TerrainImage = ConvertFrom.RegionSettings.TerrainImageID; + ParcelImage = ConvertFrom.RegionSettings.ParcelImageID; Access = ConvertFrom.AccessLevel; Maturity = ConvertFrom.RegionSettings.Maturity; RegionSecret = ConvertFrom.regionSecret; @@ -253,6 +255,7 @@ namespace OpenSim.Services.Interfaces RegionID = ConvertFrom.RegionID; ServerURI = ConvertFrom.ServerURI; TerrainImage = ConvertFrom.TerrainImage; + ParcelImage = ConvertFrom.ParcelImage; Access = ConvertFrom.Access; Maturity = ConvertFrom.Maturity; RegionSecret = ConvertFrom.RegionSecret; @@ -281,7 +284,7 @@ namespace OpenSim.Services.Interfaces public override int GetHashCode() { - return RegionID.GetHashCode() ^ TerrainImage.GetHashCode(); + return RegionID.GetHashCode() ^ TerrainImage.GetHashCode() ^ ParcelImage.GetHashCode(); } #endregion @@ -359,6 +362,7 @@ namespace OpenSim.Services.Interfaces kvp["serverURI"] = ServerURI; kvp["serverPort"] = InternalEndPoint.Port.ToString(); kvp["regionMapTexture"] = TerrainImage.ToString(); + kvp["parcelMapTexture"] = ParcelImage.ToString(); kvp["access"] = Access.ToString(); kvp["regionSecret"] = RegionSecret; kvp["owner_uuid"] = EstateOwner.ToString(); @@ -411,6 +415,9 @@ namespace OpenSim.Services.Interfaces if (kvp.ContainsKey("regionMapTexture")) UUID.TryParse((string)kvp["regionMapTexture"], out TerrainImage); + if (kvp.ContainsKey("parcelMapTexture")) + UUID.TryParse((string)kvp["parcelMapTexture"], out ParcelImage); + if (kvp.ContainsKey("access")) Access = Byte.Parse((string)kvp["access"]); -- cgit v1.1 From c4cc626dffd87b6ab28f40c847db2def95e189b7 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 30 Jan 2012 20:34:32 +0000 Subject: Add the needed column in the regions table and a few tweaks. Warning: Contains a Migration Warning: Cannot guarantee nut free --- OpenSim/Data/MySQL/Resources/GridStore.migrations | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'OpenSim') diff --git a/OpenSim/Data/MySQL/Resources/GridStore.migrations b/OpenSim/Data/MySQL/Resources/GridStore.migrations index eda6dbb..98ba8c5 100644 --- a/OpenSim/Data/MySQL/Resources/GridStore.migrations +++ b/OpenSim/Data/MySQL/Resources/GridStore.migrations @@ -94,3 +94,12 @@ BEGIN; alter table regions modify column regionName varchar(128) default NULL; COMMIT; + +:VERSION 9 # ------------ + +BEGIN; + +alter table regions add column `parcelMapTexture` varchar(36) default NULL; + +COMMIT; + -- cgit v1.1 From 53c3faac5d3102cf9bd7d348acaac9a07804f382 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 30 Jan 2012 21:24:21 +0000 Subject: Patch in the rest of the maptile stuff --- OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs index c81eeeb..ac95598 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs @@ -1348,6 +1348,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap m_log.Debug("[WORLDMAP]: STORING MAPTILE IMAGE"); UUID terrainImageID = UUID.Random(); + UUID parcelImageID = UUID.Zero; // UUID.Random(); AssetBase asset = new AssetBase( terrainImageID, @@ -1364,13 +1365,16 @@ namespace OpenSim.Region.CoreModules.World.WorldMap m_scene.AssetService.Store(asset); // Switch to the new one - UUID lastMapRegionUUID = m_scene.RegionInfo.RegionSettings.TerrainImageID; + UUID lastTerrainImageID = m_scene.RegionInfo.RegionSettings.TerrainImageID; + UUID lastParcelImageID = m_scene.RegionInfo.RegionSettings.TerrainImageID; m_scene.RegionInfo.RegionSettings.TerrainImageID = terrainImageID; + m_scene.RegionInfo.RegionSettings.ParcelImageID = parcelImageID; m_scene.RegionInfo.RegionSettings.Save(); // Delete the old one - m_log.DebugFormat("[WORLDMAP]: Deleting old map tile {0}", lastMapRegionUUID); - m_scene.AssetService.Delete(lastMapRegionUUID.ToString()); + // m_log.DebugFormat("[WORLDMAP]: Deleting old map tile {0}", lastTerrainImageID); + m_scene.AssetService.Delete(lastTerrainImageID.ToString()); + m_scene.AssetService.Delete(lastParcelImageID.ToString()); } private void MakeRootAgent(ScenePresence avatar) -- cgit v1.1 From 2b84b6d8b1216d01aef4ad5fad513176e0867c6d Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 30 Jan 2012 21:38:46 +0000 Subject: Use the requested sim's map, not our own --- OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs index ac95598..e42c946 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs @@ -1024,10 +1024,10 @@ namespace OpenSim.Region.CoreModules.World.WorldMap switch (flag & 0xffff) { case 0: - block.MapImageId = m_scene.RegionInfo.RegionSettings.ParcelImageID; + block.MapImageId = r.TerrainImage; break; case 2: - block.MapImageId = m_scene.RegionInfo.RegionSettings.ParcelImageID; + block.MapImageId = r.ParcelImage; break; default: block.MapImageId = UUID.Zero; -- cgit v1.1 From d2dfa4cfe7aadfed0611fb31414d9c8fff420b24 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 31 Jan 2012 03:09:44 +0000 Subject: Make parcel sale overlays work. No auction support. --- OpenSim/Region/Application/OpenSimBase.cs | 6 +- .../CoreModules/World/WorldMap/WorldMapModule.cs | 88 +++++++++++++++++++++- 2 files changed, 87 insertions(+), 7 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs index a680a59..f482d8f 100644 --- a/OpenSim/Region/Application/OpenSimBase.cs +++ b/OpenSim/Region/Application/OpenSimBase.cs @@ -383,6 +383,9 @@ namespace OpenSim // TODO : Try setting resource for region xstats here on scene MainServer.Instance.AddStreamHandler(new Region.Framework.Scenes.RegionStatsHandler(regionInfo)); + scene.loadAllLandObjectsFromStorage(regionInfo.originRegionID); + scene.EventManager.TriggerParcelPrimCountUpdate(); + try { scene.RegisterRegionWithGrid(); @@ -398,9 +401,6 @@ namespace OpenSim Environment.Exit(1); } - scene.loadAllLandObjectsFromStorage(regionInfo.originRegionID); - scene.EventManager.TriggerParcelPrimCountUpdate(); - // We need to do this after we've initialized the // scripting engines. scene.CreateScriptInstances(); diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs index e42c946..6c6aa37 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs @@ -213,7 +213,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap UUID agentID, Caps caps) { //try - //{ + // //m_log.DebugFormat("[MAPLAYER]: path: {0}, param: {1}, agent:{2}", // path, param, agentID.ToString()); @@ -1345,10 +1345,12 @@ namespace OpenSim.Region.CoreModules.World.WorldMap if (data == null) return; + byte[] overlay = GenerateOverlay(); + m_log.Debug("[WORLDMAP]: STORING MAPTILE IMAGE"); UUID terrainImageID = UUID.Random(); - UUID parcelImageID = UUID.Zero; // UUID.Random(); + UUID parcelImageID = UUID.Zero; AssetBase asset = new AssetBase( terrainImageID, @@ -1364,9 +1366,26 @@ namespace OpenSim.Region.CoreModules.World.WorldMap m_log.DebugFormat("[WORLDMAP]: Storing map tile {0}", asset.ID); m_scene.AssetService.Store(asset); + if (overlay != null) + { + parcelImageID = UUID.Random(); + + AssetBase parcels = new AssetBase( + parcelImageID, + "parcelImage_" + m_scene.RegionInfo.RegionID.ToString(), + (sbyte)AssetType.Texture, + m_scene.RegionInfo.RegionID.ToString()); + parcels.Data = overlay; + parcels.Description = m_scene.RegionInfo.RegionName; + parcels.Temporary = false; + parcels.Flags = AssetFlags.Maptile; + + m_scene.AssetService.Store(parcels); + } + // Switch to the new one UUID lastTerrainImageID = m_scene.RegionInfo.RegionSettings.TerrainImageID; - UUID lastParcelImageID = m_scene.RegionInfo.RegionSettings.TerrainImageID; + UUID lastParcelImageID = m_scene.RegionInfo.RegionSettings.ParcelImageID; m_scene.RegionInfo.RegionSettings.TerrainImageID = terrainImageID; m_scene.RegionInfo.RegionSettings.ParcelImageID = parcelImageID; m_scene.RegionInfo.RegionSettings.Save(); @@ -1374,7 +1393,8 @@ namespace OpenSim.Region.CoreModules.World.WorldMap // Delete the old one // m_log.DebugFormat("[WORLDMAP]: Deleting old map tile {0}", lastTerrainImageID); m_scene.AssetService.Delete(lastTerrainImageID.ToString()); - m_scene.AssetService.Delete(lastParcelImageID.ToString()); + if (lastParcelImageID != UUID.Zero) + m_scene.AssetService.Delete(lastParcelImageID.ToString()); } private void MakeRootAgent(ScenePresence avatar) @@ -1420,6 +1440,66 @@ namespace OpenSim.Region.CoreModules.World.WorldMap } } + private Byte[] GenerateOverlay() + { + Bitmap overlay = new Bitmap(256, 256); + + bool[,] saleBitmap = new bool[64, 64]; + for (int x = 0 ; x < 64 ; x++) + { + for (int y = 0 ; y < 64 ; y++) + saleBitmap[x, y] = false; + } + + bool landForSale = false; + + List parcels = m_scene.LandChannel.AllParcels(); + + Color background = Color.FromArgb(0, 0, 0, 0); + SolidBrush transparent = new SolidBrush(background); + Graphics g = Graphics.FromImage(overlay); + g.FillRectangle(transparent, 0, 0, 256, 256); + + SolidBrush yellow = new SolidBrush(Color.FromArgb(255, 249, 223, 9)); + + foreach (ILandObject land in parcels) + { + // m_log.DebugFormat("[WORLD MAP]: Parcel {0} flags {1}", land.LandData.Name, land.LandData.Flags); + if ((land.LandData.Flags & (uint)ParcelFlags.ForSale) != 0) + { + landForSale = true; + + saleBitmap = land.MergeLandBitmaps(saleBitmap, land.GetLandBitmap()); + } + } + + if (!landForSale) + { + m_log.DebugFormat("[WORLD MAP]: Region {0} has no parcels for sale, not geenrating overlay", m_scene.RegionInfo.RegionName); + return null; + } + + m_log.DebugFormat("[WORLD MAP]: Region {0} has parcels for sale, genrating overlay", m_scene.RegionInfo.RegionName); + + for (int x = 0 ; x < 64 ; x++) + { + for (int y = 0 ; y < 64 ; y++) + { + if (saleBitmap[x, y]) + g.FillRectangle(yellow, x * 4, 252 - (y * 4), 4, 4); + } + } + + try + { + return OpenJPEG.EncodeFromImage(overlay, true); + } + catch (Exception e) + { + m_log.DebugFormat("[WORLD MAP]: Error creating parcel overlay: " + e.ToString()); + } + return null; + } } public struct MapRequestState -- cgit v1.1 From a98a146c50964c9d55d9cf512fa48df015fa8aaf Mon Sep 17 00:00:00 2001 From: PixelTomsen Date: Tue, 31 Jan 2012 17:44:39 +0100 Subject: Fix:llSetText - limited text to a maximum of 254 chars mantis: http://opensimulator.org/mantis/view.php?id=5867 Signed-off-by: nebadon --- OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 50fe218..67dee02 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -4039,9 +4039,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api Vector3 av3 = new Vector3(Util.Clip((float)color.x, 0.0f, 1.0f), Util.Clip((float)color.y, 0.0f, 1.0f), Util.Clip((float)color.z, 0.0f, 1.0f)); - m_host.SetText(text, av3, Util.Clip((float)alpha, 0.0f, 1.0f)); - m_host.ParentGroup.HasGroupChanged = true; - m_host.ParentGroup.ScheduleGroupForFullUpdate(); + m_host.SetText(text.Length > 254 ? text.Remove(255) : text, av3, Util.Clip((float)alpha, 0.0f, 1.0f)); + //m_host.ParentGroup.HasGroupChanged = true; + //m_host.ParentGroup.ScheduleGroupForFullUpdate(); } public LSL_Float llWater(LSL_Vector offset) -- cgit v1.1 From f3780b9eaeae8834c49f6e2f6045ef922916924d Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 31 Jan 2012 19:56:37 +0000 Subject: Add torture tests to test adding 10,000, 100,000 and 200,000 single prim scene objects. These can be run using the "nant torture" target. They are not part of "nant test" due to their long-run future nature. Such tests are designed to do some testing of extreme situations and give some feedback on memory usage, etc. However, data can be inconsistent due to different machine circumstances and virtual machine actions. This area is under development. --- OpenSim/Region/Framework/Scenes/Scene.cs | 2 + OpenSim/Region/Framework/Scenes/SceneGraph.cs | 6 ++ OpenSim/Tests/Torture/ObjectTortureTests.cs | 126 ++++++++++++++++++++++++++ 3 files changed, 134 insertions(+) create mode 100644 OpenSim/Tests/Torture/ObjectTortureTests.cs (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 984058c..975d769 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -1943,6 +1943,7 @@ namespace OpenSim.Region.Framework.Scenes /// If true, the object is made persistent into the scene. /// If false, the object will not persist over server restarts /// + /// true if the object was added. false if not public bool AddNewSceneObject(SceneObjectGroup sceneObject, bool attachToBackup) { return AddNewSceneObject(sceneObject, attachToBackup, true); @@ -1960,6 +1961,7 @@ namespace OpenSim.Region.Framework.Scenes /// If true, updates for the new scene object are sent to all viewers in range. /// If false, it is left to the caller to schedule the update /// + /// true if the object was added. false if not public bool AddNewSceneObject(SceneObjectGroup sceneObject, bool attachToBackup, bool sendClientUpdates) { if (m_sceneGraph.AddNewSceneObject(sceneObject, attachToBackup, sendClientUpdates)) diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 36a454e..006f9c6 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -357,7 +357,13 @@ namespace OpenSim.Region.Framework.Scenes return false; if (Entities.ContainsKey(sceneObject.UUID)) + { +// m_log.DebugFormat( +// "[SCENEGRAPH]: Scene graph for {0} already contains object {1} in AddSceneObject()", +// m_parentScene.RegionInfo.RegionName, sceneObject.UUID); + return false; + } // m_log.DebugFormat( // "[SCENEGRAPH]: Adding scene object {0} {1}, with {2} parts on {3}", diff --git a/OpenSim/Tests/Torture/ObjectTortureTests.cs b/OpenSim/Tests/Torture/ObjectTortureTests.cs new file mode 100644 index 0000000..cdbaa66 --- /dev/null +++ b/OpenSim/Tests/Torture/ObjectTortureTests.cs @@ -0,0 +1,126 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Diagnostics; +using System.Reflection; +using log4net; +using NUnit.Framework; +using OpenMetaverse; +using OpenSim.Framework; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Tests.Common; +using OpenSim.Tests.Common.Mock; + +namespace OpenSim.Tests.Torture +{ + /// + /// Object torture tests + /// + /// + /// Don't rely on the numbers given by these tests - they will vary a lot depending on what is already cached, + /// how much memory is free, etc. In some cases, later larger tests will apparently take less time than smaller + /// earlier tests. + /// + [TestFixture] + public class ObjectTortureTests + { +// [Test] +// public void Test0000Clean() +// { +// TestHelpers.InMethod(); +//// log4net.Config.XmlConfigurator.Configure(); +// +// TestAddObjects(200000); +// } + + [Test] + public void Test0001TenThousandObjects() + { + TestHelpers.InMethod(); +// log4net.Config.XmlConfigurator.Configure(); + + TestAddObjects(10000); + } + + [Test] + public void Test0002OneHundredThousandObjects() + { + TestHelpers.InMethod(); +// log4net.Config.XmlConfigurator.Configure(); + + TestAddObjects(100000); + } + + [Test] + public void Test0003TwoHundredThousandObjects() + { + TestHelpers.InMethod(); +// log4net.Config.XmlConfigurator.Configure(); + + TestAddObjects(200000); + } + + private void TestAddObjects(int objectsToAdd) + { + UUID ownerId = new UUID("F0000000-0000-0000-0000-000000000000"); + + TestScene scene = SceneHelpers.SetupScene(); + + Process process = Process.GetCurrentProcess(); +// long startProcessMemory = process.PrivateMemorySize64; + long startGcMemory = GC.GetTotalMemory(true); + DateTime start = DateTime.Now; + + for (int i = 1; i <= objectsToAdd; i++) + { + SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, ownerId, "part_", i); + Assert.That(scene.AddNewSceneObject(so, false), Is.True, string.Format("Object {0} was not created", i)); + } + + TimeSpan elapsed = DateTime.Now - start; +// long processMemoryAlloc = process.PrivateMemorySize64 - startProcessMemory; + long processGcAlloc = GC.GetTotalMemory(false) - startGcMemory; + + for (int i = 1; i <= objectsToAdd; i++) + { + Assert.That( + scene.GetSceneObjectGroup(TestHelpers.ParseTail(i)), + Is.Not.Null, + string.Format("Object {0} could not be retrieved", i)); + } + +// Console.WriteLine( +// "Took {0}ms, {1}MB to create {2} single prim scene objects", +// elapsed.Milliseconds, processGcAlloc / 1024 / 1024, objectsToAdd); + + Console.WriteLine( + "Took {0}MB to create {1} single prim scene objects", + processGcAlloc / 1024 / 1024, objectsToAdd); + } + } +} \ No newline at end of file -- cgit v1.1 From 10b9348071094122d5e2dd636f7cce9c0b25f0a9 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 31 Jan 2012 20:30:30 +0000 Subject: Remove scene object null check on SceneGraph.AddSceneObject(). Complain explicitly if there's an attempt to add any object with a zero UUID. Callers themselves need to check that they're not attempting to add a null scene object. --- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 006f9c6..06de72f 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -353,8 +353,14 @@ namespace OpenSim.Region.Framework.Scenes /// protected bool AddSceneObject(SceneObjectGroup sceneObject, bool attachToBackup, bool sendClientUpdates) { - if (sceneObject == null || sceneObject.RootPart.UUID == UUID.Zero) + if (sceneObject.UUID == UUID.Zero) + { + m_log.ErrorFormat( + "[SCENEGRAPH]: Tried to add scene object {0} to {1} with illegal UUID of {2}", + sceneObject.Name, m_parentScene.RegionInfo.RegionName, UUID.Zero); + return false; + } if (Entities.ContainsKey(sceneObject.UUID)) { -- cgit v1.1 From 1505c22995e411af0c7e29d0331cdf244d69fd4c Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 31 Jan 2012 21:09:26 +0000 Subject: Use Environment.TickCount & Int32.MaxValue; instead of Util.EnvironmentTickCount(); when producing the threads report to reduce wraparound. This matches the tickcount masking in the thread watchdog. For some reason, Util.EnvironmentTickCount() masks ticks by 0x3fffffff instead of 0xffffffff --- OpenSim/Framework/Servers/BaseOpenSimServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/Servers/BaseOpenSimServer.cs b/OpenSim/Framework/Servers/BaseOpenSimServer.cs index 4c381d0..545e76c 100644 --- a/OpenSim/Framework/Servers/BaseOpenSimServer.cs +++ b/OpenSim/Framework/Servers/BaseOpenSimServer.cs @@ -251,7 +251,7 @@ namespace OpenSim.Framework.Servers sb.Append(threads.Length + " threads are being tracked:" + Environment.NewLine); - int timeNow = Util.EnvironmentTickCount(); + int timeNow = Environment.TickCount & Int32.MaxValue; sb.AppendFormat(reportFormat, "ID", "NAME", "LAST UPDATE (MS)", "LIFETIME (MS)", "PRIORITY", "STATE"); sb.Append(Environment.NewLine); -- cgit v1.1 From 2f84d5397bcce4c8de0c0cf70cb65307e9e37908 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 31 Jan 2012 21:14:09 +0000 Subject: minor: remove mono compiler warning --- OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index 29ad966..a7bf06d 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -9252,9 +9252,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP { param1 = Convert.ToUInt32(Utils.BytesToString(messagePacket.ParamList[1].Parameter)); } - catch (Exception ex) + catch { - } } -- cgit v1.1 From 9bd02b5da19ae758bfb7a543976b26ced0cd1ba2 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 31 Jan 2012 21:57:45 +0000 Subject: Move object delete commands into a commands region module, in preparation for adding similar show commands. --- .../World/Objects/Commands/ObjectCommandsModule.cs | 206 +++++++++++++++++++++ OpenSim/Region/Framework/Scenes/Scene.cs | 104 ----------- 2 files changed, 206 insertions(+), 104 deletions(-) create mode 100644 OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs b/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs new file mode 100644 index 0000000..57c109e --- /dev/null +++ b/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs @@ -0,0 +1,206 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using System.Reflection; +using System.Text; +using log4net; +using Mono.Addins; +using Nini.Config; +using OpenMetaverse; +using OpenSim.Framework; +using OpenSim.Framework.Console; +using OpenSim.Framework.Statistics; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.Framework.Scenes; + +namespace OpenSim.Region.CoreModules.World.Objects.Commands +{ + /// + /// A module that holds commands for manipulating objects in the scene. + /// + [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "ObjectCommandsModule")] + public class ObjectCommandsModule : INonSharedRegionModule + { +// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + private Scene m_scene; + + public string Name { get { return "Object Commands Module"; } } + + public Type ReplaceableInterface { get { return null; } } + + public void Initialise(IConfigSource source) + { +// m_log.DebugFormat("[OBJECT COMMANDS MODULE]: INITIALIZED MODULE"); + } + + public void PostInitialise() + { +// m_log.DebugFormat("[OBJECT COMMANDS MODULE]: POST INITIALIZED MODULE"); + } + + public void Close() + { +// m_log.DebugFormat("[OBJECT COMMANDS MODULE]: CLOSED MODULE"); + } + + public void AddRegion(Scene scene) + { +// m_log.DebugFormat("[OBJECT COMMANDS MODULE]: REGION {0} ADDED", scene.RegionInfo.RegionName); + + m_scene = scene; + } + + public void RemoveRegion(Scene scene) + { +// m_log.DebugFormat("[OBJECTS COMMANDS MODULE]: REGION {0} REMOVED", scene.RegionInfo.RegionName); + } + + public void RegionLoaded(Scene scene) + { +// m_log.DebugFormat("[OBJECTS COMMANDS MODULE]: REGION {0} LOADED", scene.RegionInfo.RegionName); + + MainConsole.Instance.Commands.AddCommand("region", false, "delete object owner", + "delete object owner ", + "Delete object by owner", HandleDeleteObject); + MainConsole.Instance.Commands.AddCommand("region", false, "delete object creator", + "delete object creator ", + "Delete object by creator", HandleDeleteObject); + MainConsole.Instance.Commands.AddCommand("region", false, "delete object uuid", + "delete object uuid ", + "Delete object by uuid", HandleDeleteObject); + MainConsole.Instance.Commands.AddCommand("region", false, "delete object name", + "delete object name ", + "Delete object by name", HandleDeleteObject); + MainConsole.Instance.Commands.AddCommand("region", false, "delete object outside", + "delete object outside", + "Delete all objects outside boundaries", HandleDeleteObject); + } + + private void HandleDeleteObject(string module, string[] cmd) + { + if (cmd.Length < 3) + return; + + string mode = cmd[2]; + string o = ""; + + if (mode != "outside") + { + if (cmd.Length < 4) + return; + + o = cmd[3]; + } + + List deletes = new List(); + + UUID match; + + switch (mode) + { + case "owner": + if (!UUID.TryParse(o, out match)) + return; + + m_scene.ForEachSOG(delegate (SceneObjectGroup g) + { + if (g.OwnerID == match && !g.IsAttachment) + deletes.Add(g); + }); + + break; + + case "creator": + if (!UUID.TryParse(o, out match)) + return; + + m_scene.ForEachSOG(delegate (SceneObjectGroup g) + { + if (g.RootPart.CreatorID == match && !g.IsAttachment) + deletes.Add(g); + }); + + break; + + case "uuid": + if (!UUID.TryParse(o, out match)) + return; + + m_scene.ForEachSOG(delegate (SceneObjectGroup g) + { + if (g.UUID == match && !g.IsAttachment) + deletes.Add(g); + }); + + break; + + case "name": + m_scene.ForEachSOG(delegate (SceneObjectGroup g) + { + if (g.RootPart.Name == o && !g.IsAttachment) + deletes.Add(g); + }); + + break; + + case "outside": + m_scene.ForEachSOG(delegate (SceneObjectGroup g) + { + SceneObjectPart rootPart = g.RootPart; + bool delete = false; + + if (rootPart.GroupPosition.Z < 0.0 || rootPart.GroupPosition.Z > 10000.0) + { + delete = true; + } + else + { + ILandObject parcel + = m_scene.LandChannel.GetLandObject(rootPart.GroupPosition.X, rootPart.GroupPosition.Y); + + if (parcel == null || parcel.LandData.Name == "NO LAND") + delete = true; + } + + if (delete && !g.IsAttachment && !deletes.Contains(g)) + deletes.Add(g); + }); + + break; + } + + foreach (SceneObjectGroup g in deletes) + { + MainConsole.Instance.OutputFormat("Deleting object {0}", g.UUID); + m_scene.DeleteSceneObject(g, false); + } + } + } +} \ No newline at end of file diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 975d769..df6c88f 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -600,23 +600,6 @@ namespace OpenSim.Region.Framework.Scenes "reload estate", "Reload the estate data", HandleReloadEstate); - MainConsole.Instance.Commands.AddCommand("region", false, "delete object owner", - "delete object owner ", - "Delete object by owner", HandleDeleteObject); - MainConsole.Instance.Commands.AddCommand("region", false, "delete object creator", - "delete object creator ", - "Delete object by creator", HandleDeleteObject); - MainConsole.Instance.Commands.AddCommand("region", false, "delete object uuid", - "delete object uuid ", - "Delete object by uuid", HandleDeleteObject); - MainConsole.Instance.Commands.AddCommand("region", false, "delete object name", - "delete object name ", - "Delete object by name", HandleDeleteObject); - - MainConsole.Instance.Commands.AddCommand("region", false, "delete object outside", - "delete object outside", - "Delete all objects outside boundaries", HandleDeleteObject); - //Bind Storage Manager functions to some land manager functions for this scene EventManager.OnLandObjectAdded += new EventManager.LandObjectAdded(simDataService.StoreLandObject); @@ -4860,93 +4843,6 @@ namespace OpenSim.Region.Framework.Scenes } } - private void HandleDeleteObject(string module, string[] cmd) - { - if (cmd.Length < 3) - return; - - string mode = cmd[2]; - string o = ""; - - if (mode != "outside") - { - if (cmd.Length < 4) - return; - - o = cmd[3]; - } - - List deletes = new List(); - - UUID match; - - switch (mode) - { - case "owner": - if (!UUID.TryParse(o, out match)) - return; - ForEachSOG(delegate (SceneObjectGroup g) - { - if (g.OwnerID == match && !g.IsAttachment) - deletes.Add(g); - }); - break; - case "creator": - if (!UUID.TryParse(o, out match)) - return; - ForEachSOG(delegate (SceneObjectGroup g) - { - if (g.RootPart.CreatorID == match && !g.IsAttachment) - deletes.Add(g); - }); - break; - case "uuid": - if (!UUID.TryParse(o, out match)) - return; - ForEachSOG(delegate (SceneObjectGroup g) - { - if (g.UUID == match && !g.IsAttachment) - deletes.Add(g); - }); - break; - case "name": - ForEachSOG(delegate (SceneObjectGroup g) - { - if (g.RootPart.Name == o && !g.IsAttachment) - deletes.Add(g); - }); - break; - case "outside": - ForEachSOG(delegate (SceneObjectGroup g) - { - SceneObjectPart rootPart = g.RootPart; - bool delete = false; - - if (rootPart.GroupPosition.Z < 0.0 || rootPart.GroupPosition.Z > 10000.0) - { - delete = true; - } - else - { - ILandObject parcel = LandChannel.GetLandObject(rootPart.GroupPosition.X, rootPart.GroupPosition.Y); - - if (parcel == null || parcel.LandData.Name == "NO LAND") - delete = true; - } - - if (delete && !g.IsAttachment && !deletes.Contains(g)) - deletes.Add(g); - }); - break; - } - - foreach (SceneObjectGroup g in deletes) - { - m_log.InfoFormat("[SCENE]: Deleting object {0}", g.UUID); - DeleteSceneObject(g, false); - } - } - private void HandleReloadEstate(string module, string[] cmd) { if (MainConsole.Instance.ConsoleScene == null || -- cgit v1.1 From e3e38e34c5f58a3c466d1b651b41faf834ff5259 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 31 Jan 2012 22:21:10 +0000 Subject: If a particular region is selected in the console, only try to delete objects in that region, rather than in every region on the simulator The old wrong behaviour was in place before the command was extracted to a module. --- .../World/Objects/Commands/ObjectCommandsModule.cs | 37 ++++++++++++---------- 1 file changed, 21 insertions(+), 16 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs b/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs index 57c109e..42eeb6c 100644 --- a/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs +++ b/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs @@ -50,6 +50,7 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private Scene m_scene; + private ICommandConsole m_console; public string Name { get { return "Object Commands Module"; } } @@ -75,36 +76,40 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands // m_log.DebugFormat("[OBJECT COMMANDS MODULE]: REGION {0} ADDED", scene.RegionInfo.RegionName); m_scene = scene; - } - - public void RemoveRegion(Scene scene) - { -// m_log.DebugFormat("[OBJECTS COMMANDS MODULE]: REGION {0} REMOVED", scene.RegionInfo.RegionName); - } + m_console = MainConsole.Instance; - public void RegionLoaded(Scene scene) - { -// m_log.DebugFormat("[OBJECTS COMMANDS MODULE]: REGION {0} LOADED", scene.RegionInfo.RegionName); - - MainConsole.Instance.Commands.AddCommand("region", false, "delete object owner", + m_console.Commands.AddCommand("region", false, "delete object owner", "delete object owner ", "Delete object by owner", HandleDeleteObject); - MainConsole.Instance.Commands.AddCommand("region", false, "delete object creator", + m_console.Commands.AddCommand("region", false, "delete object creator", "delete object creator ", "Delete object by creator", HandleDeleteObject); - MainConsole.Instance.Commands.AddCommand("region", false, "delete object uuid", + m_console.Commands.AddCommand("region", false, "delete object uuid", "delete object uuid ", "Delete object by uuid", HandleDeleteObject); - MainConsole.Instance.Commands.AddCommand("region", false, "delete object name", + m_console.Commands.AddCommand("region", false, "delete object name", "delete object name ", "Delete object by name", HandleDeleteObject); - MainConsole.Instance.Commands.AddCommand("region", false, "delete object outside", + m_console.Commands.AddCommand("region", false, "delete object outside", "delete object outside", "Delete all objects outside boundaries", HandleDeleteObject); } + public void RemoveRegion(Scene scene) + { +// m_log.DebugFormat("[OBJECTS COMMANDS MODULE]: REGION {0} REMOVED", scene.RegionInfo.RegionName); + } + + public void RegionLoaded(Scene scene) + { +// m_log.DebugFormat("[OBJECTS COMMANDS MODULE]: REGION {0} LOADED", scene.RegionInfo.RegionName); + } + private void HandleDeleteObject(string module, string[] cmd) { + if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene)) + return; + if (cmd.Length < 3) return; @@ -198,7 +203,7 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands foreach (SceneObjectGroup g in deletes) { - MainConsole.Instance.OutputFormat("Deleting object {0}", g.UUID); + m_console.OutputFormat("Deleting object {0}", g.UUID); m_scene.DeleteSceneObject(g, false); } } -- cgit v1.1 From 77b032549ee8a12202a6aa974c6fd07761515d51 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 31 Jan 2012 22:22:32 +0000 Subject: Add the name of a deleted object to the console output --- .../Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs b/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs index 42eeb6c..3e0f622 100644 --- a/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs +++ b/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs @@ -203,7 +203,7 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands foreach (SceneObjectGroup g in deletes) { - m_console.OutputFormat("Deleting object {0}", g.UUID); + m_console.OutputFormat("Deleting object {0} {1}", g.UUID, g.Name); m_scene.DeleteSceneObject(g, false); } } -- cgit v1.1 From 647b326edcd5f80e31ebbff8bd6501c0919c267b Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 31 Jan 2012 22:27:05 +0000 Subject: Add more user feedback if an object isn't found for which delete was requested. --- .../World/Objects/Commands/ObjectCommandsModule.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs b/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs index 3e0f622..78f86cc 100644 --- a/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs +++ b/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs @@ -140,6 +140,9 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands deletes.Add(g); }); + if (deletes.Count == 0) + m_console.OutputFormat("No objects were found with owner {0}", match); + break; case "creator": @@ -152,6 +155,9 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands deletes.Add(g); }); + if (deletes.Count == 0) + m_console.OutputFormat("No objects were found with creator {0}", match); + break; case "uuid": @@ -164,6 +170,9 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands deletes.Add(g); }); + if (deletes.Count == 0) + m_console.OutputFormat("No objects were found with uuid {0}", match); + break; case "name": @@ -173,6 +182,9 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands deletes.Add(g); }); + if (deletes.Count == 0) + m_console.OutputFormat("No objects were found with name {0}", o); + break; case "outside": @@ -198,6 +210,9 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands deletes.Add(g); }); + if (deletes.Count == 0) + m_console.OutputFormat("No objects were found outside region bounds"); + break; } -- cgit v1.1 From ab89adfaefb7c2858cb2f90f783c010157d980a7 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 31 Jan 2012 23:03:39 +0000 Subject: Implement "show object uuid " console command. This will show details about a part with the given uuid if it's found. --- .../World/Objects/Commands/ObjectCommandsModule.cs | 61 ++++++++++++++++++++-- .../Region/Framework/Scenes/SceneObjectGroup.cs | 6 +++ 2 files changed, 62 insertions(+), 5 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs b/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs index 78f86cc..b378f7a 100644 --- a/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs +++ b/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs @@ -80,19 +80,33 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands m_console.Commands.AddCommand("region", false, "delete object owner", "delete object owner ", - "Delete object by owner", HandleDeleteObject); + "Delete a scene object by owner", HandleDeleteObject); m_console.Commands.AddCommand("region", false, "delete object creator", "delete object creator ", - "Delete object by creator", HandleDeleteObject); + "Delete a scene object by creator", HandleDeleteObject); m_console.Commands.AddCommand("region", false, "delete object uuid", "delete object uuid ", - "Delete object by uuid", HandleDeleteObject); + "Delete a scene object by uuid", HandleDeleteObject); m_console.Commands.AddCommand("region", false, "delete object name", "delete object name ", - "Delete object by name", HandleDeleteObject); + "Delete a scene object by name", HandleDeleteObject); m_console.Commands.AddCommand("region", false, "delete object outside", "delete object outside", - "Delete all objects outside boundaries", HandleDeleteObject); + "Delete all scene objects outside region boundaries", HandleDeleteObject); + + m_console.Commands.AddCommand( + "region", + false, + "show object uuid", + "show object uuid ", + "Show details of a scene object with the given UUID", HandleShowObjectByUuid); + +// m_console.Commands.AddCommand( +// "region", +// false, +// "show object name ", +// "show object name ", +// "Show details of scene objects with the given name", HandleShowObjectName); } public void RemoveRegion(Scene scene) @@ -105,6 +119,43 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands // m_log.DebugFormat("[OBJECTS COMMANDS MODULE]: REGION {0} LOADED", scene.RegionInfo.RegionName); } + private void HandleShowObjectByUuid(string module, string[] cmd) + { + if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene)) + return; + + if (cmd.Length < 4) + { + m_console.OutputFormat("Usage: show object uuid "); + return; + } + + UUID objectUuid; + if (!UUID.TryParse(cmd[3], out objectUuid)) + { + m_console.OutputFormat("{0} is not a valid uuid", cmd[3]); + return; + } + + SceneObjectPart sop = m_scene.GetSceneObjectPart(objectUuid); + + if (sop == null) + { + m_console.OutputFormat("No object found with uuid {0}", objectUuid); + return; + } + + StringBuilder sb = new StringBuilder(); + sb.AppendFormat("Name: {0}\n", sop.Name); + sb.AppendFormat("Description: {0}\n", sop.Description); + sb.AppendFormat("Location: {0} @ {1}\n", sop.AbsolutePosition, sop.ParentGroup.Scene.RegionInfo.RegionName); + sb.AppendFormat("Parent: {0}", + sop.IsRoot ? "Is Root\n" : string.Format("{0} {1}\n", sop.ParentGroup.Name, sop.ParentGroup.UUID)); + sb.AppendFormat("Parts: {0}", sop.IsRoot ? "1" : sop.ParentGroup.PrimCount.ToString()); + + m_console.OutputFormat(sb.ToString()); + } + private void HandleDeleteObject(string module, string[] cmd) { if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene)) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 739c5fa..e7f2fdb 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -264,6 +264,12 @@ namespace OpenSim.Region.Framework.Scenes set { RootPart.Name = value; } } + public string Description + { + get { return RootPart.Description; } + set { RootPart.Description = value; } + } + /// /// Added because the Parcel code seems to use it /// but not sure a object should have this -- cgit v1.1 From ac7cded080ff4db606c42f81b4d1f798fe7fa624 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 31 Jan 2012 23:06:48 +0000 Subject: Get rid of the "no objects found" feedback for now - this doesn't work well if a command is executed over multiple scenes. --- .../World/Objects/Commands/ObjectCommandsModule.cs | 24 ++++++++++++---------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs b/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs index b378f7a..d5a3e77 100644 --- a/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs +++ b/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs @@ -141,7 +141,7 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands if (sop == null) { - m_console.OutputFormat("No object found with uuid {0}", objectUuid); +// m_console.OutputFormat("No object found with uuid {0}", objectUuid); return; } @@ -191,8 +191,8 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands deletes.Add(g); }); - if (deletes.Count == 0) - m_console.OutputFormat("No objects were found with owner {0}", match); +// if (deletes.Count == 0) +// m_console.OutputFormat("No objects were found with owner {0}", match); break; @@ -206,8 +206,8 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands deletes.Add(g); }); - if (deletes.Count == 0) - m_console.OutputFormat("No objects were found with creator {0}", match); +// if (deletes.Count == 0) +// m_console.OutputFormat("No objects were found with creator {0}", match); break; @@ -221,8 +221,8 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands deletes.Add(g); }); - if (deletes.Count == 0) - m_console.OutputFormat("No objects were found with uuid {0}", match); +// if (deletes.Count == 0) +// m_console.OutputFormat("No objects were found with uuid {0}", match); break; @@ -233,8 +233,8 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands deletes.Add(g); }); - if (deletes.Count == 0) - m_console.OutputFormat("No objects were found with name {0}", o); +// if (deletes.Count == 0) +// m_console.OutputFormat("No objects were found with name {0}", o); break; @@ -261,12 +261,14 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands deletes.Add(g); }); - if (deletes.Count == 0) - m_console.OutputFormat("No objects were found outside region bounds"); +// if (deletes.Count == 0) +// m_console.OutputFormat("No objects were found outside region bounds"); break; } + m_console.OutputFormat("Deleting {0} objects in {1}", deletes.Count, m_scene.RegionInfo.RegionName); + foreach (SceneObjectGroup g in deletes) { m_console.OutputFormat("Deleting object {0} {1}", g.UUID, g.Name); -- cgit v1.1 From 996cc6097e7d5bbccd1a0b85a1d901686037e19b Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 31 Jan 2012 23:21:02 +0000 Subject: Implement "show object name " console command to show details of an object with the given name --- .../World/Objects/Commands/ObjectCommandsModule.cs | 57 +++++++++++++++++++--- 1 file changed, 49 insertions(+), 8 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs b/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs index d5a3e77..d1ae4dc 100644 --- a/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs +++ b/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs @@ -101,12 +101,12 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands "show object uuid ", "Show details of a scene object with the given UUID", HandleShowObjectByUuid); -// m_console.Commands.AddCommand( -// "region", -// false, -// "show object name ", -// "show object name ", -// "Show details of scene objects with the given name", HandleShowObjectName); + m_console.Commands.AddCommand( + "region", + false, + "show object name", + "show object name ", + "Show details of scene objects with the given name", HandleShowObjectByName); } public void RemoveRegion(Scene scene) @@ -146,14 +146,55 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands } StringBuilder sb = new StringBuilder(); + AddPartReport(sb, sop); + + m_console.OutputFormat(sb.ToString()); + } + + private void HandleShowObjectByName(string module, string[] cmd) + { + if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene)) + return; + + if (cmd.Length < 4) + { + m_console.OutputFormat("Usage: show object name "); + return; + } + + string name = cmd[3]; + + List parts = new List(); + + m_scene.ForEachSOG(so => so.ForEachPart(sop => { if (sop.Name == name) { parts.Add(sop); } })); + + if (parts.Count == 0) + { + m_console.OutputFormat("No parts with name {0} found in {1}", name, m_scene.RegionInfo.RegionName); + return; + } + + StringBuilder sb = new StringBuilder(); + + foreach (SceneObjectPart part in parts) + { + AddPartReport(sb, part); + sb.Append("\n"); + } + + m_console.OutputFormat(sb.ToString()); + } + + private StringBuilder AddPartReport(StringBuilder sb, SceneObjectPart sop) + { sb.AppendFormat("Name: {0}\n", sop.Name); sb.AppendFormat("Description: {0}\n", sop.Description); sb.AppendFormat("Location: {0} @ {1}\n", sop.AbsolutePosition, sop.ParentGroup.Scene.RegionInfo.RegionName); sb.AppendFormat("Parent: {0}", sop.IsRoot ? "Is Root\n" : string.Format("{0} {1}\n", sop.ParentGroup.Name, sop.ParentGroup.UUID)); - sb.AppendFormat("Parts: {0}", sop.IsRoot ? "1" : sop.ParentGroup.PrimCount.ToString()); + sb.AppendFormat("Parts: {0}\n", sop.IsRoot ? "1" : sop.ParentGroup.PrimCount.ToString());; - m_console.OutputFormat(sb.ToString()); + return sb; } private void HandleDeleteObject(string module, string[] cmd) -- cgit v1.1 From f028dca711c7ebcda32e4b035eb667455e3bc29d Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 31 Jan 2012 23:35:13 +0000 Subject: Add "show part uuid" and "show part name" console commands. These commands will display part/prim details for a given uuid or name The "show object uuid" and "show object name" commands will now only display details for objects (i.e. not child parts in a linkset). This is for consistency with the "delete object" commands which only delete objects, not parts. --- .../World/Objects/Commands/ObjectCommandsModule.cs | 104 +++++++++++++++++++-- 1 file changed, 97 insertions(+), 7 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs b/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs index d1ae4dc..e3d04cd 100644 --- a/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs +++ b/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs @@ -107,6 +107,20 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands "show object name", "show object name ", "Show details of scene objects with the given name", HandleShowObjectByName); + + m_console.Commands.AddCommand( + "region", + false, + "show part uuid", + "show part uuid ", + "Show details of a scene object parts with the given UUID", HandleShowPartByUuid); + + m_console.Commands.AddCommand( + "region", + false, + "show part name", + "show part name ", + "Show details of scene object parts with the given name", HandleShowPartByName); } public void RemoveRegion(Scene scene) @@ -137,16 +151,16 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands return; } - SceneObjectPart sop = m_scene.GetSceneObjectPart(objectUuid); + SceneObjectGroup so = m_scene.GetSceneObjectGroup(objectUuid); - if (sop == null) + if (so == null) { -// m_console.OutputFormat("No object found with uuid {0}", objectUuid); +// m_console.OutputFormat("No part found with uuid {0}", objectUuid); return; } StringBuilder sb = new StringBuilder(); - AddPartReport(sb, sop); + AddSceneObjectReport(sb, so); m_console.OutputFormat(sb.ToString()); } @@ -164,6 +178,72 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands string name = cmd[3]; + List sceneObjects = new List(); + + m_scene.ForEachSOG(so => { if (so.Name == name) { sceneObjects.Add(so); }}); + + if (sceneObjects.Count == 0) + { + m_console.OutputFormat("No objects with name {0} found in {1}", name, m_scene.RegionInfo.RegionName); + return; + } + + StringBuilder sb = new StringBuilder(); + + foreach (SceneObjectGroup so in sceneObjects) + { + AddSceneObjectReport(sb, so); + sb.Append("\n"); + } + + m_console.OutputFormat(sb.ToString()); + } + + private void HandleShowPartByUuid(string module, string[] cmd) + { + if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene)) + return; + + if (cmd.Length < 4) + { + m_console.OutputFormat("Usage: show part uuid "); + return; + } + + UUID objectUuid; + if (!UUID.TryParse(cmd[3], out objectUuid)) + { + m_console.OutputFormat("{0} is not a valid uuid", cmd[3]); + return; + } + + SceneObjectPart sop = m_scene.GetSceneObjectPart(objectUuid); + + if (sop == null) + { +// m_console.OutputFormat("No part found with uuid {0}", objectUuid); + return; + } + + StringBuilder sb = new StringBuilder(); + AddScenePartReport(sb, sop); + + m_console.OutputFormat(sb.ToString()); + } + + private void HandleShowPartByName(string module, string[] cmd) + { + if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene)) + return; + + if (cmd.Length < 4) + { + m_console.OutputFormat("Usage: show part name "); + return; + } + + string name = cmd[3]; + List parts = new List(); m_scene.ForEachSOG(so => so.ForEachPart(sop => { if (sop.Name == name) { parts.Add(sop); } })); @@ -178,21 +258,31 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands foreach (SceneObjectPart part in parts) { - AddPartReport(sb, part); + AddScenePartReport(sb, part); sb.Append("\n"); } m_console.OutputFormat(sb.ToString()); } - private StringBuilder AddPartReport(StringBuilder sb, SceneObjectPart sop) + private StringBuilder AddSceneObjectReport(StringBuilder sb, SceneObjectGroup so) + { + sb.AppendFormat("Name: {0}\n", so.Name); + sb.AppendFormat("Description: {0}\n", so.Description); + sb.AppendFormat("Location: {0} @ {1}\n", so.AbsolutePosition, so.Scene.RegionInfo.RegionName); + sb.AppendFormat("Parts: {0}\n", so.PrimCount); + + return sb; + } + + private StringBuilder AddScenePartReport(StringBuilder sb, SceneObjectPart sop) { sb.AppendFormat("Name: {0}\n", sop.Name); sb.AppendFormat("Description: {0}\n", sop.Description); sb.AppendFormat("Location: {0} @ {1}\n", sop.AbsolutePosition, sop.ParentGroup.Scene.RegionInfo.RegionName); sb.AppendFormat("Parent: {0}", sop.IsRoot ? "Is Root\n" : string.Format("{0} {1}\n", sop.ParentGroup.Name, sop.ParentGroup.UUID)); - sb.AppendFormat("Parts: {0}\n", sop.IsRoot ? "1" : sop.ParentGroup.PrimCount.ToString());; + sb.AppendFormat("Parts: {0}\n", !sop.IsRoot ? "1" : sop.ParentGroup.PrimCount.ToString());; return sb; } -- cgit v1.1 From 437de6743c98b9ab217ac56ca6646883ca44c240 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 1 Feb 2012 00:07:06 +0000 Subject: Implement "xengine status" console command to show various xengine stats --- OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 32 ++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index c9bbf0e..c9fb722 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -26,14 +26,15 @@ */ using System; -using System.IO; -using System.Threading; using System.Collections; using System.Collections.Generic; +using System.Globalization; +using System.IO; +using System.Reflection; using System.Security; using System.Security.Policy; -using System.Reflection; -using System.Globalization; +using System.Text; +using System.Threading; using System.Xml; using OpenMetaverse; using OpenMetaverse.StructuredData; @@ -273,6 +274,11 @@ namespace OpenSim.Region.ScriptEngine.XEngine } MainConsole.Instance.Commands.AddCommand( + "scripts", false, "xengine status", "xengine status", "Show status information", + "Show status information on the script engine.", + HandleShowStatus); + + MainConsole.Instance.Commands.AddCommand( "scripts", false, "scripts show", "scripts show []", "Show script information", "Show information on all scripts known to the script engine." + "If a is given then only information on that script will be shown.", @@ -359,6 +365,24 @@ namespace OpenSim.Region.ScriptEngine.XEngine } } + private void HandleShowStatus(string module, string[] cmdparams) + { + StringBuilder sb = new StringBuilder(); + sb.AppendFormat("Status of XEngine instance for {0}\n", m_Scene.RegionInfo.RegionName); + + lock (m_Scripts) + sb.AppendFormat("Scripts loaded : {0}\n", m_Scripts.Count); + + sb.AppendFormat("Unique scripts : {0}\n", m_uniqueScripts.Count); + sb.AppendFormat("Scripts waiting for load : {0}\n", m_CompileQueue.Count); + sb.AppendFormat("Allocated threads : {0}\n", m_ThreadPool.ActiveThreads); + sb.AppendFormat("In use threads : {0}\n", m_ThreadPool.InUseThreads); + sb.AppendFormat("Work items waiting : {0}\n", m_ThreadPool.WaitingCallbacks); +// sb.AppendFormat("Assemblies loaded : {0}\n", m_Assemblies.Count); + + MainConsole.Instance.OutputFormat(sb.ToString()); + } + public void HandleShowScripts(string module, string[] cmdparams) { if (cmdparams.Length == 2) -- cgit v1.1 From 8b3da1bff4344d4dc7738f97e5aaa6d024db8f7e Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 1 Feb 2012 00:10:07 +0000 Subject: Make script console commands only show for selected region. --- OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'OpenSim') diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index c9fb722..459821b 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -324,6 +324,9 @@ namespace OpenSim.Region.ScriptEngine.XEngine /// true if we're okay to proceed, false if not. private void HandleScriptsAction(string[] cmdparams, Action action) { + if (!(MainConsole.Instance.ConsoleScene == null || MainConsole.Instance.ConsoleScene == m_Scene)) + return; + lock (m_Scripts) { string rawItemId; @@ -367,6 +370,9 @@ namespace OpenSim.Region.ScriptEngine.XEngine private void HandleShowStatus(string module, string[] cmdparams) { + if (!(MainConsole.Instance.ConsoleScene == null || MainConsole.Instance.ConsoleScene == m_Scene)) + return; + StringBuilder sb = new StringBuilder(); sb.AppendFormat("Status of XEngine instance for {0}\n", m_Scene.RegionInfo.RegionName); @@ -385,6 +391,9 @@ namespace OpenSim.Region.ScriptEngine.XEngine public void HandleShowScripts(string module, string[] cmdparams) { + if (!(MainConsole.Instance.ConsoleScene == null || MainConsole.Instance.ConsoleScene == m_Scene)) + return; + if (cmdparams.Length == 2) { lock (m_Scripts) -- cgit v1.1 From e3680f216eeb631cd8955a708b1eee492566fa5c Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 1 Feb 2012 00:17:02 +0000 Subject: Add count of events queued for a particular script in "scripts show" console command --- OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 459821b..13c5cd9 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -428,10 +428,15 @@ namespace OpenSim.Region.ScriptEngine.XEngine status = "running"; } - MainConsole.Instance.OutputFormat( - "{0}.{1}, item UUID {2}, prim UUID {3} @ {4} ({5})", - instance.PrimName, instance.ScriptName, instance.ItemID, instance.ObjectID, - sop.AbsolutePosition, status); + Queue eq = instance.EventQueue; + + lock (eq) + { + MainConsole.Instance.OutputFormat( + "{0}.{1}, queued events = {2}, item UUID {3}, prim UUID {4} @ {5} ({6})", + instance.PrimName, instance.ScriptName, eq.Count, instance.ItemID, instance.ObjectID, + sop.AbsolutePosition, status); + } } private void HandleSuspendScript(IScriptInstance instance) -- cgit v1.1 From 99e71222f05345d7c4e1658bf52b90087cad7ab7 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 1 Feb 2012 00:27:42 +0000 Subject: Lay out script status in property per row format, since getting too long for console lines. --- OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 13c5cd9..f11987e 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -428,15 +428,21 @@ namespace OpenSim.Region.ScriptEngine.XEngine status = "running"; } + StringBuilder sb = new StringBuilder(); Queue eq = instance.EventQueue; + sb.AppendFormat("Script name : {0}\n", instance.ScriptName); + sb.AppendFormat("Status : {0}\n", status); + lock (eq) - { - MainConsole.Instance.OutputFormat( - "{0}.{1}, queued events = {2}, item UUID {3}, prim UUID {4} @ {5} ({6})", - instance.PrimName, instance.ScriptName, eq.Count, instance.ItemID, instance.ObjectID, - sop.AbsolutePosition, status); - } + sb.AppendFormat("Queued events : {0}\n", eq.Count); + + sb.AppendFormat("Item UUID : {0}\n", instance.ItemID); + sb.AppendFormat("Containing part name: {0}\n", instance.PrimName); + sb.AppendFormat("Containing part UUID: {0}\n", instance.ObjectID); + sb.AppendFormat("Position : {0}\n", sop.AbsolutePosition); + + MainConsole.Instance.OutputFormat(sb.ToString()); } private void HandleSuspendScript(IScriptInstance instance) -- cgit v1.1 From 3d7b5e5e93b4d9f8c2ad3be8241ee0a484fe222b Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 31 Jan 2012 22:00:59 -0800 Subject: HG: This hopefully fixes the HG teleports back home to OSGrid. Looks like Uri.ToString() drops the port when it's port 80. --- .../CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs index 8d41728..38a7805 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs @@ -348,7 +348,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer region.ExternalHostName = uri.Host; region.HttpPort = (uint)uri.Port; - region.ServerURI = uri.ToString(); + region.ServerURI = aCircuit.ServiceURLs["HomeURI"].ToString(); region.RegionName = string.Empty; region.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), (int)0); return region; -- cgit v1.1 From fcc1fa2c32af3df8962e470150b641dda036a8ab Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 1 Feb 2012 09:36:14 +0000 Subject: Straighten out some attachment mess. Don't save attachment states for HG visitors at all. On Leaving a sim, save only the changed ones. Don't save all scripted stuff when leaving a sim. --- .../Avatar/Attachments/AttachmentsModule.cs | 19 ++++++++----------- OpenSim/Region/Framework/Scenes/Scene.cs | 12 +++++++++++- 2 files changed, 19 insertions(+), 12 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 2142d02..65ba730 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -148,7 +148,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments } } - public void SaveChangedAttachments(IScenePresence sp) + public void SaveChangedAttachments(IScenePresence sp, bool saveAllScripted) { // m_log.DebugFormat("[ATTACHMENTS MODULE]: Saving changed attachments for {0}", sp.Name); @@ -157,13 +157,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments foreach (SceneObjectGroup grp in sp.GetAttachments()) { -// if (grp.HasGroupChanged) // Resizer scripts? -// { - grp.IsAttachment = false; - grp.AbsolutePosition = grp.RootPart.AttachedPos; - UpdateKnownItem(sp, grp); - grp.IsAttachment = true; -// } + grp.IsAttachment = false; + grp.AbsolutePosition = grp.RootPart.AttachedPos; + UpdateKnownItem(sp, grp, saveAllScripted); + grp.IsAttachment = true; } } @@ -460,7 +457,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments /// /// /// - private void UpdateKnownItem(IScenePresence sp, SceneObjectGroup grp) + private void UpdateKnownItem(IScenePresence sp, SceneObjectGroup grp, bool saveAllScripted) { // Saving attachments for NPCs messes them up for the real owner! INPCModule module = m_scene.RequestModuleInterface(); @@ -470,7 +467,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments return; } - if (grp.HasGroupChanged || grp.ContainsScripts()) + if (grp.HasGroupChanged || (saveAllScripted && grp.ContainsScripts())) { m_log.DebugFormat( "[ATTACHMENTS MODULE]: Updating asset for attachment {0}, attachpoint {1}", @@ -696,7 +693,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments group.IsAttachment = false; group.AbsolutePosition = group.RootPart.AttachedPos; - UpdateKnownItem(sp, group); + UpdateKnownItem(sp, group, true); m_scene.DeleteSceneObject(group, false); return; diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index df6c88f..34d1151 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -3104,7 +3104,17 @@ namespace OpenSim.Region.Framework.Scenes m_eventManager.TriggerOnRemovePresence(agentID); if (AttachmentsModule != null && !avatar.IsChildAgent && avatar.PresenceType != PresenceType.Npc) - AttachmentsModule.SaveChangedAttachments(avatar); + { + IUserManagement uMan = m_aScene.RequestModuleInterface(); + // Don't save attachments for HG visitors, it + // messes up their inventory. When a HG visitor logs + // out on a foreign grid, their attachments will be + // reloaded in the state they were in when they left + // the home grid. This is best anyway as the visited + // grid may use an incompatible script engine. + if (uMan == null || uMan.IsLocalGridUser(id)) + AttachmentsModule.SaveChangedAttachments(avatar, false); + } ForEachClient( delegate(IClientAPI client) -- cgit v1.1 From c08d6df7e13abde2905ece634cd6770b3804554c Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 1 Feb 2012 09:38:20 +0000 Subject: Prevent a changed attachment that has been saved from being saved again. --- OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 65ba730..7086e6c 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -500,6 +500,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments if (sp.ControllingClient != null) sp.ControllingClient.SendInventoryItemCreateUpdate(item, 0); } + grp.HasGroupChanged = false; // Prevent it being saved over and over } else { -- cgit v1.1 From 241ddd031f36eda9f1339398ae30d52c1b9e83e5 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 1 Feb 2012 09:45:15 +0000 Subject: Fix copy/paste errors --- OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs | 2 +- OpenSim/Region/Framework/Scenes/Scene.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs index e668dae..eb07165 100644 --- a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs @@ -46,7 +46,7 @@ namespace OpenSim.Region.Framework.Interfaces /// Save the attachments that have change on this presence. /// /// - void SaveChangedAttachments(IScenePresence sp); + void SaveChangedAttachments(IScenePresence sp, bool saveAllScripted); /// /// Delete all the presence's attachments from the scene diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 34d1151..2af4a1c 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -3105,14 +3105,14 @@ namespace OpenSim.Region.Framework.Scenes if (AttachmentsModule != null && !avatar.IsChildAgent && avatar.PresenceType != PresenceType.Npc) { - IUserManagement uMan = m_aScene.RequestModuleInterface(); + IUserManagement uMan = RequestModuleInterface(); // Don't save attachments for HG visitors, it // messes up their inventory. When a HG visitor logs // out on a foreign grid, their attachments will be // reloaded in the state they were in when they left // the home grid. This is best anyway as the visited // grid may use an incompatible script engine. - if (uMan == null || uMan.IsLocalGridUser(id)) + if (uMan == null || uMan.IsLocalGridUser(avatar.UUID)) AttachmentsModule.SaveChangedAttachments(avatar, false); } -- cgit v1.1 From 003bd9f1b3a774141d53282d3b3c13a7e121f0a4 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 1 Feb 2012 10:05:04 +0000 Subject: Small optimization to last commit --- OpenSim/Region/Framework/Scenes/Scene.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 2af4a1c..23fee4e 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -3056,11 +3056,11 @@ namespace OpenSim.Region.Framework.Scenes public override void RemoveClient(UUID agentID, bool closeChildAgents) { CheckHeartbeat(); - bool childagentYN = false; + bool isChildAgent = false; ScenePresence avatar = GetScenePresence(agentID); if (avatar != null) { - childagentYN = avatar.IsChildAgent; + isChildAgent = avatar.IsChildAgent; if (avatar.ParentID != 0) { @@ -3071,9 +3071,9 @@ namespace OpenSim.Region.Framework.Scenes { m_log.DebugFormat( "[SCENE]: Removing {0} agent {1} from region {2}", - (childagentYN ? "child" : "root"), agentID, RegionInfo.RegionName); + (isChildAgent ? "child" : "root"), agentID, RegionInfo.RegionName); - m_sceneGraph.removeUserCount(!childagentYN); + m_sceneGraph.removeUserCount(!isChildAgent); // TODO: We shouldn't use closeChildAgents here - it's being used by the NPC module to stop // unnecessary operations. This should go away once NPCs have no accompanying IClientAPI @@ -3103,7 +3103,7 @@ namespace OpenSim.Region.Framework.Scenes { m_eventManager.TriggerOnRemovePresence(agentID); - if (AttachmentsModule != null && !avatar.IsChildAgent && avatar.PresenceType != PresenceType.Npc) + if (AttachmentsModule != null && !isChildAgent && avatar.PresenceType != PresenceType.Npc) { IUserManagement uMan = RequestModuleInterface(); // Don't save attachments for HG visitors, it -- cgit v1.1