From f4c165afe7003ad6276ad7d015fd1c9164a84328 Mon Sep 17 00:00:00 2001
From: Diva Canto
Date: Sat, 6 Mar 2010 08:21:54 -0800
Subject: Bug fix: store correct position information upon logout. Fixes mantis
#4608
---
.../Presence/PresenceDetector.cs | 29 +++++++++++++---------
OpenSim/Region/Framework/Scenes/Scene.cs | 2 +-
OpenSim/Region/Framework/Scenes/SceneBase.cs | 15 +++++++++++
.../Framework/Scenes/Tests/SceneBaseTests.cs | 5 ++++
4 files changed, 38 insertions(+), 13 deletions(-)
(limited to 'OpenSim/Region')
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs
index 891fc14..e98df28 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs
@@ -77,23 +77,28 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence
public void OnNewClient(IClientAPI client)
{
- client.OnLogout += OnLogout;
+ client.OnConnectionClosed += OnConnectionClose;
}
- public void OnLogout(IClientAPI client)
+ public void OnConnectionClose(IClientAPI client)
{
- client.OnLogout -= OnLogout;
-
- ScenePresence sp = null;
- Vector3 position = new Vector3(128, 128, 0);
- Vector3 lookat = new Vector3(0, 1, 0);
-
- if (m_aScene.TryGetAvatar(client.AgentId, out sp))
+ if (client.IsLoggingOut)
{
- position = sp.AbsolutePosition;
- lookat = sp.Lookat;
+ object sp = null;
+ Vector3 position = new Vector3(128, 128, 0);
+ Vector3 lookat = new Vector3(0, 1, 0);
+
+ if (client.Scene.TryGetAvatar(client.AgentId, out sp))
+ {
+ if (sp is ScenePresence)
+ {
+ position = ((ScenePresence)sp).AbsolutePosition;
+ lookat = ((ScenePresence)sp).Lookat;
+ }
+ }
+
+ m_PresenceService.LogoutAgent(client.SessionId, position, lookat);
}
- m_PresenceService.LogoutAgent(client.SessionId, position, lookat);
}
}
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 30c69a8..1eb3117 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -4216,7 +4216,7 @@ namespace OpenSim.Region.Framework.Scenes
return m_sceneGraph.GetGroupByPrim(localID);
}
- public bool TryGetAvatar(UUID avatarId, out ScenePresence avatar)
+ public override bool TryGetAvatar(UUID avatarId, out ScenePresence avatar)
{
return m_sceneGraph.TryGetAvatar(avatarId, out avatar);
}
diff --git a/OpenSim/Region/Framework/Scenes/SceneBase.cs b/OpenSim/Region/Framework/Scenes/SceneBase.cs
index 4f6e824..74476ed 100644
--- a/OpenSim/Region/Framework/Scenes/SceneBase.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneBase.cs
@@ -190,6 +190,21 @@ namespace OpenSim.Region.Framework.Scenes
///
public abstract void RemoveClient(UUID agentID);
+ public bool TryGetAvatar(UUID agentID, out object scenePresence)
+ {
+ scenePresence = null;
+ ScenePresence sp = null;
+ if (TryGetAvatar(agentID, out sp))
+ {
+ scenePresence = sp;
+ return true;
+ }
+
+ return false;
+ }
+
+ public abstract bool TryGetAvatar(UUID agentID, out ScenePresence scenePresence);
+
#endregion
///
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneBaseTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneBaseTests.cs
index 8230f32..840039c 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneBaseTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneBaseTests.cs
@@ -65,6 +65,11 @@ namespace OpenSim.Region.Framework.Scenes.Tests
{
throw new NotImplementedException();
}
+
+ public override bool TryGetAvatar(UUID agentID, out ScenePresence scenePresence)
+ {
+ throw new NotImplementedException();
+ }
}
[Test]
--
cgit v1.1
From 2dcf73dd93f2bc8993c2f534ef5ee8c72e24d0f3 Mon Sep 17 00:00:00 2001
From: unknown
Date: Sat, 6 Mar 2010 14:13:12 -0600
Subject: - supporting llTextBox
Signed-off-by: Melanie
---
.../Region/ClientStack/LindenUDP/LLClientView.cs | 20 +++++++++++++++
.../CoreModules/Avatar/Dialog/DialogModule.cs | 26 ++++++++++++++++++-
.../Region/Examples/SimpleModule/MyNpcCharacter.cs | 4 +++
.../Region/Framework/Interfaces/IDialogModule.cs | 5 ++++
.../Server/IRCClientView.cs | 4 +++
.../Region/OptionalModules/World/NPC/NPCAvatar.cs | 4 +++
.../Shared/Api/Implementation/LSL_Api.cs | 29 ++++++++++++++++++++--
7 files changed, 89 insertions(+), 3 deletions(-)
(limited to 'OpenSim/Region')
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
index 569dc8d..2e59457 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
@@ -11630,5 +11630,25 @@ namespace OpenSim.Region.ClientStack.LindenUDP
OutPacket(packet, ThrottleOutPacketType.Task);
}
+
+ public void SendTextBoxRequest(string message, int chatChannel, string objectname, string ownerFirstName, string ownerLastName, UUID objectId)
+ {
+ ScriptDialogPacket dialog = (ScriptDialogPacket)PacketPool.Instance.GetPacket(PacketType.ScriptDialog);
+ dialog.Data.ObjectID = objectId;
+ dialog.Data.ChatChannel = chatChannel;
+ dialog.Data.ImageID = UUID.Zero;
+ dialog.Data.ObjectName = Util.StringToBytes256(objectname);
+ // this is the username of the *owner*
+ dialog.Data.FirstName = Util.StringToBytes256(ownerFirstName);
+ dialog.Data.LastName = Util.StringToBytes256(ownerLastName);
+ dialog.Data.Message = Util.StringToBytes256(message);
+
+
+ ScriptDialogPacket.ButtonsBlock[] buttons = new ScriptDialogPacket.ButtonsBlock[1];
+ buttons[0] = new ScriptDialogPacket.ButtonsBlock();
+ buttons[0].ButtonLabel = Util.StringToBytes256("!!llTextBox!!");
+ dialog.Buttons = buttons;
+ OutPacket(dialog, ThrottleOutPacketType.Task);
+ }
}
}
diff --git a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs
index fac052a..b8e013c 100644
--- a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs
@@ -25,6 +25,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+using System;
using System.Collections.Generic;
using System.Reflection;
using log4net;
@@ -151,7 +152,30 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog
// region as the sending avatar.
SendNotificationToUsersInRegion(fromAvatarID, fromAvatarName, message);
}
-
+
+ public void SendTextBoxToUser(UUID avatarid, string message, int chatChannel, string name, UUID objectid, UUID ownerid)
+ {
+ UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, ownerid);
+ string ownerFirstName, ownerLastName;
+ if (account != null)
+ {
+ ownerFirstName = account.FirstName;
+ ownerLastName = account.LastName;
+ }
+ else
+ {
+ ownerFirstName = "(unknown";
+ ownerLastName = "user)";
+ }
+
+
+ ScenePresence sp = m_scene.GetScenePresence(avatarid);
+
+ if (sp != null) {
+ sp.ControllingClient.SendTextBoxRequest(message, chatChannel, name, ownerFirstName, ownerLastName, objectid);
+ }
+ }
+
public void SendNotificationToUsersInRegion(
UUID fromAvatarID, string fromAvatarName, string message)
{
diff --git a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs
index a1957d1..7fdddc3 100644
--- a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs
+++ b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs
@@ -1153,5 +1153,9 @@ namespace OpenSim.Region.Examples.SimpleModule
public void SendChangeUserRights(UUID agentID, UUID friendID, int rights)
{
}
+
+ public void SendTextBoxRequest(string message, int chatChannel, string objectname, string ownerFirstName, string ownerLastName, UUID objectId)
+ {
+ }
}
}
diff --git a/OpenSim/Region/Framework/Interfaces/IDialogModule.cs b/OpenSim/Region/Framework/Interfaces/IDialogModule.cs
index ce57c44..35b4b63 100644
--- a/OpenSim/Region/Framework/Interfaces/IDialogModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IDialogModule.cs
@@ -131,5 +131,10 @@ namespace OpenSim.Region.Framework.Interfaces
/// The name of the user doing the sending
/// The message being sent to the user
void SendNotificationToUsersInEstate(UUID fromAvatarID, string fromAvatarName, string message);
+
+ ///
+ /// Send a textbox entry for the client to respond to
+ ///
+ void SendTextBoxToUser(UUID avatarid, string message, int chatChannel, string name, UUID objectid, UUID ownerid);
}
}
diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
index 96530a1..f2253f2 100644
--- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
+++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
@@ -1679,5 +1679,9 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
public void SendChangeUserRights(UUID agentID, UUID friendID, int rights)
{
}
+
+ public void SendTextBoxRequest(string message, int chatChannel, string objectname, string ownerFirstName, string ownerLastName, UUID objectId)
+ {
+ }
}
}
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
index f8ab8d8..65445d9 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
@@ -1159,5 +1159,9 @@ namespace OpenSim.Region.OptionalModules.World.NPC
public void SendChangeUserRights(UUID agentID, UUID friendID, int rights)
{
}
+
+ public void SendTextBoxRequest(string message, int chatChannel, string objectname, string ownerFirstName, string ownerLastName, UUID objectId)
+ {
+ }
}
}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 0a871d9..6f68305 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -4009,10 +4009,34 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
ScriptSleep(5000);
}
- public void llTextBox(string avatar, string message, int chat_channel)
+ public void llTextBox(string agent, string message, int chatChannel)
{
+ IDialogModule dm = World.RequestModuleInterface();
+
+ if (dm == null)
+ return;
+
m_host.AddScriptLPS(1);
- NotImplemented("llTextBox");
+ UUID av = new UUID();
+ if (!UUID.TryParse(agent,out av))
+ {
+ LSLError("First parameter to llDialog needs to be a key");
+ return;
+ }
+
+ if( message == string.Empty)
+ {
+ ShoutError("Trying to use llTextBox with empty message.");
+ }
+ else if (message.Length > 512)
+ {
+ ShoutError("Trying to use llTextBox with message over 512 characters.");
+ }
+ else
+ {
+ dm.SendTextBoxToUser(av, message, chatChannel, m_host.Name, m_host.UUID, m_host.OwnerID);
+ ScriptSleep(1000);
+ }
}
public void llModifyLand(int action, int brush)
@@ -4027,6 +4051,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public void llCollisionSound(string impact_sound, double impact_volume)
{
+
m_host.AddScriptLPS(1);
// TODO: Parameter check logic required.
UUID soundId = UUID.Zero;
--
cgit v1.1
From 89a739b45f0384cd9fc0801ce71be7976f16a999 Mon Sep 17 00:00:00 2001
From: Melanie
Date: Sun, 7 Mar 2010 16:05:24 +0000
Subject: Small consistency change
---
OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
(limited to 'OpenSim/Region')
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 6f68305..59db81e 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -5900,7 +5900,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
for (int i = 0; i < rules.Length; i += 2)
{
- switch (Convert.ToInt32(rules.Data[i]))
+ switch (rules.GetLSLIntegerItem(i))
{
case (int)ScriptBaseClass.PSYS_PART_FLAGS:
prules.PartDataFlags = (Primitive.ParticleSystem.ParticleDataFlags)(uint)rules.GetLSLIntegerItem(i + 1);
@@ -9871,4 +9871,4 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
}
}
-}
\ No newline at end of file
+}
--
cgit v1.1
From fa38cf3ee8caf6efa3004a3c089acb156f677a3e Mon Sep 17 00:00:00 2001
From: John Hurliman
Date: Sun, 7 Mar 2010 17:03:56 -0800
Subject: * Added code to support either CSJ2K or OpenJPEG texture decoding.
Currently hardcoded to CSJ2K (so no functional change) but this could easily
be switched to a config option
---
.../Agent/TextureSender/J2KDecoderModule.cs | 53 ++++++++++++++--------
1 file changed, 33 insertions(+), 20 deletions(-)
(limited to 'OpenSim/Region')
diff --git a/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs b/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs
index 50c83b5..5b022ac 100644
--- a/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs
+++ b/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs
@@ -144,41 +144,54 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender
/// JPEG2000 data
private void DoJ2KDecode(UUID assetID, byte[] j2kData)
{
-// int DecodeTime = 0;
-// DecodeTime = Environment.TickCount;
+ bool USE_CSJ2K = true;
+
+ //int DecodeTime = 0;
+ //DecodeTime = Environment.TickCount;
OpenJPEG.J2KLayerInfo[] layers;
if (!TryLoadCacheForAsset(assetID, out layers))
{
- try
+ if (USE_CSJ2K)
{
- List layerStarts = CSJ2K.J2kImage.GetLayerBoundaries(new MemoryStream(j2kData));
-
- if (layerStarts != null && layerStarts.Count > 0)
+ try
{
- layers = new OpenJPEG.J2KLayerInfo[layerStarts.Count];
+ List layerStarts = CSJ2K.J2kImage.GetLayerBoundaries(new MemoryStream(j2kData));
- for (int i = 0; i < layerStarts.Count; i++)
+ if (layerStarts != null && layerStarts.Count > 0)
{
- OpenJPEG.J2KLayerInfo layer = new OpenJPEG.J2KLayerInfo();
+ layers = new OpenJPEG.J2KLayerInfo[layerStarts.Count];
- if (i == 0)
- layer.Start = 0;
- else
- layer.Start = layerStarts[i];
+ for (int i = 0; i < layerStarts.Count; i++)
+ {
+ OpenJPEG.J2KLayerInfo layer = new OpenJPEG.J2KLayerInfo();
- if (i == layerStarts.Count - 1)
- layer.End = j2kData.Length;
- else
- layer.End = layerStarts[i + 1] - 1;
+ if (i == 0)
+ layer.Start = 0;
+ else
+ layer.Start = layerStarts[i];
- layers[i] = layer;
+ if (i == layerStarts.Count - 1)
+ layer.End = j2kData.Length;
+ else
+ layer.End = layerStarts[i + 1] - 1;
+
+ layers[i] = layer;
+ }
}
}
+ catch (Exception ex)
+ {
+ m_log.Warn("[J2KDecoderModule]: CSJ2K threw an exception decoding texture " + assetID + ": " + ex.Message);
+ }
}
- catch (Exception ex)
+ else
{
- m_log.Warn("[J2KDecoderModule]: CSJ2K threw an exception decoding texture " + assetID + ": " + ex.Message);
+ int components;
+ if (!OpenJPEG.DecodeLayerBoundaries(j2kData, out layers, out components))
+ {
+ m_log.Warn("[J2KDecoderModule]: OpenJPEG failed to decode texture " + assetID);
+ }
}
if (layers == null || layers.Length == 0)
--
cgit v1.1
From 2362da2ad03d84569da9cf558a84b9942afac852 Mon Sep 17 00:00:00 2001
From: Melanie
Date: Mon, 8 Mar 2010 20:29:26 +0000
Subject: Add config option for switching between CSJ2K and BuggyJPEG.
---
.../CoreModules/Agent/TextureSender/J2KDecoderModule.cs | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
(limited to 'OpenSim/Region')
diff --git a/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs b/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs
index 5b022ac..1386e86 100644
--- a/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs
+++ b/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs
@@ -60,6 +60,8 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender
#region IRegionModule
+ private bool m_useCSJ2K = true;
+
public string Name { get { return "J2KDecoderModule"; } }
public bool IsSharedModule { get { return true; } }
@@ -73,6 +75,12 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender
m_scene = scene;
scene.RegisterModuleInterface(this);
+
+ IConfig startupConfig = source.Configs["Startup"];
+ if (startupConfig != null)
+ {
+ m_useCSJ2K = startupConfig.GetBoolean("UseCSJ2K", m_useCSJ2K);
+ }
}
public void PostInitialise()
@@ -144,15 +152,13 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender
/// JPEG2000 data
private void DoJ2KDecode(UUID assetID, byte[] j2kData)
{
- bool USE_CSJ2K = true;
-
//int DecodeTime = 0;
//DecodeTime = Environment.TickCount;
OpenJPEG.J2KLayerInfo[] layers;
if (!TryLoadCacheForAsset(assetID, out layers))
{
- if (USE_CSJ2K)
+ if (m_useCSJ2K)
{
try
{
--
cgit v1.1
From 01218093a6ac1e7e4be0147d58b1b571f965e1c4 Mon Sep 17 00:00:00 2001
From: John Hurliman
Date: Tue, 9 Mar 2010 12:06:53 -0800
Subject: * Typo fixes * Performance improvement in the expensive
GenerateClientFlags()
---
.../ServiceConnectorsOut/Asset/RemoteAssetServiceConnector.cs | 2 +-
.../ServiceConnectorsOut/Avatar/RemoteAvatarServiceConnector.cs | 2 +-
.../ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs | 2 +-
.../ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs | 2 +-
.../UserAccounts/RemoteUserAccountServiceConnector.cs | 2 +-
.../Region/CoreModules/World/Permissions/PermissionsModule.cs | 9 +++++----
6 files changed, 10 insertions(+), 9 deletions(-)
(limited to 'OpenSim/Region')
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/RemoteAssetServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/RemoteAssetServiceConnector.cs
index 4eff60e..8a22cfc 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/RemoteAssetServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/RemoteAssetServiceConnector.cs
@@ -69,7 +69,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
IConfig assetConfig = source.Configs["AssetService"];
if (assetConfig == null)
{
- m_log.Error("[ASSET CONNECTOR]: AssetService missing from OpanSim.ini");
+ m_log.Error("[ASSET CONNECTOR]: AssetService missing from OpenSim.ini");
return;
}
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Avatar/RemoteAvatarServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Avatar/RemoteAvatarServiceConnector.cs
index 48759b5..d665a54 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Avatar/RemoteAvatarServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Avatar/RemoteAvatarServiceConnector.cs
@@ -66,7 +66,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Avatar
IConfig userConfig = source.Configs["AvatarService"];
if (userConfig == null)
{
- m_log.Error("[AVATAR CONNECTOR]: AvatarService missing from OpanSim.ini");
+ m_log.Error("[AVATAR CONNECTOR]: AvatarService missing from OpenSim.ini");
return;
}
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs
index e913891..783d606 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs
@@ -69,7 +69,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
//IConfig userConfig = config.Configs["SimulationService"];
//if (userConfig == null)
//{
- // m_log.Error("[AVATAR CONNECTOR]: SimulationService missing from OpanSim.ini");
+ // m_log.Error("[AVATAR CONNECTOR]: SimulationService missing from OpenSim.ini");
// return;
//}
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs
index 2b1f815..4d82a05 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs
@@ -74,7 +74,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
//IConfig userConfig = config.Configs["SimulationService"];
//if (userConfig == null)
//{
- // m_log.Error("[AVATAR CONNECTOR]: SimulationService missing from OpanSim.ini");
+ // m_log.Error("[AVATAR CONNECTOR]: SimulationService missing from OpenSim.ini");
// return;
//}
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs
index 13acdf2..1140692 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs
@@ -69,7 +69,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts
IConfig userConfig = source.Configs["UserAccountService"];
if (userConfig == null)
{
- m_log.Error("[USER CONNECTOR]: UserAccountService missing from OpanSim.ini");
+ m_log.Error("[USER CONNECTOR]: UserAccountService missing from OpenSim.ini");
return;
}
diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
index 4652d70..2211f3e 100644
--- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
+++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
@@ -609,16 +609,17 @@ namespace OpenSim.Region.CoreModules.World.Permissions
if (IsFriendWithPerms(user, objectOwner))
return objectOwnerMask;
- // Estate users should be able to edit anything in the sim
- if (IsEstateManager(user) && m_RegionOwnerIsGod && (!IsAdministrator(objectOwner)) || objectOwner == user)
+ // Estate users should be able to edit anything in the sim if RegionOwnerIsGod is set
+ if (IsEstateManager(user) && m_RegionOwnerIsGod)
return objectOwnerMask;
// Admin should be able to edit anything in the sim (including admin objects)
if (IsAdministrator(user))
return objectOwnerMask;
-
+
// Users should be able to edit what is over their land.
- ILandObject parcel = m_scene.LandChannel.GetLandObject(task.AbsolutePosition.X, task.AbsolutePosition.Y);
+ Vector3 taskPos = task.AbsolutePosition;
+ ILandObject parcel = m_scene.LandChannel.GetLandObject(taskPos.X, taskPos.Y);
if (parcel != null && parcel.LandData.OwnerID == user && m_ParcelOwnerIsGod)
{
// Admin objects should not be editable by the above
--
cgit v1.1
From 98f91a252cade093894511110157d7fcd7e4487e Mon Sep 17 00:00:00 2001
From: unknown
Date: Mon, 8 Mar 2010 01:19:45 -0600
Subject: - parcel blocking, region crossing blocking, teleport blocking
Signed-off-by: Melanie
---
.../Region/ClientStack/LindenUDP/LLClientView.cs | 4 +
.../CoreModules/World/Land/LandManagementModule.cs | 93 ++++++++-
.../Region/CoreModules/World/Land/LandObject.cs | 9 +-
.../Region/Examples/SimpleModule/MyNpcCharacter.cs | 1 +
OpenSim/Region/Framework/Scenes/Scene.cs | 230 ++++++++++++++++++++-
.../Server/IRCClientView.cs | 1 +
.../Region/OptionalModules/World/NPC/NPCAvatar.cs | 1 +
7 files changed, 328 insertions(+), 11 deletions(-)
(limited to 'OpenSim/Region')
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
index 2e59457..a9b5c2b 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
@@ -127,6 +127,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
public event ObjectDeselect OnObjectDetach;
public event ObjectDrop OnObjectDrop;
public event GenericCall1 OnCompleteMovementToRegion;
+ public event UpdateAgent OnPreAgentUpdate;
public event UpdateAgent OnAgentUpdate;
public event AgentRequestSit OnAgentRequestSit;
public event AgentSit OnAgentSit;
@@ -4893,7 +4894,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
UpdateAgent handlerAgentUpdate = OnAgentUpdate;
lastarg = arg; // save this set of arguments for nexttime
if (handlerAgentUpdate != null)
+ {
+ OnPreAgentUpdate(this, arg);
OnAgentUpdate(this, arg);
+ }
handlerAgentUpdate = null;
}
diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
index f0c87f4..38f371a 100644
--- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
+++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
@@ -28,6 +28,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
+using System.Diagnostics;
using System.Reflection;
using log4net;
using Nini.Config;
@@ -84,6 +85,7 @@ namespace OpenSim.Region.CoreModules.World.Land
// caches ExtendedLandData
private Cache parcelInfoCache;
+ private Vector3? forcedPosition = null;
#region INonSharedRegionModule Members
@@ -136,6 +138,13 @@ namespace OpenSim.Region.CoreModules.World.Land
{
}
+ private bool OnVerifyUserConnection(ScenePresence scenePresence, out string reason)
+ {
+ ILandObject nearestParcel = m_scene.GetNearestAllowedParcel(scenePresence.UUID, scenePresence.AbsolutePosition.X, scenePresence.AbsolutePosition.Y);
+ reason = "You are not allowed to enter this sim.";
+ return nearestParcel != null;
+ }
+
void EventManagerOnNewClient(IClientAPI client)
{
//Register some client events
@@ -153,6 +162,7 @@ namespace OpenSim.Region.CoreModules.World.Land
client.OnParcelInfoRequest += ClientOnParcelInfoRequest;
client.OnParcelDwellRequest += ClientOnParcelDwellRequest;
client.OnParcelDeedToGroup += ClientOnParcelDeedToGroup;
+ client.OnPreAgentUpdate += ClientOnPreAgentUpdate;
EntityBase presenceEntity;
if (m_scene.Entities.TryGetValue(client.AgentId, out presenceEntity) && presenceEntity is ScenePresence)
@@ -162,6 +172,40 @@ namespace OpenSim.Region.CoreModules.World.Land
}
}
+ void ClientOnPreAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData)
+ {
+ //If we are forcing a position for them to go
+ if( forcedPosition != null )
+ {
+ ScenePresence clientAvatar = m_scene.GetScenePresence(remoteClient.AgentId);
+
+ //Putting the user into flying, both keeps the avatar in fligth when it bumps into something and stopped from going another direction AND
+ //When the avatar walks into a ban line on the ground, it prevents getting stuck
+ agentData.ControlFlags = (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY;
+
+
+ //Make sure we stop if they get about to the right place to prevent yoyo and prevents getting stuck on banlines
+ if (Vector3.Distance(clientAvatar.AbsolutePosition, forcedPosition.Value) < .2)
+ {
+ Debug.WriteLine(string.Format("Stopping force position because {0} is close enough to position {1}", forcedPosition.Value, clientAvatar.AbsolutePosition));
+ forcedPosition = null;
+ }
+ //if we are far away, teleport
+ else if(Vector3.Distance(clientAvatar.AbsolutePosition,forcedPosition.Value) > 3 )
+ {
+ Debug.WriteLine(string.Format("Teleporting out because {0} is too far from avatar position {1}",forcedPosition.Value,clientAvatar.AbsolutePosition));
+ clientAvatar.Teleport(forcedPosition.Value);
+ forcedPosition = null;
+ }
+ else
+ {
+ //Forces them toward the forced position we want if they aren't there yet
+ agentData.UseClientAgentPosition = true;
+ agentData.ClientAgentPosition = forcedPosition.Value;
+ }
+ }
+ }
+
public void PostInitialise()
{
@@ -267,9 +311,6 @@ namespace OpenSim.Region.CoreModules.World.Land
{
avatar.ControllingClient.SendAlertMessage(
"You are not allowed on this parcel because you are banned. Please go away.");
-
- avatar.PhysicsActor.Position = avatar.lastKnownAllowedPosition;
- avatar.PhysicsActor.Velocity = Vector3.Zero;
}
else
{
@@ -278,6 +319,24 @@ namespace OpenSim.Region.CoreModules.World.Land
}
}
+
+
+ private void ForceAvatarToPosition(ScenePresence avatar, Vector3? position)
+ {
+ if (m_scene.Permissions.IsGod(avatar.UUID)) return;
+ if (position.HasValue)
+ {
+ forcedPosition = position;
+ }
+ }
+
+ public void SendYouAreRestrictedNotice(ScenePresence avatar)
+ {
+ avatar.ControllingClient.SendAlertMessage(
+ "You are not allowed on this parcel because the land owner has restricted access.");
+
+ }
+
public void EventManagerOnAvatarEnteringNewParcel(ScenePresence avatar, int localLandID, UUID regionID)
{
if (m_scene.RegionInfo.RegionID == regionID)
@@ -295,11 +354,12 @@ namespace OpenSim.Region.CoreModules.World.Land
if (parcelAvatarIsEntering.IsBannedFromLand(avatar.UUID))
{
SendYouAreBannedNotice(avatar);
+ ForceAvatarToPosition(avatar, m_scene.GetNearestAllowedPosition(avatar));
}
else if (parcelAvatarIsEntering.IsRestrictedFromLand(avatar.UUID))
{
- avatar.ControllingClient.SendAlertMessage(
- "You are not allowed on this parcel because the land owner has restricted access. For now, you can enter, but please respect the land owner's decisions (or he can ban you!).");
+ SendYouAreRestrictedNotice(avatar);
+ ForceAvatarToPosition(avatar, m_scene.GetNearestAllowedPosition(avatar));
}
else
{
@@ -400,7 +460,26 @@ namespace OpenSim.Region.CoreModules.World.Land
else if (clientAvatar.AbsolutePosition.Z < LandChannel.BAN_LINE_SAFETY_HIEGHT &&
parcel.IsBannedFromLand(clientAvatar.UUID))
{
- SendYouAreBannedNotice(clientAvatar);
+ //once we've sent the message once, keep going toward the target until we are done
+ if (forcedPosition == null)
+ {
+ SendYouAreBannedNotice(clientAvatar);
+ ForceAvatarToPosition(clientAvatar, m_scene.GetNearestAllowedPosition(clientAvatar));
+ }
+ }
+ else if ( parcel.IsRestrictedFromLand(clientAvatar.UUID))
+ {
+ //once we've sent the message once, keep going toward the target until we are done
+ if (forcedPosition == null)
+ {
+ SendYouAreRestrictedNotice(clientAvatar);
+ ForceAvatarToPosition(clientAvatar, m_scene.GetNearestAllowedPosition(clientAvatar));
+ }
+ }
+ else
+ {
+ //when we are finally in a safe place, lets release the forced position lock
+ forcedPosition = null;
}
}
}
@@ -412,7 +491,7 @@ namespace OpenSim.Region.CoreModules.World.Land
ILandObject over = GetLandObject(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y);
if (over != null)
{
- if (!over.IsBannedFromLand(avatar.UUID) || avatar.AbsolutePosition.Z >= LandChannel.BAN_LINE_SAFETY_HIEGHT)
+ if (!over.IsRestrictedFromLand(avatar.UUID) && (!over.IsBannedFromLand(avatar.UUID) || avatar.AbsolutePosition.Z >= LandChannel.BAN_LINE_SAFETY_HIEGHT))
{
avatar.lastKnownAllowedPosition =
new Vector3(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y, avatar.AbsolutePosition.Z);
diff --git a/OpenSim/Region/CoreModules/World/Land/LandObject.cs b/OpenSim/Region/CoreModules/World/Land/LandObject.cs
index 1fa8630..27d9fdb 100644
--- a/OpenSim/Region/CoreModules/World/Land/LandObject.cs
+++ b/OpenSim/Region/CoreModules/World/Land/LandObject.cs
@@ -104,7 +104,7 @@ namespace OpenSim.Region.CoreModules.World.Land
/// Returns true if the piece of land contains the specified point
public bool ContainsPoint(int x, int y)
{
- if (x >= 0 && y >= 0 && x <= Constants.RegionSize && x <= Constants.RegionSize)
+ if (x >= 0 && y >= 0 && x <= Constants.RegionSize && y <= Constants.RegionSize)
{
return (LandBitmap[x / 4, y / 4] == true);
}
@@ -286,7 +286,8 @@ namespace OpenSim.Region.CoreModules.World.Land
entry.AgentID = avatar;
entry.Flags = AccessList.Ban;
entry.Time = new DateTime();
- if (LandData.ParcelAccessList.Contains(entry))
+ //See if they are on the list, but make sure the owner isn't banned
+ if (LandData.ParcelAccessList.Contains(entry) && LandData.OwnerID != avatar )
{
//They are banned, so lets send them a notice about this parcel
return true;
@@ -303,7 +304,9 @@ namespace OpenSim.Region.CoreModules.World.Land
entry.AgentID = avatar;
entry.Flags = AccessList.Access;
entry.Time = new DateTime();
- if (!LandData.ParcelAccessList.Contains(entry))
+
+ //If they are not on the access list and are not the owner
+ if (!LandData.ParcelAccessList.Contains(entry) && LandData.OwnerID != avatar)
{
//They are not allowed in this parcel, but not banned, so lets send them a notice about this parcel
return true;
diff --git a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs
index 7fdddc3..d052f38 100644
--- a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs
+++ b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs
@@ -84,6 +84,7 @@ namespace OpenSim.Region.Examples.SimpleModule
public event Action OnRegionHandShakeReply;
public event GenericCall2 OnRequestWearables;
public event GenericCall1 OnCompleteMovementToRegion;
+ public event UpdateAgent OnPreAgentUpdate;
public event UpdateAgent OnAgentUpdate;
public event AgentRequestSit OnAgentRequestSit;
public event AgentSit OnAgentSit;
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 1eb3117..311821a 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -27,6 +27,7 @@
using System;
using System.Collections.Generic;
+using System.Diagnostics;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
@@ -3224,6 +3225,7 @@ namespace OpenSim.Region.Framework.Scenes
/// also return a reason.
public bool NewUserConnection(AgentCircuitData agent, uint teleportFlags, out string reason)
{
+ TeleportFlags tp = (TeleportFlags)teleportFlags;
//Teleport flags:
//
// TeleportFlags.ViaGodlikeLure - Border Crossing
@@ -3257,6 +3259,17 @@ namespace OpenSim.Region.Framework.Scenes
CapsModule.NewUserConnection(agent);
+ ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y);
+
+ //On login or border crossing test land permisions
+ if (tp != TeleportFlags.Default)
+ {
+ if (land != null && !TestLandRestrictions(agent, land, out reason))
+ {
+ return false;
+ }
+ }
+
ScenePresence sp = m_sceneGraph.GetScenePresence(agent.AgentID);
if (sp != null)
{
@@ -3329,7 +3342,6 @@ namespace OpenSim.Region.Framework.Scenes
}
}
// Honor parcel landing type and position.
- ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y);
if (land != null)
{
if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero)
@@ -3345,6 +3357,40 @@ namespace OpenSim.Region.Framework.Scenes
return true;
}
+ private bool TestLandRestrictions(AgentCircuitData agent, ILandObject land, out string reason)
+ {
+
+ bool banned = land.IsBannedFromLand(agent.AgentID);
+ bool restricted = land.IsRestrictedFromLand(agent.AgentID);
+
+ if (banned || restricted)
+ {
+ ILandObject nearestParcel = GetNearestAllowedParcel(agent.AgentID, agent.startpos.X, agent.startpos.Y);
+ if (nearestParcel != null)
+ {
+ //Move agent to nearest allowed
+ Vector3 newPosition = GetParcelCenterAtGround(nearestParcel);
+ agent.startpos.X = newPosition.X;
+ agent.startpos.Y = newPosition.Y;
+ }
+ else
+ {
+ if (banned)
+ {
+ reason = "Cannot regioncross into banned parcel.";
+ }
+ else
+ {
+ reason = String.Format("Denied access to private region {0}: You are not on the access list for that region.",
+ RegionInfo.RegionName);
+ }
+ return false;
+ }
+ }
+ reason = "";
+ return true;
+ }
+
///
/// Verifies that the user has a presence on the Grid
///
@@ -3476,6 +3522,18 @@ namespace OpenSim.Region.Framework.Scenes
return true;
}
+ private ILandObject GetParcelAtPoint(float x, float y)
+ {
+ foreach (var parcel in AllParcels())
+ {
+ if( parcel.ContainsPoint((int)x,(int)y))
+ {
+ return parcel;
+ }
+ }
+ return null;
+ }
+
///
/// Update an AgentCircuitData object with new information
///
@@ -4748,5 +4806,175 @@ namespace OpenSim.Region.Framework.Scenes
{
get { return m_allowScriptCrossings; }
}
+
+ public Vector3? GetNearestAllowedPosition(ScenePresence avatar)
+ {
+ //simulate to make sure we have pretty up to date positions
+ PhysicsScene.Simulate(0);
+
+ ILandObject nearestParcel = GetNearestAllowedParcel(avatar.UUID, avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y);
+
+ if (nearestParcel != null)
+ {
+ Vector3 dir = Vector3.Normalize(Vector3.Multiply(avatar.Velocity, -1));
+ //Try to get a location that feels like where they came from
+ Vector3? nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel);
+ if (nearestPoint != null)
+ {
+ Debug.WriteLine("Found a sane previous position based on velocity, sending them to: " + nearestPoint.ToString());
+ return nearestPoint.Value;
+ }
+
+ //Sometimes velocity might be zero (local teleport), so try finding point along path from avatar to center of nearest parcel
+ Vector3 directionToParcelCenter = Vector3.Subtract(GetParcelCenterAtGround(nearestParcel), avatar.AbsolutePosition);
+ dir = Vector3.Normalize(directionToParcelCenter);
+ nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel);
+ if (nearestPoint != null)
+ {
+ Debug.WriteLine("They had a zero velocity, sending them to: " + nearestPoint.ToString());
+ return nearestPoint.Value;
+ }
+
+ //Ultimate backup if we have no idea where they are
+ Debug.WriteLine("Have no idea where they are, sending them to: " + avatar.lastKnownAllowedPosition.ToString());
+ return avatar.lastKnownAllowedPosition;
+
+ }
+
+ //Go to the edge, this happens in teleporting to a region with no available parcels
+ Vector3 nearestRegionEdgePoint = GetNearestRegionEdgePosition(avatar);
+ //Debug.WriteLine("They are really in a place they don't belong, sending them to: " + nearestRegionEdgePoint.ToString());
+ return nearestRegionEdgePoint;
+ return null;
+ }
+
+ private Vector3 GetParcelCenterAtGround(ILandObject parcel)
+ {
+ Vector2 center = GetParcelCenter(parcel);
+ return GetPositionAtGround(center.X, center.Y);
+ }
+
+ private Vector3? GetNearestPointInParcelAlongDirectionFromPoint(Vector3 pos, Vector3 direction, ILandObject parcel)
+ {
+ Vector3 unitDirection = Vector3.Normalize(direction);
+ //Making distance to search go through some sane limit of distance
+ for (float distance = 0; distance < Constants.RegionSize * 2; distance += .5f)
+ {
+ Vector3 testPos = Vector3.Add(pos, Vector3.Multiply(unitDirection, distance));
+ if (parcel.ContainsPoint((int)testPos.X, (int)testPos.Y))
+ {
+ return testPos;
+ }
+ }
+ return null;
+ }
+
+ public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y)
+ {
+ List all = AllParcels();
+ float minParcelDistance = float.MaxValue;
+ ILandObject nearestParcel = null;
+
+ foreach (var parcel in all)
+ {
+ if (!parcel.IsEitherBannedOrRestricted(avatarId))
+ {
+ float parcelDistance = GetParcelDistancefromPoint(parcel, x, y);
+ if (parcelDistance < minParcelDistance)
+ {
+ minParcelDistance = parcelDistance;
+ nearestParcel = parcel;
+ }
+ }
+ }
+
+ return nearestParcel;
+ }
+
+ private List AllParcels()
+ {
+ return LandChannel.AllParcels();
+ }
+
+ private float GetParcelDistancefromPoint(ILandObject parcel, float x, float y)
+ {
+ return Vector2.Distance(new Vector2(x, y), GetParcelCenter(parcel));
+ }
+
+ //calculate the average center point of a parcel
+ private Vector2 GetParcelCenter(ILandObject parcel)
+ {
+ int count = 0;
+ int avgx = 0;
+ int avgy = 0;
+ for (int x = 0; x < Constants.RegionSize; x++)
+ {
+ for (int y = 0; y < Constants.RegionSize; y++)
+ {
+ //Just keep a running average as we check if all the points are inside or not
+ if (parcel.ContainsPoint(x, y))
+ {
+ if (count == 0)
+ {
+ avgx = x;
+ avgy = y;
+ }
+ else
+ {
+ avgx = (avgx * count + x) / (count + 1);
+ avgy = (avgy * count + y) / (count + 1);
+ }
+ count += 1;
+ }
+ }
+ }
+ return new Vector2(avgx, avgy);
+ }
+
+ private Vector3 GetNearestRegionEdgePosition(ScenePresence avatar)
+ {
+ float xdistance = avatar.AbsolutePosition.X < Constants.RegionSize / 2 ? avatar.AbsolutePosition.X : Constants.RegionSize - avatar.AbsolutePosition.X;
+ float ydistance = avatar.AbsolutePosition.Y < Constants.RegionSize / 2 ? avatar.AbsolutePosition.Y : Constants.RegionSize - avatar.AbsolutePosition.Y;
+
+ //find out what vertical edge to go to
+ if (xdistance < ydistance)
+ {
+ if (avatar.AbsolutePosition.X < Constants.RegionSize / 2)
+ {
+ return GetPositionAtAvatarHeightOrGroundHeight(avatar, 0.0f, avatar.AbsolutePosition.Y);
+ }
+ else
+ {
+ return GetPositionAtAvatarHeightOrGroundHeight(avatar, Constants.RegionSize, avatar.AbsolutePosition.Y);
+ }
+ }
+ //find out what horizontal edge to go to
+ else
+ {
+ if (avatar.AbsolutePosition.Y < Constants.RegionSize / 2)
+ {
+ return GetPositionAtAvatarHeightOrGroundHeight(avatar, avatar.AbsolutePosition.X, 0.0f);
+ }
+ else
+ {
+ return GetPositionAtAvatarHeightOrGroundHeight(avatar, avatar.AbsolutePosition.X, Constants.RegionSize);
+ }
+ }
+ }
+
+ private Vector3 GetPositionAtAvatarHeightOrGroundHeight(ScenePresence avatar, float x, float y)
+ {
+ Vector3 ground = GetPositionAtGround(x, y);
+ if( avatar.AbsolutePosition.Z > ground.Z)
+ {
+ ground.Z = avatar.AbsolutePosition.Z;
+ }
+ return ground;
+ }
+
+ private Vector3 GetPositionAtGround(float x, float y)
+ {
+ return new Vector3(x, y, GetGroundHeight(x, y));
+ }
}
}
diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
index f2253f2..1885946 100644
--- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
+++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
@@ -680,6 +680,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
public event Action OnRegionHandShakeReply;
public event GenericCall2 OnRequestWearables;
public event GenericCall1 OnCompleteMovementToRegion;
+ public event UpdateAgent OnPreAgentUpdate;
public event UpdateAgent OnAgentUpdate;
public event AgentRequestSit OnAgentRequestSit;
public event AgentSit OnAgentSit;
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
index 65445d9..77958eb 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
@@ -190,6 +190,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
public event Action OnRegionHandShakeReply;
public event GenericCall2 OnRequestWearables;
public event GenericCall1 OnCompleteMovementToRegion;
+ public event UpdateAgent OnPreAgentUpdate;
public event UpdateAgent OnAgentUpdate;
public event AgentRequestSit OnAgentRequestSit;
public event AgentSit OnAgentSit;
--
cgit v1.1