diff options
Diffstat (limited to 'OpenSim/Region/Framework')
47 files changed, 2029 insertions, 4231 deletions
diff --git a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs new file mode 100644 index 0000000..958847b --- /dev/null +++ b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs | |||
@@ -0,0 +1,140 @@ | |||
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 | |||
28 | using System; | ||
29 | using System.Xml; | ||
30 | using OpenMetaverse; | ||
31 | using OpenMetaverse.Packets; | ||
32 | using OpenSim.Framework; | ||
33 | using OpenSim.Region.Framework.Scenes; | ||
34 | |||
35 | namespace OpenSim.Region.Framework.Interfaces | ||
36 | { | ||
37 | public interface IAttachmentsModule | ||
38 | { | ||
39 | /// <summary> | ||
40 | /// Attach an object to an avatar from the world. | ||
41 | /// </summary> | ||
42 | /// <param name="controllingClient"></param> | ||
43 | /// <param name="localID"></param> | ||
44 | /// <param name="attachPoint"></param> | ||
45 | /// <param name="rot"></param> | ||
46 | /// <param name="silent"></param> | ||
47 | void AttachObject( | ||
48 | IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, Quaternion rot, bool silent); | ||
49 | |||
50 | /// <summary> | ||
51 | /// Attach an object to an avatar. | ||
52 | /// </summary> | ||
53 | /// <param name="controllingClient"></param> | ||
54 | /// <param name="localID"></param> | ||
55 | /// <param name="attachPoint"></param> | ||
56 | /// <param name="rot"></param> | ||
57 | /// <param name="attachPos"></param> | ||
58 | /// <param name="silent"></param> | ||
59 | /// <returns>true if the object was successfully attached, false otherwise</returns> | ||
60 | bool AttachObject( | ||
61 | IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, Quaternion rot, Vector3 attachPos, bool silent); | ||
62 | |||
63 | /// <summary> | ||
64 | /// Rez an attachment from user inventory and change inventory status to match. | ||
65 | /// </summary> | ||
66 | /// <param name="remoteClient"></param> | ||
67 | /// <param name="itemID"></param> | ||
68 | /// <param name="AttachmentPt"></param> | ||
69 | /// <returns>The scene object that was attached. Null if the scene object could not be found</returns> | ||
70 | UUID RezSingleAttachmentFromInventory(IClientAPI remoteClient, UUID itemID, uint AttachmentPt); | ||
71 | |||
72 | /// <summary> | ||
73 | /// Rez an attachment from user inventory | ||
74 | /// </summary> | ||
75 | /// <param name="remoteClient"></param> | ||
76 | /// <param name="itemID"></param> | ||
77 | /// <param name="AttachmentPt"></param> | ||
78 | /// <param name="updateinventoryStatus"> | ||
79 | /// If true, we also update the user's inventory to show that the attachment is set. If false, we do not. | ||
80 | /// False is required so that we don't attempt to update information when a user enters a scene with the | ||
81 | /// attachment already correctly set up in inventory. | ||
82 | /// <returns>The uuid of the scene object that was attached. Null if the scene object could not be found</returns> | ||
83 | UUID RezSingleAttachmentFromInventory( | ||
84 | IClientAPI remoteClient, UUID itemID, uint AttachmentPt, bool updateInventoryStatus); | ||
85 | |||
86 | // Same as above, but also load script states from a separate doc | ||
87 | UUID RezSingleAttachmentFromInventory( | ||
88 | IClientAPI remoteClient, UUID itemID, uint AttachmentPt, bool updateInventoryStatus, XmlDocument doc); | ||
89 | |||
90 | /// <summary> | ||
91 | /// Rez multiple attachments from a user's inventory | ||
92 | /// </summary> | ||
93 | /// <param name="remoteClient"></param> | ||
94 | /// <param name="header"></param> | ||
95 | /// <param name="objects"></param> | ||
96 | void RezMultipleAttachmentsFromInventory( | ||
97 | IClientAPI remoteClient, | ||
98 | RezMultipleAttachmentsFromInvPacket.HeaderDataBlock header, | ||
99 | RezMultipleAttachmentsFromInvPacket.ObjectDataBlock[] objects); | ||
100 | |||
101 | /// <summary> | ||
102 | /// Detach an object from the avatar. | ||
103 | /// </summary> | ||
104 | /// | ||
105 | /// This method is called in response to a client's detach request, so we only update the information in | ||
106 | /// inventory | ||
107 | /// <param name="objectLocalID"></param> | ||
108 | /// <param name="remoteClient"></param> | ||
109 | void DetachObject(uint objectLocalID, IClientAPI remoteClient); | ||
110 | |||
111 | /// <summary> | ||
112 | /// Detach the given item to the ground. | ||
113 | /// </summary> | ||
114 | /// <param name="itemID"></param> | ||
115 | /// <param name="remoteClient"></param> | ||
116 | void DetachSingleAttachmentToGround(UUID itemID, IClientAPI remoteClient); | ||
117 | |||
118 | /// <summary> | ||
119 | /// Update the user inventory to the attachment of an item | ||
120 | /// </summary> | ||
121 | /// <param name="att"></param> | ||
122 | /// <param name="remoteClient"></param> | ||
123 | /// <param name="itemID"></param> | ||
124 | /// <param name="AttachmentPt"></param> | ||
125 | /// <returns></returns> | ||
126 | UUID SetAttachmentInventoryStatus( | ||
127 | SceneObjectGroup att, IClientAPI remoteClient, UUID itemID, uint AttachmentPt); | ||
128 | |||
129 | /// <summary> | ||
130 | /// Update the user inventory to show a detach. | ||
131 | /// </summary> | ||
132 | /// <param name="itemID"> | ||
133 | /// A <see cref="UUID"/> | ||
134 | /// </param> | ||
135 | /// <param name="remoteClient"> | ||
136 | /// A <see cref="IClientAPI"/> | ||
137 | /// </param> | ||
138 | void ShowDetachInUserInventory(UUID itemID, IClientAPI remoteClient); | ||
139 | } | ||
140 | } | ||
diff --git a/OpenSim/Region/Framework/Interfaces/IDialogModule.cs b/OpenSim/Region/Framework/Interfaces/IDialogModule.cs index ce57c44..be9764a 100644 --- a/OpenSim/Region/Framework/Interfaces/IDialogModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IDialogModule.cs | |||
@@ -120,16 +120,8 @@ namespace OpenSim.Region.Framework.Interfaces | |||
120 | void SendNotificationToUsersInRegion(UUID fromAvatarID, string fromAvatarName, string message); | 120 | void SendNotificationToUsersInRegion(UUID fromAvatarID, string fromAvatarName, string message); |
121 | 121 | ||
122 | /// <summary> | 122 | /// <summary> |
123 | /// Send a notification to all users in the estate. This notification should remain around until the | 123 | /// Send a textbox entry for the client to respond to |
124 | /// user explicitly dismisses it. | ||
125 | /// </summary> | 124 | /// </summary> |
126 | /// | 125 | void SendTextBoxToUser(UUID avatarid, string message, int chatChannel, string name, UUID objectid, UUID ownerid); |
127 | /// On the Linden Labs Second Client (as of 1.21), this is a big blue box message on the upper right of the | ||
128 | /// screen. | ||
129 | /// | ||
130 | /// <param name="fromAvatarID">The user sending the message</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> | ||
133 | void SendNotificationToUsersInEstate(UUID fromAvatarID, string fromAvatarName, string message); | ||
134 | } | 126 | } |
135 | } | 127 | } |
diff --git a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs index 16ca3f9..1e2f60b 100644 --- a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs +++ b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs | |||
@@ -73,6 +73,9 @@ namespace OpenSim.Region.Framework.Interfaces | |||
73 | /// </summary> | 73 | /// </summary> |
74 | void CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource); | 74 | void CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource); |
75 | 75 | ||
76 | ArrayList GetScriptErrors(UUID itemID); | ||
77 | void ResumeScripts(); | ||
78 | |||
76 | /// <summary> | 79 | /// <summary> |
77 | /// Stop all the scripts in this entity. | 80 | /// Stop all the scripts in this entity. |
78 | /// </summary> | 81 | /// </summary> |
@@ -160,6 +163,7 @@ namespace OpenSim.Region.Framework.Interfaces | |||
160 | /// in this prim's inventory.</param> | 163 | /// in this prim's inventory.</param> |
161 | /// <returns>false if the item did not exist, true if the update occurred successfully</returns> | 164 | /// <returns>false if the item did not exist, true if the update occurred successfully</returns> |
162 | bool UpdateInventoryItem(TaskInventoryItem item); | 165 | bool UpdateInventoryItem(TaskInventoryItem item); |
166 | bool UpdateInventoryItem(TaskInventoryItem item, bool fireScriptEvents); | ||
163 | 167 | ||
164 | /// <summary> | 168 | /// <summary> |
165 | /// Remove an item from this entity's inventory | 169 | /// Remove an item from this entity's inventory |
@@ -212,5 +216,6 @@ namespace OpenSim.Region.Framework.Interfaces | |||
212 | /// A <see cref="Dictionary`2"/> | 216 | /// A <see cref="Dictionary`2"/> |
213 | /// </returns> | 217 | /// </returns> |
214 | Dictionary<UUID, string> GetScriptStates(); | 218 | Dictionary<UUID, string> GetScriptStates(); |
219 | Dictionary<UUID, string> GetScriptStates(bool oldIDs); | ||
215 | } | 220 | } |
216 | } | 221 | } |
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 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | ||
30 | |||
31 | using OpenSim.Framework; | ||
32 | using OpenSim.Services.Interfaces; | 29 | using OpenSim.Services.Interfaces; |
30 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
31 | |||
33 | using OpenMetaverse; | 32 | using OpenMetaverse; |
33 | using OpenSim.Framework; | ||
34 | using OpenSim.Region.Framework.Scenes; | ||
34 | 35 | ||
35 | namespace OpenSim.Region.Framework.Scenes.Hypergrid | 36 | namespace 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 | ||
28 | using System.Collections.Generic; | ||
28 | using OpenMetaverse; | 29 | using OpenMetaverse; |
29 | using OpenSim.Framework; | 30 | using 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/IEstateModule.cs b/OpenSim/Region/Framework/Interfaces/IEstateModule.cs index 890fa31..c850f7f 100644 --- a/OpenSim/Region/Framework/Interfaces/IEstateModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IEstateModule.cs | |||
@@ -29,8 +29,15 @@ using OpenMetaverse; | |||
29 | 29 | ||
30 | namespace OpenSim.Region.Framework.Interfaces | 30 | namespace OpenSim.Region.Framework.Interfaces |
31 | { | 31 | { |
32 | public delegate void ChangeDelegate(UUID regionID); | ||
33 | public delegate void MessageDelegate(UUID regionID, UUID fromID, string fromName, string message); | ||
34 | |||
32 | public interface IEstateModule : IRegionModule | 35 | public interface IEstateModule : IRegionModule |
33 | { | 36 | { |
37 | event ChangeDelegate OnRegionInfoChange; | ||
38 | event ChangeDelegate OnEstateInfoChange; | ||
39 | event MessageDelegate OnEstateMessage; | ||
40 | |||
34 | uint GetRegionFlags(); | 41 | uint GetRegionFlags(); |
35 | bool IsManager(UUID avatarID); | 42 | bool IsManager(UUID avatarID); |
36 | 43 | ||
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/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/IInterregionComms.cs b/OpenSim/Region/Framework/Interfaces/IInterregionComms.cs index 2d6287f..67a500f 100644 --- a/OpenSim/Region/Framework/Interfaces/IInterregionComms.cs +++ b/OpenSim/Region/Framework/Interfaces/IInterregionComms.cs | |||
@@ -68,6 +68,14 @@ namespace OpenSim.Region.Framework.Interfaces | |||
68 | bool SendReleaseAgent(ulong regionHandle, UUID id, string uri); | 68 | bool SendReleaseAgent(ulong regionHandle, UUID id, string uri); |
69 | 69 | ||
70 | /// <summary> | 70 | /// <summary> |
71 | /// Close chid agent. | ||
72 | /// </summary> | ||
73 | /// <param name="regionHandle"></param> | ||
74 | /// <param name="id"></param> | ||
75 | /// <returns></returns> | ||
76 | bool SendCloseChildAgent(ulong regionHandle, UUID id); | ||
77 | |||
78 | /// <summary> | ||
71 | /// Close agent. | 79 | /// Close agent. |
72 | /// </summary> | 80 | /// </summary> |
73 | /// <param name="regionHandle"></param> | 81 | /// <param name="regionHandle"></param> |
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 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Text; | 30 | |
31 | using OpenMetaverse; | 31 | using OpenSim.Framework; |
32 | using OpenSim.Region.Framework.Scenes; | 32 | using OpenSim.Region.Framework.Scenes; |
33 | 33 | ||
34 | using OpenMetaverse; | ||
35 | |||
34 | namespace OpenSim.Region.Framework.Interfaces | 36 | namespace 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 | ||
28 | using System; | 28 | using System; |
29 | using System.IO; | 29 | using System.IO; |
30 | using OpenSim.Framework.Communications.Cache; | 30 | using OpenSim.Services.Interfaces; |
31 | 31 | ||
32 | namespace OpenSim.Region.Framework.Interfaces | 32 | namespace 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/IRegionArchiverModule.cs b/OpenSim/Region/Framework/Interfaces/IRegionArchiverModule.cs index 991d60c..89e59d0 100644 --- a/OpenSim/Region/Framework/Interfaces/IRegionArchiverModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IRegionArchiverModule.cs | |||
@@ -90,8 +90,12 @@ namespace OpenSim.Region.Framework.Interfaces | |||
90 | /// If true, the loaded region merges with the existing one rather than replacing it. Any terrain or region | 90 | /// If true, the loaded region merges with the existing one rather than replacing it. Any terrain or region |
91 | /// settings in the archive will be ignored. | 91 | /// settings in the archive will be ignored. |
92 | /// </param> | 92 | /// </param> |
93 | /// <param name="skipAssets"> | ||
94 | /// If true, the archive is loaded without loading any assets contained within it. This is useful if the | ||
95 | /// assets are already known to be present in the grid's asset service. | ||
96 | /// </param> | ||
93 | /// <param name="requestId">If supplied, this request Id is later returned in the saved event</param> | 97 | /// <param name="requestId">If supplied, this request Id is later returned in the saved event</param> |
94 | void DearchiveRegion(string loadPath, bool merge, Guid requestId); | 98 | void DearchiveRegion(string loadPath, bool merge, bool skipAssets, Guid requestId); |
95 | 99 | ||
96 | /// <summary> | 100 | /// <summary> |
97 | /// Dearchive a region from a stream. This replaces the existing scene. | 101 | /// Dearchive a region from a stream. This replaces the existing scene. |
@@ -113,7 +117,11 @@ namespace OpenSim.Region.Framework.Interfaces | |||
113 | /// If true, the loaded region merges with the existing one rather than replacing it. Any terrain or region | 117 | /// If true, the loaded region merges with the existing one rather than replacing it. Any terrain or region |
114 | /// settings in the archive will be ignored. | 118 | /// settings in the archive will be ignored. |
115 | /// </param> | 119 | /// </param> |
120 | /// <param name="skipAssets"> | ||
121 | /// If true, the archive is loaded without loading any assets contained within it. This is useful if the | ||
122 | /// assets are already known to be present in the grid's asset service. | ||
123 | /// </param | ||
116 | /// <param name="requestId">If supplied, this request Id is later returned in the saved event</param> | 124 | /// <param name="requestId">If supplied, this request Id is later returned in the saved event</param> |
117 | void DearchiveRegion(Stream loadStream, bool merge, Guid requestId); | 125 | void DearchiveRegion(Stream loadStream, bool merge, bool skipAssets, Guid requestId); |
118 | } | 126 | } |
119 | } | 127 | } |
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/Interfaces/IRegionModule.cs b/OpenSim/Region/Framework/Interfaces/IRegionModule.cs index 8eb906c..e25a6e8 100644 --- a/OpenSim/Region/Framework/Interfaces/IRegionModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IRegionModule.cs | |||
@@ -30,6 +30,9 @@ using OpenSim.Region.Framework.Scenes; | |||
30 | 30 | ||
31 | namespace OpenSim.Region.Framework.Interfaces | 31 | namespace OpenSim.Region.Framework.Interfaces |
32 | { | 32 | { |
33 | /// <summary> | ||
34 | /// DEPRECATED! Use INonSharedRegionModule or ISharedRegionModule instead | ||
35 | /// </summary> | ||
33 | public interface IRegionModule | 36 | public interface IRegionModule |
34 | { | 37 | { |
35 | void Initialise(Scene scene, IConfigSource source); | 38 | void Initialise(Scene scene, IConfigSource source); |
diff --git a/OpenSim/Region/Framework/Interfaces/IScriptModule.cs b/OpenSim/Region/Framework/Interfaces/IScriptModule.cs index e90b300..fecdd1b 100644 --- a/OpenSim/Region/Framework/Interfaces/IScriptModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IScriptModule.cs | |||
@@ -41,6 +41,14 @@ namespace OpenSim.Region.Framework.Interfaces | |||
41 | bool PostScriptEvent(UUID itemID, string name, Object[] args); | 41 | bool PostScriptEvent(UUID itemID, string name, Object[] args); |
42 | bool PostObjectEvent(UUID itemID, string name, Object[] args); | 42 | bool PostObjectEvent(UUID itemID, string name, Object[] args); |
43 | 43 | ||
44 | // Suspend ALL scripts in a given scene object. The item ID | ||
45 | // is the UUID of a SOG, and the method acts on all contained | ||
46 | // scripts. This is different from the suspend/resume that | ||
47 | // can be issued by a client. | ||
48 | // | ||
49 | void SuspendScript(UUID itemID); | ||
50 | void ResumeScript(UUID itemID); | ||
51 | |||
44 | ArrayList GetScriptErrors(UUID itemID); | 52 | ArrayList GetScriptErrors(UUID itemID); |
45 | } | 53 | } |
46 | } | 54 | } |
diff --git a/OpenSim/Region/Framework/Interfaces/IWorldMapModule.cs b/OpenSim/Region/Framework/Interfaces/IWorldMapModule.cs index de1bcd4..ac6afed 100644 --- a/OpenSim/Region/Framework/Interfaces/IWorldMapModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IWorldMapModule.cs | |||
@@ -29,6 +29,6 @@ namespace OpenSim.Region.Framework.Interfaces | |||
29 | { | 29 | { |
30 | public interface IWorldMapModule | 30 | public interface IWorldMapModule |
31 | { | 31 | { |
32 | void LazySaveGeneratedMaptile(byte[] data, bool temporary); | 32 | void RegenerateMaptile(byte[] data); |
33 | } | 33 | } |
34 | } | 34 | } |
diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs index b43caf2..702a1e2 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs | |||
@@ -378,7 +378,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation | |||
378 | } | 378 | } |
379 | } | 379 | } |
380 | 380 | ||
381 | AssetBase Animasset = new AssetBase(UUID.Random(), "Random Animation", (sbyte)AssetType.Animation); | 381 | AssetBase Animasset = new AssetBase(UUID.Random(), "Random Animation", (sbyte)AssetType.Animation, m_scenePresence.UUID.ToString()); |
382 | Animasset.Data = anim.ToBytes(); | 382 | Animasset.Data = anim.ToBytes(); |
383 | Animasset.Temporary = true; | 383 | Animasset.Temporary = true; |
384 | Animasset.Local = true; | 384 | Animasset.Local = true; |
@@ -413,11 +413,12 @@ namespace OpenSim.Region.Framework.Scenes.Animation | |||
413 | if (m_scenePresence.IsChildAgent) | 413 | if (m_scenePresence.IsChildAgent) |
414 | return; | 414 | return; |
415 | 415 | ||
416 | m_scenePresence.Scene.ForEachScenePresence( | 416 | UUID[] animIDs; |
417 | delegate(ScenePresence SP) | 417 | int[] sequenceNums; |
418 | { | 418 | UUID[] objectIDs; |
419 | SP.Animator.SendAnimPack(); | 419 | |
420 | }); | 420 | m_animations.GetArrays(out animIDs, out sequenceNums, out objectIDs); |
421 | client.SendAnimations(animIDs, sequenceNums, m_scenePresence.ControllingClient.AgentId, objectIDs); | ||
421 | } | 422 | } |
422 | 423 | ||
423 | /// <summary> | 424 | /// <summary> |
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; | |||
32 | using log4net; | 32 | using log4net; |
33 | using OpenMetaverse; | 33 | using OpenMetaverse; |
34 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
35 | using OpenSim.Region.Framework.Interfaces; | ||
35 | 36 | ||
36 | namespace OpenSim.Region.Framework.Scenes | 37 | namespace 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 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Reflection; | ||
31 | using System.Threading; | ||
32 | using log4net; | ||
33 | using OpenMetaverse; | ||
34 | using OpenSim.Framework; | ||
35 | using OpenSim.Framework.Communications.Cache; | ||
36 | using OpenSim.Framework.Communications.Clients; | ||
37 | using OpenSim.Region.Framework.Scenes.Serialization; | ||
38 | using OpenSim.Region.Framework.Interfaces; | ||
39 | using OpenSim.Services.Interfaces; | ||
40 | |||
41 | //using HyperGrid.Framework; | ||
42 | //using OpenSim.Region.Communications.Hypergrid; | ||
43 | |||
44 | namespace 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 | |||
28 | using System.Reflection; | ||
29 | using log4net; | ||
30 | using Nini.Config; | ||
31 | using OpenMetaverse; | ||
32 | using OpenSim.Framework; | ||
33 | using OpenSim.Framework.Communications; | ||
34 | using OpenSim.Framework.Communications.Cache; | ||
35 | using OpenSim.Region.Framework.Interfaces; | ||
36 | |||
37 | namespace 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 | |||
28 | using OpenMetaverse; | ||
29 | using OpenSim.Framework; | ||
30 | using OpenSim.Framework.Communications.Cache; | ||
31 | using TPFlags = OpenSim.Framework.Constants.TeleportFlags; | ||
32 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
33 | |||
34 | namespace 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 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Net; | ||
31 | using System.Reflection; | ||
32 | using System.Threading; | ||
33 | using log4net; | ||
34 | using OpenMetaverse; | ||
35 | using OpenSim.Framework; | ||
36 | using OpenSim.Framework.Client; | ||
37 | using OpenSim.Framework.Communications; | ||
38 | using OpenSim.Framework.Communications.Cache; | ||
39 | using OpenSim.Framework.Capabilities; | ||
40 | using OpenSim.Region.Framework.Interfaces; | ||
41 | using OpenSim.Services.Interfaces; | ||
42 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
43 | |||
44 | namespace 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; | |||
36 | using OpenMetaverse.StructuredData; | 36 | using OpenMetaverse.StructuredData; |
37 | using OpenSim.Framework; | 37 | using OpenSim.Framework; |
38 | using OpenSim.Framework.Communications; | 38 | using OpenSim.Framework.Communications; |
39 | using OpenSim.Framework.Communications.Services; | 39 | |
40 | using OpenSim.Framework.Communications.Cache; | ||
41 | using OpenSim.Framework.Console; | 40 | using OpenSim.Framework.Console; |
42 | using OpenSim.Framework.Servers; | 41 | using OpenSim.Framework.Servers; |
43 | using OpenSim.Framework.Servers.HttpServer; | 42 | using OpenSim.Framework.Servers.HttpServer; |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index ba70ae5..cbe3456 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | |||
@@ -35,7 +35,6 @@ using OpenMetaverse; | |||
35 | using OpenMetaverse.Packets; | 35 | using OpenMetaverse.Packets; |
36 | using log4net; | 36 | using log4net; |
37 | using OpenSim.Framework; | 37 | using OpenSim.Framework; |
38 | using OpenSim.Framework.Communications.Cache; | ||
39 | using OpenSim.Region.Framework; | 38 | using OpenSim.Region.Framework; |
40 | using OpenSim.Region.Framework.Interfaces; | 39 | using OpenSim.Region.Framework.Interfaces; |
41 | using OpenSim.Region.Framework.Scenes.Serialization; | 40 | using OpenSim.Region.Framework.Scenes.Serialization; |
@@ -64,6 +63,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
64 | if (group is SceneObjectGroup) | 63 | if (group is SceneObjectGroup) |
65 | { | 64 | { |
66 | ((SceneObjectGroup) group).CreateScriptInstances(0, false, DefaultScriptEngine, 0); | 65 | ((SceneObjectGroup) group).CreateScriptInstances(0, false, DefaultScriptEngine, 0); |
66 | ((SceneObjectGroup) group).ResumeScripts(); | ||
67 | } | 67 | } |
68 | } | 68 | } |
69 | } | 69 | } |
@@ -94,6 +94,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
94 | 94 | ||
95 | public void AddInventoryItem(UUID AgentID, InventoryItemBase item) | 95 | public void AddInventoryItem(UUID AgentID, InventoryItemBase item) |
96 | { | 96 | { |
97 | InventoryFolderBase folder; | ||
98 | |||
99 | if (item.Folder == UUID.Zero) | ||
100 | { | ||
101 | folder = InventoryService.GetFolderForType(AgentID, (AssetType)item.AssetType); | ||
102 | if (folder == null) | ||
103 | { | ||
104 | folder = InventoryService.GetRootFolder(AgentID); | ||
105 | |||
106 | if (folder == null) | ||
107 | return; | ||
108 | } | ||
109 | |||
110 | item.Folder = folder.ID; | ||
111 | } | ||
112 | |||
97 | if (InventoryService.AddItem(item)) | 113 | if (InventoryService.AddItem(item)) |
98 | { | 114 | { |
99 | int userlevel = 0; | 115 | int userlevel = 0; |
@@ -101,12 +117,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
101 | { | 117 | { |
102 | userlevel = 1; | 118 | userlevel = 1; |
103 | } | 119 | } |
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); | 120 | EventManager.TriggerOnNewInventoryItemUploadComplete(AgentID, item.AssetID, item.Name, userlevel); |
111 | } | 121 | } |
112 | else | 122 | else |
@@ -132,70 +142,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
132 | } | 142 | } |
133 | 143 | ||
134 | /// <summary> | 144 | /// <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> | 145 | /// <see>CapsUpdatedInventoryItemAsset(IClientAPI, UUID, byte[])</see> |
191 | /// </summary> | 146 | /// </summary> |
192 | public UUID CapsUpdateInventoryItemAsset(UUID avatarId, UUID itemID, byte[] data) | 147 | public UUID CapsUpdateInventoryItemAsset(UUID avatarId, UUID itemID, byte[] data) |
193 | { | 148 | { |
194 | ScenePresence avatar; | 149 | ScenePresence avatar; |
195 | 150 | ||
196 | if (TryGetAvatar(avatarId, out avatar)) | 151 | if (TryGetScenePresence(avatarId, out avatar)) |
197 | { | 152 | { |
198 | return CapsUpdateInventoryItemAsset(avatar.ControllingClient, itemID, data); | 153 | IInventoryAccessModule invAccess = RequestModuleInterface<IInventoryAccessModule>(); |
154 | if (invAccess != null) | ||
155 | return invAccess.CapsUpdateInventoryItemAsset(avatar.ControllingClient, itemID, data); | ||
199 | } | 156 | } |
200 | else | 157 | else |
201 | { | 158 | { |
@@ -251,7 +208,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
251 | return new ArrayList(); | 208 | return new ArrayList(); |
252 | } | 209 | } |
253 | 210 | ||
254 | AssetBase asset = CreateAsset(item.Name, item.Description, (sbyte)AssetType.LSLText, data); | 211 | AssetBase asset = CreateAsset(item.Name, item.Description, (sbyte)AssetType.LSLText, data, remoteClient.AgentId); |
255 | AssetService.Store(asset); | 212 | AssetService.Store(asset); |
256 | 213 | ||
257 | if (isScriptRunning) | 214 | if (isScriptRunning) |
@@ -261,7 +218,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
261 | 218 | ||
262 | // Update item with new asset | 219 | // Update item with new asset |
263 | item.AssetID = asset.FullID; | 220 | item.AssetID = asset.FullID; |
264 | group.UpdateInventoryItem(item); | 221 | if (group.UpdateInventoryItem(item)) |
222 | remoteClient.SendAgentAlertMessage("Notecard saved", false); | ||
223 | |||
265 | part.GetProperties(remoteClient); | 224 | part.GetProperties(remoteClient); |
266 | 225 | ||
267 | // Trigger rerunning of script (use TriggerRezScript event, see RezScript) | 226 | // Trigger rerunning of script (use TriggerRezScript event, see RezScript) |
@@ -277,6 +236,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
277 | { | 236 | { |
278 | remoteClient.SendAgentAlertMessage("Script saved", false); | 237 | remoteClient.SendAgentAlertMessage("Script saved", false); |
279 | } | 238 | } |
239 | part.ParentGroup.ResumeScripts(); | ||
280 | return errors; | 240 | return errors; |
281 | } | 241 | } |
282 | 242 | ||
@@ -288,7 +248,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
288 | { | 248 | { |
289 | ScenePresence avatar; | 249 | ScenePresence avatar; |
290 | 250 | ||
291 | if (TryGetAvatar(avatarId, out avatar)) | 251 | if (TryGetScenePresence(avatarId, out avatar)) |
292 | { | 252 | { |
293 | return CapsUpdateTaskInventoryScriptAsset( | 253 | return CapsUpdateTaskInventoryScriptAsset( |
294 | avatar.ControllingClient, itemId, primId, isScriptRunning, data); | 254 | avatar.ControllingClient, itemId, primId, isScriptRunning, data); |
@@ -472,6 +432,25 @@ namespace OpenSim.Region.Framework.Scenes | |||
472 | itemCopy.BasePermissions = item.BasePermissions; | 432 | itemCopy.BasePermissions = item.BasePermissions; |
473 | } | 433 | } |
474 | 434 | ||
435 | if (itemCopy.Folder == UUID.Zero) | ||
436 | { | ||
437 | InventoryFolderBase folder = InventoryService.GetFolderForType(recipient, (AssetType)itemCopy.AssetType); | ||
438 | |||
439 | if (folder != null) | ||
440 | { | ||
441 | itemCopy.Folder = folder.ID; | ||
442 | } | ||
443 | else | ||
444 | { | ||
445 | InventoryFolderBase root = InventoryService.GetRootFolder(recipient); | ||
446 | |||
447 | if (root != null) | ||
448 | itemCopy.Folder = root.ID; | ||
449 | else | ||
450 | return null; // No destination | ||
451 | } | ||
452 | } | ||
453 | |||
475 | itemCopy.GroupID = UUID.Zero; | 454 | itemCopy.GroupID = UUID.Zero; |
476 | itemCopy.GroupOwned = false; | 455 | itemCopy.GroupOwned = false; |
477 | itemCopy.Flags = item.Flags; | 456 | itemCopy.Flags = item.Flags; |
@@ -479,7 +458,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
479 | itemCopy.SaleType = item.SaleType; | 458 | itemCopy.SaleType = item.SaleType; |
480 | 459 | ||
481 | if (InventoryService.AddItem(itemCopy)) | 460 | if (InventoryService.AddItem(itemCopy)) |
482 | TransferInventoryAssets(itemCopy, senderId, recipient); | 461 | { |
462 | IInventoryAccessModule invAccess = RequestModuleInterface<IInventoryAccessModule>(); | ||
463 | if (invAccess != null) | ||
464 | invAccess.TransferInventoryAssets(itemCopy, senderId, recipient); | ||
465 | } | ||
483 | 466 | ||
484 | if (!Permissions.BypassPermissions()) | 467 | if (!Permissions.BypassPermissions()) |
485 | { | 468 | { |
@@ -501,10 +484,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
501 | 484 | ||
502 | } | 485 | } |
503 | 486 | ||
504 | protected virtual void TransferInventoryAssets(InventoryItemBase item, UUID sender, UUID receiver) | ||
505 | { | ||
506 | } | ||
507 | |||
508 | /// <summary> | 487 | /// <summary> |
509 | /// Give an entire inventory folder from one user to another. The entire contents (including all descendent | 488 | /// Give an entire inventory folder from one user to another. The entire contents (including all descendent |
510 | /// folders) is given. | 489 | /// folders) is given. |
@@ -532,7 +511,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
532 | return null; | 511 | return null; |
533 | } | 512 | } |
534 | 513 | ||
535 | |||
536 | if (recipientParentFolderId == UUID.Zero) | 514 | if (recipientParentFolderId == UUID.Zero) |
537 | { | 515 | { |
538 | InventoryFolderBase recipientRootFolder = InventoryService.GetRootFolder(recipientId); | 516 | InventoryFolderBase recipientRootFolder = InventoryService.GetRootFolder(recipientId); |
@@ -574,7 +552,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
574 | "[AGENT INVENTORY]: CopyInventoryItem received by {0} with oldAgentID {1}, oldItemID {2}, new FolderID {3}, newName {4}", | 552 | "[AGENT INVENTORY]: CopyInventoryItem received by {0} with oldAgentID {1}, oldItemID {2}, new FolderID {3}, newName {4}", |
575 | remoteClient.AgentId, oldAgentID, oldItemID, newFolderID, newName); | 553 | remoteClient.AgentId, oldAgentID, oldItemID, newFolderID, newName); |
576 | 554 | ||
577 | InventoryItemBase item = CommsManager.UserProfileCacheService.LibraryRoot.FindItem(oldItemID); | 555 | InventoryItemBase item = null; |
556 | if (LibraryService != null && LibraryService.LibraryRootFolder != null) | ||
557 | item = LibraryService.LibraryRootFolder.FindItem(oldItemID); | ||
578 | 558 | ||
579 | if (item == null) | 559 | if (item == null) |
580 | { | 560 | { |
@@ -628,15 +608,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
628 | /// <summary> | 608 | /// <summary> |
629 | /// Create a new asset data structure. | 609 | /// Create a new asset data structure. |
630 | /// </summary> | 610 | /// </summary> |
631 | /// <param name="name"></param> | 611 | private AssetBase CreateAsset(string name, string description, sbyte assetType, byte[] data, UUID creatorID) |
632 | /// <param name="description"></param> | ||
633 | /// <param name="invType"></param> | ||
634 | /// <param name="assetType"></param> | ||
635 | /// <param name="data"></param> | ||
636 | /// <returns></returns> | ||
637 | private AssetBase CreateAsset(string name, string description, sbyte assetType, byte[] data) | ||
638 | { | 612 | { |
639 | AssetBase asset = new AssetBase(UUID.Random(), name, assetType); | 613 | AssetBase asset = new AssetBase(UUID.Random(), name, assetType, creatorID.ToString()); |
640 | asset.Description = description; | 614 | asset.Description = description; |
641 | asset.Data = (data == null) ? new byte[1] : data; | 615 | asset.Data = (data == null) ? new byte[1] : data; |
642 | 616 | ||
@@ -746,13 +720,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
746 | 720 | ||
747 | if (transactionID == UUID.Zero) | 721 | if (transactionID == UUID.Zero) |
748 | { | 722 | { |
749 | CachedUserInfo userInfo | 723 | ScenePresence presence; |
750 | = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId); | 724 | if (TryGetScenePresence(remoteClient.AgentId, out presence)) |
751 | |||
752 | if (userInfo != null) | ||
753 | { | 725 | { |
754 | ScenePresence presence; | ||
755 | TryGetAvatar(remoteClient.AgentId, out presence); | ||
756 | byte[] data = null; | 726 | byte[] data = null; |
757 | 727 | ||
758 | if (invType == (sbyte)InventoryType.Landmark && presence != null) | 728 | if (invType == (sbyte)InventoryType.Landmark && presence != null) |
@@ -766,7 +736,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
766 | data = Encoding.ASCII.GetBytes(strdata); | 736 | data = Encoding.ASCII.GetBytes(strdata); |
767 | } | 737 | } |
768 | 738 | ||
769 | AssetBase asset = CreateAsset(name, description, assetType, data); | 739 | AssetBase asset = CreateAsset(name, description, assetType, data, remoteClient.AgentId); |
770 | AssetService.Store(asset); | 740 | AssetService.Store(asset); |
771 | 741 | ||
772 | CreateNewInventoryItem(remoteClient, remoteClient.AgentId.ToString(), folderID, asset.Name, 0, callbackID, asset, invType, nextOwnerMask, creationDate); | 742 | CreateNewInventoryItem(remoteClient, remoteClient.AgentId.ToString(), folderID, asset.Name, 0, callbackID, asset, invType, nextOwnerMask, creationDate); |
@@ -774,7 +744,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
774 | else | 744 | else |
775 | { | 745 | { |
776 | m_log.ErrorFormat( | 746 | m_log.ErrorFormat( |
777 | "userInfo for agent uuid {0} unexpectedly null in CreateNewInventoryItem", | 747 | "ScenePresence for agent uuid {0} unexpectedly not found in CreateNewInventoryItem", |
778 | remoteClient.AgentId); | 748 | remoteClient.AgentId); |
779 | } | 749 | } |
780 | } | 750 | } |
@@ -790,6 +760,37 @@ namespace OpenSim.Region.Framework.Scenes | |||
790 | } | 760 | } |
791 | } | 761 | } |
792 | 762 | ||
763 | private void HandleLinkInventoryItem(IClientAPI remoteClient, UUID transActionID, UUID folderID, | ||
764 | uint callbackID, string description, string name, | ||
765 | sbyte invType, sbyte type, UUID olditemID) | ||
766 | { | ||
767 | m_log.DebugFormat("[AGENT INVENTORY]: Received request to create inventory item link {0} in folder {1} pointing to {2}", name, folderID, olditemID); | ||
768 | |||
769 | if (!Permissions.CanCreateUserInventory(invType, remoteClient.AgentId)) | ||
770 | return; | ||
771 | |||
772 | ScenePresence presence; | ||
773 | if (TryGetScenePresence(remoteClient.AgentId, out presence)) | ||
774 | { | ||
775 | byte[] data = null; | ||
776 | |||
777 | AssetBase asset = new AssetBase(); | ||
778 | asset.FullID = olditemID; | ||
779 | asset.Type = type; | ||
780 | asset.Name = name; | ||
781 | asset.Description = description; | ||
782 | |||
783 | CreateNewInventoryItem(remoteClient, remoteClient.AgentId.ToString(), folderID, name, 0, callbackID, asset, invType, (uint)PermissionMask.All, (uint)PermissionMask.All, (uint)PermissionMask.All, (uint)PermissionMask.All, (uint)PermissionMask.All, Util.UnixTimeSinceEpoch()); | ||
784 | |||
785 | } | ||
786 | else | ||
787 | { | ||
788 | m_log.ErrorFormat( | ||
789 | "ScenePresence for agent uuid {0} unexpectedly not found in HandleLinkInventoryItem", | ||
790 | remoteClient.AgentId); | ||
791 | } | ||
792 | } | ||
793 | |||
793 | /// <summary> | 794 | /// <summary> |
794 | /// Remove an inventory item for the client's inventory | 795 | /// Remove an inventory item for the client's inventory |
795 | /// </summary> | 796 | /// </summary> |
@@ -1013,7 +1014,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1013 | { | 1014 | { |
1014 | ScenePresence avatar; | 1015 | ScenePresence avatar; |
1015 | 1016 | ||
1016 | if (TryGetAvatar(avatarId, out avatar)) | 1017 | if (TryGetScenePresence(avatarId, out avatar)) |
1017 | { | 1018 | { |
1018 | return MoveTaskInventoryItem(avatar.ControllingClient, folderId, part, itemId); | 1019 | return MoveTaskInventoryItem(avatar.ControllingClient, folderId, part, itemId); |
1019 | } | 1020 | } |
@@ -1127,7 +1128,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1127 | 1128 | ||
1128 | ScenePresence avatar; | 1129 | ScenePresence avatar; |
1129 | 1130 | ||
1130 | if (TryGetAvatar(srcTaskItem.OwnerID, out avatar)) | 1131 | if (TryGetScenePresence(srcTaskItem.OwnerID, out avatar)) |
1131 | { | 1132 | { |
1132 | destPart.GetProperties(avatar.ControllingClient); | 1133 | destPart.GetProperties(avatar.ControllingClient); |
1133 | } | 1134 | } |
@@ -1155,7 +1156,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1155 | } | 1156 | } |
1156 | 1157 | ||
1157 | ScenePresence avatar = null; | 1158 | ScenePresence avatar = null; |
1158 | if (TryGetAvatar(destID, out avatar)) | 1159 | if (TryGetScenePresence(destID, out avatar)) |
1159 | { | 1160 | { |
1160 | //profile.SendInventoryDecendents(avatar.ControllingClient, | 1161 | //profile.SendInventoryDecendents(avatar.ControllingClient, |
1161 | // profile.RootFolder.ID, true, false); | 1162 | // profile.RootFolder.ID, true, false); |
@@ -1171,15 +1172,36 @@ namespace OpenSim.Region.Framework.Scenes | |||
1171 | 1172 | ||
1172 | private void SendInventoryUpdate(IClientAPI client, InventoryFolderBase folder, bool fetchFolders, bool fetchItems) | 1173 | private void SendInventoryUpdate(IClientAPI client, InventoryFolderBase folder, bool fetchFolders, bool fetchItems) |
1173 | { | 1174 | { |
1174 | m_log.DebugFormat("[AGENT INVENTORY]: Send Inventory Folder {0} Update to {1} {2}", folder.Name, client.FirstName, client.LastName); | 1175 | if (folder == null) |
1176 | return; | ||
1177 | |||
1178 | // TODO: This code for looking in the folder for the library should be folded somewhere else | ||
1179 | // so that this class doesn't have to know the details (and so that multiple libraries, etc. | ||
1180 | // can be handled transparently). | ||
1181 | InventoryFolderImpl fold = null; | ||
1182 | if (LibraryService != null && LibraryService.LibraryRootFolder != null) | ||
1183 | { | ||
1184 | if ((fold = LibraryService.LibraryRootFolder.FindFolder(folder.ID)) != null) | ||
1185 | { | ||
1186 | client.SendInventoryFolderDetails( | ||
1187 | fold.Owner, folder.ID, fold.RequestListOfItems(), | ||
1188 | fold.RequestListOfFolders(), fold.Version, fetchFolders, fetchItems); | ||
1189 | return; | ||
1190 | } | ||
1191 | } | ||
1192 | |||
1193 | // Fetch the folder contents | ||
1175 | InventoryCollection contents = InventoryService.GetFolderContent(client.AgentId, folder.ID); | 1194 | InventoryCollection contents = InventoryService.GetFolderContent(client.AgentId, folder.ID); |
1176 | InventoryFolderBase containingFolder = new InventoryFolderBase(); | 1195 | |
1177 | containingFolder.ID = folder.ID; | 1196 | // Fetch the folder itself to get its current version |
1178 | containingFolder.Owner = client.AgentId; | 1197 | InventoryFolderBase containingFolder = new InventoryFolderBase(folder.ID, client.AgentId); |
1179 | containingFolder = InventoryService.GetFolder(containingFolder); | 1198 | containingFolder = InventoryService.GetFolder(containingFolder); |
1180 | int version = containingFolder.Version; | ||
1181 | 1199 | ||
1182 | client.SendInventoryFolderDetails(client.AgentId, folder.ID, contents.Items, contents.Folders, version, fetchFolders, fetchItems); | 1200 | //m_log.DebugFormat("[AGENT INVENTORY]: Sending inventory folder contents ({0} nodes) for \"{1}\" to {2} {3}", |
1201 | // contents.Folders.Count + contents.Items.Count, containingFolder.Name, client.FirstName, client.LastName); | ||
1202 | |||
1203 | if (containingFolder != null && containingFolder != null) | ||
1204 | client.SendInventoryFolderDetails(client.AgentId, folder.ID, contents.Items, contents.Folders, containingFolder.Version, fetchFolders, fetchItems); | ||
1183 | } | 1205 | } |
1184 | 1206 | ||
1185 | /// <summary> | 1207 | /// <summary> |
@@ -1221,11 +1243,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1221 | item = InventoryService.GetItem(item); | 1243 | item = InventoryService.GetItem(item); |
1222 | 1244 | ||
1223 | // Try library | 1245 | // Try library |
1224 | if (null == item) | 1246 | if (null == item && LibraryService != null && LibraryService.LibraryRootFolder != null) |
1225 | { | 1247 | { |
1226 | item = CommsManager.UserProfileCacheService.LibraryRoot.FindItem(itemID); | 1248 | item = LibraryService.LibraryRootFolder.FindItem(itemID); |
1227 | } | 1249 | } |
1228 | 1250 | ||
1251 | // If we've found the item in the user's inventory or in the library | ||
1229 | if (item != null) | 1252 | if (item != null) |
1230 | { | 1253 | { |
1231 | part.ParentGroup.AddInventoryItem(remoteClient, primLocalID, item, copyID); | 1254 | part.ParentGroup.AddInventoryItem(remoteClient, primLocalID, item, copyID); |
@@ -1260,7 +1283,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1260 | remoteClient, part, transactionID, currentItem); | 1283 | remoteClient, part, transactionID, currentItem); |
1261 | } | 1284 | } |
1262 | if (part.Inventory.UpdateInventoryItem(itemInfo)) | 1285 | if (part.Inventory.UpdateInventoryItem(itemInfo)) |
1286 | { | ||
1287 | remoteClient.SendAgentAlertMessage("Notecard saved", false); | ||
1263 | part.GetProperties(remoteClient); | 1288 | part.GetProperties(remoteClient); |
1289 | } | ||
1264 | } | 1290 | } |
1265 | } | 1291 | } |
1266 | else | 1292 | else |
@@ -1290,9 +1316,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1290 | 1316 | ||
1291 | // Try library | 1317 | // Try library |
1292 | // XXX clumsy, possibly should be one call | 1318 | // XXX clumsy, possibly should be one call |
1293 | if (null == item) | 1319 | if (null == item && LibraryService != null && LibraryService.LibraryRootFolder != null) |
1294 | { | 1320 | { |
1295 | item = CommsManager.UserProfileCacheService.LibraryRoot.FindItem(itemID); | 1321 | item = LibraryService.LibraryRootFolder.FindItem(itemID); |
1296 | } | 1322 | } |
1297 | 1323 | ||
1298 | if (item != null) | 1324 | if (item != null) |
@@ -1312,6 +1338,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1312 | // "Rezzed script {0} into prim local ID {1} for user {2}", | 1338 | // "Rezzed script {0} into prim local ID {1} for user {2}", |
1313 | // item.inventoryName, localID, remoteClient.Name); | 1339 | // item.inventoryName, localID, remoteClient.Name); |
1314 | part.GetProperties(remoteClient); | 1340 | part.GetProperties(remoteClient); |
1341 | part.ParentGroup.ResumeScripts(); | ||
1315 | } | 1342 | } |
1316 | else | 1343 | else |
1317 | { | 1344 | { |
@@ -1349,7 +1376,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1349 | itemBase.InvType, part.UUID, remoteClient.AgentId)) | 1376 | itemBase.InvType, part.UUID, remoteClient.AgentId)) |
1350 | return; | 1377 | return; |
1351 | 1378 | ||
1352 | 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}")); | 1379 | AssetBase asset = CreateAsset(itemBase.Name, itemBase.Description, (sbyte)itemBase.AssetType, |
1380 | Encoding.ASCII.GetBytes("default\n{\n state_entry()\n {\n llSay(0, \"Script running\");\n }\n}"), | ||
1381 | remoteClient.AgentId); | ||
1353 | AssetService.Store(asset); | 1382 | AssetService.Store(asset); |
1354 | 1383 | ||
1355 | TaskInventoryItem taskItem = new TaskInventoryItem(); | 1384 | TaskInventoryItem taskItem = new TaskInventoryItem(); |
@@ -1379,6 +1408,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1379 | part.GetProperties(remoteClient); | 1408 | part.GetProperties(remoteClient); |
1380 | 1409 | ||
1381 | part.Inventory.CreateScriptInstance(taskItem, 0, false, DefaultScriptEngine, 0); | 1410 | part.Inventory.CreateScriptInstance(taskItem, 0, false, DefaultScriptEngine, 0); |
1411 | part.ParentGroup.ResumeScripts(); | ||
1382 | } | 1412 | } |
1383 | } | 1413 | } |
1384 | 1414 | ||
@@ -1482,9 +1512,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1482 | destPart.Inventory.CreateScriptInstance(destTaskItem, start_param, false, DefaultScriptEngine, 0); | 1512 | destPart.Inventory.CreateScriptInstance(destTaskItem, start_param, false, DefaultScriptEngine, 0); |
1483 | } | 1513 | } |
1484 | 1514 | ||
1515 | destPart.ParentGroup.ResumeScripts(); | ||
1516 | |||
1485 | ScenePresence avatar; | 1517 | ScenePresence avatar; |
1486 | 1518 | ||
1487 | if (TryGetAvatar(srcTaskItem.OwnerID, out avatar)) | 1519 | if (TryGetScenePresence(srcTaskItem.OwnerID, out avatar)) |
1488 | { | 1520 | { |
1489 | destPart.GetProperties(avatar.ControllingClient); | 1521 | destPart.GetProperties(avatar.ControllingClient); |
1490 | } | 1522 | } |
@@ -1618,237 +1650,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1618 | } | 1650 | } |
1619 | } | 1651 | } |
1620 | 1652 | ||
1621 | /// <summary> | ||
1622 | /// Delete a scene object from a scene and place in the given avatar's inventory. | ||
1623 | /// Returns the UUID of the newly created asset. | ||
1624 | /// </summary> | ||
1625 | /// <param name="action"></param> | ||
1626 | /// <param name="folderID"></param> | ||
1627 | /// <param name="objectGroup"></param> | ||
1628 | /// <param name="remoteClient"> </param> | ||
1629 | public virtual UUID DeleteToInventory(DeRezAction action, UUID folderID, | ||
1630 | SceneObjectGroup objectGroup, IClientAPI remoteClient) | ||
1631 | { | ||
1632 | UUID assetID = UUID.Zero; | ||
1633 | |||
1634 | Vector3 inventoryStoredPosition = new Vector3 | ||
1635 | (((objectGroup.AbsolutePosition.X > (int)Constants.RegionSize) | ||
1636 | ? 250 | ||
1637 | : objectGroup.AbsolutePosition.X) | ||
1638 | , | ||
1639 | (objectGroup.AbsolutePosition.X > (int)Constants.RegionSize) | ||
1640 | ? 250 | ||
1641 | : objectGroup.AbsolutePosition.X, | ||
1642 | objectGroup.AbsolutePosition.Z); | ||
1643 | |||
1644 | Vector3 originalPosition = objectGroup.AbsolutePosition; | ||
1645 | |||
1646 | objectGroup.AbsolutePosition = inventoryStoredPosition; | ||
1647 | |||
1648 | string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(objectGroup); | ||
1649 | |||
1650 | objectGroup.AbsolutePosition = originalPosition; | ||
1651 | |||
1652 | // Get the user info of the item destination | ||
1653 | // | ||
1654 | UUID userID = UUID.Zero; | ||
1655 | |||
1656 | if (action == DeRezAction.Take || action == DeRezAction.TakeCopy || | ||
1657 | action == DeRezAction.SaveToExistingUserInventoryItem) | ||
1658 | { | ||
1659 | // Take or take copy require a taker | ||
1660 | // Saving changes requires a local user | ||
1661 | // | ||
1662 | if (remoteClient == null) | ||
1663 | return UUID.Zero; | ||
1664 | |||
1665 | userID = remoteClient.AgentId; | ||
1666 | } | ||
1667 | else | ||
1668 | { | ||
1669 | // All returns / deletes go to the object owner | ||
1670 | // | ||
1671 | |||
1672 | userID = objectGroup.RootPart.OwnerID; | ||
1673 | } | ||
1674 | |||
1675 | if (userID == UUID.Zero) // Can't proceed | ||
1676 | { | ||
1677 | return UUID.Zero; | ||
1678 | } | ||
1679 | |||
1680 | // If we're returning someone's item, it goes back to the | ||
1681 | // owner's Lost And Found folder. | ||
1682 | // Delete is treated like return in this case | ||
1683 | // Deleting your own items makes them go to trash | ||
1684 | // | ||
1685 | |||
1686 | InventoryFolderBase folder = null; | ||
1687 | InventoryItemBase item = null; | ||
1688 | |||
1689 | if (DeRezAction.SaveToExistingUserInventoryItem == action) | ||
1690 | { | ||
1691 | item = new InventoryItemBase(objectGroup.RootPart.FromUserInventoryItemID, userID); | ||
1692 | item = InventoryService.GetItem(item); | ||
1693 | |||
1694 | //item = userInfo.RootFolder.FindItem( | ||
1695 | // objectGroup.RootPart.FromUserInventoryItemID); | ||
1696 | |||
1697 | if (null == item) | ||
1698 | { | ||
1699 | m_log.DebugFormat( | ||
1700 | "[AGENT INVENTORY]: Object {0} {1} scheduled for save to inventory has already been deleted.", | ||
1701 | objectGroup.Name, objectGroup.UUID); | ||
1702 | return UUID.Zero; | ||
1703 | } | ||
1704 | } | ||
1705 | else | ||
1706 | { | ||
1707 | // Folder magic | ||
1708 | // | ||
1709 | if (action == DeRezAction.Delete) | ||
1710 | { | ||
1711 | // Deleting someone else's item | ||
1712 | // | ||
1713 | |||
1714 | |||
1715 | if (remoteClient == null || | ||
1716 | objectGroup.OwnerID != remoteClient.AgentId) | ||
1717 | { | ||
1718 | // Folder skeleton may not be loaded and we | ||
1719 | // have to wait for the inventory to find | ||
1720 | // the destination folder | ||
1721 | // | ||
1722 | folder = InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder); | ||
1723 | } | ||
1724 | else | ||
1725 | { | ||
1726 | // Assume inventory skeleton was loaded during login | ||
1727 | // and all folders can be found | ||
1728 | // | ||
1729 | folder = InventoryService.GetFolderForType(userID, AssetType.TrashFolder); | ||
1730 | } | ||
1731 | } | ||
1732 | else if (action == DeRezAction.Return) | ||
1733 | { | ||
1734 | |||
1735 | // Dump to lost + found unconditionally | ||
1736 | // | ||
1737 | folder = InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder); | ||
1738 | } | ||
1739 | |||
1740 | if (folderID == UUID.Zero && folder == null) | ||
1741 | { | ||
1742 | if (action == DeRezAction.Delete) | ||
1743 | { | ||
1744 | // Deletes go to trash by default | ||
1745 | // | ||
1746 | folder = InventoryService.GetFolderForType(userID, AssetType.TrashFolder); | ||
1747 | } | ||
1748 | else | ||
1749 | { | ||
1750 | // Catch all. Use lost & found | ||
1751 | // | ||
1752 | |||
1753 | folder = InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder); | ||
1754 | } | ||
1755 | } | ||
1756 | |||
1757 | if (folder == null) // None of the above | ||
1758 | { | ||
1759 | //folder = userInfo.RootFolder.FindFolder(folderID); | ||
1760 | folder = new InventoryFolderBase(folderID); | ||
1761 | |||
1762 | if (folder == null) // Nowhere to put it | ||
1763 | { | ||
1764 | return UUID.Zero; | ||
1765 | } | ||
1766 | } | ||
1767 | |||
1768 | item = new InventoryItemBase(); | ||
1769 | item.CreatorId = objectGroup.RootPart.CreatorID.ToString(); | ||
1770 | item.ID = UUID.Random(); | ||
1771 | item.InvType = (int)InventoryType.Object; | ||
1772 | item.Folder = folder.ID; | ||
1773 | item.Owner = userID; | ||
1774 | } | ||
1775 | |||
1776 | AssetBase asset = CreateAsset( | ||
1777 | objectGroup.GetPartName(objectGroup.RootPart.LocalId), | ||
1778 | objectGroup.GetPartDescription(objectGroup.RootPart.LocalId), | ||
1779 | (sbyte)AssetType.Object, | ||
1780 | Utils.StringToBytes(sceneObjectXml)); | ||
1781 | AssetService.Store(asset); | ||
1782 | assetID = asset.FullID; | ||
1783 | |||
1784 | if (DeRezAction.SaveToExistingUserInventoryItem == action) | ||
1785 | { | ||
1786 | item.AssetID = asset.FullID; | ||
1787 | InventoryService.UpdateItem(item); | ||
1788 | } | ||
1789 | else | ||
1790 | { | ||
1791 | item.AssetID = asset.FullID; | ||
1792 | |||
1793 | if (remoteClient != null && (remoteClient.AgentId != objectGroup.RootPart.OwnerID) && Permissions.PropagatePermissions()) | ||
1794 | { | ||
1795 | uint perms=objectGroup.GetEffectivePermissions(); | ||
1796 | uint nextPerms=(perms & 7) << 13; | ||
1797 | if ((nextPerms & (uint)PermissionMask.Copy) == 0) | ||
1798 | perms &= ~(uint)PermissionMask.Copy; | ||
1799 | if ((nextPerms & (uint)PermissionMask.Transfer) == 0) | ||
1800 | perms &= ~(uint)PermissionMask.Transfer; | ||
1801 | if ((nextPerms & (uint)PermissionMask.Modify) == 0) | ||
1802 | perms &= ~(uint)PermissionMask.Modify; | ||
1803 | |||
1804 | item.BasePermissions = perms & objectGroup.RootPart.NextOwnerMask; | ||
1805 | item.CurrentPermissions = item.BasePermissions; | ||
1806 | item.NextPermissions = objectGroup.RootPart.NextOwnerMask; | ||
1807 | item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask & objectGroup.RootPart.NextOwnerMask; | ||
1808 | item.GroupPermissions = objectGroup.RootPart.GroupMask & objectGroup.RootPart.NextOwnerMask; | ||
1809 | item.CurrentPermissions |= 8; // Slam! | ||
1810 | } | ||
1811 | else | ||
1812 | { | ||
1813 | uint ownerPerms = objectGroup.GetEffectivePermissions(); | ||
1814 | if ((objectGroup.RootPart.OwnerMask & (uint)PermissionMask.Modify) != 0) | ||
1815 | ownerPerms |= (uint)PermissionMask.Modify; | ||
1816 | |||
1817 | item.BasePermissions = ownerPerms; | ||
1818 | item.CurrentPermissions = ownerPerms; | ||
1819 | |||
1820 | item.NextPermissions = objectGroup.RootPart.NextOwnerMask; | ||
1821 | item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask; | ||
1822 | item.GroupPermissions = objectGroup.RootPart.GroupMask; | ||
1823 | |||
1824 | item.CurrentPermissions |= 8; // Slam! | ||
1825 | } | ||
1826 | |||
1827 | // TODO: add the new fields (Flags, Sale info, etc) | ||
1828 | item.CreationDate = Util.UnixTimeSinceEpoch(); | ||
1829 | item.Description = asset.Description; | ||
1830 | item.Name = asset.Name; | ||
1831 | item.AssetType = asset.Type; | ||
1832 | |||
1833 | InventoryService.AddItem(item); | ||
1834 | |||
1835 | if (remoteClient != null && item.Owner == remoteClient.AgentId) | ||
1836 | { | ||
1837 | remoteClient.SendInventoryItemCreateUpdate(item, 0); | ||
1838 | } | ||
1839 | else | ||
1840 | { | ||
1841 | ScenePresence notifyUser = GetScenePresence(item.Owner); | ||
1842 | if (notifyUser != null) | ||
1843 | { | ||
1844 | notifyUser.ControllingClient.SendInventoryItemCreateUpdate(item, 0); | ||
1845 | } | ||
1846 | } | ||
1847 | } | ||
1848 | |||
1849 | return assetID; | ||
1850 | } | ||
1851 | |||
1852 | public void UpdateKnownItem(IClientAPI remoteClient, SceneObjectGroup grp, UUID itemID, UUID agentID) | 1653 | public void UpdateKnownItem(IClientAPI remoteClient, SceneObjectGroup grp, UUID itemID, UUID agentID) |
1853 | { | 1654 | { |
1854 | SceneObjectGroup objectGroup = grp; | 1655 | SceneObjectGroup objectGroup = grp; |
@@ -1875,7 +1676,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1875 | objectGroup.GetPartName(objectGroup.LocalId), | 1676 | objectGroup.GetPartName(objectGroup.LocalId), |
1876 | objectGroup.GetPartDescription(objectGroup.LocalId), | 1677 | objectGroup.GetPartDescription(objectGroup.LocalId), |
1877 | (sbyte)AssetType.Object, | 1678 | (sbyte)AssetType.Object, |
1878 | Utils.StringToBytes(sceneObjectXml)); | 1679 | Utils.StringToBytes(sceneObjectXml), |
1680 | remoteClient.AgentId); | ||
1879 | AssetService.Store(asset); | 1681 | AssetService.Store(asset); |
1880 | 1682 | ||
1881 | item.AssetID = asset.FullID; | 1683 | item.AssetID = asset.FullID; |
@@ -1922,7 +1724,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1922 | grp.GetPartName(grp.LocalId), | 1724 | grp.GetPartName(grp.LocalId), |
1923 | grp.GetPartDescription(grp.LocalId), | 1725 | grp.GetPartDescription(grp.LocalId), |
1924 | (sbyte)AssetType.Object, | 1726 | (sbyte)AssetType.Object, |
1925 | Utils.StringToBytes(sceneObjectXml)); | 1727 | Utils.StringToBytes(sceneObjectXml), |
1728 | remoteClient.AgentId); | ||
1926 | AssetService.Store(asset); | 1729 | AssetService.Store(asset); |
1927 | 1730 | ||
1928 | InventoryItemBase item = new InventoryItemBase(); | 1731 | InventoryItemBase item = new InventoryItemBase(); |
@@ -1989,225 +1792,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1989 | UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection, | 1792 | UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection, |
1990 | bool RezSelected, bool RemoveItem, UUID fromTaskID) | 1793 | bool RezSelected, bool RemoveItem, UUID fromTaskID) |
1991 | { | 1794 | { |
1992 | RezObject( | 1795 | IInventoryAccessModule invAccess = RequestModuleInterface<IInventoryAccessModule>(); |
1993 | remoteClient, itemID, RayEnd, RayStart, RayTargetID, BypassRayCast, RayEndIsIntersection, | 1796 | if (invAccess != null) |
1994 | RezSelected, RemoveItem, fromTaskID, false); | 1797 | invAccess.RezObject( |
1995 | } | 1798 | remoteClient, itemID, RayEnd, RayStart, RayTargetID, BypassRayCast, RayEndIsIntersection, |
1996 | 1799 | RezSelected, RemoveItem, fromTaskID, false); | |
1997 | /// <summary> | ||
1998 | /// Rez an object into the scene from the user's inventory | ||
1999 | /// </summary> | ||
2000 | /// <param name="remoteClient"></param> | ||
2001 | /// <param name="itemID"></param> | ||
2002 | /// <param name="RayEnd"></param> | ||
2003 | /// <param name="RayStart"></param> | ||
2004 | /// <param name="RayTargetID"></param> | ||
2005 | /// <param name="BypassRayCast"></param> | ||
2006 | /// <param name="RayEndIsIntersection"></param> | ||
2007 | /// <param name="RezSelected"></param> | ||
2008 | /// <param name="RemoveItem"></param> | ||
2009 | /// <param name="fromTaskID"></param> | ||
2010 | /// <param name="attachment"></param> | ||
2011 | /// <returns>The SceneObjectGroup rezzed or null if rez was unsuccessful.</returns> | ||
2012 | public virtual SceneObjectGroup RezObject(IClientAPI remoteClient, UUID itemID, Vector3 RayEnd, Vector3 RayStart, | ||
2013 | UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection, | ||
2014 | bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment) | ||
2015 | { | ||
2016 | // Work out position details | ||
2017 | byte bRayEndIsIntersection = (byte)0; | ||
2018 | |||
2019 | if (RayEndIsIntersection) | ||
2020 | { | ||
2021 | bRayEndIsIntersection = (byte)1; | ||
2022 | } | ||
2023 | else | ||
2024 | { | ||
2025 | bRayEndIsIntersection = (byte)0; | ||
2026 | } | ||
2027 | |||
2028 | Vector3 scale = new Vector3(0.5f, 0.5f, 0.5f); | ||
2029 | |||
2030 | |||
2031 | Vector3 pos = GetNewRezLocation( | ||
2032 | RayStart, RayEnd, RayTargetID, Quaternion.Identity, | ||
2033 | BypassRayCast, bRayEndIsIntersection,true,scale, false); | ||
2034 | |||
2035 | // Rez object | ||
2036 | InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); | ||
2037 | item = InventoryService.GetItem(item); | ||
2038 | |||
2039 | if (item != null) | ||
2040 | { | ||
2041 | AssetBase rezAsset = AssetService.Get(item.AssetID.ToString()); | ||
2042 | |||
2043 | if (rezAsset != null) | ||
2044 | { | ||
2045 | UUID itemId = UUID.Zero; | ||
2046 | |||
2047 | // If we have permission to copy then link the rezzed object back to the user inventory | ||
2048 | // item that it came from. This allows us to enable 'save object to inventory' | ||
2049 | if (!Permissions.BypassPermissions()) | ||
2050 | { | ||
2051 | if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == (uint)PermissionMask.Copy) | ||
2052 | { | ||
2053 | itemId = item.ID; | ||
2054 | } | ||
2055 | } | ||
2056 | else | ||
2057 | { | ||
2058 | // Brave new fullperm world | ||
2059 | // | ||
2060 | itemId = item.ID; | ||
2061 | } | ||
2062 | |||
2063 | string xmlData = Utils.BytesToString(rezAsset.Data); | ||
2064 | SceneObjectGroup group | ||
2065 | = SceneObjectSerializer.FromOriginalXmlFormat(itemId, xmlData); | ||
2066 | |||
2067 | if (!Permissions.CanRezObject( | ||
2068 | group.Children.Count, remoteClient.AgentId, pos) | ||
2069 | && !attachment) | ||
2070 | { | ||
2071 | // The client operates in no fail mode. It will | ||
2072 | // have already removed the item from the folder | ||
2073 | // if it's no copy. | ||
2074 | // Put it back if it's not an attachment | ||
2075 | // | ||
2076 | if (((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) && (!attachment)) | ||
2077 | remoteClient.SendBulkUpdateInventory(item); | ||
2078 | return null; | ||
2079 | } | ||
2080 | |||
2081 | group.ResetIDs(); | ||
2082 | |||
2083 | if (attachment) | ||
2084 | { | ||
2085 | group.RootPart.ObjectFlags |= (uint)PrimFlags.Phantom; | ||
2086 | group.RootPart.IsAttachment = true; | ||
2087 | } | ||
2088 | |||
2089 | AddNewSceneObject(group, true); | ||
2090 | |||
2091 | // m_log.InfoFormat("ray end point for inventory rezz is {0} {1} {2} ", RayEnd.X, RayEnd.Y, RayEnd.Z); | ||
2092 | // if attachment we set it's asset id so object updates can reflect that | ||
2093 | // if not, we set it's position in world. | ||
2094 | if (!attachment) | ||
2095 | { | ||
2096 | float offsetHeight = 0; | ||
2097 | pos = GetNewRezLocation( | ||
2098 | RayStart, RayEnd, RayTargetID, Quaternion.Identity, | ||
2099 | BypassRayCast, bRayEndIsIntersection, true, group.GetAxisAlignedBoundingBox(out offsetHeight), false); | ||
2100 | pos.Z += offsetHeight; | ||
2101 | group.AbsolutePosition = pos; | ||
2102 | // m_log.InfoFormat("rezx point for inventory rezz is {0} {1} {2} and offsetheight was {3}", pos.X, pos.Y, pos.Z, offsetHeight); | ||
2103 | |||
2104 | } | ||
2105 | else | ||
2106 | { | ||
2107 | group.SetFromItemID(itemID); | ||
2108 | } | ||
2109 | |||
2110 | SceneObjectPart rootPart = null; | ||
2111 | try | ||
2112 | { | ||
2113 | rootPart = group.GetChildPart(group.UUID); | ||
2114 | } | ||
2115 | catch (NullReferenceException) | ||
2116 | { | ||
2117 | string isAttachment = ""; | ||
2118 | |||
2119 | if (attachment) | ||
2120 | isAttachment = " Object was an attachment"; | ||
2121 | |||
2122 | m_log.Error("[AGENT INVENTORY]: Error rezzing ItemID: " + itemID + " object has no rootpart." + isAttachment); | ||
2123 | } | ||
2124 | |||
2125 | // Since renaming the item in the inventory does not affect the name stored | ||
2126 | // in the serialization, transfer the correct name from the inventory to the | ||
2127 | // object itself before we rez. | ||
2128 | rootPart.Name = item.Name; | ||
2129 | rootPart.Description = item.Description; | ||
2130 | |||
2131 | List<SceneObjectPart> partList = new List<SceneObjectPart>(group.Children.Values); | ||
2132 | |||
2133 | group.SetGroup(remoteClient.ActiveGroupId, remoteClient); | ||
2134 | if (rootPart.OwnerID != item.Owner) | ||
2135 | { | ||
2136 | //Need to kill the for sale here | ||
2137 | rootPart.ObjectSaleType = 0; | ||
2138 | rootPart.SalePrice = 10; | ||
2139 | |||
2140 | if (Permissions.PropagatePermissions()) | ||
2141 | { | ||
2142 | if ((item.CurrentPermissions & 8) != 0) | ||
2143 | { | ||
2144 | foreach (SceneObjectPart part in partList) | ||
2145 | { | ||
2146 | part.EveryoneMask = item.EveryOnePermissions; | ||
2147 | part.NextOwnerMask = item.NextPermissions; | ||
2148 | part.GroupMask = 0; // DO NOT propagate here | ||
2149 | } | ||
2150 | } | ||
2151 | group.ApplyNextOwnerPermissions(); | ||
2152 | } | ||
2153 | } | ||
2154 | |||
2155 | foreach (SceneObjectPart part in partList) | ||
2156 | { | ||
2157 | if (part.OwnerID != item.Owner) | ||
2158 | { | ||
2159 | part.LastOwnerID = part.OwnerID; | ||
2160 | part.OwnerID = item.Owner; | ||
2161 | part.Inventory.ChangeInventoryOwner(item.Owner); | ||
2162 | } | ||
2163 | else if (((item.CurrentPermissions & 8) != 0) && (!attachment)) // Slam! | ||
2164 | { | ||
2165 | part.EveryoneMask = item.EveryOnePermissions; | ||
2166 | part.NextOwnerMask = item.NextPermissions; | ||
2167 | |||
2168 | part.GroupMask = 0; // DO NOT propagate here | ||
2169 | } | ||
2170 | } | ||
2171 | |||
2172 | rootPart.TrimPermissions(); | ||
2173 | |||
2174 | if (!attachment) | ||
2175 | { | ||
2176 | if (group.RootPart.Shape.PCode == (byte)PCode.Prim) | ||
2177 | { | ||
2178 | group.ClearPartAttachmentData(); | ||
2179 | } | ||
2180 | } | ||
2181 | |||
2182 | if (!attachment) | ||
2183 | { | ||
2184 | // Fire on_rez | ||
2185 | group.CreateScriptInstances(0, true, DefaultScriptEngine, 0); | ||
2186 | |||
2187 | rootPart.ScheduleFullUpdate(); | ||
2188 | } | ||
2189 | |||
2190 | if (!Permissions.BypassPermissions()) | ||
2191 | { | ||
2192 | if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) | ||
2193 | { | ||
2194 | // If this is done on attachments, no | ||
2195 | // copy ones will be lost, so avoid it | ||
2196 | // | ||
2197 | if (!attachment) | ||
2198 | { | ||
2199 | List<UUID> uuids = new List<UUID>(); | ||
2200 | uuids.Add(item.ID); | ||
2201 | InventoryService.DeleteItems(item.Owner, uuids); | ||
2202 | } | ||
2203 | } | ||
2204 | } | ||
2205 | |||
2206 | return rootPart.ParentGroup; | ||
2207 | } | ||
2208 | } | ||
2209 | |||
2210 | return null; | ||
2211 | } | 1800 | } |
2212 | 1801 | ||
2213 | /// <summary> | 1802 | /// <summary> |
@@ -2345,178 +1934,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2345 | EventManager.TriggerStopScript(part.LocalId, itemID); | 1934 | EventManager.TriggerStopScript(part.LocalId, itemID); |
2346 | } | 1935 | } |
2347 | 1936 | ||
2348 | internal void SendAttachEvent(uint localID, UUID itemID, UUID avatarID) | ||
2349 | { | ||
2350 | EventManager.TriggerOnAttach(localID, itemID, avatarID); | ||
2351 | } | ||
2352 | |||
2353 | /// <summary> | ||
2354 | /// Called when the client receives a request to rez a single attachment on to the avatar from inventory | ||
2355 | /// (RezSingleAttachmentFromInv packet). | ||
2356 | /// </summary> | ||
2357 | /// <param name="remoteClient"></param> | ||
2358 | /// <param name="itemID"></param> | ||
2359 | /// <param name="AttachmentPt"></param> | ||
2360 | /// <returns></returns> | ||
2361 | public UUID RezSingleAttachment(IClientAPI remoteClient, UUID itemID, uint AttachmentPt) | ||
2362 | { | ||
2363 | m_log.DebugFormat("[USER INVENTORY]: Rezzing single attachment from item {0} for {1}", itemID, remoteClient.Name); | ||
2364 | |||
2365 | SceneObjectGroup att = m_sceneGraph.RezSingleAttachment(remoteClient, itemID, AttachmentPt); | ||
2366 | |||
2367 | if (att == null) | ||
2368 | { | ||
2369 | DetachSingleAttachmentToInv(itemID, remoteClient); | ||
2370 | return UUID.Zero; | ||
2371 | } | ||
2372 | |||
2373 | return RezSingleAttachment(att, remoteClient, itemID, AttachmentPt); | ||
2374 | } | ||
2375 | |||
2376 | /// <summary> | ||
2377 | /// Update the user inventory to reflect an attachment | ||
2378 | /// </summary> | ||
2379 | /// <param name="att"></param> | ||
2380 | /// <param name="remoteClient"></param> | ||
2381 | /// <param name="itemID"></param> | ||
2382 | /// <param name="AttachmentPt"></param> | ||
2383 | /// <returns></returns> | ||
2384 | public UUID RezSingleAttachment(SceneObjectGroup att, IClientAPI remoteClient, UUID itemID, uint AttachmentPt) | ||
2385 | { | ||
2386 | m_log.DebugFormat( | ||
2387 | "[USER INVENTORY]: Updating inventory of {0} to show attachment of {1} (item ID {2})", | ||
2388 | remoteClient.Name, att.Name, itemID); | ||
2389 | |||
2390 | if (!att.IsDeleted) | ||
2391 | AttachmentPt = att.RootPart.AttachmentPoint; | ||
2392 | |||
2393 | ScenePresence presence; | ||
2394 | if (TryGetAvatar(remoteClient.AgentId, out presence)) | ||
2395 | { | ||
2396 | InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); | ||
2397 | item = InventoryService.GetItem(item); | ||
2398 | |||
2399 | presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID /*att.UUID*/); | ||
2400 | } | ||
2401 | return att.UUID; | ||
2402 | } | ||
2403 | |||
2404 | public void RezMultipleAttachments(IClientAPI remoteClient, RezMultipleAttachmentsFromInvPacket.HeaderDataBlock header, | ||
2405 | RezMultipleAttachmentsFromInvPacket.ObjectDataBlock[] objects) | ||
2406 | { | ||
2407 | foreach (RezMultipleAttachmentsFromInvPacket.ObjectDataBlock obj in objects) | ||
2408 | { | ||
2409 | RezSingleAttachment(remoteClient, obj.ItemID, obj.AttachmentPt); | ||
2410 | } | ||
2411 | } | ||
2412 | |||
2413 | /// <summary> | ||
2414 | /// Attach an object. | ||
2415 | /// </summary> | ||
2416 | /// <param name="controllingClient"></param> | ||
2417 | /// <param name="localID"></param> | ||
2418 | /// <param name="attachPoint"></param> | ||
2419 | /// <param name="rot"></param> | ||
2420 | /// <param name="pos"></param> | ||
2421 | /// <param name="silent"></param> | ||
2422 | /// <returns>true if the object was successfully attached, false otherwise</returns> | ||
2423 | public bool AttachObject(IClientAPI controllingClient, uint localID, uint attachPoint, Quaternion rot, Vector3 pos, bool silent) | ||
2424 | { | ||
2425 | return m_sceneGraph.AttachObject(controllingClient, localID, attachPoint, rot, pos, silent); | ||
2426 | } | ||
2427 | |||
2428 | /// <summary> | ||
2429 | /// This registers the item as attached in a user's inventory | ||
2430 | /// </summary> | ||
2431 | /// <param name="remoteClient"></param> | ||
2432 | /// <param name="AttachmentPt"></param> | ||
2433 | /// <param name="itemID"></param> | ||
2434 | /// <param name="att"></param> | ||
2435 | public void AttachObject(IClientAPI remoteClient, uint AttachmentPt, UUID itemID, SceneObjectGroup att) | ||
2436 | { | ||
2437 | // m_log.DebugFormat( | ||
2438 | // "[USER INVENTORY]: Updating attachment {0} for {1} at {2} using item ID {3}", | ||
2439 | // att.Name, remoteClient.Name, AttachmentPt, itemID); | ||
2440 | |||
2441 | if (UUID.Zero == itemID) | ||
2442 | { | ||
2443 | m_log.Error("[SCENE INVENTORY]: Unable to save attachment. Error inventory item ID."); | ||
2444 | return; | ||
2445 | } | ||
2446 | |||
2447 | if (0 == AttachmentPt) | ||
2448 | { | ||
2449 | m_log.Error("[SCENE INVENTORY]: Unable to save attachment. Error attachment point."); | ||
2450 | return; | ||
2451 | } | ||
2452 | |||
2453 | if (null == att.RootPart) | ||
2454 | { | ||
2455 | m_log.Error("[SCENE INVENTORY]: Unable to save attachment for a prim without the rootpart!"); | ||
2456 | return; | ||
2457 | } | ||
2458 | |||
2459 | ScenePresence presence; | ||
2460 | if (TryGetAvatar(remoteClient.AgentId, out presence)) | ||
2461 | { | ||
2462 | // XXYY!! | ||
2463 | InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); | ||
2464 | item = InventoryService.GetItem(item); | ||
2465 | presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID /*att.UUID*/); | ||
2466 | |||
2467 | if (m_AvatarFactory != null) | ||
2468 | m_AvatarFactory.UpdateDatabase(remoteClient.AgentId, presence.Appearance); | ||
2469 | } | ||
2470 | } | ||
2471 | |||
2472 | public void DetachSingleAttachmentToGround(UUID itemID, IClientAPI remoteClient) | ||
2473 | { | ||
2474 | SceneObjectPart part = GetSceneObjectPart(itemID); | ||
2475 | if (part == null || part.ParentGroup == null) | ||
2476 | return; | ||
2477 | |||
2478 | UUID inventoryID = part.ParentGroup.GetFromItemID(); | ||
2479 | |||
2480 | ScenePresence presence; | ||
2481 | if (TryGetAvatar(remoteClient.AgentId, out presence)) | ||
2482 | { | ||
2483 | if (!Permissions.CanRezObject(part.ParentGroup.Children.Count, remoteClient.AgentId, presence.AbsolutePosition)) | ||
2484 | return; | ||
2485 | |||
2486 | presence.Appearance.DetachAttachment(itemID); | ||
2487 | IAvatarFactory ava = RequestModuleInterface<IAvatarFactory>(); | ||
2488 | if (ava != null) | ||
2489 | { | ||
2490 | ava.UpdateDatabase(remoteClient.AgentId, presence.Appearance); | ||
2491 | } | ||
2492 | part.ParentGroup.DetachToGround(); | ||
2493 | |||
2494 | List<UUID> uuids = new List<UUID>(); | ||
2495 | uuids.Add(inventoryID); | ||
2496 | InventoryService.DeleteItems(remoteClient.AgentId, uuids); | ||
2497 | remoteClient.SendRemoveInventoryItem(inventoryID); | ||
2498 | } | ||
2499 | SendAttachEvent(part.ParentGroup.LocalId, itemID, UUID.Zero); | ||
2500 | } | ||
2501 | |||
2502 | public void DetachSingleAttachmentToInv(UUID itemID, IClientAPI remoteClient) | ||
2503 | { | ||
2504 | ScenePresence presence; | ||
2505 | if (TryGetAvatar(remoteClient.AgentId, out presence)) | ||
2506 | { | ||
2507 | presence.Appearance.DetachAttachment(itemID); | ||
2508 | |||
2509 | // Save avatar attachment information | ||
2510 | if (m_AvatarFactory != null) | ||
2511 | { | ||
2512 | m_log.Info("[SCENE]: Saving avatar attachment. AgentID: " + remoteClient.AgentId + ", ItemID: " + itemID); | ||
2513 | m_AvatarFactory.UpdateDatabase(remoteClient.AgentId, presence.Appearance); | ||
2514 | } | ||
2515 | } | ||
2516 | |||
2517 | m_sceneGraph.DetachSingleAttachmentToInv(itemID, remoteClient); | ||
2518 | } | ||
2519 | |||
2520 | public void GetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID) | 1937 | public void GetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID) |
2521 | { | 1938 | { |
2522 | EventManager.TriggerGetScriptRunning(controllingClient, objectID, itemID); | 1939 | 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..e25b1f1 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs | |||
@@ -32,7 +32,7 @@ using OpenMetaverse; | |||
32 | using OpenMetaverse.Packets; | 32 | using OpenMetaverse.Packets; |
33 | using OpenSim.Framework; | 33 | using OpenSim.Framework; |
34 | using OpenSim.Framework.Communications; | 34 | using OpenSim.Framework.Communications; |
35 | using OpenSim.Framework.Communications.Cache; | 35 | using OpenSim.Services.Interfaces; |
36 | 36 | ||
37 | namespace OpenSim.Region.Framework.Scenes | 37 | namespace 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; |
@@ -494,17 +513,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
494 | { | 513 | { |
495 | // FIXME MAYBE: We're not handling sortOrder! | 514 | // FIXME MAYBE: We're not handling sortOrder! |
496 | 515 | ||
497 | // TODO: This code for looking in the folder for the library should be folded back into the | 516 | // TODO: This code for looking in the folder for the library should be folded somewhere else |
498 | // CachedUserInfo so that this class doesn't have to know the details (and so that multiple libraries, etc. | 517 | // 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 ee097bc..377abe3 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -27,6 +27,7 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Diagnostics; | ||
30 | using System.Drawing; | 31 | using System.Drawing; |
31 | using System.Drawing.Imaging; | 32 | using System.Drawing.Imaging; |
32 | using System.IO; | 33 | using System.IO; |
@@ -41,8 +42,7 @@ using OpenMetaverse.Imaging; | |||
41 | using OpenSim.Framework; | 42 | using OpenSim.Framework; |
42 | using OpenSim.Services.Interfaces; | 43 | using OpenSim.Services.Interfaces; |
43 | using OpenSim.Framework.Communications; | 44 | using OpenSim.Framework.Communications; |
44 | using OpenSim.Framework.Communications.Cache; | 45 | |
45 | using OpenSim.Framework.Communications.Clients; | ||
46 | using OpenSim.Framework.Console; | 46 | using OpenSim.Framework.Console; |
47 | using OpenSim.Region.Framework.Interfaces; | 47 | using OpenSim.Region.Framework.Interfaces; |
48 | using OpenSim.Region.Framework.Scenes.Scripting; | 48 | using 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,87 @@ 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 | |||
322 | protected IGridUserService m_GridUserService; | ||
323 | public IGridUserService GridUserService | ||
324 | { | ||
325 | get | ||
326 | { | ||
327 | if (m_GridUserService == null) | ||
328 | m_GridUserService = RequestModuleInterface<IGridUserService>(); | ||
329 | return m_GridUserService; | ||
330 | } | ||
331 | } | ||
332 | |||
257 | protected IXMLRPC m_xmlrpcModule; | 333 | protected IXMLRPC m_xmlrpcModule; |
258 | protected IWorldComm m_worldCommModule; | 334 | protected IWorldComm m_worldCommModule; |
335 | public IAttachmentsModule AttachmentsModule { get; set; } | ||
259 | protected IAvatarFactory m_AvatarFactory; | 336 | protected IAvatarFactory m_AvatarFactory; |
260 | public IAvatarFactory AvatarFactory | 337 | public IAvatarFactory AvatarFactory |
261 | { | 338 | { |
@@ -263,10 +340,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
263 | } | 340 | } |
264 | protected IConfigSource m_config; | 341 | protected IConfigSource m_config; |
265 | protected IRegionSerialiserModule m_serialiser; | 342 | protected IRegionSerialiserModule m_serialiser; |
266 | protected IInterregionCommsOut m_interregionCommsOut; | ||
267 | protected IInterregionCommsIn m_interregionCommsIn; | ||
268 | protected IDialogModule m_dialogModule; | 343 | protected IDialogModule m_dialogModule; |
269 | protected ITeleportModule m_teleportModule; | 344 | protected IEntityTransferModule m_teleportModule; |
270 | 345 | ||
271 | protected ICapabilitiesModule m_capsModule; | 346 | protected ICapabilitiesModule m_capsModule; |
272 | public ICapabilitiesModule CapsModule | 347 | public ICapabilitiesModule CapsModule |
@@ -497,7 +572,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
497 | #region Constructors | 572 | #region Constructors |
498 | 573 | ||
499 | public Scene(RegionInfo regInfo, AgentCircuitManager authen, | 574 | public Scene(RegionInfo regInfo, AgentCircuitManager authen, |
500 | CommunicationsManager commsMan, SceneCommunicationService sceneGridService, | 575 | SceneCommunicationService sceneGridService, |
501 | StorageManager storeManager, | 576 | StorageManager storeManager, |
502 | ModuleLoader moduleLoader, bool dumpAssetsToFile, bool physicalPrim, | 577 | ModuleLoader moduleLoader, bool dumpAssetsToFile, bool physicalPrim, |
503 | bool SeeIntoRegionFromNeighbor, IConfigSource config, string simulatorVersion) | 578 | bool SeeIntoRegionFromNeighbor, IConfigSource config, string simulatorVersion) |
@@ -533,7 +608,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
533 | m_lastAllocatedLocalId = (uint)(random.NextDouble() * (double)(uint.MaxValue/2))+(uint)(uint.MaxValue/4); | 608 | m_lastAllocatedLocalId = (uint)(random.NextDouble() * (double)(uint.MaxValue/2))+(uint)(uint.MaxValue/4); |
534 | m_moduleLoader = moduleLoader; | 609 | m_moduleLoader = moduleLoader; |
535 | m_authenticateHandler = authen; | 610 | m_authenticateHandler = authen; |
536 | CommsManager = commsMan; | ||
537 | m_sceneGridService = sceneGridService; | 611 | m_sceneGridService = sceneGridService; |
538 | m_storageManager = storeManager; | 612 | m_storageManager = storeManager; |
539 | m_regInfo = regInfo; | 613 | m_regInfo = regInfo; |
@@ -557,9 +631,52 @@ namespace OpenSim.Region.Framework.Scenes | |||
557 | 631 | ||
558 | if (m_storageManager.EstateDataStore != null) | 632 | if (m_storageManager.EstateDataStore != null) |
559 | { | 633 | { |
560 | m_regInfo.EstateSettings = m_storageManager.EstateDataStore.LoadEstateSettings(m_regInfo.RegionID); | 634 | m_regInfo.EstateSettings = m_storageManager.EstateDataStore.LoadEstateSettings(m_regInfo.RegionID, false); |
635 | if (m_regInfo.EstateSettings.EstateID == 0) // No record at all | ||
636 | { | ||
637 | MainConsole.Instance.Output("Your region is not part of an estate."); | ||
638 | while (true) | ||
639 | { | ||
640 | string response = MainConsole.Instance.CmdPrompt("Do you wish to join an existing estate?", "no", new List<string>() {"yes", "no"}); | ||
641 | if (response == "no") | ||
642 | { | ||
643 | // Create a new estate | ||
644 | m_regInfo.EstateSettings = m_storageManager.EstateDataStore.LoadEstateSettings(m_regInfo.RegionID, true); | ||
645 | |||
646 | m_regInfo.EstateSettings.EstateName = MainConsole.Instance.CmdPrompt("New estate name", m_regInfo.EstateSettings.EstateName); | ||
647 | m_regInfo.EstateSettings.Save(); | ||
648 | break; | ||
649 | } | ||
650 | else | ||
651 | { | ||
652 | response = MainConsole.Instance.CmdPrompt("Estate name to join", "None"); | ||
653 | if (response == "None") | ||
654 | continue; | ||
655 | |||
656 | List<int> estateIDs = m_storageManager.EstateDataStore.GetEstates(response); | ||
657 | if (estateIDs.Count < 1) | ||
658 | { | ||
659 | MainConsole.Instance.Output("The name you have entered matches no known estate. Please try again"); | ||
660 | continue; | ||
661 | } | ||
662 | |||
663 | int estateID = estateIDs[0]; | ||
664 | |||
665 | m_regInfo.EstateSettings = m_storageManager.EstateDataStore.LoadEstateSettings(estateID); | ||
666 | |||
667 | if (m_storageManager.EstateDataStore.LinkRegion(m_regInfo.RegionID, estateID)) | ||
668 | break; | ||
669 | |||
670 | MainConsole.Instance.Output("Joining the estate failed. Please try again."); | ||
671 | } | ||
672 | } | ||
673 | } | ||
561 | } | 674 | } |
562 | 675 | ||
676 | MainConsole.Instance.Commands.AddCommand("region", false, "reload estate", | ||
677 | "reload estate", | ||
678 | "Reload the estate data", HandleReloadEstate); | ||
679 | |||
563 | //Bind Storage Manager functions to some land manager functions for this scene | 680 | //Bind Storage Manager functions to some land manager functions for this scene |
564 | EventManager.OnLandObjectAdded += | 681 | EventManager.OnLandObjectAdded += |
565 | new EventManager.LandObjectAdded(m_storageManager.DataStore.StoreLandObject); | 682 | new EventManager.LandObjectAdded(m_storageManager.DataStore.StoreLandObject); |
@@ -606,9 +723,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
606 | // | 723 | // |
607 | IConfig startupConfig = m_config.Configs["Startup"]; | 724 | IConfig startupConfig = m_config.Configs["Startup"]; |
608 | 725 | ||
609 | // Should we try to run loops synchronously or asynchronously? | ||
610 | m_useAsyncWhenPossible = startupConfig.GetBoolean("use_async_when_possible", false); | ||
611 | |||
612 | //Animation states | 726 | //Animation states |
613 | m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); | 727 | m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); |
614 | // TODO: Change default to true once the feature is supported | 728 | // TODO: Change default to true once the feature is supported |
@@ -792,6 +906,36 @@ namespace OpenSim.Region.Framework.Scenes | |||
792 | return m_simulatorVersion; | 906 | return m_simulatorVersion; |
793 | } | 907 | } |
794 | 908 | ||
909 | public string[] GetUserNames(UUID uuid) | ||
910 | { | ||
911 | string[] returnstring = new string[0]; | ||
912 | |||
913 | UserAccount account = UserAccountService.GetUserAccount(RegionInfo.ScopeID, uuid); | ||
914 | |||
915 | if (account != null) | ||
916 | { | ||
917 | returnstring = new string[2]; | ||
918 | returnstring[0] = account.FirstName; | ||
919 | returnstring[1] = account.LastName; | ||
920 | } | ||
921 | |||
922 | return returnstring; | ||
923 | } | ||
924 | |||
925 | public string GetUserName(UUID uuid) | ||
926 | { | ||
927 | string[] names = GetUserNames(uuid); | ||
928 | if (names.Length == 2) | ||
929 | { | ||
930 | string firstname = names[0]; | ||
931 | string lastname = names[1]; | ||
932 | |||
933 | return firstname + " " + lastname; | ||
934 | |||
935 | } | ||
936 | return "(hippos)"; | ||
937 | } | ||
938 | |||
795 | /// <summary> | 939 | /// <summary> |
796 | /// Another region is up. | 940 | /// Another region is up. |
797 | /// | 941 | /// |
@@ -825,7 +969,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
825 | regInfo.RegionName = otherRegion.RegionName; | 969 | regInfo.RegionName = otherRegion.RegionName; |
826 | regInfo.ScopeID = otherRegion.ScopeID; | 970 | regInfo.ScopeID = otherRegion.ScopeID; |
827 | regInfo.ExternalHostName = otherRegion.ExternalHostName; | 971 | regInfo.ExternalHostName = otherRegion.ExternalHostName; |
828 | 972 | GridRegion r = new GridRegion(regInfo); | |
829 | try | 973 | try |
830 | { | 974 | { |
831 | ForEachScenePresence(delegate(ScenePresence agent) | 975 | ForEachScenePresence(delegate(ScenePresence agent) |
@@ -839,7 +983,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
839 | List<ulong> old = new List<ulong>(); | 983 | List<ulong> old = new List<ulong>(); |
840 | old.Add(otherRegion.RegionHandle); | 984 | old.Add(otherRegion.RegionHandle); |
841 | agent.DropOldNeighbours(old); | 985 | agent.DropOldNeighbours(old); |
842 | InformClientOfNeighbor(agent, regInfo); | 986 | if (m_teleportModule != null) |
987 | m_teleportModule.EnableChildAgent(agent, r); | ||
843 | } | 988 | } |
844 | } | 989 | } |
845 | ); | 990 | ); |
@@ -999,6 +1144,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
999 | { | 1144 | { |
1000 | foreach (RegionInfo region in m_regionRestartNotifyList) | 1145 | foreach (RegionInfo region in m_regionRestartNotifyList) |
1001 | { | 1146 | { |
1147 | GridRegion r = new GridRegion(region); | ||
1002 | try | 1148 | try |
1003 | { | 1149 | { |
1004 | ForEachScenePresence(delegate(ScenePresence agent) | 1150 | ForEachScenePresence(delegate(ScenePresence agent) |
@@ -1006,9 +1152,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1006 | // If agent is a root agent. | 1152 | // If agent is a root agent. |
1007 | if (!agent.IsChildAgent) | 1153 | if (!agent.IsChildAgent) |
1008 | { | 1154 | { |
1009 | //agent.ControllingClient.new | 1155 | if (m_teleportModule != null) |
1010 | //this.CommsManager.InterRegion.InformRegionOfChildAgent(otherRegion.RegionHandle, agent.ControllingClient.RequestClientInfo()); | 1156 | m_teleportModule.EnableChildAgent(agent, r); |
1011 | InformClientOfNeighbor(agent, region); | ||
1012 | } | 1157 | } |
1013 | } | 1158 | } |
1014 | ); | 1159 | ); |
@@ -1029,7 +1174,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1029 | { | 1174 | { |
1030 | if (m_scripts_enabled != !ScriptEngine) | 1175 | if (m_scripts_enabled != !ScriptEngine) |
1031 | { | 1176 | { |
1032 | // Tedd! Here's the method to disable the scripting engine! | ||
1033 | if (ScriptEngine) | 1177 | if (ScriptEngine) |
1034 | { | 1178 | { |
1035 | m_log.Info("Stopping all Scripts in Scene"); | 1179 | m_log.Info("Stopping all Scripts in Scene"); |
@@ -1051,6 +1195,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1051 | if (ent is SceneObjectGroup) | 1195 | if (ent is SceneObjectGroup) |
1052 | { | 1196 | { |
1053 | ((SceneObjectGroup)ent).CreateScriptInstances(0, false, DefaultScriptEngine, 0); | 1197 | ((SceneObjectGroup)ent).CreateScriptInstances(0, false, DefaultScriptEngine, 0); |
1198 | ((SceneObjectGroup)ent).ResumeScripts(); | ||
1054 | } | 1199 | } |
1055 | } | 1200 | } |
1056 | } | 1201 | } |
@@ -1067,10 +1212,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1067 | 1212 | ||
1068 | public int GetInaccurateNeighborCount() | 1213 | public int GetInaccurateNeighborCount() |
1069 | { | 1214 | { |
1070 | lock (m_neighbours) | 1215 | return m_neighbours.Count; |
1071 | { | ||
1072 | return m_neighbours.Count; | ||
1073 | } | ||
1074 | } | 1216 | } |
1075 | 1217 | ||
1076 | // This is the method that shuts down the scene. | 1218 | // This is the method that shuts down the scene. |
@@ -1150,12 +1292,89 @@ namespace OpenSim.Region.Framework.Scenes | |||
1150 | m_worldCommModule = RequestModuleInterface<IWorldComm>(); | 1292 | m_worldCommModule = RequestModuleInterface<IWorldComm>(); |
1151 | XferManager = RequestModuleInterface<IXfer>(); | 1293 | XferManager = RequestModuleInterface<IXfer>(); |
1152 | m_AvatarFactory = RequestModuleInterface<IAvatarFactory>(); | 1294 | m_AvatarFactory = RequestModuleInterface<IAvatarFactory>(); |
1295 | AttachmentsModule = RequestModuleInterface<IAttachmentsModule>(); | ||
1153 | m_serialiser = RequestModuleInterface<IRegionSerialiserModule>(); | 1296 | m_serialiser = RequestModuleInterface<IRegionSerialiserModule>(); |
1154 | m_interregionCommsOut = RequestModuleInterface<IInterregionCommsOut>(); | ||
1155 | m_interregionCommsIn = RequestModuleInterface<IInterregionCommsIn>(); | ||
1156 | m_dialogModule = RequestModuleInterface<IDialogModule>(); | 1297 | m_dialogModule = RequestModuleInterface<IDialogModule>(); |
1157 | m_capsModule = RequestModuleInterface<ICapabilitiesModule>(); | 1298 | m_capsModule = RequestModuleInterface<ICapabilitiesModule>(); |
1158 | m_teleportModule = RequestModuleInterface<ITeleportModule>(); | 1299 | m_teleportModule = RequestModuleInterface<IEntityTransferModule>(); |
1300 | |||
1301 | // Shoving this in here for now, because we have the needed | ||
1302 | // interfaces at this point | ||
1303 | // | ||
1304 | // TODO: Find a better place for this | ||
1305 | // | ||
1306 | while (m_regInfo.EstateSettings.EstateOwner == UUID.Zero && MainConsole.Instance != null) | ||
1307 | { | ||
1308 | MainConsole.Instance.Output("The current estate has no owner set."); | ||
1309 | string first = MainConsole.Instance.CmdPrompt("Estate owner first name", "Test"); | ||
1310 | string last = MainConsole.Instance.CmdPrompt("Estate owner last name", "User"); | ||
1311 | |||
1312 | UserAccount account = UserAccountService.GetUserAccount(m_regInfo.ScopeID, first, last); | ||
1313 | |||
1314 | if (account == null) | ||
1315 | { | ||
1316 | // Create a new account | ||
1317 | account = new UserAccount(m_regInfo.ScopeID, first, last, String.Empty); | ||
1318 | if (account.ServiceURLs == null || (account.ServiceURLs != null && account.ServiceURLs.Count == 0)) | ||
1319 | { | ||
1320 | account.ServiceURLs = new Dictionary<string, object>(); | ||
1321 | account.ServiceURLs["HomeURI"] = string.Empty; | ||
1322 | account.ServiceURLs["GatekeeperURI"] = string.Empty; | ||
1323 | account.ServiceURLs["InventoryServerURI"] = string.Empty; | ||
1324 | account.ServiceURLs["AssetServerURI"] = string.Empty; | ||
1325 | } | ||
1326 | |||
1327 | if (UserAccountService.StoreUserAccount(account)) | ||
1328 | { | ||
1329 | string password = MainConsole.Instance.PasswdPrompt("Password"); | ||
1330 | string email = MainConsole.Instance.CmdPrompt("Email", ""); | ||
1331 | |||
1332 | account.Email = email; | ||
1333 | UserAccountService.StoreUserAccount(account); | ||
1334 | |||
1335 | bool success = false; | ||
1336 | success = AuthenticationService.SetPassword(account.PrincipalID, password); | ||
1337 | if (!success) | ||
1338 | m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to set password for account {0} {1}.", | ||
1339 | first, last); | ||
1340 | |||
1341 | GridRegion home = null; | ||
1342 | if (GridService != null) | ||
1343 | { | ||
1344 | List<GridRegion> defaultRegions = GridService.GetDefaultRegions(UUID.Zero); | ||
1345 | if (defaultRegions != null && defaultRegions.Count >= 1) | ||
1346 | home = defaultRegions[0]; | ||
1347 | |||
1348 | if (GridUserService != null && home != null) | ||
1349 | GridUserService.SetHome(account.PrincipalID.ToString(), home.RegionID, new Vector3(128, 128, 0), new Vector3(0, 1, 0)); | ||
1350 | else | ||
1351 | m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to set home for account {0} {1}.", | ||
1352 | first, last); | ||
1353 | |||
1354 | } | ||
1355 | else | ||
1356 | m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to retrieve home region for account {0} {1}.", | ||
1357 | first, last); | ||
1358 | |||
1359 | if (InventoryService != null) | ||
1360 | success = InventoryService.CreateUserInventory(account.PrincipalID); | ||
1361 | if (!success) | ||
1362 | m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to create inventory for account {0} {1}.", | ||
1363 | first, last); | ||
1364 | |||
1365 | |||
1366 | m_log.InfoFormat("[USER ACCOUNT SERVICE]: Account {0} {1} created successfully", first, last); | ||
1367 | |||
1368 | m_regInfo.EstateSettings.EstateOwner = account.PrincipalID; | ||
1369 | m_regInfo.EstateSettings.Save(); | ||
1370 | } | ||
1371 | } | ||
1372 | else | ||
1373 | { | ||
1374 | m_regInfo.EstateSettings.EstateOwner = account.PrincipalID; | ||
1375 | m_regInfo.EstateSettings.Save(); | ||
1376 | } | ||
1377 | } | ||
1159 | } | 1378 | } |
1160 | 1379 | ||
1161 | #endregion | 1380 | #endregion |
@@ -1539,7 +1758,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1539 | m_storageManager.DataStore.StoreTerrain(Heightmap.GetDoubles(), RegionInfo.RegionID); | 1758 | m_storageManager.DataStore.StoreTerrain(Heightmap.GetDoubles(), RegionInfo.RegionID); |
1540 | } | 1759 | } |
1541 | 1760 | ||
1542 | public void StoreWindlightProfile(RegionMeta7WindlightData wl) | 1761 | public void StoreWindlightProfile(RegionLightShareData wl) |
1543 | { | 1762 | { |
1544 | m_regInfo.WindlightSettings = wl; | 1763 | m_regInfo.WindlightSettings = wl; |
1545 | m_storageManager.DataStore.StoreRegionWindlightSettings(wl); | 1764 | m_storageManager.DataStore.StoreRegionWindlightSettings(wl); |
@@ -1605,7 +1824,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1605 | GridRegion region = new GridRegion(RegionInfo); | 1824 | GridRegion region = new GridRegion(RegionInfo); |
1606 | string error = GridService.RegisterRegion(RegionInfo.ScopeID, region); | 1825 | string error = GridService.RegisterRegion(RegionInfo.ScopeID, region); |
1607 | if (error != String.Empty) | 1826 | if (error != String.Empty) |
1827 | { | ||
1608 | throw new Exception(error); | 1828 | throw new Exception(error); |
1829 | } | ||
1609 | 1830 | ||
1610 | m_sceneGridService.SetScene(this); | 1831 | m_sceneGridService.SetScene(this); |
1611 | m_sceneGridService.InformNeighborsThatRegionisUp(RequestModuleInterface<INeighbourService>(), RegionInfo); | 1832 | m_sceneGridService.InformNeighborsThatRegionisUp(RequestModuleInterface<INeighbourService>(), RegionInfo); |
@@ -1630,7 +1851,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1630 | /// <summary> | 1851 | /// <summary> |
1631 | /// Create a terrain texture for this scene | 1852 | /// Create a terrain texture for this scene |
1632 | /// </summary> | 1853 | /// </summary> |
1633 | public void CreateTerrainTexture(bool temporary) | 1854 | public void CreateTerrainTexture() |
1634 | { | 1855 | { |
1635 | //create a texture asset of the terrain | 1856 | //create a texture asset of the terrain |
1636 | IMapImageGenerator terrain = RequestModuleInterface<IMapImageGenerator>(); | 1857 | IMapImageGenerator terrain = RequestModuleInterface<IMapImageGenerator>(); |
@@ -1648,7 +1869,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1648 | IWorldMapModule mapModule = RequestModuleInterface<IWorldMapModule>(); | 1869 | IWorldMapModule mapModule = RequestModuleInterface<IWorldMapModule>(); |
1649 | 1870 | ||
1650 | if (mapModule != null) | 1871 | if (mapModule != null) |
1651 | mapModule.LazySaveGeneratedMaptile(data, temporary); | 1872 | mapModule.RegenerateMaptile(data); |
1873 | else | ||
1874 | m_log.DebugFormat("[SCENE]: MapModule is null, can't save maptile"); | ||
1652 | } | 1875 | } |
1653 | } | 1876 | } |
1654 | 1877 | ||
@@ -2017,7 +2240,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 | 2240 | /// Move the given scene object into a new region depending on which region its absolute position has moved |
2018 | /// into. | 2241 | /// into. |
2019 | /// | 2242 | /// |
2020 | /// This method locates the new region handle and offsets the prim position for the new region | ||
2021 | /// </summary> | 2243 | /// </summary> |
2022 | /// <param name="attemptedPosition">the attempted out of region position of the scene object</param> | 2244 | /// <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> | 2245 | /// <param name="grp">the scene object that we're crossing</param> |
@@ -2059,191 +2281,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2059 | return; | 2281 | return; |
2060 | } | 2282 | } |
2061 | 2283 | ||
2062 | int thisx = (int)RegionInfo.RegionLocX; | 2284 | if (m_teleportModule != null) |
2063 | int thisy = (int)RegionInfo.RegionLocY; | 2285 | 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 | } | 2286 | } |
2248 | 2287 | ||
2249 | public Border GetCrossedBorder(Vector3 position, Cardinals gridline) | 2288 | public Border GetCrossedBorder(Vector3 position, Cardinals gridline) |
@@ -2427,75 +2466,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2427 | 2466 | ||
2428 | 2467 | ||
2429 | /// <summary> | 2468 | /// <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. | 2469 | /// Called when objects or attachments cross the border between regions. |
2500 | /// </summary> | 2470 | /// </summary> |
2501 | /// <param name="sog"></param> | 2471 | /// <param name="sog"></param> |
@@ -2539,10 +2509,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
2539 | //m_log.DebugFormat(" >>> IncomingCreateObject(userID, itemID) <<< {0} {1}", userID, itemID); | 2509 | //m_log.DebugFormat(" >>> IncomingCreateObject(userID, itemID) <<< {0} {1}", userID, itemID); |
2540 | 2510 | ||
2541 | ScenePresence sp = GetScenePresence(userID); | 2511 | ScenePresence sp = GetScenePresence(userID); |
2542 | if (sp != null) | 2512 | if (sp != null && AttachmentsModule != null) |
2543 | { | 2513 | { |
2544 | uint attPt = (uint)sp.Appearance.GetAttachpoint(itemID); | 2514 | uint attPt = (uint)sp.Appearance.GetAttachpoint(itemID); |
2545 | m_sceneGraph.RezSingleAttachment(sp.ControllingClient, itemID, attPt); | 2515 | AttachmentsModule.RezSingleAttachmentFromInventory(sp.ControllingClient, itemID, attPt); |
2546 | } | 2516 | } |
2547 | 2517 | ||
2548 | return false; | 2518 | return false; |
@@ -2567,6 +2537,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2567 | 2537 | ||
2568 | return false; | 2538 | return false; |
2569 | } | 2539 | } |
2540 | |||
2541 | sceneObject.SetScene(this); | ||
2542 | |||
2570 | // Force allocation of new LocalId | 2543 | // Force allocation of new LocalId |
2571 | // | 2544 | // |
2572 | foreach (SceneObjectPart p in sceneObject.Children.Values) | 2545 | foreach (SceneObjectPart p in sceneObject.Children.Values) |
@@ -2603,9 +2576,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
2603 | //grp.SetFromAssetID(grp.RootPart.LastOwnerID); | 2576 | //grp.SetFromAssetID(grp.RootPart.LastOwnerID); |
2604 | m_log.DebugFormat( | 2577 | m_log.DebugFormat( |
2605 | "[ATTACHMENT]: Attach to avatar {0} at position {1}", sp.UUID, grp.AbsolutePosition); | 2578 | "[ATTACHMENT]: Attach to avatar {0} at position {1}", sp.UUID, grp.AbsolutePosition); |
2579 | |||
2580 | if (AttachmentsModule != null) | ||
2581 | AttachmentsModule.AttachObject( | ||
2582 | sp.ControllingClient, grp.LocalId, (uint)0, grp.GroupRotation, grp.AbsolutePosition, false); | ||
2606 | 2583 | ||
2607 | AttachObject( | ||
2608 | sp.ControllingClient, grp.LocalId, (uint)0, grp.GroupRotation, grp.AbsolutePosition, false); | ||
2609 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); | 2584 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); |
2610 | grp.SendGroupFullUpdate(); | 2585 | grp.SendGroupFullUpdate(); |
2611 | } | 2586 | } |
@@ -2645,6 +2620,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2645 | /// <param name="client"></param> | 2620 | /// <param name="client"></param> |
2646 | public override void AddNewClient(IClientAPI client) | 2621 | public override void AddNewClient(IClientAPI client) |
2647 | { | 2622 | { |
2623 | bool vialogin = false; | ||
2624 | |||
2648 | m_clientManager.Add(client); | 2625 | m_clientManager.Add(client); |
2649 | 2626 | ||
2650 | CheckHeartbeat(); | 2627 | CheckHeartbeat(); |
@@ -2679,23 +2656,37 @@ namespace OpenSim.Region.Framework.Scenes | |||
2679 | { | 2656 | { |
2680 | AgentCircuitData aCircuit = m_authenticateHandler.GetAgentCircuitData(client.CircuitCode); | 2657 | AgentCircuitData aCircuit = m_authenticateHandler.GetAgentCircuitData(client.CircuitCode); |
2681 | 2658 | ||
2682 | m_log.Debug("[Scene] Adding new agent " + client.Name + " to scene " + RegionInfo.RegionName); | 2659 | // Do the verification here |
2683 | /* | 2660 | System.Net.IPEndPoint ep = (System.Net.IPEndPoint)client.GetClientEP(); |
2684 | string logMsg = string.Format("[SCENE]: Adding new {0} agent for {1} in {2}", | 2661 | if (aCircuit != null) |
2685 | ((aCircuit.child == true) ? "child" : "root"), client.Name, | 2662 | { |
2686 | RegionInfo.RegionName); | 2663 | if (!VerifyClient(aCircuit, ep, out vialogin)) |
2687 | 2664 | { | |
2688 | m_log.Debug(logMsg); | 2665 | // uh-oh, this is fishy |
2689 | */ | 2666 | m_log.WarnFormat("[Scene]: Agent {0} with session {1} connecting with unidentified end point {2}. Refusing service.", |
2667 | client.AgentId, client.SessionId, ep.ToString()); | ||
2668 | try | ||
2669 | { | ||
2670 | client.Close(); | ||
2671 | } | ||
2672 | catch (Exception e) | ||
2673 | { | ||
2674 | m_log.DebugFormat("[Scene]: Exception while closing aborted client: {0}", e.StackTrace); | ||
2675 | } | ||
2676 | return; | ||
2677 | } | ||
2678 | } | ||
2690 | 2679 | ||
2691 | CommsManager.UserProfileCacheService.AddNewUser(client.AgentId); | 2680 | m_log.Debug("[Scene] Adding new agent " + client.Name + " to scene " + RegionInfo.RegionName); |
2692 | 2681 | ||
2693 | ScenePresence sp = CreateAndAddScenePresence(client); | 2682 | ScenePresence sp = CreateAndAddScenePresence(client); |
2683 | if (aCircuit != null) | ||
2684 | sp.Appearance = aCircuit.Appearance; | ||
2694 | 2685 | ||
2695 | // HERE!!! Do the initial attachments right here | 2686 | // HERE!!! Do the initial attachments right here |
2696 | // first agent upon login is a root agent by design. | 2687 | // first agent upon login is a root agent by design. |
2697 | // All other AddNewClient calls find aCircuit.child to be true | 2688 | // All other AddNewClient calls find aCircuit.child to be true |
2698 | if (aCircuit == null || aCircuit.child == false) | 2689 | if (aCircuit == null || (aCircuit != null && aCircuit.child == false)) |
2699 | { | 2690 | { |
2700 | sp.IsChildAgent = false; | 2691 | sp.IsChildAgent = false; |
2701 | Util.FireAndForget(delegate(object o) { sp.RezAttachments(); }); | 2692 | Util.FireAndForget(delegate(object o) { sp.RezAttachments(); }); |
@@ -2704,9 +2695,69 @@ namespace OpenSim.Region.Framework.Scenes | |||
2704 | 2695 | ||
2705 | m_LastLogin = Util.EnvironmentTickCount(); | 2696 | m_LastLogin = Util.EnvironmentTickCount(); |
2706 | EventManager.TriggerOnNewClient(client); | 2697 | EventManager.TriggerOnNewClient(client); |
2698 | if (vialogin) | ||
2699 | EventManager.TriggerOnClientLogin(client); | ||
2707 | } | 2700 | } |
2708 | 2701 | ||
2709 | 2702 | private bool VerifyClient(AgentCircuitData aCircuit, System.Net.IPEndPoint ep, out bool vialogin) | |
2703 | { | ||
2704 | vialogin = false; | ||
2705 | |||
2706 | // Do the verification here | ||
2707 | if ((aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0) | ||
2708 | { | ||
2709 | m_log.DebugFormat("[Scene]: Incoming client {0} {1} in region {2} via Login", aCircuit.firstname, aCircuit.lastname, RegionInfo.RegionName); | ||
2710 | vialogin = true; | ||
2711 | IUserAgentVerificationModule userVerification = RequestModuleInterface<IUserAgentVerificationModule>(); | ||
2712 | if (userVerification != null && ep != null) | ||
2713 | { | ||
2714 | if (!userVerification.VerifyClient(aCircuit, ep.Address.ToString())) | ||
2715 | { | ||
2716 | // uh-oh, this is fishy | ||
2717 | m_log.DebugFormat("[Scene]: User Client Verification for {0} {1} in {2} returned false", aCircuit.firstname, aCircuit.lastname, RegionInfo.RegionName); | ||
2718 | return false; | ||
2719 | } | ||
2720 | else | ||
2721 | m_log.DebugFormat("[Scene]: User Client Verification for {0} {1} in {2} returned true", aCircuit.firstname, aCircuit.lastname, RegionInfo.RegionName); | ||
2722 | } | ||
2723 | } | ||
2724 | |||
2725 | return true; | ||
2726 | } | ||
2727 | |||
2728 | // Called by Caps, on the first HTTP contact from the client | ||
2729 | public override bool CheckClient(UUID agentID, System.Net.IPEndPoint ep) | ||
2730 | { | ||
2731 | AgentCircuitData aCircuit = m_authenticateHandler.GetAgentCircuitData(agentID); | ||
2732 | if (aCircuit != null) | ||
2733 | { | ||
2734 | bool vialogin = false; | ||
2735 | if (!VerifyClient(aCircuit, ep, out vialogin)) | ||
2736 | { | ||
2737 | // if it doesn't pass, we remove the agentcircuitdata altogether | ||
2738 | // and the scene presence and the client, if they exist | ||
2739 | try | ||
2740 | { | ||
2741 | ScenePresence sp = GetScenePresence(agentID); | ||
2742 | if (sp != null) | ||
2743 | sp.ControllingClient.Close(); | ||
2744 | |||
2745 | // BANG! SLASH! | ||
2746 | m_authenticateHandler.RemoveCircuit(agentID); | ||
2747 | |||
2748 | return false; | ||
2749 | } | ||
2750 | catch (Exception e) | ||
2751 | { | ||
2752 | m_log.DebugFormat("[Scene]: Exception while closing aborted client: {0}", e.StackTrace); | ||
2753 | } | ||
2754 | } | ||
2755 | else | ||
2756 | return true; | ||
2757 | } | ||
2758 | |||
2759 | return false; | ||
2760 | } | ||
2710 | 2761 | ||
2711 | /// <summary> | 2762 | /// <summary> |
2712 | /// Register for events from the client | 2763 | /// Register for events from the client |
@@ -2790,6 +2841,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2790 | public virtual void SubscribeToClientInventoryEvents(IClientAPI client) | 2841 | public virtual void SubscribeToClientInventoryEvents(IClientAPI client) |
2791 | { | 2842 | { |
2792 | client.OnCreateNewInventoryItem += CreateNewInventoryItem; | 2843 | client.OnCreateNewInventoryItem += CreateNewInventoryItem; |
2844 | client.OnLinkInventoryItem += HandleLinkInventoryItem; | ||
2793 | client.OnCreateNewInventoryFolder += HandleCreateInventoryFolder; | 2845 | client.OnCreateNewInventoryFolder += HandleCreateInventoryFolder; |
2794 | client.OnUpdateInventoryFolder += HandleUpdateInventoryFolder; | 2846 | client.OnUpdateInventoryFolder += HandleUpdateInventoryFolder; |
2795 | client.OnMoveInventoryFolder += HandleMoveInventoryFolder; // 2; //!! | 2847 | client.OnMoveInventoryFolder += HandleMoveInventoryFolder; // 2; //!! |
@@ -2809,19 +2861,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
2809 | } | 2861 | } |
2810 | 2862 | ||
2811 | public virtual void SubscribeToClientAttachmentEvents(IClientAPI client) | 2863 | public virtual void SubscribeToClientAttachmentEvents(IClientAPI client) |
2812 | { | 2864 | { |
2813 | client.OnRezSingleAttachmentFromInv += RezSingleAttachment; | 2865 | if (AttachmentsModule != null) |
2814 | client.OnRezMultipleAttachmentsFromInv += RezMultipleAttachments; | 2866 | { |
2815 | client.OnDetachAttachmentIntoInv += DetachSingleAttachmentToInv; | 2867 | client.OnRezSingleAttachmentFromInv += AttachmentsModule.RezSingleAttachmentFromInventory; |
2816 | client.OnObjectAttach += m_sceneGraph.AttachObject; | 2868 | client.OnRezMultipleAttachmentsFromInv += AttachmentsModule.RezMultipleAttachmentsFromInventory; |
2817 | client.OnObjectDetach += m_sceneGraph.DetachObject; | 2869 | client.OnObjectAttach += AttachmentsModule.AttachObject; |
2870 | client.OnObjectDetach += AttachmentsModule.DetachObject; | ||
2871 | client.OnDetachAttachmentIntoInv += AttachmentsModule.ShowDetachInUserInventory; | ||
2872 | } | ||
2818 | } | 2873 | } |
2819 | 2874 | ||
2820 | public virtual void SubscribeToClientTeleportEvents(IClientAPI client) | 2875 | public virtual void SubscribeToClientTeleportEvents(IClientAPI client) |
2821 | { | 2876 | { |
2822 | client.OnTeleportLocationRequest += RequestTeleportLocation; | 2877 | client.OnTeleportLocationRequest += RequestTeleportLocation; |
2823 | client.OnTeleportLandmarkRequest += RequestTeleportLandmark; | 2878 | client.OnTeleportLandmarkRequest += RequestTeleportLandmark; |
2824 | client.OnTeleportHomeRequest += TeleportClientHome; | ||
2825 | } | 2879 | } |
2826 | 2880 | ||
2827 | public virtual void SubscribeToClientScriptEvents(IClientAPI client) | 2881 | public virtual void SubscribeToClientScriptEvents(IClientAPI client) |
@@ -2841,7 +2895,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2841 | 2895 | ||
2842 | public virtual void SubscribeToClientGridEvents(IClientAPI client) | 2896 | public virtual void SubscribeToClientGridEvents(IClientAPI client) |
2843 | { | 2897 | { |
2844 | client.OnNameFromUUIDRequest += CommsManager.HandleUUIDNameRequest; | 2898 | client.OnNameFromUUIDRequest += HandleUUIDNameRequest; |
2845 | client.OnMoneyTransferRequest += ProcessMoneyTransferRequest; | 2899 | client.OnMoneyTransferRequest += ProcessMoneyTransferRequest; |
2846 | client.OnAvatarPickerRequest += ProcessAvatarPickerRequest; | 2900 | client.OnAvatarPickerRequest += ProcessAvatarPickerRequest; |
2847 | client.OnSetStartLocationRequest += SetHomeRezPoint; | 2901 | client.OnSetStartLocationRequest += SetHomeRezPoint; |
@@ -2863,7 +2917,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2863 | 2917 | ||
2864 | protected virtual void UnsubscribeToClientEvents(IClientAPI client) | 2918 | protected virtual void UnsubscribeToClientEvents(IClientAPI client) |
2865 | { | 2919 | { |
2866 | |||
2867 | } | 2920 | } |
2868 | 2921 | ||
2869 | /// <summary> | 2922 | /// <summary> |
@@ -2885,7 +2938,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2885 | 2938 | ||
2886 | UnSubscribeToClientNetworkEvents(client); | 2939 | UnSubscribeToClientNetworkEvents(client); |
2887 | 2940 | ||
2888 | |||
2889 | // EventManager.TriggerOnNewClient(client); | 2941 | // EventManager.TriggerOnNewClient(client); |
2890 | } | 2942 | } |
2891 | 2943 | ||
@@ -2942,7 +2994,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2942 | client.OnRezObject -= RezObject; | 2994 | client.OnRezObject -= RezObject; |
2943 | } | 2995 | } |
2944 | 2996 | ||
2945 | |||
2946 | public virtual void UnSubscribeToClientInventoryEvents(IClientAPI client) | 2997 | public virtual void UnSubscribeToClientInventoryEvents(IClientAPI client) |
2947 | { | 2998 | { |
2948 | client.OnCreateNewInventoryItem -= CreateNewInventoryItem; | 2999 | client.OnCreateNewInventoryItem -= CreateNewInventoryItem; |
@@ -2965,19 +3016,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
2965 | } | 3016 | } |
2966 | 3017 | ||
2967 | public virtual void UnSubscribeToClientAttachmentEvents(IClientAPI client) | 3018 | public virtual void UnSubscribeToClientAttachmentEvents(IClientAPI client) |
2968 | { | 3019 | { |
2969 | client.OnRezSingleAttachmentFromInv -= RezSingleAttachment; | 3020 | if (AttachmentsModule != null) |
2970 | client.OnRezMultipleAttachmentsFromInv -= RezMultipleAttachments; | 3021 | { |
2971 | client.OnDetachAttachmentIntoInv -= DetachSingleAttachmentToInv; | 3022 | client.OnRezSingleAttachmentFromInv -= AttachmentsModule.RezSingleAttachmentFromInventory; |
2972 | client.OnObjectAttach -= m_sceneGraph.AttachObject; | 3023 | client.OnRezMultipleAttachmentsFromInv -= AttachmentsModule.RezMultipleAttachmentsFromInventory; |
2973 | client.OnObjectDetach -= m_sceneGraph.DetachObject; | 3024 | client.OnObjectAttach -= AttachmentsModule.AttachObject; |
3025 | client.OnObjectDetach -= AttachmentsModule.DetachObject; | ||
3026 | client.OnDetachAttachmentIntoInv -= AttachmentsModule.ShowDetachInUserInventory; | ||
3027 | } | ||
2974 | } | 3028 | } |
2975 | 3029 | ||
2976 | public virtual void UnSubscribeToClientTeleportEvents(IClientAPI client) | 3030 | public virtual void UnSubscribeToClientTeleportEvents(IClientAPI client) |
2977 | { | 3031 | { |
2978 | client.OnTeleportLocationRequest -= RequestTeleportLocation; | 3032 | client.OnTeleportLocationRequest -= RequestTeleportLocation; |
2979 | client.OnTeleportLandmarkRequest -= RequestTeleportLandmark; | 3033 | client.OnTeleportLandmarkRequest -= RequestTeleportLandmark; |
2980 | client.OnTeleportHomeRequest -= TeleportClientHome; | 3034 | //client.OnTeleportHomeRequest -= TeleportClientHome; |
2981 | } | 3035 | } |
2982 | 3036 | ||
2983 | public virtual void UnSubscribeToClientScriptEvents(IClientAPI client) | 3037 | public virtual void UnSubscribeToClientScriptEvents(IClientAPI client) |
@@ -2997,7 +3051,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2997 | 3051 | ||
2998 | public virtual void UnSubscribeToClientGridEvents(IClientAPI client) | 3052 | public virtual void UnSubscribeToClientGridEvents(IClientAPI client) |
2999 | { | 3053 | { |
3000 | client.OnNameFromUUIDRequest -= CommsManager.HandleUUIDNameRequest; | 3054 | client.OnNameFromUUIDRequest -= HandleUUIDNameRequest; |
3001 | client.OnMoneyTransferRequest -= ProcessMoneyTransferRequest; | 3055 | client.OnMoneyTransferRequest -= ProcessMoneyTransferRequest; |
3002 | client.OnAvatarPickerRequest -= ProcessAvatarPickerRequest; | 3056 | client.OnAvatarPickerRequest -= ProcessAvatarPickerRequest; |
3003 | client.OnSetStartLocationRequest -= SetHomeRezPoint; | 3057 | client.OnSetStartLocationRequest -= SetHomeRezPoint; |
@@ -3024,30 +3078,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
3024 | /// <param name="client">The IClientAPI for the client</param> | 3078 | /// <param name="client">The IClientAPI for the client</param> |
3025 | public virtual void TeleportClientHome(UUID agentId, IClientAPI client) | 3079 | public virtual void TeleportClientHome(UUID agentId, IClientAPI client) |
3026 | { | 3080 | { |
3027 | UserProfileData UserProfile = CommsManager.UserService.GetUserProfile(agentId); | 3081 | if (m_teleportModule != null) |
3028 | if (UserProfile != null) | 3082 | m_teleportModule.TeleportHome(agentId, client); |
3083 | else | ||
3029 | { | 3084 | { |
3030 | GridRegion regionInfo = GridService.GetRegionByUUID(UUID.Zero, UserProfile.HomeRegionID); | 3085 | m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); |
3031 | if (regionInfo == null) | 3086 | 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 | } | 3087 | } |
3052 | } | 3088 | } |
3053 | 3089 | ||
@@ -3138,7 +3174,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3138 | } | 3174 | } |
3139 | 3175 | ||
3140 | /// <summary> | 3176 | /// <summary> |
3141 | /// Sets the Home Point. The GridService uses this to know where to put a user when they log-in | 3177 | /// Sets the Home Point. The LoginService uses this to know where to put a user when they log-in |
3142 | /// </summary> | 3178 | /// </summary> |
3143 | /// <param name="remoteClient"></param> | 3179 | /// <param name="remoteClient"></param> |
3144 | /// <param name="regionHandle"></param> | 3180 | /// <param name="regionHandle"></param> |
@@ -3147,27 +3183,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
3147 | /// <param name="flags"></param> | 3183 | /// <param name="flags"></param> |
3148 | public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) | 3184 | public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) |
3149 | { | 3185 | { |
3150 | UserProfileData UserProfile = CommsManager.UserService.GetUserProfile(remoteClient.AgentId); | 3186 | if (GridUserService != null && GridUserService.SetHome(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. | 3187 | // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. |
3165 | m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); | 3188 | m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); |
3166 | } | ||
3167 | else | 3189 | else |
3168 | { | ||
3169 | m_dialogModule.SendAlertToUser(remoteClient, "Set Home request Failed."); | 3190 | m_dialogModule.SendAlertToUser(remoteClient, "Set Home request Failed."); |
3170 | } | ||
3171 | } | 3191 | } |
3172 | 3192 | ||
3173 | /// <summary> | 3193 | /// <summary> |
@@ -3240,14 +3260,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
3240 | m_sceneGraph.removeUserCount(!childagentYN); | 3260 | m_sceneGraph.removeUserCount(!childagentYN); |
3241 | CapsModule.RemoveCapsHandler(agentID); | 3261 | CapsModule.RemoveCapsHandler(agentID); |
3242 | 3262 | ||
3243 | if (avatar.Scene.NeedSceneCacheClear(avatar.UUID)) | 3263 | // REFACTORING PROBLEM -- well not really a problem, but just to point out that whatever |
3244 | { | 3264 | // this method is doing is HORRIBLE!!! |
3245 | CommsManager.UserProfileCacheService.RemoveUser(agentID); | 3265 | avatar.Scene.NeedSceneCacheClear(avatar.UUID); |
3246 | } | ||
3247 | 3266 | ||
3248 | if (!avatar.IsChildAgent) | 3267 | if (!avatar.IsChildAgent) |
3249 | { | 3268 | { |
3250 | m_sceneGridService.LogOffUser(agentID, RegionInfo.RegionID, RegionInfo.RegionHandle, avatar.AbsolutePosition, avatar.Lookat); | ||
3251 | //List<ulong> childknownRegions = new List<ulong>(); | 3269 | //List<ulong> childknownRegions = new List<ulong>(); |
3252 | //List<ulong> ckn = avatar.KnownChildRegionHandles; | 3270 | //List<ulong> ckn = avatar.KnownChildRegionHandles; |
3253 | //for (int i = 0; i < ckn.Count; i++) | 3271 | //for (int i = 0; i < ckn.Count; i++) |
@@ -3302,12 +3320,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3302 | m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString()); | 3320 | m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString()); |
3303 | } | 3321 | } |
3304 | 3322 | ||
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); | 3323 | m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); |
3312 | 3324 | ||
3313 | //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); | 3325 | //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); |
@@ -3371,7 +3383,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3371 | /// </summary> | 3383 | /// </summary> |
3372 | public void RegisterCommsEvents() | 3384 | public void RegisterCommsEvents() |
3373 | { | 3385 | { |
3374 | m_sceneGridService.OnExpectUser += HandleNewUserConnection; | ||
3375 | m_sceneGridService.OnAvatarCrossingIntoRegion += AgentCrossing; | 3386 | m_sceneGridService.OnAvatarCrossingIntoRegion += AgentCrossing; |
3376 | m_sceneGridService.OnCloseAgentConnection += IncomingCloseAgent; | 3387 | m_sceneGridService.OnCloseAgentConnection += IncomingCloseAgent; |
3377 | //m_eventManager.OnRegionUp += OtherRegionUp; | 3388 | //m_eventManager.OnRegionUp += OtherRegionUp; |
@@ -3380,14 +3391,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3380 | m_sceneGridService.OnLogOffUser += HandleLogOffUserFromGrid; | 3391 | m_sceneGridService.OnLogOffUser += HandleLogOffUserFromGrid; |
3381 | m_sceneGridService.KiPrimitive += SendKillObject; | 3392 | m_sceneGridService.KiPrimitive += SendKillObject; |
3382 | m_sceneGridService.OnGetLandData += GetLandData; | 3393 | 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 | } | 3394 | } |
3392 | 3395 | ||
3393 | /// <summary> | 3396 | /// <summary> |
@@ -3400,14 +3403,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
3400 | //m_sceneGridService.OnRemoveKnownRegionFromAvatar -= HandleRemoveKnownRegionsFromAvatar; | 3403 | //m_sceneGridService.OnRemoveKnownRegionFromAvatar -= HandleRemoveKnownRegionsFromAvatar; |
3401 | //m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate; | 3404 | //m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate; |
3402 | //m_eventManager.OnRegionUp -= OtherRegionUp; | 3405 | //m_eventManager.OnRegionUp -= OtherRegionUp; |
3403 | m_sceneGridService.OnExpectUser -= HandleNewUserConnection; | ||
3404 | m_sceneGridService.OnAvatarCrossingIntoRegion -= AgentCrossing; | 3406 | m_sceneGridService.OnAvatarCrossingIntoRegion -= AgentCrossing; |
3405 | m_sceneGridService.OnCloseAgentConnection -= IncomingCloseAgent; | 3407 | m_sceneGridService.OnCloseAgentConnection -= IncomingCloseAgent; |
3406 | m_sceneGridService.OnGetLandData -= GetLandData; | 3408 | m_sceneGridService.OnGetLandData -= GetLandData; |
3407 | 3409 | ||
3408 | if (m_interregionCommsIn != null) | ||
3409 | m_interregionCommsIn.OnChildAgentUpdate -= IncomingChildAgentDataUpdate; | ||
3410 | |||
3411 | // this does nothing; should be removed | 3410 | // this does nothing; should be removed |
3412 | m_sceneGridService.Close(); | 3411 | m_sceneGridService.Close(); |
3413 | 3412 | ||
@@ -3415,22 +3414,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3415 | m_log.WarnFormat("[SCENE]: Deregister from grid failed for region {0}", m_regInfo.RegionName); | 3414 | m_log.WarnFormat("[SCENE]: Deregister from grid failed for region {0}", m_regInfo.RegionName); |
3416 | } | 3415 | } |
3417 | 3416 | ||
3418 | /// <summary> | ||
3419 | /// A handler for the SceneCommunicationService event, to match that events return type of void. | ||
3420 | /// Use NewUserConnection() directly if possible so the return type can refuse connections. | ||
3421 | /// At the moment nothing actually seems to use this event, | ||
3422 | /// as everything is switching to calling the NewUserConnection method directly. | ||
3423 | /// | ||
3424 | /// Now obsoleting this because it doesn't handle teleportFlags propertly | ||
3425 | /// | ||
3426 | /// </summary> | ||
3427 | /// <param name="agent"></param> | ||
3428 | [Obsolete("Please call NewUserConnection directly.")] | ||
3429 | public void HandleNewUserConnection(AgentCircuitData agent) | ||
3430 | { | ||
3431 | string reason; | ||
3432 | NewUserConnection(agent, 0, out reason); | ||
3433 | } | ||
3434 | 3417 | ||
3435 | /// <summary> | 3418 | /// <summary> |
3436 | /// Do the work necessary to initiate a new user connection for a particular scene. | 3419 | /// Do the work necessary to initiate a new user connection for a particular scene. |
@@ -3444,6 +3427,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3444 | /// also return a reason.</returns> | 3427 | /// also return a reason.</returns> |
3445 | public bool NewUserConnection(AgentCircuitData agent, uint teleportFlags, out string reason) | 3428 | public bool NewUserConnection(AgentCircuitData agent, uint teleportFlags, out string reason) |
3446 | { | 3429 | { |
3430 | TeleportFlags tp = (TeleportFlags)teleportFlags; | ||
3447 | //Teleport flags: | 3431 | //Teleport flags: |
3448 | // | 3432 | // |
3449 | // TeleportFlags.ViaGodlikeLure - Border Crossing | 3433 | // TeleportFlags.ViaGodlikeLure - Border Crossing |
@@ -3464,7 +3448,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3464 | agent.AgentID, agent.circuitcode, teleportFlags); | 3448 | agent.AgentID, agent.circuitcode, teleportFlags); |
3465 | 3449 | ||
3466 | reason = String.Empty; | 3450 | reason = String.Empty; |
3467 | if (!AuthenticateUser(agent, out reason)) | 3451 | if (!VerifyUserPresence(agent, out reason)) |
3468 | return false; | 3452 | return false; |
3469 | 3453 | ||
3470 | if (!AuthorizeUser(agent, out reason)) | 3454 | if (!AuthorizeUser(agent, out reason)) |
@@ -3477,16 +3461,36 @@ namespace OpenSim.Region.Framework.Scenes | |||
3477 | 3461 | ||
3478 | CapsModule.NewUserConnection(agent); | 3462 | CapsModule.NewUserConnection(agent); |
3479 | 3463 | ||
3480 | ScenePresence sp = m_sceneGraph.GetScenePresence(agent.AgentID); | 3464 | ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); |
3465 | |||
3466 | //On login or border crossing test land permisions | ||
3467 | if (tp != TeleportFlags.Default) | ||
3468 | { | ||
3469 | if (land != null && !TestLandRestrictions(agent, land, out reason)) | ||
3470 | { | ||
3471 | return false; | ||
3472 | } | ||
3473 | } | ||
3474 | |||
3475 | ScenePresence sp = GetScenePresence(agent.AgentID); | ||
3481 | if (sp != null) | 3476 | if (sp != null) |
3482 | { | 3477 | { |
3483 | m_log.DebugFormat( | 3478 | if (sp.IsChildAgent) |
3484 | "[SCENE]: Adjusting known seeds for existing agent {0} in {1}", | 3479 | { |
3485 | agent.AgentID, RegionInfo.RegionName); | 3480 | m_log.DebugFormat( |
3481 | "[SCENE]: Adjusting known seeds for existing agent {0} in {1}", | ||
3482 | agent.AgentID, RegionInfo.RegionName); | ||
3486 | 3483 | ||
3487 | sp.AdjustKnownSeeds(); | 3484 | sp.AdjustKnownSeeds(); |
3488 | 3485 | ||
3489 | return true; | 3486 | return true; |
3487 | } | ||
3488 | else | ||
3489 | { | ||
3490 | // We have a zombie from a crashed session. Kill it. | ||
3491 | m_log.DebugFormat("[SCENE]: Zombie scene presence detected for {0} in {1}", agent.AgentID, RegionInfo.RegionName); | ||
3492 | sp.ControllingClient.Close(false); | ||
3493 | } | ||
3490 | } | 3494 | } |
3491 | 3495 | ||
3492 | CapsModule.AddCapsHandler(agent.AgentID); | 3496 | CapsModule.AddCapsHandler(agent.AgentID); |
@@ -3564,40 +3568,73 @@ namespace OpenSim.Region.Framework.Scenes | |||
3564 | */// This is now handled properly in ScenePresence.MakeRootAgent | 3568 | */// This is now handled properly in ScenePresence.MakeRootAgent |
3565 | } | 3569 | } |
3566 | 3570 | ||
3571 | agent.teleportFlags = teleportFlags; | ||
3567 | m_authenticateHandler.AddNewCircuit(agent.circuitcode, agent); | 3572 | m_authenticateHandler.AddNewCircuit(agent.circuitcode, agent); |
3568 | 3573 | ||
3569 | // rewrite session_id | 3574 | return true; |
3570 | CachedUserInfo userinfo = CommsManager.UserProfileCacheService.GetUserDetails(agent.AgentID); | 3575 | } |
3571 | if (userinfo != null) | 3576 | |
3572 | { | 3577 | private bool TestLandRestrictions(AgentCircuitData agent, ILandObject land, out string reason) |
3573 | userinfo.SessionID = agent.SessionID; | 3578 | { |
3574 | } | 3579 | |
3575 | else | 3580 | bool banned = land.IsBannedFromLand(agent.AgentID); |
3581 | bool restricted = land.IsRestrictedFromLand(agent.AgentID); | ||
3582 | |||
3583 | if (banned || restricted) | ||
3576 | { | 3584 | { |
3577 | m_log.WarnFormat( | 3585 | 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); | 3586 | if (nearestParcel != null) |
3587 | { | ||
3588 | //Move agent to nearest allowed | ||
3589 | Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); | ||
3590 | agent.startpos.X = newPosition.X; | ||
3591 | agent.startpos.Y = newPosition.Y; | ||
3592 | } | ||
3593 | else | ||
3594 | { | ||
3595 | if (banned) | ||
3596 | { | ||
3597 | reason = "Cannot regioncross into banned parcel."; | ||
3598 | } | ||
3599 | else | ||
3600 | { | ||
3601 | reason = String.Format("Denied access to private region {0}: You are not on the access list for that region.", | ||
3602 | RegionInfo.RegionName); | ||
3603 | } | ||
3604 | return false; | ||
3605 | } | ||
3579 | } | 3606 | } |
3580 | 3607 | reason = ""; | |
3581 | return true; | 3608 | return true; |
3582 | } | 3609 | } |
3583 | 3610 | ||
3584 | /// <summary> | 3611 | /// <summary> |
3585 | /// Verifies that the user has a session on the Grid | 3612 | /// Verifies that the user has a presence on the Grid |
3586 | /// </summary> | 3613 | /// </summary> |
3587 | /// <param name="agent">Circuit Data of the Agent we're verifying</param> | 3614 | /// <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> | 3615 | /// <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 | 3616 | /// <returns>True if the user has a session on the grid. False if it does not. False will |
3590 | /// also return a reason.</returns> | 3617 | /// also return a reason.</returns> |
3591 | public virtual bool AuthenticateUser(AgentCircuitData agent, out string reason) | 3618 | public virtual bool VerifyUserPresence(AgentCircuitData agent, out string reason) |
3592 | { | 3619 | { |
3593 | reason = String.Empty; | 3620 | reason = String.Empty; |
3594 | 3621 | ||
3595 | bool result = CommsManager.UserService.VerifySession(agent.AgentID, agent.SessionID); | 3622 | IPresenceService presence = RequestModuleInterface<IPresenceService>(); |
3596 | m_log.Debug("[CONNECTION BEGIN]: User authentication returned " + result); | 3623 | if (presence == null) |
3597 | if (!result) | 3624 | { |
3598 | reason = String.Format("Failed to authenticate user {0} {1}, access denied.", agent.firstname, agent.lastname); | 3625 | reason = String.Format("Failed to verify user {0} {1} in region {2}. Presence service does not exist.", agent.firstname, agent.lastname, RegionInfo.RegionName); |
3626 | return false; | ||
3627 | } | ||
3628 | |||
3629 | OpenSim.Services.Interfaces.PresenceInfo pinfo = presence.GetAgent(agent.SessionID); | ||
3630 | |||
3631 | if (pinfo == null) | ||
3632 | { | ||
3633 | reason = String.Format("Failed to verify user {0} {1}, access denied to region {2}.", agent.firstname, agent.lastname, RegionInfo.RegionName); | ||
3634 | return false; | ||
3635 | } | ||
3599 | 3636 | ||
3600 | return result; | 3637 | return true; |
3601 | } | 3638 | } |
3602 | 3639 | ||
3603 | /// <summary> | 3640 | /// <summary> |
@@ -3702,6 +3739,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
3702 | return true; | 3739 | return true; |
3703 | } | 3740 | } |
3704 | 3741 | ||
3742 | private ILandObject GetParcelAtPoint(float x, float y) | ||
3743 | { | ||
3744 | foreach (var parcel in AllParcels()) | ||
3745 | { | ||
3746 | if (parcel.ContainsPoint((int)x,(int)y)) | ||
3747 | { | ||
3748 | return parcel; | ||
3749 | } | ||
3750 | } | ||
3751 | return null; | ||
3752 | } | ||
3753 | |||
3705 | /// <summary> | 3754 | /// <summary> |
3706 | /// Update an AgentCircuitData object with new information | 3755 | /// Update an AgentCircuitData object with new information |
3707 | /// </summary> | 3756 | /// </summary> |
@@ -3730,8 +3779,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3730 | /// <param name="message">message to display to the user. Reason for being logged off</param> | 3779 | /// <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) | 3780 | public void HandleLogOffUserFromGrid(UUID AvatarID, UUID RegionSecret, string message) |
3732 | { | 3781 | { |
3733 | ScenePresence loggingOffUser = null; | 3782 | ScenePresence loggingOffUser = GetScenePresence(AvatarID); |
3734 | loggingOffUser = GetScenePresence(AvatarID); | ||
3735 | if (loggingOffUser != null) | 3783 | if (loggingOffUser != null) |
3736 | { | 3784 | { |
3737 | UUID localRegionSecret = UUID.Zero; | 3785 | UUID localRegionSecret = UUID.Zero; |
@@ -3767,10 +3815,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3767 | /// <param name="isFlying"></param> | 3815 | /// <param name="isFlying"></param> |
3768 | public virtual void AgentCrossing(UUID agentID, Vector3 position, bool isFlying) | 3816 | public virtual void AgentCrossing(UUID agentID, Vector3 position, bool isFlying) |
3769 | { | 3817 | { |
3770 | ScenePresence presence; | 3818 | ScenePresence presence = GetScenePresence(agentID); |
3771 | m_sceneGraph.TryGetAvatar(agentID, out presence); | 3819 | if(presence != null) |
3772 | |||
3773 | if (presence != null) | ||
3774 | { | 3820 | { |
3775 | try | 3821 | try |
3776 | { | 3822 | { |
@@ -3798,8 +3844,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3798 | /// <returns>true if we handled it.</returns> | 3844 | /// <returns>true if we handled it.</returns> |
3799 | public virtual bool IncomingChildAgentDataUpdate(AgentData cAgentData) | 3845 | public virtual bool IncomingChildAgentDataUpdate(AgentData cAgentData) |
3800 | { | 3846 | { |
3801 | // m_log.DebugFormat( | 3847 | m_log.DebugFormat( |
3802 | // "[SCENE]: Incoming child agent update for {0} in {1}", cAgentData.AgentID, RegionInfo.RegionName); | 3848 | "[SCENE]: Incoming child agent update for {0} in {1}", cAgentData.AgentID, RegionInfo.RegionName); |
3803 | 3849 | ||
3804 | // We have to wait until the viewer contacts this region after receiving EAC. | 3850 | // We have to wait until the viewer contacts this region after receiving EAC. |
3805 | // That calls AddNewClient, which finally creates the ScenePresence | 3851 | // That calls AddNewClient, which finally creates the ScenePresence |
@@ -3868,22 +3914,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
3868 | return false; | 3914 | return false; |
3869 | } | 3915 | } |
3870 | 3916 | ||
3871 | public virtual bool IncomingReleaseAgent(UUID id) | 3917 | public bool IncomingCloseAgent(UUID agentID) |
3872 | { | 3918 | { |
3873 | return m_sceneGridService.ReleaseAgent(id); | 3919 | return IncomingCloseAgent(agentID, false); |
3874 | } | 3920 | } |
3875 | 3921 | ||
3876 | public void SendReleaseAgent(ulong regionHandle, UUID id, string uri) | 3922 | public bool IncomingCloseChildAgent(UUID agentID) |
3877 | { | 3923 | { |
3878 | m_interregionCommsOut.SendReleaseAgent(regionHandle, id, uri); | 3924 | return IncomingCloseAgent(agentID, true); |
3879 | } | 3925 | } |
3880 | 3926 | ||
3881 | /// <summary> | 3927 | /// <summary> |
3882 | /// Tell a single agent to disconnect from the region. | 3928 | /// Tell a single agent to disconnect from the region. |
3883 | /// </summary> | 3929 | /// </summary> |
3884 | /// <param name="regionHandle"></param> | ||
3885 | /// <param name="agentID"></param> | 3930 | /// <param name="agentID"></param> |
3886 | public bool IncomingCloseAgent(UUID agentID) | 3931 | /// <param name="childOnly"></param> |
3932 | public bool IncomingCloseAgent(UUID agentID, bool childOnly) | ||
3887 | { | 3933 | { |
3888 | //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); | 3934 | //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); |
3889 | 3935 | ||
@@ -3895,7 +3941,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3895 | { | 3941 | { |
3896 | m_sceneGraph.removeUserCount(false); | 3942 | m_sceneGraph.removeUserCount(false); |
3897 | } | 3943 | } |
3898 | else | 3944 | else if (!childOnly) |
3899 | { | 3945 | { |
3900 | m_sceneGraph.removeUserCount(true); | 3946 | m_sceneGraph.removeUserCount(true); |
3901 | } | 3947 | } |
@@ -3911,9 +3957,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
3911 | } | 3957 | } |
3912 | else | 3958 | else |
3913 | presence.ControllingClient.SendShutdownConnectionNotice(); | 3959 | presence.ControllingClient.SendShutdownConnectionNotice(); |
3960 | presence.ControllingClient.Close(false); | ||
3961 | } | ||
3962 | else if (!childOnly) | ||
3963 | { | ||
3964 | presence.ControllingClient.Close(true); | ||
3914 | } | 3965 | } |
3915 | |||
3916 | presence.ControllingClient.Close(); | ||
3917 | return true; | 3966 | return true; |
3918 | } | 3967 | } |
3919 | 3968 | ||
@@ -3922,30 +3971,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3922 | } | 3971 | } |
3923 | 3972 | ||
3924 | /// <summary> | 3973 | /// <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. | 3974 | /// Tries to teleport agent to other region. |
3950 | /// </summary> | 3975 | /// </summary> |
3951 | /// <param name="remoteClient"></param> | 3976 | /// <param name="remoteClient"></param> |
@@ -3978,9 +4003,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3978 | public void RequestTeleportLocation(IClientAPI remoteClient, ulong regionHandle, Vector3 position, | 4003 | public void RequestTeleportLocation(IClientAPI remoteClient, ulong regionHandle, Vector3 position, |
3979 | Vector3 lookAt, uint teleportFlags) | 4004 | Vector3 lookAt, uint teleportFlags) |
3980 | { | 4005 | { |
3981 | ScenePresence sp; | 4006 | ScenePresence sp = GetScenePresence(remoteClient.AgentId); |
3982 | m_sceneGraph.TryGetAvatar(remoteClient.AgentId, out sp); | ||
3983 | |||
3984 | if (sp != null) | 4007 | if (sp != null) |
3985 | { | 4008 | { |
3986 | uint regionX = m_regInfo.RegionLocX; | 4009 | uint regionX = m_regInfo.RegionLocX; |
@@ -4020,16 +4043,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
4020 | } | 4043 | } |
4021 | 4044 | ||
4022 | if (m_teleportModule != null) | 4045 | if (m_teleportModule != null) |
4023 | { | 4046 | m_teleportModule.Teleport(sp, regionHandle, position, lookAt, teleportFlags); |
4024 | m_teleportModule.RequestTeleportToLocation(sp, regionHandle, | ||
4025 | position, lookAt, teleportFlags); | ||
4026 | } | ||
4027 | else | 4047 | else |
4028 | { | 4048 | { |
4029 | m_sceneGridService.RequestTeleportToLocation(sp, regionHandle, | 4049 | m_log.DebugFormat("[SCENE]: Unable to perform teleports: no AgentTransferModule is active"); |
4030 | position, lookAt, teleportFlags); | 4050 | sp.ControllingClient.SendTeleportFailed("Unable to perform teleports on this simulator."); |
4031 | } | 4051 | } |
4032 | |||
4033 | } | 4052 | } |
4034 | } | 4053 | } |
4035 | 4054 | ||
@@ -4055,7 +4074,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
4055 | 4074 | ||
4056 | public void CrossAgentToNewRegion(ScenePresence agent, bool isFlying) | 4075 | public void CrossAgentToNewRegion(ScenePresence agent, bool isFlying) |
4057 | { | 4076 | { |
4058 | m_sceneGridService.CrossAgentToNewRegion(this, agent, isFlying); | 4077 | if (m_teleportModule != null) |
4078 | m_teleportModule.Cross(agent, isFlying); | ||
4079 | else | ||
4080 | { | ||
4081 | m_log.DebugFormat("[SCENE]: Unable to cross agent to neighbouring region, because there is no AgentTransferModule"); | ||
4082 | } | ||
4059 | } | 4083 | } |
4060 | 4084 | ||
4061 | public void SendOutChildAgentUpdates(AgentPosition cadu, ScenePresence presence) | 4085 | public void SendOutChildAgentUpdates(AgentPosition cadu, ScenePresence presence) |
@@ -4081,35 +4105,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
4081 | objectCapacity = objects; | 4105 | objectCapacity = objects; |
4082 | } | 4106 | } |
4083 | 4107 | ||
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 | 4108 | #endregion |
4114 | 4109 | ||
4115 | public void HandleObjectPermissionsUpdate(IClientAPI controller, UUID agentID, UUID sessionID, byte field, uint localId, uint mask, byte set) | 4110 | public void HandleObjectPermissionsUpdate(IClientAPI controller, UUID agentID, UUID sessionID, byte field, uint localId, uint mask, byte set) |
@@ -4187,17 +4182,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", | 4182 | 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"); | 4183 | "Agent ID", "Session ID", "Circuit", "IP", "World"); |
4189 | 4184 | ||
4190 | foreach (ScenePresence scenePresence in GetAvatars()) | 4185 | ForEachScenePresence(delegate(ScenePresence sp) |
4191 | { | 4186 | { |
4192 | m_log.ErrorFormat("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16},{5,-16}{6,-16}", | 4187 | m_log.ErrorFormat("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16},{5,-16}{6,-16}", |
4193 | scenePresence.Firstname, | 4188 | sp.Firstname, |
4194 | scenePresence.Lastname, | 4189 | sp.Lastname, |
4195 | scenePresence.UUID, | 4190 | sp.UUID, |
4196 | scenePresence.ControllingClient.AgentId, | 4191 | sp.ControllingClient.AgentId, |
4197 | "Unknown", | 4192 | "Unknown", |
4198 | "Unknown", | 4193 | "Unknown", |
4199 | RegionInfo.RegionName); | 4194 | RegionInfo.RegionName); |
4200 | } | 4195 | }); |
4201 | 4196 | ||
4202 | break; | 4197 | break; |
4203 | } | 4198 | } |
@@ -4363,56 +4358,45 @@ namespace OpenSim.Region.Framework.Scenes | |||
4363 | m_sceneGraph.RemovePhysicalPrim(num); | 4358 | m_sceneGraph.RemovePhysicalPrim(num); |
4364 | } | 4359 | } |
4365 | 4360 | ||
4366 | //The idea is to have a group of method that return a list of avatars meeting some requirement | 4361 | 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 | { | 4362 | { |
4376 | return m_sceneGraph.GetAvatars(); | 4363 | return m_sceneGraph.GetRootAgentCount(); |
4377 | } | 4364 | } |
4378 | 4365 | ||
4379 | /// <summary> | 4366 | 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 | { | 4367 | { |
4384 | return m_sceneGraph.GetRootAgentCount(); | 4368 | return m_sceneGraph.GetChildAgentCount(); |
4385 | } | 4369 | } |
4386 | 4370 | ||
4387 | /// <summary> | 4371 | /// <summary> |
4388 | /// Return a list of all ScenePresences in this region. This returns child agents as well as root agents. | 4372 | /// 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> | 4373 | /// </summary> |
4391 | /// <returns></returns> | 4374 | /// <param name="agentID"></param> |
4392 | public ScenePresence[] GetScenePresences() | 4375 | /// <returns>null if the presence was not found</returns> |
4376 | public ScenePresence GetScenePresence(UUID agentID) | ||
4393 | { | 4377 | { |
4394 | return m_sceneGraph.GetScenePresences(); | 4378 | return m_sceneGraph.GetScenePresence(agentID); |
4395 | } | 4379 | } |
4396 | 4380 | ||
4397 | /// <summary> | 4381 | /// <summary> |
4398 | /// Request a filtered list of ScenePresences in this region. | 4382 | /// Request the scene presence by name. |
4399 | /// This list is a new object, so it can be iterated over without locking. | ||
4400 | /// </summary> | 4383 | /// </summary> |
4401 | /// <param name="filter"></param> | 4384 | /// <param name="firstName"></param> |
4402 | /// <returns></returns> | 4385 | /// <param name="lastName"></param> |
4403 | public List<ScenePresence> GetScenePresences(FilterAvatarList filter) | 4386 | /// <returns>null if the presence was not found</returns> |
4387 | public ScenePresence GetScenePresence(string firstName, string lastName) | ||
4404 | { | 4388 | { |
4405 | return m_sceneGraph.GetScenePresences(filter); | 4389 | return m_sceneGraph.GetScenePresence(firstName, lastName); |
4406 | } | 4390 | } |
4407 | 4391 | ||
4408 | /// <summary> | 4392 | /// <summary> |
4409 | /// Request a scene presence by UUID | 4393 | /// Request the scene presence by localID. |
4410 | /// </summary> | 4394 | /// </summary> |
4411 | /// <param name="avatarID"></param> | 4395 | /// <param name="localID"></param> |
4412 | /// <returns></returns> | 4396 | /// <returns>null if the presence was not found</returns> |
4413 | public ScenePresence GetScenePresence(UUID avatarID) | 4397 | public ScenePresence GetScenePresence(uint localID) |
4414 | { | 4398 | { |
4415 | return m_sceneGraph.GetScenePresence(avatarID); | 4399 | return m_sceneGraph.GetScenePresence(localID); |
4416 | } | 4400 | } |
4417 | 4401 | ||
4418 | public override bool PresenceChildStatus(UUID avatarID) | 4402 | public override bool PresenceChildStatus(UUID avatarID) |
@@ -4430,25 +4414,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
4430 | } | 4414 | } |
4431 | 4415 | ||
4432 | /// <summary> | 4416 | /// <summary> |
4433 | /// | 4417 | /// Performs action on all scene presences. |
4434 | /// </summary> | 4418 | /// </summary> |
4435 | /// <param name="action"></param> | 4419 | /// <param name="action"></param> |
4436 | public void ForEachScenePresence(Action<ScenePresence> action) | 4420 | public void ForEachScenePresence(Action<ScenePresence> action) |
4437 | { | 4421 | { |
4438 | // We don't want to try to send messages if there are no avatars. | ||
4439 | if (m_sceneGraph != null) | 4422 | if (m_sceneGraph != null) |
4440 | { | 4423 | { |
4441 | try | 4424 | 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 | } | 4425 | } |
4453 | } | 4426 | } |
4454 | 4427 | ||
@@ -4512,9 +4485,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
4512 | return m_sceneGraph.GetGroupByPrim(localID); | 4485 | return m_sceneGraph.GetGroupByPrim(localID); |
4513 | } | 4486 | } |
4514 | 4487 | ||
4515 | public bool TryGetAvatar(UUID avatarId, out ScenePresence avatar) | 4488 | public override bool TryGetScenePresence(UUID avatarId, out ScenePresence avatar) |
4516 | { | 4489 | { |
4517 | return m_sceneGraph.TryGetAvatar(avatarId, out avatar); | 4490 | return m_sceneGraph.TryGetScenePresence(avatarId, out avatar); |
4518 | } | 4491 | } |
4519 | 4492 | ||
4520 | public bool TryGetAvatarByName(string avatarName, out ScenePresence avatar) | 4493 | public bool TryGetAvatarByName(string avatarName, out ScenePresence avatar) |
@@ -4524,20 +4497,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4524 | 4497 | ||
4525 | public void ForEachClient(Action<IClientAPI> action) | 4498 | public void ForEachClient(Action<IClientAPI> action) |
4526 | { | 4499 | { |
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); | 4500 | m_clientManager.ForEachSync(action); |
4536 | |||
4537 | //if (doAsynchronous) | ||
4538 | // m_clientManager.ForEach(action); | ||
4539 | //else | ||
4540 | // m_clientManager.ForEachSync(action); | ||
4541 | } | 4501 | } |
4542 | 4502 | ||
4543 | public bool TryGetClient(UUID avatarID, out IClientAPI client) | 4503 | public bool TryGetClient(UUID avatarID, out IClientAPI client) |
@@ -4664,6 +4624,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4664 | foreach (SceneObjectPart child in partList) | 4624 | foreach (SceneObjectPart child in partList) |
4665 | { | 4625 | { |
4666 | child.Inventory.ChangeInventoryOwner(remoteClient.AgentId); | 4626 | child.Inventory.ChangeInventoryOwner(remoteClient.AgentId); |
4627 | child.TriggerScriptChangedEvent(Changed.OWNER); | ||
4667 | child.ApplyNextOwnerPermissions(); | 4628 | child.ApplyNextOwnerPermissions(); |
4668 | } | 4629 | } |
4669 | } | 4630 | } |
@@ -4673,6 +4634,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
4673 | 4634 | ||
4674 | group.HasGroupChanged = true; | 4635 | group.HasGroupChanged = true; |
4675 | part.GetProperties(remoteClient); | 4636 | part.GetProperties(remoteClient); |
4637 | part.TriggerScriptChangedEvent(Changed.OWNER); | ||
4638 | group.ResumeScripts(); | ||
4676 | part.ScheduleFullUpdate(); | 4639 | part.ScheduleFullUpdate(); |
4677 | 4640 | ||
4678 | break; | 4641 | break; |
@@ -4709,7 +4672,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
4709 | group.GetPartName(localID), | 4672 | group.GetPartName(localID), |
4710 | group.GetPartDescription(localID), | 4673 | group.GetPartDescription(localID), |
4711 | (sbyte)AssetType.Object, | 4674 | (sbyte)AssetType.Object, |
4712 | Utils.StringToBytes(sceneObjectXml)); | 4675 | Utils.StringToBytes(sceneObjectXml), |
4676 | group.OwnerID); | ||
4713 | AssetService.Store(asset); | 4677 | AssetService.Store(asset); |
4714 | 4678 | ||
4715 | InventoryItemBase item = new InventoryItemBase(); | 4679 | InventoryItemBase item = new InventoryItemBase(); |
@@ -5033,5 +4997,241 @@ namespace OpenSim.Region.Framework.Scenes | |||
5033 | if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 2000) | 4997 | if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 2000) |
5034 | StartTimer(); | 4998 | StartTimer(); |
5035 | } | 4999 | } |
5000 | |||
5001 | public override ISceneObject DeserializeObject(string representation) | ||
5002 | { | ||
5003 | return SceneObjectSerializer.FromXml2Format(representation); | ||
5004 | } | ||
5005 | |||
5006 | public override bool AllowScriptCrossings | ||
5007 | { | ||
5008 | get { return m_allowScriptCrossings; } | ||
5009 | } | ||
5010 | |||
5011 | public Vector3? GetNearestAllowedPosition(ScenePresence avatar) | ||
5012 | { | ||
5013 | //simulate to make sure we have pretty up to date positions | ||
5014 | PhysicsScene.Simulate(0); | ||
5015 | |||
5016 | ILandObject nearestParcel = GetNearestAllowedParcel(avatar.UUID, avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); | ||
5017 | |||
5018 | if (nearestParcel != null) | ||
5019 | { | ||
5020 | Vector3 dir = Vector3.Normalize(Vector3.Multiply(avatar.Velocity, -1)); | ||
5021 | //Try to get a location that feels like where they came from | ||
5022 | Vector3? nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); | ||
5023 | if (nearestPoint != null) | ||
5024 | { | ||
5025 | Debug.WriteLine("Found a sane previous position based on velocity, sending them to: " + nearestPoint.ToString()); | ||
5026 | return nearestPoint.Value; | ||
5027 | } | ||
5028 | |||
5029 | //Sometimes velocity might be zero (local teleport), so try finding point along path from avatar to center of nearest parcel | ||
5030 | Vector3 directionToParcelCenter = Vector3.Subtract(GetParcelCenterAtGround(nearestParcel), avatar.AbsolutePosition); | ||
5031 | dir = Vector3.Normalize(directionToParcelCenter); | ||
5032 | nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); | ||
5033 | if (nearestPoint != null) | ||
5034 | { | ||
5035 | Debug.WriteLine("They had a zero velocity, sending them to: " + nearestPoint.ToString()); | ||
5036 | return nearestPoint.Value; | ||
5037 | } | ||
5038 | |||
5039 | //Ultimate backup if we have no idea where they are | ||
5040 | Debug.WriteLine("Have no idea where they are, sending them to: " + avatar.lastKnownAllowedPosition.ToString()); | ||
5041 | return avatar.lastKnownAllowedPosition; | ||
5042 | |||
5043 | } | ||
5044 | |||
5045 | //Go to the edge, this happens in teleporting to a region with no available parcels | ||
5046 | Vector3 nearestRegionEdgePoint = GetNearestRegionEdgePosition(avatar); | ||
5047 | //Debug.WriteLine("They are really in a place they don't belong, sending them to: " + nearestRegionEdgePoint.ToString()); | ||
5048 | return nearestRegionEdgePoint; | ||
5049 | return null; | ||
5050 | } | ||
5051 | |||
5052 | private Vector3 GetParcelCenterAtGround(ILandObject parcel) | ||
5053 | { | ||
5054 | Vector2 center = GetParcelCenter(parcel); | ||
5055 | return GetPositionAtGround(center.X, center.Y); | ||
5056 | } | ||
5057 | |||
5058 | private Vector3? GetNearestPointInParcelAlongDirectionFromPoint(Vector3 pos, Vector3 direction, ILandObject parcel) | ||
5059 | { | ||
5060 | Vector3 unitDirection = Vector3.Normalize(direction); | ||
5061 | //Making distance to search go through some sane limit of distance | ||
5062 | for (float distance = 0; distance < Constants.RegionSize * 2; distance += .5f) | ||
5063 | { | ||
5064 | Vector3 testPos = Vector3.Add(pos, Vector3.Multiply(unitDirection, distance)); | ||
5065 | if (parcel.ContainsPoint((int)testPos.X, (int)testPos.Y)) | ||
5066 | { | ||
5067 | return testPos; | ||
5068 | } | ||
5069 | } | ||
5070 | return null; | ||
5071 | } | ||
5072 | |||
5073 | public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y) | ||
5074 | { | ||
5075 | List<ILandObject> all = AllParcels(); | ||
5076 | float minParcelDistance = float.MaxValue; | ||
5077 | ILandObject nearestParcel = null; | ||
5078 | |||
5079 | foreach (var parcel in all) | ||
5080 | { | ||
5081 | if (!parcel.IsEitherBannedOrRestricted(avatarId)) | ||
5082 | { | ||
5083 | float parcelDistance = GetParcelDistancefromPoint(parcel, x, y); | ||
5084 | if (parcelDistance < minParcelDistance) | ||
5085 | { | ||
5086 | minParcelDistance = parcelDistance; | ||
5087 | nearestParcel = parcel; | ||
5088 | } | ||
5089 | } | ||
5090 | } | ||
5091 | |||
5092 | return nearestParcel; | ||
5093 | } | ||
5094 | |||
5095 | private List<ILandObject> AllParcels() | ||
5096 | { | ||
5097 | return LandChannel.AllParcels(); | ||
5098 | } | ||
5099 | |||
5100 | private float GetParcelDistancefromPoint(ILandObject parcel, float x, float y) | ||
5101 | { | ||
5102 | return Vector2.Distance(new Vector2(x, y), GetParcelCenter(parcel)); | ||
5103 | } | ||
5104 | |||
5105 | //calculate the average center point of a parcel | ||
5106 | private Vector2 GetParcelCenter(ILandObject parcel) | ||
5107 | { | ||
5108 | int count = 0; | ||
5109 | int avgx = 0; | ||
5110 | int avgy = 0; | ||
5111 | for (int x = 0; x < Constants.RegionSize; x++) | ||
5112 | { | ||
5113 | for (int y = 0; y < Constants.RegionSize; y++) | ||
5114 | { | ||
5115 | //Just keep a running average as we check if all the points are inside or not | ||
5116 | if (parcel.ContainsPoint(x, y)) | ||
5117 | { | ||
5118 | if (count == 0) | ||
5119 | { | ||
5120 | avgx = x; | ||
5121 | avgy = y; | ||
5122 | } | ||
5123 | else | ||
5124 | { | ||
5125 | avgx = (avgx * count + x) / (count + 1); | ||
5126 | avgy = (avgy * count + y) / (count + 1); | ||
5127 | } | ||
5128 | count += 1; | ||
5129 | } | ||
5130 | } | ||
5131 | } | ||
5132 | return new Vector2(avgx, avgy); | ||
5133 | } | ||
5134 | |||
5135 | private Vector3 GetNearestRegionEdgePosition(ScenePresence avatar) | ||
5136 | { | ||
5137 | float xdistance = avatar.AbsolutePosition.X < Constants.RegionSize / 2 ? avatar.AbsolutePosition.X : Constants.RegionSize - avatar.AbsolutePosition.X; | ||
5138 | float ydistance = avatar.AbsolutePosition.Y < Constants.RegionSize / 2 ? avatar.AbsolutePosition.Y : Constants.RegionSize - avatar.AbsolutePosition.Y; | ||
5139 | |||
5140 | //find out what vertical edge to go to | ||
5141 | if (xdistance < ydistance) | ||
5142 | { | ||
5143 | if (avatar.AbsolutePosition.X < Constants.RegionSize / 2) | ||
5144 | { | ||
5145 | return GetPositionAtAvatarHeightOrGroundHeight(avatar, 0.0f, avatar.AbsolutePosition.Y); | ||
5146 | } | ||
5147 | else | ||
5148 | { | ||
5149 | return GetPositionAtAvatarHeightOrGroundHeight(avatar, Constants.RegionSize, avatar.AbsolutePosition.Y); | ||
5150 | } | ||
5151 | } | ||
5152 | //find out what horizontal edge to go to | ||
5153 | else | ||
5154 | { | ||
5155 | if (avatar.AbsolutePosition.Y < Constants.RegionSize / 2) | ||
5156 | { | ||
5157 | return GetPositionAtAvatarHeightOrGroundHeight(avatar, avatar.AbsolutePosition.X, 0.0f); | ||
5158 | } | ||
5159 | else | ||
5160 | { | ||
5161 | return GetPositionAtAvatarHeightOrGroundHeight(avatar, avatar.AbsolutePosition.X, Constants.RegionSize); | ||
5162 | } | ||
5163 | } | ||
5164 | } | ||
5165 | |||
5166 | private Vector3 GetPositionAtAvatarHeightOrGroundHeight(ScenePresence avatar, float x, float y) | ||
5167 | { | ||
5168 | Vector3 ground = GetPositionAtGround(x, y); | ||
5169 | if (avatar.AbsolutePosition.Z > ground.Z) | ||
5170 | { | ||
5171 | ground.Z = avatar.AbsolutePosition.Z; | ||
5172 | } | ||
5173 | return ground; | ||
5174 | } | ||
5175 | |||
5176 | private Vector3 GetPositionAtGround(float x, float y) | ||
5177 | { | ||
5178 | return new Vector3(x, y, GetGroundHeight(x, y)); | ||
5179 | } | ||
5180 | |||
5181 | public List<UUID> GetEstateRegions(int estateID) | ||
5182 | { | ||
5183 | if (m_storageManager.EstateDataStore == null) | ||
5184 | return new List<UUID>(); | ||
5185 | |||
5186 | return m_storageManager.EstateDataStore.GetRegions(estateID); | ||
5187 | } | ||
5188 | |||
5189 | public void ReloadEstateData() | ||
5190 | { | ||
5191 | m_regInfo.EstateSettings = m_storageManager.EstateDataStore.LoadEstateSettings(m_regInfo.RegionID, false); | ||
5192 | |||
5193 | TriggerEstateSunUpdate(); | ||
5194 | } | ||
5195 | |||
5196 | public void TriggerEstateSunUpdate() | ||
5197 | { | ||
5198 | float sun; | ||
5199 | if (RegionInfo.RegionSettings.UseEstateSun) | ||
5200 | { | ||
5201 | sun = (float)RegionInfo.EstateSettings.SunPosition; | ||
5202 | if (RegionInfo.EstateSettings.UseGlobalTime) | ||
5203 | { | ||
5204 | sun = EventManager.GetCurrentTimeAsSunLindenHour() - 6.0f; | ||
5205 | } | ||
5206 | |||
5207 | // | ||
5208 | EventManager.TriggerEstateToolsSunUpdate( | ||
5209 | RegionInfo.RegionHandle, | ||
5210 | RegionInfo.EstateSettings.FixedSun, | ||
5211 | RegionInfo.RegionSettings.UseEstateSun, | ||
5212 | sun); | ||
5213 | } | ||
5214 | else | ||
5215 | { | ||
5216 | // Use the Sun Position from the Region Settings | ||
5217 | sun = (float)RegionInfo.RegionSettings.SunPosition - 6.0f; | ||
5218 | |||
5219 | EventManager.TriggerEstateToolsSunUpdate( | ||
5220 | RegionInfo.RegionHandle, | ||
5221 | RegionInfo.RegionSettings.FixedSun, | ||
5222 | RegionInfo.RegionSettings.UseEstateSun, | ||
5223 | sun); | ||
5224 | } | ||
5225 | } | ||
5226 | |||
5227 | private void HandleReloadEstate(string module, string[] cmd) | ||
5228 | { | ||
5229 | if (MainConsole.Instance.ConsoleScene == null || | ||
5230 | (MainConsole.Instance.ConsoleScene is Scene && | ||
5231 | (Scene)MainConsole.Instance.ConsoleScene == this)) | ||
5232 | { | ||
5233 | ReloadEstateData(); | ||
5234 | } | ||
5235 | } | ||
5036 | } | 5236 | } |
5037 | } | 5237 | } |
diff --git a/OpenSim/Region/Framework/Scenes/SceneBase.cs b/OpenSim/Region/Framework/Scenes/SceneBase.cs index 5e798c0..bfc19b7 100644 --- a/OpenSim/Region/Framework/Scenes/SceneBase.cs +++ b/OpenSim/Region/Framework/Scenes/SceneBase.cs | |||
@@ -34,7 +34,7 @@ using log4net; | |||
34 | using Nini.Config; | 34 | using Nini.Config; |
35 | using OpenSim.Framework; | 35 | using OpenSim.Framework; |
36 | using OpenSim.Framework.Console; | 36 | using OpenSim.Framework.Console; |
37 | using OpenSim.Framework.Communications.Cache; | 37 | |
38 | using OpenSim.Region.Framework.Interfaces; | 38 | using OpenSim.Region.Framework.Interfaces; |
39 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | 39 | using 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,17 @@ 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 | |||
539 | public abstract bool CheckClient(UUID agentID, System.Net.IPEndPoint ep); | ||
513 | } | 540 | } |
514 | } | 541 | } |
diff --git a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs index 04626d3..6309cd9 100644 --- a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs +++ b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs | |||
@@ -36,7 +36,6 @@ using log4net; | |||
36 | using OpenSim.Framework; | 36 | using OpenSim.Framework; |
37 | using OpenSim.Framework.Client; | 37 | using OpenSim.Framework.Client; |
38 | using OpenSim.Framework.Communications; | 38 | using OpenSim.Framework.Communications; |
39 | using OpenSim.Framework.Communications.Cache; | ||
40 | using OpenSim.Framework.Capabilities; | 39 | using OpenSim.Framework.Capabilities; |
41 | using OpenSim.Region.Framework.Interfaces; | 40 | using OpenSim.Region.Framework.Interfaces; |
42 | using OpenSim.Services.Interfaces; | 41 | using 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.CloseChildAgent(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 090f379..c16ba12 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs | |||
@@ -35,6 +35,7 @@ using log4net; | |||
35 | using OpenSim.Framework; | 35 | using OpenSim.Framework; |
36 | using OpenSim.Region.Framework.Scenes.Types; | 36 | using OpenSim.Region.Framework.Scenes.Types; |
37 | using OpenSim.Region.Physics.Manager; | 37 | using OpenSim.Region.Physics.Manager; |
38 | using OpenSim.Region.Framework.Interfaces; | ||
38 | 39 | ||
39 | namespace OpenSim.Region.Framework.Scenes | 40 | namespace OpenSim.Region.Framework.Scenes |
40 | { | 41 | { |
@@ -69,6 +70,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
69 | 70 | ||
70 | protected Dictionary<UUID, ScenePresence> m_scenePresences = new Dictionary<UUID, ScenePresence>(); | 71 | protected Dictionary<UUID, ScenePresence> m_scenePresences = new Dictionary<UUID, ScenePresence>(); |
71 | protected ScenePresence[] m_scenePresenceArray = new ScenePresence[0]; | 72 | protected ScenePresence[] m_scenePresenceArray = new ScenePresence[0]; |
73 | protected List<ScenePresence> m_scenePresenceList = new List<ScenePresence>(); | ||
74 | |||
75 | protected OpenMetaverse.ReaderWriterLockSlim m_scenePresencesLock = new OpenMetaverse.ReaderWriterLockSlim(); | ||
72 | 76 | ||
73 | // SceneObjects is not currently populated or used. | 77 | // SceneObjects is not currently populated or used. |
74 | //public Dictionary<UUID, SceneObjectGroup> SceneObjects; | 78 | //public Dictionary<UUID, SceneObjectGroup> SceneObjects; |
@@ -131,10 +135,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
131 | 135 | ||
132 | protected internal void Close() | 136 | protected internal void Close() |
133 | { | 137 | { |
134 | lock (m_scenePresences) | 138 | m_scenePresencesLock.EnterWriteLock(); |
139 | try | ||
135 | { | 140 | { |
136 | m_scenePresences.Clear(); | 141 | m_scenePresences.Clear(); |
137 | m_scenePresenceArray = new ScenePresence[0]; | 142 | m_scenePresenceArray = new ScenePresence[0]; |
143 | m_scenePresenceList = new List<ScenePresence>(); | ||
144 | } | ||
145 | finally | ||
146 | { | ||
147 | m_scenePresencesLock.ExitWriteLock(); | ||
138 | } | 148 | } |
139 | 149 | ||
140 | lock (m_dictionary_lock) | 150 | lock (m_dictionary_lock) |
@@ -164,9 +174,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
164 | 174 | ||
165 | protected internal void UpdatePresences() | 175 | protected internal void UpdatePresences() |
166 | { | 176 | { |
167 | ScenePresence[] updateScenePresences = GetScenePresences(); | 177 | ForEachScenePresence(delegate(ScenePresence presence) |
168 | for (int i = 0; i < updateScenePresences.Length; i++) | 178 | { |
169 | updateScenePresences[i].Update(); | 179 | presence.Update(); |
180 | }); | ||
170 | } | 181 | } |
171 | 182 | ||
172 | protected internal float UpdatePhysics(double elapsed) | 183 | protected internal float UpdatePhysics(double elapsed) |
@@ -195,9 +206,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
195 | 206 | ||
196 | protected internal void UpdateScenePresenceMovement() | 207 | protected internal void UpdateScenePresenceMovement() |
197 | { | 208 | { |
198 | ScenePresence[] moveEntities = GetScenePresences(); | 209 | ForEachScenePresence(delegate(ScenePresence presence) |
199 | for (int i = 0; i < moveEntities.Length; i++) | 210 | { |
200 | moveEntities[i].UpdateMovement(); | 211 | presence.UpdateMovement(); |
212 | }); | ||
201 | } | 213 | } |
202 | 214 | ||
203 | #endregion | 215 | #endregion |
@@ -464,9 +476,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
464 | { | 476 | { |
465 | SceneObjectGroup group = GetGroupByPrim(objectLocalID); | 477 | SceneObjectGroup group = GetGroupByPrim(objectLocalID); |
466 | if (group != null) | 478 | if (group != null) |
467 | { | 479 | m_parentScene.AttachmentsModule.DetachSingleAttachmentToGround(group.UUID, remoteClient); |
468 | m_parentScene.DetachSingleAttachmentToGround(group.UUID, remoteClient); | ||
469 | } | ||
470 | } | 480 | } |
471 | 481 | ||
472 | protected internal void DetachObject(uint objectLocalID, IClientAPI remoteClient) | 482 | protected internal void DetachObject(uint objectLocalID, IClientAPI remoteClient) |
@@ -475,7 +485,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
475 | if (group != null) | 485 | if (group != null) |
476 | { | 486 | { |
477 | //group.DetachToGround(); | 487 | //group.DetachToGround(); |
478 | m_parentScene.DetachSingleAttachmentToInv(group.GetFromItemID(), remoteClient); | 488 | m_parentScene.AttachmentsModule.ShowDetachInUserInventory(group.GetFromItemID(), remoteClient); |
479 | } | 489 | } |
480 | } | 490 | } |
481 | 491 | ||
@@ -509,212 +519,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
509 | } | 519 | } |
510 | } | 520 | } |
511 | 521 | ||
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) | 522 | protected internal ScenePresence CreateAndAddChildScenePresence(IClientAPI client, AvatarAppearance appearance) |
719 | { | 523 | { |
720 | ScenePresence newAvatar = null; | 524 | ScenePresence newAvatar = null; |
@@ -747,7 +551,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
747 | 551 | ||
748 | Entities[presence.UUID] = presence; | 552 | Entities[presence.UUID] = presence; |
749 | 553 | ||
750 | lock (m_scenePresences) | 554 | m_scenePresencesLock.EnterWriteLock(); |
555 | try | ||
751 | { | 556 | { |
752 | if (!m_scenePresences.ContainsKey(presence.UUID)) | 557 | if (!m_scenePresences.ContainsKey(presence.UUID)) |
753 | { | 558 | { |
@@ -759,11 +564,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
759 | Array.Copy(m_scenePresenceArray, newArray, oldLength); | 564 | Array.Copy(m_scenePresenceArray, newArray, oldLength); |
760 | newArray[oldLength] = presence; | 565 | newArray[oldLength] = presence; |
761 | m_scenePresenceArray = newArray; | 566 | m_scenePresenceArray = newArray; |
567 | m_scenePresenceList = new List<ScenePresence>(m_scenePresenceArray); | ||
762 | } | 568 | } |
763 | else | 569 | else |
764 | { | 570 | { |
765 | m_scenePresences[presence.UUID] = presence; | 571 | m_scenePresences[presence.UUID] = presence; |
766 | 572 | ||
767 | // Do a linear search through the array of ScenePresence references | 573 | // Do a linear search through the array of ScenePresence references |
768 | // and update the modified entry | 574 | // and update the modified entry |
769 | for (int i = 0; i < m_scenePresenceArray.Length; i++) | 575 | for (int i = 0; i < m_scenePresenceArray.Length; i++) |
@@ -774,8 +580,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
774 | break; | 580 | break; |
775 | } | 581 | } |
776 | } | 582 | } |
583 | m_scenePresenceList = new List<ScenePresence>(m_scenePresenceArray); | ||
777 | } | 584 | } |
778 | } | 585 | } |
586 | finally | ||
587 | { | ||
588 | m_scenePresencesLock.ExitWriteLock(); | ||
589 | } | ||
779 | } | 590 | } |
780 | 591 | ||
781 | /// <summary> | 592 | /// <summary> |
@@ -790,7 +601,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
790 | agentID); | 601 | agentID); |
791 | } | 602 | } |
792 | 603 | ||
793 | lock (m_scenePresences) | 604 | m_scenePresencesLock.EnterWriteLock(); |
605 | try | ||
794 | { | 606 | { |
795 | if (m_scenePresences.Remove(agentID)) | 607 | if (m_scenePresences.Remove(agentID)) |
796 | { | 608 | { |
@@ -809,12 +621,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
809 | } | 621 | } |
810 | } | 622 | } |
811 | m_scenePresenceArray = newArray; | 623 | m_scenePresenceArray = newArray; |
624 | m_scenePresenceList = new List<ScenePresence>(m_scenePresenceArray); | ||
812 | } | 625 | } |
813 | else | 626 | else |
814 | { | 627 | { |
815 | m_log.WarnFormat("[SCENE] Tried to remove non-existent scene presence with agent ID {0} from scene ScenePresences list", agentID); | 628 | m_log.WarnFormat("[SCENE] Tried to remove non-existent scene presence with agent ID {0} from scene ScenePresences list", agentID); |
816 | } | 629 | } |
817 | } | 630 | } |
631 | finally | ||
632 | { | ||
633 | m_scenePresencesLock.ExitWriteLock(); | ||
634 | } | ||
818 | } | 635 | } |
819 | 636 | ||
820 | protected internal void SwapRootChildAgent(bool direction_RC_CR_T_F) | 637 | protected internal void SwapRootChildAgent(bool direction_RC_CR_T_F) |
@@ -845,18 +662,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
845 | 662 | ||
846 | public void RecalculateStats() | 663 | public void RecalculateStats() |
847 | { | 664 | { |
848 | ScenePresence[] presences = GetScenePresences(); | ||
849 | int rootcount = 0; | 665 | int rootcount = 0; |
850 | int childcount = 0; | 666 | int childcount = 0; |
851 | 667 | ||
852 | for (int i = 0; i < presences.Length; i++) | 668 | ForEachScenePresence(delegate(ScenePresence presence) |
853 | { | 669 | { |
854 | ScenePresence user = presences[i]; | 670 | if (presence.IsChildAgent) |
855 | if (user.IsChildAgent) | ||
856 | ++childcount; | 671 | ++childcount; |
857 | else | 672 | else |
858 | ++rootcount; | 673 | ++rootcount; |
859 | } | 674 | }); |
860 | 675 | ||
861 | m_numRootAgents = rootcount; | 676 | m_numRootAgents = rootcount; |
862 | m_numChildAgents = childcount; | 677 | m_numChildAgents = childcount; |
@@ -903,25 +718,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
903 | #endregion | 718 | #endregion |
904 | 719 | ||
905 | #region Get Methods | 720 | #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> | 721 | /// <summary> |
926 | /// Get the controlling client for the given avatar, if there is one. | 722 | /// Get the controlling client for the given avatar, if there is one. |
927 | /// | 723 | /// |
@@ -948,44 +744,103 @@ namespace OpenSim.Region.Framework.Scenes | |||
948 | } | 744 | } |
949 | 745 | ||
950 | /// <summary> | 746 | /// <summary> |
951 | /// Request a filtered list of m_scenePresences in this World | 747 | /// Request a copy of m_scenePresences in this World |
748 | /// There is no guarantee that presences will remain in the scene after the list is returned. | ||
749 | /// This list should remain private to SceneGraph. Callers wishing to iterate should instead | ||
750 | /// pass a delegate to ForEachScenePresence. | ||
952 | /// </summary> | 751 | /// </summary> |
953 | /// <returns></returns> | 752 | /// <returns></returns> |
954 | protected internal List<ScenePresence> GetScenePresences(FilterAvatarList filter) | 753 | private List<ScenePresence> GetScenePresences() |
955 | { | 754 | { |
956 | // No locking of scene presences here since we're passing back a list... | 755 | m_scenePresencesLock.EnterReadLock(); |
957 | 756 | try | |
958 | List<ScenePresence> result = new List<ScenePresence>(); | ||
959 | ScenePresence[] scenePresences = GetScenePresences(); | ||
960 | |||
961 | for (int i = 0; i < scenePresences.Length; i++) | ||
962 | { | 757 | { |
963 | ScenePresence avatar = scenePresences[i]; | 758 | return m_scenePresenceList; |
964 | if (filter(avatar)) | 759 | } |
965 | result.Add(avatar); | 760 | finally |
761 | { | ||
762 | m_scenePresencesLock.ExitReadLock(); | ||
966 | } | 763 | } |
967 | |||
968 | return result; | ||
969 | } | 764 | } |
970 | 765 | ||
971 | /// <summary> | 766 | /// <summary> |
972 | /// Request a scene presence by UUID | 767 | /// Request a scene presence by UUID. Fast, indexed lookup. |
973 | /// </summary> | 768 | /// </summary> |
974 | /// <param name="avatarID"></param> | 769 | /// <param name="agentID"></param> |
975 | /// <returns>null if the agent was not found</returns> | 770 | /// <returns>null if the presence was not found</returns> |
976 | protected internal ScenePresence GetScenePresence(UUID agentID) | 771 | protected internal ScenePresence GetScenePresence(UUID agentID) |
977 | { | 772 | { |
978 | ScenePresence sp; | 773 | ScenePresence sp; |
979 | 774 | m_scenePresencesLock.EnterReadLock(); | |
980 | lock (m_scenePresences) | 775 | try |
981 | { | 776 | { |
982 | m_scenePresences.TryGetValue(agentID, out sp); | 777 | m_scenePresences.TryGetValue(agentID, out sp); |
983 | } | 778 | } |
984 | 779 | finally | |
780 | { | ||
781 | m_scenePresencesLock.ExitReadLock(); | ||
782 | } | ||
985 | return sp; | 783 | return sp; |
986 | } | 784 | } |
987 | 785 | ||
988 | /// <summary> | 786 | /// <summary> |
787 | /// Request the scene presence by name. | ||
788 | /// </summary> | ||
789 | /// <param name="firstName"></param> | ||
790 | /// <param name="lastName"></param> | ||
791 | /// <returns>null if the presence was not found</returns> | ||
792 | protected internal ScenePresence GetScenePresence(string firstName, string lastName) | ||
793 | { | ||
794 | foreach (ScenePresence presence in GetScenePresences()) | ||
795 | { | ||
796 | if (presence.Firstname == firstName && presence.Lastname == lastName) | ||
797 | return presence; | ||
798 | } | ||
799 | return null; | ||
800 | } | ||
801 | |||
802 | /// <summary> | ||
803 | /// Request the scene presence by localID. | ||
804 | /// </summary> | ||
805 | /// <param name="localID"></param> | ||
806 | /// <returns>null if the presence was not found</returns> | ||
807 | protected internal ScenePresence GetScenePresence(uint localID) | ||
808 | { | ||
809 | foreach (ScenePresence presence in GetScenePresences()) | ||
810 | if (presence.LocalId == localID) | ||
811 | return presence; | ||
812 | return null; | ||
813 | } | ||
814 | |||
815 | protected internal bool TryGetScenePresence(UUID agentID, out ScenePresence avatar) | ||
816 | { | ||
817 | m_scenePresencesLock.EnterReadLock(); | ||
818 | try | ||
819 | { | ||
820 | m_scenePresences.TryGetValue(agentID, out avatar); | ||
821 | } | ||
822 | finally | ||
823 | { | ||
824 | m_scenePresencesLock.ExitReadLock(); | ||
825 | } | ||
826 | return (avatar != null); | ||
827 | } | ||
828 | |||
829 | protected internal bool TryGetAvatarByName(string name, out ScenePresence avatar) | ||
830 | { | ||
831 | avatar = null; | ||
832 | foreach (ScenePresence presence in GetScenePresences()) | ||
833 | { | ||
834 | if (String.Compare(name, presence.ControllingClient.Name, true) == 0) | ||
835 | { | ||
836 | avatar = presence; | ||
837 | break; | ||
838 | } | ||
839 | } | ||
840 | return (avatar != null); | ||
841 | } | ||
842 | |||
843 | /// <summary> | ||
989 | /// Get a scene object group that contains the prim with the given local id | 844 | /// Get a scene object group that contains the prim with the given local id |
990 | /// </summary> | 845 | /// </summary> |
991 | /// <param name="localID"></param> | 846 | /// <param name="localID"></param> |
@@ -1136,34 +991,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1136 | return group.GetChildPart(fullID); | 991 | return group.GetChildPart(fullID); |
1137 | } | 992 | } |
1138 | 993 | ||
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> | 994 | /// <summary> |
1168 | /// Returns a list of the entities in the scene. This is a new list so no locking is required to iterate over | 995 | /// Returns a list of the entities in the scene. This is a new list so no locking is required to iterate over |
1169 | /// it | 996 | /// it |
@@ -1226,6 +1053,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1226 | return UUID.Zero; | 1053 | return UUID.Zero; |
1227 | } | 1054 | } |
1228 | 1055 | ||
1056 | /// <summary> | ||
1057 | /// Performs action on all scene object groups. | ||
1058 | /// </summary> | ||
1059 | /// <param name="action"></param> | ||
1229 | protected internal void ForEachSOG(Action<SceneObjectGroup> action) | 1060 | protected internal void ForEachSOG(Action<SceneObjectGroup> action) |
1230 | { | 1061 | { |
1231 | List<SceneObjectGroup> objlist = new List<SceneObjectGroup>(SceneObjectGroupsByFullID.Values); | 1062 | List<SceneObjectGroup> objlist = new List<SceneObjectGroup>(SceneObjectGroupsByFullID.Values); |
@@ -1242,6 +1073,47 @@ namespace OpenSim.Region.Framework.Scenes | |||
1242 | } | 1073 | } |
1243 | } | 1074 | } |
1244 | } | 1075 | } |
1076 | |||
1077 | |||
1078 | /// <summary> | ||
1079 | /// Performs action on all scene presences. This can ultimately run the actions in parallel but | ||
1080 | /// any delegates passed in will need to implement their own locking on data they reference and | ||
1081 | /// modify outside of the scope of the delegate. | ||
1082 | /// </summary> | ||
1083 | /// <param name="action"></param> | ||
1084 | public void ForEachScenePresence(Action<ScenePresence> action) | ||
1085 | { | ||
1086 | // Once all callers have their delegates configured for parallelism, we can unleash this | ||
1087 | /* | ||
1088 | Action<ScenePresence> protectedAction = new Action<ScenePresence>(delegate(ScenePresence sp) | ||
1089 | { | ||
1090 | try | ||
1091 | { | ||
1092 | action(sp); | ||
1093 | } | ||
1094 | catch (Exception e) | ||
1095 | { | ||
1096 | m_log.Info("[BUG] in " + m_parentScene.RegionInfo.RegionName + ": " + e.ToString()); | ||
1097 | m_log.Info("[BUG] Stack Trace: " + e.StackTrace); | ||
1098 | } | ||
1099 | }); | ||
1100 | Parallel.ForEach<ScenePresence>(GetScenePresences(), protectedAction); | ||
1101 | */ | ||
1102 | // For now, perform actiona serially | ||
1103 | |||
1104 | foreach (ScenePresence sp in GetScenePresences()) | ||
1105 | { | ||
1106 | try | ||
1107 | { | ||
1108 | action(sp); | ||
1109 | } | ||
1110 | catch (Exception e) | ||
1111 | { | ||
1112 | m_log.Info("[BUG] in " + m_parentScene.RegionInfo.RegionName + ": " + e.ToString()); | ||
1113 | m_log.Info("[BUG] Stack Trace: " + e.StackTrace); | ||
1114 | } | ||
1115 | } | ||
1116 | } | ||
1245 | 1117 | ||
1246 | #endregion | 1118 | #endregion |
1247 | 1119 | ||
@@ -1924,6 +1796,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1924 | copy.CreateScriptInstances(0, false, m_parentScene.DefaultScriptEngine, 0); | 1796 | copy.CreateScriptInstances(0, false, m_parentScene.DefaultScriptEngine, 0); |
1925 | copy.HasGroupChanged = true; | 1797 | copy.HasGroupChanged = true; |
1926 | copy.ScheduleGroupForFullUpdate(); | 1798 | copy.ScheduleGroupForFullUpdate(); |
1799 | copy.ResumeScripts(); | ||
1927 | 1800 | ||
1928 | // required for physics to update it's position | 1801 | // required for physics to update it's position |
1929 | copy.AbsolutePosition = copy.AbsolutePosition; | 1802 | copy.AbsolutePosition = copy.AbsolutePosition; |
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.Inventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs index 8b58b3e..1149a20 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs | |||
@@ -171,7 +171,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
171 | item.NextPermissions; | 171 | item.NextPermissions; |
172 | taskItem.NextPermissions = item.NextPermissions; | 172 | taskItem.NextPermissions = item.NextPermissions; |
173 | taskItem.CurrentPermissions |= 8; | 173 | taskItem.CurrentPermissions |= 8; |
174 | } else { | 174 | } |
175 | else | ||
176 | { | ||
175 | taskItem.BasePermissions = item.BasePermissions; | 177 | taskItem.BasePermissions = item.BasePermissions; |
176 | taskItem.CurrentPermissions = item.CurrentPermissions; | 178 | taskItem.CurrentPermissions = item.CurrentPermissions; |
177 | taskItem.CurrentPermissions |= 8; | 179 | taskItem.CurrentPermissions |= 8; |
@@ -412,5 +414,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
412 | scriptModule.SetXMLState(itemID, n.OuterXml); | 414 | scriptModule.SetXMLState(itemID, n.OuterXml); |
413 | } | 415 | } |
414 | } | 416 | } |
417 | |||
418 | public void ResumeScripts() | ||
419 | { | ||
420 | foreach (SceneObjectPart part in m_parts.Values) | ||
421 | { | ||
422 | part.Inventory.ResumeScripts(); | ||
423 | } | ||
424 | } | ||
415 | } | 425 | } |
416 | } | 426 | } |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 13d1d4e..a4b8944 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | |||
@@ -123,7 +123,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
123 | } | 123 | } |
124 | if (m_partsLock.RecursiveWriteCount > 0) | 124 | if (m_partsLock.RecursiveWriteCount > 0) |
125 | { | 125 | { |
126 | m_log.Error("[SceneObjectGroup.m_parts] Recursive read lock requested. This should not happen and means something needs to be fixed."); | 126 | m_log.Error("[SceneObjectGroup.m_parts] Recursive read lock requested (write lock exists on this thread). This should not happen and means something needs to be fixed."); |
127 | m_partsLock.ExitWriteLock(); | 127 | m_partsLock.ExitWriteLock(); |
128 | } | 128 | } |
129 | 129 | ||
@@ -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 | ||
@@ -1040,6 +1041,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1040 | 1041 | ||
1041 | public void SaveScriptedState(XmlTextWriter writer) | 1042 | public void SaveScriptedState(XmlTextWriter writer) |
1042 | { | 1043 | { |
1044 | SaveScriptedState(writer, false); | ||
1045 | } | ||
1046 | |||
1047 | public void SaveScriptedState(XmlTextWriter writer, bool oldIDs) | ||
1048 | { | ||
1043 | XmlDocument doc = new XmlDocument(); | 1049 | XmlDocument doc = new XmlDocument(); |
1044 | Dictionary<UUID,string> states = new Dictionary<UUID,string>(); | 1050 | Dictionary<UUID,string> states = new Dictionary<UUID,string>(); |
1045 | 1051 | ||
@@ -1049,7 +1055,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1049 | foreach (SceneObjectPart part in m_parts.Values) | 1055 | foreach (SceneObjectPart part in m_parts.Values) |
1050 | { | 1056 | { |
1051 | 1057 | ||
1052 | Dictionary<UUID,string> pstates = part.Inventory.GetScriptStates(); | 1058 | Dictionary<UUID,string> pstates = part.Inventory.GetScriptStates(oldIDs); |
1053 | foreach (UUID itemid in pstates.Keys) | 1059 | foreach (UUID itemid in pstates.Keys) |
1054 | { | 1060 | { |
1055 | states.Add(itemid, pstates[itemid]); | 1061 | states.Add(itemid, pstates[itemid]); |
@@ -1411,21 +1417,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
1411 | { | 1417 | { |
1412 | // part.Inventory.RemoveScriptInstances(); | 1418 | // part.Inventory.RemoveScriptInstances(); |
1413 | 1419 | ||
1414 | ScenePresence[] avatars = Scene.GetScenePresences(); | 1420 | Scene.ForEachScenePresence(delegate (ScenePresence sp) |
1415 | for (int i = 0; i < avatars.Length; i++) | ||
1416 | { | 1421 | { |
1417 | if (avatars[i].ParentID == LocalId) | 1422 | if (sp.ParentID == LocalId) |
1418 | { | 1423 | { |
1419 | avatars[i].StandUp(); | 1424 | sp.StandUp(); |
1420 | } | 1425 | } |
1421 | 1426 | ||
1422 | if (!silent) | 1427 | if (!silent) |
1423 | { | 1428 | { |
1424 | part.UpdateFlag = 0; | 1429 | part.UpdateFlag = 0; |
1425 | if (part == m_rootPart) | 1430 | if (part == m_rootPart) |
1426 | avatars[i].ControllingClient.SendKillObject(m_regionHandle, part.LocalId); | 1431 | sp.ControllingClient.SendKillObject(m_regionHandle, part.LocalId); |
1427 | } | 1432 | } |
1428 | } | 1433 | }); |
1429 | 1434 | ||
1430 | } | 1435 | } |
1431 | 1436 | ||
@@ -1647,11 +1652,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1647 | 1652 | ||
1648 | #endregion | 1653 | #endregion |
1649 | 1654 | ||
1650 | #region Client Updating | ||
1651 | |||
1652 | public void SendFullUpdateToClient(IClientAPI remoteClient) | 1655 | public void SendFullUpdateToClient(IClientAPI remoteClient) |
1653 | { | 1656 | { |
1654 | SendPartFullUpdate(remoteClient, RootPart, m_scene.Permissions.GenerateClientFlags(remoteClient.AgentId, RootPart.UUID)); | 1657 | RootPart.SendFullUpdate( |
1658 | remoteClient, m_scene.Permissions.GenerateClientFlags(remoteClient.AgentId, RootPart.UUID)); | ||
1655 | 1659 | ||
1656 | lockPartsForRead(true); | 1660 | lockPartsForRead(true); |
1657 | { | 1661 | { |
@@ -1659,42 +1663,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
1659 | { | 1663 | { |
1660 | 1664 | ||
1661 | if (part != RootPart) | 1665 | if (part != RootPart) |
1662 | SendPartFullUpdate(remoteClient, part, m_scene.Permissions.GenerateClientFlags(remoteClient.AgentId, part.UUID)); | 1666 | part.SendFullUpdate( |
1663 | 1667 | remoteClient, m_scene.Permissions.GenerateClientFlags(remoteClient.AgentId, part.UUID)); | |
1664 | } | 1668 | } |
1665 | } | 1669 | } |
1666 | lockPartsForRead(false); | 1670 | lockPartsForRead(false); |
1667 | } | 1671 | } |
1668 | 1672 | ||
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 | } | ||
1689 | } | ||
1690 | else | ||
1691 | { | ||
1692 | part.SendFullUpdateToClient(remoteClient, clientFlags); | ||
1693 | } | ||
1694 | } | ||
1695 | |||
1696 | #endregion | ||
1697 | |||
1698 | #region Copying | 1673 | #region Copying |
1699 | 1674 | ||
1700 | /// <summary> | 1675 | /// <summary> |
@@ -2206,14 +2181,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2206 | public void ScheduleTerseUpdateToAvatar(ScenePresence presence) | 2181 | public void ScheduleTerseUpdateToAvatar(ScenePresence presence) |
2207 | { | 2182 | { |
2208 | lockPartsForRead(true); | 2183 | lockPartsForRead(true); |
2184 | |||
2185 | foreach (SceneObjectPart part in m_parts.Values) | ||
2209 | { | 2186 | { |
2210 | foreach (SceneObjectPart part in m_parts.Values) | 2187 | part.AddTerseUpdateToAvatar(presence); |
2211 | { | ||
2212 | |||
2213 | part.AddTerseUpdateToAvatar(presence); | ||
2214 | |||
2215 | } | ||
2216 | } | 2188 | } |
2189 | |||
2217 | lockPartsForRead(false); | 2190 | lockPartsForRead(false); |
2218 | } | 2191 | } |
2219 | 2192 | ||
@@ -2246,14 +2219,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
2246 | public void ScheduleGroupForTerseUpdate() | 2219 | public void ScheduleGroupForTerseUpdate() |
2247 | { | 2220 | { |
2248 | lockPartsForRead(true); | 2221 | lockPartsForRead(true); |
2222 | foreach (SceneObjectPart part in m_parts.Values) | ||
2249 | { | 2223 | { |
2250 | foreach (SceneObjectPart part in m_parts.Values) | 2224 | part.ScheduleTerseUpdate(); |
2251 | { | ||
2252 | |||
2253 | part.ScheduleTerseUpdate(); | ||
2254 | |||
2255 | } | ||
2256 | } | 2225 | } |
2226 | |||
2257 | lockPartsForRead(false); | 2227 | lockPartsForRead(false); |
2258 | } | 2228 | } |
2259 | 2229 | ||
@@ -3107,8 +3077,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3107 | { | 3077 | { |
3108 | if (obPart.UUID != m_rootPart.UUID) | 3078 | if (obPart.UUID != m_rootPart.UUID) |
3109 | { | 3079 | { |
3110 | obPart.IgnoreUndoUpdate = true; | ||
3111 | Vector3 oldSize = new Vector3(obPart.Scale); | 3080 | Vector3 oldSize = new Vector3(obPart.Scale); |
3081 | obPart.IgnoreUndoUpdate = true; | ||
3112 | 3082 | ||
3113 | float f = 1.0f; | 3083 | float f = 1.0f; |
3114 | float a = 1.0f; | 3084 | float a = 1.0f; |
@@ -3681,7 +3651,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3681 | if (atRotTargets.Count > 0) | 3651 | if (atRotTargets.Count > 0) |
3682 | { | 3652 | { |
3683 | uint[] localids = new uint[0]; | 3653 | uint[] localids = new uint[0]; |
3684 | lock (m_parts) | 3654 | lockPartsForRead(true); |
3655 | try | ||
3685 | { | 3656 | { |
3686 | localids = new uint[m_parts.Count]; | 3657 | localids = new uint[m_parts.Count]; |
3687 | int cntr = 0; | 3658 | int cntr = 0; |
@@ -3691,6 +3662,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
3691 | cntr++; | 3662 | cntr++; |
3692 | } | 3663 | } |
3693 | } | 3664 | } |
3665 | finally | ||
3666 | { | ||
3667 | lockPartsForRead(false); | ||
3668 | } | ||
3694 | 3669 | ||
3695 | for (int ctr = 0; ctr < localids.Length; ctr++) | 3670 | for (int ctr = 0; ctr < localids.Length; ctr++) |
3696 | { | 3671 | { |
@@ -3709,7 +3684,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3709 | { | 3684 | { |
3710 | //trigger not_at_target | 3685 | //trigger not_at_target |
3711 | uint[] localids = new uint[0]; | 3686 | uint[] localids = new uint[0]; |
3712 | lock (m_parts) | 3687 | lockPartsForRead(true); |
3688 | try | ||
3713 | { | 3689 | { |
3714 | localids = new uint[m_parts.Count]; | 3690 | localids = new uint[m_parts.Count]; |
3715 | int cntr = 0; | 3691 | int cntr = 0; |
@@ -3719,6 +3695,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
3719 | cntr++; | 3695 | cntr++; |
3720 | } | 3696 | } |
3721 | } | 3697 | } |
3698 | finally | ||
3699 | { | ||
3700 | lockPartsForRead(false); | ||
3701 | } | ||
3722 | 3702 | ||
3723 | for (int ctr = 0; ctr < localids.Length; ctr++) | 3703 | for (int ctr = 0; ctr < localids.Length; ctr++) |
3724 | { | 3704 | { |
@@ -3962,5 +3942,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
3962 | 3942 | ||
3963 | return priority; | 3943 | return priority; |
3964 | } | 3944 | } |
3945 | |||
3946 | public void ResetOwnerChangeFlag() | ||
3947 | { | ||
3948 | ForEachPart(delegate(SceneObjectPart part) | ||
3949 | { | ||
3950 | part.ResetOwnerChangeFlag(); | ||
3951 | }); | ||
3952 | } | ||
3965 | } | 3953 | } |
3966 | } | 3954 | } |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 548a64f..48e65a5 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) |
@@ -4672,5 +4683,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
4672 | { | 4683 | { |
4673 | return new Color4((byte)Color.R, (byte)Color.G, (byte)Color.B, (byte)(0xFF - Color.A)); | 4684 | return new Color4((byte)Color.R, (byte)Color.G, (byte)Color.B, (byte)(0xFF - Color.A)); |
4674 | } | 4685 | } |
4686 | |||
4687 | public void ResetOwnerChangeFlag() | ||
4688 | { | ||
4689 | List<UUID> inv = Inventory.GetInventoryList(); | ||
4690 | |||
4691 | foreach (UUID itemID in inv) | ||
4692 | { | ||
4693 | TaskInventoryItem item = Inventory.GetInventoryItem(itemID); | ||
4694 | item.OwnerChanged = false; | ||
4695 | Inventory.UpdateInventoryItem(item); | ||
4696 | } | ||
4697 | } | ||
4675 | } | 4698 | } |
4676 | } | 4699 | } |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index a2fceb7..c4cff12 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | |||
@@ -34,7 +34,6 @@ using System.Reflection; | |||
34 | using OpenMetaverse; | 34 | using OpenMetaverse; |
35 | using log4net; | 35 | using log4net; |
36 | using OpenSim.Framework; | 36 | using OpenSim.Framework; |
37 | using OpenSim.Framework.Communications.Cache; | ||
38 | using OpenSim.Region.Framework.Interfaces; | 37 | using OpenSim.Region.Framework.Interfaces; |
39 | using OpenSim.Region.Framework.Scenes.Scripting; | 38 | using OpenSim.Region.Framework.Scenes.Scripting; |
40 | 39 | ||
@@ -213,7 +212,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
213 | } | 212 | } |
214 | } | 213 | } |
215 | 214 | ||
216 | private ArrayList GetScriptErrors(UUID itemID) | 215 | public ArrayList GetScriptErrors(UUID itemID) |
217 | { | 216 | { |
218 | ArrayList ret = new ArrayList(); | 217 | ArrayList ret = new ArrayList(); |
219 | 218 | ||
@@ -296,38 +295,36 @@ namespace OpenSim.Region.Framework.Scenes | |||
296 | return; | 295 | return; |
297 | } | 296 | } |
298 | 297 | ||
299 | m_part.ParentGroup.Scene.AssetService.Get(item.AssetID.ToString(), this, delegate(string id, object sender, AssetBase asset) | 298 | AssetBase asset = m_part.ParentGroup.Scene.AssetService.Get(item.AssetID.ToString()); |
300 | { | 299 | if (null == asset) |
301 | if (null == asset) | 300 | { |
302 | { | 301 | string msg = String.Format("asset ID {0} could not be found", item.AssetID); |
303 | string msg = String.Format("asset ID {0} could not be found", item.AssetID); | 302 | StoreScriptError(item.ItemID, msg); |
304 | StoreScriptError(item.ItemID, msg); | 303 | m_log.ErrorFormat( |
305 | m_log.ErrorFormat( | 304 | "[PRIM INVENTORY]: " + |
306 | "[PRIM INVENTORY]: " + | 305 | "Couldn't start script {0}, {1} at {2} in {3} since asset ID {4} could not be found", |
307 | "Couldn't start script {0}, {1} at {2} in {3} since {4}", | 306 | item.Name, item.ItemID, m_part.AbsolutePosition, |
308 | item.Name, item.ItemID, m_part.AbsolutePosition, | 307 | m_part.ParentGroup.Scene.RegionInfo.RegionName, item.AssetID); |
309 | m_part.ParentGroup.Scene.RegionInfo.RegionName, msg); | 308 | } |
310 | } | 309 | else |
311 | else | 310 | { |
312 | { | 311 | if (m_part.ParentGroup.m_savedScriptState != null) |
313 | if (m_part.ParentGroup.m_savedScriptState != null) | 312 | RestoreSavedScriptState(item.OldItemID, item.ItemID); |
314 | RestoreSavedScriptState(item.OldItemID, item.ItemID); | 313 | |
315 | m_items.LockItemsForWrite(true); | 314 | m_items.LockItemsForWrite(true); |
316 | m_items[item.ItemID].PermsMask = 0; | 315 | |
317 | m_items[item.ItemID].PermsGranter = UUID.Zero; | 316 | m_items[item.ItemID].PermsMask = 0; |
318 | m_items.LockItemsForWrite(false); | 317 | m_items[item.ItemID].PermsGranter = UUID.Zero; |
319 | string script = Utils.BytesToString(asset.Data); | 318 | |
320 | m_part.ParentGroup.Scene.EventManager.TriggerRezScript( | 319 | m_items.LockItemsForWrite(false); |
321 | m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource); | 320 | |
322 | StoreScriptErrors(item.ItemID, null); | 321 | string script = Utils.BytesToString(asset.Data); |
323 | m_part.ParentGroup.AddActiveScriptCount(1); | 322 | m_part.ParentGroup.Scene.EventManager.TriggerRezScript( |
324 | m_part.ScheduleFullUpdate(); | 323 | m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource); |
325 | } | 324 | StoreScriptErrors(item.ItemID, null); |
326 | }); | 325 | m_part.ParentGroup.AddActiveScriptCount(1); |
327 | } | 326 | m_part.ScheduleFullUpdate(); |
328 | else | 327 | } |
329 | { | ||
330 | StoreScriptError(item.ItemID, "scripts disabled"); | ||
331 | } | 328 | } |
332 | } | 329 | } |
333 | 330 | ||
@@ -654,6 +651,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
654 | item.ParentID = m_part.UUID; | 651 | item.ParentID = m_part.UUID; |
655 | item.ParentPartID = m_part.UUID; | 652 | item.ParentPartID = m_part.UUID; |
656 | item.Name = name; | 653 | item.Name = name; |
654 | item.GroupID = m_part.GroupID; | ||
657 | 655 | ||
658 | m_items.LockItemsForWrite(true); | 656 | m_items.LockItemsForWrite(true); |
659 | m_items.Add(item.ItemID, item); | 657 | m_items.Add(item.ItemID, item); |
@@ -716,15 +714,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
716 | { | 714 | { |
717 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(); | 715 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(); |
718 | 716 | ||
719 | lock (m_items) | 717 | m_items.LockItemsForRead(true); |
718 | |||
719 | foreach (TaskInventoryItem item in m_items.Values) | ||
720 | { | 720 | { |
721 | foreach (TaskInventoryItem item in m_items.Values) | 721 | if (item.Name == name) |
722 | { | 722 | items.Add(item); |
723 | if (item.Name == name) | ||
724 | items.Add(item); | ||
725 | } | ||
726 | } | 723 | } |
727 | 724 | ||
725 | m_items.LockItemsForRead(false); | ||
726 | |||
728 | return items; | 727 | return items; |
729 | } | 728 | } |
730 | 729 | ||
@@ -736,6 +735,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
736 | /// <returns>false if the item did not exist, true if the update occurred successfully</returns> | 735 | /// <returns>false if the item did not exist, true if the update occurred successfully</returns> |
737 | public bool UpdateInventoryItem(TaskInventoryItem item) | 736 | public bool UpdateInventoryItem(TaskInventoryItem item) |
738 | { | 737 | { |
738 | return UpdateInventoryItem(item, true); | ||
739 | } | ||
740 | |||
741 | public bool UpdateInventoryItem(TaskInventoryItem item, bool fireScriptEvents) | ||
742 | { | ||
739 | m_items.LockItemsForWrite(true); | 743 | m_items.LockItemsForWrite(true); |
740 | 744 | ||
741 | if (m_items.ContainsKey(item.ItemID)) | 745 | if (m_items.ContainsKey(item.ItemID)) |
@@ -743,6 +747,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
743 | item.ParentID = m_part.UUID; | 747 | item.ParentID = m_part.UUID; |
744 | item.ParentPartID = m_part.UUID; | 748 | item.ParentPartID = m_part.UUID; |
745 | item.Flags = m_items[item.ItemID].Flags; | 749 | item.Flags = m_items[item.ItemID].Flags; |
750 | |||
751 | // If group permissions have been set on, check that the groupID is up to date in case it has | ||
752 | // changed since permissions were last set. | ||
753 | if (item.GroupPermissions != (uint)PermissionMask.None) | ||
754 | item.GroupID = m_part.GroupID; | ||
755 | |||
746 | if (item.AssetID == UUID.Zero) | 756 | if (item.AssetID == UUID.Zero) |
747 | { | 757 | { |
748 | item.AssetID = m_items[item.ItemID].AssetID; | 758 | item.AssetID = m_items[item.ItemID].AssetID; |
@@ -760,8 +770,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
760 | 770 | ||
761 | m_items[item.ItemID] = item; | 771 | m_items[item.ItemID] = item; |
762 | m_inventorySerial++; | 772 | m_inventorySerial++; |
763 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); | 773 | if (fireScriptEvents) |
764 | 774 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); | |
765 | HasInventoryChanged = true; | 775 | HasInventoryChanged = true; |
766 | m_part.ParentGroup.HasGroupChanged = true; | 776 | m_part.ParentGroup.HasGroupChanged = true; |
767 | m_items.LockItemsForWrite(false); | 777 | m_items.LockItemsForWrite(false); |
@@ -830,12 +840,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
830 | } | 840 | } |
831 | else | 841 | else |
832 | { | 842 | { |
843 | m_items.LockItemsForRead(false); | ||
833 | m_log.ErrorFormat( | 844 | m_log.ErrorFormat( |
834 | "[PRIM INVENTORY]: " + | 845 | "[PRIM INVENTORY]: " + |
835 | "Tried to remove item ID {0} from prim {1}, {2} but the item does not exist in this inventory", | 846 | "Tried to remove item ID {0} from prim {1}, {2} but the item does not exist in this inventory", |
836 | itemID, m_part.Name, m_part.UUID); | 847 | itemID, m_part.Name, m_part.UUID); |
837 | } | 848 | } |
838 | m_items.LockItemsForWrite(false); | ||
839 | 849 | ||
840 | return -1; | 850 | return -1; |
841 | } | 851 | } |
@@ -896,6 +906,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
896 | uint everyoneMask = 0; | 906 | uint everyoneMask = 0; |
897 | uint baseMask = item.BasePermissions; | 907 | uint baseMask = item.BasePermissions; |
898 | uint ownerMask = item.CurrentPermissions; | 908 | uint ownerMask = item.CurrentPermissions; |
909 | uint groupMask = item.GroupPermissions; | ||
899 | 910 | ||
900 | invString.AddItemStart(); | 911 | invString.AddItemStart(); |
901 | invString.AddNameValueLine("item_id", item.ItemID.ToString()); | 912 | invString.AddNameValueLine("item_id", item.ItemID.ToString()); |
@@ -905,7 +916,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
905 | 916 | ||
906 | invString.AddNameValueLine("base_mask", Utils.UIntToHexString(baseMask)); | 917 | invString.AddNameValueLine("base_mask", Utils.UIntToHexString(baseMask)); |
907 | invString.AddNameValueLine("owner_mask", Utils.UIntToHexString(ownerMask)); | 918 | invString.AddNameValueLine("owner_mask", Utils.UIntToHexString(ownerMask)); |
908 | invString.AddNameValueLine("group_mask", Utils.UIntToHexString(0)); | 919 | invString.AddNameValueLine("group_mask", Utils.UIntToHexString(groupMask)); |
909 | invString.AddNameValueLine("everyone_mask", Utils.UIntToHexString(everyoneMask)); | 920 | invString.AddNameValueLine("everyone_mask", Utils.UIntToHexString(everyoneMask)); |
910 | invString.AddNameValueLine("next_owner_mask", Utils.UIntToHexString(item.NextPermissions)); | 921 | invString.AddNameValueLine("next_owner_mask", Utils.UIntToHexString(item.NextPermissions)); |
911 | 922 | ||
@@ -1071,12 +1082,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1071 | item.CurrentPermissions &= ~(uint)PermissionMask.Modify; | 1082 | item.CurrentPermissions &= ~(uint)PermissionMask.Modify; |
1072 | item.CurrentPermissions |= 8; | 1083 | item.CurrentPermissions |= 8; |
1073 | } | 1084 | } |
1085 | item.OwnerChanged = true; | ||
1074 | item.CurrentPermissions &= item.NextPermissions; | 1086 | item.CurrentPermissions &= item.NextPermissions; |
1075 | item.BasePermissions &= item.NextPermissions; | 1087 | item.BasePermissions &= item.NextPermissions; |
1076 | item.EveryonePermissions &= item.NextPermissions; | 1088 | item.EveryonePermissions &= item.NextPermissions; |
1077 | } | 1089 | } |
1078 | |||
1079 | m_part.TriggerScriptChangedEvent(Changed.OWNER); | ||
1080 | } | 1090 | } |
1081 | 1091 | ||
1082 | public void ApplyGodPermissions(uint perms) | 1092 | public void ApplyGodPermissions(uint perms) |
@@ -1112,6 +1122,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1112 | 1122 | ||
1113 | public Dictionary<UUID, string> GetScriptStates() | 1123 | public Dictionary<UUID, string> GetScriptStates() |
1114 | { | 1124 | { |
1125 | return GetScriptStates(false); | ||
1126 | } | ||
1127 | |||
1128 | public Dictionary<UUID, string> GetScriptStates(bool oldIDs) | ||
1129 | { | ||
1115 | IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>(); | 1130 | IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>(); |
1116 | 1131 | ||
1117 | Dictionary<UUID, string> ret = new Dictionary<UUID, string>(); | 1132 | Dictionary<UUID, string> ret = new Dictionary<UUID, string>(); |
@@ -1129,8 +1144,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
1129 | string n = e.GetXMLState(item.ItemID); | 1144 | string n = e.GetXMLState(item.ItemID); |
1130 | if (n != String.Empty) | 1145 | if (n != String.Empty) |
1131 | { | 1146 | { |
1132 | if (!ret.ContainsKey(item.ItemID)) | 1147 | if (oldIDs) |
1133 | ret[item.ItemID] = n; | 1148 | { |
1149 | if (!ret.ContainsKey(item.OldItemID)) | ||
1150 | ret[item.OldItemID] = n; | ||
1151 | } | ||
1152 | else | ||
1153 | { | ||
1154 | if (!ret.ContainsKey(item.ItemID)) | ||
1155 | ret[item.ItemID] = n; | ||
1156 | } | ||
1134 | break; | 1157 | break; |
1135 | } | 1158 | } |
1136 | } | 1159 | } |
@@ -1139,5 +1162,34 @@ namespace OpenSim.Region.Framework.Scenes | |||
1139 | } | 1162 | } |
1140 | return ret; | 1163 | return ret; |
1141 | } | 1164 | } |
1165 | |||
1166 | public void ResumeScripts() | ||
1167 | { | ||
1168 | IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>(); | ||
1169 | if (engines == null) | ||
1170 | return; | ||
1171 | |||
1172 | |||
1173 | Items.LockItemsForRead(true); | ||
1174 | |||
1175 | foreach (TaskInventoryItem item in m_items.Values) | ||
1176 | { | ||
1177 | if (item.InvType == (int)InventoryType.LSL) | ||
1178 | { | ||
1179 | foreach (IScriptModule engine in engines) | ||
1180 | { | ||
1181 | if (engine != null) | ||
1182 | { | ||
1183 | if (item.OwnerChanged) | ||
1184 | engine.PostScriptEvent(item.ItemID, "changed", new Object[] { (int)Changed.OWNER }); | ||
1185 | item.OwnerChanged = false; | ||
1186 | engine.ResumeScript(item.ItemID); | ||
1187 | } | ||
1188 | } | ||
1189 | } | ||
1190 | } | ||
1191 | |||
1192 | Items.LockItemsForRead(false); | ||
1193 | } | ||
1142 | } | 1194 | } |
1143 | } | 1195 | } |
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 68acabe..ad66273 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -26,6 +26,7 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Xml; | ||
29 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
30 | using System.Reflection; | 31 | using System.Reflection; |
31 | using System.Timers; | 32 | using System.Timers; |
@@ -33,12 +34,12 @@ using OpenMetaverse; | |||
33 | using log4net; | 34 | using log4net; |
34 | using OpenSim.Framework; | 35 | using OpenSim.Framework; |
35 | using OpenSim.Framework.Client; | 36 | using OpenSim.Framework.Client; |
36 | using OpenSim.Framework.Communications.Cache; | ||
37 | using OpenSim.Region.Framework.Interfaces; | 37 | using OpenSim.Region.Framework.Interfaces; |
38 | using OpenSim.Region.Framework.Scenes.Animation; | 38 | using OpenSim.Region.Framework.Scenes.Animation; |
39 | using OpenSim.Region.Framework.Scenes.Types; | 39 | using OpenSim.Region.Framework.Scenes.Types; |
40 | using OpenSim.Region.Physics.Manager; | 40 | using OpenSim.Region.Physics.Manager; |
41 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | 41 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; |
42 | using OpenSim.Services.Interfaces; | ||
42 | 43 | ||
43 | namespace OpenSim.Region.Framework.Scenes | 44 | namespace OpenSim.Region.Framework.Scenes |
44 | { | 45 | { |
@@ -150,7 +151,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
150 | 151 | ||
151 | private float m_sitAvatarHeight = 2.0f; | 152 | private float m_sitAvatarHeight = 2.0f; |
152 | 153 | ||
153 | private float m_godlevel; | 154 | private int m_godLevel; |
155 | private int m_userLevel; | ||
154 | 156 | ||
155 | private bool m_invulnerable = true; | 157 | private bool m_invulnerable = true; |
156 | 158 | ||
@@ -211,7 +213,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
211 | private bool m_autopilotMoving; | 213 | private bool m_autopilotMoving; |
212 | private Vector3 m_autoPilotTarget; | 214 | private Vector3 m_autoPilotTarget; |
213 | private bool m_sitAtAutoTarget; | 215 | private bool m_sitAtAutoTarget; |
214 | private Vector3 m_initialSitTarget; //KF: First estimate of where to sit | 216 | private Vector3 m_initialSitTarget = Vector3.Zero; //KF: First estimate of where to sit |
215 | 217 | ||
216 | private string m_nextSitAnimation = String.Empty; | 218 | private string m_nextSitAnimation = String.Empty; |
217 | 219 | ||
@@ -225,7 +227,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
225 | private int m_lastColCount = -1; //KF: Look for Collision chnages | 227 | private int m_lastColCount = -1; //KF: Look for Collision chnages |
226 | private int m_updateCount = 0; //KF: Update Anims for a while | 228 | private int m_updateCount = 0; //KF: Update Anims for a while |
227 | private static readonly int UPDATE_COUNT = 10; // how many frames to update for | 229 | private static readonly int UPDATE_COUNT = 10; // how many frames to update for |
228 | |||
229 | private const int NumMovementsBetweenRayCast = 5; | 230 | private const int NumMovementsBetweenRayCast = 5; |
230 | 231 | ||
231 | private bool CameraConstraintActive; | 232 | private bool CameraConstraintActive; |
@@ -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 | } |
@@ -655,6 +663,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
655 | set { m_flyDisabled = value; } | 663 | set { m_flyDisabled = value; } |
656 | } | 664 | } |
657 | 665 | ||
666 | public string Viewer | ||
667 | { | ||
668 | get { return m_scene.AuthenticateHandler.GetAgentCircuitData(ControllingClient.CircuitCode).Viewer; } | ||
669 | } | ||
670 | |||
658 | #endregion | 671 | #endregion |
659 | 672 | ||
660 | #region Constructor(s) | 673 | #region Constructor(s) |
@@ -678,6 +691,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
678 | m_regionInfo = reginfo; | 691 | m_regionInfo = reginfo; |
679 | m_localId = m_scene.AllocateLocalId(); | 692 | m_localId = m_scene.AllocateLocalId(); |
680 | 693 | ||
694 | UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, m_uuid); | ||
695 | |||
696 | if (account != null) | ||
697 | m_userLevel = account.UserLevel; | ||
698 | |||
681 | IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>(); | 699 | IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>(); |
682 | if (gm != null) | 700 | if (gm != null) |
683 | m_grouptitle = gm.GetGroupTitle(m_uuid); | 701 | m_grouptitle = gm.GetGroupTitle(m_uuid); |
@@ -697,8 +715,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
697 | // Request info about all the (root) agents in this region | 715 | // Request info about all the (root) agents in this region |
698 | // Note: This won't send data *to* other clients in that region (children don't send) | 716 | // Note: This won't send data *to* other clients in that region (children don't send) |
699 | SendInitialFullUpdateToAllClients(); | 717 | SendInitialFullUpdateToAllClients(); |
700 | |||
701 | RegisterToEvents(); | 718 | RegisterToEvents(); |
719 | if (m_controllingClient != null) | ||
720 | { | ||
721 | m_controllingClient.ProcessPendingPackets(); | ||
722 | } | ||
702 | SetDirectionVectors(); | 723 | SetDirectionVectors(); |
703 | } | 724 | } |
704 | 725 | ||
@@ -840,7 +861,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
840 | m_grouptitle = gm.GetGroupTitle(m_uuid); | 861 | m_grouptitle = gm.GetGroupTitle(m_uuid); |
841 | 862 | ||
842 | m_rootRegionHandle = m_scene.RegionInfo.RegionHandle; | 863 | m_rootRegionHandle = m_scene.RegionInfo.RegionHandle; |
843 | |||
844 | m_scene.SetRootAgentScene(m_uuid); | 864 | m_scene.SetRootAgentScene(m_uuid); |
845 | 865 | ||
846 | // Moved this from SendInitialData to ensure that m_appearance is initialized | 866 | // Moved this from SendInitialData to ensure that m_appearance is initialized |
@@ -868,7 +888,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
868 | if (land != null) | 888 | if (land != null) |
869 | { | 889 | { |
870 | //Don't restrict gods, estate managers, or land owners to the TP point. This behaviour mimics agni. | 890 | //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) | 891 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero && UserLevel < 200 && !m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid) && land.LandData.OwnerID != m_uuid) |
872 | { | 892 | { |
873 | pos = land.LandData.UserLocation; | 893 | pos = land.LandData.UserLocation; |
874 | } | 894 | } |
@@ -885,7 +905,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
885 | if (!(pos.Y < 0)) | 905 | if (!(pos.Y < 0)) |
886 | emergencyPos.Y = pos.Y; | 906 | emergencyPos.Y = pos.Y; |
887 | if (!(pos.Z < 0)) | 907 | if (!(pos.Z < 0)) |
888 | emergencyPos.X = pos.X; | 908 | emergencyPos.Z = pos.Z; |
889 | } | 909 | } |
890 | if (pos.Y < 0) | 910 | if (pos.Y < 0) |
891 | { | 911 | { |
@@ -897,18 +917,23 @@ namespace OpenSim.Region.Framework.Scenes | |||
897 | } | 917 | } |
898 | if (pos.Z < 0) | 918 | if (pos.Z < 0) |
899 | { | 919 | { |
900 | if (!(pos.X < 0)) | 920 | emergencyPos.Z = 128; |
901 | emergencyPos.X = pos.X; | ||
902 | if (!(pos.Y < 0)) | 921 | if (!(pos.Y < 0)) |
903 | emergencyPos.Y = pos.Y; | 922 | emergencyPos.Y = pos.Y; |
904 | //Leave as 128 | 923 | if (!(pos.X < 0)) |
924 | emergencyPos.X = pos.X; | ||
905 | } | 925 | } |
926 | } | ||
906 | 927 | ||
928 | if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) | ||
929 | { | ||
907 | m_log.WarnFormat( | 930 | m_log.WarnFormat( |
908 | "[SCENE PRESENCE]: MakeRootAgent() was given an illegal position of {0} for avatar {1}, {2}. Substituting {3}", | 931 | "[SCENE PRESENCE]: MakeRootAgent() was given an illegal position of {0} for avatar {1}, {2}. Clamping", |
909 | pos, Name, UUID, emergencyPos); | 932 | pos, Name, UUID); |
910 | 933 | ||
911 | pos = emergencyPos; | 934 | if (pos.X < 0f) pos.X = 0f; |
935 | if (pos.Y < 0f) pos.Y = 0f; | ||
936 | if (pos.Z < 0f) pos.Z = 0f; | ||
912 | } | 937 | } |
913 | 938 | ||
914 | float localAVHeight = 1.56f; | 939 | float localAVHeight = 1.56f; |
@@ -919,7 +944,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
919 | 944 | ||
920 | float posZLimit = 0; | 945 | float posZLimit = 0; |
921 | 946 | ||
922 | if (pos.X <Constants.RegionSize && pos.Y < Constants.RegionSize) | 947 | if (pos.X < Constants.RegionSize && pos.Y < Constants.RegionSize) |
923 | posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y]; | 948 | posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y]; |
924 | 949 | ||
925 | float newPosZ = posZLimit + localAVHeight / 2; | 950 | float newPosZ = posZLimit + localAVHeight / 2; |
@@ -971,14 +996,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
971 | 996 | ||
972 | m_isChildAgent = false; | 997 | m_isChildAgent = false; |
973 | 998 | ||
974 | ScenePresence[] animAgents = m_scene.GetScenePresences(); | 999 | // send the animations of the other presences to me |
975 | for (int i = 0; i < animAgents.Length; i++) | 1000 | m_scene.ForEachScenePresence(delegate(ScenePresence presence) |
976 | { | 1001 | { |
977 | ScenePresence presence = animAgents[i]; | ||
978 | |||
979 | if (presence != this) | 1002 | if (presence != this) |
980 | presence.Animator.SendAnimPackToClient(ControllingClient); | 1003 | presence.Animator.SendAnimPackToClient(ControllingClient); |
981 | } | 1004 | }); |
982 | 1005 | ||
983 | m_scene.EventManager.TriggerOnMakeRootAgent(this); | 1006 | m_scene.EventManager.TriggerOnMakeRootAgent(this); |
984 | } | 1007 | } |
@@ -1162,8 +1185,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1162 | /// This is called upon a very important packet sent from the client, | 1185 | /// This is called upon a very important packet sent from the client, |
1163 | /// so it's client-controlled. Never call this method directly. | 1186 | /// so it's client-controlled. Never call this method directly. |
1164 | /// </summary> | 1187 | /// </summary> |
1165 | public void CompleteMovement() | 1188 | public void CompleteMovement(IClientAPI client) |
1166 | { | 1189 | { |
1190 | //m_log.Debug("[SCENE PRESENCE]: CompleteMovement"); | ||
1191 | |||
1167 | Vector3 look = Velocity; | 1192 | Vector3 look = Velocity; |
1168 | if ((look.X == 0) && (look.Y == 0) && (look.Z == 0)) | 1193 | if ((look.X == 0) && (look.Y == 0) && (look.Z == 0)) |
1169 | { | 1194 | { |
@@ -1180,7 +1205,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1180 | pos.Z = ground + 1.5f; | 1205 | pos.Z = ground + 1.5f; |
1181 | AbsolutePosition = pos; | 1206 | AbsolutePosition = pos; |
1182 | } | 1207 | } |
1183 | |||
1184 | m_isChildAgent = false; | 1208 | m_isChildAgent = false; |
1185 | bool m_flying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); | 1209 | bool m_flying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); |
1186 | MakeRootAgent(AbsolutePosition, m_flying); | 1210 | MakeRootAgent(AbsolutePosition, m_flying); |
@@ -1188,7 +1212,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1188 | if ((m_callbackURI != null) && !m_callbackURI.Equals("")) | 1212 | if ((m_callbackURI != null) && !m_callbackURI.Equals("")) |
1189 | { | 1213 | { |
1190 | m_log.DebugFormat("[SCENE PRESENCE]: Releasing agent in URI {0}", m_callbackURI); | 1214 | m_log.DebugFormat("[SCENE PRESENCE]: Releasing agent in URI {0}", m_callbackURI); |
1191 | Scene.SendReleaseAgent(m_rootRegionHandle, UUID, m_callbackURI); | 1215 | Scene.SimulationService.ReleaseAgent(m_originRegionID, UUID, m_callbackURI); |
1192 | m_callbackURI = null; | 1216 | m_callbackURI = null; |
1193 | } | 1217 | } |
1194 | 1218 | ||
@@ -1196,6 +1220,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
1196 | 1220 | ||
1197 | m_controllingClient.MoveAgentIntoRegion(m_regionInfo, AbsolutePosition, look); | 1221 | m_controllingClient.MoveAgentIntoRegion(m_regionInfo, AbsolutePosition, look); |
1198 | SendInitialData(); | 1222 | SendInitialData(); |
1223 | |||
1224 | // Create child agents in neighbouring regions | ||
1225 | if (!m_isChildAgent) | ||
1226 | { | ||
1227 | IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>(); | ||
1228 | if (m_agentTransfer != null) | ||
1229 | m_agentTransfer.EnableChildAgents(this); | ||
1230 | else | ||
1231 | m_log.DebugFormat("[SCENE PRESENCE]: Unable to create child agents in neighbours, because AgentTransferModule is not active"); | ||
1232 | |||
1233 | IFriendsModule friendsModule = m_scene.RequestModuleInterface<IFriendsModule>(); | ||
1234 | if (friendsModule != null) | ||
1235 | friendsModule.SendFriendsOnlineIfNeeded(ControllingClient); | ||
1236 | } | ||
1237 | |||
1199 | } | 1238 | } |
1200 | 1239 | ||
1201 | /// <summary> | 1240 | /// <summary> |
@@ -1264,6 +1303,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1264 | m_log.Error("[AVATAR]: NonFinite Avatar position detected... Reset Position. Mantis this please. Error #9999902"); | 1303 | m_log.Error("[AVATAR]: NonFinite Avatar position detected... Reset Position. Mantis this please. Error #9999902"); |
1265 | 1304 | ||
1266 | m_pos = m_LastFinitePos; | 1305 | m_pos = m_LastFinitePos; |
1306 | |||
1267 | if (!m_pos.IsFinite()) | 1307 | if (!m_pos.IsFinite()) |
1268 | { | 1308 | { |
1269 | m_pos.X = 127f; | 1309 | m_pos.X = 127f; |
@@ -1900,6 +1940,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1900 | { | 1940 | { |
1901 | m_avUnscriptedSitPos = Vector3.Zero; // Zero = Sit on prim center | 1941 | m_avUnscriptedSitPos = Vector3.Zero; // Zero = Sit on prim center |
1902 | autopilotTarget = part.AbsolutePosition; | 1942 | autopilotTarget = part.AbsolutePosition; |
1943 | //Console.WriteLine("UsSmall autopilotTarget={0}", autopilotTarget); | ||
1903 | } | 1944 | } |
1904 | else return; // occupied small | 1945 | else return; // occupied small |
1905 | } // end large/small | 1946 | } // end large/small |
@@ -2276,7 +2317,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2276 | m_pos += SIT_TARGET_ADJUSTMENT; | 2317 | m_pos += SIT_TARGET_ADJUSTMENT; |
2277 | m_bodyRot = sitTargetOrient; | 2318 | m_bodyRot = sitTargetOrient; |
2278 | m_parentPosition = part.AbsolutePosition; | 2319 | m_parentPosition = part.AbsolutePosition; |
2279 | part.IsOccupied = true; | 2320 | part.IsOccupied = true; |
2321 | Console.WriteLine("Scripted Sit ofset {0}", m_pos); | ||
2280 | } | 2322 | } |
2281 | else | 2323 | else |
2282 | { | 2324 | { |
@@ -2356,7 +2398,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2356 | // else | 2398 | // else |
2357 | // { // single or child prim | 2399 | // { // single or child prim |
2358 | partIRot = Quaternion.Inverse(part.GetWorldRotation()); | 2400 | partIRot = Quaternion.Inverse(part.GetWorldRotation()); |
2359 | // } | 2401 | // } |
2360 | if (m_initialSitTarget != null) | 2402 | if (m_initialSitTarget != null) |
2361 | { | 2403 | { |
2362 | float offZ = collisionPoint.Z - m_initialSitTarget.Z; | 2404 | float offZ = collisionPoint.Z - m_initialSitTarget.Z; |
@@ -2401,6 +2443,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2401 | { | 2443 | { |
2402 | if (m_isChildAgent) | 2444 | if (m_isChildAgent) |
2403 | { | 2445 | { |
2446 | // WHAT??? | ||
2404 | m_log.Debug("[SCENEPRESENCE]: AddNewMovement() called on child agent, making root agent!"); | 2447 | m_log.Debug("[SCENEPRESENCE]: AddNewMovement() called on child agent, making root agent!"); |
2405 | 2448 | ||
2406 | // we have to reset the user's child agent connections. | 2449 | // we have to reset the user's child agent connections. |
@@ -2424,7 +2467,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2424 | 2467 | ||
2425 | if (m_scene.SceneGridService != null) | 2468 | if (m_scene.SceneGridService != null) |
2426 | { | 2469 | { |
2427 | m_scene.SceneGridService.EnableNeighbourChildAgents(this, new List<RegionInfo>()); | 2470 | IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>(); |
2471 | if (m_agentTransfer != null) | ||
2472 | m_agentTransfer.EnableChildAgents(this); | ||
2428 | } | 2473 | } |
2429 | 2474 | ||
2430 | return; | 2475 | return; |
@@ -2600,35 +2645,33 @@ namespace OpenSim.Region.Framework.Scenes | |||
2600 | 2645 | ||
2601 | List<Vector3> CoarseLocations = new List<Vector3>(); | 2646 | List<Vector3> CoarseLocations = new List<Vector3>(); |
2602 | List<UUID> AvatarUUIDs = new List<UUID>(); | 2647 | List<UUID> AvatarUUIDs = new List<UUID>(); |
2603 | List<ScenePresence> avatars = m_scene.GetAvatars(); | 2648 | m_scene.ForEachScenePresence(delegate(ScenePresence sp) |
2604 | for (int i = 0; i < avatars.Count; i++) | ||
2605 | { | 2649 | { |
2606 | // Requested by LibOMV. Send Course Location on self. | 2650 | if (sp.IsChildAgent) |
2607 | //if (avatars[i] != this) | 2651 | return; |
2608 | //{ | 2652 | |
2609 | if (avatars[i].ParentID != 0) | 2653 | if (sp.ParentID != 0) |
2654 | { | ||
2655 | // sitting avatar | ||
2656 | SceneObjectPart sop = m_scene.GetSceneObjectPart(sp.ParentID); | ||
2657 | if (sop != null) | ||
2610 | { | 2658 | { |
2611 | // sitting avatar | 2659 | CoarseLocations.Add(sop.AbsolutePosition + sp.m_pos); |
2612 | SceneObjectPart sop = m_scene.GetSceneObjectPart(avatars[i].ParentID); | 2660 | AvatarUUIDs.Add(sp.UUID); |
2613 | if (sop != null) | ||
2614 | { | ||
2615 | CoarseLocations.Add(sop.AbsolutePosition + avatars[i].m_pos); | ||
2616 | AvatarUUIDs.Add(avatars[i].UUID); | ||
2617 | } | ||
2618 | else | ||
2619 | { | ||
2620 | // we can't find the parent.. ! arg! | ||
2621 | CoarseLocations.Add(avatars[i].m_pos); | ||
2622 | AvatarUUIDs.Add(avatars[i].UUID); | ||
2623 | } | ||
2624 | } | 2661 | } |
2625 | else | 2662 | else |
2626 | { | 2663 | { |
2627 | CoarseLocations.Add(avatars[i].m_pos); | 2664 | // we can't find the parent.. ! arg! |
2628 | AvatarUUIDs.Add(avatars[i].UUID); | 2665 | CoarseLocations.Add(sp.m_pos); |
2666 | AvatarUUIDs.Add(sp.UUID); | ||
2629 | } | 2667 | } |
2630 | //} | 2668 | } |
2631 | } | 2669 | else |
2670 | { | ||
2671 | CoarseLocations.Add(sp.m_pos); | ||
2672 | AvatarUUIDs.Add(sp.UUID); | ||
2673 | } | ||
2674 | }); | ||
2632 | 2675 | ||
2633 | m_controllingClient.SendCoarseLocationUpdate(AvatarUUIDs, CoarseLocations); | 2676 | m_controllingClient.SendCoarseLocationUpdate(AvatarUUIDs, CoarseLocations); |
2634 | 2677 | ||
@@ -2670,13 +2713,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
2670 | public void SendInitialFullUpdateToAllClients() | 2713 | public void SendInitialFullUpdateToAllClients() |
2671 | { | 2714 | { |
2672 | m_perfMonMS = Util.EnvironmentTickCount(); | 2715 | m_perfMonMS = Util.EnvironmentTickCount(); |
2673 | 2716 | int avUpdates = 0; | |
2674 | ScenePresence[] avatars = m_scene.GetScenePresences(); | 2717 | m_scene.ForEachScenePresence(delegate(ScenePresence avatar) |
2675 | |||
2676 | for (int i = 0; i < avatars.Length; i++) | ||
2677 | { | 2718 | { |
2678 | ScenePresence avatar = avatars[i]; | 2719 | ++avUpdates; |
2679 | |||
2680 | // only send if this is the root (children are only "listening posts" in a foreign region) | 2720 | // only send if this is the root (children are only "listening posts" in a foreign region) |
2681 | if (!IsChildAgent) | 2721 | if (!IsChildAgent) |
2682 | { | 2722 | { |
@@ -2692,9 +2732,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2692 | avatar.Animator.SendAnimPackToClient(ControllingClient); | 2732 | avatar.Animator.SendAnimPackToClient(ControllingClient); |
2693 | } | 2733 | } |
2694 | } | 2734 | } |
2695 | } | 2735 | }); |
2696 | 2736 | ||
2697 | m_scene.StatsReporter.AddAgentUpdates(avatars.Length); | 2737 | m_scene.StatsReporter.AddAgentUpdates(avUpdates); |
2698 | m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); | 2738 | m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); |
2699 | 2739 | ||
2700 | //Animator.SendAnimPack(); | 2740 | //Animator.SendAnimPack(); |
@@ -2705,13 +2745,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
2705 | m_perfMonMS = Util.EnvironmentTickCount(); | 2745 | m_perfMonMS = Util.EnvironmentTickCount(); |
2706 | 2746 | ||
2707 | // only send update from root agents to other clients; children are only "listening posts" | 2747 | // only send update from root agents to other clients; children are only "listening posts" |
2708 | List<ScenePresence> avatars = m_scene.GetAvatars(); | 2748 | int count = 0; |
2709 | foreach (ScenePresence avatar in avatars) | 2749 | m_scene.ForEachScenePresence(delegate(ScenePresence sp) |
2710 | { | 2750 | { |
2711 | SendFullUpdateToOtherClient(avatar); | 2751 | if (sp.IsChildAgent) |
2712 | 2752 | return; | |
2713 | } | 2753 | SendFullUpdateToOtherClient(sp); |
2714 | m_scene.StatsReporter.AddAgentUpdates(avatars.Count); | 2754 | ++count; |
2755 | }); | ||
2756 | m_scene.StatsReporter.AddAgentUpdates(count); | ||
2715 | m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); | 2757 | m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); |
2716 | 2758 | ||
2717 | Animator.SendAnimPack(); | 2759 | Animator.SendAnimPack(); |
@@ -2732,14 +2774,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2732 | m_controllingClient.SendAvatarData(new SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_grouptitle, m_uuid, LocalId, | 2774 | m_controllingClient.SendAvatarData(new SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_grouptitle, m_uuid, LocalId, |
2733 | pos, m_appearance.Texture.GetBytes(), m_parentID, m_bodyRot)); | 2775 | pos, m_appearance.Texture.GetBytes(), m_parentID, m_bodyRot)); |
2734 | 2776 | ||
2735 | if (!m_isChildAgent) | ||
2736 | { | ||
2737 | m_scene.InformClientOfNeighbours(this); | ||
2738 | } | ||
2739 | |||
2740 | SendInitialFullUpdateToAllClients(); | 2777 | SendInitialFullUpdateToAllClients(); |
2741 | SendAppearanceToAllOtherAgents(); | 2778 | SendAppearanceToAllOtherAgents(); |
2742 | } | 2779 | } |
2743 | 2780 | ||
2744 | /// <summary> | 2781 | /// <summary> |
2745 | /// Tell the client for this scene presence what items it should be wearing now | 2782 | /// Tell the client for this scene presence what items it should be wearing now |
@@ -2821,14 +2858,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
2821 | } | 2858 | } |
2822 | } | 2859 | } |
2823 | } | 2860 | } |
2861 | |||
2824 | } | 2862 | } |
2825 | 2863 | ||
2864 | |||
2826 | #endregion Bake Cache Check | 2865 | #endregion Bake Cache Check |
2827 | 2866 | ||
2828 | m_appearance.SetAppearance(textureEntry, visualParams); | 2867 | m_appearance.SetAppearance(textureEntry, visualParams); |
2829 | if (m_appearance.AvatarHeight > 0) | 2868 | if (m_appearance.AvatarHeight > 0) |
2830 | SetHeight(m_appearance.AvatarHeight); | 2869 | SetHeight(m_appearance.AvatarHeight); |
2831 | m_scene.CommsManager.AvatarService.UpdateUserAppearance(m_controllingClient.AgentId, m_appearance); | 2870 | |
2871 | // This is not needed, because only the transient data changed | ||
2872 | //AvatarData adata = new AvatarData(m_appearance); | ||
2873 | //m_scene.AvatarService.SetAvatar(m_controllingClient.AgentId, adata); | ||
2832 | 2874 | ||
2833 | SendAppearanceToAllOtherAgents(); | 2875 | SendAppearanceToAllOtherAgents(); |
2834 | if (!m_startAnimationSet) | 2876 | if (!m_startAnimationSet) |
@@ -2848,7 +2890,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2848 | public void SetWearable(int wearableId, AvatarWearable wearable) | 2890 | public void SetWearable(int wearableId, AvatarWearable wearable) |
2849 | { | 2891 | { |
2850 | m_appearance.SetWearable(wearableId, wearable); | 2892 | m_appearance.SetWearable(wearableId, wearable); |
2851 | m_scene.CommsManager.AvatarService.UpdateUserAppearance(m_controllingClient.AgentId, m_appearance); | 2893 | AvatarData adata = new AvatarData(m_appearance); |
2894 | m_scene.AvatarService.SetAvatar(m_controllingClient.AgentId, adata); | ||
2852 | m_controllingClient.SendWearables(m_appearance.Wearables, m_appearance.Serial++); | 2895 | m_controllingClient.SendWearables(m_appearance.Wearables, m_appearance.Serial++); |
2853 | } | 2896 | } |
2854 | 2897 | ||
@@ -2870,7 +2913,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2870 | /// </summary> | 2913 | /// </summary> |
2871 | protected void CheckForSignificantMovement() | 2914 | protected void CheckForSignificantMovement() |
2872 | { | 2915 | { |
2873 | if (Util.GetDistanceTo(AbsolutePosition, posLastSignificantMove) > 0.5) | 2916 | // Movement updates for agents in neighboring regions are sent directly to clients. |
2917 | // This value only affects how often agent positions are sent to neighbor regions | ||
2918 | // for things such as distance-based update prioritization | ||
2919 | const float SIGNIFICANT_MOVEMENT = 2.0f; | ||
2920 | |||
2921 | if (Util.GetDistanceTo(AbsolutePosition, posLastSignificantMove) > SIGNIFICANT_MOVEMENT) | ||
2874 | { | 2922 | { |
2875 | posLastSignificantMove = AbsolutePosition; | 2923 | posLastSignificantMove = AbsolutePosition; |
2876 | m_scene.EventManager.TriggerSignificantClientMovement(m_controllingClient); | 2924 | m_scene.EventManager.TriggerSignificantClientMovement(m_controllingClient); |
@@ -2881,18 +2929,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
2881 | if (Util.GetDistanceTo(AbsolutePosition, m_lastChildAgentUpdatePosition) >= Scene.ChildReprioritizationDistance || | 2929 | if (Util.GetDistanceTo(AbsolutePosition, m_lastChildAgentUpdatePosition) >= Scene.ChildReprioritizationDistance || |
2882 | Util.GetDistanceTo(CameraPosition, m_lastChildAgentUpdateCamPosition) >= Scene.ChildReprioritizationDistance) | 2930 | Util.GetDistanceTo(CameraPosition, m_lastChildAgentUpdateCamPosition) >= Scene.ChildReprioritizationDistance) |
2883 | { | 2931 | { |
2932 | m_lastChildAgentUpdatePosition = AbsolutePosition; | ||
2933 | m_lastChildAgentUpdateCamPosition = CameraPosition; | ||
2934 | |||
2884 | ChildAgentDataUpdate cadu = new ChildAgentDataUpdate(); | 2935 | ChildAgentDataUpdate cadu = new ChildAgentDataUpdate(); |
2885 | cadu.ActiveGroupID = UUID.Zero.Guid; | 2936 | cadu.ActiveGroupID = UUID.Zero.Guid; |
2886 | cadu.AgentID = UUID.Guid; | 2937 | cadu.AgentID = UUID.Guid; |
2887 | cadu.alwaysrun = m_setAlwaysRun; | 2938 | cadu.alwaysrun = m_setAlwaysRun; |
2888 | cadu.AVHeight = m_avHeight; | 2939 | cadu.AVHeight = m_avHeight; |
2889 | sLLVector3 tempCameraCenter = new sLLVector3(new Vector3(m_CameraCenter.X, m_CameraCenter.Y, m_CameraCenter.Z)); | 2940 | Vector3 tempCameraCenter = m_CameraCenter; |
2890 | cadu.cameraPosition = tempCameraCenter; | 2941 | cadu.cameraPosition = tempCameraCenter; |
2891 | cadu.drawdistance = m_DrawDistance; | 2942 | cadu.drawdistance = m_DrawDistance; |
2892 | if (m_scene.Permissions.IsGod(new UUID(cadu.AgentID))) | ||
2893 | cadu.godlevel = m_godlevel; | ||
2894 | cadu.GroupAccess = 0; | 2943 | cadu.GroupAccess = 0; |
2895 | cadu.Position = new sLLVector3(AbsolutePosition); | 2944 | cadu.Position = AbsolutePosition; |
2896 | cadu.regionHandle = m_rootRegionHandle; | 2945 | cadu.regionHandle = m_rootRegionHandle; |
2897 | float multiplier = 1; | 2946 | float multiplier = 1; |
2898 | int innacurateNeighbors = m_scene.GetInaccurateNeighborCount(); | 2947 | int innacurateNeighbors = m_scene.GetInaccurateNeighborCount(); |
@@ -2907,15 +2956,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2907 | 2956 | ||
2908 | //m_log.Info("[NeighborThrottle]: " + m_scene.GetInaccurateNeighborCount().ToString() + " - m: " + multiplier.ToString()); | 2957 | //m_log.Info("[NeighborThrottle]: " + m_scene.GetInaccurateNeighborCount().ToString() + " - m: " + multiplier.ToString()); |
2909 | cadu.throttles = ControllingClient.GetThrottlesPacked(multiplier); | 2958 | cadu.throttles = ControllingClient.GetThrottlesPacked(multiplier); |
2910 | cadu.Velocity = new sLLVector3(Velocity); | 2959 | cadu.Velocity = Velocity; |
2911 | 2960 | ||
2912 | AgentPosition agentpos = new AgentPosition(); | 2961 | AgentPosition agentpos = new AgentPosition(); |
2913 | agentpos.CopyFrom(cadu); | 2962 | agentpos.CopyFrom(cadu); |
2914 | 2963 | ||
2915 | m_scene.SendOutChildAgentUpdates(agentpos, this); | 2964 | m_scene.SendOutChildAgentUpdates(agentpos, this); |
2916 | |||
2917 | m_lastChildAgentUpdatePosition = AbsolutePosition; | ||
2918 | m_lastChildAgentUpdateCamPosition = CameraPosition; | ||
2919 | } | 2965 | } |
2920 | } | 2966 | } |
2921 | 2967 | ||
@@ -3171,18 +3217,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
3171 | // For now, assign god level 200 to anyone | 3217 | // For now, assign god level 200 to anyone |
3172 | // who is granted god powers, but has no god level set. | 3218 | // who is granted god powers, but has no god level set. |
3173 | // | 3219 | // |
3174 | CachedUserInfo profile = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(agentID); | 3220 | UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, agentID); |
3175 | if (profile.UserProfile.GodLevel > 0) | 3221 | if (account != null) |
3176 | m_godlevel = profile.UserProfile.GodLevel; | 3222 | { |
3177 | else | 3223 | if (account.UserLevel > 0) |
3178 | m_godlevel = 200; | 3224 | m_godLevel = account.UserLevel; |
3225 | else | ||
3226 | m_godLevel = 200; | ||
3227 | } | ||
3179 | } | 3228 | } |
3180 | else | 3229 | else |
3181 | { | 3230 | { |
3182 | m_godlevel = 0; | 3231 | m_godLevel = 0; |
3183 | } | 3232 | } |
3184 | 3233 | ||
3185 | ControllingClient.SendAdminResponse(token, (uint)m_godlevel); | 3234 | ControllingClient.SendAdminResponse(token, (uint)m_godLevel); |
3186 | } | 3235 | } |
3187 | 3236 | ||
3188 | #region Child Agent Updates | 3237 | #region Child Agent Updates |
@@ -3241,7 +3290,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3241 | public void CopyTo(AgentData cAgent) | 3290 | public void CopyTo(AgentData cAgent) |
3242 | { | 3291 | { |
3243 | cAgent.AgentID = UUID; | 3292 | cAgent.AgentID = UUID; |
3244 | cAgent.RegionHandle = m_rootRegionHandle; | 3293 | cAgent.RegionID = Scene.RegionInfo.RegionID; |
3245 | 3294 | ||
3246 | cAgent.Position = AbsolutePosition; | 3295 | cAgent.Position = AbsolutePosition; |
3247 | cAgent.Velocity = m_velocity; | 3296 | cAgent.Velocity = m_velocity; |
@@ -3273,7 +3322,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3273 | cAgent.ControlFlags = (uint)m_AgentControlFlags; | 3322 | cAgent.ControlFlags = (uint)m_AgentControlFlags; |
3274 | 3323 | ||
3275 | if (m_scene.Permissions.IsGod(new UUID(cAgent.AgentID))) | 3324 | if (m_scene.Permissions.IsGod(new UUID(cAgent.AgentID))) |
3276 | cAgent.GodLevel = (byte)m_godlevel; | 3325 | cAgent.GodLevel = (byte)m_godLevel; |
3277 | else | 3326 | else |
3278 | cAgent.GodLevel = (byte) 0; | 3327 | cAgent.GodLevel = (byte) 0; |
3279 | 3328 | ||
@@ -3340,11 +3389,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
3340 | 3389 | ||
3341 | public void CopyFrom(AgentData cAgent) | 3390 | public void CopyFrom(AgentData cAgent) |
3342 | { | 3391 | { |
3343 | m_rootRegionHandle = cAgent.RegionHandle; | 3392 | m_originRegionID = cAgent.RegionID; |
3344 | 3393 | ||
3345 | m_callbackURI = cAgent.CallbackURI; | 3394 | m_callbackURI = cAgent.CallbackURI; |
3346 | 3395 | ||
3347 | m_pos = cAgent.Position; | 3396 | m_pos = cAgent.Position; |
3397 | |||
3348 | m_velocity = cAgent.Velocity; | 3398 | m_velocity = cAgent.Velocity; |
3349 | m_CameraCenter = cAgent.Center; | 3399 | m_CameraCenter = cAgent.Center; |
3350 | //m_avHeight = cAgent.Size.Z; | 3400 | //m_avHeight = cAgent.Size.Z; |
@@ -3362,7 +3412,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3362 | m_AgentControlFlags = (AgentManager.ControlFlags)cAgent.ControlFlags; | 3412 | m_AgentControlFlags = (AgentManager.ControlFlags)cAgent.ControlFlags; |
3363 | 3413 | ||
3364 | if (m_scene.Permissions.IsGod(new UUID(cAgent.AgentID))) | 3414 | if (m_scene.Permissions.IsGod(new UUID(cAgent.AgentID))) |
3365 | m_godlevel = cAgent.GodLevel; | 3415 | m_godLevel = cAgent.GodLevel; |
3366 | m_setAlwaysRun = cAgent.AlwaysRun; | 3416 | m_setAlwaysRun = cAgent.AlwaysRun; |
3367 | 3417 | ||
3368 | uint i = 0; | 3418 | uint i = 0; |
@@ -3720,36 +3770,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3720 | } | 3770 | } |
3721 | } | 3771 | } |
3722 | 3772 | ||
3723 | public bool CrossAttachmentsIntoNewRegion(ulong regionHandle, bool silent) | ||
3724 | { | ||
3725 | lock (m_attachments) | ||
3726 | { | ||
3727 | // Validate | ||
3728 | foreach (SceneObjectGroup gobj in m_attachments) | ||
3729 | { | ||
3730 | if (gobj == null || gobj.IsDeleted) | ||
3731 | return false; | ||
3732 | } | ||
3733 | |||
3734 | foreach (SceneObjectGroup gobj in m_attachments) | ||
3735 | { | ||
3736 | // If the prim group is null then something must have happened to it! | ||
3737 | if (gobj != null && gobj.RootPart != null) | ||
3738 | { | ||
3739 | // Set the parent localID to 0 so it transfers over properly. | ||
3740 | gobj.RootPart.SetParentLocalId(0); | ||
3741 | gobj.AbsolutePosition = gobj.RootPart.AttachedPos; | ||
3742 | gobj.RootPart.IsAttachment = false; | ||
3743 | //gobj.RootPart.LastOwnerID = gobj.GetFromAssetID(); | ||
3744 | m_log.DebugFormat("[ATTACHMENT]: Sending attachment {0} to region {1}", gobj.UUID, regionHandle); | ||
3745 | m_scene.CrossPrimGroupIntoNewRegion(regionHandle, gobj, silent); | ||
3746 | } | ||
3747 | } | ||
3748 | m_attachments.Clear(); | ||
3749 | |||
3750 | return true; | ||
3751 | } | ||
3752 | } | ||
3753 | 3773 | ||
3754 | public void initializeScenePresence(IClientAPI client, RegionInfo region, Scene scene) | 3774 | public void initializeScenePresence(IClientAPI client, RegionInfo region, Scene scene) |
3755 | { | 3775 | { |
@@ -3758,7 +3778,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
3758 | m_scene = scene; | 3778 | m_scene = scene; |
3759 | 3779 | ||
3760 | RegisterToEvents(); | 3780 | RegisterToEvents(); |
3761 | 3781 | if (m_controllingClient != null) | |
3782 | { | ||
3783 | m_controllingClient.ProcessPendingPackets(); | ||
3784 | } | ||
3762 | /* | 3785 | /* |
3763 | AbsolutePosition = client.StartPos; | 3786 | AbsolutePosition = client.StartPos; |
3764 | 3787 | ||
@@ -3985,10 +4008,36 @@ namespace OpenSim.Region.Framework.Scenes | |||
3985 | { | 4008 | { |
3986 | if (null == m_appearance) | 4009 | if (null == m_appearance) |
3987 | { | 4010 | { |
3988 | m_log.WarnFormat("[ATTACHMENT] Appearance has not been initialized for agent {0}", UUID); | 4011 | m_log.WarnFormat("[ATTACHMENT]: Appearance has not been initialized for agent {0}", UUID); |
3989 | return; | 4012 | return; |
3990 | } | 4013 | } |
3991 | 4014 | ||
4015 | XmlDocument doc = new XmlDocument(); | ||
4016 | string stateData = String.Empty; | ||
4017 | |||
4018 | IAttachmentsService attServ = m_scene.RequestModuleInterface<IAttachmentsService>(); | ||
4019 | if (attServ != null) | ||
4020 | { | ||
4021 | m_log.DebugFormat("[ATTACHMENT]: Loading attachment data from attachment service"); | ||
4022 | stateData = attServ.Get(ControllingClient.AgentId.ToString()); | ||
4023 | doc.LoadXml(stateData); | ||
4024 | } | ||
4025 | |||
4026 | Dictionary<UUID, string> itemData = new Dictionary<UUID, string>(); | ||
4027 | |||
4028 | XmlNodeList nodes = doc.GetElementsByTagName("Attachment"); | ||
4029 | if (nodes.Count > 0) | ||
4030 | { | ||
4031 | foreach (XmlNode n in nodes) | ||
4032 | { | ||
4033 | XmlElement elem = (XmlElement)n; | ||
4034 | string itemID = elem.GetAttribute("ItemID"); | ||
4035 | string xml = elem.InnerXml; | ||
4036 | |||
4037 | itemData[new UUID(itemID)] = xml; | ||
4038 | } | ||
4039 | } | ||
4040 | |||
3992 | List<int> attPoints = m_appearance.GetAttachedPoints(); | 4041 | List<int> attPoints = m_appearance.GetAttachedPoints(); |
3993 | foreach (int p in attPoints) | 4042 | foreach (int p in attPoints) |
3994 | { | 4043 | { |
@@ -4008,13 +4057,30 @@ namespace OpenSim.Region.Framework.Scenes | |||
4008 | 4057 | ||
4009 | try | 4058 | try |
4010 | { | 4059 | { |
4011 | // Rez from inventory | 4060 | string xmlData; |
4012 | UUID asset = m_scene.RezSingleAttachment(ControllingClient, | 4061 | XmlDocument d = new XmlDocument(); |
4013 | itemID, (uint)p); | 4062 | UUID asset; |
4063 | if (itemData.TryGetValue(itemID, out xmlData)) | ||
4064 | { | ||
4065 | d.LoadXml(xmlData); | ||
4066 | m_log.InfoFormat("[ATTACHMENT]: Found saved state for item {0}, loading it", itemID); | ||
4014 | 4067 | ||
4015 | m_log.InfoFormat("[ATTACHMENT]: Rezzed attachment in point {0} from item {1} and asset {2} ({3})", | 4068 | // Rez from inventory |
4016 | p, itemID, assetID, asset); | 4069 | asset |
4070 | = m_scene.AttachmentsModule.RezSingleAttachmentFromInventory(ControllingClient, itemID, (uint)p, true, d); | ||
4071 | |||
4072 | } | ||
4073 | else | ||
4074 | { | ||
4075 | // Rez from inventory (with a null doc to let | ||
4076 | // CHANGED_OWNER happen) | ||
4077 | asset | ||
4078 | = m_scene.AttachmentsModule.RezSingleAttachmentFromInventory(ControllingClient, itemID, (uint)p, true, null); | ||
4079 | } | ||
4017 | 4080 | ||
4081 | m_log.InfoFormat( | ||
4082 | "[ATTACHMENT]: Rezzed attachment in point {0} from item {1} and asset {2} ({3})", | ||
4083 | p, itemID, assetID, asset); | ||
4018 | } | 4084 | } |
4019 | catch (Exception e) | 4085 | catch (Exception e) |
4020 | { | 4086 | { |
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; | |||
31 | using log4net; | 31 | using log4net; |
32 | using OpenSim.Framework; | 32 | using OpenSim.Framework; |
33 | using OpenSim.Framework.Client; | 33 | using OpenSim.Framework.Client; |
34 | using OpenSim.Framework.Communications.Cache; | ||
35 | using OpenSim.Region.Framework.Interfaces; | 34 | using OpenSim.Region.Framework.Interfaces; |
36 | using OpenSim.Region.Framework.Scenes.Types; | 35 | using OpenSim.Region.Framework.Scenes.Types; |
37 | 36 | ||
diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneXmlLoader.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneXmlLoader.cs index cf0f345..b6677f0 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneXmlLoader.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneXmlLoader.cs | |||
@@ -182,6 +182,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
182 | foreach (SceneObjectGroup sceneObject in sceneObjects) | 182 | foreach (SceneObjectGroup sceneObject in sceneObjects) |
183 | { | 183 | { |
184 | sceneObject.CreateScriptInstances(0, true, scene.DefaultScriptEngine, 0); | 184 | sceneObject.CreateScriptInstances(0, true, scene.DefaultScriptEngine, 0); |
185 | sceneObject.ResumeScripts(); | ||
185 | } | 186 | } |
186 | } | 187 | } |
187 | 188 | ||
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneBaseTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneBaseTests.cs index 8230f32..42587c1 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneBaseTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneBaseTests.cs | |||
@@ -65,6 +65,16 @@ 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 | } | ||
73 | |||
74 | public override bool CheckClient(UUID agentID, System.Net.IPEndPoint ep) | ||
75 | { | ||
76 | throw new NotImplementedException(); | ||
77 | } | ||
68 | } | 78 | } |
69 | 79 | ||
70 | [Test] | 80 | [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; | |||
32 | using OpenMetaverse; | 32 | using OpenMetaverse; |
33 | using OpenSim.Framework; | 33 | using OpenSim.Framework; |
34 | using OpenSim.Framework.Communications; | 34 | using OpenSim.Framework.Communications; |
35 | using OpenSim.Framework.Communications.Cache; | 35 | |
36 | using OpenSim.Region.Communications.Local; | ||
37 | using OpenSim.Region.Framework.Scenes; | 36 | using OpenSim.Region.Framework.Scenes; |
38 | using OpenSim.Tests.Common; | 37 | using OpenSim.Tests.Common; |
39 | using OpenSim.Tests.Common.Mock; | 38 | using 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; | |||
32 | using OpenMetaverse; | 32 | using OpenMetaverse; |
33 | using OpenSim.Framework; | 33 | using OpenSim.Framework; |
34 | using OpenSim.Framework.Communications; | 34 | using OpenSim.Framework.Communications; |
35 | using OpenSim.Framework.Communications.Cache; | 35 | |
36 | using OpenSim.Region.Communications.Local; | ||
37 | using OpenSim.Region.Framework.Scenes; | 36 | using OpenSim.Region.Framework.Scenes; |
38 | using OpenSim.Tests.Common; | 37 | using OpenSim.Tests.Common; |
39 | using OpenSim.Tests.Common.Mock; | 38 | using 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; | |||
40 | using OpenSim.Framework.Communications; | 40 | using OpenSim.Framework.Communications; |
41 | using OpenSim.Region.Framework.Scenes; | 41 | using OpenSim.Region.Framework.Scenes; |
42 | using OpenSim.Region.Framework.Interfaces; | 42 | using OpenSim.Region.Framework.Interfaces; |
43 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion; | ||
44 | using OpenSim.Region.CoreModules.World.Serialiser; | 43 | using OpenSim.Region.CoreModules.World.Serialiser; |
44 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; | ||
45 | using OpenSim.Tests.Common; | 45 | using OpenSim.Tests.Common; |
46 | using OpenSim.Tests.Common.Mock; | 46 | using OpenSim.Tests.Common.Mock; |
47 | using OpenSim.Tests.Common.Setup; | 47 | using 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; | |||
34 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
35 | using OpenSim.Framework.Communications; | 35 | using OpenSim.Framework.Communications; |
36 | using OpenSim.Region.Framework.Interfaces; | 36 | using OpenSim.Region.Framework.Interfaces; |
37 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion; | 37 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; |
38 | using OpenSim.Tests.Common; | 38 | using OpenSim.Tests.Common; |
39 | using OpenSim.Tests.Common.Mock; | 39 | using OpenSim.Tests.Common.Mock; |
40 | using OpenSim.Tests.Common.Setup; | 40 | using 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 | } |