aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/world/Avatar.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/world/Avatar.cs')
-rw-r--r--src/world/Avatar.cs54
1 files changed, 54 insertions, 0 deletions
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 @@
1using System; 1using System;
2using System.Collections.Generic; 2using System.Collections.Generic;
3using System.IO;
3using System.Text; 4using System.Text;
4using libsecondlife; 5using libsecondlife;
5using libsecondlife.Packets; 6using libsecondlife.Packets;
@@ -11,12 +12,42 @@ namespace OpenSim.world
11 public string firstname; 12 public string firstname;
12 public string lastname; 13 public string lastname;
13 public OpenSimClient ControllingClient; 14 public OpenSimClient ControllingClient;
15 private libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock AvatarTemplate;
14 16
15 public Avatar(OpenSimClient TheClient) { 17 public Avatar(OpenSimClient TheClient) {
16 Console.WriteLine("Avatar.cs - Loading details from grid (DUMMY)"); 18 Console.WriteLine("Avatar.cs - Loading details from grid (DUMMY)");
17 ControllingClient=TheClient; 19 ControllingClient=TheClient;
20 SetupTemplate("avatar-template.dat");
18 } 21 }
19 22
23 private void SetupTemplate(string name)
24 {
25
26 int i = 0;
27 FileInfo fInfo = new FileInfo(name);
28 long numBytes = fInfo.Length;
29 FileStream fStream = new FileStream(name, FileMode.Open, FileAccess.Read);
30 BinaryReader br = new BinaryReader(fStream);
31 byte [] data1 = br.ReadBytes((int)numBytes);
32 br.Close();
33 fStream.Close();
34
35 libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock objdata = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock(data1, ref i);
36
37 System.Text.Encoding enc = System.Text.Encoding.ASCII;
38 libsecondlife.LLVector3 pos = new LLVector3(objdata.ObjectData, 16);
39 pos.X = 100f;
40 objdata.ID = 8880000;
41 objdata.NameValue = enc.GetBytes("FirstName STRING RW SV Test \nLastName STRING RW SV User \0");
42 libsecondlife.LLVector3 pos2 = new LLVector3(13.981f,100.0f,20.0f);
43 //objdata.FullID=user.AgentID;
44 byte[] pb = pos.GetBytes();
45 Array.Copy(pb, 0, objdata.ObjectData, 16, pb.Length);
46
47 AvatarTemplate = objdata;
48
49 }
50
20 public void CompleteMovement(World RegionInfo) { 51 public void CompleteMovement(World RegionInfo) {
21 Console.WriteLine("Avatar.cs:CompleteMovement() - Constructing AgentMovementComplete packet"); 52 Console.WriteLine("Avatar.cs:CompleteMovement() - Constructing AgentMovementComplete packet");
22 AgentMovementCompletePacket mov = new AgentMovementCompletePacket(); 53 AgentMovementCompletePacket mov = new AgentMovementCompletePacket();
@@ -33,6 +64,29 @@ namespace OpenSim.world
33 } 64 }
34 65
35 public void SendInitialPosition() { 66 public void SendInitialPosition() {
67 System.Text.Encoding _enc = System.Text.Encoding.ASCII;
68
69
70 //send a objectupdate packet with information about the clients avatar
71 ObjectUpdatePacket objupdate = new ObjectUpdatePacket();
72 objupdate.RegionData.RegionHandle = OpenSim_Main.cfg.RegionHandle;
73 objupdate.RegionData.TimeDilation = 64096;
74 objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1];
75
76 objupdate.ObjectData[0] = AvatarTemplate;
77 //give this avatar object a local id and assign the user a name
78 objupdate.ObjectData[0].ID = 8880000 + OpenSim_Main.local_world._localNumber;
79 //User_info.name="Test"+this.local_numer+" User";
80 objupdate.ObjectData[0].FullID = ControllingClient.AgentID;
81 objupdate.ObjectData[0].NameValue = _enc.GetBytes("FirstName STRING RW SV " + firstname + "\nLastName STRING RW SV " + lastname + " \0");
82
83 libsecondlife.LLVector3 pos2 = new LLVector3(100f, 100.0f, 22.0f);
84
85 byte[] pb = pos2.GetBytes();
86
87 Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 16, pb.Length);
88 OpenSim_Main.local_world._localNumber++;
89 this.ControllingClient.OutPacket(objupdate);
36 } 90 }
37 91
38 public void SendInitialAppearance() { 92 public void SendInitialAppearance() {