aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework')
-rw-r--r--OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs106
-rw-r--r--OpenSim/Region/Framework/Interfaces/IDialogModule.cs5
-rw-r--r--OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs (renamed from OpenSim/Region/Framework/Scenes/Hypergrid/HGUuidGatherer.cs)46
-rw-r--r--OpenSim/Region/Framework/Interfaces/IEstateDataStore.cs8
-rw-r--r--OpenSim/Region/Framework/Interfaces/IFriendsModule.cs16
-rw-r--r--OpenSim/Region/Framework/Interfaces/IGroupsMessagingModule.cs73
-rw-r--r--OpenSim/Region/Framework/Interfaces/IGroupsModule.cs39
-rw-r--r--OpenSim/Region/Framework/Interfaces/IInventoryAccessModule.cs (renamed from OpenSim/Region/Framework/Interfaces/ITeleportModule.cs)16
-rw-r--r--OpenSim/Region/Framework/Interfaces/IInventoryArchiverModule.cs4
-rw-r--r--OpenSim/Region/Framework/Interfaces/IPresenceModule.cs10
-rw-r--r--OpenSim/Region/Framework/Interfaces/IRegionDataStore.cs4
-rw-r--r--OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs5
-rw-r--r--OpenSim/Region/Framework/Scenes/EventManager.cs55
-rw-r--r--OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs265
-rw-r--r--OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.Inventory.cs174
-rw-r--r--OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.cs77
-rw-r--r--OpenSim/Region/Framework/Scenes/Hypergrid/HGSceneCommunicationService.cs391
-rw-r--r--OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs3
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Inventory.cs740
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs73
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs1168
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneBase.cs28
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs1243
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneGraph.cs402
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneManager.cs33
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs78
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs153
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs279
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneViewer.cs1
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneBaseTests.cs5
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs12
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs3
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs14
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs8
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/StandaloneTeleportTests.cs9
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs6
-rw-r--r--OpenSim/Region/Framework/Scenes/UuidGatherer.cs48
39 files changed, 1506 insertions, 4098 deletions
diff --git a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs
new file mode 100644
index 0000000..0222b02
--- /dev/null
+++ b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs
@@ -0,0 +1,106 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using OpenMetaverse;
30using OpenSim.Framework;
31using OpenSim.Region.Framework.Scenes;
32
33namespace OpenSim.Region.Framework.Interfaces
34{
35 public interface IAttachmentsModule
36 {
37 /// <summary>
38 /// Attach an object to an avatar from the world.
39 /// </summary>
40 /// <param name="controllingClient"></param>
41 /// <param name="localID"></param>
42 /// <param name="attachPoint"></param>
43 /// <param name="rot"></param>
44 /// <param name="silent"></param>
45 void AttachObject(
46 IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, Quaternion rot, bool silent);
47
48 /// <summary>
49 /// Attach an object to an avatar.
50 /// </summary>
51 /// <param name="controllingClient"></param>
52 /// <param name="localID"></param>
53 /// <param name="attachPoint"></param>
54 /// <param name="rot"></param>
55 /// <param name="attachPos"></param>
56 /// <param name="silent"></param>
57 /// <returns>true if the object was successfully attached, false otherwise</returns>
58 bool AttachObject(
59 IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, Quaternion rot, Vector3 attachPos, bool silent);
60
61 /// <summary>
62 /// Rez an attachment from user inventory and change inventory status to match.
63 /// </summary>
64 /// <param name="remoteClient"></param>
65 /// <param name="itemID"></param>
66 /// <param name="AttachmentPt"></param>
67 /// <returns>The scene object that was attached. Null if the scene object could not be found</returns>
68 UUID RezSingleAttachmentFromInventory(IClientAPI remoteClient, UUID itemID, uint AttachmentPt);
69
70 /// <summary>
71 /// Rez an attachment from user inventory
72 /// </summary>
73 /// <param name="remoteClient"></param>
74 /// <param name="itemID"></param>
75 /// <param name="AttachmentPt"></param>
76 /// <param name="updateinventoryStatus">
77 /// If true, we also update the user's inventory to show that the attachment is set. If false, we do not.
78 /// False is required so that we don't attempt to update information when a user enters a scene with the
79 /// attachment already correctly set up in inventory.
80 /// <returns>The uuid of the scene object that was attached. Null if the scene object could not be found</returns>
81 UUID RezSingleAttachmentFromInventory(
82 IClientAPI remoteClient, UUID itemID, uint AttachmentPt, bool updateInventoryStatus);
83
84 /// <summary>
85 /// Update the user inventory to the attachment of an item
86 /// </summary>
87 /// <param name="att"></param>
88 /// <param name="remoteClient"></param>
89 /// <param name="itemID"></param>
90 /// <param name="AttachmentPt"></param>
91 /// <returns></returns>
92 UUID SetAttachmentInventoryStatus(
93 SceneObjectGroup att, IClientAPI remoteClient, UUID itemID, uint AttachmentPt);
94
95 /// <summary>
96 /// Update the user inventory to show a detach.
97 /// </summary>
98 /// <param name="itemID">
99 /// A <see cref="UUID"/>
100 /// </param>
101 /// <param name="remoteClient">
102 /// A <see cref="IClientAPI"/>
103 /// </param>
104 void ShowDetachInUserInventory(UUID itemID, IClientAPI remoteClient);
105 }
106} \ No newline at end of file
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
131 /// <param name="fromAvatarName">The name of the user doing the sending</param> 131 /// <param name="fromAvatarName">The name of the user doing the sending</param>
132 /// <param name="message">The message being sent to the user</param> 132 /// <param name="message">The message being sent to the user</param>
133 void SendNotificationToUsersInEstate(UUID fromAvatarID, string fromAvatarName, string message); 133 void SendNotificationToUsersInEstate(UUID fromAvatarID, string fromAvatarName, string message);
134
135 /// <summary>
136 /// Send a textbox entry for the client to respond to
137 /// </summary>
138 void SendTextBoxToUser(UUID avatarid, string message, int chatChannel, string name, UUID objectid, UUID ownerid);
134 } 139 }
135} 140}
diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGUuidGatherer.cs b/OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs
index 5d4e7ac..e8738c4 100644
--- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGUuidGatherer.cs
+++ b/OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs
@@ -26,31 +26,35 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections.Generic;
30
31using OpenSim.Framework;
32using OpenSim.Services.Interfaces; 29using OpenSim.Services.Interfaces;
30using GridRegion = OpenSim.Services.Interfaces.GridRegion;
31
33using OpenMetaverse; 32using OpenMetaverse;
33using OpenSim.Framework;
34using OpenSim.Region.Framework.Scenes;
34 35
35namespace OpenSim.Region.Framework.Scenes.Hypergrid 36namespace OpenSim.Region.Framework.Interfaces
36{ 37{
37 public class HGUuidGatherer : UuidGatherer 38 public interface IEntityTransferModule
39 {
40 void Teleport(ScenePresence agent, ulong regionHandle, Vector3 position,
41 Vector3 lookAt, uint teleportFlags);
42
43 void TeleportHome(UUID id, IClientAPI client);
44
45 void Cross(ScenePresence agent, bool isFlying);
46
47 void AgentArrivedAtDestination(UUID agent);
48
49 void EnableChildAgents(ScenePresence agent);
50
51 void EnableChildAgent(ScenePresence agent, GridRegion region);
52
53 void Cross(SceneObjectGroup sog, Vector3 position, bool silent);
54 }
55
56 public interface IUserAgentVerificationModule
38 { 57 {
39 protected string m_assetServerURL; 58 bool VerifyClient(AgentCircuitData aCircuit, string token);
40 protected HGAssetMapper m_assetMapper;
41
42 public HGUuidGatherer(HGAssetMapper assMap, IAssetService assetCache, string assetServerURL) : base(assetCache)
43 {
44 m_assetMapper = assMap;
45 m_assetServerURL = assetServerURL;
46 }
47
48 protected override AssetBase GetAsset(UUID uuid)
49 {
50 if (string.Empty == m_assetServerURL)
51 return m_assetCache.Get(uuid.ToString());
52 else
53 return m_assetMapper.FetchAsset(m_assetServerURL, uuid);
54 }
55 } 59 }
56} 60}
diff --git a/OpenSim/Region/Framework/Interfaces/IEstateDataStore.cs b/OpenSim/Region/Framework/Interfaces/IEstateDataStore.cs
index 668ff98..87c7a05 100644
--- a/OpenSim/Region/Framework/Interfaces/IEstateDataStore.cs
+++ b/OpenSim/Region/Framework/Interfaces/IEstateDataStore.cs
@@ -25,6 +25,7 @@
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using System.Collections.Generic;
28using OpenMetaverse; 29using OpenMetaverse;
29using OpenSim.Framework; 30using OpenSim.Framework;
30 31
@@ -34,7 +35,12 @@ namespace OpenSim.Region.Framework.Interfaces
34 { 35 {
35 void Initialise(string connectstring); 36 void Initialise(string connectstring);
36 37
37 EstateSettings LoadEstateSettings(UUID regionID); 38 EstateSettings LoadEstateSettings(UUID regionID, bool create);
39 EstateSettings LoadEstateSettings(int estateID);
38 void StoreEstateSettings(EstateSettings es); 40 void StoreEstateSettings(EstateSettings es);
41 List<int> GetEstates(string search);
42 bool LinkRegion(UUID regionID, int estateID);
43 List<UUID> GetRegions(int estateID);
44 bool DeleteEstate(int estateID);
39 } 45 }
40} 46}
diff --git a/OpenSim/Region/Framework/Interfaces/IFriendsModule.cs b/OpenSim/Region/Framework/Interfaces/IFriendsModule.cs
index 8386030..0ff7dee 100644
--- a/OpenSim/Region/Framework/Interfaces/IFriendsModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IFriendsModule.cs
@@ -33,19 +33,7 @@ namespace OpenSim.Region.Framework.Interfaces
33{ 33{
34 public interface IFriendsModule 34 public interface IFriendsModule
35 { 35 {
36 /// <summary> 36 uint GetFriendPerms(UUID PrincipalID, UUID FriendID);
37 /// Offer a friendship to a user from the server end rather than by direct initiation from a client. 37 void SendFriendsOnlineIfNeeded(IClientAPI client);
38 /// </summary>
39 /// <param name="fromUserId">
40 /// A user with this id must existing in the user data store, but need not be logged on.
41 /// </param>
42 /// <param name="toUserClient">
43 /// An actually logged in client to which the offer is being made.
44 /// FIXME: This is somewhat too tightly coupled - it should arguably be possible to offer friendships even if the
45 /// receiving user is not currently online.
46 /// </param>
47 /// <param name="offerMessage"></param>
48 void OfferFriendship(UUID fromUserId, IClientAPI toUserClient, string offerMessage);
49 List<FriendListItem> GetUserFriends(UUID agentID);
50 } 38 }
51} 39}
diff --git a/OpenSim/Region/Framework/Interfaces/IGroupsMessagingModule.cs b/OpenSim/Region/Framework/Interfaces/IGroupsMessagingModule.cs
new file mode 100644
index 0000000..f158236
--- /dev/null
+++ b/OpenSim/Region/Framework/Interfaces/IGroupsMessagingModule.cs
@@ -0,0 +1,73 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using OpenMetaverse;
29using OpenSim.Framework;
30
31namespace OpenSim.Region.Framework.Interfaces
32{
33 /// <summary>
34 /// Provide mechanisms for messaging groups.
35 /// </summary>
36 ///
37 /// TODO: Provide a mechanism for receiving group messages as well as sending them
38 ///
39 public interface IGroupsMessagingModule
40 {
41 /// <summary>
42 /// Start a group chat session.
43 /// </summary>
44 /// You must call this before calling SendMessageToGroup(). If a chat session for this group is already taking
45 /// place then the agent will added to that session.
46 /// <param name="agentID">
47 /// A UUID that represents the agent being added. If you are agentless (e.g. you are
48 /// a region module), then you can use any random ID.
49 /// </param>
50 /// <param name="groupID">
51 /// The ID for the group to join. Currently, the session ID used is identical to the
52 /// group ID.
53 /// </param>
54 /// <returns>
55 /// True if the chat session was started successfully, false otherwise.
56 /// </returns>
57 bool StartGroupChatSession(UUID agentID, UUID groupID);
58
59 /// <summary>
60 /// Send a message to an entire group.
61 /// </summary>
62 /// <param name="im">
63 /// The message itself. The fields that must be populated are
64 ///
65 /// imSessionID - Populate this with the group ID (session ID and group ID are currently identical)
66 /// fromAgentName - Populate this with whatever arbitrary name you want to show up in the chat dialog
67 /// message - The message itself
68 /// dialog - This must be (byte)InstantMessageDialog.SessionSend
69 /// </param>
70 /// <param name="groupID"></param>
71 void SendMessageToGroup(GridInstantMessage im, UUID groupID);
72 }
73} \ No newline at end of file
diff --git a/OpenSim/Region/Framework/Interfaces/IGroupsModule.cs b/OpenSim/Region/Framework/Interfaces/IGroupsModule.cs
index 8980b2d..2c091e7 100644
--- a/OpenSim/Region/Framework/Interfaces/IGroupsModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IGroupsModule.cs
@@ -37,21 +37,51 @@ namespace OpenSim.Region.Framework.Interfaces
37 { 37 {
38 event NewGroupNotice OnNewGroupNotice; 38 event NewGroupNotice OnNewGroupNotice;
39 39
40 /// <summary>
41 /// Create a group
42 /// </summary>
43 /// <param name="remoteClient"></param>
44 /// <param name="name"></param>
45 /// <param name="charter"></param>
46 /// <param name="showInList"></param>
47 /// <param name="insigniaID"></param>
48 /// <param name="membershipFee"></param>
49 /// <param name="openEnrollment"></param>
50 /// <param name="allowPublish"></param>
51 /// <param name="maturePublish"></param>
52 /// <returns>The UUID of the created group</returns>
53 UUID CreateGroup(
54 IClientAPI remoteClient, string name, string charter, bool showInList, UUID insigniaID, int membershipFee,
55 bool openEnrollment, bool allowPublish, bool maturePublish);
56
57 /// <summary>
58 /// Get a group
59 /// </summary>
60 /// <param name="name">Name of the group</param>
61 /// <returns>The group's data. Null if there is no such group.</returns>
62 GroupRecord GetGroupRecord(string name);
63
64 /// <summary>
65 /// Get a group
66 /// </summary>
67 /// <param name="GroupID">ID of the group</param>
68 /// <returns>The group's data. Null if there is no such group.</returns>
69 GroupRecord GetGroupRecord(UUID GroupID);
70
40 void ActivateGroup(IClientAPI remoteClient, UUID groupID); 71 void ActivateGroup(IClientAPI remoteClient, UUID groupID);
41 List<GroupTitlesData> GroupTitlesRequest(IClientAPI remoteClient, UUID groupID); 72 List<GroupTitlesData> GroupTitlesRequest(IClientAPI remoteClient, UUID groupID);
42 List<GroupMembersData> GroupMembersRequest(IClientAPI remoteClient, UUID groupID); 73 List<GroupMembersData> GroupMembersRequest(IClientAPI remoteClient, UUID groupID);
43 List<GroupRolesData> GroupRoleDataRequest(IClientAPI remoteClient, UUID groupID); 74 List<GroupRolesData> GroupRoleDataRequest(IClientAPI remoteClient, UUID groupID);
44 List<GroupRoleMembersData> GroupRoleMembersRequest(IClientAPI remoteClient, UUID groupID); 75 List<GroupRoleMembersData> GroupRoleMembersRequest(IClientAPI remoteClient, UUID groupID);
45 GroupProfileData GroupProfileRequest(IClientAPI remoteClient, UUID groupID); 76 GroupProfileData GroupProfileRequest(IClientAPI remoteClient, UUID groupID);
46 GroupMembershipData[] GetMembershipData(UUID UserID); 77 GroupMembershipData[] GetMembershipData(UUID UserID);
47 GroupMembershipData GetMembershipData(UUID GroupID, UUID UserID); 78 GroupMembershipData GetMembershipData(UUID GroupID, UUID UserID);
48 79
49 void UpdateGroupInfo(IClientAPI remoteClient, UUID groupID, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish); 80 void UpdateGroupInfo(IClientAPI remoteClient, UUID groupID, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish);
50 81
51 void SetGroupAcceptNotices(IClientAPI remoteClient, UUID groupID, bool acceptNotices, bool listInProfile); 82 void SetGroupAcceptNotices(IClientAPI remoteClient, UUID groupID, bool acceptNotices, bool listInProfile);
52 83
53 void GroupTitleUpdate(IClientAPI remoteClient, UUID GroupID, UUID TitleRoleID); 84 void GroupTitleUpdate(IClientAPI remoteClient, UUID GroupID, UUID TitleRoleID);
54 UUID CreateGroup(IClientAPI remoteClient, string name, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish);
55 85
56 GroupNoticeData[] GroupNoticesListRequest(IClientAPI remoteClient, UUID GroupID); 86 GroupNoticeData[] GroupNoticesListRequest(IClientAPI remoteClient, UUID GroupID);
57 string GetGroupTitle(UUID avatarID); 87 string GetGroupTitle(UUID avatarID);
@@ -64,7 +94,6 @@ namespace OpenSim.Region.Framework.Interfaces
64 void LeaveGroupRequest(IClientAPI remoteClient, UUID GroupID); 94 void LeaveGroupRequest(IClientAPI remoteClient, UUID GroupID);
65 void EjectGroupMemberRequest(IClientAPI remoteClient, UUID GroupID, UUID EjecteeID); 95 void EjectGroupMemberRequest(IClientAPI remoteClient, UUID GroupID, UUID EjecteeID);
66 void InviteGroupRequest(IClientAPI remoteClient, UUID GroupID, UUID InviteeID, UUID RoleID); 96 void InviteGroupRequest(IClientAPI remoteClient, UUID GroupID, UUID InviteeID, UUID RoleID);
67 GroupRecord GetGroupRecord(UUID GroupID);
68 void NotifyChange(UUID GroupID); 97 void NotifyChange(UUID GroupID);
69 } 98 }
70} 99} \ No newline at end of file
diff --git a/OpenSim/Region/Framework/Interfaces/ITeleportModule.cs b/OpenSim/Region/Framework/Interfaces/IInventoryAccessModule.cs
index 5f9129d..8185258 100644
--- a/OpenSim/Region/Framework/Interfaces/ITeleportModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IInventoryAccessModule.cs
@@ -27,15 +27,21 @@
27 27
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Text; 30
31using OpenMetaverse; 31using OpenSim.Framework;
32using OpenSim.Region.Framework.Scenes; 32using OpenSim.Region.Framework.Scenes;
33 33
34using OpenMetaverse;
35
34namespace OpenSim.Region.Framework.Interfaces 36namespace OpenSim.Region.Framework.Interfaces
35{ 37{
36 public interface ITeleportModule 38 public interface IInventoryAccessModule
37 { 39 {
38 void RequestTeleportToLocation(ScenePresence avatar, ulong regionHandle, Vector3 position, 40 UUID CapsUpdateInventoryItemAsset(IClientAPI remoteClient, UUID itemID, byte[] data);
39 Vector3 lookAt, uint teleportFlags); 41 UUID DeleteToInventory(DeRezAction action, UUID folderID, SceneObjectGroup objectGroup, IClientAPI remoteClient);
42 SceneObjectGroup RezObject(IClientAPI remoteClient, UUID itemID, Vector3 RayEnd, Vector3 RayStart,
43 UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection,
44 bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment);
45 void TransferInventoryAssets(InventoryItemBase item, UUID sender, UUID receiver);
40 } 46 }
41} 47}
diff --git a/OpenSim/Region/Framework/Interfaces/IInventoryArchiverModule.cs b/OpenSim/Region/Framework/Interfaces/IInventoryArchiverModule.cs
index 2d038ce..fbadd91 100644
--- a/OpenSim/Region/Framework/Interfaces/IInventoryArchiverModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IInventoryArchiverModule.cs
@@ -27,7 +27,7 @@
27 27
28using System; 28using System;
29using System.IO; 29using System.IO;
30using OpenSim.Framework.Communications.Cache; 30using OpenSim.Services.Interfaces;
31 31
32namespace OpenSim.Region.Framework.Interfaces 32namespace OpenSim.Region.Framework.Interfaces
33{ 33{
@@ -41,7 +41,7 @@ namespace OpenSim.Region.Framework.Interfaces
41 /// <param name="savePath">The stream to which the archive was saved</param> 41 /// <param name="savePath">The stream to which the archive was saved</param>
42 /// <param name="reportedException">Contains the exception generated if the save did not succeed</param> 42 /// <param name="reportedException">Contains the exception generated if the save did not succeed</param>
43 public delegate void InventoryArchiveSaved( 43 public delegate void InventoryArchiveSaved(
44 Guid id, bool succeeded, CachedUserInfo userInfo, string invPath, Stream saveStream, Exception reportedException); 44 Guid id, bool succeeded, UserAccount userInfo, string invPath, Stream saveStream, Exception reportedException);
45 45
46 public interface IInventoryArchiverModule 46 public interface IInventoryArchiverModule
47 { 47 {
diff --git a/OpenSim/Region/Framework/Interfaces/IPresenceModule.cs b/OpenSim/Region/Framework/Interfaces/IPresenceModule.cs
index 630c6a3..d44c1e1 100644
--- a/OpenSim/Region/Framework/Interfaces/IPresenceModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IPresenceModule.cs
@@ -31,13 +31,13 @@ namespace OpenSim.Region.Framework.Interfaces
31{ 31{
32 public struct PresenceInfo 32 public struct PresenceInfo
33 { 33 {
34 public UUID userID; 34 public string UserID;
35 public UUID regionID; 35 public UUID RegionID;
36 36
37 public PresenceInfo(UUID userID, UUID regionID) 37 public PresenceInfo(string userID, UUID regionID)
38 { 38 {
39 this.userID = userID; 39 UserID = userID;
40 this.regionID = regionID; 40 RegionID = regionID;
41 } 41 }
42 } 42 }
43 43
diff --git a/OpenSim/Region/Framework/Interfaces/IRegionDataStore.cs b/OpenSim/Region/Framework/Interfaces/IRegionDataStore.cs
index 7312799..3e8e196 100644
--- a/OpenSim/Region/Framework/Interfaces/IRegionDataStore.cs
+++ b/OpenSim/Region/Framework/Interfaces/IRegionDataStore.cs
@@ -103,8 +103,8 @@ namespace OpenSim.Region.Framework.Interfaces
103 103
104 void StoreRegionSettings(RegionSettings rs); 104 void StoreRegionSettings(RegionSettings rs);
105 RegionSettings LoadRegionSettings(UUID regionUUID); 105 RegionSettings LoadRegionSettings(UUID regionUUID);
106 RegionMeta7WindlightData LoadRegionWindlightSettings(UUID regionUUID); 106 RegionLightShareData LoadRegionWindlightSettings(UUID regionUUID);
107 void StoreRegionWindlightSettings(RegionMeta7WindlightData wl); 107 void StoreRegionWindlightSettings(RegionLightShareData wl);
108 108
109 void Shutdown(); 109 void Shutdown();
110 } 110 }
diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs
index be0e985..fd7d44f 100644
--- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs
+++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs
@@ -385,7 +385,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation
385 } 385 }
386 } 386 }
387 387
388 AssetBase Animasset = new AssetBase(UUID.Random(), "Random Animation", (sbyte)AssetType.Animation); 388 AssetBase Animasset = new AssetBase(UUID.Random(), "Random Animation", (sbyte)AssetType.Animation, m_scenePresence.UUID.ToString());
389 Animasset.Data = anim.ToBytes(); 389 Animasset.Data = anim.ToBytes();
390 Animasset.Temporary = true; 390 Animasset.Temporary = true;
391 Animasset.Local = true; 391 Animasset.Local = true;
diff --git a/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs b/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs
index 9a7863b..c08b961 100644
--- a/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs
+++ b/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs
@@ -32,6 +32,7 @@ using System.Timers;
32using log4net; 32using log4net;
33using OpenMetaverse; 33using OpenMetaverse;
34using OpenSim.Framework; 34using OpenSim.Framework;
35using OpenSim.Region.Framework.Interfaces;
35 36
36namespace OpenSim.Region.Framework.Scenes 37namespace OpenSim.Region.Framework.Scenes
37{ 38{
@@ -137,7 +138,9 @@ namespace OpenSim.Region.Framework.Scenes
137 138
138 try 139 try
139 { 140 {
140 m_scene.DeleteToInventory(x.action, x.folderID, x.objectGroup, x.remoteClient); 141 IInventoryAccessModule invAccess = m_scene.RequestModuleInterface<IInventoryAccessModule>();
142 if (invAccess != null)
143 invAccess.DeleteToInventory(x.action, x.folderID, x.objectGroup, x.remoteClient);
141 if (x.permissionToDelete) 144 if (x.permissionToDelete)
142 m_scene.DeleteSceneObject(x.objectGroup, false); 145 m_scene.DeleteSceneObject(x.objectGroup, false);
143 } 146 }
diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs
index 7fb1cd8..ef125cd 100644
--- a/OpenSim/Region/Framework/Scenes/EventManager.cs
+++ b/OpenSim/Region/Framework/Scenes/EventManager.cs
@@ -66,13 +66,16 @@ namespace OpenSim.Region.Framework.Scenes
66 public event OnClientConnectCoreDelegate OnClientConnect; 66 public event OnClientConnectCoreDelegate OnClientConnect;
67 67
68 public delegate void OnNewClientDelegate(IClientAPI client); 68 public delegate void OnNewClientDelegate(IClientAPI client);
69 69
70 /// <summary> 70 /// <summary>
71 /// Deprecated in favour of OnClientConnect. 71 /// Deprecated in favour of OnClientConnect.
72 /// Will be marked Obsolete after IClientCore has 100% of IClientAPI interfaces. 72 /// Will be marked Obsolete after IClientCore has 100% of IClientAPI interfaces.
73 /// </summary> 73 /// </summary>
74 public event OnNewClientDelegate OnNewClient; 74 public event OnNewClientDelegate OnNewClient;
75 75
76 public delegate void OnClientLoginDelegate(IClientAPI client);
77 public event OnClientLoginDelegate OnClientLogin;
78
76 public delegate void OnNewPresenceDelegate(ScenePresence presence); 79 public delegate void OnNewPresenceDelegate(ScenePresence presence);
77 80
78 public event OnNewPresenceDelegate OnNewPresence; 81 public event OnNewPresenceDelegate OnNewPresence;
@@ -107,12 +110,12 @@ namespace OpenSim.Region.Framework.Scenes
107 public event OnSetRootAgentSceneDelegate OnSetRootAgentScene; 110 public event OnSetRootAgentSceneDelegate OnSetRootAgentScene;
108 111
109 /// <summary> 112 /// <summary>
110 /// Called when an object is touched/grabbed. 113 /// Fired when an object is touched/grabbed.
111 /// </summary> 114 /// </summary>
112 /// The originalID is the local ID of the part that was actually touched. The localID itself is always that of 115 /// The originalID is the local ID of the part that was actually touched. The localID itself is always that of
113 /// the root part. 116 /// the root part.
114 public delegate void ObjectGrabDelegate(uint localID, uint originalID, Vector3 offsetPos, IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs);
115 public event ObjectGrabDelegate OnObjectGrab; 117 public event ObjectGrabDelegate OnObjectGrab;
118 public delegate void ObjectGrabDelegate(uint localID, uint originalID, Vector3 offsetPos, IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs);
116 119
117 public event ObjectGrabDelegate OnObjectGrabbing; 120 public event ObjectGrabDelegate OnObjectGrabbing;
118 public event ObjectDeGrabDelegate OnObjectDeGrab; 121 public event ObjectDeGrabDelegate OnObjectDeGrab;
@@ -120,8 +123,11 @@ namespace OpenSim.Region.Framework.Scenes
120 123
121 public event OnPermissionErrorDelegate OnPermissionError; 124 public event OnPermissionErrorDelegate OnPermissionError;
122 125
123 public delegate void NewRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine, int stateSource); 126 /// <summary>
127 /// Fired when a new script is created.
128 /// </summary>
124 public event NewRezScript OnRezScript; 129 public event NewRezScript OnRezScript;
130 public delegate void NewRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine, int stateSource);
125 131
126 public delegate void RemoveScript(uint localID, UUID itemID); 132 public delegate void RemoveScript(uint localID, UUID itemID);
127 public event RemoveScript OnRemoveScript; 133 public event RemoveScript OnRemoveScript;
@@ -165,36 +171,33 @@ namespace OpenSim.Region.Framework.Scenes
165 171
166 public event ClientClosed OnClientClosed; 172 public event ClientClosed OnClientClosed;
167 173
168 public delegate void ScriptChangedEvent(uint localID, uint change); 174 /// <summary>
169 175 /// This is fired when a scene object property that a script might be interested in (such as color, scale or
176 /// inventory) changes. Only enough information is sent for the LSL changed event
177 /// (see http://lslwiki.net/lslwiki/wakka.php?wakka=changed)
178 /// </summary>
170 public event ScriptChangedEvent OnScriptChangedEvent; 179 public event ScriptChangedEvent OnScriptChangedEvent;
180 public delegate void ScriptChangedEvent(uint localID, uint change);
171 181
172 public delegate void ScriptControlEvent(uint localID, UUID item, UUID avatarID, uint held, uint changed); 182 public delegate void ScriptControlEvent(uint localID, UUID item, UUID avatarID, uint held, uint changed);
173
174 public event ScriptControlEvent OnScriptControlEvent; 183 public event ScriptControlEvent OnScriptControlEvent;
175 184
176 public delegate void ScriptAtTargetEvent(uint localID, uint handle, Vector3 targetpos, Vector3 atpos); 185 public delegate void ScriptAtTargetEvent(uint localID, uint handle, Vector3 targetpos, Vector3 atpos);
177
178 public event ScriptAtTargetEvent OnScriptAtTargetEvent; 186 public event ScriptAtTargetEvent OnScriptAtTargetEvent;
179 187
180 public delegate void ScriptNotAtTargetEvent(uint localID); 188 public delegate void ScriptNotAtTargetEvent(uint localID);
181
182 public event ScriptNotAtTargetEvent OnScriptNotAtTargetEvent; 189 public event ScriptNotAtTargetEvent OnScriptNotAtTargetEvent;
183 190
184 public delegate void ScriptAtRotTargetEvent(uint localID, uint handle, Quaternion targetrot, Quaternion atrot); 191 public delegate void ScriptAtRotTargetEvent(uint localID, uint handle, Quaternion targetrot, Quaternion atrot);
185
186 public event ScriptAtRotTargetEvent OnScriptAtRotTargetEvent; 192 public event ScriptAtRotTargetEvent OnScriptAtRotTargetEvent;
187 193
188 public delegate void ScriptNotAtRotTargetEvent(uint localID); 194 public delegate void ScriptNotAtRotTargetEvent(uint localID);
189
190 public event ScriptNotAtRotTargetEvent OnScriptNotAtRotTargetEvent; 195 public event ScriptNotAtRotTargetEvent OnScriptNotAtRotTargetEvent;
191 196
192 public delegate void ScriptColliding(uint localID, ColliderArgs colliders); 197 public delegate void ScriptColliding(uint localID, ColliderArgs colliders);
193
194 public event ScriptColliding OnScriptColliderStart; 198 public event ScriptColliding OnScriptColliderStart;
195 public event ScriptColliding OnScriptColliding; 199 public event ScriptColliding OnScriptColliding;
196 public event ScriptColliding OnScriptCollidingEnd; 200 public event ScriptColliding OnScriptCollidingEnd;
197
198 public event ScriptColliding OnScriptLandColliderStart; 201 public event ScriptColliding OnScriptLandColliderStart;
199 public event ScriptColliding OnScriptLandColliding; 202 public event ScriptColliding OnScriptLandColliding;
200 public event ScriptColliding OnScriptLandColliderEnd; 203 public event ScriptColliding OnScriptLandColliderEnd;
@@ -204,7 +207,7 @@ namespace OpenSim.Region.Framework.Scenes
204 207
205 public delegate void OnMakeRootAgentDelegate(ScenePresence presence); 208 public delegate void OnMakeRootAgentDelegate(ScenePresence presence);
206 public delegate void OnSaveNewWindlightProfileDelegate(); 209 public delegate void OnSaveNewWindlightProfileDelegate();
207 public delegate void OnSendNewWindlightProfileTargetedDelegate(RegionMeta7WindlightData wl, UUID user); 210 public delegate void OnSendNewWindlightProfileTargetedDelegate(RegionLightShareData wl, UUID user);
208 public event OnMakeRootAgentDelegate OnMakeRootAgent; 211 public event OnMakeRootAgentDelegate OnMakeRootAgent;
209 public event OnSendNewWindlightProfileTargetedDelegate OnSendNewWindlightProfileTargeted; 212 public event OnSendNewWindlightProfileTargetedDelegate OnSendNewWindlightProfileTargeted;
210 public event OnSaveNewWindlightProfileDelegate OnSaveNewWindlightProfile; 213 public event OnSaveNewWindlightProfileDelegate OnSaveNewWindlightProfile;
@@ -587,6 +590,28 @@ namespace OpenSim.Region.Framework.Scenes
587 } 590 }
588 } 591 }
589 592
593 public void TriggerOnClientLogin(IClientAPI client)
594 {
595 OnClientLoginDelegate handlerClientLogin = OnClientLogin;
596 if (handlerClientLogin != null)
597 {
598 foreach (OnClientLoginDelegate d in handlerClientLogin.GetInvocationList())
599 {
600 try
601 {
602 d(client);
603 }
604 catch (Exception e)
605 {
606 m_log.ErrorFormat(
607 "[EVENT MANAGER]: Delegate for TriggerOnClientLogin failed - continuing. {0} {1}",
608 e.Message, e.StackTrace);
609 }
610 }
611 }
612
613 }
614
590 public void TriggerOnNewPresence(ScenePresence presence) 615 public void TriggerOnNewPresence(ScenePresence presence)
591 { 616 {
592 OnNewPresenceDelegate handlerNewPresence = OnNewPresence; 617 OnNewPresenceDelegate handlerNewPresence = OnNewPresence;
@@ -1195,7 +1220,7 @@ namespace OpenSim.Region.Framework.Scenes
1195 } 1220 }
1196 } 1221 }
1197 1222
1198 public void TriggerOnSendNewWindlightProfileTargeted(RegionMeta7WindlightData wl, UUID user) 1223 public void TriggerOnSendNewWindlightProfileTargeted(RegionLightShareData wl, UUID user)
1199 { 1224 {
1200 OnSendNewWindlightProfileTargetedDelegate handlerSendNewWindlightProfileTargeted = OnSendNewWindlightProfileTargeted; 1225 OnSendNewWindlightProfileTargetedDelegate handlerSendNewWindlightProfileTargeted = OnSendNewWindlightProfileTargeted;
1201 if (handlerSendNewWindlightProfileTargeted != null) 1226 if (handlerSendNewWindlightProfileTargeted != null)
diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs
deleted file mode 100644
index ec50598..0000000
--- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs
+++ /dev/null
@@ -1,265 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.Reflection;
31using System.Threading;
32using log4net;
33using OpenMetaverse;
34using OpenSim.Framework;
35using OpenSim.Framework.Communications.Cache;
36using OpenSim.Framework.Communications.Clients;
37using OpenSim.Region.Framework.Scenes.Serialization;
38using OpenSim.Region.Framework.Interfaces;
39using OpenSim.Services.Interfaces;
40
41//using HyperGrid.Framework;
42//using OpenSim.Region.Communications.Hypergrid;
43
44namespace OpenSim.Region.Framework.Scenes.Hypergrid
45{
46 public class HGAssetMapper
47 {
48 #region Fields
49 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
50
51 // This maps between inventory server urls and inventory server clients
52// private Dictionary<string, InventoryClient> m_inventoryServers = new Dictionary<string, InventoryClient>();
53
54 private Scene m_scene;
55
56 private IHyperAssetService m_hyper;
57 IHyperAssetService HyperlinkAssets
58 {
59 get
60 {
61 if (m_hyper == null)
62 m_hyper = m_scene.RequestModuleInterface<IHyperAssetService>();
63 return m_hyper;
64 }
65 }
66
67 #endregion
68
69 #region Constructor
70
71 public HGAssetMapper(Scene scene)
72 {
73 m_scene = scene;
74 }
75
76 #endregion
77
78 #region Internal functions
79
80// private string UserAssetURL(UUID userID)
81// {
82// CachedUserInfo uinfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(userID);
83// if (uinfo != null)
84// return (uinfo.UserProfile.UserAssetURI == "") ? null : uinfo.UserProfile.UserAssetURI;
85// return null;
86// }
87
88// private string UserInventoryURL(UUID userID)
89// {
90// CachedUserInfo uinfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(userID);
91// if (uinfo != null)
92// return (uinfo.UserProfile.UserInventoryURI == "") ? null : uinfo.UserProfile.UserInventoryURI;
93// return null;
94// }
95
96
97 public AssetBase FetchAsset(string url, UUID assetID)
98 {
99 AssetBase asset = m_scene.AssetService.Get(url + "/" + assetID.ToString());
100
101 if (asset != null)
102 {
103 m_log.DebugFormat("[HGScene]: Copied asset {0} from {1} to local asset server. ", asset.ID, url);
104 return asset;
105 }
106 return null;
107 }
108
109 public bool PostAsset(string url, AssetBase asset)
110 {
111 if (asset != null)
112 {
113 // See long comment in AssetCache.AddAsset
114 if (!asset.Temporary || asset.Local)
115 {
116 // We need to copy the asset into a new asset, because
117 // we need to set its ID to be URL+UUID, so that the
118 // HGAssetService dispatches it to the remote grid.
119 // It's not pretty, but the best that can be done while
120 // not having a global naming infrastructure
121 AssetBase asset1 = new AssetBase(asset.FullID, asset.Name, asset.Type);
122 Copy(asset, asset1);
123 try
124 {
125 asset1.ID = url + "/" + asset.ID;
126 }
127 catch
128 {
129 m_log.Warn("[HGScene]: Oops.");
130 }
131
132 m_scene.AssetService.Store(asset1);
133 m_log.DebugFormat("[HGScene]: Posted copy of asset {0} from local asset server to {1}", asset1.ID, url);
134 }
135 return true;
136 }
137 else
138 m_log.Warn("[HGScene]: Tried to post asset to remote server, but asset not in local cache.");
139
140 return false;
141 }
142
143 private void Copy(AssetBase from, AssetBase to)
144 {
145 to.Data = from.Data;
146 to.Description = from.Description;
147 to.FullID = from.FullID;
148 to.ID = from.ID;
149 to.Local = from.Local;
150 to.Name = from.Name;
151 to.Temporary = from.Temporary;
152 to.Type = from.Type;
153
154 }
155
156 // TODO: unused
157 // private void Dump(Dictionary<UUID, bool> lst)
158 // {
159 // m_log.Debug("XXX -------- UUID DUMP ------- XXX");
160 // foreach (KeyValuePair<UUID, bool> kvp in lst)
161 // m_log.Debug(" >> " + kvp.Key + " (texture? " + kvp.Value + ")");
162 // m_log.Debug("XXX -------- UUID DUMP ------- XXX");
163 // }
164
165 #endregion
166
167
168 #region Public interface
169
170 public void Get(UUID assetID, UUID ownerID)
171 {
172 // Get the item from the remote asset server onto the local AssetCache
173 // and place an entry in m_assetMap
174
175 string userAssetURL = HyperlinkAssets.GetUserAssetServer(ownerID);
176 if ((userAssetURL != string.Empty) && (userAssetURL != HyperlinkAssets.GetSimAssetServer()))
177 {
178 m_log.Debug("[HGScene]: Fetching object " + assetID + " from asset server " + userAssetURL);
179 AssetBase asset = FetchAsset(userAssetURL, assetID);
180
181 if (asset != null)
182 {
183 // OK, now fetch the inside.
184 Dictionary<UUID, int> ids = new Dictionary<UUID, int>();
185 HGUuidGatherer uuidGatherer = new HGUuidGatherer(this, m_scene.AssetService, userAssetURL);
186 uuidGatherer.GatherAssetUuids(asset.FullID, (AssetType)asset.Type, ids);
187 foreach (UUID uuid in ids.Keys)
188 FetchAsset(userAssetURL, uuid);
189
190 m_log.DebugFormat("[HGScene]: Successfully fetched asset {0} from asset server {1}", asset.ID, userAssetURL);
191
192 }
193 else
194 m_log.Warn("[HGScene]: Could not fetch asset from remote asset server " + userAssetURL);
195 }
196 else
197 m_log.Debug("[HGScene]: user's asset server is the local region's asset server");
198 }
199
200 //public InventoryItemBase Get(InventoryItemBase item, UUID rootFolder, CachedUserInfo userInfo)
201 //{
202 // InventoryClient invCli = null;
203 // string inventoryURL = UserInventoryURL(item.Owner);
204 // if (!m_inventoryServers.TryGetValue(inventoryURL, out invCli))
205 // {
206 // m_log.Debug("[HGScene]: Starting new InventorytClient for " + inventoryURL);
207 // invCli = new InventoryClient(inventoryURL);
208 // m_inventoryServers.Add(inventoryURL, invCli);
209 // }
210
211 // item = invCli.GetInventoryItem(item);
212 // if (item != null)
213 // {
214 // // Change the folder, stick it in root folder, all items flattened out here in this region cache
215 // item.Folder = rootFolder;
216 // //userInfo.AddItem(item); don't use this, it calls back to the inventory server
217 // lock (userInfo.RootFolder.Items)
218 // {
219 // userInfo.RootFolder.Items[item.ID] = item;
220 // }
221
222 // }
223 // return item;
224 //}
225
226 public void Post(UUID assetID, UUID ownerID)
227 {
228 // Post the item from the local AssetCache onto the remote asset server
229 // and place an entry in m_assetMap
230
231 string userAssetURL = HyperlinkAssets.GetUserAssetServer(ownerID);
232 if ((userAssetURL != string.Empty) && (userAssetURL != HyperlinkAssets.GetSimAssetServer()))
233 {
234 m_log.Debug("[HGScene]: Posting object " + assetID + " to asset server " + userAssetURL);
235 AssetBase asset = m_scene.AssetService.Get(assetID.ToString());
236 if (asset != null)
237 {
238 Dictionary<UUID, int> ids = new Dictionary<UUID, int>();
239 HGUuidGatherer uuidGatherer = new HGUuidGatherer(this, m_scene.AssetService, string.Empty);
240 uuidGatherer.GatherAssetUuids(asset.FullID, (AssetType)asset.Type, ids);
241 foreach (UUID uuid in ids.Keys)
242 {
243 asset = m_scene.AssetService.Get(uuid.ToString());
244 if (asset == null)
245 m_log.DebugFormat("[HGScene]: Could not find asset {0}", uuid);
246 else
247 PostAsset(userAssetURL, asset);
248 }
249
250 // maybe all pieces got there...
251 m_log.DebugFormat("[HGScene]: Successfully posted item {0} to asset server {1}", assetID, userAssetURL);
252
253 }
254 else
255 m_log.DebugFormat("[HGScene]: Something wrong with asset {0}, it could not be found", assetID);
256 }
257 else
258 m_log.Debug("[HGScene]: user's asset server is local region's asset server");
259
260 }
261
262 #endregion
263
264 }
265}
diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.Inventory.cs
deleted file mode 100644
index 6f7f34f..0000000
--- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.Inventory.cs
+++ /dev/null
@@ -1,174 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System.Reflection;
29using log4net;
30using Nini.Config;
31using OpenMetaverse;
32using OpenSim.Framework;
33using OpenSim.Framework.Communications;
34using OpenSim.Framework.Communications.Cache;
35using OpenSim.Region.Framework.Interfaces;
36
37namespace OpenSim.Region.Framework.Scenes.Hypergrid
38{
39 public partial class HGScene : Scene
40 {
41 #region Fields
42 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
43
44 private HGAssetMapper m_assMapper;
45 public HGAssetMapper AssetMapper
46 {
47 get { return m_assMapper; }
48 }
49
50 private IHyperAssetService m_hyper;
51 private IHyperAssetService HyperAssets
52 {
53 get
54 {
55 if (m_hyper == null)
56 m_hyper = RequestModuleInterface<IHyperAssetService>();
57 return m_hyper;
58 }
59 }
60
61 #endregion
62
63 #region Constructors
64
65 public HGScene(RegionInfo regInfo, AgentCircuitManager authen,
66 CommunicationsManager commsMan, SceneCommunicationService sceneGridService,
67 StorageManager storeManager,
68 ModuleLoader moduleLoader, bool dumpAssetsToFile, bool physicalPrim,
69 bool SeeIntoRegionFromNeighbor, IConfigSource config, string simulatorVersion)
70 : base(regInfo, authen, commsMan, sceneGridService, storeManager, moduleLoader,
71 dumpAssetsToFile, physicalPrim, SeeIntoRegionFromNeighbor, config, simulatorVersion)
72 {
73 m_log.Info("[HGScene]: Starting HGScene.");
74 m_assMapper = new HGAssetMapper(this);
75
76 EventManager.OnNewInventoryItemUploadComplete += UploadInventoryItem;
77 }
78
79 #endregion
80
81 #region Event handlers
82
83 public void UploadInventoryItem(UUID avatarID, UUID assetID, string name, int userlevel)
84 {
85 CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(avatarID);
86 if (userInfo != null)
87 {
88 m_assMapper.Post(assetID, avatarID);
89 }
90 }
91
92 #endregion
93
94 #region Overrides of Scene.Inventory methods
95
96 ///
97 /// CapsUpdateInventoryItemAsset
98 ///
99 public override UUID CapsUpdateInventoryItemAsset(IClientAPI remoteClient, UUID itemID, byte[] data)
100 {
101 UUID newAssetID = base.CapsUpdateInventoryItemAsset(remoteClient, itemID, data);
102
103 UploadInventoryItem(remoteClient.AgentId, newAssetID, "", 0);
104
105 return newAssetID;
106 }
107
108 ///
109 /// DeleteToInventory
110 ///
111 public override UUID DeleteToInventory(DeRezAction action, UUID folderID, SceneObjectGroup objectGroup, IClientAPI remoteClient)
112 {
113 UUID assetID = base.DeleteToInventory(action, folderID, objectGroup, remoteClient);
114
115 if (!assetID.Equals(UUID.Zero))
116 {
117 UploadInventoryItem(remoteClient.AgentId, assetID, "", 0);
118 }
119 else
120 m_log.Debug("[HGScene]: Scene.Inventory did not create asset");
121
122 return assetID;
123 }
124
125 ///
126 /// RezObject
127 ///
128 public override SceneObjectGroup RezObject(IClientAPI remoteClient, UUID itemID, Vector3 RayEnd, Vector3 RayStart,
129 UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection,
130 bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment)
131 {
132 m_log.DebugFormat("[HGScene] RezObject itemID={0} fromTaskID={1}", itemID, fromTaskID);
133
134 //if (fromTaskID.Equals(UUID.Zero))
135 //{
136 InventoryItemBase item = new InventoryItemBase(itemID);
137 item.Owner = remoteClient.AgentId;
138 item = InventoryService.GetItem(item);
139 //if (item == null)
140 //{ // Fetch the item
141 // item = new InventoryItemBase();
142 // item.Owner = remoteClient.AgentId;
143 // item.ID = itemID;
144 // item = m_assMapper.Get(item, userInfo.RootFolder.ID, userInfo);
145 //}
146 if (item != null)
147 {
148 m_assMapper.Get(item.AssetID, remoteClient.AgentId);
149
150 }
151 //}
152
153 // OK, we're done fetching. Pass it up to the default RezObject
154 return base.RezObject(remoteClient, itemID, RayEnd, RayStart, RayTargetID, BypassRayCast, RayEndIsIntersection,
155 RezSelected, RemoveItem, fromTaskID, attachment);
156
157 }
158
159 protected override void TransferInventoryAssets(InventoryItemBase item, UUID sender, UUID receiver)
160 {
161 string userAssetServer = HyperAssets.GetUserAssetServer(sender);
162 if ((userAssetServer != string.Empty) && (userAssetServer != HyperAssets.GetSimAssetServer()))
163 m_assMapper.Get(item.AssetID, sender);
164
165 userAssetServer = HyperAssets.GetUserAssetServer(receiver);
166 if ((userAssetServer != string.Empty) && (userAssetServer != HyperAssets.GetSimAssetServer()))
167 m_assMapper.Post(item.AssetID, receiver);
168 }
169
170 #endregion
171
172 }
173
174}
diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.cs
deleted file mode 100644
index b1981b6..0000000
--- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.cs
+++ /dev/null
@@ -1,77 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using OpenMetaverse;
29using OpenSim.Framework;
30using OpenSim.Framework.Communications.Cache;
31using TPFlags = OpenSim.Framework.Constants.TeleportFlags;
32using GridRegion = OpenSim.Services.Interfaces.GridRegion;
33
34namespace OpenSim.Region.Framework.Scenes.Hypergrid
35{
36 public partial class HGScene : Scene
37 {
38 /// <summary>
39 /// Teleport an avatar to their home region
40 /// </summary>
41 /// <param name="agentId"></param>
42 /// <param name="client"></param>
43 public override void TeleportClientHome(UUID agentId, IClientAPI client)
44 {
45 m_log.Debug("[HGScene]: TeleportClientHome " + client.FirstName + " " + client.LastName);
46
47 CachedUserInfo uinfo = CommsManager.UserProfileCacheService.GetUserDetails(agentId);
48 if (uinfo != null)
49 {
50 UserProfileData UserProfile = uinfo.UserProfile;
51
52 if (UserProfile != null)
53 {
54 GridRegion regionInfo = GridService.GetRegionByUUID(UUID.Zero, UserProfile.HomeRegionID);
55 //if (regionInfo != null)
56 //{
57 // UserProfile.HomeRegionID = regionInfo.RegionID;
58 // //CommsManager.UserService.UpdateUserProfile(UserProfile);
59 //}
60 if (regionInfo == null)
61 {
62 // can't find the Home region: Tell viewer and abort
63 client.SendTeleportFailed("Your home-region could not be found.");
64 return;
65 }
66 RequestTeleportLocation(
67 client, regionInfo.RegionHandle, UserProfile.HomeLocation, UserProfile.HomeLookAt,
68 (uint)(TPFlags.SetLastToTarget | TPFlags.ViaHome));
69 }
70 }
71 else
72 client.SendTeleportFailed("Sorry! I lost your home-region information.");
73
74 }
75
76 }
77}
diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGSceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGSceneCommunicationService.cs
deleted file mode 100644
index 416826c..0000000
--- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGSceneCommunicationService.cs
+++ /dev/null
@@ -1,391 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.Net;
31using System.Reflection;
32using System.Threading;
33using log4net;
34using OpenMetaverse;
35using OpenSim.Framework;
36using OpenSim.Framework.Client;
37using OpenSim.Framework.Communications;
38using OpenSim.Framework.Communications.Cache;
39using OpenSim.Framework.Capabilities;
40using OpenSim.Region.Framework.Interfaces;
41using OpenSim.Services.Interfaces;
42using GridRegion = OpenSim.Services.Interfaces.GridRegion;
43
44namespace OpenSim.Region.Framework.Scenes.Hypergrid
45{
46 public class HGSceneCommunicationService : SceneCommunicationService
47 {
48 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
49
50 private IHyperlinkService m_hg;
51 IHyperlinkService HyperlinkService
52 {
53 get
54 {
55 if (m_hg == null)
56 m_hg = m_scene.RequestModuleInterface<IHyperlinkService>();
57 return m_hg;
58 }
59 }
60
61 public HGSceneCommunicationService(CommunicationsManager commsMan) : base(commsMan)
62 {
63 }
64
65
66 /// <summary>
67 /// Try to teleport an agent to a new region.
68 /// </summary>
69 /// <param name="remoteClient"></param>
70 /// <param name="RegionHandle"></param>
71 /// <param name="position"></param>
72 /// <param name="lookAt"></param>
73 /// <param name="flags"></param>
74 public override void RequestTeleportToLocation(ScenePresence avatar, ulong regionHandle, Vector3 position,
75 Vector3 lookAt, uint teleportFlags)
76 {
77 if (!avatar.Scene.Permissions.CanTeleport(avatar.UUID))
78 return;
79
80 bool destRegionUp = true;
81
82 IEventQueue eq = avatar.Scene.RequestModuleInterface<IEventQueue>();
83
84 // Reset animations; the viewer does that in teleports.
85 avatar.Animator.ResetAnimations();
86
87 if (regionHandle == m_regionInfo.RegionHandle)
88 {
89 // Teleport within the same region
90 if (IsOutsideRegion(avatar.Scene, position) || position.Z < 0)
91 {
92 Vector3 emergencyPos = new Vector3(128, 128, 128);
93
94 m_log.WarnFormat(
95 "[HGSceneCommService]: RequestTeleportToLocation() was given an illegal position of {0} for avatar {1}, {2}. Substituting {3}",
96 position, avatar.Name, avatar.UUID, emergencyPos);
97 position = emergencyPos;
98 }
99 // TODO: Get proper AVG Height
100 float localAVHeight = 1.56f;
101
102 float posZLimit = 22;
103
104 if (position.X > 0 && position.X <= (int)Constants.RegionSize && position.Y > 0 && position.Y <= (int)Constants.RegionSize)
105 {
106 posZLimit = (float) avatar.Scene.Heightmap[(int) position.X, (int) position.Y];
107 }
108
109 float newPosZ = posZLimit + localAVHeight;
110 if (posZLimit >= (position.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ)))
111 {
112 position.Z = newPosZ;
113 }
114
115 // Only send this if the event queue is null
116 if (eq == null)
117 avatar.ControllingClient.SendTeleportLocationStart();
118
119
120 avatar.ControllingClient.SendLocalTeleport(position, lookAt, teleportFlags);
121 avatar.Teleport(position);
122 }
123 else
124 {
125 uint x = 0, y = 0;
126 Utils.LongToUInts(regionHandle, out x, out y);
127 GridRegion reg = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, (int)x, (int)y);
128
129 if (reg != null)
130 {
131
132 uint newRegionX = (uint)(reg.RegionHandle >> 40);
133 uint newRegionY = (((uint)(reg.RegionHandle)) >> 8);
134 uint oldRegionX = (uint)(m_regionInfo.RegionHandle >> 40);
135 uint oldRegionY = (((uint)(m_regionInfo.RegionHandle)) >> 8);
136
137 ///
138 /// Hypergrid mod start
139 ///
140 ///
141 bool isHyperLink = (HyperlinkService.GetHyperlinkRegion(reg.RegionHandle) != null);
142 bool isHomeUser = true;
143 ulong realHandle = regionHandle;
144 CachedUserInfo uinfo = m_commsProvider.UserProfileCacheService.GetUserDetails(avatar.UUID);
145 if (uinfo != null)
146 {
147 isHomeUser = HyperlinkService.IsLocalUser(uinfo.UserProfile.ID);
148 realHandle = m_hg.FindRegionHandle(regionHandle);
149 m_log.Debug("XXX ---- home user? " + isHomeUser + " --- hyperlink? " + isHyperLink + " --- real handle: " + realHandle.ToString());
150 }
151 ///
152 /// Hypergrid mod stop
153 ///
154 ///
155
156 if (eq == null)
157 avatar.ControllingClient.SendTeleportLocationStart();
158
159
160 // Let's do DNS resolution only once in this process, please!
161 // This may be a costly operation. The reg.ExternalEndPoint field is not a passive field,
162 // it's actually doing a lot of work.
163 IPEndPoint endPoint = reg.ExternalEndPoint;
164 if (endPoint.Address == null)
165 {
166 // Couldn't resolve the name. Can't TP, because the viewer wants IP addresses.
167 destRegionUp = false;
168 }
169
170 if (destRegionUp)
171 {
172 // Fixing a bug where teleporting while sitting results in the avatar ending up removed from
173 // both regions
174 if (avatar.ParentID != (uint)0)
175 avatar.StandUp();
176
177 if (!avatar.ValidateAttachments())
178 {
179 avatar.ControllingClient.SendTeleportFailed("Inconsistent attachment state");
180 return;
181 }
182
183 // the avatar.Close below will clear the child region list. We need this below for (possibly)
184 // closing the child agents, so save it here (we need a copy as it is Clear()-ed).
185 //List<ulong> childRegions = new List<ulong>(avatar.GetKnownRegionList());
186 // Compared to ScenePresence.CrossToNewRegion(), there's no obvious code to handle a teleport
187 // failure at this point (unlike a border crossing failure). So perhaps this can never fail
188 // once we reach here...
189 //avatar.Scene.RemoveCapsHandler(avatar.UUID);
190
191 string capsPath = String.Empty;
192 AgentCircuitData agentCircuit = avatar.ControllingClient.RequestClientInfo();
193 agentCircuit.BaseFolder = UUID.Zero;
194 agentCircuit.InventoryFolder = UUID.Zero;
195 agentCircuit.startpos = position;
196 agentCircuit.child = true;
197 if (Util.IsOutsideView(oldRegionX, newRegionX, oldRegionY, newRegionY))
198 {
199 // brand new agent, let's create a new caps seed
200 agentCircuit.CapsPath = CapsUtil.GetRandomCapsObjectPath();
201 }
202
203 string reason = String.Empty;
204
205 //if (!m_commsProvider.InterRegion.InformRegionOfChildAgent(reg.RegionHandle, agentCircuit))
206 if (!m_interregionCommsOut.SendCreateChildAgent(reg.RegionHandle, agentCircuit, teleportFlags, out reason))
207 {
208 avatar.ControllingClient.SendTeleportFailed(String.Format("Destination is not accepting teleports: {0}",
209 reason));
210 return;
211 }
212
213 // Let's close some agents
214 if (isHyperLink) // close them all except this one
215 {
216 List<ulong> regions = new List<ulong>(avatar.KnownChildRegionHandles);
217 regions.Remove(avatar.Scene.RegionInfo.RegionHandle);
218 SendCloseChildAgentConnections(avatar.UUID, regions);
219 }
220 else // close just a few
221 avatar.CloseChildAgents(newRegionX, newRegionY);
222
223 if (Util.IsOutsideView(oldRegionX, newRegionX, oldRegionY, newRegionY) || isHyperLink)
224 {
225 capsPath
226 = "http://"
227 + reg.ExternalHostName
228 + ":"
229 + reg.HttpPort
230 + CapsUtil.GetCapsSeedPath(agentCircuit.CapsPath);
231
232 if (eq != null)
233 {
234 #region IP Translation for NAT
235 IClientIPEndpoint ipepClient;
236 if (avatar.ClientView.TryGet(out ipepClient))
237 {
238 endPoint.Address = NetworkUtil.GetIPFor(ipepClient.EndPoint, endPoint.Address);
239 }
240 #endregion
241
242 eq.EnableSimulator(realHandle, endPoint, avatar.UUID);
243
244 // ES makes the client send a UseCircuitCode message to the destination,
245 // which triggers a bunch of things there.
246 // So let's wait
247 Thread.Sleep(2000);
248
249 eq.EstablishAgentCommunication(avatar.UUID, endPoint, capsPath);
250 }
251 else
252 {
253 avatar.ControllingClient.InformClientOfNeighbour(realHandle, endPoint);
254 // TODO: make Event Queue disablable!
255 }
256 }
257 else
258 {
259 // child agent already there
260 agentCircuit.CapsPath = avatar.Scene.CapsModule.GetChildSeed(avatar.UUID, reg.RegionHandle);
261 capsPath = "http://" + reg.ExternalHostName + ":" + reg.HttpPort
262 + "/CAPS/" + agentCircuit.CapsPath + "0000/";
263 }
264
265 //m_commsProvider.InterRegion.ExpectAvatarCrossing(reg.RegionHandle, avatar.ControllingClient.AgentId,
266 // position, false);
267
268 //if (!m_commsProvider.InterRegion.ExpectAvatarCrossing(reg.RegionHandle, avatar.ControllingClient.AgentId,
269 // position, false))
270 //{
271 // avatar.ControllingClient.SendTeleportFailed("Problem with destination.");
272 // // We should close that agent we just created over at destination...
273 // List<ulong> lst = new List<ulong>();
274 // lst.Add(realHandle);
275 // SendCloseChildAgentAsync(avatar.UUID, lst);
276 // return;
277 //}
278
279 SetInTransit(avatar.UUID);
280 // Let's send a full update of the agent. This is a synchronous call.
281 AgentData agent = new AgentData();
282 avatar.CopyTo(agent);
283 agent.Position = position;
284 agent.CallbackURI = "http://" + m_regionInfo.ExternalHostName + ":" + m_regionInfo.HttpPort +
285 "/agent/" + avatar.UUID.ToString() + "/" + avatar.Scene.RegionInfo.RegionHandle.ToString() + "/release/";
286
287 m_interregionCommsOut.SendChildAgentUpdate(reg.RegionHandle, agent);
288
289 m_log.DebugFormat(
290 "[CAPS]: Sending new CAPS seed url {0} to client {1}", agentCircuit.CapsPath, avatar.UUID);
291
292
293 ///
294 /// Hypergrid mod: realHandle instead of reg.RegionHandle
295 ///
296 ///
297 if (eq != null)
298 {
299 eq.TeleportFinishEvent(realHandle, 13, endPoint,
300 4, teleportFlags, capsPath, avatar.UUID);
301 }
302 else
303 {
304 avatar.ControllingClient.SendRegionTeleport(realHandle, 13, endPoint, 4,
305 teleportFlags, capsPath);
306 }
307 ///
308 /// Hypergrid mod stop
309 ///
310
311
312 // TeleportFinish makes the client send CompleteMovementIntoRegion (at the destination), which
313 // trigers a whole shebang of things there, including MakeRoot. So let's wait for confirmation
314 // that the client contacted the destination before we send the attachments and close things here.
315 if (!WaitForCallback(avatar.UUID))
316 {
317 // Client never contacted destination. Let's restore everything back
318 avatar.ControllingClient.SendTeleportFailed("Problems connecting to destination.");
319
320 ResetFromTransit(avatar.UUID);
321 // Yikes! We should just have a ref to scene here.
322 avatar.Scene.InformClientOfNeighbours(avatar);
323
324 // Finally, kill the agent we just created at the destination.
325 m_interregionCommsOut.SendCloseAgent(reg.RegionHandle, avatar.UUID);
326
327 return;
328 }
329
330 // Can't go back from here
331 if (KiPrimitive != null)
332 {
333 KiPrimitive(avatar.LocalId);
334 }
335
336 avatar.MakeChildAgent();
337
338 // CrossAttachmentsIntoNewRegion is a synchronous call. We shouldn't need to wait after it
339 avatar.CrossAttachmentsIntoNewRegion(reg.RegionHandle, true);
340
341
342 // Finally, let's close this previously-known-as-root agent, when the jump is outside the view zone
343 ///
344 /// Hypergrid mod: extra check for isHyperLink
345 ///
346 if (Util.IsOutsideView(oldRegionX, newRegionX, oldRegionY, newRegionY) || isHyperLink)
347 {
348 Thread.Sleep(5000);
349 avatar.Close();
350 CloseConnection(avatar.UUID);
351 }
352 // if (teleport success) // seems to be always success here
353 // the user may change their profile information in other region,
354 // so the userinfo in UserProfileCache is not reliable any more, delete it
355 if (avatar.Scene.NeedSceneCacheClear(avatar.UUID) || isHyperLink)
356 {
357 m_commsProvider.UserProfileCacheService.RemoveUser(avatar.UUID);
358 m_log.DebugFormat(
359 "[HGSceneCommService]: User {0} is going to another region, profile cache removed",
360 avatar.UUID);
361 }
362 }
363 else
364 {
365 avatar.ControllingClient.SendTeleportFailed("Remote Region appears to be down");
366 }
367 }
368 else
369 {
370 // TP to a place that doesn't exist (anymore)
371 // Inform the viewer about that
372 avatar.ControllingClient.SendTeleportFailed("The region you tried to teleport to doesn't exist anymore");
373
374 // and set the map-tile to '(Offline)'
375 uint regX, regY;
376 Utils.LongToUInts(regionHandle, out regX, out regY);
377
378 MapBlockData block = new MapBlockData();
379 block.X = (ushort)(regX / Constants.RegionSize);
380 block.Y = (ushort)(regY / Constants.RegionSize);
381 block.Access = 254; // == not there
382
383 List<MapBlockData> blocks = new List<MapBlockData>();
384 blocks.Add(block);
385 avatar.ControllingClient.SendMapBlock(blocks, 0);
386 }
387 }
388 }
389
390 }
391}
diff --git a/OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs b/OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs
index e9660b1..d25d5dd 100644
--- a/OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs
+++ b/OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs
@@ -36,8 +36,7 @@ using OpenMetaverse;
36using OpenMetaverse.StructuredData; 36using OpenMetaverse.StructuredData;
37using OpenSim.Framework; 37using OpenSim.Framework;
38using OpenSim.Framework.Communications; 38using OpenSim.Framework.Communications;
39using OpenSim.Framework.Communications.Services; 39
40using OpenSim.Framework.Communications.Cache;
41using OpenSim.Framework.Console; 40using OpenSim.Framework.Console;
42using OpenSim.Framework.Servers; 41using OpenSim.Framework.Servers;
43using OpenSim.Framework.Servers.HttpServer; 42using OpenSim.Framework.Servers.HttpServer;
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index 6c57d18..357cdc4 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -35,7 +35,7 @@ using OpenMetaverse;
35using OpenMetaverse.Packets; 35using OpenMetaverse.Packets;
36using log4net; 36using log4net;
37using OpenSim.Framework; 37using OpenSim.Framework;
38using OpenSim.Framework.Communications.Cache; 38
39using OpenSim.Region.Framework; 39using OpenSim.Region.Framework;
40using OpenSim.Region.Framework.Interfaces; 40using OpenSim.Region.Framework.Interfaces;
41using OpenSim.Region.Framework.Scenes.Serialization; 41using OpenSim.Region.Framework.Scenes.Serialization;
@@ -101,12 +101,6 @@ namespace OpenSim.Region.Framework.Scenes
101 { 101 {
102 userlevel = 1; 102 userlevel = 1;
103 } 103 }
104 // TODO: remove this cruft once MasterAvatar is fully deprecated
105 //
106 if (m_regInfo.MasterAvatarAssignedUUID == AgentID)
107 {
108 userlevel = 2;
109 }
110 EventManager.TriggerOnNewInventoryItemUploadComplete(AgentID, item.AssetID, item.Name, userlevel); 104 EventManager.TriggerOnNewInventoryItemUploadComplete(AgentID, item.AssetID, item.Name, userlevel);
111 } 105 }
112 else 106 else
@@ -132,70 +126,17 @@ namespace OpenSim.Region.Framework.Scenes
132 } 126 }
133 127
134 /// <summary> 128 /// <summary>
135 /// Capability originating call to update the asset of an item in an agent's inventory
136 /// </summary>
137 /// <param name="remoteClient"></param>
138 /// <param name="itemID"></param>
139 /// <param name="data"></param>
140 /// <returns></returns>
141 public virtual UUID CapsUpdateInventoryItemAsset(IClientAPI remoteClient, UUID itemID, byte[] data)
142 {
143 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
144 item = InventoryService.GetItem(item);
145
146 if (item != null)
147 {
148 if ((InventoryType)item.InvType == InventoryType.Notecard)
149 {
150 if (!Permissions.CanEditNotecard(itemID, UUID.Zero, remoteClient.AgentId))
151 {
152 remoteClient.SendAgentAlertMessage("Insufficient permissions to edit notecard", false);
153 return UUID.Zero;
154 }
155
156 remoteClient.SendAgentAlertMessage("Notecard saved", false);
157 }
158 else if ((InventoryType)item.InvType == InventoryType.LSL)
159 {
160 if (!Permissions.CanEditScript(itemID, UUID.Zero, remoteClient.AgentId))
161 {
162 remoteClient.SendAgentAlertMessage("Insufficient permissions to edit script", false);
163 return UUID.Zero;
164 }
165
166 remoteClient.SendAgentAlertMessage("Script saved", false);
167 }
168
169 AssetBase asset =
170 CreateAsset(item.Name, item.Description, (sbyte)item.AssetType, data);
171 item.AssetID = asset.FullID;
172 AssetService.Store(asset);
173
174 InventoryService.UpdateItem(item);
175
176 // remoteClient.SendInventoryItemCreateUpdate(item);
177 return (asset.FullID);
178 }
179 else
180 {
181 m_log.ErrorFormat(
182 "[AGENT INVENTORY]: Could not find item {0} for caps inventory update",
183 itemID);
184 }
185
186 return UUID.Zero;
187 }
188
189 /// <summary>
190 /// <see>CapsUpdatedInventoryItemAsset(IClientAPI, UUID, byte[])</see> 129 /// <see>CapsUpdatedInventoryItemAsset(IClientAPI, UUID, byte[])</see>
191 /// </summary> 130 /// </summary>
192 public UUID CapsUpdateInventoryItemAsset(UUID avatarId, UUID itemID, byte[] data) 131 public UUID CapsUpdateInventoryItemAsset(UUID avatarId, UUID itemID, byte[] data)
193 { 132 {
194 ScenePresence avatar; 133 ScenePresence avatar;
195 134
196 if (TryGetAvatar(avatarId, out avatar)) 135 if (TryGetScenePresence(avatarId, out avatar))
197 { 136 {
198 return CapsUpdateInventoryItemAsset(avatar.ControllingClient, itemID, data); 137 IInventoryAccessModule invAccess = RequestModuleInterface<IInventoryAccessModule>();
138 if (invAccess != null)
139 return invAccess.CapsUpdateInventoryItemAsset(avatar.ControllingClient, itemID, data);
199 } 140 }
200 else 141 else
201 { 142 {
@@ -251,7 +192,7 @@ namespace OpenSim.Region.Framework.Scenes
251 return new ArrayList(); 192 return new ArrayList();
252 } 193 }
253 194
254 AssetBase asset = CreateAsset(item.Name, item.Description, (sbyte)AssetType.LSLText, data); 195 AssetBase asset = CreateAsset(item.Name, item.Description, (sbyte)AssetType.LSLText, data, remoteClient.AgentId);
255 AssetService.Store(asset); 196 AssetService.Store(asset);
256 197
257 if (isScriptRunning) 198 if (isScriptRunning)
@@ -288,7 +229,7 @@ namespace OpenSim.Region.Framework.Scenes
288 { 229 {
289 ScenePresence avatar; 230 ScenePresence avatar;
290 231
291 if (TryGetAvatar(avatarId, out avatar)) 232 if (TryGetScenePresence(avatarId, out avatar))
292 { 233 {
293 return CapsUpdateTaskInventoryScriptAsset( 234 return CapsUpdateTaskInventoryScriptAsset(
294 avatar.ControllingClient, itemId, primId, isScriptRunning, data); 235 avatar.ControllingClient, itemId, primId, isScriptRunning, data);
@@ -477,7 +418,11 @@ namespace OpenSim.Region.Framework.Scenes
477 itemCopy.SaleType = item.SaleType; 418 itemCopy.SaleType = item.SaleType;
478 419
479 if (InventoryService.AddItem(itemCopy)) 420 if (InventoryService.AddItem(itemCopy))
480 TransferInventoryAssets(itemCopy, senderId, recipient); 421 {
422 IInventoryAccessModule invAccess = RequestModuleInterface<IInventoryAccessModule>();
423 if (invAccess != null)
424 invAccess.TransferInventoryAssets(itemCopy, senderId, recipient);
425 }
481 426
482 if (!Permissions.BypassPermissions()) 427 if (!Permissions.BypassPermissions())
483 { 428 {
@@ -499,10 +444,6 @@ namespace OpenSim.Region.Framework.Scenes
499 444
500 } 445 }
501 446
502 protected virtual void TransferInventoryAssets(InventoryItemBase item, UUID sender, UUID receiver)
503 {
504 }
505
506 /// <summary> 447 /// <summary>
507 /// Give an entire inventory folder from one user to another. The entire contents (including all descendent 448 /// Give an entire inventory folder from one user to another. The entire contents (including all descendent
508 /// folders) is given. 449 /// folders) is given.
@@ -572,7 +513,9 @@ namespace OpenSim.Region.Framework.Scenes
572 "[AGENT INVENTORY]: CopyInventoryItem received by {0} with oldAgentID {1}, oldItemID {2}, new FolderID {3}, newName {4}", 513 "[AGENT INVENTORY]: CopyInventoryItem received by {0} with oldAgentID {1}, oldItemID {2}, new FolderID {3}, newName {4}",
573 remoteClient.AgentId, oldAgentID, oldItemID, newFolderID, newName); 514 remoteClient.AgentId, oldAgentID, oldItemID, newFolderID, newName);
574 515
575 InventoryItemBase item = CommsManager.UserProfileCacheService.LibraryRoot.FindItem(oldItemID); 516 InventoryItemBase item = null;
517 if (LibraryService != null && LibraryService.LibraryRootFolder != null)
518 item = LibraryService.LibraryRootFolder.FindItem(oldItemID);
576 519
577 if (item == null) 520 if (item == null)
578 { 521 {
@@ -626,15 +569,9 @@ namespace OpenSim.Region.Framework.Scenes
626 /// <summary> 569 /// <summary>
627 /// Create a new asset data structure. 570 /// Create a new asset data structure.
628 /// </summary> 571 /// </summary>
629 /// <param name="name"></param> 572 private AssetBase CreateAsset(string name, string description, sbyte assetType, byte[] data, UUID creatorID)
630 /// <param name="description"></param>
631 /// <param name="invType"></param>
632 /// <param name="assetType"></param>
633 /// <param name="data"></param>
634 /// <returns></returns>
635 private AssetBase CreateAsset(string name, string description, sbyte assetType, byte[] data)
636 { 573 {
637 AssetBase asset = new AssetBase(UUID.Random(), name, assetType); 574 AssetBase asset = new AssetBase(UUID.Random(), name, assetType, creatorID.ToString());
638 asset.Description = description; 575 asset.Description = description;
639 asset.Data = (data == null) ? new byte[1] : data; 576 asset.Data = (data == null) ? new byte[1] : data;
640 577
@@ -744,13 +681,9 @@ namespace OpenSim.Region.Framework.Scenes
744 681
745 if (transactionID == UUID.Zero) 682 if (transactionID == UUID.Zero)
746 { 683 {
747 CachedUserInfo userInfo 684 ScenePresence presence;
748 = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId); 685 if (TryGetScenePresence(remoteClient.AgentId, out presence))
749
750 if (userInfo != null)
751 { 686 {
752 ScenePresence presence;
753 TryGetAvatar(remoteClient.AgentId, out presence);
754 byte[] data = null; 687 byte[] data = null;
755 688
756 if (invType == (sbyte)InventoryType.Landmark && presence != null) 689 if (invType == (sbyte)InventoryType.Landmark && presence != null)
@@ -764,7 +697,7 @@ namespace OpenSim.Region.Framework.Scenes
764 data = Encoding.ASCII.GetBytes(strdata); 697 data = Encoding.ASCII.GetBytes(strdata);
765 } 698 }
766 699
767 AssetBase asset = CreateAsset(name, description, assetType, data); 700 AssetBase asset = CreateAsset(name, description, assetType, data, remoteClient.AgentId);
768 AssetService.Store(asset); 701 AssetService.Store(asset);
769 702
770 CreateNewInventoryItem(remoteClient, remoteClient.AgentId.ToString(), folderID, asset.Name, 0, callbackID, asset, invType, nextOwnerMask, creationDate); 703 CreateNewInventoryItem(remoteClient, remoteClient.AgentId.ToString(), folderID, asset.Name, 0, callbackID, asset, invType, nextOwnerMask, creationDate);
@@ -772,7 +705,7 @@ namespace OpenSim.Region.Framework.Scenes
772 else 705 else
773 { 706 {
774 m_log.ErrorFormat( 707 m_log.ErrorFormat(
775 "userInfo for agent uuid {0} unexpectedly null in CreateNewInventoryItem", 708 "ScenePresence for agent uuid {0} unexpectedly not found in CreateNewInventoryItem",
776 remoteClient.AgentId); 709 remoteClient.AgentId);
777 } 710 }
778 } 711 }
@@ -1011,7 +944,7 @@ namespace OpenSim.Region.Framework.Scenes
1011 { 944 {
1012 ScenePresence avatar; 945 ScenePresence avatar;
1013 946
1014 if (TryGetAvatar(avatarId, out avatar)) 947 if (TryGetScenePresence(avatarId, out avatar))
1015 { 948 {
1016 return MoveTaskInventoryItem(avatar.ControllingClient, folderId, part, itemId); 949 return MoveTaskInventoryItem(avatar.ControllingClient, folderId, part, itemId);
1017 } 950 }
@@ -1125,7 +1058,7 @@ namespace OpenSim.Region.Framework.Scenes
1125 1058
1126 ScenePresence avatar; 1059 ScenePresence avatar;
1127 1060
1128 if (TryGetAvatar(srcTaskItem.OwnerID, out avatar)) 1061 if (TryGetScenePresence(srcTaskItem.OwnerID, out avatar))
1129 { 1062 {
1130 destPart.GetProperties(avatar.ControllingClient); 1063 destPart.GetProperties(avatar.ControllingClient);
1131 } 1064 }
@@ -1153,7 +1086,7 @@ namespace OpenSim.Region.Framework.Scenes
1153 } 1086 }
1154 1087
1155 ScenePresence avatar = null; 1088 ScenePresence avatar = null;
1156 if (TryGetAvatar(destID, out avatar)) 1089 if (TryGetScenePresence(destID, out avatar))
1157 { 1090 {
1158 //profile.SendInventoryDecendents(avatar.ControllingClient, 1091 //profile.SendInventoryDecendents(avatar.ControllingClient,
1159 // profile.RootFolder.ID, true, false); 1092 // profile.RootFolder.ID, true, false);
@@ -1169,15 +1102,21 @@ namespace OpenSim.Region.Framework.Scenes
1169 1102
1170 private void SendInventoryUpdate(IClientAPI client, InventoryFolderBase folder, bool fetchFolders, bool fetchItems) 1103 private void SendInventoryUpdate(IClientAPI client, InventoryFolderBase folder, bool fetchFolders, bool fetchItems)
1171 { 1104 {
1172 m_log.DebugFormat("[AGENT INVENTORY]: Send Inventory Folder {0} Update to {1} {2}", folder.Name, client.FirstName, client.LastName); 1105 if (folder == null)
1106 return;
1107
1108 // Fetch the folder contents
1173 InventoryCollection contents = InventoryService.GetFolderContent(client.AgentId, folder.ID); 1109 InventoryCollection contents = InventoryService.GetFolderContent(client.AgentId, folder.ID);
1174 InventoryFolderBase containingFolder = new InventoryFolderBase(); 1110
1175 containingFolder.ID = folder.ID; 1111 // Fetch the folder itself to get its current version
1176 containingFolder.Owner = client.AgentId; 1112 InventoryFolderBase containingFolder = new InventoryFolderBase(folder.ID, client.AgentId);
1177 containingFolder = InventoryService.GetFolder(containingFolder); 1113 containingFolder = InventoryService.GetFolder(containingFolder);
1178 int version = containingFolder.Version;
1179 1114
1180 client.SendInventoryFolderDetails(client.AgentId, folder.ID, contents.Items, contents.Folders, version, fetchFolders, fetchItems); 1115 //m_log.DebugFormat("[AGENT INVENTORY]: Sending inventory folder contents ({0} nodes) for \"{1}\" to {2} {3}",
1116 // contents.Folders.Count + contents.Items.Count, containingFolder.Name, client.FirstName, client.LastName);
1117
1118 if (containingFolder != null)
1119 client.SendInventoryFolderDetails(client.AgentId, folder.ID, contents.Items, contents.Folders, containingFolder.Version, fetchFolders, fetchItems);
1181 } 1120 }
1182 1121
1183 /// <summary> 1122 /// <summary>
@@ -1219,9 +1158,9 @@ namespace OpenSim.Region.Framework.Scenes
1219 item = InventoryService.GetItem(item); 1158 item = InventoryService.GetItem(item);
1220 1159
1221 // Try library 1160 // Try library
1222 if (null == item) 1161 if (null == item && LibraryService != null && LibraryService.LibraryRootFolder != null)
1223 { 1162 {
1224 item = CommsManager.UserProfileCacheService.LibraryRoot.FindItem(itemID); 1163 item = LibraryService.LibraryRootFolder.FindItem(itemID);
1225 } 1164 }
1226 1165
1227 if (item != null) 1166 if (item != null)
@@ -1288,9 +1227,9 @@ namespace OpenSim.Region.Framework.Scenes
1288 1227
1289 // Try library 1228 // Try library
1290 // XXX clumsy, possibly should be one call 1229 // XXX clumsy, possibly should be one call
1291 if (null == item) 1230 if (null == item && LibraryService != null && LibraryService.LibraryRootFolder != null)
1292 { 1231 {
1293 item = CommsManager.UserProfileCacheService.LibraryRoot.FindItem(itemID); 1232 item = LibraryService.LibraryRootFolder.FindItem(itemID);
1294 } 1233 }
1295 1234
1296 if (item != null) 1235 if (item != null)
@@ -1347,7 +1286,9 @@ namespace OpenSim.Region.Framework.Scenes
1347 itemBase.InvType, part.UUID, remoteClient.AgentId)) 1286 itemBase.InvType, part.UUID, remoteClient.AgentId))
1348 return; 1287 return;
1349 1288
1350 AssetBase asset = CreateAsset(itemBase.Name, itemBase.Description, (sbyte)itemBase.AssetType, Encoding.ASCII.GetBytes("default\n{\n state_entry()\n {\n llSay(0, \"Script running\");\n }\n}")); 1289 AssetBase asset = CreateAsset(itemBase.Name, itemBase.Description, (sbyte)itemBase.AssetType,
1290 Encoding.ASCII.GetBytes("default\n{\n state_entry()\n {\n llSay(0, \"Script running\");\n }\n}"),
1291 remoteClient.AgentId);
1351 AssetService.Store(asset); 1292 AssetService.Store(asset);
1352 1293
1353 TaskInventoryItem taskItem = new TaskInventoryItem(); 1294 TaskInventoryItem taskItem = new TaskInventoryItem();
@@ -1482,7 +1423,7 @@ namespace OpenSim.Region.Framework.Scenes
1482 1423
1483 ScenePresence avatar; 1424 ScenePresence avatar;
1484 1425
1485 if (TryGetAvatar(srcTaskItem.OwnerID, out avatar)) 1426 if (TryGetScenePresence(srcTaskItem.OwnerID, out avatar))
1486 { 1427 {
1487 destPart.GetProperties(avatar.ControllingClient); 1428 destPart.GetProperties(avatar.ControllingClient);
1488 } 1429 }
@@ -1616,237 +1557,6 @@ namespace OpenSim.Region.Framework.Scenes
1616 } 1557 }
1617 } 1558 }
1618 1559
1619 /// <summary>
1620 /// Delete a scene object from a scene and place in the given avatar's inventory.
1621 /// Returns the UUID of the newly created asset.
1622 /// </summary>
1623 /// <param name="action"></param>
1624 /// <param name="folderID"></param>
1625 /// <param name="objectGroup"></param>
1626 /// <param name="remoteClient"> </param>
1627 public virtual UUID DeleteToInventory(DeRezAction action, UUID folderID,
1628 SceneObjectGroup objectGroup, IClientAPI remoteClient)
1629 {
1630 UUID assetID = UUID.Zero;
1631
1632 Vector3 inventoryStoredPosition = new Vector3
1633 (((objectGroup.AbsolutePosition.X > (int)Constants.RegionSize)
1634 ? 250
1635 : objectGroup.AbsolutePosition.X)
1636 ,
1637 (objectGroup.AbsolutePosition.X > (int)Constants.RegionSize)
1638 ? 250
1639 : objectGroup.AbsolutePosition.X,
1640 objectGroup.AbsolutePosition.Z);
1641
1642 Vector3 originalPosition = objectGroup.AbsolutePosition;
1643
1644 objectGroup.AbsolutePosition = inventoryStoredPosition;
1645
1646 string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(objectGroup);
1647
1648 objectGroup.AbsolutePosition = originalPosition;
1649
1650 // Get the user info of the item destination
1651 //
1652 UUID userID = UUID.Zero;
1653
1654 if (action == DeRezAction.Take || action == DeRezAction.TakeCopy ||
1655 action == DeRezAction.SaveToExistingUserInventoryItem)
1656 {
1657 // Take or take copy require a taker
1658 // Saving changes requires a local user
1659 //
1660 if (remoteClient == null)
1661 return UUID.Zero;
1662
1663 userID = remoteClient.AgentId;
1664 }
1665 else
1666 {
1667 // All returns / deletes go to the object owner
1668 //
1669
1670 userID = objectGroup.RootPart.OwnerID;
1671 }
1672
1673 if (userID == UUID.Zero) // Can't proceed
1674 {
1675 return UUID.Zero;
1676 }
1677
1678 // If we're returning someone's item, it goes back to the
1679 // owner's Lost And Found folder.
1680 // Delete is treated like return in this case
1681 // Deleting your own items makes them go to trash
1682 //
1683
1684 InventoryFolderBase folder = null;
1685 InventoryItemBase item = null;
1686
1687 if (DeRezAction.SaveToExistingUserInventoryItem == action)
1688 {
1689 item = new InventoryItemBase(objectGroup.RootPart.FromUserInventoryItemID, userID);
1690 item = InventoryService.GetItem(item);
1691
1692 //item = userInfo.RootFolder.FindItem(
1693 // objectGroup.RootPart.FromUserInventoryItemID);
1694
1695 if (null == item)
1696 {
1697 m_log.DebugFormat(
1698 "[AGENT INVENTORY]: Object {0} {1} scheduled for save to inventory has already been deleted.",
1699 objectGroup.Name, objectGroup.UUID);
1700 return UUID.Zero;
1701 }
1702 }
1703 else
1704 {
1705 // Folder magic
1706 //
1707 if (action == DeRezAction.Delete)
1708 {
1709 // Deleting someone else's item
1710 //
1711
1712
1713 if (remoteClient == null ||
1714 objectGroup.OwnerID != remoteClient.AgentId)
1715 {
1716 // Folder skeleton may not be loaded and we
1717 // have to wait for the inventory to find
1718 // the destination folder
1719 //
1720 folder = InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder);
1721 }
1722 else
1723 {
1724 // Assume inventory skeleton was loaded during login
1725 // and all folders can be found
1726 //
1727 folder = InventoryService.GetFolderForType(userID, AssetType.TrashFolder);
1728 }
1729 }
1730 else if (action == DeRezAction.Return)
1731 {
1732
1733 // Dump to lost + found unconditionally
1734 //
1735 folder = InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder);
1736 }
1737
1738 if (folderID == UUID.Zero && folder == null)
1739 {
1740 if (action == DeRezAction.Delete)
1741 {
1742 // Deletes go to trash by default
1743 //
1744 folder = InventoryService.GetFolderForType(userID, AssetType.TrashFolder);
1745 }
1746 else
1747 {
1748 // Catch all. Use lost & found
1749 //
1750
1751 folder = InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder);
1752 }
1753 }
1754
1755 if (folder == null) // None of the above
1756 {
1757 //folder = userInfo.RootFolder.FindFolder(folderID);
1758 folder = new InventoryFolderBase(folderID);
1759
1760 if (folder == null) // Nowhere to put it
1761 {
1762 return UUID.Zero;
1763 }
1764 }
1765
1766 item = new InventoryItemBase();
1767 item.CreatorId = objectGroup.RootPart.CreatorID.ToString();
1768 item.ID = UUID.Random();
1769 item.InvType = (int)InventoryType.Object;
1770 item.Folder = folder.ID;
1771 item.Owner = userID;
1772 }
1773
1774 AssetBase asset = CreateAsset(
1775 objectGroup.GetPartName(objectGroup.RootPart.LocalId),
1776 objectGroup.GetPartDescription(objectGroup.RootPart.LocalId),
1777 (sbyte)AssetType.Object,
1778 Utils.StringToBytes(sceneObjectXml));
1779 AssetService.Store(asset);
1780 assetID = asset.FullID;
1781
1782 if (DeRezAction.SaveToExistingUserInventoryItem == action)
1783 {
1784 item.AssetID = asset.FullID;
1785 InventoryService.UpdateItem(item);
1786 }
1787 else
1788 {
1789 item.AssetID = asset.FullID;
1790
1791 if (remoteClient != null && (remoteClient.AgentId != objectGroup.RootPart.OwnerID) && Permissions.PropagatePermissions())
1792 {
1793 uint perms=objectGroup.GetEffectivePermissions();
1794 uint nextPerms=(perms & 7) << 13;
1795 if ((nextPerms & (uint)PermissionMask.Copy) == 0)
1796 perms &= ~(uint)PermissionMask.Copy;
1797 if ((nextPerms & (uint)PermissionMask.Transfer) == 0)
1798 perms &= ~(uint)PermissionMask.Transfer;
1799 if ((nextPerms & (uint)PermissionMask.Modify) == 0)
1800 perms &= ~(uint)PermissionMask.Modify;
1801
1802 item.BasePermissions = perms & objectGroup.RootPart.NextOwnerMask;
1803 item.CurrentPermissions = item.BasePermissions;
1804 item.NextPermissions = objectGroup.RootPart.NextOwnerMask;
1805 item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask & objectGroup.RootPart.NextOwnerMask;
1806 item.GroupPermissions = objectGroup.RootPart.GroupMask & objectGroup.RootPart.NextOwnerMask;
1807 item.CurrentPermissions |= 8; // Slam!
1808 }
1809 else
1810 {
1811 uint ownerPerms = objectGroup.GetEffectivePermissions();
1812 if ((objectGroup.RootPart.OwnerMask & (uint)PermissionMask.Modify) != 0)
1813 ownerPerms |= (uint)PermissionMask.Modify;
1814
1815 item.BasePermissions = ownerPerms;
1816 item.CurrentPermissions = ownerPerms;
1817
1818 item.NextPermissions = objectGroup.RootPart.NextOwnerMask;
1819 item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask;
1820 item.GroupPermissions = objectGroup.RootPart.GroupMask;
1821
1822 item.CurrentPermissions |= 8; // Slam!
1823 }
1824
1825 // TODO: add the new fields (Flags, Sale info, etc)
1826 item.CreationDate = Util.UnixTimeSinceEpoch();
1827 item.Description = asset.Description;
1828 item.Name = asset.Name;
1829 item.AssetType = asset.Type;
1830
1831 InventoryService.AddItem(item);
1832
1833 if (remoteClient != null && item.Owner == remoteClient.AgentId)
1834 {
1835 remoteClient.SendInventoryItemCreateUpdate(item, 0);
1836 }
1837 else
1838 {
1839 ScenePresence notifyUser = GetScenePresence(item.Owner);
1840 if (notifyUser != null)
1841 {
1842 notifyUser.ControllingClient.SendInventoryItemCreateUpdate(item, 0);
1843 }
1844 }
1845 }
1846
1847 return assetID;
1848 }
1849
1850 public void UpdateKnownItem(IClientAPI remoteClient, SceneObjectGroup grp, UUID itemID, UUID agentID) 1560 public void UpdateKnownItem(IClientAPI remoteClient, SceneObjectGroup grp, UUID itemID, UUID agentID)
1851 { 1561 {
1852 SceneObjectGroup objectGroup = grp; 1562 SceneObjectGroup objectGroup = grp;
@@ -1873,7 +1583,8 @@ namespace OpenSim.Region.Framework.Scenes
1873 objectGroup.GetPartName(objectGroup.LocalId), 1583 objectGroup.GetPartName(objectGroup.LocalId),
1874 objectGroup.GetPartDescription(objectGroup.LocalId), 1584 objectGroup.GetPartDescription(objectGroup.LocalId),
1875 (sbyte)AssetType.Object, 1585 (sbyte)AssetType.Object,
1876 Utils.StringToBytes(sceneObjectXml)); 1586 Utils.StringToBytes(sceneObjectXml),
1587 remoteClient.AgentId);
1877 AssetService.Store(asset); 1588 AssetService.Store(asset);
1878 1589
1879 item.AssetID = asset.FullID; 1590 item.AssetID = asset.FullID;
@@ -1920,7 +1631,8 @@ namespace OpenSim.Region.Framework.Scenes
1920 grp.GetPartName(grp.LocalId), 1631 grp.GetPartName(grp.LocalId),
1921 grp.GetPartDescription(grp.LocalId), 1632 grp.GetPartDescription(grp.LocalId),
1922 (sbyte)AssetType.Object, 1633 (sbyte)AssetType.Object,
1923 Utils.StringToBytes(sceneObjectXml)); 1634 Utils.StringToBytes(sceneObjectXml),
1635 remoteClient.AgentId);
1924 AssetService.Store(asset); 1636 AssetService.Store(asset);
1925 1637
1926 InventoryItemBase item = new InventoryItemBase(); 1638 InventoryItemBase item = new InventoryItemBase();
@@ -1987,225 +1699,11 @@ namespace OpenSim.Region.Framework.Scenes
1987 UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection, 1699 UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection,
1988 bool RezSelected, bool RemoveItem, UUID fromTaskID) 1700 bool RezSelected, bool RemoveItem, UUID fromTaskID)
1989 { 1701 {
1990 RezObject( 1702 IInventoryAccessModule invAccess = RequestModuleInterface<IInventoryAccessModule>();
1991 remoteClient, itemID, RayEnd, RayStart, RayTargetID, BypassRayCast, RayEndIsIntersection, 1703 if (invAccess != null)
1992 RezSelected, RemoveItem, fromTaskID, false); 1704 invAccess.RezObject(
1993 } 1705 remoteClient, itemID, RayEnd, RayStart, RayTargetID, BypassRayCast, RayEndIsIntersection,
1994 1706 RezSelected, RemoveItem, fromTaskID, false);
1995 /// <summary>
1996 /// Rez an object into the scene from the user's inventory
1997 /// </summary>
1998 /// <param name="remoteClient"></param>
1999 /// <param name="itemID"></param>
2000 /// <param name="RayEnd"></param>
2001 /// <param name="RayStart"></param>
2002 /// <param name="RayTargetID"></param>
2003 /// <param name="BypassRayCast"></param>
2004 /// <param name="RayEndIsIntersection"></param>
2005 /// <param name="RezSelected"></param>
2006 /// <param name="RemoveItem"></param>
2007 /// <param name="fromTaskID"></param>
2008 /// <param name="attachment"></param>
2009 /// <returns>The SceneObjectGroup rezzed or null if rez was unsuccessful.</returns>
2010 public virtual SceneObjectGroup RezObject(IClientAPI remoteClient, UUID itemID, Vector3 RayEnd, Vector3 RayStart,
2011 UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection,
2012 bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment)
2013 {
2014 // Work out position details
2015 byte bRayEndIsIntersection = (byte)0;
2016
2017 if (RayEndIsIntersection)
2018 {
2019 bRayEndIsIntersection = (byte)1;
2020 }
2021 else
2022 {
2023 bRayEndIsIntersection = (byte)0;
2024 }
2025
2026 Vector3 scale = new Vector3(0.5f, 0.5f, 0.5f);
2027
2028
2029 Vector3 pos = GetNewRezLocation(
2030 RayStart, RayEnd, RayTargetID, Quaternion.Identity,
2031 BypassRayCast, bRayEndIsIntersection,true,scale, false);
2032
2033 // Rez object
2034 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
2035 item = InventoryService.GetItem(item);
2036
2037 if (item != null)
2038 {
2039 AssetBase rezAsset = AssetService.Get(item.AssetID.ToString());
2040
2041 if (rezAsset != null)
2042 {
2043 UUID itemId = UUID.Zero;
2044
2045 // If we have permission to copy then link the rezzed object back to the user inventory
2046 // item that it came from. This allows us to enable 'save object to inventory'
2047 if (!Permissions.BypassPermissions())
2048 {
2049 if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == (uint)PermissionMask.Copy)
2050 {
2051 itemId = item.ID;
2052 }
2053 }
2054 else
2055 {
2056 // Brave new fullperm world
2057 //
2058 itemId = item.ID;
2059 }
2060
2061 string xmlData = Utils.BytesToString(rezAsset.Data);
2062 SceneObjectGroup group
2063 = SceneObjectSerializer.FromOriginalXmlFormat(itemId, xmlData);
2064
2065 if (!Permissions.CanRezObject(
2066 group.Children.Count, remoteClient.AgentId, pos)
2067 && !attachment)
2068 {
2069 // The client operates in no fail mode. It will
2070 // have already removed the item from the folder
2071 // if it's no copy.
2072 // Put it back if it's not an attachment
2073 //
2074 if (((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) && (!attachment))
2075 remoteClient.SendBulkUpdateInventory(item);
2076 return null;
2077 }
2078
2079 group.ResetIDs();
2080
2081 if (attachment)
2082 {
2083 group.RootPart.ObjectFlags |= (uint)PrimFlags.Phantom;
2084 group.RootPart.IsAttachment = true;
2085 }
2086
2087 AddNewSceneObject(group, true);
2088
2089 // m_log.InfoFormat("ray end point for inventory rezz is {0} {1} {2} ", RayEnd.X, RayEnd.Y, RayEnd.Z);
2090 // if attachment we set it's asset id so object updates can reflect that
2091 // if not, we set it's position in world.
2092 if (!attachment)
2093 {
2094 float offsetHeight = 0;
2095 pos = GetNewRezLocation(
2096 RayStart, RayEnd, RayTargetID, Quaternion.Identity,
2097 BypassRayCast, bRayEndIsIntersection, true, group.GetAxisAlignedBoundingBox(out offsetHeight), false);
2098 pos.Z += offsetHeight;
2099 group.AbsolutePosition = pos;
2100 // m_log.InfoFormat("rezx point for inventory rezz is {0} {1} {2} and offsetheight was {3}", pos.X, pos.Y, pos.Z, offsetHeight);
2101
2102 }
2103 else
2104 {
2105 group.SetFromItemID(itemID);
2106 }
2107
2108 SceneObjectPart rootPart = null;
2109 try
2110 {
2111 rootPart = group.GetChildPart(group.UUID);
2112 }
2113 catch (NullReferenceException)
2114 {
2115 string isAttachment = "";
2116
2117 if (attachment)
2118 isAttachment = " Object was an attachment";
2119
2120 m_log.Error("[AGENT INVENTORY]: Error rezzing ItemID: " + itemID + " object has no rootpart." + isAttachment);
2121 }
2122
2123 // Since renaming the item in the inventory does not affect the name stored
2124 // in the serialization, transfer the correct name from the inventory to the
2125 // object itself before we rez.
2126 rootPart.Name = item.Name;
2127 rootPart.Description = item.Description;
2128
2129 List<SceneObjectPart> partList = new List<SceneObjectPart>(group.Children.Values);
2130
2131 group.SetGroup(remoteClient.ActiveGroupId, remoteClient);
2132 if (rootPart.OwnerID != item.Owner)
2133 {
2134 //Need to kill the for sale here
2135 rootPart.ObjectSaleType = 0;
2136 rootPart.SalePrice = 10;
2137
2138 if (Permissions.PropagatePermissions())
2139 {
2140 if ((item.CurrentPermissions & 8) != 0)
2141 {
2142 foreach (SceneObjectPart part in partList)
2143 {
2144 part.EveryoneMask = item.EveryOnePermissions;
2145 part.NextOwnerMask = item.NextPermissions;
2146 part.GroupMask = 0; // DO NOT propagate here
2147 }
2148 }
2149 group.ApplyNextOwnerPermissions();
2150 }
2151 }
2152
2153 foreach (SceneObjectPart part in partList)
2154 {
2155 if (part.OwnerID != item.Owner)
2156 {
2157 part.LastOwnerID = part.OwnerID;
2158 part.OwnerID = item.Owner;
2159 part.Inventory.ChangeInventoryOwner(item.Owner);
2160 }
2161 else if (((item.CurrentPermissions & 8) != 0) && (!attachment)) // Slam!
2162 {
2163 part.EveryoneMask = item.EveryOnePermissions;
2164 part.NextOwnerMask = item.NextPermissions;
2165
2166 part.GroupMask = 0; // DO NOT propagate here
2167 }
2168 }
2169
2170 rootPart.TrimPermissions();
2171
2172 if (!attachment)
2173 {
2174 if (group.RootPart.Shape.PCode == (byte)PCode.Prim)
2175 {
2176 group.ClearPartAttachmentData();
2177 }
2178 }
2179
2180 if (!attachment)
2181 {
2182 // Fire on_rez
2183 group.CreateScriptInstances(0, true, DefaultScriptEngine, 0);
2184
2185 rootPart.ScheduleFullUpdate();
2186 }
2187
2188 if (!Permissions.BypassPermissions())
2189 {
2190 if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0)
2191 {
2192 // If this is done on attachments, no
2193 // copy ones will be lost, so avoid it
2194 //
2195 if (!attachment)
2196 {
2197 List<UUID> uuids = new List<UUID>();
2198 uuids.Add(item.ID);
2199 InventoryService.DeleteItems(item.Owner, uuids);
2200 }
2201 }
2202 }
2203
2204 return rootPart.ParentGroup;
2205 }
2206 }
2207
2208 return null;
2209 } 1707 }
2210 1708
2211 /// <summary> 1709 /// <summary>
@@ -2348,122 +1846,12 @@ namespace OpenSim.Region.Framework.Scenes
2348 EventManager.TriggerOnAttach(localID, itemID, avatarID); 1846 EventManager.TriggerOnAttach(localID, itemID, avatarID);
2349 } 1847 }
2350 1848
2351 /// <summary>
2352 /// Called when the client receives a request to rez a single attachment on to the avatar from inventory
2353 /// (RezSingleAttachmentFromInv packet).
2354 /// </summary>
2355 /// <param name="remoteClient"></param>
2356 /// <param name="itemID"></param>
2357 /// <param name="AttachmentPt"></param>
2358 /// <returns></returns>
2359 public UUID RezSingleAttachment(IClientAPI remoteClient, UUID itemID, uint AttachmentPt)
2360 {
2361 m_log.DebugFormat("[USER INVENTORY]: Rezzing single attachment from item {0} for {1}", itemID, remoteClient.Name);
2362
2363 SceneObjectGroup att = m_sceneGraph.RezSingleAttachment(remoteClient, itemID, AttachmentPt);
2364
2365 if (att == null)
2366 {
2367 DetachSingleAttachmentToInv(itemID, remoteClient);
2368 return UUID.Zero;
2369 }
2370
2371 return RezSingleAttachment(att, remoteClient, itemID, AttachmentPt);
2372 }
2373
2374 /// <summary>
2375 /// Update the user inventory to reflect an attachment
2376 /// </summary>
2377 /// <param name="att"></param>
2378 /// <param name="remoteClient"></param>
2379 /// <param name="itemID"></param>
2380 /// <param name="AttachmentPt"></param>
2381 /// <returns></returns>
2382 public UUID RezSingleAttachment(SceneObjectGroup att, IClientAPI remoteClient, UUID itemID, uint AttachmentPt)
2383 {
2384 m_log.DebugFormat(
2385 "[USER INVENTORY]: Updating inventory of {0} to show attachment of {1} (item ID {2})",
2386 remoteClient.Name, att.Name, itemID);
2387
2388 if (!att.IsDeleted)
2389 AttachmentPt = att.RootPart.AttachmentPoint;
2390
2391 ScenePresence presence;
2392 if (TryGetAvatar(remoteClient.AgentId, out presence))
2393 {
2394 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
2395 item = InventoryService.GetItem(item);
2396
2397 presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID /*att.UUID*/);
2398 }
2399 return att.UUID;
2400 }
2401
2402 public void RezMultipleAttachments(IClientAPI remoteClient, RezMultipleAttachmentsFromInvPacket.HeaderDataBlock header, 1849 public void RezMultipleAttachments(IClientAPI remoteClient, RezMultipleAttachmentsFromInvPacket.HeaderDataBlock header,
2403 RezMultipleAttachmentsFromInvPacket.ObjectDataBlock[] objects) 1850 RezMultipleAttachmentsFromInvPacket.ObjectDataBlock[] objects)
2404 { 1851 {
2405 foreach (RezMultipleAttachmentsFromInvPacket.ObjectDataBlock obj in objects) 1852 foreach (RezMultipleAttachmentsFromInvPacket.ObjectDataBlock obj in objects)
2406 { 1853 {
2407 RezSingleAttachment(remoteClient, obj.ItemID, obj.AttachmentPt); 1854 AttachmentsModule.RezSingleAttachmentFromInventory(remoteClient, obj.ItemID, obj.AttachmentPt);
2408 }
2409 }
2410
2411 /// <summary>
2412 /// Attach an object.
2413 /// </summary>
2414 /// <param name="controllingClient"></param>
2415 /// <param name="localID"></param>
2416 /// <param name="attachPoint"></param>
2417 /// <param name="rot"></param>
2418 /// <param name="pos"></param>
2419 /// <param name="silent"></param>
2420 /// <returns>true if the object was successfully attached, false otherwise</returns>
2421 public bool AttachObject(IClientAPI controllingClient, uint localID, uint attachPoint, Quaternion rot, Vector3 pos, bool silent)
2422 {
2423 return m_sceneGraph.AttachObject(controllingClient, localID, attachPoint, rot, pos, silent);
2424 }
2425
2426 /// <summary>
2427 /// This registers the item as attached in a user's inventory
2428 /// </summary>
2429 /// <param name="remoteClient"></param>
2430 /// <param name="AttachmentPt"></param>
2431 /// <param name="itemID"></param>
2432 /// <param name="att"></param>
2433 public void AttachObject(IClientAPI remoteClient, uint AttachmentPt, UUID itemID, SceneObjectGroup att)
2434 {
2435// m_log.DebugFormat(
2436// "[USER INVENTORY]: Updating attachment {0} for {1} at {2} using item ID {3}",
2437// att.Name, remoteClient.Name, AttachmentPt, itemID);
2438
2439 if (UUID.Zero == itemID)
2440 {
2441 m_log.Error("[SCENE INVENTORY]: Unable to save attachment. Error inventory item ID.");
2442 return;
2443 }
2444
2445 if (0 == AttachmentPt)
2446 {
2447 m_log.Error("[SCENE INVENTORY]: Unable to save attachment. Error attachment point.");
2448 return;
2449 }
2450
2451 if (null == att.RootPart)
2452 {
2453 m_log.Error("[SCENE INVENTORY]: Unable to save attachment for a prim without the rootpart!");
2454 return;
2455 }
2456
2457 ScenePresence presence;
2458 if (TryGetAvatar(remoteClient.AgentId, out presence))
2459 {
2460 // XXYY!!
2461 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
2462 item = InventoryService.GetItem(item);
2463 presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID /*att.UUID*/);
2464
2465 if (m_AvatarFactory != null)
2466 m_AvatarFactory.UpdateDatabase(remoteClient.AgentId, presence.Appearance);
2467 } 1855 }
2468 } 1856 }
2469 1857
@@ -2476,7 +1864,7 @@ namespace OpenSim.Region.Framework.Scenes
2476 UUID inventoryID = part.ParentGroup.GetFromItemID(); 1864 UUID inventoryID = part.ParentGroup.GetFromItemID();
2477 1865
2478 ScenePresence presence; 1866 ScenePresence presence;
2479 if (TryGetAvatar(remoteClient.AgentId, out presence)) 1867 if (TryGetScenePresence(remoteClient.AgentId, out presence))
2480 { 1868 {
2481 if (!Permissions.CanRezObject(part.ParentGroup.Children.Count, remoteClient.AgentId, presence.AbsolutePosition)) 1869 if (!Permissions.CanRezObject(part.ParentGroup.Children.Count, remoteClient.AgentId, presence.AbsolutePosition))
2482 return; 1870 return;
@@ -2497,24 +1885,6 @@ namespace OpenSim.Region.Framework.Scenes
2497 SendAttachEvent(part.ParentGroup.LocalId, itemID, UUID.Zero); 1885 SendAttachEvent(part.ParentGroup.LocalId, itemID, UUID.Zero);
2498 } 1886 }
2499 1887
2500 public void DetachSingleAttachmentToInv(UUID itemID, IClientAPI remoteClient)
2501 {
2502 ScenePresence presence;
2503 if (TryGetAvatar(remoteClient.AgentId, out presence))
2504 {
2505 presence.Appearance.DetachAttachment(itemID);
2506
2507 // Save avatar attachment information
2508 if (m_AvatarFactory != null)
2509 {
2510 m_log.Info("[SCENE]: Saving avatar attachment. AgentID: " + remoteClient.AgentId + ", ItemID: " + itemID);
2511 m_AvatarFactory.UpdateDatabase(remoteClient.AgentId, presence.Appearance);
2512 }
2513 }
2514
2515 m_sceneGraph.DetachSingleAttachmentToInv(itemID, remoteClient);
2516 }
2517
2518 public void GetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID) 1888 public void GetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID)
2519 { 1889 {
2520 EventManager.TriggerGetScriptRunning(controllingClient, objectID, itemID); 1890 EventManager.TriggerGetScriptRunning(controllingClient, objectID, itemID);
diff --git a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
index ac04dc7..bc10230 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
@@ -32,7 +32,7 @@ using OpenMetaverse;
32using OpenMetaverse.Packets; 32using OpenMetaverse.Packets;
33using OpenSim.Framework; 33using OpenSim.Framework;
34using OpenSim.Framework.Communications; 34using OpenSim.Framework.Communications;
35using OpenSim.Framework.Communications.Cache; 35using OpenSim.Services.Interfaces;
36 36
37namespace OpenSim.Region.Framework.Scenes 37namespace OpenSim.Region.Framework.Scenes
38{ 38{
@@ -371,14 +371,16 @@ namespace OpenSim.Region.Framework.Scenes
371 { 371 {
372 //EventManager.TriggerAvatarPickerRequest(); 372 //EventManager.TriggerAvatarPickerRequest();
373 373
374 List<AvatarPickerAvatar> AvatarResponses = new List<AvatarPickerAvatar>(); 374 List<UserAccount> accounts = UserAccountService.GetUserAccounts(RegionInfo.ScopeID, query);
375 AvatarResponses = m_sceneGridService.GenerateAgentPickerRequestResponse(RequestID, query); 375
376 if (accounts == null)
377 return;
376 378
377 AvatarPickerReplyPacket replyPacket = (AvatarPickerReplyPacket) PacketPool.Instance.GetPacket(PacketType.AvatarPickerReply); 379 AvatarPickerReplyPacket replyPacket = (AvatarPickerReplyPacket) PacketPool.Instance.GetPacket(PacketType.AvatarPickerReply);
378 // TODO: don't create new blocks if recycling an old packet 380 // TODO: don't create new blocks if recycling an old packet
379 381
380 AvatarPickerReplyPacket.DataBlock[] searchData = 382 AvatarPickerReplyPacket.DataBlock[] searchData =
381 new AvatarPickerReplyPacket.DataBlock[AvatarResponses.Count]; 383 new AvatarPickerReplyPacket.DataBlock[accounts.Count];
382 AvatarPickerReplyPacket.AgentDataBlock agentData = new AvatarPickerReplyPacket.AgentDataBlock(); 384 AvatarPickerReplyPacket.AgentDataBlock agentData = new AvatarPickerReplyPacket.AgentDataBlock();
383 385
384 agentData.AgentID = avatarID; 386 agentData.AgentID = avatarID;
@@ -387,16 +389,16 @@ namespace OpenSim.Region.Framework.Scenes
387 //byte[] bytes = new byte[AvatarResponses.Count*32]; 389 //byte[] bytes = new byte[AvatarResponses.Count*32];
388 390
389 int i = 0; 391 int i = 0;
390 foreach (AvatarPickerAvatar item in AvatarResponses) 392 foreach (UserAccount item in accounts)
391 { 393 {
392 UUID translatedIDtem = item.AvatarID; 394 UUID translatedIDtem = item.PrincipalID;
393 searchData[i] = new AvatarPickerReplyPacket.DataBlock(); 395 searchData[i] = new AvatarPickerReplyPacket.DataBlock();
394 searchData[i].AvatarID = translatedIDtem; 396 searchData[i].AvatarID = translatedIDtem;
395 searchData[i].FirstName = Utils.StringToBytes((string) item.firstName); 397 searchData[i].FirstName = Utils.StringToBytes((string) item.FirstName);
396 searchData[i].LastName = Utils.StringToBytes((string) item.lastName); 398 searchData[i].LastName = Utils.StringToBytes((string) item.LastName);
397 i++; 399 i++;
398 } 400 }
399 if (AvatarResponses.Count == 0) 401 if (accounts.Count == 0)
400 { 402 {
401 searchData = new AvatarPickerReplyPacket.DataBlock[0]; 403 searchData = new AvatarPickerReplyPacket.DataBlock[0];
402 } 404 }
@@ -455,7 +457,24 @@ namespace OpenSim.Region.Framework.Scenes
455 } 457 }
456 ); 458 );
457 } 459 }
458 460
461 public void HandleUUIDNameRequest(UUID uuid, IClientAPI remote_client)
462 {
463 if (LibraryService != null && (LibraryService.LibraryRootFolder.Owner == uuid))
464 {
465 remote_client.SendNameReply(uuid, "Mr", "OpenSim");
466 }
467 else
468 {
469 string[] names = GetUserNames(uuid);
470 if (names.Length == 2)
471 {
472 remote_client.SendNameReply(uuid, names[0], names[1]);
473 }
474
475 }
476 }
477
459 /// <summary> 478 /// <summary>
460 /// Handle a fetch inventory request from the client 479 /// Handle a fetch inventory request from the client
461 /// </summary> 480 /// </summary>
@@ -464,7 +483,7 @@ namespace OpenSim.Region.Framework.Scenes
464 /// <param name="ownerID"></param> 483 /// <param name="ownerID"></param>
465 public void HandleFetchInventory(IClientAPI remoteClient, UUID itemID, UUID ownerID) 484 public void HandleFetchInventory(IClientAPI remoteClient, UUID itemID, UUID ownerID)
466 { 485 {
467 if (ownerID == CommsManager.UserProfileCacheService.LibraryRoot.Owner) 486 if (LibraryService != null && LibraryService.LibraryRootFolder != null && ownerID == LibraryService.LibraryRootFolder.Owner)
468 { 487 {
469 //m_log.Debug("request info for library item"); 488 //m_log.Debug("request info for library item");
470 return; 489 return;
@@ -498,13 +517,14 @@ namespace OpenSim.Region.Framework.Scenes
498 // CachedUserInfo so that this class doesn't have to know the details (and so that multiple libraries, etc. 517 // CachedUserInfo so that this class doesn't have to know the details (and so that multiple libraries, etc.
499 // can be handled transparently). 518 // can be handled transparently).
500 InventoryFolderImpl fold = null; 519 InventoryFolderImpl fold = null;
501 if ((fold = CommsManager.UserProfileCacheService.LibraryRoot.FindFolder(folderID)) != null) 520 if (LibraryService != null && LibraryService.LibraryRootFolder != null)
502 { 521 if ((fold = LibraryService.LibraryRootFolder.FindFolder(folderID)) != null)
503 remoteClient.SendInventoryFolderDetails( 522 {
504 fold.Owner, folderID, fold.RequestListOfItems(), 523 remoteClient.SendInventoryFolderDetails(
505 fold.RequestListOfFolders(), fold.Version, fetchFolders, fetchItems); 524 fold.Owner, folderID, fold.RequestListOfItems(),
506 return; 525 fold.RequestListOfFolders(), fold.Version, fetchFolders, fetchItems);
507 } 526 return;
527 }
508 528
509 // We're going to send the reply async, because there may be 529 // We're going to send the reply async, because there may be
510 // an enormous quantity of packets -- basically the entire inventory! 530 // an enormous quantity of packets -- basically the entire inventory!
@@ -552,15 +572,16 @@ namespace OpenSim.Region.Framework.Scenes
552 // CachedUserInfo so that this class doesn't have to know the details (and so that multiple libraries, etc. 572 // CachedUserInfo so that this class doesn't have to know the details (and so that multiple libraries, etc.
553 // can be handled transparently). 573 // can be handled transparently).
554 InventoryFolderImpl fold; 574 InventoryFolderImpl fold;
555 if ((fold = CommsManager.UserProfileCacheService.LibraryRoot.FindFolder(folderID)) != null) 575 if (LibraryService != null && LibraryService.LibraryRootFolder != null)
556 { 576 if ((fold = LibraryService.LibraryRootFolder.FindFolder(folderID)) != null)
557 version = 0; 577 {
558 InventoryCollection ret = new InventoryCollection(); 578 version = 0;
559 ret.Folders = new List<InventoryFolderBase>(); 579 InventoryCollection ret = new InventoryCollection();
560 ret.Items = fold.RequestListOfItems(); 580 ret.Folders = new List<InventoryFolderBase>();
581 ret.Items = fold.RequestListOfItems();
561 582
562 return ret; 583 return ret;
563 } 584 }
564 585
565 InventoryCollection contents = new InventoryCollection(); 586 InventoryCollection contents = new InventoryCollection();
566 587
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index db073e8..671f8fc 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -27,6 +27,7 @@
27 27
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Diagnostics;
30using System.Drawing; 31using System.Drawing;
31using System.Drawing.Imaging; 32using System.Drawing.Imaging;
32using System.IO; 33using System.IO;
@@ -41,8 +42,7 @@ using OpenMetaverse.Imaging;
41using OpenSim.Framework; 42using OpenSim.Framework;
42using OpenSim.Services.Interfaces; 43using OpenSim.Services.Interfaces;
43using OpenSim.Framework.Communications; 44using OpenSim.Framework.Communications;
44using OpenSim.Framework.Communications.Cache; 45
45using OpenSim.Framework.Communications.Clients;
46using OpenSim.Framework.Console; 46using OpenSim.Framework.Console;
47using OpenSim.Region.Framework.Interfaces; 47using OpenSim.Region.Framework.Interfaces;
48using OpenSim.Region.Framework.Scenes.Scripting; 48using OpenSim.Region.Framework.Scenes.Scripting;
@@ -131,7 +131,6 @@ namespace OpenSim.Region.Framework.Scenes
131 private readonly Timer m_restartTimer = new Timer(15000); // Wait before firing 131 private readonly Timer m_restartTimer = new Timer(15000); // Wait before firing
132 private int m_incrementsof15seconds; 132 private int m_incrementsof15seconds;
133 private volatile bool m_backingup; 133 private volatile bool m_backingup;
134 private bool m_useAsyncWhenPossible;
135 134
136 private Dictionary<UUID, ReturnInfo> m_returns = new Dictionary<UUID, ReturnInfo>(); 135 private Dictionary<UUID, ReturnInfo> m_returns = new Dictionary<UUID, ReturnInfo>();
137 private Dictionary<UUID, SceneObjectGroup> m_groupsWithTargets = new Dictionary<UUID, SceneObjectGroup>(); 136 private Dictionary<UUID, SceneObjectGroup> m_groupsWithTargets = new Dictionary<UUID, SceneObjectGroup>();
@@ -141,7 +140,6 @@ namespace OpenSim.Region.Framework.Scenes
141 protected ModuleLoader m_moduleLoader; 140 protected ModuleLoader m_moduleLoader;
142 protected StorageManager m_storageManager; 141 protected StorageManager m_storageManager;
143 protected AgentCircuitManager m_authenticateHandler; 142 protected AgentCircuitManager m_authenticateHandler;
144 public CommunicationsManager CommsManager;
145 143
146 protected SceneCommunicationService m_sceneGridService; 144 protected SceneCommunicationService m_sceneGridService;
147 public bool LoginsDisabled = true; 145 public bool LoginsDisabled = true;
@@ -203,11 +201,11 @@ namespace OpenSim.Region.Framework.Scenes
203 { 201 {
204 m_AuthorizationService = RequestModuleInterface<IAuthorizationService>(); 202 m_AuthorizationService = RequestModuleInterface<IAuthorizationService>();
205 203
206 if (m_AuthorizationService == null) 204 //if (m_AuthorizationService == null)
207 { 205 //{
208 // don't throw an exception if no authorization service is set for the time being 206 // // don't throw an exception if no authorization service is set for the time being
209 m_log.InfoFormat("[SCENE]: No Authorization service is configured"); 207 // m_log.InfoFormat("[SCENE]: No Authorization service is configured");
210 } 208 //}
211 } 209 }
212 210
213 return m_AuthorizationService; 211 return m_AuthorizationService;
@@ -254,8 +252,76 @@ namespace OpenSim.Region.Framework.Scenes
254 } 252 }
255 } 253 }
256 254
255 protected ILibraryService m_LibraryService;
256
257 public ILibraryService LibraryService
258 {
259 get
260 {
261 if (m_LibraryService == null)
262 m_LibraryService = RequestModuleInterface<ILibraryService>();
263
264 return m_LibraryService;
265 }
266 }
267
268 protected ISimulationService m_simulationService;
269 public ISimulationService SimulationService
270 {
271 get
272 {
273 if (m_simulationService == null)
274 m_simulationService = RequestModuleInterface<ISimulationService>();
275 return m_simulationService;
276 }
277 }
278
279 protected IAuthenticationService m_AuthenticationService;
280 public IAuthenticationService AuthenticationService
281 {
282 get
283 {
284 if (m_AuthenticationService == null)
285 m_AuthenticationService = RequestModuleInterface<IAuthenticationService>();
286 return m_AuthenticationService;
287 }
288 }
289
290 protected IPresenceService m_PresenceService;
291 public IPresenceService PresenceService
292 {
293 get
294 {
295 if (m_PresenceService == null)
296 m_PresenceService = RequestModuleInterface<IPresenceService>();
297 return m_PresenceService;
298 }
299 }
300 protected IUserAccountService m_UserAccountService;
301 public IUserAccountService UserAccountService
302 {
303 get
304 {
305 if (m_UserAccountService == null)
306 m_UserAccountService = RequestModuleInterface<IUserAccountService>();
307 return m_UserAccountService;
308 }
309 }
310
311 protected OpenSim.Services.Interfaces.IAvatarService m_AvatarService;
312 public OpenSim.Services.Interfaces.IAvatarService AvatarService
313 {
314 get
315 {
316 if (m_AvatarService == null)
317 m_AvatarService = RequestModuleInterface<IAvatarService>();
318 return m_AvatarService;
319 }
320 }
321
257 protected IXMLRPC m_xmlrpcModule; 322 protected IXMLRPC m_xmlrpcModule;
258 protected IWorldComm m_worldCommModule; 323 protected IWorldComm m_worldCommModule;
324 public IAttachmentsModule AttachmentsModule { get; set; }
259 protected IAvatarFactory m_AvatarFactory; 325 protected IAvatarFactory m_AvatarFactory;
260 public IAvatarFactory AvatarFactory 326 public IAvatarFactory AvatarFactory
261 { 327 {
@@ -263,10 +329,8 @@ namespace OpenSim.Region.Framework.Scenes
263 } 329 }
264 protected IConfigSource m_config; 330 protected IConfigSource m_config;
265 protected IRegionSerialiserModule m_serialiser; 331 protected IRegionSerialiserModule m_serialiser;
266 protected IInterregionCommsOut m_interregionCommsOut;
267 protected IInterregionCommsIn m_interregionCommsIn;
268 protected IDialogModule m_dialogModule; 332 protected IDialogModule m_dialogModule;
269 protected ITeleportModule m_teleportModule; 333 protected IEntityTransferModule m_teleportModule;
270 334
271 protected ICapabilitiesModule m_capsModule; 335 protected ICapabilitiesModule m_capsModule;
272 public ICapabilitiesModule CapsModule 336 public ICapabilitiesModule CapsModule
@@ -497,7 +561,7 @@ namespace OpenSim.Region.Framework.Scenes
497 #region Constructors 561 #region Constructors
498 562
499 public Scene(RegionInfo regInfo, AgentCircuitManager authen, 563 public Scene(RegionInfo regInfo, AgentCircuitManager authen,
500 CommunicationsManager commsMan, SceneCommunicationService sceneGridService, 564 SceneCommunicationService sceneGridService,
501 StorageManager storeManager, 565 StorageManager storeManager,
502 ModuleLoader moduleLoader, bool dumpAssetsToFile, bool physicalPrim, 566 ModuleLoader moduleLoader, bool dumpAssetsToFile, bool physicalPrim,
503 bool SeeIntoRegionFromNeighbor, IConfigSource config, string simulatorVersion) 567 bool SeeIntoRegionFromNeighbor, IConfigSource config, string simulatorVersion)
@@ -533,7 +597,6 @@ namespace OpenSim.Region.Framework.Scenes
533 m_lastAllocatedLocalId = (uint)(random.NextDouble() * (double)(uint.MaxValue/2))+(uint)(uint.MaxValue/4); 597 m_lastAllocatedLocalId = (uint)(random.NextDouble() * (double)(uint.MaxValue/2))+(uint)(uint.MaxValue/4);
534 m_moduleLoader = moduleLoader; 598 m_moduleLoader = moduleLoader;
535 m_authenticateHandler = authen; 599 m_authenticateHandler = authen;
536 CommsManager = commsMan;
537 m_sceneGridService = sceneGridService; 600 m_sceneGridService = sceneGridService;
538 m_storageManager = storeManager; 601 m_storageManager = storeManager;
539 m_regInfo = regInfo; 602 m_regInfo = regInfo;
@@ -557,7 +620,46 @@ namespace OpenSim.Region.Framework.Scenes
557 620
558 if (m_storageManager.EstateDataStore != null) 621 if (m_storageManager.EstateDataStore != null)
559 { 622 {
560 m_regInfo.EstateSettings = m_storageManager.EstateDataStore.LoadEstateSettings(m_regInfo.RegionID); 623 m_regInfo.EstateSettings = m_storageManager.EstateDataStore.LoadEstateSettings(m_regInfo.RegionID, false);
624 if (m_regInfo.EstateSettings.EstateID == 0) // No record at all
625 {
626 MainConsole.Instance.Output("Your region is not part of an estate.");
627 while (true)
628 {
629 string response = MainConsole.Instance.CmdPrompt("Do you wish to join an existing estate?", "no", new List<string>() {"yes", "no"});
630 if (response == "no")
631 {
632 // Create a new estate
633 m_regInfo.EstateSettings = m_storageManager.EstateDataStore.LoadEstateSettings(m_regInfo.RegionID, true);
634
635 m_regInfo.EstateSettings.EstateName = MainConsole.Instance.CmdPrompt("New estate name", m_regInfo.EstateSettings.EstateName);
636 m_regInfo.EstateSettings.Save();
637 break;
638 }
639 else
640 {
641 response = MainConsole.Instance.CmdPrompt("Estate name to join", "None");
642 if (response == "None")
643 continue;
644
645 List<int> estateIDs = m_storageManager.EstateDataStore.GetEstates(response);
646 if (estateIDs.Count < 1)
647 {
648 MainConsole.Instance.Output("The name you have entered matches no known estate. Please try again");
649 continue;
650 }
651
652 int estateID = estateIDs[0];
653
654 m_regInfo.EstateSettings = m_storageManager.EstateDataStore.LoadEstateSettings(estateID);
655
656 if (m_storageManager.EstateDataStore.LinkRegion(m_regInfo.RegionID, estateID))
657 break;
658
659 MainConsole.Instance.Output("Joining the estate failed. Please try again.");
660 }
661 }
662 }
561 } 663 }
562 664
563 //Bind Storage Manager functions to some land manager functions for this scene 665 //Bind Storage Manager functions to some land manager functions for this scene
@@ -606,9 +708,6 @@ namespace OpenSim.Region.Framework.Scenes
606 // 708 //
607 IConfig startupConfig = m_config.Configs["Startup"]; 709 IConfig startupConfig = m_config.Configs["Startup"];
608 710
609 // Should we try to run loops synchronously or asynchronously?
610 m_useAsyncWhenPossible = startupConfig.GetBoolean("use_async_when_possible", false);
611
612 //Animation states 711 //Animation states
613 m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); 712 m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false);
614 // TODO: Change default to true once the feature is supported 713 // TODO: Change default to true once the feature is supported
@@ -792,6 +891,36 @@ namespace OpenSim.Region.Framework.Scenes
792 return m_simulatorVersion; 891 return m_simulatorVersion;
793 } 892 }
794 893
894 public string[] GetUserNames(UUID uuid)
895 {
896 string[] returnstring = new string[0];
897
898 UserAccount account = UserAccountService.GetUserAccount(RegionInfo.ScopeID, uuid);
899
900 if (account != null)
901 {
902 returnstring = new string[2];
903 returnstring[0] = account.FirstName;
904 returnstring[1] = account.LastName;
905 }
906
907 return returnstring;
908 }
909
910 public string GetUserName(UUID uuid)
911 {
912 string[] names = GetUserNames(uuid);
913 if (names.Length == 2)
914 {
915 string firstname = names[0];
916 string lastname = names[1];
917
918 return firstname + " " + lastname;
919
920 }
921 return "(hippos)";
922 }
923
795 /// <summary> 924 /// <summary>
796 /// Another region is up. 925 /// Another region is up.
797 /// 926 ///
@@ -825,7 +954,7 @@ namespace OpenSim.Region.Framework.Scenes
825 regInfo.RegionName = otherRegion.RegionName; 954 regInfo.RegionName = otherRegion.RegionName;
826 regInfo.ScopeID = otherRegion.ScopeID; 955 regInfo.ScopeID = otherRegion.ScopeID;
827 regInfo.ExternalHostName = otherRegion.ExternalHostName; 956 regInfo.ExternalHostName = otherRegion.ExternalHostName;
828 957 GridRegion r = new GridRegion(regInfo);
829 try 958 try
830 { 959 {
831 ForEachScenePresence(delegate(ScenePresence agent) 960 ForEachScenePresence(delegate(ScenePresence agent)
@@ -839,7 +968,8 @@ namespace OpenSim.Region.Framework.Scenes
839 List<ulong> old = new List<ulong>(); 968 List<ulong> old = new List<ulong>();
840 old.Add(otherRegion.RegionHandle); 969 old.Add(otherRegion.RegionHandle);
841 agent.DropOldNeighbours(old); 970 agent.DropOldNeighbours(old);
842 InformClientOfNeighbor(agent, regInfo); 971 if (m_teleportModule != null)
972 m_teleportModule.EnableChildAgent(agent, r);
843 } 973 }
844 } 974 }
845 ); 975 );
@@ -999,6 +1129,7 @@ namespace OpenSim.Region.Framework.Scenes
999 { 1129 {
1000 foreach (RegionInfo region in m_regionRestartNotifyList) 1130 foreach (RegionInfo region in m_regionRestartNotifyList)
1001 { 1131 {
1132 GridRegion r = new GridRegion(region);
1002 try 1133 try
1003 { 1134 {
1004 ForEachScenePresence(delegate(ScenePresence agent) 1135 ForEachScenePresence(delegate(ScenePresence agent)
@@ -1006,9 +1137,8 @@ namespace OpenSim.Region.Framework.Scenes
1006 // If agent is a root agent. 1137 // If agent is a root agent.
1007 if (!agent.IsChildAgent) 1138 if (!agent.IsChildAgent)
1008 { 1139 {
1009 //agent.ControllingClient.new 1140 if (m_teleportModule != null)
1010 //this.CommsManager.InterRegion.InformRegionOfChildAgent(otherRegion.RegionHandle, agent.ControllingClient.RequestClientInfo()); 1141 m_teleportModule.EnableChildAgent(agent, r);
1011 InformClientOfNeighbor(agent, region);
1012 } 1142 }
1013 } 1143 }
1014 ); 1144 );
@@ -1067,10 +1197,7 @@ namespace OpenSim.Region.Framework.Scenes
1067 1197
1068 public int GetInaccurateNeighborCount() 1198 public int GetInaccurateNeighborCount()
1069 { 1199 {
1070 lock (m_neighbours) 1200 return m_neighbours.Count;
1071 {
1072 return m_neighbours.Count;
1073 }
1074 } 1201 }
1075 1202
1076 // This is the method that shuts down the scene. 1203 // This is the method that shuts down the scene.
@@ -1150,12 +1277,89 @@ namespace OpenSim.Region.Framework.Scenes
1150 m_worldCommModule = RequestModuleInterface<IWorldComm>(); 1277 m_worldCommModule = RequestModuleInterface<IWorldComm>();
1151 XferManager = RequestModuleInterface<IXfer>(); 1278 XferManager = RequestModuleInterface<IXfer>();
1152 m_AvatarFactory = RequestModuleInterface<IAvatarFactory>(); 1279 m_AvatarFactory = RequestModuleInterface<IAvatarFactory>();
1280 AttachmentsModule = RequestModuleInterface<IAttachmentsModule>();
1153 m_serialiser = RequestModuleInterface<IRegionSerialiserModule>(); 1281 m_serialiser = RequestModuleInterface<IRegionSerialiserModule>();
1154 m_interregionCommsOut = RequestModuleInterface<IInterregionCommsOut>();
1155 m_interregionCommsIn = RequestModuleInterface<IInterregionCommsIn>();
1156 m_dialogModule = RequestModuleInterface<IDialogModule>(); 1282 m_dialogModule = RequestModuleInterface<IDialogModule>();
1157 m_capsModule = RequestModuleInterface<ICapabilitiesModule>(); 1283 m_capsModule = RequestModuleInterface<ICapabilitiesModule>();
1158 m_teleportModule = RequestModuleInterface<ITeleportModule>(); 1284 m_teleportModule = RequestModuleInterface<IEntityTransferModule>();
1285
1286 // Shoving this in here for now, because we have the needed
1287 // interfaces at this point
1288 //
1289 // TODO: Find a better place for this
1290 //
1291 while (m_regInfo.EstateSettings.EstateOwner == UUID.Zero && MainConsole.Instance != null)
1292 {
1293 MainConsole.Instance.Output("The current estate has no owner set.");
1294 string first = MainConsole.Instance.CmdPrompt("Estate owner first name", "Test");
1295 string last = MainConsole.Instance.CmdPrompt("Estate owner last name", "User");
1296
1297 UserAccount account = UserAccountService.GetUserAccount(m_regInfo.ScopeID, first, last);
1298
1299 if (account == null)
1300 {
1301 // Create a new account
1302 account = new UserAccount(m_regInfo.ScopeID, first, last, String.Empty);
1303 if (account.ServiceURLs == null || (account.ServiceURLs != null && account.ServiceURLs.Count == 0))
1304 {
1305 account.ServiceURLs = new Dictionary<string, object>();
1306 account.ServiceURLs["HomeURI"] = string.Empty;
1307 account.ServiceURLs["GatekeeperURI"] = string.Empty;
1308 account.ServiceURLs["InventoryServerURI"] = string.Empty;
1309 account.ServiceURLs["AssetServerURI"] = string.Empty;
1310 }
1311
1312 if (UserAccountService.StoreUserAccount(account))
1313 {
1314 string password = MainConsole.Instance.PasswdPrompt("Password");
1315 string email = MainConsole.Instance.CmdPrompt("Email", "");
1316
1317 account.Email = email;
1318 UserAccountService.StoreUserAccount(account);
1319
1320 bool success = false;
1321 success = AuthenticationService.SetPassword(account.PrincipalID, password);
1322 if (!success)
1323 m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to set password for account {0} {1}.",
1324 first, last);
1325
1326 GridRegion home = null;
1327 if (GridService != null)
1328 {
1329 List<GridRegion> defaultRegions = GridService.GetDefaultRegions(UUID.Zero);
1330 if (defaultRegions != null && defaultRegions.Count >= 1)
1331 home = defaultRegions[0];
1332
1333 if (PresenceService != null && home != null)
1334 PresenceService.SetHomeLocation(account.PrincipalID.ToString(), home.RegionID, new Vector3(128, 128, 0), new Vector3(0, 1, 0));
1335 else
1336 m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to set home for account {0} {1}.",
1337 first, last);
1338
1339 }
1340 else
1341 m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to retrieve home region for account {0} {1}.",
1342 first, last);
1343
1344 if (InventoryService != null)
1345 success = InventoryService.CreateUserInventory(account.PrincipalID);
1346 if (!success)
1347 m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to create inventory for account {0} {1}.",
1348 first, last);
1349
1350
1351 m_log.InfoFormat("[USER ACCOUNT SERVICE]: Account {0} {1} created successfully", first, last);
1352
1353 m_regInfo.EstateSettings.EstateOwner = account.PrincipalID;
1354 m_regInfo.EstateSettings.Save();
1355 }
1356 }
1357 else
1358 {
1359 m_regInfo.EstateSettings.EstateOwner = account.PrincipalID;
1360 m_regInfo.EstateSettings.Save();
1361 }
1362 }
1159 } 1363 }
1160 1364
1161 #endregion 1365 #endregion
@@ -1539,7 +1743,7 @@ namespace OpenSim.Region.Framework.Scenes
1539 m_storageManager.DataStore.StoreTerrain(Heightmap.GetDoubles(), RegionInfo.RegionID); 1743 m_storageManager.DataStore.StoreTerrain(Heightmap.GetDoubles(), RegionInfo.RegionID);
1540 } 1744 }
1541 1745
1542 public void StoreWindlightProfile(RegionMeta7WindlightData wl) 1746 public void StoreWindlightProfile(RegionLightShareData wl)
1543 { 1747 {
1544 m_regInfo.WindlightSettings = wl; 1748 m_regInfo.WindlightSettings = wl;
1545 m_storageManager.DataStore.StoreRegionWindlightSettings(wl); 1749 m_storageManager.DataStore.StoreRegionWindlightSettings(wl);
@@ -1605,7 +1809,9 @@ namespace OpenSim.Region.Framework.Scenes
1605 GridRegion region = new GridRegion(RegionInfo); 1809 GridRegion region = new GridRegion(RegionInfo);
1606 string error = GridService.RegisterRegion(RegionInfo.ScopeID, region); 1810 string error = GridService.RegisterRegion(RegionInfo.ScopeID, region);
1607 if (error != String.Empty) 1811 if (error != String.Empty)
1812 {
1608 throw new Exception(error); 1813 throw new Exception(error);
1814 }
1609 1815
1610 m_sceneGridService.SetScene(this); 1816 m_sceneGridService.SetScene(this);
1611 m_sceneGridService.InformNeighborsThatRegionisUp(RequestModuleInterface<INeighbourService>(), RegionInfo); 1817 m_sceneGridService.InformNeighborsThatRegionisUp(RequestModuleInterface<INeighbourService>(), RegionInfo);
@@ -2017,7 +2223,6 @@ namespace OpenSim.Region.Framework.Scenes
2017 /// Move the given scene object into a new region depending on which region its absolute position has moved 2223 /// Move the given scene object into a new region depending on which region its absolute position has moved
2018 /// into. 2224 /// into.
2019 /// 2225 ///
2020 /// This method locates the new region handle and offsets the prim position for the new region
2021 /// </summary> 2226 /// </summary>
2022 /// <param name="attemptedPosition">the attempted out of region position of the scene object</param> 2227 /// <param name="attemptedPosition">the attempted out of region position of the scene object</param>
2023 /// <param name="grp">the scene object that we're crossing</param> 2228 /// <param name="grp">the scene object that we're crossing</param>
@@ -2059,191 +2264,8 @@ namespace OpenSim.Region.Framework.Scenes
2059 return; 2264 return;
2060 } 2265 }
2061 2266
2062 int thisx = (int)RegionInfo.RegionLocX; 2267 if (m_teleportModule != null)
2063 int thisy = (int)RegionInfo.RegionLocY; 2268 m_teleportModule.Cross(grp, attemptedPosition, silent);
2064 Vector3 EastCross = new Vector3(0.1f,0,0);
2065 Vector3 WestCross = new Vector3(-0.1f, 0, 0);
2066 Vector3 NorthCross = new Vector3(0, 0.1f, 0);
2067 Vector3 SouthCross = new Vector3(0, -0.1f, 0);
2068
2069
2070 // use this if no borders were crossed!
2071 ulong newRegionHandle
2072 = Util.UIntsToLong((uint)((thisx) * Constants.RegionSize),
2073 (uint)((thisy) * Constants.RegionSize));
2074
2075 Vector3 pos = attemptedPosition;
2076
2077 int changeX = 1;
2078 int changeY = 1;
2079
2080 if (TestBorderCross(attemptedPosition + WestCross, Cardinals.W))
2081 {
2082 if (TestBorderCross(attemptedPosition + SouthCross, Cardinals.S))
2083 {
2084
2085 Border crossedBorderx = GetCrossedBorder(attemptedPosition + WestCross, Cardinals.W);
2086
2087 if (crossedBorderx.BorderLine.Z > 0)
2088 {
2089 pos.X = ((pos.X + crossedBorderx.BorderLine.Z));
2090 changeX = (int)(crossedBorderx.BorderLine.Z /(int) Constants.RegionSize);
2091 }
2092 else
2093 pos.X = ((pos.X + Constants.RegionSize));
2094
2095 Border crossedBordery = GetCrossedBorder(attemptedPosition + SouthCross, Cardinals.S);
2096 //(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize)
2097
2098 if (crossedBordery.BorderLine.Z > 0)
2099 {
2100 pos.Y = ((pos.Y + crossedBordery.BorderLine.Z));
2101 changeY = (int)(crossedBordery.BorderLine.Z / (int)Constants.RegionSize);
2102 }
2103 else
2104 pos.Y = ((pos.Y + Constants.RegionSize));
2105
2106
2107
2108 newRegionHandle
2109 = Util.UIntsToLong((uint)((thisx - changeX) * Constants.RegionSize),
2110 (uint)((thisy - changeY) * Constants.RegionSize));
2111 // x - 1
2112 // y - 1
2113 }
2114 else if (TestBorderCross(attemptedPosition + NorthCross, Cardinals.N))
2115 {
2116 Border crossedBorderx = GetCrossedBorder(attemptedPosition + WestCross, Cardinals.W);
2117
2118 if (crossedBorderx.BorderLine.Z > 0)
2119 {
2120 pos.X = ((pos.X + crossedBorderx.BorderLine.Z));
2121 changeX = (int)(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize);
2122 }
2123 else
2124 pos.X = ((pos.X + Constants.RegionSize));
2125
2126
2127 Border crossedBordery = GetCrossedBorder(attemptedPosition + SouthCross, Cardinals.S);
2128 //(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize)
2129
2130 try
2131 {
2132 if (crossedBordery.BorderLine.Z > 0)
2133 {
2134 pos.Y = ((pos.Y + crossedBordery.BorderLine.Z));
2135 changeY = (int)(crossedBordery.BorderLine.Z / (int)Constants.RegionSize);
2136 }
2137 else
2138 pos.Y = ((pos.Y + Constants.RegionSize));
2139
2140 newRegionHandle
2141 = Util.UIntsToLong((uint)((thisx - changeX) * Constants.RegionSize),
2142 (uint)((thisy + changeY) * Constants.RegionSize));
2143 // x - 1
2144 // y + 1
2145 }
2146 catch (Exception ex)
2147 {
2148 }
2149 }
2150 else
2151 {
2152 Border crossedBorderx = GetCrossedBorder(attemptedPosition + WestCross, Cardinals.W);
2153
2154 if (crossedBorderx.BorderLine.Z > 0)
2155 {
2156 pos.X = ((pos.X + crossedBorderx.BorderLine.Z));
2157 changeX = (int)(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize);
2158 }
2159 else
2160 pos.X = ((pos.X + Constants.RegionSize));
2161
2162 newRegionHandle
2163 = Util.UIntsToLong((uint)((thisx - changeX) * Constants.RegionSize),
2164 (uint) (thisy*Constants.RegionSize));
2165 // x - 1
2166 }
2167 }
2168 else if (TestBorderCross(attemptedPosition + EastCross, Cardinals.E))
2169 {
2170 if (TestBorderCross(attemptedPosition + SouthCross, Cardinals.S))
2171 {
2172
2173 pos.X = ((pos.X - Constants.RegionSize));
2174 Border crossedBordery = GetCrossedBorder(attemptedPosition + SouthCross, Cardinals.S);
2175 //(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize)
2176
2177 if (crossedBordery.BorderLine.Z > 0)
2178 {
2179 pos.Y = ((pos.Y + crossedBordery.BorderLine.Z));
2180 changeY = (int)(crossedBordery.BorderLine.Z / (int)Constants.RegionSize);
2181 }
2182 else
2183 pos.Y = ((pos.Y + Constants.RegionSize));
2184
2185
2186 newRegionHandle
2187 = Util.UIntsToLong((uint)((thisx + changeX) * Constants.RegionSize),
2188 (uint)((thisy - changeY) * Constants.RegionSize));
2189 // x + 1
2190 // y - 1
2191 }
2192 else if (TestBorderCross(attemptedPosition + NorthCross, Cardinals.N))
2193 {
2194 pos.X = ((pos.X - Constants.RegionSize));
2195 pos.Y = ((pos.Y - Constants.RegionSize));
2196 newRegionHandle
2197 = Util.UIntsToLong((uint)((thisx + changeX) * Constants.RegionSize),
2198 (uint)((thisy + changeY) * Constants.RegionSize));
2199 // x + 1
2200 // y + 1
2201 }
2202 else
2203 {
2204 pos.X = ((pos.X - Constants.RegionSize));
2205 newRegionHandle
2206 = Util.UIntsToLong((uint)((thisx + changeX) * Constants.RegionSize),
2207 (uint) (thisy*Constants.RegionSize));
2208 // x + 1
2209 }
2210 }
2211 else if (TestBorderCross(attemptedPosition + SouthCross, Cardinals.S))
2212 {
2213 Border crossedBordery = GetCrossedBorder(attemptedPosition + SouthCross, Cardinals.S);
2214 //(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize)
2215
2216 if (crossedBordery.BorderLine.Z > 0)
2217 {
2218 pos.Y = ((pos.Y + crossedBordery.BorderLine.Z));
2219 changeY = (int)(crossedBordery.BorderLine.Z / (int)Constants.RegionSize);
2220 }
2221 else
2222 pos.Y = ((pos.Y + Constants.RegionSize));
2223
2224 newRegionHandle
2225 = Util.UIntsToLong((uint)(thisx * Constants.RegionSize), (uint)((thisy - changeY) * Constants.RegionSize));
2226 // y - 1
2227 }
2228 else if (TestBorderCross(attemptedPosition + NorthCross, Cardinals.N))
2229 {
2230
2231 pos.Y = ((pos.Y - Constants.RegionSize));
2232 newRegionHandle
2233 = Util.UIntsToLong((uint)(thisx * Constants.RegionSize), (uint)((thisy + changeY) * Constants.RegionSize));
2234 // y + 1
2235 }
2236
2237 // Offset the positions for the new region across the border
2238 Vector3 oldGroupPosition = grp.RootPart.GroupPosition;
2239 grp.OffsetForNewRegion(pos);
2240
2241 // If we fail to cross the border, then reset the position of the scene object on that border.
2242 if (!CrossPrimGroupIntoNewRegion(newRegionHandle, grp, silent))
2243 {
2244 grp.OffsetForNewRegion(oldGroupPosition);
2245 grp.ScheduleGroupForFullUpdate();
2246 }
2247 } 2269 }
2248 2270
2249 public Border GetCrossedBorder(Vector3 position, Cardinals gridline) 2271 public Border GetCrossedBorder(Vector3 position, Cardinals gridline)
@@ -2427,75 +2449,6 @@ namespace OpenSim.Region.Framework.Scenes
2427 2449
2428 2450
2429 /// <summary> 2451 /// <summary>
2430 /// Move the given scene object into a new region
2431 /// </summary>
2432 /// <param name="newRegionHandle"></param>
2433 /// <param name="grp">Scene Object Group that we're crossing</param>
2434 /// <returns>
2435 /// true if the crossing itself was successful, false on failure
2436 /// FIMXE: we still return true if the crossing object was not successfully deleted from the originating region
2437 /// </returns>
2438 public bool CrossPrimGroupIntoNewRegion(ulong newRegionHandle, SceneObjectGroup grp, bool silent)
2439 {
2440 //m_log.Debug(" >>> CrossPrimGroupIntoNewRegion <<<");
2441
2442 bool successYN = false;
2443 grp.RootPart.UpdateFlag = 0;
2444 //int primcrossingXMLmethod = 0;
2445
2446 if (newRegionHandle != 0)
2447 {
2448 //string objectState = grp.GetStateSnapshot();
2449
2450 //successYN
2451 // = m_sceneGridService.PrimCrossToNeighboringRegion(
2452 // newRegionHandle, grp.UUID, m_serialiser.SaveGroupToXml2(grp), primcrossingXMLmethod);
2453 //if (successYN && (objectState != "") && m_allowScriptCrossings)
2454 //{
2455 // successYN = m_sceneGridService.PrimCrossToNeighboringRegion(
2456 // newRegionHandle, grp.UUID, objectState, 100);
2457 //}
2458
2459 // And the new channel...
2460 if (m_interregionCommsOut != null)
2461 successYN = m_interregionCommsOut.SendCreateObject(newRegionHandle, grp, true);
2462
2463 if (successYN)
2464 {
2465 // We remove the object here
2466 try
2467 {
2468 DeleteSceneObject(grp, silent);
2469 }
2470 catch (Exception e)
2471 {
2472 m_log.ErrorFormat(
2473 "[INTERREGION]: Exception deleting the old object left behind on a border crossing for {0}, {1}",
2474 grp, e);
2475 }
2476 }
2477 else
2478 {
2479 if (!grp.IsDeleted)
2480 {
2481 if (grp.RootPart.PhysActor != null)
2482 {
2483 grp.RootPart.PhysActor.CrossingFailure();
2484 }
2485 }
2486
2487 m_log.ErrorFormat("[INTERREGION]: Prim crossing failed for {0}", grp);
2488 }
2489 }
2490 else
2491 {
2492 m_log.Error("[INTERREGION]: region handle was unexpectedly 0 in Scene.CrossPrimGroupIntoNewRegion()");
2493 }
2494
2495 return successYN;
2496 }
2497
2498 /// <summary>
2499 /// Called when objects or attachments cross the border between regions. 2452 /// Called when objects or attachments cross the border between regions.
2500 /// </summary> 2453 /// </summary>
2501 /// <param name="sog"></param> 2454 /// <param name="sog"></param>
@@ -2539,10 +2492,10 @@ namespace OpenSim.Region.Framework.Scenes
2539 //m_log.DebugFormat(" >>> IncomingCreateObject(userID, itemID) <<< {0} {1}", userID, itemID); 2492 //m_log.DebugFormat(" >>> IncomingCreateObject(userID, itemID) <<< {0} {1}", userID, itemID);
2540 2493
2541 ScenePresence sp = GetScenePresence(userID); 2494 ScenePresence sp = GetScenePresence(userID);
2542 if (sp != null) 2495 if (sp != null && AttachmentsModule != null)
2543 { 2496 {
2544 uint attPt = (uint)sp.Appearance.GetAttachpoint(itemID); 2497 uint attPt = (uint)sp.Appearance.GetAttachpoint(itemID);
2545 m_sceneGraph.RezSingleAttachment(sp.ControllingClient, itemID, attPt); 2498 AttachmentsModule.RezSingleAttachmentFromInventory(sp.ControllingClient, itemID, attPt);
2546 } 2499 }
2547 2500
2548 return false; 2501 return false;
@@ -2567,6 +2520,9 @@ namespace OpenSim.Region.Framework.Scenes
2567 2520
2568 return false; 2521 return false;
2569 } 2522 }
2523
2524 sceneObject.SetScene(this);
2525
2570 // Force allocation of new LocalId 2526 // Force allocation of new LocalId
2571 // 2527 //
2572 foreach (SceneObjectPart p in sceneObject.Children.Values) 2528 foreach (SceneObjectPart p in sceneObject.Children.Values)
@@ -2603,9 +2559,11 @@ namespace OpenSim.Region.Framework.Scenes
2603 //grp.SetFromAssetID(grp.RootPart.LastOwnerID); 2559 //grp.SetFromAssetID(grp.RootPart.LastOwnerID);
2604 m_log.DebugFormat( 2560 m_log.DebugFormat(
2605 "[ATTACHMENT]: Attach to avatar {0} at position {1}", sp.UUID, grp.AbsolutePosition); 2561 "[ATTACHMENT]: Attach to avatar {0} at position {1}", sp.UUID, grp.AbsolutePosition);
2562
2563 if (AttachmentsModule != null)
2564 AttachmentsModule.AttachObject(
2565 sp.ControllingClient, grp.LocalId, (uint)0, grp.GroupRotation, grp.AbsolutePosition, false);
2606 2566
2607 AttachObject(
2608 sp.ControllingClient, grp.LocalId, (uint)0, grp.GroupRotation, grp.AbsolutePosition, false);
2609 RootPrim.RemFlag(PrimFlags.TemporaryOnRez); 2567 RootPrim.RemFlag(PrimFlags.TemporaryOnRez);
2610 grp.SendGroupFullUpdate(); 2568 grp.SendGroupFullUpdate();
2611 } 2569 }
@@ -2645,6 +2603,8 @@ namespace OpenSim.Region.Framework.Scenes
2645 /// <param name="client"></param> 2603 /// <param name="client"></param>
2646 public override void AddNewClient(IClientAPI client) 2604 public override void AddNewClient(IClientAPI client)
2647 { 2605 {
2606 bool vialogin = false;
2607
2648 m_clientManager.Add(client); 2608 m_clientManager.Add(client);
2649 2609
2650 CheckHeartbeat(); 2610 CheckHeartbeat();
@@ -2679,23 +2639,48 @@ namespace OpenSim.Region.Framework.Scenes
2679 { 2639 {
2680 AgentCircuitData aCircuit = m_authenticateHandler.GetAgentCircuitData(client.CircuitCode); 2640 AgentCircuitData aCircuit = m_authenticateHandler.GetAgentCircuitData(client.CircuitCode);
2681 2641
2682 m_log.Debug("[Scene] Adding new agent " + client.Name + " to scene " + RegionInfo.RegionName); 2642 // Do the verification here
2683 /* 2643 System.Net.EndPoint ep = client.GetClientEP();
2684 string logMsg = string.Format("[SCENE]: Adding new {0} agent for {1} in {2}", 2644 if (aCircuit != null)
2685 ((aCircuit.child == true) ? "child" : "root"), client.Name, 2645 {
2686 RegionInfo.RegionName); 2646 if ((aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0)
2687 2647 {
2688 m_log.Debug(logMsg); 2648 m_log.DebugFormat("[Scene]: Incoming client {0} {1} in region {2} via Login", aCircuit.firstname, aCircuit.lastname, RegionInfo.RegionName);
2689 */ 2649 vialogin = true;
2650 IUserAgentVerificationModule userVerification = RequestModuleInterface<IUserAgentVerificationModule>();
2651 if (userVerification != null && ep != null)
2652 {
2653 if (!userVerification.VerifyClient(aCircuit, ep.ToString()))
2654 {
2655 // uh-oh, this is fishy
2656 m_log.WarnFormat("[Scene]: Agent {0} with session {1} connecting with unidentified end point {2}. Refusing service.",
2657 client.AgentId, client.SessionId, ep.ToString());
2658 try
2659 {
2660 client.Close();
2661 }
2662 catch (Exception e)
2663 {
2664 m_log.DebugFormat("[Scene]: Exception while closing aborted client: {0}", e.StackTrace);
2665 }
2666 return;
2667 }
2668 else
2669 m_log.DebugFormat("[Scene]: User Client Verification for {0} {1} returned true", aCircuit.firstname, aCircuit.lastname);
2670 }
2671 }
2672 }
2690 2673
2691 CommsManager.UserProfileCacheService.AddNewUser(client.AgentId); 2674 m_log.Debug("[Scene] Adding new agent " + client.Name + " to scene " + RegionInfo.RegionName);
2692 2675
2693 ScenePresence sp = CreateAndAddScenePresence(client); 2676 ScenePresence sp = CreateAndAddScenePresence(client);
2677 if (aCircuit != null)
2678 sp.Appearance = aCircuit.Appearance;
2694 2679
2695 // HERE!!! Do the initial attachments right here 2680 // HERE!!! Do the initial attachments right here
2696 // first agent upon login is a root agent by design. 2681 // first agent upon login is a root agent by design.
2697 // All other AddNewClient calls find aCircuit.child to be true 2682 // All other AddNewClient calls find aCircuit.child to be true
2698 if (aCircuit == null || aCircuit.child == false) 2683 if (aCircuit == null || (aCircuit != null && aCircuit.child == false))
2699 { 2684 {
2700 sp.IsChildAgent = false; 2685 sp.IsChildAgent = false;
2701 Util.FireAndForget(delegate(object o) { sp.RezAttachments(); }); 2686 Util.FireAndForget(delegate(object o) { sp.RezAttachments(); });
@@ -2704,6 +2689,8 @@ namespace OpenSim.Region.Framework.Scenes
2704 2689
2705 m_LastLogin = Util.EnvironmentTickCount(); 2690 m_LastLogin = Util.EnvironmentTickCount();
2706 EventManager.TriggerOnNewClient(client); 2691 EventManager.TriggerOnNewClient(client);
2692 if (vialogin)
2693 EventManager.TriggerOnClientLogin(client);
2707 } 2694 }
2708 2695
2709 2696
@@ -2809,19 +2796,22 @@ namespace OpenSim.Region.Framework.Scenes
2809 } 2796 }
2810 2797
2811 public virtual void SubscribeToClientAttachmentEvents(IClientAPI client) 2798 public virtual void SubscribeToClientAttachmentEvents(IClientAPI client)
2812 { 2799 {
2813 client.OnRezSingleAttachmentFromInv += RezSingleAttachment; 2800 client.OnRezMultipleAttachmentsFromInv += RezMultipleAttachments;
2814 client.OnRezMultipleAttachmentsFromInv += RezMultipleAttachments;
2815 client.OnDetachAttachmentIntoInv += DetachSingleAttachmentToInv;
2816 client.OnObjectAttach += m_sceneGraph.AttachObject;
2817 client.OnObjectDetach += m_sceneGraph.DetachObject; 2801 client.OnObjectDetach += m_sceneGraph.DetachObject;
2802
2803 if (AttachmentsModule != null)
2804 {
2805 client.OnRezSingleAttachmentFromInv += AttachmentsModule.RezSingleAttachmentFromInventory;
2806 client.OnObjectAttach += AttachmentsModule.AttachObject;
2807 client.OnDetachAttachmentIntoInv += AttachmentsModule.ShowDetachInUserInventory;
2808 }
2818 } 2809 }
2819 2810
2820 public virtual void SubscribeToClientTeleportEvents(IClientAPI client) 2811 public virtual void SubscribeToClientTeleportEvents(IClientAPI client)
2821 { 2812 {
2822 client.OnTeleportLocationRequest += RequestTeleportLocation; 2813 client.OnTeleportLocationRequest += RequestTeleportLocation;
2823 client.OnTeleportLandmarkRequest += RequestTeleportLandmark; 2814 client.OnTeleportLandmarkRequest += RequestTeleportLandmark;
2824 client.OnTeleportHomeRequest += TeleportClientHome;
2825 } 2815 }
2826 2816
2827 public virtual void SubscribeToClientScriptEvents(IClientAPI client) 2817 public virtual void SubscribeToClientScriptEvents(IClientAPI client)
@@ -2841,7 +2831,7 @@ namespace OpenSim.Region.Framework.Scenes
2841 2831
2842 public virtual void SubscribeToClientGridEvents(IClientAPI client) 2832 public virtual void SubscribeToClientGridEvents(IClientAPI client)
2843 { 2833 {
2844 client.OnNameFromUUIDRequest += CommsManager.HandleUUIDNameRequest; 2834 client.OnNameFromUUIDRequest += HandleUUIDNameRequest;
2845 client.OnMoneyTransferRequest += ProcessMoneyTransferRequest; 2835 client.OnMoneyTransferRequest += ProcessMoneyTransferRequest;
2846 client.OnAvatarPickerRequest += ProcessAvatarPickerRequest; 2836 client.OnAvatarPickerRequest += ProcessAvatarPickerRequest;
2847 client.OnSetStartLocationRequest += SetHomeRezPoint; 2837 client.OnSetStartLocationRequest += SetHomeRezPoint;
@@ -2863,7 +2853,6 @@ namespace OpenSim.Region.Framework.Scenes
2863 2853
2864 protected virtual void UnsubscribeToClientEvents(IClientAPI client) 2854 protected virtual void UnsubscribeToClientEvents(IClientAPI client)
2865 { 2855 {
2866
2867 } 2856 }
2868 2857
2869 /// <summary> 2858 /// <summary>
@@ -2885,7 +2874,6 @@ namespace OpenSim.Region.Framework.Scenes
2885 2874
2886 UnSubscribeToClientNetworkEvents(client); 2875 UnSubscribeToClientNetworkEvents(client);
2887 2876
2888
2889 // EventManager.TriggerOnNewClient(client); 2877 // EventManager.TriggerOnNewClient(client);
2890 } 2878 }
2891 2879
@@ -2942,7 +2930,6 @@ namespace OpenSim.Region.Framework.Scenes
2942 client.OnRezObject -= RezObject; 2930 client.OnRezObject -= RezObject;
2943 } 2931 }
2944 2932
2945
2946 public virtual void UnSubscribeToClientInventoryEvents(IClientAPI client) 2933 public virtual void UnSubscribeToClientInventoryEvents(IClientAPI client)
2947 { 2934 {
2948 client.OnCreateNewInventoryItem -= CreateNewInventoryItem; 2935 client.OnCreateNewInventoryItem -= CreateNewInventoryItem;
@@ -2966,18 +2953,22 @@ namespace OpenSim.Region.Framework.Scenes
2966 2953
2967 public virtual void UnSubscribeToClientAttachmentEvents(IClientAPI client) 2954 public virtual void UnSubscribeToClientAttachmentEvents(IClientAPI client)
2968 { 2955 {
2969 client.OnRezSingleAttachmentFromInv -= RezSingleAttachment; 2956 client.OnRezMultipleAttachmentsFromInv -= RezMultipleAttachments;
2970 client.OnRezMultipleAttachmentsFromInv -= RezMultipleAttachments;
2971 client.OnDetachAttachmentIntoInv -= DetachSingleAttachmentToInv;
2972 client.OnObjectAttach -= m_sceneGraph.AttachObject;
2973 client.OnObjectDetach -= m_sceneGraph.DetachObject; 2957 client.OnObjectDetach -= m_sceneGraph.DetachObject;
2958
2959 if (AttachmentsModule != null)
2960 {
2961 client.OnRezSingleAttachmentFromInv -= AttachmentsModule.RezSingleAttachmentFromInventory;
2962 client.OnObjectAttach -= AttachmentsModule.AttachObject;
2963 client.OnDetachAttachmentIntoInv -= AttachmentsModule.ShowDetachInUserInventory;
2964 }
2974 } 2965 }
2975 2966
2976 public virtual void UnSubscribeToClientTeleportEvents(IClientAPI client) 2967 public virtual void UnSubscribeToClientTeleportEvents(IClientAPI client)
2977 { 2968 {
2978 client.OnTeleportLocationRequest -= RequestTeleportLocation; 2969 client.OnTeleportLocationRequest -= RequestTeleportLocation;
2979 client.OnTeleportLandmarkRequest -= RequestTeleportLandmark; 2970 client.OnTeleportLandmarkRequest -= RequestTeleportLandmark;
2980 client.OnTeleportHomeRequest -= TeleportClientHome; 2971 //client.OnTeleportHomeRequest -= TeleportClientHome;
2981 } 2972 }
2982 2973
2983 public virtual void UnSubscribeToClientScriptEvents(IClientAPI client) 2974 public virtual void UnSubscribeToClientScriptEvents(IClientAPI client)
@@ -2997,7 +2988,7 @@ namespace OpenSim.Region.Framework.Scenes
2997 2988
2998 public virtual void UnSubscribeToClientGridEvents(IClientAPI client) 2989 public virtual void UnSubscribeToClientGridEvents(IClientAPI client)
2999 { 2990 {
3000 client.OnNameFromUUIDRequest -= CommsManager.HandleUUIDNameRequest; 2991 client.OnNameFromUUIDRequest -= HandleUUIDNameRequest;
3001 client.OnMoneyTransferRequest -= ProcessMoneyTransferRequest; 2992 client.OnMoneyTransferRequest -= ProcessMoneyTransferRequest;
3002 client.OnAvatarPickerRequest -= ProcessAvatarPickerRequest; 2993 client.OnAvatarPickerRequest -= ProcessAvatarPickerRequest;
3003 client.OnSetStartLocationRequest -= SetHomeRezPoint; 2994 client.OnSetStartLocationRequest -= SetHomeRezPoint;
@@ -3024,30 +3015,12 @@ namespace OpenSim.Region.Framework.Scenes
3024 /// <param name="client">The IClientAPI for the client</param> 3015 /// <param name="client">The IClientAPI for the client</param>
3025 public virtual void TeleportClientHome(UUID agentId, IClientAPI client) 3016 public virtual void TeleportClientHome(UUID agentId, IClientAPI client)
3026 { 3017 {
3027 UserProfileData UserProfile = CommsManager.UserService.GetUserProfile(agentId); 3018 if (m_teleportModule != null)
3028 if (UserProfile != null) 3019 m_teleportModule.TeleportHome(agentId, client);
3020 else
3029 { 3021 {
3030 GridRegion regionInfo = GridService.GetRegionByUUID(UUID.Zero, UserProfile.HomeRegionID); 3022 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active");
3031 if (regionInfo == null) 3023 client.SendTeleportFailed("Unable to perform teleports on this simulator.");
3032 {
3033 uint x = 0, y = 0;
3034 Utils.LongToUInts(UserProfile.HomeRegion, out x, out y);
3035 regionInfo = GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y);
3036 if (regionInfo != null) // home region can be away temporarily, too
3037 {
3038 UserProfile.HomeRegionID = regionInfo.RegionID;
3039 CommsManager.UserService.UpdateUserProfile(UserProfile);
3040 }
3041 }
3042 if (regionInfo == null)
3043 {
3044 // can't find the Home region: Tell viewer and abort
3045 client.SendTeleportFailed("Your home-region could not be found.");
3046 return;
3047 }
3048 RequestTeleportLocation(
3049 client, regionInfo.RegionHandle, UserProfile.HomeLocation, UserProfile.HomeLookAt,
3050 (uint)(TPFlags.SetLastToTarget | TPFlags.ViaHome));
3051 } 3024 }
3052 } 3025 }
3053 3026
@@ -3138,7 +3111,7 @@ namespace OpenSim.Region.Framework.Scenes
3138 } 3111 }
3139 3112
3140 /// <summary> 3113 /// <summary>
3141 /// Sets the Home Point. The GridService uses this to know where to put a user when they log-in 3114 /// Sets the Home Point. The LoginService uses this to know where to put a user when they log-in
3142 /// </summary> 3115 /// </summary>
3143 /// <param name="remoteClient"></param> 3116 /// <param name="remoteClient"></param>
3144 /// <param name="regionHandle"></param> 3117 /// <param name="regionHandle"></param>
@@ -3147,27 +3120,11 @@ namespace OpenSim.Region.Framework.Scenes
3147 /// <param name="flags"></param> 3120 /// <param name="flags"></param>
3148 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) 3121 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags)
3149 { 3122 {
3150 UserProfileData UserProfile = CommsManager.UserService.GetUserProfile(remoteClient.AgentId); 3123 if (PresenceService.SetHomeLocation(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt))
3151 if (UserProfile != null)
3152 {
3153 // I know I'm ignoring the regionHandle provided by the teleport location request.
3154 // reusing the TeleportLocationRequest delegate, so regionHandle isn't valid
3155 UserProfile.HomeRegionID = RegionInfo.RegionID;
3156 // TODO: The next line can be removed, as soon as only homeRegionID based UserServers are around.
3157 // TODO: The HomeRegion property can be removed then, too
3158 UserProfile.HomeRegion = RegionInfo.RegionHandle;
3159
3160 UserProfile.HomeLocation = position;
3161 UserProfile.HomeLookAt = lookAt;
3162 CommsManager.UserService.UpdateUserProfile(UserProfile);
3163
3164 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. 3124 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot.
3165 m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); 3125 m_dialogModule.SendAlertToUser(remoteClient, "Home position set.");
3166 }
3167 else 3126 else
3168 {
3169 m_dialogModule.SendAlertToUser(remoteClient, "Set Home request Failed."); 3127 m_dialogModule.SendAlertToUser(remoteClient, "Set Home request Failed.");
3170 }
3171 } 3128 }
3172 3129
3173 /// <summary> 3130 /// <summary>
@@ -3240,14 +3197,12 @@ namespace OpenSim.Region.Framework.Scenes
3240 m_sceneGraph.removeUserCount(!childagentYN); 3197 m_sceneGraph.removeUserCount(!childagentYN);
3241 CapsModule.RemoveCapsHandler(agentID); 3198 CapsModule.RemoveCapsHandler(agentID);
3242 3199
3243 if (avatar.Scene.NeedSceneCacheClear(avatar.UUID)) 3200 // REFACTORING PROBLEM -- well not really a problem, but just to point out that whatever
3244 { 3201 // this method is doing is HORRIBLE!!!
3245 CommsManager.UserProfileCacheService.RemoveUser(agentID); 3202 avatar.Scene.NeedSceneCacheClear(avatar.UUID);
3246 }
3247 3203
3248 if (!avatar.IsChildAgent) 3204 if (!avatar.IsChildAgent)
3249 { 3205 {
3250 m_sceneGridService.LogOffUser(agentID, RegionInfo.RegionID, RegionInfo.RegionHandle, avatar.AbsolutePosition, avatar.Lookat);
3251 //List<ulong> childknownRegions = new List<ulong>(); 3206 //List<ulong> childknownRegions = new List<ulong>();
3252 //List<ulong> ckn = avatar.KnownChildRegionHandles; 3207 //List<ulong> ckn = avatar.KnownChildRegionHandles;
3253 //for (int i = 0; i < ckn.Count; i++) 3208 //for (int i = 0; i < ckn.Count; i++)
@@ -3302,12 +3257,6 @@ namespace OpenSim.Region.Framework.Scenes
3302 m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString()); 3257 m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString());
3303 } 3258 }
3304 3259
3305 // Remove client agent from profile, so new logins will work
3306 if (!childagentYN)
3307 {
3308 m_sceneGridService.ClearUserAgent(agentID);
3309 }
3310
3311 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); 3260 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode);
3312 3261
3313 //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); 3262 //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false));
@@ -3380,14 +3329,6 @@ namespace OpenSim.Region.Framework.Scenes
3380 m_sceneGridService.OnLogOffUser += HandleLogOffUserFromGrid; 3329 m_sceneGridService.OnLogOffUser += HandleLogOffUserFromGrid;
3381 m_sceneGridService.KiPrimitive += SendKillObject; 3330 m_sceneGridService.KiPrimitive += SendKillObject;
3382 m_sceneGridService.OnGetLandData += GetLandData; 3331 m_sceneGridService.OnGetLandData += GetLandData;
3383
3384 if (m_interregionCommsIn != null)
3385 {
3386 m_log.Debug("[SCENE]: Registering with InterregionCommsIn");
3387 m_interregionCommsIn.OnChildAgentUpdate += IncomingChildAgentDataUpdate;
3388 }
3389 else
3390 m_log.Debug("[SCENE]: Unable to register with InterregionCommsIn");
3391 } 3332 }
3392 3333
3393 /// <summary> 3334 /// <summary>
@@ -3405,9 +3346,6 @@ namespace OpenSim.Region.Framework.Scenes
3405 m_sceneGridService.OnCloseAgentConnection -= IncomingCloseAgent; 3346 m_sceneGridService.OnCloseAgentConnection -= IncomingCloseAgent;
3406 m_sceneGridService.OnGetLandData -= GetLandData; 3347 m_sceneGridService.OnGetLandData -= GetLandData;
3407 3348
3408 if (m_interregionCommsIn != null)
3409 m_interregionCommsIn.OnChildAgentUpdate -= IncomingChildAgentDataUpdate;
3410
3411 // this does nothing; should be removed 3349 // this does nothing; should be removed
3412 m_sceneGridService.Close(); 3350 m_sceneGridService.Close();
3413 3351
@@ -3444,6 +3382,7 @@ namespace OpenSim.Region.Framework.Scenes
3444 /// also return a reason.</returns> 3382 /// also return a reason.</returns>
3445 public bool NewUserConnection(AgentCircuitData agent, uint teleportFlags, out string reason) 3383 public bool NewUserConnection(AgentCircuitData agent, uint teleportFlags, out string reason)
3446 { 3384 {
3385 TeleportFlags tp = (TeleportFlags)teleportFlags;
3447 //Teleport flags: 3386 //Teleport flags:
3448 // 3387 //
3449 // TeleportFlags.ViaGodlikeLure - Border Crossing 3388 // TeleportFlags.ViaGodlikeLure - Border Crossing
@@ -3464,7 +3403,7 @@ namespace OpenSim.Region.Framework.Scenes
3464 agent.AgentID, agent.circuitcode, teleportFlags); 3403 agent.AgentID, agent.circuitcode, teleportFlags);
3465 3404
3466 reason = String.Empty; 3405 reason = String.Empty;
3467 if (!AuthenticateUser(agent, out reason)) 3406 if (!VerifyUserPresence(agent, out reason))
3468 return false; 3407 return false;
3469 3408
3470 if (!AuthorizeUser(agent, out reason)) 3409 if (!AuthorizeUser(agent, out reason))
@@ -3477,7 +3416,18 @@ namespace OpenSim.Region.Framework.Scenes
3477 3416
3478 CapsModule.NewUserConnection(agent); 3417 CapsModule.NewUserConnection(agent);
3479 3418
3480 ScenePresence sp = m_sceneGraph.GetScenePresence(agent.AgentID); 3419 ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y);
3420
3421 //On login or border crossing test land permisions
3422 if (tp != TeleportFlags.Default)
3423 {
3424 if (land != null && !TestLandRestrictions(agent, land, out reason))
3425 {
3426 return false;
3427 }
3428 }
3429
3430 ScenePresence sp = GetScenePresence(agent.AgentID);
3481 if (sp != null) 3431 if (sp != null)
3482 { 3432 {
3483 m_log.DebugFormat( 3433 m_log.DebugFormat(
@@ -3564,40 +3514,73 @@ namespace OpenSim.Region.Framework.Scenes
3564 */// This is now handled properly in ScenePresence.MakeRootAgent 3514 */// This is now handled properly in ScenePresence.MakeRootAgent
3565 } 3515 }
3566 3516
3517 agent.teleportFlags = teleportFlags;
3567 m_authenticateHandler.AddNewCircuit(agent.circuitcode, agent); 3518 m_authenticateHandler.AddNewCircuit(agent.circuitcode, agent);
3568 3519
3569 // rewrite session_id 3520 return true;
3570 CachedUserInfo userinfo = CommsManager.UserProfileCacheService.GetUserDetails(agent.AgentID); 3521 }
3571 if (userinfo != null) 3522
3572 { 3523 private bool TestLandRestrictions(AgentCircuitData agent, ILandObject land, out string reason)
3573 userinfo.SessionID = agent.SessionID; 3524 {
3574 } 3525
3575 else 3526 bool banned = land.IsBannedFromLand(agent.AgentID);
3527 bool restricted = land.IsRestrictedFromLand(agent.AgentID);
3528
3529 if (banned || restricted)
3576 { 3530 {
3577 m_log.WarnFormat( 3531 ILandObject nearestParcel = GetNearestAllowedParcel(agent.AgentID, agent.startpos.X, agent.startpos.Y);
3578 "[CONNECTION BEGIN]: We couldn't find a User Info record for {0}. This is usually an indication that the UUID we're looking up is invalid", agent.AgentID); 3532 if (nearestParcel != null)
3533 {
3534 //Move agent to nearest allowed
3535 Vector3 newPosition = GetParcelCenterAtGround(nearestParcel);
3536 agent.startpos.X = newPosition.X;
3537 agent.startpos.Y = newPosition.Y;
3538 }
3539 else
3540 {
3541 if (banned)
3542 {
3543 reason = "Cannot regioncross into banned parcel.";
3544 }
3545 else
3546 {
3547 reason = String.Format("Denied access to private region {0}: You are not on the access list for that region.",
3548 RegionInfo.RegionName);
3549 }
3550 return false;
3551 }
3579 } 3552 }
3580 3553 reason = "";
3581 return true; 3554 return true;
3582 } 3555 }
3583 3556
3584 /// <summary> 3557 /// <summary>
3585 /// Verifies that the user has a session on the Grid 3558 /// Verifies that the user has a presence on the Grid
3586 /// </summary> 3559 /// </summary>
3587 /// <param name="agent">Circuit Data of the Agent we're verifying</param> 3560 /// <param name="agent">Circuit Data of the Agent we're verifying</param>
3588 /// <param name="reason">Outputs the reason for the false response on this string</param> 3561 /// <param name="reason">Outputs the reason for the false response on this string</param>
3589 /// <returns>True if the user has a session on the grid. False if it does not. False will 3562 /// <returns>True if the user has a session on the grid. False if it does not. False will
3590 /// also return a reason.</returns> 3563 /// also return a reason.</returns>
3591 public virtual bool AuthenticateUser(AgentCircuitData agent, out string reason) 3564 public virtual bool VerifyUserPresence(AgentCircuitData agent, out string reason)
3592 { 3565 {
3593 reason = String.Empty; 3566 reason = String.Empty;
3594 3567
3595 bool result = CommsManager.UserService.VerifySession(agent.AgentID, agent.SessionID); 3568 IPresenceService presence = RequestModuleInterface<IPresenceService>();
3596 m_log.Debug("[CONNECTION BEGIN]: User authentication returned " + result); 3569 if (presence == null)
3597 if (!result) 3570 {
3598 reason = String.Format("Failed to authenticate user {0} {1}, access denied.", agent.firstname, agent.lastname); 3571 reason = String.Format("Failed to verify user {0} {1} in region {2}. Presence service does not exist.", agent.firstname, agent.lastname, RegionInfo.RegionName);
3572 return false;
3573 }
3574
3575 OpenSim.Services.Interfaces.PresenceInfo pinfo = presence.GetAgent(agent.SessionID);
3576
3577 if (pinfo == null || (pinfo != null && pinfo.Online == false))
3578 {
3579 reason = String.Format("Failed to verify user {0} {1}, access denied to region {2}.", agent.firstname, agent.lastname, RegionInfo.RegionName);
3580 return false;
3581 }
3599 3582
3600 return result; 3583 return true;
3601 } 3584 }
3602 3585
3603 /// <summary> 3586 /// <summary>
@@ -3702,6 +3685,18 @@ namespace OpenSim.Region.Framework.Scenes
3702 return true; 3685 return true;
3703 } 3686 }
3704 3687
3688 private ILandObject GetParcelAtPoint(float x, float y)
3689 {
3690 foreach (var parcel in AllParcels())
3691 {
3692 if (parcel.ContainsPoint((int)x,(int)y))
3693 {
3694 return parcel;
3695 }
3696 }
3697 return null;
3698 }
3699
3705 /// <summary> 3700 /// <summary>
3706 /// Update an AgentCircuitData object with new information 3701 /// Update an AgentCircuitData object with new information
3707 /// </summary> 3702 /// </summary>
@@ -3730,8 +3725,7 @@ namespace OpenSim.Region.Framework.Scenes
3730 /// <param name="message">message to display to the user. Reason for being logged off</param> 3725 /// <param name="message">message to display to the user. Reason for being logged off</param>
3731 public void HandleLogOffUserFromGrid(UUID AvatarID, UUID RegionSecret, string message) 3726 public void HandleLogOffUserFromGrid(UUID AvatarID, UUID RegionSecret, string message)
3732 { 3727 {
3733 ScenePresence loggingOffUser = null; 3728 ScenePresence loggingOffUser = GetScenePresence(AvatarID);
3734 loggingOffUser = GetScenePresence(AvatarID);
3735 if (loggingOffUser != null) 3729 if (loggingOffUser != null)
3736 { 3730 {
3737 UUID localRegionSecret = UUID.Zero; 3731 UUID localRegionSecret = UUID.Zero;
@@ -3767,10 +3761,8 @@ namespace OpenSim.Region.Framework.Scenes
3767 /// <param name="isFlying"></param> 3761 /// <param name="isFlying"></param>
3768 public virtual void AgentCrossing(UUID agentID, Vector3 position, bool isFlying) 3762 public virtual void AgentCrossing(UUID agentID, Vector3 position, bool isFlying)
3769 { 3763 {
3770 ScenePresence presence; 3764 ScenePresence presence = GetScenePresence(agentID);
3771 m_sceneGraph.TryGetAvatar(agentID, out presence); 3765 if(presence != null)
3772
3773 if (presence != null)
3774 { 3766 {
3775 try 3767 try
3776 { 3768 {
@@ -3798,8 +3790,8 @@ namespace OpenSim.Region.Framework.Scenes
3798 /// <returns>true if we handled it.</returns> 3790 /// <returns>true if we handled it.</returns>
3799 public virtual bool IncomingChildAgentDataUpdate(AgentData cAgentData) 3791 public virtual bool IncomingChildAgentDataUpdate(AgentData cAgentData)
3800 { 3792 {
3801// m_log.DebugFormat( 3793 m_log.DebugFormat(
3802// "[SCENE]: Incoming child agent update for {0} in {1}", cAgentData.AgentID, RegionInfo.RegionName); 3794 "[SCENE]: Incoming child agent update for {0} in {1}", cAgentData.AgentID, RegionInfo.RegionName);
3803 3795
3804 // We have to wait until the viewer contacts this region after receiving EAC. 3796 // We have to wait until the viewer contacts this region after receiving EAC.
3805 // That calls AddNewClient, which finally creates the ScenePresence 3797 // That calls AddNewClient, which finally creates the ScenePresence
@@ -3868,16 +3860,6 @@ namespace OpenSim.Region.Framework.Scenes
3868 return false; 3860 return false;
3869 } 3861 }
3870 3862
3871 public virtual bool IncomingReleaseAgent(UUID id)
3872 {
3873 return m_sceneGridService.ReleaseAgent(id);
3874 }
3875
3876 public void SendReleaseAgent(ulong regionHandle, UUID id, string uri)
3877 {
3878 m_interregionCommsOut.SendReleaseAgent(regionHandle, id, uri);
3879 }
3880
3881 /// <summary> 3863 /// <summary>
3882 /// Tell a single agent to disconnect from the region. 3864 /// Tell a single agent to disconnect from the region.
3883 /// </summary> 3865 /// </summary>
@@ -3922,30 +3904,6 @@ namespace OpenSim.Region.Framework.Scenes
3922 } 3904 }
3923 3905
3924 /// <summary> 3906 /// <summary>
3925 /// Tell neighboring regions about this agent
3926 /// When the regions respond with a true value,
3927 /// tell the agents about the region.
3928 ///
3929 /// We have to tell the regions about the agents first otherwise it'll deny them access
3930 ///
3931 /// </summary>
3932 /// <param name="presence"></param>
3933 public void InformClientOfNeighbours(ScenePresence presence)
3934 {
3935 m_sceneGridService.EnableNeighbourChildAgents(presence, m_neighbours);
3936 }
3937
3938 /// <summary>
3939 /// Tell a neighboring region about this agent
3940 /// </summary>
3941 /// <param name="presence"></param>
3942 /// <param name="region"></param>
3943 public void InformClientOfNeighbor(ScenePresence presence, RegionInfo region)
3944 {
3945 m_sceneGridService.EnableNeighbourChildAgents(presence, m_neighbours);
3946 }
3947
3948 /// <summary>
3949 /// Tries to teleport agent to other region. 3907 /// Tries to teleport agent to other region.
3950 /// </summary> 3908 /// </summary>
3951 /// <param name="remoteClient"></param> 3909 /// <param name="remoteClient"></param>
@@ -3978,9 +3936,7 @@ namespace OpenSim.Region.Framework.Scenes
3978 public void RequestTeleportLocation(IClientAPI remoteClient, ulong regionHandle, Vector3 position, 3936 public void RequestTeleportLocation(IClientAPI remoteClient, ulong regionHandle, Vector3 position,
3979 Vector3 lookAt, uint teleportFlags) 3937 Vector3 lookAt, uint teleportFlags)
3980 { 3938 {
3981 ScenePresence sp; 3939 ScenePresence sp = GetScenePresence(remoteClient.AgentId);
3982 m_sceneGraph.TryGetAvatar(remoteClient.AgentId, out sp);
3983
3984 if (sp != null) 3940 if (sp != null)
3985 { 3941 {
3986 uint regionX = m_regInfo.RegionLocX; 3942 uint regionX = m_regInfo.RegionLocX;
@@ -4020,16 +3976,12 @@ namespace OpenSim.Region.Framework.Scenes
4020 } 3976 }
4021 3977
4022 if (m_teleportModule != null) 3978 if (m_teleportModule != null)
4023 { 3979 m_teleportModule.Teleport(sp, regionHandle, position, lookAt, teleportFlags);
4024 m_teleportModule.RequestTeleportToLocation(sp, regionHandle,
4025 position, lookAt, teleportFlags);
4026 }
4027 else 3980 else
4028 { 3981 {
4029 m_sceneGridService.RequestTeleportToLocation(sp, regionHandle, 3982 m_log.DebugFormat("[SCENE]: Unable to perform teleports: no AgentTransferModule is active");
4030 position, lookAt, teleportFlags); 3983 sp.ControllingClient.SendTeleportFailed("Unable to perform teleports on this simulator.");
4031 } 3984 }
4032
4033 } 3985 }
4034 } 3986 }
4035 3987
@@ -4055,7 +4007,12 @@ namespace OpenSim.Region.Framework.Scenes
4055 4007
4056 public void CrossAgentToNewRegion(ScenePresence agent, bool isFlying) 4008 public void CrossAgentToNewRegion(ScenePresence agent, bool isFlying)
4057 { 4009 {
4058 m_sceneGridService.CrossAgentToNewRegion(this, agent, isFlying); 4010 if (m_teleportModule != null)
4011 m_teleportModule.Cross(agent, isFlying);
4012 else
4013 {
4014 m_log.DebugFormat("[SCENE]: Unable to cross agent to neighbouring region, because there is no AgentTransferModule");
4015 }
4059 } 4016 }
4060 4017
4061 public void SendOutChildAgentUpdates(AgentPosition cadu, ScenePresence presence) 4018 public void SendOutChildAgentUpdates(AgentPosition cadu, ScenePresence presence)
@@ -4081,35 +4038,6 @@ namespace OpenSim.Region.Framework.Scenes
4081 objectCapacity = objects; 4038 objectCapacity = objects;
4082 } 4039 }
4083 4040
4084 public List<FriendListItem> GetFriendList(string id)
4085 {
4086 UUID avatarID;
4087 if (!UUID.TryParse(id, out avatarID))
4088 return new List<FriendListItem>();
4089
4090 return CommsManager.GetUserFriendList(avatarID);
4091 }
4092
4093 public Dictionary<UUID, FriendRegionInfo> GetFriendRegionInfos(List<UUID> uuids)
4094 {
4095 return CommsManager.GetFriendRegionInfos(uuids);
4096 }
4097
4098 public virtual void StoreAddFriendship(UUID ownerID, UUID friendID, uint perms)
4099 {
4100 m_sceneGridService.AddNewUserFriend(ownerID, friendID, perms);
4101 }
4102
4103 public virtual void StoreUpdateFriendship(UUID ownerID, UUID friendID, uint perms)
4104 {
4105 m_sceneGridService.UpdateUserFriendPerms(ownerID, friendID, perms);
4106 }
4107
4108 public virtual void StoreRemoveFriendship(UUID ownerID, UUID ExfriendID)
4109 {
4110 m_sceneGridService.RemoveUserFriend(ownerID, ExfriendID);
4111 }
4112
4113 #endregion 4041 #endregion
4114 4042
4115 public void HandleObjectPermissionsUpdate(IClientAPI controller, UUID agentID, UUID sessionID, byte field, uint localId, uint mask, byte set) 4043 public void HandleObjectPermissionsUpdate(IClientAPI controller, UUID agentID, UUID sessionID, byte field, uint localId, uint mask, byte set)
@@ -4187,17 +4115,17 @@ namespace OpenSim.Region.Framework.Scenes
4187 m_log.ErrorFormat("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16}{5,-16}{6,-16}", "Firstname", "Lastname", 4115 m_log.ErrorFormat("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16}{5,-16}{6,-16}", "Firstname", "Lastname",
4188 "Agent ID", "Session ID", "Circuit", "IP", "World"); 4116 "Agent ID", "Session ID", "Circuit", "IP", "World");
4189 4117
4190 foreach (ScenePresence scenePresence in GetAvatars()) 4118 ForEachScenePresence(delegate(ScenePresence sp)
4191 { 4119 {
4192 m_log.ErrorFormat("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16},{5,-16}{6,-16}", 4120 m_log.ErrorFormat("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16},{5,-16}{6,-16}",
4193 scenePresence.Firstname, 4121 sp.Firstname,
4194 scenePresence.Lastname, 4122 sp.Lastname,
4195 scenePresence.UUID, 4123 sp.UUID,
4196 scenePresence.ControllingClient.AgentId, 4124 sp.ControllingClient.AgentId,
4197 "Unknown", 4125 "Unknown",
4198 "Unknown", 4126 "Unknown",
4199 RegionInfo.RegionName); 4127 RegionInfo.RegionName);
4200 } 4128 });
4201 4129
4202 break; 4130 break;
4203 } 4131 }
@@ -4363,56 +4291,45 @@ namespace OpenSim.Region.Framework.Scenes
4363 m_sceneGraph.RemovePhysicalPrim(num); 4291 m_sceneGraph.RemovePhysicalPrim(num);
4364 } 4292 }
4365 4293
4366 //The idea is to have a group of method that return a list of avatars meeting some requirement 4294 public int GetRootAgentCount()
4367 // ie it could be all m_scenePresences within a certain range of the calling prim/avatar.
4368
4369 /// <summary>
4370 /// Return a list of all avatars in this region.
4371 /// This list is a new object, so it can be iterated over without locking.
4372 /// </summary>
4373 /// <returns></returns>
4374 public List<ScenePresence> GetAvatars()
4375 { 4295 {
4376 return m_sceneGraph.GetAvatars(); 4296 return m_sceneGraph.GetRootAgentCount();
4377 } 4297 }
4378 4298
4379 /// <summary> 4299 public int GetChildAgentCount()
4380 /// Cheaply return the number of avatars in a region (without fetching a list object)
4381 /// </summary>
4382 public int GetRootAgentCount()
4383 { 4300 {
4384 return m_sceneGraph.GetRootAgentCount(); 4301 return m_sceneGraph.GetChildAgentCount();
4385 } 4302 }
4386 4303
4387 /// <summary> 4304 /// <summary>
4388 /// Return a list of all ScenePresences in this region. This returns child agents as well as root agents. 4305 /// Request a scene presence by UUID. Fast, indexed lookup.
4389 /// This list is a new object, so it can be iterated over without locking.
4390 /// </summary> 4306 /// </summary>
4391 /// <returns></returns> 4307 /// <param name="agentID"></param>
4392 public ScenePresence[] GetScenePresences() 4308 /// <returns>null if the presence was not found</returns>
4309 public ScenePresence GetScenePresence(UUID agentID)
4393 { 4310 {
4394 return m_sceneGraph.GetScenePresences(); 4311 return m_sceneGraph.GetScenePresence(agentID);
4395 } 4312 }
4396 4313
4397 /// <summary> 4314 /// <summary>
4398 /// Request a filtered list of ScenePresences in this region. 4315 /// Request the scene presence by name.
4399 /// This list is a new object, so it can be iterated over without locking.
4400 /// </summary> 4316 /// </summary>
4401 /// <param name="filter"></param> 4317 /// <param name="firstName"></param>
4402 /// <returns></returns> 4318 /// <param name="lastName"></param>
4403 public List<ScenePresence> GetScenePresences(FilterAvatarList filter) 4319 /// <returns>null if the presence was not found</returns>
4320 public ScenePresence GetScenePresence(string firstName, string lastName)
4404 { 4321 {
4405 return m_sceneGraph.GetScenePresences(filter); 4322 return m_sceneGraph.GetScenePresence(firstName, lastName);
4406 } 4323 }
4407 4324
4408 /// <summary> 4325 /// <summary>
4409 /// Request a scene presence by UUID 4326 /// Request the scene presence by localID.
4410 /// </summary> 4327 /// </summary>
4411 /// <param name="avatarID"></param> 4328 /// <param name="localID"></param>
4412 /// <returns></returns> 4329 /// <returns>null if the presence was not found</returns>
4413 public ScenePresence GetScenePresence(UUID avatarID) 4330 public ScenePresence GetScenePresence(uint localID)
4414 { 4331 {
4415 return m_sceneGraph.GetScenePresence(avatarID); 4332 return m_sceneGraph.GetScenePresence(localID);
4416 } 4333 }
4417 4334
4418 public override bool PresenceChildStatus(UUID avatarID) 4335 public override bool PresenceChildStatus(UUID avatarID)
@@ -4430,25 +4347,14 @@ namespace OpenSim.Region.Framework.Scenes
4430 } 4347 }
4431 4348
4432 /// <summary> 4349 /// <summary>
4433 /// 4350 /// Performs action on all scene presences.
4434 /// </summary> 4351 /// </summary>
4435 /// <param name="action"></param> 4352 /// <param name="action"></param>
4436 public void ForEachScenePresence(Action<ScenePresence> action) 4353 public void ForEachScenePresence(Action<ScenePresence> action)
4437 { 4354 {
4438 // We don't want to try to send messages if there are no avatars.
4439 if (m_sceneGraph != null) 4355 if (m_sceneGraph != null)
4440 { 4356 {
4441 try 4357 m_sceneGraph.ForEachScenePresence(action);
4442 {
4443 ScenePresence[] presences = GetScenePresences();
4444 for (int i = 0; i < presences.Length; i++)
4445 action(presences[i]);
4446 }
4447 catch (Exception e)
4448 {
4449 m_log.Info("[BUG] in " + RegionInfo.RegionName + ": " + e.ToString());
4450 m_log.Info("[BUG] Stack Trace: " + e.StackTrace);
4451 }
4452 } 4358 }
4453 } 4359 }
4454 4360
@@ -4512,9 +4418,9 @@ namespace OpenSim.Region.Framework.Scenes
4512 return m_sceneGraph.GetGroupByPrim(localID); 4418 return m_sceneGraph.GetGroupByPrim(localID);
4513 } 4419 }
4514 4420
4515 public bool TryGetAvatar(UUID avatarId, out ScenePresence avatar) 4421 public override bool TryGetScenePresence(UUID avatarId, out ScenePresence avatar)
4516 { 4422 {
4517 return m_sceneGraph.TryGetAvatar(avatarId, out avatar); 4423 return m_sceneGraph.TryGetScenePresence(avatarId, out avatar);
4518 } 4424 }
4519 4425
4520 public bool TryGetAvatarByName(string avatarName, out ScenePresence avatar) 4426 public bool TryGetAvatarByName(string avatarName, out ScenePresence avatar)
@@ -4524,20 +4430,7 @@ namespace OpenSim.Region.Framework.Scenes
4524 4430
4525 public void ForEachClient(Action<IClientAPI> action) 4431 public void ForEachClient(Action<IClientAPI> action)
4526 { 4432 {
4527 ForEachClient(action, m_useAsyncWhenPossible);
4528 }
4529
4530 public void ForEachClient(Action<IClientAPI> action, bool doAsynchronous)
4531 {
4532 // FIXME: Asynchronous iteration is disabled until we have a threading model that
4533 // can support calling this function from an async packet handler without
4534 // potentially deadlocking
4535 m_clientManager.ForEachSync(action); 4433 m_clientManager.ForEachSync(action);
4536
4537 //if (doAsynchronous)
4538 // m_clientManager.ForEach(action);
4539 //else
4540 // m_clientManager.ForEachSync(action);
4541 } 4434 }
4542 4435
4543 public bool TryGetClient(UUID avatarID, out IClientAPI client) 4436 public bool TryGetClient(UUID avatarID, out IClientAPI client)
@@ -4709,7 +4602,8 @@ namespace OpenSim.Region.Framework.Scenes
4709 group.GetPartName(localID), 4602 group.GetPartName(localID),
4710 group.GetPartDescription(localID), 4603 group.GetPartDescription(localID),
4711 (sbyte)AssetType.Object, 4604 (sbyte)AssetType.Object,
4712 Utils.StringToBytes(sceneObjectXml)); 4605 Utils.StringToBytes(sceneObjectXml),
4606 group.OwnerID);
4713 AssetService.Store(asset); 4607 AssetService.Store(asset);
4714 4608
4715 InventoryItemBase item = new InventoryItemBase(); 4609 InventoryItemBase item = new InventoryItemBase();
@@ -5033,5 +4927,185 @@ namespace OpenSim.Region.Framework.Scenes
5033 if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 2000) 4927 if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 2000)
5034 StartTimer(); 4928 StartTimer();
5035 } 4929 }
4930
4931 public override ISceneObject DeserializeObject(string representation)
4932 {
4933 return SceneObjectSerializer.FromXml2Format(representation);
4934 }
4935
4936 public override bool AllowScriptCrossings
4937 {
4938 get { return m_allowScriptCrossings; }
4939 }
4940
4941 public Vector3? GetNearestAllowedPosition(ScenePresence avatar)
4942 {
4943 //simulate to make sure we have pretty up to date positions
4944 PhysicsScene.Simulate(0);
4945
4946 ILandObject nearestParcel = GetNearestAllowedParcel(avatar.UUID, avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y);
4947
4948 if (nearestParcel != null)
4949 {
4950 Vector3 dir = Vector3.Normalize(Vector3.Multiply(avatar.Velocity, -1));
4951 //Try to get a location that feels like where they came from
4952 Vector3? nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel);
4953 if (nearestPoint != null)
4954 {
4955 Debug.WriteLine("Found a sane previous position based on velocity, sending them to: " + nearestPoint.ToString());
4956 return nearestPoint.Value;
4957 }
4958
4959 //Sometimes velocity might be zero (local teleport), so try finding point along path from avatar to center of nearest parcel
4960 Vector3 directionToParcelCenter = Vector3.Subtract(GetParcelCenterAtGround(nearestParcel), avatar.AbsolutePosition);
4961 dir = Vector3.Normalize(directionToParcelCenter);
4962 nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel);
4963 if (nearestPoint != null)
4964 {
4965 Debug.WriteLine("They had a zero velocity, sending them to: " + nearestPoint.ToString());
4966 return nearestPoint.Value;
4967 }
4968
4969 //Ultimate backup if we have no idea where they are
4970 Debug.WriteLine("Have no idea where they are, sending them to: " + avatar.lastKnownAllowedPosition.ToString());
4971 return avatar.lastKnownAllowedPosition;
4972
4973 }
4974
4975 //Go to the edge, this happens in teleporting to a region with no available parcels
4976 Vector3 nearestRegionEdgePoint = GetNearestRegionEdgePosition(avatar);
4977 //Debug.WriteLine("They are really in a place they don't belong, sending them to: " + nearestRegionEdgePoint.ToString());
4978 return nearestRegionEdgePoint;
4979 return null;
4980 }
4981
4982 private Vector3 GetParcelCenterAtGround(ILandObject parcel)
4983 {
4984 Vector2 center = GetParcelCenter(parcel);
4985 return GetPositionAtGround(center.X, center.Y);
4986 }
4987
4988 private Vector3? GetNearestPointInParcelAlongDirectionFromPoint(Vector3 pos, Vector3 direction, ILandObject parcel)
4989 {
4990 Vector3 unitDirection = Vector3.Normalize(direction);
4991 //Making distance to search go through some sane limit of distance
4992 for (float distance = 0; distance < Constants.RegionSize * 2; distance += .5f)
4993 {
4994 Vector3 testPos = Vector3.Add(pos, Vector3.Multiply(unitDirection, distance));
4995 if (parcel.ContainsPoint((int)testPos.X, (int)testPos.Y))
4996 {
4997 return testPos;
4998 }
4999 }
5000 return null;
5001 }
5002
5003 public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y)
5004 {
5005 List<ILandObject> all = AllParcels();
5006 float minParcelDistance = float.MaxValue;
5007 ILandObject nearestParcel = null;
5008
5009 foreach (var parcel in all)
5010 {
5011 if (!parcel.IsEitherBannedOrRestricted(avatarId))
5012 {
5013 float parcelDistance = GetParcelDistancefromPoint(parcel, x, y);
5014 if (parcelDistance < minParcelDistance)
5015 {
5016 minParcelDistance = parcelDistance;
5017 nearestParcel = parcel;
5018 }
5019 }
5020 }
5021
5022 return nearestParcel;
5023 }
5024
5025 private List<ILandObject> AllParcels()
5026 {
5027 return LandChannel.AllParcels();
5028 }
5029
5030 private float GetParcelDistancefromPoint(ILandObject parcel, float x, float y)
5031 {
5032 return Vector2.Distance(new Vector2(x, y), GetParcelCenter(parcel));
5033 }
5034
5035 //calculate the average center point of a parcel
5036 private Vector2 GetParcelCenter(ILandObject parcel)
5037 {
5038 int count = 0;
5039 int avgx = 0;
5040 int avgy = 0;
5041 for (int x = 0; x < Constants.RegionSize; x++)
5042 {
5043 for (int y = 0; y < Constants.RegionSize; y++)
5044 {
5045 //Just keep a running average as we check if all the points are inside or not
5046 if (parcel.ContainsPoint(x, y))
5047 {
5048 if (count == 0)
5049 {
5050 avgx = x;
5051 avgy = y;
5052 }
5053 else
5054 {
5055 avgx = (avgx * count + x) / (count + 1);
5056 avgy = (avgy * count + y) / (count + 1);
5057 }
5058 count += 1;
5059 }
5060 }
5061 }
5062 return new Vector2(avgx, avgy);
5063 }
5064
5065 private Vector3 GetNearestRegionEdgePosition(ScenePresence avatar)
5066 {
5067 float xdistance = avatar.AbsolutePosition.X < Constants.RegionSize / 2 ? avatar.AbsolutePosition.X : Constants.RegionSize - avatar.AbsolutePosition.X;
5068 float ydistance = avatar.AbsolutePosition.Y < Constants.RegionSize / 2 ? avatar.AbsolutePosition.Y : Constants.RegionSize - avatar.AbsolutePosition.Y;
5069
5070 //find out what vertical edge to go to
5071 if (xdistance < ydistance)
5072 {
5073 if (avatar.AbsolutePosition.X < Constants.RegionSize / 2)
5074 {
5075 return GetPositionAtAvatarHeightOrGroundHeight(avatar, 0.0f, avatar.AbsolutePosition.Y);
5076 }
5077 else
5078 {
5079 return GetPositionAtAvatarHeightOrGroundHeight(avatar, Constants.RegionSize, avatar.AbsolutePosition.Y);
5080 }
5081 }
5082 //find out what horizontal edge to go to
5083 else
5084 {
5085 if (avatar.AbsolutePosition.Y < Constants.RegionSize / 2)
5086 {
5087 return GetPositionAtAvatarHeightOrGroundHeight(avatar, avatar.AbsolutePosition.X, 0.0f);
5088 }
5089 else
5090 {
5091 return GetPositionAtAvatarHeightOrGroundHeight(avatar, avatar.AbsolutePosition.X, Constants.RegionSize);
5092 }
5093 }
5094 }
5095
5096 private Vector3 GetPositionAtAvatarHeightOrGroundHeight(ScenePresence avatar, float x, float y)
5097 {
5098 Vector3 ground = GetPositionAtGround(x, y);
5099 if (avatar.AbsolutePosition.Z > ground.Z)
5100 {
5101 ground.Z = avatar.AbsolutePosition.Z;
5102 }
5103 return ground;
5104 }
5105
5106 private Vector3 GetPositionAtGround(float x, float y)
5107 {
5108 return new Vector3(x, y, GetGroundHeight(x, y));
5109 }
5036 } 5110 }
5037} 5111}
diff --git a/OpenSim/Region/Framework/Scenes/SceneBase.cs b/OpenSim/Region/Framework/Scenes/SceneBase.cs
index 5e798c0..3218dad 100644
--- a/OpenSim/Region/Framework/Scenes/SceneBase.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneBase.cs
@@ -34,7 +34,7 @@ using log4net;
34using Nini.Config; 34using Nini.Config;
35using OpenSim.Framework; 35using OpenSim.Framework;
36using OpenSim.Framework.Console; 36using OpenSim.Framework.Console;
37using OpenSim.Framework.Communications.Cache; 37
38using OpenSim.Region.Framework.Interfaces; 38using OpenSim.Region.Framework.Interfaces;
39using GridRegion = OpenSim.Services.Interfaces.GridRegion; 39using GridRegion = OpenSim.Services.Interfaces.GridRegion;
40 40
@@ -190,6 +190,21 @@ namespace OpenSim.Region.Framework.Scenes
190 /// <param name="agentID"></param> 190 /// <param name="agentID"></param>
191 public abstract void RemoveClient(UUID agentID); 191 public abstract void RemoveClient(UUID agentID);
192 192
193 public bool TryGetScenePresence(UUID agentID, out object scenePresence)
194 {
195 scenePresence = null;
196 ScenePresence sp = null;
197 if (TryGetScenePresence(agentID, out sp))
198 {
199 scenePresence = sp;
200 return true;
201 }
202
203 return false;
204 }
205
206 public abstract bool TryGetScenePresence(UUID agentID, out ScenePresence scenePresence);
207
193 #endregion 208 #endregion
194 209
195 /// <summary> 210 /// <summary>
@@ -510,5 +525,16 @@ namespace OpenSim.Region.Framework.Scenes
510 525
511 MainConsole.Instance.Commands.AddCommand(modulename, shared, command, shorthelp, longhelp, callback); 526 MainConsole.Instance.Commands.AddCommand(modulename, shared, command, shorthelp, longhelp, callback);
512 } 527 }
528
529 public virtual ISceneObject DeserializeObject(string representation)
530 {
531 return null;
532 }
533
534 public virtual bool AllowScriptCrossings
535 {
536 get { return false; }
537 }
538
513 } 539 }
514} 540}
diff --git a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
index 04626d3..9d0e6f4 100644
--- a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
@@ -36,7 +36,6 @@ using log4net;
36using OpenSim.Framework; 36using OpenSim.Framework;
37using OpenSim.Framework.Client; 37using OpenSim.Framework.Client;
38using OpenSim.Framework.Communications; 38using OpenSim.Framework.Communications;
39using OpenSim.Framework.Communications.Cache;
40using OpenSim.Framework.Capabilities; 39using OpenSim.Framework.Capabilities;
41using OpenSim.Region.Framework.Interfaces; 40using OpenSim.Region.Framework.Interfaces;
42using OpenSim.Services.Interfaces; 41using OpenSim.Services.Interfaces;
@@ -56,8 +55,6 @@ namespace OpenSim.Region.Framework.Scenes
56 { 55 {
57 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 56 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
58 57
59 protected CommunicationsManager m_commsProvider;
60 protected IInterregionCommsOut m_interregionCommsOut;
61 protected RegionInfo m_regionInfo; 58 protected RegionInfo m_regionInfo;
62 protected Scene m_scene; 59 protected Scene m_scene;
63 60
@@ -106,29 +103,26 @@ namespace OpenSim.Region.Framework.Scenes
106 /// </summary> 103 /// </summary>
107 public event GetLandData OnGetLandData; 104 public event GetLandData OnGetLandData;
108 105
109 private AgentCrossing handlerAvatarCrossingIntoRegion = null; // OnAvatarCrossingIntoRegion; 106// private AgentCrossing handlerAvatarCrossingIntoRegion = null; // OnAvatarCrossingIntoRegion;
110 private ExpectUserDelegate handlerExpectUser = null; // OnExpectUser; 107// private ExpectUserDelegate handlerExpectUser = null; // OnExpectUser;
111 private CloseAgentConnection handlerCloseAgentConnection = null; // OnCloseAgentConnection; 108// private CloseAgentConnection handlerCloseAgentConnection = null; // OnCloseAgentConnection;
112 private PrimCrossing handlerPrimCrossingIntoRegion = null; // OnPrimCrossingIntoRegion; 109// private PrimCrossing handlerPrimCrossingIntoRegion = null; // OnPrimCrossingIntoRegion;
113 //private RegionUp handlerRegionUp = null; // OnRegionUp; 110 //private RegionUp handlerRegionUp = null; // OnRegionUp;
114 private ChildAgentUpdate handlerChildAgentUpdate = null; // OnChildAgentUpdate; 111// private ChildAgentUpdate handlerChildAgentUpdate = null; // OnChildAgentUpdate;
115 //private RemoveKnownRegionsFromAvatarList handlerRemoveKnownRegionFromAvatar = null; // OnRemoveKnownRegionFromAvatar; 112 //private RemoveKnownRegionsFromAvatarList handlerRemoveKnownRegionFromAvatar = null; // OnRemoveKnownRegionFromAvatar;
116 private LogOffUser handlerLogOffUser = null; 113// private LogOffUser handlerLogOffUser = null;
117 private GetLandData handlerGetLandData = null; // OnGetLandData 114// private GetLandData handlerGetLandData = null; // OnGetLandData
118 115
119 public KiPrimitiveDelegate KiPrimitive; 116 public KiPrimitiveDelegate KiPrimitive;
120 117
121 public SceneCommunicationService(CommunicationsManager commsMan) 118 public SceneCommunicationService()
122 { 119 {
123 m_commsProvider = commsMan;
124 m_agentsInTransit = new List<UUID>();
125 } 120 }
126 121
127 public void SetScene(Scene s) 122 public void SetScene(Scene s)
128 { 123 {
129 m_scene = s; 124 m_scene = s;
130 m_regionInfo = s.RegionInfo; 125 m_regionInfo = s.RegionInfo;
131 m_interregionCommsOut = m_scene.RequestModuleInterface<IInterregionCommsOut>();
132 } 126 }
133 127
134 /// <summary> 128 /// <summary>
@@ -148,377 +142,6 @@ namespace OpenSim.Region.Framework.Scenes
148 { 142 {
149 } 143 }
150 144
151 #region CommsManager Event handlers
152
153 /// <summary>
154 /// A New User will arrive shortly, Informs the scene that there's a new user on the way
155 /// </summary>
156 /// <param name="agent">Data we need to ensure that the agent can connect</param>
157 ///
158 protected void NewUserConnection(AgentCircuitData agent)
159 {
160 handlerExpectUser = OnExpectUser;
161 if (handlerExpectUser != null)
162 {
163 //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: OnExpectUser Fired for User:" + agent.firstname + " " + agent.lastname);
164 handlerExpectUser(agent);
165 }
166 }
167
168 /// <summary>
169 /// The Grid has requested us to log-off the user
170 /// </summary>
171 /// <param name="AgentID">Unique ID of agent to log-off</param>
172 /// <param name="RegionSecret">The secret string that the region establishes with the grid when registering</param>
173 /// <param name="message">The message to send to the user that tells them why they were logged off</param>
174 protected void GridLogOffUser(UUID AgentID, UUID RegionSecret, string message)
175 {
176 handlerLogOffUser = OnLogOffUser;
177 if (handlerLogOffUser != null)
178 {
179 handlerLogOffUser(AgentID, RegionSecret, message);
180 }
181 }
182
183 /// <summary>
184 /// Inform the scene that we've got an update about a child agent that we have
185 /// </summary>
186 /// <param name="cAgentData"></param>
187 /// <returns></returns>
188 protected bool ChildAgentUpdate(ChildAgentDataUpdate cAgentData)
189 {
190 handlerChildAgentUpdate = OnChildAgentUpdate;
191 if (handlerChildAgentUpdate != null)
192 handlerChildAgentUpdate(cAgentData);
193
194 return true;
195 }
196
197
198 protected void AgentCrossing(UUID agentID, Vector3 position, bool isFlying)
199 {
200 handlerAvatarCrossingIntoRegion = OnAvatarCrossingIntoRegion;
201 if (handlerAvatarCrossingIntoRegion != null)
202 {
203 handlerAvatarCrossingIntoRegion(agentID, position, isFlying);
204 }
205 }
206
207 protected void PrimCrossing(UUID primID, Vector3 position, bool isPhysical)
208 {
209 handlerPrimCrossingIntoRegion = OnPrimCrossingIntoRegion;
210 if (handlerPrimCrossingIntoRegion != null)
211 {
212 handlerPrimCrossingIntoRegion(primID, position, isPhysical);
213 }
214 }
215
216 protected bool CloseConnection(UUID agentID)
217 {
218 m_log.Debug("[INTERREGION]: Incoming Agent Close Request for agent: " + agentID);
219
220 handlerCloseAgentConnection = OnCloseAgentConnection;
221 if (handlerCloseAgentConnection != null)
222 {
223 return handlerCloseAgentConnection(agentID);
224 }
225
226 return false;
227 }
228
229 protected LandData FetchLandData(uint x, uint y)
230 {
231 handlerGetLandData = OnGetLandData;
232 if (handlerGetLandData != null)
233 {
234 return handlerGetLandData(x, y);
235 }
236 return null;
237 }
238
239 #endregion
240
241 #region Inform Client of Neighbours
242
243 private delegate void InformClientOfNeighbourDelegate(
244 ScenePresence avatar, AgentCircuitData a, GridRegion reg, IPEndPoint endPoint, bool newAgent);
245
246 private void InformClientOfNeighbourCompleted(IAsyncResult iar)
247 {
248 InformClientOfNeighbourDelegate icon = (InformClientOfNeighbourDelegate) iar.AsyncState;
249 icon.EndInvoke(iar);
250 }
251
252 /// <summary>
253 /// Async component for informing client of which neighbours exist
254 /// </summary>
255 /// <remarks>
256 /// This needs to run asynchronously, as a network timeout may block the thread for a long while
257 /// </remarks>
258 /// <param name="remoteClient"></param>
259 /// <param name="a"></param>
260 /// <param name="regionHandle"></param>
261 /// <param name="endPoint"></param>
262 private void InformClientOfNeighbourAsync(ScenePresence avatar, AgentCircuitData a, GridRegion reg,
263 IPEndPoint endPoint, bool newAgent)
264 {
265 // Let's wait just a little to give time to originating regions to catch up with closing child agents
266 // after a cross here
267 Thread.Sleep(500);
268
269 uint x, y;
270 Utils.LongToUInts(reg.RegionHandle, out x, out y);
271 x = x / Constants.RegionSize;
272 y = y / Constants.RegionSize;
273 m_log.Info("[INTERGRID]: Starting to inform client about neighbour " + x + ", " + y + "(" + endPoint.ToString() + ")");
274
275 string capsPath = "http://" + reg.ExternalHostName + ":" + reg.HttpPort
276 + "/CAPS/" + a.CapsPath + "0000/";
277
278 string reason = String.Empty;
279
280
281 bool regionAccepted = m_interregionCommsOut.SendCreateChildAgent(reg.RegionHandle, a, 0, out reason);
282
283 if (regionAccepted && newAgent)
284 {
285 IEventQueue eq = avatar.Scene.RequestModuleInterface<IEventQueue>();
286 if (eq != null)
287 {
288 #region IP Translation for NAT
289 IClientIPEndpoint ipepClient;
290 if (avatar.ClientView.TryGet(out ipepClient))
291 {
292 endPoint.Address = NetworkUtil.GetIPFor(ipepClient.EndPoint, endPoint.Address);
293 }
294 #endregion
295
296 eq.EnableSimulator(reg.RegionHandle, endPoint, avatar.UUID);
297 eq.EstablishAgentCommunication(avatar.UUID, endPoint, capsPath);
298 m_log.DebugFormat("[CAPS]: Sending new CAPS seed url {0} to client {1} in region {2}",
299 capsPath, avatar.UUID, avatar.Scene.RegionInfo.RegionName);
300 }
301 else
302 {
303 avatar.ControllingClient.InformClientOfNeighbour(reg.RegionHandle, endPoint);
304 // TODO: make Event Queue disablable!
305 }
306
307 m_log.Info("[INTERGRID]: Completed inform client about neighbour " + endPoint.ToString());
308
309 }
310
311 }
312
313 public List<GridRegion> RequestNeighbours(Scene pScene, uint pRegionLocX, uint pRegionLocY)
314 {
315 Border[] northBorders = pScene.NorthBorders.ToArray();
316 Border[] southBorders = pScene.SouthBorders.ToArray();
317 Border[] eastBorders = pScene.EastBorders.ToArray();
318 Border[] westBorders = pScene.WestBorders.ToArray();
319
320 // Legacy one region. Provided for simplicity while testing the all inclusive method in the else statement.
321 if (northBorders.Length <= 1 && southBorders.Length <= 1 && eastBorders.Length <= 1 && westBorders.Length <= 1)
322 {
323 return m_scene.GridService.GetNeighbours(m_regionInfo.ScopeID, m_regionInfo.RegionID);
324 }
325 else
326 {
327 Vector2 extent = Vector2.Zero;
328 for (int i = 0; i < eastBorders.Length; i++)
329 {
330 extent.X = (eastBorders[i].BorderLine.Z > extent.X) ? eastBorders[i].BorderLine.Z : extent.X;
331 }
332 for (int i = 0; i < northBorders.Length; i++)
333 {
334 extent.Y = (northBorders[i].BorderLine.Z > extent.Y) ? northBorders[i].BorderLine.Z : extent.Y;
335 }
336
337 // Loss of fraction on purpose
338 extent.X = ((int)extent.X / (int)Constants.RegionSize) + 1;
339 extent.Y = ((int)extent.Y / (int)Constants.RegionSize) + 1;
340
341 int startX = (int)(pRegionLocX - 1) * (int)Constants.RegionSize;
342 int startY = (int)(pRegionLocY - 1) * (int)Constants.RegionSize;
343
344 int endX = ((int)pRegionLocX + (int)extent.X) * (int)Constants.RegionSize;
345 int endY = ((int)pRegionLocY + (int)extent.Y) * (int)Constants.RegionSize;
346
347 List<GridRegion> neighbours = m_scene.GridService.GetRegionRange(m_regionInfo.ScopeID, startX, endX, startY, endY);
348 neighbours.RemoveAll(delegate(GridRegion r) { return r.RegionID == m_regionInfo.RegionID; });
349
350 return neighbours;
351 }
352 }
353
354 /// <summary>
355 /// This informs all neighboring regions about agent "avatar".
356 /// Calls an asynchronous method to do so.. so it doesn't lag the sim.
357 /// </summary>
358 public void EnableNeighbourChildAgents(ScenePresence avatar, List<RegionInfo> lstneighbours)
359 {
360 List<GridRegion> neighbours = new List<GridRegion>();
361
362 if (m_regionInfo != null)
363 {
364 neighbours = RequestNeighbours(avatar.Scene,m_regionInfo.RegionLocX, m_regionInfo.RegionLocY);
365 }
366 else
367 {
368 m_log.Debug("[ENABLENEIGHBOURCHILDAGENTS]: m_regionInfo was null in EnableNeighbourChildAgents, is this a NPC?");
369 }
370
371 /// We need to find the difference between the new regions where there are no child agents
372 /// and the regions where there are already child agents. We only send notification to the former.
373 List<ulong> neighbourHandles = NeighbourHandles(neighbours); // on this region
374 neighbourHandles.Add(avatar.Scene.RegionInfo.RegionHandle); // add this region too
375 List<ulong> previousRegionNeighbourHandles ;
376
377 if (avatar.Scene.CapsModule != null)
378 {
379 previousRegionNeighbourHandles =
380 new List<ulong>(avatar.Scene.CapsModule.GetChildrenSeeds(avatar.UUID).Keys);
381 }
382 else
383 {
384 previousRegionNeighbourHandles = new List<ulong>();
385 }
386
387 List<ulong> newRegions = NewNeighbours(neighbourHandles, previousRegionNeighbourHandles);
388 List<ulong> oldRegions = OldNeighbours(neighbourHandles, previousRegionNeighbourHandles);
389
390 //Dump("Current Neighbors", neighbourHandles);
391 //Dump("Previous Neighbours", previousRegionNeighbourHandles);
392 //Dump("New Neighbours", newRegions);
393 //Dump("Old Neighbours", oldRegions);
394
395 /// Update the scene presence's known regions here on this region
396 avatar.DropOldNeighbours(oldRegions);
397
398 /// Collect as many seeds as possible
399 Dictionary<ulong, string> seeds;
400 if (avatar.Scene.CapsModule != null)
401 seeds
402 = new Dictionary<ulong, string>(avatar.Scene.CapsModule.GetChildrenSeeds(avatar.UUID));
403 else
404 seeds = new Dictionary<ulong, string>();
405
406 //m_log.Debug(" !!! No. of seeds: " + seeds.Count);
407 if (!seeds.ContainsKey(avatar.Scene.RegionInfo.RegionHandle))
408 seeds.Add(avatar.Scene.RegionInfo.RegionHandle, avatar.ControllingClient.RequestClientInfo().CapsPath);
409
410 /// Create the necessary child agents
411 List<AgentCircuitData> cagents = new List<AgentCircuitData>();
412 foreach (GridRegion neighbour in neighbours)
413 {
414 if (neighbour.RegionHandle != avatar.Scene.RegionInfo.RegionHandle)
415 {
416
417 AgentCircuitData agent = avatar.ControllingClient.RequestClientInfo();
418 agent.BaseFolder = UUID.Zero;
419 agent.InventoryFolder = UUID.Zero;
420 agent.startpos = new Vector3(128, 128, 70);
421 agent.child = true;
422
423 if (newRegions.Contains(neighbour.RegionHandle))
424 {
425 agent.CapsPath = CapsUtil.GetRandomCapsObjectPath();
426 avatar.AddNeighbourRegion(neighbour.RegionHandle, agent.CapsPath);
427 seeds.Add(neighbour.RegionHandle, agent.CapsPath);
428 }
429 else
430 agent.CapsPath = avatar.Scene.CapsModule.GetChildSeed(avatar.UUID, neighbour.RegionHandle);
431
432 cagents.Add(agent);
433 }
434 }
435
436 /// Update all child agent with everyone's seeds
437 foreach (AgentCircuitData a in cagents)
438 {
439 a.ChildrenCapSeeds = new Dictionary<ulong, string>(seeds);
440 }
441
442 if (avatar.Scene.CapsModule != null)
443 {
444 // These two are the same thing!
445 avatar.Scene.CapsModule.SetChildrenSeed(avatar.UUID, seeds);
446 }
447 avatar.KnownRegions = seeds;
448 //avatar.Scene.DumpChildrenSeeds(avatar.UUID);
449 //avatar.DumpKnownRegions();
450
451 bool newAgent = false;
452 int count = 0;
453 foreach (GridRegion neighbour in neighbours)
454 {
455 // Don't do it if there's already an agent in that region
456 if (newRegions.Contains(neighbour.RegionHandle))
457 newAgent = true;
458 else
459 newAgent = false;
460
461 if (neighbour.RegionHandle != avatar.Scene.RegionInfo.RegionHandle)
462 {
463 InformClientOfNeighbourDelegate d = InformClientOfNeighbourAsync;
464 try
465 {
466 d.BeginInvoke(avatar, cagents[count], neighbour, neighbour.ExternalEndPoint, newAgent,
467 InformClientOfNeighbourCompleted,
468 d);
469 }
470
471 catch (ArgumentOutOfRangeException)
472 {
473 m_log.ErrorFormat(
474 "[REGIONINFO]: Neighbour Regions response included the current region in the neighbor list. The following region will not display to the client: {0} for region {1} ({2}, {3}).",
475 neighbour.ExternalHostName,
476 neighbour.RegionHandle,
477 neighbour.RegionLocX,
478 neighbour.RegionLocY);
479 }
480 catch (Exception e)
481 {
482 m_log.ErrorFormat(
483 "[REGIONINFO]: Could not resolve external hostname {0} for region {1} ({2}, {3}). {4}",
484 neighbour.ExternalHostName,
485 neighbour.RegionHandle,
486 neighbour.RegionLocX,
487 neighbour.RegionLocY,
488 e);
489
490 // FIXME: Okay, even though we've failed, we're still going to throw the exception on,
491 // since I don't know what will happen if we just let the client continue
492
493 // XXX: Well, decided to swallow the exception instead for now. Let us see how that goes.
494 // throw e;
495
496 }
497 }
498 count++;
499 }
500 }
501
502 /// <summary>
503 /// This informs a single neighboring region about agent "avatar".
504 /// Calls an asynchronous method to do so.. so it doesn't lag the sim.
505 /// </summary>
506 public void InformNeighborChildAgent(ScenePresence avatar, GridRegion region)
507 {
508 AgentCircuitData agent = avatar.ControllingClient.RequestClientInfo();
509 agent.BaseFolder = UUID.Zero;
510 agent.InventoryFolder = UUID.Zero;
511 agent.startpos = new Vector3(128, 128, 70);
512 agent.child = true;
513
514 InformClientOfNeighbourDelegate d = InformClientOfNeighbourAsync;
515 d.BeginInvoke(avatar, agent, region, region.ExternalEndPoint, true,
516 InformClientOfNeighbourCompleted,
517 d);
518 }
519
520 #endregion
521
522 public delegate void InformNeighbourThatRegionUpDelegate(INeighbourService nService, RegionInfo region, ulong regionhandle); 145 public delegate void InformNeighbourThatRegionUpDelegate(INeighbourService nService, RegionInfo region, ulong regionhandle);
523 146
524 private void InformNeighborsThatRegionisUpCompleted(IAsyncResult iar) 147 private void InformNeighborsThatRegionisUpCompleted(IAsyncResult iar)
@@ -550,7 +173,7 @@ namespace OpenSim.Region.Framework.Scenes
550 } 173 }
551 else 174 else
552 { 175 {
553 m_log.WarnFormat("[INTERGRID]: Failed to inform neighbour {0}-{1} that I'm here.", x / Constants.RegionSize, y / Constants.RegionSize); 176 m_log.InfoFormat("[INTERGRID]: Failed to inform neighbour {0}-{1} that I'm here.", x / Constants.RegionSize, y / Constants.RegionSize);
554 } 177 }
555 } 178 }
556 179
@@ -592,7 +215,10 @@ namespace OpenSim.Region.Framework.Scenes
592 try 215 try
593 { 216 {
594 //m_commsProvider.InterRegion.ChildAgentUpdate(regionHandle, cAgentData); 217 //m_commsProvider.InterRegion.ChildAgentUpdate(regionHandle, cAgentData);
595 m_interregionCommsOut.SendChildAgentUpdate(regionHandle, cAgentData); 218 uint x = 0, y = 0;
219 Utils.LongToUInts(regionHandle, out x, out y);
220 GridRegion destination = m_scene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y);
221 m_scene.SimulationService.UpdateAgent(destination, cAgentData);
596 } 222 }
597 catch 223 catch
598 { 224 {
@@ -652,7 +278,10 @@ namespace OpenSim.Region.Framework.Scenes
652 // let's do our best, but there's not much we can do if the neighbour doesn't accept. 278 // let's do our best, but there's not much we can do if the neighbour doesn't accept.
653 279
654 //m_commsProvider.InterRegion.TellRegionToCloseChildConnection(regionHandle, agentID); 280 //m_commsProvider.InterRegion.TellRegionToCloseChildConnection(regionHandle, agentID);
655 m_interregionCommsOut.SendCloseAgent(regionHandle, agentID); 281 uint x = 0, y = 0;
282 Utils.LongToUInts(regionHandle, out x, out y);
283 GridRegion destination = m_scene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y);
284 m_scene.SimulationService.CloseAgent(destination, agentID);
656 } 285 }
657 286
658 private void SendCloseChildAgentCompleted(IAsyncResult iar) 287 private void SendCloseChildAgentCompleted(IAsyncResult iar)
@@ -672,848 +301,10 @@ namespace OpenSim.Region.Framework.Scenes
672 } 301 }
673 } 302 }
674 303
675
676 /// <summary>
677 /// Try to teleport an agent to a new region.
678 /// </summary>
679 /// <param name="remoteClient"></param>
680 /// <param name="RegionHandle"></param>
681 /// <param name="position"></param>
682 /// <param name="lookAt"></param>
683 /// <param name="flags"></param>
684 public virtual void RequestTeleportToLocation(ScenePresence avatar, ulong regionHandle, Vector3 position,
685 Vector3 lookAt, uint teleportFlags)
686 {
687 if (!avatar.Scene.Permissions.CanTeleport(avatar.UUID))
688 return;
689
690 bool destRegionUp = true;
691
692 IEventQueue eq = avatar.Scene.RequestModuleInterface<IEventQueue>();
693
694 // Reset animations; the viewer does that in teleports.
695 avatar.Animator.ResetAnimations();
696
697 if (regionHandle == m_regionInfo.RegionHandle)
698 {
699 m_log.DebugFormat(
700 "[SCENE COMMUNICATION SERVICE]: RequestTeleportToLocation {0} within {1}",
701 position, m_regionInfo.RegionName);
702
703 // Teleport within the same region
704 if (IsOutsideRegion(avatar.Scene, position) || position.Z < 0)
705 {
706 Vector3 emergencyPos = new Vector3(128, 128, 128);
707
708 m_log.WarnFormat(
709 "[SCENE COMMUNICATION SERVICE]: RequestTeleportToLocation() was given an illegal position of {0} for avatar {1}, {2}. Substituting {3}",
710 position, avatar.Name, avatar.UUID, emergencyPos);
711 position = emergencyPos;
712 }
713
714 Vector3 currentPos = avatar.AbsolutePosition;
715 ILandObject srcLand = m_scene.LandChannel.GetLandObject(currentPos.X, currentPos.Y);
716 ILandObject destLand = m_scene.LandChannel.GetLandObject(position.X, position.Y);
717 if (srcLand != null && destLand != null && (teleportFlags & (uint)TeleportFlags.ViaLure) == 0 && (teleportFlags & (uint)TeleportFlags.ViaGodlikeLure) == 0)
718 {
719 if (srcLand.LandData.LocalID == destLand.LandData.LocalID)
720 {
721 //TPing within the same parcel. If the landing point is restricted, block the TP.
722 //Don't restrict gods, estate managers, or land owners to the TP point. This behaviour mimics agni.
723 if (destLand.LandData.LandingType == (byte)1 && destLand.LandData.UserLocation != Vector3.Zero && avatar.GodLevel < 200 && !m_scene.RegionInfo.EstateSettings.IsEstateManager(avatar.UUID) && destLand.LandData.OwnerID != avatar.UUID)
724 {
725 //Disabling this behaviour for now pending review. ~CasperW
726
727 //avatar.ControllingClient.SendAgentAlertMessage("Can't TP to the destination; landing point set.", false);
728 //position = currentPos;
729 }
730 }
731 else
732 {
733 //Tping to a different parcel. Respect the landing point on the destination parcel.
734 if (destLand.LandData.LandingType == (byte)1 && destLand.LandData.UserLocation != Vector3.Zero && avatar.GodLevel < 200 && !m_scene.RegionInfo.EstateSettings.IsEstateManager(avatar.UUID) && destLand.LandData.OwnerID != avatar.UUID)
735 {
736 position = destLand.LandData.UserLocation;
737 }
738 }
739 }
740
741 // TODO: Get proper AVG Height
742 float localAVHeight = 1.56f;
743 float posZLimit = 22;
744
745 // TODO: Check other Scene HeightField
746 if (position.X > 0 && position.X <= (int)Constants.RegionSize && position.Y > 0 && position.Y <=(int)Constants.RegionSize)
747 {
748 posZLimit = (float) avatar.Scene.Heightmap[(int) position.X, (int) position.Y];
749 }
750
751 float newPosZ = posZLimit + localAVHeight;
752 if (posZLimit >= (position.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ)))
753 {
754 position.Z = newPosZ;
755 }
756
757 // Only send this if the event queue is null
758 if (eq == null)
759 avatar.ControllingClient.SendTeleportLocationStart();
760
761 avatar.ControllingClient.SendLocalTeleport(position, lookAt, teleportFlags);
762 avatar.Teleport(position);
763 }
764 else
765 {
766 uint x = 0, y = 0;
767 Utils.LongToUInts(regionHandle, out x, out y);
768 GridRegion reg = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, (int)x, (int)y);
769
770 if (reg != null)
771 {
772 m_log.DebugFormat(
773 "[SCENE COMMUNICATION SERVICE]: RequestTeleportToLocation to {0} in {1}",
774 position, reg.RegionName);
775
776 if (eq == null)
777 avatar.ControllingClient.SendTeleportLocationStart();
778
779 // Let's do DNS resolution only once in this process, please!
780 // This may be a costly operation. The reg.ExternalEndPoint field is not a passive field,
781 // it's actually doing a lot of work.
782 IPEndPoint endPoint = reg.ExternalEndPoint;
783 if (endPoint.Address == null)
784 {
785 // Couldn't resolve the name. Can't TP, because the viewer wants IP addresses.
786 destRegionUp = false;
787 }
788
789 if (destRegionUp)
790 {
791 uint newRegionX = (uint)(reg.RegionHandle >> 40);
792 uint newRegionY = (((uint)(reg.RegionHandle)) >> 8);
793 uint oldRegionX = (uint)(m_regionInfo.RegionHandle >> 40);
794 uint oldRegionY = (((uint)(m_regionInfo.RegionHandle)) >> 8);
795
796 // Fixing a bug where teleporting while sitting results in the avatar ending up removed from
797 // both regions
798 if (avatar.ParentID != (uint)0)
799 avatar.StandUp();
800
801 if (!avatar.ValidateAttachments())
802 {
803 avatar.ControllingClient.SendTeleportFailed("Inconsistent attachment state");
804 return;
805 }
806
807 // the avatar.Close below will clear the child region list. We need this below for (possibly)
808 // closing the child agents, so save it here (we need a copy as it is Clear()-ed).
809 //List<ulong> childRegions = new List<ulong>(avatar.GetKnownRegionList());
810 // Compared to ScenePresence.CrossToNewRegion(), there's no obvious code to handle a teleport
811 // failure at this point (unlike a border crossing failure). So perhaps this can never fail
812 // once we reach here...
813 //avatar.Scene.RemoveCapsHandler(avatar.UUID);
814
815 string capsPath = String.Empty;
816 AgentCircuitData agentCircuit = avatar.ControllingClient.RequestClientInfo();
817 agentCircuit.BaseFolder = UUID.Zero;
818 agentCircuit.InventoryFolder = UUID.Zero;
819 agentCircuit.startpos = position;
820 agentCircuit.child = true;
821
822 if (Util.IsOutsideView(oldRegionX, newRegionX, oldRegionY, newRegionY))
823 {
824 // brand new agent, let's create a new caps seed
825 agentCircuit.CapsPath = CapsUtil.GetRandomCapsObjectPath();
826 }
827
828 string reason = String.Empty;
829
830 // Let's create an agent there if one doesn't exist yet.
831 //if (!m_commsProvider.InterRegion.InformRegionOfChildAgent(reg.RegionHandle, agentCircuit))
832 if (!m_interregionCommsOut.SendCreateChildAgent(reg.RegionHandle, agentCircuit, teleportFlags, out reason))
833 {
834 avatar.ControllingClient.SendTeleportFailed(String.Format("Destination is not accepting teleports: {0}",
835 reason));
836 return;
837 }
838
839 // OK, it got this agent. Let's close some child agents
840 avatar.CloseChildAgents(newRegionX, newRegionY);
841
842 if (Util.IsOutsideView(oldRegionX, newRegionX, oldRegionY, newRegionY))
843 {
844 #region IP Translation for NAT
845 IClientIPEndpoint ipepClient;
846 if (avatar.ClientView.TryGet(out ipepClient))
847 {
848 capsPath
849 = "http://"
850 + NetworkUtil.GetHostFor(ipepClient.EndPoint, reg.ExternalHostName)
851 + ":"
852 + reg.HttpPort
853 + CapsUtil.GetCapsSeedPath(agentCircuit.CapsPath);
854 }
855 else
856 {
857 capsPath
858 = "http://"
859 + reg.ExternalHostName
860 + ":"
861 + reg.HttpPort
862 + CapsUtil.GetCapsSeedPath(agentCircuit.CapsPath);
863 }
864 #endregion
865
866 if (eq != null)
867 {
868 #region IP Translation for NAT
869 // Uses ipepClient above
870 if (avatar.ClientView.TryGet(out ipepClient))
871 {
872 endPoint.Address = NetworkUtil.GetIPFor(ipepClient.EndPoint, endPoint.Address);
873 }
874 #endregion
875
876 eq.EnableSimulator(reg.RegionHandle, endPoint, avatar.UUID);
877
878 // ES makes the client send a UseCircuitCode message to the destination,
879 // which triggers a bunch of things there.
880 // So let's wait
881 Thread.Sleep(2000);
882
883 eq.EstablishAgentCommunication(avatar.UUID, endPoint, capsPath);
884 }
885 else
886 {
887 avatar.ControllingClient.InformClientOfNeighbour(reg.RegionHandle, endPoint);
888 }
889 }
890 else
891 {
892 agentCircuit.CapsPath = avatar.Scene.CapsModule.GetChildSeed(avatar.UUID, reg.RegionHandle);
893 capsPath = "http://" + reg.ExternalHostName + ":" + reg.HttpPort
894 + "/CAPS/" + agentCircuit.CapsPath + "0000/";
895 }
896
897 // Expect avatar crossing is a heavy-duty function at the destination.
898 // That is where MakeRoot is called, which fetches appearance and inventory.
899 // Plus triggers OnMakeRoot, which spawns a series of asynchronous updates.
900 //m_commsProvider.InterRegion.ExpectAvatarCrossing(reg.RegionHandle, avatar.ControllingClient.AgentId,
901 // position, false);
902
903 //{
904 // avatar.ControllingClient.SendTeleportFailed("Problem with destination.");
905 // // We should close that agent we just created over at destination...
906 // List<ulong> lst = new List<ulong>();
907 // lst.Add(reg.RegionHandle);
908 // SendCloseChildAgentAsync(avatar.UUID, lst);
909 // return;
910 //}
911
912 SetInTransit(avatar.UUID);
913 // Let's send a full update of the agent. This is a synchronous call.
914 AgentData agent = new AgentData();
915 avatar.CopyTo(agent);
916 agent.Position = position;
917 agent.CallbackURI = "http://" + m_regionInfo.ExternalHostName + ":" + m_regionInfo.HttpPort +
918 "/agent/" + avatar.UUID.ToString() + "/" + avatar.Scene.RegionInfo.RegionHandle.ToString() + "/release/";
919
920 m_interregionCommsOut.SendChildAgentUpdate(reg.RegionHandle, agent);
921
922 m_log.DebugFormat(
923 "[CAPS]: Sending new CAPS seed url {0} to client {1}", capsPath, avatar.UUID);
924
925
926 if (eq != null)
927 {
928 eq.TeleportFinishEvent(reg.RegionHandle, 13, endPoint,
929 0, teleportFlags, capsPath, avatar.UUID);
930 }
931 else
932 {
933 avatar.ControllingClient.SendRegionTeleport(reg.RegionHandle, 13, endPoint, 4,
934 teleportFlags, capsPath);
935 }
936
937 // TeleportFinish makes the client send CompleteMovementIntoRegion (at the destination), which
938 // trigers a whole shebang of things there, including MakeRoot. So let's wait for confirmation
939 // that the client contacted the destination before we send the attachments and close things here.
940 if (!WaitForCallback(avatar.UUID))
941 {
942 // Client never contacted destination. Let's restore everything back
943 avatar.ControllingClient.SendTeleportFailed("Problems connecting to destination.");
944
945 ResetFromTransit(avatar.UUID);
946
947 // Yikes! We should just have a ref to scene here.
948 avatar.Scene.InformClientOfNeighbours(avatar);
949
950 // Finally, kill the agent we just created at the destination.
951 m_interregionCommsOut.SendCloseAgent(reg.RegionHandle, avatar.UUID);
952
953 return;
954 }
955
956 // Can't go back from here
957 if (KiPrimitive != null)
958 {
959 KiPrimitive(avatar.LocalId);
960 }
961
962 avatar.MakeChildAgent();
963
964 // CrossAttachmentsIntoNewRegion is a synchronous call. We shouldn't need to wait after it
965 avatar.CrossAttachmentsIntoNewRegion(reg.RegionHandle, true);
966
967 // Finally, let's close this previously-known-as-root agent, when the jump is outside the view zone
968
969 if (Util.IsOutsideView(oldRegionX, newRegionX, oldRegionY, newRegionY))
970 {
971 Thread.Sleep(5000);
972 avatar.Close();
973 CloseConnection(avatar.UUID);
974 }
975 else
976 // now we have a child agent in this region.
977 avatar.Reset();
978
979
980 // if (teleport success) // seems to be always success here
981 // the user may change their profile information in other region,
982 // so the userinfo in UserProfileCache is not reliable any more, delete it
983 if (avatar.Scene.NeedSceneCacheClear(avatar.UUID))
984 {
985 m_commsProvider.UserProfileCacheService.RemoveUser(avatar.UUID);
986 m_log.DebugFormat(
987 "[SCENE COMMUNICATION SERVICE]: User {0} is going to another region, profile cache removed",
988 avatar.UUID);
989 }
990 }
991 else
992 {
993 avatar.ControllingClient.SendTeleportFailed("Remote Region appears to be down");
994 }
995 }
996 else
997 {
998 // TP to a place that doesn't exist (anymore)
999 // Inform the viewer about that
1000 avatar.ControllingClient.SendTeleportFailed("The region you tried to teleport to doesn't exist anymore");
1001
1002 // and set the map-tile to '(Offline)'
1003 uint regX, regY;
1004 Utils.LongToUInts(regionHandle, out regX, out regY);
1005
1006 MapBlockData block = new MapBlockData();
1007 block.X = (ushort)(regX / Constants.RegionSize);
1008 block.Y = (ushort)(regY / Constants.RegionSize);
1009 block.Access = 254; // == not there
1010
1011 List<MapBlockData> blocks = new List<MapBlockData>();
1012 blocks.Add(block);
1013 avatar.ControllingClient.SendMapBlock(blocks, 0);
1014 }
1015 }
1016 }
1017
1018 protected bool IsOutsideRegion(Scene s, Vector3 pos)
1019 {
1020
1021 if (s.TestBorderCross(pos,Cardinals.N))
1022 return true;
1023 if (s.TestBorderCross(pos, Cardinals.S))
1024 return true;
1025 if (s.TestBorderCross(pos, Cardinals.E))
1026 return true;
1027 if (s.TestBorderCross(pos, Cardinals.W))
1028 return true;
1029
1030 return false;
1031 }
1032
1033 public bool WaitForCallback(UUID id)
1034 {
1035 int count = 400;
1036 while (m_agentsInTransit.Contains(id) && count-- > 0)
1037 {
1038 //m_log.Debug(" >>> Waiting... " + count);
1039 Thread.Sleep(100);
1040 }
1041
1042 if (count > 0)
1043 return true;
1044 else
1045 return false;
1046 }
1047
1048 public bool ReleaseAgent(UUID id)
1049 {
1050 //m_log.Debug(" >>> ReleaseAgent called <<< ");
1051 return ResetFromTransit(id);
1052 }
1053
1054 public void SetInTransit(UUID id)
1055 {
1056 lock (m_agentsInTransit)
1057 {
1058 if (!m_agentsInTransit.Contains(id))
1059 m_agentsInTransit.Add(id);
1060 }
1061 }
1062
1063 protected bool ResetFromTransit(UUID id)
1064 {
1065 lock (m_agentsInTransit)
1066 {
1067 if (m_agentsInTransit.Contains(id))
1068 {
1069 m_agentsInTransit.Remove(id);
1070 return true;
1071 }
1072 }
1073 return false;
1074 }
1075
1076 private List<ulong> NeighbourHandles(List<GridRegion> neighbours)
1077 {
1078 List<ulong> handles = new List<ulong>();
1079 foreach (GridRegion reg in neighbours)
1080 {
1081 handles.Add(reg.RegionHandle);
1082 }
1083 return handles;
1084 }
1085
1086 private List<ulong> NewNeighbours(List<ulong> currentNeighbours, List<ulong> previousNeighbours)
1087 {
1088 return currentNeighbours.FindAll(delegate(ulong handle) { return !previousNeighbours.Contains(handle); });
1089 }
1090
1091// private List<ulong> CommonNeighbours(List<ulong> currentNeighbours, List<ulong> previousNeighbours)
1092// {
1093// return currentNeighbours.FindAll(delegate(ulong handle) { return previousNeighbours.Contains(handle); });
1094// }
1095
1096 private List<ulong> OldNeighbours(List<ulong> currentNeighbours, List<ulong> previousNeighbours)
1097 {
1098 return previousNeighbours.FindAll(delegate(ulong handle) { return !currentNeighbours.Contains(handle); });
1099 }
1100
1101 public void CrossAgentToNewRegion(Scene scene, ScenePresence agent, bool isFlying)
1102 {
1103 Vector3 pos = agent.AbsolutePosition;
1104 Vector3 newpos = new Vector3(pos.X, pos.Y, pos.Z);
1105 uint neighbourx = m_regionInfo.RegionLocX;
1106 uint neighboury = m_regionInfo.RegionLocY;
1107 const float boundaryDistance = 1.7f;
1108 Vector3 northCross = new Vector3(0,boundaryDistance, 0);
1109 Vector3 southCross = new Vector3(0, -1 * boundaryDistance, 0);
1110 Vector3 eastCross = new Vector3(boundaryDistance, 0, 0);
1111 Vector3 westCross = new Vector3(-1 * boundaryDistance, 0, 0);
1112
1113 // distance to edge that will trigger crossing
1114
1115
1116 // distance into new region to place avatar
1117 const float enterDistance = 0.5f;
1118
1119 if (scene.TestBorderCross(pos + westCross, Cardinals.W))
1120 {
1121 if (scene.TestBorderCross(pos + northCross, Cardinals.N))
1122 {
1123 Border b = scene.GetCrossedBorder(pos + northCross, Cardinals.N);
1124 neighboury += (uint)(int)(b.BorderLine.Z / (int)Constants.RegionSize);
1125 }
1126 else if (scene.TestBorderCross(pos + southCross, Cardinals.S))
1127 {
1128 Border b = scene.GetCrossedBorder(pos + southCross, Cardinals.S);
1129 if (b.TriggerRegionX == 0 && b.TriggerRegionY == 0)
1130 {
1131 neighboury--;
1132 newpos.Y = Constants.RegionSize - enterDistance;
1133 }
1134 else
1135 {
1136 neighboury = b.TriggerRegionY;
1137 neighbourx = b.TriggerRegionX;
1138
1139 Vector3 newposition = pos;
1140 newposition.X += (scene.RegionInfo.RegionLocX - neighbourx) * Constants.RegionSize;
1141 newposition.Y += (scene.RegionInfo.RegionLocY - neighboury) * Constants.RegionSize;
1142 agent.ControllingClient.SendAgentAlertMessage(
1143 String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false);
1144 InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene);
1145 return;
1146 }
1147 }
1148
1149 Border ba = scene.GetCrossedBorder(pos + westCross, Cardinals.W);
1150 if (ba.TriggerRegionX == 0 && ba.TriggerRegionY == 0)
1151 {
1152 neighbourx--;
1153 newpos.X = Constants.RegionSize - enterDistance;
1154 }
1155 else
1156 {
1157 neighboury = ba.TriggerRegionY;
1158 neighbourx = ba.TriggerRegionX;
1159
1160
1161 Vector3 newposition = pos;
1162 newposition.X += (scene.RegionInfo.RegionLocX - neighbourx) * Constants.RegionSize;
1163 newposition.Y += (scene.RegionInfo.RegionLocY - neighboury) * Constants.RegionSize;
1164 agent.ControllingClient.SendAgentAlertMessage(
1165 String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false);
1166 InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene);
1167
1168
1169 return;
1170 }
1171
1172 }
1173 else if (scene.TestBorderCross(pos + eastCross, Cardinals.E))
1174 {
1175 Border b = scene.GetCrossedBorder(pos + eastCross, Cardinals.E);
1176 neighbourx += (uint)(int)(b.BorderLine.Z / (int)Constants.RegionSize);
1177 newpos.X = enterDistance;
1178
1179 if (scene.TestBorderCross(pos + southCross, Cardinals.S))
1180 {
1181 Border ba = scene.GetCrossedBorder(pos + southCross, Cardinals.S);
1182 if (ba.TriggerRegionX == 0 && ba.TriggerRegionY == 0)
1183 {
1184 neighboury--;
1185 newpos.Y = Constants.RegionSize - enterDistance;
1186 }
1187 else
1188 {
1189 neighboury = ba.TriggerRegionY;
1190 neighbourx = ba.TriggerRegionX;
1191 Vector3 newposition = pos;
1192 newposition.X += (scene.RegionInfo.RegionLocX - neighbourx) * Constants.RegionSize;
1193 newposition.Y += (scene.RegionInfo.RegionLocY - neighboury) * Constants.RegionSize;
1194 agent.ControllingClient.SendAgentAlertMessage(
1195 String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false);
1196 InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene);
1197 return;
1198 }
1199 }
1200 else if (scene.TestBorderCross(pos + northCross, Cardinals.N))
1201 {
1202 Border c = scene.GetCrossedBorder(pos + northCross, Cardinals.N);
1203 neighboury += (uint)(int)(c.BorderLine.Z / (int)Constants.RegionSize);
1204 newpos.Y = enterDistance;
1205 }
1206
1207
1208 }
1209 else if (scene.TestBorderCross(pos + southCross, Cardinals.S))
1210 {
1211 Border b = scene.GetCrossedBorder(pos + southCross, Cardinals.S);
1212 if (b.TriggerRegionX == 0 && b.TriggerRegionY == 0)
1213 {
1214 neighboury--;
1215 newpos.Y = Constants.RegionSize - enterDistance;
1216 }
1217 else
1218 {
1219 neighboury = b.TriggerRegionY;
1220 neighbourx = b.TriggerRegionX;
1221 Vector3 newposition = pos;
1222 newposition.X += (scene.RegionInfo.RegionLocX - neighbourx) * Constants.RegionSize;
1223 newposition.Y += (scene.RegionInfo.RegionLocY - neighboury) * Constants.RegionSize;
1224 agent.ControllingClient.SendAgentAlertMessage(
1225 String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false);
1226 InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene);
1227 return;
1228 }
1229 }
1230 else if (scene.TestBorderCross(pos + northCross, Cardinals.N))
1231 {
1232
1233 Border b = scene.GetCrossedBorder(pos + northCross, Cardinals.N);
1234 neighboury += (uint)(int)(b.BorderLine.Z / (int)Constants.RegionSize);
1235 newpos.Y = enterDistance;
1236 }
1237
1238 /*
1239
1240 if (pos.X < boundaryDistance) //West
1241 {
1242 neighbourx--;
1243 newpos.X = Constants.RegionSize - enterDistance;
1244 }
1245 else if (pos.X > Constants.RegionSize - boundaryDistance) // East
1246 {
1247 neighbourx++;
1248 newpos.X = enterDistance;
1249 }
1250
1251 if (pos.Y < boundaryDistance) // South
1252 {
1253 neighboury--;
1254 newpos.Y = Constants.RegionSize - enterDistance;
1255 }
1256 else if (pos.Y > Constants.RegionSize - boundaryDistance) // North
1257 {
1258 neighboury++;
1259 newpos.Y = enterDistance;
1260 }
1261 */
1262
1263 CrossAgentToNewRegionDelegate d = CrossAgentToNewRegionAsync;
1264 d.BeginInvoke(agent, newpos, neighbourx, neighboury, isFlying, CrossAgentToNewRegionCompleted, d);
1265 }
1266
1267 public delegate void InformClientToInitateTeleportToLocationDelegate(ScenePresence agent, uint regionX, uint regionY,
1268 Vector3 position,
1269 Scene initiatingScene);
1270
1271 public void InformClientToInitateTeleportToLocation(ScenePresence agent, uint regionX, uint regionY, Vector3 position,
1272 Scene initiatingScene)
1273 {
1274
1275 // This assumes that we know what our neighbors are.
1276
1277 InformClientToInitateTeleportToLocationDelegate d = InformClientToInitiateTeleportToLocationAsync;
1278 d.BeginInvoke(agent,regionX,regionY,position,initiatingScene,
1279 InformClientToInitiateTeleportToLocationCompleted,
1280 d);
1281 }
1282
1283 public void InformClientToInitiateTeleportToLocationAsync(ScenePresence agent, uint regionX, uint regionY, Vector3 position,
1284 Scene initiatingScene)
1285 {
1286 Thread.Sleep(10000);
1287 IMessageTransferModule im = initiatingScene.RequestModuleInterface<IMessageTransferModule>();
1288 if (im != null)
1289 {
1290 UUID gotoLocation = Util.BuildFakeParcelID(
1291 Util.UIntsToLong(
1292 (regionX *
1293 (uint)Constants.RegionSize),
1294 (regionY *
1295 (uint)Constants.RegionSize)),
1296 (uint)(int)position.X,
1297 (uint)(int)position.Y,
1298 (uint)(int)position.Z);
1299 GridInstantMessage m = new GridInstantMessage(initiatingScene, UUID.Zero,
1300 "Region", agent.UUID,
1301 (byte)InstantMessageDialog.GodLikeRequestTeleport, false,
1302 "", gotoLocation, false, new Vector3(127, 0, 0),
1303 new Byte[0]);
1304 im.SendInstantMessage(m, delegate(bool success)
1305 {
1306 m_log.DebugFormat("[CLIENT]: Client Initiating Teleport sending IM success = {0}", success);
1307 });
1308
1309 }
1310 }
1311
1312 private void InformClientToInitiateTeleportToLocationCompleted(IAsyncResult iar)
1313 {
1314 InformClientToInitateTeleportToLocationDelegate icon =
1315 (InformClientToInitateTeleportToLocationDelegate) iar.AsyncState;
1316 icon.EndInvoke(iar);
1317 }
1318
1319 public delegate ScenePresence CrossAgentToNewRegionDelegate(ScenePresence agent, Vector3 pos, uint neighbourx, uint neighboury, bool isFlying);
1320
1321 /// <summary>
1322 /// This Closes child agents on neighboring regions
1323 /// Calls an asynchronous method to do so.. so it doesn't lag the sim.
1324 /// </summary>
1325 protected ScenePresence CrossAgentToNewRegionAsync(ScenePresence agent, Vector3 pos, uint neighbourx, uint neighboury, bool isFlying)
1326 {
1327 m_log.DebugFormat("[SCENE COMM]: Crossing agent {0} {1} to {2}-{3}", agent.Firstname, agent.Lastname, neighbourx, neighboury);
1328
1329 ulong neighbourHandle = Utils.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize));
1330
1331 int x = (int)(neighbourx * Constants.RegionSize), y = (int)(neighboury * Constants.RegionSize);
1332 GridRegion neighbourRegion = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, (int)x, (int)y);
1333
1334 if (neighbourRegion != null && agent.ValidateAttachments())
1335 {
1336 pos = pos + (agent.Velocity);
1337
1338 //CachedUserInfo userInfo = m_commsProvider.UserProfileCacheService.GetUserDetails(agent.UUID);
1339 //if (userInfo != null)
1340 //{
1341 // userInfo.DropInventory();
1342 //}
1343 //else
1344 //{
1345 // m_log.WarnFormat("[SCENE COMM]: No cached user info found for {0} {1} on leaving region {2}",
1346 // agent.Name, agent.UUID, agent.Scene.RegionInfo.RegionName);
1347 //}
1348
1349 //bool crossingSuccessful =
1350 // CrossToNeighbouringRegion(neighbourHandle, agent.ControllingClient.AgentId, pos,
1351 //isFlying);
1352
1353 SetInTransit(agent.UUID);
1354 AgentData cAgent = new AgentData();
1355 agent.CopyTo(cAgent);
1356 cAgent.Position = pos;
1357 if (isFlying)
1358 cAgent.ControlFlags |= (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY;
1359 cAgent.CallbackURI = "http://" + m_regionInfo.ExternalHostName + ":" + m_regionInfo.HttpPort +
1360 "/agent/" + agent.UUID.ToString() + "/" + agent.Scene.RegionInfo.RegionHandle.ToString() + "/release/";
1361
1362 m_interregionCommsOut.SendChildAgentUpdate(neighbourHandle, cAgent);
1363
1364 // Next, let's close the child agent connections that are too far away.
1365 agent.CloseChildAgents(neighbourx, neighboury);
1366
1367 //AgentCircuitData circuitdata = m_controllingClient.RequestClientInfo();
1368 agent.ControllingClient.RequestClientInfo();
1369
1370 //m_log.Debug("BEFORE CROSS");
1371 //Scene.DumpChildrenSeeds(UUID);
1372 //DumpKnownRegions();
1373 string agentcaps;
1374 if (!agent.KnownRegions.TryGetValue(neighbourRegion.RegionHandle, out agentcaps))
1375 {
1376 m_log.ErrorFormat("[SCENE COMM]: No CAPS information for region handle {0}, exiting CrossToNewRegion.",
1377 neighbourRegion.RegionHandle);
1378 return agent;
1379 }
1380 // TODO Should construct this behind a method
1381 string capsPath =
1382 "http://" + neighbourRegion.ExternalHostName + ":" + neighbourRegion.HttpPort
1383 + "/CAPS/" + agentcaps /*circuitdata.CapsPath*/ + "0000/";
1384
1385 m_log.DebugFormat("[CAPS]: Sending new CAPS seed url {0} to client {1}", capsPath, agent.UUID);
1386
1387 IEventQueue eq = agent.Scene.RequestModuleInterface<IEventQueue>();
1388 if (eq != null)
1389 {
1390 eq.CrossRegion(neighbourHandle, pos, agent.Velocity, neighbourRegion.ExternalEndPoint,
1391 capsPath, agent.UUID, agent.ControllingClient.SessionId);
1392 }
1393 else
1394 {
1395 agent.ControllingClient.CrossRegion(neighbourHandle, pos, agent.Velocity, neighbourRegion.ExternalEndPoint,
1396 capsPath);
1397 }
1398
1399 if (!WaitForCallback(agent.UUID))
1400 {
1401 ResetFromTransit(agent.UUID);
1402
1403 // Yikes! We should just have a ref to scene here.
1404 agent.Scene.InformClientOfNeighbours(agent);
1405
1406 return agent;
1407 }
1408
1409 agent.MakeChildAgent();
1410 // now we have a child agent in this region. Request all interesting data about other (root) agents
1411 agent.SendInitialFullUpdateToAllClients();
1412
1413 agent.CrossAttachmentsIntoNewRegion(neighbourHandle, true);
1414
1415 // m_scene.SendKillObject(m_localId);
1416
1417 agent.Scene.NotifyMyCoarseLocationChange();
1418 // the user may change their profile information in other region,
1419 // so the userinfo in UserProfileCache is not reliable any more, delete it
1420 if (agent.Scene.NeedSceneCacheClear(agent.UUID))
1421 {
1422 agent.Scene.CommsManager.UserProfileCacheService.RemoveUser(agent.UUID);
1423 m_log.DebugFormat(
1424 "[SCENE COMM]: User {0} is going to another region, profile cache removed", agent.UUID);
1425 }
1426 }
1427
1428 //m_log.Debug("AFTER CROSS");
1429 //Scene.DumpChildrenSeeds(UUID);
1430 //DumpKnownRegions();
1431 return agent;
1432 }
1433
1434 private void CrossAgentToNewRegionCompleted(IAsyncResult iar)
1435 {
1436 CrossAgentToNewRegionDelegate icon = (CrossAgentToNewRegionDelegate)iar.AsyncState;
1437 ScenePresence agent = icon.EndInvoke(iar);
1438
1439 // If the cross was successful, this agent is a child agent
1440 if (agent.IsChildAgent)
1441 {
1442 agent.Reset();
1443 }
1444 else // Not successful
1445 {
1446 //CachedUserInfo userInfo = m_commsProvider.UserProfileCacheService.GetUserDetails(agent.UUID);
1447 //if (userInfo != null)
1448 //{
1449 // userInfo.FetchInventory();
1450 //}
1451 agent.RestoreInCurrentScene();
1452 }
1453 // In any case
1454 agent.NotInTransit();
1455
1456 //m_log.DebugFormat("[SCENE COMM]: Crossing agent {0} {1} completed.", agent.Firstname, agent.Lastname);
1457 }
1458
1459
1460 public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, Vector3 position, Vector3 lookat)
1461 {
1462 m_commsProvider.LogOffUser(userid, regionid, regionhandle, position, lookat);
1463 }
1464
1465 // deprecated as of 2008-08-27
1466 public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, float posx, float posy, float posz)
1467 {
1468 m_commsProvider.LogOffUser(userid, regionid, regionhandle, posx, posy, posz);
1469 }
1470
1471 public void ClearUserAgent(UUID avatarID)
1472 {
1473 m_commsProvider.UserService.ClearUserAgent(avatarID);
1474 }
1475
1476 public void AddNewUserFriend(UUID friendlistowner, UUID friend, uint perms)
1477 {
1478 m_commsProvider.AddNewUserFriend(friendlistowner, friend, perms);
1479 }
1480
1481 public void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms)
1482 {
1483 m_commsProvider.UpdateUserFriendPerms(friendlistowner, friend, perms);
1484 }
1485
1486 public void RemoveUserFriend(UUID friendlistowner, UUID friend)
1487 {
1488 m_commsProvider.RemoveUserFriend(friendlistowner, friend);
1489 }
1490
1491 public List<FriendListItem> GetUserFriendList(UUID friendlistowner)
1492 {
1493 return m_commsProvider.GetUserFriendList(friendlistowner);
1494 }
1495
1496 public List<AvatarPickerAvatar> GenerateAgentPickerRequestResponse(UUID queryID, string query)
1497 {
1498 return m_commsProvider.GenerateAgentPickerRequestResponse(queryID, query);
1499 }
1500
1501 public List<GridRegion> RequestNamedRegions(string name, int maxNumber) 304 public List<GridRegion> RequestNamedRegions(string name, int maxNumber)
1502 { 305 {
1503 return m_scene.GridService.GetRegionsByName(UUID.Zero, name, maxNumber); 306 return m_scene.GridService.GetRegionsByName(UUID.Zero, name, maxNumber);
1504 } 307 }
1505 308
1506 //private void Dump(string msg, List<ulong> handles)
1507 //{
1508 // m_log.InfoFormat("-------------- HANDLE DUMP ({0}) ---------", msg);
1509 // foreach (ulong handle in handles)
1510 // {
1511 // uint x, y;
1512 // Utils.LongToUInts(handle, out x, out y);
1513 // x = x / Constants.RegionSize;
1514 // y = y / Constants.RegionSize;
1515 // m_log.InfoFormat("({0}, {1})", x, y);
1516 // }
1517 //}
1518 } 309 }
1519} 310}
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index bbcb85e..3a1962c 100644
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -35,6 +35,7 @@ using log4net;
35using OpenSim.Framework; 35using OpenSim.Framework;
36using OpenSim.Region.Framework.Scenes.Types; 36using OpenSim.Region.Framework.Scenes.Types;
37using OpenSim.Region.Physics.Manager; 37using OpenSim.Region.Physics.Manager;
38using OpenSim.Region.Framework.Interfaces;
38 39
39namespace OpenSim.Region.Framework.Scenes 40namespace OpenSim.Region.Framework.Scenes
40{ 41{
@@ -164,9 +165,10 @@ namespace OpenSim.Region.Framework.Scenes
164 165
165 protected internal void UpdatePresences() 166 protected internal void UpdatePresences()
166 { 167 {
167 ScenePresence[] updateScenePresences = GetScenePresences(); 168 ForEachScenePresence(delegate(ScenePresence presence)
168 for (int i = 0; i < updateScenePresences.Length; i++) 169 {
169 updateScenePresences[i].Update(); 170 presence.Update();
171 });
170 } 172 }
171 173
172 protected internal float UpdatePhysics(double elapsed) 174 protected internal float UpdatePhysics(double elapsed)
@@ -195,9 +197,10 @@ namespace OpenSim.Region.Framework.Scenes
195 197
196 protected internal void UpdateScenePresenceMovement() 198 protected internal void UpdateScenePresenceMovement()
197 { 199 {
198 ScenePresence[] moveEntities = GetScenePresences(); 200 ForEachScenePresence(delegate(ScenePresence presence)
199 for (int i = 0; i < moveEntities.Length; i++) 201 {
200 moveEntities[i].UpdateMovement(); 202 presence.UpdateMovement();
203 });
201 } 204 }
202 205
203 #endregion 206 #endregion
@@ -475,7 +478,7 @@ namespace OpenSim.Region.Framework.Scenes
475 if (group != null) 478 if (group != null)
476 { 479 {
477 //group.DetachToGround(); 480 //group.DetachToGround();
478 m_parentScene.DetachSingleAttachmentToInv(group.GetFromItemID(), remoteClient); 481 m_parentScene.AttachmentsModule.ShowDetachInUserInventory(group.GetFromItemID(), remoteClient);
479 } 482 }
480 } 483 }
481 484
@@ -509,212 +512,6 @@ namespace OpenSim.Region.Framework.Scenes
509 } 512 }
510 } 513 }
511 514
512 /// <summary>
513 /// Event Handling routine for Attach Object
514 /// </summary>
515 /// <param name="remoteClient"></param>
516 /// <param name="objectLocalID"></param>
517 /// <param name="AttachmentPt"></param>
518 /// <param name="rot"></param>
519 protected internal void AttachObject(IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, Quaternion rot, bool silent)
520 {
521 // If we can't take it, we can't attach it!
522 SceneObjectPart part = m_parentScene.GetSceneObjectPart(objectLocalID);
523 if (part == null)
524 return;
525
526 if (!m_parentScene.Permissions.CanTakeObject(part.UUID, remoteClient.AgentId))
527 return;
528
529 // Calls attach with a Zero position
530 if (AttachObject(remoteClient, objectLocalID, AttachmentPt, rot, Vector3.Zero, false))
531 {
532 m_parentScene.SendAttachEvent(objectLocalID, part.ParentGroup.GetFromItemID(), remoteClient.AgentId);
533
534 // Save avatar attachment information
535 ScenePresence presence;
536 if (m_parentScene.AvatarFactory != null && m_parentScene.TryGetAvatar(remoteClient.AgentId, out presence))
537 {
538 m_log.Info(
539 "[SCENE]: Saving avatar attachment. AgentID: " + remoteClient.AgentId
540 + ", AttachmentPoint: " + AttachmentPt);
541
542 m_parentScene.AvatarFactory.UpdateDatabase(remoteClient.AgentId, presence.Appearance);
543 }
544 }
545 }
546
547 /// <summary>
548 /// Rez an attachment
549 /// </summary>
550 /// <param name="remoteClient"></param>
551 /// <param name="itemID"></param>
552 /// <param name="AttachmentPt"></param>
553 /// <returns>The scene object that was attached. Null if the scene object could not be found</returns>
554 public SceneObjectGroup RezSingleAttachment(IClientAPI remoteClient, UUID itemID, uint AttachmentPt)
555 {
556 SceneObjectGroup objatt = m_parentScene.RezObject(remoteClient,
557 itemID, Vector3.Zero, Vector3.Zero, UUID.Zero, (byte)1, true,
558 false, false, remoteClient.AgentId, true);
559
560// m_log.DebugFormat(
561// "[SCENE GRAPH]: Retrieved single object {0} for attachment to {1} on point {2}",
562// objatt.Name, remoteClient.Name, AttachmentPt);
563
564 if (objatt != null)
565 {
566 bool tainted = false;
567 if (AttachmentPt != 0 && AttachmentPt != objatt.GetAttachmentPoint())
568 tainted = true;
569
570 AttachObject(remoteClient, objatt.LocalId, AttachmentPt, Quaternion.Identity, objatt.AbsolutePosition, false);
571 //objatt.ScheduleGroupForFullUpdate();
572
573 if (tainted)
574 objatt.HasGroupChanged = true;
575
576 // Fire after attach, so we don't get messy perms dialogs
577 // 3 == AttachedRez
578 objatt.CreateScriptInstances(0, true, m_parentScene.DefaultScriptEngine, 3);
579
580 // Do this last so that event listeners have access to all the effects of the attachment
581 m_parentScene.EventManager.TriggerOnAttach(objatt.LocalId, itemID, remoteClient.AgentId);
582 }
583 else
584 {
585 m_log.WarnFormat(
586 "[SCENE GRAPH]: Could not retrieve item {0} for attaching to avatar {1} at point {2}",
587 itemID, remoteClient.Name, AttachmentPt);
588 }
589
590 return objatt;
591 }
592
593 // What makes this method odd and unique is it tries to detach using an UUID.... Yay for standards.
594 // To LocalId or UUID, *THAT* is the question. How now Brown UUID??
595 public void DetachSingleAttachmentToInv(UUID itemID, IClientAPI remoteClient)
596 {
597 if (itemID == UUID.Zero) // If this happened, someone made a mistake....
598 return;
599
600 // We can NOT use the dictionries here, as we are looking
601 // for an entity by the fromAssetID, which is NOT the prim UUID
602 //
603 List<EntityBase> detachEntities = GetEntities();
604 SceneObjectGroup group;
605
606 foreach (EntityBase entity in detachEntities)
607 {
608 if (entity is SceneObjectGroup)
609 {
610 group = (SceneObjectGroup)entity;
611 if (group.GetFromItemID() == itemID)
612 {
613 m_parentScene.SendAttachEvent(group.LocalId, itemID, UUID.Zero);
614 bool hasScripts = false;
615 foreach (SceneObjectPart part in group.Children.Values)
616 {
617 if (part.Inventory.ContainsScripts())
618 {
619 hasScripts = true;
620 break;
621 }
622 }
623
624 if (hasScripts) // Allow the object to execute the attach(NULL_KEY) event
625 System.Threading.Thread.Sleep(100);
626 group.DetachToInventoryPrep();
627 m_log.Debug("[DETACH]: Saving attachpoint: " +
628 ((uint)group.GetAttachmentPoint()).ToString());
629 m_parentScene.UpdateKnownItem(remoteClient, group,
630 group.GetFromItemID(), group.OwnerID);
631 m_parentScene.DeleteSceneObject(group, false);
632 return;
633 }
634 }
635 }
636 }
637
638 /// <summary>
639 /// Attach a scene object to an avatar.
640 /// </summary>
641 /// <param name="remoteClient"></param>
642 /// <param name="objectLocalID"></param>
643 /// <param name="AttachmentPt"></param>
644 /// <param name="rot"></param>
645 /// <param name="attachPos"></param>
646 /// <param name="silent"></param>
647 /// <returns>true if the attachment was successful, false otherwise</returns>
648 protected internal bool AttachObject(
649 IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, Quaternion rot, Vector3 attachPos, bool silent)
650 {
651 SceneObjectGroup group = GetGroupByPrim(objectLocalID);
652 if (group != null)
653 {
654 if (m_parentScene.Permissions.CanTakeObject(group.UUID, remoteClient.AgentId))
655 {
656 // If the attachment point isn't the same as the one previously used
657 // set it's offset position = 0 so that it appears on the attachment point
658 // and not in a weird location somewhere unknown.
659 if (AttachmentPt != 0 && AttachmentPt != (uint)group.GetAttachmentPoint())
660 {
661 attachPos = Vector3.Zero;
662 }
663
664 // AttachmentPt 0 means the client chose to 'wear' the attachment.
665 if (AttachmentPt == 0)
666 {
667 // Check object for stored attachment point
668 AttachmentPt = (uint)group.GetAttachmentPoint();
669 }
670
671 // if we still didn't find a suitable attachment point.......
672 if (AttachmentPt == 0)
673 {
674 // Stick it on left hand with Zero Offset from the attachment point.
675 AttachmentPt = (uint)AttachmentPoint.LeftHand;
676 attachPos = Vector3.Zero;
677 }
678
679 group.SetAttachmentPoint((byte)AttachmentPt);
680 group.AbsolutePosition = attachPos;
681
682 // Saves and gets itemID
683 UUID itemId;
684
685 if (group.GetFromItemID() == UUID.Zero)
686 {
687 m_parentScene.attachObjectAssetStore(remoteClient, group, remoteClient.AgentId, out itemId);
688 }
689 else
690 {
691 itemId = group.GetFromItemID();
692 }
693
694 m_parentScene.AttachObject(remoteClient, AttachmentPt, itemId, group);
695
696 group.AttachToAgent(remoteClient.AgentId, AttachmentPt, attachPos, silent);
697 // In case it is later dropped again, don't let
698 // it get cleaned up
699 //
700 group.RootPart.RemFlag(PrimFlags.TemporaryOnRez);
701 group.HasGroupChanged = false;
702 }
703 else
704 {
705 remoteClient.SendAgentAlertMessage("You don't have sufficient permissions to attach this object", false);
706 return false;
707 }
708 }
709 else
710 {
711 m_log.DebugFormat("[SCENE GRAPH]: AttachObject found no such scene object {0}", objectLocalID);
712 return false;
713 }
714
715 return true;
716 }
717
718 protected internal ScenePresence CreateAndAddChildScenePresence(IClientAPI client, AvatarAppearance appearance) 515 protected internal ScenePresence CreateAndAddChildScenePresence(IClientAPI client, AvatarAppearance appearance)
719 { 516 {
720 ScenePresence newAvatar = null; 517 ScenePresence newAvatar = null;
@@ -845,18 +642,16 @@ namespace OpenSim.Region.Framework.Scenes
845 642
846 public void RecalculateStats() 643 public void RecalculateStats()
847 { 644 {
848 ScenePresence[] presences = GetScenePresences();
849 int rootcount = 0; 645 int rootcount = 0;
850 int childcount = 0; 646 int childcount = 0;
851 647
852 for (int i = 0; i < presences.Length; i++) 648 ForEachScenePresence(delegate(ScenePresence presence)
853 { 649 {
854 ScenePresence user = presences[i]; 650 if (presence.IsChildAgent)
855 if (user.IsChildAgent)
856 ++childcount; 651 ++childcount;
857 else 652 else
858 ++rootcount; 653 ++rootcount;
859 } 654 });
860 655
861 m_numRootAgents = rootcount; 656 m_numRootAgents = rootcount;
862 m_numChildAgents = childcount; 657 m_numChildAgents = childcount;
@@ -903,25 +698,6 @@ namespace OpenSim.Region.Framework.Scenes
903 #endregion 698 #endregion
904 699
905 #region Get Methods 700 #region Get Methods
906
907 /// <summary>
908 /// Request a List of all scene presences in this scene. This is a new list, so no
909 /// locking is required to iterate over it.
910 /// </summary>
911 /// <returns></returns>
912 protected internal ScenePresence[] GetScenePresences()
913 {
914 return m_scenePresenceArray;
915 }
916
917 protected internal List<ScenePresence> GetAvatars()
918 {
919 List<ScenePresence> result =
920 GetScenePresences(delegate(ScenePresence scenePresence) { return !scenePresence.IsChildAgent; });
921
922 return result;
923 }
924
925 /// <summary> 701 /// <summary>
926 /// Get the controlling client for the given avatar, if there is one. 702 /// Get the controlling client for the given avatar, if there is one.
927 /// 703 ///
@@ -948,41 +724,83 @@ namespace OpenSim.Region.Framework.Scenes
948 } 724 }
949 725
950 /// <summary> 726 /// <summary>
951 /// Request a filtered list of m_scenePresences in this World 727 /// Request a copy of m_scenePresences in this World
728 /// There is no guarantee that presences will remain in the scene after the list is returned.
729 /// This list should remain private to SceneGraph. Callers wishing to iterate should instead
730 /// pass a delegate to ForEachScenePresence.
952 /// </summary> 731 /// </summary>
953 /// <returns></returns> 732 /// <returns></returns>
954 protected internal List<ScenePresence> GetScenePresences(FilterAvatarList filter) 733 private List<ScenePresence> GetScenePresences()
955 { 734 {
956 // No locking of scene presences here since we're passing back a list... 735 lock (m_scenePresences)
957 736 return new List<ScenePresence>(m_scenePresenceArray);
958 List<ScenePresence> result = new List<ScenePresence>(); 737 }
959 ScenePresence[] scenePresences = GetScenePresences();
960 738
961 for (int i = 0; i < scenePresences.Length; i++) 739 /// <summary>
740 /// Request a scene presence by UUID. Fast, indexed lookup.
741 /// </summary>
742 /// <param name="agentID"></param>
743 /// <returns>null if the presence was not found</returns>
744 protected internal ScenePresence GetScenePresence(UUID agentID)
745 {
746 ScenePresence sp;
747 lock (m_scenePresences)
962 { 748 {
963 ScenePresence avatar = scenePresences[i]; 749 m_scenePresences.TryGetValue(agentID, out sp);
964 if (filter(avatar))
965 result.Add(avatar);
966 } 750 }
751 return sp;
752 }
967 753
968 return result; 754 /// <summary>
755 /// Request the scene presence by name.
756 /// </summary>
757 /// <param name="firstName"></param>
758 /// <param name="lastName"></param>
759 /// <returns>null if the presence was not found</returns>
760 protected internal ScenePresence GetScenePresence(string firstName, string lastName)
761 {
762 foreach (ScenePresence presence in GetScenePresences())
763 {
764 if (presence.Firstname == firstName && presence.Lastname == lastName)
765 return presence;
766 }
767 return null;
969 } 768 }
970 769
971 /// <summary> 770 /// <summary>
972 /// Request a scene presence by UUID 771 /// Request the scene presence by localID.
973 /// </summary> 772 /// </summary>
974 /// <param name="avatarID"></param> 773 /// <param name="localID"></param>
975 /// <returns>null if the agent was not found</returns> 774 /// <returns>null if the presence was not found</returns>
976 protected internal ScenePresence GetScenePresence(UUID agentID) 775 protected internal ScenePresence GetScenePresence(uint localID)
776 {
777 foreach (ScenePresence presence in GetScenePresences())
778 if (presence.LocalId == localID)
779 return presence;
780 return null;
781 }
782
783 protected internal bool TryGetScenePresence(UUID agentID, out ScenePresence avatar)
977 { 784 {
978 ScenePresence sp;
979
980 lock (m_scenePresences) 785 lock (m_scenePresences)
981 { 786 {
982 m_scenePresences.TryGetValue(agentID, out sp); 787 m_scenePresences.TryGetValue(agentID, out avatar);
983 } 788 }
789 return (avatar != null);
790 }
984 791
985 return sp; 792 protected internal bool TryGetAvatarByName(string name, out ScenePresence avatar)
793 {
794 avatar = null;
795 foreach (ScenePresence presence in GetScenePresences())
796 {
797 if (String.Compare(name, presence.ControllingClient.Name, true) == 0)
798 {
799 avatar = presence;
800 break;
801 }
802 }
803 return (avatar != null);
986 } 804 }
987 805
988 /// <summary> 806 /// <summary>
@@ -1136,34 +954,6 @@ namespace OpenSim.Region.Framework.Scenes
1136 return group.GetChildPart(fullID); 954 return group.GetChildPart(fullID);
1137 } 955 }
1138 956
1139 protected internal bool TryGetAvatar(UUID avatarId, out ScenePresence avatar)
1140 {
1141 lock (m_scenePresences)
1142 return m_scenePresences.TryGetValue(avatarId, out avatar);
1143 }
1144
1145 protected internal bool TryGetAvatarByName(string avatarName, out ScenePresence avatar)
1146 {
1147 ScenePresence[] presences = GetScenePresences();
1148
1149 for (int i = 0; i < presences.Length; i++)
1150 {
1151 ScenePresence presence = presences[i];
1152
1153 if (!presence.IsChildAgent)
1154 {
1155 if (String.Compare(avatarName, presence.ControllingClient.Name, true) == 0)
1156 {
1157 avatar = presence;
1158 return true;
1159 }
1160 }
1161 }
1162
1163 avatar = null;
1164 return false;
1165 }
1166
1167 /// <summary> 957 /// <summary>
1168 /// Returns a list of the entities in the scene. This is a new list so no locking is required to iterate over 958 /// Returns a list of the entities in the scene. This is a new list so no locking is required to iterate over
1169 /// it 959 /// it
@@ -1226,6 +1016,10 @@ namespace OpenSim.Region.Framework.Scenes
1226 return UUID.Zero; 1016 return UUID.Zero;
1227 } 1017 }
1228 1018
1019 /// <summary>
1020 /// Performs action on all scene object groups.
1021 /// </summary>
1022 /// <param name="action"></param>
1229 protected internal void ForEachSOG(Action<SceneObjectGroup> action) 1023 protected internal void ForEachSOG(Action<SceneObjectGroup> action)
1230 { 1024 {
1231 List<SceneObjectGroup> objlist = new List<SceneObjectGroup>(SceneObjectGroupsByFullID.Values); 1025 List<SceneObjectGroup> objlist = new List<SceneObjectGroup>(SceneObjectGroupsByFullID.Values);
@@ -1242,6 +1036,46 @@ namespace OpenSim.Region.Framework.Scenes
1242 } 1036 }
1243 } 1037 }
1244 } 1038 }
1039
1040
1041 /// <summary>
1042 /// Performs action on all scene presences. This can ultimately run the actions in parallel but
1043 /// any delegates passed in will need to implement their own locking on data they reference and
1044 /// modify outside of the scope of the delegate.
1045 /// </summary>
1046 /// <param name="action"></param>
1047 public void ForEachScenePresence(Action<ScenePresence> action)
1048 {
1049 // Once all callers have their delegates configured for parallelism, we can unleash this
1050 /*
1051 Action<ScenePresence> protectedAction = new Action<ScenePresence>(delegate(ScenePresence sp)
1052 {
1053 try
1054 {
1055 action(sp);
1056 }
1057 catch (Exception e)
1058 {
1059 m_log.Info("[BUG] in " + m_parentScene.RegionInfo.RegionName + ": " + e.ToString());
1060 m_log.Info("[BUG] Stack Trace: " + e.StackTrace);
1061 }
1062 });
1063 Parallel.ForEach<ScenePresence>(GetScenePresences(), protectedAction);
1064 */
1065 // For now, perform actiona serially
1066 foreach (ScenePresence sp in GetScenePresences())
1067 {
1068 try
1069 {
1070 action(sp);
1071 }
1072 catch (Exception e)
1073 {
1074 m_log.Info("[BUG] in " + m_parentScene.RegionInfo.RegionName + ": " + e.ToString());
1075 m_log.Info("[BUG] Stack Trace: " + e.StackTrace);
1076 }
1077 }
1078 }
1245 1079
1246 #endregion 1080 #endregion
1247 1081
diff --git a/OpenSim/Region/Framework/Scenes/SceneManager.cs b/OpenSim/Region/Framework/Scenes/SceneManager.cs
index c2e3370..3b84734 100644
--- a/OpenSim/Region/Framework/Scenes/SceneManager.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneManager.cs
@@ -414,22 +414,18 @@ namespace OpenSim.Region.Framework.Scenes
414 ForEachCurrentScene( 414 ForEachCurrentScene(
415 delegate(Scene scene) 415 delegate(Scene scene)
416 { 416 {
417 ScenePresence[] scenePresences = scene.GetScenePresences(); 417 scene.ForEachScenePresence(delegate(ScenePresence scenePresence)
418
419 for (int i = 0; i < scenePresences.Length; i++)
420 { 418 {
421 ScenePresence scenePresence = scenePresences[i];
422
423 if (!scenePresence.IsChildAgent) 419 if (!scenePresence.IsChildAgent)
424 { 420 {
425 m_log.ErrorFormat("Packet debug for {0} {1} set to {2}", 421 m_log.DebugFormat("Packet debug for {0} {1} set to {2}",
426 scenePresence.Firstname, 422 scenePresence.Firstname,
427 scenePresence.Lastname, 423 scenePresence.Lastname,
428 newDebug); 424 newDebug);
429 425
430 scenePresence.ControllingClient.SetDebugPacketLevel(newDebug); 426 scenePresence.ControllingClient.SetDebugPacketLevel(newDebug);
431 } 427 }
432 } 428 });
433 } 429 }
434 ); 430 );
435 } 431 }
@@ -441,14 +437,11 @@ namespace OpenSim.Region.Framework.Scenes
441 ForEachCurrentScene( 437 ForEachCurrentScene(
442 delegate(Scene scene) 438 delegate(Scene scene)
443 { 439 {
444 ScenePresence[] scenePresences = scene.GetScenePresences(); 440 scene.ForEachScenePresence(delegate(ScenePresence scenePresence)
445
446 for (int i = 0; i < scenePresences.Length; i++)
447 { 441 {
448 ScenePresence scenePresence = scenePresences[i];
449 if (!scenePresence.IsChildAgent) 442 if (!scenePresence.IsChildAgent)
450 avatars.Add(scenePresence); 443 avatars.Add(scenePresence);
451 } 444 });
452 } 445 }
453 ); 446 );
454 447
@@ -461,18 +454,20 @@ namespace OpenSim.Region.Framework.Scenes
461 454
462 ForEachCurrentScene(delegate(Scene scene) 455 ForEachCurrentScene(delegate(Scene scene)
463 { 456 {
464 ScenePresence[] scenePresences = scene.GetScenePresences(); 457 scene.ForEachScenePresence(delegate(ScenePresence sp)
465 presences.AddRange(scenePresences); 458 {
459 presences.Add(sp);
460 });
466 }); 461 });
467 462
468 return presences; 463 return presences;
469 } 464 }
470 465
471 public RegionInfo GetRegionInfo(ulong regionHandle) 466 public RegionInfo GetRegionInfo(UUID regionID)
472 { 467 {
473 foreach (Scene scene in m_localScenes) 468 foreach (Scene scene in m_localScenes)
474 { 469 {
475 if (scene.RegionInfo.RegionHandle == regionHandle) 470 if (scene.RegionInfo.RegionID == regionID)
476 { 471 {
477 return scene.RegionInfo; 472 return scene.RegionInfo;
478 } 473 }
@@ -491,11 +486,11 @@ namespace OpenSim.Region.Framework.Scenes
491 ForEachCurrentScene(delegate(Scene scene) { scene.HandleEditCommand(cmdparams); }); 486 ForEachCurrentScene(delegate(Scene scene) { scene.HandleEditCommand(cmdparams); });
492 } 487 }
493 488
494 public bool TryGetAvatar(UUID avatarId, out ScenePresence avatar) 489 public bool TryGetScenePresence(UUID avatarId, out ScenePresence avatar)
495 { 490 {
496 foreach (Scene scene in m_localScenes) 491 foreach (Scene scene in m_localScenes)
497 { 492 {
498 if (scene.TryGetAvatar(avatarId, out avatar)) 493 if (scene.TryGetScenePresence(avatarId, out avatar))
499 { 494 {
500 return true; 495 return true;
501 } 496 }
@@ -510,7 +505,7 @@ namespace OpenSim.Region.Framework.Scenes
510 ScenePresence avatar = null; 505 ScenePresence avatar = null;
511 foreach (Scene mScene in m_localScenes) 506 foreach (Scene mScene in m_localScenes)
512 { 507 {
513 if (mScene.TryGetAvatar(avatarId, out avatar)) 508 if (mScene.TryGetScenePresence(avatarId, out avatar))
514 { 509 {
515 scene = mScene; 510 scene = mScene;
516 return true; 511 return true;
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 13d1d4e..84c3719 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -418,6 +418,7 @@ namespace OpenSim.Region.Framework.Scenes
418 RootPart.ScriptSetPhysicsStatus(false); 418 RootPart.ScriptSetPhysicsStatus(false);
419 Scene.SimChat(Utils.StringToBytes("Hit Sandbox Limit"), 419 Scene.SimChat(Utils.StringToBytes("Hit Sandbox Limit"),
420 ChatTypeEnum.DebugChannel, 0x7FFFFFFF, RootPart.AbsolutePosition, Name, UUID, false); 420 ChatTypeEnum.DebugChannel, 0x7FFFFFFF, RootPart.AbsolutePosition, Name, UUID, false);
421 lockPartsForRead(false);
421 return; 422 return;
422 } 423 }
423 } 424 }
@@ -530,8 +531,8 @@ namespace OpenSim.Region.Framework.Scenes
530 private List<SceneObjectPart> m_PlaySoundSlavePrims = new List<SceneObjectPart>(); 531 private List<SceneObjectPart> m_PlaySoundSlavePrims = new List<SceneObjectPart>();
531 public List<SceneObjectPart> PlaySoundSlavePrims 532 public List<SceneObjectPart> PlaySoundSlavePrims
532 { 533 {
533 get { return m_LoopSoundSlavePrims; } 534 get { return m_PlaySoundSlavePrims; }
534 set { m_LoopSoundSlavePrims = value; } 535 set { m_PlaySoundSlavePrims = value; }
535 } 536 }
536 537
537 private SceneObjectPart m_LoopSoundMasterPrim = null; 538 private SceneObjectPart m_LoopSoundMasterPrim = null;
@@ -686,7 +687,7 @@ namespace OpenSim.Region.Framework.Scenes
686 ApplyPhysics(m_scene.m_physicalPrim); 687 ApplyPhysics(m_scene.m_physicalPrim);
687 688
688 // Don't trigger the update here - otherwise some client issues occur when multiple updates are scheduled 689 // Don't trigger the update here - otherwise some client issues occur when multiple updates are scheduled
689 // for the same object with very different properties. The caller must schedule the update. 690 // for the same object with very different properties. The caller must schedule the update.
690 //ScheduleGroupForFullUpdate(); 691 //ScheduleGroupForFullUpdate();
691 } 692 }
692 693
@@ -1411,21 +1412,20 @@ namespace OpenSim.Region.Framework.Scenes
1411 { 1412 {
1412// part.Inventory.RemoveScriptInstances(); 1413// part.Inventory.RemoveScriptInstances();
1413 1414
1414 ScenePresence[] avatars = Scene.GetScenePresences(); 1415 Scene.ForEachScenePresence(delegate (ScenePresence sp)
1415 for (int i = 0; i < avatars.Length; i++)
1416 { 1416 {
1417 if (avatars[i].ParentID == LocalId) 1417 if (sp.ParentID == LocalId)
1418 { 1418 {
1419 avatars[i].StandUp(); 1419 sp.StandUp();
1420 } 1420 }
1421 1421
1422 if (!silent) 1422 if (!silent)
1423 { 1423 {
1424 part.UpdateFlag = 0; 1424 part.UpdateFlag = 0;
1425 if (part == m_rootPart) 1425 if (part == m_rootPart)
1426 avatars[i].ControllingClient.SendKillObject(m_regionHandle, part.LocalId); 1426 sp.ControllingClient.SendKillObject(m_regionHandle, part.LocalId);
1427 } 1427 }
1428 } 1428 });
1429 1429
1430 } 1430 }
1431 1431
@@ -1647,11 +1647,10 @@ namespace OpenSim.Region.Framework.Scenes
1647 1647
1648 #endregion 1648 #endregion
1649 1649
1650 #region Client Updating
1651
1652 public void SendFullUpdateToClient(IClientAPI remoteClient) 1650 public void SendFullUpdateToClient(IClientAPI remoteClient)
1653 { 1651 {
1654 SendPartFullUpdate(remoteClient, RootPart, m_scene.Permissions.GenerateClientFlags(remoteClient.AgentId, RootPart.UUID)); 1652 RootPart.SendFullUpdate(
1653 remoteClient, m_scene.Permissions.GenerateClientFlags(remoteClient.AgentId, RootPart.UUID));
1655 1654
1656 lockPartsForRead(true); 1655 lockPartsForRead(true);
1657 { 1656 {
@@ -1659,42 +1658,12 @@ namespace OpenSim.Region.Framework.Scenes
1659 { 1658 {
1660 1659
1661 if (part != RootPart) 1660 if (part != RootPart)
1662 SendPartFullUpdate(remoteClient, part, m_scene.Permissions.GenerateClientFlags(remoteClient.AgentId, part.UUID)); 1661 part.SendFullUpdate(
1663 1662 remoteClient, m_scene.Permissions.GenerateClientFlags(remoteClient.AgentId, part.UUID));
1664 }
1665 }
1666 lockPartsForRead(false);
1667 }
1668
1669 /// <summary>
1670 /// Send a full update to the client for the given part
1671 /// </summary>
1672 /// <param name="remoteClient"></param>
1673 /// <param name="part"></param>
1674 internal void SendPartFullUpdate(IClientAPI remoteClient, SceneObjectPart part, uint clientFlags)
1675 {
1676// m_log.DebugFormat(
1677// "[SOG]: Sendinging part full update to {0} for {1} {2}", remoteClient.Name, part.Name, part.LocalId);
1678
1679 if (m_rootPart.UUID == part.UUID)
1680 {
1681 if (IsAttachment)
1682 {
1683 part.SendFullUpdateToClient(remoteClient, m_rootPart.AttachedPos, clientFlags);
1684 }
1685 else
1686 {
1687 part.SendFullUpdateToClient(remoteClient, AbsolutePosition, clientFlags);
1688 } 1663 }
1689 } 1664 }
1690 else
1691 {
1692 part.SendFullUpdateToClient(remoteClient, clientFlags);
1693 }
1694 } 1665 }
1695 1666
1696 #endregion
1697
1698 #region Copying 1667 #region Copying
1699 1668
1700 /// <summary> 1669 /// <summary>
@@ -2206,14 +2175,12 @@ namespace OpenSim.Region.Framework.Scenes
2206 public void ScheduleTerseUpdateToAvatar(ScenePresence presence) 2175 public void ScheduleTerseUpdateToAvatar(ScenePresence presence)
2207 { 2176 {
2208 lockPartsForRead(true); 2177 lockPartsForRead(true);
2178
2179 foreach (SceneObjectPart part in m_parts.Values)
2209 { 2180 {
2210 foreach (SceneObjectPart part in m_parts.Values) 2181 part.AddTerseUpdateToAvatar(presence);
2211 {
2212
2213 part.AddTerseUpdateToAvatar(presence);
2214
2215 }
2216 } 2182 }
2183
2217 lockPartsForRead(false); 2184 lockPartsForRead(false);
2218 } 2185 }
2219 2186
@@ -2246,14 +2213,11 @@ namespace OpenSim.Region.Framework.Scenes
2246 public void ScheduleGroupForTerseUpdate() 2213 public void ScheduleGroupForTerseUpdate()
2247 { 2214 {
2248 lockPartsForRead(true); 2215 lockPartsForRead(true);
2216 foreach (SceneObjectPart part in m_parts.Values)
2249 { 2217 {
2250 foreach (SceneObjectPart part in m_parts.Values) 2218 part.ScheduleTerseUpdate();
2251 {
2252
2253 part.ScheduleTerseUpdate();
2254
2255 }
2256 } 2219 }
2220
2257 lockPartsForRead(false); 2221 lockPartsForRead(false);
2258 } 2222 }
2259 2223
@@ -3107,8 +3071,8 @@ namespace OpenSim.Region.Framework.Scenes
3107 { 3071 {
3108 if (obPart.UUID != m_rootPart.UUID) 3072 if (obPart.UUID != m_rootPart.UUID)
3109 { 3073 {
3110 obPart.IgnoreUndoUpdate = true;
3111 Vector3 oldSize = new Vector3(obPart.Scale); 3074 Vector3 oldSize = new Vector3(obPart.Scale);
3075 obPart.IgnoreUndoUpdate = true;
3112 3076
3113 float f = 1.0f; 3077 float f = 1.0f;
3114 float a = 1.0f; 3078 float a = 1.0f;
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 548a64f..4b2641c 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -573,8 +573,8 @@ namespace OpenSim.Region.Framework.Scenes
573 private List<SceneObjectPart> m_PlaySoundSlavePrims = new List<SceneObjectPart>(); 573 private List<SceneObjectPart> m_PlaySoundSlavePrims = new List<SceneObjectPart>();
574 public List<SceneObjectPart> PlaySoundSlavePrims 574 public List<SceneObjectPart> PlaySoundSlavePrims
575 { 575 {
576 get { return m_LoopSoundSlavePrims; } 576 get { return m_PlaySoundSlavePrims; }
577 set { m_LoopSoundSlavePrims = value; } 577 set { m_PlaySoundSlavePrims = value; }
578 } 578 }
579 579
580 private SceneObjectPart m_LoopSoundMasterPrim = null; 580 private SceneObjectPart m_LoopSoundMasterPrim = null;
@@ -682,7 +682,7 @@ namespace OpenSim.Region.Framework.Scenes
682 if (m_parentGroup != null) // TODO can there be a SOP without a SOG? 682 if (m_parentGroup != null) // TODO can there be a SOP without a SOG?
683 { 683 {
684 ScenePresence avatar; 684 ScenePresence avatar;
685 if (m_parentGroup.Scene.TryGetAvatar(m_sitTargetAvatar, out avatar)) 685 if (m_parentGroup.Scene.TryGetScenePresence(m_sitTargetAvatar, out avatar))
686 { 686 {
687 avatar.ParentPosition = GetWorldPosition(); 687 avatar.ParentPosition = GetWorldPosition();
688 } 688 }
@@ -1208,15 +1208,14 @@ namespace OpenSim.Region.Framework.Scenes
1208 1208
1209 private void SendObjectPropertiesToClient(UUID AgentID) 1209 private void SendObjectPropertiesToClient(UUID AgentID)
1210 { 1210 {
1211 ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences(); 1211 m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence avatar)
1212 for (int i = 0; i < avatars.Length; i++)
1213 { 1212 {
1214 // Ugly reference :( 1213 // Ugly reference :(
1215 if (avatars[i].UUID == AgentID) 1214 if (avatar.UUID == AgentID)
1216 { 1215 {
1217 m_parentGroup.GetProperties(avatars[i].ControllingClient); 1216 m_parentGroup.GetProperties(avatar.ControllingClient);
1218 } 1217 }
1219 } 1218 });
1220 } 1219 }
1221 1220
1222 // TODO: unused: 1221 // TODO: unused:
@@ -1271,11 +1270,10 @@ namespace OpenSim.Region.Framework.Scenes
1271 /// </summary> 1270 /// </summary>
1272 public void AddFullUpdateToAllAvatars() 1271 public void AddFullUpdateToAllAvatars()
1273 { 1272 {
1274 ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences(); 1273 m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence avatar)
1275 for (int i = 0; i < avatars.Length; i++)
1276 { 1274 {
1277 avatars[i].SceneViewer.QueuePartForUpdate(this); 1275 avatar.SceneViewer.QueuePartForUpdate(this);
1278 } 1276 });
1279 } 1277 }
1280 1278
1281 public void AddFullUpdateToAvatar(ScenePresence presence) 1279 public void AddFullUpdateToAvatar(ScenePresence presence)
@@ -1296,11 +1294,10 @@ namespace OpenSim.Region.Framework.Scenes
1296 /// Terse updates 1294 /// Terse updates
1297 public void AddTerseUpdateToAllAvatars() 1295 public void AddTerseUpdateToAllAvatars()
1298 { 1296 {
1299 ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences(); 1297 m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence avatar)
1300 for (int i = 0; i < avatars.Length; i++)
1301 { 1298 {
1302 avatars[i].SceneViewer.QueuePartForUpdate(this); 1299 avatar.SceneViewer.QueuePartForUpdate(this);
1303 } 1300 });
1304 } 1301 }
1305 1302
1306 public void AddTerseUpdateToAvatar(ScenePresence presence) 1303 public void AddTerseUpdateToAvatar(ScenePresence presence)
@@ -1335,11 +1332,11 @@ namespace OpenSim.Region.Framework.Scenes
1335 if (volume < 0) 1332 if (volume < 0)
1336 volume = 0; 1333 volume = 0;
1337 1334
1338 List<ScenePresence> avatarts = m_parentGroup.Scene.GetAvatars(); 1335 m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence sp)
1339 foreach (ScenePresence p in avatarts)
1340 { 1336 {
1341 p.ControllingClient.SendAttachedSoundGainChange(UUID, (float)volume); 1337 if(!sp.IsChildAgent)
1342 } 1338 sp.ControllingClient.SendAttachedSoundGainChange(UUID, (float)volume);
1339 });
1343 } 1340 }
1344 1341
1345 /// <summary> 1342 /// <summary>
@@ -2060,6 +2057,7 @@ namespace OpenSim.Region.Framework.Scenes
2060 { 2057 {
2061 m_lastColliders.Remove(localID); 2058 m_lastColliders.Remove(localID);
2062 } 2059 }
2060
2063 if (m_parentGroup == null) 2061 if (m_parentGroup == null)
2064 return; 2062 return;
2065 if (m_parentGroup.IsDeleted) 2063 if (m_parentGroup.IsDeleted)
@@ -2136,17 +2134,13 @@ namespace OpenSim.Region.Framework.Scenes
2136 } 2134 }
2137 else 2135 else
2138 { 2136 {
2139 ScenePresence[] avlist = m_parentGroup.Scene.GetScenePresences(); 2137 m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence av)
2140
2141 for (int i = 0; i < avlist.Length; i++)
2142 { 2138 {
2143 ScenePresence av = avlist[i];
2144
2145 if (av.LocalId == localId) 2139 if (av.LocalId == localId)
2146 { 2140 {
2147 if (m_parentGroup.RootPart.CollisionFilter.ContainsValue(av.UUID.ToString()) || m_parentGroup.RootPart.CollisionFilter.ContainsValue(av.Name)) 2141 if (m_parentGroup.RootPart.CollisionFilter.ContainsValue(av.UUID.ToString()) || m_parentGroup.RootPart.CollisionFilter.ContainsValue(av.Name))
2148 { 2142 {
2149 bool found = m_parentGroup.RootPart.CollisionFilter.TryGetValue(1,out data); 2143 bool found = m_parentGroup.RootPart.CollisionFilter.TryGetValue(1, out data);
2150 //If it is 1, it is to accept ONLY collisions from this avatar 2144 //If it is 1, it is to accept ONLY collisions from this avatar
2151 if (found) 2145 if (found)
2152 { 2146 {
@@ -2168,7 +2162,7 @@ namespace OpenSim.Region.Framework.Scenes
2168 } 2162 }
2169 else 2163 else
2170 { 2164 {
2171 bool found = m_parentGroup.RootPart.CollisionFilter.TryGetValue(1,out data); 2165 bool found = m_parentGroup.RootPart.CollisionFilter.TryGetValue(1, out data);
2172 //If it is 1, it is to accept ONLY collisions from this avatar, so this other avatar will not work 2166 //If it is 1, it is to accept ONLY collisions from this avatar, so this other avatar will not work
2173 if (!found) 2167 if (!found)
2174 { 2168 {
@@ -2186,7 +2180,7 @@ namespace OpenSim.Region.Framework.Scenes
2186 } 2180 }
2187 2181
2188 } 2182 }
2189 } 2183 });
2190 } 2184 }
2191 } 2185 }
2192 if (colliding.Count > 0) 2186 if (colliding.Count > 0)
@@ -2272,17 +2266,13 @@ namespace OpenSim.Region.Framework.Scenes
2272 } 2266 }
2273 else 2267 else
2274 { 2268 {
2275 ScenePresence[] avlist = m_parentGroup.Scene.GetScenePresences(); 2269 m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence av)
2276
2277 for (int i = 0; i < avlist.Length; i++)
2278 { 2270 {
2279 ScenePresence av = avlist[i];
2280
2281 if (av.LocalId == localId) 2271 if (av.LocalId == localId)
2282 { 2272 {
2283 if (m_parentGroup.RootPart.CollisionFilter.ContainsValue(av.UUID.ToString()) || m_parentGroup.RootPart.CollisionFilter.ContainsValue(av.Name)) 2273 if (m_parentGroup.RootPart.CollisionFilter.ContainsValue(av.UUID.ToString()) || m_parentGroup.RootPart.CollisionFilter.ContainsValue(av.Name))
2284 { 2274 {
2285 bool found = m_parentGroup.RootPart.CollisionFilter.TryGetValue(1,out data); 2275 bool found = m_parentGroup.RootPart.CollisionFilter.TryGetValue(1, out data);
2286 //If it is 1, it is to accept ONLY collisions from this avatar 2276 //If it is 1, it is to accept ONLY collisions from this avatar
2287 if (found) 2277 if (found)
2288 { 2278 {
@@ -2304,7 +2294,7 @@ namespace OpenSim.Region.Framework.Scenes
2304 } 2294 }
2305 else 2295 else
2306 { 2296 {
2307 bool found = m_parentGroup.RootPart.CollisionFilter.TryGetValue(1,out data); 2297 bool found = m_parentGroup.RootPart.CollisionFilter.TryGetValue(1, out data);
2308 //If it is 1, it is to accept ONLY collisions from this avatar, so this other avatar will not work 2298 //If it is 1, it is to accept ONLY collisions from this avatar, so this other avatar will not work
2309 if (!found) 2299 if (!found)
2310 { 2300 {
@@ -2322,7 +2312,7 @@ namespace OpenSim.Region.Framework.Scenes
2322 } 2312 }
2323 2313
2324 } 2314 }
2325 } 2315 });
2326 } 2316 }
2327 } 2317 }
2328 if (colliding.Count > 0) 2318 if (colliding.Count > 0)
@@ -2403,17 +2393,13 @@ namespace OpenSim.Region.Framework.Scenes
2403 } 2393 }
2404 else 2394 else
2405 { 2395 {
2406 ScenePresence[] avlist = m_parentGroup.Scene.GetScenePresences(); 2396 m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence av)
2407
2408 for (int i = 0; i < avlist.Length; i++)
2409 { 2397 {
2410 ScenePresence av = avlist[i];
2411
2412 if (av.LocalId == localId) 2398 if (av.LocalId == localId)
2413 { 2399 {
2414 if (m_parentGroup.RootPart.CollisionFilter.ContainsValue(av.UUID.ToString()) || m_parentGroup.RootPart.CollisionFilter.ContainsValue(av.Name)) 2400 if (m_parentGroup.RootPart.CollisionFilter.ContainsValue(av.UUID.ToString()) || m_parentGroup.RootPart.CollisionFilter.ContainsValue(av.Name))
2415 { 2401 {
2416 bool found = m_parentGroup.RootPart.CollisionFilter.TryGetValue(1,out data); 2402 bool found = m_parentGroup.RootPart.CollisionFilter.TryGetValue(1, out data);
2417 //If it is 1, it is to accept ONLY collisions from this avatar 2403 //If it is 1, it is to accept ONLY collisions from this avatar
2418 if (found) 2404 if (found)
2419 { 2405 {
@@ -2435,7 +2421,7 @@ namespace OpenSim.Region.Framework.Scenes
2435 } 2421 }
2436 else 2422 else
2437 { 2423 {
2438 bool found = m_parentGroup.RootPart.CollisionFilter.TryGetValue(1,out data); 2424 bool found = m_parentGroup.RootPart.CollisionFilter.TryGetValue(1, out data);
2439 //If it is 1, it is to accept ONLY collisions from this avatar, so this other avatar will not work 2425 //If it is 1, it is to accept ONLY collisions from this avatar, so this other avatar will not work
2440 if (!found) 2426 if (!found)
2441 { 2427 {
@@ -2453,7 +2439,7 @@ namespace OpenSim.Region.Framework.Scenes
2453 } 2439 }
2454 2440
2455 } 2441 }
2456 } 2442 });
2457 } 2443 }
2458 } 2444 }
2459 2445
@@ -2640,12 +2626,13 @@ namespace OpenSim.Region.Framework.Scenes
2640 TaskInventory.LockItemsForRead(false); 2626 TaskInventory.LockItemsForRead(false);
2641 } 2627 }
2642 2628
2643 List<ScenePresence> avatarts = m_parentGroup.Scene.GetAvatars(); 2629 m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence sp)
2644 foreach (ScenePresence p in avatarts)
2645 { 2630 {
2646 if (!(Util.GetDistanceTo(p.AbsolutePosition, AbsolutePosition) >= 100)) 2631 if (sp.IsChildAgent)
2647 p.ControllingClient.SendPreLoadSound(objectID, objectID, soundID); 2632 return;
2648 } 2633 if (!(Util.GetDistanceTo(sp.AbsolutePosition, AbsolutePosition) >= 100))
2634 sp.ControllingClient.SendPreLoadSound(objectID, objectID, soundID);
2635 });
2649 } 2636 }
2650 2637
2651 public void RemFlag(PrimFlags flag) 2638 public void RemFlag(PrimFlags flag)
@@ -2820,41 +2807,66 @@ namespace OpenSim.Region.Framework.Scenes
2820 } 2807 }
2821 } 2808 }
2822 2809
2810// /// <summary>
2811// ///
2812// /// </summary>
2813// /// <param name="remoteClient"></param>
2814// public void SendFullUpdate(IClientAPI remoteClient, uint clientFlags)
2815// {
2816// m_parentGroup.SendPartFullUpdate(remoteClient, this, clientFlags);
2817// }
2818
2819
2823 /// <summary> 2820 /// <summary>
2824 /// 2821 /// Send a full update to the client for the given part
2825 /// </summary> 2822 /// </summary>
2826 /// <param name="remoteClient"></param> 2823 /// <param name="remoteClient"></param>
2827 public void SendFullUpdate(IClientAPI remoteClient, uint clientFlags) 2824 /// <param name="clientFlags"></param>
2825 protected internal void SendFullUpdate(IClientAPI remoteClient, uint clientFlags)
2828 { 2826 {
2829 m_parentGroup.SendPartFullUpdate(remoteClient, this, clientFlags); 2827// m_log.DebugFormat(
2828// "[SOG]: Sendinging part full update to {0} for {1} {2}", remoteClient.Name, part.Name, part.LocalId);
2829
2830 if (IsRoot)
2831 {
2832 if (IsAttachment)
2833 {
2834 SendFullUpdateToClient(remoteClient, AttachedPos, clientFlags);
2835 }
2836 else
2837 {
2838 SendFullUpdateToClient(remoteClient, AbsolutePosition, clientFlags);
2839 }
2840 }
2841 else
2842 {
2843 SendFullUpdateToClient(remoteClient, clientFlags);
2844 }
2830 } 2845 }
2831 2846
2832 /// <summary> 2847 /// <summary>
2833 /// 2848 /// Send a full update for this part to all clients.
2834 /// </summary> 2849 /// </summary>
2835 public void SendFullUpdateToAllClients() 2850 public void SendFullUpdateToAllClients()
2836 { 2851 {
2837 ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences(); 2852 m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence avatar)
2838 for (int i = 0; i < avatars.Length; i++)
2839 { 2853 {
2840 // Ugly reference :( 2854 SendFullUpdate(avatar.ControllingClient, avatar.GenerateClientFlags(UUID));
2841 m_parentGroup.SendPartFullUpdate(avatars[i].ControllingClient, this, 2855 });
2842 avatars[i].GenerateClientFlags(UUID));
2843 }
2844 } 2856 }
2845 2857
2858 /// <summary>
2859 /// Send a full update to all clients except the one nominated.
2860 /// </summary>
2861 /// <param name="agentID"></param>
2846 public void SendFullUpdateToAllClientsExcept(UUID agentID) 2862 public void SendFullUpdateToAllClientsExcept(UUID agentID)
2847 { 2863 {
2848 ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences(); 2864 m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence avatar)
2849 for (int i = 0; i < avatars.Length; i++)
2850 { 2865 {
2851 // Ugly reference :( 2866 // Ugly reference :(
2852 if (avatars[i].UUID != agentID) 2867 if (avatar.UUID != agentID)
2853 { 2868 SendFullUpdate(avatar.ControllingClient, avatar.GenerateClientFlags(UUID));
2854 m_parentGroup.SendPartFullUpdate(avatars[i].ControllingClient, this, 2869 });
2855 avatars[i].GenerateClientFlags(UUID));
2856 }
2857 }
2858 } 2870 }
2859 2871
2860 /// <summary> 2872 /// <summary>
@@ -3055,11 +3067,10 @@ namespace OpenSim.Region.Framework.Scenes
3055 /// </summary> 3067 /// </summary>
3056 public void SendTerseUpdateToAllClients() 3068 public void SendTerseUpdateToAllClients()
3057 { 3069 {
3058 ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences(); 3070 m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence avatar)
3059 for (int i = 0; i < avatars.Length; i++)
3060 { 3071 {
3061 SendTerseUpdateToClient(avatars[i].ControllingClient); 3072 SendTerseUpdateToClient(avatar.ControllingClient);
3062 } 3073 });
3063 } 3074 }
3064 3075
3065 public void SetAttachmentPoint(uint AttachmentPoint) 3076 public void SetAttachmentPoint(uint AttachmentPoint)
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
index a2fceb7..a1991c5 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
@@ -34,7 +34,6 @@ using System.Reflection;
34using OpenMetaverse; 34using OpenMetaverse;
35using log4net; 35using log4net;
36using OpenSim.Framework; 36using OpenSim.Framework;
37using OpenSim.Framework.Communications.Cache;
38using OpenSim.Region.Framework.Interfaces; 37using OpenSim.Region.Framework.Interfaces;
39using OpenSim.Region.Framework.Scenes.Scripting; 38using OpenSim.Region.Framework.Scenes.Scripting;
40 39
@@ -761,7 +760,6 @@ namespace OpenSim.Region.Framework.Scenes
761 m_items[item.ItemID] = item; 760 m_items[item.ItemID] = item;
762 m_inventorySerial++; 761 m_inventorySerial++;
763 m_part.TriggerScriptChangedEvent(Changed.INVENTORY); 762 m_part.TriggerScriptChangedEvent(Changed.INVENTORY);
764
765 HasInventoryChanged = true; 763 HasInventoryChanged = true;
766 m_part.ParentGroup.HasGroupChanged = true; 764 m_part.ParentGroup.HasGroupChanged = true;
767 m_items.LockItemsForWrite(false); 765 m_items.LockItemsForWrite(false);
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 2603fe1..5c54616 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -33,12 +33,12 @@ using OpenMetaverse;
33using log4net; 33using log4net;
34using OpenSim.Framework; 34using OpenSim.Framework;
35using OpenSim.Framework.Client; 35using OpenSim.Framework.Client;
36using OpenSim.Framework.Communications.Cache;
37using OpenSim.Region.Framework.Interfaces; 36using OpenSim.Region.Framework.Interfaces;
38using OpenSim.Region.Framework.Scenes.Animation; 37using OpenSim.Region.Framework.Scenes.Animation;
39using OpenSim.Region.Framework.Scenes.Types; 38using OpenSim.Region.Framework.Scenes.Types;
40using OpenSim.Region.Physics.Manager; 39using OpenSim.Region.Physics.Manager;
41using GridRegion = OpenSim.Services.Interfaces.GridRegion; 40using GridRegion = OpenSim.Services.Interfaces.GridRegion;
41using OpenSim.Services.Interfaces;
42 42
43namespace OpenSim.Region.Framework.Scenes 43namespace OpenSim.Region.Framework.Scenes
44{ 44{
@@ -150,7 +150,8 @@ namespace OpenSim.Region.Framework.Scenes
150 150
151 private float m_sitAvatarHeight = 2.0f; 151 private float m_sitAvatarHeight = 2.0f;
152 152
153 private float m_godlevel; 153 private int m_godLevel;
154 private int m_userLevel;
154 155
155 private bool m_invulnerable = true; 156 private bool m_invulnerable = true;
156 157
@@ -266,6 +267,8 @@ namespace OpenSim.Region.Framework.Scenes
266 267
267 // For teleports and crossings callbacks 268 // For teleports and crossings callbacks
268 string m_callbackURI; 269 string m_callbackURI;
270 UUID m_originRegionID;
271
269 ulong m_rootRegionHandle; 272 ulong m_rootRegionHandle;
270 273
271 /// <value> 274 /// <value>
@@ -302,9 +305,14 @@ namespace OpenSim.Region.Framework.Scenes
302 get { return m_invulnerable; } 305 get { return m_invulnerable; }
303 } 306 }
304 307
305 public float GodLevel 308 public int UserLevel
309 {
310 get { return m_userLevel; }
311 }
312
313 public int GodLevel
306 { 314 {
307 get { return m_godlevel; } 315 get { return m_godLevel; }
308 } 316 }
309 317
310 public ulong RegionHandle 318 public ulong RegionHandle
@@ -457,7 +465,7 @@ namespace OpenSim.Region.Framework.Scenes
457 PhysicsActor actor = m_physicsActor; 465 PhysicsActor actor = m_physicsActor;
458// if (actor != null) 466// if (actor != null)
459 if ((actor != null) && (m_parentID == 0)) // KF Do NOT update m_pos here if Av is sitting! 467 if ((actor != null) && (m_parentID == 0)) // KF Do NOT update m_pos here if Av is sitting!
460 m_pos = actor.Position; 468 m_pos = actor.Position;
461 469
462 return m_parentPosition + m_pos; 470 return m_parentPosition + m_pos;
463 } 471 }
@@ -678,6 +686,11 @@ namespace OpenSim.Region.Framework.Scenes
678 m_regionInfo = reginfo; 686 m_regionInfo = reginfo;
679 m_localId = m_scene.AllocateLocalId(); 687 m_localId = m_scene.AllocateLocalId();
680 688
689 UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, m_uuid);
690
691 if (account != null)
692 m_userLevel = account.UserLevel;
693
681 IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>(); 694 IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>();
682 if (gm != null) 695 if (gm != null)
683 m_grouptitle = gm.GetGroupTitle(m_uuid); 696 m_grouptitle = gm.GetGroupTitle(m_uuid);
@@ -868,47 +881,22 @@ namespace OpenSim.Region.Framework.Scenes
868 if (land != null) 881 if (land != null)
869 { 882 {
870 //Don't restrict gods, estate managers, or land owners to the TP point. This behaviour mimics agni. 883 //Don't restrict gods, estate managers, or land owners to the TP point. This behaviour mimics agni.
871 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero && m_godlevel < 200 && !m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid) && land.LandData.OwnerID != m_uuid) 884 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero && m_userLevel < 200 && !m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid) && land.LandData.OwnerID != m_uuid)
872 { 885 {
873 pos = land.LandData.UserLocation; 886 pos = land.LandData.UserLocation;
874 } 887 }
875 } 888 }
876 } 889 }
877 890
878 if (pos.X < 0 || pos.Y < 0 || pos.Z < 0) 891 if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f)
879 { 892 {
880 Vector3 emergencyPos = new Vector3(((int)Constants.RegionSize * 0.5f), ((int)Constants.RegionSize * 0.5f), 128);
881
882 if (pos.X < 0)
883 {
884 emergencyPos.X = (int)Constants.RegionSize + pos.X;
885 if (!(pos.Y < 0))
886 emergencyPos.Y = pos.Y;
887 if (!(pos.Z < 0))
888 emergencyPos.X = pos.X;
889 }
890 if (pos.Y < 0)
891 {
892 emergencyPos.Y = (int)Constants.RegionSize + pos.Y;
893 if (!(pos.X < 0))
894 emergencyPos.X = pos.X;
895 if (!(pos.Z < 0))
896 emergencyPos.Z = pos.Z;
897 }
898 if (pos.Z < 0)
899 {
900 if (!(pos.X < 0))
901 emergencyPos.X = pos.X;
902 if (!(pos.Y < 0))
903 emergencyPos.Y = pos.Y;
904 //Leave as 128
905 }
906
907 m_log.WarnFormat( 893 m_log.WarnFormat(
908 "[SCENE PRESENCE]: MakeRootAgent() was given an illegal position of {0} for avatar {1}, {2}. Substituting {3}", 894 "[SCENE PRESENCE]: MakeRootAgent() was given an illegal position of {0} for avatar {1}, {2}. Clamping",
909 pos, Name, UUID, emergencyPos); 895 pos, Name, UUID);
910 896
911 pos = emergencyPos; 897 if (pos.X < 0f) pos.X = 0f;
898 if (pos.Y < 0f) pos.Y = 0f;
899 if (pos.Z < 0f) pos.Z = 0f;
912 } 900 }
913 901
914 float localAVHeight = 1.56f; 902 float localAVHeight = 1.56f;
@@ -919,7 +907,7 @@ namespace OpenSim.Region.Framework.Scenes
919 907
920 float posZLimit = 0; 908 float posZLimit = 0;
921 909
922 if (pos.X <Constants.RegionSize && pos.Y < Constants.RegionSize) 910 if (pos.X < Constants.RegionSize && pos.Y < Constants.RegionSize)
923 posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y]; 911 posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y];
924 912
925 float newPosZ = posZLimit + localAVHeight / 2; 913 float newPosZ = posZLimit + localAVHeight / 2;
@@ -971,14 +959,11 @@ namespace OpenSim.Region.Framework.Scenes
971 959
972 m_isChildAgent = false; 960 m_isChildAgent = false;
973 961
974 ScenePresence[] animAgents = m_scene.GetScenePresences(); 962 m_scene.ForEachScenePresence(delegate(ScenePresence presence)
975 for (int i = 0; i < animAgents.Length; i++)
976 { 963 {
977 ScenePresence presence = animAgents[i];
978
979 if (presence != this) 964 if (presence != this)
980 presence.Animator.SendAnimPackToClient(ControllingClient); 965 presence.Animator.SendAnimPackToClient(ControllingClient);
981 } 966 });
982 967
983 m_scene.EventManager.TriggerOnMakeRootAgent(this); 968 m_scene.EventManager.TriggerOnMakeRootAgent(this);
984 } 969 }
@@ -1162,8 +1147,10 @@ namespace OpenSim.Region.Framework.Scenes
1162 /// This is called upon a very important packet sent from the client, 1147 /// This is called upon a very important packet sent from the client,
1163 /// so it's client-controlled. Never call this method directly. 1148 /// so it's client-controlled. Never call this method directly.
1164 /// </summary> 1149 /// </summary>
1165 public void CompleteMovement() 1150 public void CompleteMovement(IClientAPI client)
1166 { 1151 {
1152 //m_log.Debug("[SCENE PRESENCE]: CompleteMovement");
1153
1167 Vector3 look = Velocity; 1154 Vector3 look = Velocity;
1168 if ((look.X == 0) && (look.Y == 0) && (look.Z == 0)) 1155 if ((look.X == 0) && (look.Y == 0) && (look.Z == 0))
1169 { 1156 {
@@ -1188,7 +1175,7 @@ namespace OpenSim.Region.Framework.Scenes
1188 if ((m_callbackURI != null) && !m_callbackURI.Equals("")) 1175 if ((m_callbackURI != null) && !m_callbackURI.Equals(""))
1189 { 1176 {
1190 m_log.DebugFormat("[SCENE PRESENCE]: Releasing agent in URI {0}", m_callbackURI); 1177 m_log.DebugFormat("[SCENE PRESENCE]: Releasing agent in URI {0}", m_callbackURI);
1191 Scene.SendReleaseAgent(m_rootRegionHandle, UUID, m_callbackURI); 1178 Scene.SimulationService.ReleaseAgent(m_originRegionID, UUID, m_callbackURI);
1192 m_callbackURI = null; 1179 m_callbackURI = null;
1193 } 1180 }
1194 1181
@@ -1196,6 +1183,21 @@ namespace OpenSim.Region.Framework.Scenes
1196 1183
1197 m_controllingClient.MoveAgentIntoRegion(m_regionInfo, AbsolutePosition, look); 1184 m_controllingClient.MoveAgentIntoRegion(m_regionInfo, AbsolutePosition, look);
1198 SendInitialData(); 1185 SendInitialData();
1186
1187 // Create child agents in neighbouring regions
1188 if (!m_isChildAgent)
1189 {
1190 IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>();
1191 if (m_agentTransfer != null)
1192 m_agentTransfer.EnableChildAgents(this);
1193 else
1194 m_log.DebugFormat("[SCENE PRESENCE]: Unable to create child agents in neighbours, because AgentTransferModule is not active");
1195
1196 IFriendsModule friendsModule = m_scene.RequestModuleInterface<IFriendsModule>();
1197 if (friendsModule != null)
1198 friendsModule.SendFriendsOnlineIfNeeded(ControllingClient);
1199 }
1200
1199 } 1201 }
1200 1202
1201 /// <summary> 1203 /// <summary>
@@ -1264,6 +1266,7 @@ namespace OpenSim.Region.Framework.Scenes
1264 m_log.Error("[AVATAR]: NonFinite Avatar position detected... Reset Position. Mantis this please. Error #9999902"); 1266 m_log.Error("[AVATAR]: NonFinite Avatar position detected... Reset Position. Mantis this please. Error #9999902");
1265 1267
1266 m_pos = m_LastFinitePos; 1268 m_pos = m_LastFinitePos;
1269
1267 if (!m_pos.IsFinite()) 1270 if (!m_pos.IsFinite())
1268 { 1271 {
1269 m_pos.X = 127f; 1272 m_pos.X = 127f;
@@ -1901,6 +1904,7 @@ namespace OpenSim.Region.Framework.Scenes
1901 { 1904 {
1902 m_avUnscriptedSitPos = Vector3.Zero; // Zero = Sit on prim center 1905 m_avUnscriptedSitPos = Vector3.Zero; // Zero = Sit on prim center
1903 autopilotTarget = part.AbsolutePosition; 1906 autopilotTarget = part.AbsolutePosition;
1907//Console.WriteLine("UsSmall autopilotTarget={0}", autopilotTarget);
1904 } 1908 }
1905 else return; // occupied small 1909 else return; // occupied small
1906 } // end large/small 1910 } // end large/small
@@ -2277,7 +2281,8 @@ namespace OpenSim.Region.Framework.Scenes
2277 m_pos += SIT_TARGET_ADJUSTMENT; 2281 m_pos += SIT_TARGET_ADJUSTMENT;
2278 m_bodyRot = sitTargetOrient; 2282 m_bodyRot = sitTargetOrient;
2279 m_parentPosition = part.AbsolutePosition; 2283 m_parentPosition = part.AbsolutePosition;
2280 part.IsOccupied = true; 2284 part.IsOccupied = true;
2285Console.WriteLine("Scripted Sit ofset {0}", m_pos);
2281 } 2286 }
2282 else 2287 else
2283 { 2288 {
@@ -2399,6 +2404,7 @@ namespace OpenSim.Region.Framework.Scenes
2399 { 2404 {
2400 if (m_isChildAgent) 2405 if (m_isChildAgent)
2401 { 2406 {
2407 // WHAT???
2402 m_log.Debug("[SCENEPRESENCE]: AddNewMovement() called on child agent, making root agent!"); 2408 m_log.Debug("[SCENEPRESENCE]: AddNewMovement() called on child agent, making root agent!");
2403 2409
2404 // we have to reset the user's child agent connections. 2410 // we have to reset the user's child agent connections.
@@ -2422,7 +2428,9 @@ namespace OpenSim.Region.Framework.Scenes
2422 2428
2423 if (m_scene.SceneGridService != null) 2429 if (m_scene.SceneGridService != null)
2424 { 2430 {
2425 m_scene.SceneGridService.EnableNeighbourChildAgents(this, new List<RegionInfo>()); 2431 IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>();
2432 if (m_agentTransfer != null)
2433 m_agentTransfer.EnableChildAgents(this);
2426 } 2434 }
2427 2435
2428 return; 2436 return;
@@ -2590,35 +2598,33 @@ namespace OpenSim.Region.Framework.Scenes
2590 2598
2591 List<Vector3> CoarseLocations = new List<Vector3>(); 2599 List<Vector3> CoarseLocations = new List<Vector3>();
2592 List<UUID> AvatarUUIDs = new List<UUID>(); 2600 List<UUID> AvatarUUIDs = new List<UUID>();
2593 List<ScenePresence> avatars = m_scene.GetAvatars(); 2601 m_scene.ForEachScenePresence(delegate(ScenePresence sp)
2594 for (int i = 0; i < avatars.Count; i++)
2595 { 2602 {
2596 // Requested by LibOMV. Send Course Location on self. 2603 if (sp.IsChildAgent)
2597 //if (avatars[i] != this) 2604 return;
2598 //{ 2605
2599 if (avatars[i].ParentID != 0) 2606 if (sp.ParentID != 0)
2607 {
2608 // sitting avatar
2609 SceneObjectPart sop = m_scene.GetSceneObjectPart(sp.ParentID);
2610 if (sop != null)
2600 { 2611 {
2601 // sitting avatar 2612 CoarseLocations.Add(sop.AbsolutePosition + sp.m_pos);
2602 SceneObjectPart sop = m_scene.GetSceneObjectPart(avatars[i].ParentID); 2613 AvatarUUIDs.Add(sp.UUID);
2603 if (sop != null)
2604 {
2605 CoarseLocations.Add(sop.AbsolutePosition + avatars[i].m_pos);
2606 AvatarUUIDs.Add(avatars[i].UUID);
2607 }
2608 else
2609 {
2610 // we can't find the parent.. ! arg!
2611 CoarseLocations.Add(avatars[i].m_pos);
2612 AvatarUUIDs.Add(avatars[i].UUID);
2613 }
2614 } 2614 }
2615 else 2615 else
2616 { 2616 {
2617 CoarseLocations.Add(avatars[i].m_pos); 2617 // we can't find the parent.. ! arg!
2618 AvatarUUIDs.Add(avatars[i].UUID); 2618 CoarseLocations.Add(sp.m_pos);
2619 AvatarUUIDs.Add(sp.UUID);
2619 } 2620 }
2620 //} 2621 }
2621 } 2622 else
2623 {
2624 CoarseLocations.Add(sp.m_pos);
2625 AvatarUUIDs.Add(sp.UUID);
2626 }
2627 });
2622 2628
2623 m_controllingClient.SendCoarseLocationUpdate(AvatarUUIDs, CoarseLocations); 2629 m_controllingClient.SendCoarseLocationUpdate(AvatarUUIDs, CoarseLocations);
2624 2630
@@ -2660,13 +2666,10 @@ namespace OpenSim.Region.Framework.Scenes
2660 public void SendInitialFullUpdateToAllClients() 2666 public void SendInitialFullUpdateToAllClients()
2661 { 2667 {
2662 m_perfMonMS = Util.EnvironmentTickCount(); 2668 m_perfMonMS = Util.EnvironmentTickCount();
2663 2669 int avUpdates = 0;
2664 ScenePresence[] avatars = m_scene.GetScenePresences(); 2670 m_scene.ForEachScenePresence(delegate(ScenePresence avatar)
2665
2666 for (int i = 0; i < avatars.Length; i++)
2667 { 2671 {
2668 ScenePresence avatar = avatars[i]; 2672 ++avUpdates;
2669
2670 // only send if this is the root (children are only "listening posts" in a foreign region) 2673 // only send if this is the root (children are only "listening posts" in a foreign region)
2671 if (!IsChildAgent) 2674 if (!IsChildAgent)
2672 { 2675 {
@@ -2682,9 +2685,9 @@ namespace OpenSim.Region.Framework.Scenes
2682 avatar.Animator.SendAnimPackToClient(ControllingClient); 2685 avatar.Animator.SendAnimPackToClient(ControllingClient);
2683 } 2686 }
2684 } 2687 }
2685 } 2688 });
2686 2689
2687 m_scene.StatsReporter.AddAgentUpdates(avatars.Length); 2690 m_scene.StatsReporter.AddAgentUpdates(avUpdates);
2688 m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); 2691 m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS));
2689 2692
2690 //Animator.SendAnimPack(); 2693 //Animator.SendAnimPack();
@@ -2695,13 +2698,15 @@ namespace OpenSim.Region.Framework.Scenes
2695 m_perfMonMS = Util.EnvironmentTickCount(); 2698 m_perfMonMS = Util.EnvironmentTickCount();
2696 2699
2697 // only send update from root agents to other clients; children are only "listening posts" 2700 // only send update from root agents to other clients; children are only "listening posts"
2698 List<ScenePresence> avatars = m_scene.GetAvatars(); 2701 int count = 0;
2699 foreach (ScenePresence avatar in avatars) 2702 m_scene.ForEachScenePresence(delegate(ScenePresence sp)
2700 { 2703 {
2701 SendFullUpdateToOtherClient(avatar); 2704 if (sp.IsChildAgent)
2702 2705 return;
2703 } 2706 SendFullUpdateToOtherClient(sp);
2704 m_scene.StatsReporter.AddAgentUpdates(avatars.Count); 2707 ++count;
2708 });
2709 m_scene.StatsReporter.AddAgentUpdates(count);
2705 m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); 2710 m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS));
2706 2711
2707 Animator.SendAnimPack(); 2712 Animator.SendAnimPack();
@@ -2722,14 +2727,9 @@ namespace OpenSim.Region.Framework.Scenes
2722 m_controllingClient.SendAvatarData(new SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_grouptitle, m_uuid, LocalId, 2727 m_controllingClient.SendAvatarData(new SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_grouptitle, m_uuid, LocalId,
2723 pos, m_appearance.Texture.GetBytes(), m_parentID, m_bodyRot)); 2728 pos, m_appearance.Texture.GetBytes(), m_parentID, m_bodyRot));
2724 2729
2725 if (!m_isChildAgent)
2726 {
2727 m_scene.InformClientOfNeighbours(this);
2728 }
2729
2730 SendInitialFullUpdateToAllClients(); 2730 SendInitialFullUpdateToAllClients();
2731 SendAppearanceToAllOtherAgents(); 2731 SendAppearanceToAllOtherAgents();
2732 } 2732 }
2733 2733
2734 /// <summary> 2734 /// <summary>
2735 /// Tell the client for this scene presence what items it should be wearing now 2735 /// Tell the client for this scene presence what items it should be wearing now
@@ -2811,14 +2811,19 @@ namespace OpenSim.Region.Framework.Scenes
2811 } 2811 }
2812 } 2812 }
2813 } 2813 }
2814
2814 } 2815 }
2815 2816
2817
2816 #endregion Bake Cache Check 2818 #endregion Bake Cache Check
2817 2819
2818 m_appearance.SetAppearance(textureEntry, visualParams); 2820 m_appearance.SetAppearance(textureEntry, visualParams);
2819 if (m_appearance.AvatarHeight > 0) 2821 if (m_appearance.AvatarHeight > 0)
2820 SetHeight(m_appearance.AvatarHeight); 2822 SetHeight(m_appearance.AvatarHeight);
2821 m_scene.CommsManager.AvatarService.UpdateUserAppearance(m_controllingClient.AgentId, m_appearance); 2823
2824 // This is not needed, because only the transient data changed
2825 //AvatarData adata = new AvatarData(m_appearance);
2826 //m_scene.AvatarService.SetAvatar(m_controllingClient.AgentId, adata);
2822 2827
2823 SendAppearanceToAllOtherAgents(); 2828 SendAppearanceToAllOtherAgents();
2824 if (!m_startAnimationSet) 2829 if (!m_startAnimationSet)
@@ -2838,7 +2843,8 @@ namespace OpenSim.Region.Framework.Scenes
2838 public void SetWearable(int wearableId, AvatarWearable wearable) 2843 public void SetWearable(int wearableId, AvatarWearable wearable)
2839 { 2844 {
2840 m_appearance.SetWearable(wearableId, wearable); 2845 m_appearance.SetWearable(wearableId, wearable);
2841 m_scene.CommsManager.AvatarService.UpdateUserAppearance(m_controllingClient.AgentId, m_appearance); 2846 AvatarData adata = new AvatarData(m_appearance);
2847 m_scene.AvatarService.SetAvatar(m_controllingClient.AgentId, adata);
2842 m_controllingClient.SendWearables(m_appearance.Wearables, m_appearance.Serial++); 2848 m_controllingClient.SendWearables(m_appearance.Wearables, m_appearance.Serial++);
2843 } 2849 }
2844 2850
@@ -2860,7 +2866,12 @@ namespace OpenSim.Region.Framework.Scenes
2860 /// </summary> 2866 /// </summary>
2861 protected void CheckForSignificantMovement() 2867 protected void CheckForSignificantMovement()
2862 { 2868 {
2863 if (Util.GetDistanceTo(AbsolutePosition, posLastSignificantMove) > 0.5) 2869 // Movement updates for agents in neighboring regions are sent directly to clients.
2870 // This value only affects how often agent positions are sent to neighbor regions
2871 // for things such as distance-based update prioritization
2872 const float SIGNIFICANT_MOVEMENT = 2.0f;
2873
2874 if (Util.GetDistanceTo(AbsolutePosition, posLastSignificantMove) > SIGNIFICANT_MOVEMENT)
2864 { 2875 {
2865 posLastSignificantMove = AbsolutePosition; 2876 posLastSignificantMove = AbsolutePosition;
2866 m_scene.EventManager.TriggerSignificantClientMovement(m_controllingClient); 2877 m_scene.EventManager.TriggerSignificantClientMovement(m_controllingClient);
@@ -2871,18 +2882,19 @@ namespace OpenSim.Region.Framework.Scenes
2871 if (Util.GetDistanceTo(AbsolutePosition, m_lastChildAgentUpdatePosition) >= Scene.ChildReprioritizationDistance || 2882 if (Util.GetDistanceTo(AbsolutePosition, m_lastChildAgentUpdatePosition) >= Scene.ChildReprioritizationDistance ||
2872 Util.GetDistanceTo(CameraPosition, m_lastChildAgentUpdateCamPosition) >= Scene.ChildReprioritizationDistance) 2883 Util.GetDistanceTo(CameraPosition, m_lastChildAgentUpdateCamPosition) >= Scene.ChildReprioritizationDistance)
2873 { 2884 {
2885 m_lastChildAgentUpdatePosition = AbsolutePosition;
2886 m_lastChildAgentUpdateCamPosition = CameraPosition;
2887
2874 ChildAgentDataUpdate cadu = new ChildAgentDataUpdate(); 2888 ChildAgentDataUpdate cadu = new ChildAgentDataUpdate();
2875 cadu.ActiveGroupID = UUID.Zero.Guid; 2889 cadu.ActiveGroupID = UUID.Zero.Guid;
2876 cadu.AgentID = UUID.Guid; 2890 cadu.AgentID = UUID.Guid;
2877 cadu.alwaysrun = m_setAlwaysRun; 2891 cadu.alwaysrun = m_setAlwaysRun;
2878 cadu.AVHeight = m_avHeight; 2892 cadu.AVHeight = m_avHeight;
2879 sLLVector3 tempCameraCenter = new sLLVector3(new Vector3(m_CameraCenter.X, m_CameraCenter.Y, m_CameraCenter.Z)); 2893 Vector3 tempCameraCenter = m_CameraCenter;
2880 cadu.cameraPosition = tempCameraCenter; 2894 cadu.cameraPosition = tempCameraCenter;
2881 cadu.drawdistance = m_DrawDistance; 2895 cadu.drawdistance = m_DrawDistance;
2882 if (m_scene.Permissions.IsGod(new UUID(cadu.AgentID)))
2883 cadu.godlevel = m_godlevel;
2884 cadu.GroupAccess = 0; 2896 cadu.GroupAccess = 0;
2885 cadu.Position = new sLLVector3(AbsolutePosition); 2897 cadu.Position = AbsolutePosition;
2886 cadu.regionHandle = m_rootRegionHandle; 2898 cadu.regionHandle = m_rootRegionHandle;
2887 float multiplier = 1; 2899 float multiplier = 1;
2888 int innacurateNeighbors = m_scene.GetInaccurateNeighborCount(); 2900 int innacurateNeighbors = m_scene.GetInaccurateNeighborCount();
@@ -2897,15 +2909,12 @@ namespace OpenSim.Region.Framework.Scenes
2897 2909
2898 //m_log.Info("[NeighborThrottle]: " + m_scene.GetInaccurateNeighborCount().ToString() + " - m: " + multiplier.ToString()); 2910 //m_log.Info("[NeighborThrottle]: " + m_scene.GetInaccurateNeighborCount().ToString() + " - m: " + multiplier.ToString());
2899 cadu.throttles = ControllingClient.GetThrottlesPacked(multiplier); 2911 cadu.throttles = ControllingClient.GetThrottlesPacked(multiplier);
2900 cadu.Velocity = new sLLVector3(Velocity); 2912 cadu.Velocity = Velocity;
2901 2913
2902 AgentPosition agentpos = new AgentPosition(); 2914 AgentPosition agentpos = new AgentPosition();
2903 agentpos.CopyFrom(cadu); 2915 agentpos.CopyFrom(cadu);
2904 2916
2905 m_scene.SendOutChildAgentUpdates(agentpos, this); 2917 m_scene.SendOutChildAgentUpdates(agentpos, this);
2906
2907 m_lastChildAgentUpdatePosition = AbsolutePosition;
2908 m_lastChildAgentUpdateCamPosition = CameraPosition;
2909 } 2918 }
2910 } 2919 }
2911 2920
@@ -3161,18 +3170,21 @@ namespace OpenSim.Region.Framework.Scenes
3161 // For now, assign god level 200 to anyone 3170 // For now, assign god level 200 to anyone
3162 // who is granted god powers, but has no god level set. 3171 // who is granted god powers, but has no god level set.
3163 // 3172 //
3164 CachedUserInfo profile = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(agentID); 3173 UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, agentID);
3165 if (profile.UserProfile.GodLevel > 0) 3174 if (account != null)
3166 m_godlevel = profile.UserProfile.GodLevel; 3175 {
3167 else 3176 if (account.UserLevel > 0)
3168 m_godlevel = 200; 3177 m_godLevel = account.UserLevel;
3178 else
3179 m_godLevel = 200;
3180 }
3169 } 3181 }
3170 else 3182 else
3171 { 3183 {
3172 m_godlevel = 0; 3184 m_godLevel = 0;
3173 } 3185 }
3174 3186
3175 ControllingClient.SendAdminResponse(token, (uint)m_godlevel); 3187 ControllingClient.SendAdminResponse(token, (uint)m_godLevel);
3176 } 3188 }
3177 3189
3178 #region Child Agent Updates 3190 #region Child Agent Updates
@@ -3231,7 +3243,7 @@ namespace OpenSim.Region.Framework.Scenes
3231 public void CopyTo(AgentData cAgent) 3243 public void CopyTo(AgentData cAgent)
3232 { 3244 {
3233 cAgent.AgentID = UUID; 3245 cAgent.AgentID = UUID;
3234 cAgent.RegionHandle = m_rootRegionHandle; 3246 cAgent.RegionID = Scene.RegionInfo.RegionID;
3235 3247
3236 cAgent.Position = AbsolutePosition; 3248 cAgent.Position = AbsolutePosition;
3237 cAgent.Velocity = m_velocity; 3249 cAgent.Velocity = m_velocity;
@@ -3263,7 +3275,7 @@ namespace OpenSim.Region.Framework.Scenes
3263 cAgent.ControlFlags = (uint)m_AgentControlFlags; 3275 cAgent.ControlFlags = (uint)m_AgentControlFlags;
3264 3276
3265 if (m_scene.Permissions.IsGod(new UUID(cAgent.AgentID))) 3277 if (m_scene.Permissions.IsGod(new UUID(cAgent.AgentID)))
3266 cAgent.GodLevel = (byte)m_godlevel; 3278 cAgent.GodLevel = (byte)m_godLevel;
3267 else 3279 else
3268 cAgent.GodLevel = (byte) 0; 3280 cAgent.GodLevel = (byte) 0;
3269 3281
@@ -3330,11 +3342,12 @@ namespace OpenSim.Region.Framework.Scenes
3330 3342
3331 public void CopyFrom(AgentData cAgent) 3343 public void CopyFrom(AgentData cAgent)
3332 { 3344 {
3333 m_rootRegionHandle = cAgent.RegionHandle; 3345 m_originRegionID = cAgent.RegionID;
3334 3346
3335 m_callbackURI = cAgent.CallbackURI; 3347 m_callbackURI = cAgent.CallbackURI;
3336 3348
3337 m_pos = cAgent.Position; 3349 m_pos = cAgent.Position;
3350
3338 m_velocity = cAgent.Velocity; 3351 m_velocity = cAgent.Velocity;
3339 m_CameraCenter = cAgent.Center; 3352 m_CameraCenter = cAgent.Center;
3340 //m_avHeight = cAgent.Size.Z; 3353 //m_avHeight = cAgent.Size.Z;
@@ -3352,7 +3365,7 @@ namespace OpenSim.Region.Framework.Scenes
3352 m_AgentControlFlags = (AgentManager.ControlFlags)cAgent.ControlFlags; 3365 m_AgentControlFlags = (AgentManager.ControlFlags)cAgent.ControlFlags;
3353 3366
3354 if (m_scene.Permissions.IsGod(new UUID(cAgent.AgentID))) 3367 if (m_scene.Permissions.IsGod(new UUID(cAgent.AgentID)))
3355 m_godlevel = cAgent.GodLevel; 3368 m_godLevel = cAgent.GodLevel;
3356 m_setAlwaysRun = cAgent.AlwaysRun; 3369 m_setAlwaysRun = cAgent.AlwaysRun;
3357 3370
3358 uint i = 0; 3371 uint i = 0;
@@ -3710,36 +3723,6 @@ namespace OpenSim.Region.Framework.Scenes
3710 } 3723 }
3711 } 3724 }
3712 3725
3713 public bool CrossAttachmentsIntoNewRegion(ulong regionHandle, bool silent)
3714 {
3715 lock (m_attachments)
3716 {
3717 // Validate
3718 foreach (SceneObjectGroup gobj in m_attachments)
3719 {
3720 if (gobj == null || gobj.IsDeleted)
3721 return false;
3722 }
3723
3724 foreach (SceneObjectGroup gobj in m_attachments)
3725 {
3726 // If the prim group is null then something must have happened to it!
3727 if (gobj != null && gobj.RootPart != null)
3728 {
3729 // Set the parent localID to 0 so it transfers over properly.
3730 gobj.RootPart.SetParentLocalId(0);
3731 gobj.AbsolutePosition = gobj.RootPart.AttachedPos;
3732 gobj.RootPart.IsAttachment = false;
3733 //gobj.RootPart.LastOwnerID = gobj.GetFromAssetID();
3734 m_log.DebugFormat("[ATTACHMENT]: Sending attachment {0} to region {1}", gobj.UUID, regionHandle);
3735 m_scene.CrossPrimGroupIntoNewRegion(regionHandle, gobj, silent);
3736 }
3737 }
3738 m_attachments.Clear();
3739
3740 return true;
3741 }
3742 }
3743 3726
3744 public void initializeScenePresence(IClientAPI client, RegionInfo region, Scene scene) 3727 public void initializeScenePresence(IClientAPI client, RegionInfo region, Scene scene)
3745 { 3728 {
@@ -3975,7 +3958,7 @@ namespace OpenSim.Region.Framework.Scenes
3975 { 3958 {
3976 if (null == m_appearance) 3959 if (null == m_appearance)
3977 { 3960 {
3978 m_log.WarnFormat("[ATTACHMENT] Appearance has not been initialized for agent {0}", UUID); 3961 m_log.WarnFormat("[ATTACHMENT]: Appearance has not been initialized for agent {0}", UUID);
3979 return; 3962 return;
3980 } 3963 }
3981 3964
@@ -3999,12 +3982,12 @@ namespace OpenSim.Region.Framework.Scenes
3999 try 3982 try
4000 { 3983 {
4001 // Rez from inventory 3984 // Rez from inventory
4002 UUID asset = m_scene.RezSingleAttachment(ControllingClient, 3985 UUID asset
4003 itemID, (uint)p); 3986 = m_scene.AttachmentsModule.RezSingleAttachmentFromInventory(ControllingClient, itemID, (uint)p);
4004
4005 m_log.InfoFormat("[ATTACHMENT]: Rezzed attachment in point {0} from item {1} and asset {2} ({3})",
4006 p, itemID, assetID, asset);
4007 3987
3988 m_log.InfoFormat(
3989 "[ATTACHMENT]: Rezzed attachment in point {0} from item {1} and asset {2} ({3})",
3990 p, itemID, assetID, asset);
4008 } 3991 }
4009 catch (Exception e) 3992 catch (Exception e)
4010 { 3993 {
diff --git a/OpenSim/Region/Framework/Scenes/SceneViewer.cs b/OpenSim/Region/Framework/Scenes/SceneViewer.cs
index 1cff0eb..4ba4fab 100644
--- a/OpenSim/Region/Framework/Scenes/SceneViewer.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneViewer.cs
@@ -31,7 +31,6 @@ using OpenMetaverse;
31using log4net; 31using log4net;
32using OpenSim.Framework; 32using OpenSim.Framework;
33using OpenSim.Framework.Client; 33using OpenSim.Framework.Client;
34using OpenSim.Framework.Communications.Cache;
35using OpenSim.Region.Framework.Interfaces; 34using OpenSim.Region.Framework.Interfaces;
36using OpenSim.Region.Framework.Scenes.Types; 35using OpenSim.Region.Framework.Scenes.Types;
37 36
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneBaseTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneBaseTests.cs
index 8230f32..dd9f8f6 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
65 { 65 {
66 throw new NotImplementedException(); 66 throw new NotImplementedException();
67 } 67 }
68
69 public override bool TryGetScenePresence(UUID agentID, out ScenePresence scenePresence)
70 {
71 throw new NotImplementedException();
72 }
68 } 73 }
69 74
70 [Test] 75 [Test]
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs
index 0ed00de..78f2ae3 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs
@@ -32,8 +32,7 @@ using NUnit.Framework.SyntaxHelpers;
32using OpenMetaverse; 32using OpenMetaverse;
33using OpenSim.Framework; 33using OpenSim.Framework;
34using OpenSim.Framework.Communications; 34using OpenSim.Framework.Communications;
35using OpenSim.Framework.Communications.Cache; 35
36using OpenSim.Region.Communications.Local;
37using OpenSim.Region.Framework.Scenes; 36using OpenSim.Region.Framework.Scenes;
38using OpenSim.Tests.Common; 37using OpenSim.Tests.Common;
39using OpenSim.Tests.Common.Mock; 38using OpenSim.Tests.Common.Mock;
@@ -87,6 +86,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
87 public void TestDeleteSceneObjectAsync() 86 public void TestDeleteSceneObjectAsync()
88 { 87 {
89 TestHelper.InMethod(); 88 TestHelper.InMethod();
89 //log4net.Config.XmlConfigurator.Configure();
90 90
91 UUID agentId = UUID.Parse("00000000-0000-0000-0000-000000000001"); 91 UUID agentId = UUID.Parse("00000000-0000-0000-0000-000000000001");
92 92
@@ -95,16 +95,18 @@ namespace OpenSim.Region.Framework.Scenes.Tests
95 // Turn off the timer on the async sog deleter - we'll crank it by hand for this test. 95 // Turn off the timer on the async sog deleter - we'll crank it by hand for this test.
96 AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter; 96 AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter;
97 sogd.Enabled = false; 97 sogd.Enabled = false;
98 98
99 SceneObjectPart part = SceneSetupHelpers.AddSceneObject(scene); 99 SceneObjectPart part = SceneSetupHelpers.AddSceneObject(scene);
100 100
101 IClientAPI client = SceneSetupHelpers.AddRootAgent(scene, agentId); 101 IClientAPI client = SceneSetupHelpers.AddRootAgent(scene, agentId);
102 scene.DeRezObject(client, part.LocalId, UUID.Zero, DeRezAction.Delete, UUID.Zero); 102 scene.DeRezObject(client, part.LocalId, UUID.Zero, DeRezAction.Delete, UUID.Zero);
103 103
104 SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId); 104 SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId);
105
105 Assert.That(retrievedPart, Is.Not.Null); 106 Assert.That(retrievedPart, Is.Not.Null);
106 107
107 sogd.InventoryDeQueueAndDelete(); 108 sogd.InventoryDeQueueAndDelete();
109
108 SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(part.LocalId); 110 SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(part.LocalId);
109 Assert.That(retrievedPart2, Is.Null); 111 Assert.That(retrievedPart2, Is.Null);
110 } 112 }
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs
index 709cca2..0b7608d 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs
@@ -32,8 +32,7 @@ using NUnit.Framework.SyntaxHelpers;
32using OpenMetaverse; 32using OpenMetaverse;
33using OpenSim.Framework; 33using OpenSim.Framework;
34using OpenSim.Framework.Communications; 34using OpenSim.Framework.Communications;
35using OpenSim.Framework.Communications.Cache; 35
36using OpenSim.Region.Communications.Local;
37using OpenSim.Region.Framework.Scenes; 36using OpenSim.Region.Framework.Scenes;
38using OpenSim.Tests.Common; 37using OpenSim.Tests.Common;
39using OpenSim.Tests.Common.Mock; 38using OpenSim.Tests.Common.Mock;
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs
index f00dd66..501207e 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs
@@ -40,8 +40,8 @@ using OpenSim.Framework;
40using OpenSim.Framework.Communications; 40using OpenSim.Framework.Communications;
41using OpenSim.Region.Framework.Scenes; 41using OpenSim.Region.Framework.Scenes;
42using OpenSim.Region.Framework.Interfaces; 42using OpenSim.Region.Framework.Interfaces;
43using OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion;
44using OpenSim.Region.CoreModules.World.Serialiser; 43using OpenSim.Region.CoreModules.World.Serialiser;
44using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation;
45using OpenSim.Tests.Common; 45using OpenSim.Tests.Common;
46using OpenSim.Tests.Common.Mock; 46using OpenSim.Tests.Common.Mock;
47using OpenSim.Tests.Common.Setup; 47using OpenSim.Tests.Common.Setup;
@@ -58,7 +58,6 @@ namespace OpenSim.Region.Framework.Scenes.Tests
58 public UUID agent1, agent2, agent3; 58 public UUID agent1, agent2, agent3;
59 public static Random random; 59 public static Random random;
60 public ulong region1,region2,region3; 60 public ulong region1,region2,region3;
61 public TestCommunicationsManager cm;
62 public AgentCircuitData acd1; 61 public AgentCircuitData acd1;
63 public SceneObjectGroup sog1, sog2, sog3; 62 public SceneObjectGroup sog1, sog2, sog3;
64 public TestClient testclient; 63 public TestClient testclient;
@@ -66,12 +65,11 @@ namespace OpenSim.Region.Framework.Scenes.Tests
66 [TestFixtureSetUp] 65 [TestFixtureSetUp]
67 public void Init() 66 public void Init()
68 { 67 {
69 cm = new TestCommunicationsManager(); 68 scene = SceneSetupHelpers.SetupScene("Neighbour x", UUID.Random(), 1000, 1000);
70 scene = SceneSetupHelpers.SetupScene("Neighbour x", UUID.Random(), 1000, 1000, cm); 69 scene2 = SceneSetupHelpers.SetupScene("Neighbour x+1", UUID.Random(), 1001, 1000);
71 scene2 = SceneSetupHelpers.SetupScene("Neighbour x+1", UUID.Random(), 1001, 1000, cm); 70 scene3 = SceneSetupHelpers.SetupScene("Neighbour x-1", UUID.Random(), 999, 1000);
72 scene3 = SceneSetupHelpers.SetupScene("Neighbour x-1", UUID.Random(), 999, 1000, cm);
73 71
74 ISharedRegionModule interregionComms = new RESTInterregionComms(); 72 ISharedRegionModule interregionComms = new LocalSimulationConnectorModule();
75 interregionComms.Initialise(new IniConfigSource()); 73 interregionComms.Initialise(new IniConfigSource());
76 interregionComms.PostInitialise(); 74 interregionComms.PostInitialise();
77 SceneSetupHelpers.SetupSceneModules(scene, new IniConfigSource(), interregionComms); 75 SceneSetupHelpers.SetupSceneModules(scene, new IniConfigSource(), interregionComms);
@@ -373,7 +371,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
373 371
374 Assert.That(presence.HasAttachments(), Is.False, "Presence has attachments before cross"); 372 Assert.That(presence.HasAttachments(), Is.False, "Presence has attachments before cross");
375 373
376 Assert.That(presence2.CrossAttachmentsIntoNewRegion(region1, true), Is.True, "Cross was not successful"); 374 //Assert.That(presence2.CrossAttachmentsIntoNewRegion(region1, true), Is.True, "Cross was not successful");
377 Assert.That(presence2.HasAttachments(), Is.False, "Presence2 objects were not deleted"); 375 Assert.That(presence2.HasAttachments(), Is.False, "Presence2 objects were not deleted");
378 Assert.That(presence.HasAttachments(), Is.True, "Presence has not received new objects"); 376 Assert.That(presence.HasAttachments(), Is.True, "Presence has not received new objects");
379 } 377 }
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs
index 5abbb82..8b2d387 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs
@@ -101,13 +101,13 @@ namespace OpenSim.Region.Framework.Scenes.Tests
101 { 101 {
102 throw new NotImplementedException(); 102 throw new NotImplementedException();
103 } 103 }
104 public RegionMeta7WindlightData LoadRegionWindlightSettings(UUID regionUUID) 104 public RegionLightShareData LoadRegionWindlightSettings(UUID regionUUID)
105 { 105 {
106 //This connector doesn't support the windlight module yet 106 //This connector doesn't support the windlight module yet
107 //Return default LL windlight settings 107 //Return default LL windlight settings
108 return new RegionMeta7WindlightData(); 108 return new RegionLightShareData();
109 } 109 }
110 public void StoreRegionWindlightSettings(RegionMeta7WindlightData wl) 110 public void StoreRegionWindlightSettings(RegionLightShareData wl)
111 { 111 {
112 //This connector doesn't support the windlight module yet 112 //This connector doesn't support the windlight module yet
113 } 113 }
@@ -141,7 +141,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
141 RegionInfo regionInfo = new RegionInfo(0,0,null,null); 141 RegionInfo regionInfo = new RegionInfo(0,0,null,null);
142 FakeStorageManager storageManager = new FakeStorageManager(); 142 FakeStorageManager storageManager = new FakeStorageManager();
143 143
144 new Scene(regionInfo, null, null, null, storageManager, null, false, false, false, null, null); 144 new Scene(regionInfo, null, null, storageManager, null, false, false, false, null, null);
145 } 145 }
146 } 146 }
147} 147}
diff --git a/OpenSim/Region/Framework/Scenes/Tests/StandaloneTeleportTests.cs b/OpenSim/Region/Framework/Scenes/Tests/StandaloneTeleportTests.cs
index b46eb8e..cafe48a 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/StandaloneTeleportTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/StandaloneTeleportTests.cs
@@ -34,7 +34,7 @@ using OpenMetaverse;
34using OpenSim.Framework; 34using OpenSim.Framework;
35using OpenSim.Framework.Communications; 35using OpenSim.Framework.Communications;
36using OpenSim.Region.Framework.Interfaces; 36using OpenSim.Region.Framework.Interfaces;
37using OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion; 37using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation;
38using OpenSim.Tests.Common; 38using OpenSim.Tests.Common;
39using OpenSim.Tests.Common.Mock; 39using OpenSim.Tests.Common.Mock;
40using OpenSim.Tests.Common.Setup; 40using OpenSim.Tests.Common.Setup;
@@ -113,17 +113,16 @@ namespace OpenSim.Region.Framework.Scenes.Tests
113 113
114 UUID sceneAId = UUID.Parse("00000000-0000-0000-0000-000000000100"); 114 UUID sceneAId = UUID.Parse("00000000-0000-0000-0000-000000000100");
115 UUID sceneBId = UUID.Parse("00000000-0000-0000-0000-000000000200"); 115 UUID sceneBId = UUID.Parse("00000000-0000-0000-0000-000000000200");
116 TestCommunicationsManager cm = new TestCommunicationsManager();
117 116
118 // shared module 117 // shared module
119 ISharedRegionModule interregionComms = new RESTInterregionComms(); 118 ISharedRegionModule interregionComms = new LocalSimulationConnectorModule();
120 119
121 120
122 Scene sceneB = SceneSetupHelpers.SetupScene("sceneB", sceneBId, 1010, 1010, cm, "grid"); 121 Scene sceneB = SceneSetupHelpers.SetupScene("sceneB", sceneBId, 1010, 1010, "grid");
123 SceneSetupHelpers.SetupSceneModules(sceneB, new IniConfigSource(), interregionComms); 122 SceneSetupHelpers.SetupSceneModules(sceneB, new IniConfigSource(), interregionComms);
124 sceneB.RegisterRegionWithGrid(); 123 sceneB.RegisterRegionWithGrid();
125 124
126 Scene sceneA = SceneSetupHelpers.SetupScene("sceneA", sceneAId, 1000, 1000, cm, "grid"); 125 Scene sceneA = SceneSetupHelpers.SetupScene("sceneA", sceneAId, 1000, 1000, "grid");
127 SceneSetupHelpers.SetupSceneModules(sceneA, new IniConfigSource(), interregionComms); 126 SceneSetupHelpers.SetupSceneModules(sceneA, new IniConfigSource(), interregionComms);
128 sceneA.RegisterRegionWithGrid(); 127 sceneA.RegisterRegionWithGrid();
129 128
diff --git a/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs b/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs
index a36c4db..8b80ebe 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs
@@ -58,10 +58,10 @@ namespace OpenSim.Region.Framework.Scenes.Tests
58 TestHelper.InMethod(); 58 TestHelper.InMethod();
59 59
60 UUID corruptAssetUuid = UUID.Parse("00000000-0000-0000-0000-000000000666"); 60 UUID corruptAssetUuid = UUID.Parse("00000000-0000-0000-0000-000000000666");
61 AssetBase corruptAsset = AssetHelpers.CreateAsset(corruptAssetUuid, "CORRUPT ASSET"); 61 AssetBase corruptAsset = AssetHelpers.CreateAsset(corruptAssetUuid, "CORRUPT ASSET", UUID.Zero);
62 m_assetService.Store(corruptAsset); 62 m_assetService.Store(corruptAsset);
63 63
64 IDictionary<UUID, int> foundAssetUuids = new Dictionary<UUID, int>(); 64 IDictionary<UUID, AssetType> foundAssetUuids = new Dictionary<UUID, AssetType>();
65 m_uuidGatherer.GatherAssetUuids(corruptAssetUuid, AssetType.Object, foundAssetUuids); 65 m_uuidGatherer.GatherAssetUuids(corruptAssetUuid, AssetType.Object, foundAssetUuids);
66 66
67 // We count the uuid as gathered even if the asset itself is corrupt. 67 // We count the uuid as gathered even if the asset itself is corrupt.
@@ -77,7 +77,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
77 TestHelper.InMethod(); 77 TestHelper.InMethod();
78 78
79 UUID missingAssetUuid = UUID.Parse("00000000-0000-0000-0000-000000000666"); 79 UUID missingAssetUuid = UUID.Parse("00000000-0000-0000-0000-000000000666");
80 IDictionary<UUID, int> foundAssetUuids = new Dictionary<UUID, int>(); 80 IDictionary<UUID, AssetType> foundAssetUuids = new Dictionary<UUID, AssetType>();
81 81
82 m_uuidGatherer.GatherAssetUuids(missingAssetUuid, AssetType.Object, foundAssetUuids); 82 m_uuidGatherer.GatherAssetUuids(missingAssetUuid, AssetType.Object, foundAssetUuids);
83 83
diff --git a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs
index 3edb677..0ec3cc3 100644
--- a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs
+++ b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs
@@ -84,9 +84,9 @@ namespace OpenSim.Region.Framework.Scenes
84 /// <param name="assetUuid">The uuid of the asset for which to gather referenced assets</param> 84 /// <param name="assetUuid">The uuid of the asset for which to gather referenced assets</param>
85 /// <param name="assetType">The type of the asset for the uuid given</param> 85 /// <param name="assetType">The type of the asset for the uuid given</param>
86 /// <param name="assetUuids">The assets gathered</param> 86 /// <param name="assetUuids">The assets gathered</param>
87 public void GatherAssetUuids(UUID assetUuid, AssetType assetType, IDictionary<UUID, int> assetUuids) 87 public void GatherAssetUuids(UUID assetUuid, AssetType assetType, IDictionary<UUID, AssetType> assetUuids)
88 { 88 {
89 assetUuids[assetUuid] = 1; 89 assetUuids[assetUuid] = assetType;
90 90
91 if (AssetType.Bodypart == assetType || AssetType.Clothing == assetType) 91 if (AssetType.Bodypart == assetType || AssetType.Clothing == assetType)
92 { 92 {
@@ -116,7 +116,7 @@ namespace OpenSim.Region.Framework.Scenes
116 /// 116 ///
117 /// <param name="sceneObject">The scene object for which to gather assets</param> 117 /// <param name="sceneObject">The scene object for which to gather assets</param>
118 /// <param name="assetUuids">The assets gathered</param> 118 /// <param name="assetUuids">The assets gathered</param>
119 public void GatherAssetUuids(SceneObjectGroup sceneObject, IDictionary<UUID, int> assetUuids) 119 public void GatherAssetUuids(SceneObjectGroup sceneObject, IDictionary<UUID, AssetType> assetUuids)
120 { 120 {
121// m_log.DebugFormat( 121// m_log.DebugFormat(
122// "[ASSET GATHERER]: Getting assets for object {0}, {1}", sceneObject.Name, sceneObject.UUID); 122// "[ASSET GATHERER]: Getting assets for object {0}, {1}", sceneObject.Name, sceneObject.UUID);
@@ -129,25 +129,26 @@ namespace OpenSim.Region.Framework.Scenes
129 try 129 try
130 { 130 {
131 Primitive.TextureEntry textureEntry = part.Shape.Textures; 131 Primitive.TextureEntry textureEntry = part.Shape.Textures;
132 132 if (textureEntry != null)
133 // Get the prim's default texture. This will be used for faces which don't have their own texture
134 assetUuids[textureEntry.DefaultTexture.TextureID] = 1;
135
136 // XXX: Not a great way to iterate through face textures, but there's no
137 // other method available to tell how many faces there actually are
138 //int i = 0;
139 foreach (Primitive.TextureEntryFace texture in textureEntry.FaceTextures)
140 { 133 {
141 if (texture != null) 134 // Get the prim's default texture. This will be used for faces which don't have their own texture
135 if (textureEntry.DefaultTexture != null)
136 assetUuids[textureEntry.DefaultTexture.TextureID] = AssetType.Texture;
137
138 if (textureEntry.FaceTextures != null)
142 { 139 {
143 //m_log.DebugFormat("[ARCHIVER]: Got face {0}", i++); 140 // Loop through the rest of the texture faces (a non-null face means the face is different from DefaultTexture)
144 assetUuids[texture.TextureID] = 1; 141 foreach (Primitive.TextureEntryFace texture in textureEntry.FaceTextures)
142 {
143 if (texture != null)
144 assetUuids[texture.TextureID] = AssetType.Texture;
145 }
145 } 146 }
146 } 147 }
147 148
148 // If the prim is a sculpt then preserve this information too 149 // If the prim is a sculpt then preserve this information too
149 if (part.Shape.SculptTexture != UUID.Zero) 150 if (part.Shape.SculptTexture != UUID.Zero)
150 assetUuids[part.Shape.SculptTexture] = 1; 151 assetUuids[part.Shape.SculptTexture] = AssetType.Texture;
151 152
152 TaskInventoryDictionary taskDictionary = (TaskInventoryDictionary)part.TaskInventory.Clone(); 153 TaskInventoryDictionary taskDictionary = (TaskInventoryDictionary)part.TaskInventory.Clone();
153 154
@@ -217,7 +218,7 @@ namespace OpenSim.Region.Framework.Scenes
217 /// </summary> 218 /// </summary>
218 /// <param name="scriptUuid"></param> 219 /// <param name="scriptUuid"></param>
219 /// <param name="assetUuids">Dictionary in which to record the references</param> 220 /// <param name="assetUuids">Dictionary in which to record the references</param>
220 protected void GetScriptAssetUuids(UUID scriptUuid, IDictionary<UUID, int> assetUuids) 221 protected void GetScriptAssetUuids(UUID scriptUuid, IDictionary<UUID, AssetType> assetUuids)
221 { 222 {
222 AssetBase scriptAsset = GetAsset(scriptUuid); 223 AssetBase scriptAsset = GetAsset(scriptUuid);
223 224
@@ -232,7 +233,9 @@ namespace OpenSim.Region.Framework.Scenes
232 { 233 {
233 UUID uuid = new UUID(uuidMatch.Value); 234 UUID uuid = new UUID(uuidMatch.Value);
234 //m_log.DebugFormat("[ARCHIVER]: Recording {0} in script", uuid); 235 //m_log.DebugFormat("[ARCHIVER]: Recording {0} in script", uuid);
235 assetUuids[uuid] = 1; 236
237 // Assume AssetIDs embedded in scripts are textures
238 assetUuids[uuid] = AssetType.Texture;
236 } 239 }
237 } 240 }
238 } 241 }
@@ -242,7 +245,7 @@ namespace OpenSim.Region.Framework.Scenes
242 /// </summary> 245 /// </summary>
243 /// <param name="wearableAssetUuid"></param> 246 /// <param name="wearableAssetUuid"></param>
244 /// <param name="assetUuids">Dictionary in which to record the references</param> 247 /// <param name="assetUuids">Dictionary in which to record the references</param>
245 protected void GetWearableAssetUuids(UUID wearableAssetUuid, IDictionary<UUID, int> assetUuids) 248 protected void GetWearableAssetUuids(UUID wearableAssetUuid, IDictionary<UUID, AssetType> assetUuids)
246 { 249 {
247 AssetBase assetBase = GetAsset(wearableAssetUuid); 250 AssetBase assetBase = GetAsset(wearableAssetUuid);
248 251
@@ -257,8 +260,7 @@ namespace OpenSim.Region.Framework.Scenes
257 260
258 foreach (UUID uuid in wearableAsset.Textures.Values) 261 foreach (UUID uuid in wearableAsset.Textures.Values)
259 { 262 {
260 //m_log.DebugFormat("[ARCHIVER]: Got bodypart uuid {0}", uuid); 263 assetUuids[uuid] = AssetType.Texture;
261 assetUuids[uuid] = 1;
262 } 264 }
263 } 265 }
264 } 266 }
@@ -270,7 +272,7 @@ namespace OpenSim.Region.Framework.Scenes
270 /// </summary> 272 /// </summary>
271 /// <param name="sceneObject"></param> 273 /// <param name="sceneObject"></param>
272 /// <param name="assetUuids"></param> 274 /// <param name="assetUuids"></param>
273 protected void GetSceneObjectAssetUuids(UUID sceneObjectUuid, IDictionary<UUID, int> assetUuids) 275 protected void GetSceneObjectAssetUuids(UUID sceneObjectUuid, IDictionary<UUID, AssetType> assetUuids)
274 { 276 {
275 AssetBase objectAsset = GetAsset(sceneObjectUuid); 277 AssetBase objectAsset = GetAsset(sceneObjectUuid);
276 278
@@ -284,7 +286,7 @@ namespace OpenSim.Region.Framework.Scenes
284 } 286 }
285 } 287 }
286 288
287 protected void GetGestureAssetUuids(UUID gestureUuid, IDictionary<UUID, int> assetUuids) 289 protected void GetGestureAssetUuids(UUID gestureUuid, IDictionary<UUID, AssetType> assetUuids)
288 { 290 {
289 AssetBase assetBase = GetAsset(gestureUuid); 291 AssetBase assetBase = GetAsset(gestureUuid);
290 292
@@ -316,7 +318,7 @@ namespace OpenSim.Region.Framework.Scenes
316 // If it can be parsed as a UUID, it is an asset ID 318 // If it can be parsed as a UUID, it is an asset ID
317 UUID uuid; 319 UUID uuid;
318 if (UUID.TryParse(id, out uuid)) 320 if (UUID.TryParse(id, out uuid))
319 assetUuids[uuid] = 1; 321 assetUuids[uuid] = AssetType.Animation;
320 } 322 }
321 } 323 }
322 } 324 }