aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Tools/pCampBot
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2011-11-23 21:19:10 +0000
committerJustin Clark-Casey (justincc)2011-11-23 21:19:10 +0000
commite9f2a9bddbb47ac8c80aeccea0022ad534cbd552 (patch)
tree5d74bb33a073630a45c4dcf3654c91bc1f5093cc /OpenSim/Tools/pCampBot
parentMerge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff)
downloadopensim-SC_OLD-e9f2a9bddbb47ac8c80aeccea0022ad534cbd552.zip
opensim-SC_OLD-e9f2a9bddbb47ac8c80aeccea0022ad534cbd552.tar.gz
opensim-SC_OLD-e9f2a9bddbb47ac8c80aeccea0022ad534cbd552.tar.bz2
opensim-SC_OLD-e9f2a9bddbb47ac8c80aeccea0022ad534cbd552.tar.xz
get pCampBot to extract nearby and store nearby region information
Diffstat (limited to 'OpenSim/Tools/pCampBot')
-rw-r--r--OpenSim/Tools/pCampBot/Bot.cs12
-rw-r--r--OpenSim/Tools/pCampBot/BotManager.cs54
2 files changed, 62 insertions, 4 deletions
diff --git a/OpenSim/Tools/pCampBot/Bot.cs b/OpenSim/Tools/pCampBot/Bot.cs
index 7f941a4..7c16bf4 100644
--- a/OpenSim/Tools/pCampBot/Bot.cs
+++ b/OpenSim/Tools/pCampBot/Bot.cs
@@ -218,7 +218,19 @@ namespace pCampBot
218 { 218 {
219 MakeDefaultAppearance(wear); 219 MakeDefaultAppearance(wear);
220 } 220 }
221
221 Client.Self.Jump(true); 222 Client.Self.Jump(true);
223
224 // Extract nearby region information.
225 Client.Grid.GridRegion += BotManager.Grid_GridRegion;
226 uint xUint, yUint;
227 Utils.LongToUInts(Client.Network.CurrentSim.Handle, out xUint, out yUint);
228 ushort minX, minY, maxX, maxY;
229 minX = (ushort)Math.Min(0, xUint - 5);
230 minY = (ushort)Math.Min(0, yUint - 5);
231 maxX = (ushort)(xUint + 5);
232 maxY = (ushort)(yUint + 5);
233 Client.Grid.RequestMapBlocks(GridLayerType.Terrain, minX, minY, maxX, maxY, false);
222 } 234 }
223 else 235 else
224 { 236 {
diff --git a/OpenSim/Tools/pCampBot/BotManager.cs b/OpenSim/Tools/pCampBot/BotManager.cs
index 056f991..f372f9b 100644
--- a/OpenSim/Tools/pCampBot/BotManager.cs
+++ b/OpenSim/Tools/pCampBot/BotManager.cs
@@ -55,7 +55,7 @@ namespace pCampBot
55 /// Random number generator. 55 /// Random number generator.
56 /// </summary> 56 /// </summary>
57 public Random Rng { get; private set; } 57 public Random Rng { get; private set; }
58 58
59 public IConfig Config { get; private set; } 59 public IConfig Config { get; private set; }
60 60
61 /// <summary> 61 /// <summary>
@@ -64,12 +64,18 @@ namespace pCampBot
64 public Dictionary<UUID, bool> AssetsReceived { get; private set; } 64 public Dictionary<UUID, bool> AssetsReceived { get; private set; }
65 65
66 /// <summary> 66 /// <summary>
67 /// The regions that we know about.
68 /// </summary>
69 public Dictionary<ulong, GridRegion> RegionsKnown { get; private set; }
70
71 /// <summary>
67 /// Constructor Creates MainConsole.Instance to take commands and provide the place to write data 72 /// Constructor Creates MainConsole.Instance to take commands and provide the place to write data
68 /// </summary> 73 /// </summary>
69 public BotManager() 74 public BotManager()
70 { 75 {
71 Rng = new Random(Environment.TickCount); 76 Rng = new Random(Environment.TickCount);
72 AssetsReceived = new Dictionary<UUID, bool>(); 77 AssetsReceived = new Dictionary<UUID, bool>();
78 RegionsKnown = new Dictionary<ulong, GridRegion>();
73 79
74 m_console = CreateConsole(); 80 m_console = CreateConsole();
75 MainConsole.Instance = m_console; 81 MainConsole.Instance = m_console;
@@ -99,6 +105,11 @@ namespace pCampBot
99 "Shutdown bots and exit", 105 "Shutdown bots and exit",
100 HandleShutdown); 106 HandleShutdown);
101 107
108 m_console.Commands.AddCommand("bot", false, "show regions",
109 "show regions",
110 "Show regions known to bots",
111 HandleShowRegions);
112
102 m_console.Commands.AddCommand("bot", false, "show status", 113 m_console.Commands.AddCommand("bot", false, "show status",
103 "show status", 114 "show status",
104 "Shows the status of all bots", 115 "Shows the status of all bots",
@@ -246,17 +257,33 @@ namespace pCampBot
246 }); 257 });
247 } 258 }
248 259
260 private void HandleShowRegions(string module, string[] cmd)
261 {
262 string outputFormat = "{0,-30} {1, -20} {2, -5} {3, -5}";
263 MainConsole.Instance.OutputFormat(outputFormat, "Name", "Handle", "X", "Y");
264
265 lock (RegionsKnown)
266 {
267 foreach (GridRegion region in RegionsKnown.Values)
268 {
269 MainConsole.Instance.OutputFormat(
270 outputFormat, region.Name, region.RegionHandle, region.X, region.Y);
271 }
272 }
273 }
274
249 private void HandleShowStatus(string module, string[] cmd) 275 private void HandleShowStatus(string module, string[] cmd)
250 { 276 {
251 string outputFormat = "{0,-30} {1,-14}"; 277 string outputFormat = "{0,-30} {1, -30} {2,-14}";
252 MainConsole.Instance.OutputFormat(outputFormat, "Name", "Status"); 278 MainConsole.Instance.OutputFormat(outputFormat, "Name", "Region", "Status");
253 279
254 lock (m_lBot) 280 lock (m_lBot)
255 { 281 {
256 foreach (Bot pb in m_lBot) 282 foreach (Bot pb in m_lBot)
257 { 283 {
258 MainConsole.Instance.OutputFormat( 284 MainConsole.Instance.OutputFormat(
259 outputFormat, pb.Name, (pb.IsConnected ? "Connected" : "Disconnected")); 285 outputFormat,
286 pb.Name, pb.Client.Network.CurrentSim.Name, pb.IsConnected ? "Connected" : "Disconnected");
260 } 287 }
261 } 288 }
262 } 289 }
@@ -280,5 +307,24 @@ namespace pCampBot
280// if (newbots > 0) 307// if (newbots > 0)
281// addbots(newbots); 308// addbots(newbots);
282// } 309// }
310
311 internal void Grid_GridRegion(object o, GridRegionEventArgs args)
312 {
313 lock (RegionsKnown)
314 {
315 GridRegion newRegion = args.Region;
316
317 if (RegionsKnown.ContainsKey(newRegion.RegionHandle))
318 {
319 return;
320 }
321 else
322 {
323 m_log.DebugFormat(
324 "[BOT MANAGER]: Adding {0} {1} to known regions", newRegion.Name, newRegion.RegionHandle);
325 RegionsKnown[newRegion.RegionHandle] = newRegion;
326 }
327 }
328 }
283 } 329 }
284} 330}