aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim.RegionServer/world
diff options
context:
space:
mode:
authorMW2007-05-21 16:06:58 +0000
committerMW2007-05-21 16:06:58 +0000
commitfe46b045f75dec5ecdd0a29273c70df3e6ea540e (patch)
tree554c0fb47e513fc6a89f496d99b7b67de24edde7 /OpenSim.RegionServer/world
parentIncreased version number to 0.2! ZOMG! (diff)
downloadopensim-SC-fe46b045f75dec5ecdd0a29273c70df3e6ea540e.zip
opensim-SC-fe46b045f75dec5ecdd0a29273c70df3e6ea540e.tar.gz
opensim-SC-fe46b045f75dec5ecdd0a29273c70df3e6ea540e.tar.bz2
opensim-SC-fe46b045f75dec5ecdd0a29273c70df3e6ea540e.tar.xz
Start of a redesign of SimClient (now renamed ClientView)/World/Avatar/Prim , switching to a event based system (World/Avatar register as event handlers). It is possible that I've broke something with this commit but it doesn't matter as I'll just hide and no one will find me.
Diffstat (limited to '')
-rw-r--r--OpenSim.RegionServer/world/Avatar.Update.cs57
-rw-r--r--OpenSim.RegionServer/world/Avatar.cs8
-rw-r--r--OpenSim.RegionServer/world/Primitive.cs16
-rw-r--r--OpenSim.RegionServer/world/Primitive2.cs27
-rw-r--r--OpenSim.RegionServer/world/SceneObject.cs4
-rw-r--r--OpenSim.RegionServer/world/World.PacketHandlers.cs56
-rw-r--r--OpenSim.RegionServer/world/World.cs34
-rw-r--r--OpenSim.RegionServer/world/WorldBase.cs10
8 files changed, 101 insertions, 111 deletions
diff --git a/OpenSim.RegionServer/world/Avatar.Update.cs b/OpenSim.RegionServer/world/Avatar.Update.cs
index ba2965d..75f0bb4 100644
--- a/OpenSim.RegionServer/world/Avatar.Update.cs
+++ b/OpenSim.RegionServer/world/Avatar.Update.cs
@@ -28,9 +28,10 @@ namespace OpenSim.world
28 terse.RegionData.TimeDilation = 64096; 28 terse.RegionData.TimeDilation = 64096;
29 terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; 29 terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
30 terse.ObjectData[0] = terseBlock; 30 terse.ObjectData[0] = terseBlock;
31 foreach (SimClient client in m_clientThreads.Values) 31 List<Avatar> avList = this.m_world.RequestAvatarList();
32 foreach (Avatar client in avList)
32 { 33 {
33 client.OutPacket(terse); 34 client.SendPacketToViewer(terse);
34 } 35 }
35 36
36 updateflag = false; 37 updateflag = false;
@@ -51,9 +52,10 @@ namespace OpenSim.world
51 terse.RegionData.TimeDilation = 64096; 52 terse.RegionData.TimeDilation = 64096;
52 terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; 53 terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
53 terse.ObjectData[0] = terseBlock; 54 terse.ObjectData[0] = terseBlock;
54 foreach (SimClient client in m_clientThreads.Values) 55 List<Avatar> avList = this.m_world.RequestAvatarList();
56 foreach (Avatar client in avList)
55 { 57 {
56 client.OutPacket(terse); 58 client.SendPacketToViewer(terse);
57 } 59 }
58 _updateCount = 0; 60 _updateCount = 0;
59 } 61 }
@@ -134,15 +136,13 @@ namespace OpenSim.world
134 byte[] pb = pos2.GetBytes(); 136 byte[] pb = pos2.GetBytes();
135 Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 16, pb.Length); 137 Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 16, pb.Length);
136 m_world._localNumber++; 138 m_world._localNumber++;
137 foreach (SimClient client in m_clientThreads.Values) 139
140 List<Avatar> avList = this.m_world.RequestAvatarList();
141 foreach (Avatar client in avList)
138 { 142 {
139 client.OutPacket(objupdate); 143 client.SendPacketToViewer(objupdate);
140 if (client.AgentID != ControllingClient.AgentID) 144 if (client.ControllingClient.AgentID != this.ControllingClient.AgentID)
141 { 145 {
142 //the below line is already in Simclient.cs at line number 245 , directly below the call to this method
143 //if there is a problem/bug with that , then lets fix it there rather than duplicating it here
144 //client.ClientAvatar.SendAppearanceToOtherAgent(this.ControllingClient);
145
146 SendAppearanceToOtherAgent(client); 146 SendAppearanceToOtherAgent(client);
147 } 147 }
148 } 148 }
@@ -169,30 +169,12 @@ namespace OpenSim.world
169 ControllingClient.OutPacket(aw); 169 ControllingClient.OutPacket(aw);
170 } 170 }
171 171
172 public void SendAppearanceToOtherAgent(SimClient userInfo) 172 public void SendAppearanceToOtherAgent(Avatar avatarInfo)
173 { 173 {
174 AvatarAppearancePacket avp = new AvatarAppearancePacket(); 174 AvatarAppearancePacket avp = new AvatarAppearancePacket();
175 avp.VisualParam = new AvatarAppearancePacket.VisualParamBlock[218]; 175 avp.VisualParam = new AvatarAppearancePacket.VisualParamBlock[218];
176 avp.ObjectData.TextureEntry = this.avatarAppearanceTexture.ToBytes(); 176 avp.ObjectData.TextureEntry = this.avatarAppearanceTexture.ToBytes();
177 177
178 //a wearable update packets should only be sent about the viewers/agents own avatar not for other avatars
179 //but it seems that the following code only created the packets and never actually sent them anyway
180 /*AgentWearablesUpdatePacket aw = new AgentWearablesUpdatePacket();
181 aw.AgentData.AgentID = this.ControllingClient.AgentID;
182 aw.AgentData.SessionID = userInfo.SessionID;
183 aw.AgentData.SerialNum = 0; //removed the use of a random number as a random number could be less than the last number, should have a counter variable for this
184
185 aw.WearableData = new AgentWearablesUpdatePacket.WearableDataBlock[13];
186 AgentWearablesUpdatePacket.WearableDataBlock awb;
187 for (int i = 0; i < 13; i++)
188 {
189 awb = new AgentWearablesUpdatePacket.WearableDataBlock();
190 awb.WearableType = (byte)i;
191 awb.AssetID = this.Wearables[i].AssetID;
192 awb.ItemID = this.Wearables[i].ItemID;
193 aw.WearableData[i] = awb;
194 }*/
195
196 AvatarAppearancePacket.VisualParamBlock avblock = null; 178 AvatarAppearancePacket.VisualParamBlock avblock = null;
197 for (int i = 0; i < 218; i++) 179 for (int i = 0; i < 218; i++)
198 { 180 {
@@ -203,7 +185,7 @@ namespace OpenSim.world
203 185
204 avp.Sender.IsTrial = false; 186 avp.Sender.IsTrial = false;
205 avp.Sender.ID = ControllingClient.AgentID; 187 avp.Sender.ID = ControllingClient.AgentID;
206 userInfo.OutPacket(avp); 188 avatarInfo.SendPacketToViewer(avp);
207 } 189 }
208 190
209 public void SetAppearance(AgentSetAppearancePacket appear) 191 public void SetAppearance(AgentSetAppearancePacket appear)
@@ -214,9 +196,11 @@ namespace OpenSim.world
214 { 196 {
215 this.visualParams[i] = appear.VisualParam[i].ParamValue; 197 this.visualParams[i] = appear.VisualParam[i].ParamValue;
216 } 198 }
217 foreach (SimClient client in m_clientThreads.Values) 199
200 List<Avatar> avList = this.m_world.RequestAvatarList();
201 foreach (Avatar client in avList)
218 { 202 {
219 if (client.AgentID != ControllingClient.AgentID) 203 if (client.ControllingClient.AgentID != this.ControllingClient.AgentID)
220 { 204 {
221 SendAppearanceToOtherAgent(client); 205 SendAppearanceToOtherAgent(client);
222 } 206 }
@@ -320,11 +304,12 @@ namespace OpenSim.world
320 ani.AnimationList[0].AnimID = this.current_anim; 304 ani.AnimationList[0].AnimID = this.current_anim;
321 ani.AnimationList[0].AnimSequenceID = this.anim_seq; 305 ani.AnimationList[0].AnimSequenceID = this.anim_seq;
322 306
323 //ControllingClient.OutPacket(ani); 307 List<Avatar> avList = this.m_world.RequestAvatarList();
324 foreach (SimClient client in m_clientThreads.Values) 308 foreach (Avatar client in avList)
325 { 309 {
326 client.OutPacket(ani); 310 client.SendPacketToViewer(ani);
327 } 311 }
312
328 } 313 }
329 314
330 } 315 }
diff --git a/OpenSim.RegionServer/world/Avatar.cs b/OpenSim.RegionServer/world/Avatar.cs
index c684c45..55e5ae4 100644
--- a/OpenSim.RegionServer/world/Avatar.cs
+++ b/OpenSim.RegionServer/world/Avatar.cs
@@ -16,7 +16,7 @@ namespace OpenSim.world
16 public static AvatarAnimations Animations; 16 public static AvatarAnimations Animations;
17 public string firstname; 17 public string firstname;
18 public string lastname; 18 public string lastname;
19 public SimClient ControllingClient; 19 public ClientView ControllingClient;
20 public LLUUID current_anim; 20 public LLUUID current_anim;
21 public int anim_seq; 21 public int anim_seq;
22 private static libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock AvatarTemplate; 22 private static libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock AvatarTemplate;
@@ -30,16 +30,16 @@ namespace OpenSim.world
30 private AvatarWearable[] Wearables; 30 private AvatarWearable[] Wearables;
31 private LLVector3 positionLastFrame = new LLVector3(0, 0, 0); 31 private LLVector3 positionLastFrame = new LLVector3(0, 0, 0);
32 private ulong m_regionHandle; 32 private ulong m_regionHandle;
33 private Dictionary<uint, SimClient> m_clientThreads; 33 //private Dictionary<uint, ClientView> m_clientThreads;
34 private string m_regionName; 34 private string m_regionName;
35 private ushort m_regionWaterHeight; 35 private ushort m_regionWaterHeight;
36 private bool m_regionTerraform; 36 private bool m_regionTerraform;
37 //private bool childShadowAvatar = false; 37 //private bool childShadowAvatar = false;
38 38
39 public Avatar(SimClient TheClient, World world, string regionName, Dictionary<uint, SimClient> clientThreads, ulong regionHandle, bool regionTerraform, ushort regionWater) 39 public Avatar(ClientView TheClient, World world, string regionName, Dictionary<uint, ClientView> clientThreads, ulong regionHandle, bool regionTerraform, ushort regionWater)
40 { 40 {
41 m_world = world; 41 m_world = world;
42 m_clientThreads = clientThreads; 42 // m_clientThreads = clientThreads;
43 m_regionName = regionName; 43 m_regionName = regionName;
44 m_regionHandle = regionHandle; 44 m_regionHandle = regionHandle;
45 m_regionTerraform = regionTerraform; 45 m_regionTerraform = regionTerraform;
diff --git a/OpenSim.RegionServer/world/Primitive.cs b/OpenSim.RegionServer/world/Primitive.cs
index 4f861f7..e048a9e 100644
--- a/OpenSim.RegionServer/world/Primitive.cs
+++ b/OpenSim.RegionServer/world/Primitive.cs
@@ -22,7 +22,7 @@ namespace OpenSim.world
22 private bool physicsEnabled = false; 22 private bool physicsEnabled = false;
23 private bool physicstest = false; 23 private bool physicstest = false;
24 private LLVector3 positionLastFrame = new LLVector3(0, 0, 0); 24 private LLVector3 positionLastFrame = new LLVector3(0, 0, 0);
25 private Dictionary<uint, SimClient> m_clientThreads; 25 private Dictionary<uint, ClientView> m_clientThreads;
26 private ulong m_regionHandle; 26 private ulong m_regionHandle;
27 private const uint FULL_MASK_PERMISSIONS = 2147483647; 27 private const uint FULL_MASK_PERMISSIONS = 2147483647;
28 28
@@ -75,7 +75,7 @@ namespace OpenSim.world
75 } 75 }
76 } 76 }
77 77
78 public Primitive(Dictionary<uint, SimClient> clientThreads, ulong regionHandle, World world) 78 public Primitive(Dictionary<uint, ClientView> clientThreads, ulong regionHandle, World world)
79 { 79 {
80 mesh_cutbegin = 0.0f; 80 mesh_cutbegin = 0.0f;
81 mesh_cutend = 1.0f; 81 mesh_cutend = 1.0f;
@@ -104,7 +104,7 @@ namespace OpenSim.world
104 return this.primData.ToBytes(); 104 return this.primData.ToBytes();
105 } 105 }
106 106
107 public void GetProperites(SimClient client) 107 public void GetProperites(ClientView client)
108 { 108 {
109 ObjectPropertiesPacket proper = new ObjectPropertiesPacket(); 109 ObjectPropertiesPacket proper = new ObjectPropertiesPacket();
110 proper.ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[1]; 110 proper.ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[1];
@@ -164,7 +164,7 @@ namespace OpenSim.world
164 } 164 }
165 if (this.newPrimFlag) 165 if (this.newPrimFlag)
166 { 166 {
167 foreach (SimClient client in m_clientThreads.Values) 167 foreach (ClientView client in m_clientThreads.Values)
168 { 168 {
169 client.OutPacket(OurPacket); 169 client.OutPacket(OurPacket);
170 } 170 }
@@ -177,7 +177,7 @@ namespace OpenSim.world
177 terse.RegionData.TimeDilation = 64096; 177 terse.RegionData.TimeDilation = 64096;
178 terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; 178 terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
179 terse.ObjectData[0] = this.CreateImprovedBlock(); 179 terse.ObjectData[0] = this.CreateImprovedBlock();
180 foreach (SimClient client in m_clientThreads.Values) 180 foreach (ClientView client in m_clientThreads.Values)
181 { 181 {
182 client.OutPacket(terse); 182 client.OutPacket(terse);
183 } 183 }
@@ -185,7 +185,7 @@ namespace OpenSim.world
185 } 185 }
186 else if (this.dirtyFlag) 186 else if (this.dirtyFlag)
187 { 187 {
188 foreach (SimClient client in m_clientThreads.Values) 188 foreach (ClientView client in m_clientThreads.Values)
189 { 189 {
190 UpdateClient(client); 190 UpdateClient(client);
191 } 191 }
@@ -202,7 +202,7 @@ namespace OpenSim.world
202 terse.RegionData.TimeDilation = 64096; 202 terse.RegionData.TimeDilation = 64096;
203 terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; 203 terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
204 terse.ObjectData[0] = this.CreateImprovedBlock(); 204 terse.ObjectData[0] = this.CreateImprovedBlock();
205 foreach (SimClient client in m_clientThreads.Values) 205 foreach (ClientView client in m_clientThreads.Values)
206 { 206 {
207 client.OutPacket(terse); 207 client.OutPacket(terse);
208 } 208 }
@@ -220,7 +220,7 @@ namespace OpenSim.world
220 } 220 }
221 } 221 }
222 222
223 public void UpdateClient(SimClient RemoteClient) 223 public void UpdateClient(ClientView RemoteClient)
224 { 224 {
225 225
226 LLVector3 lPos; 226 LLVector3 lPos;
diff --git a/OpenSim.RegionServer/world/Primitive2.cs b/OpenSim.RegionServer/world/Primitive2.cs
index 3b39456..6d071d4 100644
--- a/OpenSim.RegionServer/world/Primitive2.cs
+++ b/OpenSim.RegionServer/world/Primitive2.cs
@@ -16,7 +16,7 @@ namespace OpenSim.world
16 protected PrimData primData; 16 protected PrimData primData;
17 //private ObjectUpdatePacket OurPacket; 17 //private ObjectUpdatePacket OurPacket;
18 private LLVector3 positionLastFrame = new LLVector3(0, 0, 0); 18 private LLVector3 positionLastFrame = new LLVector3(0, 0, 0);
19 private Dictionary<uint, SimClient> m_clientThreads; 19 private Dictionary<uint, ClientView> m_clientThreads;
20 private ulong m_regionHandle; 20 private ulong m_regionHandle;
21 private const uint FULL_MASK_PERMISSIONS = 2147483647; 21 private const uint FULL_MASK_PERMISSIONS = 2147483647;
22 private bool physicsEnabled = false; 22 private bool physicsEnabled = false;
@@ -58,7 +58,7 @@ namespace OpenSim.world
58 } 58 }
59 #endregion 59 #endregion
60 60
61 public Primitive2(Dictionary<uint, SimClient> clientThreads, ulong regionHandle, World world) 61 public Primitive2(Dictionary<uint, ClientView> clientThreads, ulong regionHandle, World world)
62 { 62 {
63 m_clientThreads = clientThreads; 63 m_clientThreads = clientThreads;
64 m_regionHandle = regionHandle; 64 m_regionHandle = regionHandle;
@@ -66,6 +66,17 @@ namespace OpenSim.world
66 inventoryItems = new Dictionary<LLUUID, InventoryItem>(); 66 inventoryItems = new Dictionary<LLUUID, InventoryItem>();
67 } 67 }
68 68
69 public Primitive2(Dictionary<uint, ClientView> clientThreads, ulong regionHandle, World world, LLUUID owner)
70 {
71 m_clientThreads = clientThreads;
72 m_regionHandle = regionHandle;
73 m_world = world;
74 inventoryItems = new Dictionary<LLUUID, InventoryItem>();
75 this.primData = new PrimData();
76 this.primData.CreationDate = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
77 this.primData.OwnerID = owner;
78 }
79
69 public byte[] GetByteArray() 80 public byte[] GetByteArray()
70 { 81 {
71 byte[] result = null; 82 byte[] result = null;
@@ -159,7 +170,7 @@ namespace OpenSim.world
159 170
160 } 171 }
161 172
162 public void GetProperites(SimClient client) 173 public void GetProperites(ClientView client)
163 { 174 {
164 ObjectPropertiesPacket proper = new ObjectPropertiesPacket(); 175 ObjectPropertiesPacket proper = new ObjectPropertiesPacket();
165 proper.ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[1]; 176 proper.ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[1];
@@ -202,12 +213,12 @@ namespace OpenSim.world
202 return null; 213 return null;
203 } 214 }
204 215
205 public void RequestInventoryInfo(SimClient simClient, RequestTaskInventoryPacket packet) 216 public void RequestInventoryInfo(ClientView simClient, RequestTaskInventoryPacket packet)
206 { 217 {
207 218
208 } 219 }
209 220
210 public void RequestXferInventory(SimClient simClient, ulong xferID) 221 public void RequestXferInventory(ClientView simClient, ulong xferID)
211 { 222 {
212 //will only currently work if the total size of the inventory data array is under about 1000 bytes 223 //will only currently work if the total size of the inventory data array is under about 1000 bytes
213 SendXferPacketPacket send = new SendXferPacketPacket(); 224 SendXferPacketPacket send = new SendXferPacketPacket();
@@ -246,7 +257,7 @@ namespace OpenSim.world
246 #region Update viewers Methods 257 #region Update viewers Methods
247 258
248 //should change these mehtods, so that outgoing packets are sent through the avatar class 259 //should change these mehtods, so that outgoing packets are sent through the avatar class
249 public void SendFullUpdateToClient(SimClient remoteClient) 260 public void SendFullUpdateToClient(ClientView remoteClient)
250 { 261 {
251 LLVector3 lPos; 262 LLVector3 lPos;
252 if (this._physActor != null && this.physicsEnabled) 263 if (this._physActor != null && this.physicsEnabled)
@@ -273,7 +284,7 @@ namespace OpenSim.world
273 284
274 } 285 }
275 286
276 public void SendTerseUpdateToClient(SimClient RemoteClient) 287 public void SendTerseUpdateToClient(ClientView RemoteClient)
277 { 288 {
278 289
279 } 290 }
@@ -316,7 +327,7 @@ namespace OpenSim.world
316 PData.PathTwist = addPacket.ObjectData.PathTwist; 327 PData.PathTwist = addPacket.ObjectData.PathTwist;
317 PData.PathTwistBegin = addPacket.ObjectData.PathTwistBegin; 328 PData.PathTwistBegin = addPacket.ObjectData.PathTwistBegin;
318 LLVector3 pos1 = addPacket.ObjectData.RayEnd; 329 LLVector3 pos1 = addPacket.ObjectData.RayEnd;
319 this.primData.FullID = this.uuid = LLUUID.Random(); 330 this.primData.FullID = this.uuid = LLUUID.Random();
320 this.localid = (uint)(localID); 331 this.localid = (uint)(localID);
321 this.primData.Position = this.Pos = pos1; 332 this.primData.Position = this.Pos = pos1;
322 } 333 }
diff --git a/OpenSim.RegionServer/world/SceneObject.cs b/OpenSim.RegionServer/world/SceneObject.cs
index 5b5a7b2..a846fb5 100644
--- a/OpenSim.RegionServer/world/SceneObject.cs
+++ b/OpenSim.RegionServer/world/SceneObject.cs
@@ -15,7 +15,7 @@ namespace OpenSim.world
15 { 15 {
16 private LLUUID rootUUID; 16 private LLUUID rootUUID;
17 private Dictionary<LLUUID, Primitive2> ChildPrimitives = new Dictionary<LLUUID, Primitive2>(); 17 private Dictionary<LLUUID, Primitive2> ChildPrimitives = new Dictionary<LLUUID, Primitive2>();
18 private Dictionary<uint, SimClient> m_clientThreads; 18 private Dictionary<uint, ClientView> m_clientThreads;
19 private World m_world; 19 private World m_world;
20 20
21 public SceneObject() 21 public SceneObject()
@@ -42,7 +42,7 @@ namespace OpenSim.world
42 42
43 } 43 }
44 44
45 public void GetProperites(SimClient client) 45 public void GetProperites(ClientView client)
46 { 46 {
47 /* 47 /*
48 ObjectPropertiesPacket proper = new ObjectPropertiesPacket(); 48 ObjectPropertiesPacket proper = new ObjectPropertiesPacket();
diff --git a/OpenSim.RegionServer/world/World.PacketHandlers.cs b/OpenSim.RegionServer/world/World.PacketHandlers.cs
index 175b777..27f200f 100644
--- a/OpenSim.RegionServer/world/World.PacketHandlers.cs
+++ b/OpenSim.RegionServer/world/World.PacketHandlers.cs
@@ -16,7 +16,7 @@ namespace OpenSim.world
16 public partial class World 16 public partial class World
17 { 17 {
18 18
19 public bool ModifyTerrain(SimClient simClient, Packet packet) 19 public bool ModifyTerrain(ClientView simClient, Packet packet)
20 { 20 {
21 ModifyLandPacket modify = (ModifyLandPacket)packet; 21 ModifyLandPacket modify = (ModifyLandPacket)packet;
22 22
@@ -42,68 +42,44 @@ namespace OpenSim.world
42 return true; 42 return true;
43 } 43 }
44 44
45 public bool SimChat(SimClient simClient, Packet packet) 45 public void SimChat(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID)
46 { 46 {
47 System.Text.Encoding enc = System.Text.Encoding.ASCII; 47 foreach (ClientView client in m_clientThreads.Values)
48 ChatFromViewerPacket inchatpack = (ChatFromViewerPacket)packet;
49 if (Util.FieldToString(inchatpack.ChatData.Message) == "")
50 {
51 //empty message so don't bother with it
52 return true;
53 }
54
55 string fromName = simClient.ClientAvatar.firstname + " " + simClient.ClientAvatar.lastname;
56 byte[] message = inchatpack.ChatData.Message;
57 byte type = inchatpack.ChatData.Type;
58 LLVector3 fromPos = simClient.ClientAvatar.Pos;
59 LLUUID fromAgentID = simClient.AgentID;
60
61 libsecondlife.Packets.ChatFromSimulatorPacket reply = new ChatFromSimulatorPacket();
62 reply.ChatData.Audible = 1;
63 reply.ChatData.Message = message;
64 reply.ChatData.ChatType = type;
65 reply.ChatData.SourceType = 1;
66 reply.ChatData.Position = fromPos;
67 reply.ChatData.FromName = enc.GetBytes(fromName + "\0");
68 reply.ChatData.OwnerID = fromAgentID;
69 reply.ChatData.SourceID = fromAgentID;
70
71 foreach (SimClient client in m_clientThreads.Values)
72 { 48 {
73 // int dis = Util.fast_distance2d((int)(client.ClientAvatar.Pos.X - simClient.ClientAvatar.Pos.X), (int)(client.ClientAvatar.Pos.Y - simClient.ClientAvatar.Pos.Y)); 49 // int dis = Util.fast_distance2d((int)(client.ClientAvatar.Pos.X - simClient.ClientAvatar.Pos.X), (int)(client.ClientAvatar.Pos.Y - simClient.ClientAvatar.Pos.Y));
74 int dis = (int)client.ClientAvatar.Pos.GetDistanceTo(simClient.ClientAvatar.Pos); 50 int dis = (int)client.ClientAvatar.Pos.GetDistanceTo(fromPos);
75 51
76 switch (inchatpack.ChatData.Type) 52 switch (type)
77 { 53 {
78 case 0: // Whisper 54 case 0: // Whisper
79 if ((dis < 10) && (dis > -10)) 55 if ((dis < 10) && (dis > -10))
80 { 56 {
81 client.OutPacket(reply); 57 //should change so the message is sent through the avatar rather than direct to the ClientView
58 client.SendChatMessage(message, type, fromPos, fromName, fromAgentID);
82 } 59 }
83 break; 60 break;
84 case 1: // Say 61 case 1: // Say
85 if ((dis < 30) && (dis > -30)) 62 if ((dis < 30) && (dis > -30))
86 { 63 {
87 client.OutPacket(reply); 64 client.SendChatMessage(message, type, fromPos, fromName, fromAgentID);
88 } 65 }
89 break; 66 break;
90 case 2: // Shout 67 case 2: // Shout
91 if ((dis < 100) && (dis > -100)) 68 if ((dis < 100) && (dis > -100))
92 { 69 {
93 client.OutPacket(reply); 70 client.SendChatMessage(message, type, fromPos, fromName, fromAgentID);
94 } 71 }
95 break; 72 break;
96 73
97 case 0xff: // Broadcast 74 case 0xff: // Broadcast
98 client.OutPacket(reply); 75 client.SendChatMessage(message, type, fromPos, fromName, fromAgentID);
99 break; 76 break;
100 } 77 }
101 78
102 } 79 }
103 return true;
104 } 80 }
105 81
106 public bool RezObject(SimClient simClient, Packet packet) 82 public bool RezObject(ClientView simClient, Packet packet)
107 { 83 {
108 RezObjectPacket rezPacket = (RezObjectPacket)packet; 84 RezObjectPacket rezPacket = (RezObjectPacket)packet;
109 AgentInventory inven = this._inventoryCache.GetAgentsInventory(simClient.AgentID); 85 AgentInventory inven = this._inventoryCache.GetAgentsInventory(simClient.AgentID);
@@ -126,7 +102,7 @@ namespace OpenSim.world
126 return true; 102 return true;
127 } 103 }
128 104
129 public bool DeRezObject(SimClient simClient, Packet packet) 105 public bool DeRezObject(ClientView simClient, Packet packet)
130 { 106 {
131 DeRezObjectPacket DeRezPacket = (DeRezObjectPacket)packet; 107 DeRezObjectPacket DeRezPacket = (DeRezObjectPacket)packet;
132 108
@@ -151,7 +127,7 @@ namespace OpenSim.world
151 kill.ObjectData = new KillObjectPacket.ObjectDataBlock[1]; 127 kill.ObjectData = new KillObjectPacket.ObjectDataBlock[1];
152 kill.ObjectData[0] = new KillObjectPacket.ObjectDataBlock(); 128 kill.ObjectData[0] = new KillObjectPacket.ObjectDataBlock();
153 kill.ObjectData[0].ID = ent.localid; 129 kill.ObjectData[0].ID = ent.localid;
154 foreach (SimClient client in m_clientThreads.Values) 130 foreach (ClientView client in m_clientThreads.Values)
155 { 131 {
156 client.OutPacket(kill); 132 client.OutPacket(kill);
157 } 133 }
@@ -201,7 +177,7 @@ namespace OpenSim.world
201 kill.ObjectData = new KillObjectPacket.ObjectDataBlock[1]; 177 kill.ObjectData = new KillObjectPacket.ObjectDataBlock[1];
202 kill.ObjectData[0] = new KillObjectPacket.ObjectDataBlock(); 178 kill.ObjectData[0] = new KillObjectPacket.ObjectDataBlock();
203 kill.ObjectData[0].ID = selectedEnt.localid; 179 kill.ObjectData[0].ID = selectedEnt.localid;
204 foreach (SimClient client in m_clientThreads.Values) 180 foreach (ClientView client in m_clientThreads.Values)
205 { 181 {
206 client.OutPacket(kill); 182 client.OutPacket(kill);
207 } 183 }
@@ -215,7 +191,7 @@ namespace OpenSim.world
215 return true; 191 return true;
216 } 192 }
217 193
218 public void RequestMapBlock(SimClient simClient, int minX, int minY, int maxX, int maxY) 194 public void RequestMapBlock(ClientView simClient, int minX, int minY, int maxX, int maxY)
219 { 195 {
220 System.Text.Encoding _enc = System.Text.Encoding.ASCII; 196 System.Text.Encoding _enc = System.Text.Encoding.ASCII;
221 if (((m_regInfo.RegionLocX > minX) && (m_regInfo.RegionLocX < maxX)) && ((m_regInfo.RegionLocY > minY) && (m_regInfo.RegionLocY < maxY))) 197 if (((m_regInfo.RegionLocX > minX) && (m_regInfo.RegionLocX < maxX)) && ((m_regInfo.RegionLocY > minY) && (m_regInfo.RegionLocY < maxY)))
diff --git a/OpenSim.RegionServer/world/World.cs b/OpenSim.RegionServer/world/World.cs
index 983e66d..c90e3f6 100644
--- a/OpenSim.RegionServer/world/World.cs
+++ b/OpenSim.RegionServer/world/World.cs
@@ -57,7 +57,7 @@ namespace OpenSim.world
57 /// <param name="clientThreads">Dictionary to contain client threads</param> 57 /// <param name="clientThreads">Dictionary to contain client threads</param>
58 /// <param name="regionHandle">Region Handle for this region</param> 58 /// <param name="regionHandle">Region Handle for this region</param>
59 /// <param name="regionName">Region Name for this region</param> 59 /// <param name="regionName">Region Name for this region</param>
60 public World(Dictionary<uint, SimClient> clientThreads, RegionInfo regInfo, ulong regionHandle, string regionName) 60 public World(Dictionary<uint, ClientView> clientThreads, RegionInfo regInfo, ulong regionHandle, string regionName)
61 { 61 {
62 try 62 try
63 { 63 {
@@ -324,7 +324,7 @@ namespace OpenSim.world
324 } 324 }
325 this.localStorage.SaveMap(this.Terrain.getHeights1D()); 325 this.localStorage.SaveMap(this.Terrain.getHeights1D());
326 326
327 foreach (SimClient client in m_clientThreads.Values) 327 foreach (ClientView client in m_clientThreads.Values)
328 { 328 {
329 this.SendLayerData(client); 329 this.SendLayerData(client);
330 } 330 }
@@ -355,7 +355,7 @@ namespace OpenSim.world
355 } 355 }
356 this.localStorage.SaveMap(this.Terrain.getHeights1D()); 356 this.localStorage.SaveMap(this.Terrain.getHeights1D());
357 357
358 foreach (SimClient client in m_clientThreads.Values) 358 foreach (ClientView client in m_clientThreads.Values)
359 { 359 {
360 this.SendLayerData(client); 360 this.SendLayerData(client);
361 } 361 }
@@ -389,7 +389,7 @@ namespace OpenSim.world
389 } 389 }
390 this.localStorage.SaveMap(this.Terrain.getHeights1D()); 390 this.localStorage.SaveMap(this.Terrain.getHeights1D());
391 391
392 foreach (SimClient client in m_clientThreads.Values) 392 foreach (ClientView client in m_clientThreads.Values)
393 { 393 {
394 this.SendLayerData(pointx, pointy, client); 394 this.SendLayerData(pointx, pointy, client);
395 } 395 }
@@ -437,7 +437,7 @@ namespace OpenSim.world
437 /// Sends prims to a client 437 /// Sends prims to a client
438 /// </summary> 438 /// </summary>
439 /// <param name="RemoteClient">Client to send to</param> 439 /// <param name="RemoteClient">Client to send to</param>
440 public void GetInitialPrims(SimClient RemoteClient) 440 public void GetInitialPrims(ClientView RemoteClient)
441 { 441 {
442 try 442 try
443 { 443 {
@@ -495,7 +495,7 @@ namespace OpenSim.world
495 } 495 }
496 } 496 }
497 497
498 public void AddNewPrim(ObjectAddPacket addPacket, SimClient AgentClient) 498 public void AddNewPrim(ObjectAddPacket addPacket, ClientView AgentClient)
499 { 499 {
500 AddNewPrim(addPacket, AgentClient.AgentID); 500 AddNewPrim(addPacket, AgentClient.AgentID);
501 } 501 }
@@ -530,8 +530,9 @@ namespace OpenSim.world
530 530
531 #region Add/Remove Avatar Methods 531 #region Add/Remove Avatar Methods
532 532
533 public override void AddViewerAgent(SimClient agentClient) 533 public override void AddViewerAgent(ClientView agentClient)
534 { 534 {
535 agentClient.OnChatFromViewer += new ClientView.ChatFromViewer(this.SimChat);
535 try 536 try
536 { 537 {
537 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "World.cs:AddViewerAgent() - Creating new avatar for remote viewer agent"); 538 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "World.cs:AddViewerAgent() - Creating new avatar for remote viewer agent");
@@ -576,7 +577,7 @@ namespace OpenSim.world
576 } 577 }
577 } 578 }
578 579
579 public override void RemoveViewerAgent(SimClient agentClient) 580 public override void RemoveViewerAgent(ClientView agentClient)
580 { 581 {
581 try 582 try
582 { 583 {
@@ -600,6 +601,23 @@ namespace OpenSim.world
600 } 601 }
601 #endregion 602 #endregion
602 603
604 #region Request Avatars List Methods
605 //The idea is to have a group of method that return a list of avatars meeting some requirement
606 // ie it could be all Avatars within a certain range of the calling prim/avatar.
607
608 public List<Avatar> RequestAvatarList()
609 {
610 List<Avatar> result = new List<Avatar>();
611
612 foreach (Avatar avatar in Avatars.Values)
613 {
614 result.Add(avatar);
615 }
616
617 return result;
618 }
619 #endregion
620
603 #region ShutDown 621 #region ShutDown
604 /// <summary> 622 /// <summary>
605 /// Tidy before shutdown 623 /// Tidy before shutdown
diff --git a/OpenSim.RegionServer/world/WorldBase.cs b/OpenSim.RegionServer/world/WorldBase.cs
index b8c086d..edc5518 100644
--- a/OpenSim.RegionServer/world/WorldBase.cs
+++ b/OpenSim.RegionServer/world/WorldBase.cs
@@ -20,7 +20,7 @@ namespace OpenSim.world
20 public class WorldBase 20 public class WorldBase
21 { 21 {
22 public Dictionary<libsecondlife.LLUUID, Entity> Entities; 22 public Dictionary<libsecondlife.LLUUID, Entity> Entities;
23 protected Dictionary<uint, SimClient> m_clientThreads; 23 protected Dictionary<uint, ClientView> m_clientThreads;
24 protected ulong m_regionHandle; 24 protected ulong m_regionHandle;
25 protected string m_regionName; 25 protected string m_regionName;
26 protected InventoryCache _inventoryCache; 26 protected InventoryCache _inventoryCache;
@@ -90,7 +90,7 @@ namespace OpenSim.world
90 /// Send the region heightmap to the client 90 /// Send the region heightmap to the client
91 /// </summary> 91 /// </summary>
92 /// <param name="RemoteClient">Client to send to</param> 92 /// <param name="RemoteClient">Client to send to</param>
93 public virtual void SendLayerData(SimClient RemoteClient) 93 public virtual void SendLayerData(ClientView RemoteClient)
94 { 94 {
95 try 95 try
96 { 96 {
@@ -122,7 +122,7 @@ namespace OpenSim.world
122 /// <param name="px">Patch coordinate (x) 0..16</param> 122 /// <param name="px">Patch coordinate (x) 0..16</param>
123 /// <param name="py">Patch coordinate (y) 0..16</param> 123 /// <param name="py">Patch coordinate (y) 0..16</param>
124 /// <param name="RemoteClient">The client to send to</param> 124 /// <param name="RemoteClient">The client to send to</param>
125 public void SendLayerData(int px, int py, SimClient RemoteClient) 125 public void SendLayerData(int px, int py, ClientView RemoteClient)
126 { 126 {
127 try 127 try
128 { 128 {
@@ -148,7 +148,7 @@ namespace OpenSim.world
148 /// Add a new Agent's avatar 148 /// Add a new Agent's avatar
149 /// </summary> 149 /// </summary>
150 /// <param name="agentClient"></param> 150 /// <param name="agentClient"></param>
151 public virtual void AddViewerAgent(SimClient agentClient) 151 public virtual void AddViewerAgent(ClientView agentClient)
152 { 152 {
153 153
154 } 154 }
@@ -157,7 +157,7 @@ namespace OpenSim.world
157 /// Remove a Agent's avatar 157 /// Remove a Agent's avatar
158 /// </summary> 158 /// </summary>
159 /// <param name="agentClient"></param> 159 /// <param name="agentClient"></param>
160 public virtual void RemoveViewerAgent(SimClient agentClient) 160 public virtual void RemoveViewerAgent(ClientView agentClient)
161 { 161 {
162 162
163 } 163 }