From 488e71620866c0749a0347d878f0707de2b8eb15 Mon Sep 17 00:00:00 2001 From: MW Date: Sun, 10 Jun 2007 15:43:04 +0000 Subject: Prim creation working. --- OpenSim/OpenSim.Region/World/Avatar.cs | 10 +- OpenSim/OpenSim.Region/World/Primitive.cs | 141 +++++++++------------ OpenSim/OpenSim.Region/World/World.cs | 23 +++- .../AuthenticateSessionsLocal.cs | 38 ------ .../AuthenticateSessionsRemote.cs | 25 ---- .../ClientView.PacketHandlers.cs | 21 ++- .../ClientView.ProcessPackets.cs | 5 +- OpenSim/OpenSim.RegionServer/ClientView.cs | 2 +- .../OpenSim.RegionServer.csproj | 55 ++++---- OpenSim/OpenSim/OpenSimMain.cs | 4 +- 10 files changed, 132 insertions(+), 192 deletions(-) delete mode 100644 OpenSim/OpenSim.RegionServer/AuthenticateSessionsLocal.cs delete mode 100644 OpenSim/OpenSim.RegionServer/AuthenticateSessionsRemote.cs (limited to 'OpenSim') diff --git a/OpenSim/OpenSim.Region/World/Avatar.cs b/OpenSim/OpenSim.Region/World/Avatar.cs index 88a7969..65af5a6 100644 --- a/OpenSim/OpenSim.Region/World/Avatar.cs +++ b/OpenSim/OpenSim.Region/World/Avatar.cs @@ -66,7 +66,6 @@ namespace OpenSim.Region Wearables = AvatarWearable.DefaultWearables; this.avatarAppearanceTexture = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-5005-000000000005")); - Console.WriteLine("avatar point 4"); //register for events ControllingClient.OnRequestWearables += new GenericCall(this.SendOurAppearance); @@ -77,14 +76,7 @@ namespace OpenSim.Region ControllingClient.OnStartAnim += new StartAnim(this.SendAnimPack); ControllingClient.OnChildAgentStatus += new StatusChange(this.ChildStatusChange); ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement); - * */ - - ControllingClient.OnParcelPropertiesRequest +=new ParcelPropertiesRequest(this.m_world.parcelManager.handleParcelPropertiesRequest); - ControllingClient.OnParcelDivideRequest += new ParcelDivideRequest(this.m_world.parcelManager.handleParcelDivideRequest); - ControllingClient.OnParcelJoinRequest += new ParcelJoinRequest(this.m_world.parcelManager.handleParcelJoinRequest); - ControllingClient.OnParcelPropertiesUpdateRequest += new ParcelPropertiesUpdateRequest(this.m_world.parcelManager.handleParcelPropertiesUpdateRequest); - - ControllingClient.OnEstateOwnerMessage += new EstateOwnerMessageRequest(this.m_world.estateManager.handleEstateOwnerMessage); + */ } /// diff --git a/OpenSim/OpenSim.Region/World/Primitive.cs b/OpenSim/OpenSim.Region/World/Primitive.cs index 1f70550..d540a3b 100644 --- a/OpenSim/OpenSim.Region/World/Primitive.cs +++ b/OpenSim/OpenSim.Region/World/Primitive.cs @@ -14,12 +14,12 @@ namespace OpenSim.Region public class Primitive : Entity { protected PrimData primData; - //private ObjectUpdatePacket OurPacket; private LLVector3 positionLastFrame = new LLVector3(0, 0, 0); private Dictionary m_clientThreads; private ulong m_regionHandle; private const uint FULL_MASK_PERMISSIONS = 2147483647; private bool physicsEnabled = false; + private byte updateFlag = 0; private Dictionary inventoryItems; @@ -66,7 +66,7 @@ namespace OpenSim.Region inventoryItems = new Dictionary(); } - public Primitive(Dictionary clientThreads, ulong regionHandle, World world, LLUUID owner) + public Primitive(Dictionary clientThreads, ulong regionHandle, World world, LLUUID owner, LLUUID fullID, uint localID) { m_clientThreads = clientThreads; m_regionHandle = regionHandle; @@ -75,8 +75,34 @@ namespace OpenSim.Region this.primData = new PrimData(); this.primData.CreationDate = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; this.primData.OwnerID = owner; + this.primData.FullID = this.uuid = fullID; + this.primData.LocalID = this.localid = localID; } + /// + /// Constructor to create a default cube + /// + /// + /// + /// + /// + /// + /// + public Primitive(Dictionary clientThreads, ulong regionHandle, World world, LLUUID owner, uint localID, LLVector3 position) + { + m_clientThreads = clientThreads; + m_regionHandle = regionHandle; + m_world = world; + inventoryItems = new Dictionary(); + this.primData = PrimData.DefaultCube(); + this.primData.OwnerID = owner; + this.primData.LocalID = this.localid = localID; + this.Pos = this.primData.Position = position; + + this.updateFlag = 1; + } + + public byte[] GetByteArray() { byte[] result = null; @@ -115,7 +141,11 @@ namespace OpenSim.Region public override void update() { - LLVector3 pos2 = new LLVector3(0, 0, 0); + if (this.updateFlag == 1) + { + this.SendFullUpdateToAllClients(); + this.updateFlag = 0; + } } public override void BackUp() @@ -275,17 +305,39 @@ namespace OpenSim.Region public void SendFullUpdateToAllClients() { - + List avatars = this.m_world.RequestAvatarList(); + for (int i = 0; i < avatars.Count; i++) + { + this.SendFullUpdateToClient(avatars[i].ControllingClient); + } } public void SendTerseUpdateToClient(IClientAPI RemoteClient) { + LLVector3 lPos; + Axiom.MathLib.Quaternion lRot; + if (this._physActor != null && this.physicsEnabled) + { + PhysicsVector pPos = this._physActor.Position; + lPos = new LLVector3(pPos.X, pPos.Y, pPos.Z); + lRot = this._physActor.Orientation; + } + else + { + lPos = this.Pos; + lRot = this.rotation; + } + } public void SendTerseUpdateToALLClients() { - + List avatars = this.m_world.RequestAvatarList(); + for (int i = 0; i < avatars.Count; i++) + { + this.SendTerseUpdateToClient(avatars[i].ControllingClient); + } } #endregion @@ -324,6 +376,8 @@ namespace OpenSim.Region this.primData.FullID = this.uuid = LLUUID.Random(); this.localid = (uint)(localID); this.primData.Position = this.Pos = pos1; + + this.updateFlag = 1; } public void CreateFromBytes(byte[] data) @@ -343,82 +397,5 @@ namespace OpenSim.Region #endregion - - protected ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateImprovedBlock() - { - uint ID = this.localid; - byte[] bytes = new byte[60]; - - int i = 0; - ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock(); - dat.TextureEntry = new byte[0]; - bytes[i++] = (byte)(ID % 256); - bytes[i++] = (byte)((ID >> 8) % 256); - bytes[i++] = (byte)((ID >> 16) % 256); - bytes[i++] = (byte)((ID >> 24) % 256); - bytes[i++] = 0; - bytes[i++] = 0; - - LLVector3 lPos; - Axiom.MathLib.Quaternion lRot; - if (this._physActor != null && this.physicsEnabled) - { - PhysicsVector pPos = this._physActor.Position; - lPos = new LLVector3(pPos.X, pPos.Y, pPos.Z); - lRot = this._physActor.Orientation; - } - else - { - lPos = this.Pos; - lRot = this.rotation; - } - byte[] pb = lPos.GetBytes(); - Array.Copy(pb, 0, bytes, i, pb.Length); - i += 12; - ushort ac = 32767; - - //vel - bytes[i++] = (byte)(ac % 256); - bytes[i++] = (byte)((ac >> 8) % 256); - bytes[i++] = (byte)(ac % 256); - bytes[i++] = (byte)((ac >> 8) % 256); - bytes[i++] = (byte)(ac % 256); - bytes[i++] = (byte)((ac >> 8) % 256); - - //accel - bytes[i++] = (byte)(ac % 256); - bytes[i++] = (byte)((ac >> 8) % 256); - bytes[i++] = (byte)(ac % 256); - bytes[i++] = (byte)((ac >> 8) % 256); - bytes[i++] = (byte)(ac % 256); - bytes[i++] = (byte)((ac >> 8) % 256); - - ushort rw, rx, ry, rz; - rw = (ushort)(32768 * (lRot.w + 1)); - rx = (ushort)(32768 * (lRot.x + 1)); - ry = (ushort)(32768 * (lRot.y + 1)); - rz = (ushort)(32768 * (lRot.z + 1)); - - //rot - bytes[i++] = (byte)(rx % 256); - bytes[i++] = (byte)((rx >> 8) % 256); - bytes[i++] = (byte)(ry % 256); - bytes[i++] = (byte)((ry >> 8) % 256); - bytes[i++] = (byte)(rz % 256); - bytes[i++] = (byte)((rz >> 8) % 256); - bytes[i++] = (byte)(rw % 256); - bytes[i++] = (byte)((rw >> 8) % 256); - - //rotation vel - bytes[i++] = (byte)(ac % 256); - bytes[i++] = (byte)((ac >> 8) % 256); - bytes[i++] = (byte)(ac % 256); - bytes[i++] = (byte)((ac >> 8) % 256); - bytes[i++] = (byte)(ac % 256); - bytes[i++] = (byte)((ac >> 8) % 256); - - dat.Data = bytes; - return dat; - } } } diff --git a/OpenSim/OpenSim.Region/World/World.cs b/OpenSim/OpenSim.Region/World/World.cs index c5c554d..49ba8fa 100644 --- a/OpenSim/OpenSim.Region/World/World.cs +++ b/OpenSim/OpenSim.Region/World/World.cs @@ -450,7 +450,19 @@ namespace OpenSim.Region /// public void AddNewPrim(ObjectAddPacket addPacket, LLUUID ownerID) { - + try + { + // MainConsole.Instance.Notice("World.cs: AddNewPrim() - Creating new prim"); + Primitive prim = new Primitive(m_clientThreads, m_regionHandle, this); + prim.CreateFromPacket(addPacket, ownerID, this._primCount); + + this.Entities.Add(prim.uuid, prim); + this._primCount++; + } + catch (Exception e) + { + // MainConsole.Instance.Warn("World.cs: AddNewPrim() - Failed with exception " + e.ToString()); + } } #endregion @@ -469,6 +481,15 @@ namespace OpenSim.Region //remoteClient.OnRequestWearables += new GenericCall(this.GetInitialPrims); remoteClient.OnChatFromViewer += new ChatFromViewer(this.SimChat); remoteClient.OnRequestWearables += new GenericCall(this.InformClientOfNeighbours); + remoteClient.OnAddPrim += new GenericCall4(this.AddNewPrim); + + /* + remoteClient.OnParcelPropertiesRequest += new ParcelPropertiesRequest(parcelManager.handleParcelPropertiesRequest); + remoteClient.OnParcelDivideRequest += new ParcelDivideRequest(parcelManager.handleParcelDivideRequest); + remoteClient.OnParcelJoinRequest += new ParcelJoinRequest(parcelManager.handleParcelJoinRequest); + remoteClient.OnParcelPropertiesUpdateRequest += new ParcelPropertiesUpdateRequest(parcelManager.handleParcelPropertiesUpdateRequest); + remoteClient.OnEstateOwnerMessage += new EstateOwnerMessageRequest(estateManager.handleEstateOwnerMessage); + */ Avatar newAvatar = null; try diff --git a/OpenSim/OpenSim.RegionServer/AuthenticateSessionsLocal.cs b/OpenSim/OpenSim.RegionServer/AuthenticateSessionsLocal.cs deleted file mode 100644 index 4db7ccb..0000000 --- a/OpenSim/OpenSim.RegionServer/AuthenticateSessionsLocal.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using libsecondlife; -using OpenSim.Framework.Types; -using OpenSim.Framework; - -namespace OpenSim -{ - public class AuthenticateSessionsLocal : AuthenticateSessionsBase - { - public AuthenticateSessionsLocal() - { - - } - - public bool AddNewSessionHandler(ulong regionHandle, Login loginData) - { - AddNewSession( loginData ); - return true; - } - - public void AddNewSession(Login loginData) - { - AgentCircuitData agent = new AgentCircuitData(); - agent.AgentID = loginData.Agent; - agent.firstname = loginData.First; - agent.lastname = loginData.Last; - agent.SessionID = loginData.Session; - agent.SecureSessionID = loginData.SecureSession; - agent.circuitcode = loginData.CircuitCode; - agent.BaseFolder = loginData.BaseFolder; - agent.InventoryFolder = loginData.InventoryFolder; - agent.startpos = new LLVector3(128,128,70); - this.AddNewCircuit(agent.circuitcode, agent); - } - } -} diff --git a/OpenSim/OpenSim.RegionServer/AuthenticateSessionsRemote.cs b/OpenSim/OpenSim.RegionServer/AuthenticateSessionsRemote.cs deleted file mode 100644 index 13bce0e..0000000 --- a/OpenSim/OpenSim.RegionServer/AuthenticateSessionsRemote.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Text; -using System.Xml; -using libsecondlife; -using OpenSim.Framework.Types; -using OpenSim.Framework; -using Nwc.XmlRpc; - -namespace OpenSim -{ - public class AuthenticateSessionsRemote : AuthenticateSessionsBase - { - public AuthenticateSessionsRemote() - { - - } - - public XmlRpcResponse ExpectUser(XmlRpcRequest request) - { - return new XmlRpcResponse(); - } - } -} diff --git a/OpenSim/OpenSim.RegionServer/ClientView.PacketHandlers.cs b/OpenSim/OpenSim.RegionServer/ClientView.PacketHandlers.cs index 9fb52c6..d069f51 100644 --- a/OpenSim/OpenSim.RegionServer/ClientView.PacketHandlers.cs +++ b/OpenSim/OpenSim.RegionServer/ClientView.PacketHandlers.cs @@ -91,19 +91,28 @@ namespace OpenSim { if (multipleupdate.ObjectData[i].Type == 9) //change position { - libsecondlife.LLVector3 pos = new LLVector3(multipleupdate.ObjectData[i].Data, 0); - OnUpdatePrimPosition(multipleupdate.ObjectData[i].ObjectLocalID, pos, this); + if (OnUpdatePrimPosition != null) + { + libsecondlife.LLVector3 pos = new LLVector3(multipleupdate.ObjectData[i].Data, 0); + OnUpdatePrimPosition(multipleupdate.ObjectData[i].ObjectLocalID, pos, this); + } //should update stored position of the prim } else if (multipleupdate.ObjectData[i].Type == 10)//rotation { - libsecondlife.LLQuaternion rot = new LLQuaternion(multipleupdate.ObjectData[i].Data, 0, true); - OnUpdatePrimRotation(multipleupdate.ObjectData[i].ObjectLocalID, rot, this); + if (OnUpdatePrimRotation != null) + { + libsecondlife.LLQuaternion rot = new LLQuaternion(multipleupdate.ObjectData[i].Data, 0, true); + OnUpdatePrimRotation(multipleupdate.ObjectData[i].ObjectLocalID, rot, this); + } } else if (multipleupdate.ObjectData[i].Type == 13)//scale { - libsecondlife.LLVector3 scale = new LLVector3(multipleupdate.ObjectData[i].Data, 12); - OnUpdatePrimScale(multipleupdate.ObjectData[i].ObjectLocalID, scale, this); + if (OnUpdatePrimScale != null) + { + libsecondlife.LLVector3 scale = new LLVector3(multipleupdate.ObjectData[i].Data, 12); + OnUpdatePrimScale(multipleupdate.ObjectData[i].ObjectLocalID, scale, this); + } } } return true; diff --git a/OpenSim/OpenSim.RegionServer/ClientView.ProcessPackets.cs b/OpenSim/OpenSim.RegionServer/ClientView.ProcessPackets.cs index d36e579..00f3b66 100644 --- a/OpenSim/OpenSim.RegionServer/ClientView.ProcessPackets.cs +++ b/OpenSim/OpenSim.RegionServer/ClientView.ProcessPackets.cs @@ -488,7 +488,10 @@ namespace OpenSim #region Estate Packets case PacketType.EstateOwnerMessage: EstateOwnerMessagePacket messagePacket = (EstateOwnerMessagePacket)Pack; - OnEstateOwnerMessage(messagePacket, this); + if (OnEstateOwnerMessage != null) + { + OnEstateOwnerMessage(messagePacket, this); + } break; #endregion #region unimplemented handlers diff --git a/OpenSim/OpenSim.RegionServer/ClientView.cs b/OpenSim/OpenSim.RegionServer/ClientView.cs index f9a7fe4..809d3cf 100644 --- a/OpenSim/OpenSim.RegionServer/ClientView.cs +++ b/OpenSim/OpenSim.RegionServer/ClientView.cs @@ -69,7 +69,7 @@ namespace OpenSim private AgentAssetUpload UploadAssets; private LLUUID newAssetFolder = LLUUID.Zero; - private bool debug = false; + private bool debug = true; protected IWorld m_world; private Dictionary m_clientThreads; private AssetCache m_assetCache; diff --git a/OpenSim/OpenSim.RegionServer/OpenSim.RegionServer.csproj b/OpenSim/OpenSim.RegionServer/OpenSim.RegionServer.csproj index 990b5c3..04febf0 100644 --- a/OpenSim/OpenSim.RegionServer/OpenSim.RegionServer.csproj +++ b/OpenSim/OpenSim.RegionServer/OpenSim.RegionServer.csproj @@ -1,4 +1,4 @@ - + Local 8.0.50727 @@ -6,7 +6,8 @@ {632E1BFD-0000-0000-0000-000000000000} Debug AnyCPU - + + OpenSim.RegionServer @@ -15,9 +16,11 @@ IE50 false Library - + + OpenSim.RegionServer - + + @@ -28,7 +31,8 @@ TRACE;DEBUG - + + True 4096 False @@ -37,7 +41,8 @@ False False 4 - + + False @@ -46,7 +51,8 @@ TRACE - + + False 4096 True @@ -55,26 +61,27 @@ False False 4 - + + - + System.dll False - + System.Xml.dll False - + ..\..\bin\libsecondlife.dll False - + ..\..\bin\Axiom.MathLib.dll False - + ..\..\bin\Db4objects.Db4o.dll False @@ -84,55 +91,49 @@ OpenSim.Terrain.BasicTerrain {2270B8FE-0000-0000-0000-000000000000} {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - False + False OpenSim.Framework {8ACA2445-0000-0000-0000-000000000000} {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - False + False OpenSim.Framework.Console {A7CD0630-0000-0000-0000-000000000000} {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - False + False OpenSim.GenericConfig.Xml {E88EF749-0000-0000-0000-000000000000} {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - False + False OpenSim.Physics.Manager {8BE16150-0000-0000-0000-000000000000} {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - False + False OpenSim.Servers {8BB20F0A-0000-0000-0000-000000000000} {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - False + False XMLRPC {8E81D43C-0000-0000-0000-000000000000} {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - False + False Code - - Code - - - Code - Code @@ -192,4 +193,4 @@ - + \ No newline at end of file diff --git a/OpenSim/OpenSim/OpenSimMain.cs b/OpenSim/OpenSim/OpenSimMain.cs index e1f6281..bd07c8f 100644 --- a/OpenSim/OpenSim/OpenSimMain.cs +++ b/OpenSim/OpenSim/OpenSimMain.cs @@ -212,13 +212,13 @@ namespace OpenSim regionDat = new RegionInfo(); if (m_sandbox) { - AuthenticateSessionsLocal authen = new AuthenticateSessionsLocal(); + AuthenticateSessionsBase authen = new AuthenticateSessionsBase(); // new AuthenticateSessionsLocal(); this.AuthenticateSessionsHandler.Add(authen); authenBase = authen; } else { - AuthenticateSessionsRemote authen = new AuthenticateSessionsRemote(); + AuthenticateSessionsBase authen = new AuthenticateSessionsBase(); //new AuthenticateSessionsRemote(); this.AuthenticateSessionsHandler.Add (authen); authenBase = authen; } -- cgit v1.1