* Rex merge, Environment/Scene
parent
69c92d53cb
commit
dd96983915
|
@ -1,77 +1,62 @@
|
|||
/*
|
||||
* 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 OpenSim 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.Xml;
|
||||
using libsecondlife;
|
||||
using OpenSim.Framework.Console;
|
||||
|
||||
namespace OpenSim.Region.Environment.Scenes
|
||||
{
|
||||
public class AvatarAnimations
|
||||
{
|
||||
public Dictionary<string, LLUUID> AnimsLLUUID = new Dictionary<string, LLUUID>();
|
||||
public Dictionary<LLUUID, string> AnimsNames = new Dictionary<LLUUID, string>();
|
||||
|
||||
public AvatarAnimations()
|
||||
{
|
||||
}
|
||||
|
||||
public void LoadAnims()
|
||||
{
|
||||
//MainLog.Instance.Verbose("CLIENT", "Loading avatar animations");
|
||||
using (XmlTextReader reader = new XmlTextReader("data/avataranimations.xml"))
|
||||
{
|
||||
XmlDocument doc = new XmlDocument();
|
||||
doc.Load(reader);
|
||||
foreach (XmlNode nod in doc.DocumentElement.ChildNodes)
|
||||
{
|
||||
if (nod.Attributes["name"] != null)
|
||||
{
|
||||
AnimsLLUUID.Add(nod.Attributes["name"].Value, nod.InnerText);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MainLog.Instance.Verbose("CLIENT", "Loaded " + AnimsLLUUID.Count.ToString() + " animation(s)");
|
||||
|
||||
try
|
||||
{
|
||||
//Mantis: 0000224: 2755 - Enumeration Operation may not execute [immediate crash] (ODE/2750/WIN2003)
|
||||
foreach (KeyValuePair<string, LLUUID> kp in ScenePresence.Animations.AnimsLLUUID)
|
||||
{
|
||||
AnimsNames.Add(kp.Value, kp.Key);
|
||||
}
|
||||
}
|
||||
catch (InvalidOperationException)
|
||||
{
|
||||
MainLog.Instance.Warn("AVATAR", "Unable to load animation names for an Avatar");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 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 OpenSim 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.Xml;
|
||||
using libsecondlife;
|
||||
using OpenSim.Framework.Console;
|
||||
|
||||
namespace OpenSim.Region.Environment.Scenes
|
||||
{
|
||||
public class AvatarAnimations
|
||||
{
|
||||
public Dictionary<string, LLUUID> AnimsLLUUID = new Dictionary<string, LLUUID>();
|
||||
public Dictionary<LLUUID, string> AnimsNames = new Dictionary<LLUUID, string>();
|
||||
|
||||
public AvatarAnimations()
|
||||
{
|
||||
using (XmlTextReader reader = new XmlTextReader("data/avataranimations.xml"))
|
||||
{
|
||||
XmlDocument doc = new XmlDocument();
|
||||
doc.Load(reader);
|
||||
foreach (XmlNode nod in doc.DocumentElement.ChildNodes)
|
||||
{
|
||||
if (nod.Attributes["name"] != null)
|
||||
{
|
||||
string name = (string)nod.Attributes["name"].Value;
|
||||
LLUUID id = (LLUUID)nod.InnerText;
|
||||
|
||||
AnimsLLUUID.Add(name, id);
|
||||
AnimsNames.Add(id, name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,174 +1,186 @@
|
|||
/*
|
||||
* 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 OpenSim 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 libsecondlife;
|
||||
using libsecondlife.Packets;
|
||||
using OpenSim.Framework;
|
||||
|
||||
namespace OpenSim.Region.Environment.Scenes
|
||||
{
|
||||
public class AvatarAppearance
|
||||
{
|
||||
protected LLUUID m_scenePresenceID;
|
||||
protected int m_wearablesSerial = 1;
|
||||
|
||||
protected bool m_rexmode; //rex
|
||||
protected string m_avatarStorageAddr;
|
||||
|
||||
|
||||
protected byte[] m_visualParams;
|
||||
|
||||
public byte[] VisualParams
|
||||
{
|
||||
get { return m_visualParams; }
|
||||
set { m_visualParams = value; }
|
||||
}
|
||||
|
||||
protected AvatarWearable[] m_wearables;
|
||||
|
||||
public AvatarWearable[] Wearables
|
||||
{
|
||||
get { return m_wearables; }
|
||||
set { m_wearables = value; }
|
||||
}
|
||||
|
||||
protected LLObject.TextureEntry m_textureEntry;
|
||||
|
||||
public LLObject.TextureEntry TextureEntry
|
||||
{
|
||||
get { return m_textureEntry; }
|
||||
set { m_textureEntry = value; }
|
||||
}
|
||||
|
||||
protected float m_avatarHeight = 0;
|
||||
|
||||
public float AvatarHeight
|
||||
{
|
||||
get { return m_avatarHeight; }
|
||||
set { m_avatarHeight = value; }
|
||||
}
|
||||
|
||||
public AvatarAppearance()
|
||||
{
|
||||
}
|
||||
|
||||
public AvatarAppearance(LLUUID avatarID, AvatarWearable[] wearables, byte[] visualParams)
|
||||
{
|
||||
m_scenePresenceID = avatarID;
|
||||
m_wearablesSerial = 1;
|
||||
m_wearables = wearables;
|
||||
m_visualParams = visualParams;
|
||||
m_textureEntry = GetDefaultTextureEntry();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// AvatarAppearance for rexmode, using avatarstorage address for describing avatar
|
||||
/// </summary>
|
||||
/// <param name="avatarID"></param>
|
||||
/// <param name="avatarStorage"></param>
|
||||
public AvatarAppearance(LLUUID avatarID, string avatarStorage)//rex
|
||||
{
|
||||
m_scenePresenceID = avatarID;
|
||||
m_avatarStorageAddr = avatarStorage;
|
||||
m_rexmode = true;
|
||||
m_textureEntry = GetDefaultTextureEntry(); // rex mode fix against nullpointer in SendInitialData()
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="texture"></param>
|
||||
/// <param name="visualParam"></param>
|
||||
public void SetAppearance(byte[] texture, AgentSetAppearancePacket.VisualParamBlock[] visualParam)
|
||||
{
|
||||
LLObject.TextureEntry textureEnt = new LLObject.TextureEntry(texture, 0, texture.Length);
|
||||
m_textureEntry = textureEnt;
|
||||
|
||||
for (int i = 0; i < visualParam.Length; i++)
|
||||
{
|
||||
m_visualParams[i] = visualParam[i].ParamValue;
|
||||
}
|
||||
|
||||
// Teravus : Nifty AV Height Getting Maaaaagical formula. Oh how we love turning 0-255 into meters.
|
||||
// (float)m_visualParams[25] = Height
|
||||
// (float)m_visualParams[125] = LegLength
|
||||
m_avatarHeight = (1.50856f + (((float) m_visualParams[25]/255.0f)*(2.525506f - 1.50856f)))
|
||||
+ (((float) m_visualParams[125]/255.0f)/1.5f);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="avatar"></param>
|
||||
public void SendAppearanceToOtherAgent(ScenePresence avatar)
|
||||
{
|
||||
if (!m_rexmode) {
|
||||
avatar.ControllingClient.SendAppearance(m_scenePresenceID, m_visualParams,
|
||||
m_textureEntry.ToBytes());
|
||||
}
|
||||
else { //rex mode appearance sending
|
||||
avatar.ControllingClient.SendRexAppearance(m_scenePresenceID, m_avatarStorageAddr);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetWearable(IClientAPI client, int wearableId, AvatarWearable wearable)
|
||||
{
|
||||
if (m_wearables != null) // rex mode fix, wearables may be null
|
||||
{
|
||||
m_wearables[wearableId] = wearable;
|
||||
SendOwnWearables(client);
|
||||
}
|
||||
}
|
||||
|
||||
public void SendOwnWearables(IClientAPI ourClient)
|
||||
{
|
||||
if (m_wearables != null) // rex mode fix, wearables may be null
|
||||
{
|
||||
ourClient.SendWearables(m_wearables, m_wearablesSerial++);
|
||||
}
|
||||
|
||||
if (m_rexmode) // rex mode addition, send also for the agent itself
|
||||
{
|
||||
ourClient.SendRexAppearance(m_scenePresenceID, m_avatarStorageAddr);
|
||||
}
|
||||
}
|
||||
|
||||
public static LLObject.TextureEntry GetDefaultTextureEntry()
|
||||
{
|
||||
LLObject.TextureEntry textu = new LLObject.TextureEntry(new LLUUID("C228D1CF-4B5D-4BA8-84F4-899A0796AA97"));
|
||||
textu.CreateFace(0).TextureID = new LLUUID("00000000-0000-1111-9999-000000000012");
|
||||
textu.CreateFace(1).TextureID = new LLUUID("5748decc-f629-461c-9a36-a35a221fe21f");
|
||||
textu.CreateFace(2).TextureID = new LLUUID("5748decc-f629-461c-9a36-a35a221fe21f");
|
||||
textu.CreateFace(3).TextureID = new LLUUID("6522E74D-1660-4E7F-B601-6F48C1659A77");
|
||||
textu.CreateFace(4).TextureID = new LLUUID("7CA39B4C-BD19-4699-AFF7-F93FD03D3E7B");
|
||||
textu.CreateFace(5).TextureID = new LLUUID("00000000-0000-1111-9999-000000000010");
|
||||
textu.CreateFace(6).TextureID = new LLUUID("00000000-0000-1111-9999-000000000011");
|
||||
return textu;
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 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 OpenSim 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 libsecondlife;
|
||||
using libsecondlife.Packets;
|
||||
using OpenSim.Framework;
|
||||
|
||||
namespace OpenSim.Region.Environment.Scenes
|
||||
{
|
||||
public class AvatarAppearance
|
||||
{
|
||||
protected LLUUID m_scenePresenceID;
|
||||
|
||||
public LLUUID ScenePresenceID
|
||||
{
|
||||
get { return m_scenePresenceID; }
|
||||
set { m_scenePresenceID = value; }
|
||||
}
|
||||
protected int m_wearablesSerial = 1;
|
||||
|
||||
protected bool m_rexmode; //rex
|
||||
protected string m_avatarStorageAddr;
|
||||
|
||||
|
||||
public int WearablesSerial
|
||||
{
|
||||
get { return m_wearablesSerial; }
|
||||
set { m_wearablesSerial = value; }
|
||||
}
|
||||
|
||||
protected byte[] m_visualParams;
|
||||
|
||||
public byte[] VisualParams
|
||||
{
|
||||
get { return m_visualParams; }
|
||||
set { m_visualParams = value; }
|
||||
}
|
||||
|
||||
protected AvatarWearable[] m_wearables;
|
||||
|
||||
public AvatarWearable[] Wearables
|
||||
{
|
||||
get { return m_wearables; }
|
||||
set { m_wearables = value; }
|
||||
}
|
||||
|
||||
protected LLObject.TextureEntry m_textureEntry;
|
||||
|
||||
public LLObject.TextureEntry TextureEntry
|
||||
{
|
||||
get { return m_textureEntry; }
|
||||
set { m_textureEntry = value; }
|
||||
}
|
||||
|
||||
protected float m_avatarHeight = 0;
|
||||
|
||||
public float AvatarHeight
|
||||
{
|
||||
get { return m_avatarHeight; }
|
||||
set { m_avatarHeight = value; }
|
||||
}
|
||||
|
||||
public AvatarAppearance()
|
||||
{
|
||||
}
|
||||
|
||||
public AvatarAppearance(LLUUID avatarID, AvatarWearable[] wearables, byte[] visualParams)
|
||||
{
|
||||
m_scenePresenceID = avatarID;
|
||||
m_wearablesSerial = 1;
|
||||
m_wearables = wearables;
|
||||
m_visualParams = visualParams;
|
||||
m_textureEntry = GetDefaultTextureEntry();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// AvatarAppearance for rexmode, using avatarstorage address for describing avatar
|
||||
/// </summary>
|
||||
/// <param name="avatarID"></param>
|
||||
/// <param name="avatarStorage"></param>
|
||||
public AvatarAppearance(LLUUID avatarID, string avatarStorage)//rex
|
||||
{
|
||||
m_scenePresenceID = avatarID;
|
||||
m_avatarStorageAddr = avatarStorage;
|
||||
m_rexmode = true;
|
||||
m_textureEntry = GetDefaultTextureEntry(); // rex mode fix against nullpointer in SendInitialData()
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="texture"></param>
|
||||
/// <param name="visualParam"></param>
|
||||
public void SetAppearance(byte[] texture, AgentSetAppearancePacket.VisualParamBlock[] visualParam)
|
||||
{
|
||||
LLObject.TextureEntry textureEnt = new LLObject.TextureEntry(texture, 0, texture.Length);
|
||||
m_textureEntry = textureEnt;
|
||||
|
||||
for (int i = 0; i < visualParam.Length; i++)
|
||||
{
|
||||
m_visualParams[i] = visualParam[i].ParamValue;
|
||||
}
|
||||
|
||||
// Teravus : Nifty AV Height Getting Maaaaagical formula. Oh how we love turning 0-255 into meters.
|
||||
// (float)m_visualParams[25] = Height
|
||||
// (float)m_visualParams[125] = LegLength
|
||||
m_avatarHeight = (1.50856f + (((float) m_visualParams[25]/255.0f)*(2.525506f - 1.50856f)))
|
||||
+ (((float) m_visualParams[125]/255.0f)/1.5f);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="avatar"></param>
|
||||
public void SendAppearanceToOtherAgent(ScenePresence avatar)
|
||||
{
|
||||
if (!m_rexmode) {
|
||||
avatar.ControllingClient.SendAppearance(m_scenePresenceID, m_visualParams,
|
||||
m_textureEntry.ToBytes());
|
||||
}
|
||||
else { //rex mode appearance sending
|
||||
avatar.ControllingClient.SendRexAppearance(m_scenePresenceID, m_avatarStorageAddr);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetWearable(IClientAPI client, int wearableId, AvatarWearable wearable)
|
||||
{
|
||||
if (m_wearables != null) // rex mode fix, wearables may be null
|
||||
{
|
||||
m_wearables[wearableId] = wearable;
|
||||
SendOwnWearables(client);
|
||||
}
|
||||
}
|
||||
|
||||
public void SendOwnWearables(IClientAPI ourClient)
|
||||
{
|
||||
if (m_wearables != null) // rex mode fix, wearables may be null
|
||||
{
|
||||
ourClient.SendWearables(m_wearables, m_wearablesSerial++);
|
||||
}
|
||||
|
||||
if (m_rexmode) // rex mode addition, send also for the agent itself
|
||||
{
|
||||
ourClient.SendRexAppearance(m_scenePresenceID, m_avatarStorageAddr);
|
||||
}
|
||||
}
|
||||
|
||||
public static LLObject.TextureEntry GetDefaultTextureEntry()
|
||||
{
|
||||
LLObject.TextureEntry textu = new LLObject.TextureEntry(new LLUUID("C228D1CF-4B5D-4BA8-84F4-899A0796AA97"));
|
||||
textu.CreateFace(0).TextureID = new LLUUID("00000000-0000-1111-9999-000000000012");
|
||||
textu.CreateFace(1).TextureID = new LLUUID("5748decc-f629-461c-9a36-a35a221fe21f");
|
||||
textu.CreateFace(2).TextureID = new LLUUID("5748decc-f629-461c-9a36-a35a221fe21f");
|
||||
textu.CreateFace(3).TextureID = new LLUUID("6522E74D-1660-4E7F-B601-6F48C1659A77");
|
||||
textu.CreateFace(4).TextureID = new LLUUID("7CA39B4C-BD19-4699-AFF7-F93FD03D3E7B");
|
||||
textu.CreateFace(5).TextureID = new LLUUID("00000000-0000-1111-9999-000000000010");
|
||||
textu.CreateFace(6).TextureID = new LLUUID("00000000-0000-1111-9999-000000000011");
|
||||
return textu;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,180 +1,162 @@
|
|||
/*
|
||||
* 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 OpenSim 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.Collections.Generic;
|
||||
using Axiom.Math;
|
||||
using libsecondlife;
|
||||
|
||||
namespace OpenSim.Region.Environment.Scenes
|
||||
{
|
||||
public abstract class EntityBase
|
||||
{
|
||||
protected List<EntityBase> m_children;
|
||||
|
||||
protected Scene m_scene;
|
||||
|
||||
public Scene Scene
|
||||
{
|
||||
get { return m_scene; }
|
||||
}
|
||||
|
||||
public LLUUID m_uuid;
|
||||
|
||||
public virtual LLUUID UUID
|
||||
{
|
||||
get { return m_uuid; }
|
||||
set { m_uuid = value; }
|
||||
}
|
||||
|
||||
protected string m_name;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public virtual string Name
|
||||
{
|
||||
get { return m_name; }
|
||||
set { m_name = value; }
|
||||
}
|
||||
|
||||
protected LLVector3 m_pos;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public virtual LLVector3 AbsolutePosition
|
||||
{
|
||||
get { return m_pos; }
|
||||
set { m_pos = value; }
|
||||
}
|
||||
|
||||
protected LLVector3 m_velocity;
|
||||
protected LLVector3 m_rotationalvelocity;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public virtual LLVector3 Velocity
|
||||
{
|
||||
get { return m_velocity; }
|
||||
set { m_velocity = value; }
|
||||
}
|
||||
|
||||
protected Quaternion m_rotation = new Quaternion(0, 0, 1, 0);
|
||||
|
||||
public virtual Quaternion Rotation
|
||||
{
|
||||
get { return m_rotation; }
|
||||
set { m_rotation = value; }
|
||||
}
|
||||
|
||||
protected uint m_localId;
|
||||
|
||||
public virtual uint LocalId
|
||||
{
|
||||
get { return m_localId; }
|
||||
set { m_localId = value; }
|
||||
}
|
||||
|
||||
// rex, added
|
||||
public bool DeleteMe = false;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new Entity (should not occur on it's own)
|
||||
/// </summary>
|
||||
public EntityBase()
|
||||
{
|
||||
m_uuid = LLUUID.Zero;
|
||||
|
||||
m_pos = new LLVector3();
|
||||
m_velocity = new LLVector3();
|
||||
Rotation = new Quaternion();
|
||||
m_name = "(basic entity)";
|
||||
m_rotationalvelocity = new LLVector3(0, 0, 0);
|
||||
m_children = new List<EntityBase>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public virtual void UpdateMovement()
|
||||
{
|
||||
foreach (EntityBase child in m_children)
|
||||
|
||||
{
|
||||
child.UpdateMovement();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Performs any updates that need to be done at each frame. This function is overridable from it's children.
|
||||
/// </summary>
|
||||
public virtual void Update()
|
||||
{
|
||||
// Do any per-frame updates needed that are applicable to every type of entity
|
||||
|
||||
foreach (EntityBase child in m_children)
|
||||
{
|
||||
child.Update();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copies the entity
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public virtual EntityBase Copy()
|
||||
{
|
||||
return (EntityBase) MemberwiseClone();
|
||||
}
|
||||
|
||||
|
||||
public abstract void SetText(string text, Vector3 color, double alpha);
|
||||
}
|
||||
|
||||
//Nested Classes
|
||||
public class EntityIntersection
|
||||
{
|
||||
public Vector3 ipoint = new Vector3(0, 0, 0);
|
||||
public float normal = 0;
|
||||
public bool HitTF = false;
|
||||
public SceneObjectPart obj;
|
||||
public float distance = 0;
|
||||
|
||||
public EntityIntersection()
|
||||
{
|
||||
}
|
||||
|
||||
public EntityIntersection(Vector3 _ipoint, float _normal, bool _HitTF)
|
||||
{
|
||||
ipoint = _ipoint;
|
||||
normal = _normal;
|
||||
HitTF = _HitTF;
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 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 OpenSim 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.Collections.Generic;
|
||||
using Axiom.Math;
|
||||
using libsecondlife;
|
||||
|
||||
namespace OpenSim.Region.Environment.Scenes
|
||||
{
|
||||
public abstract class EntityBase
|
||||
{
|
||||
protected Scene m_scene;
|
||||
|
||||
public Scene Scene
|
||||
{
|
||||
get { return m_scene; }
|
||||
}
|
||||
|
||||
public LLUUID m_uuid;
|
||||
|
||||
public virtual LLUUID UUID
|
||||
{
|
||||
get { return m_uuid; }
|
||||
set { m_uuid = value; }
|
||||
}
|
||||
|
||||
protected string m_name;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public virtual string Name
|
||||
{
|
||||
get { return m_name; }
|
||||
set { m_name = value; }
|
||||
}
|
||||
|
||||
protected LLVector3 m_pos;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public virtual LLVector3 AbsolutePosition
|
||||
{
|
||||
get { return m_pos; }
|
||||
set { m_pos = value; }
|
||||
}
|
||||
|
||||
protected LLVector3 m_velocity;
|
||||
protected LLVector3 m_rotationalvelocity;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public virtual LLVector3 Velocity
|
||||
{
|
||||
get { return m_velocity; }
|
||||
set { m_velocity = value; }
|
||||
}
|
||||
|
||||
protected Quaternion m_rotation = new Quaternion(0, 0, 1, 0);
|
||||
|
||||
public virtual Quaternion Rotation
|
||||
{
|
||||
get { return m_rotation; }
|
||||
set { m_rotation = value; }
|
||||
}
|
||||
|
||||
protected uint m_localId;
|
||||
|
||||
public virtual uint LocalId
|
||||
{
|
||||
get { return m_localId; }
|
||||
set { m_localId = value; }
|
||||
}
|
||||
|
||||
// rex, added
|
||||
public bool DeleteMe = false;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new Entity (should not occur on it's own)
|
||||
/// </summary>
|
||||
public EntityBase()
|
||||
{
|
||||
m_uuid = LLUUID.Zero;
|
||||
|
||||
m_pos = new LLVector3();
|
||||
m_velocity = new LLVector3();
|
||||
Rotation = new Quaternion();
|
||||
m_name = "(basic entity)";
|
||||
m_rotationalvelocity = new LLVector3(0, 0, 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public abstract void UpdateMovement();
|
||||
|
||||
/// <summary>
|
||||
/// Performs any updates that need to be done at each frame.
|
||||
/// </summary>
|
||||
public abstract void Update();
|
||||
|
||||
/// <summary>
|
||||
/// Copies the entity
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public virtual EntityBase Copy()
|
||||
{
|
||||
return (EntityBase) MemberwiseClone();
|
||||
}
|
||||
|
||||
|
||||
public abstract void SetText(string text, Vector3 color, double alpha);
|
||||
}
|
||||
|
||||
//Nested Classes
|
||||
public class EntityIntersection
|
||||
{
|
||||
public Vector3 ipoint = new Vector3(0, 0, 0);
|
||||
public float normal = 0;
|
||||
public bool HitTF = false;
|
||||
public SceneObjectPart obj;
|
||||
public float distance = 0;
|
||||
|
||||
public EntityIntersection()
|
||||
{
|
||||
}
|
||||
|
||||
public EntityIntersection(Vector3 _ipoint, float _normal, bool _HitTF)
|
||||
{
|
||||
ipoint = _ipoint;
|
||||
normal = _normal;
|
||||
HitTF = _HitTF;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,38 +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 OpenSim 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 libsecondlife;
|
||||
using OpenSim.Framework;
|
||||
|
||||
namespace OpenSim.Region.Environment.Scenes
|
||||
{
|
||||
public interface IScenePresenceBody
|
||||
{
|
||||
void processMovement(IClientAPI remoteClient, uint flags, LLQuaternion bodyRotation);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 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 OpenSim 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 libsecondlife;
|
||||
using OpenSim.Framework;
|
||||
|
||||
namespace OpenSim.Region.Environment.Scenes
|
||||
{
|
||||
public interface IScenePresenceBody
|
||||
{
|
||||
void processMovement(IClientAPI remoteClient, uint flags, LLQuaternion bodyRotation);
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -1,206 +1,225 @@
|
|||
/*
|
||||
* 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 OpenSim 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.Collections.Generic;
|
||||
using libsecondlife;
|
||||
using libsecondlife.Packets;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.UserManagement;
|
||||
using OpenSim.Framework.Console;
|
||||
|
||||
namespace OpenSim.Region.Environment.Scenes
|
||||
{
|
||||
public partial class Scene
|
||||
{
|
||||
/// <summary>
|
||||
/// Modifies terrain using the specified information
|
||||
/// </summary>
|
||||
/// <param name="height">The height at which the user started modifying the terrain</param>
|
||||
/// <param name="seconds">The number of seconds the modify button was pressed</param>
|
||||
/// <param name="brushsize">The size of the brush used</param>
|
||||
/// <param name="action">The action to be performed</param>
|
||||
/// <param name="north">Distance from the north border where the cursor is located</param>
|
||||
/// <param name="west">Distance from the west border where the cursor is located</param>
|
||||
public void ModifyTerrain(float height, float seconds, byte brushsize, byte action, float north, float west,
|
||||
float south, float east,
|
||||
IClientAPI remoteUser)
|
||||
{
|
||||
// Do a permissions check before allowing terraforming.
|
||||
// random users are now no longer allowed to terraform
|
||||
// if permissions are enabled.
|
||||
if (!PermissionsMngr.CanTerraform(remoteUser.AgentId, new LLVector3(north, west, 0)))
|
||||
return;
|
||||
|
||||
//if it wasn't for the permission checking we could have the terrain module directly subscribe to the OnModifyTerrain event
|
||||
Terrain.ModifyTerrain(height, seconds, brushsize, action, north, west, south, east, remoteUser);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="message"></param>
|
||||
/// <param name="type"></param>
|
||||
/// <param name="fromPos"></param>
|
||||
/// <param name="fromName"></param>
|
||||
/// <param name="fromAgentID"></param>
|
||||
public void SimChat(byte[] message, ChatTypeEnum type, int channel, LLVector3 fromPos, string fromName,
|
||||
LLUUID fromAgentID)
|
||||
{
|
||||
if (m_simChatModule != null)
|
||||
{
|
||||
ChatFromViewerArgs args = new ChatFromViewerArgs();
|
||||
|
||||
args.Message = Helpers.FieldToUTF8String(message);
|
||||
args.Channel = channel;
|
||||
args.Type = type;
|
||||
args.Position = fromPos;
|
||||
|
||||
ScenePresence user = GetScenePresence(fromAgentID);
|
||||
if (user != null)
|
||||
args.Sender = user.ControllingClient;
|
||||
else
|
||||
args.Sender = null;
|
||||
|
||||
args.From = fromName;
|
||||
|
||||
m_simChatModule.SimChat(this, args);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="primLocalID"></param>
|
||||
/// <param name="remoteClient"></param>
|
||||
public void SelectPrim(uint primLocalID, IClientAPI remoteClient)
|
||||
{
|
||||
List<EntityBase> EntitieList = GetEntities();
|
||||
|
||||
foreach (EntityBase ent in EntitieList)
|
||||
{
|
||||
if (ent is SceneObjectGroup)
|
||||
{
|
||||
if (((SceneObjectGroup) ent).LocalId == primLocalID)
|
||||
{
|
||||
((SceneObjectGroup) ent).GetProperites(remoteClient);
|
||||
((SceneObjectGroup) ent).IsSelected = true;
|
||||
LandManager.setPrimsTainted();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="primLocalID"></param>
|
||||
/// <param name="remoteClient"></param>
|
||||
public void DeselectPrim(uint primLocalID, IClientAPI remoteClient)
|
||||
{
|
||||
List<EntityBase> EntitieList = GetEntities();
|
||||
|
||||
foreach (EntityBase ent in EntitieList)
|
||||
{
|
||||
if (ent is SceneObjectGroup)
|
||||
{
|
||||
if (((SceneObjectGroup) ent).LocalId == primLocalID)
|
||||
{
|
||||
((SceneObjectGroup) ent).IsSelected = false;
|
||||
LandManager.setPrimsTainted();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void ProcessObjectGrab(uint localID, LLVector3 offsetPos, IClientAPI remoteClient)
|
||||
{
|
||||
EventManager.TriggerObjectGrab(localID, offsetPos, remoteClient);
|
||||
|
||||
List<EntityBase> EntitieList = GetEntities();
|
||||
|
||||
foreach (EntityBase ent in EntitieList)
|
||||
{
|
||||
if (ent is SceneObjectGroup)
|
||||
{
|
||||
SceneObjectGroup obj = ent as SceneObjectGroup;
|
||||
|
||||
if (obj.HasChildPrim(localID))
|
||||
{
|
||||
obj.ObjectGrabHandler(localID, offsetPos, remoteClient);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void ProcessAvatarPickerRequest(IClientAPI client, LLUUID avatarID, LLUUID RequestID, string query)
|
||||
{
|
||||
//EventManager.TriggerAvatarPickerRequest();
|
||||
|
||||
List<AvatarPickerAvatar> AvatarResponses = new List<AvatarPickerAvatar>();
|
||||
AvatarResponses = CommsManager.GenerateAgentPickerRequestResponse(RequestID, query);
|
||||
|
||||
AvatarPickerReplyPacket replyPacket = (AvatarPickerReplyPacket) PacketPool.Instance.GetPacket(PacketType.AvatarPickerReply);
|
||||
// TODO: don't create new blocks if recycling an old packet
|
||||
|
||||
AvatarPickerReplyPacket.DataBlock[] searchData =
|
||||
new AvatarPickerReplyPacket.DataBlock[AvatarResponses.Count];
|
||||
AvatarPickerReplyPacket.AgentDataBlock agentData = new AvatarPickerReplyPacket.AgentDataBlock();
|
||||
|
||||
agentData.AgentID = avatarID;
|
||||
agentData.QueryID = RequestID;
|
||||
replyPacket.AgentData = agentData;
|
||||
byte[] bytes = new byte[AvatarResponses.Count*32];
|
||||
|
||||
int i = 0;
|
||||
foreach (AvatarPickerAvatar item in AvatarResponses)
|
||||
{
|
||||
LLUUID translatedIDtem = item.AvatarID;
|
||||
searchData[i] = new AvatarPickerReplyPacket.DataBlock();
|
||||
searchData[i].AvatarID = translatedIDtem;
|
||||
searchData[i].FirstName = Helpers.StringToField((string) item.firstName);
|
||||
searchData[i].LastName = Helpers.StringToField((string) item.lastName);
|
||||
i++;
|
||||
}
|
||||
if (AvatarResponses.Count == 0)
|
||||
{
|
||||
searchData = new AvatarPickerReplyPacket.DataBlock[0];
|
||||
}
|
||||
replyPacket.Data = searchData;
|
||||
client.SendAvatarPickerReply(replyPacket);
|
||||
}
|
||||
|
||||
// rex, added
|
||||
public void ProcessRexClientScriptCommand(IClientAPI remoteClient,LLUUID agentID,List<string> vParams)
|
||||
{
|
||||
EventManager.TriggerOnRexClientScriptCommand(GetScenePresence(agentID), vParams);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 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 OpenSim 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.Collections.Generic;
|
||||
using libsecondlife;
|
||||
using libsecondlife.Packets;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.UserManagement;
|
||||
using OpenSim.Framework.Console;
|
||||
|
||||
namespace OpenSim.Region.Environment.Scenes
|
||||
{
|
||||
public partial class Scene
|
||||
{
|
||||
/// <summary>
|
||||
/// Modifies terrain using the specified information
|
||||
/// </summary>
|
||||
/// <param name="height">The height at which the user started modifying the terrain</param>
|
||||
/// <param name="seconds">The number of seconds the modify button was pressed</param>
|
||||
/// <param name="brushsize">The size of the brush used</param>
|
||||
/// <param name="action">The action to be performed</param>
|
||||
/// <param name="north">Distance from the north border where the cursor is located</param>
|
||||
/// <param name="west">Distance from the west border where the cursor is located</param>
|
||||
public void ModifyTerrain(float height, float seconds, byte brushsize, byte action, float north, float west,
|
||||
float south, float east,
|
||||
IClientAPI remoteUser)
|
||||
{
|
||||
// Do a permissions check before allowing terraforming.
|
||||
// random users are now no longer allowed to terraform
|
||||
// if permissions are enabled.
|
||||
if (!PermissionsMngr.CanTerraform(remoteUser.AgentId, new LLVector3(north, west, 0)))
|
||||
return;
|
||||
|
||||
//if it wasn't for the permission checking we could have the terrain module directly subscribe to the OnModifyTerrain event
|
||||
Terrain.ModifyTerrain(height, seconds, brushsize, action, north, west, south, east, remoteUser);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="message"></param>
|
||||
/// <param name="type"></param>
|
||||
/// <param name="fromPos"></param>
|
||||
/// <param name="fromName"></param>
|
||||
/// <param name="fromAgentID"></param>
|
||||
public void SimChat(byte[] message, ChatTypeEnum type, int channel, LLVector3 fromPos, string fromName,
|
||||
LLUUID fromAgentID)
|
||||
{
|
||||
if (m_simChatModule != null)
|
||||
{
|
||||
ChatFromViewerArgs args = new ChatFromViewerArgs();
|
||||
|
||||
args.Message = Helpers.FieldToUTF8String(message);
|
||||
args.Channel = channel;
|
||||
args.Type = type;
|
||||
args.Position = fromPos;
|
||||
|
||||
ScenePresence user = GetScenePresence(fromAgentID);
|
||||
if (user != null)
|
||||
args.Sender = user.ControllingClient;
|
||||
else
|
||||
args.Sender = null;
|
||||
|
||||
args.From = fromName;
|
||||
|
||||
m_simChatModule.SimChat(this, args);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="primLocalID"></param>
|
||||
/// <param name="remoteClient"></param>
|
||||
public void SelectPrim(uint primLocalID, IClientAPI remoteClient)
|
||||
{
|
||||
List<EntityBase> EntitieList = GetEntities();
|
||||
|
||||
foreach (EntityBase ent in EntitieList)
|
||||
{
|
||||
if (ent is SceneObjectGroup)
|
||||
{
|
||||
if (((SceneObjectGroup) ent).LocalId == primLocalID)
|
||||
{
|
||||
((SceneObjectGroup) ent).GetProperties(remoteClient);
|
||||
((SceneObjectGroup) ent).IsSelected = true;
|
||||
LandManager.setPrimsTainted();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="primLocalID"></param>
|
||||
/// <param name="remoteClient"></param>
|
||||
public void DeselectPrim(uint primLocalID, IClientAPI remoteClient)
|
||||
{
|
||||
List<EntityBase> EntitieList = GetEntities();
|
||||
|
||||
foreach (EntityBase ent in EntitieList)
|
||||
{
|
||||
if (ent is SceneObjectGroup)
|
||||
{
|
||||
if (((SceneObjectGroup) ent).LocalId == primLocalID)
|
||||
{
|
||||
((SceneObjectGroup) ent).IsSelected = false;
|
||||
LandManager.setPrimsTainted();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void ProcessMoneyTransferRequest(LLUUID source, LLUUID destination, int amount, int transactiontype, string description)
|
||||
{
|
||||
EventManager.MoneyTransferArgs args = new EventManager.MoneyTransferArgs(
|
||||
source, destination, amount, transactiontype, description);
|
||||
|
||||
EventManager.TriggerMoneyTransfer(this, args);
|
||||
}
|
||||
|
||||
public virtual void ProcessObjectGrab(uint localID, LLVector3 offsetPos, IClientAPI remoteClient)
|
||||
{
|
||||
|
||||
List<EntityBase> EntitieList = GetEntities();
|
||||
|
||||
foreach (EntityBase ent in EntitieList)
|
||||
{
|
||||
if (ent is SceneObjectGroup)
|
||||
{
|
||||
SceneObjectGroup obj = ent as SceneObjectGroup;
|
||||
|
||||
// Is this prim part of the group
|
||||
if (obj.HasChildPrim(localID))
|
||||
{
|
||||
// Currently only grab/touch for the single prim
|
||||
// the client handles rez correctly
|
||||
obj.ObjectGrabHandler(localID, offsetPos, remoteClient);
|
||||
|
||||
// trigger event, one for each prim part in the group
|
||||
// so that a touch to a non-root prim in a group will still
|
||||
// trigger a touch_start for a script in the root prim
|
||||
foreach (SceneObjectPart part in obj.Children.Values)
|
||||
{
|
||||
EventManager.TriggerObjectGrab(part.LocalID, part.OffsetPosition, remoteClient);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void ProcessAvatarPickerRequest(IClientAPI client, LLUUID avatarID, LLUUID RequestID, string query)
|
||||
{
|
||||
//EventManager.TriggerAvatarPickerRequest();
|
||||
|
||||
List<AvatarPickerAvatar> AvatarResponses = new List<AvatarPickerAvatar>();
|
||||
AvatarResponses = m_sceneGridService.GenerateAgentPickerRequestResponse(RequestID, query);
|
||||
|
||||
AvatarPickerReplyPacket replyPacket = (AvatarPickerReplyPacket) PacketPool.Instance.GetPacket(PacketType.AvatarPickerReply);
|
||||
// TODO: don't create new blocks if recycling an old packet
|
||||
|
||||
AvatarPickerReplyPacket.DataBlock[] searchData =
|
||||
new AvatarPickerReplyPacket.DataBlock[AvatarResponses.Count];
|
||||
AvatarPickerReplyPacket.AgentDataBlock agentData = new AvatarPickerReplyPacket.AgentDataBlock();
|
||||
|
||||
agentData.AgentID = avatarID;
|
||||
agentData.QueryID = RequestID;
|
||||
replyPacket.AgentData = agentData;
|
||||
//byte[] bytes = new byte[AvatarResponses.Count*32];
|
||||
|
||||
int i = 0;
|
||||
foreach (AvatarPickerAvatar item in AvatarResponses)
|
||||
{
|
||||
LLUUID translatedIDtem = item.AvatarID;
|
||||
searchData[i] = new AvatarPickerReplyPacket.DataBlock();
|
||||
searchData[i].AvatarID = translatedIDtem;
|
||||
searchData[i].FirstName = Helpers.StringToField((string) item.firstName);
|
||||
searchData[i].LastName = Helpers.StringToField((string) item.lastName);
|
||||
i++;
|
||||
}
|
||||
if (AvatarResponses.Count == 0)
|
||||
{
|
||||
searchData = new AvatarPickerReplyPacket.DataBlock[0];
|
||||
}
|
||||
replyPacket.Data = searchData;
|
||||
client.SendAvatarPickerReply(replyPacket);
|
||||
}
|
||||
|
||||
// rex, added
|
||||
public void ProcessRexClientScriptCommand(IClientAPI remoteClient,LLUUID agentID,List<string> vParams)
|
||||
{
|
||||
EventManager.TriggerOnRexClientScriptCommand(GetScenePresence(agentID), vParams);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,198 +1,209 @@
|
|||
/*
|
||||
* 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 OpenSim 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 libsecondlife;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Communications.Cache;
|
||||
using OpenSim.Framework.Console;
|
||||
using OpenSim.Region.Terrain;
|
||||
|
||||
namespace OpenSim.Region.Environment.Scenes
|
||||
{
|
||||
public abstract class SceneBase : IScene
|
||||
{
|
||||
#region Events
|
||||
|
||||
public event restart OnRestart;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Fields
|
||||
|
||||
private readonly ClientManager m_clientManager = new ClientManager();
|
||||
|
||||
public ClientManager ClientManager
|
||||
{
|
||||
get { return m_clientManager; }
|
||||
}
|
||||
|
||||
protected ulong m_regionHandle;
|
||||
protected string m_regionName;
|
||||
protected RegionInfo m_regInfo;
|
||||
|
||||
public TerrainEngine Terrain;
|
||||
|
||||
protected EventManager m_eventManager;
|
||||
|
||||
public EventManager EventManager
|
||||
{
|
||||
get { return m_eventManager; }
|
||||
}
|
||||
|
||||
protected string m_datastore;
|
||||
|
||||
private uint m_nextLocalId = 8880000;
|
||||
|
||||
private AssetCache m_assetCache;
|
||||
|
||||
public AssetCache AssetCache
|
||||
{
|
||||
get { return m_assetCache; }
|
||||
set { m_assetCache = value; }
|
||||
}
|
||||
|
||||
protected RegionStatus m_regStatus;
|
||||
|
||||
public RegionStatus Region_Status
|
||||
{
|
||||
get { return m_regStatus; }
|
||||
set { m_regStatus = value; }
|
||||
}
|
||||
|
||||
public bool RexMode
|
||||
{
|
||||
get { return m_rexMode; }
|
||||
set { m_rexMode = value; }
|
||||
}
|
||||
public bool m_rexMode;
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Update Methods
|
||||
|
||||
/// <summary>
|
||||
/// Normally called once every frame/tick to let the world preform anything required (like running the physics simulation)
|
||||
/// </summary>
|
||||
public abstract void Update();
|
||||
|
||||
#endregion
|
||||
|
||||
#region Terrain Methods
|
||||
|
||||
/// <summary>
|
||||
/// Loads the World heightmap
|
||||
/// </summary>
|
||||
public abstract void LoadWorldMap();
|
||||
|
||||
/// <summary>
|
||||
/// Send the region heightmap to the client
|
||||
/// </summary>
|
||||
/// <param name="RemoteClient">Client to send to</param>
|
||||
public virtual void SendLayerData(IClientAPI RemoteClient)
|
||||
{
|
||||
RemoteClient.SendLayerData(Terrain.GetHeights1D());
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Add/Remove Agent/Avatar
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="remoteClient"></param>
|
||||
/// <param name="agentID"></param>
|
||||
/// <param name="child"></param>
|
||||
public abstract void AddNewClient(IClientAPI client, bool child);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="agentID"></param>
|
||||
public abstract void RemoveClient(LLUUID agentID);
|
||||
public abstract void RemoveClient(LLUUID agentID, uint circuitCode);
|
||||
|
||||
public abstract void CloseAllAgents(uint circuitcode);
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public virtual RegionInfo RegionInfo
|
||||
{
|
||||
get { return m_regInfo; }
|
||||
}
|
||||
|
||||
public uint NextLocalId
|
||||
{
|
||||
get { return m_nextLocalId++; }
|
||||
}
|
||||
|
||||
#region admin stuff
|
||||
|
||||
/// <summary>
|
||||
/// Region Restart - Seconds till restart.
|
||||
/// </summary>
|
||||
/// <param name="seconds"></param>
|
||||
public virtual void Restart(int seconds)
|
||||
{
|
||||
MainLog.Instance.Error("REGION", "passing Restart Message up the namespace");
|
||||
OnRestart(RegionInfo);
|
||||
}
|
||||
|
||||
public virtual bool PresenceChildStatus(LLUUID avatarID)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
public abstract bool OtherRegionUp(RegionInfo thisRegion);
|
||||
|
||||
#endregion
|
||||
|
||||
#region Shutdown
|
||||
|
||||
/// <summary>
|
||||
/// Tidy before shutdown
|
||||
/// </summary>
|
||||
public virtual void Close()
|
||||
{
|
||||
try
|
||||
{
|
||||
EventManager.TriggerShutdown();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
MainLog.Instance.Error("SCENE", "SceneBase.cs: Close() - Failed with exception " + e.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 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 OpenSim 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 libsecondlife;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Communications.Cache;
|
||||
using OpenSim.Framework.Console;
|
||||
using OpenSim.Region.Terrain;
|
||||
using OpenSim.Region.Environment.Interfaces;
|
||||
|
||||
namespace OpenSim.Region.Environment.Scenes
|
||||
{
|
||||
public abstract class SceneBase : IScene
|
||||
{
|
||||
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
#region Events
|
||||
|
||||
public event restart OnRestart;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Fields
|
||||
|
||||
private readonly ClientManager m_clientManager = new ClientManager();
|
||||
|
||||
public ClientManager ClientManager
|
||||
{
|
||||
get { return m_clientManager; }
|
||||
}
|
||||
|
||||
protected ulong m_regionHandle;
|
||||
protected string m_regionName;
|
||||
protected RegionInfo m_regInfo;
|
||||
|
||||
public TerrainEngine Terrain;
|
||||
public ITerrainChannel Heightmap;
|
||||
|
||||
protected EventManager m_eventManager;
|
||||
|
||||
public EventManager EventManager
|
||||
{
|
||||
get { return m_eventManager; }
|
||||
}
|
||||
|
||||
protected string m_datastore;
|
||||
|
||||
private uint m_nextLocalId = 8880000;
|
||||
|
||||
private AssetCache m_assetCache;
|
||||
|
||||
public AssetCache AssetCache
|
||||
{
|
||||
get { return m_assetCache; }
|
||||
set { m_assetCache = value; }
|
||||
}
|
||||
|
||||
protected RegionStatus m_regStatus;
|
||||
|
||||
public RegionStatus Region_Status
|
||||
{
|
||||
get { return m_regStatus; }
|
||||
set { m_regStatus = value; }
|
||||
}
|
||||
|
||||
public bool RexMode
|
||||
{
|
||||
get { return m_rexMode; }
|
||||
set { m_rexMode = value; }
|
||||
}
|
||||
public bool m_rexMode;
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Update Methods
|
||||
|
||||
/// <summary>
|
||||
/// Normally called once every frame/tick to let the world preform anything required (like running the physics simulation)
|
||||
/// </summary>
|
||||
public abstract void Update();
|
||||
|
||||
#endregion
|
||||
|
||||
#region Terrain Methods
|
||||
|
||||
/// <summary>
|
||||
/// Loads the World heightmap
|
||||
/// </summary>
|
||||
public abstract void LoadWorldMap();
|
||||
|
||||
/// <summary>
|
||||
/// Send the region heightmap to the client
|
||||
/// </summary>
|
||||
/// <param name="RemoteClient">Client to send to</param>
|
||||
public virtual void SendLayerData(IClientAPI RemoteClient)
|
||||
{
|
||||
RemoteClient.SendLayerData(Terrain.GetHeights1D());
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Add/Remove Agent/Avatar
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="remoteClient"></param>
|
||||
/// <param name="agentID"></param>
|
||||
/// <param name="child"></param>
|
||||
public abstract void AddNewClient(IClientAPI client, bool child);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="agentID"></param>
|
||||
public abstract void RemoveClient(LLUUID agentID);
|
||||
public abstract void RemoveClient(LLUUID agentID, uint circuitCode);
|
||||
|
||||
public abstract void CloseAllAgents(uint circuitcode);
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public virtual RegionInfo RegionInfo
|
||||
{
|
||||
get { return m_regInfo; }
|
||||
}
|
||||
|
||||
public uint NextLocalId
|
||||
{
|
||||
get { return m_nextLocalId++; }
|
||||
}
|
||||
|
||||
#region admin stuff
|
||||
|
||||
/// <summary>
|
||||
/// Region Restart - Seconds till restart.
|
||||
/// </summary>
|
||||
/// <param name="seconds"></param>
|
||||
public virtual void Restart(int seconds)
|
||||
{
|
||||
m_log.Error("[REGION]: passing Restart Message up the namespace");
|
||||
restart handler001 = OnRestart;
|
||||
if (handler001 != null)
|
||||
handler001(RegionInfo);
|
||||
}
|
||||
|
||||
public virtual bool PresenceChildStatus(LLUUID avatarID)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
public abstract bool OtherRegionUp(RegionInfo thisRegion);
|
||||
|
||||
public virtual string GetSimulatorVersion()
|
||||
{
|
||||
return "OpenSimulator v0.5 SVN";
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Shutdown
|
||||
|
||||
/// <summary>
|
||||
/// Tidy before shutdown
|
||||
/// </summary>
|
||||
public virtual void Close()
|
||||
{
|
||||
try
|
||||
{
|
||||
EventManager.TriggerShutdown();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.Error("[SCENE]: SceneBase.cs: Close() - Failed with exception " + e.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,437 +1,441 @@
|
|||
/*
|
||||
* 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 OpenSim 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 libsecondlife;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Console;
|
||||
|
||||
namespace OpenSim.Region.Environment.Scenes
|
||||
{
|
||||
public delegate void RestartSim(RegionInfo thisregion);
|
||||
|
||||
public class SceneManager
|
||||
{
|
||||
public event RestartSim OnRestartSim;
|
||||
|
||||
private readonly List<Scene> m_localScenes;
|
||||
private Scene m_currentScene = null;
|
||||
|
||||
public Scene CurrentScene
|
||||
{
|
||||
get { return m_currentScene; }
|
||||
}
|
||||
|
||||
public Scene CurrentOrFirstScene
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_currentScene == null)
|
||||
{
|
||||
return m_localScenes[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
return m_currentScene;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public SceneManager()
|
||||
{
|
||||
m_localScenes = new List<Scene>();
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
for (int i = 0; i < m_localScenes.Count; i++)
|
||||
{
|
||||
m_localScenes[i].Close();
|
||||
}
|
||||
}
|
||||
|
||||
public void Close(Scene cscene)
|
||||
{
|
||||
if (m_localScenes.Contains(cscene))
|
||||
{
|
||||
for (int i = 0; i < m_localScenes.Count; i++)
|
||||
{
|
||||
if (m_localScenes[i].Equals(cscene))
|
||||
{
|
||||
m_localScenes[i].Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Add(Scene scene)
|
||||
{
|
||||
scene.OnRestart += HandleRestart;
|
||||
m_localScenes.Add(scene);
|
||||
}
|
||||
|
||||
public void HandleRestart(RegionInfo rdata)
|
||||
{
|
||||
MainLog.Instance.Error("SCENEMANAGER",
|
||||
"Got Restart message for region:" + rdata.RegionName + " Sending up to main");
|
||||
int RegionSceneElement = -1;
|
||||
for (int i = 0; i < m_localScenes.Count; i++)
|
||||
{
|
||||
if (rdata.RegionName == m_localScenes[i].RegionInfo.RegionName)
|
||||
{
|
||||
RegionSceneElement = i;
|
||||
}
|
||||
}
|
||||
|
||||
// Now we make sure the region is no longer known about by the SceneManager
|
||||
// Prevents duplicates.
|
||||
|
||||
if (RegionSceneElement >= 0)
|
||||
{
|
||||
m_localScenes.RemoveAt(RegionSceneElement);
|
||||
}
|
||||
|
||||
// Send signal to main that we're restarting this sim.
|
||||
OnRestartSim(rdata);
|
||||
}
|
||||
|
||||
public void SendSimOnlineNotification(ulong regionHandle)
|
||||
{
|
||||
RegionInfo Result = null;
|
||||
|
||||
for (int i = 0; i < m_localScenes.Count; i++)
|
||||
{
|
||||
if (m_localScenes[i].RegionInfo.RegionHandle == regionHandle)
|
||||
{
|
||||
// Inform other regions to tell their avatar about me
|
||||
Result = m_localScenes[i].RegionInfo;
|
||||
}
|
||||
}
|
||||
if (!(Result.Equals(null)))
|
||||
{
|
||||
for (int i = 0; i < m_localScenes.Count; i++)
|
||||
{
|
||||
if (m_localScenes[i].RegionInfo.RegionHandle != regionHandle)
|
||||
{
|
||||
// Inform other regions to tell their avatar about me
|
||||
//m_localScenes[i].OtherRegionUp(Result);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MainLog.Instance.Error("REGION", "Unable to notify Other regions of this Region coming up");
|
||||
}
|
||||
}
|
||||
|
||||
public void SaveCurrentSceneToXml(string filename)
|
||||
{
|
||||
CurrentOrFirstScene.SavePrimsToXml(filename);
|
||||
}
|
||||
|
||||
public void LoadCurrentSceneFromXml(string filename, bool generateNewIDs, LLVector3 loadOffset)
|
||||
{
|
||||
CurrentOrFirstScene.LoadPrimsFromXml(filename, generateNewIDs, loadOffset);
|
||||
}
|
||||
|
||||
public void SaveCurrentSceneToXml2(string filename)
|
||||
{
|
||||
CurrentOrFirstScene.SavePrimsToXml2(filename);
|
||||
}
|
||||
|
||||
public void LoadCurrentSceneFromXml2(string filename)
|
||||
{
|
||||
CurrentOrFirstScene.LoadPrimsFromXml2(filename);
|
||||
}
|
||||
|
||||
public bool RunTerrainCmdOnCurrentScene(string[] cmdparams, ref string result)
|
||||
{
|
||||
if (m_currentScene == null)
|
||||
{
|
||||
bool success = true;
|
||||
foreach (Scene scene in m_localScenes)
|
||||
{
|
||||
if (!scene.Terrain.RunTerrainCmd(cmdparams, ref result, scene.RegionInfo.RegionName))
|
||||
{
|
||||
success = false;
|
||||
}
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
else
|
||||
{
|
||||
return m_currentScene.Terrain.RunTerrainCmd(cmdparams, ref result, m_currentScene.RegionInfo.RegionName);
|
||||
}
|
||||
}
|
||||
|
||||
public void SendCommandToCurrentSceneScripts(string[] cmdparams)
|
||||
{
|
||||
ForEachCurrentScene(delegate(Scene scene) { scene.SendCommandToPlugins(cmdparams); });
|
||||
}
|
||||
|
||||
// rex new function
|
||||
public void SendPythonScriptCommand(string[] cmdparams)
|
||||
{
|
||||
ForEachCurrentScene(delegate(Scene scene) { scene.EventManager.TriggerOnPythonScriptCommand(cmdparams[0]); });
|
||||
}
|
||||
|
||||
public void SetBypassPermissionsOnCurrentScene(bool bypassPermissions)
|
||||
{
|
||||
ForEachCurrentScene(delegate(Scene scene) { scene.PermissionsMngr.BypassPermissions = bypassPermissions; });
|
||||
}
|
||||
|
||||
private void ForEachCurrentScene(Action<Scene> func)
|
||||
{
|
||||
if (m_currentScene == null)
|
||||
{
|
||||
m_localScenes.ForEach(func);
|
||||
}
|
||||
else
|
||||
{
|
||||
func(m_currentScene);
|
||||
}
|
||||
}
|
||||
|
||||
public void RestartCurrentScene()
|
||||
{
|
||||
ForEachCurrentScene(delegate(Scene scene) { scene.RestartNow(); });
|
||||
}
|
||||
|
||||
public void BackupCurrentScene()
|
||||
{
|
||||
ForEachCurrentScene(delegate(Scene scene) { scene.Backup(); });
|
||||
}
|
||||
|
||||
// rex, new function
|
||||
public void ForcedBackupCurrentScene()
|
||||
{
|
||||
ForEachCurrentScene(delegate(Scene scene) { scene.ForcedBackup(); });
|
||||
}
|
||||
|
||||
public void HandleAlertCommandOnCurrentScene(string[] cmdparams)
|
||||
{
|
||||
ForEachCurrentScene(delegate(Scene scene) { scene.HandleAlertCommand(cmdparams); });
|
||||
}
|
||||
|
||||
public void SendGeneralMessage(string msg)
|
||||
{
|
||||
ForEachCurrentScene(delegate(Scene scene) { scene.SendGeneralAlert(msg); });
|
||||
}
|
||||
|
||||
public bool TrySetCurrentScene(string regionName)
|
||||
{
|
||||
if ((String.Compare(regionName, "root") == 0) || (String.Compare(regionName, "..") == 0))
|
||||
{
|
||||
m_currentScene = null;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Searching for Region: '" + regionName + "'");
|
||||
|
||||
foreach (Scene scene in m_localScenes)
|
||||
{
|
||||
if (String.Compare(scene.RegionInfo.RegionName, regionName, true) == 0)
|
||||
{
|
||||
m_currentScene = scene;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public bool TryGetScene(string regionName, out Scene scene)
|
||||
{
|
||||
foreach (Scene mscene in m_localScenes)
|
||||
{
|
||||
if (String.Compare(mscene.RegionInfo.RegionName, regionName, true) == 0)
|
||||
{
|
||||
scene = mscene;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
scene = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool TryGetScene(LLUUID regionID, out Scene scene)
|
||||
{
|
||||
foreach (Scene mscene in m_localScenes)
|
||||
{
|
||||
if (mscene.RegionInfo.RegionID == regionID)
|
||||
{
|
||||
scene = mscene;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
scene = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
public void SetDebugPacketOnCurrentScene(LogBase log, int newDebug)
|
||||
{
|
||||
ForEachCurrentScene(delegate(Scene scene)
|
||||
{
|
||||
List<EntityBase> EntitieList = scene.GetEntities();
|
||||
|
||||
foreach (EntityBase entity in EntitieList)
|
||||
{
|
||||
if (entity is ScenePresence)
|
||||
{
|
||||
ScenePresence scenePrescence = entity as ScenePresence;
|
||||
if (!scenePrescence.IsChildAgent)
|
||||
{
|
||||
log.Error(String.Format("Packet debug for {0} {1} set to {2}",
|
||||
scenePrescence.Firstname,
|
||||
scenePrescence.Lastname,
|
||||
newDebug));
|
||||
|
||||
scenePrescence.ControllingClient.SetDebug(newDebug);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public List<ScenePresence> GetCurrentSceneAvatars()
|
||||
{
|
||||
List<ScenePresence> avatars = new List<ScenePresence>();
|
||||
|
||||
ForEachCurrentScene(delegate(Scene scene)
|
||||
{
|
||||
List<EntityBase> EntitieList = scene.GetEntities();
|
||||
|
||||
foreach (EntityBase entity in EntitieList)
|
||||
{
|
||||
if (entity is ScenePresence)
|
||||
{
|
||||
ScenePresence scenePrescence = entity as ScenePresence;
|
||||
if (!scenePrescence.IsChildAgent)
|
||||
{
|
||||
avatars.Add(scenePrescence);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return avatars;
|
||||
}
|
||||
|
||||
public RegionInfo GetRegionInfo(ulong regionHandle)
|
||||
{
|
||||
foreach (Scene scene in m_localScenes)
|
||||
{
|
||||
if (scene.RegionInfo.RegionHandle == regionHandle)
|
||||
{
|
||||
return scene.RegionInfo;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void SetCurrentSceneTimePhase(int timePhase)
|
||||
{
|
||||
ForEachCurrentScene(delegate(Scene scene)
|
||||
{
|
||||
scene.SetTimePhase(
|
||||
timePhase)
|
||||
;
|
||||
});
|
||||
}
|
||||
|
||||
public void ForceCurrentSceneClientUpdate()
|
||||
{
|
||||
ForEachCurrentScene(delegate(Scene scene) { scene.ForceClientUpdate(); });
|
||||
}
|
||||
|
||||
public void HandleEditCommandOnCurrentScene(string[] cmdparams)
|
||||
{
|
||||
ForEachCurrentScene(delegate(Scene scene) { scene.HandleEditCommand(cmdparams); });
|
||||
}
|
||||
|
||||
public bool TryGetAvatar(LLUUID avatarId, out ScenePresence avatar)
|
||||
{
|
||||
foreach (Scene scene in m_localScenes)
|
||||
{
|
||||
if (scene.TryGetAvatar(avatarId, out avatar))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
avatar = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool TryGetAvatarsScene(LLUUID avatarId, out Scene scene)
|
||||
{
|
||||
ScenePresence avatar = null;
|
||||
foreach (Scene mScene in m_localScenes)
|
||||
{
|
||||
if (mScene.TryGetAvatar(avatarId, out avatar))
|
||||
{
|
||||
scene = mScene;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
scene = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
public void CloseScene(Scene scene)
|
||||
{
|
||||
m_localScenes.Remove(scene);
|
||||
scene.Close();
|
||||
}
|
||||
|
||||
public bool TryGetAvatarByName(string avatarName, out ScenePresence avatar)
|
||||
{
|
||||
foreach (Scene scene in m_localScenes)
|
||||
{
|
||||
if (scene.TryGetAvatarByName(avatarName, out avatar))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
avatar = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
public void ForEachScene(Action<Scene> action)
|
||||
{
|
||||
m_localScenes.ForEach(action);
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 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 OpenSim 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 libsecondlife;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Console;
|
||||
|
||||
namespace OpenSim.Region.Environment.Scenes
|
||||
{
|
||||
public delegate void RestartSim(RegionInfo thisregion);
|
||||
|
||||
public class SceneManager
|
||||
{
|
||||
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
public event RestartSim OnRestartSim;
|
||||
|
||||
private readonly List<Scene> m_localScenes;
|
||||
private Scene m_currentScene = null;
|
||||
|
||||
public List<Scene> Scenes
|
||||
{
|
||||
get { return m_localScenes; }
|
||||
}
|
||||
|
||||
public Scene CurrentScene
|
||||
{
|
||||
get { return m_currentScene; }
|
||||
}
|
||||
|
||||
public Scene CurrentOrFirstScene
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_currentScene == null)
|
||||
{
|
||||
return m_localScenes[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
return m_currentScene;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public SceneManager()
|
||||
{
|
||||
m_localScenes = new List<Scene>();
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
for (int i = 0; i < m_localScenes.Count; i++)
|
||||
{
|
||||
m_localScenes[i].Close();
|
||||
}
|
||||
}
|
||||
|
||||
public void Close(Scene cscene)
|
||||
{
|
||||
if (m_localScenes.Contains(cscene))
|
||||
{
|
||||
for (int i = 0; i < m_localScenes.Count; i++)
|
||||
{
|
||||
if (m_localScenes[i].Equals(cscene))
|
||||
{
|
||||
m_localScenes[i].Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Add(Scene scene)
|
||||
{
|
||||
scene.OnRestart += HandleRestart;
|
||||
m_localScenes.Add(scene);
|
||||
}
|
||||
|
||||
public void HandleRestart(RegionInfo rdata)
|
||||
{
|
||||
m_log.Error("[SCENEMANAGER]: Got Restart message for region:" + rdata.RegionName + " Sending up to main");
|
||||
int RegionSceneElement = -1;
|
||||
for (int i = 0; i < m_localScenes.Count; i++)
|
||||
{
|
||||
if (rdata.RegionName == m_localScenes[i].RegionInfo.RegionName)
|
||||
{
|
||||
RegionSceneElement = i;
|
||||
}
|
||||
}
|
||||
|
||||
// Now we make sure the region is no longer known about by the SceneManager
|
||||
// Prevents duplicates.
|
||||
|
||||
if (RegionSceneElement >= 0)
|
||||
{
|
||||
m_localScenes.RemoveAt(RegionSceneElement);
|
||||
}
|
||||
|
||||
// Send signal to main that we're restarting this sim.
|
||||
OnRestartSim(rdata);
|
||||
}
|
||||
|
||||
public void SendSimOnlineNotification(ulong regionHandle)
|
||||
{
|
||||
RegionInfo Result = null;
|
||||
|
||||
for (int i = 0; i < m_localScenes.Count; i++)
|
||||
{
|
||||
if (m_localScenes[i].RegionInfo.RegionHandle == regionHandle)
|
||||
{
|
||||
// Inform other regions to tell their avatar about me
|
||||
Result = m_localScenes[i].RegionInfo;
|
||||
}
|
||||
}
|
||||
if (!(Result.Equals(null)))
|
||||
{
|
||||
for (int i = 0; i < m_localScenes.Count; i++)
|
||||
{
|
||||
if (m_localScenes[i].RegionInfo.RegionHandle != regionHandle)
|
||||
{
|
||||
// Inform other regions to tell their avatar about me
|
||||
//m_localScenes[i].OtherRegionUp(Result);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_log.Error("[REGION]: Unable to notify Other regions of this Region coming up");
|
||||
}
|
||||
}
|
||||
|
||||
public void SaveCurrentSceneToXml(string filename)
|
||||
{
|
||||
CurrentOrFirstScene.SavePrimsToXml(filename);
|
||||
}
|
||||
|
||||
public void LoadCurrentSceneFromXml(string filename, bool generateNewIDs, LLVector3 loadOffset)
|
||||
{
|
||||
CurrentOrFirstScene.LoadPrimsFromXml(filename, generateNewIDs, loadOffset);
|
||||
}
|
||||
|
||||
public void SaveCurrentSceneToXml2(string filename)
|
||||
{
|
||||
CurrentOrFirstScene.SavePrimsToXml2(filename);
|
||||
}
|
||||
|
||||
public void LoadCurrentSceneFromXml2(string filename)
|
||||
{
|
||||
CurrentOrFirstScene.LoadPrimsFromXml2(filename);
|
||||
}
|
||||
|
||||
public bool RunTerrainCmdOnCurrentScene(string[] cmdparams, ref string result)
|
||||
{
|
||||
if (m_currentScene == null)
|
||||
{
|
||||
bool success = true;
|
||||
foreach (Scene scene in m_localScenes)
|
||||
{
|
||||
if (!scene.Terrain.RunTerrainCmd(cmdparams, ref result, scene.RegionInfo.RegionName))
|
||||
{
|
||||
success = false;
|
||||
}
|
||||
|
||||
// Messy way of preventing us printing out the same help text for each scene
|
||||
if (cmdparams.Length <= 0 || cmdparams[0] == "help")
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
else
|
||||
{
|
||||
return m_currentScene.Terrain.RunTerrainCmd(cmdparams, ref result, m_currentScene.RegionInfo.RegionName);
|
||||
}
|
||||
}
|
||||
|
||||
public void SendCommandToCurrentSceneScripts(string[] cmdparams)
|
||||
{
|
||||
ForEachCurrentScene(delegate(Scene scene) { scene.SendCommandToPlugins(cmdparams); });
|
||||
}
|
||||
|
||||
// rex new function
|
||||
public void SendPythonScriptCommand(string[] cmdparams)
|
||||
{
|
||||
ForEachCurrentScene(delegate(Scene scene) { scene.EventManager.TriggerOnPythonScriptCommand(cmdparams[0]); });
|
||||
}
|
||||
|
||||
public void SetBypassPermissionsOnCurrentScene(bool bypassPermissions)
|
||||
{
|
||||
ForEachCurrentScene(delegate(Scene scene) { scene.PermissionsMngr.BypassPermissions = bypassPermissions; });
|
||||
}
|
||||
|
||||
private void ForEachCurrentScene(Action<Scene> func)
|
||||
{
|
||||
if (m_currentScene == null)
|
||||
{
|
||||
m_localScenes.ForEach(func);
|
||||
}
|
||||
else
|
||||
{
|
||||
func(m_currentScene);
|
||||
}
|
||||
}
|
||||
|
||||
public void RestartCurrentScene()
|
||||
{
|
||||
ForEachCurrentScene(delegate(Scene scene) { scene.RestartNow(); });
|
||||
}
|
||||
|
||||
public void BackupCurrentScene()
|
||||
{
|
||||
ForEachCurrentScene(delegate(Scene scene) { scene.Backup(); });
|
||||
}
|
||||
|
||||
// rex, new function
|
||||
public void ForcedBackupCurrentScene()
|
||||
{
|
||||
ForEachCurrentScene(delegate(Scene scene) { scene.ForcedBackup(); });
|
||||
}
|
||||
|
||||
public void HandleAlertCommandOnCurrentScene(string[] cmdparams)
|
||||
{
|
||||
ForEachCurrentScene(delegate(Scene scene) { scene.HandleAlertCommand(cmdparams); });
|
||||
}
|
||||
|
||||
public void SendGeneralMessage(string msg)
|
||||
{
|
||||
ForEachCurrentScene(delegate(Scene scene) { scene.SendGeneralAlert(msg); });
|
||||
}
|
||||
|
||||
public bool TrySetCurrentScene(string regionName)
|
||||
{
|
||||
if ((String.Compare(regionName, "root") == 0) || (String.Compare(regionName, "..") == 0))
|
||||
{
|
||||
m_currentScene = null;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Searching for Region: '" + regionName + "'");
|
||||
|
||||
foreach (Scene scene in m_localScenes)
|
||||
{
|
||||
if (String.Compare(scene.RegionInfo.RegionName, regionName, true) == 0)
|
||||
{
|
||||
m_currentScene = scene;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public bool TryGetScene(string regionName, out Scene scene)
|
||||
{
|
||||
foreach (Scene mscene in m_localScenes)
|
||||
{
|
||||
if (String.Compare(mscene.RegionInfo.RegionName, regionName, true) == 0)
|
||||
{
|
||||
scene = mscene;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
scene = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool TryGetScene(LLUUID regionID, out Scene scene)
|
||||
{
|
||||
foreach (Scene mscene in m_localScenes)
|
||||
{
|
||||
if (mscene.RegionInfo.RegionID == regionID)
|
||||
{
|
||||
scene = mscene;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
scene = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
public void SetDebugPacketOnCurrentScene(int newDebug)
|
||||
{
|
||||
ForEachCurrentScene(delegate(Scene scene)
|
||||
{
|
||||
List<ScenePresence> scenePresences = scene.GetScenePresences();
|
||||
|
||||
foreach (ScenePresence scenePresence in scenePresences)
|
||||
{
|
||||
if (!scenePresence.IsChildAgent)
|
||||
{
|
||||
m_log.ErrorFormat("Packet debug for {0} {1} set to {2}",
|
||||
scenePresence.Firstname,
|
||||
scenePresence.Lastname,
|
||||
newDebug);
|
||||
|
||||
scenePresence.ControllingClient.SetDebug(newDebug);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public List<ScenePresence> GetCurrentSceneAvatars()
|
||||
{
|
||||
List<ScenePresence> avatars = new List<ScenePresence>();
|
||||
|
||||
ForEachCurrentScene(delegate(Scene scene)
|
||||
{
|
||||
List<ScenePresence> scenePrescences = scene.GetScenePresences();
|
||||
|
||||
foreach (ScenePresence scenePrescence in scenePrescences)
|
||||
{
|
||||
if (!scenePrescence.IsChildAgent)
|
||||
{
|
||||
avatars.Add(scenePrescence);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return avatars;
|
||||
}
|
||||
|
||||
public RegionInfo GetRegionInfo(ulong regionHandle)
|
||||
{
|
||||
foreach (Scene scene in m_localScenes)
|
||||
{
|
||||
if (scene.RegionInfo.RegionHandle == regionHandle)
|
||||
{
|
||||
return scene.RegionInfo;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void SetCurrentSceneTimePhase(int timePhase)
|
||||
{
|
||||
ForEachCurrentScene(delegate(Scene scene)
|
||||
{
|
||||
scene.SetTimePhase(
|
||||
timePhase)
|
||||
;
|
||||
});
|
||||
}
|
||||
|
||||
public void ForceCurrentSceneClientUpdate()
|
||||
{
|
||||
ForEachCurrentScene(delegate(Scene scene) { scene.ForceClientUpdate(); });
|
||||
}
|
||||
|
||||
public void HandleEditCommandOnCurrentScene(string[] cmdparams)
|
||||
{
|
||||
ForEachCurrentScene(delegate(Scene scene) { scene.HandleEditCommand(cmdparams); });
|
||||
}
|
||||
|
||||
public bool TryGetAvatar(LLUUID avatarId, out ScenePresence avatar)
|
||||
{
|
||||
foreach (Scene scene in m_localScenes)
|
||||
{
|
||||
if (scene.TryGetAvatar(avatarId, out avatar))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
avatar = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool TryGetAvatarsScene(LLUUID avatarId, out Scene scene)
|
||||
{
|
||||
ScenePresence avatar = null;
|
||||
foreach (Scene mScene in m_localScenes)
|
||||
{
|
||||
if (mScene.TryGetAvatar(avatarId, out avatar))
|
||||
{
|
||||
scene = mScene;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
scene = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
public void CloseScene(Scene scene)
|
||||
{
|
||||
m_localScenes.Remove(scene);
|
||||
scene.Close();
|
||||
}
|
||||
|
||||
public bool TryGetAvatarByName(string avatarName, out ScenePresence avatar)
|
||||
{
|
||||
foreach (Scene scene in m_localScenes)
|
||||
{
|
||||
if (scene.TryGetAvatarByName(avatarName, out avatar))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
avatar = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
public void ForEachScene(Action<Scene> action)
|
||||
{
|
||||
m_localScenes.ForEach(action);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,180 +1,275 @@
|
|||
/*
|
||||
* 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 OpenSim 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 libsecondlife;
|
||||
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Console;
|
||||
using OpenSim.Region.Environment.Interfaces;
|
||||
|
||||
namespace OpenSim.Region.Environment.Scenes
|
||||
{
|
||||
public partial class SceneObjectGroup : EntityBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Start a given script.
|
||||
/// </summary>
|
||||
/// <param name="localID">
|
||||
/// A <see cref="System.UInt32"/>
|
||||
/// </param>
|
||||
public void StartScript(uint localID, LLUUID itemID)
|
||||
{
|
||||
SceneObjectPart part = GetChildPart(localID);
|
||||
if (part != null)
|
||||
{
|
||||
part.StartScript(itemID);
|
||||
}
|
||||
else
|
||||
{
|
||||
MainLog.Instance.Error(
|
||||
"PRIMINVENTORY",
|
||||
"Couldn't find part {0} in object group {1}, {2} to start script with ID {3}",
|
||||
localID, Name, UUID, itemID);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Start the scripts contained in all the prims in this group.
|
||||
/// </summary>
|
||||
public void StartScripts()
|
||||
{
|
||||
foreach (SceneObjectPart part in m_parts.Values)
|
||||
{
|
||||
part.StartScripts();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="remoteClient"></param>
|
||||
/// <param name="localID"></param>
|
||||
public bool GetPartInventoryFileName(IClientAPI remoteClient, uint localID)
|
||||
{
|
||||
SceneObjectPart part = GetChildPart(localID);
|
||||
if (part != null)
|
||||
{
|
||||
return part.GetInventoryFileName(remoteClient, localID);
|
||||
}
|
||||
else
|
||||
{
|
||||
MainLog.Instance.Error(
|
||||
"PRIMINVENTORY",
|
||||
"Couldn't find part {0} in object group {1}, {2} to retreive prim inventory",
|
||||
localID, Name, UUID);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void RequestInventoryFile(uint localID, IXfer xferManager)
|
||||
{
|
||||
SceneObjectPart part = GetChildPart(localID);
|
||||
if (part != null)
|
||||
{
|
||||
part.RequestInventoryFile(xferManager);
|
||||
}
|
||||
else
|
||||
{
|
||||
MainLog.Instance.Error(
|
||||
"PRIMINVENTORY",
|
||||
"Couldn't find part {0} in object group {1}, {2} to request inventory data",
|
||||
localID, Name, UUID);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add an inventory item to a prim in this group.
|
||||
/// </summary>
|
||||
/// <param name="remoteClient"></param>
|
||||
/// <param name="localID"></param>
|
||||
/// <param name="item"></param>
|
||||
/// <param name="copyItemID">The item UUID that should be used by the new item.</param>
|
||||
/// <returns></returns>
|
||||
public bool AddInventoryItem(IClientAPI remoteClient, uint localID,
|
||||
InventoryItemBase item, LLUUID copyItemID)
|
||||
{
|
||||
LLUUID newItemId = ((copyItemID != null) ? copyItemID : item.inventoryID);
|
||||
|
||||
SceneObjectPart part = GetChildPart(localID);
|
||||
if (part != null)
|
||||
{
|
||||
TaskInventoryItem taskItem = new TaskInventoryItem();
|
||||
|
||||
taskItem.item_id = newItemId;
|
||||
taskItem.asset_id = item.assetID;
|
||||
taskItem.name = item.inventoryName;
|
||||
taskItem.desc = item.inventoryDescription;
|
||||
taskItem.owner_id = item.avatarID;
|
||||
taskItem.creator_id = item.creatorsID;
|
||||
taskItem.type = TaskInventoryItem.Types[item.assetType];
|
||||
taskItem.inv_type = TaskInventoryItem.InvTypes[item.invType];
|
||||
part.AddInventoryItem(taskItem);
|
||||
|
||||
// It might seem somewhat crude to update the whole group for a single prim inventory change,
|
||||
// but it's possible that other prim inventory changes will take place before the region
|
||||
// persistence thread visits this object. In the future, changes can be signalled at a more
|
||||
// granular level, or we could let the datastore worry about whether prims have really
|
||||
// changed since they were last persisted.
|
||||
HasChanged = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
MainLog.Instance.Error(
|
||||
"PRIMINVENTORY",
|
||||
"Couldn't find prim local ID {0} in group {1}, {2} to add inventory item ID {3}",
|
||||
localID, Name, UUID, newItemId);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public int RemoveInventoryItem(IClientAPI remoteClient, uint localID, LLUUID itemID)
|
||||
{
|
||||
SceneObjectPart part = GetChildPart(localID);
|
||||
if (part != null)
|
||||
{
|
||||
int type = part.RemoveInventoryItem(remoteClient, localID, itemID);
|
||||
|
||||
// It might seem somewhat crude to update the whole group for a single prim inventory change,
|
||||
// but it's possible that other prim inventory changes will take place before the region
|
||||
// persistence thread visits this object. In the future, changes can be signalled at a more
|
||||
// granular level, or we could let the datastore worry about whether prims have really
|
||||
// changed since they were last persisted.
|
||||
HasChanged = true;
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 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 OpenSim 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 libsecondlife;
|
||||
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Console;
|
||||
using OpenSim.Region.Environment.Interfaces;
|
||||
|
||||
namespace OpenSim.Region.Environment.Scenes
|
||||
{
|
||||
public partial class SceneObjectGroup : EntityBase
|
||||
{
|
||||
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
/// <summary>
|
||||
/// Start a given script.
|
||||
/// </summary>
|
||||
/// <param name="localID">
|
||||
/// A <see cref="System.UInt32"/>
|
||||
/// </param>
|
||||
public void StartScript(uint localID, LLUUID itemID)
|
||||
{
|
||||
SceneObjectPart part = GetChildPart(localID);
|
||||
if (part != null)
|
||||
{
|
||||
part.StartScript(itemID);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_log.ErrorFormat(
|
||||
"[PRIMINVENTORY]: " +
|
||||
"Couldn't find part {0} in object group {1}, {2} to start script with ID {3}",
|
||||
localID, Name, UUID, itemID);
|
||||
}
|
||||
}
|
||||
|
||||
// /// Start a given script.
|
||||
// /// </summary>
|
||||
// /// <param name="localID">
|
||||
// /// A <see cref="System.UInt32"/>
|
||||
// /// </param>
|
||||
// public void StartScript(LLUUID partID, LLUUID itemID)
|
||||
// {
|
||||
// SceneObjectPart part = GetChildPart(partID);
|
||||
// if (part != null)
|
||||
// {
|
||||
// part.StartScript(itemID);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// m_log.ErrorFormat(
|
||||
// "[PRIMINVENTORY]: " +
|
||||
// "Couldn't find part {0} in object group {1}, {2} to start script with ID {3}",
|
||||
// localID, Name, UUID, itemID);
|
||||
// }
|
||||
// }
|
||||
|
||||
/// <summary>
|
||||
/// Start the scripts contained in all the prims in this group.
|
||||
/// </summary>
|
||||
public void StartScripts()
|
||||
{
|
||||
// Don't start scripts if they're turned off in the region!
|
||||
if (!((m_scene.RegionInfo.EstateSettings.regionFlags & Simulator.RegionFlags.SkipScripts) == Simulator.RegionFlags.SkipScripts))
|
||||
{
|
||||
foreach (SceneObjectPart part in m_parts.Values)
|
||||
{
|
||||
part.StartScripts();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void StopScripts()
|
||||
{
|
||||
lock (m_parts)
|
||||
{
|
||||
foreach (SceneObjectPart part in m_parts.Values)
|
||||
{
|
||||
part.StopScripts();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Start a given script.
|
||||
/// </summary>
|
||||
/// <param name="localID">
|
||||
/// A <see cref="System.UInt32"/>
|
||||
/// </param>
|
||||
public void StopScript(uint partID, LLUUID itemID)
|
||||
{
|
||||
SceneObjectPart part = GetChildPart(partID);
|
||||
if (part != null)
|
||||
{
|
||||
part.StopScript(itemID);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_log.ErrorFormat(
|
||||
"[PRIMINVENTORY]: " +
|
||||
"Couldn't find part {0} in object group {1}, {2} to stop script with ID {3}",
|
||||
partID, Name, UUID, itemID);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="remoteClient"></param>
|
||||
/// <param name="localID"></param>
|
||||
public bool GetPartInventoryFileName(IClientAPI remoteClient, uint localID)
|
||||
{
|
||||
SceneObjectPart part = GetChildPart(localID);
|
||||
if (part != null)
|
||||
{
|
||||
return part.GetInventoryFileName(remoteClient, localID);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_log.ErrorFormat(
|
||||
"[PRIMINVENTORY]: " +
|
||||
"Couldn't find part {0} in object group {1}, {2} to retreive prim inventory",
|
||||
localID, Name, UUID);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void RequestInventoryFile(uint localID, IXfer xferManager)
|
||||
{
|
||||
SceneObjectPart part = GetChildPart(localID);
|
||||
if (part != null)
|
||||
{
|
||||
part.RequestInventoryFile(xferManager);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_log.ErrorFormat(
|
||||
"[PRIMINVENTORY]: " +
|
||||
"Couldn't find part {0} in object group {1}, {2} to request inventory data",
|
||||
localID, Name, UUID);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add an inventory item to a prim in this group.
|
||||
/// </summary>
|
||||
/// <param name="remoteClient"></param>
|
||||
/// <param name="localID"></param>
|
||||
/// <param name="item"></param>
|
||||
/// <param name="copyItemID">The item UUID that should be used by the new item.</param>
|
||||
/// <returns></returns>
|
||||
public bool AddInventoryItem(IClientAPI remoteClient, uint localID,
|
||||
InventoryItemBase item, LLUUID copyItemID)
|
||||
{
|
||||
LLUUID newItemId = (!copyItemID.Equals(null)) ? copyItemID : item.inventoryID;
|
||||
|
||||
SceneObjectPart part = GetChildPart(localID);
|
||||
if (part != null)
|
||||
{
|
||||
TaskInventoryItem taskItem = new TaskInventoryItem();
|
||||
|
||||
taskItem.ItemID = newItemId;
|
||||
taskItem.AssetID = item.assetID;
|
||||
taskItem.Name = item.inventoryName;
|
||||
taskItem.Description = item.inventoryDescription;
|
||||
taskItem.OwnerID = item.avatarID;
|
||||
taskItem.CreatorID = item.creatorsID;
|
||||
taskItem.Type = item.assetType;
|
||||
taskItem.InvType = item.invType;
|
||||
part.AddInventoryItem(taskItem);
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_log.ErrorFormat(
|
||||
"[PRIMINVENTORY]: " +
|
||||
"Couldn't find prim local ID {0} in group {1}, {2} to add inventory item ID {3}",
|
||||
localID, Name, UUID, newItemId);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns an existing inventory item. Returns the original, so any changes will be live.
|
||||
/// </summary>
|
||||
/// <param name="primID"></param>
|
||||
/// <param name="itemID"></param>
|
||||
/// <returns>null if the item does not exist</returns>
|
||||
public TaskInventoryItem GetInventoryItem(uint primID, LLUUID itemID)
|
||||
{
|
||||
SceneObjectPart part = GetChildPart(primID);
|
||||
if (part != null)
|
||||
{
|
||||
return part.GetInventoryItem(itemID);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_log.ErrorFormat(
|
||||
"[PRIMINVENTORY]: " +
|
||||
"Couldn't find prim local ID {0} in prim {1}, {2} to get inventory item ID {3}",
|
||||
primID, part.Name, part.UUID, itemID);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update an existing inventory item.
|
||||
/// </summary>
|
||||
/// <param name="item">The updated item. An item with the same id must already exist
|
||||
/// in this prim's inventory</param>
|
||||
/// <returns>false if the item did not exist, true if the update occurred succesfully</returns>
|
||||
public bool UpdateInventoryItem(TaskInventoryItem item)
|
||||
{
|
||||
SceneObjectPart part = GetChildPart(item.ParentPartID);
|
||||
if (part != null)
|
||||
{
|
||||
part.UpdateInventoryItem(item);
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_log.ErrorFormat(
|
||||
"[PRIMINVENTORY]: " +
|
||||
"Couldn't find prim ID {0} to update item {1}, {2}",
|
||||
item.ParentPartID, item.Name, item.ItemID);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public int RemoveInventoryItem(uint localID, LLUUID itemID)
|
||||
{
|
||||
SceneObjectPart part = GetChildPart(localID);
|
||||
if (part != null)
|
||||
{
|
||||
int type = part.RemoveInventoryItem(itemID);
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,317 +1,513 @@
|
|||
/*
|
||||
* 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 OpenSim 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.Xml.Serialization;
|
||||
|
||||
using libsecondlife;
|
||||
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Console;
|
||||
using OpenSim.Region.Environment.Interfaces;
|
||||
using OpenSim.Region.Environment.Scenes.Scripting;
|
||||
|
||||
namespace OpenSim.Region.Environment.Scenes
|
||||
{
|
||||
public partial class SceneObjectPart : IScriptHost
|
||||
{
|
||||
private string m_inventoryFileName = "";
|
||||
|
||||
/// <summary>
|
||||
/// The inventory folder for this prim
|
||||
/// </summary>
|
||||
private LLUUID m_folderID = LLUUID.Zero;
|
||||
|
||||
/// <summary>
|
||||
/// Exposing this is not particularly good, but it's one of the least evils at the moment to see
|
||||
/// folder id from prim inventory item data, since it's not (yet) actually stored with the prim.
|
||||
/// </summary>
|
||||
public LLUUID FolderID
|
||||
{
|
||||
get { return m_folderID; }
|
||||
set { m_folderID = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Holds in memory prim inventory
|
||||
/// </summary>
|
||||
protected IDictionary<LLUUID, TaskInventoryItem> m_taskInventory
|
||||
= new Dictionary<LLUUID, TaskInventoryItem>();
|
||||
|
||||
[XmlIgnore]
|
||||
public IDictionary<LLUUID, TaskInventoryItem> TaskInventory
|
||||
{
|
||||
get { return m_taskInventory; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serial count for inventory file , used to tell if inventory has changed
|
||||
/// no need for this to be part of Database backup
|
||||
/// </summary>
|
||||
protected uint m_inventorySerial = 0;
|
||||
|
||||
public uint InventorySerial
|
||||
{
|
||||
get { return m_inventorySerial; }
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Start all the scripts contained in this prim's inventory
|
||||
/// </summary>
|
||||
public void StartScripts()
|
||||
{
|
||||
foreach (TaskInventoryItem item in m_taskInventory.Values)
|
||||
{
|
||||
if ("lsltext" == item.type)
|
||||
{
|
||||
StartScript(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Start a script which is in this prim's inventory.
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
/// <returns></returns>
|
||||
public void StartScript(TaskInventoryItem item)
|
||||
{
|
||||
// MainLog.Instance.Verbose(
|
||||
// "PRIMINVENTORY",
|
||||
// "Starting script {0}, {1} in prim {2}, {3}",
|
||||
// item.name, item.item_id, Name, UUID);
|
||||
|
||||
AssetBase rezAsset = m_parentGroup.Scene.AssetCache.GetAsset(item.asset_id, false);
|
||||
|
||||
if (rezAsset != null)
|
||||
{
|
||||
string script = Helpers.FieldToUTF8String(rezAsset.Data);
|
||||
m_parentGroup.Scene.EventManager.TriggerRezScript(LocalID, item.item_id, script);
|
||||
}
|
||||
else
|
||||
{
|
||||
MainLog.Instance.Error(
|
||||
"PRIMINVENTORY",
|
||||
"Couldn't start script {0}, {1} since asset ID {2} could not be found",
|
||||
item.name, item.item_id, item.asset_id);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Start a script which is in this prim's inventory.
|
||||
/// </summary>
|
||||
/// <param name="itemId">
|
||||
/// A <see cref="LLUUID"/>
|
||||
/// </param>
|
||||
public void StartScript(LLUUID itemId)
|
||||
{
|
||||
if (m_taskInventory.ContainsKey(itemId))
|
||||
{
|
||||
StartScript(m_taskInventory[itemId]);
|
||||
}
|
||||
else
|
||||
{
|
||||
MainLog.Instance.Error(
|
||||
"PRIMINVENTORY",
|
||||
"Couldn't start script with ID {0} since it couldn't be found for prim {1}, {2}",
|
||||
itemId, Name, UUID);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add an item to this prim's inventory.
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
public void AddInventoryItem(TaskInventoryItem item)
|
||||
{
|
||||
item.parent_id = m_folderID;
|
||||
item.creation_date = 1000;
|
||||
item.ParentPartID = UUID;
|
||||
m_taskInventory.Add(item.item_id, item);
|
||||
m_inventorySerial++;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add a whole collection of items to the prim's inventory at once. We assume that the items already
|
||||
/// have all their fields correctly filled out.
|
||||
/// </summary>
|
||||
/// <param name="items"></param>
|
||||
public void AddInventoryItems(ICollection<TaskInventoryItem> items)
|
||||
{
|
||||
foreach (TaskInventoryItem item in items)
|
||||
{
|
||||
m_taskInventory.Add(item.item_id, item);
|
||||
}
|
||||
|
||||
m_inventorySerial++;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove an item from this prim's inventory
|
||||
/// </summary>
|
||||
/// <param name="remoteClient"></param>
|
||||
/// <param name="localID"></param>
|
||||
/// <param name="itemID"></param>
|
||||
/// <returns>Numeric asset type of the item removed.</returns>
|
||||
public int RemoveInventoryItem(IClientAPI remoteClient, uint localID, LLUUID itemID)
|
||||
{
|
||||
if (localID == LocalID)
|
||||
{
|
||||
if (m_taskInventory.ContainsKey(itemID))
|
||||
{
|
||||
string type = m_taskInventory[itemID].inv_type;
|
||||
m_taskInventory.Remove(itemID);
|
||||
m_inventorySerial++;
|
||||
if (type == "lsltext")
|
||||
{
|
||||
return 10;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="client"></param>
|
||||
/// <param name="localID"></param>
|
||||
public bool GetInventoryFileName(IClientAPI client, uint localID)
|
||||
{
|
||||
if (m_inventorySerial > 0)
|
||||
{
|
||||
client.SendTaskInventory(m_uuid, (short) m_inventorySerial,
|
||||
Helpers.StringToField(m_inventoryFileName));
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
client.SendTaskInventory(m_uuid, 0, new byte[0]);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void RequestInventoryFile(IXfer xferManager)
|
||||
{
|
||||
byte[] fileData = new byte[0];
|
||||
InventoryStringBuilder invString = new InventoryStringBuilder(m_folderID, UUID);
|
||||
foreach (TaskInventoryItem item in m_taskInventory.Values)
|
||||
{
|
||||
invString.AddItemStart();
|
||||
invString.AddNameValueLine("item_id", item.item_id.ToString());
|
||||
invString.AddNameValueLine("parent_id", item.parent_id.ToString());
|
||||
|
||||
invString.AddPermissionsStart();
|
||||
invString.AddNameValueLine("base_mask", "0x7FFFFFFF");
|
||||
invString.AddNameValueLine("owner_mask", "0x7FFFFFFF");
|
||||
invString.AddNameValueLine("group_mask", "0x7FFFFFFF");
|
||||
invString.AddNameValueLine("everyone_mask", "0x7FFFFFFF");
|
||||
invString.AddNameValueLine("next_owner_mask", "0x7FFFFFFF");
|
||||
invString.AddNameValueLine("creator_id", item.creator_id.ToString());
|
||||
invString.AddNameValueLine("owner_id", item.owner_id.ToString());
|
||||
invString.AddNameValueLine("last_owner_id", item.last_owner_id.ToString());
|
||||
invString.AddNameValueLine("group_id", item.group_id.ToString());
|
||||
invString.AddSectionEnd();
|
||||
|
||||
invString.AddNameValueLine("asset_id", item.asset_id.ToString());
|
||||
invString.AddNameValueLine("type", item.type);
|
||||
invString.AddNameValueLine("inv_type", item.inv_type);
|
||||
invString.AddNameValueLine("flags", "0x00");
|
||||
invString.AddNameValueLine("name", item.name + "|");
|
||||
invString.AddNameValueLine("desc", item.desc + "|");
|
||||
invString.AddNameValueLine("creation_date", item.creation_date.ToString());
|
||||
invString.AddSectionEnd();
|
||||
}
|
||||
|
||||
fileData = Helpers.StringToField(invString.BuildString);
|
||||
|
||||
// MainLog.Instance.Verbose(
|
||||
// "PRIMINVENTORY", "RequestInventoryFile fileData: {0}", Helpers.FieldToUTF8String(fileData));
|
||||
|
||||
if (fileData.Length > 2)
|
||||
{
|
||||
xferManager.AddNewFile(m_inventoryFileName, fileData);
|
||||
}
|
||||
}
|
||||
|
||||
public class InventoryStringBuilder
|
||||
{
|
||||
public string BuildString = "";
|
||||
|
||||
public InventoryStringBuilder(LLUUID folderID, LLUUID parentID)
|
||||
{
|
||||
BuildString += "\tinv_object\t0\n\t{\n";
|
||||
AddNameValueLine("obj_id", folderID.ToString());
|
||||
AddNameValueLine("parent_id", parentID.ToString());
|
||||
AddNameValueLine("type", "category");
|
||||
AddNameValueLine("name", "Contents");
|
||||
AddSectionEnd();
|
||||
}
|
||||
|
||||
public void AddItemStart()
|
||||
{
|
||||
BuildString += "\tinv_item\t0\n";
|
||||
BuildString += "\t{\n";
|
||||
}
|
||||
|
||||
public void AddPermissionsStart()
|
||||
{
|
||||
BuildString += "\tpermissions 0\n";
|
||||
BuildString += "\t{\n";
|
||||
}
|
||||
|
||||
public void AddSectionEnd()
|
||||
{
|
||||
BuildString += "\t}\n";
|
||||
}
|
||||
|
||||
public void AddLine(string addLine)
|
||||
{
|
||||
BuildString += addLine;
|
||||
}
|
||||
|
||||
public void AddNameValueLine(string name, string value)
|
||||
{
|
||||
BuildString += "\t\t";
|
||||
BuildString += name + "\t";
|
||||
BuildString += value + "\n";
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 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 OpenSim 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.Xml.Serialization;
|
||||
|
||||
using libsecondlife;
|
||||
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Communications.Cache;
|
||||
using OpenSim.Framework.Console;
|
||||
using OpenSim.Region.Environment.Interfaces;
|
||||
using OpenSim.Region.Environment.Scenes.Scripting;
|
||||
|
||||
namespace OpenSim.Region.Environment.Scenes
|
||||
{
|
||||
public partial class SceneObjectPart : IScriptHost
|
||||
{
|
||||
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
private string m_inventoryFileName = String.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// The inventory folder for this prim
|
||||
/// </summary>
|
||||
private LLUUID m_folderID = LLUUID.Zero;
|
||||
|
||||
/// <summary>
|
||||
/// Exposing this is not particularly good, but it's one of the least evils at the moment to see
|
||||
/// folder id from prim inventory item data, since it's not (yet) actually stored with the prim.
|
||||
/// </summary>
|
||||
public LLUUID FolderID
|
||||
{
|
||||
get { return m_folderID; }
|
||||
set { m_folderID = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serial count for inventory file , used to tell if inventory has changed
|
||||
/// no need for this to be part of Database backup
|
||||
/// </summary>
|
||||
protected uint m_inventorySerial = 0;
|
||||
|
||||
public uint InventorySerial
|
||||
{
|
||||
get { return m_inventorySerial; }
|
||||
set { m_inventorySerial = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Holds in memory prim inventory
|
||||
/// </summary>
|
||||
protected TaskInventoryDictionary m_taskInventory = new TaskInventoryDictionary();
|
||||
|
||||
public TaskInventoryDictionary TaskInventory
|
||||
{
|
||||
get { return m_taskInventory; }
|
||||
set { m_taskInventory = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tracks whether inventory has changed since the last persistent backup
|
||||
/// </summary>
|
||||
private bool HasInventoryChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Reset LLUUIDs for all the items in the prim's inventory. This involves either generating
|
||||
/// new ones or setting existing UUIDs to the correct parent UUIDs
|
||||
/// </summary>
|
||||
/// <param name="linkNum'>Link number for the part</param>
|
||||
public void ResetInventoryIDs()
|
||||
{
|
||||
lock (TaskInventory)
|
||||
{
|
||||
IList<TaskInventoryItem> items = new List<TaskInventoryItem>(TaskInventory.Values);
|
||||
TaskInventory.Clear();
|
||||
|
||||
foreach (TaskInventoryItem item in items)
|
||||
{
|
||||
item.ResetIDs(UUID);
|
||||
TaskInventory.Add(item.ItemID, item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Start all the scripts contained in this prim's inventory
|
||||
/// </summary>
|
||||
public void StartScripts()
|
||||
{
|
||||
lock (m_taskInventory)
|
||||
{
|
||||
foreach (TaskInventoryItem item in m_taskInventory.Values)
|
||||
{
|
||||
// XXX more hardcoding badness. Should be an enum in TaskInventoryItem
|
||||
if (10 == item.Type)
|
||||
{
|
||||
StartScript(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void StopScripts()
|
||||
{
|
||||
lock (m_taskInventory)
|
||||
{
|
||||
foreach (TaskInventoryItem item in m_taskInventory.Values)
|
||||
{
|
||||
if (10 == item.Type)
|
||||
{
|
||||
StopScript(item.ItemID);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Start a script which is in this prim's inventory.
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
/// <returns></returns>
|
||||
public void StartScript(TaskInventoryItem item)
|
||||
{
|
||||
// m_log.InfoFormat(
|
||||
// "[PRIMINVENTORY]: " +
|
||||
// "Starting script {0}, {1} in prim {2}, {3}",
|
||||
// item.Name, item.ItemID, Name, UUID);
|
||||
AddFlag(LLObject.ObjectFlags.Scripted);
|
||||
|
||||
if (!((m_parentGroup.Scene.RegionInfo.EstateSettings.regionFlags & Simulator.RegionFlags.SkipScripts) == Simulator.RegionFlags.SkipScripts))
|
||||
{
|
||||
AssetCache cache = m_parentGroup.Scene.AssetCache;
|
||||
|
||||
cache.GetAsset(item.AssetID, delegate(LLUUID assetID, AssetBase asset)
|
||||
{
|
||||
if (null == asset)
|
||||
{
|
||||
m_log.ErrorFormat(
|
||||
"[PRIMINVENTORY]: " +
|
||||
"Couldn't start script {0}, {1} since asset ID {2} could not be found",
|
||||
item.Name, item.ItemID, item.AssetID);
|
||||
}
|
||||
else
|
||||
{
|
||||
string script = Helpers.FieldToUTF8String(asset.Data);
|
||||
m_parentGroup.Scene.EventManager.TriggerRezScript(LocalID,item.ItemID,script);
|
||||
m_parentGroup.AddActiveScriptCount(1);
|
||||
ScheduleFullUpdate();
|
||||
}
|
||||
}, false);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Start a script which is in this prim's inventory.
|
||||
/// </summary>
|
||||
/// <param name="itemId">
|
||||
/// A <see cref="LLUUID"/>
|
||||
/// </param>
|
||||
public void StartScript(LLUUID itemId)
|
||||
{
|
||||
lock (m_taskInventory)
|
||||
{
|
||||
if (m_taskInventory.ContainsKey(itemId))
|
||||
{
|
||||
StartScript(m_taskInventory[itemId]);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
m_log.ErrorFormat(
|
||||
"[PRIMINVENTORY]: " +
|
||||
"Couldn't start script with ID {0} since it couldn't be found for prim {1}, {2}",
|
||||
itemId, Name, UUID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stop a script which is in this prim's inventory.
|
||||
/// </summary>
|
||||
/// <param name="itemId"></param>
|
||||
public void StopScript(LLUUID itemId)
|
||||
{
|
||||
if (m_taskInventory.ContainsKey(itemId))
|
||||
{
|
||||
m_parentGroup.Scene.EventManager.TriggerRemoveScript(LocalID, itemId);
|
||||
m_parentGroup.AddActiveScriptCount(-1);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_log.ErrorFormat(
|
||||
"[PRIMINVENTORY]: " +
|
||||
"Couldn't stop script with ID {0} since it couldn't be found for prim {1}, {2}",
|
||||
itemId, Name, UUID);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add an item to this prim's inventory.
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
public void AddInventoryItem(TaskInventoryItem item)
|
||||
{
|
||||
item.ParentID = m_folderID;
|
||||
item.CreationDate = 1000;
|
||||
item.ParentPartID = UUID;
|
||||
|
||||
lock (m_taskInventory)
|
||||
{
|
||||
m_taskInventory.Add(item.ItemID, item);
|
||||
TriggerScriptChangedEvent(Changed.INVENTORY);
|
||||
}
|
||||
|
||||
m_inventorySerial++;
|
||||
HasInventoryChanged = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Restore a whole collection of items to the prim's inventory at once.
|
||||
/// We assume that the items already have all their fields correctly filled out.
|
||||
/// The items are not flagged for persistence to the database, since they are being restored
|
||||
/// from persistence rather than being newly added.
|
||||
/// </summary>
|
||||
/// <param name="items"></param>
|
||||
public void RestoreInventoryItems(ICollection<TaskInventoryItem> items)
|
||||
{
|
||||
lock (m_taskInventory)
|
||||
{
|
||||
foreach (TaskInventoryItem item in items)
|
||||
{
|
||||
m_taskInventory.Add(item.ItemID, item);
|
||||
TriggerScriptChangedEvent(Changed.INVENTORY);
|
||||
}
|
||||
}
|
||||
|
||||
m_inventorySerial++;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns an existing inventory item. Returns the original, so any changes will be live.
|
||||
/// </summary>
|
||||
/// <param name="itemID"></param>
|
||||
/// <returns>null if the item does not exist</returns>
|
||||
public TaskInventoryItem GetInventoryItem(LLUUID itemID)
|
||||
{
|
||||
lock (m_taskInventory)
|
||||
{
|
||||
if (m_taskInventory.ContainsKey(itemID))
|
||||
{
|
||||
return m_taskInventory[itemID];
|
||||
}
|
||||
else
|
||||
{
|
||||
m_log.ErrorFormat(
|
||||
"[PRIMINVENTORY]: " +
|
||||
"Tried to retrieve item ID {0} from prim {1}, {2} but the item does not exist in this inventory",
|
||||
itemID, Name, UUID);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update an existing inventory item.
|
||||
/// </summary>
|
||||
/// <param name="item">The updated item. An item with the same id must already exist
|
||||
/// in this prim's inventory.</param>
|
||||
/// <returns>false if the item did not exist, true if the update occurred succesfully</returns>
|
||||
public bool UpdateInventoryItem(TaskInventoryItem item)
|
||||
{
|
||||
lock (m_taskInventory)
|
||||
{
|
||||
if (m_taskInventory.ContainsKey(item.ItemID))
|
||||
{
|
||||
m_taskInventory[item.ItemID] = item;
|
||||
m_inventorySerial++;
|
||||
TriggerScriptChangedEvent(Changed.INVENTORY);
|
||||
|
||||
HasInventoryChanged = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_log.ErrorFormat(
|
||||
"[PRIMINVENTORY]: " +
|
||||
"Tried to retrieve item ID {0} from prim {1}, {2} but the item does not exist in this inventory",
|
||||
item.ItemID, Name, UUID);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void AddScriptLPS(int count)
|
||||
{
|
||||
m_parentGroup.AddScriptLPS(count);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove an item from this prim's inventory
|
||||
/// </summary>
|
||||
/// <param name="itemID"></param>
|
||||
/// <returns>Numeric asset type of the item removed. Returns -1 if the item did not exist
|
||||
/// in this prim's inventory.</returns>
|
||||
public int RemoveInventoryItem(LLUUID itemID)
|
||||
{
|
||||
lock (m_taskInventory)
|
||||
{
|
||||
if (m_taskInventory.ContainsKey(itemID))
|
||||
{
|
||||
int type = m_taskInventory[itemID].InvType;
|
||||
m_taskInventory.Remove(itemID);
|
||||
m_inventorySerial++;
|
||||
TriggerScriptChangedEvent(Changed.INVENTORY);
|
||||
|
||||
HasInventoryChanged = true;
|
||||
|
||||
int scriptcount = 0;
|
||||
lock (m_taskInventory)
|
||||
{
|
||||
foreach (TaskInventoryItem item in m_taskInventory.Values)
|
||||
{
|
||||
if (item.Type == 10)
|
||||
{
|
||||
scriptcount++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if (scriptcount <= 0)
|
||||
{
|
||||
RemFlag(LLObject.ObjectFlags.Scripted);
|
||||
ScheduleFullUpdate();
|
||||
}
|
||||
ScheduleFullUpdate();
|
||||
|
||||
return type;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_log.ErrorFormat(
|
||||
"[PRIMINVENTORY]: " +
|
||||
"Tried to remove item ID {0} from prim {1}, {2} but the item does not exist in this inventory",
|
||||
itemID, Name, UUID);
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="client"></param>
|
||||
/// <param name="localID"></param>
|
||||
public bool GetInventoryFileName(IClientAPI client, uint localID)
|
||||
{
|
||||
if (m_inventorySerial > 0)
|
||||
{
|
||||
client.SendTaskInventory(m_uuid, (short)m_inventorySerial,
|
||||
Helpers.StringToField(m_inventoryFileName));
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
client.SendTaskInventory(m_uuid, 0, new byte[0]);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void RequestInventoryFile(IXfer xferManager)
|
||||
{
|
||||
byte[] fileData = new byte[0];
|
||||
InventoryStringBuilder invString = new InventoryStringBuilder(m_folderID, UUID);
|
||||
|
||||
lock (m_taskInventory)
|
||||
{
|
||||
foreach (TaskInventoryItem item in m_taskInventory.Values)
|
||||
{
|
||||
invString.AddItemStart();
|
||||
invString.AddNameValueLine("item_id", item.ItemID.ToString());
|
||||
invString.AddNameValueLine("parent_id", item.ParentID.ToString());
|
||||
|
||||
invString.AddPermissionsStart();
|
||||
invString.AddNameValueLine("base_mask", "0x7FFFFFFF");
|
||||
invString.AddNameValueLine("owner_mask", "0x7FFFFFFF");
|
||||
invString.AddNameValueLine("group_mask", "0x7FFFFFFF");
|
||||
invString.AddNameValueLine("everyone_mask", "0x7FFFFFFF");
|
||||
invString.AddNameValueLine("next_owner_mask", "0x7FFFFFFF");
|
||||
invString.AddNameValueLine("creator_id", item.CreatorID.ToString());
|
||||
invString.AddNameValueLine("owner_id", item.OwnerID.ToString());
|
||||
invString.AddNameValueLine("last_owner_id", item.LastOwnerID.ToString());
|
||||
invString.AddNameValueLine("group_id", item.GroupID.ToString());
|
||||
invString.AddSectionEnd();
|
||||
|
||||
invString.AddNameValueLine("asset_id", item.AssetID.ToString());
|
||||
invString.AddNameValueLine("type", TaskInventoryItem.Types[item.Type]);
|
||||
invString.AddNameValueLine("inv_type", TaskInventoryItem.InvTypes[item.InvType]);
|
||||
invString.AddNameValueLine("flags", "0x00");
|
||||
invString.AddNameValueLine("name", item.Name + "|");
|
||||
invString.AddNameValueLine("desc", item.Description + "|");
|
||||
invString.AddNameValueLine("creation_date", item.CreationDate.ToString());
|
||||
invString.AddSectionEnd();
|
||||
}
|
||||
}
|
||||
|
||||
fileData = Helpers.StringToField(invString.BuildString);
|
||||
|
||||
// m_log.InfoFormat(
|
||||
// "[PRIMINVENTORY]: RequestInventoryFile fileData: {0}", Helpers.FieldToUTF8String(fileData));
|
||||
|
||||
if (fileData.Length > 2)
|
||||
{
|
||||
xferManager.AddNewFile(m_inventoryFileName, fileData);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Process inventory backup
|
||||
/// </summary>
|
||||
/// <param name="datastore"></param>
|
||||
public void ProcessInventoryBackup(IRegionDataStore datastore)
|
||||
{
|
||||
if (HasInventoryChanged)
|
||||
{
|
||||
lock (TaskInventory)
|
||||
{
|
||||
datastore.StorePrimInventory(UUID, TaskInventory.Values);
|
||||
}
|
||||
|
||||
HasInventoryChanged = false;
|
||||
}
|
||||
}
|
||||
|
||||
public class InventoryStringBuilder
|
||||
{
|
||||
public string BuildString = String.Empty;
|
||||
|
||||
public InventoryStringBuilder(LLUUID folderID, LLUUID parentID)
|
||||
{
|
||||
BuildString += "\tinv_object\t0\n\t{\n";
|
||||
AddNameValueLine("obj_id", folderID.ToString());
|
||||
AddNameValueLine("parent_id", parentID.ToString());
|
||||
AddNameValueLine("type", "category");
|
||||
AddNameValueLine("name", "Contents");
|
||||
AddSectionEnd();
|
||||
}
|
||||
|
||||
public void AddItemStart()
|
||||
{
|
||||
BuildString += "\tinv_item\t0\n";
|
||||
BuildString += "\t{\n";
|
||||
}
|
||||
|
||||
public void AddPermissionsStart()
|
||||
{
|
||||
BuildString += "\tpermissions 0\n";
|
||||
BuildString += "\t{\n";
|
||||
}
|
||||
|
||||
public void AddSectionEnd()
|
||||
{
|
||||
BuildString += "\t}\n";
|
||||
}
|
||||
|
||||
public void AddLine(string addLine)
|
||||
{
|
||||
BuildString += addLine;
|
||||
}
|
||||
|
||||
public void AddNameValueLine(string name, string value)
|
||||
{
|
||||
BuildString += "\t\t";
|
||||
BuildString += name + "\t";
|
||||
BuildString += value + "\n";
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,192 +1,224 @@
|
|||
/*
|
||||
* 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 OpenSim 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.Xml;
|
||||
using Axiom.Math;
|
||||
using libsecondlife;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Region.Physics.Manager;
|
||||
|
||||
namespace OpenSim.Region.Environment.Scenes
|
||||
{
|
||||
public class SceneXmlLoader // can move to a module?
|
||||
{
|
||||
protected InnerScene m_innerScene;
|
||||
protected RegionInfo m_regInfo;
|
||||
protected Scene m_parentScene;
|
||||
|
||||
public SceneXmlLoader(Scene parentScene, InnerScene innerScene, RegionInfo regionInfo)
|
||||
{
|
||||
m_parentScene = parentScene;
|
||||
m_innerScene = innerScene;
|
||||
m_regInfo = regionInfo;
|
||||
}
|
||||
|
||||
public void LoadPrimsFromXml(string fileName, bool newIDS, LLVector3 loadOffset)
|
||||
{
|
||||
XmlDocument doc = new XmlDocument();
|
||||
XmlNode rootNode;
|
||||
int primCount = 0;
|
||||
if (fileName.StartsWith("http:") || File.Exists(fileName))
|
||||
{
|
||||
XmlTextReader reader = new XmlTextReader(fileName);
|
||||
reader.WhitespaceHandling = WhitespaceHandling.None;
|
||||
doc.Load(reader);
|
||||
reader.Close();
|
||||
rootNode = doc.FirstChild;
|
||||
foreach (XmlNode aPrimNode in rootNode.ChildNodes)
|
||||
{
|
||||
SceneObjectGroup obj = new SceneObjectGroup(m_parentScene,
|
||||
m_regInfo.RegionHandle, aPrimNode.OuterXml);
|
||||
if (newIDS)
|
||||
{
|
||||
obj.GenerateNewIDs();
|
||||
}
|
||||
//if we want this to be a import method then we need new uuids for the object to avoid any clashes
|
||||
//obj.RegenerateFullIDs();
|
||||
m_innerScene.AddEntity(obj);
|
||||
|
||||
SceneObjectPart rootPart = obj.GetChildPart(obj.UUID);
|
||||
// Apply loadOffsets for load/import and move combinations
|
||||
rootPart.GroupPosition = rootPart.AbsolutePosition + loadOffset;
|
||||
bool UsePhysics = (((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Physics) > 0) &&
|
||||
m_parentScene.m_physicalPrim);
|
||||
if ((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Phantom) == 0)
|
||||
{
|
||||
rootPart.PhysActor = m_innerScene.PhysicsScene.AddPrimShape(
|
||||
rootPart.Name,
|
||||
rootPart.Shape,
|
||||
new PhysicsVector(rootPart.AbsolutePosition.X + loadOffset.X,
|
||||
rootPart.AbsolutePosition.Y + loadOffset.Y,
|
||||
rootPart.AbsolutePosition.Z + loadOffset.Z),
|
||||
new PhysicsVector(rootPart.Scale.X, rootPart.Scale.Y, rootPart.Scale.Z),
|
||||
new Quaternion(rootPart.RotationOffset.W, rootPart.RotationOffset.X,
|
||||
rootPart.RotationOffset.Y, rootPart.RotationOffset.Z), UsePhysics, rootPart.LocalID);
|
||||
rootPart.DoPhysicsPropertyUpdate(UsePhysics, true);
|
||||
}
|
||||
primCount++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("Could not open file " + fileName + " for reading");
|
||||
}
|
||||
}
|
||||
|
||||
public void SavePrimsToXml(string fileName)
|
||||
{
|
||||
FileStream file = new FileStream(fileName, FileMode.Create);
|
||||
StreamWriter stream = new StreamWriter(file);
|
||||
int primCount = 0;
|
||||
stream.WriteLine("<scene>\n");
|
||||
|
||||
List<EntityBase> EntityList = m_innerScene.GetEntities();
|
||||
|
||||
foreach (EntityBase ent in EntityList)
|
||||
{
|
||||
if (ent is SceneObjectGroup)
|
||||
{
|
||||
stream.WriteLine(((SceneObjectGroup) ent).ToXmlString());
|
||||
primCount++;
|
||||
}
|
||||
}
|
||||
stream.WriteLine("</scene>\n");
|
||||
stream.Close();
|
||||
file.Close();
|
||||
}
|
||||
|
||||
public void LoadPrimsFromXml2(string fileName)
|
||||
{
|
||||
XmlDocument doc = new XmlDocument();
|
||||
XmlNode rootNode;
|
||||
if (fileName.StartsWith("http:") || File.Exists(fileName))
|
||||
{
|
||||
XmlTextReader reader = new XmlTextReader(fileName);
|
||||
reader.WhitespaceHandling = WhitespaceHandling.None;
|
||||
doc.Load(reader);
|
||||
reader.Close();
|
||||
rootNode = doc.FirstChild;
|
||||
foreach (XmlNode aPrimNode in rootNode.ChildNodes)
|
||||
{
|
||||
CreatePrimFromXml(aPrimNode.OuterXml);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("Could not open file " + fileName + " for reading");
|
||||
}
|
||||
}
|
||||
|
||||
public void CreatePrimFromXml(string xmlData)
|
||||
{
|
||||
SceneObjectGroup obj = new SceneObjectGroup(xmlData);
|
||||
m_innerScene.AddEntityFromStorage(obj);
|
||||
|
||||
SceneObjectPart rootPart = obj.GetChildPart(obj.UUID);
|
||||
bool UsePhysics = (((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Physics) > 0) &&
|
||||
m_parentScene.m_physicalPrim);
|
||||
if ((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Phantom) == 0)
|
||||
{
|
||||
rootPart.PhysActor = m_innerScene.PhysicsScene.AddPrimShape(
|
||||
rootPart.Name,
|
||||
rootPart.Shape,
|
||||
new PhysicsVector(rootPart.AbsolutePosition.X, rootPart.AbsolutePosition.Y,
|
||||
rootPart.AbsolutePosition.Z),
|
||||
new PhysicsVector(rootPart.Scale.X, rootPart.Scale.Y, rootPart.Scale.Z),
|
||||
new Quaternion(rootPart.RotationOffset.W, rootPart.RotationOffset.X,
|
||||
rootPart.RotationOffset.Y, rootPart.RotationOffset.Z), UsePhysics, rootPart.LocalID);
|
||||
rootPart.DoPhysicsPropertyUpdate(UsePhysics, true);
|
||||
}
|
||||
}
|
||||
|
||||
public void SavePrimsToXml2(string fileName)
|
||||
{
|
||||
FileStream file = new FileStream(fileName, FileMode.Create);
|
||||
StreamWriter stream = new StreamWriter(file);
|
||||
int primCount = 0;
|
||||
stream.WriteLine("<scene>\n");
|
||||
|
||||
List<EntityBase> EntityList = m_innerScene.GetEntities();
|
||||
|
||||
foreach (EntityBase ent in EntityList)
|
||||
{
|
||||
if (ent is SceneObjectGroup)
|
||||
{
|
||||
stream.WriteLine(((SceneObjectGroup) ent).ToXmlString2());
|
||||
primCount++;
|
||||
}
|
||||
}
|
||||
stream.WriteLine("</scene>\n");
|
||||
stream.Close();
|
||||
file.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 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 OpenSim 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.Xml;
|
||||
using Axiom.Math;
|
||||
using libsecondlife;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Region.Physics.Manager;
|
||||
|
||||
namespace OpenSim.Region.Environment.Scenes
|
||||
{
|
||||
public class SceneXmlLoader // can move to a module?
|
||||
{
|
||||
protected InnerScene m_innerScene;
|
||||
protected RegionInfo m_regInfo;
|
||||
protected Scene m_parentScene;
|
||||
|
||||
public SceneXmlLoader(Scene parentScene, InnerScene innerScene, RegionInfo regionInfo)
|
||||
{
|
||||
m_parentScene = parentScene;
|
||||
m_innerScene = innerScene;
|
||||
m_regInfo = regionInfo;
|
||||
}
|
||||
|
||||
public void LoadPrimsFromXml(string fileName, bool newIDS, LLVector3 loadOffset)
|
||||
{
|
||||
XmlDocument doc = new XmlDocument();
|
||||
XmlNode rootNode;
|
||||
int primCount = 0;
|
||||
if (fileName.StartsWith("http:") || File.Exists(fileName))
|
||||
{
|
||||
XmlTextReader reader = new XmlTextReader(fileName);
|
||||
reader.WhitespaceHandling = WhitespaceHandling.None;
|
||||
doc.Load(reader);
|
||||
reader.Close();
|
||||
rootNode = doc.FirstChild;
|
||||
foreach (XmlNode aPrimNode in rootNode.ChildNodes)
|
||||
{
|
||||
SceneObjectGroup obj = new SceneObjectGroup(m_parentScene,
|
||||
m_regInfo.RegionHandle, aPrimNode.OuterXml);
|
||||
if (newIDS)
|
||||
{
|
||||
obj.ResetIDs();
|
||||
}
|
||||
//if we want this to be a import method then we need new uuids for the object to avoid any clashes
|
||||
//obj.RegenerateFullIDs();
|
||||
m_innerScene.AddEntity(obj);
|
||||
|
||||
SceneObjectPart rootPart = obj.GetChildPart(obj.UUID);
|
||||
// Apply loadOffsets for load/import and move combinations
|
||||
rootPart.GroupPosition = rootPart.AbsolutePosition + loadOffset;
|
||||
bool UsePhysics = (((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Physics) > 0) &&
|
||||
m_parentScene.m_physicalPrim);
|
||||
if ((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Phantom) == 0)
|
||||
{
|
||||
rootPart.PhysActor = m_innerScene.PhysicsScene.AddPrimShape(
|
||||
rootPart.Name,
|
||||
rootPart.Shape,
|
||||
new PhysicsVector(rootPart.AbsolutePosition.X + loadOffset.X,
|
||||
rootPart.AbsolutePosition.Y + loadOffset.Y,
|
||||
rootPart.AbsolutePosition.Z + loadOffset.Z),
|
||||
new PhysicsVector(rootPart.Scale.X, rootPart.Scale.Y, rootPart.Scale.Z),
|
||||
new Quaternion(rootPart.RotationOffset.W, rootPart.RotationOffset.X,
|
||||
rootPart.RotationOffset.Y, rootPart.RotationOffset.Z), UsePhysics, rootPart.LocalID);
|
||||
rootPart.DoPhysicsPropertyUpdate(UsePhysics, true);
|
||||
}
|
||||
primCount++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("Could not open file " + fileName + " for reading");
|
||||
}
|
||||
}
|
||||
|
||||
public void SavePrimsToXml(string fileName)
|
||||
{
|
||||
FileStream file = new FileStream(fileName, FileMode.Create);
|
||||
StreamWriter stream = new StreamWriter(file);
|
||||
int primCount = 0;
|
||||
stream.WriteLine("<scene>\n");
|
||||
|
||||
List<EntityBase> EntityList = m_innerScene.GetEntities();
|
||||
|
||||
foreach (EntityBase ent in EntityList)
|
||||
{
|
||||
if (ent is SceneObjectGroup)
|
||||
{
|
||||
stream.WriteLine(((SceneObjectGroup) ent).ToXmlString());
|
||||
primCount++;
|
||||
}
|
||||
}
|
||||
stream.WriteLine("</scene>\n");
|
||||
stream.Close();
|
||||
file.Close();
|
||||
}
|
||||
|
||||
public string SavePrimGroupToXML2String(SceneObjectGroup grp)
|
||||
{
|
||||
string returnstring = "";
|
||||
returnstring += "<scene>\n";
|
||||
returnstring += grp.ToXmlString2();
|
||||
returnstring += "</scene>\n";
|
||||
return returnstring;
|
||||
|
||||
}
|
||||
|
||||
public void LoadGroupFromXml2String(string xmlString)
|
||||
{
|
||||
XmlDocument doc = new XmlDocument();
|
||||
XmlNode rootNode;
|
||||
|
||||
XmlTextReader reader = new XmlTextReader(new StringReader(xmlString));
|
||||
reader.WhitespaceHandling = WhitespaceHandling.None;
|
||||
doc.Load(reader);
|
||||
reader.Close();
|
||||
rootNode = doc.FirstChild;
|
||||
foreach (XmlNode aPrimNode in rootNode.ChildNodes)
|
||||
{
|
||||
CreatePrimFromXml(aPrimNode.OuterXml);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void LoadPrimsFromXml2(string fileName)
|
||||
{
|
||||
XmlDocument doc = new XmlDocument();
|
||||
XmlNode rootNode;
|
||||
if (fileName.StartsWith("http:") || File.Exists(fileName))
|
||||
{
|
||||
XmlTextReader reader = new XmlTextReader(fileName);
|
||||
reader.WhitespaceHandling = WhitespaceHandling.None;
|
||||
doc.Load(reader);
|
||||
reader.Close();
|
||||
rootNode = doc.FirstChild;
|
||||
foreach (XmlNode aPrimNode in rootNode.ChildNodes)
|
||||
{
|
||||
CreatePrimFromXml(aPrimNode.OuterXml);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("Could not open file " + fileName + " for reading");
|
||||
}
|
||||
}
|
||||
|
||||
public void CreatePrimFromXml(string xmlData)
|
||||
{
|
||||
SceneObjectGroup obj = new SceneObjectGroup(xmlData);
|
||||
LLVector3 receivedVelocity = obj.RootPart.Velocity;
|
||||
//System.Console.WriteLine(obj.RootPart.Velocity.ToString());
|
||||
m_innerScene.AddEntityFromStorage(obj);
|
||||
|
||||
SceneObjectPart rootPart = obj.GetChildPart(obj.UUID);
|
||||
bool UsePhysics = (((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Physics) > 0) &&
|
||||
m_parentScene.m_physicalPrim);
|
||||
if ((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Phantom) == 0)
|
||||
{
|
||||
rootPart.PhysActor = m_innerScene.PhysicsScene.AddPrimShape(
|
||||
rootPart.Name,
|
||||
rootPart.Shape,
|
||||
new PhysicsVector(rootPart.AbsolutePosition.X, rootPart.AbsolutePosition.Y,
|
||||
rootPart.AbsolutePosition.Z),
|
||||
new PhysicsVector(rootPart.Scale.X, rootPart.Scale.Y, rootPart.Scale.Z),
|
||||
new Quaternion(rootPart.RotationOffset.W, rootPart.RotationOffset.X,
|
||||
rootPart.RotationOffset.Y, rootPart.RotationOffset.Z), UsePhysics, rootPart.LocalID);
|
||||
rootPart.DoPhysicsPropertyUpdate(UsePhysics, true);
|
||||
rootPart.Velocity = receivedVelocity;
|
||||
}
|
||||
|
||||
obj.ScheduleGroupForFullUpdate();
|
||||
}
|
||||
|
||||
public void SavePrimsToXml2(string fileName)
|
||||
{
|
||||
FileStream file = new FileStream(fileName, FileMode.Create);
|
||||
StreamWriter stream = new StreamWriter(file);
|
||||
int primCount = 0;
|
||||
stream.WriteLine("<scene>\n");
|
||||
|
||||
List<EntityBase> EntityList = m_innerScene.GetEntities();
|
||||
|
||||
foreach (EntityBase ent in EntityList)
|
||||
{
|
||||
if (ent is SceneObjectGroup)
|
||||
{
|
||||
stream.WriteLine(((SceneObjectGroup) ent).ToXmlString2());
|
||||
primCount++;
|
||||
}
|
||||
}
|
||||
stream.WriteLine("</scene>\n");
|
||||
stream.Close();
|
||||
file.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,46 +1,46 @@
|
|||
/*
|
||||
* 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 OpenSim 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 Axiom.Math;
|
||||
using libsecondlife;
|
||||
|
||||
namespace OpenSim.Region.Environment.Scenes.Scripting
|
||||
{
|
||||
public interface IScriptHost
|
||||
{
|
||||
string Name { get; set; }
|
||||
string SitName { get; set; }
|
||||
string TouchName { get; set; }
|
||||
string Description { get; set; }
|
||||
LLUUID UUID { get; }
|
||||
LLUUID ObjectOwner { get; }
|
||||
LLUUID ObjectCreator { get; }
|
||||
LLVector3 AbsolutePosition { get; }
|
||||
void SetText(string text, Vector3 color, double alpha);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 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 OpenSim 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 Axiom.Math;
|
||||
using libsecondlife;
|
||||
|
||||
namespace OpenSim.Region.Environment.Scenes.Scripting
|
||||
{
|
||||
public interface IScriptHost
|
||||
{
|
||||
string Name { get; set; }
|
||||
string SitName { get; set; }
|
||||
string TouchName { get; set; }
|
||||
string Description { get; set; }
|
||||
LLUUID UUID { get; }
|
||||
LLUUID ObjectOwner { get; }
|
||||
LLUUID ObjectCreator { get; }
|
||||
LLVector3 AbsolutePosition { get; }
|
||||
void SetText(string text, Vector3 color, double alpha);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,88 +1,88 @@
|
|||
/*
|
||||
* 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 OpenSim 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 Axiom.Math;
|
||||
using libsecondlife;
|
||||
|
||||
namespace OpenSim.Region.Environment.Scenes.Scripting
|
||||
{
|
||||
public class NullScriptHost : IScriptHost
|
||||
{
|
||||
private LLVector3 m_pos = new LLVector3(128, 128, 30);
|
||||
|
||||
public string Name
|
||||
{
|
||||
get { return "Object"; }
|
||||
set { }
|
||||
}
|
||||
|
||||
public string SitName
|
||||
{
|
||||
get { return ""; }
|
||||
set { }
|
||||
}
|
||||
|
||||
public string TouchName
|
||||
{
|
||||
get { return ""; }
|
||||
set { }
|
||||
}
|
||||
|
||||
public string Description
|
||||
{
|
||||
get { return ""; }
|
||||
set { }
|
||||
}
|
||||
|
||||
public LLUUID UUID
|
||||
{
|
||||
get { return LLUUID.Zero; }
|
||||
}
|
||||
|
||||
public LLUUID ObjectOwner
|
||||
{
|
||||
get { return LLUUID.Zero; }
|
||||
}
|
||||
|
||||
public LLUUID ObjectCreator
|
||||
{
|
||||
get { return LLUUID.Zero; }
|
||||
}
|
||||
|
||||
public LLVector3 AbsolutePosition
|
||||
{
|
||||
get { return m_pos; }
|
||||
}
|
||||
|
||||
public void SetText(string text, Vector3 color, double alpha)
|
||||
{
|
||||
Console.WriteLine("Tried to SetText [{0}] on NullScriptHost", text);
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 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 OpenSim 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 Axiom.Math;
|
||||
using libsecondlife;
|
||||
|
||||
namespace OpenSim.Region.Environment.Scenes.Scripting
|
||||
{
|
||||
public class NullScriptHost : IScriptHost
|
||||
{
|
||||
private LLVector3 m_pos = new LLVector3(128, 128, 30);
|
||||
|
||||
public string Name
|
||||
{
|
||||
get { return "Object"; }
|
||||
set { }
|
||||
}
|
||||
|
||||
public string SitName
|
||||
{
|
||||
get { return String.Empty; }
|
||||
set { }
|
||||
}
|
||||
|
||||
public string TouchName
|
||||
{
|
||||
get { return String.Empty; }
|
||||
set { }
|
||||
}
|
||||
|
||||
public string Description
|
||||
{
|
||||
get { return String.Empty; }
|
||||
set { }
|
||||
}
|
||||
|
||||
public LLUUID UUID
|
||||
{
|
||||
get { return LLUUID.Zero; }
|
||||
}
|
||||
|
||||
public LLUUID ObjectOwner
|
||||
{
|
||||
get { return LLUUID.Zero; }
|
||||
}
|
||||
|
||||
public LLUUID ObjectCreator
|
||||
{
|
||||
get { return LLUUID.Zero; }
|
||||
}
|
||||
|
||||
public LLVector3 AbsolutePosition
|
||||
{
|
||||
get { return m_pos; }
|
||||
}
|
||||
|
||||
public void SetText(string text, Vector3 color, double alpha)
|
||||
{
|
||||
Console.WriteLine("Tried to SetText [{0}] on NullScriptHost", text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,40 +1,40 @@
|
|||
/*
|
||||
* 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 OpenSim 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 OpenSim.Framework.Console;
|
||||
|
||||
//TODO: WHERE TO PLACE THIS?
|
||||
|
||||
namespace OpenSim.Region.Environment.Scenes.Scripting
|
||||
{
|
||||
public interface ScriptEngineInterface
|
||||
{
|
||||
void InitializeEngine(Scene Sceneworld, LogBase logger);
|
||||
void Shutdown();
|
||||
// void StartScript(string ScriptID, IScriptHost ObjectID);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 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 OpenSim 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 OpenSim.Framework.Console;
|
||||
|
||||
//TODO: WHERE TO PLACE THIS?
|
||||
|
||||
namespace OpenSim.Region.Environment.Scenes.Scripting
|
||||
{
|
||||
public interface ScriptEngineInterface
|
||||
{
|
||||
void InitializeEngine(Scene Sceneworld);
|
||||
void Shutdown();
|
||||
// void StartScript(string ScriptID, IScriptHost ObjectID);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,124 +1,119 @@
|
|||
/*
|
||||
* 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 OpenSim 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.
|
||||
*
|
||||
*/
|
||||
/* Original code: Tedd Hansen */
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using OpenSim.Framework.Console;
|
||||
|
||||
namespace OpenSim.Region.Environment.Scenes.Scripting
|
||||
{
|
||||
public class ScriptEngineLoader
|
||||
{
|
||||
private LogBase m_log;
|
||||
|
||||
public ScriptEngineLoader(LogBase logger)
|
||||
{
|
||||
m_log = logger;
|
||||
}
|
||||
|
||||
public ScriptEngineInterface LoadScriptEngine(string EngineName)
|
||||
{
|
||||
ScriptEngineInterface ret = null;
|
||||
try
|
||||
{
|
||||
ret =
|
||||
LoadAndInitAssembly(
|
||||
Path.Combine("ScriptEngines", "OpenSim.Region.ScriptEngine." + EngineName + ".dll"),
|
||||
"OpenSim.Region.ScriptEngine." + EngineName + ".ScriptEngine");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.Error("ScriptEngine",
|
||||
"Error loading assembly \"" + EngineName + "\": " + e.Message + ", " +
|
||||
e.StackTrace.ToString());
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Does actual loading and initialization of script Assembly
|
||||
/// </summary>
|
||||
/// <param name="FreeAppDomain">AppDomain to load script into</param>
|
||||
/// <param name="FileName">FileName of script assembly (.dll)</param>
|
||||
/// <returns></returns>
|
||||
private ScriptEngineInterface LoadAndInitAssembly(string FileName, string NameSpace)
|
||||
{
|
||||
//Common.SendToDebug("Loading ScriptEngine Assembly " + FileName);
|
||||
// Load .Net Assembly (.dll)
|
||||
// Initialize and return it
|
||||
|
||||
// TODO: Add error handling
|
||||
|
||||
Assembly a;
|
||||
//try
|
||||
//{
|
||||
|
||||
|
||||
// Load to default appdomain (temporary)
|
||||
a = Assembly.LoadFrom(FileName);
|
||||
// Load to specified appdomain
|
||||
// TODO: Insert security
|
||||
//a = FreeAppDomain.Load(FileName);
|
||||
//}
|
||||
//catch (Exception e)
|
||||
//{
|
||||
// m_log.Error("ScriptEngine", "Error loading assembly \"" + FileName + "\": " + e.ToString());
|
||||
//}
|
||||
|
||||
|
||||
//Console.WriteLine("Loading: " + FileName);
|
||||
//foreach (Type _t in a.GetTypes())
|
||||
//{
|
||||
// Console.WriteLine("Type: " + _t.ToString());
|
||||
//}
|
||||
|
||||
Type t;
|
||||
//try
|
||||
//{
|
||||
t = a.GetType(NameSpace, true);
|
||||
//}
|
||||
//catch (Exception e)
|
||||
//{
|
||||
// m_log.Error("ScriptEngine", "Error initializing type \"" + NameSpace + "\" from \"" + FileName + "\": " + e.ToString());
|
||||
//}
|
||||
|
||||
ScriptEngineInterface ret;
|
||||
//try
|
||||
//{
|
||||
ret = (ScriptEngineInterface) Activator.CreateInstance(t);
|
||||
//}
|
||||
//catch (Exception e)
|
||||
//{
|
||||
// m_log.Error("ScriptEngine", "Error initializing type \"" + NameSpace + "\" from \"" + FileName + "\": " + e.ToString());
|
||||
//}
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 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 OpenSim 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.
|
||||
*
|
||||
*/
|
||||
/* Original code: Tedd Hansen */
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using OpenSim.Framework.Console;
|
||||
|
||||
namespace OpenSim.Region.Environment.Scenes.Scripting
|
||||
{
|
||||
public class ScriptEngineLoader
|
||||
{
|
||||
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
public ScriptEngineInterface LoadScriptEngine(string EngineName)
|
||||
{
|
||||
ScriptEngineInterface ret = null;
|
||||
try
|
||||
{
|
||||
ret =
|
||||
LoadAndInitAssembly(
|
||||
Path.Combine("ScriptEngines", "OpenSim.Region.ScriptEngine." + EngineName + ".dll"),
|
||||
"OpenSim.Region.ScriptEngine." + EngineName + ".ScriptEngine");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.Error("[ScriptEngine]: " +
|
||||
"Error loading assembly \"" + EngineName + "\": " + e.Message + ", " +
|
||||
e.StackTrace.ToString());
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Does actual loading and initialization of script Assembly
|
||||
/// </summary>
|
||||
/// <param name="FreeAppDomain">AppDomain to load script into</param>
|
||||
/// <param name="FileName">FileName of script assembly (.dll)</param>
|
||||
/// <returns></returns>
|
||||
private ScriptEngineInterface LoadAndInitAssembly(string FileName, string NameSpace)
|
||||
{
|
||||
//Common.SendToDebug("Loading ScriptEngine Assembly " + FileName);
|
||||
// Load .Net Assembly (.dll)
|
||||
// Initialize and return it
|
||||
|
||||
// TODO: Add error handling
|
||||
|
||||
Assembly a;
|
||||
//try
|
||||
//{
|
||||
|
||||
|
||||
// Load to default appdomain (temporary)
|
||||
a = Assembly.LoadFrom(FileName);
|
||||
// Load to specified appdomain
|
||||
// TODO: Insert security
|
||||
//a = FreeAppDomain.Load(FileName);
|
||||
//}
|
||||
//catch (Exception e)
|
||||
//{
|
||||
// m_log.Error("[ScriptEngine]: Error loading assembly \String.Empty + FileName + "\": " + e.ToString());
|
||||
//}
|
||||
|
||||
|
||||
//Console.WriteLine("Loading: " + FileName);
|
||||
//foreach (Type _t in a.GetTypes())
|
||||
//{
|
||||
// Console.WriteLine("Type: " + _t.ToString());
|
||||
//}
|
||||
|
||||
Type t;
|
||||
//try
|
||||
//{
|
||||
t = a.GetType(NameSpace, true);
|
||||
//}
|
||||
//catch (Exception e)
|
||||
//{
|
||||
// m_log.Error("[ScriptEngine]: Error initializing type \String.Empty + NameSpace + "\" from \String.Empty + FileName + "\": " + e.ToString());
|
||||
//}
|
||||
|
||||
ScriptEngineInterface ret;
|
||||
//try
|
||||
//{
|
||||
ret = (ScriptEngineInterface) Activator.CreateInstance(t);
|
||||
//}
|
||||
//catch (Exception e)
|
||||
//{
|
||||
// m_log.Error("[ScriptEngine]: Error initializing type \String.Empty + NameSpace + "\" from \String.Empty + FileName + "\": " + e.ToString());
|
||||
//}
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,246 +1,392 @@
|
|||
/*
|
||||
* 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 OpenSim 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.Timers;
|
||||
using libsecondlife.Packets;
|
||||
using OpenSim.Framework;
|
||||
|
||||
namespace OpenSim.Region.Environment.Scenes
|
||||
{
|
||||
public class SimStatsReporter
|
||||
{
|
||||
public delegate void SendStatResult(SimStatsPacket pack);
|
||||
|
||||
public event SendStatResult OnSendStatsResult;
|
||||
|
||||
private enum Stats : uint
|
||||
{
|
||||
TimeDilation = 0,
|
||||
SimFPS = 1,
|
||||
PhysicsFPS = 2,
|
||||
AgentUpdates = 3,
|
||||
TotalPrim = 11,
|
||||
ActivePrim = 12,
|
||||
Agents = 13,
|
||||
ChildAgents = 14,
|
||||
InPacketsPerSecond = 17,
|
||||
OutPacketsPerSecond = 18,
|
||||
UnAckedBytes = 24
|
||||
}
|
||||
|
||||
private int statsUpdatesEveryMS = 1000;
|
||||
private float m_timeDilation = 0;
|
||||
private int m_fps = 0;
|
||||
private float m_pfps = 0;
|
||||
private float m_agentUpdates = 0;
|
||||
private int m_rootAgents = 0;
|
||||
private int m_childAgents = 0;
|
||||
private int m_numPrim = 0;
|
||||
private int m_inPacketsPerSecond = 0;
|
||||
private int m_outPacketsPerSecond = 0;
|
||||
private int m_activePrim = 0;
|
||||
private int m_unAckedBytes = 0;
|
||||
private RegionInfo ReportingRegion;
|
||||
|
||||
private Timer m_report = new Timer();
|
||||
|
||||
|
||||
public SimStatsReporter(RegionInfo regionData)
|
||||
{
|
||||
ReportingRegion = regionData;
|
||||
m_report.AutoReset = true;
|
||||
m_report.Interval = statsUpdatesEveryMS;
|
||||
m_report.Elapsed += new ElapsedEventHandler(statsHeartBeat);
|
||||
m_report.Enabled = true;
|
||||
}
|
||||
|
||||
private void statsHeartBeat(object sender, EventArgs e)
|
||||
{
|
||||
m_report.Enabled = false;
|
||||
SimStatsPacket statpack = (SimStatsPacket) PacketPool.Instance.GetPacket(PacketType.SimStats);
|
||||
// TODO: don't create new blocks if recycling an old packet
|
||||
|
||||
SimStatsPacket.StatBlock[] sb = new SimStatsPacket.StatBlock[11];
|
||||
statpack.Region = new SimStatsPacket.RegionBlock();
|
||||
statpack.Region.RegionX = ReportingRegion.RegionLocX;
|
||||
statpack.Region.RegionY = ReportingRegion.RegionLocY;
|
||||
try
|
||||
{
|
||||
statpack.Region.RegionFlags = (uint) ReportingRegion.EstateSettings.regionFlags;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
statpack.Region.RegionFlags = (uint) 0;
|
||||
}
|
||||
statpack.Region.ObjectCapacity = (uint) 15000;
|
||||
|
||||
#region various statistic googly moogly
|
||||
|
||||
float simfps = (int) (m_fps*5);
|
||||
|
||||
if (simfps > 45)
|
||||
simfps = simfps - (simfps - 45);
|
||||
if (simfps < 0)
|
||||
simfps = 0;
|
||||
|
||||
float physfps = (m_pfps/statsUpdatesEveryMS);
|
||||
|
||||
if (physfps > 50)
|
||||
physfps = physfps - (physfps - 50);
|
||||
|
||||
if (physfps < 0)
|
||||
physfps = 0;
|
||||
|
||||
#endregion
|
||||
|
||||
sb[0] = new SimStatsPacket.StatBlock();
|
||||
sb[0].StatID = (uint) Stats.TimeDilation;
|
||||
sb[0].StatValue = (m_timeDilation);
|
||||
|
||||
sb[1] = new SimStatsPacket.StatBlock();
|
||||
sb[1].StatID = (uint) Stats.SimFPS;
|
||||
sb[1].StatValue = simfps;
|
||||
|
||||
sb[2] = new SimStatsPacket.StatBlock();
|
||||
sb[2].StatID = (uint) Stats.PhysicsFPS;
|
||||
sb[2].StatValue = physfps;
|
||||
|
||||
sb[3] = new SimStatsPacket.StatBlock();
|
||||
sb[3].StatID = (uint) Stats.AgentUpdates;
|
||||
sb[3].StatValue = (m_agentUpdates/statsUpdatesEveryMS);
|
||||
|
||||
sb[4] = new SimStatsPacket.StatBlock();
|
||||
sb[4].StatID = (uint) Stats.Agents;
|
||||
sb[4].StatValue = m_rootAgents;
|
||||
|
||||
sb[5] = new SimStatsPacket.StatBlock();
|
||||
sb[5].StatID = (uint) Stats.ChildAgents;
|
||||
sb[5].StatValue = m_childAgents;
|
||||
|
||||
sb[6] = new SimStatsPacket.StatBlock();
|
||||
sb[6].StatID = (uint) Stats.TotalPrim;
|
||||
sb[6].StatValue = m_numPrim;
|
||||
|
||||
sb[7] = new SimStatsPacket.StatBlock();
|
||||
sb[7].StatID = (uint) Stats.ActivePrim;
|
||||
sb[7].StatValue = m_activePrim;
|
||||
|
||||
sb[8] = new SimStatsPacket.StatBlock();
|
||||
sb[8].StatID = (uint) Stats.InPacketsPerSecond;
|
||||
sb[8].StatValue = (int) (m_inPacketsPerSecond/statsUpdatesEveryMS);
|
||||
|
||||
sb[9] = new SimStatsPacket.StatBlock();
|
||||
sb[9].StatID = (uint) Stats.OutPacketsPerSecond;
|
||||
sb[9].StatValue = (int) (m_outPacketsPerSecond/statsUpdatesEveryMS);
|
||||
|
||||
sb[10] = new SimStatsPacket.StatBlock();
|
||||
sb[10].StatID = (uint) Stats.UnAckedBytes;
|
||||
sb[10].StatValue = (int) (m_unAckedBytes/statsUpdatesEveryMS);
|
||||
|
||||
statpack.Stat = sb;
|
||||
|
||||
if (OnSendStatsResult != null)
|
||||
{
|
||||
OnSendStatsResult(statpack);
|
||||
}
|
||||
resetvalues();
|
||||
m_report.Enabled = true;
|
||||
}
|
||||
|
||||
private void resetvalues()
|
||||
{
|
||||
m_fps = 0;
|
||||
m_pfps = 0;
|
||||
m_agentUpdates = 0;
|
||||
m_inPacketsPerSecond = 0;
|
||||
m_outPacketsPerSecond = 0;
|
||||
m_unAckedBytes = 0;
|
||||
}
|
||||
|
||||
public void SetTimeDilation(float td)
|
||||
{
|
||||
m_timeDilation = td;
|
||||
if (m_timeDilation > 1.0f)
|
||||
m_timeDilation = (m_timeDilation - (m_timeDilation - 0.91f));
|
||||
|
||||
if (m_timeDilation < 0)
|
||||
m_timeDilation = 0.0f;
|
||||
}
|
||||
|
||||
public void SetRootAgents(int rootAgents)
|
||||
{
|
||||
m_rootAgents = rootAgents;
|
||||
}
|
||||
|
||||
public void SetChildAgents(int childAgents)
|
||||
{
|
||||
m_childAgents = childAgents;
|
||||
}
|
||||
|
||||
public void SetObjects(int objects)
|
||||
{
|
||||
m_numPrim = objects;
|
||||
}
|
||||
|
||||
public void SetActiveObjects(int objects)
|
||||
{
|
||||
m_activePrim = objects;
|
||||
}
|
||||
|
||||
public void AddFPS(int frames)
|
||||
{
|
||||
m_fps += frames;
|
||||
}
|
||||
|
||||
public void AddPhysicsFPS(float frames)
|
||||
{
|
||||
m_pfps += frames;
|
||||
}
|
||||
|
||||
public void AddAgentUpdates(float numUpdates)
|
||||
{
|
||||
m_agentUpdates += numUpdates;
|
||||
}
|
||||
|
||||
public void AddInPackets(int numPackets)
|
||||
{
|
||||
m_inPacketsPerSecond += numPackets;
|
||||
}
|
||||
|
||||
public void AddOutPackets(int numPackets)
|
||||
{
|
||||
m_outPacketsPerSecond += numPackets;
|
||||
}
|
||||
|
||||
public void AddunAckedBytes(int numBytes)
|
||||
{
|
||||
m_unAckedBytes += numBytes;
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 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 OpenSim 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.Timers;
|
||||
using libsecondlife.Packets;
|
||||
using OpenSim.Framework;
|
||||
|
||||
namespace OpenSim.Region.Environment.Scenes
|
||||
{
|
||||
public class SimStatsReporter
|
||||
{
|
||||
public delegate void SendStatResult(SimStatsPacket pack);
|
||||
|
||||
public event SendStatResult OnSendStatsResult;
|
||||
|
||||
private SendStatResult handler001 = null;
|
||||
|
||||
private enum Stats : uint
|
||||
{
|
||||
TimeDilation = 0,
|
||||
SimFPS = 1,
|
||||
PhysicsFPS = 2,
|
||||
AgentUpdates = 3,
|
||||
FrameMS = 4,
|
||||
NetMS = 5,
|
||||
OtherMS = 6,
|
||||
PhysicsMS = 7,
|
||||
AgentMS = 8,
|
||||
ImageMS = 9,
|
||||
ScriptMS = 10,
|
||||
TotalPrim = 11,
|
||||
ActivePrim = 12,
|
||||
Agents = 13,
|
||||
ChildAgents = 14,
|
||||
ActiveScripts = 15,
|
||||
ScriptLinesPerSecond = 16,
|
||||
InPacketsPerSecond = 17,
|
||||
OutPacketsPerSecond = 18,
|
||||
PendingDownloads = 19,
|
||||
PendingUploads = 20,
|
||||
UnAckedBytes = 24,
|
||||
|
||||
// Havok4 related... May or may not be in upcoming LLclients
|
||||
// (kelly added them sometime late in January 2008)
|
||||
NumRCCSLODReduced = 25,
|
||||
NumRCCSFixed = 26
|
||||
}
|
||||
|
||||
// Sending a stats update every 3 seconds
|
||||
private int statsUpdatesEveryMS = 3000;
|
||||
private float statsUpdateFactor = 0;
|
||||
private float m_timeDilation = 0;
|
||||
private int m_fps = 0;
|
||||
private float m_pfps = 0;
|
||||
private int m_agentUpdates = 0;
|
||||
|
||||
private int m_frameMS = 0;
|
||||
private int m_netMS = 0;
|
||||
private int m_agentMS = 0;
|
||||
private int m_physicsMS = 0;
|
||||
private int m_imageMS = 0;
|
||||
private int m_otherMS = 0;
|
||||
private int m_scriptMS = 0;
|
||||
|
||||
private int m_rootAgents = 0;
|
||||
private int m_childAgents = 0;
|
||||
private int m_numPrim = 0;
|
||||
private int m_inPacketsPerSecond = 0;
|
||||
private int m_outPacketsPerSecond = 0;
|
||||
private int m_activePrim = 0;
|
||||
private int m_unAckedBytes = 0;
|
||||
private int m_pendingDownloads = 0;
|
||||
private int m_pendingUploads = 0;
|
||||
private int m_activeScripts = 0;
|
||||
private int m_scriptLinesPerSecond = 0;
|
||||
|
||||
|
||||
SimStatsPacket.StatBlock[] sb = new SimStatsPacket.StatBlock[21];
|
||||
SimStatsPacket.RegionBlock rb = new SimStatsPacket.RegionBlock();
|
||||
SimStatsPacket statpack = (SimStatsPacket)PacketPool.Instance.GetPacket(PacketType.SimStats);
|
||||
|
||||
|
||||
private RegionInfo ReportingRegion;
|
||||
|
||||
private Timer m_report = new Timer();
|
||||
|
||||
|
||||
public SimStatsReporter(RegionInfo regionData)
|
||||
{
|
||||
|
||||
statsUpdateFactor = (float)(statsUpdatesEveryMS / 1000);
|
||||
ReportingRegion = regionData;
|
||||
for (int i = 0; i<21;i++)
|
||||
{
|
||||
sb[i] = new SimStatsPacket.StatBlock();
|
||||
}
|
||||
m_report.AutoReset = true;
|
||||
m_report.Interval = statsUpdatesEveryMS;
|
||||
m_report.Elapsed += new ElapsedEventHandler(statsHeartBeat);
|
||||
m_report.Enabled = true;
|
||||
}
|
||||
|
||||
public void SetUpdateMS(int ms)
|
||||
{
|
||||
statsUpdatesEveryMS = ms;
|
||||
statsUpdateFactor = (float)(statsUpdatesEveryMS / 1000);
|
||||
m_report.Interval = statsUpdatesEveryMS;
|
||||
}
|
||||
|
||||
private void statsHeartBeat(object sender, EventArgs e)
|
||||
{
|
||||
m_report.Enabled = false;
|
||||
|
||||
// Packet is already initialized and ready for data insert
|
||||
|
||||
|
||||
statpack.Region = rb;
|
||||
statpack.Region.RegionX = ReportingRegion.RegionLocX;
|
||||
statpack.Region.RegionY = ReportingRegion.RegionLocY;
|
||||
try
|
||||
{
|
||||
statpack.Region.RegionFlags = (uint) ReportingRegion.EstateSettings.regionFlags;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
statpack.Region.RegionFlags = (uint) 0;
|
||||
}
|
||||
statpack.Region.ObjectCapacity = (uint) 15000;
|
||||
|
||||
#region various statistic googly moogly
|
||||
|
||||
// Our FPS is actually 10fps, so multiplying by 5 to get the amount that people expect there
|
||||
// 0-50 is pretty close to 0-45
|
||||
float simfps = (int) ((m_fps * 5));
|
||||
|
||||
//if (simfps > 45)
|
||||
//simfps = simfps - (simfps - 45);
|
||||
//if (simfps < 0)
|
||||
//simfps = 0;
|
||||
|
||||
//
|
||||
float physfps = ((m_pfps / 1000));
|
||||
|
||||
//if (physfps > 600)
|
||||
//physfps = physfps - (physfps - 600);
|
||||
|
||||
if (physfps < 0)
|
||||
physfps = 0;
|
||||
|
||||
#endregion
|
||||
|
||||
//Our time dilation is 0.91 when we're running a full speed,
|
||||
// therefore to make sure we get an appropriate range,
|
||||
// we have to factor in our error. (0.10f * statsUpdateFactor)
|
||||
// multiplies the fix for the error times the amount of times it'll occur a second
|
||||
// / 10 divides the value by the number of times the sim heartbeat runs (10fps)
|
||||
// Then we divide the whole amount by the amount of seconds pass in between stats updates.
|
||||
|
||||
sb[0].StatID = (uint) Stats.TimeDilation;
|
||||
sb[0].StatValue = m_timeDilation ; //((((m_timeDilation + (0.10f * statsUpdateFactor)) /10) / statsUpdateFactor));
|
||||
|
||||
sb[1].StatID = (uint) Stats.SimFPS;
|
||||
sb[1].StatValue = simfps/statsUpdateFactor;
|
||||
|
||||
sb[2].StatID = (uint) Stats.PhysicsFPS;
|
||||
sb[2].StatValue = physfps / statsUpdateFactor;
|
||||
|
||||
sb[3].StatID = (uint) Stats.AgentUpdates;
|
||||
sb[3].StatValue = (m_agentUpdates / statsUpdateFactor);
|
||||
|
||||
sb[4].StatID = (uint) Stats.Agents;
|
||||
sb[4].StatValue = m_rootAgents;
|
||||
|
||||
sb[5].StatID = (uint) Stats.ChildAgents;
|
||||
sb[5].StatValue = m_childAgents;
|
||||
|
||||
sb[6].StatID = (uint) Stats.TotalPrim;
|
||||
sb[6].StatValue = m_numPrim;
|
||||
|
||||
sb[7].StatID = (uint) Stats.ActivePrim;
|
||||
sb[7].StatValue = m_activePrim;
|
||||
|
||||
sb[8].StatID = (uint)Stats.FrameMS;
|
||||
sb[8].StatValue = m_frameMS / statsUpdateFactor;
|
||||
|
||||
sb[9].StatID = (uint)Stats.NetMS;
|
||||
sb[9].StatValue = m_netMS / statsUpdateFactor;
|
||||
|
||||
sb[10].StatID = (uint)Stats.PhysicsMS;
|
||||
sb[10].StatValue = m_physicsMS / statsUpdateFactor;
|
||||
|
||||
sb[11].StatID = (uint)Stats.ImageMS ;
|
||||
sb[11].StatValue = m_imageMS / statsUpdateFactor;
|
||||
|
||||
sb[12].StatID = (uint)Stats.OtherMS;
|
||||
sb[12].StatValue = m_otherMS / statsUpdateFactor;
|
||||
|
||||
sb[13].StatID = (uint)Stats.InPacketsPerSecond;
|
||||
sb[13].StatValue = (m_inPacketsPerSecond);
|
||||
|
||||
sb[14].StatID = (uint)Stats.OutPacketsPerSecond;
|
||||
sb[14].StatValue = (m_outPacketsPerSecond / statsUpdateFactor);
|
||||
|
||||
sb[15].StatID = (uint)Stats.UnAckedBytes;
|
||||
sb[15].StatValue = m_unAckedBytes;
|
||||
|
||||
sb[16].StatID = (uint)Stats.AgentMS;
|
||||
sb[16].StatValue = m_agentMS / statsUpdateFactor;
|
||||
|
||||
sb[17].StatID = (uint)Stats.PendingDownloads;
|
||||
sb[17].StatValue = m_pendingDownloads;
|
||||
|
||||
sb[18].StatID = (uint)Stats.PendingUploads;
|
||||
sb[18].StatValue = m_pendingUploads;
|
||||
|
||||
sb[19].StatID = (uint)Stats.ActiveScripts;
|
||||
sb[19].StatValue = m_activeScripts;
|
||||
|
||||
sb[20].StatID = (uint)Stats.ScriptLinesPerSecond;
|
||||
sb[20].StatValue = m_scriptLinesPerSecond / statsUpdateFactor;
|
||||
|
||||
statpack.Stat = sb;
|
||||
|
||||
handler001 = OnSendStatsResult;
|
||||
if (handler001 != null)
|
||||
{
|
||||
handler001(statpack);
|
||||
}
|
||||
resetvalues();
|
||||
m_report.Enabled = true;
|
||||
}
|
||||
|
||||
private void resetvalues()
|
||||
{
|
||||
m_timeDilation = 0;
|
||||
m_fps = 0;
|
||||
m_pfps = 0;
|
||||
m_agentUpdates = 0;
|
||||
m_inPacketsPerSecond = 0;
|
||||
m_outPacketsPerSecond = 0;
|
||||
m_unAckedBytes = 0;
|
||||
m_scriptLinesPerSecond = 0;
|
||||
|
||||
m_frameMS = 0;
|
||||
m_agentMS = 0;
|
||||
m_netMS = 0;
|
||||
m_physicsMS = 0;
|
||||
m_imageMS = 0;
|
||||
m_otherMS = 0;
|
||||
m_scriptMS = 0;
|
||||
}
|
||||
|
||||
# region methods called from Scene
|
||||
// The majority of these functions are additive
|
||||
// so that you can easily change the amount of
|
||||
// seconds in between sim stats updates
|
||||
|
||||
public void AddTimeDilation(float td)
|
||||
{
|
||||
//float tdsetting = td;
|
||||
//if (tdsetting > 1.0f)
|
||||
//tdsetting = (tdsetting - (tdsetting - 0.91f));
|
||||
|
||||
//if (tdsetting < 0)
|
||||
//tdsetting = 0.0f;
|
||||
m_timeDilation = td;
|
||||
}
|
||||
|
||||
public void SetRootAgents(int rootAgents)
|
||||
{
|
||||
m_rootAgents = rootAgents;
|
||||
}
|
||||
|
||||
public void SetChildAgents(int childAgents)
|
||||
{
|
||||
m_childAgents = childAgents;
|
||||
}
|
||||
|
||||
public void SetObjects(int objects)
|
||||
{
|
||||
m_numPrim = objects;
|
||||
}
|
||||
|
||||
public void SetActiveObjects(int objects)
|
||||
{
|
||||
m_activePrim = objects;
|
||||
}
|
||||
|
||||
public void AddFPS(int frames)
|
||||
{
|
||||
m_fps += frames;
|
||||
}
|
||||
|
||||
public void AddPhysicsFPS(float frames)
|
||||
{
|
||||
m_pfps += frames;
|
||||
}
|
||||
|
||||
public void AddAgentUpdates(int numUpdates)
|
||||
{
|
||||
m_agentUpdates += numUpdates;
|
||||
}
|
||||
|
||||
public void AddInPackets(int numPackets)
|
||||
{
|
||||
m_inPacketsPerSecond += numPackets;
|
||||
}
|
||||
|
||||
public void AddOutPackets(int numPackets)
|
||||
{
|
||||
m_outPacketsPerSecond += numPackets;
|
||||
}
|
||||
|
||||
public void AddunAckedBytes(int numBytes)
|
||||
{
|
||||
m_unAckedBytes += numBytes;
|
||||
}
|
||||
|
||||
public void addFrameMS(int ms)
|
||||
{
|
||||
m_frameMS += ms;
|
||||
}
|
||||
public void addNetMS(int ms)
|
||||
{
|
||||
m_netMS += ms;
|
||||
}
|
||||
public void addAgentMS(int ms)
|
||||
{
|
||||
m_agentMS += ms;
|
||||
}
|
||||
public void addPhysicsMS(int ms)
|
||||
{
|
||||
m_physicsMS += ms;
|
||||
}
|
||||
public void addImageMS(int ms)
|
||||
{
|
||||
m_imageMS += ms;
|
||||
}
|
||||
public void addOtherMS(int ms)
|
||||
{
|
||||
m_otherMS += ms;
|
||||
}
|
||||
|
||||
// private static readonly log4net.ILog m_log
|
||||
// = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
public void addPendingDownload(int count)
|
||||
{
|
||||
m_pendingDownloads += count;
|
||||
//m_log.InfoFormat("[stats]: Adding {0} to pending downloads to make {1}", count, m_pendingDownloads);
|
||||
}
|
||||
|
||||
public void addScriptLines(int count)
|
||||
{
|
||||
m_scriptLinesPerSecond += count;
|
||||
}
|
||||
|
||||
public void SetActiveScripts(int count)
|
||||
{
|
||||
m_activeScripts = count;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue