From 67e12b95ea7b68f4904a7484d77ecfd787d16d0c Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Tue, 30 Oct 2007 09:05:31 +0000 Subject: * Optimized usings * Shortened type references * Removed redundant 'this' qualifier --- .../ClientStack/ClientStackNetworkHandler.cs | 6 +- OpenSim/Region/ClientStack/ClientView.API.cs | 538 +++++++++++---------- .../ClientStack/ClientView.PacketHandlers.cs | 89 ++-- .../Region/ClientStack/ClientView.PacketQueue.cs | 39 +- .../ClientStack/ClientView.ProcessPackets.cs | 270 ++++++----- OpenSim/Region/ClientStack/ClientView.cs | 86 ++-- OpenSim/Region/ClientStack/PacketServer.cs | 33 +- .../Region/ClientStack/RegionApplicationBase.cs | 25 +- OpenSim/Region/ClientStack/UDPServer.cs | 60 +-- 9 files changed, 613 insertions(+), 533 deletions(-) (limited to 'OpenSim/Region/ClientStack') diff --git a/OpenSim/Region/ClientStack/ClientStackNetworkHandler.cs b/OpenSim/Region/ClientStack/ClientStackNetworkHandler.cs index 3960c19..4b44ead 100644 --- a/OpenSim/Region/ClientStack/ClientStackNetworkHandler.cs +++ b/OpenSim/Region/ClientStack/ClientStackNetworkHandler.cs @@ -29,12 +29,10 @@ using System.Net.Sockets; namespace OpenSim.Region.ClientStack { - public interface ClientStackNetworkHandler { - void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode);// EndPoint packetSender); + void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode); // EndPoint packetSender); void RemoveClientCircuit(uint circuitcode); void RegisterPacketServer(PacketServer server); } - -} +} \ No newline at end of file diff --git a/OpenSim/Region/ClientStack/ClientView.API.cs b/OpenSim/Region/ClientStack/ClientView.API.cs index 24962f8..7dcf1e8 100644 --- a/OpenSim/Region/ClientStack/ClientView.API.cs +++ b/OpenSim/Region/ClientStack/ClientView.API.cs @@ -32,10 +32,8 @@ using System.Text; using Axiom.Math; using libsecondlife; using libsecondlife.Packets; -using OpenSim.Framework.Console; -using OpenSim.Framework.Interfaces; -using OpenSim.Framework; using OpenSim.Framework; +using OpenSim.Framework.Console; namespace OpenSim.Region.ClientStack { @@ -116,26 +114,18 @@ namespace OpenSim.Region.ClientStack /// public LLVector3 StartPos { - get - { - return startpos; - } - set - { - startpos = value; - } + get { return startpos; } + set { startpos = value; } } /// /// /// private LLUUID m_agentId; + public LLUUID AgentId { - get - { - return m_agentId; - } + get { return m_agentId; } } /// @@ -143,11 +133,7 @@ namespace OpenSim.Region.ClientStack /// public string FirstName { - get - { - return this.firstName; - } - + get { return firstName; } } /// @@ -155,10 +141,7 @@ namespace OpenSim.Region.ClientStack /// public string LastName { - get - { - return this.lastName; - } + get { return lastName; } } #region Scene/Avatar to Client @@ -182,11 +165,11 @@ namespace OpenSim.Region.ClientStack handshake.RegionInfo.TerrainStartHeight01 = regionInfo.EstateSettings.terrainStartHeight1; handshake.RegionInfo.TerrainStartHeight10 = regionInfo.EstateSettings.terrainStartHeight2; handshake.RegionInfo.TerrainStartHeight11 = regionInfo.EstateSettings.terrainStartHeight3; - handshake.RegionInfo.SimAccess = (byte)regionInfo.EstateSettings.simAccess; + handshake.RegionInfo.SimAccess = (byte) regionInfo.EstateSettings.simAccess; handshake.RegionInfo.WaterHeight = regionInfo.EstateSettings.waterHeight; - handshake.RegionInfo.RegionFlags = (uint)regionInfo.EstateSettings.regionFlags; + handshake.RegionInfo.RegionFlags = (uint) regionInfo.EstateSettings.regionFlags; handshake.RegionInfo.SimName = _enc.GetBytes(regionInfo.RegionName + "\0"); handshake.RegionInfo.SimOwner = regionInfo.MasterAvatarAssignedUUID; @@ -200,7 +183,7 @@ namespace OpenSim.Region.ClientStack handshake.RegionInfo.TerrainDetail3 = regionInfo.EstateSettings.terrainDetail3; handshake.RegionInfo.CacheID = LLUUID.Random(); //I guess this is for the client to remember an old setting? - this.OutPacket(handshake); + OutPacket(handshake); } /// @@ -210,14 +193,14 @@ namespace OpenSim.Region.ClientStack public void MoveAgentIntoRegion(RegionInfo regInfo, LLVector3 pos, LLVector3 look) { AgentMovementCompletePacket mov = new AgentMovementCompletePacket(); - mov.AgentData.SessionID = this.m_sessionId; - mov.AgentData.AgentID = this.AgentId; + mov.AgentData.SessionID = m_sessionId; + mov.AgentData.AgentID = AgentId; mov.Data.RegionHandle = regInfo.RegionHandle; mov.Data.Timestamp = 1172750370; // TODO - dynamicalise this if ((pos.X == 0) && (pos.Y == 0) && (pos.Z == 0)) { - mov.Data.Position = this.startpos; + mov.Data.Position = startpos; } else { @@ -255,7 +238,7 @@ namespace OpenSim.Region.ClientStack reply.ChatData.OwnerID = fromAgentID; reply.ChatData.SourceID = fromAgentID; - this.OutPacket(reply); + OutPacket(reply); } /// @@ -264,27 +247,27 @@ namespace OpenSim.Region.ClientStack /// TODO /// /// - public void SendInstantMessage(LLUUID fromAgent, LLUUID fromAgentSession, string message, LLUUID toAgent, LLUUID imSessionID, string fromName, byte dialog, uint timeStamp) + public void SendInstantMessage(LLUUID fromAgent, LLUUID fromAgentSession, string message, LLUUID toAgent, + LLUUID imSessionID, string fromName, byte dialog, uint timeStamp) { - - Encoding enc = Encoding.ASCII; - ImprovedInstantMessagePacket msg = new ImprovedInstantMessagePacket(); - msg.AgentData.AgentID = fromAgent; - msg.AgentData.SessionID = fromAgentSession; - msg.MessageBlock.FromAgentName = enc.GetBytes(fromName + " \0"); - msg.MessageBlock.Dialog = dialog; - msg.MessageBlock.FromGroup = false; - msg.MessageBlock.ID = imSessionID; - msg.MessageBlock.Offline = 0; - msg.MessageBlock.ParentEstateID = 0; - msg.MessageBlock.Position = new LLVector3(); - msg.MessageBlock.RegionID = LLUUID.Random(); - msg.MessageBlock.Timestamp = timeStamp; - msg.MessageBlock.ToAgentID = toAgent; - msg.MessageBlock.Message = enc.GetBytes(message + "\0"); - msg.MessageBlock.BinaryBucket = new byte[0]; - - this.OutPacket(msg); + Encoding enc = Encoding.ASCII; + ImprovedInstantMessagePacket msg = new ImprovedInstantMessagePacket(); + msg.AgentData.AgentID = fromAgent; + msg.AgentData.SessionID = fromAgentSession; + msg.MessageBlock.FromAgentName = enc.GetBytes(fromName + " \0"); + msg.MessageBlock.Dialog = dialog; + msg.MessageBlock.FromGroup = false; + msg.MessageBlock.ID = imSessionID; + msg.MessageBlock.Offline = 0; + msg.MessageBlock.ParentEstateID = 0; + msg.MessageBlock.Position = new LLVector3(); + msg.MessageBlock.RegionID = LLUUID.Random(); + msg.MessageBlock.Timestamp = timeStamp; + msg.MessageBlock.ToAgentID = toAgent; + msg.MessageBlock.Message = enc.GetBytes(message + "\0"); + msg.MessageBlock.BinaryBucket = new byte[0]; + + OutPacket(msg); } /// @@ -301,10 +284,10 @@ namespace OpenSim.Region.ClientStack { for (int x = 0; x < 16; x = x + 4) { - patches[0] = x + 0 + y * 16; - patches[1] = x + 1 + y * 16; - patches[2] = x + 2 + y * 16; - patches[3] = x + 3 + y * 16; + patches[0] = x + 0 + y*16; + patches[1] = x + 1 + y*16; + patches[2] = x + 2 + y*16; + patches[3] = x + 3 + y*16; Packet layerpack = TerrainManager.CreateLandPacket(map, patches); OutPacket(layerpack); @@ -313,7 +296,8 @@ namespace OpenSim.Region.ClientStack } catch (Exception e) { - MainLog.Instance.Warn("client", "ClientView API.cs: SendLayerData() - Failed with exception " + e.ToString()); + MainLog.Instance.Warn("client", + "ClientView API.cs: SendLayerData() - Failed with exception " + e.ToString()); } } @@ -332,14 +316,15 @@ namespace OpenSim.Region.ClientStack patchx = px; patchy = py; - patches[0] = patchx + 0 + patchy * 16; + patches[0] = patchx + 0 + patchy*16; Packet layerpack = TerrainManager.CreateLandPacket(map, patches); OutPacket(layerpack); } catch (Exception e) { - MainLog.Instance.Warn("client", "ClientView API .cs: SendLayerData() - Failed with exception " + e.ToString()); + MainLog.Instance.Warn("client", + "ClientView API .cs: SendLayerData() - Failed with exception " + e.ToString()); } } @@ -352,17 +337,17 @@ namespace OpenSim.Region.ClientStack public void InformClientOfNeighbour(ulong neighbourHandle, IPEndPoint neighbourEndPoint) { IPAddress neighbourIP = neighbourEndPoint.Address; - ushort neighbourPort = (ushort)neighbourEndPoint.Port; + ushort neighbourPort = (ushort) neighbourEndPoint.Port; EnableSimulatorPacket enablesimpacket = new EnableSimulatorPacket(); enablesimpacket.SimulatorInfo = new EnableSimulatorPacket.SimulatorInfoBlock(); enablesimpacket.SimulatorInfo.Handle = neighbourHandle; byte[] byteIP = neighbourIP.GetAddressBytes(); - enablesimpacket.SimulatorInfo.IP = (uint)byteIP[3] << 24; - enablesimpacket.SimulatorInfo.IP += (uint)byteIP[2] << 16; - enablesimpacket.SimulatorInfo.IP += (uint)byteIP[1] << 8; - enablesimpacket.SimulatorInfo.IP += (uint)byteIP[0]; + enablesimpacket.SimulatorInfo.IP = (uint) byteIP[3] << 24; + enablesimpacket.SimulatorInfo.IP += (uint) byteIP[2] << 16; + enablesimpacket.SimulatorInfo.IP += (uint) byteIP[1] << 8; + enablesimpacket.SimulatorInfo.IP += (uint) byteIP[0]; enablesimpacket.SimulatorInfo.Port = neighbourPort; OutPacket(enablesimpacket); } @@ -374,46 +359,48 @@ namespace OpenSim.Region.ClientStack public AgentCircuitData RequestClientInfo() { AgentCircuitData agentData = new AgentCircuitData(); - agentData.AgentID = this.AgentId; - agentData.SessionID = this.m_sessionId; - agentData.SecureSessionID = this.SecureSessionID; - agentData.circuitcode = this.m_circuitCode; + agentData.AgentID = AgentId; + agentData.SessionID = m_sessionId; + agentData.SecureSessionID = SecureSessionID; + agentData.circuitcode = m_circuitCode; agentData.child = false; - agentData.firstname = this.firstName; - agentData.lastname = this.lastName; + agentData.firstname = firstName; + agentData.lastname = lastName; agentData.CapsPath = ""; return agentData; } - public void CrossRegion(ulong newRegionHandle, LLVector3 pos, LLVector3 lookAt, IPEndPoint externalIPEndPoint, string capsURL) + public void CrossRegion(ulong newRegionHandle, LLVector3 pos, LLVector3 lookAt, IPEndPoint externalIPEndPoint, + string capsURL) { - LLVector3 look = new LLVector3(lookAt.X * 10, lookAt.Y * 10, lookAt.Z * 10); + LLVector3 look = new LLVector3(lookAt.X*10, lookAt.Y*10, lookAt.Z*10); CrossedRegionPacket newSimPack = new CrossedRegionPacket(); newSimPack.AgentData = new CrossedRegionPacket.AgentDataBlock(); - newSimPack.AgentData.AgentID = this.AgentId; - newSimPack.AgentData.SessionID = this.m_sessionId; + newSimPack.AgentData.AgentID = AgentId; + newSimPack.AgentData.SessionID = m_sessionId; newSimPack.Info = new CrossedRegionPacket.InfoBlock(); newSimPack.Info.Position = pos; - newSimPack.Info.LookAt = look; // new LLVector3(0.0f, 0.0f, 0.0f); // copied from Avatar.cs - SHOULD BE DYNAMIC!!!!!!!!!! + newSimPack.Info.LookAt = look; + // new LLVector3(0.0f, 0.0f, 0.0f); // copied from Avatar.cs - SHOULD BE DYNAMIC!!!!!!!!!! newSimPack.RegionData = new CrossedRegionPacket.RegionDataBlock(); newSimPack.RegionData.RegionHandle = newRegionHandle; byte[] byteIP = externalIPEndPoint.Address.GetAddressBytes(); - newSimPack.RegionData.SimIP = (uint)byteIP[3] << 24; - newSimPack.RegionData.SimIP += (uint)byteIP[2] << 16; - newSimPack.RegionData.SimIP += (uint)byteIP[1] << 8; - newSimPack.RegionData.SimIP += (uint)byteIP[0]; - newSimPack.RegionData.SimPort = (ushort)externalIPEndPoint.Port; + newSimPack.RegionData.SimIP = (uint) byteIP[3] << 24; + newSimPack.RegionData.SimIP += (uint) byteIP[2] << 16; + newSimPack.RegionData.SimIP += (uint) byteIP[1] << 8; + newSimPack.RegionData.SimIP += (uint) byteIP[0]; + newSimPack.RegionData.SimPort = (ushort) externalIPEndPoint.Port; //newSimPack.RegionData.SeedCapability = new byte[0]; newSimPack.RegionData.SeedCapability = Helpers.StringToField(capsURL); - this.OutPacket(newSimPack); + OutPacket(newSimPack); } public void SendMapBlock(List mapBlocks) { MapBlockReplyPacket mapReply = new MapBlockReplyPacket(); - mapReply.AgentData.AgentID = this.AgentId; + mapReply.AgentData.AgentID = AgentId; mapReply.Data = new MapBlockReplyPacket.DataBlock[mapBlocks.Count]; mapReply.AgentData.Flags = 0; @@ -429,13 +416,13 @@ namespace OpenSim.Region.ClientStack mapReply.Data[i].Access = mapBlocks[i].Access; mapReply.Data[i].Agents = mapBlocks[i].Agents; } - this.OutPacket(mapReply); + OutPacket(mapReply); } public void SendLocalTeleport(LLVector3 position, LLVector3 lookAt, uint flags) { TeleportLocalPacket tpLocal = new TeleportLocalPacket(); - tpLocal.Info.AgentID = this.AgentId; + tpLocal.Info.AgentID = AgentId; tpLocal.Info.TeleportFlags = flags; tpLocal.Info.LocationID = 2; tpLocal.Info.LookAt = lookAt; @@ -443,10 +430,11 @@ namespace OpenSim.Region.ClientStack OutPacket(tpLocal); } - public void SendRegionTeleport(ulong regionHandle, byte simAccess, IPEndPoint newRegionEndPoint, uint locationID, uint flags, string capsURL) + public void SendRegionTeleport(ulong regionHandle, byte simAccess, IPEndPoint newRegionEndPoint, uint locationID, + uint flags, string capsURL) { TeleportFinishPacket teleport = new TeleportFinishPacket(); - teleport.Info.AgentID = this.AgentId; + teleport.Info.AgentID = AgentId; teleport.Info.RegionHandle = regionHandle; teleport.Info.SimAccess = simAccess; @@ -455,13 +443,13 @@ namespace OpenSim.Region.ClientStack IPAddress oIP = newRegionEndPoint.Address; byte[] byteIP = oIP.GetAddressBytes(); - uint ip = (uint)byteIP[3] << 24; - ip += (uint)byteIP[2] << 16; - ip += (uint)byteIP[1] << 8; - ip += (uint)byteIP[0]; + uint ip = (uint) byteIP[3] << 24; + ip += (uint) byteIP[2] << 16; + ip += (uint) byteIP[1] << 8; + ip += (uint) byteIP[0]; teleport.Info.SimIP = ip; - teleport.Info.SimPort = (ushort)newRegionEndPoint.Port; + teleport.Info.SimPort = (ushort) newRegionEndPoint.Port; teleport.Info.LocationID = 4; teleport.Info.TeleportFlags = 1 << 4; OutPacket(teleport); @@ -473,8 +461,8 @@ namespace OpenSim.Region.ClientStack public void SendTeleportCancel() { TeleportCancelPacket tpCancel = new TeleportCancelPacket(); - tpCancel.Info.SessionID = this.m_sessionId; - tpCancel.Info.AgentID = this.AgentId; + tpCancel.Info.SessionID = m_sessionId; + tpCancel.Info.AgentID = AgentId; OutPacket(tpCancel); } @@ -492,7 +480,7 @@ namespace OpenSim.Region.ClientStack public void SendMoneyBalance(LLUUID transaction, bool success, byte[] description, int balance) { MoneyBalanceReplyPacket money = new MoneyBalanceReplyPacket(); - money.MoneyData.AgentID = this.AgentId; + money.MoneyData.AgentID = AgentId; money.MoneyData.TransactionID = transaction; money.MoneyData.TransactionSuccess = success; money.MoneyData.Description = description; @@ -506,7 +494,6 @@ namespace OpenSim.Region.ClientStack pc.PingID.PingID = seq; pc.Header.Reliable = false; OutPacket(pc); - } public void SendKillObject(ulong regionHandle, uint localID) @@ -522,8 +509,8 @@ namespace OpenSim.Region.ClientStack { Encoding enc = Encoding.ASCII; uint FULL_MASK_PERMISSIONS = 2147483647; - InventoryDescendentsPacket descend = this.CreateInventoryDescendentsPacket(ownerID, folderID); - + InventoryDescendentsPacket descend = CreateInventoryDescendentsPacket(ownerID, folderID); + int count = 0; if (items.Count < 40) { @@ -550,25 +537,30 @@ namespace OpenSim.Region.ClientStack descend.ItemData[i].FolderID = item.parentFolderID; descend.ItemData[i].GroupID = new LLUUID("00000000-0000-0000-0000-000000000000"); descend.ItemData[i].GroupMask = 0; - descend.ItemData[i].InvType = (sbyte)item.invType; + descend.ItemData[i].InvType = (sbyte) item.invType; descend.ItemData[i].Name = enc.GetBytes(item.inventoryName + "\0"); descend.ItemData[i].NextOwnerMask = item.inventoryNextPermissions; descend.ItemData[i].OwnerID = item.avatarID; descend.ItemData[i].OwnerMask = item.inventoryCurrentPermissions; descend.ItemData[i].SalePrice = 0; descend.ItemData[i].SaleType = 0; - descend.ItemData[i].Type = (sbyte)item.assetType; - descend.ItemData[i].CRC = Helpers.InventoryCRC(1000, 0, descend.ItemData[i].InvType, descend.ItemData[i].Type, descend.ItemData[i].AssetID, descend.ItemData[i].GroupID, 100, descend.ItemData[i].OwnerID, descend.ItemData[i].CreatorID, descend.ItemData[i].ItemID, descend.ItemData[i].FolderID, FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS); + descend.ItemData[i].Type = (sbyte) item.assetType; + descend.ItemData[i].CRC = + Helpers.InventoryCRC(1000, 0, descend.ItemData[i].InvType, descend.ItemData[i].Type, + descend.ItemData[i].AssetID, descend.ItemData[i].GroupID, 100, + descend.ItemData[i].OwnerID, descend.ItemData[i].CreatorID, + descend.ItemData[i].ItemID, descend.ItemData[i].FolderID, FULL_MASK_PERMISSIONS, + 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS); i++; count++; if (i == 40) { - this.OutPacket(descend); - + OutPacket(descend); + if ((items.Count - count) > 0) { - descend = this.CreateInventoryDescendentsPacket(ownerID, folderID); + descend = CreateInventoryDescendentsPacket(ownerID, folderID); if ((items.Count - count) < 40) { descend.ItemData = new InventoryDescendentsPacket.ItemDataBlock[items.Count - count]; @@ -586,15 +578,14 @@ namespace OpenSim.Region.ClientStack if (i < 40) { - this.OutPacket(descend); + OutPacket(descend); } - } private InventoryDescendentsPacket CreateInventoryDescendentsPacket(LLUUID ownerID, LLUUID folderID) { InventoryDescendentsPacket descend = new InventoryDescendentsPacket(); - descend.AgentData.AgentID = this.AgentId; + descend.AgentData.AgentID = AgentId; descend.AgentData.OwnerID = ownerID; descend.AgentData.FolderID = folderID; descend.AgentData.Version = 0; @@ -607,31 +598,39 @@ namespace OpenSim.Region.ClientStack Encoding enc = Encoding.ASCII; uint FULL_MASK_PERMISSIONS = 2147483647; FetchInventoryReplyPacket inventoryReply = new FetchInventoryReplyPacket(); - inventoryReply.AgentData.AgentID = this.AgentId; + inventoryReply.AgentData.AgentID = AgentId; inventoryReply.InventoryData = new FetchInventoryReplyPacket.InventoryDataBlock[1]; inventoryReply.InventoryData[0] = new FetchInventoryReplyPacket.InventoryDataBlock(); inventoryReply.InventoryData[0].ItemID = item.inventoryID; inventoryReply.InventoryData[0].AssetID = item.assetID; inventoryReply.InventoryData[0].CreatorID = item.creatorsID; inventoryReply.InventoryData[0].BaseMask = item.inventoryBasePermissions; - inventoryReply.InventoryData[0].CreationDate = (int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; + inventoryReply.InventoryData[0].CreationDate = + (int) (DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; inventoryReply.InventoryData[0].Description = enc.GetBytes(item.inventoryDescription + "\0"); inventoryReply.InventoryData[0].EveryoneMask = item.inventoryEveryOnePermissions; inventoryReply.InventoryData[0].Flags = 0; inventoryReply.InventoryData[0].FolderID = item.parentFolderID; inventoryReply.InventoryData[0].GroupID = new LLUUID("00000000-0000-0000-0000-000000000000"); inventoryReply.InventoryData[0].GroupMask = 0; - inventoryReply.InventoryData[0].InvType = (sbyte)item.invType; + inventoryReply.InventoryData[0].InvType = (sbyte) item.invType; inventoryReply.InventoryData[0].Name = enc.GetBytes(item.inventoryName + "\0"); inventoryReply.InventoryData[0].NextOwnerMask = item.inventoryNextPermissions; inventoryReply.InventoryData[0].OwnerID = item.avatarID; inventoryReply.InventoryData[0].OwnerMask = item.inventoryCurrentPermissions; inventoryReply.InventoryData[0].SalePrice = 0; inventoryReply.InventoryData[0].SaleType = 0; - inventoryReply.InventoryData[0].Type = (sbyte)item.assetType; - inventoryReply.InventoryData[0].CRC = Helpers.InventoryCRC(1000, 0, inventoryReply.InventoryData[0].InvType, inventoryReply.InventoryData[0].Type, inventoryReply.InventoryData[0].AssetID, inventoryReply.InventoryData[0].GroupID, 100, inventoryReply.InventoryData[0].OwnerID, inventoryReply.InventoryData[0].CreatorID, inventoryReply.InventoryData[0].ItemID, inventoryReply.InventoryData[0].FolderID, FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS); - - this.OutPacket(inventoryReply); + inventoryReply.InventoryData[0].Type = (sbyte) item.assetType; + inventoryReply.InventoryData[0].CRC = + Helpers.InventoryCRC(1000, 0, inventoryReply.InventoryData[0].InvType, + inventoryReply.InventoryData[0].Type, inventoryReply.InventoryData[0].AssetID, + inventoryReply.InventoryData[0].GroupID, 100, + inventoryReply.InventoryData[0].OwnerID, inventoryReply.InventoryData[0].CreatorID, + inventoryReply.InventoryData[0].ItemID, inventoryReply.InventoryData[0].FolderID, + FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS, + FULL_MASK_PERMISSIONS); + + OutPacket(inventoryReply); } public void SendInventoryItemUpdate(InventoryItemBase Item) @@ -639,7 +638,7 @@ namespace OpenSim.Region.ClientStack Encoding enc = Encoding.ASCII; uint FULL_MASK_PERMISSIONS = 2147483647; UpdateCreateInventoryItemPacket InventoryReply = new UpdateCreateInventoryItemPacket(); - InventoryReply.AgentData.AgentID = this.AgentId; + InventoryReply.AgentData.AgentID = AgentId; InventoryReply.AgentData.SimApproved = true; InventoryReply.InventoryData = new UpdateCreateInventoryItemPacket.InventoryDataBlock[1]; InventoryReply.InventoryData[0] = new UpdateCreateInventoryItemPacket.InventoryDataBlock(); @@ -654,15 +653,22 @@ namespace OpenSim.Region.ClientStack InventoryReply.InventoryData[0].FolderID = Item.parentFolderID; InventoryReply.InventoryData[0].GroupID = new LLUUID("00000000-0000-0000-0000-000000000000"); InventoryReply.InventoryData[0].GroupMask = 0; - InventoryReply.InventoryData[0].InvType = (sbyte)Item.invType; + InventoryReply.InventoryData[0].InvType = (sbyte) Item.invType; InventoryReply.InventoryData[0].Name = enc.GetBytes(Item.inventoryName + "\0"); InventoryReply.InventoryData[0].NextOwnerMask = Item.inventoryNextPermissions; InventoryReply.InventoryData[0].OwnerID = Item.avatarID; InventoryReply.InventoryData[0].OwnerMask = Item.inventoryCurrentPermissions; InventoryReply.InventoryData[0].SalePrice = 100; InventoryReply.InventoryData[0].SaleType = 0; - InventoryReply.InventoryData[0].Type = (sbyte)Item.assetType; - InventoryReply.InventoryData[0].CRC = Helpers.InventoryCRC(1000, 0, InventoryReply.InventoryData[0].InvType, InventoryReply.InventoryData[0].Type, InventoryReply.InventoryData[0].AssetID, InventoryReply.InventoryData[0].GroupID, 100, InventoryReply.InventoryData[0].OwnerID, InventoryReply.InventoryData[0].CreatorID, InventoryReply.InventoryData[0].ItemID, InventoryReply.InventoryData[0].FolderID, FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS); + InventoryReply.InventoryData[0].Type = (sbyte) Item.assetType; + InventoryReply.InventoryData[0].CRC = + Helpers.InventoryCRC(1000, 0, InventoryReply.InventoryData[0].InvType, + InventoryReply.InventoryData[0].Type, InventoryReply.InventoryData[0].AssetID, + InventoryReply.InventoryData[0].GroupID, 100, + InventoryReply.InventoryData[0].OwnerID, InventoryReply.InventoryData[0].CreatorID, + InventoryReply.InventoryData[0].ItemID, InventoryReply.InventoryData[0].FolderID, + FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS, + FULL_MASK_PERMISSIONS); OutPacket(InventoryReply); } @@ -670,8 +676,8 @@ namespace OpenSim.Region.ClientStack public void SendRemoveInventoryItem(LLUUID itemID) { RemoveInventoryItemPacket remove = new RemoveInventoryItemPacket(); - remove.AgentData.AgentID = this.AgentId; - remove.AgentData.SessionID = this.m_sessionId; + remove.AgentData.AgentID = AgentId; + remove.AgentData.SessionID = m_sessionId; remove.InventoryData = new RemoveInventoryItemPacket.InventoryDataBlock[1]; remove.InventoryData[0] = new RemoveInventoryItemPacket.InventoryDataBlock(); remove.InventoryData[0].ItemID = itemID; @@ -716,13 +722,14 @@ namespace OpenSim.Region.ClientStack public void SendAgentAlertMessage(string message, bool modal) { AgentAlertMessagePacket alertPack = new AgentAlertMessagePacket(); - alertPack.AgentData.AgentID = this.AgentId; + alertPack.AgentData.AgentID = AgentId; alertPack.AlertData.Message = Helpers.StringToField(message); alertPack.AlertData.Modal = modal; OutPacket(alertPack); } - public void SendLoadURL(string objectname, LLUUID objectID, LLUUID ownerID, bool groupOwned, string message, string url) + public void SendLoadURL(string objectname, LLUUID objectID, LLUUID ownerID, bool groupOwned, string message, + string url) { LoadURLPacket loadURL = new LoadURLPacket(); loadURL.Data.ObjectName = Helpers.StringToField(objectname); @@ -761,14 +768,13 @@ namespace OpenSim.Region.ClientStack public void SendViewerTime(int phase) { - SimulatorViewerTimeMessagePacket viewertime = new SimulatorViewerTimeMessagePacket(); //viewertime.TimeInfo.SecPerDay = 86400; // viewertime.TimeInfo.SecPerYear = 31536000; viewertime.TimeInfo.SecPerDay = 1000; viewertime.TimeInfo.SecPerYear = 365000; viewertime.TimeInfo.SunPhase = 1; - int sunPhase = (phase + 2) / 2; + int sunPhase = (phase + 2)/2; if ((sunPhase < 6) || (sunPhase > 36)) { viewertime.TimeInfo.SunDirection = new LLVector3(0f, 0.8f, -0.8f); @@ -781,27 +787,41 @@ namespace OpenSim.Region.ClientStack sunPhase = 12; } sunPhase = sunPhase - 12; - float yValue = 0.1f * (sunPhase); - if (yValue > 1.2f) { yValue = yValue - 1.2f; } - if (yValue > 1 ) { yValue = 1; } - if (yValue < 0) { yValue = 0; } + float yValue = 0.1f*(sunPhase); + if (yValue > 1.2f) + { + yValue = yValue - 1.2f; + } + if (yValue > 1) + { + yValue = 1; + } + if (yValue < 0) + { + yValue = 0; + } if (sunPhase < 14) { yValue = 1 - yValue; } - if (sunPhase < 12) { yValue *= -1; } + if (sunPhase < 12) + { + yValue *= -1; + } viewertime.TimeInfo.SunDirection = new LLVector3(0f, yValue, 0.3f); //Console.WriteLine("sending sun update " + yValue); } viewertime.TimeInfo.SunAngVelocity = new LLVector3(0, 0.0f, 10.0f); - viewertime.TimeInfo.UsecSinceStart = (ulong)Util.UnixTimeSinceEpoch(); + viewertime.TimeInfo.UsecSinceStart = (ulong) Util.UnixTimeSinceEpoch(); OutPacket(viewertime); } - public void SendAvatarProperties(LLUUID avatarID, string aboutText, string bornOn, string charterMember, string flAbout, uint flags, LLUUID flImageID, LLUUID imageID, string profileURL, LLUUID partnerID) + public void SendAvatarProperties(LLUUID avatarID, string aboutText, string bornOn, string charterMember, + string flAbout, uint flags, LLUUID flImageID, LLUUID imageID, string profileURL, + LLUUID partnerID) { AvatarPropertiesReplyPacket avatarReply = new AvatarPropertiesReplyPacket(); - avatarReply.AgentData.AgentID = this.AgentId; + avatarReply.AgentData.AgentID = AgentId; avatarReply.AgentData.AvatarID = avatarID; avatarReply.PropertiesData.AboutText = Helpers.StringToField(aboutText); avatarReply.PropertiesData.BornOn = Helpers.StringToField(bornOn); @@ -827,6 +847,7 @@ namespace OpenSim.Region.ClientStack OutPacket(avatarSitResponse); } + #endregion #region Appearance/ Wearables Methods @@ -838,22 +859,22 @@ namespace OpenSim.Region.ClientStack public void SendWearables(AvatarWearable[] wearables) { AgentWearablesUpdatePacket aw = new AgentWearablesUpdatePacket(); - aw.AgentData.AgentID = this.AgentId; + aw.AgentData.AgentID = AgentId; aw.AgentData.SerialNum = 0; - aw.AgentData.SessionID = this.m_sessionId; + aw.AgentData.SessionID = m_sessionId; aw.WearableData = new AgentWearablesUpdatePacket.WearableDataBlock[13]; AgentWearablesUpdatePacket.WearableDataBlock awb; for (int i = 0; i < wearables.Length; i++) { awb = new AgentWearablesUpdatePacket.WearableDataBlock(); - awb.WearableType = (byte)i; + awb.WearableType = (byte) i; awb.AssetID = wearables[i].AssetID; awb.ItemID = wearables[i].ItemID; aw.WearableData[i] = awb; } - this.OutPacket(aw); + OutPacket(aw); } /// @@ -893,7 +914,7 @@ namespace OpenSim.Region.ClientStack ani.AnimationList[0] = new AvatarAnimationPacket.AnimationListBlock(); ani.AnimationList[0].AnimID = animID; ani.AnimationList[0].AnimSequenceID = seq; - this.OutPacket(ani); + OutPacket(ani); } #endregion @@ -909,25 +930,26 @@ namespace OpenSim.Region.ClientStack /// /// /// - public void SendAvatarData(ulong regionHandle, string firstName, string lastName, LLUUID avatarID, uint avatarLocalID, LLVector3 Pos, byte[] textureEntry, uint parentID) + public void SendAvatarData(ulong regionHandle, string firstName, string lastName, LLUUID avatarID, + uint avatarLocalID, LLVector3 Pos, byte[] textureEntry, uint parentID) { ObjectUpdatePacket objupdate = new ObjectUpdatePacket(); objupdate.RegionData.RegionHandle = regionHandle; objupdate.RegionData.TimeDilation = 64096; objupdate.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1]; - objupdate.ObjectData[0] = this.CreateDefaultAvatarPacket(textureEntry); + objupdate.ObjectData[0] = CreateDefaultAvatarPacket(textureEntry); //give this avatar object a local id and assign the user a name objupdate.ObjectData[0].ID = avatarLocalID; objupdate.ObjectData[0].FullID = avatarID; objupdate.ObjectData[0].ParentID = parentID; - objupdate.ObjectData[0].NameValue = Helpers.StringToField("FirstName STRING RW SV " + firstName + "\nLastName STRING RW SV " + lastName); - LLVector3 pos2 = new LLVector3((float)Pos.X, (float)Pos.Y, (float)Pos.Z); + objupdate.ObjectData[0].NameValue = + Helpers.StringToField("FirstName STRING RW SV " + firstName + "\nLastName STRING RW SV " + lastName); + LLVector3 pos2 = new LLVector3((float) Pos.X, (float) Pos.Y, (float) Pos.Z); byte[] pb = pos2.GetBytes(); Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 16, pb.Length); OutPacket(objupdate); - } /// @@ -938,38 +960,41 @@ namespace OpenSim.Region.ClientStack /// /// /// - public void SendAvatarTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position, LLVector3 velocity, LLQuaternion rotation) + public void SendAvatarTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position, + LLVector3 velocity, LLQuaternion rotation) { - ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseBlock = this.CreateAvatarImprovedBlock(localID, position, velocity, rotation); + ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseBlock = + CreateAvatarImprovedBlock(localID, position, velocity, rotation); ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket(); terse.RegionData.RegionHandle = regionHandle; terse.RegionData.TimeDilation = timeDilation; terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; terse.ObjectData[0] = terseBlock; - this.OutPacket(terse); + OutPacket(terse); } - public void SendCoarseLocationUpdate(List CoarseLocations) - { - CoarseLocationUpdatePacket loc = new CoarseLocationUpdatePacket(); - int total = CoarseLocations.Count; - CoarseLocationUpdatePacket.IndexBlock ib = - new CoarseLocationUpdatePacket.IndexBlock(); - loc.Location = new CoarseLocationUpdatePacket.LocationBlock[total]; - for(int i=0; i CoarseLocations) + { + CoarseLocationUpdatePacket loc = new CoarseLocationUpdatePacket(); + int total = CoarseLocations.Count; + CoarseLocationUpdatePacket.IndexBlock ib = + new CoarseLocationUpdatePacket.IndexBlock(); + loc.Location = new CoarseLocationUpdatePacket.LocationBlock[total]; + for (int i = 0; i < total; i++) + { + CoarseLocationUpdatePacket.LocationBlock lb = + new CoarseLocationUpdatePacket.LocationBlock(); + lb.X = (byte) CoarseLocations[i].X; + lb.Y = (byte) CoarseLocations[i].Y; + lb.Z = (byte) (CoarseLocations[i].Z/4); + loc.Location[i] = lb; + } + ib.You = -1; + ib.Prey = -1; + loc.Index = ib; + OutPacket(loc); + } #endregion @@ -984,27 +1009,28 @@ namespace OpenSim.Region.ClientStack public void AttachObject(uint localID, LLQuaternion rotation, byte attachPoint) { ObjectAttachPacket attach = new ObjectAttachPacket(); - attach.AgentData.AgentID = this.AgentId; - attach.AgentData.SessionID = this.m_sessionId; + attach.AgentData.AgentID = AgentId; + attach.AgentData.SessionID = m_sessionId; attach.AgentData.AttachmentPoint = attachPoint; attach.ObjectData = new ObjectAttachPacket.ObjectDataBlock[1]; attach.ObjectData[0] = new ObjectAttachPacket.ObjectDataBlock(); attach.ObjectData[0].ObjectLocalID = localID; attach.ObjectData[0].Rotation = rotation; - this.OutPacket(attach); + OutPacket(attach); } public void SendPrimitiveToClient( - ulong regionHandle, ushort timeDilation, uint localID, PrimitiveBaseShape primShape, LLVector3 pos, uint flags, + ulong regionHandle, ushort timeDilation, uint localID, PrimitiveBaseShape primShape, LLVector3 pos, + uint flags, LLUUID objectID, LLUUID ownerID, string text, uint parentID, byte[] particleSystem, LLQuaternion rotation) { ObjectUpdatePacket outPacket = new ObjectUpdatePacket(); outPacket.RegionData.RegionHandle = regionHandle; - outPacket.RegionData.TimeDilation = timeDilation; + outPacket.RegionData.TimeDilation = timeDilation; outPacket.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1]; - outPacket.ObjectData[0] = this.CreatePrimUpdateBlock(primShape, flags); + outPacket.ObjectData[0] = CreatePrimUpdateBlock(primShape, flags); outPacket.ObjectData[0].ID = localID; outPacket.ObjectData[0].FullID = objectID; @@ -1033,35 +1059,38 @@ namespace OpenSim.Region.ClientStack /// /// /// - public void SendPrimTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position, LLQuaternion rotation) + public void SendPrimTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position, + LLQuaternion rotation) { ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket(); terse.RegionData.RegionHandle = regionHandle; terse.RegionData.TimeDilation = timeDilation; terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; - terse.ObjectData[0] = this.CreatePrimImprovedBlock(localID, position, rotation); + terse.ObjectData[0] = CreatePrimImprovedBlock(localID, position, rotation); - this.OutPacket(terse); + OutPacket(terse); } #endregion #region Helper Methods - protected ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateAvatarImprovedBlock(uint localID, LLVector3 pos, LLVector3 velocity, LLQuaternion rotation) + protected ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateAvatarImprovedBlock(uint localID, LLVector3 pos, + LLVector3 velocity, + LLQuaternion rotation) { byte[] bytes = new byte[60]; int i = 0; ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock(); - dat.TextureEntry = new byte[0];// AvatarTemplate.TextureEntry; + dat.TextureEntry = new byte[0]; // AvatarTemplate.TextureEntry; uint ID = localID; - bytes[i++] = (byte)(ID % 256); - bytes[i++] = (byte)((ID >> 8) % 256); - bytes[i++] = (byte)((ID >> 16) % 256); - bytes[i++] = (byte)((ID >> 24) % 256); + bytes[i++] = (byte) (ID%256); + bytes[i++] = (byte) ((ID >> 8)%256); + bytes[i++] = (byte) ((ID >> 16)%256); + bytes[i++] = (byte) ((ID >> 24)%256); bytes[i++] = 0; bytes[i++] = 1; i += 14; @@ -1078,55 +1107,55 @@ namespace OpenSim.Region.ClientStack internDirec = new Vector3(velocity.X, velocity.Y, velocity.Z); - internDirec = internDirec / 128.0f; + internDirec = internDirec/128.0f; internDirec.x += 1; internDirec.y += 1; internDirec.z += 1; - InternVelocityX = (ushort)(32768 * internDirec.x); - InternVelocityY = (ushort)(32768 * internDirec.y); - InternVelocityZ = (ushort)(32768 * internDirec.z); + InternVelocityX = (ushort) (32768*internDirec.x); + InternVelocityY = (ushort) (32768*internDirec.y); + InternVelocityZ = (ushort) (32768*internDirec.z); ushort ac = 32767; - bytes[i++] = (byte)(InternVelocityX % 256); - bytes[i++] = (byte)((InternVelocityX >> 8) % 256); - bytes[i++] = (byte)(InternVelocityY % 256); - bytes[i++] = (byte)((InternVelocityY >> 8) % 256); - bytes[i++] = (byte)(InternVelocityZ % 256); - bytes[i++] = (byte)((InternVelocityZ >> 8) % 256); + bytes[i++] = (byte) (InternVelocityX%256); + bytes[i++] = (byte) ((InternVelocityX >> 8)%256); + bytes[i++] = (byte) (InternVelocityY%256); + bytes[i++] = (byte) ((InternVelocityY >> 8)%256); + bytes[i++] = (byte) (InternVelocityZ%256); + bytes[i++] = (byte) ((InternVelocityZ >> 8)%256); //accel - bytes[i++] = (byte)(ac % 256); - bytes[i++] = (byte)((ac >> 8) % 256); - bytes[i++] = (byte)(ac % 256); - bytes[i++] = (byte)((ac >> 8) % 256); - bytes[i++] = (byte)(ac % 256); - bytes[i++] = (byte)((ac >> 8) % 256); + bytes[i++] = (byte) (ac%256); + bytes[i++] = (byte) ((ac >> 8)%256); + bytes[i++] = (byte) (ac%256); + bytes[i++] = (byte) ((ac >> 8)%256); + bytes[i++] = (byte) (ac%256); + bytes[i++] = (byte) ((ac >> 8)%256); //rotation ushort rw, rx, ry, rz; - rw = (ushort)(32768 * (rotation.W + 1)); - rx = (ushort)(32768 * (rotation.X + 1)); - ry = (ushort)(32768 * (rotation.Y + 1)); - rz = (ushort)(32768 * (rotation.Z + 1)); + rw = (ushort) (32768*(rotation.W + 1)); + rx = (ushort) (32768*(rotation.X + 1)); + ry = (ushort) (32768*(rotation.Y + 1)); + rz = (ushort) (32768*(rotation.Z + 1)); //rot - bytes[i++] = (byte)(rx % 256); - bytes[i++] = (byte)((rx >> 8) % 256); - bytes[i++] = (byte)(ry % 256); - bytes[i++] = (byte)((ry >> 8) % 256); - bytes[i++] = (byte)(rz % 256); - bytes[i++] = (byte)((rz >> 8) % 256); - bytes[i++] = (byte)(rw % 256); - bytes[i++] = (byte)((rw >> 8) % 256); + bytes[i++] = (byte) (rx%256); + bytes[i++] = (byte) ((rx >> 8)%256); + bytes[i++] = (byte) (ry%256); + bytes[i++] = (byte) ((ry >> 8)%256); + bytes[i++] = (byte) (rz%256); + bytes[i++] = (byte) ((rz >> 8)%256); + bytes[i++] = (byte) (rw%256); + bytes[i++] = (byte) ((rw >> 8)%256); //rotation vel - bytes[i++] = (byte)(ac % 256); - bytes[i++] = (byte)((ac >> 8) % 256); - bytes[i++] = (byte)(ac % 256); - bytes[i++] = (byte)((ac >> 8) % 256); - bytes[i++] = (byte)(ac % 256); - bytes[i++] = (byte)((ac >> 8) % 256); + bytes[i++] = (byte) (ac%256); + bytes[i++] = (byte) ((ac >> 8)%256); + bytes[i++] = (byte) (ac%256); + bytes[i++] = (byte) ((ac >> 8)%256); + bytes[i++] = (byte) (ac%256); + bytes[i++] = (byte) ((ac >> 8)%256); dat.Data = bytes; @@ -1140,7 +1169,9 @@ namespace OpenSim.Region.ClientStack /// /// /// - protected ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreatePrimImprovedBlock(uint localID, LLVector3 position, LLQuaternion rotation) + protected ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreatePrimImprovedBlock(uint localID, + LLVector3 position, + LLQuaternion rotation) { uint ID = localID; byte[] bytes = new byte[60]; @@ -1148,10 +1179,10 @@ namespace OpenSim.Region.ClientStack int i = 0; ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock(); dat.TextureEntry = new byte[0]; - bytes[i++] = (byte)(ID % 256); - bytes[i++] = (byte)((ID >> 8) % 256); - bytes[i++] = (byte)((ID >> 16) % 256); - bytes[i++] = (byte)((ID >> 24) % 256); + bytes[i++] = (byte) (ID%256); + bytes[i++] = (byte) ((ID >> 8)%256); + bytes[i++] = (byte) ((ID >> 16)%256); + bytes[i++] = (byte) ((ID >> 24)%256); bytes[i++] = 0; bytes[i++] = 0; @@ -1161,44 +1192,44 @@ namespace OpenSim.Region.ClientStack ushort ac = 32767; //vel - bytes[i++] = (byte)(ac % 256); - bytes[i++] = (byte)((ac >> 8) % 256); - bytes[i++] = (byte)(ac % 256); - bytes[i++] = (byte)((ac >> 8) % 256); - bytes[i++] = (byte)(ac % 256); - bytes[i++] = (byte)((ac >> 8) % 256); + bytes[i++] = (byte) (ac%256); + bytes[i++] = (byte) ((ac >> 8)%256); + bytes[i++] = (byte) (ac%256); + bytes[i++] = (byte) ((ac >> 8)%256); + bytes[i++] = (byte) (ac%256); + bytes[i++] = (byte) ((ac >> 8)%256); //accel - bytes[i++] = (byte)(ac % 256); - bytes[i++] = (byte)((ac >> 8) % 256); - bytes[i++] = (byte)(ac % 256); - bytes[i++] = (byte)((ac >> 8) % 256); - bytes[i++] = (byte)(ac % 256); - bytes[i++] = (byte)((ac >> 8) % 256); + bytes[i++] = (byte) (ac%256); + bytes[i++] = (byte) ((ac >> 8)%256); + bytes[i++] = (byte) (ac%256); + bytes[i++] = (byte) ((ac >> 8)%256); + bytes[i++] = (byte) (ac%256); + bytes[i++] = (byte) ((ac >> 8)%256); ushort rw, rx, ry, rz; - rw = (ushort)(32768 * (rotation.W + 1)); - rx = (ushort)(32768 * (rotation.X + 1)); - ry = (ushort)(32768 * (rotation.Y + 1)); - rz = (ushort)(32768 * (rotation.Z + 1)); + rw = (ushort) (32768*(rotation.W + 1)); + rx = (ushort) (32768*(rotation.X + 1)); + ry = (ushort) (32768*(rotation.Y + 1)); + rz = (ushort) (32768*(rotation.Z + 1)); //rot - bytes[i++] = (byte)(rx % 256); - bytes[i++] = (byte)((rx >> 8) % 256); - bytes[i++] = (byte)(ry % 256); - bytes[i++] = (byte)((ry >> 8) % 256); - bytes[i++] = (byte)(rz % 256); - bytes[i++] = (byte)((rz >> 8) % 256); - bytes[i++] = (byte)(rw % 256); - bytes[i++] = (byte)((rw >> 8) % 256); + bytes[i++] = (byte) (rx%256); + bytes[i++] = (byte) ((rx >> 8)%256); + bytes[i++] = (byte) (ry%256); + bytes[i++] = (byte) ((ry >> 8)%256); + bytes[i++] = (byte) (rz%256); + bytes[i++] = (byte) ((rz >> 8)%256); + bytes[i++] = (byte) (rw%256); + bytes[i++] = (byte) ((rw >> 8)%256); //rotation vel - bytes[i++] = (byte)(ac % 256); - bytes[i++] = (byte)((ac >> 8) % 256); - bytes[i++] = (byte)(ac % 256); - bytes[i++] = (byte)((ac >> 8) % 256); - bytes[i++] = (byte)(ac % 256); - bytes[i++] = (byte)((ac >> 8) % 256); + bytes[i++] = (byte) (ac%256); + bytes[i++] = (byte) ((ac >> 8)%256); + bytes[i++] = (byte) (ac%256); + bytes[i++] = (byte) ((ac >> 8)%256); + bytes[i++] = (byte) (ac%256); + bytes[i++] = (byte) ((ac >> 8)%256); dat.Data = bytes; return dat; @@ -1212,16 +1243,15 @@ namespace OpenSim.Region.ClientStack protected ObjectUpdatePacket.ObjectDataBlock CreatePrimUpdateBlock(PrimitiveBaseShape primShape, uint flags) { ObjectUpdatePacket.ObjectDataBlock objupdate = new ObjectUpdatePacket.ObjectDataBlock(); - this.SetDefaultPrimPacketValues(objupdate); + SetDefaultPrimPacketValues(objupdate); objupdate.UpdateFlags = flags; - this.SetPrimPacketShapeData(objupdate, primShape); + SetPrimPacketShapeData(objupdate, primShape); return objupdate; } protected void SetPrimPacketShapeData(ObjectUpdatePacket.ObjectDataBlock objectData, PrimitiveBaseShape primData) { - objectData.TextureEntry = primData.TextureEntry; objectData.PCode = primData.PCode; objectData.PathBegin = primData.PathBegin; @@ -1278,10 +1308,11 @@ namespace OpenSim.Region.ClientStack /// protected ObjectUpdatePacket.ObjectDataBlock CreateDefaultAvatarPacket(byte[] textureEntry) { - ObjectUpdatePacket.ObjectDataBlock objdata = new ObjectUpdatePacket.ObjectDataBlock(); // new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock(data1, ref i); + ObjectUpdatePacket.ObjectDataBlock objdata = new ObjectUpdatePacket.ObjectDataBlock(); + // new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock(data1, ref i); SetDefaultAvatarPacketValues(ref objdata); - objdata.UpdateFlags = 61 + (9 << 8) + (130 << 16) + (16 << 24); + objdata.UpdateFlags = 61 + (9 << 8) + (130 << 16) + (16 << 24); objdata.PathCurve = 16; objdata.ProfileCurve = 1; objdata.PathScaleX = 100; @@ -1353,6 +1384,5 @@ namespace OpenSim.Region.ClientStack } #endregion - } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ClientStack/ClientView.PacketHandlers.cs b/OpenSim/Region/ClientStack/ClientView.PacketHandlers.cs index 0771a4a..d589a7b 100644 --- a/OpenSim/Region/ClientStack/ClientView.PacketHandlers.cs +++ b/OpenSim/Region/ClientStack/ClientView.PacketHandlers.cs @@ -27,9 +27,8 @@ */ using libsecondlife; using libsecondlife.Packets; -using OpenSim.Framework.Console; -using OpenSim.Framework.Interfaces; using OpenSim.Framework; +using OpenSim.Framework.Console; namespace OpenSim.Region.ClientStack { @@ -37,17 +36,17 @@ namespace OpenSim.Region.ClientStack { protected virtual void RegisterLocalPacketHandlers() { - this.AddLocalPacketHandler(PacketType.LogoutRequest, this.Logout); - this.AddLocalPacketHandler(PacketType.ViewerEffect, this.HandleViewerEffect); - this.AddLocalPacketHandler(PacketType.AgentCachedTexture, this.AgentTextureCached); - this.AddLocalPacketHandler(PacketType.MultipleObjectUpdate, this.MultipleObjUpdate); + AddLocalPacketHandler(PacketType.LogoutRequest, Logout); + AddLocalPacketHandler(PacketType.ViewerEffect, HandleViewerEffect); + AddLocalPacketHandler(PacketType.AgentCachedTexture, AgentTextureCached); + AddLocalPacketHandler(PacketType.MultipleObjectUpdate, MultipleObjUpdate); } private bool HandleViewerEffect(IClientAPI sender, Packet Pack) { - ViewerEffectPacket viewer = (ViewerEffectPacket)Pack; + ViewerEffectPacket viewer = (ViewerEffectPacket) Pack; - if( OnViewerEffect != null ) + if (OnViewerEffect != null) { OnViewerEffect(sender, viewer.Effect); } @@ -59,7 +58,7 @@ namespace OpenSim.Region.ClientStack { MainLog.Instance.Verbose("CLIENT", "Got a logout request"); - if( OnLogout != null ) + if (OnLogout != null) { OnLogout(client); } @@ -70,13 +69,14 @@ namespace OpenSim.Region.ClientStack protected bool AgentTextureCached(IClientAPI simclient, Packet packet) { //System.Console.WriteLine("texture cached: " + packet.ToString()); - AgentCachedTexturePacket chechedtex = (AgentCachedTexturePacket)packet; + AgentCachedTexturePacket chechedtex = (AgentCachedTexturePacket) packet; AgentCachedTextureResponsePacket cachedresp = new AgentCachedTextureResponsePacket(); - cachedresp.AgentData.AgentID = this.AgentId; - cachedresp.AgentData.SessionID = this.m_sessionId; - cachedresp.AgentData.SerialNum = this.cachedtextureserial; - this.cachedtextureserial++; - cachedresp.WearableData = new AgentCachedTextureResponsePacket.WearableDataBlock[chechedtex.WearableData.Length]; + cachedresp.AgentData.AgentID = AgentId; + cachedresp.AgentData.SessionID = m_sessionId; + cachedresp.AgentData.SerialNum = cachedtextureserial; + cachedtextureserial++; + cachedresp.WearableData = + new AgentCachedTextureResponsePacket.WearableDataBlock[chechedtex.WearableData.Length]; for (int i = 0; i < chechedtex.WearableData.Length; i++) { cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock(); @@ -84,17 +84,18 @@ namespace OpenSim.Region.ClientStack cachedresp.WearableData[i].TextureID = LLUUID.Zero; cachedresp.WearableData[i].HostName = new byte[0]; } - this.OutPacket(cachedresp); + OutPacket(cachedresp); return true; } protected bool MultipleObjUpdate(IClientAPI simClient, Packet packet) { - MultipleObjectUpdatePacket multipleupdate = (MultipleObjectUpdatePacket)packet; + MultipleObjectUpdatePacket multipleupdate = (MultipleObjectUpdatePacket) packet; // System.Console.WriteLine("new multi update packet " + multipleupdate.ToString()); for (int i = 0; i < multipleupdate.ObjectData.Length; i++) { #region position + if (multipleupdate.ObjectData[i].Type == 9) //change position { if (OnUpdatePrimGroupPosition != null) @@ -102,20 +103,20 @@ namespace OpenSim.Region.ClientStack LLVector3 pos = new LLVector3(multipleupdate.ObjectData[i].Data, 0); OnUpdatePrimGroupPosition(multipleupdate.ObjectData[i].ObjectLocalID, pos, this); } - } else if (multipleupdate.ObjectData[i].Type == 1) //single item of group change position { if (OnUpdatePrimSinglePosition != null) { - libsecondlife.LLVector3 pos = new LLVector3(multipleupdate.ObjectData[i].Data, 0); + LLVector3 pos = new LLVector3(multipleupdate.ObjectData[i].Data, 0); // System.Console.WriteLine("new movement position is " + pos.X + " , " + pos.Y + " , " + pos.Z); OnUpdatePrimSinglePosition(multipleupdate.ObjectData[i].ObjectLocalID, pos, this); } } - #endregion position - #region rotation - else if (multipleupdate.ObjectData[i].Type == 2)// single item of group rotation from tab + #endregion position + #region rotation + + else if (multipleupdate.ObjectData[i].Type == 2) // single item of group rotation from tab { if (OnUpdatePrimSingleRotation != null) { @@ -124,38 +125,39 @@ namespace OpenSim.Region.ClientStack OnUpdatePrimSingleRotation(multipleupdate.ObjectData[i].ObjectLocalID, rot, this); } } - else if (multipleupdate.ObjectData[i].Type == 3)// single item of group rotation from mouse + else if (multipleupdate.ObjectData[i].Type == 3) // single item of group rotation from mouse { if (OnUpdatePrimSingleRotation != null) { - libsecondlife.LLQuaternion rot = new LLQuaternion(multipleupdate.ObjectData[i].Data, 12, true); + LLQuaternion rot = new LLQuaternion(multipleupdate.ObjectData[i].Data, 12, true); //System.Console.WriteLine("new mouse rotation is " + rot.X + " , " + rot.Y + " , " + rot.Z + " , " + rot.W); OnUpdatePrimSingleRotation(multipleupdate.ObjectData[i].ObjectLocalID, rot, this); } } - else if (multipleupdate.ObjectData[i].Type == 10)//group rotation from object tab + else if (multipleupdate.ObjectData[i].Type == 10) //group rotation from object tab { if (OnUpdatePrimGroupRotation != null) { - libsecondlife.LLQuaternion rot = new LLQuaternion(multipleupdate.ObjectData[i].Data, 0, true); + LLQuaternion rot = new LLQuaternion(multipleupdate.ObjectData[i].Data, 0, true); // Console.WriteLine("new rotation is " + rot.X + " , " + rot.Y + " , " + rot.Z + " , " + rot.W); OnUpdatePrimGroupRotation(multipleupdate.ObjectData[i].ObjectLocalID, rot, this); } } - else if (multipleupdate.ObjectData[i].Type == 11)//group rotation from mouse + else if (multipleupdate.ObjectData[i].Type == 11) //group rotation from mouse { if (OnUpdatePrimGroupMouseRotation != null) { - libsecondlife.LLVector3 pos = new LLVector3(multipleupdate.ObjectData[i].Data, 0); - libsecondlife.LLQuaternion rot = new LLQuaternion(multipleupdate.ObjectData[i].Data, 12, true); + LLVector3 pos = new LLVector3(multipleupdate.ObjectData[i].Data, 0); + LLQuaternion rot = new LLQuaternion(multipleupdate.ObjectData[i].Data, 12, true); //Console.WriteLine("new rotation position is " + pos.X + " , " + pos.Y + " , " + pos.Z); // Console.WriteLine("new rotation is " + rot.X + " , " + rot.Y + " , " + rot.Z + " , " + rot.W); OnUpdatePrimGroupMouseRotation(multipleupdate.ObjectData[i].ObjectLocalID, pos, rot, this); } } - #endregion - #region scale - else if (multipleupdate.ObjectData[i].Type == 13)//group scale from object tab + #endregion + #region scale + + else if (multipleupdate.ObjectData[i].Type == 13) //group scale from object tab { if (OnUpdatePrimScale != null) { @@ -164,40 +166,41 @@ namespace OpenSim.Region.ClientStack OnUpdatePrimScale(multipleupdate.ObjectData[i].ObjectLocalID, scale, this); // Change the position based on scale (for bug number 246) - libsecondlife.LLVector3 pos = new LLVector3(multipleupdate.ObjectData[i].Data, 0); + LLVector3 pos = new LLVector3(multipleupdate.ObjectData[i].Data, 0); // System.Console.WriteLine("new movement position is " + pos.X + " , " + pos.Y + " , " + pos.Z); OnUpdatePrimSinglePosition(multipleupdate.ObjectData[i].ObjectLocalID, pos, this); } } - else if (multipleupdate.ObjectData[i].Type == 29)//group scale from mouse + else if (multipleupdate.ObjectData[i].Type == 29) //group scale from mouse { if (OnUpdatePrimScale != null) { - libsecondlife.LLVector3 scale = new LLVector3(multipleupdate.ObjectData[i].Data, 12); + LLVector3 scale = new LLVector3(multipleupdate.ObjectData[i].Data, 12); // Console.WriteLine("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z ); OnUpdatePrimScale(multipleupdate.ObjectData[i].ObjectLocalID, scale, this); - libsecondlife.LLVector3 pos = new LLVector3(multipleupdate.ObjectData[i].Data, 0); + LLVector3 pos = new LLVector3(multipleupdate.ObjectData[i].Data, 0); OnUpdatePrimSinglePosition(multipleupdate.ObjectData[i].ObjectLocalID, pos, this); } } - else if (multipleupdate.ObjectData[i].Type == 5)//single prim scale from object tab + else if (multipleupdate.ObjectData[i].Type == 5) //single prim scale from object tab { if (OnUpdatePrimScale != null) { - libsecondlife.LLVector3 scale = new LLVector3(multipleupdate.ObjectData[i].Data, 12); + LLVector3 scale = new LLVector3(multipleupdate.ObjectData[i].Data, 12); // Console.WriteLine("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z); OnUpdatePrimScale(multipleupdate.ObjectData[i].ObjectLocalID, scale, this); } } - else if (multipleupdate.ObjectData[i].Type == 21)//single prim scale from mouse + else if (multipleupdate.ObjectData[i].Type == 21) //single prim scale from mouse { if (OnUpdatePrimScale != null) { - libsecondlife.LLVector3 scale = new LLVector3(multipleupdate.ObjectData[i].Data, 12); + LLVector3 scale = new LLVector3(multipleupdate.ObjectData[i].Data, 12); // Console.WriteLine("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z); OnUpdatePrimScale(multipleupdate.ObjectData[i].ObjectLocalID, scale, this); } } + #endregion } return true; @@ -208,7 +211,7 @@ namespace OpenSim.Region.ClientStack //should be getting the map layer from the grid server //send a layer covering the 800,800 - 1200,1200 area (should be covering the requested area) MapLayerReplyPacket mapReply = new MapLayerReplyPacket(); - mapReply.AgentData.AgentID = this.AgentId; + mapReply.AgentData.AgentID = AgentId; mapReply.AgentData.Flags = 0; mapReply.LayerData = new MapLayerReplyPacket.LayerDataBlock[1]; mapReply.LayerData[0] = new MapLayerReplyPacket.LayerDataBlock(); @@ -217,7 +220,7 @@ namespace OpenSim.Region.ClientStack mapReply.LayerData[0].Top = 30000; mapReply.LayerData[0].Right = 30000; mapReply.LayerData[0].ImageID = new LLUUID("00000000-0000-0000-9999-000000000006"); - this.OutPacket(mapReply); + OutPacket(mapReply); } public void RequestMapBlocks(int minX, int minY, int maxX, int maxY) @@ -251,4 +254,4 @@ namespace OpenSim.Region.ClientStack */ } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ClientStack/ClientView.PacketQueue.cs b/OpenSim/Region/ClientStack/ClientView.PacketQueue.cs index 5cd30ce..efeff29 100644 --- a/OpenSim/Region/ClientStack/ClientView.PacketQueue.cs +++ b/OpenSim/Region/ClientStack/ClientView.PacketQueue.cs @@ -32,13 +32,12 @@ using System.Net.Sockets; using System.Timers; using libsecondlife; using libsecondlife.Packets; -using OpenSim.Framework.Console; using OpenSim.Framework; -using OpenSim.Region.Environment; +using OpenSim.Framework.Console; namespace OpenSim.Region.ClientStack { - public partial class ClientView + public partial class ClientView { protected BlockingQueue PacketQueue; protected Dictionary PendingAcks = new Dictionary(); @@ -84,7 +83,7 @@ namespace OpenSim.Region.ClientStack Pack.Header.Sequence = Sequence; } - if (Pack.Header.Reliable) //DIRTY HACK + if (Pack.Header.Reliable) //DIRTY HACK { lock (NeedAck) { @@ -148,19 +147,21 @@ namespace OpenSim.Region.ClientStack if (Pack.Header.Zerocoded) { int packetsize = Helpers.ZeroEncode(sendbuffer, sendbuffer.Length, ZeroOutBuffer); - m_networkServer.SendPacketTo(ZeroOutBuffer, packetsize, SocketFlags.None, m_circuitCode);//userEP); + m_networkServer.SendPacketTo(ZeroOutBuffer, packetsize, SocketFlags.None, m_circuitCode); //userEP); } else { - m_networkServer.SendPacketTo(sendbuffer, sendbuffer.Length, SocketFlags.None, m_circuitCode); //userEP); + m_networkServer.SendPacketTo(sendbuffer, sendbuffer.Length, SocketFlags.None, m_circuitCode); + //userEP); } } catch (Exception) { - MainLog.Instance.Warn("client", "OpenSimClient.cs:ProcessOutPacket() - WARNING: Socket exception occurred on connection " + userEP.ToString() + " - killing thread"); - this.KillThread(); + MainLog.Instance.Warn("client", + "OpenSimClient.cs:ProcessOutPacket() - WARNING: Socket exception occurred on connection " + + userEP.ToString() + " - killing thread"); + KillThread(); } - } public virtual void InPacket(Packet NewPack) @@ -180,7 +181,7 @@ namespace OpenSim.Region.ClientStack // Handle PacketAck packets if (NewPack.Type == PacketType.PacketAck) { - PacketAckPacket ackPacket = (PacketAckPacket)NewPack; + PacketAckPacket ackPacket = (PacketAckPacket) NewPack; lock (NeedAck) { @@ -193,7 +194,7 @@ namespace OpenSim.Region.ClientStack else if ((NewPack.Type == PacketType.StartPingCheck)) { //reply to pingcheck - StartPingCheckPacket startPing = (StartPingCheckPacket)NewPack; + StartPingCheckPacket startPing = (StartPingCheckPacket) NewPack; CompletePingCheckPacket endPing = new CompletePingCheckPacket(); endPing.PingID.PingID = startPing.PingID.PingID; OutPacket(endPing); @@ -203,9 +204,8 @@ namespace OpenSim.Region.ClientStack QueItem item = new QueItem(); item.Packet = NewPack; item.Incoming = true; - this.PacketQueue.Enqueue(item); + PacketQueue.Enqueue(item); } - } public virtual void OutPacket(Packet NewPack) @@ -213,7 +213,7 @@ namespace OpenSim.Region.ClientStack QueItem item = new QueItem(); item.Packet = NewPack; item.Incoming = false; - this.PacketQueue.Enqueue(item); + PacketQueue.Enqueue(item); } # region Low Level Packet Methods @@ -229,7 +229,6 @@ namespace OpenSim.Region.ClientStack ack_it.Header.Reliable = false; OutPacket(ack_it); - } /* if (Pack.Header.Reliable) @@ -252,8 +251,8 @@ namespace OpenSim.Region.ClientStack { if ((now - packet.TickCount > RESEND_TIMEOUT) && (!packet.Header.Resent)) { - MainLog.Instance.Verbose( "Resending " + packet.Type.ToString() + " packet, " + - (now - packet.TickCount) + "ms have passed"); + MainLog.Instance.Verbose("Resending " + packet.Type.ToString() + " packet, " + + (now - packet.TickCount) + "ms have passed"); packet.Header.Resent = true; OutPacket(packet); @@ -271,7 +270,7 @@ namespace OpenSim.Region.ClientStack if (PendingAcks.Count > 250) { // FIXME: Handle the odd case where we have too many pending ACKs queued up - MainLog.Instance.Verbose( "Too many ACKs queued up!"); + MainLog.Instance.Verbose("Too many ACKs queued up!"); return; } @@ -302,6 +301,7 @@ namespace OpenSim.Region.ClientStack SendAcks(); ResendUnacked(); } + #endregion #region Nested Classes @@ -315,6 +315,7 @@ namespace OpenSim.Region.ClientStack public Packet Packet; public bool Incoming; } + #endregion } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs b/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs index 13e8b43..dd2562c 100644 --- a/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs +++ b/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs @@ -31,8 +31,6 @@ using System.Text; using libsecondlife; using libsecondlife.Packets; using OpenSim.Framework; -using OpenSim.Framework.Interfaces; -using OpenSim.Region.Environment.Scenes; namespace OpenSim.Region.ClientStack { @@ -63,7 +61,7 @@ namespace OpenSim.Region.ClientStack { ack_pack(Pack); - if (this.ProcessPacketMethod(Pack)) + if (ProcessPacketMethod(Pack)) { //there is a handler registered that handled this packet type return; @@ -74,16 +72,17 @@ namespace OpenSim.Region.ClientStack switch (Pack.Type) { - #region Scene/Avatar + #region Scene/Avatar + case PacketType.AvatarPropertiesRequest: - AvatarPropertiesRequestPacket avatarProperties = (AvatarPropertiesRequestPacket)Pack; + AvatarPropertiesRequestPacket avatarProperties = (AvatarPropertiesRequestPacket) Pack; if (OnRequestAvatarProperties != null) { OnRequestAvatarProperties(this, avatarProperties.AgentData.AvatarID); } break; case PacketType.ChatFromViewer: - ChatFromViewerPacket inchatpack = (ChatFromViewerPacket)Pack; + ChatFromViewerPacket inchatpack = (ChatFromViewerPacket) Pack; if (Util.FieldToString(inchatpack.ChatData.Message) == "") { //empty message so don't bother with it @@ -103,30 +102,32 @@ namespace OpenSim.Region.ClientStack args.Channel = channel; args.From = fromName; args.Message = Util.FieldToString(message); - args.Type = (ChatTypeEnum)type; + args.Type = (ChatTypeEnum) type; args.Position = fromPos; args.Scene = Scene; args.Sender = this; - this.OnChatFromViewer(this, args); + OnChatFromViewer(this, args); } break; case PacketType.ImprovedInstantMessage: - ImprovedInstantMessagePacket msgpack = (ImprovedInstantMessagePacket)Pack; + ImprovedInstantMessagePacket msgpack = (ImprovedInstantMessagePacket) Pack; string IMfromName = Util.FieldToString(msgpack.MessageBlock.FromAgentName); string IMmessage = Util.FieldToString(msgpack.MessageBlock.Message); if (OnInstantMessage != null) { - this.OnInstantMessage(msgpack.AgentData.AgentID, msgpack.AgentData.SessionID, msgpack.MessageBlock.ToAgentID, msgpack.MessageBlock.ID, - msgpack.MessageBlock.Timestamp, IMfromName, IMmessage, msgpack.MessageBlock.Dialog); + OnInstantMessage(msgpack.AgentData.AgentID, msgpack.AgentData.SessionID, + msgpack.MessageBlock.ToAgentID, msgpack.MessageBlock.ID, + msgpack.MessageBlock.Timestamp, IMfromName, IMmessage, + msgpack.MessageBlock.Dialog); } break; case PacketType.RezObject: - RezObjectPacket rezPacket = (RezObjectPacket)Pack; + RezObjectPacket rezPacket = (RezObjectPacket) Pack; if (OnRezObject != null) { - this.OnRezObject(this, rezPacket.InventoryData.ItemID, rezPacket.RezData.RayEnd); + OnRezObject(this, rezPacket.InventoryData.ItemID, rezPacket.RezData.RayEnd); } break; case PacketType.DeRezObject: @@ -136,13 +137,15 @@ namespace OpenSim.Region.ClientStack } break; case PacketType.ModifyLand: - ModifyLandPacket modify = (ModifyLandPacket)Pack; + ModifyLandPacket modify = (ModifyLandPacket) Pack; if (modify.ParcelData.Length > 0) { if (OnModifyTerrain != null) { - OnModifyTerrain(modify.ModifyBlock.Height, modify.ModifyBlock.Seconds, modify.ModifyBlock.BrushSize, - modify.ModifyBlock.Action, modify.ParcelData[0].North, modify.ParcelData[0].West, this); + OnModifyTerrain(modify.ModifyBlock.Height, modify.ModifyBlock.Seconds, + modify.ModifyBlock.BrushSize, + modify.ModifyBlock.Action, modify.ParcelData[0].North, + modify.ParcelData[0].West, this); } } break; @@ -164,7 +167,7 @@ namespace OpenSim.Region.ClientStack break; case PacketType.AgentSetAppearance: //OpenSim.Framework.Console.MainLog.Instance.Verbose("set appear", Pack.ToString()); - AgentSetAppearancePacket appear = (AgentSetAppearancePacket)Pack; + AgentSetAppearancePacket appear = (AgentSetAppearancePacket) Pack; if (OnSetAppearance != null) { OnSetAppearance(appear.ObjectData.TextureEntry, appear.VisualParam); @@ -179,17 +182,16 @@ namespace OpenSim.Region.ClientStack case PacketType.AgentUpdate: if (OnAgentUpdate != null) { - AgentUpdatePacket agenUpdate = (AgentUpdatePacket)Pack; + AgentUpdatePacket agenUpdate = (AgentUpdatePacket) Pack; OnAgentUpdate(this, agenUpdate.AgentData.ControlFlags, agenUpdate.AgentData.BodyRotation); } break; case PacketType.AgentAnimation: - AgentAnimationPacket AgentAni = (AgentAnimationPacket)Pack; + AgentAnimationPacket AgentAni = (AgentAnimationPacket) Pack; for (int i = 0; i < AgentAni.AnimationList.Length; i++) { if (AgentAni.AnimationList[i].StartAnim) { - if (OnStartAnim != null) { OnStartAnim(this, AgentAni.AnimationList[i].AnimID, 1); @@ -198,27 +200,29 @@ namespace OpenSim.Region.ClientStack } break; case PacketType.AgentRequestSit: - AgentRequestSitPacket agentRequestSit = (AgentRequestSitPacket)Pack; + AgentRequestSitPacket agentRequestSit = (AgentRequestSitPacket) Pack; SendSitResponse(agentRequestSit.TargetObject.TargetID, agentRequestSit.TargetObject.Offset); if (OnAgentRequestSit != null) { - OnAgentRequestSit(this, agentRequestSit.AgentData.AgentID, agentRequestSit.TargetObject.TargetID); + OnAgentRequestSit(this, agentRequestSit.AgentData.AgentID, + agentRequestSit.TargetObject.TargetID); } break; case PacketType.AgentSit: if (OnAgentSit != null) { - AgentSitPacket agentSit = (AgentSitPacket)Pack; + AgentSitPacket agentSit = (AgentSitPacket) Pack; OnAgentSit(this, agentSit.AgentData.AgentID); } break; - #endregion + #endregion + + #region Objects/m_sceneObjects - #region Objects/m_sceneObjects case PacketType.ObjectLink: // OpenSim.Framework.Console.MainLog.Instance.Verbose( Pack.ToString()); - ObjectLinkPacket link = (ObjectLinkPacket)Pack; + ObjectLinkPacket link = (ObjectLinkPacket) Pack; uint parentprimid = 0; List childrenprims = new List(); if (link.ObjectData.Length > 1) @@ -238,13 +242,13 @@ namespace OpenSim.Region.ClientStack case PacketType.ObjectAdd: if (OnAddPrim != null) { - ObjectAddPacket addPacket = (ObjectAddPacket)Pack; + ObjectAddPacket addPacket = (ObjectAddPacket) Pack; PrimitiveBaseShape shape = GetShapeFromAddPacket(addPacket); - OnAddPrim(this.AgentId, addPacket.ObjectData.RayEnd, shape); + OnAddPrim(AgentId, addPacket.ObjectData.RayEnd, shape); } break; case PacketType.ObjectShape: - ObjectShapePacket shapePacket = (ObjectShapePacket)Pack; + ObjectShapePacket shapePacket = (ObjectShapePacket) Pack; for (int i = 0; i < shapePacket.ObjectData.Length; i++) { if (OnUpdatePrimShape != null) @@ -254,26 +258,28 @@ namespace OpenSim.Region.ClientStack } break; case PacketType.ObjectExtraParams: - ObjectExtraParamsPacket extraPar = (ObjectExtraParamsPacket)Pack; + ObjectExtraParamsPacket extraPar = (ObjectExtraParamsPacket) Pack; if (OnUpdateExtraParams != null) { - OnUpdateExtraParams(extraPar.ObjectData[0].ObjectLocalID, extraPar.ObjectData[0].ParamType, extraPar.ObjectData[0].ParamInUse, extraPar.ObjectData[0].ParamData); + OnUpdateExtraParams(extraPar.ObjectData[0].ObjectLocalID, extraPar.ObjectData[0].ParamType, + extraPar.ObjectData[0].ParamInUse, extraPar.ObjectData[0].ParamData); } break; case PacketType.ObjectDuplicate: - ObjectDuplicatePacket dupe = (ObjectDuplicatePacket)Pack; + ObjectDuplicatePacket dupe = (ObjectDuplicatePacket) Pack; for (int i = 0; i < dupe.ObjectData.Length; i++) { if (OnObjectDuplicate != null) { - OnObjectDuplicate(dupe.ObjectData[i].ObjectLocalID, dupe.SharedData.Offset, dupe.SharedData.DuplicateFlags); + OnObjectDuplicate(dupe.ObjectData[i].ObjectLocalID, dupe.SharedData.Offset, + dupe.SharedData.DuplicateFlags); } } break; case PacketType.ObjectSelect: - ObjectSelectPacket incomingselect = (ObjectSelectPacket)Pack; + ObjectSelectPacket incomingselect = (ObjectSelectPacket) Pack; for (int i = 0; i < incomingselect.ObjectData.Length; i++) { if (OnObjectSelect != null) @@ -283,7 +289,7 @@ namespace OpenSim.Region.ClientStack } break; case PacketType.ObjectDeselect: - ObjectDeselectPacket incomingdeselect = (ObjectDeselectPacket)Pack; + ObjectDeselectPacket incomingdeselect = (ObjectDeselectPacket) Pack; for (int i = 0; i < incomingdeselect.ObjectData.Length; i++) { if (OnObjectDeselect != null) @@ -293,55 +299,58 @@ namespace OpenSim.Region.ClientStack } break; case PacketType.ObjectFlagUpdate: - ObjectFlagUpdatePacket flags = (ObjectFlagUpdatePacket)Pack; + ObjectFlagUpdatePacket flags = (ObjectFlagUpdatePacket) Pack; if (OnUpdatePrimFlags != null) { OnUpdatePrimFlags(flags.AgentData.ObjectLocalID, Pack, this); } break; case PacketType.ObjectImage: - ObjectImagePacket imagePack = (ObjectImagePacket)Pack; + ObjectImagePacket imagePack = (ObjectImagePacket) Pack; for (int i = 0; i < imagePack.ObjectData.Length; i++) { if (OnUpdatePrimTexture != null) { - OnUpdatePrimTexture(imagePack.ObjectData[i].ObjectLocalID, imagePack.ObjectData[i].TextureEntry, this); + OnUpdatePrimTexture(imagePack.ObjectData[i].ObjectLocalID, + imagePack.ObjectData[i].TextureEntry, this); } } break; case PacketType.ObjectGrab: - ObjectGrabPacket grab = (ObjectGrabPacket)Pack; + ObjectGrabPacket grab = (ObjectGrabPacket) Pack; if (OnGrabObject != null) { OnGrabObject(grab.ObjectData.LocalID, grab.ObjectData.GrabOffset, this); } break; case PacketType.ObjectGrabUpdate: - ObjectGrabUpdatePacket grabUpdate = (ObjectGrabUpdatePacket)Pack; + ObjectGrabUpdatePacket grabUpdate = (ObjectGrabUpdatePacket) Pack; if (OnGrabUpdate != null) { - OnGrabUpdate(grabUpdate.ObjectData.ObjectID, grabUpdate.ObjectData.GrabOffsetInitial, grabUpdate.ObjectData.GrabPosition, this); + OnGrabUpdate(grabUpdate.ObjectData.ObjectID, grabUpdate.ObjectData.GrabOffsetInitial, + grabUpdate.ObjectData.GrabPosition, this); } break; case PacketType.ObjectDeGrab: - ObjectDeGrabPacket deGrab = (ObjectDeGrabPacket)Pack; + ObjectDeGrabPacket deGrab = (ObjectDeGrabPacket) Pack; if (OnDeGrabObject != null) { OnDeGrabObject(deGrab.ObjectData.LocalID, this); } break; case PacketType.ObjectDescription: - ObjectDescriptionPacket objDes = (ObjectDescriptionPacket)Pack; + ObjectDescriptionPacket objDes = (ObjectDescriptionPacket) Pack; for (int i = 0; i < objDes.ObjectData.Length; i++) { if (OnObjectDescription != null) { - OnObjectDescription(objDes.ObjectData[i].LocalID, enc.GetString(objDes.ObjectData[i].Description)); + OnObjectDescription(objDes.ObjectData[i].LocalID, + enc.GetString(objDes.ObjectData[i].Description)); } } break; case PacketType.ObjectName: - ObjectNamePacket objName = (ObjectNamePacket)Pack; + ObjectNamePacket objName = (ObjectNamePacket) Pack; for (int i = 0; i < objName.ObjectData.Length; i++) { if (OnObjectName != null) @@ -353,15 +362,16 @@ namespace OpenSim.Region.ClientStack case PacketType.ObjectPermissions: //Console.WriteLine("permissions set " + Pack.ToString()); break; - #endregion - #region Inventory/Asset/Other related packets + #endregion + + #region Inventory/Asset/Other related packets + case PacketType.RequestImage: - RequestImagePacket imageRequest = (RequestImagePacket)Pack; + RequestImagePacket imageRequest = (RequestImagePacket) Pack; //Console.WriteLine("image request: " + Pack.ToString()); for (int i = 0; i < imageRequest.RequestImage.Length; i++) { - // still working on the Texture download module so for now using old method // TextureRequestArgs args = new TextureRequestArgs(); // args.RequestedAssetID = imageRequest.RequestImage[i].Image; @@ -373,86 +383,104 @@ namespace OpenSim.Region.ClientStack // OnRequestTexture(this, args); // } - m_assetCache.AddTextureRequest(this, imageRequest.RequestImage[i].Image, imageRequest.RequestImage[i].Packet, imageRequest.RequestImage[i].DiscardLevel); + m_assetCache.AddTextureRequest(this, imageRequest.RequestImage[i].Image, + imageRequest.RequestImage[i].Packet, + imageRequest.RequestImage[i].DiscardLevel); } break; case PacketType.TransferRequest: //Console.WriteLine("OpenSimClient.cs:ProcessInPacket() - Got transfer request"); - TransferRequestPacket transfer = (TransferRequestPacket)Pack; + TransferRequestPacket transfer = (TransferRequestPacket) Pack; m_assetCache.AddAssetRequest(this, transfer); break; case PacketType.AssetUploadRequest: - AssetUploadRequestPacket request = (AssetUploadRequestPacket)Pack; + AssetUploadRequestPacket request = (AssetUploadRequestPacket) Pack; // Console.WriteLine("upload request " + Pack.ToString()); // Console.WriteLine("upload request was for assetid: " + request.AssetBlock.TransactionID.Combine(this.SecureSessionID).ToStringHyphenated()); if (OnAssetUploadRequest != null) { - OnAssetUploadRequest(this, request.AssetBlock.TransactionID.Combine(this.SecureSessionID), request.AssetBlock.TransactionID, request.AssetBlock.Type, request.AssetBlock.AssetData, request.AssetBlock.StoreLocal); + OnAssetUploadRequest(this, request.AssetBlock.TransactionID.Combine(SecureSessionID), + request.AssetBlock.TransactionID, request.AssetBlock.Type, + request.AssetBlock.AssetData, request.AssetBlock.StoreLocal); } break; case PacketType.RequestXfer: - RequestXferPacket xferReq = (RequestXferPacket)Pack; + RequestXferPacket xferReq = (RequestXferPacket) Pack; if (OnRequestXfer != null) { OnRequestXfer(this, xferReq.XferID.ID, Util.FieldToString(xferReq.XferID.Filename)); } break; case PacketType.SendXferPacket: - SendXferPacketPacket xferRec = (SendXferPacketPacket)Pack; + SendXferPacketPacket xferRec = (SendXferPacketPacket) Pack; if (OnXferReceive != null) { OnXferReceive(this, xferRec.XferID.ID, xferRec.XferID.Packet, xferRec.DataPacket.Data); } break; case PacketType.ConfirmXferPacket: - ConfirmXferPacketPacket confirmXfer = (ConfirmXferPacketPacket)Pack; + ConfirmXferPacketPacket confirmXfer = (ConfirmXferPacketPacket) Pack; if (OnConfirmXfer != null) { OnConfirmXfer(this, confirmXfer.XferID.ID, confirmXfer.XferID.Packet); } break; case PacketType.CreateInventoryFolder: - if (this.OnCreateNewInventoryFolder != null) + if (OnCreateNewInventoryFolder != null) { - CreateInventoryFolderPacket invFolder = (CreateInventoryFolderPacket)Pack; - this.OnCreateNewInventoryFolder(this, invFolder.FolderData.FolderID, (ushort)invFolder.FolderData.Type, Util.FieldToString(invFolder.FolderData.Name), invFolder.FolderData.ParentID); + CreateInventoryFolderPacket invFolder = (CreateInventoryFolderPacket) Pack; + OnCreateNewInventoryFolder(this, invFolder.FolderData.FolderID, + (ushort) invFolder.FolderData.Type, + Util.FieldToString(invFolder.FolderData.Name), + invFolder.FolderData.ParentID); } break; case PacketType.CreateInventoryItem: - CreateInventoryItemPacket createItem = (CreateInventoryItemPacket)Pack; - if (this.OnCreateNewInventoryItem != null) + CreateInventoryItemPacket createItem = (CreateInventoryItemPacket) Pack; + if (OnCreateNewInventoryItem != null) { - this.OnCreateNewInventoryItem(this, createItem.InventoryBlock.TransactionID, createItem.InventoryBlock.FolderID, createItem.InventoryBlock.CallbackID, - Util.FieldToString(createItem.InventoryBlock.Description), Util.FieldToString(createItem.InventoryBlock.Name), createItem.InventoryBlock.InvType, - createItem.InventoryBlock.Type, createItem.InventoryBlock.WearableType, createItem.InventoryBlock.NextOwnerMask); + OnCreateNewInventoryItem(this, createItem.InventoryBlock.TransactionID, + createItem.InventoryBlock.FolderID, + createItem.InventoryBlock.CallbackID, + Util.FieldToString(createItem.InventoryBlock.Description), + Util.FieldToString(createItem.InventoryBlock.Name), + createItem.InventoryBlock.InvType, + createItem.InventoryBlock.Type, + createItem.InventoryBlock.WearableType, + createItem.InventoryBlock.NextOwnerMask); } break; case PacketType.FetchInventory: - if (this.OnFetchInventory != null) + if (OnFetchInventory != null) { - FetchInventoryPacket FetchInventory = (FetchInventoryPacket)Pack; + FetchInventoryPacket FetchInventory = (FetchInventoryPacket) Pack; for (int i = 0; i < FetchInventory.InventoryData.Length; i++) { - this.OnFetchInventory(this, FetchInventory.InventoryData[i].ItemID, FetchInventory.InventoryData[i].OwnerID); + OnFetchInventory(this, FetchInventory.InventoryData[i].ItemID, + FetchInventory.InventoryData[i].OwnerID); } } break; case PacketType.FetchInventoryDescendents: - if (this.OnFetchInventoryDescendents != null) + if (OnFetchInventoryDescendents != null) { - FetchInventoryDescendentsPacket Fetch = (FetchInventoryDescendentsPacket)Pack; - this.OnFetchInventoryDescendents(this, Fetch.InventoryData.FolderID, Fetch.InventoryData.OwnerID, Fetch.InventoryData.FetchFolders, Fetch.InventoryData.FetchItems, Fetch.InventoryData.SortOrder); + FetchInventoryDescendentsPacket Fetch = (FetchInventoryDescendentsPacket) Pack; + OnFetchInventoryDescendents(this, Fetch.InventoryData.FolderID, Fetch.InventoryData.OwnerID, + Fetch.InventoryData.FetchFolders, Fetch.InventoryData.FetchItems, + Fetch.InventoryData.SortOrder); } break; case PacketType.UpdateInventoryItem: - UpdateInventoryItemPacket update = (UpdateInventoryItemPacket)Pack; + UpdateInventoryItemPacket update = (UpdateInventoryItemPacket) Pack; if (OnUpdateInventoryItem != null) { for (int i = 0; i < update.InventoryData.Length; i++) { if (update.InventoryData[i].TransactionID != LLUUID.Zero) { - OnUpdateInventoryItem(this, update.InventoryData[i].TransactionID, update.InventoryData[i].TransactionID.Combine(this.SecureSessionID), update.InventoryData[i].ItemID); + OnUpdateInventoryItem(this, update.InventoryData[i].TransactionID, + update.InventoryData[i].TransactionID.Combine(SecureSessionID), + update.InventoryData[i].ItemID); } } } @@ -488,25 +516,26 @@ namespace OpenSim.Region.ClientStack }*/ break; case PacketType.RequestTaskInventory: - RequestTaskInventoryPacket requesttask = (RequestTaskInventoryPacket)Pack; - if (this.OnRequestTaskInventory != null) + RequestTaskInventoryPacket requesttask = (RequestTaskInventoryPacket) Pack; + if (OnRequestTaskInventory != null) { - this.OnRequestTaskInventory(this, requesttask.InventoryData.LocalID); + OnRequestTaskInventory(this, requesttask.InventoryData.LocalID); } break; case PacketType.UpdateTaskInventory: //Console.WriteLine(Pack.ToString()); - UpdateTaskInventoryPacket updatetask = (UpdateTaskInventoryPacket)Pack; + UpdateTaskInventoryPacket updatetask = (UpdateTaskInventoryPacket) Pack; if (OnUpdateTaskInventory != null) { if (updatetask.UpdateData.Key == 0) { - OnUpdateTaskInventory(this, updatetask.InventoryData.ItemID, updatetask.InventoryData.FolderID, updatetask.UpdateData.LocalID); + OnUpdateTaskInventory(this, updatetask.InventoryData.ItemID, + updatetask.InventoryData.FolderID, updatetask.UpdateData.LocalID); } } break; case PacketType.RemoveTaskInventory: - RemoveTaskInventoryPacket removeTask = (RemoveTaskInventoryPacket)Pack; + RemoveTaskInventoryPacket removeTask = (RemoveTaskInventoryPacket) Pack; if (OnRemoveTaskItem != null) { OnRemoveTaskItem(this, removeTask.InventoryData.ItemID, removeTask.InventoryData.LocalID); @@ -517,38 +546,39 @@ namespace OpenSim.Region.ClientStack break; case PacketType.RezScript: //Console.WriteLine(Pack.ToString()); - RezScriptPacket rezScript = (RezScriptPacket)Pack; + RezScriptPacket rezScript = (RezScriptPacket) Pack; if (OnRezScript != null) { OnRezScript(this, rezScript.InventoryBlock.ItemID, rezScript.UpdateBlock.ObjectLocalID); } break; case PacketType.MapLayerRequest: - this.RequestMapLayer(); + RequestMapLayer(); break; case PacketType.MapBlockRequest: - MapBlockRequestPacket MapRequest = (MapBlockRequestPacket)Pack; + MapBlockRequestPacket MapRequest = (MapBlockRequestPacket) Pack; if (OnRequestMapBlocks != null) { - OnRequestMapBlocks(this, MapRequest.PositionData.MinX, MapRequest.PositionData.MinY, MapRequest.PositionData.MaxX, MapRequest.PositionData.MaxY); + OnRequestMapBlocks(this, MapRequest.PositionData.MinX, MapRequest.PositionData.MinY, + MapRequest.PositionData.MaxX, MapRequest.PositionData.MaxY); } break; case PacketType.TeleportLandmarkRequest: - TeleportLandmarkRequestPacket tpReq = (TeleportLandmarkRequestPacket)Pack; + TeleportLandmarkRequestPacket tpReq = (TeleportLandmarkRequestPacket) Pack; TeleportStartPacket tpStart = new TeleportStartPacket(); tpStart.Info.TeleportFlags = 8; // tp via lm - this.OutPacket(tpStart); + OutPacket(tpStart); TeleportProgressPacket tpProgress = new TeleportProgressPacket(); tpProgress.Info.Message = (new ASCIIEncoding()).GetBytes("sending_landmark"); tpProgress.Info.TeleportFlags = 8; tpProgress.AgentData.AgentID = tpReq.Info.AgentID; - this.OutPacket(tpProgress); + OutPacket(tpProgress); // Fetch landmark LLUUID lmid = tpReq.Info.LandmarkID; - AssetBase lma = this.m_assetCache.GetAsset(lmid); + AssetBase lma = m_assetCache.GetAsset(lmid); if (lma != null) { AssetLandmark lm = new AssetLandmark(lma); @@ -558,7 +588,7 @@ namespace OpenSim.Region.ClientStack TeleportLocalPacket tpLocal = new TeleportLocalPacket(); tpLocal.Info.AgentID = tpReq.Info.AgentID; - tpLocal.Info.TeleportFlags = 8; // Teleport via landmark + tpLocal.Info.TeleportFlags = 8; // Teleport via landmark tpLocal.Info.LocationID = 2; tpLocal.Info.Position = lm.Position; OutPacket(tpLocal); @@ -582,12 +612,13 @@ namespace OpenSim.Region.ClientStack } break; case PacketType.TeleportLocationRequest: - TeleportLocationRequestPacket tpLocReq = (TeleportLocationRequestPacket)Pack; + TeleportLocationRequestPacket tpLocReq = (TeleportLocationRequestPacket) Pack; // Console.WriteLine(tpLocReq.ToString()); if (OnTeleportLocationRequest != null) { - OnTeleportLocationRequest(this, tpLocReq.Info.RegionHandle, tpLocReq.Info.Position, tpLocReq.Info.LookAt, 16); + OnTeleportLocationRequest(this, tpLocReq.Info.RegionHandle, tpLocReq.Info.Position, + tpLocReq.Info.LookAt, 16); } else { @@ -598,76 +629,94 @@ namespace OpenSim.Region.ClientStack OutPacket(tpCancel); } break; - #endregion + + #endregion case PacketType.MoneyBalanceRequest: SendMoneyBalance(LLUUID.Zero, true, new byte[0], MoneyBalance); break; case PacketType.UUIDNameRequest: - UUIDNameRequestPacket incoming = (UUIDNameRequestPacket)Pack; + UUIDNameRequestPacket incoming = (UUIDNameRequestPacket) Pack; foreach (UUIDNameRequestPacket.UUIDNameBlockBlock UUIDBlock in incoming.UUIDNameBlock) { OnNameFromUUIDRequest(UUIDBlock.ID, this); } break; - #region Parcel related packets + + #region Parcel related packets + case PacketType.ParcelPropertiesRequest: - ParcelPropertiesRequestPacket propertiesRequest = (ParcelPropertiesRequestPacket)Pack; + ParcelPropertiesRequestPacket propertiesRequest = (ParcelPropertiesRequestPacket) Pack; if (OnParcelPropertiesRequest != null) { - OnParcelPropertiesRequest((int)Math.Round(propertiesRequest.ParcelData.West), (int)Math.Round(propertiesRequest.ParcelData.South), (int)Math.Round(propertiesRequest.ParcelData.East), (int)Math.Round(propertiesRequest.ParcelData.North), propertiesRequest.ParcelData.SequenceID, propertiesRequest.ParcelData.SnapSelection, this); + OnParcelPropertiesRequest((int) Math.Round(propertiesRequest.ParcelData.West), + (int) Math.Round(propertiesRequest.ParcelData.South), + (int) Math.Round(propertiesRequest.ParcelData.East), + (int) Math.Round(propertiesRequest.ParcelData.North), + propertiesRequest.ParcelData.SequenceID, + propertiesRequest.ParcelData.SnapSelection, this); } break; case PacketType.ParcelDivide: - ParcelDividePacket landDivide = (ParcelDividePacket)Pack; + ParcelDividePacket landDivide = (ParcelDividePacket) Pack; if (OnParcelDivideRequest != null) { - OnParcelDivideRequest((int)Math.Round(landDivide.ParcelData.West), (int)Math.Round(landDivide.ParcelData.South), (int)Math.Round(landDivide.ParcelData.East), (int)Math.Round(landDivide.ParcelData.North), this); + OnParcelDivideRequest((int) Math.Round(landDivide.ParcelData.West), + (int) Math.Round(landDivide.ParcelData.South), + (int) Math.Round(landDivide.ParcelData.East), + (int) Math.Round(landDivide.ParcelData.North), this); } break; case PacketType.ParcelJoin: - ParcelJoinPacket landJoin = (ParcelJoinPacket)Pack; + ParcelJoinPacket landJoin = (ParcelJoinPacket) Pack; if (OnParcelJoinRequest != null) { - OnParcelJoinRequest((int)Math.Round(landJoin.ParcelData.West), (int)Math.Round(landJoin.ParcelData.South), (int)Math.Round(landJoin.ParcelData.East), (int)Math.Round(landJoin.ParcelData.North), this); + OnParcelJoinRequest((int) Math.Round(landJoin.ParcelData.West), + (int) Math.Round(landJoin.ParcelData.South), + (int) Math.Round(landJoin.ParcelData.East), + (int) Math.Round(landJoin.ParcelData.North), this); } break; case PacketType.ParcelPropertiesUpdate: - ParcelPropertiesUpdatePacket updatePacket = (ParcelPropertiesUpdatePacket)Pack; + ParcelPropertiesUpdatePacket updatePacket = (ParcelPropertiesUpdatePacket) Pack; if (OnParcelPropertiesUpdateRequest != null) { OnParcelPropertiesUpdateRequest(updatePacket, this); - } break; case PacketType.ParcelSelectObjects: - ParcelSelectObjectsPacket selectPacket = (ParcelSelectObjectsPacket)Pack; + ParcelSelectObjectsPacket selectPacket = (ParcelSelectObjectsPacket) Pack; if (OnParcelSelectObjects != null) { - OnParcelSelectObjects(selectPacket.ParcelData.LocalID, Convert.ToInt32(selectPacket.ParcelData.ReturnType), this); + OnParcelSelectObjects(selectPacket.ParcelData.LocalID, + Convert.ToInt32(selectPacket.ParcelData.ReturnType), this); } break; case PacketType.ParcelObjectOwnersRequest: - ParcelObjectOwnersRequestPacket reqPacket = (ParcelObjectOwnersRequestPacket)Pack; + ParcelObjectOwnersRequestPacket reqPacket = (ParcelObjectOwnersRequestPacket) Pack; if (OnParcelObjectOwnerRequest != null) { OnParcelObjectOwnerRequest(reqPacket.ParcelData.LocalID, this); } break; - #endregion - #region Estate Packets + #endregion + + #region Estate Packets + case PacketType.EstateOwnerMessage: - EstateOwnerMessagePacket messagePacket = (EstateOwnerMessagePacket)Pack; + EstateOwnerMessagePacket messagePacket = (EstateOwnerMessagePacket) Pack; if (OnEstateOwnerMessage != null) { OnEstateOwnerMessage(messagePacket, this); } break; - #endregion - #region unimplemented handlers + #endregion + + #region unimplemented handlers + case PacketType.AgentIsNowWearing: // AgentIsNowWearingPacket wear = (AgentIsNowWearingPacket)Pack; //Console.WriteLine(Pack.ToString()); @@ -675,7 +724,8 @@ namespace OpenSim.Region.ClientStack case PacketType.ObjectScale: //OpenSim.Framework.Console.MainLog.Instance.Verbose( Pack.ToString()); break; - #endregion + + #endregion } } } @@ -721,4 +771,4 @@ namespace OpenSim.Region.ClientStack OutPacket(logReply); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ClientStack/ClientView.cs b/OpenSim/Region/ClientStack/ClientView.cs index 6d49e34..55f50a4 100644 --- a/OpenSim/Region/ClientStack/ClientView.cs +++ b/OpenSim/Region/ClientStack/ClientView.cs @@ -36,7 +36,7 @@ using libsecondlife.Packets; using OpenSim.Framework; using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Console; -using Timer = System.Timers.Timer; +using Timer=System.Timers.Timer; namespace OpenSim.Region.ClientStack { @@ -50,8 +50,11 @@ namespace OpenSim.Region.ClientStack { public static TerrainManager TerrainManager; - protected static Dictionary PacketHandlers = new Dictionary(); //Global/static handlers for all clients - protected Dictionary m_packetHandlers = new Dictionary(); //local handlers for this instance + protected static Dictionary PacketHandlers = + new Dictionary(); //Global/static handlers for all clients + + protected Dictionary m_packetHandlers = new Dictionary(); + //local handlers for this instance private LLUUID m_sessionId; public LLUUID SecureSessionID = LLUUID.Zero; @@ -84,7 +87,9 @@ namespace OpenSim.Region.ClientStack private int probesWithNoIngressPackets = 0; private int lastPacketsReceived = 0; - public ClientView(EndPoint remoteEP, UseCircuitCodePacket initialcirpack, ClientManager clientManager, IScene scene, AssetCache assetCache, PacketServer packServer, AgentCircuitManager authenSessions) + public ClientView(EndPoint remoteEP, UseCircuitCodePacket initialcirpack, ClientManager clientManager, + IScene scene, AssetCache assetCache, PacketServer packServer, + AgentCircuitManager authenSessions) { m_moneyBalance = 1000; @@ -96,11 +101,11 @@ namespace OpenSim.Region.ClientStack // m_inventoryCache = inventoryCache; m_authenticateSessionsHandler = authenSessions; - MainLog.Instance.Verbose("CLIENT","Started up new client thread to handle incoming request"); + MainLog.Instance.Verbose("CLIENT", "Started up new client thread to handle incoming request"); cirpack = initialcirpack; userEP = remoteEP; - this.startpos = m_authenticateSessionsHandler.GetPosition(initialcirpack.CircuitCode.Code); + startpos = m_authenticateSessionsHandler.GetPosition(initialcirpack.CircuitCode.Code); PacketQueue = new BlockingQueue(); @@ -109,7 +114,7 @@ namespace OpenSim.Region.ClientStack AckTimer.Elapsed += new ElapsedEventHandler(AckTimer_Elapsed); AckTimer.Start(); - this.RegisterLocalPacketHandlers(); + RegisterLocalPacketHandlers(); ClientThread = new Thread(new ThreadStart(AuthUser)); ClientThread.IsBackground = true; @@ -121,7 +126,7 @@ namespace OpenSim.Region.ClientStack get { return m_sessionId; } } - public void SetDebug(int newDebug) + public void SetDebug(int newDebug) { debug = newDebug; } @@ -132,14 +137,15 @@ namespace OpenSim.Region.ClientStack { clientPingTimer.Stop(); - m_scene.RemoveClient(this.AgentId); + m_scene.RemoveClient(AgentId); - this.ClientThread.Abort(); + ClientThread.Abort(); } #endregion # region Packet Handling + public static bool AddPacketHandler(PacketType packetType, PacketMethod handler) { bool result = false; @@ -195,23 +201,27 @@ namespace OpenSim.Region.ClientStack protected void DebugPacket(string direction, Packet packet) { - if (debug > 0) { + if (debug > 0) + { string info; - if (debug < 255 && packet.Type == PacketType.AgentUpdate) - return; - if (debug < 254 && packet.Type == PacketType.ViewerEffect) - return; + if (debug < 255 && packet.Type == PacketType.AgentUpdate) + return; + if (debug < 254 && packet.Type == PacketType.ViewerEffect) + return; if (debug < 253 && ( - packet.Type == PacketType.CompletePingCheck || - packet.Type == PacketType.StartPingCheck - ) ) - return; - if (debug < 252 && packet.Type == PacketType.PacketAck) - return; - - if (debug > 1) { + packet.Type == PacketType.CompletePingCheck || + packet.Type == PacketType.StartPingCheck + )) + return; + if (debug < 252 && packet.Type == PacketType.PacketAck) + return; + + if (debug > 1) + { info = packet.ToString(); - } else { + } + else + { info = packet.Type.ToString(); } Console.WriteLine(m_circuitCode + ":" + direction + ": " + info); @@ -242,6 +252,7 @@ namespace OpenSim.Region.ClientStack } } } + # endregion protected void CheckClientConnectivity(object sender, ElapsedEventArgs e) @@ -251,7 +262,7 @@ namespace OpenSim.Region.ClientStack probesWithNoIngressPackets++; if (probesWithNoIngressPackets > 30) { - if( OnConnectionClosed != null ) + if (OnConnectionClosed != null) { OnConnectionClosed(this); } @@ -278,14 +289,16 @@ namespace OpenSim.Region.ClientStack clientPingTimer.Elapsed += new ElapsedEventHandler(CheckClientConnectivity); clientPingTimer.Enabled = true; - MainLog.Instance.Verbose("CLIENT","Adding viewer agent to scene"); - this.m_scene.AddNewClient(this, true); + MainLog.Instance.Verbose("CLIENT", "Adding viewer agent to scene"); + m_scene.AddNewClient(this, true); } protected virtual void AuthUser() { // AuthenticateResponse sessionInfo = m_gridServer.AuthenticateSession(cirpack.m_circuitCode.m_sessionId, cirpack.m_circuitCode.ID, cirpack.m_circuitCode.Code); - AuthenticateResponse sessionInfo = this.m_authenticateSessionsHandler.AuthenticateSession(cirpack.CircuitCode.SessionID, cirpack.CircuitCode.ID, cirpack.CircuitCode.Code); + AuthenticateResponse sessionInfo = + m_authenticateSessionsHandler.AuthenticateSession(cirpack.CircuitCode.SessionID, cirpack.CircuitCode.ID, + cirpack.CircuitCode.Code); if (!sessionInfo.Authorised) { //session/circuit not authorised @@ -297,27 +310,26 @@ namespace OpenSim.Region.ClientStack MainLog.Instance.Notice("CLIENT", "Got authenticated connection from " + userEP.ToString()); //session is authorised m_agentId = cirpack.CircuitCode.ID; - this.m_sessionId = cirpack.CircuitCode.SessionID; - this.m_circuitCode = cirpack.CircuitCode.Code; - this.firstName = sessionInfo.LoginInfo.First; - this.lastName = sessionInfo.LoginInfo.Last; + m_sessionId = cirpack.CircuitCode.SessionID; + m_circuitCode = cirpack.CircuitCode.Code; + firstName = sessionInfo.LoginInfo.First; + lastName = sessionInfo.LoginInfo.Last; if (sessionInfo.LoginInfo.SecureSession != LLUUID.Zero) { - this.SecureSessionID = sessionInfo.LoginInfo.SecureSession; + SecureSessionID = sessionInfo.LoginInfo.SecureSession; } InitNewClient(); ClientLoop(); } } - # endregion + # endregion protected void KillThread() { - this.ClientThread.Abort(); + ClientThread.Abort(); } - } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ClientStack/PacketServer.cs b/OpenSim/Region/ClientStack/PacketServer.cs index 1b64602..f75536a 100644 --- a/OpenSim/Region/ClientStack/PacketServer.cs +++ b/OpenSim/Region/ClientStack/PacketServer.cs @@ -25,15 +25,11 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ -using System.Collections.Generic; using System.Net; using System.Net.Sockets; using libsecondlife.Packets; using OpenSim.Framework; using OpenSim.Framework.Communications.Cache; -using OpenSim.Framework; -using OpenSim.Framework.Interfaces; -using libsecondlife; namespace OpenSim.Region.ClientStack { @@ -56,10 +52,7 @@ namespace OpenSim.Region.ClientStack public IScene LocalScene { - set - { - this.m_scene = value; - } + set { m_scene = value; } } /// @@ -72,17 +65,21 @@ namespace OpenSim.Region.ClientStack m_scene.ClientManager.InPacket(circuitCode, packet); } - protected virtual IClientAPI CreateNewClient(EndPoint remoteEP, UseCircuitCodePacket initialcirpack, ClientManager clientManager, IScene scene, AssetCache assetCache, PacketServer packServer, AgentCircuitManager authenSessions) + protected virtual IClientAPI CreateNewClient(EndPoint remoteEP, UseCircuitCodePacket initialcirpack, + ClientManager clientManager, IScene scene, AssetCache assetCache, + PacketServer packServer, AgentCircuitManager authenSessions) { - return new ClientView(remoteEP, initialcirpack, clientManager, scene, assetCache, packServer, authenSessions ); + return + new ClientView(remoteEP, initialcirpack, clientManager, scene, assetCache, packServer, authenSessions); } - public virtual bool AddNewClient(EndPoint epSender, UseCircuitCodePacket useCircuit, AssetCache assetCache, AgentCircuitManager authenticateSessionsClass) + public virtual bool AddNewClient(EndPoint epSender, UseCircuitCodePacket useCircuit, AssetCache assetCache, + AgentCircuitManager authenticateSessionsClass) { IClientAPI newuser; if (m_scene.ClientManager.TryGetClient(useCircuit.CircuitCode.Code, out newuser)) - { + { return false; } else @@ -104,7 +101,7 @@ namespace OpenSim.Region.ClientStack { client.SendLogoutPacket(); - CloseClient( client ); + CloseClient(client); } @@ -117,7 +114,7 @@ namespace OpenSim.Region.ClientStack /// public virtual void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode) { - this.m_networkHandler.SendPacketTo(buffer, size, flags, circuitcode); + m_networkHandler.SendPacketTo(buffer, size, flags, circuitcode); } /// @@ -126,13 +123,13 @@ namespace OpenSim.Region.ClientStack /// public virtual void CloseCircuit(uint circuitcode) { - m_networkHandler.RemoveClientCircuit( circuitcode ); + m_networkHandler.RemoveClientCircuit(circuitcode); m_scene.ClientManager.CloseAllAgents(circuitcode); } - public virtual void CloseClient( IClientAPI client ) + public virtual void CloseClient(IClientAPI client) { - CloseCircuit( client.CircuitCode ); + CloseCircuit(client.CircuitCode); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ClientStack/RegionApplicationBase.cs b/OpenSim/Region/ClientStack/RegionApplicationBase.cs index 657af54..7551bff 100644 --- a/OpenSim/Region/ClientStack/RegionApplicationBase.cs +++ b/OpenSim/Region/ClientStack/RegionApplicationBase.cs @@ -28,17 +28,15 @@ using System; using System.Collections.Generic; using System.Net; +using libsecondlife; using OpenSim.Framework; +using OpenSim.Framework.Communications; using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Console; -using OpenSim.Framework.Interfaces; using OpenSim.Framework.Servers; -using OpenSim.Framework; -using OpenSim.Region.Physics.Manager; using OpenSim.Region.Environment; -using libsecondlife; using OpenSim.Region.Environment.Scenes; -using OpenSim.Framework.Communications; +using OpenSim.Region.Physics.Manager; namespace OpenSim.Region.ClientStack { @@ -67,9 +65,8 @@ namespace OpenSim.Region.ClientStack m_startuptime = DateTime.Now; } - virtual public void StartUp() + public virtual void StartUp() { - ClientView.TerrainManager = new TerrainManager(new SecondLife()); Initialize(); @@ -116,7 +113,10 @@ namespace OpenSim.Region.ClientStack scene.PhysScene.SetTerrain(scene.Terrain.GetHeights1D()); //Master Avatar Setup - UserProfileData masterAvatar = m_commsManager.UserService.SetupMasterUser(scene.RegionInfo.MasterAvatarFirstName, scene.RegionInfo.MasterAvatarLastName, scene.RegionInfo.MasterAvatarSandboxPassword); + UserProfileData masterAvatar = + m_commsManager.UserService.SetupMasterUser(scene.RegionInfo.MasterAvatarFirstName, + scene.RegionInfo.MasterAvatarLastName, + scene.RegionInfo.MasterAvatarSandboxPassword); if (masterAvatar != null) { m_log.Verbose("PARCEL", "Found master avatar [" + masterAvatar.UUID.ToStringHyphenated() + "]"); @@ -126,7 +126,7 @@ namespace OpenSim.Region.ClientStack else { m_log.Verbose("PARCEL", "No master avatar found, using null."); - scene.RegionInfo.MasterAvatarAssignedUUID = libsecondlife.LLUUID.Zero; + scene.RegionInfo.MasterAvatarAssignedUUID = LLUUID.Zero; //TODO: Load parcels from storageManager } @@ -138,8 +138,7 @@ namespace OpenSim.Region.ClientStack return scene; } - protected abstract Scene CreateScene(RegionInfo regionInfo, StorageManager storageManager, AgentCircuitManager circuitManager); - - + protected abstract Scene CreateScene(RegionInfo regionInfo, StorageManager storageManager, + AgentCircuitManager circuitManager); } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ClientStack/UDPServer.cs b/OpenSim/Region/ClientStack/UDPServer.cs index 584b80c..e5965cb 100644 --- a/OpenSim/Region/ClientStack/UDPServer.cs +++ b/OpenSim/Region/ClientStack/UDPServer.cs @@ -32,13 +32,10 @@ using System.Net.Sockets; using libsecondlife.Packets; using OpenSim.Framework; using OpenSim.Framework.Communications.Cache; -using OpenSim.Framework; using OpenSim.Framework.Console; -using OpenSim.Framework.Interfaces; namespace OpenSim.Region.ClientStack { - public class UDPServer : ClientStackNetworkHandler { protected Dictionary clientCircuits = new Dictionary(); @@ -59,22 +56,16 @@ namespace OpenSim.Region.ClientStack public PacketServer PacketServer { - get - { - return m_packetServer; - } - set - { - m_packetServer = value; - } + get { return m_packetServer; } + set { m_packetServer = value; } } public IScene LocalScene { set { - this.m_localScene = value; - this.m_packetServer.LocalScene = this.m_localScene; + m_localScene = value; + m_packetServer.LocalScene = m_localScene; } } @@ -85,10 +76,10 @@ namespace OpenSim.Region.ClientStack public UDPServer(int port, AssetCache assetCache, LogBase console, AgentCircuitManager authenticateClass) { listenPort = port; - this.m_assetCache = assetCache; - this.m_log = console; - this.m_authenticateSessionsClass = authenticateClass; - this.CreatePacketServer(); + m_assetCache = assetCache; + m_log = console; + m_authenticateSessionsClass = authenticateClass; + CreatePacketServer(); } protected virtual void CreatePacketServer() @@ -99,7 +90,7 @@ namespace OpenSim.Region.ClientStack protected virtual void OnReceivedData(IAsyncResult result) { ipeSender = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0); - epSender = (EndPoint)ipeSender; + epSender = (EndPoint) ipeSender; Packet packet = null; int numBytes; @@ -108,7 +99,7 @@ namespace OpenSim.Region.ClientStack { numBytes = Server.EndReceiveFrom(result, ref epSender); } - catch (System.Net.Sockets.SocketException e) + catch (SocketException e) { // TODO : Actually only handle those states that we have control over, re-throw everything else, // TODO: implement cases as we encounter them. @@ -134,7 +125,7 @@ namespace OpenSim.Region.ClientStack if (clientCircuits.TryGetValue(epSender, out circuit)) { //if so then send packet to the packetserver - this.m_packetServer.InPacket(circuit, packet); + m_packetServer.InPacket(circuit, packet); } else if (packet.Type == PacketType.UseCircuitCode) { @@ -142,7 +133,8 @@ namespace OpenSim.Region.ClientStack AddNewClient(packet); } else - { // invalid client + { + // invalid client m_log.Warn("client", "Got a packet from an invalid client - " + epSender.ToString()); } @@ -160,10 +152,10 @@ namespace OpenSim.Region.ClientStack protected virtual void AddNewClient(Packet packet) { - UseCircuitCodePacket useCircuit = (UseCircuitCodePacket)packet; - this.clientCircuits.Add(epSender, useCircuit.CircuitCode.Code); + UseCircuitCodePacket useCircuit = (UseCircuitCodePacket) packet; + clientCircuits.Add(epSender, useCircuit.CircuitCode.Code); - this.PacketServer.AddNewClient(epSender, useCircuit, m_assetCache, m_authenticateSessionsClass); + PacketServer.AddNewClient(epSender, useCircuit, m_assetCache, m_authenticateSessionsClass); } public void ServerListener() @@ -177,24 +169,24 @@ namespace OpenSim.Region.ClientStack m_log.Verbose("SERVER", "UDP socket bound, getting ready to listen"); ipeSender = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0); - epSender = (EndPoint)ipeSender; - ReceivedData = new AsyncCallback(this.OnReceivedData); + epSender = (EndPoint) ipeSender; + ReceivedData = new AsyncCallback(OnReceivedData); Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null); m_log.Status("SERVER", "Listening..."); - } public virtual void RegisterPacketServer(PacketServer server) { - this.m_packetServer = server; + m_packetServer = server; } - public virtual void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode)//EndPoint packetSender) + public virtual void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode) + //EndPoint packetSender) { // find the endpoint for this circuit EndPoint sendto = null; - foreach (KeyValuePair p in this.clientCircuits) + foreach (KeyValuePair p in clientCircuits) { if (p.Value == circuitcode) { @@ -205,22 +197,20 @@ namespace OpenSim.Region.ClientStack if (sendto != null) { //we found the endpoint so send the packet to it - this.Server.SendTo(buffer, size, flags, sendto); + Server.SendTo(buffer, size, flags, sendto); } } public virtual void RemoveClientCircuit(uint circuitcode) { - foreach (KeyValuePair p in this.clientCircuits) + foreach (KeyValuePair p in clientCircuits) { if (p.Value == circuitcode) { - this.clientCircuits.Remove(p.Key); + clientCircuits.Remove(p.Key); break; } } } - - } } \ No newline at end of file -- cgit v1.1