aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/Main.cs3
-rw-r--r--src/OpenSimClient.cs12
-rw-r--r--src/world/Avatar.cs107
-rw-r--r--src/world/Entity.cs18
-rw-r--r--src/world/PhysicsEngine.cs8
-rw-r--r--src/world/World.cs12
6 files changed, 147 insertions, 13 deletions
diff --git a/src/Main.cs b/src/Main.cs
index 146d837..fe2183b 100644
--- a/src/Main.cs
+++ b/src/Main.cs
@@ -46,7 +46,7 @@ namespace OpenSim
46 /// </summary> 46 /// </summary>
47 public class OpenSim_Main 47 public class OpenSim_Main
48 { 48 {
49 private static OpenSim_Main sim; 49 public static OpenSim_Main sim;
50 public static SimConfig cfg; 50 public static SimConfig cfg;
51 public static World local_world; 51 public static World local_world;
52 private static Thread MainListener; 52 private static Thread MainListener;
@@ -68,6 +68,7 @@ namespace OpenSim
68 sim.Startup(); 68 sim.Startup();
69 while(true) { 69 while(true) {
70 local_world.DoStuff(); 70 local_world.DoStuff();
71 Thread.Sleep(100);
71 } 72 }
72 } 73 }
73 74
diff --git a/src/OpenSimClient.cs b/src/OpenSimClient.cs
index 47f6dbf..696031d 100644
--- a/src/OpenSimClient.cs
+++ b/src/OpenSimClient.cs
@@ -60,6 +60,7 @@ namespace OpenSim
60 private const int MAX_APPENDED_ACKS = 10; 60 private const int MAX_APPENDED_ACKS = 10;
61 private const int RESEND_TIMEOUT = 4000; 61 private const int RESEND_TIMEOUT = 4000;
62 private const int MAX_SEQUENCE = 0xFFFFFF; 62 private const int MAX_SEQUENCE = 0xFFFFFF;
63 private Queue<uint> Inbox;
63 64
64 public void ack_pack(Packet Pack) { 65 public void ack_pack(Packet Pack) {
65 //libsecondlife.Packets.PacketAckPacket ack_it = new PacketAckPacket(); 66 //libsecondlife.Packets.PacketAckPacket ack_it = new PacketAckPacket();
@@ -152,16 +153,22 @@ namespace OpenSim
152 break; 153 break;
153 case PacketType.LogoutRequest: 154 case PacketType.LogoutRequest:
154 Console.WriteLine("OpenSimClient.cs:ProcessInPacket() - Got a logout request"); 155 Console.WriteLine("OpenSimClient.cs:ProcessInPacket() - Got a logout request");
155 OpenSim_Main.local_world.Entities.Remove(this.AgentID); 156 lock(OpenSim_Main.local_world.Entities) {
157 OpenSim_Main.local_world.Entities.Remove(this.AgentID);
158 }
156 WebRequest DeleteSession = WebRequest.Create(OpenSim_Main.cfg.GridURL + "/usersessions/" + OpenSim_Main.cfg.GridSendKey + "/" + this.AgentID.ToString() + this.CircuitCode.ToString() + "/delete"); 159 WebRequest DeleteSession = WebRequest.Create(OpenSim_Main.cfg.GridURL + "/usersessions/" + OpenSim_Main.cfg.GridSendKey + "/" + this.AgentID.ToString() + this.CircuitCode.ToString() + "/delete");
157 WebResponse GridResponse = DeleteSession.GetResponse(); 160 WebResponse GridResponse = DeleteSession.GetResponse();
158 StreamReader sr = new StreamReader(GridResponse.GetResponseStream()); 161 StreamReader sr = new StreamReader(GridResponse.GetResponseStream());
159 String grTest = sr.ReadLine(); 162 String grTest = sr.ReadLine();
160 sr.Close(); 163 sr.Close();
161 GridResponse.Close(); 164 GridResponse.Close();
165 Console.WriteLine("DEBUG: " + grTest);
162 166
163 this.ClientThread.Abort(); 167 this.ClientThread.Abort();
164 break; 168 break;
169 case PacketType.AgentUpdate:
170 ClientAvatar.HandleAgentUpdate((AgentUpdatePacket)Pack);
171 break;
165 } 172 }
166 } 173 }
167 174
@@ -315,6 +322,7 @@ namespace OpenSim
315 { 322 {
316 foreach (uint ack in NewPack.Header.AckList) 323 foreach (uint ack in NewPack.Header.AckList)
317 { 324 {
325 Console.WriteLine("Got appended ack: "+ack);
318 NeedAck.Remove(ack); 326 NeedAck.Remove(ack);
319 } 327 }
320 } 328 }
@@ -329,6 +337,7 @@ namespace OpenSim
329 { 337 {
330 foreach (PacketAckPacket.PacketsBlock block in ackPacket.Packets) 338 foreach (PacketAckPacket.PacketsBlock block in ackPacket.Packets)
331 { 339 {
340 Console.WriteLine("Got PacketAck: "+block.ID);
332 NeedAck.Remove(block.ID); 341 NeedAck.Remove(block.ID);
333 } 342 }
334 } 343 }
@@ -398,6 +407,7 @@ namespace OpenSim
398 private void AuthUser() { 407 private void AuthUser() {
399 Console.WriteLine("OpenSimClient.cs:AuthUser() - Authenticating new user request with grid"); 408 Console.WriteLine("OpenSimClient.cs:AuthUser() - Authenticating new user request with grid");
400 WebRequest CheckSession = WebRequest.Create(OpenSim_Main.cfg.GridURL + "/usersessions/" + OpenSim_Main.cfg.GridSendKey + "/" + cirpack.CircuitCode.ID.ToString() + "/" + cirpack.CircuitCode.Code.ToString() + "/exists"); 409 WebRequest CheckSession = WebRequest.Create(OpenSim_Main.cfg.GridURL + "/usersessions/" + OpenSim_Main.cfg.GridSendKey + "/" + cirpack.CircuitCode.ID.ToString() + "/" + cirpack.CircuitCode.Code.ToString() + "/exists");
410 Console.WriteLine(OpenSim_Main.cfg.GridURL);
401 WebResponse GridResponse = CheckSession.GetResponse(); 411 WebResponse GridResponse = CheckSession.GetResponse();
402 StreamReader sr = new StreamReader(GridResponse.GetResponseStream()); 412 StreamReader sr = new StreamReader(GridResponse.GetResponseStream());
403 String grTest = sr.ReadLine(); 413 String grTest = sr.ReadLine();
diff --git a/src/world/Avatar.cs b/src/world/Avatar.cs
index f3905cd..68606c4 100644
--- a/src/world/Avatar.cs
+++ b/src/world/Avatar.cs
@@ -4,6 +4,7 @@ using System.IO;
4using System.Text; 4using System.Text;
5using libsecondlife; 5using libsecondlife;
6using libsecondlife.Packets; 6using libsecondlife.Packets;
7using Axiom.MathLib;
7 8
8namespace OpenSim.world 9namespace OpenSim.world
9{ 10{
@@ -12,16 +13,37 @@ namespace OpenSim.world
12 public string firstname; 13 public string firstname;
13 public string lastname; 14 public string lastname;
14 public OpenSimClient ControllingClient; 15 public OpenSimClient ControllingClient;
16 public uint CurrentKeyMask;
17
15 private libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock AvatarTemplate; 18 private libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock AvatarTemplate;
16 19
17 public Avatar(OpenSimClient TheClient) { 20 public Avatar(OpenSimClient TheClient) {
18 Console.WriteLine("Avatar.cs - Loading details from grid (DUMMY)"); 21 Console.WriteLine("Avatar.cs - Loading details from grid (DUMMY)");
19 ControllingClient=TheClient; 22 ControllingClient=TheClient;
20 SetupTemplate("avatar-template.dat"); 23 SetupTemplate("avatar-template.dat");
24
25 position = new LLVector3(100.0f,100.0f,60.0f);
21 } 26 }
22 27
23 public void update() { 28 public override void update() {
24 base.update(); 29 lock(this) {
30 base.update();
31
32 Console.WriteLine("KeyMask: " + this.CurrentKeyMask);
33
34 if((this.CurrentKeyMask & (uint)MainAvatar.AgentUpdateFlags.AGENT_CONTROL_AT_POS) != 0) {
35 Vector3 tmpVelocity = this.rotation * new Vector3(1.0f,0.0f,0.0f);
36 tmpVelocity.Normalize(); tmpVelocity = tmpVelocity * 0.3f;
37 this.velocity.X = tmpVelocity.x;
38 this.velocity.Y = tmpVelocity.y;
39 this.velocity.Z = tmpVelocity.z;
40 Console.WriteLine("Walking at "+ this.velocity.ToString());
41 } else {
42 this.velocity.X=0;
43 this.velocity.Y=0;
44 this.velocity.Z=0;
45 }
46 }
25 } 47 }
26 48
27 private void SetupTemplate(string name) 49 private void SetupTemplate(string name)
@@ -41,7 +63,7 @@ namespace OpenSim.world
41 System.Text.Encoding enc = System.Text.Encoding.ASCII; 63 System.Text.Encoding enc = System.Text.Encoding.ASCII;
42 libsecondlife.LLVector3 pos = new LLVector3(objdata.ObjectData, 16); 64 libsecondlife.LLVector3 pos = new LLVector3(objdata.ObjectData, 16);
43 pos.X = 100f; 65 pos.X = 100f;
44 objdata.ID = 8880000; 66 objdata.ID = this.localid;
45 objdata.NameValue = enc.GetBytes("FirstName STRING RW SV Test \nLastName STRING RW SV User \0"); 67 objdata.NameValue = enc.GetBytes("FirstName STRING RW SV Test \nLastName STRING RW SV User \0");
46 libsecondlife.LLVector3 pos2 = new LLVector3(100f,100f,23f); 68 libsecondlife.LLVector3 pos2 = new LLVector3(100f,100f,23f);
47 //objdata.FullID=user.AgentID; 69 //objdata.FullID=user.AgentID;
@@ -60,7 +82,7 @@ namespace OpenSim.world
60 mov.Data.RegionHandle = OpenSim_Main.cfg.RegionHandle; 82 mov.Data.RegionHandle = OpenSim_Main.cfg.RegionHandle;
61 // TODO - dynamicalise this stuff 83 // TODO - dynamicalise this stuff
62 mov.Data.Timestamp = 1172750370; 84 mov.Data.Timestamp = 1172750370;
63 mov.Data.Position = new LLVector3(100f, 100f, 23f); 85 mov.Data.Position = new LLVector3((float)this.position.X, (float)this.position.Y, (float)this.position.Z);
64 mov.Data.LookAt = new LLVector3(0.99f, 0.042f, 0); 86 mov.Data.LookAt = new LLVector3(0.99f, 0.042f, 0);
65 87
66 Console.WriteLine("Sending AgentMovementComplete packet"); 88 Console.WriteLine("Sending AgentMovementComplete packet");
@@ -79,12 +101,12 @@ namespace OpenSim.world
79 101
80 objupdate.ObjectData[0] = AvatarTemplate; 102 objupdate.ObjectData[0] = AvatarTemplate;
81 //give this avatar object a local id and assign the user a name 103 //give this avatar object a local id and assign the user a name
82 objupdate.ObjectData[0].ID = 8880000 + OpenSim_Main.local_world._localNumber; 104 objupdate.ObjectData[0].ID = this.localid;
83 //User_info.name="Test"+this.local_numer+" User"; 105 //User_info.name="Test"+this.local_numer+" User";
84 objupdate.ObjectData[0].FullID = ControllingClient.AgentID; 106 objupdate.ObjectData[0].FullID = ControllingClient.AgentID;
85 objupdate.ObjectData[0].NameValue = _enc.GetBytes("FirstName STRING RW SV " + firstname + "\nLastName STRING RW SV " + lastname + " \0"); 107 objupdate.ObjectData[0].NameValue = _enc.GetBytes("FirstName STRING RW SV " + firstname + "\nLastName STRING RW SV " + lastname + " \0");
86 108
87 libsecondlife.LLVector3 pos2 = new LLVector3(100f, 100.0f, 23.0f); 109 libsecondlife.LLVector3 pos2 = new LLVector3((float)this.position.X, (float)this.position.Y, (float)this.position.Z);
88 110
89 byte[] pb = pos2.GetBytes(); 111 byte[] pb = pos2.GetBytes();
90 112
@@ -92,6 +114,68 @@ namespace OpenSim.world
92 OpenSim_Main.local_world._localNumber++; 114 OpenSim_Main.local_world._localNumber++;
93 this.ControllingClient.OutPacket(objupdate); 115 this.ControllingClient.OutPacket(objupdate);
94 } 116 }
117
118 public override ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateTerseBlock() {
119 byte[] bytes = new byte[60];
120 int i=0;
121 ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock();
122
123 dat.TextureEntry = AvatarTemplate.TextureEntry;
124 libsecondlife.LLVector3 pos2 = new LLVector3(this.position.X, this.position.Y, this.position.Z);
125
126 uint ID = this.localid;
127 bytes[i++] = (byte)(ID % 256);
128 bytes[i++] = (byte)((ID >> 8) % 256);
129 bytes[i++] = (byte)((ID >> 16) % 256);
130 bytes[i++] = (byte)((ID >> 24) % 256);
131 bytes[i++] = 0;
132 bytes[i++] = 1;
133 i += 14;
134 bytes[i++] = 128;
135 bytes[i++] = 63;
136
137 byte[] pb = pos2.GetBytes();
138 Array.Copy(pb, 0, bytes, i, pb.Length);
139 i += 12;
140
141 ushort ac = 32767;
142 bytes[i++] = (byte)(ac % 256); // avatar.InternVelocityX
143 bytes[i++] = (byte)((ac>> 8) % 256);
144 bytes[i++] = (byte)(ac % 256); // avatar.InternVelocityY
145 bytes[i++] = (byte)((ac >> 8) % 256);
146 bytes[i++] = (byte)(ac % 256); // avatar.InternVelocityZ
147 bytes[i++] = (byte)((ac >> 8) % 256);
148
149 //accel
150 bytes[i++] = (byte)(ac % 256);
151 bytes[i++] = (byte)((ac >> 8) % 256);
152 bytes[i++] = (byte)(ac % 256);
153 bytes[i++] = (byte)((ac >> 8) % 256);
154 bytes[i++] = (byte)(ac % 256);
155 bytes[i++] = (byte)((ac >> 8) % 256);
156
157 //rot
158 bytes[i++] = (byte)(ac % 256);
159 bytes[i++] = (byte)((ac >> 8) % 256);
160 bytes[i++] = (byte)(ac % 256);
161 bytes[i++] = (byte)((ac >> 8) % 256);
162 bytes[i++] = (byte)(ac % 256);
163 bytes[i++] = (byte)((ac >> 8) % 256);
164 bytes[i++] = (byte)(ac % 256);
165 bytes[i++] = (byte)((ac >> 8) % 256);
166
167 //rotation vel
168 bytes[i++] = (byte)(ac % 256);
169 bytes[i++] = (byte)((ac >> 8) % 256);
170 bytes[i++] = (byte)(ac % 256);
171 bytes[i++] = (byte)((ac >> 8) % 256);
172 bytes[i++] = (byte)(ac % 256);
173 bytes[i++] = (byte)((ac >> 8) % 256);
174
175 dat.Data=bytes;
176 return(dat);
177
178 }
95 179
96 public void SendInitialAppearance() { 180 public void SendInitialAppearance() {
97 AgentWearablesUpdatePacket aw = new AgentWearablesUpdatePacket(); 181 AgentWearablesUpdatePacket aw = new AgentWearablesUpdatePacket();
@@ -151,5 +235,16 @@ namespace OpenSim.world
151 Console.WriteLine("Avatar.cs:SendRegionHandshake() - Sending RegionHandshake packet"); 235 Console.WriteLine("Avatar.cs:SendRegionHandshake() - Sending RegionHandshake packet");
152 this.ControllingClient.OutPacket(handshake); 236 this.ControllingClient.OutPacket(handshake);
153 } 237 }
238
239 public void HandleAgentUpdate(AgentUpdatePacket update) {
240 lock(this) {
241 // FIXME: shouldn't update these direction
242 this.rotation = new Quaternion(update.AgentData.BodyRotation.W, update.AgentData.BodyRotation.X, update.AgentData.BodyRotation.Y, update.AgentData.BodyRotation.Z);
243
244 this.CurrentKeyMask = update.AgentData.ControlFlags;
245 this.needupdate = true;
246 }
247 }
248
154 } 249 }
155} 250}
diff --git a/src/world/Entity.cs b/src/world/Entity.cs
index 92ab2da..7880a46 100644
--- a/src/world/Entity.cs
+++ b/src/world/Entity.cs
@@ -2,15 +2,18 @@ using System;
2using System.Collections.Generic; 2using System.Collections.Generic;
3using System.Text; 3using System.Text;
4using Axiom.MathLib; 4using Axiom.MathLib;
5using libsecondlife;
5using OpenSim.types; 6using OpenSim.types;
7using libsecondlife.Packets;
6 8
7namespace OpenSim.world 9namespace OpenSim.world
8{ 10{
9 public class Entity 11 public class Entity
10 { 12 {
11 protected libsecondlife.LLUUID uuid; 13 protected libsecondlife.LLUUID uuid;
12 protected Vector3 position; 14 protected uint localid;
13 protected Vector3 velocity; 15 public LLVector3 position;
16 public LLVector3 velocity;
14 protected Quaternion rotation; 17 protected Quaternion rotation;
15 protected string name; 18 protected string name;
16 protected List<Entity> children; 19 protected List<Entity> children;
@@ -19,8 +22,9 @@ namespace OpenSim.world
19 public Entity() 22 public Entity()
20 { 23 {
21 uuid = new libsecondlife.LLUUID(); 24 uuid = new libsecondlife.LLUUID();
22 position = new Vector3(); 25 localid = 8880000 + (OpenSim_Main.local_world._localNumber++); // FIXME - race condition!
23 velocity = new Vector3(); 26 position = new LLVector3();
27 velocity = new LLVector3();
24 rotation = new Quaternion(); 28 rotation = new Quaternion();
25 name = "(basic entity)"; 29 name = "(basic entity)";
26 children = new List<Entity>(); 30 children = new List<Entity>();
@@ -33,8 +37,14 @@ namespace OpenSim.world
33 if(child.needupdate) 37 if(child.needupdate)
34 child.update(); 38 child.update();
35 } 39 }
40 this.needupdate=false;
36 } 41 }
37 42
43 public virtual ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateTerseBlock() {
44 return null;
45 }
46
47
38 public virtual string getName() 48 public virtual string getName()
39 { 49 {
40 return name; 50 return name;
diff --git a/src/world/PhysicsEngine.cs b/src/world/PhysicsEngine.cs
index 7585135..a789828 100644
--- a/src/world/PhysicsEngine.cs
+++ b/src/world/PhysicsEngine.cs
@@ -18,6 +18,14 @@ namespace OpenSim.world
18 } 18 }
19 19
20 public void DoStuff(World simworld) { 20 public void DoStuff(World simworld) {
21 foreach (libsecondlife.LLUUID UUID in simworld.Entities.Keys)
22 {
23 if( true /* simworld.Entities[UUID].needupdate */) { // FIXME!
24 simworld.Entities[UUID].position += simworld.Entities[UUID].velocity;
25 Console.WriteLine("Moving "+UUID.ToString()+ " to "+ simworld.Entities[UUID].position.ToString());
26 }
27
28 }
21 } 29 }
22 } 30 }
23} 31}
diff --git a/src/world/World.cs b/src/world/World.cs
index 1fabca4..b261884 100644
--- a/src/world/World.cs
+++ b/src/world/World.cs
@@ -51,7 +51,17 @@ namespace OpenSim.world
51 if(Entities[UUID].needupdate) { 51 if(Entities[UUID].needupdate) {
52 Entities[UUID].update(); 52 Entities[UUID].update();
53 } 53 }
54 54 if(Entities[UUID] is Avatar) { // FIXME: only send updates when avatar moves.
55 ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseBlock = Entities[UUID].CreateTerseBlock();
56 foreach(OpenSimClient client in OpenSim_Main.sim.ClientThreads.Values) {
57 ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket();
58 terse.RegionData.RegionHandle = OpenSim_Main.cfg.RegionHandle; // FIXME
59 terse.RegionData.TimeDilation = 0;
60 terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
61 terse.ObjectData[0] = terseBlock;
62 client.OutPacket(terse);
63 }
64 }
55 } 65 }
56 } 66 }
57 67