2007-11-06 09:26:10 +00:00
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2021-07-25 11:10:52 -05:00
|
|
|
using System.Linq;
|
2007-11-06 09:26:10 +00:00
|
|
|
using System.Text;
|
|
|
|
|
|
2008-07-21 21:12:59 +00:00
|
|
|
namespace OpenMetaverse.TestClient
|
2007-11-06 09:26:10 +00:00
|
|
|
{
|
2008-05-01 20:58:20 +00:00
|
|
|
/// <summary>
|
|
|
|
|
/// Display a list of all agent locations in a specified region
|
|
|
|
|
/// </summary>
|
2007-11-06 09:26:10 +00:00
|
|
|
public class AgentLocationsCommand : Command
|
|
|
|
|
{
|
|
|
|
|
public AgentLocationsCommand(TestClient testClient)
|
|
|
|
|
{
|
|
|
|
|
Name = "agentlocations";
|
|
|
|
|
Description = "Downloads all of the agent locations in a specified region. Usage: agentlocations [regionhandle]";
|
2008-07-25 08:55:36 +00:00
|
|
|
Category = CommandCategory.Simulator;
|
2007-11-06 09:26:10 +00:00
|
|
|
}
|
|
|
|
|
|
2008-07-25 05:15:05 +00:00
|
|
|
public override string Execute(string[] args, UUID fromAgentID)
|
2007-11-06 09:26:10 +00:00
|
|
|
{
|
|
|
|
|
ulong regionHandle;
|
|
|
|
|
|
|
|
|
|
if (args.Length == 0)
|
|
|
|
|
regionHandle = Client.Network.CurrentSim.Handle;
|
2022-02-25 19:38:11 -06:00
|
|
|
else if (!(args.Length == 1 && ulong.TryParse(args[0], out regionHandle)))
|
2007-11-06 09:26:10 +00:00
|
|
|
return "Usage: agentlocations [regionhandle]";
|
|
|
|
|
|
2009-10-19 08:21:41 +00:00
|
|
|
List<MapItem> items = Client.Grid.MapItems(regionHandle, GridItemType.AgentLocations,
|
2025-01-13 07:44:05 -06:00
|
|
|
GridLayerType.Objects, TimeSpan.FromSeconds(20));
|
2007-11-06 09:26:10 +00:00
|
|
|
|
|
|
|
|
if (items != null)
|
|
|
|
|
{
|
|
|
|
|
StringBuilder ret = new StringBuilder();
|
|
|
|
|
ret.AppendLine("Agent locations:");
|
|
|
|
|
|
2021-07-25 11:10:52 -05:00
|
|
|
foreach (var location in items.Cast<MapAgentLocation>())
|
2007-11-06 09:26:10 +00:00
|
|
|
{
|
2021-07-25 11:10:52 -05:00
|
|
|
ret.AppendLine($"{location.AvatarCount} avatar(s) at {location.LocalX},{location.LocalY}");
|
2007-11-06 09:26:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ret.ToString();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return "Failed to fetch agent locations";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|