aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--OpenSim/ConsoleClient/Requester.cs2
-rw-r--r--OpenSim/Framework/Serialization/External/LandDataSerializer.cs4
-rw-r--r--OpenSim/Framework/Serialization/External/RegionSettingsSerializer.cs4
-rw-r--r--OpenSim/Framework/Serialization/TarArchiveReader.cs8
-rw-r--r--OpenSim/Framework/Serialization/TarArchiveWriter.cs23
-rw-r--r--OpenSim/Framework/Servers/BaseOpenSimServer.cs4
-rw-r--r--OpenSim/Framework/Util.cs3
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs20
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs157
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/AssetsDearchiver.cs2
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/FileLoaders/Terragen.cs2
-rw-r--r--OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs91
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs27
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs4
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs3
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs3
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs7
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs5
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs15
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs8
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs3
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Listener.cs8
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs8
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs19
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/Tests/XEngineTest.cs6
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/XEngine.cs17
-rw-r--r--OpenSim/Server/Base/ServicesServerBase.cs8
-rw-r--r--OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs3
-rw-r--r--OpenSim/Tests/Common/Helpers/UserInventoryHelpers.cs78
-rw-r--r--OpenSim/Tools/Compiler/Program.cs13
-rw-r--r--prebuild.xml2
32 files changed, 393 insertions, 166 deletions
diff --git a/OpenSim/ConsoleClient/Requester.cs b/OpenSim/ConsoleClient/Requester.cs
index fefe969..aabb02c 100644
--- a/OpenSim/ConsoleClient/Requester.cs
+++ b/OpenSim/ConsoleClient/Requester.cs
@@ -50,7 +50,7 @@ namespace OpenSim.ConsoleClient
50 50
51 request.ContentType = "application/x-www-form-urlencoded"; 51 request.ContentType = "application/x-www-form-urlencoded";
52 52
53 byte[] buffer = new System.Text.ASCIIEncoding().GetBytes(data); 53 byte[] buffer = Encoding.ASCII.GetBytes(data);
54 int length = (int) buffer.Length; 54 int length = (int) buffer.Length;
55 request.ContentLength = length; 55 request.ContentLength = length;
56 56
diff --git a/OpenSim/Framework/Serialization/External/LandDataSerializer.cs b/OpenSim/Framework/Serialization/External/LandDataSerializer.cs
index e8d82d3..a64f01c 100644
--- a/OpenSim/Framework/Serialization/External/LandDataSerializer.cs
+++ b/OpenSim/Framework/Serialization/External/LandDataSerializer.cs
@@ -44,8 +44,6 @@ namespace OpenSim.Framework.Serialization.External
44 { 44 {
45// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 45// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
46 46
47 protected static UTF8Encoding m_utf8Encoding = new UTF8Encoding();
48
49 private static Dictionary<string, Action<LandData, XmlTextReader>> m_ldProcessors 47 private static Dictionary<string, Action<LandData, XmlTextReader>> m_ldProcessors
50 = new Dictionary<string, Action<LandData, XmlTextReader>>(); 48 = new Dictionary<string, Action<LandData, XmlTextReader>>();
51 49
@@ -163,7 +161,7 @@ namespace OpenSim.Framework.Serialization.External
163 /// <exception cref="System.Xml.XmlException"></exception> 161 /// <exception cref="System.Xml.XmlException"></exception>
164 public static LandData Deserialize(byte[] serializedLandData) 162 public static LandData Deserialize(byte[] serializedLandData)
165 { 163 {
166 return Deserialize(m_utf8Encoding.GetString(serializedLandData, 0, serializedLandData.Length)); 164 return Deserialize(Encoding.UTF8.GetString(serializedLandData, 0, serializedLandData.Length));
167 } 165 }
168 166
169 /// <summary> 167 /// <summary>
diff --git a/OpenSim/Framework/Serialization/External/RegionSettingsSerializer.cs b/OpenSim/Framework/Serialization/External/RegionSettingsSerializer.cs
index f18435d..19468c3 100644
--- a/OpenSim/Framework/Serialization/External/RegionSettingsSerializer.cs
+++ b/OpenSim/Framework/Serialization/External/RegionSettingsSerializer.cs
@@ -40,8 +40,6 @@ namespace OpenSim.Framework.Serialization.External
40 /// </summary> 40 /// </summary>
41 public class RegionSettingsSerializer 41 public class RegionSettingsSerializer
42 { 42 {
43 protected static ASCIIEncoding m_asciiEncoding = new ASCIIEncoding();
44
45 /// <summary> 43 /// <summary>
46 /// Deserialize settings 44 /// Deserialize settings
47 /// </summary> 45 /// </summary>
@@ -50,7 +48,7 @@ namespace OpenSim.Framework.Serialization.External
50 /// <exception cref="System.Xml.XmlException"></exception> 48 /// <exception cref="System.Xml.XmlException"></exception>
51 public static RegionSettings Deserialize(byte[] serializedSettings) 49 public static RegionSettings Deserialize(byte[] serializedSettings)
52 { 50 {
53 return Deserialize(m_asciiEncoding.GetString(serializedSettings, 0, serializedSettings.Length)); 51 return Deserialize(Encoding.ASCII.GetString(serializedSettings, 0, serializedSettings.Length));
54 } 52 }
55 53
56 /// <summary> 54 /// <summary>
diff --git a/OpenSim/Framework/Serialization/TarArchiveReader.cs b/OpenSim/Framework/Serialization/TarArchiveReader.cs
index 77c29f8..339a37a 100644
--- a/OpenSim/Framework/Serialization/TarArchiveReader.cs
+++ b/OpenSim/Framework/Serialization/TarArchiveReader.cs
@@ -53,8 +53,6 @@ namespace OpenSim.Framework.Serialization
53 TYPE_CONTIGUOUS_FILE = 8, 53 TYPE_CONTIGUOUS_FILE = 8,
54 } 54 }
55 55
56 protected static ASCIIEncoding m_asciiEncoding = new ASCIIEncoding();
57
58 /// <summary> 56 /// <summary>
59 /// Binary reader for the underlying stream 57 /// Binary reader for the underlying stream
60 /// </summary> 58 /// </summary>
@@ -120,13 +118,13 @@ namespace OpenSim.Framework.Serialization
120 if (header[156] == (byte)'L') 118 if (header[156] == (byte)'L')
121 { 119 {
122 int longNameLength = ConvertOctalBytesToDecimal(header, 124, 11); 120 int longNameLength = ConvertOctalBytesToDecimal(header, 124, 11);
123 tarHeader.FilePath = m_asciiEncoding.GetString(ReadData(longNameLength)); 121 tarHeader.FilePath = Encoding.ASCII.GetString(ReadData(longNameLength));
124 //m_log.DebugFormat("[TAR ARCHIVE READER]: Got long file name {0}", tarHeader.FilePath); 122 //m_log.DebugFormat("[TAR ARCHIVE READER]: Got long file name {0}", tarHeader.FilePath);
125 header = m_br.ReadBytes(512); 123 header = m_br.ReadBytes(512);
126 } 124 }
127 else 125 else
128 { 126 {
129 tarHeader.FilePath = m_asciiEncoding.GetString(header, 0, 100); 127 tarHeader.FilePath = Encoding.ASCII.GetString(header, 0, 100);
130 tarHeader.FilePath = tarHeader.FilePath.Trim(m_nullCharArray); 128 tarHeader.FilePath = tarHeader.FilePath.Trim(m_nullCharArray);
131 //m_log.DebugFormat("[TAR ARCHIVE READER]: Got short file name {0}", tarHeader.FilePath); 129 //m_log.DebugFormat("[TAR ARCHIVE READER]: Got short file name {0}", tarHeader.FilePath);
132 } 130 }
@@ -205,7 +203,7 @@ namespace OpenSim.Framework.Serialization
205 { 203 {
206 // Trim leading white space: ancient tars do that instead 204 // Trim leading white space: ancient tars do that instead
207 // of leading 0s :-( don't ask. really. 205 // of leading 0s :-( don't ask. really.
208 string oString = m_asciiEncoding.GetString(bytes, startIndex, count).TrimStart(m_spaceCharArray); 206 string oString = Encoding.ASCII.GetString(bytes, startIndex, count).TrimStart(m_spaceCharArray);
209 207
210 int d = 0; 208 int d = 0;
211 209
diff --git a/OpenSim/Framework/Serialization/TarArchiveWriter.cs b/OpenSim/Framework/Serialization/TarArchiveWriter.cs
index fca909f..122fa8e 100644
--- a/OpenSim/Framework/Serialization/TarArchiveWriter.cs
+++ b/OpenSim/Framework/Serialization/TarArchiveWriter.cs
@@ -41,7 +41,6 @@ namespace OpenSim.Framework.Serialization
41 { 41 {
42// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 42// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
43 43
44 protected static ASCIIEncoding m_asciiEncoding = new ASCIIEncoding();
45 protected static UTF8Encoding m_utf8Encoding = new UTF8Encoding(); 44 protected static UTF8Encoding m_utf8Encoding = new UTF8Encoding();
46 45
47 /// <summary> 46 /// <summary>
@@ -85,7 +84,7 @@ namespace OpenSim.Framework.Serialization
85 public void WriteFile(string filePath, byte[] data) 84 public void WriteFile(string filePath, byte[] data)
86 { 85 {
87 if (filePath.Length > 100) 86 if (filePath.Length > 100)
88 WriteEntry("././@LongLink", m_asciiEncoding.GetBytes(filePath), 'L'); 87 WriteEntry("././@LongLink", Encoding.ASCII.GetBytes(filePath), 'L');
89 88
90 char fileType; 89 char fileType;
91 90
@@ -137,7 +136,7 @@ namespace OpenSim.Framework.Serialization
137 oString = "0" + oString; 136 oString = "0" + oString;
138 } 137 }
139 138
140 byte[] oBytes = m_asciiEncoding.GetBytes(oString); 139 byte[] oBytes = Encoding.ASCII.GetBytes(oString);
141 140
142 return oBytes; 141 return oBytes;
143 } 142 }
@@ -156,20 +155,20 @@ namespace OpenSim.Framework.Serialization
156 byte[] header = new byte[512]; 155 byte[] header = new byte[512];
157 156
158 // file path field (100) 157 // file path field (100)
159 byte[] nameBytes = m_asciiEncoding.GetBytes(filePath); 158 byte[] nameBytes = Encoding.ASCII.GetBytes(filePath);
160 int nameSize = (nameBytes.Length >= 100) ? 100 : nameBytes.Length; 159 int nameSize = (nameBytes.Length >= 100) ? 100 : nameBytes.Length;
161 Array.Copy(nameBytes, header, nameSize); 160 Array.Copy(nameBytes, header, nameSize);
162 161
163 // file mode (8) 162 // file mode (8)
164 byte[] modeBytes = m_asciiEncoding.GetBytes("0000777"); 163 byte[] modeBytes = Encoding.ASCII.GetBytes("0000777");
165 Array.Copy(modeBytes, 0, header, 100, 7); 164 Array.Copy(modeBytes, 0, header, 100, 7);
166 165
167 // owner user id (8) 166 // owner user id (8)
168 byte[] ownerIdBytes = m_asciiEncoding.GetBytes("0000764"); 167 byte[] ownerIdBytes = Encoding.ASCII.GetBytes("0000764");
169 Array.Copy(ownerIdBytes, 0, header, 108, 7); 168 Array.Copy(ownerIdBytes, 0, header, 108, 7);
170 169
171 // group user id (8) 170 // group user id (8)
172 byte[] groupIdBytes = m_asciiEncoding.GetBytes("0000764"); 171 byte[] groupIdBytes = Encoding.ASCII.GetBytes("0000764");
173 Array.Copy(groupIdBytes, 0, header, 116, 7); 172 Array.Copy(groupIdBytes, 0, header, 116, 7);
174 173
175 // file size in bytes (12) 174 // file size in bytes (12)
@@ -181,17 +180,17 @@ namespace OpenSim.Framework.Serialization
181 Array.Copy(fileSizeBytes, 0, header, 124, 11); 180 Array.Copy(fileSizeBytes, 0, header, 124, 11);
182 181
183 // last modification time (12) 182 // last modification time (12)
184 byte[] lastModTimeBytes = m_asciiEncoding.GetBytes("11017037332"); 183 byte[] lastModTimeBytes = Encoding.ASCII.GetBytes("11017037332");
185 Array.Copy(lastModTimeBytes, 0, header, 136, 11); 184 Array.Copy(lastModTimeBytes, 0, header, 136, 11);
186 185
187 // entry type indicator (1) 186 // entry type indicator (1)
188 header[156] = m_asciiEncoding.GetBytes(new char[] { fileType })[0]; 187 header[156] = Encoding.ASCII.GetBytes(new char[] { fileType })[0];
189 188
190 Array.Copy(m_asciiEncoding.GetBytes("0000000"), 0, header, 329, 7); 189 Array.Copy(Encoding.ASCII.GetBytes("0000000"), 0, header, 329, 7);
191 Array.Copy(m_asciiEncoding.GetBytes("0000000"), 0, header, 337, 7); 190 Array.Copy(Encoding.ASCII.GetBytes("0000000"), 0, header, 337, 7);
192 191
193 // check sum for header block (8) [calculated last] 192 // check sum for header block (8) [calculated last]
194 Array.Copy(m_asciiEncoding.GetBytes(" "), 0, header, 148, 8); 193 Array.Copy(Encoding.ASCII.GetBytes(" "), 0, header, 148, 8);
195 194
196 int checksum = 0; 195 int checksum = 0;
197 foreach (byte b in header) 196 foreach (byte b in header)
diff --git a/OpenSim/Framework/Servers/BaseOpenSimServer.cs b/OpenSim/Framework/Servers/BaseOpenSimServer.cs
index 7bbb290..9a2cd0e 100644
--- a/OpenSim/Framework/Servers/BaseOpenSimServer.cs
+++ b/OpenSim/Framework/Servers/BaseOpenSimServer.cs
@@ -591,8 +591,8 @@ namespace OpenSim.Framework.Servers
591 { 591 {
592 string pidstring = System.Diagnostics.Process.GetCurrentProcess().Id.ToString(); 592 string pidstring = System.Diagnostics.Process.GetCurrentProcess().Id.ToString();
593 FileStream fs = File.Create(path); 593 FileStream fs = File.Create(path);
594 System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding(); 594
595 Byte[] buf = enc.GetBytes(pidstring); 595 Byte[] buf = Encoding.ASCII.GetBytes(pidstring);
596 fs.Write(buf, 0, buf.Length); 596 fs.Write(buf, 0, buf.Length);
597 fs.Close(); 597 fs.Close();
598 m_pidFile = path; 598 m_pidFile = path;
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs
index 728cda0..30bbfd4 100644
--- a/OpenSim/Framework/Util.cs
+++ b/OpenSim/Framework/Util.cs
@@ -1248,8 +1248,7 @@ namespace OpenSim.Framework
1248 1248
1249 public static string Base64ToString(string str) 1249 public static string Base64ToString(string str)
1250 { 1250 {
1251 UTF8Encoding encoder = new UTF8Encoding(); 1251 Decoder utf8Decode = Encoding.UTF8.GetDecoder();
1252 Decoder utf8Decode = encoder.GetDecoder();
1253 1252
1254 byte[] todecode_byte = Convert.FromBase64String(str); 1253 byte[] todecode_byte = Convert.FromBase64String(str);
1255 int charCount = utf8Decode.GetCharCount(todecode_byte, 0, todecode_byte.Length); 1254 int charCount = utf8Decode.GetCharCount(todecode_byte, 0, todecode_byte.Length);
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index 2bb60d5..394b90a 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -237,7 +237,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
237 if (sp.PresenceType == PresenceType.Npc) 237 if (sp.PresenceType == PresenceType.Npc)
238 RezSingleAttachmentFromInventoryInternal(sp, UUID.Zero, attach.AssetID, p, null); 238 RezSingleAttachmentFromInventoryInternal(sp, UUID.Zero, attach.AssetID, p, null);
239 else 239 else
240 RezSingleAttachmentFromInventory(sp, attach.ItemID, p, true, d); 240 RezSingleAttachmentFromInventory(sp, attach.ItemID, p, d);
241 } 241 }
242 catch (Exception e) 242 catch (Exception e)
243 { 243 {
@@ -405,10 +405,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
405 405
406 public ISceneEntity RezSingleAttachmentFromInventory(IScenePresence sp, UUID itemID, uint AttachmentPt) 406 public ISceneEntity RezSingleAttachmentFromInventory(IScenePresence sp, UUID itemID, uint AttachmentPt)
407 { 407 {
408 return RezSingleAttachmentFromInventory(sp, itemID, AttachmentPt, true, null); 408 return RezSingleAttachmentFromInventory(sp, itemID, AttachmentPt, null);
409 } 409 }
410 410
411 public ISceneEntity RezSingleAttachmentFromInventory(IScenePresence sp, UUID itemID, uint AttachmentPt, bool updateInventoryStatus, XmlDocument doc) 411 public ISceneEntity RezSingleAttachmentFromInventory(IScenePresence sp, UUID itemID, uint AttachmentPt, XmlDocument doc)
412 { 412 {
413 if (!Enabled) 413 if (!Enabled)
414 return null; 414 return null;
@@ -596,6 +596,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
596 /// </remarks> 596 /// </remarks>
597 /// <param name="sp"></param> 597 /// <param name="sp"></param>
598 /// <param name="grp"></param> 598 /// <param name="grp"></param>
599 /// <param name="saveAllScripted"></param>
599 private void UpdateKnownItem(IScenePresence sp, SceneObjectGroup grp, bool saveAllScripted) 600 private void UpdateKnownItem(IScenePresence sp, SceneObjectGroup grp, bool saveAllScripted)
600 { 601 {
601 // Saving attachments for NPCs messes them up for the real owner! 602 // Saving attachments for NPCs messes them up for the real owner!
@@ -789,18 +790,23 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
789 null, assetID, Vector3.Zero, Vector3.Zero, UUID.Zero, (byte)1, true, 790 null, assetID, Vector3.Zero, Vector3.Zero, UUID.Zero, (byte)1, true,
790 false, false, sp.UUID, true); 791 false, false, sp.UUID, true);
791 792
792// m_log.DebugFormat(
793// "[ATTACHMENTS MODULE]: Retrieved single object {0} for attachment to {1} on point {2}",
794// objatt.Name, remoteClient.Name, AttachmentPt);
795
796 if (objatt != null) 793 if (objatt != null)
797 { 794 {
795// m_log.DebugFormat(
796// "[ATTACHMENTS MODULE]: Rezzed single object {0} for attachment to {1} on point {2} in {3}",
797// objatt.Name, sp.Name, attachmentPt, m_scene.Name);
798
798 // HasGroupChanged is being set from within RezObject. Ideally it would be set by the caller. 799 // HasGroupChanged is being set from within RezObject. Ideally it would be set by the caller.
799 objatt.HasGroupChanged = false; 800 objatt.HasGroupChanged = false;
800 bool tainted = false; 801 bool tainted = false;
801 if (attachmentPt != 0 && attachmentPt != objatt.AttachmentPoint) 802 if (attachmentPt != 0 && attachmentPt != objatt.AttachmentPoint)
802 tainted = true; 803 tainted = true;
803 804
805 // FIXME: Detect whether it's really likely for AttachObject to throw an exception in the normal
806 // course of events. If not, then it's probably not worth trying to recover the situation
807 // since this is more likely to trigger further exceptions and confuse later debugging. If
808 // exceptions can be thrown in expected error conditions (not NREs) then make this consistent
809 // since other normal error conditions will simply return false instead.
804 // This will throw if the attachment fails 810 // This will throw if the attachment fails
805 try 811 try
806 { 812 {
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
index 8423d43..cd1e1c1 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
@@ -31,6 +31,7 @@ using System.Reflection;
31using System.Text; 31using System.Text;
32using System.Threading; 32using System.Threading;
33using System.Timers; 33using System.Timers;
34using System.Xml;
34using Timer=System.Timers.Timer; 35using Timer=System.Timers.Timer;
35using Nini.Config; 36using Nini.Config;
36using NUnit.Framework; 37using NUnit.Framework;
@@ -41,10 +42,12 @@ using OpenSim.Region.CoreModules.Avatar.Attachments;
41using OpenSim.Region.CoreModules.Framework; 42using OpenSim.Region.CoreModules.Framework;
42using OpenSim.Region.CoreModules.Framework.EntityTransfer; 43using OpenSim.Region.CoreModules.Framework.EntityTransfer;
43using OpenSim.Region.CoreModules.Framework.InventoryAccess; 44using OpenSim.Region.CoreModules.Framework.InventoryAccess;
44using OpenSim.Region.CoreModules.World.Serialiser; 45using OpenSim.Region.CoreModules.Scripting.WorldComm;
45using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; 46using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation;
47using OpenSim.Region.CoreModules.World.Serialiser;
46using OpenSim.Region.Framework.Scenes; 48using OpenSim.Region.Framework.Scenes;
47using OpenSim.Region.Framework.Interfaces; 49using OpenSim.Region.Framework.Interfaces;
50using OpenSim.Region.ScriptEngine.XEngine;
48using OpenSim.Services.Interfaces; 51using OpenSim.Services.Interfaces;
49using OpenSim.Tests.Common; 52using OpenSim.Tests.Common;
50using OpenSim.Tests.Common.Mock; 53using OpenSim.Tests.Common.Mock;
@@ -57,6 +60,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
57 [TestFixture] 60 [TestFixture]
58 public class AttachmentsModuleTests : OpenSimTestCase 61 public class AttachmentsModuleTests : OpenSimTestCase
59 { 62 {
63 private AutoResetEvent m_chatEvent = new AutoResetEvent(false);
64 private OSChatMessage m_osChatMessageReceived;
65
60 [TestFixtureSetUp] 66 [TestFixtureSetUp]
61 public void FixtureInit() 67 public void FixtureInit()
62 { 68 {
@@ -72,16 +78,74 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
72 Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod; 78 Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod;
73 } 79 }
74 80
75 private Scene CreateDefaultTestScene() 81 private void OnChatFromWorld(object sender, OSChatMessage oscm)
82 {
83// Console.WriteLine("Got chat [{0}]", oscm.Message);
84
85 m_osChatMessageReceived = oscm;
86 m_chatEvent.Set();
87 }
88
89 private Scene CreateTestScene()
90 {
91 IConfigSource config = new IniConfigSource();
92 List<object> modules = new List<object>();
93
94 AddCommonConfig(config, modules);
95
96 Scene scene
97 = new SceneHelpers().SetupScene(
98 "attachments-test-scene", TestHelpers.ParseTail(999), 1000, 1000, config);
99 SceneHelpers.SetupSceneModules(scene, config, modules.ToArray());
100
101 return scene;
102 }
103
104 private Scene CreateScriptingEnabledTestScene()
76 { 105 {
77 IConfigSource config = new IniConfigSource(); 106 IConfigSource config = new IniConfigSource();
107 List<object> modules = new List<object>();
108
109 AddCommonConfig(config, modules);
110 AddScriptingConfig(config, modules);
111
112 Scene scene
113 = new SceneHelpers().SetupScene(
114 "attachments-test-scene", TestHelpers.ParseTail(999), 1000, 1000, config);
115 SceneHelpers.SetupSceneModules(scene, config, modules.ToArray());
116
117 scene.StartScripts();
118
119 return scene;
120 }
121
122 private void AddCommonConfig(IConfigSource config, List<object> modules)
123 {
78 config.AddConfig("Modules"); 124 config.AddConfig("Modules");
79 config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule"); 125 config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule");
80 126
81 Scene scene = new SceneHelpers().SetupScene(); 127 modules.Add(new AttachmentsModule());
82 SceneHelpers.SetupSceneModules(scene, config, new AttachmentsModule(), new BasicInventoryAccessModule()); 128 modules.Add(new BasicInventoryAccessModule());
129 }
130
131 private void AddScriptingConfig(IConfigSource config, List<object> modules)
132 {
133 IConfig startupConfig = config.AddConfig("Startup");
134 startupConfig.Set("DefaultScriptEngine", "XEngine");
135
136 IConfig xEngineConfig = config.AddConfig("XEngine");
137 xEngineConfig.Set("Enabled", "true");
138 xEngineConfig.Set("StartDelay", "0");
83 139
84 return scene; 140 // These tests will not run with AppDomainLoading = true, at least on mono. For unknown reasons, the call
141 // to AssemblyResolver.OnAssemblyResolve fails.
142 xEngineConfig.Set("AppDomainLoading", "false");
143
144 modules.Add(new XEngine());
145
146 // Necessary to stop serialization complaining
147 // FIXME: Stop this being necessary if at all possible
148// modules.Add(new WorldCommModule());
85 } 149 }
86 150
87 /// <summary> 151 /// <summary>
@@ -116,7 +180,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
116 TestHelpers.InMethod(); 180 TestHelpers.InMethod();
117// TestHelpers.EnableLogging(); 181// TestHelpers.EnableLogging();
118 182
119 Scene scene = CreateDefaultTestScene(); 183 Scene scene = CreateTestScene();
120 UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1); 184 UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1);
121 ScenePresence sp = SceneHelpers.AddScenePresence(scene, ua1); 185 ScenePresence sp = SceneHelpers.AddScenePresence(scene, ua1);
122 186
@@ -163,7 +227,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
163 TestHelpers.InMethod(); 227 TestHelpers.InMethod();
164// TestHelpers.EnableLogging(); 228// TestHelpers.EnableLogging();
165 229
166 Scene scene = CreateDefaultTestScene(); 230 Scene scene = CreateTestScene();
167 UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1); 231 UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1);
168 ScenePresence sp = SceneHelpers.AddScenePresence(scene, ua1); 232 ScenePresence sp = SceneHelpers.AddScenePresence(scene, ua1);
169 233
@@ -185,12 +249,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
185 } 249 }
186 250
187 [Test] 251 [Test]
188 public void TestAddAttachmentFromInventory() 252 public void TestRezAttachmentFromInventory()
189 { 253 {
190 TestHelpers.InMethod(); 254 TestHelpers.InMethod();
191// log4net.Config.XmlConfigurator.Configure(); 255// log4net.Config.XmlConfigurator.Configure();
192 256
193 Scene scene = CreateDefaultTestScene(); 257 Scene scene = CreateTestScene();
194 UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1); 258 UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1);
195 ScenePresence sp = SceneHelpers.AddScenePresence(scene, ua1.PrincipalID); 259 ScenePresence sp = SceneHelpers.AddScenePresence(scene, ua1.PrincipalID);
196 260
@@ -217,13 +281,38 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
217 Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1)); 281 Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1));
218 } 282 }
219 283
284 /// <summary>
285 /// Test specific conditions associated with rezzing a scripted attachment from inventory.
286 /// </summary>
287 [Test]
288 public void TestRezScriptedAttachmentFromInventory()
289 {
290 TestHelpers.InMethod();
291
292 Scene scene = CreateTestScene();
293 UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1);
294 ScenePresence sp = SceneHelpers.AddScenePresence(scene, ua1.PrincipalID);
295
296 SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, sp.UUID, "att-name", 0x10);
297 TaskInventoryHelpers.AddScript(scene, so.RootPart);
298 InventoryItemBase userItem = UserInventoryHelpers.AddInventoryItem(scene, so, 0x100, 0x1000);
299
300 scene.AttachmentsModule.RezSingleAttachmentFromInventory(sp, userItem.ID, (uint)AttachmentPoint.Chest);
301
302 // TODO: Need to have a test that checks the script is actually started but this involves a lot more
303 // plumbing of the script engine and either pausing for events or more infrastructure to turn off various
304 // script engine delays/asychronicity that isn't helpful in an automated regression testing context.
305 SceneObjectGroup attSo = scene.GetSceneObjectGroup(so.Name);
306 Assert.That(attSo.ContainsScripts(), Is.True);
307 }
308
220 [Test] 309 [Test]
221 public void TestDetachAttachmentToGround() 310 public void TestDetachAttachmentToGround()
222 { 311 {
223 TestHelpers.InMethod(); 312 TestHelpers.InMethod();
224// log4net.Config.XmlConfigurator.Configure(); 313// log4net.Config.XmlConfigurator.Configure();
225 314
226 Scene scene = CreateDefaultTestScene(); 315 Scene scene = CreateTestScene();
227 UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1); 316 UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1);
228 ScenePresence sp = SceneHelpers.AddScenePresence(scene, ua1.PrincipalID); 317 ScenePresence sp = SceneHelpers.AddScenePresence(scene, ua1.PrincipalID);
229 318
@@ -253,9 +342,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
253 public void TestDetachAttachmentToInventory() 342 public void TestDetachAttachmentToInventory()
254 { 343 {
255 TestHelpers.InMethod(); 344 TestHelpers.InMethod();
256// log4net.Config.XmlConfigurator.Configure();
257 345
258 Scene scene = CreateDefaultTestScene(); 346 Scene scene = CreateTestScene();
259 UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1); 347 UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1);
260 ScenePresence sp = SceneHelpers.AddScenePresence(scene, ua1.PrincipalID); 348 ScenePresence sp = SceneHelpers.AddScenePresence(scene, ua1.PrincipalID);
261 349
@@ -278,6 +366,45 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
278 } 366 }
279 367
280 /// <summary> 368 /// <summary>
369 /// Test specific conditions associated with detaching a scripted attachment from inventory.
370 /// </summary>
371 [Test]
372 public void TestDetachScriptedAttachmentToInventory()
373 {
374 TestHelpers.InMethod();
375// TestHelpers.EnableLogging();
376
377 Scene scene = CreateScriptingEnabledTestScene();
378 UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1);
379 ScenePresence sp = SceneHelpers.AddScenePresence(scene, ua1);
380
381 SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, sp.UUID, "att-name", 0x10);
382 TaskInventoryHelpers.AddScript(scene, so.RootPart);
383 InventoryItemBase userItem = UserInventoryHelpers.AddInventoryItem(scene, so, 0x100, 0x1000);
384
385 // FIXME: Right now, we have to do a tricksy chat listen to make sure we know when the script is running.
386 // In the future, we need to be able to do this programatically more predicably.
387 scene.EventManager.OnChatFromWorld += OnChatFromWorld;
388
389 SceneObjectGroup soRezzed
390 = (SceneObjectGroup)scene.AttachmentsModule.RezSingleAttachmentFromInventory(sp, userItem.ID, (uint)AttachmentPoint.Chest);
391
392 // Wait for chat to signal rezzed script has been started.
393 m_chatEvent.WaitOne(60000);
394
395 scene.AttachmentsModule.DetachSingleAttachmentToInv(sp, soRezzed);
396
397 InventoryItemBase userItemUpdated = scene.InventoryService.GetItem(userItem);
398 AssetBase asset = scene.AssetService.Get(userItemUpdated.AssetID.ToString());
399
400 XmlDocument soXml = new XmlDocument();
401 soXml.LoadXml(Encoding.UTF8.GetString(asset.Data));
402
403 XmlNodeList scriptStateNodes = soXml.GetElementsByTagName("ScriptState");
404 Assert.That(scriptStateNodes.Count, Is.EqualTo(1));
405 }
406
407 /// <summary>
281 /// Test that attachments don't hang about in the scene when the agent is closed 408 /// Test that attachments don't hang about in the scene when the agent is closed
282 /// </summary> 409 /// </summary>
283 [Test] 410 [Test]
@@ -286,7 +413,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
286 TestHelpers.InMethod(); 413 TestHelpers.InMethod();
287// log4net.Config.XmlConfigurator.Configure(); 414// log4net.Config.XmlConfigurator.Configure();
288 415
289 Scene scene = CreateDefaultTestScene(); 416 Scene scene = CreateTestScene();
290 UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1); 417 UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1);
291 InventoryItemBase attItem = CreateAttachmentItem(scene, ua1.PrincipalID, "att", 0x10, 0x20); 418 InventoryItemBase attItem = CreateAttachmentItem(scene, ua1.PrincipalID, "att", 0x10, 0x20);
292 419
@@ -309,7 +436,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
309 TestHelpers.InMethod(); 436 TestHelpers.InMethod();
310// log4net.Config.XmlConfigurator.Configure(); 437// log4net.Config.XmlConfigurator.Configure();
311 438
312 Scene scene = CreateDefaultTestScene(); 439 Scene scene = CreateTestScene();
313 UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1); 440 UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1);
314 InventoryItemBase attItem = CreateAttachmentItem(scene, ua1.PrincipalID, "att", 0x10, 0x20); 441 InventoryItemBase attItem = CreateAttachmentItem(scene, ua1.PrincipalID, "att", 0x10, 0x20);
315 442
@@ -345,7 +472,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
345 { 472 {
346 TestHelpers.InMethod(); 473 TestHelpers.InMethod();
347 474
348 Scene scene = CreateDefaultTestScene(); 475 Scene scene = CreateTestScene();
349 UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1); 476 UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1);
350 InventoryItemBase attItem = CreateAttachmentItem(scene, ua1.PrincipalID, "att", 0x10, 0x20); 477 InventoryItemBase attItem = CreateAttachmentItem(scene, ua1.PrincipalID, "att", 0x10, 0x20);
351 478
diff --git a/OpenSim/Region/CoreModules/World/Archiver/AssetsDearchiver.cs b/OpenSim/Region/CoreModules/World/Archiver/AssetsDearchiver.cs
index 2c04008..8c0ef88 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/AssetsDearchiver.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/AssetsDearchiver.cs
@@ -46,8 +46,6 @@ namespace OpenSim.Region.CoreModules.World.Archiver
46 { 46 {
47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
48 48
49 protected static ASCIIEncoding m_asciiEncoding = new ASCIIEncoding();
50
51 /// <summary> 49 /// <summary>
52 /// Store for asset data we received before we get the metadata 50 /// Store for asset data we received before we get the metadata
53 /// </summary> 51 /// </summary>
diff --git a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/Terragen.cs b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/Terragen.cs
index 7a0db26..b5c7d33 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/Terragen.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/Terragen.cs
@@ -252,7 +252,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
252 if (horizontalScale < 0.01d) 252 if (horizontalScale < 0.01d)
253 horizontalScale = 0.01d; 253 horizontalScale = 0.01d;
254 254
255 System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding(); 255 Encoding enc = Encoding.ASCII;
256 256
257 bs.Write(enc.GetBytes("TERRAGENTERRAIN ")); 257 bs.Write(enc.GetBytes("TERRAGENTERRAIN "));
258 258
diff --git a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs
index e7b9ba5..410eda0 100644
--- a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs
@@ -97,7 +97,7 @@ namespace OpenSim.Region.Framework.Interfaces
97 97
98 // Same as above, but also load script states from a separate doc 98 // Same as above, but also load script states from a separate doc
99 ISceneEntity RezSingleAttachmentFromInventory( 99 ISceneEntity RezSingleAttachmentFromInventory(
100 IScenePresence presence, UUID itemID, uint AttachmentPt, bool updateInventoryStatus, XmlDocument doc); 100 IScenePresence presence, UUID itemID, uint AttachmentPt, XmlDocument doc);
101 101
102 /// <summary> 102 /// <summary>
103 /// Rez multiple attachments from a user's inventory 103 /// Rez multiple attachments from a user's inventory
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index cc7d0fb..33a2cc5 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -646,6 +646,9 @@ namespace OpenSim.Region.Framework.Scenes
646 return; 646 return;
647 } 647 }
648 } 648 }
649
650 // Restuff the new GroupPosition into each SOP of the linkset.
651 // This has the affect of resetting and tainting the physics actors.
649 SceneObjectPart[] parts = m_parts.GetArray(); 652 SceneObjectPart[] parts = m_parts.GetArray();
650 bool triggerScriptEvent = m_rootPart.GroupPosition != val; 653 bool triggerScriptEvent = m_rootPart.GroupPosition != val;
651 if (m_dupeInProgress) 654 if (m_dupeInProgress)
@@ -1755,6 +1758,9 @@ namespace OpenSim.Region.Framework.Scenes
1755 1758
1756 public void ResetChildPrimPhysicsPositions() 1759 public void ResetChildPrimPhysicsPositions()
1757 { 1760 {
1761 // Setting this SOG's absolute position also loops through and sets the positions
1762 // of the SOP's in this SOG's linkset. This has the side affect of making sure
1763 // the physics world matches the simulated world.
1758 AbsolutePosition = AbsolutePosition; // could someone in the know please explain how this works? 1764 AbsolutePosition = AbsolutePosition; // could someone in the know please explain how this works?
1759 1765
1760 // teravus: AbsolutePosition is NOT a normal property! 1766 // teravus: AbsolutePosition is NOT a normal property!
@@ -2714,6 +2720,8 @@ namespace OpenSim.Region.Framework.Scenes
2714 LinkToGroup(objectGroup, false); 2720 LinkToGroup(objectGroup, false);
2715 } 2721 }
2716 2722
2723 // Link an existing group to this group.
2724 // The group being linked need not be a linkset -- it can have just one prim.
2717 public void LinkToGroup(SceneObjectGroup objectGroup, bool insert) 2725 public void LinkToGroup(SceneObjectGroup objectGroup, bool insert)
2718 { 2726 {
2719// m_log.DebugFormat( 2727// m_log.DebugFormat(
@@ -2724,6 +2732,7 @@ namespace OpenSim.Region.Framework.Scenes
2724 if (objectGroup == this) 2732 if (objectGroup == this)
2725 return; 2733 return;
2726 2734
2735 // 'linkPart' == the root of the group being linked into this group
2727 SceneObjectPart linkPart = objectGroup.m_rootPart; 2736 SceneObjectPart linkPart = objectGroup.m_rootPart;
2728 2737
2729 if (m_rootPart.PhysActor != null) 2738 if (m_rootPart.PhysActor != null)
@@ -2735,31 +2744,44 @@ namespace OpenSim.Region.Framework.Scenes
2735 bool grpusephys = UsesPhysics; 2744 bool grpusephys = UsesPhysics;
2736 bool grptemporary = IsTemporary; 2745 bool grptemporary = IsTemporary;
2737 2746
2747 // Remember where the group being linked thought it was
2738 Vector3 oldGroupPosition = linkPart.GroupPosition; 2748 Vector3 oldGroupPosition = linkPart.GroupPosition;
2739 Quaternion oldRootRotation = linkPart.RotationOffset; 2749 Quaternion oldRootRotation = linkPart.RotationOffset;
2740 2750
2741 linkPart.OffsetPosition = linkPart.GroupPosition - AbsolutePosition; 2751 // A linked SOP remembers its location and rotation relative to the root of a group.
2752 // Convert the root of the group being linked to be relative to the
2753 // root of the group being linked to.
2754 // Note: Some of the assignments have complex side effects.
2742 2755
2756 // First move the new group's root SOP's position to be relative to ours
2757 // (radams1: Not sure if the multiple setting of OffsetPosition is required. If not,
2758 // this code can be reordered to have a more logical flow.)
2759 linkPart.OffsetPosition = linkPart.GroupPosition - AbsolutePosition;
2760 // Assign the new parent to the root of the old group
2743 linkPart.ParentID = m_rootPart.LocalId; 2761 linkPart.ParentID = m_rootPart.LocalId;
2744 2762 // Now that it's a child, it's group position is our root position
2745 linkPart.GroupPosition = AbsolutePosition; 2763 linkPart.GroupPosition = AbsolutePosition;
2746 2764
2747 Vector3 axPos = linkPart.OffsetPosition; 2765 Vector3 axPos = linkPart.OffsetPosition;
2766 // Rotate the linking root SOP's position to be relative to the new root prim
2748 Quaternion parentRot = m_rootPart.RotationOffset; 2767 Quaternion parentRot = m_rootPart.RotationOffset;
2749 axPos *= Quaternion.Conjugate(parentRot); 2768 axPos *= Quaternion.Conjugate(parentRot);
2750 linkPart.OffsetPosition = axPos; 2769 linkPart.OffsetPosition = axPos;
2751 2770
2771 // Make the linking root SOP's rotation relative to the new root prim
2752 Quaternion oldRot = linkPart.RotationOffset; 2772 Quaternion oldRot = linkPart.RotationOffset;
2753 Quaternion newRot = Quaternion.Conjugate(parentRot) * oldRot; 2773 Quaternion newRot = Quaternion.Conjugate(parentRot) * oldRot;
2754 linkPart.RotationOffset = newRot; 2774 linkPart.RotationOffset = newRot;
2755 2775
2756// linkPart.ParentID = m_rootPart.LocalId; done above 2776 // If there is only one SOP in a SOG, the LinkNum is zero. I.e., not a linkset.
2757 2777 // Now that we know this SOG has at least two SOPs in it, the new root
2778 // SOP becomes the first in the linkset.
2758 if (m_rootPart.LinkNum == 0) 2779 if (m_rootPart.LinkNum == 0)
2759 m_rootPart.LinkNum = 1; 2780 m_rootPart.LinkNum = 1;
2760 2781
2761 lock (m_parts.SyncRoot) 2782 lock (m_parts.SyncRoot)
2762 { 2783 {
2784 // Calculate the new link number for the old root SOP
2763 int linkNum; 2785 int linkNum;
2764 if (insert) 2786 if (insert)
2765 { 2787 {
@@ -2775,6 +2797,7 @@ namespace OpenSim.Region.Framework.Scenes
2775 linkNum = PrimCount + 1; 2797 linkNum = PrimCount + 1;
2776 } 2798 }
2777 2799
2800 // Add the old root SOP as a part in our group's list
2778 m_parts.Add(linkPart.UUID, linkPart); 2801 m_parts.Add(linkPart.UUID, linkPart);
2779 2802
2780 linkPart.SetParent(this); 2803 linkPart.SetParent(this);
@@ -2782,6 +2805,8 @@ namespace OpenSim.Region.Framework.Scenes
2782 2805
2783 // let physics know preserve part volume dtc messy since UpdatePrimFlags doesn't look to parent changes for now 2806 // let physics know preserve part volume dtc messy since UpdatePrimFlags doesn't look to parent changes for now
2784 linkPart.UpdatePrimFlags(grpusephys, grptemporary, (IsPhantom || (linkPart.Flags & PrimFlags.Phantom) != 0), linkPart.VolumeDetectActive, true); 2807 linkPart.UpdatePrimFlags(grpusephys, grptemporary, (IsPhantom || (linkPart.Flags & PrimFlags.Phantom) != 0), linkPart.VolumeDetectActive, true);
2808
2809 // If the added SOP is physical, also tell the physics engine about the link relationship.
2785 if (linkPart.PhysActor != null && m_rootPart.PhysActor != null && m_rootPart.PhysActor.IsPhysical) 2810 if (linkPart.PhysActor != null && m_rootPart.PhysActor != null && m_rootPart.PhysActor.IsPhysical)
2786 { 2811 {
2787 linkPart.PhysActor.link(m_rootPart.PhysActor); 2812 linkPart.PhysActor.link(m_rootPart.PhysActor);
@@ -2791,20 +2816,26 @@ namespace OpenSim.Region.Framework.Scenes
2791 linkPart.LinkNum = linkNum++; 2816 linkPart.LinkNum = linkNum++;
2792 linkPart.UpdatePrimFlags(UsesPhysics, IsTemporary, IsPhantom, IsVolumeDetect, false); 2817 linkPart.UpdatePrimFlags(UsesPhysics, IsTemporary, IsPhantom, IsVolumeDetect, false);
2793 2818
2819 // Get a list of the SOP's in the old group in order of their linknum's.
2794 SceneObjectPart[] ogParts = objectGroup.Parts; 2820 SceneObjectPart[] ogParts = objectGroup.Parts;
2795 Array.Sort(ogParts, delegate(SceneObjectPart a, SceneObjectPart b) 2821 Array.Sort(ogParts, delegate(SceneObjectPart a, SceneObjectPart b)
2796 { 2822 {
2797 return a.LinkNum - b.LinkNum; 2823 return a.LinkNum - b.LinkNum;
2798 }); 2824 });
2799 2825
2826 // Add each of the SOP's from the old linkset to our linkset
2800 for (int i = 0; i < ogParts.Length; i++) 2827 for (int i = 0; i < ogParts.Length; i++)
2801 { 2828 {
2802 SceneObjectPart part = ogParts[i]; 2829 SceneObjectPart part = ogParts[i];
2803 if (part.UUID != objectGroup.m_rootPart.UUID) 2830 if (part.UUID != objectGroup.m_rootPart.UUID)
2804 { 2831 {
2805 LinkNonRootPart(part, oldGroupPosition, oldRootRotation, linkNum++); 2832 LinkNonRootPart(part, oldGroupPosition, oldRootRotation, linkNum++);
2806 // let physics know 2833
2834 // Update the physics flags for the newly added SOP
2835 // (Is this necessary? LinkNonRootPart() has already called UpdatePrimFlags but with different flags!??)
2807 part.UpdatePrimFlags(grpusephys, grptemporary, (IsPhantom || (part.Flags & PrimFlags.Phantom) != 0), part.VolumeDetectActive, true); 2836 part.UpdatePrimFlags(grpusephys, grptemporary, (IsPhantom || (part.Flags & PrimFlags.Phantom) != 0), part.VolumeDetectActive, true);
2837
2838 // If the added SOP is physical, also tell the physics engine about the link relationship.
2808 if (part.PhysActor != null && m_rootPart.PhysActor != null && m_rootPart.PhysActor.IsPhysical) 2839 if (part.PhysActor != null && m_rootPart.PhysActor != null && m_rootPart.PhysActor.IsPhysical)
2809 { 2840 {
2810 part.PhysActor.link(m_rootPart.PhysActor); 2841 part.PhysActor.link(m_rootPart.PhysActor);
@@ -2815,6 +2846,7 @@ namespace OpenSim.Region.Framework.Scenes
2815 } 2846 }
2816 } 2847 }
2817 2848
2849 // Now that we've aquired all of the old SOG's parts, remove the old SOG from the scene.
2818 m_scene.UnlinkSceneObject(objectGroup, true); 2850 m_scene.UnlinkSceneObject(objectGroup, true);
2819 objectGroup.IsDeleted = true; 2851 objectGroup.IsDeleted = true;
2820 2852
@@ -2890,7 +2922,7 @@ namespace OpenSim.Region.Framework.Scenes
2890 /// <remarks> 2922 /// <remarks>
2891 /// FIXME: This method should not be called directly since it bypasses update locking, allowing a potential race 2923 /// FIXME: This method should not be called directly since it bypasses update locking, allowing a potential race
2892 /// condition. But currently there is no 2924 /// condition. But currently there is no
2893 /// alternative method that does take a lonk to delink a single prim. 2925 /// alternative method that does take a lock to delink a single prim.
2894 /// </remarks> 2926 /// </remarks>
2895 /// <param name="partID"></param> 2927 /// <param name="partID"></param>
2896 /// <param name="sendEvents"></param> 2928 /// <param name="sendEvents"></param>
@@ -2906,6 +2938,7 @@ namespace OpenSim.Region.Framework.Scenes
2906 2938
2907 linkPart.ClearUndoState(); 2939 linkPart.ClearUndoState();
2908 2940
2941 Vector3 worldPos = linkPart.GetWorldPosition();
2909 Quaternion worldRot = linkPart.GetWorldRotation(); 2942 Quaternion worldRot = linkPart.GetWorldRotation();
2910 2943
2911 // Remove the part from this object 2944 // Remove the part from this object
@@ -2915,6 +2948,7 @@ namespace OpenSim.Region.Framework.Scenes
2915 2948
2916 SceneObjectPart[] parts = m_parts.GetArray(); 2949 SceneObjectPart[] parts = m_parts.GetArray();
2917 2950
2951 // Rejigger the linknum's of the remaining SOP's to fill any gap
2918 if (parts.Length == 1 && RootPart != null) 2952 if (parts.Length == 1 && RootPart != null)
2919 { 2953 {
2920 // Single prim left 2954 // Single prim left
@@ -2936,22 +2970,31 @@ namespace OpenSim.Region.Framework.Scenes
2936 2970
2937 PhysicsActor linkPartPa = linkPart.PhysActor; 2971 PhysicsActor linkPartPa = linkPart.PhysActor;
2938 2972
2973 // Remove the SOP from the physical scene.
2974 // If the new SOG is physical, it is re-created later.
2975 // (There is a problem here in that we have not yet told the physics
2976 // engine about the delink. Someday, linksets should be made first
2977 // class objects in the physics engine interface).
2939 if (linkPartPa != null) 2978 if (linkPartPa != null)
2940 m_scene.PhysicsScene.RemovePrim(linkPartPa); 2979 m_scene.PhysicsScene.RemovePrim(linkPartPa);
2941 2980
2942 // We need to reset the child part's position 2981 // We need to reset the child part's position
2943 // ready for life as a separate object after being a part of another object 2982 // ready for life as a separate object after being a part of another object
2944 Quaternion parentRot = m_rootPart.RotationOffset;
2945 2983
2984 /* This commented out code seems to recompute what GetWorldPosition already does.
2985 * Replace with a call to GetWorldPosition (before unlinking)
2986 Quaternion parentRot = m_rootPart.RotationOffset;
2946 Vector3 axPos = linkPart.OffsetPosition; 2987 Vector3 axPos = linkPart.OffsetPosition;
2947
2948 axPos *= parentRot; 2988 axPos *= parentRot;
2949 linkPart.OffsetPosition = new Vector3(axPos.X, axPos.Y, axPos.Z); 2989 linkPart.OffsetPosition = new Vector3(axPos.X, axPos.Y, axPos.Z);
2950 linkPart.GroupPosition = AbsolutePosition + linkPart.OffsetPosition; 2990 linkPart.GroupPosition = AbsolutePosition + linkPart.OffsetPosition;
2951 linkPart.OffsetPosition = new Vector3(0, 0, 0); 2991 linkPart.OffsetPosition = new Vector3(0, 0, 0);
2952 2992 */
2993 linkPart.GroupPosition = worldPos;
2994 linkPart.OffsetPosition = Vector3.Zero;
2953 linkPart.RotationOffset = worldRot; 2995 linkPart.RotationOffset = worldRot;
2954 2996
2997 // Create a new SOG to go around this unlinked and unattached SOP
2955 SceneObjectGroup objectGroup = new SceneObjectGroup(linkPart); 2998 SceneObjectGroup objectGroup = new SceneObjectGroup(linkPart);
2956 2999
2957 m_scene.AddNewSceneObject(objectGroup, true); 3000 m_scene.AddNewSceneObject(objectGroup, true);
@@ -2989,43 +3032,57 @@ namespace OpenSim.Region.Framework.Scenes
2989 m_isBackedUp = false; 3032 m_isBackedUp = false;
2990 } 3033 }
2991 3034
3035 // This links an SOP from a previous linkset into my linkset.
3036 // The trick is that the SOP's position and rotation are relative to the old root SOP's
3037 // so we are passed in the position and rotation of the old linkset so this can
3038 // unjigger this SOP's position and rotation from the previous linkset and
3039 // then make them relative to my linkset root.
2992 private void LinkNonRootPart(SceneObjectPart part, Vector3 oldGroupPosition, Quaternion oldGroupRotation, int linkNum) 3040 private void LinkNonRootPart(SceneObjectPart part, Vector3 oldGroupPosition, Quaternion oldGroupRotation, int linkNum)
2993 { 3041 {
2994 Quaternion parentRot = oldGroupRotation; 3042 Quaternion parentRot = oldGroupRotation;
2995 Quaternion oldRot = part.RotationOffset; 3043 Quaternion oldRot = part.RotationOffset;
2996 Quaternion worldRot = parentRot * oldRot;
2997
2998 parentRot = oldGroupRotation;
2999 3044
3045 // Move our position to not be relative to the old parent
3000 Vector3 axPos = part.OffsetPosition; 3046 Vector3 axPos = part.OffsetPosition;
3001
3002 axPos *= parentRot; 3047 axPos *= parentRot;
3003 part.OffsetPosition = axPos; 3048 part.OffsetPosition = axPos;
3004 Vector3 newPos = oldGroupPosition + part.OffsetPosition; 3049 Vector3 newPos = oldGroupPosition + part.OffsetPosition;
3005 part.GroupPosition = newPos; 3050 part.GroupPosition = newPos;
3006 part.OffsetPosition = Vector3.Zero; 3051 part.OffsetPosition = Vector3.Zero;
3052
3053 // Compution our rotation to be not relative to the old parent
3054 Quaternion worldRot = parentRot * oldRot;
3007 part.RotationOffset = worldRot; 3055 part.RotationOffset = worldRot;
3008 3056
3057 // Add this SOP to our linkset
3009 part.SetParent(this); 3058 part.SetParent(this);
3010 part.ParentID = m_rootPart.LocalId; 3059 part.ParentID = m_rootPart.LocalId;
3011
3012 m_parts.Add(part.UUID, part); 3060 m_parts.Add(part.UUID, part);
3013 3061
3014 part.LinkNum = linkNum; 3062 part.LinkNum = linkNum;
3015 3063
3016 part.OffsetPosition = newPos - AbsolutePosition; 3064 // Compute the new position of this SOP relative to the group position
3065 part.OffsetPosition = part.GroupPosition - AbsolutePosition;
3017 3066
3018 Quaternion rootRotation = m_rootPart.RotationOffset; 3067 // (radams1 20120711: I don't know why part.OffsetPosition is set multiple times.
3068 // It would have the affect of setting the physics engine position multiple
3069 // times. In theory, that is not necessary but I don't have a good linkset
3070 // test to know that cleaning up this code wouldn't break things.)
3019 3071
3072 // Rotate the relative position by the rotation of the group
3073 Quaternion rootRotation = m_rootPart.RotationOffset;
3020 Vector3 pos = part.OffsetPosition; 3074 Vector3 pos = part.OffsetPosition;
3021 pos *= Quaternion.Conjugate(rootRotation); 3075 pos *= Quaternion.Conjugate(rootRotation);
3022 part.OffsetPosition = pos; 3076 part.OffsetPosition = pos;
3023 3077
3078 // Compute the SOP's rotation relative to the rotation of the group.
3024 parentRot = m_rootPart.RotationOffset; 3079 parentRot = m_rootPart.RotationOffset;
3025 oldRot = part.RotationOffset; 3080 oldRot = part.RotationOffset;
3026 Quaternion newRot = Quaternion.Conjugate(parentRot) * worldRot; 3081 Quaternion newRot = Quaternion.Conjugate(parentRot) * worldRot;
3027 part.RotationOffset = newRot; 3082 part.RotationOffset = newRot;
3028 3083
3084 // Since this SOP's state has changed, push those changes into the physics engine
3085 // and the simulator.
3029 part.UpdatePrimFlags(UsesPhysics, IsTemporary, IsPhantom, IsVolumeDetect, false); 3086 part.UpdatePrimFlags(UsesPhysics, IsTemporary, IsPhantom, IsVolumeDetect, false);
3030 } 3087 }
3031 3088
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 2410970..b038876 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -752,6 +752,7 @@ namespace OpenSim.Region.Framework.Scenes
752 return m_groupPosition; 752 return m_groupPosition;
753 } 753 }
754 754
755 // If I'm an attachment, my position is reported as the position of who I'm attached to
755 if (ParentGroup.IsAttachment) 756 if (ParentGroup.IsAttachment)
756 { 757 {
757 ScenePresence sp = ParentGroup.Scene.GetScenePresence(ParentGroup.AttachedAvatar); 758 ScenePresence sp = ParentGroup.Scene.GetScenePresence(ParentGroup.AttachedAvatar);
@@ -779,7 +780,7 @@ namespace OpenSim.Region.Framework.Scenes
779 } 780 }
780 else 781 else
781 { 782 {
782 // To move the child prim in respect to the group position and rotation we have to calculate 783 // The physics engine always sees all objects (root or linked) in world coordinates.
783 actor.Position = GetWorldPosition(); 784 actor.Position = GetWorldPosition();
784 actor.Orientation = GetWorldRotation(); 785 actor.Orientation = GetWorldRotation();
785 } 786 }
@@ -858,6 +859,8 @@ namespace OpenSim.Region.Framework.Scenes
858 { 859 {
859 // We don't want the physics engine mucking up the rotations in a linkset 860 // We don't want the physics engine mucking up the rotations in a linkset
860 PhysicsActor actor = PhysActor; 861 PhysicsActor actor = PhysActor;
862 // If this is a root of a linkset, the real rotation is what the physics engine thinks.
863 // If not a root prim, the offset rotation is computed by SOG and is relative to the root.
861 if (ParentID == 0 && (Shape.PCode != 9 || Shape.State == 0) && actor != null) 864 if (ParentID == 0 && (Shape.PCode != 9 || Shape.State == 0) && actor != null)
862 { 865 {
863 if (actor.Orientation.X != 0f || actor.Orientation.Y != 0f 866 if (actor.Orientation.X != 0f || actor.Orientation.Y != 0f
@@ -2529,14 +2532,20 @@ namespace OpenSim.Region.Framework.Scenes
2529 /// <returns>A Linked Child Prim objects position in world</returns> 2532 /// <returns>A Linked Child Prim objects position in world</returns>
2530 public Vector3 GetWorldPosition() 2533 public Vector3 GetWorldPosition()
2531 { 2534 {
2532 Quaternion parentRot = ParentGroup.RootPart.RotationOffset; 2535 Vector3 ret;
2533 Vector3 axPos = OffsetPosition; 2536 if (_parentID == 0)
2534 axPos *= parentRot; 2537 // if a root SOP, my position is what it is
2535 Vector3 translationOffsetPosition = axPos; 2538 ret = GroupPosition;
2536 if(_parentID == 0)
2537 return GroupPosition;
2538 else 2539 else
2539 return ParentGroup.AbsolutePosition + translationOffsetPosition; 2540 {
2541 // If a child SOP, my position is relative to the root SOP so take
2542 // my info and add the root's position and rotation to
2543 // get my world position.
2544 Quaternion parentRot = ParentGroup.RootPart.RotationOffset;
2545 Vector3 translationOffsetPosition = OffsetPosition * parentRot;
2546 ret = ParentGroup.AbsolutePosition + translationOffsetPosition;
2547 }
2548 return ret;
2540 } 2549 }
2541 2550
2542 /// <summary> 2551 /// <summary>
@@ -2553,6 +2562,8 @@ namespace OpenSim.Region.Framework.Scenes
2553 } 2562 }
2554 else 2563 else
2555 { 2564 {
2565 // A child SOP's rotation is relative to the root SOP's rotation.
2566 // Combine them to get my absolute rotation.
2556 Quaternion parentRot = ParentGroup.RootPart.RotationOffset; 2567 Quaternion parentRot = ParentGroup.RootPart.RotationOffset;
2557 Quaternion oldRot = RotationOffset; 2568 Quaternion oldRot = RotationOffset;
2558 newRot = parentRot * oldRot; 2569 newRot = parentRot * oldRot;
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
index e5e29d0..1c9a17e 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
@@ -1453,6 +1453,10 @@ namespace OpenSim.Region.Framework.Scenes
1453 { 1453 {
1454 if (e != null) 1454 if (e != null)
1455 { 1455 {
1456// m_log.DebugFormat(
1457// "[PRIM INVENTORY]: Getting script state from engine {0} for {1} in part {2} in group {3} in {4}",
1458// e.Name, item.Name, m_part.Name, m_part.ParentGroup.Name, m_part.ParentGroup.Scene.Name);
1459
1456 string n = e.GetXMLState(item.ItemID); 1460 string n = e.GetXMLState(item.ItemID);
1457 if (n != String.Empty) 1461 if (n != String.Empty)
1458 { 1462 {
diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs
index 6c53d95..7b20446 100644
--- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs
@@ -823,11 +823,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
823 m_log.DebugFormat("[FreeSwitchVoice]: Region:Parcel \"{0}\": parcel id {1}: using channel name {2}", 823 m_log.DebugFormat("[FreeSwitchVoice]: Region:Parcel \"{0}\": parcel id {1}: using channel name {2}",
824 landName, land.LocalID, landUUID); 824 landName, land.LocalID, landUUID);
825 } 825 }
826 System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
827 826
828 // slvoice handles the sip address differently if it begins with confctl, hiding it from the user in the friends list. however it also disables 827 // slvoice handles the sip address differently if it begins with confctl, hiding it from the user in the friends list. however it also disables
829 // the personal speech indicators as well unless some siren14-3d codec magic happens. we dont have siren143d so we'll settle for the personal speech indicator. 828 // the personal speech indicators as well unless some siren14-3d codec magic happens. we dont have siren143d so we'll settle for the personal speech indicator.
830 channelUri = String.Format("sip:conf-{0}@{1}", "x" + Convert.ToBase64String(encoding.GetBytes(landUUID)), m_freeSwitchRealm); 829 channelUri = String.Format("sip:conf-{0}@{1}", "x" + Convert.ToBase64String(Encoding.ASCII.GetBytes(landUUID)), m_freeSwitchRealm);
831 830
832 lock (m_ParcelAddress) 831 lock (m_ParcelAddress)
833 { 832 {
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs
index 52fc27d..61aaf04 100644
--- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs
@@ -1120,7 +1120,6 @@ namespace Nwc.XmlRpc
1120 /// <summary>Class supporting the request side of an XML-RPC transaction.</summary> 1120 /// <summary>Class supporting the request side of an XML-RPC transaction.</summary>
1121 public class ConfigurableKeepAliveXmlRpcRequest : XmlRpcRequest 1121 public class ConfigurableKeepAliveXmlRpcRequest : XmlRpcRequest
1122 { 1122 {
1123 private Encoding _encoding = new ASCIIEncoding();
1124 private XmlRpcRequestSerializer _serializer = new XmlRpcRequestSerializer(); 1123 private XmlRpcRequestSerializer _serializer = new XmlRpcRequestSerializer();
1125 private XmlRpcResponseDeserializer _deserializer = new XmlRpcResponseDeserializer(); 1124 private XmlRpcResponseDeserializer _deserializer = new XmlRpcResponseDeserializer();
1126 private bool _disableKeepAlive = true; 1125 private bool _disableKeepAlive = true;
@@ -1153,7 +1152,7 @@ namespace Nwc.XmlRpc
1153 request.KeepAlive = !_disableKeepAlive; 1152 request.KeepAlive = !_disableKeepAlive;
1154 1153
1155 Stream stream = request.GetRequestStream(); 1154 Stream stream = request.GetRequestStream();
1156 XmlTextWriter xml = new XmlTextWriter(stream, _encoding); 1155 XmlTextWriter xml = new XmlTextWriter(stream, Encoding.ASCII);
1157 _serializer.Serialize(xml, this); 1156 _serializer.Serialize(xml, this);
1158 xml.Flush(); 1157 xml.Flush();
1159 xml.Close(); 1158 xml.Close();
diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs
index 4949097..eaba816 100644
--- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs
@@ -425,10 +425,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
425 425
426 try 426 try
427 { 427 {
428 System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding(); 428 string jsondata = SLUtil.ParseNotecardToString(Encoding.UTF8.GetString(a.Data));
429 string jsondata = SLUtil.ParseNotecardToString(enc.GetString(a.Data)); 429 int result = m_store.SetValue(storeID, path, jsondata,true) ? 1 : 0;
430 int result = m_store.SetValue(storeID,path,jsondata,true) ? 1 : 0; 430 m_comms.DispatchReply(scriptID,result, "", reqID.ToString());
431 m_comms.DispatchReply(scriptID,result,"",reqID.ToString());
432 return; 431 return;
433 } 432 }
434 catch (Exception e) 433 catch (Exception e)
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs
index 74f5208..03481d2 100644
--- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs
@@ -482,10 +482,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
482 // Convert to base64 482 // Convert to base64
483 // 483 //
484 string filetext = Convert.ToBase64String(data); 484 string filetext = Convert.ToBase64String(data);
485 485 Byte[] buf = Encoding.ASCII.GetBytes(filetext);
486 ASCIIEncoding enc = new ASCIIEncoding();
487
488 Byte[] buf = enc.GetBytes(filetext);
489 486
490 m_log.Info("MRM 9"); 487 m_log.Info("MRM 9");
491 488
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs
index 3cbdde5..693992a 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs
@@ -233,17 +233,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
233 m_Timer[engine].UnSetTimerEvents(localID, itemID); 233 m_Timer[engine].UnSetTimerEvents(localID, itemID);
234 234
235 // Remove from: HttpRequest 235 // Remove from: HttpRequest
236 IHttpRequestModule iHttpReq = 236 IHttpRequestModule iHttpReq = engine.World.RequestModuleInterface<IHttpRequestModule>();
237 engine.World.RequestModuleInterface<IHttpRequestModule>(); 237 if (iHttpReq != null)
238 iHttpReq.StopHttpRequest(localID, itemID); 238 iHttpReq.StopHttpRequest(localID, itemID);
239 239
240 IWorldComm comms = engine.World.RequestModuleInterface<IWorldComm>(); 240 IWorldComm comms = engine.World.RequestModuleInterface<IWorldComm>();
241 if (comms != null) 241 if (comms != null)
242 comms.DeleteListener(itemID); 242 comms.DeleteListener(itemID);
243 243
244 IXMLRPC xmlrpc = engine.World.RequestModuleInterface<IXMLRPC>(); 244 IXMLRPC xmlrpc = engine.World.RequestModuleInterface<IXMLRPC>();
245 xmlrpc.DeleteChannels(itemID); 245 if (xmlrpc != null)
246 xmlrpc.CancelSRDRequests(itemID); 246 {
247 xmlrpc.DeleteChannels(itemID);
248 xmlrpc.CancelSRDRequests(itemID);
249 }
247 250
248 // Remove Sensors 251 // Remove Sensors
249 m_SensorRepeat[engine].UnSetSenseRepeaterEvents(localID, itemID); 252 m_SensorRepeat[engine].UnSetSenseRepeaterEvents(localID, itemID);
@@ -325,7 +328,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
325 { 328 {
326 List<Object> data = new List<Object>(); 329 List<Object> data = new List<Object>();
327 330
328 Object[] listeners=m_Listener[engine].GetSerializationData(itemID); 331 Object[] listeners = m_Listener[engine].GetSerializationData(itemID);
329 if (listeners.Length > 0) 332 if (listeners.Length > 0)
330 { 333 {
331 data.Add("listener"); 334 data.Add("listener");
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index e9db5d5..fed3122 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -11918,9 +11918,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
11918 return; 11918 return;
11919 } 11919 }
11920 11920
11921 System.Text.UTF8Encoding enc = 11921 string data = Encoding.UTF8.GetString(a.Data);
11922 new System.Text.UTF8Encoding();
11923 string data = enc.GetString(a.Data);
11924 //m_log.Debug(data); 11922 //m_log.Debug(data);
11925 NotecardCache.Cache(id, data); 11923 NotecardCache.Cache(id, data);
11926 AsyncCommands. 11924 AsyncCommands.
@@ -11973,9 +11971,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
11973 return; 11971 return;
11974 } 11972 }
11975 11973
11976 System.Text.UTF8Encoding enc = 11974 string data = Encoding.UTF8.GetString(a.Data);
11977 new System.Text.UTF8Encoding();
11978 string data = enc.GetString(a.Data);
11979 //m_log.Debug(data); 11975 //m_log.Debug(data);
11980 NotecardCache.Cache(id, data); 11976 NotecardCache.Cache(id, data);
11981 AsyncCommands.DataserverPlugin.DataserverReply(id.ToString(), 11977 AsyncCommands.DataserverPlugin.DataserverReply(id.ToString(),
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index b639d36..4d20f7b 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -1822,8 +1822,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1822 if (a == null) 1822 if (a == null)
1823 return UUID.Zero; 1823 return UUID.Zero;
1824 1824
1825 System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding(); 1825 string data = Encoding.UTF8.GetString(a.Data);
1826 string data = enc.GetString(a.Data);
1827 NotecardCache.Cache(assetID, data); 1826 NotecardCache.Cache(assetID, data);
1828 }; 1827 };
1829 1828
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Listener.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Listener.cs
index 93e0261..efa86fc 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Listener.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Listener.cs
@@ -88,13 +88,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
88 88
89 public Object[] GetSerializationData(UUID itemID) 89 public Object[] GetSerializationData(UUID itemID)
90 { 90 {
91 return m_commsPlugin.GetSerializationData(itemID); 91 if (m_commsPlugin != null)
92 return m_commsPlugin.GetSerializationData(itemID);
93 else
94 return new Object[]{};
92 } 95 }
93 96
94 public void CreateFromData(uint localID, UUID itemID, UUID hostID, 97 public void CreateFromData(uint localID, UUID itemID, UUID hostID,
95 Object[] data) 98 Object[] data)
96 { 99 {
97 m_commsPlugin.CreateFromData(localID, itemID, hostID, data); 100 if (m_commsPlugin != null)
101 m_commsPlugin.CreateFromData(localID, itemID, hostID, data);
98 } 102 }
99 } 103 }
100} \ No newline at end of file 104} \ No newline at end of file
diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs
index 8f2ec49..17a0d69 100644
--- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs
@@ -31,6 +31,7 @@ using System.Collections.Generic;
31using System.Globalization; 31using System.Globalization;
32using System.Reflection; 32using System.Reflection;
33using System.IO; 33using System.IO;
34using System.Text;
34using Microsoft.CSharp; 35using Microsoft.CSharp;
35//using Microsoft.JScript; 36//using Microsoft.JScript;
36using Microsoft.VisualBasic; 37using Microsoft.VisualBasic;
@@ -711,9 +712,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
711 // 712 //
712 string filetext = System.Convert.ToBase64String(data); 713 string filetext = System.Convert.ToBase64String(data);
713 714
714 System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding(); 715 Byte[] buf = Encoding.ASCII.GetBytes(filetext);
715
716 Byte[] buf = enc.GetBytes(filetext);
717 716
718 FileStream sfs = File.Create(assembly + ".text"); 717 FileStream sfs = File.Create(assembly + ".text");
719 sfs.Write(buf, 0, buf.Length); 718 sfs.Write(buf, 0, buf.Length);
@@ -804,8 +803,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
804 mapstring += String.Format("{0},{1},{2},{3}\n", k.Key, k.Value, v.Key, v.Value); 803 mapstring += String.Format("{0},{1},{2},{3}\n", k.Key, k.Value, v.Key, v.Value);
805 } 804 }
806 805
807 System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding(); 806 Byte[] mapbytes = Encoding.ASCII.GetBytes(mapstring);
808 Byte[] mapbytes = enc.GetBytes(mapstring);
809 FileStream mfs = File.Create(filename); 807 FileStream mfs = File.Create(filename);
810 mfs.Write(mapbytes, 0, mapbytes.Length); 808 mfs.Write(mapbytes, 0, mapbytes.Length);
811 mfs.Close(); 809 mfs.Close();
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
index 3797683..3ddf1d4 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
@@ -26,16 +26,17 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections;
30using System.Collections.Generic;
31using System.Globalization;
29using System.IO; 32using System.IO;
30using System.Diagnostics; //for [DebuggerNonUserCode] 33using System.Diagnostics; //for [DebuggerNonUserCode]
34using System.Reflection;
31using System.Runtime.Remoting; 35using System.Runtime.Remoting;
32using System.Runtime.Remoting.Lifetime; 36using System.Runtime.Remoting.Lifetime;
33using System.Threading;
34using System.Collections;
35using System.Collections.Generic;
36using System.Security.Policy; 37using System.Security.Policy;
37using System.Reflection; 38using System.Text;
38using System.Globalization; 39using System.Threading;
39using System.Xml; 40using System.Xml;
40using OpenMetaverse; 41using OpenMetaverse;
41using log4net; 42using log4net;
@@ -298,13 +299,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
298 using (FileStream fs = File.Open(savedState, 299 using (FileStream fs = File.Open(savedState,
299 FileMode.Open, FileAccess.Read, FileShare.None)) 300 FileMode.Open, FileAccess.Read, FileShare.None))
300 { 301 {
301 System.Text.UTF8Encoding enc =
302 new System.Text.UTF8Encoding();
303
304 Byte[] data = new Byte[size]; 302 Byte[] data = new Byte[size];
305 fs.Read(data, 0, size); 303 fs.Read(data, 0, size);
306 304
307 xml = enc.GetString(data); 305 xml = Encoding.UTF8.GetString(data);
308 306
309 ScriptSerializer.Deserialize(xml, this); 307 ScriptSerializer.Deserialize(xml, this);
310 308
@@ -956,8 +954,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
956 try 954 try
957 { 955 {
958 FileStream fs = File.Create(Path.Combine(Path.GetDirectoryName(assembly), ItemID.ToString() + ".state")); 956 FileStream fs = File.Create(Path.Combine(Path.GetDirectoryName(assembly), ItemID.ToString() + ".state"));
959 System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding(); 957 Byte[] buf = (new UTF8Encoding()).GetBytes(xml);
960 Byte[] buf = enc.GetBytes(xml);
961 fs.Write(buf, 0, buf.Length); 958 fs.Write(buf, 0, buf.Length);
962 fs.Close(); 959 fs.Close();
963 } 960 }
diff --git a/OpenSim/Region/ScriptEngine/XEngine/Tests/XEngineTest.cs b/OpenSim/Region/ScriptEngine/XEngine/Tests/XEngineTest.cs
index a3f848c..f247a0b 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/Tests/XEngineTest.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/Tests/XEngineTest.cs
@@ -58,9 +58,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine.Tests
58// Console.WriteLine(AppDomain.CurrentDomain.BaseDirectory); 58// Console.WriteLine(AppDomain.CurrentDomain.BaseDirectory);
59 m_xEngine = new XEngine(); 59 m_xEngine = new XEngine();
60 60
61 // Necessary to stop serialization complaining
62 WorldCommModule wcModule = new WorldCommModule();
63
64 IniConfigSource configSource = new IniConfigSource(); 61 IniConfigSource configSource = new IniConfigSource();
65 62
66 IConfig startupConfig = configSource.AddConfig("Startup"); 63 IConfig startupConfig = configSource.AddConfig("Startup");
@@ -68,13 +65,14 @@ namespace OpenSim.Region.ScriptEngine.XEngine.Tests
68 65
69 IConfig xEngineConfig = configSource.AddConfig("XEngine"); 66 IConfig xEngineConfig = configSource.AddConfig("XEngine");
70 xEngineConfig.Set("Enabled", "true"); 67 xEngineConfig.Set("Enabled", "true");
68 xEngineConfig.Set("StartDelay", "0");
71 69
72 // These tests will not run with AppDomainLoading = true, at least on mono. For unknown reasons, the call 70 // These tests will not run with AppDomainLoading = true, at least on mono. For unknown reasons, the call
73 // to AssemblyResolver.OnAssemblyResolve fails. 71 // to AssemblyResolver.OnAssemblyResolve fails.
74 xEngineConfig.Set("AppDomainLoading", "false"); 72 xEngineConfig.Set("AppDomainLoading", "false");
75 73
76 m_scene = new SceneHelpers().SetupScene("My Test", UUID.Random(), 1000, 1000, configSource); 74 m_scene = new SceneHelpers().SetupScene("My Test", UUID.Random(), 1000, 1000, configSource);
77 SceneHelpers.SetupSceneModules(m_scene, configSource, m_xEngine, wcModule); 75 SceneHelpers.SetupSceneModules(m_scene, configSource, m_xEngine);
78 m_scene.StartScripts(); 76 m_scene.StartScripts();
79 } 77 }
80 78
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
index cc783aa..d763063 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
@@ -78,7 +78,13 @@ namespace OpenSim.Region.ScriptEngine.XEngine
78 private IConfigSource m_ConfigSource = null; 78 private IConfigSource m_ConfigSource = null;
79 private ICompiler m_Compiler; 79 private ICompiler m_Compiler;
80 private int m_MinThreads; 80 private int m_MinThreads;
81 private int m_MaxThreads ; 81 private int m_MaxThreads;
82
83 /// <summary>
84 /// Amount of time to delay before starting.
85 /// </summary>
86 private int m_StartDelay;
87
82 private int m_IdleTimeout; 88 private int m_IdleTimeout;
83 private int m_StackSize; 89 private int m_StackSize;
84 private int m_SleepTime; 90 private int m_SleepTime;
@@ -299,6 +305,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
299 m_MaxThreads = m_ScriptConfig.GetInt("MaxThreads", 100); 305 m_MaxThreads = m_ScriptConfig.GetInt("MaxThreads", 100);
300 m_IdleTimeout = m_ScriptConfig.GetInt("IdleTimeout", 60); 306 m_IdleTimeout = m_ScriptConfig.GetInt("IdleTimeout", 60);
301 string priority = m_ScriptConfig.GetString("Priority", "BelowNormal"); 307 string priority = m_ScriptConfig.GetString("Priority", "BelowNormal");
308 m_StartDelay = m_ScriptConfig.GetInt("StartDelay", 15000);
302 m_MaxScriptQueue = m_ScriptConfig.GetInt("MaxScriptEventQueue",300); 309 m_MaxScriptQueue = m_ScriptConfig.GetInt("MaxScriptEventQueue",300);
303 m_StackSize = m_ScriptConfig.GetInt("ThreadStackSize", 262144); 310 m_StackSize = m_ScriptConfig.GetInt("ThreadStackSize", 262144);
304 m_SleepTime = m_ScriptConfig.GetInt("MaintenanceInterval", 10) * 1000; 311 m_SleepTime = m_ScriptConfig.GetInt("MaintenanceInterval", 10) * 1000;
@@ -957,7 +964,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
957 { 964 {
958 // This delay exists to stop mono problems where script compilation and startup would stop the sim 965 // This delay exists to stop mono problems where script compilation and startup would stop the sim
959 // working properly for the session. 966 // working properly for the session.
960 System.Threading.Thread.Sleep(15000); 967 System.Threading.Thread.Sleep(m_StartDelay);
961 } 968 }
962 969
963 object[] o; 970 object[] o;
@@ -1768,12 +1775,12 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1768 1775
1769 public string GetXMLState(UUID itemID) 1776 public string GetXMLState(UUID itemID)
1770 { 1777 {
1771// m_log.DebugFormat("[XEngine]: Getting XML state for {0}", itemID); 1778// m_log.DebugFormat("[XEngine]: Getting XML state for script instance {0}", itemID);
1772 1779
1773 IScriptInstance instance = GetInstance(itemID); 1780 IScriptInstance instance = GetInstance(itemID);
1774 if (instance == null) 1781 if (instance == null)
1775 { 1782 {
1776// m_log.DebugFormat("[XEngine]: Found no script for {0}, returning empty string", itemID); 1783// m_log.DebugFormat("[XEngine]: Found no script instance for {0}, returning empty string", itemID);
1777 return ""; 1784 return "";
1778 } 1785 }
1779 1786
@@ -1848,7 +1855,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1848 tfs.Read(tdata, 0, tdata.Length); 1855 tfs.Read(tdata, 0, tdata.Length);
1849 } 1856 }
1850 1857
1851 assem = new System.Text.ASCIIEncoding().GetString(tdata); 1858 assem = Encoding.ASCII.GetString(tdata);
1852 } 1859 }
1853 catch (Exception e) 1860 catch (Exception e)
1854 { 1861 {
diff --git a/OpenSim/Server/Base/ServicesServerBase.cs b/OpenSim/Server/Base/ServicesServerBase.cs
index 36c48e6..b137c05 100644
--- a/OpenSim/Server/Base/ServicesServerBase.cs
+++ b/OpenSim/Server/Base/ServicesServerBase.cs
@@ -27,9 +27,10 @@
27 27
28using System; 28using System;
29using System.IO; 29using System.IO;
30using System.Xml;
31using System.Threading;
32using System.Reflection; 30using System.Reflection;
31using System.Threading;
32using System.Text;
33using System.Xml;
33using OpenSim.Framework; 34using OpenSim.Framework;
34using OpenSim.Framework.Console; 35using OpenSim.Framework.Console;
35using log4net; 36using log4net;
@@ -335,8 +336,7 @@ namespace OpenSim.Server.Base
335 { 336 {
336 string pidstring = System.Diagnostics.Process.GetCurrentProcess().Id.ToString(); 337 string pidstring = System.Diagnostics.Process.GetCurrentProcess().Id.ToString();
337 FileStream fs = File.Create(path); 338 FileStream fs = File.Create(path);
338 System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding(); 339 Byte[] buf = Encoding.ASCII.GetBytes(pidstring);
339 Byte[] buf = enc.GetBytes(pidstring);
340 fs.Write(buf, 0, buf.Length); 340 fs.Write(buf, 0, buf.Length);
341 fs.Close(); 341 fs.Close();
342 m_pidFile = path; 342 m_pidFile = path;
diff --git a/OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs b/OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs
index 9607f1f..fba03ab 100644
--- a/OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs
+++ b/OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs
@@ -69,7 +69,7 @@ namespace OpenSim.Tests.Common
69 } 69 }
70 70
71 /// <summary> 71 /// <summary>
72 /// Add a blank script to the given part. 72 /// Add a simple script to the given part.
73 /// </summary> 73 /// </summary>
74 /// <remarks> 74 /// <remarks>
75 /// TODO: Accept input for item and asset IDs to avoid mysterious script failures that try to use any of these 75 /// TODO: Accept input for item and asset IDs to avoid mysterious script failures that try to use any of these
@@ -81,6 +81,7 @@ namespace OpenSim.Tests.Common
81 public static TaskInventoryItem AddScript(Scene scene, SceneObjectPart part) 81 public static TaskInventoryItem AddScript(Scene scene, SceneObjectPart part)
82 { 82 {
83 AssetScriptText ast = new AssetScriptText(); 83 AssetScriptText ast = new AssetScriptText();
84 ast.Source = "default { state_entry() { llSay(0, \"Hello World\"); } }";
84 ast.Encode(); 85 ast.Encode();
85 86
86 UUID assetUuid = new UUID("00000000-0000-0000-1000-000000000000"); 87 UUID assetUuid = new UUID("00000000-0000-0000-1000-000000000000");
diff --git a/OpenSim/Tests/Common/Helpers/UserInventoryHelpers.cs b/OpenSim/Tests/Common/Helpers/UserInventoryHelpers.cs
index fdc60d8..b3a7c9e 100644
--- a/OpenSim/Tests/Common/Helpers/UserInventoryHelpers.cs
+++ b/OpenSim/Tests/Common/Helpers/UserInventoryHelpers.cs
@@ -43,6 +43,57 @@ namespace OpenSim.Tests.Common
43 public static readonly string PATH_DELIMITER = "/"; 43 public static readonly string PATH_DELIMITER = "/";
44 44
45 /// <summary> 45 /// <summary>
46 /// Add an existing scene object as an item in the user's inventory.
47 /// </summary>
48 /// <param name='scene'></param>
49 /// <param name='so'></param>
50 /// <param name='inventoryIdTail'></param>
51 /// <param name='assetIdTail'></param>
52 /// <returns>The inventory item created.</returns>
53 public static InventoryItemBase AddInventoryItem(
54 Scene scene, SceneObjectGroup so, int inventoryIdTail, int assetIdTail)
55 {
56 return AddInventoryItem(
57 scene,
58 so.Name,
59 TestHelpers.ParseTail(inventoryIdTail),
60 InventoryType.Object,
61 AssetHelpers.CreateAsset(TestHelpers.ParseTail(assetIdTail), so),
62 so.OwnerID);
63 }
64
65 /// <summary>
66 /// Creates a notecard in the objects folder and specify an item id.
67 /// </summary>
68 /// <param name="scene"></param>
69 /// <param name="itemName"></param>
70 /// <param name="itemId"></param>
71 /// <param name="itemType"></param>
72 /// <param name="asset">The serialized asset for this item</param>
73 /// <param name="userId"></param>
74 /// <returns></returns>
75 private static InventoryItemBase AddInventoryItem(
76 Scene scene, string itemName, UUID itemId, InventoryType itemType, AssetBase asset, UUID userId)
77 {
78 scene.AssetService.Store(asset);
79
80 InventoryItemBase item = new InventoryItemBase();
81 item.Name = itemName;
82 item.AssetID = asset.FullID;
83 item.ID = itemId;
84 item.Owner = userId;
85 item.AssetType = asset.Type;
86 item.InvType = (int)itemType;
87
88 InventoryFolderBase folder = scene.InventoryService.GetFolderForType(userId, (AssetType)asset.Type);
89
90 item.Folder = folder.ID;
91 scene.AddInventoryItem(item);
92
93 return item;
94 }
95
96 /// <summary>
46 /// Creates a notecard in the objects folder and specify an item id. 97 /// Creates a notecard in the objects folder and specify an item id.
47 /// </summary> 98 /// </summary>
48 /// <param name="scene"></param> 99 /// <param name="scene"></param>
@@ -81,42 +132,27 @@ namespace OpenSim.Tests.Common
81 /// <param name="type">Type of item to create</param> 132 /// <param name="type">Type of item to create</param>
82 /// <returns></returns> 133 /// <returns></returns>
83 public static InventoryItemBase CreateInventoryItem( 134 public static InventoryItemBase CreateInventoryItem(
84 Scene scene, string itemName, UUID itemId, UUID assetId, UUID userId, InventoryType type) 135 Scene scene, string itemName, UUID itemId, UUID assetId, UUID userId, InventoryType itemType)
85 { 136 {
86 AssetBase asset = null; 137 AssetBase asset = null;
87 138
88 if (type == InventoryType.Notecard) 139 if (itemType == InventoryType.Notecard)
89 { 140 {
90 asset = AssetHelpers.CreateNotecardAsset(); 141 asset = AssetHelpers.CreateNotecardAsset();
91 asset.CreatorID = userId.ToString(); 142 asset.CreatorID = userId.ToString();
92 } 143 }
93 else if (type == InventoryType.Object) 144 else if (itemType == InventoryType.Object)
94 { 145 {
95 asset = AssetHelpers.CreateAsset(assetId, SceneHelpers.CreateSceneObject(1, userId)); 146 asset = AssetHelpers.CreateAsset(assetId, SceneHelpers.CreateSceneObject(1, userId));
96 } 147 }
97 else 148 else
98 { 149 {
99 throw new Exception(string.Format("Inventory type {0} not supported", type)); 150 throw new Exception(string.Format("Inventory type {0} not supported", itemType));
100 } 151 }
101 152
102 scene.AssetService.Store(asset); 153 return AddInventoryItem(scene, itemName, itemId, itemType, asset, userId);
103
104 InventoryItemBase item = new InventoryItemBase();
105 item.Name = itemName;
106 item.AssetID = asset.FullID;
107 item.ID = itemId;
108 item.Owner = userId;
109 item.AssetType = asset.Type;
110 item.InvType = (int)type;
111
112 InventoryFolderBase folder = scene.InventoryService.GetFolderForType(userId, AssetType.Notecard);
113
114 item.Folder = folder.ID;
115 scene.AddInventoryItem(item);
116
117 return item;
118 } 154 }
119 155
120 /// <summary> 156 /// <summary>
121 /// Create inventory folders starting from the user's root folder. 157 /// Create inventory folders starting from the user's root folder.
122 /// </summary> 158 /// </summary>
diff --git a/OpenSim/Tools/Compiler/Program.cs b/OpenSim/Tools/Compiler/Program.cs
index 249e18b..6c59c31 100644
--- a/OpenSim/Tools/Compiler/Program.cs
+++ b/OpenSim/Tools/Compiler/Program.cs
@@ -28,6 +28,7 @@
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.IO; 30using System.IO;
31using System.Text;
31using Microsoft.CSharp; 32using Microsoft.CSharp;
32using OpenSim.Region.ScriptEngine.Shared.CodeTools; 33using OpenSim.Region.ScriptEngine.Shared.CodeTools;
33using System.CodeDom.Compiler; 34using System.CodeDom.Compiler;
@@ -201,12 +202,8 @@ namespace OpenSim.Tools.LSL.Compiler
201 // Convert to base64 202 // Convert to base64
202 // 203 //
203 string filetext = System.Convert.ToBase64String(data); 204 string filetext = System.Convert.ToBase64String(data);
204 205 Byte[] buf = Encoding.ASCII.GetBytes(filetext);
205 System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding(); 206 FileStream sfs = File.Create(OutFile + ".text");
206
207 Byte[] buf = enc.GetBytes(filetext);
208
209 FileStream sfs = File.Create(OutFile+".text");
210 sfs.Write(buf, 0, buf.Length); 207 sfs.Write(buf, 0, buf.Length);
211 sfs.Close(); 208 sfs.Close();
212 209
@@ -222,9 +219,9 @@ namespace OpenSim.Tools.LSL.Compiler
222// } 219// }
223// } 220// }
224 221
225 buf = enc.GetBytes(posmap); 222 buf = Encoding.ASCII.GetBytes(posmap);
226 223
227 FileStream mfs = File.Create(OutFile+".map"); 224 FileStream mfs = File.Create(OutFile + ".map");
228 mfs.Write(buf, 0, buf.Length); 225 mfs.Write(buf, 0, buf.Length);
229 mfs.Close(); 226 mfs.Close();
230 227
diff --git a/prebuild.xml b/prebuild.xml
index 2543a1b..cb62aec 100644
--- a/prebuild.xml
+++ b/prebuild.xml
@@ -3025,6 +3025,8 @@
3025 <Reference name="OpenSim.Region.Framework"/> 3025 <Reference name="OpenSim.Region.Framework"/>
3026 <Reference name="OpenSim.Region.CoreModules"/> 3026 <Reference name="OpenSim.Region.CoreModules"/>
3027 <Reference name="OpenSim.Region.Physics.Manager"/> 3027 <Reference name="OpenSim.Region.Physics.Manager"/>
3028 <Reference name="OpenSim.Region.ScriptEngine.Shared"/>
3029 <Reference name="OpenSim.Region.ScriptEngine.XEngine"/>
3028 <Reference name="OpenSim.Services.Interfaces"/> 3030 <Reference name="OpenSim.Services.Interfaces"/>
3029 3031
3030 <!-- Unit tests --> 3032 <!-- Unit tests -->