diff options
Diffstat (limited to 'OpenSim.RegionServer/world/World.PacketHandlers.cs')
-rw-r--r-- | OpenSim.RegionServer/world/World.PacketHandlers.cs | 257 |
1 files changed, 0 insertions, 257 deletions
diff --git a/OpenSim.RegionServer/world/World.PacketHandlers.cs b/OpenSim.RegionServer/world/World.PacketHandlers.cs deleted file mode 100644 index 7d74cb7..0000000 --- a/OpenSim.RegionServer/world/World.PacketHandlers.cs +++ /dev/null | |||
@@ -1,257 +0,0 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Text; | ||
4 | using libsecondlife; | ||
5 | using libsecondlife.Packets; | ||
6 | using OpenSim.Physics.Manager; | ||
7 | using OpenSim.Framework.Interfaces; | ||
8 | using OpenSim.Framework.Types; | ||
9 | using OpenSim.Framework.Terrain; | ||
10 | using OpenSim.Framework.Inventory; | ||
11 | using OpenSim.Framework.Utilities; | ||
12 | using OpenSim.Assets; | ||
13 | |||
14 | namespace OpenSim.world | ||
15 | { | ||
16 | public partial class World | ||
17 | { | ||
18 | public void ModifyTerrain(byte Action, float North, float West) | ||
19 | { | ||
20 | switch (Action) | ||
21 | { | ||
22 | case 1: | ||
23 | // raise terrain | ||
24 | Terrain.raise(North, West, 10.0, 0.001); | ||
25 | RegenerateTerrain(true, (int)North, (int)West); | ||
26 | break; | ||
27 | case 2: | ||
28 | //lower terrain | ||
29 | Terrain.lower(North, West, 10.0, 0.001); | ||
30 | RegenerateTerrain(true, (int)North, (int)West); | ||
31 | break; | ||
32 | } | ||
33 | return; | ||
34 | } | ||
35 | |||
36 | public void SimChat(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID) | ||
37 | { | ||
38 | foreach (ClientView client in m_clientThreads.Values) | ||
39 | { | ||
40 | // int dis = Util.fast_distance2d((int)(client.ClientAvatar.Pos.X - simClient.ClientAvatar.Pos.X), (int)(client.ClientAvatar.Pos.Y - simClient.ClientAvatar.Pos.Y)); | ||
41 | int dis = (int)client.ClientAvatar.Pos.GetDistanceTo(fromPos); | ||
42 | |||
43 | switch (type) | ||
44 | { | ||
45 | case 0: // Whisper | ||
46 | if ((dis < 10) && (dis > -10)) | ||
47 | { | ||
48 | //should change so the message is sent through the avatar rather than direct to the ClientView | ||
49 | client.SendChatMessage(message, type, fromPos, fromName, fromAgentID); | ||
50 | } | ||
51 | break; | ||
52 | case 1: // Say | ||
53 | if ((dis < 30) && (dis > -30)) | ||
54 | { | ||
55 | client.SendChatMessage(message, type, fromPos, fromName, fromAgentID); | ||
56 | } | ||
57 | break; | ||
58 | case 2: // Shout | ||
59 | if ((dis < 100) && (dis > -100)) | ||
60 | { | ||
61 | client.SendChatMessage(message, type, fromPos, fromName, fromAgentID); | ||
62 | } | ||
63 | break; | ||
64 | |||
65 | case 0xff: // Broadcast | ||
66 | client.SendChatMessage(message, type, fromPos, fromName, fromAgentID); | ||
67 | break; | ||
68 | } | ||
69 | |||
70 | } | ||
71 | } | ||
72 | |||
73 | public void RezObject(AssetBase primasset, LLVector3 pos) | ||
74 | { | ||
75 | PrimData primd = new PrimData(primasset.Data); | ||
76 | Primitive nPrim = new Primitive(m_clientThreads, m_regionHandle, this); | ||
77 | nPrim.CreateFromStorage(primd, pos, this._primCount, true); | ||
78 | this.Entities.Add(nPrim.uuid, nPrim); | ||
79 | this._primCount++; | ||
80 | } | ||
81 | |||
82 | public bool DeRezObject(ClientView simClient, Packet packet) | ||
83 | { | ||
84 | DeRezObjectPacket DeRezPacket = (DeRezObjectPacket)packet; | ||
85 | |||
86 | //Needs to delete object from physics at a later date | ||
87 | if (DeRezPacket.AgentBlock.DestinationID == LLUUID.Zero) | ||
88 | { | ||
89 | //currently following code not used (or don't know of any case of destination being zero | ||
90 | libsecondlife.LLUUID[] DeRezEnts; | ||
91 | DeRezEnts = new libsecondlife.LLUUID[DeRezPacket.ObjectData.Length]; | ||
92 | int i = 0; | ||
93 | foreach (DeRezObjectPacket.ObjectDataBlock Data in DeRezPacket.ObjectData) | ||
94 | { | ||
95 | |||
96 | //OpenSim.Framework.Console.MainConsole.Instance.WriteLine("LocalID:" + Data.ObjectLocalID.ToString()); | ||
97 | foreach (Entity ent in this.Entities.Values) | ||
98 | { | ||
99 | if (ent.localid == Data.ObjectLocalID) | ||
100 | { | ||
101 | DeRezEnts[i++] = ent.uuid; | ||
102 | this.localStorage.RemovePrim(ent.uuid); | ||
103 | KillObjectPacket kill = new KillObjectPacket(); | ||
104 | kill.ObjectData = new KillObjectPacket.ObjectDataBlock[1]; | ||
105 | kill.ObjectData[0] = new KillObjectPacket.ObjectDataBlock(); | ||
106 | kill.ObjectData[0].ID = ent.localid; | ||
107 | foreach (ClientView client in m_clientThreads.Values) | ||
108 | { | ||
109 | client.OutPacket(kill); | ||
110 | } | ||
111 | //Uncommenting this means an old UUID will be re-used, thus crashing the asset server | ||
112 | //Uncomment when prim/object UUIDs are random or such | ||
113 | //2007-03-22 - Randomskk | ||
114 | //this._primCount--; | ||
115 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.VERBOSE, "Deleted UUID " + ent.uuid); | ||
116 | } | ||
117 | } | ||
118 | } | ||
119 | foreach (libsecondlife.LLUUID uuid in DeRezEnts) | ||
120 | { | ||
121 | lock (Entities) | ||
122 | { | ||
123 | Entities.Remove(uuid); | ||
124 | } | ||
125 | } | ||
126 | } | ||
127 | else | ||
128 | { | ||
129 | foreach (DeRezObjectPacket.ObjectDataBlock Data in DeRezPacket.ObjectData) | ||
130 | { | ||
131 | Entity selectedEnt = null; | ||
132 | //OpenSim.Framework.Console.MainConsole.Instance.WriteLine("LocalID:" + Data.ObjectLocalID.ToString()); | ||
133 | foreach (Entity ent in this.Entities.Values) | ||
134 | { | ||
135 | if (ent.localid == Data.ObjectLocalID) | ||
136 | { | ||
137 | AssetBase primAsset = new AssetBase(); | ||
138 | primAsset.FullID = LLUUID.Random();//DeRezPacket.AgentBlock.TransactionID.Combine(LLUUID.Zero); //should be combining with securesessionid | ||
139 | primAsset.InvType = 6; | ||
140 | primAsset.Type = 6; | ||
141 | primAsset.Name = "Prim"; | ||
142 | primAsset.Description = ""; | ||
143 | primAsset.Data = ((Primitive)ent).GetByteArray(); | ||
144 | this._assetCache.AddAsset(primAsset); | ||
145 | this._inventoryCache.AddNewInventoryItem(simClient, DeRezPacket.AgentBlock.DestinationID, primAsset); | ||
146 | selectedEnt = ent; | ||
147 | break; | ||
148 | } | ||
149 | } | ||
150 | if (selectedEnt != null) | ||
151 | { | ||
152 | this.localStorage.RemovePrim(selectedEnt.uuid); | ||
153 | KillObjectPacket kill = new KillObjectPacket(); | ||
154 | kill.ObjectData = new KillObjectPacket.ObjectDataBlock[1]; | ||
155 | kill.ObjectData[0] = new KillObjectPacket.ObjectDataBlock(); | ||
156 | kill.ObjectData[0].ID = selectedEnt.localid; | ||
157 | foreach (ClientView client in m_clientThreads.Values) | ||
158 | { | ||
159 | client.OutPacket(kill); | ||
160 | } | ||
161 | lock (Entities) | ||
162 | { | ||
163 | Entities.Remove(selectedEnt.uuid); | ||
164 | } | ||
165 | } | ||
166 | } | ||
167 | } | ||
168 | return true; | ||
169 | } | ||
170 | |||
171 | public void SendAvatarsToClient(ClientView RemoteClient) | ||
172 | { | ||
173 | foreach (ClientView client in m_clientThreads.Values) | ||
174 | { | ||
175 | if (client.AgentID != RemoteClient.AgentID) | ||
176 | { | ||
177 | // ObjectUpdatePacket objupdate = client.ClientAvatar.CreateUpdatePacket(); | ||
178 | // RemoteClient.OutPacket(objupdate); | ||
179 | client.ClientAvatar.SendUpdateToOtherClient(RemoteClient.ClientAvatar); | ||
180 | client.ClientAvatar.SendAppearanceToOtherAgent(RemoteClient.ClientAvatar); | ||
181 | } | ||
182 | } | ||
183 | } | ||
184 | |||
185 | /* | ||
186 | public void RequestMapBlock(ClientView simClient, int minX, int minY, int maxX, int maxY) | ||
187 | { | ||
188 | System.Text.Encoding _enc = System.Text.Encoding.ASCII; | ||
189 | if (((m_regInfo.RegionLocX > minX) && (m_regInfo.RegionLocX < maxX)) && ((m_regInfo.RegionLocY > minY) && (m_regInfo.RegionLocY < maxY))) | ||
190 | { | ||
191 | MapBlockReplyPacket mapReply = new MapBlockReplyPacket(); | ||
192 | mapReply.AgentData.AgentID = simClient.AgentID; | ||
193 | mapReply.AgentData.Flags = 0; | ||
194 | mapReply.Data = new MapBlockReplyPacket.DataBlock[1]; | ||
195 | mapReply.Data[0] = new MapBlockReplyPacket.DataBlock(); | ||
196 | mapReply.Data[0].MapImageID = new LLUUID("00000000-0000-0000-9999-000000000007"); | ||
197 | mapReply.Data[0].X = (ushort)m_regInfo.RegionLocX; | ||
198 | mapReply.Data[0].Y = (ushort)m_regInfo.RegionLocY; | ||
199 | mapReply.Data[0].WaterHeight = (byte)m_regInfo.RegionWaterHeight; | ||
200 | mapReply.Data[0].Name = _enc.GetBytes(this.m_regionName); | ||
201 | mapReply.Data[0].RegionFlags = 72458694; | ||
202 | mapReply.Data[0].Access = 13; | ||
203 | mapReply.Data[0].Agents = 1; //should send number of clients connected | ||
204 | simClient.OutPacket(mapReply); | ||
205 | } | ||
206 | } | ||
207 | public bool RezObjectHandler(ClientView simClient, Packet packet) | ||
208 | { | ||
209 | RezObjectPacket rezPacket = (RezObjectPacket)packet; | ||
210 | AgentInventory inven = this._inventoryCache.GetAgentsInventory(simClient.AgentID); | ||
211 | if (inven != null) | ||
212 | { | ||
213 | if (inven.InventoryItems.ContainsKey(rezPacket.InventoryData.ItemID)) | ||
214 | { | ||
215 | AssetBase asset = this._assetCache.GetAsset(inven.InventoryItems[rezPacket.InventoryData.ItemID].AssetID); | ||
216 | if (asset != null) | ||
217 | { | ||
218 | PrimData primd = new PrimData(asset.Data); | ||
219 | Primitive nPrim = new Primitive(m_clientThreads, m_regionHandle, this); | ||
220 | nPrim.CreateFromStorage(primd, rezPacket.RezData.RayEnd, this._primCount, true); | ||
221 | this.Entities.Add(nPrim.uuid, nPrim); | ||
222 | this._primCount++; | ||
223 | this._inventoryCache.DeleteInventoryItem(simClient, rezPacket.InventoryData.ItemID); | ||
224 | } | ||
225 | } | ||
226 | } | ||
227 | return true; | ||
228 | } | ||
229 | public bool ModifyTerrain(ClientView simClient, Packet packet) | ||
230 | { | ||
231 | ModifyLandPacket modify = (ModifyLandPacket)packet; | ||
232 | |||
233 | switch (modify.ModifyBlock.Action) | ||
234 | { | ||
235 | case 1: | ||
236 | // raise terrain | ||
237 | if (modify.ParcelData.Length > 0) | ||
238 | { | ||
239 | Terrain.raise(modify.ParcelData[0].North, modify.ParcelData[0].West, 10.0, 0.1); | ||
240 | RegenerateTerrain(true, (int)modify.ParcelData[0].North, (int)modify.ParcelData[0].West); | ||
241 | } | ||
242 | break; | ||
243 | case 2: | ||
244 | //lower terrain | ||
245 | if (modify.ParcelData.Length > 0) | ||
246 | { | ||
247 | Terrain.lower(modify.ParcelData[0].North, modify.ParcelData[0].West, 10.0, 0.1); | ||
248 | RegenerateTerrain(true, (int)modify.ParcelData[0].North, (int)modify.ParcelData[0].West); | ||
249 | } | ||
250 | break; | ||
251 | } | ||
252 | return true; | ||
253 | } | ||
254 | */ | ||
255 | |||
256 | } | ||
257 | } | ||