From a62bff5fa6356a8fd92d017b443855ffac7282fb Mon Sep 17 00:00:00 2001 From: Madpeter <57852827+Madpeterz@users.noreply.github.com> Date: Sun, 21 Jul 2024 00:16:09 +0100 Subject: [PATCH] GetSimParcelLayers --- BetterSecondBot.sln | 1 + SecondBotEvents/Commands/ParcelCommands.cs | 93 +++++++++++++++++++++- 2 files changed, 92 insertions(+), 2 deletions(-) diff --git a/BetterSecondBot.sln b/BetterSecondBot.sln index fcdd3f4..15e0b3f 100644 --- a/BetterSecondBot.sln +++ b/BetterSecondBot.sln @@ -10,6 +10,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Project Items", "Project It .dockerignore = .dockerignore .gitignore = .gitignore SecondBotEvents\Dockerfile = SecondBotEvents\Dockerfile + github.autobuild.yml = github.autobuild.yml NuGet.Config = NuGet.Config oldDockerfile = oldDockerfile README.md = README.md diff --git a/SecondBotEvents/Commands/ParcelCommands.cs b/SecondBotEvents/Commands/ParcelCommands.cs index 8abaa98..7b7fa77 100644 --- a/SecondBotEvents/Commands/ParcelCommands.cs +++ b/SecondBotEvents/Commands/ParcelCommands.cs @@ -1,5 +1,6 @@ using Newtonsoft.Json; using OpenMetaverse; +using OpenMetaverse.ImportExport.Collada14; using SecondBotEvents.Services; using Swan; using System; @@ -8,6 +9,7 @@ using System.Linq; using System.Threading; using static OpenMetaverse.DirectoryManager; using static OpenMetaverse.ParcelManager; +using static OpenMetaverse.Stats.UtilizationStatistics; namespace SecondBotEvents.Commands { @@ -25,7 +27,6 @@ namespace SecondBotEvents.Commands public int currentprims; public string startbox; public string endbox; - public byte[] bitmap; } [ClassInfo("Control the land under our feet")] @@ -55,6 +56,95 @@ namespace SecondBotEvents.Commands return BasicReply(JsonConvert.SerializeObject(reply)); } + [About("requests the parcel layout as a SVG\n call UpdateListOfParcels first to update list before calling")] + [ReturnHints("json encoded svg")] + public object GetSimParcelLayers() + { + Dictionary data = GetClient().Network.CurrentSim.Parcels.Copy(); + Dictionary parcelbox = new Dictionary(); + uint SimWidth = GetClient().Network.CurrentSim.SizeX; + uint SimHeight = GetClient().Network.CurrentSim.SizeY; + Dictionary maps = new Dictionary(); + + + int lastparcelid = 0; + uint lowX = 0; + uint lowY = 0; + Random rnd = new Random(); + uint startX = 4; + string svg = ""; + uint boxheight = 0; + var color = ""; + Parcel P = null; + string parcelname = "?"; + int checkparcel = GetClient().Parcels.GetParcelLocalID(GetClient().Network.CurrentSim, new Vector3(startX, 4, 20)); + while (startX < SimWidth) + { + uint startY = 4; + while (startY < SimHeight) + { + checkparcel = GetClient().Parcels.GetParcelLocalID(GetClient().Network.CurrentSim, new Vector3(startX, startY, 20)); + if ((checkparcel != lastparcelid) || (startY >= SimHeight)) + { + if(lastparcelid == 0) + { + lastparcelid = checkparcel; + lowX = startX - 4; + lowY = startY - 4; + } + else + { + boxheight = (startY-4) - lowY; + color = ""; + if (maps.ContainsKey(lastparcelid) == false) + { + color = "rgb(" + rnd.Next(0, 256) + "," + rnd.Next(0, 256) + ",125)"; + maps.Add(lastparcelid, color); + } + else + { + color = maps[lastparcelid]; + } + parcelname = "?"; + if (data.ContainsKey(lastparcelid) == true) + { + P = GetClient().Network.CurrentSim.Parcels[lastparcelid]; + parcelname = P.Name; + } + svg = svg + ""; + lastparcelid = checkparcel; + lowX = startX - 4; + lowY = startY - 4; + } + } + startY += 4; + } + boxheight = (startY - 8) - lowY; + color = ""; + if (maps.ContainsKey(lastparcelid) == false) + { + color = "rgb(" + rnd.Next(0, 256) + "," + rnd.Next(0, 256) + ",125)"; + maps.Add(lastparcelid, color); + } + else + { + color = maps[lastparcelid]; + } + parcelname = "?"; + if (data.ContainsKey(lastparcelid) == true) + { + P = GetClient().Network.CurrentSim.Parcels[lastparcelid]; + parcelname = P.Name; + } + svg = svg + ""; + lastparcelid = 0; + startX += 4; + } + svg = svg + ""; + return BasicReply(svg); + } + + [About("Requests a packet blob for the parcels in the current sim\n call UpdateListOfParcels first to update list before calling")] [ReturnHints("json encoded object")] public object GetListOfParcels() @@ -77,7 +167,6 @@ namespace SecondBotEvents.Commands R.currentprims = A.TotalPrims; R.maxprims = A.MaxPrims; R.name = A.Name; - R.bitmap = A.Bitmap; reply.parcels.Add(R); } return BasicReply(JsonConvert.SerializeObject(reply));