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