parent
604b786d89
commit
4ce0c0794a
|
@ -377,19 +377,19 @@ namespace OpenSim
|
|||
switch (command)
|
||||
{
|
||||
case "set-time":
|
||||
m_localScenes.SetTimePhase(Convert.ToInt32(cmdparams[0]));
|
||||
m_localScenes.SetCurrentSceneTimePhase(Convert.ToInt32(cmdparams[0]));
|
||||
break;
|
||||
|
||||
case "force-update":
|
||||
Console.WriteLine("Updating all clients");
|
||||
m_localScenes.ForceClientUpdate();
|
||||
m_localScenes.ForceCurrentSceneClientUpdate();
|
||||
break;
|
||||
|
||||
|
||||
case "edit-scale":
|
||||
if (cmdparams.Length == 4)
|
||||
{
|
||||
m_localScenes.HandleEditCommand(cmdparams);
|
||||
m_localScenes.HandleEditCommandOnCurrentScene(cmdparams);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -427,34 +427,34 @@ namespace OpenSim
|
|||
case "save-xml":
|
||||
if (cmdparams.Length > 0)
|
||||
{
|
||||
m_localScenes.SavePrimsToXml(cmdparams[0]);
|
||||
m_localScenes.SaveCurrentSceneToXml(cmdparams[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_localScenes.SavePrimsToXml(DEFAULT_PRIM_BACKUP_FILENAME);
|
||||
m_localScenes.SaveCurrentSceneToXml(DEFAULT_PRIM_BACKUP_FILENAME);
|
||||
}
|
||||
break;
|
||||
|
||||
case "load-xml":
|
||||
if (cmdparams.Length > 0)
|
||||
{
|
||||
m_localScenes.LoadPrimsFromXml(cmdparams[0]);
|
||||
m_localScenes.LoadCurrentSceneFromXml(cmdparams[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_localScenes.LoadPrimsFromXml(DEFAULT_PRIM_BACKUP_FILENAME);
|
||||
m_localScenes.LoadCurrentSceneFromXml(DEFAULT_PRIM_BACKUP_FILENAME);
|
||||
}
|
||||
break;
|
||||
|
||||
case "terrain":
|
||||
if (!m_localScenes.RunTerrainCmd(cmdparams, ref result))
|
||||
if (!m_localScenes.RunTerrainCmdOnCurrentScene(cmdparams, ref result))
|
||||
{
|
||||
m_log.Error(result);
|
||||
}
|
||||
break;
|
||||
|
||||
case "script":
|
||||
m_localScenes.SendCommandToScripts(cmdparams);
|
||||
m_localScenes.SendCommandToCurrentSceneScripts(cmdparams);
|
||||
break;
|
||||
|
||||
case "command-script":
|
||||
|
@ -468,16 +468,16 @@ namespace OpenSim
|
|||
// Treats each user as a super-admin when disabled
|
||||
bool permissions = Convert.ToBoolean(cmdparams[0]);
|
||||
|
||||
m_localScenes.BypassPermissions(!permissions);
|
||||
m_localScenes.SetBypassPermissionsOnCurrentScene(!permissions);
|
||||
|
||||
break;
|
||||
|
||||
case "backup":
|
||||
m_localScenes.Backup();
|
||||
m_localScenes.BackupCurrentScene();
|
||||
break;
|
||||
|
||||
case "alert":
|
||||
m_localScenes.HandleAlertCommand(cmdparams);
|
||||
m_localScenes.HandleAlertCommandOnCurrentScene(cmdparams);
|
||||
break;
|
||||
|
||||
case "create":
|
||||
|
@ -497,7 +497,7 @@ namespace OpenSim
|
|||
{
|
||||
string regionName = this.CombineParams(cmdparams, 0);
|
||||
|
||||
if (m_localScenes.TrySetCurrentRegion(regionName))
|
||||
if (m_localScenes.TrySetCurrentScene(regionName))
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -535,7 +535,7 @@ namespace OpenSim
|
|||
int newDebug;
|
||||
if (int.TryParse(args[1], out newDebug))
|
||||
{
|
||||
m_localScenes.DebugPacket(m_log, newDebug);
|
||||
m_localScenes.SetDebugPacketOnCurrentScene(m_log, newDebug);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -568,7 +568,7 @@ namespace OpenSim
|
|||
case "users":
|
||||
m_log.Error(String.Format("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16}{5,-16}{6,-16}", "Firstname", "Lastname", "Agent ID", "Session ID", "Circuit", "IP", "World"));
|
||||
|
||||
List<ScenePresence> avatars = m_localScenes.GetAvatars();
|
||||
List<ScenePresence> avatars = m_localScenes.GetCurrentSceneAvatars();
|
||||
|
||||
foreach (ScenePresence avatar in avatars)
|
||||
{
|
||||
|
|
|
@ -8,207 +8,207 @@ using OpenSim.Framework.Utilities;
|
|||
using OpenSim.Region.Environment.Interfaces;
|
||||
using OpenSim.Region.Environment.Scenes;
|
||||
|
||||
namespace OpenSim.Region.Environment.Modules
|
||||
{
|
||||
public class ChatModule : IRegionModule, ISimChat
|
||||
{
|
||||
private Scene m_scene;
|
||||
|
||||
private string m_server = "irc2.choopa.net";
|
||||
|
||||
// private int m_port = 6668;
|
||||
//private string m_user = "USER OpenSimBot 8 * :I'm a OpenSim to irc bot";
|
||||
private string m_nick = "OSimBot";
|
||||
private string m_channel = "#opensim";
|
||||
|
||||
// private NetworkStream m_stream;
|
||||
private TcpClient m_irc;
|
||||
private StreamWriter m_ircWriter;
|
||||
private StreamReader m_ircReader;
|
||||
|
||||
// private Thread pingSender;
|
||||
// private Thread listener;
|
||||
|
||||
private bool connected = false;
|
||||
|
||||
public ChatModule()
|
||||
{
|
||||
m_nick = "OSimBot" + Util.RandomClass.Next(1, 99);
|
||||
m_irc = null;
|
||||
m_ircWriter = null;
|
||||
m_ircReader = null;
|
||||
}
|
||||
|
||||
public void Initialise(Scene scene)
|
||||
{
|
||||
m_scene = scene;
|
||||
m_scene.EventManager.OnNewClient += NewClient;
|
||||
|
||||
m_scene.RegisterModuleInterface<ISimChat>(this);
|
||||
}
|
||||
|
||||
public void PostInitialise()
|
||||
{
|
||||
/*
|
||||
try
|
||||
{
|
||||
m_irc = new TcpClient(m_server, m_port);
|
||||
m_stream = m_irc.GetStream();
|
||||
m_ircReader = new StreamReader(m_stream);
|
||||
m_ircWriter = new StreamWriter(m_stream);
|
||||
|
||||
pingSender = new Thread(new ThreadStart(this.PingRun));
|
||||
pingSender.Start();
|
||||
|
||||
listener = new Thread(new ThreadStart(this.ListenerRun));
|
||||
listener.Start();
|
||||
|
||||
m_ircWriter.WriteLine(m_user);
|
||||
m_ircWriter.Flush();
|
||||
m_ircWriter.WriteLine("NICK " + m_nick);
|
||||
m_ircWriter.Flush();
|
||||
m_ircWriter.WriteLine("JOIN " + m_channel);
|
||||
m_ircWriter.Flush();
|
||||
connected = true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e.ToString());
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
public void CloseDown()
|
||||
{
|
||||
m_ircWriter.Close();
|
||||
m_ircReader.Close();
|
||||
m_irc.Close();
|
||||
}
|
||||
|
||||
public string GetName()
|
||||
{
|
||||
return "ChatModule";
|
||||
}
|
||||
|
||||
public bool IsSharedModule()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public void NewClient(IClientAPI client)
|
||||
{
|
||||
client.OnChatFromViewer += SimChat;
|
||||
}
|
||||
|
||||
public void PingRun()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
m_ircWriter.WriteLine("PING :" + m_server);
|
||||
m_ircWriter.Flush();
|
||||
Thread.Sleep(15000);
|
||||
}
|
||||
}
|
||||
|
||||
public void ListenerRun()
|
||||
{
|
||||
string inputLine;
|
||||
LLVector3 pos = new LLVector3(128, 128, 20);
|
||||
while (true)
|
||||
{
|
||||
while ((inputLine = m_ircReader.ReadLine()) != null)
|
||||
{
|
||||
Console.WriteLine(inputLine);
|
||||
if (inputLine.Contains(m_channel))
|
||||
{
|
||||
string mess = inputLine.Substring(inputLine.IndexOf(m_channel));
|
||||
m_scene.ForEachScenePresence(delegate(ScenePresence presence)
|
||||
{
|
||||
namespace OpenSim.Region.Environment.Modules
|
||||
{
|
||||
public class ChatModule : IRegionModule, ISimChat
|
||||
{
|
||||
private Scene m_scene;
|
||||
|
||||
private string m_server = "irc2.choopa.net";
|
||||
|
||||
// private int m_port = 6668;
|
||||
//private string m_user = "USER OpenSimBot 8 * :I'm a OpenSim to irc bot";
|
||||
private string m_nick = "OSimBot";
|
||||
private string m_channel = "#opensim";
|
||||
|
||||
// private NetworkStream m_stream;
|
||||
private TcpClient m_irc;
|
||||
private StreamWriter m_ircWriter;
|
||||
private StreamReader m_ircReader;
|
||||
|
||||
// private Thread pingSender;
|
||||
// private Thread listener;
|
||||
|
||||
private bool connected = false;
|
||||
|
||||
public ChatModule()
|
||||
{
|
||||
m_nick = "OSimBot" + Util.RandomClass.Next(1, 99);
|
||||
m_irc = null;
|
||||
m_ircWriter = null;
|
||||
m_ircReader = null;
|
||||
}
|
||||
|
||||
public void Initialise(Scene scene)
|
||||
{
|
||||
m_scene = scene;
|
||||
m_scene.EventManager.OnNewClient += NewClient;
|
||||
|
||||
m_scene.RegisterModuleInterface<ISimChat>(this);
|
||||
}
|
||||
|
||||
public void PostInitialise()
|
||||
{
|
||||
/*
|
||||
try
|
||||
{
|
||||
m_irc = new TcpClient(m_server, m_port);
|
||||
m_stream = m_irc.GetStream();
|
||||
m_ircReader = new StreamReader(m_stream);
|
||||
m_ircWriter = new StreamWriter(m_stream);
|
||||
|
||||
pingSender = new Thread(new ThreadStart(this.PingRun));
|
||||
pingSender.Start();
|
||||
|
||||
listener = new Thread(new ThreadStart(this.ListenerRun));
|
||||
listener.Start();
|
||||
|
||||
m_ircWriter.WriteLine(m_user);
|
||||
m_ircWriter.Flush();
|
||||
m_ircWriter.WriteLine("NICK " + m_nick);
|
||||
m_ircWriter.Flush();
|
||||
m_ircWriter.WriteLine("JOIN " + m_channel);
|
||||
m_ircWriter.Flush();
|
||||
connected = true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e.ToString());
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
public void CloseDown()
|
||||
{
|
||||
m_ircWriter.Close();
|
||||
m_ircReader.Close();
|
||||
m_irc.Close();
|
||||
}
|
||||
|
||||
public string GetName()
|
||||
{
|
||||
return "ChatModule";
|
||||
}
|
||||
|
||||
public bool IsSharedModule()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public void NewClient(IClientAPI client)
|
||||
{
|
||||
client.OnChatFromViewer += SimChat;
|
||||
}
|
||||
|
||||
public void PingRun()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
m_ircWriter.WriteLine("PING :" + m_server);
|
||||
m_ircWriter.Flush();
|
||||
Thread.Sleep(15000);
|
||||
}
|
||||
}
|
||||
|
||||
public void ListenerRun()
|
||||
{
|
||||
string inputLine;
|
||||
LLVector3 pos = new LLVector3(128, 128, 20);
|
||||
while (true)
|
||||
{
|
||||
while ((inputLine = m_ircReader.ReadLine()) != null)
|
||||
{
|
||||
Console.WriteLine(inputLine);
|
||||
if (inputLine.Contains(m_channel))
|
||||
{
|
||||
string mess = inputLine.Substring(inputLine.IndexOf(m_channel));
|
||||
m_scene.ForEachScenePresence(delegate(ScenePresence presence)
|
||||
{
|
||||
presence.ControllingClient.SendChatMessage(
|
||||
Helpers.StringToField(mess), 255, pos, "IRC:",
|
||||
LLUUID.Zero);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Helpers.StringToField(mess), 255, pos, "IRC:",
|
||||
LLUUID.Zero);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SimChat(byte[] message, byte type, int channel, LLVector3 fromPos, string fromName,
|
||||
LLUUID fromAgentID)
|
||||
{
|
||||
ScenePresence avatar = null;
|
||||
avatar = m_scene.RequestAvatar(fromAgentID);
|
||||
if (avatar != null)
|
||||
{
|
||||
fromPos = avatar.AbsolutePosition;
|
||||
fromName = avatar.Firstname + " " + avatar.Lastname;
|
||||
avatar = null;
|
||||
}
|
||||
|
||||
if (connected)
|
||||
{
|
||||
m_ircWriter.WriteLine("PRIVMSG " + m_channel + " :" + "<" + fromName + ">: " +
|
||||
Util.FieldToString(message));
|
||||
m_ircWriter.Flush();
|
||||
}
|
||||
|
||||
if (channel == 0)
|
||||
{
|
||||
m_scene.ForEachScenePresence(delegate(ScenePresence presence)
|
||||
{
|
||||
int dis = -1000;
|
||||
|
||||
//err ??? the following code seems to be request a scenePresence when it already has a ref to it
|
||||
avatar = m_scene.RequestAvatar(presence.ControllingClient.AgentId);
|
||||
if (avatar != null)
|
||||
{
|
||||
dis = (int) avatar.AbsolutePosition.GetDistanceTo(fromPos);
|
||||
}
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case 0: // Whisper
|
||||
if ((dis < 10) && (dis > -10))
|
||||
{
|
||||
//should change so the message is sent through the avatar rather than direct to the ClientView
|
||||
presence.ControllingClient.SendChatMessage(message,
|
||||
type,
|
||||
fromPos,
|
||||
fromName,
|
||||
fromAgentID);
|
||||
}
|
||||
break;
|
||||
case 1: // Say
|
||||
if ((dis < 30) && (dis > -30))
|
||||
{
|
||||
//Console.WriteLine("sending chat");
|
||||
presence.ControllingClient.SendChatMessage(message,
|
||||
type,
|
||||
fromPos,
|
||||
fromName,
|
||||
fromAgentID);
|
||||
}
|
||||
break;
|
||||
case 2: // Shout
|
||||
if ((dis < 100) && (dis > -100))
|
||||
{
|
||||
presence.ControllingClient.SendChatMessage(message,
|
||||
type,
|
||||
fromPos,
|
||||
fromName,
|
||||
fromAgentID);
|
||||
}
|
||||
break;
|
||||
|
||||
case 0xff: // Broadcast
|
||||
presence.ControllingClient.SendChatMessage(message, type,
|
||||
fromPos,
|
||||
fromName,
|
||||
fromAgentID);
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
LLUUID fromAgentID)
|
||||
{
|
||||
ScenePresence avatar = null;
|
||||
avatar = m_scene.RequestAvatar(fromAgentID);
|
||||
if (avatar != null)
|
||||
{
|
||||
fromPos = avatar.AbsolutePosition;
|
||||
fromName = avatar.Firstname + " " + avatar.Lastname;
|
||||
avatar = null;
|
||||
}
|
||||
|
||||
if (connected)
|
||||
{
|
||||
m_ircWriter.WriteLine("PRIVMSG " + m_channel + " :" + "<" + fromName + ">: " +
|
||||
Util.FieldToString(message));
|
||||
m_ircWriter.Flush();
|
||||
}
|
||||
|
||||
if (channel == 0)
|
||||
{
|
||||
m_scene.ForEachScenePresence(delegate(ScenePresence presence)
|
||||
{
|
||||
int dis = -1000;
|
||||
|
||||
//err ??? the following code seems to be request a scenePresence when it already has a ref to it
|
||||
avatar = m_scene.RequestAvatar(presence.ControllingClient.AgentId);
|
||||
if (avatar != null)
|
||||
{
|
||||
dis = (int) avatar.AbsolutePosition.GetDistanceTo(fromPos);
|
||||
}
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case 0: // Whisper
|
||||
if ((dis < 10) && (dis > -10))
|
||||
{
|
||||
//should change so the message is sent through the avatar rather than direct to the ClientView
|
||||
presence.ControllingClient.SendChatMessage(message,
|
||||
type,
|
||||
fromPos,
|
||||
fromName,
|
||||
fromAgentID);
|
||||
}
|
||||
break;
|
||||
case 1: // Say
|
||||
if ((dis < 30) && (dis > -30))
|
||||
{
|
||||
//Console.WriteLine("sending chat");
|
||||
presence.ControllingClient.SendChatMessage(message,
|
||||
type,
|
||||
fromPos,
|
||||
fromName,
|
||||
fromAgentID);
|
||||
}
|
||||
break;
|
||||
case 2: // Shout
|
||||
if ((dis < 100) && (dis > -100))
|
||||
{
|
||||
presence.ControllingClient.SendChatMessage(message,
|
||||
type,
|
||||
fromPos,
|
||||
fromName,
|
||||
fromAgentID);
|
||||
}
|
||||
break;
|
||||
|
||||
case 0xff: // Broadcast
|
||||
presence.ControllingClient.SendChatMessage(message, type,
|
||||
fromPos,
|
||||
fromName,
|
||||
fromAgentID);
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -48,7 +48,7 @@ using OpenSim.Region.Environment.Scenes.Scripting;
|
|||
using OpenSim.Region.Environment.Types;
|
||||
using OpenSim.Region.Physics.Manager;
|
||||
using OpenSim.Region.Terrain;
|
||||
using Timer=System.Timers.Timer;
|
||||
using Timer = System.Timers.Timer;
|
||||
|
||||
namespace OpenSim.Region.Environment.Scenes
|
||||
{
|
||||
|
@ -195,7 +195,7 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
Prims = new Dictionary<LLUUID, SceneObjectGroup>();
|
||||
|
||||
MainLog.Instance.Verbose("Creating LandMap");
|
||||
Terrain = new TerrainEngine((int) RegionInfo.RegionLocX, (int) RegionInfo.RegionLocY);
|
||||
Terrain = new TerrainEngine((int)RegionInfo.RegionLocX, (int)RegionInfo.RegionLocY);
|
||||
|
||||
ScenePresence.LoadAnims();
|
||||
|
||||
|
@ -254,7 +254,7 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
if (phyScene.IsThreaded)
|
||||
{
|
||||
phyScene.GetResults();
|
||||
/// no engines implement this, and what does it have to do with threading? possible DEAD CODE
|
||||
/// no engines implement this, and what does it have to do with threading? possible DEAD CODE
|
||||
}
|
||||
|
||||
List<EntityBase> moveEntities = new List<EntityBase>(Entities.Values);
|
||||
|
@ -313,7 +313,7 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
{
|
||||
for (int y = 0; y < 16; y++)
|
||||
{
|
||||
if (Terrain.Tainted(x*16, y*16))
|
||||
if (Terrain.Tainted(x * 16, y * 16))
|
||||
{
|
||||
SendLayerData(x, y, presence.ControllingClient,
|
||||
terData);
|
||||
|
@ -526,7 +526,7 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
{
|
||||
AddEntityFromStorage(prim);
|
||||
SceneObjectPart rootPart = prim.GetChildPart(prim.UUID);
|
||||
if ((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Phantom) == 0)
|
||||
if ((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Phantom) == 0)
|
||||
rootPart.PhysActor = phyScene.AddPrim(
|
||||
new PhysicsVector(rootPart.AbsolutePosition.X, rootPart.AbsolutePosition.Y,
|
||||
rootPart.AbsolutePosition.Z),
|
||||
|
@ -570,10 +570,10 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
// if grass or tree, make phantom
|
||||
if ((rootPart.Shape.PCode == 95) || (rootPart.Shape.PCode == 255))
|
||||
{
|
||||
rootPart.ObjectFlags += (uint) LLObject.ObjectFlags.Phantom;
|
||||
rootPart.ObjectFlags += (uint)LLObject.ObjectFlags.Phantom;
|
||||
}
|
||||
// if not phantom, add to physics
|
||||
if ((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Phantom) == 0)
|
||||
if ((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Phantom) == 0)
|
||||
rootPart.PhysActor =
|
||||
phyScene.AddPrim(new PhysicsVector(pos.X, pos.Y, pos.Z),
|
||||
new PhysicsVector(shape.Scale.X, shape.Scale.Y, shape.Scale.Z),
|
||||
|
@ -587,9 +587,9 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
{
|
||||
if (obj is SceneObjectGroup)
|
||||
{
|
||||
if (((SceneObjectGroup) obj).LocalId == localID)
|
||||
if (((SceneObjectGroup)obj).LocalId == localID)
|
||||
{
|
||||
RemoveEntity((SceneObjectGroup) obj);
|
||||
RemoveEntity((SceneObjectGroup)obj);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -657,7 +657,7 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
AddEntity(obj);
|
||||
|
||||
SceneObjectPart rootPart = obj.GetChildPart(obj.UUID);
|
||||
if ((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Phantom) == 0)
|
||||
if ((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Phantom) == 0)
|
||||
rootPart.PhysActor = phyScene.AddPrim(
|
||||
new PhysicsVector(rootPart.AbsolutePosition.X, rootPart.AbsolutePosition.Y,
|
||||
rootPart.AbsolutePosition.Z),
|
||||
|
@ -683,7 +683,7 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
{
|
||||
if (ent is SceneObjectGroup)
|
||||
{
|
||||
stream.WriteLine(((SceneObjectGroup) ent).ToXmlString());
|
||||
stream.WriteLine(((SceneObjectGroup)ent).ToXmlString());
|
||||
primCount++;
|
||||
}
|
||||
}
|
||||
|
@ -706,9 +706,9 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
{
|
||||
SubscribeToClientEvents(client);
|
||||
m_estateManager.sendRegionHandshake(client);
|
||||
|
||||
|
||||
CreateAndAddScenePresence(client, child);
|
||||
|
||||
|
||||
m_LandManager.sendParcelOverlay(client);
|
||||
commsManager.UserProfiles.AddNewUser(client.AgentId);
|
||||
commsManager.TransactionsManager.AddUser(client.AgentId);
|
||||
|
@ -793,7 +793,7 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
MainLog.Instance.Verbose(RegionInfo.RegionName + ": Creating new root agent.");
|
||||
MainLog.Instance.Verbose(RegionInfo.RegionName + ": Adding Physical agent.");
|
||||
|
||||
newAvatar.AddToPhysicalScene( );
|
||||
newAvatar.AddToPhysicalScene();
|
||||
}
|
||||
|
||||
lock (Entities)
|
||||
|
@ -835,14 +835,14 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
|
||||
ForEachScenePresence(
|
||||
delegate(ScenePresence presence)
|
||||
{
|
||||
presence.CoarseLocationChange(avatar);
|
||||
presence.ControllingClient.SendKillObject(avatar.RegionHandle, avatar.LocalId);
|
||||
if (presence.PhysActor != null)
|
||||
{
|
||||
presence.CoarseLocationChange(avatar);
|
||||
presence.ControllingClient.SendKillObject(avatar.RegionHandle, avatar.LocalId);
|
||||
if (presence.PhysActor != null)
|
||||
{
|
||||
phyScene.RemoveAvatar(presence.PhysActor);
|
||||
}
|
||||
});
|
||||
phyScene.RemoveAvatar(presence.PhysActor);
|
||||
}
|
||||
});
|
||||
|
||||
lock (Avatars)
|
||||
{
|
||||
|
@ -968,7 +968,7 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
if (ent is SceneObjectGroup)
|
||||
{
|
||||
// ((SceneObjectGroup)ent).SendFullUpdateToClient(client);
|
||||
((SceneObjectGroup) ent).ScheduleFullUpdateToAvatar(presence);
|
||||
((SceneObjectGroup)ent).ScheduleFullUpdateToAvatar(presence);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1157,17 +1157,17 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
|
||||
public void RegisterModuleInterface<M>(M mod)
|
||||
{
|
||||
if (!ModuleInterfaces.ContainsKey(typeof (M)))
|
||||
if (!ModuleInterfaces.ContainsKey(typeof(M)))
|
||||
{
|
||||
ModuleInterfaces.Add(typeof (M), mod);
|
||||
ModuleInterfaces.Add(typeof(M), mod);
|
||||
}
|
||||
}
|
||||
|
||||
public T RequestModuleInterface<T>()
|
||||
{
|
||||
if (ModuleInterfaces.ContainsKey(typeof (T)))
|
||||
if (ModuleInterfaces.ContainsKey(typeof(T)))
|
||||
{
|
||||
return (T) ModuleInterfaces[typeof (T)];
|
||||
return (T)ModuleInterfaces[typeof(T)];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1257,7 +1257,7 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
{
|
||||
if (ent is SceneObjectGroup)
|
||||
{
|
||||
((SceneObjectGroup) ent).ScheduleGroupForFullUpdate();
|
||||
((SceneObjectGroup)ent).ScheduleGroupForFullUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1269,7 +1269,7 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
{
|
||||
if (ent is SceneObjectGroup)
|
||||
{
|
||||
SceneObjectPart part = ((SceneObjectGroup) ent).GetChildPart(((SceneObjectGroup) ent).UUID);
|
||||
SceneObjectPart part = ((SceneObjectGroup)ent).GetChildPart(((SceneObjectGroup)ent).UUID);
|
||||
if (part != null)
|
||||
{
|
||||
if (part.Name == cmmdparams[0])
|
||||
|
@ -1357,10 +1357,10 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
{
|
||||
if (ent is SceneObjectGroup)
|
||||
{
|
||||
hasPrim = ((SceneObjectGroup) ent).HasChildPrim(localID);
|
||||
hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID);
|
||||
if (hasPrim != false)
|
||||
{
|
||||
return ((SceneObjectGroup) ent).GetPartsFullID(localID);
|
||||
return ((SceneObjectGroup)ent).GetPartsFullID(localID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1374,10 +1374,10 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
{
|
||||
if (ent is SceneObjectGroup)
|
||||
{
|
||||
hasPrim = ((SceneObjectGroup) ent).HasChildPrim(localID);
|
||||
hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID);
|
||||
if (hasPrim != false)
|
||||
{
|
||||
return ((SceneObjectGroup) ent).GetChildPart(localID);
|
||||
return ((SceneObjectGroup)ent).GetChildPart(localID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1391,14 +1391,30 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
{
|
||||
if (ent is SceneObjectGroup)
|
||||
{
|
||||
hasPrim = ((SceneObjectGroup) ent).HasChildPrim(fullID);
|
||||
hasPrim = ((SceneObjectGroup)ent).HasChildPrim(fullID);
|
||||
if (hasPrim != false)
|
||||
{
|
||||
return ((SceneObjectGroup) ent).GetChildPart(fullID);
|
||||
return ((SceneObjectGroup)ent).GetChildPart(fullID);
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
internal bool TryGetAvatar(LLUUID avatarId, out ScenePresence avatar)
|
||||
{
|
||||
ScenePresence presence;
|
||||
if (Avatars.TryGetValue(avatarId, out presence))
|
||||
{
|
||||
if (!presence.childAgent)
|
||||
{
|
||||
avatar = presence;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
avatar = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,215 +2,230 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using OpenSim.Framework.Console;
|
||||
using OpenSim.Framework.Types;
|
||||
using libsecondlife;
|
||||
|
||||
namespace OpenSim.Region.Environment.Scenes
|
||||
{
|
||||
public class SceneManager
|
||||
{
|
||||
private readonly List<Scene> m_localScenes;
|
||||
namespace OpenSim.Region.Environment.Scenes
|
||||
{
|
||||
public class SceneManager
|
||||
{
|
||||
private readonly List<Scene> m_localScenes;
|
||||
private Scene m_currentScene = null;
|
||||
|
||||
public Scene CurrentScene
|
||||
{
|
||||
get { return m_currentScene; }
|
||||
}
|
||||
|
||||
private Scene CurrentOrFirstScene
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_currentScene == null)
|
||||
{
|
||||
return m_localScenes[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
return m_currentScene;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public SceneManager()
|
||||
{
|
||||
m_localScenes = new List<Scene>();
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
for (int i = 0; i < m_localScenes.Count; i++)
|
||||
{
|
||||
m_localScenes[i].Close();
|
||||
}
|
||||
}
|
||||
|
||||
public void Add(Scene scene)
|
||||
{
|
||||
m_localScenes.Add(scene);
|
||||
}
|
||||
|
||||
public void SavePrimsToXml(string filename)
|
||||
{
|
||||
CurrentOrFirstScene.SavePrimsToXml(filename);
|
||||
}
|
||||
|
||||
public void LoadPrimsFromXml(string filename)
|
||||
{
|
||||
CurrentOrFirstScene.LoadPrimsFromXml(filename);
|
||||
}
|
||||
|
||||
public bool RunTerrainCmd(string[] cmdparams, ref string result)
|
||||
{
|
||||
if (m_currentScene == null)
|
||||
{
|
||||
bool success = true;
|
||||
foreach (Scene scene in m_localScenes)
|
||||
{
|
||||
if (!scene.Terrain.RunTerrainCmd(cmdparams, ref result, scene.RegionInfo.RegionName))
|
||||
{
|
||||
success = false;
|
||||
}
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
else
|
||||
{
|
||||
return m_currentScene.Terrain.RunTerrainCmd(cmdparams, ref result, m_currentScene.RegionInfo.RegionName);
|
||||
}
|
||||
}
|
||||
|
||||
public void SendCommandToScripts(string[] cmdparams)
|
||||
{
|
||||
ForEach(delegate(Scene scene) { scene.SendCommandToScripts(cmdparams); });
|
||||
}
|
||||
|
||||
public void BypassPermissions(bool bypassPermissions)
|
||||
{
|
||||
ForEach(delegate(Scene scene) { scene.PermissionsMngr.BypassPermissions = bypassPermissions; });
|
||||
}
|
||||
|
||||
private void ForEach(Action<Scene> func)
|
||||
{
|
||||
if (m_currentScene == null)
|
||||
{
|
||||
m_localScenes.ForEach(func);
|
||||
}
|
||||
else
|
||||
{
|
||||
func(m_currentScene);
|
||||
}
|
||||
}
|
||||
|
||||
public void Backup()
|
||||
{
|
||||
ForEach(delegate(Scene scene) { scene.Backup(); });
|
||||
}
|
||||
|
||||
public void HandleAlertCommand(string[] cmdparams)
|
||||
{
|
||||
ForEach(delegate(Scene scene) { scene.HandleAlertCommand(cmdparams); });
|
||||
}
|
||||
|
||||
public bool TrySetCurrentRegion(string regionName)
|
||||
{
|
||||
if ((String.Compare(regionName, "root") == 0) || (String.Compare(regionName, "..") == 0))
|
||||
{
|
||||
m_currentScene = null;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Searching for Region: '" + regionName + "'");
|
||||
|
||||
foreach (Scene scene in m_localScenes)
|
||||
{
|
||||
if (String.Compare(scene.RegionInfo.RegionName, regionName, true) == 0)
|
||||
{
|
||||
m_currentScene = scene;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void DebugPacket(LogBase log, int newDebug)
|
||||
{
|
||||
ForEach(delegate(Scene scene)
|
||||
{
|
||||
foreach (EntityBase entity in scene.Entities.Values)
|
||||
{
|
||||
if (entity is ScenePresence)
|
||||
{
|
||||
ScenePresence scenePrescence = entity as ScenePresence;
|
||||
if (!scenePrescence.childAgent)
|
||||
{
|
||||
log.Error(String.Format("Packet debug for {0} {1} set to {2}",
|
||||
scenePrescence.Firstname, scenePrescence.Lastname,
|
||||
newDebug));
|
||||
|
||||
scenePrescence.ControllingClient.SetDebug(newDebug);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public List<ScenePresence> GetAvatars()
|
||||
{
|
||||
List<ScenePresence> avatars = new List<ScenePresence>();
|
||||
|
||||
ForEach(delegate(Scene scene)
|
||||
{
|
||||
foreach (EntityBase entity in scene.Entities.Values)
|
||||
{
|
||||
if (entity is ScenePresence)
|
||||
{
|
||||
ScenePresence scenePrescence = entity as ScenePresence;
|
||||
if (!scenePrescence.childAgent)
|
||||
{
|
||||
avatars.Add(scenePrescence);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return avatars;
|
||||
}
|
||||
|
||||
public RegionInfo GetRegionInfo(ulong regionHandle)
|
||||
{
|
||||
foreach (Scene scene in m_localScenes)
|
||||
{
|
||||
if (scene.RegionInfo.RegionHandle == regionHandle)
|
||||
{
|
||||
return scene.RegionInfo;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void SetTimePhase(int timePhase)
|
||||
{
|
||||
ForEach(delegate(Scene scene)
|
||||
{
|
||||
scene.SetTimePhase(
|
||||
timePhase)
|
||||
;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public void ForceClientUpdate()
|
||||
{
|
||||
ForEach(delegate(Scene scene) { scene.ForceClientUpdate(); });
|
||||
}
|
||||
|
||||
public void HandleEditCommand(string[] cmdparams)
|
||||
{
|
||||
ForEach(delegate(Scene scene) { scene.HandleEditCommand(cmdparams); });
|
||||
}
|
||||
}
|
||||
public Scene CurrentScene
|
||||
{
|
||||
get { return m_currentScene; }
|
||||
}
|
||||
|
||||
public Scene CurrentOrFirstScene
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_currentScene == null)
|
||||
{
|
||||
return m_localScenes[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
return m_currentScene;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public SceneManager()
|
||||
{
|
||||
m_localScenes = new List<Scene>();
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
for (int i = 0; i < m_localScenes.Count; i++)
|
||||
{
|
||||
m_localScenes[i].Close();
|
||||
}
|
||||
}
|
||||
|
||||
public void Add(Scene scene)
|
||||
{
|
||||
m_localScenes.Add(scene);
|
||||
}
|
||||
|
||||
public void SaveCurrentSceneToXml(string filename)
|
||||
{
|
||||
CurrentOrFirstScene.SavePrimsToXml(filename);
|
||||
}
|
||||
|
||||
public void LoadCurrentSceneFromXml(string filename)
|
||||
{
|
||||
CurrentOrFirstScene.LoadPrimsFromXml(filename);
|
||||
}
|
||||
|
||||
public bool RunTerrainCmdOnCurrentScene(string[] cmdparams, ref string result)
|
||||
{
|
||||
if (m_currentScene == null)
|
||||
{
|
||||
bool success = true;
|
||||
foreach (Scene scene in m_localScenes)
|
||||
{
|
||||
if (!scene.Terrain.RunTerrainCmd(cmdparams, ref result, scene.RegionInfo.RegionName))
|
||||
{
|
||||
success = false;
|
||||
}
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
else
|
||||
{
|
||||
return m_currentScene.Terrain.RunTerrainCmd(cmdparams, ref result, m_currentScene.RegionInfo.RegionName);
|
||||
}
|
||||
}
|
||||
|
||||
public void SendCommandToCurrentSceneScripts(string[] cmdparams)
|
||||
{
|
||||
ForEachCurrentScene(delegate(Scene scene) { scene.SendCommandToScripts(cmdparams); });
|
||||
}
|
||||
|
||||
public void SetBypassPermissionsOnCurrentScene(bool bypassPermissions)
|
||||
{
|
||||
ForEachCurrentScene(delegate(Scene scene) { scene.PermissionsMngr.BypassPermissions = bypassPermissions; });
|
||||
}
|
||||
|
||||
private void ForEachCurrentScene(Action<Scene> func)
|
||||
{
|
||||
if (m_currentScene == null)
|
||||
{
|
||||
m_localScenes.ForEach(func);
|
||||
}
|
||||
else
|
||||
{
|
||||
func(m_currentScene);
|
||||
}
|
||||
}
|
||||
|
||||
public void BackupCurrentScene()
|
||||
{
|
||||
ForEachCurrentScene(delegate(Scene scene) { scene.Backup(); });
|
||||
}
|
||||
|
||||
public void HandleAlertCommandOnCurrentScene(string[] cmdparams)
|
||||
{
|
||||
ForEachCurrentScene(delegate(Scene scene) { scene.HandleAlertCommand(cmdparams); });
|
||||
}
|
||||
|
||||
public bool TrySetCurrentScene(string regionName)
|
||||
{
|
||||
if ((String.Compare(regionName, "root") == 0) || (String.Compare(regionName, "..") == 0))
|
||||
{
|
||||
m_currentScene = null;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Searching for Region: '" + regionName + "'");
|
||||
|
||||
foreach (Scene scene in m_localScenes)
|
||||
{
|
||||
if (String.Compare(scene.RegionInfo.RegionName, regionName, true) == 0)
|
||||
{
|
||||
m_currentScene = scene;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void SetDebugPacketOnCurrentScene(LogBase log, int newDebug)
|
||||
{
|
||||
ForEachCurrentScene(delegate(Scene scene)
|
||||
{
|
||||
foreach (EntityBase entity in scene.Entities.Values)
|
||||
{
|
||||
if (entity is ScenePresence)
|
||||
{
|
||||
ScenePresence scenePrescence = entity as ScenePresence;
|
||||
if (!scenePrescence.childAgent)
|
||||
{
|
||||
log.Error(String.Format("Packet debug for {0} {1} set to {2}",
|
||||
scenePrescence.Firstname, scenePrescence.Lastname,
|
||||
newDebug));
|
||||
|
||||
scenePrescence.ControllingClient.SetDebug(newDebug);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public List<ScenePresence> GetCurrentSceneAvatars()
|
||||
{
|
||||
List<ScenePresence> avatars = new List<ScenePresence>();
|
||||
|
||||
ForEachCurrentScene(delegate(Scene scene)
|
||||
{
|
||||
foreach (EntityBase entity in scene.Entities.Values)
|
||||
{
|
||||
if (entity is ScenePresence)
|
||||
{
|
||||
ScenePresence scenePrescence = entity as ScenePresence;
|
||||
if (!scenePrescence.childAgent)
|
||||
{
|
||||
avatars.Add(scenePrescence);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return avatars;
|
||||
}
|
||||
|
||||
public RegionInfo GetRegionInfo(ulong regionHandle)
|
||||
{
|
||||
foreach (Scene scene in m_localScenes)
|
||||
{
|
||||
if (scene.RegionInfo.RegionHandle == regionHandle)
|
||||
{
|
||||
return scene.RegionInfo;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void SetCurrentSceneTimePhase(int timePhase)
|
||||
{
|
||||
ForEachCurrentScene(delegate(Scene scene)
|
||||
{
|
||||
scene.SetTimePhase(
|
||||
timePhase)
|
||||
;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public void ForceCurrentSceneClientUpdate()
|
||||
{
|
||||
ForEachCurrentScene(delegate(Scene scene) { scene.ForceClientUpdate(); });
|
||||
}
|
||||
|
||||
public void HandleEditCommandOnCurrentScene(string[] cmdparams)
|
||||
{
|
||||
ForEachCurrentScene(delegate(Scene scene) { scene.HandleEditCommand(cmdparams); });
|
||||
}
|
||||
|
||||
public bool TryGetAvatar( LLUUID avatarId, out ScenePresence avatar )
|
||||
{
|
||||
foreach (Scene scene in m_localScenes)
|
||||
{
|
||||
if( scene.TryGetAvatar( avatarId, out avatar ))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
avatar = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue