aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack
diff options
context:
space:
mode:
authorlbsa712007-12-27 21:41:48 +0000
committerlbsa712007-12-27 21:41:48 +0000
commitefd90b56b761219af6425b1c7a2cdd3b6ffb4de2 (patch)
treebf5b897e1e3c13211e3e2fc61d30508b94c928c0 /OpenSim/Region/ClientStack
parent* removed always true if (diff)
downloadopensim-SC_OLD-efd90b56b761219af6425b1c7a2cdd3b6ffb4de2.zip
opensim-SC_OLD-efd90b56b761219af6425b1c7a2cdd3b6ffb4de2.tar.gz
opensim-SC_OLD-efd90b56b761219af6425b1c7a2cdd3b6ffb4de2.tar.bz2
opensim-SC_OLD-efd90b56b761219af6425b1c7a2cdd3b6ffb4de2.tar.xz
* Optimized usings
* shortened references * Removed redundant 'this' * Normalized EOF
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/ClientStack/ClientStackNetworkHandler.cs2
-rw-r--r--OpenSim/Region/ClientStack/ClientView.cs378
-rw-r--r--OpenSim/Region/ClientStack/PacketQueue.cs198
-rw-r--r--OpenSim/Region/ClientStack/PacketServer.cs13
-rw-r--r--OpenSim/Region/ClientStack/PacketThrottle.cs43
-rw-r--r--OpenSim/Region/ClientStack/QueItem.cs18
-rw-r--r--OpenSim/Region/ClientStack/RegionApplicationBase.cs9
-rw-r--r--OpenSim/Region/ClientStack/UDPServer.cs87
8 files changed, 384 insertions, 364 deletions
diff --git a/OpenSim/Region/ClientStack/ClientStackNetworkHandler.cs b/OpenSim/Region/ClientStack/ClientStackNetworkHandler.cs
index 7bfadea..b3af1cc 100644
--- a/OpenSim/Region/ClientStack/ClientStackNetworkHandler.cs
+++ b/OpenSim/Region/ClientStack/ClientStackNetworkHandler.cs
@@ -35,4 +35,4 @@ namespace OpenSim.Region.ClientStack
35 void RemoveClientCircuit(uint circuitcode); 35 void RemoveClientCircuit(uint circuitcode);
36 void RegisterPacketServer(PacketServer server); 36 void RegisterPacketServer(PacketServer server);
37 } 37 }
38} 38} \ No newline at end of file
diff --git a/OpenSim/Region/ClientStack/ClientView.cs b/OpenSim/Region/ClientStack/ClientView.cs
index f29d2f9..b232ed6 100644
--- a/OpenSim/Region/ClientStack/ClientView.cs
+++ b/OpenSim/Region/ClientStack/ClientView.cs
@@ -38,6 +38,7 @@ using libsecondlife.Packets;
38using OpenSim.Framework; 38using OpenSim.Framework;
39using OpenSim.Framework.Communications.Cache; 39using OpenSim.Framework.Communications.Cache;
40using OpenSim.Framework.Console; 40using OpenSim.Framework.Console;
41using OpenSim.Region.Environment.Scenes;
41using Timer=System.Timers.Timer; 42using Timer=System.Timers.Timer;
42 43
43namespace OpenSim.Region.ClientStack 44namespace OpenSim.Region.ClientStack
@@ -71,9 +72,10 @@ namespace OpenSim.Region.ClientStack
71 private readonly uint m_circuitCode; 72 private readonly uint m_circuitCode;
72 private int m_moneyBalance; 73 private int m_moneyBalance;
73 74
74 private readonly byte[] m_channelVersion=new byte[] { 0x00} ; // Dummy value needed by libSL 75 private readonly byte[] m_channelVersion = new byte[] {0x00}; // Dummy value needed by libSL
75 76
76 /* protected variables */ 77 /* protected variables */
78
77 protected static Dictionary<PacketType, PacketMethod> PacketHandlers = 79 protected static Dictionary<PacketType, PacketMethod> PacketHandlers =
78 new Dictionary<PacketType, PacketMethod>(); //Global/static handlers for all clients 80 new Dictionary<PacketType, PacketMethod>(); //Global/static handlers for all clients
79 81
@@ -94,7 +96,7 @@ namespace OpenSim.Region.ClientStack
94 protected const int RESEND_TIMEOUT = 4000; 96 protected const int RESEND_TIMEOUT = 4000;
95 protected const int MAX_SEQUENCE = 0xFFFFFF; 97 protected const int MAX_SEQUENCE = 0xFFFFFF;
96 protected PacketServer m_networkServer; 98 protected PacketServer m_networkServer;
97 99
98 /* public variables */ 100 /* public variables */
99 protected string m_firstName; 101 protected string m_firstName;
100 protected string m_lastName; 102 protected string m_lastName;
@@ -103,11 +105,12 @@ namespace OpenSim.Region.ClientStack
103 protected EndPoint m_userEndPoint; 105 protected EndPoint m_userEndPoint;
104 106
105 /* Properties */ 107 /* Properties */
108
106 public LLUUID SecureSessionId 109 public LLUUID SecureSessionId
107 { 110 {
108 get { return m_secureSessionId; } 111 get { return m_secureSessionId; }
109 } 112 }
110 113
111 public IScene Scene 114 public IScene Scene
112 { 115 {
113 get { return m_scene; } 116 get { return m_scene; }
@@ -144,7 +147,7 @@ namespace OpenSim.Region.ClientStack
144 { 147 {
145 get { return m_lastName; } 148 get { return m_lastName; }
146 } 149 }
147 150
148 /// <summary> 151 /// <summary>
149 /// Full name of the client (first name and last name) 152 /// Full name of the client (first name and last name)
150 /// </summary> 153 /// </summary>
@@ -162,10 +165,11 @@ namespace OpenSim.Region.ClientStack
162 { 165 {
163 get { return m_moneyBalance; } 166 get { return m_moneyBalance; }
164 } 167 }
165 168
166 /* METHODS */ 169 /* METHODS */
167 170
168 public ClientView(EndPoint remoteEP, IScene scene, AssetCache assetCache, PacketServer packServer, AgentCircuitManager authenSessions, LLUUID agentId, LLUUID sessionId, uint circuitCode) 171 public ClientView(EndPoint remoteEP, IScene scene, AssetCache assetCache, PacketServer packServer,
172 AgentCircuitManager authenSessions, LLUUID agentId, LLUUID sessionId, uint circuitCode)
169 { 173 {
170 m_moneyBalance = 1000; 174 m_moneyBalance = 1000;
171 175
@@ -209,7 +213,6 @@ namespace OpenSim.Region.ClientStack
209 213
210 private void CloseCleanup() 214 private void CloseCleanup()
211 { 215 {
212
213 m_scene.RemoveClient(AgentId); 216 m_scene.RemoveClient(AgentId);
214 // Send the STOP packet 217 // Send the STOP packet
215 DisableSimulatorPacket disable = new DisableSimulatorPacket(); 218 DisableSimulatorPacket disable = new DisableSimulatorPacket();
@@ -222,9 +225,6 @@ namespace OpenSim.Region.ClientStack
222 225
223 Thread.Sleep(2000); 226 Thread.Sleep(2000);
224 227
225
226
227
228 228
229 // Shut down timers 229 // Shut down timers
230 m_ackTimer.Stop(); 230 m_ackTimer.Stop();
@@ -243,18 +243,15 @@ namespace OpenSim.Region.ClientStack
243 243
244 public void Close(bool ShutdownCircult) 244 public void Close(bool ShutdownCircult)
245 { 245 {
246
247 // Pull Client out of Region 246 // Pull Client out of Region
248 MainLog.Instance.Verbose("CLIENT", "Close has been called"); 247 MainLog.Instance.Verbose("CLIENT", "Close has been called");
249 248
250 //raiseevent on the packet server to Shutdown the circuit 249 //raiseevent on the packet server to Shutdown the circuit
251 if (ShutdownCircult) 250 if (ShutdownCircult)
252 OnConnectionClosed(this); 251 OnConnectionClosed(this);
253
254 252
255 CloseCleanup();
256 253
257 254 CloseCleanup();
258 } 255 }
259 256
260 public void Kick(string message) 257 public void Kick(string message)
@@ -262,8 +259,8 @@ namespace OpenSim.Region.ClientStack
262 KickUserPacket kupack = new KickUserPacket(); 259 KickUserPacket kupack = new KickUserPacket();
263 kupack.UserInfo.AgentID = AgentId; 260 kupack.UserInfo.AgentID = AgentId;
264 kupack.UserInfo.SessionID = SessionId; 261 kupack.UserInfo.SessionID = SessionId;
265 kupack.TargetBlock.TargetIP = (uint)0; 262 kupack.TargetBlock.TargetIP = (uint) 0;
266 kupack.TargetBlock.TargetPort = (ushort)0; 263 kupack.TargetBlock.TargetPort = (ushort) 0;
267 kupack.UserInfo.Reason = Helpers.StringToField(message); 264 kupack.UserInfo.Reason = Helpers.StringToField(message);
268 OutPacket(kupack, ThrottleOutPacketType.Task); 265 OutPacket(kupack, ThrottleOutPacketType.Task);
269 } 266 }
@@ -340,9 +337,9 @@ namespace OpenSim.Region.ClientStack
340 if (m_debug < 254 && packet.Type == PacketType.ViewerEffect) 337 if (m_debug < 254 && packet.Type == PacketType.ViewerEffect)
341 return; 338 return;
342 if (m_debug < 253 && ( 339 if (m_debug < 253 && (
343 packet.Type == PacketType.CompletePingCheck || 340 packet.Type == PacketType.CompletePingCheck ||
344 packet.Type == PacketType.StartPingCheck 341 packet.Type == PacketType.StartPingCheck
345 )) 342 ))
346 return; 343 return;
347 if (m_debug < 252 && packet.Type == PacketType.PacketAck) 344 if (m_debug < 252 && packet.Type == PacketType.PacketAck)
348 return; 345 return;
@@ -552,7 +549,7 @@ namespace OpenSim.Region.ClientStack
552 public event EstateOwnerMessageRequest OnEstateOwnerMessage; 549 public event EstateOwnerMessageRequest OnEstateOwnerMessage;
553 public event RegionInfoRequest OnRegionInfoRequest; 550 public event RegionInfoRequest OnRegionInfoRequest;
554 public event EstateCovenantRequest OnEstateCovenantRequest; 551 public event EstateCovenantRequest OnEstateCovenantRequest;
555 552
556 #region Scene/Avatar to Client 553 #region Scene/Avatar to Client
557 554
558 /// <summary> 555 /// <summary>
@@ -561,7 +558,8 @@ namespace OpenSim.Region.ClientStack
561 /// <param name="regionInfo"></param> 558 /// <param name="regionInfo"></param>
562 public void SendRegionHandshake(RegionInfo regionInfo) 559 public void SendRegionHandshake(RegionInfo regionInfo)
563 { 560 {
564 RegionHandshakePacket handshake = (RegionHandshakePacket) PacketPool.Instance.GetPacket(PacketType.RegionHandshake); 561 RegionHandshakePacket handshake =
562 (RegionHandshakePacket) PacketPool.Instance.GetPacket(PacketType.RegionHandshake);
565 563
566 handshake.RegionInfo.BillableFactor = regionInfo.EstateSettings.billableFactor; 564 handshake.RegionInfo.BillableFactor = regionInfo.EstateSettings.billableFactor;
567 handshake.RegionInfo.IsEstateManager = false; 565 handshake.RegionInfo.IsEstateManager = false;
@@ -645,7 +643,7 @@ namespace OpenSim.Region.ClientStack
645 643
646 OutPacket(reply, ThrottleOutPacketType.Task); 644 OutPacket(reply, ThrottleOutPacketType.Task);
647 } 645 }
648 646
649 /// <summary> 647 /// <summary>
650 /// 648 ///
651 /// </summary> 649 /// </summary>
@@ -861,7 +859,7 @@ namespace OpenSim.Region.ClientStack
861 public void SendTeleportFailed() 859 public void SendTeleportFailed()
862 { 860 {
863 TeleportFailedPacket tpFailed = new TeleportFailedPacket(); 861 TeleportFailedPacket tpFailed = new TeleportFailedPacket();
864 tpFailed.Info.AgentID = this.AgentId; 862 tpFailed.Info.AgentID = AgentId;
865 tpFailed.Info.Reason = Helpers.StringToField("unknown failure of teleport"); 863 tpFailed.Info.Reason = Helpers.StringToField("unknown failure of teleport");
866 OutPacket(tpFailed, ThrottleOutPacketType.Task); 864 OutPacket(tpFailed, ThrottleOutPacketType.Task);
867 } 865 }
@@ -914,8 +912,8 @@ namespace OpenSim.Region.ClientStack
914 /// <param name="items">The items contained in the folder identified by folderID</param> 912 /// <param name="items">The items contained in the folder identified by folderID</param>
915 /// <param name="fetchFolders">Do we need to send folder information?</param> 913 /// <param name="fetchFolders">Do we need to send folder information?</param>
916 /// <param name="fetchItems">Do we need to send item information?</param> 914 /// <param name="fetchItems">Do we need to send item information?</param>
917 public void SendInventoryFolderDetails(LLUUID ownerID, LLUUID folderID, List<InventoryItemBase> items, 915 public void SendInventoryFolderDetails(LLUUID ownerID, LLUUID folderID, List<InventoryItemBase> items,
918 List<InventoryFolderBase> folders, 916 List<InventoryFolderBase> folders,
919 bool fetchFolders, bool fetchItems) 917 bool fetchFolders, bool fetchItems)
920 { 918 {
921 // An inventory descendents packet consists of a single agent section and an inventory details 919 // An inventory descendents packet consists of a single agent section and an inventory details
@@ -929,14 +927,14 @@ namespace OpenSim.Region.ClientStack
929 // for one example of this kind of thing. So we'll go for a cautious max 927 // for one example of this kind of thing. So we'll go for a cautious max
930 // items of 20 which gives a packet size of about 11k 928 // items of 20 which gives a packet size of about 11k
931 int MAX_ITEMS_PER_PACKET = 20; 929 int MAX_ITEMS_PER_PACKET = 20;
932 930
933 Encoding enc = Encoding.ASCII; 931 Encoding enc = Encoding.ASCII;
934 uint FULL_MASK_PERMISSIONS = 2147483647; 932 uint FULL_MASK_PERMISSIONS = 2147483647;
935 933
936 if (fetchItems) 934 if (fetchItems)
937 { 935 {
938 InventoryDescendentsPacket descend = CreateInventoryDescendentsPacket(ownerID, folderID); 936 InventoryDescendentsPacket descend = CreateInventoryDescendentsPacket(ownerID, folderID);
939 937
940 if (items.Count < MAX_ITEMS_PER_PACKET) 938 if (items.Count < MAX_ITEMS_PER_PACKET)
941 { 939 {
942 descend.ItemData = new InventoryDescendentsPacket.ItemDataBlock[items.Count]; 940 descend.ItemData = new InventoryDescendentsPacket.ItemDataBlock[items.Count];
@@ -947,7 +945,7 @@ namespace OpenSim.Region.ClientStack
947 descend.ItemData = new InventoryDescendentsPacket.ItemDataBlock[MAX_ITEMS_PER_PACKET]; 945 descend.ItemData = new InventoryDescendentsPacket.ItemDataBlock[MAX_ITEMS_PER_PACKET];
948 descend.AgentData.Descendents = MAX_ITEMS_PER_PACKET; 946 descend.AgentData.Descendents = MAX_ITEMS_PER_PACKET;
949 } 947 }
950 948
951 // Even if we aren't fetching the folders, we still need to include the folder count 949 // Even if we aren't fetching the folders, we still need to include the folder count
952 // in the total number of descendents. Failure to do so will cause subtle bugs such 950 // in the total number of descendents. Failure to do so will cause subtle bugs such
953 // as the failure of textures which haven't been expanded in inventory to show up 951 // as the failure of textures which haven't been expanded in inventory to show up
@@ -956,7 +954,7 @@ namespace OpenSim.Region.ClientStack
956 { 954 {
957 descend.AgentData.Descendents += folders.Count; 955 descend.AgentData.Descendents += folders.Count;
958 } 956 }
959 957
960 int count = 0; 958 int count = 0;
961 int i = 0; 959 int i = 0;
962 foreach (InventoryItemBase item in items) 960 foreach (InventoryItemBase item in items)
@@ -973,28 +971,31 @@ namespace OpenSim.Region.ClientStack
973 descend.ItemData[i].FolderID = item.parentFolderID; 971 descend.ItemData[i].FolderID = item.parentFolderID;
974 descend.ItemData[i].GroupID = new LLUUID("00000000-0000-0000-0000-000000000000"); 972 descend.ItemData[i].GroupID = new LLUUID("00000000-0000-0000-0000-000000000000");
975 descend.ItemData[i].GroupMask = 0; 973 descend.ItemData[i].GroupMask = 0;
976 descend.ItemData[i].InvType = (sbyte)item.invType; 974 descend.ItemData[i].InvType = (sbyte) item.invType;
977 descend.ItemData[i].Name = Helpers.StringToField(item.inventoryName); 975 descend.ItemData[i].Name = Helpers.StringToField(item.inventoryName);
978 descend.ItemData[i].NextOwnerMask = item.inventoryNextPermissions; 976 descend.ItemData[i].NextOwnerMask = item.inventoryNextPermissions;
979 descend.ItemData[i].OwnerID = item.avatarID; 977 descend.ItemData[i].OwnerID = item.avatarID;
980 descend.ItemData[i].OwnerMask = item.inventoryCurrentPermissions; 978 descend.ItemData[i].OwnerMask = item.inventoryCurrentPermissions;
981 descend.ItemData[i].SalePrice = 0; 979 descend.ItemData[i].SalePrice = 0;
982 descend.ItemData[i].SaleType = 0; 980 descend.ItemData[i].SaleType = 0;
983 descend.ItemData[i].Type = (sbyte)item.assetType; 981 descend.ItemData[i].Type = (sbyte) item.assetType;
984 descend.ItemData[i].CRC = 982 descend.ItemData[i].CRC =
985 Helpers.InventoryCRC(descend.ItemData[i].CreationDate, descend.ItemData[i].SaleType, 983 Helpers.InventoryCRC(descend.ItemData[i].CreationDate, descend.ItemData[i].SaleType,
986 descend.ItemData[i].InvType, descend.ItemData[i].Type, 984 descend.ItemData[i].InvType, descend.ItemData[i].Type,
987 descend.ItemData[i].AssetID, descend.ItemData[i].GroupID, descend.ItemData[i].SalePrice, 985 descend.ItemData[i].AssetID, descend.ItemData[i].GroupID,
986 descend.ItemData[i].SalePrice,
988 descend.ItemData[i].OwnerID, descend.ItemData[i].CreatorID, 987 descend.ItemData[i].OwnerID, descend.ItemData[i].CreatorID,
989 descend.ItemData[i].ItemID, descend.ItemData[i].FolderID, descend.ItemData[i].EveryoneMask, 988 descend.ItemData[i].ItemID, descend.ItemData[i].FolderID,
990 descend.ItemData[i].Flags, descend.ItemData[i].OwnerMask, descend.ItemData[i].GroupMask, item.inventoryCurrentPermissions); 989 descend.ItemData[i].EveryoneMask,
991 990 descend.ItemData[i].Flags, descend.ItemData[i].OwnerMask,
991 descend.ItemData[i].GroupMask, item.inventoryCurrentPermissions);
992
992 i++; 993 i++;
993 count++; 994 count++;
994 if (i == MAX_ITEMS_PER_PACKET) 995 if (i == MAX_ITEMS_PER_PACKET)
995 { 996 {
996 OutPacket(descend, ThrottleOutPacketType.Asset); 997 OutPacket(descend, ThrottleOutPacketType.Asset);
997 998
998 if ((items.Count - count) > 0) 999 if ((items.Count - count) > 0)
999 { 1000 {
1000 descend = CreateInventoryDescendentsPacket(ownerID, folderID); 1001 descend = CreateInventoryDescendentsPacket(ownerID, folderID);
@@ -1012,7 +1013,7 @@ namespace OpenSim.Region.ClientStack
1012 } 1013 }
1013 } 1014 }
1014 } 1015 }
1015 1016
1016 if (i < MAX_ITEMS_PER_PACKET) 1017 if (i < MAX_ITEMS_PER_PACKET)
1017 { 1018 {
1018 OutPacket(descend, ThrottleOutPacketType.Asset); 1019 OutPacket(descend, ThrottleOutPacketType.Asset);
@@ -1023,7 +1024,7 @@ namespace OpenSim.Region.ClientStack
1023 if (fetchFolders) 1024 if (fetchFolders)
1024 { 1025 {
1025 InventoryDescendentsPacket descend = CreateInventoryDescendentsPacket(ownerID, folderID); 1026 InventoryDescendentsPacket descend = CreateInventoryDescendentsPacket(ownerID, folderID);
1026 1027
1027 if (folders.Count < MAX_ITEMS_PER_PACKET) 1028 if (folders.Count < MAX_ITEMS_PER_PACKET)
1028 { 1029 {
1029 descend.FolderData = new InventoryDescendentsPacket.FolderDataBlock[folders.Count]; 1030 descend.FolderData = new InventoryDescendentsPacket.FolderDataBlock[folders.Count];
@@ -1034,14 +1035,14 @@ namespace OpenSim.Region.ClientStack
1034 descend.FolderData = new InventoryDescendentsPacket.FolderDataBlock[MAX_ITEMS_PER_PACKET]; 1035 descend.FolderData = new InventoryDescendentsPacket.FolderDataBlock[MAX_ITEMS_PER_PACKET];
1035 descend.AgentData.Descendents = MAX_ITEMS_PER_PACKET; 1036 descend.AgentData.Descendents = MAX_ITEMS_PER_PACKET;
1036 } 1037 }
1037 1038
1038 // Not sure if this scenario ever actually occurs, but nonetheless we include the items 1039 // Not sure if this scenario ever actually occurs, but nonetheless we include the items
1039 // count even if we're not sending item data for the same reasons as above. 1040 // count even if we're not sending item data for the same reasons as above.
1040 if (!fetchItems) 1041 if (!fetchItems)
1041 { 1042 {
1042 descend.AgentData.Descendents += items.Count; 1043 descend.AgentData.Descendents += items.Count;
1043 } 1044 }
1044 1045
1045 int i = 0; 1046 int i = 0;
1046 int count = 0; 1047 int count = 0;
1047 foreach (InventoryFolderBase folder in folders) 1048 foreach (InventoryFolderBase folder in folders)
@@ -1050,32 +1051,34 @@ namespace OpenSim.Region.ClientStack
1050 descend.FolderData[i].FolderID = folder.folderID; 1051 descend.FolderData[i].FolderID = folder.folderID;
1051 descend.FolderData[i].Name = Helpers.StringToField(folder.name); 1052 descend.FolderData[i].Name = Helpers.StringToField(folder.name);
1052 descend.FolderData[i].ParentID = folder.parentID; 1053 descend.FolderData[i].ParentID = folder.parentID;
1053 descend.FolderData[i].Type = (sbyte)folder.type; 1054 descend.FolderData[i].Type = (sbyte) folder.type;
1054 1055
1055 i++; 1056 i++;
1056 count++; 1057 count++;
1057 if (i == MAX_ITEMS_PER_PACKET) 1058 if (i == MAX_ITEMS_PER_PACKET)
1058 { 1059 {
1059 OutPacket(descend, ThrottleOutPacketType.Asset); 1060 OutPacket(descend, ThrottleOutPacketType.Asset);
1060 1061
1061 if ((folders.Count - count) > 0) 1062 if ((folders.Count - count) > 0)
1062 { 1063 {
1063 descend = CreateInventoryDescendentsPacket(ownerID, folderID); 1064 descend = CreateInventoryDescendentsPacket(ownerID, folderID);
1064 if ((folders.Count - count) < MAX_ITEMS_PER_PACKET) 1065 if ((folders.Count - count) < MAX_ITEMS_PER_PACKET)
1065 { 1066 {
1066 descend.FolderData = new InventoryDescendentsPacket.FolderDataBlock[folders.Count - count]; 1067 descend.FolderData =
1068 new InventoryDescendentsPacket.FolderDataBlock[folders.Count - count];
1067 descend.AgentData.Descendents = folders.Count - count; 1069 descend.AgentData.Descendents = folders.Count - count;
1068 } 1070 }
1069 else 1071 else
1070 { 1072 {
1071 descend.FolderData = new InventoryDescendentsPacket.FolderDataBlock[MAX_ITEMS_PER_PACKET]; 1073 descend.FolderData =
1074 new InventoryDescendentsPacket.FolderDataBlock[MAX_ITEMS_PER_PACKET];
1072 descend.AgentData.Descendents = MAX_ITEMS_PER_PACKET; 1075 descend.AgentData.Descendents = MAX_ITEMS_PER_PACKET;
1073 } 1076 }
1074 i = 0; 1077 i = 0;
1075 } 1078 }
1076 } 1079 }
1077 } 1080 }
1078 1081
1079 if (i < MAX_ITEMS_PER_PACKET) 1082 if (i < MAX_ITEMS_PER_PACKET)
1080 { 1083 {
1081 OutPacket(descend, ThrottleOutPacketType.Asset); 1084 OutPacket(descend, ThrottleOutPacketType.Asset);
@@ -1204,6 +1207,7 @@ namespace OpenSim.Region.ClientStack
1204 sendXfer.DataPacket.Data = data; 1207 sendXfer.DataPacket.Data = data;
1205 OutPacket(sendXfer, ThrottleOutPacketType.Task); 1208 OutPacket(sendXfer, ThrottleOutPacketType.Task);
1206 } 1209 }
1210
1207 public void SendAvatarPickerReply(AvatarPickerReplyPacket replyPacket) 1211 public void SendAvatarPickerReply(AvatarPickerReplyPacket replyPacket)
1208 { 1212 {
1209 OutPacket(replyPacket, ThrottleOutPacketType.Task); 1213 OutPacket(replyPacket, ThrottleOutPacketType.Task);
@@ -1272,7 +1276,7 @@ namespace OpenSim.Region.ClientStack
1272 OutPacket(sound, ThrottleOutPacketType.Task); 1276 OutPacket(sound, ThrottleOutPacketType.Task);
1273 } 1277 }
1274 1278
1275 public void SendSunPos(LLVector3 sunPos, LLVector3 sunVel) 1279 public void SendSunPos(LLVector3 sunPos, LLVector3 sunVel)
1276 { 1280 {
1277 SimulatorViewerTimeMessagePacket viewertime = new SimulatorViewerTimeMessagePacket(); 1281 SimulatorViewerTimeMessagePacket viewertime = new SimulatorViewerTimeMessagePacket();
1278 viewertime.TimeInfo.SunDirection = sunPos; 1282 viewertime.TimeInfo.SunDirection = sunPos;
@@ -1524,12 +1528,13 @@ namespace OpenSim.Region.ClientStack
1524 1528
1525 OutPacket(attach, ThrottleOutPacketType.Task); 1529 OutPacket(attach, ThrottleOutPacketType.Task);
1526 } 1530 }
1527 1531
1528 1532
1529 public void SendPrimitiveToClient( 1533 public void SendPrimitiveToClient(
1530 ulong regionHandle, ushort timeDilation, uint localID, PrimitiveBaseShape primShape, LLVector3 pos, 1534 ulong regionHandle, ushort timeDilation, uint localID, PrimitiveBaseShape primShape, LLVector3 pos,
1531 uint flags, 1535 uint flags,
1532 LLUUID objectID, LLUUID ownerID, string text, byte[] color, uint parentID, byte[] particleSystem, LLQuaternion rotation, byte clickAction) 1536 LLUUID objectID, LLUUID ownerID, string text, byte[] color, uint parentID, byte[] particleSystem,
1537 LLQuaternion rotation, byte clickAction)
1533 { 1538 {
1534 ObjectUpdatePacket outPacket = new ObjectUpdatePacket(); 1539 ObjectUpdatePacket outPacket = new ObjectUpdatePacket();
1535 outPacket.RegionData.RegionHandle = regionHandle; 1540 outPacket.RegionData.RegionHandle = regionHandle;
@@ -1572,8 +1577,8 @@ namespace OpenSim.Region.ClientStack
1572 public void SendPrimTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position, 1577 public void SendPrimTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position,
1573 LLQuaternion rotation) 1578 LLQuaternion rotation)
1574 { 1579 {
1575 LLVector3 velocity = new LLVector3(0f,0f,0f); 1580 LLVector3 velocity = new LLVector3(0f, 0f, 0f);
1576 LLVector3 rotationalvelocity = new LLVector3(0f,0f,0f); 1581 LLVector3 rotationalvelocity = new LLVector3(0f, 0f, 0f);
1577 ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket(); 1582 ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket();
1578 terse.RegionData.RegionHandle = regionHandle; 1583 terse.RegionData.RegionHandle = regionHandle;
1579 terse.RegionData.TimeDilation = timeDilation; 1584 terse.RegionData.TimeDilation = timeDilation;
@@ -1582,10 +1587,10 @@ namespace OpenSim.Region.ClientStack
1582 1587
1583 OutPacket(terse, ThrottleOutPacketType.Task); 1588 OutPacket(terse, ThrottleOutPacketType.Task);
1584 } 1589 }
1590
1585 public void SendPrimTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position, 1591 public void SendPrimTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position,
1586 LLQuaternion rotation, LLVector3 velocity, LLVector3 rotationalvelocity) 1592 LLQuaternion rotation, LLVector3 velocity, LLVector3 rotationalvelocity)
1587 { 1593 {
1588
1589 ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket(); 1594 ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket();
1590 terse.RegionData.RegionHandle = regionHandle; 1595 terse.RegionData.RegionHandle = regionHandle;
1591 terse.RegionData.TimeDilation = timeDilation; 1596 terse.RegionData.TimeDilation = timeDilation;
@@ -1594,7 +1599,6 @@ namespace OpenSim.Region.ClientStack
1594 1599
1595 OutPacket(terse, ThrottleOutPacketType.Task); 1600 OutPacket(terse, ThrottleOutPacketType.Task);
1596 } 1601 }
1597
1598 1602
1599 #endregion 1603 #endregion
1600 1604
@@ -1696,7 +1700,9 @@ namespace OpenSim.Region.ClientStack
1696 /// <returns></returns> 1700 /// <returns></returns>
1697 protected ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreatePrimImprovedBlock(uint localID, 1701 protected ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreatePrimImprovedBlock(uint localID,
1698 LLVector3 position, 1702 LLVector3 position,
1699 LLQuaternion rotation, LLVector3 velocity, LLVector3 rotationalvelocity) 1703 LLQuaternion rotation,
1704 LLVector3 velocity,
1705 LLVector3 rotationalvelocity)
1700 { 1706 {
1701 uint ID = localID; 1707 uint ID = localID;
1702 byte[] bytes = new byte[60]; 1708 byte[] bytes = new byte[60];
@@ -1724,16 +1730,16 @@ namespace OpenSim.Region.ClientStack
1724 vel.y += 1; 1730 vel.y += 1;
1725 vel.z += 1; 1731 vel.z += 1;
1726 //vel 1732 //vel
1727 velx = (ushort)(32768 * (vel.x)); 1733 velx = (ushort) (32768*(vel.x));
1728 vely = (ushort)(32768 * (vel.y)); 1734 vely = (ushort) (32768*(vel.y));
1729 velz = (ushort)(32768 * (vel.z)); 1735 velz = (ushort) (32768*(vel.z));
1730 1736
1731 bytes[i++] = (byte) (velx % 256); 1737 bytes[i++] = (byte) (velx%256);
1732 bytes[i++] = (byte) ((velx >> 8) % 256); 1738 bytes[i++] = (byte) ((velx >> 8)%256);
1733 bytes[i++] = (byte) (vely % 256); 1739 bytes[i++] = (byte) (vely%256);
1734 bytes[i++] = (byte) ((vely >> 8) % 256); 1740 bytes[i++] = (byte) ((vely >> 8)%256);
1735 bytes[i++] = (byte) (velz % 256); 1741 bytes[i++] = (byte) (velz%256);
1736 bytes[i++] = (byte) ((velz >> 8) % 256); 1742 bytes[i++] = (byte) ((velz >> 8)%256);
1737 1743
1738 //accel 1744 //accel
1739 bytes[i++] = (byte) (ac%256); 1745 bytes[i++] = (byte) (ac%256);
@@ -1763,21 +1769,21 @@ namespace OpenSim.Region.ClientStack
1763 ushort rvelx, rvely, rvelz; 1769 ushort rvelx, rvely, rvelz;
1764 Vector3 rvel = new Vector3(rotationalvelocity.X, rotationalvelocity.Y, rotationalvelocity.Z); 1770 Vector3 rvel = new Vector3(rotationalvelocity.X, rotationalvelocity.Y, rotationalvelocity.Z);
1765 1771
1766 rvel = rvel / 128.0f; 1772 rvel = rvel/128.0f;
1767 rvel.x += 1; 1773 rvel.x += 1;
1768 rvel.y += 1; 1774 rvel.y += 1;
1769 rvel.z += 1; 1775 rvel.z += 1;
1770 //vel 1776 //vel
1771 rvelx = (ushort)(32768 * (rvel.x)); 1777 rvelx = (ushort) (32768*(rvel.x));
1772 rvely = (ushort)(32768 * (rvel.y)); 1778 rvely = (ushort) (32768*(rvel.y));
1773 rvelz = (ushort)(32768 * (rvel.z)); 1779 rvelz = (ushort) (32768*(rvel.z));
1774 1780
1775 bytes[i++] = (byte)(rvelx % 256); 1781 bytes[i++] = (byte) (rvelx%256);
1776 bytes[i++] = (byte)((rvelx >> 8) % 256); 1782 bytes[i++] = (byte) ((rvelx >> 8)%256);
1777 bytes[i++] = (byte)(rvely % 256); 1783 bytes[i++] = (byte) (rvely%256);
1778 bytes[i++] = (byte)((rvely >> 8) % 256); 1784 bytes[i++] = (byte) ((rvely >> 8)%256);
1779 bytes[i++] = (byte)(rvelz % 256); 1785 bytes[i++] = (byte) (rvelz%256);
1780 bytes[i++] = (byte)((rvelz >> 8) % 256); 1786 bytes[i++] = (byte) ((rvelz >> 8)%256);
1781 1787
1782 dat.Data = bytes; 1788 dat.Data = bytes;
1783 return dat; 1789 return dat;
@@ -1906,7 +1912,7 @@ namespace OpenSim.Region.ClientStack
1906 objdata.Sound = LLUUID.Zero; 1912 objdata.Sound = LLUUID.Zero;
1907 LLObject.TextureEntry ntex = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-5005-000000000005")); 1913 LLObject.TextureEntry ntex = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-5005-000000000005"));
1908 objdata.TextureEntry = ntex.ToBytes(); 1914 objdata.TextureEntry = ntex.ToBytes();
1909 1915
1910 objdata.State = 0; 1916 objdata.State = 0;
1911 objdata.Data = new byte[0]; 1917 objdata.Data = new byte[0];
1912 1918
@@ -1993,13 +1999,13 @@ namespace OpenSim.Region.ClientStack
1993 { 1999 {
1994 MultipleObjectUpdatePacket multipleupdate = (MultipleObjectUpdatePacket) packet; 2000 MultipleObjectUpdatePacket multipleupdate = (MultipleObjectUpdatePacket) packet;
1995 // System.Console.WriteLine("new multi update packet " + multipleupdate.ToString()); 2001 // System.Console.WriteLine("new multi update packet " + multipleupdate.ToString());
1996 OpenSim.Region.Environment.Scenes.Scene tScene = (OpenSim.Region.Environment.Scenes.Scene)this.m_scene; 2002 Scene tScene = (Scene) m_scene;
1997 2003
1998 for (int i = 0; i < multipleupdate.ObjectData.Length; i++) 2004 for (int i = 0; i < multipleupdate.ObjectData.Length; i++)
1999 { 2005 {
2000 // Can't act on Null Data 2006 // Can't act on Null Data
2001 if (multipleupdate.ObjectData[i].Data != null) 2007 if (multipleupdate.ObjectData[i].Data != null)
2002 { 2008 {
2003 LLUUID editobj = tScene.GetSceneObjectPart(multipleupdate.ObjectData[i].ObjectLocalID).UUID; 2009 LLUUID editobj = tScene.GetSceneObjectPart(multipleupdate.ObjectData[i].ObjectLocalID).UUID;
2004 if (editobj != null) 2010 if (editobj != null)
2005 { 2011 {
@@ -2024,8 +2030,8 @@ namespace OpenSim.Region.ClientStack
2024 OnUpdatePrimSinglePosition(multipleupdate.ObjectData[i].ObjectLocalID, pos, this); 2030 OnUpdatePrimSinglePosition(multipleupdate.ObjectData[i].ObjectLocalID, pos, this);
2025 } 2031 }
2026 } 2032 }
2027 #endregion position 2033 #endregion position
2028 #region rotation 2034 #region rotation
2029 2035
2030 else if (multipleupdate.ObjectData[i].Type == 2) // single item of group rotation from tab 2036 else if (multipleupdate.ObjectData[i].Type == 2) // single item of group rotation from tab
2031 { 2037 {
@@ -2062,11 +2068,12 @@ namespace OpenSim.Region.ClientStack
2062 LLQuaternion rot = new LLQuaternion(multipleupdate.ObjectData[i].Data, 12, true); 2068 LLQuaternion rot = new LLQuaternion(multipleupdate.ObjectData[i].Data, 12, true);
2063 //Console.WriteLine("new rotation position is " + pos.X + " , " + pos.Y + " , " + pos.Z); 2069 //Console.WriteLine("new rotation position is " + pos.X + " , " + pos.Y + " , " + pos.Z);
2064 // Console.WriteLine("new rotation is " + rot.X + " , " + rot.Y + " , " + rot.Z + " , " + rot.W); 2070 // Console.WriteLine("new rotation is " + rot.X + " , " + rot.Y + " , " + rot.Z + " , " + rot.W);
2065 OnUpdatePrimGroupMouseRotation(multipleupdate.ObjectData[i].ObjectLocalID, pos, rot, this); 2071 OnUpdatePrimGroupMouseRotation(multipleupdate.ObjectData[i].ObjectLocalID, pos, rot,
2072 this);
2066 } 2073 }
2067 } 2074 }
2068 #endregion 2075 #endregion
2069 #region scale 2076 #region scale
2070 2077
2071 else if (multipleupdate.ObjectData[i].Type == 13) //group scale from object tab 2078 else if (multipleupdate.ObjectData[i].Type == 13) //group scale from object tab
2072 { 2079 {
@@ -2118,9 +2125,9 @@ namespace OpenSim.Region.ClientStack
2118 else 2125 else
2119 { 2126 {
2120 // It's a ghost! tell the client to delete it from view. 2127 // It's a ghost! tell the client to delete it from view.
2121 simClient.SendKillObject(this.Scene.RegionInfo.RegionHandle, multipleupdate.ObjectData[i].ObjectLocalID); 2128 simClient.SendKillObject(Scene.RegionInfo.RegionHandle,
2129 multipleupdate.ObjectData[i].ObjectLocalID);
2122 } 2130 }
2123
2124 } 2131 }
2125 } 2132 }
2126 return true; 2133 return true;
@@ -2173,10 +2180,12 @@ namespace OpenSim.Region.ClientStack
2173 this.OutPacket(mbReply, ThrottleOutPacketType.Land); 2180 this.OutPacket(mbReply, ThrottleOutPacketType.Land);
2174 */ 2181 */
2175 } 2182 }
2183
2176 public void SetChildAgentThrottle(byte[] throttles) 2184 public void SetChildAgentThrottle(byte[] throttles)
2177 { 2185 {
2178 m_packetQueue.SetThrottleFromClient(throttles); 2186 m_packetQueue.SetThrottleFromClient(throttles);
2179 } 2187 }
2188
2180 // Previously ClientView.m_packetQueue 2189 // Previously ClientView.m_packetQueue
2181 2190
2182 // A thread safe sequence number allocator. 2191 // A thread safe sequence number allocator.
@@ -2198,7 +2207,7 @@ namespace OpenSim.Region.ClientStack
2198 } 2207 }
2199 return seq; 2208 return seq;
2200 } 2209 }
2201 2210
2202 protected void AddAck(Packet Pack) 2211 protected void AddAck(Packet Pack)
2203 { 2212 {
2204 lock (m_needAck) 2213 lock (m_needAck)
@@ -2236,13 +2245,13 @@ namespace OpenSim.Region.ClientStack
2236 { 2245 {
2237 Pack.Header.AckList = new uint[m_pendingAcks.Count]; 2246 Pack.Header.AckList = new uint[m_pendingAcks.Count];
2238 int i = 0; 2247 int i = 0;
2239 2248
2240 foreach (uint ack in m_pendingAcks.Values) 2249 foreach (uint ack in m_pendingAcks.Values)
2241 { 2250 {
2242 Pack.Header.AckList[i] = ack; 2251 Pack.Header.AckList[i] = ack;
2243 i++; 2252 i++;
2244 } 2253 }
2245 2254
2246 m_pendingAcks.Clear(); 2255 m_pendingAcks.Clear();
2247 Pack.Header.AppendedAcks = true; 2256 Pack.Header.AppendedAcks = true;
2248 } 2257 }
@@ -2272,22 +2281,22 @@ namespace OpenSim.Region.ClientStack
2272 // Actually make the byte array and send it 2281 // Actually make the byte array and send it
2273 try 2282 try
2274 { 2283 {
2275 byte[] sendbuffer = Pack.ToBytes(); 2284 byte[] sendbuffer = Pack.ToBytes();
2276 if (Pack is RegionHandshakePacket) 2285 if (Pack is RegionHandshakePacket)
2277 { 2286 {
2278 PacketPool.Instance.ReturnPacket(Pack); 2287 PacketPool.Instance.ReturnPacket(Pack);
2279 } 2288 }
2280 2289
2281 if (Pack.Header.Zerocoded) 2290 if (Pack.Header.Zerocoded)
2282 { 2291 {
2283 byte[] ZeroOutBuffer = new byte[4096]; 2292 byte[] ZeroOutBuffer = new byte[4096];
2284 int packetsize = Helpers.ZeroEncode(sendbuffer, sendbuffer.Length, ZeroOutBuffer); 2293 int packetsize = Helpers.ZeroEncode(sendbuffer, sendbuffer.Length, ZeroOutBuffer);
2285 m_networkServer.SendPacketTo(ZeroOutBuffer, packetsize, SocketFlags.None, m_circuitCode); 2294 m_networkServer.SendPacketTo(ZeroOutBuffer, packetsize, SocketFlags.None, m_circuitCode);
2286 } 2295 }
2287 else 2296 else
2288 { 2297 {
2289 m_networkServer.SendPacketTo(sendbuffer, sendbuffer.Length, SocketFlags.None, m_circuitCode); 2298 m_networkServer.SendPacketTo(sendbuffer, sendbuffer.Length, SocketFlags.None, m_circuitCode);
2290 } 2299 }
2291 } 2300 }
2292 catch (Exception e) 2301 catch (Exception e)
2293 { 2302 {
@@ -2298,7 +2307,7 @@ namespace OpenSim.Region.ClientStack
2298 Close(true); 2307 Close(true);
2299 } 2308 }
2300 } 2309 }
2301 2310
2302 public virtual void InPacket(Packet NewPack) 2311 public virtual void InPacket(Packet NewPack)
2303 { 2312 {
2304 // Handle appended ACKs 2313 // Handle appended ACKs
@@ -2314,7 +2323,7 @@ namespace OpenSim.Region.ClientStack
2314 } 2323 }
2315 } 2324 }
2316 } 2325 }
2317 2326
2318 2327
2319 // Handle PacketAck packets 2328 // Handle PacketAck packets
2320 if (NewPack.Type == PacketType.PacketAck) 2329 if (NewPack.Type == PacketType.PacketAck)
@@ -2353,7 +2362,7 @@ namespace OpenSim.Region.ClientStack
2353 item.Packet = NewPack; 2362 item.Packet = NewPack;
2354 item.Incoming = false; 2363 item.Incoming = false;
2355 item.throttleType = throttlePacketType; // Packet throttle type 2364 item.throttleType = throttlePacketType; // Packet throttle type
2356 m_packetQueue.Enqueue(item); 2365 m_packetQueue.Enqueue(item);
2357 } 2366 }
2358 2367
2359 # region Low Level Packet Methods 2368 # region Low Level Packet Methods
@@ -2392,7 +2401,7 @@ namespace OpenSim.Region.ClientStack
2392 if ((now - packet.TickCount > RESEND_TIMEOUT) && (!packet.Header.Resent)) 2401 if ((now - packet.TickCount > RESEND_TIMEOUT) && (!packet.Header.Resent))
2393 { 2402 {
2394 MainLog.Instance.Verbose("NETWORK", "Resending " + packet.Type.ToString() + " packet, " + 2403 MainLog.Instance.Verbose("NETWORK", "Resending " + packet.Type.ToString() + " packet, " +
2395 (now - packet.TickCount) + "ms have passed"); 2404 (now - packet.TickCount) + "ms have passed");
2396 2405
2397 packet.Header.Resent = true; 2406 packet.Header.Resent = true;
2398 OutPacket(packet, ThrottleOutPacketType.Resend); 2407 OutPacket(packet, ThrottleOutPacketType.Resend);
@@ -2442,6 +2451,7 @@ namespace OpenSim.Region.ClientStack
2442 } 2451 }
2443 2452
2444 #endregion 2453 #endregion
2454
2445 // Previously ClientView.ProcessPackets 2455 // Previously ClientView.ProcessPackets
2446 2456
2447 public bool AddMoney(int debit) 2457 public bool AddMoney(int debit)
@@ -2539,12 +2549,13 @@ namespace OpenSim.Region.ClientStack
2539 { 2549 {
2540 if (OnModifyTerrain != null) 2550 if (OnModifyTerrain != null)
2541 { 2551 {
2542 for (int i=0; i < modify.ParcelData.Length; i++) 2552 for (int i = 0; i < modify.ParcelData.Length; i++)
2543 { 2553 {
2544 OnModifyTerrain(modify.ModifyBlock.Height, modify.ModifyBlock.Seconds, 2554 OnModifyTerrain(modify.ModifyBlock.Height, modify.ModifyBlock.Seconds,
2545 modify.ModifyBlock.BrushSize, 2555 modify.ModifyBlock.BrushSize,
2546 modify.ModifyBlock.Action, modify.ParcelData[i].North, 2556 modify.ModifyBlock.Action, modify.ParcelData[i].North,
2547 modify.ParcelData[i].West, modify.ParcelData[i].South, modify.ParcelData[i].East, this); 2557 modify.ParcelData[i].West, modify.ParcelData[i].South,
2558 modify.ParcelData[i].East, this);
2548 } 2559 }
2549 } 2560 }
2550 } 2561 }
@@ -2558,7 +2569,7 @@ namespace OpenSim.Region.ClientStack
2558 case PacketType.AgentWearablesRequest: 2569 case PacketType.AgentWearablesRequest:
2559 if (OnRequestWearables != null) 2570 if (OnRequestWearables != null)
2560 { 2571 {
2561 OnRequestWearables( ); 2572 OnRequestWearables();
2562 } 2573 }
2563 if (OnRequestAvatarsData != null) 2574 if (OnRequestAvatarsData != null)
2564 { 2575 {
@@ -2575,21 +2586,23 @@ namespace OpenSim.Region.ClientStack
2575 case PacketType.AgentIsNowWearing: 2586 case PacketType.AgentIsNowWearing:
2576 if (OnAvatarNowWearing != null) 2587 if (OnAvatarNowWearing != null)
2577 { 2588 {
2578 AgentIsNowWearingPacket nowWearing = (AgentIsNowWearingPacket)Pack; 2589 AgentIsNowWearingPacket nowWearing = (AgentIsNowWearingPacket) Pack;
2579 AvatarWearingArgs wearingArgs = new AvatarWearingArgs(); 2590 AvatarWearingArgs wearingArgs = new AvatarWearingArgs();
2580 for (int i = 0; i < nowWearing.WearableData.Length; i++) 2591 for (int i = 0; i < nowWearing.WearableData.Length; i++)
2581 { 2592 {
2582 AvatarWearingArgs.Wearable wearable = new AvatarWearingArgs.Wearable(nowWearing.WearableData[i].ItemID, nowWearing.WearableData[i].WearableType); 2593 AvatarWearingArgs.Wearable wearable =
2594 new AvatarWearingArgs.Wearable(nowWearing.WearableData[i].ItemID,
2595 nowWearing.WearableData[i].WearableType);
2583 wearingArgs.NowWearing.Add(wearable); 2596 wearingArgs.NowWearing.Add(wearable);
2584 } 2597 }
2585 OnAvatarNowWearing(this, wearingArgs); 2598 OnAvatarNowWearing(this, wearingArgs);
2586 } 2599 }
2587 break; 2600 break;
2588 case PacketType.SetAlwaysRun: 2601 case PacketType.SetAlwaysRun:
2589 SetAlwaysRunPacket run = (SetAlwaysRunPacket)Pack; 2602 SetAlwaysRunPacket run = (SetAlwaysRunPacket) Pack;
2590 2603
2591 if (OnSetAlwaysRun != null) 2604 if (OnSetAlwaysRun != null)
2592 OnSetAlwaysRun(this,run.AgentData.AlwaysRun); 2605 OnSetAlwaysRun(this, run.AgentData.AlwaysRun);
2593 2606
2594 break; 2607 break;
2595 case PacketType.CompleteAgentMovement: 2608 case PacketType.CompleteAgentMovement:
@@ -2603,7 +2616,8 @@ namespace OpenSim.Region.ClientStack
2603 { 2616 {
2604 AgentUpdatePacket agenUpdate = (AgentUpdatePacket) Pack; 2617 AgentUpdatePacket agenUpdate = (AgentUpdatePacket) Pack;
2605 2618
2606 OnAgentUpdate(this, agenUpdate); //agenUpdate.AgentData.ControlFlags, agenUpdate.AgentData.BodyRotationa); 2619 OnAgentUpdate(this, agenUpdate);
2620 //agenUpdate.AgentData.ControlFlags, agenUpdate.AgentData.BodyRotationa);
2607 } 2621 }
2608 break; 2622 break;
2609 case PacketType.AgentAnimation: 2623 case PacketType.AgentAnimation:
@@ -2642,15 +2656,17 @@ namespace OpenSim.Region.ClientStack
2642 } 2656 }
2643 break; 2657 break;
2644 case PacketType.AvatarPickerRequest: 2658 case PacketType.AvatarPickerRequest:
2645 AvatarPickerRequestPacket avRequestQuery = (AvatarPickerRequestPacket)Pack; 2659 AvatarPickerRequestPacket avRequestQuery = (AvatarPickerRequestPacket) Pack;
2646 AvatarPickerRequestPacket.AgentDataBlock Requestdata = avRequestQuery.AgentData; 2660 AvatarPickerRequestPacket.AgentDataBlock Requestdata = avRequestQuery.AgentData;
2647 AvatarPickerRequestPacket.DataBlock querydata = avRequestQuery.Data; 2661 AvatarPickerRequestPacket.DataBlock querydata = avRequestQuery.Data;
2648 //System.Console.WriteLine("Agent Sends:" + Helpers.FieldToUTF8String(querydata.Name)); 2662 //System.Console.WriteLine("Agent Sends:" + Helpers.FieldToUTF8String(querydata.Name));
2649 if (OnAvatarPickerRequest != null) 2663 if (OnAvatarPickerRequest != null)
2650 { 2664 {
2651 OnAvatarPickerRequest(this, Requestdata.AgentID, Requestdata.QueryID, Helpers.FieldToUTF8String(querydata.Name)); 2665 OnAvatarPickerRequest(this, Requestdata.AgentID, Requestdata.QueryID,
2666 Helpers.FieldToUTF8String(querydata.Name));
2652 } 2667 }
2653 break; 2668 break;
2669
2654 #endregion 2670 #endregion
2655 2671
2656 #region Objects/m_sceneObjects 2672 #region Objects/m_sceneObjects
@@ -2675,7 +2691,7 @@ namespace OpenSim.Region.ClientStack
2675 break; 2691 break;
2676 case PacketType.ObjectDelink: 2692 case PacketType.ObjectDelink:
2677 ObjectDelinkPacket delink = (ObjectDelinkPacket) Pack; 2693 ObjectDelinkPacket delink = (ObjectDelinkPacket) Pack;
2678 2694
2679 // It appears the prim at index 0 is not always the root prim (for 2695 // It appears the prim at index 0 is not always the root prim (for
2680 // instance, when one prim of a link set has been edited independently 2696 // instance, when one prim of a link set has been edited independently
2681 // of the others). Therefore, we'll pass all the ids onto the delink 2697 // of the others). Therefore, we'll pass all the ids onto the delink
@@ -2683,11 +2699,11 @@ namespace OpenSim.Region.ClientStack
2683 List<uint> prims = new List<uint>(); 2699 List<uint> prims = new List<uint>();
2684 for (int i = 0; i < delink.ObjectData.Length; i++) 2700 for (int i = 0; i < delink.ObjectData.Length; i++)
2685 { 2701 {
2686 prims.Add(delink.ObjectData[i].ObjectLocalID); 2702 prims.Add(delink.ObjectData[i].ObjectLocalID);
2687 } 2703 }
2688 2704
2689 if (OnDelinkObjects != null) 2705 if (OnDelinkObjects != null)
2690 { 2706 {
2691 OnDelinkObjects(prims); 2707 OnDelinkObjects(prims);
2692 } 2708 }
2693 2709
@@ -2706,7 +2722,8 @@ namespace OpenSim.Region.ClientStack
2706 { 2722 {
2707 if (OnUpdatePrimShape != null) 2723 if (OnUpdatePrimShape != null)
2708 { 2724 {
2709 OnUpdatePrimShape(this.m_agentId, shapePacket.ObjectData[i].ObjectLocalID, shapePacket.ObjectData[i]); 2725 OnUpdatePrimShape(m_agentId, shapePacket.ObjectData[i].ObjectLocalID,
2726 shapePacket.ObjectData[i]);
2710 } 2727 }
2711 } 2728 }
2712 break; 2729 break;
@@ -2714,7 +2731,8 @@ namespace OpenSim.Region.ClientStack
2714 ObjectExtraParamsPacket extraPar = (ObjectExtraParamsPacket) Pack; 2731 ObjectExtraParamsPacket extraPar = (ObjectExtraParamsPacket) Pack;
2715 if (OnUpdateExtraParams != null) 2732 if (OnUpdateExtraParams != null)
2716 { 2733 {
2717 OnUpdateExtraParams(this.m_agentId, extraPar.ObjectData[0].ObjectLocalID, extraPar.ObjectData[0].ParamType, 2734 OnUpdateExtraParams(m_agentId, extraPar.ObjectData[0].ObjectLocalID,
2735 extraPar.ObjectData[0].ParamType,
2718 extraPar.ObjectData[0].ParamInUse, extraPar.ObjectData[0].ParamData); 2736 extraPar.ObjectData[0].ParamInUse, extraPar.ObjectData[0].ParamData);
2719 } 2737 }
2720 break; 2738 break;
@@ -2726,7 +2744,8 @@ namespace OpenSim.Region.ClientStack
2726 if (OnObjectDuplicate != null) 2744 if (OnObjectDuplicate != null)
2727 { 2745 {
2728 OnObjectDuplicate(dupe.ObjectData[i].ObjectLocalID, dupe.SharedData.Offset, 2746 OnObjectDuplicate(dupe.ObjectData[i].ObjectLocalID, dupe.SharedData.Offset,
2729 dupe.SharedData.DuplicateFlags, AgentandGroupData.AgentID, AgentandGroupData.GroupID); 2747 dupe.SharedData.DuplicateFlags, AgentandGroupData.AgentID,
2748 AgentandGroupData.GroupID);
2730 } 2749 }
2731 } 2750 }
2732 2751
@@ -2809,21 +2828,23 @@ namespace OpenSim.Region.ClientStack
2809 { 2828 {
2810 if (OnObjectName != null) 2829 if (OnObjectName != null)
2811 { 2830 {
2812 OnObjectName(this, objName.ObjectData[i].LocalID, m_encoding.GetString(objName.ObjectData[i].Name)); 2831 OnObjectName(this, objName.ObjectData[i].LocalID,
2832 m_encoding.GetString(objName.ObjectData[i].Name));
2813 } 2833 }
2814 } 2834 }
2815 break; 2835 break;
2816 case PacketType.ObjectPermissions: 2836 case PacketType.ObjectPermissions:
2817 MainLog.Instance.Warn("CLIENT", "unhandled packet " + PacketType.ObjectPermissions.ToString()); 2837 MainLog.Instance.Warn("CLIENT", "unhandled packet " + PacketType.ObjectPermissions.ToString());
2818 ObjectPermissionsPacket newobjPerms = (ObjectPermissionsPacket)Pack; 2838 ObjectPermissionsPacket newobjPerms = (ObjectPermissionsPacket) Pack;
2839
2840 List<ObjectPermissionsPacket.ObjectDataBlock> permChanges =
2841 new List<ObjectPermissionsPacket.ObjectDataBlock>();
2819 2842
2820 List<ObjectPermissionsPacket.ObjectDataBlock> permChanges = new List<ObjectPermissionsPacket.ObjectDataBlock>();
2821
2822 for (int i = 0; i < newobjPerms.ObjectData.Length; i++) 2843 for (int i = 0; i < newobjPerms.ObjectData.Length; i++)
2823 { 2844 {
2824 permChanges.Add(newobjPerms.ObjectData[i]); 2845 permChanges.Add(newobjPerms.ObjectData[i]);
2825 } 2846 }
2826 2847
2827 // Here's our data, 2848 // Here's our data,
2828 // PermField contains the field the info goes into 2849 // PermField contains the field the info goes into
2829 // PermField determines which mask we're changing 2850 // PermField determines which mask we're changing
@@ -2847,16 +2868,15 @@ namespace OpenSim.Region.ClientStack
2847 2868
2848 case PacketType.RequestObjectPropertiesFamily: 2869 case PacketType.RequestObjectPropertiesFamily:
2849 //This powers the little tooltip that appears when you move your mouse over an object 2870 //This powers the little tooltip that appears when you move your mouse over an object
2850 RequestObjectPropertiesFamilyPacket packToolTip = (RequestObjectPropertiesFamilyPacket)Pack; 2871 RequestObjectPropertiesFamilyPacket packToolTip = (RequestObjectPropertiesFamilyPacket) Pack;
2851 2872
2852 2873
2853 RequestObjectPropertiesFamilyPacket.ObjectDataBlock packObjBlock = packToolTip.ObjectData; 2874 RequestObjectPropertiesFamilyPacket.ObjectDataBlock packObjBlock = packToolTip.ObjectData;
2854 2875
2855 if (OnRequestObjectPropertiesFamily != null) 2876 if (OnRequestObjectPropertiesFamily != null)
2856 { 2877 {
2857 OnRequestObjectPropertiesFamily(this, this.m_agentId, packObjBlock.RequestFlags, packObjBlock.ObjectID); 2878 OnRequestObjectPropertiesFamily(this, m_agentId, packObjBlock.RequestFlags,
2858 2879 packObjBlock.ObjectID);
2859
2860 } 2880 }
2861 2881
2862 break; 2882 break;
@@ -2882,7 +2902,7 @@ namespace OpenSim.Region.ClientStack
2882 OnRequestTexture(this, args); 2902 OnRequestTexture(this, args);
2883 } 2903 }
2884 2904
2885 // m_assetCache.AddTextureRequest(this, imageRequest.RequestImage[i].Image, 2905 // m_assetCache.AddTextureRequest(this, imageRequest.RequestImage[i].Image,
2886 // imageRequest.RequestImage[i].Packet, 2906 // imageRequest.RequestImage[i].Packet,
2887 // imageRequest.RequestImage[i].DiscardLevel); 2907 // imageRequest.RequestImage[i].DiscardLevel);
2888 } 2908 }
@@ -2898,10 +2918,11 @@ namespace OpenSim.Region.ClientStack
2898 // Console.WriteLine("upload request was for assetid: " + request.AssetBlock.TransactionID.Combine(this.SecureSessionId).ToString()); 2918 // Console.WriteLine("upload request was for assetid: " + request.AssetBlock.TransactionID.Combine(this.SecureSessionId).ToString());
2899 if (OnAssetUploadRequest != null) 2919 if (OnAssetUploadRequest != null)
2900 { 2920 {
2901 LLUUID temp=libsecondlife.LLUUID.Combine(request.AssetBlock.TransactionID, SecureSessionId); 2921 LLUUID temp = LLUUID.Combine(request.AssetBlock.TransactionID, SecureSessionId);
2902 OnAssetUploadRequest(this, temp, 2922 OnAssetUploadRequest(this, temp,
2903 request.AssetBlock.TransactionID, request.AssetBlock.Type, 2923 request.AssetBlock.TransactionID, request.AssetBlock.Type,
2904 request.AssetBlock.AssetData, request.AssetBlock.StoreLocal, request.AssetBlock.Tempfile); 2924 request.AssetBlock.AssetData, request.AssetBlock.StoreLocal,
2925 request.AssetBlock.Tempfile);
2905 } 2926 }
2906 break; 2927 break;
2907 case PacketType.RequestXfer: 2928 case PacketType.RequestXfer:
@@ -2938,24 +2959,24 @@ namespace OpenSim.Region.ClientStack
2938 case PacketType.UpdateInventoryFolder: 2959 case PacketType.UpdateInventoryFolder:
2939 if (OnUpdateInventoryFolder != null) 2960 if (OnUpdateInventoryFolder != null)
2940 { 2961 {
2941 UpdateInventoryFolderPacket invFolder = (UpdateInventoryFolderPacket)Pack; 2962 UpdateInventoryFolderPacket invFolder = (UpdateInventoryFolderPacket) Pack;
2942 for (int i = 0; i < invFolder.FolderData.Length; i++) 2963 for (int i = 0; i < invFolder.FolderData.Length; i++)
2943 { 2964 {
2944 OnUpdateInventoryFolder(this, invFolder.FolderData[i].FolderID, 2965 OnUpdateInventoryFolder(this, invFolder.FolderData[i].FolderID,
2945 (ushort)invFolder.FolderData[i].Type, 2966 (ushort) invFolder.FolderData[i].Type,
2946 Util.FieldToString(invFolder.FolderData[i].Name), 2967 Util.FieldToString(invFolder.FolderData[i].Name),
2947 invFolder.FolderData[i].ParentID); 2968 invFolder.FolderData[i].ParentID);
2948 } 2969 }
2949 } 2970 }
2950 break; 2971 break;
2951 case PacketType.MoveInventoryFolder: 2972 case PacketType.MoveInventoryFolder:
2952 if (OnMoveInventoryFolder != null) 2973 if (OnMoveInventoryFolder != null)
2953 { 2974 {
2954 MoveInventoryFolderPacket invFolder = (MoveInventoryFolderPacket)Pack; 2975 MoveInventoryFolderPacket invFolder = (MoveInventoryFolderPacket) Pack;
2955 for (int i = 0; i < invFolder.InventoryData.Length; i++) 2976 for (int i = 0; i < invFolder.InventoryData.Length; i++)
2956 { 2977 {
2957 OnMoveInventoryFolder(this, invFolder.InventoryData[i].FolderID, 2978 OnMoveInventoryFolder(this, invFolder.InventoryData[i].FolderID,
2958 invFolder.InventoryData[i].ParentID); 2979 invFolder.InventoryData[i].ParentID);
2959 } 2980 }
2960 } 2981 }
2961 break; 2982 break;
@@ -2997,7 +3018,7 @@ namespace OpenSim.Region.ClientStack
2997 case PacketType.PurgeInventoryDescendents: 3018 case PacketType.PurgeInventoryDescendents:
2998 if (OnPurgeInventoryDescendents != null) 3019 if (OnPurgeInventoryDescendents != null)
2999 { 3020 {
3000 PurgeInventoryDescendentsPacket Purge = (PurgeInventoryDescendentsPacket)Pack; 3021 PurgeInventoryDescendentsPacket Purge = (PurgeInventoryDescendentsPacket) Pack;
3001 OnPurgeInventoryDescendents(this, Purge.InventoryData.FolderID); 3022 OnPurgeInventoryDescendents(this, Purge.InventoryData.FolderID);
3002 } 3023 }
3003 break; 3024 break;
@@ -3007,11 +3028,11 @@ namespace OpenSim.Region.ClientStack
3007 { 3028 {
3008 for (int i = 0; i < update.InventoryData.Length; i++) 3029 for (int i = 0; i < update.InventoryData.Length; i++)
3009 { 3030 {
3010 OnUpdateInventoryItem(this, update.InventoryData[i].TransactionID, 3031 OnUpdateInventoryItem(this, update.InventoryData[i].TransactionID,
3011 update.InventoryData[i].ItemID, 3032 update.InventoryData[i].ItemID,
3012 Util.FieldToString(update.InventoryData[i].Name), 3033 Util.FieldToString(update.InventoryData[i].Name),
3013 Util.FieldToString(update.InventoryData[i].Description), 3034 Util.FieldToString(update.InventoryData[i].Description),
3014 update.InventoryData[i].NextOwnerMask); 3035 update.InventoryData[i].NextOwnerMask);
3015 } 3036 }
3016 } 3037 }
3017 //Console.WriteLine(Pack.ToString()); 3038 //Console.WriteLine(Pack.ToString());
@@ -3051,17 +3072,20 @@ namespace OpenSim.Region.ClientStack
3051 { 3072 {
3052 foreach (CopyInventoryItemPacket.InventoryDataBlock datablock in copyitem.InventoryData) 3073 foreach (CopyInventoryItemPacket.InventoryDataBlock datablock in copyitem.InventoryData)
3053 { 3074 {
3054 OnCopyInventoryItem(this, datablock.CallbackID, datablock.OldAgentID, datablock.OldItemID, datablock.NewFolderID, Util.FieldToString(datablock.NewName)); 3075 OnCopyInventoryItem(this, datablock.CallbackID, datablock.OldAgentID,
3076 datablock.OldItemID, datablock.NewFolderID,
3077 Util.FieldToString(datablock.NewName));
3055 } 3078 }
3056 } 3079 }
3057 break; 3080 break;
3058 case PacketType.MoveInventoryItem: 3081 case PacketType.MoveInventoryItem:
3059 MoveInventoryItemPacket moveitem = (MoveInventoryItemPacket)Pack; 3082 MoveInventoryItemPacket moveitem = (MoveInventoryItemPacket) Pack;
3060 if (OnMoveInventoryItem != null) 3083 if (OnMoveInventoryItem != null)
3061 { 3084 {
3062 foreach (MoveInventoryItemPacket.InventoryDataBlock datablock in moveitem.InventoryData) 3085 foreach (MoveInventoryItemPacket.InventoryDataBlock datablock in moveitem.InventoryData)
3063 { 3086 {
3064 OnMoveInventoryItem(this, datablock.FolderID, datablock.ItemID, datablock.Length, Util.FieldToString(datablock.NewName)); 3087 OnMoveInventoryItem(this, datablock.FolderID, datablock.ItemID, datablock.Length,
3088 Util.FieldToString(datablock.NewName));
3065 } 3089 }
3066 } 3090 }
3067 break; 3091 break;
@@ -3115,7 +3139,7 @@ namespace OpenSim.Region.ClientStack
3115 case PacketType.MapNameRequest: 3139 case PacketType.MapNameRequest:
3116 MapNameRequestPacket map = (MapNameRequestPacket) Pack; 3140 MapNameRequestPacket map = (MapNameRequestPacket) Pack;
3117 string mapName = UTF8Encoding.UTF8.GetString(map.NameData.Name, 0, 3141 string mapName = UTF8Encoding.UTF8.GetString(map.NameData.Name, 0,
3118 map.NameData.Name.Length - 1); 3142 map.NameData.Name.Length - 1);
3119 if (OnMapNameRequest != null) 3143 if (OnMapNameRequest != null)
3120 { 3144 {
3121 OnMapNameRequest(this, mapName); 3145 OnMapNameRequest(this, mapName);
@@ -3202,29 +3226,34 @@ namespace OpenSim.Region.ClientStack
3202 break; 3226 break;
3203 3227
3204 #region Parcel related packets 3228 #region Parcel related packets
3229
3205 case PacketType.ParcelAccessListRequest: 3230 case PacketType.ParcelAccessListRequest:
3206 ParcelAccessListRequestPacket requestPacket = (ParcelAccessListRequestPacket)Pack; 3231 ParcelAccessListRequestPacket requestPacket = (ParcelAccessListRequestPacket) Pack;
3207 if (OnParcelAccessListRequest != null) 3232 if (OnParcelAccessListRequest != null)
3208 { 3233 {
3209 OnParcelAccessListRequest(requestPacket.AgentData.AgentID, requestPacket.AgentData.SessionID, requestPacket.Data.Flags, requestPacket.Data.SequenceID, requestPacket.Data.LocalID,this); 3234 OnParcelAccessListRequest(requestPacket.AgentData.AgentID, requestPacket.AgentData.SessionID,
3235 requestPacket.Data.Flags, requestPacket.Data.SequenceID,
3236 requestPacket.Data.LocalID, this);
3210 } 3237 }
3211 break; 3238 break;
3212 3239
3213 case PacketType.ParcelAccessListUpdate: 3240 case PacketType.ParcelAccessListUpdate:
3214 ParcelAccessListUpdatePacket updatePacket = (ParcelAccessListUpdatePacket)Pack; 3241 ParcelAccessListUpdatePacket updatePacket = (ParcelAccessListUpdatePacket) Pack;
3215 List<ParcelManager.ParcelAccessEntry> entries = new List<ParcelManager.ParcelAccessEntry>(); 3242 List<ParcelManager.ParcelAccessEntry> entries = new List<ParcelManager.ParcelAccessEntry>();
3216 foreach (ParcelAccessListUpdatePacket.ListBlock block in updatePacket.List) 3243 foreach (ParcelAccessListUpdatePacket.ListBlock block in updatePacket.List)
3217 { 3244 {
3218 ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry(); 3245 ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry();
3219 entry.AgentID = block.ID; 3246 entry.AgentID = block.ID;
3220 entry.Flags = (ParcelManager.AccessList)block.Flags; 3247 entry.Flags = (ParcelManager.AccessList) block.Flags;
3221 entry.Time = new DateTime(); 3248 entry.Time = new DateTime();
3222 entries.Add(entry); 3249 entries.Add(entry);
3223 } 3250 }
3224 3251
3225 if (OnParcelAccessListUpdateRequest != null) 3252 if (OnParcelAccessListUpdateRequest != null)
3226 { 3253 {
3227 OnParcelAccessListUpdateRequest(updatePacket.AgentData.AgentID, updatePacket.AgentData.SessionID, updatePacket.Data.Flags, updatePacket.Data.LocalID, entries, this); 3254 OnParcelAccessListUpdateRequest(updatePacket.AgentData.AgentID,
3255 updatePacket.AgentData.SessionID, updatePacket.Data.Flags,
3256 updatePacket.Data.LocalID, entries, this);
3228 } 3257 }
3229 break; 3258 break;
3230 case PacketType.ParcelPropertiesRequest: 3259 case PacketType.ParcelPropertiesRequest:
@@ -3296,28 +3325,30 @@ namespace OpenSim.Region.ClientStack
3296 } 3325 }
3297 break; 3326 break;
3298 case PacketType.RequestRegionInfo: 3327 case PacketType.RequestRegionInfo:
3299 RequestRegionInfoPacket.AgentDataBlock mPacket = ((RequestRegionInfoPacket)Pack).AgentData; 3328 RequestRegionInfoPacket.AgentDataBlock mPacket = ((RequestRegionInfoPacket) Pack).AgentData;
3300 if (OnRegionInfoRequest != null) 3329 if (OnRegionInfoRequest != null)
3301 { 3330 {
3302 OnRegionInfoRequest(this, mPacket.SessionID); 3331 OnRegionInfoRequest(this, mPacket.SessionID);
3303 } 3332 }
3304 break; 3333 break;
3305 case PacketType.EstateCovenantRequest: 3334 case PacketType.EstateCovenantRequest:
3306 // TODO: handle this packet 3335 // TODO: handle this packet
3307 EstateCovenantRequestPacket.AgentDataBlock epack = ((EstateCovenantRequestPacket)Pack).AgentData; 3336 EstateCovenantRequestPacket.AgentDataBlock epack =
3337 ((EstateCovenantRequestPacket) Pack).AgentData;
3308 if (OnEstateCovenantRequest != null) 3338 if (OnEstateCovenantRequest != null)
3309 { 3339 {
3310 OnEstateCovenantRequest(this, epack.SessionID); 3340 OnEstateCovenantRequest(this, epack.SessionID);
3311 } 3341 }
3312 break; 3342 break;
3313 case PacketType.AgentThrottle: 3343 case PacketType.AgentThrottle:
3314 AgentThrottlePacket atpack = (AgentThrottlePacket)Pack; 3344 AgentThrottlePacket atpack = (AgentThrottlePacket) Pack;
3315 m_packetQueue.SetThrottleFromClient(atpack.Throttle.Throttles); 3345 m_packetQueue.SetThrottleFromClient(atpack.Throttle.Throttles);
3316 break; 3346 break;
3317 3347
3318 #endregion 3348 #endregion
3319 3349
3320 #region unimplemented handlers 3350 #region unimplemented handlers
3351
3321 case PacketType.RequestGodlikePowers: 3352 case PacketType.RequestGodlikePowers:
3322 RequestGodlikePowersPacket rglpPack = (RequestGodlikePowersPacket) Pack; 3353 RequestGodlikePowersPacket rglpPack = (RequestGodlikePowersPacket) Pack;
3323 RequestGodlikePowersPacket.RequestBlockBlock rblock = rglpPack.RequestBlock; 3354 RequestGodlikePowersPacket.RequestBlockBlock rblock = rglpPack.RequestBlock;
@@ -3325,16 +3356,17 @@ namespace OpenSim.Region.ClientStack
3325 RequestGodlikePowersPacket.AgentDataBlock ablock = rglpPack.AgentData; 3356 RequestGodlikePowersPacket.AgentDataBlock ablock = rglpPack.AgentData;
3326 3357
3327 OnRequestGodlikePowers(ablock.AgentID, ablock.SessionID, token, this); 3358 OnRequestGodlikePowers(ablock.AgentID, ablock.SessionID, token, this);
3328 3359
3329 break; 3360 break;
3330 case PacketType.GodKickUser: 3361 case PacketType.GodKickUser:
3331 MainLog.Instance.Warn("CLIENT", "unhandled GodKickUser packet"); 3362 MainLog.Instance.Warn("CLIENT", "unhandled GodKickUser packet");
3332 3363
3333 GodKickUserPacket gkupack = (GodKickUserPacket) Pack; 3364 GodKickUserPacket gkupack = (GodKickUserPacket) Pack;
3334 3365
3335 if (gkupack.UserInfo.GodSessionID == SessionId && this.AgentId == gkupack.UserInfo.GodID) 3366 if (gkupack.UserInfo.GodSessionID == SessionId && AgentId == gkupack.UserInfo.GodID)
3336 { 3367 {
3337 OnGodKickUser(gkupack.UserInfo.GodID, gkupack.UserInfo.GodSessionID, gkupack.UserInfo.AgentID, (uint) 0, gkupack.UserInfo.Reason); 3368 OnGodKickUser(gkupack.UserInfo.GodID, gkupack.UserInfo.GodSessionID,
3369 gkupack.UserInfo.AgentID, (uint) 0, gkupack.UserInfo.Reason);
3338 } 3370 }
3339 else 3371 else
3340 { 3372 {
@@ -3404,7 +3436,7 @@ namespace OpenSim.Region.ClientStack
3404 // TODO: handle this packet 3436 // TODO: handle this packet
3405 MainLog.Instance.Warn("CLIENT", "unhandled AgentDataUpdateRequest packet"); 3437 MainLog.Instance.Warn("CLIENT", "unhandled AgentDataUpdateRequest packet");
3406 break; 3438 break;
3407 3439
3408 case PacketType.ParcelDwellRequest: 3440 case PacketType.ParcelDwellRequest:
3409 // TODO: handle this packet 3441 // TODO: handle this packet
3410 MainLog.Instance.Warn("CLIENT", "unhandled ParcelDwellRequest packet"); 3442 MainLog.Instance.Warn("CLIENT", "unhandled ParcelDwellRequest packet");
@@ -3440,7 +3472,7 @@ namespace OpenSim.Region.ClientStack
3440 default: 3472 default:
3441 MainLog.Instance.Warn("CLIENT", "unhandled packet " + Pack.ToString()); 3473 MainLog.Instance.Warn("CLIENT", "unhandled packet " + Pack.ToString());
3442 break; 3474 break;
3443 3475
3444 #endregion 3476 #endregion
3445 } 3477 }
3446 } 3478 }
@@ -3490,4 +3522,4 @@ namespace OpenSim.Region.ClientStack
3490 OutPacket(logReply, ThrottleOutPacketType.Task); 3522 OutPacket(logReply, ThrottleOutPacketType.Task);
3491 } 3523 }
3492 } 3524 }
3493} 3525} \ No newline at end of file
diff --git a/OpenSim/Region/ClientStack/PacketQueue.cs b/OpenSim/Region/ClientStack/PacketQueue.cs
index 4c9295e..1065f63 100644
--- a/OpenSim/Region/ClientStack/PacketQueue.cs
+++ b/OpenSim/Region/ClientStack/PacketQueue.cs
@@ -27,17 +27,10 @@
27*/ 27*/
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Net;
31using System.Net.Sockets;
32using System.Text;
33using System.Threading; 30using System.Threading;
34using System.Timers; 31using System.Timers;
35using Axiom.Math;
36using libsecondlife;
37using libsecondlife.Packets; 32using libsecondlife.Packets;
38using OpenSim.Framework; 33using OpenSim.Framework;
39using OpenSim.Framework.Communications.Cache;
40using OpenSim.Framework.Console;
41using Timer=System.Timers.Timer; 34using Timer=System.Timers.Timer;
42 35
43namespace OpenSim.Region.ClientStack 36namespace OpenSim.Region.ClientStack
@@ -47,7 +40,7 @@ namespace OpenSim.Region.ClientStack
47 private bool m_enabled = true; 40 private bool m_enabled = true;
48 41
49 private BlockingQueue<QueItem> SendQueue; 42 private BlockingQueue<QueItem> SendQueue;
50 43
51 private Queue<QueItem> IncomingPacketQueue; 44 private Queue<QueItem> IncomingPacketQueue;
52 private Queue<QueItem> OutgoingPacketQueue; 45 private Queue<QueItem> OutgoingPacketQueue;
53 private Queue<QueItem> ResendOutgoingPacketQueue; 46 private Queue<QueItem> ResendOutgoingPacketQueue;
@@ -57,7 +50,7 @@ namespace OpenSim.Region.ClientStack
57 private Queue<QueItem> TaskOutgoingPacketQueue; 50 private Queue<QueItem> TaskOutgoingPacketQueue;
58 private Queue<QueItem> TextureOutgoingPacketQueue; 51 private Queue<QueItem> TextureOutgoingPacketQueue;
59 private Queue<QueItem> AssetOutgoingPacketQueue; 52 private Queue<QueItem> AssetOutgoingPacketQueue;
60 53
61 private Dictionary<uint, uint> PendingAcks = new Dictionary<uint, uint>(); 54 private Dictionary<uint, uint> PendingAcks = new Dictionary<uint, uint>();
62 private Dictionary<uint, Packet> NeedAck = new Dictionary<uint, Packet>(); 55 private Dictionary<uint, Packet> NeedAck = new Dictionary<uint, Packet>();
63 56
@@ -82,15 +75,15 @@ namespace OpenSim.Region.ClientStack
82 // private long ThrottleInterval; 75 // private long ThrottleInterval;
83 private Timer throttleTimer; 76 private Timer throttleTimer;
84 77
85 public PacketQueue() 78 public PacketQueue()
86 { 79 {
87 // While working on this, the BlockingQueue had me fooled for a bit. 80 // While working on this, the BlockingQueue had me fooled for a bit.
88 // The Blocking queue causes the thread to stop until there's something 81 // The Blocking queue causes the thread to stop until there's something
89 // in it to process. it's an on-purpose threadlock though because 82 // in it to process. it's an on-purpose threadlock though because
90 // without it, the clientloop will suck up all sim resources. 83 // without it, the clientloop will suck up all sim resources.
91 84
92 SendQueue = new BlockingQueue<QueItem>(); 85 SendQueue = new BlockingQueue<QueItem>();
93 86
94 IncomingPacketQueue = new Queue<QueItem>(); 87 IncomingPacketQueue = new Queue<QueItem>();
95 OutgoingPacketQueue = new Queue<QueItem>(); 88 OutgoingPacketQueue = new Queue<QueItem>();
96 ResendOutgoingPacketQueue = new Queue<QueItem>(); 89 ResendOutgoingPacketQueue = new Queue<QueItem>();
@@ -100,7 +93,7 @@ namespace OpenSim.Region.ClientStack
100 TaskOutgoingPacketQueue = new Queue<QueItem>(); 93 TaskOutgoingPacketQueue = new Queue<QueItem>();
101 TextureOutgoingPacketQueue = new Queue<QueItem>(); 94 TextureOutgoingPacketQueue = new Queue<QueItem>();
102 AssetOutgoingPacketQueue = new Queue<QueItem>(); 95 AssetOutgoingPacketQueue = new Queue<QueItem>();
103 96
104 97
105 // Set up the throttle classes (min, max, current) in bytes 98 // Set up the throttle classes (min, max, current) in bytes
106 ResendThrottle = new PacketThrottle(5000, 100000, 50000); 99 ResendThrottle = new PacketThrottle(5000, 100000, 50000);
@@ -114,14 +107,13 @@ namespace OpenSim.Region.ClientStack
114 // Number of bytes allowed to go out per second. (256kbps per client) 107 // Number of bytes allowed to go out per second. (256kbps per client)
115 TotalThrottle = new PacketThrottle(0, 162144, 1536000); 108 TotalThrottle = new PacketThrottle(0, 162144, 1536000);
116 109
117 throttleTimer = new Timer((int)(throttletimems/throttleTimeDivisor)); 110 throttleTimer = new Timer((int) (throttletimems/throttleTimeDivisor));
118 throttleTimer.Elapsed += new ElapsedEventHandler(ThrottleTimerElapsed); 111 throttleTimer.Elapsed += new ElapsedEventHandler(ThrottleTimerElapsed);
119 throttleTimer.Start(); 112 throttleTimer.Start();
120 113
121 // TIMERS needed for this 114 // TIMERS needed for this
122 // LastThrottle = DateTime.Now.Ticks; 115 // LastThrottle = DateTime.Now.Ticks;
123 // ThrottleInterval = (long)(throttletimems/throttleTimeDivisor); 116 // ThrottleInterval = (long)(throttletimems/throttleTimeDivisor);
124
125 } 117 }
126 118
127 /* STANDARD QUEUE MANIPULATION INTERFACES */ 119 /* STANDARD QUEUE MANIPULATION INTERFACES */
@@ -129,44 +121,48 @@ namespace OpenSim.Region.ClientStack
129 121
130 public void Enqueue(QueItem item) 122 public void Enqueue(QueItem item)
131 { 123 {
132 if (!m_enabled) {return;} 124 if (!m_enabled)
125 {
126 return;
127 }
133 // We could micro lock, but that will tend to actually 128 // We could micro lock, but that will tend to actually
134 // probably be worse than just synchronizing on SendQueue 129 // probably be worse than just synchronizing on SendQueue
135 130
136 lock (this) { 131 lock (this)
132 {
137 switch (item.throttleType) 133 switch (item.throttleType)
138 { 134 {
139 case ThrottleOutPacketType.Resend: 135 case ThrottleOutPacketType.Resend:
140 ThrottleCheck(ref ResendThrottle, ref ResendOutgoingPacketQueue, item); 136 ThrottleCheck(ref ResendThrottle, ref ResendOutgoingPacketQueue, item);
141 break; 137 break;
142 case ThrottleOutPacketType.Texture: 138 case ThrottleOutPacketType.Texture:
143 ThrottleCheck(ref TextureThrottle, ref TextureOutgoingPacketQueue, item); 139 ThrottleCheck(ref TextureThrottle, ref TextureOutgoingPacketQueue, item);
144 break; 140 break;
145 case ThrottleOutPacketType.Task: 141 case ThrottleOutPacketType.Task:
146 ThrottleCheck(ref TaskThrottle, ref TaskOutgoingPacketQueue, item); 142 ThrottleCheck(ref TaskThrottle, ref TaskOutgoingPacketQueue, item);
147 break; 143 break;
148 case ThrottleOutPacketType.Land: 144 case ThrottleOutPacketType.Land:
149 ThrottleCheck(ref LandThrottle, ref LandOutgoingPacketQueue, item); 145 ThrottleCheck(ref LandThrottle, ref LandOutgoingPacketQueue, item);
150 break; 146 break;
151 case ThrottleOutPacketType.Asset: 147 case ThrottleOutPacketType.Asset:
152 ThrottleCheck(ref AssetThrottle, ref AssetOutgoingPacketQueue, item); 148 ThrottleCheck(ref AssetThrottle, ref AssetOutgoingPacketQueue, item);
153 break; 149 break;
154 case ThrottleOutPacketType.Cloud: 150 case ThrottleOutPacketType.Cloud:
155 ThrottleCheck(ref CloudThrottle, ref CloudOutgoingPacketQueue, item); 151 ThrottleCheck(ref CloudThrottle, ref CloudOutgoingPacketQueue, item);
156 break; 152 break;
157 case ThrottleOutPacketType.Wind: 153 case ThrottleOutPacketType.Wind:
158 ThrottleCheck(ref WindThrottle, ref WindOutgoingPacketQueue, item); 154 ThrottleCheck(ref WindThrottle, ref WindOutgoingPacketQueue, item);
159 break; 155 break;
160 156
161 default: 157 default:
162 // Acknowledgements and other such stuff should go directly to the blocking Queue 158 // Acknowledgements and other such stuff should go directly to the blocking Queue
163 // Throttling them may and likely 'will' be problematic 159 // Throttling them may and likely 'will' be problematic
164 SendQueue.Enqueue(item); 160 SendQueue.Enqueue(item);
165 break; 161 break;
166 } 162 }
167 } 163 }
168 } 164 }
169 165
170 public QueItem Dequeue() 166 public QueItem Dequeue()
171 { 167 {
172 return SendQueue.Dequeue(); 168 return SendQueue.Dequeue();
@@ -174,7 +170,8 @@ namespace OpenSim.Region.ClientStack
174 170
175 public void Flush() 171 public void Flush()
176 { 172 {
177 lock(this) { 173 lock (this)
174 {
178 while (PacketsWaiting()) 175 while (PacketsWaiting())
179 { 176 {
180 //Now comes the fun part.. we dump all our elements into m_packetQueue that we've saved up. 177 //Now comes the fun part.. we dump all our elements into m_packetQueue that we've saved up.
@@ -211,7 +208,7 @@ namespace OpenSim.Region.ClientStack
211 } 208 }
212 } 209 }
213 210
214 public void Close() 211 public void Close()
215 { 212 {
216 m_enabled = false; 213 m_enabled = false;
217 throttleTimer.Stop(); 214 throttleTimer.Stop();
@@ -242,22 +239,22 @@ namespace OpenSim.Region.ClientStack
242 239
243 public void ProcessThrottle() 240 public void ProcessThrottle()
244 { 241 {
245
246 // I was considering this.. Will an event fire if the thread it's on is blocked? 242 // I was considering this.. Will an event fire if the thread it's on is blocked?
247 243
248 // Then I figured out.. it doesn't really matter.. because this thread won't be blocked for long 244 // Then I figured out.. it doesn't really matter.. because this thread won't be blocked for long
249 // The General overhead of the UDP protocol gets sent to the queue un-throttled by this 245 // The General overhead of the UDP protocol gets sent to the queue un-throttled by this
250 // so This'll pick up about around the right time. 246 // so This'll pick up about around the right time.
251 247
252 int MaxThrottleLoops = 4550; // 50*7 packets can be dequeued at once. 248 int MaxThrottleLoops = 4550; // 50*7 packets can be dequeued at once.
253 int throttleLoops = 0; 249 int throttleLoops = 0;
254 250
255 // We're going to dequeue all of the saved up packets until 251 // We're going to dequeue all of the saved up packets until
256 // we've hit the throttle limit or there's no more packets to send 252 // we've hit the throttle limit or there's no more packets to send
257 lock (this) { 253 lock (this)
254 {
258 ResetCounters(); 255 ResetCounters();
259 // MainLog.Instance.Verbose("THROTTLE", "Entering Throttle"); 256 // MainLog.Instance.Verbose("THROTTLE", "Entering Throttle");
260 while (TotalThrottle.UnderLimit() && PacketsWaiting() && 257 while (TotalThrottle.UnderLimit() && PacketsWaiting() &&
261 (throttleLoops <= MaxThrottleLoops)) 258 (throttleLoops <= MaxThrottleLoops))
262 { 259 {
263 throttleLoops++; 260 throttleLoops++;
@@ -265,7 +262,7 @@ namespace OpenSim.Region.ClientStack
265 if (ResendThrottle.UnderLimit() && ResendOutgoingPacketQueue.Count > 0) 262 if (ResendThrottle.UnderLimit() && ResendOutgoingPacketQueue.Count > 0)
266 { 263 {
267 QueItem qpack = ResendOutgoingPacketQueue.Dequeue(); 264 QueItem qpack = ResendOutgoingPacketQueue.Dequeue();
268 265
269 SendQueue.Enqueue(qpack); 266 SendQueue.Enqueue(qpack);
270 TotalThrottle.Add(qpack.Packet.ToBytes().Length); 267 TotalThrottle.Add(qpack.Packet.ToBytes().Length);
271 ResendThrottle.Add(qpack.Packet.ToBytes().Length); 268 ResendThrottle.Add(qpack.Packet.ToBytes().Length);
@@ -273,7 +270,7 @@ namespace OpenSim.Region.ClientStack
273 if (LandThrottle.UnderLimit() && LandOutgoingPacketQueue.Count > 0) 270 if (LandThrottle.UnderLimit() && LandOutgoingPacketQueue.Count > 0)
274 { 271 {
275 QueItem qpack = LandOutgoingPacketQueue.Dequeue(); 272 QueItem qpack = LandOutgoingPacketQueue.Dequeue();
276 273
277 SendQueue.Enqueue(qpack); 274 SendQueue.Enqueue(qpack);
278 TotalThrottle.Add(qpack.Packet.ToBytes().Length); 275 TotalThrottle.Add(qpack.Packet.ToBytes().Length);
279 LandThrottle.Add(qpack.Packet.ToBytes().Length); 276 LandThrottle.Add(qpack.Packet.ToBytes().Length);
@@ -281,7 +278,7 @@ namespace OpenSim.Region.ClientStack
281 if (WindThrottle.UnderLimit() && WindOutgoingPacketQueue.Count > 0) 278 if (WindThrottle.UnderLimit() && WindOutgoingPacketQueue.Count > 0)
282 { 279 {
283 QueItem qpack = WindOutgoingPacketQueue.Dequeue(); 280 QueItem qpack = WindOutgoingPacketQueue.Dequeue();
284 281
285 SendQueue.Enqueue(qpack); 282 SendQueue.Enqueue(qpack);
286 TotalThrottle.Add(qpack.Packet.ToBytes().Length); 283 TotalThrottle.Add(qpack.Packet.ToBytes().Length);
287 WindThrottle.Add(qpack.Packet.ToBytes().Length); 284 WindThrottle.Add(qpack.Packet.ToBytes().Length);
@@ -289,7 +286,7 @@ namespace OpenSim.Region.ClientStack
289 if (CloudThrottle.UnderLimit() && CloudOutgoingPacketQueue.Count > 0) 286 if (CloudThrottle.UnderLimit() && CloudOutgoingPacketQueue.Count > 0)
290 { 287 {
291 QueItem qpack = CloudOutgoingPacketQueue.Dequeue(); 288 QueItem qpack = CloudOutgoingPacketQueue.Dequeue();
292 289
293 SendQueue.Enqueue(qpack); 290 SendQueue.Enqueue(qpack);
294 TotalThrottle.Add(qpack.Packet.ToBytes().Length); 291 TotalThrottle.Add(qpack.Packet.ToBytes().Length);
295 CloudThrottle.Add(qpack.Packet.ToBytes().Length); 292 CloudThrottle.Add(qpack.Packet.ToBytes().Length);
@@ -297,7 +294,7 @@ namespace OpenSim.Region.ClientStack
297 if (TaskThrottle.UnderLimit() && TaskOutgoingPacketQueue.Count > 0) 294 if (TaskThrottle.UnderLimit() && TaskOutgoingPacketQueue.Count > 0)
298 { 295 {
299 QueItem qpack = TaskOutgoingPacketQueue.Dequeue(); 296 QueItem qpack = TaskOutgoingPacketQueue.Dequeue();
300 297
301 SendQueue.Enqueue(qpack); 298 SendQueue.Enqueue(qpack);
302 TotalThrottle.Add(qpack.Packet.ToBytes().Length); 299 TotalThrottle.Add(qpack.Packet.ToBytes().Length);
303 TaskThrottle.Add(qpack.Packet.ToBytes().Length); 300 TaskThrottle.Add(qpack.Packet.ToBytes().Length);
@@ -305,7 +302,7 @@ namespace OpenSim.Region.ClientStack
305 if (TextureThrottle.UnderLimit() && TextureOutgoingPacketQueue.Count > 0) 302 if (TextureThrottle.UnderLimit() && TextureOutgoingPacketQueue.Count > 0)
306 { 303 {
307 QueItem qpack = TextureOutgoingPacketQueue.Dequeue(); 304 QueItem qpack = TextureOutgoingPacketQueue.Dequeue();
308 305
309 SendQueue.Enqueue(qpack); 306 SendQueue.Enqueue(qpack);
310 TotalThrottle.Add(qpack.Packet.ToBytes().Length); 307 TotalThrottle.Add(qpack.Packet.ToBytes().Length);
311 TextureThrottle.Add(qpack.Packet.ToBytes().Length); 308 TextureThrottle.Add(qpack.Packet.ToBytes().Length);
@@ -313,19 +310,18 @@ namespace OpenSim.Region.ClientStack
313 if (AssetThrottle.UnderLimit() && AssetOutgoingPacketQueue.Count > 0) 310 if (AssetThrottle.UnderLimit() && AssetOutgoingPacketQueue.Count > 0)
314 { 311 {
315 QueItem qpack = AssetOutgoingPacketQueue.Dequeue(); 312 QueItem qpack = AssetOutgoingPacketQueue.Dequeue();
316 313
317 SendQueue.Enqueue(qpack); 314 SendQueue.Enqueue(qpack);
318 TotalThrottle.Add(qpack.Packet.ToBytes().Length); 315 TotalThrottle.Add(qpack.Packet.ToBytes().Length);
319 AssetThrottle.Add(qpack.Packet.ToBytes().Length); 316 AssetThrottle.Add(qpack.Packet.ToBytes().Length);
320 } 317 }
321 } 318 }
322 // MainLog.Instance.Verbose("THROTTLE", "Processed " + throttleLoops + " packets"); 319 // MainLog.Instance.Verbose("THROTTLE", "Processed " + throttleLoops + " packets");
323
324 } 320 }
325 } 321 }
326 322
327 private void ThrottleTimerElapsed(object sender, ElapsedEventArgs e) 323 private void ThrottleTimerElapsed(object sender, ElapsedEventArgs e)
328 { 324 {
329 // just to change the signature, and that ProcessThrottle 325 // just to change the signature, and that ProcessThrottle
330 // will be used elsewhere possibly 326 // will be used elsewhere possibly
331 ProcessThrottle(); 327 ProcessThrottle();
@@ -339,7 +335,7 @@ namespace OpenSim.Region.ClientStack
339 // wait for the timer to fire to put things into the 335 // wait for the timer to fire to put things into the
340 // output queue 336 // output queue
341 337
342 if((q.Count == 0) && (throttle.UnderLimit())) 338 if ((q.Count == 0) && (throttle.UnderLimit()))
343 { 339 {
344 Monitor.Enter(this); 340 Monitor.Enter(this);
345 throttle.Add(item.Packet.ToBytes().Length); 341 throttle.Add(item.Packet.ToBytes().Length);
@@ -357,31 +353,39 @@ namespace OpenSim.Region.ClientStack
357 353
358 private int ScaleThrottle(int value, int curmax, int newmax) 354 private int ScaleThrottle(int value, int curmax, int newmax)
359 { 355 {
360 return (int)(((float)value/(float)curmax) * newmax); 356 return (int) (((float) value/(float) curmax)*newmax);
361 } 357 }
358
362 private byte[] GetThrottlesPacked(float multiplier) 359 private byte[] GetThrottlesPacked(float multiplier)
363 { 360 {
364 int singlefloat = 4; 361 int singlefloat = 4;
365 float tResend = ResendThrottle.Throttle * multiplier; 362 float tResend = ResendThrottle.Throttle*multiplier;
366 float tLand = LandThrottle.Throttle * multiplier; 363 float tLand = LandThrottle.Throttle*multiplier;
367 float tWind = WindThrottle.Throttle * multiplier; 364 float tWind = WindThrottle.Throttle*multiplier;
368 float tCloud = CloudThrottle.Throttle * multiplier; 365 float tCloud = CloudThrottle.Throttle*multiplier;
369 float tTask = TaskThrottle.Throttle * multiplier; 366 float tTask = TaskThrottle.Throttle*multiplier;
370 float tTexture = TextureThrottle.Throttle * multiplier; 367 float tTexture = TextureThrottle.Throttle*multiplier;
371 float tAsset = AssetThrottle.Throttle * multiplier; 368 float tAsset = AssetThrottle.Throttle*multiplier;
372 369
373 byte[] throttles = new byte[singlefloat * 7]; 370 byte[] throttles = new byte[singlefloat*7];
374 int i = 0; 371 int i = 0;
375 Buffer.BlockCopy(BitConverter.GetBytes(tResend), 0, throttles, singlefloat * i, singlefloat); i++; 372 Buffer.BlockCopy(BitConverter.GetBytes(tResend), 0, throttles, singlefloat*i, singlefloat);
376 Buffer.BlockCopy(BitConverter.GetBytes(tLand), 0, throttles, singlefloat * i, singlefloat); i++; 373 i++;
377 Buffer.BlockCopy(BitConverter.GetBytes(tWind), 0, throttles, singlefloat * i, singlefloat); i++; 374 Buffer.BlockCopy(BitConverter.GetBytes(tLand), 0, throttles, singlefloat*i, singlefloat);
378 Buffer.BlockCopy(BitConverter.GetBytes(tCloud), 0, throttles, singlefloat * i, singlefloat); i++; 375 i++;
379 Buffer.BlockCopy(BitConverter.GetBytes(tTask), 0, throttles, singlefloat * i, singlefloat); i++; 376 Buffer.BlockCopy(BitConverter.GetBytes(tWind), 0, throttles, singlefloat*i, singlefloat);
380 Buffer.BlockCopy(BitConverter.GetBytes(tTexture), 0, throttles, singlefloat * i, singlefloat); i++; 377 i++;
381 Buffer.BlockCopy(BitConverter.GetBytes(tAsset), 0, throttles, singlefloat * i, singlefloat); 378 Buffer.BlockCopy(BitConverter.GetBytes(tCloud), 0, throttles, singlefloat*i, singlefloat);
379 i++;
380 Buffer.BlockCopy(BitConverter.GetBytes(tTask), 0, throttles, singlefloat*i, singlefloat);
381 i++;
382 Buffer.BlockCopy(BitConverter.GetBytes(tTexture), 0, throttles, singlefloat*i, singlefloat);
383 i++;
384 Buffer.BlockCopy(BitConverter.GetBytes(tAsset), 0, throttles, singlefloat*i, singlefloat);
382 385
383 return throttles; 386 return throttles;
384 } 387 }
388
385 public void SetThrottleFromClient(byte[] throttle) 389 public void SetThrottleFromClient(byte[] throttle)
386 { 390 {
387 int tResend = -1; 391 int tResend = -1;
@@ -401,25 +405,25 @@ namespace OpenSim.Region.ClientStack
401 // it might be smart to do this check more often... 405 // it might be smart to do this check more often...
402 if (!BitConverter.IsLittleEndian) 406 if (!BitConverter.IsLittleEndian)
403 for (int i = 0; i < 7; i++) 407 for (int i = 0; i < 7; i++)
404 Array.Reverse(throttle, j + i * singlefloat, singlefloat); 408 Array.Reverse(throttle, j + i*singlefloat, singlefloat);
405 409
406 // values gotten from libsecondlife.org/wiki/Throttle. Thanks MW_ 410 // values gotten from libsecondlife.org/wiki/Throttle. Thanks MW_
407 // bytes 411 // bytes
408 // Convert to integer, since.. the full fp space isn't used. 412 // Convert to integer, since.. the full fp space isn't used.
409 tResend = (int)BitConverter.ToSingle(throttle, j); 413 tResend = (int) BitConverter.ToSingle(throttle, j);
410 j += singlefloat; 414 j += singlefloat;
411 tLand = (int)BitConverter.ToSingle(throttle, j); 415 tLand = (int) BitConverter.ToSingle(throttle, j);
412 j += singlefloat; 416 j += singlefloat;
413 tWind = (int)BitConverter.ToSingle(throttle, j); 417 tWind = (int) BitConverter.ToSingle(throttle, j);
414 j += singlefloat; 418 j += singlefloat;
415 tCloud = (int)BitConverter.ToSingle(throttle, j); 419 tCloud = (int) BitConverter.ToSingle(throttle, j);
416 j += singlefloat; 420 j += singlefloat;
417 tTask = (int)BitConverter.ToSingle(throttle, j); 421 tTask = (int) BitConverter.ToSingle(throttle, j);
418 j += singlefloat; 422 j += singlefloat;
419 tTexture = (int)BitConverter.ToSingle(throttle, j); 423 tTexture = (int) BitConverter.ToSingle(throttle, j);
420 j += singlefloat; 424 j += singlefloat;
421 tAsset = (int)BitConverter.ToSingle(throttle, j); 425 tAsset = (int) BitConverter.ToSingle(throttle, j);
422 426
423 tall = tResend + tLand + tWind + tCloud + tTask + tTexture + tAsset; 427 tall = tResend + tLand + tWind + tCloud + tTask + tTexture + tAsset;
424 /* 428 /*
425 MainLog.Instance.Verbose("CLIENT", "Client AgentThrottle - Got throttle:resendbytes=" + tResend + 429 MainLog.Instance.Verbose("CLIENT", "Client AgentThrottle - Got throttle:resendbytes=" + tResend +
@@ -431,13 +435,13 @@ namespace OpenSim.Region.ClientStack
431 " Assetbytes=" + tAsset + 435 " Assetbytes=" + tAsset +
432 " Allbytes=" + tall); 436 " Allbytes=" + tall);
433 */ 437 */
434 438
435 // Total Sanity 439 // Total Sanity
436 // Make sure that the client sent sane total values. 440 // Make sure that the client sent sane total values.
437 441
438 // If the client didn't send acceptable values.... 442 // If the client didn't send acceptable values....
439 // Scale the clients values down until they are acceptable. 443 // Scale the clients values down until they are acceptable.
440 444
441 if (tall <= TotalThrottle.Max) 445 if (tall <= TotalThrottle.Max)
442 { 446 {
443 ResendThrottle.Throttle = tResend; 447 ResendThrottle.Throttle = tResend;
@@ -448,7 +452,7 @@ namespace OpenSim.Region.ClientStack
448 TextureThrottle.Throttle = tTexture; 452 TextureThrottle.Throttle = tTexture;
449 AssetThrottle.Throttle = tAsset; 453 AssetThrottle.Throttle = tAsset;
450 TotalThrottle.Throttle = tall; 454 TotalThrottle.Throttle = tall;
451 } 455 }
452 else if (tall < 1) 456 else if (tall < 1)
453 { 457 {
454 // client is stupid, penalize him by minning everything 458 // client is stupid, penalize him by minning everything
@@ -478,4 +482,4 @@ namespace OpenSim.Region.ClientStack
478 ResetCounters(); 482 ResetCounters();
479 } 483 }
480 } 484 }
481} 485} \ No newline at end of file
diff --git a/OpenSim/Region/ClientStack/PacketServer.cs b/OpenSim/Region/ClientStack/PacketServer.cs
index a232db8..7e01adf 100644
--- a/OpenSim/Region/ClientStack/PacketServer.cs
+++ b/OpenSim/Region/ClientStack/PacketServer.cs
@@ -68,10 +68,11 @@ namespace OpenSim.Region.ClientStack
68 68
69 protected virtual IClientAPI CreateNewClient(EndPoint remoteEP, UseCircuitCodePacket initialcirpack, 69 protected virtual IClientAPI CreateNewClient(EndPoint remoteEP, UseCircuitCodePacket initialcirpack,
70 ClientManager clientManager, IScene scene, AssetCache assetCache, 70 ClientManager clientManager, IScene scene, AssetCache assetCache,
71 PacketServer packServer, AgentCircuitManager authenSessions, LLUUID agentId, LLUUID sessionId, uint circuitCode) 71 PacketServer packServer, AgentCircuitManager authenSessions,
72 LLUUID agentId, LLUUID sessionId, uint circuitCode)
72 { 73 {
73 return 74 return
74 new ClientView(remoteEP, scene, assetCache, packServer, authenSessions, agentId, sessionId, circuitCode ); 75 new ClientView(remoteEP, scene, assetCache, packServer, authenSessions, agentId, sessionId, circuitCode);
75 } 76 }
76 77
77 public virtual bool AddNewClient(EndPoint epSender, UseCircuitCodePacket useCircuit, AssetCache assetCache, 78 public virtual bool AddNewClient(EndPoint epSender, UseCircuitCodePacket useCircuit, AssetCache assetCache,
@@ -86,7 +87,8 @@ namespace OpenSim.Region.ClientStack
86 else 87 else
87 { 88 {
88 newuser = CreateNewClient(epSender, useCircuit, m_scene.ClientManager, m_scene, assetCache, this, 89 newuser = CreateNewClient(epSender, useCircuit, m_scene.ClientManager, m_scene, assetCache, this,
89 authenticateSessionsClass, useCircuit.CircuitCode.ID, useCircuit.CircuitCode.SessionID, useCircuit.CircuitCode.Code); 90 authenticateSessionsClass, useCircuit.CircuitCode.ID,
91 useCircuit.CircuitCode.SessionID, useCircuit.CircuitCode.Code);
90 92
91 m_scene.ClientManager.Add(useCircuit.CircuitCode.Code, newuser); 93 m_scene.ClientManager.Add(useCircuit.CircuitCode.Code, newuser);
92 94
@@ -123,9 +125,8 @@ namespace OpenSim.Region.ClientStack
123 /// <param name="circuitcode"></param> 125 /// <param name="circuitcode"></param>
124 public virtual void CloseCircuit(uint circuitcode) 126 public virtual void CloseCircuit(uint circuitcode)
125 { 127 {
126
127 m_networkHandler.RemoveClientCircuit(circuitcode); 128 m_networkHandler.RemoveClientCircuit(circuitcode);
128 129
129 //m_scene.ClientManager.CloseAllAgents(circuitcode); 130 //m_scene.ClientManager.CloseAllAgents(circuitcode);
130 } 131 }
131 132
@@ -135,4 +136,4 @@ namespace OpenSim.Region.ClientStack
135 client.Close(false); 136 client.Close(false);
136 } 137 }
137 } 138 }
138} 139} \ No newline at end of file
diff --git a/OpenSim/Region/ClientStack/PacketThrottle.cs b/OpenSim/Region/ClientStack/PacketThrottle.cs
index f9a5c09..f56f4f8 100644
--- a/OpenSim/Region/ClientStack/PacketThrottle.cs
+++ b/OpenSim/Region/ClientStack/PacketThrottle.cs
@@ -25,26 +25,10 @@
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using System;
29using System.Collections.Generic;
30using System.Net;
31using System.Net.Sockets;
32using System.Text;
33using System.Threading;
34using System.Timers;
35using Axiom.Math;
36using libsecondlife;
37using libsecondlife.Packets;
38using OpenSim.Framework;
39using OpenSim.Framework.Communications.Cache;
40using OpenSim.Framework.Console;
41using Timer=System.Timers.Timer;
42
43namespace OpenSim.Region.ClientStack 28namespace OpenSim.Region.ClientStack
44{ 29{
45 public class PacketThrottle 30 public class PacketThrottle
46 { 31 {
47
48 private int max; // max allowable throttle 32 private int max; // max allowable throttle
49 private int min; // min allowable throttle 33 private int min; // min allowable throttle
50 private int throttle; // current throttle setting 34 private int throttle; // current throttle setting
@@ -63,10 +47,10 @@ namespace OpenSim.Region.ClientStack
63 { 47 {
64 sent = 0; 48 sent = 0;
65 } 49 }
66 50
67 public bool UnderLimit() 51 public bool UnderLimit()
68 { 52 {
69 return (sent < (throttle / divisor)); 53 return (sent < (throttle/divisor));
70 } 54 }
71 55
72 public int Add(int bytes) 56 public int Add(int bytes)
@@ -78,27 +62,32 @@ namespace OpenSim.Region.ClientStack
78 // Properties 62 // Properties
79 public int Max 63 public int Max
80 { 64 {
81 get {return max;} 65 get { return max; }
82 } 66 }
83 67
84 public int Min 68 public int Min
85 { 69 {
86 get {return min;} 70 get { return min; }
87 } 71 }
88 72
89 public int Throttle 73 public int Throttle
90 { 74 {
91 get {return throttle;} 75 get { return throttle; }
92 set 76 set
93 { 77 {
94 if (value > max) { 78 if (value > max)
79 {
95 throttle = max; 80 throttle = max;
96 } else if (value < min) { 81 }
82 else if (value < min)
83 {
97 throttle = min; 84 throttle = min;
98 } else { 85 }
86 else
87 {
99 throttle = value; 88 throttle = value;
100 } 89 }
101 } 90 }
102 } 91 }
103 } 92 }
104} 93} \ No newline at end of file
diff --git a/OpenSim/Region/ClientStack/QueItem.cs b/OpenSim/Region/ClientStack/QueItem.cs
index 23b1648..ea0f680 100644
--- a/OpenSim/Region/ClientStack/QueItem.cs
+++ b/OpenSim/Region/ClientStack/QueItem.cs
@@ -31,14 +31,14 @@ using OpenSim.Framework;
31 31
32namespace OpenSim.Region.ClientStack 32namespace OpenSim.Region.ClientStack
33{ 33{
34 public class QueItem 34 public class QueItem
35 {
36 public QueItem()
35 { 37 {
36 public QueItem()
37 {
38 }
39
40 public Packet Packet;
41 public bool Incoming;
42 public ThrottleOutPacketType throttleType;
43 } 38 }
44} 39
40 public Packet Packet;
41 public bool Incoming;
42 public ThrottleOutPacketType throttleType;
43 }
44} \ No newline at end of file
diff --git a/OpenSim/Region/ClientStack/RegionApplicationBase.cs b/OpenSim/Region/ClientStack/RegionApplicationBase.cs
index f20b132..e9331e9 100644
--- a/OpenSim/Region/ClientStack/RegionApplicationBase.cs
+++ b/OpenSim/Region/ClientStack/RegionApplicationBase.cs
@@ -29,7 +29,6 @@ using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Net; 30using System.Net;
31using libsecondlife; 31using libsecondlife;
32using Nini.Config;
33using OpenSim.Framework; 32using OpenSim.Framework;
34using OpenSim.Framework.Communications; 33using OpenSim.Framework.Communications;
35using OpenSim.Framework.Communications.Cache; 34using OpenSim.Framework.Communications.Cache;
@@ -55,7 +54,7 @@ namespace OpenSim.Region.ClientStack
55 protected CommunicationsManager m_commsManager; 54 protected CommunicationsManager m_commsManager;
56 55
57 protected SceneManager m_sceneManager = new SceneManager(); 56 protected SceneManager m_sceneManager = new SceneManager();
58 57
59 protected StorageManager m_storageManager; 58 protected StorageManager m_storageManager;
60 protected string m_storageConnectionString; 59 protected string m_storageConnectionString;
61 60
@@ -73,7 +72,7 @@ namespace OpenSim.Region.ClientStack
73 { 72 {
74 ClientView.TerrainManager = new TerrainManager(new SecondLife()); 73 ClientView.TerrainManager = new TerrainManager(new SecondLife());
75 74
76 m_storageManager = CreateStorageManager(m_storageConnectionString ); 75 m_storageManager = CreateStorageManager(m_storageConnectionString);
77 76
78 Initialize(); 77 Initialize();
79 78
@@ -142,7 +141,7 @@ namespace OpenSim.Region.ClientStack
142 m_log.Verbose("PARCEL", "No master avatar found, using null."); 141 m_log.Verbose("PARCEL", "No master avatar found, using null.");
143 scene.RegionInfo.MasterAvatarAssignedUUID = LLUUID.Zero; 142 scene.RegionInfo.MasterAvatarAssignedUUID = LLUUID.Zero;
144 } 143 }
145 144
146 scene.LoadPrimsFromStorage(m_permissions); 145 scene.LoadPrimsFromStorage(m_permissions);
147 scene.loadAllLandObjectsFromStorage(); 146 scene.loadAllLandObjectsFromStorage();
148 scene.performParcelPrimCountUpdate(); 147 scene.performParcelPrimCountUpdate();
@@ -153,4 +152,4 @@ namespace OpenSim.Region.ClientStack
153 protected abstract Scene CreateScene(RegionInfo regionInfo, StorageManager storageManager, 152 protected abstract Scene CreateScene(RegionInfo regionInfo, StorageManager storageManager,
154 AgentCircuitManager circuitManager); 153 AgentCircuitManager circuitManager);
155 } 154 }
156} 155} \ No newline at end of file
diff --git a/OpenSim/Region/ClientStack/UDPServer.cs b/OpenSim/Region/ClientStack/UDPServer.cs
index 47e0b3c..10435bf 100644
--- a/OpenSim/Region/ClientStack/UDPServer.cs
+++ b/OpenSim/Region/ClientStack/UDPServer.cs
@@ -30,6 +30,7 @@ using System.Collections;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Net; 31using System.Net;
32using System.Net.Sockets; 32using System.Net.Sockets;
33using libsecondlife;
33using libsecondlife.Packets; 34using libsecondlife.Packets;
34using OpenSim.Framework; 35using OpenSim.Framework;
35using OpenSim.Framework.Communications.Cache; 36using OpenSim.Framework.Communications.Cache;
@@ -44,24 +45,22 @@ namespace OpenSim.Region.ClientStack
44 { 45 {
45 } 46 }
46 47
47 static readonly PacketPool instance = new PacketPool(); 48 private static readonly PacketPool instance = new PacketPool();
48 49
49 public static PacketPool Instance 50 public static PacketPool Instance
50 { 51 {
51 get 52 get { return instance; }
52 {
53 return instance;
54 }
55 } 53 }
56 54
57 private Hashtable pool = new Hashtable(); 55 private Hashtable pool = new Hashtable();
58 56
59 public Packet GetPacket(PacketType type) { 57 public Packet GetPacket(PacketType type)
58 {
60 Packet packet = null; 59 Packet packet = null;
61 60
62 lock(pool) 61 lock (pool)
63 { 62 {
64 if(pool[type] == null || ((Stack) pool[type]).Count == 0) 63 if (pool[type] == null || ((Stack) pool[type]).Count == 0)
65 { 64 {
66 // Creating a new packet if we cannot reuse an old package 65 // Creating a new packet if we cannot reuse an old package
67 packet = Packet.BuildPacket(type); 66 packet = Packet.BuildPacket(type);
@@ -69,30 +68,33 @@ namespace OpenSim.Region.ClientStack
69 else 68 else
70 { 69 {
71 // Recycle old packages 70 // Recycle old packages
72 packet=(Packet) ((Stack) pool[type]).Pop(); 71 packet = (Packet) ((Stack) pool[type]).Pop();
73 } 72 }
74 } 73 }
75 74
76 return packet; 75 return packet;
77 } 76 }
78 77
79 public Packet GetPacket(byte[] bytes, ref int packetEnd, byte[] zeroBuffer) { 78 public Packet GetPacket(byte[] bytes, ref int packetEnd, byte[] zeroBuffer)
79 {
80 Packet packet = GetPacket(GetType(bytes, packetEnd, zeroBuffer)); 80 Packet packet = GetPacket(GetType(bytes, packetEnd, zeroBuffer));
81 81
82 int i = 0; 82 int i = 0;
83 packet.FromBytes(bytes, ref i, ref packetEnd, zeroBuffer); 83 packet.FromBytes(bytes, ref i, ref packetEnd, zeroBuffer);
84 return packet; 84 return packet;
85 } 85 }
86
86 public PacketType GetType(byte[] bytes, int packetEnd, byte[] zeroBuffer) 87 public PacketType GetType(byte[] bytes, int packetEnd, byte[] zeroBuffer)
87 { 88 {
88 //Function removed from LibSL revision 1540 89 //Function removed from LibSL revision 1540
89 // We're using it.. so Built it into UDP server for now.. 90 // We're using it.. so Built it into UDP server for now..
90 ushort id; libsecondlife.PacketFrequency freq; 91 ushort id;
92 PacketFrequency freq;
91 int i = 0, end = packetEnd; 93 int i = 0, end = packetEnd;
92 Header header = Header.BuildHeader(bytes, ref i, ref end); 94 Header header = Header.BuildHeader(bytes, ref i, ref end);
93 if (header.Zerocoded) 95 if (header.Zerocoded)
94 { 96 {
95 end = libsecondlife.Helpers.ZeroDecode(bytes, end + 1, zeroBuffer) - 1; 97 end = Helpers.ZeroDecode(bytes, end + 1, zeroBuffer) - 1;
96 bytes = zeroBuffer; 98 bytes = zeroBuffer;
97 } 99 }
98 100
@@ -100,25 +102,30 @@ namespace OpenSim.Region.ClientStack
100 { 102 {
101 if (bytes[7] == 0xFF) 103 if (bytes[7] == 0xFF)
102 { 104 {
103 id = (ushort)((bytes[8] << 8) + bytes[9]); freq = libsecondlife.PacketFrequency.Low; 105 id = (ushort) ((bytes[8] << 8) + bytes[9]);
106 freq = PacketFrequency.Low;
104 } 107 }
105 else 108 else
106 { 109 {
107 id = (ushort)bytes[7]; freq = libsecondlife.PacketFrequency.Medium; 110 id = (ushort) bytes[7];
111 freq = PacketFrequency.Medium;
108 } 112 }
109 } 113 }
110 else 114 else
111 { 115 {
112 id = (ushort)bytes[6]; freq = libsecondlife.PacketFrequency.High; 116 id = (ushort) bytes[6];
117 freq = PacketFrequency.High;
113 } 118 }
114 return Packet.GetType(id, freq); 119 return Packet.GetType(id, freq);
115 } 120 }
116 public void ReturnPacket(Packet packet) { 121
117 lock(pool) 122 public void ReturnPacket(Packet packet)
123 {
124 lock (pool)
118 { 125 {
119 PacketType type=packet.Type; 126 PacketType type = packet.Type;
120 127
121 if(pool[type] == null) 128 if (pool[type] == null)
122 { 129 {
123 pool[type] = new Stack(); 130 pool[type] = new Stack();
124 } 131 }
@@ -162,15 +169,11 @@ namespace OpenSim.Region.ClientStack
162 m_packetServer.LocalScene = m_localScene; 169 m_packetServer.LocalScene = m_localScene;
163 m_regionHandle = m_localScene.RegionInfo.RegionHandle; 170 m_regionHandle = m_localScene.RegionInfo.RegionHandle;
164 } 171 }
165
166 } 172 }
167 173
168 public ulong RegionHandle 174 public ulong RegionHandle
169 { 175 {
170 get 176 get { return m_regionHandle; }
171 {
172 return m_regionHandle;
173 }
174 } 177 }
175 178
176 public UDPServer() 179 public UDPServer()
@@ -212,30 +215,29 @@ namespace OpenSim.Region.ClientStack
212 case SocketError.AlreadyInProgress: 215 case SocketError.AlreadyInProgress:
213 case SocketError.NetworkReset: 216 case SocketError.NetworkReset:
214 case SocketError.ConnectionReset: 217 case SocketError.ConnectionReset:
215 218
216 try 219 try
217 { 220 {
218 CloseEndPoint(epSender); 221 CloseEndPoint(epSender);
219 } 222 }
220 catch (System.Exception a) 223 catch (Exception a)
221 { 224 {
222 MainLog.Instance.Verbose("UDPSERVER", a.ToString()); 225 MainLog.Instance.Verbose("UDPSERVER", a.ToString());
223 } 226 }
224 try 227 try
225 { 228 {
226 Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null); 229 Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender,
227 230 ReceivedData, null);
231
228 // Ter: For some stupid reason ConnectionReset basically kills our async event structure.. 232 // Ter: For some stupid reason ConnectionReset basically kills our async event structure..
229 // so therefore.. we've got to tell the server to BeginReceiveFrom again. 233 // so therefore.. we've got to tell the server to BeginReceiveFrom again.
230 // This will happen over and over until we've gone through all packets 234 // This will happen over and over until we've gone through all packets
231 // sent to and from this particular user. 235 // sent to and from this particular user.
232 // Stupid I know.. 236 // Stupid I know..
233 // but Flusing the buffer would be even more stupid... so, we're stuck with this ugly method. 237 // but Flusing the buffer would be even more stupid... so, we're stuck with this ugly method.
234
235 } 238 }
236 catch (SocketException) 239 catch (SocketException)
237 { 240 {
238
239 } 241 }
240 break; 242 break;
241 default: 243 default:
@@ -243,13 +245,14 @@ namespace OpenSim.Region.ClientStack
243 { 245 {
244 CloseEndPoint(epSender); 246 CloseEndPoint(epSender);
245 } 247 }
246 catch (System.Exception) 248 catch (Exception)
247 { 249 {
248 //MainLog.Instance.Verbose("UDPSERVER", a.ToString()); 250 //MainLog.Instance.Verbose("UDPSERVER", a.ToString());
249 } 251 }
250 try 252 try
251 { 253 {
252 Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null); 254 Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender,
255 ReceivedData, null);
253 256
254 // Ter: For some stupid reason ConnectionReset basically kills our async event structure.. 257 // Ter: For some stupid reason ConnectionReset basically kills our async event structure..
255 // so therefore.. we've got to tell the server to BeginReceiveFrom again. 258 // so therefore.. we've got to tell the server to BeginReceiveFrom again.
@@ -257,17 +260,15 @@ namespace OpenSim.Region.ClientStack
257 // sent to and from this particular user. 260 // sent to and from this particular user.
258 // Stupid I know.. 261 // Stupid I know..
259 // but Flusing the buffer would be even more stupid... so, we're stuck with this ugly method. 262 // but Flusing the buffer would be even more stupid... so, we're stuck with this ugly method.
260
261 } 263 }
262 catch (SocketException) 264 catch (SocketException)
263 { 265 {
264
265 } 266 }
266 267
267 // Here's some reference code! :D 268 // Here's some reference code! :D
268 // Shutdown and restart the UDP listener! hehe 269 // Shutdown and restart the UDP listener! hehe
269 // Shiny 270 // Shiny
270 271
271 //Server.Shutdown(SocketShutdown.Both); 272 //Server.Shutdown(SocketShutdown.Both);
272 //CloseEndPoint(epSender); 273 //CloseEndPoint(epSender);
273 //ServerListener(); 274 //ServerListener();
@@ -276,7 +277,7 @@ namespace OpenSim.Region.ClientStack
276 277
277 return; 278 return;
278 } 279 }
279 catch (System.ObjectDisposedException) 280 catch (ObjectDisposedException)
280 { 281 {
281 //MainLog.Instance.Debug("UDPSERVER", e.ToString()); 282 //MainLog.Instance.Debug("UDPSERVER", e.ToString());
282 return; 283 return;
@@ -288,7 +289,7 @@ namespace OpenSim.Region.ClientStack
288 { 289 {
289 packet = PacketPool.Instance.GetPacket(RecvBuffer, ref packetEnd, ZeroBuffer); 290 packet = PacketPool.Instance.GetPacket(RecvBuffer, ref packetEnd, ZeroBuffer);
290 } 291 }
291 catch(Exception) 292 catch (Exception)
292 { 293 {
293 //MainLog.Instance.Debug("UDPSERVER", e.ToString()); 294 //MainLog.Instance.Debug("UDPSERVER", e.ToString());
294 } 295 }
@@ -311,7 +312,6 @@ namespace OpenSim.Region.ClientStack
311 } 312 }
312 else 313 else
313 { 314 {
314
315 // invalid client 315 // invalid client
316 //CFK: This message seems to have served its usefullness as of 12-15 so I am commenting it out for now 316 //CFK: This message seems to have served its usefullness as of 12-15 so I am commenting it out for now
317 //m_log.Warn("client", "Got a packet from an invalid client - " + epSender.ToString()); 317 //m_log.Warn("client", "Got a packet from an invalid client - " + epSender.ToString());
@@ -326,9 +326,7 @@ namespace OpenSim.Region.ClientStack
326 uint circuit; 326 uint circuit;
327 if (clientCircuits.TryGetValue(sender, out circuit)) 327 if (clientCircuits.TryGetValue(sender, out circuit))
328 { 328 {
329
330 m_packetServer.CloseCircuit(circuit); 329 m_packetServer.CloseCircuit(circuit);
331
332 } 330 }
333 } 331 }
334 332
@@ -381,14 +379,11 @@ namespace OpenSim.Region.ClientStack
381 EndPoint sendto = null; 379 EndPoint sendto = null;
382 if (clientCircuits_reverse.TryGetValue(circuitcode, out sendto)) 380 if (clientCircuits_reverse.TryGetValue(circuitcode, out sendto))
383 { 381 {
384
385 clientCircuits.Remove(sendto); 382 clientCircuits.Remove(sendto);
386
387 383
388 384
389 clientCircuits_reverse.Remove(circuitcode); 385 clientCircuits_reverse.Remove(circuitcode);
390
391 } 386 }
392 } 387 }
393 } 388 }
394} 389} \ No newline at end of file