aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs')
-rw-r--r--OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs156
1 files changed, 155 insertions, 1 deletions
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}