aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorBlueWall2012-04-26 16:13:47 -0400
committerBlueWall2012-04-26 16:13:47 -0400
commitfba802bb03b7dee804059eae888b63c88280389c (patch)
treeca7312919830dd469dfd4e9b739d5291702007e4 /OpenSim/Region
parentAdd a version of osNpcSay that takes a channel number Mantis 5747 (diff)
parentMerge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff)
downloadopensim-SC_OLD-fba802bb03b7dee804059eae888b63c88280389c.zip
opensim-SC_OLD-fba802bb03b7dee804059eae888b63c88280389c.tar.gz
opensim-SC_OLD-fba802bb03b7dee804059eae888b63c88280389c.tar.bz2
opensim-SC_OLD-fba802bb03b7dee804059eae888b63c88280389c.tar.xz
Merge branch 'master' of /home/opensim/var/repo/opensim
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs33
-rw-r--r--OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs21
-rw-r--r--OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs31
-rw-r--r--OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs13
-rw-r--r--OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs4
-rw-r--r--OpenSim/Region/CoreModules/World/LegacyMap/ShadedMapTileRenderer.cs4
-rw-r--r--OpenSim/Region/CoreModules/World/LegacyMap/TexturedMapTileRenderer.cs4
-rw-r--r--OpenSim/Region/CoreModules/World/Warp3DMap/MapImageModule.cs4
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Inventory.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs42
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs19
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs36
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/Friends/FriendsCommandsModule.cs17
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs39
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs2
-rw-r--r--OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs4
-rw-r--r--OpenSim/Region/Physics/OdePlugin/ODEPrim.cs1
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/ApiManager.cs41
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs390
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs30
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs14
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs13
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs7
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/XEngine.cs8
25 files changed, 423 insertions, 358 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index faa413e..7200c4b 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -143,7 +143,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
143 } 143 }
144 catch (Exception e) 144 catch (Exception e)
145 { 145 {
146 m_log.ErrorFormat("[ATTACHMENTS MODULE]: Unable to rez attachment: {0}{1}", e.Message, e.StackTrace); 146 UUID agentId = (sp.ControllingClient == null) ? (UUID)null : sp.ControllingClient.AgentId;
147 m_log.ErrorFormat("[ATTACHMENTS MODULE]: Unable to rez attachment with itemID {0}, assetID {1}, point {2} for {3}: {4}\n{5}",
148 attach.ItemID, attach.AssetID, p, agentId, e.Message, e.StackTrace);
147 } 149 }
148 } 150 }
149 } 151 }
@@ -389,7 +391,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
389 lock (sp.AttachmentsSyncLock) 391 lock (sp.AttachmentsSyncLock)
390 { 392 {
391 // Save avatar attachment information 393 // Save avatar attachment information
392 m_log.Debug("[ATTACHMENTS MODULE]: Detaching from UserID: " + sp.UUID + ", ItemID: " + itemID); 394// m_log.Debug("[ATTACHMENTS MODULE]: Detaching from UserID: " + sp.UUID + ", ItemID: " + itemID);
393 395
394 bool changed = sp.Appearance.DetachAttachment(itemID); 396 bool changed = sp.Appearance.DetachAttachment(itemID);
395 if (changed && m_scene.AvatarFactory != null) 397 if (changed && m_scene.AvatarFactory != null)
@@ -469,9 +471,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
469 471
470 if (grp.HasGroupChanged || (saveAllScripted && grp.ContainsScripts())) 472 if (grp.HasGroupChanged || (saveAllScripted && grp.ContainsScripts()))
471 { 473 {
472 m_log.DebugFormat( 474// m_log.DebugFormat(
473 "[ATTACHMENTS MODULE]: Updating asset for attachment {0}, attachpoint {1}", 475// "[ATTACHMENTS MODULE]: Updating asset for attachment {0}, attachpoint {1}",
474 grp.UUID, grp.AttachmentPoint); 476// grp.UUID, grp.AttachmentPoint);
475 477
476 string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp); 478 string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp);
477 479
@@ -502,12 +504,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
502 } 504 }
503 grp.HasGroupChanged = false; // Prevent it being saved over and over 505 grp.HasGroupChanged = false; // Prevent it being saved over and over
504 } 506 }
505 else 507// else
506 { 508// {
507 m_log.DebugFormat( 509// m_log.DebugFormat(
508 "[ATTACHMENTS MODULE]: Don't need to update asset for unchanged attachment {0}, attachpoint {1}", 510// "[ATTACHMENTS MODULE]: Don't need to update asset for unchanged attachment {0}, attachpoint {1}",
509 grp.UUID, grp.AttachmentPoint); 511// grp.UUID, grp.AttachmentPoint);
510 } 512// }
511 } 513 }
512 514
513 /// <summary> 515 /// <summary>
@@ -889,13 +891,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
889 // Calls attach with a Zero position 891 // Calls attach with a Zero position
890 if (AttachObject(sp, part.ParentGroup, AttachmentPt, false)) 892 if (AttachObject(sp, part.ParentGroup, AttachmentPt, false))
891 { 893 {
892 m_scene.EventManager.TriggerOnAttach(objectLocalID, part.ParentGroup.FromItemID, remoteClient.AgentId); 894// m_log.Debug(
895// "[ATTACHMENTS MODULE]: Saving avatar attachment. AgentID: " + remoteClient.AgentId
896// + ", AttachmentPoint: " + AttachmentPt);
893 897
894 // Save avatar attachment information 898 // Save avatar attachment information
895 m_log.Debug( 899 m_scene.EventManager.TriggerOnAttach(objectLocalID, part.ParentGroup.FromItemID, remoteClient.AgentId);
896 "[ATTACHMENTS MODULE]: Saving avatar attachment. AgentID: " + remoteClient.AgentId
897 + ", AttachmentPoint: " + AttachmentPt);
898
899 } 900 }
900 } 901 }
901 catch (Exception e) 902 catch (Exception e)
diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
index b0cee03..0ed10d2 100644
--- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
@@ -158,7 +158,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
158 // Process the baked texture array 158 // Process the baked texture array
159 if (textureEntry != null) 159 if (textureEntry != null)
160 { 160 {
161 m_log.InfoFormat("[AVFACTORY]: Received texture update for {0} {1}", sp.Name, sp.UUID); 161// m_log.DebugFormat("[AVFACTORY]: Received texture update for {0} {1}", sp.Name, sp.UUID);
162 162
163// WriteBakedTexturesReport(sp, m_log.DebugFormat); 163// WriteBakedTexturesReport(sp, m_log.DebugFormat);
164 164
@@ -208,7 +208,8 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
208 ScenePresence sp = m_scene.GetScenePresence(agentId); 208 ScenePresence sp = m_scene.GetScenePresence(agentId);
209 if (sp == null) 209 if (sp == null)
210 { 210 {
211 m_log.WarnFormat("[AVFACTORY]: Agent {0} no longer in the scene", agentId); 211 // This is expected if the user has gone away.
212// m_log.DebugFormat("[AVFACTORY]: Agent {0} no longer in the scene", agentId);
212 return false; 213 return false;
213 } 214 }
214 215
@@ -248,10 +249,10 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
248 249
249 if (bakedTextureFace == null) 250 if (bakedTextureFace == null)
250 { 251 {
251 m_log.WarnFormat( 252 // This can happen legitimately, since some baked textures might not exist
252 "[AV FACTORY]: No texture ID set for {0} for {1} in {2} not found when trying to save permanently", 253 //m_log.WarnFormat(
253 bakeType, sp.Name, m_scene.RegionInfo.RegionName); 254 // "[AV FACTORY]: No texture ID set for {0} for {1} in {2} not found when trying to save permanently",
254 255 // bakeType, sp.Name, m_scene.RegionInfo.RegionName);
255 continue; 256 continue;
256 } 257 }
257 258
@@ -337,7 +338,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
337 return false; 338 return false;
338 } 339 }
339 340
340 m_log.DebugFormat("[AVFACTORY]: Completed texture check for {0} {1}", sp.Name, sp.UUID); 341// m_log.DebugFormat("[AVFACTORY]: Completed texture check for {0} {1}", sp.Name, sp.UUID);
341 342
342 // If we only found default textures, then the appearance is not cached 343 // If we only found default textures, then the appearance is not cached
343 return (defonly ? false : true); 344 return (defonly ? false : true);
@@ -417,7 +418,8 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
417// acd.AgentID, i, acd.Appearance.Texture.FaceTextures[i]); 418// acd.AgentID, i, acd.Appearance.Texture.FaceTextures[i]);
418 419
419 int ftIndex = (int)AppearanceManager.BakeTypeToAgentTextureIndex(bakeType); 420 int ftIndex = (int)AppearanceManager.BakeTypeToAgentTextureIndex(bakeType);
420 bakedTextures[bakeType] = faceTextures[ftIndex]; 421 Primitive.TextureEntryFace texture = faceTextures[ftIndex]; // this will be null if there's no such baked texture
422 bakedTextures[bakeType] = texture;
421 } 423 }
422 424
423 return bakedTextures; 425 return bakedTextures;
@@ -482,7 +484,8 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
482 ScenePresence sp = m_scene.GetScenePresence(agentid); 484 ScenePresence sp = m_scene.GetScenePresence(agentid);
483 if (sp == null) 485 if (sp == null)
484 { 486 {
485 m_log.WarnFormat("[AVFACTORY]: Agent {0} no longer in the scene", agentid); 487 // This is expected if the user has gone away.
488// m_log.DebugFormat("[AVFACTORY]: Agent {0} no longer in the scene", agentid);
486 return; 489 return;
487 } 490 }
488 491
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
index fa9cd55..a36d0fe 100644
--- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
@@ -61,8 +61,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
61 set { m_MaxTransferDistance = value; } 61 set { m_MaxTransferDistance = value; }
62 } 62 }
63 63
64 private int m_levelHGTeleport = 0;
65
66 protected bool m_Enabled = false; 64 protected bool m_Enabled = false;
67 protected Scene m_aScene; 65 protected Scene m_aScene;
68 protected List<Scene> m_Scenes = new List<Scene>(); 66 protected List<Scene> m_Scenes = new List<Scene>();
@@ -106,7 +104,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
106 if (transferConfig != null) 104 if (transferConfig != null)
107 { 105 {
108 MaxTransferDistance = transferConfig.GetInt("max_distance", 4095); 106 MaxTransferDistance = transferConfig.GetInt("max_distance", 4095);
109 m_levelHGTeleport = transferConfig.GetInt("LevelHGTeleport", 0);
110 } 107 }
111 108
112 m_agentsInTransit = new List<UUID>(); 109 m_agentsInTransit = new List<UUID>();
@@ -172,13 +169,17 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
172 // Reset animations; the viewer does that in teleports. 169 // Reset animations; the viewer does that in teleports.
173 sp.Animator.ResetAnimations(); 170 sp.Animator.ResetAnimations();
174 171
172 string destinationRegionName = "(not found)";
173
175 try 174 try
176 { 175 {
177 if (regionHandle == sp.Scene.RegionInfo.RegionHandle) 176 if (regionHandle == sp.Scene.RegionInfo.RegionHandle)
178 { 177 {
178 destinationRegionName = sp.Scene.RegionInfo.RegionName;
179
179 m_log.DebugFormat( 180 m_log.DebugFormat(
180 "[ENTITY TRANSFER MODULE]: RequestTeleportToLocation {0} within {1}", 181 "[ENTITY TRANSFER MODULE]: RequestTeleportToLocation for {0} to {1} within existing region {2}",
181 position, sp.Scene.RegionInfo.RegionName); 182 sp.Name, position, destinationRegionName);
182 183
183 // Teleport within the same region 184 // Teleport within the same region
184 if (IsOutsideRegion(sp.Scene, position) || position.Z < 0) 185 if (IsOutsideRegion(sp.Scene, position) || position.Z < 0)
@@ -188,6 +189,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
188 m_log.WarnFormat( 189 m_log.WarnFormat(
189 "[ENTITY TRANSFER MODULE]: RequestTeleportToLocation() was given an illegal position of {0} for avatar {1}, {2}. Substituting {3}", 190 "[ENTITY TRANSFER MODULE]: RequestTeleportToLocation() was given an illegal position of {0} for avatar {1}, {2}. Substituting {3}",
190 position, sp.Name, sp.UUID, emergencyPos); 191 position, sp.Name, sp.UUID, emergencyPos);
192
191 position = emergencyPos; 193 position = emergencyPos;
192 } 194 }
193 195
@@ -210,6 +212,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
210 sp.ControllingClient.SendTeleportStart(teleportFlags); 212 sp.ControllingClient.SendTeleportStart(teleportFlags);
211 213
212 sp.ControllingClient.SendLocalTeleport(position, lookAt, teleportFlags); 214 sp.ControllingClient.SendLocalTeleport(position, lookAt, teleportFlags);
215 sp.Velocity = Vector3.Zero;
213 sp.Teleport(position); 216 sp.Teleport(position);
214 217
215 foreach (SceneObjectGroup grp in sp.GetAttachments()) 218 foreach (SceneObjectGroup grp in sp.GetAttachments())
@@ -233,15 +236,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
233 return; 236 return;
234 } 237 }
235 238
236 // check if HyperGrid teleport is allowed, based on user level 239 destinationRegionName = finalDestination.RegionName;
237 int flags = m_aScene.GridService.GetRegionFlags(sp.Scene.RegionInfo.ScopeID, reg.RegionID);
238
239 if (((flags & (int)OpenSim.Data.RegionFlags.Hyperlink) != 0) && (sp.UserLevel < m_levelHGTeleport))
240 {
241 m_log.WarnFormat("[ENTITY TRANSFER MODULE]: Final destination link is non permitted hypergrid region. Unable to teleport agent.");
242 sp.ControllingClient.SendTeleportFailed("HyperGrid teleport not permitted");
243 return;
244 }
245 240
246 uint curX = 0, curY = 0; 241 uint curX = 0, curY = 0;
247 Utils.LongToUInts(sp.Scene.RegionInfo.RegionHandle, out curX, out curY); 242 Utils.LongToUInts(sp.Scene.RegionInfo.RegionHandle, out curX, out curY);
@@ -307,7 +302,11 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
307 } 302 }
308 catch (Exception e) 303 catch (Exception e)
309 { 304 {
310 m_log.WarnFormat("[ENTITY TRANSFER MODULE]: Exception on teleport: {0} {1}", e.Message, e.StackTrace); 305 m_log.ErrorFormat(
306 "[ENTITY TRANSFER MODULE]: Exception on teleport of {0} from {1}@{2} to {3}@{4}: {5}{6}",
307 sp.Name, sp.AbsolutePosition, sp.Scene.RegionInfo.RegionName, position, destinationRegionName,
308 e.Message, e.StackTrace);
309
311 sp.ControllingClient.SendTeleportFailed("Internal error"); 310 sp.ControllingClient.SendTeleportFailed("Internal error");
312 } 311 }
313 } 312 }
@@ -402,7 +401,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
402 bool logout = false; 401 bool logout = false;
403 if (!CreateAgent(sp, reg, finalDestination, agentCircuit, teleportFlags, out reason, out logout)) 402 if (!CreateAgent(sp, reg, finalDestination, agentCircuit, teleportFlags, out reason, out logout))
404 { 403 {
405 sp.ControllingClient.SendTeleportFailed(String.Format("Destination refused: {0}", 404 sp.ControllingClient.SendTeleportFailed(String.Format("Teleport refused: {0}",
406 reason)); 405 reason));
407 return; 406 return;
408 } 407 }
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
index 7f9175d..634fb43 100644
--- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
@@ -50,6 +50,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
50 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 50 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
51 51
52 private bool m_Initialized = false; 52 private bool m_Initialized = false;
53 private int m_levelHGTeleport = 0;
53 54
54 private GatekeeperServiceConnector m_GatekeeperConnector; 55 private GatekeeperServiceConnector m_GatekeeperConnector;
55 56
@@ -68,6 +69,10 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
68 string name = moduleConfig.GetString("EntityTransferModule", ""); 69 string name = moduleConfig.GetString("EntityTransferModule", "");
69 if (name == Name) 70 if (name == Name)
70 { 71 {
72 IConfig transferConfig = source.Configs["EntityTransfer"];
73 if (transferConfig != null)
74 m_levelHGTeleport = transferConfig.GetInt("LevelHGTeleport", 0);
75
71 InitialiseCommon(source); 76 InitialiseCommon(source);
72 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: {0} enabled.", Name); 77 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: {0} enabled.", Name);
73 } 78 }
@@ -164,6 +169,14 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
164 if (flags == -1 /* no region in DB */ || (flags & (int)OpenSim.Data.RegionFlags.Hyperlink) != 0) 169 if (flags == -1 /* no region in DB */ || (flags & (int)OpenSim.Data.RegionFlags.Hyperlink) != 0)
165 { 170 {
166 // this user is going to another grid 171 // this user is going to another grid
172 // check if HyperGrid teleport is allowed, based on user level
173 if (sp.UserLevel < m_levelHGTeleport)
174 {
175 m_log.WarnFormat("[HG ENTITY TRANSFER MODULE]: Unable to HG teleport agent due to insufficient UserLevel.");
176 reason = "HyperGrid teleport not permitted";
177 return false;
178 }
179
167 if (agentCircuit.ServiceURLs.ContainsKey("HomeURI")) 180 if (agentCircuit.ServiceURLs.ContainsKey("HomeURI"))
168 { 181 {
169 string userAgentDriver = agentCircuit.ServiceURLs["HomeURI"].ToString(); 182 string userAgentDriver = agentCircuit.ServiceURLs["HomeURI"].ToString();
diff --git a/OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs b/OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs
index f86c790..aa306c7 100644
--- a/OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs
+++ b/OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs
@@ -225,7 +225,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
225 int tc = 0; 225 int tc = 0;
226 double[,] hm = whichScene.Heightmap.GetDoubles(); 226 double[,] hm = whichScene.Heightmap.GetDoubles();
227 tc = Environment.TickCount; 227 tc = Environment.TickCount;
228 m_log.Info("[MAPTILE]: Generating Maptile Step 2: Object Volume Profile"); 228 m_log.Debug("[MAPTILE]: Generating Maptile Step 2: Object Volume Profile");
229 EntityBase[] objs = whichScene.GetEntities(); 229 EntityBase[] objs = whichScene.GetEntities();
230 Dictionary<uint, DrawStruct> z_sort = new Dictionary<uint, DrawStruct>(); 230 Dictionary<uint, DrawStruct> z_sort = new Dictionary<uint, DrawStruct>();
231 //SortedList<float, RectangleDrawStruct> z_sort = new SortedList<float, RectangleDrawStruct>(); 231 //SortedList<float, RectangleDrawStruct> z_sort = new SortedList<float, RectangleDrawStruct>();
@@ -541,7 +541,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
541 g.Dispose(); 541 g.Dispose();
542 } // lock entities objs 542 } // lock entities objs
543 543
544 m_log.Info("[MAPTILE]: Generating Maptile Step 2: Done in " + (Environment.TickCount - tc) + " ms"); 544 m_log.Debug("[MAPTILE]: Generating Maptile Step 2: Done in " + (Environment.TickCount - tc) + " ms");
545 return mapbmp; 545 return mapbmp;
546 } 546 }
547 547
diff --git a/OpenSim/Region/CoreModules/World/LegacyMap/ShadedMapTileRenderer.cs b/OpenSim/Region/CoreModules/World/LegacyMap/ShadedMapTileRenderer.cs
index eb1a27f..992bff3 100644
--- a/OpenSim/Region/CoreModules/World/LegacyMap/ShadedMapTileRenderer.cs
+++ b/OpenSim/Region/CoreModules/World/LegacyMap/ShadedMapTileRenderer.cs
@@ -54,7 +54,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
54 public void TerrainToBitmap(Bitmap mapbmp) 54 public void TerrainToBitmap(Bitmap mapbmp)
55 { 55 {
56 int tc = Environment.TickCount; 56 int tc = Environment.TickCount;
57 m_log.Info("[MAPTILE]: Generating Maptile Step 1: Terrain"); 57 m_log.Debug("[MAPTILE]: Generating Maptile Step 1: Terrain");
58 58
59 double[,] hm = m_scene.Heightmap.GetDoubles(); 59 double[,] hm = m_scene.Heightmap.GetDoubles();
60 bool ShadowDebugContinue = true; 60 bool ShadowDebugContinue = true;
@@ -238,7 +238,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
238 } 238 }
239 } 239 }
240 } 240 }
241 m_log.Info("[MAPTILE]: Generating Maptile Step 1: Done in " + (Environment.TickCount - tc) + " ms"); 241 m_log.Debug("[MAPTILE]: Generating Maptile Step 1: Done in " + (Environment.TickCount - tc) + " ms");
242 } 242 }
243 } 243 }
244} 244}
diff --git a/OpenSim/Region/CoreModules/World/LegacyMap/TexturedMapTileRenderer.cs b/OpenSim/Region/CoreModules/World/LegacyMap/TexturedMapTileRenderer.cs
index 1d2141e..d13c2ef 100644
--- a/OpenSim/Region/CoreModules/World/LegacyMap/TexturedMapTileRenderer.cs
+++ b/OpenSim/Region/CoreModules/World/LegacyMap/TexturedMapTileRenderer.cs
@@ -278,7 +278,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
278 public void TerrainToBitmap(Bitmap mapbmp) 278 public void TerrainToBitmap(Bitmap mapbmp)
279 { 279 {
280 int tc = Environment.TickCount; 280 int tc = Environment.TickCount;
281 m_log.Info("[MAPTILE]: Generating Maptile Step 1: Terrain"); 281 m_log.Debug("[MAPTILE]: Generating Maptile Step 1: Terrain");
282 282
283 // These textures should be in the AssetCache anyway, as every client conneting to this 283 // These textures should be in the AssetCache anyway, as every client conneting to this
284 // region needs them. Except on start, when the map is recreated (before anyone connected), 284 // region needs them. Except on start, when the map is recreated (before anyone connected),
@@ -412,7 +412,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
412 } 412 }
413 } 413 }
414 } 414 }
415 m_log.Info("[MAPTILE]: Generating Maptile Step 1: Done in " + (Environment.TickCount - tc) + " ms"); 415 m_log.Debug("[MAPTILE]: Generating Maptile Step 1: Done in " + (Environment.TickCount - tc) + " ms");
416 } 416 }
417 } 417 }
418} 418}
diff --git a/OpenSim/Region/CoreModules/World/Warp3DMap/MapImageModule.cs b/OpenSim/Region/CoreModules/World/Warp3DMap/MapImageModule.cs
index 6163fd1..4f4e296 100644
--- a/OpenSim/Region/CoreModules/World/Warp3DMap/MapImageModule.cs
+++ b/OpenSim/Region/CoreModules/World/Warp3DMap/MapImageModule.cs
@@ -88,11 +88,11 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
88 if (renderers.Count > 0) 88 if (renderers.Count > 0)
89 { 89 {
90 m_primMesher = RenderingLoader.LoadRenderer(renderers[0]); 90 m_primMesher = RenderingLoader.LoadRenderer(renderers[0]);
91 m_log.Info("[MAPTILE]: Loaded prim mesher " + m_primMesher.ToString()); 91 m_log.Debug("[MAPTILE]: Loaded prim mesher " + m_primMesher.ToString());
92 } 92 }
93 else 93 else
94 { 94 {
95 m_log.Info("[MAPTILE]: No prim mesher loaded, prim rendering will be disabled"); 95 m_log.Debug("[MAPTILE]: No prim mesher loaded, prim rendering will be disabled");
96 } 96 }
97 97
98 m_scene.RegisterModuleInterface<IMapImageGenerator>(this); 98 m_scene.RegisterModuleInterface<IMapImageGenerator>(this);
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index 10b25ed..816d3b6 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -1988,7 +1988,7 @@ namespace OpenSim.Region.Framework.Scenes
1988 } 1988 }
1989 } 1989 }
1990 1990
1991 if (permissionToTake) 1991 if (permissionToTake && (action != DeRezAction.Delete || this.m_useTrashOnDelete))
1992 { 1992 {
1993 m_asyncSceneObjectDeleter.DeleteToInventory( 1993 m_asyncSceneObjectDeleter.DeleteToInventory(
1994 action, destinationID, deleteGroups, remoteClient, 1994 action, destinationID, deleteGroups, remoteClient,
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index a87dfb7..7a2b2ed 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -103,6 +103,7 @@ namespace OpenSim.Region.Framework.Scenes
103 public bool m_trustBinaries; 103 public bool m_trustBinaries;
104 public bool m_allowScriptCrossings; 104 public bool m_allowScriptCrossings;
105 public bool m_useFlySlow; 105 public bool m_useFlySlow;
106 public bool m_useTrashOnDelete = true;
106 107
107 /// <summary> 108 /// <summary>
108 /// Temporarily setting to trigger appearance resends at 60 second intervals. 109 /// Temporarily setting to trigger appearance resends at 60 second intervals.
@@ -709,6 +710,7 @@ namespace OpenSim.Region.Framework.Scenes
709 m_clampPrimSize = true; 710 m_clampPrimSize = true;
710 } 711 }
711 712
713 m_useTrashOnDelete = startupConfig.GetBoolean("UseTrashOnDelete",m_useTrashOnDelete);
712 m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries); 714 m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries);
713 m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings); 715 m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings);
714 m_dontPersistBefore = 716 m_dontPersistBefore =
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 49a3485..2686004 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -1969,6 +1969,11 @@ namespace OpenSim.Region.Framework.Scenes
1969 /// <param name="objectGroup">The group of prims which should be linked to this group</param> 1969 /// <param name="objectGroup">The group of prims which should be linked to this group</param>
1970 public void LinkToGroup(SceneObjectGroup objectGroup) 1970 public void LinkToGroup(SceneObjectGroup objectGroup)
1971 { 1971 {
1972 LinkToGroup(objectGroup, false);
1973 }
1974
1975 public void LinkToGroup(SceneObjectGroup objectGroup, bool insert)
1976 {
1972// m_log.DebugFormat( 1977// m_log.DebugFormat(
1973// "[SCENE OBJECT GROUP]: Linking group with root part {0}, {1} to group with root part {2}, {3}", 1978// "[SCENE OBJECT GROUP]: Linking group with root part {0}, {1} to group with root part {2}, {3}",
1974// objectGroup.RootPart.Name, objectGroup.RootPart.UUID, RootPart.Name, RootPart.UUID); 1979// objectGroup.RootPart.Name, objectGroup.RootPart.UUID, RootPart.Name, RootPart.UUID);
@@ -1979,6 +1984,10 @@ namespace OpenSim.Region.Framework.Scenes
1979 1984
1980 SceneObjectPart linkPart = objectGroup.m_rootPart; 1985 SceneObjectPart linkPart = objectGroup.m_rootPart;
1981 1986
1987 // physics flags from group to be applied to linked parts
1988 bool grpusephys = UsesPhysics;
1989 bool grptemporary = IsTemporary;
1990
1982 Vector3 oldGroupPosition = linkPart.GroupPosition; 1991 Vector3 oldGroupPosition = linkPart.GroupPosition;
1983 Quaternion oldRootRotation = linkPart.RotationOffset; 1992 Quaternion oldRootRotation = linkPart.RotationOffset;
1984 1993
@@ -2002,15 +2011,35 @@ namespace OpenSim.Region.Framework.Scenes
2002 2011
2003 lock (m_parts.SyncRoot) 2012 lock (m_parts.SyncRoot)
2004 { 2013 {
2005 int linkNum = PrimCount + 1; 2014 int linkNum;
2015 if (insert)
2016 {
2017 linkNum = 2;
2018 foreach (SceneObjectPart part in Parts)
2019 {
2020 if (part.LinkNum > 1)
2021 part.LinkNum++;
2022 }
2023 }
2024 else
2025 {
2026 linkNum = PrimCount + 1;
2027 }
2006 2028
2007 m_parts.Add(linkPart.UUID, linkPart); 2029 m_parts.Add(linkPart.UUID, linkPart);
2008 2030
2009 linkPart.SetParent(this); 2031 linkPart.SetParent(this);
2010 linkPart.CreateSelected = true; 2032 linkPart.CreateSelected = true;
2011 2033
2034 // let physics know preserve part volume dtc messy since UpdatePrimFlags doesn't look to parent changes for now
2035 linkPart.UpdatePrimFlags(grpusephys, grptemporary, (IsPhantom || (linkPart.Flags & PrimFlags.Phantom) != 0), linkPart.VolumeDetectActive);
2036 if (linkPart.PhysActor != null && m_rootPart.PhysActor != null && m_rootPart.PhysActor.IsPhysical)
2037 {
2038 linkPart.PhysActor.link(m_rootPart.PhysActor);
2039 this.Scene.PhysicsScene.AddPhysicsActorTaint(linkPart.PhysActor);
2040 }
2041
2012 linkPart.LinkNum = linkNum++; 2042 linkPart.LinkNum = linkNum++;
2013 linkPart.UpdatePrimFlags(UsesPhysics, IsTemporary, IsPhantom, IsVolumeDetect);
2014 2043
2015 SceneObjectPart[] ogParts = objectGroup.Parts; 2044 SceneObjectPart[] ogParts = objectGroup.Parts;
2016 Array.Sort(ogParts, delegate(SceneObjectPart a, SceneObjectPart b) 2045 Array.Sort(ogParts, delegate(SceneObjectPart a, SceneObjectPart b)
@@ -2022,7 +2051,16 @@ namespace OpenSim.Region.Framework.Scenes
2022 { 2051 {
2023 SceneObjectPart part = ogParts[i]; 2052 SceneObjectPart part = ogParts[i];
2024 if (part.UUID != objectGroup.m_rootPart.UUID) 2053 if (part.UUID != objectGroup.m_rootPart.UUID)
2054 {
2025 LinkNonRootPart(part, oldGroupPosition, oldRootRotation, linkNum++); 2055 LinkNonRootPart(part, oldGroupPosition, oldRootRotation, linkNum++);
2056 // let physics know
2057 part.UpdatePrimFlags(grpusephys, grptemporary, (IsPhantom || (part.Flags & PrimFlags.Phantom) != 0), part.VolumeDetectActive);
2058 if (part.PhysActor != null && m_rootPart.PhysActor != null && m_rootPart.PhysActor.IsPhysical)
2059 {
2060 part.PhysActor.link(m_rootPart.PhysActor);
2061 this.Scene.PhysicsScene.AddPhysicsActorTaint(part.PhysActor);
2062 }
2063 }
2026 part.ClearUndoState(); 2064 part.ClearUndoState();
2027 } 2065 }
2028 } 2066 }
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index b5f789b..e8178ce 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -990,23 +990,24 @@ namespace OpenSim.Region.Framework.Scenes
990 /// <param name="pos"></param> 990 /// <param name="pos"></param>
991 public void Teleport(Vector3 pos) 991 public void Teleport(Vector3 pos)
992 { 992 {
993 bool isFlying = Flying; 993 TeleportWithMomentum(pos, null);
994 RemoveFromPhysicalScene();
995 Velocity = Vector3.Zero;
996 CheckLandingPoint(ref pos);
997 AbsolutePosition = pos;
998 AddToPhysicalScene(isFlying);
999
1000 SendTerseUpdateToAllClients();
1001 } 994 }
1002 995
1003 public void TeleportWithMomentum(Vector3 pos) 996 public void TeleportWithMomentum(Vector3 pos, Vector3? v)
1004 { 997 {
1005 bool isFlying = Flying; 998 bool isFlying = Flying;
999 Vector3 vel = Velocity;
1006 RemoveFromPhysicalScene(); 1000 RemoveFromPhysicalScene();
1007 CheckLandingPoint(ref pos); 1001 CheckLandingPoint(ref pos);
1008 AbsolutePosition = pos; 1002 AbsolutePosition = pos;
1009 AddToPhysicalScene(isFlying); 1003 AddToPhysicalScene(isFlying);
1004 if (PhysicsActor != null)
1005 {
1006 if (v.HasValue)
1007 PhysicsActor.SetMomentum((Vector3)v);
1008 else
1009 PhysicsActor.SetMomentum(vel);
1010 }
1010 1011
1011 SendTerseUpdateToAllClients(); 1012 SendTerseUpdateToAllClients();
1012 } 1013 }
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs
index bebc10c..eb7bfbd 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs
@@ -33,6 +33,7 @@ using OpenMetaverse;
33using OpenSim.Framework; 33using OpenSim.Framework;
34using OpenSim.Framework.Communications; 34using OpenSim.Framework.Communications;
35using OpenSim.Framework.Servers; 35using OpenSim.Framework.Servers;
36using OpenSim.Region.CoreModules.Framework.EntityTransfer;
36using OpenSim.Region.Framework.Interfaces; 37using OpenSim.Region.Framework.Interfaces;
37using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; 38using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation;
38using OpenSim.Tests.Common; 39using OpenSim.Tests.Common;
@@ -47,6 +48,41 @@ namespace OpenSim.Region.Framework.Scenes.Tests
47 [TestFixture] 48 [TestFixture]
48 public class ScenePresenceTeleportTests 49 public class ScenePresenceTeleportTests
49 { 50 {
51 [Test]
52 public void TestSameRegionTeleport()
53 {
54 TestHelpers.InMethod();
55// log4net.Config.XmlConfigurator.Configure();
56
57 EntityTransferModule etm = new EntityTransferModule();
58
59 IConfigSource config = new IniConfigSource();
60 config.AddConfig("Modules");
61 // Not strictly necessary since FriendsModule assumes it is the default (!)
62 config.Configs["Modules"].Set("EntityTransferModule", etm.Name);
63
64 TestScene scene = SceneHelpers.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
65 SceneHelpers.SetupSceneModules(scene, config, etm);
66
67 Vector3 teleportPosition = new Vector3(10, 11, 12);
68 Vector3 teleportLookAt = new Vector3(20, 21, 22);
69
70 ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1));
71 sp.AbsolutePosition = new Vector3(30, 31, 32);
72 scene.RequestTeleportLocation(
73 sp.ControllingClient,
74 scene.RegionInfo.RegionHandle,
75 teleportPosition,
76 teleportLookAt,
77 (uint)TeleportFlags.ViaLocation);
78
79 Assert.That(sp.AbsolutePosition, Is.EqualTo(teleportPosition));
80
81 // Lookat is sent to the client only - sp.Lookat does not yield the same thing (calculation from camera
82 // position instead).
83// Assert.That(sp.Lookat, Is.EqualTo(teleportLookAt));
84 }
85
50 /// <summary> 86 /// <summary>
51 /// Test a teleport between two regions that are not neighbours and do not share any neighbours in common. 87 /// Test a teleport between two regions that are not neighbours and do not share any neighbours in common.
52 /// </summary> 88 /// </summary>
diff --git a/OpenSim/Region/OptionalModules/Avatar/Friends/FriendsCommandsModule.cs b/OpenSim/Region/OptionalModules/Avatar/Friends/FriendsCommandsModule.cs
index e68f9d0..2602050 100644
--- a/OpenSim/Region/OptionalModules/Avatar/Friends/FriendsCommandsModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/Friends/FriendsCommandsModule.cs
@@ -58,6 +58,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Friends
58 private Scene m_scene; 58 private Scene m_scene;
59 private IFriendsModule m_friendsModule; 59 private IFriendsModule m_friendsModule;
60 private IUserManagement m_userManagementModule; 60 private IUserManagement m_userManagementModule;
61 private IPresenceService m_presenceService;
61 62
62// private IAvatarFactoryModule m_avatarFactory; 63// private IAvatarFactoryModule m_avatarFactory;
63 64
@@ -99,8 +100,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.Friends
99 100
100 m_friendsModule = m_scene.RequestModuleInterface<IFriendsModule>(); 101 m_friendsModule = m_scene.RequestModuleInterface<IFriendsModule>();
101 m_userManagementModule = m_scene.RequestModuleInterface<IUserManagement>(); 102 m_userManagementModule = m_scene.RequestModuleInterface<IUserManagement>();
103 m_presenceService = m_scene.RequestModuleInterface<IPresenceService>();
102 104
103 if (m_friendsModule != null && m_userManagementModule != null) 105 if (m_friendsModule != null && m_userManagementModule != null && m_presenceService != null)
104 { 106 {
105 m_scene.AddCommand( 107 m_scene.AddCommand(
106 "Friends", this, "friends show", 108 "Friends", this, "friends show",
@@ -162,7 +164,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.Friends
162 164
163 MainConsole.Instance.OutputFormat("Friends for {0} {1} {2}:", firstName, lastName, userId); 165 MainConsole.Instance.OutputFormat("Friends for {0} {1} {2}:", firstName, lastName, userId);
164 166
165 MainConsole.Instance.OutputFormat("UUID, Name, MyFlags, TheirFlags"); 167 MainConsole.Instance.OutputFormat(
168 "{0,-36} {1,-36} {2,-7} {3,7} {4,10}", "UUID", "Name", "Status", "MyFlags", "TheirFlags");
166 169
167 foreach (FriendInfo friend in friends) 170 foreach (FriendInfo friend in friends)
168 { 171 {
@@ -175,14 +178,22 @@ namespace OpenSim.Region.OptionalModules.Avatar.Friends
175 178
176 UUID friendId; 179 UUID friendId;
177 string friendName; 180 string friendName;
181 string onlineText;
178 182
179 if (UUID.TryParse(friend.Friend, out friendId)) 183 if (UUID.TryParse(friend.Friend, out friendId))
180 friendName = m_userManagementModule.GetUserName(friendId); 184 friendName = m_userManagementModule.GetUserName(friendId);
181 else 185 else
182 friendName = friend.Friend; 186 friendName = friend.Friend;
183 187
188 OpenSim.Services.Interfaces.PresenceInfo[] pi = m_presenceService.GetAgents(new string[] { friend.Friend });
189 if (pi.Length > 0)
190 onlineText = "online";
191 else
192 onlineText = "offline";
193
184 MainConsole.Instance.OutputFormat( 194 MainConsole.Instance.OutputFormat(
185 "{0} {1} {2} {3}", friend.Friend, friendName, friend.MyFlags, friend.TheirFlags); 195 "{0,-36} {1,-36} {2,-7} {3,-7} {4,-10}",
196 friend.Friend, friendName, onlineText, friend.MyFlags, friend.TheirFlags);
186 } 197 }
187 } 198 }
188 } 199 }
diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs
index eda2aef..4949097 100644
--- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs
@@ -163,28 +163,37 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
163 return; 163 return;
164 } 164 }
165 165
166 m_comms.RegisterScriptInvocation(this,"JsonCreateStore"); 166 try
167 m_comms.RegisterScriptInvocation(this,"JsonDestroyStore"); 167 {
168 m_comms.RegisterScriptInvocation(this,"JsonCreateStore");
169 m_comms.RegisterScriptInvocation(this,"JsonDestroyStore");
168 170
169 m_comms.RegisterScriptInvocation(this,"JsonReadNotecard"); 171 m_comms.RegisterScriptInvocation(this,"JsonReadNotecard");
170 m_comms.RegisterScriptInvocation(this,"JsonWriteNotecard"); 172 m_comms.RegisterScriptInvocation(this,"JsonWriteNotecard");
171 173
172 m_comms.RegisterScriptInvocation(this,"JsonTestPath"); 174 m_comms.RegisterScriptInvocation(this,"JsonTestPath");
173 m_comms.RegisterScriptInvocation(this,"JsonTestPathJson"); 175 m_comms.RegisterScriptInvocation(this,"JsonTestPathJson");
174 176
175 m_comms.RegisterScriptInvocation(this,"JsonGetValue"); 177 m_comms.RegisterScriptInvocation(this,"JsonGetValue");
176 m_comms.RegisterScriptInvocation(this,"JsonGetValueJson"); 178 m_comms.RegisterScriptInvocation(this,"JsonGetValueJson");
177 179
178 m_comms.RegisterScriptInvocation(this,"JsonTakeValue"); 180 m_comms.RegisterScriptInvocation(this,"JsonTakeValue");
179 m_comms.RegisterScriptInvocation(this,"JsonTakeValueJson"); 181 m_comms.RegisterScriptInvocation(this,"JsonTakeValueJson");
180 182
181 m_comms.RegisterScriptInvocation(this,"JsonReadValue"); 183 m_comms.RegisterScriptInvocation(this,"JsonReadValue");
182 m_comms.RegisterScriptInvocation(this,"JsonReadValueJson"); 184 m_comms.RegisterScriptInvocation(this,"JsonReadValueJson");
183 185
184 m_comms.RegisterScriptInvocation(this,"JsonSetValue"); 186 m_comms.RegisterScriptInvocation(this,"JsonSetValue");
185 m_comms.RegisterScriptInvocation(this,"JsonSetValueJson"); 187 m_comms.RegisterScriptInvocation(this,"JsonSetValueJson");
186 188
187 m_comms.RegisterScriptInvocation(this,"JsonRemoveValue"); 189 m_comms.RegisterScriptInvocation(this,"JsonRemoveValue");
190 }
191 catch (Exception e)
192 {
193 // See http://opensimulator.org/mantis/view.php?id=5971 for more information
194 m_log.WarnFormat("[JsonStroreScripts] script method registration failed; {0}",e.Message);
195 m_enabled = false;
196 }
188 } 197 }
189 } 198 }
190 199
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs
index 922eaaf..d192309 100644
--- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs
@@ -68,7 +68,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
68 public Vector3 WorldPosition 68 public Vector3 WorldPosition
69 { 69 {
70 get { return GetSP().AbsolutePosition; } 70 get { return GetSP().AbsolutePosition; }
71 set { GetSP().TeleportWithMomentum(value); } 71 set { GetSP().Teleport(value); }
72 } 72 }
73 73
74 public bool IsChildAgent 74 public bool IsChildAgent
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
index adc6f9c..3ac1eb1 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
@@ -157,7 +157,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
157 157
158 sp.CompleteMovement(npcAvatar, false); 158 sp.CompleteMovement(npcAvatar, false);
159 m_avatars.Add(npcAvatar.AgentId, npcAvatar); 159 m_avatars.Add(npcAvatar.AgentId, npcAvatar);
160 m_log.DebugFormat("[NPC MODULE]: Created NPC with id {0}", npcAvatar.AgentId); 160 m_log.DebugFormat("[NPC MODULE]: Created NPC {0} {1}", npcAvatar.AgentId, sp.Name);
161 161
162 return npcAvatar.AgentId; 162 return npcAvatar.AgentId;
163 } 163 }
@@ -340,7 +340,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
340 scene.RemoveClient(agentID, false); 340 scene.RemoveClient(agentID, false);
341 m_avatars.Remove(agentID); 341 m_avatars.Remove(agentID);
342 342
343// m_log.DebugFormat("[NPC MODULE]: Removed {0} {1}", agentID, av.Name); 343 m_log.DebugFormat("[NPC MODULE]: Removed NPC {0} {1}", agentID, av.Name);
344 return true; 344 return true;
345 } 345 }
346 } 346 }
diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
index 3f88353..0716214 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
@@ -338,6 +338,7 @@ namespace OpenSim.Region.Physics.OdePlugin
338 d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags); 338 d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags);
339 339
340 _parent_scene.geom_name_map[prim_geom] = Name; 340 _parent_scene.geom_name_map[prim_geom] = Name;
341 _parent_scene.actor_name_map[prim_geom] = this;
341 342
342 if (childPrim) 343 if (childPrim)
343 { 344 {
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/ApiManager.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/ApiManager.cs
index 47ed6ba..684138f 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/ApiManager.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/ApiManager.cs
@@ -29,42 +29,43 @@ using System;
29using System.Collections; 29using System.Collections;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Reflection; 31using System.Reflection;
32using log4net;
32using OpenSim.Region.ScriptEngine.Interfaces; 33using OpenSim.Region.ScriptEngine.Interfaces;
33 34
34namespace OpenSim.Region.ScriptEngine.Shared.Api 35namespace OpenSim.Region.ScriptEngine.Shared.Api
35{ 36{
36 public class ApiManager 37 public class ApiManager
37 { 38 {
39// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
40
38 private Dictionary<string,Type> m_Apis = new Dictionary<string,Type>(); 41 private Dictionary<string,Type> m_Apis = new Dictionary<string,Type>();
39 42
40 public string[] GetApis() 43 public string[] GetApis()
41 { 44 {
42 if (m_Apis.Count > 0) 45 if (m_Apis.Count <= 0)
43 { 46 {
44 List<string> l = new List<string>(m_Apis.Keys); 47 Assembly a = Assembly.GetExecutingAssembly();
45 return l.ToArray();
46 }
47 48
48 Assembly a = Assembly.GetExecutingAssembly(); 49 Type[] types = a.GetExportedTypes();
49 50
50 Type[] types = a.GetExportedTypes(); 51 foreach (Type t in types)
51
52 foreach (Type t in types)
53 {
54 string name = t.ToString();
55 int idx = name.LastIndexOf('.');
56 if (idx != -1)
57 name = name.Substring(idx+1);
58
59 if (name.EndsWith("_Api"))
60 { 52 {
61 name = name.Substring(0, name.Length - 4); 53 string name = t.ToString();
62 m_Apis[name] = t; 54 int idx = name.LastIndexOf('.');
55 if (idx != -1)
56 name = name.Substring(idx+1);
57
58 if (name.EndsWith("_Api"))
59 {
60 name = name.Substring(0, name.Length - 4);
61 m_Apis[name] = t;
62 }
63 } 63 }
64 } 64 }
65 65
66 List<string> ret = new List<string>(m_Apis.Keys); 66// m_log.DebugFormat("[API MANAGER]: Found {0} apis", m_Apis.Keys.Count);
67 return ret.ToArray(); 67
68 return new List<string>(m_Apis.Keys).ToArray();
68 } 69 }
69 70
70 public IScriptApi CreateApi(string api) 71 public IScriptApi CreateApi(string api)
@@ -76,4 +77,4 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
76 return ret; 77 return ret;
77 } 78 }
78 } 79 }
79} 80} \ No newline at end of file
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index a2176ba..d641958 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -85,7 +85,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
85 protected IScriptEngine m_ScriptEngine; 85 protected IScriptEngine m_ScriptEngine;
86 protected SceneObjectPart m_host; 86 protected SceneObjectPart m_host;
87 protected uint m_localID; 87 protected uint m_localID;
88
89 /// <summary>
90 /// The UUID of the item that hosts this script
91 /// </summary>
88 protected UUID m_itemID; 92 protected UUID m_itemID;
93
89 protected bool throwErrorOnNotImplemented = true; 94 protected bool throwErrorOnNotImplemented = true;
90 protected AsyncCommandManager AsyncCommands = null; 95 protected AsyncCommandManager AsyncCommands = null;
91 protected float m_ScriptDelayFactor = 1.0f; 96 protected float m_ScriptDelayFactor = 1.0f;
@@ -267,23 +272,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
267 } 272 }
268 } 273 }
269 274
270 protected UUID InventorySelf() 275 /// <summary>
276 /// Get the inventory item that hosts ourselves.
277 /// </summary>
278 /// <remarks>
279 /// FIXME: It would be far easier to pass in TaskInventoryItem rather than just m_itemID so that we don't need
280 /// to keep looking ourselves up.
281 /// </remarks>
282 /// <returns></returns>
283 protected TaskInventoryItem GetSelfInventoryItem()
271 { 284 {
272 UUID invItemID = new UUID();
273
274 lock (m_host.TaskInventory) 285 lock (m_host.TaskInventory)
275 { 286 return m_host.TaskInventory[m_itemID];
276 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
277 {
278 if (inv.Value.Type == 10 && inv.Value.ItemID == m_itemID)
279 {
280 invItemID = inv.Key;
281 break;
282 }
283 }
284 }
285
286 return invItemID;
287 } 287 }
288 288
289 protected UUID InventoryKey(string name, int type) 289 protected UUID InventoryKey(string name, int type)
@@ -832,8 +832,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
832 832
833 public void llRegionSayTo(string target, int channel, string msg) 833 public void llRegionSayTo(string target, int channel, string msg)
834 { 834 {
835 string error = String.Empty;
836
837 if (msg.Length > 1023) 835 if (msg.Length > 1023)
838 msg = msg.Substring(0, 1023); 836 msg = msg.Substring(0, 1023);
839 837
@@ -2701,18 +2699,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2701 2699
2702 public LSL_Integer llGiveMoney(string destination, int amount) 2700 public LSL_Integer llGiveMoney(string destination, int amount)
2703 { 2701 {
2704 UUID invItemID=InventorySelf();
2705 if (invItemID == UUID.Zero)
2706 return 0;
2707
2708 m_host.AddScriptLPS(1); 2702 m_host.AddScriptLPS(1);
2709 2703
2710 TaskInventoryItem item = m_host.TaskInventory[invItemID]; 2704 TaskInventoryItem item = GetSelfInventoryItem();
2711
2712 lock (m_host.TaskInventory)
2713 {
2714 item = m_host.TaskInventory[invItemID];
2715 }
2716 2705
2717 if (item.PermsGranter == UUID.Zero) 2706 if (item.PermsGranter == UUID.Zero)
2718 return 0; 2707 return 0;
@@ -2955,15 +2944,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2955 2944
2956 public void llTakeControls(int controls, int accept, int pass_on) 2945 public void llTakeControls(int controls, int accept, int pass_on)
2957 { 2946 {
2958 TaskInventoryItem item; 2947 TaskInventoryItem item = GetSelfInventoryItem();
2959
2960 lock (m_host.TaskInventory)
2961 {
2962 if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
2963 return;
2964 else
2965 item = m_host.TaskInventory[InventorySelf()];
2966 }
2967 2948
2968 if (item.PermsGranter != UUID.Zero) 2949 if (item.PermsGranter != UUID.Zero)
2969 { 2950 {
@@ -2983,18 +2964,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2983 2964
2984 public void llReleaseControls() 2965 public void llReleaseControls()
2985 { 2966 {
2986 TaskInventoryItem item;
2987
2988 lock (m_host.TaskInventory)
2989 {
2990 if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
2991 return;
2992 else
2993 item = m_host.TaskInventory[InventorySelf()];
2994 }
2995
2996 m_host.AddScriptLPS(1); 2967 m_host.AddScriptLPS(1);
2997 2968
2969 TaskInventoryItem item = GetSelfInventoryItem();
2970
2998 if (item.PermsGranter != UUID.Zero) 2971 if (item.PermsGranter != UUID.Zero)
2999 { 2972 {
3000 ScenePresence presence = World.GetScenePresence(item.PermsGranter); 2973 ScenePresence presence = World.GetScenePresence(item.PermsGranter);
@@ -3019,36 +2992,62 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3019 m_UrlModule.ReleaseURL(url); 2992 m_UrlModule.ReleaseURL(url);
3020 } 2993 }
3021 2994
3022 public void llAttachToAvatar(int attachment) 2995 /// <summary>
2996 /// Attach the object containing this script to the avatar that owns it.
2997 /// </summary>
2998 /// <param name='attachment'>The attachment point (e.g. ATTACH_CHEST)</param>
2999 /// <returns>true if the attach suceeded, false if it did not</returns>
3000 public bool AttachToAvatar(int attachmentPoint)
3001 {
3002 SceneObjectGroup grp = m_host.ParentGroup;
3003 ScenePresence presence = World.GetScenePresence(m_host.OwnerID);
3004
3005 IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule;
3006
3007 if (attachmentsModule != null)
3008 return attachmentsModule.AttachObject(presence, grp, (uint)attachmentPoint, false);
3009 else
3010 return false;
3011 }
3012
3013 /// <summary>
3014 /// Detach the object containing this script from the avatar it is attached to.
3015 /// </summary>
3016 /// <remarks>
3017 /// Nothing happens if the object is not attached.
3018 /// </remarks>
3019 public void DetachFromAvatar()
3020 {
3021 Util.FireAndForget(DetachWrapper, m_host);
3022 }
3023
3024 private void DetachWrapper(object o)
3025 {
3026 SceneObjectPart host = (SceneObjectPart)o;
3027
3028 SceneObjectGroup grp = host.ParentGroup;
3029 UUID itemID = grp.FromItemID;
3030 ScenePresence presence = World.GetScenePresence(host.OwnerID);
3031
3032 IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule;
3033 if (attachmentsModule != null)
3034 attachmentsModule.DetachSingleAttachmentToInv(presence, itemID);
3035 }
3036
3037 public void llAttachToAvatar(int attachmentPoint)
3023 { 3038 {
3024 m_host.AddScriptLPS(1); 3039 m_host.AddScriptLPS(1);
3025 3040
3026// if (m_host.ParentGroup.RootPart.AttachmentPoint == 0) 3041// if (m_host.ParentGroup.RootPart.AttachmentPoint == 0)
3027// return; 3042// return;
3028 3043
3029 TaskInventoryItem item; 3044 TaskInventoryItem item = GetSelfInventoryItem();
3030
3031 lock (m_host.TaskInventory)
3032 {
3033 if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
3034 return;
3035 else
3036 item = m_host.TaskInventory[InventorySelf()];
3037 }
3038 3045
3039 if (item.PermsGranter != m_host.OwnerID) 3046 if (item.PermsGranter != m_host.OwnerID)
3040 return; 3047 return;
3041 3048
3042 if ((item.PermsMask & ScriptBaseClass.PERMISSION_ATTACH) != 0) 3049 if ((item.PermsMask & ScriptBaseClass.PERMISSION_ATTACH) != 0)
3043 { 3050 AttachToAvatar(attachmentPoint);
3044 SceneObjectGroup grp = m_host.ParentGroup;
3045
3046 ScenePresence presence = World.GetScenePresence(m_host.OwnerID);
3047
3048 IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule;
3049 if (attachmentsModule != null)
3050 attachmentsModule.AttachObject(presence, grp, (uint)attachment, false);
3051 }
3052 } 3051 }
3053 3052
3054 public void llDetachFromAvatar() 3053 public void llDetachFromAvatar()
@@ -3058,38 +3057,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3058 if (m_host.ParentGroup.AttachmentPoint == 0) 3057 if (m_host.ParentGroup.AttachmentPoint == 0)
3059 return; 3058 return;
3060 3059
3061 TaskInventoryItem item; 3060 TaskInventoryItem item = GetSelfInventoryItem();
3062
3063 lock (m_host.TaskInventory)
3064 {
3065 if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
3066 return;
3067 else
3068 item = m_host.TaskInventory[InventorySelf()];
3069 }
3070 3061
3071 if (item.PermsGranter != m_host.OwnerID) 3062 if (item.PermsGranter != m_host.OwnerID)
3072 return; 3063 return;
3073 3064
3074 if ((item.PermsMask & ScriptBaseClass.PERMISSION_ATTACH) != 0) 3065 if ((item.PermsMask & ScriptBaseClass.PERMISSION_ATTACH) != 0)
3075 { 3066 DetachFromAvatar();
3076 IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule;
3077 if (attachmentsModule != null)
3078 Util.FireAndForget(DetachWrapper, m_host);
3079 }
3080 }
3081
3082 private void DetachWrapper(object o)
3083 {
3084 SceneObjectPart host = (SceneObjectPart)o;
3085
3086 SceneObjectGroup grp = host.ParentGroup;
3087 UUID itemID = grp.FromItemID;
3088 ScenePresence presence = World.GetScenePresence(host.OwnerID);
3089
3090 IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule;
3091 if (attachmentsModule != null)
3092 attachmentsModule.DetachSingleAttachmentToInv(presence, itemID);
3093 } 3067 }
3094 3068
3095 public void llTakeCamera(string avatar) 3069 public void llTakeCamera(string avatar)
@@ -3317,19 +3291,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3317 { 3291 {
3318 m_host.AddScriptLPS(1); 3292 m_host.AddScriptLPS(1);
3319 3293
3320 UUID invItemID = InventorySelf(); 3294 TaskInventoryItem item = GetSelfInventoryItem();
3321 if (invItemID == UUID.Zero)
3322 return;
3323
3324 TaskInventoryItem item;
3325
3326 lock (m_host.TaskInventory)
3327 {
3328 if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
3329 return;
3330 else
3331 item = m_host.TaskInventory[InventorySelf()];
3332 }
3333 3295
3334 if (item.PermsGranter == UUID.Zero) 3296 if (item.PermsGranter == UUID.Zero)
3335 return; 3297 return;
@@ -3354,19 +3316,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3354 { 3316 {
3355 m_host.AddScriptLPS(1); 3317 m_host.AddScriptLPS(1);
3356 3318
3357 UUID invItemID=InventorySelf(); 3319 TaskInventoryItem item = GetSelfInventoryItem();
3358 if (invItemID == UUID.Zero)
3359 return;
3360
3361 TaskInventoryItem item;
3362
3363 lock (m_host.TaskInventory)
3364 {
3365 if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
3366 return;
3367 else
3368 item = m_host.TaskInventory[InventorySelf()];
3369 }
3370 3320
3371 if (item.PermsGranter == UUID.Zero) 3321 if (item.PermsGranter == UUID.Zero)
3372 return; 3322 return;
@@ -3421,22 +3371,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3421 3371
3422 public void llRequestPermissions(string agent, int perm) 3372 public void llRequestPermissions(string agent, int perm)
3423 { 3373 {
3424 UUID agentID = new UUID(); 3374 UUID agentID;
3425 3375
3426 if (!UUID.TryParse(agent, out agentID)) 3376 if (!UUID.TryParse(agent, out agentID))
3427 return; 3377 return;
3428 3378
3429 UUID invItemID = InventorySelf(); 3379 TaskInventoryItem item = GetSelfInventoryItem();
3430
3431 if (invItemID == UUID.Zero)
3432 return; // Not in a prim? How??
3433
3434 TaskInventoryItem item;
3435
3436 lock (m_host.TaskInventory)
3437 {
3438 item = m_host.TaskInventory[invItemID];
3439 }
3440 3380
3441 if (agentID == UUID.Zero || perm == 0) // Releasing permissions 3381 if (agentID == UUID.Zero || perm == 0) // Releasing permissions
3442 { 3382 {
@@ -3470,8 +3410,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3470 { 3410 {
3471 lock (m_host.TaskInventory) 3411 lock (m_host.TaskInventory)
3472 { 3412 {
3473 m_host.TaskInventory[invItemID].PermsGranter = agentID; 3413 m_host.TaskInventory[m_itemID].PermsGranter = agentID;
3474 m_host.TaskInventory[invItemID].PermsMask = perm; 3414 m_host.TaskInventory[m_itemID].PermsMask = perm;
3475 } 3415 }
3476 3416
3477 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( 3417 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams(
@@ -3494,8 +3434,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3494 { 3434 {
3495 lock (m_host.TaskInventory) 3435 lock (m_host.TaskInventory)
3496 { 3436 {
3497 m_host.TaskInventory[invItemID].PermsGranter = agentID; 3437 m_host.TaskInventory[m_itemID].PermsGranter = agentID;
3498 m_host.TaskInventory[invItemID].PermsMask = perm; 3438 m_host.TaskInventory[m_itemID].PermsMask = perm;
3499 } 3439 }
3500 3440
3501 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( 3441 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams(
@@ -3519,8 +3459,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3519 { 3459 {
3520 lock (m_host.TaskInventory) 3460 lock (m_host.TaskInventory)
3521 { 3461 {
3522 m_host.TaskInventory[invItemID].PermsGranter = agentID; 3462 m_host.TaskInventory[m_itemID].PermsGranter = agentID;
3523 m_host.TaskInventory[invItemID].PermsMask = 0; 3463 m_host.TaskInventory[m_itemID].PermsMask = 0;
3524 } 3464 }
3525 3465
3526 presence.ControllingClient.OnScriptAnswer += handleScriptAnswer; 3466 presence.ControllingClient.OnScriptAnswer += handleScriptAnswer;
@@ -3528,7 +3468,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3528 } 3468 }
3529 3469
3530 presence.ControllingClient.SendScriptQuestion( 3470 presence.ControllingClient.SendScriptQuestion(
3531 m_host.UUID, m_host.ParentGroup.RootPart.Name, ownerName, invItemID, perm); 3471 m_host.UUID, m_host.ParentGroup.RootPart.Name, ownerName, m_itemID, perm);
3532 3472
3533 return; 3473 return;
3534 } 3474 }
@@ -3545,20 +3485,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3545 if (taskID != m_host.UUID) 3485 if (taskID != m_host.UUID)
3546 return; 3486 return;
3547 3487
3548 UUID invItemID = InventorySelf(); 3488 client.OnScriptAnswer -= handleScriptAnswer;
3549 3489 m_waitingForScriptAnswer = false;
3550 if (invItemID == UUID.Zero)
3551 return;
3552
3553 client.OnScriptAnswer-=handleScriptAnswer;
3554 m_waitingForScriptAnswer=false;
3555 3490
3556 if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) 3491 if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0)
3557 llReleaseControls(); 3492 llReleaseControls();
3558 3493
3559 lock (m_host.TaskInventory) 3494 lock (m_host.TaskInventory)
3560 { 3495 {
3561 m_host.TaskInventory[invItemID].PermsMask = answer; 3496 m_host.TaskInventory[m_itemID].PermsMask = answer;
3562 } 3497 }
3563 3498
3564 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( 3499 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams(
@@ -3571,39 +3506,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3571 { 3506 {
3572 m_host.AddScriptLPS(1); 3507 m_host.AddScriptLPS(1);
3573 3508
3574 lock (m_host.TaskInventory) 3509 return GetSelfInventoryItem().PermsGranter.ToString();
3575 {
3576 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
3577 {
3578 if (item.Type == 10 && item.ItemID == m_itemID)
3579 {
3580 return item.PermsGranter.ToString();
3581 }
3582 }
3583 }
3584
3585 return UUID.Zero.ToString();
3586 } 3510 }
3587 3511
3588 public LSL_Integer llGetPermissions() 3512 public LSL_Integer llGetPermissions()
3589 { 3513 {
3590 m_host.AddScriptLPS(1); 3514 m_host.AddScriptLPS(1);
3591 3515
3592 lock (m_host.TaskInventory) 3516 int perms = GetSelfInventoryItem().PermsMask;
3593 {
3594 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
3595 {
3596 if (item.Type == 10 && item.ItemID == m_itemID)
3597 {
3598 int perms = item.PermsMask;
3599 if (m_automaticLinkPermission)
3600 perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS;
3601 return perms;
3602 }
3603 }
3604 }
3605 3517
3606 return 0; 3518 if (m_automaticLinkPermission)
3519 perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS;
3520
3521 return perms;
3607 } 3522 }
3608 3523
3609 public LSL_Integer llGetLinkNumber() 3524 public LSL_Integer llGetLinkNumber()
@@ -3631,17 +3546,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3631 public void llCreateLink(string target, int parent) 3546 public void llCreateLink(string target, int parent)
3632 { 3547 {
3633 m_host.AddScriptLPS(1); 3548 m_host.AddScriptLPS(1);
3634 UUID invItemID = InventorySelf();
3635 UUID targetID; 3549 UUID targetID;
3636 3550
3637 if (!UUID.TryParse(target, out targetID)) 3551 if (!UUID.TryParse(target, out targetID))
3638 return; 3552 return;
3639 3553
3640 TaskInventoryItem item; 3554 TaskInventoryItem item = GetSelfInventoryItem();
3641 lock (m_host.TaskInventory)
3642 {
3643 item = m_host.TaskInventory[invItemID];
3644 }
3645 3555
3646 if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 3556 if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0
3647 && !m_automaticLinkPermission) 3557 && !m_automaticLinkPermission)
@@ -3659,11 +3569,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3659 3569
3660 if (targetPart.ParentGroup.AttachmentPoint != 0) 3570 if (targetPart.ParentGroup.AttachmentPoint != 0)
3661 return; // Fail silently if attached 3571 return; // Fail silently if attached
3572
3573 if (targetPart.ParentGroup.RootPart.OwnerID != m_host.ParentGroup.RootPart.OwnerID)
3574 return;
3575
3662 SceneObjectGroup parentPrim = null, childPrim = null; 3576 SceneObjectGroup parentPrim = null, childPrim = null;
3663 3577
3664 if (targetPart != null) 3578 if (targetPart != null)
3665 { 3579 {
3666 if (parent != 0) { 3580 if (parent != 0)
3581 {
3667 parentPrim = m_host.ParentGroup; 3582 parentPrim = m_host.ParentGroup;
3668 childPrim = targetPart.ParentGroup; 3583 childPrim = targetPart.ParentGroup;
3669 } 3584 }
@@ -3675,7 +3590,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3675 3590
3676 // Required for linking 3591 // Required for linking
3677 childPrim.RootPart.ClearUpdateSchedule(); 3592 childPrim.RootPart.ClearUpdateSchedule();
3678 parentPrim.LinkToGroup(childPrim); 3593 parentPrim.LinkToGroup(childPrim, true);
3679 } 3594 }
3680 3595
3681 parentPrim.TriggerScriptChangedEvent(Changed.LINK); 3596 parentPrim.TriggerScriptChangedEvent(Changed.LINK);
@@ -3692,16 +3607,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3692 public void llBreakLink(int linknum) 3607 public void llBreakLink(int linknum)
3693 { 3608 {
3694 m_host.AddScriptLPS(1); 3609 m_host.AddScriptLPS(1);
3695 UUID invItemID = InventorySelf();
3696 3610
3697 lock (m_host.TaskInventory) 3611 if ((GetSelfInventoryItem().PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0
3612 && !m_automaticLinkPermission)
3698 { 3613 {
3699 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 3614 ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!");
3700 && !m_automaticLinkPermission) 3615 return;
3701 {
3702 ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!");
3703 return;
3704 }
3705 } 3616 }
3706 3617
3707 if (linknum < ScriptBaseClass.LINK_THIS) 3618 if (linknum < ScriptBaseClass.LINK_THIS)
@@ -4578,23 +4489,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4578 4489
4579 public LSL_String llGetScriptName() 4490 public LSL_String llGetScriptName()
4580 { 4491 {
4581 string result = String.Empty;
4582
4583 m_host.AddScriptLPS(1); 4492 m_host.AddScriptLPS(1);
4584 4493
4585 lock (m_host.TaskInventory) 4494 TaskInventoryItem item = GetSelfInventoryItem();
4586 {
4587 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
4588 {
4589 if (item.Type == 10 && item.ItemID == m_itemID)
4590 {
4591 result = item.Name != null ? item.Name : String.Empty;
4592 break;
4593 }
4594 }
4595 }
4596 4495
4597 return result; 4496 return item.Name != null ? item.Name : String.Empty;
4598 } 4497 }
4599 4498
4600 public LSL_Integer llGetLinkNumberOfSides(int link) 4499 public LSL_Integer llGetLinkNumberOfSides(int link)
@@ -9695,21 +9594,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9695 public LSL_Vector llGetCameraPos() 9594 public LSL_Vector llGetCameraPos()
9696 { 9595 {
9697 m_host.AddScriptLPS(1); 9596 m_host.AddScriptLPS(1);
9698 UUID invItemID = InventorySelf();
9699 9597
9700 if (invItemID == UUID.Zero) 9598 TaskInventoryItem item = GetSelfInventoryItem();
9701 return new LSL_Vector();
9702 9599
9703 lock (m_host.TaskInventory) 9600 if (item.PermsGranter == UUID.Zero)
9704 { 9601 return new LSL_Vector();
9705 if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero)
9706 return new LSL_Vector();
9707 9602
9708 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) 9603 if ((item.PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0)
9709 { 9604 {
9710 ShoutError("No permissions to track the camera"); 9605 ShoutError("No permissions to track the camera");
9711 return new LSL_Vector(); 9606 return new LSL_Vector();
9712 }
9713 } 9607 }
9714 9608
9715 ScenePresence presence = World.GetScenePresence(m_host.OwnerID); 9609 ScenePresence presence = World.GetScenePresence(m_host.OwnerID);
@@ -9724,20 +9618,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9724 public LSL_Rotation llGetCameraRot() 9618 public LSL_Rotation llGetCameraRot()
9725 { 9619 {
9726 m_host.AddScriptLPS(1); 9620 m_host.AddScriptLPS(1);
9727 UUID invItemID = InventorySelf();
9728 if (invItemID == UUID.Zero)
9729 return new LSL_Rotation();
9730 9621
9731 lock (m_host.TaskInventory) 9622 TaskInventoryItem item = GetSelfInventoryItem();
9732 {
9733 if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero)
9734 return new LSL_Rotation();
9735 9623
9736 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) 9624 if (item.PermsGranter == UUID.Zero)
9737 { 9625 return new LSL_Rotation();
9738 ShoutError("No permissions to track the camera"); 9626
9739 return new LSL_Rotation(); 9627 if ((item.PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0)
9740 } 9628 {
9629 ShoutError("No permissions to track the camera");
9630 return new LSL_Rotation();
9741 } 9631 }
9742 9632
9743 ScenePresence presence = World.GetScenePresence(m_host.OwnerID); 9633 ScenePresence presence = World.GetScenePresence(m_host.OwnerID);
@@ -9911,23 +9801,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9911 { 9801 {
9912 m_host.AddScriptLPS(1); 9802 m_host.AddScriptLPS(1);
9913 9803
9914 // our key in the object we are in
9915 UUID invItemID = InventorySelf();
9916 if (invItemID == UUID.Zero) return;
9917
9918 // the object we are in 9804 // the object we are in
9919 UUID objectID = m_host.ParentUUID; 9805 UUID objectID = m_host.ParentUUID;
9920 if (objectID == UUID.Zero) return; 9806 if (objectID == UUID.Zero)
9807 return;
9921 9808
9922 UUID agentID; 9809 TaskInventoryItem item = GetSelfInventoryItem();
9923 lock (m_host.TaskInventory)
9924 {
9925 // we need the permission first, to know which avatar we want to set the camera for
9926 agentID = m_host.TaskInventory[invItemID].PermsGranter;
9927 9810
9928 if (agentID == UUID.Zero) return; 9811 // we need the permission first, to know which avatar we want to set the camera for
9929 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return; 9812 UUID agentID = item.PermsGranter;
9930 } 9813
9814 if (agentID == UUID.Zero)
9815 return;
9816
9817 if ((item.PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0)
9818 return;
9931 9819
9932 ScenePresence presence = World.GetScenePresence(agentID); 9820 ScenePresence presence = World.GetScenePresence(agentID);
9933 9821
@@ -9967,27 +9855,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9967 { 9855 {
9968 m_host.AddScriptLPS(1); 9856 m_host.AddScriptLPS(1);
9969 9857
9970 // our key in the object we are in
9971 UUID invItemID=InventorySelf();
9972 if (invItemID == UUID.Zero) return;
9973
9974 // the object we are in 9858 // the object we are in
9975 UUID objectID = m_host.ParentUUID; 9859 UUID objectID = m_host.ParentUUID;
9976 if (objectID == UUID.Zero) return; 9860 if (objectID == UUID.Zero)
9861 return;
9862
9863 TaskInventoryItem item = GetSelfInventoryItem();
9977 9864
9978 // we need the permission first, to know which avatar we want to clear the camera for 9865 // we need the permission first, to know which avatar we want to clear the camera for
9979 UUID agentID; 9866 UUID agentID = item.PermsGranter;
9980 lock (m_host.TaskInventory) 9867
9981 { 9868 if (agentID == UUID.Zero)
9982 agentID = m_host.TaskInventory[invItemID].PermsGranter; 9869 return;
9983 if (agentID == UUID.Zero) return; 9870
9984 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return; 9871 if ((item.PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0)
9985 } 9872 return;
9986 9873
9987 ScenePresence presence = World.GetScenePresence(agentID); 9874 ScenePresence presence = World.GetScenePresence(agentID);
9988 9875
9989 // we are not interested in child-agents 9876 // we are not interested in child-agents
9990 if (presence.IsChildAgent) return; 9877 if (presence.IsChildAgent)
9878 return;
9991 9879
9992 presence.ControllingClient.SendClearFollowCamProperties(objectID); 9880 presence.ControllingClient.SendClearFollowCamProperties(objectID);
9993 } 9881 }
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 890115d..893fda1 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -209,6 +209,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
209 throw new Exception("OSSL Runtime Error: " + msg); 209 throw new Exception("OSSL Runtime Error: " + msg);
210 } 210 }
211 211
212 /// <summary>
213 /// Initialize the LSL interface.
214 /// </summary>
215 /// <remarks>
216 /// FIXME: This is an abomination. We should be able to set this up earlier but currently we have no
217 /// guarantee the interface is present on Initialize(). There needs to be another post initialize call from
218 /// ScriptInstance.
219 /// </remarks>
212 private void InitLSL() 220 private void InitLSL()
213 { 221 {
214 if (m_LSL_Api != null) 222 if (m_LSL_Api != null)
@@ -1609,7 +1617,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1609 1617
1610 public Object osParseJSONNew(string JSON) 1618 public Object osParseJSONNew(string JSON)
1611 { 1619 {
1612 CheckThreatLevel(ThreatLevel.None, "osParseJSON"); 1620 CheckThreatLevel(ThreatLevel.None, "osParseJSONNew");
1613 1621
1614 m_host.AddScriptLPS(1); 1622 m_host.AddScriptLPS(1);
1615 1623
@@ -3132,5 +3140,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3132 estate.setEstateTerrainTextureHeights(corner, (float)low, (float)high); 3140 estate.setEstateTerrainTextureHeights(corner, (float)low, (float)high);
3133 } 3141 }
3134 } 3142 }
3143
3144 public void osForceAttachToAvatar(int attachmentPoint)
3145 {
3146 CheckThreatLevel(ThreatLevel.High, "osForceAttachToAvatar");
3147
3148 m_host.AddScriptLPS(1);
3149
3150 InitLSL();
3151 ((LSL_Api)m_LSL_Api).AttachToAvatar(attachmentPoint);
3152 }
3153
3154 public void osForceDetachFromAvatar()
3155 {
3156 CheckThreatLevel(ThreatLevel.High, "osForceDetachFromAvatar");
3157
3158 m_host.AddScriptLPS(1);
3159
3160 InitLSL();
3161 ((LSL_Api)m_LSL_Api).DetachFromAvatar();
3162 }
3135 } 3163 }
3136} \ No newline at end of file 3164} \ No newline at end of file
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
index 2d3e8e8..e92518d 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
@@ -98,6 +98,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
98 void osAvatarPlayAnimation(string avatar, string animation); 98 void osAvatarPlayAnimation(string avatar, string animation);
99 void osAvatarStopAnimation(string avatar, string animation); 99 void osAvatarStopAnimation(string avatar, string animation);
100 100
101 // Attachment commands
102
103 /// <summary>
104 /// Attach the object containing this script to the avatar that owns it without checking for PERMISSION_ATTACH
105 /// </summary>
106 /// <param name='attachment'>The attachment point. For example, ATTACH_CHEST</param>
107 void osForceAttachToAvatar(int attachment);
108
109 /// <summary>
110 /// Detach the object containing this script from the avatar it is attached to without checking for PERMISSION_ATTACH
111 /// </summary>
112 /// <remarks>Nothing happens if the object is not attached.</remarks>
113 void osForceDetachFromAvatar();
114
101 //texture draw functions 115 //texture draw functions
102 string osMovePen(string drawList, int x, int y); 116 string osMovePen(string drawList, int x, int y);
103 string osDrawLine(string drawList, int startX, int startY, int endX, int endY); 117 string osDrawLine(string drawList, int startX, int startY, int endX, int endY);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
index e836959..d230662 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
@@ -289,8 +289,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
289 m_OSSL_Functions.osAvatarStopAnimation(avatar, animation); 289 m_OSSL_Functions.osAvatarStopAnimation(avatar, animation);
290 } 290 }
291 291
292 // Avatar functions
292 293
293 //Texture Draw functions 294 public void osForceAttachToAvatar(int attachmentPoint)
295 {
296 m_OSSL_Functions.osForceAttachToAvatar(attachmentPoint);
297 }
298
299 public void osForceDetachFromAvatar()
300 {
301 m_OSSL_Functions.osForceDetachFromAvatar();
302 }
303
304 // Texture Draw functions
294 305
295 public string osMovePen(string drawList, int x, int y) 306 public string osMovePen(string drawList, int x, int y)
296 { 307 {
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
index 6e36742..2c8af81 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
@@ -964,7 +964,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
964 public IScriptApi GetApi(string name) 964 public IScriptApi GetApi(string name)
965 { 965 {
966 if (m_Apis.ContainsKey(name)) 966 if (m_Apis.ContainsKey(name))
967 {
968// m_log.DebugFormat("[SCRIPT INSTANCE]: Found api {0} in {1}@{2}", name, ScriptName, PrimName);
969
967 return m_Apis[name]; 970 return m_Apis[name];
971 }
972
973// m_log.DebugFormat("[SCRIPT INSTANCE]: Did not find api {0} in {1}@{2}", name, ScriptName, PrimName);
974
968 return null; 975 return null;
969 } 976 }
970 977
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
index 23a4cf9..a9b6e67 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
@@ -1812,9 +1812,11 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1812 // if there already exists a file at that location, it may be locked. 1812 // if there already exists a file at that location, it may be locked.
1813 m_log.ErrorFormat("[XEngine]: File {0} already exists! {1}", path, ex.Message); 1813 m_log.ErrorFormat("[XEngine]: File {0} already exists! {1}", path, ex.Message);
1814 } 1814 }
1815
1816 string textpath = path + ".text";
1815 try 1817 try
1816 { 1818 {
1817 using (FileStream fs = File.Create(path + ".text")) 1819 using (FileStream fs = File.Create(textpath))
1818 { 1820 {
1819 using (StreamWriter sw = new StreamWriter(fs)) 1821 using (StreamWriter sw = new StreamWriter(fs))
1820 { 1822 {
@@ -1827,7 +1829,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1827 catch (IOException ex) 1829 catch (IOException ex)
1828 { 1830 {
1829 // if there already exists a file at that location, it may be locked. 1831 // if there already exists a file at that location, it may be locked.
1830 m_log.ErrorFormat("[XEngine]: File {0} already exists! {1}", path, ex.Message); 1832 m_log.ErrorFormat("[XEngine]: File {0} already exists! {1}", textpath, ex.Message);
1831 } 1833 }
1832 } 1834 }
1833 } 1835 }
@@ -1876,7 +1878,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1876 catch (IOException ex) 1878 catch (IOException ex)
1877 { 1879 {
1878 // if there already exists a file at that location, it may be locked. 1880 // if there already exists a file at that location, it may be locked.
1879 m_log.ErrorFormat("[XEngine]: File {0} already exists! {1}", statepath, ex.Message); 1881 m_log.ErrorFormat("[XEngine]: File {0} already exists! {1}", mappath, ex.Message);
1880 } 1882 }
1881 } 1883 }
1882 1884