diff options
author | Sean Dague | 2007-07-16 15:40:11 +0000 |
---|---|---|
committer | Sean Dague | 2007-07-16 15:40:11 +0000 |
commit | 2a3c79df83e800d5dfe75a1a3b140ed81da2b1d6 (patch) | |
tree | e3f80ad51736cf17e856547b1bcf956010927434 /OpenSim/Region/ClientStack | |
parent | *Trunk compiles now (diff) | |
download | opensim-SC_OLD-2a3c79df83e800d5dfe75a1a3b140ed81da2b1d6.zip opensim-SC_OLD-2a3c79df83e800d5dfe75a1a3b140ed81da2b1d6.tar.gz opensim-SC_OLD-2a3c79df83e800d5dfe75a1a3b140ed81da2b1d6.tar.bz2 opensim-SC_OLD-2a3c79df83e800d5dfe75a1a3b140ed81da2b1d6.tar.xz |
changed to native line ending encoding
Diffstat (limited to 'OpenSim/Region/ClientStack')
-rw-r--r-- | OpenSim/Region/ClientStack/Assets/InventoryCache.cs | 676 | ||||
-rw-r--r-- | OpenSim/Region/ClientStack/ClientStackNetworkHandler.cs | 80 | ||||
-rw-r--r-- | OpenSim/Region/ClientStack/ClientView.API.cs | 2360 | ||||
-rw-r--r-- | OpenSim/Region/ClientStack/ClientView.AgentAssetUpload.cs | 714 | ||||
-rw-r--r-- | OpenSim/Region/ClientStack/ClientView.PacketHandlers.cs | 472 | ||||
-rw-r--r-- | OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs | 1294 | ||||
-rw-r--r-- | OpenSim/Region/ClientStack/ClientView.cs | 586 | ||||
-rw-r--r-- | OpenSim/Region/ClientStack/ClientViewBase.cs | 652 | ||||
-rw-r--r-- | OpenSim/Region/ClientStack/PacketServer.cs | 368 | ||||
-rw-r--r-- | OpenSim/Region/ClientStack/RegionApplicationBase.cs | 236 | ||||
-rw-r--r-- | OpenSim/Region/ClientStack/UDPServer.cs | 390 |
11 files changed, 3914 insertions, 3914 deletions
diff --git a/OpenSim/Region/ClientStack/Assets/InventoryCache.cs b/OpenSim/Region/ClientStack/Assets/InventoryCache.cs index e2cfa46..1bb6c07 100644 --- a/OpenSim/Region/ClientStack/Assets/InventoryCache.cs +++ b/OpenSim/Region/ClientStack/Assets/InventoryCache.cs | |||
@@ -1,338 +1,338 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | 2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
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 | */ |
28 | 28 | ||
29 | using System; | 29 | using System; |
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using System.Text; | 31 | using System.Text; |
32 | using libsecondlife; | 32 | using libsecondlife; |
33 | using libsecondlife.Packets; | 33 | using libsecondlife.Packets; |
34 | using OpenSim.Framework.Interfaces; | 34 | using OpenSim.Framework.Interfaces; |
35 | using OpenSim.Framework.Inventory; | 35 | using OpenSim.Framework.Inventory; |
36 | using OpenSim.Framework.Types; | 36 | using OpenSim.Framework.Types; |
37 | using OpenSim.Region.ClientStack; | 37 | using OpenSim.Region.ClientStack; |
38 | 38 | ||
39 | namespace OpenSim.Assets | 39 | namespace OpenSim.Assets |
40 | { | 40 | { |
41 | /// <summary> | 41 | /// <summary> |
42 | /// Description of InventoryManager. | 42 | /// Description of InventoryManager. |
43 | /// </summary> | 43 | /// </summary> |
44 | public class InventoryCache | 44 | public class InventoryCache |
45 | { | 45 | { |
46 | private Dictionary<LLUUID, AgentInventory> _agentsInventory; | 46 | private Dictionary<LLUUID, AgentInventory> _agentsInventory; |
47 | private List<UserServerRequest> _serverRequests; //list of requests made to user server. | 47 | private List<UserServerRequest> _serverRequests; //list of requests made to user server. |
48 | private Encoding _enc = Encoding.ASCII; | 48 | private Encoding _enc = Encoding.ASCII; |
49 | private const uint FULL_MASK_PERMISSIONS = 2147483647; | 49 | private const uint FULL_MASK_PERMISSIONS = 2147483647; |
50 | 50 | ||
51 | public InventoryCache() | 51 | public InventoryCache() |
52 | { | 52 | { |
53 | _agentsInventory = new Dictionary<LLUUID, AgentInventory>(); | 53 | _agentsInventory = new Dictionary<LLUUID, AgentInventory>(); |
54 | _serverRequests = new List<UserServerRequest>(); | 54 | _serverRequests = new List<UserServerRequest>(); |
55 | } | 55 | } |
56 | 56 | ||
57 | public void AddNewAgentsInventory(AgentInventory agentInventory) | 57 | public void AddNewAgentsInventory(AgentInventory agentInventory) |
58 | { | 58 | { |
59 | if (!this._agentsInventory.ContainsKey(agentInventory.AgentID)) | 59 | if (!this._agentsInventory.ContainsKey(agentInventory.AgentID)) |
60 | { | 60 | { |
61 | this._agentsInventory.Add(agentInventory.AgentID, agentInventory); | 61 | this._agentsInventory.Add(agentInventory.AgentID, agentInventory); |
62 | } | 62 | } |
63 | } | 63 | } |
64 | 64 | ||
65 | public AgentInventory FetchAgentsInventory(LLUUID agentID, IUserServer userserver) | 65 | public AgentInventory FetchAgentsInventory(LLUUID agentID, IUserServer userserver) |
66 | { | 66 | { |
67 | AgentInventory res = null; | 67 | AgentInventory res = null; |
68 | if (!this._agentsInventory.ContainsKey(agentID)) | 68 | if (!this._agentsInventory.ContainsKey(agentID)) |
69 | { | 69 | { |
70 | res = userserver.RequestAgentsInventory(agentID); | 70 | res = userserver.RequestAgentsInventory(agentID); |
71 | this._agentsInventory.Add(agentID,res); | 71 | this._agentsInventory.Add(agentID,res); |
72 | } | 72 | } |
73 | return res; | 73 | return res; |
74 | } | 74 | } |
75 | 75 | ||
76 | public AgentInventory GetAgentsInventory(LLUUID agentID) | 76 | public AgentInventory GetAgentsInventory(LLUUID agentID) |
77 | { | 77 | { |
78 | if (this._agentsInventory.ContainsKey(agentID)) | 78 | if (this._agentsInventory.ContainsKey(agentID)) |
79 | { | 79 | { |
80 | return this._agentsInventory[agentID]; | 80 | return this._agentsInventory[agentID]; |
81 | } | 81 | } |
82 | 82 | ||
83 | return null; | 83 | return null; |
84 | } | 84 | } |
85 | 85 | ||
86 | public void ClientLeaving(LLUUID clientID, IUserServer userserver) | 86 | public void ClientLeaving(LLUUID clientID, IUserServer userserver) |
87 | { | 87 | { |
88 | if (this._agentsInventory.ContainsKey(clientID)) | 88 | if (this._agentsInventory.ContainsKey(clientID)) |
89 | { | 89 | { |
90 | if (userserver != null) | 90 | if (userserver != null) |
91 | { | 91 | { |
92 | userserver.UpdateAgentsInventory(clientID, this._agentsInventory[clientID]); | 92 | userserver.UpdateAgentsInventory(clientID, this._agentsInventory[clientID]); |
93 | } | 93 | } |
94 | this._agentsInventory.Remove(clientID); | 94 | this._agentsInventory.Remove(clientID); |
95 | } | 95 | } |
96 | } | 96 | } |
97 | 97 | ||
98 | public bool CreateNewInventoryFolder(ClientView remoteClient, LLUUID folderID) | 98 | public bool CreateNewInventoryFolder(ClientView remoteClient, LLUUID folderID) |
99 | { | 99 | { |
100 | return this.CreateNewInventoryFolder(remoteClient, folderID, 0); | 100 | return this.CreateNewInventoryFolder(remoteClient, folderID, 0); |
101 | } | 101 | } |
102 | 102 | ||
103 | public bool CreateNewInventoryFolder(ClientView remoteClient, LLUUID folderID, ushort type) | 103 | public bool CreateNewInventoryFolder(ClientView remoteClient, LLUUID folderID, ushort type) |
104 | { | 104 | { |
105 | bool res = false; | 105 | bool res = false; |
106 | if (folderID != LLUUID.Zero) //don't create a folder with a zero id | 106 | if (folderID != LLUUID.Zero) //don't create a folder with a zero id |
107 | { | 107 | { |
108 | if (this._agentsInventory.ContainsKey(remoteClient.AgentID)) | 108 | if (this._agentsInventory.ContainsKey(remoteClient.AgentID)) |
109 | { | 109 | { |
110 | res = this._agentsInventory[remoteClient.AgentID].CreateNewFolder(folderID, type); | 110 | res = this._agentsInventory[remoteClient.AgentID].CreateNewFolder(folderID, type); |
111 | } | 111 | } |
112 | } | 112 | } |
113 | return res; | 113 | return res; |
114 | } | 114 | } |
115 | 115 | ||
116 | public bool CreateNewInventoryFolder(ClientView remoteClient, LLUUID folderID, ushort type, string folderName, LLUUID parent) | 116 | public bool CreateNewInventoryFolder(ClientView remoteClient, LLUUID folderID, ushort type, string folderName, LLUUID parent) |
117 | { | 117 | { |
118 | bool res = false; | 118 | bool res = false; |
119 | if (folderID != LLUUID.Zero) //don't create a folder with a zero id | 119 | if (folderID != LLUUID.Zero) //don't create a folder with a zero id |
120 | { | 120 | { |
121 | if (this._agentsInventory.ContainsKey(remoteClient.AgentID)) | 121 | if (this._agentsInventory.ContainsKey(remoteClient.AgentID)) |
122 | { | 122 | { |
123 | res = this._agentsInventory[remoteClient.AgentID].CreateNewFolder(folderID, type, folderName, parent); | 123 | res = this._agentsInventory[remoteClient.AgentID].CreateNewFolder(folderID, type, folderName, parent); |
124 | } | 124 | } |
125 | } | 125 | } |
126 | return res; | 126 | return res; |
127 | } | 127 | } |
128 | 128 | ||
129 | public LLUUID AddNewInventoryItem(ClientView remoteClient, LLUUID folderID, AssetBase asset) | 129 | public LLUUID AddNewInventoryItem(ClientView remoteClient, LLUUID folderID, AssetBase asset) |
130 | { | 130 | { |
131 | LLUUID newItem = null; | 131 | LLUUID newItem = null; |
132 | if (this._agentsInventory.ContainsKey(remoteClient.AgentID)) | 132 | if (this._agentsInventory.ContainsKey(remoteClient.AgentID)) |
133 | { | 133 | { |
134 | newItem = this._agentsInventory[remoteClient.AgentID].AddToInventory(folderID, asset); | 134 | newItem = this._agentsInventory[remoteClient.AgentID].AddToInventory(folderID, asset); |
135 | if (newItem != null) | 135 | if (newItem != null) |
136 | { | 136 | { |
137 | InventoryItem Item = this._agentsInventory[remoteClient.AgentID].InventoryItems[newItem]; | 137 | InventoryItem Item = this._agentsInventory[remoteClient.AgentID].InventoryItems[newItem]; |
138 | this.SendItemUpdateCreate(remoteClient, Item); | 138 | this.SendItemUpdateCreate(remoteClient, Item); |
139 | } | 139 | } |
140 | } | 140 | } |
141 | 141 | ||
142 | return newItem; | 142 | return newItem; |
143 | } | 143 | } |
144 | public bool DeleteInventoryItem(ClientView remoteClient, LLUUID itemID) | 144 | public bool DeleteInventoryItem(ClientView remoteClient, LLUUID itemID) |
145 | { | 145 | { |
146 | bool res = false; | 146 | bool res = false; |
147 | if (this._agentsInventory.ContainsKey(remoteClient.AgentID)) | 147 | if (this._agentsInventory.ContainsKey(remoteClient.AgentID)) |
148 | { | 148 | { |
149 | res = this._agentsInventory[remoteClient.AgentID].DeleteFromInventory(itemID); | 149 | res = this._agentsInventory[remoteClient.AgentID].DeleteFromInventory(itemID); |
150 | if (res) | 150 | if (res) |
151 | { | 151 | { |
152 | RemoveInventoryItemPacket remove = new RemoveInventoryItemPacket(); | 152 | RemoveInventoryItemPacket remove = new RemoveInventoryItemPacket(); |
153 | remove.AgentData.AgentID = remoteClient.AgentID; | 153 | remove.AgentData.AgentID = remoteClient.AgentID; |
154 | remove.AgentData.SessionID = remoteClient.SessionID; | 154 | remove.AgentData.SessionID = remoteClient.SessionID; |
155 | remove.InventoryData = new RemoveInventoryItemPacket.InventoryDataBlock[1]; | 155 | remove.InventoryData = new RemoveInventoryItemPacket.InventoryDataBlock[1]; |
156 | remove.InventoryData[0] = new RemoveInventoryItemPacket.InventoryDataBlock(); | 156 | remove.InventoryData[0] = new RemoveInventoryItemPacket.InventoryDataBlock(); |
157 | remove.InventoryData[0].ItemID = itemID; | 157 | remove.InventoryData[0].ItemID = itemID; |
158 | remoteClient.OutPacket(remove); | 158 | remoteClient.OutPacket(remove); |
159 | } | 159 | } |
160 | } | 160 | } |
161 | 161 | ||
162 | return res; | 162 | return res; |
163 | } | 163 | } |
164 | 164 | ||
165 | public bool UpdateInventoryItemAsset(ClientView remoteClient, LLUUID itemID, AssetBase asset) | 165 | public bool UpdateInventoryItemAsset(ClientView remoteClient, LLUUID itemID, AssetBase asset) |
166 | { | 166 | { |
167 | if (this._agentsInventory.ContainsKey(remoteClient.AgentID)) | 167 | if (this._agentsInventory.ContainsKey(remoteClient.AgentID)) |
168 | { | 168 | { |
169 | bool res = _agentsInventory[remoteClient.AgentID].UpdateItemAsset(itemID, asset); | 169 | bool res = _agentsInventory[remoteClient.AgentID].UpdateItemAsset(itemID, asset); |
170 | if (res) | 170 | if (res) |
171 | { | 171 | { |
172 | InventoryItem Item = this._agentsInventory[remoteClient.AgentID].InventoryItems[itemID]; | 172 | InventoryItem Item = this._agentsInventory[remoteClient.AgentID].InventoryItems[itemID]; |
173 | this.SendItemUpdateCreate(remoteClient, Item); | 173 | this.SendItemUpdateCreate(remoteClient, Item); |
174 | } | 174 | } |
175 | return res; | 175 | return res; |
176 | } | 176 | } |
177 | 177 | ||
178 | return false; | 178 | return false; |
179 | } | 179 | } |
180 | 180 | ||
181 | public bool UpdateInventoryItemDetails(ClientView remoteClient, LLUUID itemID, UpdateInventoryItemPacket.InventoryDataBlock packet) | 181 | public bool UpdateInventoryItemDetails(ClientView remoteClient, LLUUID itemID, UpdateInventoryItemPacket.InventoryDataBlock packet) |
182 | { | 182 | { |
183 | if (this._agentsInventory.ContainsKey(remoteClient.AgentID)) | 183 | if (this._agentsInventory.ContainsKey(remoteClient.AgentID)) |
184 | { | 184 | { |
185 | bool res = _agentsInventory[remoteClient.AgentID].UpdateItemDetails(itemID, packet); | 185 | bool res = _agentsInventory[remoteClient.AgentID].UpdateItemDetails(itemID, packet); |
186 | if (res) | 186 | if (res) |
187 | { | 187 | { |
188 | InventoryItem Item = this._agentsInventory[remoteClient.AgentID].InventoryItems[itemID]; | 188 | InventoryItem Item = this._agentsInventory[remoteClient.AgentID].InventoryItems[itemID]; |
189 | this.SendItemUpdateCreate(remoteClient, Item); | 189 | this.SendItemUpdateCreate(remoteClient, Item); |
190 | } | 190 | } |
191 | return res; | 191 | return res; |
192 | } | 192 | } |
193 | 193 | ||
194 | return false; | 194 | return false; |
195 | } | 195 | } |
196 | 196 | ||
197 | public void FetchInventoryDescendents(ClientView userInfo, FetchInventoryDescendentsPacket FetchDescend) | 197 | public void FetchInventoryDescendents(ClientView userInfo, FetchInventoryDescendentsPacket FetchDescend) |
198 | { | 198 | { |
199 | 199 | ||
200 | if (this._agentsInventory.ContainsKey(userInfo.AgentID)) | 200 | if (this._agentsInventory.ContainsKey(userInfo.AgentID)) |
201 | { | 201 | { |
202 | AgentInventory agentInventory = this._agentsInventory[userInfo.AgentID]; | 202 | AgentInventory agentInventory = this._agentsInventory[userInfo.AgentID]; |
203 | if (FetchDescend.InventoryData.FetchItems) | 203 | if (FetchDescend.InventoryData.FetchItems) |
204 | { | 204 | { |
205 | if (agentInventory.InventoryFolders.ContainsKey(FetchDescend.InventoryData.FolderID)) | 205 | if (agentInventory.InventoryFolders.ContainsKey(FetchDescend.InventoryData.FolderID)) |
206 | { | 206 | { |
207 | InventoryFolder Folder = agentInventory.InventoryFolders[FetchDescend.InventoryData.FolderID]; | 207 | InventoryFolder Folder = agentInventory.InventoryFolders[FetchDescend.InventoryData.FolderID]; |
208 | InventoryDescendentsPacket Descend = new InventoryDescendentsPacket(); | 208 | InventoryDescendentsPacket Descend = new InventoryDescendentsPacket(); |
209 | Descend.AgentData.AgentID = userInfo.AgentID; | 209 | Descend.AgentData.AgentID = userInfo.AgentID; |
210 | Descend.AgentData.OwnerID = Folder.OwnerID; | 210 | Descend.AgentData.OwnerID = Folder.OwnerID; |
211 | Descend.AgentData.FolderID = FetchDescend.InventoryData.FolderID; | 211 | Descend.AgentData.FolderID = FetchDescend.InventoryData.FolderID; |
212 | Descend.AgentData.Descendents = Folder.Items.Count; | 212 | Descend.AgentData.Descendents = Folder.Items.Count; |
213 | Descend.AgentData.Version = Folder.Items.Count; | 213 | Descend.AgentData.Version = Folder.Items.Count; |
214 | 214 | ||
215 | 215 | ||
216 | Descend.ItemData = new InventoryDescendentsPacket.ItemDataBlock[Folder.Items.Count]; | 216 | Descend.ItemData = new InventoryDescendentsPacket.ItemDataBlock[Folder.Items.Count]; |
217 | for (int i = 0; i < Folder.Items.Count; i++) | 217 | for (int i = 0; i < Folder.Items.Count; i++) |
218 | { | 218 | { |
219 | 219 | ||
220 | InventoryItem Item = Folder.Items[i]; | 220 | InventoryItem Item = Folder.Items[i]; |
221 | Descend.ItemData[i] = new InventoryDescendentsPacket.ItemDataBlock(); | 221 | Descend.ItemData[i] = new InventoryDescendentsPacket.ItemDataBlock(); |
222 | Descend.ItemData[i].ItemID = Item.ItemID; | 222 | Descend.ItemData[i].ItemID = Item.ItemID; |
223 | Descend.ItemData[i].AssetID = Item.AssetID; | 223 | Descend.ItemData[i].AssetID = Item.AssetID; |
224 | Descend.ItemData[i].CreatorID = Item.CreatorID; | 224 | Descend.ItemData[i].CreatorID = Item.CreatorID; |
225 | Descend.ItemData[i].BaseMask = FULL_MASK_PERMISSIONS; | 225 | Descend.ItemData[i].BaseMask = FULL_MASK_PERMISSIONS; |
226 | Descend.ItemData[i].CreationDate = 1000; | 226 | Descend.ItemData[i].CreationDate = 1000; |
227 | Descend.ItemData[i].Description = _enc.GetBytes(Item.Description + "\0"); | 227 | Descend.ItemData[i].Description = _enc.GetBytes(Item.Description + "\0"); |
228 | Descend.ItemData[i].EveryoneMask = FULL_MASK_PERMISSIONS; | 228 | Descend.ItemData[i].EveryoneMask = FULL_MASK_PERMISSIONS; |
229 | Descend.ItemData[i].Flags = 1; | 229 | Descend.ItemData[i].Flags = 1; |
230 | Descend.ItemData[i].FolderID = Item.FolderID; | 230 | Descend.ItemData[i].FolderID = Item.FolderID; |
231 | Descend.ItemData[i].GroupID = new LLUUID("00000000-0000-0000-0000-000000000000"); | 231 | Descend.ItemData[i].GroupID = new LLUUID("00000000-0000-0000-0000-000000000000"); |
232 | Descend.ItemData[i].GroupMask = FULL_MASK_PERMISSIONS; | 232 | Descend.ItemData[i].GroupMask = FULL_MASK_PERMISSIONS; |
233 | Descend.ItemData[i].InvType = Item.InvType; | 233 | Descend.ItemData[i].InvType = Item.InvType; |
234 | Descend.ItemData[i].Name = _enc.GetBytes(Item.Name + "\0"); | 234 | Descend.ItemData[i].Name = _enc.GetBytes(Item.Name + "\0"); |
235 | Descend.ItemData[i].NextOwnerMask = FULL_MASK_PERMISSIONS; | 235 | Descend.ItemData[i].NextOwnerMask = FULL_MASK_PERMISSIONS; |
236 | Descend.ItemData[i].OwnerID = Item.OwnerID; | 236 | Descend.ItemData[i].OwnerID = Item.OwnerID; |
237 | Descend.ItemData[i].OwnerMask = FULL_MASK_PERMISSIONS; | 237 | Descend.ItemData[i].OwnerMask = FULL_MASK_PERMISSIONS; |
238 | Descend.ItemData[i].SalePrice = 100; | 238 | Descend.ItemData[i].SalePrice = 100; |
239 | Descend.ItemData[i].SaleType = 0; | 239 | Descend.ItemData[i].SaleType = 0; |
240 | Descend.ItemData[i].Type = Item.Type; | 240 | Descend.ItemData[i].Type = Item.Type; |
241 | Descend.ItemData[i].CRC = Helpers.InventoryCRC(1000, 0, Descend.ItemData[i].InvType, Descend.ItemData[i].Type, Descend.ItemData[i].AssetID, Descend.ItemData[i].GroupID, 100, Descend.ItemData[i].OwnerID, Descend.ItemData[i].CreatorID, Descend.ItemData[i].ItemID, Descend.ItemData[i].FolderID, FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS); | 241 | Descend.ItemData[i].CRC = Helpers.InventoryCRC(1000, 0, Descend.ItemData[i].InvType, Descend.ItemData[i].Type, Descend.ItemData[i].AssetID, Descend.ItemData[i].GroupID, 100, Descend.ItemData[i].OwnerID, Descend.ItemData[i].CreatorID, Descend.ItemData[i].ItemID, Descend.ItemData[i].FolderID, FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS); |
242 | } | 242 | } |
243 | 243 | ||
244 | userInfo.OutPacket(Descend); | 244 | userInfo.OutPacket(Descend); |
245 | 245 | ||
246 | } | 246 | } |
247 | } | 247 | } |
248 | else | 248 | else |
249 | { | 249 | { |
250 | Console.WriteLine("fetch subfolders"); | 250 | Console.WriteLine("fetch subfolders"); |
251 | } | 251 | } |
252 | } | 252 | } |
253 | } | 253 | } |
254 | 254 | ||
255 | public void FetchInventory(ClientView userInfo, FetchInventoryPacket FetchItems) | 255 | public void FetchInventory(ClientView userInfo, FetchInventoryPacket FetchItems) |
256 | { | 256 | { |
257 | if (this._agentsInventory.ContainsKey(userInfo.AgentID)) | 257 | if (this._agentsInventory.ContainsKey(userInfo.AgentID)) |
258 | { | 258 | { |
259 | AgentInventory agentInventory = this._agentsInventory[userInfo.AgentID]; | 259 | AgentInventory agentInventory = this._agentsInventory[userInfo.AgentID]; |
260 | 260 | ||
261 | for (int i = 0; i < FetchItems.InventoryData.Length; i++) | 261 | for (int i = 0; i < FetchItems.InventoryData.Length; i++) |
262 | { | 262 | { |
263 | if (agentInventory.InventoryItems.ContainsKey(FetchItems.InventoryData[i].ItemID)) | 263 | if (agentInventory.InventoryItems.ContainsKey(FetchItems.InventoryData[i].ItemID)) |
264 | { | 264 | { |
265 | InventoryItem Item = agentInventory.InventoryItems[FetchItems.InventoryData[i].ItemID]; | 265 | InventoryItem Item = agentInventory.InventoryItems[FetchItems.InventoryData[i].ItemID]; |
266 | FetchInventoryReplyPacket InventoryReply = new FetchInventoryReplyPacket(); | 266 | FetchInventoryReplyPacket InventoryReply = new FetchInventoryReplyPacket(); |
267 | InventoryReply.AgentData.AgentID = userInfo.AgentID; | 267 | InventoryReply.AgentData.AgentID = userInfo.AgentID; |
268 | InventoryReply.InventoryData = new FetchInventoryReplyPacket.InventoryDataBlock[1]; | 268 | InventoryReply.InventoryData = new FetchInventoryReplyPacket.InventoryDataBlock[1]; |
269 | InventoryReply.InventoryData[0] = new FetchInventoryReplyPacket.InventoryDataBlock(); | 269 | InventoryReply.InventoryData[0] = new FetchInventoryReplyPacket.InventoryDataBlock(); |
270 | InventoryReply.InventoryData[0].ItemID = Item.ItemID; | 270 | InventoryReply.InventoryData[0].ItemID = Item.ItemID; |
271 | InventoryReply.InventoryData[0].AssetID = Item.AssetID; | 271 | InventoryReply.InventoryData[0].AssetID = Item.AssetID; |
272 | InventoryReply.InventoryData[0].CreatorID = Item.CreatorID; | 272 | InventoryReply.InventoryData[0].CreatorID = Item.CreatorID; |
273 | InventoryReply.InventoryData[0].BaseMask = FULL_MASK_PERMISSIONS; | 273 | InventoryReply.InventoryData[0].BaseMask = FULL_MASK_PERMISSIONS; |
274 | InventoryReply.InventoryData[0].CreationDate = (int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; | 274 | InventoryReply.InventoryData[0].CreationDate = (int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; |
275 | InventoryReply.InventoryData[0].Description = _enc.GetBytes(Item.Description + "\0"); | 275 | InventoryReply.InventoryData[0].Description = _enc.GetBytes(Item.Description + "\0"); |
276 | InventoryReply.InventoryData[0].EveryoneMask = FULL_MASK_PERMISSIONS; | 276 | InventoryReply.InventoryData[0].EveryoneMask = FULL_MASK_PERMISSIONS; |
277 | InventoryReply.InventoryData[0].Flags = 0; | 277 | InventoryReply.InventoryData[0].Flags = 0; |
278 | InventoryReply.InventoryData[0].FolderID = Item.FolderID; | 278 | InventoryReply.InventoryData[0].FolderID = Item.FolderID; |
279 | InventoryReply.InventoryData[0].GroupID = new LLUUID("00000000-0000-0000-0000-000000000000"); | 279 | InventoryReply.InventoryData[0].GroupID = new LLUUID("00000000-0000-0000-0000-000000000000"); |
280 | InventoryReply.InventoryData[0].GroupMask = FULL_MASK_PERMISSIONS; | 280 | InventoryReply.InventoryData[0].GroupMask = FULL_MASK_PERMISSIONS; |
281 | InventoryReply.InventoryData[0].InvType = Item.InvType; | 281 | InventoryReply.InventoryData[0].InvType = Item.InvType; |
282 | InventoryReply.InventoryData[0].Name = _enc.GetBytes(Item.Name + "\0"); | 282 | InventoryReply.InventoryData[0].Name = _enc.GetBytes(Item.Name + "\0"); |
283 | InventoryReply.InventoryData[0].NextOwnerMask = FULL_MASK_PERMISSIONS; | 283 | InventoryReply.InventoryData[0].NextOwnerMask = FULL_MASK_PERMISSIONS; |
284 | InventoryReply.InventoryData[0].OwnerID = Item.OwnerID; | 284 | InventoryReply.InventoryData[0].OwnerID = Item.OwnerID; |
285 | InventoryReply.InventoryData[0].OwnerMask = FULL_MASK_PERMISSIONS; | 285 | InventoryReply.InventoryData[0].OwnerMask = FULL_MASK_PERMISSIONS; |
286 | InventoryReply.InventoryData[0].SalePrice = 100; | 286 | InventoryReply.InventoryData[0].SalePrice = 100; |
287 | InventoryReply.InventoryData[0].SaleType = 0; | 287 | InventoryReply.InventoryData[0].SaleType = 0; |
288 | InventoryReply.InventoryData[0].Type = Item.Type; | 288 | InventoryReply.InventoryData[0].Type = Item.Type; |
289 | InventoryReply.InventoryData[0].CRC = Helpers.InventoryCRC(1000, 0, InventoryReply.InventoryData[0].InvType, InventoryReply.InventoryData[0].Type, InventoryReply.InventoryData[0].AssetID, InventoryReply.InventoryData[0].GroupID, 100, InventoryReply.InventoryData[0].OwnerID, InventoryReply.InventoryData[0].CreatorID, InventoryReply.InventoryData[0].ItemID, InventoryReply.InventoryData[0].FolderID, FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS); | 289 | InventoryReply.InventoryData[0].CRC = Helpers.InventoryCRC(1000, 0, InventoryReply.InventoryData[0].InvType, InventoryReply.InventoryData[0].Type, InventoryReply.InventoryData[0].AssetID, InventoryReply.InventoryData[0].GroupID, 100, InventoryReply.InventoryData[0].OwnerID, InventoryReply.InventoryData[0].CreatorID, InventoryReply.InventoryData[0].ItemID, InventoryReply.InventoryData[0].FolderID, FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS); |
290 | userInfo.OutPacket(InventoryReply); | 290 | userInfo.OutPacket(InventoryReply); |
291 | } | 291 | } |
292 | } | 292 | } |
293 | } | 293 | } |
294 | } | 294 | } |
295 | 295 | ||
296 | private void SendItemUpdateCreate(ClientView remoteClient, InventoryItem Item) | 296 | private void SendItemUpdateCreate(ClientView remoteClient, InventoryItem Item) |
297 | { | 297 | { |
298 | 298 | ||
299 | UpdateCreateInventoryItemPacket InventoryReply = new UpdateCreateInventoryItemPacket(); | 299 | UpdateCreateInventoryItemPacket InventoryReply = new UpdateCreateInventoryItemPacket(); |
300 | InventoryReply.AgentData.AgentID = remoteClient.AgentID; | 300 | InventoryReply.AgentData.AgentID = remoteClient.AgentID; |
301 | InventoryReply.AgentData.SimApproved = true; | 301 | InventoryReply.AgentData.SimApproved = true; |
302 | InventoryReply.InventoryData = new UpdateCreateInventoryItemPacket.InventoryDataBlock[1]; | 302 | InventoryReply.InventoryData = new UpdateCreateInventoryItemPacket.InventoryDataBlock[1]; |
303 | InventoryReply.InventoryData[0] = new UpdateCreateInventoryItemPacket.InventoryDataBlock(); | 303 | InventoryReply.InventoryData[0] = new UpdateCreateInventoryItemPacket.InventoryDataBlock(); |
304 | InventoryReply.InventoryData[0].ItemID = Item.ItemID; | 304 | InventoryReply.InventoryData[0].ItemID = Item.ItemID; |
305 | InventoryReply.InventoryData[0].AssetID = Item.AssetID; | 305 | InventoryReply.InventoryData[0].AssetID = Item.AssetID; |
306 | InventoryReply.InventoryData[0].CreatorID = Item.CreatorID; | 306 | InventoryReply.InventoryData[0].CreatorID = Item.CreatorID; |
307 | InventoryReply.InventoryData[0].BaseMask = FULL_MASK_PERMISSIONS; | 307 | InventoryReply.InventoryData[0].BaseMask = FULL_MASK_PERMISSIONS; |
308 | InventoryReply.InventoryData[0].CreationDate = 1000; | 308 | InventoryReply.InventoryData[0].CreationDate = 1000; |
309 | InventoryReply.InventoryData[0].Description = _enc.GetBytes(Item.Description + "\0"); | 309 | InventoryReply.InventoryData[0].Description = _enc.GetBytes(Item.Description + "\0"); |
310 | InventoryReply.InventoryData[0].EveryoneMask = FULL_MASK_PERMISSIONS; | 310 | InventoryReply.InventoryData[0].EveryoneMask = FULL_MASK_PERMISSIONS; |
311 | InventoryReply.InventoryData[0].Flags = 0; | 311 | InventoryReply.InventoryData[0].Flags = 0; |
312 | InventoryReply.InventoryData[0].FolderID = Item.FolderID; | 312 | InventoryReply.InventoryData[0].FolderID = Item.FolderID; |
313 | InventoryReply.InventoryData[0].GroupID = new LLUUID("00000000-0000-0000-0000-000000000000"); | 313 | InventoryReply.InventoryData[0].GroupID = new LLUUID("00000000-0000-0000-0000-000000000000"); |
314 | InventoryReply.InventoryData[0].GroupMask = FULL_MASK_PERMISSIONS; | 314 | InventoryReply.InventoryData[0].GroupMask = FULL_MASK_PERMISSIONS; |
315 | InventoryReply.InventoryData[0].InvType = Item.InvType; | 315 | InventoryReply.InventoryData[0].InvType = Item.InvType; |
316 | InventoryReply.InventoryData[0].Name = _enc.GetBytes(Item.Name + "\0"); | 316 | InventoryReply.InventoryData[0].Name = _enc.GetBytes(Item.Name + "\0"); |
317 | InventoryReply.InventoryData[0].NextOwnerMask = FULL_MASK_PERMISSIONS; | 317 | InventoryReply.InventoryData[0].NextOwnerMask = FULL_MASK_PERMISSIONS; |
318 | InventoryReply.InventoryData[0].OwnerID = Item.OwnerID; | 318 | InventoryReply.InventoryData[0].OwnerID = Item.OwnerID; |
319 | InventoryReply.InventoryData[0].OwnerMask = FULL_MASK_PERMISSIONS; | 319 | InventoryReply.InventoryData[0].OwnerMask = FULL_MASK_PERMISSIONS; |
320 | InventoryReply.InventoryData[0].SalePrice = 100; | 320 | InventoryReply.InventoryData[0].SalePrice = 100; |
321 | InventoryReply.InventoryData[0].SaleType = 0; | 321 | InventoryReply.InventoryData[0].SaleType = 0; |
322 | InventoryReply.InventoryData[0].Type = Item.Type; | 322 | InventoryReply.InventoryData[0].Type = Item.Type; |
323 | InventoryReply.InventoryData[0].CRC = Helpers.InventoryCRC(1000, 0, InventoryReply.InventoryData[0].InvType, InventoryReply.InventoryData[0].Type, InventoryReply.InventoryData[0].AssetID, InventoryReply.InventoryData[0].GroupID, 100, InventoryReply.InventoryData[0].OwnerID, InventoryReply.InventoryData[0].CreatorID, InventoryReply.InventoryData[0].ItemID, InventoryReply.InventoryData[0].FolderID, FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS); | 323 | InventoryReply.InventoryData[0].CRC = Helpers.InventoryCRC(1000, 0, InventoryReply.InventoryData[0].InvType, InventoryReply.InventoryData[0].Type, InventoryReply.InventoryData[0].AssetID, InventoryReply.InventoryData[0].GroupID, 100, InventoryReply.InventoryData[0].OwnerID, InventoryReply.InventoryData[0].CreatorID, InventoryReply.InventoryData[0].ItemID, InventoryReply.InventoryData[0].FolderID, FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS); |
324 | 324 | ||
325 | remoteClient.OutPacket(InventoryReply); | 325 | remoteClient.OutPacket(InventoryReply); |
326 | } | 326 | } |
327 | } | 327 | } |
328 | 328 | ||
329 | 329 | ||
330 | 330 | ||
331 | public class UserServerRequest | 331 | public class UserServerRequest |
332 | { | 332 | { |
333 | public UserServerRequest() | 333 | public UserServerRequest() |
334 | { | 334 | { |
335 | 335 | ||
336 | } | 336 | } |
337 | } | 337 | } |
338 | } | 338 | } |
diff --git a/OpenSim/Region/ClientStack/ClientStackNetworkHandler.cs b/OpenSim/Region/ClientStack/ClientStackNetworkHandler.cs index f4e537c..e3ad9d0 100644 --- a/OpenSim/Region/ClientStack/ClientStackNetworkHandler.cs +++ b/OpenSim/Region/ClientStack/ClientStackNetworkHandler.cs | |||
@@ -1,40 +1,40 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | 2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
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 | */ |
28 | using System.Net.Sockets; | 28 | using System.Net.Sockets; |
29 | 29 | ||
30 | namespace OpenSim.Region.ClientStack | 30 | namespace OpenSim.Region.ClientStack |
31 | { | 31 | { |
32 | 32 | ||
33 | public interface ClientStackNetworkHandler | 33 | public interface ClientStackNetworkHandler |
34 | { | 34 | { |
35 | void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode);// EndPoint packetSender); | 35 | void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode);// EndPoint packetSender); |
36 | void RemoveClientCircuit(uint circuitcode); | 36 | void RemoveClientCircuit(uint circuitcode); |
37 | void RegisterPacketServer(PacketServer server); | 37 | void RegisterPacketServer(PacketServer server); |
38 | } | 38 | } |
39 | 39 | ||
40 | } | 40 | } |
diff --git a/OpenSim/Region/ClientStack/ClientView.API.cs b/OpenSim/Region/ClientStack/ClientView.API.cs index 33e34c1..2ac1000 100644 --- a/OpenSim/Region/ClientStack/ClientView.API.cs +++ b/OpenSim/Region/ClientStack/ClientView.API.cs | |||
@@ -1,1180 +1,1180 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | 2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
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 | */ |
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Net; | 30 | using System.Net; |
31 | using System.Text; | 31 | using System.Text; |
32 | using Axiom.Math; | 32 | using Axiom.Math; |
33 | using libsecondlife; | 33 | using libsecondlife; |
34 | using libsecondlife.Packets; | 34 | using libsecondlife.Packets; |
35 | using OpenSim.Framework.Console; | 35 | using OpenSim.Framework.Console; |
36 | using OpenSim.Framework.Interfaces; | 36 | using OpenSim.Framework.Interfaces; |
37 | using OpenSim.Framework.Types; | 37 | using OpenSim.Framework.Types; |
38 | using OpenSim.Framework.Data; | 38 | using OpenSim.Framework.Data; |
39 | 39 | ||
40 | namespace OpenSim.Region.ClientStack | 40 | namespace OpenSim.Region.ClientStack |
41 | { | 41 | { |
42 | partial class ClientView | 42 | partial class ClientView |
43 | { | 43 | { |
44 | public event ImprovedInstantMessage OnInstantMessage; | 44 | public event ImprovedInstantMessage OnInstantMessage; |
45 | public event ChatFromViewer OnChatFromViewer; | 45 | public event ChatFromViewer OnChatFromViewer; |
46 | public event RezObject OnRezObject; | 46 | public event RezObject OnRezObject; |
47 | public event GenericCall4 OnDeRezObject; | 47 | public event GenericCall4 OnDeRezObject; |
48 | public event ModifyTerrain OnModifyTerrain; | 48 | public event ModifyTerrain OnModifyTerrain; |
49 | public event GenericCall OnRegionHandShakeReply; | 49 | public event GenericCall OnRegionHandShakeReply; |
50 | public event GenericCall OnRequestWearables; | 50 | public event GenericCall OnRequestWearables; |
51 | public event SetAppearance OnSetAppearance; | 51 | public event SetAppearance OnSetAppearance; |
52 | public event GenericCall2 OnCompleteMovementToRegion; | 52 | public event GenericCall2 OnCompleteMovementToRegion; |
53 | public event UpdateAgent OnAgentUpdate; | 53 | public event UpdateAgent OnAgentUpdate; |
54 | public event StartAnim OnStartAnim; | 54 | public event StartAnim OnStartAnim; |
55 | public event GenericCall OnRequestAvatarsData; | 55 | public event GenericCall OnRequestAvatarsData; |
56 | public event LinkObjects OnLinkObjects; | 56 | public event LinkObjects OnLinkObjects; |
57 | public event UpdateVector OnGrapObject; | 57 | public event UpdateVector OnGrapObject; |
58 | public event ObjectSelect OnDeGrapObject; | 58 | public event ObjectSelect OnDeGrapObject; |
59 | public event ObjectDuplicate OnObjectDuplicate; | 59 | public event ObjectDuplicate OnObjectDuplicate; |
60 | public event MoveObject OnGrapUpdate; | 60 | public event MoveObject OnGrapUpdate; |
61 | public event AddNewPrim OnAddPrim; | 61 | public event AddNewPrim OnAddPrim; |
62 | public event UpdateShape OnUpdatePrimShape; | 62 | public event UpdateShape OnUpdatePrimShape; |
63 | public event ObjectSelect OnObjectSelect; | 63 | public event ObjectSelect OnObjectSelect; |
64 | public event ObjectDeselect OnObjectDeselect; | 64 | public event ObjectDeselect OnObjectDeselect; |
65 | public event GenericCall7 OnObjectDescription; | 65 | public event GenericCall7 OnObjectDescription; |
66 | public event GenericCall7 OnObjectName; | 66 | public event GenericCall7 OnObjectName; |
67 | public event UpdatePrimFlags OnUpdatePrimFlags; | 67 | public event UpdatePrimFlags OnUpdatePrimFlags; |
68 | public event UpdatePrimTexture OnUpdatePrimTexture; | 68 | public event UpdatePrimTexture OnUpdatePrimTexture; |
69 | public event UpdateVector OnUpdatePrimGroupPosition; | 69 | public event UpdateVector OnUpdatePrimGroupPosition; |
70 | public event UpdateVector OnUpdatePrimSinglePosition; | 70 | public event UpdateVector OnUpdatePrimSinglePosition; |
71 | public event UpdatePrimRotation OnUpdatePrimGroupRotation; | 71 | public event UpdatePrimRotation OnUpdatePrimGroupRotation; |
72 | public event UpdatePrimSingleRotation OnUpdatePrimSingleRotation; | 72 | public event UpdatePrimSingleRotation OnUpdatePrimSingleRotation; |
73 | public event UpdatePrimGroupRotation OnUpdatePrimGroupMouseRotation; | 73 | public event UpdatePrimGroupRotation OnUpdatePrimGroupMouseRotation; |
74 | public event UpdateVector OnUpdatePrimScale; | 74 | public event UpdateVector OnUpdatePrimScale; |
75 | public event StatusChange OnChildAgentStatus; | 75 | public event StatusChange OnChildAgentStatus; |
76 | public event GenericCall2 OnStopMovement; | 76 | public event GenericCall2 OnStopMovement; |
77 | public event NewAvatar OnNewAvatar; | 77 | public event NewAvatar OnNewAvatar; |
78 | public event GenericCall6 OnRemoveAvatar; | 78 | public event GenericCall6 OnRemoveAvatar; |
79 | public event RequestMapBlocks OnRequestMapBlocks; | 79 | public event RequestMapBlocks OnRequestMapBlocks; |
80 | public event TeleportLocationRequest OnTeleportLocationRequest; | 80 | public event TeleportLocationRequest OnTeleportLocationRequest; |
81 | 81 | ||
82 | public event UUIDNameRequest OnNameFromUUIDRequest; | 82 | public event UUIDNameRequest OnNameFromUUIDRequest; |
83 | 83 | ||
84 | public event ParcelPropertiesRequest OnParcelPropertiesRequest; | 84 | public event ParcelPropertiesRequest OnParcelPropertiesRequest; |
85 | public event ParcelDivideRequest OnParcelDivideRequest; | 85 | public event ParcelDivideRequest OnParcelDivideRequest; |
86 | public event ParcelJoinRequest OnParcelJoinRequest; | 86 | public event ParcelJoinRequest OnParcelJoinRequest; |
87 | public event ParcelPropertiesUpdateRequest OnParcelPropertiesUpdateRequest; | 87 | public event ParcelPropertiesUpdateRequest OnParcelPropertiesUpdateRequest; |
88 | public event ParcelSelectObjects OnParcelSelectObjects; | 88 | public event ParcelSelectObjects OnParcelSelectObjects; |
89 | public event ParcelObjectOwnerRequest OnParcelObjectOwnerRequest; | 89 | public event ParcelObjectOwnerRequest OnParcelObjectOwnerRequest; |
90 | public event EstateOwnerMessageRequest OnEstateOwnerMessage; | 90 | public event EstateOwnerMessageRequest OnEstateOwnerMessage; |
91 | 91 | ||
92 | /// <summary> | 92 | /// <summary> |
93 | /// | 93 | /// |
94 | /// </summary> | 94 | /// </summary> |
95 | public LLVector3 StartPos | 95 | public LLVector3 StartPos |
96 | { | 96 | { |
97 | get | 97 | get |
98 | { | 98 | { |
99 | return startpos; | 99 | return startpos; |
100 | } | 100 | } |
101 | set | 101 | set |
102 | { | 102 | { |
103 | startpos = value; | 103 | startpos = value; |
104 | } | 104 | } |
105 | } | 105 | } |
106 | 106 | ||
107 | /// <summary> | 107 | /// <summary> |
108 | /// | 108 | /// |
109 | /// </summary> | 109 | /// </summary> |
110 | public LLUUID AgentId | 110 | public LLUUID AgentId |
111 | { | 111 | { |
112 | get | 112 | get |
113 | { | 113 | { |
114 | return this.AgentID; | 114 | return this.AgentID; |
115 | } | 115 | } |
116 | } | 116 | } |
117 | 117 | ||
118 | /// <summary> | 118 | /// <summary> |
119 | /// | 119 | /// |
120 | /// </summary> | 120 | /// </summary> |
121 | public string FirstName | 121 | public string FirstName |
122 | { | 122 | { |
123 | get | 123 | get |
124 | { | 124 | { |
125 | return this.firstName; | 125 | return this.firstName; |
126 | } | 126 | } |
127 | 127 | ||
128 | } | 128 | } |
129 | 129 | ||
130 | /// <summary> | 130 | /// <summary> |
131 | /// | 131 | /// |
132 | /// </summary> | 132 | /// </summary> |
133 | public string LastName | 133 | public string LastName |
134 | { | 134 | { |
135 | get | 135 | get |
136 | { | 136 | { |
137 | return this.lastName; | 137 | return this.lastName; |
138 | } | 138 | } |
139 | } | 139 | } |
140 | 140 | ||
141 | #region World/Avatar to Client | 141 | #region World/Avatar to Client |
142 | 142 | ||
143 | /// <summary> | 143 | /// <summary> |
144 | /// | 144 | /// |
145 | /// </summary> | 145 | /// </summary> |
146 | /// <param name="regionInfo"></param> | 146 | /// <param name="regionInfo"></param> |
147 | public void SendRegionHandshake(RegionInfo regionInfo) | 147 | public void SendRegionHandshake(RegionInfo regionInfo) |
148 | { | 148 | { |
149 | Encoding _enc = Encoding.ASCII; | 149 | Encoding _enc = Encoding.ASCII; |
150 | RegionHandshakePacket handshake = new RegionHandshakePacket(); | 150 | RegionHandshakePacket handshake = new RegionHandshakePacket(); |
151 | 151 | ||
152 | handshake.RegionInfo.BillableFactor = regionInfo.estateSettings.billableFactor; | 152 | handshake.RegionInfo.BillableFactor = regionInfo.estateSettings.billableFactor; |
153 | handshake.RegionInfo.IsEstateManager = false; | 153 | handshake.RegionInfo.IsEstateManager = false; |
154 | handshake.RegionInfo.TerrainHeightRange00 = regionInfo.estateSettings.terrainHeightRange0; | 154 | handshake.RegionInfo.TerrainHeightRange00 = regionInfo.estateSettings.terrainHeightRange0; |
155 | handshake.RegionInfo.TerrainHeightRange01 = regionInfo.estateSettings.terrainHeightRange1; | 155 | handshake.RegionInfo.TerrainHeightRange01 = regionInfo.estateSettings.terrainHeightRange1; |
156 | handshake.RegionInfo.TerrainHeightRange10 = regionInfo.estateSettings.terrainHeightRange2; | 156 | handshake.RegionInfo.TerrainHeightRange10 = regionInfo.estateSettings.terrainHeightRange2; |
157 | handshake.RegionInfo.TerrainHeightRange11 = regionInfo.estateSettings.terrainHeightRange3; | 157 | handshake.RegionInfo.TerrainHeightRange11 = regionInfo.estateSettings.terrainHeightRange3; |
158 | handshake.RegionInfo.TerrainStartHeight00 = regionInfo.estateSettings.terrainStartHeight0; | 158 | handshake.RegionInfo.TerrainStartHeight00 = regionInfo.estateSettings.terrainStartHeight0; |
159 | handshake.RegionInfo.TerrainStartHeight01 = regionInfo.estateSettings.terrainStartHeight1; | 159 | handshake.RegionInfo.TerrainStartHeight01 = regionInfo.estateSettings.terrainStartHeight1; |
160 | handshake.RegionInfo.TerrainStartHeight10 = regionInfo.estateSettings.terrainStartHeight2; | 160 | handshake.RegionInfo.TerrainStartHeight10 = regionInfo.estateSettings.terrainStartHeight2; |
161 | handshake.RegionInfo.TerrainStartHeight11 = regionInfo.estateSettings.terrainStartHeight3; | 161 | handshake.RegionInfo.TerrainStartHeight11 = regionInfo.estateSettings.terrainStartHeight3; |
162 | handshake.RegionInfo.SimAccess = (byte)regionInfo.estateSettings.simAccess; | 162 | handshake.RegionInfo.SimAccess = (byte)regionInfo.estateSettings.simAccess; |
163 | handshake.RegionInfo.WaterHeight = regionInfo.estateSettings.waterHeight; | 163 | handshake.RegionInfo.WaterHeight = regionInfo.estateSettings.waterHeight; |
164 | 164 | ||
165 | 165 | ||
166 | handshake.RegionInfo.RegionFlags = (uint)regionInfo.estateSettings.regionFlags; | 166 | handshake.RegionInfo.RegionFlags = (uint)regionInfo.estateSettings.regionFlags; |
167 | 167 | ||
168 | handshake.RegionInfo.SimName = _enc.GetBytes(regionInfo.RegionName + "\0"); | 168 | handshake.RegionInfo.SimName = _enc.GetBytes(regionInfo.RegionName + "\0"); |
169 | handshake.RegionInfo.SimOwner = regionInfo.MasterAvatarAssignedUUID; | 169 | handshake.RegionInfo.SimOwner = regionInfo.MasterAvatarAssignedUUID; |
170 | handshake.RegionInfo.TerrainBase0 = regionInfo.estateSettings.terrainBase0; | 170 | handshake.RegionInfo.TerrainBase0 = regionInfo.estateSettings.terrainBase0; |
171 | handshake.RegionInfo.TerrainBase1 = regionInfo.estateSettings.terrainBase1; | 171 | handshake.RegionInfo.TerrainBase1 = regionInfo.estateSettings.terrainBase1; |
172 | handshake.RegionInfo.TerrainBase2 = regionInfo.estateSettings.terrainBase2; | 172 | handshake.RegionInfo.TerrainBase2 = regionInfo.estateSettings.terrainBase2; |
173 | handshake.RegionInfo.TerrainBase3 = regionInfo.estateSettings.terrainBase3; | 173 | handshake.RegionInfo.TerrainBase3 = regionInfo.estateSettings.terrainBase3; |
174 | handshake.RegionInfo.TerrainDetail0 = regionInfo.estateSettings.terrainDetail0; | 174 | handshake.RegionInfo.TerrainDetail0 = regionInfo.estateSettings.terrainDetail0; |
175 | handshake.RegionInfo.TerrainDetail1 = regionInfo.estateSettings.terrainDetail1; | 175 | handshake.RegionInfo.TerrainDetail1 = regionInfo.estateSettings.terrainDetail1; |
176 | handshake.RegionInfo.TerrainDetail2 = regionInfo.estateSettings.terrainDetail2; | 176 | handshake.RegionInfo.TerrainDetail2 = regionInfo.estateSettings.terrainDetail2; |
177 | handshake.RegionInfo.TerrainDetail3 = regionInfo.estateSettings.terrainDetail3; | 177 | handshake.RegionInfo.TerrainDetail3 = regionInfo.estateSettings.terrainDetail3; |
178 | handshake.RegionInfo.CacheID = LLUUID.Random(); //I guess this is for the client to remember an old setting? | 178 | handshake.RegionInfo.CacheID = LLUUID.Random(); //I guess this is for the client to remember an old setting? |
179 | 179 | ||
180 | this.OutPacket(handshake); | 180 | this.OutPacket(handshake); |
181 | } | 181 | } |
182 | 182 | ||
183 | /// <summary> | 183 | /// <summary> |
184 | /// | 184 | /// |
185 | /// </summary> | 185 | /// </summary> |
186 | /// <param name="regInfo"></param> | 186 | /// <param name="regInfo"></param> |
187 | public void MoveAgentIntoRegion(RegionInfo regInfo, LLVector3 pos, LLVector3 look) | 187 | public void MoveAgentIntoRegion(RegionInfo regInfo, LLVector3 pos, LLVector3 look) |
188 | { | 188 | { |
189 | AgentMovementCompletePacket mov = new AgentMovementCompletePacket(); | 189 | AgentMovementCompletePacket mov = new AgentMovementCompletePacket(); |
190 | mov.AgentData.SessionID = this.SessionID; | 190 | mov.AgentData.SessionID = this.SessionID; |
191 | mov.AgentData.AgentID = this.AgentID; | 191 | mov.AgentData.AgentID = this.AgentID; |
192 | mov.Data.RegionHandle = regInfo.RegionHandle; | 192 | mov.Data.RegionHandle = regInfo.RegionHandle; |
193 | mov.Data.Timestamp = 1172750370; // TODO - dynamicalise this | 193 | mov.Data.Timestamp = 1172750370; // TODO - dynamicalise this |
194 | 194 | ||
195 | if ((pos.X == 0) && (pos.Y == 0) && (pos.Z == 0)) | 195 | if ((pos.X == 0) && (pos.Y == 0) && (pos.Z == 0)) |
196 | { | 196 | { |
197 | mov.Data.Position = this.startpos; | 197 | mov.Data.Position = this.startpos; |
198 | } | 198 | } |
199 | else | 199 | else |
200 | { | 200 | { |
201 | mov.Data.Position = pos; | 201 | mov.Data.Position = pos; |
202 | } | 202 | } |
203 | mov.Data.LookAt = look; | 203 | mov.Data.LookAt = look; |
204 | 204 | ||
205 | OutPacket(mov); | 205 | OutPacket(mov); |
206 | } | 206 | } |
207 | 207 | ||
208 | /// <summary> | 208 | /// <summary> |
209 | /// | 209 | /// |
210 | /// </summary> | 210 | /// </summary> |
211 | /// <param name="message"></param> | 211 | /// <param name="message"></param> |
212 | /// <param name="type"></param> | 212 | /// <param name="type"></param> |
213 | /// <param name="fromPos"></param> | 213 | /// <param name="fromPos"></param> |
214 | /// <param name="fromName"></param> | 214 | /// <param name="fromName"></param> |
215 | /// <param name="fromAgentID"></param> | 215 | /// <param name="fromAgentID"></param> |
216 | public void SendChatMessage(string message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID) | 216 | public void SendChatMessage(string message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID) |
217 | { | 217 | { |
218 | SendChatMessage(Helpers.StringToField(message), type, fromPos, fromName, fromAgentID); | 218 | SendChatMessage(Helpers.StringToField(message), type, fromPos, fromName, fromAgentID); |
219 | } | 219 | } |
220 | 220 | ||
221 | /// <summary> | 221 | /// <summary> |
222 | /// | 222 | /// |
223 | /// </summary> | 223 | /// </summary> |
224 | /// <param name="message"></param> | 224 | /// <param name="message"></param> |
225 | /// <param name="type"></param> | 225 | /// <param name="type"></param> |
226 | /// <param name="fromPos"></param> | 226 | /// <param name="fromPos"></param> |
227 | /// <param name="fromName"></param> | 227 | /// <param name="fromName"></param> |
228 | /// <param name="fromAgentID"></param> | 228 | /// <param name="fromAgentID"></param> |
229 | public void SendChatMessage(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID) | 229 | public void SendChatMessage(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID) |
230 | { | 230 | { |
231 | Encoding enc = Encoding.ASCII; | 231 | Encoding enc = Encoding.ASCII; |
232 | ChatFromSimulatorPacket reply = new ChatFromSimulatorPacket(); | 232 | ChatFromSimulatorPacket reply = new ChatFromSimulatorPacket(); |
233 | reply.ChatData.Audible = 1; | 233 | reply.ChatData.Audible = 1; |
234 | reply.ChatData.Message = message; | 234 | reply.ChatData.Message = message; |
235 | reply.ChatData.ChatType = type; | 235 | reply.ChatData.ChatType = type; |
236 | reply.ChatData.SourceType = 1; | 236 | reply.ChatData.SourceType = 1; |
237 | reply.ChatData.Position = fromPos; | 237 | reply.ChatData.Position = fromPos; |
238 | reply.ChatData.FromName = enc.GetBytes(fromName + "\0"); | 238 | reply.ChatData.FromName = enc.GetBytes(fromName + "\0"); |
239 | reply.ChatData.OwnerID = fromAgentID; | 239 | reply.ChatData.OwnerID = fromAgentID; |
240 | reply.ChatData.SourceID = fromAgentID; | 240 | reply.ChatData.SourceID = fromAgentID; |
241 | 241 | ||
242 | this.OutPacket(reply); | 242 | this.OutPacket(reply); |
243 | } | 243 | } |
244 | 244 | ||
245 | /// <summary> | 245 | /// <summary> |
246 | /// | 246 | /// |
247 | /// </summary> | 247 | /// </summary> |
248 | /// <remarks>TODO</remarks> | 248 | /// <remarks>TODO</remarks> |
249 | /// <param name="message"></param> | 249 | /// <param name="message"></param> |
250 | /// <param name="target"></param> | 250 | /// <param name="target"></param> |
251 | public void SendInstantMessage(string message, LLUUID target, string fromName) | 251 | public void SendInstantMessage(string message, LLUUID target, string fromName) |
252 | { | 252 | { |
253 | if (message != "typing") | 253 | if (message != "typing") |
254 | { | 254 | { |
255 | Encoding enc = Encoding.ASCII; | 255 | Encoding enc = Encoding.ASCII; |
256 | ImprovedInstantMessagePacket msg = new ImprovedInstantMessagePacket(); | 256 | ImprovedInstantMessagePacket msg = new ImprovedInstantMessagePacket(); |
257 | msg.AgentData.AgentID = this.AgentID; | 257 | msg.AgentData.AgentID = this.AgentID; |
258 | msg.AgentData.SessionID = this.SessionID; | 258 | msg.AgentData.SessionID = this.SessionID; |
259 | msg.MessageBlock.FromAgentName = enc.GetBytes(fromName + " \0"); | 259 | msg.MessageBlock.FromAgentName = enc.GetBytes(fromName + " \0"); |
260 | msg.MessageBlock.Dialog = 0; | 260 | msg.MessageBlock.Dialog = 0; |
261 | msg.MessageBlock.FromGroup = false; | 261 | msg.MessageBlock.FromGroup = false; |
262 | msg.MessageBlock.ID = target.Combine(this.SecureSessionID); | 262 | msg.MessageBlock.ID = target.Combine(this.SecureSessionID); |
263 | msg.MessageBlock.Offline = 0; | 263 | msg.MessageBlock.Offline = 0; |
264 | msg.MessageBlock.ParentEstateID = 0; | 264 | msg.MessageBlock.ParentEstateID = 0; |
265 | msg.MessageBlock.Position = new LLVector3(); | 265 | msg.MessageBlock.Position = new LLVector3(); |
266 | msg.MessageBlock.RegionID = new LLUUID(); | 266 | msg.MessageBlock.RegionID = new LLUUID(); |
267 | msg.MessageBlock.Timestamp = 0; | 267 | msg.MessageBlock.Timestamp = 0; |
268 | msg.MessageBlock.ToAgentID = target; | 268 | msg.MessageBlock.ToAgentID = target; |
269 | msg.MessageBlock.Message = enc.GetBytes(message + "\0"); | 269 | msg.MessageBlock.Message = enc.GetBytes(message + "\0"); |
270 | msg.MessageBlock.BinaryBucket = new byte[0]; | 270 | msg.MessageBlock.BinaryBucket = new byte[0]; |
271 | 271 | ||
272 | this.OutPacket(msg); | 272 | this.OutPacket(msg); |
273 | } | 273 | } |
274 | } | 274 | } |
275 | 275 | ||
276 | /// <summary> | 276 | /// <summary> |
277 | /// Send the region heightmap to the client | 277 | /// Send the region heightmap to the client |
278 | /// </summary> | 278 | /// </summary> |
279 | /// <param name="map">heightmap</param> | 279 | /// <param name="map">heightmap</param> |
280 | public virtual void SendLayerData(float[] map) | 280 | public virtual void SendLayerData(float[] map) |
281 | { | 281 | { |
282 | try | 282 | try |
283 | { | 283 | { |
284 | int[] patches = new int[4]; | 284 | int[] patches = new int[4]; |
285 | 285 | ||
286 | for (int y = 0; y < 16; y++) | 286 | for (int y = 0; y < 16; y++) |
287 | { | 287 | { |
288 | for (int x = 0; x < 16; x = x + 4) | 288 | for (int x = 0; x < 16; x = x + 4) |
289 | { | 289 | { |
290 | patches[0] = x + 0 + y * 16; | 290 | patches[0] = x + 0 + y * 16; |
291 | patches[1] = x + 1 + y * 16; | 291 | patches[1] = x + 1 + y * 16; |
292 | patches[2] = x + 2 + y * 16; | 292 | patches[2] = x + 2 + y * 16; |
293 | patches[3] = x + 3 + y * 16; | 293 | patches[3] = x + 3 + y * 16; |
294 | 294 | ||
295 | Packet layerpack = TerrainManager.CreateLandPacket(map, patches); | 295 | Packet layerpack = TerrainManager.CreateLandPacket(map, patches); |
296 | OutPacket(layerpack); | 296 | OutPacket(layerpack); |
297 | } | 297 | } |
298 | } | 298 | } |
299 | } | 299 | } |
300 | catch (Exception e) | 300 | catch (Exception e) |
301 | { | 301 | { |
302 | MainLog.Instance.Warn("ClientView API.cs: SendLayerData() - Failed with exception " + e.ToString()); | 302 | MainLog.Instance.Warn("ClientView API.cs: SendLayerData() - Failed with exception " + e.ToString()); |
303 | } | 303 | } |
304 | } | 304 | } |
305 | 305 | ||
306 | /// <summary> | 306 | /// <summary> |
307 | /// Sends a specified patch to a client | 307 | /// Sends a specified patch to a client |
308 | /// </summary> | 308 | /// </summary> |
309 | /// <param name="px">Patch coordinate (x) 0..16</param> | 309 | /// <param name="px">Patch coordinate (x) 0..16</param> |
310 | /// <param name="py">Patch coordinate (y) 0..16</param> | 310 | /// <param name="py">Patch coordinate (y) 0..16</param> |
311 | /// <param name="map">heightmap</param> | 311 | /// <param name="map">heightmap</param> |
312 | public void SendLayerData(int px, int py, float[] map) | 312 | public void SendLayerData(int px, int py, float[] map) |
313 | { | 313 | { |
314 | try | 314 | try |
315 | { | 315 | { |
316 | int[] patches = new int[1]; | 316 | int[] patches = new int[1]; |
317 | int patchx, patchy; | 317 | int patchx, patchy; |
318 | patchx = px / 16; | 318 | patchx = px / 16; |
319 | patchy = py / 16; | 319 | patchy = py / 16; |
320 | 320 | ||
321 | patches[0] = patchx + 0 + patchy * 16; | 321 | patches[0] = patchx + 0 + patchy * 16; |
322 | 322 | ||
323 | Packet layerpack = TerrainManager.CreateLandPacket(map, patches); | 323 | Packet layerpack = TerrainManager.CreateLandPacket(map, patches); |
324 | OutPacket(layerpack); | 324 | OutPacket(layerpack); |
325 | } | 325 | } |
326 | catch (Exception e) | 326 | catch (Exception e) |
327 | { | 327 | { |
328 | MainLog.Instance.Warn("ClientView API .cs: SendLayerData() - Failed with exception " + e.ToString()); | 328 | MainLog.Instance.Warn("ClientView API .cs: SendLayerData() - Failed with exception " + e.ToString()); |
329 | } | 329 | } |
330 | } | 330 | } |
331 | 331 | ||
332 | /// <summary> | 332 | /// <summary> |
333 | /// | 333 | /// |
334 | /// </summary> | 334 | /// </summary> |
335 | /// <param name="neighbourHandle"></param> | 335 | /// <param name="neighbourHandle"></param> |
336 | /// <param name="neighbourIP"></param> | 336 | /// <param name="neighbourIP"></param> |
337 | /// <param name="neighbourPort"></param> | 337 | /// <param name="neighbourPort"></param> |
338 | public void InformClientOfNeighbour(ulong neighbourHandle, IPEndPoint neighbourEndPoint) | 338 | public void InformClientOfNeighbour(ulong neighbourHandle, IPEndPoint neighbourEndPoint) |
339 | { | 339 | { |
340 | IPAddress neighbourIP = neighbourEndPoint.Address; | 340 | IPAddress neighbourIP = neighbourEndPoint.Address; |
341 | ushort neighbourPort = (ushort)neighbourEndPoint.Port; | 341 | ushort neighbourPort = (ushort)neighbourEndPoint.Port; |
342 | 342 | ||
343 | EnableSimulatorPacket enablesimpacket = new EnableSimulatorPacket(); | 343 | EnableSimulatorPacket enablesimpacket = new EnableSimulatorPacket(); |
344 | enablesimpacket.SimulatorInfo = new EnableSimulatorPacket.SimulatorInfoBlock(); | 344 | enablesimpacket.SimulatorInfo = new EnableSimulatorPacket.SimulatorInfoBlock(); |
345 | enablesimpacket.SimulatorInfo.Handle = neighbourHandle; | 345 | enablesimpacket.SimulatorInfo.Handle = neighbourHandle; |
346 | 346 | ||
347 | byte[] byteIP = neighbourIP.GetAddressBytes(); | 347 | byte[] byteIP = neighbourIP.GetAddressBytes(); |
348 | enablesimpacket.SimulatorInfo.IP = (uint)byteIP[3] << 24; | 348 | enablesimpacket.SimulatorInfo.IP = (uint)byteIP[3] << 24; |
349 | enablesimpacket.SimulatorInfo.IP += (uint)byteIP[2] << 16; | 349 | enablesimpacket.SimulatorInfo.IP += (uint)byteIP[2] << 16; |
350 | enablesimpacket.SimulatorInfo.IP += (uint)byteIP[1] << 8; | 350 | enablesimpacket.SimulatorInfo.IP += (uint)byteIP[1] << 8; |
351 | enablesimpacket.SimulatorInfo.IP += (uint)byteIP[0]; | 351 | enablesimpacket.SimulatorInfo.IP += (uint)byteIP[0]; |
352 | enablesimpacket.SimulatorInfo.Port = neighbourPort; | 352 | enablesimpacket.SimulatorInfo.Port = neighbourPort; |
353 | OutPacket(enablesimpacket); | 353 | OutPacket(enablesimpacket); |
354 | } | 354 | } |
355 | 355 | ||
356 | /// <summary> | 356 | /// <summary> |
357 | /// | 357 | /// |
358 | /// </summary> | 358 | /// </summary> |
359 | /// <returns></returns> | 359 | /// <returns></returns> |
360 | public AgentCircuitData RequestClientInfo() | 360 | public AgentCircuitData RequestClientInfo() |
361 | { | 361 | { |
362 | AgentCircuitData agentData = new AgentCircuitData(); | 362 | AgentCircuitData agentData = new AgentCircuitData(); |
363 | agentData.AgentID = this.AgentId; | 363 | agentData.AgentID = this.AgentId; |
364 | agentData.SessionID = this.SessionID; | 364 | agentData.SessionID = this.SessionID; |
365 | agentData.SecureSessionID = this.SecureSessionID; | 365 | agentData.SecureSessionID = this.SecureSessionID; |
366 | agentData.circuitcode = this.CircuitCode; | 366 | agentData.circuitcode = this.CircuitCode; |
367 | agentData.child = false; | 367 | agentData.child = false; |
368 | agentData.firstname = this.firstName; | 368 | agentData.firstname = this.firstName; |
369 | agentData.lastname = this.lastName; | 369 | agentData.lastname = this.lastName; |
370 | 370 | ||
371 | return agentData; | 371 | return agentData; |
372 | } | 372 | } |
373 | 373 | ||
374 | public void CrossRegion(ulong newRegionHandle, LLVector3 pos, LLVector3 lookAt, IPEndPoint externalIPEndPoint) | 374 | public void CrossRegion(ulong newRegionHandle, LLVector3 pos, LLVector3 lookAt, IPEndPoint externalIPEndPoint) |
375 | { | 375 | { |
376 | LLVector3 look = new LLVector3(lookAt.X * 10, lookAt.Y * 10, lookAt.Z * 10); | 376 | LLVector3 look = new LLVector3(lookAt.X * 10, lookAt.Y * 10, lookAt.Z * 10); |
377 | 377 | ||
378 | CrossedRegionPacket newSimPack = new CrossedRegionPacket(); | 378 | CrossedRegionPacket newSimPack = new CrossedRegionPacket(); |
379 | newSimPack.AgentData = new CrossedRegionPacket.AgentDataBlock(); | 379 | newSimPack.AgentData = new CrossedRegionPacket.AgentDataBlock(); |
380 | newSimPack.AgentData.AgentID = this.AgentID; | 380 | newSimPack.AgentData.AgentID = this.AgentID; |
381 | newSimPack.AgentData.SessionID = this.SessionID; | 381 | newSimPack.AgentData.SessionID = this.SessionID; |
382 | newSimPack.Info = new CrossedRegionPacket.InfoBlock(); | 382 | newSimPack.Info = new CrossedRegionPacket.InfoBlock(); |
383 | newSimPack.Info.Position = pos; | 383 | newSimPack.Info.Position = pos; |
384 | newSimPack.Info.LookAt = look; // new LLVector3(0.0f, 0.0f, 0.0f); // copied from Avatar.cs - SHOULD BE DYNAMIC!!!!!!!!!! | 384 | newSimPack.Info.LookAt = look; // new LLVector3(0.0f, 0.0f, 0.0f); // copied from Avatar.cs - SHOULD BE DYNAMIC!!!!!!!!!! |
385 | newSimPack.RegionData = new CrossedRegionPacket.RegionDataBlock(); | 385 | newSimPack.RegionData = new CrossedRegionPacket.RegionDataBlock(); |
386 | newSimPack.RegionData.RegionHandle = newRegionHandle; | 386 | newSimPack.RegionData.RegionHandle = newRegionHandle; |
387 | byte[] byteIP = externalIPEndPoint.Address.GetAddressBytes(); | 387 | byte[] byteIP = externalIPEndPoint.Address.GetAddressBytes(); |
388 | newSimPack.RegionData.SimIP = (uint)byteIP[3] << 24; | 388 | newSimPack.RegionData.SimIP = (uint)byteIP[3] << 24; |
389 | newSimPack.RegionData.SimIP += (uint)byteIP[2] << 16; | 389 | newSimPack.RegionData.SimIP += (uint)byteIP[2] << 16; |
390 | newSimPack.RegionData.SimIP += (uint)byteIP[1] << 8; | 390 | newSimPack.RegionData.SimIP += (uint)byteIP[1] << 8; |
391 | newSimPack.RegionData.SimIP += (uint)byteIP[0]; | 391 | newSimPack.RegionData.SimIP += (uint)byteIP[0]; |
392 | newSimPack.RegionData.SimPort = (ushort)externalIPEndPoint.Port; | 392 | newSimPack.RegionData.SimPort = (ushort)externalIPEndPoint.Port; |
393 | newSimPack.RegionData.SeedCapability = new byte[0]; | 393 | newSimPack.RegionData.SeedCapability = new byte[0]; |
394 | 394 | ||
395 | this.OutPacket(newSimPack); | 395 | this.OutPacket(newSimPack); |
396 | //this.DowngradeClient(); | 396 | //this.DowngradeClient(); |
397 | } | 397 | } |
398 | 398 | ||
399 | public void SendMapBlock(List<MapBlockData> mapBlocks) | 399 | public void SendMapBlock(List<MapBlockData> mapBlocks) |
400 | { | 400 | { |
401 | MapBlockReplyPacket mapReply = new MapBlockReplyPacket(); | 401 | MapBlockReplyPacket mapReply = new MapBlockReplyPacket(); |
402 | mapReply.AgentData.AgentID = this.AgentID; | 402 | mapReply.AgentData.AgentID = this.AgentID; |
403 | mapReply.Data = new MapBlockReplyPacket.DataBlock[mapBlocks.Count]; | 403 | mapReply.Data = new MapBlockReplyPacket.DataBlock[mapBlocks.Count]; |
404 | mapReply.AgentData.Flags = 0; | 404 | mapReply.AgentData.Flags = 0; |
405 | 405 | ||
406 | for (int i = 0; i < mapBlocks.Count; i++) | 406 | for (int i = 0; i < mapBlocks.Count; i++) |
407 | { | 407 | { |
408 | mapReply.Data[i] = new MapBlockReplyPacket.DataBlock(); | 408 | mapReply.Data[i] = new MapBlockReplyPacket.DataBlock(); |
409 | mapReply.Data[i].MapImageID = mapBlocks[i].MapImageId; | 409 | mapReply.Data[i].MapImageID = mapBlocks[i].MapImageId; |
410 | mapReply.Data[i].X = mapBlocks[i].X; | 410 | mapReply.Data[i].X = mapBlocks[i].X; |
411 | mapReply.Data[i].Y = mapBlocks[i].Y; | 411 | mapReply.Data[i].Y = mapBlocks[i].Y; |
412 | mapReply.Data[i].WaterHeight = mapBlocks[i].WaterHeight; | 412 | mapReply.Data[i].WaterHeight = mapBlocks[i].WaterHeight; |
413 | mapReply.Data[i].Name = Helpers.StringToField(mapBlocks[i].Name); | 413 | mapReply.Data[i].Name = Helpers.StringToField(mapBlocks[i].Name); |
414 | mapReply.Data[i].RegionFlags = mapBlocks[i].RegionFlags; | 414 | mapReply.Data[i].RegionFlags = mapBlocks[i].RegionFlags; |
415 | mapReply.Data[i].Access = mapBlocks[i].Access; | 415 | mapReply.Data[i].Access = mapBlocks[i].Access; |
416 | mapReply.Data[i].Agents = mapBlocks[i].Agents; | 416 | mapReply.Data[i].Agents = mapBlocks[i].Agents; |
417 | } | 417 | } |
418 | this.OutPacket(mapReply); | 418 | this.OutPacket(mapReply); |
419 | } | 419 | } |
420 | 420 | ||
421 | public void SendLocalTeleport(LLVector3 position, LLVector3 lookAt, uint flags) | 421 | public void SendLocalTeleport(LLVector3 position, LLVector3 lookAt, uint flags) |
422 | { | 422 | { |
423 | TeleportLocalPacket tpLocal = new TeleportLocalPacket(); | 423 | TeleportLocalPacket tpLocal = new TeleportLocalPacket(); |
424 | tpLocal.Info.AgentID = this.AgentID; | 424 | tpLocal.Info.AgentID = this.AgentID; |
425 | tpLocal.Info.TeleportFlags = flags; | 425 | tpLocal.Info.TeleportFlags = flags; |
426 | tpLocal.Info.LocationID = 2; | 426 | tpLocal.Info.LocationID = 2; |
427 | tpLocal.Info.LookAt = lookAt; | 427 | tpLocal.Info.LookAt = lookAt; |
428 | tpLocal.Info.Position = position; | 428 | tpLocal.Info.Position = position; |
429 | OutPacket(tpLocal); | 429 | OutPacket(tpLocal); |
430 | } | 430 | } |
431 | 431 | ||
432 | public void SendRegionTeleport(ulong regionHandle, byte simAccess, IPEndPoint newRegionEndPoint, uint locationID, uint flags) | 432 | public void SendRegionTeleport(ulong regionHandle, byte simAccess, IPEndPoint newRegionEndPoint, uint locationID, uint flags) |
433 | { | 433 | { |
434 | TeleportFinishPacket teleport = new TeleportFinishPacket(); | 434 | TeleportFinishPacket teleport = new TeleportFinishPacket(); |
435 | teleport.Info.AgentID = this.AgentID; | 435 | teleport.Info.AgentID = this.AgentID; |
436 | teleport.Info.RegionHandle = regionHandle; | 436 | teleport.Info.RegionHandle = regionHandle; |
437 | teleport.Info.SimAccess = simAccess; | 437 | teleport.Info.SimAccess = simAccess; |
438 | teleport.Info.SeedCapability = new byte[0]; | 438 | teleport.Info.SeedCapability = new byte[0]; |
439 | 439 | ||
440 | IPAddress oIP = newRegionEndPoint.Address; | 440 | IPAddress oIP = newRegionEndPoint.Address; |
441 | byte[] byteIP = oIP.GetAddressBytes(); | 441 | byte[] byteIP = oIP.GetAddressBytes(); |
442 | uint ip = (uint)byteIP[3] << 24; | 442 | uint ip = (uint)byteIP[3] << 24; |
443 | ip += (uint)byteIP[2] << 16; | 443 | ip += (uint)byteIP[2] << 16; |
444 | ip += (uint)byteIP[1] << 8; | 444 | ip += (uint)byteIP[1] << 8; |
445 | ip += (uint)byteIP[0]; | 445 | ip += (uint)byteIP[0]; |
446 | 446 | ||
447 | teleport.Info.SimIP = ip; | 447 | teleport.Info.SimIP = ip; |
448 | teleport.Info.SimPort = (ushort)newRegionEndPoint.Port; | 448 | teleport.Info.SimPort = (ushort)newRegionEndPoint.Port; |
449 | teleport.Info.LocationID = 4; | 449 | teleport.Info.LocationID = 4; |
450 | teleport.Info.TeleportFlags = 1 << 4; | 450 | teleport.Info.TeleportFlags = 1 << 4; |
451 | OutPacket(teleport); | 451 | OutPacket(teleport); |
452 | } | 452 | } |
453 | 453 | ||
454 | /// <summary> | 454 | /// <summary> |
455 | /// | 455 | /// |
456 | /// </summary> | 456 | /// </summary> |
457 | public void SendTeleportCancel() | 457 | public void SendTeleportCancel() |
458 | { | 458 | { |
459 | TeleportCancelPacket tpCancel = new TeleportCancelPacket(); | 459 | TeleportCancelPacket tpCancel = new TeleportCancelPacket(); |
460 | tpCancel.Info.SessionID = this.SessionID; | 460 | tpCancel.Info.SessionID = this.SessionID; |
461 | tpCancel.Info.AgentID = this.AgentID; | 461 | tpCancel.Info.AgentID = this.AgentID; |
462 | 462 | ||
463 | OutPacket(tpCancel); | 463 | OutPacket(tpCancel); |
464 | } | 464 | } |
465 | 465 | ||
466 | /// <summary> | 466 | /// <summary> |
467 | /// | 467 | /// |
468 | /// </summary> | 468 | /// </summary> |
469 | public void SendTeleportLocationStart() | 469 | public void SendTeleportLocationStart() |
470 | { | 470 | { |
471 | TeleportStartPacket tpStart = new TeleportStartPacket(); | 471 | TeleportStartPacket tpStart = new TeleportStartPacket(); |
472 | tpStart.Info.TeleportFlags = 16; // Teleport via location | 472 | tpStart.Info.TeleportFlags = 16; // Teleport via location |
473 | OutPacket(tpStart); | 473 | OutPacket(tpStart); |
474 | } | 474 | } |
475 | 475 | ||
476 | public void SendMoneyBalance(LLUUID transaction, bool success, byte[] description, int balance) | 476 | public void SendMoneyBalance(LLUUID transaction, bool success, byte[] description, int balance) |
477 | { | 477 | { |
478 | MoneyBalanceReplyPacket money = new MoneyBalanceReplyPacket(); | 478 | MoneyBalanceReplyPacket money = new MoneyBalanceReplyPacket(); |
479 | money.MoneyData.AgentID = this.AgentID; | 479 | money.MoneyData.AgentID = this.AgentID; |
480 | money.MoneyData.TransactionID = transaction; | 480 | money.MoneyData.TransactionID = transaction; |
481 | money.MoneyData.TransactionSuccess = success; | 481 | money.MoneyData.TransactionSuccess = success; |
482 | money.MoneyData.Description = description; | 482 | money.MoneyData.Description = description; |
483 | money.MoneyData.MoneyBalance = balance; | 483 | money.MoneyData.MoneyBalance = balance; |
484 | OutPacket(money); | 484 | OutPacket(money); |
485 | } | 485 | } |
486 | 486 | ||
487 | public void SendStartPingCheck(byte seq) | 487 | public void SendStartPingCheck(byte seq) |
488 | { | 488 | { |
489 | StartPingCheckPacket pc = new StartPingCheckPacket(); | 489 | StartPingCheckPacket pc = new StartPingCheckPacket(); |
490 | pc.PingID.PingID = seq; | 490 | pc.PingID.PingID = seq; |
491 | OutPacket(pc); | 491 | OutPacket(pc); |
492 | } | 492 | } |
493 | 493 | ||
494 | public void SendKillObject(ulong regionHandle, uint avatarLocalID) | 494 | public void SendKillObject(ulong regionHandle, uint avatarLocalID) |
495 | { | 495 | { |
496 | KillObjectPacket kill = new KillObjectPacket(); | 496 | KillObjectPacket kill = new KillObjectPacket(); |
497 | kill.ObjectData = new KillObjectPacket.ObjectDataBlock[1]; | 497 | kill.ObjectData = new KillObjectPacket.ObjectDataBlock[1]; |
498 | kill.ObjectData[0] = new KillObjectPacket.ObjectDataBlock(); | 498 | kill.ObjectData[0] = new KillObjectPacket.ObjectDataBlock(); |
499 | kill.ObjectData[0].ID = avatarLocalID; | 499 | kill.ObjectData[0].ID = avatarLocalID; |
500 | OutPacket(kill); | 500 | OutPacket(kill); |
501 | } | 501 | } |
502 | 502 | ||
503 | public void SendInventoryFolderDetails(LLUUID ownerID, LLUUID folderID, List<InventoryItemBase> items) | 503 | public void SendInventoryFolderDetails(LLUUID ownerID, LLUUID folderID, List<InventoryItemBase> items) |
504 | { | 504 | { |
505 | Encoding enc = Encoding.ASCII; | 505 | Encoding enc = Encoding.ASCII; |
506 | uint FULL_MASK_PERMISSIONS = 2147483647; | 506 | uint FULL_MASK_PERMISSIONS = 2147483647; |
507 | InventoryDescendentsPacket descend = new InventoryDescendentsPacket(); | 507 | InventoryDescendentsPacket descend = new InventoryDescendentsPacket(); |
508 | descend.AgentData.AgentID = this.AgentId; | 508 | descend.AgentData.AgentID = this.AgentId; |
509 | descend.AgentData.OwnerID = ownerID; | 509 | descend.AgentData.OwnerID = ownerID; |
510 | descend.AgentData.FolderID = folderID; | 510 | descend.AgentData.FolderID = folderID; |
511 | descend.AgentData.Descendents = items.Count; | 511 | descend.AgentData.Descendents = items.Count; |
512 | descend.AgentData.Version = 0; | 512 | descend.AgentData.Version = 0; |
513 | descend.ItemData = new InventoryDescendentsPacket.ItemDataBlock[items.Count]; | 513 | descend.ItemData = new InventoryDescendentsPacket.ItemDataBlock[items.Count]; |
514 | int i = 0; | 514 | int i = 0; |
515 | foreach (InventoryItemBase item in items) | 515 | foreach (InventoryItemBase item in items) |
516 | { | 516 | { |
517 | descend.ItemData[i] = new InventoryDescendentsPacket.ItemDataBlock(); | 517 | descend.ItemData[i] = new InventoryDescendentsPacket.ItemDataBlock(); |
518 | descend.ItemData[i].ItemID = item.inventoryID; | 518 | descend.ItemData[i].ItemID = item.inventoryID; |
519 | descend.ItemData[i].AssetID = item.assetID; | 519 | descend.ItemData[i].AssetID = item.assetID; |
520 | descend.ItemData[i].CreatorID = item.creatorsID; | 520 | descend.ItemData[i].CreatorID = item.creatorsID; |
521 | descend.ItemData[i].BaseMask = FULL_MASK_PERMISSIONS; | 521 | descend.ItemData[i].BaseMask = FULL_MASK_PERMISSIONS; |
522 | descend.ItemData[i].CreationDate = 1000; | 522 | descend.ItemData[i].CreationDate = 1000; |
523 | descend.ItemData[i].Description = enc.GetBytes(item.inventoryDescription+ "\0"); | 523 | descend.ItemData[i].Description = enc.GetBytes(item.inventoryDescription+ "\0"); |
524 | descend.ItemData[i].EveryoneMask = FULL_MASK_PERMISSIONS; | 524 | descend.ItemData[i].EveryoneMask = FULL_MASK_PERMISSIONS; |
525 | descend.ItemData[i].Flags = 1; | 525 | descend.ItemData[i].Flags = 1; |
526 | descend.ItemData[i].FolderID = item.parentFolderID; | 526 | descend.ItemData[i].FolderID = item.parentFolderID; |
527 | descend.ItemData[i].GroupID = new LLUUID("00000000-0000-0000-0000-000000000000"); | 527 | descend.ItemData[i].GroupID = new LLUUID("00000000-0000-0000-0000-000000000000"); |
528 | descend.ItemData[i].GroupMask = FULL_MASK_PERMISSIONS; | 528 | descend.ItemData[i].GroupMask = FULL_MASK_PERMISSIONS; |
529 | descend.ItemData[i].InvType = (sbyte)item.type; | 529 | descend.ItemData[i].InvType = (sbyte)item.type; |
530 | descend.ItemData[i].Name = enc.GetBytes(item.inventoryName+ "\0"); | 530 | descend.ItemData[i].Name = enc.GetBytes(item.inventoryName+ "\0"); |
531 | descend.ItemData[i].NextOwnerMask = FULL_MASK_PERMISSIONS; | 531 | descend.ItemData[i].NextOwnerMask = FULL_MASK_PERMISSIONS; |
532 | descend.ItemData[i].OwnerID = item.avatarID; | 532 | descend.ItemData[i].OwnerID = item.avatarID; |
533 | descend.ItemData[i].OwnerMask = FULL_MASK_PERMISSIONS; | 533 | descend.ItemData[i].OwnerMask = FULL_MASK_PERMISSIONS; |
534 | descend.ItemData[i].SalePrice = 0; | 534 | descend.ItemData[i].SalePrice = 0; |
535 | descend.ItemData[i].SaleType = 0; | 535 | descend.ItemData[i].SaleType = 0; |
536 | descend.ItemData[i].Type = (sbyte)item.type; | 536 | descend.ItemData[i].Type = (sbyte)item.type; |
537 | descend.ItemData[i].CRC = Helpers.InventoryCRC(1000, 0, descend.ItemData[i].InvType, descend.ItemData[i].Type, descend.ItemData[i].AssetID, descend.ItemData[i].GroupID, 100,descend.ItemData[i].OwnerID, descend.ItemData[i].CreatorID, descend.ItemData[i].ItemID, descend.ItemData[i].FolderID, FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS); | 537 | descend.ItemData[i].CRC = Helpers.InventoryCRC(1000, 0, descend.ItemData[i].InvType, descend.ItemData[i].Type, descend.ItemData[i].AssetID, descend.ItemData[i].GroupID, 100,descend.ItemData[i].OwnerID, descend.ItemData[i].CreatorID, descend.ItemData[i].ItemID, descend.ItemData[i].FolderID, FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS); |
538 | 538 | ||
539 | i++; | 539 | i++; |
540 | } | 540 | } |
541 | 541 | ||
542 | this.OutPacket(descend); | 542 | this.OutPacket(descend); |
543 | 543 | ||
544 | } | 544 | } |
545 | 545 | ||
546 | public void SendInventoryItemDetails(LLUUID ownerID, LLUUID folderID, InventoryItemBase item) | 546 | public void SendInventoryItemDetails(LLUUID ownerID, LLUUID folderID, InventoryItemBase item) |
547 | { | 547 | { |
548 | Encoding enc = Encoding.ASCII; | 548 | Encoding enc = Encoding.ASCII; |
549 | uint FULL_MASK_PERMISSIONS = 2147483647; | 549 | uint FULL_MASK_PERMISSIONS = 2147483647; |
550 | FetchInventoryReplyPacket inventoryReply = new FetchInventoryReplyPacket(); | 550 | FetchInventoryReplyPacket inventoryReply = new FetchInventoryReplyPacket(); |
551 | inventoryReply.AgentData.AgentID = this.AgentId; | 551 | inventoryReply.AgentData.AgentID = this.AgentId; |
552 | inventoryReply.InventoryData = new FetchInventoryReplyPacket.InventoryDataBlock[1]; | 552 | inventoryReply.InventoryData = new FetchInventoryReplyPacket.InventoryDataBlock[1]; |
553 | inventoryReply.InventoryData[0] = new FetchInventoryReplyPacket.InventoryDataBlock(); | 553 | inventoryReply.InventoryData[0] = new FetchInventoryReplyPacket.InventoryDataBlock(); |
554 | inventoryReply.InventoryData[0].ItemID = item.inventoryID; | 554 | inventoryReply.InventoryData[0].ItemID = item.inventoryID; |
555 | inventoryReply.InventoryData[0].AssetID = item.assetID; | 555 | inventoryReply.InventoryData[0].AssetID = item.assetID; |
556 | inventoryReply.InventoryData[0].CreatorID = item.creatorsID; | 556 | inventoryReply.InventoryData[0].CreatorID = item.creatorsID; |
557 | inventoryReply.InventoryData[0].BaseMask = FULL_MASK_PERMISSIONS; | 557 | inventoryReply.InventoryData[0].BaseMask = FULL_MASK_PERMISSIONS; |
558 | inventoryReply.InventoryData[0].CreationDate = (int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; | 558 | inventoryReply.InventoryData[0].CreationDate = (int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; |
559 | inventoryReply.InventoryData[0].Description = enc.GetBytes(item.inventoryDescription + "\0"); | 559 | inventoryReply.InventoryData[0].Description = enc.GetBytes(item.inventoryDescription + "\0"); |
560 | inventoryReply.InventoryData[0].EveryoneMask = FULL_MASK_PERMISSIONS; | 560 | inventoryReply.InventoryData[0].EveryoneMask = FULL_MASK_PERMISSIONS; |
561 | inventoryReply.InventoryData[0].Flags = 0; | 561 | inventoryReply.InventoryData[0].Flags = 0; |
562 | inventoryReply.InventoryData[0].FolderID = item.parentFolderID; | 562 | inventoryReply.InventoryData[0].FolderID = item.parentFolderID; |
563 | inventoryReply.InventoryData[0].GroupID = new LLUUID("00000000-0000-0000-0000-000000000000"); | 563 | inventoryReply.InventoryData[0].GroupID = new LLUUID("00000000-0000-0000-0000-000000000000"); |
564 | inventoryReply.InventoryData[0].GroupMask = FULL_MASK_PERMISSIONS; | 564 | inventoryReply.InventoryData[0].GroupMask = FULL_MASK_PERMISSIONS; |
565 | inventoryReply.InventoryData[0].InvType = (sbyte)item.type; | 565 | inventoryReply.InventoryData[0].InvType = (sbyte)item.type; |
566 | inventoryReply.InventoryData[0].Name = enc.GetBytes(item.inventoryName + "\0"); | 566 | inventoryReply.InventoryData[0].Name = enc.GetBytes(item.inventoryName + "\0"); |
567 | inventoryReply.InventoryData[0].NextOwnerMask = FULL_MASK_PERMISSIONS; | 567 | inventoryReply.InventoryData[0].NextOwnerMask = FULL_MASK_PERMISSIONS; |
568 | inventoryReply.InventoryData[0].OwnerID = item.avatarID; | 568 | inventoryReply.InventoryData[0].OwnerID = item.avatarID; |
569 | inventoryReply.InventoryData[0].OwnerMask = FULL_MASK_PERMISSIONS; | 569 | inventoryReply.InventoryData[0].OwnerMask = FULL_MASK_PERMISSIONS; |
570 | inventoryReply.InventoryData[0].SalePrice = 0; | 570 | inventoryReply.InventoryData[0].SalePrice = 0; |
571 | inventoryReply.InventoryData[0].SaleType = 0; | 571 | inventoryReply.InventoryData[0].SaleType = 0; |
572 | inventoryReply.InventoryData[0].Type = (sbyte)item.type; | 572 | inventoryReply.InventoryData[0].Type = (sbyte)item.type; |
573 | inventoryReply.InventoryData[0].CRC = Helpers.InventoryCRC(1000, 0, inventoryReply.InventoryData[0].InvType, inventoryReply.InventoryData[0].Type, inventoryReply.InventoryData[0].AssetID, inventoryReply.InventoryData[0].GroupID, 100, inventoryReply.InventoryData[0].OwnerID, inventoryReply.InventoryData[0].CreatorID, inventoryReply.InventoryData[0].ItemID, inventoryReply.InventoryData[0].FolderID, FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS); | 573 | inventoryReply.InventoryData[0].CRC = Helpers.InventoryCRC(1000, 0, inventoryReply.InventoryData[0].InvType, inventoryReply.InventoryData[0].Type, inventoryReply.InventoryData[0].AssetID, inventoryReply.InventoryData[0].GroupID, 100, inventoryReply.InventoryData[0].OwnerID, inventoryReply.InventoryData[0].CreatorID, inventoryReply.InventoryData[0].ItemID, inventoryReply.InventoryData[0].FolderID, FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS); |
574 | 574 | ||
575 | this.OutPacket(inventoryReply); | 575 | this.OutPacket(inventoryReply); |
576 | } | 576 | } |
577 | 577 | ||
578 | #region Appearance/ Wearables Methods | 578 | #region Appearance/ Wearables Methods |
579 | 579 | ||
580 | /// <summary> | 580 | /// <summary> |
581 | /// | 581 | /// |
582 | /// </summary> | 582 | /// </summary> |
583 | /// <param name="wearables"></param> | 583 | /// <param name="wearables"></param> |
584 | public void SendWearables(AvatarWearable[] wearables) | 584 | public void SendWearables(AvatarWearable[] wearables) |
585 | { | 585 | { |
586 | AgentWearablesUpdatePacket aw = new AgentWearablesUpdatePacket(); | 586 | AgentWearablesUpdatePacket aw = new AgentWearablesUpdatePacket(); |
587 | aw.AgentData.AgentID = this.AgentID; | 587 | aw.AgentData.AgentID = this.AgentID; |
588 | aw.AgentData.SerialNum = 0; | 588 | aw.AgentData.SerialNum = 0; |
589 | aw.AgentData.SessionID = this.SessionID; | 589 | aw.AgentData.SessionID = this.SessionID; |
590 | 590 | ||
591 | aw.WearableData = new AgentWearablesUpdatePacket.WearableDataBlock[13]; | 591 | aw.WearableData = new AgentWearablesUpdatePacket.WearableDataBlock[13]; |
592 | AgentWearablesUpdatePacket.WearableDataBlock awb; | 592 | AgentWearablesUpdatePacket.WearableDataBlock awb; |
593 | for (int i = 0; i < wearables.Length; i++) | 593 | for (int i = 0; i < wearables.Length; i++) |
594 | { | 594 | { |
595 | awb = new AgentWearablesUpdatePacket.WearableDataBlock(); | 595 | awb = new AgentWearablesUpdatePacket.WearableDataBlock(); |
596 | awb.WearableType = (byte)i; | 596 | awb.WearableType = (byte)i; |
597 | awb.AssetID = wearables[i].AssetID; | 597 | awb.AssetID = wearables[i].AssetID; |
598 | awb.ItemID = wearables[i].ItemID; | 598 | awb.ItemID = wearables[i].ItemID; |
599 | aw.WearableData[i] = awb; | 599 | aw.WearableData[i] = awb; |
600 | } | 600 | } |
601 | 601 | ||
602 | this.OutPacket(aw); | 602 | this.OutPacket(aw); |
603 | } | 603 | } |
604 | 604 | ||
605 | /// <summary> | 605 | /// <summary> |
606 | /// | 606 | /// |
607 | /// </summary> | 607 | /// </summary> |
608 | /// <param name="agentID"></param> | 608 | /// <param name="agentID"></param> |
609 | /// <param name="visualParams"></param> | 609 | /// <param name="visualParams"></param> |
610 | /// <param name="textureEntry"></param> | 610 | /// <param name="textureEntry"></param> |
611 | public void SendAppearance(LLUUID agentID, byte[] visualParams, byte[] textureEntry) | 611 | public void SendAppearance(LLUUID agentID, byte[] visualParams, byte[] textureEntry) |
612 | { | 612 | { |
613 | AvatarAppearancePacket avp = new AvatarAppearancePacket(); | 613 | AvatarAppearancePacket avp = new AvatarAppearancePacket(); |
614 | avp.VisualParam = new AvatarAppearancePacket.VisualParamBlock[218]; | 614 | avp.VisualParam = new AvatarAppearancePacket.VisualParamBlock[218]; |
615 | avp.ObjectData.TextureEntry = textureEntry; | 615 | avp.ObjectData.TextureEntry = textureEntry; |
616 | 616 | ||
617 | AvatarAppearancePacket.VisualParamBlock avblock = null; | 617 | AvatarAppearancePacket.VisualParamBlock avblock = null; |
618 | for (int i = 0; i < visualParams.Length; i++) | 618 | for (int i = 0; i < visualParams.Length; i++) |
619 | { | 619 | { |
620 | avblock = new AvatarAppearancePacket.VisualParamBlock(); | 620 | avblock = new AvatarAppearancePacket.VisualParamBlock(); |
621 | avblock.ParamValue = visualParams[i]; | 621 | avblock.ParamValue = visualParams[i]; |
622 | avp.VisualParam[i] = avblock; | 622 | avp.VisualParam[i] = avblock; |
623 | } | 623 | } |
624 | 624 | ||
625 | avp.Sender.IsTrial = false; | 625 | avp.Sender.IsTrial = false; |
626 | avp.Sender.ID = agentID; | 626 | avp.Sender.ID = agentID; |
627 | OutPacket(avp); | 627 | OutPacket(avp); |
628 | } | 628 | } |
629 | 629 | ||
630 | public void SendAnimation(LLUUID animID, int seq, LLUUID sourceAgentId) | 630 | public void SendAnimation(LLUUID animID, int seq, LLUUID sourceAgentId) |
631 | { | 631 | { |
632 | AvatarAnimationPacket ani = new AvatarAnimationPacket(); | 632 | AvatarAnimationPacket ani = new AvatarAnimationPacket(); |
633 | ani.AnimationSourceList = new AvatarAnimationPacket.AnimationSourceListBlock[1]; | 633 | ani.AnimationSourceList = new AvatarAnimationPacket.AnimationSourceListBlock[1]; |
634 | ani.AnimationSourceList[0] = new AvatarAnimationPacket.AnimationSourceListBlock(); | 634 | ani.AnimationSourceList[0] = new AvatarAnimationPacket.AnimationSourceListBlock(); |
635 | ani.AnimationSourceList[0].ObjectID = sourceAgentId; | 635 | ani.AnimationSourceList[0].ObjectID = sourceAgentId; |
636 | ani.Sender = new AvatarAnimationPacket.SenderBlock(); | 636 | ani.Sender = new AvatarAnimationPacket.SenderBlock(); |
637 | ani.Sender.ID = sourceAgentId; | 637 | ani.Sender.ID = sourceAgentId; |
638 | ani.AnimationList = new AvatarAnimationPacket.AnimationListBlock[1]; | 638 | ani.AnimationList = new AvatarAnimationPacket.AnimationListBlock[1]; |
639 | ani.AnimationList[0] = new AvatarAnimationPacket.AnimationListBlock(); | 639 | ani.AnimationList[0] = new AvatarAnimationPacket.AnimationListBlock(); |
640 | ani.AnimationList[0].AnimID = animID; | 640 | ani.AnimationList[0].AnimID = animID; |
641 | ani.AnimationList[0].AnimSequenceID = seq; | 641 | ani.AnimationList[0].AnimSequenceID = seq; |
642 | this.OutPacket(ani); | 642 | this.OutPacket(ani); |
643 | } | 643 | } |
644 | 644 | ||
645 | #endregion | 645 | #endregion |
646 | 646 | ||
647 | #region Avatar Packet/data sending Methods | 647 | #region Avatar Packet/data sending Methods |
648 | 648 | ||
649 | /// <summary> | 649 | /// <summary> |
650 | /// send a objectupdate packet with information about the clients avatar | 650 | /// send a objectupdate packet with information about the clients avatar |
651 | /// </summary> | 651 | /// </summary> |
652 | /// <param name="regionInfo"></param> | 652 | /// <param name="regionInfo"></param> |
653 | /// <param name="firstName"></param> | 653 | /// <param name="firstName"></param> |
654 | /// <param name="lastName"></param> | 654 | /// <param name="lastName"></param> |
655 | /// <param name="avatarID"></param> | 655 | /// <param name="avatarID"></param> |
656 | /// <param name="avatarLocalID"></param> | 656 | /// <param name="avatarLocalID"></param> |
657 | /// <param name="Pos"></param> | 657 | /// <param name="Pos"></param> |
658 | public void SendAvatarData(ulong regionHandle, string firstName, string lastName, LLUUID avatarID, uint avatarLocalID, LLVector3 Pos, byte[] textureEntry) | 658 | public void SendAvatarData(ulong regionHandle, string firstName, string lastName, LLUUID avatarID, uint avatarLocalID, LLVector3 Pos, byte[] textureEntry) |
659 | { | 659 | { |
660 | ObjectUpdatePacket objupdate = new ObjectUpdatePacket(); | 660 | ObjectUpdatePacket objupdate = new ObjectUpdatePacket(); |
661 | objupdate.RegionData.RegionHandle = regionHandle; | 661 | objupdate.RegionData.RegionHandle = regionHandle; |
662 | objupdate.RegionData.TimeDilation = 64096; | 662 | objupdate.RegionData.TimeDilation = 64096; |
663 | objupdate.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1]; | 663 | objupdate.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1]; |
664 | objupdate.ObjectData[0] = this.CreateDefaultAvatarPacket(textureEntry); | 664 | objupdate.ObjectData[0] = this.CreateDefaultAvatarPacket(textureEntry); |
665 | 665 | ||
666 | //give this avatar object a local id and assign the user a name | 666 | //give this avatar object a local id and assign the user a name |
667 | objupdate.ObjectData[0].ID = avatarLocalID; | 667 | objupdate.ObjectData[0].ID = avatarLocalID; |
668 | objupdate.ObjectData[0].FullID = avatarID; | 668 | objupdate.ObjectData[0].FullID = avatarID; |
669 | objupdate.ObjectData[0].NameValue = Helpers.StringToField("FirstName STRING RW SV " + firstName + "\nLastName STRING RW SV " + lastName ); | 669 | objupdate.ObjectData[0].NameValue = Helpers.StringToField("FirstName STRING RW SV " + firstName + "\nLastName STRING RW SV " + lastName ); |
670 | LLVector3 pos2 = new LLVector3((float)Pos.X, (float)Pos.Y, (float)Pos.Z); | 670 | LLVector3 pos2 = new LLVector3((float)Pos.X, (float)Pos.Y, (float)Pos.Z); |
671 | byte[] pb = pos2.GetBytes(); | 671 | byte[] pb = pos2.GetBytes(); |
672 | Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 16, pb.Length); | 672 | Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 16, pb.Length); |
673 | 673 | ||
674 | OutPacket(objupdate); | 674 | OutPacket(objupdate); |
675 | 675 | ||
676 | } | 676 | } |
677 | 677 | ||
678 | /// <summary> | 678 | /// <summary> |
679 | /// | 679 | /// |
680 | /// </summary> | 680 | /// </summary> |
681 | /// <param name="regionHandle"></param> | 681 | /// <param name="regionHandle"></param> |
682 | /// <param name="timeDilation"></param> | 682 | /// <param name="timeDilation"></param> |
683 | /// <param name="localID"></param> | 683 | /// <param name="localID"></param> |
684 | /// <param name="position"></param> | 684 | /// <param name="position"></param> |
685 | /// <param name="velocity"></param> | 685 | /// <param name="velocity"></param> |
686 | public void SendAvatarTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position, LLVector3 velocity) | 686 | public void SendAvatarTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position, LLVector3 velocity) |
687 | { | 687 | { |
688 | ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseBlock = this.CreateAvatarImprovedBlock(localID, position, velocity); | 688 | ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseBlock = this.CreateAvatarImprovedBlock(localID, position, velocity); |
689 | ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket(); | 689 | ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket(); |
690 | terse.RegionData.RegionHandle = regionHandle; | 690 | terse.RegionData.RegionHandle = regionHandle; |
691 | terse.RegionData.TimeDilation = timeDilation; | 691 | terse.RegionData.TimeDilation = timeDilation; |
692 | terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; | 692 | terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; |
693 | terse.ObjectData[0] = terseBlock; | 693 | terse.ObjectData[0] = terseBlock; |
694 | 694 | ||
695 | this.OutPacket(terse); | 695 | this.OutPacket(terse); |
696 | } | 696 | } |
697 | 697 | ||
698 | #endregion | 698 | #endregion |
699 | 699 | ||
700 | #region Primitive Packet/data Sending Methods | 700 | #region Primitive Packet/data Sending Methods |
701 | 701 | ||
702 | /// <summary> | 702 | /// <summary> |
703 | /// | 703 | /// |
704 | /// </summary> | 704 | /// </summary> |
705 | /// <param name="localID"></param> | 705 | /// <param name="localID"></param> |
706 | /// <param name="rotation"></param> | 706 | /// <param name="rotation"></param> |
707 | /// <param name="attachPoint"></param> | 707 | /// <param name="attachPoint"></param> |
708 | public void AttachObject(uint localID, LLQuaternion rotation, byte attachPoint) | 708 | public void AttachObject(uint localID, LLQuaternion rotation, byte attachPoint) |
709 | { | 709 | { |
710 | ObjectAttachPacket attach = new ObjectAttachPacket(); | 710 | ObjectAttachPacket attach = new ObjectAttachPacket(); |
711 | attach.AgentData.AgentID = this.AgentID; | 711 | attach.AgentData.AgentID = this.AgentID; |
712 | attach.AgentData.SessionID = this.SessionID; | 712 | attach.AgentData.SessionID = this.SessionID; |
713 | attach.AgentData.AttachmentPoint = attachPoint; | 713 | attach.AgentData.AttachmentPoint = attachPoint; |
714 | attach.ObjectData = new ObjectAttachPacket.ObjectDataBlock[1]; | 714 | attach.ObjectData = new ObjectAttachPacket.ObjectDataBlock[1]; |
715 | attach.ObjectData[0] = new ObjectAttachPacket.ObjectDataBlock(); | 715 | attach.ObjectData[0] = new ObjectAttachPacket.ObjectDataBlock(); |
716 | attach.ObjectData[0].ObjectLocalID = localID; | 716 | attach.ObjectData[0].ObjectLocalID = localID; |
717 | attach.ObjectData[0].Rotation = rotation; | 717 | attach.ObjectData[0].Rotation = rotation; |
718 | 718 | ||
719 | this.OutPacket(attach); | 719 | this.OutPacket(attach); |
720 | } | 720 | } |
721 | 721 | ||
722 | /// <summary> | 722 | /// <summary> |
723 | /// Sends a full ObjectUpdatePacket to a client to inform it of a new primitive | 723 | /// Sends a full ObjectUpdatePacket to a client to inform it of a new primitive |
724 | /// or big changes to a existing primitive. | 724 | /// or big changes to a existing primitive. |
725 | /// </summary> | 725 | /// </summary> |
726 | /// <param name="regionHandle"></param> | 726 | /// <param name="regionHandle"></param> |
727 | /// <param name="timeDilation"></param> | 727 | /// <param name="timeDilation"></param> |
728 | /// <param name="localID"></param> | 728 | /// <param name="localID"></param> |
729 | /// <param name="primData"></param> | 729 | /// <param name="primData"></param> |
730 | /// <param name="pos"></param> | 730 | /// <param name="pos"></param> |
731 | /// <param name="rotation"></param> | 731 | /// <param name="rotation"></param> |
732 | /// <param name="textureID"></param> | 732 | /// <param name="textureID"></param> |
733 | public void SendPrimitiveToClient(ulong regionHandle, ushort timeDilation, uint localID, PrimData primData, LLVector3 pos, LLQuaternion rotation, LLUUID textureID, uint flags) | 733 | public void SendPrimitiveToClient(ulong regionHandle, ushort timeDilation, uint localID, PrimData primData, LLVector3 pos, LLQuaternion rotation, LLUUID textureID, uint flags) |
734 | { | 734 | { |
735 | ObjectUpdatePacket outPacket = new ObjectUpdatePacket(); | 735 | ObjectUpdatePacket outPacket = new ObjectUpdatePacket(); |
736 | outPacket.RegionData.RegionHandle = regionHandle; | 736 | outPacket.RegionData.RegionHandle = regionHandle; |
737 | outPacket.RegionData.TimeDilation = timeDilation; | 737 | outPacket.RegionData.TimeDilation = timeDilation; |
738 | outPacket.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1]; | 738 | outPacket.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1]; |
739 | outPacket.ObjectData[0] = this.CreatePrimUpdateBlock(primData, textureID, flags); | 739 | outPacket.ObjectData[0] = this.CreatePrimUpdateBlock(primData, textureID, flags); |
740 | outPacket.ObjectData[0].ID = localID; | 740 | outPacket.ObjectData[0].ID = localID; |
741 | outPacket.ObjectData[0].FullID = primData.FullID; | 741 | outPacket.ObjectData[0].FullID = primData.FullID; |
742 | byte[] pb = pos.GetBytes(); | 742 | byte[] pb = pos.GetBytes(); |
743 | Array.Copy(pb, 0, outPacket.ObjectData[0].ObjectData, 0, pb.Length); | 743 | Array.Copy(pb, 0, outPacket.ObjectData[0].ObjectData, 0, pb.Length); |
744 | byte[] rot = rotation.GetBytes(); | 744 | byte[] rot = rotation.GetBytes(); |
745 | Array.Copy(rot, 0, outPacket.ObjectData[0].ObjectData, 48, rot.Length); | 745 | Array.Copy(rot, 0, outPacket.ObjectData[0].ObjectData, 48, rot.Length); |
746 | OutPacket(outPacket); | 746 | OutPacket(outPacket); |
747 | } | 747 | } |
748 | 748 | ||
749 | /// <summary> | 749 | /// <summary> |
750 | /// Sends a full ObjectUpdatePacket to a client to inform it of a new primitive | 750 | /// Sends a full ObjectUpdatePacket to a client to inform it of a new primitive |
751 | /// or big changes to a existing primitive. | 751 | /// or big changes to a existing primitive. |
752 | /// Uses default rotation | 752 | /// Uses default rotation |
753 | /// </summary> | 753 | /// </summary> |
754 | /// <param name="primData"></param> | 754 | /// <param name="primData"></param> |
755 | /// <param name="pos"></param> | 755 | /// <param name="pos"></param> |
756 | public void SendPrimitiveToClient(ulong regionHandle, ushort timeDilation, uint localID, PrimData primData, LLVector3 pos, LLUUID textureID, uint flags) | 756 | public void SendPrimitiveToClient(ulong regionHandle, ushort timeDilation, uint localID, PrimData primData, LLVector3 pos, LLUUID textureID, uint flags) |
757 | { | 757 | { |
758 | ObjectUpdatePacket outPacket = new ObjectUpdatePacket(); | 758 | ObjectUpdatePacket outPacket = new ObjectUpdatePacket(); |
759 | outPacket.RegionData.RegionHandle = regionHandle; | 759 | outPacket.RegionData.RegionHandle = regionHandle; |
760 | outPacket.RegionData.TimeDilation = timeDilation; | 760 | outPacket.RegionData.TimeDilation = timeDilation; |
761 | outPacket.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1]; | 761 | outPacket.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1]; |
762 | outPacket.ObjectData[0] = this.CreatePrimUpdateBlock(primData, textureID, flags); | 762 | outPacket.ObjectData[0] = this.CreatePrimUpdateBlock(primData, textureID, flags); |
763 | outPacket.ObjectData[0].ID = localID; | 763 | outPacket.ObjectData[0].ID = localID; |
764 | outPacket.ObjectData[0].FullID = primData.FullID; | 764 | outPacket.ObjectData[0].FullID = primData.FullID; |
765 | byte[] pb = pos.GetBytes(); | 765 | byte[] pb = pos.GetBytes(); |
766 | Array.Copy(pb, 0, outPacket.ObjectData[0].ObjectData, 0, pb.Length); | 766 | Array.Copy(pb, 0, outPacket.ObjectData[0].ObjectData, 0, pb.Length); |
767 | 767 | ||
768 | OutPacket(outPacket); | 768 | OutPacket(outPacket); |
769 | } | 769 | } |
770 | 770 | ||
771 | 771 | ||
772 | public void SendPrimitiveToClient(ulong regionHandle, ushort timeDilation, uint localID, PrimitiveBaseShape primShape, LLVector3 pos, LLQuaternion rotation, uint flags, LLUUID objectID, LLUUID ownerID, string text, uint parentID) | 772 | public void SendPrimitiveToClient(ulong regionHandle, ushort timeDilation, uint localID, PrimitiveBaseShape primShape, LLVector3 pos, LLQuaternion rotation, uint flags, LLUUID objectID, LLUUID ownerID, string text, uint parentID) |
773 | { | 773 | { |
774 | ObjectUpdatePacket outPacket = new ObjectUpdatePacket(); | 774 | ObjectUpdatePacket outPacket = new ObjectUpdatePacket(); |
775 | outPacket.RegionData.RegionHandle = regionHandle; | 775 | outPacket.RegionData.RegionHandle = regionHandle; |
776 | outPacket.RegionData.TimeDilation = timeDilation; | 776 | outPacket.RegionData.TimeDilation = timeDilation; |
777 | outPacket.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1]; | 777 | outPacket.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1]; |
778 | outPacket.ObjectData[0] = this.CreatePrimUpdateBlock(primShape, flags); | 778 | outPacket.ObjectData[0] = this.CreatePrimUpdateBlock(primShape, flags); |
779 | outPacket.ObjectData[0].ID = localID; | 779 | outPacket.ObjectData[0].ID = localID; |
780 | outPacket.ObjectData[0].FullID = objectID; | 780 | outPacket.ObjectData[0].FullID = objectID; |
781 | outPacket.ObjectData[0].OwnerID = ownerID; | 781 | outPacket.ObjectData[0].OwnerID = ownerID; |
782 | outPacket.ObjectData[0].Text = enc.GetBytes(text); | 782 | outPacket.ObjectData[0].Text = enc.GetBytes(text); |
783 | outPacket.ObjectData[0].ParentID = parentID; | 783 | outPacket.ObjectData[0].ParentID = parentID; |
784 | byte[] pb = pos.GetBytes(); | 784 | byte[] pb = pos.GetBytes(); |
785 | Array.Copy(pb, 0, outPacket.ObjectData[0].ObjectData, 0, pb.Length); | 785 | Array.Copy(pb, 0, outPacket.ObjectData[0].ObjectData, 0, pb.Length); |
786 | byte[] rot = rotation.GetBytes(); | 786 | byte[] rot = rotation.GetBytes(); |
787 | Array.Copy(rot, 0, outPacket.ObjectData[0].ObjectData, 36, rot.Length); | 787 | Array.Copy(rot, 0, outPacket.ObjectData[0].ObjectData, 36, rot.Length); |
788 | OutPacket(outPacket); | 788 | OutPacket(outPacket); |
789 | } | 789 | } |
790 | 790 | ||
791 | public void SendPrimitiveToClient(ulong regionHandle, ushort timeDilation, uint localID, PrimitiveBaseShape primShape, LLVector3 pos, uint flags, LLUUID objectID, LLUUID ownerID, string text, uint parentID) | 791 | public void SendPrimitiveToClient(ulong regionHandle, ushort timeDilation, uint localID, PrimitiveBaseShape primShape, LLVector3 pos, uint flags, LLUUID objectID, LLUUID ownerID, string text, uint parentID) |
792 | { | 792 | { |
793 | ObjectUpdatePacket outPacket = new ObjectUpdatePacket(); | 793 | ObjectUpdatePacket outPacket = new ObjectUpdatePacket(); |
794 | outPacket.RegionData.RegionHandle = regionHandle; | 794 | outPacket.RegionData.RegionHandle = regionHandle; |
795 | outPacket.RegionData.TimeDilation = timeDilation; | 795 | outPacket.RegionData.TimeDilation = timeDilation; |
796 | outPacket.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1]; | 796 | outPacket.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1]; |
797 | outPacket.ObjectData[0] = this.CreatePrimUpdateBlock(primShape, flags); | 797 | outPacket.ObjectData[0] = this.CreatePrimUpdateBlock(primShape, flags); |
798 | outPacket.ObjectData[0].ID = localID; | 798 | outPacket.ObjectData[0].ID = localID; |
799 | outPacket.ObjectData[0].FullID = objectID; | 799 | outPacket.ObjectData[0].FullID = objectID; |
800 | outPacket.ObjectData[0].OwnerID = ownerID; | 800 | outPacket.ObjectData[0].OwnerID = ownerID; |
801 | outPacket.ObjectData[0].Text = enc.GetBytes(text); | 801 | outPacket.ObjectData[0].Text = enc.GetBytes(text); |
802 | outPacket.ObjectData[0].ParentID = parentID; | 802 | outPacket.ObjectData[0].ParentID = parentID; |
803 | byte[] pb = pos.GetBytes(); | 803 | byte[] pb = pos.GetBytes(); |
804 | Array.Copy(pb, 0, outPacket.ObjectData[0].ObjectData, 0, pb.Length); | 804 | Array.Copy(pb, 0, outPacket.ObjectData[0].ObjectData, 0, pb.Length); |
805 | 805 | ||
806 | OutPacket(outPacket); | 806 | OutPacket(outPacket); |
807 | } | 807 | } |
808 | /// <summary> | 808 | /// <summary> |
809 | /// | 809 | /// |
810 | /// </summary> | 810 | /// </summary> |
811 | /// <param name="regionHandle"></param> | 811 | /// <param name="regionHandle"></param> |
812 | /// <param name="timeDilation"></param> | 812 | /// <param name="timeDilation"></param> |
813 | /// <param name="localID"></param> | 813 | /// <param name="localID"></param> |
814 | /// <param name="position"></param> | 814 | /// <param name="position"></param> |
815 | /// <param name="rotation"></param> | 815 | /// <param name="rotation"></param> |
816 | public void SendPrimTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position, LLQuaternion rotation) | 816 | public void SendPrimTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position, LLQuaternion rotation) |
817 | { | 817 | { |
818 | ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket(); | 818 | ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket(); |
819 | terse.RegionData.RegionHandle = regionHandle; | 819 | terse.RegionData.RegionHandle = regionHandle; |
820 | terse.RegionData.TimeDilation = timeDilation; | 820 | terse.RegionData.TimeDilation = timeDilation; |
821 | terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; | 821 | terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; |
822 | terse.ObjectData[0] = this.CreatePrimImprovedBlock(localID, position, rotation); | 822 | terse.ObjectData[0] = this.CreatePrimImprovedBlock(localID, position, rotation); |
823 | 823 | ||
824 | this.OutPacket(terse); | 824 | this.OutPacket(terse); |
825 | } | 825 | } |
826 | 826 | ||
827 | #endregion | 827 | #endregion |
828 | 828 | ||
829 | #endregion | 829 | #endregion |
830 | 830 | ||
831 | #region Helper Methods | 831 | #region Helper Methods |
832 | 832 | ||
833 | protected ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateAvatarImprovedBlock(uint localID, LLVector3 pos, LLVector3 velocity) | 833 | protected ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateAvatarImprovedBlock(uint localID, LLVector3 pos, LLVector3 velocity) |
834 | { | 834 | { |
835 | byte[] bytes = new byte[60]; | 835 | byte[] bytes = new byte[60]; |
836 | int i = 0; | 836 | int i = 0; |
837 | ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock(); | 837 | ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock(); |
838 | 838 | ||
839 | dat.TextureEntry = new byte[0];// AvatarTemplate.TextureEntry; | 839 | dat.TextureEntry = new byte[0];// AvatarTemplate.TextureEntry; |
840 | 840 | ||
841 | uint ID = localID; | 841 | uint ID = localID; |
842 | 842 | ||
843 | bytes[i++] = (byte)(ID % 256); | 843 | bytes[i++] = (byte)(ID % 256); |
844 | bytes[i++] = (byte)((ID >> 8) % 256); | 844 | bytes[i++] = (byte)((ID >> 8) % 256); |
845 | bytes[i++] = (byte)((ID >> 16) % 256); | 845 | bytes[i++] = (byte)((ID >> 16) % 256); |
846 | bytes[i++] = (byte)((ID >> 24) % 256); | 846 | bytes[i++] = (byte)((ID >> 24) % 256); |
847 | bytes[i++] = 0; | 847 | bytes[i++] = 0; |
848 | bytes[i++] = 1; | 848 | bytes[i++] = 1; |
849 | i += 14; | 849 | i += 14; |
850 | bytes[i++] = 128; | 850 | bytes[i++] = 128; |
851 | bytes[i++] = 63; | 851 | bytes[i++] = 63; |
852 | 852 | ||
853 | byte[] pb = pos.GetBytes(); | 853 | byte[] pb = pos.GetBytes(); |
854 | Array.Copy(pb, 0, bytes, i, pb.Length); | 854 | Array.Copy(pb, 0, bytes, i, pb.Length); |
855 | i += 12; | 855 | i += 12; |
856 | ushort InternVelocityX; | 856 | ushort InternVelocityX; |
857 | ushort InternVelocityY; | 857 | ushort InternVelocityY; |
858 | ushort InternVelocityZ; | 858 | ushort InternVelocityZ; |
859 | Vector3 internDirec = new Vector3(0, 0, 0); | 859 | Vector3 internDirec = new Vector3(0, 0, 0); |
860 | 860 | ||
861 | internDirec = new Vector3(velocity.X, velocity.Y, velocity.Z); | 861 | internDirec = new Vector3(velocity.X, velocity.Y, velocity.Z); |
862 | 862 | ||
863 | internDirec = internDirec / 128.0f; | 863 | internDirec = internDirec / 128.0f; |
864 | internDirec.x += 1; | 864 | internDirec.x += 1; |
865 | internDirec.y += 1; | 865 | internDirec.y += 1; |
866 | internDirec.z += 1; | 866 | internDirec.z += 1; |
867 | 867 | ||
868 | InternVelocityX = (ushort)(32768 * internDirec.x); | 868 | InternVelocityX = (ushort)(32768 * internDirec.x); |
869 | InternVelocityY = (ushort)(32768 * internDirec.y); | 869 | InternVelocityY = (ushort)(32768 * internDirec.y); |
870 | InternVelocityZ = (ushort)(32768 * internDirec.z); | 870 | InternVelocityZ = (ushort)(32768 * internDirec.z); |
871 | 871 | ||
872 | ushort ac = 32767; | 872 | ushort ac = 32767; |
873 | bytes[i++] = (byte)(InternVelocityX % 256); | 873 | bytes[i++] = (byte)(InternVelocityX % 256); |
874 | bytes[i++] = (byte)((InternVelocityX >> 8) % 256); | 874 | bytes[i++] = (byte)((InternVelocityX >> 8) % 256); |
875 | bytes[i++] = (byte)(InternVelocityY % 256); | 875 | bytes[i++] = (byte)(InternVelocityY % 256); |
876 | bytes[i++] = (byte)((InternVelocityY >> 8) % 256); | 876 | bytes[i++] = (byte)((InternVelocityY >> 8) % 256); |
877 | bytes[i++] = (byte)(InternVelocityZ % 256); | 877 | bytes[i++] = (byte)(InternVelocityZ % 256); |
878 | bytes[i++] = (byte)((InternVelocityZ >> 8) % 256); | 878 | bytes[i++] = (byte)((InternVelocityZ >> 8) % 256); |
879 | 879 | ||
880 | //accel | 880 | //accel |
881 | bytes[i++] = (byte)(ac % 256); | 881 | bytes[i++] = (byte)(ac % 256); |
882 | bytes[i++] = (byte)((ac >> 8) % 256); | 882 | bytes[i++] = (byte)((ac >> 8) % 256); |
883 | bytes[i++] = (byte)(ac % 256); | 883 | bytes[i++] = (byte)(ac % 256); |
884 | bytes[i++] = (byte)((ac >> 8) % 256); | 884 | bytes[i++] = (byte)((ac >> 8) % 256); |
885 | bytes[i++] = (byte)(ac % 256); | 885 | bytes[i++] = (byte)(ac % 256); |
886 | bytes[i++] = (byte)((ac >> 8) % 256); | 886 | bytes[i++] = (byte)((ac >> 8) % 256); |
887 | 887 | ||
888 | //rot | 888 | //rot |
889 | bytes[i++] = (byte)(ac % 256); | 889 | bytes[i++] = (byte)(ac % 256); |
890 | bytes[i++] = (byte)((ac >> 8) % 256); | 890 | bytes[i++] = (byte)((ac >> 8) % 256); |
891 | bytes[i++] = (byte)(ac % 256); | 891 | bytes[i++] = (byte)(ac % 256); |
892 | bytes[i++] = (byte)((ac >> 8) % 256); | 892 | bytes[i++] = (byte)((ac >> 8) % 256); |
893 | bytes[i++] = (byte)(ac % 256); | 893 | bytes[i++] = (byte)(ac % 256); |
894 | bytes[i++] = (byte)((ac >> 8) % 256); | 894 | bytes[i++] = (byte)((ac >> 8) % 256); |
895 | bytes[i++] = (byte)(ac % 256); | 895 | bytes[i++] = (byte)(ac % 256); |
896 | bytes[i++] = (byte)((ac >> 8) % 256); | 896 | bytes[i++] = (byte)((ac >> 8) % 256); |
897 | 897 | ||
898 | //rotation vel | 898 | //rotation vel |
899 | bytes[i++] = (byte)(ac % 256); | 899 | bytes[i++] = (byte)(ac % 256); |
900 | bytes[i++] = (byte)((ac >> 8) % 256); | 900 | bytes[i++] = (byte)((ac >> 8) % 256); |
901 | bytes[i++] = (byte)(ac % 256); | 901 | bytes[i++] = (byte)(ac % 256); |
902 | bytes[i++] = (byte)((ac >> 8) % 256); | 902 | bytes[i++] = (byte)((ac >> 8) % 256); |
903 | bytes[i++] = (byte)(ac % 256); | 903 | bytes[i++] = (byte)(ac % 256); |
904 | bytes[i++] = (byte)((ac >> 8) % 256); | 904 | bytes[i++] = (byte)((ac >> 8) % 256); |
905 | 905 | ||
906 | dat.Data = bytes; | 906 | dat.Data = bytes; |
907 | return (dat); | 907 | return (dat); |
908 | } | 908 | } |
909 | 909 | ||
910 | /// <summary> | 910 | /// <summary> |
911 | /// | 911 | /// |
912 | /// </summary> | 912 | /// </summary> |
913 | /// <param name="localID"></param> | 913 | /// <param name="localID"></param> |
914 | /// <param name="position"></param> | 914 | /// <param name="position"></param> |
915 | /// <param name="rotation"></param> | 915 | /// <param name="rotation"></param> |
916 | /// <returns></returns> | 916 | /// <returns></returns> |
917 | protected ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreatePrimImprovedBlock(uint localID, LLVector3 position, LLQuaternion rotation) | 917 | protected ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreatePrimImprovedBlock(uint localID, LLVector3 position, LLQuaternion rotation) |
918 | { | 918 | { |
919 | uint ID = localID; | 919 | uint ID = localID; |
920 | byte[] bytes = new byte[60]; | 920 | byte[] bytes = new byte[60]; |
921 | 921 | ||
922 | int i = 0; | 922 | int i = 0; |
923 | ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock(); | 923 | ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock(); |
924 | dat.TextureEntry = new byte[0]; | 924 | dat.TextureEntry = new byte[0]; |
925 | bytes[i++] = (byte)(ID % 256); | 925 | bytes[i++] = (byte)(ID % 256); |
926 | bytes[i++] = (byte)((ID >> 8) % 256); | 926 | bytes[i++] = (byte)((ID >> 8) % 256); |
927 | bytes[i++] = (byte)((ID >> 16) % 256); | 927 | bytes[i++] = (byte)((ID >> 16) % 256); |
928 | bytes[i++] = (byte)((ID >> 24) % 256); | 928 | bytes[i++] = (byte)((ID >> 24) % 256); |
929 | bytes[i++] = 0; | 929 | bytes[i++] = 0; |
930 | bytes[i++] = 0; | 930 | bytes[i++] = 0; |
931 | 931 | ||
932 | byte[] pb = position.GetBytes(); | 932 | byte[] pb = position.GetBytes(); |
933 | Array.Copy(pb, 0, bytes, i, pb.Length); | 933 | Array.Copy(pb, 0, bytes, i, pb.Length); |
934 | i += 12; | 934 | i += 12; |
935 | ushort ac = 32767; | 935 | ushort ac = 32767; |
936 | 936 | ||
937 | //vel | 937 | //vel |
938 | bytes[i++] = (byte)(ac % 256); | 938 | bytes[i++] = (byte)(ac % 256); |
939 | bytes[i++] = (byte)((ac >> 8) % 256); | 939 | bytes[i++] = (byte)((ac >> 8) % 256); |
940 | bytes[i++] = (byte)(ac % 256); | 940 | bytes[i++] = (byte)(ac % 256); |
941 | bytes[i++] = (byte)((ac >> 8) % 256); | 941 | bytes[i++] = (byte)((ac >> 8) % 256); |
942 | bytes[i++] = (byte)(ac % 256); | 942 | bytes[i++] = (byte)(ac % 256); |
943 | bytes[i++] = (byte)((ac >> 8) % 256); | 943 | bytes[i++] = (byte)((ac >> 8) % 256); |
944 | 944 | ||
945 | //accel | 945 | //accel |
946 | bytes[i++] = (byte)(ac % 256); | 946 | bytes[i++] = (byte)(ac % 256); |
947 | bytes[i++] = (byte)((ac >> 8) % 256); | 947 | bytes[i++] = (byte)((ac >> 8) % 256); |
948 | bytes[i++] = (byte)(ac % 256); | 948 | bytes[i++] = (byte)(ac % 256); |
949 | bytes[i++] = (byte)((ac >> 8) % 256); | 949 | bytes[i++] = (byte)((ac >> 8) % 256); |
950 | bytes[i++] = (byte)(ac % 256); | 950 | bytes[i++] = (byte)(ac % 256); |
951 | bytes[i++] = (byte)((ac >> 8) % 256); | 951 | bytes[i++] = (byte)((ac >> 8) % 256); |
952 | 952 | ||
953 | ushort rw, rx, ry, rz; | 953 | ushort rw, rx, ry, rz; |
954 | rw = (ushort)(32768 * (rotation.W + 1)); | 954 | rw = (ushort)(32768 * (rotation.W + 1)); |
955 | rx = (ushort)(32768 * (rotation.X + 1)); | 955 | rx = (ushort)(32768 * (rotation.X + 1)); |
956 | ry = (ushort)(32768 * (rotation.Y + 1)); | 956 | ry = (ushort)(32768 * (rotation.Y + 1)); |
957 | rz = (ushort)(32768 * (rotation.Z + 1)); | 957 | rz = (ushort)(32768 * (rotation.Z + 1)); |
958 | 958 | ||
959 | //rot | 959 | //rot |
960 | bytes[i++] = (byte)(rx % 256); | 960 | bytes[i++] = (byte)(rx % 256); |
961 | bytes[i++] = (byte)((rx >> 8) % 256); | 961 | bytes[i++] = (byte)((rx >> 8) % 256); |
962 | bytes[i++] = (byte)(ry % 256); | 962 | bytes[i++] = (byte)(ry % 256); |
963 | bytes[i++] = (byte)((ry >> 8) % 256); | 963 | bytes[i++] = (byte)((ry >> 8) % 256); |
964 | bytes[i++] = (byte)(rz % 256); | 964 | bytes[i++] = (byte)(rz % 256); |
965 | bytes[i++] = (byte)((rz >> 8) % 256); | 965 | bytes[i++] = (byte)((rz >> 8) % 256); |
966 | bytes[i++] = (byte)(rw % 256); | 966 | bytes[i++] = (byte)(rw % 256); |
967 | bytes[i++] = (byte)((rw >> 8) % 256); | 967 | bytes[i++] = (byte)((rw >> 8) % 256); |
968 | 968 | ||
969 | //rotation vel | 969 | //rotation vel |
970 | bytes[i++] = (byte)(ac % 256); | 970 | bytes[i++] = (byte)(ac % 256); |
971 | bytes[i++] = (byte)((ac >> 8) % 256); | 971 | bytes[i++] = (byte)((ac >> 8) % 256); |
972 | bytes[i++] = (byte)(ac % 256); | 972 | bytes[i++] = (byte)(ac % 256); |
973 | bytes[i++] = (byte)((ac >> 8) % 256); | 973 | bytes[i++] = (byte)((ac >> 8) % 256); |
974 | bytes[i++] = (byte)(ac % 256); | 974 | bytes[i++] = (byte)(ac % 256); |
975 | bytes[i++] = (byte)((ac >> 8) % 256); | 975 | bytes[i++] = (byte)((ac >> 8) % 256); |
976 | 976 | ||
977 | dat.Data = bytes; | 977 | dat.Data = bytes; |
978 | return dat; | 978 | return dat; |
979 | } | 979 | } |
980 | 980 | ||
981 | 981 | ||
982 | /// <summary> | 982 | /// <summary> |
983 | /// Create the ObjectDataBlock for a ObjectUpdatePacket (for a Primitive) | 983 | /// Create the ObjectDataBlock for a ObjectUpdatePacket (for a Primitive) |
984 | /// </summary> | 984 | /// </summary> |
985 | /// <param name="primData"></param> | 985 | /// <param name="primData"></param> |
986 | /// <returns></returns> | 986 | /// <returns></returns> |
987 | protected ObjectUpdatePacket.ObjectDataBlock CreatePrimUpdateBlock(PrimData primData, LLUUID textureID, uint flags) | 987 | protected ObjectUpdatePacket.ObjectDataBlock CreatePrimUpdateBlock(PrimData primData, LLUUID textureID, uint flags) |
988 | { | 988 | { |
989 | ObjectUpdatePacket.ObjectDataBlock objupdate = new ObjectUpdatePacket.ObjectDataBlock(); | 989 | ObjectUpdatePacket.ObjectDataBlock objupdate = new ObjectUpdatePacket.ObjectDataBlock(); |
990 | this.SetDefaultPrimPacketValues(objupdate); | 990 | this.SetDefaultPrimPacketValues(objupdate); |
991 | objupdate.UpdateFlags = flags; | 991 | objupdate.UpdateFlags = flags; |
992 | this.SetPrimPacketShapeData(objupdate, primData, textureID); | 992 | this.SetPrimPacketShapeData(objupdate, primData, textureID); |
993 | 993 | ||
994 | return objupdate; | 994 | return objupdate; |
995 | } | 995 | } |
996 | 996 | ||
997 | /// <summary> | 997 | /// <summary> |
998 | /// Create the ObjectDataBlock for a ObjectUpdatePacket (for a Primitive) | 998 | /// Create the ObjectDataBlock for a ObjectUpdatePacket (for a Primitive) |
999 | /// </summary> | 999 | /// </summary> |
1000 | /// <param name="primData"></param> | 1000 | /// <param name="primData"></param> |
1001 | /// <returns></returns> | 1001 | /// <returns></returns> |
1002 | protected ObjectUpdatePacket.ObjectDataBlock CreatePrimUpdateBlock(PrimitiveBaseShape primShape, uint flags) | 1002 | protected ObjectUpdatePacket.ObjectDataBlock CreatePrimUpdateBlock(PrimitiveBaseShape primShape, uint flags) |
1003 | { | 1003 | { |
1004 | ObjectUpdatePacket.ObjectDataBlock objupdate = new ObjectUpdatePacket.ObjectDataBlock(); | 1004 | ObjectUpdatePacket.ObjectDataBlock objupdate = new ObjectUpdatePacket.ObjectDataBlock(); |
1005 | this.SetDefaultPrimPacketValues(objupdate); | 1005 | this.SetDefaultPrimPacketValues(objupdate); |
1006 | objupdate.UpdateFlags = flags; | 1006 | objupdate.UpdateFlags = flags; |
1007 | this.SetPrimPacketShapeData(objupdate, primShape); | 1007 | this.SetPrimPacketShapeData(objupdate, primShape); |
1008 | 1008 | ||
1009 | return objupdate; | 1009 | return objupdate; |
1010 | } | 1010 | } |
1011 | 1011 | ||
1012 | 1012 | ||
1013 | /// <summary> | 1013 | /// <summary> |
1014 | /// Copy the data from a PrimData object to a ObjectUpdatePacket | 1014 | /// Copy the data from a PrimData object to a ObjectUpdatePacket |
1015 | /// </summary> | 1015 | /// </summary> |
1016 | /// <param name="objectData"></param> | 1016 | /// <param name="objectData"></param> |
1017 | /// <param name="primData"></param> | 1017 | /// <param name="primData"></param> |
1018 | protected void SetPrimPacketShapeData(ObjectUpdatePacket.ObjectDataBlock objectData, PrimData primData, LLUUID textureID) | 1018 | protected void SetPrimPacketShapeData(ObjectUpdatePacket.ObjectDataBlock objectData, PrimData primData, LLUUID textureID) |
1019 | { | 1019 | { |
1020 | LLObject.TextureEntry ntex = new LLObject.TextureEntry(textureID); | 1020 | LLObject.TextureEntry ntex = new LLObject.TextureEntry(textureID); |
1021 | objectData.TextureEntry = ntex.ToBytes(); | 1021 | objectData.TextureEntry = ntex.ToBytes(); |
1022 | objectData.OwnerID = primData.OwnerID; | 1022 | objectData.OwnerID = primData.OwnerID; |
1023 | objectData.ParentID = primData.ParentID; | 1023 | objectData.ParentID = primData.ParentID; |
1024 | objectData.PCode = primData.PCode; | 1024 | objectData.PCode = primData.PCode; |
1025 | objectData.PathBegin = primData.PathBegin; | 1025 | objectData.PathBegin = primData.PathBegin; |
1026 | objectData.PathEnd = primData.PathEnd; | 1026 | objectData.PathEnd = primData.PathEnd; |
1027 | objectData.PathScaleX = primData.PathScaleX; | 1027 | objectData.PathScaleX = primData.PathScaleX; |
1028 | objectData.PathScaleY = primData.PathScaleY; | 1028 | objectData.PathScaleY = primData.PathScaleY; |
1029 | objectData.PathShearX = primData.PathShearX; | 1029 | objectData.PathShearX = primData.PathShearX; |
1030 | objectData.PathShearY = primData.PathShearY; | 1030 | objectData.PathShearY = primData.PathShearY; |
1031 | objectData.PathSkew = primData.PathSkew; | 1031 | objectData.PathSkew = primData.PathSkew; |
1032 | objectData.ProfileBegin = primData.ProfileBegin; | 1032 | objectData.ProfileBegin = primData.ProfileBegin; |
1033 | objectData.ProfileEnd = primData.ProfileEnd; | 1033 | objectData.ProfileEnd = primData.ProfileEnd; |
1034 | objectData.Scale = primData.Scale; | 1034 | objectData.Scale = primData.Scale; |
1035 | objectData.PathCurve = primData.PathCurve; | 1035 | objectData.PathCurve = primData.PathCurve; |
1036 | objectData.ProfileCurve = primData.ProfileCurve; | 1036 | objectData.ProfileCurve = primData.ProfileCurve; |
1037 | objectData.ProfileHollow = primData.ProfileHollow; | 1037 | objectData.ProfileHollow = primData.ProfileHollow; |
1038 | objectData.PathRadiusOffset = primData.PathRadiusOffset; | 1038 | objectData.PathRadiusOffset = primData.PathRadiusOffset; |
1039 | objectData.PathRevolutions = primData.PathRevolutions; | 1039 | objectData.PathRevolutions = primData.PathRevolutions; |
1040 | objectData.PathTaperX = primData.PathTaperX; | 1040 | objectData.PathTaperX = primData.PathTaperX; |
1041 | objectData.PathTaperY = primData.PathTaperY; | 1041 | objectData.PathTaperY = primData.PathTaperY; |
1042 | objectData.PathTwist = primData.PathTwist; | 1042 | objectData.PathTwist = primData.PathTwist; |
1043 | objectData.PathTwistBegin = primData.PathTwistBegin; | 1043 | objectData.PathTwistBegin = primData.PathTwistBegin; |
1044 | } | 1044 | } |
1045 | 1045 | ||
1046 | protected void SetPrimPacketShapeData(ObjectUpdatePacket.ObjectDataBlock objectData, PrimitiveBaseShape primData) | 1046 | protected void SetPrimPacketShapeData(ObjectUpdatePacket.ObjectDataBlock objectData, PrimitiveBaseShape primData) |
1047 | { | 1047 | { |
1048 | 1048 | ||
1049 | objectData.TextureEntry = primData.TextureEntry; | 1049 | objectData.TextureEntry = primData.TextureEntry; |
1050 | objectData.PCode = primData.PCode; | 1050 | objectData.PCode = primData.PCode; |
1051 | objectData.PathBegin = primData.PathBegin; | 1051 | objectData.PathBegin = primData.PathBegin; |
1052 | objectData.PathEnd = primData.PathEnd; | 1052 | objectData.PathEnd = primData.PathEnd; |
1053 | objectData.PathScaleX = primData.PathScaleX; | 1053 | objectData.PathScaleX = primData.PathScaleX; |
1054 | objectData.PathScaleY = primData.PathScaleY; | 1054 | objectData.PathScaleY = primData.PathScaleY; |
1055 | objectData.PathShearX = primData.PathShearX; | 1055 | objectData.PathShearX = primData.PathShearX; |
1056 | objectData.PathShearY = primData.PathShearY; | 1056 | objectData.PathShearY = primData.PathShearY; |
1057 | objectData.PathSkew = primData.PathSkew; | 1057 | objectData.PathSkew = primData.PathSkew; |
1058 | objectData.ProfileBegin = primData.ProfileBegin; | 1058 | objectData.ProfileBegin = primData.ProfileBegin; |
1059 | objectData.ProfileEnd = primData.ProfileEnd; | 1059 | objectData.ProfileEnd = primData.ProfileEnd; |
1060 | objectData.Scale = primData.Scale; | 1060 | objectData.Scale = primData.Scale; |
1061 | objectData.PathCurve = primData.PathCurve; | 1061 | objectData.PathCurve = primData.PathCurve; |
1062 | objectData.ProfileCurve = primData.ProfileCurve; | 1062 | objectData.ProfileCurve = primData.ProfileCurve; |
1063 | objectData.ProfileHollow = primData.ProfileHollow; | 1063 | objectData.ProfileHollow = primData.ProfileHollow; |
1064 | objectData.PathRadiusOffset = primData.PathRadiusOffset; | 1064 | objectData.PathRadiusOffset = primData.PathRadiusOffset; |
1065 | objectData.PathRevolutions = primData.PathRevolutions; | 1065 | objectData.PathRevolutions = primData.PathRevolutions; |
1066 | objectData.PathTaperX = primData.PathTaperX; | 1066 | objectData.PathTaperX = primData.PathTaperX; |
1067 | objectData.PathTaperY = primData.PathTaperY; | 1067 | objectData.PathTaperY = primData.PathTaperY; |
1068 | objectData.PathTwist = primData.PathTwist; | 1068 | objectData.PathTwist = primData.PathTwist; |
1069 | objectData.PathTwistBegin = primData.PathTwistBegin; | 1069 | objectData.PathTwistBegin = primData.PathTwistBegin; |
1070 | } | 1070 | } |
1071 | 1071 | ||
1072 | /// <summary> | 1072 | /// <summary> |
1073 | /// Set some default values in a ObjectUpdatePacket | 1073 | /// Set some default values in a ObjectUpdatePacket |
1074 | /// </summary> | 1074 | /// </summary> |
1075 | /// <param name="objdata"></param> | 1075 | /// <param name="objdata"></param> |
1076 | protected void SetDefaultPrimPacketValues(ObjectUpdatePacket.ObjectDataBlock objdata) | 1076 | protected void SetDefaultPrimPacketValues(ObjectUpdatePacket.ObjectDataBlock objdata) |
1077 | { | 1077 | { |
1078 | objdata.PSBlock = new byte[0]; | 1078 | objdata.PSBlock = new byte[0]; |
1079 | objdata.ExtraParams = new byte[1]; | 1079 | objdata.ExtraParams = new byte[1]; |
1080 | objdata.MediaURL = new byte[0]; | 1080 | objdata.MediaURL = new byte[0]; |
1081 | objdata.NameValue = new byte[0]; | 1081 | objdata.NameValue = new byte[0]; |
1082 | objdata.Text = new byte[0]; | 1082 | objdata.Text = new byte[0]; |
1083 | objdata.TextColor = new byte[4]; | 1083 | objdata.TextColor = new byte[4]; |
1084 | objdata.JointAxisOrAnchor = new LLVector3(0, 0, 0); | 1084 | objdata.JointAxisOrAnchor = new LLVector3(0, 0, 0); |
1085 | objdata.JointPivot = new LLVector3(0, 0, 0); | 1085 | objdata.JointPivot = new LLVector3(0, 0, 0); |
1086 | objdata.Material = 3; | 1086 | objdata.Material = 3; |
1087 | objdata.TextureAnim = new byte[0]; | 1087 | objdata.TextureAnim = new byte[0]; |
1088 | objdata.Sound = LLUUID.Zero; | 1088 | objdata.Sound = LLUUID.Zero; |
1089 | objdata.State = 0; | 1089 | objdata.State = 0; |
1090 | objdata.Data = new byte[0]; | 1090 | objdata.Data = new byte[0]; |
1091 | 1091 | ||
1092 | objdata.ObjectData = new byte[60]; | 1092 | objdata.ObjectData = new byte[60]; |
1093 | objdata.ObjectData[46] = 128; | 1093 | objdata.ObjectData[46] = 128; |
1094 | objdata.ObjectData[47] = 63; | 1094 | objdata.ObjectData[47] = 63; |
1095 | } | 1095 | } |
1096 | 1096 | ||
1097 | 1097 | ||
1098 | /// <summary> | 1098 | /// <summary> |
1099 | /// | 1099 | /// |
1100 | /// </summary> | 1100 | /// </summary> |
1101 | /// <returns></returns> | 1101 | /// <returns></returns> |
1102 | protected ObjectUpdatePacket.ObjectDataBlock CreateDefaultAvatarPacket(byte[] textureEntry) | 1102 | protected ObjectUpdatePacket.ObjectDataBlock CreateDefaultAvatarPacket(byte[] textureEntry) |
1103 | { | 1103 | { |
1104 | ObjectUpdatePacket.ObjectDataBlock objdata = new ObjectUpdatePacket.ObjectDataBlock(); // new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock(data1, ref i); | 1104 | ObjectUpdatePacket.ObjectDataBlock objdata = new ObjectUpdatePacket.ObjectDataBlock(); // new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock(data1, ref i); |
1105 | 1105 | ||
1106 | SetDefaultAvatarPacketValues(ref objdata); | 1106 | SetDefaultAvatarPacketValues(ref objdata); |
1107 | objdata.UpdateFlags = 61 + (9 << 8) + (130 << 16) + (16 << 24); | 1107 | objdata.UpdateFlags = 61 + (9 << 8) + (130 << 16) + (16 << 24); |
1108 | objdata.PathCurve = 16; | 1108 | objdata.PathCurve = 16; |
1109 | objdata.ProfileCurve = 1; | 1109 | objdata.ProfileCurve = 1; |
1110 | objdata.PathScaleX = 100; | 1110 | objdata.PathScaleX = 100; |
1111 | objdata.PathScaleY = 100; | 1111 | objdata.PathScaleY = 100; |
1112 | objdata.ParentID = 0; | 1112 | objdata.ParentID = 0; |
1113 | objdata.OwnerID = LLUUID.Zero; | 1113 | objdata.OwnerID = LLUUID.Zero; |
1114 | objdata.Scale = new LLVector3(1, 1, 1); | 1114 | objdata.Scale = new LLVector3(1, 1, 1); |
1115 | objdata.PCode = 47; | 1115 | objdata.PCode = 47; |
1116 | if (textureEntry != null) | 1116 | if (textureEntry != null) |
1117 | { | 1117 | { |
1118 | objdata.TextureEntry = textureEntry; | 1118 | objdata.TextureEntry = textureEntry; |
1119 | } | 1119 | } |
1120 | Encoding enc = Encoding.ASCII; | 1120 | Encoding enc = Encoding.ASCII; |
1121 | LLVector3 pos = new LLVector3(objdata.ObjectData, 16); | 1121 | LLVector3 pos = new LLVector3(objdata.ObjectData, 16); |
1122 | pos.X = 100f; | 1122 | pos.X = 100f; |
1123 | objdata.ID = 8880000; | 1123 | objdata.ID = 8880000; |
1124 | objdata.NameValue = enc.GetBytes("FirstName STRING RW SV Test \nLastName STRING RW SV User \0"); | 1124 | objdata.NameValue = enc.GetBytes("FirstName STRING RW SV Test \nLastName STRING RW SV User \0"); |
1125 | LLVector3 pos2 = new LLVector3(100f, 100f, 23f); | 1125 | LLVector3 pos2 = new LLVector3(100f, 100f, 23f); |
1126 | //objdata.FullID=user.AgentID; | 1126 | //objdata.FullID=user.AgentID; |
1127 | byte[] pb = pos.GetBytes(); | 1127 | byte[] pb = pos.GetBytes(); |
1128 | Array.Copy(pb, 0, objdata.ObjectData, 16, pb.Length); | 1128 | Array.Copy(pb, 0, objdata.ObjectData, 16, pb.Length); |
1129 | 1129 | ||
1130 | return objdata; | 1130 | return objdata; |
1131 | } | 1131 | } |
1132 | 1132 | ||
1133 | /// <summary> | 1133 | /// <summary> |
1134 | /// | 1134 | /// |
1135 | /// </summary> | 1135 | /// </summary> |
1136 | /// <param name="objdata"></param> | 1136 | /// <param name="objdata"></param> |
1137 | protected void SetDefaultAvatarPacketValues(ref ObjectUpdatePacket.ObjectDataBlock objdata) | 1137 | protected void SetDefaultAvatarPacketValues(ref ObjectUpdatePacket.ObjectDataBlock objdata) |
1138 | { | 1138 | { |
1139 | objdata.PSBlock = new byte[0]; | 1139 | objdata.PSBlock = new byte[0]; |
1140 | objdata.ExtraParams = new byte[1]; | 1140 | objdata.ExtraParams = new byte[1]; |
1141 | objdata.MediaURL = new byte[0]; | 1141 | objdata.MediaURL = new byte[0]; |
1142 | objdata.NameValue = new byte[0]; | 1142 | objdata.NameValue = new byte[0]; |
1143 | objdata.Text = new byte[0]; | 1143 | objdata.Text = new byte[0]; |
1144 | objdata.TextColor = new byte[4]; | 1144 | objdata.TextColor = new byte[4]; |
1145 | objdata.JointAxisOrAnchor = new LLVector3(0, 0, 0); | 1145 | objdata.JointAxisOrAnchor = new LLVector3(0, 0, 0); |
1146 | objdata.JointPivot = new LLVector3(0, 0, 0); | 1146 | objdata.JointPivot = new LLVector3(0, 0, 0); |
1147 | objdata.Material = 4; | 1147 | objdata.Material = 4; |
1148 | objdata.TextureAnim = new byte[0]; | 1148 | objdata.TextureAnim = new byte[0]; |
1149 | objdata.Sound = LLUUID.Zero; | 1149 | objdata.Sound = LLUUID.Zero; |
1150 | LLObject.TextureEntry ntex = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-5005-000000000005")); | 1150 | LLObject.TextureEntry ntex = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-5005-000000000005")); |
1151 | objdata.TextureEntry = ntex.ToBytes(); | 1151 | objdata.TextureEntry = ntex.ToBytes(); |
1152 | objdata.State = 0; | 1152 | objdata.State = 0; |
1153 | objdata.Data = new byte[0]; | 1153 | objdata.Data = new byte[0]; |
1154 | 1154 | ||
1155 | objdata.ObjectData = new byte[76]; | 1155 | objdata.ObjectData = new byte[76]; |
1156 | objdata.ObjectData[15] = 128; | 1156 | objdata.ObjectData[15] = 128; |
1157 | objdata.ObjectData[16] = 63; | 1157 | objdata.ObjectData[16] = 63; |
1158 | objdata.ObjectData[56] = 128; | 1158 | objdata.ObjectData[56] = 128; |
1159 | objdata.ObjectData[61] = 102; | 1159 | objdata.ObjectData[61] = 102; |
1160 | objdata.ObjectData[62] = 40; | 1160 | objdata.ObjectData[62] = 40; |
1161 | objdata.ObjectData[63] = 61; | 1161 | objdata.ObjectData[63] = 61; |
1162 | objdata.ObjectData[64] = 189; | 1162 | objdata.ObjectData[64] = 189; |
1163 | } | 1163 | } |
1164 | 1164 | ||
1165 | #endregion | 1165 | #endregion |
1166 | 1166 | ||
1167 | public void SendNameReply(LLUUID profileId, string firstname, string lastname) | 1167 | public void SendNameReply(LLUUID profileId, string firstname, string lastname) |
1168 | { | 1168 | { |
1169 | UUIDNameReplyPacket packet = new UUIDNameReplyPacket(); | 1169 | UUIDNameReplyPacket packet = new UUIDNameReplyPacket(); |
1170 | 1170 | ||
1171 | packet.UUIDNameBlock = new UUIDNameReplyPacket.UUIDNameBlockBlock[1]; | 1171 | packet.UUIDNameBlock = new UUIDNameReplyPacket.UUIDNameBlockBlock[1]; |
1172 | packet.UUIDNameBlock[0] = new UUIDNameReplyPacket.UUIDNameBlockBlock(); | 1172 | packet.UUIDNameBlock[0] = new UUIDNameReplyPacket.UUIDNameBlockBlock(); |
1173 | packet.UUIDNameBlock[0].ID = profileId; | 1173 | packet.UUIDNameBlock[0].ID = profileId; |
1174 | packet.UUIDNameBlock[0].FirstName = Helpers.StringToField( firstname ); | 1174 | packet.UUIDNameBlock[0].FirstName = Helpers.StringToField( firstname ); |
1175 | packet.UUIDNameBlock[0].LastName = Helpers.StringToField( lastname ); | 1175 | packet.UUIDNameBlock[0].LastName = Helpers.StringToField( lastname ); |
1176 | 1176 | ||
1177 | OutPacket( packet ); | 1177 | OutPacket( packet ); |
1178 | } | 1178 | } |
1179 | } | 1179 | } |
1180 | } | 1180 | } |
diff --git a/OpenSim/Region/ClientStack/ClientView.AgentAssetUpload.cs b/OpenSim/Region/ClientStack/ClientView.AgentAssetUpload.cs index 60cd33a..109f7e6 100644 --- a/OpenSim/Region/ClientStack/ClientView.AgentAssetUpload.cs +++ b/OpenSim/Region/ClientStack/ClientView.AgentAssetUpload.cs | |||
@@ -1,357 +1,357 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | 2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
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 | */ |
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using libsecondlife; | 30 | using libsecondlife; |
31 | using libsecondlife.Packets; | 31 | using libsecondlife.Packets; |
32 | using OpenSim.Assets; | 32 | using OpenSim.Assets; |
33 | using OpenSim.Framework.Interfaces; | 33 | using OpenSim.Framework.Interfaces; |
34 | using OpenSim.Framework.Types; | 34 | using OpenSim.Framework.Types; |
35 | using OpenSim.Framework.Utilities; | 35 | using OpenSim.Framework.Utilities; |
36 | using OpenSim.Region.Caches; | 36 | using OpenSim.Region.Caches; |
37 | 37 | ||
38 | namespace OpenSim.Region.ClientStack | 38 | namespace OpenSim.Region.ClientStack |
39 | { | 39 | { |
40 | partial class ClientView | 40 | partial class ClientView |
41 | { | 41 | { |
42 | public class AgentAssetUpload | 42 | public class AgentAssetUpload |
43 | { | 43 | { |
44 | private Dictionary<LLUUID, AssetTransaction> transactions = new Dictionary<LLUUID, AssetTransaction>(); | 44 | private Dictionary<LLUUID, AssetTransaction> transactions = new Dictionary<LLUUID, AssetTransaction>(); |
45 | private ClientView ourClient; | 45 | private ClientView ourClient; |
46 | private AssetCache m_assetCache; | 46 | private AssetCache m_assetCache; |
47 | private InventoryCache m_inventoryCache; | 47 | private InventoryCache m_inventoryCache; |
48 | 48 | ||
49 | public AgentAssetUpload(ClientView client, AssetCache assetCache, InventoryCache inventoryCache) | 49 | public AgentAssetUpload(ClientView client, AssetCache assetCache, InventoryCache inventoryCache) |
50 | { | 50 | { |
51 | this.ourClient = client; | 51 | this.ourClient = client; |
52 | m_assetCache = assetCache; | 52 | m_assetCache = assetCache; |
53 | m_inventoryCache = inventoryCache; | 53 | m_inventoryCache = inventoryCache; |
54 | } | 54 | } |
55 | 55 | ||
56 | public void AddUpload(LLUUID transactionID, AssetBase asset) | 56 | public void AddUpload(LLUUID transactionID, AssetBase asset) |
57 | { | 57 | { |
58 | AssetTransaction upload = new AssetTransaction(); | 58 | AssetTransaction upload = new AssetTransaction(); |
59 | lock (this.transactions) | 59 | lock (this.transactions) |
60 | { | 60 | { |
61 | upload.Asset = asset; | 61 | upload.Asset = asset; |
62 | upload.TransactionID = transactionID; | 62 | upload.TransactionID = transactionID; |
63 | this.transactions.Add(transactionID, upload); | 63 | this.transactions.Add(transactionID, upload); |
64 | } | 64 | } |
65 | if (upload.Asset.Data.Length > 2) | 65 | if (upload.Asset.Data.Length > 2) |
66 | { | 66 | { |
67 | //is complete | 67 | //is complete |
68 | upload.UploadComplete = true; | 68 | upload.UploadComplete = true; |
69 | AssetUploadCompletePacket response = new AssetUploadCompletePacket(); | 69 | AssetUploadCompletePacket response = new AssetUploadCompletePacket(); |
70 | response.AssetBlock.Type = asset.Type; | 70 | response.AssetBlock.Type = asset.Type; |
71 | response.AssetBlock.Success = true; | 71 | response.AssetBlock.Success = true; |
72 | response.AssetBlock.UUID = transactionID.Combine(this.ourClient.SecureSessionID); | 72 | response.AssetBlock.UUID = transactionID.Combine(this.ourClient.SecureSessionID); |
73 | this.ourClient.OutPacket(response); | 73 | this.ourClient.OutPacket(response); |
74 | m_assetCache.AddAsset(asset); | 74 | m_assetCache.AddAsset(asset); |
75 | } | 75 | } |
76 | else | 76 | else |
77 | { | 77 | { |
78 | upload.UploadComplete = false; | 78 | upload.UploadComplete = false; |
79 | upload.XferID = Util.GetNextXferID(); | 79 | upload.XferID = Util.GetNextXferID(); |
80 | RequestXferPacket xfer = new RequestXferPacket(); | 80 | RequestXferPacket xfer = new RequestXferPacket(); |
81 | xfer.XferID.ID = upload.XferID; | 81 | xfer.XferID.ID = upload.XferID; |
82 | xfer.XferID.VFileType = upload.Asset.Type; | 82 | xfer.XferID.VFileType = upload.Asset.Type; |
83 | xfer.XferID.VFileID = transactionID.Combine(this.ourClient.SecureSessionID); | 83 | xfer.XferID.VFileID = transactionID.Combine(this.ourClient.SecureSessionID); |
84 | xfer.XferID.FilePath = 0; | 84 | xfer.XferID.FilePath = 0; |
85 | xfer.XferID.Filename = new byte[0]; | 85 | xfer.XferID.Filename = new byte[0]; |
86 | this.ourClient.OutPacket(xfer); | 86 | this.ourClient.OutPacket(xfer); |
87 | } | 87 | } |
88 | 88 | ||
89 | } | 89 | } |
90 | 90 | ||
91 | public AssetBase GetUpload(LLUUID transactionID) | 91 | public AssetBase GetUpload(LLUUID transactionID) |
92 | { | 92 | { |
93 | if (this.transactions.ContainsKey(transactionID)) | 93 | if (this.transactions.ContainsKey(transactionID)) |
94 | { | 94 | { |
95 | return this.transactions[transactionID].Asset; | 95 | return this.transactions[transactionID].Asset; |
96 | } | 96 | } |
97 | 97 | ||
98 | return null; | 98 | return null; |
99 | } | 99 | } |
100 | 100 | ||
101 | public void HandleUploadPacket(AssetUploadRequestPacket pack, LLUUID assetID) | 101 | public void HandleUploadPacket(AssetUploadRequestPacket pack, LLUUID assetID) |
102 | { | 102 | { |
103 | // Console.Write("asset upload request , type = " + pack.AssetBlock.Type.ToString()); | 103 | // Console.Write("asset upload request , type = " + pack.AssetBlock.Type.ToString()); |
104 | AssetBase asset = null; | 104 | AssetBase asset = null; |
105 | if (pack.AssetBlock.Type == 0) | 105 | if (pack.AssetBlock.Type == 0) |
106 | { | 106 | { |
107 | 107 | ||
108 | //first packet for transaction | 108 | //first packet for transaction |
109 | asset = new AssetBase(); | 109 | asset = new AssetBase(); |
110 | asset.FullID = assetID; | 110 | asset.FullID = assetID; |
111 | asset.Type = pack.AssetBlock.Type; | 111 | asset.Type = pack.AssetBlock.Type; |
112 | asset.InvType = asset.Type; | 112 | asset.InvType = asset.Type; |
113 | asset.Name = "UploadedTexture" + Util.RandomClass.Next(1, 1000).ToString("000"); | 113 | asset.Name = "UploadedTexture" + Util.RandomClass.Next(1, 1000).ToString("000"); |
114 | asset.Data = pack.AssetBlock.AssetData; | 114 | asset.Data = pack.AssetBlock.AssetData; |
115 | 115 | ||
116 | 116 | ||
117 | } | 117 | } |
118 | else if (pack.AssetBlock.Type == 13 | pack.AssetBlock.Type == 5 | pack.AssetBlock.Type == 7) | 118 | else if (pack.AssetBlock.Type == 13 | pack.AssetBlock.Type == 5 | pack.AssetBlock.Type == 7) |
119 | { | 119 | { |
120 | 120 | ||
121 | asset = new AssetBase(); | 121 | asset = new AssetBase(); |
122 | asset.FullID = assetID; | 122 | asset.FullID = assetID; |
123 | // Console.WriteLine("skin asset id is " + assetID.ToStringHyphenated()); | 123 | // Console.WriteLine("skin asset id is " + assetID.ToStringHyphenated()); |
124 | asset.Type = pack.AssetBlock.Type; | 124 | asset.Type = pack.AssetBlock.Type; |
125 | asset.InvType = asset.Type; | 125 | asset.InvType = asset.Type; |
126 | asset.Name = "NewClothing" + Util.RandomClass.Next(1, 1000).ToString("000"); | 126 | asset.Name = "NewClothing" + Util.RandomClass.Next(1, 1000).ToString("000"); |
127 | asset.Data = pack.AssetBlock.AssetData; | 127 | asset.Data = pack.AssetBlock.AssetData; |
128 | 128 | ||
129 | 129 | ||
130 | } | 130 | } |
131 | 131 | ||
132 | if (asset != null) | 132 | if (asset != null) |
133 | { | 133 | { |
134 | this.AddUpload(pack.AssetBlock.TransactionID, asset); | 134 | this.AddUpload(pack.AssetBlock.TransactionID, asset); |
135 | } | 135 | } |
136 | else | 136 | else |
137 | { | 137 | { |
138 | 138 | ||
139 | //currently we don't support this asset type | 139 | //currently we don't support this asset type |
140 | //so lets just tell the client that the upload is complete | 140 | //so lets just tell the client that the upload is complete |
141 | AssetUploadCompletePacket response = new AssetUploadCompletePacket(); | 141 | AssetUploadCompletePacket response = new AssetUploadCompletePacket(); |
142 | response.AssetBlock.Type = pack.AssetBlock.Type; | 142 | response.AssetBlock.Type = pack.AssetBlock.Type; |
143 | response.AssetBlock.Success = true; | 143 | response.AssetBlock.Success = true; |
144 | response.AssetBlock.UUID = pack.AssetBlock.TransactionID.Combine(this.ourClient.SecureSessionID); | 144 | response.AssetBlock.UUID = pack.AssetBlock.TransactionID.Combine(this.ourClient.SecureSessionID); |
145 | this.ourClient.OutPacket(response); | 145 | this.ourClient.OutPacket(response); |
146 | } | 146 | } |
147 | 147 | ||
148 | } | 148 | } |
149 | 149 | ||
150 | #region Xfer packet system for larger uploads | 150 | #region Xfer packet system for larger uploads |
151 | 151 | ||
152 | public void HandleXferPacket(SendXferPacketPacket xferPacket) | 152 | public void HandleXferPacket(SendXferPacketPacket xferPacket) |
153 | { | 153 | { |
154 | lock (this.transactions) | 154 | lock (this.transactions) |
155 | { | 155 | { |
156 | foreach (AssetTransaction trans in this.transactions.Values) | 156 | foreach (AssetTransaction trans in this.transactions.Values) |
157 | { | 157 | { |
158 | if (trans.XferID == xferPacket.XferID.ID) | 158 | if (trans.XferID == xferPacket.XferID.ID) |
159 | { | 159 | { |
160 | if (trans.Asset.Data.Length > 1) | 160 | if (trans.Asset.Data.Length > 1) |
161 | { | 161 | { |
162 | byte[] newArray = new byte[trans.Asset.Data.Length + xferPacket.DataPacket.Data.Length]; | 162 | byte[] newArray = new byte[trans.Asset.Data.Length + xferPacket.DataPacket.Data.Length]; |
163 | Array.Copy(trans.Asset.Data, 0, newArray, 0, trans.Asset.Data.Length); | 163 | Array.Copy(trans.Asset.Data, 0, newArray, 0, trans.Asset.Data.Length); |
164 | Array.Copy(xferPacket.DataPacket.Data, 0, newArray, trans.Asset.Data.Length, xferPacket.DataPacket.Data.Length); | 164 | Array.Copy(xferPacket.DataPacket.Data, 0, newArray, trans.Asset.Data.Length, xferPacket.DataPacket.Data.Length); |
165 | trans.Asset.Data = newArray; | 165 | trans.Asset.Data = newArray; |
166 | } | 166 | } |
167 | else | 167 | else |
168 | { | 168 | { |
169 | byte[] newArray = new byte[xferPacket.DataPacket.Data.Length - 4]; | 169 | byte[] newArray = new byte[xferPacket.DataPacket.Data.Length - 4]; |
170 | Array.Copy(xferPacket.DataPacket.Data, 4, newArray, 0, xferPacket.DataPacket.Data.Length - 4); | 170 | Array.Copy(xferPacket.DataPacket.Data, 4, newArray, 0, xferPacket.DataPacket.Data.Length - 4); |
171 | trans.Asset.Data = newArray; | 171 | trans.Asset.Data = newArray; |
172 | } | 172 | } |
173 | 173 | ||
174 | if ((xferPacket.XferID.Packet & 2147483648) != 0) | 174 | if ((xferPacket.XferID.Packet & 2147483648) != 0) |
175 | { | 175 | { |
176 | //end of transfer | 176 | //end of transfer |
177 | trans.UploadComplete = true; | 177 | trans.UploadComplete = true; |
178 | AssetUploadCompletePacket response = new AssetUploadCompletePacket(); | 178 | AssetUploadCompletePacket response = new AssetUploadCompletePacket(); |
179 | response.AssetBlock.Type = trans.Asset.Type; | 179 | response.AssetBlock.Type = trans.Asset.Type; |
180 | response.AssetBlock.Success = true; | 180 | response.AssetBlock.Success = true; |
181 | response.AssetBlock.UUID = trans.TransactionID.Combine(this.ourClient.SecureSessionID); | 181 | response.AssetBlock.UUID = trans.TransactionID.Combine(this.ourClient.SecureSessionID); |
182 | this.ourClient.OutPacket(response); | 182 | this.ourClient.OutPacket(response); |
183 | 183 | ||
184 | m_assetCache.AddAsset(trans.Asset); | 184 | m_assetCache.AddAsset(trans.Asset); |
185 | //check if we should add it to inventory | 185 | //check if we should add it to inventory |
186 | if (trans.AddToInventory) | 186 | if (trans.AddToInventory) |
187 | { | 187 | { |
188 | // m_assetCache.AddAsset(trans.Asset); | 188 | // m_assetCache.AddAsset(trans.Asset); |
189 | m_inventoryCache.AddNewInventoryItem(this.ourClient, trans.InventFolder, trans.Asset); | 189 | m_inventoryCache.AddNewInventoryItem(this.ourClient, trans.InventFolder, trans.Asset); |
190 | } | 190 | } |
191 | 191 | ||
192 | 192 | ||
193 | } | 193 | } |
194 | break; | 194 | break; |
195 | } | 195 | } |
196 | 196 | ||
197 | } | 197 | } |
198 | } | 198 | } |
199 | 199 | ||
200 | ConfirmXferPacketPacket confirmXfer = new ConfirmXferPacketPacket(); | 200 | ConfirmXferPacketPacket confirmXfer = new ConfirmXferPacketPacket(); |
201 | confirmXfer.XferID.ID = xferPacket.XferID.ID; | 201 | confirmXfer.XferID.ID = xferPacket.XferID.ID; |
202 | confirmXfer.XferID.Packet = xferPacket.XferID.Packet; | 202 | confirmXfer.XferID.Packet = xferPacket.XferID.Packet; |
203 | this.ourClient.OutPacket(confirmXfer); | 203 | this.ourClient.OutPacket(confirmXfer); |
204 | } | 204 | } |
205 | 205 | ||
206 | #endregion | 206 | #endregion |
207 | 207 | ||
208 | public AssetBase AddUploadToAssetCache(LLUUID transactionID) | 208 | public AssetBase AddUploadToAssetCache(LLUUID transactionID) |
209 | { | 209 | { |
210 | AssetBase asset = null; | 210 | AssetBase asset = null; |
211 | if (this.transactions.ContainsKey(transactionID)) | 211 | if (this.transactions.ContainsKey(transactionID)) |
212 | { | 212 | { |
213 | AssetTransaction trans = this.transactions[transactionID]; | 213 | AssetTransaction trans = this.transactions[transactionID]; |
214 | if (trans.UploadComplete) | 214 | if (trans.UploadComplete) |
215 | { | 215 | { |
216 | m_assetCache.AddAsset(trans.Asset); | 216 | m_assetCache.AddAsset(trans.Asset); |
217 | asset = trans.Asset; | 217 | asset = trans.Asset; |
218 | } | 218 | } |
219 | } | 219 | } |
220 | 220 | ||
221 | return asset; | 221 | return asset; |
222 | } | 222 | } |
223 | 223 | ||
224 | public void CreateInventoryItem(CreateInventoryItemPacket packet) | 224 | public void CreateInventoryItem(CreateInventoryItemPacket packet) |
225 | { | 225 | { |
226 | if (this.transactions.ContainsKey(packet.InventoryBlock.TransactionID)) | 226 | if (this.transactions.ContainsKey(packet.InventoryBlock.TransactionID)) |
227 | { | 227 | { |
228 | AssetTransaction trans = this.transactions[packet.InventoryBlock.TransactionID]; | 228 | AssetTransaction trans = this.transactions[packet.InventoryBlock.TransactionID]; |
229 | trans.Asset.Description = Util.FieldToString(packet.InventoryBlock.Description); | 229 | trans.Asset.Description = Util.FieldToString(packet.InventoryBlock.Description); |
230 | trans.Asset.Name = Util.FieldToString(packet.InventoryBlock.Name); | 230 | trans.Asset.Name = Util.FieldToString(packet.InventoryBlock.Name); |
231 | trans.Asset.Type = packet.InventoryBlock.Type; | 231 | trans.Asset.Type = packet.InventoryBlock.Type; |
232 | trans.Asset.InvType = packet.InventoryBlock.InvType; | 232 | trans.Asset.InvType = packet.InventoryBlock.InvType; |
233 | if (trans.UploadComplete) | 233 | if (trans.UploadComplete) |
234 | { | 234 | { |
235 | //already complete so we can add it to the inventory | 235 | //already complete so we can add it to the inventory |
236 | //m_assetCache.AddAsset(trans.Asset); | 236 | //m_assetCache.AddAsset(trans.Asset); |
237 | m_inventoryCache.AddNewInventoryItem(this.ourClient, packet.InventoryBlock.FolderID, trans.Asset); | 237 | m_inventoryCache.AddNewInventoryItem(this.ourClient, packet.InventoryBlock.FolderID, trans.Asset); |
238 | } | 238 | } |
239 | else | 239 | else |
240 | { | 240 | { |
241 | trans.AddToInventory = true; | 241 | trans.AddToInventory = true; |
242 | trans.InventFolder = packet.InventoryBlock.FolderID; | 242 | trans.InventFolder = packet.InventoryBlock.FolderID; |
243 | } | 243 | } |
244 | } | 244 | } |
245 | } | 245 | } |
246 | 246 | ||
247 | private class AssetTransaction | 247 | private class AssetTransaction |
248 | { | 248 | { |
249 | public uint XferID; | 249 | public uint XferID; |
250 | public AssetBase Asset; | 250 | public AssetBase Asset; |
251 | public bool AddToInventory; | 251 | public bool AddToInventory; |
252 | public LLUUID InventFolder = LLUUID.Zero; | 252 | public LLUUID InventFolder = LLUUID.Zero; |
253 | public bool UploadComplete = false; | 253 | public bool UploadComplete = false; |
254 | public LLUUID TransactionID = LLUUID.Zero; | 254 | public LLUUID TransactionID = LLUUID.Zero; |
255 | 255 | ||
256 | public AssetTransaction() | 256 | public AssetTransaction() |
257 | { | 257 | { |
258 | 258 | ||
259 | } | 259 | } |
260 | } | 260 | } |
261 | 261 | ||
262 | //new class , not currently used. | 262 | //new class , not currently used. |
263 | public class AssetXferUploader | 263 | public class AssetXferUploader |
264 | { | 264 | { |
265 | private IClientAPI ourClient; | 265 | private IClientAPI ourClient; |
266 | 266 | ||
267 | public bool UploadComplete = false; | 267 | public bool UploadComplete = false; |
268 | 268 | ||
269 | public bool AddToInventory; | 269 | public bool AddToInventory; |
270 | public LLUUID InventFolder = LLUUID.Zero; | 270 | public LLUUID InventFolder = LLUUID.Zero; |
271 | 271 | ||
272 | public uint XferID; | 272 | public uint XferID; |
273 | public AssetBase Asset; | 273 | public AssetBase Asset; |
274 | public LLUUID TransactionID = LLUUID.Zero; | 274 | public LLUUID TransactionID = LLUUID.Zero; |
275 | 275 | ||
276 | 276 | ||
277 | public AssetXferUploader(IClientAPI remoteClient, LLUUID assetID, LLUUID transaction, sbyte type, byte[] data) | 277 | public AssetXferUploader(IClientAPI remoteClient, LLUUID assetID, LLUUID transaction, sbyte type, byte[] data) |
278 | { | 278 | { |
279 | ourClient = remoteClient; | 279 | ourClient = remoteClient; |
280 | Asset = new AssetBase(); | 280 | Asset = new AssetBase(); |
281 | Asset.FullID = assetID; | 281 | Asset.FullID = assetID; |
282 | Asset.InvType = type; | 282 | Asset.InvType = type; |
283 | Asset.Type = type; | 283 | Asset.Type = type; |
284 | Asset.Data = data; | 284 | Asset.Data = data; |
285 | Asset.Name = "blank"; | 285 | Asset.Name = "blank"; |
286 | Asset.Description = "empty"; | 286 | Asset.Description = "empty"; |
287 | TransactionID = transaction; | 287 | TransactionID = transaction; |
288 | 288 | ||
289 | if (Asset.Data.Length > 2) | 289 | if (Asset.Data.Length > 2) |
290 | { | 290 | { |
291 | //data block should only have data in it, if there is no more data to be uploaded | 291 | //data block should only have data in it, if there is no more data to be uploaded |
292 | this.SendCompleteMessage(); | 292 | this.SendCompleteMessage(); |
293 | } | 293 | } |
294 | else | 294 | else |
295 | { | 295 | { |
296 | this.ReqestStartXfer(); | 296 | this.ReqestStartXfer(); |
297 | } | 297 | } |
298 | } | 298 | } |
299 | 299 | ||
300 | protected void SendCompleteMessage() | 300 | protected void SendCompleteMessage() |
301 | { | 301 | { |
302 | UploadComplete = true; | 302 | UploadComplete = true; |
303 | AssetUploadCompletePacket response = new AssetUploadCompletePacket(); | 303 | AssetUploadCompletePacket response = new AssetUploadCompletePacket(); |
304 | response.AssetBlock.Type = Asset.Type; | 304 | response.AssetBlock.Type = Asset.Type; |
305 | response.AssetBlock.Success = true; | 305 | response.AssetBlock.Success = true; |
306 | response.AssetBlock.UUID = Asset.FullID; | 306 | response.AssetBlock.UUID = Asset.FullID; |
307 | this.ourClient.OutPacket(response); | 307 | this.ourClient.OutPacket(response); |
308 | 308 | ||
309 | //TODO trigger event | 309 | //TODO trigger event |
310 | } | 310 | } |
311 | 311 | ||
312 | protected void ReqestStartXfer() | 312 | protected void ReqestStartXfer() |
313 | { | 313 | { |
314 | UploadComplete = false; | 314 | UploadComplete = false; |
315 | XferID = Util.GetNextXferID(); | 315 | XferID = Util.GetNextXferID(); |
316 | RequestXferPacket xfer = new RequestXferPacket(); | 316 | RequestXferPacket xfer = new RequestXferPacket(); |
317 | xfer.XferID.ID = XferID; | 317 | xfer.XferID.ID = XferID; |
318 | xfer.XferID.VFileType = Asset.Type; | 318 | xfer.XferID.VFileType = Asset.Type; |
319 | xfer.XferID.VFileID = Asset.FullID; | 319 | xfer.XferID.VFileID = Asset.FullID; |
320 | xfer.XferID.FilePath = 0; | 320 | xfer.XferID.FilePath = 0; |
321 | xfer.XferID.Filename = new byte[0]; | 321 | xfer.XferID.Filename = new byte[0]; |
322 | this.ourClient.OutPacket(xfer); | 322 | this.ourClient.OutPacket(xfer); |
323 | } | 323 | } |
324 | 324 | ||
325 | public void HandleXferPacket(uint xferID, uint packetID, byte[] data) | 325 | public void HandleXferPacket(uint xferID, uint packetID, byte[] data) |
326 | { | 326 | { |
327 | if (XferID == xferID) | 327 | if (XferID == xferID) |
328 | { | 328 | { |
329 | if (Asset.Data.Length > 1) | 329 | if (Asset.Data.Length > 1) |
330 | { | 330 | { |
331 | byte[] newArray = new byte[Asset.Data.Length + data.Length]; | 331 | byte[] newArray = new byte[Asset.Data.Length + data.Length]; |
332 | Array.Copy(Asset.Data, 0, newArray, 0, Asset.Data.Length); | 332 | Array.Copy(Asset.Data, 0, newArray, 0, Asset.Data.Length); |
333 | Array.Copy(data, 0, newArray, Asset.Data.Length, data.Length); | 333 | Array.Copy(data, 0, newArray, Asset.Data.Length, data.Length); |
334 | Asset.Data = newArray; | 334 | Asset.Data = newArray; |
335 | } | 335 | } |
336 | else | 336 | else |
337 | { | 337 | { |
338 | byte[] newArray = new byte[data.Length - 4]; | 338 | byte[] newArray = new byte[data.Length - 4]; |
339 | Array.Copy(data, 4, newArray, 0, data.Length - 4); | 339 | Array.Copy(data, 4, newArray, 0, data.Length - 4); |
340 | Asset.Data = newArray; | 340 | Asset.Data = newArray; |
341 | } | 341 | } |
342 | 342 | ||
343 | ConfirmXferPacketPacket confirmXfer = new ConfirmXferPacketPacket(); | 343 | ConfirmXferPacketPacket confirmXfer = new ConfirmXferPacketPacket(); |
344 | confirmXfer.XferID.ID = xferID; | 344 | confirmXfer.XferID.ID = xferID; |
345 | confirmXfer.XferID.Packet = packetID; | 345 | confirmXfer.XferID.Packet = packetID; |
346 | this.ourClient.OutPacket(confirmXfer); | 346 | this.ourClient.OutPacket(confirmXfer); |
347 | 347 | ||
348 | if ((packetID & 2147483648) != 0) | 348 | if ((packetID & 2147483648) != 0) |
349 | { | 349 | { |
350 | this.SendCompleteMessage(); | 350 | this.SendCompleteMessage(); |
351 | } | 351 | } |
352 | } | 352 | } |
353 | } | 353 | } |
354 | } | 354 | } |
355 | } | 355 | } |
356 | } | 356 | } |
357 | } | 357 | } |
diff --git a/OpenSim/Region/ClientStack/ClientView.PacketHandlers.cs b/OpenSim/Region/ClientStack/ClientView.PacketHandlers.cs index e67807e..27265cf 100644 --- a/OpenSim/Region/ClientStack/ClientView.PacketHandlers.cs +++ b/OpenSim/Region/ClientStack/ClientView.PacketHandlers.cs | |||
@@ -1,236 +1,236 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | 2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
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 | */ |
28 | using libsecondlife; | 28 | using libsecondlife; |
29 | using libsecondlife.Packets; | 29 | using libsecondlife.Packets; |
30 | using OpenSim.Framework.Console; | 30 | using OpenSim.Framework.Console; |
31 | 31 | ||
32 | namespace OpenSim.Region.ClientStack | 32 | namespace OpenSim.Region.ClientStack |
33 | { | 33 | { |
34 | public partial class ClientView | 34 | public partial class ClientView |
35 | { | 35 | { |
36 | protected virtual void RegisterLocalPacketHandlers() | 36 | protected virtual void RegisterLocalPacketHandlers() |
37 | { | 37 | { |
38 | this.AddLocalPacketHandler(PacketType.LogoutRequest, this.Logout); | 38 | this.AddLocalPacketHandler(PacketType.LogoutRequest, this.Logout); |
39 | this.AddLocalPacketHandler(PacketType.AgentCachedTexture, this.AgentTextureCached); | 39 | this.AddLocalPacketHandler(PacketType.AgentCachedTexture, this.AgentTextureCached); |
40 | this.AddLocalPacketHandler(PacketType.MultipleObjectUpdate, this.MultipleObjUpdate); | 40 | this.AddLocalPacketHandler(PacketType.MultipleObjectUpdate, this.MultipleObjUpdate); |
41 | } | 41 | } |
42 | 42 | ||
43 | protected virtual bool Logout(ClientView simClient, Packet packet) | 43 | protected virtual bool Logout(ClientView simClient, Packet packet) |
44 | { | 44 | { |
45 | MainLog.Instance.Verbose( "OpenSimClient.cs:ProcessInPacket() - Got a logout request"); | 45 | MainLog.Instance.Verbose( "OpenSimClient.cs:ProcessInPacket() - Got a logout request"); |
46 | //send reply to let the client logout | 46 | //send reply to let the client logout |
47 | LogoutReplyPacket logReply = new LogoutReplyPacket(); | 47 | LogoutReplyPacket logReply = new LogoutReplyPacket(); |
48 | logReply.AgentData.AgentID = this.AgentID; | 48 | logReply.AgentData.AgentID = this.AgentID; |
49 | logReply.AgentData.SessionID = this.SessionID; | 49 | logReply.AgentData.SessionID = this.SessionID; |
50 | logReply.InventoryData = new LogoutReplyPacket.InventoryDataBlock[1]; | 50 | logReply.InventoryData = new LogoutReplyPacket.InventoryDataBlock[1]; |
51 | logReply.InventoryData[0] = new LogoutReplyPacket.InventoryDataBlock(); | 51 | logReply.InventoryData[0] = new LogoutReplyPacket.InventoryDataBlock(); |
52 | logReply.InventoryData[0].ItemID = LLUUID.Zero; | 52 | logReply.InventoryData[0].ItemID = LLUUID.Zero; |
53 | OutPacket(logReply); | 53 | OutPacket(logReply); |
54 | // | 54 | // |
55 | this.KillClient(); | 55 | this.KillClient(); |
56 | return true; | 56 | return true; |
57 | } | 57 | } |
58 | 58 | ||
59 | protected bool AgentTextureCached(ClientView simclient, Packet packet) | 59 | protected bool AgentTextureCached(ClientView simclient, Packet packet) |
60 | { | 60 | { |
61 | // Console.WriteLine(packet.ToString()); | 61 | // Console.WriteLine(packet.ToString()); |
62 | AgentCachedTexturePacket chechedtex = (AgentCachedTexturePacket)packet; | 62 | AgentCachedTexturePacket chechedtex = (AgentCachedTexturePacket)packet; |
63 | AgentCachedTextureResponsePacket cachedresp = new AgentCachedTextureResponsePacket(); | 63 | AgentCachedTextureResponsePacket cachedresp = new AgentCachedTextureResponsePacket(); |
64 | cachedresp.AgentData.AgentID = this.AgentID; | 64 | cachedresp.AgentData.AgentID = this.AgentID; |
65 | cachedresp.AgentData.SessionID = this.SessionID; | 65 | cachedresp.AgentData.SessionID = this.SessionID; |
66 | cachedresp.AgentData.SerialNum = this.cachedtextureserial; | 66 | cachedresp.AgentData.SerialNum = this.cachedtextureserial; |
67 | this.cachedtextureserial++; | 67 | this.cachedtextureserial++; |
68 | cachedresp.WearableData = new AgentCachedTextureResponsePacket.WearableDataBlock[chechedtex.WearableData.Length]; | 68 | cachedresp.WearableData = new AgentCachedTextureResponsePacket.WearableDataBlock[chechedtex.WearableData.Length]; |
69 | for (int i = 0; i < chechedtex.WearableData.Length; i++) | 69 | for (int i = 0; i < chechedtex.WearableData.Length; i++) |
70 | { | 70 | { |
71 | cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock(); | 71 | cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock(); |
72 | cachedresp.WearableData[i].TextureIndex = chechedtex.WearableData[i].TextureIndex; | 72 | cachedresp.WearableData[i].TextureIndex = chechedtex.WearableData[i].TextureIndex; |
73 | cachedresp.WearableData[i].TextureID = LLUUID.Zero; | 73 | cachedresp.WearableData[i].TextureID = LLUUID.Zero; |
74 | cachedresp.WearableData[i].HostName = new byte[0]; | 74 | cachedresp.WearableData[i].HostName = new byte[0]; |
75 | } | 75 | } |
76 | this.OutPacket(cachedresp); | 76 | this.OutPacket(cachedresp); |
77 | return true; | 77 | return true; |
78 | } | 78 | } |
79 | 79 | ||
80 | protected bool MultipleObjUpdate(ClientView simClient, Packet packet) | 80 | protected bool MultipleObjUpdate(ClientView simClient, Packet packet) |
81 | { | 81 | { |
82 | MultipleObjectUpdatePacket multipleupdate = (MultipleObjectUpdatePacket)packet; | 82 | MultipleObjectUpdatePacket multipleupdate = (MultipleObjectUpdatePacket)packet; |
83 | //System.Console.WriteLine("new multi update packet " + multipleupdate.ToString()); | 83 | //System.Console.WriteLine("new multi update packet " + multipleupdate.ToString()); |
84 | for (int i = 0; i < multipleupdate.ObjectData.Length; i++) | 84 | for (int i = 0; i < multipleupdate.ObjectData.Length; i++) |
85 | { | 85 | { |
86 | #region position | 86 | #region position |
87 | if (multipleupdate.ObjectData[i].Type == 9) //change position | 87 | if (multipleupdate.ObjectData[i].Type == 9) //change position |
88 | { | 88 | { |
89 | if (OnUpdatePrimGroupPosition != null) | 89 | if (OnUpdatePrimGroupPosition != null) |
90 | { | 90 | { |
91 | LLVector3 pos = new LLVector3(multipleupdate.ObjectData[i].Data, 0); | 91 | LLVector3 pos = new LLVector3(multipleupdate.ObjectData[i].Data, 0); |
92 | OnUpdatePrimGroupPosition(multipleupdate.ObjectData[i].ObjectLocalID, pos, this); | 92 | OnUpdatePrimGroupPosition(multipleupdate.ObjectData[i].ObjectLocalID, pos, this); |
93 | } | 93 | } |
94 | 94 | ||
95 | } | 95 | } |
96 | else if (multipleupdate.ObjectData[i].Type == 1) //single item of group change position | 96 | else if (multipleupdate.ObjectData[i].Type == 1) //single item of group change position |
97 | { | 97 | { |
98 | if (OnUpdatePrimSinglePosition != null) | 98 | if (OnUpdatePrimSinglePosition != null) |
99 | { | 99 | { |
100 | libsecondlife.LLVector3 pos = new LLVector3(multipleupdate.ObjectData[i].Data, 0); | 100 | libsecondlife.LLVector3 pos = new LLVector3(multipleupdate.ObjectData[i].Data, 0); |
101 | // System.Console.WriteLine("new movement position is " + pos.X + " , " + pos.Y + " , " + pos.Z); | 101 | // System.Console.WriteLine("new movement position is " + pos.X + " , " + pos.Y + " , " + pos.Z); |
102 | OnUpdatePrimSinglePosition(multipleupdate.ObjectData[i].ObjectLocalID, pos, this); | 102 | OnUpdatePrimSinglePosition(multipleupdate.ObjectData[i].ObjectLocalID, pos, this); |
103 | } | 103 | } |
104 | } | 104 | } |
105 | #endregion position | 105 | #endregion position |
106 | #region rotation | 106 | #region rotation |
107 | else if (multipleupdate.ObjectData[i].Type == 2)// single item of group rotation from tab | 107 | else if (multipleupdate.ObjectData[i].Type == 2)// single item of group rotation from tab |
108 | { | 108 | { |
109 | if (OnUpdatePrimSingleRotation != null) | 109 | if (OnUpdatePrimSingleRotation != null) |
110 | { | 110 | { |
111 | LLQuaternion rot = new LLQuaternion(multipleupdate.ObjectData[i].Data, 0, true); | 111 | LLQuaternion rot = new LLQuaternion(multipleupdate.ObjectData[i].Data, 0, true); |
112 | // Console.WriteLine("new rotation is " + rot.X + " , " + rot.Y + " , " + rot.Z + " , " + rot.W); | 112 | // Console.WriteLine("new rotation is " + rot.X + " , " + rot.Y + " , " + rot.Z + " , " + rot.W); |
113 | OnUpdatePrimSingleRotation(multipleupdate.ObjectData[i].ObjectLocalID, rot, this); | 113 | OnUpdatePrimSingleRotation(multipleupdate.ObjectData[i].ObjectLocalID, rot, this); |
114 | } | 114 | } |
115 | } | 115 | } |
116 | else if (multipleupdate.ObjectData[i].Type == 3)// single item of group rotation from mouse | 116 | else if (multipleupdate.ObjectData[i].Type == 3)// single item of group rotation from mouse |
117 | { | 117 | { |
118 | if (OnUpdatePrimSingleRotation != null) | 118 | if (OnUpdatePrimSingleRotation != null) |
119 | { | 119 | { |
120 | libsecondlife.LLQuaternion rot = new LLQuaternion(multipleupdate.ObjectData[i].Data, 12, true); | 120 | libsecondlife.LLQuaternion rot = new LLQuaternion(multipleupdate.ObjectData[i].Data, 12, true); |
121 | // Console.WriteLine("new rotation is " + rot.X + " , " + rot.Y + " , " + rot.Z + " , " + rot.W); | 121 | // Console.WriteLine("new rotation is " + rot.X + " , " + rot.Y + " , " + rot.Z + " , " + rot.W); |
122 | OnUpdatePrimSingleRotation(multipleupdate.ObjectData[i].ObjectLocalID, rot, this); | 122 | OnUpdatePrimSingleRotation(multipleupdate.ObjectData[i].ObjectLocalID, rot, this); |
123 | } | 123 | } |
124 | } | 124 | } |
125 | else if (multipleupdate.ObjectData[i].Type == 10)//group rotation from object tab | 125 | else if (multipleupdate.ObjectData[i].Type == 10)//group rotation from object tab |
126 | { | 126 | { |
127 | if (OnUpdatePrimGroupRotation != null) | 127 | if (OnUpdatePrimGroupRotation != null) |
128 | { | 128 | { |
129 | libsecondlife.LLQuaternion rot = new LLQuaternion(multipleupdate.ObjectData[i].Data, 0, true); | 129 | libsecondlife.LLQuaternion rot = new LLQuaternion(multipleupdate.ObjectData[i].Data, 0, true); |
130 | // Console.WriteLine("new rotation is " + rot.X + " , " + rot.Y + " , " + rot.Z + " , " + rot.W); | 130 | // Console.WriteLine("new rotation is " + rot.X + " , " + rot.Y + " , " + rot.Z + " , " + rot.W); |
131 | OnUpdatePrimGroupRotation(multipleupdate.ObjectData[i].ObjectLocalID, rot, this); | 131 | OnUpdatePrimGroupRotation(multipleupdate.ObjectData[i].ObjectLocalID, rot, this); |
132 | } | 132 | } |
133 | } | 133 | } |
134 | else if (multipleupdate.ObjectData[i].Type == 11)//group rotation from mouse | 134 | else if (multipleupdate.ObjectData[i].Type == 11)//group rotation from mouse |
135 | { | 135 | { |
136 | if (OnUpdatePrimGroupMouseRotation != null) | 136 | if (OnUpdatePrimGroupMouseRotation != null) |
137 | { | 137 | { |
138 | libsecondlife.LLVector3 pos = new LLVector3(multipleupdate.ObjectData[i].Data, 0); | 138 | libsecondlife.LLVector3 pos = new LLVector3(multipleupdate.ObjectData[i].Data, 0); |
139 | libsecondlife.LLQuaternion rot = new LLQuaternion(multipleupdate.ObjectData[i].Data, 12, true); | 139 | libsecondlife.LLQuaternion rot = new LLQuaternion(multipleupdate.ObjectData[i].Data, 12, true); |
140 | //Console.WriteLine("new rotation position is " + pos.X + " , " + pos.Y + " , " + pos.Z); | 140 | //Console.WriteLine("new rotation position is " + pos.X + " , " + pos.Y + " , " + pos.Z); |
141 | // Console.WriteLine("new rotation is " + rot.X + " , " + rot.Y + " , " + rot.Z + " , " + rot.W); | 141 | // Console.WriteLine("new rotation is " + rot.X + " , " + rot.Y + " , " + rot.Z + " , " + rot.W); |
142 | OnUpdatePrimGroupMouseRotation(multipleupdate.ObjectData[i].ObjectLocalID, pos, rot, this); | 142 | OnUpdatePrimGroupMouseRotation(multipleupdate.ObjectData[i].ObjectLocalID, pos, rot, this); |
143 | } | 143 | } |
144 | } | 144 | } |
145 | #endregion | 145 | #endregion |
146 | #region scale | 146 | #region scale |
147 | else if (multipleupdate.ObjectData[i].Type == 13)//group scale from object tab | 147 | else if (multipleupdate.ObjectData[i].Type == 13)//group scale from object tab |
148 | { | 148 | { |
149 | if (OnUpdatePrimScale != null) | 149 | if (OnUpdatePrimScale != null) |
150 | { | 150 | { |
151 | LLVector3 scale = new LLVector3(multipleupdate.ObjectData[i].Data, 12); | 151 | LLVector3 scale = new LLVector3(multipleupdate.ObjectData[i].Data, 12); |
152 | //Console.WriteLine("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z); | 152 | //Console.WriteLine("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z); |
153 | OnUpdatePrimScale(multipleupdate.ObjectData[i].ObjectLocalID, scale, this); | 153 | OnUpdatePrimScale(multipleupdate.ObjectData[i].ObjectLocalID, scale, this); |
154 | } | 154 | } |
155 | } | 155 | } |
156 | else if (multipleupdate.ObjectData[i].Type == 29)//group scale from mouse | 156 | else if (multipleupdate.ObjectData[i].Type == 29)//group scale from mouse |
157 | { | 157 | { |
158 | if (OnUpdatePrimScale != null) | 158 | if (OnUpdatePrimScale != null) |
159 | { | 159 | { |
160 | libsecondlife.LLVector3 scale = new LLVector3(multipleupdate.ObjectData[i].Data, 0); | 160 | libsecondlife.LLVector3 scale = new LLVector3(multipleupdate.ObjectData[i].Data, 0); |
161 | // Console.WriteLine("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z ); | 161 | // Console.WriteLine("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z ); |
162 | // OnUpdatePrimScale(multipleupdate.ObjectData[i].ObjectLocalID, scale, this); | 162 | // OnUpdatePrimScale(multipleupdate.ObjectData[i].ObjectLocalID, scale, this); |
163 | } | 163 | } |
164 | } | 164 | } |
165 | else if (multipleupdate.ObjectData[i].Type == 5)//single prim scale from object tab | 165 | else if (multipleupdate.ObjectData[i].Type == 5)//single prim scale from object tab |
166 | { | 166 | { |
167 | if (OnUpdatePrimScale != null) | 167 | if (OnUpdatePrimScale != null) |
168 | { | 168 | { |
169 | libsecondlife.LLVector3 scale = new LLVector3(multipleupdate.ObjectData[i].Data, 12); | 169 | libsecondlife.LLVector3 scale = new LLVector3(multipleupdate.ObjectData[i].Data, 12); |
170 | // Console.WriteLine("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z); | 170 | // Console.WriteLine("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z); |
171 | OnUpdatePrimScale(multipleupdate.ObjectData[i].ObjectLocalID, scale, this); | 171 | OnUpdatePrimScale(multipleupdate.ObjectData[i].ObjectLocalID, scale, this); |
172 | } | 172 | } |
173 | } | 173 | } |
174 | else if (multipleupdate.ObjectData[i].Type == 21)//single prim scale from mouse | 174 | else if (multipleupdate.ObjectData[i].Type == 21)//single prim scale from mouse |
175 | { | 175 | { |
176 | if (OnUpdatePrimScale != null) | 176 | if (OnUpdatePrimScale != null) |
177 | { | 177 | { |
178 | libsecondlife.LLVector3 scale = new LLVector3(multipleupdate.ObjectData[i].Data, 12); | 178 | libsecondlife.LLVector3 scale = new LLVector3(multipleupdate.ObjectData[i].Data, 12); |
179 | // Console.WriteLine("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z); | 179 | // Console.WriteLine("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z); |
180 | OnUpdatePrimScale(multipleupdate.ObjectData[i].ObjectLocalID, scale, this); | 180 | OnUpdatePrimScale(multipleupdate.ObjectData[i].ObjectLocalID, scale, this); |
181 | } | 181 | } |
182 | } | 182 | } |
183 | #endregion | 183 | #endregion |
184 | } | 184 | } |
185 | return true; | 185 | return true; |
186 | } | 186 | } |
187 | 187 | ||
188 | public void RequestMapLayer() | 188 | public void RequestMapLayer() |
189 | { | 189 | { |
190 | //should be getting the map layer from the grid server | 190 | //should be getting the map layer from the grid server |
191 | //send a layer covering the 800,800 - 1200,1200 area (should be covering the requested area) | 191 | //send a layer covering the 800,800 - 1200,1200 area (should be covering the requested area) |
192 | MapLayerReplyPacket mapReply = new MapLayerReplyPacket(); | 192 | MapLayerReplyPacket mapReply = new MapLayerReplyPacket(); |
193 | mapReply.AgentData.AgentID = this.AgentID; | 193 | mapReply.AgentData.AgentID = this.AgentID; |
194 | mapReply.AgentData.Flags = 0; | 194 | mapReply.AgentData.Flags = 0; |
195 | mapReply.LayerData = new MapLayerReplyPacket.LayerDataBlock[1]; | 195 | mapReply.LayerData = new MapLayerReplyPacket.LayerDataBlock[1]; |
196 | mapReply.LayerData[0] = new MapLayerReplyPacket.LayerDataBlock(); | 196 | mapReply.LayerData[0] = new MapLayerReplyPacket.LayerDataBlock(); |
197 | mapReply.LayerData[0].Bottom = 0; | 197 | mapReply.LayerData[0].Bottom = 0; |
198 | mapReply.LayerData[0].Left = 0; | 198 | mapReply.LayerData[0].Left = 0; |
199 | mapReply.LayerData[0].Top = 30000; | 199 | mapReply.LayerData[0].Top = 30000; |
200 | mapReply.LayerData[0].Right = 30000; | 200 | mapReply.LayerData[0].Right = 30000; |
201 | mapReply.LayerData[0].ImageID = new LLUUID("00000000-0000-0000-9999-000000000006"); | 201 | mapReply.LayerData[0].ImageID = new LLUUID("00000000-0000-0000-9999-000000000006"); |
202 | this.OutPacket(mapReply); | 202 | this.OutPacket(mapReply); |
203 | } | 203 | } |
204 | 204 | ||
205 | public void RequestMapBlocks(int minX, int minY, int maxX, int maxY) | 205 | public void RequestMapBlocks(int minX, int minY, int maxX, int maxY) |
206 | { | 206 | { |
207 | /* | 207 | /* |
208 | IList simMapProfiles = m_gridServer.RequestMapBlocks(minX, minY, maxX, maxY); | 208 | IList simMapProfiles = m_gridServer.RequestMapBlocks(minX, minY, maxX, maxY); |
209 | MapBlockReplyPacket mbReply = new MapBlockReplyPacket(); | 209 | MapBlockReplyPacket mbReply = new MapBlockReplyPacket(); |
210 | mbReply.AgentData.AgentID = this.AgentID; | 210 | mbReply.AgentData.AgentID = this.AgentID; |
211 | int len; | 211 | int len; |
212 | if (simMapProfiles == null) | 212 | if (simMapProfiles == null) |
213 | len = 0; | 213 | len = 0; |
214 | else | 214 | else |
215 | len = simMapProfiles.Count; | 215 | len = simMapProfiles.Count; |
216 | 216 | ||
217 | mbReply.Data = new MapBlockReplyPacket.DataBlock[len]; | 217 | mbReply.Data = new MapBlockReplyPacket.DataBlock[len]; |
218 | int iii; | 218 | int iii; |
219 | for (iii = 0; iii < len; iii++) | 219 | for (iii = 0; iii < len; iii++) |
220 | { | 220 | { |
221 | Hashtable mp = (Hashtable)simMapProfiles[iii]; | 221 | Hashtable mp = (Hashtable)simMapProfiles[iii]; |
222 | mbReply.Data[iii] = new MapBlockReplyPacket.DataBlock(); | 222 | mbReply.Data[iii] = new MapBlockReplyPacket.DataBlock(); |
223 | mbReply.Data[iii].Name = System.Text.Encoding.UTF8.GetBytes((string)mp["name"]); | 223 | mbReply.Data[iii].Name = System.Text.Encoding.UTF8.GetBytes((string)mp["name"]); |
224 | mbReply.Data[iii].Access = System.Convert.ToByte(mp["access"]); | 224 | mbReply.Data[iii].Access = System.Convert.ToByte(mp["access"]); |
225 | mbReply.Data[iii].Agents = System.Convert.ToByte(mp["agents"]); | 225 | mbReply.Data[iii].Agents = System.Convert.ToByte(mp["agents"]); |
226 | mbReply.Data[iii].MapImageID = new LLUUID((string)mp["map-image-id"]); | 226 | mbReply.Data[iii].MapImageID = new LLUUID((string)mp["map-image-id"]); |
227 | mbReply.Data[iii].RegionFlags = System.Convert.ToUInt32(mp["region-flags"]); | 227 | mbReply.Data[iii].RegionFlags = System.Convert.ToUInt32(mp["region-flags"]); |
228 | mbReply.Data[iii].WaterHeight = System.Convert.ToByte(mp["water-height"]); | 228 | mbReply.Data[iii].WaterHeight = System.Convert.ToByte(mp["water-height"]); |
229 | mbReply.Data[iii].X = System.Convert.ToUInt16(mp["x"]); | 229 | mbReply.Data[iii].X = System.Convert.ToUInt16(mp["x"]); |
230 | mbReply.Data[iii].Y = System.Convert.ToUInt16(mp["y"]); | 230 | mbReply.Data[iii].Y = System.Convert.ToUInt16(mp["y"]); |
231 | } | 231 | } |
232 | this.OutPacket(mbReply); | 232 | this.OutPacket(mbReply); |
233 | */ | 233 | */ |
234 | } | 234 | } |
235 | } | 235 | } |
236 | } | 236 | } |
diff --git a/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs b/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs index a8512a7..1f9110c 100644 --- a/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs +++ b/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs | |||
@@ -1,647 +1,647 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | 2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
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 | */ |
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Text; | 30 | using System.Text; |
31 | using libsecondlife; | 31 | using libsecondlife; |
32 | using libsecondlife.Packets; | 32 | using libsecondlife.Packets; |
33 | using OpenSim.Framework.Inventory; | 33 | using OpenSim.Framework.Inventory; |
34 | using OpenSim.Framework.Types; | 34 | using OpenSim.Framework.Types; |
35 | using OpenSim.Framework.Utilities; | 35 | using OpenSim.Framework.Utilities; |
36 | 36 | ||
37 | namespace OpenSim.Region.ClientStack | 37 | namespace OpenSim.Region.ClientStack |
38 | { | 38 | { |
39 | public partial class ClientView | 39 | public partial class ClientView |
40 | { | 40 | { |
41 | protected override void ProcessInPacket(Packet Pack) | 41 | protected override void ProcessInPacket(Packet Pack) |
42 | { | 42 | { |
43 | ack_pack(Pack); | 43 | ack_pack(Pack); |
44 | if (debug) | 44 | if (debug) |
45 | { | 45 | { |
46 | if (Pack.Type != PacketType.AgentUpdate) | 46 | if (Pack.Type != PacketType.AgentUpdate) |
47 | { | 47 | { |
48 | Console.WriteLine(CircuitCode + ":IN: " + Pack.Type.ToString()); | 48 | Console.WriteLine(CircuitCode + ":IN: " + Pack.Type.ToString()); |
49 | } | 49 | } |
50 | } | 50 | } |
51 | 51 | ||
52 | if (this.ProcessPacketMethod(Pack)) | 52 | if (this.ProcessPacketMethod(Pack)) |
53 | { | 53 | { |
54 | //there is a handler registered that handled this packet type | 54 | //there is a handler registered that handled this packet type |
55 | return; | 55 | return; |
56 | } | 56 | } |
57 | else | 57 | else |
58 | { | 58 | { |
59 | Encoding _enc = Encoding.ASCII; | 59 | Encoding _enc = Encoding.ASCII; |
60 | 60 | ||
61 | switch (Pack.Type) | 61 | switch (Pack.Type) |
62 | { | 62 | { |
63 | case PacketType.ViewerEffect: | 63 | case PacketType.ViewerEffect: |
64 | ViewerEffectPacket viewer = (ViewerEffectPacket)Pack; | 64 | ViewerEffectPacket viewer = (ViewerEffectPacket)Pack; |
65 | foreach (ClientView client in m_clientThreads.Values) | 65 | foreach (ClientView client in m_clientThreads.Values) |
66 | { | 66 | { |
67 | if (client.AgentID != this.AgentID) | 67 | if (client.AgentID != this.AgentID) |
68 | { | 68 | { |
69 | viewer.AgentData.AgentID = client.AgentID; | 69 | viewer.AgentData.AgentID = client.AgentID; |
70 | viewer.AgentData.SessionID = client.SessionID; | 70 | viewer.AgentData.SessionID = client.SessionID; |
71 | client.OutPacket(viewer); | 71 | client.OutPacket(viewer); |
72 | } | 72 | } |
73 | } | 73 | } |
74 | break; | 74 | break; |
75 | 75 | ||
76 | #region World/Avatar | 76 | #region World/Avatar |
77 | case PacketType.ChatFromViewer: | 77 | case PacketType.ChatFromViewer: |
78 | ChatFromViewerPacket inchatpack = (ChatFromViewerPacket)Pack; | 78 | ChatFromViewerPacket inchatpack = (ChatFromViewerPacket)Pack; |
79 | if (Util.FieldToString(inchatpack.ChatData.Message) == "") | 79 | if (Util.FieldToString(inchatpack.ChatData.Message) == "") |
80 | { | 80 | { |
81 | //empty message so don't bother with it | 81 | //empty message so don't bother with it |
82 | break; | 82 | break; |
83 | } | 83 | } |
84 | string fromName = ""; //ClientAvatar.firstname + " " + ClientAvatar.lastname; | 84 | string fromName = ""; //ClientAvatar.firstname + " " + ClientAvatar.lastname; |
85 | byte[] message = inchatpack.ChatData.Message; | 85 | byte[] message = inchatpack.ChatData.Message; |
86 | byte type = inchatpack.ChatData.Type; | 86 | byte type = inchatpack.ChatData.Type; |
87 | LLVector3 fromPos = new LLVector3(); // ClientAvatar.Pos; | 87 | LLVector3 fromPos = new LLVector3(); // ClientAvatar.Pos; |
88 | LLUUID fromAgentID = AgentID; | 88 | LLUUID fromAgentID = AgentID; |
89 | if (OnChatFromViewer != null) | 89 | if (OnChatFromViewer != null) |
90 | { | 90 | { |
91 | this.OnChatFromViewer(message, type, fromPos, fromName, fromAgentID); | 91 | this.OnChatFromViewer(message, type, fromPos, fromName, fromAgentID); |
92 | } | 92 | } |
93 | break; | 93 | break; |
94 | case PacketType.ImprovedInstantMessage: | 94 | case PacketType.ImprovedInstantMessage: |
95 | ImprovedInstantMessagePacket msgpack = (ImprovedInstantMessagePacket)Pack; | 95 | ImprovedInstantMessagePacket msgpack = (ImprovedInstantMessagePacket)Pack; |
96 | 96 | ||
97 | string IMfromName = Util.FieldToString(msgpack.MessageBlock.FromAgentName); | 97 | string IMfromName = Util.FieldToString(msgpack.MessageBlock.FromAgentName); |
98 | string IMmessage = Util.FieldToString(msgpack.MessageBlock.Message); | 98 | string IMmessage = Util.FieldToString(msgpack.MessageBlock.Message); |
99 | 99 | ||
100 | if (OnInstantMessage != null) | 100 | if (OnInstantMessage != null) |
101 | { | 101 | { |
102 | this.OnInstantMessage(msgpack.AgentData.AgentID, msgpack.MessageBlock.ToAgentID, | 102 | this.OnInstantMessage(msgpack.AgentData.AgentID, msgpack.MessageBlock.ToAgentID, |
103 | msgpack.MessageBlock.Timestamp, IMfromName, IMmessage); | 103 | msgpack.MessageBlock.Timestamp, IMfromName, IMmessage); |
104 | } | 104 | } |
105 | break; | 105 | break; |
106 | case PacketType.RezObject: | 106 | case PacketType.RezObject: |
107 | RezObjectPacket rezPacket = (RezObjectPacket)Pack; | 107 | RezObjectPacket rezPacket = (RezObjectPacket)Pack; |
108 | AgentInventory inven = this.m_inventoryCache.GetAgentsInventory(this.AgentID); | 108 | AgentInventory inven = this.m_inventoryCache.GetAgentsInventory(this.AgentID); |
109 | if (inven != null) | 109 | if (inven != null) |
110 | { | 110 | { |
111 | if (inven.InventoryItems.ContainsKey(rezPacket.InventoryData.ItemID)) | 111 | if (inven.InventoryItems.ContainsKey(rezPacket.InventoryData.ItemID)) |
112 | { | 112 | { |
113 | AssetBase asset = this.m_assetCache.GetAsset(inven.InventoryItems[rezPacket.InventoryData.ItemID].AssetID); | 113 | AssetBase asset = this.m_assetCache.GetAsset(inven.InventoryItems[rezPacket.InventoryData.ItemID].AssetID); |
114 | if (asset != null) | 114 | if (asset != null) |
115 | { | 115 | { |
116 | if (OnRezObject != null) | 116 | if (OnRezObject != null) |
117 | { | 117 | { |
118 | this.OnRezObject(asset, rezPacket.RezData.RayEnd); | 118 | this.OnRezObject(asset, rezPacket.RezData.RayEnd); |
119 | this.m_inventoryCache.DeleteInventoryItem(this, rezPacket.InventoryData.ItemID); | 119 | this.m_inventoryCache.DeleteInventoryItem(this, rezPacket.InventoryData.ItemID); |
120 | } | 120 | } |
121 | } | 121 | } |
122 | } | 122 | } |
123 | } | 123 | } |
124 | break; | 124 | break; |
125 | case PacketType.DeRezObject: | 125 | case PacketType.DeRezObject: |
126 | if (OnDeRezObject != null) | 126 | if (OnDeRezObject != null) |
127 | { | 127 | { |
128 | OnDeRezObject(Pack, this); | 128 | OnDeRezObject(Pack, this); |
129 | } | 129 | } |
130 | break; | 130 | break; |
131 | case PacketType.ModifyLand: | 131 | case PacketType.ModifyLand: |
132 | ModifyLandPacket modify = (ModifyLandPacket)Pack; | 132 | ModifyLandPacket modify = (ModifyLandPacket)Pack; |
133 | if (modify.ParcelData.Length > 0) | 133 | if (modify.ParcelData.Length > 0) |
134 | { | 134 | { |
135 | if (OnModifyTerrain != null) | 135 | if (OnModifyTerrain != null) |
136 | { | 136 | { |
137 | OnModifyTerrain(modify.ModifyBlock.Height, modify.ModifyBlock.Seconds, modify.ModifyBlock.BrushSize, | 137 | OnModifyTerrain(modify.ModifyBlock.Height, modify.ModifyBlock.Seconds, modify.ModifyBlock.BrushSize, |
138 | modify.ModifyBlock.Action, modify.ParcelData[0].North, modify.ParcelData[0].West); | 138 | modify.ModifyBlock.Action, modify.ParcelData[0].North, modify.ParcelData[0].West); |
139 | } | 139 | } |
140 | } | 140 | } |
141 | break; | 141 | break; |
142 | case PacketType.RegionHandshakeReply: | 142 | case PacketType.RegionHandshakeReply: |
143 | if (OnRegionHandShakeReply != null) | 143 | if (OnRegionHandShakeReply != null) |
144 | { | 144 | { |
145 | OnRegionHandShakeReply(this); | 145 | OnRegionHandShakeReply(this); |
146 | } | 146 | } |
147 | break; | 147 | break; |
148 | case PacketType.AgentWearablesRequest: | 148 | case PacketType.AgentWearablesRequest: |
149 | if (OnRequestWearables != null) | 149 | if (OnRequestWearables != null) |
150 | { | 150 | { |
151 | OnRequestWearables(this); | 151 | OnRequestWearables(this); |
152 | } | 152 | } |
153 | if (OnRequestAvatarsData != null) | 153 | if (OnRequestAvatarsData != null) |
154 | { | 154 | { |
155 | OnRequestAvatarsData(this); | 155 | OnRequestAvatarsData(this); |
156 | } | 156 | } |
157 | break; | 157 | break; |
158 | case PacketType.AgentSetAppearance: | 158 | case PacketType.AgentSetAppearance: |
159 | AgentSetAppearancePacket appear = (AgentSetAppearancePacket)Pack; | 159 | AgentSetAppearancePacket appear = (AgentSetAppearancePacket)Pack; |
160 | if (OnSetAppearance != null) | 160 | if (OnSetAppearance != null) |
161 | { | 161 | { |
162 | OnSetAppearance(appear.ObjectData.TextureEntry, appear.VisualParam); | 162 | OnSetAppearance(appear.ObjectData.TextureEntry, appear.VisualParam); |
163 | } | 163 | } |
164 | break; | 164 | break; |
165 | case PacketType.CompleteAgentMovement: | 165 | case PacketType.CompleteAgentMovement: |
166 | if (OnCompleteMovementToRegion != null) | 166 | if (OnCompleteMovementToRegion != null) |
167 | { | 167 | { |
168 | OnCompleteMovementToRegion(); | 168 | OnCompleteMovementToRegion(); |
169 | } | 169 | } |
170 | break; | 170 | break; |
171 | case PacketType.AgentUpdate: | 171 | case PacketType.AgentUpdate: |
172 | if (OnAgentUpdate != null) | 172 | if (OnAgentUpdate != null) |
173 | { | 173 | { |
174 | AgentUpdatePacket agenUpdate = (AgentUpdatePacket)Pack; | 174 | AgentUpdatePacket agenUpdate = (AgentUpdatePacket)Pack; |
175 | OnAgentUpdate(this, agenUpdate.AgentData.ControlFlags, agenUpdate.AgentData.BodyRotation); | 175 | OnAgentUpdate(this, agenUpdate.AgentData.ControlFlags, agenUpdate.AgentData.BodyRotation); |
176 | } | 176 | } |
177 | break; | 177 | break; |
178 | case PacketType.AgentAnimation: | 178 | case PacketType.AgentAnimation: |
179 | if (!m_child) | 179 | if (!m_child) |
180 | { | 180 | { |
181 | AgentAnimationPacket AgentAni = (AgentAnimationPacket)Pack; | 181 | AgentAnimationPacket AgentAni = (AgentAnimationPacket)Pack; |
182 | for (int i = 0; i < AgentAni.AnimationList.Length; i++) | 182 | for (int i = 0; i < AgentAni.AnimationList.Length; i++) |
183 | { | 183 | { |
184 | if (AgentAni.AnimationList[i].StartAnim) | 184 | if (AgentAni.AnimationList[i].StartAnim) |
185 | { | 185 | { |
186 | if (OnStartAnim != null) | 186 | if (OnStartAnim != null) |
187 | { | 187 | { |
188 | OnStartAnim(AgentAni.AnimationList[i].AnimID, 1); | 188 | OnStartAnim(AgentAni.AnimationList[i].AnimID, 1); |
189 | } | 189 | } |
190 | } | 190 | } |
191 | } | 191 | } |
192 | } | 192 | } |
193 | break; | 193 | break; |
194 | 194 | ||
195 | #endregion | 195 | #endregion |
196 | 196 | ||
197 | #region Objects/Prims | 197 | #region Objects/Prims |
198 | case PacketType.ObjectLink: | 198 | case PacketType.ObjectLink: |
199 | // OpenSim.Framework.Console.MainLog.Instance.Verbose( Pack.ToString()); | 199 | // OpenSim.Framework.Console.MainLog.Instance.Verbose( Pack.ToString()); |
200 | ObjectLinkPacket link = (ObjectLinkPacket)Pack; | 200 | ObjectLinkPacket link = (ObjectLinkPacket)Pack; |
201 | uint parentprimid = 0; | 201 | uint parentprimid = 0; |
202 | List<uint> childrenprims = new List<uint>(); | 202 | List<uint> childrenprims = new List<uint>(); |
203 | if (link.ObjectData.Length > 1) | 203 | if (link.ObjectData.Length > 1) |
204 | { | 204 | { |
205 | parentprimid = link.ObjectData[0].ObjectLocalID; | 205 | parentprimid = link.ObjectData[0].ObjectLocalID; |
206 | 206 | ||
207 | for (int i = 1; i < link.ObjectData.Length; i++) | 207 | for (int i = 1; i < link.ObjectData.Length; i++) |
208 | { | 208 | { |
209 | childrenprims.Add(link.ObjectData[i].ObjectLocalID); | 209 | childrenprims.Add(link.ObjectData[i].ObjectLocalID); |
210 | } | 210 | } |
211 | } | 211 | } |
212 | if (OnLinkObjects != null) | 212 | if (OnLinkObjects != null) |
213 | { | 213 | { |
214 | OnLinkObjects(parentprimid, childrenprims); | 214 | OnLinkObjects(parentprimid, childrenprims); |
215 | } | 215 | } |
216 | break; | 216 | break; |
217 | case PacketType.ObjectAdd: | 217 | case PacketType.ObjectAdd: |
218 | if (OnAddPrim != null) | 218 | if (OnAddPrim != null) |
219 | { | 219 | { |
220 | ObjectAddPacket addPacket = (ObjectAddPacket) Pack ; | 220 | ObjectAddPacket addPacket = (ObjectAddPacket) Pack ; |
221 | 221 | ||
222 | PrimitiveBaseShape shape = new PrimitiveBaseShape(); | 222 | PrimitiveBaseShape shape = new PrimitiveBaseShape(); |
223 | 223 | ||
224 | shape.PCode = addPacket.ObjectData.PCode; | 224 | shape.PCode = addPacket.ObjectData.PCode; |
225 | shape.PathBegin = addPacket.ObjectData.PathBegin; | 225 | shape.PathBegin = addPacket.ObjectData.PathBegin; |
226 | shape.PathEnd = addPacket.ObjectData.PathEnd; | 226 | shape.PathEnd = addPacket.ObjectData.PathEnd; |
227 | shape.PathScaleX = addPacket.ObjectData.PathScaleX; | 227 | shape.PathScaleX = addPacket.ObjectData.PathScaleX; |
228 | shape.PathScaleY = addPacket.ObjectData.PathScaleY; | 228 | shape.PathScaleY = addPacket.ObjectData.PathScaleY; |
229 | shape.PathShearX = addPacket.ObjectData.PathShearX; | 229 | shape.PathShearX = addPacket.ObjectData.PathShearX; |
230 | shape.PathShearY = addPacket.ObjectData.PathShearY; | 230 | shape.PathShearY = addPacket.ObjectData.PathShearY; |
231 | shape.PathSkew = addPacket.ObjectData.PathSkew; | 231 | shape.PathSkew = addPacket.ObjectData.PathSkew; |
232 | shape.ProfileBegin = addPacket.ObjectData.ProfileBegin; | 232 | shape.ProfileBegin = addPacket.ObjectData.ProfileBegin; |
233 | shape.ProfileEnd = addPacket.ObjectData.ProfileEnd; | 233 | shape.ProfileEnd = addPacket.ObjectData.ProfileEnd; |
234 | shape.Scale = addPacket.ObjectData.Scale; | 234 | shape.Scale = addPacket.ObjectData.Scale; |
235 | shape.PathCurve = addPacket.ObjectData.PathCurve; | 235 | shape.PathCurve = addPacket.ObjectData.PathCurve; |
236 | shape.ProfileCurve = addPacket.ObjectData.ProfileCurve; | 236 | shape.ProfileCurve = addPacket.ObjectData.ProfileCurve; |
237 | shape.ProfileHollow = addPacket.ObjectData.ProfileHollow; | 237 | shape.ProfileHollow = addPacket.ObjectData.ProfileHollow; |
238 | shape.PathRadiusOffset = addPacket.ObjectData.PathRadiusOffset; | 238 | shape.PathRadiusOffset = addPacket.ObjectData.PathRadiusOffset; |
239 | shape.PathRevolutions = addPacket.ObjectData.PathRevolutions; | 239 | shape.PathRevolutions = addPacket.ObjectData.PathRevolutions; |
240 | shape.PathTaperX = addPacket.ObjectData.PathTaperX; | 240 | shape.PathTaperX = addPacket.ObjectData.PathTaperX; |
241 | shape.PathTaperY = addPacket.ObjectData.PathTaperY; | 241 | shape.PathTaperY = addPacket.ObjectData.PathTaperY; |
242 | shape.PathTwist = addPacket.ObjectData.PathTwist; | 242 | shape.PathTwist = addPacket.ObjectData.PathTwist; |
243 | shape.PathTwistBegin = addPacket.ObjectData.PathTwistBegin; | 243 | shape.PathTwistBegin = addPacket.ObjectData.PathTwistBegin; |
244 | LLObject.TextureEntry ntex = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-9999-000000000005")); | 244 | LLObject.TextureEntry ntex = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-9999-000000000005")); |
245 | shape.TextureEntry = ntex.ToBytes(); | 245 | shape.TextureEntry = ntex.ToBytes(); |
246 | 246 | ||
247 | OnAddPrim(this.AgentId, addPacket.ObjectData.RayEnd, shape); | 247 | OnAddPrim(this.AgentId, addPacket.ObjectData.RayEnd, shape); |
248 | } | 248 | } |
249 | break; | 249 | break; |
250 | case PacketType.ObjectShape: | 250 | case PacketType.ObjectShape: |
251 | ObjectShapePacket shapePacket = (ObjectShapePacket)Pack; | 251 | ObjectShapePacket shapePacket = (ObjectShapePacket)Pack; |
252 | for (int i = 0; i < shapePacket.ObjectData.Length; i++) | 252 | for (int i = 0; i < shapePacket.ObjectData.Length; i++) |
253 | { | 253 | { |
254 | if (OnUpdatePrimShape != null) | 254 | if (OnUpdatePrimShape != null) |
255 | { | 255 | { |
256 | OnUpdatePrimShape(shapePacket.ObjectData[i].ObjectLocalID, shapePacket.ObjectData[i]); | 256 | OnUpdatePrimShape(shapePacket.ObjectData[i].ObjectLocalID, shapePacket.ObjectData[i]); |
257 | } | 257 | } |
258 | } | 258 | } |
259 | break; | 259 | break; |
260 | case PacketType.ObjectDuplicate: | 260 | case PacketType.ObjectDuplicate: |
261 | ObjectDuplicatePacket dupe = (ObjectDuplicatePacket)Pack; | 261 | ObjectDuplicatePacket dupe = (ObjectDuplicatePacket)Pack; |
262 | for (int i = 0; i < dupe.ObjectData.Length; i++) | 262 | for (int i = 0; i < dupe.ObjectData.Length; i++) |
263 | { | 263 | { |
264 | if (OnObjectDuplicate != null) | 264 | if (OnObjectDuplicate != null) |
265 | { | 265 | { |
266 | OnObjectDuplicate(dupe.ObjectData[i].ObjectLocalID, dupe.SharedData.Offset, dupe.SharedData.DuplicateFlags); | 266 | OnObjectDuplicate(dupe.ObjectData[i].ObjectLocalID, dupe.SharedData.Offset, dupe.SharedData.DuplicateFlags); |
267 | } | 267 | } |
268 | } | 268 | } |
269 | 269 | ||
270 | break; | 270 | break; |
271 | 271 | ||
272 | case PacketType.ObjectSelect: | 272 | case PacketType.ObjectSelect: |
273 | ObjectSelectPacket incomingselect = (ObjectSelectPacket)Pack; | 273 | ObjectSelectPacket incomingselect = (ObjectSelectPacket)Pack; |
274 | for (int i = 0; i < incomingselect.ObjectData.Length; i++) | 274 | for (int i = 0; i < incomingselect.ObjectData.Length; i++) |
275 | { | 275 | { |
276 | if (OnObjectSelect != null) | 276 | if (OnObjectSelect != null) |
277 | { | 277 | { |
278 | OnObjectSelect(incomingselect.ObjectData[i].ObjectLocalID, this); | 278 | OnObjectSelect(incomingselect.ObjectData[i].ObjectLocalID, this); |
279 | } | 279 | } |
280 | } | 280 | } |
281 | break; | 281 | break; |
282 | case PacketType.ObjectDeselect: | 282 | case PacketType.ObjectDeselect: |
283 | ObjectDeselectPacket incomingdeselect = (ObjectDeselectPacket)Pack; | 283 | ObjectDeselectPacket incomingdeselect = (ObjectDeselectPacket)Pack; |
284 | for (int i = 0; i < incomingdeselect.ObjectData.Length; i++) | 284 | for (int i = 0; i < incomingdeselect.ObjectData.Length; i++) |
285 | { | 285 | { |
286 | if (OnObjectDeselect != null) | 286 | if (OnObjectDeselect != null) |
287 | { | 287 | { |
288 | OnObjectDeselect(incomingdeselect.ObjectData[i].ObjectLocalID, this); | 288 | OnObjectDeselect(incomingdeselect.ObjectData[i].ObjectLocalID, this); |
289 | } | 289 | } |
290 | } | 290 | } |
291 | break; | 291 | break; |
292 | case PacketType.ObjectFlagUpdate: | 292 | case PacketType.ObjectFlagUpdate: |
293 | ObjectFlagUpdatePacket flags = (ObjectFlagUpdatePacket)Pack; | 293 | ObjectFlagUpdatePacket flags = (ObjectFlagUpdatePacket)Pack; |
294 | if (OnUpdatePrimFlags != null) | 294 | if (OnUpdatePrimFlags != null) |
295 | { | 295 | { |
296 | OnUpdatePrimFlags(flags.AgentData.ObjectLocalID, Pack, this); | 296 | OnUpdatePrimFlags(flags.AgentData.ObjectLocalID, Pack, this); |
297 | } | 297 | } |
298 | break; | 298 | break; |
299 | case PacketType.ObjectImage: | 299 | case PacketType.ObjectImage: |
300 | ObjectImagePacket imagePack = (ObjectImagePacket)Pack; | 300 | ObjectImagePacket imagePack = (ObjectImagePacket)Pack; |
301 | for (int i = 0; i < imagePack.ObjectData.Length; i++) | 301 | for (int i = 0; i < imagePack.ObjectData.Length; i++) |
302 | { | 302 | { |
303 | if (OnUpdatePrimTexture != null) | 303 | if (OnUpdatePrimTexture != null) |
304 | { | 304 | { |
305 | OnUpdatePrimTexture(imagePack.ObjectData[i].ObjectLocalID, imagePack.ObjectData[i].TextureEntry, this); | 305 | OnUpdatePrimTexture(imagePack.ObjectData[i].ObjectLocalID, imagePack.ObjectData[i].TextureEntry, this); |
306 | } | 306 | } |
307 | } | 307 | } |
308 | break; | 308 | break; |
309 | case PacketType.ObjectGrab: | 309 | case PacketType.ObjectGrab: |
310 | ObjectGrabPacket grap = (ObjectGrabPacket)Pack; | 310 | ObjectGrabPacket grap = (ObjectGrabPacket)Pack; |
311 | if (OnGrapObject != null) | 311 | if (OnGrapObject != null) |
312 | { | 312 | { |
313 | OnGrapObject(grap.ObjectData.LocalID, grap.ObjectData.GrabOffset, this); | 313 | OnGrapObject(grap.ObjectData.LocalID, grap.ObjectData.GrabOffset, this); |
314 | } | 314 | } |
315 | break; | 315 | break; |
316 | case PacketType.ObjectGrabUpdate: | 316 | case PacketType.ObjectGrabUpdate: |
317 | ObjectGrabUpdatePacket grapUpdate = (ObjectGrabUpdatePacket)Pack; | 317 | ObjectGrabUpdatePacket grapUpdate = (ObjectGrabUpdatePacket)Pack; |
318 | if (OnGrapUpdate != null) | 318 | if (OnGrapUpdate != null) |
319 | { | 319 | { |
320 | OnGrapUpdate(grapUpdate.ObjectData.ObjectID, grapUpdate.ObjectData.GrabOffsetInitial, grapUpdate.ObjectData.GrabPosition, this); | 320 | OnGrapUpdate(grapUpdate.ObjectData.ObjectID, grapUpdate.ObjectData.GrabOffsetInitial, grapUpdate.ObjectData.GrabPosition, this); |
321 | } | 321 | } |
322 | break; | 322 | break; |
323 | case PacketType.ObjectDeGrab: | 323 | case PacketType.ObjectDeGrab: |
324 | ObjectDeGrabPacket deGrap = (ObjectDeGrabPacket)Pack; | 324 | ObjectDeGrabPacket deGrap = (ObjectDeGrabPacket)Pack; |
325 | if (OnDeGrapObject != null) | 325 | if (OnDeGrapObject != null) |
326 | { | 326 | { |
327 | OnDeGrapObject(deGrap.ObjectData.LocalID, this); | 327 | OnDeGrapObject(deGrap.ObjectData.LocalID, this); |
328 | } | 328 | } |
329 | break; | 329 | break; |
330 | case PacketType.ObjectDescription: | 330 | case PacketType.ObjectDescription: |
331 | ObjectDescriptionPacket objDes = (ObjectDescriptionPacket)Pack; | 331 | ObjectDescriptionPacket objDes = (ObjectDescriptionPacket)Pack; |
332 | for (int i = 0; i < objDes.ObjectData.Length; i++) | 332 | for (int i = 0; i < objDes.ObjectData.Length; i++) |
333 | { | 333 | { |
334 | if (OnObjectDescription != null) | 334 | if (OnObjectDescription != null) |
335 | { | 335 | { |
336 | OnObjectDescription(objDes.ObjectData[i].LocalID, enc.GetString(objDes.ObjectData[i].Description)); | 336 | OnObjectDescription(objDes.ObjectData[i].LocalID, enc.GetString(objDes.ObjectData[i].Description)); |
337 | } | 337 | } |
338 | } | 338 | } |
339 | break; | 339 | break; |
340 | case PacketType.ObjectName: | 340 | case PacketType.ObjectName: |
341 | ObjectNamePacket objName = (ObjectNamePacket)Pack; | 341 | ObjectNamePacket objName = (ObjectNamePacket)Pack; |
342 | for (int i = 0; i < objName.ObjectData.Length; i++) | 342 | for (int i = 0; i < objName.ObjectData.Length; i++) |
343 | { | 343 | { |
344 | if (OnObjectName != null) | 344 | if (OnObjectName != null) |
345 | { | 345 | { |
346 | OnObjectName(objName.ObjectData[i].LocalID, enc.GetString(objName.ObjectData[i].Name)); | 346 | OnObjectName(objName.ObjectData[i].LocalID, enc.GetString(objName.ObjectData[i].Name)); |
347 | } | 347 | } |
348 | } | 348 | } |
349 | break; | 349 | break; |
350 | case PacketType.ObjectPermissions: | 350 | case PacketType.ObjectPermissions: |
351 | //Console.WriteLine("permissions set " + Pack.ToString()); | 351 | //Console.WriteLine("permissions set " + Pack.ToString()); |
352 | break; | 352 | break; |
353 | #endregion | 353 | #endregion |
354 | 354 | ||
355 | #region Inventory/Asset/Other related packets | 355 | #region Inventory/Asset/Other related packets |
356 | case PacketType.RequestImage: | 356 | case PacketType.RequestImage: |
357 | RequestImagePacket imageRequest = (RequestImagePacket)Pack; | 357 | RequestImagePacket imageRequest = (RequestImagePacket)Pack; |
358 | for (int i = 0; i < imageRequest.RequestImage.Length; i++) | 358 | for (int i = 0; i < imageRequest.RequestImage.Length; i++) |
359 | { | 359 | { |
360 | m_assetCache.AddTextureRequest(this, imageRequest.RequestImage[i].Image); | 360 | m_assetCache.AddTextureRequest(this, imageRequest.RequestImage[i].Image); |
361 | } | 361 | } |
362 | break; | 362 | break; |
363 | case PacketType.TransferRequest: | 363 | case PacketType.TransferRequest: |
364 | //Console.WriteLine("OpenSimClient.cs:ProcessInPacket() - Got transfer request"); | 364 | //Console.WriteLine("OpenSimClient.cs:ProcessInPacket() - Got transfer request"); |
365 | TransferRequestPacket transfer = (TransferRequestPacket)Pack; | 365 | TransferRequestPacket transfer = (TransferRequestPacket)Pack; |
366 | m_assetCache.AddAssetRequest(this, transfer); | 366 | m_assetCache.AddAssetRequest(this, transfer); |
367 | break; | 367 | break; |
368 | case PacketType.AssetUploadRequest: | 368 | case PacketType.AssetUploadRequest: |
369 | AssetUploadRequestPacket request = (AssetUploadRequestPacket)Pack; | 369 | AssetUploadRequestPacket request = (AssetUploadRequestPacket)Pack; |
370 | this.UploadAssets.HandleUploadPacket(request, request.AssetBlock.TransactionID.Combine(this.SecureSessionID)); | 370 | this.UploadAssets.HandleUploadPacket(request, request.AssetBlock.TransactionID.Combine(this.SecureSessionID)); |
371 | break; | 371 | break; |
372 | case PacketType.RequestXfer: | 372 | case PacketType.RequestXfer: |
373 | //Console.WriteLine(Pack.ToString()); | 373 | //Console.WriteLine(Pack.ToString()); |
374 | break; | 374 | break; |
375 | case PacketType.SendXferPacket: | 375 | case PacketType.SendXferPacket: |
376 | this.UploadAssets.HandleXferPacket((SendXferPacketPacket)Pack); | 376 | this.UploadAssets.HandleXferPacket((SendXferPacketPacket)Pack); |
377 | break; | 377 | break; |
378 | case PacketType.CreateInventoryFolder: | 378 | case PacketType.CreateInventoryFolder: |
379 | CreateInventoryFolderPacket invFolder = (CreateInventoryFolderPacket)Pack; | 379 | CreateInventoryFolderPacket invFolder = (CreateInventoryFolderPacket)Pack; |
380 | m_inventoryCache.CreateNewInventoryFolder(this, invFolder.FolderData.FolderID, (ushort)invFolder.FolderData.Type, Util.FieldToString(invFolder.FolderData.Name), invFolder.FolderData.ParentID); | 380 | m_inventoryCache.CreateNewInventoryFolder(this, invFolder.FolderData.FolderID, (ushort)invFolder.FolderData.Type, Util.FieldToString(invFolder.FolderData.Name), invFolder.FolderData.ParentID); |
381 | //Console.WriteLine(Pack.ToString()); | 381 | //Console.WriteLine(Pack.ToString()); |
382 | break; | 382 | break; |
383 | case PacketType.CreateInventoryItem: | 383 | case PacketType.CreateInventoryItem: |
384 | //Console.WriteLine(Pack.ToString()); | 384 | //Console.WriteLine(Pack.ToString()); |
385 | CreateInventoryItemPacket createItem = (CreateInventoryItemPacket)Pack; | 385 | CreateInventoryItemPacket createItem = (CreateInventoryItemPacket)Pack; |
386 | if (createItem.InventoryBlock.TransactionID != LLUUID.Zero) | 386 | if (createItem.InventoryBlock.TransactionID != LLUUID.Zero) |
387 | { | 387 | { |
388 | this.UploadAssets.CreateInventoryItem(createItem); | 388 | this.UploadAssets.CreateInventoryItem(createItem); |
389 | } | 389 | } |
390 | else | 390 | else |
391 | { | 391 | { |
392 | // Console.Write(Pack.ToString()); | 392 | // Console.Write(Pack.ToString()); |
393 | this.CreateInventoryItem(createItem); | 393 | this.CreateInventoryItem(createItem); |
394 | } | 394 | } |
395 | break; | 395 | break; |
396 | case PacketType.FetchInventory: | 396 | case PacketType.FetchInventory: |
397 | //Console.WriteLine("fetch item packet"); | 397 | //Console.WriteLine("fetch item packet"); |
398 | FetchInventoryPacket FetchInventory = (FetchInventoryPacket)Pack; | 398 | FetchInventoryPacket FetchInventory = (FetchInventoryPacket)Pack; |
399 | m_inventoryCache.FetchInventory(this, FetchInventory); | 399 | m_inventoryCache.FetchInventory(this, FetchInventory); |
400 | break; | 400 | break; |
401 | case PacketType.FetchInventoryDescendents: | 401 | case PacketType.FetchInventoryDescendents: |
402 | FetchInventoryDescendentsPacket Fetch = (FetchInventoryDescendentsPacket)Pack; | 402 | FetchInventoryDescendentsPacket Fetch = (FetchInventoryDescendentsPacket)Pack; |
403 | m_inventoryCache.FetchInventoryDescendents(this, Fetch); | 403 | m_inventoryCache.FetchInventoryDescendents(this, Fetch); |
404 | break; | 404 | break; |
405 | case PacketType.UpdateInventoryItem: | 405 | case PacketType.UpdateInventoryItem: |
406 | UpdateInventoryItemPacket update = (UpdateInventoryItemPacket)Pack; | 406 | UpdateInventoryItemPacket update = (UpdateInventoryItemPacket)Pack; |
407 | //Console.WriteLine(Pack.ToString()); | 407 | //Console.WriteLine(Pack.ToString()); |
408 | for (int i = 0; i < update.InventoryData.Length; i++) | 408 | for (int i = 0; i < update.InventoryData.Length; i++) |
409 | { | 409 | { |
410 | if (update.InventoryData[i].TransactionID != LLUUID.Zero) | 410 | if (update.InventoryData[i].TransactionID != LLUUID.Zero) |
411 | { | 411 | { |
412 | AssetBase asset = m_assetCache.GetAsset(update.InventoryData[i].TransactionID.Combine(this.SecureSessionID)); | 412 | AssetBase asset = m_assetCache.GetAsset(update.InventoryData[i].TransactionID.Combine(this.SecureSessionID)); |
413 | if (asset != null) | 413 | if (asset != null) |
414 | { | 414 | { |
415 | // Console.WriteLine("updating inventory item, found asset" + asset.FullID.ToStringHyphenated() + " already in cache"); | 415 | // Console.WriteLine("updating inventory item, found asset" + asset.FullID.ToStringHyphenated() + " already in cache"); |
416 | m_inventoryCache.UpdateInventoryItemAsset(this, update.InventoryData[i].ItemID, asset); | 416 | m_inventoryCache.UpdateInventoryItemAsset(this, update.InventoryData[i].ItemID, asset); |
417 | } | 417 | } |
418 | else | 418 | else |
419 | { | 419 | { |
420 | asset = this.UploadAssets.AddUploadToAssetCache(update.InventoryData[i].TransactionID); | 420 | asset = this.UploadAssets.AddUploadToAssetCache(update.InventoryData[i].TransactionID); |
421 | if (asset != null) | 421 | if (asset != null) |
422 | { | 422 | { |
423 | //Console.WriteLine("updating inventory item, adding asset" + asset.FullID.ToStringHyphenated() + " to cache"); | 423 | //Console.WriteLine("updating inventory item, adding asset" + asset.FullID.ToStringHyphenated() + " to cache"); |
424 | m_inventoryCache.UpdateInventoryItemAsset(this, update.InventoryData[i].ItemID, asset); | 424 | m_inventoryCache.UpdateInventoryItemAsset(this, update.InventoryData[i].ItemID, asset); |
425 | } | 425 | } |
426 | else | 426 | else |
427 | { | 427 | { |
428 | //Console.WriteLine("trying to update inventory item, but asset is null"); | 428 | //Console.WriteLine("trying to update inventory item, but asset is null"); |
429 | } | 429 | } |
430 | } | 430 | } |
431 | } | 431 | } |
432 | else | 432 | else |
433 | { | 433 | { |
434 | m_inventoryCache.UpdateInventoryItemDetails(this, update.InventoryData[i].ItemID, update.InventoryData[i]); ; | 434 | m_inventoryCache.UpdateInventoryItemDetails(this, update.InventoryData[i].ItemID, update.InventoryData[i]); ; |
435 | } | 435 | } |
436 | } | 436 | } |
437 | break; | 437 | break; |
438 | case PacketType.RequestTaskInventory: | 438 | case PacketType.RequestTaskInventory: |
439 | // Console.WriteLine(Pack.ToString()); | 439 | // Console.WriteLine(Pack.ToString()); |
440 | RequestTaskInventoryPacket requesttask = (RequestTaskInventoryPacket)Pack; | 440 | RequestTaskInventoryPacket requesttask = (RequestTaskInventoryPacket)Pack; |
441 | ReplyTaskInventoryPacket replytask = new ReplyTaskInventoryPacket(); | 441 | ReplyTaskInventoryPacket replytask = new ReplyTaskInventoryPacket(); |
442 | //bool foundent = false; | 442 | //bool foundent = false; |
443 | /* foreach (Entity ent in m_world.Entities.Values) | 443 | /* foreach (Entity ent in m_world.Entities.Values) |
444 | { | 444 | { |
445 | if (ent.localid == requesttask.InventoryData.LocalID) | 445 | if (ent.localid == requesttask.InventoryData.LocalID) |
446 | { | 446 | { |
447 | replytask.InventoryData.TaskID = ent.uuid; | 447 | replytask.InventoryData.TaskID = ent.uuid; |
448 | replytask.InventoryData.Serial = 0; | 448 | replytask.InventoryData.Serial = 0; |
449 | replytask.InventoryData.Filename = new byte[0]; | 449 | replytask.InventoryData.Filename = new byte[0]; |
450 | foundent = true; | 450 | foundent = true; |
451 | } | 451 | } |
452 | } | 452 | } |
453 | if (foundent) | 453 | if (foundent) |
454 | { | 454 | { |
455 | this.OutPacket(replytask); | 455 | this.OutPacket(replytask); |
456 | }*/ | 456 | }*/ |
457 | break; | 457 | break; |
458 | case PacketType.UpdateTaskInventory: | 458 | case PacketType.UpdateTaskInventory: |
459 | // Console.WriteLine(Pack.ToString()); | 459 | // Console.WriteLine(Pack.ToString()); |
460 | UpdateTaskInventoryPacket updatetask = (UpdateTaskInventoryPacket)Pack; | 460 | UpdateTaskInventoryPacket updatetask = (UpdateTaskInventoryPacket)Pack; |
461 | AgentInventory myinventory = this.m_inventoryCache.GetAgentsInventory(this.AgentID); | 461 | AgentInventory myinventory = this.m_inventoryCache.GetAgentsInventory(this.AgentID); |
462 | /*if (myinventory != null) | 462 | /*if (myinventory != null) |
463 | { | 463 | { |
464 | if (updatetask.UpdateData.Key == 0) | 464 | if (updatetask.UpdateData.Key == 0) |
465 | { | 465 | { |
466 | if (myinventory.InventoryItems[updatetask.InventoryData.ItemID] != null) | 466 | if (myinventory.InventoryItems[updatetask.InventoryData.ItemID] != null) |
467 | { | 467 | { |
468 | if (myinventory.InventoryItems[updatetask.InventoryData.ItemID].Type == 7) | 468 | if (myinventory.InventoryItems[updatetask.InventoryData.ItemID].Type == 7) |
469 | { | 469 | { |
470 | LLUUID noteaid = myinventory.InventoryItems[updatetask.InventoryData.ItemID].AssetID; | 470 | LLUUID noteaid = myinventory.InventoryItems[updatetask.InventoryData.ItemID].AssetID; |
471 | AssetBase assBase = this.m_assetCache.GetAsset(noteaid); | 471 | AssetBase assBase = this.m_assetCache.GetAsset(noteaid); |
472 | if (assBase != null) | 472 | if (assBase != null) |
473 | { | 473 | { |
474 | foreach (Entity ent in m_world.Entities.Values) | 474 | foreach (Entity ent in m_world.Entities.Values) |
475 | { | 475 | { |
476 | if (ent.localid == updatetask.UpdateData.LocalID) | 476 | if (ent.localid == updatetask.UpdateData.LocalID) |
477 | { | 477 | { |
478 | if (ent is OpenSim.world.Primitive) | 478 | if (ent is OpenSim.world.Primitive) |
479 | { | 479 | { |
480 | this.m_world.AddScript(ent, Util.FieldToString(assBase.Data)); | 480 | this.m_world.AddScript(ent, Util.FieldToString(assBase.Data)); |
481 | } | 481 | } |
482 | } | 482 | } |
483 | } | 483 | } |
484 | } | 484 | } |
485 | } | 485 | } |
486 | } | 486 | } |
487 | } | 487 | } |
488 | }*/ | 488 | }*/ |
489 | break; | 489 | break; |
490 | case PacketType.MapLayerRequest: | 490 | case PacketType.MapLayerRequest: |
491 | this.RequestMapLayer(); | 491 | this.RequestMapLayer(); |
492 | break; | 492 | break; |
493 | case PacketType.MapBlockRequest: | 493 | case PacketType.MapBlockRequest: |
494 | MapBlockRequestPacket MapRequest = (MapBlockRequestPacket)Pack; | 494 | MapBlockRequestPacket MapRequest = (MapBlockRequestPacket)Pack; |
495 | if (OnRequestMapBlocks != null) | 495 | if (OnRequestMapBlocks != null) |
496 | { | 496 | { |
497 | OnRequestMapBlocks(this, MapRequest.PositionData.MinX, MapRequest.PositionData.MinY, MapRequest.PositionData.MaxX, MapRequest.PositionData.MaxY); | 497 | OnRequestMapBlocks(this, MapRequest.PositionData.MinX, MapRequest.PositionData.MinY, MapRequest.PositionData.MaxX, MapRequest.PositionData.MaxY); |
498 | } | 498 | } |
499 | break; | 499 | break; |
500 | case PacketType.TeleportLandmarkRequest: | 500 | case PacketType.TeleportLandmarkRequest: |
501 | TeleportLandmarkRequestPacket tpReq = (TeleportLandmarkRequestPacket)Pack; | 501 | TeleportLandmarkRequestPacket tpReq = (TeleportLandmarkRequestPacket)Pack; |
502 | 502 | ||
503 | TeleportStartPacket tpStart = new TeleportStartPacket(); | 503 | TeleportStartPacket tpStart = new TeleportStartPacket(); |
504 | tpStart.Info.TeleportFlags = 8; // tp via lm | 504 | tpStart.Info.TeleportFlags = 8; // tp via lm |
505 | this.OutPacket(tpStart); | 505 | this.OutPacket(tpStart); |
506 | 506 | ||
507 | TeleportProgressPacket tpProgress = new TeleportProgressPacket(); | 507 | TeleportProgressPacket tpProgress = new TeleportProgressPacket(); |
508 | tpProgress.Info.Message = (new ASCIIEncoding()).GetBytes("sending_landmark"); | 508 | tpProgress.Info.Message = (new ASCIIEncoding()).GetBytes("sending_landmark"); |
509 | tpProgress.Info.TeleportFlags = 8; | 509 | tpProgress.Info.TeleportFlags = 8; |
510 | tpProgress.AgentData.AgentID = tpReq.Info.AgentID; | 510 | tpProgress.AgentData.AgentID = tpReq.Info.AgentID; |
511 | this.OutPacket(tpProgress); | 511 | this.OutPacket(tpProgress); |
512 | 512 | ||
513 | // Fetch landmark | 513 | // Fetch landmark |
514 | LLUUID lmid = tpReq.Info.LandmarkID; | 514 | LLUUID lmid = tpReq.Info.LandmarkID; |
515 | AssetBase lma = this.m_assetCache.GetAsset(lmid); | 515 | AssetBase lma = this.m_assetCache.GetAsset(lmid); |
516 | if (lma != null) | 516 | if (lma != null) |
517 | { | 517 | { |
518 | AssetLandmark lm = new AssetLandmark(lma); | 518 | AssetLandmark lm = new AssetLandmark(lma); |
519 | 519 | ||
520 | if (lm.RegionID == m_world.RegionInfo.SimUUID) | 520 | if (lm.RegionID == m_world.RegionInfo.SimUUID) |
521 | { | 521 | { |
522 | TeleportLocalPacket tpLocal = new TeleportLocalPacket(); | 522 | TeleportLocalPacket tpLocal = new TeleportLocalPacket(); |
523 | 523 | ||
524 | tpLocal.Info.AgentID = tpReq.Info.AgentID; | 524 | tpLocal.Info.AgentID = tpReq.Info.AgentID; |
525 | tpLocal.Info.TeleportFlags = 8; // Teleport via landmark | 525 | tpLocal.Info.TeleportFlags = 8; // Teleport via landmark |
526 | tpLocal.Info.LocationID = 2; | 526 | tpLocal.Info.LocationID = 2; |
527 | tpLocal.Info.Position = lm.Position; | 527 | tpLocal.Info.Position = lm.Position; |
528 | OutPacket(tpLocal); | 528 | OutPacket(tpLocal); |
529 | } | 529 | } |
530 | else | 530 | else |
531 | { | 531 | { |
532 | TeleportCancelPacket tpCancel = new TeleportCancelPacket(); | 532 | TeleportCancelPacket tpCancel = new TeleportCancelPacket(); |
533 | tpCancel.Info.AgentID = tpReq.Info.AgentID; | 533 | tpCancel.Info.AgentID = tpReq.Info.AgentID; |
534 | tpCancel.Info.SessionID = tpReq.Info.SessionID; | 534 | tpCancel.Info.SessionID = tpReq.Info.SessionID; |
535 | OutPacket(tpCancel); | 535 | OutPacket(tpCancel); |
536 | } | 536 | } |
537 | } | 537 | } |
538 | else | 538 | else |
539 | { | 539 | { |
540 | Console.WriteLine("Cancelling Teleport - fetch asset not yet implemented"); | 540 | Console.WriteLine("Cancelling Teleport - fetch asset not yet implemented"); |
541 | 541 | ||
542 | TeleportCancelPacket tpCancel = new TeleportCancelPacket(); | 542 | TeleportCancelPacket tpCancel = new TeleportCancelPacket(); |
543 | tpCancel.Info.AgentID = tpReq.Info.AgentID; | 543 | tpCancel.Info.AgentID = tpReq.Info.AgentID; |
544 | tpCancel.Info.SessionID = tpReq.Info.SessionID; | 544 | tpCancel.Info.SessionID = tpReq.Info.SessionID; |
545 | OutPacket(tpCancel); | 545 | OutPacket(tpCancel); |
546 | } | 546 | } |
547 | break; | 547 | break; |
548 | case PacketType.TeleportLocationRequest: | 548 | case PacketType.TeleportLocationRequest: |
549 | TeleportLocationRequestPacket tpLocReq = (TeleportLocationRequestPacket)Pack; | 549 | TeleportLocationRequestPacket tpLocReq = (TeleportLocationRequestPacket)Pack; |
550 | // Console.WriteLine(tpLocReq.ToString()); | 550 | // Console.WriteLine(tpLocReq.ToString()); |
551 | 551 | ||
552 | if (OnTeleportLocationRequest != null) | 552 | if (OnTeleportLocationRequest != null) |
553 | { | 553 | { |
554 | OnTeleportLocationRequest(this, tpLocReq.Info.RegionHandle, tpLocReq.Info.Position, tpLocReq.Info.LookAt, 16); | 554 | OnTeleportLocationRequest(this, tpLocReq.Info.RegionHandle, tpLocReq.Info.Position, tpLocReq.Info.LookAt, 16); |
555 | } | 555 | } |
556 | else | 556 | else |
557 | { | 557 | { |
558 | //no event handler so cancel request | 558 | //no event handler so cancel request |
559 | TeleportCancelPacket tpCancel = new TeleportCancelPacket(); | 559 | TeleportCancelPacket tpCancel = new TeleportCancelPacket(); |
560 | tpCancel.Info.SessionID = tpLocReq.AgentData.SessionID; | 560 | tpCancel.Info.SessionID = tpLocReq.AgentData.SessionID; |
561 | tpCancel.Info.AgentID = tpLocReq.AgentData.AgentID; | 561 | tpCancel.Info.AgentID = tpLocReq.AgentData.AgentID; |
562 | OutPacket(tpCancel); | 562 | OutPacket(tpCancel); |
563 | } | 563 | } |
564 | break; | 564 | break; |
565 | #endregion | 565 | #endregion |
566 | 566 | ||
567 | case PacketType.MoneyBalanceRequest: | 567 | case PacketType.MoneyBalanceRequest: |
568 | this.SendMoneyBalance(LLUUID.Zero, true, new byte[0], 1000); | 568 | this.SendMoneyBalance(LLUUID.Zero, true, new byte[0], 1000); |
569 | break; | 569 | break; |
570 | case PacketType.UUIDNameRequest: | 570 | case PacketType.UUIDNameRequest: |
571 | UUIDNameRequestPacket incoming = (UUIDNameRequestPacket)Pack; | 571 | UUIDNameRequestPacket incoming = (UUIDNameRequestPacket)Pack; |
572 | foreach (UUIDNameRequestPacket.UUIDNameBlockBlock UUIDBlock in incoming.UUIDNameBlock) | 572 | foreach (UUIDNameRequestPacket.UUIDNameBlockBlock UUIDBlock in incoming.UUIDNameBlock) |
573 | { | 573 | { |
574 | OnNameFromUUIDRequest(UUIDBlock.ID, this); | 574 | OnNameFromUUIDRequest(UUIDBlock.ID, this); |
575 | } | 575 | } |
576 | break; | 576 | break; |
577 | #region Parcel related packets | 577 | #region Parcel related packets |
578 | case PacketType.ParcelPropertiesRequest: | 578 | case PacketType.ParcelPropertiesRequest: |
579 | ParcelPropertiesRequestPacket propertiesRequest = (ParcelPropertiesRequestPacket)Pack; | 579 | ParcelPropertiesRequestPacket propertiesRequest = (ParcelPropertiesRequestPacket)Pack; |
580 | if (OnParcelPropertiesRequest != null) | 580 | if (OnParcelPropertiesRequest != null) |
581 | { | 581 | { |
582 | OnParcelPropertiesRequest((int)Math.Round(propertiesRequest.ParcelData.West), (int)Math.Round(propertiesRequest.ParcelData.South), (int)Math.Round(propertiesRequest.ParcelData.East), (int)Math.Round(propertiesRequest.ParcelData.North), propertiesRequest.ParcelData.SequenceID, propertiesRequest.ParcelData.SnapSelection, this); | 582 | OnParcelPropertiesRequest((int)Math.Round(propertiesRequest.ParcelData.West), (int)Math.Round(propertiesRequest.ParcelData.South), (int)Math.Round(propertiesRequest.ParcelData.East), (int)Math.Round(propertiesRequest.ParcelData.North), propertiesRequest.ParcelData.SequenceID, propertiesRequest.ParcelData.SnapSelection, this); |
583 | } | 583 | } |
584 | break; | 584 | break; |
585 | case PacketType.ParcelDivide: | 585 | case PacketType.ParcelDivide: |
586 | ParcelDividePacket parcelDivide = (ParcelDividePacket)Pack; | 586 | ParcelDividePacket parcelDivide = (ParcelDividePacket)Pack; |
587 | if (OnParcelDivideRequest != null) | 587 | if (OnParcelDivideRequest != null) |
588 | { | 588 | { |
589 | OnParcelDivideRequest((int)Math.Round(parcelDivide.ParcelData.West), (int)Math.Round(parcelDivide.ParcelData.South), (int)Math.Round(parcelDivide.ParcelData.East), (int)Math.Round(parcelDivide.ParcelData.North), this); | 589 | OnParcelDivideRequest((int)Math.Round(parcelDivide.ParcelData.West), (int)Math.Round(parcelDivide.ParcelData.South), (int)Math.Round(parcelDivide.ParcelData.East), (int)Math.Round(parcelDivide.ParcelData.North), this); |
590 | } | 590 | } |
591 | break; | 591 | break; |
592 | case PacketType.ParcelJoin: | 592 | case PacketType.ParcelJoin: |
593 | ParcelJoinPacket parcelJoin = (ParcelJoinPacket)Pack; | 593 | ParcelJoinPacket parcelJoin = (ParcelJoinPacket)Pack; |
594 | if (OnParcelJoinRequest != null) | 594 | if (OnParcelJoinRequest != null) |
595 | { | 595 | { |
596 | OnParcelJoinRequest((int)Math.Round(parcelJoin.ParcelData.West), (int)Math.Round(parcelJoin.ParcelData.South), (int)Math.Round(parcelJoin.ParcelData.East), (int)Math.Round(parcelJoin.ParcelData.North), this); | 596 | OnParcelJoinRequest((int)Math.Round(parcelJoin.ParcelData.West), (int)Math.Round(parcelJoin.ParcelData.South), (int)Math.Round(parcelJoin.ParcelData.East), (int)Math.Round(parcelJoin.ParcelData.North), this); |
597 | } | 597 | } |
598 | break; | 598 | break; |
599 | case PacketType.ParcelPropertiesUpdate: | 599 | case PacketType.ParcelPropertiesUpdate: |
600 | ParcelPropertiesUpdatePacket updatePacket = (ParcelPropertiesUpdatePacket)Pack; | 600 | ParcelPropertiesUpdatePacket updatePacket = (ParcelPropertiesUpdatePacket)Pack; |
601 | if (OnParcelPropertiesUpdateRequest != null) | 601 | if (OnParcelPropertiesUpdateRequest != null) |
602 | { | 602 | { |
603 | OnParcelPropertiesUpdateRequest(updatePacket, this); | 603 | OnParcelPropertiesUpdateRequest(updatePacket, this); |
604 | 604 | ||
605 | } | 605 | } |
606 | break; | 606 | break; |
607 | case PacketType.ParcelSelectObjects: | 607 | case PacketType.ParcelSelectObjects: |
608 | ParcelSelectObjectsPacket selectPacket = (ParcelSelectObjectsPacket)Pack; | 608 | ParcelSelectObjectsPacket selectPacket = (ParcelSelectObjectsPacket)Pack; |
609 | if (OnParcelSelectObjects != null) | 609 | if (OnParcelSelectObjects != null) |
610 | { | 610 | { |
611 | OnParcelSelectObjects(selectPacket.ParcelData.LocalID, Convert.ToInt32(selectPacket.ParcelData.ReturnType), this); | 611 | OnParcelSelectObjects(selectPacket.ParcelData.LocalID, Convert.ToInt32(selectPacket.ParcelData.ReturnType), this); |
612 | } | 612 | } |
613 | break; | 613 | break; |
614 | 614 | ||
615 | case PacketType.ParcelObjectOwnersRequest: | 615 | case PacketType.ParcelObjectOwnersRequest: |
616 | ParcelObjectOwnersRequestPacket reqPacket = (ParcelObjectOwnersRequestPacket)Pack; | 616 | ParcelObjectOwnersRequestPacket reqPacket = (ParcelObjectOwnersRequestPacket)Pack; |
617 | if (OnParcelObjectOwnerRequest != null) | 617 | if (OnParcelObjectOwnerRequest != null) |
618 | { | 618 | { |
619 | OnParcelObjectOwnerRequest(reqPacket.ParcelData.LocalID, this); | 619 | OnParcelObjectOwnerRequest(reqPacket.ParcelData.LocalID, this); |
620 | } | 620 | } |
621 | break; | 621 | break; |
622 | #endregion | 622 | #endregion |
623 | 623 | ||
624 | #region Estate Packets | 624 | #region Estate Packets |
625 | case PacketType.EstateOwnerMessage: | 625 | case PacketType.EstateOwnerMessage: |
626 | EstateOwnerMessagePacket messagePacket = (EstateOwnerMessagePacket)Pack; | 626 | EstateOwnerMessagePacket messagePacket = (EstateOwnerMessagePacket)Pack; |
627 | if (OnEstateOwnerMessage != null) | 627 | if (OnEstateOwnerMessage != null) |
628 | { | 628 | { |
629 | OnEstateOwnerMessage(messagePacket, this); | 629 | OnEstateOwnerMessage(messagePacket, this); |
630 | } | 630 | } |
631 | break; | 631 | break; |
632 | #endregion | 632 | #endregion |
633 | 633 | ||
634 | #region unimplemented handlers | 634 | #region unimplemented handlers |
635 | case PacketType.AgentIsNowWearing: | 635 | case PacketType.AgentIsNowWearing: |
636 | // AgentIsNowWearingPacket wear = (AgentIsNowWearingPacket)Pack; | 636 | // AgentIsNowWearingPacket wear = (AgentIsNowWearingPacket)Pack; |
637 | //Console.WriteLine(Pack.ToString()); | 637 | //Console.WriteLine(Pack.ToString()); |
638 | break; | 638 | break; |
639 | case PacketType.ObjectScale: | 639 | case PacketType.ObjectScale: |
640 | //OpenSim.Framework.Console.MainLog.Instance.Verbose( Pack.ToString()); | 640 | //OpenSim.Framework.Console.MainLog.Instance.Verbose( Pack.ToString()); |
641 | break; | 641 | break; |
642 | #endregion | 642 | #endregion |
643 | } | 643 | } |
644 | } | 644 | } |
645 | } | 645 | } |
646 | } | 646 | } |
647 | } | 647 | } |
diff --git a/OpenSim/Region/ClientStack/ClientView.cs b/OpenSim/Region/ClientStack/ClientView.cs index 0fe3884..9fddc7b 100644 --- a/OpenSim/Region/ClientStack/ClientView.cs +++ b/OpenSim/Region/ClientStack/ClientView.cs | |||
@@ -1,293 +1,293 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | 2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
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 | */ |
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Net; | 30 | using System.Net; |
31 | using System.Text; | 31 | using System.Text; |
32 | using System.Threading; | 32 | using System.Threading; |
33 | using System.Timers; | 33 | using System.Timers; |
34 | using libsecondlife; | 34 | using libsecondlife; |
35 | using libsecondlife.Packets; | 35 | using libsecondlife.Packets; |
36 | using OpenSim.Assets; | 36 | using OpenSim.Assets; |
37 | using OpenSim.Framework; | 37 | using OpenSim.Framework; |
38 | using OpenSim.Framework.Console; | 38 | using OpenSim.Framework.Console; |
39 | using OpenSim.Framework.Interfaces; | 39 | using OpenSim.Framework.Interfaces; |
40 | using OpenSim.Framework.Inventory; | 40 | using OpenSim.Framework.Inventory; |
41 | using OpenSim.Framework.Types; | 41 | using OpenSim.Framework.Types; |
42 | using OpenSim.Framework.Utilities; | 42 | using OpenSim.Framework.Utilities; |
43 | using OpenSim.Region.Caches; | 43 | using OpenSim.Region.Caches; |
44 | using Timer=System.Timers.Timer; | 44 | using Timer=System.Timers.Timer; |
45 | 45 | ||
46 | namespace OpenSim.Region.ClientStack | 46 | namespace OpenSim.Region.ClientStack |
47 | { | 47 | { |
48 | public delegate bool PacketMethod(ClientView simClient, Packet packet); | 48 | public delegate bool PacketMethod(ClientView simClient, Packet packet); |
49 | 49 | ||
50 | /// <summary> | 50 | /// <summary> |
51 | /// Handles new client connections | 51 | /// Handles new client connections |
52 | /// Constructor takes a single Packet and authenticates everything | 52 | /// Constructor takes a single Packet and authenticates everything |
53 | /// </summary> | 53 | /// </summary> |
54 | public partial class ClientView : ClientViewBase, IClientAPI | 54 | public partial class ClientView : ClientViewBase, IClientAPI |
55 | { | 55 | { |
56 | public static TerrainManager TerrainManager; | 56 | public static TerrainManager TerrainManager; |
57 | 57 | ||
58 | protected static Dictionary<PacketType, PacketMethod> PacketHandlers = new Dictionary<PacketType, PacketMethod>(); //Global/static handlers for all clients | 58 | protected static Dictionary<PacketType, PacketMethod> PacketHandlers = new Dictionary<PacketType, PacketMethod>(); //Global/static handlers for all clients |
59 | protected Dictionary<PacketType, PacketMethod> m_packetHandlers = new Dictionary<PacketType, PacketMethod>(); //local handlers for this instance | 59 | protected Dictionary<PacketType, PacketMethod> m_packetHandlers = new Dictionary<PacketType, PacketMethod>(); //local handlers for this instance |
60 | 60 | ||
61 | public LLUUID AgentID; | 61 | public LLUUID AgentID; |
62 | public LLUUID SessionID; | 62 | public LLUUID SessionID; |
63 | public LLUUID SecureSessionID = LLUUID.Zero; | 63 | public LLUUID SecureSessionID = LLUUID.Zero; |
64 | public string firstName; | 64 | public string firstName; |
65 | public string lastName; | 65 | public string lastName; |
66 | public bool m_child = false; | 66 | public bool m_child = false; |
67 | private UseCircuitCodePacket cirpack; | 67 | private UseCircuitCodePacket cirpack; |
68 | public Thread ClientThread; | 68 | public Thread ClientThread; |
69 | public LLVector3 startpos; | 69 | public LLVector3 startpos; |
70 | 70 | ||
71 | private AgentAssetUpload UploadAssets; | 71 | private AgentAssetUpload UploadAssets; |
72 | private LLUUID newAssetFolder = LLUUID.Zero; | 72 | private LLUUID newAssetFolder = LLUUID.Zero; |
73 | private bool debug = false; | 73 | private bool debug = false; |
74 | protected IWorld m_world; | 74 | protected IWorld m_world; |
75 | private Dictionary<uint, ClientView> m_clientThreads; | 75 | private Dictionary<uint, ClientView> m_clientThreads; |
76 | private AssetCache m_assetCache; | 76 | private AssetCache m_assetCache; |
77 | private InventoryCache m_inventoryCache; | 77 | private InventoryCache m_inventoryCache; |
78 | private int cachedtextureserial = 0; | 78 | private int cachedtextureserial = 0; |
79 | protected AuthenticateSessionsBase m_authenticateSessionsHandler; | 79 | protected AuthenticateSessionsBase m_authenticateSessionsHandler; |
80 | private Encoding enc = Encoding.ASCII; | 80 | private Encoding enc = Encoding.ASCII; |
81 | // Dead client detection vars | 81 | // Dead client detection vars |
82 | private Timer clientPingTimer; | 82 | private Timer clientPingTimer; |
83 | private int packetsReceived = 0; | 83 | private int packetsReceived = 0; |
84 | private int probesWithNoIngressPackets = 0; | 84 | private int probesWithNoIngressPackets = 0; |
85 | private int lastPacketsReceived = 0; | 85 | private int lastPacketsReceived = 0; |
86 | 86 | ||
87 | public ClientView(EndPoint remoteEP, UseCircuitCodePacket initialcirpack, Dictionary<uint, ClientView> clientThreads, IWorld world, AssetCache assetCache, PacketServer packServer, InventoryCache inventoryCache, AuthenticateSessionsBase authenSessions ) | 87 | public ClientView(EndPoint remoteEP, UseCircuitCodePacket initialcirpack, Dictionary<uint, ClientView> clientThreads, IWorld world, AssetCache assetCache, PacketServer packServer, InventoryCache inventoryCache, AuthenticateSessionsBase authenSessions ) |
88 | { | 88 | { |
89 | m_world = world; | 89 | m_world = world; |
90 | m_clientThreads = clientThreads; | 90 | m_clientThreads = clientThreads; |
91 | m_assetCache = assetCache; | 91 | m_assetCache = assetCache; |
92 | 92 | ||
93 | m_networkServer = packServer; | 93 | m_networkServer = packServer; |
94 | m_inventoryCache = inventoryCache; | 94 | m_inventoryCache = inventoryCache; |
95 | m_authenticateSessionsHandler = authenSessions; | 95 | m_authenticateSessionsHandler = authenSessions; |
96 | 96 | ||
97 | MainLog.Instance.Verbose( "OpenSimClient.cs - Started up new client thread to handle incoming request"); | 97 | MainLog.Instance.Verbose( "OpenSimClient.cs - Started up new client thread to handle incoming request"); |
98 | cirpack = initialcirpack; | 98 | cirpack = initialcirpack; |
99 | userEP = remoteEP; | 99 | userEP = remoteEP; |
100 | 100 | ||
101 | this.startpos = m_authenticateSessionsHandler.GetPosition(initialcirpack.CircuitCode.Code); | 101 | this.startpos = m_authenticateSessionsHandler.GetPosition(initialcirpack.CircuitCode.Code); |
102 | 102 | ||
103 | PacketQueue = new BlockingQueue<QueItem>(); | 103 | PacketQueue = new BlockingQueue<QueItem>(); |
104 | 104 | ||
105 | this.UploadAssets = new AgentAssetUpload(this, m_assetCache, m_inventoryCache); | 105 | this.UploadAssets = new AgentAssetUpload(this, m_assetCache, m_inventoryCache); |
106 | AckTimer = new Timer(500); | 106 | AckTimer = new Timer(500); |
107 | AckTimer.Elapsed += new ElapsedEventHandler(AckTimer_Elapsed); | 107 | AckTimer.Elapsed += new ElapsedEventHandler(AckTimer_Elapsed); |
108 | AckTimer.Start(); | 108 | AckTimer.Start(); |
109 | 109 | ||
110 | this.RegisterLocalPacketHandlers(); | 110 | this.RegisterLocalPacketHandlers(); |
111 | 111 | ||
112 | ClientThread = new Thread(new ThreadStart(AuthUser)); | 112 | ClientThread = new Thread(new ThreadStart(AuthUser)); |
113 | ClientThread.IsBackground = true; | 113 | ClientThread.IsBackground = true; |
114 | ClientThread.Start(); | 114 | ClientThread.Start(); |
115 | } | 115 | } |
116 | 116 | ||
117 | # region Client Methods | 117 | # region Client Methods |
118 | 118 | ||
119 | public void KillClient() | 119 | public void KillClient() |
120 | { | 120 | { |
121 | clientPingTimer.Stop(); | 121 | clientPingTimer.Stop(); |
122 | this.m_inventoryCache.ClientLeaving(this.AgentID, null); | 122 | this.m_inventoryCache.ClientLeaving(this.AgentID, null); |
123 | m_world.RemoveClient(this.AgentId); | 123 | m_world.RemoveClient(this.AgentId); |
124 | 124 | ||
125 | m_clientThreads.Remove(this.CircuitCode); | 125 | m_clientThreads.Remove(this.CircuitCode); |
126 | m_networkServer.RemoveClientCircuit(this.CircuitCode); | 126 | m_networkServer.RemoveClientCircuit(this.CircuitCode); |
127 | this.ClientThread.Abort(); | 127 | this.ClientThread.Abort(); |
128 | } | 128 | } |
129 | #endregion | 129 | #endregion |
130 | 130 | ||
131 | # region Packet Handling | 131 | # region Packet Handling |
132 | public static bool AddPacketHandler(PacketType packetType, PacketMethod handler) | 132 | public static bool AddPacketHandler(PacketType packetType, PacketMethod handler) |
133 | { | 133 | { |
134 | bool result = false; | 134 | bool result = false; |
135 | lock (PacketHandlers) | 135 | lock (PacketHandlers) |
136 | { | 136 | { |
137 | if (!PacketHandlers.ContainsKey(packetType)) | 137 | if (!PacketHandlers.ContainsKey(packetType)) |
138 | { | 138 | { |
139 | PacketHandlers.Add(packetType, handler); | 139 | PacketHandlers.Add(packetType, handler); |
140 | result = true; | 140 | result = true; |
141 | } | 141 | } |
142 | } | 142 | } |
143 | return result; | 143 | return result; |
144 | } | 144 | } |
145 | 145 | ||
146 | public bool AddLocalPacketHandler(PacketType packetType, PacketMethod handler) | 146 | public bool AddLocalPacketHandler(PacketType packetType, PacketMethod handler) |
147 | { | 147 | { |
148 | bool result = false; | 148 | bool result = false; |
149 | lock (m_packetHandlers) | 149 | lock (m_packetHandlers) |
150 | { | 150 | { |
151 | if (!m_packetHandlers.ContainsKey(packetType)) | 151 | if (!m_packetHandlers.ContainsKey(packetType)) |
152 | { | 152 | { |
153 | m_packetHandlers.Add(packetType, handler); | 153 | m_packetHandlers.Add(packetType, handler); |
154 | result = true; | 154 | result = true; |
155 | } | 155 | } |
156 | } | 156 | } |
157 | return result; | 157 | return result; |
158 | } | 158 | } |
159 | 159 | ||
160 | protected virtual bool ProcessPacketMethod(Packet packet) | 160 | protected virtual bool ProcessPacketMethod(Packet packet) |
161 | { | 161 | { |
162 | bool result = false; | 162 | bool result = false; |
163 | bool found = false; | 163 | bool found = false; |
164 | PacketMethod method; | 164 | PacketMethod method; |
165 | if (m_packetHandlers.TryGetValue(packet.Type, out method)) | 165 | if (m_packetHandlers.TryGetValue(packet.Type, out method)) |
166 | { | 166 | { |
167 | //there is a local handler for this packet type | 167 | //there is a local handler for this packet type |
168 | result = method(this, packet); | 168 | result = method(this, packet); |
169 | } | 169 | } |
170 | else | 170 | else |
171 | { | 171 | { |
172 | //there is not a local handler so see if there is a Global handler | 172 | //there is not a local handler so see if there is a Global handler |
173 | lock (PacketHandlers) | 173 | lock (PacketHandlers) |
174 | { | 174 | { |
175 | found = PacketHandlers.TryGetValue(packet.Type, out method); | 175 | found = PacketHandlers.TryGetValue(packet.Type, out method); |
176 | } | 176 | } |
177 | if (found) | 177 | if (found) |
178 | { | 178 | { |
179 | result = method(this, packet); | 179 | result = method(this, packet); |
180 | } | 180 | } |
181 | } | 181 | } |
182 | return result; | 182 | return result; |
183 | } | 183 | } |
184 | 184 | ||
185 | protected virtual void ClientLoop() | 185 | protected virtual void ClientLoop() |
186 | { | 186 | { |
187 | MainLog.Instance.Verbose( "OpenSimClient.cs:ClientLoop() - Entered loop"); | 187 | MainLog.Instance.Verbose( "OpenSimClient.cs:ClientLoop() - Entered loop"); |
188 | while (true) | 188 | while (true) |
189 | { | 189 | { |
190 | QueItem nextPacket = PacketQueue.Dequeue(); | 190 | QueItem nextPacket = PacketQueue.Dequeue(); |
191 | if (nextPacket.Incoming) | 191 | if (nextPacket.Incoming) |
192 | { | 192 | { |
193 | //is a incoming packet | 193 | //is a incoming packet |
194 | if (nextPacket.Packet.Type != PacketType.AgentUpdate) { | 194 | if (nextPacket.Packet.Type != PacketType.AgentUpdate) { |
195 | packetsReceived++; | 195 | packetsReceived++; |
196 | } | 196 | } |
197 | ProcessInPacket(nextPacket.Packet); | 197 | ProcessInPacket(nextPacket.Packet); |
198 | } | 198 | } |
199 | else | 199 | else |
200 | { | 200 | { |
201 | //is a out going packet | 201 | //is a out going packet |
202 | ProcessOutPacket(nextPacket.Packet); | 202 | ProcessOutPacket(nextPacket.Packet); |
203 | } | 203 | } |
204 | } | 204 | } |
205 | } | 205 | } |
206 | # endregion | 206 | # endregion |
207 | 207 | ||
208 | protected void CheckClientConnectivity(object sender, ElapsedEventArgs e) | 208 | protected void CheckClientConnectivity(object sender, ElapsedEventArgs e) |
209 | { | 209 | { |
210 | if (packetsReceived == lastPacketsReceived) { | 210 | if (packetsReceived == lastPacketsReceived) { |
211 | probesWithNoIngressPackets++; | 211 | probesWithNoIngressPackets++; |
212 | if (probesWithNoIngressPackets > 30) { | 212 | if (probesWithNoIngressPackets > 30) { |
213 | this.KillClient(); | 213 | this.KillClient(); |
214 | } else { | 214 | } else { |
215 | // this will normally trigger at least one packet (ping response) | 215 | // this will normally trigger at least one packet (ping response) |
216 | SendStartPingCheck(0); | 216 | SendStartPingCheck(0); |
217 | } | 217 | } |
218 | } else { | 218 | } else { |
219 | // Something received in the meantime - we can reset the counters | 219 | // Something received in the meantime - we can reset the counters |
220 | probesWithNoIngressPackets = 0; | 220 | probesWithNoIngressPackets = 0; |
221 | lastPacketsReceived = packetsReceived; | 221 | lastPacketsReceived = packetsReceived; |
222 | } | 222 | } |
223 | } | 223 | } |
224 | 224 | ||
225 | # region Setup | 225 | # region Setup |
226 | 226 | ||
227 | protected virtual void InitNewClient() | 227 | protected virtual void InitNewClient() |
228 | { | 228 | { |
229 | clientPingTimer = new Timer(1000); | 229 | clientPingTimer = new Timer(1000); |
230 | clientPingTimer.Elapsed += new ElapsedEventHandler(CheckClientConnectivity); | 230 | clientPingTimer.Elapsed += new ElapsedEventHandler(CheckClientConnectivity); |
231 | clientPingTimer.Enabled = true; | 231 | clientPingTimer.Enabled = true; |
232 | 232 | ||
233 | MainLog.Instance.Verbose( "OpenSimClient.cs:InitNewClient() - Adding viewer agent to world"); | 233 | MainLog.Instance.Verbose( "OpenSimClient.cs:InitNewClient() - Adding viewer agent to world"); |
234 | this.m_world.AddNewClient(this, false); | 234 | this.m_world.AddNewClient(this, false); |
235 | } | 235 | } |
236 | 236 | ||
237 | protected virtual void AuthUser() | 237 | protected virtual void AuthUser() |
238 | { | 238 | { |
239 | // AuthenticateResponse sessionInfo = m_gridServer.AuthenticateSession(cirpack.CircuitCode.SessionID, cirpack.CircuitCode.ID, cirpack.CircuitCode.Code); | 239 | // AuthenticateResponse sessionInfo = m_gridServer.AuthenticateSession(cirpack.CircuitCode.SessionID, cirpack.CircuitCode.ID, cirpack.CircuitCode.Code); |
240 | AuthenticateResponse sessionInfo = this.m_authenticateSessionsHandler.AuthenticateSession(cirpack.CircuitCode.SessionID, cirpack.CircuitCode.ID, cirpack.CircuitCode.Code); | 240 | AuthenticateResponse sessionInfo = this.m_authenticateSessionsHandler.AuthenticateSession(cirpack.CircuitCode.SessionID, cirpack.CircuitCode.ID, cirpack.CircuitCode.Code); |
241 | if (!sessionInfo.Authorised) | 241 | if (!sessionInfo.Authorised) |
242 | { | 242 | { |
243 | //session/circuit not authorised | 243 | //session/circuit not authorised |
244 | MainLog.Instance.Notice("OpenSimClient.cs:AuthUser() - New user request denied to " + userEP.ToString()); | 244 | MainLog.Instance.Notice("OpenSimClient.cs:AuthUser() - New user request denied to " + userEP.ToString()); |
245 | ClientThread.Abort(); | 245 | ClientThread.Abort(); |
246 | } | 246 | } |
247 | else | 247 | else |
248 | { | 248 | { |
249 | MainLog.Instance.Notice("OpenSimClient.cs:AuthUser() - Got authenticated connection from " + userEP.ToString()); | 249 | MainLog.Instance.Notice("OpenSimClient.cs:AuthUser() - Got authenticated connection from " + userEP.ToString()); |
250 | //session is authorised | 250 | //session is authorised |
251 | this.AgentID = cirpack.CircuitCode.ID; | 251 | this.AgentID = cirpack.CircuitCode.ID; |
252 | this.SessionID = cirpack.CircuitCode.SessionID; | 252 | this.SessionID = cirpack.CircuitCode.SessionID; |
253 | this.CircuitCode = cirpack.CircuitCode.Code; | 253 | this.CircuitCode = cirpack.CircuitCode.Code; |
254 | this.firstName = sessionInfo.LoginInfo.First; | 254 | this.firstName = sessionInfo.LoginInfo.First; |
255 | this.lastName = sessionInfo.LoginInfo.Last; | 255 | this.lastName = sessionInfo.LoginInfo.Last; |
256 | 256 | ||
257 | if (sessionInfo.LoginInfo.SecureSession != LLUUID.Zero) | 257 | if (sessionInfo.LoginInfo.SecureSession != LLUUID.Zero) |
258 | { | 258 | { |
259 | this.SecureSessionID = sessionInfo.LoginInfo.SecureSession; | 259 | this.SecureSessionID = sessionInfo.LoginInfo.SecureSession; |
260 | } | 260 | } |
261 | InitNewClient(); | 261 | InitNewClient(); |
262 | 262 | ||
263 | ClientLoop(); | 263 | ClientLoop(); |
264 | } | 264 | } |
265 | } | 265 | } |
266 | # endregion | 266 | # endregion |
267 | 267 | ||
268 | 268 | ||
269 | protected override void KillThread() | 269 | protected override void KillThread() |
270 | { | 270 | { |
271 | this.ClientThread.Abort(); | 271 | this.ClientThread.Abort(); |
272 | } | 272 | } |
273 | 273 | ||
274 | #region Inventory Creation | 274 | #region Inventory Creation |
275 | private void SetupInventory(AuthenticateResponse sessionInfo) | 275 | private void SetupInventory(AuthenticateResponse sessionInfo) |
276 | { | 276 | { |
277 | 277 | ||
278 | } | 278 | } |
279 | private AgentInventory CreateInventory(LLUUID baseFolder) | 279 | private AgentInventory CreateInventory(LLUUID baseFolder) |
280 | { | 280 | { |
281 | AgentInventory inventory = null; | 281 | AgentInventory inventory = null; |
282 | 282 | ||
283 | return inventory; | 283 | return inventory; |
284 | } | 284 | } |
285 | 285 | ||
286 | private void CreateInventoryItem(CreateInventoryItemPacket packet) | 286 | private void CreateInventoryItem(CreateInventoryItemPacket packet) |
287 | { | 287 | { |
288 | 288 | ||
289 | } | 289 | } |
290 | #endregion | 290 | #endregion |
291 | 291 | ||
292 | } | 292 | } |
293 | } | 293 | } |
diff --git a/OpenSim/Region/ClientStack/ClientViewBase.cs b/OpenSim/Region/ClientStack/ClientViewBase.cs index cc04bda..597cd7d 100644 --- a/OpenSim/Region/ClientStack/ClientViewBase.cs +++ b/OpenSim/Region/ClientStack/ClientViewBase.cs | |||
@@ -1,326 +1,326 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | 2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
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 | */ |
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Net; | 30 | using System.Net; |
31 | using System.Net.Sockets; | 31 | using System.Net.Sockets; |
32 | using System.Timers; | 32 | using System.Timers; |
33 | using libsecondlife; | 33 | using libsecondlife; |
34 | using libsecondlife.Packets; | 34 | using libsecondlife.Packets; |
35 | using OpenSim.Framework.Console; | 35 | using OpenSim.Framework.Console; |
36 | using OpenSim.Framework.Utilities; | 36 | using OpenSim.Framework.Utilities; |
37 | using OpenSim.Region.Environment; | 37 | using OpenSim.Region.Environment; |
38 | 38 | ||
39 | namespace OpenSim.Region.ClientStack | 39 | namespace OpenSim.Region.ClientStack |
40 | { | 40 | { |
41 | public class ClientViewBase | 41 | public class ClientViewBase |
42 | { | 42 | { |
43 | protected BlockingQueue<QueItem> PacketQueue; | 43 | protected BlockingQueue<QueItem> PacketQueue; |
44 | protected Dictionary<uint, uint> PendingAcks = new Dictionary<uint, uint>(); | 44 | protected Dictionary<uint, uint> PendingAcks = new Dictionary<uint, uint>(); |
45 | protected Dictionary<uint, Packet> NeedAck = new Dictionary<uint, Packet>(); | 45 | protected Dictionary<uint, Packet> NeedAck = new Dictionary<uint, Packet>(); |
46 | 46 | ||
47 | protected Timer AckTimer; | 47 | protected Timer AckTimer; |
48 | protected uint Sequence = 0; | 48 | protected uint Sequence = 0; |
49 | protected object SequenceLock = new object(); | 49 | protected object SequenceLock = new object(); |
50 | protected const int MAX_APPENDED_ACKS = 10; | 50 | protected const int MAX_APPENDED_ACKS = 10; |
51 | protected const int RESEND_TIMEOUT = 4000; | 51 | protected const int RESEND_TIMEOUT = 4000; |
52 | protected const int MAX_SEQUENCE = 0xFFFFFF; | 52 | protected const int MAX_SEQUENCE = 0xFFFFFF; |
53 | 53 | ||
54 | public uint CircuitCode; | 54 | public uint CircuitCode; |
55 | public EndPoint userEP; | 55 | public EndPoint userEP; |
56 | 56 | ||
57 | protected PacketServer m_networkServer; | 57 | protected PacketServer m_networkServer; |
58 | 58 | ||
59 | public ClientViewBase() | 59 | public ClientViewBase() |
60 | { | 60 | { |
61 | 61 | ||
62 | } | 62 | } |
63 | 63 | ||
64 | protected virtual void ProcessInPacket(Packet Pack) | 64 | protected virtual void ProcessInPacket(Packet Pack) |
65 | { | 65 | { |
66 | 66 | ||
67 | } | 67 | } |
68 | 68 | ||
69 | protected virtual void ProcessOutPacket(Packet Pack) | 69 | protected virtual void ProcessOutPacket(Packet Pack) |
70 | { | 70 | { |
71 | // Keep track of when this packet was sent out | 71 | // Keep track of when this packet was sent out |
72 | Pack.TickCount = System.Environment.TickCount; | 72 | Pack.TickCount = System.Environment.TickCount; |
73 | 73 | ||
74 | // Console.WriteLine(CircuitCode + ":OUT: " + Pack.Type.ToString()); | 74 | // Console.WriteLine(CircuitCode + ":OUT: " + Pack.Type.ToString()); |
75 | 75 | ||
76 | if (!Pack.Header.Resent) | 76 | if (!Pack.Header.Resent) |
77 | { | 77 | { |
78 | // Set the sequence number | 78 | // Set the sequence number |
79 | lock (SequenceLock) | 79 | lock (SequenceLock) |
80 | { | 80 | { |
81 | if (Sequence >= MAX_SEQUENCE) | 81 | if (Sequence >= MAX_SEQUENCE) |
82 | Sequence = 1; | 82 | Sequence = 1; |
83 | else | 83 | else |
84 | Sequence++; | 84 | Sequence++; |
85 | Pack.Header.Sequence = Sequence; | 85 | Pack.Header.Sequence = Sequence; |
86 | } | 86 | } |
87 | 87 | ||
88 | if (Pack.Header.Reliable) //DIRTY HACK | 88 | if (Pack.Header.Reliable) //DIRTY HACK |
89 | { | 89 | { |
90 | lock (NeedAck) | 90 | lock (NeedAck) |
91 | { | 91 | { |
92 | if (!NeedAck.ContainsKey(Pack.Header.Sequence)) | 92 | if (!NeedAck.ContainsKey(Pack.Header.Sequence)) |
93 | { | 93 | { |
94 | try | 94 | try |
95 | { | 95 | { |
96 | NeedAck.Add(Pack.Header.Sequence, Pack); | 96 | NeedAck.Add(Pack.Header.Sequence, Pack); |
97 | } | 97 | } |
98 | catch (Exception e) // HACKY | 98 | catch (Exception e) // HACKY |
99 | { | 99 | { |
100 | e.ToString(); | 100 | e.ToString(); |
101 | // Ignore | 101 | // Ignore |
102 | // Seems to throw a exception here occasionally | 102 | // Seems to throw a exception here occasionally |
103 | // of 'duplicate key' despite being locked. | 103 | // of 'duplicate key' despite being locked. |
104 | // !?!?!? | 104 | // !?!?!? |
105 | } | 105 | } |
106 | } | 106 | } |
107 | else | 107 | else |
108 | { | 108 | { |
109 | // Client.Log("Attempted to add a duplicate sequence number (" + | 109 | // Client.Log("Attempted to add a duplicate sequence number (" + |
110 | // packet.Header.Sequence + ") to the NeedAck dictionary for packet type " + | 110 | // packet.Header.Sequence + ") to the NeedAck dictionary for packet type " + |
111 | // packet.Type.ToString(), Helpers.LogLevel.Warning); | 111 | // packet.Type.ToString(), Helpers.LogLevel.Warning); |
112 | } | 112 | } |
113 | } | 113 | } |
114 | 114 | ||
115 | // Don't append ACKs to resent packets, in case that's what was causing the | 115 | // Don't append ACKs to resent packets, in case that's what was causing the |
116 | // delivery to fail | 116 | // delivery to fail |
117 | if (!Pack.Header.Resent) | 117 | if (!Pack.Header.Resent) |
118 | { | 118 | { |
119 | // Append any ACKs that need to be sent out to this packet | 119 | // Append any ACKs that need to be sent out to this packet |
120 | lock (PendingAcks) | 120 | lock (PendingAcks) |
121 | { | 121 | { |
122 | if (PendingAcks.Count > 0 && PendingAcks.Count < MAX_APPENDED_ACKS && | 122 | if (PendingAcks.Count > 0 && PendingAcks.Count < MAX_APPENDED_ACKS && |
123 | Pack.Type != PacketType.PacketAck && | 123 | Pack.Type != PacketType.PacketAck && |
124 | Pack.Type != PacketType.LogoutRequest) | 124 | Pack.Type != PacketType.LogoutRequest) |
125 | { | 125 | { |
126 | Pack.Header.AckList = new uint[PendingAcks.Count]; | 126 | Pack.Header.AckList = new uint[PendingAcks.Count]; |
127 | int i = 0; | 127 | int i = 0; |
128 | 128 | ||
129 | foreach (uint ack in PendingAcks.Values) | 129 | foreach (uint ack in PendingAcks.Values) |
130 | { | 130 | { |
131 | Pack.Header.AckList[i] = ack; | 131 | Pack.Header.AckList[i] = ack; |
132 | i++; | 132 | i++; |
133 | } | 133 | } |
134 | 134 | ||
135 | PendingAcks.Clear(); | 135 | PendingAcks.Clear(); |
136 | Pack.Header.AppendedAcks = true; | 136 | Pack.Header.AppendedAcks = true; |
137 | } | 137 | } |
138 | } | 138 | } |
139 | } | 139 | } |
140 | } | 140 | } |
141 | } | 141 | } |
142 | 142 | ||
143 | byte[] ZeroOutBuffer = new byte[4096]; | 143 | byte[] ZeroOutBuffer = new byte[4096]; |
144 | byte[] sendbuffer; | 144 | byte[] sendbuffer; |
145 | sendbuffer = Pack.ToBytes(); | 145 | sendbuffer = Pack.ToBytes(); |
146 | 146 | ||
147 | try | 147 | try |
148 | { | 148 | { |
149 | if (Pack.Header.Zerocoded) | 149 | if (Pack.Header.Zerocoded) |
150 | { | 150 | { |
151 | int packetsize = Helpers.ZeroEncode(sendbuffer, sendbuffer.Length, ZeroOutBuffer); | 151 | int packetsize = Helpers.ZeroEncode(sendbuffer, sendbuffer.Length, ZeroOutBuffer); |
152 | m_networkServer.SendPacketTo(ZeroOutBuffer, packetsize, SocketFlags.None, CircuitCode);//userEP); | 152 | m_networkServer.SendPacketTo(ZeroOutBuffer, packetsize, SocketFlags.None, CircuitCode);//userEP); |
153 | } | 153 | } |
154 | else | 154 | else |
155 | { | 155 | { |
156 | m_networkServer.SendPacketTo(sendbuffer, sendbuffer.Length, SocketFlags.None, CircuitCode); //userEP); | 156 | m_networkServer.SendPacketTo(sendbuffer, sendbuffer.Length, SocketFlags.None, CircuitCode); //userEP); |
157 | } | 157 | } |
158 | } | 158 | } |
159 | catch (Exception) | 159 | catch (Exception) |
160 | { | 160 | { |
161 | MainLog.Instance.Warn("OpenSimClient.cs:ProcessOutPacket() - WARNING: Socket exception occurred on connection " + userEP.ToString() + " - killing thread"); | 161 | MainLog.Instance.Warn("OpenSimClient.cs:ProcessOutPacket() - WARNING: Socket exception occurred on connection " + userEP.ToString() + " - killing thread"); |
162 | this.KillThread(); | 162 | this.KillThread(); |
163 | } | 163 | } |
164 | 164 | ||
165 | } | 165 | } |
166 | 166 | ||
167 | public virtual void InPacket(Packet NewPack) | 167 | public virtual void InPacket(Packet NewPack) |
168 | { | 168 | { |
169 | // Handle appended ACKs | 169 | // Handle appended ACKs |
170 | if (NewPack.Header.AppendedAcks) | 170 | if (NewPack.Header.AppendedAcks) |
171 | { | 171 | { |
172 | lock (NeedAck) | 172 | lock (NeedAck) |
173 | { | 173 | { |
174 | foreach (uint ack in NewPack.Header.AckList) | 174 | foreach (uint ack in NewPack.Header.AckList) |
175 | { | 175 | { |
176 | NeedAck.Remove(ack); | 176 | NeedAck.Remove(ack); |
177 | } | 177 | } |
178 | } | 178 | } |
179 | } | 179 | } |
180 | 180 | ||
181 | // Handle PacketAck packets | 181 | // Handle PacketAck packets |
182 | if (NewPack.Type == PacketType.PacketAck) | 182 | if (NewPack.Type == PacketType.PacketAck) |
183 | { | 183 | { |
184 | PacketAckPacket ackPacket = (PacketAckPacket)NewPack; | 184 | PacketAckPacket ackPacket = (PacketAckPacket)NewPack; |
185 | 185 | ||
186 | lock (NeedAck) | 186 | lock (NeedAck) |
187 | { | 187 | { |
188 | foreach (PacketAckPacket.PacketsBlock block in ackPacket.Packets) | 188 | foreach (PacketAckPacket.PacketsBlock block in ackPacket.Packets) |
189 | { | 189 | { |
190 | NeedAck.Remove(block.ID); | 190 | NeedAck.Remove(block.ID); |
191 | } | 191 | } |
192 | } | 192 | } |
193 | } | 193 | } |
194 | else if ((NewPack.Type == PacketType.StartPingCheck)) | 194 | else if ((NewPack.Type == PacketType.StartPingCheck)) |
195 | { | 195 | { |
196 | //reply to pingcheck | 196 | //reply to pingcheck |
197 | StartPingCheckPacket startPing = (StartPingCheckPacket)NewPack; | 197 | StartPingCheckPacket startPing = (StartPingCheckPacket)NewPack; |
198 | CompletePingCheckPacket endPing = new CompletePingCheckPacket(); | 198 | CompletePingCheckPacket endPing = new CompletePingCheckPacket(); |
199 | endPing.PingID.PingID = startPing.PingID.PingID; | 199 | endPing.PingID.PingID = startPing.PingID.PingID; |
200 | OutPacket(endPing); | 200 | OutPacket(endPing); |
201 | } | 201 | } |
202 | else | 202 | else |
203 | { | 203 | { |
204 | QueItem item = new QueItem(); | 204 | QueItem item = new QueItem(); |
205 | item.Packet = NewPack; | 205 | item.Packet = NewPack; |
206 | item.Incoming = true; | 206 | item.Incoming = true; |
207 | this.PacketQueue.Enqueue(item); | 207 | this.PacketQueue.Enqueue(item); |
208 | } | 208 | } |
209 | 209 | ||
210 | } | 210 | } |
211 | 211 | ||
212 | public virtual void OutPacket(Packet NewPack) | 212 | public virtual void OutPacket(Packet NewPack) |
213 | { | 213 | { |
214 | QueItem item = new QueItem(); | 214 | QueItem item = new QueItem(); |
215 | item.Packet = NewPack; | 215 | item.Packet = NewPack; |
216 | item.Incoming = false; | 216 | item.Incoming = false; |
217 | this.PacketQueue.Enqueue(item); | 217 | this.PacketQueue.Enqueue(item); |
218 | } | 218 | } |
219 | 219 | ||
220 | # region Low Level Packet Methods | 220 | # region Low Level Packet Methods |
221 | 221 | ||
222 | protected void ack_pack(Packet Pack) | 222 | protected void ack_pack(Packet Pack) |
223 | { | 223 | { |
224 | if (Pack.Header.Reliable) | 224 | if (Pack.Header.Reliable) |
225 | { | 225 | { |
226 | PacketAckPacket ack_it = new PacketAckPacket(); | 226 | PacketAckPacket ack_it = new PacketAckPacket(); |
227 | ack_it.Packets = new PacketAckPacket.PacketsBlock[1]; | 227 | ack_it.Packets = new PacketAckPacket.PacketsBlock[1]; |
228 | ack_it.Packets[0] = new PacketAckPacket.PacketsBlock(); | 228 | ack_it.Packets[0] = new PacketAckPacket.PacketsBlock(); |
229 | ack_it.Packets[0].ID = Pack.Header.Sequence; | 229 | ack_it.Packets[0].ID = Pack.Header.Sequence; |
230 | ack_it.Header.Reliable = false; | 230 | ack_it.Header.Reliable = false; |
231 | 231 | ||
232 | OutPacket(ack_it); | 232 | OutPacket(ack_it); |
233 | 233 | ||
234 | } | 234 | } |
235 | /* | 235 | /* |
236 | if (Pack.Header.Reliable) | 236 | if (Pack.Header.Reliable) |
237 | { | 237 | { |
238 | lock (PendingAcks) | 238 | lock (PendingAcks) |
239 | { | 239 | { |
240 | uint sequence = (uint)Pack.Header.Sequence; | 240 | uint sequence = (uint)Pack.Header.Sequence; |
241 | if (!PendingAcks.ContainsKey(sequence)) { PendingAcks[sequence] = sequence; } | 241 | if (!PendingAcks.ContainsKey(sequence)) { PendingAcks[sequence] = sequence; } |
242 | } | 242 | } |
243 | }*/ | 243 | }*/ |
244 | } | 244 | } |
245 | 245 | ||
246 | protected void ResendUnacked() | 246 | protected void ResendUnacked() |
247 | { | 247 | { |
248 | int now = System.Environment.TickCount; | 248 | int now = System.Environment.TickCount; |
249 | 249 | ||
250 | lock (NeedAck) | 250 | lock (NeedAck) |
251 | { | 251 | { |
252 | foreach (Packet packet in NeedAck.Values) | 252 | foreach (Packet packet in NeedAck.Values) |
253 | { | 253 | { |
254 | if ((now - packet.TickCount > RESEND_TIMEOUT) && (!packet.Header.Resent)) | 254 | if ((now - packet.TickCount > RESEND_TIMEOUT) && (!packet.Header.Resent)) |
255 | { | 255 | { |
256 | MainLog.Instance.Verbose( "Resending " + packet.Type.ToString() + " packet, " + | 256 | MainLog.Instance.Verbose( "Resending " + packet.Type.ToString() + " packet, " + |
257 | (now - packet.TickCount) + "ms have passed"); | 257 | (now - packet.TickCount) + "ms have passed"); |
258 | 258 | ||
259 | packet.Header.Resent = true; | 259 | packet.Header.Resent = true; |
260 | OutPacket(packet); | 260 | OutPacket(packet); |
261 | } | 261 | } |
262 | } | 262 | } |
263 | } | 263 | } |
264 | } | 264 | } |
265 | 265 | ||
266 | protected void SendAcks() | 266 | protected void SendAcks() |
267 | { | 267 | { |
268 | lock (PendingAcks) | 268 | lock (PendingAcks) |
269 | { | 269 | { |
270 | if (PendingAcks.Count > 0) | 270 | if (PendingAcks.Count > 0) |
271 | { | 271 | { |
272 | if (PendingAcks.Count > 250) | 272 | if (PendingAcks.Count > 250) |
273 | { | 273 | { |
274 | // FIXME: Handle the odd case where we have too many pending ACKs queued up | 274 | // FIXME: Handle the odd case where we have too many pending ACKs queued up |
275 | MainLog.Instance.Verbose( "Too many ACKs queued up!"); | 275 | MainLog.Instance.Verbose( "Too many ACKs queued up!"); |
276 | return; | 276 | return; |
277 | } | 277 | } |
278 | 278 | ||
279 | //OpenSim.Framework.Console.MainLog.Instance.WriteLine("Sending PacketAck"); | 279 | //OpenSim.Framework.Console.MainLog.Instance.WriteLine("Sending PacketAck"); |
280 | 280 | ||
281 | 281 | ||
282 | int i = 0; | 282 | int i = 0; |
283 | PacketAckPacket acks = new PacketAckPacket(); | 283 | PacketAckPacket acks = new PacketAckPacket(); |
284 | acks.Packets = new PacketAckPacket.PacketsBlock[PendingAcks.Count]; | 284 | acks.Packets = new PacketAckPacket.PacketsBlock[PendingAcks.Count]; |
285 | 285 | ||
286 | foreach (uint ack in PendingAcks.Values) | 286 | foreach (uint ack in PendingAcks.Values) |
287 | { | 287 | { |
288 | acks.Packets[i] = new PacketAckPacket.PacketsBlock(); | 288 | acks.Packets[i] = new PacketAckPacket.PacketsBlock(); |
289 | acks.Packets[i].ID = ack; | 289 | acks.Packets[i].ID = ack; |
290 | i++; | 290 | i++; |
291 | } | 291 | } |
292 | 292 | ||
293 | acks.Header.Reliable = false; | 293 | acks.Header.Reliable = false; |
294 | OutPacket(acks); | 294 | OutPacket(acks); |
295 | 295 | ||
296 | PendingAcks.Clear(); | 296 | PendingAcks.Clear(); |
297 | } | 297 | } |
298 | } | 298 | } |
299 | } | 299 | } |
300 | 300 | ||
301 | protected void AckTimer_Elapsed(object sender, ElapsedEventArgs ea) | 301 | protected void AckTimer_Elapsed(object sender, ElapsedEventArgs ea) |
302 | { | 302 | { |
303 | SendAcks(); | 303 | SendAcks(); |
304 | ResendUnacked(); | 304 | ResendUnacked(); |
305 | } | 305 | } |
306 | #endregion | 306 | #endregion |
307 | 307 | ||
308 | protected virtual void KillThread() | 308 | protected virtual void KillThread() |
309 | { | 309 | { |
310 | 310 | ||
311 | } | 311 | } |
312 | 312 | ||
313 | #region Nested Classes | 313 | #region Nested Classes |
314 | 314 | ||
315 | public class QueItem | 315 | public class QueItem |
316 | { | 316 | { |
317 | public QueItem() | 317 | public QueItem() |
318 | { | 318 | { |
319 | } | 319 | } |
320 | 320 | ||
321 | public Packet Packet; | 321 | public Packet Packet; |
322 | public bool Incoming; | 322 | public bool Incoming; |
323 | } | 323 | } |
324 | #endregion | 324 | #endregion |
325 | } | 325 | } |
326 | } | 326 | } |
diff --git a/OpenSim/Region/ClientStack/PacketServer.cs b/OpenSim/Region/ClientStack/PacketServer.cs index a88c682..466fdde 100644 --- a/OpenSim/Region/ClientStack/PacketServer.cs +++ b/OpenSim/Region/ClientStack/PacketServer.cs | |||
@@ -1,184 +1,184 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | 2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
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 | */ |
28 | using System.Collections.Generic; | 28 | using System.Collections.Generic; |
29 | using System.Net; | 29 | using System.Net; |
30 | using System.Net.Sockets; | 30 | using System.Net.Sockets; |
31 | using libsecondlife.Packets; | 31 | using libsecondlife.Packets; |
32 | using OpenSim.Assets; | 32 | using OpenSim.Assets; |
33 | using OpenSim.Framework; | 33 | using OpenSim.Framework; |
34 | using OpenSim.Framework.Interfaces; | 34 | using OpenSim.Framework.Interfaces; |
35 | using OpenSim.Region.Caches; | 35 | using OpenSim.Region.Caches; |
36 | 36 | ||
37 | namespace OpenSim.Region.ClientStack | 37 | namespace OpenSim.Region.ClientStack |
38 | { | 38 | { |
39 | public class PacketServer | 39 | public class PacketServer |
40 | { | 40 | { |
41 | private ClientStackNetworkHandler _networkHandler; | 41 | private ClientStackNetworkHandler _networkHandler; |
42 | private IWorld _localWorld; | 42 | private IWorld _localWorld; |
43 | public Dictionary<uint, ClientView> ClientThreads = new Dictionary<uint, ClientView>(); | 43 | public Dictionary<uint, ClientView> ClientThreads = new Dictionary<uint, ClientView>(); |
44 | private ClientManager m_clientManager = new ClientManager(); | 44 | private ClientManager m_clientManager = new ClientManager(); |
45 | public ClientManager ClientManager | 45 | public ClientManager ClientManager |
46 | { | 46 | { |
47 | get { return m_clientManager; } | 47 | get { return m_clientManager; } |
48 | } | 48 | } |
49 | 49 | ||
50 | public PacketServer(ClientStackNetworkHandler networkHandler) | 50 | public PacketServer(ClientStackNetworkHandler networkHandler) |
51 | { | 51 | { |
52 | _networkHandler = networkHandler; | 52 | _networkHandler = networkHandler; |
53 | _networkHandler.RegisterPacketServer(this); | 53 | _networkHandler.RegisterPacketServer(this); |
54 | } | 54 | } |
55 | 55 | ||
56 | public IWorld LocalWorld | 56 | public IWorld LocalWorld |
57 | { | 57 | { |
58 | set | 58 | set |
59 | { | 59 | { |
60 | this._localWorld = value; | 60 | this._localWorld = value; |
61 | } | 61 | } |
62 | } | 62 | } |
63 | 63 | ||
64 | /// <summary> | 64 | /// <summary> |
65 | /// | 65 | /// |
66 | /// </summary> | 66 | /// </summary> |
67 | /// <param name="circuitCode"></param> | 67 | /// <param name="circuitCode"></param> |
68 | /// <param name="packet"></param> | 68 | /// <param name="packet"></param> |
69 | public virtual void ClientInPacket(uint circuitCode, Packet packet) | 69 | public virtual void ClientInPacket(uint circuitCode, Packet packet) |
70 | { | 70 | { |
71 | if (this.ClientThreads.ContainsKey(circuitCode)) | 71 | if (this.ClientThreads.ContainsKey(circuitCode)) |
72 | { | 72 | { |
73 | ClientThreads[circuitCode].InPacket(packet); | 73 | ClientThreads[circuitCode].InPacket(packet); |
74 | } | 74 | } |
75 | } | 75 | } |
76 | 76 | ||
77 | /// <summary> | 77 | /// <summary> |
78 | /// | 78 | /// |
79 | /// </summary> | 79 | /// </summary> |
80 | /// <param name="circuitCode"></param> | 80 | /// <param name="circuitCode"></param> |
81 | /// <returns></returns> | 81 | /// <returns></returns> |
82 | public virtual bool AddNewCircuitCodeClient(uint circuitCode) | 82 | public virtual bool AddNewCircuitCodeClient(uint circuitCode) |
83 | { | 83 | { |
84 | return false; | 84 | return false; |
85 | } | 85 | } |
86 | 86 | ||
87 | /// <summary> | 87 | /// <summary> |
88 | /// | 88 | /// |
89 | /// </summary> | 89 | /// </summary> |
90 | /// <param name="packet"></param> | 90 | /// <param name="packet"></param> |
91 | public virtual void SendPacketToAllClients(Packet packet) | 91 | public virtual void SendPacketToAllClients(Packet packet) |
92 | { | 92 | { |
93 | 93 | ||
94 | } | 94 | } |
95 | 95 | ||
96 | /// <summary> | 96 | /// <summary> |
97 | /// | 97 | /// |
98 | /// </summary> | 98 | /// </summary> |
99 | /// <param name="packet"></param> | 99 | /// <param name="packet"></param> |
100 | /// <param name="simClient"></param> | 100 | /// <param name="simClient"></param> |
101 | public virtual void SendPacketToAllExcept(Packet packet, ClientView simClient) | 101 | public virtual void SendPacketToAllExcept(Packet packet, ClientView simClient) |
102 | { | 102 | { |
103 | 103 | ||
104 | } | 104 | } |
105 | 105 | ||
106 | /// <summary> | 106 | /// <summary> |
107 | /// | 107 | /// |
108 | /// </summary> | 108 | /// </summary> |
109 | /// <param name="packetType"></param> | 109 | /// <param name="packetType"></param> |
110 | /// <param name="handler"></param> | 110 | /// <param name="handler"></param> |
111 | public virtual void AddClientPacketHandler(PacketType packetType, PacketMethod handler) | 111 | public virtual void AddClientPacketHandler(PacketType packetType, PacketMethod handler) |
112 | { | 112 | { |
113 | 113 | ||
114 | } | 114 | } |
115 | 115 | ||
116 | /// <summary> | 116 | /// <summary> |
117 | /// | 117 | /// |
118 | /// </summary> | 118 | /// </summary> |
119 | public virtual void RegisterClientPacketHandlers() | 119 | public virtual void RegisterClientPacketHandlers() |
120 | { | 120 | { |
121 | 121 | ||
122 | } | 122 | } |
123 | 123 | ||
124 | /// <summary> | 124 | /// <summary> |
125 | /// | 125 | /// |
126 | /// </summary> | 126 | /// </summary> |
127 | /// <param name="remoteEP"></param> | 127 | /// <param name="remoteEP"></param> |
128 | /// <param name="initialcirpack"></param> | 128 | /// <param name="initialcirpack"></param> |
129 | /// <param name="clientThreads"></param> | 129 | /// <param name="clientThreads"></param> |
130 | /// <param name="world"></param> | 130 | /// <param name="world"></param> |
131 | /// <param name="assetCache"></param> | 131 | /// <param name="assetCache"></param> |
132 | /// <param name="packServer"></param> | 132 | /// <param name="packServer"></param> |
133 | /// <param name="inventoryCache"></param> | 133 | /// <param name="inventoryCache"></param> |
134 | /// <param name="authenSessions"></param> | 134 | /// <param name="authenSessions"></param> |
135 | /// <returns></returns> | 135 | /// <returns></returns> |
136 | protected virtual ClientView CreateNewClient(EndPoint remoteEP, UseCircuitCodePacket initialcirpack, Dictionary<uint, ClientView> clientThreads, IWorld world, AssetCache assetCache, PacketServer packServer, InventoryCache inventoryCache, AuthenticateSessionsBase authenSessions) | 136 | protected virtual ClientView CreateNewClient(EndPoint remoteEP, UseCircuitCodePacket initialcirpack, Dictionary<uint, ClientView> clientThreads, IWorld world, AssetCache assetCache, PacketServer packServer, InventoryCache inventoryCache, AuthenticateSessionsBase authenSessions) |
137 | { | 137 | { |
138 | return new ClientView(remoteEP, initialcirpack, clientThreads, world, assetCache, packServer, inventoryCache, authenSessions ); | 138 | return new ClientView(remoteEP, initialcirpack, clientThreads, world, assetCache, packServer, inventoryCache, authenSessions ); |
139 | } | 139 | } |
140 | 140 | ||
141 | /// <summary> | 141 | /// <summary> |
142 | /// | 142 | /// |
143 | /// </summary> | 143 | /// </summary> |
144 | /// <param name="epSender"></param> | 144 | /// <param name="epSender"></param> |
145 | /// <param name="useCircuit"></param> | 145 | /// <param name="useCircuit"></param> |
146 | /// <param name="assetCache"></param> | 146 | /// <param name="assetCache"></param> |
147 | /// <param name="inventoryCache"></param> | 147 | /// <param name="inventoryCache"></param> |
148 | /// <param name="authenticateSessionsClass"></param> | 148 | /// <param name="authenticateSessionsClass"></param> |
149 | /// <returns></returns> | 149 | /// <returns></returns> |
150 | public virtual bool AddNewClient(EndPoint epSender, UseCircuitCodePacket useCircuit, AssetCache assetCache, InventoryCache inventoryCache, AuthenticateSessionsBase authenticateSessionsClass) | 150 | public virtual bool AddNewClient(EndPoint epSender, UseCircuitCodePacket useCircuit, AssetCache assetCache, InventoryCache inventoryCache, AuthenticateSessionsBase authenticateSessionsClass) |
151 | { | 151 | { |
152 | ClientView newuser = | 152 | ClientView newuser = |
153 | CreateNewClient(epSender, useCircuit, ClientThreads, _localWorld, assetCache, this, inventoryCache, | 153 | CreateNewClient(epSender, useCircuit, ClientThreads, _localWorld, assetCache, this, inventoryCache, |
154 | authenticateSessionsClass); | 154 | authenticateSessionsClass); |
155 | 155 | ||
156 | this.ClientThreads.Add(useCircuit.CircuitCode.Code, newuser); | 156 | this.ClientThreads.Add(useCircuit.CircuitCode.Code, newuser); |
157 | this.m_clientManager.Add(useCircuit.CircuitCode.Code, (IClientAPI)newuser); | 157 | this.m_clientManager.Add(useCircuit.CircuitCode.Code, (IClientAPI)newuser); |
158 | 158 | ||
159 | return true; | 159 | return true; |
160 | } | 160 | } |
161 | 161 | ||
162 | /// <summary> | 162 | /// <summary> |
163 | /// | 163 | /// |
164 | /// </summary> | 164 | /// </summary> |
165 | /// <param name="buffer"></param> | 165 | /// <param name="buffer"></param> |
166 | /// <param name="size"></param> | 166 | /// <param name="size"></param> |
167 | /// <param name="flags"></param> | 167 | /// <param name="flags"></param> |
168 | /// <param name="circuitcode"></param> | 168 | /// <param name="circuitcode"></param> |
169 | public virtual void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode) | 169 | public virtual void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode) |
170 | { | 170 | { |
171 | this._networkHandler.SendPacketTo(buffer, size, flags, circuitcode); | 171 | this._networkHandler.SendPacketTo(buffer, size, flags, circuitcode); |
172 | } | 172 | } |
173 | 173 | ||
174 | /// <summary> | 174 | /// <summary> |
175 | /// | 175 | /// |
176 | /// </summary> | 176 | /// </summary> |
177 | /// <param name="circuitcode"></param> | 177 | /// <param name="circuitcode"></param> |
178 | public virtual void RemoveClientCircuit(uint circuitcode) | 178 | public virtual void RemoveClientCircuit(uint circuitcode) |
179 | { | 179 | { |
180 | this._networkHandler.RemoveClientCircuit(circuitcode); | 180 | this._networkHandler.RemoveClientCircuit(circuitcode); |
181 | this.m_clientManager.Remove(circuitcode); | 181 | this.m_clientManager.Remove(circuitcode); |
182 | } | 182 | } |
183 | } | 183 | } |
184 | } | 184 | } |
diff --git a/OpenSim/Region/ClientStack/RegionApplicationBase.cs b/OpenSim/Region/ClientStack/RegionApplicationBase.cs index 7ae74f8..ed7df17 100644 --- a/OpenSim/Region/ClientStack/RegionApplicationBase.cs +++ b/OpenSim/Region/ClientStack/RegionApplicationBase.cs | |||
@@ -1,118 +1,118 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | 2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
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 | */ |
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Net; | 30 | using System.Net; |
31 | using OpenSim.Assets; | 31 | using OpenSim.Assets; |
32 | using OpenSim.Framework; | 32 | using OpenSim.Framework; |
33 | using OpenSim.Framework.Console; | 33 | using OpenSim.Framework.Console; |
34 | using OpenSim.Framework.Interfaces; | 34 | using OpenSim.Framework.Interfaces; |
35 | using OpenSim.Framework.Servers; | 35 | using OpenSim.Framework.Servers; |
36 | using OpenSim.Framework.Types; | 36 | using OpenSim.Framework.Types; |
37 | using OpenSim.Physics.Manager; | 37 | using OpenSim.Physics.Manager; |
38 | using OpenSim.Region.Caches; | 38 | using OpenSim.Region.Caches; |
39 | using OpenSim.Region.Environment; | 39 | using OpenSim.Region.Environment; |
40 | 40 | ||
41 | namespace OpenSim.Region.ClientStack | 41 | namespace OpenSim.Region.ClientStack |
42 | { | 42 | { |
43 | public class RegionApplicationBase | 43 | public class RegionApplicationBase |
44 | { | 44 | { |
45 | protected IGenericConfig localConfig; | 45 | protected IGenericConfig localConfig; |
46 | protected PhysicsManager physManager; | 46 | protected PhysicsManager physManager; |
47 | protected AssetCache AssetCache; | 47 | protected AssetCache AssetCache; |
48 | protected InventoryCache InventoryCache; | 48 | protected InventoryCache InventoryCache; |
49 | protected Dictionary<EndPoint, uint> clientCircuits = new Dictionary<EndPoint, uint>(); | 49 | protected Dictionary<EndPoint, uint> clientCircuits = new Dictionary<EndPoint, uint>(); |
50 | protected DateTime startuptime; | 50 | protected DateTime startuptime; |
51 | protected NetworkServersInfo serversData; | 51 | protected NetworkServersInfo serversData; |
52 | 52 | ||
53 | public string m_physicsEngine; | 53 | public string m_physicsEngine; |
54 | public bool m_sandbox = false; | 54 | public bool m_sandbox = false; |
55 | public bool m_loginserver; | 55 | public bool m_loginserver; |
56 | public bool user_accounts = false; | 56 | public bool user_accounts = false; |
57 | public bool gridLocalAsset = false; | 57 | public bool gridLocalAsset = false; |
58 | protected bool configFileSetup = false; | 58 | protected bool configFileSetup = false; |
59 | public string m_config; | 59 | public string m_config; |
60 | 60 | ||
61 | protected List<UDPServer> m_udpServer = new List<UDPServer>(); | 61 | protected List<UDPServer> m_udpServer = new List<UDPServer>(); |
62 | protected List<RegionInfo> regionData = new List<RegionInfo>(); | 62 | protected List<RegionInfo> regionData = new List<RegionInfo>(); |
63 | protected List<IWorld> m_localWorld = new List<IWorld>(); | 63 | protected List<IWorld> m_localWorld = new List<IWorld>(); |
64 | protected BaseHttpServer httpServer; | 64 | protected BaseHttpServer httpServer; |
65 | protected List<AuthenticateSessionsBase> AuthenticateSessionsHandler = new List<AuthenticateSessionsBase>(); | 65 | protected List<AuthenticateSessionsBase> AuthenticateSessionsHandler = new List<AuthenticateSessionsBase>(); |
66 | 66 | ||
67 | protected LogBase m_log; | 67 | protected LogBase m_log; |
68 | 68 | ||
69 | public RegionApplicationBase() | 69 | public RegionApplicationBase() |
70 | { | 70 | { |
71 | 71 | ||
72 | } | 72 | } |
73 | 73 | ||
74 | public RegionApplicationBase(bool sandBoxMode, bool startLoginServer, string physicsEngine, bool useConfigFile, bool silent, string configFile) | 74 | public RegionApplicationBase(bool sandBoxMode, bool startLoginServer, string physicsEngine, bool useConfigFile, bool silent, string configFile) |
75 | { | 75 | { |
76 | this.configFileSetup = useConfigFile; | 76 | this.configFileSetup = useConfigFile; |
77 | m_sandbox = sandBoxMode; | 77 | m_sandbox = sandBoxMode; |
78 | m_loginserver = startLoginServer; | 78 | m_loginserver = startLoginServer; |
79 | m_physicsEngine = physicsEngine; | 79 | m_physicsEngine = physicsEngine; |
80 | m_config = configFile; | 80 | m_config = configFile; |
81 | } | 81 | } |
82 | 82 | ||
83 | /*protected World m_localWorld; | 83 | /*protected World m_localWorld; |
84 | public World LocalWorld | 84 | public World LocalWorld |
85 | { | 85 | { |
86 | get { return m_localWorld; } | 86 | get { return m_localWorld; } |
87 | }*/ | 87 | }*/ |
88 | 88 | ||
89 | /// <summary> | 89 | /// <summary> |
90 | /// Performs initialisation of the world, such as loading configuration from disk. | 90 | /// Performs initialisation of the world, such as loading configuration from disk. |
91 | /// </summary> | 91 | /// </summary> |
92 | public virtual void StartUp() | 92 | public virtual void StartUp() |
93 | { | 93 | { |
94 | } | 94 | } |
95 | 95 | ||
96 | protected virtual void SetupLocalGridServers() | 96 | protected virtual void SetupLocalGridServers() |
97 | { | 97 | { |
98 | } | 98 | } |
99 | 99 | ||
100 | protected virtual void SetupRemoteGridServers() | 100 | protected virtual void SetupRemoteGridServers() |
101 | { | 101 | { |
102 | 102 | ||
103 | } | 103 | } |
104 | 104 | ||
105 | protected virtual void SetupScene() | 105 | protected virtual void SetupScene() |
106 | { | 106 | { |
107 | } | 107 | } |
108 | 108 | ||
109 | protected virtual void SetupHttpListener() | 109 | protected virtual void SetupHttpListener() |
110 | { | 110 | { |
111 | } | 111 | } |
112 | 112 | ||
113 | protected virtual void ConnectToRemoteGridServer() | 113 | protected virtual void ConnectToRemoteGridServer() |
114 | { | 114 | { |
115 | 115 | ||
116 | } | 116 | } |
117 | } | 117 | } |
118 | } | 118 | } |
diff --git a/OpenSim/Region/ClientStack/UDPServer.cs b/OpenSim/Region/ClientStack/UDPServer.cs index 6eea524..781f96a 100644 --- a/OpenSim/Region/ClientStack/UDPServer.cs +++ b/OpenSim/Region/ClientStack/UDPServer.cs | |||
@@ -1,196 +1,196 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | 2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
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 | */ |
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Net; | 30 | using System.Net; |
31 | using System.Net.Sockets; | 31 | using System.Net.Sockets; |
32 | using libsecondlife.Packets; | 32 | using libsecondlife.Packets; |
33 | using OpenSim.Assets; | 33 | using OpenSim.Assets; |
34 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
35 | using OpenSim.Framework.Console; | 35 | using OpenSim.Framework.Console; |
36 | using OpenSim.Framework.Interfaces; | 36 | using OpenSim.Framework.Interfaces; |
37 | using OpenSim.Region.Caches; | 37 | using OpenSim.Region.Caches; |
38 | 38 | ||
39 | namespace OpenSim.Region.ClientStack | 39 | namespace OpenSim.Region.ClientStack |
40 | { | 40 | { |
41 | 41 | ||
42 | public class UDPServer : ClientStackNetworkHandler | 42 | public class UDPServer : ClientStackNetworkHandler |
43 | { | 43 | { |
44 | protected Dictionary<EndPoint, uint> clientCircuits = new Dictionary<EndPoint, uint>(); | 44 | protected Dictionary<EndPoint, uint> clientCircuits = new Dictionary<EndPoint, uint>(); |
45 | public Socket Server; | 45 | public Socket Server; |
46 | protected IPEndPoint ServerIncoming; | 46 | protected IPEndPoint ServerIncoming; |
47 | protected byte[] RecvBuffer = new byte[4096]; | 47 | protected byte[] RecvBuffer = new byte[4096]; |
48 | protected byte[] ZeroBuffer = new byte[8192]; | 48 | protected byte[] ZeroBuffer = new byte[8192]; |
49 | protected IPEndPoint ipeSender; | 49 | protected IPEndPoint ipeSender; |
50 | protected EndPoint epSender; | 50 | protected EndPoint epSender; |
51 | protected AsyncCallback ReceivedData; | 51 | protected AsyncCallback ReceivedData; |
52 | protected PacketServer _packetServer; | 52 | protected PacketServer _packetServer; |
53 | 53 | ||
54 | protected int listenPort; | 54 | protected int listenPort; |
55 | protected IWorld m_localWorld; | 55 | protected IWorld m_localWorld; |
56 | protected AssetCache m_assetCache; | 56 | protected AssetCache m_assetCache; |
57 | protected InventoryCache m_inventoryCache; | 57 | protected InventoryCache m_inventoryCache; |
58 | protected LogBase m_log; | 58 | protected LogBase m_log; |
59 | protected AuthenticateSessionsBase m_authenticateSessionsClass; | 59 | protected AuthenticateSessionsBase m_authenticateSessionsClass; |
60 | 60 | ||
61 | public PacketServer PacketServer | 61 | public PacketServer PacketServer |
62 | { | 62 | { |
63 | get | 63 | get |
64 | { | 64 | { |
65 | return _packetServer; | 65 | return _packetServer; |
66 | } | 66 | } |
67 | set | 67 | set |
68 | { | 68 | { |
69 | _packetServer = value; | 69 | _packetServer = value; |
70 | } | 70 | } |
71 | } | 71 | } |
72 | 72 | ||
73 | public IWorld LocalWorld | 73 | public IWorld LocalWorld |
74 | { | 74 | { |
75 | set | 75 | set |
76 | { | 76 | { |
77 | this.m_localWorld = value; | 77 | this.m_localWorld = value; |
78 | this._packetServer.LocalWorld = this.m_localWorld; | 78 | this._packetServer.LocalWorld = this.m_localWorld; |
79 | } | 79 | } |
80 | } | 80 | } |
81 | 81 | ||
82 | public UDPServer() | 82 | public UDPServer() |
83 | { | 83 | { |
84 | } | 84 | } |
85 | 85 | ||
86 | public UDPServer(int port, AssetCache assetCache, InventoryCache inventoryCache, LogBase console, AuthenticateSessionsBase authenticateClass) | 86 | public UDPServer(int port, AssetCache assetCache, InventoryCache inventoryCache, LogBase console, AuthenticateSessionsBase authenticateClass) |
87 | { | 87 | { |
88 | listenPort = port; | 88 | listenPort = port; |
89 | this.m_assetCache = assetCache; | 89 | this.m_assetCache = assetCache; |
90 | this.m_inventoryCache = inventoryCache; | 90 | this.m_inventoryCache = inventoryCache; |
91 | this.m_log = console; | 91 | this.m_log = console; |
92 | this.m_authenticateSessionsClass = authenticateClass; | 92 | this.m_authenticateSessionsClass = authenticateClass; |
93 | this.CreatePacketServer(); | 93 | this.CreatePacketServer(); |
94 | 94 | ||
95 | } | 95 | } |
96 | 96 | ||
97 | protected virtual void CreatePacketServer() | 97 | protected virtual void CreatePacketServer() |
98 | { | 98 | { |
99 | PacketServer packetServer = new PacketServer(this); | 99 | PacketServer packetServer = new PacketServer(this); |
100 | } | 100 | } |
101 | 101 | ||
102 | protected virtual void OnReceivedData(IAsyncResult result) | 102 | protected virtual void OnReceivedData(IAsyncResult result) |
103 | { | 103 | { |
104 | ipeSender = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0); | 104 | ipeSender = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0); |
105 | epSender = (EndPoint)ipeSender; | 105 | epSender = (EndPoint)ipeSender; |
106 | Packet packet = null; | 106 | Packet packet = null; |
107 | int numBytes = Server.EndReceiveFrom(result, ref epSender); | 107 | int numBytes = Server.EndReceiveFrom(result, ref epSender); |
108 | int packetEnd = numBytes - 1; | 108 | int packetEnd = numBytes - 1; |
109 | 109 | ||
110 | packet = Packet.BuildPacket(RecvBuffer, ref packetEnd, ZeroBuffer); | 110 | packet = Packet.BuildPacket(RecvBuffer, ref packetEnd, ZeroBuffer); |
111 | 111 | ||
112 | // do we already have a circuit for this endpoint | 112 | // do we already have a circuit for this endpoint |
113 | if (this.clientCircuits.ContainsKey(epSender)) | 113 | if (this.clientCircuits.ContainsKey(epSender)) |
114 | { | 114 | { |
115 | //if so then send packet to the packetserver | 115 | //if so then send packet to the packetserver |
116 | this._packetServer.ClientInPacket(this.clientCircuits[epSender], packet); | 116 | this._packetServer.ClientInPacket(this.clientCircuits[epSender], packet); |
117 | } | 117 | } |
118 | else if (packet.Type == PacketType.UseCircuitCode) | 118 | else if (packet.Type == PacketType.UseCircuitCode) |
119 | { | 119 | { |
120 | // new client | 120 | // new client |
121 | this.AddNewClient(packet); | 121 | this.AddNewClient(packet); |
122 | } | 122 | } |
123 | else | 123 | else |
124 | { // invalid client | 124 | { // invalid client |
125 | m_log.Warn("UDPServer.cs:OnReceivedData() - WARNING: Got a packet from an invalid client - " + epSender.ToString()); | 125 | m_log.Warn("UDPServer.cs:OnReceivedData() - WARNING: Got a packet from an invalid client - " + epSender.ToString()); |
126 | } | 126 | } |
127 | 127 | ||
128 | Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null); | 128 | Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null); |
129 | } | 129 | } |
130 | 130 | ||
131 | protected virtual void AddNewClient(Packet packet) | 131 | protected virtual void AddNewClient(Packet packet) |
132 | { | 132 | { |
133 | UseCircuitCodePacket useCircuit = (UseCircuitCodePacket)packet; | 133 | UseCircuitCodePacket useCircuit = (UseCircuitCodePacket)packet; |
134 | this.clientCircuits.Add(epSender, useCircuit.CircuitCode.Code); | 134 | this.clientCircuits.Add(epSender, useCircuit.CircuitCode.Code); |
135 | 135 | ||
136 | this.PacketServer.AddNewClient(epSender, useCircuit, m_assetCache, m_inventoryCache, m_authenticateSessionsClass); | 136 | this.PacketServer.AddNewClient(epSender, useCircuit, m_assetCache, m_inventoryCache, m_authenticateSessionsClass); |
137 | } | 137 | } |
138 | 138 | ||
139 | public void ServerListener() | 139 | public void ServerListener() |
140 | { | 140 | { |
141 | m_log.Status("UDPServer.cs:ServerListener() - Opening UDP socket on " + listenPort); | 141 | m_log.Status("UDPServer.cs:ServerListener() - Opening UDP socket on " + listenPort); |
142 | 142 | ||
143 | ServerIncoming = new IPEndPoint(IPAddress.Parse("0.0.0.0"), listenPort); | 143 | ServerIncoming = new IPEndPoint(IPAddress.Parse("0.0.0.0"), listenPort); |
144 | Server = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); | 144 | Server = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); |
145 | Server.Bind(ServerIncoming); | 145 | Server.Bind(ServerIncoming); |
146 | 146 | ||
147 | m_log.Verbose("UDPServer.cs:ServerListener() - UDP socket bound, getting ready to listen"); | 147 | m_log.Verbose("UDPServer.cs:ServerListener() - UDP socket bound, getting ready to listen"); |
148 | 148 | ||
149 | ipeSender = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0); | 149 | ipeSender = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0); |
150 | epSender = (EndPoint)ipeSender; | 150 | epSender = (EndPoint)ipeSender; |
151 | ReceivedData = new AsyncCallback(this.OnReceivedData); | 151 | ReceivedData = new AsyncCallback(this.OnReceivedData); |
152 | Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null); | 152 | Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null); |
153 | 153 | ||
154 | m_log.Verbose("UDPServer.cs:ServerListener() - Listening..."); | 154 | m_log.Verbose("UDPServer.cs:ServerListener() - Listening..."); |
155 | 155 | ||
156 | } | 156 | } |
157 | 157 | ||
158 | public virtual void RegisterPacketServer(PacketServer server) | 158 | public virtual void RegisterPacketServer(PacketServer server) |
159 | { | 159 | { |
160 | this._packetServer = server; | 160 | this._packetServer = server; |
161 | } | 161 | } |
162 | 162 | ||
163 | public virtual void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode)//EndPoint packetSender) | 163 | public virtual void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode)//EndPoint packetSender) |
164 | { | 164 | { |
165 | // find the endpoint for this circuit | 165 | // find the endpoint for this circuit |
166 | EndPoint sendto = null; | 166 | EndPoint sendto = null; |
167 | foreach (KeyValuePair<EndPoint, uint> p in this.clientCircuits) | 167 | foreach (KeyValuePair<EndPoint, uint> p in this.clientCircuits) |
168 | { | 168 | { |
169 | if (p.Value == circuitcode) | 169 | if (p.Value == circuitcode) |
170 | { | 170 | { |
171 | sendto = p.Key; | 171 | sendto = p.Key; |
172 | break; | 172 | break; |
173 | } | 173 | } |
174 | } | 174 | } |
175 | if (sendto != null) | 175 | if (sendto != null) |
176 | { | 176 | { |
177 | //we found the endpoint so send the packet to it | 177 | //we found the endpoint so send the packet to it |
178 | this.Server.SendTo(buffer, size, flags, sendto); | 178 | this.Server.SendTo(buffer, size, flags, sendto); |
179 | } | 179 | } |
180 | } | 180 | } |
181 | 181 | ||
182 | public virtual void RemoveClientCircuit(uint circuitcode) | 182 | public virtual void RemoveClientCircuit(uint circuitcode) |
183 | { | 183 | { |
184 | foreach (KeyValuePair<EndPoint, uint> p in this.clientCircuits) | 184 | foreach (KeyValuePair<EndPoint, uint> p in this.clientCircuits) |
185 | { | 185 | { |
186 | if (p.Value == circuitcode) | 186 | if (p.Value == circuitcode) |
187 | { | 187 | { |
188 | this.clientCircuits.Remove(p.Key); | 188 | this.clientCircuits.Remove(p.Key); |
189 | break; | 189 | break; |
190 | } | 190 | } |
191 | } | 191 | } |
192 | } | 192 | } |
193 | 193 | ||
194 | 194 | ||
195 | } | 195 | } |
196 | } \ No newline at end of file | 196 | } \ No newline at end of file |