aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Data/Null/NullRegionData.cs64
-rw-r--r--OpenSim/Framework/Console/ConsoleDisplayTable.cs15
-rw-r--r--OpenSim/Framework/Util.cs11
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs15
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs10
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs42
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs28
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/AssetsArchiver.cs7
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs18
-rw-r--r--OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs3
-rw-r--r--OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs96
-rw-r--r--OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs11
-rw-r--r--OpenSim/Region/CoreModules/World/Sun/SunModule.cs44
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/EventManager.cs13
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs28
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs35
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs79
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/Animations/AnimationsCommandModule.cs215
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/Attachments/AttachmentsCommandModule.cs1
-rw-r--r--OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs14
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs122
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs10
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs29
-rw-r--r--OpenSim/Services/GridService/GridService.cs14
-rw-r--r--OpenSim/Services/GridService/HypergridLinker.cs2
26 files changed, 633 insertions, 295 deletions
diff --git a/OpenSim/Data/Null/NullRegionData.cs b/OpenSim/Data/Null/NullRegionData.cs
index b4d701a..f707d98 100644
--- a/OpenSim/Data/Null/NullRegionData.cs
+++ b/OpenSim/Data/Null/NullRegionData.cs
@@ -113,11 +113,14 @@ namespace OpenSim.Data.Null
113 // Find region data 113 // Find region data
114 List<RegionData> ret = new List<RegionData>(); 114 List<RegionData> ret = new List<RegionData>();
115 115
116 foreach (RegionData r in m_regionData.Values) 116 lock (m_regionData)
117 { 117 {
118// m_log.DebugFormat("[NULL REGION DATA]: comparing {0} to {1}", cleanName, r.RegionName.ToLower()); 118 foreach (RegionData r in m_regionData.Values)
119 {
120 // m_log.DebugFormat("[NULL REGION DATA]: comparing {0} to {1}", cleanName, r.RegionName.ToLower());
119 if (queryMatch(r.RegionName.ToLower())) 121 if (queryMatch(r.RegionName.ToLower()))
120 ret.Add(r); 122 ret.Add(r);
123 }
121 } 124 }
122 125
123 if (ret.Count > 0) 126 if (ret.Count > 0)
@@ -133,10 +136,13 @@ namespace OpenSim.Data.Null
133 136
134 List<RegionData> ret = new List<RegionData>(); 137 List<RegionData> ret = new List<RegionData>();
135 138
136 foreach (RegionData r in m_regionData.Values) 139 lock (m_regionData)
137 { 140 {
138 if (r.posX == posX && r.posY == posY) 141 foreach (RegionData r in m_regionData.Values)
139 ret.Add(r); 142 {
143 if (r.posX == posX && r.posY == posY)
144 ret.Add(r);
145 }
140 } 146 }
141 147
142 if (ret.Count > 0) 148 if (ret.Count > 0)
@@ -150,8 +156,11 @@ namespace OpenSim.Data.Null
150 if (m_useStaticInstance && Instance != this) 156 if (m_useStaticInstance && Instance != this)
151 return Instance.Get(regionID, scopeID); 157 return Instance.Get(regionID, scopeID);
152 158
153 if (m_regionData.ContainsKey(regionID)) 159 lock (m_regionData)
154 return m_regionData[regionID]; 160 {
161 if (m_regionData.ContainsKey(regionID))
162 return m_regionData[regionID];
163 }
155 164
156 return null; 165 return null;
157 } 166 }
@@ -163,10 +172,13 @@ namespace OpenSim.Data.Null
163 172
164 List<RegionData> ret = new List<RegionData>(); 173 List<RegionData> ret = new List<RegionData>();
165 174
166 foreach (RegionData r in m_regionData.Values) 175 lock (m_regionData)
167 { 176 {
168 if (r.posX >= startX && r.posX <= endX && r.posY >= startY && r.posY <= endY) 177 foreach (RegionData r in m_regionData.Values)
169 ret.Add(r); 178 {
179 if (r.posX >= startX && r.posX <= endX && r.posY >= startY && r.posY <= endY)
180 ret.Add(r);
181 }
170 } 182 }
171 183
172 return ret; 184 return ret;
@@ -180,7 +192,10 @@ namespace OpenSim.Data.Null
180// m_log.DebugFormat( 192// m_log.DebugFormat(
181// "[NULL REGION DATA]: Storing region {0} {1}, scope {2}", data.RegionName, data.RegionID, data.ScopeID); 193// "[NULL REGION DATA]: Storing region {0} {1}, scope {2}", data.RegionName, data.RegionID, data.ScopeID);
182 194
183 m_regionData[data.RegionID] = data; 195 lock (m_regionData)
196 {
197 m_regionData[data.RegionID] = data;
198 }
184 199
185 return true; 200 return true;
186 } 201 }
@@ -190,10 +205,13 @@ namespace OpenSim.Data.Null
190 if (m_useStaticInstance && Instance != this) 205 if (m_useStaticInstance && Instance != this)
191 return Instance.SetDataItem(regionID, item, value); 206 return Instance.SetDataItem(regionID, item, value);
192 207
193 if (!m_regionData.ContainsKey(regionID)) 208 lock (m_regionData)
194 return false; 209 {
210 if (!m_regionData.ContainsKey(regionID))
211 return false;
195 212
196 m_regionData[regionID].Data[item] = value; 213 m_regionData[regionID].Data[item] = value;
214 }
197 215
198 return true; 216 return true;
199 } 217 }
@@ -205,10 +223,13 @@ namespace OpenSim.Data.Null
205 223
206// m_log.DebugFormat("[NULL REGION DATA]: Deleting region {0}", regionID); 224// m_log.DebugFormat("[NULL REGION DATA]: Deleting region {0}", regionID);
207 225
208 if (!m_regionData.ContainsKey(regionID)) 226 lock (m_regionData)
209 return false; 227 {
228 if (!m_regionData.ContainsKey(regionID))
229 return false;
210 230
211 m_regionData.Remove(regionID); 231 m_regionData.Remove(regionID);
232 }
212 233
213 return true; 234 return true;
214 } 235 }
@@ -238,10 +259,13 @@ namespace OpenSim.Data.Null
238 259
239 List<RegionData> ret = new List<RegionData>(); 260 List<RegionData> ret = new List<RegionData>();
240 261
241 foreach (RegionData r in m_regionData.Values) 262 lock (m_regionData)
242 { 263 {
243 if ((Convert.ToInt32(r.Data["flags"]) & regionFlags) != 0) 264 foreach (RegionData r in m_regionData.Values)
244 ret.Add(r); 265 {
266 if ((Convert.ToInt32(r.Data["flags"]) & regionFlags) != 0)
267 ret.Add(r);
268 }
245 } 269 }
246 270
247 return ret; 271 return ret;
diff --git a/OpenSim/Framework/Console/ConsoleDisplayTable.cs b/OpenSim/Framework/Console/ConsoleDisplayTable.cs
index c620dfe..711a337 100644
--- a/OpenSim/Framework/Console/ConsoleDisplayTable.cs
+++ b/OpenSim/Framework/Console/ConsoleDisplayTable.cs
@@ -56,7 +56,7 @@ namespace OpenSim.Framework.Console
56 public List<ConsoleDisplayTableRow> Rows { get; private set; } 56 public List<ConsoleDisplayTableRow> Rows { get; private set; }
57 57
58 /// <summary> 58 /// <summary>
59 /// Number of spaces to indent the table. 59 /// Number of spaces to indent the whole table.
60 /// </summary> 60 /// </summary>
61 public int Indent { get; set; } 61 public int Indent { get; set; }
62 62
@@ -84,7 +84,7 @@ namespace OpenSim.Framework.Console
84 Columns.Add(new ConsoleDisplayTableColumn(name, width)); 84 Columns.Add(new ConsoleDisplayTableColumn(name, width));
85 } 85 }
86 86
87 public void AddRow(params string[] cells) 87 public void AddRow(params object[] cells)
88 { 88 {
89 Rows.Add(new ConsoleDisplayTableRow(cells)); 89 Rows.Add(new ConsoleDisplayTableRow(cells));
90 } 90 }
@@ -113,7 +113,8 @@ namespace OpenSim.Framework.Console
113 113
114 for (int i = 0; i < Columns.Count; i++) 114 for (int i = 0; i < Columns.Count; i++)
115 { 115 {
116 formatSb.Append(' ', TableSpacing); 116 if (i != 0)
117 formatSb.Append(' ', TableSpacing);
117 118
118 // Can only do left formatting for now 119 // Can only do left formatting for now
119 formatSb.AppendFormat("{{{0},-{1}}}", i, Columns[i].Width); 120 formatSb.AppendFormat("{{{0},-{1}}}", i, Columns[i].Width);
@@ -139,16 +140,16 @@ namespace OpenSim.Framework.Console
139 140
140 public struct ConsoleDisplayTableRow 141 public struct ConsoleDisplayTableRow
141 { 142 {
142 public List<string> Cells { get; private set; } 143 public List<object> Cells { get; private set; }
143 144
144 public ConsoleDisplayTableRow(List<string> cells) : this() 145 public ConsoleDisplayTableRow(List<object> cells) : this()
145 { 146 {
146 Cells = cells; 147 Cells = cells;
147 } 148 }
148 149
149 public ConsoleDisplayTableRow(params string[] cells) : this() 150 public ConsoleDisplayTableRow(params object[] cells) : this()
150 { 151 {
151 Cells = new List<string>(cells); 152 Cells = new List<object>(cells);
152 } 153 }
153 } 154 }
154} \ No newline at end of file 155} \ No newline at end of file
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs
index e76ac24..c049247 100644
--- a/OpenSim/Framework/Util.cs
+++ b/OpenSim/Framework/Util.cs
@@ -2114,5 +2114,16 @@ namespace OpenSim.Framework
2114 return firstName + "." + lastName + " " + "@" + uri.Authority; 2114 return firstName + "." + lastName + " " + "@" + uri.Authority;
2115 } 2115 }
2116 #endregion 2116 #endregion
2117
2118 /// <summary>
2119 /// Escapes the special characters used in "LIKE".
2120 /// </summary>
2121 /// <remarks>
2122 /// For example: EscapeForLike("foo_bar%baz") = "foo\_bar\%baz"
2123 /// </remarks>
2124 public static string EscapeForLike(string str)
2125 {
2126 return str.Replace("_", "\\_").Replace("%", "\\%");
2127 }
2117 } 2128 }
2118} 2129}
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index acd156e..6323160 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -722,15 +722,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
722 722
723 if (!silent) 723 if (!silent)
724 { 724 {
725 // Killing it here will cause the client to deselect it 725 if (so.HasPrivateAttachmentPoint)
726 // It then reappears on the avatar, deselected
727 // through the full update below
728 //
729 if (so.IsSelected)
730 {
731 m_scene.SendKillObject(new List<uint> { so.RootPart.LocalId });
732 }
733 else if (so.HasPrivateAttachmentPoint)
734 { 726 {
735// m_log.DebugFormat( 727// m_log.DebugFormat(
736// "[ATTACHMENTS MODULE]: Killing private HUD {0} for avatars other than {1} at attachment point {2}", 728// "[ATTACHMENTS MODULE]: Killing private HUD {0} for avatars other than {1} at attachment point {2}",
@@ -745,7 +737,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
745 }); 737 });
746 } 738 }
747 739
748 so.IsSelected = false; // fudge.... 740 // Fudge below is an extremely unhelpful comment. It's probably here so that the scheduled full update
741 // will succeed, as that will not update if an attachment is selected.
742 so.IsSelected = false; // fudge....
743
749 so.ScheduleGroupForFullUpdate(); 744 so.ScheduleGroupForFullUpdate();
750 } 745 }
751 746
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs
index d0e88f6..4c85637 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs
@@ -124,7 +124,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
124 SaveAssets = true; 124 SaveAssets = true;
125 } 125 }
126 126
127 protected void ReceivedAllAssets(ICollection<UUID> assetsFoundUuids, ICollection<UUID> assetsNotFoundUuids) 127 protected void ReceivedAllAssets(ICollection<UUID> assetsFoundUuids, ICollection<UUID> assetsNotFoundUuids, bool timedOut)
128 { 128 {
129 Exception reportedException = null; 129 Exception reportedException = null;
130 bool succeeded = true; 130 bool succeeded = true;
@@ -143,6 +143,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
143 m_saveStream.Close(); 143 m_saveStream.Close();
144 } 144 }
145 145
146 if (timedOut)
147 {
148 succeeded = false;
149 reportedException = new Exception("Loading assets timed out");
150 }
151
146 m_module.TriggerInventoryArchiveSaved( 152 m_module.TriggerInventoryArchiveSaved(
147 m_id, succeeded, m_userInfo, m_invPath, m_saveStream, reportedException); 153 m_id, succeeded, m_userInfo, m_invPath, m_saveStream, reportedException);
148 } 154 }
@@ -350,7 +356,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
350 { 356 {
351 m_log.DebugFormat("[INVENTORY ARCHIVER]: Not saving assets since --noassets was specified"); 357 m_log.DebugFormat("[INVENTORY ARCHIVER]: Not saving assets since --noassets was specified");
352 358
353 ReceivedAllAssets(new List<UUID>(), new List<UUID>()); 359 ReceivedAllAssets(new List<UUID>(), new List<UUID>(), false);
354 } 360 }
355 } 361 }
356 catch (Exception) 362 catch (Exception)
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
index 01f1c63..fcfdf7c 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
@@ -622,13 +622,18 @@ namespace OpenSim.Region.CoreModules.World.Archiver
622 /// <returns></returns> 622 /// <returns></returns>
623 private bool ResolveUserUuid(Scene scene, UUID uuid) 623 private bool ResolveUserUuid(Scene scene, UUID uuid)
624 { 624 {
625 if (!m_validUserUuids.ContainsKey(uuid)) 625 lock (m_validUserUuids)
626 { 626 {
627 UserAccount account = scene.UserAccountService.GetUserAccount(scene.RegionInfo.ScopeID, uuid); 627 if (!m_validUserUuids.ContainsKey(uuid))
628 m_validUserUuids.Add(uuid, account != null); 628 {
629 } 629 // Note: we call GetUserAccount() inside the lock because this UserID is likely
630 // to occur many times, and we only want to query the users service once.
631 UserAccount account = scene.UserAccountService.GetUserAccount(scene.RegionInfo.ScopeID, uuid);
632 m_validUserUuids.Add(uuid, account != null);
633 }
630 634
631 return m_validUserUuids[uuid]; 635 return m_validUserUuids[uuid];
636 }
632 } 637 }
633 638
634 /// <summary> 639 /// <summary>
@@ -641,19 +646,26 @@ namespace OpenSim.Region.CoreModules.World.Archiver
641 if (uuid == UUID.Zero) 646 if (uuid == UUID.Zero)
642 return true; // this means the object has no group 647 return true; // this means the object has no group
643 648
644 if (!m_validGroupUuids.ContainsKey(uuid)) 649 lock (m_validGroupUuids)
645 { 650 {
646 bool exists; 651 if (!m_validGroupUuids.ContainsKey(uuid))
647 652 {
648 if (m_groupsModule == null) 653 bool exists;
649 exists = false; 654 if (m_groupsModule == null)
650 else 655 {
651 exists = (m_groupsModule.GetGroupRecord(uuid) != null); 656 exists = false;
657 }
658 else
659 {
660 // Note: we call GetGroupRecord() inside the lock because this GroupID is likely
661 // to occur many times, and we only want to query the groups service once.
662 exists = (m_groupsModule.GetGroupRecord(uuid) != null);
663 }
664 m_validGroupUuids.Add(uuid, exists);
665 }
652 666
653 m_validGroupUuids.Add(uuid, exists); 667 return m_validGroupUuids[uuid];
654 } 668 }
655
656 return m_validGroupUuids[uuid];
657 } 669 }
658 670
659 /// Load an asset 671 /// Load an asset
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs
index 7bdd65c..367693d 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs
@@ -587,19 +587,29 @@ namespace OpenSim.Region.CoreModules.World.Archiver
587 } 587 }
588 } 588 }
589 589
590 protected void ReceivedAllAssets( 590 protected void ReceivedAllAssets(ICollection<UUID> assetsFoundUuids, ICollection<UUID> assetsNotFoundUuids, bool timedOut)
591 ICollection<UUID> assetsFoundUuids, ICollection<UUID> assetsNotFoundUuids)
592 { 591 {
593 foreach (UUID uuid in assetsNotFoundUuids) 592 string errorMessage;
593
594 if (timedOut)
594 { 595 {
595 m_log.DebugFormat("[ARCHIVER]: Could not find asset {0}", uuid); 596 errorMessage = "Loading assets timed out";
596 } 597 }
598 else
599 {
600 foreach (UUID uuid in assetsNotFoundUuids)
601 {
602 m_log.DebugFormat("[ARCHIVER]: Could not find asset {0}", uuid);
603 }
597 604
598 // m_log.InfoFormat( 605 // m_log.InfoFormat(
599 // "[ARCHIVER]: Received {0} of {1} assets requested", 606 // "[ARCHIVER]: Received {0} of {1} assets requested",
600 // assetsFoundUuids.Count, assetsFoundUuids.Count + assetsNotFoundUuids.Count); 607 // assetsFoundUuids.Count, assetsFoundUuids.Count + assetsNotFoundUuids.Count);
601 608
602 CloseArchive(String.Empty); 609 errorMessage = String.Empty;
610 }
611
612 CloseArchive(errorMessage);
603 } 613 }
604 614
605 /// <summary> 615 /// <summary>
@@ -626,4 +636,4 @@ namespace OpenSim.Region.CoreModules.World.Archiver
626 m_rootScene.EventManager.TriggerOarFileSaved(m_requestId, errorMessage); 636 m_rootScene.EventManager.TriggerOarFileSaved(m_requestId, errorMessage);
627 } 637 }
628 } 638 }
629} \ No newline at end of file 639}
diff --git a/OpenSim/Region/CoreModules/World/Archiver/AssetsArchiver.cs b/OpenSim/Region/CoreModules/World/Archiver/AssetsArchiver.cs
index 95d109c..c1ff94d 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/AssetsArchiver.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/AssetsArchiver.cs
@@ -150,12 +150,5 @@ namespace OpenSim.Region.CoreModules.World.Archiver
150 m_log.InfoFormat("[ARCHIVER]: Added {0} assets to archive", m_assetsWritten); 150 m_log.InfoFormat("[ARCHIVER]: Added {0} assets to archive", m_assetsWritten);
151 } 151 }
152 152
153 /// <summary>
154 /// Only call this if you need to force a close on the underlying writer.
155 /// </summary>
156 public void ForceClose()
157 {
158 m_archiveWriter.Close();
159 }
160 } 153 }
161} 154}
diff --git a/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs
index e2f8833..715bf51 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs
@@ -50,7 +50,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
50 /// Method called when all the necessary assets for an archive request have been received. 50 /// Method called when all the necessary assets for an archive request have been received.
51 /// </summary> 51 /// </summary>
52 public delegate void AssetsRequestCallback( 52 public delegate void AssetsRequestCallback(
53 ICollection<UUID> assetsFoundUuids, ICollection<UUID> assetsNotFoundUuids); 53 ICollection<UUID> assetsFoundUuids, ICollection<UUID> assetsNotFoundUuids, bool timedOut);
54 54
55 enum RequestState 55 enum RequestState
56 { 56 {
@@ -148,7 +148,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
148 if (m_repliesRequired == 0) 148 if (m_repliesRequired == 0)
149 { 149 {
150 m_requestState = RequestState.Completed; 150 m_requestState = RequestState.Completed;
151 PerformAssetsRequestCallback(null); 151 PerformAssetsRequestCallback(false);
152 return; 152 return;
153 } 153 }
154 154
@@ -164,7 +164,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
164 164
165 protected void OnRequestCallbackTimeout(object source, ElapsedEventArgs args) 165 protected void OnRequestCallbackTimeout(object source, ElapsedEventArgs args)
166 { 166 {
167 bool close = true; 167 bool timedOut = true;
168 168
169 try 169 try
170 { 170 {
@@ -174,7 +174,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
174 // the final request came in (assuming that such a thing is possible) 174 // the final request came in (assuming that such a thing is possible)
175 if (m_requestState == RequestState.Completed) 175 if (m_requestState == RequestState.Completed)
176 { 176 {
177 close = false; 177 timedOut = false;
178 return; 178 return;
179 } 179 }
180 180
@@ -223,8 +223,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver
223 } 223 }
224 finally 224 finally
225 { 225 {
226 if (close) 226 if (timedOut)
227 m_assetsArchiver.ForceClose(); 227 Util.FireAndForget(PerformAssetsRequestCallback, true);
228 } 228 }
229 } 229 }
230 230
@@ -290,7 +290,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
290 290
291 // We want to stop using the asset cache thread asap 291 // We want to stop using the asset cache thread asap
292 // as we now need to do the work of producing the rest of the archive 292 // as we now need to do the work of producing the rest of the archive
293 Util.FireAndForget(PerformAssetsRequestCallback); 293 Util.FireAndForget(PerformAssetsRequestCallback, false);
294 } 294 }
295 else 295 else
296 { 296 {
@@ -311,9 +311,11 @@ namespace OpenSim.Region.CoreModules.World.Archiver
311 { 311 {
312 Culture.SetCurrentCulture(); 312 Culture.SetCurrentCulture();
313 313
314 Boolean timedOut = (Boolean)o;
315
314 try 316 try
315 { 317 {
316 m_assetsRequestCallback(m_foundAssetUuids, m_notFoundAssetUuids); 318 m_assetsRequestCallback(m_foundAssetUuids, m_notFoundAssetUuids, timedOut);
317 } 319 }
318 catch (Exception e) 320 catch (Exception e)
319 { 321 {
diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
index 267332d..9aee491 100644
--- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
+++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
@@ -128,7 +128,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
128 { 128 {
129 uint sun = 0; 129 uint sun = 0;
130 130
131 if (!Scene.RegionInfo.EstateSettings.UseGlobalTime) 131 if (Scene.RegionInfo.EstateSettings.FixedSun)
132 sun = (uint)(Scene.RegionInfo.EstateSettings.SunPosition * 1024.0) + 0x1800; 132 sun = (uint)(Scene.RegionInfo.EstateSettings.SunPosition * 1024.0) + 0x1800;
133 UUID estateOwner; 133 UUID estateOwner;
134 estateOwner = Scene.RegionInfo.EstateSettings.EstateOwner; 134 estateOwner = Scene.RegionInfo.EstateSettings.EstateOwner;
@@ -1128,6 +1128,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
1128 { 1128 {
1129 Scene.RegionInfo.EstateSettings.UseGlobalTime = false; 1129 Scene.RegionInfo.EstateSettings.UseGlobalTime = false;
1130 Scene.RegionInfo.EstateSettings.SunPosition = (parms2 - 0x1800)/1024.0; 1130 Scene.RegionInfo.EstateSettings.SunPosition = (parms2 - 0x1800)/1024.0;
1131 // Warning: FixedSun should be set to True, otherwise this sun position won't be used.
1131 } 1132 }
1132 1133
1133 if ((parms1 & 0x00000010) != 0) 1134 if ((parms1 & 0x00000010) != 0)
diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
index 281c143..b4f7d51 100644
--- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
+++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
@@ -141,6 +141,7 @@ namespace OpenSim.Region.CoreModules.World.Land
141 m_scene.EventManager.OnValidateLandBuy += EventManagerOnValidateLandBuy; 141 m_scene.EventManager.OnValidateLandBuy += EventManagerOnValidateLandBuy;
142 m_scene.EventManager.OnLandBuy += EventManagerOnLandBuy; 142 m_scene.EventManager.OnLandBuy += EventManagerOnLandBuy;
143 m_scene.EventManager.OnNewClient += EventManagerOnNewClient; 143 m_scene.EventManager.OnNewClient += EventManagerOnNewClient;
144 m_scene.EventManager.OnMakeChildAgent += EventMakeChildAgent;
144 m_scene.EventManager.OnSignificantClientMovement += EventManagerOnSignificantClientMovement; 145 m_scene.EventManager.OnSignificantClientMovement += EventManagerOnSignificantClientMovement;
145 m_scene.EventManager.OnNoticeNoLandDataFromStorage += EventManagerOnNoLandDataFromStorage; 146 m_scene.EventManager.OnNoticeNoLandDataFromStorage += EventManagerOnNoLandDataFromStorage;
146 m_scene.EventManager.OnIncomingLandDataFromStorage += EventManagerOnIncomingLandDataFromStorage; 147 m_scene.EventManager.OnIncomingLandDataFromStorage += EventManagerOnIncomingLandDataFromStorage;
@@ -221,6 +222,11 @@ namespace OpenSim.Region.CoreModules.World.Land
221 } 222 }
222 } 223 }
223 224
225 public void EventMakeChildAgent(ScenePresence avatar)
226 {
227 avatar.currentParcelUUID = UUID.Zero;
228 }
229
224 void ClientOnPreAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData) 230 void ClientOnPreAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData)
225 { 231 {
226 } 232 }
@@ -249,17 +255,15 @@ namespace OpenSim.Region.CoreModules.World.Land
249 newData.LocalID = local_id; 255 newData.LocalID = local_id;
250 ILandObject landobj = null; 256 ILandObject landobj = null;
251 257
258 ILandObject land;
252 lock (m_landList) 259 lock (m_landList)
253 { 260 {
254 if (m_landList.ContainsKey(local_id)) 261 if (m_landList.TryGetValue(local_id, out land))
255 { 262 land.LandData = newData;
256 m_landList[local_id].LandData = newData;
257 landobj = m_landList[local_id];
258// m_scene.EventManager.TriggerLandObjectUpdated((uint)local_id, m_landList[local_id]);
259 }
260 } 263 }
261 if(landobj != null) 264
262 m_scene.EventManager.TriggerLandObjectUpdated((uint)local_id, landobj); 265 if (land != null)
266 m_scene.EventManager.TriggerLandObjectUpdated((uint)local_id, land);
263 } 267 }
264 268
265 public bool AllowedForcefulBans 269 public bool AllowedForcefulBans
@@ -584,7 +588,7 @@ namespace OpenSim.Region.CoreModules.World.Land
584 // Only now can we add the prim counts to the land object - we rely on the global ID which is generated 588 // Only now can we add the prim counts to the land object - we rely on the global ID which is generated
585 // as a random UUID inside LandData initialization 589 // as a random UUID inside LandData initialization
586 if (m_primCountModule != null) 590 if (m_primCountModule != null)
587 new_land.PrimCounts = m_primCountModule.GetPrimCounts(new_land.LandData.GlobalID); 591 new_land.PrimCounts = m_primCountModule.GetPrimCounts(new_land.LandData.GlobalID);
588 592
589 lock (m_landList) 593 lock (m_landList)
590 { 594 {
@@ -621,6 +625,7 @@ namespace OpenSim.Region.CoreModules.World.Land
621 /// <param name="local_id">Land.localID of the peice of land to remove.</param> 625 /// <param name="local_id">Land.localID of the peice of land to remove.</param>
622 public void removeLandObject(int local_id) 626 public void removeLandObject(int local_id)
623 { 627 {
628 ILandObject land;
624 lock (m_landList) 629 lock (m_landList)
625 { 630 {
626 for (int x = 0; x < 64; x++) 631 for (int x = 0; x < 64; x++)
@@ -637,9 +642,11 @@ namespace OpenSim.Region.CoreModules.World.Land
637 } 642 }
638 } 643 }
639 644
640 m_scene.EventManager.TriggerLandObjectRemoved(m_landList[local_id].LandData.GlobalID); 645 land = m_landList[local_id];
641 m_landList.Remove(local_id); 646 m_landList.Remove(local_id);
642 } 647 }
648
649 m_scene.EventManager.TriggerLandObjectRemoved(land.LandData.GlobalID);
643 } 650 }
644 651
645 /// <summary> 652 /// <summary>
@@ -1399,25 +1406,72 @@ namespace OpenSim.Region.CoreModules.World.Land
1399 1406
1400 public void ReturnObjectsInParcel(int localID, uint returnType, UUID[] agentIDs, UUID[] taskIDs, IClientAPI remoteClient) 1407 public void ReturnObjectsInParcel(int localID, uint returnType, UUID[] agentIDs, UUID[] taskIDs, IClientAPI remoteClient)
1401 { 1408 {
1402 ILandObject selectedParcel = null; 1409 if (localID != -1)
1403 lock (m_landList)
1404 { 1410 {
1405 m_landList.TryGetValue(localID, out selectedParcel); 1411 ILandObject selectedParcel = null;
1412 lock (m_landList)
1413 {
1414 m_landList.TryGetValue(localID, out selectedParcel);
1415 }
1416
1417 if (selectedParcel == null)
1418 return;
1419
1420 selectedParcel.ReturnLandObjects(returnType, agentIDs, taskIDs, remoteClient);
1406 } 1421 }
1422 else
1423 {
1424 if (returnType != 1)
1425 {
1426 m_log.WarnFormat("[LAND MANAGEMENT MODULE]: ReturnObjectsInParcel: unknown return type {0}", returnType);
1427 return;
1428 }
1407 1429
1408 if (selectedParcel == null) return; 1430 // We get here when the user returns objects from the list of Top Colliders or Top Scripts.
1431 // In that case we receive specific object UUID's, but no parcel ID.
1409 1432
1410 selectedParcel.ReturnLandObjects(returnType, agentIDs, taskIDs, remoteClient); 1433 Dictionary<UUID, HashSet<SceneObjectGroup>> returns = new Dictionary<UUID, HashSet<SceneObjectGroup>>();
1434
1435 foreach (UUID groupID in taskIDs)
1436 {
1437 SceneObjectGroup obj = m_scene.GetSceneObjectGroup(groupID);
1438 if (obj != null)
1439 {
1440 if (!returns.ContainsKey(obj.OwnerID))
1441 returns[obj.OwnerID] = new HashSet<SceneObjectGroup>();
1442 returns[obj.OwnerID].Add(obj);
1443 }
1444 else
1445 {
1446 m_log.WarnFormat("[LAND MANAGEMENT MODULE]: ReturnObjectsInParcel: unknown object {0}", groupID);
1447 }
1448 }
1449
1450 int num = 0;
1451 foreach (HashSet<SceneObjectGroup> objs in returns.Values)
1452 num += objs.Count;
1453 m_log.DebugFormat("[LAND MANAGEMENT MODULE]: Returning {0} specific object(s)", num);
1454
1455 foreach (HashSet<SceneObjectGroup> objs in returns.Values)
1456 {
1457 List<SceneObjectGroup> objs2 = new List<SceneObjectGroup>(objs);
1458 if (m_scene.Permissions.CanReturnObjects(null, remoteClient.AgentId, objs2))
1459 {
1460 m_scene.returnObjects(objs2.ToArray(), remoteClient.AgentId);
1461 }
1462 else
1463 {
1464 m_log.WarnFormat("[LAND MANAGEMENT MODULE]: ReturnObjectsInParcel: not permitted to return {0} object(s) belonging to user {1}",
1465 objs2.Count, objs2[0].OwnerID);
1466 }
1467 }
1468 }
1411 } 1469 }
1412 1470
1413 public void EventManagerOnNoLandDataFromStorage() 1471 public void EventManagerOnNoLandDataFromStorage()
1414 { 1472 {
1415 // called methods already have locks 1473 ResetSimLandObjects();
1416// lock (m_landList) 1474 CreateDefaultParcel();
1417 {
1418 ResetSimLandObjects();
1419 CreateDefaultParcel();
1420 }
1421 } 1475 }
1422 1476
1423 #endregion 1477 #endregion
diff --git a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs
index 55b8227..771fdd2 100644
--- a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs
+++ b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs
@@ -490,11 +490,14 @@ namespace OpenSim.Region.CoreModules.World.Land
490 490
491 m_Scene.ForEachSOG(AddObject); 491 m_Scene.ForEachSOG(AddObject);
492 492
493 List<UUID> primcountKeys = new List<UUID>(m_PrimCounts.Keys); 493 lock (m_PrimCounts)
494 foreach (UUID k in primcountKeys)
495 { 494 {
496 if (!m_OwnerMap.ContainsKey(k)) 495 List<UUID> primcountKeys = new List<UUID>(m_PrimCounts.Keys);
497 m_PrimCounts.Remove(k); 496 foreach (UUID k in primcountKeys)
497 {
498 if (!m_OwnerMap.ContainsKey(k))
499 m_PrimCounts.Remove(k);
500 }
498 } 501 }
499 502
500 m_Tainted = false; 503 m_Tainted = false;
diff --git a/OpenSim/Region/CoreModules/World/Sun/SunModule.cs b/OpenSim/Region/CoreModules/World/Sun/SunModule.cs
index a321c09..6f344c8 100644
--- a/OpenSim/Region/CoreModules/World/Sun/SunModule.cs
+++ b/OpenSim/Region/CoreModules/World/Sun/SunModule.cs
@@ -252,12 +252,11 @@ namespace OpenSim.Region.CoreModules
252 } 252 }
253 253
254 // TODO: Decouple this, so we can get rid of Linden Hour info 254 // TODO: Decouple this, so we can get rid of Linden Hour info
255 // Update Region infor with new Sun Position and Hour 255 // Update Region with new Sun Vector
256 // set estate settings for region access to sun position 256 // set estate settings for region access to sun position
257 if (receivedEstateToolsSunUpdate) 257 if (receivedEstateToolsSunUpdate)
258 { 258 {
259 m_scene.RegionInfo.RegionSettings.SunVector = Position; 259 m_scene.RegionInfo.RegionSettings.SunVector = Position;
260 m_scene.RegionInfo.RegionSettings.SunPosition = GetCurrentTimeAsLindenSunHour();
261 } 260 }
262 } 261 }
263 262
@@ -395,7 +394,7 @@ namespace OpenSim.Region.CoreModules
395 ready = false; 394 ready = false;
396 395
397 // Remove our hooks 396 // Remove our hooks
398 m_scene.EventManager.OnFrame -= SunUpdate; 397 m_scene.EventManager.OnFrame -= SunUpdate;
399 m_scene.EventManager.OnAvatarEnteringNewParcel -= AvatarEnteringParcel; 398 m_scene.EventManager.OnAvatarEnteringNewParcel -= AvatarEnteringParcel;
400 m_scene.EventManager.OnEstateToolsSunUpdate -= EstateToolsSunUpdate; 399 m_scene.EventManager.OnEstateToolsSunUpdate -= EstateToolsSunUpdate;
401 m_scene.EventManager.OnGetCurrentTimeAsLindenSunHour -= GetCurrentTimeAsLindenSunHour; 400 m_scene.EventManager.OnGetCurrentTimeAsLindenSunHour -= GetCurrentTimeAsLindenSunHour;
@@ -459,26 +458,33 @@ namespace OpenSim.Region.CoreModules
459 SunToClient(avatar.ControllingClient); 458 SunToClient(avatar.ControllingClient);
460 } 459 }
461 460
462 /// <summary> 461 public void EstateToolsSunUpdate(ulong regionHandle)
463 ///
464 /// </summary>
465 /// <param name="regionHandle"></param>
466 /// <param name="FixedTime">Is the sun's position fixed?</param>
467 /// <param name="useEstateTime">Use the Region or Estate Sun hour?</param>
468 /// <param name="FixedSunHour">What hour of the day is the Sun Fixed at?</param>
469 public void EstateToolsSunUpdate(ulong regionHandle, bool FixedSun, bool useEstateTime, float FixedSunHour)
470 { 462 {
471 if (m_scene.RegionInfo.RegionHandle == regionHandle) 463 if (m_scene.RegionInfo.RegionHandle == regionHandle)
472 { 464 {
473 // Must limit the Sun Hour to 0 ... 24 465 float sunFixedHour;
474 while (FixedSunHour > 24.0f) 466 bool fixedSun;
475 FixedSunHour -= 24;
476 467
477 while (FixedSunHour < 0) 468 if (m_scene.RegionInfo.RegionSettings.UseEstateSun)
478 FixedSunHour += 24; 469 {
470 sunFixedHour = (float)m_scene.RegionInfo.EstateSettings.SunPosition;
471 fixedSun = m_scene.RegionInfo.EstateSettings.FixedSun;
472 }
473 else
474 {
475 sunFixedHour = (float)m_scene.RegionInfo.RegionSettings.SunPosition - 6.0f;
476 fixedSun = m_scene.RegionInfo.RegionSettings.FixedSun;
477 }
478
479 // Must limit the Sun Hour to 0 ... 24
480 while (sunFixedHour > 24.0f)
481 sunFixedHour -= 24;
479 482
480 m_SunFixedHour = FixedSunHour; 483 while (sunFixedHour < 0)
481 m_SunFixed = FixedSun; 484 sunFixedHour += 24;
485
486 m_SunFixedHour = sunFixedHour;
487 m_SunFixed = fixedSun;
482 488
483 // m_log.DebugFormat("[SUN]: Sun Settings Update: Fixed Sun? : {0}", m_SunFixed.ToString()); 489 // m_log.DebugFormat("[SUN]: Sun Settings Update: Fixed Sun? : {0}", m_SunFixed.ToString());
484 // m_log.DebugFormat("[SUN]: Sun Settings Update: Sun Hour : {0}", m_SunFixedHour.ToString()); 490 // m_log.DebugFormat("[SUN]: Sun Settings Update: Sun Hour : {0}", m_SunFixedHour.ToString());
@@ -501,7 +507,7 @@ namespace OpenSim.Region.CoreModules
501 { 507 {
502 m_scene.ForEachRootClient(delegate(IClientAPI client) 508 m_scene.ForEachRootClient(delegate(IClientAPI client)
503 { 509 {
504 SunToClient(client); 510 SunToClient(client);
505 }); 511 });
506 } 512 }
507 513
diff --git a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
index 33aabe4..4d738a5 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
@@ -480,7 +480,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain
480 else 480 else
481 { 481 {
482 m_plugineffects[pluginName] = effect; 482 m_plugineffects[pluginName] = effect;
483 m_log.Warn("E ... " + pluginName + " (Replaced)"); 483 m_log.Info("E ... " + pluginName + " (Replaced)");
484 } 484 }
485 } 485 }
486 } 486 }
diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs
index 5b1c9f4..ac5f433 100644
--- a/OpenSim/Region/Framework/Scenes/EventManager.cs
+++ b/OpenSim/Region/Framework/Scenes/EventManager.cs
@@ -755,7 +755,7 @@ namespace OpenSim.Region.Framework.Scenes
755 public event ScriptTimerEvent OnScriptTimerEvent; 755 public event ScriptTimerEvent OnScriptTimerEvent;
756 */ 756 */
757 757
758 public delegate void EstateToolsSunUpdate(ulong regionHandle, bool FixedTime, bool EstateSun, float LindenHour); 758 public delegate void EstateToolsSunUpdate(ulong regionHandle);
759 public delegate void GetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID); 759 public delegate void GetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID);
760 760
761 public event EstateToolsSunUpdate OnEstateToolsSunUpdate; 761 public event EstateToolsSunUpdate OnEstateToolsSunUpdate;
@@ -2536,13 +2536,10 @@ namespace OpenSim.Region.Framework.Scenes
2536 } 2536 }
2537 2537
2538 /// <summary> 2538 /// <summary>
2539 /// Updates the system as to how the position of the sun should be handled. 2539 /// Called when the sun's position parameters have changed in the Region and/or Estate
2540 /// </summary> 2540 /// </summary>
2541 /// <param name="regionHandle"></param> 2541 /// <param name="regionHandle">The region that changed</param>
2542 /// <param name="FixedTime">True if the Sun Position is fixed</param> 2542 public void TriggerEstateToolsSunUpdate(ulong regionHandle)
2543 /// <param name="useEstateTime">True if the Estate Settings should be used instead of region</param>
2544 /// <param name="FixedSunHour">The hour 0.0 <= FixedSunHour <= 24.0 at which the sun is fixed at. Sun Hour 0 is sun-rise, when Day/Night ratio is 1:1</param>
2545 public void TriggerEstateToolsSunUpdate(ulong regionHandle, bool FixedTime, bool useEstateTime, float FixedSunHour)
2546 { 2543 {
2547 EstateToolsSunUpdate handlerEstateToolsSunUpdate = OnEstateToolsSunUpdate; 2544 EstateToolsSunUpdate handlerEstateToolsSunUpdate = OnEstateToolsSunUpdate;
2548 if (handlerEstateToolsSunUpdate != null) 2545 if (handlerEstateToolsSunUpdate != null)
@@ -2551,7 +2548,7 @@ namespace OpenSim.Region.Framework.Scenes
2551 { 2548 {
2552 try 2549 try
2553 { 2550 {
2554 d(regionHandle, FixedTime, useEstateTime, FixedSunHour); 2551 d(regionHandle);
2555 } 2552 }
2556 catch (Exception e) 2553 catch (Exception e)
2557 { 2554 {
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 2a1949d..54e3b2d 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -5619,33 +5619,7 @@ Environment.Exit(1);
5619 5619
5620 public void TriggerEstateSunUpdate() 5620 public void TriggerEstateSunUpdate()
5621 { 5621 {
5622 float sun; 5622 EventManager.TriggerEstateToolsSunUpdate(RegionInfo.RegionHandle);
5623 if (RegionInfo.RegionSettings.UseEstateSun)
5624 {
5625 sun = (float)RegionInfo.EstateSettings.SunPosition;
5626 if (RegionInfo.EstateSettings.UseGlobalTime)
5627 {
5628 sun = EventManager.GetCurrentTimeAsSunLindenHour() - 6.0f;
5629 }
5630
5631 //
5632 EventManager.TriggerEstateToolsSunUpdate(
5633 RegionInfo.RegionHandle,
5634 RegionInfo.EstateSettings.FixedSun,
5635 RegionInfo.RegionSettings.UseEstateSun,
5636 sun);
5637 }
5638 else
5639 {
5640 // Use the Sun Position from the Region Settings
5641 sun = (float)RegionInfo.RegionSettings.SunPosition - 6.0f;
5642
5643 EventManager.TriggerEstateToolsSunUpdate(
5644 RegionInfo.RegionHandle,
5645 RegionInfo.RegionSettings.FixedSun,
5646 RegionInfo.RegionSettings.UseEstateSun,
5647 sun);
5648 }
5649 } 5623 }
5650 5624
5651 private void HandleReloadEstate(string module, string[] cmd) 5625 private void HandleReloadEstate(string module, string[] cmd)
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 1fc8d3d..7490ac8 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -945,6 +945,18 @@ namespace OpenSim.Region.Framework.Scenes
945 /// </remarks> 945 /// </remarks>
946 public UUID FromFolderID { get; set; } 946 public UUID FromFolderID { get; set; }
947 947
948 /// <summary>
949 /// IDs of all avatars sat on this scene object.
950 /// </summary>
951 /// <remarks>
952 /// We need this so that we can maintain a linkset wide ordering of avatars sat on different parts.
953 /// This must be locked before it is read or written.
954 /// SceneObjectPart sitting avatar add/remove code also locks on this object to avoid race conditions.
955 /// No avatar should appear more than once in this list.
956 /// Do not manipulate this list directly - use the Add/Remove sitting avatar methods on SceneObjectPart.
957 /// </remarks>
958 protected internal List<UUID> m_sittingAvatars = new List<UUID>();
959
948 #endregion 960 #endregion
949 961
950// ~SceneObjectGroup() 962// ~SceneObjectGroup()
@@ -4523,17 +4535,28 @@ namespace OpenSim.Region.Framework.Scenes
4523 } 4535 }
4524 4536
4525 /// <summary> 4537 /// <summary>
4538 /// Get a copy of the list of sitting avatars on all prims of this object.
4539 /// </summary>
4540 /// <remarks>
4541 /// This is sorted by the order in which avatars sat down. If an avatar stands up then all avatars that sat
4542 /// down after it move one place down the list.
4543 /// </remarks>
4544 /// <returns>A list of the sitting avatars. Returns an empty list if there are no sitting avatars.</returns>
4545 public List<UUID> GetSittingAvatars()
4546 {
4547 lock (m_sittingAvatars)
4548 return new List<UUID>(m_sittingAvatars);
4549 }
4550
4551 /// <summary>
4526 /// Gets the number of sitting avatars. 4552 /// Gets the number of sitting avatars.
4527 /// </summary> 4553 /// </summary>
4528 /// <remarks>This applies to all sitting avatars whether there is a sit target set or not.</remarks> 4554 /// <remarks>This applies to all sitting avatars whether there is a sit target set or not.</remarks>
4529 /// <returns></returns> 4555 /// <returns></returns>
4530 public int GetSittingAvatarsCount() 4556 public int GetSittingAvatarsCount()
4531 { 4557 {
4532 int count = 0; 4558 lock (m_sittingAvatars)
4533 4559 return m_sittingAvatars.Count;
4534 Array.ForEach<SceneObjectPart>(m_parts.GetArray(), p => count += p.GetSittingAvatarsCount());
4535
4536 return count;
4537 } 4560 }
4538 4561
4539 public override string ToString() 4562 public override string ToString()
@@ -4542,7 +4565,7 @@ namespace OpenSim.Region.Framework.Scenes
4542 } 4565 }
4543 4566
4544 #region ISceneObject 4567 #region ISceneObject
4545 4568
4546 public virtual ISceneObject CloneForNewScene() 4569 public virtual ISceneObject CloneForNewScene()
4547 { 4570 {
4548 SceneObjectGroup sog = Copy(false); 4571 SceneObjectGroup sog = Copy(false);
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 143a339..e68793a 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -1342,7 +1342,7 @@ namespace OpenSim.Region.Framework.Scenes
1342 public UUID SitTargetAvatar { get; set; } 1342 public UUID SitTargetAvatar { get; set; }
1343 1343
1344 /// <summary> 1344 /// <summary>
1345 /// IDs of all avatars start on this object part. 1345 /// IDs of all avatars sat on this part.
1346 /// </summary> 1346 /// </summary>
1347 /// <remarks> 1347 /// <remarks>
1348 /// We need to track this so that we can stop sat upon prims from being attached. 1348 /// We need to track this so that we can stop sat upon prims from being attached.
@@ -5196,18 +5196,22 @@ namespace OpenSim.Region.Framework.Scenes
5196 /// <param name='avatarId'></param> 5196 /// <param name='avatarId'></param>
5197 protected internal bool AddSittingAvatar(UUID avatarId) 5197 protected internal bool AddSittingAvatar(UUID avatarId)
5198 { 5198 {
5199 if (IsSitTargetSet && SitTargetAvatar == UUID.Zero) 5199 lock (ParentGroup.m_sittingAvatars)
5200 SitTargetAvatar = avatarId; 5200 {
5201 if (IsSitTargetSet && SitTargetAvatar == UUID.Zero)
5202 SitTargetAvatar = avatarId;
5201 5203
5202 HashSet<UUID> sittingAvatars = m_sittingAvatars; 5204 if (m_sittingAvatars == null)
5205 m_sittingAvatars = new HashSet<UUID>();
5203 5206
5204 if (sittingAvatars == null) 5207 if (m_sittingAvatars.Add(avatarId))
5205 sittingAvatars = new HashSet<UUID>(); 5208 {
5209 ParentGroup.m_sittingAvatars.Add(avatarId);
5206 5210
5207 lock (sittingAvatars) 5211 return true;
5208 { 5212 }
5209 m_sittingAvatars = sittingAvatars; 5213
5210 return m_sittingAvatars.Add(avatarId); 5214 return false;
5211 } 5215 }
5212 } 5216 }
5213 5217
@@ -5221,27 +5225,26 @@ namespace OpenSim.Region.Framework.Scenes
5221 /// <param name='avatarId'></param> 5225 /// <param name='avatarId'></param>
5222 protected internal bool RemoveSittingAvatar(UUID avatarId) 5226 protected internal bool RemoveSittingAvatar(UUID avatarId)
5223 { 5227 {
5224 if (SitTargetAvatar == avatarId) 5228 lock (ParentGroup.m_sittingAvatars)
5225 SitTargetAvatar = UUID.Zero; 5229 {
5226 5230 if (SitTargetAvatar == avatarId)
5227 HashSet<UUID> sittingAvatars = m_sittingAvatars; 5231 SitTargetAvatar = UUID.Zero;
5228 5232
5229 // This can occur under a race condition where another thread 5233 if (m_sittingAvatars == null)
5230 if (sittingAvatars == null) 5234 return false;
5231 return false;
5232 5235
5233 lock (sittingAvatars) 5236 if (m_sittingAvatars.Remove(avatarId))
5234 {
5235 if (sittingAvatars.Remove(avatarId))
5236 { 5237 {
5237 if (sittingAvatars.Count == 0) 5238 if (m_sittingAvatars.Count == 0)
5238 m_sittingAvatars = null; 5239 m_sittingAvatars = null;
5239 5240
5241 ParentGroup.m_sittingAvatars.Remove(avatarId);
5242
5240 return true; 5243 return true;
5241 } 5244 }
5242 }
5243 5245
5244 return false; 5246 return false;
5247 }
5245 } 5248 }
5246 5249
5247 /// <summary> 5250 /// <summary>
@@ -5251,16 +5254,12 @@ namespace OpenSim.Region.Framework.Scenes
5251 /// <returns>A hashset of the sitting avatars. Returns null if there are no sitting avatars.</returns> 5254 /// <returns>A hashset of the sitting avatars. Returns null if there are no sitting avatars.</returns>
5252 public HashSet<UUID> GetSittingAvatars() 5255 public HashSet<UUID> GetSittingAvatars()
5253 { 5256 {
5254 HashSet<UUID> sittingAvatars = m_sittingAvatars; 5257 lock (ParentGroup.m_sittingAvatars)
5255
5256 if (sittingAvatars == null)
5257 { 5258 {
5258 return null; 5259 if (m_sittingAvatars == null)
5259 } 5260 return null;
5260 else 5261 else
5261 { 5262 return new HashSet<UUID>(m_sittingAvatars);
5262 lock (sittingAvatars)
5263 return new HashSet<UUID>(sittingAvatars);
5264 } 5263 }
5265 } 5264 }
5266 5265
@@ -5271,13 +5270,13 @@ namespace OpenSim.Region.Framework.Scenes
5271 /// <returns></returns> 5270 /// <returns></returns>
5272 public int GetSittingAvatarsCount() 5271 public int GetSittingAvatarsCount()
5273 { 5272 {
5274 HashSet<UUID> sittingAvatars = m_sittingAvatars; 5273 lock (ParentGroup.m_sittingAvatars)
5275 5274 {
5276 if (sittingAvatars == null) 5275 if (m_sittingAvatars == null)
5277 return 0; 5276 return 0;
5278 5277 else
5279 lock (sittingAvatars) 5278 return m_sittingAvatars.Count;
5280 return sittingAvatars.Count; 5279 }
5281 } 5280 }
5282 } 5281 }
5283} 5282} \ No newline at end of file
diff --git a/OpenSim/Region/OptionalModules/Avatar/Animations/AnimationsCommandModule.cs b/OpenSim/Region/OptionalModules/Avatar/Animations/AnimationsCommandModule.cs
new file mode 100644
index 0000000..e951d9e
--- /dev/null
+++ b/OpenSim/Region/OptionalModules/Avatar/Animations/AnimationsCommandModule.cs
@@ -0,0 +1,215 @@
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 System.Linq;
31using System.Reflection;
32using System.Text;
33using log4net;
34using Mono.Addins;
35using Nini.Config;
36using OpenMetaverse;
37using OpenSim.Framework;
38using OpenSim.Framework.Console;
39using OpenSim.Framework.Monitoring;
40using OpenSim.Region.ClientStack.LindenUDP;
41using OpenSim.Region.Framework.Interfaces;
42using OpenSim.Region.Framework.Scenes;
43using OpenSim.Region.Framework.Scenes.Animation;
44using OpenSim.Services.Interfaces;
45
46namespace OpenSim.Region.OptionalModules.Avatar.Animations
47{
48 /// <summary>
49 /// A module that just holds commands for inspecting avatar animations.
50 /// </summary>
51 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "AnimationsCommandModule")]
52 public class AnimationsCommandModule : ISharedRegionModule
53 {
54// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
55
56 private List<Scene> m_scenes = new List<Scene>();
57
58 public string Name { get { return "Animations Command Module"; } }
59
60 public Type ReplaceableInterface { get { return null; } }
61
62 public void Initialise(IConfigSource source)
63 {
64// m_log.DebugFormat("[ANIMATIONS COMMAND MODULE]: INITIALIZED MODULE");
65 }
66
67 public void PostInitialise()
68 {
69// m_log.DebugFormat("[ANIMATIONS COMMAND MODULE]: POST INITIALIZED MODULE");
70 }
71
72 public void Close()
73 {
74// m_log.DebugFormat("[ANIMATIONS COMMAND MODULE]: CLOSED MODULE");
75 }
76
77 public void AddRegion(Scene scene)
78 {
79// m_log.DebugFormat("[ANIMATIONS COMMAND MODULE]: REGION {0} ADDED", scene.RegionInfo.RegionName);
80 }
81
82 public void RemoveRegion(Scene scene)
83 {
84// m_log.DebugFormat("[ATTACHMENTS COMMAND MODULE]: REGION {0} REMOVED", scene.RegionInfo.RegionName);
85
86 lock (m_scenes)
87 m_scenes.Remove(scene);
88 }
89
90 public void RegionLoaded(Scene scene)
91 {
92// m_log.DebugFormat("[ANIMATIONS COMMAND MODULE]: REGION {0} LOADED", scene.RegionInfo.RegionName);
93
94 lock (m_scenes)
95 m_scenes.Add(scene);
96
97 scene.AddCommand(
98 "Users", this, "show animations",
99 "show animations [<first-name> <last-name>]",
100 "Show animation information for avatars in this simulator.",
101 "If no name is supplied then information for all avatars is shown.\n"
102 + "Please note that for inventory animations, the animation name is the name under which the animation was originally uploaded\n"
103 + ", which is not necessarily the current inventory name.",
104 HandleShowAnimationsCommand);
105 }
106
107 protected void HandleShowAnimationsCommand(string module, string[] cmd)
108 {
109 if (cmd.Length != 2 && cmd.Length < 4)
110 {
111 MainConsole.Instance.OutputFormat("Usage: show animations [<first-name> <last-name>]");
112 return;
113 }
114
115 bool targetNameSupplied = false;
116 string optionalTargetFirstName = null;
117 string optionalTargetLastName = null;
118
119 if (cmd.Length >= 4)
120 {
121 targetNameSupplied = true;
122 optionalTargetFirstName = cmd[2];
123 optionalTargetLastName = cmd[3];
124 }
125
126 StringBuilder sb = new StringBuilder();
127
128 lock (m_scenes)
129 {
130 foreach (Scene scene in m_scenes)
131 {
132 if (targetNameSupplied)
133 {
134 ScenePresence sp = scene.GetScenePresence(optionalTargetFirstName, optionalTargetLastName);
135 if (sp != null && !sp.IsChildAgent)
136 GetAttachmentsReport(sp, sb);
137 }
138 else
139 {
140 scene.ForEachRootScenePresence(sp => GetAttachmentsReport(sp, sb));
141 }
142 }
143 }
144
145 MainConsole.Instance.Output(sb.ToString());
146 }
147
148 private void GetAttachmentsReport(ScenePresence sp, StringBuilder sb)
149 {
150 sb.AppendFormat("Animations for {0}\n", sp.Name);
151
152 ConsoleDisplayList cdl = new ConsoleDisplayList() { Indent = 2 };
153 ScenePresenceAnimator spa = sp.Animator;
154 AnimationSet anims = sp.Animator.Animations;
155
156 string cma = spa.CurrentMovementAnimation;
157 cdl.AddRow(
158 "Current movement anim",
159 string.Format("{0}, {1}", DefaultAvatarAnimations.GetDefaultAnimation(cma), cma));
160
161 UUID defaultAnimId = anims.DefaultAnimation.AnimID;
162 cdl.AddRow(
163 "Default anim",
164 string.Format("{0}, {1}", defaultAnimId, GetAnimName(sp.Scene.AssetService, defaultAnimId)));
165
166 UUID implicitDefaultAnimId = anims.ImplicitDefaultAnimation.AnimID;
167 cdl.AddRow(
168 "Implicit default anim",
169 string.Format("{0}, {1}", implicitDefaultAnimId, GetAnimName(sp.Scene.AssetService, implicitDefaultAnimId)));
170
171 cdl.AddToStringBuilder(sb);
172
173 ConsoleDisplayTable cdt = new ConsoleDisplayTable() { Indent = 2 };
174 cdt.AddColumn("Animation ID", 36);
175 cdt.AddColumn("Name", 20);
176 cdt.AddColumn("Seq", 3);
177 cdt.AddColumn("Object ID", 36);
178
179 UUID[] animIds;
180 int[] sequenceNumbers;
181 UUID[] objectIds;
182
183 sp.Animator.Animations.GetArrays(out animIds, out sequenceNumbers, out objectIds);
184
185 for (int i = 0; i < animIds.Length; i++)
186 {
187 UUID animId = animIds[i];
188 string animName = GetAnimName(sp.Scene.AssetService, animId);
189 int seq = sequenceNumbers[i];
190 UUID objectId = objectIds[i];
191
192 cdt.AddRow(animId, animName, seq, objectId);
193 }
194
195 cdt.AddToStringBuilder(sb);
196 sb.Append("\n");
197 }
198
199 private string GetAnimName(IAssetService assetService, UUID animId)
200 {
201 string animName;
202
203 if (!DefaultAvatarAnimations.AnimsNames.TryGetValue(animId, out animName))
204 {
205 AssetMetadata amd = assetService.GetMetadata(animId.ToString());
206 if (amd != null)
207 animName = amd.Name;
208 else
209 animName = "Unknown";
210 }
211
212 return animName;
213 }
214 }
215} \ No newline at end of file
diff --git a/OpenSim/Region/OptionalModules/Avatar/Attachments/AttachmentsCommandModule.cs b/OpenSim/Region/OptionalModules/Avatar/Attachments/AttachmentsCommandModule.cs
index 68bcb4a..d97e3b3 100644
--- a/OpenSim/Region/OptionalModules/Avatar/Attachments/AttachmentsCommandModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/Attachments/AttachmentsCommandModule.cs
@@ -97,6 +97,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Attachments
97 "Users", this, "attachments show", 97 "Users", this, "attachments show",
98 "attachments show [<first-name> <last-name>]", 98 "attachments show [<first-name> <last-name>]",
99 "Show attachment information for avatars in this simulator.", 99 "Show attachment information for avatars in this simulator.",
100 "If no name is supplied then information for all avatars is shown.",
100 HandleShowAttachmentsCommand); 101 HandleShowAttachmentsCommand);
101 } 102 }
102 103
diff --git a/OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs b/OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs
index c7e3a7a..57d9217 100644
--- a/OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs
+++ b/OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs
@@ -49,7 +49,7 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule
49 /// (such as land transfers). There is no money code here! Use FORGE as an example for money code. 49 /// (such as land transfers). There is no money code here! Use FORGE as an example for money code.
50 /// Demo Economy/Money Module. This is a purposely crippled module! 50 /// Demo Economy/Money Module. This is a purposely crippled module!
51 /// // To land transfer you need to add: 51 /// // To land transfer you need to add:
52 /// -helperuri <ADDRESS TO THIS SERVER> 52 /// -helperuri http://serveraddress:port/
53 /// to the command line parameters you use to start up your client 53 /// to the command line parameters you use to start up your client
54 /// This commonly looks like -helperuri http://127.0.0.1:9000/ 54 /// This commonly looks like -helperuri http://127.0.0.1:9000/
55 /// 55 ///
@@ -116,10 +116,9 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule
116 } 116 }
117 117
118 /// <summary> 118 /// <summary>
119 /// Startup 119 /// Called on startup so the module can be configured.
120 /// </summary> 120 /// </summary>
121 /// <param name="scene"></param> 121 /// <param name="config">Configuration source.</param>
122 /// <param name="config"></param>
123 public void Initialise(IConfigSource config) 122 public void Initialise(IConfigSource config)
124 { 123 {
125 m_gConfig = config; 124 m_gConfig = config;
@@ -674,9 +673,12 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule
674 } 673 }
675 674
676 /// <summary> 675 /// <summary>
677 /// When the client closes the connection we remove their accounting info from memory to free up resources. 676 /// When the client closes the connection we remove their accounting
677 /// info from memory to free up resources.
678 /// </summary> 678 /// </summary>
679 /// <param name="AgentID"></param> 679 /// <param name="AgentID">UUID of agent</param>
680 /// <param name="scene">Scene the agent was connected to.</param>
681 /// <see cref="OpenSim.Region.Framework.Scenes.EventManager.ClientClosed"/>
680 public void ClientClosed(UUID AgentID, Scene scene) 682 public void ClientClosed(UUID AgentID, Scene scene)
681 { 683 {
682 684
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 253d193..aa389ba 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -3298,7 +3298,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3298 /// <summary> 3298 /// <summary>
3299 /// Attach the object containing this script to the avatar that owns it. 3299 /// Attach the object containing this script to the avatar that owns it.
3300 /// </summary> 3300 /// </summary>
3301 /// <param name='attachment'>The attachment point (e.g. ATTACH_CHEST)</param> 3301 /// <param name='attachmentPoint'>
3302 /// The attachment point (e.g. <see cref="OpenSim.Region.ScriptEngine.Shared.ScriptBase.ScriptBaseClass.ATTACH_CHEST">ATTACH_CHEST</see>)
3303 /// </param>
3302 /// <returns>true if the attach suceeded, false if it did not</returns> 3304 /// <returns>true if the attach suceeded, false if it did not</returns>
3303 public bool AttachToAvatar(int attachmentPoint) 3305 public bool AttachToAvatar(int attachmentPoint)
3304 { 3306 {
@@ -3729,21 +3731,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3729 } 3731 }
3730 else 3732 else
3731 { 3733 {
3732 bool sitting = false; 3734 if (m_host.ParentGroup.GetSittingAvatars().Contains(agentID))
3733 if (m_host.SitTargetAvatar == agentID)
3734 {
3735 sitting = true;
3736 }
3737 else
3738 {
3739 foreach (SceneObjectPart p in m_host.ParentGroup.Parts)
3740 {
3741 if (p.SitTargetAvatar == agentID)
3742 sitting = true;
3743 }
3744 }
3745
3746 if (sitting)
3747 { 3735 {
3748 // When agent is sitting, certain permissions are implicit if requested from sitting agent 3736 // When agent is sitting, certain permissions are implicit if requested from sitting agent
3749 implicitPerms = ScriptBaseClass.PERMISSION_TRIGGER_ANIMATION | 3737 implicitPerms = ScriptBaseClass.PERMISSION_TRIGGER_ANIMATION |
@@ -3785,7 +3773,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3785 INPCModule npcModule = World.RequestModuleInterface<INPCModule>(); 3773 INPCModule npcModule = World.RequestModuleInterface<INPCModule>();
3786 if (npcModule != null && npcModule.IsNPC(agentID, World)) 3774 if (npcModule != null && npcModule.IsNPC(agentID, World))
3787 { 3775 {
3788 if (agentID == m_host.ParentGroup.OwnerID || npcModule.GetOwner(agentID) == m_host.ParentGroup.OwnerID) 3776 if (npcModule.CheckPermissions(agentID, m_host.OwnerID))
3789 { 3777 {
3790 lock (m_host.TaskInventory) 3778 lock (m_host.TaskInventory)
3791 { 3779 {
@@ -4160,62 +4148,56 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4160 public LSL_String llGetLinkName(int linknum) 4148 public LSL_String llGetLinkName(int linknum)
4161 { 4149 {
4162 m_host.AddScriptLPS(1); 4150 m_host.AddScriptLPS(1);
4163 // simplest case, this prims link number
4164 if (linknum == m_host.LinkNum || linknum == ScriptBaseClass.LINK_THIS)
4165 return m_host.Name;
4166 4151
4167 // parse for sitting avatare-names 4152 if (linknum < 0)
4168 List<String> nametable = new List<String>();
4169 World.ForEachRootScenePresence(delegate(ScenePresence presence)
4170 { 4153 {
4171 SceneObjectPart sitPart = presence.ParentPart; 4154 if (linknum == ScriptBaseClass.LINK_THIS)
4172 if (sitPart != null && m_host.ParentGroup.ContainsPart(sitPart.LocalId))
4173 nametable.Add(presence.ControllingClient.Name);
4174 });
4175
4176 int totalprims = m_host.ParentGroup.PrimCount + nametable.Count;
4177 if (totalprims > m_host.ParentGroup.PrimCount)
4178 {
4179 // sitting Avatar-Name with negativ linknum / SinglePrim
4180 if (linknum < 0 && m_host.ParentGroup.PrimCount == 1 && nametable.Count == 1)
4181 return nametable[0];
4182 // Prim-Name / SinglePrim Sitting Avatar
4183 if (linknum == 1 && m_host.ParentGroup.PrimCount == 1 && nametable.Count == 1)
4184 return m_host.Name; 4155 return m_host.Name;
4185 // LinkNumber > of Real PrimSet = AvatarName 4156 else
4186 if (linknum > m_host.ParentGroup.PrimCount && linknum <= totalprims) 4157 return ScriptBaseClass.NULL_KEY;
4187 return nametable[totalprims - linknum];
4188 } 4158 }
4189 4159
4190 // Single prim 4160 int actualPrimCount = m_host.ParentGroup.PrimCount;
4191 if (m_host.LinkNum == 0) 4161 List<UUID> sittingAvatarIds = m_host.ParentGroup.GetSittingAvatars();
4162 int adjustedPrimCount = actualPrimCount + sittingAvatarIds.Count;
4163
4164 // Special case for a single prim. In this case the linknum is zero. However, this will not match a single
4165 // prim that has any avatars sat upon it (in which case the root prim is link 1).
4166 if (linknum == 0)
4192 { 4167 {
4193 if (linknum == 0 || linknum == ScriptBaseClass.LINK_ROOT) 4168 if (actualPrimCount == 1 && sittingAvatarIds.Count == 0)
4194 return m_host.Name; 4169 return m_host.Name;
4195 else
4196 return UUID.Zero.ToString();
4197 }
4198 4170
4199 // Link set 4171 return ScriptBaseClass.NULL_KEY;
4200 SceneObjectPart part = null; 4172 }
4201 if (m_host.LinkNum == 1) // this is the Root prim 4173 // Special case to handle a single prim with sitting avatars. GetLinkPart() would only match zero but
4174 // here we must match 1 (ScriptBaseClass.LINK_ROOT).
4175 else if (linknum == 1 && actualPrimCount == 1)
4202 { 4176 {
4203 if (linknum < 0) 4177 if (sittingAvatarIds.Count > 0)
4204 part = m_host.ParentGroup.GetLinkNumPart(2); 4178 return m_host.ParentGroup.RootPart.Name;
4205 else 4179 else
4206 part = m_host.ParentGroup.GetLinkNumPart(linknum); 4180 return ScriptBaseClass.NULL_KEY;
4207 } 4181 }
4208 else // this is a child prim 4182 else if (linknum <= adjustedPrimCount)
4209 { 4183 {
4210 if (linknum < 2) 4184 if (linknum <= actualPrimCount)
4211 part = m_host.ParentGroup.GetLinkNumPart(1); 4185 {
4186 return m_host.ParentGroup.GetLinkNumPart(linknum).Name;
4187 }
4212 else 4188 else
4213 part = m_host.ParentGroup.GetLinkNumPart(linknum); 4189 {
4190 ScenePresence sp = World.GetScenePresence(sittingAvatarIds[linknum - actualPrimCount - 1]);
4191 if (sp != null)
4192 return sp.Name;
4193 else
4194 return ScriptBaseClass.NULL_KEY;
4195 }
4214 } 4196 }
4215 if (part != null)
4216 return part.Name;
4217 else 4197 else
4218 return UUID.Zero.ToString(); 4198 {
4199 return ScriptBaseClass.NULL_KEY;
4200 }
4219 } 4201 }
4220 4202
4221 public LSL_Integer llGetInventoryNumber(int type) 4203 public LSL_Integer llGetInventoryNumber(int type)
@@ -5828,9 +5810,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
5828 } 5810 }
5829 5811
5830 /// <summary> 5812 /// <summary>
5831 /// Insert the list identified by <src> into the 5813 /// Insert the list identified by <paramref name="src"/> into the
5832 /// list designated by <dest> such that the first 5814 /// list designated by <paramref name="dest"/> such that the first
5833 /// new element has the index specified by <index> 5815 /// new element has the index specified by <paramref name="index"/>
5834 /// </summary> 5816 /// </summary>
5835 5817
5836 public LSL_List llListInsertList(LSL_List dest, LSL_List src, int index) 5818 public LSL_List llListInsertList(LSL_List dest, LSL_List src, int index)
@@ -6663,6 +6645,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6663 ps.BurstSpeedMax = 1.0f; 6645 ps.BurstSpeedMax = 1.0f;
6664 ps.BurstRate = 0.1f; 6646 ps.BurstRate = 0.1f;
6665 ps.PartMaxAge = 10.0f; 6647 ps.PartMaxAge = 10.0f;
6648 ps.BurstPartCount = 1;
6666 return ps; 6649 return ps;
6667 } 6650 }
6668 6651
@@ -6684,10 +6667,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6684 SetParticleSystem(m_host, rules); 6667 SetParticleSystem(m_host, rules);
6685 } 6668 }
6686 6669
6687 private void SetParticleSystem(SceneObjectPart part, LSL_List rules) 6670 private void SetParticleSystem(SceneObjectPart part, LSL_List rules)
6688 { 6671 {
6689
6690
6691 if (rules.Length == 0) 6672 if (rules.Length == 0)
6692 { 6673 {
6693 part.RemoveParticleSystem(); 6674 part.RemoveParticleSystem();
@@ -13232,7 +13213,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
13232 /// Get a notecard line. 13213 /// Get a notecard line.
13233 /// </summary> 13214 /// </summary>
13234 /// <param name="assetID"></param> 13215 /// <param name="assetID"></param>
13235 /// <param name="line">Lines start at index 0</param> 13216 /// <param name="lineNumber">Lines start at index 0</param>
13236 /// <returns></returns> 13217 /// <returns></returns>
13237 public static string GetLine(UUID assetID, int lineNumber) 13218 public static string GetLine(UUID assetID, int lineNumber)
13238 { 13219 {
@@ -13261,9 +13242,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
13261 /// Get a notecard line. 13242 /// Get a notecard line.
13262 /// </summary> 13243 /// </summary>
13263 /// <param name="assetID"></param> 13244 /// <param name="assetID"></param>
13264 /// <param name="line">Lines start at index 0</param> 13245 /// <param name="lineNumber">Lines start at index 0</param>
13265 /// <param name="maxLength">Maximum length of the returned line. Longer lines will be truncated</para> 13246 /// <param name="maxLength">
13266 /// <returns></returns> 13247 /// Maximum length of the returned line.
13248 /// </param>
13249 /// <returns>
13250 /// If the line length is longer than <paramref name="maxLength"/>,
13251 /// the return string will be truncated.
13252 /// </returns>
13267 public static string GetLine(UUID assetID, int lineNumber, int maxLength) 13253 public static string GetLine(UUID assetID, int lineNumber, int maxLength)
13268 { 13254 {
13269 string line = GetLine(assetID, lineNumber); 13255 string line = GetLine(assetID, lineNumber);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 51c8c7e..637d83a 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -1214,12 +1214,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1214 sunHour += 24.0; 1214 sunHour += 24.0;
1215 1215
1216 World.RegionInfo.RegionSettings.UseEstateSun = useEstateSun; 1216 World.RegionInfo.RegionSettings.UseEstateSun = useEstateSun;
1217 World.RegionInfo.RegionSettings.SunPosition = sunHour + 6; // LL Region Sun Hour is 6 to 30 1217 World.RegionInfo.RegionSettings.SunPosition = sunHour + 6; // LL Region Sun Hour is 6 to 30
1218 World.RegionInfo.RegionSettings.FixedSun = sunFixed; 1218 World.RegionInfo.RegionSettings.FixedSun = sunFixed;
1219 World.RegionInfo.RegionSettings.Save(); 1219 World.RegionInfo.RegionSettings.Save();
1220 1220
1221 World.EventManager.TriggerEstateToolsSunUpdate( 1221 World.EventManager.TriggerEstateToolsSunUpdate(World.RegionInfo.RegionHandle);
1222 World.RegionInfo.RegionHandle, sunFixed, useEstateSun, (float)sunHour);
1223 } 1222 }
1224 1223
1225 /// <summary> 1224 /// <summary>
@@ -1244,8 +1243,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1244 World.RegionInfo.EstateSettings.FixedSun = sunFixed; 1243 World.RegionInfo.EstateSettings.FixedSun = sunFixed;
1245 World.RegionInfo.EstateSettings.Save(); 1244 World.RegionInfo.EstateSettings.Save();
1246 1245
1247 World.EventManager.TriggerEstateToolsSunUpdate( 1246 World.EventManager.TriggerEstateToolsSunUpdate(World.RegionInfo.RegionHandle);
1248 World.RegionInfo.RegionHandle, sunFixed, World.RegionInfo.RegionSettings.UseEstateSun, (float)sunHour);
1249 } 1247 }
1250 1248
1251 /// <summary> 1249 /// <summary>
diff --git a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
index c9c4753..2e61fb8 100644
--- a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
@@ -633,19 +633,44 @@ namespace OpenSim.Region.ScriptEngine.Shared
633 633
634 public LSL_Types.Vector3 GetVector3Item(int itemIndex) 634 public LSL_Types.Vector3 GetVector3Item(int itemIndex)
635 { 635 {
636 if(m_data[itemIndex] is LSL_Types.Vector3) 636 if (m_data[itemIndex] is LSL_Types.Vector3)
637 {
637 return (LSL_Types.Vector3)m_data[itemIndex]; 638 return (LSL_Types.Vector3)m_data[itemIndex];
639 }
640 else if(m_data[itemIndex] is OpenMetaverse.Vector3)
641 {
642 return new LSL_Types.Vector3(
643 (OpenMetaverse.Vector3)m_data[itemIndex]);
644 }
638 else 645 else
646 {
639 throw new InvalidCastException(string.Format( 647 throw new InvalidCastException(string.Format(
640 "{0} expected but {1} given", 648 "{0} expected but {1} given",
641 typeof(LSL_Types.Vector3).Name, 649 typeof(LSL_Types.Vector3).Name,
642 m_data[itemIndex] != null ? 650 m_data[itemIndex] != null ?
643 m_data[itemIndex].GetType().Name : "null")); 651 m_data[itemIndex].GetType().Name : "null"));
652 }
644 } 653 }
645 654
646 public LSL_Types.Quaternion GetQuaternionItem(int itemIndex) 655 public LSL_Types.Quaternion GetQuaternionItem(int itemIndex)
647 { 656 {
648 return (LSL_Types.Quaternion)m_data[itemIndex]; 657 if (m_data[itemIndex] is LSL_Types.Quaternion)
658 {
659 return (LSL_Types.Quaternion)m_data[itemIndex];
660 }
661 else if(m_data[itemIndex] is OpenMetaverse.Quaternion)
662 {
663 return new LSL_Types.Quaternion(
664 (OpenMetaverse.Quaternion)m_data[itemIndex]);
665 }
666 else
667 {
668 throw new InvalidCastException(string.Format(
669 "{0} expected but {1} given",
670 typeof(LSL_Types.Quaternion).Name,
671 m_data[itemIndex] != null ?
672 m_data[itemIndex].GetType().Name : "null"));
673 }
649 } 674 }
650 675
651 public LSL_Types.key GetKeyItem(int itemIndex) 676 public LSL_Types.key GetKeyItem(int itemIndex)
diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs
index ee3b858..daebf8b 100644
--- a/OpenSim/Services/GridService/GridService.cs
+++ b/OpenSim/Services/GridService/GridService.cs
@@ -185,15 +185,15 @@ namespace OpenSim.Services.GridService
185 185
186 if (!m_AllowDuplicateNames) 186 if (!m_AllowDuplicateNames)
187 { 187 {
188 List<RegionData> dupe = m_Database.Get(regionInfos.RegionName, scopeID); 188 List<RegionData> dupe = m_Database.Get(Util.EscapeForLike(regionInfos.RegionName), scopeID);
189 if (dupe != null && dupe.Count > 0) 189 if (dupe != null && dupe.Count > 0)
190 { 190 {
191 foreach (RegionData d in dupe) 191 foreach (RegionData d in dupe)
192 { 192 {
193 if (d.RegionID != regionInfos.RegionID) 193 if (d.RegionID != regionInfos.RegionID)
194 { 194 {
195 m_log.WarnFormat("[GRID SERVICE]: Region {0} tried to register duplicate name with ID {1}.", 195 m_log.WarnFormat("[GRID SERVICE]: Region tried to register using a duplicate name. New region: {0} ({1}), existing region: {2} ({3}).",
196 regionInfos.RegionName, regionInfos.RegionID); 196 regionInfos.RegionName, regionInfos.RegionID, d.RegionName, d.RegionID);
197 return "Duplicate region name"; 197 return "Duplicate region name";
198 } 198 }
199 } 199 }
@@ -359,7 +359,7 @@ namespace OpenSim.Services.GridService
359 359
360 public GridRegion GetRegionByName(UUID scopeID, string name) 360 public GridRegion GetRegionByName(UUID scopeID, string name)
361 { 361 {
362 List<RegionData> rdatas = m_Database.Get(name, scopeID); 362 List<RegionData> rdatas = m_Database.Get(Util.EscapeForLike(name), scopeID);
363 if ((rdatas != null) && (rdatas.Count > 0)) 363 if ((rdatas != null) && (rdatas.Count > 0))
364 return RegionData2RegionInfo(rdatas[0]); // get the first 364 return RegionData2RegionInfo(rdatas[0]); // get the first
365 365
@@ -377,7 +377,7 @@ namespace OpenSim.Services.GridService
377 { 377 {
378// m_log.DebugFormat("[GRID SERVICE]: GetRegionsByName {0}", name); 378// m_log.DebugFormat("[GRID SERVICE]: GetRegionsByName {0}", name);
379 379
380 List<RegionData> rdatas = m_Database.Get(name + "%", scopeID); 380 List<RegionData> rdatas = m_Database.Get(Util.EscapeForLike(name) + "%", scopeID);
381 381
382 int count = 0; 382 int count = 0;
383 List<GridRegion> rinfos = new List<GridRegion>(); 383 List<GridRegion> rinfos = new List<GridRegion>();
@@ -586,7 +586,7 @@ namespace OpenSim.Services.GridService
586 586
587 string regionName = cmd[3]; 587 string regionName = cmd[3];
588 588
589 List<RegionData> regions = m_Database.Get(regionName, UUID.Zero); 589 List<RegionData> regions = m_Database.Get(Util.EscapeForLike(regionName), UUID.Zero);
590 if (regions == null || regions.Count < 1) 590 if (regions == null || regions.Count < 1)
591 { 591 {
592 MainConsole.Instance.Output("No region with name {0} found", regionName); 592 MainConsole.Instance.Output("No region with name {0} found", regionName);
@@ -716,7 +716,7 @@ namespace OpenSim.Services.GridService
716 return; 716 return;
717 } 717 }
718 718
719 List<RegionData> regions = m_Database.Get(cmd[3], UUID.Zero); 719 List<RegionData> regions = m_Database.Get(Util.EscapeForLike(cmd[3]), UUID.Zero);
720 if (regions == null || regions.Count < 1) 720 if (regions == null || regions.Count < 1)
721 { 721 {
722 MainConsole.Instance.Output("Region not found"); 722 MainConsole.Instance.Output("Region not found");
diff --git a/OpenSim/Services/GridService/HypergridLinker.cs b/OpenSim/Services/GridService/HypergridLinker.cs
index 743d089..073197f 100644
--- a/OpenSim/Services/GridService/HypergridLinker.cs
+++ b/OpenSim/Services/GridService/HypergridLinker.cs
@@ -387,7 +387,7 @@ namespace OpenSim.Services.GridService
387 m_log.DebugFormat("[HYPERGRID LINKER]: Request to unlink {0}", mapName); 387 m_log.DebugFormat("[HYPERGRID LINKER]: Request to unlink {0}", mapName);
388 GridRegion regInfo = null; 388 GridRegion regInfo = null;
389 389
390 List<RegionData> regions = m_Database.Get(mapName, m_ScopeID); 390 List<RegionData> regions = m_Database.Get(Util.EscapeForLike(mapName), m_ScopeID);
391 if (regions != null && regions.Count > 0) 391 if (regions != null && regions.Count > 0)
392 { 392 {
393 OpenSim.Framework.RegionFlags rflags = (OpenSim.Framework.RegionFlags)Convert.ToInt32(regions[0].Data["flags"]); 393 OpenSim.Framework.RegionFlags rflags = (OpenSim.Framework.RegionFlags)Convert.ToInt32(regions[0].Data["flags"]);