diff options
author | Melanie | 2012-09-16 04:11:20 +0100 |
---|---|---|
committer | Melanie | 2012-09-16 04:11:20 +0100 |
commit | db774d4292588db1e2ac4a9fafe977ddbec353ee (patch) | |
tree | 5fc381d7cb96cc0d2b47e4807821f488c339ec13 /OpenSim/Region/CoreModules/Framework | |
parent | Merge branch 'avination' into careminster (diff) | |
parent | Merge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff) | |
download | opensim-SC_OLD-db774d4292588db1e2ac4a9fafe977ddbec353ee.zip opensim-SC_OLD-db774d4292588db1e2ac4a9fafe977ddbec353ee.tar.gz opensim-SC_OLD-db774d4292588db1e2ac4a9fafe977ddbec353ee.tar.bz2 opensim-SC_OLD-db774d4292588db1e2ac4a9fafe977ddbec353ee.tar.xz |
Merge branch 'master' into careminster
Conflicts:
OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
OpenSim/Region/Framework/Scenes/EventManager.cs
Diffstat (limited to 'OpenSim/Region/CoreModules/Framework')
3 files changed, 174 insertions, 3 deletions
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index 486f9d2..1f62743 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs | |||
@@ -327,6 +327,14 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
327 | return; | 327 | return; |
328 | } | 328 | } |
329 | 329 | ||
330 | // Validate assorted conditions | ||
331 | string reason = string.Empty; | ||
332 | if (!ValidateGenericConditions(sp, reg, finalDestination, teleportFlags, out reason)) | ||
333 | { | ||
334 | sp.ControllingClient.SendTeleportFailed(reason); | ||
335 | return; | ||
336 | } | ||
337 | |||
330 | // | 338 | // |
331 | // This is it | 339 | // This is it |
332 | // | 340 | // |
@@ -358,6 +366,13 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
358 | } | 366 | } |
359 | } | 367 | } |
360 | 368 | ||
369 | // Nothing to validate here | ||
370 | protected virtual bool ValidateGenericConditions(ScenePresence sp, GridRegion reg, GridRegion finalDestination, uint teleportFlags, out string reason) | ||
371 | { | ||
372 | reason = String.Empty; | ||
373 | return true; | ||
374 | } | ||
375 | |||
361 | /// <summary> | 376 | /// <summary> |
362 | /// Determines whether this instance is within the max transfer distance. | 377 | /// Determines whether this instance is within the max transfer distance. |
363 | /// </summary> | 378 | /// </summary> |
@@ -574,7 +589,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
574 | 589 | ||
575 | //sp.ControllingClient.SendTeleportProgress(teleportFlags, "Updating agent..."); | 590 | //sp.ControllingClient.SendTeleportProgress(teleportFlags, "Updating agent..."); |
576 | 591 | ||
577 | if (!UpdateAgent(reg, finalDestination, agent)) | 592 | if (!UpdateAgent(reg, finalDestination, agent, sp)) |
578 | { | 593 | { |
579 | // Region doesn't take it | 594 | // Region doesn't take it |
580 | m_log.WarnFormat( | 595 | m_log.WarnFormat( |
@@ -701,7 +716,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
701 | return success; | 716 | return success; |
702 | } | 717 | } |
703 | 718 | ||
704 | protected virtual bool UpdateAgent(GridRegion reg, GridRegion finalDestination, AgentData agent) | 719 | protected virtual bool UpdateAgent(GridRegion reg, GridRegion finalDestination, AgentData agent, ScenePresence sp) |
705 | { | 720 | { |
706 | return Scene.SimulationService.UpdateAgent(finalDestination, agent); | 721 | return Scene.SimulationService.UpdateAgent(finalDestination, agent); |
707 | } | 722 | } |
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs index 3010b59..0f1a381 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs | |||
@@ -54,6 +54,47 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
54 | 54 | ||
55 | private GatekeeperServiceConnector m_GatekeeperConnector; | 55 | private GatekeeperServiceConnector m_GatekeeperConnector; |
56 | 56 | ||
57 | protected bool m_RestrictAppearanceAbroad; | ||
58 | protected string m_AccountName; | ||
59 | protected AvatarAppearance m_ExportedAppearance; | ||
60 | |||
61 | protected AvatarAppearance ExportedAppearance | ||
62 | { | ||
63 | get | ||
64 | { | ||
65 | if (m_ExportedAppearance != null) | ||
66 | return m_ExportedAppearance; | ||
67 | |||
68 | string[] parts = m_AccountName.Split(); | ||
69 | if (parts.Length != 2) | ||
70 | { | ||
71 | m_log.WarnFormat("[HG ENTITY TRANSFER MODULE]: Wrong user account name format {0}. Specify 'First Last'", m_AccountName); | ||
72 | return null; | ||
73 | } | ||
74 | UserAccount account = Scene.UserAccountService.GetUserAccount(UUID.Zero, parts[0], parts[1]); | ||
75 | if (account == null) | ||
76 | { | ||
77 | m_log.WarnFormat("[HG ENTITY TRANSFER MODULE]: Unknown account {0}", m_AccountName); | ||
78 | return null; | ||
79 | } | ||
80 | m_ExportedAppearance = Scene.AvatarService.GetAppearance(account.PrincipalID); | ||
81 | if (m_ExportedAppearance != null) | ||
82 | m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Successfully retrieved appearance for {0}", m_AccountName); | ||
83 | |||
84 | foreach (AvatarAttachment att in m_ExportedAppearance.GetAttachments()) | ||
85 | { | ||
86 | InventoryItemBase item = new InventoryItemBase(att.ItemID, account.PrincipalID); | ||
87 | item = Scene.InventoryService.GetItem(item); | ||
88 | if (item != null) | ||
89 | m_ExportedAppearance.SetAttachment(att.AttachPoint, att.ItemID, item.AssetID); | ||
90 | else | ||
91 | m_log.WarnFormat("[HG ENTITY TRANSFER MODULE]: Unable to retrieve item {0} from inventory", att.ItemID); | ||
92 | } | ||
93 | return m_ExportedAppearance; | ||
94 | } | ||
95 | } | ||
96 | |||
97 | |||
57 | #region ISharedRegionModule | 98 | #region ISharedRegionModule |
58 | 99 | ||
59 | public override string Name | 100 | public override string Name |
@@ -72,8 +113,18 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
72 | { | 113 | { |
73 | IConfig transferConfig = source.Configs["EntityTransfer"]; | 114 | IConfig transferConfig = source.Configs["EntityTransfer"]; |
74 | if (transferConfig != null) | 115 | if (transferConfig != null) |
116 | { | ||
75 | m_levelHGTeleport = transferConfig.GetInt("LevelHGTeleport", 0); | 117 | m_levelHGTeleport = transferConfig.GetInt("LevelHGTeleport", 0); |
76 | 118 | ||
119 | m_RestrictAppearanceAbroad = transferConfig.GetBoolean("RestrictAppearanceAbroad", false); | ||
120 | if (m_RestrictAppearanceAbroad) | ||
121 | { | ||
122 | m_AccountName = transferConfig.GetString("AccountForAppearance", string.Empty); | ||
123 | if (m_AccountName == string.Empty) | ||
124 | m_log.WarnFormat("[HG ENTITY TRANSFER MODULE]: RestrictAppearanceAbroad is on, but no account has been given for avatar appearance!"); | ||
125 | } | ||
126 | } | ||
127 | |||
77 | InitialiseCommon(source); | 128 | InitialiseCommon(source); |
78 | m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: {0} enabled.", Name); | 129 | m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: {0} enabled.", Name); |
79 | } | 130 | } |
@@ -200,6 +251,109 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
200 | TeleportHome(id, client); | 251 | TeleportHome(id, client); |
201 | } | 252 | } |
202 | 253 | ||
254 | protected override bool ValidateGenericConditions(ScenePresence sp, GridRegion reg, GridRegion finalDestination, uint teleportFlags, out string reason) | ||
255 | { | ||
256 | reason = "Please wear your grid's allowed appearance before teleporting to another grid"; | ||
257 | if (!m_RestrictAppearanceAbroad) | ||
258 | return true; | ||
259 | |||
260 | // The rest is only needed for controlling appearance | ||
261 | |||
262 | int flags = Scene.GridService.GetRegionFlags(Scene.RegionInfo.ScopeID, reg.RegionID); | ||
263 | if (flags == -1 /* no region in DB */ || (flags & (int)OpenSim.Data.RegionFlags.Hyperlink) != 0) | ||
264 | { | ||
265 | // this user is going to another grid | ||
266 | if (Scene.UserManagementModule.IsLocalGridUser(sp.UUID)) | ||
267 | { | ||
268 | m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: RestrictAppearanceAbroad is ON. Checking generic appearance"); | ||
269 | |||
270 | // Check wearables | ||
271 | for (int i = 0; i < AvatarWearable.MAX_WEARABLES; i++) | ||
272 | { | ||
273 | for (int j = 0; j < sp.Appearance.Wearables[i].Count; j++) | ||
274 | { | ||
275 | if (sp.Appearance.Wearables[i] == null) | ||
276 | continue; | ||
277 | |||
278 | if (ExportedAppearance.Wearables[i] == null) | ||
279 | { | ||
280 | m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Wearable not allowed to go outside {0}", i); | ||
281 | return false; | ||
282 | } | ||
283 | |||
284 | if (sp.Appearance.Wearables[i][j].AssetID != ExportedAppearance.Wearables[i][j].AssetID) | ||
285 | { | ||
286 | m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Wearable not allowed to go outside {0}", i); | ||
287 | return false; | ||
288 | } | ||
289 | } | ||
290 | } | ||
291 | |||
292 | // Check attachments | ||
293 | |||
294 | foreach (AvatarAttachment att in sp.Appearance.GetAttachments()) | ||
295 | { | ||
296 | bool found = false; | ||
297 | foreach (AvatarAttachment att2 in ExportedAppearance.GetAttachments()) | ||
298 | { | ||
299 | if (att2.AssetID == att.AssetID) | ||
300 | { | ||
301 | found = true; | ||
302 | break; | ||
303 | } | ||
304 | } | ||
305 | if (!found) | ||
306 | { | ||
307 | m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Attachment not allowed to go outside {0}", att.AttachPoint); | ||
308 | return false; | ||
309 | } | ||
310 | } | ||
311 | } | ||
312 | } | ||
313 | |||
314 | reason = string.Empty; | ||
315 | return true; | ||
316 | } | ||
317 | |||
318 | |||
319 | //protected override bool UpdateAgent(GridRegion reg, GridRegion finalDestination, AgentData agentData, ScenePresence sp) | ||
320 | //{ | ||
321 | // int flags = Scene.GridService.GetRegionFlags(Scene.RegionInfo.ScopeID, reg.RegionID); | ||
322 | // if (flags == -1 /* no region in DB */ || (flags & (int)OpenSim.Data.RegionFlags.Hyperlink) != 0) | ||
323 | // { | ||
324 | // // this user is going to another grid | ||
325 | // if (m_RestrictAppearanceAbroad && Scene.UserManagementModule.IsLocalGridUser(agentData.AgentID)) | ||
326 | // { | ||
327 | // // We need to strip the agent off its appearance | ||
328 | // m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: RestrictAppearanceAbroad is ON. Sending generic appearance"); | ||
329 | |||
330 | // // Delete existing npc attachments | ||
331 | // Scene.AttachmentsModule.DeleteAttachmentsFromScene(sp, false); | ||
332 | |||
333 | // // XXX: We can't just use IAvatarFactoryModule.SetAppearance() yet since it doesn't transfer attachments | ||
334 | // AvatarAppearance newAppearance = new AvatarAppearance(ExportedAppearance, true); | ||
335 | // sp.Appearance = newAppearance; | ||
336 | |||
337 | // // Rez needed npc attachments | ||
338 | // Scene.AttachmentsModule.RezAttachments(sp); | ||
339 | |||
340 | |||
341 | // IAvatarFactoryModule module = Scene.RequestModuleInterface<IAvatarFactoryModule>(); | ||
342 | // //module.SendAppearance(sp.UUID); | ||
343 | // module.RequestRebake(sp, false); | ||
344 | |||
345 | // Scene.AttachmentsModule.CopyAttachments(sp, agentData); | ||
346 | // agentData.Appearance = sp.Appearance; | ||
347 | // } | ||
348 | // } | ||
349 | |||
350 | // foreach (AvatarAttachment a in agentData.Appearance.GetAttachments()) | ||
351 | // m_log.DebugFormat("[XXX]: {0}-{1}", a.ItemID, a.AssetID); | ||
352 | |||
353 | |||
354 | // return base.UpdateAgent(reg, finalDestination, agentData, sp); | ||
355 | //} | ||
356 | |||
203 | public override bool TeleportHome(UUID id, IClientAPI client) | 357 | public override bool TeleportHome(UUID id, IClientAPI client) |
204 | { | 358 | { |
205 | m_log.DebugFormat( | 359 | m_log.DebugFormat( |
@@ -375,4 +529,4 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
375 | return region; | 529 | return region; |
376 | } | 530 | } |
377 | } | 531 | } |
378 | } \ No newline at end of file | 532 | } |
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs index cf72b58..a0cad40 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs | |||
@@ -308,6 +308,8 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
308 | protected override InventoryItemBase GetItem(UUID agentID, UUID itemID) | 308 | protected override InventoryItemBase GetItem(UUID agentID, UUID itemID) |
309 | { | 309 | { |
310 | InventoryItemBase item = base.GetItem(agentID, itemID); | 310 | InventoryItemBase item = base.GetItem(agentID, itemID); |
311 | if (item == null) | ||
312 | return null; | ||
311 | 313 | ||
312 | string userAssetServer = string.Empty; | 314 | string userAssetServer = string.Empty; |
313 | if (IsForeignUser(agentID, out userAssetServer)) | 315 | if (IsForeignUser(agentID, out userAssetServer)) |