From 9924f35613e7cbb1a30316c032f16e69234d9983 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Mon, 6 Aug 2007 13:21:30 +0000 Subject: * encapsulated firstname/lastname on ScenePresence * fixed 'users' console command * minor refactorings --- OpenSim/Region/Application/OpenSimMain.cs | 11 ++- .../Environment/Scenes/Scene.PacketHandlers.cs | 4 +- OpenSim/Region/Environment/Scenes/Scene.cs | 2 +- OpenSim/Region/Environment/Scenes/ScenePresence.cs | 86 ++++++++++++---------- .../Scripting/Engines/LSLEngine/LSLScript.cs | 2 +- .../Region/Environment/Scenes/Scripting/Script.cs | 2 +- .../Scenes/Scripting/ScriptInterpretedAPI.cs | 13 ++-- 7 files changed, 65 insertions(+), 55 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Application/OpenSimMain.cs b/OpenSim/Region/Application/OpenSimMain.cs index 7fb48b0..28d0477 100644 --- a/OpenSim/Region/Application/OpenSimMain.cs +++ b/OpenSim/Region/Application/OpenSimMain.cs @@ -65,7 +65,7 @@ namespace OpenSim protected List m_udpServers = new List(); protected List m_regionData = new List(); - protected List m_localScenes = new List(); + protected List m_localScenes = new List(); private bool m_silent; private string m_logFilename = ("region-console-" + Guid.NewGuid().ToString() + ".log"); @@ -430,16 +430,15 @@ namespace OpenSim m_log.Error("That is " + (DateTime.Now - m_startuptime).ToString()); break; case "users": - ScenePresence TempAv; 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")); for (int i = 0; i < m_localScenes.Count; i++) { - foreach (libsecondlife.LLUUID UUID in ((Scene)m_localScenes[i]).Entities.Keys) + foreach (Entity entity in m_localScenes[i].Entities.Values ) { - if (((Scene)m_localScenes[i]).Entities[UUID].ToString() == "OpenSim.world.Avatar") + if ( entity is ScenePresence ) { - TempAv = (ScenePresence)((Scene)m_localScenes[i]).Entities[UUID]; - m_log.Error(String.Format("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16},{5,-16}{6,-16}", TempAv.firstname, TempAv.lastname, UUID, TempAv.ControllingClient.AgentId, "Unknown", "Unknown"), ((Scene)m_localScenes[i]).RegionInfo.RegionName); + ScenePresence scenePrescence = entity as ScenePresence; + m_log.Error(String.Format("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16},{5,-16}{6,-16}", scenePrescence.Firstname, scenePrescence.Lastname, scenePrescence.UUID, scenePrescence.ControllingClient.AgentId, "Unknown", "Unknown"), ((Scene)m_localScenes[i]).RegionInfo.RegionName); } } } diff --git a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs index e839961..2f3ce6e 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs @@ -124,7 +124,7 @@ namespace OpenSim.Region.Environment.Scenes // Local sim message ScenePresence fromAvatar = this.Avatars[fromAgentID]; ScenePresence toAvatar = this.Avatars[toAgentID]; - string fromName = fromAvatar.firstname + " " + fromAvatar.lastname; + string fromName = fromAvatar.Firstname + " " + fromAvatar.Lastname; toAvatar.ControllingClient.SendInstantMessage(message, toAgentID, fromName); } else @@ -153,7 +153,7 @@ namespace OpenSim.Region.Environment.Scenes { avatar = this.Avatars[fromAgentID]; fromPos = avatar.Pos; - fromName = avatar.firstname + " " + avatar.lastname; + fromName = avatar.Firstname + " " + avatar.Lastname; avatar = null; } diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index 56e5a0a..4a57d13 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -963,7 +963,7 @@ namespace OpenSim.Region.Environment.Scenes { foreach (ScenePresence presence in this.Avatars.Values) { - if ((presence.firstname == firstName) && (presence.lastname == lastName)) + if ((presence.Firstname == firstName) && (presence.Lastname == lastName)) { presence.ControllingClient.SendAgentAlertMessage(message, modal); break; diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs index 882bb20..cc66b2e 100644 --- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs @@ -43,8 +43,6 @@ namespace OpenSim.Region.Environment.Scenes public static bool PhysicsEngineFlying = false; public static AvatarAnimations Animations; public static byte[] DefaultTexture; - public string firstname; - public string lastname; public IClientAPI ControllingClient; public LLUUID current_anim; public int anim_seq; @@ -69,7 +67,7 @@ namespace OpenSim.Region.Environment.Scenes protected RegionInfo m_regionInfo; protected ulong crossingFromRegion = 0; - private IScenePresenceBody m_body; + private IScenePresenceBody m_body; private Vector3[] Dir_Vectors = new Vector3[6]; private enum Dir_ControlFlags @@ -117,10 +115,22 @@ namespace OpenSim.Region.Environment.Scenes } } - public ulong RegionHandle - { - get { return m_regionHandle; } - } + public ulong RegionHandle + { + get { return m_regionHandle; } + } + + private string m_firstname; + public string Firstname + { + get { return m_firstname; } + } + + private string m_lastname; + public string Lastname + { + get { return m_lastname; } + } #endregion @@ -142,8 +152,8 @@ namespace OpenSim.Region.Environment.Scenes m_regionHandle = reginfo.RegionHandle; MainLog.Instance.Verbose("Avatar.cs "); ControllingClient = theClient; - this.firstname = ControllingClient.FirstName; - this.lastname = ControllingClient.LastName; + this.m_firstname = ControllingClient.FirstName; + this.m_lastname = ControllingClient.LastName; m_localId = m_scene.NextLocalId; Pos = ControllingClient.StartPos; @@ -166,7 +176,7 @@ namespace OpenSim.Region.Environment.Scenes // ControllingClient.OnStartAnim += new StartAnim(this.SendAnimPack); // ControllingClient.OnChildAgentStatus += new StatusChange(this.ChildStatusChange); //ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement); - + Dir_Vectors[0] = new Vector3(1, 0, 0); //FOWARD Dir_Vectors[1] = new Vector3(-1, 0, 0); //BACK Dir_Vectors[2] = new Vector3(0, 1, 0); //LEFT @@ -312,7 +322,7 @@ namespace OpenSim.Region.Environment.Scenes { movementflag -= (byte)(uint)DCF; update_movementflag = true; - + } } i++; @@ -399,7 +409,7 @@ namespace OpenSim.Region.Environment.Scenes this.CheckForSignificantMovement(); this.CheckForBorderCrossing(); - + } } #endregion @@ -434,7 +444,7 @@ namespace OpenSim.Region.Environment.Scenes /// public void SendFullUpdateToOtherClient(ScenePresence remoteAvatar) { - remoteAvatar.ControllingClient.SendAvatarData(m_regionInfo.RegionHandle, this.firstname, this.lastname, this.m_uuid, this.LocalId, this.Pos, this.m_textureEntry.ToBytes()); + remoteAvatar.ControllingClient.SendAvatarData(m_regionInfo.RegionHandle, this.m_firstname, this.m_lastname, this.m_uuid, this.LocalId, this.Pos, this.m_textureEntry.ToBytes()); } public void SendFullUpdateToALLClients() @@ -456,15 +466,15 @@ namespace OpenSim.Region.Environment.Scenes /// public void SendInitialData() { - this.ControllingClient.SendAvatarData(m_regionInfo.RegionHandle, this.firstname, this.lastname, this.m_uuid, this.LocalId, this.Pos, this.m_textureEntry.ToBytes()); + this.ControllingClient.SendAvatarData(m_regionInfo.RegionHandle, this.m_firstname, this.m_lastname, this.m_uuid, this.LocalId, this.Pos, this.m_textureEntry.ToBytes()); if (this.newAvatar) { this.m_scene.InformClientOfNeighbours(this.ControllingClient); this.newAvatar = false; } - // this.SendFullUpdateToALLClients(); - // this.SendArrearanceToAllOtherAgents(); + // this.SendFullUpdateToALLClients(); + // this.SendArrearanceToAllOtherAgents(); } /// @@ -486,11 +496,11 @@ namespace OpenSim.Region.Environment.Scenes /// public void SendArrearanceToAllOtherAgents() { - List avatars = this.m_scene.RequestAvatarList(); - foreach (ScenePresence avatar in this.m_scene.RequestAvatarList()) - { - this.SendAppearanceToOtherAgent(avatar); - } + List avatars = this.m_scene.RequestAvatarList(); + foreach (ScenePresence avatar in this.m_scene.RequestAvatarList()) + { + this.SendAppearanceToOtherAgent(avatar); + } } /// @@ -509,13 +519,13 @@ namespace OpenSim.Region.Environment.Scenes /// public void SendAnimPack(LLUUID animID, int seq) { - this.current_anim = animID; - this.anim_seq = seq; - List avatars = this.m_scene.RequestAvatarList(); - for (int i = 0; i < avatars.Count; i++) - { - avatars[i].ControllingClient.SendAnimation(animID, seq, this.ControllingClient.AgentId); - } + this.current_anim = animID; + this.anim_seq = seq; + List avatars = this.m_scene.RequestAvatarList(); + for (int i = 0; i < avatars.Count; i++) + { + avatars[i].ControllingClient.SendAnimation(animID, seq, this.ControllingClient.AgentId); + } } /// @@ -648,16 +658,16 @@ namespace OpenSim.Region.Environment.Scenes public static void CreateDefaultTextureEntry(string name) { - /* FileInfo fInfo = new FileInfo(name); - long numBytes = fInfo.Length; - FileStream fStream = new FileStream(name, FileMode.Open, FileAccess.Read); - BinaryReader br = new BinaryReader(fStream); - byte[] data1 = br.ReadBytes((int)numBytes); - br.Close(); - fStream.Close(); - DefaultTexture = data1; - LLObject.TextureEntry textu = new LLObject.TextureEntry(data1, 0, data1.Length); - Console.WriteLine("default texture entry: " + textu.ToString());*/ + /* FileInfo fInfo = new FileInfo(name); + long numBytes = fInfo.Length; + FileStream fStream = new FileStream(name, FileMode.Open, FileAccess.Read); + BinaryReader br = new BinaryReader(fStream); + byte[] data1 = br.ReadBytes((int)numBytes); + br.Close(); + fStream.Close(); + DefaultTexture = data1; + LLObject.TextureEntry textu = new LLObject.TextureEntry(data1, 0, data1.Length); + Console.WriteLine("default texture entry: " + textu.ToString());*/ LLObject.TextureEntry textu = new LLObject.TextureEntry(new LLUUID("C228D1CF-4B5D-4BA8-84F4-899A0796AA97")); textu.CreateFace(0).TextureID = new LLUUID("00000000-0000-1111-9999-000000000012"); diff --git a/OpenSim/Region/Environment/Scenes/Scripting/Engines/LSLEngine/LSLScript.cs b/OpenSim/Region/Environment/Scenes/Scripting/Engines/LSLEngine/LSLScript.cs index 6eca69a..71d4c7e 100644 --- a/OpenSim/Region/Environment/Scenes/Scripting/Engines/LSLEngine/LSLScript.cs +++ b/OpenSim/Region/Environment/Scenes/Scripting/Engines/LSLEngine/LSLScript.cs @@ -10,7 +10,7 @@ namespace OpenSim.Region.Scripting.LSL class LSLScript : IScript { ScriptInfo scriptInfo; - LSL.Engine lindenScriptEngine; + Engine lindenScriptEngine; public LSLScript(string filename, libsecondlife.LLUUID taskObject) { diff --git a/OpenSim/Region/Environment/Scenes/Scripting/Script.cs b/OpenSim/Region/Environment/Scenes/Scripting/Script.cs index fa4bdde..e1e1d87 100644 --- a/OpenSim/Region/Environment/Scenes/Scripting/Script.cs +++ b/OpenSim/Region/Environment/Scenes/Scripting/Script.cs @@ -53,7 +53,7 @@ namespace OpenSim.Region.Scripting void events_OnNewPresence(ScenePresence presence) { - script.logger.Verbose("Hello " + presence.firstname.ToString() + "!"); + script.logger.Verbose("Hello " + presence.Firstname.ToString() + "!"); } void events_OnFrame() diff --git a/OpenSim/Region/Environment/Scenes/Scripting/ScriptInterpretedAPI.cs b/OpenSim/Region/Environment/Scenes/Scripting/ScriptInterpretedAPI.cs index 284ae74..af8a29f 100644 --- a/OpenSim/Region/Environment/Scenes/Scripting/ScriptInterpretedAPI.cs +++ b/OpenSim/Region/Environment/Scenes/Scripting/ScriptInterpretedAPI.cs @@ -8,6 +8,7 @@ using LSLList = System.Collections.Generic.List; using OpenSim.Region.Environment.Scenes; using OpenSim.Region.Environment.LandManagement; +using libsecondlife; namespace OpenSim.Region.Scripting { @@ -17,13 +18,13 @@ namespace OpenSim.Region.Scripting /// Avoid at all costs. This should ONLY be used for LSL. class ScriptInterpretedAPI { - protected libsecondlife.LLUUID m_object; + protected LLUUID m_object; protected Scene m_scene; /// /// The scene in which this script is acting /// - public Scene World + public Scene Scene { get { return m_scene; } } @@ -41,7 +42,7 @@ namespace OpenSim.Region.Scripting /// public SceneObject Task { - get { return World.Objects[ObjectID]; } + get { return Scene.Objects[ObjectID]; } } /// @@ -74,7 +75,7 @@ namespace OpenSim.Region.Scripting public void osAddToLandPassList(Key avatar, float hours) { Vector myPosition = Task.Pos; - Land myParcel = World.LandManager.getLandObject(myPosition.X, myPosition.Y); + Land myParcel = Scene.LandManager.getLandObject(myPosition.X, myPosition.Y); OpenSim.Framework.Console.MainLog.Instance.Warn("script", "Unimplemented function called by script: osAddToLandPassList(Key avatar, float hours)"); return; @@ -228,8 +229,8 @@ namespace OpenSim.Region.Scripting public void osCreateLink(Key target, int parent) { - if(World.Entities[target] is SceneObject) - Task.AddNewChildPrims((SceneObject)World.Entities[target]); + if(Scene.Entities[target] is SceneObject) + Task.AddNewChildPrims((SceneObject)Scene.Entities[target]); return; } -- cgit v1.1