From 3a157273da7de6caa098ac4af406e37be02a1171 Mon Sep 17 00:00:00 2001 From: MW Date: Sat, 3 Feb 2007 19:51:52 +0000 Subject: [PATCH] Added Basic Inventory support --- Agent_Manager.cs | 52 +++-- AssetManagement.cs | 460 ++++++++++++++++++++++++++++++++++++++ Asset_manager.cs | 73 +++++- Controller.cs | 89 +++++--- Globals.cs | 3 +- GridManager.cs | 2 +- InventoryManager.cs | 240 ++++++++++++++++++++ Login_manager.cs | 77 ++++--- Physics_manager.cs | 4 +- Prim_manager.cs | 4 +- SceneGraphManager.cs | 40 ++++ Script_manager.cs | 4 +- Second-server.csproj | 5 +- StorageManager.cs | 4 +- Texture_manager.cs | 11 +- bin/Release/new-login.dat | 2 + 16 files changed, 965 insertions(+), 105 deletions(-) create mode 100644 AssetManagement.cs create mode 100644 InventoryManager.cs create mode 100644 SceneGraphManager.cs create mode 100644 bin/Release/new-login.dat diff --git a/Agent_Manager.cs b/Agent_Manager.cs index 9aa8d7f167..2f5cebae5f 100644 --- a/Agent_Manager.cs +++ b/Agent_Manager.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2007 Michael Wright +Copyright (c) OpenSim project, http://sim.opensecondlife.org/ * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -44,6 +44,7 @@ namespace OpenSim private uint local_numer=0; private Server server; public PrimManager Prim_Manager; + public AssetManagement Asset_Manager; private libsecondlife.Packets.RegionHandshakePacket RegionPacket; private System.Text.Encoding enc = System.Text.Encoding.ASCII; @@ -101,7 +102,7 @@ namespace OpenSim /// /// /// - public bool NewAgent(User_Agent_info User_info, string first, string last) + public bool NewAgent(User_Agent_info User_info, string first, string last ,LLUUID BaseFolder,LLUUID InventoryFolder) { AvatarData agent=new AvatarData(); agent.FullID=User_info.AgentID; @@ -109,7 +110,13 @@ namespace OpenSim 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); + return(true); } @@ -343,29 +350,27 @@ namespace OpenSim /// public void SendIntialAvatarAppearance(User_Agent_info user) { - + AvatarData Agent=this.AgentList[user.AgentID]; AgentWearablesUpdatePacket aw=new AgentWearablesUpdatePacket(); aw.AgentData.AgentID=user.AgentID; - aw.AgentData.SerialNum=0;//(uint)appc; - //appc++; - aw.AgentData.SessionID=user.SessionID;//new LLUUID("00000000-0000-0000-0000-000000000000");//user.SessionID; + aw.AgentData.SerialNum=0; + aw.AgentData.SessionID=user.SessionID; aw.WearableData= new AgentWearablesUpdatePacket.WearableDataBlock[13]; AgentWearablesUpdatePacket.WearableDataBlock awb=null; awb=new AgentWearablesUpdatePacket.WearableDataBlock(); awb.WearableType=(byte)0; - awb.AssetID=new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73"); - awb.ItemID=new LLUUID("b7878441893b094917f791174bc8401c"); + 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; - /*awb=new AgentWearablesUpdatePacket.WearableDataBlock(); + awb=new AgentWearablesUpdatePacket.WearableDataBlock(); awb.WearableType=(byte)1; - awb.AssetID=new LLUUID("e0ee49b5a4184df8d3c9a65361fe7f49"); - awb.ItemID=new LLUUID("193f0876fc11d143797454352f9c9c26"); - //awb.ItemID=new LLUUID("00000000-0000-0000-0000-000000000000"); - aw.WearableData[1]=awb;*/ + awb.AssetID=Agent.Wearables[1].AssetID;//new LLUUID("e0ee49b5a4184df8d3c9a65361fe7f49"); + awb.ItemID=Agent.Wearables[1].ItemID;//new LLUUID("193f0876fc11d143797454352f9c9c26"); + aw.WearableData[1]=awb; - for(int i=1; i<13; i++) + for(int i=2; i<13; i++) { awb=new AgentWearablesUpdatePacket.WearableDataBlock(); awb.WearableType=(byte)i; @@ -412,6 +417,7 @@ namespace OpenSim server.SendPacket(avp,true,user); } + /// /// /// @@ -638,8 +644,26 @@ namespace OpenSim public bool Walk=false; public bool Started=false; //public TextureEntry TextureEntry; + public AvatarWearable[] Wearables; + public LLUUID InventoryFolder; + public LLUUID BaseFolder; public AvatarData() + { + Wearables=new AvatarWearable[2]; //should be 13 + for(int i=0; i<2; i++) + { + Wearables[i]=new AvatarWearable(); + } + } + } + + public class AvatarWearable + { + public LLUUID AssetID; + public LLUUID ItemID; + + public AvatarWearable() { } diff --git a/AssetManagement.cs b/AssetManagement.cs new file mode 100644 index 0000000000..adc8bd5266 --- /dev/null +++ b/AssetManagement.cs @@ -0,0 +1,460 @@ +/* + * +Copyright (c) OpenSim project, http://sim.opensecondlife.org/ +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* + */ + +using System; +using System.Collections.Generic; +using libsecondlife; +using System.Collections; +using libsecondlife.Packets; +using libsecondlife.AssetSystem; +using System.IO; + +namespace OpenSim +{ + /// + /// Asset and Image management + /// + public class AssetManagement + { + 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 AssetManagement(Server server) + { + this.server=server; + Textures=new Dictionary (); + Assets=new Dictionary (); + this.initialise(); + } + + /// + /// + /// + 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"); + this.LoadAsset(Asset); + this.Assets.Add(Asset.Full_ID,Asset); + + Asset=new AssetInfo(); + Asset.filename="base_skin.dat"; + Asset.Full_ID=new LLUUID("e0ee49b5a4184df8d3c9a65361fe7f49"); + this.LoadAsset(Asset); + this.Assets.Add(Asset.Full_ID,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"; + this.LoadImage(Image); + this.Textures.Add(Image.Full_ID,Image); + + Image=new TextureImage(); + Image.filename="map_base.jp2"; + Image.Full_ID=new LLUUID("00000000-0000-0000-7007-000000000006"); + this.LoadImage(Image); + this.Textures.Add(Image.Full_ID,Image); + + Image=new TextureImage(); + Image.filename="map1.jp2"; + Image.Full_ID=new LLUUID("00000000-0000-0000-7009-000000000008"); + this.LoadImage(Image); + this.Textures.Add(Image.Full_ID,Image); + } + + /// + /// + /// + /// + /// + /// + #region AssetRegion + + public void AddAssetRequest(User_Agent_info UserInfo, LLUUID AssetID, TransferRequestPacket TransferRequest) + { + + if(!this.Assets.ContainsKey(AssetID)) + { + //not found asset + return; + } + 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; + + server.SendPacket(Transfer,true,UserInfo); + + 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]; + Array.Copy(info.data,chunk,1000); + 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)]; + Array.Copy(info.data,1000,chunk1,0,chunk1.Length); + 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); + } + + } + + public void CreateNewInventorySet(ref AvatarData Avata,User_Agent_info UserInfo) + { + //Create Folders + 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); + + 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()); + Array.Copy(Agentid,0,Shape.data,294,Agentid.Length); + this.Assets.Add(Shape.Full_ID,Shape); + + Avata.Wearables[0].ItemID=InventoryManager.AddToInventory(UserInfo,BaseFolder,Shape); + Avata.Wearables[0].AssetID=Shape.Full_ID; + + //Give copy of default skin + 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; + + Array.Copy(Agentid,0,Skin.data,238,Agentid.Length); + this.Assets.Add(Skin.Full_ID,Skin); + + Avata.Wearables[1].ItemID=InventoryManager.AddToInventory(UserInfo,BaseFolder,Skin); + Avata.Wearables[1].AssetID=Skin.Full_ID; + + //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); + + } + + + private void LoadAsset(AssetInfo info) + { + //should request Asset from storage manager + //but for now read from file + + string data_path = System.AppDomain.CurrentDomain.BaseDirectory + @"\assets\"; + 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]; + BinaryReader br = new BinaryReader(fStream); + idata= br.ReadBytes((int)numBytes); + br.Close(); + fStream.Close(); + 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; + return(NewAsset); + } + #endregion + + #region TextureRegion + public void AddTextureRequest(User_Agent_info user, LLUUID image_id) + { + + if(!this.Textures.ContainsKey(image_id)) + { + //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); + return; + } + TextureImage imag=this.Textures[image_id]; + TextureRequest req=new TextureRequest(); + req.RequestUser=user; + req.RequestImage=image_id; + 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++; + } + else + { + req.num_packets=1; + } + + this.TextureRequests.Add(req); + + } + + public void AddTexture(LLUUID image_id, string name, byte[] data) + { + + } + public void DoWork(ulong time) + { + 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) + { + //lower than 5 so do all of them + num=this.TextureRequests.Count; + } + else + { + num=5; + } + TextureRequest req; + for(int i=0; i, * All rights reserved. @@ -45,6 +45,9 @@ namespace OpenSim public ArrayList requests=new ArrayList(); //should change to a generic // public ArrayList uploads=new ArrayList(); private Server server; + public TextureManager TextureMan; + public InventoryManager InventoryManager; + private System.Text.Encoding enc = System.Text.Encoding.ASCII; public AssetManager(Server serve) { @@ -55,7 +58,7 @@ namespace OpenSim public void AddRequest(User_Agent_info user, LLUUID asset_id, TransferRequestPacket tran_req) { - + Console.WriteLine("Asset Request "+ asset_id); if(!this.Assets.ContainsKey(asset_id)) { //not found asset @@ -103,7 +106,44 @@ namespace OpenSim server.SendPacket(tran_p,true,user); } + } + public void CreateNewBaseSet(ref AvatarData Avata,User_Agent_info UserInfo) + { + //LLUUID BaseFolder=new LLUUID("4f5f559e-77a0-a4b9-84f9-8c74c07f7cfc");//*/"4fb2dab6-a987-da66-05ee-96ca82bccbf1"); + //LLUUID BaseFolder=new LLUUID("480e2d92-61f6-9f16-f4f5-0f77cfa4f8f9"); + LLUUID BaseFolder=Avata.BaseFolder; + InventoryManager.CreateNewFolder(UserInfo,Avata.InventoryFolder); + InventoryManager.CreateNewFolder(UserInfo, BaseFolder); + AssetInfo Base=this.Assets[new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73")]; + AssetInfo Shape=new AssetInfo(); + + Shape.filename=""; + Shape.data=new byte[Base.data.Length]; + Array.Copy(Base.data,Shape.data,Base.data.Length); + Shape.Full_ID=LLUUID.Random(); + Shape.Name="Default Skin"; + Shape.Description="Default"; + Shape.InvType=18; + + Shape.Type=libsecondlife.AssetSystem.Asset.ASSET_TYPE_WEARABLE_BODY; + byte[] Agentid=enc.GetBytes(UserInfo.AgentID.ToStringHyphenated()); + Array.Copy(Agentid,0,Shape.data,294,Agentid.Length); + this.Assets.Add(Shape.Full_ID,Shape); + /*FileStream fStream = new FileStream("Assetshape.dat", FileMode.CreateNew); + BinaryWriter bw = new BinaryWriter(fStream); + bw.Write(Shape.data); + bw.Close(); + fStream.Close();*/ + + Avata.Wearables[0].ItemID=InventoryManager.AddToInventory(UserInfo,BaseFolder,Shape); + Avata.Wearables[0].AssetID=Shape.Full_ID; + //Avata.RootFolder=BaseFolder; + + //give test texture + + TextureImage Texture=TextureMan.textures[new LLUUID("00000000-0000-0000-5005-000000000005")]; + InventoryManager.AddToInventory(UserInfo,BaseFolder,Texture); } @@ -115,6 +155,13 @@ namespace OpenSim im.Full_ID=new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73"); this.loadAsset(im); this.Assets.Add(im.Full_ID,im); + + + im=new AssetInfo(); + im.filename="base_skin.dat"; + im.Full_ID=new LLUUID("e0ee49b5a4184df8d3c9a65361fe7f49"); + this.loadAsset(im); + this.Assets.Add(im.Full_ID,im); } private void loadAsset(AssetInfo info) { @@ -152,11 +199,10 @@ namespace OpenSim } } - public class AssetInfo + public class AssetInfo:AssetBase { - public byte[] data; - public LLUUID Full_ID; - public string name; + //public byte[] data; + //public LLUUID Full_ID; public string filename; public bool loaded; public ulong last_used; //need to add a tick/time counter and keep record @@ -167,4 +213,19 @@ namespace OpenSim } } + + public class AssetBase + { + public byte[] data; + public LLUUID Full_ID; + public sbyte Type; + public sbyte InvType; + public string Name; + public string Description; + + public AssetBase() + { + + } + } } diff --git a/Controller.cs b/Controller.cs index f2bd85cfb9..0a6fee9a53 100644 --- a/Controller.cs +++ b/Controller.cs @@ -1,7 +1,7 @@ /* -Copyright (c) 2007 Michael Wright +Copyright (c) OpenSim project, http://sim.opensecondlife.org/ + -* Copyright (c) , * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -58,9 +58,10 @@ namespace OpenSim public Logon _login; private AgentManager Agent_Manager; private PrimManager Prim_Manager; - private TextureManager Texture_Manager; - private AssetManager Asset_Manager; + // private TextureManager Texture_Manager; + private AssetManagement Asset_Manager; private GridManager Grid_Manager; + private InventoryManager Inventory_Manager; private LoginManager Login_Manager; //built in login server private ulong time; //ticks private Timer timer1 = new Timer(); @@ -71,10 +72,14 @@ namespace OpenSim server = new Server( this ); Agent_Manager = new AgentManager( this.server ); Prim_Manager = new PrimManager( this.server ); - Texture_Manager = new TextureManager( this.server ); - Asset_Manager = new AssetManager( this.server ); + // Texture_Manager = new TextureManager( 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; + // Asset_Manager.TextureMan=Texture_Manager; Grid_Manager=new GridManager(this.server,Agent_Manager); if(Globals.Instance.LoginSever) { @@ -89,80 +94,93 @@ namespace OpenSim } public void MainCallback( Packet pack, User_Agent_info User_info ) { - //System.Console.WriteLine(pack.Type); - if( ( pack.Type != PacketType.StartPingCheck ) && ( pack.Type != PacketType.AgentUpdate ) ) { - // System.Console.WriteLine(pack.Type); + + /*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; - } + }*/ + + //should replace with a switch if( pack.Type == PacketType.AgentSetAppearance ) { - // System.Console.WriteLine(pack); + // System.Console.WriteLine(pack); //this.richTextBox1.Text=this.richTextBox1.Text+"\n "+pack.Type; } - if(pack.Type== PacketType.MapBlockRequest) + else if( pack.Type == PacketType.FetchInventory) + { + FetchInventoryPacket FetchInventory=(FetchInventoryPacket)pack; + Inventory_Manager.FetchInventory(User_info,FetchInventory); + } + else if( pack.Type == PacketType.FetchInventoryDescendents) + { + FetchInventoryDescendentsPacket Fetch=(FetchInventoryDescendentsPacket)pack; + Inventory_Manager.FetchInventoryDescendents(User_info,Fetch); + } + 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); } - if(pack.Type== PacketType.CloseCircuit) + else if(pack.Type== PacketType.CloseCircuit) { this.Agent_Manager.RemoveAgent(User_info); } - if(pack.Type== PacketType.MapLayerRequest) + else if(pack.Type== PacketType.MapLayerRequest) { this.Grid_Manager.RequestMapLayer(User_info); } - 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); } - if( pack.Type == PacketType.TransferRequest ) { + else if( pack.Type == PacketType.TransferRequest ) { TransferRequestPacket tran = (TransferRequestPacket)pack; LLUUID id = new LLUUID( tran.TransferInfo.Params, 0 ); - if( ( id == new LLUUID( "66c41e39-38f9-f75a-024e-585989bfab73" ) ) || ( id == new LLUUID( "e0ee49b5a4184df8d3c9a65361fe7f49" ) ) ) { - Asset_Manager.AddRequest( User_info, id, tran ); - } + // if( ( id == new LLUUID( "66c41e39-38f9-f75a-024e-585989bfab73" ) ) || ( id == new LLUUID( "e0ee49b5a4184df8d3c9a65361fe7f49" ) ) ) { + Asset_Manager.AddAssetRequest( User_info, id, tran ); + // } } - if( ( pack.Type == PacketType.StartPingCheck ) ) { + else if( ( pack.Type == PacketType.StartPingCheck ) ) { //reply to pingcheck libsecondlife.Packets.StartPingCheckPacket startp = (libsecondlife.Packets.StartPingCheckPacket)pack; libsecondlife.Packets.CompletePingCheckPacket endping = new CompletePingCheckPacket(); endping.PingID.PingID = startp.PingID.PingID; server.SendPacket( endping, true, User_info ); } - if( pack.Type == PacketType.CompleteAgentMovement ) { + else if( pack.Type == PacketType.CompleteAgentMovement ) { // new client Agent_Manager.AgentJoin( User_info ); } - if( pack.Type == PacketType.RequestImage ) { + else if( pack.Type == PacketType.RequestImage ) { RequestImagePacket image_req = (RequestImagePacket)pack; for( int i = 0; i < image_req.RequestImage.Length; i++ ) { - this.Texture_Manager.AddRequest( User_info, image_req.RequestImage[ i ].Image ); + this.Asset_Manager.AddTextureRequest( User_info, image_req.RequestImage[ i ].Image ); } } - if( pack.Type == PacketType.RegionHandshakeReply ) { + 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); } - if( pack.Type == PacketType.ObjectAdd ) { + 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); } - if( pack.Type == PacketType.ObjectPosition ) { + else if( pack.Type == PacketType.ObjectPosition ) { //System.Console.WriteLine(pack.ToString()); } - if( pack.Type == PacketType.MultipleObjectUpdate ) { + else if( pack.Type == PacketType.MultipleObjectUpdate ) { //System.Console.WriteLine(pack.ToString()); MultipleObjectUpdatePacket mupd = (MultipleObjectUpdatePacket)pack; @@ -185,11 +203,12 @@ namespace OpenSim } } } - if( pack.Type == PacketType.AgentWearablesRequest ) { + else if( pack.Type == PacketType.AgentWearablesRequest ) { Agent_Manager.SendIntialAvatarAppearance( User_info ); } - 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 ); @@ -224,8 +243,7 @@ namespace OpenSim } } } - - if( pack.Type == PacketType.ChatFromViewer ) { + else if( pack.Type == PacketType.ChatFromViewer ) { ChatFromViewerPacket chat = (ChatFromViewerPacket)pack; System.Text.Encoding enc = System.Text.Encoding.ASCII; @@ -252,14 +270,17 @@ namespace OpenSim public void NewUserCallback( User_Agent_info UserInfo ) { 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; + Base=_login.BaseFolder; + Inventory=_login.InventoryFolder; //should get agentid and sessionid so they can be checked. } - Agent_Manager.NewAgent( UserInfo ,first,last); + Agent_Manager.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 @@ -277,7 +298,7 @@ namespace OpenSim void Timer1Tick( object sender, System.EventArgs e ) { this.time++; Agent_Manager.UpdatePositions(); - Texture_Manager.DoWork( time ); + this.Asset_Manager.DoWork( time ); } } public class Logon @@ -286,6 +307,8 @@ namespace OpenSim public string last="User"; public LLUUID Agent; public LLUUID Session; + public LLUUID InventoryFolder; + public LLUUID BaseFolder; public Logon() { diff --git a/Globals.cs b/Globals.cs index 5763b671c8..44dae8244b 100644 --- a/Globals.cs +++ b/Globals.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2007 Michael Wright +Copyright (c) OpenSim project, http://sim.opensecondlife.org/ * Copyright (c) , * All rights reserved. @@ -53,6 +53,7 @@ namespace OpenSim public int IpPort=1000; public bool LoginSever=true; + public ushort LoginServerPort=8080; //public string RegionName= "The Other\0"; //public ulong RegionHandle= 1095113581519872; diff --git a/GridManager.cs b/GridManager.cs index 52ac789cac..c6b7c49a2a 100644 --- a/GridManager.cs +++ b/GridManager.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2007 Michael Wright +Copyright (c) OpenSim project, http://sim.opensecondlife.org/ * Copyright (c) , * All rights reserved. diff --git a/InventoryManager.cs b/InventoryManager.cs new file mode 100644 index 0000000000..bbc340eba5 --- /dev/null +++ b/InventoryManager.cs @@ -0,0 +1,240 @@ +/* +Copyright (c) OpenSim project, http://sim.opensecondlife.org/ + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using libsecondlife; +using libsecondlife.Packets; +using libsecondlife.AssetSystem; +using System.IO; + +namespace OpenSim +{ + /// + /// Description of InventoryManager. + /// + public class InventoryManager + { + private System.Text.Encoding enc = System.Text.Encoding.ASCII; + public Dictionary Folders; + public Dictionary Items; + private Server server; + + /// + /// + /// + /// + public InventoryManager(Server serve) + { + server=serve; + Folders=new Dictionary(); + Items=new Dictionary(); + } + + /// + /// + /// + /// + /// + /// + /// + public LLUUID AddToInventory(User_Agent_info UserInfo, LLUUID FolderID,AssetBase Asset) + { + if(this.Folders.ContainsKey(FolderID)) + { + 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]; + Folder.Items.Add(Item); + return(Item.ItemID); + } + else + { + return(null); + } + } + + /// + /// + /// + /// + /// + /// + public bool CreateNewFolder(User_Agent_info UserInfo, LLUUID NewFolder) + { + InventoryFolder Folder=new InventoryFolder(); + Folder.FolderID=NewFolder; + Folder.OwnerID=UserInfo.AgentID; + this.Folders.Add(Folder.FolderID,Folder); + + return(true); + } + + /// + /// + /// + /// + /// + public void FetchInventoryDescendents(User_Agent_info User_info,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;//User_info.AgentID; + Descend.AgentData.FolderID=FetchDescend.InventoryData.FolderID;//Folder.FolderID;//new LLUUID("4fb2dab6-a987-da66-05ee-96ca82bccbf1"); + 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) + { + + for(int i=0; i Items; + //public List Subfolders; + + public LLUUID FolderID; + public LLUUID OwnerID; + public LLUUID ParentID; + + + public InventoryFolder() + { + Items=new List(); + } + + } + + public class InventoryItem + { + public LLUUID FolderID; + public LLUUID OwnerID; + public LLUUID ItemID; + public LLUUID AssetID; + public LLUUID CreatorID=LLUUID.Zero;//new LLUUID("3d924400-038e-6ad9-920b-cfbb9b40585c"); + public sbyte InvType; + public sbyte Type; + public string Name; + public string Description; + + public InventoryItem() + { + + } + } +} diff --git a/Login_manager.cs b/Login_manager.cs index a41bde3b3b..c8251b6cf9 100644 --- a/Login_manager.cs +++ b/Login_manager.cs @@ -1,6 +1,5 @@ -/*Copyright (c) 2007 Michael Wright - -* Copyright (c) , +/* +* Copyright (c) OpenSim project, http://sim.opensecondlife.org/> * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -34,6 +33,7 @@ using System.Text; using System.Text.RegularExpressions; using System.Threading; using System.Collections; +using System.Xml; using libsecondlife; namespace OpenSim @@ -48,7 +48,7 @@ namespace OpenSim Login=login; } public Logon Login; - public ushort loginPort = 8080; + public ushort loginPort = Globals.Instance.LoginServerPort; public IPAddress clientAddress = IPAddress.Loopback; public IPAddress remoteAddress = IPAddress.Any; private Socket loginServer; @@ -128,7 +128,7 @@ namespace OpenSim // read the HTTP body into a buffer char[] content = new char[contentLength]; reader.Read(content, 0, contentLength); - // System.Text.Encoding enc = System.Text.Encoding.ASCII; + //System.Text.Encoding enc = System.Text.Encoding.ASCII; XmlRpcRequest request = (XmlRpcRequest)(new XmlRpcRequestDeserializer()).Deserialize(new String(content)); Hashtable requestData = (Hashtable)request.Params[0]; @@ -162,6 +162,41 @@ namespace OpenSim int SessionRand=this.RandomClass.Next(1,999); Session=new LLUUID("aaaabbbb-8932-"+SessionRand.ToString("0000")+"-8664-58f53e442797"); + + StreamReader SR; + string ResponseString=""; + string lines; + SR=File.OpenText("new-login.dat"); + + lines=SR.ReadLine(); + + while(lines!="end-mfile") + { + + 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(); + + ArrayList InventoryRoot=(ArrayList) responseData["inventory-root"]; + Hashtable Inventoryroot=(Hashtable)InventoryRoot[0]; + Inventoryroot["folder_id"]=InventoryFolderID.ToStringHyphenated(); + + //copy data to login object lock(Login) { @@ -169,38 +204,18 @@ namespace OpenSim Login.last=last; Login.Agent=Agent; Login.Session=Session; + Login.BaseFolder=BaseFolderID; + Login.InventoryFolder=InventoryFolderID; } - + // forward the XML-RPC response to the client writer.WriteLine("HTTP/1.0 200 OK"); writer.WriteLine("Content-type: text/xml"); writer.WriteLine(); - - StreamReader SR; - string lines; - SR=File.OpenText("login.dat"); - lines=SR.ReadLine(); - writer.WriteLine(lines); - - lines=SR.ReadLine(); - //lines="session_id"+Agent.ToString()+""; - lines="session_id99998888-"+AgentRand.ToString("0000")+"-4f52-8ec1-0b1d5cd6aead"; - writer.WriteLine(lines); - lines=SR.ReadLine(); - writer.WriteLine(lines); - lines=SR.ReadLine(); - //lines="agent_id"+Session.ToString()+""; - lines="agent_idaaaabbbb-8932-"+SessionRand.ToString("0000")+"-8664-58f53e442797"; - writer.WriteLine(lines); - lines=SR.ReadLine(); - - while(lines!="end-mfile") - { - writer.WriteLine(lines); - lines=SR.ReadLine(); - } - SR.Close(); + XmlTextWriter responseWriter = new XmlTextWriter(writer); + XmlRpcResponseSerializer.Singleton.Serialize(responseWriter, response); + responseWriter.Close(); } } } diff --git a/Physics_manager.cs b/Physics_manager.cs index 82b581c413..17f3340654 100644 --- a/Physics_manager.cs +++ b/Physics_manager.cs @@ -1,7 +1,5 @@ /* -Copyright (c) 2007 Michael Wright - -* Copyright (c) , +Copyright (c) OpenSim project, http://sim.opensecondlife.org/ * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/Prim_manager.cs b/Prim_manager.cs index 1dc075b99a..56eccfc6dd 100644 --- a/Prim_manager.cs +++ b/Prim_manager.cs @@ -1,7 +1,5 @@ /* -Copyright (c) 2007 Michael Wright - -* Copyright (c) , +Copyright (c) OpenSim project, http://sim.opensecondlife.org/ * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/SceneGraphManager.cs b/SceneGraphManager.cs new file mode 100644 index 0000000000..739eccb7e8 --- /dev/null +++ b/SceneGraphManager.cs @@ -0,0 +1,40 @@ +/* +Copyright (c) OpenSim project, http://sim.opensecondlife.org/ +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +using System; + +namespace OpenSim +{ + /// + /// Description of SceneGraphManager. + /// + public class SceneGraphManager + { + public SceneGraphManager() + { + } + } +} diff --git a/Script_manager.cs b/Script_manager.cs index 354247b9c4..87a32d06bc 100644 --- a/Script_manager.cs +++ b/Script_manager.cs @@ -1,7 +1,5 @@ /* - * Copyright (c) 2007 Michael Wright - -* Copyright (c) , + Copyright (c) OpenSim project, http://sim.opensecondlife.org/ * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/Second-server.csproj b/Second-server.csproj index bb1c558dbb..5f626d36d4 100644 --- a/Second-server.csproj +++ b/Second-server.csproj @@ -45,15 +45,16 @@ - - + + + \ No newline at end of file diff --git a/StorageManager.cs b/StorageManager.cs index 2c6b7e0281..596e4e677d 100644 --- a/StorageManager.cs +++ b/StorageManager.cs @@ -1,7 +1,5 @@ /* -Copyright (c) 2007 Michael Wright - -* Copyright (c) , +Copyright (c) OpenSim project, http://sim.opensecondlife.org/ * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/Texture_manager.cs b/Texture_manager.cs index 7177cb6c0b..daf14528d7 100644 --- a/Texture_manager.cs +++ b/Texture_manager.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2007 Michael Wright +Copyright (c) OpenSim project, http://sim.opensecondlife.org/ * Copyright (c) , * All rights reserved. @@ -165,6 +165,7 @@ namespace OpenSim TextureImage im=new TextureImage(); im.filename="testpic2.jp2"; im.Full_ID=new LLUUID("00000000-0000-0000-5005-000000000005"); + im.Name="test Texture"; this.LoadImage(im); this.textures.Add(im.Full_ID,im); @@ -219,11 +220,11 @@ namespace OpenSim } } - public class TextureImage + public class TextureImage: AssetBase { - public byte[] data; - public LLUUID Full_ID; - public string name; + //public byte[] data; + //public LLUUID Full_ID; + //public string name; public string filename; public bool loaded; public ulong last_used; //need to add a tick/time counter and keep record diff --git a/bin/Release/new-login.dat b/bin/Release/new-login.dat new file mode 100644 index 0000000000..48335335ab --- /dev/null +++ b/bin/Release/new-login.dat @@ -0,0 +1,2 @@ +messageWelcome to OpenSimsession_id99998888-8520-4f52-8ec1-0b1d5cd6aeadinventory-skel-libsim_port1000agent_accessMevent_notificationsstart_locationlastglobal-texturessun_texture_idcce0f112-878f-4586-a2e2-a8f104bba271cloud_texture_idfc4b9f0b-d008-45c6-96a4-01dd947ac621moon_texture_idd07f6eed-b96a-47cd-b51d-400ad4a1c428seconds_since_epoch1169908672first_name"Test"circuit_code50633318event_categorieslogin-flagsstipend_since_loginNever_logged_inYgenderedYdaylight_savingsNseed_capabilityhome{'region_handle':[r258560, r259840], 'position':[r41.6589, r100.8374, r22.5072], 'look_at':[r-0.57343, r-0.819255,r0]}secure_session_id71810f75-7437-49fb-8963-02b8fd1b95bflast_nameUserui-configallow_first_lifeYclassified_categoriescategory_nameShoppingcategory_id1category_nameLand Rentalcategory_id2category_nameProperty Rentalcategory_id3category_nameSpecial Attractioncategory_id4category_nameNew Productscategory_id5category_nameEmploymentcategory_id6category_nameWantedcategory_id7category_nameServicecategory_id8category_namePersonalcategory_id9region_x255232inventory-skeletonnameMy Inventoryparent_id00000000-0000-0000-0000-000000000000version4type_default8folder_idf798e114-c10f-409b-a90d-a11577ff1de8nameTexturesparent_idf798e114-c10f-409b-a90d-a11577ff1de8version1type_default0folder_idfc8b4059-30bb-43a8-a042-46f5b431ad82sim_ip127.0.0.1region_y254976gesturesinventory-lib-ownerinventory-rootfolder_idf798e114-c10f-409b-a90d-a11577ff1de8logintruelook_at[r0.99949799999999999756,r0.03166859999999999814,r0]agent_idaaaabbbb-8932-0271-8664-58f53e442797inventory-lib-rootinitial-outfitfolder_nameNightclub Femalegenderfemale +end-mfile \ No newline at end of file