Merge branch 'master' into careminster-presence-refactor

avinationmerge
Melanie 2011-02-19 01:59:49 +00:00
commit 4834b47679
18 changed files with 585 additions and 418 deletions

View File

@ -181,7 +181,6 @@ namespace OpenSim.Framework.Capabilities
RegisterRegionServiceHandlers(capsBase); RegisterRegionServiceHandlers(capsBase);
RegisterInventoryServiceHandlers(capsBase); RegisterInventoryServiceHandlers(capsBase);
} }
public void RegisterRegionServiceHandlers(string capsBase) public void RegisterRegionServiceHandlers(string capsBase)

View File

@ -785,7 +785,19 @@ namespace OpenSim.Framework.Servers.HttpServer
if (methodWasFound) if (methodWasFound)
{ {
xmlRprcRequest.Params.Add(request.Url); // Param[2] xmlRprcRequest.Params.Add(request.Url); // Param[2]
xmlRprcRequest.Params.Add(request.Headers.Get("X-Forwarded-For")); // Param[3]
string xff = "X-Forwarded-For";
string xfflower = xff.ToLower();
foreach (string s in request.Headers.AllKeys)
{
if (s != null && s.Equals(xfflower))
{
xff = xfflower;
break;
}
}
xmlRprcRequest.Params.Add(request.Headers.Get(xff)); // Param[3]
try try
{ {

View File

@ -845,7 +845,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
private void HandleUseCircuitCode(object o) private void HandleUseCircuitCode(object o)
{ {
DateTime startTime = DateTime.Now; // DateTime startTime = DateTime.Now;
object[] array = (object[])o; object[] array = (object[])o;
UDPPacketBuffer buffer = (UDPPacketBuffer)array[0]; UDPPacketBuffer buffer = (UDPPacketBuffer)array[0];
UseCircuitCodePacket packet = (UseCircuitCodePacket)array[1]; UseCircuitCodePacket packet = (UseCircuitCodePacket)array[1];

View File

@ -49,16 +49,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog
{ {
m_scene = scene; m_scene = scene;
m_scene.RegisterModuleInterface<IDialogModule>(this); m_scene.RegisterModuleInterface<IDialogModule>(this);
m_scene.AddCommand( m_scene.AddCommand(
this, "alert", "alert <first> <last> <message>", this, "alert", "alert <message>",
"Send an alert to a user", "Send an alert to everyone",
HandleAlertConsoleCommand); HandleAlertConsoleCommand);
m_scene.AddCommand( m_scene.AddCommand(
this, "alert general", "alert [general] <message>", this, "alert-user", "alert-user <first> <last> <message>",
"Send an alert to everyone", "Send an alert to a user",
"If keyword 'general' is omitted, then <message> must be surrounded by quotation marks.",
HandleAlertConsoleCommand); HandleAlertConsoleCommand);
} }
@ -177,55 +176,32 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog
{ {
if (m_scene.ConsoleScene() != null && m_scene.ConsoleScene() != m_scene) if (m_scene.ConsoleScene() != null && m_scene.ConsoleScene() != m_scene)
return; return;
bool isGeneral = false;
string firstName = string.Empty;
string lastName = string.Empty;
string message = string.Empty; string message = string.Empty;
if (cmdparams.Length > 1) if (cmdparams[0].ToLower().Equals("alert"))
{ {
firstName = cmdparams[1]; message = CombineParams(cmdparams, 1);
isGeneral = firstName.ToLower().Equals("general"); m_log.InfoFormat("[DIALOG]: Sending general alert in region {0} with message {1}",
} m_scene.RegionInfo.RegionName, message);
if (cmdparams.Length == 2 && !isGeneral) SendGeneralAlert(message);
{
// alert "message"
message = cmdparams[1];
isGeneral = true;
}
else if (cmdparams.Length > 2 && isGeneral)
{
// alert general <message>
message = CombineParams(cmdparams, 2);
} }
else if (cmdparams.Length > 3) else if (cmdparams.Length > 3)
{ {
// alert <first> <last> <message> string firstName = cmdparams[1];
lastName = cmdparams[2]; string lastName = cmdparams[2];
message = CombineParams(cmdparams, 3); message = CombineParams(cmdparams, 3);
m_log.InfoFormat(
"[DIALOG]: Sending alert in region {0} to {1} {2} with message {3}",
m_scene.RegionInfo.RegionName, firstName, lastName, message);
SendAlertToUser(firstName, lastName, message, false);
} }
else else
{ {
OpenSim.Framework.Console.MainConsole.Instance.Output( OpenSim.Framework.Console.MainConsole.Instance.Output(
"Usage: alert \"message\" | alert general <message> | alert <first> <last> <message>"); "Usage: alert <message> | alert-user <first> <last> <message>");
return; return;
} }
if (isGeneral)
{
m_log.InfoFormat(
"[DIALOG]: Sending general alert in region {0} with message {1}",
m_scene.RegionInfo.RegionName, message);
SendGeneralAlert(message);
}
else
{
m_log.InfoFormat(
"[DIALOG]: Sending alert in region {0} to {1} {2} with message {3}",
m_scene.RegionInfo.RegionName, firstName, lastName, message);
SendAlertToUser(firstName, lastName, message, false);
}
} }
private string CombineParams(string[] commandParams, int pos) private string CombineParams(string[] commandParams, int pos)

View File

@ -131,7 +131,16 @@ namespace OpenSim.Region.Framework.Scenes
protected ICapabilitiesModule m_capsModule; protected ICapabilitiesModule m_capsModule;
// Central Update Loop // Central Update Loop
protected int m_fps = 10; protected int m_fps = 10;
protected uint m_frame;
/// <summary>
/// Current scene frame number
/// </summary>
public uint Frame
{
get;
protected set;
}
protected float m_timespan = 0.089f; protected float m_timespan = 0.089f;
protected DateTime m_lastupdate = DateTime.UtcNow; protected DateTime m_lastupdate = DateTime.UtcNow;
@ -1212,6 +1221,9 @@ namespace OpenSim.Region.Framework.Scenes
try try
{ {
Update(); Update();
m_lastUpdate = Util.EnvironmentTickCount();
m_firstHeartbeat = false;
} }
catch (ThreadAbortException) catch (ThreadAbortException)
{ {
@ -1225,190 +1237,180 @@ namespace OpenSim.Region.Framework.Scenes
Watchdog.RemoveThread(); Watchdog.RemoveThread();
} }
/// <summary>
/// Performs per-frame updates on the scene, this should be the central scene loop
/// </summary>
public override void Update() public override void Update()
{ {
float physicsFPS; TimeSpan SinceLastFrame = DateTime.UtcNow - m_lastupdate;
int maintc; float physicsFPS = 0f;
while (!shuttingdown) int maintc = Util.EnvironmentTickCount();
int tmpFrameMS = maintc;
tempOnRezMS = eventMS = backupMS = terrainMS = landMS = 0;
// Increment the frame counter
++Frame;
try
{ {
TimeSpan SinceLastFrame = DateTime.UtcNow - m_lastupdate; // Check if any objects have reached their targets
physicsFPS = 0f; CheckAtTargets();
maintc = Util.EnvironmentTickCount(); // Update SceneObjectGroups that have scheduled themselves for updates
int tmpFrameMS = maintc; // Objects queue their updates onto all scene presences
tempOnRezMS = eventMS = backupMS = terrainMS = landMS = 0; if (Frame % m_update_objects == 0)
m_sceneGraph.UpdateObjectGroups();
// Increment the frame counter // Run through all ScenePresences looking for updates
++m_frame; // Presence updates and queued object updates for each presence are sent to clients
if (Frame % m_update_presences == 0)
m_sceneGraph.UpdatePresences();
try // Coarse locations relate to positions of green dots on the mini-map (on a SecondLife client)
if (Frame % m_update_coarse_locations == 0)
{ {
// Check if any objects have reached their targets List<Vector3> coarseLocations;
CheckAtTargets(); List<UUID> avatarUUIDs;
SceneGraph.GetCoarseLocations(out coarseLocations, out avatarUUIDs, 60);
// Update SceneObjectGroups that have scheduled themselves for updates // Send coarse locations to clients
// Objects queue their updates onto all scene presences ForEachScenePresence(delegate(ScenePresence presence)
if (m_frame % m_update_objects == 0)
m_sceneGraph.UpdateObjectGroups();
// Run through all ScenePresences looking for updates
// Presence updates and queued object updates for each presence are sent to clients
if (m_frame % m_update_presences == 0)
m_sceneGraph.UpdatePresences();
// Coarse locations relate to positions of green dots on the mini-map (on a SecondLife client)
if (m_frame % m_update_coarse_locations == 0)
{ {
List<Vector3> coarseLocations; presence.SendCoarseLocations(coarseLocations, avatarUUIDs);
List<UUID> avatarUUIDs; });
SceneGraph.GetCoarseLocations(out coarseLocations, out avatarUUIDs, 60); }
// Send coarse locations to clients
ForEachScenePresence(delegate(ScenePresence presence) int tmpPhysicsMS2 = Util.EnvironmentTickCount();
{ if ((Frame % m_update_physics == 0) && m_physics_enabled)
presence.SendCoarseLocations(coarseLocations, avatarUUIDs); m_sceneGraph.UpdatePreparePhysics();
}); physicsMS2 = Util.EnvironmentTickCountSubtract(tmpPhysicsMS2);
// Apply any pending avatar force input to the avatar's velocity
if (Frame % m_update_entitymovement == 0)
m_sceneGraph.UpdateScenePresenceMovement();
// Perform the main physics update. This will do the actual work of moving objects and avatars according to their
// velocity
int tmpPhysicsMS = Util.EnvironmentTickCount();
if (Frame % m_update_physics == 0)
{
if (m_physics_enabled)
physicsFPS = m_sceneGraph.UpdatePhysics(Math.Max(SinceLastFrame.TotalSeconds, m_timespan));
if (SynchronizeScene != null)
SynchronizeScene(this);
}
physicsMS = Util.EnvironmentTickCountSubtract(tmpPhysicsMS);
// Delete temp-on-rez stuff
if (Frame % 1000 == 0 && !m_cleaningTemps)
{
int tmpTempOnRezMS = Util.EnvironmentTickCount();
m_cleaningTemps = true;
Util.FireAndForget(delegate { CleanTempObjects(); m_cleaningTemps = false; });
tempOnRezMS = Util.EnvironmentTickCountSubtract(tmpTempOnRezMS);
}
if (RegionStatus != RegionStatus.SlaveScene)
{
if (Frame % m_update_events == 0)
{
int evMS = Util.EnvironmentTickCount();
UpdateEvents();
eventMS = Util.EnvironmentTickCountSubtract(evMS); ;
} }
int tmpPhysicsMS2 = Util.EnvironmentTickCount(); if (Frame % m_update_backup == 0)
if ((m_frame % m_update_physics == 0) && m_physics_enabled)
m_sceneGraph.UpdatePreparePhysics();
physicsMS2 = Util.EnvironmentTickCountSubtract(tmpPhysicsMS2);
// Apply any pending avatar force input to the avatar's velocity
if (m_frame % m_update_entitymovement == 0)
m_sceneGraph.UpdateScenePresenceMovement();
// Perform the main physics update. This will do the actual work of moving objects and avatars according to their
// velocity
int tmpPhysicsMS = Util.EnvironmentTickCount();
if (m_frame % m_update_physics == 0)
{ {
if (m_physics_enabled) int backMS = Util.EnvironmentTickCount();
physicsFPS = m_sceneGraph.UpdatePhysics(Math.Max(SinceLastFrame.TotalSeconds, m_timespan)); UpdateStorageBackup();
if (SynchronizeScene != null) backupMS = Util.EnvironmentTickCountSubtract(backMS);
SynchronizeScene(this);
}
physicsMS = Util.EnvironmentTickCountSubtract(tmpPhysicsMS);
// Delete temp-on-rez stuff
if (m_frame % 1000 == 0 && !m_cleaningTemps)
{
int tmpTempOnRezMS = Util.EnvironmentTickCount();
m_cleaningTemps = true;
Util.FireAndForget(delegate { CleanTempObjects(); m_cleaningTemps = false; });
tempOnRezMS = Util.EnvironmentTickCountSubtract(tmpTempOnRezMS);
} }
if (RegionStatus != RegionStatus.SlaveScene) if (Frame % m_update_terrain == 0)
{ {
if (m_frame % m_update_events == 0) int terMS = Util.EnvironmentTickCount();
{ UpdateTerrain();
int evMS = Util.EnvironmentTickCount(); terrainMS = Util.EnvironmentTickCountSubtract(terMS);
UpdateEvents();
eventMS = Util.EnvironmentTickCountSubtract(evMS); ;
}
if (m_frame % m_update_backup == 0)
{
int backMS = Util.EnvironmentTickCount();
UpdateStorageBackup();
backupMS = Util.EnvironmentTickCountSubtract(backMS);
}
if (m_frame % m_update_terrain == 0)
{
int terMS = Util.EnvironmentTickCount();
UpdateTerrain();
terrainMS = Util.EnvironmentTickCountSubtract(terMS);
}
if (m_frame % m_update_land == 0)
{
int ldMS = Util.EnvironmentTickCount();
UpdateLand();
landMS = Util.EnvironmentTickCountSubtract(ldMS);
}
frameMS = Util.EnvironmentTickCountSubtract(tmpFrameMS);
otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS;
lastCompletedFrame = Util.EnvironmentTickCount();
// if (m_frame%m_update_avatars == 0)
// UpdateInWorldTime();
StatsReporter.AddPhysicsFPS(physicsFPS);
StatsReporter.AddTimeDilation(TimeDilation);
StatsReporter.AddFPS(1);
StatsReporter.SetRootAgents(m_sceneGraph.GetRootAgentCount());
StatsReporter.SetChildAgents(m_sceneGraph.GetChildAgentCount());
StatsReporter.SetObjects(m_sceneGraph.GetTotalObjectsCount());
StatsReporter.SetActiveObjects(m_sceneGraph.GetActiveObjectsCount());
StatsReporter.addFrameMS(frameMS);
StatsReporter.addPhysicsMS(physicsMS + physicsMS2);
StatsReporter.addOtherMS(otherMS);
StatsReporter.SetActiveScripts(m_sceneGraph.GetActiveScriptsCount());
StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS());
} }
if (LoginsDisabled && m_frame == 20) if (Frame % m_update_land == 0)
{ {
// In 99.9% of cases it is a bad idea to manually force garbage collection. However, int ldMS = Util.EnvironmentTickCount();
// this is a rare case where we know we have just went through a long cycle of heap UpdateLand();
// allocations, and there is no more work to be done until someone logs in landMS = Util.EnvironmentTickCountSubtract(ldMS);
GC.Collect(); }
IConfig startupConfig = m_config.Configs["Startup"]; frameMS = Util.EnvironmentTickCountSubtract(tmpFrameMS);
if (startupConfig == null || !startupConfig.GetBoolean("StartDisabled", false)) otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS;
{ lastCompletedFrame = Util.EnvironmentTickCount();
m_log.DebugFormat("[REGION]: Enabling logins for {0}", RegionInfo.RegionName);
LoginsDisabled = false; // if (Frame%m_update_avatars == 0)
m_sceneGridService.InformNeighborsThatRegionisUp(RequestModuleInterface<INeighbourService>(), RegionInfo); // UpdateInWorldTime();
} StatsReporter.AddPhysicsFPS(physicsFPS);
StatsReporter.AddTimeDilation(TimeDilation);
StatsReporter.AddFPS(1);
StatsReporter.SetRootAgents(m_sceneGraph.GetRootAgentCount());
StatsReporter.SetChildAgents(m_sceneGraph.GetChildAgentCount());
StatsReporter.SetObjects(m_sceneGraph.GetTotalObjectsCount());
StatsReporter.SetActiveObjects(m_sceneGraph.GetActiveObjectsCount());
StatsReporter.addFrameMS(frameMS);
StatsReporter.addPhysicsMS(physicsMS + physicsMS2);
StatsReporter.addOtherMS(otherMS);
StatsReporter.SetActiveScripts(m_sceneGraph.GetActiveScriptsCount());
StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS());
}
if (LoginsDisabled && Frame == 20)
{
// In 99.9% of cases it is a bad idea to manually force garbage collection. However,
// this is a rare case where we know we have just went through a long cycle of heap
// allocations, and there is no more work to be done until someone logs in
GC.Collect();
IConfig startupConfig = m_config.Configs["Startup"];
if (startupConfig == null || !startupConfig.GetBoolean("StartDisabled", false))
{
m_log.DebugFormat("[REGION]: Enabling logins for {0}", RegionInfo.RegionName);
LoginsDisabled = false;
m_sceneGridService.InformNeighborsThatRegionisUp(RequestModuleInterface<INeighbourService>(), RegionInfo);
} }
} }
catch (NotImplementedException)
{
throw;
}
catch (AccessViolationException e)
{
m_log.Error("[REGION]: Failed with exception " + e.ToString() + " On Region: " + RegionInfo.RegionName);
}
//catch (NullReferenceException e)
//{
// m_log.Error("[REGION]: Failed with exception " + e.ToString() + " On Region: " + RegionInfo.RegionName);
//}
catch (InvalidOperationException e)
{
m_log.Error("[REGION]: Failed with exception " + e.ToString() + " On Region: " + RegionInfo.RegionName);
}
catch (Exception e)
{
m_log.Error("[REGION]: Failed with exception " + e.ToString() + " On Region: " + RegionInfo.RegionName);
}
finally
{
m_lastupdate = DateTime.UtcNow;
}
maintc = Util.EnvironmentTickCountSubtract(maintc);
maintc = (int)(m_timespan * 1000) - maintc;
if (maintc > 0)
Thread.Sleep(maintc);
// Tell the watchdog that this thread is still alive
Watchdog.UpdateThread();
m_lastUpdate = Util.EnvironmentTickCount();
m_firstHeartbeat = false;
} }
} catch (NotImplementedException)
{
throw;
}
catch (AccessViolationException e)
{
m_log.Error("[REGION]: Failed with exception " + e.ToString() + " On Region: " + RegionInfo.RegionName);
}
//catch (NullReferenceException e)
//{
// m_log.Error("[REGION]: Failed with exception " + e.ToString() + " On Region: " + RegionInfo.RegionName);
//}
catch (InvalidOperationException e)
{
m_log.Error("[REGION]: Failed with exception " + e.ToString() + " On Region: " + RegionInfo.RegionName);
}
catch (Exception e)
{
m_log.Error("[REGION]: Failed with exception " + e.ToString() + " On Region: " + RegionInfo.RegionName);
}
finally
{
m_lastupdate = DateTime.UtcNow;
}
maintc = Util.EnvironmentTickCountSubtract(maintc);
maintc = (int)(m_timespan * 1000) - maintc;
m_lastUpdate = Util.EnvironmentTickCount();
m_firstHeartbeat = false;
if (maintc > 0)
Thread.Sleep(maintc);
// Tell the watchdog that this thread is still alive
Watchdog.UpdateThread();
}
public void AddGroupTarget(SceneObjectGroup grp) public void AddGroupTarget(SceneObjectGroup grp)
{ {
@ -3127,7 +3129,9 @@ namespace OpenSim.Region.Framework.Scenes
(childagentYN ? "child" : "root"), agentID, RegionInfo.RegionName); (childagentYN ? "child" : "root"), agentID, RegionInfo.RegionName);
m_sceneGraph.removeUserCount(!childagentYN); m_sceneGraph.removeUserCount(!childagentYN);
CapsModule.RemoveCapsHandler(agentID);
if (CapsModule != null)
CapsModule.RemoveCapsHandler(agentID);
// REFACTORING PROBLEM -- well not really a problem, but just to point out that whatever // REFACTORING PROBLEM -- well not really a problem, but just to point out that whatever
// this method is doing is HORRIBLE!!! // this method is doing is HORRIBLE!!!
@ -3405,8 +3409,11 @@ namespace OpenSim.Region.Framework.Scenes
RegionInfo.RegionName, (agent.child ? "child" : "root"), agent.firstname, agent.lastname, RegionInfo.RegionName, (agent.child ? "child" : "root"), agent.firstname, agent.lastname,
agent.AgentID, agent.circuitcode); agent.AgentID, agent.circuitcode);
CapsModule.NewUserConnection(agent); if (CapsModule != null)
CapsModule.AddCapsHandler(agent.AgentID); {
CapsModule.NewUserConnection(agent);
CapsModule.AddCapsHandler(agent.AgentID);
}
} }
else else
{ {
@ -3421,7 +3428,9 @@ namespace OpenSim.Region.Framework.Scenes
agent.AgentID, RegionInfo.RegionName); agent.AgentID, RegionInfo.RegionName);
sp.AdjustKnownSeeds(); sp.AdjustKnownSeeds();
CapsModule.NewUserConnection(agent);
if (CapsModule != null)
CapsModule.NewUserConnection(agent);
} }
} }
@ -3933,15 +3942,15 @@ namespace OpenSim.Region.Framework.Scenes
public void RequestTeleportLocation(IClientAPI remoteClient, string regionName, Vector3 position, public void RequestTeleportLocation(IClientAPI remoteClient, string regionName, Vector3 position,
Vector3 lookat, uint teleportFlags) Vector3 lookat, uint teleportFlags)
{ {
GridRegion regionInfo = GridService.GetRegionByName(UUID.Zero, regionName); List<GridRegion> regions = GridService.GetRegionsByName(RegionInfo.ScopeID, regionName, 1);
if (regionInfo == null) if (regions == null || regions.Count == 0)
{ {
// can't find the region: Tell viewer and abort // can't find the region: Tell viewer and abort
remoteClient.SendTeleportFailed("The region '" + regionName + "' could not be found."); remoteClient.SendTeleportFailed("The region '" + regionName + "' could not be found.");
return; return;
} }
RequestTeleportLocation(remoteClient, regionInfo.RegionHandle, position, lookat, teleportFlags); RequestTeleportLocation(remoteClient, regions[0].RegionHandle, position, lookat, teleportFlags);
} }
/// <summary> /// <summary>

View File

@ -1310,7 +1310,9 @@ namespace OpenSim.Region.Framework.Scenes
if (m_agentTransfer != null) if (m_agentTransfer != null)
m_agentTransfer.EnableChildAgents(this); m_agentTransfer.EnableChildAgents(this);
else else
m_log.DebugFormat("[SCENE PRESENCE]: Unable to create child agents in neighbours, because AgentTransferModule is not active"); m_log.DebugFormat(
"[SCENE PRESENCE]: Unable to create child agents in neighbours, because AgentTransferModule is not active for region {0}",
m_scene.RegionInfo.RegionName);
IFriendsModule friendsModule = m_scene.RequestModuleInterface<IFriendsModule>(); IFriendsModule friendsModule = m_scene.RequestModuleInterface<IFriendsModule>();
if (friendsModule != null) if (friendsModule != null)
@ -3028,8 +3030,11 @@ namespace OpenSim.Region.Framework.Scenes
#region Border Crossing Methods #region Border Crossing Methods
/// <summary> /// <summary>
/// Checks to see if the avatar is in range of a border and calls CrossToNewRegion /// Starts the process of moving an avatar into another region if they are crossing the border.
/// </summary> /// </summary>
/// <remarks>
/// Also removes the avatar from the physical scene if transit has started.
/// </remarks>
protected void CheckForBorderCrossing() protected void CheckForBorderCrossing()
{ {
if (IsChildAgent) if (IsChildAgent)
@ -3097,7 +3102,6 @@ namespace OpenSim.Region.Framework.Scenes
neighbor = HaveNeighbor(Cardinals.N, ref fix); neighbor = HaveNeighbor(Cardinals.N, ref fix);
} }
// Makes sure avatar does not end up outside region // Makes sure avatar does not end up outside region
if (neighbor <= 0) if (neighbor <= 0)
{ {
@ -3152,6 +3156,13 @@ namespace OpenSim.Region.Framework.Scenes
} }
else else
{ {
// We must remove the agent from the physical scene if it has been placed in transit. If we don't,
// then this method continues to be called from ScenePresence.Update() until the handover of the client between
// regions is completed. Since this handover can take more than 1000ms (due to the 1000ms
// event queue polling response from the server), this results in the avatar pausing on the border
// for the handover period.
RemoveFromPhysicalScene();
// This constant has been inferred from experimentation // This constant has been inferred from experimentation
// I'm not sure what this value should be, so I tried a few values. // I'm not sure what this value should be, so I tried a few values.
timeStep = 0.04f; timeStep = 0.04f;
@ -3163,6 +3174,15 @@ namespace OpenSim.Region.Framework.Scenes
} }
} }
/// <summary>
/// Checks whether this region has a neighbour in the given direction.
/// </summary>
/// <param name="car"></param>
/// <param name="fix"></param>
/// <returns>
/// An integer which represents a compass point. N == 1, going clockwise until we reach NW == 8.
/// Returns a positive integer if there is a region in that direction, a negative integer if not.
/// </returns>
protected int HaveNeighbor(Cardinals car, ref int[] fix) protected int HaveNeighbor(Cardinals car, ref int[] fix)
{ {
uint neighbourx = m_regionInfo.RegionLocX; uint neighbourx = m_regionInfo.RegionLocX;

View File

@ -0,0 +1,174 @@
/*
* 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 System.Threading;
using System.Timers;
using Timer=System.Timers.Timer;
using Nini.Config;
using NUnit.Framework;
using NUnit.Framework.SyntaxHelpers;
using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Framework.Communications;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.CoreModules.World.Serialiser;
using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation;
using OpenSim.Tests.Common;
using OpenSim.Tests.Common.Mock;
using OpenSim.Tests.Common.Setup;
namespace OpenSim.Region.Framework.Scenes.Tests
{
/// <summary>
/// Attachment tests
/// </summary>
[TestFixture]
public class AttachmentTests
{
public Scene scene, scene2;
public UUID agent1;
public static Random random;
public ulong region1, region2;
public AgentCircuitData acd1;
public SceneObjectGroup sog1, sog2, sog3;
[TestFixtureSetUp]
public void Init()
{
TestHelper.InMethod();
scene = SceneSetupHelpers.SetupScene("Neighbour x", UUID.Random(), 1000, 1000);
scene2 = SceneSetupHelpers.SetupScene("Neighbour x+1", UUID.Random(), 1001, 1000);
ISharedRegionModule interregionComms = new LocalSimulationConnectorModule();
interregionComms.Initialise(new IniConfigSource());
interregionComms.PostInitialise();
SceneSetupHelpers.SetupSceneModules(scene, new IniConfigSource(), interregionComms);
SceneSetupHelpers.SetupSceneModules(scene2, new IniConfigSource(), interregionComms);
agent1 = UUID.Random();
random = new Random();
sog1 = NewSOG(UUID.Random(), scene, agent1);
sog2 = NewSOG(UUID.Random(), scene, agent1);
sog3 = NewSOG(UUID.Random(), scene, agent1);
//ulong neighbourHandle = Utils.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize));
region1 = scene.RegionInfo.RegionHandle;
region2 = scene2.RegionInfo.RegionHandle;
SceneSetupHelpers.AddRootAgent(scene, agent1);
}
[Test]
public void T030_TestAddAttachments()
{
TestHelper.InMethod();
ScenePresence presence = scene.GetScenePresence(agent1);
presence.AddAttachment(sog1);
presence.AddAttachment(sog2);
presence.AddAttachment(sog3);
Assert.That(presence.HasAttachments(), Is.True);
Assert.That(presence.ValidateAttachments(), Is.True);
}
[Test]
public void T031_RemoveAttachments()
{
TestHelper.InMethod();
ScenePresence presence = scene.GetScenePresence(agent1);
presence.RemoveAttachment(sog1);
presence.RemoveAttachment(sog2);
presence.RemoveAttachment(sog3);
Assert.That(presence.HasAttachments(), Is.False);
}
// I'm commenting this test because scene setup NEEDS InventoryService to
// be non-null
//[Test]
public void T032_CrossAttachments()
{
TestHelper.InMethod();
ScenePresence presence = scene.GetScenePresence(agent1);
ScenePresence presence2 = scene2.GetScenePresence(agent1);
presence2.AddAttachment(sog1);
presence2.AddAttachment(sog2);
ISharedRegionModule serialiser = new SerialiserModule();
SceneSetupHelpers.SetupSceneModules(scene, new IniConfigSource(), serialiser);
SceneSetupHelpers.SetupSceneModules(scene2, new IniConfigSource(), serialiser);
Assert.That(presence.HasAttachments(), Is.False, "Presence has attachments before cross");
//Assert.That(presence2.CrossAttachmentsIntoNewRegion(region1, true), Is.True, "Cross was not successful");
Assert.That(presence2.HasAttachments(), Is.False, "Presence2 objects were not deleted");
Assert.That(presence.HasAttachments(), Is.True, "Presence has not received new objects");
}
private SceneObjectGroup NewSOG(UUID uuid, Scene scene, UUID agent)
{
SceneObjectPart sop = new SceneObjectPart();
sop.Name = RandomName();
sop.Description = RandomName();
sop.Text = RandomName();
sop.SitName = RandomName();
sop.TouchName = RandomName();
sop.UUID = uuid;
sop.Shape = PrimitiveBaseShape.Default;
sop.Shape.State = 1;
sop.OwnerID = agent;
SceneObjectGroup sog = new SceneObjectGroup(sop);
sog.SetScene(scene);
return sog;
}
private static string RandomName()
{
StringBuilder name = new StringBuilder();
int size = random.Next(5,12);
char ch;
for (int i = 0; i < size; i++)
{
ch = Convert.ToChar(Convert.ToInt32(Math.Floor(26 * random.NextDouble() + 65))) ;
name.Append(ch);
}
return name.ToString();
}
}
}

View File

@ -40,6 +40,7 @@ using OpenSim.Framework;
using OpenSim.Framework.Communications; using OpenSim.Framework.Communications;
using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.CoreModules.Framework.EntityTransfer;
using OpenSim.Region.CoreModules.World.Serialiser; using OpenSim.Region.CoreModules.World.Serialiser;
using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation;
using OpenSim.Tests.Common; using OpenSim.Tests.Common;
@ -116,9 +117,6 @@ namespace OpenSim.Region.Framework.Scenes.Tests
agent.ChildrenCapSeeds = new Dictionary<ulong, string>(); agent.ChildrenCapSeeds = new Dictionary<ulong, string>();
agent.child = true; agent.child = true;
if (scene.PresenceService == null)
Console.WriteLine("Presence Service is null");
scene.PresenceService.LoginAgent(agent.AgentID.ToString(), agent.SessionID, agent.SecureSessionID); scene.PresenceService.LoginAgent(agent.AgentID.ToString(), agent.SessionID, agent.SecureSessionID);
string reason; string reason;
@ -175,25 +173,6 @@ namespace OpenSim.Region.Framework.Scenes.Tests
Assert.That(neighbours.Count, Is.EqualTo(2)); Assert.That(neighbours.Count, Is.EqualTo(2));
} }
public void fixNullPresence()
{
string firstName = "testfirstname";
AgentCircuitData agent = new AgentCircuitData();
agent.AgentID = agent1;
agent.firstname = firstName;
agent.lastname = "testlastname";
agent.SessionID = UUID.Zero;
agent.SecureSessionID = UUID.Zero;
agent.circuitcode = 123;
agent.BaseFolder = UUID.Zero;
agent.InventoryFolder = UUID.Zero;
agent.startpos = Vector3.Zero;
agent.CapsPath = GetRandomCapsObjectPath();
acd1 = agent;
}
[Test] [Test]
public void T013_TestRemoveNeighbourRegion() public void T013_TestRemoveNeighbourRegion()
@ -211,24 +190,36 @@ namespace OpenSim.Region.Framework.Scenes.Tests
CompleteAvatarMovement CompleteAvatarMovement
*/ */
} }
// I'm commenting this test, because this is not supposed to happen here /// <summary>
//[Test] /// Test that if a root agent logs into a region, a child agent is also established in the neighbouring region
public void T020_TestMakeRootAgent() /// </summary>
/// <remarks>
/// Please note that unlike the other tests here, this doesn't rely on structures
/// </remarks>
[Test]
public void TestChildAgentEstablished()
{ {
TestHelper.InMethod(); TestHelper.InMethod();
// log4net.Config.XmlConfigurator.Configure();
ScenePresence presence = scene.GetScenePresence(agent1);
Assert.That(presence.IsChildAgent, Is.False, "Starts out as a root agent"); UUID agent1Id = UUID.Parse("00000000-0000-0000-0000-000000000001");
presence.MakeChildAgent(); TestScene myScene1 = SceneSetupHelpers.SetupScene("Neighbour y", UUID.Random(), 1000, 1000);
Assert.That(presence.IsChildAgent, Is.True, "Did not change to child agent after MakeChildAgent"); TestScene myScene2 = SceneSetupHelpers.SetupScene("Neighbour y + 1", UUID.Random(), 1001, 1000);
// Accepts 0 but rejects Constants.RegionSize IConfigSource configSource = new IniConfigSource();
Vector3 pos = new Vector3(0,unchecked(Constants.RegionSize-1),0); configSource.AddConfig("Modules").Set("EntityTransferModule", "BasicEntityTransferModule");
presence.MakeRootAgent(pos,true); EntityTransferModule etm = new EntityTransferModule();
Assert.That(presence.IsChildAgent, Is.False, "Did not go back to root agent");
Assert.That(presence.AbsolutePosition, Is.EqualTo(pos), "Position is not the same one entered"); SceneSetupHelpers.SetupSceneModules(myScene1, configSource, etm);
SceneSetupHelpers.AddRootAgent(myScene1, agent1Id);
ScenePresence childPresence = myScene2.GetScenePresence(agent1);
// TODO: Need to do a fair amount of work to allow synchronous establishment of child agents
// Assert.That(childPresence, Is.Not.Null);
// Assert.That(childPresence.IsChildAgent, Is.True);
} }
// I'm commenting this test because it does not represent // I'm commenting this test because it does not represent
@ -333,63 +324,26 @@ namespace OpenSim.Region.Framework.Scenes.Tests
Assert.That(presence2.IsChildAgent, Is.True, "Did not return from region as expected."); Assert.That(presence2.IsChildAgent, Is.True, "Did not return from region as expected.");
Assert.That(presence.IsChildAgent, Is.False, "Presence was not made root in old region again."); Assert.That(presence.IsChildAgent, Is.False, "Presence was not made root in old region again.");
} }
[Test] public void fixNullPresence()
public void T030_TestAddAttachments()
{ {
TestHelper.InMethod(); string firstName = "testfirstname";
ScenePresence presence = scene.GetScenePresence(agent1); AgentCircuitData agent = new AgentCircuitData();
agent.AgentID = agent1;
agent.firstname = firstName;
agent.lastname = "testlastname";
agent.SessionID = UUID.Zero;
agent.SecureSessionID = UUID.Zero;
agent.circuitcode = 123;
agent.BaseFolder = UUID.Zero;
agent.InventoryFolder = UUID.Zero;
agent.startpos = Vector3.Zero;
agent.CapsPath = GetRandomCapsObjectPath();
presence.AddAttachment(sog1); acd1 = agent;
presence.AddAttachment(sog2);
presence.AddAttachment(sog3);
Assert.That(presence.HasAttachments(), Is.True);
Assert.That(presence.ValidateAttachments(), Is.True);
} }
[Test]
public void T031_RemoveAttachments()
{
TestHelper.InMethod();
ScenePresence presence = scene.GetScenePresence(agent1);
presence.RemoveAttachment(sog1);
presence.RemoveAttachment(sog2);
presence.RemoveAttachment(sog3);
Assert.That(presence.HasAttachments(), Is.False);
}
// I'm commenting this test because scene setup NEEDS InventoryService to
// be non-null
//[Test]
public void T032_CrossAttachments()
{
TestHelper.InMethod();
ScenePresence presence = scene.GetScenePresence(agent1);
ScenePresence presence2 = scene2.GetScenePresence(agent1);
presence2.AddAttachment(sog1);
presence2.AddAttachment(sog2);
ISharedRegionModule serialiser = new SerialiserModule();
SceneSetupHelpers.SetupSceneModules(scene, new IniConfigSource(), serialiser);
SceneSetupHelpers.SetupSceneModules(scene2, new IniConfigSource(), serialiser);
Assert.That(presence.HasAttachments(), Is.False, "Presence has attachments before cross");
//Assert.That(presence2.CrossAttachmentsIntoNewRegion(region1, true), Is.True, "Cross was not successful");
Assert.That(presence2.HasAttachments(), Is.False, "Presence2 objects were not deleted");
Assert.That(presence.HasAttachments(), Is.True, "Presence has not received new objects");
}
[TearDown]
public void TearDown()
{
if (MainServer.Instance != null) MainServer.Instance.Stop();
}
public static string GetRandomCapsObjectPath() public static string GetRandomCapsObjectPath()
{ {
UUID caps = UUID.Random(); UUID caps = UUID.Random();

View File

@ -0,0 +1,71 @@
/*
* 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 System.Threading;
using System.Timers;
using Timer=System.Timers.Timer;
using Nini.Config;
using NUnit.Framework;
using NUnit.Framework.SyntaxHelpers;
using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Framework.Communications;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.CoreModules.World.Serialiser;
using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation;
using OpenSim.Tests.Common;
using OpenSim.Tests.Common.Mock;
using OpenSim.Tests.Common.Setup;
namespace OpenSim.Region.Framework.Scenes.Tests
{
/// <summary>
/// Scene presence tests
/// </summary>
[TestFixture]
public class SceneTests
{
/// <summary>
/// Very basic scene update test. Should become more elaborate with time.
/// </summary>
[Test]
public void TestUpdateScene()
{
TestHelper.InMethod();
Scene scene = SceneSetupHelpers.SetupScene();
scene.Update();
Assert.That(scene.Frame, Is.EqualTo(1));
}
}
}

View File

@ -690,10 +690,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
// //
CheckThreatLevel(ThreatLevel.High, "osTeleportAgent"); CheckThreatLevel(ThreatLevel.High, "osTeleportAgent");
TeleportAgent(agent, regionName, position, lookat); TeleportAgent(agent, regionName, position, lookat, false);
} }
private void TeleportAgent(string agent, string regionName, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat) private void TeleportAgent(string agent, string regionName,
LSL_Types.Vector3 position, LSL_Types.Vector3 lookat, bool relaxRestrictions)
{ {
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
UUID agentId = new UUID(); UUID agentId = new UUID();
@ -702,25 +703,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
ScenePresence presence = World.GetScenePresence(agentId); ScenePresence presence = World.GetScenePresence(agentId);
if (presence != null) if (presence != null)
{ {
// agent must be over owners land to avoid abuse // For osTeleportAgent, agent must be over owners land to avoid abuse
if (m_host.OwnerID // For osTeleportOwner, this restriction isn't necessary
if (relaxRestrictions ||
m_host.OwnerID
== World.LandChannel.GetLandObject( == World.LandChannel.GetLandObject(
presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID) presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID)
{ {
// Check for hostname, attempt to make a HG link,
// and convert the regionName to the target region
if (regionName.Contains(".") && regionName.Contains(":"))
{
// Even though we use none of the results, we need to perform this call because it appears
// to have some the side effect of setting up hypergrid teleport locations.
World.GridService.GetRegionsByName(World.RegionInfo.ScopeID, regionName, 1);
// List<GridRegion> regions = World.GridService.GetRegionsByName(World.RegionInfo.ScopeID, regionName, 1);
string[] parts = regionName.Split(new char[] { ':' });
if (parts.Length > 2)
regionName = parts[0] + ':' + parts[1] + "/ " + parts[2];
regionName = "http://" + regionName;
}
World.RequestTeleportLocation(presence.ControllingClient, regionName, World.RequestTeleportLocation(presence.ControllingClient, regionName,
new Vector3((float)position.x, (float)position.y, (float)position.z), new Vector3((float)position.x, (float)position.y, (float)position.z),
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);
@ -737,10 +726,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
// //
CheckThreatLevel(ThreatLevel.High, "osTeleportAgent"); CheckThreatLevel(ThreatLevel.High, "osTeleportAgent");
TeleportAgent(agent, regionX, regionY, position, lookat); TeleportAgent(agent, regionX, regionY, position, lookat, false);
} }
private void TeleportAgent(string agent, int regionX, int regionY, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat) private void TeleportAgent(string agent, int regionX, int regionY,
LSL_Types.Vector3 position, LSL_Types.Vector3 lookat, bool relaxRestrictions)
{ {
ulong regionHandle = Util.UIntsToLong(((uint)regionX * (uint)Constants.RegionSize), ((uint)regionY * (uint)Constants.RegionSize)); ulong regionHandle = Util.UIntsToLong(((uint)regionX * (uint)Constants.RegionSize), ((uint)regionY * (uint)Constants.RegionSize));
@ -751,8 +741,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
ScenePresence presence = World.GetScenePresence(agentId); ScenePresence presence = World.GetScenePresence(agentId);
if (presence != null) if (presence != null)
{ {
// agent must be over owners land to avoid abuse // For osTeleportAgent, agent must be over owners land to avoid abuse
if (m_host.OwnerID // For osTeleportOwner, this restriction isn't necessary
if (relaxRestrictions ||
m_host.OwnerID
== World.LandChannel.GetLandObject( == World.LandChannel.GetLandObject(
presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID) presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID)
{ {
@ -775,7 +767,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
// Threat level None because this is what can already be done with the World Map in the viewer // Threat level None because this is what can already be done with the World Map in the viewer
CheckThreatLevel(ThreatLevel.None, "osTeleportOwner"); CheckThreatLevel(ThreatLevel.None, "osTeleportOwner");
TeleportAgent(m_host.OwnerID.ToString(), regionName, position, lookat); TeleportAgent(m_host.OwnerID.ToString(), regionName, position, lookat, true);
} }
public void osTeleportOwner(LSL_Types.Vector3 position, LSL_Types.Vector3 lookat) public void osTeleportOwner(LSL_Types.Vector3 position, LSL_Types.Vector3 lookat)
@ -787,7 +779,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{ {
CheckThreatLevel(ThreatLevel.None, "osTeleportOwner"); CheckThreatLevel(ThreatLevel.None, "osTeleportOwner");
TeleportAgent(m_host.OwnerID.ToString(), regionX, regionY, position, lookat); TeleportAgent(m_host.OwnerID.ToString(), regionX, regionY, position, lookat, true);
} }
// Functions that get information from the agent itself. // Functions that get information from the agent itself.

View File

@ -185,7 +185,7 @@ namespace OpenSim.Services.Connectors.Simulation
} }
// unreachable // unreachable
return true; // return true;
} }
/// <summary> /// <summary>
@ -274,7 +274,11 @@ namespace OpenSim.Services.Connectors.Simulation
try try
{ {
OSDMap result = WebUtil.ServiceOSDRequest(uri, request, "QUERYACCESS", 10000); OSDMap result = WebUtil.ServiceOSDRequest(uri, request, "QUERYACCESS", 10000);
bool success = result["Success"].AsBoolean(); bool success = result["success"].AsBoolean();
reason = result["reason"].AsString();
//m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: QueryAccess to {0} returned {1}", uri, success);
if (!success) if (!success)
{ {
if (result.ContainsKey("Message")) if (result.ContainsKey("Message"))

View File

@ -271,6 +271,7 @@ namespace OpenSim.Services.GridService
{ {
List<GridRegion> rinfos = new List<GridRegion>(); List<GridRegion> rinfos = new List<GridRegion>();
RegionData region = m_Database.Get(regionID, scopeID); RegionData region = m_Database.Get(regionID, scopeID);
if (region != null) if (region != null)
{ {
// Not really? Maybe? // Not really? Maybe?
@ -278,15 +279,24 @@ namespace OpenSim.Services.GridService
region.posX + (int)Constants.RegionSize + 1, region.posY + (int)Constants.RegionSize + 1, scopeID); region.posX + (int)Constants.RegionSize + 1, region.posY + (int)Constants.RegionSize + 1, scopeID);
foreach (RegionData rdata in rdatas) foreach (RegionData rdata in rdatas)
{
if (rdata.RegionID != regionID) if (rdata.RegionID != regionID)
{ {
int flags = Convert.ToInt32(rdata.Data["flags"]); int flags = Convert.ToInt32(rdata.Data["flags"]);
if ((flags & (int)Data.RegionFlags.Hyperlink) == 0) // no hyperlinks as neighbours if ((flags & (int)Data.RegionFlags.Hyperlink) == 0) // no hyperlinks as neighbours
rinfos.Add(RegionData2RegionInfo(rdata)); rinfos.Add(RegionData2RegionInfo(rdata));
} }
}
m_log.DebugFormat("[GRID SERVICE]: region {0} has {1} neighbours", region.RegionName, rinfos.Count);
} }
m_log.DebugFormat("[GRID SERVICE]: region {0} has {1} neighbours", region.RegionName, rinfos.Count); else
{
m_log.WarnFormat(
"[GRID SERVICE]: GetNeighbours() called for scope {0}, region {1} but no such region found",
scopeID, regionID);
}
return rinfos; return rinfos;
} }

View File

@ -121,7 +121,7 @@ namespace OpenSim.Services.GridService
m_Check4096 = gridConfig.GetBoolean("Check4096", true); m_Check4096 = gridConfig.GetBoolean("Check4096", true);
m_MapTileDirectory = gridConfig.GetString("MapTileDirectory", string.Empty); m_MapTileDirectory = gridConfig.GetString("MapTileDirectory", "maptiles");
m_GatekeeperConnector = new GatekeeperServiceConnector(m_AssetService); m_GatekeeperConnector = new GatekeeperServiceConnector(m_AssetService);

View File

@ -560,8 +560,11 @@ namespace OpenSim.Tests.Common.Mock
agentData.lastname = m_lastName; agentData.lastname = m_lastName;
ICapabilitiesModule capsModule = m_scene.RequestModuleInterface<ICapabilitiesModule>(); ICapabilitiesModule capsModule = m_scene.RequestModuleInterface<ICapabilitiesModule>();
agentData.CapsPath = capsModule.GetCapsPath(m_agentId); if (capsModule != null)
agentData.ChildrenCapSeeds = new Dictionary<ulong, string>(capsModule.GetChildrenSeeds(m_agentId)); {
agentData.CapsPath = capsModule.GetCapsPath(m_agentId);
agentData.ChildrenCapSeeds = new Dictionary<ulong, string>(capsModule.GetChildrenSeeds(m_agentId));
}
return agentData; return agentData;
} }

View File

@ -132,24 +132,11 @@ namespace OpenSim.Tests.Common.Setup
public static TestScene SetupScene( public static TestScene SetupScene(
string name, UUID id, uint x, uint y, String realServices) string name, UUID id, uint x, uint y, String realServices)
{ {
bool newScene = false;
Console.WriteLine("Setting up test scene {0}", name); Console.WriteLine("Setting up test scene {0}", name);
// REFACTORING PROBLEM!
//// If cm is the same as our last commsManager used, this means the tester wants to link
//// regions. In this case, don't use the sameshared region modules and dont initialize them again.
//// Also, no need to start another MainServer and MainConsole instance.
//if (cm == null || cm != commsManager)
//{
// System.Console.WriteLine("Starting a brand new scene");
// newScene = true;
MainConsole.Instance = new MockConsole("TEST PROMPT");
// MainServer.Instance = new BaseHttpServer(980);
// commsManager = cm;
//}
// We must set up a console otherwise setup of some modules may fail // We must set up a console otherwise setup of some modules may fail
MainConsole.Instance = new MockConsole("TEST PROMPT");
RegionInfo regInfo = new RegionInfo(x, y, new IPEndPoint(IPAddress.Loopback, 9000), "127.0.0.1"); RegionInfo regInfo = new RegionInfo(x, y, new IPEndPoint(IPAddress.Loopback, 9000), "127.0.0.1");
regInfo.RegionName = name; regInfo.RegionName = name;
regInfo.RegionID = id; regInfo.RegionID = id;
@ -164,50 +151,27 @@ namespace OpenSim.Tests.Common.Setup
TestScene testScene = new TestScene( TestScene testScene = new TestScene(
regInfo, acm, scs, simDataService, estateDataService, null, false, false, false, configSource, null); regInfo, acm, scs, simDataService, estateDataService, null, false, false, false, configSource, null);
INonSharedRegionModule capsModule = new CapabilitiesModule();
capsModule.Initialise(new IniConfigSource());
testScene.AddRegionModule(capsModule.Name, capsModule);
capsModule.AddRegion(testScene);
IRegionModule godsModule = new GodsModule(); IRegionModule godsModule = new GodsModule();
godsModule.Initialise(testScene, new IniConfigSource()); godsModule.Initialise(testScene, new IniConfigSource());
testScene.AddModule(godsModule.Name, godsModule); testScene.AddModule(godsModule.Name, godsModule);
realServices = realServices.ToLower(); realServices = realServices.ToLower();
// IConfigSource config = new IniConfigSource();
// If we have a brand new scene, need to initialize shared region modules if (realServices.Contains("asset"))
if ((m_assetService == null && m_inventoryService == null) || newScene) StartAssetService(testScene, true);
{
if (realServices.Contains("asset"))
StartAssetService(testScene, true);
else
StartAssetService(testScene, false);
// For now, always started a 'real' authentication service
StartAuthenticationService(testScene, true);
if (realServices.Contains("inventory"))
StartInventoryService(testScene, true);
else
StartInventoryService(testScene, false);
StartGridService(testScene, true);
StartUserAccountService(testScene);
StartPresenceService(testScene);
}
// If not, make sure the shared module gets references to this new scene
else else
{ StartAssetService(testScene, false);
m_assetService.AddRegion(testScene);
m_assetService.RegionLoaded(testScene);
m_inventoryService.AddRegion(testScene);
m_inventoryService.RegionLoaded(testScene);
m_userAccountService.AddRegion(testScene);
m_userAccountService.RegionLoaded(testScene);
m_presenceService.AddRegion(testScene);
m_presenceService.RegionLoaded(testScene);
} // For now, always started a 'real' authentication service
StartAuthenticationService(testScene, true);
if (realServices.Contains("inventory"))
StartInventoryService(testScene, true);
else
StartInventoryService(testScene, false);
StartGridService(testScene, true);
StartUserAccountService(testScene);
StartPresenceService(testScene);
m_inventoryService.PostInitialise(); m_inventoryService.PostInitialise();
m_assetService.PostInitialise(); m_assetService.PostInitialise();
@ -504,12 +468,10 @@ namespace OpenSim.Tests.Common.Setup
TestClient client = new TestClient(agentData, scene); TestClient client = new TestClient(agentData, scene);
scene.AddNewClient(client); scene.AddNewClient(client);
// Stage 3: Invoke agent crossing, which converts the child agent into a root agent (with appearance, // Stage 3: Complete the entrance into the region. This converts the child agent into a root agent.
// inventory, etc.)
//scene.AgentCrossing(agentData.AgentID, new Vector3(90, 90, 90), false); OBSOLETE
ScenePresence scp = scene.GetScenePresence(agentData.AgentID); ScenePresence scp = scene.GetScenePresence(agentData.AgentID);
scp.MakeRootAgent(new Vector3(90, 90, 90), true); scp.CompleteMovement(client);
//scp.MakeRootAgent(new Vector3(90, 90, 90), true);
return client; return client;
} }
@ -543,24 +505,5 @@ namespace OpenSim.Tests.Common.Setup
return part; return part;
} }
/// <summary>
/// Delete a scene object asynchronously
/// </summary>
/// <param name="scene"></param>
/// <param name="part"></param>
/// <param name="action"></param>
/// <param name="destinationId"></param>
/// <param name="client"></param>
public static void DeleteSceneObjectAsync(
TestScene scene, SceneObjectPart part, DeRezAction action, UUID destinationId, IClientAPI client)
{
// Turn off the timer on the async sog deleter - we'll crank it by hand within a unit test
AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter;
sogd.Enabled = false;
scene.DeRezObjects(client, new List<uint>() { part.LocalId }, UUID.Zero, action, destinationId);
sogd.InventoryDeQueueAndDelete();
}
} }
} }

View File

@ -72,7 +72,7 @@ ServiceConnectors = "8003/OpenSim.Server.Handlers.dll:AssetServiceConnector,8003
AssetService = "OpenSim.Services.AssetService.dll:AssetService" AssetService = "OpenSim.Services.AssetService.dll:AssetService"
;; Directory for map tile images of linked regions ;; Directory for map tile images of linked regions
; MapTileDirectory = "./" ; MapTileDirectory = "./maptiles"
;; Next, we can specify properties of regions, including default and fallback regions ;; Next, we can specify properties of regions, including default and fallback regions
;; The syntax is: Region_<RegionName> = "<flags>" ;; The syntax is: Region_<RegionName> = "<flags>"

View File

@ -43,7 +43,7 @@
;AllowHypergridMapSearch = true ;AllowHypergridMapSearch = true
;; Directory for map tile images of linked regions ;; Directory for map tile images of linked regions
; MapTileDirectory = "./" ; MapTileDirectory = "./maptiles"
[AvatarService] [AvatarService]
; ;

View File

@ -70,7 +70,7 @@
; Check4096 = true ; Check4096 = true
;; Directory for map tile images of remote regions ;; Directory for map tile images of remote regions
; MapTileDirectory = "./" ; MapTileDirectory = "./maptiles"
;; Next, we can specify properties of regions, including default and fallback regions ;; Next, we can specify properties of regions, including default and fallback regions
;; The syntax is: Region_<RegioName> = "<flags>" ;; The syntax is: Region_<RegioName> = "<flags>"