From 8c80d98252f376a815e522c705a3c576dfc16f75 Mon Sep 17 00:00:00 2001 From: MW Date: Sun, 4 Feb 2007 11:36:35 +0000 Subject: Clean up --- Prim_manager.cs | 236 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 118 insertions(+), 118 deletions(-) (limited to 'Prim_manager.cs') diff --git a/Prim_manager.cs b/Prim_manager.cs index 856bffe..aa1c32a 100644 --- a/Prim_manager.cs +++ b/Prim_manager.cs @@ -40,11 +40,10 @@ namespace OpenSim /// public class PrimManager { - private Server server; - public AgentManager Agent_Manager; - - private uint prim_count; + private Server _server; + private uint _primCount; + public AgentManager AgentManagement; public libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock PrimTemplate; public Dictionary PrimList; @@ -52,10 +51,10 @@ namespace OpenSim /// /// /// - public PrimManager(Server serve) + public PrimManager(Server server) { - server=serve; - PrimList=new Dictionary (); + _server = server; + PrimList = new Dictionary (); this.SetupTemplates("objectupate164.dat"); } @@ -66,58 +65,59 @@ namespace OpenSim /// /// /// - public void CreatePrim(User_Agent_info User_info, libsecondlife.LLVector3 p1, ObjectAddPacket add_pack) + public void CreatePrim(UserAgentInfo userInfo, libsecondlife.LLVector3 pos1, ObjectAddPacket addPacket) { - ObjectUpdatePacket objupdate=new ObjectUpdatePacket(); - objupdate.RegionData.RegionHandle=Globals.Instance.RegionHandle; - objupdate.RegionData.TimeDilation=64096; - objupdate.ObjectData=new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1]; - PrimData PData=new PrimData(); - objupdate.ObjectData[0]=this.PrimTemplate; - PData.OwnerID=objupdate.ObjectData[0].OwnerID=User_info.AgentID; - PData.PCode=objupdate.ObjectData[0].PCode=add_pack.ObjectData.PCode; - PData.PathBegin=objupdate.ObjectData[0].PathBegin=add_pack.ObjectData.PathBegin; - PData.PathEnd=objupdate.ObjectData[0].PathEnd=add_pack.ObjectData.PathEnd; - PData.PathScaleX=objupdate.ObjectData[0].PathScaleX=add_pack.ObjectData.PathScaleX; - PData.PathScaleY=objupdate.ObjectData[0].PathScaleY=add_pack.ObjectData.PathScaleY; - PData.PathShearX=objupdate.ObjectData[0].PathShearX=add_pack.ObjectData.PathShearX; - PData.PathShearY=objupdate.ObjectData[0].PathShearY=add_pack.ObjectData.PathShearY; - PData.PathSkew=objupdate.ObjectData[0].PathSkew=add_pack.ObjectData.PathSkew; - PData.ProfileBegin=objupdate.ObjectData[0].ProfileBegin=add_pack.ObjectData.ProfileBegin; - PData.ProfileEnd=objupdate.ObjectData[0].ProfileEnd=add_pack.ObjectData.ProfileEnd; - PData.Scale=objupdate.ObjectData[0].Scale=add_pack.ObjectData.Scale;//new LLVector3(1,1,1); - PData.PathCurve=objupdate.ObjectData[0].PathCurve=add_pack.ObjectData.PathCurve; - PData.ProfileCurve=objupdate.ObjectData[0].ProfileCurve=add_pack.ObjectData.ProfileCurve; - PData.ParentID=objupdate.ObjectData[0].ParentID=0; - PData.ProfileHollow=objupdate.ObjectData[0].ProfileHollow=add_pack.ObjectData.ProfileHollow; + ObjectUpdatePacket objupdate = new ObjectUpdatePacket(); + objupdate.RegionData.RegionHandle = Globals.Instance.RegionHandle; + objupdate.RegionData.TimeDilation = 64096; + + objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1]; + PrimData PData = new PrimData(); + objupdate.ObjectData[0] = this.PrimTemplate; + PData.OwnerID=objupdate.ObjectData[0].OwnerID = userInfo.AgentID; + PData.PCode=objupdate.ObjectData[0].PCode = addPacket.ObjectData.PCode; + PData.PathBegin=objupdate.ObjectData[0].PathBegin = addPacket.ObjectData.PathBegin; + PData.PathEnd=objupdate.ObjectData[0].PathEnd = addPacket.ObjectData.PathEnd; + PData.PathScaleX=objupdate.ObjectData[0].PathScaleX = addPacket.ObjectData.PathScaleX; + PData.PathScaleY=objupdate.ObjectData[0].PathScaleY = addPacket.ObjectData.PathScaleY; + PData.PathShearX=objupdate.ObjectData[0].PathShearX = addPacket.ObjectData.PathShearX; + PData.PathShearY=objupdate.ObjectData[0].PathShearY = addPacket.ObjectData.PathShearY; + PData.PathSkew=objupdate.ObjectData[0].PathSkew = addPacket.ObjectData.PathSkew; + PData.ProfileBegin=objupdate.ObjectData[0].ProfileBegin = addPacket.ObjectData.ProfileBegin; + PData.ProfileEnd=objupdate.ObjectData[0].ProfileEnd = addPacket.ObjectData.ProfileEnd; + PData.Scale=objupdate.ObjectData[0].Scale = addPacket.ObjectData.Scale; + PData.PathCurve=objupdate.ObjectData[0].PathCurve = addPacket.ObjectData.PathCurve; + PData.ProfileCurve=objupdate.ObjectData[0].ProfileCurve = addPacket.ObjectData.ProfileCurve; + PData.ParentID=objupdate.ObjectData[0].ParentID = 0; + PData.ProfileHollow=objupdate.ObjectData[0].ProfileHollow = addPacket.ObjectData.ProfileHollow; //finish off copying rest of shape data - objupdate.ObjectData[0].ID=(uint)(702000+prim_count); - objupdate.ObjectData[0].FullID=new LLUUID("edba7151-5857-acc5-b30b-f01efefda"+prim_count.ToString("000")); + objupdate.ObjectData[0].ID = (uint)(702000 + _primCount); + objupdate.ObjectData[0].FullID = new LLUUID("edba7151-5857-acc5-b30b-f01efefda"+_primCount.ToString("000")); //update position - byte[] pb=p1.GetBytes(); - Array.Copy(pb,0,objupdate.ObjectData[0].ObjectData,0,pb.Length); + byte[] pb = pos1.GetBytes(); + Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 0, pb.Length); - prim_count++; - server.SendPacket(objupdate,true,User_info); + _primCount++; + _server.SendPacket(objupdate, true, userInfo); //should send to all users - foreach (KeyValuePair kp in Agent_Manager.AgentList) + foreach (KeyValuePair kp in AgentManagement.AgentList) { - if(kp.Value.NetInfo.AgentID!=User_info.AgentID) + if(kp.Value.NetInfo.AgentID != userInfo.AgentID) { - server.SendPacket(objupdate,true,kp.Value.NetInfo); + _server.SendPacket(objupdate, true, kp.Value.NetInfo); } } //should store this infomation - PrimInfo NewPrim=new PrimInfo(); - NewPrim.FullID=objupdate.ObjectData[0].FullID; - NewPrim.LocalID=objupdate.ObjectData[0].ID; - NewPrim.Position=p1; - NewPrim.data=PData; + PrimInfo NewPrim = new PrimInfo(); + NewPrim.FullID = objupdate.ObjectData[0].FullID; + NewPrim.LocalID = objupdate.ObjectData[0].ID; + NewPrim.Position = pos1; + NewPrim.Data = PData; - this.PrimList.Add(NewPrim.FullID,NewPrim); + this.PrimList.Add(NewPrim.FullID, NewPrim); //store rest of data @@ -131,62 +131,62 @@ namespace OpenSim /// /// /// - public void UpdatePrimPosition(User_Agent_info User,LLVector3 position,uint LocalID,bool setRotation, LLQuaternion rotation) + public void UpdatePrimPosition(UserAgentInfo userInfo, LLVector3 position, uint localID, bool setRotation, LLQuaternion rotation) { - PrimInfo pri=null; + PrimInfo pri = null; foreach (KeyValuePair kp in this.PrimList) { - if(kp.Value.LocalID==LocalID) + if(kp.Value.LocalID == localID) { - pri=kp.Value; + pri = kp.Value; } } - if(pri==null) + if(pri == null) { return; } - uint ID=pri.LocalID; - libsecondlife.LLVector3 pos2=new LLVector3(position.X,position.Y,position.Z); + uint ID = pri.LocalID; + libsecondlife.LLVector3 pos2 = new LLVector3(position.X, position.Y, position.Z); libsecondlife.LLQuaternion rotation2; if(!setRotation) { - pri.Position=pos2; - rotation2=new LLQuaternion(pri.Rotation.X,pri.Rotation.Y,pri.Rotation.Z,pri.Rotation.W); + pri.Position = pos2; + rotation2 = new LLQuaternion(pri.Rotation.X, pri.Rotation.Y, pri.Rotation.Z, pri.Rotation.W); } else { - rotation2=new LLQuaternion(rotation.X,rotation.Y,rotation.Z,rotation.W); - pos2=pri.Position; - pri.Rotation=rotation; + rotation2=new LLQuaternion(rotation.X, rotation.Y, rotation.Z, rotation.W); + pos2 = pri.Position; + pri.Rotation = rotation; } - rotation2.W+=1; - rotation2.X+=1; - rotation2.Y+=1; - rotation2.Z+=1; + rotation2.W += 1; + rotation2.X += 1; + rotation2.Y += 1; + rotation2.Z += 1; - byte[] bytes=new byte[60]; + byte[] bytes = new byte[60]; - ImprovedTerseObjectUpdatePacket im=new ImprovedTerseObjectUpdatePacket(); - im.RegionData.RegionHandle=Globals.Instance.RegionHandle; - im.RegionData.TimeDilation=64096; - im.ObjectData=new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; - int i=0; - ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat=new ImprovedTerseObjectUpdatePacket.ObjectDataBlock(); - im.ObjectData[0]=dat; - dat.TextureEntry=PrimTemplate.TextureEntry; + ImprovedTerseObjectUpdatePacket im = new ImprovedTerseObjectUpdatePacket(); + im.RegionData.RegionHandle = Globals.Instance.RegionHandle; + im.RegionData.TimeDilation = 64096; + im.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; + int i = 0; + ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock(); + im.ObjectData[0] = dat; + dat.TextureEntry = PrimTemplate.TextureEntry; 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;//1; + bytes[i++]= 0; + bytes[i++]= 0; - byte[] pb=pos2.GetBytes(); - pri.Position=pos2; - Array.Copy(pb,0,bytes,i,pb.Length); - i+=12; - ushort ac=32767; + byte[] pb = pos2.GetBytes(); + pri.Position = pos2; + Array.Copy(pb, 0, bytes, i, pb.Length); + i += 12; + ushort ac = 32767; //vel bytes[i++] = (byte)(ac % 256); @@ -205,10 +205,10 @@ namespace OpenSim bytes[i++] = (byte)((ac >> 8) % 256); ushort rw, rx,ry,rz; - rw=(ushort)(32768*rotation2.W); - rx=(ushort)(32768*rotation2.X); - ry=(ushort)(32768*rotation2.Y); - rz=(ushort)(32768*rotation2.Z); + rw = (ushort)(32768 * rotation2.W); + rx = (ushort)(32768 * rotation2.X); + ry = (ushort)(32768 * rotation2.Y); + rz = (ushort)(32768 * rotation2.Z); //rot bytes[i++] = (byte)(rx % 256); @@ -230,11 +230,11 @@ namespace OpenSim dat.Data=bytes; - foreach (KeyValuePair kp in Agent_Manager.AgentList) + foreach (KeyValuePair kp in AgentManagement.AgentList) { - if(kp.Value.NetInfo.AgentID!=User.AgentID) + if(kp.Value.NetInfo.AgentID!=userInfo.AgentID) { - server.SendPacket(im,true,kp.Value.NetInfo); + _server.SendPacket(im, true, kp.Value.NetInfo); } } } @@ -243,7 +243,7 @@ namespace OpenSim /// /// /// - public void SendExistingPrims(User_Agent_info user) + public void SendExistingPrims(UserAgentInfo userInfo) { //send data for already created prims to a new joining user } @@ -254,12 +254,12 @@ namespace OpenSim /// public void SetupTemplates(string name) { - ObjectUpdatePacket objupdate=new ObjectUpdatePacket(); - objupdate.RegionData.RegionHandle=Globals.Instance.RegionHandle; - objupdate.RegionData.TimeDilation=64096; - objupdate.ObjectData=new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1]; + ObjectUpdatePacket objupdate = new ObjectUpdatePacket(); + objupdate.RegionData.RegionHandle = Globals.Instance.RegionHandle; + objupdate.RegionData.TimeDilation = 64096; + objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1]; - int i=0; + int i = 0; FileInfo fInfo = new FileInfo(name); long numBytes = fInfo.Length; FileStream fStream = new FileStream(name, FileMode.Open, FileAccess.Read); @@ -268,18 +268,18 @@ namespace OpenSim br.Close(); fStream.Close(); - libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock objdata=new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock(data1,ref i); - objupdate.ObjectData[0]=objdata; - this.PrimTemplate=objdata; - objdata.UpdateFlags=objdata.UpdateFlags+12-16+32+256; - objdata.OwnerID=new LLUUID("00000000-0000-0000-0000-000000000000"); + libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock objdata = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock(data1,ref i); + objupdate.ObjectData[0] = objdata; + this.PrimTemplate = objdata; + objdata.UpdateFlags = objdata.UpdateFlags + 12 - 16 + 32 + 256; + objdata.OwnerID = new LLUUID("00000000-0000-0000-0000-000000000000"); //test adding a new texture to object , to test image downloading - LLObject.TextureEntry te=new LLObject.TextureEntry(objdata.TextureEntry,0,objdata.TextureEntry.Length); - te.DefaultTexture.TextureID=new LLUUID("00000000-0000-0000-5005-000000000005"); + LLObject.TextureEntry te = new LLObject.TextureEntry(objdata.TextureEntry, 0, objdata.TextureEntry.Length); + te.DefaultTexture.TextureID = new LLUUID("00000000-0000-0000-5005-000000000005"); - LLObject.TextureEntry ntex=new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-5005-000000000005")); + LLObject.TextureEntry ntex = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-5005-000000000005")); - objdata.TextureEntry=ntex.ToBytes(); + objdata.TextureEntry = ntex.ToBytes(); } /// @@ -287,34 +287,34 @@ namespace OpenSim /// /// /// - public void ReadPrimDatabase(string name,User_Agent_info user) + public void ReadPrimDatabase(string name, UserAgentInfo userInfo) { StreamReader SR; string line; SR=File.OpenText(name); - string [] comp= new string[10]; + string [] comp = new string[10]; string delimStr = " , "; char [] delimiter = delimStr.ToCharArray(); line=SR.ReadLine(); - while(line!="end") + while(line != "end") { - comp=line.Split(delimiter); - if(comp[0]=="ObjPack") + comp = line.Split(delimiter); + if(comp[0] == "ObjPack") { - int num=Convert.ToInt32(comp[2]); - int start=Convert.ToInt32(comp[1]); - ObjectUpdatePacket objupdate=new ObjectUpdatePacket(); - objupdate.RegionData.RegionHandle=Globals.Instance.RegionHandle; - objupdate.RegionData.TimeDilation=64096; - objupdate.ObjectData=new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[num]; + int num = Convert.ToInt32(comp[2]); + int start = Convert.ToInt32(comp[1]); + ObjectUpdatePacket objupdate = new ObjectUpdatePacket(); + objupdate.RegionData.RegionHandle = Globals.Instance.RegionHandle; + objupdate.RegionData.TimeDilation = 64096; + objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[num]; // int count=0; string data_path = System.AppDomain.CurrentDomain.BaseDirectory + @"\data\"; - for(int cc=0; cc