diff options
author | Justin Clark-Casey (justincc) | 2014-10-28 23:00:49 +0000 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2014-11-25 23:23:09 +0000 |
commit | 3a1ce2715a522dcb1971944af17ad10d2263c7ab (patch) | |
tree | 910296da502f599c8d019c88fdcea7128eff25be /OpenSim/Region/OptionalModules/Avatar | |
parent | Add "wearables show" console command. (diff) | |
download | opensim-SC-3a1ce2715a522dcb1971944af17ad10d2263c7ab.zip opensim-SC-3a1ce2715a522dcb1971944af17ad10d2263c7ab.tar.gz opensim-SC-3a1ce2715a522dcb1971944af17ad10d2263c7ab.tar.bz2 opensim-SC-3a1ce2715a522dcb1971944af17ad10d2263c7ab.tar.xz |
Add "wearables check" console command
This checks that all the wearable assets and any assets for a given logged in avatar exist in the asset service
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/OptionalModules/Avatar/Appearance/AppearanceInfoModule.cs | 96 |
1 files changed, 87 insertions, 9 deletions
diff --git a/OpenSim/Region/OptionalModules/Avatar/Appearance/AppearanceInfoModule.cs b/OpenSim/Region/OptionalModules/Avatar/Appearance/AppearanceInfoModule.cs index 51dfd47..f67f613 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Appearance/AppearanceInfoModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Appearance/AppearanceInfoModule.cs | |||
@@ -51,7 +51,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.Appearance | |||
51 | { | 51 | { |
52 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 52 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
53 | 53 | ||
54 | private Dictionary<UUID, Scene> m_scenes = new Dictionary<UUID, Scene>(); | 54 | private List<Scene> m_scenes = new List<Scene>(); |
55 | |||
55 | // private IAvatarFactoryModule m_avatarFactory; | 56 | // private IAvatarFactoryModule m_avatarFactory; |
56 | 57 | ||
57 | public string Name { get { return "Appearance Information Module"; } } | 58 | public string Name { get { return "Appearance Information Module"; } } |
@@ -83,7 +84,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Appearance | |||
83 | // m_log.DebugFormat("[APPEARANCE INFO MODULE]: REGION {0} REMOVED", scene.RegionInfo.RegionName); | 84 | // m_log.DebugFormat("[APPEARANCE INFO MODULE]: REGION {0} REMOVED", scene.RegionInfo.RegionName); |
84 | 85 | ||
85 | lock (m_scenes) | 86 | lock (m_scenes) |
86 | m_scenes.Remove(scene.RegionInfo.RegionID); | 87 | m_scenes.Remove(scene); |
87 | } | 88 | } |
88 | 89 | ||
89 | public void RegionLoaded(Scene scene) | 90 | public void RegionLoaded(Scene scene) |
@@ -91,7 +92,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Appearance | |||
91 | // m_log.DebugFormat("[APPEARANCE INFO MODULE]: REGION {0} LOADED", scene.RegionInfo.RegionName); | 92 | // m_log.DebugFormat("[APPEARANCE INFO MODULE]: REGION {0} LOADED", scene.RegionInfo.RegionName); |
92 | 93 | ||
93 | lock (m_scenes) | 94 | lock (m_scenes) |
94 | m_scenes[scene.RegionInfo.RegionID] = scene; | 95 | m_scenes.Add(scene); |
95 | 96 | ||
96 | scene.AddCommand( | 97 | scene.AddCommand( |
97 | "Users", this, "show appearance", | 98 | "Users", this, "show appearance", |
@@ -140,6 +141,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.Appearance | |||
140 | "If no avatar name is given then a general summary for all avatars in the scene is shown.\n" | 141 | "If no avatar name is given then a general summary for all avatars in the scene is shown.\n" |
141 | + "If an avatar name is given then specific information about current wearables is shown.", | 142 | + "If an avatar name is given then specific information about current wearables is shown.", |
142 | HandleShowWearablesCommand); | 143 | HandleShowWearablesCommand); |
144 | |||
145 | scene.AddCommand( | ||
146 | "Users", this, "wearables check", | ||
147 | "wearables check <first-name> <last-name>", | ||
148 | "Check that the wearables of a given avatar in the scene are valid.", | ||
149 | "This currently checks that the wearable assets themselves and any assets referenced by them exist.", | ||
150 | HandleCheckWearablesCommand); | ||
143 | } | 151 | } |
144 | 152 | ||
145 | private void HandleSendAppearanceCommand(string module, string[] cmd) | 153 | private void HandleSendAppearanceCommand(string module, string[] cmd) |
@@ -163,7 +171,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Appearance | |||
163 | 171 | ||
164 | lock (m_scenes) | 172 | lock (m_scenes) |
165 | { | 173 | { |
166 | foreach (Scene scene in m_scenes.Values) | 174 | foreach (Scene scene in m_scenes) |
167 | { | 175 | { |
168 | if (targetNameSupplied) | 176 | if (targetNameSupplied) |
169 | { | 177 | { |
@@ -215,7 +223,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Appearance | |||
215 | 223 | ||
216 | lock (m_scenes) | 224 | lock (m_scenes) |
217 | { | 225 | { |
218 | foreach (Scene scene in m_scenes.Values) | 226 | foreach (Scene scene in m_scenes) |
219 | { | 227 | { |
220 | if (targetNameSupplied) | 228 | if (targetNameSupplied) |
221 | { | 229 | { |
@@ -251,7 +259,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Appearance | |||
251 | 259 | ||
252 | lock (m_scenes) | 260 | lock (m_scenes) |
253 | { | 261 | { |
254 | foreach (Scene scene in m_scenes.Values) | 262 | foreach (Scene scene in m_scenes) |
255 | { | 263 | { |
256 | ScenePresence sp = scene.GetScenePresence(firstname, lastname); | 264 | ScenePresence sp = scene.GetScenePresence(firstname, lastname); |
257 | if (sp != null && !sp.IsChildAgent) | 265 | if (sp != null && !sp.IsChildAgent) |
@@ -285,7 +293,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Appearance | |||
285 | 293 | ||
286 | lock (m_scenes) | 294 | lock (m_scenes) |
287 | { | 295 | { |
288 | foreach (Scene scene in m_scenes.Values) | 296 | foreach (Scene scene in m_scenes) |
289 | { | 297 | { |
290 | scene.ForEachRootScenePresence( | 298 | scene.ForEachRootScenePresence( |
291 | sp => | 299 | sp => |
@@ -338,7 +346,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Appearance | |||
338 | { | 346 | { |
339 | lock (m_scenes) | 347 | lock (m_scenes) |
340 | { | 348 | { |
341 | foreach (Scene scene in m_scenes.Values) | 349 | foreach (Scene scene in m_scenes) |
342 | { | 350 | { |
343 | ScenePresence sp = scene.GetScenePresence(optionalTargetFirstName, optionalTargetLastName); | 351 | ScenePresence sp = scene.GetScenePresence(optionalTargetFirstName, optionalTargetLastName); |
344 | if (sp != null && !sp.IsChildAgent) | 352 | if (sp != null && !sp.IsChildAgent) |
@@ -354,7 +362,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Appearance | |||
354 | 362 | ||
355 | lock (m_scenes) | 363 | lock (m_scenes) |
356 | { | 364 | { |
357 | foreach (Scene scene in m_scenes.Values) | 365 | foreach (Scene scene in m_scenes) |
358 | { | 366 | { |
359 | scene.ForEachRootScenePresence( | 367 | scene.ForEachRootScenePresence( |
360 | sp => | 368 | sp => |
@@ -376,6 +384,76 @@ namespace OpenSim.Region.OptionalModules.Avatar.Appearance | |||
376 | MainConsole.Instance.Output(sb.ToString()); | 384 | MainConsole.Instance.Output(sb.ToString()); |
377 | } | 385 | } |
378 | 386 | ||
387 | private void HandleCheckWearablesCommand(string module, string[] cmd) | ||
388 | { | ||
389 | if (cmd.Length != 4) | ||
390 | { | ||
391 | MainConsole.Instance.OutputFormat("Usage: wearables check <first-name> <last-name>"); | ||
392 | return; | ||
393 | } | ||
394 | |||
395 | string firstname = cmd[2]; | ||
396 | string lastname = cmd[3]; | ||
397 | |||
398 | StringBuilder sb = new StringBuilder(); | ||
399 | UuidGatherer uuidGatherer = new UuidGatherer(m_scenes[0].AssetService); | ||
400 | |||
401 | lock (m_scenes) | ||
402 | { | ||
403 | foreach (Scene scene in m_scenes) | ||
404 | { | ||
405 | ScenePresence sp = scene.GetScenePresence(firstname, lastname); | ||
406 | if (sp != null && !sp.IsChildAgent) | ||
407 | { | ||
408 | sb.AppendFormat("Wearables checks for {0}\n\n", sp.Name); | ||
409 | |||
410 | for (int i = (int)WearableType.Shape; i < (int)WearableType.Physics; i++) | ||
411 | { | ||
412 | AvatarWearable aw = sp.Appearance.Wearables[i]; | ||
413 | |||
414 | if (aw.Count > 0) | ||
415 | { | ||
416 | sb.Append(Enum.GetName(typeof(WearableType), i)); | ||
417 | sb.Append("\n"); | ||
418 | |||
419 | for (int j = 0; j < aw.Count; j++) | ||
420 | { | ||
421 | WearableItem wi = aw[j]; | ||
422 | |||
423 | ConsoleDisplayList cdl = new ConsoleDisplayList(); | ||
424 | cdl.Indent = 2; | ||
425 | cdl.AddRow("Item UUID", wi.ItemID); | ||
426 | cdl.AddRow("Assets", ""); | ||
427 | sb.Append(cdl.ToString()); | ||
428 | |||
429 | Dictionary<UUID, sbyte> assetUuids = new Dictionary<UUID, sbyte>(); | ||
430 | uuidGatherer.GatherAssetUuids(wi.AssetID, assetUuids); | ||
431 | string[] assetStrings | ||
432 | = Array.ConvertAll<UUID, string>(assetUuids.Keys.ToArray(), u => u.ToString()); | ||
433 | |||
434 | bool[] existChecks = scene.AssetService.AssetsExist(assetStrings); | ||
435 | |||
436 | ConsoleDisplayTable cdt = new ConsoleDisplayTable(); | ||
437 | cdt.Indent = 4; | ||
438 | cdt.AddColumn("Type", 10); | ||
439 | cdt.AddColumn("UUID", ConsoleDisplayUtil.UuidSize); | ||
440 | cdt.AddColumn("Found", 5); | ||
441 | |||
442 | for (int k = 0; k < existChecks.Length; k++) | ||
443 | cdt.AddRow((AssetType)assetUuids[new UUID(assetStrings[k])], assetStrings[k], existChecks[k] ? "yes" : "no"); | ||
444 | |||
445 | sb.Append(cdt.ToString()); | ||
446 | sb.Append("\n"); | ||
447 | } | ||
448 | } | ||
449 | } | ||
450 | } | ||
451 | } | ||
452 | } | ||
453 | |||
454 | MainConsole.Instance.Output(sb.ToString()); | ||
455 | } | ||
456 | |||
379 | private void AppendWearablesDetailReport(ScenePresence sp, StringBuilder sb) | 457 | private void AppendWearablesDetailReport(ScenePresence sp, StringBuilder sb) |
380 | { | 458 | { |
381 | sb.AppendFormat("\nWearables for {0}\n", sp.Name); | 459 | sb.AppendFormat("\nWearables for {0}\n", sp.Name); |