Clean up. Added GridManager and teleport between regions/sims.

brokenplugins
MW 2007-02-02 17:23:56 +00:00
parent f5398c7260
commit e75e6f426b
11 changed files with 733 additions and 450 deletions

View File

@ -32,122 +32,173 @@ using libsecondlife.AssetSystem;
using System.IO; using System.IO;
using Axiom.MathLib; using Axiom.MathLib;
namespace Second_server namespace OpenSim
{ {
/// <summary> /// <summary>
/// Description of Agent_Manager. /// Description of Agent_Manager.
/// </summary> /// </summary>
public class Agent_Manager public class AgentManager
{ {
public Dictionary<libsecondlife.LLUUID,Avatar_data> Agent_list; public Dictionary<libsecondlife.LLUUID,AvatarData> AgentList;
//public uint number_agents=0;
private uint local_numer=0; private uint local_numer=0;
private Server server; private Server server;
public Prim_manager prim_man; public PrimManager Prim_Manager;
private byte [] data1;
private libsecondlife.Packets.RegionHandshakePacket reg; private libsecondlife.Packets.RegionHandshakePacket RegionPacket;
private System.Text.Encoding enc = System.Text.Encoding.ASCII; private System.Text.Encoding enc = System.Text.Encoding.ASCII;
public libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock avatar_template; public libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock AvatarTemplate;
//private int appc=0;
public Agent_Manager(Server serve) /// <summary>
///
/// </summary>
/// <param name="serve"></param>
public AgentManager(Server serve)
{ {
Agent_list=new Dictionary<libsecondlife.LLUUID,Avatar_data>(); AgentList=new Dictionary<libsecondlife.LLUUID,AvatarData>();
server=serve; server=serve;
this.initialise(); this.initialise();
} }
//***************************************************
public Avatar_data Get_Agent(LLUUID id) /// <summary>
///
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public AvatarData GetAgent(LLUUID id)
{ {
if(!this.AgentList.ContainsKey(id))
if(!this.Agent_list.ContainsKey(id))
{ {
return null; return null;
} }
else else
{ {
Avatar_data ad=this.Agent_list[id]; AvatarData ad=this.AgentList[id];
return ad; return ad;
} }
} }
/// <summary>
public void Add_Agent(Avatar_data agent) ///
/// </summary>
/// <param name="agent"></param>
public void AddAgent(AvatarData agent)
{ {
this.Agent_list.Add(agent.Full_ID,agent); this.AgentList.Add(agent.FullID,agent);
} }
/// <summary>
///
/// </summary>
/// <param name="User_info"></param>
/// <param name="first"></param>
/// <param name="last"></param>
/// <returns></returns>
///
public bool New_Agent(User_Agent_info User_info) /// <summary>
///
/// </summary>
/// <param name="User_info"></param>
/// <param name="first"></param>
/// <param name="last"></param>
/// <returns></returns>
public bool NewAgent(User_Agent_info User_info, string first, string last)
{ {
Avatar_data ad=new Avatar_data(); AvatarData agent=new AvatarData();
ad.Full_ID=User_info.AgentID; agent.FullID=User_info.AgentID;
ad.Net_info=User_info; agent.NetInfo=User_info;
ad.pos=new LLVector3(100,100,22); agent.NetInfo.first_name=first;
this.Agent_list.Add(ad.Full_ID,ad); agent.NetInfo.last_name=last;
agent.Position=new LLVector3(100,100,22);
this.AgentList.Add(agent.FullID,agent);
return(true); return(true);
} }
public void Agent_join(User_Agent_info User_info) /// <summary>
///
/// </summary>
/// <param name="UserInfo"></param>
public void RemoveAgent(User_Agent_info UserInfo)
{
this.AgentList.Remove(UserInfo.AgentID);
//tell other clients to delete this avatar
}
/// <summary>
///
/// </summary>
/// <param name="User_info"></param>
public void AgentJoin(User_Agent_info User_info)
{ {
//send region data //send region data
server.SendPacket(reg,true,User_info); server.SendPacket(RegionPacket,true,User_info);
//inform client of join comlete //inform client of join comlete
libsecondlife.Packets.AgentMovementCompletePacket mov=new AgentMovementCompletePacket(); libsecondlife.Packets.AgentMovementCompletePacket mov=new AgentMovementCompletePacket();
mov.AgentData.SessionID=User_info.SessionID; mov.AgentData.SessionID=User_info.SessionID;
mov.AgentData.AgentID=User_info.AgentID; mov.AgentData.AgentID=User_info.AgentID;
mov.Data.RegionHandle=1096213093147648; mov.Data.RegionHandle=Globals.Instance.RegionHandle;
mov.Data.Timestamp=1169838966; mov.Data.Timestamp=1169838966;
mov.Data.Position=new LLVector3(100f,100f,22f); mov.Data.Position=new LLVector3(100f,100f,22f);
mov.Data.LookAt=new LLVector3(0.99f,0.042f,0); mov.Data.LookAt=new LLVector3(0.99f,0.042f,0);
server.SendPacket(mov,true,User_info); server.SendPacket(mov,true,User_info);
} }
public void tick()
/// <summary>
///
/// </summary>
public void UpdatePositions()
{ {
//update positions //update positions
foreach (KeyValuePair<libsecondlife.LLUUID,Avatar_data> kp in this.Agent_list) foreach (KeyValuePair<libsecondlife.LLUUID,AvatarData> kp in this.AgentList)
{ {
kp.Value.pos.X+=(kp.Value.vel.X*0.2f); kp.Value.Position.X+=(kp.Value.Velocity.X*0.2f);
kp.Value.pos.Y+=(kp.Value.vel.Y*0.2f); kp.Value.Position.Y+=(kp.Value.Velocity.Y*0.2f);
kp.Value.pos.Z+=(kp.Value.vel.Z*0.2f); kp.Value.Position.Z+=(kp.Value.Velocity.Z*0.2f);
} }
} }
//**************************************************************
/// <summary>
///
/// </summary>
private void initialise() private void initialise()
{ {
//Region data //Region data
reg=new RegionHandshakePacket(); RegionPacket=new RegionHandshakePacket();
reg.RegionInfo.BillableFactor=0; RegionPacket.RegionInfo.BillableFactor=0;
reg.RegionInfo.IsEstateManager=false; RegionPacket.RegionInfo.IsEstateManager=false;
reg.RegionInfo.TerrainHeightRange00=60; RegionPacket.RegionInfo.TerrainHeightRange00=60;
reg.RegionInfo.TerrainHeightRange01=60; RegionPacket.RegionInfo.TerrainHeightRange01=60;
reg.RegionInfo.TerrainHeightRange10=60; RegionPacket.RegionInfo.TerrainHeightRange10=60;
reg.RegionInfo.TerrainHeightRange11=60; RegionPacket.RegionInfo.TerrainHeightRange11=60;
reg.RegionInfo.TerrainStartHeight00=20; RegionPacket.RegionInfo.TerrainStartHeight00=20;
reg.RegionInfo.TerrainStartHeight01=20; RegionPacket.RegionInfo.TerrainStartHeight01=20;
reg.RegionInfo.TerrainStartHeight10=20; RegionPacket.RegionInfo.TerrainStartHeight10=20;
reg.RegionInfo.TerrainStartHeight11=20; RegionPacket.RegionInfo.TerrainStartHeight11=20;
reg.RegionInfo.SimAccess=13; RegionPacket.RegionInfo.SimAccess=13;
reg.RegionInfo.WaterHeight=5; RegionPacket.RegionInfo.WaterHeight=5;
reg.RegionInfo.RegionFlags=72458694; RegionPacket.RegionInfo.RegionFlags=72458694;
reg.RegionInfo.SimName=enc.GetBytes( "Test Sandbox\0"); RegionPacket.RegionInfo.SimName=enc.GetBytes( Globals.Instance.RegionName);
reg.RegionInfo.SimOwner=new LLUUID("00000000-0000-0000-0000-000000000000"); RegionPacket.RegionInfo.SimOwner=new LLUUID("00000000-0000-0000-0000-000000000000");
reg.RegionInfo.TerrainBase0=new LLUUID("b8d3965a-ad78-bf43-699b-bff8eca6c975"); RegionPacket.RegionInfo.TerrainBase0=new LLUUID("b8d3965a-ad78-bf43-699b-bff8eca6c975");
reg.RegionInfo.TerrainBase1=new LLUUID("abb783e6-3e93-26c0-248a-247666855da3"); RegionPacket.RegionInfo.TerrainBase1=new LLUUID("abb783e6-3e93-26c0-248a-247666855da3");
reg.RegionInfo.TerrainBase2=new LLUUID("179cdabd-398a-9b6b-1391-4dc333ba321f"); RegionPacket.RegionInfo.TerrainBase2=new LLUUID("179cdabd-398a-9b6b-1391-4dc333ba321f");
reg.RegionInfo.TerrainBase3=new LLUUID("beb169c7-11ea-fff2-efe5-0f24dc881df2"); RegionPacket.RegionInfo.TerrainBase3=new LLUUID("beb169c7-11ea-fff2-efe5-0f24dc881df2");
reg.RegionInfo.TerrainDetail0=new LLUUID("00000000-0000-0000-0000-000000000000"); RegionPacket.RegionInfo.TerrainDetail0=new LLUUID("00000000-0000-0000-0000-000000000000");
reg.RegionInfo.TerrainDetail1=new LLUUID("00000000-0000-0000-0000-000000000000"); RegionPacket.RegionInfo.TerrainDetail1=new LLUUID("00000000-0000-0000-0000-000000000000");
reg.RegionInfo.TerrainDetail2=new LLUUID("00000000-0000-0000-0000-000000000000"); RegionPacket.RegionInfo.TerrainDetail2=new LLUUID("00000000-0000-0000-0000-000000000000");
reg.RegionInfo.TerrainDetail3=new LLUUID("00000000-0000-0000-0000-000000000000"); RegionPacket.RegionInfo.TerrainDetail3=new LLUUID("00000000-0000-0000-0000-000000000000");
reg.RegionInfo.CacheID=new LLUUID("545ec0a5-5751-1026-8a0b-216e38a7ab33"); RegionPacket.RegionInfo.CacheID=new LLUUID("545ec0a5-5751-1026-8a0b-216e38a7ab37");
this.setuptemplate("objectupate168.dat"); this.SetupTemplate("objectupate168.dat");
} }
public void setuptemplate(string name) /// <summary>
///
/// </summary>
/// <param name="name"></param>
private void SetupTemplate(string name)
{ {
/*ObjectUpdatePacket objupdate=new ObjectUpdatePacket(); /*ObjectUpdatePacket objupdate=new ObjectUpdatePacket();
objupdate.RegionData.RegionHandle=1096213093147648; objupdate.RegionData.RegionHandle=1096213093147648;
@ -184,95 +235,87 @@ namespace Second_server
Array.Copy(pb,0,objdata.ObjectData,16,pb.Length); Array.Copy(pb,0,objdata.ObjectData,16,pb.Length);
avatar_template=objdata; AvatarTemplate=objdata;
} }
//**********************************************************
public void send_intial_data(User_Agent_info User_info) /// <summary>
///
/// </summary>
/// <param name="User_info"></param>
public void SendInitialData(User_Agent_info User_info)
{ {
//shouldn't really have to read all this in from disk for every new client? //shouldn't have to read all this in from disk for every new client
string data_path=System.AppDomain.CurrentDomain.BaseDirectory + @"\layer_data\"; string data_path=System.AppDomain.CurrentDomain.BaseDirectory + @"\layer_data\";
//send layerdata //send layerdata
LayerDataPacket layerpack=new LayerDataPacket(); LayerDataPacket layerpack=new LayerDataPacket();
layerpack.LayerID.Type=76; layerpack.LayerID.Type=76;
//layerpack.LayerData.ReadfromFile(data_path+@"layerdata0.dat"); this.SendLayerData(User_info,ref layerpack,data_path+@"layerdata0.dat");
this.read_layerdata(User_info,ref layerpack,data_path+@"layerdata0.dat");
//server.SendPacket(layerpack,true,User_info);
LayerDataPacket layerpack1=new LayerDataPacket(); LayerDataPacket layerpack1=new LayerDataPacket();
layerpack1.LayerID.Type=76; layerpack1.LayerID.Type=76;
//layerpack1.LayerData.ReadfromFile(data_path+@"layerdata1.dat"); this.SendLayerData(User_info,ref layerpack,data_path+@"layerdata1.dat");
this.read_layerdata(User_info,ref layerpack,data_path+@"layerdata1.dat");
//server.SendPacket(layerpack1,true,User_info);
LayerDataPacket layerpack2=new LayerDataPacket(); LayerDataPacket layerpack2=new LayerDataPacket();
layerpack2.LayerID.Type=56; layerpack2.LayerID.Type=56;
//layerpack2.LayerData.ReadfromFile(data_path+@"layerdata2.dat"); this.SendLayerData(User_info,ref layerpack,data_path+@"layerdata2.dat");
this.read_layerdata(User_info,ref layerpack,data_path+@"layerdata2.dat");
//server.SendPacket(layerpack2,true,User_info);
LayerDataPacket layerpack3=new LayerDataPacket(); LayerDataPacket layerpack3=new LayerDataPacket();
layerpack3.LayerID.Type=55; layerpack3.LayerID.Type=55;
//layerpack3.LayerData.ReadfromFile(data_path+@"layerdata3.dat"); this.SendLayerData(User_info,ref layerpack,data_path+@"layerdata3.dat");
this.read_layerdata(User_info,ref layerpack,data_path+@"layerdata3.dat");
//server.SendPacket(layerpack3,true,User_info);
LayerDataPacket layerpack4=new LayerDataPacket(); LayerDataPacket layerpack4=new LayerDataPacket();
layerpack4.LayerID.Type=56; layerpack4.LayerID.Type=56;
//layerpack4.LayerData.ReadfromFile(data_path+@"layerdata4.dat"); this.SendLayerData(User_info,ref layerpack,data_path+@"layerdata4.dat");
this.read_layerdata(User_info,ref layerpack,data_path+@"layerdata4.dat");
//server.SendPacket(layerpack4,true,User_info);
LayerDataPacket layerpack5=new LayerDataPacket(); LayerDataPacket layerpack5=new LayerDataPacket();
layerpack5.LayerID.Type=55; layerpack5.LayerID.Type=55;
//layerpack5.LayerData.ReadfromFile(data_path+@"layerdata5.dat"); this.SendLayerData(User_info,ref layerpack,data_path+@"layerdata5.dat");
this.read_layerdata(User_info,ref layerpack,data_path+@"layerdata5.dat");
//server.SendPacket(layerpack5,true,User_info);
//send intial set of captured prims data? //send intial set of captured prims data?
this.prim_man.Read_Prim_database( "objectdatabase.ini",User_info); this.Prim_Manager.ReadPrimDatabase( "objectdatabase.ini",User_info);
//send prims that have been created by users //send prims that have been created by users
//prim_man.send_existing_prims(User_info); //prim_man.send_existing_prims(User_info);
//send update about clients avatar //send update about clients avatar
this.send_intial_avatar_position(User_info); this.SendInitialAvatarPosition(User_info);
//send updates about all other users //send updates about all other users
//this.send_test_avatar_position(User_info); foreach (KeyValuePair<libsecondlife.LLUUID,AvatarData> kp in this.AgentList)
foreach (KeyValuePair<libsecondlife.LLUUID,Avatar_data> kp in this.Agent_list)
{ {
if(kp.Value.Net_info.AgentID!=User_info.AgentID) if(kp.Value.NetInfo.AgentID!=User_info.AgentID)
{ {
this.send_other_avatar_position(User_info,kp.Value); this.SendOtherAvatarPosition(User_info,kp.Value);
}
} }
} }
/// <summary>
} ///
public void send_intial_avatar_position(User_Agent_info User_info) /// </summary>
/// <param name="User_info"></param>
public void SendInitialAvatarPosition(User_Agent_info User_info)
{ {
//send a objectupdate packet with information about the clients avatar //send a objectupdate packet with information about the clients avatar
ObjectUpdatePacket objupdate=new ObjectUpdatePacket(); ObjectUpdatePacket objupdate=new ObjectUpdatePacket();
objupdate.RegionData.RegionHandle=1096213093147648; objupdate.RegionData.RegionHandle=Globals.Instance.RegionHandle;
objupdate.RegionData.TimeDilation=64096; objupdate.RegionData.TimeDilation=64096;
objupdate.ObjectData=new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1]; objupdate.ObjectData=new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1];
objupdate.ObjectData[0]=avatar_template; objupdate.ObjectData[0]=AvatarTemplate;
//give this avatar object a local id and assign the user a name //give this avatar object a local id and assign the user a name
objupdate.ObjectData[0].ID=8880000+this.local_numer; objupdate.ObjectData[0].ID=8880000+this.local_numer;
User_info.localID=objupdate.ObjectData[0].ID; User_info.localID=objupdate.ObjectData[0].ID;
//User_info.name="Test"+this.local_numer+" User"; //User_info.name="Test"+this.local_numer+" User";
this.Get_Agent(User_info.AgentID).started=true; this.GetAgent(User_info.AgentID).Started=true;
objupdate.ObjectData[0].FullID=User_info.AgentID; objupdate.ObjectData[0].FullID=User_info.AgentID;
objupdate.ObjectData[0].NameValue=enc.GetBytes("FirstName STRING RW SV Test"+ this.local_numer+"\nLastName STRING RW SV User \0"); objupdate.ObjectData[0].NameValue=enc.GetBytes("FirstName STRING RW SV "+User_info.first_name+"\nLastName STRING RW SV "+User_info.last_name+" \0");
User_info.name="FirstName STRING RW SV Test"+ this.local_numer+"\nLastName STRING RW SV User \0"; User_info.name="FirstName STRING RW SV "+User_info.first_name+"\nLastName STRING RW SV "+User_info.last_name+" \0";
User_info.last_name="User"; //User_info.last_name="User";
User_info.first_name="Test"+this.local_numer; //User_info.first_name="Test"+this.local_numer;
libsecondlife.LLVector3 pos2=new LLVector3(100f,100.0f,22.0f); libsecondlife.LLVector3 pos2=new LLVector3(100f,100.0f,22.0f);
byte[] pb=pos2.GetBytes(); byte[] pb=pos2.GetBytes();
@ -283,37 +326,24 @@ namespace Second_server
server.SendPacket(objupdate,true,User_info); server.SendPacket(objupdate,true,User_info);
//send this info to other existing clients //send this info to other existing clients
foreach (KeyValuePair<libsecondlife.LLUUID,Avatar_data> kp in this.Agent_list) foreach (KeyValuePair<libsecondlife.LLUUID,AvatarData> kp in this.AgentList)
{ {
if(kp.Value.Net_info.AgentID!=User_info.AgentID) if(kp.Value.NetInfo.AgentID!=User_info.AgentID)
{ {
server.SendPacket(objupdate,true,kp.Value.Net_info); server.SendPacket(objupdate,true,kp.Value.NetInfo);
this.send_other_apper(kp.Value.Net_info,objupdate.ObjectData[0].FullID); this.SendOtherAppearance(kp.Value.NetInfo,objupdate.ObjectData[0].FullID);
} }
} }
} }
public void send_intial_avatar_apper(User_Agent_info user)
/// <summary>
///
/// </summary>
/// <param name="user"></param>
public void SendIntialAvatarAppearance(User_Agent_info user)
{ {
//seems that we don't send a avatarapperance for ourself.
/*AvatarAppearancePacket avp=new AvatarAppearancePacket();
avp.VisualParam=new AvatarAppearancePacket.VisualParamBlock[218];
avp.ObjectData.TextureEntry=this.avatar_template.TextureEntry;// br.ReadBytes((int)numBytes);
AvatarAppearancePacket.VisualParamBlock avblock=null;
for(int i=0; i<218; i++)
{
avblock=new AvatarAppearancePacket.VisualParamBlock();
avblock.ParamValue=(byte)100;
avp.VisualParam[i]=avblock;
}
avp.Sender.IsTrial=false;
avp.Sender.ID=user.AgentID;
*/
AgentWearablesUpdatePacket aw=new AgentWearablesUpdatePacket(); AgentWearablesUpdatePacket aw=new AgentWearablesUpdatePacket();
aw.AgentData.AgentID=user.AgentID; aw.AgentData.AgentID=user.AgentID;
aw.AgentData.SerialNum=0;//(uint)appc; aw.AgentData.SerialNum=0;//(uint)appc;
@ -325,12 +355,9 @@ namespace Second_server
awb=new AgentWearablesUpdatePacket.WearableDataBlock(); awb=new AgentWearablesUpdatePacket.WearableDataBlock();
awb.WearableType=(byte)0; awb.WearableType=(byte)0;
awb.AssetID=new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73"); awb.AssetID=new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73");
//awb.ItemID=new LLUUID("b7878000-0000-0000-0000-000000000000");
awb.ItemID=new LLUUID("b7878441893b094917f791174bc8401c"); awb.ItemID=new LLUUID("b7878441893b094917f791174bc8401c");
//awb.ItemID=new LLUUID("00000000-0000-0000-0000-000000000000");
aw.WearableData[0]=awb; aw.WearableData[0]=awb;
/*awb=new AgentWearablesUpdatePacket.WearableDataBlock(); /*awb=new AgentWearablesUpdatePacket.WearableDataBlock();
awb.WearableType=(byte)1; awb.WearableType=(byte)1;
awb.AssetID=new LLUUID("e0ee49b5a4184df8d3c9a65361fe7f49"); awb.AssetID=new LLUUID("e0ee49b5a4184df8d3c9a65361fe7f49");
@ -338,7 +365,6 @@ namespace Second_server
//awb.ItemID=new LLUUID("00000000-0000-0000-0000-000000000000"); //awb.ItemID=new LLUUID("00000000-0000-0000-0000-000000000000");
aw.WearableData[1]=awb;*/ aw.WearableData[1]=awb;*/
for(int i=1; i<13; i++) for(int i=1; i<13; i++)
{ {
awb=new AgentWearablesUpdatePacket.WearableDataBlock(); awb=new AgentWearablesUpdatePacket.WearableDataBlock();
@ -348,13 +374,15 @@ namespace Second_server
aw.WearableData[i]=awb; aw.WearableData[i]=awb;
} }
//server.SendPacket(avp,true,user);
server.SendPacket(aw,true,user); server.SendPacket(aw,true,user);
//System.Console.WriteLine(avp);
} }
public void send_other_apper(User_Agent_info user,LLUUID id)
/// <summary>
///
/// </summary>
/// <param name="user"></param>
/// <param name="id"></param>
public void SendOtherAppearance(User_Agent_info user,LLUUID id)
{ {
AvatarAppearancePacket avp=new AvatarAppearancePacket(); AvatarAppearancePacket avp=new AvatarAppearancePacket();
@ -384,21 +412,25 @@ namespace Second_server
server.SendPacket(avp,true,user); server.SendPacket(avp,true,user);
} }
/// <summary>
public void send_test_avatar_position(User_Agent_info User_info) ///
/// </summary>
/// <param name="User_info"></param>
/// <param name="avd"></param>
public void SendOtherAvatarPosition(User_Agent_info User_info, AvatarData avd)
{ {
//send a objectupdate packet with information about the clients avatar //send a objectupdate packet with information about the clients avatar
ObjectUpdatePacket objupdate=new ObjectUpdatePacket(); ObjectUpdatePacket objupdate=new ObjectUpdatePacket();
objupdate.RegionData.RegionHandle=1096213093147648; objupdate.RegionData.RegionHandle=Globals.Instance.RegionHandle;
objupdate.RegionData.TimeDilation=64500; objupdate.RegionData.TimeDilation=64500;
objupdate.ObjectData=new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1]; objupdate.ObjectData=new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1];
objupdate.ObjectData[0]=avatar_template; objupdate.ObjectData[0]=AvatarTemplate;
//give this avatar object a local id and assign the user a name //give this avatar object a local id and assign the user a name
objupdate.ObjectData[0].ID=8880000+this.local_numer; objupdate.ObjectData[0].ID=avd.NetInfo.localID;
objupdate.ObjectData[0].FullID=new LLUUID("00000000-0000-0000-5665-000000000034"); objupdate.ObjectData[0].FullID=avd.NetInfo.AgentID;//new LLUUID("00000000-0000-0000-5665-000000000034");
objupdate.ObjectData[0].NameValue=enc.GetBytes("FirstName STRING RW SV Test"+ this.local_numer+"\nLastName STRING RW SV User \0"); objupdate.ObjectData[0].NameValue=enc.GetBytes(avd.NetInfo.name);//enc.GetBytes("FirstName STRING RW SV Test"+ this.local_numer+"\nLastName STRING RW SV User \0");
libsecondlife.LLVector3 pos2=new LLVector3(120f,120.0f,22.0f); libsecondlife.LLVector3 pos2=new LLVector3(avd.Position.X,avd.Position.Y,avd.Position.Z);
byte[] pb=pos2.GetBytes(); byte[] pb=pos2.GetBytes();
@ -407,37 +439,16 @@ namespace Second_server
server.SendPacket(objupdate,true,User_info); server.SendPacket(objupdate,true,User_info);
this.send_other_apper(User_info,new LLUUID("00000000-0000-0000-5665-000000000034")); this.SendOtherAppearance(User_info,avd.NetInfo.AgentID);//new LLUUID("00000000-0000-0000-5665-000000000034"));
} }
public void send_other_avatar_position(User_Agent_info User_info, Avatar_data avd) /// <summary>
{ ///
//send a objectupdate packet with information about the clients avatar /// </summary>
ObjectUpdatePacket objupdate=new ObjectUpdatePacket(); /// <param name="User_info"></param>
objupdate.RegionData.RegionHandle=1096213093147648; /// <param name="line"></param>
objupdate.RegionData.TimeDilation=64500; public void SendChatMessage(User_Agent_info User_info, string line)
objupdate.ObjectData=new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1];
objupdate.ObjectData[0]=avatar_template;
//give this avatar object a local id and assign the user a name
objupdate.ObjectData[0].ID=avd.Net_info.localID;
objupdate.ObjectData[0].FullID=avd.Net_info.AgentID;//new LLUUID("00000000-0000-0000-5665-000000000034");
objupdate.ObjectData[0].NameValue=enc.GetBytes(avd.Net_info.name);//enc.GetBytes("FirstName STRING RW SV Test"+ this.local_numer+"\nLastName STRING RW SV User \0");
libsecondlife.LLVector3 pos2=new LLVector3(avd.pos.X,avd.pos.Y,avd.pos.Z);
byte[] pb=pos2.GetBytes();
Array.Copy(pb,0,objupdate.ObjectData[0].ObjectData,16,pb.Length);
this.local_numer++;
server.SendPacket(objupdate,true,User_info);
this.send_other_apper(User_info,avd.Net_info.AgentID);//new LLUUID("00000000-0000-0000-5665-000000000034"));
}
//*************************************************************
public void send_chat_message(User_Agent_info User_info, string line)
{ {
libsecondlife.Packets.ChatFromSimulatorPacket reply=new ChatFromSimulatorPacket(); libsecondlife.Packets.ChatFromSimulatorPacket reply=new ChatFromSimulatorPacket();
reply.ChatData.Audible=1; reply.ChatData.Audible=1;
@ -452,23 +463,33 @@ namespace Second_server
server.SendPacket(reply,true,User_info); server.SendPacket(reply,true,User_info);
//send to all users //send to all users
foreach (KeyValuePair<libsecondlife.LLUUID,Avatar_data> kp in this.Agent_list) foreach (KeyValuePair<libsecondlife.LLUUID,AvatarData> kp in this.AgentList)
{ {
if(kp.Value.Net_info.AgentID!=User_info.AgentID) if(kp.Value.NetInfo.AgentID!=User_info.AgentID)
{ {
server.SendPacket(reply,true,kp.Value.Net_info); server.SendPacket(reply,true,kp.Value.NetInfo);
} }
} }
} }
//*************************************************************
public void send_move_command(User_Agent_info user, bool stop,float x, float y, float z, uint av_id, libsecondlife.LLQuaternion body) /// <summary>
///
/// </summary>
/// <param name="user"></param>
/// <param name="stop"></param>
/// <param name="x"></param>
/// <param name="y"></param>
/// <param name="z"></param>
/// <param name="av_id"></param>
/// <param name="body"></param>
public void SendMoveCommand(User_Agent_info user, bool stop,float x, float y, float z, uint av_id, libsecondlife.LLQuaternion body)
{ {
uint ID=user.localID; uint ID=user.localID;
//ID=av_id; //ID=av_id;
byte[] bytes=new byte[60]; byte[] bytes=new byte[60];
ImprovedTerseObjectUpdatePacket im=new ImprovedTerseObjectUpdatePacket(); ImprovedTerseObjectUpdatePacket im=new ImprovedTerseObjectUpdatePacket();
im.RegionData.RegionHandle=1096213093147648; im.RegionData.RegionHandle=Globals.Instance.RegionHandle;;
im.RegionData.TimeDilation=64096; im.RegionData.TimeDilation=64096;
im.ObjectData=new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; im.ObjectData=new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
@ -477,7 +498,7 @@ namespace Second_server
im.ObjectData[0]=dat; im.ObjectData[0]=dat;
dat.TextureEntry=avatar_template.TextureEntry; dat.TextureEntry=AvatarTemplate.TextureEntry;
libsecondlife.LLVector3 pos2=new LLVector3(x,y,z); libsecondlife.LLVector3 pos2=new LLVector3(x,y,z);
bytes[i++] = (byte)(ID % 256); bytes[i++] = (byte)(ID % 256);
@ -571,16 +592,22 @@ namespace Second_server
server.SendPacket(im,true,user); server.SendPacket(im,true,user);
//should send to all users. //should send to all users.
foreach (KeyValuePair<libsecondlife.LLUUID,Avatar_data> kp in this.Agent_list) foreach (KeyValuePair<libsecondlife.LLUUID,AvatarData> kp in this.AgentList)
{ {
if(kp.Value.Net_info.AgentID!=user.AgentID) if(kp.Value.NetInfo.AgentID!=user.AgentID)
{ {
server.SendPacket(im,true,kp.Value.Net_info); server.SendPacket(im,true,kp.Value.NetInfo);
} }
} }
} }
//*************************************************************
public void read_layerdata(User_Agent_info User_info,ref LayerDataPacket lay,string name) /// <summary>
///
/// </summary>
/// <param name="User_info"></param>
/// <param name="lay"></param>
/// <param name="name"></param>
public void SendLayerData(User_Agent_info User_info,ref LayerDataPacket lay,string name)
{ {
FileInfo fInfo = new FileInfo(name); FileInfo fInfo = new FileInfo(name);
@ -590,7 +617,7 @@ namespace Second_server
BinaryReader br = new BinaryReader(fStream); BinaryReader br = new BinaryReader(fStream);
data1 = br.ReadBytes((int)numBytes); byte [] data1 = br.ReadBytes((int)numBytes);
br.Close(); br.Close();
@ -601,18 +628,32 @@ namespace Second_server
} }
} }
public class Avatar_data public class AvatarData
{ {
public User_Agent_info Net_info; public User_Agent_info NetInfo;
public LLUUID Full_ID; public LLUUID FullID;
public LLVector3 pos; public LLVector3 Position;
public LLVector3 vel=new LLVector3(0,0,0); public LLVector3 Velocity=new LLVector3(0,0,0);
public bool walk=false; //public LLQuaternion Rotation;
public bool started=false; public bool Walk=false;
public bool Started=false;
//public TextureEntry TextureEntry;
public Avatar_data() public AvatarData()
{ {
} }
} }
/*
public class AvatarParams
{
public byte[] Params;
public AvatarParams()
{
}
}
*/
} }

View File

@ -36,11 +36,11 @@ using System.Runtime.InteropServices;
// change them to the information which is associated with the assembly // change them to the information which is associated with the assembly
// you compile. // you compile.
[assembly: AssemblyTitle("Second-server")] [assembly: AssemblyTitle("OpenSim")]
[assembly: AssemblyDescription("")] [assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")] [assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Second-server")] [assembly: AssemblyProduct("OpenSim")]
[assembly: AssemblyCopyright("")] [assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
@ -56,4 +56,4 @@ using System.Runtime.InteropServices;
// You can specify all values by your own or you can build default build and revision // You can specify all values by your own or you can build default build and revision
// numbers with the '*' character (the default): // numbers with the '*' character (the default):
[assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("0.1.*")]

View File

@ -34,26 +34,26 @@ using libsecondlife.Packets;
using libsecondlife.AssetSystem; using libsecondlife.AssetSystem;
using System.IO; using System.IO;
namespace Second_server namespace OpenSim
{ {
/// <summary> /// <summary>
/// Description of Asset_manager. /// Description of Asset_manager.
/// </summary> /// </summary>
public class Asset_manager public class AssetManager
{ {
public Dictionary<libsecondlife.LLUUID,Asset_info> Assets; public Dictionary<libsecondlife.LLUUID,AssetInfo> Assets;
public ArrayList requests=new ArrayList(); //should change to a generic public ArrayList requests=new ArrayList(); //should change to a generic
// public ArrayList uploads=new ArrayList(); // public ArrayList uploads=new ArrayList();
private Server server; private Server server;
public Asset_manager(Server serve) public AssetManager(Server serve)
{ {
server=serve; server=serve;
Assets=new Dictionary<libsecondlife.LLUUID,Asset_info> (); Assets=new Dictionary<libsecondlife.LLUUID,AssetInfo> ();
this.initialise(); this.initialise();
} }
public void add_request(User_Agent_info user, LLUUID asset_id, TransferRequestPacket tran_req) public void AddRequest(User_Agent_info user, LLUUID asset_id, TransferRequestPacket tran_req)
{ {
if(!this.Assets.ContainsKey(asset_id)) if(!this.Assets.ContainsKey(asset_id))
@ -61,18 +61,18 @@ namespace Second_server
//not found asset //not found asset
return; return;
} }
Asset_info info=this.Assets[asset_id]; AssetInfo info=this.Assets[asset_id];
System.Console.WriteLine("send asset : "+asset_id); System.Console.WriteLine("send asset : "+asset_id);
//for now as it will be only skin or shape request just send back the asset //for now as it will be only skin or shape request just send back the asset
TransferInfoPacket tran_i=new TransferInfoPacket(); TransferInfoPacket Transfer=new TransferInfoPacket();
tran_i.TransferInfo.ChannelType=2; Transfer.TransferInfo.ChannelType=2;
tran_i.TransferInfo.Status=0; Transfer.TransferInfo.Status=0;
tran_i.TransferInfo.TargetType=0; Transfer.TransferInfo.TargetType=0;
tran_i.TransferInfo.Params=tran_req.TransferInfo.Params; Transfer.TransferInfo.Params=tran_req.TransferInfo.Params;
tran_i.TransferInfo.Size=info.data.Length; Transfer.TransferInfo.Size=info.data.Length;
tran_i.TransferInfo.TransferID=tran_req.TransferInfo.TransferID; Transfer.TransferInfo.TransferID=tran_req.TransferInfo.TransferID;
server.SendPacket(tran_i,true,user); server.SendPacket(Transfer,true,user);
TransferPacketPacket tran_p=new TransferPacketPacket(); TransferPacketPacket tran_p=new TransferPacketPacket();
tran_p.TransferData.Packet=0; tran_p.TransferData.Packet=0;
@ -110,14 +110,17 @@ namespace Second_server
private void initialise() private void initialise()
{ {
//for now read in our test image //for now read in our test image
Asset_info im=new Asset_info(); AssetInfo im=new AssetInfo();
im.filename="base_shape.dat"; im.filename="base_shape.dat";
im.Full_ID=new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73"); im.Full_ID=new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73");
this.load_asset(im); this.loadAsset(im);
this.Assets.Add(im.Full_ID,im); this.Assets.Add(im.Full_ID,im);
} }
private void load_asset(Asset_info info) 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 data_path = System.AppDomain.CurrentDomain.BaseDirectory + @"\assets\";
string filename=data_path+@info.filename; string filename=data_path+@info.filename;
FileInfo fInfo = new FileInfo(filename); FileInfo fInfo = new FileInfo(filename);
@ -135,21 +138,21 @@ namespace Second_server
} }
} }
public class Asset_request public class AssetRequest
{ {
public User_Agent_info req_user; public User_Agent_info RequestUser;
public LLUUID req_image; public LLUUID RequestImage;
public Asset_info asset_inf; public AssetInfo asset_inf;
public long data_pointer=0; public long data_pointer=0;
public int num_packets=0; public int num_packets=0;
public int packet_counter=0; public int packet_counter=0;
public Asset_request() public AssetRequest()
{ {
} }
} }
public class Asset_info public class AssetInfo
{ {
public byte[] data; public byte[] data;
public LLUUID Full_ID; public LLUUID Full_ID;
@ -159,7 +162,7 @@ namespace Second_server
public ulong last_used; //need to add a tick/time counter and keep record public ulong last_used; //need to add a tick/time counter and keep record
// of how often images are requested to unload unused ones. // of how often images are requested to unload unused ones.
public Asset_info() public AssetInfo()
{ {
} }

View File

@ -38,11 +38,12 @@ using System.IO;
using Axiom.MathLib; using Axiom.MathLib;
using log4net; using log4net;
namespace Second_server { namespace OpenSim
{
/// <summary> /// <summary>
/// Description of MainForm. /// Description of MainForm.
/// </summary> /// </summary>
public partial class Controller : Server_callback { public partial class Controller : ServerCallback {
@ -54,51 +55,79 @@ namespace Second_server {
} }
public Server server; public Server server;
public Logon _login;
private Agent_Manager agent_man; private AgentManager Agent_Manager;
private Prim_manager prim_man; private PrimManager Prim_Manager;
private Texture_manager texture_man; private TextureManager Texture_Manager;
private Asset_manager asset_man; private AssetManager Asset_Manager;
private Login_manager login_man; //built in login server private GridManager Grid_Manager;
private LoginManager Login_Manager; //built in login server
private ulong time; //ticks private ulong time; //ticks
private Timer timer1 = new Timer(); private Timer timer1 = new Timer();
public Controller() { public Controller() {
_login=new Logon(); // should create a list for these.
server = new Server( this ); server = new Server( this );
agent_man = new Agent_Manager( this.server ); Agent_Manager = new AgentManager( this.server );
prim_man = new Prim_manager( this.server ); Prim_Manager = new PrimManager( this.server );
texture_man = new Texture_manager( this.server ); Texture_Manager = new TextureManager( this.server );
asset_man = new Asset_manager( this.server ); Asset_Manager = new AssetManager( this.server );
prim_man.agent_man = agent_man; Prim_Manager.Agent_Manager = Agent_Manager;
agent_man.prim_man = prim_man; Agent_Manager.Prim_Manager = Prim_Manager;
login_man = new Login_manager(); // startup Grid_Manager=new GridManager(this.server,Agent_Manager);
login_man.startup(); // login server if(Globals.Instance.LoginSever)
{
Console.WriteLine("Starting login Server");
Login_Manager = new LoginManager(_login); // startup
Login_Manager.Startup(); // login server
}
timer1.Enabled = true; timer1.Enabled = true;
timer1.Interval = 200; timer1.Interval = 200;
timer1.Elapsed +=new ElapsedEventHandler( this.Timer1Tick ); timer1.Elapsed +=new ElapsedEventHandler( this.Timer1Tick );
} }
public void main_callback( Packet pack, User_Agent_info User_info ) { public void MainCallback( Packet pack, User_Agent_info User_info ) {
//System.Console.WriteLine(pack.Type);
if( ( pack.Type != PacketType.StartPingCheck ) && ( pack.Type != PacketType.AgentUpdate ) ) { if( ( pack.Type != PacketType.StartPingCheck ) && ( pack.Type != PacketType.AgentUpdate ) ) {
System.Console.WriteLine(pack.Type); // System.Console.WriteLine(pack.Type);
//this.richTextBox1.Text=this.richTextBox1.Text+"\n "+pack.Type; //this.richTextBox1.Text=this.richTextBox1.Text+"\n "+pack.Type;
} }
if( pack.Type == PacketType.AgentSetAppearance ) { if( pack.Type == PacketType.AgentSetAppearance ) {
System.Console.WriteLine(pack); // System.Console.WriteLine(pack);
//this.richTextBox1.Text=this.richTextBox1.Text+"\n "+pack.Type; //this.richTextBox1.Text=this.richTextBox1.Text+"\n "+pack.Type;
}
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)
{
this.Agent_Manager.RemoveAgent(User_info);
}
if(pack.Type== PacketType.MapLayerRequest)
{
this.Grid_Manager.RequestMapLayer(User_info);
}
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 ) { if( pack.Type == PacketType.TransferRequest ) {
TransferRequestPacket tran = (TransferRequestPacket)pack; TransferRequestPacket tran = (TransferRequestPacket)pack;
LLUUID id = new LLUUID( tran.TransferInfo.Params, 0 ); LLUUID id = new LLUUID( tran.TransferInfo.Params, 0 );
if( ( id == new LLUUID( "66c41e39-38f9-f75a-024e-585989bfab73" ) ) || ( id == new LLUUID( "e0ee49b5a4184df8d3c9a65361fe7f49" ) ) ) { if( ( id == new LLUUID( "66c41e39-38f9-f75a-024e-585989bfab73" ) ) || ( id == new LLUUID( "e0ee49b5a4184df8d3c9a65361fe7f49" ) ) ) {
//System.Console.WriteLine(pack); Asset_Manager.AddRequest( User_info, id, tran );
//System.Console.WriteLine(tran.TransferInfo.TransferID);
asset_man.add_request( User_info, id, tran );
//this.richTextBox1.Text=this.richTextBox1.Text+"\n "+pack.Type;
} }
} }
@ -111,23 +140,23 @@ namespace Second_server {
} }
if( pack.Type == PacketType.CompleteAgentMovement ) { if( pack.Type == PacketType.CompleteAgentMovement ) {
// new client // new client
agent_man.Agent_join( User_info ); Agent_Manager.AgentJoin( User_info );
} }
if( pack.Type == PacketType.RequestImage ) { if( pack.Type == PacketType.RequestImage ) {
RequestImagePacket image_req = (RequestImagePacket)pack; RequestImagePacket image_req = (RequestImagePacket)pack;
for( int i = 0; i < image_req.RequestImage.Length; i++ ) { for( int i = 0; i < image_req.RequestImage.Length; i++ ) {
this.texture_man.add_request( User_info, image_req.RequestImage[ i ].Image ); this.Texture_Manager.AddRequest( User_info, image_req.RequestImage[ i ].Image );
} }
} }
if( pack.Type == PacketType.RegionHandshakeReply ) { if( pack.Type == PacketType.RegionHandshakeReply ) {
//recieved regionhandshake so can now start sending info //recieved regionhandshake so can now start sending info
agent_man.send_intial_data( User_info ); Agent_Manager.SendInitialData( User_info );
//this.setuptemplates("objectupate164.dat",User_info,false); //this.setuptemplates("objectupate164.dat",User_info,false);
} }
if( pack.Type == PacketType.ObjectAdd ) { if( pack.Type == PacketType.ObjectAdd ) {
ObjectAddPacket ad = (ObjectAddPacket)pack; ObjectAddPacket ad = (ObjectAddPacket)pack;
prim_man.create_prim( User_info, ad.ObjectData.RayEnd, ad ); Prim_Manager.CreatePrim( User_info, ad.ObjectData.RayEnd, ad );
//this.send_prim(User_info,ad.ObjectData.RayEnd, ad); //this.send_prim(User_info,ad.ObjectData.RayEnd, ad);
} }
if( pack.Type == PacketType.ObjectPosition ) { if( pack.Type == PacketType.ObjectPosition ) {
@ -141,46 +170,55 @@ namespace Second_server {
if( mupd.ObjectData[ i ].Type == 9 ) //change position if( mupd.ObjectData[ i ].Type == 9 ) //change position
{ {
libsecondlife.LLVector3 pos = new LLVector3( mupd.ObjectData[ i ].Data, 0 ); libsecondlife.LLVector3 pos = new LLVector3( mupd.ObjectData[ i ].Data, 0 );
// libsecondlife.LLQuaternion rot=new LLQuaternion(mupd.ObjectData[i].Data,12,true);
prim_man.update_prim_position( User_info, pos.X, pos.Y, pos.Z, mupd.ObjectData[ i ].ObjectLocalID ); Prim_Manager.UpdatePrimPosition( User_info, pos, mupd.ObjectData[ i ].ObjectLocalID ,false ,libsecondlife.LLQuaternion.Identity);
//should update stored position of the prim //should update stored position of the prim
} }
else if( mupd.ObjectData[ i ].Type == 10 )
{
//System.Console.WriteLine(mupd.ObjectData[ i ].Type);
//System.Console.WriteLine(mupd);
libsecondlife.LLVector3 pos = new LLVector3(100,100,22);
libsecondlife.LLQuaternion rot=new LLQuaternion(mupd.ObjectData[i].Data,0,true);
Prim_Manager.UpdatePrimPosition( User_info, pos, mupd.ObjectData[ i ].ObjectLocalID ,true ,rot);
}
} }
} }
if( pack.Type == PacketType.AgentWearablesRequest ) { if( pack.Type == PacketType.AgentWearablesRequest ) {
agent_man.send_intial_avatar_apper( User_info ); Agent_Manager.SendIntialAvatarAppearance( User_info );
} }
if( pack.Type == PacketType.AgentUpdate ) { if( pack.Type == PacketType.AgentUpdate ) {
AgentUpdatePacket ag = (AgentUpdatePacket)pack; AgentUpdatePacket ag = (AgentUpdatePacket)pack;
uint mask = ag.AgentData.ControlFlags & ( 1 ); uint mask = ag.AgentData.ControlFlags & ( 1 );
Avatar_data m_av = agent_man.Get_Agent( User_info.AgentID ); AvatarData m_av = Agent_Manager.GetAgent( User_info.AgentID );
if( m_av != null ) { if( m_av != null ) {
if( m_av.started ) { if( m_av.Started ) {
if( mask == ( 1 ) ) { if( mask == ( 1 ) ) {
if( !m_av.walk ) { if( !m_av.Walk ) {
//start walking //start walking
agent_man.send_move_command( User_info, false, m_av.pos.X, m_av.pos.Y, m_av.pos.Z, 0, ag.AgentData.BodyRotation ); Agent_Manager.SendMoveCommand( User_info, false, m_av.Position.X, m_av.Position.Y, m_av.Position.Z, 0, ag.AgentData.BodyRotation );
Axiom.MathLib.Vector3 v3 = new Axiom.MathLib.Vector3( 1, 0, 0 ); Axiom.MathLib.Vector3 v3 = new Axiom.MathLib.Vector3( 1, 0, 0 );
Axiom.MathLib.Quaternion q = new Axiom.MathLib.Quaternion( ag.AgentData.BodyRotation.W, ag.AgentData.BodyRotation.X, ag.AgentData.BodyRotation.Y, ag.AgentData.BodyRotation.Z ); Axiom.MathLib.Quaternion q = new Axiom.MathLib.Quaternion( ag.AgentData.BodyRotation.W, ag.AgentData.BodyRotation.X, ag.AgentData.BodyRotation.Y, ag.AgentData.BodyRotation.Z );
Axiom.MathLib.Vector3 direc = q * v3; Axiom.MathLib.Vector3 direc = q * v3;
direc.Normalize(); direc.Normalize();
direc = direc * ( ( 0.03f ) * 128f ); direc = direc * ( ( 0.03f ) * 128f );
m_av.vel.X = direc.x; m_av.Velocity.X = direc.x;
m_av.vel.Y = direc.y; m_av.Velocity.Y = direc.y;
m_av.vel.Z = direc.z; m_av.Velocity.Z = direc.z;
m_av.walk = true; m_av.Walk = true;
} }
} }
else { else {
if( m_av.walk ) { if( m_av.Walk ) {
//walking but key not pressed so need to stop //walking but key not pressed so need to stop
agent_man.send_move_command( User_info, true, m_av.pos.X, m_av.pos.Y, m_av.pos.Z, 0, ag.AgentData.BodyRotation ); Agent_Manager.SendMoveCommand( User_info, true, m_av.Position.X, m_av.Position.Y, m_av.Position.Z, 0, ag.AgentData.BodyRotation );
m_av.walk = false; m_av.Walk = false;
m_av.vel.X = 0; m_av.Velocity.X = 0;
m_av.vel.Y = 0; m_av.Velocity.Y = 0;
m_av.vel.Z = 0; m_av.Velocity.Z = 0;
} }
} }
} }
@ -205,25 +243,52 @@ namespace Second_server {
else if( comp[ 0 ] == "veloc" ) { else if( comp[ 0 ] == "veloc" ) {
} }
else { else {
agent_man.send_chat_message( User_info, line ); Agent_Manager.SendChatMessage( User_info, line );
} }
} }
} }
} }
public void new_user( User_Agent_info User_info ) { public void NewUserCallback( User_Agent_info UserInfo ) {
Console.WriteLine( "new user - {0} - has joined [session {1}]", User_info.AgentID.ToString(), User_info.SessionID.ToString() ); Console.WriteLine( "new user - {0} - has joined [session {1}]", UserInfo.AgentID.ToString(), UserInfo.SessionID.ToString() +"curcuit used"+UserInfo.circuitCode);
agent_man.New_Agent( User_info ); string first,last;
lock(_login)
{
first=_login.first;
last=_login.last;
//should get agentid and sessionid so they can be checked.
}
Agent_Manager.NewAgent( UserInfo ,first,last);
//now because of the lack of Global account management (User server etc)
//we need to reset the names back to default incase a teleport happens
//which will not have a Login name set, so they will use default names
lock(_login)
{
_login.first="Test";
_login.last="User";
}
} }
public void error( string text ) { public void ErrorCallback( string text ) {
Console.WriteLine( "error report: {0}", text ); Console.WriteLine( "error report: {0}", text );
} }
void Timer1Tick( object sender, System.EventArgs e ) { void Timer1Tick( object sender, System.EventArgs e ) {
this.time++; this.time++;
agent_man.tick(); Agent_Manager.UpdatePositions();
texture_man.Do_work( time ); Texture_Manager.DoWork( time );
}
}
public class Logon
{
public string first="Test";
public string last="User";
public LLUUID Agent;
public LLUUID Session;
public Logon()
{
} }
} }
} }

View File

@ -25,7 +25,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
using Nwc.XmlRpc;
using System; using System;
using System.IO; using System.IO;
using System.Net; using System.Net;
@ -33,24 +33,27 @@ using System.Net.Sockets;
using System.Text; using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Threading; using System.Threading;
using System.Collections;
using libsecondlife;
namespace Second_server namespace OpenSim
{ {
/// <summary> /// <summary>
/// Description of Login_manager. /// Description of Login_manager.
/// </summary> /// </summary>
public class Login_manager public class LoginManager
{ {
public Login_manager() public LoginManager(Logon login)
{ {
Login=login;
} }
public Logon Login;
public ushort loginPort = 8080; public ushort loginPort = 8080;
public IPAddress clientAddress = IPAddress.Loopback; public IPAddress clientAddress = IPAddress.Loopback;
public IPAddress remoteAddress = IPAddress.Any; public IPAddress remoteAddress = IPAddress.Any;
private Socket loginServer; private Socket loginServer;
private Random RandomClass = new Random(); private Random RandomClass = new Random();
private int NumClients;
// InitializeLoginProxy: initialize the login proxy // InitializeLoginProxy: initialize the login proxy
private void InitializeLoginProxy() { private void InitializeLoginProxy() {
@ -59,7 +62,7 @@ namespace Second_server
loginServer.Listen(1); loginServer.Listen(1);
} }
public void startup() public void Startup()
{ {
this.InitializeLoginProxy(); this.InitializeLoginProxy();
Thread runLoginProxy = new Thread(new ThreadStart(RunLoginProxy)); Thread runLoginProxy = new Thread(new ThreadStart(RunLoginProxy));
@ -121,11 +124,52 @@ namespace Second_server
if (match.Success) if (match.Success)
contentLength = Convert.ToInt32(match.Groups[1].Captures[0].ToString()); contentLength = Convert.ToInt32(match.Groups[1].Captures[0].ToString());
} while (line != ""); } while (line != "");
System.Console.WriteLine(line);
// read the HTTP body into a buffer // read the HTTP body into a buffer
char[] content = new char[contentLength]; char[] content = new char[contentLength];
reader.Read(content, 0, contentLength); reader.Read(content, 0, contentLength);
// System.Text.Encoding enc = System.Text.Encoding.ASCII;
XmlRpcRequest request = (XmlRpcRequest)(new XmlRpcRequestDeserializer()).Deserialize(new String(content));
Hashtable requestData = (Hashtable)request.Params[0];
string first;
string last;
LLUUID Agent;
LLUUID Session;
//get login name
if(requestData.Contains("first"))
{
first=(string)requestData["first"];
}
else
{
first="test";
}
if(requestData.Contains("last"))
{
last=(string)requestData["last"];
}
else
{
last="User"+NumClients.ToString();
}
NumClients++;
//create a agent and session LLUUID
int AgentRand=this.RandomClass.Next(1,9999);
Agent=new LLUUID("99998888-"+AgentRand.ToString("0000")+"-4f52-8ec1-0b1d5cd6aead");
int SessionRand=this.RandomClass.Next(1,999);
Session=new LLUUID("aaaabbbb-8932-"+SessionRand.ToString("0000")+"-8664-58f53e442797");
//copy data to login object
lock(Login)
{
Login.first=first;
Login.last=last;
Login.Agent=Agent;
Login.Session=Session;
}
// forward the XML-RPC response to the client // forward the XML-RPC response to the client
writer.WriteLine("HTTP/1.0 200 OK"); writer.WriteLine("HTTP/1.0 200 OK");
@ -138,16 +182,16 @@ namespace Second_server
SR=File.OpenText("login.dat"); SR=File.OpenText("login.dat");
lines=SR.ReadLine(); lines=SR.ReadLine();
writer.WriteLine(lines); writer.WriteLine(lines);
lines=SR.ReadLine();
int ran=this.RandomClass.Next(1,9999);
lines="<member><name>session_id</name><value><string>99998888-"+ran.ToString("0000")+"-4f52-8ec1-0b1d5cd6aead</string></value></member>"; 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); writer.WriteLine(lines);
lines=SR.ReadLine(); lines=SR.ReadLine();
writer.WriteLine(lines); writer.WriteLine(lines);
lines=SR.ReadLine(); lines=SR.ReadLine();
ran=this.RandomClass.Next(1,9999); //lines="<member><name>agent_id</name><value><string>"+Session.ToString()+"</string></value></member>";
lines="<member><name>agent_id</name><value><string>aaaabbbb-8932-"+ran.ToString("0000")+"-8664-58f53e442797</string></value></member>"; lines="<member><name>agent_id</name><value><string>aaaabbbb-8932-"+SessionRand.ToString("0000")+"-8664-58f53e442797</string></value></member>";
writer.WriteLine(lines); writer.WriteLine(lines);
lines=SR.ReadLine(); lines=SR.ReadLine();

View File

@ -35,53 +35,63 @@ using libsecondlife.AssetSystem;
using System.IO; using System.IO;
using Axiom.MathLib; using Axiom.MathLib;
namespace Second_server namespace OpenSim
{ {
/// <summary> /// <summary>
/// Description of Prim_manager. /// Description of Prim_manager.
/// </summary> /// </summary>
public class Prim_manager public class PrimManager
{ {
private Server server; private Server server;
public Agent_Manager agent_man; public AgentManager Agent_Manager;
private uint prim_count; private uint prim_count;
public libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock object_template; public libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock PrimTemplate;
public Dictionary<libsecondlife.LLUUID,prim_info> Prim_list; public Dictionary<libsecondlife.LLUUID,PrimInfo> PrimList;
public Prim_manager(Server serve)
/// <summary>
///
/// </summary>
/// <param name="serve"></param>
public PrimManager(Server serve)
{ {
server=serve; server=serve;
Prim_list=new Dictionary<libsecondlife.LLUUID,prim_info> (); PrimList=new Dictionary<libsecondlife.LLUUID,PrimInfo> ();
this.setuptemplates("objectupate164.dat"); this.SetupTemplates("objectupate164.dat");
} }
/// <summary>
//********************************************************************* ///
public void create_prim(User_Agent_info User_info, libsecondlife.LLVector3 p1, ObjectAddPacket add_pack) /// </summary>
/// <param name="User_info"></param>
/// <param name="p1"></param>
/// <param name="add_pack"></param>
public void CreatePrim(User_Agent_info User_info, libsecondlife.LLVector3 p1, ObjectAddPacket add_pack)
{ {
ObjectUpdatePacket objupdate=new ObjectUpdatePacket(); ObjectUpdatePacket objupdate=new ObjectUpdatePacket();
objupdate.RegionData.RegionHandle=1096213093147648; objupdate.RegionData.RegionHandle=Globals.Instance.RegionHandle;
objupdate.RegionData.TimeDilation=64096; objupdate.RegionData.TimeDilation=64096;
objupdate.ObjectData=new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1]; objupdate.ObjectData=new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1];
PrimData PData=new PrimData();
objupdate.ObjectData[0]=this.object_template; objupdate.ObjectData[0]=this.PrimTemplate;
objupdate.ObjectData[0].OwnerID=User_info.AgentID; PData.OwnerID=objupdate.ObjectData[0].OwnerID=User_info.AgentID;
objupdate.ObjectData[0].PCode=add_pack.ObjectData.PCode; PData.PCode=objupdate.ObjectData[0].PCode=add_pack.ObjectData.PCode;
objupdate.ObjectData[0].PathBegin=add_pack.ObjectData.PathBegin; PData.PathBegin=objupdate.ObjectData[0].PathBegin=add_pack.ObjectData.PathBegin;
objupdate.ObjectData[0].PathEnd=add_pack.ObjectData.PathEnd; PData.PathEnd=objupdate.ObjectData[0].PathEnd=add_pack.ObjectData.PathEnd;
objupdate.ObjectData[0].PathScaleX=add_pack.ObjectData.PathScaleX; PData.PathScaleX=objupdate.ObjectData[0].PathScaleX=add_pack.ObjectData.PathScaleX;
objupdate.ObjectData[0].PathScaleY=add_pack.ObjectData.PathScaleY; PData.PathScaleY=objupdate.ObjectData[0].PathScaleY=add_pack.ObjectData.PathScaleY;
objupdate.ObjectData[0].PathShearX=add_pack.ObjectData.PathShearX; PData.PathShearX=objupdate.ObjectData[0].PathShearX=add_pack.ObjectData.PathShearX;
objupdate.ObjectData[0].PathShearY=add_pack.ObjectData.PathShearY; PData.PathShearY=objupdate.ObjectData[0].PathShearY=add_pack.ObjectData.PathShearY;
objupdate.ObjectData[0].PathSkew=add_pack.ObjectData.PathSkew; PData.PathSkew=objupdate.ObjectData[0].PathSkew=add_pack.ObjectData.PathSkew;
objupdate.ObjectData[0].ProfileBegin=add_pack.ObjectData.ProfileBegin; PData.ProfileBegin=objupdate.ObjectData[0].ProfileBegin=add_pack.ObjectData.ProfileBegin;
objupdate.ObjectData[0].ProfileEnd=add_pack.ObjectData.ProfileEnd; PData.ProfileEnd=objupdate.ObjectData[0].ProfileEnd=add_pack.ObjectData.ProfileEnd;
objupdate.ObjectData[0].Scale=add_pack.ObjectData.Scale;//new LLVector3(1,1,1); PData.Scale=objupdate.ObjectData[0].Scale=add_pack.ObjectData.Scale;//new LLVector3(1,1,1);
objupdate.ObjectData[0].PathCurve=add_pack.ObjectData.PathCurve; PData.PathCurve=objupdate.ObjectData[0].PathCurve=add_pack.ObjectData.PathCurve;
objupdate.ObjectData[0].ProfileCurve=add_pack.ObjectData.ProfileCurve; PData.ProfileCurve=objupdate.ObjectData[0].ProfileCurve=add_pack.ObjectData.ProfileCurve;
objupdate.ObjectData[0].ParentID=0; PData.ParentID=objupdate.ObjectData[0].ParentID=0;
objupdate.ObjectData[0].ProfileHollow=add_pack.ObjectData.ProfileHollow; PData.ProfileHollow=objupdate.ObjectData[0].ProfileHollow=add_pack.ObjectData.ProfileHollow;
//finish off copying rest of shape data //finish off copying rest of shape data
objupdate.ObjectData[0].ID=(uint)(702000+prim_count); objupdate.ObjectData[0].ID=(uint)(702000+prim_count);
@ -95,30 +105,40 @@ namespace Second_server
server.SendPacket(objupdate,true,User_info); server.SendPacket(objupdate,true,User_info);
//should send to all users //should send to all users
foreach (KeyValuePair<libsecondlife.LLUUID,Avatar_data> kp in agent_man.Agent_list) foreach (KeyValuePair<libsecondlife.LLUUID,AvatarData> kp in Agent_Manager.AgentList)
{ {
if(kp.Value.Net_info.AgentID!=User_info.AgentID) if(kp.Value.NetInfo.AgentID!=User_info.AgentID)
{ {
server.SendPacket(objupdate,true,kp.Value.Net_info); server.SendPacket(objupdate,true,kp.Value.NetInfo);
} }
} }
//should store this infomation //should store this infomation
prim_info n_prim=new prim_info(); PrimInfo NewPrim=new PrimInfo();
n_prim.full_ID=objupdate.ObjectData[0].FullID; NewPrim.FullID=objupdate.ObjectData[0].FullID;
n_prim.local_ID=objupdate.ObjectData[0].ID; NewPrim.LocalID=objupdate.ObjectData[0].ID;
n_prim.pos=p1; NewPrim.Position=p1;
NewPrim.data=PData;
this.Prim_list.Add(n_prim.full_ID,n_prim); this.PrimList.Add(NewPrim.FullID,NewPrim);
//store rest of data //store rest of data
} }
public void update_prim_position(User_Agent_info user,float x, float y, float z,uint l_id)
/// <summary>
///
/// </summary>
/// <param name="User"></param>
/// <param name="position"></param>
/// <param name="LocalID"></param>
/// <param name="setRotation"></param>
/// <param name="rotation"></param>
public void UpdatePrimPosition(User_Agent_info User,LLVector3 position,uint LocalID,bool setRotation, LLQuaternion rotation)
{ {
prim_info pri=null; PrimInfo pri=null;
foreach (KeyValuePair<libsecondlife.LLUUID,prim_info> kp in this.Prim_list) foreach (KeyValuePair<libsecondlife.LLUUID,PrimInfo> kp in this.PrimList)
{ {
if(kp.Value.local_ID==l_id) if(kp.Value.LocalID==LocalID)
{ {
pri=kp.Value; pri=kp.Value;
} }
@ -127,18 +147,37 @@ namespace Second_server
{ {
return; return;
} }
uint ID=pri.local_ID; uint ID=pri.LocalID;
libsecondlife.LLVector3 pos2=new LLVector3(position.X,position.Y,position.Z);
libsecondlife.LLQuaternion rotation2;
if(!setRotation)
{
pri.Position=pos2;
rotation2=new LLQuaternion(pri.Rotation.X,pri.Rotation.Y,pri.Rotation.Z,pri.Rotation.W);
}
else
{
rotation2=new LLQuaternion(rotation.X,rotation.Y,rotation.Z,rotation.W);
pos2=pri.Position;
pri.Rotation=rotation;
}
rotation2.W+=1;
rotation2.X+=1;
rotation2.Y+=1;
rotation2.Z+=1;
byte[] bytes=new byte[60]; byte[] bytes=new byte[60];
ImprovedTerseObjectUpdatePacket im=new ImprovedTerseObjectUpdatePacket(); ImprovedTerseObjectUpdatePacket im=new ImprovedTerseObjectUpdatePacket();
im.RegionData.RegionHandle=1096213093147648; im.RegionData.RegionHandle=Globals.Instance.RegionHandle;
im.RegionData.TimeDilation=64096; im.RegionData.TimeDilation=64096;
im.ObjectData=new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; im.ObjectData=new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
int i=0; int i=0;
ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat=new ImprovedTerseObjectUpdatePacket.ObjectDataBlock(); ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat=new ImprovedTerseObjectUpdatePacket.ObjectDataBlock();
im.ObjectData[0]=dat; im.ObjectData[0]=dat;
dat.TextureEntry=object_template.TextureEntry; dat.TextureEntry=PrimTemplate.TextureEntry;
libsecondlife.LLVector3 pos2=new LLVector3(x,y,z); //System.Console.WriteLine("new position is :"+position);
bytes[i++] = (byte)(ID % 256); bytes[i++] = (byte)(ID % 256);
bytes[i++] = (byte)((ID >> 8) % 256); bytes[i++] = (byte)((ID >> 8) % 256);
@ -151,7 +190,7 @@ namespace Second_server
// bytes[i++]=128; // bytes[i++]=128;
// bytes[i++]=63; // bytes[i++]=63;
byte[] pb=pos2.GetBytes(); byte[] pb=pos2.GetBytes();
pri.pos=pos2; pri.Position=pos2;
Array.Copy(pb,0,bytes,i,pb.Length); Array.Copy(pb,0,bytes,i,pb.Length);
i+=12; i+=12;
ushort ac=32767; ushort ac=32767;
@ -172,16 +211,36 @@ namespace Second_server
bytes[i++] = (byte)(ac % 256); bytes[i++] = (byte)(ac % 256);
bytes[i++] = (byte)((ac >> 8) % 256); bytes[i++] = (byte)((ac >> 8) % 256);
//rot //if(setRotation)
bytes[i++] = (byte)(ac % 256); //{
bytes[i++] = (byte)((ac >> 8) % 256);
bytes[i++] = (byte)(ac % 256);
bytes[i++] = (byte)((ac >> 8) % 256);
bytes[i++] = (byte)(ac % 256);
bytes[i++] = (byte)((ac >> 8) % 256);
bytes[i++] = (byte)(ac % 256);
bytes[i++] = (byte)((ac >> 8) % 256);
ushort rw, rx,ry,rz;
rw=(ushort)(32768*rotation2.W);
rx=(ushort)(32768*rotation2.X);
ry=(ushort)(32768*rotation2.Y);
rz=(ushort)(32768*rotation2.Z);
//rot
bytes[i++] = (byte)(rx % 256);
bytes[i++] = (byte)((rx >> 8) % 256);
bytes[i++] = (byte)(ry % 256);
bytes[i++] = (byte)((ry >> 8) % 256);
bytes[i++] = (byte)(rz % 256);
bytes[i++] = (byte)((rz >> 8) % 256);
bytes[i++] = (byte)(rw % 256);
bytes[i++] = (byte)((rw >> 8) % 256);
//}
/*else
{
bytes[i++] = (byte)(ac % 256);
bytes[i++] = (byte)((ac >> 8) % 256);
bytes[i++] = (byte)(ac % 256);
bytes[i++] = (byte)((ac >> 8) % 256);
bytes[i++] = (byte)(ac % 256);
bytes[i++] = (byte)((ac >> 8) % 256);
bytes[i++] = (byte)(ac % 256);
bytes[i++] = (byte)((ac >> 8) % 256);
}*/
//rotation vel //rotation vel
bytes[i++] = (byte)(ac % 256); bytes[i++] = (byte)(ac % 256);
bytes[i++] = (byte)((ac >> 8) % 256); bytes[i++] = (byte)((ac >> 8) % 256);
@ -193,23 +252,32 @@ namespace Second_server
dat.Data=bytes; dat.Data=bytes;
//server.SendPacket(im,true,user); //server.SendPacket(im,true,user);
//should send to all users. //should send to all users.
foreach (KeyValuePair<libsecondlife.LLUUID,Avatar_data> kp in agent_man.Agent_list) foreach (KeyValuePair<libsecondlife.LLUUID,AvatarData> kp in Agent_Manager.AgentList)
{ {
if(kp.Value.Net_info.AgentID!=user.AgentID) if(kp.Value.NetInfo.AgentID!=User.AgentID)
{ {
server.SendPacket(im,true,kp.Value.Net_info); server.SendPacket(im,true,kp.Value.NetInfo);
} }
} }
} }
public void send_existing_prims(User_Agent_info user)
/// <summary>
///
/// </summary>
/// <param name="user"></param>
public void SendExistingPrims(User_Agent_info user)
{ {
//send data for already created prims to a new joining user //send data for already created prims to a new joining user
} }
//**************************************************************
public void setuptemplates(string name) /// <summary>
///
/// </summary>
/// <param name="name"></param>
public void SetupTemplates(string name)
{ {
ObjectUpdatePacket objupdate=new ObjectUpdatePacket(); ObjectUpdatePacket objupdate=new ObjectUpdatePacket();
objupdate.RegionData.RegionHandle=1096213093147648; objupdate.RegionData.RegionHandle=Globals.Instance.RegionHandle;
objupdate.RegionData.TimeDilation=64096; objupdate.RegionData.TimeDilation=64096;
objupdate.ObjectData=new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1]; objupdate.ObjectData=new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1];
@ -224,7 +292,7 @@ namespace Second_server
libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock objdata=new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock(data1,ref i); libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock objdata=new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock(data1,ref i);
objupdate.ObjectData[0]=objdata; objupdate.ObjectData[0]=objdata;
this.object_template=objdata; this.PrimTemplate=objdata;
objdata.UpdateFlags=objdata.UpdateFlags+12-16+32+256; objdata.UpdateFlags=objdata.UpdateFlags+12-16+32+256;
objdata.OwnerID=new LLUUID("00000000-0000-0000-0000-000000000000"); objdata.OwnerID=new LLUUID("00000000-0000-0000-0000-000000000000");
//test adding a new texture to object , to test image downloading //test adding a new texture to object , to test image downloading
@ -235,8 +303,13 @@ namespace Second_server
objdata.TextureEntry=ntex.ToBytes(); objdata.TextureEntry=ntex.ToBytes();
} }
//********************************************************************
public void Read_Prim_database(string name,User_Agent_info user) /// <summary>
///
/// </summary>
/// <param name="name"></param>
/// <param name="user"></param>
public void ReadPrimDatabase(string name,User_Agent_info user)
{ {
StreamReader SR; StreamReader SR;
string line; string line;
@ -253,7 +326,7 @@ namespace Second_server
int num=Convert.ToInt32(comp[2]); int num=Convert.ToInt32(comp[2]);
int start=Convert.ToInt32(comp[1]); int start=Convert.ToInt32(comp[1]);
ObjectUpdatePacket objupdate=new ObjectUpdatePacket(); ObjectUpdatePacket objupdate=new ObjectUpdatePacket();
objupdate.RegionData.RegionHandle=1096213093147648; objupdate.RegionData.RegionHandle=Globals.Instance.RegionHandle;
objupdate.RegionData.TimeDilation=64096; objupdate.RegionData.TimeDilation=64096;
objupdate.ObjectData=new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[num]; objupdate.ObjectData=new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[num];
@ -285,24 +358,44 @@ namespace Second_server
} }
} }
public class prim_info public class PrimInfo
{ {
public LLVector3 pos; public LLVector3 Position;
public LLVector3 vel; public LLVector3 Velocity;
public uint local_ID; public LLQuaternion Rotation=LLQuaternion.Identity;
public LLUUID full_ID; public uint LocalID;
public prim_data data; public LLUUID FullID;
public PrimData data;
public prim_info() public PrimInfo()
{ {
pos=new LLVector3(0,0,0); Position=new LLVector3(0,0,0);
vel=new LLVector3(0,0,0); Velocity=new LLVector3(0,0,0);
data=new prim_data(); //data=new PrimData();
} }
} }
public class prim_data public class PrimData
{ {
public prim_data() public LLUUID OwnerID;
public byte PCode;
public byte PathBegin;
public byte PathEnd;
public byte PathScaleX;
public byte PathScaleY;
public byte PathShearX;
public byte PathShearY;
public sbyte PathSkew;
public byte ProfileBegin;
public byte ProfileEnd;
public LLVector3 Scale;
public byte PathCurve;
public byte ProfileCurve;
public uint ParentID=0;
public byte ProfileHollow;
public bool DataBaseStorage=false;
public PrimData()
{ {
} }

View File

@ -33,18 +33,18 @@ using System.Collections;
//using LuaInterface; //using LuaInterface;
using libsecondlife; using libsecondlife;
namespace Second_server namespace OpenSim
{ {
/// <summary> /// <summary>
/// Description of Script_manager. /// Description of Script_manager.
/// </summary> /// </summary>
public class Script_manager public class ScriptManager
{ {
//public LuaInterface.Lua Lu; //public LuaInterface.Lua Lu;
//private ArrayList scripts; //private ArrayList scripts;
//private prim_info current_prim; //private prim_info current_prim;
public Script_manager() public ScriptManager()
{ {
} }
@ -54,36 +54,52 @@ namespace Second_server
//register any lua routines , like check finish script one //register any lua routines , like check finish script one
Lu.OpenMathLib(); Lu.OpenMathLib();
}*/ }*/
public void script_register( script_object_interface script)
private void RegisterFunctions()
{ {
//called by scripts to register themselves //lu.RegisterFunction( "RegisterScript",this,this.GetType().GetMethod("ScriptRegister"));
//lu.RegisterFunction( "MoveObject",this,this.GetType().GetMethod("MoveObject"));
//lu.RegisterFunction( "Say",this,this.GetType().GetMethod("Say"));
} }
public void Call_tick(prim_info prim) public void Call_tick(PrimInfo prim)
{ {
//set current prim and then call tick function in linked script //set current prim and then call tick function in linked script
} }
public void Call_click(prim_info prim) public void Call_touch(PrimInfo prim)
{ {
//set current prim and then call clicked function in linked script //set current prim and then call clicked function in linked script
} }
private void Register_functions() public void Call_on_rex(PrimInfo prim)
{ {
//lu.RegisterFunction( "register_script",this,this.GetType().GetMethod("script_register")); //set current prim and then call clicked function in linked script
//lu.RegisterFunction( "Move_object",this,this.GetType().GetMethod("Move_object"));
} }
//Lua registered functions
public void Move_object(float x ,float y, float z) #region Lua Functions
public void ScriptRegister( script_object_interface script)
{
//called by scripts to register themselves
}
public void MoveObject(float x ,float y, float z)
{ {
} }
public void Say(string message)
{
}
#endregion
} }
public interface script_object_interface public interface script_object_interface
{ {
void Frame_tick(); void frame_tick();
void clicked(); void touch(int num);
void on_rex(int num);
} }
} }

View File

@ -1,8 +1,8 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup> <PropertyGroup>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<RootNamespace>Controller</RootNamespace> <RootNamespace>OpenSim</RootNamespace>
<AssemblyName>Second-server</AssemblyName> <AssemblyName>OpenSim</AssemblyName>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{132A6E3E-8F2D-4BF5-BDFB-8555F53F334E}</ProjectGuid> <ProjectGuid>{132A6E3E-8F2D-4BF5-BDFB-8555F53F334E}</ProjectGuid>
@ -35,6 +35,10 @@
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Data" /> <Reference Include="System.Data" />
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
<Reference Include="libsecondlife">
<HintPath>bin\Release\libsecondlife.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
</Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="AssemblyInfo.cs" /> <Compile Include="AssemblyInfo.cs" />
@ -47,12 +51,9 @@
<Compile Include="Asset_manager.cs" /> <Compile Include="Asset_manager.cs" />
<Compile Include="Script_manager.cs" /> <Compile Include="Script_manager.cs" />
<Compile Include="Server.cs" /> <Compile Include="Server.cs" />
</ItemGroup> <Compile Include="StorageManager.cs" />
<ItemGroup> <Compile Include="GridManager.cs" />
<ProjectReference Include="..\..\libsecondlife\libsecondlife-cs\libsecondlife.csproj"> <Compile Include="Globals.cs" />
<Project>{D9CDEDFB-8169-4B03-B57F-0DF638F044EC}</Project>
<Name>libsecondlife</Name>
</ProjectReference>
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" /> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
</Project> </Project>

View File

@ -1,6 +1,6 @@
 
Microsoft Visual Studio Solution File, Format Version 9.00 Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005 # SharpDevelop 2.1.0.2017
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Second-server", "Second-server.csproj", "{132A6E3E-8F2D-4BF5-BDFB-8555F53F334E}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Second-server", "Second-server.csproj", "{132A6E3E-8F2D-4BF5-BDFB-8555F53F334E}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "libsecondlife", "..\..\libsecondlife\libsecondlife-cs\libsecondlife.csproj", "{D9CDEDFB-8169-4B03-B57F-0DF638F044EC}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "libsecondlife", "..\..\libsecondlife\libsecondlife-cs\libsecondlife.csproj", "{D9CDEDFB-8169-4B03-B57F-0DF638F044EC}"
@ -27,6 +27,8 @@ Global
{D9CDEDFB-8169-4B03-B57F-0DF638F044EC}.Release|.NET 1.1.Build.0 = Release|.NET 1.1 {D9CDEDFB-8169-4B03-B57F-0DF638F044EC}.Release|.NET 1.1.Build.0 = Release|.NET 1.1
{D9CDEDFB-8169-4B03-B57F-0DF638F044EC}.Release|Any CPU.ActiveCfg = Release|Any CPU {D9CDEDFB-8169-4B03-B57F-0DF638F044EC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D9CDEDFB-8169-4B03-B57F-0DF638F044EC}.Release|Any CPU.Build.0 = Release|Any CPU {D9CDEDFB-8169-4B03-B57F-0DF638F044EC}.Release|Any CPU.Build.0 = Release|Any CPU
{132A6E3E-8F2D-4BF5-BDFB-8555F53F334E}.Debug|.NET 1.1.Build.0 = Debug|.NET 1.1
{132A6E3E-8F2D-4BF5-BDFB-8555F53F334E}.Release|.NET 1.1.Build.0 = Release|.NET 1.1
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

View File

@ -37,16 +37,17 @@ using System.Timers;
//really hacked , messy code //really hacked , messy code
namespace Second_server namespace OpenSim
{ {
/// <summary> /// <summary>
/// Description of Server. /// Description of Server.
/// </summary> /// </summary>
public interface Server_callback public interface ServerCallback
{ {
void main_callback(Packet pack, User_Agent_info User_info); //should replace with delegates
void new_user(User_Agent_info User_info); void MainCallback(Packet pack, User_Agent_info User_info);
void error(string text); void NewUserCallback(User_Agent_info User_info);
void ErrorCallback(string text);
} }
public class Server public class Server
{ {
@ -91,7 +92,7 @@ namespace Second_server
get { return connected; } get { return connected; }
} }
private Server_callback callback_object; private ServerCallback CallbackObject;
//private NetworkManager Network; //private NetworkManager Network;
// private Dictionary<PacketType, List<NetworkManager.PacketCallback>> Callbacks; // private Dictionary<PacketType, List<NetworkManager.PacketCallback>> Callbacks;
private uint Sequence = 0; private uint Sequence = 0;
@ -125,10 +126,10 @@ namespace Second_server
/// <param name="circuit"></param> /// <param name="circuit"></param>
/// <param name="ip"></param> /// <param name="ip"></param>
/// <param name="port"></param> /// <param name="port"></param>
public Server(Server_callback s_callback) public Server(ServerCallback s_callback)
{ {
this.callback_object=s_callback; this.CallbackObject=s_callback;
// Client = client; // Client = client;
// Network = client.Network; // Network = client.Network;
// Callbacks = callbacks; // Callbacks = callbacks;
@ -148,7 +149,7 @@ namespace Second_server
// Create an endpoint that we will be communicating with (need it in two // Create an endpoint that we will be communicating with (need it in two
// types due to .NET weirdness) // types due to .NET weirdness)
// ipEndPoint = new IPEndPoint(ip, port); // ipEndPoint = new IPEndPoint(ip, port);
ipEndPoint = new IPEndPoint(IPAddress.Any, 1000); ipEndPoint = new IPEndPoint(IPAddress.Any, Globals.Instance.IpPort);
endPoint = (EndPoint)ipEndPoint; endPoint = (EndPoint)ipEndPoint;
@ -486,7 +487,7 @@ namespace Second_server
new_user.endpoint=epSender; new_user.endpoint=epSender;
new_user.Inbox = new Queue<uint>(Settings.INBOX_SIZE); new_user.Inbox = new Queue<uint>(Settings.INBOX_SIZE);
this.callback_object.new_user(new_user); this.CallbackObject.NewUserCallback(new_user);
this.User_agents.Add(new_user); this.User_agents.Add(new_user);
} }
@ -526,14 +527,14 @@ namespace Second_server
{ {
//error finding agent //error finding agent
this.callback_object.error("no user found"); this.CallbackObject.ErrorCallback("no user found");
return; return;
} }
// Fail-safe check // Fail-safe check
if (packet == null) if (packet == null)
{ {
this.callback_object.error("couldn't build packet"); this.CallbackObject.ErrorCallback("couldn't build packet");
// Client.Log("Couldn't build a message from the incoming data", Helpers.LogLevel.Warning); // Client.Log("Couldn't build a message from the incoming data", Helpers.LogLevel.Warning);
return; return;
} }
@ -615,7 +616,7 @@ namespace Second_server
} }
// this.callback_object.error("calling callback"); // this.callback_object.error("calling callback");
this.callback_object.main_callback(packet,User_info); this.CallbackObject.MainCallback(packet,User_info);
// this.callback_object.error("finished"); // this.callback_object.error("finished");
// Fire the registered packet events // Fire the registered packet events
#region FireCallbacks #region FireCallbacks

View File

@ -36,26 +36,26 @@ using libsecondlife.AssetSystem;
using System.IO; using System.IO;
namespace Second_server namespace OpenSim
{ {
/// <summary> /// <summary>
/// Description of Texture_manager. /// Description of Texture_manager.
/// </summary> /// </summary>
public class Texture_manager public class TextureManager
{ {
public Dictionary<libsecondlife.LLUUID,Texture_image> textures; public Dictionary<libsecondlife.LLUUID,TextureImage> textures;
public ArrayList requests=new ArrayList(); //should change to a generic public ArrayList requests=new ArrayList(); //should change to a generic
public ArrayList uploads=new ArrayList(); public ArrayList uploads=new ArrayList();
private Server server; private Server server;
public Texture_manager(Server serve) public TextureManager(Server serve)
{ {
server=serve; server=serve;
textures=new Dictionary<libsecondlife.LLUUID,Texture_image> (); textures=new Dictionary<libsecondlife.LLUUID,TextureImage> ();
this.initialise(); this.initialise();
} }
public void add_request(User_Agent_info user, LLUUID image_id) public void AddRequest(User_Agent_info user, LLUUID image_id)
{ {
if(!this.textures.ContainsKey(image_id)) if(!this.textures.ContainsKey(image_id))
@ -66,10 +66,10 @@ namespace Second_server
server.SendPacket(im_not,true,user); server.SendPacket(im_not,true,user);
return; return;
} }
Texture_image imag=this.textures[image_id]; TextureImage imag=this.textures[image_id];
Texture_request req=new Texture_request(); TextureRequest req=new TextureRequest();
req.req_user=user; req.RequestUser=user;
req.req_image=image_id; req.RequestImage=image_id;
req.image_info=imag; req.image_info=imag;
if(imag.data.LongLength>1000) //should be bigger or smaller? if(imag.data.LongLength>1000) //should be bigger or smaller?
@ -87,11 +87,11 @@ namespace Second_server
} }
public void add_texture(LLUUID image_id, string name, byte[] data) public void AddTexture(LLUUID image_id, string name, byte[] data)
{ {
} }
public void Do_work(ulong time) public void DoWork(ulong time)
{ {
if(this.requests.Count==0) if(this.requests.Count==0)
{ {
@ -109,10 +109,10 @@ namespace Second_server
{ {
num=5; num=5;
} }
Texture_request req; TextureRequest req;
for(int i=0; i<num; i++) for(int i=0; i<num; i++)
{ {
req=(Texture_request)this.requests[i]; req=(TextureRequest)this.requests[i];
if(req.packet_counter==0) if(req.packet_counter==0)
{ {
@ -126,9 +126,10 @@ namespace Second_server
im.ImageID.Size=(uint)req.image_info.data.Length; im.ImageID.Size=(uint)req.image_info.data.Length;
im.ImageData.Data=req.image_info.data; im.ImageData.Data=req.image_info.data;
im.ImageID.Codec=2; im.ImageID.Codec=2;
server.SendPacket(im,true,req.req_user); server.SendPacket(im,true,req.RequestUser);
req.packet_counter++; req.packet_counter++;
req.image_info.last_used=time; req.image_info.last_used=time;
System.Console.WriteLine("sent texture: "+req.image_info.Full_ID);
} }
else else
{ {
@ -145,7 +146,7 @@ namespace Second_server
//remove requests that have been completed //remove requests that have been completed
for(int i=0; i<num; i++) for(int i=0; i<num; i++)
{ {
req=(Texture_request)this.requests[i]; req=(TextureRequest)this.requests[i];
if(req.packet_counter==req.num_packets) if(req.packet_counter==req.num_packets)
{ {
this.requests.Remove(req); this.requests.Remove(req);
@ -153,7 +154,7 @@ namespace Second_server
} }
} }
public void recieve_texture(Packet pack) public void RecieveTexture(Packet pack)
{ {
} }
@ -161,14 +162,30 @@ namespace Second_server
private void initialise() private void initialise()
{ {
//for now read in our test image //for now read in our test image
Texture_image im=new Texture_image(); TextureImage im=new TextureImage();
im.filename="testpic2.jp2"; im.filename="testpic2.jp2";
im.Full_ID=new LLUUID("00000000-0000-0000-5005-000000000005"); im.Full_ID=new LLUUID("00000000-0000-0000-5005-000000000005");
this.load_image(im); this.LoadImage(im);
this.textures.Add(im.Full_ID,im); this.textures.Add(im.Full_ID,im);
im=new TextureImage();
im.filename="map_base.jp2";
im.Full_ID=new LLUUID("00000000-0000-0000-7007-000000000006");
this.LoadImage(im);
this.textures.Add(im.Full_ID,im);
im=new TextureImage();
im.filename="map1.jp2";
im.Full_ID=new LLUUID("00000000-0000-0000-7009-000000000008");
this.LoadImage(im);
this.textures.Add(im.Full_ID,im);
} }
private void load_image(Texture_image im) 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 data_path=System.AppDomain.CurrentDomain.BaseDirectory + @"\textures\";
string filename=data_path+@im.filename; string filename=data_path+@im.filename;
FileInfo fInfo = new FileInfo(filename); FileInfo fInfo = new FileInfo(filename);
@ -187,21 +204,21 @@ namespace Second_server
} }
public class Texture_request public class TextureRequest
{ {
public User_Agent_info req_user; public User_Agent_info RequestUser;
public LLUUID req_image; public LLUUID RequestImage;
public Texture_image image_info; public TextureImage image_info;
public long data_pointer=0; public long data_pointer=0;
public int num_packets=0; public int num_packets=0;
public int packet_counter=0; public int packet_counter=0;
public Texture_request() public TextureRequest()
{ {
} }
} }
public class Texture_image public class TextureImage
{ {
public byte[] data; public byte[] data;
public LLUUID Full_ID; public LLUUID Full_ID;
@ -211,7 +228,7 @@ namespace Second_server
public ulong last_used; //need to add a tick/time counter and keep record public ulong last_used; //need to add a tick/time counter and keep record
// of how often images are requested to unload unused ones. // of how often images are requested to unload unused ones.
public Texture_image() public TextureImage()
{ {
} }