diff --git a/Agent_Manager.cs b/Agent_Manager.cs index 769ee2a9c3..5ff40cdcf6 100644 --- a/Agent_Manager.cs +++ b/Agent_Manager.cs @@ -41,23 +41,23 @@ namespace OpenSim { public Dictionary AgentList; - private uint local_numer=0; - private Server server; + private uint _localNumber=0; + private Server _server; public PrimManager Prim_Manager; - public AssetManagement Asset_Manager; + public AssetManagement assetManager; private libsecondlife.Packets.RegionHandshakePacket RegionPacket; - private System.Text.Encoding enc = System.Text.Encoding.ASCII; - public libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock AvatarTemplate; + private System.Text.Encoding _enc = System.Text.Encoding.ASCII; + private libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock AvatarTemplate; /// /// /// /// - public AgentManager(Server serve) + public AgentManager(Server server) { - AgentList=new Dictionary(); - server=serve; + AgentList = new Dictionary(); + _server = server; this.initialise(); } @@ -74,8 +74,8 @@ namespace OpenSim } else { - AvatarData ad=this.AgentList[id]; - return ad; + AvatarData avatar = this.AgentList[id]; + return avatar; } } /// @@ -84,7 +84,7 @@ namespace OpenSim /// public void AddAgent(AvatarData agent) { - this.AgentList.Add(agent.FullID,agent); + this.AgentList.Add(agent.FullID, agent); } /// /// @@ -102,20 +102,20 @@ namespace OpenSim /// /// /// - public bool NewAgent(User_Agent_info User_info, string first, string last ,LLUUID BaseFolder,LLUUID InventoryFolder) + public bool NewAgent(UserAgentInfo userInfo, string first, string last, LLUUID baseFolder, LLUUID inventoryFolder) { - AvatarData agent=new AvatarData(); - agent.FullID=User_info.AgentID; - agent.NetInfo=User_info; - agent.NetInfo.first_name=first; - agent.NetInfo.last_name=last; - agent.Position=new LLVector3(100,100,22); - agent.BaseFolder=BaseFolder; - agent.InventoryFolder=InventoryFolder; - this.AgentList.Add(agent.FullID,agent); + AvatarData agent = new AvatarData(); + agent.FullID = userInfo.AgentID; + agent.NetInfo = userInfo; + agent.NetInfo.first_name =first; + agent.NetInfo.last_name = last; + agent.Position = new LLVector3(100, 100, 22); + agent.BaseFolder = baseFolder; + agent.InventoryFolder = inventoryFolder; + this.AgentList.Add(agent.FullID, agent); //Create new Wearable Assets and place in Inventory - this.Asset_Manager.CreateNewInventorySet(ref agent,User_info); + this.assetManager.CreateNewInventorySet(ref agent, userInfo); return(true); } @@ -124,9 +124,9 @@ namespace OpenSim /// /// /// - public void RemoveAgent(User_Agent_info UserInfo) + public void RemoveAgent(UserAgentInfo userInfo) { - this.AgentList.Remove(UserInfo.AgentID); + this.AgentList.Remove(userInfo.AgentID); //tell other clients to delete this avatar } @@ -135,20 +135,20 @@ namespace OpenSim /// /// /// - public void AgentJoin(User_Agent_info User_info) + public void AgentJoin(UserAgentInfo userInfo) { //send region data - server.SendPacket(RegionPacket,true,User_info); + _server.SendPacket(RegionPacket,true, userInfo); //inform client of join comlete - libsecondlife.Packets.AgentMovementCompletePacket mov=new AgentMovementCompletePacket(); - mov.AgentData.SessionID=User_info.SessionID; - mov.AgentData.AgentID=User_info.AgentID; - mov.Data.RegionHandle=Globals.Instance.RegionHandle; - mov.Data.Timestamp=1169838966; - mov.Data.Position=new LLVector3(100f,100f,22f); - mov.Data.LookAt=new LLVector3(0.99f,0.042f,0); - server.SendPacket(mov,true,User_info); + libsecondlife.Packets.AgentMovementCompletePacket mov = new AgentMovementCompletePacket(); + mov.AgentData.SessionID = userInfo.SessionID; + mov.AgentData.AgentID = userInfo.AgentID; + mov.Data.RegionHandle = Globals.Instance.RegionHandle; + mov.Data.Timestamp = 1169838966; + mov.Data.Position = new LLVector3(100f, 100f, 22f); + mov.Data.LookAt = new LLVector3(0.99f, 0.042f, 0); + _server.SendPacket(mov, true, userInfo); } /// @@ -157,12 +157,12 @@ namespace OpenSim public void UpdatePositions() { //update positions - foreach (KeyValuePair kp in this.AgentList) + foreach (KeyValuePair kp in this.AgentList) { - kp.Value.Position.X+=(kp.Value.Velocity.X*0.2f); - kp.Value.Position.Y+=(kp.Value.Velocity.Y*0.2f); - kp.Value.Position.Z+=(kp.Value.Velocity.Z*0.2f); + kp.Value.Position.X += (kp.Value.Velocity.X * 0.2f); + kp.Value.Position.Y += (kp.Value.Velocity.Y * 0.2f); + kp.Value.Position.Z += (kp.Value.Velocity.Z * 0.2f); } } @@ -172,31 +172,31 @@ namespace OpenSim private void initialise() { //Region data - RegionPacket=new RegionHandshakePacket(); - RegionPacket.RegionInfo.BillableFactor=0; - RegionPacket.RegionInfo.IsEstateManager=false; - RegionPacket.RegionInfo.TerrainHeightRange00=60; - RegionPacket.RegionInfo.TerrainHeightRange01=60; - RegionPacket.RegionInfo.TerrainHeightRange10=60; - RegionPacket.RegionInfo.TerrainHeightRange11=60; - RegionPacket.RegionInfo.TerrainStartHeight00=20; - RegionPacket.RegionInfo.TerrainStartHeight01=20; - RegionPacket.RegionInfo.TerrainStartHeight10=20; - RegionPacket.RegionInfo.TerrainStartHeight11=20; - RegionPacket.RegionInfo.SimAccess=13; - RegionPacket.RegionInfo.WaterHeight=5; - RegionPacket.RegionInfo.RegionFlags=72458694; - RegionPacket.RegionInfo.SimName=enc.GetBytes( Globals.Instance.RegionName); - RegionPacket.RegionInfo.SimOwner=new LLUUID("00000000-0000-0000-0000-000000000000"); - RegionPacket.RegionInfo.TerrainBase0=new LLUUID("b8d3965a-ad78-bf43-699b-bff8eca6c975"); - RegionPacket.RegionInfo.TerrainBase1=new LLUUID("abb783e6-3e93-26c0-248a-247666855da3"); - RegionPacket.RegionInfo.TerrainBase2=new LLUUID("179cdabd-398a-9b6b-1391-4dc333ba321f"); - RegionPacket.RegionInfo.TerrainBase3=new LLUUID("beb169c7-11ea-fff2-efe5-0f24dc881df2"); - RegionPacket.RegionInfo.TerrainDetail0=new LLUUID("00000000-0000-0000-0000-000000000000"); - RegionPacket.RegionInfo.TerrainDetail1=new LLUUID("00000000-0000-0000-0000-000000000000"); - RegionPacket.RegionInfo.TerrainDetail2=new LLUUID("00000000-0000-0000-0000-000000000000"); - RegionPacket.RegionInfo.TerrainDetail3=new LLUUID("00000000-0000-0000-0000-000000000000"); - RegionPacket.RegionInfo.CacheID=new LLUUID("545ec0a5-5751-1026-8a0b-216e38a7ab37"); + RegionPacket = new RegionHandshakePacket(); + RegionPacket.RegionInfo.BillableFactor = 0; + RegionPacket.RegionInfo.IsEstateManager = false; + RegionPacket.RegionInfo.TerrainHeightRange00 = 60; + RegionPacket.RegionInfo.TerrainHeightRange01 = 60; + RegionPacket.RegionInfo.TerrainHeightRange10 = 60; + RegionPacket.RegionInfo.TerrainHeightRange11 = 60; + RegionPacket.RegionInfo.TerrainStartHeight00 = 20; + RegionPacket.RegionInfo.TerrainStartHeight01 = 20; + RegionPacket.RegionInfo.TerrainStartHeight10 = 20; + RegionPacket.RegionInfo.TerrainStartHeight11 = 20; + RegionPacket.RegionInfo.SimAccess = 13; + RegionPacket.RegionInfo.WaterHeight = 5; + RegionPacket.RegionInfo.RegionFlags = 72458694; + RegionPacket.RegionInfo.SimName = _enc.GetBytes( Globals.Instance.RegionName); + RegionPacket.RegionInfo.SimOwner = new LLUUID("00000000-0000-0000-0000-000000000000"); + RegionPacket.RegionInfo.TerrainBase0 = new LLUUID("b8d3965a-ad78-bf43-699b-bff8eca6c975"); + RegionPacket.RegionInfo.TerrainBase1 = new LLUUID("abb783e6-3e93-26c0-248a-247666855da3"); + RegionPacket.RegionInfo.TerrainBase2 = new LLUUID("179cdabd-398a-9b6b-1391-4dc333ba321f"); + RegionPacket.RegionInfo.TerrainBase3 = new LLUUID("beb169c7-11ea-fff2-efe5-0f24dc881df2"); + RegionPacket.RegionInfo.TerrainDetail0 = new LLUUID("00000000-0000-0000-0000-000000000000"); + RegionPacket.RegionInfo.TerrainDetail1 = new LLUUID("00000000-0000-0000-0000-000000000000"); + RegionPacket.RegionInfo.TerrainDetail2 = new LLUUID("00000000-0000-0000-0000-000000000000"); + RegionPacket.RegionInfo.TerrainDetail3 = new LLUUID("00000000-0000-0000-0000-000000000000"); + RegionPacket.RegionInfo.CacheID = new LLUUID("545ec0a5-5751-1026-8a0b-216e38a7ab37"); this.SetupTemplate("objectupate168.dat"); } @@ -208,7 +208,7 @@ namespace OpenSim private void SetupTemplate(string name) { - int i=0; + int i = 0; FileInfo fInfo = new FileInfo(name); long numBytes = fInfo.Length; FileStream fStream = new FileStream(name, FileMode.Open, FileAccess.Read); @@ -217,19 +217,19 @@ namespace OpenSim br.Close(); fStream.Close(); - libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock objdata=new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock(data1,ref i); + libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock objdata = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock(data1, ref i); System.Text.Encoding enc = System.Text.Encoding.ASCII; - libsecondlife.LLVector3 pos=new LLVector3(objdata.ObjectData, 16); - pos.X=100f; - objdata.ID=8880000; - objdata.NameValue=enc.GetBytes("FirstName STRING RW SV Test \nLastName STRING RW SV User \0"); - libsecondlife.LLVector3 pos2=new LLVector3(13.981f,100.0f,20.0f); + libsecondlife.LLVector3 pos = new LLVector3(objdata.ObjectData, 16); + pos.X = 100f; + objdata.ID = 8880000; + objdata.NameValue = enc.GetBytes("FirstName STRING RW SV Test \nLastName STRING RW SV User \0"); + libsecondlife.LLVector3 pos2 = new LLVector3(13.981f,100.0f,20.0f); //objdata.FullID=user.AgentID; - byte[] pb=pos.GetBytes(); - Array.Copy(pb,0,objdata.ObjectData,16,pb.Length); + byte[] pb = pos.GetBytes(); + Array.Copy(pb, 0, objdata.ObjectData, 16, pb.Length); - AvatarTemplate=objdata; + AvatarTemplate = objdata; } @@ -237,52 +237,52 @@ namespace OpenSim /// /// /// - public void SendInitialData(User_Agent_info User_info) + public void SendInitialData(UserAgentInfo userInfo) { //shouldn't have to read all this in from disk for every new client - string data_path=System.AppDomain.CurrentDomain.BaseDirectory + @"\layer_data\"; + string data_path = System.AppDomain.CurrentDomain.BaseDirectory + @"\layer_data\"; //send layerdata - LayerDataPacket layerpack=new LayerDataPacket(); - layerpack.LayerID.Type=76; - this.SendLayerData(User_info,ref layerpack,data_path+@"layerdata0.dat"); + LayerDataPacket layerpack = new LayerDataPacket(); + layerpack.LayerID.Type = 76; + this.SendLayerData(userInfo,ref layerpack, data_path+@"layerdata0.dat"); - LayerDataPacket layerpack1=new LayerDataPacket(); - layerpack1.LayerID.Type=76; - this.SendLayerData(User_info,ref layerpack,data_path+@"layerdata1.dat"); + LayerDataPacket layerpack1 = new LayerDataPacket(); + layerpack1.LayerID.Type = 76; + this.SendLayerData(userInfo, ref layerpack, data_path+@"layerdata1.dat"); - LayerDataPacket layerpack2=new LayerDataPacket(); - layerpack2.LayerID.Type=56; - this.SendLayerData(User_info,ref layerpack,data_path+@"layerdata2.dat"); + LayerDataPacket layerpack2 = new LayerDataPacket(); + layerpack2.LayerID.Type = 56; + this.SendLayerData(userInfo, ref layerpack, data_path+@"layerdata2.dat"); - LayerDataPacket layerpack3=new LayerDataPacket(); - layerpack3.LayerID.Type=55; - this.SendLayerData(User_info,ref layerpack,data_path+@"layerdata3.dat"); + LayerDataPacket layerpack3 = new LayerDataPacket(); + layerpack3.LayerID.Type = 55; + this.SendLayerData(userInfo, ref layerpack, data_path+@"layerdata3.dat"); - LayerDataPacket layerpack4=new LayerDataPacket(); - layerpack4.LayerID.Type=56; - this.SendLayerData(User_info,ref layerpack,data_path+@"layerdata4.dat"); + LayerDataPacket layerpack4 = new LayerDataPacket(); + layerpack4.LayerID.Type = 56; + this.SendLayerData(userInfo, ref layerpack, data_path+@"layerdata4.dat"); - LayerDataPacket layerpack5=new LayerDataPacket(); - layerpack5.LayerID.Type=55; - this.SendLayerData(User_info,ref layerpack,data_path+@"layerdata5.dat"); + LayerDataPacket layerpack5 = new LayerDataPacket(); + layerpack5.LayerID.Type = 55; + this.SendLayerData(userInfo, ref layerpack, data_path+@"layerdata5.dat"); //send intial set of captured prims data? - this.Prim_Manager.ReadPrimDatabase( "objectdatabase.ini",User_info); + this.Prim_Manager.ReadPrimDatabase( "objectdatabase.ini", userInfo); //send prims that have been created by users //prim_man.send_existing_prims(User_info); //send update about clients avatar - this.SendInitialAvatarPosition(User_info); + this.SendInitialAvatarPosition(userInfo); //send updates about all other users - foreach (KeyValuePair kp in this.AgentList) + foreach (KeyValuePair kp in this.AgentList) { - if(kp.Value.NetInfo.AgentID!=User_info.AgentID) + if(kp.Value.NetInfo.AgentID != userInfo.AgentID) { - this.SendOtherAvatarPosition(User_info,kp.Value); + this.SendOtherAvatarPosition(userInfo, kp.Value); } } } @@ -291,41 +291,40 @@ namespace OpenSim /// /// /// - public void SendInitialAvatarPosition(User_Agent_info User_info) + public void SendInitialAvatarPosition(UserAgentInfo userInfo) { //send a objectupdate packet with information about the clients avatar - 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]; - objupdate.ObjectData[0]=AvatarTemplate; + objupdate.ObjectData[0] = AvatarTemplate; //give this avatar object a local id and assign the user a name - objupdate.ObjectData[0].ID=8880000+this.local_numer; - User_info.localID=objupdate.ObjectData[0].ID; + objupdate.ObjectData[0].ID = 8880000 + this._localNumber; + userInfo.localID = objupdate.ObjectData[0].ID; //User_info.name="Test"+this.local_numer+" User"; - this.GetAgent(User_info.AgentID).Started=true; - objupdate.ObjectData[0].FullID=User_info.AgentID; - objupdate.ObjectData[0].NameValue=enc.GetBytes("FirstName STRING RW SV "+User_info.first_name+"\nLastName STRING RW SV "+User_info.last_name+" \0"); - User_info.name="FirstName STRING RW SV "+User_info.first_name+"\nLastName STRING RW SV "+User_info.last_name+" \0"; - //User_info.last_name="User"; - //User_info.first_name="Test"+this.local_numer; - libsecondlife.LLVector3 pos2=new LLVector3(100f,100.0f,22.0f); + this.GetAgent(userInfo.AgentID).Started = true; + objupdate.ObjectData[0].FullID = userInfo.AgentID; + objupdate.ObjectData[0].NameValue = _enc.GetBytes("FirstName STRING RW SV " + userInfo.first_name + "\nLastName STRING RW SV " + userInfo.last_name + " \0"); + userInfo.name = "FirstName STRING RW SV " + userInfo.first_name + "\nLastName STRING RW SV " + userInfo.last_name + " \0"; - byte[] pb=pos2.GetBytes(); + libsecondlife.LLVector3 pos2 = new LLVector3(100f, 100.0f, 22.0f); + + byte[] pb = pos2.GetBytes(); - Array.Copy(pb,0,objupdate.ObjectData[0].ObjectData,16,pb.Length); - this.local_numer++; + Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 16, pb.Length); + this._localNumber++; - server.SendPacket(objupdate,true,User_info); + _server.SendPacket(objupdate, true, userInfo); //send this info to other existing clients - foreach (KeyValuePair kp in this.AgentList) + foreach (KeyValuePair kp in this.AgentList) { - if(kp.Value.NetInfo.AgentID!=User_info.AgentID) + if(kp.Value.NetInfo.AgentID != userInfo.AgentID) { - server.SendPacket(objupdate,true,kp.Value.NetInfo); - this.SendOtherAppearance(kp.Value.NetInfo,objupdate.ObjectData[0].FullID); + _server.SendPacket(objupdate, true, kp.Value.NetInfo); + this.SendOtherAppearance(kp.Value.NetInfo, objupdate.ObjectData[0].FullID); } } @@ -335,38 +334,38 @@ namespace OpenSim /// /// /// - public void SendIntialAvatarAppearance(User_Agent_info user) + public void SendIntialAvatarAppearance(UserAgentInfo userInfo) { - AvatarData Agent=this.AgentList[user.AgentID]; - AgentWearablesUpdatePacket aw=new AgentWearablesUpdatePacket(); - aw.AgentData.AgentID=user.AgentID; - aw.AgentData.SerialNum=0; - aw.AgentData.SessionID=user.SessionID; + AvatarData Agent = this.AgentList[userInfo.AgentID]; + AgentWearablesUpdatePacket aw = new AgentWearablesUpdatePacket(); + aw.AgentData.AgentID = userInfo.AgentID; + aw.AgentData.SerialNum = 0; + aw.AgentData.SessionID = userInfo.SessionID; - aw.WearableData= new AgentWearablesUpdatePacket.WearableDataBlock[13]; - AgentWearablesUpdatePacket.WearableDataBlock awb=null; - awb=new AgentWearablesUpdatePacket.WearableDataBlock(); - awb.WearableType=(byte)0; - awb.AssetID=Agent.Wearables[0].AssetID;//new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73"); - awb.ItemID=Agent.Wearables[0].ItemID;//new LLUUID("b7878441893b094917f791174bc8401c"); - aw.WearableData[0]=awb; + aw.WearableData = new AgentWearablesUpdatePacket.WearableDataBlock[13]; + AgentWearablesUpdatePacket.WearableDataBlock awb = null; + awb = new AgentWearablesUpdatePacket.WearableDataBlock(); + awb.WearableType = (byte)0; + awb.AssetID = Agent.Wearables[0].AssetID; + awb.ItemID = Agent.Wearables[0].ItemID; + aw.WearableData[0] = awb; - awb=new AgentWearablesUpdatePacket.WearableDataBlock(); - awb.WearableType=(byte)1; - awb.AssetID=Agent.Wearables[1].AssetID;//new LLUUID("e0ee49b5a4184df8d3c9a65361fe7f49"); - awb.ItemID=Agent.Wearables[1].ItemID;//new LLUUID("193f0876fc11d143797454352f9c9c26"); - aw.WearableData[1]=awb; + awb = new AgentWearablesUpdatePacket.WearableDataBlock(); + awb.WearableType =(byte)1; + awb.AssetID = Agent.Wearables[1].AssetID; + awb.ItemID = Agent.Wearables[1].ItemID; + aw.WearableData[1] = awb; for(int i=2; i<13; i++) { - awb=new AgentWearablesUpdatePacket.WearableDataBlock(); - awb.WearableType=(byte)i; - awb.AssetID=new LLUUID("00000000-0000-0000-0000-000000000000"); - awb.ItemID=new LLUUID("00000000-0000-0000-0000-000000000000"); - aw.WearableData[i]=awb; + awb = new AgentWearablesUpdatePacket.WearableDataBlock(); + awb.WearableType = (byte)i; + awb.AssetID = new LLUUID("00000000-0000-0000-0000-000000000000"); + awb.ItemID = new LLUUID("00000000-0000-0000-0000-000000000000"); + aw.WearableData[i] = awb; } - server.SendPacket(aw,true,user); + _server.SendPacket(aw, true, userInfo); } /// @@ -374,34 +373,33 @@ namespace OpenSim /// /// /// - public void SendOtherAppearance(User_Agent_info user,LLUUID id) + public void SendOtherAppearance(UserAgentInfo userInfo, LLUUID id) { - AvatarAppearancePacket avp=new AvatarAppearancePacket(); + AvatarAppearancePacket avp = new AvatarAppearancePacket(); - avp.VisualParam=new AvatarAppearancePacket.VisualParamBlock[218]; + avp.VisualParam = new AvatarAppearancePacket.VisualParamBlock[218]; //avp.ObjectData.TextureEntry=this.avatar_template.TextureEntry;// br.ReadBytes((int)numBytes); FileInfo fInfo = new FileInfo("Avatar_texture3.dat"); - long numBytes = fInfo.Length; FileStream fStream = new FileStream("Avatar_texture3.dat", FileMode.Open, FileAccess.Read); BinaryReader br = new BinaryReader(fStream); - avp.ObjectData.TextureEntry= br.ReadBytes((int)numBytes); + avp.ObjectData.TextureEntry = br.ReadBytes((int)numBytes); br.Close(); fStream.Close(); - AvatarAppearancePacket.VisualParamBlock avblock=null; - for(int i=0; i<218; i++) + AvatarAppearancePacket.VisualParamBlock avblock = null; + for(int i = 0; i < 218; i++) { - avblock=new AvatarAppearancePacket.VisualParamBlock(); - avblock.ParamValue=(byte)100; - avp.VisualParam[i]=avblock; + avblock = new AvatarAppearancePacket.VisualParamBlock(); + avblock.ParamValue = (byte)100; + avp.VisualParam[i] = avblock; } - avp.Sender.IsTrial=false; - avp.Sender.ID=id; - server.SendPacket(avp,true,user); + avp.Sender.IsTrial = false; + avp.Sender.ID = id; + _server.SendPacket(avp, true, userInfo); } @@ -410,29 +408,27 @@ namespace OpenSim /// /// /// - public void SendOtherAvatarPosition(User_Agent_info User_info, AvatarData avd) + public void SendOtherAvatarPosition(UserAgentInfo userInfo, AvatarData avatar) { //send a objectupdate packet with information about the clients avatar - ObjectUpdatePacket objupdate=new ObjectUpdatePacket(); - objupdate.RegionData.RegionHandle=Globals.Instance.RegionHandle; - objupdate.RegionData.TimeDilation=64500; - objupdate.ObjectData=new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1]; + ObjectUpdatePacket objupdate = new ObjectUpdatePacket(); + objupdate.RegionData.RegionHandle = Globals.Instance.RegionHandle; + objupdate.RegionData.TimeDilation = 64500; + objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1]; - objupdate.ObjectData[0]=AvatarTemplate; + objupdate.ObjectData[0] = AvatarTemplate; //give this avatar object a local id and assign the user a name - objupdate.ObjectData[0].ID=avd.NetInfo.localID; - objupdate.ObjectData[0].FullID=avd.NetInfo.AgentID;//new LLUUID("00000000-0000-0000-5665-000000000034"); - objupdate.ObjectData[0].NameValue=enc.GetBytes(avd.NetInfo.name);//enc.GetBytes("FirstName STRING RW SV Test"+ this.local_numer+"\nLastName STRING RW SV User \0"); - libsecondlife.LLVector3 pos2=new LLVector3(avd.Position.X,avd.Position.Y,avd.Position.Z); + objupdate.ObjectData[0].ID = avatar.NetInfo.localID; + objupdate.ObjectData[0].FullID = avatar.NetInfo.AgentID; + objupdate.ObjectData[0].NameValue = _enc.GetBytes(avatar.NetInfo.name); + libsecondlife.LLVector3 pos2 = new LLVector3(avatar.Position.X, avatar.Position.Y, avatar.Position.Z); - byte[] pb=pos2.GetBytes(); - - Array.Copy(pb,0,objupdate.ObjectData[0].ObjectData,16,pb.Length); - this.local_numer++; + byte[] pb = pos2.GetBytes(); + Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 16, pb.Length); + this._localNumber++; - server.SendPacket(objupdate,true,User_info); - - this.SendOtherAppearance(User_info,avd.NetInfo.AgentID);//new LLUUID("00000000-0000-0000-5665-000000000034")); + _server.SendPacket(objupdate, true, userInfo); + this.SendOtherAppearance(userInfo, avatar.NetInfo.AgentID); } @@ -441,26 +437,26 @@ namespace OpenSim /// /// /// - public void SendChatMessage(User_Agent_info User_info, string line) + public void SendChatMessage(UserAgentInfo userInfo, string line) { - libsecondlife.Packets.ChatFromSimulatorPacket reply=new ChatFromSimulatorPacket(); - reply.ChatData.Audible=1; - reply.ChatData.Message=enc.GetBytes(line); - reply.ChatData.ChatType=1; - reply.ChatData.SourceType=1; - reply.ChatData.Position=new LLVector3(120,100,21); //should set to actual position - reply.ChatData.FromName=enc.GetBytes(User_info.first_name +" "+User_info.last_name +"\0"); //enc.GetBytes("Echo: \0"); //and actual name - reply.ChatData.OwnerID=User_info.AgentID; - reply.ChatData.SourceID=User_info.AgentID; + libsecondlife.Packets.ChatFromSimulatorPacket reply = new ChatFromSimulatorPacket(); + reply.ChatData.Audible = 1; + reply.ChatData.Message = _enc.GetBytes(line); + reply.ChatData.ChatType = 1; + reply.ChatData.SourceType = 1; + reply.ChatData.Position = new LLVector3(120, 100, 21); //should set to actual position + reply.ChatData.FromName = _enc.GetBytes(userInfo.first_name + " " + userInfo.last_name + "\0"); + reply.ChatData.OwnerID = userInfo.AgentID; + reply.ChatData.SourceID = userInfo.AgentID; //echo to sender - server.SendPacket(reply,true,User_info); + _server.SendPacket(reply, true, userInfo); //send to all users - foreach (KeyValuePair kp in this.AgentList) + foreach (KeyValuePair kp in this.AgentList) { - if(kp.Value.NetInfo.AgentID!=User_info.AgentID) + if(kp.Value.NetInfo.AgentID!=userInfo.AgentID) { - server.SendPacket(reply,true,kp.Value.NetInfo); + _server.SendPacket(reply, true, kp.Value.NetInfo); } } } @@ -475,54 +471,54 @@ namespace OpenSim /// /// /// - public void SendMoveCommand(User_Agent_info user, bool stop,float x, float y, float z, uint av_id, libsecondlife.LLQuaternion body) + public void SendMoveCommand(UserAgentInfo userInfo, bool stop, float x, float y, float z, uint avatarID, libsecondlife.LLQuaternion body) { - uint ID=user.localID; - //ID=av_id; - 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]; + Console.WriteLine("sending move"); + uint ID = userInfo.localID; + byte[] bytes = new byte[60]; int i=0; - ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat=new ImprovedTerseObjectUpdatePacket.ObjectDataBlock(); - im.ObjectData[0]=dat; + ImprovedTerseObjectUpdatePacket im = new ImprovedTerseObjectUpdatePacket(); + im.RegionData.RegionHandle = Globals.Instance.RegionHandle;; + im.RegionData.TimeDilation = 64096; - dat.TextureEntry=AvatarTemplate.TextureEntry; - libsecondlife.LLVector3 pos2=new LLVector3(x,y,z); + im.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; + ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock(); + + im.ObjectData[0] = dat; + + dat.TextureEntry = AvatarTemplate.TextureEntry; + libsecondlife.LLVector3 pos2 = new LLVector3(x, y, z); 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++]=1; + bytes[i++] = 0; + bytes[i++] = 1; - i+=14; - bytes[i++]=128; - bytes[i++]=63; - byte[] pb=pos2.GetBytes(); + i += 14; + bytes[i++] = 128; + bytes[i++] = 63; + byte[] pb = pos2.GetBytes(); - Array.Copy(pb,0,bytes,i,pb.Length); - i+=12; - ushort ac=32767; - Axiom.MathLib.Vector3 v3=new Axiom.MathLib.Vector3(1,0,0); - Axiom.MathLib.Quaternion q=new Axiom.MathLib.Quaternion(body.W,body.X,body.Y,body.Z); - Axiom.MathLib.Vector3 direc=q*v3; + Array.Copy(pb, 0, bytes, i, pb.Length); + i += 12; + ushort ac = 32767; + Axiom.MathLib.Vector3 v3 = new Axiom.MathLib.Vector3(1, 0, 0); + Axiom.MathLib.Quaternion q = new Axiom.MathLib.Quaternion(body.W, body.X, body.Y, body.Z); + Axiom.MathLib.Vector3 direc = q * v3; direc.Normalize(); - direc=direc*(0.03f); - direc.x+=1; - direc.y+=1; - direc.z+=1; - ushort dx,dy,dz; - dx=(ushort)(32768*direc.x); - dy=(ushort)(32768*direc.y); - dz=(ushort)(32768*direc.z); + direc = direc * (0.03f); + direc.x += 1; + direc.y += 1; + direc.z += 1; + ushort dx, dy, dz; + dx = (ushort)(32768 * direc.x); + dy = (ushort)(32768 * direc.y); + dz = (ushort)(32768 * direc.z); //vel if(!stop) @@ -582,14 +578,14 @@ namespace OpenSim dat.Data=bytes; - server.SendPacket(im,true,user); + _server.SendPacket(im, true, userInfo); //should send to all users. - foreach (KeyValuePair kp in this.AgentList) + foreach (KeyValuePair kp in this.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); } } } @@ -600,36 +596,30 @@ namespace OpenSim /// /// /// - public void SendLayerData(User_Agent_info User_info,ref LayerDataPacket lay,string name) + public void SendLayerData(UserAgentInfo userInfo, ref LayerDataPacket layer, string name) { FileInfo fInfo = new FileInfo(name); - long numBytes = fInfo.Length; - FileStream fStream = new FileStream(name, FileMode.Open, FileAccess.Read); - BinaryReader br = new BinaryReader(fStream); - byte [] data1 = br.ReadBytes((int)numBytes); - br.Close(); - fStream.Close(); - lay.LayerData.Data=data1; - server.SendPacket(lay,true,User_info); - //System.Console.WriteLine("sent"); + layer.LayerData.Data = data1; + _server.SendPacket(layer, true, userInfo); + } } public class AvatarData { - public User_Agent_info NetInfo; + public UserAgentInfo NetInfo; public LLUUID FullID; public LLVector3 Position; - public LLVector3 Velocity=new LLVector3(0,0,0); + public LLVector3 Velocity = new LLVector3(0,0,0); //public LLQuaternion Rotation; - public bool Walk=false; - public bool Started=false; + public bool Walk = false; + public bool Started = false; //public TextureEntry TextureEntry; public AvatarWearable[] Wearables; public LLUUID InventoryFolder; @@ -638,9 +628,9 @@ namespace OpenSim public AvatarData() { Wearables=new AvatarWearable[2]; //should be 13 - for(int i=0; i<2; i++) + for(int i = 0; i < 2; i++) { - Wearables[i]=new AvatarWearable(); + Wearables[i] = new AvatarWearable(); } } } diff --git a/AssetManagement.cs b/AssetManagement.cs index a43a969d1c..07b2b57fa4 100644 --- a/AssetManagement.cs +++ b/AssetManagement.cs @@ -44,22 +44,23 @@ namespace OpenSim public Dictionary Assets; public Dictionary Textures; - public ArrayList AssetRequests=new ArrayList(); //should change to a generic - public ArrayList TextureRequests=new ArrayList(); - // public ArrayList uploads=new ArrayList(); - private Server server; - public InventoryManager InventoryManager; - private System.Text.Encoding enc = System.Text.Encoding.ASCII; + public ArrayList AssetRequests = new ArrayList(); //should change to a generic + public ArrayList TextureRequests = new ArrayList(); + //public ArrayList uploads=new ArrayList(); + private Server _server; + private InventoryManager _inventoryManager; + private System.Text.Encoding _enc = System.Text.Encoding.ASCII; /// /// /// - /// - public AssetManagement(Server server) + /// + public AssetManagement(Server server, InventoryManager inventoryManager) { - this.server=server; - Textures=new Dictionary (); - Assets=new Dictionary (); + this._server = server; + this._inventoryManager = inventoryManager; + Textures = new Dictionary (); + Assets = new Dictionary (); this.initialise(); } @@ -69,38 +70,38 @@ namespace OpenSim private void initialise() { //Shape and skin base assets - AssetInfo Asset=new AssetInfo(); - Asset.filename="base_shape.dat"; - Asset.Full_ID=new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73"); + AssetInfo Asset = new AssetInfo(); + Asset.filename = "base_shape.dat"; + Asset.FullID = new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73"); this.LoadAsset(Asset, false); - this.Assets.Add(Asset.Full_ID, Asset); + this.Assets.Add(Asset.FullID, Asset); - Asset=new AssetInfo(); - Asset.filename="base_skin.dat"; - Asset.Full_ID=new LLUUID("e0ee49b5a4184df8d3c9a65361fe7f49"); + Asset = new AssetInfo(); + Asset.filename = "base_skin.dat"; + Asset.FullID = new LLUUID("e0ee49b5a4184df8d3c9a65361fe7f49"); this.LoadAsset(Asset, false); - this.Assets.Add(Asset.Full_ID, Asset); + this.Assets.Add(Asset.FullID, Asset); //our test images //Change these filenames to images you want to use. - TextureImage Image=new TextureImage(); - Image.filename="testpic2.jp2"; - Image.Full_ID=new LLUUID("00000000-0000-0000-5005-000000000005"); - Image.Name="test Texture"; + TextureImage Image = new TextureImage(); + Image.filename = "testpic2.jp2"; + Image.FullID = new LLUUID("00000000-0000-0000-5005-000000000005"); + Image.Name = "test Texture"; this.LoadAsset(Image, true); - this.Textures.Add(Image.Full_ID, Image); + this.Textures.Add(Image.FullID, Image); - Image=new TextureImage(); - Image.filename="map_base.jp2"; - Image.Full_ID=new LLUUID("00000000-0000-0000-7007-000000000006"); + Image = new TextureImage(); + Image.filename = "map_base.jp2"; + Image.FullID = new LLUUID("00000000-0000-0000-7007-000000000006"); this.LoadAsset(Image, true); - this.Textures.Add(Image.Full_ID, Image); + this.Textures.Add(Image.FullID, Image); - Image=new TextureImage(); - Image.filename="map1.jp2"; - Image.Full_ID=new LLUUID("00000000-0000-0000-7009-000000000008"); + Image = new TextureImage(); + Image.filename = "map1.jp2"; + Image.FullID = new LLUUID("00000000-0000-0000-7009-000000000008"); this.LoadAsset(Image, true); - this.Textures.Add(Image.Full_ID, Image); + this.Textures.Add(Image.FullID, Image); } /// @@ -111,101 +112,101 @@ namespace OpenSim /// #region AssetRegion - public void AddAssetRequest(User_Agent_info UserInfo, LLUUID AssetID, TransferRequestPacket TransferRequest) + public void AddAssetRequest(UserAgentInfo userInfo, LLUUID assetID, TransferRequestPacket transferRequest) { - if(!this.Assets.ContainsKey(AssetID)) + if(!this.Assets.ContainsKey(assetID)) { //not found asset return; } - AssetInfo info=this.Assets[AssetID]; + AssetInfo info = this.Assets[assetID]; //for now as it will be only skin or shape request just send back the asset - TransferInfoPacket Transfer=new TransferInfoPacket(); - Transfer.TransferInfo.ChannelType=2; - Transfer.TransferInfo.Status=0; - Transfer.TransferInfo.TargetType=0; - Transfer.TransferInfo.Params=TransferRequest.TransferInfo.Params; - Transfer.TransferInfo.Size=info.data.Length; - Transfer.TransferInfo.TransferID=TransferRequest.TransferInfo.TransferID; + TransferInfoPacket Transfer = new TransferInfoPacket(); + Transfer.TransferInfo.ChannelType = 2; + Transfer.TransferInfo.Status = 0; + Transfer.TransferInfo.TargetType = 0; + Transfer.TransferInfo.Params = transferRequest.TransferInfo.Params; + Transfer.TransferInfo.Size = info.data.Length; + Transfer.TransferInfo.TransferID = transferRequest.TransferInfo.TransferID; - server.SendPacket(Transfer, true, UserInfo); + _server.SendPacket(Transfer, true, userInfo); - TransferPacketPacket TransferPacket=new TransferPacketPacket(); - TransferPacket.TransferData.Packet=0; - TransferPacket.TransferData.ChannelType=2; - TransferPacket.TransferData.TransferID=TransferRequest.TransferInfo.TransferID; + TransferPacketPacket TransferPacket = new TransferPacketPacket(); + TransferPacket.TransferData.Packet = 0; + TransferPacket.TransferData.ChannelType = 2; + TransferPacket.TransferData.TransferID=transferRequest.TransferInfo.TransferID; if(info.data.Length>1000) //but needs to be less than 2000 at the moment { - byte[] chunk=new byte[1000]; + byte[] chunk = new byte[1000]; Array.Copy(info.data,chunk,1000); - TransferPacket.TransferData.Data=chunk; - TransferPacket.TransferData.Status=0; - server.SendPacket(TransferPacket,true,UserInfo); + TransferPacket.TransferData.Data = chunk; + TransferPacket.TransferData.Status = 0; + _server.SendPacket(TransferPacket,true,userInfo); - TransferPacket=new TransferPacketPacket(); - TransferPacket.TransferData.Packet=1; - TransferPacket.TransferData.ChannelType=2; - TransferPacket.TransferData.TransferID=TransferRequest.TransferInfo.TransferID; - byte[] chunk1=new byte[(info.data.Length-1000)]; + TransferPacket = new TransferPacketPacket(); + TransferPacket.TransferData.Packet = 1; + TransferPacket.TransferData.ChannelType = 2; + TransferPacket.TransferData.TransferID = transferRequest.TransferInfo.TransferID; + byte[] chunk1 = new byte[(info.data.Length-1000)]; Array.Copy(info.data, 1000, chunk1, 0, chunk1.Length); - TransferPacket.TransferData.Data=chunk1; - TransferPacket.TransferData.Status=1; - server.SendPacket(TransferPacket, true, UserInfo); + TransferPacket.TransferData.Data = chunk1; + TransferPacket.TransferData.Status = 1; + _server.SendPacket(TransferPacket, true, userInfo); } else { - TransferPacket.TransferData.Status=1; //last packet? so set to 1 - TransferPacket.TransferData.Data=info.data; - server.SendPacket(TransferPacket, true, UserInfo); + TransferPacket.TransferData.Status = 1; //last packet? so set to 1 + TransferPacket.TransferData.Data = info.data; + _server.SendPacket(TransferPacket, true, userInfo); } } - public void CreateNewInventorySet(ref AvatarData Avata,User_Agent_info UserInfo) + public void CreateNewInventorySet(ref AvatarData Avata,UserAgentInfo UserInfo) { //Create Folders - LLUUID BaseFolder=Avata.BaseFolder; - InventoryManager.CreateNewFolder(UserInfo, Avata.InventoryFolder); - InventoryManager.CreateNewFolder(UserInfo, BaseFolder); + LLUUID BaseFolder = Avata.BaseFolder; + _inventoryManager.CreateNewFolder(UserInfo, Avata.InventoryFolder); + _inventoryManager.CreateNewFolder(UserInfo, BaseFolder); //Give a copy of default shape - AssetInfo Base=this.Assets[new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73")]; - AssetInfo Shape=this.CloneAsset(UserInfo.AgentID, Base); + AssetInfo Base = this.Assets[new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73")]; + AssetInfo Shape = this.CloneAsset(UserInfo.AgentID, Base); - Shape.filename=""; - Shape.Name="Default Shape"; - Shape.Description="Default Shape"; - Shape.InvType=18; - Shape.Type=libsecondlife.AssetSystem.Asset.ASSET_TYPE_WEARABLE_BODY; + Shape.filename = ""; + Shape.Name = "Default Shape"; + Shape.Description = "Default Shape"; + Shape.InvType = 18; + Shape.Type = libsecondlife.AssetSystem.Asset.ASSET_TYPE_WEARABLE_BODY; - byte[] Agentid=enc.GetBytes(UserInfo.AgentID.ToStringHyphenated()); + byte[] Agentid = _enc.GetBytes(UserInfo.AgentID.ToStringHyphenated()); Array.Copy(Agentid, 0, Shape.data, 294, Agentid.Length); - this.Assets.Add(Shape.Full_ID, Shape); + this.Assets.Add(Shape.FullID, Shape); - Avata.Wearables[0].ItemID=InventoryManager.AddToInventory(UserInfo, BaseFolder, Shape); - Avata.Wearables[0].AssetID=Shape.Full_ID; + Avata.Wearables[0].ItemID = _inventoryManager.AddToInventory(UserInfo, BaseFolder, Shape); + Avata.Wearables[0].AssetID = Shape.FullID; //Give copy of default skin - Base=this.Assets[new LLUUID("e0ee49b5a4184df8d3c9a65361fe7f49")]; + Base = this.Assets[new LLUUID("e0ee49b5a4184df8d3c9a65361fe7f49")]; AssetInfo Skin=this.CloneAsset(UserInfo.AgentID, Base); - Skin.filename=""; - Skin.Name="Default Skin"; - Skin.Description="Default Skin"; - Skin.InvType=18; - Skin.Type=libsecondlife.AssetSystem.Asset.ASSET_TYPE_WEARABLE_BODY; + Skin.filename = ""; + Skin.Name = "Default Skin"; + Skin.Description = "Default Skin"; + Skin.InvType = 18; + Skin.Type = libsecondlife.AssetSystem.Asset.ASSET_TYPE_WEARABLE_BODY; Array.Copy(Agentid,0,Skin.data,238,Agentid.Length); - this.Assets.Add(Skin.Full_ID, Skin); + this.Assets.Add(Skin.FullID, Skin); - Avata.Wearables[1].ItemID=InventoryManager.AddToInventory(UserInfo, BaseFolder, Skin); - Avata.Wearables[1].AssetID=Skin.Full_ID; + Avata.Wearables[1].ItemID = _inventoryManager.AddToInventory(UserInfo, BaseFolder, Skin); + Avata.Wearables[1].AssetID = Skin.FullID; //give a copy of test texture - TextureImage Texture=this.CloneImage(UserInfo.AgentID,Textures[new LLUUID("00000000-0000-0000-5005-000000000005")]); - this.Textures.Add(Texture.Full_ID, Texture); - InventoryManager.AddToInventory(UserInfo, BaseFolder, Texture); + TextureImage Texture = this.CloneImage(UserInfo.AgentID, Textures[new LLUUID("00000000-0000-0000-5005-000000000005")]); + this.Textures.Add(Texture.FullID, Texture); + _inventoryManager.AddToInventory(UserInfo, BaseFolder, Texture); } @@ -217,116 +218,116 @@ namespace OpenSim string folder; if(Image) { - folder=@"\textures\"; + folder = @"\textures\"; } else { - folder=@"\assets\"; + folder = @"\assets\"; } string data_path = System.AppDomain.CurrentDomain.BaseDirectory + folder; - string filename=data_path+@info.filename; + string filename = data_path+@info.filename; FileInfo fInfo = new FileInfo(filename); long numBytes = fInfo.Length; FileStream fStream = new FileStream(filename, FileMode.Open, FileAccess.Read); - byte[] idata=new byte[numBytes]; + byte[] idata = new byte[numBytes]; BinaryReader br = new BinaryReader(fStream); idata= br.ReadBytes((int)numBytes); br.Close(); fStream.Close(); - info.data=idata; + info.data = idata; //info.loaded=true; } public AssetInfo CloneAsset(LLUUID NewOwner, AssetInfo SourceAsset) { - AssetInfo NewAsset=new AssetInfo(); - NewAsset.data=new byte[SourceAsset.data.Length]; - Array.Copy(SourceAsset.data,NewAsset.data,SourceAsset.data.Length); - NewAsset.Full_ID=LLUUID.Random(); - NewAsset.Type=SourceAsset.Type; - NewAsset.InvType=SourceAsset.InvType; + AssetInfo NewAsset = new AssetInfo(); + NewAsset.data = new byte[SourceAsset.data.Length]; + Array.Copy(SourceAsset.data, NewAsset.data, SourceAsset.data.Length); + NewAsset.FullID = LLUUID.Random(); + NewAsset.Type = SourceAsset.Type; + NewAsset.InvType = SourceAsset.InvType; return(NewAsset); } #endregion #region TextureRegion - public void AddTextureRequest(User_Agent_info user, LLUUID image_id) + public void AddTextureRequest(UserAgentInfo userInfo, LLUUID imageID) { - if(!this.Textures.ContainsKey(image_id)) + if(!this.Textures.ContainsKey(imageID)) { //not found image so send back image not in data base message - ImageNotInDatabasePacket im_not=new ImageNotInDatabasePacket(); - im_not.ImageID.ID=image_id; - server.SendPacket(im_not, true, user); + ImageNotInDatabasePacket im_not = new ImageNotInDatabasePacket(); + im_not.ImageID.ID=imageID; + _server.SendPacket(im_not, true, userInfo); return; } - TextureImage imag=this.Textures[image_id]; - TextureRequest req=new TextureRequest(); - req.RequestUser=user; - req.RequestImage=image_id; - req.image_info=imag; + TextureImage imag = this.Textures[imageID]; + TextureRequest req = new TextureRequest(); + req.RequestUser = userInfo; + req.RequestImage = imageID; + req.image_info = imag; if(imag.data.LongLength>1000) //should be bigger or smaller? { //over 1000 bytes so split up file - req.num_packets=(int)imag.data.LongLength/1000; + req.num_packets = (int)imag.data.LongLength/1000; req.num_packets++; } else { - req.num_packets=1; + req.num_packets = 1; } this.TextureRequests.Add(req); } - public void AddTexture(LLUUID image_id, string name, byte[] data) + public void AddTexture(LLUUID imageID, string name, byte[] data) { } public void DoWork(ulong time) { - if(this.TextureRequests.Count==0) + if(this.TextureRequests.Count == 0) { //no requests waiting return; } int num; //should be running in its own thread but for now is called by timer - if(this.TextureRequests.Count<5) + if(this.TextureRequests.Count < 5) { //lower than 5 so do all of them - num=this.TextureRequests.Count; + num = this.TextureRequests.Count; } else { num=5; } TextureRequest req; - for(int i=0; i /// Description of MainForm. /// - public partial class Controller : ServerCallback { - - + public partial class Controller : ServerCallback + { [STAThread] - public static void Main( string[] args ) { + public static void Main( string[] args ) + { Controller c = new Controller(); while( true ) // fuckin' a - System.Threading.Thread.Sleep( 1000 ); - + System.Threading.Thread.Sleep( 1000 ); } - public Server server; - public Logon _login; - private AgentManager Agent_Manager; - private PrimManager Prim_Manager; - private AssetManagement Asset_Manager; - private GridManager Grid_Manager; - private InventoryManager Inventory_Manager; - private LoginManager Login_Manager; //built in login server + + private Server _server; + private Logon _login; + private AgentManager _agentManager; + private PrimManager _primManager; + private AssetManagement _assetManager; + private GridManager _gridManager; + private InventoryManager _inventoryManager; + private LoginManager _loginManager; //built in login server private ulong time; //ticks private Timer timer1 = new Timer(); public Controller() { - _login=new Logon(); // should create a list for these. - server = new Server( this ); - Agent_Manager = new AgentManager( this.server ); - Prim_Manager = new PrimManager( this.server ); - Asset_Manager = new AssetManagement( this.server ); - Prim_Manager.Agent_Manager = Agent_Manager; - Agent_Manager.Prim_Manager = Prim_Manager; - Agent_Manager.Asset_Manager=Asset_Manager; - Inventory_Manager=new InventoryManager(this.server); - Asset_Manager.InventoryManager=Inventory_Manager; - Grid_Manager=new GridManager(this.server,Agent_Manager); + _login = new Logon(); // should create a list for these. + _server = new Server( this ); + _agentManager = new AgentManager( this._server ); + _primManager = new PrimManager( this._server ); + _inventoryManager = new InventoryManager(this._server); + _assetManager = new AssetManagement(this._server, _inventoryManager ); + _primManager.AgentManagement = _agentManager; + _agentManager.Prim_Manager = _primManager; + _agentManager.assetManager = _assetManager; + _gridManager = new GridManager(this._server, _agentManager); if(Globals.Instance.LoginSever) { Console.WriteLine("Starting login Server"); - Login_Manager = new LoginManager(_login); // startup - Login_Manager.Startup(); // login server + _loginManager = new LoginManager(_login); // startup + _loginManager.Startup(); // login server } timer1.Enabled = true; @@ -92,169 +91,162 @@ namespace OpenSim } - public void MainCallback( Packet pack, User_Agent_info User_info ) { + public void MainCallback( Packet pack, UserAgentInfo userInfo ) + { /*if( ( pack.Type != PacketType.StartPingCheck ) && ( pack.Type != PacketType.AgentUpdate ) ) { //Log packet? - // System.Console.WriteLine(pack.Type); - //this.richTextBox1.Text=this.richTextBox1.Text+"\n "+pack.Type; + //System.Console.WriteLine(pack.Type); + //this.richTextBox1.Text = this.richTextBox1.Text + "\n " + pack.Type; }*/ //should replace with a switch if( pack.Type == PacketType.AgentSetAppearance ) { - //System.Console.WriteLine(pack); - //this.richTextBox1.Text=this.richTextBox1.Text+"\n "+pack.Type; - + } else if( pack.Type == PacketType.FetchInventory) { - FetchInventoryPacket FetchInventory=(FetchInventoryPacket)pack; - Inventory_Manager.FetchInventory(User_info,FetchInventory); + FetchInventoryPacket FetchInventory = (FetchInventoryPacket)pack; + _inventoryManager.FetchInventory(userInfo, FetchInventory); } else if( pack.Type == PacketType.FetchInventoryDescendents) { - FetchInventoryDescendentsPacket Fetch=(FetchInventoryDescendentsPacket)pack; - Inventory_Manager.FetchInventoryDescendents(User_info,Fetch); + FetchInventoryDescendentsPacket Fetch = (FetchInventoryDescendentsPacket)pack; + _inventoryManager.FetchInventoryDescendents(userInfo, Fetch); } - else if(pack.Type== PacketType.MapBlockRequest) + else if(pack.Type == PacketType.MapBlockRequest) { - //int MinX, MinY, MaxX, MaxY; MapBlockRequestPacket MapRequest=(MapBlockRequestPacket)pack; - this.Grid_Manager.RequestMapBlock(User_info,MapRequest.PositionData.MinX,MapRequest.PositionData.MinY,MapRequest.PositionData.MaxX,MapRequest.PositionData.MaxY); + this._gridManager.RequestMapBlock(userInfo, MapRequest.PositionData.MinX, MapRequest.PositionData.MinY, MapRequest.PositionData.MaxX, MapRequest.PositionData.MaxY); } - else if(pack.Type== PacketType.CloseCircuit) + else if(pack.Type == PacketType.CloseCircuit) { - this.Agent_Manager.RemoveAgent(User_info); + this._agentManager.RemoveAgent(userInfo); } - else if(pack.Type== PacketType.MapLayerRequest) + else if(pack.Type == PacketType.MapLayerRequest) { - this.Grid_Manager.RequestMapLayer(User_info); - + this._gridManager.RequestMapLayer(userInfo); } - else if((pack.Type== PacketType.TeleportRequest ) ||(pack.Type== PacketType.TeleportLocationRequest)) + else if((pack.Type == PacketType.TeleportRequest ) || (pack.Type == PacketType.TeleportLocationRequest)) { - TeleportLocationRequestPacket Request=(TeleportLocationRequestPacket)pack; - - this.Grid_Manager.RequestTeleport(User_info,Request); + TeleportLocationRequestPacket Request = (TeleportLocationRequestPacket)pack; + this._gridManager.RequestTeleport(userInfo,Request); } else if( pack.Type == PacketType.TransferRequest ) { - TransferRequestPacket tran = (TransferRequestPacket)pack; - LLUUID id = new LLUUID( tran.TransferInfo.Params, 0 ); - Asset_Manager.AddAssetRequest( User_info, id, tran ); - + TransferRequestPacket transfer = (TransferRequestPacket)pack; + LLUUID id = new LLUUID( transfer.TransferInfo.Params, 0 ); + _assetManager.AddAssetRequest( userInfo, id, transfer ); } else if( ( pack.Type == PacketType.StartPingCheck ) ) { //reply to pingcheck - libsecondlife.Packets.StartPingCheckPacket startp = (libsecondlife.Packets.StartPingCheckPacket)pack; + libsecondlife.Packets.StartPingCheckPacket startping = (libsecondlife.Packets.StartPingCheckPacket)pack; libsecondlife.Packets.CompletePingCheckPacket endping = new CompletePingCheckPacket(); - endping.PingID.PingID = startp.PingID.PingID; - server.SendPacket( endping, true, User_info ); + endping.PingID.PingID = startping.PingID.PingID; + _server.SendPacket(endping, true, userInfo ); } else if( pack.Type == PacketType.CompleteAgentMovement ) - { - // new client - Agent_Manager.AgentJoin( User_info ); + { + _agentManager.AgentJoin(userInfo ); } else if( pack.Type == PacketType.RequestImage ) { - RequestImagePacket image_req = (RequestImagePacket)pack; - for( int i = 0; i < image_req.RequestImage.Length; i++ ) + RequestImagePacket imageRequest = (RequestImagePacket)pack; + for( int i = 0; i < imageRequest.RequestImage.Length; i++ ) { - this.Asset_Manager.AddTextureRequest( User_info, image_req.RequestImage[ i ].Image ); + this._assetManager.AddTextureRequest(userInfo, imageRequest.RequestImage[i].Image); } } else if( pack.Type == PacketType.RegionHandshakeReply ) { //recieved regionhandshake so can now start sending info - Agent_Manager.SendInitialData( User_info ); - //this.setuptemplates("objectupate164.dat",User_info,false); - } + _agentManager.SendInitialData(userInfo ); + } else if( pack.Type == PacketType.ObjectAdd ) { ObjectAddPacket ad = (ObjectAddPacket)pack; - Prim_Manager.CreatePrim( User_info, ad.ObjectData.RayEnd, ad ); - //this.send_prim(User_info,ad.ObjectData.RayEnd, ad); + _primManager.CreatePrim(userInfo, ad.ObjectData.RayEnd, ad ); } else if( pack.Type == PacketType.ObjectPosition ) { //System.Console.WriteLine(pack.ToString()); } - else if( pack.Type == PacketType.MultipleObjectUpdate ) { - //System.Console.WriteLine(pack.ToString()); - MultipleObjectUpdatePacket mupd = (MultipleObjectUpdatePacket)pack; + else if( pack.Type == PacketType.MultipleObjectUpdate ) + { + MultipleObjectUpdatePacket multipleupdate = (MultipleObjectUpdatePacket)pack; - for( int i = 0; i < mupd.ObjectData.Length; i++ ) + for( int i = 0; i < multipleupdate.ObjectData.Length; i++ ) { - if( mupd.ObjectData[ i ].Type == 9 ) //change position + if( multipleupdate.ObjectData[ i ].Type == 9 ) //change position { - libsecondlife.LLVector3 pos = new LLVector3( mupd.ObjectData[ i ].Data, 0 ); - // libsecondlife.LLQuaternion rot=new LLQuaternion(mupd.ObjectData[i].Data,12,true); - Prim_Manager.UpdatePrimPosition( User_info, pos, mupd.ObjectData[ i ].ObjectLocalID ,false ,libsecondlife.LLQuaternion.Identity); + libsecondlife.LLVector3 pos = new LLVector3(multipleupdate.ObjectData[ i ].Data, 0 ); + _primManager.UpdatePrimPosition(userInfo, pos, multipleupdate.ObjectData[ i ].ObjectLocalID ,false ,libsecondlife.LLQuaternion.Identity); //should update stored position of the prim } - else if( mupd.ObjectData[ i ].Type == 10 ) + else if(multipleupdate.ObjectData[i].Type == 10 )//rotation { - //System.Console.WriteLine(mupd.ObjectData[ i ].Type); - //System.Console.WriteLine(mupd); libsecondlife.LLVector3 pos = new LLVector3(100,100,22); - libsecondlife.LLQuaternion rot=new LLQuaternion(mupd.ObjectData[i].Data,0,true); - Prim_Manager.UpdatePrimPosition( User_info, pos, mupd.ObjectData[ i ].ObjectLocalID ,true ,rot); - + libsecondlife.LLQuaternion rot = new LLQuaternion(multipleupdate.ObjectData[i].Data, 0, true); + _primManager.UpdatePrimPosition(userInfo, pos, multipleupdate.ObjectData[ i ].ObjectLocalID, true ,rot); } } } else if( pack.Type == PacketType.AgentWearablesRequest ) { - Agent_Manager.SendIntialAvatarAppearance( User_info ); + _agentManager.SendIntialAvatarAppearance(userInfo ); } - else if( pack.Type == PacketType.AgentUpdate ) + else if(pack.Type == PacketType.AgentUpdate) { - AgentUpdatePacket ag = (AgentUpdatePacket)pack; - uint mask = ag.AgentData.ControlFlags & ( 1 ); - AvatarData m_av = Agent_Manager.GetAgent( User_info.AgentID ); - if( m_av != null ) - { - if( m_av.Started ) + // System.Console.WriteLine("agent update"); + AgentUpdatePacket agent = (AgentUpdatePacket)pack; + uint mask = agent.AgentData.ControlFlags & ( 1 ); + AvatarData avatar = _agentManager.GetAgent(userInfo.AgentID ); + if(avatar != null ) + { + if(avatar.Started ) { - if( mask == ( 1 ) ) + if( mask == ( 1 ) ) { - if( !m_av.Walk ) + if(!avatar.Walk) { //start walking - Agent_Manager.SendMoveCommand( User_info, false, m_av.Position.X, m_av.Position.Y, m_av.Position.Z, 0, ag.AgentData.BodyRotation ); + _agentManager.SendMoveCommand(userInfo, false, avatar.Position.X, avatar.Position.Y, avatar.Position.Z, 0, agent.AgentData.BodyRotation ); Axiom.MathLib.Vector3 v3 = new Axiom.MathLib.Vector3( 1, 0, 0 ); - Axiom.MathLib.Quaternion q = new Axiom.MathLib.Quaternion( ag.AgentData.BodyRotation.W, ag.AgentData.BodyRotation.X, ag.AgentData.BodyRotation.Y, ag.AgentData.BodyRotation.Z ); + Axiom.MathLib.Quaternion q = new Axiom.MathLib.Quaternion( agent.AgentData.BodyRotation.W, agent.AgentData.BodyRotation.X, agent.AgentData.BodyRotation.Y, agent.AgentData.BodyRotation.Z ); Axiom.MathLib.Vector3 direc = q * v3; direc.Normalize(); direc = direc * ( ( 0.03f ) * 128f ); - m_av.Velocity.X = direc.x; - m_av.Velocity.Y = direc.y; - m_av.Velocity.Z = direc.z; - m_av.Walk = true; + avatar.Velocity.X = direc.x; + avatar.Velocity.Y = direc.y; + avatar.Velocity.Z = direc.z; + avatar.Walk = true; } } else { - if( m_av.Walk ) + if(avatar.Walk) { //walking but key not pressed so need to stop - Agent_Manager.SendMoveCommand( User_info, true, m_av.Position.X, m_av.Position.Y, m_av.Position.Z, 0, ag.AgentData.BodyRotation ); - m_av.Walk = false; - m_av.Velocity.X = 0; - m_av.Velocity.Y = 0; - m_av.Velocity.Z = 0; + _agentManager.SendMoveCommand(userInfo, true, avatar.Position.X, avatar.Position.Y, avatar.Position.Z, 0, agent.AgentData.BodyRotation ); + avatar.Walk = false; + avatar.Velocity.X = 0; + avatar.Velocity.Y = 0; + avatar.Velocity.Z = 0; } } } } + else + { + + } } else if( pack.Type == PacketType.ChatFromViewer ) { ChatFromViewerPacket chat = (ChatFromViewerPacket)pack; System.Text.Encoding enc = System.Text.Encoding.ASCII; - string myString = enc.GetString( chat.ChatData.Message ); + string myString = enc.GetString(chat.ChatData.Message ); if( myString != "" ) { string[] comp = new string[ 10 ]; string delimStr = " , "; @@ -271,34 +263,32 @@ namespace OpenSim } else { - Agent_Manager.SendChatMessage( User_info, line ); - + _agentManager.SendChatMessage(userInfo, line ); } } } } - public void NewUserCallback( User_Agent_info UserInfo ) + public void NewUserCallback(UserAgentInfo userInfo ) { - Console.WriteLine( "new user - {0} - has joined [session {1}]", UserInfo.AgentID.ToString(), UserInfo.SessionID.ToString() +"curcuit used"+UserInfo.circuitCode); + Console.WriteLine( "new user - {0} - has joined [session {1}]", userInfo.AgentID.ToString(), userInfo.SessionID.ToString() +"curcuit used"+userInfo.circuitCode); string first,last; LLUUID Base,Inventory; lock(_login) { - first=_login.first; - last=_login.last; + first=_login.First; + last=_login.Last; Base=_login.BaseFolder; - Inventory=_login.InventoryFolder; - + Inventory=_login.InventoryFolder; //should get agentid and sessionid so they can be checked. } - Agent_Manager.NewAgent( UserInfo ,first,last,Base,Inventory); + _agentManager.NewAgent(userInfo, first, last, Base, Inventory); //now because of the lack of Global account management (User server etc) //we need to reset the names back to default incase a teleport happens //which will not have a Login name set, so they will use default names lock(_login) { - _login.first="Test"; - _login.last="User"; + _login.First="Test"; + _login.Last="User"; } } @@ -308,14 +298,14 @@ namespace OpenSim void Timer1Tick( object sender, System.EventArgs e ) { this.time++; - Agent_Manager.UpdatePositions(); - this.Asset_Manager.DoWork( time ); + _agentManager.UpdatePositions(); + this._assetManager.DoWork( time ); } } public class Logon { - public string first="Test"; - public string last="User"; + public string First = "Test"; + public string Last = "User"; public LLUUID Agent; public LLUUID Session; public LLUUID InventoryFolder; diff --git a/Globals.cs b/Globals.cs index 44dae8244b..066a76d419 100644 --- a/Globals.cs +++ b/Globals.cs @@ -38,8 +38,10 @@ namespace OpenSim { private static Globals instance = new Globals(); - public static Globals Instance { - get { + public static Globals Instance + { + get + { return instance; } } @@ -48,17 +50,13 @@ namespace OpenSim { } - public string RegionName="Test Sandbox\0"; - public ulong RegionHandle= 1096213093147648; - public int IpPort=1000; + public string RegionName = "Test Sandbox\0"; + public ulong RegionHandle = 1096213093147648; + public int IpPort = 1000; - public bool LoginSever=true; - public ushort LoginServerPort=8080; + public bool LoginSever = true; + public ushort LoginServerPort = 8080; - //public string RegionName= "The Other\0"; - //public ulong RegionHandle= 1095113581519872; - //public int IpPort=1020; - //public bool LoginSever=false; } } diff --git a/GridManager.cs b/GridManager.cs index c6b7c49a2a..c52bd51d51 100644 --- a/GridManager.cs +++ b/GridManager.cs @@ -44,21 +44,21 @@ namespace OpenSim /// public class GridManager { - private Server server; - private System.Text.Encoding enc = System.Text.Encoding.ASCII; - private AgentManager AgentManager; - private Dictionary Grid; + private Server _server; + private System.Text.Encoding _enc = System.Text.Encoding.ASCII; + private AgentManager _agentManager; + public Dictionary Grid; /// /// /// /// /// - public GridManager(Server serve, AgentManager agentManager) + public GridManager(Server server, AgentManager agentManager) { - Grid=new Dictionary(); - server=serve; - AgentManager=agentManager; + Grid = new Dictionary(); + _server = server; + _agentManager = agentManager; LoadGrid(); } @@ -66,20 +66,20 @@ namespace OpenSim /// /// /// - public void RequestMapLayer(User_Agent_info UserInfo) + public void RequestMapLayer(UserAgentInfo userInfo) { //send a layer covering the 800,800 - 1200,1200 area - MapLayerReplyPacket MapReply=new MapLayerReplyPacket(); - MapReply.AgentData.AgentID=UserInfo.AgentID; - MapReply.AgentData.Flags=0; - MapReply.LayerData=new MapLayerReplyPacket.LayerDataBlock[1]; - MapReply.LayerData[0]=new MapLayerReplyPacket.LayerDataBlock(); - MapReply.LayerData[0].Bottom=800; - MapReply.LayerData[0].Left=800; - MapReply.LayerData[0].Top=1200; - MapReply.LayerData[0].Right=1200; - MapReply.LayerData[0].ImageID=new LLUUID("00000000-0000-0000-7007-000000000006"); - server.SendPacket(MapReply,true,UserInfo); + MapLayerReplyPacket MapReply = new MapLayerReplyPacket(); + MapReply.AgentData.AgentID = userInfo.AgentID; + MapReply.AgentData.Flags = 0; + MapReply.LayerData = new MapLayerReplyPacket.LayerDataBlock[1]; + MapReply.LayerData[0] = new MapLayerReplyPacket.LayerDataBlock(); + MapReply.LayerData[0].Bottom = 800; + MapReply.LayerData[0].Left = 800; + MapReply.LayerData[0].Top = 1200; + MapReply.LayerData[0].Right = 1200; + MapReply.LayerData[0].ImageID = new LLUUID("00000000-0000-0000-7007-000000000006"); + _server.SendPacket(MapReply, true, userInfo); } /// @@ -90,28 +90,28 @@ namespace OpenSim /// /// /// - public void RequestMapBlock(User_Agent_info UserInfo, int MinX, int MinY,int MaxX,int MaxY) + public void RequestMapBlock(UserAgentInfo userInfo, int minX, int minY,int maxX,int maxY) { - foreach (KeyValuePair RegionPair in this.Grid) + foreach (KeyValuePair RegionPair in this.Grid) { //check Region is inside the requested area - RegionInfo Region=RegionPair.Value; - if(((Region.X>MinX) && (Region.XMinY) && (Region.Y minX) && (Region.X < maxX)) && ((Region.Y > minY) && (Region.Y < maxY))) { - MapBlockReplyPacket MapReply=new MapBlockReplyPacket(); - MapReply.AgentData.AgentID=UserInfo.AgentID; - MapReply.AgentData.Flags=0; - MapReply.Data=new MapBlockReplyPacket.DataBlock[1]; - MapReply.Data[0]=new MapBlockReplyPacket.DataBlock(); - MapReply.Data[0].MapImageID=Region.ImageID; - MapReply.Data[0].X=Region.X; - MapReply.Data[0].Y=Region.Y; - MapReply.Data[0].WaterHeight=Region.WaterHeight; - MapReply.Data[0].Name=enc.GetBytes( Region.Name); - MapReply.Data[0].RegionFlags=72458694; - MapReply.Data[0].Access=13; - MapReply.Data[0].Agents=1; - server.SendPacket(MapReply,true,UserInfo); + MapBlockReplyPacket MapReply = new MapBlockReplyPacket(); + MapReply.AgentData.AgentID = userInfo.AgentID; + MapReply.AgentData.Flags = 0; + MapReply.Data = new MapBlockReplyPacket.DataBlock[1]; + MapReply.Data[0] = new MapBlockReplyPacket.DataBlock(); + MapReply.Data[0].MapImageID = Region.ImageID; + MapReply.Data[0].X = Region.X; + MapReply.Data[0].Y = Region.Y; + MapReply.Data[0].WaterHeight = Region.WaterHeight; + MapReply.Data[0].Name = _enc.GetBytes( Region.Name); + MapReply.Data[0].RegionFlags = 72458694; + MapReply.Data[0].Access = 13; + MapReply.Data[0].Agents = 1; + _server.SendPacket(MapReply, true, userInfo); } } @@ -122,35 +122,35 @@ namespace OpenSim /// /// /// - public void RequestTeleport(User_Agent_info UserInfo, TeleportLocationRequestPacket Request) + public void RequestTeleport(UserAgentInfo userInfo, TeleportLocationRequestPacket request) { - if(Grid.ContainsKey(Request.Info.RegionHandle)) + if(Grid.ContainsKey(request.Info.RegionHandle)) { - RegionInfo Region=Grid[Request.Info.RegionHandle]; - libsecondlife.Packets.TeleportStartPacket TeleportStart=new TeleportStartPacket(); - TeleportStart.Info.TeleportFlags=16; - server.SendPacket(TeleportStart,true,UserInfo); + RegionInfo Region = Grid[request.Info.RegionHandle]; + libsecondlife.Packets.TeleportStartPacket TeleportStart = new TeleportStartPacket(); + TeleportStart.Info.TeleportFlags = 16; + _server.SendPacket(TeleportStart, true, userInfo); - libsecondlife.Packets.TeleportFinishPacket Teleport=new TeleportFinishPacket(); - Teleport.Info.AgentID=UserInfo.AgentID; - Teleport.Info.RegionHandle=Request.Info.RegionHandle; - Teleport.Info.SimAccess=13; - Teleport.Info.SeedCapability=new byte[0]; + libsecondlife.Packets.TeleportFinishPacket Teleport = new TeleportFinishPacket(); + Teleport.Info.AgentID = userInfo.AgentID; + Teleport.Info.RegionHandle = request.Info.RegionHandle; + Teleport.Info.SimAccess = 13; + Teleport.Info.SeedCapability = new byte[0]; - System.Net.IPAddress oIP=System.Net.IPAddress.Parse(Region.IPAddress.Address); - byte[] byteIP=oIP.GetAddressBytes(); + System.Net.IPAddress oIP = System.Net.IPAddress.Parse(Region.IPAddress.Address); + byte[] byteIP = oIP.GetAddressBytes(); uint ip=(uint)byteIP[3]<<24; ip+=(uint)byteIP[2]<<16; ip+=(uint)byteIP[1]<<8; ip+=(uint)byteIP[0]; - Teleport.Info.SimIP=ip; - Teleport.Info.SimPort=Region.IPAddress.Port; - Teleport.Info.LocationID=4; - Teleport.Info.TeleportFlags= 1 << 4;; - server.SendPacket(Teleport,true,UserInfo); + Teleport.Info.SimIP = ip; + Teleport.Info.SimPort = Region.IPAddress.Port; + Teleport.Info.LocationID = 4; + Teleport.Info.TeleportFlags = 1 << 4;; + _server.SendPacket(Teleport, true, userInfo); - this.AgentManager.RemoveAgent(UserInfo); + this._agentManager.RemoveAgent(userInfo); } } @@ -162,13 +162,13 @@ namespace OpenSim { //should connect to a space server to see what grids there are //but for now we read static xml files - ulong CurrentHandle=0; - bool Login=true; + ulong CurrentHandle = 0; + bool Login = true; XmlDocument doc = new XmlDocument(); try { - doc.Load(Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory,"Grid.ini" )); + doc.Load(Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "Grid.ini" )); } catch ( Exception e) { @@ -189,102 +189,102 @@ namespace OpenSim if (nodes.HasChildNodes) { foreach( XmlNode xmlnc in nodes.ChildNodes) { - if(xmlnc.Name=="Region") + if(xmlnc.Name == "Region") { string xmlAttri; - RegionInfo Region=new RegionInfo(); - if(xmlnc.Attributes["Name"]!=null) + RegionInfo Region = new RegionInfo(); + if(xmlnc.Attributes["Name"] != null) { - xmlAttri=((XmlAttribute)xmlnc.Attributes.GetNamedItem("Name")).Value; - Region.Name=xmlAttri+" \0"; + xmlAttri = ((XmlAttribute)xmlnc.Attributes.GetNamedItem("Name")).Value; + Region.Name = xmlAttri+" \0"; } - if(xmlnc.Attributes["ImageID"]!=null) + if(xmlnc.Attributes["ImageID"] != null) { - xmlAttri=((XmlAttribute)xmlnc.Attributes.GetNamedItem("ImageID")).Value; - Region.ImageID=new LLUUID(xmlAttri); + xmlAttri = ((XmlAttribute)xmlnc.Attributes.GetNamedItem("ImageID")).Value; + Region.ImageID = new LLUUID(xmlAttri); } - if(xmlnc.Attributes["IP_Address"]!=null) + if(xmlnc.Attributes["IP_Address"] != null) { - xmlAttri=((XmlAttribute)xmlnc.Attributes.GetNamedItem("IP_Address")).Value; - Region.IPAddress.Address=xmlAttri; + xmlAttri = ((XmlAttribute)xmlnc.Attributes.GetNamedItem("IP_Address")).Value; + Region.IPAddress.Address = xmlAttri; } - if(xmlnc.Attributes["IP_Port"]!=null) + if(xmlnc.Attributes["IP_Port"] != null) { - xmlAttri=((XmlAttribute)xmlnc.Attributes.GetNamedItem("IP_Port")).Value; - Region.IPAddress.Port=Convert.ToUInt16(xmlAttri); + xmlAttri = ((XmlAttribute)xmlnc.Attributes.GetNamedItem("IP_Port")).Value; + Region.IPAddress.Port = Convert.ToUInt16(xmlAttri); } - if(xmlnc.Attributes["Location_X"]!=null) + if(xmlnc.Attributes["Location_X"] != null) { - xmlAttri=((XmlAttribute)xmlnc.Attributes.GetNamedItem("Location_X")).Value; - Region.X=Convert.ToUInt16(xmlAttri); + xmlAttri = ((XmlAttribute)xmlnc.Attributes.GetNamedItem("Location_X")).Value; + Region.X = Convert.ToUInt16(xmlAttri); } - if(xmlnc.Attributes["Location_Y"]!=null) + if(xmlnc.Attributes["Location_Y"] != null) { - xmlAttri=((XmlAttribute)xmlnc.Attributes.GetNamedItem("Location_Y")).Value; - Region.Y=Convert.ToUInt16(xmlAttri); + xmlAttri = ((XmlAttribute)xmlnc.Attributes.GetNamedItem("Location_Y")).Value; + Region.Y = Convert.ToUInt16(xmlAttri); } - this.Grid.Add(Region.Handle,Region); + this.Grid.Add(Region.Handle, Region); } - if(xmlnc.Name=="CurrentRegion") + if(xmlnc.Name == "CurrentRegion") { string xmlAttri; - uint Rx=0,Ry=0; - if(xmlnc.Attributes["RegionHandle"]!=null) + uint Rx = 0, Ry = 0; + if(xmlnc.Attributes["RegionHandle"] != null) { - xmlAttri=((XmlAttribute)xmlnc.Attributes.GetNamedItem("RegionHandle")).Value; - CurrentHandle=Convert.ToUInt64(xmlAttri); + xmlAttri = ((XmlAttribute)xmlnc.Attributes.GetNamedItem("RegionHandle")).Value; + CurrentHandle = Convert.ToUInt64(xmlAttri); } else { - if(xmlnc.Attributes["Region_X"]!=null) + if(xmlnc.Attributes["Region_X"] != null) { - xmlAttri=((XmlAttribute)xmlnc.Attributes.GetNamedItem("Region_X")).Value; - Rx=Convert.ToUInt32(xmlAttri); + xmlAttri = ((XmlAttribute)xmlnc.Attributes.GetNamedItem("Region_X")).Value; + Rx = Convert.ToUInt32(xmlAttri); } - if(xmlnc.Attributes["Region_Y"]!=null) + if(xmlnc.Attributes["Region_Y"] != null) { - xmlAttri=((XmlAttribute)xmlnc.Attributes.GetNamedItem("Region_Y")).Value; - Ry=Convert.ToUInt32(xmlAttri); + xmlAttri = ((XmlAttribute)xmlnc.Attributes.GetNamedItem("Region_Y")).Value; + Ry = Convert.ToUInt32(xmlAttri); } } - if(xmlnc.Attributes["LoginServer"]!=null) + if(xmlnc.Attributes["LoginServer"] != null) { - xmlAttri=((XmlAttribute)xmlnc.Attributes.GetNamedItem("LoginServer")).Value; - Login=Convert.ToBoolean(xmlAttri); + xmlAttri = ((XmlAttribute)xmlnc.Attributes.GetNamedItem("LoginServer")).Value; + Login = Convert.ToBoolean(xmlAttri); } - if(CurrentHandle==0) + if(CurrentHandle == 0) { //no RegionHandle set //so check for Region X and Y - if((Rx >0) && (Ry>0)) + if((Rx > 0) && (Ry > 0)) { - CurrentHandle=Helpers.UIntsToLong((Rx*256),(Ry*256)); + CurrentHandle = Helpers.UIntsToLong((Rx*256), (Ry*256)); } else { //seems to be no Region location set // so set default - CurrentHandle=1096213093147648; + CurrentHandle = 1096213093147648; } } } } //finished loading grid, now set Globals to current region - if(CurrentHandle!=0) + if(CurrentHandle != 0) { if(Grid.ContainsKey(CurrentHandle)) { - RegionInfo Region=Grid[CurrentHandle]; - Globals.Instance.RegionHandle=Region.Handle; - Globals.Instance.RegionName=Region.Name; - Globals.Instance.IpPort=Region.IPAddress.Port; - Globals.Instance.LoginSever=Login; + RegionInfo Region = Grid[CurrentHandle]; + Globals.Instance.RegionHandle = Region.Handle; + Globals.Instance.RegionName = Region.Name; + Globals.Instance.IpPort = Region.IPAddress.Port; + Globals.Instance.LoginSever = Login; } } @@ -317,8 +317,8 @@ namespace OpenSim } set { - x=value; - Handle=Helpers.UIntsToLong((((uint)x)*256),(((uint)y)*256)); + x = value; + Handle = Helpers.UIntsToLong((((uint)x)*256), (((uint)y)*256)); } } public ushort Y @@ -329,33 +329,33 @@ namespace OpenSim } set { - y=value; - Handle=Helpers.UIntsToLong((((uint)x)*256),(((uint)y)*256)); + y = value; + Handle = Helpers.UIntsToLong((((uint)x)*256), (((uint)y)*256)); } } public ulong Handle { get { - if(handle>0) + if(handle > 0) { return(handle); } else { - return(Helpers.UIntsToLong((((uint)x)*256),(((uint)y)*256))); + return(Helpers.UIntsToLong((((uint)x)*256), (((uint)y)*256))); } } set { - handle=value; + handle = value; } } public RegionInfo() { - this.IPAddress=new RegionIP(); + this.IPAddress = new RegionIP(); } } public class RegionIP diff --git a/InventoryManager.cs b/InventoryManager.cs index 72c9607435..17f7f5c52a 100644 --- a/InventoryManager.cs +++ b/InventoryManager.cs @@ -38,20 +38,20 @@ namespace OpenSim /// public class InventoryManager { - private System.Text.Encoding enc = System.Text.Encoding.ASCII; + public Dictionary Folders; public Dictionary Items; - private Server server; - + private Server _server; + private System.Text.Encoding _enc = System.Text.Encoding.ASCII; private const uint FULL_MASK_PERMISSIONS = 2147483647; /// /// /// /// - public InventoryManager(Server serve) + public InventoryManager(Server server) { - server=serve; + _server = server; Folders=new Dictionary(); Items=new Dictionary(); } @@ -63,23 +63,23 @@ namespace OpenSim /// /// /// - public LLUUID AddToInventory(User_Agent_info UserInfo, LLUUID FolderID,AssetBase Asset) + public LLUUID AddToInventory(UserAgentInfo userInfo, LLUUID folderID, AssetBase asset) { - if(this.Folders.ContainsKey(FolderID)) + if(this.Folders.ContainsKey(folderID)) { - LLUUID NewItemID=LLUUID.Random(); + LLUUID NewItemID = LLUUID.Random(); - InventoryItem Item=new InventoryItem(); - Item.FolderID=FolderID; - Item.OwnerID=UserInfo.AgentID; - Item.AssetID=Asset.Full_ID; - Item.ItemID=NewItemID; - Item.Type=Asset.Type; - Item.Name=Asset.Name; - Item.Description=Asset.Description; - Item.InvType=Asset.InvType; - this.Items.Add(Item.ItemID,Item); - InventoryFolder Folder=Folders[Item.FolderID]; + InventoryItem Item = new InventoryItem(); + Item.FolderID = folderID; + Item.OwnerID = userInfo.AgentID; + Item.AssetID = asset.FullID; + Item.ItemID = NewItemID; + Item.Type = asset.Type; + Item.Name = asset.Name; + Item.Description = asset.Description; + Item.InvType = asset.InvType; + this.Items.Add(Item.ItemID, Item); + InventoryFolder Folder = Folders[Item.FolderID]; Folder.Items.Add(Item); return(Item.ItemID); } @@ -95,12 +95,12 @@ namespace OpenSim /// /// /// - public bool CreateNewFolder(User_Agent_info UserInfo, LLUUID NewFolder) + public bool CreateNewFolder(UserAgentInfo userInfo, LLUUID newFolder) { - InventoryFolder Folder=new InventoryFolder(); - Folder.FolderID=NewFolder; - Folder.OwnerID=UserInfo.AgentID; - this.Folders.Add(Folder.FolderID,Folder); + InventoryFolder Folder = new InventoryFolder(); + Folder.FolderID = newFolder; + Folder.OwnerID = userInfo.AgentID; + this.Folders.Add(Folder.FolderID, Folder); return(true); } @@ -110,49 +110,49 @@ namespace OpenSim /// /// /// - public void FetchInventoryDescendents(User_Agent_info User_info,FetchInventoryDescendentsPacket FetchDescend) + public void FetchInventoryDescendents(UserAgentInfo userInfo, FetchInventoryDescendentsPacket FetchDescend) { if(FetchDescend.InventoryData.FetchItems) { if(this.Folders.ContainsKey(FetchDescend.InventoryData.FolderID)) { - InventoryFolder Folder=this.Folders[FetchDescend.InventoryData.FolderID]; - InventoryDescendentsPacket Descend=new InventoryDescendentsPacket(); - Descend.AgentData.AgentID=User_info.AgentID; - Descend.AgentData.OwnerID=Folder.OwnerID; - Descend.AgentData.FolderID=FetchDescend.InventoryData.FolderID; - Descend.AgentData.Descendents=Folder.Items.Count; - Descend.AgentData.Version=Folder.Items.Count; + InventoryFolder Folder = this.Folders[FetchDescend.InventoryData.FolderID]; + InventoryDescendentsPacket Descend = new InventoryDescendentsPacket(); + Descend.AgentData.AgentID = userInfo.AgentID; + Descend.AgentData.OwnerID = Folder.OwnerID; + Descend.AgentData.FolderID = FetchDescend.InventoryData.FolderID; + Descend.AgentData.Descendents = Folder.Items.Count; + Descend.AgentData.Version = Folder.Items.Count; - Descend.ItemData=new InventoryDescendentsPacket.ItemDataBlock[Folder.Items.Count]; - for(int i=0; i /// - public void FetchInventory(User_Agent_info User_info, FetchInventoryPacket FetchItems) + public void FetchInventory(UserAgentInfo userInfo, FetchInventoryPacket FetchItems) { - for(int i=0; i(); + Items = new List(); } } @@ -228,7 +228,7 @@ namespace OpenSim public LLUUID OwnerID; public LLUUID ItemID; public LLUUID AssetID; - public LLUUID CreatorID=LLUUID.Zero; + public LLUUID CreatorID = LLUUID.Zero; public sbyte InvType; public sbyte Type; public string Name; diff --git a/Login_manager.cs b/Login_manager.cs index dc90613912..2d4f524992 100644 --- a/Login_manager.cs +++ b/Login_manager.cs @@ -116,7 +116,8 @@ namespace OpenSim int contentLength = 0; // read HTTP header - do { + do + { // read one line of the header line = reader.ReadLine(); @@ -145,72 +146,72 @@ namespace OpenSim //get login name if(requestData.Contains("first")) { - first=(string)requestData["first"]; + first = (string)requestData["first"]; } else { - first="test"; + first = "test"; } if(requestData.Contains("last")) { - last=(string)requestData["last"]; + last = (string)requestData["last"]; } else { - last="User"+NumClients.ToString(); + last = "User"+NumClients.ToString(); } NumClients++; //create a agent and session LLUUID - int AgentRand=this.RandomClass.Next(1,9999); - Agent=new LLUUID("99998888-"+AgentRand.ToString("0000")+"-4f52-8ec1-0b1d5cd6aead"); - int SessionRand=this.RandomClass.Next(1,999); - Session=new LLUUID("aaaabbbb-8932-"+SessionRand.ToString("0000")+"-8664-58f53e442797"); + int AgentRand = this.RandomClass.Next(1,9999); + Agent = new LLUUID("99998888-"+AgentRand.ToString("0000")+"-4f52-8ec1-0b1d5cd6aead"); + int SessionRand = this.RandomClass.Next(1,999); + Session = new LLUUID("aaaabbbb-8932-"+SessionRand.ToString("0000")+"-8664-58f53e442797"); StreamReader SR; - string ResponseString=""; + string ResponseString = ""; string lines; SR=File.OpenText("new-login.dat"); lines=SR.ReadLine(); - while(lines!="end-mfile") + while(lines != "end-mfile") { - ResponseString+=lines; - lines=SR.ReadLine(); + ResponseString += lines; + lines = SR.ReadLine(); } SR.Close(); XmlRpcResponse response =(XmlRpcResponse)(new XmlRpcResponseDeserializer()).Deserialize(ResponseString); Hashtable responseData = (Hashtable)response.Value; - responseData["agent_id"]=Agent.ToStringHyphenated(); - responseData["session_id"]=Session.ToStringHyphenated(); - ArrayList InventoryList=(ArrayList) responseData["inventory-skeleton"]; - Hashtable Inventory1=(Hashtable)InventoryList[0]; - Hashtable Inventory2=(Hashtable)InventoryList[1]; - LLUUID BaseFolderID=LLUUID.Random(); - LLUUID InventoryFolderID=LLUUID.Random(); - Inventory2["name"]="Base"; - Inventory2["folder_id"]=BaseFolderID.ToStringHyphenated(); - Inventory1["folder_id"]=InventoryFolderID.ToStringHyphenated(); + responseData["agent_id"] = Agent.ToStringHyphenated(); + responseData["session_id"] = Session.ToStringHyphenated(); + ArrayList InventoryList = (ArrayList) responseData["inventory-skeleton"]; + Hashtable Inventory1 = (Hashtable)InventoryList[0]; + Hashtable Inventory2 = (Hashtable)InventoryList[1]; + LLUUID BaseFolderID = LLUUID.Random(); + LLUUID InventoryFolderID = LLUUID.Random(); + Inventory2["name"] = "Base"; + Inventory2["folder_id"] = BaseFolderID.ToStringHyphenated(); + Inventory1["folder_id"] = InventoryFolderID.ToStringHyphenated(); - ArrayList InventoryRoot=(ArrayList) responseData["inventory-root"]; - Hashtable Inventoryroot=(Hashtable)InventoryRoot[0]; - Inventoryroot["folder_id"]=InventoryFolderID.ToStringHyphenated(); + ArrayList InventoryRoot = (ArrayList) responseData["inventory-root"]; + Hashtable Inventoryroot = (Hashtable)InventoryRoot[0]; + Inventoryroot["folder_id"] = InventoryFolderID.ToStringHyphenated(); //copy data to login object lock(Login) { - Login.first=first; - Login.last=last; - Login.Agent=Agent; - Login.Session=Session; - Login.BaseFolder=BaseFolderID; - Login.InventoryFolder=InventoryFolderID; + Login.First = first; + Login.Last = last; + Login.Agent = Agent; + Login.Session = Session; + Login.BaseFolder = BaseFolderID; + Login.InventoryFolder = InventoryFolderID; } // forward the XML-RPC response to the client diff --git a/Prim_manager.cs b/Prim_manager.cs index 856bffe3ff..aa1c32aad6 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 /// Packet to be sent /// Increment sequence number? - public void SendPacket(Packet packet, bool incrementSequence, User_Agent_info User_info) + public void SendPacket(Packet packet, bool incrementSequence, UserAgentInfo User_info) { byte[] buffer; int bytes; @@ -324,7 +324,7 @@ namespace OpenSim /// /// Sends out pending acknowledgements /// - private void SendAcks(User_Agent_info User_info) + private void SendAcks(UserAgentInfo User_info) { lock (User_info.PendingAcks) { @@ -358,7 +358,7 @@ namespace OpenSim /// /// Resend unacknowledged packets /// - private void ResendUnacked(User_Agent_info User_info) + private void ResendUnacked(UserAgentInfo User_info) { if (connected) { @@ -397,7 +397,7 @@ namespace OpenSim // Update the disconnect flag so this sim doesn't time out DisconnectCandidate = false; - User_Agent_info User_info=null; + UserAgentInfo User_info=null; lock (RecvBuffer) { @@ -416,7 +416,7 @@ namespace OpenSim if (packet.Type == PacketType.UseCircuitCode) { UseCircuitCodePacket cir_pack=(UseCircuitCodePacket)packet; - User_Agent_info new_user=new User_Agent_info(); + UserAgentInfo new_user=new UserAgentInfo(); new_user.circuitCode=cir_pack.CircuitCode.Code; new_user.AgentID=cir_pack.CircuitCode.ID; new_user.SessionID=cir_pack.CircuitCode.SessionID; @@ -429,13 +429,13 @@ namespace OpenSim } - User_Agent_info temp_agent=null; + UserAgentInfo temp_agent=null; IPEndPoint send_ip=(IPEndPoint)epSender; // this.callback_object.error("incoming: address is "+send_ip.Address +"port number is: "+send_ip.Port.ToString()); for(int ii=0; ii PendingAcks = new Dictionary(); - public User_Agent_info() + public UserAgentInfo() { }