Merge branch 'master' of ssh://opensimulator.org/var/git/opensim

iar_mods
Dan Lake 2012-02-01 16:25:35 -08:00
commit c10193c72b
136 changed files with 5757 additions and 1738 deletions

View File

@ -38,52 +38,8 @@
<include name=".hgignore"/> <include name=".hgignore"/>
</fileset> </fileset>
</delete> </delete>
</target> </target>
<!-- I don't think these targets are being actively used. But just in case, we'll just comment them out for now - justincc -->
<!--
<property name="projectdir" value="opensim-0.6.9" />
<target name="dist" depends="distdir">
<zip zipfile="${projectdir}.zip">
<fileset basedir=".">
<include name="${projectdir}/**" />
</fileset>
</zip>
<tar destfile="${projectdir}.tar.gz" compression="GZip">
<fileset basedir=".">
<include name="${projectdir}/**" />
</fileset>
</tar>
</target>
<target name="distdir">
<delete dir="${projectdir}" />
<copy todir="${projectdir}">
<fileset basedir=".">
<include name="ThirdPartyLicenses/**" />
<include name="CONTRIBUTORS.txt" />
<include name="README" />
<include name="OpenSim/**/*.cs" />
<include name="**/*.build" />
<include name="**/*.csproj" />
<include name="**/*.csproj.user" />
<include name="**/*.sln" />
<include name="bin/*.dll" />
<include name="bin/*.so" />
<include name="bin/*.config" />
<include name="bin/assets/**" />
<include name="bin/data/**" />
<include name="bin/OpenSim*xml" />
<include name="bin/OpenSim.ini" />
<include name="bin/defaultstripe.png" />
<exclude name="bin/OpenSim.*dll" />
</fileset>
</copy>
<touch file="${projectdir}/bin/startup_commands.txt" />
</target>
-->
<target name="test" depends="build, find-nunit"> <target name="test" depends="build, find-nunit">
<setenv name="MONO_THREADS_PER_CPU" value="100" /> <setenv name="MONO_THREADS_PER_CPU" value="100" />
@ -153,116 +109,17 @@
<fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.capabilities.handlers.tests)==0}" /> <fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.capabilities.handlers.tests)==0}" />
<delete dir="%temp%"/> <delete dir="%temp%"/>
</target> </target>
<target name="test-cov" depends="build"> <target name="torture" depends="build, find-nunit">
<!-- Code Coverage Test. Prototype, only works with mono 1.2. Instructions in http://opensimulator.org/wiki/Automated_Testing --> <setenv name="MONO_THREADS_PER_CPU" value="100" />
<mkdir dir="cov" failonerror="false" />
<exec program="mono"> <exec program="${nunitcmd}" failonerror="true" resultproperty="testresult.opensim.tests.torture">
<arg value="--debug" /> <arg value="./bin/OpenSim.Tests.Torture.dll" />
<arg value="--profile=monocov:outfile=./cov/OpenSim.Framework.Servers.cov,+[OpenSim.Framework.Servers]" />
<arg value="/usr/lib/nunit/nunit-console.exe" />
<arg value="./bin/OpenSim.Framework.Servers.Tests.dll" />
</exec>
<delete dir="./cov/OpenSim.Framework.Servers" />
<exec program="monocov">
<arg value="--export-html=./cov/OpenSim.Framework.Servers ./cov/OpenSim.Framework.Servers.cov" />
</exec> </exec>
<!-- <fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.tests.torture)==0}" />
<exec program="mono"> <delete dir="%temp%"/>
<arg value="&#45;&#45;debug" />
<arg value="&#45;&#45;profile=monocov:outfile=./cov/OpenSim.Region.ClientStack.LindenUDP.cov,+[OpenSim.Region.ClientStack.LindenUDP]" />
<arg value="/usr/lib/nunit/nunit-console.exe" />
<arg value="./bin/OpenSim.Region.ClientStack.LindenUDP.Tests.dll" />
</exec>
<delete dir="./cov/OpenSim.Region.ClientStack.LindenUDP" />
<exec program="monocov">
<arg value="&#45;&#45;export-html=./cov/OpenSim.Region.ClientStack.LindenUDP ./cov/OpenSim.Region.ClientStack.LindenUDP.cov" />
</exec>
-->
<exec program="mono">
<arg value="--debug" />
<arg value="--profile=monocov:outfile=./cov/OpenSim.Region.ScriptEngine.Shared.cov,+[OpenSim.Region.ScriptEngine.Shared]" />
<arg value="/usr/lib/nunit/nunit-console.exe" />
<arg value="./bin/OpenSim.Region.ScriptEngine.Shared.Tests.dll" />
</exec>
<delete dir="./cov/OpenSim.Region.ScriptEngine.Shared" />
<exec program="monocov">
<arg value="--export-html=./cov/OpenSim.Region.ScriptEngine.Shared ./cov/OpenSim.Region.ScriptEngine.Shared.cov" />
</exec>
<exec program="mono">
<arg value="--debug" />
<arg value="--profile=monocov:outfile=./cov/OpenSim.Region.ScriptEngine.Shared.CodeTools.cov,+[OpenSim.Region.ScriptEngine.Shared.CodeTools]" />
<arg value="/usr/lib/nunit/nunit-console.exe" />
<arg value="./bin/OpenSim.Region.ScriptEngine.Shared.CodeTools.Tests.dll" />
</exec>
<delete dir="./cov/OpenSim.Region.ScriptEngine.Shared.CodeTools" />
<exec program="monocov">
<arg value="--export-html=./cov/OpenSim.Region.ScriptEngine.Shared.CodeTools ./cov/OpenSim.Region.ScriptEngine.Shared.CodeTools.cov" />
</exec>
<exec program="mono">
<arg value="--debug" />
<arg value="--profile=monocov:outfile=./cov/OpenSim.Region.CoreModules.cov,+[OpenSim.Region.CoreModules]" />
<arg value="/usr/lib/nunit/nunit-console.exe" />
<arg value="./bin/OpenSim.Region.CoreModules.Tests.dll" />
</exec>
<delete dir="./cov/OpenSim.Region.CoreModules" />
<exec program="monocov">
<arg value="--export-html=./cov/OpenSim.Region.CoreModules ./cov/OpenSim.Region.CoreModules.cov" />
</exec>
<exec program="mono">
<arg value="--debug" />
<arg value="--profile=monocov:outfile=./cov/OpenSim.Region.OptionalModules.cov,+[OpenSim.Region.OptionalModules]" />
<arg value="/usr/lib/nunit/nunit-console.exe" />
<arg value="./bin/OpenSim.Region.OptionalModules.Tests.dll" />
</exec>
<delete dir="./cov/OpenSim.Region.OptionalModules" />
<exec program="monocov">
<arg value="--export-html=./cov/OpenSim.Region.OptionalModules ./cov/OpenSim.Region.OptionalModules.cov" />
</exec>
<exec program="mono">
<arg value="--debug" />
<arg value="--profile=monocov:outfile=./cov/OpenSim.Region.Framework.cov,+[OpenSim.Region.Framework]" />
<arg value="/usr/lib/nunit/nunit-console.exe" />
<arg value="./bin/OpenSim.Region.Framework.Tests.dll" />
</exec>
<delete dir="./cov/OpenSim.Region.Framework" />
<exec program="monocov">
<arg value="--export-html=./cov/OpenSim.Region.Framework ./cov/OpenSim.Region.Framework.cov" />
</exec>
<exec program="mono">
<arg value="--debug" />
<arg value="--profile=monocov:outfile=./cov/OpenSim.Data.SQLite.cov,+[OpenSim.Data.SQLite]" />
<arg value="/usr/lib/nunit/nunit-console.exe" />
<arg value="./bin/OpenSim.Data.SQLite.Tests.dll" />
</exec>
<delete dir="./cov/OpenSim.Data.SQLite" />
<exec program="monocov">
<arg value="--export-html=./cov/OpenSim.Data.SQLite ./cov/OpenSim.Data.SQLite.cov" />
</exec>
<exec program="mono">
<arg value="--debug" />
<arg value="--profile=monocov:outfile=./cov/OpenSim.Data.MySQL.cov,+[OpenSim.Data.MySQL.Tests]" />
<arg value="/usr/lib/nunit/nunit-console.exe" />
<arg value="./bin/OpenSim.Data.MySQL.Tests.dll" />
</exec>
<delete dir="./cov/OpenSim.Data.MySQL" />
<exec program="monocov">
<arg value="--export-html=./cov/OpenSim.Data.MySQL ./cov/OpenSim.Data.MySQL.cov" />
</exec>
<delete file="C:\NUnitPrimaryTrace.txt" failonerror="false" />
<delete file="TestResult.xml" failonerror="false" />
</target> </target>
<target name="find-nunit"> <target name="find-nunit">
@ -275,15 +132,12 @@
if="${int::parse(hasnunit2)==0}" /> if="${int::parse(hasnunit2)==0}" />
<property name="nunitcmd" value="nunit-console" <property name="nunitcmd" value="nunit-console"
if="${int::parse(hasnunit2)==1}" /> if="${int::parse(hasnunit2)==1}" />
</target> </target>
<!-- this is used for panda test execution --> <!-- this is used for panda test execution -->
<!-- work in progress --> <!-- work in progress -->
<target name="test-xml" depends="build, find-nunit"> <target name="test-xml" depends="build, find-nunit">
<mkdir dir="test-results" failonerror="false" /> <mkdir dir="test-results" failonerror="false" />
<!-- Unit Test Assembly --> <!-- Unit Test Assembly -->
<exec program="${nunitcmd}" failonerror="false" resultproperty="testresult.opensim.tests"> <exec program="${nunitcmd}" failonerror="false" resultproperty="testresult.opensim.tests">
@ -356,36 +210,7 @@
<fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.region.framework.tests)==0}" /> <fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.region.framework.tests)==0}" />
<fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.data.tests)==0}" /> <fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.data.tests)==0}" />
<fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.capabilities.handlers.tests)==0}" /> <fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.capabilities.handlers.tests)==0}" />
</target> </target>
<!-- <exec program="nunit-console.exe" failonerror="false" resultproperty="testresult.acceptancetestassembly"> -->
<!-- <arg value="AcceptanceTestAssembly.dll" /> -->
<!-- <arg value="/xml=AcceptanceTestAssembly-Results.xml" /> -->
<!-- </exec> -->
<!-- <fail message="Failures reported in unit tests." unless="${int::parse(testresult.unittestassembly)==0}" /> -->
<!-- <fail message="Failures reported in acceptance tests." unless="${int::parse(testresult.acceptancetestassembly)==0}" /> -->
<!-- </target> -->
<!-- <nunit2 failonerror="true" verbose="true"> -->
<!-- <formatter type="Xml" usefile="true" extension=".xml" outputdir="./test-results" /> -->
<!-- <test> -->
<!-- <assemblies> -->
<!-- <include name="./bin/OpenSim.Framework.Tests.dll" /> -->
<!-- <include name="./bin/OpenSim.Framework.Servers.Tests.dll" /> -->
<!-- <include name="./bin/OpenSim.Region.ClientStack.LindenUDP.Tests.dll" /> -->
<!-- <include name="./bin/OpenSim.Region.ScriptEngine.Tests.dll" /> -->
<!-- <include name="./bin/OpenSim.Region.CoreModules.Tests.dll" /> -->
<!-- <include name="./bin/OpenSim.Region.OptionalModules.Tests.dll" /> -->
<!-- <include name="./bin/OpenSim.Region.Framework.Tests.dll" /> -->
<!-- <include name="./bin/OpenSim.Data.SQLite.Tests.dll" /> -->
<!-- <include name="./bin/OpenSim.Data.MySQL.Tests.dll" /> -->
<!-- </assemblies> -->
<!-- </test> -->
<!-- </nunit2> -->
<!-- </target> -->
<target name="doxygen"> <target name="doxygen">
<exec program="doxygen" workingdir="doc" commandline="doxygen.conf" /> <exec program="doxygen" workingdir="doc" commandline="doxygen.conf" />

View File

@ -17,13 +17,22 @@ Prereqs:
* On some Linux distributions you may need to install additional packages. * On some Linux distributions you may need to install additional packages.
See http://opensimulator.org/wiki/Dependencies for more information. See http://opensimulator.org/wiki/Dependencies for more information.
* May also use xbuild (included in mono distributions)
* May use Monodevelop, a cross-platform IDE
From the distribution type: From the distribution type:
* ./runprebuild.sh * ./runprebuild.sh
* nant * nant (or xbuild)
* cd bin * cd bin
* copy OpenSim.ini.example to OpenSim.ini and other appropriate files in bin/config-include * copy OpenSim.ini.example to OpenSim.ini and other appropriate files in bin/config-include
* run mono OpenSim.exe * run mono OpenSim.exe
=== Using Monodevelop ===
From the distribution type:
* ./runprebuild.sh
* type monodevelop OpenSim.sln
=== References === === References ===
Helpful resources: Helpful resources:

View File

@ -257,17 +257,13 @@ namespace OpenSim.ApplicationPlugins.RemoteController
{ {
m_log.Info("[RADMIN]: Request to restart Region."); m_log.Info("[RADMIN]: Request to restart Region.");
CheckStringParameters(requestData, responseData, new string[] {"regionID"}); CheckRegionParams(requestData, responseData);
UUID regionID = new UUID((string) requestData["regionID"]); Scene rebootedScene = null;
GetSceneFromRegionParams(requestData, responseData, out rebootedScene);
Scene rebootedScene;
responseData["success"] = false; responseData["success"] = false;
responseData["accepted"] = true; responseData["accepted"] = true;
if (!m_application.SceneManager.TryGetScene(regionID, out rebootedScene))
throw new Exception("region not found");
responseData["rebooting"] = true; responseData["rebooting"] = true;
IRestartModule restartModule = rebootedScene.RequestModuleInterface<IRestartModule>(); IRestartModule restartModule = rebootedScene.RequestModuleInterface<IRestartModule>();
@ -329,14 +325,15 @@ namespace OpenSim.ApplicationPlugins.RemoteController
// } // }
CheckStringParameters(requestData, responseData, new string[] {"filename", "regionid"}); CheckStringParameters(requestData, responseData, new string[] {"filename", "regionid"});
CheckRegionParams(requestData, responseData);
string file = (string) requestData["filename"]; Scene scene = null;
UUID regionID = (UUID) (string) requestData["regionid"]; GetSceneFromRegionParams(requestData, responseData, out scene);
m_log.InfoFormat("[RADMIN]: Terrain Loading: {0}", file); string file = (string)requestData["filename"];
responseData["accepted"] = true; responseData["accepted"] = true;
LoadHeightmap(file, regionID); LoadHeightmap(file, scene.RegionInfo.RegionID);
responseData["success"] = true; responseData["success"] = true;
@ -353,18 +350,16 @@ namespace OpenSim.ApplicationPlugins.RemoteController
// m_log.DebugFormat("[RADMIN]: Save Terrain: XmlRpc {0}", request.ToString()); // m_log.DebugFormat("[RADMIN]: Save Terrain: XmlRpc {0}", request.ToString());
CheckStringParameters(requestData, responseData, new string[] { "filename", "regionid" }); CheckStringParameters(requestData, responseData, new string[] { "filename", "regionid" });
CheckRegionParams(requestData, responseData);
Scene region = null;
GetSceneFromRegionParams(requestData, responseData, out region);
string file = (string)requestData["filename"]; string file = (string)requestData["filename"];
UUID regionID = (UUID)(string)requestData["regionid"];
m_log.InfoFormat("[RADMIN]: Terrain Saving: {0}", file); m_log.InfoFormat("[RADMIN]: Terrain Saving: {0}", file);
responseData["accepted"] = true; responseData["accepted"] = true;
Scene region = null;
if (!m_application.SceneManager.TryGetScene(regionID, out region))
throw new Exception("1: unable to get a scene with that name");
ITerrainModule terrainModule = region.RequestModuleInterface<ITerrainModule>(); ITerrainModule terrainModule = region.RequestModuleInterface<ITerrainModule>();
if (null == terrainModule) throw new Exception("terrain module not available"); if (null == terrainModule) throw new Exception("terrain module not available");
@ -732,7 +727,8 @@ namespace OpenSim.ApplicationPlugins.RemoteController
responseData["success"] = true; responseData["success"] = true;
responseData["region_name"] = region.RegionName; responseData["region_name"] = region.RegionName;
responseData["region_uuid"] = region.RegionID.ToString(); responseData["region_id"] = region.RegionID.ToString();
responseData["region_uuid"] = region.RegionID.ToString(); //Deprecate July 2012
m_log.Info("[RADMIN]: CreateRegion: request complete"); m_log.Info("[RADMIN]: CreateRegion: request complete");
} }
@ -774,16 +770,16 @@ namespace OpenSim.ApplicationPlugins.RemoteController
lock (m_requestLock) lock (m_requestLock)
{ {
CheckStringParameters(requestData, responseData, new string[] {"region_name"}); CheckStringParameters(requestData, responseData, new string[] {"region_name"});
CheckRegionParams(requestData, responseData);
Scene scene = null; Scene scene = null;
string regionName = (string) requestData["region_name"]; GetSceneFromRegionParams(requestData, responseData, out scene);
if (!m_application.SceneManager.TryGetScene(regionName, out scene))
throw new Exception(String.Format("region \"{0}\" does not exist", regionName));
m_application.RemoveRegion(scene, true); m_application.RemoveRegion(scene, true);
responseData["success"] = true; responseData["success"] = true;
responseData["region_name"] = regionName; responseData["region_name"] = scene.RegionInfo.RegionName;
responseData["region_id"] = scene.RegionInfo.RegionID;
m_log.Info("[RADMIN]: DeleteRegion: request complete"); m_log.Info("[RADMIN]: DeleteRegion: request complete");
} }
@ -823,44 +819,21 @@ namespace OpenSim.ApplicationPlugins.RemoteController
Hashtable responseData = (Hashtable)response.Value; Hashtable responseData = (Hashtable)response.Value;
Hashtable requestData = (Hashtable)request.Params[0]; Hashtable requestData = (Hashtable)request.Params[0];
Scene scene = null;
lock (m_requestLock) lock (m_requestLock)
{ {
if (requestData.ContainsKey("region_id") && CheckRegionParams(requestData, responseData);
!String.IsNullOrEmpty((string) requestData["region_id"]))
{ Scene scene = null;
// Region specified by UUID GetSceneFromRegionParams(requestData, responseData, out scene);
UUID regionID = (UUID) (string) requestData["region_id"];
if (!m_application.SceneManager.TryGetScene(regionID, out scene))
throw new Exception(String.Format("region \"{0}\" does not exist", regionID));
m_application.CloseRegion(scene); m_application.CloseRegion(scene);
responseData["success"] = true; responseData["success"] = true;
responseData["region_id"] = regionID; responseData["region_name"] = scene.RegionInfo.RegionName;
responseData["region_id"] = scene.RegionInfo.RegionID;
response.Value = responseData; response.Value = responseData;
}
else if (
requestData.ContainsKey("region_name")
&& !String.IsNullOrEmpty((string) requestData["region_name"]))
{
// Region specified by name
string regionName = (string) requestData["region_name"];
if (!m_application.SceneManager.TryGetScene(regionName, out scene))
throw new Exception(String.Format("region \"{0}\" does not exist", regionName));
m_application.CloseRegion(scene);
responseData["success"] = true;
responseData["region_name"] = regionName;
}
else
{
throw new Exception("no region specified");
}
m_log.Info("[RADMIN]: CloseRegion: request complete"); m_log.Info("[RADMIN]: CloseRegion: request complete");
} }
@ -907,12 +880,10 @@ namespace OpenSim.ApplicationPlugins.RemoteController
lock (m_requestLock) lock (m_requestLock)
{ {
CheckStringParameters(requestData, responseData, new string[] {"region_name"}); CheckRegionParams(requestData, responseData);
Scene scene = null; Scene scene = null;
string regionName = (string) requestData["region_name"]; GetSceneFromRegionParams(requestData, responseData, out scene);
if (!m_application.SceneManager.TryGetScene(regionName, out scene))
throw new Exception(String.Format("region \"{0}\" does not exist", regionName));
// Modify access // Modify access
scene.RegionInfo.EstateSettings.PublicAccess = scene.RegionInfo.EstateSettings.PublicAccess =
@ -942,7 +913,8 @@ namespace OpenSim.ApplicationPlugins.RemoteController
} }
responseData["success"] = true; responseData["success"] = true;
responseData["region_name"] = regionName; responseData["region_name"] = scene.RegionInfo.RegionName;
responseData["region_id"] = scene.RegionInfo.RegionID;
m_log.Info("[RADMIN]: ModifyRegion: request complete"); m_log.Info("[RADMIN]: ModifyRegion: request complete");
} }
@ -1338,22 +1310,12 @@ namespace OpenSim.ApplicationPlugins.RemoteController
try try
{ {
CheckStringParameters(requestData, responseData, new string[] {"filename"}); CheckStringParameters(requestData, responseData, new string[] {"filename"});
CheckRegionParams(requestData, responseData);
Scene scene = null;
GetSceneFromRegionParams(requestData, responseData, out scene);
string filename = (string) requestData["filename"]; string filename = (string) requestData["filename"];
Scene scene = null;
if (requestData.Contains("region_uuid"))
{
UUID region_uuid = (UUID) (string) requestData["region_uuid"];
if (!m_application.SceneManager.TryGetScene(region_uuid, out scene))
throw new Exception(String.Format("failed to switch to region {0}", region_uuid.ToString()));
}
else if (requestData.Contains("region_name"))
{
string region_name = (string) requestData["region_name"];
if (!m_application.SceneManager.TryGetScene(region_name, out scene))
throw new Exception(String.Format("failed to switch to region {0}", region_name));
}
else throw new Exception("neither region_name nor region_uuid given");
bool mergeOar = false; bool mergeOar = false;
bool skipAssets = false; bool skipAssets = false;
@ -1434,22 +1396,12 @@ namespace OpenSim.ApplicationPlugins.RemoteController
try try
{ {
CheckStringParameters(requestData, responseData, new string[] {"filename"}); CheckStringParameters(requestData, responseData, new string[] {"filename"});
CheckRegionParams(requestData, responseData);
Scene scene = null;
GetSceneFromRegionParams(requestData, responseData, out scene);
string filename = (string)requestData["filename"]; string filename = (string)requestData["filename"];
Scene scene = null;
if (requestData.Contains("region_uuid"))
{
UUID region_uuid = (UUID) (string) requestData["region_uuid"];
if (!m_application.SceneManager.TryGetScene(region_uuid, out scene))
throw new Exception(String.Format("failed to switch to region {0}", region_uuid.ToString()));
}
else if (requestData.Contains("region_name"))
{
string region_name = (string) requestData["region_name"];
if (!m_application.SceneManager.TryGetScene(region_name, out scene))
throw new Exception(String.Format("failed to switch to region {0}", region_name));
}
else throw new Exception("neither region_name nor region_uuid given");
Dictionary<string, object> options = new Dictionary<string, object>(); Dictionary<string, object> options = new Dictionary<string, object>();
@ -1521,25 +1473,12 @@ namespace OpenSim.ApplicationPlugins.RemoteController
try try
{ {
CheckStringParameters(requestData, responseData, new string[] {"filename"}); CheckStringParameters(requestData, responseData, new string[] {"filename"});
CheckRegionParams(requestData, responseData);
Scene scene = null;
GetSceneFromRegionParams(requestData, responseData, out scene);
string filename = (string) requestData["filename"]; string filename = (string) requestData["filename"];
if (requestData.Contains("region_uuid"))
{
UUID region_uuid = (UUID) (string) requestData["region_uuid"];
if (!m_application.SceneManager.TrySetCurrentScene(region_uuid))
throw new Exception(String.Format("failed to switch to region {0}", region_uuid.ToString()));
m_log.InfoFormat("[RADMIN]: Switched to region {0}", region_uuid.ToString());
}
else if (requestData.Contains("region_name"))
{
string region_name = (string) requestData["region_name"];
if (!m_application.SceneManager.TrySetCurrentScene(region_name))
throw new Exception(String.Format("failed to switch to region {0}", region_name));
m_log.InfoFormat("[RADMIN]: Switched to region {0}", region_name);
}
else throw new Exception("neither region_name nor region_uuid given");
responseData["switched"] = true; responseData["switched"] = true;
@ -1587,23 +1526,12 @@ namespace OpenSim.ApplicationPlugins.RemoteController
try try
{ {
CheckStringParameters(requestData, responseData, new string[] {"filename"}); CheckStringParameters(requestData, responseData, new string[] {"filename"});
CheckRegionParams(requestData, responseData);
Scene scene = null;
GetSceneFromRegionParams(requestData, responseData, out scene);
string filename = (string) requestData["filename"]; string filename = (string) requestData["filename"];
if (requestData.Contains("region_uuid"))
{
UUID region_uuid = (UUID) (string) requestData["region_uuid"];
if (!m_application.SceneManager.TrySetCurrentScene(region_uuid))
throw new Exception(String.Format("failed to switch to region {0}", region_uuid.ToString()));
m_log.InfoFormat("[RADMIN]: Switched to region {0}", region_uuid.ToString());
}
else if (requestData.Contains("region_name"))
{
string region_name = (string) requestData["region_name"];
if (!m_application.SceneManager.TrySetCurrentScene(region_name))
throw new Exception(String.Format("failed to switch to region {0}", region_name));
m_log.InfoFormat("[RADMIN]: Switched to region {0}", region_name);
}
else throw new Exception("neither region_name nor region_uuid given");
responseData["switched"] = true; responseData["switched"] = true;
@ -1647,33 +1575,15 @@ namespace OpenSim.ApplicationPlugins.RemoteController
Hashtable responseData = (Hashtable)response.Value; Hashtable responseData = (Hashtable)response.Value;
Hashtable requestData = (Hashtable)request.Params[0]; Hashtable requestData = (Hashtable)request.Params[0];
responseData["success"] = true; CheckRegionParams(requestData, responseData);
if (requestData.Contains("region_uuid")) Scene scene = null;
{ GetSceneFromRegionParams(requestData, responseData, out scene);
UUID region_uuid = (UUID) (string) requestData["region_uuid"];
if (!m_application.SceneManager.TrySetCurrentScene(region_uuid))
throw new Exception(String.Format("failed to switch to region {0}", region_uuid.ToString()));
m_log.InfoFormat("[RADMIN]: Switched to region {0}", region_uuid.ToString());
}
else if (requestData.Contains("region_name"))
{
string region_name = (string) requestData["region_name"];
if (!m_application.SceneManager.TrySetCurrentScene(region_name))
throw new Exception(String.Format("failed to switch to region {0}", region_name));
m_log.InfoFormat("[RADMIN]: Switched to region {0}", region_name);
}
else
{
throw new Exception("neither region_name nor region_uuid given");
}
Scene scene = m_application.SceneManager.CurrentScene;
int health = scene.GetHealth(); int health = scene.GetHealth();
responseData["health"] = health; responseData["health"] = health;
responseData["success"] = true;
m_log.Info("[RADMIN]: Query XML Administrator Request complete"); m_log.Info("[RADMIN]: Query XML Administrator Request complete");
} }
@ -1700,24 +1610,11 @@ namespace OpenSim.ApplicationPlugins.RemoteController
responseData["success"] = true; responseData["success"] = true;
if (requestData.Contains("region_uuid")) CheckRegionParams(requestData, responseData);
{
UUID region_uuid = (UUID) (string) requestData["region_uuid"];
if (!m_application.SceneManager.TrySetCurrentScene(region_uuid))
throw new Exception(String.Format("failed to switch to region {0}", region_uuid.ToString()));
m_log.InfoFormat("[RADMIN]: Switched to region {0}", region_uuid.ToString());
}
else if (requestData.Contains("region_name"))
{
string region_name = (string) requestData["region_name"];
if (!m_application.SceneManager.TrySetCurrentScene(region_name))
throw new Exception(String.Format("failed to switch to region {0}", region_name));
m_log.InfoFormat("[RADMIN]: Switched to region {0}", region_name); Scene scene = null;
} GetSceneFromRegionParams(requestData, responseData, out scene);
else throw new Exception("neither region_name nor region_uuid given");
Scene scene = m_application.SceneManager.CurrentScene;
scene.RegionInfo.EstateSettings.EstateAccess = new UUID[]{}; scene.RegionInfo.EstateSettings.EstateAccess = new UUID[]{};
if (scene.RegionInfo.Persistent) if (scene.RegionInfo.Persistent)
@ -1733,32 +1630,17 @@ namespace OpenSim.ApplicationPlugins.RemoteController
Hashtable responseData = (Hashtable)response.Value; Hashtable responseData = (Hashtable)response.Value;
Hashtable requestData = (Hashtable)request.Params[0]; Hashtable requestData = (Hashtable)request.Params[0];
if (requestData.Contains("region_uuid")) CheckRegionParams(requestData, responseData);
{
UUID region_uuid = (UUID) (string) requestData["region_uuid"]; Scene scene = null;
if (!m_application.SceneManager.TrySetCurrentScene(region_uuid)) GetSceneFromRegionParams(requestData, responseData, out scene);
throw new Exception(String.Format("failed to switch to region {0}", region_uuid.ToString()));
m_log.InfoFormat("[RADMIN]: Switched to region {0}", region_uuid.ToString());
}
else if (requestData.Contains("region_name"))
{
string region_name = (string) requestData["region_name"];
if (!m_application.SceneManager.TrySetCurrentScene(region_name))
throw new Exception(String.Format("failed to switch to region {0}", region_name));
m_log.InfoFormat("[RADMIN]: Switched to region {0}", region_name);
}
else
{
throw new Exception("neither region_name nor region_uuid given");
}
int addedUsers = 0; int addedUsers = 0;
if (requestData.Contains("users")) if (requestData.Contains("users"))
{ {
UUID scopeID = m_application.SceneManager.CurrentOrFirstScene.RegionInfo.ScopeID; UUID scopeID = scene.RegionInfo.ScopeID;
IUserAccountService userService = m_application.SceneManager.CurrentOrFirstScene.UserAccountService; IUserAccountService userService = scene.UserAccountService;
Scene scene = m_application.SceneManager.CurrentScene;
Hashtable users = (Hashtable) requestData["users"]; Hashtable users = (Hashtable) requestData["users"];
List<UUID> uuids = new List<UUID>(); List<UUID> uuids = new List<UUID>();
foreach (string name in users.Values) foreach (string name in users.Values)
@ -1797,32 +1679,18 @@ namespace OpenSim.ApplicationPlugins.RemoteController
Hashtable responseData = (Hashtable)response.Value; Hashtable responseData = (Hashtable)response.Value;
Hashtable requestData = (Hashtable)request.Params[0]; Hashtable requestData = (Hashtable)request.Params[0];
responseData["success"] = true; CheckRegionParams(requestData, responseData);
if (requestData.Contains("region_uuid")) Scene scene = null;
{ GetSceneFromRegionParams(requestData, responseData, out scene);
UUID region_uuid = (UUID) (string) requestData["region_uuid"];
if (!m_application.SceneManager.TrySetCurrentScene(region_uuid))
throw new Exception(String.Format("failed to switch to region {0}", region_uuid.ToString()));
m_log.InfoFormat("[RADMIN]: Switched to region {0}", region_uuid.ToString());
}
else if (requestData.Contains("region_name"))
{
string region_name = (string) requestData["region_name"];
if (!m_application.SceneManager.TrySetCurrentScene(region_name))
throw new Exception(String.Format("failed to switch to region {0}", region_name));
m_log.InfoFormat("[RADMIN]: Switched to region {0}", region_name);
}
else throw new Exception("neither region_name nor region_uuid given");
int removedUsers = 0; int removedUsers = 0;
if (requestData.Contains("users")) if (requestData.Contains("users"))
{ {
UUID scopeID = m_application.SceneManager.CurrentOrFirstScene.RegionInfo.ScopeID; UUID scopeID = scene.RegionInfo.ScopeID;
IUserAccountService userService = m_application.SceneManager.CurrentOrFirstScene.UserAccountService; IUserAccountService userService = scene.UserAccountService;
//UserProfileCacheService ups = m_application.CommunicationsManager.UserProfileCacheService; //UserProfileCacheService ups = m_application.CommunicationsManager.UserProfileCacheService;
Scene scene = m_application.SceneManager.CurrentScene;
Hashtable users = (Hashtable) requestData["users"]; Hashtable users = (Hashtable) requestData["users"];
List<UUID> uuids = new List<UUID>(); List<UUID> uuids = new List<UUID>();
foreach (string name in users.Values) foreach (string name in users.Values)
@ -1849,6 +1717,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
} }
responseData["removed"] = removedUsers; responseData["removed"] = removedUsers;
responseData["success"] = true;
m_log.Info("[RADMIN]: Access List Remove Request complete"); m_log.Info("[RADMIN]: Access List Remove Request complete");
} }
@ -1860,32 +1729,18 @@ namespace OpenSim.ApplicationPlugins.RemoteController
Hashtable responseData = (Hashtable)response.Value; Hashtable responseData = (Hashtable)response.Value;
Hashtable requestData = (Hashtable)request.Params[0]; Hashtable requestData = (Hashtable)request.Params[0];
responseData["success"] = true; CheckRegionParams(requestData, responseData);
if (requestData.Contains("region_uuid")) Scene scene = null;
{ GetSceneFromRegionParams(requestData, responseData, out scene);
UUID region_uuid = (UUID) (string) requestData["region_uuid"];
if (!m_application.SceneManager.TrySetCurrentScene(region_uuid))
throw new Exception(String.Format("failed to switch to region {0}", region_uuid.ToString()));
m_log.InfoFormat("[RADMIN]: Switched to region {0}", region_uuid.ToString());
}
else if (requestData.Contains("region_name"))
{
string region_name = (string) requestData["region_name"];
if (!m_application.SceneManager.TrySetCurrentScene(region_name))
throw new Exception(String.Format("failed to switch to region {0}", region_name));
m_log.InfoFormat("[RADMIN]: Switched to region {0}", region_name);
}
else throw new Exception("neither region_name nor region_uuid given");
Scene scene = m_application.SceneManager.CurrentScene;
UUID[] accessControlList = scene.RegionInfo.EstateSettings.EstateAccess; UUID[] accessControlList = scene.RegionInfo.EstateSettings.EstateAccess;
Hashtable users = new Hashtable(); Hashtable users = new Hashtable();
foreach (UUID user in accessControlList) foreach (UUID user in accessControlList)
{ {
UUID scopeID = m_application.SceneManager.CurrentOrFirstScene.RegionInfo.ScopeID; UUID scopeID = scene.RegionInfo.ScopeID;
UserAccount account = m_application.SceneManager.CurrentOrFirstScene.UserAccountService.GetUserAccount(scopeID, user); UserAccount account = scene.UserAccountService.GetUserAccount(scopeID, user);
if (account != null) if (account != null)
{ {
users[user.ToString()] = account.FirstName + " " + account.LastName; users[user.ToString()] = account.FirstName + " " + account.LastName;
@ -1893,6 +1748,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
} }
responseData["users"] = users; responseData["users"] = users;
responseData["success"] = true;
m_log.Info("[RADMIN]: Access List List Request complete"); m_log.Info("[RADMIN]: Access List List Request complete");
} }
@ -2010,6 +1866,126 @@ namespace OpenSim.ApplicationPlugins.RemoteController
} }
} }
private void CheckRegionParams(Hashtable requestData, Hashtable responseData)
{
//Checks if region parameters exist and gives exeption if no parameters are given
if ((requestData.ContainsKey("region_id") && !String.IsNullOrEmpty((string)requestData["region_id"])) ||
(requestData.ContainsKey("region_name") && !String.IsNullOrEmpty((string)requestData["region_name"])))
{
return;
}
#region Deprecate July 2012
//region_ID, regionid, region_uuid will be deprecated in July 2012!!!!!!
else if (requestData.ContainsKey("regionid") &&
!String.IsNullOrEmpty((string)requestData["regionid"]))
{
m_log.WarnFormat("[RADMIN]: Use of parameter regionid will be deprecated as of July 2012. Use region_id instead");
}
else if (requestData.ContainsKey("region_ID") &&
!String.IsNullOrEmpty((string)requestData["region_ID"]))
{
m_log.WarnFormat("[RADMIN]: Use of parameter region_ID will be deprecated as of July 2012. Use region_id instead");
}
else if (requestData.ContainsKey("regionID") &&
!String.IsNullOrEmpty((string)requestData["regionID"]))
{
m_log.WarnFormat("[RADMIN]: Use of parameter regionID will be deprecated as of July 2012. Use region_id instead");
}
else if (requestData.ContainsKey("region_uuid") &&
!String.IsNullOrEmpty((string)requestData["region_uuid"]))
{
m_log.WarnFormat("[RADMIN]: Use of parameter region_uuid will be deprecated as of July 2012. Use region_id instead");
}
#endregion
else
{
responseData["accepted"] = false;
throw new Exception("no region_name or region_id given");
}
}
private void GetSceneFromRegionParams(Hashtable requestData, Hashtable responseData, out Scene scene)
{
scene = null;
if (requestData.ContainsKey("region_id") &&
!String.IsNullOrEmpty((string)requestData["region_id"]))
{
UUID regionID = (UUID)(string)requestData["region_id"];
if (!m_application.SceneManager.TryGetScene(regionID, out scene))
{
responseData["error"] = String.Format("Region ID {0} not found", regionID);
throw new Exception(String.Format("Region ID {0} not found", regionID));
}
}
#region Deprecate July 2012
else if (requestData.ContainsKey("regionid") &&
!String.IsNullOrEmpty((string)requestData["regionid"]))
{
m_log.WarnFormat("[RADMIN]: Use of parameter regionid will be deprecated as of July 2012. Use region_id instead");
UUID regionID = (UUID)(string)requestData["regionid"];
if (!m_application.SceneManager.TryGetScene(regionID, out scene))
{
responseData["error"] = String.Format("Region ID {0} not found", regionID);
throw new Exception(String.Format("Region ID {0} not found", regionID));
}
}
else if (requestData.ContainsKey("region_ID") &&
!String.IsNullOrEmpty((string)requestData["region_ID"]))
{
m_log.WarnFormat("[RADMIN]: Use of parameter region_ID will be deprecated as of July 2012. Use region_id instead");
UUID regionID = (UUID)(string)requestData["region_ID"];
if (!m_application.SceneManager.TryGetScene(regionID, out scene))
{
responseData["error"] = String.Format("Region ID {0} not found", regionID);
throw new Exception(String.Format("Region ID {0} not found", regionID));
}
}
else if (requestData.ContainsKey("regionID") &&
!String.IsNullOrEmpty((string)requestData["regionID"]))
{
m_log.WarnFormat("[RADMIN]: Use of parameter regionID will be deprecated as of July 2012. Use region_id instead");
UUID regionID = (UUID)(string)requestData["regionID"];
if (!m_application.SceneManager.TryGetScene(regionID, out scene))
{
responseData["error"] = String.Format("Region ID {0} not found", regionID);
throw new Exception(String.Format("Region ID {0} not found", regionID));
}
}
else if (requestData.ContainsKey("region_uuid") &&
!String.IsNullOrEmpty((string)requestData["region_uuid"]))
{
m_log.WarnFormat("[RADMIN]: Use of parameter region_uuid will be deprecated as of July 2012. Use region_id instead");
UUID regionID = (UUID)(string)requestData["region_uuid"];
if (!m_application.SceneManager.TryGetScene(regionID, out scene))
{
responseData["error"] = String.Format("Region ID {0} not found", regionID);
throw new Exception(String.Format("Region ID {0} not found", regionID));
}
}
#endregion
else if (requestData.ContainsKey("region_name") &&
!String.IsNullOrEmpty((string)requestData["region_name"]))
{
string regionName = (string)requestData["region_name"];
if (!m_application.SceneManager.TryGetScene(regionName, out scene))
{
responseData["error"] = String.Format("Region {0} not found", regionName);
throw new Exception(String.Format("Region {0} not found", regionName));
}
}
else
{
responseData["error"] = "no region_name or region_id given";
throw new Exception("no region_name or region_id given");
}
return;
}
private bool GetBoolean(Hashtable requestData, string tag, bool defaultValue) private bool GetBoolean(Hashtable requestData, string tag, bool defaultValue)
{ {
// If an access value has been provided, apply it. // If an access value has been provided, apply it.

View File

@ -0,0 +1,148 @@
/*
* 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;
using System.Collections.Generic;
using System.Reflection;
using log4net;
using Nini.Config;
using OpenMetaverse;
using OpenMetaverse.StructuredData;
using OpenSim.Framework;
using OpenSim.Framework.Capabilities;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Services.Interfaces;
using Caps = OpenSim.Framework.Capabilities.Caps;
using OSDArray = OpenMetaverse.StructuredData.OSDArray;
using OSDMap = OpenMetaverse.StructuredData.OSDMap;
namespace OpenSim.Capabilities.Handlers
{
public class FetchInventory2Handler
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private IInventoryService m_inventoryService;
public FetchInventory2Handler(IInventoryService invService)
{
m_inventoryService = invService;
}
public string FetchInventoryRequest(string request, string path, string param, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{
// m_log.DebugFormat("[FETCH INVENTORY HANDLER]: Received FetchInventory capabilty request");
OSDMap requestmap = (OSDMap)OSDParser.DeserializeLLSDXml(Utils.StringToBytes(request));
OSDArray itemsRequested = (OSDArray)requestmap["items"];
string reply;
LLSDFetchInventory llsdReply = new LLSDFetchInventory();
foreach (OSDMap osdItemId in itemsRequested)
{
UUID itemId = osdItemId["item_id"].AsUUID();
InventoryItemBase item = m_inventoryService.GetItem(new InventoryItemBase(itemId));
if (item != null)
{
// We don't know the agent that this request belongs to so we'll use the agent id of the item
// which will be the same for all items.
llsdReply.agent_id = item.Owner;
llsdReply.items.Array.Add(ConvertInventoryItem(item));
}
}
reply = LLSDHelpers.SerialiseLLSDReply(llsdReply);
return reply;
}
/// <summary>
/// Convert an internal inventory item object into an LLSD object.
/// </summary>
/// <param name="invItem"></param>
/// <returns></returns>
private LLSDInventoryItem ConvertInventoryItem(InventoryItemBase invItem)
{
LLSDInventoryItem llsdItem = new LLSDInventoryItem();
llsdItem.asset_id = invItem.AssetID;
llsdItem.created_at = invItem.CreationDate;
llsdItem.desc = invItem.Description;
llsdItem.flags = (int)invItem.Flags;
llsdItem.item_id = invItem.ID;
llsdItem.name = invItem.Name;
llsdItem.parent_id = invItem.Folder;
try
{
llsdItem.type = Utils.AssetTypeToString((AssetType)invItem.AssetType);
llsdItem.inv_type = Utils.InventoryTypeToString((InventoryType)invItem.InvType);
}
catch (Exception e)
{
m_log.ErrorFormat(
"[WEB FETCH INV DESC HANDLER]: Problem setting asset {0} inventory {1} types while converting inventory item {2}: {3}",
invItem.AssetType, invItem.InvType, invItem.Name, e.Message);
}
llsdItem.permissions = new LLSDPermissions();
llsdItem.permissions.creator_id = invItem.CreatorIdAsUuid;
llsdItem.permissions.base_mask = (int)invItem.CurrentPermissions;
llsdItem.permissions.everyone_mask = (int)invItem.EveryOnePermissions;
llsdItem.permissions.group_id = invItem.GroupID;
llsdItem.permissions.group_mask = (int)invItem.GroupPermissions;
llsdItem.permissions.is_owner_group = invItem.GroupOwned;
llsdItem.permissions.next_owner_mask = (int)invItem.NextPermissions;
llsdItem.permissions.owner_id = invItem.Owner;
llsdItem.permissions.owner_mask = (int)invItem.CurrentPermissions;
llsdItem.sale_info = new LLSDSaleInfo();
llsdItem.sale_info.sale_price = invItem.SalePrice;
switch (invItem.SaleType)
{
default:
llsdItem.sale_info.sale_type = "not";
break;
case 1:
llsdItem.sale_info.sale_type = "original";
break;
case 2:
llsdItem.sale_info.sale_type = "copy";
break;
case 3:
llsdItem.sale_info.sale_type = "contents";
break;
}
return llsdItem;
}
}
}

View File

@ -0,0 +1,70 @@
/*
* 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 Nini.Config;
using OpenSim.Server.Base;
using OpenSim.Services.Interfaces;
using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Server.Handlers.Base;
using OpenMetaverse;
namespace OpenSim.Capabilities.Handlers
{
public class FetchInventory2ServerConnector : ServiceConnector
{
private IInventoryService m_InventoryService;
private string m_ConfigName = "CapsService";
public FetchInventory2ServerConnector(IConfigSource config, IHttpServer server, string configName)
: base(config, server, configName)
{
if (configName != String.Empty)
m_ConfigName = configName;
IConfig serverConfig = config.Configs[m_ConfigName];
if (serverConfig == null)
throw new Exception(String.Format("No section '{0}' in config file", m_ConfigName));
string invService = serverConfig.GetString("InventoryService", String.Empty);
if (invService == String.Empty)
throw new Exception("No InventoryService in config file");
Object[] args = new Object[] { config };
m_InventoryService = ServerUtils.LoadPlugin<IInventoryService>(invService, args);
if (m_InventoryService == null)
throw new Exception(String.Format("Failed to load InventoryService from {0}; config is {1}", invService, m_ConfigName));
FetchInventory2Handler fiHandler = new FetchInventory2Handler(m_InventoryService);
IRequestHandler reqHandler
= new RestStreamHandler("POST", "/CAPS/FetchInventory/", fiHandler.FetchInventoryRequest);
server.AddStreamHandler(reqHandler);
}
}
}

View File

@ -245,7 +245,7 @@ namespace OpenSim.Capabilities.Handlers
// containingFolder.Name, containingFolder.ID, agentID); // containingFolder.Name, containingFolder.ID, agentID);
version = containingFolder.Version; version = containingFolder.Version;
//
// if (fetchItems) // if (fetchItems)
// { // {
// List<InventoryItemBase> linkedItemsToAdd = new List<InventoryItemBase>(); // List<InventoryItemBase> linkedItemsToAdd = new List<InventoryItemBase>();

View File

@ -95,4 +95,11 @@ namespace OpenSim.Framework.Capabilities
public UUID owner_id; public UUID owner_id;
public int version; public int version;
} }
[OSDMap]
public class LLSDFetchInventory
{
public UUID agent_id;
public OSDArray items = new OSDArray();
}
} }

View File

@ -210,7 +210,6 @@ namespace OpenSim.Data.MySQL
} }
LoadBanList(es); LoadBanList(es);
es.EstateManagers = LoadUUIDList(es.EstateID, "estate_managers"); es.EstateManagers = LoadUUIDList(es.EstateID, "estate_managers");
es.EstateAccess = LoadUUIDList(es.EstateID, "estate_users"); es.EstateAccess = LoadUUIDList(es.EstateID, "estate_users");
es.EstateGroups = LoadUUIDList(es.EstateID, "estate_groups"); es.EstateGroups = LoadUUIDList(es.EstateID, "estate_groups");

View File

@ -846,6 +846,8 @@ namespace OpenSim.Data.MySQL
} }
} }
LoadSpawnPoints(rs);
return rs; return rs;
} }
@ -994,7 +996,9 @@ namespace OpenSim.Data.MySQL
"use_estate_sun, fixed_sun, sun_position, " + "use_estate_sun, fixed_sun, sun_position, " +
"covenant, Sandbox, sunvectorx, sunvectory, " + "covenant, Sandbox, sunvectorx, sunvectory, " +
"sunvectorz, loaded_creation_datetime, " + "sunvectorz, loaded_creation_datetime, " +
"loaded_creation_id, map_tile_ID) values (?RegionUUID, ?BlockTerraform, " + "loaded_creation_id, map_tile_ID, " +
"TelehubObject, parcel_tile_ID) " +
"values (?RegionUUID, ?BlockTerraform, " +
"?BlockFly, ?AllowDamage, ?RestrictPushing, " + "?BlockFly, ?AllowDamage, ?RestrictPushing, " +
"?AllowLandResell, ?AllowLandJoinDivide, " + "?AllowLandResell, ?AllowLandJoinDivide, " +
"?BlockShowInSearch, ?AgentLimit, ?ObjectBonus, " + "?BlockShowInSearch, ?AgentLimit, ?ObjectBonus, " +
@ -1009,7 +1013,7 @@ namespace OpenSim.Data.MySQL
"?SunPosition, ?Covenant, ?Sandbox, " + "?SunPosition, ?Covenant, ?Sandbox, " +
"?SunVectorX, ?SunVectorY, ?SunVectorZ, " + "?SunVectorX, ?SunVectorY, ?SunVectorZ, " +
"?LoadedCreationDateTime, ?LoadedCreationID, " + "?LoadedCreationDateTime, ?LoadedCreationID, " +
"?TerrainImageID)"; "?TerrainImageID, ?TelehubObject, ?ParcelImageID) ";
FillRegionSettingsCommand(cmd, rs); FillRegionSettingsCommand(cmd, rs);
@ -1017,6 +1021,7 @@ namespace OpenSim.Data.MySQL
} }
} }
} }
SaveSpawnPoints(rs);
} }
public List<LandData> LoadLandObjects(UUID regionUUID) public List<LandData> LoadLandObjects(UUID regionUUID)
@ -1296,6 +1301,8 @@ namespace OpenSim.Data.MySQL
newSettings.LoadedCreationID = (String) row["loaded_creation_id"]; newSettings.LoadedCreationID = (String) row["loaded_creation_id"];
newSettings.TerrainImageID = DBGuid.FromDB(row["map_tile_ID"]); newSettings.TerrainImageID = DBGuid.FromDB(row["map_tile_ID"]);
newSettings.ParcelImageID = DBGuid.FromDB(row["parcel_tile_ID"]);
newSettings.TelehubObject = DBGuid.FromDB(row["TelehubObject"]);
return newSettings; return newSettings;
} }
@ -1626,7 +1633,8 @@ namespace OpenSim.Data.MySQL
cmd.Parameters.AddWithValue("LoadedCreationDateTime", settings.LoadedCreationDateTime); cmd.Parameters.AddWithValue("LoadedCreationDateTime", settings.LoadedCreationDateTime);
cmd.Parameters.AddWithValue("LoadedCreationID", settings.LoadedCreationID); cmd.Parameters.AddWithValue("LoadedCreationID", settings.LoadedCreationID);
cmd.Parameters.AddWithValue("TerrainImageID", settings.TerrainImageID); cmd.Parameters.AddWithValue("TerrainImageID", settings.TerrainImageID);
cmd.Parameters.AddWithValue("ParcelImageID", settings.ParcelImageID);
cmd.Parameters.AddWithValue("TelehubObject", settings.TelehubObject);
} }
/// <summary> /// <summary>
@ -1828,5 +1836,72 @@ namespace OpenSim.Data.MySQL
} }
} }
} }
private void LoadSpawnPoints(RegionSettings rs)
{
rs.ClearSpawnPoints();
lock (m_dbLock)
{
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
{
dbcon.Open();
using (MySqlCommand cmd = dbcon.CreateCommand())
{
cmd.CommandText = "select Yaw, Pitch, Distance from spawn_points where RegionID = ?RegionID";
cmd.Parameters.AddWithValue("?RegionID", rs.RegionUUID.ToString());
using (IDataReader r = cmd.ExecuteReader())
{
while (r.Read())
{
SpawnPoint sp = new SpawnPoint();
sp.Yaw = (float)r["Yaw"];
sp.Pitch = (float)r["Pitch"];
sp.Distance = (float)r["Distance"];
rs.AddSpawnPoint(sp);
}
}
}
}
}
}
private void SaveSpawnPoints(RegionSettings rs)
{
lock (m_dbLock)
{
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
{
dbcon.Open();
using (MySqlCommand cmd = dbcon.CreateCommand())
{
cmd.CommandText = "delete from spawn_points where RegionID = ?RegionID";
cmd.Parameters.AddWithValue("?RegionID", rs.RegionUUID.ToString());
cmd.ExecuteNonQuery();
cmd.Parameters.Clear();
cmd.CommandText = "insert into spawn_points (RegionID, Yaw, Pitch, Distance) values ( ?RegionID, ?Yaw, ?Pitch, ?Distance)";
foreach (SpawnPoint p in rs.SpawnPoints())
{
cmd.Parameters.AddWithValue("?RegionID", rs.RegionUUID.ToString());
cmd.Parameters.AddWithValue("?Yaw", p.Yaw);
cmd.Parameters.AddWithValue("?Pitch", p.Pitch);
cmd.Parameters.AddWithValue("?Distance", p.Distance);
cmd.ExecuteNonQuery();
cmd.Parameters.Clear();
}
}
}
}
}
} }
} }

View File

@ -94,3 +94,12 @@ BEGIN;
alter table regions modify column regionName varchar(128) default NULL; alter table regions modify column regionName varchar(128) default NULL;
COMMIT; COMMIT;
:VERSION 9 # ------------
BEGIN;
alter table regions add column `parcelMapTexture` varchar(36) default NULL;
COMMIT;

View File

@ -842,3 +842,24 @@ alter table regionsettings ENGINE = MyISAM;
alter table terrain ENGINE = MyISAM; alter table terrain ENGINE = MyISAM;
COMMIT; COMMIT;
:VERSION 39 #--------------- Telehub support
BEGIN;
CREATE TABLE IF NOT EXISTS `spawn_points` (
`RegionID` varchar(36) COLLATE utf8_unicode_ci NOT NULL,
`Yaw` float NOT NULL,
`Pitch` float NOT NULL,
`Distance` float NOT NULL,
KEY `RegionID` (`RegionID`)
) ENGINE=Innodb;
ALTER TABLE `regionsettings` ADD COLUMN `TelehubObject` varchar(36) NOT NULL;
COMMIT;
:VERSION 40 #---------------- Parcels for sale
BEGIN;
ALTER TABLE `regionsettings` ADD COLUMN `parcel_tile_ID` char(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000';
COMMIT;

View File

@ -685,7 +685,7 @@ namespace OpenSim.Data.Tests
SceneObjectGroup sog = GetMySOG("object1"); SceneObjectGroup sog = GetMySOG("object1");
InventoryItemBase i = NewItem(item1, zero, zero, itemname1, zero); InventoryItemBase i = NewItem(item1, zero, zero, itemname1, zero);
Assert.That(sog.AddInventoryItem(null, sog.RootPart.LocalId, i, zero), Is.True); Assert.That(sog.AddInventoryItem(zero, sog.RootPart.LocalId, i, zero), Is.True);
TaskInventoryItem t = sog.GetInventoryItem(sog.RootPart.LocalId, item1); TaskInventoryItem t = sog.GetInventoryItem(sog.RootPart.LocalId, item1);
Assert.That(t.Name, Is.EqualTo(itemname1), "Assert.That(t.Name, Is.EqualTo(itemname1))"); Assert.That(t.Name, Is.EqualTo(itemname1), "Assert.That(t.Name, Is.EqualTo(itemname1))");
@ -762,7 +762,7 @@ namespace OpenSim.Data.Tests
i.CreationDate = creationd; i.CreationDate = creationd;
SceneObjectGroup sog = GetMySOG("object1"); SceneObjectGroup sog = GetMySOG("object1");
Assert.That(sog.AddInventoryItem(null, sog.RootPart.LocalId, i, zero), Is.True); Assert.That(sog.AddInventoryItem(zero, sog.RootPart.LocalId, i, zero), Is.True);
TaskInventoryItem t = sog.GetInventoryItem(sog.RootPart.LocalId, id); TaskInventoryItem t = sog.GetInventoryItem(sog.RootPart.LocalId, id);
Assert.That(t.Name, Is.EqualTo(name), "Assert.That(t.Name, Is.EqualTo(name))"); Assert.That(t.Name, Is.EqualTo(name), "Assert.That(t.Name, Is.EqualTo(name))");
@ -807,10 +807,10 @@ namespace OpenSim.Data.Tests
SceneObjectGroup sog = FindSOG("object1", region1); SceneObjectGroup sog = FindSOG("object1", region1);
Assert.That(sog.AddInventoryItem(null, sog.RootPart.LocalId, ib1, zero), Is.True); Assert.That(sog.AddInventoryItem(zero, sog.RootPart.LocalId, ib1, zero), Is.True);
Assert.That(sog.AddInventoryItem(null, sog.RootPart.LocalId, ib2, zero), Is.True); Assert.That(sog.AddInventoryItem(zero, sog.RootPart.LocalId, ib2, zero), Is.True);
Assert.That(sog.AddInventoryItem(null, sog.RootPart.LocalId, ib3, zero), Is.True); Assert.That(sog.AddInventoryItem(zero, sog.RootPart.LocalId, ib3, zero), Is.True);
Assert.That(sog.AddInventoryItem(null, sog.RootPart.LocalId, ib4, zero), Is.True); Assert.That(sog.AddInventoryItem(zero, sog.RootPart.LocalId, ib4, zero), Is.True);
TaskInventoryItem t1 = sog.GetInventoryItem(sog.RootPart.LocalId, i1); TaskInventoryItem t1 = sog.GetInventoryItem(sog.RootPart.LocalId, i1);
Assert.That(t1.Name, Is.EqualTo(ib1.Name), "Assert.That(t1.Name, Is.EqualTo(ib1.Name))"); Assert.That(t1.Name, Is.EqualTo(ib1.Name), "Assert.That(t1.Name, Is.EqualTo(ib1.Name))");

View File

@ -373,5 +373,11 @@ namespace OpenSim.Framework
return l_EstateAccess.Contains(user); return l_EstateAccess.Contains(user);
} }
public bool GroupAccess(UUID groupID)
{
return l_EstateGroups.Contains(groupID);
}
} }
} }

View File

@ -358,6 +358,8 @@ namespace OpenSim.Framework
public delegate void EstateChangeInfo(IClientAPI client, UUID invoice, UUID senderID, UInt32 param1, UInt32 param2); public delegate void EstateChangeInfo(IClientAPI client, UUID invoice, UUID senderID, UInt32 param1, UInt32 param2);
public delegate void EstateManageTelehub(IClientAPI client, UUID invoice, UUID senderID, string cmd, UInt32 param1);
public delegate void RequestTerrain(IClientAPI remoteClient, string clientFileName); public delegate void RequestTerrain(IClientAPI remoteClient, string clientFileName);
public delegate void BakeTerrain(IClientAPI remoteClient); public delegate void BakeTerrain(IClientAPI remoteClient);
@ -769,6 +771,7 @@ namespace OpenSim.Framework
event ModifyTerrain OnModifyTerrain; event ModifyTerrain OnModifyTerrain;
event BakeTerrain OnBakeTerrain; event BakeTerrain OnBakeTerrain;
event EstateChangeInfo OnEstateChangeInfo; event EstateChangeInfo OnEstateChangeInfo;
event EstateManageTelehub OnEstateManageTelehub;
// [Obsolete("LLClientView Specific.")] // [Obsolete("LLClientView Specific.")]
event SetAppearance OnSetAppearance; event SetAppearance OnSetAppearance;
// [Obsolete("LLClientView Specific - Replace and rename OnAvatarUpdate. Difference from SetAppearance?")] // [Obsolete("LLClientView Specific - Replace and rename OnAvatarUpdate. Difference from SetAppearance?")]
@ -1074,7 +1077,15 @@ namespace OpenSim.Framework
void SendWindData(Vector2[] windSpeeds); void SendWindData(Vector2[] windSpeeds);
void SendCloudData(float[] cloudCover); void SendCloudData(float[] cloudCover);
/// <summary>
/// Sent when an agent completes its movement into a region.
/// </summary>
/// <remarks>
/// This packet marks completion of the arrival of a root avatar in a region, whether through login, region
/// crossing or direct teleport.
/// </remarks>
void MoveAgentIntoRegion(RegionInfo regInfo, Vector3 pos, Vector3 look); void MoveAgentIntoRegion(RegionInfo regInfo, Vector3 pos, Vector3 look);
void InformClientOfNeighbour(ulong neighbourHandle, IPEndPoint neighbourExternalEndPoint); void InformClientOfNeighbour(ulong neighbourHandle, IPEndPoint neighbourExternalEndPoint);
/// <summary> /// <summary>
@ -1133,6 +1144,8 @@ namespace OpenSim.Framework
void SendTaskInventory(UUID taskID, short serial, byte[] fileName); void SendTaskInventory(UUID taskID, short serial, byte[] fileName);
void SendTelehubInfo(UUID ObjectID, string ObjectName, Vector3 ObjectPos, Quaternion ObjectRot, List<Vector3> SpawnPoint);
/// <summary> /// <summary>
/// Used by the server to inform the client of new inventory items and folders. /// Used by the server to inform the client of new inventory items and folders.
/// </summary> /// </summary>

View File

@ -130,5 +130,11 @@ namespace OpenSim.Framework
/// </summary> /// </summary>
/// <param name="url"></param> /// <param name="url"></param>
void SetMusicUrl(string url); void SetMusicUrl(string url);
/// <summary>
/// Get the music url for this land parcel
/// </summary>
/// <returns>The music url.</returns>
string GetMusicUrl();
} }
} }

View File

@ -36,8 +36,8 @@ namespace OpenSim.Framework
int amount); int amount);
int GetBalance(UUID agentID); int GetBalance(UUID agentID);
bool UploadCovered(IClientAPI client, int amount); bool UploadCovered(UUID agentID, int amount);
bool AmountCovered(IClientAPI client, int amount); bool AmountCovered(UUID agentID, int amount);
void ApplyCharge(UUID agentID, int amount, string text); void ApplyCharge(UUID agentID, int amount, string text);
void ApplyUploadCharge(UUID agentID, int amount, string text); void ApplyUploadCharge(UUID agentID, int amount, string text);

View File

@ -26,11 +26,53 @@
*/ */
using System; using System;
using System.Collections.Generic;
using System.IO; using System.IO;
using OpenMetaverse; using OpenMetaverse;
namespace OpenSim.Framework namespace OpenSim.Framework
{ {
public struct SpawnPoint
{
public float Yaw;
public float Pitch;
public float Distance;
public void SetLocation(Vector3 pos, Quaternion rot, Vector3 point)
{
// The point is an absolute position, so we need the relative
// location to the spawn point
Vector3 offset = point - pos;
Distance = Vector3.Mag(offset);
// Next we need to rotate this vector into the spawn point's
// coordinate system
rot.W = -rot.W;
offset = offset * rot;
Vector3 dir = Vector3.Normalize(offset);
// Get the bearing (yaw)
Yaw = (float)Math.Atan2(dir.Y, dir.X);
// Get the elevation (pitch)
Pitch = (float)-Math.Atan2(dir.Z, Math.Sqrt(dir.X * dir.X + dir.Y * dir.Y));
}
public Vector3 GetLocation(Vector3 pos, Quaternion rot)
{
Quaternion y = Quaternion.CreateFromEulers(0, 0, Yaw);
Quaternion p = Quaternion.CreateFromEulers(0, Pitch, 0);
Vector3 dir = new Vector3(1, 0, 0) * p * y;
Vector3 offset = dir * (float)Distance;
offset *= rot;
return pos + offset;
}
}
public class RegionSettings public class RegionSettings
{ {
public delegate void SaveDelegate(RegionSettings rs); public delegate void SaveDelegate(RegionSettings rs);
@ -331,6 +373,14 @@ namespace OpenSim.Framework
set { m_SunVector = value; } set { m_SunVector = value; }
} }
private UUID m_ParcelImageID;
public UUID ParcelImageID
{
get { return m_ParcelImageID; }
set { m_ParcelImageID = value; }
}
private UUID m_TerrainImageID; private UUID m_TerrainImageID;
public UUID TerrainImageID public UUID TerrainImageID
@ -397,5 +447,49 @@ namespace OpenSim.Framework
set { m_LoadedCreationID = value; } set { m_LoadedCreationID = value; }
} }
// Connected Telehub object
private UUID m_TelehubObject;
public UUID TelehubObject
{
get
{
return m_TelehubObject;
}
set
{
m_TelehubObject = value;
}
}
// Our Connected Telehub's SpawnPoints
public List<SpawnPoint> l_SpawnPoints = new List<SpawnPoint>();
// Add a SpawnPoint
// ** These are not region coordinates **
// They are relative to the Telehub coordinates
//
public void AddSpawnPoint(SpawnPoint point)
{
l_SpawnPoints.Add(point);
}
// Remove a SpawnPoint
public void RemoveSpawnPoint(int point_index)
{
l_SpawnPoints.RemoveAt(point_index);
}
// Return the List of SpawnPoints
public List<SpawnPoint> SpawnPoints()
{
return l_SpawnPoints;
}
// Clear the SpawnPoints List of all entries
public void ClearSpawnPoints()
{
l_SpawnPoints.Clear();
}
} }
} }

View File

@ -44,13 +44,13 @@ namespace OpenSim.Framework.Serialization.External
/// with creator data added to it. /// with creator data added to it.
/// </summary> /// </summary>
/// <param name="xml">The SceneObjectPart represented in XML2</param> /// <param name="xml">The SceneObjectPart represented in XML2</param>
/// <param name="profileURL">The URL of the profile service for the creator</param> /// <param name="homeURL">The URL of the user agents service (home) for the creator</param>
/// <param name="userService">The service for retrieving user account information</param> /// <param name="userService">The service for retrieving user account information</param>
/// <param name="scopeID">The scope of the user account information (Grid ID)</param> /// <param name="scopeID">The scope of the user account information (Grid ID)</param>
/// <returns>The SceneObjectPart represented in XML2</returns> /// <returns>The SceneObjectPart represented in XML2</returns>
public static string RewriteSOP(string xml, string profileURL, IUserAccountService userService, UUID scopeID) public static string RewriteSOP(string xml, string homeURL, IUserAccountService userService, UUID scopeID)
{ {
if (xml == string.Empty || profileURL == string.Empty || userService == null) if (xml == string.Empty || homeURL == string.Empty || userService == null)
return xml; return xml;
XmlDocument doc = new XmlDocument(); XmlDocument doc = new XmlDocument();
@ -83,7 +83,7 @@ namespace OpenSim.Framework.Serialization.External
if (!hasCreatorData && creator != null) if (!hasCreatorData && creator != null)
{ {
XmlElement creatorData = doc.CreateElement("CreatorData"); XmlElement creatorData = doc.CreateElement("CreatorData");
creatorData.InnerText = profileURL + "/" + creator.PrincipalID + ";" + creator.FirstName + " " + creator.LastName; creatorData.InnerText = homeURL + ";" + creator.FirstName + " " + creator.LastName;
sop.AppendChild(creatorData); sop.AppendChild(creatorData);
} }
} }

View File

@ -251,7 +251,7 @@ namespace OpenSim.Framework.Servers
sb.Append(threads.Length + " threads are being tracked:" + Environment.NewLine); sb.Append(threads.Length + " threads are being tracked:" + Environment.NewLine);
int timeNow = Util.EnvironmentTickCount(); int timeNow = Environment.TickCount & Int32.MaxValue;
sb.AppendFormat(reportFormat, "ID", "NAME", "LAST UPDATE (MS)", "LIFETIME (MS)", "PRIORITY", "STATE"); sb.AppendFormat(reportFormat, "ID", "NAME", "LAST UPDATE (MS)", "LIFETIME (MS)", "PRIORITY", "STATE");
sb.Append(Environment.NewLine); sb.Append(Environment.NewLine);

View File

@ -42,15 +42,15 @@ namespace OpenSim.Framework.Statistics
{ {
private long abnormalClientThreadTerminations; private long abnormalClientThreadTerminations;
private long assetsInCache; // private long assetsInCache;
private long texturesInCache; // private long texturesInCache;
private long assetCacheMemoryUsage; // private long assetCacheMemoryUsage;
private long textureCacheMemoryUsage; // private long textureCacheMemoryUsage;
private TimeSpan assetRequestTimeAfterCacheMiss; // private TimeSpan assetRequestTimeAfterCacheMiss;
private long blockedMissingTextureRequests; // private long blockedMissingTextureRequests;
private long assetServiceRequestFailures; // private long assetServiceRequestFailures;
private long inventoryServiceRetrievalFailures; // private long inventoryServiceRetrievalFailures;
private volatile float timeDilation; private volatile float timeDilation;
private volatile float simFps; private volatile float simFps;
@ -79,27 +79,27 @@ namespace OpenSim.Framework.Statistics
/// </summary> /// </summary>
public long AbnormalClientThreadTerminations { get { return abnormalClientThreadTerminations; } } public long AbnormalClientThreadTerminations { get { return abnormalClientThreadTerminations; } }
/// <summary> // /// <summary>
/// These statistics are being collected by push rather than pull. Pull would be simpler, but I had the // /// These statistics are being collected by push rather than pull. Pull would be simpler, but I had the
/// notion of providing some flow statistics (which pull wouldn't give us). Though admittedly these // /// notion of providing some flow statistics (which pull wouldn't give us). Though admittedly these
/// haven't yet been implemented... // /// haven't yet been implemented...
/// </summary> // /// </summary>
public long AssetsInCache { get { return assetsInCache; } } // public long AssetsInCache { get { return assetsInCache; } }
//
/// <value> // /// <value>
/// Currently unused // /// Currently unused
/// </value> // /// </value>
public long TexturesInCache { get { return texturesInCache; } } // public long TexturesInCache { get { return texturesInCache; } }
//
/// <value> // /// <value>
/// Currently misleading since we can't currently subtract removed asset memory usage without a performance hit // /// Currently misleading since we can't currently subtract removed asset memory usage without a performance hit
/// </value> // /// </value>
public long AssetCacheMemoryUsage { get { return assetCacheMemoryUsage; } } // public long AssetCacheMemoryUsage { get { return assetCacheMemoryUsage; } }
//
/// <value> // /// <value>
/// Currently unused // /// Currently unused
/// </value> // /// </value>
public long TextureCacheMemoryUsage { get { return textureCacheMemoryUsage; } } // public long TextureCacheMemoryUsage { get { return textureCacheMemoryUsage; } }
public float TimeDilation { get { return timeDilation; } } public float TimeDilation { get { return timeDilation; } }
public float SimFps { get { return simFps; } } public float SimFps { get { return simFps; } }
@ -123,32 +123,33 @@ namespace OpenSim.Framework.Statistics
public float ActiveScripts { get { return activeScripts; } } public float ActiveScripts { get { return activeScripts; } }
public float ScriptLinesPerSecond { get { return scriptLinesPerSecond; } } public float ScriptLinesPerSecond { get { return scriptLinesPerSecond; } }
/// <summary> // /// <summary>
/// This is the time it took for the last asset request made in response to a cache miss. // /// This is the time it took for the last asset request made in response to a cache miss.
/// </summary> // /// </summary>
public TimeSpan AssetRequestTimeAfterCacheMiss { get { return assetRequestTimeAfterCacheMiss; } } // public TimeSpan AssetRequestTimeAfterCacheMiss { get { return assetRequestTimeAfterCacheMiss; } }
//
/// <summary> // /// <summary>
/// Number of persistent requests for missing textures we have started blocking from clients. To some extent // /// Number of persistent requests for missing textures we have started blocking from clients. To some extent
/// this is just a temporary statistic to keep this problem in view - the root cause of this lies either // /// this is just a temporary statistic to keep this problem in view - the root cause of this lies either
/// in a mishandling of the reply protocol, related to avatar appearance or may even originate in graphics // /// in a mishandling of the reply protocol, related to avatar appearance or may even originate in graphics
/// driver bugs on clients (though this seems less likely). // /// driver bugs on clients (though this seems less likely).
/// </summary> // /// </summary>
public long BlockedMissingTextureRequests { get { return blockedMissingTextureRequests; } } // public long BlockedMissingTextureRequests { get { return blockedMissingTextureRequests; } }
//
/// <summary> // /// <summary>
/// Record the number of times that an asset request has failed. Failures are effectively exceptions, such as // /// Record the number of times that an asset request has failed. Failures are effectively exceptions, such as
/// request timeouts. If an asset service replies that a particular asset cannot be found, this is not counted // /// request timeouts. If an asset service replies that a particular asset cannot be found, this is not counted
/// as a failure // /// as a failure
/// </summary> // /// </summary>
public long AssetServiceRequestFailures { get { return assetServiceRequestFailures; } } // public long AssetServiceRequestFailures { get { return assetServiceRequestFailures; } }
/// <summary> /// <summary>
/// Number of known failures to retrieve avatar inventory from the inventory service. This does not /// Number of known failures to retrieve avatar inventory from the inventory service. This does not
/// cover situations where the inventory service accepts the request but never returns any data, since /// cover situations where the inventory service accepts the request but never returns any data, since
/// we do not yet timeout this situation. /// we do not yet timeout this situation.
/// </summary> /// </summary>
public long InventoryServiceRetrievalFailures { get { return inventoryServiceRetrievalFailures; } } /// <remarks>Commented out because we do not cache inventory at this point</remarks>
// public long InventoryServiceRetrievalFailures { get { return inventoryServiceRetrievalFailures; } }
/// <summary> /// <summary>
/// Retrieve the total frame time (in ms) of the last frame /// Retrieve the total frame time (in ms) of the last frame
@ -171,58 +172,58 @@ namespace OpenSim.Framework.Statistics
abnormalClientThreadTerminations++; abnormalClientThreadTerminations++;
} }
public void AddAsset(AssetBase asset) // public void AddAsset(AssetBase asset)
{ // {
assetsInCache++; // assetsInCache++;
//assetCacheMemoryUsage += asset.Data.Length; // //assetCacheMemoryUsage += asset.Data.Length;
} // }
//
// public void RemoveAsset(UUID uuid)
// {
// assetsInCache--;
// }
//
// public void AddTexture(AssetBase image)
// {
// if (image.Data != null)
// {
// texturesInCache++;
//
// // This could have been a pull stat, though there was originally a nebulous idea to measure flow rates
// textureCacheMemoryUsage += image.Data.Length;
// }
// }
//
// /// <summary>
// /// Signal that the asset cache has been cleared.
// /// </summary>
// public void ClearAssetCacheStatistics()
// {
// assetsInCache = 0;
// assetCacheMemoryUsage = 0;
// texturesInCache = 0;
// textureCacheMemoryUsage = 0;
// }
//
// public void AddAssetRequestTimeAfterCacheMiss(TimeSpan ts)
// {
// assetRequestTimeAfterCacheMiss = ts;
// }
//
// public void AddBlockedMissingTextureRequest()
// {
// blockedMissingTextureRequests++;
// }
//
// public void AddAssetServiceRequestFailure()
// {
// assetServiceRequestFailures++;
// }
public void RemoveAsset(UUID uuid) // public void AddInventoryServiceRetrievalFailure()
{ // {
assetsInCache--; // inventoryServiceRetrievalFailures++;
} // }
public void AddTexture(AssetBase image)
{
if (image.Data != null)
{
texturesInCache++;
// This could have been a pull stat, though there was originally a nebulous idea to measure flow rates
textureCacheMemoryUsage += image.Data.Length;
}
}
/// <summary>
/// Signal that the asset cache has been cleared.
/// </summary>
public void ClearAssetCacheStatistics()
{
assetsInCache = 0;
assetCacheMemoryUsage = 0;
texturesInCache = 0;
textureCacheMemoryUsage = 0;
}
public void AddAssetRequestTimeAfterCacheMiss(TimeSpan ts)
{
assetRequestTimeAfterCacheMiss = ts;
}
public void AddBlockedMissingTextureRequest()
{
blockedMissingTextureRequests++;
}
public void AddAssetServiceRequestFailure()
{
assetServiceRequestFailures++;
}
public void AddInventoryServiceRetrievalFailure()
{
inventoryServiceRetrievalFailures++;
}
/// <summary> /// <summary>
/// Register as a packet queue stats provider /// Register as a packet queue stats provider
@ -290,8 +291,8 @@ namespace OpenSim.Framework.Statistics
public override string Report() public override string Report()
{ {
StringBuilder sb = new StringBuilder(Environment.NewLine); StringBuilder sb = new StringBuilder(Environment.NewLine);
sb.Append("ASSET STATISTICS"); // sb.Append("ASSET STATISTICS");
sb.Append(Environment.NewLine); // sb.Append(Environment.NewLine);
/* /*
sb.Append( sb.Append(
@ -308,6 +309,7 @@ Asset service request failures: {6}"+ Environment.NewLine,
AssetServiceRequestFailures)); AssetServiceRequestFailures));
*/ */
/*
sb.Append( sb.Append(
string.Format( string.Format(
@"Asset cache contains {0,6} assets @"Asset cache contains {0,6} assets
@ -318,7 +320,7 @@ Asset service request failures: {3}" + Environment.NewLine,
assetRequestTimeAfterCacheMiss.Milliseconds / 1000.0, assetRequestTimeAfterCacheMiss.Milliseconds / 1000.0,
BlockedMissingTextureRequests, BlockedMissingTextureRequests,
AssetServiceRequestFailures)); AssetServiceRequestFailures));
*/
sb.Append(Environment.NewLine); sb.Append(Environment.NewLine);
sb.Append("CONNECTION STATISTICS"); sb.Append("CONNECTION STATISTICS");
@ -328,13 +330,13 @@ Asset service request failures: {3}" + Environment.NewLine,
"Abnormal client thread terminations: {0}" + Environment.NewLine, "Abnormal client thread terminations: {0}" + Environment.NewLine,
abnormalClientThreadTerminations)); abnormalClientThreadTerminations));
sb.Append(Environment.NewLine); // sb.Append(Environment.NewLine);
sb.Append("INVENTORY STATISTICS"); // sb.Append("INVENTORY STATISTICS");
sb.Append(Environment.NewLine); // sb.Append(Environment.NewLine);
sb.Append( // sb.Append(
string.Format( // string.Format(
"Initial inventory caching failures: {0}" + Environment.NewLine, // "Initial inventory caching failures: {0}" + Environment.NewLine,
InventoryServiceRetrievalFailures)); // InventoryServiceRetrievalFailures));
sb.Append(Environment.NewLine); sb.Append(Environment.NewLine);
sb.Append("FRAME STATISTICS"); sb.Append("FRAME STATISTICS");
@ -390,17 +392,17 @@ Asset service request failures: {3}" + Environment.NewLine,
public override string XReport(string uptime, string version) public override string XReport(string uptime, string version)
{ {
OSDMap args = new OSDMap(30); OSDMap args = new OSDMap(30);
args["AssetsInCache"] = OSD.FromString (String.Format ("{0:0.##}", AssetsInCache)); // args["AssetsInCache"] = OSD.FromString (String.Format ("{0:0.##}", AssetsInCache));
args["TimeAfterCacheMiss"] = OSD.FromString (String.Format ("{0:0.##}", // args["TimeAfterCacheMiss"] = OSD.FromString (String.Format ("{0:0.##}",
assetRequestTimeAfterCacheMiss.Milliseconds / 1000.0)); // assetRequestTimeAfterCacheMiss.Milliseconds / 1000.0));
args["BlockedMissingTextureRequests"] = OSD.FromString (String.Format ("{0:0.##}", // args["BlockedMissingTextureRequests"] = OSD.FromString (String.Format ("{0:0.##}",
BlockedMissingTextureRequests)); // BlockedMissingTextureRequests));
args["AssetServiceRequestFailures"] = OSD.FromString (String.Format ("{0:0.##}", // args["AssetServiceRequestFailures"] = OSD.FromString (String.Format ("{0:0.##}",
AssetServiceRequestFailures)); // AssetServiceRequestFailures));
args["abnormalClientThreadTerminations"] = OSD.FromString (String.Format ("{0:0.##}", // args["abnormalClientThreadTerminations"] = OSD.FromString (String.Format ("{0:0.##}",
abnormalClientThreadTerminations)); // abnormalClientThreadTerminations));
args["InventoryServiceRetrievalFailures"] = OSD.FromString (String.Format ("{0:0.##}", // args["InventoryServiceRetrievalFailures"] = OSD.FromString (String.Format ("{0:0.##}",
InventoryServiceRetrievalFailures)); // InventoryServiceRetrievalFailures));
args["Dilatn"] = OSD.FromString (String.Format ("{0:0.##}", timeDilation)); args["Dilatn"] = OSD.FromString (String.Format ("{0:0.##}", timeDilation));
args["SimFPS"] = OSD.FromString (String.Format ("{0:0.##}", simFps)); args["SimFPS"] = OSD.FromString (String.Format ("{0:0.##}", simFps));
args["PhyFPS"] = OSD.FromString (String.Format ("{0:0.##}", physicsFps)); args["PhyFPS"] = OSD.FromString (String.Format ("{0:0.##}", physicsFps));

View File

@ -107,15 +107,13 @@ namespace OpenSim
} }
else else
{ {
m_log.ErrorFormat("Master ini file {0} not found", masterFilePath); m_log.ErrorFormat("Master ini file {0} not found", Path.GetFullPath(masterFilePath));
Environment.Exit(1); Environment.Exit(1);
} }
} }
} }
string iniFileName = startupConfig.GetString("inifile", "OpenSim.ini");
string iniFileName =
startupConfig.GetString("inifile", "OpenSim.ini");
if (IsUri(iniFileName)) if (IsUri(iniFileName))
{ {
@ -131,8 +129,7 @@ namespace OpenSim
if (!File.Exists(Application.iniFilePath)) if (!File.Exists(Application.iniFilePath))
{ {
iniFileName = "OpenSim.xml"; iniFileName = "OpenSim.xml";
Application.iniFilePath = Path.GetFullPath( Application.iniFilePath = Path.GetFullPath(Path.Combine(Util.configDir(), iniFileName));
Path.Combine(Util.configDir(), iniFileName));
} }
if (File.Exists(Application.iniFilePath)) if (File.Exists(Application.iniFilePath))
@ -142,15 +139,12 @@ namespace OpenSim
} }
} }
string iniDirName = string iniDirName = startupConfig.GetString("inidirectory", "config");
startupConfig.GetString("inidirectory", "config"); string iniDirPath = Path.Combine(Util.configDir(), iniDirName);
string iniDirPath =
Path.Combine(Util.configDir(), iniDirName);
if (Directory.Exists(iniDirPath)) if (Directory.Exists(iniDirPath))
{ {
m_log.InfoFormat("Searching folder {0} for config ini files", m_log.InfoFormat("Searching folder {0} for config ini files", iniDirPath);
iniDirPath);
string[] fileEntries = Directory.GetFiles(iniDirName); string[] fileEntries = Directory.GetFiles(iniDirName);
foreach (string filePath in fileEntries) foreach (string filePath in fileEntries)
@ -172,7 +166,6 @@ namespace OpenSim
if (sources.Count == 0) if (sources.Count == 0)
{ {
m_log.FatalFormat("[CONFIG]: Could not load any configuration"); m_log.FatalFormat("[CONFIG]: Could not load any configuration");
m_log.FatalFormat("[CONFIG]: Did you copy the OpenSimDefaults.ini.example file to OpenSimDefaults.ini?");
Environment.Exit(1); Environment.Exit(1);
} }

View File

@ -250,8 +250,10 @@ namespace OpenSim
+ "If level <= 0 then no extra http logging is done.\n", + "If level <= 0 then no extra http logging is done.\n",
Debug); Debug);
m_console.Commands.AddCommand("region", false, "debug teleport", "debug teleport", "Toggle teleport route debugging", Debug);
m_console.Commands.AddCommand("region", false, "debug scene", m_console.Commands.AddCommand("region", false, "debug scene",
"debug scene <cripting> <collisions> <physics>", "debug scene <scripting> <collisions> <physics>",
"Turn on scene debugging", Debug); "Turn on scene debugging", Debug);
m_console.Commands.AddCommand("region", false, "change region", m_console.Commands.AddCommand("region", false, "change region",
@ -289,12 +291,16 @@ namespace OpenSim
m_console.Commands.AddCommand("region", false, "save oar", m_console.Commands.AddCommand("region", false, "save oar",
//"save oar [-v|--version=<N>] [-p|--profile=<url>] [<OAR path>]", //"save oar [-v|--version=<N>] [-p|--profile=<url>] [<OAR path>]",
"save oar [-p|--profile=<url>] [--noassets] [--perm=<permissions>] [<OAR path>]", "save oar [-h|--home=<url>] [--noassets] [--publish] [--perm=<permissions>] [<OAR path>]",
"Save a region's data to an OAR archive.", "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 // "-v|--version=<N> generates scene objects as per older versions of the serialization (e.g. -v=0)" + Environment.NewLine
"-p|--profile=<url> adds the url of the profile service to the saved user information." + 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 + "--noassets stops assets being saved to the OAR." + Environment.NewLine
+ "--perm stops objects with insufficient permissions from 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 + " <permissions> can contain one or more of these characters: \"C\" = Copy, \"T\" = Transfer" + Environment.NewLine
+ "The OAR path must be a filesystem path." + "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.", + " If this is not given then the oar is saved to region.oar in the current directory.",
@ -948,6 +954,21 @@ namespace OpenSim
break; break;
case "teleport":
foreach(Scene s in m_sceneManager.Scenes)
{
if (s.DEBUG)
{
s.DEBUG = false;
MainConsole.Instance.Output("Teleport debugging is disabled!");
}
else{
s.DEBUG = true;
MainConsole.Instance.Output("Teleport debugging is enabled!");
}
}
break;
default: default:
MainConsole.Instance.Output("Unknown debug command"); MainConsole.Instance.Output("Unknown debug command");
break; break;

View File

@ -202,16 +202,16 @@ namespace OpenSim
// Load the simulation data service // Load the simulation data service
IConfig simDataConfig = m_config.Source.Configs["SimulationDataStore"]; IConfig simDataConfig = m_config.Source.Configs["SimulationDataStore"];
if (simDataConfig == null) if (simDataConfig == null)
throw new Exception("Configuration file is missing the [SimulationDataStore] section"); throw new Exception("Configuration file is missing the [SimulationDataStore] section. Have you copied OpenSim.ini.example to OpenSim.ini to reference config-include/ files?");
string module = simDataConfig.GetString("LocalServiceModule", String.Empty); string module = simDataConfig.GetString("LocalServiceModule", String.Empty);
if (String.IsNullOrEmpty(module)) if (String.IsNullOrEmpty(module))
throw new Exception("Configuration file is missing the LocalServiceModule parameter in the [SimulationDataStore] section"); throw new Exception("Configuration file is missing the LocalServiceModule parameter in the [SimulationDataStore] section.");
m_simulationDataService = ServerUtils.LoadPlugin<ISimulationDataService>(module, new object[] { m_config.Source }); m_simulationDataService = ServerUtils.LoadPlugin<ISimulationDataService>(module, new object[] { m_config.Source });
// Load the estate data service // Load the estate data service
IConfig estateDataConfig = m_config.Source.Configs["EstateDataStore"]; IConfig estateDataConfig = m_config.Source.Configs["EstateDataStore"];
if (estateDataConfig == null) if (estateDataConfig == null)
throw new Exception("Configuration file is missing the [EstateDataStore] section"); throw new Exception("Configuration file is missing the [EstateDataStore] section. Have you copied OpenSim.ini.example to OpenSim.ini to reference config-include/ files?");
module = estateDataConfig.GetString("LocalServiceModule", String.Empty); module = estateDataConfig.GetString("LocalServiceModule", String.Empty);
if (String.IsNullOrEmpty(module)) if (String.IsNullOrEmpty(module))
throw new Exception("Configuration file is missing the LocalServiceModule parameter in the [EstateDataStore] section"); throw new Exception("Configuration file is missing the LocalServiceModule parameter in the [EstateDataStore] section");
@ -383,6 +383,9 @@ namespace OpenSim
// TODO : Try setting resource for region xstats here on scene // TODO : Try setting resource for region xstats here on scene
MainServer.Instance.AddStreamHandler(new Region.Framework.Scenes.RegionStatsHandler(regionInfo)); MainServer.Instance.AddStreamHandler(new Region.Framework.Scenes.RegionStatsHandler(regionInfo));
scene.loadAllLandObjectsFromStorage(regionInfo.originRegionID);
scene.EventManager.TriggerParcelPrimCountUpdate();
try try
{ {
scene.RegisterRegionWithGrid(); scene.RegisterRegionWithGrid();
@ -398,9 +401,6 @@ namespace OpenSim
Environment.Exit(1); Environment.Exit(1);
} }
scene.loadAllLandObjectsFromStorage(regionInfo.originRegionID);
scene.EventManager.TriggerParcelPrimCountUpdate();
// We need to do this after we've initialized the // We need to do this after we've initialized the
// scripting engines. // scripting engines.
scene.CreateScriptInstances(); scene.CreateScriptInstances();

View File

@ -94,6 +94,7 @@ namespace OpenSim.Region.ClientStack.Linden
private static readonly string m_notecardUpdatePath = "0004/"; private static readonly string m_notecardUpdatePath = "0004/";
private static readonly string m_notecardTaskUpdatePath = "0005/"; private static readonly string m_notecardTaskUpdatePath = "0005/";
// private static readonly string m_fetchInventoryPath = "0006/"; // private static readonly string m_fetchInventoryPath = "0006/";
private static readonly string m_copyFromNotecardPath = "0007/";
// private static readonly string m_remoteParcelRequestPath = "0009/";// This is in the LandManagementModule. // private static readonly string m_remoteParcelRequestPath = "0009/";// This is in the LandManagementModule.
@ -180,6 +181,7 @@ namespace OpenSim.Region.ClientStack.Linden
m_HostCapsObj.RegisterHandler("UpdateNotecardAgentInventory", req); m_HostCapsObj.RegisterHandler("UpdateNotecardAgentInventory", req);
m_HostCapsObj.RegisterHandler("UpdateScriptAgentInventory", req); m_HostCapsObj.RegisterHandler("UpdateScriptAgentInventory", req);
m_HostCapsObj.RegisterHandler("UpdateScriptAgent", req); m_HostCapsObj.RegisterHandler("UpdateScriptAgent", req);
m_HostCapsObj.RegisterHandler("CopyInventoryFromNotecard", new RestStreamHandler("POST", capsBase + m_copyFromNotecardPath, CopyInventoryFromNotecard));
// As of RC 1.22.9 of the Linden client this is // As of RC 1.22.9 of the Linden client this is
// supported // supported
@ -366,7 +368,7 @@ namespace OpenSim.Region.ClientStack.Linden
if (mm != null) if (mm != null)
{ {
if (!mm.UploadCovered(client, mm.UploadCharge)) if (!mm.UploadCovered(client.AgentId, mm.UploadCharge))
{ {
if (client != null) if (client != null)
client.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false); client.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false);
@ -723,6 +725,75 @@ namespace OpenSim.Region.ClientStack.Linden
return LLSDHelpers.SerialiseLLSDReply(uploadResponse); return LLSDHelpers.SerialiseLLSDReply(uploadResponse);
} }
/// <summary>
/// Called by the CopyInventoryFromNotecard caps handler.
/// </summary>
/// <param name="request"></param>
/// <param name="path"></param>
/// <param name="param"></param>
public string CopyInventoryFromNotecard(string request, string path, string param,
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{
Hashtable response = new Hashtable();
response["int_response_code"] = 404;
response["content_type"] = "text/plain";
response["keepalive"] = false;
response["str_response_string"] = "";
try
{
OSDMap content = (OSDMap)OSDParser.DeserializeLLSDXml(request);
UUID objectID = content["object-id"].AsUUID();
UUID notecardID = content["notecard-id"].AsUUID();
UUID folderID = content["folder-id"].AsUUID();
UUID itemID = content["item-id"].AsUUID();
// m_log.InfoFormat("[CAPS]: CopyInventoryFromNotecard, FolderID:{0}, ItemID:{1}, NotecardID:{2}, ObjectID:{3}", folderID, itemID, notecardID, objectID);
if (objectID != UUID.Zero)
{
SceneObjectPart part = m_Scene.GetSceneObjectPart(objectID);
if (part != null)
{
TaskInventoryItem taskItem = part.Inventory.GetInventoryItem(notecardID);
if (!m_Scene.Permissions.CanCopyObjectInventory(notecardID, objectID, m_HostCapsObj.AgentID))
{
return LLSDHelpers.SerialiseLLSDReply(response);
}
}
}
InventoryItemBase item = null;
InventoryItemBase copyItem = null;
IClientAPI client = null;
m_Scene.TryGetClient(m_HostCapsObj.AgentID, out client);
item = m_Scene.InventoryService.GetItem(new InventoryItemBase(itemID));
if (item != null)
{
copyItem = m_Scene.GiveInventoryItem(m_HostCapsObj.AgentID, item.Owner, itemID, folderID);
if (copyItem != null && client != null)
{
m_log.InfoFormat("[CAPS]: CopyInventoryFromNotecard, ItemID:{0}, FolderID:{1}", copyItem.ID, copyItem.Folder);
client.SendBulkUpdateInventory(copyItem);
}
}
else
{
m_log.ErrorFormat("[CAPS]: CopyInventoryFromNotecard - Failed to retrieve item {0} from notecard {1}", itemID, notecardID);
if (client != null)
client.SendAlertMessage("Failed to retrieve item");
}
}
catch (Exception e)
{
m_log.ErrorFormat("[CAPS]: CopyInventoryFromNotecard : {0}", e.ToString());
}
response["int_response_code"] = 200;
return LLSDHelpers.SerialiseLLSDReply(response);
}
} }
public class AssetUploader public class AssetUploader

View File

@ -0,0 +1,151 @@
/*
* 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;
using System.Reflection;
using log4net;
using Nini.Config;
using Mono.Addins;
using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Services.Interfaces;
using Caps = OpenSim.Framework.Capabilities.Caps;
using OpenSim.Capabilities.Handlers;
namespace OpenSim.Region.ClientStack.Linden
{
/// <summary>
/// This module implements both WebFetchInventoryDescendents and FetchInventoryDescendents2 capabilities.
/// </summary>
[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
public class FetchInventory2Module : INonSharedRegionModule
{
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public bool Enabled { get; private set; }
private Scene m_scene;
private IInventoryService m_inventoryService;
private string m_fetchInventory2Url;
private FetchInventory2Handler m_fetchHandler;
#region ISharedRegionModule Members
public void Initialise(IConfigSource source)
{
IConfig config = source.Configs["ClientStack.LindenCaps"];
if (config == null)
return;
m_fetchInventory2Url = config.GetString("Cap_FetchInventory2", string.Empty);
if (m_fetchInventory2Url != string.Empty)
Enabled = true;
}
public void AddRegion(Scene s)
{
if (!Enabled)
return;
m_scene = s;
}
public void RemoveRegion(Scene s)
{
if (!Enabled)
return;
m_scene.EventManager.OnRegisterCaps -= RegisterCaps;
m_scene = null;
}
public void RegionLoaded(Scene s)
{
if (!Enabled)
return;
m_inventoryService = m_scene.InventoryService;
// We'll reuse the same handler for all requests.
if (m_fetchInventory2Url == "localhost")
m_fetchHandler = new FetchInventory2Handler(m_inventoryService);
m_scene.EventManager.OnRegisterCaps += RegisterCaps;
}
public void PostInitialise() {}
public void Close() {}
public string Name { get { return "FetchInventory2Module"; } }
public Type ReplaceableInterface
{
get { return null; }
}
#endregion
private void RegisterCaps(UUID agentID, Caps caps)
{
RegisterFetchCap(agentID, caps, "FetchInventory2", m_fetchInventory2Url);
}
private void RegisterFetchCap(UUID agentID, Caps caps, string capName, string url)
{
string capUrl;
if (url == "localhost")
{
capUrl = "/CAPS/" + UUID.Random();
IRequestHandler reqHandler
= new RestStreamHandler("POST", capUrl, m_fetchHandler.FetchInventoryRequest);
caps.RegisterHandler(capName, reqHandler);
}
else
{
capUrl = url;
caps.RegisterHandler(capName, capUrl);
}
// m_log.DebugFormat(
// "[FETCH INVENTORY2 MODULE]: Registered capability {0} at {1} in region {2} for {3}",
// capName, capUrl, m_scene.RegionInfo.RegionName, agentID);
}
}
}

View File

@ -147,7 +147,7 @@ namespace OpenSim.Region.ClientStack.Linden
{ {
if (m_scene.TryGetClient(agentID, out client)) if (m_scene.TryGetClient(agentID, out client))
{ {
if (!mm.UploadCovered(client, mm.UploadCharge)) if (!mm.UploadCovered(client.AgentId, mm.UploadCharge))
{ {
if (client != null) if (client != null)
client.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false); client.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false);

View File

@ -45,6 +45,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP
private const int IMAGE_PACKET_SIZE = 1000; private const int IMAGE_PACKET_SIZE = 1000;
private const int FIRST_PACKET_SIZE = 600; private const int FIRST_PACKET_SIZE = 600;
/// <summary>
/// If we've requested an asset but not received it in this ticks timeframe, then allow a duplicate
/// request from the client to trigger a fresh asset request.
/// </summary>
/// <remarks>
/// There are 10,000 ticks in a millisecond
/// </remarks>
private const int ASSET_REQUEST_TIMEOUT = 100000000;
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public uint LastSequence; public uint LastSequence;
@ -57,8 +66,22 @@ namespace OpenSim.Region.ClientStack.LindenUDP
public UUID AgentID; public UUID AgentID;
public IInventoryAccessModule InventoryAccessModule; public IInventoryAccessModule InventoryAccessModule;
private OpenJPEG.J2KLayerInfo[] m_layers; private OpenJPEG.J2KLayerInfo[] m_layers;
/// <summary>
/// Has this request decoded the asset data?
/// </summary>
public bool IsDecoded { get; private set; } public bool IsDecoded { get; private set; }
/// <summary>
/// Has this request received the required asset data?
/// </summary>
public bool HasAsset { get; private set; } public bool HasAsset { get; private set; }
/// <summary>
/// Time in milliseconds at which the asset was requested.
/// </summary>
public long AssetRequestTime { get; private set; }
public C5.IPriorityQueueHandle<J2KImage> PriorityQueueHandle; public C5.IPriorityQueueHandle<J2KImage> PriorityQueueHandle;
private uint m_currentPacket; private uint m_currentPacket;
@ -82,7 +105,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
/// <param name="packetsToSend">Maximum number of packets to send during this call</param> /// <param name="packetsToSend">Maximum number of packets to send during this call</param>
/// <param name="packetsSent">Number of packets sent during this call</param> /// <param name="packetsSent">Number of packets sent during this call</param>
/// <returns>True if the transfer completes at the current discard level, otherwise false</returns> /// <returns>True if the transfer completes at the current discard level, otherwise false</returns>
public bool SendPackets(LLClientView client, int packetsToSend, out int packetsSent) public bool SendPackets(IClientAPI client, int packetsToSend, out int packetsSent)
{ {
packetsSent = 0; packetsSent = 0;
@ -114,17 +137,24 @@ namespace OpenSim.Region.ClientStack.LindenUDP
return (m_currentPacket > m_stopPacket); return (m_currentPacket > m_stopPacket);
} }
/// <summary>
/// This is where we decide what we need to update
/// and assign the real discardLevel and packetNumber
/// assuming of course that the connected client might be bonkers
/// </summary>
public void RunUpdate() public void RunUpdate()
{ {
//This is where we decide what we need to update
//and assign the real discardLevel and packetNumber
//assuming of course that the connected client might be bonkers
if (!HasAsset) if (!HasAsset)
{ {
if (!m_assetRequested) if (!m_assetRequested || DateTime.UtcNow.Ticks > AssetRequestTime + ASSET_REQUEST_TIMEOUT)
{ {
// m_log.DebugFormat(
// "[J2KIMAGE]: Requesting asset {0} from request in packet {1}, already requested? {2}, due to timeout? {3}",
// TextureID, LastSequence, m_assetRequested, DateTime.UtcNow.Ticks > AssetRequestTime + ASSET_REQUEST_TIMEOUT);
m_assetRequested = true; m_assetRequested = true;
AssetRequestTime = DateTime.UtcNow.Ticks;
AssetService.Get(TextureID.ToString(), this, AssetReceived); AssetService.Get(TextureID.ToString(), this, AssetReceived);
} }
} }
@ -137,6 +167,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
{ {
//Request decode //Request decode
m_decodeRequested = true; m_decodeRequested = true;
// m_log.DebugFormat("[J2KIMAGE]: Requesting decode of asset {0}", TextureID);
// Do we have a jpeg decoder? // Do we have a jpeg decoder?
if (J2KDecoder != null) if (J2KDecoder != null)
{ {
@ -149,7 +182,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
// Send it off to the jpeg decoder // Send it off to the jpeg decoder
J2KDecoder.BeginDecode(TextureID, m_asset, J2KDecodedCallback); J2KDecoder.BeginDecode(TextureID, m_asset, J2KDecodedCallback);
} }
} }
else else
{ {
@ -208,7 +240,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
} }
} }
private bool SendFirstPacket(LLClientView client) private bool SendFirstPacket(IClientAPI client)
{ {
if (client == null) if (client == null)
return false; return false;
@ -243,7 +275,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
return false; return false;
} }
private bool SendPacket(LLClientView client) private bool SendPacket(IClientAPI client)
{ {
if (client == null) if (client == null)
return false; return false;
@ -328,14 +360,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP
{ {
if (m_currentPacket == 0) if (m_currentPacket == 0)
return 0; return 0;
if (m_currentPacket == 1) if (m_currentPacket == 1)
return FIRST_PACKET_SIZE; return FIRST_PACKET_SIZE;
int result = FIRST_PACKET_SIZE + ((int)m_currentPacket - 2) * IMAGE_PACKET_SIZE; int result = FIRST_PACKET_SIZE + ((int)m_currentPacket - 2) * IMAGE_PACKET_SIZE;
if (result < 0) if (result < 0)
{
result = FIRST_PACKET_SIZE; result = FIRST_PACKET_SIZE;
}
return result; return result;
} }
@ -372,9 +405,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP
private void AssetReceived(string id, Object sender, AssetBase asset) private void AssetReceived(string id, Object sender, AssetBase asset)
{ {
// m_log.DebugFormat(
// "[J2KIMAGE]: Received asset {0} ({1} bytes)", id, asset != null ? asset.Data.Length.ToString() : "n/a");
UUID assetID = UUID.Zero; UUID assetID = UUID.Zero;
if (asset != null) if (asset != null)
{
assetID = asset.FullID; assetID = asset.FullID;
}
else if ((InventoryAccessModule != null) && (sender != InventoryAccessModule)) else if ((InventoryAccessModule != null) && (sender != InventoryAccessModule))
{ {
// Unfortunately we need this here, there's no other way. // Unfortunately we need this here, there's no other way.
@ -395,7 +433,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
} }
AssetDataCallback(assetID, asset); AssetDataCallback(assetID, asset);
} }
} }
} }

View File

@ -219,6 +219,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
public event BakeTerrain OnBakeTerrain; public event BakeTerrain OnBakeTerrain;
public event RequestTerrain OnUploadTerrain; public event RequestTerrain OnUploadTerrain;
public event EstateChangeInfo OnEstateChangeInfo; public event EstateChangeInfo OnEstateChangeInfo;
public event EstateManageTelehub OnEstateManageTelehub;
public event EstateRestartSimRequest OnEstateRestartSimRequest; public event EstateRestartSimRequest OnEstateRestartSimRequest;
public event EstateChangeCovenantRequest OnEstateChangeCovenantRequest; public event EstateChangeCovenantRequest OnEstateChangeCovenantRequest;
public event UpdateEstateAccessDeltaRequest OnUpdateEstateAccessDeltaRequest; public event UpdateEstateAccessDeltaRequest OnUpdateEstateAccessDeltaRequest;
@ -304,6 +305,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
protected static Dictionary<PacketType, PacketMethod> PacketHandlers = new Dictionary<PacketType, PacketMethod>(); //Global/static handlers for all clients protected static Dictionary<PacketType, PacketMethod> PacketHandlers = new Dictionary<PacketType, PacketMethod>(); //Global/static handlers for all clients
/// <summary>
/// Handles UDP texture download.
/// </summary>
public LLImageManager ImageManager { get; private set; }
private readonly LLUDPServer m_udpServer; private readonly LLUDPServer m_udpServer;
private readonly LLUDPClient m_udpClient; private readonly LLUDPClient m_udpClient;
private readonly UUID m_sessionId; private readonly UUID m_sessionId;
@ -348,7 +354,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
protected Dictionary<PacketType, PacketProcessor> m_packetHandlers = new Dictionary<PacketType, PacketProcessor>(); 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 protected Dictionary<string, GenericMessage> m_genericPacketHandlers = new Dictionary<string, GenericMessage>(); //PauPaw:Local Generic Message handlers
protected Scene m_scene; protected Scene m_scene;
private LLImageManager m_imageManager;
protected string m_firstName; protected string m_firstName;
protected string m_lastName; protected string m_lastName;
protected Thread m_clientThread; protected Thread m_clientThread;
@ -459,7 +464,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
m_assetService = m_scene.RequestModuleInterface<IAssetService>(); m_assetService = m_scene.RequestModuleInterface<IAssetService>();
m_GroupsModule = scene.RequestModuleInterface<IGroupsModule>(); m_GroupsModule = scene.RequestModuleInterface<IGroupsModule>();
m_imageManager = new LLImageManager(this, m_assetService, Scene.RequestModuleInterface<IJ2KDecoder>()); ImageManager = new LLImageManager(this, m_assetService, Scene.RequestModuleInterface<IJ2KDecoder>());
m_channelVersion = Util.StringToBytes256(scene.GetSimulatorVersion()); m_channelVersion = Util.StringToBytes256(scene.GetSimulatorVersion());
m_agentId = agentId; m_agentId = agentId;
m_sessionId = sessionId; m_sessionId = sessionId;
@ -499,7 +504,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
IsActive = false; IsActive = false;
// Shutdown the image manager // Shutdown the image manager
m_imageManager.Close(); ImageManager.Close();
// Fire the callback for this connection closing // Fire the callback for this connection closing
if (OnConnectionClosed != null) if (OnConnectionClosed != null)
@ -577,7 +582,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
/// Add a handler for the given packet type. /// Add a handler for the given packet type.
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// The packet is handled on its own thread. If packets must be handled in the order in which thye /// The packet is handled on its own thread. If packets must be handled in the order in which they
/// are received then please use the synchronous version of this method. /// are received then please use the synchronous version of this method.
/// </remarks> /// </remarks>
/// <param name="packetType"></param> /// <param name="packetType"></param>
@ -758,9 +763,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
OutPacket(handshake, ThrottleOutPacketType.Task); OutPacket(handshake, ThrottleOutPacketType.Task);
} }
/// <summary>
///
/// </summary>
public void MoveAgentIntoRegion(RegionInfo regInfo, Vector3 pos, Vector3 look) public void MoveAgentIntoRegion(RegionInfo regInfo, Vector3 pos, Vector3 look)
{ {
AgentMovementCompletePacket mov = (AgentMovementCompletePacket)PacketPool.Instance.GetPacket(PacketType.AgentMovementComplete); AgentMovementCompletePacket mov = (AgentMovementCompletePacket)PacketPool.Instance.GetPacket(PacketType.AgentMovementComplete);
@ -3476,6 +3478,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
public void SendAppearance(UUID agentID, byte[] visualParams, byte[] textureEntry) public void SendAppearance(UUID agentID, byte[] visualParams, byte[] textureEntry)
{ {
// m_log.DebugFormat(
// "[LLCLIENTVIEW]: Sending avatar appearance for {0} with {1} bytes to {2} {3}",
// agentID, textureEntry.Length, Name, AgentId);
AvatarAppearancePacket avp = (AvatarAppearancePacket)PacketPool.Instance.GetPacket(PacketType.AvatarAppearance); AvatarAppearancePacket avp = (AvatarAppearancePacket)PacketPool.Instance.GetPacket(PacketType.AvatarAppearance);
// TODO: don't create new blocks if recycling an old packet // TODO: don't create new blocks if recycling an old packet
avp.VisualParam = new AvatarAppearancePacket.VisualParamBlock[218]; avp.VisualParam = new AvatarAppearancePacket.VisualParamBlock[218];
@ -3497,7 +3503,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
public void SendAnimations(UUID[] animations, int[] seqs, UUID sourceAgentId, UUID[] objectIDs) public void SendAnimations(UUID[] animations, int[] seqs, UUID sourceAgentId, UUID[] objectIDs)
{ {
//m_log.DebugFormat("[CLIENT]: Sending animations to {0}", Name); // m_log.DebugFormat("[LLCLIENTVIEW]: Sending animations for {0} to {1}", sourceAgentId, Name);
AvatarAnimationPacket ani = (AvatarAnimationPacket)PacketPool.Instance.GetPacket(PacketType.AvatarAnimation); AvatarAnimationPacket ani = (AvatarAnimationPacket)PacketPool.Instance.GetPacket(PacketType.AvatarAnimation);
// TODO: don't create new blocks if recycling an old packet // TODO: don't create new blocks if recycling an old packet
@ -3532,6 +3538,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
/// </summary> /// </summary>
public void SendAvatarDataImmediate(ISceneEntity avatar) public void SendAvatarDataImmediate(ISceneEntity avatar)
{ {
// m_log.DebugFormat(
// "[LLCLIENTVIEW]: Sending immediate object update for avatar {0} {1} to {2} {3}",
// avatar.Name, avatar.UUID, Name, AgentId);
ScenePresence presence = avatar as ScenePresence; ScenePresence presence = avatar as ScenePresence;
if (presence == null) if (presence == null)
return; return;
@ -3939,7 +3949,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
} }
if ((categories & ThrottleOutPacketTypeFlags.Texture) != 0) if ((categories & ThrottleOutPacketTypeFlags.Texture) != 0)
m_imageManager.ProcessImageQueue(m_udpServer.TextureSendLimit); ImageManager.ProcessImageQueue(m_udpServer.TextureSendLimit);
} }
public void SendAssetUploadCompleteMessage(sbyte AssetType, bool Success, UUID AssetFullID) public void SendAssetUploadCompleteMessage(sbyte AssetType, bool Success, UUID AssetFullID)
@ -4473,6 +4483,23 @@ namespace OpenSim.Region.ClientStack.LindenUDP
OutPacket(packet, ThrottleOutPacketType.Task); OutPacket(packet, ThrottleOutPacketType.Task);
} }
public void SendTelehubInfo(UUID ObjectID, string ObjectName, Vector3 ObjectPos, Quaternion ObjectRot, List<Vector3> SpawnPoint)
{
TelehubInfoPacket packet = (TelehubInfoPacket)PacketPool.Instance.GetPacket(PacketType.TelehubInfo);
packet.TelehubBlock.ObjectID = ObjectID;
packet.TelehubBlock.ObjectName = Utils.StringToBytes(ObjectName);
packet.TelehubBlock.TelehubPos = ObjectPos;
packet.TelehubBlock.TelehubRot = ObjectRot;
packet.SpawnPointBlock = new TelehubInfoPacket.SpawnPointBlockBlock[SpawnPoint.Count];
for (int n = 0; n < SpawnPoint.Count; n++)
{
packet.SpawnPointBlock[n] = new TelehubInfoPacket.SpawnPointBlockBlock{SpawnPointPos = SpawnPoint[n]};
}
OutPacket(packet, ThrottleOutPacketType.Task);
}
#endregion #endregion
#region Land Data Sending Methods #region Land Data Sending Methods
@ -7470,7 +7497,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
if ((ImageType)block.Type == ImageType.Baked) if ((ImageType)block.Type == ImageType.Baked)
args.Priority *= 2.0f; args.Priority *= 2.0f;
m_imageManager.EnqueueReq(args); ImageManager.EnqueueReq(args);
} }
return true; return true;
@ -8911,7 +8938,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
private bool HandleEstateOwnerMessage(IClientAPI sender, Packet Pack) private bool HandleEstateOwnerMessage(IClientAPI sender, Packet Pack)
{ {
EstateOwnerMessagePacket messagePacket = (EstateOwnerMessagePacket)Pack; EstateOwnerMessagePacket messagePacket = (EstateOwnerMessagePacket)Pack;
//m_log.Debug(messagePacket.ToString()); // m_log.InfoFormat("[LLCLIENTVIEW]: Packet: {0}", Utils.BytesToString(messagePacket.MethodData.Method));
GodLandStatRequest handlerLandStatRequest; GodLandStatRequest handlerLandStatRequest;
#region Packet Session and User Check #region Packet Session and User Check
@ -9210,6 +9237,34 @@ namespace OpenSim.Region.ClientStack.LindenUDP
} }
return true; return true;
case "telehub":
if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
{
UUID invoice = messagePacket.MethodData.Invoice;
UUID SenderID = messagePacket.AgentData.AgentID;
UInt32 param1 = 0u;
string command = (string)Utils.BytesToString(messagePacket.ParamList[0].Parameter);
if (command != "info ui")
{
try
{
param1 = Convert.ToUInt32(Utils.BytesToString(messagePacket.ParamList[1].Parameter));
}
catch
{
}
}
EstateManageTelehub handlerEstateManageTelehub = OnEstateManageTelehub;
if (handlerEstateManageTelehub != null)
{
handlerEstateManageTelehub(this, invoice, SenderID, command, param1);
}
}
return true;
default: default:
m_log.Error("EstateOwnerMessage: Unknown method requested\n" + messagePacket); m_log.Error("EstateOwnerMessage: Unknown method requested\n" + messagePacket);
return true; return true;
@ -9221,8 +9276,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
//lsrp.RequestData.ReportType; // 1 = colliders, 0 = scripts //lsrp.RequestData.ReportType; // 1 = colliders, 0 = scripts
//lsrp.RequestData.RequestFlags; //lsrp.RequestData.RequestFlags;
//lsrp.RequestData.Filter; //lsrp.RequestData.Filter;
// return true;
} }
private bool HandleRequestRegionInfo(IClientAPI sender, Packet Pack) private bool HandleRequestRegionInfo(IClientAPI sender, Packet Pack)

View File

@ -55,18 +55,29 @@ namespace OpenSim.Region.ClientStack.LindenUDP
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private bool m_shuttingdown; private bool m_shuttingdown;
private AssetBase m_missingImage; private AssetBase m_missingImage;
private LLClientView m_client; //Client we're assigned to private IAssetService m_assetCache;
private IAssetService m_assetCache; //Asset Cache private IJ2KDecoder m_j2kDecodeModule;
private IJ2KDecoder m_j2kDecodeModule; //Our J2K module
/// <summary>
/// Priority queue for determining which image to send first.
/// </summary>
private C5.IntervalHeap<J2KImage> m_priorityQueue = new C5.IntervalHeap<J2KImage>(10, new J2KImageComparer()); private C5.IntervalHeap<J2KImage> m_priorityQueue = new C5.IntervalHeap<J2KImage>(10, new J2KImageComparer());
/// <summary>
/// Used to control thread access to the priority queue.
/// </summary>
private object m_syncRoot = new object(); private object m_syncRoot = new object();
public LLClientView Client { get { return m_client; } } /// <summary>
/// Client served by this image manager
/// </summary>
public IClientAPI Client { get; private set; }
public AssetBase MissingImage { get { return m_missingImage; } } public AssetBase MissingImage { get { return m_missingImage; } }
public LLImageManager(LLClientView client, IAssetService pAssetCache, IJ2KDecoder pJ2kDecodeModule) public LLImageManager(IClientAPI client, IAssetService pAssetCache, IJ2KDecoder pJ2kDecodeModule)
{ {
m_client = client; Client = client;
m_assetCache = pAssetCache; m_assetCache = pAssetCache;
if (pAssetCache != null) if (pAssetCache != null)
@ -84,7 +95,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
/// <param name="newRequest"></param> /// <param name="newRequest"></param>
public void EnqueueReq(TextureRequestArgs newRequest) public void EnqueueReq(TextureRequestArgs newRequest)
{ {
//Make sure we're not shutting down..
if (!m_shuttingdown) if (!m_shuttingdown)
{ {
J2KImage imgrequest; J2KImage imgrequest;
@ -108,8 +118,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP
} }
else else
{ {
//m_log.DebugFormat("[TEX]: (UPD) ID={0}: D={1}, S={2}, P={3}", // m_log.DebugFormat(
// newRequest.RequestedAssetID, newRequest.DiscardLevel, newRequest.PacketNumber, newRequest.Priority); // "[LL IMAGE MANAGER]: Received duplicate of existing request for {0}, start packet {1} from {2}",
// newRequest.RequestedAssetID, newRequest.PacketNumber, m_client.Name);
// m_log.DebugFormat("[TEX]: (UPD) ID={0}: D={1}, S={2}, P={3}",
// newRequest.RequestedAssetID, newRequest.DiscardLevel, newRequest.PacketNumber, newRequest.Priority);
//Check the packet sequence to make sure this isn't older than //Check the packet sequence to make sure this isn't older than
//one we've already received //one we've already received
@ -126,11 +140,34 @@ namespace OpenSim.Region.ClientStack.LindenUDP
//Update the requested priority //Update the requested priority
imgrequest.Priority = newRequest.Priority; imgrequest.Priority = newRequest.Priority;
UpdateImageInQueue(imgrequest); UpdateImageInQueue(imgrequest);
//Run an update
imgrequest.RunUpdate(); imgrequest.RunUpdate();
// J2KImage imgrequest2 = new J2KImage(this);
// imgrequest2.J2KDecoder = m_j2kDecodeModule;
// imgrequest2.AssetService = m_assetCache;
// imgrequest2.AgentID = m_client.AgentId;
// imgrequest2.InventoryAccessModule = m_client.Scene.RequestModuleInterface<IInventoryAccessModule>();
// imgrequest2.DiscardLevel = newRequest.DiscardLevel;
// imgrequest2.StartPacket = Math.Max(1, newRequest.PacketNumber);
// imgrequest2.Priority = newRequest.Priority;
// imgrequest2.TextureID = newRequest.RequestedAssetID;
// imgrequest2.Priority = newRequest.Priority;
//
// //Add this download to the priority queue
// AddImageToQueue(imgrequest2);
//
// imgrequest2.RunUpdate();
} }
// else
// {
// m_log.DebugFormat(
// "[LL IMAGE MANAGER]: Ignoring duplicate of existing request for {0} (sequence {1}) from {2} as its request sequence {3} is not greater",
// newRequest.RequestedAssetID, imgrequest.LastSequence, m_client.Name, newRequest.requestSequence);
// }
} }
} }
else else
@ -142,14 +179,18 @@ namespace OpenSim.Region.ClientStack.LindenUDP
} }
else else
{ {
// m_log.DebugFormat(
// "[LL IMAGE MANAGER]: Received request for {0}, start packet {1} from {2}",
// newRequest.RequestedAssetID, newRequest.PacketNumber, m_client.Name);
//m_log.DebugFormat("[TEX]: (NEW) ID={0}: D={1}, S={2}, P={3}", //m_log.DebugFormat("[TEX]: (NEW) ID={0}: D={1}, S={2}, P={3}",
// newRequest.RequestedAssetID, newRequest.DiscardLevel, newRequest.PacketNumber, newRequest.Priority); // newRequest.RequestedAssetID, newRequest.DiscardLevel, newRequest.PacketNumber, newRequest.Priority);
imgrequest = new J2KImage(this); imgrequest = new J2KImage(this);
imgrequest.J2KDecoder = m_j2kDecodeModule; imgrequest.J2KDecoder = m_j2kDecodeModule;
imgrequest.AssetService = m_assetCache; imgrequest.AssetService = m_assetCache;
imgrequest.AgentID = m_client.AgentId; imgrequest.AgentID = Client.AgentId;
imgrequest.InventoryAccessModule = m_client.Scene.RequestModuleInterface<IInventoryAccessModule>(); imgrequest.InventoryAccessModule = Client.Scene.RequestModuleInterface<IInventoryAccessModule>();
imgrequest.DiscardLevel = newRequest.DiscardLevel; imgrequest.DiscardLevel = newRequest.DiscardLevel;
imgrequest.StartPacket = Math.Max(1, newRequest.PacketNumber); imgrequest.StartPacket = Math.Max(1, newRequest.PacketNumber);
imgrequest.Priority = newRequest.Priority; imgrequest.Priority = newRequest.Priority;
@ -159,7 +200,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
//Add this download to the priority queue //Add this download to the priority queue
AddImageToQueue(imgrequest); AddImageToQueue(imgrequest);
//Run an update
imgrequest.RunUpdate(); imgrequest.RunUpdate();
} }
} }
@ -176,12 +216,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP
// If null was returned, the texture priority queue is currently empty // If null was returned, the texture priority queue is currently empty
if (image == null) if (image == null)
return false; break;
if (image.IsDecoded) if (image.IsDecoded)
{ {
int sent; int sent;
bool imageDone = image.SendPackets(m_client, packetsToSend - packetsSent, out sent); bool imageDone = image.SendPackets(Client, packetsToSend - packetsSent, out sent);
packetsSent += sent; packetsSent += sent;
// If the send is complete, destroy any knowledge of this transfer // If the send is complete, destroy any knowledge of this transfer
@ -194,10 +234,17 @@ namespace OpenSim.Region.ClientStack.LindenUDP
// written. Undecoded textures should not be going into the priority // written. Undecoded textures should not be going into the priority
// queue, because a high priority undecoded texture will clog up the // queue, because a high priority undecoded texture will clog up the
// pipeline for a client // pipeline for a client
return true; // m_log.DebugFormat(
// "[LL IMAGE MANAGER]: Exiting image queue processing early on encountering undecoded image {0}",
// image.TextureID);
break;
} }
} }
// if (packetsSent != 0)
// m_log.DebugFormat("[LL IMAGE MANAGER]: Processed {0} packets from image queue", packetsSent);
return m_priorityQueue.Count > 0; return m_priorityQueue.Count > 0;
} }
@ -209,6 +256,36 @@ namespace OpenSim.Region.ClientStack.LindenUDP
m_shuttingdown = true; m_shuttingdown = true;
} }
/// <summary>
/// Clear the image queue.
/// </summary>
/// <returns>The number of requests cleared.</returns>
public int ClearImageQueue()
{
int requestsDeleted;
lock (m_priorityQueue)
{
requestsDeleted = m_priorityQueue.Count;
// Surprisingly, there doesn't seem to be a clear method at this time.
while (!m_priorityQueue.IsEmpty)
m_priorityQueue.DeleteMax();
}
return requestsDeleted;
}
/// <summary>
/// Returns an array containing all the images in the queue.
/// </summary>
/// <returns></returns>
public J2KImage[] GetImages()
{
lock (m_priorityQueue)
return m_priorityQueue.ToArray();
}
#region Priority Queue Helpers #region Priority Queue Helpers
private J2KImage GetHighestPriorityImage() private J2KImage GetHighestPriorityImage()
@ -219,7 +296,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
{ {
if (m_priorityQueue.Count > 0) if (m_priorityQueue.Count > 0)
{ {
try { image = m_priorityQueue.FindMax(); } try
{
image = m_priorityQueue.FindMax();
}
catch (Exception) { } catch (Exception) { }
} }
} }
@ -232,7 +312,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
lock (m_syncRoot) lock (m_syncRoot)
{ {
try { m_priorityQueue.Add(ref image.PriorityQueueHandle, image); } try
{
m_priorityQueue.Add(ref image.PriorityQueueHandle, image);
}
catch (Exception) { } catch (Exception) { }
} }
} }
@ -241,7 +324,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
{ {
lock (m_syncRoot) lock (m_syncRoot)
{ {
try { m_priorityQueue.Delete(image.PriorityQueueHandle); } try
{
m_priorityQueue.Delete(image.PriorityQueueHandle);
}
catch (Exception) { } catch (Exception) { }
} }
} }
@ -250,7 +336,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
{ {
lock (m_syncRoot) lock (m_syncRoot)
{ {
try { m_priorityQueue.Replace(image.PriorityQueueHandle, image); } try
{
m_priorityQueue.Replace(image.PriorityQueueHandle, image);
}
catch (Exception) catch (Exception)
{ {
image.PriorityQueueHandle = null; image.PriorityQueueHandle = null;

View File

@ -492,6 +492,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
if ((Environment.TickCount & Int32.MaxValue) - udpClient.TickLastPacketReceived > 1000 * 60) if ((Environment.TickCount & Int32.MaxValue) - udpClient.TickLastPacketReceived > 1000 * 60)
{ {
m_log.Warn("[LLUDPSERVER]: Ack timeout, disconnecting " + udpClient.AgentID); m_log.Warn("[LLUDPSERVER]: Ack timeout, disconnecting " + udpClient.AgentID);
StatsManager.SimExtraStats.AddAbnormalClientThreadTermination();
RemoveClient(udpClient); RemoveClient(udpClient);
return; return;

View File

@ -0,0 +1,160 @@
/*
* 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.Net;
using System.Reflection;
using log4net.Config;
using Nini.Config;
using NUnit.Framework;
using OpenMetaverse;
using OpenMetaverse.Packets;
using OpenSim.Framework;
using OpenSim.Region.CoreModules.Agent.TextureSender;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Tests.Common;
using OpenSim.Tests.Common.Mock;
namespace OpenSim.Region.ClientStack.LindenUDP.Tests
{
[TestFixture]
public class LLImageManagerTests
{
private AssetBase m_testImageAsset;
private Scene scene;
private LLImageManager llim;
private TestClient tc;
[TestFixtureSetUp]
public void FixtureInit()
{
using (
Stream resource
= GetType().Assembly.GetManifestResourceStream(
"OpenSim.Region.ClientStack.LindenUDP.Tests.Resources.4-tile2.jp2"))
{
using (BinaryReader br = new BinaryReader(resource))
{
m_testImageAsset
= new AssetBase(
TestHelpers.ParseTail(0x1),
"Test Image",
(sbyte)AssetType.Texture,
TestHelpers.ParseTail(0x2).ToString());
m_testImageAsset.Data = br.ReadBytes(99999999);
}
}
}
[SetUp]
public void SetUp()
{
UUID userId = TestHelpers.ParseTail(0x3);
J2KDecoderModule j2kdm = new J2KDecoderModule();
scene = SceneHelpers.SetupScene();
SceneHelpers.SetupSceneModules(scene, j2kdm);
tc = new TestClient(SceneHelpers.GenerateAgentData(userId), scene);
llim = new LLImageManager(tc, scene.AssetService, j2kdm);
}
[Test]
public void TestSendImage()
{
TestHelpers.InMethod();
// XmlConfigurator.Configure();
scene.AssetService.Store(m_testImageAsset);
TextureRequestArgs args = new TextureRequestArgs();
args.RequestedAssetID = m_testImageAsset.FullID;
args.DiscardLevel = 0;
args.PacketNumber = 1;
args.Priority = 5;
args.requestSequence = 1;
llim.EnqueueReq(args);
llim.ProcessImageQueue(20);
Assert.That(tc.SentImageDataPackets.Count, Is.EqualTo(1));
}
[Test]
public void TestDiscardImage()
{
TestHelpers.InMethod();
// XmlConfigurator.Configure();
scene.AssetService.Store(m_testImageAsset);
TextureRequestArgs args = new TextureRequestArgs();
args.RequestedAssetID = m_testImageAsset.FullID;
args.DiscardLevel = 0;
args.PacketNumber = 1;
args.Priority = 5;
args.requestSequence = 1;
llim.EnqueueReq(args);
// Now create a discard request
TextureRequestArgs discardArgs = new TextureRequestArgs();
discardArgs.RequestedAssetID = m_testImageAsset.FullID;
discardArgs.DiscardLevel = -1;
discardArgs.PacketNumber = 1;
discardArgs.Priority = 0;
discardArgs.requestSequence = 2;
llim.EnqueueReq(discardArgs);
llim.ProcessImageQueue(20);
Assert.That(tc.SentImageDataPackets.Count, Is.EqualTo(0));
}
[Test]
public void TestMissingImage()
{
TestHelpers.InMethod();
// XmlConfigurator.Configure();
TextureRequestArgs args = new TextureRequestArgs();
args.RequestedAssetID = m_testImageAsset.FullID;
args.DiscardLevel = 0;
args.PacketNumber = 1;
args.Priority = 5;
args.requestSequence = 1;
llim.EnqueueReq(args);
llim.ProcessImageQueue(20);
Assert.That(tc.SentImageDataPackets.Count, Is.EqualTo(0));
Assert.That(tc.SentImageNotInDatabasePackets.Count, Is.EqualTo(1));
}
}
}

View File

@ -246,7 +246,7 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
if (mm != null) if (mm != null)
{ {
if (!mm.UploadCovered(remoteClient, mm.UploadCharge)) if (!mm.UploadCovered(remoteClient.AgentId, mm.UploadCharge))
{ {
remoteClient.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false); remoteClient.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false);
return; return;

View File

@ -103,6 +103,10 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender
// If it's cached, return the cached results // If it's cached, return the cached results
if (m_decodedCache.TryGetValue(assetID, out result)) if (m_decodedCache.TryGetValue(assetID, out result))
{ {
// m_log.DebugFormat(
// "[J2KDecoderModule]: Returning existing cached {0} layers j2k decode for {1}",
// result.Length, assetID);
callback(assetID, result); callback(assetID, result);
} }
else else
@ -129,18 +133,20 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender
// Do Decode! // Do Decode!
if (decode) if (decode)
DoJ2KDecode(assetID, j2kData); Decode(assetID, j2kData);
} }
} }
/// <summary> public bool Decode(UUID assetID, byte[] j2kData)
/// Provides a synchronous decode so that caller can be assured that this executes before the next line
/// </summary>
/// <param name="assetID"></param>
/// <param name="j2kData"></param>
public void Decode(UUID assetID, byte[] j2kData)
{ {
DoJ2KDecode(assetID, j2kData); OpenJPEG.J2KLayerInfo[] layers;
int components;
return Decode(assetID, j2kData, out layers, out components);
}
public bool Decode(UUID assetID, byte[] j2kData, out OpenJPEG.J2KLayerInfo[] layers, out int components)
{
return DoJ2KDecode(assetID, j2kData, out layers, out components);
} }
#endregion IJ2KDecoder #endregion IJ2KDecoder
@ -150,14 +156,21 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender
/// </summary> /// </summary>
/// <param name="assetID">UUID of Asset</param> /// <param name="assetID">UUID of Asset</param>
/// <param name="j2kData">JPEG2000 data</param> /// <param name="j2kData">JPEG2000 data</param>
private void DoJ2KDecode(UUID assetID, byte[] j2kData) /// <param name="layers">layer data</param>
/// <param name="components">number of components</param>
/// <returns>true if decode was successful. false otherwise.</returns>
private bool DoJ2KDecode(UUID assetID, byte[] j2kData, out OpenJPEG.J2KLayerInfo[] layers, out int components)
{ {
// m_log.DebugFormat( // m_log.DebugFormat(
// "[J2KDecoderModule]: Doing J2K decoding of {0} bytes for asset {1}", j2kData.Length, assetID); // "[J2KDecoderModule]: Doing J2K decoding of {0} bytes for asset {1}", j2kData.Length, assetID);
bool decodedSuccessfully = true;
//int DecodeTime = 0; //int DecodeTime = 0;
//DecodeTime = Environment.TickCount; //DecodeTime = Environment.TickCount;
OpenJPEG.J2KLayerInfo[] layers;
// We don't get this from CSJ2K. Is it relevant?
components = 0;
if (!TryLoadCacheForAsset(assetID, out layers)) if (!TryLoadCacheForAsset(assetID, out layers))
{ {
@ -192,14 +205,15 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender
catch (Exception ex) catch (Exception ex)
{ {
m_log.Warn("[J2KDecoderModule]: CSJ2K threw an exception decoding texture " + assetID + ": " + ex.Message); m_log.Warn("[J2KDecoderModule]: CSJ2K threw an exception decoding texture " + assetID + ": " + ex.Message);
decodedSuccessfully = false;
} }
} }
else else
{ {
int components;
if (!OpenJPEG.DecodeLayerBoundaries(j2kData, out layers, out components)) if (!OpenJPEG.DecodeLayerBoundaries(j2kData, out layers, out components))
{ {
m_log.Warn("[J2KDecoderModule]: OpenJPEG failed to decode texture " + assetID); m_log.Warn("[J2KDecoderModule]: OpenJPEG failed to decode texture " + assetID);
decodedSuccessfully = false;
} }
} }
@ -208,6 +222,7 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender
m_log.Warn("[J2KDecoderModule]: Failed to decode layer data for texture " + assetID + ", guessing sane defaults"); m_log.Warn("[J2KDecoderModule]: Failed to decode layer data for texture " + assetID + ", guessing sane defaults");
// Layer decoding completely failed. Guess at sane defaults for the layer boundaries // Layer decoding completely failed. Guess at sane defaults for the layer boundaries
layers = CreateDefaultLayers(j2kData.Length); layers = CreateDefaultLayers(j2kData.Length);
decodedSuccessfully = false;
} }
// Cache Decoded layers // Cache Decoded layers
@ -227,6 +242,8 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender
m_notifyList.Remove(assetID); m_notifyList.Remove(assetID);
} }
} }
return decodedSuccessfully;
} }
private OpenJPEG.J2KLayerInfo[] CreateDefaultLayers(int j2kLength) private OpenJPEG.J2KLayerInfo[] CreateDefaultLayers(int j2kLength)

View File

@ -148,7 +148,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
} }
} }
public void SaveChangedAttachments(IScenePresence sp) public void SaveChangedAttachments(IScenePresence sp, bool saveAllScripted)
{ {
// m_log.DebugFormat("[ATTACHMENTS MODULE]: Saving changed attachments for {0}", sp.Name); // m_log.DebugFormat("[ATTACHMENTS MODULE]: Saving changed attachments for {0}", sp.Name);
@ -157,13 +157,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
foreach (SceneObjectGroup grp in sp.GetAttachments()) foreach (SceneObjectGroup grp in sp.GetAttachments())
{ {
// if (grp.HasGroupChanged) // Resizer scripts?
// {
grp.IsAttachment = false; grp.IsAttachment = false;
grp.AbsolutePosition = grp.RootPart.AttachedPos; grp.AbsolutePosition = grp.RootPart.AttachedPos;
UpdateKnownItem(sp, grp); UpdateKnownItem(sp, grp, saveAllScripted);
grp.IsAttachment = true; grp.IsAttachment = true;
// }
} }
} }
@ -460,9 +457,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
/// </remarks> /// </remarks>
/// <param name="sp"></param> /// <param name="sp"></param>
/// <param name="grp"></param> /// <param name="grp"></param>
private void UpdateKnownItem(IScenePresence sp, SceneObjectGroup grp) private void UpdateKnownItem(IScenePresence sp, SceneObjectGroup grp, bool saveAllScripted)
{ {
if (grp.HasGroupChanged || grp.ContainsScripts()) // Saving attachments for NPCs messes them up for the real owner!
INPCModule module = m_scene.RequestModuleInterface<INPCModule>();
if (module != null)
{
if (module.IsNPC(sp.UUID, m_scene))
return;
}
if (grp.HasGroupChanged || (saveAllScripted && grp.ContainsScripts()))
{ {
m_log.DebugFormat( m_log.DebugFormat(
"[ATTACHMENTS MODULE]: Updating asset for attachment {0}, attachpoint {1}", "[ATTACHMENTS MODULE]: Updating asset for attachment {0}, attachpoint {1}",
@ -495,6 +500,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
if (sp.ControllingClient != null) if (sp.ControllingClient != null)
sp.ControllingClient.SendInventoryItemCreateUpdate(item, 0); sp.ControllingClient.SendInventoryItemCreateUpdate(item, 0);
} }
grp.HasGroupChanged = false; // Prevent it being saved over and over
} }
else else
{ {
@ -688,7 +694,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
group.IsAttachment = false; group.IsAttachment = false;
group.AbsolutePosition = group.RootPart.AttachedPos; group.AbsolutePosition = group.RootPart.AttachedPos;
UpdateKnownItem(sp, group); UpdateKnownItem(sp, group, true);
m_scene.DeleteSceneObject(group, false); m_scene.DeleteSceneObject(group, false);
return; return;

View File

@ -149,14 +149,15 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
// Process the baked texture array // Process the baked texture array
if (textureEntry != null) if (textureEntry != null)
{ {
m_log.InfoFormat("[AVFACTORY]: received texture update for {0}", sp.UUID); m_log.InfoFormat("[AVFACTORY]: Received texture update for {0} {1}", sp.Name, sp.UUID);
// WriteBakedTexturesReport(sp, m_log.DebugFormat); // WriteBakedTexturesReport(sp, m_log.DebugFormat);
changed = sp.Appearance.SetTextureEntries(textureEntry) || changed; changed = sp.Appearance.SetTextureEntries(textureEntry) || changed;
// WriteBakedTexturesReport(sp, m_log.DebugFormat); // WriteBakedTexturesReport(sp, m_log.DebugFormat);
ValidateBakedTextureCache(sp, false); if (!ValidateBakedTextureCache(sp))
RequestRebake(sp, true);
// This appears to be set only in the final stage of the appearance // This appears to be set only in the final stage of the appearance
// update transaction. In theory, we should be able to do an immediate // update transaction. In theory, we should be able to do an immediate
@ -250,15 +251,6 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
return true; return true;
} }
/// <summary>
/// Check for the existence of the baked texture assets.
/// </summary>
/// <param name="sp"></param>
public bool ValidateBakedTextureCache(IScenePresence sp)
{
return ValidateBakedTextureCache(sp, true);
}
/// <summary> /// <summary>
/// Queue up a request to send appearance. /// Queue up a request to send appearance.
/// </summary> /// </summary>
@ -292,17 +284,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
} }
} }
#endregion public bool ValidateBakedTextureCache(IScenePresence sp)
#region AvatarFactoryModule private methods
/// <summary>
/// Check for the existence of the baked texture assets. Request a rebake
/// unless checkonly is true.
/// </summary>
/// <param name="client"></param>
/// <param name="checkonly"></param>
private bool ValidateBakedTextureCache(IScenePresence sp, bool checkonly)
{ {
bool defonly = true; // are we only using default textures bool defonly = true; // are we only using default textures
@ -330,24 +312,66 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
defonly = false; // found a non-default texture reference defonly = false; // found a non-default texture reference
if (m_scene.AssetService.Get(face.TextureID.ToString()) == null) if (m_scene.AssetService.Get(face.TextureID.ToString()) == null)
{
if (checkonly)
return false; return false;
m_log.DebugFormat(
"[AVFACTORY]: Missing baked texture {0} ({1}) for {2}, requesting rebake.",
face.TextureID, idx, sp.Name);
sp.ControllingClient.SendRebakeAvatarTextures(face.TextureID);
}
} }
m_log.DebugFormat("[AVFACTORY]: Completed texture check for {0}", sp.UUID); m_log.DebugFormat("[AVFACTORY]: Completed texture check for {0} {1}", sp.Name, sp.UUID);
// If we only found default textures, then the appearance is not cached // If we only found default textures, then the appearance is not cached
return (defonly ? false : true); return (defonly ? false : true);
} }
public int RequestRebake(IScenePresence sp, bool missingTexturesOnly)
{
int texturesRebaked = 0;
for (int i = 0; i < AvatarAppearance.BAKE_INDICES.Length; i++)
{
int idx = AvatarAppearance.BAKE_INDICES[i];
Primitive.TextureEntryFace face = sp.Appearance.Texture.FaceTextures[idx];
// if there is no texture entry, skip it
if (face == null)
continue;
// m_log.DebugFormat(
// "[AVFACTORY]: Looking for texture {0}, id {1} for {2} {3}",
// face.TextureID, idx, client.Name, client.AgentId);
// if the texture is one of the "defaults" then skip it
// this should probably be more intelligent (skirt texture doesnt matter
// if the avatar isnt wearing a skirt) but if any of the main baked
// textures is default then the rest should be as well
if (face.TextureID == UUID.Zero || face.TextureID == AppearanceManager.DEFAULT_AVATAR_TEXTURE)
continue;
if (missingTexturesOnly)
{
if (m_scene.AssetService.Get(face.TextureID.ToString()) != null)
continue;
else
m_log.DebugFormat(
"[AVFACTORY]: Missing baked texture {0} ({1}) for {2}, requesting rebake.",
face.TextureID, idx, sp.Name);
}
else
{
m_log.DebugFormat(
"[AVFACTORY]: Requesting rebake of {0} ({1}) for {2}.",
face.TextureID, idx, sp.Name);
}
texturesRebaked++;
sp.ControllingClient.SendRebakeAvatarTextures(face.TextureID);
}
return texturesRebaked;
}
#endregion
#region AvatarFactoryModule private methods
private Dictionary<BakeType, Primitive.TextureEntryFace> GetBakedTextureFaces(ScenePresence sp) private Dictionary<BakeType, Primitive.TextureEntryFace> GetBakedTextureFaces(ScenePresence sp)
{ {
if (sp.IsChildAgent) if (sp.IsChildAgent)

View File

@ -496,13 +496,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
string agentFriendService = string.Empty; string agentFriendService = string.Empty;
string friendFriendService = string.Empty; string friendFriendService = string.Empty;
if (agentIsLocal) if (agentClient != null)
{ {
agentClientCircuit = ((Scene)(agentClient.Scene)).AuthenticateHandler.GetAgentCircuitData(agentClient.CircuitCode); agentClientCircuit = ((Scene)(agentClient.Scene)).AuthenticateHandler.GetAgentCircuitData(agentClient.CircuitCode);
agentUUI = Util.ProduceUserUniversalIdentifier(agentClientCircuit); agentUUI = Util.ProduceUserUniversalIdentifier(agentClientCircuit);
agentFriendService = agentClientCircuit.ServiceURLs["FriendsServerURI"].ToString(); agentFriendService = agentClientCircuit.ServiceURLs["FriendsServerURI"].ToString();
} }
if (friendIsLocal) if (friendClient != null)
{ {
friendClientCircuit = ((Scene)(friendClient.Scene)).AuthenticateHandler.GetAgentCircuitData(friendClient.CircuitCode); friendClientCircuit = ((Scene)(friendClient.Scene)).AuthenticateHandler.GetAgentCircuitData(friendClient.CircuitCode);
friendUUI = Util.ProduceUserUniversalIdentifier(friendClientCircuit); friendUUI = Util.ProduceUserUniversalIdentifier(friendClientCircuit);

View File

@ -493,7 +493,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
} }
else else
{ {
sceneObjects.Add(SceneObjectSerializer.FromOriginalXmlFormat(xmlData)); SceneObjectGroup deserializedObject = SceneObjectSerializer.FromOriginalXmlFormat(xmlData);
if (deserializedObject != null)
sceneObjects.Add(deserializedObject);
} }
foreach (SceneObjectGroup sog in sceneObjects) foreach (SceneObjectGroup sog in sceneObjects)

View File

@ -122,12 +122,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
scene.AddCommand( scene.AddCommand(
this, "save iar", this, "save iar",
"save iar [--p|-profile=<url>] [--noassets] <first> <last> <inventory path> <password> [<IAR path>] [--v|-verbose]", "save iar [-h|--home=<url>] [--noassets] <first> <last> <inventory path> <password> [<IAR path>] [--v|-verbose]",
"Save user inventory archive (IAR).", "Save user inventory archive (IAR).",
"<first> is the user's first name." + Environment.NewLine "<first> is the user's first name." + Environment.NewLine
+ "<last> is the user's last name." + Environment.NewLine + "<last> is the user's last name." + Environment.NewLine
+ "<inventory path> is the path inside the user's inventory for the folder/item to be saved." + Environment.NewLine + "<inventory path> is the path inside the user's inventory for the folder/item to be saved." + Environment.NewLine
+ "-p|--profile=<url> adds the url of the profile service to the saved user information." + Environment.NewLine + "-h|--home=<url> adds the url of the profile service to the saved user information." + Environment.NewLine
+ "-c|--creators preserves information about foreign creators." + Environment.NewLine + "-c|--creators preserves information about foreign creators." + Environment.NewLine
+ "-v|--verbose extra debug messages." + Environment.NewLine + "-v|--verbose extra debug messages." + Environment.NewLine
+ "--noassets stops assets being saved to the IAR." + "--noassets stops assets being saved to the IAR."

View File

@ -208,7 +208,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
foreach (SceneObjectGroup grp in sp.GetAttachments()) foreach (SceneObjectGroup grp in sp.GetAttachments())
{ {
if (grp.IsDeleted)
sp.Scene.EventManager.TriggerOnScriptChangedEvent(grp.LocalId, (uint)Changed.TELEPORT); sp.Scene.EventManager.TriggerOnScriptChangedEvent(grp.LocalId, (uint)Changed.TELEPORT);
} }
} }

View File

@ -348,7 +348,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
region.ExternalHostName = uri.Host; region.ExternalHostName = uri.Host;
region.HttpPort = (uint)uri.Port; region.HttpPort = (uint)uri.Port;
region.ServerURI = uri.ToString(); region.ServerURI = aCircuit.ServiceURLs["HomeURI"].ToString();
region.RegionName = string.Empty; region.RegionName = string.Empty;
region.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), (int)0); region.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), (int)0);
return region; return region;

View File

@ -55,16 +55,16 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
// private Dictionary<string, InventoryClient> m_inventoryServers = new Dictionary<string, InventoryClient>(); // private Dictionary<string, InventoryClient> m_inventoryServers = new Dictionary<string, InventoryClient>();
private Scene m_scene; private Scene m_scene;
private string m_ProfileServerURI; private string m_HomeURI;
#endregion #endregion
#region Constructor #region Constructor
public HGAssetMapper(Scene scene, string profileURL) public HGAssetMapper(Scene scene, string homeURL)
{ {
m_scene = scene; m_scene = scene;
m_ProfileServerURI = profileURL; m_HomeURI = homeURL;
} }
#endregion #endregion
@ -150,7 +150,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
UUID.TryParse(meta.CreatorID, out uuid); UUID.TryParse(meta.CreatorID, out uuid);
UserAccount creator = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, uuid); UserAccount creator = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, uuid);
if (creator != null) if (creator != null)
meta.CreatorID = m_ProfileServerURI + "/" + meta.CreatorID + ";" + creator.FirstName + " " + creator.LastName; meta.CreatorID = m_HomeURI + ";" + creator.FirstName + " " + creator.LastName;
} }
} }
@ -193,7 +193,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
if (!hasCreatorData && creator != null) if (!hasCreatorData && creator != null)
{ {
XmlElement creatorData = doc.CreateElement("CreatorData"); XmlElement creatorData = doc.CreateElement("CreatorData");
creatorData.InnerText = m_ProfileServerURI + "/" + creator.PrincipalID + ";" + creator.FirstName + " " + creator.LastName; creatorData.InnerText = m_HomeURI + ";" + creator.FirstName + " " + creator.LastName;
sop.AppendChild(creatorData); sop.AppendChild(creatorData);
} }
} }

View File

@ -54,7 +54,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
get { return m_assMapper; } get { return m_assMapper; }
} }
private string m_ProfileServerURI; private string m_HomeURI;
private bool m_OutboundPermission; private bool m_OutboundPermission;
private string m_ThisGatekeeper; private string m_ThisGatekeeper;
@ -84,7 +84,10 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
IConfig thisModuleConfig = source.Configs["HGInventoryAccessModule"]; IConfig thisModuleConfig = source.Configs["HGInventoryAccessModule"];
if (thisModuleConfig != null) if (thisModuleConfig != null)
{ {
m_ProfileServerURI = thisModuleConfig.GetString("ProfileServerURI", string.Empty); // legacy configuration [obsolete]
m_HomeURI = thisModuleConfig.GetString("ProfileServerURI", string.Empty);
// preferred
m_HomeURI = thisModuleConfig.GetString("HomeURI", m_HomeURI);
m_OutboundPermission = thisModuleConfig.GetBoolean("OutboundPermission", true); m_OutboundPermission = thisModuleConfig.GetBoolean("OutboundPermission", true);
m_ThisGatekeeper = thisModuleConfig.GetString("Gatekeeper", string.Empty); m_ThisGatekeeper = thisModuleConfig.GetString("Gatekeeper", string.Empty);
} }
@ -100,7 +103,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
return; return;
base.AddRegion(scene); base.AddRegion(scene);
m_assMapper = new HGAssetMapper(scene, m_ProfileServerURI); m_assMapper = new HGAssetMapper(scene, m_HomeURI);
scene.EventManager.OnNewInventoryItemUploadComplete += UploadInventoryItem; scene.EventManager.OnNewInventoryItemUploadComplete += UploadInventoryItem;
} }

View File

@ -50,9 +50,6 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
public string LastName { get; set; } public string LastName { get; set; }
public string HomeURL { get; set; } public string HomeURL { get; set; }
public Dictionary<string, object> ServerURLs { get; set; } public Dictionary<string, object> ServerURLs { get; set; }
public string Title { get; set; }
public int Flags { get; set; }
public int Created { get; set; }
} }
public class UserManagementModule : ISharedRegionModule, IUserManagement public class UserManagementModule : ISharedRegionModule, IUserManagement
@ -284,94 +281,6 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
return string.Empty; return string.Empty;
} }
public int GetUserFlags(UUID userID)
{
UserData userdata;
lock (m_UserCache)
m_UserCache.TryGetValue(userID, out userdata);
if (userdata.Flags == -1)
GetUserInfo(userID);
if (userdata.Flags != -1)
return userdata.Flags;
return 0;
}
public int GetUserCreated(UUID userID)
{
UserData userdata;
lock (m_UserCache)
m_UserCache.TryGetValue(userID, out userdata);
if (userdata.Flags == -1)
GetUserInfo(userID);
if (userdata.Created != -1)
return userdata.Created;
return 0;
}
public string GetUserTitle(UUID userID)
{
UserData userdata;
lock (m_UserCache)
m_UserCache.TryGetValue(userID, out userdata);
if (userdata.Flags == -1)
GetUserInfo(userID);
if (userdata.Created != -1)
return userdata.Title;
return string.Empty;
}
// This will cache the user data
// Change this to return bool
private bool GetUserInfo(UUID userID)
{
UserData userdata;
lock (m_UserCache)
m_UserCache.TryGetValue(userID, out userdata);
if (userdata != null)
{
// m_log.DebugFormat("[USER MANAGEMENT MODULE]: Requested url type {0} for {1}", serverType, userID);
if (userdata.Flags >= 0)
{
// This is already populated
return true;
}
if (userdata.HomeURL != null && userdata.HomeURL != string.Empty)
{
m_log.DebugFormat(
"[USER MANAGEMENT MODULE]: Requesting user flags from '{0}' for {1}",
userdata.HomeURL, userID);
UserAgentServiceConnector uConn = new UserAgentServiceConnector(userdata.HomeURL);
Dictionary<string, object> info = uConn.GetUserInfo(userID);
// Pull our data now
if (info["result"].ToString() == "success")
{
userdata.Flags = (int)info["user_flags"];
userdata.Created = (int)info["user_created"];
userdata.Title = (string)info["user_title"];
return true;
}
}
}
return false;
}
public string GetUserUUI(UUID userID) public string GetUserUUI(UUID userID)
{ {
UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount(m_Scenes[0].RegionInfo.ScopeID, userID); UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount(m_Scenes[0].RegionInfo.ScopeID, userID);
@ -413,60 +322,76 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
user.Id = uuid; user.Id = uuid;
user.FirstName = first; user.FirstName = first;
user.LastName = last; user.LastName = last;
// user.ProfileURL = we should initialize this to the default
AddUserInternal(user); AddUserInternal(user);
} }
public void AddUser(UUID uuid, string first, string last, string profileURL) public void AddUser(UUID uuid, string first, string last, string homeURL)
{ {
AddUser(uuid, profileURL + ";" + first + " " + last); AddUser(uuid, homeURL + ";" + first + " " + last);
} }
public void AddUser(UUID id, string creatorData) public void AddUser (UUID id, string creatorData)
{ {
UserData oldUser;
//lock the whole block - prevent concurrent update
lock (m_UserCache) lock (m_UserCache)
{ {
if (m_UserCache.ContainsKey(id)) m_UserCache.TryGetValue (id, out oldUser);
if (oldUser != null)
{
if (creatorData == null || creatorData == String.Empty)
{
//ignore updates without creator data
return; return;
} }
//try update unknown users
// m_log.DebugFormat("[USER MANAGEMENT MODULE]: Adding user with id {0}, craetorData {1}", id, creatorData); //and creator's home URL's
if ((oldUser.FirstName == "Unknown" && !creatorData.Contains ("Unknown")) || (oldUser.HomeURL != null && !creatorData.StartsWith (oldUser.HomeURL)))
UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount(m_Scenes[0].RegionInfo.ScopeID, id);
if (account != null)
{ {
AddUser(id, account.FirstName, account.LastName); m_UserCache.Remove (id);
// m_log.DebugFormat("[USER MANAGEMENT MODULE]: Re-adding user with id {0}, creatorData [{1}] and old HomeURL {2}", id, creatorData,oldUser.HomeURL);
} }
else else
{ {
UserData user = new UserData(); //we have already a valid user within the cache
return;
}
}
// m_log.DebugFormat("[USER MANAGEMENT MODULE]: Adding user with id {0}, creatorData {1}", id, creatorData);
UserAccount account = m_Scenes [0].UserAccountService.GetUserAccount (m_Scenes [0].RegionInfo.ScopeID, id);
if (account != null)
{
AddUser (id, account.FirstName, account.LastName);
}
else
{
UserData user = new UserData ();
user.Id = id; user.Id = id;
user.Flags = -1;
user.Created = -1;
if (creatorData != null && creatorData != string.Empty) if (creatorData != null && creatorData != string.Empty)
{ {
//creatorData = <endpoint>;<name> //creatorData = <endpoint>;<name>
string[] parts = creatorData.Split(';'); string[] parts = creatorData.Split (';');
if (parts.Length >= 1) if (parts.Length >= 1)
{ {
user.HomeURL = parts[0]; user.HomeURL = parts [0];
try try
{ {
Uri uri = new Uri(parts[0]); Uri uri = new Uri (parts [0]);
user.LastName = "@" + uri.Authority; user.LastName = "@" + uri.Authority;
} }
catch (UriFormatException) catch (UriFormatException)
{ {
m_log.DebugFormat("[SCENE]: Unable to parse Uri {0}", parts[0]); m_log.DebugFormat ("[SCENE]: Unable to parse Uri {0}", parts [0]);
user.LastName = "@unknown"; user.LastName = "@unknown";
} }
} }
if (parts.Length >= 2) if (parts.Length >= 2)
user.FirstName = parts[1].Replace(' ', '.'); user.FirstName = parts [1].Replace (' ', '.');
} }
else else
{ {
@ -474,7 +399,8 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
user.LastName = "User"; user.LastName = "User";
} }
AddUserInternal(user); AddUserInternal (user);
}
} }
} }
@ -488,36 +414,6 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
// user.Id, user.FirstName, user.LastName, user.HomeURL); // user.Id, user.FirstName, user.LastName, user.HomeURL);
} }
//public void AddUser(UUID uuid, string userData)
//{
// if (m_UserCache.ContainsKey(uuid))
// return;
// UserData user = new UserData();
// user.Id = uuid;
// // userData = <profile url>;<name>
// string[] parts = userData.Split(';');
// if (parts.Length >= 1)
// user.ProfileURL = parts[0].Trim();
// if (parts.Length >= 2)
// {
// string[] name = parts[1].Trim().Split(' ');
// if (name.Length >= 1)
// user.FirstName = name[0];
// if (name.Length >= 2)
// user.LastName = name[1];
// else
// user.LastName = "?";
// }
// lock (m_UserCache)
// m_UserCache.Add(uuid, user);
// m_log.DebugFormat("[USER MANAGEMENT MODULE]: Added user {0} {1} {2} {3}", user.Id, user.FirstName, user.LastName, user.ProfileURL);
//}
public bool IsLocalGridUser(UUID uuid) public bool IsLocalGridUser(UUID uuid)
{ {
UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount(m_Scenes[0].RegionInfo.ScopeID, uuid); UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount(m_Scenes[0].RegionInfo.ScopeID, uuid);

View File

@ -29,6 +29,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Net; using System.Net;
using System.Net.Mail;
using System.Net.Security; using System.Net.Security;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
@ -110,22 +111,37 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest
X509Certificate certificate, X509Certificate certificate,
X509Chain chain, X509Chain chain,
SslPolicyErrors sslPolicyErrors) SslPolicyErrors sslPolicyErrors)
{
// If this is a web request we need to check the headers first
// We may want to ignore SSL
if (sender is HttpWebRequest)
{ {
HttpWebRequest Request = (HttpWebRequest)sender; HttpWebRequest Request = (HttpWebRequest)sender;
ServicePoint sp = Request.ServicePoint;
// We don't case about encryption, get out of here
if (Request.Headers.Get("NoVerifyCert") != null) if (Request.Headers.Get("NoVerifyCert") != null)
{ {
return true; return true;
} }
// If there was an upstream cert verification error, bail
if ((((int)sslPolicyErrors) & ~4) != 0) if ((((int)sslPolicyErrors) & ~4) != 0)
return false; return false;
// Check for policy and execute it if defined
if (ServicePointManager.CertificatePolicy != null) if (ServicePointManager.CertificatePolicy != null)
{ {
ServicePoint sp = Request.ServicePoint;
return ServicePointManager.CertificatePolicy.CheckValidationResult (sp, certificate, Request, 0); return ServicePointManager.CertificatePolicy.CheckValidationResult (sp, certificate, Request, 0);
} }
return true;
}
// If it's not HTTP, trust .NET to check it
if ((((int)sslPolicyErrors) & ~4) != 0)
return false;
return true; return true;
} }
#region IHttpRequestModule Members #region IHttpRequestModule Members

View File

@ -131,6 +131,12 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
public void RegionLoaded(Scene scene) public void RegionLoaded(Scene scene)
{ {
IScriptModule[] scriptModules = scene.RequestModuleInterfaces<IScriptModule>();
foreach (IScriptModule scriptModule in scriptModules)
{
scriptModule.OnScriptRemoved += ScriptRemoved;
scriptModule.OnObjectRemoved += ObjectRemoved;
}
} }
public void RemoveRegion(Scene scene) public void RemoveRegion(Scene scene)
@ -161,7 +167,6 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
urlData.urlcode = urlcode; urlData.urlcode = urlcode;
urlData.requests = new Dictionary<UUID, RequestData>(); urlData.requests = new Dictionary<UUID, RequestData>();
m_UrlMap[url] = urlData; m_UrlMap[url] = urlData;
string uri = "/lslhttp/" + urlcode.ToString() + "/"; string uri = "/lslhttp/" + urlcode.ToString() + "/";
@ -276,6 +281,8 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
public void ScriptRemoved(UUID itemID) public void ScriptRemoved(UUID itemID)
{ {
// m_log.DebugFormat("[URL MODULE]: Removing script {0}", itemID);
lock (m_UrlMap) lock (m_UrlMap)
{ {
List<string> removeURLs = new List<string>(); List<string> removeURLs = new List<string>();

View File

@ -171,6 +171,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.GridUser
{ {
return m_GridUserService.GetGridUserInfo(userID); return m_GridUserService.GetGridUserInfo(userID);
} }
public GridUserInfo[] GetGridUserInfo(string[] userID)
{
return m_GridUserService.GetGridUserInfo(userID);
}
#endregion #endregion

View File

@ -147,6 +147,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.GridUser
return m_RemoteConnector.GetGridUserInfo(userID); return m_RemoteConnector.GetGridUserInfo(userID);
} }
public GridUserInfo[] GetGridUserInfo(string[] userID)
{
return m_RemoteConnector.GetGridUserInfo(userID);
}
#endregion #endregion
} }

View File

@ -116,6 +116,9 @@ namespace OpenSim.Region.CoreModules.World.Archiver
m_merge = merge; m_merge = merge;
m_skipAssets = skipAssets; m_skipAssets = skipAssets;
m_requestId = requestId; m_requestId = requestId;
// Zero can never be a valid user id
m_validUserUuids[UUID.Zero] = false;
} }
public ArchiveReadRequest(Scene scene, Stream loadStream, bool merge, bool skipAssets, Guid requestId) public ArchiveReadRequest(Scene scene, Stream loadStream, bool merge, bool skipAssets, Guid requestId)
@ -125,6 +128,9 @@ namespace OpenSim.Region.CoreModules.World.Archiver
m_merge = merge; m_merge = merge;
m_skipAssets = skipAssets; m_skipAssets = skipAssets;
m_requestId = requestId; m_requestId = requestId;
// Zero can never be a valid user id
m_validUserUuids[UUID.Zero] = false;
} }
/// <summary> /// <summary>
@ -368,16 +374,10 @@ namespace OpenSim.Region.CoreModules.World.Archiver
if (!m_validUserUuids.ContainsKey(uuid)) if (!m_validUserUuids.ContainsKey(uuid))
{ {
UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, uuid); UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, uuid);
if (account != null) m_validUserUuids.Add(uuid, account != null);
m_validUserUuids.Add(uuid, true);
else
m_validUserUuids.Add(uuid, false);
} }
if (m_validUserUuids[uuid]) return m_validUserUuids[uuid];
return true;
else
return false;
} }
/// <summary> /// <summary>
@ -404,6 +404,12 @@ namespace OpenSim.Region.CoreModules.World.Archiver
string extension = filename.Substring(i); string extension = filename.Substring(i);
string uuid = filename.Remove(filename.Length - extension.Length); string uuid = filename.Remove(filename.Length - extension.Length);
if (m_scene.AssetService.GetMetadata(uuid) != null)
{
// m_log.DebugFormat("[ARCHIVER]: found existing asset {0}",uuid);
return true;
}
if (ArchiveConstants.EXTENSION_TO_ASSET_TYPE.ContainsKey(extension)) if (ArchiveConstants.EXTENSION_TO_ASSET_TYPE.ContainsKey(extension))
{ {
sbyte assetType = ArchiveConstants.EXTENSION_TO_ASSET_TYPE[extension]; sbyte assetType = ArchiveConstants.EXTENSION_TO_ASSET_TYPE[extension];

View File

@ -282,10 +282,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
// always (incorrectly) includes the Copy bit set in this case. But that's a mistake: the viewer // always (incorrectly) includes the Copy bit set in this case. But that's a mistake: the viewer
// does NOT show that the object has Everyone-Copy permissions, and doesn't allow it to be copied. // does NOT show that the object has Everyone-Copy permissions, and doesn't allow it to be copied.
if (permissionClass != PermissionClass.Owner) if (permissionClass != PermissionClass.Owner)
{
canTransfer |= (obj.EveryoneMask & (uint)PermissionMask.Copy) != 0; canTransfer |= (obj.EveryoneMask & (uint)PermissionMask.Copy) != 0;
}
bool partPermitted = true; bool partPermitted = true;
if (checkPermissions.Contains("C") && !canCopy) if (checkPermissions.Contains("C") && !canCopy)

View File

@ -99,6 +99,16 @@ namespace OpenSim.Region.CoreModules.World.Archiver
OptionSet options = new OptionSet().Add("m|merge", delegate (string v) { mergeOar = v != null; }); OptionSet options = new OptionSet().Add("m|merge", delegate (string v) { mergeOar = v != null; });
options.Add("s|skip-assets", delegate (string v) { skipAssets = v != null; }); options.Add("s|skip-assets", delegate (string v) { skipAssets = v != null; });
// Send a message to the region ready module
/* bluewall* Disable this for the time being
IRegionReadyModule rready = m_scene.RequestModuleInterface<IRegionReadyModule>();
if (rready != null)
{
rready.OarLoadingAlert("load");
}
*/
List<string> mainParams = options.Parse(cmdparams); List<string> mainParams = options.Parse(cmdparams);
// m_log.DebugFormat("MERGE OAR IS [{0}]", mergeOar); // m_log.DebugFormat("MERGE OAR IS [{0}]", mergeOar);
@ -125,9 +135,14 @@ namespace OpenSim.Region.CoreModules.World.Archiver
Dictionary<string, object> options = new Dictionary<string, object>(); Dictionary<string, object> options = new Dictionary<string, object>();
OptionSet ops = new OptionSet(); OptionSet ops = new OptionSet();
// ops.Add("v|version=", delegate(string v) { options["version"] = v; });
ops.Add("p|profile=", delegate(string v) { options["profile"] = v; }); // legacy argument [obsolete]
ops.Add("p|profile=", delegate(string v) { Console.WriteLine("\n WARNING: -profile option is obsolete and it will not work. Use -home instead.\n"); });
// preferred
ops.Add("h|home=", delegate(string v) { options["home"] = v; });
ops.Add("noassets", delegate(string v) { options["noassets"] = v != null; }); ops.Add("noassets", delegate(string v) { options["noassets"] = v != null; });
ops.Add("publish", v => options["wipe-owners"] = v != null);
ops.Add("perm=", delegate(string v) { options["checkPermissions"] = v; }); ops.Add("perm=", delegate(string v) { options["checkPermissions"] = v; });
List<string> mainParams = ops.Parse(cmdparams); List<string> mainParams = ops.Parse(cmdparams);

View File

@ -248,9 +248,6 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
Dictionary<string, Object> options = new Dictionary<string, Object>(); Dictionary<string, Object> options = new Dictionary<string, Object>();
options.Add("noassets", true); options.Add("noassets", true);
m_archiverModule.ArchiveRegion(archiveWriteStream, requestId, options); m_archiverModule.ArchiveRegion(archiveWriteStream, requestId, options);
//AssetServerBase assetServer = (AssetServerBase)scene.CommsManager.AssetCache.AssetServer;
//while (assetServer.HasWaitingRequests())
// assetServer.ProcessNextRequest();
// Don't wait for completion - with --noassets save oar happens synchronously // Don't wait for completion - with --noassets save oar happens synchronously
// Monitor.Wait(this, 60000); // Monitor.Wait(this, 60000);
@ -344,7 +341,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
{ {
using (BinaryReader br = new BinaryReader(resource)) using (BinaryReader br = new BinaryReader(resource))
{ {
// FIXME: Use the inspector insteadthere are so many forums and lists already, though admittedly none of them are suitable for cross virtual-enivornemnt discussion // FIXME: Use the inspector instead
soundData = br.ReadBytes(99999999); soundData = br.ReadBytes(99999999);
UUID soundUuid = UUID.Parse("00000000-0000-0000-0000-000000000001"); UUID soundUuid = UUID.Parse("00000000-0000-0000-0000-000000000001");
string soundAssetFileName string soundAssetFileName
@ -409,6 +406,86 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
Console.WriteLine("Successfully completed {0}", MethodBase.GetCurrentMethod()); Console.WriteLine("Successfully completed {0}", MethodBase.GetCurrentMethod());
} }
/// <summary>
/// Test loading an OpenSim Region Archive saved with the --publish option.
/// </summary>
[Test]
public void TestLoadPublishedOar()
{
TestHelpers.InMethod();
// log4net.Config.XmlConfigurator.Configure();
SceneObjectPart part1 = CreateSceneObjectPart1();
SceneObjectGroup sog1 = new SceneObjectGroup(part1);
m_scene.AddNewSceneObject(sog1, false);
SceneObjectPart part2 = CreateSceneObjectPart2();
AssetNotecard nc = new AssetNotecard();
nc.BodyText = "Hello World!";
nc.Encode();
UUID ncAssetUuid = new UUID("00000000-0000-0000-1000-000000000000");
UUID ncItemUuid = new UUID("00000000-0000-0000-1100-000000000000");
AssetBase ncAsset
= AssetHelpers.CreateAsset(ncAssetUuid, AssetType.Notecard, nc.AssetData, UUID.Zero);
m_scene.AssetService.Store(ncAsset);
SceneObjectGroup sog2 = new SceneObjectGroup(part2);
TaskInventoryItem ncItem
= new TaskInventoryItem { Name = "ncItem", AssetID = ncAssetUuid, ItemID = ncItemUuid };
part2.Inventory.AddInventoryItem(ncItem, true);
m_scene.AddNewSceneObject(sog2, false);
MemoryStream archiveWriteStream = new MemoryStream();
m_scene.EventManager.OnOarFileSaved += SaveCompleted;
Guid requestId = new Guid("00000000-0000-0000-0000-808080808080");
lock (this)
{
m_archiverModule.ArchiveRegion(
archiveWriteStream, requestId, new Dictionary<string, Object>() { { "wipe-owners", Boolean.TrueString } });
Monitor.Wait(this, 60000);
}
Assert.That(m_lastRequestId, Is.EqualTo(requestId));
byte[] archive = archiveWriteStream.ToArray();
MemoryStream archiveReadStream = new MemoryStream(archive);
{
UUID estateOwner = TestHelpers.ParseTail(0x4747);
UUID objectOwner = TestHelpers.ParseTail(0x15);
// Reload to new scene
ArchiverModule archiverModule = new ArchiverModule();
SerialiserModule serialiserModule = new SerialiserModule();
TerrainModule terrainModule = new TerrainModule();
TestScene scene2 = SceneHelpers.SetupScene();
SceneHelpers.SetupSceneModules(scene2, archiverModule, serialiserModule, terrainModule);
// Make sure there's a valid owner for the owner we saved (this should have been wiped if the code is
// behaving correctly
UserAccountHelpers.CreateUserWithInventory(scene2, objectOwner);
scene2.RegionInfo.EstateSettings.EstateOwner = estateOwner;
lock (this)
{
scene2.EventManager.OnOarFileLoaded += LoadCompleted;
archiverModule.DearchiveRegion(archiveReadStream);
}
Assert.That(m_lastErrorMessage, Is.Null);
SceneObjectGroup loadedSog = scene2.GetSceneObjectGroup(part1.Name);
Assert.That(loadedSog.OwnerID, Is.EqualTo(estateOwner));
Assert.That(loadedSog.LastOwnerID, Is.EqualTo(estateOwner));
}
}
/// <summary> /// <summary>
/// Test loading the region settings of an OpenSim Region Archive. /// Test loading the region settings of an OpenSim Region Archive.
/// </summary> /// </summary>

View File

@ -53,6 +53,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
protected EstateManagementCommands m_commands; protected EstateManagementCommands m_commands;
private EstateTerrainXferHandler TerrainUploader; private EstateTerrainXferHandler TerrainUploader;
public TelehubManager m_Telehub;
public event ChangeDelegate OnRegionInfoChange; public event ChangeDelegate OnRegionInfoChange;
public event ChangeDelegate OnEstateInfoChange; public event ChangeDelegate OnEstateInfoChange;
@ -599,6 +600,50 @@ namespace OpenSim.Region.CoreModules.World.Estate
} }
} }
public void handleOnEstateManageTelehub (IClientAPI client, UUID invoice, UUID senderID, string cmd, uint param1)
{
uint ObjectLocalID;
SceneObjectPart part;
switch (cmd)
{
case "info ui":
break;
case "connect":
// Add the Telehub
part = Scene.GetSceneObjectPart((uint)param1);
if (part == null)
return;
SceneObjectGroup grp = part.ParentGroup;
m_Telehub.Connect(grp);
break;
case "delete":
// Disconnect Telehub
m_Telehub.Disconnect();
break;
case "spawnpoint add":
// Add SpawnPoint to the Telehub
part = Scene.GetSceneObjectPart((uint)param1);
if (part == null)
return;
m_Telehub.AddSpawnPoint(part.AbsolutePosition);
break;
case "spawnpoint remove":
// Remove SpawnPoint from Telehub
m_Telehub.RemoveSpawnPoint((int)param1);
break;
default:
break;
}
SendTelehubInfo(client);
}
private void SendSimulatorBlueBoxMessage( private void SendSimulatorBlueBoxMessage(
IClientAPI remote_client, UUID invoice, UUID senderID, UUID sessionID, string senderName, string message) IClientAPI remote_client, UUID invoice, UUID senderID, UUID sessionID, string senderName, string message)
{ {
@ -1056,6 +1101,8 @@ namespace OpenSim.Region.CoreModules.World.Estate
Scene.EventManager.OnNewClient += EventManager_OnNewClient; Scene.EventManager.OnNewClient += EventManager_OnNewClient;
Scene.EventManager.OnRequestChangeWaterHeight += changeWaterHeight; Scene.EventManager.OnRequestChangeWaterHeight += changeWaterHeight;
m_Telehub = new TelehubManager(scene);
m_commands = new EstateManagementCommands(this); m_commands = new EstateManagementCommands(this);
m_commands.Initialise(); m_commands.Initialise();
} }
@ -1109,6 +1156,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
client.OnEstateRestartSimRequest += handleEstateRestartSimRequest; client.OnEstateRestartSimRequest += handleEstateRestartSimRequest;
client.OnEstateChangeCovenantRequest += handleChangeEstateCovenantRequest; client.OnEstateChangeCovenantRequest += handleChangeEstateCovenantRequest;
client.OnEstateChangeInfo += handleEstateChangeInfo; client.OnEstateChangeInfo += handleEstateChangeInfo;
client.OnEstateManageTelehub += handleOnEstateManageTelehub;
client.OnUpdateEstateAccessDeltaRequest += handleEstateAccessDeltaRequest; client.OnUpdateEstateAccessDeltaRequest += handleEstateAccessDeltaRequest;
client.OnSimulatorBlueBoxMessageRequest += SendSimulatorBlueBoxMessage; client.OnSimulatorBlueBoxMessageRequest += SendSimulatorBlueBoxMessage;
client.OnEstateBlueBoxMessageRequest += SendEstateBlueBoxMessage; client.OnEstateBlueBoxMessageRequest += SendEstateBlueBoxMessage;
@ -1243,5 +1291,39 @@ namespace OpenSim.Region.CoreModules.World.Estate
if (onmessage != null) if (onmessage != null)
onmessage(Scene.RegionInfo.RegionID, fromID, fromName, message); onmessage(Scene.RegionInfo.RegionID, fromID, fromName, message);
} }
private void SendTelehubInfo(IClientAPI client)
{
RegionSettings settings =
this.Scene.RegionInfo.RegionSettings;
SceneObjectGroup telehub = null;
if (settings.TelehubObject != UUID.Zero &&
(telehub = Scene.GetSceneObjectGroup(settings.TelehubObject)) != null)
{
List<Vector3> spawnPoints = new List<Vector3>();
foreach (SpawnPoint sp in settings.SpawnPoints())
{
spawnPoints.Add(sp.GetLocation(Vector3.Zero, Quaternion.Identity));
}
client.SendTelehubInfo(settings.TelehubObject,
telehub.Name,
telehub.AbsolutePosition,
telehub.GroupRotation,
spawnPoints);
}
else
{
client.SendTelehubInfo(UUID.Zero,
String.Empty,
Vector3.Zero,
Quaternion.Identity,
new List<Vector3>());
}
}
} }
} }

View File

@ -0,0 +1,95 @@
/*
* 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.Reflection;
using OpenMetaverse;
using System.Collections.Generic;
using OpenSim.Framework;
using OpenSim.Region.Framework.Scenes;
using log4net;
namespace OpenSim.Region.CoreModules.World.Estate
{
public class TelehubManager
{
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
Scene m_Scene;
public TelehubManager(Scene scene)
{
m_Scene = scene;
}
// Connect the Telehub
public void Connect(SceneObjectGroup grp)
{
m_Scene.RegionInfo.RegionSettings.ClearSpawnPoints();
m_Scene.RegionInfo.RegionSettings.TelehubObject = grp.UUID;
m_Scene.RegionInfo.RegionSettings.Save();
}
// Disconnect the Telehub:
public void Disconnect()
{
if (m_Scene.RegionInfo.RegionSettings.TelehubObject == UUID.Zero)
return;
m_Scene.RegionInfo.RegionSettings.TelehubObject = UUID.Zero;
m_Scene.RegionInfo.RegionSettings.ClearSpawnPoints();
m_Scene.RegionInfo.RegionSettings.Save();
}
// Add a SpawnPoint to the Telehub
public void AddSpawnPoint(Vector3 point)
{
if (m_Scene.RegionInfo.RegionSettings.TelehubObject == UUID.Zero)
return;
SceneObjectGroup grp = m_Scene.GetSceneObjectGroup(m_Scene.RegionInfo.RegionSettings.TelehubObject);
if (grp == null)
return;
SpawnPoint sp = new SpawnPoint();
sp.SetLocation(grp.AbsolutePosition, grp.GroupRotation, point);
m_Scene.RegionInfo.RegionSettings.AddSpawnPoint(sp);
m_Scene.RegionInfo.RegionSettings.Save();
}
// Remove a SpawnPoint from the Telehub
public void RemoveSpawnPoint(int spawnpoint)
{
if (m_Scene.RegionInfo.RegionSettings.TelehubObject == UUID.Zero)
return;
m_Scene.RegionInfo.RegionSettings.RemoveSpawnPoint(spawnpoint);
m_Scene.RegionInfo.RegionSettings.Save();
}
}
}

View File

@ -1095,6 +1095,15 @@ namespace OpenSim.Region.CoreModules.World.Land
SendLandUpdateToAvatarsOverMe(); SendLandUpdateToAvatarsOverMe();
} }
/// <summary>
/// Get the music url for this land parcel
/// </summary>
/// <returns>The music url.</returns>
public string GetMusicUrl()
{
return LandData.MusicURL;
}
#endregion #endregion
} }
} }

View File

@ -0,0 +1,410 @@
/*
* 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.Reflection;
using System.Text;
using log4net;
using Mono.Addins;
using Nini.Config;
using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Framework.Console;
using OpenSim.Framework.Statistics;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
namespace OpenSim.Region.CoreModules.World.Objects.Commands
{
/// <summary>
/// A module that holds commands for manipulating objects in the scene.
/// </summary>
[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "ObjectCommandsModule")]
public class ObjectCommandsModule : INonSharedRegionModule
{
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private Scene m_scene;
private ICommandConsole m_console;
public string Name { get { return "Object Commands Module"; } }
public Type ReplaceableInterface { get { return null; } }
public void Initialise(IConfigSource source)
{
// m_log.DebugFormat("[OBJECT COMMANDS MODULE]: INITIALIZED MODULE");
}
public void PostInitialise()
{
// m_log.DebugFormat("[OBJECT COMMANDS MODULE]: POST INITIALIZED MODULE");
}
public void Close()
{
// m_log.DebugFormat("[OBJECT COMMANDS MODULE]: CLOSED MODULE");
}
public void AddRegion(Scene scene)
{
// m_log.DebugFormat("[OBJECT COMMANDS MODULE]: REGION {0} ADDED", scene.RegionInfo.RegionName);
m_scene = scene;
m_console = MainConsole.Instance;
m_console.Commands.AddCommand("region", false, "delete object owner",
"delete object owner <UUID>",
"Delete a scene object by owner", HandleDeleteObject);
m_console.Commands.AddCommand("region", false, "delete object creator",
"delete object creator <UUID>",
"Delete a scene object by creator", HandleDeleteObject);
m_console.Commands.AddCommand("region", false, "delete object uuid",
"delete object uuid <UUID>",
"Delete a scene object by uuid", HandleDeleteObject);
m_console.Commands.AddCommand("region", false, "delete object name",
"delete object name <name>",
"Delete a scene object by name", HandleDeleteObject);
m_console.Commands.AddCommand("region", false, "delete object outside",
"delete object outside",
"Delete all scene objects outside region boundaries", HandleDeleteObject);
m_console.Commands.AddCommand(
"region",
false,
"show object uuid",
"show object uuid <UUID>",
"Show details of a scene object with the given UUID", HandleShowObjectByUuid);
m_console.Commands.AddCommand(
"region",
false,
"show object name",
"show object name <name>",
"Show details of scene objects with the given name", HandleShowObjectByName);
m_console.Commands.AddCommand(
"region",
false,
"show part uuid",
"show part uuid <UUID>",
"Show details of a scene object parts with the given UUID", HandleShowPartByUuid);
m_console.Commands.AddCommand(
"region",
false,
"show part name",
"show part name <name>",
"Show details of scene object parts with the given name", HandleShowPartByName);
}
public void RemoveRegion(Scene scene)
{
// m_log.DebugFormat("[OBJECTS COMMANDS MODULE]: REGION {0} REMOVED", scene.RegionInfo.RegionName);
}
public void RegionLoaded(Scene scene)
{
// m_log.DebugFormat("[OBJECTS COMMANDS MODULE]: REGION {0} LOADED", scene.RegionInfo.RegionName);
}
private void HandleShowObjectByUuid(string module, string[] cmd)
{
if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene))
return;
if (cmd.Length < 4)
{
m_console.OutputFormat("Usage: show object uuid <uuid>");
return;
}
UUID objectUuid;
if (!UUID.TryParse(cmd[3], out objectUuid))
{
m_console.OutputFormat("{0} is not a valid uuid", cmd[3]);
return;
}
SceneObjectGroup so = m_scene.GetSceneObjectGroup(objectUuid);
if (so == null)
{
// m_console.OutputFormat("No part found with uuid {0}", objectUuid);
return;
}
StringBuilder sb = new StringBuilder();
AddSceneObjectReport(sb, so);
m_console.OutputFormat(sb.ToString());
}
private void HandleShowObjectByName(string module, string[] cmd)
{
if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene))
return;
if (cmd.Length < 4)
{
m_console.OutputFormat("Usage: show object name <name>");
return;
}
string name = cmd[3];
List<SceneObjectGroup> sceneObjects = new List<SceneObjectGroup>();
m_scene.ForEachSOG(so => { if (so.Name == name) { sceneObjects.Add(so); }});
if (sceneObjects.Count == 0)
{
m_console.OutputFormat("No objects with name {0} found in {1}", name, m_scene.RegionInfo.RegionName);
return;
}
StringBuilder sb = new StringBuilder();
foreach (SceneObjectGroup so in sceneObjects)
{
AddSceneObjectReport(sb, so);
sb.Append("\n");
}
m_console.OutputFormat(sb.ToString());
}
private void HandleShowPartByUuid(string module, string[] cmd)
{
if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene))
return;
if (cmd.Length < 4)
{
m_console.OutputFormat("Usage: show part uuid <uuid>");
return;
}
UUID objectUuid;
if (!UUID.TryParse(cmd[3], out objectUuid))
{
m_console.OutputFormat("{0} is not a valid uuid", cmd[3]);
return;
}
SceneObjectPart sop = m_scene.GetSceneObjectPart(objectUuid);
if (sop == null)
{
// m_console.OutputFormat("No part found with uuid {0}", objectUuid);
return;
}
StringBuilder sb = new StringBuilder();
AddScenePartReport(sb, sop);
m_console.OutputFormat(sb.ToString());
}
private void HandleShowPartByName(string module, string[] cmd)
{
if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene))
return;
if (cmd.Length < 4)
{
m_console.OutputFormat("Usage: show part name <name>");
return;
}
string name = cmd[3];
List<SceneObjectPart> parts = new List<SceneObjectPart>();
m_scene.ForEachSOG(so => so.ForEachPart(sop => { if (sop.Name == name) { parts.Add(sop); } }));
if (parts.Count == 0)
{
m_console.OutputFormat("No parts with name {0} found in {1}", name, m_scene.RegionInfo.RegionName);
return;
}
StringBuilder sb = new StringBuilder();
foreach (SceneObjectPart part in parts)
{
AddScenePartReport(sb, part);
sb.Append("\n");
}
m_console.OutputFormat(sb.ToString());
}
private StringBuilder AddSceneObjectReport(StringBuilder sb, SceneObjectGroup so)
{
sb.AppendFormat("Name: {0}\n", so.Name);
sb.AppendFormat("Description: {0}\n", so.Description);
sb.AppendFormat("Location: {0} @ {1}\n", so.AbsolutePosition, so.Scene.RegionInfo.RegionName);
sb.AppendFormat("Parts: {0}\n", so.PrimCount);
return sb;
}
private StringBuilder AddScenePartReport(StringBuilder sb, SceneObjectPart sop)
{
sb.AppendFormat("Name: {0}\n", sop.Name);
sb.AppendFormat("Description: {0}\n", sop.Description);
sb.AppendFormat("Location: {0} @ {1}\n", sop.AbsolutePosition, sop.ParentGroup.Scene.RegionInfo.RegionName);
sb.AppendFormat("Parent: {0}",
sop.IsRoot ? "Is Root\n" : string.Format("{0} {1}\n", sop.ParentGroup.Name, sop.ParentGroup.UUID));
sb.AppendFormat("Parts: {0}\n", !sop.IsRoot ? "1" : sop.ParentGroup.PrimCount.ToString());;
return sb;
}
private void HandleDeleteObject(string module, string[] cmd)
{
if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene))
return;
if (cmd.Length < 3)
return;
string mode = cmd[2];
string o = "";
if (mode != "outside")
{
if (cmd.Length < 4)
return;
o = cmd[3];
}
List<SceneObjectGroup> deletes = new List<SceneObjectGroup>();
UUID match;
switch (mode)
{
case "owner":
if (!UUID.TryParse(o, out match))
return;
m_scene.ForEachSOG(delegate (SceneObjectGroup g)
{
if (g.OwnerID == match && !g.IsAttachment)
deletes.Add(g);
});
// if (deletes.Count == 0)
// m_console.OutputFormat("No objects were found with owner {0}", match);
break;
case "creator":
if (!UUID.TryParse(o, out match))
return;
m_scene.ForEachSOG(delegate (SceneObjectGroup g)
{
if (g.RootPart.CreatorID == match && !g.IsAttachment)
deletes.Add(g);
});
// if (deletes.Count == 0)
// m_console.OutputFormat("No objects were found with creator {0}", match);
break;
case "uuid":
if (!UUID.TryParse(o, out match))
return;
m_scene.ForEachSOG(delegate (SceneObjectGroup g)
{
if (g.UUID == match && !g.IsAttachment)
deletes.Add(g);
});
// if (deletes.Count == 0)
// m_console.OutputFormat("No objects were found with uuid {0}", match);
break;
case "name":
m_scene.ForEachSOG(delegate (SceneObjectGroup g)
{
if (g.RootPart.Name == o && !g.IsAttachment)
deletes.Add(g);
});
// if (deletes.Count == 0)
// m_console.OutputFormat("No objects were found with name {0}", o);
break;
case "outside":
m_scene.ForEachSOG(delegate (SceneObjectGroup g)
{
SceneObjectPart rootPart = g.RootPart;
bool delete = false;
if (rootPart.GroupPosition.Z < 0.0 || rootPart.GroupPosition.Z > 10000.0)
{
delete = true;
}
else
{
ILandObject parcel
= m_scene.LandChannel.GetLandObject(rootPart.GroupPosition.X, rootPart.GroupPosition.Y);
if (parcel == null || parcel.LandData.Name == "NO LAND")
delete = true;
}
if (delete && !g.IsAttachment && !deletes.Contains(g))
deletes.Add(g);
});
// if (deletes.Count == 0)
// m_console.OutputFormat("No objects were found outside region bounds");
break;
}
m_console.OutputFormat("Deleting {0} objects in {1}", deletes.Count, m_scene.RegionInfo.RegionName);
foreach (SceneObjectGroup g in deletes)
{
m_console.OutputFormat("Deleting object {0} {1}", g.UUID, g.Name);
m_scene.DeleteSceneObject(g, false);
}
}
}
}

View File

@ -213,7 +213,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
UUID agentID, Caps caps) UUID agentID, Caps caps)
{ {
//try //try
//{ //
//m_log.DebugFormat("[MAPLAYER]: path: {0}, param: {1}, agent:{2}", //m_log.DebugFormat("[MAPLAYER]: path: {0}, param: {1}, agent:{2}",
// path, param, agentID.ToString()); // path, param, agentID.ToString());
@ -263,7 +263,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
foreach (GridRegion r in regions) foreach (GridRegion r in regions)
{ {
MapBlockData block = new MapBlockData(); MapBlockData block = new MapBlockData();
MapBlockFromGridRegion(block, r); MapBlockFromGridRegion(block, r, 0);
mapBlocks.Add(block); mapBlocks.Add(block);
} }
avatarPresence.ControllingClient.SendMapBlock(mapBlocks, 0); avatarPresence.ControllingClient.SendMapBlock(mapBlocks, 0);
@ -373,7 +373,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
public virtual void HandleMapItemRequest(IClientAPI remoteClient, uint flags, public virtual void HandleMapItemRequest(IClientAPI remoteClient, uint flags,
uint EstateID, bool godlike, uint itemtype, ulong regionhandle) uint EstateID, bool godlike, uint itemtype, ulong regionhandle)
{ {
// m_log.DebugFormat("[WORLD MAP]: Handle MapItem request {0} {1}", regionhandle, itemtype); m_log.DebugFormat("[WORLD MAP]: Handle MapItem request {0} {1}", regionhandle, itemtype);
lock (m_rootAgents) lock (m_rootAgents)
{ {
@ -429,7 +429,8 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
// ensures that the blockingqueue doesn't get borked if the GetAgents() timing changes. // ensures that the blockingqueue doesn't get borked if the GetAgents() timing changes.
RequestMapItems("",remoteClient.AgentId,flags,EstateID,godlike,itemtype,regionhandle); RequestMapItems("",remoteClient.AgentId,flags,EstateID,godlike,itemtype,regionhandle);
} }
} else if (itemtype == 7) // Service 7 (MAP_ITEM_LAND_FOR_SALE) }
else if (itemtype == 7) // Service 7 (MAP_ITEM_LAND_FOR_SALE)
{ {
if (regionhandle == 0 || regionhandle == m_scene.RegionInfo.RegionHandle) if (regionhandle == 0 || regionhandle == m_scene.RegionInfo.RegionHandle)
{ {
@ -463,7 +464,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
mapitem.x = (uint)(xstart + x); mapitem.x = (uint)(xstart + x);
mapitem.y = (uint)(ystart + y); mapitem.y = (uint)(ystart + y);
// mapitem.z = (uint)m_scene.GetGroundHeight(x,y); // mapitem.z = (uint)m_scene.GetGroundHeight(x,y);
mapitem.id = UUID.Zero; mapitem.id = parcel.GlobalID;
mapitem.name = parcel.Name; mapitem.name = parcel.Name;
mapitem.Extra = parcel.Area; mapitem.Extra = parcel.Area;
mapitem.Extra2 = parcel.SalePrice; mapitem.Extra2 = parcel.SalePrice;
@ -481,6 +482,34 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
RequestMapItems("",remoteClient.AgentId,flags,EstateID,godlike,itemtype,regionhandle); RequestMapItems("",remoteClient.AgentId,flags,EstateID,godlike,itemtype,regionhandle);
} }
} }
else if (itemtype == 1) // Service 1 (MAP_ITEM_TELEHUB)
{
if (regionhandle == 0 || regionhandle == m_scene.RegionInfo.RegionHandle)
{
List<mapItemReply> mapitems = new List<mapItemReply>();
mapItemReply mapitem = new mapItemReply();
SceneObjectGroup sog = m_scene.GetSceneObjectGroup(m_scene.RegionInfo.RegionSettings.TelehubObject);
if (sog != null)
{
mapitem = new mapItemReply();
mapitem.x = (uint)(xstart + sog.AbsolutePosition.X);
mapitem.y = (uint)(ystart + sog.AbsolutePosition.Y);
mapitem.id = UUID.Zero;
mapitem.name = sog.Name;
mapitem.Extra = 0; // color (not used)
mapitem.Extra2 = 0; // 0 = telehub / 1 = infohub
mapitems.Add(mapitem);
remoteClient.SendMapItemReply(mapitems.ToArray(), itemtype, flags);
}
}
else
{
// Remote Map Item Request
RequestMapItems("",remoteClient.AgentId,flags,EstateID,godlike,itemtype,regionhandle);
}
}
} }
private int nAsyncRequests = 0; private int nAsyncRequests = 0;
@ -620,6 +649,28 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
} }
av.ControllingClient.SendMapItemReply(returnitems.ToArray(), itemtype, mrs.flags); av.ControllingClient.SendMapItemReply(returnitems.ToArray(), itemtype, mrs.flags);
} }
// Service 1 (MAP_ITEM_TELEHUB)
itemtype = 1;
if (response.ContainsKey(itemtype.ToString()))
{
List<mapItemReply> returnitems = new List<mapItemReply>();
OSDArray itemarray = (OSDArray)response[itemtype.ToString()];
for (int i = 0; i < itemarray.Count; i++)
{
OSDMap mapitem = (OSDMap)itemarray[i];
mapItemReply mi = new mapItemReply();
mi.x = (uint)mapitem["X"].AsInteger();
mi.y = (uint)mapitem["Y"].AsInteger();
mi.id = mapitem["ID"].AsUUID();
mi.Extra = mapitem["Extra"].AsInteger();
mi.Extra2 = mapitem["Extra2"].AsInteger();
mi.name = mapitem["Name"].AsString();
returnitems.Add(mi);
}
av.ControllingClient.SendMapItemReply(returnitems.ToArray(), itemtype, mrs.flags);
}
} }
} }
} }
@ -904,8 +955,8 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
{ {
List<MapBlockData> response = new List<MapBlockData>(); List<MapBlockData> response = new List<MapBlockData>();
// this should return one mapblock at most. // this should return one mapblock at most. It is triggered by a click
// (diva note: why?? in that case we should GetRegionByPosition) // on an unloaded square.
// But make sure: Look whether the one we requested is in there // But make sure: Look whether the one we requested is in there
List<GridRegion> regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID, List<GridRegion> regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID,
minX * (int)Constants.RegionSize, minX * (int)Constants.RegionSize,
@ -922,7 +973,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
{ {
// found it => add it to response // found it => add it to response
MapBlockData block = new MapBlockData(); MapBlockData block = new MapBlockData();
MapBlockFromGridRegion(block, r); MapBlockFromGridRegion(block, r, flag);
response.Add(block); response.Add(block);
break; break;
} }
@ -938,10 +989,8 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
block.Access = 254; // means 'simulator is offline' block.Access = 254; // means 'simulator is offline'
response.Add(block); response.Add(block);
} }
if ((flag & 2) == 2) // V2 !!! // The lower 16 bits are an unsigned int16
remoteClient.SendMapBlock(response, 2); remoteClient.SendMapBlock(response, flag & 0xffff);
else
remoteClient.SendMapBlock(response, 0);
} }
else else
{ {
@ -961,21 +1010,29 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
foreach (GridRegion r in regions) foreach (GridRegion r in regions)
{ {
MapBlockData block = new MapBlockData(); MapBlockData block = new MapBlockData();
MapBlockFromGridRegion(block, r); MapBlockFromGridRegion(block, r, flag);
mapBlocks.Add(block); mapBlocks.Add(block);
} }
if ((flag & 2) == 2) // V2 !!! remoteClient.SendMapBlock(mapBlocks, flag & 0xffff);
remoteClient.SendMapBlock(mapBlocks, 2);
else
remoteClient.SendMapBlock(mapBlocks, 0);
return mapBlocks; return mapBlocks;
} }
protected void MapBlockFromGridRegion(MapBlockData block, GridRegion r) protected void MapBlockFromGridRegion(MapBlockData block, GridRegion r, uint flag)
{ {
block.Access = r.Access; block.Access = r.Access;
switch (flag & 0xffff)
{
case 0:
block.MapImageId = r.TerrainImage; block.MapImageId = r.TerrainImage;
break;
case 2:
block.MapImageId = r.ParcelImage;
break;
default:
block.MapImageId = UUID.Zero;
break;
}
block.Name = r.RegionName; block.Name = r.RegionName;
block.X = (ushort)(r.RegionLocX / Constants.RegionSize); block.X = (ushort)(r.RegionLocX / Constants.RegionSize);
block.Y = (ushort)(r.RegionLocY / Constants.RegionSize); block.Y = (ushort)(r.RegionLocY / Constants.RegionSize);
@ -1109,7 +1166,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
foreach (GridRegion r in regions) foreach (GridRegion r in regions)
{ {
MapBlockData mapBlock = new MapBlockData(); MapBlockData mapBlock = new MapBlockData();
MapBlockFromGridRegion(mapBlock, r); MapBlockFromGridRegion(mapBlock, r, 0);
AssetBase texAsset = m_scene.AssetService.Get(mapBlock.MapImageId.ToString()); AssetBase texAsset = m_scene.AssetService.Get(mapBlock.MapImageId.ToString());
if (texAsset != null) if (texAsset != null)
@ -1240,7 +1297,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
responsemapdata["X"] = OSD.FromInteger((int)(xstart + x)); responsemapdata["X"] = OSD.FromInteger((int)(xstart + x));
responsemapdata["Y"] = OSD.FromInteger((int)(ystart + y)); responsemapdata["Y"] = OSD.FromInteger((int)(ystart + y));
// responsemapdata["Z"] = OSD.FromInteger((int)m_scene.GetGroundHeight(x,y)); // responsemapdata["Z"] = OSD.FromInteger((int)m_scene.GetGroundHeight(x,y));
responsemapdata["ID"] = OSD.FromUUID(UUID.Zero); responsemapdata["ID"] = OSD.FromUUID(parcel.GlobalID);
responsemapdata["Name"] = OSD.FromString(parcel.Name); responsemapdata["Name"] = OSD.FromString(parcel.Name);
responsemapdata["Extra"] = OSD.FromInteger(parcel.Area); responsemapdata["Extra"] = OSD.FromInteger(parcel.Area);
responsemapdata["Extra2"] = OSD.FromInteger(parcel.SalePrice); responsemapdata["Extra2"] = OSD.FromInteger(parcel.SalePrice);
@ -1250,6 +1307,26 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
responsemap["7"] = responsearr; responsemap["7"] = responsearr;
} }
if (m_scene.RegionInfo.RegionSettings.TelehubObject != UUID.Zero)
{
SceneObjectGroup sog = m_scene.GetSceneObjectGroup(m_scene.RegionInfo.RegionSettings.TelehubObject);
if (sog != null)
{
OSDArray responsearr = new OSDArray();
OSDMap responsemapdata = new OSDMap();
responsemapdata["X"] = OSD.FromInteger((int)(xstart + sog.AbsolutePosition.X));
responsemapdata["Y"] = OSD.FromInteger((int)(ystart + sog.AbsolutePosition.Y));
// responsemapdata["Z"] = OSD.FromInteger((int)m_scene.GetGroundHeight(x,y));
responsemapdata["ID"] = OSD.FromUUID(sog.UUID);
responsemapdata["Name"] = OSD.FromString(sog.Name);
responsemapdata["Extra"] = OSD.FromInteger(0); // color (unused)
responsemapdata["Extra2"] = OSD.FromInteger(0); // 0 = telehub / 1 = infohub
responsearr.Add(responsemapdata);
responsemap["1"] = responsearr;
}
}
return responsemap; return responsemap;
} }
@ -1268,9 +1345,12 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
if (data == null) if (data == null)
return; return;
byte[] overlay = GenerateOverlay();
m_log.Debug("[WORLDMAP]: STORING MAPTILE IMAGE"); m_log.Debug("[WORLDMAP]: STORING MAPTILE IMAGE");
UUID terrainImageID = UUID.Random(); UUID terrainImageID = UUID.Random();
UUID parcelImageID = UUID.Zero;
AssetBase asset = new AssetBase( AssetBase asset = new AssetBase(
terrainImageID, terrainImageID,
@ -1286,14 +1366,35 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
m_log.DebugFormat("[WORLDMAP]: Storing map tile {0}", asset.ID); m_log.DebugFormat("[WORLDMAP]: Storing map tile {0}", asset.ID);
m_scene.AssetService.Store(asset); m_scene.AssetService.Store(asset);
if (overlay != null)
{
parcelImageID = UUID.Random();
AssetBase parcels = new AssetBase(
parcelImageID,
"parcelImage_" + m_scene.RegionInfo.RegionID.ToString(),
(sbyte)AssetType.Texture,
m_scene.RegionInfo.RegionID.ToString());
parcels.Data = overlay;
parcels.Description = m_scene.RegionInfo.RegionName;
parcels.Temporary = false;
parcels.Flags = AssetFlags.Maptile;
m_scene.AssetService.Store(parcels);
}
// Switch to the new one // Switch to the new one
UUID lastMapRegionUUID = m_scene.RegionInfo.RegionSettings.TerrainImageID; UUID lastTerrainImageID = m_scene.RegionInfo.RegionSettings.TerrainImageID;
UUID lastParcelImageID = m_scene.RegionInfo.RegionSettings.ParcelImageID;
m_scene.RegionInfo.RegionSettings.TerrainImageID = terrainImageID; m_scene.RegionInfo.RegionSettings.TerrainImageID = terrainImageID;
m_scene.RegionInfo.RegionSettings.ParcelImageID = parcelImageID;
m_scene.RegionInfo.RegionSettings.Save(); m_scene.RegionInfo.RegionSettings.Save();
// Delete the old one // Delete the old one
m_log.DebugFormat("[WORLDMAP]: Deleting old map tile {0}", lastMapRegionUUID); // m_log.DebugFormat("[WORLDMAP]: Deleting old map tile {0}", lastTerrainImageID);
m_scene.AssetService.Delete(lastMapRegionUUID.ToString()); m_scene.AssetService.Delete(lastTerrainImageID.ToString());
if (lastParcelImageID != UUID.Zero)
m_scene.AssetService.Delete(lastParcelImageID.ToString());
} }
private void MakeRootAgent(ScenePresence avatar) private void MakeRootAgent(ScenePresence avatar)
@ -1339,6 +1440,66 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
} }
} }
private Byte[] GenerateOverlay()
{
Bitmap overlay = new Bitmap(256, 256);
bool[,] saleBitmap = new bool[64, 64];
for (int x = 0 ; x < 64 ; x++)
{
for (int y = 0 ; y < 64 ; y++)
saleBitmap[x, y] = false;
}
bool landForSale = false;
List<ILandObject> parcels = m_scene.LandChannel.AllParcels();
Color background = Color.FromArgb(0, 0, 0, 0);
SolidBrush transparent = new SolidBrush(background);
Graphics g = Graphics.FromImage(overlay);
g.FillRectangle(transparent, 0, 0, 256, 256);
SolidBrush yellow = new SolidBrush(Color.FromArgb(255, 249, 223, 9));
foreach (ILandObject land in parcels)
{
// m_log.DebugFormat("[WORLD MAP]: Parcel {0} flags {1}", land.LandData.Name, land.LandData.Flags);
if ((land.LandData.Flags & (uint)ParcelFlags.ForSale) != 0)
{
landForSale = true;
saleBitmap = land.MergeLandBitmaps(saleBitmap, land.GetLandBitmap());
}
}
if (!landForSale)
{
m_log.DebugFormat("[WORLD MAP]: Region {0} has no parcels for sale, not geenrating overlay", m_scene.RegionInfo.RegionName);
return null;
}
m_log.DebugFormat("[WORLD MAP]: Region {0} has parcels for sale, genrating overlay", m_scene.RegionInfo.RegionName);
for (int x = 0 ; x < 64 ; x++)
{
for (int y = 0 ; y < 64 ; y++)
{
if (saleBitmap[x, y])
g.FillRectangle(yellow, x * 4, 252 - (y * 4), 4, 4);
}
}
try
{
return OpenJPEG.EncodeFromImage(overlay, true);
}
catch (Exception e)
{
m_log.DebugFormat("[WORLD MAP]: Error creating parcel overlay: " + e.ToString());
}
return null;
}
} }
public struct MapRequestState public struct MapRequestState

View File

@ -67,7 +67,7 @@ namespace OpenSim.Region.DataSnapshot
public void OnRegisterCaps(UUID agentID, Caps caps) public void OnRegisterCaps(UUID agentID, Caps caps)
{ {
m_log.Info("[DATASNAPSHOT]: Registering service discovery capability for " + agentID); // m_log.InfoFormat("[DATASNAPSHOT]: Registering service discovery capability for {0}", agentID);
string capsBase = "/CAPS/" + caps.CapsObjectPath; string capsBase = "/CAPS/" + caps.CapsObjectPath;
caps.RegisterHandler("PublicSnapshotDataInfo", caps.RegisterHandler("PublicSnapshotDataInfo",
new RestStreamHandler("POST", capsBase + m_discoveryPath, OnDiscoveryAttempt)); new RestStreamHandler("POST", capsBase + m_discoveryPath, OnDiscoveryAttempt));

View File

@ -46,7 +46,7 @@ namespace OpenSim.Region.Framework.Interfaces
/// Save the attachments that have change on this presence. /// Save the attachments that have change on this presence.
/// </summary> /// </summary>
/// <param name="sp"></param> /// <param name="sp"></param>
void SaveChangedAttachments(IScenePresence sp); void SaveChangedAttachments(IScenePresence sp, bool saveAllScripted);
/// <summary> /// <summary>
/// Delete all the presence's attachments from the scene /// Delete all the presence's attachments from the scene

View File

@ -61,7 +61,32 @@ namespace OpenSim.Region.Framework.Interfaces
/// <returns>true if a valid agent was found, false otherwise</returns> /// <returns>true if a valid agent was found, false otherwise</returns>
bool SaveBakedTextures(UUID agentId); bool SaveBakedTextures(UUID agentId);
/// <summary>
/// Validate that OpenSim can find the baked textures need to display a given avatar
/// </summary>
/// <param name="client"></param>
/// <param name="checkonly"></param>
/// <returns>
/// true if all the baked textures referenced by the texture IDs exist or the appearance is only using default textures. false otherwise.
/// </returns>
bool ValidateBakedTextureCache(IScenePresence sp); bool ValidateBakedTextureCache(IScenePresence sp);
/// <summary>
/// Request a rebake of textures for an avatar.
/// </summary>
/// <remarks>
/// This will send the request to the viewer, since it's there that the rebake is done.
/// </remarks>
/// <param name="sp">Avatar to rebake.</param>
/// <param name="missingTexturesOnly">
/// If true, only request a rebake for the textures that are missing.
/// If false then we request a rebake of all textures for which we already have references.
/// </param>
/// <returns>
/// Number of rebake requests made. This will depend upon whether we've previously received texture IDs.
/// </returns>
int RequestRebake(IScenePresence sp, bool missingTexturesOnly);
void QueueAppearanceSend(UUID agentid); void QueueAppearanceSend(UUID agentid);
void QueueAppearanceSave(UUID agentid); void QueueAppearanceSave(UUID agentid);

View File

@ -35,6 +35,23 @@ namespace OpenSim.Region.Framework.Interfaces
public interface IJ2KDecoder public interface IJ2KDecoder
{ {
void BeginDecode(UUID assetID, byte[] j2kData, DecodedCallback callback); void BeginDecode(UUID assetID, byte[] j2kData, DecodedCallback callback);
void Decode(UUID assetID, byte[] j2kData);
/// <summary>
/// Provides a synchronous decode so that caller can be assured that this executes before the next line
/// </summary>
/// <param name="assetID"></param>
/// <param name="j2kData"></param>
/// <returns>true if decode was successful. false otherwise.</returns>
bool Decode(UUID assetID, byte[] j2kData);
/// <summary>
/// Provides a synchronous decode so that caller can be assured that this executes before the next line
/// </summary>
/// <param name="assetID"></param>
/// <param name="j2kData"></param>
/// <param name="layers">layer data</param>
/// <param name="components">number of components</param>
/// <returns>true if decode was successful. false otherwise.</returns>
bool Decode(UUID assetID, byte[] j2kData, out OpenJPEG.J2KLayerInfo[] layers, out int components);
} }
} }

View File

@ -31,6 +31,19 @@ using OpenSim.Region.Framework.Scenes;
namespace OpenSim.Region.Framework.Interfaces namespace OpenSim.Region.Framework.Interfaces
{ {
/// <summary>
/// Temporary interface. More methods to come at some point to make NPCs more object oriented rather than
/// controlling purely through module level interface calls (e.g. sit/stand).
/// </summary>
public interface INPC
{
/// <summary>
/// Should this NPC be sensed by LSL sensors as an 'agent' (interpreted here to mean a normal user)
/// rather than an OpenSim specific NPC extension?
/// </summary>
bool SenseAsAgent { get; }
}
public interface INPCModule public interface INPCModule
{ {
/// <summary> /// <summary>
@ -39,10 +52,21 @@ namespace OpenSim.Region.Framework.Interfaces
/// <param name="firstname"></param> /// <param name="firstname"></param>
/// <param name="lastname"></param> /// <param name="lastname"></param>
/// <param name="position"></param> /// <param name="position"></param>
/// <param name="senseAsAgent">
/// Make the NPC show up as an agent on LSL sensors. The default is that they
/// show up as the NPC type instead, but this is currently an OpenSim-only extension.
/// </param>
/// <param name="scene"></param> /// <param name="scene"></param>
/// <param name="appearance">The avatar appearance to use for the new NPC.</param> /// <param name="appearance">The avatar appearance to use for the new NPC.</param>
/// <returns>The UUID of the ScenePresence created.</returns> /// <returns>The UUID of the ScenePresence created.</returns>
UUID CreateNPC(string firstname, string lastname, Vector3 position, Scene scene, AvatarAppearance appearance); UUID CreateNPC(
string firstname,
string lastname,
Vector3 position,
UUID owner,
bool senseAsAgent,
Scene scene,
AvatarAppearance appearance);
/// <summary> /// <summary>
/// Check if the agent is an NPC. /// Check if the agent is an NPC.
@ -52,6 +76,22 @@ namespace OpenSim.Region.Framework.Interfaces
/// <returns>True if the agent is an NPC in the given scene. False otherwise.</returns> /// <returns>True if the agent is an NPC in the given scene. False otherwise.</returns>
bool IsNPC(UUID agentID, Scene scene); bool IsNPC(UUID agentID, Scene scene);
/// <summary>
/// Get the NPC. This is not currently complete - manipulation of NPCs still occurs through the region interface
/// </summary>
/// <param name="agentID"></param>
/// <param name="scene"></param>
/// <returns>The NPC. null if it does not exist.</returns>
INPC GetNPC(UUID agentID, Scene scene);
/// <summary>
/// Check if the caller has permission to manipulate the given NPC.
/// </summary>
/// <param name="npcID"></param>
/// <param name="callerID"></param>
/// <returns>true if they do, false if they don't or if there's no NPC with the given ID.</returns>
bool CheckPermissions(UUID npcID, UUID callerID);
/// <summary> /// <summary>
/// Set the appearance for an NPC. /// Set the appearance for an NPC.
/// </summary> /// </summary>
@ -118,5 +158,12 @@ namespace OpenSim.Region.Framework.Interfaces
/// <param name="scene"></param> /// <param name="scene"></param>
/// <returns>True if the operation succeeded, false if there was no such agent or the agent was not an NPC</returns> /// <returns>True if the operation succeeded, false if there was no such agent or the agent was not an NPC</returns>
bool DeleteNPC(UUID agentID, Scene scene); bool DeleteNPC(UUID agentID, Scene scene);
/// <summary>
/// Get the owner of a NPC
/// </summary>
/// <param name="agentID">The UUID of the NPC</param>
/// <returns>UUID of owner if the NPC exists, UUID.Zero if there was no such agent, the agent is unowned or the agent was not an NPC</returns>
UUID GetOwner(UUID agentID);
} }
} }

View File

@ -0,0 +1,38 @@
/*
* 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;
namespace OpenSim.Region.Framework.Interfaces
{
public interface IRegionReadyModule
{
void OarLoadingAlert(string msg);
}
}

View File

@ -31,8 +31,21 @@ using OpenMetaverse;
namespace OpenSim.Region.Framework.Interfaces namespace OpenSim.Region.Framework.Interfaces
{ {
public delegate void ScriptRemoved(UUID script);
public delegate void ObjectRemoved(UUID prim);
public interface IScriptModule: INonSharedRegionModule public interface IScriptModule: INonSharedRegionModule
{ {
/// <summary>
/// Triggered when a script is removed from the script module.
/// </summary>
event ScriptRemoved OnScriptRemoved;
/// <summary>
/// Triggered when an object is removed via the script module.
/// </summary>
event ObjectRemoved OnObjectRemoved;
string ScriptEngineName { get; } string ScriptEngineName { get; }
string GetXMLState(UUID itemID); string GetXMLState(UUID itemID);

View File

@ -0,0 +1,36 @@
/*
* 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 OpenMetaverse;
namespace OpenSim.Framework
{
public interface ISearchModule
{
}
}

View File

@ -14,9 +14,6 @@ namespace OpenSim.Region.Framework.Interfaces
string GetUserHomeURL(UUID uuid); string GetUserHomeURL(UUID uuid);
string GetUserUUI(UUID uuid); string GetUserUUI(UUID uuid);
string GetUserServerURL(UUID uuid, string serverType); string GetUserServerURL(UUID uuid, string serverType);
int GetUserFlags(UUID userID);
int GetUserCreated(UUID userID);
string GetUserTitle(UUID userID);
/// <summary> /// <summary>
/// Add a user. /// Add a user.
@ -50,7 +47,7 @@ namespace OpenSim.Region.Framework.Interfaces
/// <param name="uuid"></param> /// <param name="uuid"></param>
/// <param name="firstName"></param> /// <param name="firstName"></param>
/// <param name="profileURL"></param> /// <param name="profileURL"></param>
void AddUser(UUID uuid, string firstName, string lastName, string profileURL); void AddUser(UUID uuid, string firstName, string lastName, string homeURL);
bool IsLocalGridUser(UUID uuid); bool IsLocalGridUser(UUID uuid);
} }

View File

@ -61,11 +61,12 @@ namespace OpenSim.Region.Framework.Scenes.Animation
public bool m_jumping = false; public bool m_jumping = false;
public float m_jumpVelocity = 0f; public float m_jumpVelocity = 0f;
// private int m_landing = 0; // private int m_landing = 0;
public bool Falling
{ /// <summary>
get { return m_falling; } /// Is the avatar falling?
} /// </summary>
private bool m_falling = false; public bool Falling { get; private set; }
private float m_fallHeight; private float m_fallHeight;
/// <value> /// <value>
@ -223,7 +224,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation
m_animTickFall = 0; m_animTickFall = 0;
m_animTickJump = 0; m_animTickJump = 0;
m_jumping = false; m_jumping = false;
m_falling = true; Falling = false;
m_jumpVelocity = 0f; m_jumpVelocity = 0f;
actor.Selected = false; actor.Selected = false;
m_fallHeight = actor.Position.Z; // save latest flying height m_fallHeight = actor.Position.Z; // save latest flying height
@ -239,9 +240,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation
else if (move.Z < 0f) else if (move.Z < 0f)
{ {
if (actor != null && actor.IsColliding) if (actor != null && actor.IsColliding)
{
return "LAND"; return "LAND";
}
else else
return "HOVER_DOWN"; return "HOVER_DOWN";
} }
@ -260,7 +259,8 @@ namespace OpenSim.Region.Framework.Scenes.Animation
float fallElapsed = (float)(Environment.TickCount - m_animTickFall); float fallElapsed = (float)(Environment.TickCount - m_animTickFall);
float fallVelocity = (actor != null) ? actor.Velocity.Z : 0.0f; float fallVelocity = (actor != null) ? actor.Velocity.Z : 0.0f;
if (!m_jumping && (fallVelocity < -3.0f) ) m_falling = true; if (!m_jumping && (fallVelocity < -3.0f))
Falling = true;
if (m_animTickFall == 0 || (fallVelocity >= 0.0f)) if (m_animTickFall == 0 || (fallVelocity >= 0.0f))
{ {
@ -290,20 +290,20 @@ namespace OpenSim.Region.Framework.Scenes.Animation
// Start jumping, prejump // Start jumping, prejump
m_animTickFall = 0; m_animTickFall = 0;
m_jumping = true; m_jumping = true;
m_falling = false; Falling = false;
actor.Selected = true; // borrowed for jumping flag actor.Selected = true; // borrowed for jumping flag
m_animTickJump = Environment.TickCount; m_animTickJump = Environment.TickCount;
m_jumpVelocity = 0.35f; m_jumpVelocity = 0.35f;
return "PREJUMP"; return "PREJUMP";
} }
if(m_jumping) if (m_jumping)
{ {
if ( (jumptime > (JUMP_PERIOD * 1.5f)) && actor.IsColliding) if ((jumptime > (JUMP_PERIOD * 1.5f)) && actor.IsColliding)
{ {
// end jumping // end jumping
m_jumping = false; m_jumping = false;
m_falling = false; Falling = false;
actor.Selected = false; // borrowed for jumping flag actor.Selected = false; // borrowed for jumping flag
m_jumpVelocity = 0f; m_jumpVelocity = 0f;
m_animTickFall = Environment.TickCount; m_animTickFall = Environment.TickCount;
@ -330,7 +330,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation
if (CurrentMovementAnimation == "FALLDOWN") if (CurrentMovementAnimation == "FALLDOWN")
{ {
m_falling = false; Falling = false;
m_animTickFall = Environment.TickCount; m_animTickFall = Environment.TickCount;
// TODO: SOFT_LAND support // TODO: SOFT_LAND support
float fallHeight = m_fallHeight - actor.Position.Z; float fallHeight = m_fallHeight - actor.Position.Z;
@ -364,7 +364,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation
if (move.X != 0f || move.Y != 0f) if (move.X != 0f || move.Y != 0f)
{ {
m_fallHeight = actor.Position.Z; // save latest flying height m_fallHeight = actor.Position.Z; // save latest flying height
m_falling = false; Falling = false;
// Walking / crouchwalking / running // Walking / crouchwalking / running
if (move.Z < 0f) if (move.Z < 0f)
return "CROUCHWALK"; return "CROUCHWALK";
@ -375,7 +375,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation
} }
else if (!m_jumping) else if (!m_jumping)
{ {
m_falling = false; Falling = false;
// Not walking // Not walking
if (move.Z < 0) if (move.Z < 0)
return "CROUCH"; return "CROUCH";
@ -388,7 +388,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation
} }
#endregion Ground Movement #endregion Ground Movement
m_falling = false; Falling = false;
return CurrentMovementAnimation; return CurrentMovementAnimation;
} }

View File

@ -979,10 +979,13 @@ namespace OpenSim.Region.Framework.Scenes
public void RemoveTaskInventory(IClientAPI remoteClient, UUID itemID, uint localID) public void RemoveTaskInventory(IClientAPI remoteClient, UUID itemID, uint localID)
{ {
SceneObjectPart part = GetSceneObjectPart(localID); SceneObjectPart part = GetSceneObjectPart(localID);
if (part == null) SceneObjectGroup group = null;
return; if (part != null)
{
SceneObjectGroup group = part.ParentGroup; group = part.ParentGroup;
}
if (part != null && group != null)
{
if (!Permissions.CanEditObjectInventory(part.UUID, remoteClient.AgentId)) if (!Permissions.CanEditObjectInventory(part.UUID, remoteClient.AgentId))
return; return;
@ -990,6 +993,16 @@ namespace OpenSim.Region.Framework.Scenes
if (item == null) if (item == null)
return; return;
InventoryFolderBase destFolder = InventoryService.GetFolderForType(remoteClient.AgentId, AssetType.TrashFolder);
// Move the item to trash. If this is a copiable item, only
// a copy will be moved and we will still need to delete
// the item from the prim. If it was no copy, is will be
// deleted by this method.
MoveTaskInventoryItem(remoteClient, destFolder.ID, part, itemID);
if (group.GetInventoryItem(localID, itemID) != null)
{
if (item.Type == 10) if (item.Type == 10)
{ {
part.RemoveScriptEvents(itemID); part.RemoveScriptEvents(itemID);
@ -997,8 +1010,10 @@ namespace OpenSim.Region.Framework.Scenes
} }
group.RemoveInventoryItem(localID, itemID); group.RemoveInventoryItem(localID, itemID);
}
part.SendPropertiesToClient(remoteClient); part.SendPropertiesToClient(remoteClient);
} }
}
private InventoryItemBase CreateAgentInventoryItemFromTask(UUID destAgent, SceneObjectPart part, UUID itemId) private InventoryItemBase CreateAgentInventoryItemFromTask(UUID destAgent, SceneObjectPart part, UUID itemId)
{ {
@ -1058,8 +1073,16 @@ namespace OpenSim.Region.Framework.Scenes
if (!Permissions.BypassPermissions()) if (!Permissions.BypassPermissions())
{ {
if ((taskItem.CurrentPermissions & (uint)PermissionMask.Copy) == 0) if ((taskItem.CurrentPermissions & (uint)PermissionMask.Copy) == 0)
{
if (taskItem.Type == 10)
{
part.RemoveScriptEvents(itemId);
EventManager.TriggerRemoveScript(part.LocalId, itemId);
}
part.Inventory.RemoveInventoryItem(itemId); part.Inventory.RemoveInventoryItem(itemId);
} }
}
return agentItem; return agentItem;
} }
@ -1421,7 +1444,7 @@ namespace OpenSim.Region.Framework.Scenes
// If we've found the item in the user's inventory or in the library // If we've found the item in the user's inventory or in the library
if (item != null) if (item != null)
{ {
part.ParentGroup.AddInventoryItem(remoteClient, primLocalID, item, copyID); part.ParentGroup.AddInventoryItem(remoteClient.AgentId, primLocalID, item, copyID);
m_log.InfoFormat( m_log.InfoFormat(
"[PRIM INVENTORY]: Update with item {0} requested of prim {1} for {2}", "[PRIM INVENTORY]: Update with item {0} requested of prim {1} for {2}",
item.Name, primLocalID, remoteClient.Name); item.Name, primLocalID, remoteClient.Name);
@ -1450,19 +1473,26 @@ namespace OpenSim.Region.Framework.Scenes
// "[PRIM INVENTORY]: Updating item {0} in {1} for UpdateTaskInventory()", // "[PRIM INVENTORY]: Updating item {0} in {1} for UpdateTaskInventory()",
// currentItem.Name, part.Name); // currentItem.Name, part.Name);
IAgentAssetTransactions agentTransactions = this.RequestModuleInterface<IAgentAssetTransactions>(); // Viewers from at least Linden Lab 1.23 onwards use a capability to update script contents rather
if (agentTransactions != null) // than UDP. With viewers from at least 1.23 onwards, changing properties on scripts (e.g. renaming) causes
{ // this to spew spurious errors and "thing saved" messages.
agentTransactions.HandleTaskItemUpdateFromTransaction( // Rather than retaining complexity in the code and removing useful error messages, I'm going to
remoteClient, part, transactionID, currentItem); // comment this section out. If this was still working for very old viewers and there is
// a large population using them which cannot upgrade to 1.23 or derivatives then we can revisit
if ((InventoryType)itemInfo.InvType == InventoryType.Notecard) // this - justincc
remoteClient.SendAgentAlertMessage("Notecard saved", false); // IAgentAssetTransactions agentTransactions = this.RequestModuleInterface<IAgentAssetTransactions>();
else if ((InventoryType)itemInfo.InvType == InventoryType.LSL) // if (agentTransactions != null)
remoteClient.SendAgentAlertMessage("Script saved", false); // {
else // agentTransactions.HandleTaskItemUpdateFromTransaction(
remoteClient.SendAgentAlertMessage("Item saved", false); // remoteClient, part, transactionID, currentItem);
} //
// if ((InventoryType)itemInfo.InvType == InventoryType.Notecard)
// remoteClient.SendAgentAlertMessage("Notecard saved", false);
// else if ((InventoryType)itemInfo.InvType == InventoryType.LSL)
// remoteClient.SendAgentAlertMessage("Script saved", false);
// else
// remoteClient.SendAgentAlertMessage("Item saved", false);
// }
// Base ALWAYS has move // Base ALWAYS has move
currentItem.BasePermissions |= (uint)PermissionMask.Move; currentItem.BasePermissions |= (uint)PermissionMask.Move;
@ -1537,23 +1567,40 @@ namespace OpenSim.Region.Framework.Scenes
/// Rez a script into a prim's inventory, either ex nihilo or from an existing avatar inventory /// Rez a script into a prim's inventory, either ex nihilo or from an existing avatar inventory
/// </summary> /// </summary>
/// <param name="remoteClient"></param> /// <param name="remoteClient"></param>
/// <param name="itemID"> </param> /// <param name="itemBase"> </param>
/// <param name="transactionID"></param>
/// <param name="localID"></param> /// <param name="localID"></param>
public void RezScript(IClientAPI remoteClient, InventoryItemBase itemBase, UUID transactionID, uint localID) public void RezScript(IClientAPI remoteClient, InventoryItemBase itemBase, UUID transactionID, uint localID)
{ {
UUID itemID = itemBase.ID; SceneObjectPart partWhereRezzed;
UUID copyID = UUID.Random();
if (itemID != UUID.Zero) // transferred from an avatar inventory to the prim's inventory if (itemBase.ID != UUID.Zero)
partWhereRezzed = RezScriptFromAgentInventory(remoteClient.AgentId, itemBase.ID, localID);
else
partWhereRezzed = RezNewScript(remoteClient.AgentId, itemBase);
if (partWhereRezzed != null)
partWhereRezzed.SendPropertiesToClient(remoteClient);
}
/// <summary>
/// Rez a script into a prim from an agent inventory.
/// </summary>
/// <param name="agentID"></param>
/// <param name="fromItemID"></param>
/// <param name="localID"></param>
/// <returns>The part where the script was rezzed if successful. False otherwise.</returns>
public SceneObjectPart RezScriptFromAgentInventory(UUID agentID, UUID fromItemID, uint localID)
{ {
InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); UUID copyID = UUID.Random();
InventoryItemBase item = new InventoryItemBase(fromItemID, agentID);
item = InventoryService.GetItem(item); item = InventoryService.GetItem(item);
// Try library // Try library
// XXX clumsy, possibly should be one call // XXX clumsy, possibly should be one call
if (null == item && LibraryService != null && LibraryService.LibraryRootFolder != null) if (null == item && LibraryService != null && LibraryService.LibraryRootFolder != null)
{ {
item = LibraryService.LibraryRootFolder.FindItem(itemID); item = LibraryService.LibraryRootFolder.FindItem(fromItemID);
} }
if (item != null) if (item != null)
@ -1561,10 +1608,10 @@ namespace OpenSim.Region.Framework.Scenes
SceneObjectPart part = GetSceneObjectPart(localID); SceneObjectPart part = GetSceneObjectPart(localID);
if (part != null) if (part != null)
{ {
if (!Permissions.CanEditObjectInventory(part.UUID, remoteClient.AgentId)) if (!Permissions.CanEditObjectInventory(part.UUID, agentID))
return; return null;
part.ParentGroup.AddInventoryItem(remoteClient, localID, item, copyID); part.ParentGroup.AddInventoryItem(agentID, localID, item, copyID);
// TODO: switch to posting on_rez here when scripts // TODO: switch to posting on_rez here when scripts
// have state in inventory // have state in inventory
part.Inventory.CreateScriptInstance(copyID, 0, false, DefaultScriptEngine, 0); part.Inventory.CreateScriptInstance(copyID, 0, false, DefaultScriptEngine, 0);
@ -1572,8 +1619,9 @@ namespace OpenSim.Region.Framework.Scenes
// m_log.InfoFormat("[PRIMINVENTORY]: " + // m_log.InfoFormat("[PRIMINVENTORY]: " +
// "Rezzed script {0} into prim local ID {1} for user {2}", // "Rezzed script {0} into prim local ID {1} for user {2}",
// item.inventoryName, localID, remoteClient.Name); // item.inventoryName, localID, remoteClient.Name);
part.SendPropertiesToClient(remoteClient);
part.ParentGroup.ResumeScripts(); part.ParentGroup.ResumeScripts();
return part;
} }
else else
{ {
@ -1581,29 +1629,49 @@ namespace OpenSim.Region.Framework.Scenes
"[PRIM INVENTORY]: " + "[PRIM INVENTORY]: " +
"Could not rez script {0} into prim local ID {1} for user {2}" "Could not rez script {0} into prim local ID {1} for user {2}"
+ " because the prim could not be found in the region!", + " because the prim could not be found in the region!",
item.Name, localID, remoteClient.Name); item.Name, localID, agentID);
} }
} }
else else
{ {
m_log.ErrorFormat( m_log.ErrorFormat(
"[PRIM INVENTORY]: Could not find script inventory item {0} to rez for {1}!", "[PRIM INVENTORY]: Could not find script inventory item {0} to rez for {1}!",
itemID, remoteClient.Name); fromItemID, agentID);
} }
return null;
} }
else // script has been rezzed directly into a prim's inventory
/// <summary>
/// Rez a new script from nothing.
/// </summary>
/// <param name="remoteClient"></param>
/// <param name="itemBase"></param>
/// <returns>The part where the script was rezzed if successful. False otherwise.</returns>
public SceneObjectPart RezNewScript(UUID agentID, InventoryItemBase itemBase)
{ {
// The part ID is the folder ID!
SceneObjectPart part = GetSceneObjectPart(itemBase.Folder); SceneObjectPart part = GetSceneObjectPart(itemBase.Folder);
if (part == null) if (part == null)
return; {
// m_log.DebugFormat(
// "[SCENE INVENTORY]: Could not find part with id {0} for {1} to rez new script",
// itemBase.Folder, agentID);
if (!Permissions.CanCreateObjectInventory( return null;
itemBase.InvType, part.UUID, remoteClient.AgentId)) }
return;
if (!Permissions.CanCreateObjectInventory(itemBase.InvType, part.UUID, agentID))
{
// m_log.DebugFormat(
// "[SCENE INVENTORY]: No permission to create new script in {0} for {1}", part.Name, agentID);
return null;
}
AssetBase asset = CreateAsset(itemBase.Name, itemBase.Description, (sbyte)itemBase.AssetType, AssetBase asset = CreateAsset(itemBase.Name, itemBase.Description, (sbyte)itemBase.AssetType,
Encoding.ASCII.GetBytes("default\n{\n state_entry()\n {\n llSay(0, \"Script running\");\n }\n}"), Encoding.ASCII.GetBytes("default\n{\n state_entry()\n {\n llSay(0, \"Script running\");\n }\n}"),
remoteClient.AgentId); agentID);
AssetService.Store(asset); AssetService.Store(asset);
TaskInventoryItem taskItem = new TaskInventoryItem(); TaskInventoryItem taskItem = new TaskInventoryItem();
@ -1630,11 +1698,10 @@ namespace OpenSim.Region.Framework.Scenes
taskItem.AssetID = asset.FullID; taskItem.AssetID = asset.FullID;
part.Inventory.AddInventoryItem(taskItem, false); part.Inventory.AddInventoryItem(taskItem, false);
part.SendPropertiesToClient(remoteClient);
part.Inventory.CreateScriptInstance(taskItem, 0, false, DefaultScriptEngine, 0); part.Inventory.CreateScriptInstance(taskItem, 0, false, DefaultScriptEngine, 0);
part.ParentGroup.ResumeScripts(); part.ParentGroup.ResumeScripts();
}
return part;
} }
/// <summary> /// <summary>
@ -1643,7 +1710,7 @@ namespace OpenSim.Region.Framework.Scenes
/// <param name="remoteClient"></param> /// <param name="remoteClient"></param>
/// <param name="itemID"> </param> /// <param name="itemID"> </param>
/// <param name="localID"></param> /// <param name="localID"></param>
public void RezScript(UUID srcId, SceneObjectPart srcPart, UUID destId, int pin, int running, int start_param) public void RezScriptFromPrim(UUID srcId, SceneObjectPart srcPart, UUID destId, int pin, int running, int start_param)
{ {
TaskInventoryItem srcTaskItem = srcPart.Inventory.GetInventoryItem(srcId); TaskInventoryItem srcTaskItem = srcPart.Inventory.GetInventoryItem(srcId);

View File

@ -65,6 +65,7 @@ namespace OpenSim.Region.Framework.Scenes
#region Fields #region Fields
public bool EmergencyMonitoring = false; public bool EmergencyMonitoring = false;
public bool DEBUG = false;
public SynchronizeSceneHandler SynchronizeScene; public SynchronizeSceneHandler SynchronizeScene;
public SimStatsReporter StatsReporter; public SimStatsReporter StatsReporter;
@ -599,23 +600,6 @@ namespace OpenSim.Region.Framework.Scenes
"reload estate", "reload estate",
"Reload the estate data", HandleReloadEstate); "Reload the estate data", HandleReloadEstate);
MainConsole.Instance.Commands.AddCommand("region", false, "delete object owner",
"delete object owner <UUID>",
"Delete object by owner", HandleDeleteObject);
MainConsole.Instance.Commands.AddCommand("region", false, "delete object creator",
"delete object creator <UUID>",
"Delete object by creator", HandleDeleteObject);
MainConsole.Instance.Commands.AddCommand("region", false, "delete object uuid",
"delete object uuid <UUID>",
"Delete object by uuid", HandleDeleteObject);
MainConsole.Instance.Commands.AddCommand("region", false, "delete object name",
"delete object name <name>",
"Delete object by name", HandleDeleteObject);
MainConsole.Instance.Commands.AddCommand("region", false, "delete object outside",
"delete object outside",
"Delete all objects outside boundaries", HandleDeleteObject);
//Bind Storage Manager functions to some land manager functions for this scene //Bind Storage Manager functions to some land manager functions for this scene
EventManager.OnLandObjectAdded += EventManager.OnLandObjectAdded +=
new EventManager.LandObjectAdded(simDataService.StoreLandObject); new EventManager.LandObjectAdded(simDataService.StoreLandObject);
@ -1942,6 +1926,7 @@ namespace OpenSim.Region.Framework.Scenes
/// If true, the object is made persistent into the scene. /// If true, the object is made persistent into the scene.
/// If false, the object will not persist over server restarts /// If false, the object will not persist over server restarts
/// </param> /// </param>
/// <returns>true if the object was added. false if not</returns>
public bool AddNewSceneObject(SceneObjectGroup sceneObject, bool attachToBackup) public bool AddNewSceneObject(SceneObjectGroup sceneObject, bool attachToBackup)
{ {
return AddNewSceneObject(sceneObject, attachToBackup, true); return AddNewSceneObject(sceneObject, attachToBackup, true);
@ -1959,6 +1944,7 @@ namespace OpenSim.Region.Framework.Scenes
/// If true, updates for the new scene object are sent to all viewers in range. /// If true, updates for the new scene object are sent to all viewers in range.
/// If false, it is left to the caller to schedule the update /// If false, it is left to the caller to schedule the update
/// </param> /// </param>
/// <returns>true if the object was added. false if not</returns>
public bool AddNewSceneObject(SceneObjectGroup sceneObject, bool attachToBackup, bool sendClientUpdates) public bool AddNewSceneObject(SceneObjectGroup sceneObject, bool attachToBackup, bool sendClientUpdates)
{ {
if (m_sceneGraph.AddNewSceneObject(sceneObject, attachToBackup, sendClientUpdates)) if (m_sceneGraph.AddNewSceneObject(sceneObject, attachToBackup, sendClientUpdates))
@ -2528,7 +2514,7 @@ namespace OpenSim.Region.Framework.Scenes
sp = m_sceneGraph.CreateAndAddChildScenePresence(client, aCircuit.Appearance, type); sp = m_sceneGraph.CreateAndAddChildScenePresence(client, aCircuit.Appearance, type);
m_eventManager.TriggerOnNewPresence(sp); m_eventManager.TriggerOnNewPresence(sp);
sp.TeleportFlags = (TeleportFlags)aCircuit.teleportFlags; sp.TeleportFlags = (TPFlags)aCircuit.teleportFlags;
// The first agent upon login is a root agent by design. // The first agent upon login is a root agent by design.
// For this agent we will have to rez the attachments. // For this agent we will have to rez the attachments.
@ -3070,11 +3056,11 @@ namespace OpenSim.Region.Framework.Scenes
public override void RemoveClient(UUID agentID, bool closeChildAgents) public override void RemoveClient(UUID agentID, bool closeChildAgents)
{ {
CheckHeartbeat(); CheckHeartbeat();
bool childagentYN = false; bool isChildAgent = false;
ScenePresence avatar = GetScenePresence(agentID); ScenePresence avatar = GetScenePresence(agentID);
if (avatar != null) if (avatar != null)
{ {
childagentYN = avatar.IsChildAgent; isChildAgent = avatar.IsChildAgent;
if (avatar.ParentID != 0) if (avatar.ParentID != 0)
{ {
@ -3085,9 +3071,9 @@ namespace OpenSim.Region.Framework.Scenes
{ {
m_log.DebugFormat( m_log.DebugFormat(
"[SCENE]: Removing {0} agent {1} from region {2}", "[SCENE]: Removing {0} agent {1} from region {2}",
(childagentYN ? "child" : "root"), agentID, RegionInfo.RegionName); (isChildAgent ? "child" : "root"), agentID, RegionInfo.RegionName);
m_sceneGraph.removeUserCount(!childagentYN); m_sceneGraph.removeUserCount(!isChildAgent);
// TODO: We shouldn't use closeChildAgents here - it's being used by the NPC module to stop // TODO: We shouldn't use closeChildAgents here - it's being used by the NPC module to stop
// unnecessary operations. This should go away once NPCs have no accompanying IClientAPI // unnecessary operations. This should go away once NPCs have no accompanying IClientAPI
@ -3117,8 +3103,18 @@ namespace OpenSim.Region.Framework.Scenes
{ {
m_eventManager.TriggerOnRemovePresence(agentID); m_eventManager.TriggerOnRemovePresence(agentID);
if (AttachmentsModule != null && !avatar.IsChildAgent && avatar.PresenceType != PresenceType.Npc) if (AttachmentsModule != null && !isChildAgent && avatar.PresenceType != PresenceType.Npc)
AttachmentsModule.SaveChangedAttachments(avatar); {
IUserManagement uMan = RequestModuleInterface<IUserManagement>();
// 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.
if (uMan == null || uMan.IsLocalGridUser(avatar.UUID))
AttachmentsModule.SaveChangedAttachments(avatar, false);
}
ForEachClient( ForEachClient(
delegate(IClientAPI client) delegate(IClientAPI client)
@ -3333,7 +3329,7 @@ namespace OpenSim.Region.Framework.Scenes
{ {
// Let the SP know how we got here. This has a lot of interesting // Let the SP know how we got here. This has a lot of interesting
// uses down the line. // uses down the line.
sp.TeleportFlags = (TeleportFlags)teleportFlags; sp.TeleportFlags = (TPFlags)teleportFlags;
if (sp.IsChildAgent) if (sp.IsChildAgent)
{ {
@ -4867,93 +4863,6 @@ namespace OpenSim.Region.Framework.Scenes
} }
} }
private void HandleDeleteObject(string module, string[] cmd)
{
if (cmd.Length < 3)
return;
string mode = cmd[2];
string o = "";
if (mode != "outside")
{
if (cmd.Length < 4)
return;
o = cmd[3];
}
List<SceneObjectGroup> deletes = new List<SceneObjectGroup>();
UUID match;
switch (mode)
{
case "owner":
if (!UUID.TryParse(o, out match))
return;
ForEachSOG(delegate (SceneObjectGroup g)
{
if (g.OwnerID == match && !g.IsAttachment)
deletes.Add(g);
});
break;
case "creator":
if (!UUID.TryParse(o, out match))
return;
ForEachSOG(delegate (SceneObjectGroup g)
{
if (g.RootPart.CreatorID == match && !g.IsAttachment)
deletes.Add(g);
});
break;
case "uuid":
if (!UUID.TryParse(o, out match))
return;
ForEachSOG(delegate (SceneObjectGroup g)
{
if (g.UUID == match && !g.IsAttachment)
deletes.Add(g);
});
break;
case "name":
ForEachSOG(delegate (SceneObjectGroup g)
{
if (g.RootPart.Name == o && !g.IsAttachment)
deletes.Add(g);
});
break;
case "outside":
ForEachSOG(delegate (SceneObjectGroup g)
{
SceneObjectPart rootPart = g.RootPart;
bool delete = false;
if (rootPart.GroupPosition.Z < 0.0 || rootPart.GroupPosition.Z > 10000.0)
{
delete = true;
}
else
{
ILandObject parcel = LandChannel.GetLandObject(rootPart.GroupPosition.X, rootPart.GroupPosition.Y);
if (parcel == null || parcel.LandData.Name == "NO LAND")
delete = true;
}
if (delete && !g.IsAttachment && !deletes.Contains(g))
deletes.Add(g);
});
break;
}
foreach (SceneObjectGroup g in deletes)
{
m_log.InfoFormat("[SCENE]: Deleting object {0}", g.UUID);
DeleteSceneObject(g, false);
}
}
private void HandleReloadEstate(string module, string[] cmd) private void HandleReloadEstate(string module, string[] cmd)
{ {
if (MainConsole.Instance.ConsoleScene == null || if (MainConsole.Instance.ConsoleScene == null ||
@ -5076,6 +4985,36 @@ namespace OpenSim.Region.Framework.Scenes
} }
} }
if (position == Vector3.Zero) // Teleport
{
if (!RegionInfo.EstateSettings.AllowDirectTeleport)
{
SceneObjectGroup telehub;
if (RegionInfo.RegionSettings.TelehubObject != UUID.Zero && (telehub = GetSceneObjectGroup(RegionInfo.RegionSettings.TelehubObject)) != null)
{
List<SpawnPoint> spawnPoints = RegionInfo.RegionSettings.SpawnPoints();
bool banned = true;
foreach (SpawnPoint sp in spawnPoints)
{
Vector3 spawnPoint = sp.GetLocation(telehub.AbsolutePosition, telehub.GroupRotation);
ILandObject land = LandChannel.GetLandObject(spawnPoint.X, spawnPoint.Y);
if (land == null)
continue;
if (land.IsEitherBannedOrRestricted(agentID))
continue;
banned = false;
break;
}
if (banned)
{
reason = "No suitable landing point found";
return false;
}
}
}
}
reason = String.Empty; reason = String.Empty;
return true; return true;
} }

View File

@ -41,12 +41,6 @@ namespace OpenSim.Region.Framework.Scenes
{ {
public delegate void PhysicsCrash(); public delegate void PhysicsCrash();
public delegate void ObjectDuplicateDelegate(EntityBase original, EntityBase clone);
public delegate void ObjectCreateDelegate(EntityBase obj);
public delegate void ObjectDeleteDelegate(EntityBase obj);
/// <summary> /// <summary>
/// This class used to be called InnerScene and may not yet truly be a SceneGraph. The non scene graph components /// This class used to be called InnerScene and may not yet truly be a SceneGraph. The non scene graph components
/// should be migrated out over time. /// should be migrated out over time.
@ -60,10 +54,6 @@ namespace OpenSim.Region.Framework.Scenes
protected internal event PhysicsCrash UnRecoverableError; protected internal event PhysicsCrash UnRecoverableError;
private PhysicsCrash handlerPhysicsCrash = null; private PhysicsCrash handlerPhysicsCrash = null;
public event ObjectDuplicateDelegate OnObjectDuplicate;
public event ObjectCreateDelegate OnObjectCreate;
public event ObjectDeleteDelegate OnObjectRemove;
#endregion #endregion
#region Fields #region Fields
@ -364,11 +354,23 @@ namespace OpenSim.Region.Framework.Scenes
/// </returns> /// </returns>
protected bool AddSceneObject(SceneObjectGroup sceneObject, bool attachToBackup, bool sendClientUpdates) protected bool AddSceneObject(SceneObjectGroup sceneObject, bool attachToBackup, bool sendClientUpdates)
{ {
if (sceneObject == null || sceneObject.RootPart.UUID == UUID.Zero) if (sceneObject.UUID == UUID.Zero)
{
m_log.ErrorFormat(
"[SCENEGRAPH]: Tried to add scene object {0} to {1} with illegal UUID of {2}",
sceneObject.Name, m_parentScene.RegionInfo.RegionName, UUID.Zero);
return false; return false;
}
if (Entities.ContainsKey(sceneObject.UUID)) 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);
return false; return false;
}
// m_log.DebugFormat( // m_log.DebugFormat(
// "[SCENEGRAPH]: Adding scene object {0} {1}, with {2} parts on {3}", // "[SCENEGRAPH]: Adding scene object {0} {1}, with {2} parts on {3}",
@ -405,9 +407,6 @@ namespace OpenSim.Region.Framework.Scenes
if (attachToBackup) if (attachToBackup)
sceneObject.AttachToBackup(); sceneObject.AttachToBackup();
if (OnObjectCreate != null)
OnObjectCreate(sceneObject);
lock (SceneObjectGroupsByFullID) lock (SceneObjectGroupsByFullID)
SceneObjectGroupsByFullID[sceneObject.UUID] = sceneObject; SceneObjectGroupsByFullID[sceneObject.UUID] = sceneObject;
@ -457,9 +456,6 @@ namespace OpenSim.Region.Framework.Scenes
RemovePhysicalPrim(grp.PrimCount); RemovePhysicalPrim(grp.PrimCount);
} }
if (OnObjectRemove != null)
OnObjectRemove(Entities[uuid]);
lock (SceneObjectGroupsByFullID) lock (SceneObjectGroupsByFullID)
SceneObjectGroupsByFullID.Remove(grp.UUID); SceneObjectGroupsByFullID.Remove(grp.UUID);
@ -1154,8 +1150,10 @@ namespace OpenSim.Region.Framework.Scenes
/// <param name="action"></param> /// <param name="action"></param>
protected internal void ForEachSOG(Action<SceneObjectGroup> action) protected internal void ForEachSOG(Action<SceneObjectGroup> action)
{ {
// FIXME: Need to lock here, really. List<SceneObjectGroup> objlist;
List<SceneObjectGroup> objlist = new List<SceneObjectGroup>(SceneObjectGroupsByFullID.Values); lock (SceneObjectGroupsByFullID)
objlist = new List<SceneObjectGroup>(SceneObjectGroupsByFullID.Values);
foreach (SceneObjectGroup obj in objlist) foreach (SceneObjectGroup obj in objlist)
{ {
try try
@ -1164,7 +1162,7 @@ namespace OpenSim.Region.Framework.Scenes
} }
catch (Exception e) catch (Exception e)
{ {
// Catch it and move on. This includes situations where splist has inconsistent info // Catch it and move on. This includes situations where objlist has inconsistent info
m_log.WarnFormat( m_log.WarnFormat(
"[SCENEGRAPH]: Problem processing action in ForEachSOG: {0} {1}", e.Message, e.StackTrace); "[SCENEGRAPH]: Problem processing action in ForEachSOG: {0} {1}", e.Message, e.StackTrace);
} }
@ -1399,10 +1397,10 @@ namespace OpenSim.Region.Framework.Scenes
/// <summary> /// <summary>
/// Update the texture entry of the given prim. /// Update the texture entry of the given prim.
/// </summary> /// </summary>
/// /// <remarks>
/// A texture entry is an object that contains details of all the textures of the prim's face. In this case, /// A texture entry is an object that contains details of all the textures of the prim's face. In this case,
/// the texture is given in its byte serialized form. /// the texture is given in its byte serialized form.
/// /// </remarks>
/// <param name="localID"></param> /// <param name="localID"></param>
/// <param name="texture"></param> /// <param name="texture"></param>
/// <param name="remoteClient"></param> /// <param name="remoteClient"></param>
@ -1980,9 +1978,6 @@ namespace OpenSim.Region.Framework.Scenes
// required for physics to update it's position // required for physics to update it's position
copy.AbsolutePosition = copy.AbsolutePosition; copy.AbsolutePosition = copy.AbsolutePosition;
if (OnObjectDuplicate != null)
OnObjectDuplicate(original, copy);
return copy; return copy;
} }
} }

View File

@ -83,13 +83,12 @@ namespace OpenSim.Region.Framework.Scenes
/// <summary> /// <summary>
/// Add an inventory item from a user's inventory to a prim in this scene object. /// Add an inventory item from a user's inventory to a prim in this scene object.
/// </summary> /// </summary>
/// <param name="remoteClient">The client adding the item.</param> /// <param name="agentID">The agent adding the item.</param>
/// <param name="localID">The local ID of the part receiving the add.</param> /// <param name="localID">The local ID of the part receiving the add.</param>
/// <param name="item">The user inventory item being added.</param> /// <param name="item">The user inventory item being added.</param>
/// <param name="copyItemID">The item UUID that should be used by the new item.</param> /// <param name="copyItemID">The item UUID that should be used by the new item.</param>
/// <returns></returns> /// <returns></returns>
public bool AddInventoryItem(IClientAPI remoteClient, uint localID, public bool AddInventoryItem(UUID agentID, uint localID, InventoryItemBase item, UUID copyItemID)
InventoryItemBase item, UUID copyItemID)
{ {
// m_log.DebugFormat( // m_log.DebugFormat(
// "[PRIM INVENTORY]: Adding inventory item {0} from {1} to part with local ID {2}", // "[PRIM INVENTORY]: Adding inventory item {0} from {1} to part with local ID {2}",
@ -111,9 +110,7 @@ namespace OpenSim.Region.Framework.Scenes
taskItem.Type = item.AssetType; taskItem.Type = item.AssetType;
taskItem.InvType = item.InvType; taskItem.InvType = item.InvType;
if (remoteClient != null && if (agentID != part.OwnerID && m_scene.Permissions.PropagatePermissions())
remoteClient.AgentId != part.OwnerID &&
m_scene.Permissions.PropagatePermissions())
{ {
taskItem.BasePermissions = item.BasePermissions & taskItem.BasePermissions = item.BasePermissions &
item.NextPermissions; item.NextPermissions;
@ -148,11 +145,7 @@ namespace OpenSim.Region.Framework.Scenes
// taskItem.SaleType = item.SaleType; // taskItem.SaleType = item.SaleType;
taskItem.CreationDate = (uint)item.CreationDate; taskItem.CreationDate = (uint)item.CreationDate;
bool addFromAllowedDrop = false; bool addFromAllowedDrop = agentID != part.OwnerID;
if (remoteClient != null)
{
addFromAllowedDrop = remoteClient.AgentId != part.OwnerID;
}
part.Inventory.AddInventoryItem(taskItem, addFromAllowedDrop); part.Inventory.AddInventoryItem(taskItem, addFromAllowedDrop);

View File

@ -264,6 +264,12 @@ namespace OpenSim.Region.Framework.Scenes
set { RootPart.Name = value; } set { RootPart.Name = value; }
} }
public string Description
{
get { return RootPart.Description; }
set { RootPart.Description = value; }
}
/// <summary> /// <summary>
/// Added because the Parcel code seems to use it /// Added because the Parcel code seems to use it
/// but not sure a object should have this /// but not sure a object should have this
@ -441,6 +447,12 @@ namespace OpenSim.Region.Framework.Scenes
} }
} }
public UUID LastOwnerID
{
get { return m_rootPart.LastOwnerID; }
set { m_rootPart.LastOwnerID = value; }
}
public UUID OwnerID public UUID OwnerID
{ {
get { return m_rootPart.OwnerID; } get { return m_rootPart.OwnerID; }
@ -1613,12 +1625,6 @@ namespace OpenSim.Region.Framework.Scenes
RootPart.PhysActor.PIDActive = false; RootPart.PhysActor.PIDActive = false;
} }
public void stopLookAt()
{
if (RootPart.PhysActor != null)
RootPart.PhysActor.APIDActive = false;
}
/// <summary> /// <summary>
/// Uses a PID to attempt to clamp the object on the Z axis at the given height over tau seconds. /// Uses a PID to attempt to clamp the object on the Z axis at the given height over tau seconds.
/// </summary> /// </summary>

View File

@ -217,11 +217,10 @@ namespace OpenSim.Region.Framework.Scenes
public Quaternion SpinOldOrientation = Quaternion.Identity; public Quaternion SpinOldOrientation = Quaternion.Identity;
public Quaternion m_APIDTarget = Quaternion.Identity; protected int m_APIDIterations = 0;
protected Quaternion m_APIDTarget = Quaternion.Identity;
public float m_APIDDamp = 0; protected float m_APIDDamp = 0;
protected float m_APIDStrength = 0;
public float m_APIDStrength = 0;
/// <summary> /// <summary>
/// This part's inventory /// This part's inventory
@ -394,7 +393,7 @@ namespace OpenSim.Region.Framework.Scenes
private string m_creatorData = string.Empty; private string m_creatorData = string.Empty;
/// <summary> /// <summary>
/// Data about the creator in the form profile_url;name /// Data about the creator in the form home_url;name
/// </summary> /// </summary>
public string CreatorData public string CreatorData
{ {
@ -405,7 +404,7 @@ namespace OpenSim.Region.Framework.Scenes
/// <summary> /// <summary>
/// Used by the DB layer to retrieve / store the entire user identification. /// Used by the DB layer to retrieve / store the entire user identification.
/// The identification can either be a simple UUID or a string of the form /// The identification can either be a simple UUID or a string of the form
/// uuid[;profile_url[;name]] /// uuid[;home_url[;name]]
/// </summary> /// </summary>
public string CreatorIdentification public string CreatorIdentification
{ {
@ -563,22 +562,21 @@ namespace OpenSim.Region.Framework.Scenes
} }
} }
protected Quaternion APIDTarget
public Quaternion APIDTarget
{ {
get { return m_APIDTarget; } get { return m_APIDTarget; }
set { m_APIDTarget = value; } set { m_APIDTarget = value; }
} }
public float APIDDamp protected float APIDDamp
{ {
get { return m_APIDDamp; } get { return m_APIDDamp; }
set { m_APIDDamp = value; } set { m_APIDDamp = value; }
} }
public float APIDStrength protected float APIDStrength
{ {
get { return m_APIDStrength; } get { return m_APIDStrength; }
set { m_APIDStrength = value; } set { m_APIDStrength = value; }
@ -1946,19 +1944,13 @@ namespace OpenSim.Region.Framework.Scenes
public Vector3 GetWorldPosition() public Vector3 GetWorldPosition()
{ {
Quaternion parentRot = ParentGroup.RootPart.RotationOffset; Quaternion parentRot = ParentGroup.RootPart.RotationOffset;
Vector3 axPos = OffsetPosition; Vector3 axPos = OffsetPosition;
axPos *= parentRot; axPos *= parentRot;
Vector3 translationOffsetPosition = axPos; Vector3 translationOffsetPosition = axPos;
if(_parentID == 0)
// m_log.DebugFormat("[SCENE OBJECT PART]: Found group pos {0} for part {1}", GroupPosition, Name); return GroupPosition;
else
Vector3 worldPos = GroupPosition + translationOffsetPosition; return ParentGroup.AbsolutePosition + translationOffsetPosition;
// m_log.DebugFormat("[SCENE OBJECT PART]: Found world pos {0} for part {1}", worldPos, Name);
return worldPos;
} }
/// <summary> /// <summary>
@ -2688,11 +2680,6 @@ namespace OpenSim.Region.Framework.Scenes
} }
public void RotLookAt(Quaternion target, float strength, float damping) public void RotLookAt(Quaternion target, float strength, float damping)
{
rotLookAt(target, strength, damping);
}
public void rotLookAt(Quaternion target, float strength, float damping)
{ {
if (ParentGroup.IsAttachment) if (ParentGroup.IsAttachment)
{ {
@ -2708,17 +2695,26 @@ namespace OpenSim.Region.Framework.Scenes
APIDDamp = damping; APIDDamp = damping;
APIDStrength = strength; APIDStrength = strength;
APIDTarget = target; APIDTarget = target;
}
}
public void startLookAt(Quaternion rot, float damp, float strength) if (APIDStrength <= 0)
{ {
APIDDamp = damp; m_log.WarnFormat("[SceneObjectPart] Invalid rotation strength {0}",APIDStrength);
APIDStrength = strength; return;
APIDTarget = rot;
} }
public void stopLookAt() m_APIDIterations = 1 + (int)(Math.PI * APIDStrength);
}
// Necessary to get the lookat deltas applied
ParentGroup.QueueForUpdateCheck();
}
public void StartLookAt(Quaternion target, float strength, float damping)
{
RotLookAt(target,strength,damping);
}
public void StopLookAt()
{ {
APIDTarget = Quaternion.Identity; APIDTarget = Quaternion.Identity;
} }
@ -3413,13 +3409,6 @@ namespace OpenSim.Region.Framework.Scenes
} }
} }
public void StopLookAt()
{
ParentGroup.stopLookAt();
ParentGroup.ScheduleGroupForTerseUpdate();
}
/// <summary> /// <summary>
/// Set the text displayed for this part. /// Set the text displayed for this part.
/// </summary> /// </summary>
@ -4521,10 +4510,18 @@ namespace OpenSim.Region.Framework.Scenes
/// <summary> /// <summary>
/// Update the texture entry for this part. /// Update the texture entry for this part.
/// </summary> /// </summary>
/// <param name="textureEntry"></param> /// <param name="serializedTextureEntry"></param>
public void UpdateTextureEntry(byte[] textureEntry) public void UpdateTextureEntry(byte[] serializedTextureEntry)
{
UpdateTextureEntry(new Primitive.TextureEntry(serializedTextureEntry, 0, serializedTextureEntry.Length));
}
/// <summary>
/// Update the texture entry for this part.
/// </summary>
/// <param name="newTex"></param>
public void UpdateTextureEntry(Primitive.TextureEntry newTex)
{ {
Primitive.TextureEntry newTex = new Primitive.TextureEntry(textureEntry, 0, textureEntry.Length);
Primitive.TextureEntry oldTex = Shape.Textures; Primitive.TextureEntry oldTex = Shape.Textures;
Changed changeFlags = 0; Changed changeFlags = 0;
@ -4556,7 +4553,7 @@ namespace OpenSim.Region.Framework.Scenes
break; break;
} }
m_shape.TextureEntry = textureEntry; m_shape.TextureEntry = newTex.GetBytes();
if (changeFlags != 0) if (changeFlags != 0)
TriggerScriptChangedEvent(changeFlags); TriggerScriptChangedEvent(changeFlags);
UpdateFlag = UpdateRequired.FULL; UpdateFlag = UpdateRequired.FULL;
@ -4727,24 +4724,20 @@ namespace OpenSim.Region.Framework.Scenes
{ {
if (APIDTarget != Quaternion.Identity) if (APIDTarget != Quaternion.Identity)
{ {
if (Single.IsNaN(APIDTarget.W) == true) if (m_APIDIterations <= 1)
{ {
UpdateRotation(APIDTarget);
APIDTarget = Quaternion.Identity; APIDTarget = Quaternion.Identity;
return; return;
} }
Quaternion rot = RotationOffset;
Quaternion dir = (rot - APIDTarget); Quaternion rot = Quaternion.Slerp(RotationOffset,APIDTarget,1.0f/(float)m_APIDIterations);
float speed = ((APIDStrength / APIDDamp) * (float)(Math.PI / 180.0f));
if (dir.Z > speed)
{
rot.Z -= speed;
}
if (dir.Z < -speed)
{
rot.Z += speed;
}
rot.Normalize();
UpdateRotation(rot); UpdateRotation(rot);
m_APIDIterations--;
// This ensures that we'll check this object on the next iteration
ParentGroup.QueueForUpdateCheck();
} }
} }
catch (Exception ex) catch (Exception ex)

View File

@ -40,6 +40,7 @@ using OpenSim.Region.Framework.Scenes.Types;
using OpenSim.Region.Physics.Manager; using OpenSim.Region.Physics.Manager;
using GridRegion = OpenSim.Services.Interfaces.GridRegion; using GridRegion = OpenSim.Services.Interfaces.GridRegion;
using OpenSim.Services.Interfaces; using OpenSim.Services.Interfaces;
using TeleportFlags = OpenSim.Framework.Constants.TeleportFlags;
namespace OpenSim.Region.Framework.Scenes namespace OpenSim.Region.Framework.Scenes
{ {
@ -892,6 +893,8 @@ namespace OpenSim.Region.Framework.Scenes
pos.Y = crossedBorder.BorderLine.Z - 1; pos.Y = crossedBorder.BorderLine.Z - 1;
} }
CheckAndAdjustLandingPoint(ref pos);
if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f)
{ {
m_log.WarnFormat( m_log.WarnFormat(
@ -1056,6 +1059,7 @@ namespace OpenSim.Region.Framework.Scenes
bool isFlying = Flying; bool isFlying = Flying;
RemoveFromPhysicalScene(); RemoveFromPhysicalScene();
Velocity = Vector3.Zero; Velocity = Vector3.Zero;
CheckLandingPoint(ref pos);
AbsolutePosition = pos; AbsolutePosition = pos;
AddToPhysicalScene(isFlying); AddToPhysicalScene(isFlying);
@ -1066,6 +1070,7 @@ namespace OpenSim.Region.Framework.Scenes
{ {
bool isFlying = Flying; bool isFlying = Flying;
RemoveFromPhysicalScene(); RemoveFromPhysicalScene();
CheckLandingPoint(ref pos);
AbsolutePosition = pos; AbsolutePosition = pos;
AddToPhysicalScene(isFlying); AddToPhysicalScene(isFlying);
@ -1180,6 +1185,7 @@ namespace OpenSim.Region.Framework.Scenes
client.Name, Scene.RegionInfo.RegionName, AbsolutePosition); client.Name, Scene.RegionInfo.RegionName, AbsolutePosition);
Vector3 look = Velocity; Vector3 look = Velocity;
if ((look.X == 0) && (look.Y == 0) && (look.Z == 0)) if ((look.X == 0) && (look.Y == 0) && (look.Z == 0))
{ {
look = new Vector3(0.99f, 0.042f, 0); look = new Vector3(0.99f, 0.042f, 0);
@ -1206,7 +1212,7 @@ namespace OpenSim.Region.Framework.Scenes
m_callbackURI = null; m_callbackURI = null;
} }
//m_log.DebugFormat("[SCENE PRESENCE] Completed movement"); // m_log.DebugFormat("[SCENE PRESENCE] Completed movement");
ControllingClient.MoveAgentIntoRegion(m_scene.RegionInfo, AbsolutePosition, look); ControllingClient.MoveAgentIntoRegion(m_scene.RegionInfo, AbsolutePosition, look);
ValidateAndSendAppearanceAndAgentData(); ValidateAndSendAppearanceAndAgentData();
@ -1274,8 +1280,8 @@ namespace OpenSim.Region.Framework.Scenes
public void HandleAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData) public void HandleAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData)
{ {
// m_log.DebugFormat( // m_log.DebugFormat(
// "[SCENE PRESENCE]: In {0} received agent update from {1}", // "[SCENE PRESENCE]: In {0} received agent update from {1}, flags {2}",
// Scene.RegionInfo.RegionName, remoteClient.Name); // Scene.RegionInfo.RegionName, remoteClient.Name, agentData.ControlFlags);
if (IsChildAgent) if (IsChildAgent)
{ {
@ -2312,6 +2318,8 @@ namespace OpenSim.Region.Framework.Scenes
/// <param name="vec">The vector in which to move. This is relative to the rotation argument</param> /// <param name="vec">The vector in which to move. This is relative to the rotation argument</param>
public void AddNewMovement(Vector3 vec) public void AddNewMovement(Vector3 vec)
{ {
// m_log.DebugFormat("[SCENE PRESENCE]: Adding new movement {0} for {1}", vec, Name);
Vector3 direc = vec * Rotation; Vector3 direc = vec * Rotation;
direc.Normalize(); direc.Normalize();
@ -3801,5 +3809,146 @@ namespace OpenSim.Region.Framework.Scenes
m_reprioritization_called = false; m_reprioritization_called = false;
} }
} }
private void CheckLandingPoint(ref Vector3 pos)
{
// Never constrain lures
if ((TeleportFlags & TeleportFlags.ViaLure) != 0)
return;
if (m_scene.RegionInfo.EstateSettings.AllowDirectTeleport)
return;
ILandObject land = m_scene.LandChannel.GetLandObject(pos.X, pos.Y);
if (land.LandData.LandingType == (byte)LandingType.LandingPoint &&
land.LandData.UserLocation != Vector3.Zero &&
land.LandData.OwnerID != m_uuid &&
(!m_scene.Permissions.IsGod(m_uuid)) &&
(!m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid)))
{
float curr = Vector3.Distance(AbsolutePosition, pos);
if (Vector3.Distance(land.LandData.UserLocation, pos) < curr)
pos = land.LandData.UserLocation;
else
ControllingClient.SendAlertMessage("Can't teleport closer to destination");
}
}
private void CheckAndAdjustTelehub(SceneObjectGroup telehub, ref Vector3 pos)
{
if ((m_teleportFlags & (TeleportFlags.ViaLogin | TeleportFlags.ViaRegionID)) ==
(TeleportFlags.ViaLogin | TeleportFlags.ViaRegionID) ||
(m_teleportFlags & TeleportFlags.ViaLandmark) != 0 ||
(m_teleportFlags & TeleportFlags.ViaLocation) != 0 ||
(m_teleportFlags & Constants.TeleportFlags.ViaHGLogin) != 0)
{
if (GodLevel < 200 &&
((!m_scene.Permissions.IsGod(m_uuid) &&
!m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid)) ||
(m_teleportFlags & TeleportFlags.ViaLocation) != 0 ||
(m_teleportFlags & Constants.TeleportFlags.ViaHGLogin) != 0))
{
SpawnPoint[] spawnPoints = m_scene.RegionInfo.RegionSettings.SpawnPoints().ToArray();
if (spawnPoints.Length == 0)
return;
float distance = 9999;
int closest = -1;
for (int i = 0 ; i < spawnPoints.Length ; i++)
{
Vector3 spawnPosition = spawnPoints[i].GetLocation(telehub.AbsolutePosition, telehub.GroupRotation);
Vector3 offset = spawnPosition - pos;
float d = Vector3.Mag(offset);
if (d >= distance)
continue;
ILandObject land = m_scene.LandChannel.GetLandObject(spawnPosition.X, spawnPosition.Y);
if (land == null)
continue;
if (land.IsEitherBannedOrRestricted(UUID))
continue;
distance = d;
closest = i;
}
if (closest == -1)
return;
pos = spawnPoints[closest].GetLocation(telehub.AbsolutePosition, telehub.GroupRotation);
}
}
}
private void CheckAndAdjustLandingPoint(ref Vector3 pos)
{
SceneObjectGroup telehub = null;
if (m_scene.RegionInfo.RegionSettings.TelehubObject != UUID.Zero && (telehub = m_scene.GetSceneObjectGroup(m_scene.RegionInfo.RegionSettings.TelehubObject)) != null)
{
if (!m_scene.RegionInfo.EstateSettings.AllowDirectTeleport)
{
CheckAndAdjustTelehub(telehub, ref pos);
return;
}
}
ILandObject land = m_scene.LandChannel.GetLandObject(pos.X, pos.Y);
if (land != null)
{
if (Scene.DEBUG)
TeleportFlagsDebug();
// If we come in via login, landmark or map, we want to
// honor landing points. If we come in via Lure, we want
// to ignore them.
if ((m_teleportFlags & (TeleportFlags.ViaLogin | TeleportFlags.ViaRegionID)) ==
(TeleportFlags.ViaLogin | TeleportFlags.ViaRegionID) ||
(m_teleportFlags & TeleportFlags.ViaLandmark) != 0 ||
(m_teleportFlags & TeleportFlags.ViaLocation) != 0 ||
(m_teleportFlags & Constants.TeleportFlags.ViaHGLogin) != 0)
{
// Don't restrict gods, estate managers, or land owners to
// the TP point. This behaviour mimics agni.
if (land.LandData.LandingType == (byte)LandingType.LandingPoint &&
land.LandData.UserLocation != Vector3.Zero &&
GodLevel < 200 &&
((land.LandData.OwnerID != m_uuid &&
!m_scene.Permissions.IsGod(m_uuid) &&
!m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid)) ||
(m_teleportFlags & TeleportFlags.ViaLocation) != 0 ||
(m_teleportFlags & Constants.TeleportFlags.ViaHGLogin) != 0))
{
pos = land.LandData.UserLocation;
}
}
land.SendLandUpdateToClient(ControllingClient);
}
}
private void TeleportFlagsDebug() {
// Some temporary debugging help to show all the TeleportFlags we have...
bool HG = false;
if((m_teleportFlags & TeleportFlags.ViaHGLogin) == TeleportFlags.ViaHGLogin)
HG = true;
m_log.InfoFormat("[SCENE PRESENCE]: TELEPORT ******************");
uint i = 0u;
for (int x = 0; x <= 30 ; x++, i = 1u << x)
{
i = 1u << x;
if((m_teleportFlags & (TeleportFlags)i) == (TeleportFlags)i)
if (HG == false)
m_log.InfoFormat("[SCENE PRESENCE]: Teleport Flags include {0}", ((TeleportFlags) i).ToString());
else
m_log.InfoFormat("[SCENE PRESENCE]: HG Teleport Flags include {0}", ((TeleportFlags)i).ToString());
}
m_log.InfoFormat("[SCENE PRESENCE]: TELEPORT ******************");
}
} }
} }

View File

@ -54,7 +54,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
/// Deserialize a scene object from the original xml format /// Deserialize a scene object from the original xml format
/// </summary> /// </summary>
/// <param name="xmlData"></param> /// <param name="xmlData"></param>
/// <returns></returns> /// <returns>The scene object deserialized. Null on failure.</returns>
public static SceneObjectGroup FromOriginalXmlFormat(string xmlData) public static SceneObjectGroup FromOriginalXmlFormat(string xmlData)
{ {
//m_log.DebugFormat("[SOG]: Starting deserialization of SOG"); //m_log.DebugFormat("[SOG]: Starting deserialization of SOG");
@ -1134,12 +1134,12 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
if (sop.CreatorData != null && sop.CreatorData != string.Empty) if (sop.CreatorData != null && sop.CreatorData != string.Empty)
writer.WriteElementString("CreatorData", sop.CreatorData); writer.WriteElementString("CreatorData", sop.CreatorData);
else if (options.ContainsKey("profile")) else if (options.ContainsKey("home"))
{ {
if (m_UserManagement == null) if (m_UserManagement == null)
m_UserManagement = sop.ParentGroup.Scene.RequestModuleInterface<IUserManagement>(); m_UserManagement = sop.ParentGroup.Scene.RequestModuleInterface<IUserManagement>();
string name = m_UserManagement.GetUserName(sop.CreatorID); string name = m_UserManagement.GetUserName(sop.CreatorID);
writer.WriteElementString("CreatorData", (string)options["profile"] + "/" + sop.CreatorID + ";" + name); writer.WriteElementString("CreatorData", (string)options["home"] + ";" + name);
} }
WriteUUID(writer, "FolderID", sop.FolderID, options); WriteUUID(writer, "FolderID", sop.FolderID, options);
@ -1192,8 +1192,13 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
writer.WriteElementString("ObjectSaleType", sop.ObjectSaleType.ToString()); writer.WriteElementString("ObjectSaleType", sop.ObjectSaleType.ToString());
writer.WriteElementString("OwnershipCost", sop.OwnershipCost.ToString()); writer.WriteElementString("OwnershipCost", sop.OwnershipCost.ToString());
WriteUUID(writer, "GroupID", sop.GroupID, options); WriteUUID(writer, "GroupID", sop.GroupID, options);
WriteUUID(writer, "OwnerID", sop.OwnerID, options);
WriteUUID(writer, "LastOwnerID", sop.LastOwnerID, options); UUID ownerID = options.ContainsKey("wipe-owners") ? UUID.Zero : sop.OwnerID;
WriteUUID(writer, "OwnerID", ownerID, options);
UUID lastOwnerID = options.ContainsKey("wipe-owners") ? UUID.Zero : sop.LastOwnerID;
WriteUUID(writer, "LastOwnerID", lastOwnerID, options);
writer.WriteElementString("BaseMask", sop.BaseMask.ToString()); writer.WriteElementString("BaseMask", sop.BaseMask.ToString());
writer.WriteElementString("OwnerMask", sop.OwnerMask.ToString()); writer.WriteElementString("OwnerMask", sop.OwnerMask.ToString());
writer.WriteElementString("GroupMask", sop.GroupMask.ToString()); writer.WriteElementString("GroupMask", sop.GroupMask.ToString());
@ -1277,17 +1282,16 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
writer.WriteElementString("BasePermissions", item.BasePermissions.ToString()); writer.WriteElementString("BasePermissions", item.BasePermissions.ToString());
writer.WriteElementString("CreationDate", item.CreationDate.ToString()); writer.WriteElementString("CreationDate", item.CreationDate.ToString());
WriteUUID(writer, "CreatorID", item.CreatorID, options); WriteUUID(writer, "CreatorID", item.CreatorID, options);
if (item.CreatorData != null && item.CreatorData != string.Empty) if (item.CreatorData != null && item.CreatorData != string.Empty)
writer.WriteElementString("CreatorData", item.CreatorData); writer.WriteElementString("CreatorData", item.CreatorData);
else if (options.ContainsKey("profile")) else if (options.ContainsKey("home"))
{ {
if (m_UserManagement == null) if (m_UserManagement == null)
m_UserManagement = scene.RequestModuleInterface<IUserManagement>(); m_UserManagement = scene.RequestModuleInterface<IUserManagement>();
string name = m_UserManagement.GetUserName(item.CreatorID); string name = m_UserManagement.GetUserName(item.CreatorID);
writer.WriteElementString("CreatorData", (string)options["profile"] + "/" + item.CreatorID + ";" + name); writer.WriteElementString("CreatorData", (string)options["home"] + ";" + name);
} }
writer.WriteElementString("Description", item.Description); writer.WriteElementString("Description", item.Description);
@ -1298,10 +1302,16 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
writer.WriteElementString("InvType", item.InvType.ToString()); writer.WriteElementString("InvType", item.InvType.ToString());
WriteUUID(writer, "ItemID", item.ItemID, options); WriteUUID(writer, "ItemID", item.ItemID, options);
WriteUUID(writer, "OldItemID", item.OldItemID, options); WriteUUID(writer, "OldItemID", item.OldItemID, options);
WriteUUID(writer, "LastOwnerID", item.LastOwnerID, options);
UUID lastOwnerID = options.ContainsKey("wipe-owners") ? UUID.Zero : item.LastOwnerID;
WriteUUID(writer, "LastOwnerID", lastOwnerID, options);
writer.WriteElementString("Name", item.Name); writer.WriteElementString("Name", item.Name);
writer.WriteElementString("NextPermissions", item.NextPermissions.ToString()); writer.WriteElementString("NextPermissions", item.NextPermissions.ToString());
WriteUUID(writer, "OwnerID", item.OwnerID, options);
UUID ownerID = options.ContainsKey("wipe-owners") ? UUID.Zero : item.OwnerID;
WriteUUID(writer, "OwnerID", ownerID, options);
writer.WriteElementString("CurrentPermissions", item.CurrentPermissions.ToString()); writer.WriteElementString("CurrentPermissions", item.CurrentPermissions.ToString());
WriteUUID(writer, "ParentID", item.ParentID, options); WriteUUID(writer, "ParentID", item.ParentID, options);
WriteUUID(writer, "ParentPartID", item.ParentPartID, options); WriteUUID(writer, "ParentPartID", item.ParentPartID, options);

View File

@ -0,0 +1,76 @@
/*
* 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.Reflection;
using NUnit.Framework;
using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Framework.Communications;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Tests.Common;
using OpenSim.Tests.Common.Mock;
namespace OpenSim.Region.Framework.Scenes.Tests
{
[TestFixture]
public class SceneObjectScriptTests
{
[Test]
public void TestAddScript()
{
TestHelpers.InMethod();
// log4net.Config.XmlConfigurator.Configure();
UUID userId = TestHelpers.ParseTail(0x1);
UUID itemId = TestHelpers.ParseTail(0x2);
string itemName = "Test Script Item";
Scene scene = SceneHelpers.SetupScene();
SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId);
scene.AddNewSceneObject(so, true);
InventoryItemBase itemTemplate = new InventoryItemBase();
itemTemplate.Name = itemName;
itemTemplate.Folder = so.UUID;
itemTemplate.InvType = (int)InventoryType.LSL;
SceneObjectPart partWhereScriptAdded = scene.RezNewScript(userId, itemTemplate);
Assert.That(partWhereScriptAdded, Is.Not.Null);
IEntityInventory primInventory = partWhereScriptAdded.Inventory;
Assert.That(primInventory.GetInventoryList().Count, Is.EqualTo(1));
Assert.That(primInventory.ContainsScripts(), Is.True);
IList<TaskInventoryItem> primItems = primInventory.GetInventoryItems(itemName);
Assert.That(primItems.Count, Is.EqualTo(1));
}
}
}

View File

@ -658,6 +658,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
public event ModifyTerrain OnModifyTerrain; public event ModifyTerrain OnModifyTerrain;
public event BakeTerrain OnBakeTerrain; public event BakeTerrain OnBakeTerrain;
public event EstateChangeInfo OnEstateChangeInfo; public event EstateChangeInfo OnEstateChangeInfo;
public event EstateManageTelehub OnEstateManageTelehub;
public event SetAppearance OnSetAppearance; public event SetAppearance OnSetAppearance;
public event AvatarNowWearing OnAvatarNowWearing; public event AvatarNowWearing OnAvatarNowWearing;
public event RezSingleAttachmentFromInv OnRezSingleAttachmentFromInv; public event RezSingleAttachmentFromInv OnRezSingleAttachmentFromInv;
@ -1530,6 +1531,11 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
} }
public void SendTelehubInfo(UUID ObjectID, string ObjectName, Vector3 ObjectPos, Quaternion ObjectRot, List<Vector3> SpawnPoint)
{
}
public void SendMapItemReply(mapItemReply[] replies, uint mapitemtype, uint flags) public void SendMapItemReply(mapItemReply[] replies, uint mapitemtype, uint flags)
{ {

View File

@ -0,0 +1,155 @@
/*
* 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.Text;
using log4net;
using Mono.Addins;
using Nini.Config;
using OpenMetaverse;
using OpenMetaverse.Imaging;
using OpenSim.Framework;
using OpenSim.Framework.Console;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
namespace OpenSim.Region.OptionalModules.Agent.TextureSender
{
/// <summary>
/// Commands for the J2KDecoder module. For debugging purposes.
/// </summary>
/// <remarks>
/// Placed here so that they can be removed if not required and to keep the J2KDecoder module itself simple.
/// </remarks>
[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "J2KDecoderCommandModule")]
public class J2KDecoderCommandModule : ISharedRegionModule
{
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private Scene m_scene;
public string Name { get { return "Asset Information Module"; } }
public Type ReplaceableInterface { get { return null; } }
public void Initialise(IConfigSource source)
{
// m_log.DebugFormat("[J2K DECODER COMMAND MODULE]: INITIALIZED MODULE");
}
public void PostInitialise()
{
// m_log.DebugFormat("[J2K DECODER COMMAND MODULE]: POST INITIALIZED MODULE");
}
public void Close()
{
// m_log.DebugFormat("[J2K DECODER COMMAND MODULE]: CLOSED MODULE");
}
public void AddRegion(Scene scene)
{
// m_log.DebugFormat("[J2K DECODER COMMAND MODULE]: REGION {0} ADDED", scene.RegionInfo.RegionName);
}
public void RemoveRegion(Scene scene)
{
// m_log.DebugFormat("[J2K DECODER COMMAND MODULE]: REGION {0} REMOVED", scene.RegionInfo.RegionName);
}
public void RegionLoaded(Scene scene)
{
// m_log.DebugFormat("[J2K DECODER COMMAND MODULE]: REGION {0} LOADED", scene.RegionInfo.RegionName);
if (m_scene == null)
m_scene = scene;
MainConsole.Instance.Commands.AddCommand(
"j2k",
false,
"j2k decode",
"j2k decode <ID>",
"Do JPEG2000 decoding of an asset.",
"This is for debugging purposes. The asset id given must contain JPEG2000 data.",
HandleDecode);
}
void HandleDecode(string module, string[] args)
{
if (args.Length < 3)
{
MainConsole.Instance.Output("Usage is j2k decode <ID>");
return;
}
UUID assetId;
string rawAssetId = args[2];
if (!UUID.TryParse(rawAssetId, out assetId))
{
MainConsole.Instance.OutputFormat("ERROR: {0} is not a valid ID format", rawAssetId);
return;
}
AssetBase asset = m_scene.AssetService.Get(assetId.ToString());
if (asset == null)
{
MainConsole.Instance.OutputFormat("ERROR: No asset found with ID {0}", assetId);
return;
}
if (asset.Type != (sbyte)AssetType.Texture)
{
MainConsole.Instance.OutputFormat("ERROR: Asset {0} is not a texture type", assetId);
return;
}
IJ2KDecoder decoder = m_scene.RequestModuleInterface<IJ2KDecoder>();
if (decoder == null)
{
MainConsole.Instance.OutputFormat("ERROR: No IJ2KDecoder module available");
return;
}
OpenJPEG.J2KLayerInfo[] layers;
int components;
if (decoder.Decode(assetId, asset.Data, out layers, out components))
{
MainConsole.Instance.OutputFormat(
"Successfully decoded asset {0} with {1} layers and {2} components",
assetId, layers.Length, components);
}
else
{
MainConsole.Instance.OutputFormat("Decode of asset {0} failed", assetId);
}
}
}
}

View File

@ -81,13 +81,25 @@ namespace OpenSim.Region.CoreModules.UDP.Linden
lock (m_scenes) lock (m_scenes)
m_scenes[scene.RegionInfo.RegionID] = scene; m_scenes[scene.RegionInfo.RegionID] = scene;
scene.AddCommand(
this, "image queues clear",
"image queues clear <first-name> <last-name>",
"Clear the image queues (textures downloaded via UDP) for a particular client.",
(mod, cmd) => MainConsole.Instance.Output(HandleImageQueuesClear(cmd)));
scene.AddCommand(
this, "image queues show",
"image queues show <first-name> <last-name>",
"Show the image queues (textures downloaded via UDP) for a particular client.",
(mod, cmd) => MainConsole.Instance.Output(GetImageQueuesReport(cmd)));
scene.AddCommand( scene.AddCommand(
this, "show pqueues", this, "show pqueues",
"show pqueues [full]", "show pqueues [full]",
"Show priority queue data for each client", "Show priority queue data for each client",
"Without the 'full' option, only root agents are shown." "Without the 'full' option, only root agents are shown."
+ " With the 'full' option child agents are also shown.", + " With the 'full' option child agents are also shown.",
ShowPQueuesReport); (mod, cmd) => MainConsole.Instance.Output(GetPQueuesReport(cmd)));
scene.AddCommand( scene.AddCommand(
this, "show queues", this, "show queues",
@ -95,7 +107,13 @@ namespace OpenSim.Region.CoreModules.UDP.Linden
"Show queue data for each client", "Show queue data for each client",
"Without the 'full' option, only root agents are shown." "Without the 'full' option, only root agents are shown."
+ " With the 'full' option child agents are also shown.", + " With the 'full' option child agents are also shown.",
ShowQueuesReport); (mod, cmd) => MainConsole.Instance.Output(GetQueuesReport(cmd)));
scene.AddCommand(
this, "show image queues",
"show image queues <first-name> <last-name>",
"Show the image queues (textures downloaded via UDP) for a particular client.",
(mod, cmd) => MainConsole.Instance.Output(GetImageQueuesReport(cmd)));
scene.AddCommand( scene.AddCommand(
this, "show throttles", this, "show throttles",
@ -103,14 +121,14 @@ namespace OpenSim.Region.CoreModules.UDP.Linden
"Show throttle settings for each client and for the server overall", "Show throttle settings for each client and for the server overall",
"Without the 'full' option, only root agents are shown." "Without the 'full' option, only root agents are shown."
+ " With the 'full' option child agents are also shown.", + " With the 'full' option child agents are also shown.",
ShowThrottlesReport); (mod, cmd) => MainConsole.Instance.Output(GetThrottlesReport(cmd)));
scene.AddCommand( scene.AddCommand(
this, "emergency-monitoring", this, "emergency-monitoring",
"emergency-monitoring", "emergency-monitoring",
"Go on/off emergency monitoring mode", "Go on/off emergency monitoring mode",
"Go on/off emergency monitoring mode", "Go on/off emergency monitoring mode",
EmergencyMonitoring); HandleEmergencyMonitoring);
} }
public void RemoveRegion(Scene scene) public void RemoveRegion(Scene scene)
@ -126,22 +144,49 @@ namespace OpenSim.Region.CoreModules.UDP.Linden
// m_log.DebugFormat("[LINDEN UDP INFO MODULE]: REGION {0} LOADED", scene.RegionInfo.RegionName); // m_log.DebugFormat("[LINDEN UDP INFO MODULE]: REGION {0} LOADED", scene.RegionInfo.RegionName);
} }
protected void ShowPQueuesReport(string module, string[] cmd) protected string HandleImageQueuesClear(string[] cmd)
{ {
MainConsole.Instance.Output(GetPQueuesReport(cmd)); if (cmd.Length != 5)
return "Usage: image queues clear <first-name> <last-name>";
string firstName = cmd[3];
string lastName = cmd[4];
List<ScenePresence> foundAgents = new List<ScenePresence>();
lock (m_scenes)
{
foreach (Scene scene in m_scenes.Values)
{
ScenePresence sp = scene.GetScenePresence(firstName, lastName);
if (sp != null)
foundAgents.Add(sp);
}
} }
protected void ShowQueuesReport(string module, string[] cmd) if (foundAgents.Count == 0)
return string.Format("No agents found for {0} {1}", firstName, lastName);
StringBuilder report = new StringBuilder();
foreach (ScenePresence agent in foundAgents)
{ {
MainConsole.Instance.Output(GetQueuesReport(cmd)); LLClientView client = agent.ControllingClient as LLClientView;
if (client == null)
return "This command is only supported for LLClientView";
int requestsDeleted = client.ImageManager.ClearImageQueue();
report.AppendFormat(
"In region {0} ({1} agent) cleared {2} requests\n",
agent.Scene.RegionInfo.RegionName, agent.IsChildAgent ? "child" : "root", requestsDeleted);
} }
protected void ShowThrottlesReport(string module, string[] cmd) return report.ToString();
{
MainConsole.Instance.Output(GetThrottlesReport(cmd));
} }
protected void EmergencyMonitoring(string module, string[] cmd) protected void HandleEmergencyMonitoring(string module, string[] cmd)
{ {
bool mode = true; bool mode = true;
if (cmd.Length == 1 || (cmd.Length > 1 && cmd[1] == "on")) if (cmd.Length == 1 || (cmd.Length > 1 && cmd[1] == "on"))
@ -167,7 +212,6 @@ namespace OpenSim.Region.CoreModules.UDP.Linden
""); "");
} }
/// <summary> /// <summary>
/// Generate UDP Queue data report for each client /// Generate UDP Queue data report for each client
/// </summary> /// </summary>
@ -241,6 +285,73 @@ namespace OpenSim.Region.CoreModules.UDP.Linden
return report.ToString(); return report.ToString();
} }
/// <summary>
/// Generate an image queue report
/// </summary>
/// <param name="showParams"></param>
/// <returns></returns>
private string GetImageQueuesReport(string[] showParams)
{
if (showParams.Length < 5 || showParams.Length > 6)
return "Usage: image queues show <first-name> <last-name> [full]";
string firstName = showParams[3];
string lastName = showParams[4];
bool showChildAgents = showParams.Length == 6;
List<ScenePresence> foundAgents = new List<ScenePresence>();
lock (m_scenes)
{
foreach (Scene scene in m_scenes.Values)
{
ScenePresence sp = scene.GetScenePresence(firstName, lastName);
if (sp != null && (showChildAgents || !sp.IsChildAgent))
foundAgents.Add(sp);
}
}
if (foundAgents.Count == 0)
return string.Format("No agents found for {0} {1}", firstName, lastName);
StringBuilder report = new StringBuilder();
foreach (ScenePresence agent in foundAgents)
{
LLClientView client = agent.ControllingClient as LLClientView;
if (client == null)
return "This command is only supported for LLClientView";
J2KImage[] images = client.ImageManager.GetImages();
report.AppendFormat(
"In region {0} ({1} agent)\n",
agent.Scene.RegionInfo.RegionName, agent.IsChildAgent ? "child" : "root");
report.AppendFormat("Images in queue: {0}\n", images.Length);
if (images.Length > 0)
{
report.AppendFormat(
"{0,-36} {1,-8} {2,-10} {3,-9} {4,-9} {5,-7}\n",
"Texture ID",
"Last Seq",
"Priority",
"Start Pkt",
"Has Asset",
"Decoded");
foreach (J2KImage image in images)
report.AppendFormat(
"{0,36} {1,8} {2,10} {3,10} {4,9} {5,7}\n",
image.TextureID, image.LastSequence, image.Priority, image.StartPacket, image.HasAsset, image.IsDecoded);
}
}
return report.ToString();
}
/// <summary> /// <summary>
/// Generate UDP Queue data report for each client /// Generate UDP Queue data report for each client
/// </summary> /// </summary>

View File

@ -0,0 +1,185 @@
/*
* 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.Text;
using log4net;
using Mono.Addins;
using Nini.Config;
using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Framework.Console;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
namespace OpenSim.Region.OptionalModules.Asset
{
/// <summary>
/// A module that just holds commands for inspecting assets.
/// </summary>
[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "AssetInfoModule")]
public class AssetInfoModule : ISharedRegionModule
{
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private Scene m_scene;
public string Name { get { return "Asset Information Module"; } }
public Type ReplaceableInterface { get { return null; } }
public void Initialise(IConfigSource source)
{
// m_log.DebugFormat("[ASSET INFO MODULE]: INITIALIZED MODULE");
}
public void PostInitialise()
{
// m_log.DebugFormat("[ASSET INFO MODULE]: POST INITIALIZED MODULE");
}
public void Close()
{
// m_log.DebugFormat("[ASSET INFO MODULE]: CLOSED MODULE");
}
public void AddRegion(Scene scene)
{
// m_log.DebugFormat("[ASSET INFO MODULE]: REGION {0} ADDED", scene.RegionInfo.RegionName);
}
public void RemoveRegion(Scene scene)
{
// m_log.DebugFormat("[ASSET INFO MODULE]: REGION {0} REMOVED", scene.RegionInfo.RegionName);
}
public void RegionLoaded(Scene scene)
{
// m_log.DebugFormat("[ASSET INFO MODULE]: REGION {0} LOADED", scene.RegionInfo.RegionName);
if (m_scene == null)
m_scene = scene;
MainConsole.Instance.Commands.AddCommand(
"asset",
false,
"show asset",
"show asset <ID>",
"Show asset information",
HandleShowAsset);
MainConsole.Instance.Commands.AddCommand(
"asset", false, "dump asset",
"dump asset <id>",
"Dump an asset",
HandleDumpAsset);
}
void HandleDumpAsset(string module, string[] args)
{
if (args.Length < 3)
{
MainConsole.Instance.Output("Usage is dump asset <ID>");
return;
}
UUID assetId;
string rawAssetId = args[2];
if (!UUID.TryParse(rawAssetId, out assetId))
{
MainConsole.Instance.OutputFormat("ERROR: {0} is not a valid ID format", rawAssetId);
return;
}
AssetBase asset = m_scene.AssetService.Get(assetId.ToString());
if (asset == null)
{
MainConsole.Instance.OutputFormat("ERROR: No asset found with ID {0}", assetId);
return;
}
string fileName = rawAssetId;
using (FileStream fs = new FileStream(fileName, FileMode.CreateNew))
{
using (BinaryWriter bw = new BinaryWriter(fs))
{
bw.Write(asset.Data);
}
}
MainConsole.Instance.OutputFormat("Asset dumped to file {0}", fileName);
}
void HandleShowAsset(string module, string[] args)
{
if (args.Length < 3)
{
MainConsole.Instance.Output("Syntax: show asset <ID>");
return;
}
AssetBase asset = m_scene.AssetService.Get(args[2]);
if (asset == null || asset.Data.Length == 0)
{
MainConsole.Instance.Output("Asset not found");
return;
}
int i;
MainConsole.Instance.OutputFormat("Name: {0}", asset.Name);
MainConsole.Instance.OutputFormat("Description: {0}", asset.Description);
MainConsole.Instance.OutputFormat("Type: {0} (type number = {1})", (AssetType)asset.Type, asset.Type);
MainConsole.Instance.OutputFormat("Content-type: {0}", asset.Metadata.ContentType);
MainConsole.Instance.OutputFormat("Size: {0} bytes", asset.Data.Length);
MainConsole.Instance.OutputFormat("Temporary: {0}", asset.Temporary ? "yes" : "no");
MainConsole.Instance.OutputFormat("Flags: {0}", asset.Metadata.Flags);
for (i = 0 ; i < 5 ; i++)
{
int off = i * 16;
if (asset.Data.Length <= off)
break;
int len = 16;
if (asset.Data.Length < off + len)
len = asset.Data.Length - off;
byte[] line = new byte[len];
Array.Copy(asset.Data, off, line, 0, len);
string text = BitConverter.ToString(line);
MainConsole.Instance.Output(String.Format("{0:x4}: {1}", off, text));
}
}
}
}

View File

@ -27,6 +27,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Reflection; using System.Reflection;
using System.Text; using System.Text;
using log4net; using log4net;
@ -114,6 +115,23 @@ namespace OpenSim.Region.OptionalModules.Avatar.Appearance
"Send appearance data for each avatar in the simulator to other viewers.", "Send appearance data for each avatar in the simulator to other viewers.",
"Optionally, you can specify that only a particular avatar's appearance data is sent.", "Optionally, you can specify that only a particular avatar's appearance data is sent.",
HandleSendAppearanceCommand); HandleSendAppearanceCommand);
scene.AddCommand(
this, "appearance rebake",
"appearance rebake <first-name> <last-name>",
"Send a request to the user's viewer for it to rebake and reupload its appearance textures.",
"This is currently done for all baked texture references previously received, whether the simulator can find the asset or not."
+ "\nThis will only work for texture ids that the viewer has already uploaded."
+ "\nIf the viewer has not yet sent the server any texture ids then nothing will happen"
+ "\nsince requests can only be made for ids that the client has already sent us",
HandleRebakeAppearanceCommand);
scene.AddCommand(
this, "appearance find",
"appearance find <uuid-or-start-of-uuid>",
"Find out which avatar uses the given asset as a baked texture, if any.",
"You can specify just the beginning of the uuid, e.g. 2008a8d. A longer UUID must be in dashed format.",
HandleFindAppearanceCommand);
} }
private void HandleSendAppearanceCommand(string module, string[] cmd) private void HandleSendAppearanceCommand(string module, string[] cmd)
@ -211,5 +229,80 @@ namespace OpenSim.Region.OptionalModules.Avatar.Appearance
} }
} }
} }
private void HandleRebakeAppearanceCommand(string module, string[] cmd)
{
if (cmd.Length != 4)
{
MainConsole.Instance.OutputFormat("Usage: appearance rebake <first-name> <last-name>");
return;
}
string firstname = cmd[2];
string lastname = cmd[3];
lock (m_scenes)
{
foreach (Scene scene in m_scenes.Values)
{
ScenePresence sp = scene.GetScenePresence(firstname, lastname);
if (sp != null && !sp.IsChildAgent)
{
int rebakesRequested = scene.AvatarFactory.RequestRebake(sp, false);
if (rebakesRequested > 0)
MainConsole.Instance.OutputFormat(
"Requesting rebake of {0} uploaded textures for {1} in {2}",
rebakesRequested, sp.Name, scene.RegionInfo.RegionName);
else
MainConsole.Instance.OutputFormat(
"No texture IDs available for rebake request for {0} in {1}",
sp.Name, scene.RegionInfo.RegionName);
}
}
}
}
protected void HandleFindAppearanceCommand(string module, string[] cmd)
{
if (cmd.Length != 3)
{
MainConsole.Instance.OutputFormat("Usage: appearance find <uuid-or-start-of-uuid>");
return;
}
string rawUuid = cmd[2];
HashSet<ScenePresence> matchedAvatars = new HashSet<ScenePresence>();
lock (m_scenes)
{
foreach (Scene scene in m_scenes.Values)
{
scene.ForEachRootScenePresence(
sp =>
{
Dictionary<BakeType, Primitive.TextureEntryFace> bakedFaces = scene.AvatarFactory.GetBakedTextureFaces(sp.UUID);
foreach (Primitive.TextureEntryFace face in bakedFaces.Values)
{
if (face != null && face.TextureID.ToString().StartsWith(rawUuid))
matchedAvatars.Add(sp);
}
});
}
}
if (matchedAvatars.Count == 0)
{
MainConsole.Instance.OutputFormat("{0} did not match any baked avatar textures in use", rawUuid);
}
else
{
MainConsole.Instance.OutputFormat(
"{0} matched {1}",
rawUuid,
string.Join(", ", matchedAvatars.ToList().ConvertAll<string>(sp => sp.Name).ToArray()));
}
}
} }
} }

View File

@ -713,7 +713,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
if (money != null) if (money != null)
{ {
// do the transaction, that is if the agent has got sufficient funds // do the transaction, that is if the agent has got sufficient funds
if (!money.AmountCovered(remoteClient, money.GroupCreationCharge)) { if (!money.AmountCovered(remoteClient.AgentId, money.GroupCreationCharge)) {
remoteClient.SendCreateGroupReply(UUID.Zero, false, "You have got issuficient funds to create a group."); remoteClient.SendCreateGroupReply(UUID.Zero, false, "You have got issuficient funds to create a group.");
return UUID.Zero; return UUID.Zero;
} }

View File

@ -31,7 +31,6 @@ using OpenMetaverse.Assets;
namespace OpenSim.Region.OptionalModules.Scripting.Minimodule namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
{ {
/// <summary> /// <summary>
/// This implements the methods needed to operate on individual inventory items. /// This implements the methods needed to operate on individual inventory items.
/// </summary> /// </summary>
@ -39,6 +38,6 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
{ {
int Type { get; } int Type { get; }
UUID AssetID { get; } UUID AssetID { get; }
T RetrieveAsset<T>() where T : Asset, new(); T RetrieveAsset<T>() where T : OpenMetaverse.Assets.Asset, new();
} }
} }

View File

@ -44,12 +44,13 @@ using OpenSim.Region.Framework.Scenes;
namespace OpenSim.Region.OptionalModules.Scripting.RegionReady namespace OpenSim.Region.OptionalModules.Scripting.RegionReady
{ {
public class RegionReadyModule : INonSharedRegionModule public class RegionReadyModule : IRegionReadyModule, INonSharedRegionModule
{ {
private static readonly ILog m_log = private static readonly ILog m_log =
LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private IConfig m_config = null; private IConfig m_config = null;
private bool m_ScriptRez;
private bool m_firstEmptyCompileQueue; private bool m_firstEmptyCompileQueue;
private bool m_oarFileLoading; private bool m_oarFileLoading;
private bool m_lastOarLoadedOk; private bool m_lastOarLoadedOk;
@ -93,14 +94,17 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady
if (!m_enabled) if (!m_enabled)
return; return;
m_scene = scene;
m_scene.RegisterModuleInterface<IRegionReadyModule>(this);
m_ScriptRez = false;
m_firstEmptyCompileQueue = true; m_firstEmptyCompileQueue = true;
m_oarFileLoading = false; m_oarFileLoading = false;
m_lastOarLoadedOk = true; m_lastOarLoadedOk = true;
m_scene = scene;
m_scene.EventManager.OnEmptyScriptCompileQueue += OnEmptyScriptCompileQueue;
m_scene.EventManager.OnOarFileLoaded += OnOarFileLoaded; m_scene.EventManager.OnOarFileLoaded += OnOarFileLoaded;
m_scene.EventManager.OnRezScript += OnRezScript;
m_scene.EventManager.OnLoginsEnabled += OnLoginsEnabled; m_scene.EventManager.OnLoginsEnabled += OnLoginsEnabled;
m_log.DebugFormat("[RegionReady]: Enabled for region {0}", scene.RegionInfo.RegionName); m_log.DebugFormat("[RegionReady]: Enabled for region {0}", scene.RegionInfo.RegionName);
@ -118,6 +122,16 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady
} }
} }
void OnRezScript (uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine, int stateSource)
{
if (!m_ScriptRez)
{
m_ScriptRez = true;
m_scene.EventManager.OnEmptyScriptCompileQueue += OnEmptyScriptCompileQueue;
m_scene.EventManager.OnRezScript -= OnRezScript;
}
}
public void RemoveRegion(Scene scene) public void RemoveRegion(Scene scene)
{ {
if (!m_enabled) if (!m_enabled)
@ -125,6 +139,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady
m_scene.EventManager.OnEmptyScriptCompileQueue -= OnEmptyScriptCompileQueue; m_scene.EventManager.OnEmptyScriptCompileQueue -= OnEmptyScriptCompileQueue;
m_scene.EventManager.OnOarFileLoaded -= OnOarFileLoaded; m_scene.EventManager.OnOarFileLoaded -= OnOarFileLoaded;
m_scene.EventManager.OnLoginsEnabled -= OnLoginsEnabled;
if(m_uri != string.Empty) if(m_uri != string.Empty)
{ {
@ -149,8 +164,11 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady
#endregion #endregion
void OnEmptyScriptCompileQueue(int numScriptsFailed, string message) void OnEmptyScriptCompileQueue(int numScriptsFailed, string message)
{ {
m_log.InfoFormat("[RegionReady]: Script compile queue empty!");
if (m_firstEmptyCompileQueue || m_oarFileLoading) if (m_firstEmptyCompileQueue || m_oarFileLoading)
{ {
OSChatMessage c = new OSChatMessage(); OSChatMessage c = new OSChatMessage();
@ -197,6 +215,10 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady
} }
} }
// This will be triggerd by Scene if we have no scripts
// m_ScriptsRezzing will be false if there were none
// else it will be true and we should wait on the
// empty compile queue
void OnLoginsEnabled(string regionName) void OnLoginsEnabled(string regionName)
{ {
if (m_disable_logins == true) if (m_disable_logins == true)
@ -205,7 +227,12 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady
{ {
m_scene.LoginsDisabled = false; m_scene.LoginsDisabled = false;
m_scene.LoginLock = false; m_scene.LoginLock = false;
m_log.InfoFormat("[RegionReady]: Logins enabled for {0}", m_scene.RegionInfo.RegionName);
m_scene.EventManager.OnEmptyScriptCompileQueue -= OnEmptyScriptCompileQueue;
m_log.InfoFormat("[RegionReady]: Logins enabled for {0}, Oar {1}",
m_scene.RegionInfo.RegionName, m_oarFileLoading.ToString());
if ( m_uri != string.Empty ) if ( m_uri != string.Empty )
{ {
RRAlert("enabled"); RRAlert("enabled");
@ -214,6 +241,31 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady
} }
} }
public void OarLoadingAlert(string msg)
{
// Let's bypass this for now until some better feedback can be established
//
return;
if (msg == "load")
{
m_scene.EventManager.OnEmptyScriptCompileQueue += OnEmptyScriptCompileQueue;
m_scene.EventManager.OnOarFileLoaded += OnOarFileLoaded;
m_scene.EventManager.OnLoginsEnabled += OnLoginsEnabled;
m_scene.EventManager.OnRezScript += OnRezScript;
m_oarFileLoading = true;
m_firstEmptyCompileQueue = true;
m_scene.LoginsDisabled = true;
m_scene.LoginLock = true;
if ( m_uri != string.Empty )
{
RRAlert("loading oar");
RRAlert("disabled");
}
}
}
public void RRAlert(string status) public void RRAlert(string status)
{ {
string request_method = "POST"; string request_method = "POST";

View File

@ -775,11 +775,11 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule
// Please do not refactor these to be just one method // Please do not refactor these to be just one method
// Existing implementations need the distinction // Existing implementations need the distinction
// //
public bool UploadCovered(IClientAPI client, int amount) public bool UploadCovered(UUID agentID, int amount)
{ {
return true; return true;
} }
public bool AmountCovered(IClientAPI client, int amount) public bool AmountCovered(UUID agentID, int amount)
{ {
return true; return true;
} }

View File

@ -31,24 +31,32 @@ using System.Net;
using OpenMetaverse; using OpenMetaverse;
using OpenMetaverse.Packets; using OpenMetaverse.Packets;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.CoreModules.World.Estate;
namespace OpenSim.Region.OptionalModules.World.NPC namespace OpenSim.Region.OptionalModules.World.NPC
{ {
public class NPCAvatar : IClientAPI public class NPCAvatar : IClientAPI, INPC
{ {
public bool SenseAsAgent { get; set; }
private readonly string m_firstname; private readonly string m_firstname;
private readonly string m_lastname; private readonly string m_lastname;
private readonly Vector3 m_startPos; private readonly Vector3 m_startPos;
private readonly UUID m_uuid = UUID.Random(); private readonly UUID m_uuid = UUID.Random();
private readonly Scene m_scene; private readonly Scene m_scene;
private readonly UUID m_ownerID;
public NPCAvatar(string firstname, string lastname, Vector3 position, Scene scene) public NPCAvatar(
string firstname, string lastname, Vector3 position, UUID ownerID, bool senseAsAgent, Scene scene)
{ {
m_firstname = firstname; m_firstname = firstname;
m_lastname = lastname; m_lastname = lastname;
m_startPos = position; m_startPos = position;
m_scene = scene; m_scene = scene;
m_ownerID = ownerID;
SenseAsAgent = senseAsAgent;
} }
public IScene Scene public IScene Scene
@ -56,6 +64,11 @@ namespace OpenSim.Region.OptionalModules.World.NPC
get { return m_scene; } get { return m_scene; }
} }
public UUID OwnerID
{
get { return m_ownerID; }
}
public ISceneAgent SceneAgent { get { throw new NotImplementedException(); } } public ISceneAgent SceneAgent { get { throw new NotImplementedException(); } }
public void Say(string message) public void Say(string message)
@ -327,6 +340,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
public event EstateTeleportOneUserHomeRequest OnEstateTeleportOneUserHomeRequest; public event EstateTeleportOneUserHomeRequest OnEstateTeleportOneUserHomeRequest;
public event EstateTeleportAllUsersHomeRequest OnEstateTeleportAllUsersHomeRequest; public event EstateTeleportAllUsersHomeRequest OnEstateTeleportAllUsersHomeRequest;
public event EstateChangeInfo OnEstateChangeInfo; public event EstateChangeInfo OnEstateChangeInfo;
public event EstateManageTelehub OnEstateManageTelehub;
public event ScriptReset OnScriptReset; public event ScriptReset OnScriptReset;
public event GetScriptRunning OnGetScriptRunning; public event GetScriptRunning OnGetScriptRunning;
public event SetScriptRunning OnSetScriptRunning; public event SetScriptRunning OnSetScriptRunning;
@ -916,6 +930,9 @@ namespace OpenSim.Region.OptionalModules.World.NPC
public void SendEstateCovenantInformation(UUID covenant) public void SendEstateCovenantInformation(UUID covenant)
{ {
} }
public void SendTelehubInfo(UUID ObjectID, string ObjectName, Vector3 ObjectPos, Quaternion ObjectRot, List<Vector3> SpawnPoint)
{
}
public void SendDetailedEstateData(UUID invoice, string estateName, uint estateID, uint parentEstate, uint estateFlags, uint sunPosition, UUID covenant, string abuseEmail, UUID estateOwner) public void SendDetailedEstateData(UUID invoice, string estateName, uint estateID, uint parentEstate, uint estateFlags, uint sunPosition, UUID covenant, string abuseEmail, UUID estateOwner)
{ {
} }

View File

@ -56,6 +56,24 @@ namespace OpenSim.Region.OptionalModules.World.NPC
} }
} }
public void PostInitialise()
{
}
public void Close()
{
}
public string Name
{
get { return "NPCModule"; }
}
public bool IsSharedModule
{
get { return true; }
}
public bool IsNPC(UUID agentId, Scene scene) public bool IsNPC(UUID agentId, Scene scene)
{ {
// FIXME: This implementation could not just use the ScenePresence.PresenceType (and callers could inspect // FIXME: This implementation could not just use the ScenePresence.PresenceType (and callers could inspect
@ -91,9 +109,15 @@ namespace OpenSim.Region.OptionalModules.World.NPC
} }
public UUID CreateNPC( public UUID CreateNPC(
string firstname, string lastname, Vector3 position, Scene scene, AvatarAppearance appearance) string firstname,
string lastname,
Vector3 position,
UUID owner,
bool senseAsAgent,
Scene scene,
AvatarAppearance appearance)
{ {
NPCAvatar npcAvatar = new NPCAvatar(firstname, lastname, position, scene); NPCAvatar npcAvatar = new NPCAvatar(firstname, lastname, position, owner, senseAsAgent, scene);
npcAvatar.CircuitCode = (uint)Util.RandomClass.Next(0, int.MaxValue); npcAvatar.CircuitCode = (uint)Util.RandomClass.Next(0, int.MaxValue);
m_log.DebugFormat( m_log.DebugFormat(
@ -234,11 +258,37 @@ namespace OpenSim.Region.OptionalModules.World.NPC
return false; return false;
} }
public bool DeleteNPC(UUID agentID, Scene scene) public UUID GetOwner(UUID agentID)
{
lock (m_avatars)
{
NPCAvatar av;
if (m_avatars.TryGetValue(agentID, out av))
{
return av.OwnerID;
}
}
return UUID.Zero;
}
public INPC GetNPC(UUID agentID, Scene scene)
{ {
lock (m_avatars) lock (m_avatars)
{ {
if (m_avatars.ContainsKey(agentID)) if (m_avatars.ContainsKey(agentID))
return m_avatars[agentID];
else
return null;
}
}
public bool DeleteNPC(UUID agentID, Scene scene)
{
lock (m_avatars)
{
NPCAvatar av;
if (m_avatars.TryGetValue(agentID, out av))
{ {
scene.RemoveClient(agentID, false); scene.RemoveClient(agentID, false);
m_avatars.Remove(agentID); m_avatars.Remove(agentID);
@ -250,22 +300,27 @@ namespace OpenSim.Region.OptionalModules.World.NPC
return false; return false;
} }
public void PostInitialise() public bool CheckPermissions(UUID npcID, UUID callerID)
{ {
lock (m_avatars)
{
NPCAvatar av;
if (m_avatars.TryGetValue(npcID, out av))
return CheckPermissions(av, callerID);
else
return false;
}
} }
public void Close() /// <summary>
/// Check if the caller has permission to manipulate the given NPC.
/// </summary>
/// <param name="av"></param>
/// <param name="callerID"></param>
/// <returns>true if they do, false if they don't.</returns>
private bool CheckPermissions(NPCAvatar av, UUID callerID)
{ {
} return callerID == UUID.Zero || av.OwnerID == UUID.Zero || av.OwnerID == callerID;
public string Name
{
get { return "NPCModule"; }
}
public bool IsSharedModule
{
get { return true; }
} }
} }
} }

View File

@ -109,7 +109,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests
afm.SetAppearance(sp, originalTe, null); afm.SetAppearance(sp, originalTe, null);
INPCModule npcModule = scene.RequestModuleInterface<INPCModule>(); INPCModule npcModule = scene.RequestModuleInterface<INPCModule>();
UUID npcId = npcModule.CreateNPC("John", "Smith", new Vector3(128, 128, 30), scene, sp.Appearance); UUID npcId = npcModule.CreateNPC("John", "Smith", new Vector3(128, 128, 30), UUID.Zero, true, scene, sp.Appearance);
ScenePresence npc = scene.GetScenePresence(npcId); ScenePresence npc = scene.GetScenePresence(npcId);
@ -118,6 +118,26 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests
Assert.That(umm.GetUserName(npc.UUID), Is.EqualTo(string.Format("{0} {1}", npc.Firstname, npc.Lastname))); Assert.That(umm.GetUserName(npc.UUID), Is.EqualTo(string.Format("{0} {1}", npc.Firstname, npc.Lastname)));
} }
[Test]
public void TestRemove()
{
TestHelpers.InMethod();
// log4net.Config.XmlConfigurator.Configure();
ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1));
// ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId);
Vector3 startPos = new Vector3(128, 128, 30);
INPCModule npcModule = scene.RequestModuleInterface<INPCModule>();
UUID npcId = npcModule.CreateNPC("John", "Smith", startPos, UUID.Zero, true, scene, sp.Appearance);
npcModule.DeleteNPC(npcId, scene);
ScenePresence deletedNpc = scene.GetScenePresence(npcId);
Assert.That(deletedNpc, Is.Null);
}
[Test] [Test]
public void TestAttachments() public void TestAttachments()
{ {
@ -137,7 +157,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests
am.RezSingleAttachmentFromInventory(sp, attItemId, (uint)AttachmentPoint.Chest); am.RezSingleAttachmentFromInventory(sp, attItemId, (uint)AttachmentPoint.Chest);
INPCModule npcModule = scene.RequestModuleInterface<INPCModule>(); INPCModule npcModule = scene.RequestModuleInterface<INPCModule>();
UUID npcId = npcModule.CreateNPC("John", "Smith", new Vector3(128, 128, 30), scene, sp.Appearance); UUID npcId = npcModule.CreateNPC("John", "Smith", new Vector3(128, 128, 30), UUID.Zero, true, scene, sp.Appearance);
ScenePresence npc = scene.GetScenePresence(npcId); ScenePresence npc = scene.GetScenePresence(npcId);
@ -169,7 +189,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests
Vector3 startPos = new Vector3(128, 128, 30); Vector3 startPos = new Vector3(128, 128, 30);
INPCModule npcModule = scene.RequestModuleInterface<INPCModule>(); INPCModule npcModule = scene.RequestModuleInterface<INPCModule>();
UUID npcId = npcModule.CreateNPC("John", "Smith", startPos, scene, sp.Appearance); UUID npcId = npcModule.CreateNPC("John", "Smith", startPos, UUID.Zero, true, scene, sp.Appearance);
ScenePresence npc = scene.GetScenePresence(npcId); ScenePresence npc = scene.GetScenePresence(npcId);
Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos)); Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos));
@ -240,7 +260,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests
Vector3 startPos = new Vector3(128, 128, 30); Vector3 startPos = new Vector3(128, 128, 30);
INPCModule npcModule = scene.RequestModuleInterface<INPCModule>(); INPCModule npcModule = scene.RequestModuleInterface<INPCModule>();
UUID npcId = npcModule.CreateNPC("John", "Smith", startPos, scene, sp.Appearance); UUID npcId = npcModule.CreateNPC("John", "Smith", startPos, UUID.Zero, true, scene, sp.Appearance);
ScenePresence npc = scene.GetScenePresence(npcId); ScenePresence npc = scene.GetScenePresence(npcId);
SceneObjectPart part = SceneHelpers.AddSceneObject(scene); SceneObjectPart part = SceneHelpers.AddSceneObject(scene);
@ -273,7 +293,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests
Vector3 startPos = new Vector3(1, 1, 1); Vector3 startPos = new Vector3(1, 1, 1);
INPCModule npcModule = scene.RequestModuleInterface<INPCModule>(); INPCModule npcModule = scene.RequestModuleInterface<INPCModule>();
UUID npcId = npcModule.CreateNPC("John", "Smith", startPos, scene, sp.Appearance); UUID npcId = npcModule.CreateNPC("John", "Smith", startPos, UUID.Zero, true, scene, sp.Appearance);
ScenePresence npc = scene.GetScenePresence(npcId); ScenePresence npc = scene.GetScenePresence(npcId);
SceneObjectPart part = SceneHelpers.AddSceneObject(scene); SceneObjectPart part = SceneHelpers.AddSceneObject(scene);

View File

@ -72,6 +72,8 @@ public class BSScene : PhysicsScene, IPhysicsParameters
private bool m_initialized = false; private bool m_initialized = false;
private int m_detailedStatsStep = 0;
public IMesher mesher; public IMesher mesher;
private float m_meshLOD; private float m_meshLOD;
public float MeshLOD public float MeshLOD
@ -192,6 +194,8 @@ public class BSScene : PhysicsScene, IPhysicsParameters
m_meshLOD = 8f; m_meshLOD = 8f;
m_sculptLOD = 32f; m_sculptLOD = 32f;
m_detailedStatsStep = 0; // disabled
m_maxSubSteps = 10; m_maxSubSteps = 10;
m_fixedTimeStep = 1f / 60f; m_fixedTimeStep = 1f / 60f;
m_maxCollisionsPerFrame = 2048; m_maxCollisionsPerFrame = 2048;
@ -209,8 +213,9 @@ public class BSScene : PhysicsScene, IPhysicsParameters
parms.deactivationTime = 0.2f; parms.deactivationTime = 0.2f;
parms.linearSleepingThreshold = 0.8f; parms.linearSleepingThreshold = 0.8f;
parms.angularSleepingThreshold = 1.0f; parms.angularSleepingThreshold = 1.0f;
parms.ccdMotionThreshold = 0.5f; // set to zero to disable parms.ccdMotionThreshold = 0.0f; // set to zero to disable
parms.ccdSweptSphereRadius = 0.2f; parms.ccdSweptSphereRadius = 0.0f;
parms.contactProcessingThreshold = 0.1f;
parms.terrainFriction = 0.5f; parms.terrainFriction = 0.5f;
parms.terrainHitFraction = 0.8f; parms.terrainHitFraction = 0.8f;
@ -231,6 +236,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters
_meshSculptedPrim = pConfig.GetBoolean("MeshSculptedPrim", _meshSculptedPrim); _meshSculptedPrim = pConfig.GetBoolean("MeshSculptedPrim", _meshSculptedPrim);
_forceSimplePrimMeshing = pConfig.GetBoolean("ForceSimplePrimMeshing", _forceSimplePrimMeshing); _forceSimplePrimMeshing = pConfig.GetBoolean("ForceSimplePrimMeshing", _forceSimplePrimMeshing);
m_detailedStatsStep = pConfig.GetInt("DetailedStatsStep", m_detailedStatsStep);
m_meshLOD = pConfig.GetFloat("MeshLevelOfDetail", m_meshLOD); m_meshLOD = pConfig.GetFloat("MeshLevelOfDetail", m_meshLOD);
m_sculptLOD = pConfig.GetFloat("SculptLevelOfDetail", m_sculptLOD); m_sculptLOD = pConfig.GetFloat("SculptLevelOfDetail", m_sculptLOD);
@ -253,6 +259,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters
parms.angularSleepingThreshold = pConfig.GetFloat("AngularSleepingThreshold", parms.angularSleepingThreshold); parms.angularSleepingThreshold = pConfig.GetFloat("AngularSleepingThreshold", parms.angularSleepingThreshold);
parms.ccdMotionThreshold = pConfig.GetFloat("CcdMotionThreshold", parms.ccdMotionThreshold); parms.ccdMotionThreshold = pConfig.GetFloat("CcdMotionThreshold", parms.ccdMotionThreshold);
parms.ccdSweptSphereRadius = pConfig.GetFloat("CcdSweptSphereRadius", parms.ccdSweptSphereRadius); parms.ccdSweptSphereRadius = pConfig.GetFloat("CcdSweptSphereRadius", parms.ccdSweptSphereRadius);
parms.contactProcessingThreshold = pConfig.GetFloat("ContactProcessingThreshold", parms.contactProcessingThreshold);
parms.terrainFriction = pConfig.GetFloat("TerrainFriction", parms.terrainFriction); parms.terrainFriction = pConfig.GetFloat("TerrainFriction", parms.terrainFriction);
parms.terrainHitFraction = pConfig.GetFloat("TerrainHitFraction", parms.terrainHitFraction); parms.terrainHitFraction = pConfig.GetFloat("TerrainHitFraction", parms.terrainHitFraction);
@ -398,6 +405,14 @@ public class BSScene : PhysicsScene, IPhysicsParameters
} }
} }
if (m_detailedStatsStep > 0)
{
if ((m_simulationStep % m_detailedStatsStep) == 0)
{
BulletSimAPI.DumpBulletStatistics();
}
}
// TODO: FIX THIS: fps calculation wrong. This calculation always returns about 1 in normal operation. // TODO: FIX THIS: fps calculation wrong. This calculation always returns about 1 in normal operation.
return timeStep / (numSubSteps * m_fixedTimeStep) * 1000f; return timeStep / (numSubSteps * m_fixedTimeStep) * 1000f;
} }
@ -671,6 +686,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters
new PhysParameterEntry("MaxSubStep", "In simulation step, maximum number of substeps"), new PhysParameterEntry("MaxSubStep", "In simulation step, maximum number of substeps"),
new PhysParameterEntry("FixedTimeStep", "In simulation step, seconds of one substep (1/60)"), new PhysParameterEntry("FixedTimeStep", "In simulation step, seconds of one substep (1/60)"),
new PhysParameterEntry("MaxObjectMass", "Maximum object mass (10000.01)"), new PhysParameterEntry("MaxObjectMass", "Maximum object mass (10000.01)"),
new PhysParameterEntry("DetailedStats", "Frames between outputting detailed phys stats. Zero is off"),
new PhysParameterEntry("DefaultFriction", "Friction factor used on new objects"), new PhysParameterEntry("DefaultFriction", "Friction factor used on new objects"),
new PhysParameterEntry("DefaultDensity", "Density for new objects" ), new PhysParameterEntry("DefaultDensity", "Density for new objects" ),
@ -685,6 +701,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters
new PhysParameterEntry("AngularSleepingThreshold", "Seconds to measure angular movement before considering static" ), new PhysParameterEntry("AngularSleepingThreshold", "Seconds to measure angular movement before considering static" ),
// new PhysParameterEntry("CcdMotionThreshold", "" ), // new PhysParameterEntry("CcdMotionThreshold", "" ),
// new PhysParameterEntry("CcdSweptSphereRadius", "" ), // new PhysParameterEntry("CcdSweptSphereRadius", "" ),
new PhysParameterEntry("ContactProcessingThreshold", "Distance between contacts before doing collision check" ),
new PhysParameterEntry("TerrainFriction", "Factor to reduce movement against terrain surface" ), new PhysParameterEntry("TerrainFriction", "Factor to reduce movement against terrain surface" ),
new PhysParameterEntry("TerrainHitFraction", "Distance to measure hit collisions" ), new PhysParameterEntry("TerrainHitFraction", "Distance to measure hit collisions" ),
@ -715,6 +732,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters
string lparm = parm.ToLower(); string lparm = parm.ToLower();
switch (lparm) switch (lparm)
{ {
case "detailedstats": m_detailedStatsStep = (int)val; break;
case "meshlod": m_meshLOD = (int)val; break; case "meshlod": m_meshLOD = (int)val; break;
case "sculptlod": m_sculptLOD = (int)val; break; case "sculptlod": m_sculptLOD = (int)val; break;
case "maxsubstep": m_maxSubSteps = (int)val; break; case "maxsubstep": m_maxSubSteps = (int)val; break;
@ -734,6 +752,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters
case "angularsleepingthreshold": UpdateParameterPrims(ref m_params[0].angularDamping, lparm, localID, val); break; case "angularsleepingthreshold": UpdateParameterPrims(ref m_params[0].angularDamping, lparm, localID, val); break;
case "ccdmotionthreshold": UpdateParameterPrims(ref m_params[0].ccdMotionThreshold, lparm, localID, val); break; case "ccdmotionthreshold": UpdateParameterPrims(ref m_params[0].ccdMotionThreshold, lparm, localID, val); break;
case "ccdsweptsphereradius": UpdateParameterPrims(ref m_params[0].ccdSweptSphereRadius, lparm, localID, val); break; case "ccdsweptsphereradius": UpdateParameterPrims(ref m_params[0].ccdSweptSphereRadius, lparm, localID, val); break;
case "contactprocessingthreshold": UpdateParameterPrims(ref m_params[0].contactProcessingThreshold, lparm, localID, val); break;
// set a terrain physical feature and cause terrain to be recalculated // set a terrain physical feature and cause terrain to be recalculated
case "terrainfriction": m_params[0].terrainFriction = val; TaintedUpdateParameter("terrain", 0, val); break; case "terrainfriction": m_params[0].terrainFriction = val; TaintedUpdateParameter("terrain", 0, val); break;
@ -816,6 +835,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters
bool ret = true; bool ret = true;
switch (parm.ToLower()) switch (parm.ToLower())
{ {
case "detailedstats": val = (int)m_detailedStatsStep; break;
case "meshlod": val = (float)m_meshLOD; break; case "meshlod": val = (float)m_meshLOD; break;
case "sculptlod": val = (float)m_sculptLOD; break; case "sculptlod": val = (float)m_sculptLOD; break;
case "maxsubstep": val = (float)m_maxSubSteps; break; case "maxsubstep": val = (float)m_maxSubSteps; break;
@ -835,6 +855,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters
case "angularsleepingthreshold": val = m_params[0].angularDamping; break; case "angularsleepingthreshold": val = m_params[0].angularDamping; break;
case "ccdmotionthreshold": val = m_params[0].ccdMotionThreshold; break; case "ccdmotionthreshold": val = m_params[0].ccdMotionThreshold; break;
case "ccdsweptsphereradius": val = m_params[0].ccdSweptSphereRadius; break; case "ccdsweptsphereradius": val = m_params[0].ccdSweptSphereRadius; break;
case "contactprocessingthreshold": val = m_params[0].contactProcessingThreshold; break;
case "terrainfriction": val = m_params[0].terrainFriction; break; case "terrainfriction": val = m_params[0].terrainFriction; break;
case "terrainhitfraction": val = m_params[0].terrainHitFraction; break; case "terrainhitfraction": val = m_params[0].terrainHitFraction; break;

View File

@ -122,6 +122,7 @@ public struct ConfigurationParameters
public float angularSleepingThreshold; public float angularSleepingThreshold;
public float ccdMotionThreshold; public float ccdMotionThreshold;
public float ccdSweptSphereRadius; public float ccdSweptSphereRadius;
public float contactProcessingThreshold;
public float terrainFriction; public float terrainFriction;
public float terrainHitFraction; public float terrainHitFraction;
@ -248,6 +249,9 @@ public static extern RaycastHit RayTest(uint worldID, uint id, Vector3 from, Vec
[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
public static extern Vector3 RecoverFromPenetration(uint worldID, uint id); public static extern Vector3 RecoverFromPenetration(uint worldID, uint id);
[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
public static extern void DumpBulletStatistics();
// Log a debug message // Log a debug message
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate void DebugLogCallback([MarshalAs(UnmanagedType.LPStr)]string msg); public delegate void DebugLogCallback([MarshalAs(UnmanagedType.LPStr)]string msg);

View File

@ -134,9 +134,18 @@ namespace OpenSim.Region.Physics.OdePlugin
| CollisionCategories.Body | CollisionCategories.Body
| CollisionCategories.Character | CollisionCategories.Character
| CollisionCategories.Land); | CollisionCategories.Land);
internal IntPtr Body = IntPtr.Zero; /// <summary>
/// Body for dynamics simulation
/// </summary>
internal IntPtr Body { get; private set; }
private OdeScene _parent_scene; private OdeScene _parent_scene;
internal IntPtr Shell = IntPtr.Zero;
/// <summary>
/// Collision geometry
/// </summary>
internal IntPtr Shell { get; private set; }
private IntPtr Amotor = IntPtr.Zero; private IntPtr Amotor = IntPtr.Zero;
private d.Mass ShellMass; private d.Mass ShellMass;
@ -1018,6 +1027,13 @@ namespace OpenSim.Region.Physics.OdePlugin
/// <param name="tensor"></param> /// <param name="tensor"></param>
private void CreateOdeStructures(float npositionX, float npositionY, float npositionZ, float tensor) private void CreateOdeStructures(float npositionX, float npositionY, float npositionZ, float tensor)
{ {
if (!(Shell == IntPtr.Zero && Body == IntPtr.Zero && Amotor == IntPtr.Zero))
{
m_log.ErrorFormat(
"[ODE CHARACTER]: Creating ODE structures for {0} even though some already exist. Shell = {1}, Body = {2}, Amotor = {3}",
Name, Shell, Body, Amotor);
}
int dAMotorEuler = 1; int dAMotorEuler = 1;
// _parent_scene.waitForSpaceUnlock(_parent_scene.space); // _parent_scene.waitForSpaceUnlock(_parent_scene.space);
if (CAPSULE_LENGTH <= 0) if (CAPSULE_LENGTH <= 0)
@ -1032,6 +1048,7 @@ namespace OpenSim.Region.Physics.OdePlugin
CAPSULE_RADIUS = 0.01f; CAPSULE_RADIUS = 0.01f;
} }
// lock (OdeScene.UniversalColliderSyncObject)
Shell = d.CreateCapsule(_parent_scene.space, CAPSULE_RADIUS, CAPSULE_LENGTH); Shell = d.CreateCapsule(_parent_scene.space, CAPSULE_RADIUS, CAPSULE_LENGTH);
d.GeomSetCategoryBits(Shell, (int)m_collisionCategories); d.GeomSetCategoryBits(Shell, (int)m_collisionCategories);
@ -1135,6 +1152,14 @@ namespace OpenSim.Region.Physics.OdePlugin
/// </summary> /// </summary>
internal void DestroyOdeStructures() internal void DestroyOdeStructures()
{ {
// Create avatar capsule and related ODE data
if (Shell == IntPtr.Zero || Body == IntPtr.Zero || Amotor == IntPtr.Zero)
{
m_log.ErrorFormat(
"[ODE CHARACTER]: Destroying ODE structures for {0} even though some are already null. Shell = {1}, Body = {2}, Amotor = {3}",
Name, Shell, Body, Amotor);
}
// destroy avatar capsule and related ODE data // destroy avatar capsule and related ODE data
if (Amotor != IntPtr.Zero) if (Amotor != IntPtr.Zero)
{ {
@ -1155,7 +1180,9 @@ namespace OpenSim.Region.Physics.OdePlugin
if (Shell != IntPtr.Zero) if (Shell != IntPtr.Zero)
{ {
// lock (OdeScene.UniversalColliderSyncObject)
d.GeomDestroy(Shell); d.GeomDestroy(Shell);
_parent_scene.geom_name_map.Remove(Shell); _parent_scene.geom_name_map.Remove(Shell);
_parent_scene.actor_name_map.Remove(Shell); _parent_scene.actor_name_map.Remove(Shell);
@ -1260,15 +1287,6 @@ namespace OpenSim.Region.Physics.OdePlugin
{ {
if (m_tainted_isPhysical) if (m_tainted_isPhysical)
{ {
// Create avatar capsule and related ODE data
if (!(Shell == IntPtr.Zero && Body == IntPtr.Zero && Amotor == IntPtr.Zero))
{
m_log.Warn("[ODE CHARACTER]: re-creating the following avatar ODE data for " + Name + ", even though it already exists - "
+ (Shell!=IntPtr.Zero ? "Shell ":"")
+ (Body!=IntPtr.Zero ? "Body ":"")
+ (Amotor!=IntPtr.Zero ? "Amotor ":""));
}
CreateOdeStructures(_position.X, _position.Y, _position.Z, m_tensor); CreateOdeStructures(_position.X, _position.Y, _position.Z, m_tensor);
_parent_scene.AddCharacter(this); _parent_scene.AddCharacter(this);
} }

View File

@ -105,6 +105,32 @@ namespace OpenSim.Region.Physics.OdePlugin
private readonly ILog m_log; private readonly ILog m_log;
// private Dictionary<string, sCollisionData> m_storedCollisions = new Dictionary<string, sCollisionData>(); // private Dictionary<string, sCollisionData> m_storedCollisions = new Dictionary<string, sCollisionData>();
/// <summary>
/// Provide a sync object so that only one thread calls d.Collide() at a time across all OdeScene instances.
/// </summary>
/// <remarks>
/// With ODE as of r1755 (though also tested on r1860), only one thread can call d.Collide() at a
/// time, even where physics objects are in entirely different ODE worlds. This is because generating contacts
/// uses a static cache at the ODE level.
///
/// Without locking, simulators running multiple regions will eventually crash with a native stack trace similar
/// to
///
/// mono() [0x489171]
/// mono() [0x4d154f]
/// /lib/x86_64-linux-gnu/libpthread.so.0(+0xfc60) [0x7f6ded592c60]
/// .../opensim/bin/libode-x86_64.so(_ZN6Opcode11OBBCollider8_CollideEPKNS_14AABBNoLeafNodeE+0xd7a) [0x7f6dd822628a]
///
/// ODE provides an experimental option to cache in thread local storage but compiling ODE with this option
/// causes OpenSimulator to immediately crash with a native stack trace similar to
///
/// mono() [0x489171]
/// mono() [0x4d154f]
/// /lib/x86_64-linux-gnu/libpthread.so.0(+0xfc60) [0x7f03c9849c60]
/// .../opensim/bin/libode-x86_64.so(_Z12dCollideCCTLP6dxGeomS0_iP12dContactGeomi+0x92) [0x7f03b44bcf82]
/// </remarks>
internal static Object UniversalColliderSyncObject = new Object();
private Random fluidRandomizer = new Random(Environment.TickCount); private Random fluidRandomizer = new Random(Environment.TickCount);
private const uint m_regionWidth = Constants.RegionSize; private const uint m_regionWidth = Constants.RegionSize;
@ -799,7 +825,9 @@ namespace OpenSim.Region.Physics.OdePlugin
if (b1 != IntPtr.Zero && b2 != IntPtr.Zero && d.AreConnectedExcluding(b1, b2, d.JointType.Contact)) if (b1 != IntPtr.Zero && b2 != IntPtr.Zero && d.AreConnectedExcluding(b1, b2, d.JointType.Contact))
return; return;
lock (OdeScene.UniversalColliderSyncObject)
count = d.Collide(g1, g2, contacts.Length, contacts, d.ContactGeom.SizeOf); count = d.Collide(g1, g2, contacts.Length, contacts, d.ContactGeom.SizeOf);
if (count > contacts.Length) if (count > contacts.Length)
m_log.Error("[ODE SCENE]: Got " + count + " contacts when we asked for a maximum of " + contacts.Length); m_log.Error("[ODE SCENE]: Got " + count + " contacts when we asked for a maximum of " + contacts.Length);
} }
@ -1525,7 +1553,7 @@ namespace OpenSim.Region.Physics.OdePlugin
chr.CollidingGround = false; chr.CollidingGround = false;
chr.CollidingObj = false; chr.CollidingObj = false;
// test the avatar's geometry for collision with the space // Test the avatar's geometry for collision with the space
// This will return near and the space that they are the closest to // This will return near and the space that they are the closest to
// And we'll run this again against the avatar and the space segment // And we'll run this again against the avatar and the space segment
// This will return with a bunch of possible objects in the space segment // This will return with a bunch of possible objects in the space segment

View File

@ -42,10 +42,6 @@ namespace OpenSim.Region.ScriptEngine.Interfaces
/// An interface for a script API module to communicate with /// An interface for a script API module to communicate with
/// the engine it's running under /// the engine it's running under
/// </summary> /// </summary>
public delegate void ScriptRemoved(UUID script);
public delegate void ObjectRemoved(UUID prim);
public interface IScriptEngine public interface IScriptEngine
{ {
/// <summary> /// <summary>
@ -57,9 +53,6 @@ namespace OpenSim.Region.ScriptEngine.Interfaces
IScriptModule ScriptModule { get; } IScriptModule ScriptModule { get; }
event ScriptRemoved OnScriptRemoved;
event ObjectRemoved OnObjectRemoved;
/// <summary> /// <summary>
/// Post an event to a single script /// Post an event to a single script
/// </summary> /// </summary>

View File

@ -126,11 +126,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
m_TransferModule = m_TransferModule =
m_ScriptEngine.World.RequestModuleInterface<IMessageTransferModule>(); m_ScriptEngine.World.RequestModuleInterface<IMessageTransferModule>();
m_UrlModule = m_ScriptEngine.World.RequestModuleInterface<IUrlModule>(); m_UrlModule = m_ScriptEngine.World.RequestModuleInterface<IUrlModule>();
if (m_UrlModule != null)
{
m_ScriptEngine.OnScriptRemoved += m_UrlModule.ScriptRemoved;
m_ScriptEngine.OnObjectRemoved += m_UrlModule.ObjectRemoved;
}
AsyncCommands = new AsyncCommandManager(ScriptEngine); AsyncCommands = new AsyncCommandManager(ScriptEngine);
} }
@ -468,26 +463,31 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
//Now we start getting into quaternions which means sin/cos, matrices and vectors. ckrinke //Now we start getting into quaternions which means sin/cos, matrices and vectors. ckrinke
// Old implementation of llRot2Euler. Normalization not required as Atan2 function will /// <summary>
// only return values >= -PI (-180 degrees) and <= PI (180 degrees). /// Convert an LSL rotation to a Euler vector.
/// </summary>
/// <remarks>
/// Using algorithm based off http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToEuler/quat_2_euler_paper_ver2-1.pdf
/// to avoid issues with singularity and rounding with Y rotation of +/- PI/2
/// </remarks>
/// <param name="r"></param>
/// <returns></returns>
public LSL_Vector llRot2Euler(LSL_Rotation r) public LSL_Vector llRot2Euler(LSL_Rotation r)
{ {
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
//This implementation is from http://lslwiki.net/lslwiki/wakka.php?wakka=LibraryRotationFunctions. ckrinke
LSL_Rotation t = new LSL_Rotation(r.x * r.x, r.y * r.y, r.z * r.z, r.s * r.s); LSL_Vector v = new LSL_Vector(0.0, 0.0, 1.0) * r; // Z axis unit vector unaffected by Z rotation component of r.
double m = (t.x + t.y + t.z + t.s); double m = LSL_Vector.Mag(v); // Just in case v isn't normalized, need magnitude for Asin() operation later.
if (m == 0) return new LSL_Vector(); if (m == 0.0) return new LSL_Vector();
double n = 2 * (r.y * r.s + r.x * r.z); double x = Math.Atan2(-v.y, v.z);
double p = m * m - n * n; double sin = v.x / m;
if (p > 0) if (sin < -0.999999 || sin > 0.999999) x = 0.0; // Force X rotation to 0 at the singularities.
return new LSL_Vector(Math.Atan2(2.0 * (r.x * r.s - r.y * r.z), (-t.x - t.y + t.z + t.s)), double y = Math.Asin(sin);
Math.Atan2(n, Math.Sqrt(p)), // Rotate X axis unit vector by r and unwind the X and Y rotations leaving only the Z rotation
Math.Atan2(2.0 * (r.z * r.s - r.x * r.y), (t.x - t.y - t.z + t.s))); v = new LSL_Vector(1.0, 0.0, 0.0) * ((r * new LSL_Rotation(Math.Sin(-x / 2.0), 0.0, 0.0, Math.Cos(-x / 2.0))) * new LSL_Rotation(0.0, Math.Sin(-y / 2.0), 0.0, Math.Cos(-y / 2.0)));
else if (n > 0) double z = Math.Atan2(v.y, v.x);
return new LSL_Vector(0.0, Math.PI * 0.5, Math.Atan2((r.z * r.s + r.x * r.y), 0.5 - t.x - t.z));
else return new LSL_Vector(x, y, z);
return new LSL_Vector(0.0, -Math.PI * 0.5, Math.Atan2((r.z * r.s + r.x * r.y), 0.5 - t.x - t.z));
} }
/* From wiki: /* From wiki:
@ -2856,11 +2856,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
// we need to convert from a vector describing // we need to convert from a vector describing
// the angles of rotation in radians into rotation value // the angles of rotation in radians into rotation value
LSL_Types.Quaternion rot = llEuler2Rot(angle); LSL_Rotation rot = llEuler2Rot(angle);
Quaternion rotation = new Quaternion((float)rot.x, (float)rot.y, (float)rot.z, (float)rot.s);
m_host.startLookAt(rotation, (float)damping, (float)strength); // Per discussion with Melanie, for non-physical objects llLookAt appears to simply
// Orient the object to the angle calculated // set the rotation of the object, copy that behavior
//llSetRot(rot); if (strength == 0 || m_host.PhysActor == null || !m_host.PhysActor.IsPhysical)
{
llSetRot(rot);
}
else
{
m_host.StartLookAt(Rot2Quaternion(rot), (float)strength, (float)damping);
}
} }
public void llStopLookAt() public void llStopLookAt()
@ -3236,8 +3243,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public void llRotLookAt(LSL_Rotation target, double strength, double damping) public void llRotLookAt(LSL_Rotation target, double strength, double damping)
{ {
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
Quaternion rot = new Quaternion((float)target.x, (float)target.y, (float)target.z, (float)target.s);
m_host.RotLookAt(rot, (float)strength, (float)damping); // Per discussion with Melanie, for non-physical objects llLookAt appears to simply
// set the rotation of the object, copy that behavior
if (strength == 0 || m_host.PhysActor == null || !m_host.PhysActor.IsPhysical)
{
llSetLocalRot(target);
}
else
{
m_host.RotLookAt(Rot2Quaternion(target), (float)strength, (float)damping);
}
} }
public LSL_Integer llStringLength(string str) public LSL_Integer llStringLength(string str)
@ -4023,9 +4039,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
Vector3 av3 = new Vector3(Util.Clip((float)color.x, 0.0f, 1.0f), Vector3 av3 = new Vector3(Util.Clip((float)color.x, 0.0f, 1.0f),
Util.Clip((float)color.y, 0.0f, 1.0f), Util.Clip((float)color.y, 0.0f, 1.0f),
Util.Clip((float)color.z, 0.0f, 1.0f)); Util.Clip((float)color.z, 0.0f, 1.0f));
m_host.SetText(text, av3, Util.Clip((float)alpha, 0.0f, 1.0f)); m_host.SetText(text.Length > 254 ? text.Remove(255) : text, av3, Util.Clip((float)alpha, 0.0f, 1.0f));
m_host.ParentGroup.HasGroupChanged = true; //m_host.ParentGroup.HasGroupChanged = true;
m_host.ParentGroup.ScheduleGroupForFullUpdate(); //m_host.ParentGroup.ScheduleGroupForFullUpdate();
} }
public LSL_Float llWater(LSL_Vector offset) public LSL_Float llWater(LSL_Vector offset)
@ -4693,15 +4709,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return (double)Math.Asin(val); return (double)Math.Asin(val);
} }
// Xantor 30/apr/2008 // jcochran 5/jan/2012
public LSL_Float llAngleBetween(LSL_Rotation a, LSL_Rotation b) public LSL_Float llAngleBetween(LSL_Rotation a, LSL_Rotation b)
{ {
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
double angle = Math.Acos(a.x * b.x + a.y * b.y + a.z * b.z + a.s * b.s) * 2; double aa = (a.x * a.x + a.y * a.y + a.z * a.z + a.s * a.s);
if (angle < 0) angle = -angle; double bb = (b.x * b.x + b.y * b.y + b.z * b.z + b.s * b.s);
if (angle > Math.PI) return (Math.PI * 2 - angle); double aa_bb = aa * bb;
return angle; if (aa_bb == 0) return 0.0;
double ab = (a.x * b.x + a.y * b.y + a.z * b.z + a.s * b.s);
double quotient = (ab * ab) / aa_bb;
if (quotient >= 1.0) return 0.0;
return Math.Acos(2 * quotient - 1);
} }
public LSL_String llGetInventoryKey(string name) public LSL_String llGetInventoryKey(string name)
@ -5486,7 +5506,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
foreach (GridRegion sri in neighbors) foreach (GridRegion sri in neighbors)
{ {
if (sri.RegionLocX == neighborX && sri.RegionLocY == neighborY) if (sri.RegionCoordX == neighborX && sri.RegionCoordY == neighborY)
return 0; return 0;
} }
@ -6583,7 +6603,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
} }
// the rest of the permission checks are done in RezScript, so check the pin there as well // the rest of the permission checks are done in RezScript, so check the pin there as well
World.RezScript(srcId, m_host, destId, pin, running, start_param); World.RezScriptFromPrim(srcId, m_host, destId, pin, running, start_param);
// this will cause the delay even if the script pin or permissions were wrong - seems ok // this will cause the delay even if the script pin or permissions were wrong - seems ok
ScriptSleep(3000); ScriptSleep(3000);
} }
@ -7546,6 +7567,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
ScriptSleep(2000); ScriptSleep(2000);
} }
public LSL_String llGetParcelMusicURL()
{
m_host.AddScriptLPS(1);
ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y);
if (land.LandData.OwnerID != m_host.OwnerID)
return String.Empty;
return land.GetMusicUrl();
}
public LSL_Vector llGetRootPosition() public LSL_Vector llGetRootPosition()
{ {
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
@ -10613,6 +10646,75 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return list; return list;
} }
public LSL_Integer llManageEstateAccess(int action, string avatar)
{
m_host.AddScriptLPS(1);
EstateSettings estate = World.RegionInfo.EstateSettings;
bool isAccount = false;
bool isGroup = false;
if (!estate.IsEstateOwner(m_host.OwnerID) || !estate.IsEstateManager(m_host.OwnerID))
return 0;
UUID id = new UUID();
if (!UUID.TryParse(avatar, out id))
return 0;
UserAccount account = World.UserAccountService.GetUserAccount(World.RegionInfo.ScopeID, id);
isAccount = account != null ? true : false;
if (!isAccount)
{
IGroupsModule groups = World.RequestModuleInterface<IGroupsModule>();
if (groups != null)
{
GroupRecord group = groups.GetGroupRecord(id);
isGroup = group != null ? true : false;
if (!isGroup)
return 0;
}
else
return 0;
}
switch (action)
{
case ScriptBaseClass.ESTATE_ACCESS_ALLOWED_AGENT_ADD:
if (!isAccount) return 0;
if (estate.HasAccess(id)) return 1;
if (estate.IsBanned(id))
estate.RemoveBan(id);
estate.AddEstateUser(id);
break;
case ScriptBaseClass.ESTATE_ACCESS_ALLOWED_AGENT_REMOVE:
if (!isAccount || !estate.HasAccess(id)) return 0;
estate.RemoveEstateUser(id);
break;
case ScriptBaseClass.ESTATE_ACCESS_ALLOWED_GROUP_ADD:
if (!isGroup) return 0;
if (estate.GroupAccess(id)) return 1;
estate.AddEstateGroup(id);
break;
case ScriptBaseClass.ESTATE_ACCESS_ALLOWED_GROUP_REMOVE:
if (!isGroup || !estate.GroupAccess(id)) return 0;
estate.RemoveEstateGroup(id);
break;
case ScriptBaseClass.ESTATE_ACCESS_BANNED_AGENT_ADD:
if (!isAccount) return 0;
if (estate.IsBanned(id)) return 1;
EstateBan ban = new EstateBan();
ban.EstateID = estate.EstateID;
ban.BannedUserID = id;
estate.AddBan(ban);
break;
case ScriptBaseClass.ESTATE_ACCESS_BANNED_AGENT_REMOVE:
if (!isAccount || !estate.IsBanned(id)) return 0;
estate.RemoveBan(id);
break;
default: return 0;
}
return 1;
}
#region Not Implemented #region Not Implemented
// //
// Listing the unimplemented lsl functions here, please move // Listing the unimplemented lsl functions here, please move

View File

@ -157,6 +157,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
string risk = m_ScriptEngine.Config.GetString("OSFunctionThreatLevel", "VeryLow"); string risk = m_ScriptEngine.Config.GetString("OSFunctionThreatLevel", "VeryLow");
switch (risk) switch (risk)
{ {
case "NoAccess":
m_MaxThreatLevel = ThreatLevel.NoAccess;
break;
case "None": case "None":
m_MaxThreatLevel = ThreatLevel.None; m_MaxThreatLevel = ThreatLevel.None;
break; break;
@ -413,6 +416,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public LSL_Integer osSetTerrainHeight(int x, int y, double val) public LSL_Integer osSetTerrainHeight(int x, int y, double val)
{ {
CheckThreatLevel(ThreatLevel.High, "osSetTerrainHeight"); CheckThreatLevel(ThreatLevel.High, "osSetTerrainHeight");
return SetTerrainHeight(x, y, val); return SetTerrainHeight(x, y, val);
} }
@ -420,12 +424,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{ {
CheckThreatLevel(ThreatLevel.High, "osTerrainSetHeight"); CheckThreatLevel(ThreatLevel.High, "osTerrainSetHeight");
OSSLDeprecated("osTerrainSetHeight", "osSetTerrainHeight"); OSSLDeprecated("osTerrainSetHeight", "osSetTerrainHeight");
return SetTerrainHeight(x, y, val); return SetTerrainHeight(x, y, val);
} }
private LSL_Integer SetTerrainHeight(int x, int y, double val) private LSL_Integer SetTerrainHeight(int x, int y, double val)
{ {
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
if (x > ((int)Constants.RegionSize - 1) || x < 0 || y > ((int)Constants.RegionSize - 1) || y < 0) if (x > ((int)Constants.RegionSize - 1) || x < 0 || y > ((int)Constants.RegionSize - 1) || y < 0)
OSSLError("osSetTerrainHeight: Coordinate out of bounds"); OSSLError("osSetTerrainHeight: Coordinate out of bounds");
@ -465,6 +471,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public void osTerrainFlush() public void osTerrainFlush()
{ {
CheckThreatLevel(ThreatLevel.VeryLow, "osTerrainFlush"); CheckThreatLevel(ThreatLevel.VeryLow, "osTerrainFlush");
m_host.AddScriptLPS(1);
ITerrainModule terrainModule = World.RequestModuleInterface<ITerrainModule>(); ITerrainModule terrainModule = World.RequestModuleInterface<ITerrainModule>();
if (terrainModule != null) terrainModule.TaintTerrain(); if (terrainModule != null) terrainModule.TaintTerrain();
@ -736,7 +743,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{ {
// High because there is no security check. High griefer potential // High because there is no security check. High griefer potential
// //
CheckThreatLevel(ThreatLevel.High, "osTeleportAgent"); CheckThreatLevel(ThreatLevel.Severe, "osTeleportAgent");
TeleportAgent(agent, regionName, position, lookat, false); TeleportAgent(agent, regionName, position, lookat, false);
} }
@ -753,11 +760,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{ {
// For osTeleportAgent, agent must be over owners land to avoid abuse // For osTeleportAgent, agent must be over owners land to avoid abuse
// For osTeleportOwner, this restriction isn't necessary // For osTeleportOwner, this restriction isn't necessary
if (relaxRestrictions ||
m_host.OwnerID // commented out because its redundant and uneeded please remove eventually.
== World.LandChannel.GetLandObject( // if (relaxRestrictions ||
presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID) // m_host.OwnerID
{ // == World.LandChannel.GetLandObject(
// presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID)
// {
// We will launch the teleport on a new thread so that when the script threads are terminated // We will launch the teleport on a new thread so that when the script threads are terminated
// before teleport in ScriptInstance.GetXMLState(), we don't end up aborting the one doing the teleporting. // before teleport in ScriptInstance.GetXMLState(), we don't end up aborting the one doing the teleporting.
Util.FireAndForget( Util.FireAndForget(
@ -766,7 +776,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
new Vector3((float)lookat.x, (float)lookat.y, (float)lookat.z), (uint)TPFlags.ViaLocation)); new Vector3((float)lookat.x, (float)lookat.y, (float)lookat.z), (uint)TPFlags.ViaLocation));
ScriptSleep(5000); ScriptSleep(5000);
}
// }
} }
} }
} }
@ -775,7 +787,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{ {
// High because there is no security check. High griefer potential // High because there is no security check. High griefer potential
// //
CheckThreatLevel(ThreatLevel.High, "osTeleportAgent"); CheckThreatLevel(ThreatLevel.Severe, "osTeleportAgent");
TeleportAgent(agent, regionX, regionY, position, lookat, false); TeleportAgent(agent, regionX, regionY, position, lookat, false);
} }
@ -794,11 +806,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{ {
// For osTeleportAgent, agent must be over owners land to avoid abuse // For osTeleportAgent, agent must be over owners land to avoid abuse
// For osTeleportOwner, this restriction isn't necessary // For osTeleportOwner, this restriction isn't necessary
if (relaxRestrictions ||
m_host.OwnerID // commented out because its redundant and uneeded please remove eventually.
== World.LandChannel.GetLandObject( // if (relaxRestrictions ||
presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID) // m_host.OwnerID
{ // == World.LandChannel.GetLandObject(
// presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID)
// {
// We will launch the teleport on a new thread so that when the script threads are terminated // We will launch the teleport on a new thread so that when the script threads are terminated
// before teleport in ScriptInstance.GetXMLState(), we don't end up aborting the one doing the teleporting. // before teleport in ScriptInstance.GetXMLState(), we don't end up aborting the one doing the teleporting.
Util.FireAndForget( Util.FireAndForget(
@ -807,7 +822,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
new Vector3((float)lookat.x, (float)lookat.y, (float)lookat.z), (uint)TPFlags.ViaLocation)); new Vector3((float)lookat.x, (float)lookat.y, (float)lookat.z), (uint)TPFlags.ViaLocation));
ScriptSleep(5000); ScriptSleep(5000);
}
// }
} }
} }
} }
@ -871,6 +888,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
// threat level is None as we could get this information with an // threat level is None as we could get this information with an
// in-world script as well, just not as efficient // in-world script as well, just not as efficient
CheckThreatLevel(ThreatLevel.None, "osGetAgents"); CheckThreatLevel(ThreatLevel.None, "osGetAgents");
m_host.AddScriptLPS(1);
LSL_List result = new LSL_List(); LSL_List result = new LSL_List();
World.ForEachRootScenePresence(delegate(ScenePresence sp) World.ForEachRootScenePresence(delegate(ScenePresence sp)
@ -885,6 +903,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{ {
CheckThreatLevel(ThreatLevel.VeryHigh, "osAvatarPlayAnimation"); CheckThreatLevel(ThreatLevel.VeryHigh, "osAvatarPlayAnimation");
AvatarPlayAnimation(avatar, animation);
}
private void AvatarPlayAnimation(string avatar, string animation)
{
UUID avatarID = (UUID)avatar; UUID avatarID = (UUID)avatar;
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
@ -918,6 +941,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{ {
CheckThreatLevel(ThreatLevel.VeryHigh, "osAvatarStopAnimation"); CheckThreatLevel(ThreatLevel.VeryHigh, "osAvatarStopAnimation");
AvatarStopAnimation(avatar, animation);
}
private void AvatarStopAnimation(string avatar, string animation)
{
UUID avatarID = (UUID)avatar; UUID avatarID = (UUID)avatar;
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
@ -1141,6 +1169,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
// should be removed // should be removed
// //
CheckThreatLevel(ThreatLevel.High, "osSetStateEvents"); CheckThreatLevel(ThreatLevel.High, "osSetStateEvents");
m_host.AddScriptLPS(1);
m_host.SetScriptEvents(m_itemID, events); m_host.SetScriptEvents(m_itemID, events);
} }
@ -1488,7 +1517,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
ILandObject land ILandObject land
= World.LandChannel.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y); = World.LandChannel.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y);
@ -1549,6 +1577,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
// //
CheckThreatLevel(ThreatLevel.High,"osGetSimulatorVersion"); CheckThreatLevel(ThreatLevel.High,"osGetSimulatorVersion");
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
return m_ScriptEngine.World.GetSimulatorVersion(); return m_ScriptEngine.World.GetSimulatorVersion();
} }
@ -1886,6 +1915,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public string osAvatarName2Key(string firstname, string lastname) public string osAvatarName2Key(string firstname, string lastname)
{ {
CheckThreatLevel(ThreatLevel.Low, "osAvatarName2Key"); CheckThreatLevel(ThreatLevel.Low, "osAvatarName2Key");
m_host.AddScriptLPS(1);
UserAccount account = World.UserAccountService.GetUserAccount(World.RegionInfo.ScopeID, firstname, lastname); UserAccount account = World.UserAccountService.GetUserAccount(World.RegionInfo.ScopeID, firstname, lastname);
if (null == account) if (null == account)
@ -1901,6 +1931,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public string osKey2Name(string id) public string osKey2Name(string id)
{ {
CheckThreatLevel(ThreatLevel.Low, "osKey2Name"); CheckThreatLevel(ThreatLevel.Low, "osKey2Name");
m_host.AddScriptLPS(1);
UUID key = new UUID(); UUID key = new UUID();
if (UUID.TryParse(id, out key)) if (UUID.TryParse(id, out key))
@ -1921,6 +1953,69 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
} }
} }
private enum InfoType
{
Nick,
Name,
Login,
Home,
Custom
};
private string GridUserInfo(InfoType type)
{
return GridUserInfo(type, "");
}
private string GridUserInfo(InfoType type, string key)
{
string retval = String.Empty;
IConfigSource config = m_ScriptEngine.ConfigSource;
string url = config.Configs["GridInfo"].GetString("GridInfoURI", String.Empty);
if (String.IsNullOrEmpty(url))
return "Configuration Error!";
string verb ="/json_grid_info";
OSDMap json = new OSDMap();
OSDMap info = WebUtil.GetFromService(String.Format("{0}{1}",url,verb), 3000);
if (info["Success"] != true)
return "Get GridInfo Failed!";
json = (OSDMap)OSDParser.DeserializeJson(info["_RawResult"].AsString());
switch (type)
{
case InfoType.Nick:
retval = json["gridnick"];
break;
case InfoType.Name:
retval = json["gridname"];
break;
case InfoType.Login:
retval = json["login"];
break;
case InfoType.Home:
retval = json["home"];
break;
case InfoType.Custom:
retval = json[key];
break;
default:
retval = "error";
break;
}
return retval;
}
/// <summary> /// <summary>
/// Get the nickname of this grid, as set in the [GridInfo] config section. /// Get the nickname of this grid, as set in the [GridInfo] config section.
/// </summary> /// </summary>
@ -1934,10 +2029,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{ {
CheckThreatLevel(ThreatLevel.Moderate, "osGetGridNick"); CheckThreatLevel(ThreatLevel.Moderate, "osGetGridNick");
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
string nick = "hippogrid";
string nick = String.Empty;
IConfigSource config = m_ScriptEngine.ConfigSource; IConfigSource config = m_ScriptEngine.ConfigSource;
if (config.Configs["GridInfo"] != null) if (config.Configs["GridInfo"] != null)
nick = config.Configs["GridInfo"].GetString("gridnick", nick); nick = config.Configs["GridInfo"].GetString("gridnick", nick);
if (String.IsNullOrEmpty(nick))
nick = GridUserInfo(InfoType.Nick);
return nick; return nick;
} }
@ -1945,10 +2046,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{ {
CheckThreatLevel(ThreatLevel.Moderate, "osGetGridName"); CheckThreatLevel(ThreatLevel.Moderate, "osGetGridName");
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
string name = "the lost continent of hippo";
string name = String.Empty;
IConfigSource config = m_ScriptEngine.ConfigSource; IConfigSource config = m_ScriptEngine.ConfigSource;
if (config.Configs["GridInfo"] != null) if (config.Configs["GridInfo"] != null)
name = config.Configs["GridInfo"].GetString("gridname", name); name = config.Configs["GridInfo"].GetString("gridname", name);
if (String.IsNullOrEmpty(name))
name = GridUserInfo(InfoType.Name);
return name; return name;
} }
@ -1956,13 +2063,53 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{ {
CheckThreatLevel(ThreatLevel.Moderate, "osGetGridLoginURI"); CheckThreatLevel(ThreatLevel.Moderate, "osGetGridLoginURI");
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
string loginURI = "http://127.0.0.1:9000/";
string loginURI = String.Empty;
IConfigSource config = m_ScriptEngine.ConfigSource; IConfigSource config = m_ScriptEngine.ConfigSource;
if (config.Configs["GridInfo"] != null) if (config.Configs["GridInfo"] != null)
loginURI = config.Configs["GridInfo"].GetString("login", loginURI); loginURI = config.Configs["GridInfo"].GetString("login", loginURI);
if (String.IsNullOrEmpty(loginURI))
loginURI = GridUserInfo(InfoType.Login);
return loginURI; return loginURI;
} }
public string osGetGridHomeURI()
{
CheckThreatLevel(ThreatLevel.Moderate, "osGetGridHomeURI");
m_host.AddScriptLPS(1);
string HomeURI = String.Empty;
IConfigSource config = m_ScriptEngine.ConfigSource;
if (config.Configs["LoginService"] != null)
HomeURI = config.Configs["LoginService"].GetString("SRV_HomeURI", HomeURI);
if (String.IsNullOrEmpty(HomeURI))
HomeURI = GridUserInfo(InfoType.Home);
return HomeURI;
}
public string osGetGridCustom(string key)
{
CheckThreatLevel(ThreatLevel.Moderate, "osGetGridCustom");
m_host.AddScriptLPS(1);
string retval = String.Empty;
IConfigSource config = m_ScriptEngine.ConfigSource;
if (config.Configs["GridInfo"] != null)
retval = config.Configs["GridInfo"].GetString(key, retval);
if (String.IsNullOrEmpty(retval))
retval = GridUserInfo(InfoType.Custom, key);
return retval;
}
public LSL_String osFormatString(string str, LSL_List strings) public LSL_String osFormatString(string str, LSL_List strings)
{ {
CheckThreatLevel(ThreatLevel.Low, "osFormatString"); CheckThreatLevel(ThreatLevel.Low, "osFormatString");
@ -2064,10 +2211,45 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return retVal; return retVal;
} }
public LSL_Integer osIsNpc(LSL_Key npc)
{
CheckThreatLevel(ThreatLevel.None, "osIsNpc");
m_host.AddScriptLPS(1);
INPCModule module = World.RequestModuleInterface<INPCModule>();
if (module != null)
{
UUID npcId;
if (UUID.TryParse(npc.m_string, out npcId))
if (module.IsNPC(npcId, World))
return ScriptBaseClass.TRUE;
}
return ScriptBaseClass.FALSE;
}
public LSL_Key osNpcCreate(string firstname, string lastname, LSL_Vector position, string notecard) public LSL_Key osNpcCreate(string firstname, string lastname, LSL_Vector position, string notecard)
{ {
CheckThreatLevel(ThreatLevel.High, "osNpcCreate"); CheckThreatLevel(ThreatLevel.High, "osNpcCreate");
m_host.AddScriptLPS(1);
return NpcCreate(firstname, lastname, position, notecard, false, true);
}
public LSL_Key osNpcCreate(string firstname, string lastname, LSL_Vector position, string notecard, int options)
{
CheckThreatLevel(ThreatLevel.High, "osNpcCreate");
m_host.AddScriptLPS(1);
return NpcCreate(
firstname, lastname, position, notecard,
(options & ScriptBaseClass.OS_NPC_NOT_OWNED) == 0,
(options & ScriptBaseClass.OS_NPC_SENSE_AS_AGENT) == 0);
}
private LSL_Key NpcCreate(
string firstname, string lastname, LSL_Vector position, string notecard, bool owned, bool senseAsAgent)
{
INPCModule module = World.RequestModuleInterface<INPCModule>(); INPCModule module = World.RequestModuleInterface<INPCModule>();
if (module != null) if (module != null)
{ {
@ -2096,9 +2278,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (appearance == null) if (appearance == null)
return new LSL_Key(UUID.Zero.ToString()); return new LSL_Key(UUID.Zero.ToString());
UUID ownerID = UUID.Zero;
if (owned)
ownerID = m_host.OwnerID;
UUID x = module.CreateNPC(firstname, UUID x = module.CreateNPC(firstname,
lastname, lastname,
new Vector3((float) position.x, (float) position.y, (float) position.z), new Vector3((float) position.x, (float) position.y, (float) position.z),
ownerID,
senseAsAgent,
World, World,
appearance); appearance);
@ -2117,6 +2304,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public LSL_Key osNpcSaveAppearance(LSL_Key npc, string notecard) public LSL_Key osNpcSaveAppearance(LSL_Key npc, string notecard)
{ {
CheckThreatLevel(ThreatLevel.High, "osNpcSaveAppearance"); CheckThreatLevel(ThreatLevel.High, "osNpcSaveAppearance");
m_host.AddScriptLPS(1);
INPCModule npcModule = World.RequestModuleInterface<INPCModule>(); INPCModule npcModule = World.RequestModuleInterface<INPCModule>();
@ -2126,7 +2314,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (!UUID.TryParse(npc.m_string, out npcId)) if (!UUID.TryParse(npc.m_string, out npcId))
return new LSL_Key(UUID.Zero.ToString()); return new LSL_Key(UUID.Zero.ToString());
if (!npcModule.IsNPC(npcId, m_host.ParentGroup.Scene)) if (!npcModule.CheckPermissions(npcId, m_host.OwnerID))
return new LSL_Key(UUID.Zero.ToString()); return new LSL_Key(UUID.Zero.ToString());
return SaveAppearanceToNotecard(npcId, notecard); return SaveAppearanceToNotecard(npcId, notecard);
@ -2138,6 +2326,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public void osNpcLoadAppearance(LSL_Key npc, string notecard) public void osNpcLoadAppearance(LSL_Key npc, string notecard)
{ {
CheckThreatLevel(ThreatLevel.High, "osNpcLoadAppearance"); CheckThreatLevel(ThreatLevel.High, "osNpcLoadAppearance");
m_host.AddScriptLPS(1);
INPCModule npcModule = World.RequestModuleInterface<INPCModule>(); INPCModule npcModule = World.RequestModuleInterface<INPCModule>();
@ -2147,6 +2336,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (!UUID.TryParse(npc.m_string, out npcId)) if (!UUID.TryParse(npc.m_string, out npcId))
return; return;
if (!npcModule.CheckPermissions(npcId, m_host.OwnerID))
return;
string appearanceSerialized = LoadNotecard(notecard); string appearanceSerialized = LoadNotecard(notecard);
OSDMap appearanceOsd = (OSDMap)OSDParser.DeserializeLLSDXml(appearanceSerialized); OSDMap appearanceOsd = (OSDMap)OSDParser.DeserializeLLSDXml(appearanceSerialized);
// OSD a = OSDParser.DeserializeLLSDXml(appearanceSerialized); // OSD a = OSDParser.DeserializeLLSDXml(appearanceSerialized);
@ -2159,9 +2351,32 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
} }
} }
public LSL_Key osNpcGetOwner(LSL_Key npc)
{
CheckThreatLevel(ThreatLevel.None, "osNpcGetOwner");
m_host.AddScriptLPS(1);
INPCModule npcModule = World.RequestModuleInterface<INPCModule>();
if (npcModule != null)
{
UUID npcId;
if (UUID.TryParse(npc.m_string, out npcId))
{
UUID owner = npcModule.GetOwner(npcId);
if (owner != UUID.Zero)
return new LSL_Key(owner.ToString());
else
return npc;
}
}
return new LSL_Key(UUID.Zero.ToString());
}
public LSL_Vector osNpcGetPos(LSL_Key npc) public LSL_Vector osNpcGetPos(LSL_Key npc)
{ {
CheckThreatLevel(ThreatLevel.High, "osNpcGetPos"); CheckThreatLevel(ThreatLevel.High, "osNpcGetPos");
m_host.AddScriptLPS(1);
INPCModule npcModule = World.RequestModuleInterface<INPCModule>(); INPCModule npcModule = World.RequestModuleInterface<INPCModule>();
if (npcModule != null) if (npcModule != null)
@ -2170,7 +2385,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (!UUID.TryParse(npc.m_string, out npcId)) if (!UUID.TryParse(npc.m_string, out npcId))
return new LSL_Vector(0, 0, 0); return new LSL_Vector(0, 0, 0);
if (!npcModule.IsNPC(npcId, m_host.ParentGroup.Scene)) if (!npcModule.CheckPermissions(npcId, m_host.OwnerID))
return new LSL_Vector(0, 0, 0); return new LSL_Vector(0, 0, 0);
Vector3 pos = World.GetScenePresence(npcId).AbsolutePosition; Vector3 pos = World.GetScenePresence(npcId).AbsolutePosition;
@ -2183,6 +2398,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public void osNpcMoveTo(LSL_Key npc, LSL_Vector position) public void osNpcMoveTo(LSL_Key npc, LSL_Vector position)
{ {
CheckThreatLevel(ThreatLevel.High, "osNpcMoveTo"); CheckThreatLevel(ThreatLevel.High, "osNpcMoveTo");
m_host.AddScriptLPS(1);
INPCModule module = World.RequestModuleInterface<INPCModule>(); INPCModule module = World.RequestModuleInterface<INPCModule>();
if (module != null) if (module != null)
@ -2191,6 +2407,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (!UUID.TryParse(npc.m_string, out npcId)) if (!UUID.TryParse(npc.m_string, out npcId))
return; return;
if (!module.CheckPermissions(npcId, m_host.OwnerID))
return;
Vector3 pos = new Vector3((float) position.x, (float) position.y, (float) position.z); Vector3 pos = new Vector3((float) position.x, (float) position.y, (float) position.z);
module.MoveToTarget(npcId, World, pos, false, true); module.MoveToTarget(npcId, World, pos, false, true);
} }
@ -2199,6 +2418,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public void osNpcMoveToTarget(LSL_Key npc, LSL_Vector target, int options) public void osNpcMoveToTarget(LSL_Key npc, LSL_Vector target, int options)
{ {
CheckThreatLevel(ThreatLevel.High, "osNpcMoveToTarget"); CheckThreatLevel(ThreatLevel.High, "osNpcMoveToTarget");
m_host.AddScriptLPS(1);
INPCModule module = World.RequestModuleInterface<INPCModule>(); INPCModule module = World.RequestModuleInterface<INPCModule>();
if (module != null) if (module != null)
@ -2207,6 +2427,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (!UUID.TryParse(npc.m_string, out npcId)) if (!UUID.TryParse(npc.m_string, out npcId))
return; return;
if (!module.CheckPermissions(npcId, m_host.OwnerID))
return;
Vector3 pos = new Vector3((float)target.x, (float)target.y, (float)target.z); Vector3 pos = new Vector3((float)target.x, (float)target.y, (float)target.z);
module.MoveToTarget( module.MoveToTarget(
new UUID(npc.m_string), new UUID(npc.m_string),
@ -2220,6 +2443,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public LSL_Rotation osNpcGetRot(LSL_Key npc) public LSL_Rotation osNpcGetRot(LSL_Key npc)
{ {
CheckThreatLevel(ThreatLevel.High, "osNpcGetRot"); CheckThreatLevel(ThreatLevel.High, "osNpcGetRot");
m_host.AddScriptLPS(1);
INPCModule npcModule = World.RequestModuleInterface<INPCModule>(); INPCModule npcModule = World.RequestModuleInterface<INPCModule>();
if (npcModule != null) if (npcModule != null)
@ -2228,7 +2452,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (!UUID.TryParse(npc.m_string, out npcId)) if (!UUID.TryParse(npc.m_string, out npcId))
return new LSL_Rotation(Quaternion.Identity.X, Quaternion.Identity.Y, Quaternion.Identity.Z, Quaternion.Identity.W); return new LSL_Rotation(Quaternion.Identity.X, Quaternion.Identity.Y, Quaternion.Identity.Z, Quaternion.Identity.W);
if (!npcModule.IsNPC(npcId, m_host.ParentGroup.Scene)) if (!npcModule.CheckPermissions(npcId, m_host.OwnerID))
return new LSL_Rotation(Quaternion.Identity.X, Quaternion.Identity.Y, Quaternion.Identity.Z, Quaternion.Identity.W); return new LSL_Rotation(Quaternion.Identity.X, Quaternion.Identity.Y, Quaternion.Identity.Z, Quaternion.Identity.W);
ScenePresence sp = World.GetScenePresence(npcId); ScenePresence sp = World.GetScenePresence(npcId);
@ -2243,6 +2467,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public void osNpcSetRot(LSL_Key npc, LSL_Rotation rotation) public void osNpcSetRot(LSL_Key npc, LSL_Rotation rotation)
{ {
CheckThreatLevel(ThreatLevel.High, "osNpcSetRot"); CheckThreatLevel(ThreatLevel.High, "osNpcSetRot");
m_host.AddScriptLPS(1);
INPCModule npcModule = World.RequestModuleInterface<INPCModule>(); INPCModule npcModule = World.RequestModuleInterface<INPCModule>();
if (npcModule != null) if (npcModule != null)
@ -2251,7 +2476,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (!UUID.TryParse(npc.m_string, out npcId)) if (!UUID.TryParse(npc.m_string, out npcId))
return; return;
if (!npcModule.IsNPC(npcId, m_host.ParentGroup.Scene)) if (!npcModule.CheckPermissions(npcId, m_host.OwnerID))
return; return;
ScenePresence sp = World.GetScenePresence(npcId); ScenePresence sp = World.GetScenePresence(npcId);
@ -2262,53 +2487,115 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public void osNpcStopMoveToTarget(LSL_Key npc) public void osNpcStopMoveToTarget(LSL_Key npc)
{ {
CheckThreatLevel(ThreatLevel.VeryLow, "osNpcStopMoveTo"); CheckThreatLevel(ThreatLevel.VeryLow, "osNpcStopMoveTo");
m_host.AddScriptLPS(1);
INPCModule module = World.RequestModuleInterface<INPCModule>(); INPCModule module = World.RequestModuleInterface<INPCModule>();
if (module != null) if (module != null)
module.StopMoveToTarget(new UUID(npc.m_string), World); {
UUID npcId = new UUID(npc.m_string);
if (!module.CheckPermissions(npcId, m_host.OwnerID))
return;
module.StopMoveToTarget(npcId, World);
}
} }
public void osNpcSay(LSL_Key npc, string message) public void osNpcSay(LSL_Key npc, string message)
{ {
CheckThreatLevel(ThreatLevel.High, "osNpcSay"); CheckThreatLevel(ThreatLevel.High, "osNpcSay");
m_host.AddScriptLPS(1);
INPCModule module = World.RequestModuleInterface<INPCModule>(); INPCModule module = World.RequestModuleInterface<INPCModule>();
if (module != null) if (module != null)
{ {
module.Say(new UUID(npc.m_string), World, message); UUID npcId = new UUID(npc.m_string);
if (!module.CheckPermissions(npcId, m_host.OwnerID))
return;
module.Say(npcId, World, message);
} }
} }
public void osNpcSit(LSL_Key npc, LSL_Key target, int options) public void osNpcSit(LSL_Key npc, LSL_Key target, int options)
{ {
CheckThreatLevel(ThreatLevel.High, "osNpcSit"); CheckThreatLevel(ThreatLevel.High, "osNpcSit");
m_host.AddScriptLPS(1);
INPCModule module = World.RequestModuleInterface<INPCModule>(); INPCModule module = World.RequestModuleInterface<INPCModule>();
if (module != null) if (module != null)
{ {
module.Sit(new UUID(npc.m_string), new UUID(target.m_string), World); UUID npcId = new UUID(npc.m_string);
if (!module.CheckPermissions(npcId, m_host.OwnerID))
return;
module.Sit(npcId, new UUID(target.m_string), World);
} }
} }
public void osNpcStand(LSL_Key npc) public void osNpcStand(LSL_Key npc)
{ {
CheckThreatLevel(ThreatLevel.High, "osNpcStand"); CheckThreatLevel(ThreatLevel.High, "osNpcStand");
m_host.AddScriptLPS(1);
INPCModule module = World.RequestModuleInterface<INPCModule>(); INPCModule module = World.RequestModuleInterface<INPCModule>();
if (module != null) if (module != null)
{ {
module.Stand(new UUID(npc.m_string), World); UUID npcId = new UUID(npc.m_string);
if (!module.CheckPermissions(npcId, m_host.OwnerID))
return;
module.Stand(npcId, World);
} }
} }
public void osNpcRemove(LSL_Key npc) public void osNpcRemove(LSL_Key npc)
{ {
CheckThreatLevel(ThreatLevel.High, "osNpcRemove"); CheckThreatLevel(ThreatLevel.High, "osNpcRemove");
m_host.AddScriptLPS(1);
INPCModule module = World.RequestModuleInterface<INPCModule>(); INPCModule module = World.RequestModuleInterface<INPCModule>();
if (module != null) if (module != null)
{ {
module.DeleteNPC(new UUID(npc.m_string), World); UUID npcId = new UUID(npc.m_string);
if (!module.CheckPermissions(npcId, m_host.OwnerID))
return;
module.DeleteNPC(npcId, World);
}
}
public void osNpcPlayAnimation(LSL_Key npc, string animation)
{
CheckThreatLevel(ThreatLevel.High, "osNpcPlayAnimation");
m_host.AddScriptLPS(1);
INPCModule module = World.RequestModuleInterface<INPCModule>();
if (module != null)
{
UUID npcID = new UUID(npc.m_string);
if (module.CheckPermissions(npcID, m_host.OwnerID))
AvatarPlayAnimation(npcID.ToString(), animation);
}
}
public void osNpcStopAnimation(LSL_Key npc, string animation)
{
CheckThreatLevel(ThreatLevel.High, "osNpcStopAnimation");
m_host.AddScriptLPS(1);
INPCModule module = World.RequestModuleInterface<INPCModule>();
if (module != null)
{
UUID npcID = new UUID(npc.m_string);
if (module.CheckPermissions(npcID, m_host.OwnerID))
AvatarPlayAnimation(npcID.ToString(), animation);
} }
} }
@ -2320,6 +2607,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public LSL_Key osOwnerSaveAppearance(string notecard) public LSL_Key osOwnerSaveAppearance(string notecard)
{ {
CheckThreatLevel(ThreatLevel.High, "osOwnerSaveAppearance"); CheckThreatLevel(ThreatLevel.High, "osOwnerSaveAppearance");
m_host.AddScriptLPS(1);
return SaveAppearanceToNotecard(m_host.OwnerID, notecard); return SaveAppearanceToNotecard(m_host.OwnerID, notecard);
} }
@ -2327,6 +2615,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public LSL_Key osAgentSaveAppearance(LSL_Key avatarId, string notecard) public LSL_Key osAgentSaveAppearance(LSL_Key avatarId, string notecard)
{ {
CheckThreatLevel(ThreatLevel.VeryHigh, "osAgentSaveAppearance"); CheckThreatLevel(ThreatLevel.VeryHigh, "osAgentSaveAppearance");
m_host.AddScriptLPS(1);
return SaveAppearanceToNotecard(avatarId, notecard); return SaveAppearanceToNotecard(avatarId, notecard);
} }
@ -2377,6 +2666,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public LSL_Key osGetMapTexture() public LSL_Key osGetMapTexture()
{ {
CheckThreatLevel(ThreatLevel.None, "osGetMapTexture"); CheckThreatLevel(ThreatLevel.None, "osGetMapTexture");
m_host.AddScriptLPS(1);
return m_ScriptEngine.World.RegionInfo.RegionSettings.TerrainImageID.ToString(); return m_ScriptEngine.World.RegionInfo.RegionSettings.TerrainImageID.ToString();
} }
@ -2388,6 +2679,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public LSL_Key osGetRegionMapTexture(string regionName) public LSL_Key osGetRegionMapTexture(string regionName)
{ {
CheckThreatLevel(ThreatLevel.High, "osGetRegionMapTexture"); CheckThreatLevel(ThreatLevel.High, "osGetRegionMapTexture");
m_host.AddScriptLPS(1);
Scene scene = m_ScriptEngine.World; Scene scene = m_ScriptEngine.World;
UUID key = UUID.Zero; UUID key = UUID.Zero;
GridRegion region; GridRegion region;
@ -2453,6 +2746,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public void osKickAvatar(string FirstName,string SurName,string alert) public void osKickAvatar(string FirstName,string SurName,string alert)
{ {
CheckThreatLevel(ThreatLevel.Severe, "osKickAvatar"); CheckThreatLevel(ThreatLevel.Severe, "osKickAvatar");
m_host.AddScriptLPS(1);
if (World.Permissions.CanRunConsoleCommand(m_host.OwnerID)) if (World.Permissions.CanRunConsoleCommand(m_host.OwnerID))
{ {
World.ForEachRootScenePresence(delegate(ScenePresence sp) World.ForEachRootScenePresence(delegate(ScenePresence sp)
@ -2587,6 +2882,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public LSL_List osGetAvatarList() public LSL_List osGetAvatarList()
{ {
CheckThreatLevel(ThreatLevel.None, "osGetAvatarList"); CheckThreatLevel(ThreatLevel.None, "osGetAvatarList");
m_host.AddScriptLPS(1);
LSL_List result = new LSL_List(); LSL_List result = new LSL_List();
World.ForEachRootScenePresence(delegate (ScenePresence avatar) World.ForEachRootScenePresence(delegate (ScenePresence avatar)
@ -2611,6 +2907,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public LSL_String osUnixTimeToTimestamp(long time) public LSL_String osUnixTimeToTimestamp(long time)
{ {
CheckThreatLevel(ThreatLevel.VeryLow, "osUnixTimeToTimestamp"); CheckThreatLevel(ThreatLevel.VeryLow, "osUnixTimeToTimestamp");
m_host.AddScriptLPS(1);
long baseTicks = 621355968000000000; long baseTicks = 621355968000000000;
long tickResolution = 10000000; long tickResolution = 10000000;
long epochTicks = (time * tickResolution) + baseTicks; long epochTicks = (time * tickResolution) + baseTicks;

View File

@ -26,10 +26,13 @@
*/ */
using System; using System;
using System.Reflection;
using System.Collections.Generic; using System.Collections.Generic;
using OpenMetaverse; using OpenMetaverse;
using OpenSim.Framework; using OpenSim.Framework;
using log4net;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.ScriptEngine.Shared; using OpenSim.Region.ScriptEngine.Shared;
using OpenSim.Region.ScriptEngine.Shared.Api; using OpenSim.Region.ScriptEngine.Shared.Api;
@ -51,6 +54,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
private const int AGENT = 1; private const int AGENT = 1;
private const int AGENT_BY_USERNAME = 0x10; private const int AGENT_BY_USERNAME = 0x10;
private const int NPC = 0x20;
private const int ACTIVE = 2; private const int ACTIVE = 2;
private const int PASSIVE = 4; private const int PASSIVE = 4;
private const int SCRIPTED = 8; private const int SCRIPTED = 8;
@ -203,7 +207,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
List<SensedEntity> sensedEntities = new List<SensedEntity>(); List<SensedEntity> sensedEntities = new List<SensedEntity>();
// Is the sensor type is AGENT and not SCRIPTED then include agents // Is the sensor type is AGENT and not SCRIPTED then include agents
if ((ts.type & (AGENT | AGENT_BY_USERNAME)) != 0 && (ts.type & SCRIPTED) == 0) if ((ts.type & (AGENT | AGENT_BY_USERNAME | NPC)) != 0 && (ts.type & SCRIPTED) == 0)
{ {
sensedEntities.AddRange(doAgentSensor(ts)); sensedEntities.AddRange(doAgentSensor(ts));
} }
@ -413,6 +417,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
private List<SensedEntity> doAgentSensor(SenseRepeatClass ts) private List<SensedEntity> doAgentSensor(SenseRepeatClass ts)
{ {
INPCModule npcModule = m_CmdManager.m_ScriptEngine.World.RequestModuleInterface<INPCModule>();
List<SensedEntity> sensedEntities = new List<SensedEntity>(); List<SensedEntity> sensedEntities = new List<SensedEntity>();
// If nobody about quit fast // If nobody about quit fast
@ -441,6 +447,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
Action<ScenePresence> senseEntity = new Action<ScenePresence>(delegate(ScenePresence presence) Action<ScenePresence> senseEntity = new Action<ScenePresence>(delegate(ScenePresence presence)
{ {
if ((ts.type & NPC) == 0
&& presence.PresenceType == PresenceType.Npc
&& !npcModule.GetNPC(presence.UUID, presence.Scene).SenseAsAgent)
return;
if ((ts.type & AGENT) == 0
&& (presence.PresenceType == PresenceType.User
|| npcModule.GetNPC(presence.UUID, presence.Scene).SenseAsAgent))
return;
if (presence.IsDeleted || presence.IsChildAgent || presence.GodLevel > 0.0) if (presence.IsDeleted || presence.IsChildAgent || presence.GodLevel > 0.0)
return; return;
@ -452,6 +468,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
toRegionPos = presence.AbsolutePosition; toRegionPos = presence.AbsolutePosition;
dis = Math.Abs(Util.GetDistanceTo(toRegionPos, fromRegionPos)); dis = Math.Abs(Util.GetDistanceTo(toRegionPos, fromRegionPos));
// Disabled for now since all osNpc* methods check for appropriate ownership permission.
// Perhaps could be re-enabled as an NPC setting at some point since being able to make NPCs not
// sensed might be useful.
// if (presence.PresenceType == PresenceType.Npc && npcModule != null)
// {
// UUID npcOwner = npcModule.GetOwner(presence.UUID);
// if (npcOwner != UUID.Zero && npcOwner != SensePoint.OwnerID)
// return;
// }
// are they in range // are they in range
if (dis <= ts.range) if (dis <= ts.range)
{ {

View File

@ -161,6 +161,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
LSL_List llGetParcelDetails(LSL_Vector pos, LSL_List param); LSL_List llGetParcelDetails(LSL_Vector pos, LSL_List param);
LSL_Integer llGetParcelFlags(LSL_Vector pos); LSL_Integer llGetParcelFlags(LSL_Vector pos);
LSL_Integer llGetParcelMaxPrims(LSL_Vector pos, int sim_wide); LSL_Integer llGetParcelMaxPrims(LSL_Vector pos, int sim_wide);
LSL_String llGetParcelMusicURL();
LSL_Integer llGetParcelPrimCount(LSL_Vector pos, int category, int sim_wide); LSL_Integer llGetParcelPrimCount(LSL_Vector pos, int category, int sim_wide);
LSL_List llGetParcelPrimOwners(LSL_Vector pos); LSL_List llGetParcelPrimOwners(LSL_Vector pos);
LSL_Integer llGetPermissions(); LSL_Integer llGetPermissions();
@ -241,6 +242,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
void llLoopSound(string sound, double volume); void llLoopSound(string sound, double volume);
void llLoopSoundMaster(string sound, double volume); void llLoopSoundMaster(string sound, double volume);
void llLoopSoundSlave(string sound, double volume); void llLoopSoundSlave(string sound, double volume);
LSL_Integer llManageEstateAccess(int action, string avatar);
void llMakeExplosion(int particles, double scale, double vel, double lifetime, double arc, string texture, LSL_Vector offset); void llMakeExplosion(int particles, double scale, double vel, double lifetime, double arc, string texture, LSL_Vector offset);
void llMakeFire(int particles, double scale, double vel, double lifetime, double arc, string texture, LSL_Vector offset); void llMakeFire(int particles, double scale, double vel, double lifetime, double arc, string texture, LSL_Vector offset);
void llMakeFountain(int particles, double scale, double vel, double lifetime, double arc, int bounce, string texture, LSL_Vector offset, double bounce_offset); void llMakeFountain(int particles, double scale, double vel, double lifetime, double arc, int bounce, string texture, LSL_Vector offset, double bounce_offset);

View File

@ -42,6 +42,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
{ {
public enum ThreatLevel public enum ThreatLevel
{ {
NoAccess = -1,
None = 0, None = 0,
Nuisance = 1, Nuisance = 1,
VeryLow = 2, VeryLow = 2,
@ -159,6 +160,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
string osGetGridNick(); string osGetGridNick();
string osGetGridName(); string osGetGridName();
string osGetGridLoginURI(); string osGetGridLoginURI();
string osGetGridHomeURI();
string osGetGridCustom(string key);
LSL_String osFormatString(string str, LSL_List strings); LSL_String osFormatString(string str, LSL_List strings);
LSL_List osMatchString(string src, string pattern, int start); LSL_List osMatchString(string src, string pattern, int start);
@ -170,12 +173,30 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
LSL_List osGetLinkPrimitiveParams(int linknumber, LSL_List rules); LSL_List osGetLinkPrimitiveParams(int linknumber, LSL_List rules);
/// <summary>
/// Check if the given key is an npc
/// </summary>
/// <param name="npc"></param>
/// <returns>TRUE if the key belongs to an npc in the scene. FALSE otherwise.</returns>
LSL_Integer osIsNpc(LSL_Key npc);
key osNpcCreate(string user, string name, vector position, string notecard); key osNpcCreate(string user, string name, vector position, string notecard);
key osNpcCreate(string user, string name, vector position, string notecard, int options);
LSL_Key osNpcSaveAppearance(key npc, string notecard); LSL_Key osNpcSaveAppearance(key npc, string notecard);
void osNpcLoadAppearance(key npc, string notecard); void osNpcLoadAppearance(key npc, string notecard);
vector osNpcGetPos(key npc); vector osNpcGetPos(key npc);
void osNpcMoveTo(key npc, vector position); void osNpcMoveTo(key npc, vector position);
void osNpcMoveToTarget(key npc, vector target, int options); void osNpcMoveToTarget(key npc, vector target, int options);
/// <summary>
/// Get the owner of the NPC
/// </summary>
/// <param name="npc"></param>
/// <returns>
/// The owner of the NPC for an owned NPC. The NPC's agent id for an unowned NPC. UUID.Zero if the key is not an npc.
/// </returns>
LSL_Key osNpcGetOwner(key npc);
rotation osNpcGetRot(key npc); rotation osNpcGetRot(key npc);
void osNpcSetRot(LSL_Key npc, rotation rot); void osNpcSetRot(LSL_Key npc, rotation rot);
void osNpcStopMoveToTarget(LSL_Key npc); void osNpcStopMoveToTarget(LSL_Key npc);
@ -183,6 +204,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
void osNpcSit(key npc, key target, int options); void osNpcSit(key npc, key target, int options);
void osNpcStand(LSL_Key npc); void osNpcStand(LSL_Key npc);
void osNpcRemove(key npc); void osNpcRemove(key npc);
void osNpcPlayAnimation(LSL_Key npc, string animation);
void osNpcStopAnimation(LSL_Key npc, string animation);
LSL_Key osOwnerSaveAppearance(string notecard); LSL_Key osOwnerSaveAppearance(string notecard);
LSL_Key osAgentSaveAppearance(key agentId, string notecard); LSL_Key osAgentSaveAppearance(key agentId, string notecard);

View File

@ -52,6 +52,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
public const int AGENT = 1; public const int AGENT = 1;
public const int AGENT_BY_LEGACY_NAME = 1; public const int AGENT_BY_LEGACY_NAME = 1;
public const int AGENT_BY_USERNAME = 0x10; public const int AGENT_BY_USERNAME = 0x10;
public const int NPC = 0x20;
public const int ACTIVE = 2; public const int ACTIVE = 2;
public const int PASSIVE = 4; public const int PASSIVE = 4;
public const int SCRIPTED = 8; public const int SCRIPTED = 8;
@ -431,6 +432,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
public const int REGION_FLAG_ALLOW_DIRECT_TELEPORT = 0x100000; // region allows direct teleports public const int REGION_FLAG_ALLOW_DIRECT_TELEPORT = 0x100000; // region allows direct teleports
public const int REGION_FLAG_RESTRICT_PUSHOBJECT = 0x400000; // region restricts llPushObject public const int REGION_FLAG_RESTRICT_PUSHOBJECT = 0x400000; // region restricts llPushObject
//llManageEstateAccess
public const int ESTATE_ACCESS_ALLOWED_AGENT_ADD = 0;
public const int ESTATE_ACCESS_ALLOWED_AGENT_REMOVE = 1;
public const int ESTATE_ACCESS_ALLOWED_GROUP_ADD = 2;
public const int ESTATE_ACCESS_ALLOWED_GROUP_REMOVE = 3;
public const int ESTATE_ACCESS_BANNED_AGENT_ADD = 4;
public const int ESTATE_ACCESS_BANNED_AGENT_REMOVE = 5;
public static readonly LSLInteger PAY_HIDE = new LSLInteger(-1); public static readonly LSLInteger PAY_HIDE = new LSLInteger(-1);
public static readonly LSLInteger PAY_DEFAULT = new LSLInteger(-2); public static readonly LSLInteger PAY_DEFAULT = new LSLInteger(-2);
@ -605,6 +614,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
public const int OS_NPC_SIT_NOW = 0; public const int OS_NPC_SIT_NOW = 0;
public const int OS_NPC_CREATOR_OWNED = 0x1;
public const int OS_NPC_NOT_OWNED = 0x2;
public const int OS_NPC_SENSE_AS_AGENT = 0x4;
public const string URL_REQUEST_GRANTED = "URL_REQUEST_GRANTED"; public const string URL_REQUEST_GRANTED = "URL_REQUEST_GRANTED";
public const string URL_REQUEST_DENIED = "URL_REQUEST_DENIED"; public const string URL_REQUEST_DENIED = "URL_REQUEST_DENIED";

Some files were not shown because too many files have changed in this diff Show More