diff --git a/Common/OpenSim.Framework/Interfaces/IClientAPI.cs b/Common/OpenSim.Framework/Interfaces/IClientAPI.cs index a991fb607d..9f7b619f7e 100644 --- a/Common/OpenSim.Framework/Interfaces/IClientAPI.cs +++ b/Common/OpenSim.Framework/Interfaces/IClientAPI.cs @@ -24,6 +24,11 @@ namespace OpenSim.Framework.Interfaces event StartAnim OnStartAnim; event LinkObjects OnLinkObjects; + LLVector3 StartPos + { + get; + set; + } void SendAppearance(AvatarWearable[] wearables); void SendChatMessage(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID); } diff --git a/OpenSim/OpenSim.RegionServer/ClientView.ProcessPackets.cs b/OpenSim/OpenSim.RegionServer/ClientView.ProcessPackets.cs index a6ad8d2f85..ed3355fd69 100644 --- a/OpenSim/OpenSim.RegionServer/ClientView.ProcessPackets.cs +++ b/OpenSim/OpenSim.RegionServer/ClientView.ProcessPackets.cs @@ -30,6 +30,7 @@ namespace OpenSim public delegate void UpdatePrimTexture(uint localID, byte[] texture, ClientView remoteClient); public delegate void UpdatePrimVector(uint localID, LLVector3 pos, ClientView remoteClient); public delegate void UpdatePrimRotation(uint localID, LLQuaternion rot, ClientView remoteClient); + public delegate void StatusChange(bool status); public event ChatFromViewer OnChatFromViewer; public event RezObject OnRezObject; @@ -51,6 +52,7 @@ namespace OpenSim public event UpdatePrimVector OnUpdatePrimPosition; public event UpdatePrimRotation OnUpdatePrimRotation; public event UpdatePrimVector OnUpdatePrimScale; + public event StatusChange OnChildAgentStatus; protected override void ProcessInPacket(Packet Pack) { diff --git a/OpenSim/OpenSim.RegionServer/ClientView.cs b/OpenSim/OpenSim.RegionServer/ClientView.cs index e66b8300ef..295cd7bfec 100644 --- a/OpenSim/OpenSim.RegionServer/ClientView.cs +++ b/OpenSim/OpenSim.RegionServer/ClientView.cs @@ -86,6 +86,18 @@ namespace OpenSim } } + public LLVector3 StartPos + { + get + { + return startpos; + } + set + { + startpos = value; + } + } + public ClientView(EndPoint remoteEP, UseCircuitCodePacket initialcirpack, World world, Dictionary clientThreads, AssetCache assetCache, IGridServer gridServer, OpenSimNetworkHandler application, InventoryCache inventoryCache, bool sandboxMode, bool child, RegionInfo regionDat, AuthenticateSessionsBase authenSessions) { m_world = world; @@ -133,21 +145,23 @@ namespace OpenSim { OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "SimClient.cs:UpgradeClient() - upgrading child to full agent"); this.m_child = false; - this.m_world.RemoveViewerAgent(this); + //this.m_world.RemoveViewerAgent(this); if (!this.m_sandboxMode) { this.startpos = m_authenticateSessionsHandler.GetPosition(CircuitCode); m_authenticateSessionsHandler.UpdateAgentChildStatus(CircuitCode, false); } - this.InitNewClient(); + OnChildAgentStatus(this.m_child); + //this.InitNewClient(); } public void DowngradeClient() { OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "SimClient.cs:UpgradeClient() - changing full agent to child"); this.m_child = true; - this.m_world.RemoveViewerAgent(this); - this.m_world.AddViewerAgent(this); + OnChildAgentStatus(this.m_child); + //this.m_world.RemoveViewerAgent(this); + //this.m_world.AddViewerAgent(this); } public void KillClient() @@ -256,11 +270,7 @@ namespace OpenSim protected virtual void InitNewClient() { OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "OpenSimClient.cs:InitNewClient() - Adding viewer agent to world"); - - m_world.AddViewerAgent(this); - world.Entity tempent = m_world.Entities[this.AgentID]; - - this.ClientAvatar = (world.Avatar)tempent; + this.ClientAvatar = m_world.AddViewerAgent(this); } protected virtual void AuthUser() @@ -280,7 +290,7 @@ namespace OpenSim this.AgentID = cirpack.CircuitCode.ID; this.SessionID = cirpack.CircuitCode.SessionID; this.CircuitCode = cirpack.CircuitCode.Code; - InitNewClient(); //shouldn't be called here as we might be a child agent and not want a full avatar + InitNewClient(); this.ClientAvatar.firstname = sessionInfo.LoginInfo.First; this.ClientAvatar.lastname = sessionInfo.LoginInfo.Last; if (sessionInfo.LoginInfo.SecureSession != LLUUID.Zero) diff --git a/OpenSim/OpenSim.RegionServer/PacketServer.cs b/OpenSim/OpenSim.RegionServer/PacketServer.cs index fb35723215..9c8f65c63a 100644 --- a/OpenSim/OpenSim.RegionServer/PacketServer.cs +++ b/OpenSim/OpenSim.RegionServer/PacketServer.cs @@ -58,7 +58,6 @@ namespace OpenSim { if (this._localWorld != null) { - //ClientView.AddPacketHandler(PacketType.DeRezObject, _localWorld.DeRezObject); ClientView.AddPacketHandler(PacketType.UUIDNameRequest, this.RequestUUIDName); } } diff --git a/OpenSim/OpenSim.RegionServer/world/Avatar.Update.cs b/OpenSim/OpenSim.RegionServer/world/Avatar.Update.cs index e49fab38a5..ed1ffc07d6 100644 --- a/OpenSim/OpenSim.RegionServer/world/Avatar.Update.cs +++ b/OpenSim/OpenSim.RegionServer/world/Avatar.Update.cs @@ -10,89 +10,93 @@ namespace OpenSim.world { public override void update() { - if (this._physActor == null) + if (!this.childAvatar) { - //HACKHACK: Note to work out why this entity does not have a physics actor - // and prehaps create one. - return; - } - libsecondlife.LLVector3 pos2 = new LLVector3(this._physActor.Position.X, this._physActor.Position.Y, this._physActor.Position.Z); - if (this.updateflag) - { - //need to send movement info - //so create the improvedterseobjectupdate packet - //use CreateTerseBlock() - ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseBlock = CreateTerseBlock(); - ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket(); - terse.RegionData.RegionHandle = m_regionHandle; // FIXME - terse.RegionData.TimeDilation = 64096; - terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; - terse.ObjectData[0] = terseBlock; - List avList = this.m_world.RequestAvatarList(); - foreach (Avatar client in avList) + if (this._physActor == null) { - client.SendPacketToViewer(terse); + //HACKHACK: Note to work out why this entity does not have a physics actor + // and prehaps create one. + return; } - - updateflag = false; - //this._updateCount = 0; - } - else - { - - if ((pos2 != this.positionLastFrame) || (this.movementflag == 16)) + libsecondlife.LLVector3 pos2 = new LLVector3(this._physActor.Position.X, this._physActor.Position.Y, this._physActor.Position.Z); + if (this.updateflag) { - _updateCount++; - if (((!PhysicsEngineFlying) && (_updateCount > 3)) || (PhysicsEngineFlying) && (_updateCount > 0)) + //need to send movement info + //so create the improvedterseobjectupdate packet + //use CreateTerseBlock() + ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseBlock = CreateTerseBlock(); + ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket(); + terse.RegionData.RegionHandle = m_regionHandle; // FIXME + terse.RegionData.TimeDilation = 64096; + terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; + terse.ObjectData[0] = terseBlock; + List avList = this.m_world.RequestAvatarList(); + foreach (Avatar client in avList) { - //It has been a while since last update was sent so lets send one. - ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseBlock = CreateTerseBlock(); - ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket(); - terse.RegionData.RegionHandle = m_regionHandle; // FIXME - terse.RegionData.TimeDilation = 64096; - terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; - terse.ObjectData[0] = terseBlock; - List avList = this.m_world.RequestAvatarList(); - foreach (Avatar client in avList) + client.SendPacketToViewer(terse); + } + + updateflag = false; + //this._updateCount = 0; + } + else + { + + if ((pos2 != this.positionLastFrame) || (this.movementflag == 16)) + { + _updateCount++; + if (((!PhysicsEngineFlying) && (_updateCount > 3)) || (PhysicsEngineFlying) && (_updateCount > 0)) { - client.SendPacketToViewer(terse); + //It has been a while since last update was sent so lets send one. + ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseBlock = CreateTerseBlock(); + ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket(); + terse.RegionData.RegionHandle = m_regionHandle; // FIXME + terse.RegionData.TimeDilation = 64096; + terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; + terse.ObjectData[0] = terseBlock; + List avList = this.m_world.RequestAvatarList(); + foreach (Avatar client in avList) + { + client.SendPacketToViewer(terse); + } + _updateCount = 0; + } + + if (this.movementflag == 16) + { + movementflag = 0; } - _updateCount = 0; } - if (this.movementflag == 16) + } + this.positionLastFrame = pos2; + + if (!this.ControllingClient.m_sandboxMode) + { + if (pos2.X < 0) { - movementflag = 0; + ControllingClient.CrossSimBorder(new LLVector3(this._physActor.Position.X, this._physActor.Position.Y, this._physActor.Position.Z)); } - } - } - this.positionLastFrame = pos2; + if (pos2.Y < 0) + { + ControllingClient.CrossSimBorder(new LLVector3(this._physActor.Position.X, this._physActor.Position.Y, this._physActor.Position.Z)); + } - if (!this.ControllingClient.m_sandboxMode) - { - if (pos2.X < 0) - { - ControllingClient.CrossSimBorder(new LLVector3(this._physActor.Position.X, this._physActor.Position.Y, this._physActor.Position.Z)); - } + if (pos2.X > 255) + { + ControllingClient.CrossSimBorder(new LLVector3(this._physActor.Position.X, this._physActor.Position.Y, this._physActor.Position.Z)); + } - if (pos2.Y < 0) - { - ControllingClient.CrossSimBorder(new LLVector3(this._physActor.Position.X, this._physActor.Position.Y, this._physActor.Position.Z)); - } - - if (pos2.X > 255) - { - ControllingClient.CrossSimBorder(new LLVector3(this._physActor.Position.X, this._physActor.Position.Y, this._physActor.Position.Z)); - } - - if (pos2.Y > 255) - { - ControllingClient.CrossSimBorder(new LLVector3(this._physActor.Position.X, this._physActor.Position.Y, this._physActor.Position.Z)); + if (pos2.Y > 255) + { + ControllingClient.CrossSimBorder(new LLVector3(this._physActor.Position.X, this._physActor.Position.Y, this._physActor.Position.Z)); + } } } } + public void SendUpdateToOtherClient(Avatar remoteAvatar) { ObjectUpdatePacket objupdate = CreateUpdatePacket(); diff --git a/OpenSim/OpenSim.RegionServer/world/Avatar.cs b/OpenSim/OpenSim.RegionServer/world/Avatar.cs index 680d059c8b..2c1ccdf2ed 100644 --- a/OpenSim/OpenSim.RegionServer/world/Avatar.cs +++ b/OpenSim/OpenSim.RegionServer/world/Avatar.cs @@ -35,7 +35,7 @@ namespace OpenSim.world private string m_regionName; private ushort m_regionWaterHeight; private bool m_regionTerraform; - //private bool childShadowAvatar = false; + private bool childAvatar = false; public Avatar(ClientView TheClient, World world, string regionName, Dictionary clientThreads, ulong regionHandle, bool regionTerraform, ushort regionWater) { @@ -72,6 +72,7 @@ namespace OpenSim.world ControllingClient.OnCompleteMovementToRegion += new ClientView.GenericCall2(this.SendInitialPosition); ControllingClient.OnAgentUpdate += new ClientView.GenericCall3(this.HandleAgentUpdate); ControllingClient.OnStartAnim += new StartAnim(this.SendAnimPack); + ControllingClient.OnChildAgentStatus += new ClientView.StatusChange(this.ChildStatusChange); } @@ -87,6 +88,35 @@ namespace OpenSim.world } } + public void ChildStatusChange(bool status) + { + this.childAvatar = status; + + if (this.childAvatar == true) + { + this._physActor.Velocity = new PhysicsVector(0, 0, 0); + ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseBlock = CreateTerseBlock(); + ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket(); + terse.RegionData.RegionHandle = m_regionHandle; // FIXME + terse.RegionData.TimeDilation = 64096; + terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; + terse.ObjectData[0] = terseBlock; + List avList = this.m_world.RequestAvatarList(); + foreach (Avatar client in avList) + { + client.SendPacketToViewer(terse); + } + } + else + { + LLVector3 startp = ControllingClient.StartPos; + lock (m_world.LockPhysicsEngine) + { + this._physActor.Position = new PhysicsVector(startp.X, startp.Y, startp.Z); + } + } + } + public override void addForces() { lock (this.forcesList) diff --git a/OpenSim/OpenSim.RegionServer/world/World.cs b/OpenSim/OpenSim.RegionServer/world/World.cs index 921da3cd67..2edb8e70c8 100644 --- a/OpenSim/OpenSim.RegionServer/world/World.cs +++ b/OpenSim/OpenSim.RegionServer/world/World.cs @@ -530,7 +530,7 @@ namespace OpenSim.world #region Add/Remove Avatar Methods - public override void AddViewerAgent(ClientView agentClient) + public override Avatar AddViewerAgent(ClientView agentClient) { //register for events agentClient.OnChatFromViewer += new ChatFromViewer(this.SimChat); @@ -549,22 +549,23 @@ namespace OpenSim.world agentClient.OnUpdatePrimRotation += new ClientView.UpdatePrimRotation(this.UpdatePrimRotation); agentClient.OnUpdatePrimScale += new ClientView.UpdatePrimVector(this.UpdatePrimScale); agentClient.OnDeRezObject += new ClientView.GenericCall4(this.DeRezObject); - + Avatar newAvatar = null; try { OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "World.cs:AddViewerAgent() - Creating new avatar for remote viewer agent"); - Avatar newAvatar = new Avatar(agentClient, this, m_regionName, m_clientThreads, m_regionHandle, true, 20); + newAvatar = new Avatar(agentClient, this, m_regionName, m_clientThreads, m_regionHandle, true, 20); OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "World.cs:AddViewerAgent() - Adding new avatar to world"); OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "World.cs:AddViewerAgent() - Starting RegionHandshake "); newAvatar.SendRegionHandshake(this); - if (!agentClient.m_child) - { + //if (!agentClient.m_child) + //{ + PhysicsVector pVec = new PhysicsVector(newAvatar.Pos.X, newAvatar.Pos.Y, newAvatar.Pos.Z); lock (this.LockPhysicsEngine) { newAvatar.PhysActor = this.phyScene.AddAvatar(pVec); } - } + // } lock (Entities) { if (!Entities.ContainsKey(agentClient.AgentID)) @@ -592,6 +593,7 @@ namespace OpenSim.world { OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM, "World.cs: AddViewerAgent() - Failed with exception " + e.ToString()); } + return newAvatar; } public override void RemoveViewerAgent(ClientView agentClient) @@ -608,7 +610,7 @@ namespace OpenSim.world } if (agentClient.ClientAvatar.PhysActor != null) { - //this.phyScene.RemoveAvatar(agentClient.ClientAvatar.PhysActor); + this.phyScene.RemoveAvatar(agentClient.ClientAvatar.PhysActor); } } catch (Exception e) diff --git a/OpenSim/OpenSim.RegionServer/world/WorldBase.cs b/OpenSim/OpenSim.RegionServer/world/WorldBase.cs index edc55185db..ea71411f6b 100644 --- a/OpenSim/OpenSim.RegionServer/world/WorldBase.cs +++ b/OpenSim/OpenSim.RegionServer/world/WorldBase.cs @@ -148,9 +148,9 @@ namespace OpenSim.world /// Add a new Agent's avatar /// /// - public virtual void AddViewerAgent(ClientView agentClient) + public virtual Avatar AddViewerAgent(ClientView agentClient) { - + return null; } ///