From 409bcd999d19c52133f7099963febdf96d865467 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Fri, 21 Sep 2007 03:13:49 +0000 Subject: * Continuing refactoring of presence * Deleted stub ScenePresence.Body.cs * Added stub Region classes The idea is to, at first, have every ScenePresence have one RegionPresence, moving code over to it until we can detach the two classes and not have a ScenePresence for every RegionPresence. --- OpenSim/Region/Application/OpenSimMain.cs | 14 ++- OpenSim/Region/Environment/EstateManager.cs | 4 +- OpenSim/Region/Environment/LandManagement/Land.cs | 2 +- OpenSim/Region/Environment/Modules/ChatModule.cs | 12 +-- OpenSim/Region/Environment/Regions/Region.cs | 15 +++ .../Region/Environment/Regions/RegionManager.cs | 16 +++ .../Region/Environment/Regions/RegionPresence.cs | 14 +++ OpenSim/Region/Environment/Scenes/EntityBase.cs | 2 +- .../Region/Environment/Scenes/Scene.Inventory.cs | 4 +- .../Environment/Scenes/Scene.PacketHandlers.cs | 4 +- OpenSim/Region/Environment/Scenes/Scene.cs | 39 +++---- OpenSim/Region/Environment/Scenes/SceneManager.cs | 6 +- .../Region/Environment/Scenes/SceneObjectGroup.cs | 4 +- .../Region/Environment/Scenes/SceneObjectPart.cs | 4 +- .../Environment/Scenes/ScenePresence.Body.cs | 82 --------------- OpenSim/Region/Environment/Scenes/ScenePresence.cs | 116 +++++++++++---------- 16 files changed, 151 insertions(+), 187 deletions(-) create mode 100644 OpenSim/Region/Environment/Regions/Region.cs create mode 100644 OpenSim/Region/Environment/Regions/RegionManager.cs create mode 100644 OpenSim/Region/Environment/Regions/RegionPresence.cs delete mode 100644 OpenSim/Region/Environment/Scenes/ScenePresence.Body.cs diff --git a/OpenSim/Region/Application/OpenSimMain.cs b/OpenSim/Region/Application/OpenSimMain.cs index c40b018..8e067eb 100644 --- a/OpenSim/Region/Application/OpenSimMain.cs +++ b/OpenSim/Region/Application/OpenSimMain.cs @@ -567,11 +567,9 @@ 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 avatars = m_sceneManager.GetCurrentSceneAvatars(); - - foreach (ScenePresence avatar in avatars) + foreach (ScenePresence presence in m_sceneManager.GetCurrentSceneAvatars()) { - RegionInfo regionInfo = m_sceneManager.GetRegionInfo(avatar.RegionHandle); + RegionInfo regionInfo = m_sceneManager.GetRegionInfo(presence.RegionHandle); string regionName; if (regionInfo == null) @@ -585,10 +583,10 @@ namespace OpenSim m_log.Error( String.Format("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16},{5,-16}{6,-16}", - avatar.Firstname, - avatar.Lastname, - avatar.UUID, - avatar._ControllingClient.AgentId, + presence.Firstname, + presence.Lastname, + presence.UUID, + presence.ControllingClient.AgentId, "Unknown", "Unknown", regionName)); diff --git a/OpenSim/Region/Environment/EstateManager.cs b/OpenSim/Region/Environment/EstateManager.cs index 8aaeace..ac710ad 100644 --- a/OpenSim/Region/Environment/EstateManager.cs +++ b/OpenSim/Region/Environment/EstateManager.cs @@ -335,7 +335,7 @@ namespace OpenSim.Region.Environment for (int i = 0; i < avatars.Count; i++) { - sendRegionInfoPacket(avatars[i]._ControllingClient); + sendRegionInfoPacket(avatars[i].ControllingClient); } } @@ -343,7 +343,7 @@ namespace OpenSim.Region.Environment { m_scene.ForEachScenePresence( delegate( ScenePresence scenePresence ) { - sendRegionHandshake(scenePresence._ControllingClient); + sendRegionHandshake(scenePresence.ControllingClient); }); } diff --git a/OpenSim/Region/Environment/LandManagement/Land.cs b/OpenSim/Region/Environment/LandManagement/Land.cs index 0ec77c5..6c177cd 100644 --- a/OpenSim/Region/Environment/LandManagement/Land.cs +++ b/OpenSim/Region/Environment/LandManagement/Land.cs @@ -203,7 +203,7 @@ namespace OpenSim.Region.Environment.LandManagement (int) Math.Round(avatars[i].AbsolutePosition.Y)); if (over.landData.localID == landData.localID) { - sendLandProperties(0, false, 0, avatars[i]._ControllingClient); + sendLandProperties(0, false, 0, avatars[i].ControllingClient); } } } diff --git a/OpenSim/Region/Environment/Modules/ChatModule.cs b/OpenSim/Region/Environment/Modules/ChatModule.cs index d19bae5..dfbb2bb 100644 --- a/OpenSim/Region/Environment/Modules/ChatModule.cs +++ b/OpenSim/Region/Environment/Modules/ChatModule.cs @@ -124,7 +124,7 @@ namespace OpenSim.Region.Environment.Modules string mess = inputLine.Substring(inputLine.IndexOf(m_channel)); m_scene.ForEachScenePresence(delegate(ScenePresence presence) { - presence._ControllingClient.SendChatMessage( + presence.ControllingClient.SendChatMessage( Helpers.StringToField(mess), 255, pos, "IRC:", LLUUID.Zero); }); @@ -159,7 +159,7 @@ namespace OpenSim.Region.Environment.Modules int dis = -1000; //err ??? the following code seems to be request a scenePresence when it already has a ref to it - avatar = m_scene.GetScenePresence(presence._ControllingClient.AgentId); + avatar = m_scene.GetScenePresence(presence.ControllingClient.AgentId); if (avatar != null) { dis = (int) avatar.AbsolutePosition.GetDistanceTo(fromPos); @@ -171,7 +171,7 @@ namespace OpenSim.Region.Environment.Modules 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, + presence.ControllingClient.SendChatMessage(message, type, fromPos, fromName, @@ -182,7 +182,7 @@ namespace OpenSim.Region.Environment.Modules if ((dis < 30) && (dis > -30)) { //Console.WriteLine("sending chat"); - presence._ControllingClient.SendChatMessage(message, + presence.ControllingClient.SendChatMessage(message, type, fromPos, fromName, @@ -192,7 +192,7 @@ namespace OpenSim.Region.Environment.Modules case 2: // Shout if ((dis < 100) && (dis > -100)) { - presence._ControllingClient.SendChatMessage(message, + presence.ControllingClient.SendChatMessage(message, type, fromPos, fromName, @@ -201,7 +201,7 @@ namespace OpenSim.Region.Environment.Modules break; case 0xff: // Broadcast - presence._ControllingClient.SendChatMessage(message, type, + presence.ControllingClient.SendChatMessage(message, type, fromPos, fromName, fromAgentID); diff --git a/OpenSim/Region/Environment/Regions/Region.cs b/OpenSim/Region/Environment/Regions/Region.cs new file mode 100644 index 0000000..f7669a9 --- /dev/null +++ b/OpenSim/Region/Environment/Regions/Region.cs @@ -0,0 +1,15 @@ +using System.Collections.Generic; +using libsecondlife; + +namespace OpenSim.Region.Environment.Regions +{ + public class Region + { + private Dictionary m_regionPresences; + + public Region() + { + m_regionPresences = new Dictionary( ); + } + } +} diff --git a/OpenSim/Region/Environment/Regions/RegionManager.cs b/OpenSim/Region/Environment/Regions/RegionManager.cs new file mode 100644 index 0000000..ab5b97c --- /dev/null +++ b/OpenSim/Region/Environment/Regions/RegionManager.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Region.Environment.Regions +{ + public class RegionManager + { + private Dictionary m_regions; + + public RegionManager( ) + { + m_regions = new Dictionary( ); + } + } +} diff --git a/OpenSim/Region/Environment/Regions/RegionPresence.cs b/OpenSim/Region/Environment/Regions/RegionPresence.cs new file mode 100644 index 0000000..9720bb3 --- /dev/null +++ b/OpenSim/Region/Environment/Regions/RegionPresence.cs @@ -0,0 +1,14 @@ +using OpenSim.Framework.Interfaces; + +namespace OpenSim.Region.Environment.Regions +{ + public class RegionPresence + { + private IClientAPI m_client; + + public RegionPresence(IClientAPI client ) + { + m_client = client; + } + } +} diff --git a/OpenSim/Region/Environment/Scenes/EntityBase.cs b/OpenSim/Region/Environment/Scenes/EntityBase.cs index bc27ec8..4832956 100644 --- a/OpenSim/Region/Environment/Scenes/EntityBase.cs +++ b/OpenSim/Region/Environment/Scenes/EntityBase.cs @@ -125,4 +125,4 @@ namespace OpenSim.Region.Environment.Scenes public abstract void SetText(string text, Vector3 color, double alpha); } -} \ No newline at end of file +} diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs index b0e2b80..a6e47f3 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs @@ -21,7 +21,7 @@ namespace OpenSim.Region.Environment.Scenes if ( TryGetAvatar( avatarId, out avatar )) { - AddInventoryItem(avatar._ControllingClient, item); + AddInventoryItem(avatar.ControllingClient, item); } } @@ -41,7 +41,7 @@ namespace OpenSim.Region.Environment.Scenes if (TryGetAvatar(avatarId, out avatar)) { - return CapsUpdateInventoryItemAsset(avatar._ControllingClient, itemID, data); + return CapsUpdateInventoryItemAsset(avatar.ControllingClient, itemID, data); } return LLUUID.Zero; diff --git a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs index 53da016..91b9634 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs @@ -77,7 +77,7 @@ namespace OpenSim.Region.Environment.Scenes ScenePresence fromAvatar = m_scenePresences[fromAgentID]; ScenePresence toAvatar = m_scenePresences[toAgentID]; string fromName = fromAvatar.Firstname + " " + fromAvatar.Lastname; - toAvatar._ControllingClient.SendInstantMessage(fromAgentID, fromAgentSession, message, toAgentID, + toAvatar.ControllingClient.SendInstantMessage(fromAgentID, fromAgentSession, message, toAgentID, imSessionID, fromName, dialog, timestamp); } else @@ -508,7 +508,7 @@ namespace OpenSim.Region.Environment.Scenes { ForEachScenePresence(delegate(ScenePresence presence) { - presence._ControllingClient.SendAnimation(animID, seq, client.AgentId); + presence.ControllingClient.SendAnimation(animID, seq, client.AgentId); }); } diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index d89ca28..55d760e 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -310,7 +310,7 @@ namespace OpenSim.Region.Environment.Scenes { if (Terrain.Tainted(x * 16, y * 16)) { - SendLayerData(x, y, presence._ControllingClient, + SendLayerData(x, y, presence.ControllingClient, terData); } } @@ -344,7 +344,7 @@ namespace OpenSim.Region.Environment.Scenes List avatars = GetAvatars(); foreach (ScenePresence avatar in avatars) { - avatar._ControllingClient.SendViewerTime(m_timePhase); + avatar.ControllingClient.SendViewerTime(m_timePhase); } m_timeUpdateCount = 0; @@ -396,7 +396,7 @@ namespace OpenSim.Region.Environment.Scenes storageManager.DataStore.StoreTerrain(Terrain.GetHeights2DD()); - ForEachScenePresence(delegate(ScenePresence presence) { SendLayerData(presence._ControllingClient); }); + ForEachScenePresence(delegate(ScenePresence presence) { SendLayerData(presence.ControllingClient); }); foreach (LLUUID UUID in Entities.Keys) { @@ -424,7 +424,7 @@ namespace OpenSim.Region.Environment.Scenes } storageManager.DataStore.StoreTerrain(Terrain.GetHeights2DD()); - ForEachScenePresence(delegate(ScenePresence presence) { SendLayerData(presence._ControllingClient); }); + ForEachScenePresence(delegate(ScenePresence presence) { SendLayerData(presence.ControllingClient); }); foreach (LLUUID UUID in Entities.Keys) { @@ -772,7 +772,7 @@ namespace OpenSim.Region.Environment.Scenes ScenePresence newAvatar = null; newAvatar = new ScenePresence(client, this, m_regInfo); - newAvatar.childAgent = child; + newAvatar.IsChildAgent = child; if (child) { @@ -829,7 +829,7 @@ namespace OpenSim.Region.Environment.Scenes delegate(ScenePresence presence) { presence.CoarseLocationChange(avatar); - presence._ControllingClient.SendKillObject(avatar.RegionHandle, avatar.LocalId); + presence.ControllingClient.SendKillObject(avatar.RegionHandle, avatar.LocalId); if (presence.PhysicsActor != null) { phyScene.RemoveAvatar(presence.PhysicsActor); @@ -881,7 +881,7 @@ namespace OpenSim.Region.Environment.Scenes { List result = GetScenePresences(delegate(ScenePresence scenePresence) { - return !scenePresence.childAgent; + return !scenePresence.IsChildAgent; }); return result; @@ -954,7 +954,7 @@ namespace OpenSim.Region.Environment.Scenes { ForEachScenePresence(delegate(ScenePresence presence) { - presence._ControllingClient.SendKillObject(m_regionHandle, localID); + presence.ControllingClient.SendKillObject(m_regionHandle, localID); }); } @@ -1182,7 +1182,7 @@ namespace OpenSim.Region.Environment.Scenes { if (m_scenePresences.ContainsKey(avatarID)) { - m_scenePresences[avatarID]._ControllingClient.SendLoadURL(objectname, objectID, ownerID, groupOwned, message, url); + m_scenePresences[avatarID].ControllingClient.SendLoadURL(objectname, objectID, ownerID, groupOwned, message, url); } } @@ -1198,7 +1198,7 @@ namespace OpenSim.Region.Environment.Scenes { foreach (ScenePresence presence in m_scenePresences.Values) { - presence._ControllingClient.SendAlertMessage(message); + presence.ControllingClient.SendAlertMessage(message); } } @@ -1206,7 +1206,7 @@ namespace OpenSim.Region.Environment.Scenes { if (m_scenePresences.ContainsKey(agentID)) { - m_scenePresences[agentID]._ControllingClient.SendAgentAlertMessage(message, modal); + m_scenePresences[agentID].ControllingClient.SendAgentAlertMessage(message, modal); } } @@ -1216,7 +1216,7 @@ namespace OpenSim.Region.Environment.Scenes { if ((presence.Firstname == firstName) && (presence.Lastname == lastName)) { - presence._ControllingClient.SendAgentAlertMessage(message, modal); + presence.ControllingClient.SendAgentAlertMessage(message, modal); break; } } @@ -1292,24 +1292,17 @@ namespace OpenSim.Region.Environment.Scenes 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")); - foreach (EntityBase entity in Entities.Values) + foreach (ScenePresence scenePrescence in GetAvatars()) { - if (entity is ScenePresence) - { - ScenePresence scenePrescence = entity as ScenePresence; - if (!scenePrescence.childAgent) - { - MainLog.Instance.Error( + MainLog.Instance.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, + scenePrescence.ControllingClient.AgentId, "Unknown", "Unknown", RegionInfo.RegionName)); - } - } } break; case "modules": @@ -1403,7 +1396,7 @@ namespace OpenSim.Region.Environment.Scenes ScenePresence presence; if (m_scenePresences.TryGetValue(avatarId, out presence)) { - if (!presence.childAgent) + if (!presence.IsChildAgent) { avatar = presence; return true; diff --git a/OpenSim/Region/Environment/Scenes/SceneManager.cs b/OpenSim/Region/Environment/Scenes/SceneManager.cs index 27331ee..79fdff7 100644 --- a/OpenSim/Region/Environment/Scenes/SceneManager.cs +++ b/OpenSim/Region/Environment/Scenes/SceneManager.cs @@ -145,13 +145,13 @@ namespace OpenSim.Region.Environment.Scenes if (entity is ScenePresence) { ScenePresence scenePrescence = entity as ScenePresence; - if (!scenePrescence.childAgent) + if (!scenePrescence.IsChildAgent) { log.Error(String.Format("Packet debug for {0} {1} set to {2}", scenePrescence.Firstname, scenePrescence.Lastname, newDebug)); - scenePrescence._ControllingClient.SetDebug(newDebug); + scenePrescence.ControllingClient.SetDebug(newDebug); } } } @@ -169,7 +169,7 @@ namespace OpenSim.Region.Environment.Scenes if (entity is ScenePresence) { ScenePresence scenePrescence = entity as ScenePresence; - if (!scenePrescence.childAgent) + if (!scenePrescence.IsChildAgent) { avatars.Add(scenePrescence); } diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs index d1c4ae8..c1c678f 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs @@ -80,7 +80,7 @@ namespace OpenSim.Region.Environment.Scenes } } - public override LLVector3 AbsolutePosition + public LLVector3 AbsolutePosition { get { return m_rootPart.GroupPosition; } set @@ -1236,7 +1236,7 @@ namespace OpenSim.Region.Environment.Scenes List avatars = GetScenePresences(); for (int i = 0; i < avatars.Count; i++) { - avatars[i]._ControllingClient.SendKillObject(m_regionHandle, part.LocalID); + avatars[i].ControllingClient.SendKillObject(m_regionHandle, part.LocalID); } } } diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs index 1b667b8..468def0 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs @@ -700,7 +700,7 @@ namespace OpenSim.Region.Environment.Scenes List avatars = m_parentGroup.GetScenePresences(); for (int i = 0; i < avatars.Count; i++) { - m_parentGroup.SendPartFullUpdate(avatars[i]._ControllingClient, this); + m_parentGroup.SendPartFullUpdate(avatars[i].ControllingClient, this); } } @@ -764,7 +764,7 @@ namespace OpenSim.Region.Environment.Scenes List avatars = m_parentGroup.GetScenePresences(); for (int i = 0; i < avatars.Count; i++) { - m_parentGroup.SendPartTerseUpdate(avatars[i]._ControllingClient, this); + m_parentGroup.SendPartTerseUpdate(avatars[i].ControllingClient, this); } } diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.Body.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.Body.cs deleted file mode 100644 index 605e8a1..0000000 --- a/OpenSim/Region/Environment/Scenes/ScenePresence.Body.cs +++ /dev/null @@ -1,82 +0,0 @@ -/* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ -using libsecondlife; -using libsecondlife.Packets; -using OpenSim.Framework.Interfaces; - -namespace OpenSim.Region.Environment.Scenes -{ - partial class ScenePresence - { - public class Avatar : IScenePresenceBody - { - public Avatar() - { - } - - public void processMovement(IClientAPI remoteClient, uint flags, LLQuaternion bodyRotation) - { - } - - public void SetAppearance(byte[] texture, AgentSetAppearancePacket.VisualParamBlock[] visualParam) - { - } - - public void SendOurAppearance(IClientAPI OurClient) - { - } - - public void SendAppearanceToOtherAgent(ScenePresence avatarInfo) - { - } - } - - public class ChildAgent : IScenePresenceBody //is a ghost - { - public ChildAgent() - { - } - - public void processMovement(IClientAPI remoteClient, uint flags, LLQuaternion bodyRotation) - { - } - - public void SetAppearance(byte[] texture, AgentSetAppearancePacket.VisualParamBlock[] visualParam) - { - } - - public void SendOurAppearance(IClientAPI OurClient) - { - } - - public void SendAppearanceToOtherAgent(ScenePresence avatarInfo) - { - } - } - } -} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs index 1a38244..23e1035 100644 --- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs @@ -35,6 +35,7 @@ using OpenSim.Framework.Interfaces; using OpenSim.Framework.Types; using OpenSim.Framework.Utilities; using OpenSim.Region.Physics.Manager; +using OpenSim.Region.Environment.Regions; namespace OpenSim.Region.Environment.Scenes { @@ -42,33 +43,34 @@ namespace OpenSim.Region.Environment.Scenes { public static AvatarAnimations Animations; public static byte[] DefaultTexture; - public LLUUID current_anim; - public int anim_seq; - private bool updateflag = false; - private byte movementflag = 0; - private List forcesList = new List(); - private short _updateCount = 0; + + public LLUUID CurrentAnimation; + public int AnimationSeq; + + private bool m_updateflag = false; + private byte m_movementflag = 0; + private readonly List m_forcesList = new List(); + private short m_updateCount = 0; private Quaternion bodyRot; private byte[] visualParams; private AvatarWearable[] Wearables; private LLObject.TextureEntry m_textureEntry; - public bool childAgent = true; public bool IsRestrictedToRegion = false; - private bool newForce = false; + private bool m_newForce = false; private bool newAvatar = false; private bool newCoarseLocations = true; protected RegionInfo m_regionInfo; protected ulong crossingFromRegion = 0; - private IScenePresenceBody m_body; - - private Vector3[] Dir_Vectors = new Vector3[6]; + private readonly Vector3[] Dir_Vectors = new Vector3[6]; private LLVector3 lastPhysPos = new LLVector3(); + private RegionPresence m_regionPresence; + private enum Dir_ControlFlags { DIR_CONTROL_FLAG_FOWARD = MainAvatar.ControlFlags.AGENT_CONTROL_AT_POS, @@ -93,8 +95,8 @@ namespace OpenSim.Region.Environment.Scenes // private Queue m_fullGroupUpdates = new Queue(); // private Queue m_terseGroupUpdates = new Queue(); - private Queue m_fullPartUpdates = new Queue(); - private Queue m_tersePartUpdates = new Queue(); + private readonly Queue m_fullPartUpdates = new Queue(); + private readonly Queue m_tersePartUpdates = new Queue(); #region Properties @@ -109,8 +111,8 @@ namespace OpenSim.Region.Environment.Scenes public bool Updated { - set { updateflag = value; } - get { return updateflag; } + set { m_updateflag = value; } + get { return m_updateflag; } } private readonly ulong m_regionHandle; @@ -134,7 +136,7 @@ namespace OpenSim.Region.Environment.Scenes private readonly IClientAPI m_controllingClient; protected PhysicsActor m_physicsActor; - public IClientAPI _ControllingClient + public IClientAPI ControllingClient { get { return m_controllingClient; } } @@ -207,6 +209,13 @@ namespace OpenSim.Region.Environment.Scenes } } + private bool m_isChildAgent = true; + public bool IsChildAgent + { + get { return m_isChildAgent; } + set { m_isChildAgent = value; } + } + #endregion #region Constructor(s) @@ -220,6 +229,8 @@ namespace OpenSim.Region.Environment.Scenes /// public ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo) { + m_regionPresence = new RegionPresence( client ); + m_scene = world; m_uuid = client.AgentId; @@ -262,7 +273,6 @@ namespace OpenSim.Region.Environment.Scenes m_textureEntry = new LLObject.TextureEntry(DefaultTexture, 0, DefaultTexture.Length); //temporary until we move some code into the body classes - m_body = new ChildAgent(); if (newAvatar) { @@ -327,9 +337,9 @@ namespace OpenSim.Region.Environment.Scenes /// public void ChildStatusChange(bool status) { - childAgent = status; + m_isChildAgent = status; - if (childAgent == true) + if (m_isChildAgent == true) { Velocity = new LLVector3(0, 0, 0); AbsolutePosition = new LLVector3(128, 128, 70); @@ -339,7 +349,7 @@ namespace OpenSim.Region.Environment.Scenes public void MakeAvatarPhysical(LLVector3 pos, bool isFlying) { newAvatar = true; - childAgent = false; + m_isChildAgent = false; AbsolutePosition = pos; @@ -353,7 +363,7 @@ namespace OpenSim.Region.Environment.Scenes protected void MakeChildAgent() { Velocity = new LLVector3(0, 0, 0); - childAgent = true; + m_isChildAgent = true; RemoveFromPhysicalScene(); @@ -416,9 +426,9 @@ namespace OpenSim.Region.Environment.Scenes look = new LLVector3(0.99f, 0.042f, 0); } m_controllingClient.MoveAgentIntoRegion(m_regionInfo, AbsolutePosition, look); - if (childAgent) + if (m_isChildAgent) { - childAgent = false; + m_isChildAgent = false; //this.m_scene.SendAllSceneObjectsToClient(this.ControllingClient); } @@ -430,7 +440,7 @@ namespace OpenSim.Region.Environment.Scenes /// public void HandleAgentUpdate(IClientAPI remoteClient, uint flags, LLQuaternion bodyRotation) { - if (childAgent) + if (m_isChildAgent) { Console.WriteLine("DEBUG: HandleAgentUpdate: child agent"); return; @@ -463,17 +473,17 @@ namespace OpenSim.Region.Environment.Scenes { DCFlagKeyPressed = true; agent_control_v3 += Dir_Vectors[i]; - if ((movementflag & (uint) DCF) == 0) + if ((m_movementflag & (uint) DCF) == 0) { - movementflag += (byte) (uint) DCF; + m_movementflag += (byte) (uint) DCF; update_movementflag = true; } } else { - if ((movementflag & (uint) DCF) != 0) + if ((m_movementflag & (uint) DCF) != 0) { - movementflag -= (byte) (uint) DCF; + m_movementflag -= (byte) (uint) DCF; update_movementflag = true; } } @@ -490,7 +500,7 @@ namespace OpenSim.Region.Environment.Scenes { if (update_movementflag) { - if (movementflag != 0) + if (m_movementflag != 0) { if (m_physicsActor.Flying) { @@ -511,7 +521,7 @@ namespace OpenSim.Region.Environment.Scenes protected void AddNewMovement(Vector3 vec, Quaternion rotation) { - if (childAgent) + if (m_isChildAgent) { Console.WriteLine("DEBUG: AddNewMovement: child agent"); return; @@ -527,7 +537,7 @@ namespace OpenSim.Region.Environment.Scenes newVelocity.X = direc.x; newVelocity.Y = direc.y; newVelocity.Z = direc.z; - forcesList.Add(newVelocity); + m_forcesList.Add(newVelocity); } #endregion @@ -554,23 +564,23 @@ namespace OpenSim.Region.Environment.Scenes newCoarseLocations = false; } - if (childAgent == false) + if (m_isChildAgent == false) { /// check for user movement 'forces' (ie commands to move) - if (newForce) + if (m_newForce) { SendTerseUpdateToAllClients(); - _updateCount = 0; + m_updateCount = 0; } /// check for scripted movement (?) - else if (movementflag != 0) + else if (m_movementflag != 0) { - _updateCount++; - if (_updateCount > 3) + m_updateCount++; + if (m_updateCount > 3) { SendTerseUpdateToAllClients(); - _updateCount = 0; + m_updateCount = 0; } } @@ -578,7 +588,7 @@ namespace OpenSim.Region.Environment.Scenes else if (lastPhysPos.GetDistanceTo(AbsolutePosition) > 0.02) { SendTerseUpdateToAllClients(); - _updateCount = 0; + m_updateCount = 0; lastPhysPos = AbsolutePosition; } CheckForSignificantMovement(); @@ -669,7 +679,7 @@ namespace OpenSim.Region.Environment.Scenes SendFullUpdateToOtherClient(avatar); if (avatar.LocalId != LocalId) { - if (!avatar.childAgent) + if (!avatar.m_isChildAgent) { avatar.SendFullUpdateToOtherClient(this); avatar.SendAppearanceToOtherAgent(this); @@ -685,7 +695,7 @@ namespace OpenSim.Region.Environment.Scenes { m_controllingClient.SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_uuid, LocalId, AbsolutePosition, m_textureEntry.ToBytes()); - if (!childAgent) + if (!m_isChildAgent) { m_scene.InformClientOfNeighbours(m_controllingClient); newAvatar = false; @@ -748,8 +758,8 @@ namespace OpenSim.Region.Environment.Scenes /// public void SendAnimPack(LLUUID animID, int seq) { - current_anim = animID; - anim_seq = seq; + CurrentAnimation = animID; + AnimationSeq = seq; m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence) { @@ -763,7 +773,7 @@ namespace OpenSim.Region.Environment.Scenes /// public void SendAnimPack() { - SendAnimPack(current_anim, anim_seq); + SendAnimPack(CurrentAnimation, AnimationSeq); } #endregion @@ -878,22 +888,22 @@ namespace OpenSim.Region.Environment.Scenes /// public override void UpdateMovement() { - newForce = false; - lock (forcesList) + m_newForce = false; + lock (m_forcesList) { - if (forcesList.Count > 0) + if (m_forcesList.Count > 0) { - for (int i = 0; i < forcesList.Count; i++) + for (int i = 0; i < m_forcesList.Count; i++) { - NewForce force = forcesList[i]; + NewForce force = m_forcesList[i]; - updateflag = true; + m_updateflag = true; Velocity = new LLVector3(force.X, force.Y, force.Z); - newForce = true; + m_newForce = true; } - for (int i = 0; i < forcesList.Count; i++) + for (int i = 0; i < m_forcesList.Count; i++) { - forcesList.RemoveAt(0); + m_forcesList.RemoveAt(0); } } } -- cgit v1.1