Compare commits
272 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fbff51f387 | ||
|
|
b714fb0c39 | ||
|
|
f37038013d | ||
|
|
5e98e2b7c7 | ||
|
|
35f8f3ff79 | ||
|
|
7ec8e7e025 | ||
|
|
c6efebdd8c | ||
|
|
760047abc5 | ||
|
|
374ebab574 | ||
|
|
fb91ca6f1d | ||
|
|
2724cf685e | ||
|
|
8730dc9d6a | ||
|
|
d5cd60131f | ||
|
|
e7ad6ed3a3 | ||
|
|
ea36d4a4cf | ||
|
|
0e3b08fa5b | ||
|
|
205f2326dc | ||
|
|
5914270ff1 | ||
|
|
faffe2f2f9 | ||
|
|
8327e048b9 | ||
|
|
789e88d8bd | ||
|
|
5181bdae0a | ||
|
|
513b77b78d | ||
|
|
08ec18f8a3 | ||
|
|
cd9fd77e2c | ||
|
|
0588f27d18 | ||
|
|
72075e68c7 | ||
|
|
8b04e8a297 | ||
|
|
293d0cc629 | ||
|
|
0cd698d82b | ||
|
|
eeef9d7e99 | ||
|
|
0dfccfc1d9 | ||
|
|
68406ab8f9 | ||
|
|
86b005de1d | ||
|
|
cd2c5843a8 | ||
|
|
e36bc0d754 | ||
|
|
cf16ca9bda | ||
|
|
5f500c89ce | ||
|
|
69a5beeabc | ||
|
|
794363421d | ||
|
|
c51ef38e2d | ||
|
|
e38d26a2dc | ||
|
|
04d8c6b4fe | ||
|
|
7609daca38 | ||
|
|
d89faa3c16 | ||
|
|
a76a289d11 | ||
|
|
f9a8915cca | ||
|
|
50dbb9ffe4 | ||
|
|
6b1d12edcb | ||
|
|
b899d64dc1 | ||
|
|
3f6dfa92ab | ||
|
|
72d29bdb40 | ||
|
|
7e89b99e6a | ||
|
|
adbdb220df | ||
|
|
b23ab3ea85 | ||
|
|
d4f476c7ce | ||
|
|
134c6d181f | ||
|
|
f3c5ce1bbd | ||
|
|
0d9afad3fe | ||
|
|
cd44c3b90a | ||
|
|
1133f81dce | ||
|
|
811dc95105 | ||
|
|
6ee17f5b36 | ||
|
|
f4bae34283 | ||
|
|
faf250df2d | ||
|
|
5f741143fd | ||
|
|
21b1fec32d | ||
|
|
ce812c88cc | ||
|
|
7d30637d51 | ||
|
|
d4a667a918 | ||
|
|
9e914f5c32 | ||
|
|
0aaf52fca4 | ||
|
|
66824dd18c | ||
|
|
c1503205c0 | ||
|
|
c6d02801db | ||
|
|
9ca1075e7e | ||
|
|
0a4c080e63 | ||
|
|
d7add2940a | ||
|
|
75f7721b0c | ||
|
|
bf6529db32 | ||
|
|
2d05e16f7e | ||
|
|
5707e171f4 | ||
|
|
5aec0ff207 | ||
|
|
35efa88c26 | ||
|
|
227126adb7 | ||
|
|
22aa436648 | ||
|
|
a1e99642c1 | ||
|
|
31304c222d | ||
|
|
3cf8edfd68 | ||
|
|
1427430b7b | ||
|
|
ef8570f789 | ||
|
|
c846a5461c | ||
|
|
c992629576 | ||
|
|
bc13c52c98 | ||
|
|
2858b1b1f4 | ||
|
|
892dd59b13 | ||
|
|
bf6547be01 | ||
|
|
dda681515b | ||
|
|
8a574395c7 | ||
|
|
85c6eb7c50 | ||
|
|
73f9e14b43 | ||
|
|
e126915bc1 | ||
|
|
fc77bca936 | ||
|
|
55c1c10c0d | ||
|
|
7d16d0664e | ||
|
|
ac612e2105 | ||
|
|
1b1418e1de | ||
|
|
b537bbc410 | ||
|
|
b25d874afa | ||
|
|
ef14232e64 | ||
|
|
13929613b1 | ||
|
|
ca3b6b1f90 | ||
|
|
24dfb5bcb3 | ||
|
|
7451bb1613 | ||
|
|
cda67a68de | ||
|
|
e9c437ed0e | ||
|
|
c400918c84 | ||
|
|
f9913b6ef7 | ||
|
|
ecf7bb268c | ||
|
|
bcfc392edf | ||
|
|
a4281ca014 | ||
|
|
644fb6b013 | ||
|
|
fe99948c58 | ||
|
|
be39f03caa | ||
|
|
d1d331a4c0 | ||
|
|
c4533e755b | ||
|
|
e94831ddab | ||
|
|
ccc7e75ce4 | ||
|
|
ba80f137b5 | ||
|
|
e9a121e1b2 | ||
|
|
c0ab406e2e | ||
|
|
6dda7c65ae | ||
|
|
64db0bcbd2 | ||
|
|
528004d349 | ||
|
|
1971b6bb4f | ||
|
|
d97e27434c | ||
|
|
58b72933c8 | ||
|
|
4973fddc51 | ||
|
|
6460e587c4 | ||
|
|
742ad5eb93 | ||
|
|
dd85d7d981 | ||
|
|
0dd14ca0a3 | ||
|
|
cd6d7429f8 | ||
|
|
eb590becf0 | ||
|
|
b9749d5aaf | ||
|
|
48a5f10be1 | ||
|
|
56870d9609 | ||
|
|
ecb759c1e5 | ||
|
|
59a29f5f22 | ||
|
|
c489bc1cd2 | ||
|
|
356d597296 | ||
|
|
b0facd147a | ||
|
|
b6476eaac3 | ||
|
|
2a85372169 | ||
|
|
1c3b0da74a | ||
|
|
c1667d39a6 | ||
|
|
217f47b0d5 | ||
|
|
ed14dac0a3 | ||
|
|
ee7478fa16 | ||
|
|
5d3723a47f | ||
|
|
84b7ae2573 | ||
|
|
423101b425 | ||
|
|
e3453dd9ca | ||
|
|
b6cd3b625e | ||
|
|
8d59385eea | ||
|
|
ec6a195e40 | ||
|
|
2954ceccae | ||
|
|
884d603cac | ||
|
|
9ccb578721 | ||
|
|
d6f54b25cd | ||
|
|
dda999a22c | ||
|
|
3b3d9967b1 | ||
|
|
75ab9b4b88 | ||
|
|
15283d35f1 | ||
|
|
6a0de355e0 | ||
|
|
65a25ee510 | ||
|
|
ca412032e8 | ||
|
|
743437262e | ||
|
|
916e3bf886 | ||
|
|
9c89ad9154 | ||
|
|
33cff9b9d7 | ||
|
|
0e611c47d3 | ||
|
|
fc24563206 | ||
|
|
14d05dc2a9 | ||
|
|
337ea019bd | ||
|
|
cdea572d2e | ||
|
|
11e0ad6dc8 | ||
|
|
c8f0d476d2 | ||
|
|
69a6f6e3cd | ||
|
|
e8347b7095 | ||
|
|
506437b684 | ||
|
|
9f01c3d408 | ||
|
|
58869e5aa0 | ||
|
|
f3134b5cf6 | ||
|
|
eb5ec4a786 | ||
|
|
c8af20f966 | ||
|
|
d6f563794e | ||
|
|
2eaa6d5ace | ||
|
|
1a2ab7bc69 | ||
|
|
a96ac73302 | ||
|
|
57094bd017 | ||
|
|
112cddc9ca | ||
|
|
16d5b79d57 | ||
|
|
1201307c73 | ||
|
|
a85741ac37 | ||
|
|
3bd134474b | ||
|
|
b19ead5f9e | ||
|
|
7ff4eec79c | ||
|
|
7aff238eee | ||
|
|
af9d8de515 | ||
|
|
f1f390cfdf | ||
|
|
74014a3854 | ||
|
|
e4a6611865 | ||
|
|
056c9a59b2 | ||
|
|
ae1f2114f5 | ||
|
|
1b1f841c6a | ||
|
|
43a2da9edb | ||
|
|
f6e5791ecd | ||
|
|
843112340e | ||
|
|
7e73f609e5 | ||
|
|
db9616f7ba | ||
|
|
8674604ff5 | ||
|
|
462f7bccf9 | ||
|
|
510e809aba | ||
|
|
951b45b80f | ||
|
|
7b327848d0 | ||
|
|
2f998fce1f | ||
|
|
1816ecb747 | ||
|
|
eacba4fc0b | ||
|
|
9fac7fd932 | ||
|
|
f2b0377c28 | ||
|
|
d933bdbd59 | ||
|
|
f9fa34408d | ||
|
|
857494f6bd | ||
|
|
dff7cae2ee | ||
|
|
0e3fce9b5c | ||
|
|
4b2b14dad1 | ||
|
|
3769739ca7 | ||
|
|
3717812ce0 | ||
|
|
ae64d089c6 | ||
|
|
58b13d51a7 | ||
|
|
5691a8b860 | ||
|
|
f7b4802577 | ||
|
|
8183c2926d | ||
|
|
3c9b9a848f | ||
|
|
3399596e0e | ||
|
|
d32cf21576 | ||
|
|
1926de5a05 | ||
|
|
a4551b027b | ||
|
|
56c776066c | ||
|
|
0229e90dcc | ||
|
|
e420f815dc | ||
|
|
1a7be7b00e | ||
|
|
0f6b7b6a41 | ||
|
|
f202c36106 | ||
|
|
bfa6896678 | ||
|
|
571fd966cb | ||
|
|
f263d6a910 | ||
|
|
972b0b52f9 | ||
|
|
25baa2d894 | ||
|
|
f9769a9fcb | ||
|
|
bb48060b44 | ||
|
|
d043213317 | ||
|
|
5bec5bcf71 | ||
|
|
87ca820f9b | ||
|
|
0b29877790 | ||
|
|
97437feb06 | ||
|
|
2524517986 | ||
|
|
99954c1498 | ||
|
|
2b82c421ad | ||
|
|
4329cc7b8a | ||
|
|
32a4ce94f0 |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -41,6 +41,8 @@ bin/Physics*
|
||||
bin/Terrain*
|
||||
bin/Regions/*
|
||||
bin/UserAssets
|
||||
bin/assetcache
|
||||
bin/maptiles
|
||||
bin/estate_settings.xml
|
||||
bin/config-include/CenomeCache.ini
|
||||
bin/config-include/FlotsamCache.ini
|
||||
|
||||
@@ -91,6 +91,7 @@ what it is today.
|
||||
* Fly-Man
|
||||
* Flyte Xevious
|
||||
* Garmin Kawaguichi
|
||||
* Gryc Ueusp
|
||||
* Imaze Rhiano
|
||||
* Intimidated
|
||||
* Jeremy Bongio (IBM)
|
||||
|
||||
@@ -301,7 +301,8 @@ namespace OpenSim.Capabilities.Handlers
|
||||
InventoryItemBase linkedItem
|
||||
= m_InventoryService.GetItem(new InventoryItemBase(link.AssetID));
|
||||
|
||||
itemsToReturn.Insert(0, linkedItem);
|
||||
if (linkedItem != null)
|
||||
itemsToReturn.Insert(0, linkedItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,9 +66,7 @@ namespace OpenSim.Framework.Capabilities
|
||||
|
||||
TResponse response = m_method(llsdRequest);
|
||||
|
||||
Encoding encoding = new UTF8Encoding(false);
|
||||
|
||||
return encoding.GetBytes(LLSDHelpers.SerialiseLLSDReply(response));
|
||||
return Util.UTF8NoBomEncoding.GetBytes(LLSDHelpers.SerialiseLLSDReply(response));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace OpenSim.ConsoleClient
|
||||
|
||||
request.ContentType = "application/x-www-form-urlencoded";
|
||||
|
||||
byte[] buffer = new System.Text.ASCIIEncoding().GetBytes(data);
|
||||
byte[] buffer = Encoding.ASCII.GetBytes(data);
|
||||
int length = (int) buffer.Length;
|
||||
request.ContentLength = length;
|
||||
|
||||
|
||||
@@ -1069,8 +1069,6 @@ namespace OpenSim.Data.Tests
|
||||
regionInfo.RegionLocX = 0;
|
||||
regionInfo.RegionLocY = 0;
|
||||
|
||||
Scene scene = new Scene(regionInfo);
|
||||
|
||||
SceneObjectPart sop = new SceneObjectPart();
|
||||
sop.Name = name;
|
||||
sop.Description = name;
|
||||
@@ -1081,7 +1079,7 @@ namespace OpenSim.Data.Tests
|
||||
sop.Shape = PrimitiveBaseShape.Default;
|
||||
|
||||
SceneObjectGroup sog = new SceneObjectGroup(sop);
|
||||
sog.SetScene(scene);
|
||||
// sog.SetScene(scene);
|
||||
|
||||
return sog;
|
||||
}
|
||||
|
||||
@@ -98,6 +98,11 @@ namespace OpenSim.Framework
|
||||
/// </summary>
|
||||
public string lastname;
|
||||
|
||||
/// <summary>
|
||||
/// Agent's full name.
|
||||
/// </summary>
|
||||
public string Name { get { return string.Format("{0} {1}", firstname, lastname); } }
|
||||
|
||||
/// <summary>
|
||||
/// Random Unique GUID for this session. Client gets this at login and it's
|
||||
/// only supposed to be disclosed over secure channels
|
||||
|
||||
@@ -1353,7 +1353,6 @@ namespace OpenSim.Framework
|
||||
void SendBlueBoxMessage(UUID FromAvatarID, String FromAvatarName, String Message);
|
||||
|
||||
void SendLogoutPacket();
|
||||
EndPoint GetClientEP();
|
||||
|
||||
// WARNING WARNING WARNING
|
||||
//
|
||||
|
||||
@@ -56,11 +56,29 @@ namespace OpenSim.Framework
|
||||
|
||||
public interface IScene
|
||||
{
|
||||
/// <summary>
|
||||
/// The name of this scene.
|
||||
/// </summary>
|
||||
string Name { get; }
|
||||
|
||||
RegionInfo RegionInfo { get; }
|
||||
RegionStatus RegionStatus { get; set; }
|
||||
|
||||
IConfigSource Config { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Are logins enabled on this simulator?
|
||||
/// </summary>
|
||||
bool LoginsEnabled { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Is this region ready for use?
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This does not mean that logins are enabled, merely that they can be.
|
||||
/// </remarks>
|
||||
bool Ready { get; set; }
|
||||
|
||||
float TimeDilation { get; }
|
||||
|
||||
bool AllowScriptCrossings { get; }
|
||||
|
||||
@@ -99,8 +99,13 @@ namespace OpenSim.Framework
|
||||
}
|
||||
else
|
||||
{
|
||||
item = oldHeadNext.Item;
|
||||
item = oldHeadNext.Item;
|
||||
haveAdvancedHead = CAS(ref head, oldHead, oldHeadNext);
|
||||
if (haveAdvancedHead)
|
||||
{
|
||||
oldHeadNext.Item = default(T);
|
||||
oldHead.Next = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -111,6 +116,10 @@ namespace OpenSim.Framework
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
// ugly
|
||||
T item;
|
||||
while(count > 0)
|
||||
Dequeue(out item);
|
||||
Init();
|
||||
}
|
||||
|
||||
|
||||
@@ -63,12 +63,15 @@ namespace OpenSim.Framework
|
||||
|
||||
internal void Clear()
|
||||
{
|
||||
this.value = default(T);
|
||||
if (this.handle != null)
|
||||
{
|
||||
this.handle.Clear();
|
||||
this.handle = null;
|
||||
}
|
||||
ClearRef();
|
||||
}
|
||||
|
||||
internal void ClearRef()
|
||||
{
|
||||
this.value = default(T);
|
||||
this.handle = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -285,6 +288,7 @@ namespace OpenSim.Framework
|
||||
if (--this.size > 0 && index != this.size)
|
||||
{
|
||||
Set(this.items[this.size], index);
|
||||
this.items[this.size].ClearRef();
|
||||
if (!BubbleUp(index))
|
||||
BubbleDown(index);
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
using System;
|
||||
using System.Timers;
|
||||
|
||||
namespace OpenSim.Framework.Statistics
|
||||
namespace OpenSim.Framework.Monitoring
|
||||
{
|
||||
/// <summary>
|
||||
/// Asset service statistics collection
|
||||
@@ -31,8 +31,7 @@ using System.Text;
|
||||
using OpenMetaverse;
|
||||
using OpenMetaverse.StructuredData;
|
||||
|
||||
|
||||
namespace OpenSim.Framework.Statistics
|
||||
namespace OpenSim.Framework.Monitoring
|
||||
{
|
||||
/// <summary>
|
||||
/// Statistics which all collectors are interested in reporting
|
||||
@@ -44,14 +43,18 @@ namespace OpenSim.Framework.Statistics
|
||||
StringBuilder sb = new StringBuilder(Environment.NewLine);
|
||||
sb.Append("MEMORY STATISTICS");
|
||||
sb.Append(Environment.NewLine);
|
||||
sb.Append(
|
||||
string.Format(
|
||||
"Allocated to OpenSim objects: {0} MB\n",
|
||||
Math.Round(GC.GetTotalMemory(false) / 1024.0 / 1024.0)));
|
||||
sb.Append(
|
||||
string.Format(
|
||||
"Process memory : {0} MB\n",
|
||||
Math.Round(Process.GetCurrentProcess().WorkingSet64 / 1024.0 / 1024.0)));
|
||||
|
||||
sb.AppendFormat(
|
||||
"Allocated to OpenSim objects: {0} MB\n",
|
||||
Math.Round(GC.GetTotalMemory(false) / 1024.0 / 1024.0));
|
||||
|
||||
sb.AppendFormat(
|
||||
"OpenSim object memory churn : {0} MB/s\n",
|
||||
Math.Round((MemoryWatchdog.AverageMemoryChurn * 1000) / 1024.0 / 1024, 3));
|
||||
|
||||
sb.AppendFormat(
|
||||
"Process memory : {0} MB\n",
|
||||
Math.Round(Process.GetCurrentProcess().WorkingSet64 / 1024.0 / 1024.0));
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
@@ -25,7 +25,7 @@
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
namespace OpenSim.Framework.Statistics.Interfaces
|
||||
namespace OpenSim.Framework.Monitoring.Interfaces
|
||||
{
|
||||
/// <summary>
|
||||
/// Implemented by objects which allow statistical information to be pulled from them.
|
||||
@@ -25,7 +25,7 @@
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
namespace OpenSim.Framework.Statistics
|
||||
namespace OpenSim.Framework.Monitoring
|
||||
{
|
||||
/// <summary>
|
||||
/// Implemented by classes which collect up non-viewer statistical information
|
||||
129
OpenSim/Framework/Monitoring/MemoryWatchdog.cs
Normal file
129
OpenSim/Framework/Monitoring/MemoryWatchdog.cs
Normal file
@@ -0,0 +1,129 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
using log4net;
|
||||
|
||||
namespace OpenSim.Framework.Monitoring
|
||||
{
|
||||
/// <summary>
|
||||
/// Experimental watchdog for memory usage.
|
||||
/// </summary>
|
||||
public static class MemoryWatchdog
|
||||
{
|
||||
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
/// <summary>
|
||||
/// Is this watchdog active?
|
||||
/// </summary>
|
||||
public static bool Enabled
|
||||
{
|
||||
get { return m_enabled; }
|
||||
set
|
||||
{
|
||||
// m_log.DebugFormat("[MEMORY WATCHDOG]: Setting MemoryWatchdog.Enabled to {0}", value);
|
||||
|
||||
if (value && !m_enabled)
|
||||
UpdateLastRecord(GC.GetTotalMemory(false), Util.EnvironmentTickCount());
|
||||
|
||||
m_enabled = value;
|
||||
}
|
||||
}
|
||||
private static bool m_enabled;
|
||||
|
||||
/// <summary>
|
||||
/// Average memory churn in bytes per millisecond.
|
||||
/// </summary>
|
||||
public static double AverageMemoryChurn
|
||||
{
|
||||
get { if (m_samples.Count > 0) return m_samples.Average(); else return 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Maximum number of statistical samples.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// At the moment this corresponds to 1 minute since the sampling rate is every 2.5 seconds as triggered from
|
||||
/// the main Watchdog.
|
||||
/// </remarks>
|
||||
private static int m_maxSamples = 24;
|
||||
|
||||
/// <summary>
|
||||
/// Time when the watchdog was last updated.
|
||||
/// </summary>
|
||||
private static int m_lastUpdateTick;
|
||||
|
||||
/// <summary>
|
||||
/// Memory used at time of last watchdog update.
|
||||
/// </summary>
|
||||
private static long m_lastUpdateMemory;
|
||||
|
||||
/// <summary>
|
||||
/// Memory churn rate per millisecond.
|
||||
/// </summary>
|
||||
// private static double m_churnRatePerMillisecond;
|
||||
|
||||
/// <summary>
|
||||
/// Historical samples for calculating moving average.
|
||||
/// </summary>
|
||||
private static Queue<double> m_samples = new Queue<double>(m_maxSamples);
|
||||
|
||||
public static void Update()
|
||||
{
|
||||
int now = Util.EnvironmentTickCount();
|
||||
long memoryNow = GC.GetTotalMemory(false);
|
||||
long memoryDiff = memoryNow - m_lastUpdateMemory;
|
||||
|
||||
if (memoryDiff >= 0)
|
||||
{
|
||||
if (m_samples.Count >= m_maxSamples)
|
||||
m_samples.Dequeue();
|
||||
|
||||
double elapsed = Util.EnvironmentTickCountSubtract(now, m_lastUpdateTick);
|
||||
|
||||
// This should never happen since it's not useful for updates to occur with no time elapsed, but
|
||||
// protect ourselves from a divide-by-zero just in case.
|
||||
if (elapsed == 0)
|
||||
return;
|
||||
|
||||
m_samples.Enqueue(memoryDiff / (double)elapsed);
|
||||
}
|
||||
|
||||
UpdateLastRecord(memoryNow, now);
|
||||
}
|
||||
|
||||
private static void UpdateLastRecord(long memoryNow, int timeNow)
|
||||
{
|
||||
m_lastUpdateMemory = memoryNow;
|
||||
m_lastUpdateTick = timeNow;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -28,12 +28,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework.Statistics.Interfaces;
|
||||
using OpenMetaverse.StructuredData;
|
||||
using OpenSim.Framework.Monitoring.Interfaces;
|
||||
|
||||
namespace OpenSim.Framework.Statistics
|
||||
namespace OpenSim.Framework.Monitoring
|
||||
{
|
||||
/// <summary>
|
||||
/// Collects sim statistics which aren't already being collected for the linden viewer's statistics pane
|
||||
@@ -25,7 +25,7 @@
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
namespace OpenSim.Framework.Statistics
|
||||
namespace OpenSim.Framework.Monitoring
|
||||
{
|
||||
/// <summary>
|
||||
/// Singleton used to provide access to statistics reporters
|
||||
@@ -27,7 +27,7 @@
|
||||
|
||||
using System.Timers;
|
||||
|
||||
namespace OpenSim.Framework.Statistics
|
||||
namespace OpenSim.Framework.Monitoring
|
||||
{
|
||||
/// <summary>
|
||||
/// Collects user service statistics
|
||||
@@ -31,7 +31,7 @@ using System.Linq;
|
||||
using System.Threading;
|
||||
using log4net;
|
||||
|
||||
namespace OpenSim.Framework
|
||||
namespace OpenSim.Framework.Monitoring
|
||||
{
|
||||
/// <summary>
|
||||
/// Manages launching threads and keeping watch over them for timeouts
|
||||
@@ -41,8 +41,8 @@ namespace OpenSim.Framework
|
||||
/// <summary>Timer interval in milliseconds for the watchdog timer</summary>
|
||||
const double WATCHDOG_INTERVAL_MS = 2500.0d;
|
||||
|
||||
/// <summary>Maximum timeout in milliseconds before a thread is considered dead</summary>
|
||||
public const int WATCHDOG_TIMEOUT_MS = 5000;
|
||||
/// <summary>Default timeout in milliseconds before a thread is considered dead</summary>
|
||||
public const int DEFAULT_WATCHDOG_TIMEOUT_MS = 5000;
|
||||
|
||||
[System.Diagnostics.DebuggerDisplay("{Thread.Name}")]
|
||||
public class ThreadWatchdogInfo
|
||||
@@ -97,17 +97,50 @@ namespace OpenSim.Framework
|
||||
/// /summary>
|
||||
public static event Action<ThreadWatchdogInfo> OnWatchdogTimeout;
|
||||
|
||||
/// <summary>
|
||||
/// Is this watchdog active?
|
||||
/// </summary>
|
||||
public static bool Enabled
|
||||
{
|
||||
get { return m_enabled; }
|
||||
set
|
||||
{
|
||||
// m_log.DebugFormat("[MEMORY WATCHDOG]: Setting MemoryWatchdog.Enabled to {0}", value);
|
||||
|
||||
if (value == m_enabled)
|
||||
return;
|
||||
|
||||
m_enabled = value;
|
||||
|
||||
if (m_enabled)
|
||||
{
|
||||
// Set now so we don't get alerted on the first run
|
||||
LastWatchdogThreadTick = Environment.TickCount & Int32.MaxValue;
|
||||
}
|
||||
|
||||
m_watchdogTimer.Enabled = m_enabled;
|
||||
}
|
||||
}
|
||||
private static bool m_enabled;
|
||||
|
||||
private static readonly ILog m_log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||
private static Dictionary<int, ThreadWatchdogInfo> m_threads;
|
||||
private static System.Timers.Timer m_watchdogTimer;
|
||||
|
||||
/// <summary>
|
||||
/// Last time the watchdog thread ran.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Should run every WATCHDOG_INTERVAL_MS
|
||||
/// </remarks>
|
||||
public static int LastWatchdogThreadTick { get; private set; }
|
||||
|
||||
static Watchdog()
|
||||
{
|
||||
m_threads = new Dictionary<int, ThreadWatchdogInfo>();
|
||||
m_watchdogTimer = new System.Timers.Timer(WATCHDOG_INTERVAL_MS);
|
||||
m_watchdogTimer.AutoReset = false;
|
||||
m_watchdogTimer.Elapsed += WatchdogTimerElapsed;
|
||||
m_watchdogTimer.Start();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -122,7 +155,7 @@ namespace OpenSim.Framework
|
||||
public static Thread StartThread(
|
||||
ThreadStart start, string name, ThreadPriority priority, bool isBackground, bool alarmIfTimeout)
|
||||
{
|
||||
return StartThread(start, name, priority, isBackground, alarmIfTimeout, null, WATCHDOG_TIMEOUT_MS);
|
||||
return StartThread(start, name, priority, isBackground, alarmIfTimeout, null, DEFAULT_WATCHDOG_TIMEOUT_MS);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -264,6 +297,16 @@ namespace OpenSim.Framework
|
||||
/// <param name="e"></param>
|
||||
private static void WatchdogTimerElapsed(object sender, System.Timers.ElapsedEventArgs e)
|
||||
{
|
||||
int now = Environment.TickCount & Int32.MaxValue;
|
||||
int msElapsed = now - LastWatchdogThreadTick;
|
||||
|
||||
if (msElapsed > WATCHDOG_INTERVAL_MS * 2)
|
||||
m_log.WarnFormat(
|
||||
"[WATCHDOG]: {0} ms since Watchdog last ran. Interval should be approximately {1} ms",
|
||||
msElapsed, WATCHDOG_INTERVAL_MS);
|
||||
|
||||
LastWatchdogThreadTick = Environment.TickCount & Int32.MaxValue;
|
||||
|
||||
Action<ThreadWatchdogInfo> callback = OnWatchdogTimeout;
|
||||
|
||||
if (callback != null)
|
||||
@@ -272,8 +315,6 @@ namespace OpenSim.Framework
|
||||
|
||||
lock (m_threads)
|
||||
{
|
||||
int now = Environment.TickCount & Int32.MaxValue;
|
||||
|
||||
foreach (ThreadWatchdogInfo threadInfo in m_threads.Values)
|
||||
{
|
||||
if (threadInfo.Thread.ThreadState == ThreadState.Stopped)
|
||||
@@ -305,6 +346,9 @@ namespace OpenSim.Framework
|
||||
callback(callbackInfo);
|
||||
}
|
||||
|
||||
if (MemoryWatchdog.Enabled)
|
||||
MemoryWatchdog.Update();
|
||||
|
||||
m_watchdogTimer.Start();
|
||||
}
|
||||
}
|
||||
@@ -480,9 +480,16 @@ namespace OpenSim.Framework
|
||||
MainConsole.Instance.Output("=====================================\n");
|
||||
|
||||
if (name == String.Empty)
|
||||
name = MainConsole.Instance.CmdPrompt("New region name", name);
|
||||
if (name == String.Empty)
|
||||
throw new Exception("Cannot interactively create region with no name");
|
||||
{
|
||||
while (name.Trim() == string.Empty)
|
||||
{
|
||||
name = MainConsole.Instance.CmdPrompt("New region name", name);
|
||||
if (name.Trim() == string.Empty)
|
||||
{
|
||||
MainConsole.Instance.Output("Cannot interactively create region with no name");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
source.AddConfig(name);
|
||||
|
||||
@@ -513,15 +520,20 @@ namespace OpenSim.Framework
|
||||
//
|
||||
allKeys.Remove("RegionUUID");
|
||||
string regionUUID = config.GetString("RegionUUID", string.Empty);
|
||||
if (regionUUID == String.Empty)
|
||||
if (!UUID.TryParse(regionUUID.Trim(), out RegionID))
|
||||
{
|
||||
UUID newID = UUID.Random();
|
||||
|
||||
regionUUID = MainConsole.Instance.CmdPrompt("RegionUUID", newID.ToString());
|
||||
while (RegionID == UUID.Zero)
|
||||
{
|
||||
regionUUID = MainConsole.Instance.CmdPrompt("RegionUUID", newID.ToString());
|
||||
if (!UUID.TryParse(regionUUID.Trim(), out RegionID))
|
||||
{
|
||||
MainConsole.Instance.Output("RegionUUID must be a valid UUID");
|
||||
}
|
||||
}
|
||||
config.Set("RegionUUID", regionUUID);
|
||||
}
|
||||
|
||||
RegionID = new UUID(regionUUID);
|
||||
originRegionID = RegionID; // What IS this?! (Needed for RegionCombinerModule?)
|
||||
|
||||
// Location
|
||||
|
||||
@@ -42,9 +42,7 @@ namespace OpenSim.Framework.Serialization.External
|
||||
/// </summary>
|
||||
public class LandDataSerializer
|
||||
{
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
protected static UTF8Encoding m_utf8Encoding = new UTF8Encoding();
|
||||
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
private static Dictionary<string, Action<LandData, XmlTextReader>> m_ldProcessors
|
||||
= new Dictionary<string, Action<LandData, XmlTextReader>>();
|
||||
@@ -95,6 +93,8 @@ namespace OpenSim.Framework.Serialization.External
|
||||
"MediaURL", (ld, xtr) => ld.MediaURL = xtr.ReadElementString("MediaURL"));
|
||||
m_ldProcessors.Add(
|
||||
"MusicURL", (ld, xtr) => ld.MusicURL = xtr.ReadElementString("MusicURL"));
|
||||
m_ldProcessors.Add(
|
||||
"OwnerID", (ld, xtr) => ld.OwnerID = UUID.Parse(xtr.ReadElementString("OwnerID")));
|
||||
|
||||
m_ldProcessors.Add(
|
||||
"ParcelAccessList", ProcessParcelAccessList);
|
||||
@@ -163,7 +163,7 @@ namespace OpenSim.Framework.Serialization.External
|
||||
/// <exception cref="System.Xml.XmlException"></exception>
|
||||
public static LandData Deserialize(byte[] serializedLandData)
|
||||
{
|
||||
return Deserialize(m_utf8Encoding.GetString(serializedLandData, 0, serializedLandData.Length));
|
||||
return Deserialize(Encoding.UTF8.GetString(serializedLandData, 0, serializedLandData.Length));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -188,7 +188,16 @@ namespace OpenSim.Framework.Serialization.External
|
||||
return landData;
|
||||
}
|
||||
|
||||
public static string Serialize(LandData landData)
|
||||
/// <summary>
|
||||
/// Serialize land data
|
||||
/// </summary>
|
||||
/// <param name='landData'></param>
|
||||
/// <param name='options'>
|
||||
/// Serialization options.
|
||||
/// Can be null if there are no options.
|
||||
/// "wipe-owners" will write UUID.Zero rather than the ownerID so that a later reload loads all parcels with the estate owner as the owner
|
||||
/// </param>
|
||||
public static string Serialize(LandData landData, Dictionary<string, object> options)
|
||||
{
|
||||
StringWriter sw = new StringWriter();
|
||||
XmlTextWriter xtw = new XmlTextWriter(sw);
|
||||
@@ -217,7 +226,14 @@ namespace OpenSim.Framework.Serialization.External
|
||||
xtw.WriteElementString("MediaID", landData.MediaID.ToString());
|
||||
xtw.WriteElementString("MediaURL", landData.MediaURL);
|
||||
xtw.WriteElementString("MusicURL", landData.MusicURL);
|
||||
xtw.WriteElementString("OwnerID", landData.OwnerID.ToString());
|
||||
|
||||
UUID ownerIdToWrite;
|
||||
if (options != null && options.ContainsKey("wipe-owners"))
|
||||
ownerIdToWrite = UUID.Zero;
|
||||
else
|
||||
ownerIdToWrite = landData.OwnerID;
|
||||
|
||||
xtw.WriteElementString("OwnerID", ownerIdToWrite.ToString());
|
||||
|
||||
xtw.WriteStartElement("ParcelAccessList");
|
||||
foreach (LandAccessEntry pal in landData.ParcelAccessList)
|
||||
|
||||
@@ -40,8 +40,6 @@ namespace OpenSim.Framework.Serialization.External
|
||||
/// </summary>
|
||||
public class RegionSettingsSerializer
|
||||
{
|
||||
protected static ASCIIEncoding m_asciiEncoding = new ASCIIEncoding();
|
||||
|
||||
/// <summary>
|
||||
/// Deserialize settings
|
||||
/// </summary>
|
||||
@@ -50,7 +48,7 @@ namespace OpenSim.Framework.Serialization.External
|
||||
/// <exception cref="System.Xml.XmlException"></exception>
|
||||
public static RegionSettings Deserialize(byte[] serializedSettings)
|
||||
{
|
||||
return Deserialize(m_asciiEncoding.GetString(serializedSettings, 0, serializedSettings.Length));
|
||||
return Deserialize(Encoding.ASCII.GetString(serializedSettings, 0, serializedSettings.Length));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace OpenSim.Framework.Serialization.External
|
||||
/// </summary>
|
||||
public class UserInventoryItemSerializer
|
||||
{
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
private static Dictionary<string, Action<InventoryItemBase, XmlTextReader>> m_InventoryItemXmlProcessors
|
||||
= new Dictionary<string, Action<InventoryItemBase, XmlTextReader>>();
|
||||
|
||||
@@ -53,8 +53,6 @@ namespace OpenSim.Framework.Serialization
|
||||
TYPE_CONTIGUOUS_FILE = 8,
|
||||
}
|
||||
|
||||
protected static ASCIIEncoding m_asciiEncoding = new ASCIIEncoding();
|
||||
|
||||
/// <summary>
|
||||
/// Binary reader for the underlying stream
|
||||
/// </summary>
|
||||
@@ -120,13 +118,13 @@ namespace OpenSim.Framework.Serialization
|
||||
if (header[156] == (byte)'L')
|
||||
{
|
||||
int longNameLength = ConvertOctalBytesToDecimal(header, 124, 11);
|
||||
tarHeader.FilePath = m_asciiEncoding.GetString(ReadData(longNameLength));
|
||||
tarHeader.FilePath = Encoding.ASCII.GetString(ReadData(longNameLength));
|
||||
//m_log.DebugFormat("[TAR ARCHIVE READER]: Got long file name {0}", tarHeader.FilePath);
|
||||
header = m_br.ReadBytes(512);
|
||||
}
|
||||
else
|
||||
{
|
||||
tarHeader.FilePath = m_asciiEncoding.GetString(header, 0, 100);
|
||||
tarHeader.FilePath = Encoding.ASCII.GetString(header, 0, 100);
|
||||
tarHeader.FilePath = tarHeader.FilePath.Trim(m_nullCharArray);
|
||||
//m_log.DebugFormat("[TAR ARCHIVE READER]: Got short file name {0}", tarHeader.FilePath);
|
||||
}
|
||||
@@ -205,7 +203,7 @@ namespace OpenSim.Framework.Serialization
|
||||
{
|
||||
// Trim leading white space: ancient tars do that instead
|
||||
// of leading 0s :-( don't ask. really.
|
||||
string oString = m_asciiEncoding.GetString(bytes, startIndex, count).TrimStart(m_spaceCharArray);
|
||||
string oString = Encoding.ASCII.GetString(bytes, startIndex, count).TrimStart(m_spaceCharArray);
|
||||
|
||||
int d = 0;
|
||||
|
||||
|
||||
@@ -41,9 +41,6 @@ namespace OpenSim.Framework.Serialization
|
||||
{
|
||||
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
protected static ASCIIEncoding m_asciiEncoding = new ASCIIEncoding();
|
||||
protected static UTF8Encoding m_utf8Encoding = new UTF8Encoding();
|
||||
|
||||
/// <summary>
|
||||
/// Binary writer for the underlying stream
|
||||
/// </summary>
|
||||
@@ -74,7 +71,7 @@ namespace OpenSim.Framework.Serialization
|
||||
/// <param name="data"></param>
|
||||
public void WriteFile(string filePath, string data)
|
||||
{
|
||||
WriteFile(filePath, m_utf8Encoding.GetBytes(data));
|
||||
WriteFile(filePath, Util.UTF8NoBomEncoding.GetBytes(data));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -85,7 +82,7 @@ namespace OpenSim.Framework.Serialization
|
||||
public void WriteFile(string filePath, byte[] data)
|
||||
{
|
||||
if (filePath.Length > 100)
|
||||
WriteEntry("././@LongLink", m_asciiEncoding.GetBytes(filePath), 'L');
|
||||
WriteEntry("././@LongLink", Encoding.ASCII.GetBytes(filePath), 'L');
|
||||
|
||||
char fileType;
|
||||
|
||||
@@ -137,7 +134,7 @@ namespace OpenSim.Framework.Serialization
|
||||
oString = "0" + oString;
|
||||
}
|
||||
|
||||
byte[] oBytes = m_asciiEncoding.GetBytes(oString);
|
||||
byte[] oBytes = Encoding.ASCII.GetBytes(oString);
|
||||
|
||||
return oBytes;
|
||||
}
|
||||
@@ -156,20 +153,20 @@ namespace OpenSim.Framework.Serialization
|
||||
byte[] header = new byte[512];
|
||||
|
||||
// file path field (100)
|
||||
byte[] nameBytes = m_asciiEncoding.GetBytes(filePath);
|
||||
byte[] nameBytes = Encoding.ASCII.GetBytes(filePath);
|
||||
int nameSize = (nameBytes.Length >= 100) ? 100 : nameBytes.Length;
|
||||
Array.Copy(nameBytes, header, nameSize);
|
||||
|
||||
// file mode (8)
|
||||
byte[] modeBytes = m_asciiEncoding.GetBytes("0000777");
|
||||
byte[] modeBytes = Encoding.ASCII.GetBytes("0000777");
|
||||
Array.Copy(modeBytes, 0, header, 100, 7);
|
||||
|
||||
// owner user id (8)
|
||||
byte[] ownerIdBytes = m_asciiEncoding.GetBytes("0000764");
|
||||
byte[] ownerIdBytes = Encoding.ASCII.GetBytes("0000764");
|
||||
Array.Copy(ownerIdBytes, 0, header, 108, 7);
|
||||
|
||||
// group user id (8)
|
||||
byte[] groupIdBytes = m_asciiEncoding.GetBytes("0000764");
|
||||
byte[] groupIdBytes = Encoding.ASCII.GetBytes("0000764");
|
||||
Array.Copy(groupIdBytes, 0, header, 116, 7);
|
||||
|
||||
// file size in bytes (12)
|
||||
@@ -181,17 +178,17 @@ namespace OpenSim.Framework.Serialization
|
||||
Array.Copy(fileSizeBytes, 0, header, 124, 11);
|
||||
|
||||
// last modification time (12)
|
||||
byte[] lastModTimeBytes = m_asciiEncoding.GetBytes("11017037332");
|
||||
byte[] lastModTimeBytes = Encoding.ASCII.GetBytes("11017037332");
|
||||
Array.Copy(lastModTimeBytes, 0, header, 136, 11);
|
||||
|
||||
// entry type indicator (1)
|
||||
header[156] = m_asciiEncoding.GetBytes(new char[] { fileType })[0];
|
||||
header[156] = Encoding.ASCII.GetBytes(new char[] { fileType })[0];
|
||||
|
||||
Array.Copy(m_asciiEncoding.GetBytes("0000000"), 0, header, 329, 7);
|
||||
Array.Copy(m_asciiEncoding.GetBytes("0000000"), 0, header, 337, 7);
|
||||
Array.Copy(Encoding.ASCII.GetBytes("0000000"), 0, header, 329, 7);
|
||||
Array.Copy(Encoding.ASCII.GetBytes("0000000"), 0, header, 337, 7);
|
||||
|
||||
// check sum for header block (8) [calculated last]
|
||||
Array.Copy(m_asciiEncoding.GetBytes(" "), 0, header, 148, 8);
|
||||
Array.Copy(Encoding.ASCII.GetBytes(" "), 0, header, 148, 8);
|
||||
|
||||
int checksum = 0;
|
||||
foreach (byte b in header)
|
||||
|
||||
@@ -42,22 +42,23 @@ namespace OpenSim.Framework.Serialization.Tests
|
||||
private LandData land;
|
||||
private LandData landWithParcelAccessList;
|
||||
|
||||
private static string preSerialized = "<?xml version=\"1.0\" encoding=\"utf-16\"?>\n<LandData>\n <Area>128</Area>\n <AuctionID>0</AuctionID>\n <AuthBuyerID>00000000-0000-0000-0000-000000000000</AuthBuyerID>\n <Category>10</Category>\n <ClaimDate>0</ClaimDate>\n <ClaimPrice>0</ClaimPrice>\n <GlobalID>54ff9641-dd40-4a2c-b1f1-47dd3af24e50</GlobalID>\n <GroupID>d740204e-bbbf-44aa-949d-02c7d739f6a5</GroupID>\n <IsGroupOwned>False</IsGroupOwned>\n <Bitmap>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</Bitmap>\n <Description>land data to test LandDataSerializer</Description>\n <Flags>536870944</Flags>\n <LandingType>2</LandingType>\n <Name>LandDataSerializerTest Land</Name>\n <Status>0</Status>\n <LocalID>0</LocalID>\n <MediaAutoScale>1</MediaAutoScale>\n <MediaID>d4452578-2f25-4b97-a81b-819af559cfd7</MediaID>\n <MediaURL>http://videos.opensimulator.org/bumblebee.mp4</MediaURL>\n <MusicURL />\n <OwnerID>1b8eedf9-6d15-448b-8015-24286f1756bf</OwnerID>\n <ParcelAccessList />\n <PassHours>0</PassHours>\n <PassPrice>0</PassPrice>\n <SalePrice>0</SalePrice>\n <SnapshotID>00000000-0000-0000-0000-000000000000</SnapshotID>\n <UserLocation><0, 0, 0></UserLocation>\n <UserLookAt><0, 0, 0></UserLookAt>\n <Dwell>0</Dwell>\n <OtherCleanTime>0</OtherCleanTime>\n</LandData>";
|
||||
private static string preSerializedWithParcelAccessList = "<?xml version=\"1.0\" encoding=\"utf-16\"?>\n<LandData>\n <Area>128</Area>\n <AuctionID>0</AuctionID>\n <AuthBuyerID>00000000-0000-0000-0000-000000000000</AuthBuyerID>\n <Category>10</Category>\n <ClaimDate>0</ClaimDate>\n <ClaimPrice>0</ClaimPrice>\n <GlobalID>54ff9641-dd40-4a2c-b1f1-47dd3af24e50</GlobalID>\n <GroupID>d740204e-bbbf-44aa-949d-02c7d739f6a5</GroupID>\n <IsGroupOwned>False</IsGroupOwned>\n <Bitmap>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</Bitmap>\n <Description>land data to test LandDataSerializer</Description>\n <Flags>536870944</Flags>\n <LandingType>2</LandingType>\n <Name>LandDataSerializerTest Land</Name>\n <Status>0</Status>\n <LocalID>0</LocalID>\n <MediaAutoScale>1</MediaAutoScale>\n <MediaID>d4452578-2f25-4b97-a81b-819af559cfd7</MediaID>\n <MediaURL>http://videos.opensimulator.org/bumblebee.mp4</MediaURL>\n <MusicURL />\n <OwnerID>1b8eedf9-6d15-448b-8015-24286f1756bf</OwnerID>\n <ParcelAccessList>\n <ParcelAccessEntry>\n <AgentID>62d65d45-c91a-4f77-862c-46557d978b6c</AgentID>\n <Time>0</Time>\n <AccessList>2</AccessList>\n </ParcelAccessEntry>\n <ParcelAccessEntry>\n <AgentID>ec2a8d18-2378-4fe0-8b68-2a31b57c481e</AgentID>\n <Time>0</Time>\n <AccessList>1</AccessList>\n </ParcelAccessEntry>\n </ParcelAccessList>\n <PassHours>0</PassHours>\n <PassPrice>0</PassPrice>\n <SalePrice>0</SalePrice>\n <SnapshotID>00000000-0000-0000-0000-000000000000</SnapshotID>\n <UserLocation><0, 0, 0></UserLocation>\n <UserLookAt><0, 0, 0></UserLookAt>\n <Dwell>0</Dwell>\n <OtherCleanTime>0</OtherCleanTime>\n</LandData>";
|
||||
// private static string preSerialized = "<?xml version=\"1.0\" encoding=\"utf-16\"?>\n<LandData>\n <Area>128</Area>\n <AuctionID>0</AuctionID>\n <AuthBuyerID>00000000-0000-0000-0000-000000000000</AuthBuyerID>\n <Category>10</Category>\n <ClaimDate>0</ClaimDate>\n <ClaimPrice>0</ClaimPrice>\n <GlobalID>54ff9641-dd40-4a2c-b1f1-47dd3af24e50</GlobalID>\n <GroupID>d740204e-bbbf-44aa-949d-02c7d739f6a5</GroupID>\n <IsGroupOwned>False</IsGroupOwned>\n <Bitmap>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</Bitmap>\n <Description>land data to test LandDataSerializer</Description>\n <Flags>536870944</Flags>\n <LandingType>2</LandingType>\n <Name>LandDataSerializerTest Land</Name>\n <Status>0</Status>\n <LocalID>0</LocalID>\n <MediaAutoScale>1</MediaAutoScale>\n <MediaID>d4452578-2f25-4b97-a81b-819af559cfd7</MediaID>\n <MediaURL>http://videos.opensimulator.org/bumblebee.mp4</MediaURL>\n <MusicURL />\n <OwnerID>1b8eedf9-6d15-448b-8015-24286f1756bf</OwnerID>\n <ParcelAccessList />\n <PassHours>0</PassHours>\n <PassPrice>0</PassPrice>\n <SalePrice>0</SalePrice>\n <SnapshotID>00000000-0000-0000-0000-000000000000</SnapshotID>\n <UserLocation><0, 0, 0></UserLocation>\n <UserLookAt><0, 0, 0></UserLookAt>\n <Dwell>0</Dwell>\n <OtherCleanTime>0</OtherCleanTime>\n</LandData>";
|
||||
private static string preSerializedWithParcelAccessList
|
||||
= "<?xml version=\"1.0\" encoding=\"utf-16\"?>\n<LandData>\n <Area>128</Area>\n <AuctionID>0</AuctionID>\n <AuthBuyerID>00000000-0000-0000-0000-000000000000</AuthBuyerID>\n <Category>10</Category>\n <ClaimDate>0</ClaimDate>\n <ClaimPrice>0</ClaimPrice>\n <GlobalID>54ff9641-dd40-4a2c-b1f1-47dd3af24e50</GlobalID>\n <GroupID>d740204e-bbbf-44aa-949d-02c7d739f6a5</GroupID>\n <IsGroupOwned>False</IsGroupOwned>\n <Bitmap>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</Bitmap>\n <Description>land data to test LandDataSerializer</Description>\n <Flags>536870944</Flags>\n <LandingType>2</LandingType>\n <Name>LandDataSerializerTest Land</Name>\n <Status>0</Status>\n <LocalID>0</LocalID>\n <MediaAutoScale>1</MediaAutoScale>\n <MediaID>d4452578-2f25-4b97-a81b-819af559cfd7</MediaID>\n <MediaURL>http://videos.opensimulator.org/bumblebee.mp4</MediaURL>\n <MusicURL />\n <OwnerID>1b8eedf9-6d15-448b-8015-24286f1756bf</OwnerID>\n <ParcelAccessList>\n <ParcelAccessEntry>\n <AgentID>62d65d45-c91a-4f77-862c-46557d978b6c</AgentID>\n <Time>0</Time>\n <AccessList>2</AccessList>\n </ParcelAccessEntry>\n <ParcelAccessEntry>\n <AgentID>ec2a8d18-2378-4fe0-8b68-2a31b57c481e</AgentID>\n <Time>0</Time>\n <AccessList>1</AccessList>\n </ParcelAccessEntry>\n </ParcelAccessList>\n <PassHours>0</PassHours>\n <PassPrice>0</PassPrice>\n <SalePrice>0</SalePrice>\n <SnapshotID>00000000-0000-0000-0000-000000000000</SnapshotID>\n <UserLocation><0, 0, 0></UserLocation>\n <UserLookAt><0, 0, 0></UserLookAt>\n <Dwell>0</Dwell>\n <OtherCleanTime>0</OtherCleanTime>\n</LandData>";
|
||||
|
||||
[SetUp]
|
||||
public void setup()
|
||||
{
|
||||
// setup LandData object
|
||||
this.land = new LandData();
|
||||
this.land.AABBMax = new Vector3(0, 0, 0);
|
||||
this.land.AABBMin = new Vector3(128, 128, 128);
|
||||
this.land.AABBMax = new Vector3(1, 2, 3);
|
||||
this.land.AABBMin = new Vector3(129, 130, 131);
|
||||
this.land.Area = 128;
|
||||
this.land.AuctionID = 0;
|
||||
this.land.AuthBuyerID = new UUID();
|
||||
this.land.AuctionID = 4;
|
||||
this.land.AuthBuyerID = new UUID("7176df0c-6c50-45db-8a37-5e78be56a0cd");
|
||||
this.land.Category = ParcelCategory.Residential;
|
||||
this.land.ClaimDate = 0;
|
||||
this.land.ClaimPrice = 0;
|
||||
this.land.ClaimDate = 1;
|
||||
this.land.ClaimPrice = 2;
|
||||
this.land.GlobalID = new UUID("54ff9641-dd40-4a2c-b1f1-47dd3af24e50");
|
||||
this.land.GroupID = new UUID("d740204e-bbbf-44aa-949d-02c7d739f6a5");
|
||||
this.land.Description = "land data to test LandDataSerializer";
|
||||
@@ -65,7 +66,7 @@ namespace OpenSim.Framework.Serialization.Tests
|
||||
this.land.LandingType = (byte)LandingType.Direct;
|
||||
this.land.Name = "LandDataSerializerTest Land";
|
||||
this.land.Status = ParcelStatus.Leased;
|
||||
this.land.LocalID = 0;
|
||||
this.land.LocalID = 1;
|
||||
this.land.MediaAutoScale = (byte)0x01;
|
||||
this.land.MediaID = new UUID("d4452578-2f25-4b97-a81b-819af559cfd7");
|
||||
this.land.MediaURL = "http://videos.opensimulator.org/bumblebee.mp4";
|
||||
@@ -90,26 +91,26 @@ namespace OpenSim.Framework.Serialization.Tests
|
||||
/// <summary>
|
||||
/// Test the LandDataSerializer.Serialize() method
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void LandDataSerializerSerializeTest()
|
||||
{
|
||||
TestHelpers.InMethod();
|
||||
|
||||
string serialized = LandDataSerializer.Serialize(this.land).Replace("\r\n", "\n");
|
||||
Assert.That(serialized.Length > 0, "Serialize(LandData) returned empty string");
|
||||
|
||||
// adding a simple boolean variable because resharper nUnit integration doesn't like this
|
||||
// XML data in the Assert.That statement. Not sure why.
|
||||
bool result = (serialized == preSerialized);
|
||||
Assert.That(result, "result of Serialize LandData does not match expected result");
|
||||
|
||||
string serializedWithParcelAccessList = LandDataSerializer.Serialize(this.landWithParcelAccessList).Replace("\r\n", "\n");
|
||||
Assert.That(serializedWithParcelAccessList.Length > 0,
|
||||
"Serialize(LandData) returned empty string for LandData object with ParcelAccessList");
|
||||
result = (serializedWithParcelAccessList == preSerializedWithParcelAccessList);
|
||||
Assert.That(result,
|
||||
"result of Serialize(LandData) does not match expected result (pre-serialized with parcel access list");
|
||||
}
|
||||
// [Test]
|
||||
// public void LandDataSerializerSerializeTest()
|
||||
// {
|
||||
// TestHelpers.InMethod();
|
||||
//
|
||||
// string serialized = LandDataSerializer.Serialize(this.land).Replace("\r\n", "\n");
|
||||
// Assert.That(serialized.Length > 0, "Serialize(LandData) returned empty string");
|
||||
//
|
||||
// // adding a simple boolean variable because resharper nUnit integration doesn't like this
|
||||
// // XML data in the Assert.That statement. Not sure why.
|
||||
// bool result = (serialized == preSerialized);
|
||||
// Assert.That(result, "result of Serialize LandData does not match expected result");
|
||||
//
|
||||
// string serializedWithParcelAccessList = LandDataSerializer.Serialize(this.landWithParcelAccessList).Replace("\r\n", "\n");
|
||||
// Assert.That(serializedWithParcelAccessList.Length > 0,
|
||||
// "Serialize(LandData) returned empty string for LandData object with ParcelAccessList");
|
||||
// result = (serializedWithParcelAccessList == preSerializedWithParcelAccessList);
|
||||
// Assert.That(result,
|
||||
// "result of Serialize(LandData) does not match expected result (pre-serialized with parcel access list");
|
||||
// }
|
||||
|
||||
/// <summary>
|
||||
/// Test the LandDataSerializer.Deserialize() method
|
||||
@@ -120,10 +121,28 @@ namespace OpenSim.Framework.Serialization.Tests
|
||||
TestHelpers.InMethod();
|
||||
// log4net.Config.XmlConfigurator.Configure();
|
||||
|
||||
LandData ld = LandDataSerializer.Deserialize(LandDataSerializerTest.preSerialized);
|
||||
Assert.That(ld != null, "Deserialize(string) returned null");
|
||||
Assert.That(ld.GlobalID == this.land.GlobalID, "Reified LandData.GlobalID != original LandData.GlobalID");
|
||||
Assert.That(ld.Name == this.land.Name, "Reified LandData.Name != original LandData.Name");
|
||||
LandData ld = LandDataSerializer.Deserialize(LandDataSerializer.Serialize(this.land, null));
|
||||
Assert.That(ld, Is.Not.Null, "Deserialize(string) returned null");
|
||||
// Assert.That(ld.AABBMax, Is.EqualTo(land.AABBMax));
|
||||
// Assert.That(ld.AABBMin, Is.EqualTo(land.AABBMin));
|
||||
Assert.That(ld.Area, Is.EqualTo(land.Area));
|
||||
Assert.That(ld.AuctionID, Is.EqualTo(land.AuctionID));
|
||||
Assert.That(ld.AuthBuyerID, Is.EqualTo(land.AuthBuyerID));
|
||||
Assert.That(ld.Category, Is.EqualTo(land.Category));
|
||||
Assert.That(ld.ClaimDate, Is.EqualTo(land.ClaimDate));
|
||||
Assert.That(ld.ClaimPrice, Is.EqualTo(land.ClaimPrice));
|
||||
Assert.That(ld.GlobalID, Is.EqualTo(land.GlobalID), "Reified LandData.GlobalID != original LandData.GlobalID");
|
||||
Assert.That(ld.GroupID, Is.EqualTo(land.GroupID));
|
||||
Assert.That(ld.Description, Is.EqualTo(land.Description));
|
||||
Assert.That(ld.Flags, Is.EqualTo(land.Flags));
|
||||
Assert.That(ld.LandingType, Is.EqualTo(land.LandingType));
|
||||
Assert.That(ld.Name, Is.EqualTo(land.Name), "Reified LandData.Name != original LandData.Name");
|
||||
Assert.That(ld.Status, Is.EqualTo(land.Status));
|
||||
Assert.That(ld.LocalID, Is.EqualTo(land.LocalID));
|
||||
Assert.That(ld.MediaAutoScale, Is.EqualTo(land.MediaAutoScale));
|
||||
Assert.That(ld.MediaID, Is.EqualTo(land.MediaID));
|
||||
Assert.That(ld.MediaURL, Is.EqualTo(land.MediaURL));
|
||||
Assert.That(ld.OwnerID, Is.EqualTo(land.OwnerID));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
@@ -40,9 +40,9 @@ using log4net.Core;
|
||||
using log4net.Repository;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Console;
|
||||
using OpenSim.Framework.Monitoring;
|
||||
using OpenSim.Framework.Servers;
|
||||
using OpenSim.Framework.Servers.HttpServer;
|
||||
using OpenSim.Framework.Statistics;
|
||||
using Timer=System.Timers.Timer;
|
||||
|
||||
using OpenMetaverse;
|
||||
@@ -591,8 +591,8 @@ namespace OpenSim.Framework.Servers
|
||||
{
|
||||
string pidstring = System.Diagnostics.Process.GetCurrentProcess().Id.ToString();
|
||||
FileStream fs = File.Create(path);
|
||||
System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
|
||||
Byte[] buf = enc.GetBytes(pidstring);
|
||||
|
||||
Byte[] buf = Encoding.ASCII.GetBytes(pidstring);
|
||||
fs.Write(buf, 0, buf.Length);
|
||||
fs.Close();
|
||||
m_pidFile = path;
|
||||
|
||||
@@ -45,6 +45,7 @@ using OpenMetaverse.StructuredData;
|
||||
using CoolHTTPListener = HttpServer.HttpListener;
|
||||
using HttpListener=System.Net.HttpListener;
|
||||
using LogPrio=HttpServer.LogPrio;
|
||||
using OpenSim.Framework.Monitoring;
|
||||
|
||||
namespace OpenSim.Framework.Servers.HttpServer
|
||||
{
|
||||
|
||||
@@ -32,6 +32,7 @@ using System.Reflection;
|
||||
using log4net;
|
||||
using HttpServer;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Monitoring;
|
||||
|
||||
namespace OpenSim.Framework.Servers.HttpServer
|
||||
{
|
||||
|
||||
@@ -34,6 +34,7 @@ using HttpServer;
|
||||
using OpenMetaverse;
|
||||
using System.Reflection;
|
||||
using log4net;
|
||||
using OpenSim.Framework.Monitoring;
|
||||
|
||||
namespace OpenSim.Framework.Servers.HttpServer
|
||||
{
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace OpenSim
|
||||
public class VersionInfo
|
||||
{
|
||||
private const string VERSION_NUMBER = "0.7.4";
|
||||
private const Flavour VERSION_FLAVOUR = Flavour.Dev;
|
||||
private const Flavour VERSION_FLAVOUR = Flavour.RC1;
|
||||
|
||||
public enum Flavour
|
||||
{
|
||||
|
||||
@@ -73,6 +73,9 @@ namespace OpenSim.Framework
|
||||
|
||||
private bool _ownerChanged = false;
|
||||
|
||||
// This used ONLY during copy. It can't be relied on at other times!
|
||||
private bool _scriptRunning = true;
|
||||
|
||||
public UUID AssetID {
|
||||
get {
|
||||
return _assetID;
|
||||
@@ -350,6 +353,15 @@ namespace OpenSim.Framework
|
||||
}
|
||||
}
|
||||
|
||||
public bool ScriptRunning {
|
||||
get {
|
||||
return _scriptRunning;
|
||||
}
|
||||
set {
|
||||
_scriptRunning = value;
|
||||
}
|
||||
}
|
||||
|
||||
// See ICloneable
|
||||
|
||||
#region ICloneable Members
|
||||
|
||||
@@ -148,6 +148,7 @@ namespace OpenSim.Framework
|
||||
}
|
||||
|
||||
public static Encoding UTF8 = Encoding.UTF8;
|
||||
public static Encoding UTF8NoBomEncoding = new UTF8Encoding(false);
|
||||
|
||||
/// <value>
|
||||
/// Well known UUID for the blank texture used in the Linden SL viewer version 1.20 (and hopefully onwards)
|
||||
@@ -1236,8 +1237,7 @@ namespace OpenSim.Framework
|
||||
|
||||
public static string Base64ToString(string str)
|
||||
{
|
||||
UTF8Encoding encoder = new UTF8Encoding();
|
||||
Decoder utf8Decode = encoder.GetDecoder();
|
||||
Decoder utf8Decode = Encoding.UTF8.GetDecoder();
|
||||
|
||||
byte[] todecode_byte = Convert.FromBase64String(str);
|
||||
int charCount = utf8Decode.GetCharCount(todecode_byte, 0, todecode_byte.Length);
|
||||
|
||||
@@ -92,9 +92,14 @@ namespace OpenSim
|
||||
m_log.Info("[OPENSIM MAIN]: configured log4net using default OpenSim.exe.config");
|
||||
}
|
||||
|
||||
m_log.DebugFormat(
|
||||
m_log.InfoFormat(
|
||||
"[OPENSIM MAIN]: System Locale is {0}", System.Threading.Thread.CurrentThread.CurrentCulture);
|
||||
|
||||
string monoThreadsPerCpu = System.Environment.GetEnvironmentVariable("MONO_THREADS_PER_CPU");
|
||||
|
||||
m_log.InfoFormat(
|
||||
"[OPENSIM MAIN]: Environment variable MONO_THREADS_PER_CPU is {0}", monoThreadsPerCpu ?? "unset");
|
||||
|
||||
// Increase the number of IOCP threads available. Mono defaults to a tragically low number
|
||||
int workerThreads, iocpThreads;
|
||||
System.Threading.ThreadPool.GetMaxThreads(out workerThreads, out iocpThreads);
|
||||
@@ -109,7 +114,6 @@ namespace OpenSim
|
||||
|
||||
// Check if the system is compatible with OpenSimulator.
|
||||
// Ensures that the minimum system requirements are met
|
||||
m_log.Info("Performing compatibility checks... \n");
|
||||
string supported = String.Empty;
|
||||
if (Util.IsEnvironmentSupported(ref supported))
|
||||
{
|
||||
|
||||
@@ -40,7 +40,7 @@ using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Console;
|
||||
using OpenSim.Framework.Servers;
|
||||
using OpenSim.Framework.Statistics;
|
||||
using OpenSim.Framework.Monitoring;
|
||||
using OpenSim.Region.Framework.Interfaces;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
|
||||
@@ -200,9 +200,9 @@ namespace OpenSim
|
||||
PrintFileToConsole("startuplogo.txt");
|
||||
|
||||
// For now, start at the 'root' level by default
|
||||
if (m_sceneManager.Scenes.Count == 1) // If there is only one region, select it
|
||||
if (SceneManager.Scenes.Count == 1) // If there is only one region, select it
|
||||
ChangeSelectedRegion("region",
|
||||
new string[] {"change", "region", m_sceneManager.Scenes[0].RegionInfo.RegionName});
|
||||
new string[] {"change", "region", SceneManager.Scenes[0].RegionInfo.RegionName});
|
||||
else
|
||||
ChangeSelectedRegion("region", new string[] {"change", "region", "root"});
|
||||
|
||||
@@ -294,14 +294,13 @@ namespace OpenSim
|
||||
"save oar [-h|--home=<url>] [--noassets] [--publish] [--perm=<permissions>] [<OAR path>]",
|
||||
"Save a region's data to an OAR archive.",
|
||||
// "-v|--version=<N> generates scene objects as per older versions of the serialization (e.g. -v=0)" + Environment.NewLine
|
||||
"-h|--home=<url> adds the url of the profile service to the saved user information." + Environment.NewLine
|
||||
+ "--noassets stops assets being saved to the OAR." + Environment.NewLine
|
||||
+ "--publish saves an OAR stripped of owner and last owner information." + Environment.NewLine
|
||||
+ " on reload, the estate owner will be the owner of all objects" + Environment.NewLine
|
||||
+ " this is useful if you're making oars generally available that might be reloaded to the same grid from which you published" + Environment.NewLine
|
||||
+ " this option is EXPERIMENTAL" + Environment.NewLine
|
||||
+ "--perm=<permissions> stops objects with insufficient permissions from being saved to the OAR." + Environment.NewLine
|
||||
+ " <permissions> can contain one or more of these characters: \"C\" = Copy, \"T\" = Transfer" + Environment.NewLine
|
||||
"-h|--home=<url> adds the url of the profile service to the saved user information.\n"
|
||||
+ "--noassets stops assets being saved to the OAR.\n"
|
||||
+ "--publish saves an OAR stripped of owner and last owner information.\n"
|
||||
+ " on reload, the estate owner will be the owner of all objects\n"
|
||||
+ " this is useful if you're making oars generally available that might be reloaded to the same grid from which you published\n"
|
||||
+ "--perm=<permissions> stops objects with insufficient permissions from being saved to the OAR.\n"
|
||||
+ " <permissions> can contain one or more of these characters: \"C\" = Copy, \"T\" = Transfer\n"
|
||||
+ "The OAR path must be a filesystem path."
|
||||
+ " If this is not given then the oar is saved to region.oar in the current directory.",
|
||||
SaveOar);
|
||||
@@ -409,10 +408,6 @@ namespace OpenSim
|
||||
m_console.Commands.AddCommand("General", false, "modules unload",
|
||||
"modules unload <name>",
|
||||
"Unload a module", HandleModules);
|
||||
|
||||
m_console.Commands.AddCommand("Objects", false, "kill uuid",
|
||||
"kill uuid <UUID>",
|
||||
"Kill an object by UUID", KillUUID);
|
||||
}
|
||||
|
||||
public override void ShutdownSpecific()
|
||||
@@ -465,7 +460,7 @@ namespace OpenSim
|
||||
if (cmdparams.Length > 4)
|
||||
alert = String.Format("\n{0}\n", String.Join(" ", cmdparams, 4, cmdparams.Length - 4));
|
||||
|
||||
IList agents = m_sceneManager.GetCurrentSceneAvatars();
|
||||
IList agents = SceneManager.GetCurrentSceneAvatars();
|
||||
|
||||
foreach (ScenePresence presence in agents)
|
||||
{
|
||||
@@ -546,7 +541,7 @@ namespace OpenSim
|
||||
private void HandleForceUpdate(string module, string[] args)
|
||||
{
|
||||
MainConsole.Instance.Output("Updating all clients");
|
||||
m_sceneManager.ForceCurrentSceneClientUpdate();
|
||||
SceneManager.ForceCurrentSceneClientUpdate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -558,7 +553,7 @@ namespace OpenSim
|
||||
{
|
||||
if (args.Length == 6)
|
||||
{
|
||||
m_sceneManager.HandleEditCommandOnCurrentScene(args);
|
||||
SceneManager.HandleEditCommandOnCurrentScene(args);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -769,7 +764,7 @@ namespace OpenSim
|
||||
case "load":
|
||||
if (cmdparams.Length > 1)
|
||||
{
|
||||
foreach (Scene s in new ArrayList(m_sceneManager.Scenes))
|
||||
foreach (Scene s in new ArrayList(SceneManager.Scenes))
|
||||
{
|
||||
MainConsole.Instance.Output(String.Format("Loading module: {0}", cmdparams[1]));
|
||||
m_moduleLoader.LoadRegionModules(cmdparams[1], s);
|
||||
@@ -807,14 +802,14 @@ namespace OpenSim
|
||||
|
||||
case "backup":
|
||||
MainConsole.Instance.Output("Triggering save of pending object updates to persistent store");
|
||||
m_sceneManager.BackupCurrentScene();
|
||||
SceneManager.BackupCurrentScene();
|
||||
break;
|
||||
|
||||
case "remove-region":
|
||||
string regRemoveName = CombineParams(cmdparams, 0);
|
||||
|
||||
Scene removeScene;
|
||||
if (m_sceneManager.TryGetScene(regRemoveName, out removeScene))
|
||||
if (SceneManager.TryGetScene(regRemoveName, out removeScene))
|
||||
RemoveRegion(removeScene, false);
|
||||
else
|
||||
MainConsole.Instance.Output("No region with that name");
|
||||
@@ -824,14 +819,14 @@ namespace OpenSim
|
||||
string regDeleteName = CombineParams(cmdparams, 0);
|
||||
|
||||
Scene killScene;
|
||||
if (m_sceneManager.TryGetScene(regDeleteName, out killScene))
|
||||
if (SceneManager.TryGetScene(regDeleteName, out killScene))
|
||||
RemoveRegion(killScene, true);
|
||||
else
|
||||
MainConsole.Instance.Output("no region with that name");
|
||||
break;
|
||||
|
||||
case "restart":
|
||||
m_sceneManager.RestartCurrentScene();
|
||||
SceneManager.RestartCurrentScene();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -846,7 +841,7 @@ namespace OpenSim
|
||||
{
|
||||
string newRegionName = CombineParams(cmdparams, 2);
|
||||
|
||||
if (!m_sceneManager.TrySetCurrentScene(newRegionName))
|
||||
if (!SceneManager.TrySetCurrentScene(newRegionName))
|
||||
MainConsole.Instance.Output(String.Format("Couldn't select region {0}", newRegionName));
|
||||
}
|
||||
else
|
||||
@@ -854,7 +849,7 @@ namespace OpenSim
|
||||
MainConsole.Instance.Output("Usage: change region <region name>");
|
||||
}
|
||||
|
||||
string regionName = (m_sceneManager.CurrentScene == null ? "root" : m_sceneManager.CurrentScene.RegionInfo.RegionName);
|
||||
string regionName = (SceneManager.CurrentScene == null ? "root" : SceneManager.CurrentScene.RegionInfo.RegionName);
|
||||
MainConsole.Instance.Output(String.Format("Currently selected region is {0}", regionName));
|
||||
|
||||
// m_log.DebugFormat("Original prompt is {0}", m_consolePrompt);
|
||||
@@ -872,7 +867,7 @@ namespace OpenSim
|
||||
});
|
||||
|
||||
m_console.DefaultPrompt = prompt;
|
||||
m_console.ConsoleScene = m_sceneManager.CurrentScene;
|
||||
m_console.ConsoleScene = SceneManager.CurrentScene;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -896,7 +891,7 @@ namespace OpenSim
|
||||
int newDebug;
|
||||
if (int.TryParse(args[2], out newDebug))
|
||||
{
|
||||
m_sceneManager.SetDebugPacketLevelOnCurrentScene(newDebug, name);
|
||||
SceneManager.SetDebugPacketLevelOnCurrentScene(newDebug, name);
|
||||
// We provide user information elsewhere if any clients had their debug level set.
|
||||
// MainConsole.Instance.OutputFormat("Debug packet level set to {0}", newDebug);
|
||||
}
|
||||
@@ -911,7 +906,7 @@ namespace OpenSim
|
||||
case "scene":
|
||||
if (args.Length == 4)
|
||||
{
|
||||
if (m_sceneManager.CurrentScene == null)
|
||||
if (SceneManager.CurrentScene == null)
|
||||
{
|
||||
MainConsole.Instance.Output("Please use 'change region <regioname>' first");
|
||||
}
|
||||
@@ -919,7 +914,7 @@ namespace OpenSim
|
||||
{
|
||||
string key = args[2];
|
||||
string value = args[3];
|
||||
m_sceneManager.CurrentScene.SetSceneCoreDebug(
|
||||
SceneManager.CurrentScene.SetSceneCoreDebug(
|
||||
new Dictionary<string, string>() { { key, value } });
|
||||
|
||||
MainConsole.Instance.OutputFormat("Set debug scene {0} = {1}", key, value);
|
||||
@@ -958,10 +953,10 @@ namespace OpenSim
|
||||
IList agents;
|
||||
if (showParams.Length > 1 && showParams[1] == "full")
|
||||
{
|
||||
agents = m_sceneManager.GetCurrentScenePresences();
|
||||
agents = SceneManager.GetCurrentScenePresences();
|
||||
} else
|
||||
{
|
||||
agents = m_sceneManager.GetCurrentSceneAvatars();
|
||||
agents = SceneManager.GetCurrentSceneAvatars();
|
||||
}
|
||||
|
||||
MainConsole.Instance.Output(String.Format("\nAgents connected: {0}\n", agents.Count));
|
||||
@@ -1000,44 +995,11 @@ namespace OpenSim
|
||||
break;
|
||||
|
||||
case "connections":
|
||||
System.Text.StringBuilder connections = new System.Text.StringBuilder("Connections:\n");
|
||||
m_sceneManager.ForEachScene(
|
||||
delegate(Scene scene) {
|
||||
scene.ForEachClient(
|
||||
delegate(IClientAPI client) {
|
||||
connections.AppendFormat(
|
||||
"{0}: {1} ({2}) from {3} on circuit {4}\n",
|
||||
scene.RegionInfo.RegionName,
|
||||
client.Name,
|
||||
client.AgentId,
|
||||
client.RemoteEndPoint,
|
||||
client.CircuitCode
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
MainConsole.Instance.Output(connections.ToString());
|
||||
HandleShowConnections();
|
||||
break;
|
||||
|
||||
case "circuits":
|
||||
System.Text.StringBuilder acd = new System.Text.StringBuilder("Agent Circuits:\n");
|
||||
m_sceneManager.ForEachScene(
|
||||
delegate(Scene scene) {
|
||||
//this.HttpServer.
|
||||
acd.AppendFormat("{0}:\n", scene.RegionInfo.RegionName);
|
||||
foreach (AgentCircuitData aCircuit in scene.AuthenticateHandler.GetAgentCircuits().Values)
|
||||
acd.AppendFormat(
|
||||
"\t{0} {1} ({2})\n",
|
||||
aCircuit.firstname,
|
||||
aCircuit.lastname,
|
||||
(aCircuit.child ? "Child" : "Root")
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
MainConsole.Instance.Output(acd.ToString());
|
||||
HandleShowCircuits();
|
||||
break;
|
||||
|
||||
case "http-handlers":
|
||||
@@ -1074,7 +1036,7 @@ namespace OpenSim
|
||||
MainConsole.Instance.Output("Shared Module: " + module.Name);
|
||||
}
|
||||
|
||||
m_sceneManager.ForEachScene(
|
||||
SceneManager.ForEachScene(
|
||||
delegate(Scene scene) {
|
||||
m_log.Error("The currently loaded modules in " + scene.RegionInfo.RegionName + " are:");
|
||||
foreach (IRegionModule module in scene.Modules.Values)
|
||||
@@ -1087,7 +1049,7 @@ namespace OpenSim
|
||||
}
|
||||
);
|
||||
|
||||
m_sceneManager.ForEachScene(
|
||||
SceneManager.ForEachScene(
|
||||
delegate(Scene scene) {
|
||||
MainConsole.Instance.Output("Loaded new region modules in" + scene.RegionInfo.RegionName + " are:");
|
||||
foreach (IRegionModuleBase module in scene.RegionModules.Values)
|
||||
@@ -1103,7 +1065,7 @@ namespace OpenSim
|
||||
break;
|
||||
|
||||
case "regions":
|
||||
m_sceneManager.ForEachScene(
|
||||
SceneManager.ForEachScene(
|
||||
delegate(Scene scene)
|
||||
{
|
||||
MainConsole.Instance.Output(String.Format(
|
||||
@@ -1117,7 +1079,7 @@ namespace OpenSim
|
||||
break;
|
||||
|
||||
case "ratings":
|
||||
m_sceneManager.ForEachScene(
|
||||
SceneManager.ForEachScene(
|
||||
delegate(Scene scene)
|
||||
{
|
||||
string rating = "";
|
||||
@@ -1142,6 +1104,53 @@ namespace OpenSim
|
||||
}
|
||||
}
|
||||
|
||||
private void HandleShowCircuits()
|
||||
{
|
||||
ConsoleDisplayTable cdt = new ConsoleDisplayTable();
|
||||
cdt.AddColumn("Region", 20);
|
||||
cdt.AddColumn("Avatar name", 24);
|
||||
cdt.AddColumn("Type", 5);
|
||||
cdt.AddColumn("Code", 10);
|
||||
cdt.AddColumn("IP", 16);
|
||||
cdt.AddColumn("Viewer Name", 24);
|
||||
|
||||
SceneManager.ForEachScene(
|
||||
s =>
|
||||
{
|
||||
foreach (AgentCircuitData aCircuit in s.AuthenticateHandler.GetAgentCircuits().Values)
|
||||
cdt.AddRow(
|
||||
s.Name,
|
||||
aCircuit.Name,
|
||||
aCircuit.child ? "child" : "root",
|
||||
aCircuit.circuitcode.ToString(),
|
||||
aCircuit.IPAddress.ToString(),
|
||||
aCircuit.Viewer);
|
||||
});
|
||||
|
||||
MainConsole.Instance.Output(cdt.ToString());
|
||||
}
|
||||
|
||||
private void HandleShowConnections()
|
||||
{
|
||||
ConsoleDisplayTable cdt = new ConsoleDisplayTable();
|
||||
cdt.AddColumn("Region", 20);
|
||||
cdt.AddColumn("Avatar name", 24);
|
||||
cdt.AddColumn("Circuit code", 12);
|
||||
cdt.AddColumn("Endpoint", 23);
|
||||
cdt.AddColumn("Active?", 7);
|
||||
|
||||
SceneManager.ForEachScene(
|
||||
s => s.ForEachClient(
|
||||
c => cdt.AddRow(
|
||||
s.Name,
|
||||
c.Name,
|
||||
c.CircuitCode.ToString(),
|
||||
c.RemoteEndPoint.ToString(),
|
||||
c.IsActive.ToString())));
|
||||
|
||||
MainConsole.Instance.Output(cdt.ToString());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Use XML2 format to serialize data to a file
|
||||
/// </summary>
|
||||
@@ -1151,11 +1160,11 @@ namespace OpenSim
|
||||
{
|
||||
if (cmdparams.Length > 5)
|
||||
{
|
||||
m_sceneManager.SaveNamedPrimsToXml2(cmdparams[3], cmdparams[4]);
|
||||
SceneManager.SaveNamedPrimsToXml2(cmdparams[3], cmdparams[4]);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_sceneManager.SaveNamedPrimsToXml2("Primitive", DEFAULT_PRIM_BACKUP_FILENAME);
|
||||
SceneManager.SaveNamedPrimsToXml2("Primitive", DEFAULT_PRIM_BACKUP_FILENAME);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1170,11 +1179,11 @@ namespace OpenSim
|
||||
|
||||
if (cmdparams.Length > 0)
|
||||
{
|
||||
m_sceneManager.SaveCurrentSceneToXml(cmdparams[2]);
|
||||
SceneManager.SaveCurrentSceneToXml(cmdparams[2]);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_sceneManager.SaveCurrentSceneToXml(DEFAULT_PRIM_BACKUP_FILENAME);
|
||||
SceneManager.SaveCurrentSceneToXml(DEFAULT_PRIM_BACKUP_FILENAME);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1211,13 +1220,13 @@ namespace OpenSim
|
||||
MainConsole.Instance.Output(String.Format("loadOffsets <X,Y,Z> = <{0},{1},{2}>",loadOffset.X,loadOffset.Y,loadOffset.Z));
|
||||
}
|
||||
}
|
||||
m_sceneManager.LoadCurrentSceneFromXml(cmdparams[2], generateNewIDS, loadOffset);
|
||||
SceneManager.LoadCurrentSceneFromXml(cmdparams[2], generateNewIDS, loadOffset);
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
m_sceneManager.LoadCurrentSceneFromXml(DEFAULT_PRIM_BACKUP_FILENAME, false, loadOffset);
|
||||
SceneManager.LoadCurrentSceneFromXml(DEFAULT_PRIM_BACKUP_FILENAME, false, loadOffset);
|
||||
}
|
||||
catch (FileNotFoundException)
|
||||
{
|
||||
@@ -1234,11 +1243,11 @@ namespace OpenSim
|
||||
{
|
||||
if (cmdparams.Length > 2)
|
||||
{
|
||||
m_sceneManager.SaveCurrentSceneToXml2(cmdparams[2]);
|
||||
SceneManager.SaveCurrentSceneToXml2(cmdparams[2]);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_sceneManager.SaveCurrentSceneToXml2(DEFAULT_PRIM_BACKUP_FILENAME);
|
||||
SceneManager.SaveCurrentSceneToXml2(DEFAULT_PRIM_BACKUP_FILENAME);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1253,7 +1262,7 @@ namespace OpenSim
|
||||
{
|
||||
try
|
||||
{
|
||||
m_sceneManager.LoadCurrentSceneFromXml2(cmdparams[2]);
|
||||
SceneManager.LoadCurrentSceneFromXml2(cmdparams[2]);
|
||||
}
|
||||
catch (FileNotFoundException)
|
||||
{
|
||||
@@ -1264,7 +1273,7 @@ namespace OpenSim
|
||||
{
|
||||
try
|
||||
{
|
||||
m_sceneManager.LoadCurrentSceneFromXml2(DEFAULT_PRIM_BACKUP_FILENAME);
|
||||
SceneManager.LoadCurrentSceneFromXml2(DEFAULT_PRIM_BACKUP_FILENAME);
|
||||
}
|
||||
catch (FileNotFoundException)
|
||||
{
|
||||
@@ -1281,7 +1290,7 @@ namespace OpenSim
|
||||
{
|
||||
try
|
||||
{
|
||||
m_sceneManager.LoadArchiveToCurrentScene(cmdparams);
|
||||
SceneManager.LoadArchiveToCurrentScene(cmdparams);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -1295,7 +1304,7 @@ namespace OpenSim
|
||||
/// <param name="cmdparams"></param>
|
||||
protected void SaveOar(string module, string[] cmdparams)
|
||||
{
|
||||
m_sceneManager.SaveCurrentSceneToArchive(cmdparams);
|
||||
SceneManager.SaveCurrentSceneToArchive(cmdparams);
|
||||
}
|
||||
|
||||
private static string CombineParams(string[] commandParams, int pos)
|
||||
@@ -1309,58 +1318,6 @@ namespace OpenSim
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Kill an object given its UUID.
|
||||
/// </summary>
|
||||
/// <param name="cmdparams"></param>
|
||||
protected void KillUUID(string module, string[] cmdparams)
|
||||
{
|
||||
if (cmdparams.Length > 2)
|
||||
{
|
||||
UUID id = UUID.Zero;
|
||||
SceneObjectGroup grp = null;
|
||||
Scene sc = null;
|
||||
|
||||
if (!UUID.TryParse(cmdparams[2], out id))
|
||||
{
|
||||
MainConsole.Instance.Output("[KillUUID]: Error bad UUID format!");
|
||||
return;
|
||||
}
|
||||
|
||||
m_sceneManager.ForEachScene(
|
||||
delegate(Scene scene)
|
||||
{
|
||||
SceneObjectPart part = scene.GetSceneObjectPart(id);
|
||||
if (part == null)
|
||||
return;
|
||||
|
||||
grp = part.ParentGroup;
|
||||
sc = scene;
|
||||
});
|
||||
|
||||
if (grp == null)
|
||||
{
|
||||
MainConsole.Instance.Output(String.Format("[KillUUID]: Given UUID {0} not found!", id));
|
||||
}
|
||||
else
|
||||
{
|
||||
MainConsole.Instance.Output(String.Format("[KillUUID]: Found UUID {0} in scene {1}", id, sc.RegionInfo.RegionName));
|
||||
try
|
||||
{
|
||||
sc.DeleteSceneObject(grp, false);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.ErrorFormat("[KillUUID]: Error while removing objects from scene: " + e);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MainConsole.Instance.Output("[KillUUID]: Usage: kill uuid <UUID>");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ using OpenSim.Framework.Communications;
|
||||
using OpenSim.Framework.Console;
|
||||
using OpenSim.Framework.Servers;
|
||||
using OpenSim.Framework.Servers.HttpServer;
|
||||
using OpenSim.Framework.Statistics;
|
||||
using OpenSim.Framework.Monitoring;
|
||||
using OpenSim.Region.ClientStack;
|
||||
using OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts;
|
||||
using OpenSim.Region.Framework;
|
||||
@@ -285,7 +285,7 @@ namespace OpenSim
|
||||
|
||||
private void HandleCommanderCommand(string module, string[] cmd)
|
||||
{
|
||||
m_sceneManager.SendCommandToPluginModules(cmd);
|
||||
SceneManager.SendCommandToPluginModules(cmd);
|
||||
}
|
||||
|
||||
private void HandleCommanderHelp(string module, string[] cmd)
|
||||
@@ -303,7 +303,15 @@ namespace OpenSim
|
||||
// Called from base.StartUp()
|
||||
|
||||
m_httpServerPort = m_networkServersInfo.HttpListenerPort;
|
||||
m_sceneManager.OnRestartSim += handleRestartRegion;
|
||||
SceneManager.OnRestartSim += handleRestartRegion;
|
||||
|
||||
// Only enable the watchdogs when all regions are ready. Otherwise we get false positives when cpu is
|
||||
// heavily used during initial startup.
|
||||
//
|
||||
// FIXME: It's also possible that region ready status should be flipped during an OAR load since this
|
||||
// also makes heavy use of the CPU.
|
||||
SceneManager.OnRegionsReadyStatusChange
|
||||
+= sm => { MemoryWatchdog.Enabled = sm.AllRegionsReady; Watchdog.Enabled = sm.AllRegionsReady; };
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -412,7 +420,7 @@ namespace OpenSim
|
||||
// scripting engines.
|
||||
scene.CreateScriptInstances();
|
||||
|
||||
m_sceneManager.Add(scene);
|
||||
SceneManager.Add(scene);
|
||||
|
||||
if (m_autoCreateClientStack)
|
||||
{
|
||||
@@ -432,7 +440,6 @@ namespace OpenSim
|
||||
mscene = scene;
|
||||
|
||||
scene.Start();
|
||||
|
||||
scene.StartScripts();
|
||||
|
||||
return clientServer;
|
||||
@@ -561,14 +568,14 @@ namespace OpenSim
|
||||
{
|
||||
// only need to check this if we are not at the
|
||||
// root level
|
||||
if ((m_sceneManager.CurrentScene != null) &&
|
||||
(m_sceneManager.CurrentScene.RegionInfo.RegionID == scene.RegionInfo.RegionID))
|
||||
if ((SceneManager.CurrentScene != null) &&
|
||||
(SceneManager.CurrentScene.RegionInfo.RegionID == scene.RegionInfo.RegionID))
|
||||
{
|
||||
m_sceneManager.TrySetCurrentScene("..");
|
||||
SceneManager.TrySetCurrentScene("..");
|
||||
}
|
||||
|
||||
scene.DeleteAllSceneObjects();
|
||||
m_sceneManager.CloseScene(scene);
|
||||
SceneManager.CloseScene(scene);
|
||||
ShutdownClientServer(scene.RegionInfo);
|
||||
|
||||
if (!cleanup)
|
||||
@@ -610,7 +617,7 @@ namespace OpenSim
|
||||
public void RemoveRegion(string name, bool cleanUp)
|
||||
{
|
||||
Scene target;
|
||||
if (m_sceneManager.TryGetScene(name, out target))
|
||||
if (SceneManager.TryGetScene(name, out target))
|
||||
RemoveRegion(target, cleanUp);
|
||||
}
|
||||
|
||||
@@ -623,13 +630,13 @@ namespace OpenSim
|
||||
{
|
||||
// only need to check this if we are not at the
|
||||
// root level
|
||||
if ((m_sceneManager.CurrentScene != null) &&
|
||||
(m_sceneManager.CurrentScene.RegionInfo.RegionID == scene.RegionInfo.RegionID))
|
||||
if ((SceneManager.CurrentScene != null) &&
|
||||
(SceneManager.CurrentScene.RegionInfo.RegionID == scene.RegionInfo.RegionID))
|
||||
{
|
||||
m_sceneManager.TrySetCurrentScene("..");
|
||||
SceneManager.TrySetCurrentScene("..");
|
||||
}
|
||||
|
||||
m_sceneManager.CloseScene(scene);
|
||||
SceneManager.CloseScene(scene);
|
||||
ShutdownClientServer(scene.RegionInfo);
|
||||
}
|
||||
|
||||
@@ -641,7 +648,7 @@ namespace OpenSim
|
||||
public void CloseRegion(string name)
|
||||
{
|
||||
Scene target;
|
||||
if (m_sceneManager.TryGetScene(name, out target))
|
||||
if (SceneManager.TryGetScene(name, out target))
|
||||
CloseRegion(target);
|
||||
}
|
||||
|
||||
@@ -698,6 +705,7 @@ namespace OpenSim
|
||||
scene.LoadWorldMap();
|
||||
|
||||
scene.PhysicsScene = GetPhysicsScene(scene.RegionInfo.RegionName);
|
||||
scene.PhysicsScene.RequestAssetMethod = scene.PhysicsRequestAsset;
|
||||
scene.PhysicsScene.SetTerrain(scene.Heightmap.GetFloatsSerialised());
|
||||
scene.PhysicsScene.SetWaterLevel((float) regionInfo.RegionSettings.WaterHeight);
|
||||
|
||||
@@ -897,7 +905,7 @@ namespace OpenSim
|
||||
|
||||
try
|
||||
{
|
||||
m_sceneManager.Close();
|
||||
SceneManager.Close();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -922,7 +930,7 @@ namespace OpenSim
|
||||
/// <param name="usernum">The first out parameter describing the number of all the avatars in the Region server</param>
|
||||
public void GetAvatarNumber(out int usernum)
|
||||
{
|
||||
usernum = m_sceneManager.GetCurrentSceneAvatars().Count;
|
||||
usernum = SceneManager.GetCurrentSceneAvatars().Count;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -931,7 +939,7 @@ namespace OpenSim
|
||||
/// <param name="regionnum">The first out parameter describing the number of regions</param>
|
||||
public void GetRegionNumber(out int regionnum)
|
||||
{
|
||||
regionnum = m_sceneManager.Scenes.Count;
|
||||
regionnum = SceneManager.Scenes.Count;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -123,9 +123,14 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||
IConfig sconfig = config.Configs["Startup"];
|
||||
if (sconfig != null)
|
||||
{
|
||||
m_persistBakedTextures = sconfig.GetBoolean("PersistBakedTextures", m_persistBakedTextures);
|
||||
m_levelUpload = sconfig.GetInt("LevelUpload", 0);
|
||||
}
|
||||
|
||||
IConfig appearanceConfig = config.Configs["Appearance"];
|
||||
if (appearanceConfig != null)
|
||||
{
|
||||
m_persistBakedTextures = appearanceConfig.GetBoolean("PersistBakedTextures", m_persistBakedTextures);
|
||||
}
|
||||
}
|
||||
|
||||
m_assetService = m_Scene.AssetService;
|
||||
|
||||
@@ -66,9 +66,9 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||
|
||||
public void Initialise(IConfigSource source)
|
||||
{
|
||||
IConfig sconfig = source.Configs["Startup"];
|
||||
if (sconfig != null)
|
||||
m_persistBakedTextures = sconfig.GetBoolean("PersistBakedTextures", m_persistBakedTextures);
|
||||
IConfig appearanceConfig = source.Configs["Appearance"];
|
||||
if (appearanceConfig != null)
|
||||
m_persistBakedTextures = appearanceConfig.GetBoolean("PersistBakedTextures", m_persistBakedTextures);
|
||||
}
|
||||
|
||||
public void AddRegion(Scene s)
|
||||
|
||||
@@ -41,7 +41,7 @@ using OpenMetaverse.Messages.Linden;
|
||||
using OpenMetaverse.StructuredData;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Client;
|
||||
using OpenSim.Framework.Statistics;
|
||||
using OpenSim.Framework.Monitoring;
|
||||
using OpenSim.Region.Framework.Interfaces;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
using OpenSim.Services.Interfaces;
|
||||
@@ -59,7 +59,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
/// Handles new client connections
|
||||
/// Constructor takes a single Packet and authenticates everything
|
||||
/// </summary>
|
||||
public class LLClientView : IClientAPI, IClientCore, IClientIM, IClientChat, IClientInventory, IClientIPEndpoint, IStatsCollector
|
||||
public class LLClientView : IClientAPI, IClientCore, IClientIM, IClientChat, IClientInventory, IStatsCollector
|
||||
{
|
||||
/// <value>
|
||||
/// Debug packet level. See OpenSim.RegisterConsoleCommands() for more details.
|
||||
@@ -347,8 +347,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
private int m_animationSequenceNumber = 1;
|
||||
private bool m_SendLogoutPacketWhenClosing = true;
|
||||
private AgentUpdateArgs lastarg;
|
||||
private bool m_IsActive = true;
|
||||
private bool m_IsLoggingOut = false;
|
||||
|
||||
protected Dictionary<PacketType, PacketProcessor> m_packetHandlers = new Dictionary<PacketType, PacketProcessor>();
|
||||
protected Dictionary<string, GenericMessage> m_genericPacketHandlers = new Dictionary<string, GenericMessage>(); //PauPaw:Local Generic Message handlers
|
||||
@@ -357,7 +355,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
protected string m_lastName;
|
||||
protected Thread m_clientThread;
|
||||
protected Vector3 m_startpos;
|
||||
protected EndPoint m_userEndPoint;
|
||||
protected UUID m_activeGroupID;
|
||||
protected string m_activeGroupName = String.Empty;
|
||||
protected ulong m_activeGroupPowers;
|
||||
@@ -413,16 +410,19 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
public uint CircuitCode { get { return m_circuitCode; } }
|
||||
public int MoneyBalance { get { return m_moneyBalance; } }
|
||||
public int NextAnimationSequenceNumber { get { return m_animationSequenceNumber++; } }
|
||||
public bool IsActive
|
||||
{
|
||||
get { return m_IsActive; }
|
||||
set { m_IsActive = value; }
|
||||
}
|
||||
public bool IsLoggingOut
|
||||
{
|
||||
get { return m_IsLoggingOut; }
|
||||
set { m_IsLoggingOut = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// As well as it's function in IClientAPI, in LLClientView we are locking on this property in order to
|
||||
/// prevent race conditions by different threads calling Close().
|
||||
/// </summary>
|
||||
public bool IsActive { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Used to synchronise threads when client is being closed.
|
||||
/// </summary>
|
||||
public Object CloseSyncLock { get; private set; }
|
||||
|
||||
public bool IsLoggingOut { get; set; }
|
||||
|
||||
public bool DisableFacelights
|
||||
{
|
||||
@@ -442,15 +442,16 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
public LLClientView(EndPoint remoteEP, Scene scene, LLUDPServer udpServer, LLUDPClient udpClient, AuthenticateResponse sessionInfo,
|
||||
public LLClientView(Scene scene, LLUDPServer udpServer, LLUDPClient udpClient, AuthenticateResponse sessionInfo,
|
||||
UUID agentId, UUID sessionId, uint circuitCode)
|
||||
{
|
||||
// DebugPacketLevel = 1;
|
||||
|
||||
CloseSyncLock = new Object();
|
||||
|
||||
RegisterInterface<IClientIM>(this);
|
||||
RegisterInterface<IClientInventory>(this);
|
||||
RegisterInterface<IClientChat>(this);
|
||||
RegisterInterface<IClientIPEndpoint>(this);
|
||||
|
||||
m_scene = scene;
|
||||
m_entityUpdates = new PriorityQueue(m_scene.Entities.Count);
|
||||
@@ -467,7 +468,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
m_sessionId = sessionId;
|
||||
m_secureSessionId = sessionInfo.LoginInfo.SecureSession;
|
||||
m_circuitCode = circuitCode;
|
||||
m_userEndPoint = remoteEP;
|
||||
m_firstName = sessionInfo.LoginInfo.First;
|
||||
m_lastName = sessionInfo.LoginInfo.Last;
|
||||
m_startpos = sessionInfo.LoginInfo.StartPos;
|
||||
@@ -481,17 +481,40 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
m_prioritizer = new Prioritizer(m_scene);
|
||||
|
||||
RegisterLocalPacketHandlers();
|
||||
|
||||
IsActive = true;
|
||||
}
|
||||
|
||||
#region Client Methods
|
||||
|
||||
/// <summary>
|
||||
/// Shut down the client view
|
||||
/// Close down the client view
|
||||
/// </summary>
|
||||
public void Close()
|
||||
{
|
||||
IsActive = false;
|
||||
// We lock here to prevent race conditions between two threads calling close simultaneously (e.g.
|
||||
// a simultaneous relog just as a client is being closed out due to no packet ack from the old connection.
|
||||
lock (CloseSyncLock)
|
||||
{
|
||||
if (!IsActive)
|
||||
return;
|
||||
|
||||
IsActive = false;
|
||||
CloseWithoutChecks();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Closes down the client view without first checking whether it is active.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This exists because LLUDPServer has to set IsActive = false in earlier synchronous code before calling
|
||||
/// CloseWithoutIsActiveCheck asynchronously.
|
||||
///
|
||||
/// Callers must lock ClosingSyncLock before calling.
|
||||
/// </remarks>
|
||||
public void CloseWithoutChecks()
|
||||
{
|
||||
m_log.DebugFormat(
|
||||
"[CLIENT]: Close has been called for {0} attached to scene {1}",
|
||||
Name, m_scene.RegionInfo.RegionName);
|
||||
@@ -3570,7 +3593,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
|
||||
public void SendCoarseLocationUpdate(List<UUID> users, List<Vector3> CoarseLocations)
|
||||
{
|
||||
if (!IsActive) return; // We don't need to update inactive clients.
|
||||
// We don't need to update inactive clients.
|
||||
if (!IsActive)
|
||||
return;
|
||||
|
||||
CoarseLocationUpdatePacket loc = (CoarseLocationUpdatePacket)PacketPool.Instance.GetPacket(PacketType.CoarseLocationUpdate);
|
||||
loc.Header.Reliable = false;
|
||||
@@ -5167,7 +5192,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
AddLocalPacketHandler(PacketType.ChatFromViewer, HandleChatFromViewer);
|
||||
AddLocalPacketHandler(PacketType.AvatarPropertiesUpdate, HandlerAvatarPropertiesUpdate);
|
||||
AddLocalPacketHandler(PacketType.ScriptDialogReply, HandlerScriptDialogReply);
|
||||
AddLocalPacketHandler(PacketType.ImprovedInstantMessage, HandlerImprovedInstantMessage, false);
|
||||
AddLocalPacketHandler(PacketType.ImprovedInstantMessage, HandlerImprovedInstantMessage);
|
||||
AddLocalPacketHandler(PacketType.AcceptFriendship, HandlerAcceptFriendship);
|
||||
AddLocalPacketHandler(PacketType.DeclineFriendship, HandlerDeclineFriendship);
|
||||
AddLocalPacketHandler(PacketType.TerminateFriendship, HandlerTerminateFriendship);
|
||||
@@ -11833,7 +11858,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
{
|
||||
ClientInfo info = m_udpClient.GetClientInfo();
|
||||
|
||||
info.userEP = m_userEndPoint;
|
||||
info.proxyEP = null;
|
||||
info.agentcircuit = RequestClientInfo();
|
||||
|
||||
@@ -11845,11 +11869,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
m_udpClient.SetClientInfo(info);
|
||||
}
|
||||
|
||||
public EndPoint GetClientEP()
|
||||
{
|
||||
return m_userEndPoint;
|
||||
}
|
||||
|
||||
#region Media Parcel Members
|
||||
|
||||
public void SendParcelMediaCommand(uint flags, ParcelMediaCommandEnum command, float time)
|
||||
@@ -12119,24 +12138,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
return numPackets;
|
||||
}
|
||||
|
||||
#region IClientIPEndpoint Members
|
||||
|
||||
public IPAddress EndPoint
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_userEndPoint is IPEndPoint)
|
||||
{
|
||||
IPEndPoint ep = (IPEndPoint)m_userEndPoint;
|
||||
|
||||
return ep.Address;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public void SendRebakeAvatarTextures(UUID textureID)
|
||||
{
|
||||
RebakeAvatarTexturesPacket pack =
|
||||
|
||||
@@ -278,7 +278,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
public string GetStats()
|
||||
{
|
||||
return string.Format(
|
||||
"{0,7} {1,7} {2,7} {3,9} {4,7} {5,7} {6,7} {7,7} {8,7} {9,8} {10,7} {11,7}",
|
||||
"{0,7} {1,7} {2,7} {3,9} {4,7} {5,7} {6,7} {7,7} {8,7} {9,8} {10,7} {11,7} {12,7}",
|
||||
Util.EnvironmentTickCountSubtract(TickLastPacketReceived),
|
||||
PacketsReceived,
|
||||
PacketsSent,
|
||||
PacketsResent,
|
||||
|
||||
@@ -37,7 +37,7 @@ using log4net;
|
||||
using Nini.Config;
|
||||
using OpenMetaverse.Packets;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Statistics;
|
||||
using OpenSim.Framework.Monitoring;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
using OpenMetaverse;
|
||||
|
||||
@@ -270,7 +270,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
false,
|
||||
true,
|
||||
GetWatchdogIncomingAlarmData,
|
||||
Watchdog.WATCHDOG_TIMEOUT_MS);
|
||||
Watchdog.DEFAULT_WATCHDOG_TIMEOUT_MS);
|
||||
|
||||
Watchdog.StartThread(
|
||||
OutgoingPacketHandler,
|
||||
@@ -279,7 +279,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
false,
|
||||
true,
|
||||
GetWatchdogOutgoingAlarmData,
|
||||
Watchdog.WATCHDOG_TIMEOUT_MS);
|
||||
Watchdog.DEFAULT_WATCHDOG_TIMEOUT_MS);
|
||||
|
||||
m_elapsedMSSinceLastStatReport = Environment.TickCount;
|
||||
}
|
||||
@@ -1103,7 +1103,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
{
|
||||
LLUDPClient udpClient = new LLUDPClient(this, ThrottleRates, m_throttle, circuitCode, agentID, remoteEndPoint, m_defaultRTO, m_maxRTO);
|
||||
|
||||
client = new LLClientView(remoteEndPoint, m_scene, this, udpClient, sessionInfo, agentID, sessionID, circuitCode);
|
||||
client = new LLClientView(m_scene, this, udpClient, sessionInfo, agentID, sessionID, circuitCode);
|
||||
client.OnLogout += LogoutHandler;
|
||||
|
||||
((LLClientView)client).DisableFacelights = m_disableFacelights;
|
||||
@@ -1123,22 +1123,21 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
/// regular client pings.
|
||||
/// </remarks>
|
||||
/// <param name='client'></param>
|
||||
private void DeactivateClientDueToTimeout(IClientAPI client)
|
||||
private void DeactivateClientDueToTimeout(LLClientView client)
|
||||
{
|
||||
// We must set IsActive synchronously so that we can stop the packet loop reinvoking this method, even
|
||||
// though it's set later on by LLClientView.Close()
|
||||
client.IsActive = false;
|
||||
|
||||
m_log.WarnFormat(
|
||||
"[LLUDPSERVER]: Ack timeout, disconnecting {0} agent for {1} in {2}",
|
||||
client.SceneAgent.IsChildAgent ? "child" : "root", client.Name, m_scene.RegionInfo.RegionName);
|
||||
|
||||
StatsManager.SimExtraStats.AddAbnormalClientThreadTermination();
|
||||
|
||||
if (!client.SceneAgent.IsChildAgent)
|
||||
client.Kick("Simulator logged you out due to connection timeout");
|
||||
|
||||
client.Close();
|
||||
lock (client.CloseSyncLock)
|
||||
{
|
||||
m_log.WarnFormat(
|
||||
"[LLUDPSERVER]: Ack timeout, disconnecting {0} agent for {1} in {2}",
|
||||
client.SceneAgent.IsChildAgent ? "child" : "root", client.Name, m_scene.RegionInfo.RegionName);
|
||||
|
||||
StatsManager.SimExtraStats.AddAbnormalClientThreadTermination();
|
||||
|
||||
if (!client.SceneAgent.IsChildAgent)
|
||||
client.Kick("Simulator logged you out due to connection timeout");
|
||||
|
||||
client.CloseWithoutChecks();
|
||||
}
|
||||
}
|
||||
|
||||
private void IncomingPacketHandler()
|
||||
|
||||
@@ -44,9 +44,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests
|
||||
}
|
||||
protected int m_objectNameCallsReceived;
|
||||
|
||||
public MockScene()
|
||||
public MockScene() : base(new RegionInfo(1000, 1000, null, null))
|
||||
{
|
||||
m_regInfo = new RegionInfo(1000, 1000, null, null);
|
||||
m_regStatus = RegionStatus.Up;
|
||||
}
|
||||
|
||||
|
||||
@@ -53,9 +53,8 @@ namespace OpenSim.Region.ClientStack
|
||||
protected ISimulationDataService m_simulationDataService;
|
||||
protected IEstateDataService m_estateDataService;
|
||||
protected ClientStackManager m_clientStackManager;
|
||||
protected SceneManager m_sceneManager = new SceneManager();
|
||||
|
||||
public SceneManager SceneManager { get { return m_sceneManager; } }
|
||||
public SceneManager SceneManager { get; protected set; }
|
||||
public NetworkServersInfo NetServersInfo { get { return m_networkServersInfo; } }
|
||||
public ISimulationDataService SimulationDataService { get { return m_simulationDataService; } }
|
||||
public IEstateDataService EstateDataService { get { return m_estateDataService; } }
|
||||
@@ -77,6 +76,7 @@ namespace OpenSim.Region.ClientStack
|
||||
|
||||
protected override void StartupSpecific()
|
||||
{
|
||||
SceneManager = new SceneManager();
|
||||
m_clientStackManager = CreateClientStackManager();
|
||||
|
||||
Initialize();
|
||||
|
||||
@@ -28,6 +28,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.IO;
|
||||
using System.Xml;
|
||||
using log4net;
|
||||
using Mono.Addins;
|
||||
using Nini.Config;
|
||||
@@ -100,6 +102,56 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
||||
|
||||
#region IAttachmentsModule
|
||||
|
||||
public void CopyAttachments(IScenePresence sp, AgentData ad)
|
||||
{
|
||||
lock (sp.AttachmentsSyncLock)
|
||||
{
|
||||
// Attachment objects
|
||||
List<SceneObjectGroup> attachments = sp.GetAttachments();
|
||||
if (attachments.Count > 0)
|
||||
{
|
||||
ad.AttachmentObjects = new List<ISceneObject>();
|
||||
ad.AttachmentObjectStates = new List<string>();
|
||||
// IScriptModule se = m_scene.RequestModuleInterface<IScriptModule>();
|
||||
sp.InTransitScriptStates.Clear();
|
||||
|
||||
foreach (SceneObjectGroup sog in attachments)
|
||||
{
|
||||
// We need to make a copy and pass that copy
|
||||
// because of transfers withn the same sim
|
||||
ISceneObject clone = sog.CloneForNewScene();
|
||||
// Attachment module assumes that GroupPosition holds the offsets...!
|
||||
((SceneObjectGroup)clone).RootPart.GroupPosition = sog.RootPart.AttachedPos;
|
||||
((SceneObjectGroup)clone).IsAttachment = false;
|
||||
ad.AttachmentObjects.Add(clone);
|
||||
string state = sog.GetStateSnapshot();
|
||||
ad.AttachmentObjectStates.Add(state);
|
||||
sp.InTransitScriptStates.Add(state);
|
||||
// Let's remove the scripts of the original object here
|
||||
sog.RemoveScriptInstances(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void CopyAttachments(AgentData ad, IScenePresence sp)
|
||||
{
|
||||
if (ad.AttachmentObjects != null && ad.AttachmentObjects.Count > 0)
|
||||
{
|
||||
lock (sp.AttachmentsSyncLock)
|
||||
sp.ClearAttachments();
|
||||
|
||||
int i = 0;
|
||||
foreach (ISceneObject so in ad.AttachmentObjects)
|
||||
{
|
||||
((SceneObjectGroup)so).LocalId = 0;
|
||||
((SceneObjectGroup)so).RootPart.ClearUpdateSchedule();
|
||||
so.SetState(ad.AttachmentObjectStates[i++], m_scene);
|
||||
m_scene.IncomingCreateObject(Vector3.Zero, so);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// RezAttachments. This should only be called upon login on the first region.
|
||||
/// Attachment rezzings on crossings and TPs are done in a different way.
|
||||
@@ -152,7 +204,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
||||
}
|
||||
}
|
||||
|
||||
public void DeRezAttachments(IScenePresence sp, bool saveChanged, bool saveAllScripted)
|
||||
public void DeRezAttachments(IScenePresence sp)
|
||||
{
|
||||
if (!Enabled)
|
||||
return;
|
||||
@@ -161,16 +213,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
||||
|
||||
lock (sp.AttachmentsSyncLock)
|
||||
{
|
||||
foreach (SceneObjectGroup grp in sp.GetAttachments())
|
||||
foreach (SceneObjectGroup so in sp.GetAttachments())
|
||||
{
|
||||
grp.Scene.DeleteSceneObject(grp, false);
|
||||
|
||||
if (saveChanged || saveAllScripted)
|
||||
{
|
||||
grp.IsAttachment = false;
|
||||
grp.AbsolutePosition = grp.RootPart.AttachedPos;
|
||||
UpdateKnownItem(sp, grp, saveAllScripted);
|
||||
}
|
||||
UpdateDetachedObject(sp, so);
|
||||
}
|
||||
|
||||
sp.ClearAttachments();
|
||||
@@ -201,6 +246,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
||||
// m_log.DebugFormat(
|
||||
// "[ATTACHMENTS MODULE]: Attaching object {0} {1} to {2} point {3} from ground (silent = {4})",
|
||||
// group.Name, group.LocalId, sp.Name, attachmentPt, silent);
|
||||
|
||||
if (group.GetSittingAvatarsCount() != 0)
|
||||
{
|
||||
// m_log.WarnFormat(
|
||||
// "[ATTACHMENTS MODULE]: Ignoring request to attach {0} {1} to {2} on {3} since {4} avatars are still sitting on it",
|
||||
// group.Name, group.LocalId, sp.Name, attachmentPt, group.GetSittingAvatarsCount());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (sp.GetAttachments(attachmentPt).Contains(group))
|
||||
{
|
||||
@@ -242,33 +296,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
||||
|
||||
group.AttachmentPoint = attachmentPt;
|
||||
group.AbsolutePosition = attachPos;
|
||||
|
||||
// We also don't want to do any of the inventory operations for an NPC.
|
||||
|
||||
if (sp.PresenceType != PresenceType.Npc)
|
||||
{
|
||||
// Remove any previous attachments
|
||||
List<SceneObjectGroup> attachments = sp.GetAttachments(attachmentPt);
|
||||
|
||||
// At the moment we can only deal with a single attachment
|
||||
if (attachments.Count != 0)
|
||||
{
|
||||
UUID oldAttachmentItemID = attachments[0].FromItemID;
|
||||
|
||||
if (oldAttachmentItemID != UUID.Zero)
|
||||
DetachSingleAttachmentToInvInternal(sp, oldAttachmentItemID);
|
||||
else
|
||||
m_log.WarnFormat(
|
||||
"[ATTACHMENTS MODULE]: When detaching existing attachment {0} {1} at point {2} to make way for {3} {4} for {5}, couldn't find the associated item ID to adjust inventory attachment record!",
|
||||
attachments[0].Name, attachments[0].LocalId, attachmentPt, group.Name, group.LocalId, sp.Name);
|
||||
}
|
||||
|
||||
// Add the new attachment to inventory if we don't already have it.
|
||||
UUID newAttachmentItemID = group.FromItemID;
|
||||
if (newAttachmentItemID == UUID.Zero)
|
||||
newAttachmentItemID = AddSceneObjectAsNewAttachmentInInv(sp, group).ID;
|
||||
|
||||
ShowAttachInUserInventory(sp, attachmentPt, newAttachmentItemID, group);
|
||||
}
|
||||
UpdateUserInventoryWithAttachment(sp, group, attachmentPt);
|
||||
|
||||
AttachToAgent(sp, group, attachmentPt, attachPos, silent);
|
||||
}
|
||||
@@ -276,7 +306,31 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
||||
return true;
|
||||
}
|
||||
|
||||
public ISceneEntity RezSingleAttachmentFromInventory(IScenePresence sp, UUID itemID, uint AttachmentPt)
|
||||
private void UpdateUserInventoryWithAttachment(IScenePresence sp, SceneObjectGroup group, uint attachmentPt)
|
||||
{
|
||||
// Remove any previous attachments
|
||||
List<SceneObjectGroup> attachments = sp.GetAttachments(attachmentPt);
|
||||
|
||||
// At the moment we can only deal with a single attachment
|
||||
if (attachments.Count != 0)
|
||||
{
|
||||
if (attachments[0].FromItemID != UUID.Zero)
|
||||
DetachSingleAttachmentToInvInternal(sp, attachments[0]);
|
||||
else
|
||||
m_log.WarnFormat(
|
||||
"[ATTACHMENTS MODULE]: When detaching existing attachment {0} {1} at point {2} to make way for {3} {4} for {5}, couldn't find the associated item ID to adjust inventory attachment record!",
|
||||
attachments[0].Name, attachments[0].LocalId, attachmentPt, group.Name, group.LocalId, sp.Name);
|
||||
}
|
||||
|
||||
// Add the new attachment to inventory if we don't already have it.
|
||||
UUID newAttachmentItemID = group.FromItemID;
|
||||
if (newAttachmentItemID == UUID.Zero)
|
||||
newAttachmentItemID = AddSceneObjectAsNewAttachmentInInv(sp, group).ID;
|
||||
|
||||
ShowAttachInUserInventory(sp, attachmentPt, newAttachmentItemID, group);
|
||||
}
|
||||
|
||||
public SceneObjectGroup RezSingleAttachmentFromInventory(IScenePresence sp, UUID itemID, uint AttachmentPt)
|
||||
{
|
||||
if (!Enabled)
|
||||
return null;
|
||||
@@ -315,12 +369,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
||||
return null;
|
||||
}
|
||||
|
||||
SceneObjectGroup att = RezSingleAttachmentFromInventoryInternal(sp, itemID, UUID.Zero, AttachmentPt);
|
||||
|
||||
if (att == null)
|
||||
DetachSingleAttachmentToInv(sp, itemID);
|
||||
|
||||
return att;
|
||||
return RezSingleAttachmentFromInventoryInternal(sp, itemID, UUID.Zero, AttachmentPt);
|
||||
}
|
||||
|
||||
public void RezMultipleAttachmentsFromInventory(IScenePresence sp, List<KeyValuePair<UUID, uint>> rezlist)
|
||||
@@ -397,18 +446,27 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
||||
m_scene.EventManager.TriggerOnAttach(so.LocalId, so.UUID, UUID.Zero);
|
||||
}
|
||||
|
||||
public void DetachSingleAttachmentToInv(IScenePresence sp, UUID itemID)
|
||||
public void DetachSingleAttachmentToInv(IScenePresence sp, SceneObjectGroup so)
|
||||
{
|
||||
lock (sp.AttachmentsSyncLock)
|
||||
{
|
||||
// Save avatar attachment information
|
||||
// m_log.Debug("[ATTACHMENTS MODULE]: Detaching from UserID: " + sp.UUID + ", ItemID: " + itemID);
|
||||
|
||||
bool changed = sp.Appearance.DetachAttachment(itemID);
|
||||
if (so.AttachedAvatar != sp.UUID)
|
||||
{
|
||||
m_log.WarnFormat(
|
||||
"[ATTACHMENTS MODULE]: Tried to detach object {0} from {1} {2} but attached avatar id was {3} in {4}",
|
||||
so.Name, sp.Name, sp.UUID, so.AttachedAvatar, m_scene.RegionInfo.RegionName);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
bool changed = sp.Appearance.DetachAttachment(so.FromItemID);
|
||||
if (changed && m_scene.AvatarFactory != null)
|
||||
m_scene.AvatarFactory.QueueAppearanceSave(sp.UUID);
|
||||
|
||||
DetachSingleAttachmentToInvInternal(sp, itemID);
|
||||
DetachSingleAttachmentToInvInternal(sp, so);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -460,7 +518,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
||||
/// </remarks>
|
||||
/// <param name="sp"></param>
|
||||
/// <param name="grp"></param>
|
||||
private void UpdateKnownItem(IScenePresence sp, SceneObjectGroup grp, bool saveAllScripted)
|
||||
/// <param name="saveAllScripted"></param>
|
||||
private void UpdateKnownItem(IScenePresence sp, SceneObjectGroup grp, string scriptedState)
|
||||
{
|
||||
// Saving attachments for NPCs messes them up for the real owner!
|
||||
INPCModule module = m_scene.RequestModuleInterface<INPCModule>();
|
||||
@@ -470,13 +529,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
||||
return;
|
||||
}
|
||||
|
||||
if (grp.HasGroupChanged || (saveAllScripted && grp.ContainsScripts()))
|
||||
if (grp.HasGroupChanged)
|
||||
{
|
||||
// m_log.DebugFormat(
|
||||
// "[ATTACHMENTS MODULE]: Updating asset for attachment {0}, attachpoint {1}",
|
||||
// grp.UUID, grp.AttachmentPoint);
|
||||
|
||||
string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp);
|
||||
string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp, scriptedState);
|
||||
|
||||
InventoryItemBase item = new InventoryItemBase(grp.FromItemID, sp.UUID);
|
||||
item = m_scene.InventoryService.GetItem(item);
|
||||
@@ -499,10 +558,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
||||
|
||||
m_scene.InventoryService.UpdateItem(item);
|
||||
|
||||
// this gets called when the agent logs off!
|
||||
// If the name of the object has been changed whilst attached then we want to update the inventory
|
||||
// item in the viewer.
|
||||
if (sp.ControllingClient != null)
|
||||
sp.ControllingClient.SendInventoryItemCreateUpdate(item, 0);
|
||||
}
|
||||
|
||||
grp.HasGroupChanged = false; // Prevent it being saved over and over
|
||||
}
|
||||
// else
|
||||
@@ -600,11 +661,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
||||
// "[ATTACHMENTS MODULE]: Called AddSceneObjectAsAttachment for object {0} {1} for {2}",
|
||||
// grp.Name, grp.LocalId, remoteClient.Name);
|
||||
|
||||
InventoryItemBase newItem = m_invAccessModule.CopyToInventory(
|
||||
DeRezAction.TakeCopy,
|
||||
m_scene.InventoryService.GetFolderForType(sp.UUID, AssetType.Object).ID,
|
||||
new List<SceneObjectGroup> { grp },
|
||||
sp.ControllingClient, true)[0];
|
||||
InventoryItemBase newItem
|
||||
= m_invAccessModule.CopyToInventory(
|
||||
DeRezAction.TakeCopy,
|
||||
m_scene.InventoryService.GetFolderForType(sp.UUID, AssetType.Object).ID,
|
||||
new List<SceneObjectGroup> { grp },
|
||||
sp.ControllingClient, true)[0];
|
||||
|
||||
// sets itemID so client can show item as 'attached' in inventory
|
||||
grp.FromItemID = newItem.ID;
|
||||
@@ -612,46 +674,68 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
||||
return newItem;
|
||||
}
|
||||
|
||||
// What makes this method odd and unique is it tries to detach using an UUID.... Yay for standards.
|
||||
// To LocalId or UUID, *THAT* is the question. How now Brown UUID??
|
||||
private void DetachSingleAttachmentToInvInternal(IScenePresence sp, UUID itemID)
|
||||
private string GetObjectScriptStates(SceneObjectGroup grp)
|
||||
{
|
||||
using (StringWriter sw = new StringWriter())
|
||||
{
|
||||
using (XmlTextWriter writer = new XmlTextWriter(sw))
|
||||
{
|
||||
grp.SaveScriptedState(writer);
|
||||
}
|
||||
|
||||
return sw.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateDetachedObject(IScenePresence sp, SceneObjectGroup so)
|
||||
{
|
||||
// Don't save attachments for HG visitors, it
|
||||
// messes up their inventory. When a HG visitor logs
|
||||
// out on a foreign grid, their attachments will be
|
||||
// reloaded in the state they were in when they left
|
||||
// the home grid. This is best anyway as the visited
|
||||
// grid may use an incompatible script engine.
|
||||
bool saveChanged
|
||||
= sp.PresenceType != PresenceType.Npc
|
||||
&& (m_scene.UserManagementModule == null
|
||||
|| m_scene.UserManagementModule.IsLocalGridUser(sp.UUID));
|
||||
|
||||
// Scripts MUST be snapshotted before the object is
|
||||
// removed from the scene because doing otherwise will
|
||||
// clobber the run flag
|
||||
string scriptedState = GetObjectScriptStates(so);
|
||||
|
||||
// Remove the object from the scene so no more updates
|
||||
// are sent. Doing this before the below changes will ensure
|
||||
// updates can't cause "HUD artefacts"
|
||||
m_scene.DeleteSceneObject(so, false, false);
|
||||
|
||||
// Prepare sog for storage
|
||||
so.AttachedAvatar = UUID.Zero;
|
||||
so.RootPart.SetParentLocalId(0);
|
||||
so.IsAttachment = false;
|
||||
|
||||
if (saveChanged)
|
||||
{
|
||||
// We cannot use AbsolutePosition here because that would
|
||||
// attempt to cross the prim as it is detached
|
||||
so.ForEachPart(x => { x.GroupPosition = so.RootPart.AttachedPos; });
|
||||
|
||||
UpdateKnownItem(sp, so, scriptedState);
|
||||
}
|
||||
|
||||
// Now, remove the scripts
|
||||
so.RemoveScriptInstances(true);
|
||||
}
|
||||
|
||||
private void DetachSingleAttachmentToInvInternal(IScenePresence sp, SceneObjectGroup so)
|
||||
{
|
||||
// m_log.DebugFormat("[ATTACHMENTS MODULE]: Detaching item {0} to inventory for {1}", itemID, sp.Name);
|
||||
|
||||
if (itemID == UUID.Zero) // If this happened, someone made a mistake....
|
||||
return;
|
||||
m_scene.EventManager.TriggerOnAttach(so.LocalId, so.FromItemID, UUID.Zero);
|
||||
sp.RemoveAttachment(so);
|
||||
|
||||
// We can NOT use the dictionries here, as we are looking
|
||||
// for an entity by the fromAssetID, which is NOT the prim UUID
|
||||
EntityBase[] detachEntities = m_scene.GetEntities();
|
||||
SceneObjectGroup group;
|
||||
|
||||
lock (sp.AttachmentsSyncLock)
|
||||
{
|
||||
foreach (EntityBase entity in detachEntities)
|
||||
{
|
||||
if (entity is SceneObjectGroup)
|
||||
{
|
||||
group = (SceneObjectGroup)entity;
|
||||
if (group.FromItemID == itemID)
|
||||
{
|
||||
m_scene.EventManager.TriggerOnAttach(group.LocalId, itemID, UUID.Zero);
|
||||
sp.RemoveAttachment(group);
|
||||
m_scene.DeleteSceneObject(group, false);
|
||||
|
||||
// Prepare sog for storage
|
||||
group.AttachedAvatar = UUID.Zero;
|
||||
group.RootPart.SetParentLocalId(0);
|
||||
group.IsAttachment = false;
|
||||
group.AbsolutePosition = group.RootPart.AttachedPos;
|
||||
|
||||
UpdateKnownItem(sp, group, true);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
UpdateDetachedObject(sp, so);
|
||||
}
|
||||
|
||||
private SceneObjectGroup RezSingleAttachmentFromInventoryInternal(
|
||||
@@ -673,18 +757,23 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
||||
null, assetID, Vector3.Zero, Vector3.Zero, UUID.Zero, (byte)1, true,
|
||||
false, false, sp.UUID, true);
|
||||
|
||||
// m_log.DebugFormat(
|
||||
// "[ATTACHMENTS MODULE]: Retrieved single object {0} for attachment to {1} on point {2}",
|
||||
// objatt.Name, remoteClient.Name, AttachmentPt);
|
||||
|
||||
if (objatt != null)
|
||||
{
|
||||
// m_log.DebugFormat(
|
||||
// "[ATTACHMENTS MODULE]: Rezzed single object {0} for attachment to {1} on point {2} in {3}",
|
||||
// objatt.Name, sp.Name, attachmentPt, m_scene.Name);
|
||||
|
||||
// HasGroupChanged is being set from within RezObject. Ideally it would be set by the caller.
|
||||
objatt.HasGroupChanged = false;
|
||||
bool tainted = false;
|
||||
if (attachmentPt != 0 && attachmentPt != objatt.AttachmentPoint)
|
||||
tainted = true;
|
||||
|
||||
// FIXME: Detect whether it's really likely for AttachObject to throw an exception in the normal
|
||||
// course of events. If not, then it's probably not worth trying to recover the situation
|
||||
// since this is more likely to trigger further exceptions and confuse later debugging. If
|
||||
// exceptions can be thrown in expected error conditions (not NREs) then make this consistent
|
||||
// since other normal error conditions will simply return false instead.
|
||||
// This will throw if the attachment fails
|
||||
try
|
||||
{
|
||||
@@ -755,7 +844,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
||||
item = m_scene.InventoryService.GetItem(item);
|
||||
bool changed = sp.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID);
|
||||
if (changed && m_scene.AvatarFactory != null)
|
||||
{
|
||||
// m_log.DebugFormat(
|
||||
// "[ATTACHMENTS MODULE]: Queueing appearance save for {0}, attachment {1} point {2} in ShowAttachInUserInventory()",
|
||||
// sp.Name, att.Name, AttachmentPt);
|
||||
|
||||
m_scene.AvatarFactory.QueueAppearanceSave(sp.UUID);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -859,8 +954,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
||||
|
||||
ScenePresence sp = m_scene.GetScenePresence(remoteClient.AgentId);
|
||||
SceneObjectGroup group = m_scene.GetGroupByPrim(objectLocalID);
|
||||
|
||||
if (sp != null && group != null)
|
||||
DetachSingleAttachmentToInv(sp, group.FromItemID);
|
||||
DetachSingleAttachmentToInv(sp, group);
|
||||
}
|
||||
|
||||
private void Client_OnDetachAttachmentIntoInv(UUID itemID, IClientAPI remoteClient)
|
||||
@@ -870,7 +966,21 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
||||
|
||||
ScenePresence sp = m_scene.GetScenePresence(remoteClient.AgentId);
|
||||
if (sp != null)
|
||||
DetachSingleAttachmentToInv(sp, itemID);
|
||||
{
|
||||
lock (sp.AttachmentsSyncLock)
|
||||
{
|
||||
List<SceneObjectGroup> attachments = sp.GetAttachments();
|
||||
|
||||
foreach (SceneObjectGroup group in attachments)
|
||||
{
|
||||
if (group.FromItemID == itemID)
|
||||
{
|
||||
DetachSingleAttachmentToInv(sp, group);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void Client_OnObjectDrop(uint soLocalId, IClientAPI remoteClient)
|
||||
|
||||
@@ -31,6 +31,7 @@ using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Timers;
|
||||
using System.Xml;
|
||||
using Timer=System.Timers.Timer;
|
||||
using Nini.Config;
|
||||
using NUnit.Framework;
|
||||
@@ -38,11 +39,17 @@ using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Communications;
|
||||
using OpenSim.Region.CoreModules.Avatar.Attachments;
|
||||
using OpenSim.Region.CoreModules.Framework;
|
||||
using OpenSim.Region.CoreModules.Framework.EntityTransfer;
|
||||
using OpenSim.Region.CoreModules.Framework.InventoryAccess;
|
||||
using OpenSim.Region.CoreModules.World.Serialiser;
|
||||
using OpenSim.Region.CoreModules.Scripting.WorldComm;
|
||||
using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation;
|
||||
using OpenSim.Region.CoreModules.World.Serialiser;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
using OpenSim.Region.Framework.Interfaces;
|
||||
using OpenSim.Region.ScriptEngine.Interfaces;
|
||||
using OpenSim.Region.ScriptEngine.XEngine;
|
||||
using OpenSim.Services.Interfaces;
|
||||
using OpenSim.Tests.Common;
|
||||
using OpenSim.Tests.Common.Mock;
|
||||
|
||||
@@ -52,26 +59,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
|
||||
/// Attachment tests
|
||||
/// </summary>
|
||||
[TestFixture]
|
||||
public class AttachmentsModuleTests
|
||||
public class AttachmentsModuleTests : OpenSimTestCase
|
||||
{
|
||||
private Scene scene;
|
||||
private AttachmentsModule m_attMod;
|
||||
private ScenePresence m_presence;
|
||||
|
||||
/// <summary>
|
||||
/// Standard user ID
|
||||
/// </summary>
|
||||
private UUID m_userId = TestHelpers.ParseTail(0x1);
|
||||
|
||||
// /// <summary>
|
||||
// /// Standard attachment item ID
|
||||
// /// </summary>
|
||||
// private UUID m_attItemId = TestHelpers.ParseTail(0x10);
|
||||
//
|
||||
// /// <summary>
|
||||
// /// Standard attachment asset ID
|
||||
// /// </summary>
|
||||
// private UUID m_attAssetId = TestHelpers.ParseTail(0x11);
|
||||
private AutoResetEvent m_chatEvent = new AutoResetEvent(false);
|
||||
private OSChatMessage m_osChatMessageReceived;
|
||||
|
||||
[TestFixtureSetUp]
|
||||
public void FixtureInit()
|
||||
@@ -80,18 +71,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
|
||||
Util.FireAndForgetMethod = FireAndForgetMethod.None;
|
||||
}
|
||||
|
||||
[SetUp]
|
||||
public void Init()
|
||||
{
|
||||
IConfigSource config = new IniConfigSource();
|
||||
config.AddConfig("Modules");
|
||||
config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule");
|
||||
|
||||
scene = new SceneHelpers().SetupScene();
|
||||
m_attMod = new AttachmentsModule();
|
||||
SceneHelpers.SetupSceneModules(scene, config, m_attMod, new BasicInventoryAccessModule());
|
||||
}
|
||||
|
||||
[TestFixtureTearDown]
|
||||
public void TearDown()
|
||||
{
|
||||
@@ -100,6 +79,76 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
|
||||
Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod;
|
||||
}
|
||||
|
||||
private void OnChatFromWorld(object sender, OSChatMessage oscm)
|
||||
{
|
||||
// Console.WriteLine("Got chat [{0}]", oscm.Message);
|
||||
|
||||
m_osChatMessageReceived = oscm;
|
||||
m_chatEvent.Set();
|
||||
}
|
||||
|
||||
private Scene CreateTestScene()
|
||||
{
|
||||
IConfigSource config = new IniConfigSource();
|
||||
List<object> modules = new List<object>();
|
||||
|
||||
AddCommonConfig(config, modules);
|
||||
|
||||
Scene scene
|
||||
= new SceneHelpers().SetupScene(
|
||||
"attachments-test-scene", TestHelpers.ParseTail(999), 1000, 1000, config);
|
||||
SceneHelpers.SetupSceneModules(scene, config, modules.ToArray());
|
||||
|
||||
return scene;
|
||||
}
|
||||
|
||||
private Scene CreateScriptingEnabledTestScene()
|
||||
{
|
||||
IConfigSource config = new IniConfigSource();
|
||||
List<object> modules = new List<object>();
|
||||
|
||||
AddCommonConfig(config, modules);
|
||||
AddScriptingConfig(config, modules);
|
||||
|
||||
Scene scene
|
||||
= new SceneHelpers().SetupScene(
|
||||
"attachments-test-scene", TestHelpers.ParseTail(999), 1000, 1000, config);
|
||||
SceneHelpers.SetupSceneModules(scene, config, modules.ToArray());
|
||||
|
||||
scene.StartScripts();
|
||||
|
||||
return scene;
|
||||
}
|
||||
|
||||
private void AddCommonConfig(IConfigSource config, List<object> modules)
|
||||
{
|
||||
config.AddConfig("Modules");
|
||||
config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule");
|
||||
|
||||
modules.Add(new AttachmentsModule());
|
||||
modules.Add(new BasicInventoryAccessModule());
|
||||
}
|
||||
|
||||
private void AddScriptingConfig(IConfigSource config, List<object> modules)
|
||||
{
|
||||
IConfig startupConfig = config.AddConfig("Startup");
|
||||
startupConfig.Set("DefaultScriptEngine", "XEngine");
|
||||
|
||||
IConfig xEngineConfig = config.AddConfig("XEngine");
|
||||
xEngineConfig.Set("Enabled", "true");
|
||||
xEngineConfig.Set("StartDelay", "0");
|
||||
|
||||
// These tests will not run with AppDomainLoading = true, at least on mono. For unknown reasons, the call
|
||||
// to AssemblyResolver.OnAssemblyResolve fails.
|
||||
xEngineConfig.Set("AppDomainLoading", "false");
|
||||
|
||||
modules.Add(new XEngine());
|
||||
|
||||
// Necessary to stop serialization complaining
|
||||
// FIXME: Stop this being necessary if at all possible
|
||||
// modules.Add(new WorldCommModule());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates an attachment item in the given user's inventory. Does not attach.
|
||||
/// </summary>
|
||||
@@ -109,11 +158,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
|
||||
/// <returns>
|
||||
/// The attachment item.
|
||||
/// </returns>
|
||||
/// <param name='scene'></param>
|
||||
/// <param name='userId'></param>
|
||||
/// <param name='attName'></param>
|
||||
/// <param name='rawItemId'></param>
|
||||
/// <param name='rawAssetId'></param>
|
||||
private InventoryItemBase CreateAttachmentItem(UUID userId, string attName, int rawItemId, int rawAssetId)
|
||||
private InventoryItemBase CreateAttachmentItem(
|
||||
Scene scene, UUID userId, string attName, int rawItemId, int rawAssetId)
|
||||
{
|
||||
return UserInventoryHelpers.CreateInventoryItem(
|
||||
scene,
|
||||
@@ -130,18 +181,19 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
|
||||
TestHelpers.InMethod();
|
||||
// TestHelpers.EnableLogging();
|
||||
|
||||
UserAccountHelpers.CreateUserWithInventory(scene, m_userId);
|
||||
m_presence = SceneHelpers.AddScenePresence(scene, m_userId);
|
||||
Scene scene = CreateTestScene();
|
||||
UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1);
|
||||
ScenePresence sp = SceneHelpers.AddScenePresence(scene, ua1);
|
||||
|
||||
string attName = "att";
|
||||
|
||||
SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, attName, m_presence.UUID).ParentGroup;
|
||||
SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, attName, sp.UUID);
|
||||
|
||||
m_attMod.AttachObject(m_presence, so, (uint)AttachmentPoint.Chest, false);
|
||||
scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Chest, false);
|
||||
|
||||
// Check status on scene presence
|
||||
Assert.That(m_presence.HasAttachments(), Is.True);
|
||||
List<SceneObjectGroup> attachments = m_presence.GetAttachments();
|
||||
Assert.That(sp.HasAttachments(), Is.True);
|
||||
List<SceneObjectGroup> attachments = sp.GetAttachments();
|
||||
Assert.That(attachments.Count, Is.EqualTo(1));
|
||||
SceneObjectGroup attSo = attachments[0];
|
||||
Assert.That(attSo.Name, Is.EqualTo(attName));
|
||||
@@ -152,36 +204,69 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
|
||||
|
||||
// Check item status
|
||||
Assert.That(
|
||||
m_presence.Appearance.GetAttachpoint(attSo.FromItemID),
|
||||
sp.Appearance.GetAttachpoint(attSo.FromItemID),
|
||||
Is.EqualTo((int)AttachmentPoint.Chest));
|
||||
|
||||
InventoryItemBase attachmentItem = scene.InventoryService.GetItem(new InventoryItemBase(attSo.FromItemID));
|
||||
Assert.That(attachmentItem, Is.Not.Null);
|
||||
Assert.That(attachmentItem.Name, Is.EqualTo(attName));
|
||||
|
||||
InventoryFolderBase targetFolder = scene.InventoryService.GetFolderForType(m_presence.UUID, AssetType.Object);
|
||||
InventoryFolderBase targetFolder = scene.InventoryService.GetFolderForType(sp.UUID, AssetType.Object);
|
||||
Assert.That(attachmentItem.Folder, Is.EqualTo(targetFolder.ID));
|
||||
|
||||
Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1));
|
||||
|
||||
// TestHelpers.DisableLogging();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test that we do not attempt to attach an in-world object that someone else is sitting on.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestAddAttachmentFromInventory()
|
||||
public void TestAddSatOnAttachmentFromGround()
|
||||
{
|
||||
TestHelpers.InMethod();
|
||||
// TestHelpers.EnableLogging();
|
||||
|
||||
Scene scene = CreateTestScene();
|
||||
UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1);
|
||||
ScenePresence sp = SceneHelpers.AddScenePresence(scene, ua1);
|
||||
|
||||
string attName = "att";
|
||||
|
||||
SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, attName, sp.UUID);
|
||||
|
||||
UserAccount ua2 = UserAccountHelpers.CreateUserWithInventory(scene, 0x2);
|
||||
ScenePresence sp2 = SceneHelpers.AddScenePresence(scene, ua2);
|
||||
|
||||
// Put avatar within 10m of the prim so that sit doesn't fail.
|
||||
sp2.AbsolutePosition = new Vector3(0, 0, 0);
|
||||
sp2.HandleAgentRequestSit(sp2.ControllingClient, sp2.UUID, so.UUID, Vector3.Zero);
|
||||
|
||||
scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Chest, false);
|
||||
|
||||
Assert.That(sp.HasAttachments(), Is.False);
|
||||
Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestRezAttachmentFromInventory()
|
||||
{
|
||||
TestHelpers.InMethod();
|
||||
// log4net.Config.XmlConfigurator.Configure();
|
||||
|
||||
UserAccountHelpers.CreateUserWithInventory(scene, m_userId);
|
||||
m_presence = SceneHelpers.AddScenePresence(scene, m_userId);
|
||||
Scene scene = CreateTestScene();
|
||||
UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1);
|
||||
ScenePresence sp = SceneHelpers.AddScenePresence(scene, ua1.PrincipalID);
|
||||
|
||||
InventoryItemBase attItem = CreateAttachmentItem(m_userId, "att", 0x10, 0x20);
|
||||
InventoryItemBase attItem = CreateAttachmentItem(scene, ua1.PrincipalID, "att", 0x10, 0x20);
|
||||
|
||||
m_attMod.RezSingleAttachmentFromInventory(
|
||||
m_presence, attItem.ID, (uint)AttachmentPoint.Chest);
|
||||
scene.AttachmentsModule.RezSingleAttachmentFromInventory(
|
||||
sp, attItem.ID, (uint)AttachmentPoint.Chest);
|
||||
|
||||
// Check scene presence status
|
||||
Assert.That(m_presence.HasAttachments(), Is.True);
|
||||
List<SceneObjectGroup> attachments = m_presence.GetAttachments();
|
||||
Assert.That(sp.HasAttachments(), Is.True);
|
||||
List<SceneObjectGroup> attachments = sp.GetAttachments();
|
||||
Assert.That(attachments.Count, Is.EqualTo(1));
|
||||
SceneObjectGroup attSo = attachments[0];
|
||||
Assert.That(attSo.Name, Is.EqualTo(attItem.Name));
|
||||
@@ -191,8 +276,51 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
|
||||
Assert.That(attSo.IsTemporary, Is.False);
|
||||
|
||||
// Check appearance status
|
||||
Assert.That(m_presence.Appearance.GetAttachments().Count, Is.EqualTo(1));
|
||||
Assert.That(m_presence.Appearance.GetAttachpoint(attItem.ID), Is.EqualTo((int)AttachmentPoint.Chest));
|
||||
Assert.That(sp.Appearance.GetAttachments().Count, Is.EqualTo(1));
|
||||
Assert.That(sp.Appearance.GetAttachpoint(attItem.ID), Is.EqualTo((int)AttachmentPoint.Chest));
|
||||
|
||||
Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test specific conditions associated with rezzing a scripted attachment from inventory.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestRezScriptedAttachmentFromInventory()
|
||||
{
|
||||
TestHelpers.InMethod();
|
||||
|
||||
Scene scene = CreateScriptingEnabledTestScene();
|
||||
UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1);
|
||||
ScenePresence sp = SceneHelpers.AddScenePresence(scene, ua1);
|
||||
|
||||
SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, sp.UUID, "att-name", 0x10);
|
||||
TaskInventoryItem scriptItem
|
||||
= TaskInventoryHelpers.AddScript(
|
||||
scene,
|
||||
so.RootPart,
|
||||
"scriptItem",
|
||||
"default { attach(key id) { if (id != NULL_KEY) { llSay(0, \"Hello World\"); } } }");
|
||||
|
||||
InventoryItemBase userItem = UserInventoryHelpers.AddInventoryItem(scene, so, 0x100, 0x1000);
|
||||
|
||||
// FIXME: Right now, we have to do a tricksy chat listen to make sure we know when the script is running.
|
||||
// In the future, we need to be able to do this programatically more predicably.
|
||||
scene.EventManager.OnChatFromWorld += OnChatFromWorld;
|
||||
|
||||
scene.AttachmentsModule.RezSingleAttachmentFromInventory(sp, userItem.ID, (uint)AttachmentPoint.Chest);
|
||||
|
||||
m_chatEvent.WaitOne(60000);
|
||||
|
||||
// TODO: Need to have a test that checks the script is actually started but this involves a lot more
|
||||
// plumbing of the script engine and either pausing for events or more infrastructure to turn off various
|
||||
// script engine delays/asychronicity that isn't helpful in an automated regression testing context.
|
||||
SceneObjectGroup attSo = scene.GetSceneObjectGroup(so.Name);
|
||||
Assert.That(attSo.ContainsScripts(), Is.True);
|
||||
|
||||
TaskInventoryItem reRezzedScriptItem = attSo.RootPart.Inventory.GetInventoryItem(scriptItem.Name);
|
||||
IScriptModule xengine = scene.RequestModuleInterface<IScriptModule>();
|
||||
Assert.That(xengine.GetScriptState(reRezzedScriptItem.ItemID), Is.True);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -201,23 +329,24 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
|
||||
TestHelpers.InMethod();
|
||||
// log4net.Config.XmlConfigurator.Configure();
|
||||
|
||||
UserAccountHelpers.CreateUserWithInventory(scene, m_userId);
|
||||
m_presence = SceneHelpers.AddScenePresence(scene, m_userId);
|
||||
Scene scene = CreateTestScene();
|
||||
UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1);
|
||||
ScenePresence sp = SceneHelpers.AddScenePresence(scene, ua1.PrincipalID);
|
||||
|
||||
InventoryItemBase attItem = CreateAttachmentItem(m_userId, "att", 0x10, 0x20);
|
||||
InventoryItemBase attItem = CreateAttachmentItem(scene, ua1.PrincipalID, "att", 0x10, 0x20);
|
||||
|
||||
ISceneEntity so
|
||||
= m_attMod.RezSingleAttachmentFromInventory(
|
||||
m_presence, attItem.ID, (uint)AttachmentPoint.Chest);
|
||||
m_attMod.DetachSingleAttachmentToGround(m_presence, so.LocalId);
|
||||
= scene.AttachmentsModule.RezSingleAttachmentFromInventory(
|
||||
sp, attItem.ID, (uint)AttachmentPoint.Chest);
|
||||
scene.AttachmentsModule.DetachSingleAttachmentToGround(sp, so.LocalId);
|
||||
|
||||
// Check scene presence status
|
||||
Assert.That(m_presence.HasAttachments(), Is.False);
|
||||
List<SceneObjectGroup> attachments = m_presence.GetAttachments();
|
||||
Assert.That(sp.HasAttachments(), Is.False);
|
||||
List<SceneObjectGroup> attachments = sp.GetAttachments();
|
||||
Assert.That(attachments.Count, Is.EqualTo(0));
|
||||
|
||||
// Check appearance status
|
||||
Assert.That(m_presence.Appearance.GetAttachments().Count, Is.EqualTo(0));
|
||||
Assert.That(sp.Appearance.GetAttachments().Count, Is.EqualTo(0));
|
||||
|
||||
// Check item status
|
||||
Assert.That(scene.InventoryService.GetItem(new InventoryItemBase(attItem.ID)), Is.Null);
|
||||
@@ -230,24 +359,86 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
|
||||
public void TestDetachAttachmentToInventory()
|
||||
{
|
||||
TestHelpers.InMethod();
|
||||
// log4net.Config.XmlConfigurator.Configure();
|
||||
|
||||
UserAccountHelpers.CreateUserWithInventory(scene, m_userId);
|
||||
m_presence = SceneHelpers.AddScenePresence(scene, m_userId);
|
||||
Scene scene = CreateTestScene();
|
||||
UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1);
|
||||
ScenePresence sp = SceneHelpers.AddScenePresence(scene, ua1.PrincipalID);
|
||||
|
||||
InventoryItemBase attItem = CreateAttachmentItem(m_userId, "att", 0x10, 0x20);
|
||||
InventoryItemBase attItem = CreateAttachmentItem(scene, ua1.PrincipalID, "att", 0x10, 0x20);
|
||||
|
||||
m_attMod.RezSingleAttachmentFromInventory(
|
||||
m_presence, attItem.ID, (uint)AttachmentPoint.Chest);
|
||||
m_attMod.DetachSingleAttachmentToInv(m_presence, attItem.ID);
|
||||
SceneObjectGroup so
|
||||
= (SceneObjectGroup)scene.AttachmentsModule.RezSingleAttachmentFromInventory(
|
||||
sp, attItem.ID, (uint)AttachmentPoint.Chest);
|
||||
scene.AttachmentsModule.DetachSingleAttachmentToInv(sp, so);
|
||||
|
||||
// Check status on scene presence
|
||||
Assert.That(m_presence.HasAttachments(), Is.False);
|
||||
List<SceneObjectGroup> attachments = m_presence.GetAttachments();
|
||||
Assert.That(sp.HasAttachments(), Is.False);
|
||||
List<SceneObjectGroup> attachments = sp.GetAttachments();
|
||||
Assert.That(attachments.Count, Is.EqualTo(0));
|
||||
|
||||
// Check item status
|
||||
Assert.That(m_presence.Appearance.GetAttachpoint(attItem.ID), Is.EqualTo(0));
|
||||
Assert.That(sp.Appearance.GetAttachpoint(attItem.ID), Is.EqualTo(0));
|
||||
|
||||
Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(0));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test specific conditions associated with detaching a scripted attachment from inventory.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestDetachScriptedAttachmentToInventory()
|
||||
{
|
||||
TestHelpers.InMethod();
|
||||
// TestHelpers.EnableLogging();
|
||||
|
||||
Scene scene = CreateScriptingEnabledTestScene();
|
||||
UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1);
|
||||
ScenePresence sp = SceneHelpers.AddScenePresence(scene, ua1);
|
||||
|
||||
SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, sp.UUID, "att-name", 0x10);
|
||||
TaskInventoryItem scriptTaskItem
|
||||
= TaskInventoryHelpers.AddScript(
|
||||
scene,
|
||||
so.RootPart,
|
||||
"scriptItem",
|
||||
"default { attach(key id) { if (id != NULL_KEY) { llSay(0, \"Hello World\"); } } }");
|
||||
|
||||
InventoryItemBase userItem = UserInventoryHelpers.AddInventoryItem(scene, so, 0x100, 0x1000);
|
||||
|
||||
// FIXME: Right now, we have to do a tricksy chat listen to make sure we know when the script is running.
|
||||
// In the future, we need to be able to do this programatically more predicably.
|
||||
scene.EventManager.OnChatFromWorld += OnChatFromWorld;
|
||||
|
||||
SceneObjectGroup rezzedSo
|
||||
= scene.AttachmentsModule.RezSingleAttachmentFromInventory(sp, userItem.ID, (uint)AttachmentPoint.Chest);
|
||||
|
||||
// Wait for chat to signal rezzed script has been started.
|
||||
m_chatEvent.WaitOne(60000);
|
||||
|
||||
scene.AttachmentsModule.DetachSingleAttachmentToInv(sp, rezzedSo);
|
||||
|
||||
InventoryItemBase userItemUpdated = scene.InventoryService.GetItem(userItem);
|
||||
AssetBase asset = scene.AssetService.Get(userItemUpdated.AssetID.ToString());
|
||||
|
||||
// TODO: It would probably be better here to check script state via the saving and retrieval of state
|
||||
// information at a higher level, rather than having to inspect the serialization.
|
||||
XmlDocument soXml = new XmlDocument();
|
||||
soXml.LoadXml(Encoding.UTF8.GetString(asset.Data));
|
||||
|
||||
XmlNodeList scriptStateNodes = soXml.GetElementsByTagName("ScriptState");
|
||||
Assert.That(scriptStateNodes.Count, Is.EqualTo(1));
|
||||
|
||||
// Re-rez the attachment to check script running state
|
||||
SceneObjectGroup reRezzedSo = scene.AttachmentsModule.RezSingleAttachmentFromInventory(sp, userItem.ID, (uint)AttachmentPoint.Chest);
|
||||
|
||||
// Wait for chat to signal rezzed script has been started.
|
||||
m_chatEvent.WaitOne(60000);
|
||||
|
||||
TaskInventoryItem reRezzedScriptItem = reRezzedSo.RootPart.Inventory.GetInventoryItem(scriptTaskItem.Name);
|
||||
IScriptModule xengine = scene.RequestModuleInterface<IScriptModule>();
|
||||
Assert.That(xengine.GetScriptState(reRezzedScriptItem.ItemID), Is.True);
|
||||
|
||||
// Console.WriteLine(soXml.OuterXml);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -259,10 +450,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
|
||||
TestHelpers.InMethod();
|
||||
// log4net.Config.XmlConfigurator.Configure();
|
||||
|
||||
UserAccountHelpers.CreateUserWithInventory(scene, m_userId);
|
||||
InventoryItemBase attItem = CreateAttachmentItem(m_userId, "att", 0x10, 0x20);
|
||||
Scene scene = CreateTestScene();
|
||||
UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1);
|
||||
InventoryItemBase attItem = CreateAttachmentItem(scene, ua1.PrincipalID, "att", 0x10, 0x20);
|
||||
|
||||
AgentCircuitData acd = SceneHelpers.GenerateAgentData(m_userId);
|
||||
AgentCircuitData acd = SceneHelpers.GenerateAgentData(ua1.PrincipalID);
|
||||
acd.Appearance = new AvatarAppearance();
|
||||
acd.Appearance.SetAttachment((int)AttachmentPoint.Chest, attItem.ID, attItem.AssetID);
|
||||
ScenePresence presence = SceneHelpers.AddScenePresence(scene, acd);
|
||||
@@ -281,10 +473,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
|
||||
TestHelpers.InMethod();
|
||||
// log4net.Config.XmlConfigurator.Configure();
|
||||
|
||||
UserAccountHelpers.CreateUserWithInventory(scene, m_userId);
|
||||
InventoryItemBase attItem = CreateAttachmentItem(m_userId, "att", 0x10, 0x20);
|
||||
Scene scene = CreateTestScene();
|
||||
UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1);
|
||||
InventoryItemBase attItem = CreateAttachmentItem(scene, ua1.PrincipalID, "att", 0x10, 0x20);
|
||||
|
||||
AgentCircuitData acd = SceneHelpers.GenerateAgentData(m_userId);
|
||||
AgentCircuitData acd = SceneHelpers.GenerateAgentData(ua1.PrincipalID);
|
||||
acd.Appearance = new AvatarAppearance();
|
||||
acd.Appearance.SetAttachment((int)AttachmentPoint.Chest, attItem.ID, attItem.AssetID);
|
||||
ScenePresence presence = SceneHelpers.AddScenePresence(scene, acd);
|
||||
@@ -307,6 +500,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
|
||||
Assert.That(retreivedAttachments[0].ItemID, Is.EqualTo(attItem.ID));
|
||||
Assert.That(retreivedAttachments[0].AssetID, Is.EqualTo(attItem.AssetID));
|
||||
Assert.That(presence.Appearance.GetAttachpoint(attItem.ID), Is.EqualTo((int)AttachmentPoint.Chest));
|
||||
|
||||
Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1));
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -314,10 +509,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
|
||||
{
|
||||
TestHelpers.InMethod();
|
||||
|
||||
UserAccountHelpers.CreateUserWithInventory(scene, m_userId);
|
||||
InventoryItemBase attItem = CreateAttachmentItem(m_userId, "att", 0x10, 0x20);
|
||||
Scene scene = CreateTestScene();
|
||||
UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1);
|
||||
InventoryItemBase attItem = CreateAttachmentItem(scene, ua1.PrincipalID, "att", 0x10, 0x20);
|
||||
|
||||
AgentCircuitData acd = SceneHelpers.GenerateAgentData(m_userId);
|
||||
AgentCircuitData acd = SceneHelpers.GenerateAgentData(ua1.PrincipalID);
|
||||
acd.Appearance = new AvatarAppearance();
|
||||
acd.Appearance.SetAttachment((int)AttachmentPoint.Chest, attItem.ID, attItem.AssetID);
|
||||
ScenePresence sp = SceneHelpers.AddScenePresence(scene, acd);
|
||||
@@ -332,6 +528,96 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
|
||||
Assert.That(attSo.RootPart.AttachedPos, Is.EqualTo(newPosition));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSameSimulatorNeighbouringRegionsTeleport()
|
||||
{
|
||||
TestHelpers.InMethod();
|
||||
// TestHelpers.EnableLogging();
|
||||
|
||||
AttachmentsModule attModA = new AttachmentsModule();
|
||||
AttachmentsModule attModB = new AttachmentsModule();
|
||||
EntityTransferModule etmA = new EntityTransferModule();
|
||||
EntityTransferModule etmB = new EntityTransferModule();
|
||||
LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();
|
||||
|
||||
IConfigSource config = new IniConfigSource();
|
||||
IConfig modulesConfig = config.AddConfig("Modules");
|
||||
modulesConfig.Set("EntityTransferModule", etmA.Name);
|
||||
modulesConfig.Set("SimulationServices", lscm.Name);
|
||||
IConfig entityTransferConfig = config.AddConfig("EntityTransfer");
|
||||
|
||||
// In order to run a single threaded regression test we do not want the entity transfer module waiting
|
||||
// for a callback from the destination scene before removing its avatar data.
|
||||
entityTransferConfig.Set("wait_for_callback", false);
|
||||
|
||||
modulesConfig.Set("InventoryAccessModule", "BasicInventoryAccessModule");
|
||||
|
||||
SceneHelpers sh = new SceneHelpers();
|
||||
TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
|
||||
TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1001, 1000);
|
||||
|
||||
SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);
|
||||
SceneHelpers.SetupSceneModules(
|
||||
sceneA, config, new CapabilitiesModule(), etmA, attModA, new BasicInventoryAccessModule());
|
||||
SceneHelpers.SetupSceneModules(
|
||||
sceneB, config, new CapabilitiesModule(), etmB, attModB, new BasicInventoryAccessModule());
|
||||
|
||||
UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(sceneA, 0x1);
|
||||
ScenePresence beforeTeleportSp = SceneHelpers.AddScenePresence(sceneA, ua1.PrincipalID, sh.SceneManager);
|
||||
beforeTeleportSp.AbsolutePosition = new Vector3(30, 31, 32);
|
||||
|
||||
InventoryItemBase attItem = CreateAttachmentItem(sceneA, ua1.PrincipalID, "att", 0x10, 0x20);
|
||||
|
||||
sceneA.AttachmentsModule.RezSingleAttachmentFromInventory(
|
||||
beforeTeleportSp, attItem.ID, (uint)AttachmentPoint.Chest);
|
||||
|
||||
Vector3 teleportPosition = new Vector3(10, 11, 12);
|
||||
Vector3 teleportLookAt = new Vector3(20, 21, 22);
|
||||
|
||||
sceneA.RequestTeleportLocation(
|
||||
beforeTeleportSp.ControllingClient,
|
||||
sceneB.RegionInfo.RegionHandle,
|
||||
teleportPosition,
|
||||
teleportLookAt,
|
||||
(uint)TeleportFlags.ViaLocation);
|
||||
|
||||
((TestClient)beforeTeleportSp.ControllingClient).CompleteTeleportClientSide();
|
||||
|
||||
// Check attachments have made it into sceneB
|
||||
ScenePresence afterTeleportSceneBSp = sceneB.GetScenePresence(ua1.PrincipalID);
|
||||
|
||||
// This is appearance data, as opposed to actually rezzed attachments
|
||||
List<AvatarAttachment> sceneBAttachments = afterTeleportSceneBSp.Appearance.GetAttachments();
|
||||
Assert.That(sceneBAttachments.Count, Is.EqualTo(1));
|
||||
Assert.That(sceneBAttachments[0].AttachPoint, Is.EqualTo((int)AttachmentPoint.Chest));
|
||||
Assert.That(sceneBAttachments[0].ItemID, Is.EqualTo(attItem.ID));
|
||||
Assert.That(sceneBAttachments[0].AssetID, Is.EqualTo(attItem.AssetID));
|
||||
Assert.That(afterTeleportSceneBSp.Appearance.GetAttachpoint(attItem.ID), Is.EqualTo((int)AttachmentPoint.Chest));
|
||||
|
||||
// This is the actual attachment
|
||||
List<SceneObjectGroup> actualSceneBAttachments = afterTeleportSceneBSp.GetAttachments();
|
||||
Assert.That(actualSceneBAttachments.Count, Is.EqualTo(1));
|
||||
SceneObjectGroup actualSceneBAtt = actualSceneBAttachments[0];
|
||||
Assert.That(actualSceneBAtt.Name, Is.EqualTo(attItem.Name));
|
||||
Assert.That(actualSceneBAtt.AttachmentPoint, Is.EqualTo((uint)AttachmentPoint.Chest));
|
||||
|
||||
Assert.That(sceneB.GetSceneObjectGroups().Count, Is.EqualTo(1));
|
||||
|
||||
// Check attachments have been removed from sceneA
|
||||
ScenePresence afterTeleportSceneASp = sceneA.GetScenePresence(ua1.PrincipalID);
|
||||
|
||||
// Since this is appearance data, it is still present on the child avatar!
|
||||
List<AvatarAttachment> sceneAAttachments = afterTeleportSceneASp.Appearance.GetAttachments();
|
||||
Assert.That(sceneAAttachments.Count, Is.EqualTo(1));
|
||||
Assert.That(afterTeleportSceneASp.Appearance.GetAttachpoint(attItem.ID), Is.EqualTo((int)AttachmentPoint.Chest));
|
||||
|
||||
// This is the actual attachment, which should no longer exist
|
||||
List<SceneObjectGroup> actualSceneAAttachments = afterTeleportSceneASp.GetAttachments();
|
||||
Assert.That(actualSceneAAttachments.Count, Is.EqualTo(0));
|
||||
|
||||
Assert.That(sceneA.GetSceneObjectGroups().Count, Is.EqualTo(0));
|
||||
}
|
||||
|
||||
// I'm commenting this test because scene setup NEEDS InventoryService to
|
||||
// be non-null
|
||||
//[Test]
|
||||
|
||||
@@ -66,11 +66,11 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
|
||||
scene.RegisterModuleInterface<IAvatarFactoryModule>(this);
|
||||
scene.EventManager.OnNewClient += SubscribeToClientEvents;
|
||||
|
||||
IConfig sconfig = config.Configs["Startup"];
|
||||
if (sconfig != null)
|
||||
IConfig appearanceConfig = config.Configs["Appearance"];
|
||||
if (appearanceConfig != null)
|
||||
{
|
||||
m_savetime = Convert.ToInt32(sconfig.GetString("DelayBeforeAppearanceSave",Convert.ToString(m_savetime)));
|
||||
m_sendtime = Convert.ToInt32(sconfig.GetString("DelayBeforeAppearanceSend",Convert.ToString(m_sendtime)));
|
||||
m_savetime = Convert.ToInt32(appearanceConfig.GetString("DelayBeforeAppearanceSave",Convert.ToString(m_savetime)));
|
||||
m_sendtime = Convert.ToInt32(appearanceConfig.GetString("DelayBeforeAppearanceSend",Convert.ToString(m_sendtime)));
|
||||
// m_log.InfoFormat("[AVFACTORY] configured for {0} save and {1} send",m_savetime,m_sendtime);
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ using Nini.Config;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Console;
|
||||
using OpenSim.Framework.Statistics;
|
||||
using OpenSim.Framework.Monitoring;
|
||||
using OpenSim.Region.Framework.Interfaces;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
|
||||
|
||||
@@ -96,7 +96,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Groups
|
||||
|
||||
scene.EventManager.OnNewClient += OnNewClient;
|
||||
scene.EventManager.OnClientClosed += OnClientClosed;
|
||||
scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage;
|
||||
// scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage;
|
||||
}
|
||||
|
||||
public void PostInitialise()
|
||||
@@ -133,7 +133,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Groups
|
||||
private void OnNewClient(IClientAPI client)
|
||||
{
|
||||
// Subscribe to instant messages
|
||||
client.OnInstantMessage += OnInstantMessage;
|
||||
// client.OnInstantMessage += OnInstantMessage;
|
||||
client.OnAgentDataUpdateRequest += OnAgentDataUpdateRequest;
|
||||
client.OnUUIDGroupNameRequest += HandleUUIDGroupNameRequest;
|
||||
lock (m_ClientMap)
|
||||
@@ -171,15 +171,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Groups
|
||||
ActiveGroupTitle);
|
||||
}
|
||||
|
||||
private void OnInstantMessage(IClientAPI client, GridInstantMessage im)
|
||||
{
|
||||
}
|
||||
// private void OnInstantMessage(IClientAPI client, GridInstantMessage im)
|
||||
// {
|
||||
// }
|
||||
|
||||
private void OnGridInstantMessage(GridInstantMessage msg)
|
||||
{
|
||||
// Trigger the above event handler
|
||||
OnInstantMessage(null, msg);
|
||||
}
|
||||
// private void OnGridInstantMessage(GridInstantMessage msg)
|
||||
// {
|
||||
// // Trigger the above event handler
|
||||
// OnInstantMessage(null, msg);
|
||||
// }
|
||||
|
||||
private void HandleUUIDGroupNameRequest(UUID id,IClientAPI remote_client)
|
||||
{
|
||||
|
||||
@@ -137,13 +137,15 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
|
||||
foreach (Scene scene in m_Scenes)
|
||||
{
|
||||
// m_log.DebugFormat(
|
||||
// "[INSTANT MESSAGE]: Looking for root agent {0} in {1}",
|
||||
// "[INSTANT MESSAGE]: Looking for root agent {0} in {1}",
|
||||
// toAgentID.ToString(), scene.RegionInfo.RegionName);
|
||||
|
||||
ScenePresence sp = scene.GetScenePresence(toAgentID);
|
||||
if (sp != null && !sp.IsChildAgent)
|
||||
{
|
||||
// Local message
|
||||
// m_log.DebugFormat("[INSTANT MESSAGE]: Delivering IM to root agent {0} {1}", user.Name, toAgentID);
|
||||
m_log.DebugFormat("[INSTANT MESSAGE]: Delivering IM to root agent {0} {1}", sp.Name, toAgentID);
|
||||
|
||||
sp.ControllingClient.SendInstantMessage(im);
|
||||
|
||||
// Message sent
|
||||
@@ -155,13 +157,15 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
|
||||
// try child avatar second
|
||||
foreach (Scene scene in m_Scenes)
|
||||
{
|
||||
// m_log.DebugFormat(
|
||||
// "[INSTANT MESSAGE]: Looking for child of {0} in {1}", toAgentID, scene.RegionInfo.RegionName);
|
||||
m_log.DebugFormat(
|
||||
"[INSTANT MESSAGE]: Looking for child of {0} in {1}", toAgentID, scene.RegionInfo.RegionName);
|
||||
|
||||
ScenePresence sp = scene.GetScenePresence(toAgentID);
|
||||
if (sp != null)
|
||||
{
|
||||
// Local message
|
||||
// m_log.DebugFormat("[INSTANT MESSAGE]: Delivering IM to child agent {0} {1}", user.Name, toAgentID);
|
||||
m_log.DebugFormat("[INSTANT MESSAGE]: Delivering IM to child agent {0} {1}", sp.Name, toAgentID);
|
||||
|
||||
sp.ControllingClient.SendInstantMessage(im);
|
||||
|
||||
// Message sent
|
||||
@@ -170,10 +174,9 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
|
||||
}
|
||||
}
|
||||
|
||||
// m_log.DebugFormat("[INSTANT MESSAGE]: Delivering IM to {0} via XMLRPC", im.toAgentID);
|
||||
SendGridInstantMessageViaXMLRPC(im, result);
|
||||
m_log.DebugFormat("[INSTANT MESSAGE]: Delivering IM to {0} via XMLRPC", im.toAgentID);
|
||||
|
||||
return;
|
||||
SendGridInstantMessageViaXMLRPC(im, result);
|
||||
}
|
||||
|
||||
private void HandleUndeliveredMessage(GridInstantMessage im, MessageResultNotification result)
|
||||
|
||||
@@ -48,7 +48,7 @@ using OpenSim.Tests.Common.Mock;
|
||||
namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
|
||||
{
|
||||
[TestFixture]
|
||||
public class InventoryArchiveTestCase
|
||||
public class InventoryArchiveTestCase : OpenSimTestCase
|
||||
{
|
||||
protected ManualResetEvent mre = new ManualResetEvent(false);
|
||||
|
||||
@@ -84,8 +84,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
|
||||
protected string m_coaItemName = "Coalesced Item";
|
||||
|
||||
[SetUp]
|
||||
public virtual void SetUp()
|
||||
public override void SetUp()
|
||||
{
|
||||
base.SetUp();
|
||||
m_iarStream = new MemoryStream(m_iarStreamBytes);
|
||||
}
|
||||
|
||||
|
||||
@@ -297,7 +297,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
|
||||
});
|
||||
}
|
||||
}
|
||||
else if (im.dialog == (byte) InstantMessageDialog.InventoryDeclined)
|
||||
else if (
|
||||
im.dialog == (byte)InstantMessageDialog.InventoryDeclined
|
||||
|| im.dialog == (byte)InstantMessageDialog.TaskInventoryDeclined)
|
||||
{
|
||||
// Here, the recipient is local and we can assume that the
|
||||
// inventory is loaded. Courtesy of the above bulk update,
|
||||
|
||||
@@ -709,6 +709,11 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
|
||||
agent.CallbackURI, region.RegionName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clean up operations once an agent has moved away through cross or teleport.
|
||||
/// </summary>
|
||||
/// <param name='sp'></param>
|
||||
/// <param name='logout'></param>
|
||||
protected virtual void AgentHasMovedAway(ScenePresence sp, bool logout)
|
||||
{
|
||||
if (sp.Scene.AttachmentsModule != null)
|
||||
|
||||
@@ -204,8 +204,9 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
|
||||
|
||||
AssetBase asset = m_Scene.CreateAsset(name, description, assetType, data, remoteClient.AgentId);
|
||||
m_Scene.AssetService.Store(asset);
|
||||
|
||||
m_Scene.CreateNewInventoryItem(remoteClient, remoteClient.AgentId.ToString(), string.Empty, folderID, asset.Name, 0, callbackID, asset, invType, nextOwnerMask, creationDate);
|
||||
m_Scene.CreateNewInventoryItem(
|
||||
remoteClient, remoteClient.AgentId.ToString(), string.Empty, folderID,
|
||||
name, description, 0, callbackID, asset, invType, nextOwnerMask, creationDate);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -39,7 +39,7 @@ using OpenSim.Region.Framework;
|
||||
using OpenSim.Region.Framework.Interfaces;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
|
||||
namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
||||
namespace OpenSim.Region.CoreModules.Framework.Statistics.Logging
|
||||
{
|
||||
[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "BinaryLoggingModule")]
|
||||
public class BinaryLoggingModule : INonSharedRegionModule
|
||||
|
||||
161
OpenSim/Region/CoreModules/Framework/Statistics/Logging/LogWriter.cs
Executable file
161
OpenSim/Region/CoreModules/Framework/Statistics/Logging/LogWriter.cs
Executable file
@@ -0,0 +1,161 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using log4net;
|
||||
|
||||
namespace OpenSim.Region.CoreModules.Framework.Statistics.Logging
|
||||
{
|
||||
/// <summary>
|
||||
/// Class for writing a high performance, high volume log file.
|
||||
/// Sometimes, to debug, one has a high volume logging to do and the regular
|
||||
/// log file output is not appropriate.
|
||||
/// Create a new instance with the parameters needed and
|
||||
/// call Write() to output a line. Call Close() when finished.
|
||||
/// If created with no parameters, it will not log anything.
|
||||
/// </summary>
|
||||
public class LogWriter : IDisposable
|
||||
{
|
||||
public bool Enabled { get; private set; }
|
||||
|
||||
private string m_logDirectory = ".";
|
||||
private int m_logMaxFileTimeMin = 5; // 5 minutes
|
||||
public String LogFileHeader { get; set; }
|
||||
|
||||
private StreamWriter m_logFile = null;
|
||||
private TimeSpan m_logFileLife;
|
||||
private DateTime m_logFileEndTime;
|
||||
private Object m_logFileWriteLock = new Object();
|
||||
|
||||
// set externally when debugging. If let 'null', this does not write any error messages.
|
||||
public ILog ErrorLogger = null;
|
||||
private string LogHeader = "[LOG WRITER]";
|
||||
|
||||
/// <summary>
|
||||
/// Create a log writer that will not write anything. Good for when not enabled
|
||||
/// but the write statements are still in the code.
|
||||
/// </summary>
|
||||
public LogWriter()
|
||||
{
|
||||
Enabled = false;
|
||||
m_logFile = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a log writer instance.
|
||||
/// </summary>
|
||||
/// <param name="dir">The directory to create the log file in. May be 'null' for default.</param>
|
||||
/// <param name="headr">The characters that begin the log file name. May be 'null' for default.</param>
|
||||
/// <param name="maxFileTime">Maximum age of a log file in minutes. If zero, will set default.</param>
|
||||
public LogWriter(string dir, string headr, int maxFileTime)
|
||||
{
|
||||
m_logDirectory = dir == null ? "." : dir;
|
||||
|
||||
LogFileHeader = headr == null ? "log-" : headr;
|
||||
|
||||
m_logMaxFileTimeMin = maxFileTime;
|
||||
if (m_logMaxFileTimeMin < 1)
|
||||
m_logMaxFileTimeMin = 5;
|
||||
|
||||
m_logFileLife = new TimeSpan(0, m_logMaxFileTimeMin, 0);
|
||||
m_logFileEndTime = DateTime.Now + m_logFileLife;
|
||||
|
||||
Enabled = true;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
this.Close();
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
Enabled = false;
|
||||
if (m_logFile != null)
|
||||
{
|
||||
m_logFile.Close();
|
||||
m_logFile.Dispose();
|
||||
m_logFile = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void Write(string line, params object[] args)
|
||||
{
|
||||
if (!Enabled) return;
|
||||
Write(String.Format(line, args));
|
||||
}
|
||||
|
||||
public void Write(string line)
|
||||
{
|
||||
if (!Enabled) return;
|
||||
try
|
||||
{
|
||||
lock (m_logFileWriteLock)
|
||||
{
|
||||
DateTime now = DateTime.Now;
|
||||
if (m_logFile == null || now > m_logFileEndTime)
|
||||
{
|
||||
if (m_logFile != null)
|
||||
{
|
||||
m_logFile.Close();
|
||||
m_logFile.Dispose();
|
||||
m_logFile = null;
|
||||
}
|
||||
|
||||
// First log file or time has expired, start writing to a new log file
|
||||
m_logFileEndTime = now + m_logFileLife;
|
||||
string path = (m_logDirectory.Length > 0 ? m_logDirectory
|
||||
+ System.IO.Path.DirectorySeparatorChar.ToString() : "")
|
||||
+ String.Format("{0}{1}.log", LogFileHeader, now.ToString("yyyyMMddHHmmss"));
|
||||
m_logFile = new StreamWriter(File.Open(path, FileMode.Append, FileAccess.Write));
|
||||
}
|
||||
if (m_logFile != null)
|
||||
{
|
||||
StringBuilder buff = new StringBuilder(line.Length + 25);
|
||||
buff.Append(now.ToString("yyyyMMddHHmmssfff"));
|
||||
// buff.Append(now.ToString("yyyyMMddHHmmss"));
|
||||
buff.Append(",");
|
||||
buff.Append(line);
|
||||
buff.Append("\r\n");
|
||||
m_logFile.Write(buff.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
if (ErrorLogger != null)
|
||||
{
|
||||
ErrorLogger.ErrorFormat("{0}: FAILURE WRITING TO LOGFILE: {1}", LogHeader, e);
|
||||
}
|
||||
Enabled = false;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -40,6 +40,7 @@ using OpenMetaverse;
|
||||
using OpenMetaverse.StructuredData;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Capabilities;
|
||||
using OpenSim.Framework.Monitoring;
|
||||
using OpenSim.Framework.Servers;
|
||||
using OpenSim.Region.Framework.Interfaces;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
|
||||
@@ -79,7 +79,6 @@
|
||||
<RegionModule id="AuthenticationServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Authentication.AuthenticationServiceInConnectorModule" />
|
||||
<RegionModule id="AccessModule" type="OpenSim.Region.CoreModules.World.AccessModule" /> \
|
||||
<RegionModule id="MapImageModule" type="OpenSim.Region.CoreModules.World.LegacyMap.MapImageModule" /> \
|
||||
<RegionModule id="Warp3DImageModule" type="OpenSim.Region.CoreModules.World.Warp3DMap.Warp3DImageModule" /> \
|
||||
|
||||
</Extension>
|
||||
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
using log4net.Config;
|
||||
using NUnit.Framework;
|
||||
using OpenMetaverse;
|
||||
using OpenMetaverse.Assets;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Region.CoreModules.Scripting.DynamicTexture;
|
||||
using OpenSim.Region.CoreModules.Scripting.VectorRender;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
using OpenSim.Region.Framework.Scenes.Serialization;
|
||||
using OpenSim.Tests.Common;
|
||||
using OpenSim.Tests.Common.Mock;
|
||||
|
||||
namespace OpenSim.Region.CoreModules.Scripting.VectorRender.Tests
|
||||
{
|
||||
[TestFixture]
|
||||
public class VectorRenderModuleTests
|
||||
{
|
||||
[Test]
|
||||
public void TestDraw()
|
||||
{
|
||||
TestHelpers.InMethod();
|
||||
|
||||
Scene scene = new SceneHelpers().SetupScene();
|
||||
DynamicTextureModule dtm = new DynamicTextureModule();
|
||||
VectorRenderModule vrm = new VectorRenderModule();
|
||||
SceneHelpers.SetupSceneModules(scene, dtm, vrm);
|
||||
|
||||
SceneObjectGroup so = SceneHelpers.AddSceneObject(scene);
|
||||
UUID originalTextureID = so.RootPart.Shape.Textures.GetFace(0).TextureID;
|
||||
|
||||
dtm.AddDynamicTextureData(
|
||||
scene.RegionInfo.RegionID,
|
||||
so.UUID,
|
||||
vrm.GetContentType(),
|
||||
"PenColour BLACK; MoveTo 40,220; FontSize 32; Text Hello World;",
|
||||
"",
|
||||
0);
|
||||
|
||||
|
||||
Assert.That(originalTextureID, Is.Not.EqualTo(so.RootPart.Shape.Textures.GetFace(0).TextureID));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -98,16 +98,18 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender
|
||||
public void GetDrawStringSize(string text, string fontName, int fontSize,
|
||||
out double xSize, out double ySize)
|
||||
{
|
||||
Font myFont = new Font(fontName, fontSize);
|
||||
SizeF stringSize = new SizeF();
|
||||
lock (m_graph) {
|
||||
stringSize = m_graph.MeasureString(text, myFont);
|
||||
xSize = stringSize.Width;
|
||||
ySize = stringSize.Height;
|
||||
using (Font myFont = new Font(fontName, fontSize))
|
||||
{
|
||||
SizeF stringSize = new SizeF();
|
||||
lock (m_graph)
|
||||
{
|
||||
stringSize = m_graph.MeasureString(text, myFont);
|
||||
xSize = stringSize.Width;
|
||||
ySize = stringSize.Height;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region IRegionModule Members
|
||||
@@ -121,6 +123,8 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender
|
||||
|
||||
if (m_graph == null)
|
||||
{
|
||||
// We won't dispose of these explicitly since this module is only removed when the entire simulator
|
||||
// is shut down.
|
||||
Bitmap bitmap = new Bitmap(1024, 1024, PixelFormat.Format32bppArgb);
|
||||
m_graph = Graphics.FromImage(bitmap);
|
||||
}
|
||||
@@ -299,53 +303,64 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender
|
||||
}
|
||||
}
|
||||
|
||||
Bitmap bitmap;
|
||||
|
||||
if (alpha == 256)
|
||||
{
|
||||
bitmap = new Bitmap(width, height, PixelFormat.Format32bppRgb);
|
||||
}
|
||||
else
|
||||
{
|
||||
bitmap = new Bitmap(width, height, PixelFormat.Format32bppArgb);
|
||||
}
|
||||
|
||||
Graphics graph = Graphics.FromImage(bitmap);
|
||||
|
||||
// this is really just to save people filling the
|
||||
// background color in their scripts, only do when fully opaque
|
||||
if (alpha >= 255)
|
||||
{
|
||||
graph.FillRectangle(new SolidBrush(bgColor), 0, 0, width, height);
|
||||
}
|
||||
|
||||
for (int w = 0; w < bitmap.Width; w++)
|
||||
{
|
||||
if (alpha <= 255)
|
||||
{
|
||||
for (int h = 0; h < bitmap.Height; h++)
|
||||
{
|
||||
bitmap.SetPixel(w, h, Color.FromArgb(alpha, bitmap.GetPixel(w, h)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GDIDraw(data, graph, altDataDelim);
|
||||
|
||||
byte[] imageJ2000 = new byte[0];
|
||||
Bitmap bitmap = null;
|
||||
Graphics graph = null;
|
||||
|
||||
try
|
||||
{
|
||||
imageJ2000 = OpenJPEG.EncodeFromImage(bitmap, true);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.ErrorFormat(
|
||||
"[VECTORRENDERMODULE]: OpenJpeg Encode Failed. Exception {0}{1}",
|
||||
e.Message, e.StackTrace);
|
||||
}
|
||||
if (alpha == 256)
|
||||
bitmap = new Bitmap(width, height, PixelFormat.Format32bppRgb);
|
||||
else
|
||||
bitmap = new Bitmap(width, height, PixelFormat.Format32bppArgb);
|
||||
|
||||
m_textureManager.ReturnData(id, imageJ2000);
|
||||
graph = Graphics.FromImage(bitmap);
|
||||
|
||||
// this is really just to save people filling the
|
||||
// background color in their scripts, only do when fully opaque
|
||||
if (alpha >= 255)
|
||||
{
|
||||
using (SolidBrush bgFillBrush = new SolidBrush(bgColor))
|
||||
{
|
||||
graph.FillRectangle(bgFillBrush, 0, 0, width, height);
|
||||
}
|
||||
}
|
||||
|
||||
for (int w = 0; w < bitmap.Width; w++)
|
||||
{
|
||||
if (alpha <= 255)
|
||||
{
|
||||
for (int h = 0; h < bitmap.Height; h++)
|
||||
{
|
||||
bitmap.SetPixel(w, h, Color.FromArgb(alpha, bitmap.GetPixel(w, h)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GDIDraw(data, graph, altDataDelim);
|
||||
|
||||
byte[] imageJ2000 = new byte[0];
|
||||
|
||||
try
|
||||
{
|
||||
imageJ2000 = OpenJPEG.EncodeFromImage(bitmap, true);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.ErrorFormat(
|
||||
"[VECTORRENDERMODULE]: OpenJpeg Encode Failed. Exception {0}{1}",
|
||||
e.Message, e.StackTrace);
|
||||
}
|
||||
|
||||
m_textureManager.ReturnData(id, imageJ2000);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (graph != null)
|
||||
graph.Dispose();
|
||||
|
||||
if (bitmap != null)
|
||||
bitmap.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
private int parseIntParam(string strInt)
|
||||
@@ -407,237 +422,289 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender
|
||||
{
|
||||
Point startPoint = new Point(0, 0);
|
||||
Point endPoint = new Point(0, 0);
|
||||
Pen drawPen = new Pen(Color.Black, 7);
|
||||
string fontName = m_fontName;
|
||||
float fontSize = 14;
|
||||
Font myFont = new Font(fontName, fontSize);
|
||||
SolidBrush myBrush = new SolidBrush(Color.Black);
|
||||
|
||||
char[] lineDelimiter = {dataDelim};
|
||||
char[] partsDelimiter = {','};
|
||||
string[] lines = data.Split(lineDelimiter);
|
||||
Pen drawPen = null;
|
||||
Font myFont = null;
|
||||
SolidBrush myBrush = null;
|
||||
|
||||
foreach (string line in lines)
|
||||
try
|
||||
{
|
||||
string nextLine = line.Trim();
|
||||
//replace with switch, or even better, do some proper parsing
|
||||
if (nextLine.StartsWith("MoveTo"))
|
||||
drawPen = new Pen(Color.Black, 7);
|
||||
string fontName = m_fontName;
|
||||
float fontSize = 14;
|
||||
myFont = new Font(fontName, fontSize);
|
||||
myBrush = new SolidBrush(Color.Black);
|
||||
|
||||
char[] lineDelimiter = {dataDelim};
|
||||
char[] partsDelimiter = {','};
|
||||
string[] lines = data.Split(lineDelimiter);
|
||||
|
||||
foreach (string line in lines)
|
||||
{
|
||||
float x = 0;
|
||||
float y = 0;
|
||||
GetParams(partsDelimiter, ref nextLine, 6, ref x, ref y);
|
||||
startPoint.X = (int) x;
|
||||
startPoint.Y = (int) y;
|
||||
}
|
||||
else if (nextLine.StartsWith("LineTo"))
|
||||
{
|
||||
float x = 0;
|
||||
float y = 0;
|
||||
GetParams(partsDelimiter, ref nextLine, 6, ref x, ref y);
|
||||
endPoint.X = (int) x;
|
||||
endPoint.Y = (int) y;
|
||||
graph.DrawLine(drawPen, startPoint, endPoint);
|
||||
startPoint.X = endPoint.X;
|
||||
startPoint.Y = endPoint.Y;
|
||||
}
|
||||
else if (nextLine.StartsWith("Text"))
|
||||
{
|
||||
nextLine = nextLine.Remove(0, 4);
|
||||
nextLine = nextLine.Trim();
|
||||
graph.DrawString(nextLine, myFont, myBrush, startPoint);
|
||||
}
|
||||
else if (nextLine.StartsWith("Image"))
|
||||
{
|
||||
float x = 0;
|
||||
float y = 0;
|
||||
GetParams(partsDelimiter, ref nextLine, 5, ref x, ref y);
|
||||
endPoint.X = (int) x;
|
||||
endPoint.Y = (int) y;
|
||||
Image image = ImageHttpRequest(nextLine);
|
||||
if (image != null)
|
||||
string nextLine = line.Trim();
|
||||
//replace with switch, or even better, do some proper parsing
|
||||
if (nextLine.StartsWith("MoveTo"))
|
||||
{
|
||||
graph.DrawImage(image, (float)startPoint.X, (float)startPoint.Y, x, y);
|
||||
float x = 0;
|
||||
float y = 0;
|
||||
GetParams(partsDelimiter, ref nextLine, 6, ref x, ref y);
|
||||
startPoint.X = (int) x;
|
||||
startPoint.Y = (int) y;
|
||||
}
|
||||
else
|
||||
else if (nextLine.StartsWith("LineTo"))
|
||||
{
|
||||
graph.DrawString("URL couldn't be resolved or is", new Font(m_fontName,6),
|
||||
myBrush, startPoint);
|
||||
graph.DrawString("not an image. Please check URL.", new Font(m_fontName, 6),
|
||||
myBrush, new Point(startPoint.X, 12 + startPoint.Y));
|
||||
float x = 0;
|
||||
float y = 0;
|
||||
GetParams(partsDelimiter, ref nextLine, 6, ref x, ref y);
|
||||
endPoint.X = (int) x;
|
||||
endPoint.Y = (int) y;
|
||||
graph.DrawLine(drawPen, startPoint, endPoint);
|
||||
startPoint.X = endPoint.X;
|
||||
startPoint.Y = endPoint.Y;
|
||||
}
|
||||
else if (nextLine.StartsWith("Text"))
|
||||
{
|
||||
nextLine = nextLine.Remove(0, 4);
|
||||
nextLine = nextLine.Trim();
|
||||
graph.DrawString(nextLine, myFont, myBrush, startPoint);
|
||||
}
|
||||
else if (nextLine.StartsWith("Image"))
|
||||
{
|
||||
float x = 0;
|
||||
float y = 0;
|
||||
GetParams(partsDelimiter, ref nextLine, 5, ref x, ref y);
|
||||
endPoint.X = (int) x;
|
||||
endPoint.Y = (int) y;
|
||||
|
||||
using (Image image = ImageHttpRequest(nextLine))
|
||||
{
|
||||
if (image != null)
|
||||
{
|
||||
graph.DrawImage(image, (float)startPoint.X, (float)startPoint.Y, x, y);
|
||||
}
|
||||
else
|
||||
{
|
||||
using (Font errorFont = new Font(m_fontName,6))
|
||||
{
|
||||
graph.DrawString("URL couldn't be resolved or is", errorFont,
|
||||
myBrush, startPoint);
|
||||
graph.DrawString("not an image. Please check URL.", errorFont,
|
||||
myBrush, new Point(startPoint.X, 12 + startPoint.Y));
|
||||
}
|
||||
|
||||
graph.DrawRectangle(drawPen, startPoint.X, startPoint.Y, endPoint.X, endPoint.Y);
|
||||
}
|
||||
}
|
||||
|
||||
startPoint.X += endPoint.X;
|
||||
startPoint.Y += endPoint.Y;
|
||||
}
|
||||
else if (nextLine.StartsWith("Rectangle"))
|
||||
{
|
||||
float x = 0;
|
||||
float y = 0;
|
||||
GetParams(partsDelimiter, ref nextLine, 9, ref x, ref y);
|
||||
endPoint.X = (int) x;
|
||||
endPoint.Y = (int) y;
|
||||
graph.DrawRectangle(drawPen, startPoint.X, startPoint.Y, endPoint.X, endPoint.Y);
|
||||
startPoint.X += endPoint.X;
|
||||
startPoint.Y += endPoint.Y;
|
||||
}
|
||||
startPoint.X += endPoint.X;
|
||||
startPoint.Y += endPoint.Y;
|
||||
}
|
||||
else if (nextLine.StartsWith("Rectangle"))
|
||||
{
|
||||
float x = 0;
|
||||
float y = 0;
|
||||
GetParams(partsDelimiter, ref nextLine, 9, ref x, ref y);
|
||||
endPoint.X = (int) x;
|
||||
endPoint.Y = (int) y;
|
||||
graph.DrawRectangle(drawPen, startPoint.X, startPoint.Y, endPoint.X, endPoint.Y);
|
||||
startPoint.X += endPoint.X;
|
||||
startPoint.Y += endPoint.Y;
|
||||
}
|
||||
else if (nextLine.StartsWith("FillRectangle"))
|
||||
{
|
||||
float x = 0;
|
||||
float y = 0;
|
||||
GetParams(partsDelimiter, ref nextLine, 13, ref x, ref y);
|
||||
endPoint.X = (int) x;
|
||||
endPoint.Y = (int) y;
|
||||
graph.FillRectangle(myBrush, startPoint.X, startPoint.Y, endPoint.X, endPoint.Y);
|
||||
startPoint.X += endPoint.X;
|
||||
startPoint.Y += endPoint.Y;
|
||||
}
|
||||
else if (nextLine.StartsWith("FillPolygon"))
|
||||
{
|
||||
PointF[] points = null;
|
||||
GetParams(partsDelimiter, ref nextLine, 11, ref points);
|
||||
graph.FillPolygon(myBrush, points);
|
||||
}
|
||||
else if (nextLine.StartsWith("Polygon"))
|
||||
{
|
||||
PointF[] points = null;
|
||||
GetParams(partsDelimiter, ref nextLine, 7, ref points);
|
||||
graph.DrawPolygon(drawPen, points);
|
||||
}
|
||||
else if (nextLine.StartsWith("Ellipse"))
|
||||
{
|
||||
float x = 0;
|
||||
float y = 0;
|
||||
GetParams(partsDelimiter, ref nextLine, 7, ref x, ref y);
|
||||
endPoint.X = (int)x;
|
||||
endPoint.Y = (int)y;
|
||||
graph.DrawEllipse(drawPen, startPoint.X, startPoint.Y, endPoint.X, endPoint.Y);
|
||||
startPoint.X += endPoint.X;
|
||||
startPoint.Y += endPoint.Y;
|
||||
}
|
||||
else if (nextLine.StartsWith("FontSize"))
|
||||
{
|
||||
nextLine = nextLine.Remove(0, 8);
|
||||
nextLine = nextLine.Trim();
|
||||
fontSize = Convert.ToSingle(nextLine, CultureInfo.InvariantCulture);
|
||||
myFont = new Font(fontName, fontSize);
|
||||
}
|
||||
else if (nextLine.StartsWith("FontProp"))
|
||||
{
|
||||
nextLine = nextLine.Remove(0, 8);
|
||||
nextLine = nextLine.Trim();
|
||||
|
||||
string[] fprops = nextLine.Split(partsDelimiter);
|
||||
foreach (string prop in fprops)
|
||||
else if (nextLine.StartsWith("FillRectangle"))
|
||||
{
|
||||
float x = 0;
|
||||
float y = 0;
|
||||
GetParams(partsDelimiter, ref nextLine, 13, ref x, ref y);
|
||||
endPoint.X = (int) x;
|
||||
endPoint.Y = (int) y;
|
||||
graph.FillRectangle(myBrush, startPoint.X, startPoint.Y, endPoint.X, endPoint.Y);
|
||||
startPoint.X += endPoint.X;
|
||||
startPoint.Y += endPoint.Y;
|
||||
}
|
||||
else if (nextLine.StartsWith("FillPolygon"))
|
||||
{
|
||||
PointF[] points = null;
|
||||
GetParams(partsDelimiter, ref nextLine, 11, ref points);
|
||||
graph.FillPolygon(myBrush, points);
|
||||
}
|
||||
else if (nextLine.StartsWith("Polygon"))
|
||||
{
|
||||
PointF[] points = null;
|
||||
GetParams(partsDelimiter, ref nextLine, 7, ref points);
|
||||
graph.DrawPolygon(drawPen, points);
|
||||
}
|
||||
else if (nextLine.StartsWith("Ellipse"))
|
||||
{
|
||||
float x = 0;
|
||||
float y = 0;
|
||||
GetParams(partsDelimiter, ref nextLine, 7, ref x, ref y);
|
||||
endPoint.X = (int)x;
|
||||
endPoint.Y = (int)y;
|
||||
graph.DrawEllipse(drawPen, startPoint.X, startPoint.Y, endPoint.X, endPoint.Y);
|
||||
startPoint.X += endPoint.X;
|
||||
startPoint.Y += endPoint.Y;
|
||||
}
|
||||
else if (nextLine.StartsWith("FontSize"))
|
||||
{
|
||||
nextLine = nextLine.Remove(0, 8);
|
||||
nextLine = nextLine.Trim();
|
||||
fontSize = Convert.ToSingle(nextLine, CultureInfo.InvariantCulture);
|
||||
|
||||
switch (prop)
|
||||
myFont.Dispose();
|
||||
myFont = new Font(fontName, fontSize);
|
||||
}
|
||||
else if (nextLine.StartsWith("FontProp"))
|
||||
{
|
||||
nextLine = nextLine.Remove(0, 8);
|
||||
nextLine = nextLine.Trim();
|
||||
|
||||
string[] fprops = nextLine.Split(partsDelimiter);
|
||||
foreach (string prop in fprops)
|
||||
{
|
||||
case "B":
|
||||
if (!(myFont.Bold))
|
||||
myFont = new Font(myFont, myFont.Style | FontStyle.Bold);
|
||||
break;
|
||||
case "I":
|
||||
if (!(myFont.Italic))
|
||||
myFont = new Font(myFont, myFont.Style | FontStyle.Italic);
|
||||
break;
|
||||
case "U":
|
||||
if (!(myFont.Underline))
|
||||
myFont = new Font(myFont, myFont.Style | FontStyle.Underline);
|
||||
break;
|
||||
case "S":
|
||||
if (!(myFont.Strikeout))
|
||||
myFont = new Font(myFont, myFont.Style | FontStyle.Strikeout);
|
||||
break;
|
||||
case "R":
|
||||
myFont = new Font(myFont, FontStyle.Regular);
|
||||
break;
|
||||
|
||||
switch (prop)
|
||||
{
|
||||
case "B":
|
||||
if (!(myFont.Bold))
|
||||
{
|
||||
Font newFont = new Font(myFont, myFont.Style | FontStyle.Bold);
|
||||
myFont.Dispose();
|
||||
myFont = newFont;
|
||||
}
|
||||
break;
|
||||
case "I":
|
||||
if (!(myFont.Italic))
|
||||
{
|
||||
Font newFont = new Font(myFont, myFont.Style | FontStyle.Italic);
|
||||
myFont.Dispose();
|
||||
myFont = newFont;
|
||||
}
|
||||
break;
|
||||
case "U":
|
||||
if (!(myFont.Underline))
|
||||
{
|
||||
Font newFont = new Font(myFont, myFont.Style | FontStyle.Underline);
|
||||
myFont.Dispose();
|
||||
myFont = newFont;
|
||||
}
|
||||
break;
|
||||
case "S":
|
||||
if (!(myFont.Strikeout))
|
||||
{
|
||||
Font newFont = new Font(myFont, myFont.Style | FontStyle.Strikeout);
|
||||
myFont.Dispose();
|
||||
myFont = newFont;
|
||||
}
|
||||
break;
|
||||
case "R":
|
||||
// We need to place this newFont inside its own context so that the .NET compiler
|
||||
// doesn't complain about a redefinition of an existing newFont, even though there is none
|
||||
// The mono compiler doesn't produce this error.
|
||||
{
|
||||
Font newFont = new Font(myFont, FontStyle.Regular);
|
||||
myFont.Dispose();
|
||||
myFont = newFont;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (nextLine.StartsWith("FontName"))
|
||||
{
|
||||
nextLine = nextLine.Remove(0, 8);
|
||||
fontName = nextLine.Trim();
|
||||
myFont = new Font(fontName, fontSize);
|
||||
}
|
||||
else if (nextLine.StartsWith("PenSize"))
|
||||
{
|
||||
nextLine = nextLine.Remove(0, 7);
|
||||
nextLine = nextLine.Trim();
|
||||
float size = Convert.ToSingle(nextLine, CultureInfo.InvariantCulture);
|
||||
drawPen.Width = size;
|
||||
}
|
||||
else if (nextLine.StartsWith("PenCap"))
|
||||
{
|
||||
bool start = true, end = true;
|
||||
nextLine = nextLine.Remove(0, 6);
|
||||
nextLine = nextLine.Trim();
|
||||
string[] cap = nextLine.Split(partsDelimiter);
|
||||
if (cap[0].ToLower() == "start")
|
||||
end = false;
|
||||
else if (cap[0].ToLower() == "end")
|
||||
start = false;
|
||||
else if (cap[0].ToLower() != "both")
|
||||
return;
|
||||
string type = cap[1].ToLower();
|
||||
|
||||
if (end)
|
||||
else if (nextLine.StartsWith("FontName"))
|
||||
{
|
||||
switch (type)
|
||||
nextLine = nextLine.Remove(0, 8);
|
||||
fontName = nextLine.Trim();
|
||||
myFont.Dispose();
|
||||
myFont = new Font(fontName, fontSize);
|
||||
}
|
||||
else if (nextLine.StartsWith("PenSize"))
|
||||
{
|
||||
nextLine = nextLine.Remove(0, 7);
|
||||
nextLine = nextLine.Trim();
|
||||
float size = Convert.ToSingle(nextLine, CultureInfo.InvariantCulture);
|
||||
drawPen.Width = size;
|
||||
}
|
||||
else if (nextLine.StartsWith("PenCap"))
|
||||
{
|
||||
bool start = true, end = true;
|
||||
nextLine = nextLine.Remove(0, 6);
|
||||
nextLine = nextLine.Trim();
|
||||
string[] cap = nextLine.Split(partsDelimiter);
|
||||
if (cap[0].ToLower() == "start")
|
||||
end = false;
|
||||
else if (cap[0].ToLower() == "end")
|
||||
start = false;
|
||||
else if (cap[0].ToLower() != "both")
|
||||
return;
|
||||
string type = cap[1].ToLower();
|
||||
|
||||
if (end)
|
||||
{
|
||||
case "arrow":
|
||||
drawPen.EndCap = System.Drawing.Drawing2D.LineCap.ArrowAnchor;
|
||||
break;
|
||||
case "round":
|
||||
drawPen.EndCap = System.Drawing.Drawing2D.LineCap.RoundAnchor;
|
||||
break;
|
||||
case "diamond":
|
||||
drawPen.EndCap = System.Drawing.Drawing2D.LineCap.DiamondAnchor;
|
||||
break;
|
||||
case "flat":
|
||||
drawPen.EndCap = System.Drawing.Drawing2D.LineCap.Flat;
|
||||
break;
|
||||
switch (type)
|
||||
{
|
||||
case "arrow":
|
||||
drawPen.EndCap = System.Drawing.Drawing2D.LineCap.ArrowAnchor;
|
||||
break;
|
||||
case "round":
|
||||
drawPen.EndCap = System.Drawing.Drawing2D.LineCap.RoundAnchor;
|
||||
break;
|
||||
case "diamond":
|
||||
drawPen.EndCap = System.Drawing.Drawing2D.LineCap.DiamondAnchor;
|
||||
break;
|
||||
case "flat":
|
||||
drawPen.EndCap = System.Drawing.Drawing2D.LineCap.Flat;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (start)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case "arrow":
|
||||
drawPen.StartCap = System.Drawing.Drawing2D.LineCap.ArrowAnchor;
|
||||
break;
|
||||
case "round":
|
||||
drawPen.StartCap = System.Drawing.Drawing2D.LineCap.RoundAnchor;
|
||||
break;
|
||||
case "diamond":
|
||||
drawPen.StartCap = System.Drawing.Drawing2D.LineCap.DiamondAnchor;
|
||||
break;
|
||||
case "flat":
|
||||
drawPen.StartCap = System.Drawing.Drawing2D.LineCap.Flat;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (start)
|
||||
else if (nextLine.StartsWith("PenColour") || nextLine.StartsWith("PenColor"))
|
||||
{
|
||||
switch (type)
|
||||
nextLine = nextLine.Remove(0, 9);
|
||||
nextLine = nextLine.Trim();
|
||||
int hex = 0;
|
||||
|
||||
Color newColor;
|
||||
if (Int32.TryParse(nextLine, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out hex))
|
||||
{
|
||||
case "arrow":
|
||||
drawPen.StartCap = System.Drawing.Drawing2D.LineCap.ArrowAnchor;
|
||||
break;
|
||||
case "round":
|
||||
drawPen.StartCap = System.Drawing.Drawing2D.LineCap.RoundAnchor;
|
||||
break;
|
||||
case "diamond":
|
||||
drawPen.StartCap = System.Drawing.Drawing2D.LineCap.DiamondAnchor;
|
||||
break;
|
||||
case "flat":
|
||||
drawPen.StartCap = System.Drawing.Drawing2D.LineCap.Flat;
|
||||
break;
|
||||
newColor = Color.FromArgb(hex);
|
||||
}
|
||||
else
|
||||
{
|
||||
// this doesn't fail, it just returns black if nothing is found
|
||||
newColor = Color.FromName(nextLine);
|
||||
}
|
||||
|
||||
myBrush.Color = newColor;
|
||||
drawPen.Color = newColor;
|
||||
}
|
||||
}
|
||||
else if (nextLine.StartsWith("PenColour") || nextLine.StartsWith("PenColor"))
|
||||
{
|
||||
nextLine = nextLine.Remove(0, 9);
|
||||
nextLine = nextLine.Trim();
|
||||
int hex = 0;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (drawPen != null)
|
||||
drawPen.Dispose();
|
||||
|
||||
Color newColor;
|
||||
if (Int32.TryParse(nextLine, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out hex))
|
||||
{
|
||||
newColor = Color.FromArgb(hex);
|
||||
}
|
||||
else
|
||||
{
|
||||
// this doesn't fail, it just returns black if nothing is found
|
||||
newColor = Color.FromName(nextLine);
|
||||
}
|
||||
if (myFont != null)
|
||||
myFont.Dispose();
|
||||
|
||||
myBrush.Color = newColor;
|
||||
drawPen.Color = newColor;
|
||||
}
|
||||
if (myBrush != null)
|
||||
myBrush.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -691,7 +758,7 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender
|
||||
{
|
||||
try
|
||||
{
|
||||
WebRequest request = HttpWebRequest.Create(url);
|
||||
WebRequest request = HttpWebRequest.Create(url);
|
||||
//Ckrinke: Comment out for now as 'str' is unused. Bring it back into play later when it is used.
|
||||
//Ckrinke Stream str = null;
|
||||
HttpWebResponse response = (HttpWebResponse)(request).GetResponse();
|
||||
@@ -702,7 +769,8 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -41,8 +41,7 @@ using OpenMetaverse;
|
||||
|
||||
namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
|
||||
{
|
||||
public class LocalGridServicesConnector :
|
||||
ISharedRegionModule, IGridService
|
||||
public class LocalGridServicesConnector : ISharedRegionModule, IGridService
|
||||
{
|
||||
private static readonly ILog m_log =
|
||||
LogManager.GetLogger(
|
||||
@@ -51,7 +50,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
|
||||
private IGridService m_GridService;
|
||||
private Dictionary<UUID, RegionCache> m_LocalCache = new Dictionary<UUID, RegionCache>();
|
||||
|
||||
private bool m_Enabled = false;
|
||||
private bool m_Enabled;
|
||||
|
||||
public LocalGridServicesConnector()
|
||||
{
|
||||
@@ -59,7 +58,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
|
||||
|
||||
public LocalGridServicesConnector(IConfigSource source)
|
||||
{
|
||||
m_log.Debug("[LOCAL GRID CONNECTOR]: LocalGridServicesConnector instantiated");
|
||||
m_log.Debug("[LOCAL GRID SERVICE CONNECTOR]: LocalGridServicesConnector instantiated directly.");
|
||||
InitialiseService(source);
|
||||
}
|
||||
|
||||
@@ -84,8 +83,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
|
||||
if (name == Name)
|
||||
{
|
||||
InitialiseService(source);
|
||||
m_Enabled = true;
|
||||
m_log.Info("[LOCAL GRID CONNECTOR]: Local grid connector enabled");
|
||||
m_log.Info("[LOCAL GRID SERVICE CONNECTOR]: Local grid connector enabled");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -95,7 +93,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
|
||||
IConfig assetConfig = source.Configs["GridService"];
|
||||
if (assetConfig == null)
|
||||
{
|
||||
m_log.Error("[LOCAL GRID CONNECTOR]: GridService missing from OpenSim.ini");
|
||||
m_log.Error("[LOCAL GRID SERVICE CONNECTOR]: GridService missing from OpenSim.ini");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -104,7 +102,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
|
||||
|
||||
if (serviceDll == String.Empty)
|
||||
{
|
||||
m_log.Error("[LOCAL GRID CONNECTOR]: No LocalServiceModule named in section GridService");
|
||||
m_log.Error("[LOCAL GRID SERVICE CONNECTOR]: No LocalServiceModule named in section GridService");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -115,16 +113,20 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
|
||||
|
||||
if (m_GridService == null)
|
||||
{
|
||||
m_log.Error("[LOCAL GRID CONNECTOR]: Can't load grid service");
|
||||
m_log.Error("[LOCAL GRID SERVICE CONNECTOR]: Can't load grid service");
|
||||
return;
|
||||
}
|
||||
|
||||
m_Enabled = true;
|
||||
}
|
||||
|
||||
public void PostInitialise()
|
||||
{
|
||||
// FIXME: We will still add this command even if we aren't enabled since RemoteGridServiceConnector
|
||||
// will have instantiated us directly.
|
||||
MainConsole.Instance.Commands.AddCommand("Regions", false, "show neighbours",
|
||||
"show neighbours",
|
||||
"Shows the local regions' neighbours", NeighboursCommand);
|
||||
"Shows the local regions' neighbours", HandleShowNeighboursCommand);
|
||||
}
|
||||
|
||||
public void Close()
|
||||
@@ -133,17 +135,22 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
|
||||
|
||||
public void AddRegion(Scene scene)
|
||||
{
|
||||
if (m_Enabled)
|
||||
scene.RegisterModuleInterface<IGridService>(this);
|
||||
if (!m_Enabled)
|
||||
return;
|
||||
|
||||
scene.RegisterModuleInterface<IGridService>(this);
|
||||
|
||||
if (m_LocalCache.ContainsKey(scene.RegionInfo.RegionID))
|
||||
m_log.ErrorFormat("[LOCAL GRID CONNECTOR]: simulator seems to have more than one region with the same UUID. Please correct this!");
|
||||
m_log.ErrorFormat("[LOCAL GRID SERVICE CONNECTOR]: simulator seems to have more than one region with the same UUID. Please correct this!");
|
||||
else
|
||||
m_LocalCache.Add(scene.RegionInfo.RegionID, new RegionCache(scene));
|
||||
}
|
||||
|
||||
public void RemoveRegion(Scene scene)
|
||||
{
|
||||
if (!m_Enabled)
|
||||
return;
|
||||
|
||||
m_LocalCache[scene.RegionInfo.RegionID].Clear();
|
||||
m_LocalCache.Remove(scene.RegionInfo.RegionID);
|
||||
}
|
||||
@@ -232,7 +239,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
|
||||
|
||||
#endregion
|
||||
|
||||
public void NeighboursCommand(string module, string[] cmdparams)
|
||||
public void HandleShowNeighboursCommand(string module, string[] cmdparams)
|
||||
{
|
||||
System.Text.StringBuilder caps = new System.Text.StringBuilder();
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using Nini.Config;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Statistics;
|
||||
using OpenSim.Framework.Monitoring;
|
||||
using OpenSim.Services.Connectors;
|
||||
using OpenSim.Region.Framework.Interfaces;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
|
||||
@@ -128,11 +128,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage
|
||||
m_enabled = true;
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///
|
||||
///</summary>
|
||||
|
||||
|
||||
///<summary>
|
||||
///
|
||||
///</summary>
|
||||
@@ -146,10 +141,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage
|
||||
lock (m_scenes)
|
||||
m_scenes[scene.RegionInfo.RegionID] = scene;
|
||||
|
||||
scene.EventManager.OnLoginsEnabled += OnLoginsEnabled;
|
||||
scene.EventManager.OnRegionReadyStatusChange += s => { if (s.Ready) UploadMapTile(s); };
|
||||
}
|
||||
|
||||
|
||||
///<summary>
|
||||
///
|
||||
///</summary>
|
||||
@@ -163,21 +157,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage
|
||||
}
|
||||
|
||||
#endregion ISharedRegionModule
|
||||
|
||||
void OnLoginsEnabled(string regionName)
|
||||
{
|
||||
Scene scene = null;
|
||||
foreach (Scene s in m_scenes.Values)
|
||||
if (s.RegionInfo.RegionName == regionName)
|
||||
{
|
||||
scene = s;
|
||||
break;
|
||||
}
|
||||
if (scene != null)
|
||||
UploadMapTile(scene);
|
||||
}
|
||||
|
||||
|
||||
|
||||
///<summary>
|
||||
///
|
||||
///</summary>
|
||||
|
||||
@@ -125,13 +125,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Neighbour
|
||||
uint x, y;
|
||||
Utils.LongToUInts(regionHandle, out x, out y);
|
||||
|
||||
m_log.DebugFormat("[NEIGHBOUR CONNECTOR]: HelloNeighbour from region {0} to region at {1}-{2}",
|
||||
thisRegion.RegionName, x / Constants.RegionSize, y / Constants.RegionSize);
|
||||
|
||||
foreach (Scene s in m_Scenes)
|
||||
{
|
||||
if (s.RegionInfo.RegionHandle == regionHandle)
|
||||
{
|
||||
m_log.DebugFormat("[LOCAL NEIGHBOUR SERVICE CONNECTOR]: HelloNeighbour from region {0} to neighbour {1} at {2}-{3}",
|
||||
thisRegion.RegionName, s.Name, x / Constants.RegionSize, y / Constants.RegionSize);
|
||||
|
||||
//m_log.Debug("[NEIGHBOUR CONNECTOR]: Found region to SendHelloNeighbour");
|
||||
return s.IncomingHelloNeighbour(thisRegion);
|
||||
}
|
||||
|
||||
@@ -354,24 +354,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool CreateObject(GridRegion destination, UUID userID, UUID itemID)
|
||||
{
|
||||
if (destination == null)
|
||||
return false;
|
||||
|
||||
if (m_scenes.ContainsKey(destination.RegionID))
|
||||
{
|
||||
// m_log.DebugFormat(
|
||||
// "[LOCAL SIMULATION CONNECTOR]: Found region {0} {1} to send AgentUpdate",
|
||||
// s.RegionInfo.RegionName, destination.RegionHandle);
|
||||
|
||||
return m_scenes[destination.RegionID].IncomingCreateObject(userID, itemID);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
#endregion /* IInterregionComms */
|
||||
|
||||
#region Misc
|
||||
|
||||
@@ -300,13 +300,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool CreateObject(GridRegion destination, UUID userID, UUID itemID)
|
||||
{
|
||||
// Not Implemented
|
||||
return false;
|
||||
}
|
||||
|
||||
#endregion /* IInterregionComms */
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -129,18 +129,18 @@ namespace OpenSim.Region.CoreModules.World
|
||||
switch (cmd[1])
|
||||
{
|
||||
case "enable":
|
||||
scene.LoginsDisabled = false;
|
||||
scene.LoginsEnabled = true;
|
||||
MainConsole.Instance.Output(String.Format("Logins are enabled for region {0}", scene.RegionInfo.RegionName));
|
||||
break;
|
||||
case "disable":
|
||||
scene.LoginsDisabled = true;
|
||||
scene.LoginsEnabled = false;
|
||||
MainConsole.Instance.Output(String.Format("Logins are disabled for region {0}", scene.RegionInfo.RegionName));
|
||||
break;
|
||||
case "status":
|
||||
if (scene.LoginsDisabled)
|
||||
MainConsole.Instance.Output(String.Format("Login in {0} are disabled", scene.RegionInfo.RegionName));
|
||||
else
|
||||
if (scene.LoginsEnabled)
|
||||
MainConsole.Instance.Output(String.Format("Login in {0} are enabled", scene.RegionInfo.RegionName));
|
||||
else
|
||||
MainConsole.Instance.Output(String.Format("Login in {0} are disabled", scene.RegionInfo.RegionName));
|
||||
break;
|
||||
default:
|
||||
MainConsole.Instance.Output("Syntax: login enable|disable|status");
|
||||
|
||||
@@ -124,7 +124,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
||||
LandData landData = lo.LandData;
|
||||
string landDataPath = String.Format("{0}{1}.xml", ArchiveConstants.LANDDATA_PATH,
|
||||
landData.GlobalID.ToString());
|
||||
m_archiveWriter.WriteFile(landDataPath, LandDataSerializer.Serialize(landData));
|
||||
m_archiveWriter.WriteFile(landDataPath, LandDataSerializer.Serialize(landData, m_options));
|
||||
}
|
||||
|
||||
m_log.InfoFormat("[ARCHIVER]: Adding terrain information to archive.");
|
||||
|
||||
@@ -46,8 +46,6 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
||||
{
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
protected static ASCIIEncoding m_asciiEncoding = new ASCIIEncoding();
|
||||
|
||||
/// <summary>
|
||||
/// Store for asset data we received before we get the metadata
|
||||
/// </summary>
|
||||
|
||||
@@ -154,6 +154,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
||||
|
||||
protected void OnRequestCallbackTimeout(object source, ElapsedEventArgs args)
|
||||
{
|
||||
bool close = true;
|
||||
|
||||
try
|
||||
{
|
||||
lock (this)
|
||||
@@ -161,7 +163,10 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
||||
// Take care of the possibilty that this thread started but was paused just outside the lock before
|
||||
// the final request came in (assuming that such a thing is possible)
|
||||
if (m_requestState == RequestState.Completed)
|
||||
{
|
||||
close = false;
|
||||
return;
|
||||
}
|
||||
|
||||
m_requestState = RequestState.Aborted;
|
||||
}
|
||||
@@ -208,7 +213,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
||||
}
|
||||
finally
|
||||
{
|
||||
m_assetsArchiver.ForceClose();
|
||||
if (close)
|
||||
m_assetsArchiver.ForceClose();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -242,11 +248,11 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
||||
|
||||
m_requestCallbackTimer.Stop();
|
||||
|
||||
if (m_requestState == RequestState.Aborted)
|
||||
if ((m_requestState == RequestState.Aborted) || (m_requestState == RequestState.Completed))
|
||||
{
|
||||
m_log.WarnFormat(
|
||||
"[ARCHIVER]: Received information about asset {0} after archive save abortion. Ignoring.",
|
||||
id);
|
||||
"[ARCHIVER]: Received information about asset {0} while in state {1}. Ignoring.",
|
||||
id, m_requestState);
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -268,7 +274,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
||||
m_notFoundAssetUuids.Add(new UUID(id));
|
||||
}
|
||||
|
||||
if (m_foundAssetUuids.Count + m_notFoundAssetUuids.Count == m_repliesRequired)
|
||||
if (m_foundAssetUuids.Count + m_notFoundAssetUuids.Count >= m_repliesRequired)
|
||||
{
|
||||
m_requestState = RequestState.Completed;
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace OpenSim.Region.CoreModules.World.Media.Moap.Tests
|
||||
TestHelpers.InMethod();
|
||||
// log4net.Config.XmlConfigurator.Configure();
|
||||
|
||||
SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene);
|
||||
SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene).RootPart;
|
||||
MediaEntry me = new MediaEntry();
|
||||
|
||||
m_module.SetMediaEntry(part, 1, me);
|
||||
@@ -88,7 +88,7 @@ namespace OpenSim.Region.CoreModules.World.Media.Moap.Tests
|
||||
|
||||
string homeUrl = "opensimulator.org";
|
||||
|
||||
SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene);
|
||||
SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene).RootPart;
|
||||
MediaEntry me = new MediaEntry() { HomeURL = homeUrl };
|
||||
|
||||
m_module.SetMediaEntry(part, 1, me);
|
||||
|
||||
@@ -37,7 +37,7 @@ using Nini.Config;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Console;
|
||||
using OpenSim.Framework.Statistics;
|
||||
using OpenSim.Framework.Monitoring;
|
||||
using OpenSim.Region.Framework.Interfaces;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
|
||||
@@ -98,7 +98,8 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
|
||||
m_console.Commands.AddCommand(
|
||||
"Objects", false, "delete object name",
|
||||
"delete object name [--regex] <name>",
|
||||
"Delete a scene object by name.\nIf --regex is specified then the name is treatead as a regular expression",
|
||||
"Delete a scene object by name.",
|
||||
"If --regex is specified then the name is treatead as a regular expression",
|
||||
HandleDeleteObject);
|
||||
|
||||
m_console.Commands.AddCommand(
|
||||
@@ -118,7 +119,8 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
|
||||
false,
|
||||
"show object name",
|
||||
"show object name [--regex] <name>",
|
||||
"Show details of scene objects with the given name.\nIf --regex is specified then the name is treatead as a regular expression",
|
||||
"Show details of scene objects with the given name.",
|
||||
"If --regex is specified then the name is treatead as a regular expression",
|
||||
HandleShowObjectByName);
|
||||
|
||||
m_console.Commands.AddCommand(
|
||||
@@ -133,7 +135,8 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
|
||||
false,
|
||||
"show part name",
|
||||
"show part name [--regex] <name>",
|
||||
"Show details of scene object parts with the given name.\nIf --regex is specified then the name is treatead as a regular expression",
|
||||
"Show details of scene object parts with the given name.",
|
||||
"If --regex is specified then the name is treatead as a regular expression",
|
||||
HandleShowPartByName);
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ using Nini.Config;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Console;
|
||||
using OpenSim.Framework.Statistics;
|
||||
using OpenSim.Framework.Monitoring;
|
||||
using OpenSim.Region.Framework.Interfaces;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
|
||||
|
||||
@@ -119,17 +119,20 @@ namespace OpenSim.Region.CoreModules.World.Sound
|
||||
m_scene.ForEachRootScenePresence(delegate(ScenePresence sp)
|
||||
{
|
||||
double dis = Util.GetDistanceTo(sp.AbsolutePosition, position);
|
||||
|
||||
if (dis > 100.0) // Max audio distance
|
||||
return;
|
||||
|
||||
float thisSpGain;
|
||||
|
||||
// Scale by distance
|
||||
if (radius == 0)
|
||||
gain = (float)((double)gain * ((100.0 - dis) / 100.0));
|
||||
thisSpGain = (float)((double)gain * ((100.0 - dis) / 100.0));
|
||||
else
|
||||
gain = (float)((double)gain * ((radius - dis) / radius));
|
||||
thisSpGain = (float)((double)gain * ((radius - dis) / radius));
|
||||
|
||||
sp.ControllingClient.SendTriggeredSound(
|
||||
soundId, ownerID, objectID, parentID, handle, position, (float)gain);
|
||||
soundId, ownerID, objectID, parentID, handle, position, thisSpGain);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -252,7 +252,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
|
||||
if (horizontalScale < 0.01d)
|
||||
horizontalScale = 0.01d;
|
||||
|
||||
System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
|
||||
Encoding enc = Encoding.ASCII;
|
||||
|
||||
bs.Write(enc.GetBytes("TERRAGENTERRAIN "));
|
||||
|
||||
|
||||
@@ -1108,6 +1108,32 @@ namespace OpenSim.Region.CoreModules.World.Terrain
|
||||
CheckForTerrainUpdates();
|
||||
}
|
||||
|
||||
private void InterfaceMinTerrain(Object[] args)
|
||||
{
|
||||
int x, y;
|
||||
for (x = 0; x < m_channel.Width; x++)
|
||||
{
|
||||
for (y = 0; y < m_channel.Height; y++)
|
||||
{
|
||||
m_channel[x, y] = Math.Max((double)args[0], m_channel[x, y]);
|
||||
}
|
||||
}
|
||||
CheckForTerrainUpdates();
|
||||
}
|
||||
|
||||
private void InterfaceMaxTerrain(Object[] args)
|
||||
{
|
||||
int x, y;
|
||||
for (x = 0; x < m_channel.Width; x++)
|
||||
{
|
||||
for (y = 0; y < m_channel.Height; y++)
|
||||
{
|
||||
m_channel[x, y] = Math.Min((double)args[0], m_channel[x, y]);
|
||||
}
|
||||
}
|
||||
CheckForTerrainUpdates();
|
||||
}
|
||||
|
||||
private void InterfaceShowDebugStats(Object[] args)
|
||||
{
|
||||
double max = Double.MinValue;
|
||||
@@ -1248,6 +1274,12 @@ namespace OpenSim.Region.CoreModules.World.Terrain
|
||||
rescaleCommand.AddArgument("min", "min terrain height after rescaling", "Double");
|
||||
rescaleCommand.AddArgument("max", "max terrain height after rescaling", "Double");
|
||||
|
||||
Command minCommand = new Command("min", CommandIntentions.COMMAND_HAZARDOUS, InterfaceMinTerrain, "Sets the minimum terrain height to the specified value.");
|
||||
minCommand.AddArgument("min", "terrain height to use as minimum", "Double");
|
||||
|
||||
Command maxCommand = new Command("max", CommandIntentions.COMMAND_HAZARDOUS, InterfaceMaxTerrain, "Sets the maximum terrain height to the specified value.");
|
||||
maxCommand.AddArgument("min", "terrain height to use as maximum", "Double");
|
||||
|
||||
|
||||
// Debug
|
||||
Command showDebugStatsCommand =
|
||||
@@ -1279,6 +1311,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain
|
||||
m_commander.RegisterCommand("effect", pluginRunCommand);
|
||||
m_commander.RegisterCommand("flip", flipCommand);
|
||||
m_commander.RegisterCommand("rescale", rescaleCommand);
|
||||
m_commander.RegisterCommand("min", minCommand);
|
||||
m_commander.RegisterCommand("max", maxCommand);
|
||||
|
||||
// Add this to our scene so scripts can call these functions
|
||||
m_scene.RegisterModuleCommander(m_commander);
|
||||
|
||||
@@ -111,6 +111,9 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
|
||||
asset = assetService.GetCached(cacheID.ToString());
|
||||
if (asset != null)
|
||||
{
|
||||
// m_log.DebugFormat(
|
||||
// "[TERRAIN SPLAT]: Got asset service cached terrain texture {0} {1}", i, asset.ID);
|
||||
|
||||
try
|
||||
{
|
||||
using (System.IO.MemoryStream stream = new System.IO.MemoryStream(asset.Data))
|
||||
@@ -129,6 +132,9 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
|
||||
asset = assetService.Get(textureIDs[i].ToString());
|
||||
if (asset != null)
|
||||
{
|
||||
// m_log.DebugFormat(
|
||||
// "[TERRAIN SPLAT]: Got cached original JPEG2000 terrain texture {0} {1}", i, asset.ID);
|
||||
|
||||
try { detailTexture[i] = (Bitmap)CSJ2K.J2kImage.FromBytes(asset.Data); }
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -137,15 +143,13 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
|
||||
}
|
||||
|
||||
if (detailTexture[i] != null)
|
||||
{
|
||||
Bitmap bitmap = detailTexture[i];
|
||||
|
||||
{
|
||||
// Make sure this texture is the correct size, otherwise resize
|
||||
if (bitmap.Width != 256 || bitmap.Height != 256)
|
||||
if (detailTexture[i].Width != 256 || detailTexture[i].Height != 256)
|
||||
{
|
||||
using (Bitmap origBitmap = bitmap)
|
||||
using (Bitmap origBitmap = detailTexture[i])
|
||||
{
|
||||
bitmap = ImageUtils.ResizeImage(origBitmap, 256, 256);
|
||||
detailTexture[i] = ImageUtils.ResizeImage(origBitmap, 256, 256);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -153,7 +157,7 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
|
||||
byte[] data;
|
||||
using (System.IO.MemoryStream stream = new System.IO.MemoryStream())
|
||||
{
|
||||
bitmap.Save(stream, ImageFormat.Png);
|
||||
detailTexture[i].Save(stream, ImageFormat.Png);
|
||||
data = stream.ToArray();
|
||||
}
|
||||
|
||||
@@ -185,6 +189,9 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
|
||||
{
|
||||
if (detailTexture[i] == null)
|
||||
{
|
||||
// m_log.DebugFormat(
|
||||
// "[TERRAIN SPLAT]: Generating solid colour for missing texture {0}", i);
|
||||
|
||||
// Create a solid color texture for this layer
|
||||
detailTexture[i] = new Bitmap(256, 256, PixelFormat.Format24bppRgb);
|
||||
using (Graphics gfx = Graphics.FromImage(detailTexture[i]))
|
||||
|
||||
@@ -42,6 +42,7 @@ using OpenMetaverse.Imaging;
|
||||
using OpenMetaverse.StructuredData;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Capabilities;
|
||||
using OpenSim.Framework.Monitoring;
|
||||
using OpenSim.Framework.Servers;
|
||||
using OpenSim.Framework.Servers.HttpServer;
|
||||
using OpenSim.Region.Framework.Interfaces;
|
||||
@@ -730,7 +731,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
|
||||
{
|
||||
if (Environment.TickCount > (m_blacklistedregions[regionhandle] + blacklistTimeout))
|
||||
{
|
||||
m_log.DebugFormat("[WORLDMAP]: Unblock blacklisted region {0}", regionhandle);
|
||||
m_log.DebugFormat("[WORLD MAP]: Unblock blacklisted region {0}", regionhandle);
|
||||
|
||||
m_blacklistedregions.Remove(regionhandle);
|
||||
}
|
||||
@@ -781,7 +782,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
|
||||
{
|
||||
if (Environment.TickCount > (m_blacklistedurls[httpserver] + blacklistTimeout))
|
||||
{
|
||||
m_log.DebugFormat("[WORLDMAP]: Unblock blacklisted URL {0}", httpserver);
|
||||
m_log.DebugFormat("[WORLD MAP]: Unblock blacklisted URL {0}", httpserver);
|
||||
|
||||
m_blacklistedurls.Remove(httpserver);
|
||||
}
|
||||
@@ -1343,7 +1344,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
|
||||
if (terrain == null)
|
||||
return;
|
||||
|
||||
m_log.DebugFormat("[WORLDMAP]: Generating map image for {0}", m_scene.RegionInfo.RegionName);
|
||||
m_log.DebugFormat("[WORLD MAP]: Generating map image for {0}", m_scene.RegionInfo.RegionName);
|
||||
|
||||
byte[] data = terrain.WriteJpeg2000Image();
|
||||
if (data == null)
|
||||
@@ -1365,7 +1366,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
|
||||
asset.Flags = AssetFlags.Maptile;
|
||||
|
||||
// Store the new one
|
||||
m_log.DebugFormat("[WORLDMAP]: Storing map tile {0} for {1}", asset.ID, m_scene.RegionInfo.RegionName);
|
||||
m_log.DebugFormat("[WORLD MAP]: Storing map tile {0} for {1}", asset.ID, m_scene.RegionInfo.RegionName);
|
||||
|
||||
m_scene.AssetService.Store(asset);
|
||||
|
||||
|
||||
@@ -35,6 +35,20 @@ namespace OpenSim.Region.Framework.Interfaces
|
||||
{
|
||||
public interface IAttachmentsModule
|
||||
{
|
||||
/// <summary>
|
||||
/// Copy attachment data from a ScenePresence into the AgentData structure for transmission to another simulator
|
||||
/// </summary>
|
||||
/// <param name='sp'></param>
|
||||
/// <param name='ad'></param>
|
||||
void CopyAttachments(IScenePresence sp, AgentData ad);
|
||||
|
||||
/// <summary>
|
||||
/// Copy attachment data from an AgentData structure into a ScenePresence.
|
||||
/// </summary>
|
||||
/// <param name='ad'></param>
|
||||
/// <param name='sp'></param>
|
||||
void CopyAttachments(AgentData ad, IScenePresence sp);
|
||||
|
||||
/// <summary>
|
||||
/// RezAttachments. This should only be called upon login on the first region.
|
||||
/// Attachment rezzings on crossings and TPs are done in a different way.
|
||||
@@ -51,7 +65,7 @@ namespace OpenSim.Region.Framework.Interfaces
|
||||
/// <param name="sp">The presence closing</param>
|
||||
/// <param name="saveChanged">Save changed attachments.</param>
|
||||
/// <param name="saveAllScripted">Save attachments with scripts even if they haven't changed.</para>
|
||||
void DeRezAttachments(IScenePresence sp, bool saveChanged, bool saveAllScripted);
|
||||
void DeRezAttachments(IScenePresence sp);
|
||||
|
||||
/// <summary>
|
||||
/// Delete all the presence's attachments from the scene
|
||||
@@ -78,7 +92,7 @@ namespace OpenSim.Region.Framework.Interfaces
|
||||
/// <param name="itemID"></param>
|
||||
/// <param name="AttachmentPt"></param>
|
||||
/// <returns>The scene object that was attached. Null if the scene object could not be found</returns>
|
||||
ISceneEntity RezSingleAttachmentFromInventory(IScenePresence sp, UUID itemID, uint AttachmentPt);
|
||||
SceneObjectGroup RezSingleAttachmentFromInventory(IScenePresence sp, UUID itemID, uint AttachmentPt);
|
||||
|
||||
/// <summary>
|
||||
/// Rez multiple attachments from a user's inventory
|
||||
@@ -95,11 +109,11 @@ namespace OpenSim.Region.Framework.Interfaces
|
||||
void DetachSingleAttachmentToGround(IScenePresence sp, uint objectLocalID);
|
||||
|
||||
/// <summary>
|
||||
/// Detach the given item so that it remains in the user's inventory.
|
||||
/// Detach the given attachment so that it remains in the user's inventory.
|
||||
/// </summary>
|
||||
/// <param name="sp">/param>
|
||||
/// <param name="itemID"></param>
|
||||
void DetachSingleAttachmentToInv(IScenePresence sp, UUID itemID);
|
||||
/// <param name="grp">The attachment to detach.</param>
|
||||
void DetachSingleAttachmentToInv(IScenePresence sp, SceneObjectGroup grp);
|
||||
|
||||
/// <summary>
|
||||
/// Update the position of an attachment.
|
||||
|
||||
@@ -92,7 +92,7 @@ namespace OpenSim.Region.Framework.Interfaces
|
||||
void ResumeScripts();
|
||||
|
||||
/// <summary>
|
||||
/// Stop all the scripts in this entity.
|
||||
/// Stop and remove all the scripts in this entity from the scene.
|
||||
/// </summary>
|
||||
/// <param name="sceneObjectBeingDeleted">
|
||||
/// Should be true if these scripts are being removed because the scene
|
||||
@@ -100,6 +100,11 @@ namespace OpenSim.Region.Framework.Interfaces
|
||||
/// </param>
|
||||
void RemoveScriptInstances(bool sceneObjectBeingDeleted);
|
||||
|
||||
/// <summary>
|
||||
/// Stop all the scripts in this entity.
|
||||
/// </summary>
|
||||
void StopScriptInstances();
|
||||
|
||||
/// <summary>
|
||||
/// Start a script which is in this entity's inventory.
|
||||
/// </summary>
|
||||
@@ -129,7 +134,7 @@ namespace OpenSim.Region.Framework.Interfaces
|
||||
bool CreateScriptInstance(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource);
|
||||
|
||||
/// <summary>
|
||||
/// Stop a script which is in this prim's inventory.
|
||||
/// Stop and remove a script which is in this prim's inventory from the scene.
|
||||
/// </summary>
|
||||
/// <param name="itemId"></param>
|
||||
/// <param name="sceneObjectBeingDeleted">
|
||||
@@ -138,6 +143,12 @@ namespace OpenSim.Region.Framework.Interfaces
|
||||
/// </param>
|
||||
void RemoveScriptInstance(UUID itemId, bool sceneObjectBeingDeleted);
|
||||
|
||||
/// <summary>
|
||||
/// Stop a script which is in this prim's inventory.
|
||||
/// </summary>
|
||||
/// <param name="itemId"></param>
|
||||
void StopScriptInstance(UUID itemId);
|
||||
|
||||
/// <summary>
|
||||
/// Add an item to this entity's inventory. If an item with the same name already exists, then an alternative
|
||||
/// name is chosen.
|
||||
|
||||
@@ -183,6 +183,14 @@ namespace OpenSim.Region.Framework.Interfaces
|
||||
/// <returns>true if the stand succeeded, false if not</returns>
|
||||
bool Stand(UUID agentID, Scene scene);
|
||||
|
||||
/// <summary>
|
||||
/// Get the NPC to touch an object.
|
||||
/// </summary>
|
||||
/// <param name="agentID"></param>
|
||||
/// <param name="partID"></param>
|
||||
/// <returns>true if the touch is actually attempted, false if not</returns>
|
||||
bool Touch(UUID agentID, UUID partID);
|
||||
|
||||
/// <summary>
|
||||
/// Delete an NPC.
|
||||
/// </summary>
|
||||
|
||||
@@ -25,14 +25,23 @@
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using OpenSim.Framework;
|
||||
|
||||
namespace OpenSim.Region.Framework.Interfaces
|
||||
{
|
||||
public interface IRegionReadyModule
|
||||
{
|
||||
void OarLoadingAlert(string msg);
|
||||
|
||||
/// <summary>
|
||||
/// Trigger region ready status manually.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This should be called by the scene if the IRegionReadyModule has set Scene.LoginLock == true
|
||||
/// </remarks>
|
||||
/// <param name='scene'></param>
|
||||
void TriggerRegionReady(IScene scene);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -40,6 +40,12 @@ namespace OpenSim.Region.Framework.Interfaces
|
||||
/// </remarks>
|
||||
public interface IScenePresence : ISceneAgent
|
||||
{
|
||||
/// <summary>
|
||||
/// Copy of the script states while the agent is in transit. This state may
|
||||
/// need to be placed back in case of transfer fail.
|
||||
/// </summary>
|
||||
List<string> InTransitScriptStates { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The AttachmentsModule synchronizes on this to avoid race conditions between commands to add and remove attachments.
|
||||
/// </summary>
|
||||
@@ -66,6 +72,10 @@ namespace OpenSim.Region.Framework.Interfaces
|
||||
/// <returns></returns>
|
||||
List<SceneObjectGroup> GetAttachments(uint attachmentPoint);
|
||||
|
||||
/// <summary>
|
||||
/// Does this avatar have any attachments?
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
bool HasAttachments();
|
||||
|
||||
// Don't use these methods directly. Instead, use the AttachmentsModule
|
||||
@@ -73,4 +83,4 @@ namespace OpenSim.Region.Framework.Interfaces
|
||||
void RemoveAttachment(SceneObjectGroup gobj);
|
||||
void ClearAttachments();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,14 +69,14 @@ namespace OpenSim.Region.Framework.Interfaces
|
||||
|
||||
ArrayList GetScriptErrors(UUID itemID);
|
||||
|
||||
bool HasScript(UUID itemID, out bool running);
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if a script is running.
|
||||
/// </summary>
|
||||
/// <param name="itemID">The item ID of the script.</param>
|
||||
bool GetScriptState(UUID itemID);
|
||||
|
||||
void SetRunEnable(UUID instanceID, bool enable);
|
||||
|
||||
void SaveAllState();
|
||||
|
||||
/// <summary>
|
||||
@@ -101,4 +101,4 @@ namespace OpenSim.Region.Framework.Interfaces
|
||||
/// </returns>
|
||||
Dictionary<uint, float> GetObjectScriptsExecutionTimes();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,6 +67,10 @@ namespace OpenSim.Region.Framework.Interfaces
|
||||
/// <param name="key"></param>
|
||||
void DispatchReply(UUID scriptId, int code, string text, string key);
|
||||
|
||||
/// For constants
|
||||
void RegisterConstant(string cname, object value);
|
||||
object LookupModConstant(string cname);
|
||||
|
||||
// For use ONLY by the script API
|
||||
void RaiseEvent(UUID script, string id, string module, string command, string key);
|
||||
}
|
||||
|
||||
@@ -535,11 +535,5 @@ namespace OpenSim.Region.Framework.Scenes.Animation
|
||||
|
||||
SendAnimPack(animIDs, sequenceNums, objectIDs);
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
m_animations = null;
|
||||
m_scenePresence = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -496,15 +496,24 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
public delegate void RegionHeartbeatEnd(Scene scene);
|
||||
public event RegionHeartbeatEnd OnRegionHeartbeatEnd;
|
||||
|
||||
public delegate void LoginsEnabled(string regionName);
|
||||
|
||||
/// <summary>
|
||||
/// This should only fire in all circumstances if the RegionReady module is active.
|
||||
/// Fired when logins to a region are enabled or disabled.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// TODO: Fire this even when the RegionReady module is not active.
|
||||
///
|
||||
/// </remarks>
|
||||
public event LoginsEnabled OnLoginsEnabled;
|
||||
/// Fired
|
||||
public event RegionLoginsStatusChange OnRegionLoginsStatusChange;
|
||||
public delegate void RegionLoginsStatusChange(IScene scene);
|
||||
|
||||
/// <summary>
|
||||
/// Fired when a region is considered ready for use.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// A region is considered ready when startup operations such as loading of scripts already on the region
|
||||
/// have been completed.
|
||||
/// </remarks>
|
||||
public event Action<IScene> OnRegionReadyStatusChange;
|
||||
|
||||
public delegate void PrimsLoaded(Scene s);
|
||||
public event PrimsLoaded OnPrimsLoaded;
|
||||
@@ -2477,21 +2486,42 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
}
|
||||
}
|
||||
|
||||
public void TriggerLoginsEnabled (string regionName)
|
||||
public void TriggerRegionLoginsStatusChange(IScene scene)
|
||||
{
|
||||
LoginsEnabled handler = OnLoginsEnabled;
|
||||
RegionLoginsStatusChange handler = OnRegionLoginsStatusChange;
|
||||
|
||||
if ( handler != null)
|
||||
if (handler != null)
|
||||
{
|
||||
foreach (LoginsEnabled d in handler.GetInvocationList())
|
||||
foreach (RegionLoginsStatusChange d in handler.GetInvocationList())
|
||||
{
|
||||
try
|
||||
{
|
||||
d(regionName);
|
||||
d(scene);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.ErrorFormat("[EVENT MANAGER]: Delegate for LoginsEnabled failed - continuing {0} - {1}",
|
||||
m_log.ErrorFormat("[EVENT MANAGER]: Delegate for OnRegionLoginsStatusChange failed - continuing {0} - {1}",
|
||||
e.Message, e.StackTrace);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void TriggerRegionReadyStatusChange(IScene scene)
|
||||
{
|
||||
Action<IScene> handler = OnRegionReadyStatusChange;
|
||||
|
||||
if (handler != null)
|
||||
{
|
||||
foreach (Action<IScene> d in handler.GetInvocationList())
|
||||
{
|
||||
try
|
||||
{
|
||||
d(scene);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.ErrorFormat("[EVENT MANAGER]: Delegate for OnRegionReadyStatusChange failed - continuing {0} - {1}",
|
||||
e.Message, e.StackTrace);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ using OpenSim.Framework.Communications;
|
||||
using OpenSim.Framework.Console;
|
||||
using OpenSim.Framework.Servers;
|
||||
using OpenSim.Framework.Servers.HttpServer;
|
||||
using OpenSim.Framework.Statistics;
|
||||
using OpenSim.Framework.Monitoring;
|
||||
using OpenSim.Region.Framework;
|
||||
using OpenSim.Region.Framework.Interfaces;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
|
||||
@@ -814,16 +814,20 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
&& oldAgentID == LibraryService.LibraryRootFolder.Owner))
|
||||
{
|
||||
CreateNewInventoryItem(
|
||||
remoteClient, item.CreatorId, item.CreatorData, newFolderID, newName, item.Flags, callbackID, asset, (sbyte)item.InvType,
|
||||
item.BasePermissions, item.CurrentPermissions, item.EveryOnePermissions, item.NextPermissions, item.GroupPermissions, Util.UnixTimeSinceEpoch());
|
||||
remoteClient, item.CreatorId, item.CreatorData, newFolderID,
|
||||
newName, item.Description, item.Flags, callbackID, asset, (sbyte)item.InvType,
|
||||
item.BasePermissions, item.CurrentPermissions, item.EveryOnePermissions,
|
||||
item.NextPermissions, item.GroupPermissions, Util.UnixTimeSinceEpoch());
|
||||
}
|
||||
else
|
||||
{
|
||||
// If item is transfer or permissions are off or calling agent is allowed to copy item owner's inventory item.
|
||||
if (((item.CurrentPermissions & (uint)PermissionMask.Transfer) != 0) && (m_permissions.BypassPermissions() || m_permissions.CanCopyUserInventory(remoteClient.AgentId, oldItemID)))
|
||||
if (((item.CurrentPermissions & (uint)PermissionMask.Transfer) != 0)
|
||||
&& (m_permissions.BypassPermissions()
|
||||
|| m_permissions.CanCopyUserInventory(remoteClient.AgentId, oldItemID)))
|
||||
{
|
||||
CreateNewInventoryItem(
|
||||
remoteClient, item.CreatorId, item.CreatorData, newFolderID, newName, item.Flags, callbackID,
|
||||
remoteClient, item.CreatorId, item.CreatorData, newFolderID, newName, item.Description, item.Flags, callbackID,
|
||||
asset, (sbyte) item.InvType,
|
||||
item.NextPermissions, item.NextPermissions, item.EveryOnePermissions & item.NextPermissions,
|
||||
item.NextPermissions, item.GroupPermissions, Util.UnixTimeSinceEpoch());
|
||||
@@ -870,32 +874,50 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
/// <summary>
|
||||
/// Create a new inventory item.
|
||||
/// </summary>
|
||||
/// <param name="remoteClient"></param>
|
||||
/// <param name="folderID"></param>
|
||||
/// <param name="callbackID"></param>
|
||||
/// <param name="asset"></param>
|
||||
/// <param name="invType"></param>
|
||||
/// <param name="nextOwnerMask"></param>
|
||||
public void CreateNewInventoryItem(IClientAPI remoteClient, string creatorID, string creatorData, UUID folderID, string name, uint flags, uint callbackID,
|
||||
AssetBase asset, sbyte invType, uint nextOwnerMask, int creationDate)
|
||||
/// <param name="remoteClient">Client creating this inventory item.</param>
|
||||
/// <param name="creatorID"></param>
|
||||
/// <param name="creatorData"></param>
|
||||
/// <param name="folderID">UUID of folder in which this item should be placed.</param>
|
||||
/// <param name="name">Item name.</para>
|
||||
/// <param name="description">Item description.</param>
|
||||
/// <param name="flags">Item flags</param>
|
||||
/// <param name="callbackID">Generated by the client.</para>
|
||||
/// <param name="asset">Asset to which this item refers.</param>
|
||||
/// <param name="invType">Type of inventory item.</param>
|
||||
/// <param name="nextOwnerMask">Next owner pemrissions mask.</param>
|
||||
/// <param name="creationDate">Unix timestamp at which this item was created.</param>
|
||||
public void CreateNewInventoryItem(
|
||||
IClientAPI remoteClient, string creatorID, string creatorData, UUID folderID,
|
||||
string name, string description, uint flags, uint callbackID,
|
||||
AssetBase asset, sbyte invType, uint nextOwnerMask, int creationDate)
|
||||
{
|
||||
CreateNewInventoryItem(
|
||||
remoteClient, creatorID, creatorData, folderID, name, flags, callbackID, asset, invType,
|
||||
remoteClient, creatorID, creatorData, folderID, name, description, flags, callbackID, asset, invType,
|
||||
(uint)PermissionMask.All, (uint)PermissionMask.All, 0, nextOwnerMask, 0, creationDate);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a new Inventory Item
|
||||
/// </summary>
|
||||
/// <param name="remoteClient"></param>
|
||||
/// <param name="folderID"></param>
|
||||
/// <param name="callbackID"></param>
|
||||
/// <param name="asset"></param>
|
||||
/// <param name="invType"></param>
|
||||
/// <param name="nextOwnerMask"></param>
|
||||
/// <param name="creationDate"></param>
|
||||
/// <param name="remoteClient">Client creating this inventory item.</param>
|
||||
/// <param name="creatorID"></param>
|
||||
/// <param name="creatorData"></param>
|
||||
/// <param name="folderID">UUID of folder in which this item should be placed.</param>
|
||||
/// <param name="name">Item name.</para>
|
||||
/// <param name="description">Item description.</param>
|
||||
/// <param name="flags">Item flags</param>
|
||||
/// <param name="callbackID">Generated by the client.</para>
|
||||
/// <param name="asset">Asset to which this item refers.</param>
|
||||
/// <param name="invType">Type of inventory item.</param>
|
||||
/// <param name="baseMask">Base permissions mask.</param>
|
||||
/// <param name="currentMask">Current permissions mask.</param>
|
||||
/// <param name="everyoneMask">Everyone permissions mask.</param>
|
||||
/// <param name="nextOwnerMask">Next owner pemrissions mask.</param>
|
||||
/// <param name="groupMask">Group permissions mask.</param>
|
||||
/// <param name="creationDate">Unix timestamp at which this item was created.</param>
|
||||
private void CreateNewInventoryItem(
|
||||
IClientAPI remoteClient, string creatorID, string creatorData, UUID folderID, string name, uint flags, uint callbackID, AssetBase asset, sbyte invType,
|
||||
IClientAPI remoteClient, string creatorID, string creatorData, UUID folderID,
|
||||
string name, string description, uint flags, uint callbackID, AssetBase asset, sbyte invType,
|
||||
uint baseMask, uint currentMask, uint everyoneMask, uint nextOwnerMask, uint groupMask, int creationDate)
|
||||
{
|
||||
InventoryItemBase item = new InventoryItemBase();
|
||||
@@ -904,8 +926,8 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
item.CreatorData = creatorData;
|
||||
item.ID = UUID.Random();
|
||||
item.AssetID = asset.FullID;
|
||||
item.Description = asset.Description;
|
||||
item.Name = name;
|
||||
item.Description = description;
|
||||
item.Flags = flags;
|
||||
item.AssetType = asset.Type;
|
||||
item.InvType = invType;
|
||||
@@ -987,7 +1009,8 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
asset.Description = description;
|
||||
|
||||
CreateNewInventoryItem(
|
||||
remoteClient, remoteClient.AgentId.ToString(), string.Empty, folderID, name, 0, callbackID, asset, invType,
|
||||
remoteClient, remoteClient.AgentId.ToString(), string.Empty, folderID,
|
||||
name, description, 0, callbackID, asset, invType,
|
||||
(uint)PermissionMask.All, (uint)PermissionMask.All, (uint)PermissionMask.All,
|
||||
(uint)PermissionMask.All, (uint)PermissionMask.All, Util.UnixTimeSinceEpoch());
|
||||
}
|
||||
@@ -2108,7 +2131,8 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0)
|
||||
sourcePart.Inventory.RemoveInventoryItem(item.ItemID);
|
||||
}
|
||||
|
||||
|
||||
group.FromPartID = sourcePart.UUID;
|
||||
AddNewSceneObject(group, true, pos, rot, vel);
|
||||
|
||||
// We can only call this after adding the scene object, since the scene object references the scene
|
||||
@@ -2143,24 +2167,10 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
if (part == null)
|
||||
return;
|
||||
|
||||
IScriptModule[] engines = RequestModuleInterfaces<IScriptModule>();
|
||||
|
||||
if (running)
|
||||
{
|
||||
foreach (IScriptModule engine in engines)
|
||||
{
|
||||
engine.SetRunEnable(itemID, true);
|
||||
}
|
||||
EventManager.TriggerStartScript(part.LocalId, itemID);
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (IScriptModule engine in engines)
|
||||
{
|
||||
engine.SetRunEnable(itemID, false);
|
||||
}
|
||||
EventManager.TriggerStopScript(part.LocalId, itemID);
|
||||
}
|
||||
}
|
||||
|
||||
public void GetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID)
|
||||
|
||||
@@ -40,6 +40,7 @@ using OpenMetaverse;
|
||||
using OpenMetaverse.Packets;
|
||||
using OpenMetaverse.Imaging;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Monitoring;
|
||||
using OpenSim.Services.Interfaces;
|
||||
using OpenSim.Framework.Communications;
|
||||
using OpenSim.Framework.Console;
|
||||
@@ -120,14 +121,18 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
{
|
||||
get { return m_defaultDrawDistance; }
|
||||
}
|
||||
|
||||
private List<string> m_AllowedViewers = new List<string>();
|
||||
private List<string> m_BannedViewers = new List<string>();
|
||||
|
||||
// TODO: need to figure out how allow client agents but deny
|
||||
// root agents when ACL denies access to root agent
|
||||
public bool m_strictAccessControl = true;
|
||||
public int MaxUndoCount = 5;
|
||||
|
||||
// Using this for RegionReady module to prevent LoginsDisabled from changing under our feet;
|
||||
public bool LoginLock = false;
|
||||
public bool LoginsDisabled = true;
|
||||
|
||||
public bool StartDisabled = false;
|
||||
public bool LoadingPrims;
|
||||
public IXfer XferManager;
|
||||
@@ -614,8 +619,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
m_sceneGridService = sceneGridService;
|
||||
m_SimulationDataService = simDataService;
|
||||
m_EstateDataService = estateDataService;
|
||||
m_regionHandle = m_regInfo.RegionHandle;
|
||||
m_regionName = m_regInfo.RegionName;
|
||||
m_regionHandle = RegionInfo.RegionHandle;
|
||||
|
||||
m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this);
|
||||
m_asyncSceneObjectDeleter.Enabled = true;
|
||||
@@ -630,7 +634,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
// resave.
|
||||
// FIXME: It shouldn't be up to the database plugins to create this data - we should do it when a new
|
||||
// region is set up and avoid these gyrations.
|
||||
RegionSettings rs = simDataService.LoadRegionSettings(m_regInfo.RegionID);
|
||||
RegionSettings rs = simDataService.LoadRegionSettings(RegionInfo.RegionID);
|
||||
bool updatedTerrainTextures = false;
|
||||
if (rs.TerrainTexture1 == UUID.Zero)
|
||||
{
|
||||
@@ -659,10 +663,10 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
if (updatedTerrainTextures)
|
||||
rs.Save();
|
||||
|
||||
m_regInfo.RegionSettings = rs;
|
||||
RegionInfo.RegionSettings = rs;
|
||||
|
||||
if (estateDataService != null)
|
||||
m_regInfo.EstateSettings = estateDataService.LoadEstateSettings(m_regInfo.RegionID, false);
|
||||
RegionInfo.EstateSettings = estateDataService.LoadEstateSettings(RegionInfo.RegionID, false);
|
||||
|
||||
#endregion Region Settings
|
||||
|
||||
@@ -700,6 +704,8 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
{
|
||||
IConfig startupConfig = m_config.Configs["Startup"];
|
||||
|
||||
StartDisabled = startupConfig.GetBoolean("StartDisabled", false);
|
||||
|
||||
m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance", m_defaultDrawDistance);
|
||||
m_useBackup = startupConfig.GetBoolean("UseSceneBackup", m_useBackup);
|
||||
if (!m_useBackup)
|
||||
@@ -780,6 +786,24 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
}
|
||||
}
|
||||
|
||||
string grant = startupConfig.GetString("AllowedClients", String.Empty);
|
||||
if (grant.Length > 0)
|
||||
{
|
||||
foreach (string viewer in grant.Split('|'))
|
||||
{
|
||||
m_AllowedViewers.Add(viewer.Trim().ToLower());
|
||||
}
|
||||
}
|
||||
|
||||
grant = startupConfig.GetString("BannedClients", String.Empty);
|
||||
if (grant.Length > 0)
|
||||
{
|
||||
foreach (string viewer in grant.Split('|'))
|
||||
{
|
||||
m_BannedViewers.Add(viewer.Trim().ToLower());
|
||||
}
|
||||
}
|
||||
|
||||
MinFrameTime = startupConfig.GetFloat( "MinFrameTime", MinFrameTime);
|
||||
m_update_backup = startupConfig.GetInt( "UpdateStorageEveryNFrames", m_update_backup);
|
||||
m_update_coarse_locations = startupConfig.GetInt( "UpdateCoarseLocationsEveryNFrames", m_update_coarse_locations);
|
||||
@@ -790,8 +814,14 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
m_update_presences = startupConfig.GetInt( "UpdateAgentsEveryNFrames", m_update_presences);
|
||||
m_update_terrain = startupConfig.GetInt( "UpdateTerrainEveryNFrames", m_update_terrain);
|
||||
m_update_temp_cleaning = startupConfig.GetInt( "UpdateTempCleaningEveryNFrames", m_update_temp_cleaning);
|
||||
}
|
||||
|
||||
SendPeriodicAppearanceUpdates = startupConfig.GetBoolean("SendPeriodicAppearanceUpdates", SendPeriodicAppearanceUpdates);
|
||||
// FIXME: Ultimately this should be in a module.
|
||||
IConfig appearanceConfig = m_config.Configs["Appearance"];
|
||||
if (appearanceConfig != null)
|
||||
{
|
||||
SendPeriodicAppearanceUpdates
|
||||
= appearanceConfig.GetBoolean("ResendAppearanceUpdates", SendPeriodicAppearanceUpdates);
|
||||
}
|
||||
|
||||
#endregion Region Config
|
||||
@@ -828,7 +858,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats;
|
||||
}
|
||||
|
||||
public Scene(RegionInfo regInfo)
|
||||
public Scene(RegionInfo regInfo) : base(regInfo)
|
||||
{
|
||||
PhysicalPrims = true;
|
||||
CollidablePrims = true;
|
||||
@@ -855,7 +885,6 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
WestBorders.Add(westBorder);
|
||||
BordersLocked = false;
|
||||
|
||||
m_regInfo = regInfo;
|
||||
m_eventManager = new EventManager();
|
||||
|
||||
m_permissions = new ScenePermissions(this);
|
||||
@@ -1176,15 +1205,17 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
avatar.ControllingClient.SendShutdownConnectionNotice();
|
||||
});
|
||||
|
||||
// Stop updating the scene objects and agents.
|
||||
m_shuttingDown = true;
|
||||
|
||||
// Wait here, or the kick messages won't actually get to the agents before the scene terminates.
|
||||
// We also need to wait to avoid a race condition with the scene update loop which might not yet
|
||||
// have checked ShuttingDown.
|
||||
Thread.Sleep(500);
|
||||
|
||||
// Stop all client threads.
|
||||
ForEachScenePresence(delegate(ScenePresence avatar) { avatar.ControllingClient.Close(); });
|
||||
|
||||
// Stop updating the scene objects and agents.
|
||||
m_shuttingDown = true;
|
||||
|
||||
m_log.Debug("[SCENE]: Persisting changed objects");
|
||||
EventManager.TriggerSceneShuttingDown(this);
|
||||
|
||||
@@ -1199,8 +1230,17 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
|
||||
m_sceneGraph.Close();
|
||||
|
||||
if (!GridService.DeregisterRegion(m_regInfo.RegionID))
|
||||
m_log.WarnFormat("[SCENE]: Deregister from grid failed for region {0}", m_regInfo.RegionName);
|
||||
if (PhysicsScene != null)
|
||||
{
|
||||
PhysicsScene phys = PhysicsScene;
|
||||
// remove the physics engine from both Scene and SceneGraph
|
||||
PhysicsScene = null;
|
||||
phys.Dispose();
|
||||
phys = null;
|
||||
}
|
||||
|
||||
if (!GridService.DeregisterRegion(RegionInfo.RegionID))
|
||||
m_log.WarnFormat("[SCENE]: Deregister from grid failed for region {0}", Name);
|
||||
|
||||
// call the base class Close method.
|
||||
base.Close();
|
||||
@@ -1457,7 +1497,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
// landMS = Util.EnvironmentTickCountSubtract(ldMS);
|
||||
//}
|
||||
|
||||
if (LoginsDisabled && Frame == 20)
|
||||
if (!LoginsEnabled && Frame == 20)
|
||||
{
|
||||
// m_log.DebugFormat("{0} {1} {2}", LoginsDisabled, m_sceneGraph.GetActiveScriptsCount(), LoginLock);
|
||||
|
||||
@@ -1465,31 +1505,34 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
// this is a rare case where we know we have just went through a long cycle of heap
|
||||
// allocations, and there is no more work to be done until someone logs in
|
||||
GC.Collect();
|
||||
|
||||
IConfig startupConfig = m_config.Configs["Startup"];
|
||||
if (startupConfig == null || !startupConfig.GetBoolean("StartDisabled", false))
|
||||
|
||||
if (!LoginLock)
|
||||
{
|
||||
if (!StartDisabled)
|
||||
{
|
||||
m_log.InfoFormat("[REGION]: Enabling logins for {0}", RegionInfo.RegionName);
|
||||
LoginsEnabled = true;
|
||||
}
|
||||
|
||||
m_sceneGridService.InformNeighborsThatRegionisUp(
|
||||
RequestModuleInterface<INeighbourService>(), RegionInfo);
|
||||
|
||||
// Region ready should always be set
|
||||
Ready = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// This handles a case of a region having no scripts for the RegionReady module
|
||||
if (m_sceneGraph.GetActiveScriptsCount() == 0)
|
||||
{
|
||||
// need to be able to tell these have changed in RegionReady
|
||||
LoginLock = false;
|
||||
EventManager.TriggerLoginsEnabled(RegionInfo.RegionName);
|
||||
// In this case, we leave it to the IRegionReadyModule to enable logins
|
||||
|
||||
// LoginLock can currently only be set by a region module implementation.
|
||||
// If somehow this hasn't been done then the quickest way to bugfix is to see the
|
||||
// NullReferenceException
|
||||
IRegionReadyModule rrm = RequestModuleInterface<IRegionReadyModule>();
|
||||
rrm.TriggerRegionReady(this);
|
||||
}
|
||||
|
||||
// For RegionReady lockouts
|
||||
if (!LoginLock)
|
||||
{
|
||||
m_log.InfoFormat("[REGION]: Enabling logins for {0}", RegionInfo.RegionName);
|
||||
LoginsDisabled = false;
|
||||
}
|
||||
|
||||
m_sceneGridService.InformNeighborsThatRegionisUp(RequestModuleInterface<INeighbourService>(), RegionInfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
StartDisabled = true;
|
||||
LoginsDisabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1720,14 +1763,14 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
|
||||
public void StoreWindlightProfile(RegionLightShareData wl)
|
||||
{
|
||||
m_regInfo.WindlightSettings = wl;
|
||||
RegionInfo.WindlightSettings = wl;
|
||||
SimulationDataService.StoreRegionWindlightSettings(wl);
|
||||
m_eventManager.TriggerOnSaveNewWindlightProfile();
|
||||
}
|
||||
|
||||
public void LoadWindlightProfile()
|
||||
{
|
||||
m_regInfo.WindlightSettings = SimulationDataService.LoadRegionWindlightSettings(RegionInfo.RegionID);
|
||||
RegionInfo.WindlightSettings = SimulationDataService.LoadRegionWindlightSettings(RegionInfo.RegionID);
|
||||
m_eventManager.TriggerOnSaveNewWindlightProfile();
|
||||
}
|
||||
|
||||
@@ -2164,13 +2207,30 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
/// <summary>
|
||||
/// Synchronously delete the given object from the scene.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Scripts are also removed.
|
||||
/// </remarks>
|
||||
/// <param name="group">Object Id</param>
|
||||
/// <param name="silent">Suppress broadcasting changes to other clients.</param>
|
||||
public void DeleteSceneObject(SceneObjectGroup group, bool silent)
|
||||
{
|
||||
DeleteSceneObject(group, silent, true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Synchronously delete the given object from the scene.
|
||||
/// </summary>
|
||||
/// <param name="group">Object Id</param>
|
||||
/// <param name="silent">Suppress broadcasting changes to other clients.</param>
|
||||
/// <param name="removeScripts">If true, then scripts are removed. If false, then they are only stopped.</para>
|
||||
public void DeleteSceneObject(SceneObjectGroup group, bool silent, bool removeScripts)
|
||||
{
|
||||
// m_log.DebugFormat("[SCENE]: Deleting scene object {0} {1}", group.Name, group.UUID);
|
||||
|
||||
group.RemoveScriptInstances(true);
|
||||
if (removeScripts)
|
||||
group.RemoveScriptInstances(true);
|
||||
else
|
||||
group.StopScriptInstances();
|
||||
|
||||
SceneObjectPart[] partList = group.Parts;
|
||||
|
||||
@@ -2218,7 +2278,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
ForceSceneObjectBackup(so);
|
||||
|
||||
so.DetachFromBackup();
|
||||
SimulationDataService.RemoveObject(so.UUID, m_regInfo.RegionID);
|
||||
SimulationDataService.RemoveObject(so.UUID, RegionInfo.RegionID);
|
||||
}
|
||||
|
||||
// We need to keep track of this state in case this group is still queued for further backup.
|
||||
@@ -2476,7 +2536,16 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.WarnFormat("[SCENE]: Problem casting object, exception {0}{1}", e.Message, e.StackTrace);
|
||||
m_log.WarnFormat("[INTERREGION]: Problem casting object, exception {0}{1}", e.Message, e.StackTrace);
|
||||
return false;
|
||||
}
|
||||
|
||||
// If the user is banned, we won't let any of their objects
|
||||
// enter. Period.
|
||||
//
|
||||
if (RegionInfo.EstateSettings.IsBanned(newObject.OwnerID))
|
||||
{
|
||||
m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", newObject.OwnerID);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -2485,33 +2554,31 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
|
||||
if (!AddSceneObject(newObject))
|
||||
{
|
||||
m_log.DebugFormat("[SCENE]: Problem adding scene object {0} in {1} ", sog.UUID, RegionInfo.RegionName);
|
||||
m_log.DebugFormat(
|
||||
"[INTERREGION]: Problem adding scene object {0} in {1} ", newObject.UUID, RegionInfo.RegionName);
|
||||
return false;
|
||||
}
|
||||
|
||||
// For attachments, we need to wait until the agent is root
|
||||
// before we restart the scripts, or else some functions won't work.
|
||||
if (!newObject.IsAttachment)
|
||||
{
|
||||
// FIXME: It would be better to never add the scene object at all rather than add it and then delete
|
||||
// it
|
||||
if (!Permissions.CanObjectEntry(newObject.UUID, true, newObject.AbsolutePosition))
|
||||
{
|
||||
// Deny non attachments based on parcel settings
|
||||
//
|
||||
m_log.Info("[INTERREGION]: Denied prim crossing because of parcel settings");
|
||||
|
||||
DeleteSceneObject(newObject, false);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// For attachments, we need to wait until the agent is root
|
||||
// before we restart the scripts, or else some functions won't work.
|
||||
newObject.RootPart.ParentGroup.CreateScriptInstances(0, false, DefaultScriptEngine, GetStateSource(newObject));
|
||||
newObject.ResumeScripts();
|
||||
}
|
||||
else
|
||||
{
|
||||
ScenePresence sp;
|
||||
if (TryGetScenePresence(newObject.OwnerID, out sp))
|
||||
{
|
||||
// If the scene presence is here and already a root
|
||||
// agent, we came from a ;egacy region. Start the scripts
|
||||
// here as they used to start.
|
||||
// TODO: Remove in 0.7.3
|
||||
if (!sp.IsChildAgent)
|
||||
{
|
||||
newObject.RootPart.ParentGroup.CreateScriptInstances(0, false, DefaultScriptEngine, GetStateSource(newObject));
|
||||
newObject.ResumeScripts();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Do this as late as possible so that listeners have full access to the incoming object
|
||||
EventManager.TriggerOnIncomingSceneObject(newObject);
|
||||
@@ -2519,28 +2586,6 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attachment rezzing
|
||||
/// </summary>
|
||||
/// <param name="userID">Agent Unique ID</param>
|
||||
/// <param name="itemID">Object ID</param>
|
||||
/// <returns>False</returns>
|
||||
public virtual bool IncomingCreateObject(UUID userID, UUID itemID)
|
||||
{
|
||||
m_log.DebugFormat(" >>> IncomingCreateObject(userID, itemID) <<< {0} {1}", userID, itemID);
|
||||
|
||||
// Commented out since this is as yet unused and is arguably not the appropriate place to do this, as
|
||||
// attachments are being rezzed elsewhere in AddNewClient()
|
||||
// ScenePresence sp = GetScenePresence(userID);
|
||||
// if (sp != null && AttachmentsModule != null)
|
||||
// {
|
||||
// uint attPt = (uint)sp.Appearance.GetAttachpoint(itemID);
|
||||
// AttachmentsModule.RezSingleAttachmentFromInventory(sp.ControllingClient, itemID, attPt);
|
||||
// }
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a Scene Object group to the Scene.
|
||||
/// Verifies that the creator of the object is not banned from the simulator.
|
||||
@@ -2550,18 +2595,6 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
/// <returns>True if the SceneObjectGroup was added, False if it was not</returns>
|
||||
public bool AddSceneObject(SceneObjectGroup sceneObject)
|
||||
{
|
||||
// If the user is banned, we won't let any of their objects
|
||||
// enter. Period.
|
||||
//
|
||||
if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID))
|
||||
{
|
||||
m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", sceneObject.OwnerID);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
sceneObject.SetScene(this);
|
||||
|
||||
// Force allocation of new LocalId
|
||||
//
|
||||
SceneObjectPart[] parts = sceneObject.Parts;
|
||||
@@ -2606,18 +2639,6 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
else
|
||||
{
|
||||
AddRestoredSceneObject(sceneObject, true, false);
|
||||
|
||||
if (!Permissions.CanObjectEntry(sceneObject.UUID,
|
||||
true, sceneObject.AbsolutePosition))
|
||||
{
|
||||
// Deny non attachments based on parcel settings
|
||||
//
|
||||
m_log.Info("[INTERREGION]: Denied prim crossing because of parcel settings");
|
||||
|
||||
DeleteSceneObject(sceneObject, false);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -3294,17 +3315,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
{
|
||||
if (AttachmentsModule != null)
|
||||
{
|
||||
// Don't save attachments for HG visitors, it
|
||||
// messes up their inventory. When a HG visitor logs
|
||||
// out on a foreign grid, their attachments will be
|
||||
// reloaded in the state they were in when they left
|
||||
// the home grid. This is best anyway as the visited
|
||||
// grid may use an incompatible script engine.
|
||||
bool saveChanged
|
||||
= avatar.PresenceType != PresenceType.Npc
|
||||
&& (UserManagementModule == null || UserManagementModule.IsLocalGridUser(avatar.UUID));
|
||||
|
||||
AttachmentsModule.DeRezAttachments(avatar, saveChanged, false);
|
||||
AttachmentsModule.DeRezAttachments(avatar);
|
||||
}
|
||||
|
||||
ForEachClient(
|
||||
@@ -3320,24 +3331,30 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
if (AgentTransactionsModule != null)
|
||||
AgentTransactionsModule.RemoveAgentAssetTransactions(agentID);
|
||||
|
||||
avatar.Close();
|
||||
|
||||
m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.Error(
|
||||
string.Format("[SCENE]: Exception removing {0} from {1}, ", avatar.Name, RegionInfo.RegionName), e);
|
||||
string.Format("[SCENE]: Exception removing {0} from {1}. Cleaning up. Exception ", avatar.Name, Name), e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
// Always clean these structures up so that any failure above doesn't cause them to remain in the
|
||||
// scene with possibly bad effects (e.g. continually timing out on unacked packets and triggering
|
||||
// the same cleanup exception continually.
|
||||
// TODO: This should probably extend to the whole method, but we don't want to also catch the NRE
|
||||
// since this would hide the underlying failure and other associated problems.
|
||||
m_sceneGraph.RemoveScenePresence(agentID);
|
||||
m_clientManager.Remove(agentID);
|
||||
try
|
||||
{
|
||||
// Always clean these structures up so that any failure above doesn't cause them to remain in the
|
||||
// scene with possibly bad effects (e.g. continually timing out on unacked packets and triggering
|
||||
// the same cleanup exception continually.
|
||||
m_sceneGraph.RemoveScenePresence(agentID);
|
||||
m_clientManager.Remove(agentID);
|
||||
|
||||
avatar.Close();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.Error(
|
||||
string.Format("[SCENE]: Exception in final clean up of {0} in {1}. Exception ", avatar.Name, Name), e);
|
||||
}
|
||||
}
|
||||
|
||||
//m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false));
|
||||
@@ -3451,12 +3468,56 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
agent.startpos
|
||||
);
|
||||
|
||||
if (LoginsDisabled)
|
||||
if (!LoginsEnabled)
|
||||
{
|
||||
reason = "Logins Disabled";
|
||||
return false;
|
||||
}
|
||||
|
||||
//Check if the viewer is banned or in the viewer access list
|
||||
//We check if the substring is listed for higher flexebility
|
||||
bool ViewerDenied = true;
|
||||
|
||||
//Check if the specific viewer is listed in the allowed viewer list
|
||||
if (m_AllowedViewers.Count > 0)
|
||||
{
|
||||
foreach (string viewer in m_AllowedViewers)
|
||||
{
|
||||
if (viewer == agent.Viewer.Substring(0, viewer.Length).Trim().ToLower())
|
||||
{
|
||||
ViewerDenied = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ViewerDenied = false;
|
||||
}
|
||||
|
||||
//Check if the viewer is in the banned list
|
||||
if (m_BannedViewers.Count > 0)
|
||||
{
|
||||
foreach (string viewer in m_BannedViewers)
|
||||
{
|
||||
if (viewer == agent.Viewer.Substring(0, viewer.Length).Trim().ToLower())
|
||||
{
|
||||
ViewerDenied = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ViewerDenied)
|
||||
{
|
||||
m_log.DebugFormat(
|
||||
"[SCENE]: Access denied for {0} {1} using {2}",
|
||||
agent.firstname, agent.lastname, agent.Viewer);
|
||||
reason = "Access denied, your viewer is banned by the region owner";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
ScenePresence sp = GetScenePresence(agent.AgentID);
|
||||
|
||||
if (sp != null && !sp.IsChildAgent)
|
||||
@@ -3464,8 +3525,8 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
// We have a zombie from a crashed session.
|
||||
// Or the same user is trying to be root twice here, won't work.
|
||||
// Kill it.
|
||||
m_log.DebugFormat(
|
||||
"[SCENE]: Zombie scene presence detected for {0} {1} in {2}",
|
||||
m_log.WarnFormat(
|
||||
"[SCENE]: Existing root scene presence detected for {0} {1} in {2} when connecting. Removing existing presence.",
|
||||
sp.Name, sp.UUID, RegionInfo.RegionName);
|
||||
|
||||
sp.ControllingClient.Close();
|
||||
@@ -3734,9 +3795,9 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
}
|
||||
}
|
||||
|
||||
if (m_regInfo.EstateSettings != null)
|
||||
if (RegionInfo.EstateSettings != null)
|
||||
{
|
||||
if (m_regInfo.EstateSettings.IsBanned(agent.AgentID))
|
||||
if (RegionInfo.EstateSettings.IsBanned(agent.AgentID))
|
||||
{
|
||||
m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist",
|
||||
agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName);
|
||||
@@ -3768,7 +3829,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
}
|
||||
|
||||
bool groupAccess = false;
|
||||
UUID[] estateGroups = m_regInfo.EstateSettings.EstateGroups;
|
||||
UUID[] estateGroups = RegionInfo.EstateSettings.EstateGroups;
|
||||
|
||||
if (estateGroups != null)
|
||||
{
|
||||
@@ -3786,8 +3847,8 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
m_log.ErrorFormat("[CONNECTION BEGIN]: EstateGroups is null!");
|
||||
}
|
||||
|
||||
if (!m_regInfo.EstateSettings.PublicAccess &&
|
||||
!m_regInfo.EstateSettings.HasAccess(agent.AgentID) &&
|
||||
if (!RegionInfo.EstateSettings.PublicAccess &&
|
||||
!RegionInfo.EstateSettings.HasAccess(agent.AgentID) &&
|
||||
!groupAccess)
|
||||
{
|
||||
m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the estate",
|
||||
@@ -3860,7 +3921,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
// if (loggingOffUser != null)
|
||||
// {
|
||||
// UUID localRegionSecret = UUID.Zero;
|
||||
// bool parsedsecret = UUID.TryParse(m_regInfo.regionSecret, out localRegionSecret);
|
||||
// bool parsedsecret = UUID.TryParse(RegionInfo.regionSecret, out localRegionSecret);
|
||||
//
|
||||
// // Region Secret is used here in case a new sessionid overwrites an old one on the user server.
|
||||
// // Will update the user server in a few revisions to use it.
|
||||
@@ -4079,13 +4140,13 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
ScenePresence sp = GetScenePresence(remoteClient.AgentId);
|
||||
if (sp != null)
|
||||
{
|
||||
uint regionX = m_regInfo.RegionLocX;
|
||||
uint regionY = m_regInfo.RegionLocY;
|
||||
uint regionX = RegionInfo.RegionLocX;
|
||||
uint regionY = RegionInfo.RegionLocY;
|
||||
|
||||
Utils.LongToUInts(regionHandle, out regionX, out regionY);
|
||||
|
||||
int shiftx = (int) regionX - (int) m_regInfo.RegionLocX * (int)Constants.RegionSize;
|
||||
int shifty = (int) regionY - (int) m_regInfo.RegionLocY * (int)Constants.RegionSize;
|
||||
int shiftx = (int) regionX - (int) RegionInfo.RegionLocX * (int)Constants.RegionSize;
|
||||
int shifty = (int) regionY - (int) RegionInfo.RegionLocY * (int)Constants.RegionSize;
|
||||
|
||||
position.X += shiftx;
|
||||
position.Y += shifty;
|
||||
@@ -4108,7 +4169,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
|
||||
if (!result)
|
||||
{
|
||||
regionHandle = m_regInfo.RegionHandle;
|
||||
regionHandle = RegionInfo.RegionHandle;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -4416,6 +4477,23 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
return m_sceneGraph.GetScenePresence(localID);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets all the scene presences in this scene.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This method will return both root and child scene presences.
|
||||
///
|
||||
/// Consider using ForEachScenePresence() or ForEachRootScenePresence() if possible since these will not
|
||||
/// involving creating a new List object.
|
||||
/// </remarks>
|
||||
/// <returns>
|
||||
/// A list of the scene presences. Adding or removing from the list will not affect the presences in the scene.
|
||||
/// </returns>
|
||||
public List<ScenePresence> GetScenePresences()
|
||||
{
|
||||
return new List<ScenePresence>(m_sceneGraph.GetScenePresences());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Performs action on all avatars in the scene (root scene presences)
|
||||
/// Avatars may be an NPC or a 'real' client.
|
||||
@@ -4435,6 +4513,17 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
m_sceneGraph.ForEachScenePresence(action);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get all the scene object groups.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// The scene object groups. If the scene is empty then an empty list is returned.
|
||||
/// </returns>
|
||||
public List<SceneObjectGroup> GetSceneObjectGroups()
|
||||
{
|
||||
return m_sceneGraph.GetSceneObjectGroups();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a group via its UUID
|
||||
/// </summary>
|
||||
@@ -4614,7 +4703,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
|
||||
public void DeleteFromStorage(UUID uuid)
|
||||
{
|
||||
SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID);
|
||||
SimulationDataService.RemoveObject(uuid, RegionInfo.RegionID);
|
||||
}
|
||||
|
||||
public int GetHealth()
|
||||
@@ -5039,7 +5128,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
IEstateDataService estateDataService = EstateDataService;
|
||||
if (estateDataService != null)
|
||||
{
|
||||
m_regInfo.EstateSettings = estateDataService.LoadEstateSettings(m_regInfo.RegionID, false);
|
||||
RegionInfo.EstateSettings = estateDataService.LoadEstateSettings(RegionInfo.RegionID, false);
|
||||
TriggerEstateSunUpdate();
|
||||
}
|
||||
}
|
||||
@@ -5338,5 +5427,21 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
m_SpawnPoint = 1;
|
||||
return m_SpawnPoint - 1;
|
||||
}
|
||||
|
||||
// Wrappers to get physics modules retrieve assets. Has to be done this way
|
||||
// because we can't assign the asset service to physics directly - at the
|
||||
// time physics are instantiated it's not registered but it will be by
|
||||
// the time the first prim exists.
|
||||
public void PhysicsRequestAsset(UUID assetID, AssetReceivedDelegate callback)
|
||||
{
|
||||
AssetService.Get(assetID.ToString(), callback, PhysicsAssetReceived);
|
||||
}
|
||||
|
||||
private void PhysicsAssetReceived(string id, Object sender, AssetBase asset)
|
||||
{
|
||||
AssetReceivedDelegate callback = (AssetReceivedDelegate)sender;
|
||||
|
||||
callback(asset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,6 +51,8 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
#endregion
|
||||
|
||||
#region Fields
|
||||
|
||||
public string Name { get { return RegionInfo.RegionName; } }
|
||||
|
||||
public IConfigSource Config
|
||||
{
|
||||
@@ -104,6 +106,42 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
|
||||
protected readonly ClientManager m_clientManager = new ClientManager();
|
||||
|
||||
public bool LoginsEnabled
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_loginsEnabled;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (m_loginsEnabled != value)
|
||||
{
|
||||
m_loginsEnabled = value;
|
||||
EventManager.TriggerRegionLoginsStatusChange(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
private bool m_loginsEnabled;
|
||||
|
||||
public bool Ready
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_ready;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (m_ready != value)
|
||||
{
|
||||
m_ready = value;
|
||||
EventManager.TriggerRegionReadyStatusChange(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
private bool m_ready;
|
||||
|
||||
public float TimeDilation
|
||||
{
|
||||
get { return 1.0f; }
|
||||
@@ -146,6 +184,11 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
|
||||
#endregion
|
||||
|
||||
public SceneBase(RegionInfo regInfo)
|
||||
{
|
||||
RegionInfo = regInfo;
|
||||
}
|
||||
|
||||
#region Update Methods
|
||||
|
||||
/// <summary>
|
||||
@@ -209,10 +252,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public virtual RegionInfo RegionInfo
|
||||
{
|
||||
get { return m_regInfo; }
|
||||
}
|
||||
public virtual RegionInfo RegionInfo { get; private set; }
|
||||
|
||||
#region admin stuff
|
||||
|
||||
|
||||
@@ -84,16 +84,23 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
if (neighbourService != null)
|
||||
neighbour = neighbourService.HelloNeighbour(regionhandle, region);
|
||||
else
|
||||
m_log.DebugFormat("[SCENE COMMUNICATION SERVICE]: No neighbour service provided for informing neigbhours of this region");
|
||||
m_log.DebugFormat(
|
||||
"[SCENE COMMUNICATION SERVICE]: No neighbour service provided for region {0} to inform neigbhours of status",
|
||||
m_scene.Name);
|
||||
|
||||
if (neighbour != null)
|
||||
{
|
||||
m_log.DebugFormat("[SCENE COMMUNICATION SERVICE]: Successfully informed neighbour {0}-{1} that I'm here", x / Constants.RegionSize, y / Constants.RegionSize);
|
||||
m_log.DebugFormat(
|
||||
"[SCENE COMMUNICATION SERVICE]: Region {0} successfully informed neighbour {1} at {2}-{3} that it is up",
|
||||
m_scene.Name, neighbour.RegionName, x / Constants.RegionSize, y / Constants.RegionSize);
|
||||
|
||||
m_scene.EventManager.TriggerOnRegionUp(neighbour);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_log.InfoFormat("[SCENE COMMUNICATION SERVICE]: Failed to inform neighbour {0}-{1} that I'm here.", x / Constants.RegionSize, y / Constants.RegionSize);
|
||||
m_log.WarnFormat(
|
||||
"[SCENE COMMUNICATION SERVICE]: Region {0} failed to inform neighbour at {1}-{2} that it is up.",
|
||||
m_scene.Name, x / Constants.RegionSize, y / Constants.RegionSize);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,8 +108,13 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
{
|
||||
//m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: Sending InterRegion Notification that region is up " + region.RegionName);
|
||||
|
||||
List<GridRegion> neighbours = m_scene.GridService.GetNeighbours(m_scene.RegionInfo.ScopeID, m_scene.RegionInfo.RegionID);
|
||||
m_log.DebugFormat("[SCENE COMMUNICATION SERVICE]: Informing {0} neighbours that this region is up", neighbours.Count);
|
||||
List<GridRegion> neighbours
|
||||
= m_scene.GridService.GetNeighbours(m_scene.RegionInfo.ScopeID, m_scene.RegionInfo.RegionID);
|
||||
|
||||
m_log.DebugFormat(
|
||||
"[SCENE COMMUNICATION SERVICE]: Informing {0} neighbours that region {1} is up",
|
||||
neighbours.Count, m_scene.Name);
|
||||
|
||||
foreach (GridRegion n in neighbours)
|
||||
{
|
||||
InformNeighbourThatRegionUpDelegate d = InformNeighboursThatRegionIsUpAsync;
|
||||
|
||||
@@ -355,9 +355,9 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
|
||||
if (Entities.ContainsKey(sceneObject.UUID))
|
||||
{
|
||||
// m_log.DebugFormat(
|
||||
// "[SCENEGRAPH]: Scene graph for {0} already contains object {1} in AddSceneObject()",
|
||||
// m_parentScene.RegionInfo.RegionName, sceneObject.UUID);
|
||||
m_log.DebugFormat(
|
||||
"[SCENEGRAPH]: Scene graph for {0} already contains object {1} in AddSceneObject()",
|
||||
m_parentScene.RegionInfo.RegionName, sceneObject.UUID);
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -768,7 +768,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
/// pass a delegate to ForEachScenePresence.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private List<ScenePresence> GetScenePresences()
|
||||
protected internal List<ScenePresence> GetScenePresences()
|
||||
{
|
||||
return m_scenePresenceArray;
|
||||
}
|
||||
@@ -957,6 +957,18 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get all the scene object groups.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// The scene object groups. If the scene is empty then an empty list is returned.
|
||||
/// </returns>
|
||||
protected internal List<SceneObjectGroup> GetSceneObjectGroups()
|
||||
{
|
||||
lock (SceneObjectGroupsByFullID)
|
||||
return new List<SceneObjectGroup>(SceneObjectGroupsByFullID.Values);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a group in the scene
|
||||
/// </summary>
|
||||
@@ -1100,11 +1112,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
/// <param name="action"></param>
|
||||
protected internal void ForEachSOG(Action<SceneObjectGroup> action)
|
||||
{
|
||||
List<SceneObjectGroup> objlist;
|
||||
lock (SceneObjectGroupsByFullID)
|
||||
objlist = new List<SceneObjectGroup>(SceneObjectGroupsByFullID.Values);
|
||||
|
||||
foreach (SceneObjectGroup obj in objlist)
|
||||
foreach (SceneObjectGroup obj in GetSceneObjectGroups())
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -1630,6 +1638,8 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
{
|
||||
parentGroup.LinkToGroup(child);
|
||||
|
||||
child.DetachFromBackup();
|
||||
|
||||
// this is here so physics gets updated!
|
||||
// Don't remove! Bad juju! Stay away! or fix physics!
|
||||
child.AbsolutePosition = child.AbsolutePosition;
|
||||
|
||||
@@ -47,6 +47,48 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
|
||||
public event RestartSim OnRestartSim;
|
||||
|
||||
/// <summary>
|
||||
/// Fired when either all regions are ready for use or at least one region has become unready for use where
|
||||
/// previously all regions were ready.
|
||||
/// </summary>
|
||||
public event Action<SceneManager> OnRegionsReadyStatusChange;
|
||||
|
||||
/// <summary>
|
||||
/// Are all regions ready for use?
|
||||
/// </summary>
|
||||
public bool AllRegionsReady
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_allRegionsReady;
|
||||
}
|
||||
|
||||
private set
|
||||
{
|
||||
if (m_allRegionsReady != value)
|
||||
{
|
||||
m_allRegionsReady = value;
|
||||
Action<SceneManager> handler = OnRegionsReadyStatusChange;
|
||||
if (handler != null)
|
||||
{
|
||||
foreach (Action<SceneManager> d in handler.GetInvocationList())
|
||||
{
|
||||
try
|
||||
{
|
||||
d(this);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.ErrorFormat("[SCENE MANAGER]: Delegate for OnRegionsReadyStatusChange failed - continuing {0} - {1}",
|
||||
e.Message, e.StackTrace);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private bool m_allRegionsReady;
|
||||
|
||||
private static SceneManager m_instance = null;
|
||||
public static SceneManager Instance
|
||||
{
|
||||
@@ -141,10 +183,11 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
|
||||
public void Add(Scene scene)
|
||||
{
|
||||
scene.OnRestart += HandleRestart;
|
||||
|
||||
lock (m_localScenes)
|
||||
m_localScenes.Add(scene);
|
||||
|
||||
scene.OnRestart += HandleRestart;
|
||||
scene.EventManager.OnRegionReadyStatusChange += HandleRegionReadyStatusChange;
|
||||
}
|
||||
|
||||
public void HandleRestart(RegionInfo rdata)
|
||||
@@ -175,6 +218,12 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
OnRestartSim(rdata);
|
||||
}
|
||||
|
||||
private void HandleRegionReadyStatusChange(IScene scene)
|
||||
{
|
||||
lock (m_localScenes)
|
||||
AllRegionsReady = m_localScenes.TrueForAll(s => s.Ready);
|
||||
}
|
||||
|
||||
public void SendSimOnlineNotification(ulong regionHandle)
|
||||
{
|
||||
RegionInfo Result = null;
|
||||
|
||||
@@ -79,7 +79,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stop the scripts contained in all the prims in this group
|
||||
/// Stop and remove the scripts contained in all the prims in this group
|
||||
/// </summary>
|
||||
/// <param name="sceneObjectBeingDeleted">
|
||||
/// Should be true if these scripts are being removed because the scene
|
||||
@@ -92,6 +92,14 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
parts[i].Inventory.RemoveScriptInstances(sceneObjectBeingDeleted);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stop the scripts contained in all the prims in this group
|
||||
/// </summary>
|
||||
public void StopScriptInstances()
|
||||
{
|
||||
Array.ForEach<SceneObjectPart>(m_parts.GetArray(), p => p.Inventory.StopScriptInstances());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add an inventory item from a user's inventory to a prim in this scene object.
|
||||
/// </summary>
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
@@ -108,6 +109,15 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
private long timeFirstChanged;
|
||||
private long timeLastChanged;
|
||||
|
||||
/// <summary>
|
||||
/// This indicates whether the object has changed such that it needs to be repersisted to permenant storage
|
||||
/// (the database).
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Ultimately, this should be managed such that region modules can change it at the end of a set of operations
|
||||
/// so that either all changes are preserved or none at all. However, currently, a large amount of internal
|
||||
/// code will set this anyway when some object properties are changed.
|
||||
/// </remarks>
|
||||
public bool HasGroupChanged
|
||||
{
|
||||
set
|
||||
@@ -442,6 +452,8 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
}
|
||||
}
|
||||
|
||||
// Restuff the new GroupPosition into each SOP of the linkset.
|
||||
// This has the affect of resetting and tainting the physics actors.
|
||||
SceneObjectPart[] parts = m_parts.GetArray();
|
||||
for (int i = 0; i < parts.Length; i++)
|
||||
parts[i].GroupPosition = val;
|
||||
@@ -599,6 +611,14 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
/// </remarks>
|
||||
public UUID FromItemID { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Refers to the SceneObjectPart.UUID property of the object that this object was rezzed from, if applicable.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// If not applicable will be UUID.Zero
|
||||
/// </remarks>
|
||||
public UUID FromPartID { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The folder ID that this object was rezzed from, if applicable.
|
||||
/// </summary>
|
||||
@@ -629,7 +649,8 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
/// The original SceneObjectPart will be used rather than a copy, preserving
|
||||
/// its existing localID and UUID.
|
||||
/// </summary>
|
||||
public SceneObjectGroup(SceneObjectPart part)
|
||||
/// <param name='part'>Root part for this scene object.</param>
|
||||
public SceneObjectGroup(SceneObjectPart part) : this()
|
||||
{
|
||||
SetRootPart(part);
|
||||
}
|
||||
@@ -638,8 +659,8 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
/// Constructor. This object is added to the scene later via AttachToScene()
|
||||
/// </summary>
|
||||
public SceneObjectGroup(UUID ownerID, Vector3 pos, Quaternion rot, PrimitiveBaseShape shape)
|
||||
:this(new SceneObjectPart(ownerID, shape, pos, rot, Vector3.Zero))
|
||||
{
|
||||
SetRootPart(new SceneObjectPart(ownerID, shape, pos, rot, Vector3.Zero));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1046,16 +1067,6 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
{
|
||||
return Utils.FloatToUInt16(m_scene.TimeDilation, 0.0f, 1.0f);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Added as a way for the storage provider to reset the scene,
|
||||
/// most likely a better way to do this sort of thing but for now...
|
||||
/// </summary>
|
||||
/// <param name="scene"></param>
|
||||
public void SetScene(Scene scene)
|
||||
{
|
||||
m_scene = scene;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set a part to act as the root part for this scene object
|
||||
@@ -1134,6 +1145,9 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
|
||||
public void ResetChildPrimPhysicsPositions()
|
||||
{
|
||||
// Setting this SOG's absolute position also loops through and sets the positions
|
||||
// of the SOP's in this SOG's linkset. This has the side affect of making sure
|
||||
// the physics world matches the simulated world.
|
||||
AbsolutePosition = AbsolutePosition; // could someone in the know please explain how this works?
|
||||
|
||||
// teravus: AbsolutePosition is NOT a normal property!
|
||||
@@ -1817,8 +1831,13 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Schedule a full update for this scene object
|
||||
/// Schedule a full update for this scene object to all interested viewers.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Ultimately, this should be managed such that region modules can invoke it at the end of a set of operations
|
||||
/// so that either all changes are sent at once. However, currently, a large amount of internal
|
||||
/// code will set this anyway when some object properties are changed.
|
||||
/// </remarks>
|
||||
public void ScheduleGroupForFullUpdate()
|
||||
{
|
||||
// if (IsAttachment)
|
||||
@@ -1837,8 +1856,13 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Schedule a terse update for this scene object
|
||||
/// Schedule a terse update for this scene object to all interested viewers.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Ultimately, this should be managed such that region modules can invoke it at the end of a set of operations
|
||||
/// so that either all changes are sent at once. However, currently, a large amount of internal
|
||||
/// code will set this anyway when some object properties are changed.
|
||||
/// </remarks>
|
||||
public void ScheduleGroupForTerseUpdate()
|
||||
{
|
||||
// m_log.DebugFormat("[SOG]: Scheduling terse update for {0} {1}", Name, UUID);
|
||||
@@ -1978,6 +2002,8 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
LinkToGroup(objectGroup, false);
|
||||
}
|
||||
|
||||
// Link an existing group to this group.
|
||||
// The group being linked need not be a linkset -- it can have just one prim.
|
||||
public void LinkToGroup(SceneObjectGroup objectGroup, bool insert)
|
||||
{
|
||||
// m_log.DebugFormat(
|
||||
@@ -1988,35 +2014,51 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
if (objectGroup == this)
|
||||
return;
|
||||
|
||||
// 'linkPart' == the root of the group being linked into this group
|
||||
SceneObjectPart linkPart = objectGroup.m_rootPart;
|
||||
|
||||
// physics flags from group to be applied to linked parts
|
||||
bool grpusephys = UsesPhysics;
|
||||
bool grptemporary = IsTemporary;
|
||||
|
||||
// Remember where the group being linked thought it was
|
||||
Vector3 oldGroupPosition = linkPart.GroupPosition;
|
||||
Quaternion oldRootRotation = linkPart.RotationOffset;
|
||||
|
||||
linkPart.OffsetPosition = linkPart.GroupPosition - AbsolutePosition;
|
||||
linkPart.ParentID = m_rootPart.LocalId;
|
||||
linkPart.GroupPosition = AbsolutePosition;
|
||||
Vector3 axPos = linkPart.OffsetPosition;
|
||||
// A linked SOP remembers its location and rotation relative to the root of a group.
|
||||
// Convert the root of the group being linked to be relative to the
|
||||
// root of the group being linked to.
|
||||
// Note: Some of the assignments have complex side effects.
|
||||
|
||||
// First move the new group's root SOP's position to be relative to ours
|
||||
// (radams1: Not sure if the multiple setting of OffsetPosition is required. If not,
|
||||
// this code can be reordered to have a more logical flow.)
|
||||
linkPart.OffsetPosition = linkPart.GroupPosition - AbsolutePosition;
|
||||
// Assign the new parent to the root of the old group
|
||||
linkPart.ParentID = m_rootPart.LocalId;
|
||||
// Now that it's a child, it's group position is our root position
|
||||
linkPart.GroupPosition = AbsolutePosition;
|
||||
|
||||
Vector3 axPos = linkPart.OffsetPosition;
|
||||
// Rotate the linking root SOP's position to be relative to the new root prim
|
||||
Quaternion parentRot = m_rootPart.RotationOffset;
|
||||
axPos *= Quaternion.Inverse(parentRot);
|
||||
|
||||
linkPart.OffsetPosition = axPos;
|
||||
|
||||
// Make the linking root SOP's rotation relative to the new root prim
|
||||
Quaternion oldRot = linkPart.RotationOffset;
|
||||
Quaternion newRot = Quaternion.Inverse(parentRot) * oldRot;
|
||||
linkPart.RotationOffset = newRot;
|
||||
|
||||
linkPart.ParentID = m_rootPart.LocalId;
|
||||
|
||||
// If there is only one SOP in a SOG, the LinkNum is zero. I.e., not a linkset.
|
||||
// Now that we know this SOG has at least two SOPs in it, the new root
|
||||
// SOP becomes the first in the linkset.
|
||||
if (m_rootPart.LinkNum == 0)
|
||||
m_rootPart.LinkNum = 1;
|
||||
|
||||
lock (m_parts.SyncRoot)
|
||||
{
|
||||
// Calculate the new link number for the old root SOP
|
||||
int linkNum;
|
||||
if (insert)
|
||||
{
|
||||
@@ -2032,6 +2074,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
linkNum = PrimCount + 1;
|
||||
}
|
||||
|
||||
// Add the old root SOP as a part in our group's list
|
||||
m_parts.Add(linkPart.UUID, linkPart);
|
||||
|
||||
linkPart.SetParent(this);
|
||||
@@ -2039,6 +2082,8 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
|
||||
// let physics know preserve part volume dtc messy since UpdatePrimFlags doesn't look to parent changes for now
|
||||
linkPart.UpdatePrimFlags(grpusephys, grptemporary, (IsPhantom || (linkPart.Flags & PrimFlags.Phantom) != 0), linkPart.VolumeDetectActive);
|
||||
|
||||
// If the added SOP is physical, also tell the physics engine about the link relationship.
|
||||
if (linkPart.PhysActor != null && m_rootPart.PhysActor != null && m_rootPart.PhysActor.IsPhysical)
|
||||
{
|
||||
linkPart.PhysActor.link(m_rootPart.PhysActor);
|
||||
@@ -2047,20 +2092,26 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
|
||||
linkPart.LinkNum = linkNum++;
|
||||
|
||||
// Get a list of the SOP's in the old group in order of their linknum's.
|
||||
SceneObjectPart[] ogParts = objectGroup.Parts;
|
||||
Array.Sort(ogParts, delegate(SceneObjectPart a, SceneObjectPart b)
|
||||
{
|
||||
return a.LinkNum - b.LinkNum;
|
||||
});
|
||||
|
||||
// Add each of the SOP's from the old linkset to our linkset
|
||||
for (int i = 0; i < ogParts.Length; i++)
|
||||
{
|
||||
SceneObjectPart part = ogParts[i];
|
||||
if (part.UUID != objectGroup.m_rootPart.UUID)
|
||||
{
|
||||
LinkNonRootPart(part, oldGroupPosition, oldRootRotation, linkNum++);
|
||||
// let physics know
|
||||
|
||||
// Update the physics flags for the newly added SOP
|
||||
// (Is this necessary? LinkNonRootPart() has already called UpdatePrimFlags but with different flags!??)
|
||||
part.UpdatePrimFlags(grpusephys, grptemporary, (IsPhantom || (part.Flags & PrimFlags.Phantom) != 0), part.VolumeDetectActive);
|
||||
|
||||
// If the added SOP is physical, also tell the physics engine about the link relationship.
|
||||
if (part.PhysActor != null && m_rootPart.PhysActor != null && m_rootPart.PhysActor.IsPhysical)
|
||||
{
|
||||
part.PhysActor.link(m_rootPart.PhysActor);
|
||||
@@ -2071,6 +2122,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
}
|
||||
}
|
||||
|
||||
// Now that we've aquired all of the old SOG's parts, remove the old SOG from the scene.
|
||||
m_scene.UnlinkSceneObject(objectGroup, true);
|
||||
objectGroup.IsDeleted = true;
|
||||
|
||||
@@ -2143,7 +2195,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
/// <remarks>
|
||||
/// FIXME: This method should not be called directly since it bypasses update locking, allowing a potential race
|
||||
/// condition. But currently there is no
|
||||
/// alternative method that does take a lonk to delink a single prim.
|
||||
/// alternative method that does take a lock to delink a single prim.
|
||||
/// </remarks>
|
||||
/// <param name="partID"></param>
|
||||
/// <param name="sendEvents"></param>
|
||||
@@ -2156,6 +2208,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
|
||||
linkPart.ClearUndoState();
|
||||
|
||||
Vector3 worldPos = linkPart.GetWorldPosition();
|
||||
Quaternion worldRot = linkPart.GetWorldRotation();
|
||||
|
||||
// Remove the part from this object
|
||||
@@ -2165,6 +2218,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
|
||||
SceneObjectPart[] parts = m_parts.GetArray();
|
||||
|
||||
// Rejigger the linknum's of the remaining SOP's to fill any gap
|
||||
if (parts.Length == 1 && RootPart != null)
|
||||
{
|
||||
// Single prim left
|
||||
@@ -2186,22 +2240,31 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
|
||||
PhysicsActor linkPartPa = linkPart.PhysActor;
|
||||
|
||||
// Remove the SOP from the physical scene.
|
||||
// If the new SOG is physical, it is re-created later.
|
||||
// (There is a problem here in that we have not yet told the physics
|
||||
// engine about the delink. Someday, linksets should be made first
|
||||
// class objects in the physics engine interface).
|
||||
if (linkPartPa != null)
|
||||
m_scene.PhysicsScene.RemovePrim(linkPartPa);
|
||||
|
||||
// We need to reset the child part's position
|
||||
// ready for life as a separate object after being a part of another object
|
||||
|
||||
/* This commented out code seems to recompute what GetWorldPosition already does.
|
||||
* Replace with a call to GetWorldPosition (before unlinking)
|
||||
Quaternion parentRot = m_rootPart.RotationOffset;
|
||||
|
||||
Vector3 axPos = linkPart.OffsetPosition;
|
||||
|
||||
axPos *= parentRot;
|
||||
linkPart.OffsetPosition = new Vector3(axPos.X, axPos.Y, axPos.Z);
|
||||
linkPart.GroupPosition = AbsolutePosition + linkPart.OffsetPosition;
|
||||
linkPart.OffsetPosition = new Vector3(0, 0, 0);
|
||||
|
||||
*/
|
||||
linkPart.GroupPosition = worldPos;
|
||||
linkPart.OffsetPosition = Vector3.Zero;
|
||||
linkPart.RotationOffset = worldRot;
|
||||
|
||||
// Create a new SOG to go around this unlinked and unattached SOP
|
||||
SceneObjectGroup objectGroup = new SceneObjectGroup(linkPart);
|
||||
|
||||
m_scene.AddNewSceneObject(objectGroup, true);
|
||||
@@ -2230,42 +2293,56 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
m_isBackedUp = false;
|
||||
}
|
||||
|
||||
// This links an SOP from a previous linkset into my linkset.
|
||||
// The trick is that the SOP's position and rotation are relative to the old root SOP's
|
||||
// so we are passed in the position and rotation of the old linkset so this can
|
||||
// unjigger this SOP's position and rotation from the previous linkset and
|
||||
// then make them relative to my linkset root.
|
||||
private void LinkNonRootPart(SceneObjectPart part, Vector3 oldGroupPosition, Quaternion oldGroupRotation, int linkNum)
|
||||
{
|
||||
Quaternion parentRot = oldGroupRotation;
|
||||
Quaternion oldRot = part.RotationOffset;
|
||||
Quaternion worldRot = parentRot * oldRot;
|
||||
|
||||
parentRot = oldGroupRotation;
|
||||
|
||||
// Move our position to not be relative to the old parent
|
||||
Vector3 axPos = part.OffsetPosition;
|
||||
|
||||
axPos *= parentRot;
|
||||
part.OffsetPosition = axPos;
|
||||
part.GroupPosition = oldGroupPosition + part.OffsetPosition;
|
||||
part.OffsetPosition = Vector3.Zero;
|
||||
|
||||
// Compution our rotation to be not relative to the old parent
|
||||
Quaternion worldRot = parentRot * oldRot;
|
||||
part.RotationOffset = worldRot;
|
||||
|
||||
// Add this SOP to our linkset
|
||||
part.SetParent(this);
|
||||
part.ParentID = m_rootPart.LocalId;
|
||||
|
||||
m_parts.Add(part.UUID, part);
|
||||
|
||||
part.LinkNum = linkNum;
|
||||
|
||||
// Compute the new position of this SOP relative to the group position
|
||||
part.OffsetPosition = part.GroupPosition - AbsolutePosition;
|
||||
|
||||
Quaternion rootRotation = m_rootPart.RotationOffset;
|
||||
// (radams1 20120711: I don't know why part.OffsetPosition is set multiple times.
|
||||
// It would have the affect of setting the physics engine position multiple
|
||||
// times. In theory, that is not necessary but I don't have a good linkset
|
||||
// test to know that cleaning up this code wouldn't break things.)
|
||||
|
||||
// Rotate the relative position by the rotation of the group
|
||||
Quaternion rootRotation = m_rootPart.RotationOffset;
|
||||
Vector3 pos = part.OffsetPosition;
|
||||
pos *= Quaternion.Inverse(rootRotation);
|
||||
part.OffsetPosition = pos;
|
||||
|
||||
// Compute the SOP's rotation relative to the rotation of the group.
|
||||
parentRot = m_rootPart.RotationOffset;
|
||||
oldRot = part.RotationOffset;
|
||||
Quaternion newRot = Quaternion.Inverse(parentRot) * oldRot;
|
||||
part.RotationOffset = newRot;
|
||||
|
||||
// Since this SOP's state has changed, push those changes into the physics engine
|
||||
// and the simulator.
|
||||
part.UpdatePrimFlags(UsesPhysics, IsTemporary, IsPhantom, IsVolumeDetect);
|
||||
}
|
||||
|
||||
@@ -3392,6 +3469,20 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
return count;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of sitting avatars.
|
||||
/// </summary>
|
||||
/// <remarks>This applies to all sitting avatars whether there is a sit target set or not.</remarks>
|
||||
/// <returns></returns>
|
||||
public int GetSittingAvatarsCount()
|
||||
{
|
||||
int count = 0;
|
||||
|
||||
Array.ForEach<SceneObjectPart>(m_parts.GetArray(), p => count += p.GetSittingAvatarsCount());
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return String.Format("{0} {1} ({2})", Name, UUID, AbsolutePosition);
|
||||
|
||||
@@ -135,6 +135,21 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
get { return ParentGroup.RootPart == this; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Is an explicit sit target set for this part?
|
||||
/// </summary>
|
||||
public bool IsSitTargetSet
|
||||
{
|
||||
get
|
||||
{
|
||||
return
|
||||
!(SitTargetPosition == Vector3.Zero
|
||||
&& (SitTargetOrientation == Quaternion.Identity // Valid Zero Rotation quaternion
|
||||
|| SitTargetOrientation.X == 0f && SitTargetOrientation.Y == 0f && SitTargetOrientation.Z == 1f && SitTargetOrientation.W == 0f // W-Z Mapping was invalid at one point
|
||||
|| SitTargetOrientation.X == 0f && SitTargetOrientation.Y == 0f && SitTargetOrientation.Z == 0f && SitTargetOrientation.W == 0f)); // Invalid Quaternion
|
||||
}
|
||||
}
|
||||
|
||||
#region Fields
|
||||
|
||||
public bool AllowedDrop;
|
||||
@@ -374,7 +389,6 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
private uint _category;
|
||||
private Int32 _creationDate;
|
||||
private uint _parentID = 0;
|
||||
private UUID m_sitTargetAvatar = UUID.Zero;
|
||||
private uint _baseMask = (uint)PermissionMask.All;
|
||||
private uint _ownerMask = (uint)PermissionMask.All;
|
||||
private uint _groupMask = (uint)PermissionMask.None;
|
||||
@@ -679,9 +693,11 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
{
|
||||
// If this is a linkset, we don't want the physics engine mucking up our group position here.
|
||||
PhysicsActor actor = PhysActor;
|
||||
// If physical and the root prim of a linkset, the position of the group is what physics thinks.
|
||||
if (actor != null && ParentID == 0)
|
||||
m_groupPosition = actor.Position;
|
||||
|
||||
// If I'm an attachment, my position is reported as the position of who I'm attached to
|
||||
if (ParentGroup.IsAttachment)
|
||||
{
|
||||
ScenePresence sp = ParentGroup.Scene.GetScenePresence(ParentGroup.AttachedAvatar);
|
||||
@@ -707,7 +723,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
}
|
||||
else
|
||||
{
|
||||
// To move the child prim in respect to the group position and rotation we have to calculate
|
||||
// The physics engine always sees all objects (root or linked) in world coordinates.
|
||||
actor.Position = GetWorldPosition();
|
||||
actor.Orientation = GetWorldRotation();
|
||||
}
|
||||
@@ -717,7 +733,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.Error("[SCENEOBJECTPART]: GROUP POSITION. " + e.Message);
|
||||
m_log.ErrorFormat("[SCENEOBJECTPART]: GROUP POSITION. {0}", e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -781,6 +797,8 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
{
|
||||
// We don't want the physics engine mucking up the rotations in a linkset
|
||||
PhysicsActor actor = PhysActor;
|
||||
// If this is a root of a linkset, the real rotation is what the physics engine thinks.
|
||||
// If not a root prim, the offset rotation is computed by SOG and is relative to the root.
|
||||
if (ParentID == 0 && (Shape.PCode != 9 || Shape.State == 0) && actor != null)
|
||||
{
|
||||
if (actor.Orientation.X != 0f || actor.Orientation.Y != 0f
|
||||
@@ -1233,13 +1251,20 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ID of the avatar that is sat on us. If there is no such avatar then is UUID.Zero
|
||||
/// ID of the avatar that is sat on us if we have a sit target. If there is no such avatar then is UUID.Zero
|
||||
/// </summary>
|
||||
public UUID SitTargetAvatar
|
||||
{
|
||||
get { return m_sitTargetAvatar; }
|
||||
set { m_sitTargetAvatar = value; }
|
||||
}
|
||||
public UUID SitTargetAvatar { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// IDs of all avatars start on this object part.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// We need to track this so that we can stop sat upon prims from being attached.
|
||||
/// </remarks>
|
||||
/// <value>
|
||||
/// null if there are no sitting avatars. This is to save us create a hashset for every prim in a scene.
|
||||
/// </value>
|
||||
private HashSet<UUID> m_sittingAvatars;
|
||||
|
||||
public virtual UUID RegionID
|
||||
{
|
||||
@@ -1959,14 +1984,20 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
/// <returns>A Linked Child Prim objects position in world</returns>
|
||||
public Vector3 GetWorldPosition()
|
||||
{
|
||||
Quaternion parentRot = ParentGroup.RootPart.RotationOffset;
|
||||
Vector3 axPos = OffsetPosition;
|
||||
axPos *= parentRot;
|
||||
Vector3 translationOffsetPosition = axPos;
|
||||
if(_parentID == 0)
|
||||
return GroupPosition;
|
||||
Vector3 ret;
|
||||
if (_parentID == 0)
|
||||
// if a root SOP, my position is what it is
|
||||
ret = GroupPosition;
|
||||
else
|
||||
return ParentGroup.AbsolutePosition + translationOffsetPosition;
|
||||
{
|
||||
// If a child SOP, my position is relative to the root SOP so take
|
||||
// my info and add the root's position and rotation to
|
||||
// get my world position.
|
||||
Quaternion parentRot = ParentGroup.RootPart.RotationOffset;
|
||||
Vector3 translationOffsetPosition = OffsetPosition * parentRot;
|
||||
ret = ParentGroup.AbsolutePosition + translationOffsetPosition;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1983,6 +2014,8 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
}
|
||||
else
|
||||
{
|
||||
// A child SOP's rotation is relative to the root SOP's rotation.
|
||||
// Combine them to get my absolute rotation.
|
||||
Quaternion parentRot = ParentGroup.RootPart.RotationOffset;
|
||||
Quaternion oldRot = RotationOffset;
|
||||
newRot = parentRot * oldRot;
|
||||
@@ -2434,7 +2467,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
|
||||
/// <summary>
|
||||
/// Schedule a terse update for this prim. Terse updates only send position,
|
||||
/// rotation, velocity, rotational velocity and shape information.
|
||||
/// rotation, velocity and rotational velocity information.
|
||||
/// </summary>
|
||||
public void ScheduleTerseUpdate()
|
||||
{
|
||||
@@ -4493,5 +4526,99 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
Color color = Color;
|
||||
return new Color4(color.R, color.G, color.B, (byte)(0xFF - color.A));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Record an avatar sitting on this part.
|
||||
/// </summary>
|
||||
/// <remarks>This is called for all the sitting avatars whether there is a sit target set or not.</remarks>
|
||||
/// <returns>
|
||||
/// true if the avatar was not already recorded, false otherwise.
|
||||
/// </returns>
|
||||
/// <param name='avatarId'></param>
|
||||
protected internal bool AddSittingAvatar(UUID avatarId)
|
||||
{
|
||||
if (IsSitTargetSet && SitTargetAvatar == UUID.Zero)
|
||||
SitTargetAvatar = avatarId;
|
||||
|
||||
HashSet<UUID> sittingAvatars = m_sittingAvatars;
|
||||
|
||||
if (sittingAvatars == null)
|
||||
sittingAvatars = new HashSet<UUID>();
|
||||
|
||||
lock (sittingAvatars)
|
||||
{
|
||||
m_sittingAvatars = sittingAvatars;
|
||||
return m_sittingAvatars.Add(avatarId);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove an avatar recorded as sitting on this part.
|
||||
/// </summary>
|
||||
/// <remarks>This applies to all sitting avatars whether there is a sit target set or not.</remarks>
|
||||
/// <returns>
|
||||
/// true if the avatar was present and removed, false if it was not present.
|
||||
/// </returns>
|
||||
/// <param name='avatarId'></param>
|
||||
protected internal bool RemoveSittingAvatar(UUID avatarId)
|
||||
{
|
||||
if (SitTargetAvatar == avatarId)
|
||||
SitTargetAvatar = UUID.Zero;
|
||||
|
||||
HashSet<UUID> sittingAvatars = m_sittingAvatars;
|
||||
|
||||
// This can occur under a race condition where another thread
|
||||
if (sittingAvatars == null)
|
||||
return false;
|
||||
|
||||
lock (sittingAvatars)
|
||||
{
|
||||
if (sittingAvatars.Remove(avatarId))
|
||||
{
|
||||
if (sittingAvatars.Count == 0)
|
||||
m_sittingAvatars = null;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a copy of the list of sitting avatars.
|
||||
/// </summary>
|
||||
/// <remarks>This applies to all sitting avatars whether there is a sit target set or not.</remarks>
|
||||
/// <returns>A hashset of the sitting avatars. Returns null if there are no sitting avatars.</returns>
|
||||
public HashSet<UUID> GetSittingAvatars()
|
||||
{
|
||||
HashSet<UUID> sittingAvatars = m_sittingAvatars;
|
||||
|
||||
if (sittingAvatars == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
lock (sittingAvatars)
|
||||
return new HashSet<UUID>(sittingAvatars);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of sitting avatars.
|
||||
/// </summary>
|
||||
/// <remarks>This applies to all sitting avatars whether there is a sit target set or not.</remarks>
|
||||
/// <returns></returns>
|
||||
public int GetSittingAvatarsCount()
|
||||
{
|
||||
HashSet<UUID> sittingAvatars = m_sittingAvatars;
|
||||
|
||||
if (sittingAvatars == null)
|
||||
return 0;
|
||||
|
||||
lock (sittingAvatars)
|
||||
return sittingAvatars.Count;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,6 +89,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
{
|
||||
m_items = value;
|
||||
m_inventorySerial++;
|
||||
QueryScriptStates();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -217,6 +218,36 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
}
|
||||
}
|
||||
|
||||
private void QueryScriptStates()
|
||||
{
|
||||
if (m_part == null || m_part.ParentGroup == null || m_part.ParentGroup.Scene == null)
|
||||
return;
|
||||
|
||||
IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>();
|
||||
if (engines == null) // No engine at all
|
||||
return;
|
||||
|
||||
lock (Items)
|
||||
{
|
||||
foreach (TaskInventoryItem item in Items.Values)
|
||||
{
|
||||
if (item.InvType == (int)InventoryType.LSL)
|
||||
{
|
||||
foreach (IScriptModule e in engines)
|
||||
{
|
||||
bool running;
|
||||
|
||||
if (e.HasScript(item.ItemID, out running))
|
||||
{
|
||||
item.ScriptRunning = running;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource)
|
||||
{
|
||||
int scriptsValidForStarting = 0;
|
||||
@@ -249,7 +280,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stop all the scripts in this prim.
|
||||
/// Stop and remove all the scripts in this prim.
|
||||
/// </summary>
|
||||
/// <param name="sceneObjectBeingDeleted">
|
||||
/// Should be true if these scripts are being removed because the scene
|
||||
@@ -262,6 +293,14 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
RemoveScriptInstance(item.ItemID, sceneObjectBeingDeleted);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stop all the scripts in this prim.
|
||||
/// </summary>
|
||||
public void StopScriptInstances()
|
||||
{
|
||||
GetInventoryItems(InventoryType.LSL).ForEach(i => StopScriptInstance(i));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Start a script which is in this prim's inventory.
|
||||
/// </summary>
|
||||
@@ -321,6 +360,9 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
string script = Utils.BytesToString(asset.Data);
|
||||
m_part.ParentGroup.Scene.EventManager.TriggerRezScript(
|
||||
m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource);
|
||||
if (!item.ScriptRunning)
|
||||
m_part.ParentGroup.Scene.EventManager.TriggerStopScript(
|
||||
m_part.LocalId, item.ItemID);
|
||||
m_part.ParentGroup.AddActiveScriptCount(1);
|
||||
m_part.ScheduleFullUpdate();
|
||||
|
||||
@@ -409,7 +451,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stop a script which is in this prim's inventory.
|
||||
/// Stop and remove a script which is in this prim's inventory.
|
||||
/// </summary>
|
||||
/// <param name="itemId"></param>
|
||||
/// <param name="sceneObjectBeingDeleted">
|
||||
@@ -436,7 +478,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
}
|
||||
else
|
||||
{
|
||||
m_log.ErrorFormat(
|
||||
m_log.WarnFormat(
|
||||
"[PRIM INVENTORY]: " +
|
||||
"Couldn't stop script with ID {0} since it couldn't be found for prim {1}, {2} at {3} in {4}",
|
||||
itemId, m_part.Name, m_part.UUID,
|
||||
@@ -444,6 +486,51 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stop a script which is in this prim's inventory.
|
||||
/// </summary>
|
||||
/// <param name="itemId"></param>
|
||||
/// <param name="sceneObjectBeingDeleted">
|
||||
/// Should be true if this script is being removed because the scene
|
||||
/// object is being deleted. This will prevent spurious updates to the client.
|
||||
/// </param>
|
||||
public void StopScriptInstance(UUID itemId)
|
||||
{
|
||||
TaskInventoryItem scriptItem;
|
||||
|
||||
lock (m_items)
|
||||
m_items.TryGetValue(itemId, out scriptItem);
|
||||
|
||||
if (scriptItem != null)
|
||||
{
|
||||
StopScriptInstance(scriptItem);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_log.WarnFormat(
|
||||
"[PRIM INVENTORY]: " +
|
||||
"Couldn't stop script with ID {0} since it couldn't be found for prim {1}, {2} at {3} in {4}",
|
||||
itemId, m_part.Name, m_part.UUID,
|
||||
m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stop a script which is in this prim's inventory.
|
||||
/// </summary>
|
||||
/// <param name="itemId"></param>
|
||||
/// <param name="sceneObjectBeingDeleted">
|
||||
/// Should be true if this script is being removed because the scene
|
||||
/// object is being deleted. This will prevent spurious updates to the client.
|
||||
/// </param>
|
||||
public void StopScriptInstance(TaskInventoryItem item)
|
||||
{
|
||||
m_part.ParentGroup.Scene.EventManager.TriggerStopScript(m_part.LocalId, item.ItemID);
|
||||
|
||||
// At the moment, even stopped scripts are counted as active, which is probably wrong.
|
||||
// m_part.ParentGroup.AddActiveScriptCount(-1);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check if the inventory holds an item with a given name.
|
||||
/// </summary>
|
||||
@@ -1208,6 +1295,10 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
{
|
||||
if (e != null)
|
||||
{
|
||||
// m_log.DebugFormat(
|
||||
// "[PRIM INVENTORY]: Getting script state from engine {0} for {1} in part {2} in group {3} in {4}",
|
||||
// e.Name, item.Name, m_part.Name, m_part.ParentGroup.Name, m_part.ParentGroup.Scene.Name);
|
||||
|
||||
string n = e.GetXMLState(item.ItemID);
|
||||
if (n != String.Empty)
|
||||
{
|
||||
@@ -1251,4 +1342,4 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,15 +109,10 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
|
||||
public UUID currentParcelUUID = UUID.Zero;
|
||||
|
||||
protected ScenePresenceAnimator m_animator;
|
||||
/// <value>
|
||||
/// The animator for this avatar
|
||||
/// </value>
|
||||
public ScenePresenceAnimator Animator
|
||||
{
|
||||
get { return m_animator; }
|
||||
private set { m_animator = value; }
|
||||
}
|
||||
public ScenePresenceAnimator Animator { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Attachments recorded on this avatar.
|
||||
@@ -577,6 +572,12 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
/// </summary>
|
||||
public uint ParentID { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Are we sitting on an object?
|
||||
/// </summary>
|
||||
/// <remarks>A more readable way of testing presence sit status than ParentID == 0</remarks>
|
||||
public bool IsSatOnObject { get { return ParentID != 0; } }
|
||||
|
||||
/// <summary>
|
||||
/// If the avatar is sitting, the prim that it's sitting on. If not sitting then null.
|
||||
/// </summary>
|
||||
@@ -1793,10 +1794,6 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
}
|
||||
}
|
||||
|
||||
// Reset sit target.
|
||||
if (part.SitTargetAvatar == UUID)
|
||||
part.SitTargetAvatar = UUID.Zero;
|
||||
|
||||
ParentPosition = part.GetWorldPosition();
|
||||
ControllingClient.SendClearFollowCamProperties(part.ParentUUID);
|
||||
|
||||
@@ -1808,6 +1805,8 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
SendAvatarDataToAllAgents();
|
||||
m_requestedSitTargetID = 0;
|
||||
|
||||
part.RemoveSittingAvatar(UUID);
|
||||
|
||||
if (part != null)
|
||||
part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK);
|
||||
}
|
||||
@@ -1838,15 +1837,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
//look for prims with explicit sit targets that are available
|
||||
foreach (SceneObjectPart part in partArray)
|
||||
{
|
||||
// Is a sit target available?
|
||||
Vector3 avSitOffset = part.SitTargetPosition;
|
||||
Quaternion avSitOrientation = part.SitTargetOrientation;
|
||||
UUID avOnTargetAlready = part.SitTargetAvatar;
|
||||
|
||||
bool SitTargetUnOccupied = avOnTargetAlready == UUID.Zero;
|
||||
bool SitTargetisSet = avSitOffset != Vector3.Zero || avSitOrientation != Quaternion.Identity;
|
||||
|
||||
if (SitTargetisSet && SitTargetUnOccupied)
|
||||
if (part.IsSitTargetSet && part.SitTargetAvatar == UUID.Zero)
|
||||
{
|
||||
//switch the target to this prim
|
||||
return part;
|
||||
@@ -1857,10 +1848,8 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
return targetPart;
|
||||
}
|
||||
|
||||
private void SendSitResponse(UUID targetID, Vector3 offset, Quaternion pSitOrientation)
|
||||
private void SendSitResponse(UUID targetID, Vector3 offset, Quaternion sitOrientation)
|
||||
{
|
||||
Vector3 pos = new Vector3();
|
||||
Quaternion sitOrientation = pSitOrientation;
|
||||
Vector3 cameraEyeOffset = Vector3.Zero;
|
||||
Vector3 cameraAtOffset = Vector3.Zero;
|
||||
bool forceMouselook = false;
|
||||
@@ -1872,42 +1861,21 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
// TODO: determine position to sit at based on scene geometry; don't trust offset from client
|
||||
// see http://wiki.secondlife.com/wiki/User:Andrew_Linden/Office_Hours/2007_11_06 for details on how LL does it
|
||||
|
||||
// Is a sit target available?
|
||||
Vector3 avSitOffSet = part.SitTargetPosition;
|
||||
Quaternion avSitOrientation = part.SitTargetOrientation;
|
||||
UUID avOnTargetAlready = part.SitTargetAvatar;
|
||||
|
||||
bool SitTargetUnOccupied = (!(avOnTargetAlready != UUID.Zero));
|
||||
bool SitTargetisSet =
|
||||
(!(avSitOffSet == Vector3.Zero &&
|
||||
(
|
||||
avSitOrientation == Quaternion.Identity // Valid Zero Rotation quaternion
|
||||
|| avSitOrientation.X == 0f && avSitOrientation.Y == 0f && avSitOrientation.Z == 1f && avSitOrientation.W == 0f // W-Z Mapping was invalid at one point
|
||||
|| avSitOrientation.X == 0f && avSitOrientation.Y == 0f && avSitOrientation.Z == 0f && avSitOrientation.W == 0f // Invalid Quaternion
|
||||
)
|
||||
));
|
||||
|
||||
// m_log.DebugFormat("[SCENE PRESENCE]: {0} {1}", SitTargetisSet, SitTargetUnOccupied);
|
||||
|
||||
if (PhysicsActor != null)
|
||||
m_sitAvatarHeight = PhysicsActor.Size.Z;
|
||||
|
||||
bool canSit = false;
|
||||
pos = part.AbsolutePosition + offset;
|
||||
Vector3 pos = part.AbsolutePosition + offset;
|
||||
|
||||
if (SitTargetisSet)
|
||||
if (part.IsSitTargetSet && part.SitTargetAvatar == UUID.Zero)
|
||||
{
|
||||
if (SitTargetUnOccupied)
|
||||
{
|
||||
// m_log.DebugFormat(
|
||||
// "[SCENE PRESENCE]: Sitting {0} on {1} {2} because sit target is set and unoccupied",
|
||||
// Name, part.Name, part.LocalId);
|
||||
|
||||
part.SitTargetAvatar = UUID;
|
||||
offset = new Vector3(avSitOffSet.X, avSitOffSet.Y, avSitOffSet.Z);
|
||||
sitOrientation = avSitOrientation;
|
||||
canSit = true;
|
||||
}
|
||||
offset = part.SitTargetPosition;
|
||||
sitOrientation = part.SitTargetOrientation;
|
||||
canSit = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1920,6 +1888,12 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
AbsolutePosition = pos + new Vector3(0.0f, 0.0f, m_sitAvatarHeight);
|
||||
canSit = true;
|
||||
}
|
||||
// else
|
||||
// {
|
||||
// m_log.DebugFormat(
|
||||
// "[SCENE PRESENCE]: Ignoring sit request of {0} on {1} {2} because sit target is unset and outside 10m",
|
||||
// Name, part.Name, part.LocalId);
|
||||
// }
|
||||
}
|
||||
|
||||
if (canSit)
|
||||
@@ -1930,6 +1904,8 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
RemoveFromPhysicalScene();
|
||||
}
|
||||
|
||||
part.AddSittingAvatar(UUID);
|
||||
|
||||
cameraAtOffset = part.GetCameraAtOffset();
|
||||
cameraEyeOffset = part.GetCameraEyeOffset();
|
||||
forceMouselook = part.GetForceMouselook();
|
||||
@@ -2203,6 +2179,15 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
|
||||
if (part != null)
|
||||
{
|
||||
if (part.ParentGroup.IsAttachment)
|
||||
{
|
||||
m_log.WarnFormat(
|
||||
"[SCENE PRESENCE]: Avatar {0} tried to sit on part {1} from object {2} in {3} but this is an attachment for avatar id {4}",
|
||||
Name, part.Name, part.ParentGroup.Name, Scene.Name, part.ParentGroup.AttachedAvatar);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (part.SitTargetAvatar == UUID)
|
||||
{
|
||||
Vector3 sitTargetPos = part.SitTargetPosition;
|
||||
@@ -2579,8 +2564,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
//m_log.DebugFormat("[SCENE PRESENCE] SendAvatarDataToAgent from {0} ({1}) to {2} ({3})", Name, UUID, avatar.Name, avatar.UUID);
|
||||
|
||||
avatar.ControllingClient.SendAvatarDataImmediate(this);
|
||||
if (Animator != null)
|
||||
Animator.SendAnimPackToClient(avatar.ControllingClient);
|
||||
Animator.SendAnimPackToClient(avatar.ControllingClient);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -3084,31 +3068,8 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
}
|
||||
catch { }
|
||||
|
||||
// Attachment objects
|
||||
List<SceneObjectGroup> attachments = GetAttachments();
|
||||
if (attachments.Count > 0)
|
||||
{
|
||||
cAgent.AttachmentObjects = new List<ISceneObject>();
|
||||
cAgent.AttachmentObjectStates = new List<string>();
|
||||
// IScriptModule se = m_scene.RequestModuleInterface<IScriptModule>();
|
||||
InTransitScriptStates.Clear();
|
||||
|
||||
foreach (SceneObjectGroup sog in attachments)
|
||||
{
|
||||
// We need to make a copy and pass that copy
|
||||
// because of transfers withn the same sim
|
||||
ISceneObject clone = sog.CloneForNewScene();
|
||||
// Attachment module assumes that GroupPosition holds the offsets...!
|
||||
((SceneObjectGroup)clone).RootPart.GroupPosition = sog.RootPart.AttachedPos;
|
||||
((SceneObjectGroup)clone).IsAttachment = false;
|
||||
cAgent.AttachmentObjects.Add(clone);
|
||||
string state = sog.GetStateSnapshot();
|
||||
cAgent.AttachmentObjectStates.Add(state);
|
||||
InTransitScriptStates.Add(state);
|
||||
// Let's remove the scripts of the original object here
|
||||
sog.RemoveScriptInstances(true);
|
||||
}
|
||||
}
|
||||
if (Scene.AttachmentsModule != null)
|
||||
Scene.AttachmentsModule.CopyAttachments(this, cAgent);
|
||||
}
|
||||
|
||||
private void CopyFrom(AgentData cAgent)
|
||||
@@ -3178,18 +3139,8 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
if (cAgent.Anims != null)
|
||||
Animator.Animations.FromArray(cAgent.Anims);
|
||||
|
||||
if (cAgent.AttachmentObjects != null && cAgent.AttachmentObjects.Count > 0)
|
||||
{
|
||||
m_attachments = new List<SceneObjectGroup>();
|
||||
int i = 0;
|
||||
foreach (ISceneObject so in cAgent.AttachmentObjects)
|
||||
{
|
||||
((SceneObjectGroup)so).LocalId = 0;
|
||||
((SceneObjectGroup)so).RootPart.ClearUpdateSchedule();
|
||||
so.SetState(cAgent.AttachmentObjectStates[i++], m_scene);
|
||||
m_scene.IncomingCreateObject(Vector3.Zero, so);
|
||||
}
|
||||
}
|
||||
if (Scene.AttachmentsModule != null)
|
||||
Scene.AttachmentsModule.CopyAttachments(cAgent, this);
|
||||
}
|
||||
|
||||
public bool CopyAgent(out IAgentData agent)
|
||||
@@ -3282,14 +3233,12 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
//if ((Math.Abs(Velocity.X) > 0.1e-9f) || (Math.Abs(Velocity.Y) > 0.1e-9f))
|
||||
// The Physics Scene will send updates every 500 ms grep: PhysicsActor.SubscribeEvents(
|
||||
// as of this comment the interval is set in AddToPhysicalScene
|
||||
if (Animator != null)
|
||||
{
|
||||
|
||||
// if (m_updateCount > 0)
|
||||
// {
|
||||
Animator.UpdateMovementAnimations();
|
||||
Animator.UpdateMovementAnimations();
|
||||
// m_updateCount--;
|
||||
// }
|
||||
}
|
||||
|
||||
CollisionEventUpdate collisionData = (CollisionEventUpdate)e;
|
||||
Dictionary<uint, ContactPoint> coldata = collisionData.m_objCollisionList;
|
||||
@@ -3304,7 +3253,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
// m_lastColCount = coldata.Count;
|
||||
// }
|
||||
|
||||
if (coldata.Count != 0 && Animator != null)
|
||||
if (coldata.Count != 0)
|
||||
{
|
||||
switch (Animator.CurrentMovementAnimation)
|
||||
{
|
||||
@@ -3414,7 +3363,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
ControllingClient.SendHealth(Health);
|
||||
}
|
||||
|
||||
public void Close()
|
||||
protected internal void Close()
|
||||
{
|
||||
// Clear known regions
|
||||
KnownRegions = new Dictionary<ulong, string>();
|
||||
@@ -3430,8 +3379,6 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
// m_reprioritizationTimer.Dispose();
|
||||
|
||||
RemoveFromPhysicalScene();
|
||||
Animator.Close();
|
||||
Animator = null;
|
||||
}
|
||||
|
||||
public void AddAttachment(SceneObjectGroup gobj)
|
||||
|
||||
@@ -151,6 +151,24 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
|
||||
ToOriginalXmlFormat(sceneObject, writer, doScriptStates, false);
|
||||
}
|
||||
|
||||
public static string ToOriginalXmlFormat(SceneObjectGroup sceneObject, string scriptedState)
|
||||
{
|
||||
using (StringWriter sw = new StringWriter())
|
||||
{
|
||||
using (XmlTextWriter writer = new XmlTextWriter(sw))
|
||||
{
|
||||
writer.WriteStartElement(String.Empty, "SceneObjectGroup", String.Empty);
|
||||
|
||||
ToOriginalXmlFormat(sceneObject, writer, false, true);
|
||||
|
||||
writer.WriteRaw(scriptedState);
|
||||
|
||||
writer.WriteEndElement();
|
||||
}
|
||||
return sw.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serialize a scene object to the original xml format
|
||||
/// </summary>
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user