aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim.RegionServer/OpenSimMain.cs25
-rw-r--r--OpenSim.RegionServer/SimClient.cs176
-rw-r--r--OpenSim.RegionServer/world/World.cs76
3 files changed, 147 insertions, 130 deletions
diff --git a/OpenSim.RegionServer/OpenSimMain.cs b/OpenSim.RegionServer/OpenSimMain.cs
index 21f4878..ed957af 100644
--- a/OpenSim.RegionServer/OpenSimMain.cs
+++ b/OpenSim.RegionServer/OpenSimMain.cs
@@ -353,6 +353,8 @@ namespace OpenSim
353 protected virtual void RegisterClientPacketHandlers() 353 protected virtual void RegisterClientPacketHandlers()
354 { 354 {
355 SimClient.AddPacketHandler(PacketType.ModifyLand, LocalWorld.ModifyTerrain); 355 SimClient.AddPacketHandler(PacketType.ModifyLand, LocalWorld.ModifyTerrain);
356 SimClient.AddPacketHandler(PacketType.ChatFromViewer, LocalWorld.SimChat);
357 SimClient.AddPacketHandler(PacketType.UUIDNameRequest, this.RequestUUIDName);
356 } 358 }
357 359
358 public void RunCmd(string command, string[] cmdparams) 360 public void RunCmd(string command, string[] cmdparams)
@@ -401,6 +403,29 @@ namespace OpenSim
401 break; 403 break;
402 } 404 }
403 } 405 }
406
407 #region Client Packet Handlers
408
409 public bool RequestUUIDName(SimClient simClient, Packet packet)
410 {
411 System.Text.Encoding enc = System.Text.Encoding.ASCII;
412 Console.WriteLine(packet.ToString());
413 UUIDNameRequestPacket nameRequest = (UUIDNameRequestPacket)packet;
414 UUIDNameReplyPacket nameReply = new UUIDNameReplyPacket();
415 nameReply.UUIDNameBlock = new UUIDNameReplyPacket.UUIDNameBlockBlock[nameRequest.UUIDNameBlock.Length];
416
417 for (int i = 0; i < nameRequest.UUIDNameBlock.Length; i++)
418 {
419 nameReply.UUIDNameBlock[i] = new UUIDNameReplyPacket.UUIDNameBlockBlock();
420 nameReply.UUIDNameBlock[i].ID = nameRequest.UUIDNameBlock[i].ID;
421 nameReply.UUIDNameBlock[i].FirstName = enc.GetBytes("Who\0"); //for now send any name
422 nameReply.UUIDNameBlock[i].LastName = enc.GetBytes("Knows\0"); //in future need to look it up
423 }
424 simClient.OutPacket(nameReply);
425 return true;
426 }
427
428 #endregion
404 } 429 }
405 430
406 431
diff --git a/OpenSim.RegionServer/SimClient.cs b/OpenSim.RegionServer/SimClient.cs
index 5bc5e43..e9bfd56 100644
--- a/OpenSim.RegionServer/SimClient.cs
+++ b/OpenSim.RegionServer/SimClient.cs
@@ -123,7 +123,8 @@ namespace OpenSim
123 123
124 protected virtual void RegisterLocalPacketHandlers() 124 protected virtual void RegisterLocalPacketHandlers()
125 { 125 {
126 126 this.AddLocalPacketHandler(PacketType.LogoutRequest, this.Logout);
127 this.AddLocalPacketHandler(PacketType.AgentCachedTexture, this.AgentTextureCached);
127 } 128 }
128 129
129 public static bool AddPacketHandler(PacketType packetType, PacketMethod handler) 130 public static bool AddPacketHandler(PacketType packetType, PacketMethod handler)
@@ -250,24 +251,6 @@ namespace OpenSim
250 // Console.WriteLine(appear.ToString()); 251 // Console.WriteLine(appear.ToString());
251 this.ClientAvatar.SetAppearance(appear); 252 this.ClientAvatar.SetAppearance(appear);
252 break; 253 break;
253 case PacketType.AgentCachedTexture:
254 Console.WriteLine(Pack.ToString());
255 AgentCachedTexturePacket chechedtex = (AgentCachedTexturePacket)Pack;
256 AgentCachedTextureResponsePacket cachedresp = new AgentCachedTextureResponsePacket();
257 cachedresp.AgentData.AgentID = this.AgentID;
258 cachedresp.AgentData.SessionID = this.SessionID;
259 cachedresp.AgentData.SerialNum = this.cachedtextureserial;
260 this.cachedtextureserial++;
261 cachedresp.WearableData = new AgentCachedTextureResponsePacket.WearableDataBlock[chechedtex.WearableData.Length];
262 for (int i = 0; i < chechedtex.WearableData.Length; i++)
263 {
264 cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock();
265 cachedresp.WearableData[i].TextureIndex = chechedtex.WearableData[i].TextureIndex;
266 cachedresp.WearableData[i].TextureID = LLUUID.Zero;
267 cachedresp.WearableData[i].HostName = new byte[0];
268 }
269 this.OutPacket(cachedresp);
270 break;
271 case PacketType.ObjectAdd: 254 case PacketType.ObjectAdd:
272 m_world.AddNewPrim((ObjectAddPacket)Pack, this); 255 m_world.AddNewPrim((ObjectAddPacket)Pack, this);
273 break; 256 break;
@@ -292,7 +275,6 @@ namespace OpenSim
292 break; 275 break;
293 case PacketType.MultipleObjectUpdate: 276 case PacketType.MultipleObjectUpdate:
294 MultipleObjectUpdatePacket multipleupdate = (MultipleObjectUpdatePacket)Pack; 277 MultipleObjectUpdatePacket multipleupdate = (MultipleObjectUpdatePacket)Pack;
295
296 for (int i = 0; i < multipleupdate.ObjectData.Length; i++) 278 for (int i = 0; i < multipleupdate.ObjectData.Length; i++)
297 { 279 {
298 if (multipleupdate.ObjectData[i].Type == 9) //change position 280 if (multipleupdate.ObjectData[i].Type == 9) //change position
@@ -306,7 +288,6 @@ namespace OpenSim
306 288
307 } 289 }
308 } 290 }
309
310 //should update stored position of the prim 291 //should update stored position of the prim
311 } 292 }
312 else if (multipleupdate.ObjectData[i].Type == 10)//rotation 293 else if (multipleupdate.ObjectData[i].Type == 10)//rotation
@@ -350,63 +331,6 @@ namespace OpenSim
350 case PacketType.AgentUpdate: 331 case PacketType.AgentUpdate:
351 ClientAvatar.HandleUpdate((AgentUpdatePacket)Pack); 332 ClientAvatar.HandleUpdate((AgentUpdatePacket)Pack);
352 break; 333 break;
353 case PacketType.LogoutRequest:
354 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("OpenSimClient.cs:ProcessInPacket() - Got a logout request");
355 //send reply to let the client logout
356 LogoutReplyPacket logReply = new LogoutReplyPacket();
357 logReply.AgentData.AgentID = this.AgentID;
358 logReply.AgentData.SessionID = this.SessionID;
359 logReply.InventoryData = new LogoutReplyPacket.InventoryDataBlock[1];
360 logReply.InventoryData[0] = new LogoutReplyPacket.InventoryDataBlock();
361 logReply.InventoryData[0].ItemID = LLUUID.Zero;
362 OutPacket(logReply);
363 //tell all clients to kill our object
364 KillObjectPacket kill = new KillObjectPacket();
365 kill.ObjectData = new KillObjectPacket.ObjectDataBlock[1];
366 kill.ObjectData[0] = new KillObjectPacket.ObjectDataBlock();
367 kill.ObjectData[0].ID = this.ClientAvatar.localid;
368 foreach (SimClient client in m_clientThreads.Values)
369 {
370 client.OutPacket(kill);
371 }
372 if (this.m_userServer != null)
373 {
374 this.m_inventoryCache.ClientLeaving(this.AgentID, this.m_userServer);
375 }
376 else
377 {
378 this.m_inventoryCache.ClientLeaving(this.AgentID, null);
379 }
380
381 m_gridServer.LogoutSession(this.SessionID, this.AgentID, this.CircuitCode);
382 lock (m_world.Entities)
383 {
384 m_world.Entities.Remove(this.AgentID);
385 }
386 //need to do other cleaning up here too
387 m_clientThreads.Remove(this.CircuitCode); //this.userEP);
388 m_application.RemoveClientCircuit(this.CircuitCode);
389 this.ClientThread.Abort();
390 break;
391 case PacketType.ChatFromViewer:
392 ChatFromViewerPacket inchatpack = (ChatFromViewerPacket)Pack;
393 if (Helpers.FieldToString(inchatpack.ChatData.Message) == "") break;
394
395
396 libsecondlife.Packets.ChatFromSimulatorPacket reply = new ChatFromSimulatorPacket();
397 reply.ChatData.Audible = 1;
398 reply.ChatData.Message = inchatpack.ChatData.Message;
399 reply.ChatData.ChatType = 1;
400 reply.ChatData.SourceType = 1;
401 reply.ChatData.Position = this.ClientAvatar.position;
402 reply.ChatData.FromName = _enc.GetBytes(this.ClientAvatar.firstname + " " + this.ClientAvatar.lastname + "\0");
403 reply.ChatData.OwnerID = this.AgentID;
404 reply.ChatData.SourceID = this.AgentID;
405 foreach (SimClient client in m_clientThreads.Values)
406 {
407 client.OutPacket(reply);
408 }
409 break;
410 case PacketType.ObjectImage: 334 case PacketType.ObjectImage:
411 ObjectImagePacket imagePack = (ObjectImagePacket)Pack; 335 ObjectImagePacket imagePack = (ObjectImagePacket)Pack;
412 for (int i = 0; i < imagePack.ObjectData.Length; i++) 336 for (int i = 0; i < imagePack.ObjectData.Length; i++)
@@ -429,23 +353,12 @@ namespace OpenSim
429 ((OpenSim.world.Primitive)ent).UpdateObjectFlags(flags); 353 ((OpenSim.world.Primitive)ent).UpdateObjectFlags(flags);
430 } 354 }
431 } 355 }
432
433 break; 356 break;
434 case PacketType.AssetUploadRequest: 357 case PacketType.AssetUploadRequest:
435 //this.debug = true;
436 AssetUploadRequestPacket request = (AssetUploadRequestPacket)Pack; 358 AssetUploadRequestPacket request = (AssetUploadRequestPacket)Pack;
437 // Console.WriteLine(Pack.ToString());
438 // if (request.AssetBlock.Type == 0)
439 // {
440 //this.UploadAssets.HandleUploadPacket(request, LLUUID.Random());
441 //}
442 //else
443 //{
444 this.UploadAssets.HandleUploadPacket(request, request.AssetBlock.TransactionID.Combine(this.SecureSessionID)); 359 this.UploadAssets.HandleUploadPacket(request, request.AssetBlock.TransactionID.Combine(this.SecureSessionID));
445 //}
446 break; 360 break;
447 case PacketType.SendXferPacket: 361 case PacketType.SendXferPacket:
448 Console.WriteLine(Pack.ToString());
449 this.UploadAssets.HandleXferPacket((SendXferPacketPacket)Pack); 362 this.UploadAssets.HandleXferPacket((SendXferPacketPacket)Pack);
450 break; 363 break;
451 case PacketType.CreateInventoryFolder: 364 case PacketType.CreateInventoryFolder:
@@ -522,11 +435,11 @@ namespace OpenSim
522 break; 435 break;
523 case PacketType.DeRezObject: 436 case PacketType.DeRezObject:
524 //OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Received DeRezObject packet"); 437 //OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Received DeRezObject packet");
525 m_world.DeRezObject((DeRezObjectPacket)Pack, this); 438 m_world.DeRezObject(this, Pack);
526 break; 439 break;
527 case PacketType.RezObject: 440 case PacketType.RezObject:
528 //Console.WriteLine(Pack.ToString()); 441 //Console.WriteLine(Pack.ToString());
529 m_world.RezObject(this, (RezObjectPacket)Pack); 442 m_world.RezObject(this, Pack);
530 break; 443 break;
531 case PacketType.RequestTaskInventory: 444 case PacketType.RequestTaskInventory:
532 // Console.WriteLine(Pack.ToString()); 445 // Console.WriteLine(Pack.ToString());
@@ -548,22 +461,6 @@ namespace OpenSim
548 this.OutPacket(replytask); 461 this.OutPacket(replytask);
549 } 462 }
550 break; 463 break;
551 case PacketType.UUIDNameRequest:
552 //System.Text.Encoding _enc = System.Text.Encoding.ASCII;
553 Console.WriteLine(Pack.ToString());
554 UUIDNameRequestPacket nameRequest = (UUIDNameRequestPacket)Pack;
555 UUIDNameReplyPacket nameReply = new UUIDNameReplyPacket();
556 nameReply.UUIDNameBlock = new UUIDNameReplyPacket.UUIDNameBlockBlock[nameRequest.UUIDNameBlock.Length];
557
558 for (int i = 0; i < nameRequest.UUIDNameBlock.Length; i++)
559 {
560 nameReply.UUIDNameBlock[i] = new UUIDNameReplyPacket.UUIDNameBlockBlock();
561 nameReply.UUIDNameBlock[i].ID = nameRequest.UUIDNameBlock[i].ID;
562 nameReply.UUIDNameBlock[i].FirstName = _enc.GetBytes("Who\0"); //for now send any name
563 nameReply.UUIDNameBlock[i].LastName = _enc.GetBytes("Knows\0"); //in future need to look it up
564 }
565 this.OutPacket(nameReply);
566 break;
567 case PacketType.AgentAnimation: 464 case PacketType.AgentAnimation:
568 //Console.WriteLine(Pack.ToString()); 465 //Console.WriteLine(Pack.ToString());
569 break; 466 break;
@@ -872,6 +769,71 @@ namespace OpenSim
872 ClientLoop(); 769 ClientLoop();
873 } 770 }
874 } 771 }
772 #region Packet handlers
773
774 protected virtual bool Logout(SimClient simClient, Packet packet)
775 {
776 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("OpenSimClient.cs:ProcessInPacket() - Got a logout request");
777 //send reply to let the client logout
778 LogoutReplyPacket logReply = new LogoutReplyPacket();
779 logReply.AgentData.AgentID = this.AgentID;
780 logReply.AgentData.SessionID = this.SessionID;
781 logReply.InventoryData = new LogoutReplyPacket.InventoryDataBlock[1];
782 logReply.InventoryData[0] = new LogoutReplyPacket.InventoryDataBlock();
783 logReply.InventoryData[0].ItemID = LLUUID.Zero;
784 OutPacket(logReply);
785 //tell all clients to kill our object
786 KillObjectPacket kill = new KillObjectPacket();
787 kill.ObjectData = new KillObjectPacket.ObjectDataBlock[1];
788 kill.ObjectData[0] = new KillObjectPacket.ObjectDataBlock();
789 kill.ObjectData[0].ID = this.ClientAvatar.localid;
790 foreach (SimClient client in m_clientThreads.Values)
791 {
792 client.OutPacket(kill);
793 }
794 if (this.m_userServer != null)
795 {
796 this.m_inventoryCache.ClientLeaving(this.AgentID, this.m_userServer);
797 }
798 else
799 {
800 this.m_inventoryCache.ClientLeaving(this.AgentID, null);
801 }
802
803 m_gridServer.LogoutSession(this.SessionID, this.AgentID, this.CircuitCode);
804 lock (m_world.Entities)
805 {
806 m_world.Entities.Remove(this.AgentID);
807 }
808 //need to do other cleaning up here too
809 m_clientThreads.Remove(this.CircuitCode); //this.userEP);
810 m_application.RemoveClientCircuit(this.CircuitCode);
811 this.ClientThread.Abort();
812 return true;
813 }
814
815 protected bool AgentTextureCached(SimClient simclient, Packet packet)
816 {
817 Console.WriteLine(packet.ToString());
818 AgentCachedTexturePacket chechedtex = (AgentCachedTexturePacket)packet;
819 AgentCachedTextureResponsePacket cachedresp = new AgentCachedTextureResponsePacket();
820 cachedresp.AgentData.AgentID = this.AgentID;
821 cachedresp.AgentData.SessionID = this.SessionID;
822 cachedresp.AgentData.SerialNum = this.cachedtextureserial;
823 this.cachedtextureserial++;
824 cachedresp.WearableData = new AgentCachedTextureResponsePacket.WearableDataBlock[chechedtex.WearableData.Length];
825 for (int i = 0; i < chechedtex.WearableData.Length; i++)
826 {
827 cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock();
828 cachedresp.WearableData[i].TextureIndex = chechedtex.WearableData[i].TextureIndex;
829 cachedresp.WearableData[i].TextureID = LLUUID.Zero;
830 cachedresp.WearableData[i].HostName = new byte[0];
831 }
832 this.OutPacket(cachedresp);
833 return true;
834 }
835
836 #endregion
875 837
876 private AgentInventory CreateInventory(LLUUID baseFolder) 838 private AgentInventory CreateInventory(LLUUID baseFolder)
877 { 839 {
diff --git a/OpenSim.RegionServer/world/World.cs b/OpenSim.RegionServer/world/World.cs
index 66247a2..7f4ecac 100644
--- a/OpenSim.RegionServer/world/World.cs
+++ b/OpenSim.RegionServer/world/World.cs
@@ -308,8 +308,9 @@ namespace OpenSim.world
308 this._primCount++; 308 this._primCount++;
309 } 309 }
310 310
311 public void DeRezObject(DeRezObjectPacket DeRezPacket, SimClient AgentClient) 311 public void DeRezObject(SimClient simClient, Packet packet)
312 { 312 {
313 DeRezObjectPacket DeRezPacket = (DeRezObjectPacket)packet;
313 // Console.WriteLine(DeRezPacket); 314 // Console.WriteLine(DeRezPacket);
314 //Needs to delete object from physics at a later date 315 //Needs to delete object from physics at a later date
315 if (DeRezPacket.AgentBlock.DestinationID == LLUUID.Zero) 316 if (DeRezPacket.AgentBlock.DestinationID == LLUUID.Zero)
@@ -369,7 +370,7 @@ namespace OpenSim.world
369 primAsset.Description = ""; 370 primAsset.Description = "";
370 primAsset.Data = ((Primitive)ent).GetByteArray(); 371 primAsset.Data = ((Primitive)ent).GetByteArray();
371 this._assetCache.AddAsset(primAsset); 372 this._assetCache.AddAsset(primAsset);
372 this._inventoryCache.AddNewInventoryItem(AgentClient, DeRezPacket.AgentBlock.DestinationID, primAsset); 373 this._inventoryCache.AddNewInventoryItem(simClient, DeRezPacket.AgentBlock.DestinationID, primAsset);
373 selectedEnt = ent; 374 selectedEnt = ent;
374 break; 375 break;
375 } 376 }
@@ -394,27 +395,6 @@ namespace OpenSim.world
394 } 395 }
395 } 396 }
396 397
397 public void RezObject(SimClient remoteClient, RezObjectPacket packet)
398 {
399 AgentInventory inven =this._inventoryCache.GetAgentsInventory(remoteClient.AgentID);
400 if(inven != null)
401 {
402 if (inven.InventoryItems.ContainsKey(packet.InventoryData.ItemID))
403 {
404 AssetBase asset = this._assetCache.GetAsset(inven.InventoryItems[packet.InventoryData.ItemID].AssetID);
405 if (asset != null)
406 {
407 PrimData primd = new PrimData(asset.Data);
408 Primitive nPrim = new Primitive(m_clientThreads, m_regionHandle, this);
409 nPrim.CreateFromStorage(primd, packet.RezData.RayEnd, this._primCount, true);
410 this.Entities.Add(nPrim.uuid, nPrim);
411 this._primCount++;
412 this._inventoryCache.DeleteInventoryItem(remoteClient, packet.InventoryData.ItemID);
413 }
414 }
415 }
416 }
417
418 public bool Backup() 398 public bool Backup()
419 { 399 {
420 400
@@ -470,6 +450,56 @@ namespace OpenSim.world
470 } 450 }
471 return true; 451 return true;
472 } 452 }
453
454 public bool SimChat(SimClient simClient, Packet packet)
455 {
456 System.Text.Encoding enc = System.Text.Encoding.ASCII;
457 ChatFromViewerPacket inchatpack = (ChatFromViewerPacket)packet;
458 if (Helpers.FieldToString(inchatpack.ChatData.Message) == "")
459 {
460 //empty message so don't bother with it
461 return true;
462 }
463
464 libsecondlife.Packets.ChatFromSimulatorPacket reply = new ChatFromSimulatorPacket();
465 reply.ChatData.Audible = 1;
466 reply.ChatData.Message = inchatpack.ChatData.Message;
467 reply.ChatData.ChatType = 1;
468 reply.ChatData.SourceType = 1;
469 reply.ChatData.Position = simClient.ClientAvatar.position;
470 reply.ChatData.FromName = enc.GetBytes(simClient.ClientAvatar.firstname + " " + simClient.ClientAvatar.lastname + "\0");
471 reply.ChatData.OwnerID = simClient.AgentID;
472 reply.ChatData.SourceID = simClient.AgentID;
473 foreach (SimClient client in m_clientThreads.Values)
474 {
475 client.OutPacket(reply);
476 }
477 return true;
478 }
479
480 public bool RezObject(SimClient simClient, Packet packet)
481 {
482 RezObjectPacket rezPacket = (RezObjectPacket)packet;
483 AgentInventory inven = this._inventoryCache.GetAgentsInventory(simClient.AgentID);
484 if (inven != null)
485 {
486 if (inven.InventoryItems.ContainsKey(rezPacket.InventoryData.ItemID))
487 {
488 AssetBase asset = this._assetCache.GetAsset(inven.InventoryItems[rezPacket.InventoryData.ItemID].AssetID);
489 if (asset != null)
490 {
491 PrimData primd = new PrimData(asset.Data);
492 Primitive nPrim = new Primitive(m_clientThreads, m_regionHandle, this);
493 nPrim.CreateFromStorage(primd, rezPacket.RezData.RayEnd, this._primCount, true);
494 this.Entities.Add(nPrim.uuid, nPrim);
495 this._primCount++;
496 this._inventoryCache.DeleteInventoryItem(simClient, rezPacket.InventoryData.ItemID);
497 }
498 }
499 }
500 return true;
501 }
502
473 #endregion 503 #endregion
474 } 504 }
475} 505}