aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorMic Bowman2012-04-25 09:52:44 -0700
committerMic Bowman2012-04-25 09:52:44 -0700
commit1afae013111b7c817037371fca805a78c3ab67cc (patch)
treedc4f08217c64fd92f4fac250344f009f583fca4e /OpenSim
parentAdd try/catch around Json script method registration to avoild some issues (diff)
parentSlight rewording of output messages. (diff)
downloadopensim-SC_OLD-1afae013111b7c817037371fca805a78c3ab67cc.zip
opensim-SC_OLD-1afae013111b7c817037371fca805a78c3ab67cc.tar.gz
opensim-SC_OLD-1afae013111b7c817037371fca805a78c3ab67cc.tar.bz2
opensim-SC_OLD-1afae013111b7c817037371fca805a78c3ab67cc.tar.xz
Merge branch 'master' of ssh://opensimulator.org/var/git/opensim
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Data/MySQL/MySQLAuthenticationData.cs23
-rw-r--r--OpenSim/Data/MySQL/MySQLGenericTableHandler.cs6
-rw-r--r--OpenSim/Data/MySQL/MySQLRegionData.cs35
-rw-r--r--OpenSim/Framework/Console/LocalConsole.cs4
-rw-r--r--OpenSim/Framework/OSChatMessage.cs20
-rw-r--r--OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs4
-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/Avatar/Chat/ChatModule.cs52
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs8
-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/Scripting/WorldComm/WorldCommModule.cs70
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs4
-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/Objects/Commands/ObjectCommandsModule.cs2
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GenericSystemDrawing.cs103
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/FileLoaders/JPEG.cs21
-rw-r--r--OpenSim/Region/CoreModules/World/Warp3DMap/MapImageModule.cs4
-rw-r--r--OpenSim/Region/Framework/Interfaces/IWorldComm.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs26
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs14
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneGraph.cs3
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs22
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs18
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs19
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs130
-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/Minimodule/SPAvatar.cs2
-rw-r--r--OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs4
-rw-r--r--OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsActor.cs42
-rw-r--r--OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPrim.cs314
-rw-r--r--OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsScene.cs41
-rw-r--r--OpenSim/Region/Physics/OdePlugin/ODEPrim.cs472
-rw-r--r--OpenSim/Region/Physics/OdePlugin/OdeScene.cs3
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/ApiManager.cs41
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs388
-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.cs20
-rw-r--r--OpenSim/Server/Base/ServerUtils.cs5
-rw-r--r--OpenSim/Services/AvatarService/AvatarService.cs2
-rw-r--r--OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs15
-rw-r--r--OpenSim/Services/LLLoginService/LLLoginResponse.cs26
-rw-r--r--OpenSim/Tests/Common/Helpers/SceneHelpers.cs2
50 files changed, 1393 insertions, 801 deletions
diff --git a/OpenSim/Data/MySQL/MySQLAuthenticationData.cs b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs
index 8d82f61..664ce84 100644
--- a/OpenSim/Data/MySQL/MySQLAuthenticationData.cs
+++ b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs
@@ -79,14 +79,7 @@ namespace OpenSim.Data.MySQL
79 { 79 {
80 ret.PrincipalID = principalID; 80 ret.PrincipalID = principalID;
81 81
82 if (m_ColumnNames == null) 82 CheckColumnNames(result);
83 {
84 m_ColumnNames = new List<string>();
85
86 DataTable schemaTable = result.GetSchemaTable();
87 foreach (DataRow row in schemaTable.Rows)
88 m_ColumnNames.Add(row["ColumnName"].ToString());
89 }
90 83
91 foreach (string s in m_ColumnNames) 84 foreach (string s in m_ColumnNames)
92 { 85 {
@@ -105,6 +98,20 @@ namespace OpenSim.Data.MySQL
105 } 98 }
106 } 99 }
107 100
101 private void CheckColumnNames(IDataReader result)
102 {
103 if (m_ColumnNames != null)
104 return;
105
106 List<string> columnNames = new List<string>();
107
108 DataTable schemaTable = result.GetSchemaTable();
109 foreach (DataRow row in schemaTable.Rows)
110 columnNames.Add(row["ColumnName"].ToString());
111
112 m_ColumnNames = columnNames;
113 }
114
108 public bool Store(AuthenticationData data) 115 public bool Store(AuthenticationData data)
109 { 116 {
110 if (data.Data.ContainsKey("UUID")) 117 if (data.Data.ContainsKey("UUID"))
diff --git a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs
index 754cf72..da8e958 100644
--- a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs
+++ b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs
@@ -91,15 +91,17 @@ namespace OpenSim.Data.MySQL
91 if (m_ColumnNames != null) 91 if (m_ColumnNames != null)
92 return; 92 return;
93 93
94 m_ColumnNames = new List<string>(); 94 List<string> columnNames = new List<string>();
95 95
96 DataTable schemaTable = reader.GetSchemaTable(); 96 DataTable schemaTable = reader.GetSchemaTable();
97 foreach (DataRow row in schemaTable.Rows) 97 foreach (DataRow row in schemaTable.Rows)
98 { 98 {
99 if (row["ColumnName"] != null && 99 if (row["ColumnName"] != null &&
100 (!m_Fields.ContainsKey(row["ColumnName"].ToString()))) 100 (!m_Fields.ContainsKey(row["ColumnName"].ToString())))
101 m_ColumnNames.Add(row["ColumnName"].ToString()); 101 columnNames.Add(row["ColumnName"].ToString());
102 } 102 }
103
104 m_ColumnNames = columnNames;
103 } 105 }
104 106
105 public virtual T[] Get(string field, string key) 107 public virtual T[] Get(string field, string key)
diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs
index c20c392..d1f1932 100644
--- a/OpenSim/Data/MySQL/MySQLRegionData.cs
+++ b/OpenSim/Data/MySQL/MySQLRegionData.cs
@@ -162,17 +162,7 @@ namespace OpenSim.Data.MySQL
162 ret.sizeX = Convert.ToInt32(result["sizeX"]); 162 ret.sizeX = Convert.ToInt32(result["sizeX"]);
163 ret.sizeY = Convert.ToInt32(result["sizeY"]); 163 ret.sizeY = Convert.ToInt32(result["sizeY"]);
164 164
165 if (m_ColumnNames == null) 165 CheckColumnNames(result);
166 {
167 m_ColumnNames = new List<string>();
168
169 DataTable schemaTable = result.GetSchemaTable();
170 foreach (DataRow row in schemaTable.Rows)
171 {
172 if (row["ColumnName"] != null)
173 m_ColumnNames.Add(row["ColumnName"].ToString());
174 }
175 }
176 166
177 foreach (string s in m_ColumnNames) 167 foreach (string s in m_ColumnNames)
178 { 168 {
@@ -187,7 +177,11 @@ namespace OpenSim.Data.MySQL
187 if (s == "locY") 177 if (s == "locY")
188 continue; 178 continue;
189 179
190 ret.Data[s] = result[s].ToString(); 180 object value = result[s];
181 if (value is DBNull)
182 ret.Data[s] = null;
183 else
184 ret.Data[s] = result[s].ToString();
191 } 185 }
192 186
193 retList.Add(ret); 187 retList.Add(ret);
@@ -198,6 +192,23 @@ namespace OpenSim.Data.MySQL
198 return retList; 192 return retList;
199 } 193 }
200 194
195 private void CheckColumnNames(IDataReader result)
196 {
197 if (m_ColumnNames != null)
198 return;
199
200 List<string> columnNames = new List<string>();
201
202 DataTable schemaTable = result.GetSchemaTable();
203 foreach (DataRow row in schemaTable.Rows)
204 {
205 if (row["ColumnName"] != null)
206 columnNames.Add(row["ColumnName"].ToString());
207 }
208
209 m_ColumnNames = columnNames;
210 }
211
201 public bool Store(RegionData data) 212 public bool Store(RegionData data)
202 { 213 {
203 if (data.Data.ContainsKey("uuid")) 214 if (data.Data.ContainsKey("uuid"))
diff --git a/OpenSim/Framework/Console/LocalConsole.cs b/OpenSim/Framework/Console/LocalConsole.cs
index 7c8626d..f65813b 100644
--- a/OpenSim/Framework/Console/LocalConsole.cs
+++ b/OpenSim/Framework/Console/LocalConsole.cs
@@ -296,6 +296,10 @@ namespace OpenSim.Framework.Console
296 matches[0].Groups["Category"].Value); 296 matches[0].Groups["Category"].Value);
297 System.Console.Write("]:"); 297 System.Console.Write("]:");
298 } 298 }
299 else
300 {
301 outText = outText.Trim();
302 }
299 } 303 }
300 304
301 if (level == "error") 305 if (level == "error")
diff --git a/OpenSim/Framework/OSChatMessage.cs b/OpenSim/Framework/OSChatMessage.cs
index 54fa275..455756d 100644
--- a/OpenSim/Framework/OSChatMessage.cs
+++ b/OpenSim/Framework/OSChatMessage.cs
@@ -51,10 +51,12 @@ namespace OpenSim.Framework
51 protected object m_senderObject; 51 protected object m_senderObject;
52 protected ChatTypeEnum m_type; 52 protected ChatTypeEnum m_type;
53 protected UUID m_fromID; 53 protected UUID m_fromID;
54 protected UUID m_toID;
54 55
55 public OSChatMessage() 56 public OSChatMessage()
56 { 57 {
57 m_position = new Vector3(); 58 m_position = new Vector3();
59 m_toID = UUID.Zero;
58 } 60 }
59 61
60 /// <summary> 62 /// <summary>
@@ -102,6 +104,15 @@ namespace OpenSim.Framework
102 set { m_from = value; } 104 set { m_from = value; }
103 } 105 }
104 106
107 /// <summary>
108 /// The name of the sender (needed for scripts)
109 /// </summary>
110 public string To
111 {
112 get { return m_from; }
113 set { m_from = value; }
114 }
115
105 #region IEventArgs Members 116 #region IEventArgs Members
106 117
107 /// TODO: Sender and SenderObject should just be Sender and of 118 /// TODO: Sender and SenderObject should just be Sender and of
@@ -132,6 +143,15 @@ namespace OpenSim.Framework
132 } 143 }
133 144
134 /// <summary> 145 /// <summary>
146 /// The single recipient or all if not set.
147 /// </summary>
148 public UUID TargetUUID
149 {
150 get { return m_toID; }
151 set { m_toID = value; }
152 }
153
154 /// <summary>
135 /// 155 ///
136 /// </summary> 156 /// </summary>
137 public IScene Scene 157 public IScene Scene
diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
index 9d8561b..0fbf90a 100644
--- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
+++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
@@ -662,11 +662,11 @@ namespace OpenSim.Framework.Servers.HttpServer
662 } 662 }
663 catch (IOException e) 663 catch (IOException e)
664 { 664 {
665 m_log.ErrorFormat("[BASE HTTP SERVER]: HandleRequest() threw {0}", e); 665 m_log.ErrorFormat("[BASE HTTP SERVER]: HandleRequest() threw {0}{1}", e.Message, e.StackTrace);
666 } 666 }
667 catch (Exception e) 667 catch (Exception e)
668 { 668 {
669 m_log.ErrorFormat("[BASE HTTP SERVER]: HandleRequest() threw {0}", e.StackTrace); 669 m_log.ErrorFormat("[BASE HTTP SERVER]: HandleRequest() threw {0}{1}", e.Message, e.StackTrace);
670 SendHTML500(response); 670 SendHTML500(response);
671 } 671 }
672 finally 672 finally
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/Avatar/Chat/ChatModule.cs b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs
index 10b4c37..e4452fb 100644
--- a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs
@@ -186,6 +186,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
186 { 186 {
187 string fromName = c.From; 187 string fromName = c.From;
188 UUID fromID = UUID.Zero; 188 UUID fromID = UUID.Zero;
189 UUID targetID = c.TargetUUID;
189 string message = c.Message; 190 string message = c.Message;
190 IScene scene = c.Scene; 191 IScene scene = c.Scene;
191 Vector3 fromPos = c.Position; 192 Vector3 fromPos = c.Position;
@@ -221,24 +222,38 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
221 message = message.Substring(0, 1000); 222 message = message.Substring(0, 1000);
222 223
223// m_log.DebugFormat( 224// m_log.DebugFormat(
224// "[CHAT]: DCTA: fromID {0} fromName {1}, region{2}, cType {3}, sType {4}", 225// "[CHAT]: DCTA: fromID {0} fromName {1}, region{2}, cType {3}, sType {4}, targetID {5}",
225// fromID, fromName, scene.RegionInfo.RegionName, c.Type, sourceType); 226// fromID, fromName, scene.RegionInfo.RegionName, c.Type, sourceType, targetID);
226 227
227 HashSet<UUID> receiverIDs = new HashSet<UUID>(); 228 HashSet<UUID> receiverIDs = new HashSet<UUID>();
228 229
229 foreach (Scene s in m_scenes) 230 foreach (Scene s in m_scenes)
230 { 231 {
231 // This should use ForEachClient, but clients don't have a position. 232 if (targetID == UUID.Zero)
232 // If camera is moved into client, then camera position can be used 233 {
233 s.ForEachRootScenePresence( 234 // This should use ForEachClient, but clients don't have a position.
234 delegate(ScenePresence presence) 235 // If camera is moved into client, then camera position can be used
236 s.ForEachRootScenePresence(
237 delegate(ScenePresence presence)
238 {
239 if (TrySendChatMessage(presence, fromPos, regionPos, fromID, fromName, c.Type, message, sourceType, false))
240 receiverIDs.Add(presence.UUID);
241 }
242 );
243 }
244 else
245 {
246 // This is a send to a specific client eg from llRegionSayTo
247 // no need to check distance etc, jand send is as say
248 ScenePresence presence = s.GetScenePresence(targetID);
249 if (presence != null && !presence.IsChildAgent)
235 { 250 {
236 if (TrySendChatMessage(presence, fromPos, regionPos, fromID, fromName, c.Type, message, sourceType)) 251 if (TrySendChatMessage(presence, fromPos, regionPos, fromID, fromName, ChatTypeEnum.Say, message, sourceType, true))
237 receiverIDs.Add(presence.UUID); 252 receiverIDs.Add(presence.UUID);
238 } 253 }
239 ); 254 }
240 } 255 }
241 256
242 (scene as Scene).EventManager.TriggerOnChatToClients( 257 (scene as Scene).EventManager.TriggerOnChatToClients(
243 fromID, receiverIDs, message, c.Type, fromPos, fromName, sourceType, ChatAudibleLevel.Fully); 258 fromID, receiverIDs, message, c.Type, fromPos, fromName, sourceType, ChatAudibleLevel.Fully);
244 } 259 }
@@ -315,7 +330,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
315 /// precondition</returns> 330 /// precondition</returns>
316 protected virtual bool TrySendChatMessage(ScenePresence presence, Vector3 fromPos, Vector3 regionPos, 331 protected virtual bool TrySendChatMessage(ScenePresence presence, Vector3 fromPos, Vector3 regionPos,
317 UUID fromAgentID, string fromName, ChatTypeEnum type, 332 UUID fromAgentID, string fromName, ChatTypeEnum type,
318 string message, ChatSourceType src) 333 string message, ChatSourceType src, bool ignoreDistance)
319 { 334 {
320 // don't send stuff to child agents 335 // don't send stuff to child agents
321 if (presence.IsChildAgent) return false; 336 if (presence.IsChildAgent) return false;
@@ -326,12 +341,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
326 presence.Scene.RegionInfo.RegionLocY * Constants.RegionSize, 0); 341 presence.Scene.RegionInfo.RegionLocY * Constants.RegionSize, 0);
327 342
328 int dis = (int)Util.GetDistanceTo(toRegionPos, fromRegionPos); 343 int dis = (int)Util.GetDistanceTo(toRegionPos, fromRegionPos);
329 344
330 if (type == ChatTypeEnum.Whisper && dis > m_whisperdistance || 345 if (!ignoreDistance)
331 type == ChatTypeEnum.Say && dis > m_saydistance ||
332 type == ChatTypeEnum.Shout && dis > m_shoutdistance)
333 { 346 {
334 return false; 347 if (type == ChatTypeEnum.Whisper && dis > m_whisperdistance ||
348 type == ChatTypeEnum.Say && dis > m_saydistance ||
349 type == ChatTypeEnum.Shout && dis > m_shoutdistance)
350 {
351 return false;
352 }
335 } 353 }
336 354
337 // TODO: should change so the message is sent through the avatar rather than direct to the ClientView 355 // TODO: should change so the message is sent through the avatar rather than direct to the ClientView
diff --git a/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs b/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs
index d295384..2d4cffd 100644
--- a/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs
@@ -151,11 +151,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Lure
151 Scene scene = (Scene)(client.Scene); 151 Scene scene = (Scene)(client.Scene);
152 ScenePresence presence = scene.GetScenePresence(client.AgentId); 152 ScenePresence presence = scene.GetScenePresence(client.AgentId);
153 153
154 // Round up Z co-ordinate rather than round-down by casting. This stops tall avatars from being given
155 // a teleport Z co-ordinate by short avatars that drops them through or embeds them in thin floors on
156 // arrival.
157 //
158 // Ideally we would give the exact float position adjusting for the relative height of the two avatars
159 // but it looks like a float component isn't possible with a parcel ID.
154 UUID dest = Util.BuildFakeParcelID( 160 UUID dest = Util.BuildFakeParcelID(
155 scene.RegionInfo.RegionHandle, 161 scene.RegionInfo.RegionHandle,
156 (uint)presence.AbsolutePosition.X, 162 (uint)presence.AbsolutePosition.X,
157 (uint)presence.AbsolutePosition.Y, 163 (uint)presence.AbsolutePosition.Y,
158 (uint)presence.AbsolutePosition.Z); 164 (uint)Math.Ceiling(presence.AbsolutePosition.Z));
159 165
160 m_log.DebugFormat("TP invite with message {0}", message); 166 m_log.DebugFormat("TP invite with message {0}", message);
161 167
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/Scripting/WorldComm/WorldCommModule.cs b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs
index 176c86d..8358bc0 100644
--- a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs
+++ b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs
@@ -308,56 +308,56 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
308 /// <param name='msg'> 308 /// <param name='msg'>
309 /// Message. 309 /// Message.
310 /// </param> 310 /// </param>
311 public bool DeliverMessageTo(UUID target, int channel, Vector3 pos, string name, UUID id, string msg, out string error) 311 public void DeliverMessageTo(UUID target, int channel, Vector3 pos, string name, UUID id, string msg)
312 { 312 {
313 error = null;
314 // Is id an avatar? 313 // Is id an avatar?
315 ScenePresence sp = m_scene.GetScenePresence(target); 314 ScenePresence sp = m_scene.GetScenePresence(target);
316 315
317 if (sp != null) 316 if (sp != null)
318 { 317 {
319 // Send message to avatar 318 // ignore if a child agent this is restricted to inside one region
319 if (sp.IsChildAgent)
320 return;
321
322 // Send message to the avatar.
323 // Channel zero only goes to the avatar
324 // non zero channel messages only go to the attachments
320 if (channel == 0) 325 if (channel == 0)
321 { 326 {
322 m_scene.SimChatBroadcast(Utils.StringToBytes(msg), ChatTypeEnum.Broadcast, 0, pos, name, id, false); 327 m_scene.SimChatToAgent(target, Utils.StringToBytes(msg), pos, name, id, false);
323 } 328 }
324 329 else
325 List<SceneObjectGroup> attachments = sp.GetAttachments();
326
327 if (attachments.Count == 0)
328 return true;
329
330 // Get uuid of attachments
331 List<UUID> targets = new List<UUID>();
332 foreach (SceneObjectGroup sog in attachments)
333 { 330 {
334 if (!sog.IsDeleted) 331 List<SceneObjectGroup> attachments = sp.GetAttachments();
335 targets.Add(sog.UUID); 332 if (attachments.Count == 0)
336 } 333 return;
337 334
338 // Need to check each attachment 335 // Get uuid of attachments
339 foreach (ListenerInfo li in m_listenerManager.GetListeners(UUID.Zero, channel, name, id, msg)) 336 List<UUID> targets = new List<UUID>();
340 { 337 foreach (SceneObjectGroup sog in attachments)
341 if (li.GetHostID().Equals(id)) 338 {
342 continue; 339 if (!sog.IsDeleted)
340 targets.Add(sog.UUID);
341 }
343 342
344 if (m_scene.GetSceneObjectPart(li.GetHostID()) == null) 343 // Need to check each attachment
345 continue; 344 foreach (ListenerInfo li in m_listenerManager.GetListeners(UUID.Zero, channel, name, id, msg))
345 {
346 if (li.GetHostID().Equals(id))
347 continue;
346 348
347 if (targets.Contains(li.GetHostID())) 349 if (m_scene.GetSceneObjectPart(li.GetHostID()) == null)
348 QueueMessage(new ListenerInfo(li, name, id, msg)); 350 continue;
349 }
350 351
351 return true; 352 if (targets.Contains(li.GetHostID()))
352 } 353 QueueMessage(new ListenerInfo(li, name, id, msg));
354 }
355 }
353 356
354 // Need to toss an error here 357 return;
355 if (channel == 0)
356 {
357 error = "Cannot use llRegionSayTo to message objects on channel 0";
358 return false;
359 } 358 }
360 359
360 // No avatar found so look for an object
361 foreach (ListenerInfo li in m_listenerManager.GetListeners(UUID.Zero, channel, name, id, msg)) 361 foreach (ListenerInfo li in m_listenerManager.GetListeners(UUID.Zero, channel, name, id, msg))
362 { 362 {
363 // Dont process if this message is from yourself! 363 // Dont process if this message is from yourself!
@@ -375,7 +375,7 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
375 } 375 }
376 } 376 }
377 377
378 return true; 378 return;
379 } 379 }
380 380
381 protected void QueueMessage(ListenerInfo li) 381 protected void QueueMessage(ListenerInfo li)
diff --git a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
index 63f1363..e05e8f6 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
@@ -102,9 +102,9 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
102 PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere(); 102 PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere();
103 Vector3 groupPosition = new Vector3(10, 20, 30); 103 Vector3 groupPosition = new Vector3(10, 20, 30);
104 Quaternion rotationOffset = new Quaternion(20, 30, 40, 50); 104 Quaternion rotationOffset = new Quaternion(20, 30, 40, 50);
105 Vector3 offsetPosition = new Vector3(5, 10, 15); 105// Vector3 offsetPosition = new Vector3(5, 10, 15);
106 106
107 return new SceneObjectPart(ownerId, shape, groupPosition, rotationOffset, offsetPosition) { Name = partName }; 107 return new SceneObjectPart(ownerId, shape, groupPosition, rotationOffset, Vector3.Zero) { Name = partName };
108 } 108 }
109 109
110 protected SceneObjectPart CreateSceneObjectPart2() 110 protected SceneObjectPart CreateSceneObjectPart2()
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/Objects/Commands/ObjectCommandsModule.cs b/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs
index f5a5c92..06fea58 100644
--- a/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs
+++ b/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs
@@ -282,7 +282,7 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
282 sb.AppendFormat("Location: {0} @ {1}\n", sop.AbsolutePosition, sop.ParentGroup.Scene.RegionInfo.RegionName); 282 sb.AppendFormat("Location: {0} @ {1}\n", sop.AbsolutePosition, sop.ParentGroup.Scene.RegionInfo.RegionName);
283 sb.AppendFormat("Parent: {0}", 283 sb.AppendFormat("Parent: {0}",
284 sop.IsRoot ? "Is Root\n" : string.Format("{0} {1}\n", sop.ParentGroup.Name, sop.ParentGroup.UUID)); 284 sop.IsRoot ? "Is Root\n" : string.Format("{0} {1}\n", sop.ParentGroup.Name, sop.ParentGroup.UUID));
285 sb.AppendFormat("Parts: {0}\n", !sop.IsRoot ? "1" : sop.ParentGroup.PrimCount.ToString());; 285 sb.AppendFormat("Link number: {0}\n", sop.LinkNum);
286 286
287 return sb; 287 return sb;
288 } 288 }
diff --git a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GenericSystemDrawing.cs b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GenericSystemDrawing.cs
index da81dc1..d78ade5 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GenericSystemDrawing.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GenericSystemDrawing.cs
@@ -59,28 +59,32 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
59 /// <returns>A terrain channel generated from the image.</returns> 59 /// <returns>A terrain channel generated from the image.</returns>
60 public virtual ITerrainChannel LoadFile(string filename) 60 public virtual ITerrainChannel LoadFile(string filename)
61 { 61 {
62 return LoadBitmap(new Bitmap(filename)); 62 using (Bitmap b = new Bitmap(filename))
63 return LoadBitmap(b);
63 } 64 }
64 65
65 public virtual ITerrainChannel LoadFile(string filename, int offsetX, int offsetY, int fileWidth, int fileHeight, int w, int h) 66 public virtual ITerrainChannel LoadFile(string filename, int offsetX, int offsetY, int fileWidth, int fileHeight, int w, int h)
66 { 67 {
67 Bitmap bitmap = new Bitmap(filename); 68 using (Bitmap bitmap = new Bitmap(filename))
68 ITerrainChannel retval = new TerrainChannel(true);
69
70 for (int x = 0; x < retval.Width; x++)
71 { 69 {
72 for (int y = 0; y < retval.Height; y++) 70 ITerrainChannel retval = new TerrainChannel(true);
71
72 for (int x = 0; x < retval.Width; x++)
73 { 73 {
74 retval[x, y] = bitmap.GetPixel(offsetX * retval.Width + x, (bitmap.Height - (retval.Height * (offsetY + 1))) + retval.Height - y - 1).GetBrightness() * 128; 74 for (int y = 0; y < retval.Height; y++)
75 {
76 retval[x, y] = bitmap.GetPixel(offsetX * retval.Width + x, (bitmap.Height - (retval.Height * (offsetY + 1))) + retval.Height - y - 1).GetBrightness() * 128;
77 }
75 } 78 }
76 }
77 79
78 return retval; 80 return retval;
81 }
79 } 82 }
80 83
81 public virtual ITerrainChannel LoadStream(Stream stream) 84 public virtual ITerrainChannel LoadStream(Stream stream)
82 { 85 {
83 return LoadBitmap(new Bitmap(stream)); 86 using (Bitmap b = new Bitmap(stream))
87 return LoadBitmap(b);
84 } 88 }
85 89
86 protected virtual ITerrainChannel LoadBitmap(Bitmap bitmap) 90 protected virtual ITerrainChannel LoadBitmap(Bitmap bitmap)
@@ -134,35 +138,53 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
134 // "Saving the image to the same file it was constructed from is not allowed and throws an exception." 138 // "Saving the image to the same file it was constructed from is not allowed and throws an exception."
135 string tempName = Path.GetTempFileName(); 139 string tempName = Path.GetTempFileName();
136 140
137 Bitmap entireBitmap = null; 141 Bitmap existingBitmap = null;
138 Bitmap thisBitmap = null; 142 Bitmap thisBitmap = null;
139 if (File.Exists(filename)) 143 Bitmap newBitmap = null;
144
145 try
140 { 146 {
141 File.Copy(filename, tempName, true); 147 if (File.Exists(filename))
142 entireBitmap = new Bitmap(tempName); 148 {
143 if (entireBitmap.Width != fileWidth * regionSizeX || entireBitmap.Height != fileHeight * regionSizeY) 149 File.Copy(filename, tempName, true);
150 existingBitmap = new Bitmap(tempName);
151 if (existingBitmap.Width != fileWidth * regionSizeX || existingBitmap.Height != fileHeight * regionSizeY)
152 {
153 // old file, let's overwrite it
154 newBitmap = new Bitmap(fileWidth * regionSizeX, fileHeight * regionSizeY);
155 }
156 else
157 {
158 newBitmap = existingBitmap;
159 }
160 }
161 else
144 { 162 {
145 // old file, let's overwrite it 163 newBitmap = new Bitmap(fileWidth * regionSizeX, fileHeight * regionSizeY);
146 entireBitmap = new Bitmap(fileWidth * regionSizeX, fileHeight * regionSizeY);
147 } 164 }
165
166 thisBitmap = CreateGrayscaleBitmapFromMap(m_channel);
167 // Console.WriteLine("offsetX=" + offsetX + " offsetY=" + offsetY);
168 for (int x = 0; x < regionSizeX; x++)
169 for (int y = 0; y < regionSizeY; y++)
170 newBitmap.SetPixel(x + offsetX * regionSizeX, y + (fileHeight - 1 - offsetY) * regionSizeY, thisBitmap.GetPixel(x, y));
171
172 Save(newBitmap, filename);
148 } 173 }
149 else 174 finally
150 { 175 {
151 entireBitmap = new Bitmap(fileWidth * regionSizeX, fileHeight * regionSizeY); 176 if (existingBitmap != null)
152 } 177 existingBitmap.Dispose();
153 178
154 thisBitmap = CreateGrayscaleBitmapFromMap(m_channel); 179 if (thisBitmap != null)
155// Console.WriteLine("offsetX=" + offsetX + " offsetY=" + offsetY); 180 thisBitmap.Dispose();
156 for (int x = 0; x < regionSizeX; x++)
157 for (int y = 0; y < regionSizeY; y++)
158 entireBitmap.SetPixel(x + offsetX * regionSizeX, y + (fileHeight - 1 - offsetY) * regionSizeY, thisBitmap.GetPixel(x, y));
159 181
160 Save(entireBitmap, filename); 182 if (newBitmap != null)
161 thisBitmap.Dispose(); 183 newBitmap.Dispose();
162 entireBitmap.Dispose();
163 184
164 if (File.Exists(tempName)) 185 if (File.Exists(tempName))
165 File.Delete(tempName); 186 File.Delete(tempName);
187 }
166 } 188 }
167 189
168 protected virtual void Save(Bitmap bmp, string filename) 190 protected virtual void Save(Bitmap bmp, string filename)
@@ -226,16 +248,21 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
226 /// <returns>A System.Drawing.Bitmap containing a coloured image</returns> 248 /// <returns>A System.Drawing.Bitmap containing a coloured image</returns>
227 protected static Bitmap CreateBitmapFromMap(ITerrainChannel map) 249 protected static Bitmap CreateBitmapFromMap(ITerrainChannel map)
228 { 250 {
229 Bitmap gradientmapLd = new Bitmap("defaultstripe.png"); 251 int pallete;
230 252 Bitmap bmp;
231 int pallete = gradientmapLd.Height; 253 Color[] colours;
232 254
233 Bitmap bmp = new Bitmap(map.Width, map.Height); 255 using (Bitmap gradientmapLd = new Bitmap("defaultstripe.png"))
234 Color[] colours = new Color[pallete];
235
236 for (int i = 0; i < pallete; i++)
237 { 256 {
238 colours[i] = gradientmapLd.GetPixel(0, i); 257 pallete = gradientmapLd.Height;
258
259 bmp = new Bitmap(map.Width, map.Height);
260 colours = new Color[pallete];
261
262 for (int i = 0; i < pallete; i++)
263 {
264 colours[i] = gradientmapLd.GetPixel(0, i);
265 }
239 } 266 }
240 267
241 for (int y = 0; y < map.Height; y++) 268 for (int y = 0; y < map.Height; y++)
diff --git a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/JPEG.cs b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/JPEG.cs
index 699d67a..9cc767a 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/JPEG.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/JPEG.cs
@@ -99,16 +99,21 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
99 99
100 private static Bitmap CreateBitmapFromMap(ITerrainChannel map) 100 private static Bitmap CreateBitmapFromMap(ITerrainChannel map)
101 { 101 {
102 Bitmap gradientmapLd = new Bitmap("defaultstripe.png"); 102 int pallete;
103 Bitmap bmp;
104 Color[] colours;
103 105
104 int pallete = gradientmapLd.Height; 106 using (Bitmap gradientmapLd = new Bitmap("defaultstripe.png"))
105
106 Bitmap bmp = new Bitmap(map.Width, map.Height);
107 Color[] colours = new Color[pallete];
108
109 for (int i = 0; i < pallete; i++)
110 { 107 {
111 colours[i] = gradientmapLd.GetPixel(0, i); 108 pallete = gradientmapLd.Height;
109
110 bmp = new Bitmap(map.Width, map.Height);
111 colours = new Color[pallete];
112
113 for (int i = 0; i < pallete; i++)
114 {
115 colours[i] = gradientmapLd.GetPixel(0, i);
116 }
112 } 117 }
113 118
114 for (int y = 0; y < map.Height; y++) 119 for (int y = 0; y < map.Height; y++)
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/Interfaces/IWorldComm.cs b/OpenSim/Region/Framework/Interfaces/IWorldComm.cs
index e8e375e..4e74781 100644
--- a/OpenSim/Region/Framework/Interfaces/IWorldComm.cs
+++ b/OpenSim/Region/Framework/Interfaces/IWorldComm.cs
@@ -103,7 +103,7 @@ namespace OpenSim.Region.Framework.Interfaces
103 /// <param name='msg'> 103 /// <param name='msg'>
104 /// Message. 104 /// Message.
105 /// </param> 105 /// </param>
106 bool DeliverMessageTo(UUID target, int channel, Vector3 pos, string name, UUID id, string msg, out string error); 106 void DeliverMessageTo(UUID target, int channel, Vector3 pos, string name, UUID id, string msg);
107 107
108 /// <summary> 108 /// <summary>
109 /// Are there any listen events ready to be dispatched? 109 /// Are there any listen events ready to be dispatched?
diff --git a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
index 87ffc74..2701d6e 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
@@ -38,8 +38,9 @@ namespace OpenSim.Region.Framework.Scenes
38{ 38{
39 public partial class Scene 39 public partial class Scene
40 { 40 {
41
41 protected void SimChat(byte[] message, ChatTypeEnum type, int channel, Vector3 fromPos, string fromName, 42 protected void SimChat(byte[] message, ChatTypeEnum type, int channel, Vector3 fromPos, string fromName,
42 UUID fromID, bool fromAgent, bool broadcast) 43 UUID fromID, UUID targetID, bool fromAgent, bool broadcast)
43 { 44 {
44 OSChatMessage args = new OSChatMessage(); 45 OSChatMessage args = new OSChatMessage();
45 46
@@ -63,14 +64,20 @@ namespace OpenSim.Region.Framework.Scenes
63 } 64 }
64 65
65 args.From = fromName; 66 args.From = fromName;
66 //args. 67 args.TargetUUID = targetID;
67 68
68 if (broadcast) 69 if (broadcast)
69 EventManager.TriggerOnChatBroadcast(this, args); 70 EventManager.TriggerOnChatBroadcast(this, args);
70 else 71 else
71 EventManager.TriggerOnChatFromWorld(this, args); 72 EventManager.TriggerOnChatFromWorld(this, args);
72 } 73 }
73 74
75 protected void SimChat(byte[] message, ChatTypeEnum type, int channel, Vector3 fromPos, string fromName,
76 UUID fromID, bool fromAgent, bool broadcast)
77 {
78 SimChat(message, type, channel, fromPos, fromName, fromID, UUID.Zero, fromAgent, broadcast);
79 }
80
74 /// <summary> 81 /// <summary>
75 /// 82 ///
76 /// </summary> 83 /// </summary>
@@ -108,6 +115,19 @@ namespace OpenSim.Region.Framework.Scenes
108 { 115 {
109 SimChat(message, type, channel, fromPos, fromName, fromID, fromAgent, true); 116 SimChat(message, type, channel, fromPos, fromName, fromID, fromAgent, true);
110 } 117 }
118 /// <summary>
119 ///
120 /// </summary>
121 /// <param name="message"></param>
122 /// <param name="type"></param>
123 /// <param name="fromPos"></param>
124 /// <param name="fromName"></param>
125 /// <param name="fromAgentID"></param>
126 /// <param name="targetID"></param>
127 public void SimChatToAgent(UUID targetID, byte[] message, Vector3 fromPos, string fromName, UUID fromID, bool fromAgent)
128 {
129 SimChat(message, ChatTypeEnum.Say, 0, fromPos, fromName, fromID, targetID, fromAgent, false);
130 }
111 131
112 /// <summary> 132 /// <summary>
113 /// Invoked when the client requests a prim. 133 /// Invoked when the client requests a prim.
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index e488fe1..a87dfb7 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -684,8 +684,8 @@ namespace OpenSim.Region.Framework.Scenes
684 //Animation states 684 //Animation states
685 m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); 685 m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false);
686 686
687 PhysicalPrims = startupConfig.GetBoolean("physical_prim", true); 687 PhysicalPrims = startupConfig.GetBoolean("physical_prim", PhysicalPrims);
688 CollidablePrims = startupConfig.GetBoolean("collidable_prim", true); 688 CollidablePrims = startupConfig.GetBoolean("collidable_prim", CollidablePrims);
689 689
690 m_maxNonphys = startupConfig.GetFloat("NonphysicalPrimMax", m_maxNonphys); 690 m_maxNonphys = startupConfig.GetFloat("NonphysicalPrimMax", m_maxNonphys);
691 if (RegionInfo.NonphysPrimMax > 0) 691 if (RegionInfo.NonphysPrimMax > 0)
@@ -800,13 +800,11 @@ namespace OpenSim.Region.Framework.Scenes
800 StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats; 800 StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats;
801 } 801 }
802 802
803 /// <summary>
804 /// Mock constructor for scene group persistency unit tests.
805 /// SceneObjectGroup RegionId property is delegated to Scene.
806 /// </summary>
807 /// <param name="regInfo"></param>
808 public Scene(RegionInfo regInfo) 803 public Scene(RegionInfo regInfo)
809 { 804 {
805 PhysicalPrims = true;
806 CollidablePrims = true;
807
810 BordersLocked = true; 808 BordersLocked = true;
811 Border northBorder = new Border(); 809 Border northBorder = new Border();
812 northBorder.BorderLine = new Vector3(float.MinValue, float.MaxValue, (int)Constants.RegionSize); //<--- 810 northBorder.BorderLine = new Vector3(float.MinValue, float.MaxValue, (int)Constants.RegionSize); //<---
@@ -833,8 +831,6 @@ namespace OpenSim.Region.Framework.Scenes
833 m_eventManager = new EventManager(); 831 m_eventManager = new EventManager();
834 832
835 m_permissions = new ScenePermissions(this); 833 m_permissions = new ScenePermissions(this);
836
837// m_lastUpdate = Util.EnvironmentTickCount();
838 } 834 }
839 835
840 #endregion 836 #endregion
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index 0098add..67eb0fe 100644
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -91,6 +91,9 @@ namespace OpenSim.Region.Framework.Scenes
91 /// </summary> 91 /// </summary>
92 protected internal Dictionary<uint, SceneObjectGroup> SceneObjectGroupsByLocalPartID = new Dictionary<uint, SceneObjectGroup>(); 92 protected internal Dictionary<uint, SceneObjectGroup> SceneObjectGroupsByLocalPartID = new Dictionary<uint, SceneObjectGroup>();
93 93
94 /// <summary>
95 /// Lock to prevent object group update, linking and delinking operations from running concurrently.
96 /// </summary>
94 private Object m_updateLock = new Object(); 97 private Object m_updateLock = new Object();
95 98
96 #endregion 99 #endregion
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index a49ed13..49a3485 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -1962,6 +1962,10 @@ namespace OpenSim.Region.Framework.Scenes
1962 /// <summary> 1962 /// <summary>
1963 /// Link the prims in a given group to this group 1963 /// Link the prims in a given group to this group
1964 /// </summary> 1964 /// </summary>
1965 /// <remarks>
1966 /// Do not call this method directly - use Scene.LinkObjects() instead to avoid races between threads.
1967 /// FIXME: There are places where scripts call these methods directly without locking. This is a potential race condition.
1968 /// </remarks>
1965 /// <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>
1966 public void LinkToGroup(SceneObjectGroup objectGroup) 1970 public void LinkToGroup(SceneObjectGroup objectGroup)
1967 { 1971 {
@@ -2006,6 +2010,7 @@ namespace OpenSim.Region.Framework.Scenes
2006 linkPart.CreateSelected = true; 2010 linkPart.CreateSelected = true;
2007 2011
2008 linkPart.LinkNum = linkNum++; 2012 linkPart.LinkNum = linkNum++;
2013 linkPart.UpdatePrimFlags(UsesPhysics, IsTemporary, IsPhantom, IsVolumeDetect);
2009 2014
2010 SceneObjectPart[] ogParts = objectGroup.Parts; 2015 SceneObjectPart[] ogParts = objectGroup.Parts;
2011 Array.Sort(ogParts, delegate(SceneObjectPart a, SceneObjectPart b) 2016 Array.Sort(ogParts, delegate(SceneObjectPart a, SceneObjectPart b)
@@ -2045,6 +2050,11 @@ namespace OpenSim.Region.Framework.Scenes
2045 /// Delink the given prim from this group. The delinked prim is established as 2050 /// Delink the given prim from this group. The delinked prim is established as
2046 /// an independent SceneObjectGroup. 2051 /// an independent SceneObjectGroup.
2047 /// </summary> 2052 /// </summary>
2053 /// <remarks>
2054 /// FIXME: This method should not be called directly since it bypasses update locking, allowing a potential race
2055 /// condition. But currently there is no
2056 /// alternative method that does take a lonk to delink a single prim.
2057 /// </remarks>
2048 /// <param name="partID"></param> 2058 /// <param name="partID"></param>
2049 /// <returns>The object group of the newly delinked prim. Null if part could not be found</returns> 2059 /// <returns>The object group of the newly delinked prim. Null if part could not be found</returns>
2050 public SceneObjectGroup DelinkFromGroup(uint partID) 2060 public SceneObjectGroup DelinkFromGroup(uint partID)
@@ -2056,6 +2066,11 @@ namespace OpenSim.Region.Framework.Scenes
2056 /// Delink the given prim from this group. The delinked prim is established as 2066 /// Delink the given prim from this group. The delinked prim is established as
2057 /// an independent SceneObjectGroup. 2067 /// an independent SceneObjectGroup.
2058 /// </summary> 2068 /// </summary>
2069 /// <remarks>
2070 /// FIXME: This method should not be called directly since it bypasses update locking, allowing a potential race
2071 /// condition. But currently there is no
2072 /// alternative method that does take a lonk to delink a single prim.
2073 /// </remarks>
2059 /// <param name="partID"></param> 2074 /// <param name="partID"></param>
2060 /// <param name="sendEvents"></param> 2075 /// <param name="sendEvents"></param>
2061 /// <returns>The object group of the newly delinked prim. Null if part could not be found</returns> 2076 /// <returns>The object group of the newly delinked prim. Null if part could not be found</returns>
@@ -2081,6 +2096,11 @@ namespace OpenSim.Region.Framework.Scenes
2081 /// Delink the given prim from this group. The delinked prim is established as 2096 /// Delink the given prim from this group. The delinked prim is established as
2082 /// an independent SceneObjectGroup. 2097 /// an independent SceneObjectGroup.
2083 /// </summary> 2098 /// </summary>
2099 /// <remarks>
2100 /// FIXME: This method should not be called directly since it bypasses update locking, allowing a potential race
2101 /// condition. But currently there is no
2102 /// alternative method that does take a lonk to delink a single prim.
2103 /// </remarks>
2084 /// <param name="partID"></param> 2104 /// <param name="partID"></param>
2085 /// <param name="sendEvents"></param> 2105 /// <param name="sendEvents"></param>
2086 /// <returns>The object group of the newly delinked prim.</returns> 2106 /// <returns>The object group of the newly delinked prim.</returns>
@@ -2201,6 +2221,8 @@ namespace OpenSim.Region.Framework.Scenes
2201 oldRot = part.RotationOffset; 2221 oldRot = part.RotationOffset;
2202 Quaternion newRot = Quaternion.Inverse(parentRot) * oldRot; 2222 Quaternion newRot = Quaternion.Inverse(parentRot) * oldRot;
2203 part.RotationOffset = newRot; 2223 part.RotationOffset = newRot;
2224
2225 part.UpdatePrimFlags(UsesPhysics, IsTemporary, IsPhantom, IsVolumeDetect);
2204 } 2226 }
2205 2227
2206 /// <summary> 2228 /// <summary>
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 046553b..4bec2d4 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -1706,6 +1706,9 @@ namespace OpenSim.Region.Framework.Scenes
1706 /// <param name="isNew"></param> 1706 /// <param name="isNew"></param>
1707 public void DoPhysicsPropertyUpdate(bool UsePhysics, bool isNew) 1707 public void DoPhysicsPropertyUpdate(bool UsePhysics, bool isNew)
1708 { 1708 {
1709 if (ParentGroup.Scene == null)
1710 return;
1711
1709 if (!ParentGroup.Scene.PhysicalPrims && UsePhysics) 1712 if (!ParentGroup.Scene.PhysicalPrims && UsePhysics)
1710 return; 1713 return;
1711 1714
@@ -4161,7 +4164,7 @@ namespace OpenSim.Region.Framework.Scenes
4161 // For now, we use the NINJA naming scheme for identifying joints. 4164 // For now, we use the NINJA naming scheme for identifying joints.
4162 // In the future, we can support other joint specification schemes such as a 4165 // In the future, we can support other joint specification schemes such as a
4163 // custom checkbox in the viewer GUI. 4166 // custom checkbox in the viewer GUI.
4164 if (ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints) 4167 if (ParentGroup.Scene != null && ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints)
4165 { 4168 {
4166 string hingeString = "hingejoint"; 4169 string hingeString = "hingejoint";
4167 return (Name.Length >= hingeString.Length && Name.Substring(0, hingeString.Length) == hingeString); 4170 return (Name.Length >= hingeString.Length && Name.Substring(0, hingeString.Length) == hingeString);
@@ -4177,7 +4180,7 @@ namespace OpenSim.Region.Framework.Scenes
4177 // For now, we use the NINJA naming scheme for identifying joints. 4180 // For now, we use the NINJA naming scheme for identifying joints.
4178 // In the future, we can support other joint specification schemes such as a 4181 // In the future, we can support other joint specification schemes such as a
4179 // custom checkbox in the viewer GUI. 4182 // custom checkbox in the viewer GUI.
4180 if (ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints) 4183 if (ParentGroup.Scene != null && ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints)
4181 { 4184 {
4182 string ballString = "balljoint"; 4185 string ballString = "balljoint";
4183 return (Name.Length >= ballString.Length && Name.Substring(0, ballString.Length) == ballString); 4186 return (Name.Length >= ballString.Length && Name.Substring(0, ballString.Length) == ballString);
@@ -4193,7 +4196,7 @@ namespace OpenSim.Region.Framework.Scenes
4193 // For now, we use the NINJA naming scheme for identifying joints. 4196 // For now, we use the NINJA naming scheme for identifying joints.
4194 // In the future, we can support other joint specification schemes such as a 4197 // In the future, we can support other joint specification schemes such as a
4195 // custom checkbox in the viewer GUI. 4198 // custom checkbox in the viewer GUI.
4196 if (ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints) 4199 if (ParentGroup.Scene != null && ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints)
4197 { 4200 {
4198 return IsHingeJoint() || IsBallJoint(); 4201 return IsHingeJoint() || IsBallJoint();
4199 } 4202 }
@@ -4287,7 +4290,10 @@ namespace OpenSim.Region.Framework.Scenes
4287 AddFlag(PrimFlags.Phantom); 4290 AddFlag(PrimFlags.Phantom);
4288 4291
4289 if (PhysActor != null) 4292 if (PhysActor != null)
4293 {
4290 RemoveFromPhysics(); 4294 RemoveFromPhysics();
4295 pa = null;
4296 }
4291 } 4297 }
4292 else // Not phantom 4298 else // Not phantom
4293 { 4299 {
@@ -4353,7 +4359,7 @@ namespace OpenSim.Region.Framework.Scenes
4353 { 4359 {
4354 pa.SetVolumeDetect(1); 4360 pa.SetVolumeDetect(1);
4355 AddFlag(PrimFlags.Phantom); // We set this flag also if VD is active 4361 AddFlag(PrimFlags.Phantom); // We set this flag also if VD is active
4356 this.VolumeDetectActive = true; 4362 VolumeDetectActive = true;
4357 } 4363 }
4358 } 4364 }
4359 else 4365 else
@@ -4361,9 +4367,9 @@ namespace OpenSim.Region.Framework.Scenes
4361 // Remove VolumeDetect in any case. Note, it's safe to call SetVolumeDetect as often as you like 4367 // Remove VolumeDetect in any case. Note, it's safe to call SetVolumeDetect as often as you like
4362 // (mumbles, well, at least if you have infinte CPU powers :-)) 4368 // (mumbles, well, at least if you have infinte CPU powers :-))
4363 if (pa != null) 4369 if (pa != null)
4364 PhysActor.SetVolumeDetect(0); 4370 pa.SetVolumeDetect(0);
4365 4371
4366 this.VolumeDetectActive = false; 4372 VolumeDetectActive = false;
4367 } 4373 }
4368 4374
4369 if (SetTemporary) 4375 if (SetTemporary)
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/SceneObjectStatusTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs
index 2a342d5..360566d 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs
@@ -26,6 +26,7 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections.Generic;
29using System.Reflection; 30using System.Reflection;
30using NUnit.Framework; 31using NUnit.Framework;
31using OpenMetaverse; 32using OpenMetaverse;
@@ -43,24 +44,141 @@ namespace OpenSim.Region.Framework.Scenes.Tests
43 [TestFixture] 44 [TestFixture]
44 public class SceneObjectStatusTests 45 public class SceneObjectStatusTests
45 { 46 {
47 private TestScene m_scene;
48 private UUID m_ownerId = TestHelpers.ParseTail(0x1);
49 private SceneObjectGroup m_so1;
50 private SceneObjectGroup m_so2;
51
52 [SetUp]
53 public void Init()
54 {
55 m_scene = SceneHelpers.SetupScene();
56 m_so1 = SceneHelpers.CreateSceneObject(1, m_ownerId, "so1", 0x10);
57 m_so2 = SceneHelpers.CreateSceneObject(1, m_ownerId, "so2", 0x20);
58 }
59
46 [Test] 60 [Test]
47 public void TestSetPhantom() 61 public void TestSetPhantomSinglePrim()
48 { 62 {
49 TestHelpers.InMethod(); 63 TestHelpers.InMethod();
50 64
51// Scene scene = SceneSetupHelpers.SetupScene(); 65 m_scene.AddSceneObject(m_so1);
52 SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, UUID.Zero); 66
53 SceneObjectPart rootPart = so.RootPart; 67 SceneObjectPart rootPart = m_so1.RootPart;
54 Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None)); 68 Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None));
55 69
56 so.ScriptSetPhantomStatus(true); 70 m_so1.ScriptSetPhantomStatus(true);
57 71
58// Console.WriteLine("so.RootPart.Flags [{0}]", so.RootPart.Flags); 72// Console.WriteLine("so.RootPart.Flags [{0}]", so.RootPart.Flags);
59 Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.Phantom)); 73 Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.Phantom));
60 74
61 so.ScriptSetPhantomStatus(false); 75 m_so1.ScriptSetPhantomStatus(false);
62 76
63 Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None)); 77 Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None));
64 } 78 }
79
80 [Test]
81 public void TestSetPhysicsSinglePrim()
82 {
83 TestHelpers.InMethod();
84
85 m_scene.AddSceneObject(m_so1);
86
87 SceneObjectPart rootPart = m_so1.RootPart;
88 Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None));
89
90 m_so1.ScriptSetPhysicsStatus(true);
91
92// Console.WriteLine("so.RootPart.Flags [{0}]", so.RootPart.Flags);
93 Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.Physics));
94
95 m_so1.ScriptSetPhysicsStatus(false);
96
97 Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None));
98 }
99
100 [Test]
101 public void TestSetPhysicsLinkset()
102 {
103 TestHelpers.InMethod();
104
105 m_scene.AddSceneObject(m_so1);
106 m_scene.AddSceneObject(m_so2);
107
108 m_scene.LinkObjects(m_ownerId, m_so1.LocalId, new List<uint>() { m_so2.LocalId });
109
110 m_so1.ScriptSetPhysicsStatus(true);
111
112 Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.Physics));
113 Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.Physics));
114
115 m_so1.ScriptSetPhysicsStatus(false);
116
117 Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.None));
118 Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.None));
119
120 m_so1.ScriptSetPhysicsStatus(true);
121
122 Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.Physics));
123 Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.Physics));
124 }
125
126 /// <summary>
127 /// Test that linking results in the correct physical status for all linkees.
128 /// </summary>
129 [Test]
130 public void TestLinkPhysicsBothPhysical()
131 {
132 TestHelpers.InMethod();
133
134 m_scene.AddSceneObject(m_so1);
135 m_scene.AddSceneObject(m_so2);
136
137 m_so1.ScriptSetPhysicsStatus(true);
138 m_so2.ScriptSetPhysicsStatus(true);
139
140 m_scene.LinkObjects(m_ownerId, m_so1.LocalId, new List<uint>() { m_so2.LocalId });
141
142 Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.Physics));
143 Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.Physics));
144 }
145
146 /// <summary>
147 /// Test that linking results in the correct physical status for all linkees.
148 /// </summary>
149 [Test]
150 public void TestLinkPhysicsRootPhysicalOnly()
151 {
152 TestHelpers.InMethod();
153
154 m_scene.AddSceneObject(m_so1);
155 m_scene.AddSceneObject(m_so2);
156
157 m_so1.ScriptSetPhysicsStatus(true);
158
159 m_scene.LinkObjects(m_ownerId, m_so1.LocalId, new List<uint>() { m_so2.LocalId });
160
161 Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.Physics));
162 Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.Physics));
163 }
164
165 /// <summary>
166 /// Test that linking results in the correct physical status for all linkees.
167 /// </summary>
168 [Test]
169 public void TestLinkPhysicsChildPhysicalOnly()
170 {
171 TestHelpers.InMethod();
172
173 m_scene.AddSceneObject(m_so1);
174 m_scene.AddSceneObject(m_so2);
175
176 m_so2.ScriptSetPhysicsStatus(true);
177
178 m_scene.LinkObjects(m_ownerId, m_so1.LocalId, new List<uint>() { m_so2.LocalId });
179
180 Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.None));
181 Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.None));
182 }
65 } 183 }
66} \ No newline at end of file 184} \ No newline at end of file
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/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 2b8379d..435a683 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 }
@@ -299,7 +299,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
299 scene.RemoveClient(agentID, false); 299 scene.RemoveClient(agentID, false);
300 m_avatars.Remove(agentID); 300 m_avatars.Remove(agentID);
301 301
302// m_log.DebugFormat("[NPC MODULE]: Removed {0} {1}", agentID, av.Name); 302 m_log.DebugFormat("[NPC MODULE]: Removed NPC {0} {1}", agentID, av.Name);
303 return true; 303 return true;
304 } 304 }
305 } 305 }
diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsActor.cs b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsActor.cs
index b1a3ff9..e43136a 100644
--- a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsActor.cs
+++ b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsActor.cs
@@ -36,13 +36,7 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
36{ 36{
37 public class BasicActor : PhysicsActor 37 public class BasicActor : PhysicsActor
38 { 38 {
39 private Vector3 _position;
40 private Vector3 _velocity;
41 private Vector3 _acceleration;
42 private Vector3 _size; 39 private Vector3 _size;
43 private Vector3 m_rotationalVelocity;
44 private bool flying;
45 private bool iscolliding;
46 40
47 public BasicActor(Vector3 size) 41 public BasicActor(Vector3 size)
48 { 42 {
@@ -55,11 +49,7 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
55 set { return; } 49 set { return; }
56 } 50 }
57 51
58 public override Vector3 RotationalVelocity 52 public override Vector3 RotationalVelocity { get; set; }
59 {
60 get { return m_rotationalVelocity; }
61 set { m_rotationalVelocity = value; }
62 }
63 53
64 public override bool SetAlwaysRun 54 public override bool SetAlwaysRun
65 { 55 {
@@ -105,17 +95,9 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
105 set { return; } 95 set { return; }
106 } 96 }
107 97
108 public override bool Flying 98 public override bool Flying { get; set; }
109 {
110 get { return flying; }
111 set { flying = value; }
112 }
113 99
114 public override bool IsColliding 100 public override bool IsColliding { get; set; }
115 {
116 get { return iscolliding; }
117 set { iscolliding = value; }
118 }
119 101
120 public override bool CollidingGround 102 public override bool CollidingGround
121 { 103 {
@@ -134,11 +116,7 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
134 get { return false; } 116 get { return false; }
135 } 117 }
136 118
137 public override Vector3 Position 119 public override Vector3 Position { get; set; }
138 {
139 get { return _position; }
140 set { _position = value; }
141 }
142 120
143 public override Vector3 Size 121 public override Vector3 Size
144 { 122 {
@@ -206,11 +184,7 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
206 get { return Vector3.Zero; } 184 get { return Vector3.Zero; }
207 } 185 }
208 186
209 public override Vector3 Velocity 187 public override Vector3 Velocity { get; set; }
210 {
211 get { return _velocity; }
212 set { _velocity = value; }
213 }
214 188
215 public override Vector3 Torque 189 public override Vector3 Torque
216 { 190 {
@@ -230,11 +204,7 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
230 set { } 204 set { }
231 } 205 }
232 206
233 public override Vector3 Acceleration 207 public override Vector3 Acceleration { get; set; }
234 {
235 get { return _acceleration; }
236 set { _acceleration = value; }
237 }
238 208
239 public override bool Kinematic 209 public override bool Kinematic
240 { 210 {
diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPrim.cs b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPrim.cs
new file mode 100644
index 0000000..b89eeed
--- /dev/null
+++ b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPrim.cs
@@ -0,0 +1,314 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
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
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
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using Nini.Config;
31using OpenMetaverse;
32using OpenSim.Framework;
33using OpenSim.Region.Physics.Manager;
34
35namespace OpenSim.Region.Physics.BasicPhysicsPlugin
36{
37 public class BasicPhysicsPrim : PhysicsActor
38 {
39 private Vector3 _size;
40 private PrimitiveBaseShape _shape;
41
42 public BasicPhysicsPrim(
43 string name, uint localId, Vector3 position, Vector3 size, Quaternion orientation, PrimitiveBaseShape shape)
44 {
45 Name = name;
46 LocalID = localId;
47 Position = position;
48 Size = size;
49 Orientation = orientation;
50 Shape = shape;
51 }
52
53 public override int PhysicsActorType
54 {
55 get { return (int) ActorTypes.Agent; }
56 set { return; }
57 }
58
59 public override Vector3 RotationalVelocity { get; set; }
60
61 public override bool SetAlwaysRun
62 {
63 get { return false; }
64 set { return; }
65 }
66
67 public override uint LocalID
68 {
69 set { return; }
70 }
71
72 public override bool Grabbed
73 {
74 set { return; }
75 }
76
77 public override bool Selected
78 {
79 set { return; }
80 }
81
82 public override float Buoyancy
83 {
84 get { return 0f; }
85 set { return; }
86 }
87
88 public override bool FloatOnWater
89 {
90 set { return; }
91 }
92
93 public override bool IsPhysical
94 {
95 get { return false; }
96 set { return; }
97 }
98
99 public override bool ThrottleUpdates
100 {
101 get { return false; }
102 set { return; }
103 }
104
105 public override bool Flying { get; set; }
106
107 public override bool IsColliding { get; set; }
108
109 public override bool CollidingGround
110 {
111 get { return false; }
112 set { return; }
113 }
114
115 public override bool CollidingObj
116 {
117 get { return false; }
118 set { return; }
119 }
120
121 public override bool Stopped
122 {
123 get { return false; }
124 }
125
126 public override Vector3 Position { get; set; }
127
128 public override Vector3 Size
129 {
130 get { return _size; }
131 set {
132 _size = value;
133 _size.Z = _size.Z / 2.0f;
134 }
135 }
136
137 public override PrimitiveBaseShape Shape
138 {
139 set { _shape = value; }
140 }
141
142 public override float Mass
143 {
144 get { return 0f; }
145 }
146
147 public override Vector3 Force
148 {
149 get { return Vector3.Zero; }
150 set { return; }
151 }
152
153 public override int VehicleType
154 {
155 get { return 0; }
156 set { return; }
157 }
158
159 public override void VehicleFloatParam(int param, float value)
160 {
161
162 }
163
164 public override void VehicleVectorParam(int param, Vector3 value)
165 {
166
167 }
168
169 public override void VehicleRotationParam(int param, Quaternion rotation)
170 {
171
172 }
173
174 public override void VehicleFlags(int param, bool remove)
175 {
176
177 }
178
179 public override void SetVolumeDetect(int param)
180 {
181
182 }
183
184 public override Vector3 CenterOfMass
185 {
186 get { return Vector3.Zero; }
187 }
188
189 public override Vector3 GeometricCenter
190 {
191 get { return Vector3.Zero; }
192 }
193
194 public override Vector3 Velocity { get; set; }
195
196 public override Vector3 Torque
197 {
198 get { return Vector3.Zero; }
199 set { return; }
200 }
201
202 public override float CollisionScore
203 {
204 get { return 0f; }
205 set { }
206 }
207
208 public override Quaternion Orientation { get; set; }
209
210 public override Vector3 Acceleration { get; set; }
211
212 public override bool Kinematic
213 {
214 get { return true; }
215 set { }
216 }
217
218 public override void link(PhysicsActor obj)
219 {
220 }
221
222 public override void delink()
223 {
224 }
225
226 public override void LockAngularMotion(Vector3 axis)
227 {
228 }
229
230 public override void AddForce(Vector3 force, bool pushforce)
231 {
232 }
233
234 public override void AddAngularForce(Vector3 force, bool pushforce)
235 {
236 }
237
238 public override void SetMomentum(Vector3 momentum)
239 {
240 }
241
242 public override void CrossingFailure()
243 {
244 }
245
246 public override Vector3 PIDTarget
247 {
248 set { return; }
249 }
250
251 public override bool PIDActive
252 {
253 set { return; }
254 }
255
256 public override float PIDTau
257 {
258 set { return; }
259 }
260
261 public override float PIDHoverHeight
262 {
263 set { return; }
264 }
265
266 public override bool PIDHoverActive
267 {
268 set { return; }
269 }
270
271 public override PIDHoverType PIDHoverType
272 {
273 set { return; }
274 }
275
276 public override float PIDHoverTau
277 {
278 set { return; }
279 }
280
281 public override Quaternion APIDTarget
282 {
283 set { return; }
284 }
285
286 public override bool APIDActive
287 {
288 set { return; }
289 }
290
291 public override float APIDStrength
292 {
293 set { return; }
294 }
295
296 public override float APIDDamping
297 {
298 set { return; }
299 }
300
301 public override void SubscribeEvents(int ms)
302 {
303 }
304
305 public override void UnSubscribeEvents()
306 {
307 }
308
309 public override bool SubscribedEvents()
310 {
311 return false;
312 }
313 }
314}
diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsScene.cs b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsScene.cs
index 2e14216..f5826ed 100644
--- a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsScene.cs
+++ b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsScene.cs
@@ -34,9 +34,17 @@ using OpenSim.Region.Physics.Manager;
34 34
35namespace OpenSim.Region.Physics.BasicPhysicsPlugin 35namespace OpenSim.Region.Physics.BasicPhysicsPlugin
36{ 36{
37 /// <summary>
38 /// This is an incomplete extremely basic physics implementation
39 /// </summary>
40 /// <remarks>
41 /// Not useful for anything at the moment apart from some regression testing in other components where some form
42 /// of physics plugin is needed.
43 /// </remarks>
37 public class BasicScene : PhysicsScene 44 public class BasicScene : PhysicsScene
38 { 45 {
39 private List<BasicActor> _actors = new List<BasicActor>(); 46 private List<BasicActor> _actors = new List<BasicActor>();
47 private List<BasicPhysicsPrim> _prims = new List<BasicPhysicsPrim>();
40 private float[] _heightMap; 48 private float[] _heightMap;
41 49
42 //protected internal string sceneIdentifier; 50 //protected internal string sceneIdentifier;
@@ -50,10 +58,19 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
50 { 58 {
51 } 59 }
52 60
53 public override void Dispose() 61 public override void Dispose() {}
62
63 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
64 Vector3 size, Quaternion rotation, bool isPhysical, uint localid)
54 { 65 {
66 BasicPhysicsPrim prim = new BasicPhysicsPrim(primName, localid, position, size, rotation, pbs);
67 prim.IsPhysical = isPhysical;
68
69 _prims.Add(prim);
55 70
71 return prim;
56 } 72 }
73
57 public override PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 size, bool isFlying) 74 public override PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 size, bool isFlying)
58 { 75 {
59 BasicActor act = new BasicActor(size); 76 BasicActor act = new BasicActor(size);
@@ -63,30 +80,18 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
63 return act; 80 return act;
64 } 81 }
65 82
66 public override void RemovePrim(PhysicsActor prim) 83 public override void RemovePrim(PhysicsActor actor)
67 { 84 {
85 BasicPhysicsPrim prim = (BasicPhysicsPrim)actor;
86 if (_prims.Contains(prim))
87 _prims.Remove(prim);
68 } 88 }
69 89
70 public override void RemoveAvatar(PhysicsActor actor) 90 public override void RemoveAvatar(PhysicsActor actor)
71 { 91 {
72 BasicActor act = (BasicActor) actor; 92 BasicActor act = (BasicActor)actor;
73 if (_actors.Contains(act)) 93 if (_actors.Contains(act))
74 {
75 _actors.Remove(act); 94 _actors.Remove(act);
76 }
77 }
78
79/*
80 public override PhysicsActor AddPrim(Vector3 position, Vector3 size, Quaternion rotation)
81 {
82 return null;
83 }
84*/
85
86 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
87 Vector3 size, Quaternion rotation, bool isPhysical, uint localid)
88 {
89 return null;
90 } 95 }
91 96
92 public override void AddPhysicsActorTaint(PhysicsActor prim) 97 public override void AddPhysicsActorTaint(PhysicsActor prim)
diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
index 1f79cd8..0716214 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
@@ -156,7 +156,15 @@ namespace OpenSim.Region.Physics.OdePlugin
156 /// </summary> 156 /// </summary>
157 public IntPtr m_targetSpace = IntPtr.Zero; 157 public IntPtr m_targetSpace = IntPtr.Zero;
158 158
159 /// <summary>
160 /// The prim geometry, used for collision detection.
161 /// </summary>
162 /// <remarks>
163 /// This is never null except for a brief period when the geometry needs to be replaced (due to resizing or
164 /// mesh change) or when the physical prim is being removed from the scene.
165 /// </remarks>
159 public IntPtr prim_geom { get; private set; } 166 public IntPtr prim_geom { get; private set; }
167
160 public IntPtr _triMeshData { get; private set; } 168 public IntPtr _triMeshData { get; private set; }
161 169
162 private IntPtr _linkJointGroup = IntPtr.Zero; 170 private IntPtr _linkJointGroup = IntPtr.Zero;
@@ -325,14 +333,12 @@ namespace OpenSim.Region.Physics.OdePlugin
325 { 333 {
326 prim_geom = geom; 334 prim_geom = geom;
327//Console.WriteLine("SetGeom to " + prim_geom + " for " + Name); 335//Console.WriteLine("SetGeom to " + prim_geom + " for " + Name);
328 if (prim_geom != IntPtr.Zero)
329 {
330 d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories);
331 d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags);
332 336
333 _parent_scene.geom_name_map[prim_geom] = Name; 337 d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories);
334 _parent_scene.actor_name_map[prim_geom] = this; 338 d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags);
335 } 339
340 _parent_scene.geom_name_map[prim_geom] = Name;
341 _parent_scene.actor_name_map[prim_geom] = this;
336 342
337 if (childPrim) 343 if (childPrim)
338 { 344 {
@@ -765,11 +771,8 @@ namespace OpenSim.Region.Physics.OdePlugin
765 m_collisionCategories &= ~CollisionCategories.Body; 771 m_collisionCategories &= ~CollisionCategories.Body;
766 m_collisionFlags &= ~(CollisionCategories.Wind | CollisionCategories.Land); 772 m_collisionFlags &= ~(CollisionCategories.Wind | CollisionCategories.Land);
767 773
768 if (prim_geom != IntPtr.Zero) 774 d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories);
769 { 775 d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags);
770 d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories);
771 d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags);
772 }
773 776
774 d.BodyDestroy(Body); 777 d.BodyDestroy(Body);
775 lock (childrenPrim) 778 lock (childrenPrim)
@@ -793,11 +796,8 @@ namespace OpenSim.Region.Physics.OdePlugin
793 m_collisionCategories &= ~CollisionCategories.Body; 796 m_collisionCategories &= ~CollisionCategories.Body;
794 m_collisionFlags &= ~(CollisionCategories.Wind | CollisionCategories.Land); 797 m_collisionFlags &= ~(CollisionCategories.Wind | CollisionCategories.Land);
795 798
796 if (prim_geom != IntPtr.Zero) 799 d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories);
797 { 800 d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags);
798 d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories);
799 d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags);
800 }
801 801
802 Body = IntPtr.Zero; 802 Body = IntPtr.Zero;
803 } 803 }
@@ -864,10 +864,7 @@ namespace OpenSim.Region.Physics.OdePlugin
864// _parent_scene.waitForSpaceUnlock(m_targetSpace); 864// _parent_scene.waitForSpaceUnlock(m_targetSpace);
865 try 865 try
866 { 866 {
867 if (prim_geom == IntPtr.Zero) 867 SetGeom(d.CreateTriMesh(m_targetSpace, _triMeshData, parent_scene.triCallback, null, null));
868 {
869 SetGeom(d.CreateTriMesh(m_targetSpace, _triMeshData, parent_scene.triCallback, null, null));
870 }
871 } 868 }
872 catch (AccessViolationException) 869 catch (AccessViolationException)
873 { 870 {
@@ -890,73 +887,67 @@ namespace OpenSim.Region.Physics.OdePlugin
890#if SPAM 887#if SPAM
891Console.WriteLine("ZProcessTaints for " + Name); 888Console.WriteLine("ZProcessTaints for " + Name);
892#endif 889#endif
890
891 // This must be processed as the very first taint so that later operations have a prim_geom to work with
892 // if this is a new prim.
893 if (m_taintadd) 893 if (m_taintadd)
894 {
895 changeadd(); 894 changeadd();
896 }
897
898 if (prim_geom != IntPtr.Zero)
899 {
900 if (!_position.ApproxEquals(m_taintposition, 0f))
901 changemove();
902 895
903 if (m_taintrot != _orientation) 896 if (!_position.ApproxEquals(m_taintposition, 0f))
904 { 897 changemove();
905 if (childPrim && IsPhysical) // For physical child prim... 898
906 { 899 if (m_taintrot != _orientation)
907 rotate(); 900 {
908 // KF: ODE will also rotate the parent prim! 901 if (childPrim && IsPhysical) // For physical child prim...
909 // so rotate the root back to where it was 902 {
910 OdePrim parent = (OdePrim)_parent; 903 rotate();
911 parent.rotate(); 904 // KF: ODE will also rotate the parent prim!
912 } 905 // so rotate the root back to where it was
913 else 906 OdePrim parent = (OdePrim)_parent;
914 { 907 parent.rotate();
915 //Just rotate the prim
916 rotate();
917 }
918 } 908 }
919 909 else
920 if (m_taintPhysics != IsPhysical && !(m_taintparent != _parent)) 910 {
921 changePhysicsStatus(); 911 //Just rotate the prim
912 rotate();
913 }
914 }
915
916 if (m_taintPhysics != IsPhysical && !(m_taintparent != _parent))
917 changePhysicsStatus();
922 918
923 if (!_size.ApproxEquals(m_taintsize, 0f)) 919 if (!_size.ApproxEquals(m_taintsize, 0f))
924 changesize(); 920 changesize();
925 921
926 if (m_taintshape) 922 if (m_taintshape)
927 changeshape(); 923 changeshape();
928 924
929 if (m_taintforce) 925 if (m_taintforce)
930 changeAddForce(); 926 changeAddForce();
931 927
932 if (m_taintaddangularforce) 928 if (m_taintaddangularforce)
933 changeAddAngularForce(); 929 changeAddAngularForce();
934 930
935 if (!m_taintTorque.ApproxEquals(Vector3.Zero, 0.001f)) 931 if (!m_taintTorque.ApproxEquals(Vector3.Zero, 0.001f))
936 changeSetTorque(); 932 changeSetTorque();
937 933
938 if (m_taintdisable) 934 if (m_taintdisable)
939 changedisable(); 935 changedisable();
940 936
941 if (m_taintselected != m_isSelected) 937 if (m_taintselected != m_isSelected)
942 changeSelectedStatus(); 938 changeSelectedStatus();
943 939
944 if (!m_taintVelocity.ApproxEquals(Vector3.Zero, 0.001f)) 940 if (!m_taintVelocity.ApproxEquals(Vector3.Zero, 0.001f))
945 changevelocity(); 941 changevelocity();
946 942
947 if (m_taintparent != _parent) 943 if (m_taintparent != _parent)
948 changelink(); 944 changelink();
949 945
950 if (m_taintCollidesWater != m_collidesWater) 946 if (m_taintCollidesWater != m_collidesWater)
951 changefloatonwater(); 947 changefloatonwater();
952 948
953 if (!m_angularlock.ApproxEquals(m_taintAngularLock,0f)) 949 if (!m_angularlock.ApproxEquals(m_taintAngularLock,0f))
954 changeAngularLock(); 950 changeAngularLock();
955 }
956 else
957 {
958 m_log.ErrorFormat("[PHYSICS]: The scene reused a disposed PhysActor for {0}! *waves finger*, Don't be evil. A couple of things can cause this. An improper prim breakdown(be sure to set prim_geom to zero after d.GeomDestroy! An improper buildup (creating the geom failed). Or, the Scene Reused a physics actor after disposing it.)", Name);
959 }
960 } 951 }
961 952
962 /// <summary> 953 /// <summary>
@@ -1052,150 +1043,146 @@ Console.WriteLine("ZProcessTaints for " + Name);
1052 /// <param name="prim">Child prim</param> 1043 /// <param name="prim">Child prim</param>
1053 private void AddChildPrim(OdePrim prim) 1044 private void AddChildPrim(OdePrim prim)
1054 { 1045 {
1055//Console.WriteLine("AddChildPrim " + Name); 1046 if (LocalID == prim.LocalID)
1056 if (LocalID != prim.LocalID) 1047 return;
1048
1049 if (Body == IntPtr.Zero)
1057 { 1050 {
1058 if (Body == IntPtr.Zero) 1051 Body = d.BodyCreate(_parent_scene.world);
1052 setMass();
1053 }
1054
1055 lock (childrenPrim)
1056 {
1057 if (childrenPrim.Contains(prim))
1058 return;
1059
1060// m_log.DebugFormat(
1061// "[ODE PRIM]: Linking prim {0} {1} to {2} {3}", prim.Name, prim.LocalID, Name, LocalID);
1062
1063 childrenPrim.Add(prim);
1064
1065 foreach (OdePrim prm in childrenPrim)
1059 { 1066 {
1060 Body = d.BodyCreate(_parent_scene.world); 1067 d.Mass m2;
1061 setMass(); 1068 d.MassSetZero(out m2);
1069 d.MassSetBoxTotal(out m2, prim.CalculateMass(), prm._size.X, prm._size.Y, prm._size.Z);
1070
1071 d.Quaternion quat = new d.Quaternion();
1072 quat.W = prm._orientation.W;
1073 quat.X = prm._orientation.X;
1074 quat.Y = prm._orientation.Y;
1075 quat.Z = prm._orientation.Z;
1076
1077 d.Matrix3 mat = new d.Matrix3();
1078 d.RfromQ(out mat, ref quat);
1079 d.MassRotate(ref m2, ref mat);
1080 d.MassTranslate(ref m2, Position.X - prm.Position.X, Position.Y - prm.Position.Y, Position.Z - prm.Position.Z);
1081 d.MassAdd(ref pMass, ref m2);
1062 } 1082 }
1063 if (Body != IntPtr.Zero) 1083
1084 foreach (OdePrim prm in childrenPrim)
1064 { 1085 {
1065 lock (childrenPrim) 1086 prm.m_collisionCategories |= CollisionCategories.Body;
1066 { 1087 prm.m_collisionFlags |= (CollisionCategories.Land | CollisionCategories.Wind);
1067 if (!childrenPrim.Contains(prim))
1068 {
1069//Console.WriteLine("childrenPrim.Add " + prim);
1070 childrenPrim.Add(prim);
1071
1072 foreach (OdePrim prm in childrenPrim)
1073 {
1074 d.Mass m2;
1075 d.MassSetZero(out m2);
1076 d.MassSetBoxTotal(out m2, prim.CalculateMass(), prm._size.X, prm._size.Y, prm._size.Z);
1077
1078 d.Quaternion quat = new d.Quaternion();
1079 quat.W = prm._orientation.W;
1080 quat.X = prm._orientation.X;
1081 quat.Y = prm._orientation.Y;
1082 quat.Z = prm._orientation.Z;
1083
1084 d.Matrix3 mat = new d.Matrix3();
1085 d.RfromQ(out mat, ref quat);
1086 d.MassRotate(ref m2, ref mat);
1087 d.MassTranslate(ref m2, Position.X - prm.Position.X, Position.Y - prm.Position.Y, Position.Z - prm.Position.Z);
1088 d.MassAdd(ref pMass, ref m2);
1089 }
1090
1091 foreach (OdePrim prm in childrenPrim)
1092 {
1093 prm.m_collisionCategories |= CollisionCategories.Body;
1094 prm.m_collisionFlags |= (CollisionCategories.Land | CollisionCategories.Wind);
1095 1088
1096 if (prm.prim_geom == IntPtr.Zero)
1097 {
1098 m_log.WarnFormat(
1099 "[PHYSICS]: Unable to link one of the linkset elements {0} for parent {1}. No geom yet",
1100 prm.Name, prim.Name);
1101 continue;
1102 }
1103//Console.WriteLine(" GeomSetCategoryBits 1: " + prm.prim_geom + " - " + (int)prm.m_collisionCategories + " for " + Name); 1089//Console.WriteLine(" GeomSetCategoryBits 1: " + prm.prim_geom + " - " + (int)prm.m_collisionCategories + " for " + Name);
1104 d.GeomSetCategoryBits(prm.prim_geom, (int)prm.m_collisionCategories); 1090 d.GeomSetCategoryBits(prm.prim_geom, (int)prm.m_collisionCategories);
1105 d.GeomSetCollideBits(prm.prim_geom, (int)prm.m_collisionFlags); 1091 d.GeomSetCollideBits(prm.prim_geom, (int)prm.m_collisionFlags);
1106
1107 1092
1108 d.Quaternion quat = new d.Quaternion(); 1093 d.Quaternion quat = new d.Quaternion();
1109 quat.W = prm._orientation.W; 1094 quat.W = prm._orientation.W;
1110 quat.X = prm._orientation.X; 1095 quat.X = prm._orientation.X;
1111 quat.Y = prm._orientation.Y; 1096 quat.Y = prm._orientation.Y;
1112 quat.Z = prm._orientation.Z; 1097 quat.Z = prm._orientation.Z;
1113 1098
1114 d.Matrix3 mat = new d.Matrix3(); 1099 d.Matrix3 mat = new d.Matrix3();
1115 d.RfromQ(out mat, ref quat); 1100 d.RfromQ(out mat, ref quat);
1116 if (Body != IntPtr.Zero) 1101 if (Body != IntPtr.Zero)
1117 { 1102 {
1118 d.GeomSetBody(prm.prim_geom, Body); 1103 d.GeomSetBody(prm.prim_geom, Body);
1119 prm.childPrim = true; 1104 prm.childPrim = true;
1120 d.GeomSetOffsetWorldPosition(prm.prim_geom, prm.Position.X , prm.Position.Y, prm.Position.Z); 1105 d.GeomSetOffsetWorldPosition(prm.prim_geom, prm.Position.X , prm.Position.Y, prm.Position.Z);
1121 //d.GeomSetOffsetPosition(prim.prim_geom, 1106 //d.GeomSetOffsetPosition(prim.prim_geom,
1122 // (Position.X - prm.Position.X) - pMass.c.X, 1107 // (Position.X - prm.Position.X) - pMass.c.X,
1123 // (Position.Y - prm.Position.Y) - pMass.c.Y, 1108 // (Position.Y - prm.Position.Y) - pMass.c.Y,
1124 // (Position.Z - prm.Position.Z) - pMass.c.Z); 1109 // (Position.Z - prm.Position.Z) - pMass.c.Z);
1125 d.GeomSetOffsetWorldRotation(prm.prim_geom, ref mat); 1110 d.GeomSetOffsetWorldRotation(prm.prim_geom, ref mat);
1126 //d.GeomSetOffsetRotation(prm.prim_geom, ref mat); 1111 //d.GeomSetOffsetRotation(prm.prim_geom, ref mat);
1127 d.MassTranslate(ref pMass, -pMass.c.X, -pMass.c.Y, -pMass.c.Z); 1112 d.MassTranslate(ref pMass, -pMass.c.X, -pMass.c.Y, -pMass.c.Z);
1128 d.BodySetMass(Body, ref pMass); 1113 d.BodySetMass(Body, ref pMass);
1129 } 1114 }
1130 else 1115 else
1131 { 1116 {
1132 m_log.DebugFormat("[PHYSICS]: {0} ain't got no boooooooooddy, no body", Name); 1117 m_log.DebugFormat("[PHYSICS]: {0} ain't got no boooooooooddy, no body", Name);
1133 } 1118 }
1134 1119
1135 prm.m_interpenetrationcount = 0; 1120 prm.m_interpenetrationcount = 0;
1136 prm.m_collisionscore = 0; 1121 prm.m_collisionscore = 0;
1137 prm.m_disabled = false; 1122 prm.m_disabled = false;
1138 1123
1139 // The body doesn't already have a finite rotation mode set here 1124 // The body doesn't already have a finite rotation mode set here
1140 if ((!m_angularlock.ApproxEquals(Vector3.Zero, 0f)) && _parent == null) 1125 if ((!m_angularlock.ApproxEquals(Vector3.Zero, 0f)) && _parent == null)
1141 { 1126 {
1142 prm.createAMotor(m_angularlock); 1127 prm.createAMotor(m_angularlock);
1143 } 1128 }
1144 prm.Body = Body; 1129 prm.Body = Body;
1145 _parent_scene.ActivatePrim(prm); 1130 _parent_scene.ActivatePrim(prm);
1146 } 1131 }
1147 1132
1148 m_collisionCategories |= CollisionCategories.Body; 1133 m_collisionCategories |= CollisionCategories.Body;
1149 m_collisionFlags |= (CollisionCategories.Land | CollisionCategories.Wind); 1134 m_collisionFlags |= (CollisionCategories.Land | CollisionCategories.Wind);
1150 1135
1151//Console.WriteLine("GeomSetCategoryBits 2: " + prim_geom + " - " + (int)m_collisionCategories + " for " + Name); 1136//Console.WriteLine("GeomSetCategoryBits 2: " + prim_geom + " - " + (int)m_collisionCategories + " for " + Name);
1152 d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories); 1137 d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories);
1153//Console.WriteLine(" Post GeomSetCategoryBits 2"); 1138//Console.WriteLine(" Post GeomSetCategoryBits 2");
1154 d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags); 1139 d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags);
1155
1156 d.Quaternion quat2 = new d.Quaternion();
1157 quat2.W = _orientation.W;
1158 quat2.X = _orientation.X;
1159 quat2.Y = _orientation.Y;
1160 quat2.Z = _orientation.Z;
1161
1162 d.Matrix3 mat2 = new d.Matrix3();
1163 d.RfromQ(out mat2, ref quat2);
1164 d.GeomSetBody(prim_geom, Body);
1165 d.GeomSetOffsetWorldPosition(prim_geom, Position.X - pMass.c.X, Position.Y - pMass.c.Y, Position.Z - pMass.c.Z);
1166 //d.GeomSetOffsetPosition(prim.prim_geom,
1167 // (Position.X - prm.Position.X) - pMass.c.X,
1168 // (Position.Y - prm.Position.Y) - pMass.c.Y,
1169 // (Position.Z - prm.Position.Z) - pMass.c.Z);
1170 //d.GeomSetOffsetRotation(prim_geom, ref mat2);
1171 d.MassTranslate(ref pMass, -pMass.c.X, -pMass.c.Y, -pMass.c.Z);
1172 d.BodySetMass(Body, ref pMass);
1173
1174 d.BodySetAutoDisableFlag(Body, true);
1175 d.BodySetAutoDisableSteps(Body, body_autodisable_frames);
1176 1140
1177 m_interpenetrationcount = 0; 1141 d.Quaternion quat2 = new d.Quaternion();
1178 m_collisionscore = 0; 1142 quat2.W = _orientation.W;
1179 m_disabled = false; 1143 quat2.X = _orientation.X;
1144 quat2.Y = _orientation.Y;
1145 quat2.Z = _orientation.Z;
1180 1146
1181 // The body doesn't already have a finite rotation mode set here 1147 d.Matrix3 mat2 = new d.Matrix3();
1182 if ((!m_angularlock.ApproxEquals(Vector3.Zero, 0f)) && _parent == null) 1148 d.RfromQ(out mat2, ref quat2);
1183 { 1149 d.GeomSetBody(prim_geom, Body);
1184 createAMotor(m_angularlock); 1150 d.GeomSetOffsetWorldPosition(prim_geom, Position.X - pMass.c.X, Position.Y - pMass.c.Y, Position.Z - pMass.c.Z);
1185 } 1151 //d.GeomSetOffsetPosition(prim.prim_geom,
1186 d.BodySetPosition(Body, Position.X, Position.Y, Position.Z); 1152 // (Position.X - prm.Position.X) - pMass.c.X,
1187 if (m_vehicle.Type != Vehicle.TYPE_NONE) 1153 // (Position.Y - prm.Position.Y) - pMass.c.Y,
1188 m_vehicle.Enable(Body, _parent_scene); 1154 // (Position.Z - prm.Position.Z) - pMass.c.Z);
1155 //d.GeomSetOffsetRotation(prim_geom, ref mat2);
1156 d.MassTranslate(ref pMass, -pMass.c.X, -pMass.c.Y, -pMass.c.Z);
1157 d.BodySetMass(Body, ref pMass);
1189 1158
1190 _parent_scene.ActivatePrim(this); 1159 d.BodySetAutoDisableFlag(Body, true);
1191 } 1160 d.BodySetAutoDisableSteps(Body, body_autodisable_frames);
1192 } 1161
1162 m_interpenetrationcount = 0;
1163 m_collisionscore = 0;
1164 m_disabled = false;
1165
1166 // The body doesn't already have a finite rotation mode set here
1167 if ((!m_angularlock.ApproxEquals(Vector3.Zero, 0f)) && _parent == null)
1168 {
1169 createAMotor(m_angularlock);
1193 } 1170 }
1171
1172 d.BodySetPosition(Body, Position.X, Position.Y, Position.Z);
1173
1174 if (m_vehicle.Type != Vehicle.TYPE_NONE)
1175 m_vehicle.Enable(Body, _parent_scene);
1176
1177 _parent_scene.ActivatePrim(this);
1194 } 1178 }
1195 } 1179 }
1196 1180
1197 private void ChildSetGeom(OdePrim odePrim) 1181 private void ChildSetGeom(OdePrim odePrim)
1198 { 1182 {
1183// m_log.DebugFormat(
1184// "[ODE PRIM]: ChildSetGeom {0} {1} for {2} {3}", odePrim.Name, odePrim.LocalID, Name, LocalID);
1185
1199 //if (IsPhysical && Body != IntPtr.Zero) 1186 //if (IsPhysical && Body != IntPtr.Zero)
1200 lock (childrenPrim) 1187 lock (childrenPrim)
1201 { 1188 {
@@ -1210,12 +1197,14 @@ Console.WriteLine("ZProcessTaints for " + Name);
1210 //prm.childPrim = false; 1197 //prm.childPrim = false;
1211 } 1198 }
1212 } 1199 }
1200
1213 disableBody(); 1201 disableBody();
1214 1202
1215 if (Body != IntPtr.Zero) 1203 // Spurious - Body == IntPtr.Zero after disableBody()
1216 { 1204// if (Body != IntPtr.Zero)
1217 _parent_scene.DeactivatePrim(this); 1205// {
1218 } 1206// _parent_scene.DeactivatePrim(this);
1207// }
1219 1208
1220 lock (childrenPrim) 1209 lock (childrenPrim)
1221 { 1210 {
@@ -1229,6 +1218,9 @@ Console.WriteLine("ZProcessTaints for " + Name);
1229 1218
1230 private void ChildDelink(OdePrim odePrim) 1219 private void ChildDelink(OdePrim odePrim)
1231 { 1220 {
1221// m_log.DebugFormat(
1222// "[ODE PRIM]: Delinking prim {0} {1} from {2} {3}", odePrim.Name, odePrim.LocalID, Name, LocalID);
1223
1232 // Okay, we have a delinked child.. need to rebuild the body. 1224 // Okay, we have a delinked child.. need to rebuild the body.
1233 lock (childrenPrim) 1225 lock (childrenPrim)
1234 { 1226 {
@@ -1243,6 +1235,7 @@ Console.WriteLine("ZProcessTaints for " + Name);
1243 //prm.childPrim = false; 1235 //prm.childPrim = false;
1244 } 1236 }
1245 } 1237 }
1238
1246 disableBody(); 1239 disableBody();
1247 1240
1248 lock (childrenPrim) 1241 lock (childrenPrim)
@@ -1251,10 +1244,11 @@ Console.WriteLine("ZProcessTaints for " + Name);
1251 childrenPrim.Remove(odePrim); 1244 childrenPrim.Remove(odePrim);
1252 } 1245 }
1253 1246
1254 if (Body != IntPtr.Zero) 1247 // Spurious - Body == IntPtr.Zero after disableBody()
1255 { 1248// if (Body != IntPtr.Zero)
1256 _parent_scene.DeactivatePrim(this); 1249// {
1257 } 1250// _parent_scene.DeactivatePrim(this);
1251// }
1258 1252
1259 lock (childrenPrim) 1253 lock (childrenPrim)
1260 { 1254 {
@@ -1303,11 +1297,8 @@ Console.WriteLine("ZProcessTaints for " + Name);
1303 disableBodySoft(); 1297 disableBodySoft();
1304 } 1298 }
1305 1299
1306 if (prim_geom != IntPtr.Zero) 1300 d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories);
1307 { 1301 d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags);
1308 d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories);
1309 d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags);
1310 }
1311 1302
1312 if (IsPhysical) 1303 if (IsPhysical)
1313 { 1304 {
@@ -1328,11 +1319,8 @@ Console.WriteLine("ZProcessTaints for " + Name);
1328 if (m_collidesWater) 1319 if (m_collidesWater)
1329 m_collisionFlags |= CollisionCategories.Water; 1320 m_collisionFlags |= CollisionCategories.Water;
1330 1321
1331 if (prim_geom != IntPtr.Zero) 1322 d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories);
1332 { 1323 d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags);
1333 d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories);
1334 d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags);
1335 }
1336 1324
1337 if (IsPhysical) 1325 if (IsPhysical)
1338 { 1326 {
@@ -1472,6 +1460,9 @@ Console.WriteLine("CreateGeom:");
1472 } 1460 }
1473 else 1461 else
1474 { 1462 {
1463 m_log.WarnFormat(
1464 "[ODE PRIM]: Called RemoveGeom() on {0} {1} where geometry was already null.", Name, LocalID);
1465
1475 return false; 1466 return false;
1476 } 1467 }
1477 } 1468 }
@@ -1505,16 +1496,13 @@ Console.WriteLine("changeadd 1");
1505#endif 1496#endif
1506 CreateGeom(m_targetSpace, mesh); 1497 CreateGeom(m_targetSpace, mesh);
1507 1498
1508 if (prim_geom != IntPtr.Zero) 1499 d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z);
1509 { 1500 d.Quaternion myrot = new d.Quaternion();
1510 d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z); 1501 myrot.X = _orientation.X;
1511 d.Quaternion myrot = new d.Quaternion(); 1502 myrot.Y = _orientation.Y;
1512 myrot.X = _orientation.X; 1503 myrot.Z = _orientation.Z;
1513 myrot.Y = _orientation.Y; 1504 myrot.W = _orientation.W;
1514 myrot.Z = _orientation.Z; 1505 d.GeomSetQuaternion(prim_geom, ref myrot);
1515 myrot.W = _orientation.W;
1516 d.GeomSetQuaternion(prim_geom, ref myrot);
1517 }
1518 1506
1519 if (IsPhysical && Body == IntPtr.Zero) 1507 if (IsPhysical && Body == IntPtr.Zero)
1520 enableBody(); 1508 enableBody();
@@ -1579,24 +1567,20 @@ Console.WriteLine(" JointCreateFixed");
1579 //m_log.Debug("[BUG]: race!"); 1567 //m_log.Debug("[BUG]: race!");
1580 //} 1568 //}
1581 } 1569 }
1582 else
1583 {
1584 // string primScenAvatarIn = _parent_scene.whichspaceamIin(_position);
1585 // int[] arrayitem = _parent_scene.calculateSpaceArrayItemFromPos(_position);
1586// _parent_scene.waitForSpaceUnlock(m_targetSpace);
1587 1570
1588 IntPtr tempspace = _parent_scene.recalculateSpaceForGeom(prim_geom, _position, m_targetSpace); 1571 // string primScenAvatarIn = _parent_scene.whichspaceamIin(_position);
1589 m_targetSpace = tempspace; 1572 // int[] arrayitem = _parent_scene.calculateSpaceArrayItemFromPos(_position);
1573// _parent_scene.waitForSpaceUnlock(m_targetSpace);
1574
1575 IntPtr tempspace = _parent_scene.recalculateSpaceForGeom(prim_geom, _position, m_targetSpace);
1576 m_targetSpace = tempspace;
1590 1577
1591// _parent_scene.waitForSpaceUnlock(m_targetSpace); 1578// _parent_scene.waitForSpaceUnlock(m_targetSpace);
1592 if (prim_geom != IntPtr.Zero) 1579
1593 { 1580 d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z);
1594 d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z);
1595 1581
1596// _parent_scene.waitForSpaceUnlock(m_targetSpace); 1582// _parent_scene.waitForSpaceUnlock(m_targetSpace);
1597 d.SpaceAdd(m_targetSpace, prim_geom); 1583 d.SpaceAdd(m_targetSpace, prim_geom);
1598 }
1599 }
1600 1584
1601 changeSelectedStatus(); 1585 changeSelectedStatus();
1602 1586
@@ -2047,18 +2031,16 @@ Console.WriteLine(" JointCreateFixed");
2047 { 2031 {
2048 m_collidesWater = m_taintCollidesWater; 2032 m_collidesWater = m_taintCollidesWater;
2049 2033
2050 if (prim_geom != IntPtr.Zero) 2034 if (m_collidesWater)
2051 { 2035 {
2052 if (m_collidesWater) 2036 m_collisionFlags |= CollisionCategories.Water;
2053 {
2054 m_collisionFlags |= CollisionCategories.Water;
2055 }
2056 else
2057 {
2058 m_collisionFlags &= ~CollisionCategories.Water;
2059 }
2060 d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags);
2061 } 2037 }
2038 else
2039 {
2040 m_collisionFlags &= ~CollisionCategories.Water;
2041 }
2042
2043 d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags);
2062 } 2044 }
2063 2045
2064 /// <summary> 2046 /// <summary>
diff --git a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
index 842ff91..409b27b 100644
--- a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
+++ b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
@@ -2226,7 +2226,8 @@ namespace OpenSim.Region.Physics.OdePlugin
2226 /// <param name="prim"></param> 2226 /// <param name="prim"></param>
2227 internal void RemovePrimThreadLocked(OdePrim prim) 2227 internal void RemovePrimThreadLocked(OdePrim prim)
2228 { 2228 {
2229//Console.WriteLine("RemovePrimThreadLocked " + prim.m_primName); 2229// m_log.DebugFormat("[ODE SCENE]: Removing physical prim {0} {1}", prim.Name, prim.LocalID);
2230
2230 lock (prim) 2231 lock (prim)
2231 { 2232 {
2232 RemoveCollisionEventReporting(prim); 2233 RemoveCollisionEventReporting(prim);
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 36c9d5e..d4c872c 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)
@@ -839,13 +839,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
839 839
840 m_host.AddScriptLPS(1); 840 m_host.AddScriptLPS(1);
841 841
842 if (channel == ScriptBaseClass.DEBUG_CHANNEL)
843 {
844 return;
845 }
846
842 UUID TargetID; 847 UUID TargetID;
843 UUID.TryParse(target, out TargetID); 848 UUID.TryParse(target, out TargetID);
844 849
845 IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); 850 IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
846 if (wComm != null) 851 if (wComm != null)
847 if (!wComm.DeliverMessageTo(TargetID, channel, m_host.AbsolutePosition, m_host.Name, m_host.UUID, msg, out error)) 852 wComm.DeliverMessageTo(TargetID, channel, m_host.AbsolutePosition, m_host.Name, m_host.UUID, msg);
848 LSLError(error);
849 } 853 }
850 854
851 public LSL_Integer llListen(int channelID, string name, string ID, string msg) 855 public LSL_Integer llListen(int channelID, string name, string ID, string msg)
@@ -2697,18 +2701,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2697 2701
2698 public LSL_Integer llGiveMoney(string destination, int amount) 2702 public LSL_Integer llGiveMoney(string destination, int amount)
2699 { 2703 {
2700 UUID invItemID=InventorySelf();
2701 if (invItemID == UUID.Zero)
2702 return 0;
2703
2704 m_host.AddScriptLPS(1); 2704 m_host.AddScriptLPS(1);
2705 2705
2706 TaskInventoryItem item = m_host.TaskInventory[invItemID]; 2706 TaskInventoryItem item = GetSelfInventoryItem();
2707
2708 lock (m_host.TaskInventory)
2709 {
2710 item = m_host.TaskInventory[invItemID];
2711 }
2712 2707
2713 if (item.PermsGranter == UUID.Zero) 2708 if (item.PermsGranter == UUID.Zero)
2714 return 0; 2709 return 0;
@@ -2951,15 +2946,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2951 2946
2952 public void llTakeControls(int controls, int accept, int pass_on) 2947 public void llTakeControls(int controls, int accept, int pass_on)
2953 { 2948 {
2954 TaskInventoryItem item; 2949 TaskInventoryItem item = GetSelfInventoryItem();
2955
2956 lock (m_host.TaskInventory)
2957 {
2958 if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
2959 return;
2960 else
2961 item = m_host.TaskInventory[InventorySelf()];
2962 }
2963 2950
2964 if (item.PermsGranter != UUID.Zero) 2951 if (item.PermsGranter != UUID.Zero)
2965 { 2952 {
@@ -2979,18 +2966,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2979 2966
2980 public void llReleaseControls() 2967 public void llReleaseControls()
2981 { 2968 {
2982 TaskInventoryItem item;
2983
2984 lock (m_host.TaskInventory)
2985 {
2986 if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
2987 return;
2988 else
2989 item = m_host.TaskInventory[InventorySelf()];
2990 }
2991
2992 m_host.AddScriptLPS(1); 2969 m_host.AddScriptLPS(1);
2993 2970
2971 TaskInventoryItem item = GetSelfInventoryItem();
2972
2994 if (item.PermsGranter != UUID.Zero) 2973 if (item.PermsGranter != UUID.Zero)
2995 { 2974 {
2996 ScenePresence presence = World.GetScenePresence(item.PermsGranter); 2975 ScenePresence presence = World.GetScenePresence(item.PermsGranter);
@@ -3015,36 +2994,62 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3015 m_UrlModule.ReleaseURL(url); 2994 m_UrlModule.ReleaseURL(url);
3016 } 2995 }
3017 2996
3018 public void llAttachToAvatar(int attachment) 2997 /// <summary>
2998 /// Attach the object containing this script to the avatar that owns it.
2999 /// </summary>
3000 /// <param name='attachment'>The attachment point (e.g. ATTACH_CHEST)</param>
3001 /// <returns>true if the attach suceeded, false if it did not</returns>
3002 public bool AttachToAvatar(int attachmentPoint)
3003 {
3004 SceneObjectGroup grp = m_host.ParentGroup;
3005 ScenePresence presence = World.GetScenePresence(m_host.OwnerID);
3006
3007 IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule;
3008
3009 if (attachmentsModule != null)
3010 return attachmentsModule.AttachObject(presence, grp, (uint)attachmentPoint, false);
3011 else
3012 return false;
3013 }
3014
3015 /// <summary>
3016 /// Detach the object containing this script from the avatar it is attached to.
3017 /// </summary>
3018 /// <remarks>
3019 /// Nothing happens if the object is not attached.
3020 /// </remarks>
3021 public void DetachFromAvatar()
3022 {
3023 Util.FireAndForget(DetachWrapper, m_host);
3024 }
3025
3026 private void DetachWrapper(object o)
3027 {
3028 SceneObjectPart host = (SceneObjectPart)o;
3029
3030 SceneObjectGroup grp = host.ParentGroup;
3031 UUID itemID = grp.FromItemID;
3032 ScenePresence presence = World.GetScenePresence(host.OwnerID);
3033
3034 IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule;
3035 if (attachmentsModule != null)
3036 attachmentsModule.DetachSingleAttachmentToInv(presence, itemID);
3037 }
3038
3039 public void llAttachToAvatar(int attachmentPoint)
3019 { 3040 {
3020 m_host.AddScriptLPS(1); 3041 m_host.AddScriptLPS(1);
3021 3042
3022// if (m_host.ParentGroup.RootPart.AttachmentPoint == 0) 3043// if (m_host.ParentGroup.RootPart.AttachmentPoint == 0)
3023// return; 3044// return;
3024 3045
3025 TaskInventoryItem item; 3046 TaskInventoryItem item = GetSelfInventoryItem();
3026
3027 lock (m_host.TaskInventory)
3028 {
3029 if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
3030 return;
3031 else
3032 item = m_host.TaskInventory[InventorySelf()];
3033 }
3034 3047
3035 if (item.PermsGranter != m_host.OwnerID) 3048 if (item.PermsGranter != m_host.OwnerID)
3036 return; 3049 return;
3037 3050
3038 if ((item.PermsMask & ScriptBaseClass.PERMISSION_ATTACH) != 0) 3051 if ((item.PermsMask & ScriptBaseClass.PERMISSION_ATTACH) != 0)
3039 { 3052 AttachToAvatar(attachmentPoint);
3040 SceneObjectGroup grp = m_host.ParentGroup;
3041
3042 ScenePresence presence = World.GetScenePresence(m_host.OwnerID);
3043
3044 IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule;
3045 if (attachmentsModule != null)
3046 attachmentsModule.AttachObject(presence, grp, (uint)attachment, false);
3047 }
3048 } 3053 }
3049 3054
3050 public void llDetachFromAvatar() 3055 public void llDetachFromAvatar()
@@ -3054,38 +3059,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3054 if (m_host.ParentGroup.AttachmentPoint == 0) 3059 if (m_host.ParentGroup.AttachmentPoint == 0)
3055 return; 3060 return;
3056 3061
3057 TaskInventoryItem item; 3062 TaskInventoryItem item = GetSelfInventoryItem();
3058
3059 lock (m_host.TaskInventory)
3060 {
3061 if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
3062 return;
3063 else
3064 item = m_host.TaskInventory[InventorySelf()];
3065 }
3066 3063
3067 if (item.PermsGranter != m_host.OwnerID) 3064 if (item.PermsGranter != m_host.OwnerID)
3068 return; 3065 return;
3069 3066
3070 if ((item.PermsMask & ScriptBaseClass.PERMISSION_ATTACH) != 0) 3067 if ((item.PermsMask & ScriptBaseClass.PERMISSION_ATTACH) != 0)
3071 { 3068 DetachFromAvatar();
3072 IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule;
3073 if (attachmentsModule != null)
3074 Util.FireAndForget(DetachWrapper, m_host);
3075 }
3076 }
3077
3078 private void DetachWrapper(object o)
3079 {
3080 SceneObjectPart host = (SceneObjectPart)o;
3081
3082 SceneObjectGroup grp = host.ParentGroup;
3083 UUID itemID = grp.FromItemID;
3084 ScenePresence presence = World.GetScenePresence(host.OwnerID);
3085
3086 IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule;
3087 if (attachmentsModule != null)
3088 attachmentsModule.DetachSingleAttachmentToInv(presence, itemID);
3089 } 3069 }
3090 3070
3091 public void llTakeCamera(string avatar) 3071 public void llTakeCamera(string avatar)
@@ -3313,19 +3293,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3313 { 3293 {
3314 m_host.AddScriptLPS(1); 3294 m_host.AddScriptLPS(1);
3315 3295
3316 UUID invItemID = InventorySelf(); 3296 TaskInventoryItem item = GetSelfInventoryItem();
3317 if (invItemID == UUID.Zero)
3318 return;
3319
3320 TaskInventoryItem item;
3321
3322 lock (m_host.TaskInventory)
3323 {
3324 if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
3325 return;
3326 else
3327 item = m_host.TaskInventory[InventorySelf()];
3328 }
3329 3297
3330 if (item.PermsGranter == UUID.Zero) 3298 if (item.PermsGranter == UUID.Zero)
3331 return; 3299 return;
@@ -3350,19 +3318,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3350 { 3318 {
3351 m_host.AddScriptLPS(1); 3319 m_host.AddScriptLPS(1);
3352 3320
3353 UUID invItemID=InventorySelf(); 3321 TaskInventoryItem item = GetSelfInventoryItem();
3354 if (invItemID == UUID.Zero)
3355 return;
3356
3357 TaskInventoryItem item;
3358
3359 lock (m_host.TaskInventory)
3360 {
3361 if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
3362 return;
3363 else
3364 item = m_host.TaskInventory[InventorySelf()];
3365 }
3366 3322
3367 if (item.PermsGranter == UUID.Zero) 3323 if (item.PermsGranter == UUID.Zero)
3368 return; 3324 return;
@@ -3417,22 +3373,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3417 3373
3418 public void llRequestPermissions(string agent, int perm) 3374 public void llRequestPermissions(string agent, int perm)
3419 { 3375 {
3420 UUID agentID = new UUID(); 3376 UUID agentID;
3421 3377
3422 if (!UUID.TryParse(agent, out agentID)) 3378 if (!UUID.TryParse(agent, out agentID))
3423 return; 3379 return;
3424 3380
3425 UUID invItemID = InventorySelf(); 3381 TaskInventoryItem item = GetSelfInventoryItem();
3426
3427 if (invItemID == UUID.Zero)
3428 return; // Not in a prim? How??
3429
3430 TaskInventoryItem item;
3431
3432 lock (m_host.TaskInventory)
3433 {
3434 item = m_host.TaskInventory[invItemID];
3435 }
3436 3382
3437 if (agentID == UUID.Zero || perm == 0) // Releasing permissions 3383 if (agentID == UUID.Zero || perm == 0) // Releasing permissions
3438 { 3384 {
@@ -3466,8 +3412,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3466 { 3412 {
3467 lock (m_host.TaskInventory) 3413 lock (m_host.TaskInventory)
3468 { 3414 {
3469 m_host.TaskInventory[invItemID].PermsGranter = agentID; 3415 m_host.TaskInventory[m_itemID].PermsGranter = agentID;
3470 m_host.TaskInventory[invItemID].PermsMask = perm; 3416 m_host.TaskInventory[m_itemID].PermsMask = perm;
3471 } 3417 }
3472 3418
3473 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( 3419 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams(
@@ -3490,8 +3436,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3490 { 3436 {
3491 lock (m_host.TaskInventory) 3437 lock (m_host.TaskInventory)
3492 { 3438 {
3493 m_host.TaskInventory[invItemID].PermsGranter = agentID; 3439 m_host.TaskInventory[m_itemID].PermsGranter = agentID;
3494 m_host.TaskInventory[invItemID].PermsMask = perm; 3440 m_host.TaskInventory[m_itemID].PermsMask = perm;
3495 } 3441 }
3496 3442
3497 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( 3443 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams(
@@ -3515,8 +3461,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3515 { 3461 {
3516 lock (m_host.TaskInventory) 3462 lock (m_host.TaskInventory)
3517 { 3463 {
3518 m_host.TaskInventory[invItemID].PermsGranter = agentID; 3464 m_host.TaskInventory[m_itemID].PermsGranter = agentID;
3519 m_host.TaskInventory[invItemID].PermsMask = 0; 3465 m_host.TaskInventory[m_itemID].PermsMask = 0;
3520 } 3466 }
3521 3467
3522 presence.ControllingClient.OnScriptAnswer += handleScriptAnswer; 3468 presence.ControllingClient.OnScriptAnswer += handleScriptAnswer;
@@ -3524,7 +3470,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3524 } 3470 }
3525 3471
3526 presence.ControllingClient.SendScriptQuestion( 3472 presence.ControllingClient.SendScriptQuestion(
3527 m_host.UUID, m_host.ParentGroup.RootPart.Name, ownerName, invItemID, perm); 3473 m_host.UUID, m_host.ParentGroup.RootPart.Name, ownerName, m_itemID, perm);
3528 3474
3529 return; 3475 return;
3530 } 3476 }
@@ -3541,20 +3487,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3541 if (taskID != m_host.UUID) 3487 if (taskID != m_host.UUID)
3542 return; 3488 return;
3543 3489
3544 UUID invItemID = InventorySelf(); 3490 client.OnScriptAnswer -= handleScriptAnswer;
3545 3491 m_waitingForScriptAnswer = false;
3546 if (invItemID == UUID.Zero)
3547 return;
3548
3549 client.OnScriptAnswer-=handleScriptAnswer;
3550 m_waitingForScriptAnswer=false;
3551 3492
3552 if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) 3493 if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0)
3553 llReleaseControls(); 3494 llReleaseControls();
3554 3495
3555 lock (m_host.TaskInventory) 3496 lock (m_host.TaskInventory)
3556 { 3497 {
3557 m_host.TaskInventory[invItemID].PermsMask = answer; 3498 m_host.TaskInventory[m_itemID].PermsMask = answer;
3558 } 3499 }
3559 3500
3560 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( 3501 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams(
@@ -3567,39 +3508,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3567 { 3508 {
3568 m_host.AddScriptLPS(1); 3509 m_host.AddScriptLPS(1);
3569 3510
3570 lock (m_host.TaskInventory) 3511 return GetSelfInventoryItem().PermsGranter.ToString();
3571 {
3572 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
3573 {
3574 if (item.Type == 10 && item.ItemID == m_itemID)
3575 {
3576 return item.PermsGranter.ToString();
3577 }
3578 }
3579 }
3580
3581 return UUID.Zero.ToString();
3582 } 3512 }
3583 3513
3584 public LSL_Integer llGetPermissions() 3514 public LSL_Integer llGetPermissions()
3585 { 3515 {
3586 m_host.AddScriptLPS(1); 3516 m_host.AddScriptLPS(1);
3587 3517
3588 lock (m_host.TaskInventory) 3518 int perms = GetSelfInventoryItem().PermsMask;
3589 {
3590 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
3591 {
3592 if (item.Type == 10 && item.ItemID == m_itemID)
3593 {
3594 int perms = item.PermsMask;
3595 if (m_automaticLinkPermission)
3596 perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS;
3597 return perms;
3598 }
3599 }
3600 }
3601 3519
3602 return 0; 3520 if (m_automaticLinkPermission)
3521 perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS;
3522
3523 return perms;
3603 } 3524 }
3604 3525
3605 public LSL_Integer llGetLinkNumber() 3526 public LSL_Integer llGetLinkNumber()
@@ -3627,17 +3548,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3627 public void llCreateLink(string target, int parent) 3548 public void llCreateLink(string target, int parent)
3628 { 3549 {
3629 m_host.AddScriptLPS(1); 3550 m_host.AddScriptLPS(1);
3630 UUID invItemID = InventorySelf(); 3551
3631 UUID targetID; 3552 UUID targetID;
3632 3553
3633 if (!UUID.TryParse(target, out targetID)) 3554 if (!UUID.TryParse(target, out targetID))
3634 return; 3555 return;
3635 3556
3636 TaskInventoryItem item; 3557 TaskInventoryItem item = GetSelfInventoryItem();
3637 lock (m_host.TaskInventory)
3638 {
3639 item = m_host.TaskInventory[invItemID];
3640 }
3641 3558
3642 if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 3559 if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0
3643 && !m_automaticLinkPermission) 3560 && !m_automaticLinkPermission)
@@ -3688,16 +3605,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3688 public void llBreakLink(int linknum) 3605 public void llBreakLink(int linknum)
3689 { 3606 {
3690 m_host.AddScriptLPS(1); 3607 m_host.AddScriptLPS(1);
3691 UUID invItemID = InventorySelf();
3692 3608
3693 lock (m_host.TaskInventory) 3609 if ((GetSelfInventoryItem().PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0
3610 && !m_automaticLinkPermission)
3694 { 3611 {
3695 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 3612 ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!");
3696 && !m_automaticLinkPermission) 3613 return;
3697 {
3698 ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!");
3699 return;
3700 }
3701 } 3614 }
3702 3615
3703 if (linknum < ScriptBaseClass.LINK_THIS) 3616 if (linknum < ScriptBaseClass.LINK_THIS)
@@ -4574,23 +4487,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4574 4487
4575 public LSL_String llGetScriptName() 4488 public LSL_String llGetScriptName()
4576 { 4489 {
4577 string result = String.Empty;
4578
4579 m_host.AddScriptLPS(1); 4490 m_host.AddScriptLPS(1);
4580 4491
4581 lock (m_host.TaskInventory) 4492 TaskInventoryItem item = GetSelfInventoryItem();
4582 {
4583 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
4584 {
4585 if (item.Type == 10 && item.ItemID == m_itemID)
4586 {
4587 result = item.Name != null ? item.Name : String.Empty;
4588 break;
4589 }
4590 }
4591 }
4592 4493
4593 return result; 4494 return item.Name != null ? item.Name : String.Empty;
4594 } 4495 }
4595 4496
4596 public LSL_Integer llGetLinkNumberOfSides(int link) 4497 public LSL_Integer llGetLinkNumberOfSides(int link)
@@ -9691,21 +9592,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9691 public LSL_Vector llGetCameraPos() 9592 public LSL_Vector llGetCameraPos()
9692 { 9593 {
9693 m_host.AddScriptLPS(1); 9594 m_host.AddScriptLPS(1);
9694 UUID invItemID = InventorySelf();
9695 9595
9696 if (invItemID == UUID.Zero) 9596 TaskInventoryItem item = GetSelfInventoryItem();
9697 return new LSL_Vector();
9698 9597
9699 lock (m_host.TaskInventory) 9598 if (item.PermsGranter == UUID.Zero)
9700 { 9599 return new LSL_Vector();
9701 if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero)
9702 return new LSL_Vector();
9703 9600
9704 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) 9601 if ((item.PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0)
9705 { 9602 {
9706 ShoutError("No permissions to track the camera"); 9603 ShoutError("No permissions to track the camera");
9707 return new LSL_Vector(); 9604 return new LSL_Vector();
9708 }
9709 } 9605 }
9710 9606
9711 ScenePresence presence = World.GetScenePresence(m_host.OwnerID); 9607 ScenePresence presence = World.GetScenePresence(m_host.OwnerID);
@@ -9720,20 +9616,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9720 public LSL_Rotation llGetCameraRot() 9616 public LSL_Rotation llGetCameraRot()
9721 { 9617 {
9722 m_host.AddScriptLPS(1); 9618 m_host.AddScriptLPS(1);
9723 UUID invItemID = InventorySelf();
9724 if (invItemID == UUID.Zero)
9725 return new LSL_Rotation();
9726 9619
9727 lock (m_host.TaskInventory) 9620 TaskInventoryItem item = GetSelfInventoryItem();
9728 {
9729 if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero)
9730 return new LSL_Rotation();
9731 9621
9732 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) 9622 if (item.PermsGranter == UUID.Zero)
9733 { 9623 return new LSL_Rotation();
9734 ShoutError("No permissions to track the camera"); 9624
9735 return new LSL_Rotation(); 9625 if ((item.PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0)
9736 } 9626 {
9627 ShoutError("No permissions to track the camera");
9628 return new LSL_Rotation();
9737 } 9629 }
9738 9630
9739 ScenePresence presence = World.GetScenePresence(m_host.OwnerID); 9631 ScenePresence presence = World.GetScenePresence(m_host.OwnerID);
@@ -9907,23 +9799,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9907 { 9799 {
9908 m_host.AddScriptLPS(1); 9800 m_host.AddScriptLPS(1);
9909 9801
9910 // our key in the object we are in
9911 UUID invItemID = InventorySelf();
9912 if (invItemID == UUID.Zero) return;
9913
9914 // the object we are in 9802 // the object we are in
9915 UUID objectID = m_host.ParentUUID; 9803 UUID objectID = m_host.ParentUUID;
9916 if (objectID == UUID.Zero) return; 9804 if (objectID == UUID.Zero)
9805 return;
9917 9806
9918 UUID agentID; 9807 TaskInventoryItem item = GetSelfInventoryItem();
9919 lock (m_host.TaskInventory)
9920 {
9921 // we need the permission first, to know which avatar we want to set the camera for
9922 agentID = m_host.TaskInventory[invItemID].PermsGranter;
9923 9808
9924 if (agentID == UUID.Zero) return; 9809 // we need the permission first, to know which avatar we want to set the camera for
9925 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return; 9810 UUID agentID = item.PermsGranter;
9926 } 9811
9812 if (agentID == UUID.Zero)
9813 return;
9814
9815 if ((item.PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0)
9816 return;
9927 9817
9928 ScenePresence presence = World.GetScenePresence(agentID); 9818 ScenePresence presence = World.GetScenePresence(agentID);
9929 9819
@@ -9963,27 +9853,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9963 { 9853 {
9964 m_host.AddScriptLPS(1); 9854 m_host.AddScriptLPS(1);
9965 9855
9966 // our key in the object we are in
9967 UUID invItemID=InventorySelf();
9968 if (invItemID == UUID.Zero) return;
9969
9970 // the object we are in 9856 // the object we are in
9971 UUID objectID = m_host.ParentUUID; 9857 UUID objectID = m_host.ParentUUID;
9972 if (objectID == UUID.Zero) return; 9858 if (objectID == UUID.Zero)
9859 return;
9860
9861 TaskInventoryItem item = GetSelfInventoryItem();
9973 9862
9974 // we need the permission first, to know which avatar we want to clear the camera for 9863 // we need the permission first, to know which avatar we want to clear the camera for
9975 UUID agentID; 9864 UUID agentID = item.PermsGranter;
9976 lock (m_host.TaskInventory) 9865
9977 { 9866 if (agentID == UUID.Zero)
9978 agentID = m_host.TaskInventory[invItemID].PermsGranter; 9867 return;
9979 if (agentID == UUID.Zero) return; 9868
9980 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return; 9869 if ((item.PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0)
9981 } 9870 return;
9982 9871
9983 ScenePresence presence = World.GetScenePresence(agentID); 9872 ScenePresence presence = World.GetScenePresence(agentID);
9984 9873
9985 // we are not interested in child-agents 9874 // we are not interested in child-agents
9986 if (presence.IsChildAgent) return; 9875 if (presence.IsChildAgent)
9876 return;
9987 9877
9988 presence.ControllingClient.SendClearFollowCamProperties(objectID); 9878 presence.ControllingClient.SendClearFollowCamProperties(objectID);
9989 } 9879 }
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index fe94b79..7fc7337 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
@@ -3093,5 +3101,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3093 estate.setEstateTerrainTextureHeights(corner, (float)low, (float)high); 3101 estate.setEstateTerrainTextureHeights(corner, (float)low, (float)high);
3094 } 3102 }
3095 } 3103 }
3104
3105 public void osForceAttachToAvatar(int attachmentPoint)
3106 {
3107 CheckThreatLevel(ThreatLevel.High, "osForceAttachToAvatar");
3108
3109 m_host.AddScriptLPS(1);
3110
3111 InitLSL();
3112 ((LSL_Api)m_LSL_Api).AttachToAvatar(attachmentPoint);
3113 }
3114
3115 public void osForceDetachFromAvatar()
3116 {
3117 CheckThreatLevel(ThreatLevel.High, "osForceDetachFromAvatar");
3118
3119 m_host.AddScriptLPS(1);
3120
3121 InitLSL();
3122 ((LSL_Api)m_LSL_Api).DetachFromAvatar();
3123 }
3096 } 3124 }
3097} \ No newline at end of file 3125} \ 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 545bbee..d0c852b 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 b94b9bf..36ac0e3 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 b7903d5..a9b6e67 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
@@ -1021,11 +1021,18 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1021 1021
1022 AppDomain sandbox; 1022 AppDomain sandbox;
1023 if (m_AppDomainLoading) 1023 if (m_AppDomainLoading)
1024 {
1024 sandbox = AppDomain.CreateDomain( 1025 sandbox = AppDomain.CreateDomain(
1025 m_Scene.RegionInfo.RegionID.ToString(), 1026 m_Scene.RegionInfo.RegionID.ToString(),
1026 evidence, appSetup); 1027 evidence, appSetup);
1028 sandbox.AssemblyResolve +=
1029 new ResolveEventHandler(
1030 AssemblyResolver.OnAssemblyResolve);
1031 }
1027 else 1032 else
1033 {
1028 sandbox = AppDomain.CurrentDomain; 1034 sandbox = AppDomain.CurrentDomain;
1035 }
1029 1036
1030 //PolicyLevel sandboxPolicy = PolicyLevel.CreateAppDomainLevel(); 1037 //PolicyLevel sandboxPolicy = PolicyLevel.CreateAppDomainLevel();
1031 //AllMembershipCondition sandboxMembershipCondition = new AllMembershipCondition(); 1038 //AllMembershipCondition sandboxMembershipCondition = new AllMembershipCondition();
@@ -1037,9 +1044,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1037 1044
1038 m_AppDomains[appDomain] = sandbox; 1045 m_AppDomains[appDomain] = sandbox;
1039 1046
1040 m_AppDomains[appDomain].AssemblyResolve +=
1041 new ResolveEventHandler(
1042 AssemblyResolver.OnAssemblyResolve);
1043 m_DomainScripts[appDomain] = new List<UUID>(); 1047 m_DomainScripts[appDomain] = new List<UUID>();
1044 } 1048 }
1045 catch (Exception e) 1049 catch (Exception e)
@@ -1808,9 +1812,11 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1808 // 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.
1809 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);
1810 } 1814 }
1815
1816 string textpath = path + ".text";
1811 try 1817 try
1812 { 1818 {
1813 using (FileStream fs = File.Create(path + ".text")) 1819 using (FileStream fs = File.Create(textpath))
1814 { 1820 {
1815 using (StreamWriter sw = new StreamWriter(fs)) 1821 using (StreamWriter sw = new StreamWriter(fs))
1816 { 1822 {
@@ -1823,7 +1829,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1823 catch (IOException ex) 1829 catch (IOException ex)
1824 { 1830 {
1825 // 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.
1826 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);
1827 } 1833 }
1828 } 1834 }
1829 } 1835 }
@@ -1872,7 +1878,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1872 catch (IOException ex) 1878 catch (IOException ex)
1873 { 1879 {
1874 // 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.
1875 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);
1876 } 1882 }
1877 } 1883 }
1878 1884
@@ -1984,4 +1990,4 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1984// m_log.DebugFormat("[XEngine]: Could not find script with ID {0} to resume", itemID); 1990// m_log.DebugFormat("[XEngine]: Could not find script with ID {0} to resume", itemID);
1985 } 1991 }
1986 } 1992 }
1987} \ No newline at end of file 1993}
diff --git a/OpenSim/Server/Base/ServerUtils.cs b/OpenSim/Server/Base/ServerUtils.cs
index 8effdd2..0cc2a4b 100644
--- a/OpenSim/Server/Base/ServerUtils.cs
+++ b/OpenSim/Server/Base/ServerUtils.cs
@@ -117,7 +117,10 @@ namespace OpenSim.Server.Base
117 catch (Exception e) 117 catch (Exception e)
118 { 118 {
119 if (!(e is System.MissingMethodException)) 119 if (!(e is System.MissingMethodException))
120 m_log.ErrorFormat("Error loading plugin from {0}, exception {1}", dllName, e.InnerException); 120 {
121 m_log.ErrorFormat("Error loading plugin {0} from {1}. Exception: {2}",
122 interfaceName, dllName, e.InnerException == null ? e.Message : e.InnerException.Message);
123 }
121 return null; 124 return null;
122 } 125 }
123 126
diff --git a/OpenSim/Services/AvatarService/AvatarService.cs b/OpenSim/Services/AvatarService/AvatarService.cs
index c59a9e0..423c781 100644
--- a/OpenSim/Services/AvatarService/AvatarService.cs
+++ b/OpenSim/Services/AvatarService/AvatarService.cs
@@ -93,7 +93,7 @@ namespace OpenSim.Services.AvatarService
93 if (kvp.Key.StartsWith("_")) 93 if (kvp.Key.StartsWith("_"))
94 count++; 94 count++;
95 95
96 m_log.DebugFormat("[AVATAR SERVICE]: SetAvatar for {0}, attachs={1}", principalID, count); 96// m_log.DebugFormat("[AVATAR SERVICE]: SetAvatar for {0}, attachs={1}", principalID, count);
97 m_Database.Delete("PrincipalID", principalID.ToString()); 97 m_Database.Delete("PrincipalID", principalID.ToString());
98 98
99 AvatarBaseData av = new AvatarBaseData(); 99 AvatarBaseData av = new AvatarBaseData();
diff --git a/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs
index 0430ef6..19dffc3 100644
--- a/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs
@@ -154,7 +154,7 @@ namespace OpenSim.Services.Connectors.Hypergrid
154 154
155 UUID mapTile = m_HGMapImage; 155 UUID mapTile = m_HGMapImage;
156 string filename = string.Empty; 156 string filename = string.Empty;
157 Bitmap bitmap = null; 157
158 try 158 try
159 { 159 {
160 WebClient c = new WebClient(); 160 WebClient c = new WebClient();
@@ -167,11 +167,18 @@ namespace OpenSim.Services.Connectors.Hypergrid
167 c.DownloadFile(imageURL, filename); 167 c.DownloadFile(imageURL, filename);
168 } 168 }
169 else 169 else
170 {
170 m_log.DebugFormat("[GATEKEEPER SERVICE CONNECTOR]: using cached image"); 171 m_log.DebugFormat("[GATEKEEPER SERVICE CONNECTOR]: using cached image");
172 }
173
174 byte[] imageData = null;
171 175
172 bitmap = new Bitmap(filename); 176 using (Bitmap bitmap = new Bitmap(filename))
173 //m_log.Debug("Size: " + m.PhysicalDimension.Height + "-" + m.PhysicalDimension.Width); 177 {
174 byte[] imageData = OpenJPEG.EncodeFromImage(bitmap, true); 178 //m_log.Debug("Size: " + m.PhysicalDimension.Height + "-" + m.PhysicalDimension.Width);
179 imageData = OpenJPEG.EncodeFromImage(bitmap, true);
180 }
181
175 AssetBase ass = new AssetBase(UUID.Random(), "region " + name, (sbyte)AssetType.Texture, regionID.ToString()); 182 AssetBase ass = new AssetBase(UUID.Random(), "region " + name, (sbyte)AssetType.Texture, regionID.ToString());
176 183
177 // !!! for now 184 // !!! for now
diff --git a/OpenSim/Services/LLLoginService/LLLoginResponse.cs b/OpenSim/Services/LLLoginService/LLLoginResponse.cs
index 844c5ae..01de159 100644
--- a/OpenSim/Services/LLLoginService/LLLoginResponse.cs
+++ b/OpenSim/Services/LLLoginService/LLLoginResponse.cs
@@ -349,7 +349,31 @@ namespace OpenSim.Services.LLLoginService
349 349
350 private void SetDefaultValues() 350 private void SetDefaultValues()
351 { 351 {
352 DST = TimeZone.CurrentTimeZone.IsDaylightSavingTime(DateTime.Now) ? "Y" : "N"; 352 TimeZoneInfo gridTimeZone;
353
354 // Disabled for now pending making timezone a config value, which can at some point have a default of
355 // a ; separated list of possible timezones.
356 // The problem here is that US/Pacific (or even the Olsen America/Los_Angeles) is not universal across
357 // windows, mac and various distributions of linux, introducing another element of consistency.
358 // The server operator needs to be able to control this setting
359// try
360// {
361// // First try to fetch DST from Pacific Standard Time, because this is
362// // the one expected by the viewer. "US/Pacific" is the string to search
363// // on linux and mac, and should work also on Windows (to confirm)
364// gridTimeZone = TimeZoneInfo.FindSystemTimeZoneById("US/Pacific");
365// }
366// catch (Exception e)
367// {
368// m_log.WarnFormat(
369// "[TIMEZONE]: {0} Falling back to system time. System time should be set to Pacific Standard Time to provide the expected time",
370// e.Message);
371
372 gridTimeZone = TimeZoneInfo.Local;
373// }
374
375 DST = gridTimeZone.IsDaylightSavingTime(DateTime.Now) ? "Y" : "N";
376
353 StipendSinceLogin = "N"; 377 StipendSinceLogin = "N";
354 Gendered = "Y"; 378 Gendered = "Y";
355 EverLoggedIn = "Y"; 379 EverLoggedIn = "Y";
diff --git a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs
index 318758d..7a6b1cf 100644
--- a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs
+++ b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs
@@ -153,7 +153,7 @@ namespace OpenSim.Tests.Common
153 PhysicsPluginManager physicsPluginManager = new PhysicsPluginManager(); 153 PhysicsPluginManager physicsPluginManager = new PhysicsPluginManager();
154 physicsPluginManager.LoadPluginsFromAssembly("Physics/OpenSim.Region.Physics.BasicPhysicsPlugin.dll"); 154 physicsPluginManager.LoadPluginsFromAssembly("Physics/OpenSim.Region.Physics.BasicPhysicsPlugin.dll");
155 testScene.PhysicsScene 155 testScene.PhysicsScene
156 = physicsPluginManager.GetPhysicsScene("basicphysics", "ZeroMesher", new IniConfigSource(), "test"); 156 = physicsPluginManager.GetPhysicsScene("basicphysics", "ZeroMesher", new IniConfigSource(), "test");
157 157
158 testScene.RegionInfo.EstateSettings = new EstateSettings(); 158 testScene.RegionInfo.EstateSettings = new EstateSettings();
159 testScene.LoginsDisabled = false; 159 testScene.LoginsDisabled = false;