Added Basic Inventory support
parent
f21990ea06
commit
3a157273da
|
@ -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
|
|||
/// <param name="first"></param>
|
||||
/// <param name="last"></param>
|
||||
/// <returns></returns>
|
||||
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
|
|||
/// <param name="user"></param>
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
|
@ -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()
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -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 <organization> 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 <copyright holder> ``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 <copyright holder> 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
|
||||
{
|
||||
/// <summary>
|
||||
/// Asset and Image management
|
||||
/// </summary>
|
||||
public class AssetManagement
|
||||
{
|
||||
public Dictionary<libsecondlife.LLUUID,AssetInfo> Assets;
|
||||
public Dictionary<libsecondlife.LLUUID,TextureImage> 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;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="server"></param>
|
||||
public AssetManagement(Server server)
|
||||
{
|
||||
this.server=server;
|
||||
Textures=new Dictionary<libsecondlife.LLUUID,TextureImage> ();
|
||||
Assets=new Dictionary<libsecondlife.LLUUID,AssetInfo> ();
|
||||
this.initialise();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="UserInfo"></param>
|
||||
/// <param name="AssetID"></param>
|
||||
/// <param name="TransferRequest"></param>
|
||||
#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<num; i++)
|
||||
{
|
||||
req=(TextureRequest)this.TextureRequests[i];
|
||||
|
||||
if(req.packet_counter==0)
|
||||
{
|
||||
//first time for this request so send imagedata packet
|
||||
if(req.num_packets==1)
|
||||
{
|
||||
//only one packet so send whole file
|
||||
ImageDataPacket im=new ImageDataPacket();
|
||||
im.ImageID.Packets=1;
|
||||
im.ImageID.ID=req.image_info.Full_ID;
|
||||
im.ImageID.Size=(uint)req.image_info.data.Length;
|
||||
im.ImageData.Data=req.image_info.data;
|
||||
im.ImageID.Codec=2;
|
||||
server.SendPacket(im,true,req.RequestUser);
|
||||
req.packet_counter++;
|
||||
req.image_info.last_used=time;
|
||||
System.Console.WriteLine("sent texture: "+req.image_info.Full_ID);
|
||||
}
|
||||
else
|
||||
{
|
||||
//more than one packet so split file up
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//send imagepacket
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//remove requests that have been completed
|
||||
for(int i=0; i<num; i++)
|
||||
{
|
||||
req=(TextureRequest)this.TextureRequests[i];
|
||||
if(req.packet_counter==req.num_packets)
|
||||
{
|
||||
this.TextureRequests.Remove(req);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void RecieveTexture(Packet pack)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void LoadImage(TextureImage im)
|
||||
{
|
||||
//should request Image from StorageManager
|
||||
//but for now read from file
|
||||
|
||||
string data_path=System.AppDomain.CurrentDomain.BaseDirectory + @"\textures\";
|
||||
string filename=data_path+@im.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();
|
||||
im.data=idata;
|
||||
im.loaded=true;
|
||||
}
|
||||
|
||||
public TextureImage CloneImage(LLUUID NewOwner,TextureImage Source)
|
||||
{
|
||||
TextureImage NewImage=new TextureImage();
|
||||
NewImage.data=new byte[Source.data.Length];
|
||||
Array.Copy(Source.data,NewImage.data,Source.data.Length);
|
||||
NewImage.filename=Source.filename;
|
||||
NewImage.Full_ID=LLUUID.Random();
|
||||
NewImage.Name=Source.Name;
|
||||
return(NewImage);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
public class AssetRequest
|
||||
{
|
||||
public User_Agent_info RequestUser;
|
||||
public LLUUID RequestImage;
|
||||
public AssetInfo asset_inf;
|
||||
public long data_pointer=0;
|
||||
public int num_packets=0;
|
||||
public int packet_counter=0;
|
||||
|
||||
public AssetRequest()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
public class AssetInfo:AssetBase
|
||||
{
|
||||
//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
|
||||
// of how often images are requested to unload unused ones.
|
||||
|
||||
public AssetInfo()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public class AssetBase
|
||||
{
|
||||
public byte[] data;
|
||||
public LLUUID Full_ID;
|
||||
public sbyte Type;
|
||||
public sbyte InvType;
|
||||
public string Name;
|
||||
public string Description;
|
||||
|
||||
public AssetBase()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
public class TextureRequest
|
||||
{
|
||||
public User_Agent_info RequestUser;
|
||||
public LLUUID RequestImage;
|
||||
public TextureImage image_info;
|
||||
public long data_pointer=0;
|
||||
public int num_packets=0;
|
||||
public int packet_counter=0;
|
||||
|
||||
public TextureRequest()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
public class TextureImage: AssetBase
|
||||
{
|
||||
//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
|
||||
// of how often images are requested to unload unused ones.
|
||||
|
||||
public TextureImage()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (c) 2007 Michael Wright
|
||||
Copyright (c) OpenSim project, http://sim.opensecondlife.org/
|
||||
|
||||
* Copyright (c) <year>, <copyright holder>
|
||||
* 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()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
Copyright (c) 2007 Michael Wright
|
||||
Copyright (c) OpenSim project, http://sim.opensecondlife.org/
|
||||
|
||||
|
||||
* Copyright (c) <year>, <copyright holder>
|
||||
* 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()
|
||||
{
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (c) 2007 Michael Wright
|
||||
Copyright (c) OpenSim project, http://sim.opensecondlife.org/
|
||||
|
||||
* Copyright (c) <year>, <copyright holder>
|
||||
* 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;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (c) 2007 Michael Wright
|
||||
Copyright (c) OpenSim project, http://sim.opensecondlife.org/
|
||||
|
||||
* Copyright (c) <year>, <copyright holder>
|
||||
* All rights reserved.
|
||||
|
|
|
@ -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 <organization> 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 <copyright holder> ``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 <copyright holder> 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
|
||||
{
|
||||
/// <summary>
|
||||
/// Description of InventoryManager.
|
||||
/// </summary>
|
||||
public class InventoryManager
|
||||
{
|
||||
private System.Text.Encoding enc = System.Text.Encoding.ASCII;
|
||||
public Dictionary<LLUUID, InventoryFolder> Folders;
|
||||
public Dictionary<LLUUID, InventoryItem> Items;
|
||||
private Server server;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="serve"></param>
|
||||
public InventoryManager(Server serve)
|
||||
{
|
||||
server=serve;
|
||||
Folders=new Dictionary<LLUUID, InventoryFolder>();
|
||||
Items=new Dictionary<LLUUID, InventoryItem>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="UserInfo"></param>
|
||||
/// <param name="FolderID"></param>
|
||||
/// <param name="Asset"></param>
|
||||
/// <returns></returns>
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="UserInfo"></param>
|
||||
/// <param name="NewFolder"></param>
|
||||
/// <returns></returns>
|
||||
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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="User_info"></param>
|
||||
/// <param name="FetchDescend"></param>
|
||||
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<Folder.Items.Count ; i++)
|
||||
{
|
||||
|
||||
InventoryItem Item=Folder.Items[i];
|
||||
Descend.ItemData[i]=new InventoryDescendentsPacket.ItemDataBlock();
|
||||
Descend.ItemData[i].ItemID=Item.ItemID;//new LLUUID("b7878441893b094917f791174bc8401c");
|
||||
Descend.ItemData[i].AssetID=Item.AssetID;//new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73");
|
||||
Descend.ItemData[i].CreatorID=Item.CreatorID;//User_info.AgentID;
|
||||
Descend.ItemData[i].BaseMask=2147483647;
|
||||
Descend.ItemData[i].CreationDate=1000;
|
||||
Descend.ItemData[i].Description=enc.GetBytes(Item.Description+"\0");
|
||||
Descend.ItemData[i].EveryoneMask=2147483647;;
|
||||
Descend.ItemData[i].Flags=1;
|
||||
Descend.ItemData[i].FolderID=Item.FolderID;//new LLUUID("4fb2dab6-a987-da66-05ee-96ca82bccbf1");
|
||||
Descend.ItemData[i].GroupID=new LLUUID("00000000-0000-0000-0000-000000000000");
|
||||
Descend.ItemData[i].GroupMask=2147483647;
|
||||
Descend.ItemData[i].InvType=Item.InvType;
|
||||
Descend.ItemData[i].Name=enc.GetBytes(Item.Name+"\0");
|
||||
Descend.ItemData[i].NextOwnerMask=2147483647;
|
||||
Descend.ItemData[i].OwnerID=Item.OwnerID;//User_info.AgentID;
|
||||
Descend.ItemData[i].OwnerMask=2147483647;;
|
||||
Descend.ItemData[i].SalePrice=100;
|
||||
Descend.ItemData[i].SaleType=0;
|
||||
Descend.ItemData[i].Type=Item.Type;//libsecondlife.AssetSystem.Asset.ASSET_TYPE_WEARABLE_BODY;
|
||||
Descend.ItemData[i].CRC=libsecondlife.Helpers.InventoryCRC(1000,0,Descend.ItemData[i].InvType,Descend.ItemData[i].Type,Descend.ItemData[i].AssetID ,Descend.ItemData[i].GroupID,100,Descend.ItemData[i].OwnerID,Descend.ItemData[i].CreatorID,Descend.ItemData[i].ItemID,Descend.ItemData[i].FolderID,2147483647,1,2147483647,2147483647,2147483647);
|
||||
}
|
||||
server.SendPacket(Descend,true,User_info);
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("fetch subfolders");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="User_info"></param>
|
||||
public void FetchInventory(User_Agent_info User_info, FetchInventoryPacket FetchItems)
|
||||
{
|
||||
|
||||
for(int i=0; i<FetchItems.InventoryData.Length; i++)
|
||||
{
|
||||
if(this.Items.ContainsKey(FetchItems.InventoryData[i].ItemID))
|
||||
{
|
||||
|
||||
InventoryItem Item=Items[FetchItems.InventoryData[i].ItemID];
|
||||
FetchInventoryReplyPacket InventoryReply=new FetchInventoryReplyPacket();
|
||||
InventoryReply.AgentData.AgentID=User_info.AgentID;
|
||||
InventoryReply.InventoryData=new FetchInventoryReplyPacket.InventoryDataBlock[1];
|
||||
InventoryReply.InventoryData[0]=new FetchInventoryReplyPacket.InventoryDataBlock();
|
||||
InventoryReply.InventoryData[0].ItemID=Item.ItemID;//new LLUUID("b7878441893b094917f791174bc8401c");
|
||||
InventoryReply.InventoryData[0].AssetID=Item.AssetID;//new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73");
|
||||
InventoryReply.InventoryData[0].CreatorID=Item.CreatorID;//User_info.AgentID;
|
||||
InventoryReply.InventoryData[0].BaseMask=2147483647;
|
||||
InventoryReply.InventoryData[0].CreationDate=1000;
|
||||
InventoryReply.InventoryData[0].Description=enc.GetBytes( Item.Description+"\0");
|
||||
InventoryReply.InventoryData[0].EveryoneMask=2147483647;;
|
||||
InventoryReply.InventoryData[0].Flags=1;
|
||||
InventoryReply.InventoryData[0].FolderID=Item.FolderID;//new LLUUID("4fb2dab6-a987-da66-05ee-96ca82bccbf1");
|
||||
InventoryReply.InventoryData[0].GroupID=new LLUUID("00000000-0000-0000-0000-000000000000");
|
||||
InventoryReply.InventoryData[0].GroupMask=2147483647;
|
||||
InventoryReply.InventoryData[0].InvType=Item.InvType;
|
||||
InventoryReply.InventoryData[0].Name=enc.GetBytes(Item.Name+"\0");
|
||||
InventoryReply.InventoryData[0].NextOwnerMask=2147483647;
|
||||
InventoryReply.InventoryData[0].OwnerID=Item.OwnerID;//User_info.AgentID;
|
||||
InventoryReply.InventoryData[0].OwnerMask=2147483647;;
|
||||
InventoryReply.InventoryData[0].SalePrice=100;
|
||||
InventoryReply.InventoryData[0].SaleType=0;
|
||||
InventoryReply.InventoryData[0].Type=Item.Type;//libsecondlife.AssetSystem.Asset.ASSET_TYPE_WEARABLE_BODY;
|
||||
InventoryReply.InventoryData[0].CRC=libsecondlife.Helpers.InventoryCRC(1000,0,InventoryReply.InventoryData[0].InvType,InventoryReply.InventoryData[0].Type,InventoryReply.InventoryData[0].AssetID ,InventoryReply.InventoryData[0].GroupID,100,InventoryReply.InventoryData[0].OwnerID,InventoryReply.InventoryData[0].CreatorID,InventoryReply.InventoryData[0].ItemID,InventoryReply.InventoryData[0].FolderID,2147483647,1,2147483647,2147483647,2147483647);
|
||||
server.SendPacket(InventoryReply,true,User_info);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class InventoryFolder
|
||||
{
|
||||
public List<InventoryItem> Items;
|
||||
//public List<InventoryFolder> Subfolders;
|
||||
|
||||
public LLUUID FolderID;
|
||||
public LLUUID OwnerID;
|
||||
public LLUUID ParentID;
|
||||
|
||||
|
||||
public InventoryFolder()
|
||||
{
|
||||
Items=new List<InventoryItem>();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,6 +1,5 @@
|
|||
/*Copyright (c) 2007 Michael Wright
|
||||
|
||||
* Copyright (c) <year>, <copyright holder>
|
||||
/*
|
||||
* 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,6 +204,8 @@ 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
|
||||
|
@ -176,31 +213,9 @@ namespace OpenSim
|
|||
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="<member><name>session_id</name><value><string>"+Agent.ToString()+"</string></value></member>";
|
||||
lines="<member><name>session_id</name><value><string>99998888-"+AgentRand.ToString("0000")+"-4f52-8ec1-0b1d5cd6aead</string></value></member>";
|
||||
writer.WriteLine(lines);
|
||||
lines=SR.ReadLine();
|
||||
writer.WriteLine(lines);
|
||||
lines=SR.ReadLine();
|
||||
//lines="<member><name>agent_id</name><value><string>"+Session.ToString()+"</string></value></member>";
|
||||
lines="<member><name>agent_id</name><value><string>aaaabbbb-8932-"+SessionRand.ToString("0000")+"-8664-58f53e442797</string></value></member>";
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
/*
|
||||
Copyright (c) 2007 Michael Wright
|
||||
|
||||
* Copyright (c) <year>, <copyright holder>
|
||||
Copyright (c) OpenSim project, http://sim.opensecondlife.org/
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
/*
|
||||
Copyright (c) 2007 Michael Wright
|
||||
|
||||
* Copyright (c) <year>, <copyright holder>
|
||||
Copyright (c) OpenSim project, http://sim.opensecondlife.org/
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
|
|
@ -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 <organization> 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 <copyright holder> ``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 <copyright holder> 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
|
||||
{
|
||||
/// <summary>
|
||||
/// Description of SceneGraphManager.
|
||||
/// </summary>
|
||||
public class SceneGraphManager
|
||||
{
|
||||
public SceneGraphManager()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,7 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2007 Michael Wright
|
||||
|
||||
* Copyright (c) <year>, <copyright holder>
|
||||
Copyright (c) OpenSim project, http://sim.opensecondlife.org/
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
|
|
@ -45,15 +45,16 @@
|
|||
<Compile Include="Agent_Manager.cs" />
|
||||
<Compile Include="Controller.cs" />
|
||||
<Compile Include="Prim_manager.cs" />
|
||||
<Compile Include="Texture_manager.cs" />
|
||||
<Compile Include="Login_manager.cs" />
|
||||
<Compile Include="Physics_manager.cs" />
|
||||
<Compile Include="Asset_manager.cs" />
|
||||
<Compile Include="Script_manager.cs" />
|
||||
<Compile Include="Server.cs" />
|
||||
<Compile Include="StorageManager.cs" />
|
||||
<Compile Include="GridManager.cs" />
|
||||
<Compile Include="Globals.cs" />
|
||||
<Compile Include="InventoryManager.cs" />
|
||||
<Compile Include="SceneGraphManager.cs" />
|
||||
<Compile Include="AssetManagement.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
|
||||
</Project>
|
|
@ -1,7 +1,5 @@
|
|||
/*
|
||||
Copyright (c) 2007 Michael Wright
|
||||
|
||||
* Copyright (c) <year>, <copyright holder>
|
||||
Copyright (c) OpenSim project, http://sim.opensecondlife.org/
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (c) 2007 Michael Wright
|
||||
Copyright (c) OpenSim project, http://sim.opensecondlife.org/
|
||||
|
||||
* Copyright (c) <year>, <copyright holder>
|
||||
* 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
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue