From 0eabb4b98ccff663de034ac666bfcb531edb7a30 Mon Sep 17 00:00:00 2001 From: gareth Date: Thu, 1 Mar 2007 01:38:41 +0000 Subject: Broken asset code + ObjectUpdate FIXME --- src/world/Avatar.cs | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++++ src/world/World.cs | 2 +- 2 files changed, 55 insertions(+), 1 deletion(-) (limited to 'src/world') diff --git a/src/world/Avatar.cs b/src/world/Avatar.cs index 6177f6e..d579463 100644 --- a/src/world/Avatar.cs +++ b/src/world/Avatar.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.IO; using System.Text; using libsecondlife; using libsecondlife.Packets; @@ -11,12 +12,42 @@ namespace OpenSim.world public string firstname; public string lastname; public OpenSimClient ControllingClient; + private libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock AvatarTemplate; public Avatar(OpenSimClient TheClient) { Console.WriteLine("Avatar.cs - Loading details from grid (DUMMY)"); ControllingClient=TheClient; + SetupTemplate("avatar-template.dat"); } + private void SetupTemplate(string name) + { + + int i = 0; + FileInfo fInfo = new FileInfo(name); + long numBytes = fInfo.Length; + FileStream fStream = new FileStream(name, FileMode.Open, FileAccess.Read); + BinaryReader br = new BinaryReader(fStream); + byte [] data1 = br.ReadBytes((int)numBytes); + br.Close(); + fStream.Close(); + + libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock objdata = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock(data1, ref i); + + System.Text.Encoding enc = System.Text.Encoding.ASCII; + libsecondlife.LLVector3 pos = new LLVector3(objdata.ObjectData, 16); + pos.X = 100f; + objdata.ID = 8880000; + objdata.NameValue = enc.GetBytes("FirstName STRING RW SV Test \nLastName STRING RW SV User \0"); + libsecondlife.LLVector3 pos2 = new LLVector3(13.981f,100.0f,20.0f); + //objdata.FullID=user.AgentID; + byte[] pb = pos.GetBytes(); + Array.Copy(pb, 0, objdata.ObjectData, 16, pb.Length); + + AvatarTemplate = objdata; + + } + public void CompleteMovement(World RegionInfo) { Console.WriteLine("Avatar.cs:CompleteMovement() - Constructing AgentMovementComplete packet"); AgentMovementCompletePacket mov = new AgentMovementCompletePacket(); @@ -33,6 +64,29 @@ namespace OpenSim.world } public void SendInitialPosition() { + System.Text.Encoding _enc = System.Text.Encoding.ASCII; + + + //send a objectupdate packet with information about the clients avatar + ObjectUpdatePacket objupdate = new ObjectUpdatePacket(); + objupdate.RegionData.RegionHandle = OpenSim_Main.cfg.RegionHandle; + objupdate.RegionData.TimeDilation = 64096; + objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1]; + + objupdate.ObjectData[0] = AvatarTemplate; + //give this avatar object a local id and assign the user a name + objupdate.ObjectData[0].ID = 8880000 + OpenSim_Main.local_world._localNumber; + //User_info.name="Test"+this.local_numer+" User"; + objupdate.ObjectData[0].FullID = ControllingClient.AgentID; + objupdate.ObjectData[0].NameValue = _enc.GetBytes("FirstName STRING RW SV " + firstname + "\nLastName STRING RW SV " + lastname + " \0"); + + libsecondlife.LLVector3 pos2 = new LLVector3(100f, 100.0f, 22.0f); + + byte[] pb = pos2.GetBytes(); + + Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 16, pb.Length); + OpenSim_Main.local_world._localNumber++; + this.ControllingClient.OutPacket(objupdate); } public void SendInitialAppearance() { diff --git a/src/world/World.cs b/src/world/World.cs index d7e3370..ccc34ea 100644 --- a/src/world/World.cs +++ b/src/world/World.cs @@ -12,7 +12,7 @@ namespace OpenSim.world public float[] LandMap; public ScriptEngine Scripts; public TerrainDecode terrainengine = new TerrainDecode(); - + public uint _localNumber=0; public World() { -- cgit v1.1