diff options
author | Diva Canto | 2012-09-15 19:33:51 -0700 |
---|---|---|
committer | Diva Canto | 2012-09-15 19:33:51 -0700 |
commit | de69a24574786f7517e8dc3be62e413f9e0fae22 (patch) | |
tree | cd70b7896e636dcd342deef926ddd496c4fd408a /OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs | |
parent | Merge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff) | |
download | opensim-SC_OLD-de69a24574786f7517e8dc3be62e413f9e0fae22.zip opensim-SC_OLD-de69a24574786f7517e8dc3be62e413f9e0fae22.tar.gz opensim-SC_OLD-de69a24574786f7517e8dc3be62e413f9e0fae22.tar.bz2 opensim-SC_OLD-de69a24574786f7517e8dc3be62e413f9e0fae22.tar.xz |
More on HG2.0: added the possibility of controlling the appearance that avies use to visit other grids. Not as good as I wanted, but good enough. Unfortunately we can't switch the appearance from under the avie without getting into a lot of weirdnesses because appearance is viewer-controlled. So instead, when this control is on, I'm disallowing HG-TP unless the user is wearing an allowed HG appearance -- the user gets a warning and needs to switch appearance. WARNING: I'm still not committing the config vars because this is still not ready for ppl to test.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs | 154 |
1 files changed, 154 insertions, 0 deletions
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs index 08863c2..f3c5873 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 | } |
@@ -195,6 +246,109 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
195 | return base.CreateAgent(sp, reg, finalDestination, agentCircuit, teleportFlags, out reason, out logout); | 246 | return base.CreateAgent(sp, reg, finalDestination, agentCircuit, teleportFlags, out reason, out logout); |
196 | } | 247 | } |
197 | 248 | ||
249 | protected override bool ValidateGenericConditions(ScenePresence sp, GridRegion reg, GridRegion finalDestination, uint teleportFlags, out string reason) | ||
250 | { | ||
251 | reason = "Please wear your grid's allowed appearance before teleporting to another grid"; | ||
252 | if (!m_RestrictAppearanceAbroad) | ||
253 | return true; | ||
254 | |||
255 | // The rest is only needed for controlling appearance | ||
256 | |||
257 | int flags = Scene.GridService.GetRegionFlags(Scene.RegionInfo.ScopeID, reg.RegionID); | ||
258 | if (flags == -1 /* no region in DB */ || (flags & (int)OpenSim.Data.RegionFlags.Hyperlink) != 0) | ||
259 | { | ||
260 | // this user is going to another grid | ||
261 | if (Scene.UserManagementModule.IsLocalGridUser(sp.UUID)) | ||
262 | { | ||
263 | m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: RestrictAppearanceAbroad is ON. Checking generic appearance"); | ||
264 | |||
265 | // Check wearables | ||
266 | for (int i = 0; i < AvatarWearable.MAX_WEARABLES; i++) | ||
267 | { | ||
268 | for (int j = 0; j < sp.Appearance.Wearables[i].Count; j++) | ||
269 | { | ||
270 | if (sp.Appearance.Wearables[i] == null) | ||
271 | continue; | ||
272 | |||
273 | if (ExportedAppearance.Wearables[i] == null) | ||
274 | { | ||
275 | m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Wearable not allowed to go outside {0}", i); | ||
276 | return false; | ||
277 | } | ||
278 | |||
279 | if (sp.Appearance.Wearables[i][j].AssetID != ExportedAppearance.Wearables[i][j].AssetID) | ||
280 | { | ||
281 | m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Wearable not allowed to go outside {0}", i); | ||
282 | return false; | ||
283 | } | ||
284 | } | ||
285 | } | ||
286 | |||
287 | // Check attachments | ||
288 | |||
289 | foreach (AvatarAttachment att in sp.Appearance.GetAttachments()) | ||
290 | { | ||
291 | bool found = false; | ||
292 | foreach (AvatarAttachment att2 in ExportedAppearance.GetAttachments()) | ||
293 | { | ||
294 | if (att2.AssetID == att.AssetID) | ||
295 | { | ||
296 | found = true; | ||
297 | break; | ||
298 | } | ||
299 | } | ||
300 | if (!found) | ||
301 | { | ||
302 | m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Attachment not allowed to go outside {0}", att.AttachPoint); | ||
303 | return false; | ||
304 | } | ||
305 | } | ||
306 | } | ||
307 | } | ||
308 | |||
309 | reason = string.Empty; | ||
310 | return true; | ||
311 | } | ||
312 | |||
313 | |||
314 | //protected override bool UpdateAgent(GridRegion reg, GridRegion finalDestination, AgentData agentData, ScenePresence sp) | ||
315 | //{ | ||
316 | // int flags = Scene.GridService.GetRegionFlags(Scene.RegionInfo.ScopeID, reg.RegionID); | ||
317 | // if (flags == -1 /* no region in DB */ || (flags & (int)OpenSim.Data.RegionFlags.Hyperlink) != 0) | ||
318 | // { | ||
319 | // // this user is going to another grid | ||
320 | // if (m_RestrictAppearanceAbroad && Scene.UserManagementModule.IsLocalGridUser(agentData.AgentID)) | ||
321 | // { | ||
322 | // // We need to strip the agent off its appearance | ||
323 | // m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: RestrictAppearanceAbroad is ON. Sending generic appearance"); | ||
324 | |||
325 | // // Delete existing npc attachments | ||
326 | // Scene.AttachmentsModule.DeleteAttachmentsFromScene(sp, false); | ||
327 | |||
328 | // // XXX: We can't just use IAvatarFactoryModule.SetAppearance() yet since it doesn't transfer attachments | ||
329 | // AvatarAppearance newAppearance = new AvatarAppearance(ExportedAppearance, true); | ||
330 | // sp.Appearance = newAppearance; | ||
331 | |||
332 | // // Rez needed npc attachments | ||
333 | // Scene.AttachmentsModule.RezAttachments(sp); | ||
334 | |||
335 | |||
336 | // IAvatarFactoryModule module = Scene.RequestModuleInterface<IAvatarFactoryModule>(); | ||
337 | // //module.SendAppearance(sp.UUID); | ||
338 | // module.RequestRebake(sp, false); | ||
339 | |||
340 | // Scene.AttachmentsModule.CopyAttachments(sp, agentData); | ||
341 | // agentData.Appearance = sp.Appearance; | ||
342 | // } | ||
343 | // } | ||
344 | |||
345 | // foreach (AvatarAttachment a in agentData.Appearance.GetAttachments()) | ||
346 | // m_log.DebugFormat("[XXX]: {0}-{1}", a.ItemID, a.AssetID); | ||
347 | |||
348 | |||
349 | // return base.UpdateAgent(reg, finalDestination, agentData, sp); | ||
350 | //} | ||
351 | |||
198 | public override void TeleportHome(UUID id, IClientAPI client) | 352 | public override void TeleportHome(UUID id, IClientAPI client) |
199 | { | 353 | { |
200 | m_log.DebugFormat( | 354 | m_log.DebugFormat( |