aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Scenes
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Environment/Scenes')
-rw-r--r--OpenSim/Region/Environment/Scenes/Scene.Inventory.cs854
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneManager.cs474
-rw-r--r--OpenSim/Region/Environment/Scenes/Scripting/IScriptHost.cs40
-rw-r--r--OpenSim/Region/Environment/Scenes/Scripting/NullScriptHost.cs112
-rw-r--r--OpenSim/Region/Environment/Scenes/Scripting/ScriptEngineInterface.cs86
-rw-r--r--OpenSim/Region/Environment/Scenes/Scripting/ScriptEngineLoader.cs248
6 files changed, 907 insertions, 907 deletions
diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
index 70b34cf..a259dd0 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
@@ -1,427 +1,427 @@
1using System; 1using System;
2using System.IO; 2using System.IO;
3using System.Collections.Generic; 3using System.Collections.Generic;
4using libsecondlife; 4using libsecondlife;
5using libsecondlife.Packets; 5using libsecondlife.Packets;
6using OpenSim.Framework.Interfaces; 6using OpenSim.Framework.Interfaces;
7using OpenSim.Framework.Types; 7using OpenSim.Framework.Types;
8using OpenSim.Framework.Communications.Caches; 8using OpenSim.Framework.Communications.Caches;
9using OpenSim.Framework.Data; 9using OpenSim.Framework.Data;
10using OpenSim.Framework.Utilities; 10using OpenSim.Framework.Utilities;
11using OpenSim.Region.Physics.Manager; 11using OpenSim.Region.Physics.Manager;
12 12
13namespace OpenSim.Region.Environment.Scenes 13namespace OpenSim.Region.Environment.Scenes
14{ 14{
15 public partial class Scene 15 public partial class Scene
16 { 16 {
17 //split these method into this partial as a lot of these (hopefully) are only temporary and won't be needed once Caps is more complete 17 //split these method into this partial as a lot of these (hopefully) are only temporary and won't be needed once Caps is more complete
18 // or at least some of they can be moved somewhere else 18 // or at least some of they can be moved somewhere else
19 19
20 public void AddInventoryItem(LLUUID userID, InventoryItemBase item) 20 public void AddInventoryItem(LLUUID userID, InventoryItemBase item)
21 { 21 {
22 if (this.Avatars.ContainsKey(userID)) 22 if (this.Avatars.ContainsKey(userID))
23 { 23 {
24 this.AddInventoryItem(this.Avatars[userID].ControllingClient, item); 24 this.AddInventoryItem(this.Avatars[userID].ControllingClient, item);
25 } 25 }
26 } 26 }
27 27
28 public void AddInventoryItem(IClientAPI remoteClient, InventoryItemBase item) 28 public void AddInventoryItem(IClientAPI remoteClient, InventoryItemBase item)
29 { 29 {
30 CachedUserInfo userInfo = commsManager.UserProfiles.GetUserDetails(remoteClient.AgentId); 30 CachedUserInfo userInfo = commsManager.UserProfiles.GetUserDetails(remoteClient.AgentId);
31 if (userInfo != null) 31 if (userInfo != null)
32 { 32 {
33 userInfo.AddItem(remoteClient.AgentId, item); 33 userInfo.AddItem(remoteClient.AgentId, item);
34 remoteClient.SendInventoryItemUpdate(item); 34 remoteClient.SendInventoryItemUpdate(item);
35 } 35 }
36 } 36 }
37 37
38 public LLUUID CapsUpdateInventoryItemAsset(LLUUID userID, LLUUID itemID, byte[] data) 38 public LLUUID CapsUpdateInventoryItemAsset(LLUUID userID, LLUUID itemID, byte[] data)
39 { 39 {
40 if (this.Avatars.ContainsKey(userID)) 40 if (this.Avatars.ContainsKey(userID))
41 { 41 {
42 return this.CapsUpdateInventoryItemAsset(this.Avatars[userID].ControllingClient, itemID, data); 42 return this.CapsUpdateInventoryItemAsset(this.Avatars[userID].ControllingClient, itemID, data);
43 } 43 }
44 return LLUUID.Zero; 44 return LLUUID.Zero;
45 } 45 }
46 46
47 public LLUUID CapsUpdateInventoryItemAsset(IClientAPI remoteClient, LLUUID itemID, byte[] data) 47 public LLUUID CapsUpdateInventoryItemAsset(IClientAPI remoteClient, LLUUID itemID, byte[] data)
48 { 48 {
49 CachedUserInfo userInfo = commsManager.UserProfiles.GetUserDetails(remoteClient.AgentId); 49 CachedUserInfo userInfo = commsManager.UserProfiles.GetUserDetails(remoteClient.AgentId);
50 if (userInfo != null) 50 if (userInfo != null)
51 { 51 {
52 if (userInfo.RootFolder != null) 52 if (userInfo.RootFolder != null)
53 { 53 {
54 InventoryItemBase item = userInfo.RootFolder.HasItem(itemID); 54 InventoryItemBase item = userInfo.RootFolder.HasItem(itemID);
55 if (item != null) 55 if (item != null)
56 { 56 {
57 AssetBase asset; 57 AssetBase asset;
58 asset = new AssetBase(); 58 asset = new AssetBase();
59 asset.FullID = LLUUID.Random(); 59 asset.FullID = LLUUID.Random();
60 asset.Type = (sbyte)item.assetType; 60 asset.Type = (sbyte)item.assetType;
61 asset.InvType = (sbyte)item.invType; 61 asset.InvType = (sbyte)item.invType;
62 asset.Name = item.inventoryName; 62 asset.Name = item.inventoryName;
63 asset.Data = data; 63 asset.Data = data;
64 commsManager.AssetCache.AddAsset(asset); 64 commsManager.AssetCache.AddAsset(asset);
65 65
66 item.assetID = asset.FullID; 66 item.assetID = asset.FullID;
67 userInfo.UpdateItem(remoteClient.AgentId, item); 67 userInfo.UpdateItem(remoteClient.AgentId, item);
68 68
69 // remoteClient.SendInventoryItemUpdate(item); 69 // remoteClient.SendInventoryItemUpdate(item);
70 if (item.invType == 7) 70 if (item.invType == 7)
71 { 71 {
72 //do we want to know about updated note cards? 72 //do we want to know about updated note cards?
73 } 73 }
74 else if (item.invType == 10) 74 else if (item.invType == 10)
75 { 75 {
76 // do we want to know about updated scripts 76 // do we want to know about updated scripts
77 } 77 }
78 78
79 return (asset.FullID); 79 return (asset.FullID);
80 } 80 }
81 } 81 }
82 } 82 }
83 return LLUUID.Zero; 83 return LLUUID.Zero;
84 } 84 }
85 85
86 public void UDPUpdateInventoryItemAsset(IClientAPI remoteClient, LLUUID transactionID, LLUUID assetID, LLUUID itemID) 86 public void UDPUpdateInventoryItemAsset(IClientAPI remoteClient, LLUUID transactionID, LLUUID assetID, LLUUID itemID)
87 { 87 {
88 CachedUserInfo userInfo = commsManager.UserProfiles.GetUserDetails(remoteClient.AgentId); 88 CachedUserInfo userInfo = commsManager.UserProfiles.GetUserDetails(remoteClient.AgentId);
89 if (userInfo != null) 89 if (userInfo != null)
90 { 90 {
91 if (userInfo.RootFolder != null) 91 if (userInfo.RootFolder != null)
92 { 92 {
93 InventoryItemBase item = userInfo.RootFolder.HasItem(itemID); 93 InventoryItemBase item = userInfo.RootFolder.HasItem(itemID);
94 if (item != null) 94 if (item != null)
95 { 95 {
96 AgentAssetTransactions transactions = commsManager.TransactionsManager.GetUserTransActions(remoteClient.AgentId); 96 AgentAssetTransactions transactions = commsManager.TransactionsManager.GetUserTransActions(remoteClient.AgentId);
97 if (transactions != null) 97 if (transactions != null)
98 { 98 {
99 AssetBase asset = null; 99 AssetBase asset = null;
100 bool addToCache = false; 100 bool addToCache = false;
101 101
102 asset = commsManager.AssetCache.GetAsset(assetID); 102 asset = commsManager.AssetCache.GetAsset(assetID);
103 if (asset == null) 103 if (asset == null)
104 { 104 {
105 asset = transactions.GetTransactionAsset(transactionID); 105 asset = transactions.GetTransactionAsset(transactionID);
106 addToCache = true; 106 addToCache = true;
107 } 107 }
108 108
109 if (asset != null) 109 if (asset != null)
110 { 110 {
111 if (asset.FullID == assetID) 111 if (asset.FullID == assetID)
112 { 112 {
113 asset.Name = item.inventoryName; 113 asset.Name = item.inventoryName;
114 asset.Description = item.inventoryDescription; 114 asset.Description = item.inventoryDescription;
115 asset.InvType = (sbyte)item.invType; 115 asset.InvType = (sbyte)item.invType;
116 asset.Type = (sbyte)item.assetType; 116 asset.Type = (sbyte)item.assetType;
117 item.assetID = asset.FullID; 117 item.assetID = asset.FullID;
118 118
119 if (addToCache) 119 if (addToCache)
120 { 120 {
121 commsManager.AssetCache.AddAsset(asset); 121 commsManager.AssetCache.AddAsset(asset);
122 } 122 }
123 123
124 userInfo.UpdateItem(remoteClient.AgentId, item); 124 userInfo.UpdateItem(remoteClient.AgentId, item);
125 } 125 }
126 } 126 }
127 } 127 }
128 } 128 }
129 } 129 }
130 } 130 }
131 } 131 }
132 132
133 /// <summary> 133 /// <summary>
134 /// temporary method to test out creating new inventory items 134 /// temporary method to test out creating new inventory items
135 /// </summary> 135 /// </summary>
136 /// <param name="remoteClient"></param> 136 /// <param name="remoteClient"></param>
137 /// <param name="transActionID"></param> 137 /// <param name="transActionID"></param>
138 /// <param name="folderID"></param> 138 /// <param name="folderID"></param>
139 /// <param name="callbackID"></param> 139 /// <param name="callbackID"></param>
140 /// <param name="description"></param> 140 /// <param name="description"></param>
141 /// <param name="name"></param> 141 /// <param name="name"></param>
142 /// <param name="invType"></param> 142 /// <param name="invType"></param>
143 /// <param name="type"></param> 143 /// <param name="type"></param>
144 /// <param name="wearableType"></param> 144 /// <param name="wearableType"></param>
145 /// <param name="nextOwnerMask"></param> 145 /// <param name="nextOwnerMask"></param>
146 public void CreateNewInventoryItem(IClientAPI remoteClient, LLUUID transActionID, LLUUID folderID, uint callbackID, string description, string name, sbyte invType, sbyte type, byte wearableType, uint nextOwnerMask) 146 public void CreateNewInventoryItem(IClientAPI remoteClient, LLUUID transActionID, LLUUID folderID, uint callbackID, string description, string name, sbyte invType, sbyte type, byte wearableType, uint nextOwnerMask)
147 { 147 {
148 if (transActionID == LLUUID.Zero) 148 if (transActionID == LLUUID.Zero)
149 { 149 {
150 CachedUserInfo userInfo = commsManager.UserProfiles.GetUserDetails(remoteClient.AgentId); 150 CachedUserInfo userInfo = commsManager.UserProfiles.GetUserDetails(remoteClient.AgentId);
151 if (userInfo != null) 151 if (userInfo != null)
152 { 152 {
153 AssetBase asset = new AssetBase(); 153 AssetBase asset = new AssetBase();
154 asset.Name = name; 154 asset.Name = name;
155 asset.Description = description; 155 asset.Description = description;
156 asset.InvType = invType; 156 asset.InvType = invType;
157 asset.Type = type; 157 asset.Type = type;
158 asset.FullID = LLUUID.Random(); 158 asset.FullID = LLUUID.Random();
159 asset.Data = new byte[1]; 159 asset.Data = new byte[1];
160 this.commsManager.AssetCache.AddAsset(asset); 160 this.commsManager.AssetCache.AddAsset(asset);
161 161
162 InventoryItemBase item = new InventoryItemBase(); 162 InventoryItemBase item = new InventoryItemBase();
163 item.avatarID = remoteClient.AgentId; 163 item.avatarID = remoteClient.AgentId;
164 item.creatorsID = remoteClient.AgentId; 164 item.creatorsID = remoteClient.AgentId;
165 item.inventoryID = LLUUID.Random(); 165 item.inventoryID = LLUUID.Random();
166 item.assetID = asset.FullID; 166 item.assetID = asset.FullID;
167 item.inventoryDescription = description; 167 item.inventoryDescription = description;
168 item.inventoryName = name; 168 item.inventoryName = name;
169 item.assetType = invType; 169 item.assetType = invType;
170 item.invType = invType; 170 item.invType = invType;
171 item.parentFolderID = folderID; 171 item.parentFolderID = folderID;
172 item.inventoryCurrentPermissions = 2147483647; 172 item.inventoryCurrentPermissions = 2147483647;
173 item.inventoryNextPermissions = nextOwnerMask; 173 item.inventoryNextPermissions = nextOwnerMask;
174 174
175 userInfo.AddItem(remoteClient.AgentId, item); 175 userInfo.AddItem(remoteClient.AgentId, item);
176 remoteClient.SendInventoryItemUpdate(item); 176 remoteClient.SendInventoryItemUpdate(item);
177 } 177 }
178 } 178 }
179 else 179 else
180 { 180 {
181 commsManager.TransactionsManager.HandleInventoryFromTransaction(remoteClient, transActionID, folderID, callbackID, description, name, invType, type, wearableType, nextOwnerMask); 181 commsManager.TransactionsManager.HandleInventoryFromTransaction(remoteClient, transActionID, folderID, callbackID, description, name, invType, type, wearableType, nextOwnerMask);
182 //System.Console.WriteLine("request to create inventory item from transaction " + transActionID); 182 //System.Console.WriteLine("request to create inventory item from transaction " + transActionID);
183 } 183 }
184 } 184 }
185 185
186 /// <summary> 186 /// <summary>
187 /// 187 ///
188 /// </summary> 188 /// </summary>
189 /// <param name="remoteClient"></param> 189 /// <param name="remoteClient"></param>
190 /// <param name="primLocalID"></param> 190 /// <param name="primLocalID"></param>
191 public void RequestTaskInventory(IClientAPI remoteClient, uint primLocalID) 191 public void RequestTaskInventory(IClientAPI remoteClient, uint primLocalID)
192 { 192 {
193 bool hasPrim = false; 193 bool hasPrim = false;
194 foreach (EntityBase ent in Entities.Values) 194 foreach (EntityBase ent in Entities.Values)
195 { 195 {
196 if (ent is SceneObjectGroup) 196 if (ent is SceneObjectGroup)
197 { 197 {
198 hasPrim = ((SceneObjectGroup)ent).HasChildPrim(primLocalID); 198 hasPrim = ((SceneObjectGroup)ent).HasChildPrim(primLocalID);
199 if (hasPrim != false) 199 if (hasPrim != false)
200 { 200 {
201 bool fileChange = ((SceneObjectGroup)ent).GetPartInventoryFileName(remoteClient, primLocalID); 201 bool fileChange = ((SceneObjectGroup)ent).GetPartInventoryFileName(remoteClient, primLocalID);
202 if (fileChange) 202 if (fileChange)
203 { 203 {
204 if (this.XferManager != null) 204 if (this.XferManager != null)
205 { 205 {
206 ((SceneObjectGroup)ent).RequestInventoryFile(primLocalID, XferManager); 206 ((SceneObjectGroup)ent).RequestInventoryFile(primLocalID, XferManager);
207 } 207 }
208 } 208 }
209 break; 209 break;
210 } 210 }
211 } 211 }
212 } 212 }
213 } 213 }
214 214
215 public void RemoveTaskInventory(IClientAPI remoteClient, LLUUID itemID, uint localID) 215 public void RemoveTaskInventory(IClientAPI remoteClient, LLUUID itemID, uint localID)
216 { 216 {
217 bool hasPrim = false; 217 bool hasPrim = false;
218 foreach (EntityBase ent in Entities.Values) 218 foreach (EntityBase ent in Entities.Values)
219 { 219 {
220 if (ent is SceneObjectGroup) 220 if (ent is SceneObjectGroup)
221 { 221 {
222 hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID); 222 hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID);
223 if (hasPrim != false) 223 if (hasPrim != false)
224 { 224 {
225 int type = ((SceneObjectGroup)ent).RemoveInventoryItem(remoteClient, localID, itemID); 225 int type = ((SceneObjectGroup)ent).RemoveInventoryItem(remoteClient, localID, itemID);
226 ((SceneObjectGroup)ent).GetProperites(remoteClient); 226 ((SceneObjectGroup)ent).GetProperites(remoteClient);
227 if (type == 10) 227 if (type == 10)
228 { 228 {
229 this.EventManager.TriggerRemoveScript(localID, itemID); 229 this.EventManager.TriggerRemoveScript(localID, itemID);
230 } 230 }
231 } 231 }
232 } 232 }
233 } 233 }
234 } 234 }
235 235
236 public void RezScript(IClientAPI remoteClient, LLUUID itemID, uint localID) 236 public void RezScript(IClientAPI remoteClient, LLUUID itemID, uint localID)
237 { 237 {
238 CachedUserInfo userInfo = commsManager.UserProfiles.GetUserDetails(remoteClient.AgentId); 238 CachedUserInfo userInfo = commsManager.UserProfiles.GetUserDetails(remoteClient.AgentId);
239 LLUUID copyID = LLUUID.Random(); 239 LLUUID copyID = LLUUID.Random();
240 if (userInfo != null) 240 if (userInfo != null)
241 { 241 {
242 if (userInfo.RootFolder != null) 242 if (userInfo.RootFolder != null)
243 { 243 {
244 InventoryItemBase item = userInfo.RootFolder.HasItem(itemID); 244 InventoryItemBase item = userInfo.RootFolder.HasItem(itemID);
245 if (item != null) 245 if (item != null)
246 { 246 {
247 bool isTexture = false; 247 bool isTexture = false;
248 bool rezzed = false; 248 bool rezzed = false;
249 if (item.invType == 0) 249 if (item.invType == 0)
250 { 250 {
251 isTexture = true; 251 isTexture = true;
252 } 252 }
253 AssetBase rezAsset = commsManager.AssetCache.GetAsset(item.assetID, isTexture); 253 AssetBase rezAsset = commsManager.AssetCache.GetAsset(item.assetID, isTexture);
254 if (rezAsset != null) 254 if (rezAsset != null)
255 { 255 {
256 string script = Util.FieldToString(rezAsset.Data); 256 string script = Util.FieldToString(rezAsset.Data);
257 //Console.WriteLine("rez script "+script); 257 //Console.WriteLine("rez script "+script);
258 this.EventManager.TriggerRezScript(localID, copyID, script); 258 this.EventManager.TriggerRezScript(localID, copyID, script);
259 rezzed = true; 259 rezzed = true;
260 } 260 }
261 else 261 else
262 { 262 {
263 //lets try once more incase the asset cache is being slow getting the asset from server 263 //lets try once more incase the asset cache is being slow getting the asset from server
264 rezAsset = commsManager.AssetCache.GetAsset(item.assetID, isTexture); 264 rezAsset = commsManager.AssetCache.GetAsset(item.assetID, isTexture);
265 if (rezAsset != null) 265 if (rezAsset != null)
266 { 266 {
267 string script = Util.FieldToString(rezAsset.Data); 267 string script = Util.FieldToString(rezAsset.Data);
268 // Console.WriteLine("rez script " + script); 268 // Console.WriteLine("rez script " + script);
269 this.EventManager.TriggerRezScript(localID, copyID, script); 269 this.EventManager.TriggerRezScript(localID, copyID, script);
270 rezzed = true; 270 rezzed = true;
271 } 271 }
272 } 272 }
273 273
274 if (rezzed) 274 if (rezzed)
275 { 275 {
276 bool hasPrim = false; 276 bool hasPrim = false;
277 foreach (EntityBase ent in Entities.Values) 277 foreach (EntityBase ent in Entities.Values)
278 { 278 {
279 if (ent is SceneObjectGroup) 279 if (ent is SceneObjectGroup)
280 { 280 {
281 hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID); 281 hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID);
282 if (hasPrim != false) 282 if (hasPrim != false)
283 { 283 {
284 284
285 bool added = ((SceneObjectGroup)ent).AddInventoryItem(remoteClient, localID, item, copyID); 285 bool added = ((SceneObjectGroup)ent).AddInventoryItem(remoteClient, localID, item, copyID);
286 ((SceneObjectGroup)ent).GetProperites(remoteClient); 286 ((SceneObjectGroup)ent).GetProperites(remoteClient);
287 } 287 }
288 } 288 }
289 } 289 }
290 } 290 }
291 } 291 }
292 } 292 }
293 } 293 }
294 } 294 }
295 295
296 /// <summary> 296 /// <summary>
297 /// 297 ///
298 /// </summary> 298 /// </summary>
299 /// <param name="packet"></param> 299 /// <param name="packet"></param>
300 /// <param name="simClient"></param> 300 /// <param name="simClient"></param>
301 public void DeRezObject(Packet packet, IClientAPI remoteClient) 301 public void DeRezObject(Packet packet, IClientAPI remoteClient)
302 { 302 {
303 DeRezObjectPacket DeRezPacket = (DeRezObjectPacket)packet; 303 DeRezObjectPacket DeRezPacket = (DeRezObjectPacket)packet;
304 304
305 if (DeRezPacket.AgentBlock.DestinationID == LLUUID.Zero) 305 if (DeRezPacket.AgentBlock.DestinationID == LLUUID.Zero)
306 { 306 {
307 //currently following code not used (or don't know of any case of destination being zero 307 //currently following code not used (or don't know of any case of destination being zero
308 } 308 }
309 else 309 else
310 { 310 {
311 foreach (DeRezObjectPacket.ObjectDataBlock Data in DeRezPacket.ObjectData) 311 foreach (DeRezObjectPacket.ObjectDataBlock Data in DeRezPacket.ObjectData)
312 { 312 {
313 EntityBase selectedEnt = null; 313 EntityBase selectedEnt = null;
314 //OpenSim.Framework.Console.MainConsole.Instance.WriteLine("LocalID:" + Data.ObjectLocalID.ToString()); 314 //OpenSim.Framework.Console.MainConsole.Instance.WriteLine("LocalID:" + Data.ObjectLocalID.ToString());
315 foreach (EntityBase ent in this.Entities.Values) 315 foreach (EntityBase ent in this.Entities.Values)
316 { 316 {
317 if (ent.LocalId == Data.ObjectLocalID) 317 if (ent.LocalId == Data.ObjectLocalID)
318 { 318 {
319 selectedEnt = ent; 319 selectedEnt = ent;
320 break; 320 break;
321 } 321 }
322 } 322 }
323 if (selectedEnt != null) 323 if (selectedEnt != null)
324 { 324 {
325 if (PermissionsMngr.CanDeRezObject(remoteClient.AgentId, ((SceneObjectGroup)selectedEnt).UUID)) 325 if (PermissionsMngr.CanDeRezObject(remoteClient.AgentId, ((SceneObjectGroup)selectedEnt).UUID))
326 { 326 {
327 string sceneObjectXml = ((SceneObjectGroup)selectedEnt).ToXmlString(); 327 string sceneObjectXml = ((SceneObjectGroup)selectedEnt).ToXmlString();
328 CachedUserInfo userInfo = commsManager.UserProfiles.GetUserDetails(remoteClient.AgentId); 328 CachedUserInfo userInfo = commsManager.UserProfiles.GetUserDetails(remoteClient.AgentId);
329 if (userInfo != null) 329 if (userInfo != null)
330 { 330 {
331 AssetBase asset = new AssetBase(); 331 AssetBase asset = new AssetBase();
332 asset.Name = ((SceneObjectGroup)selectedEnt).GetPartName(selectedEnt.LocalId); 332 asset.Name = ((SceneObjectGroup)selectedEnt).GetPartName(selectedEnt.LocalId);
333 asset.Description = ((SceneObjectGroup)selectedEnt).GetPartDescription(selectedEnt.LocalId); 333 asset.Description = ((SceneObjectGroup)selectedEnt).GetPartDescription(selectedEnt.LocalId);
334 asset.InvType = 6; 334 asset.InvType = 6;
335 asset.Type = 6; 335 asset.Type = 6;
336 asset.FullID = LLUUID.Random(); 336 asset.FullID = LLUUID.Random();
337 asset.Data = Helpers.StringToField(sceneObjectXml); 337 asset.Data = Helpers.StringToField(sceneObjectXml);
338 commsManager.AssetCache.AddAsset(asset); 338 commsManager.AssetCache.AddAsset(asset);
339 339
340 340
341 InventoryItemBase item = new InventoryItemBase(); 341 InventoryItemBase item = new InventoryItemBase();
342 item.avatarID = remoteClient.AgentId; 342 item.avatarID = remoteClient.AgentId;
343 item.creatorsID = remoteClient.AgentId; 343 item.creatorsID = remoteClient.AgentId;
344 item.inventoryID = LLUUID.Random(); 344 item.inventoryID = LLUUID.Random();
345 item.assetID = asset.FullID; 345 item.assetID = asset.FullID;
346 item.inventoryDescription = asset.Description; 346 item.inventoryDescription = asset.Description;
347 item.inventoryName = asset.Name; 347 item.inventoryName = asset.Name;
348 item.assetType = asset.Type; 348 item.assetType = asset.Type;
349 item.invType = asset.InvType; 349 item.invType = asset.InvType;
350 item.parentFolderID = DeRezPacket.AgentBlock.DestinationID; 350 item.parentFolderID = DeRezPacket.AgentBlock.DestinationID;
351 item.inventoryCurrentPermissions = 2147483647; 351 item.inventoryCurrentPermissions = 2147483647;
352 item.inventoryNextPermissions = 2147483647; 352 item.inventoryNextPermissions = 2147483647;
353 353
354 userInfo.AddItem(remoteClient.AgentId, item); 354 userInfo.AddItem(remoteClient.AgentId, item);
355 remoteClient.SendInventoryItemUpdate(item); 355 remoteClient.SendInventoryItemUpdate(item);
356 } 356 }
357 357
358 SceneObjectPart rootPart = ((SceneObjectGroup)selectedEnt).GetChildPart(((SceneObjectGroup)selectedEnt).UUID); 358 SceneObjectPart rootPart = ((SceneObjectGroup)selectedEnt).GetChildPart(((SceneObjectGroup)selectedEnt).UUID);
359 if (rootPart.PhysActor != null) 359 if (rootPart.PhysActor != null)
360 { 360 {
361 this.phyScene.RemovePrim(rootPart.PhysActor); 361 this.phyScene.RemovePrim(rootPart.PhysActor);
362 rootPart.PhysActor = null; 362 rootPart.PhysActor = null;
363 } 363 }
364 364
365 storageManager.DataStore.RemoveObject(((SceneObjectGroup)selectedEnt).UUID, m_regInfo.SimUUID); 365 storageManager.DataStore.RemoveObject(((SceneObjectGroup)selectedEnt).UUID, m_regInfo.SimUUID);
366 ((SceneObjectGroup)selectedEnt).DeleteGroup(); 366 ((SceneObjectGroup)selectedEnt).DeleteGroup();
367 367
368 lock (Entities) 368 lock (Entities)
369 { 369 {
370 Entities.Remove(((SceneObjectGroup)selectedEnt).UUID); 370 Entities.Remove(((SceneObjectGroup)selectedEnt).UUID);
371 } 371 }
372 ((SceneObjectGroup)selectedEnt).DeleteParts(); 372 ((SceneObjectGroup)selectedEnt).DeleteParts();
373 } 373 }
374 } 374 }
375 } 375 }
376 } 376 }
377 } 377 }
378 378
379 public void RezObject(IClientAPI remoteClient, LLUUID itemID, LLVector3 pos) 379 public void RezObject(IClientAPI remoteClient, LLUUID itemID, LLVector3 pos)
380 { 380 {
381 CachedUserInfo userInfo = commsManager.UserProfiles.GetUserDetails(remoteClient.AgentId); 381 CachedUserInfo userInfo = commsManager.UserProfiles.GetUserDetails(remoteClient.AgentId);
382 if (userInfo != null) 382 if (userInfo != null)
383 { 383 {
384 if (userInfo.RootFolder != null) 384 if (userInfo.RootFolder != null)
385 { 385 {
386 InventoryItemBase item = userInfo.RootFolder.HasItem(itemID); 386 InventoryItemBase item = userInfo.RootFolder.HasItem(itemID);
387 if (item != null) 387 if (item != null)
388 { 388 {
389 AssetBase rezAsset = commsManager.AssetCache.GetAsset(item.assetID, false); 389 AssetBase rezAsset = commsManager.AssetCache.GetAsset(item.assetID, false);
390 if (rezAsset != null) 390 if (rezAsset != null)
391 { 391 {
392 this.AddRezObject(Util.FieldToString(rezAsset.Data), pos); 392 this.AddRezObject(Util.FieldToString(rezAsset.Data), pos);
393 userInfo.DeleteItem(remoteClient.AgentId, item); 393 userInfo.DeleteItem(remoteClient.AgentId, item);
394 remoteClient.SendRemoveInventoryItem(itemID); 394 remoteClient.SendRemoveInventoryItem(itemID);
395 } 395 }
396 else 396 else
397 { 397 {
398 //lets try once more incase the asset cache is being slow getting the asset from server 398 //lets try once more incase the asset cache is being slow getting the asset from server
399 rezAsset = commsManager.AssetCache.GetAsset(item.assetID, false); 399 rezAsset = commsManager.AssetCache.GetAsset(item.assetID, false);
400 if (rezAsset != null) 400 if (rezAsset != null)
401 { 401 {
402 this.AddRezObject(Util.FieldToString(rezAsset.Data), pos); 402 this.AddRezObject(Util.FieldToString(rezAsset.Data), pos);
403 userInfo.DeleteItem(remoteClient.AgentId, item); 403 userInfo.DeleteItem(remoteClient.AgentId, item);
404 remoteClient.SendRemoveInventoryItem(itemID); 404 remoteClient.SendRemoveInventoryItem(itemID);
405 } 405 }
406 } 406 }
407 } 407 }
408 } 408 }
409 } 409 }
410 } 410 }
411 411
412 private void AddRezObject(string xmlData, LLVector3 pos) 412 private void AddRezObject(string xmlData, LLVector3 pos)
413 { 413 {
414 SceneObjectGroup group = new SceneObjectGroup(this, this.m_regionHandle, xmlData); 414 SceneObjectGroup group = new SceneObjectGroup(this, this.m_regionHandle, xmlData);
415 this.AddEntity(group); 415 this.AddEntity(group);
416 group.AbsolutePosition = pos; 416 group.AbsolutePosition = pos;
417 SceneObjectPart rootPart = group.GetChildPart(group.UUID); 417 SceneObjectPart rootPart = group.GetChildPart(group.UUID);
418 if ((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Phantom) == 0) 418 if ((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Phantom) == 0)
419 rootPart.PhysActor = phyScene.AddPrim( 419 rootPart.PhysActor = phyScene.AddPrim(
420 new PhysicsVector(rootPart.AbsolutePosition.X, rootPart.AbsolutePosition.Y, rootPart.AbsolutePosition.Z), 420 new PhysicsVector(rootPart.AbsolutePosition.X, rootPart.AbsolutePosition.Y, rootPart.AbsolutePosition.Z),
421 new PhysicsVector(rootPart.Scale.X, rootPart.Scale.Y, rootPart.Scale.Z), 421 new PhysicsVector(rootPart.Scale.X, rootPart.Scale.Y, rootPart.Scale.Z),
422 new Axiom.Math.Quaternion(rootPart.RotationOffset.W, rootPart.RotationOffset.X, 422 new Axiom.Math.Quaternion(rootPart.RotationOffset.W, rootPart.RotationOffset.X,
423 rootPart.RotationOffset.Y, rootPart.RotationOffset.Z)); 423 rootPart.RotationOffset.Y, rootPart.RotationOffset.Z));
424 } 424 }
425 } 425 }
426 426
427} 427}
diff --git a/OpenSim/Region/Environment/Scenes/SceneManager.cs b/OpenSim/Region/Environment/Scenes/SceneManager.cs
index dfac406..4a99a80 100644
--- a/OpenSim/Region/Environment/Scenes/SceneManager.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneManager.cs
@@ -1,237 +1,237 @@
1using System.Collections.Generic; 1using System.Collections.Generic;
2using System; 2using System;
3using OpenSim.Framework.Console; 3using OpenSim.Framework.Console;
4using OpenSim.Framework.Types; 4using OpenSim.Framework.Types;
5 5
6namespace OpenSim.Region.Environment.Scenes 6namespace OpenSim.Region.Environment.Scenes
7{ 7{
8 public class SceneManager 8 public class SceneManager
9 { 9 {
10 private readonly List<Scene> m_localScenes; 10 private readonly List<Scene> m_localScenes;
11 private Scene m_currentScene = null; 11 private Scene m_currentScene = null;
12 public Scene CurrentScene 12 public Scene CurrentScene
13 { 13 {
14 get 14 get
15 { 15 {
16 return m_currentScene; 16 return m_currentScene;
17 } 17 }
18 } 18 }
19 19
20 private Scene CurrentOrFirstScene 20 private Scene CurrentOrFirstScene
21 { 21 {
22 get 22 get
23 { 23 {
24 if (m_currentScene == null) 24 if (m_currentScene == null)
25 { 25 {
26 return m_localScenes[0]; 26 return m_localScenes[0];
27 } 27 }
28 else 28 else
29 { 29 {
30 return m_currentScene; 30 return m_currentScene;
31 } 31 }
32 } 32 }
33 } 33 }
34 34
35 public SceneManager() 35 public SceneManager()
36 { 36 {
37 m_localScenes = new List<Scene>(); 37 m_localScenes = new List<Scene>();
38 } 38 }
39 39
40 public void Close() 40 public void Close()
41 { 41 {
42 for (int i = 0; i < m_localScenes.Count; i++) 42 for (int i = 0; i < m_localScenes.Count; i++)
43 { 43 {
44 m_localScenes[i].Close(); 44 m_localScenes[i].Close();
45 } 45 }
46 } 46 }
47 47
48 public void Add(Scene scene) 48 public void Add(Scene scene)
49 { 49 {
50 m_localScenes.Add(scene); 50 m_localScenes.Add(scene);
51 } 51 }
52 52
53 public void SavePrimsToXml(string filename) 53 public void SavePrimsToXml(string filename)
54 { 54 {
55 CurrentOrFirstScene.SavePrimsToXml(filename); 55 CurrentOrFirstScene.SavePrimsToXml(filename);
56 } 56 }
57 57
58 public void LoadPrimsFromXml(string filename) 58 public void LoadPrimsFromXml(string filename)
59 { 59 {
60 CurrentOrFirstScene.LoadPrimsFromXml(filename); 60 CurrentOrFirstScene.LoadPrimsFromXml(filename);
61 } 61 }
62 62
63 public bool RunTerrainCmd(string[] cmdparams, ref string result) 63 public bool RunTerrainCmd(string[] cmdparams, ref string result)
64 { 64 {
65 if (m_currentScene == null) 65 if (m_currentScene == null)
66 { 66 {
67 bool success = true; 67 bool success = true;
68 foreach (Scene scene in m_localScenes) 68 foreach (Scene scene in m_localScenes)
69 { 69 {
70 if (!scene.Terrain.RunTerrainCmd(cmdparams, ref result, scene.RegionInfo.RegionName)) 70 if (!scene.Terrain.RunTerrainCmd(cmdparams, ref result, scene.RegionInfo.RegionName))
71 { 71 {
72 success = false; 72 success = false;
73 } 73 }
74 } 74 }
75 75
76 return success; 76 return success;
77 } 77 }
78 else 78 else
79 { 79 {
80 return m_currentScene.Terrain.RunTerrainCmd(cmdparams, ref result, m_currentScene.RegionInfo.RegionName); 80 return m_currentScene.Terrain.RunTerrainCmd(cmdparams, ref result, m_currentScene.RegionInfo.RegionName);
81 } 81 }
82 } 82 }
83 83
84 public void SendCommandToScripts(string[] cmdparams) 84 public void SendCommandToScripts(string[] cmdparams)
85 { 85 {
86 ForEach(delegate(Scene scene) 86 ForEach(delegate(Scene scene)
87 { 87 {
88 scene.SendCommandToScripts(cmdparams); 88 scene.SendCommandToScripts(cmdparams);
89 }); 89 });
90 } 90 }
91 91
92 public void BypassPermissions(bool bypassPermissions) 92 public void BypassPermissions(bool bypassPermissions)
93 { 93 {
94 ForEach(delegate(Scene scene) 94 ForEach(delegate(Scene scene)
95 { 95 {
96 scene.PermissionsMngr.BypassPermissions = bypassPermissions; 96 scene.PermissionsMngr.BypassPermissions = bypassPermissions;
97 }); 97 });
98 } 98 }
99 99
100 private void ForEach(Action<Scene> func) 100 private void ForEach(Action<Scene> func)
101 { 101 {
102 if (m_currentScene == null) 102 if (m_currentScene == null)
103 { 103 {
104 m_localScenes.ForEach(func); 104 m_localScenes.ForEach(func);
105 } 105 }
106 else 106 else
107 { 107 {
108 func(m_currentScene); 108 func(m_currentScene);
109 } 109 }
110 } 110 }
111 111
112 public void Backup() 112 public void Backup()
113 { 113 {
114 ForEach(delegate(Scene scene) 114 ForEach(delegate(Scene scene)
115 { 115 {
116 scene.Backup(); 116 scene.Backup();
117 }); 117 });
118 } 118 }
119 119
120 public void HandleAlertCommand(string[] cmdparams) 120 public void HandleAlertCommand(string[] cmdparams)
121 { 121 {
122 ForEach(delegate(Scene scene) 122 ForEach(delegate(Scene scene)
123 { 123 {
124 scene.HandleAlertCommand(cmdparams); 124 scene.HandleAlertCommand(cmdparams);
125 }); 125 });
126 } 126 }
127 127
128 public bool TrySetCurrentRegion(string regionName) 128 public bool TrySetCurrentRegion(string regionName)
129 { 129 {
130 if ((String.Compare(regionName, "root") == 0) || (String.Compare(regionName, "..") == 0)) 130 if ((String.Compare(regionName, "root") == 0) || (String.Compare(regionName, "..") == 0))
131 { 131 {
132 m_currentScene = null; 132 m_currentScene = null;
133 return true; 133 return true;
134 } 134 }
135 else 135 else
136 { 136 {
137 Console.WriteLine("Searching for Region: '" + regionName + "'"); 137 Console.WriteLine("Searching for Region: '" + regionName + "'");
138 Scene foundScene = null; 138 Scene foundScene = null;
139 139
140 foreach (Scene scene in m_localScenes) 140 foreach (Scene scene in m_localScenes)
141 { 141 {
142 if (String.Compare(scene.RegionInfo.RegionName, regionName, true) == 0) 142 if (String.Compare(scene.RegionInfo.RegionName, regionName, true) == 0)
143 { 143 {
144 m_currentScene = scene; 144 m_currentScene = scene;
145 return true; 145 return true;
146 } 146 }
147 } 147 }
148 148
149 return false; 149 return false;
150 } 150 }
151 } 151 }
152 152
153 public void DebugPacket(LogBase log, int newDebug) 153 public void DebugPacket(LogBase log, int newDebug)
154 { 154 {
155 ForEach(delegate(Scene scene) 155 ForEach(delegate(Scene scene)
156 { 156 {
157 foreach (EntityBase entity in scene.Entities.Values) 157 foreach (EntityBase entity in scene.Entities.Values)
158 { 158 {
159 if (entity is ScenePresence) 159 if (entity is ScenePresence)
160 { 160 {
161 ScenePresence scenePrescence = entity as ScenePresence; 161 ScenePresence scenePrescence = entity as ScenePresence;
162 if (!scenePrescence.childAgent) 162 if (!scenePrescence.childAgent)
163 { 163 {
164 log.Error(String.Format("Packet debug for {0} {1} set to {2}", 164 log.Error(String.Format("Packet debug for {0} {1} set to {2}",
165 scenePrescence.Firstname, scenePrescence.Lastname, 165 scenePrescence.Firstname, scenePrescence.Lastname,
166 newDebug)); 166 newDebug));
167 167
168 scenePrescence.ControllingClient.SetDebug(newDebug); 168 scenePrescence.ControllingClient.SetDebug(newDebug);
169 } 169 }
170 } 170 }
171 } 171 }
172 }); 172 });
173 } 173 }
174 174
175 public List<ScenePresence> GetAvatars() 175 public List<ScenePresence> GetAvatars()
176 { 176 {
177 List<ScenePresence> avatars = new List<ScenePresence>(); 177 List<ScenePresence> avatars = new List<ScenePresence>();
178 178
179 ForEach(delegate(Scene scene) 179 ForEach(delegate(Scene scene)
180 { 180 {
181 foreach (EntityBase entity in scene.Entities.Values) 181 foreach (EntityBase entity in scene.Entities.Values)
182 { 182 {
183 if (entity is ScenePresence) 183 if (entity is ScenePresence)
184 { 184 {
185 ScenePresence scenePrescence = entity as ScenePresence; 185 ScenePresence scenePrescence = entity as ScenePresence;
186 if (!scenePrescence.childAgent) 186 if (!scenePrescence.childAgent)
187 { 187 {
188 avatars.Add(scenePrescence); 188 avatars.Add(scenePrescence);
189 } 189 }
190 } 190 }
191 } 191 }
192 }); 192 });
193 193
194 return avatars; 194 return avatars;
195 } 195 }
196 196
197 public RegionInfo GetRegionInfo(ulong regionHandle) 197 public RegionInfo GetRegionInfo(ulong regionHandle)
198 { 198 {
199 foreach (Scene scene in m_localScenes) 199 foreach (Scene scene in m_localScenes)
200 { 200 {
201 if (scene.RegionInfo.RegionHandle == regionHandle) 201 if (scene.RegionInfo.RegionHandle == regionHandle)
202 { 202 {
203 return scene.RegionInfo; 203 return scene.RegionInfo;
204 } 204 }
205 } 205 }
206 206
207 return null; 207 return null;
208 } 208 }
209 209
210 public void SetTimePhase(int timePhase) 210 public void SetTimePhase(int timePhase)
211 { 211 {
212 ForEach(delegate(Scene scene) 212 ForEach(delegate(Scene scene)
213 { 213 {
214 scene.SetTimePhase( 214 scene.SetTimePhase(
215 timePhase) 215 timePhase)
216 ; 216 ;
217 }); 217 });
218 } 218 }
219 219
220 220
221 public void ForceClientUpdate() 221 public void ForceClientUpdate()
222 { 222 {
223 ForEach(delegate(Scene scene) 223 ForEach(delegate(Scene scene)
224 { 224 {
225 scene.ForceClientUpdate(); 225 scene.ForceClientUpdate();
226 }); 226 });
227 } 227 }
228 228
229 public void HandleEditCommand(string[] cmdparams) 229 public void HandleEditCommand(string[] cmdparams)
230 { 230 {
231 ForEach(delegate(Scene scene) 231 ForEach(delegate(Scene scene)
232 { 232 {
233 scene.HandleEditCommand(cmdparams); 233 scene.HandleEditCommand(cmdparams);
234 }); 234 });
235 } 235 }
236 } 236 }
237} 237}
diff --git a/OpenSim/Region/Environment/Scenes/Scripting/IScriptHost.cs b/OpenSim/Region/Environment/Scenes/Scripting/IScriptHost.cs
index 2f248ce..7cf9cb7 100644
--- a/OpenSim/Region/Environment/Scenes/Scripting/IScriptHost.cs
+++ b/OpenSim/Region/Environment/Scenes/Scripting/IScriptHost.cs
@@ -1,20 +1,20 @@
1using System; 1using System;
2using System.Collections.Generic; 2using System.Collections.Generic;
3using System.Text; 3using System.Text;
4using libsecondlife; 4using libsecondlife;
5 5
6namespace OpenSim.Region.Environment.Scenes.Scripting 6namespace OpenSim.Region.Environment.Scenes.Scripting
7{ 7{
8 public interface IScriptHost 8 public interface IScriptHost
9 { 9 {
10 string Name { get; set;} 10 string Name { get; set;}
11 string SitName{ get; set;} 11 string SitName{ get; set;}
12 string TouchName { get; set;} 12 string TouchName { get; set;}
13 string Description { get; set; } 13 string Description { get; set; }
14 LLUUID UUID { get; } 14 LLUUID UUID { get; }
15 LLUUID ObjectOwner { get;} 15 LLUUID ObjectOwner { get;}
16 LLUUID ObjectCreator { get; } 16 LLUUID ObjectCreator { get; }
17 LLVector3 AbsolutePosition { get; } 17 LLVector3 AbsolutePosition { get; }
18 void SetText(string text, Axiom.Math.Vector3 color, double alpha); 18 void SetText(string text, Axiom.Math.Vector3 color, double alpha);
19 } 19 }
20} 20}
diff --git a/OpenSim/Region/Environment/Scenes/Scripting/NullScriptHost.cs b/OpenSim/Region/Environment/Scenes/Scripting/NullScriptHost.cs
index 5e3dcae..875e4cb 100644
--- a/OpenSim/Region/Environment/Scenes/Scripting/NullScriptHost.cs
+++ b/OpenSim/Region/Environment/Scenes/Scripting/NullScriptHost.cs
@@ -1,56 +1,56 @@
1using System; 1using System;
2using System.Collections.Generic; 2using System.Collections.Generic;
3using System.Text; 3using System.Text;
4using libsecondlife; 4using libsecondlife;
5 5
6namespace OpenSim.Region.Environment.Scenes.Scripting 6namespace OpenSim.Region.Environment.Scenes.Scripting
7{ 7{
8 public class NullScriptHost : IScriptHost 8 public class NullScriptHost : IScriptHost
9 { 9 {
10 10
11 LLVector3 m_pos = new LLVector3( 128, 128, 30 ); 11 LLVector3 m_pos = new LLVector3( 128, 128, 30 );
12 public string Name 12 public string Name
13 { 13 {
14 get { return "Object"; } 14 get { return "Object"; }
15 set { } 15 set { }
16 } 16 }
17 17
18 public string SitName 18 public string SitName
19 { 19 {
20 get { return ""; } 20 get { return ""; }
21 set { } 21 set { }
22 } 22 }
23 23
24 public string TouchName 24 public string TouchName
25 { 25 {
26 get { return ""; } 26 get { return ""; }
27 set { } 27 set { }
28 } 28 }
29 29
30 public string Description 30 public string Description
31 { 31 {
32 get { return ""; } 32 get { return ""; }
33 set { } 33 set { }
34 } 34 }
35 35
36 public LLUUID UUID 36 public LLUUID UUID
37 { 37 {
38 get { return LLUUID.Zero; } 38 get { return LLUUID.Zero; }
39 } 39 }
40 40
41 public LLUUID ObjectOwner 41 public LLUUID ObjectOwner
42 { get { return LLUUID.Zero; } } 42 { get { return LLUUID.Zero; } }
43 43
44 public LLUUID ObjectCreator { get { return LLUUID.Zero; } } 44 public LLUUID ObjectCreator { get { return LLUUID.Zero; } }
45 45
46 public LLVector3 AbsolutePosition 46 public LLVector3 AbsolutePosition
47 { 47 {
48 get { return m_pos; } 48 get { return m_pos; }
49 } 49 }
50 50
51 public void SetText(string text, Axiom.Math.Vector3 color, double alpha) 51 public void SetText(string text, Axiom.Math.Vector3 color, double alpha)
52 { 52 {
53 Console.WriteLine("Tried to SetText [{0}] on NullScriptHost", text); 53 Console.WriteLine("Tried to SetText [{0}] on NullScriptHost", text);
54 } 54 }
55 } 55 }
56} 56}
diff --git a/OpenSim/Region/Environment/Scenes/Scripting/ScriptEngineInterface.cs b/OpenSim/Region/Environment/Scenes/Scripting/ScriptEngineInterface.cs
index d3d58fe..5e8ff87 100644
--- a/OpenSim/Region/Environment/Scenes/Scripting/ScriptEngineInterface.cs
+++ b/OpenSim/Region/Environment/Scenes/Scripting/ScriptEngineInterface.cs
@@ -1,43 +1,43 @@
1/* 1/*
2* Copyright (c) Contributors, http://opensimulator.org/ 2* Copyright (c) Contributors, http://opensimulator.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/* Original code: Tedd Hansen */ 28/* Original code: Tedd Hansen */
29using System; 29using System;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Text; 31using System.Text;
32using OpenSim.Region.Environment.Scenes.Scripting; 32using OpenSim.Region.Environment.Scenes.Scripting;
33 33
34//TODO: WHERE TO PLACE THIS? 34//TODO: WHERE TO PLACE THIS?
35namespace OpenSim.Region.Environment.Scenes.Scripting 35namespace OpenSim.Region.Environment.Scenes.Scripting
36{ 36{
37 public interface ScriptEngineInterface 37 public interface ScriptEngineInterface
38 { 38 {
39 void InitializeEngine(OpenSim.Region.Environment.Scenes.Scene Sceneworld, OpenSim.Framework.Console.LogBase logger); 39 void InitializeEngine(OpenSim.Region.Environment.Scenes.Scene Sceneworld, OpenSim.Framework.Console.LogBase logger);
40 void Shutdown(); 40 void Shutdown();
41// void StartScript(string ScriptID, IScriptHost ObjectID); 41// void StartScript(string ScriptID, IScriptHost ObjectID);
42 } 42 }
43} 43}
diff --git a/OpenSim/Region/Environment/Scenes/Scripting/ScriptEngineLoader.cs b/OpenSim/Region/Environment/Scenes/Scripting/ScriptEngineLoader.cs
index 3500545..83bd0ab 100644
--- a/OpenSim/Region/Environment/Scenes/Scripting/ScriptEngineLoader.cs
+++ b/OpenSim/Region/Environment/Scenes/Scripting/ScriptEngineLoader.cs
@@ -1,124 +1,124 @@
1/* 1/*
2* Copyright (c) Contributors, http://opensimulator.org/ 2* Copyright (c) Contributors, http://opensimulator.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/* Original code: Tedd Hansen */ 28/* Original code: Tedd Hansen */
29using System; 29using System;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.IO; 31using System.IO;
32using System.Text; 32using System.Text;
33using System.Reflection; 33using System.Reflection;
34 34
35namespace OpenSim.Region.Environment.Scenes.Scripting 35namespace OpenSim.Region.Environment.Scenes.Scripting
36{ 36{
37 public class ScriptEngineLoader 37 public class ScriptEngineLoader
38 { 38 {
39 private OpenSim.Framework.Console.LogBase m_log; 39 private OpenSim.Framework.Console.LogBase m_log;
40 public ScriptEngineLoader(OpenSim.Framework.Console.LogBase logger) 40 public ScriptEngineLoader(OpenSim.Framework.Console.LogBase logger)
41 { 41 {
42 m_log = logger; 42 m_log = logger;
43 } 43 }
44 44
45 public ScriptEngineInterface LoadScriptEngine(string EngineName) 45 public ScriptEngineInterface LoadScriptEngine(string EngineName)
46 { 46 {
47 ScriptEngineInterface ret = null; 47 ScriptEngineInterface ret = null;
48 try 48 try
49 { 49 {
50 ret = LoadAndInitAssembly(Path.Combine("ScriptEngines", "OpenSim.Region.ScriptEngine." + EngineName + ".dll"), 50 ret = LoadAndInitAssembly(Path.Combine("ScriptEngines", "OpenSim.Region.ScriptEngine." + EngineName + ".dll"),
51 "OpenSim.Region.ScriptEngine." + EngineName + ".ScriptEngine"); 51 "OpenSim.Region.ScriptEngine." + EngineName + ".ScriptEngine");
52 } 52 }
53 catch (Exception e) 53 catch (Exception e)
54 { 54 {
55 m_log.Error("ScriptEngine", "Error loading assembly \"" + EngineName + "\": " + e.Message + ", " + e.StackTrace.ToString()); 55 m_log.Error("ScriptEngine", "Error loading assembly \"" + EngineName + "\": " + e.Message + ", " + e.StackTrace.ToString());
56 } 56 }
57 return ret; 57 return ret;
58 } 58 }
59 59
60 /// <summary> 60 /// <summary>
61 /// Does actual loading and initialization of script Assembly 61 /// Does actual loading and initialization of script Assembly
62 /// </summary> 62 /// </summary>
63 /// <param name="FreeAppDomain">AppDomain to load script into</param> 63 /// <param name="FreeAppDomain">AppDomain to load script into</param>
64 /// <param name="FileName">FileName of script assembly (.dll)</param> 64 /// <param name="FileName">FileName of script assembly (.dll)</param>
65 /// <returns></returns> 65 /// <returns></returns>
66 private ScriptEngineInterface LoadAndInitAssembly(string FileName, string NameSpace) 66 private ScriptEngineInterface LoadAndInitAssembly(string FileName, string NameSpace)
67 { 67 {
68 //Common.SendToDebug("Loading ScriptEngine Assembly " + FileName); 68 //Common.SendToDebug("Loading ScriptEngine Assembly " + FileName);
69 // Load .Net Assembly (.dll) 69 // Load .Net Assembly (.dll)
70 // Initialize and return it 70 // Initialize and return it
71 71
72 // TODO: Add error handling 72 // TODO: Add error handling
73 73
74 Assembly a; 74 Assembly a;
75 //try 75 //try
76 //{ 76 //{
77 77
78 78
79 // Load to default appdomain (temporary) 79 // Load to default appdomain (temporary)
80 a = Assembly.LoadFrom(FileName); 80 a = Assembly.LoadFrom(FileName);
81 // Load to specified appdomain 81 // Load to specified appdomain
82 // TODO: Insert security 82 // TODO: Insert security
83 //a = FreeAppDomain.Load(FileName); 83 //a = FreeAppDomain.Load(FileName);
84 //} 84 //}
85 //catch (Exception e) 85 //catch (Exception e)
86 //{ 86 //{
87 // m_log.Error("ScriptEngine", "Error loading assembly \"" + FileName + "\": " + e.ToString()); 87 // m_log.Error("ScriptEngine", "Error loading assembly \"" + FileName + "\": " + e.ToString());
88 //} 88 //}
89 89
90 90
91 //Console.WriteLine("Loading: " + FileName); 91 //Console.WriteLine("Loading: " + FileName);
92 //foreach (Type _t in a.GetTypes()) 92 //foreach (Type _t in a.GetTypes())
93 //{ 93 //{
94 // Console.WriteLine("Type: " + _t.ToString()); 94 // Console.WriteLine("Type: " + _t.ToString());
95 //} 95 //}
96 96
97 Type t; 97 Type t;
98 //try 98 //try
99 //{ 99 //{
100 t = a.GetType(NameSpace, true); 100 t = a.GetType(NameSpace, true);
101 //} 101 //}
102 //catch (Exception e) 102 //catch (Exception e)
103 //{ 103 //{
104 // m_log.Error("ScriptEngine", "Error initializing type \"" + NameSpace + "\" from \"" + FileName + "\": " + e.ToString()); 104 // m_log.Error("ScriptEngine", "Error initializing type \"" + NameSpace + "\" from \"" + FileName + "\": " + e.ToString());
105 //} 105 //}
106 106
107 ScriptEngineInterface ret; 107 ScriptEngineInterface ret;
108 //try 108 //try
109 //{ 109 //{
110 ret = (ScriptEngineInterface)Activator.CreateInstance(t); 110 ret = (ScriptEngineInterface)Activator.CreateInstance(t);
111 //} 111 //}
112 //catch (Exception e) 112 //catch (Exception e)
113 //{ 113 //{
114 // m_log.Error("ScriptEngine", "Error initializing type \"" + NameSpace + "\" from \"" + FileName + "\": " + e.ToString()); 114 // m_log.Error("ScriptEngine", "Error initializing type \"" + NameSpace + "\" from \"" + FileName + "\": " + e.ToString());
115 //} 115 //}
116 116
117 return ret; 117 return ret;
118 118
119 119
120 } 120 }
121 121
122 122
123 } 123 }
124} 124}