From 64741b55a6d68eb2853ca2f33047e6a2f459b513 Mon Sep 17 00:00:00 2001 From: MW Date: Fri, 25 May 2007 19:09:19 +0000 Subject: First part of border crossing fix. --- .../ClientView.ProcessPackets.cs | 2 + OpenSim/OpenSim.RegionServer/ClientView.cs | 30 +++-- OpenSim/OpenSim.RegionServer/PacketServer.cs | 1 - .../OpenSim.RegionServer/world/Avatar.Update.cs | 130 +++++++++++---------- OpenSim/OpenSim.RegionServer/world/Avatar.cs | 32 ++++- OpenSim/OpenSim.RegionServer/world/World.cs | 16 +-- OpenSim/OpenSim.RegionServer/world/WorldBase.cs | 4 +- 7 files changed, 131 insertions(+), 84 deletions(-) (limited to 'OpenSim/OpenSim.RegionServer') diff --git a/OpenSim/OpenSim.RegionServer/ClientView.ProcessPackets.cs b/OpenSim/OpenSim.RegionServer/ClientView.ProcessPackets.cs index a6ad8d2..ed3355f 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 e66b830..295cd7b 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 fb35723..9c8f65c 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 e49fab3..ed1ffc0 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; } + 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) + { + client.SendPacketToViewer(terse); + } - updateflag = false; - //this._updateCount = 0; - } - else - { - - if ((pos2 != this.positionLastFrame) || (this.movementflag == 16)) + updateflag = false; + //this._updateCount = 0; + } + else { - _updateCount++; - if (((!PhysicsEngineFlying) && (_updateCount > 3)) || (PhysicsEngineFlying) && (_updateCount > 0)) + + if ((pos2 != this.positionLastFrame) || (this.movementflag == 16)) { - //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) + _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; } - _updateCount = 0; - } - if (this.movementflag == 16) - { - movementflag = 0; + if (this.movementflag == 16) + { + movementflag = 0; + } } - } - - } - this.positionLastFrame = pos2; - 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)); } + this.positionLastFrame = pos2; - if (pos2.Y < 0) + if (!this.ControllingClient.m_sandboxMode) { - ControllingClient.CrossSimBorder(new LLVector3(this._physActor.Position.X, this._physActor.Position.Y, this._physActor.Position.Z)); - } + 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.Y > 255) - { - 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)); + } } } } + 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 680d059..2c1ccdf 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 921da3c..2edb8e7 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 edc5518..ea71411 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; } /// -- cgit v1.1