public ExportCommand(BotClient testClient)
            : base(testClient)
        {
            Exporting = this;
            // testClient.Objects.ObjectPropertiesFamily += new EventHandler<ObjectPropertiesFamilyEventArgs>(Objects_OnObjectPropertiesFamily);

            //testClient.Objects.ObjectProperties += new EventHandler<ObjectPropertiesEventArgs>(Objects_OnObjectProperties);
            //testClient.Avatars.ViewerEffectPointAt += new EventHandler<ViewerEffectPointAtEventArgs>(Avatars_ViewerEffectPointAt);
            //SClient = SClient ?? testClient;
            if (!Directory.Exists(dumpDir))
            {
                Directory.CreateDirectory(dumpDir);
            }
            if (!Directory.Exists(assetDumpDir))
            {
                Directory.CreateDirectory(assetDumpDir);
            }
            if (!Directory.Exists(terrainDir))
            {
                Directory.CreateDirectory(terrainDir);
            }
            if (!Directory.Exists(siminfoDir))
            {
                Directory.CreateDirectory(siminfoDir);
            }

            testClient.Self.ChatFromSimulator += listen_for_relay;
            ListenForRelay += listen_forLinkset;
            ListenForRelay += listen_TaskInv;
            testClient.Assets.XferReceived          += Asset_Xfer;
            testClient.Groups.GroupNamesReply       += GroupNames;
            testClient.Avatars.UUIDNameReply        += UserNames;
            testClient.Inventory.ScriptRunningReply += On_ScriptRunningReply;
            Name        = "simexport";
            Description = "Exports an object to an xml file. Usage: simexport exportPrim-spec directory";
            Category    = CommandCategory.Objects;
            if (!Incremental)
            {
                lock (fileWriterLock) PurgeExport();
            }
            ///onlyObjectAt.AddPoint(new Vector3(-256, -256, -256));
            ///onlyObjectAt.AddPoint(new Vector3(512, 512, 9024));
            onlyObjectAt.AddPoint(new Vector3(-256, -256, 90));
            onlyObjectAt.AddPoint(new Vector3(512, 512, 200));
        }
        internal bool ChangeConstraints(Vector3 loc, float BumpConstraint)
        {
            Box3Fill B = new Box3Fill(true);

            B.AddPoint(loc.X, loc.Y, loc.Z, new Vector3(2f, 2f, 5f));
            RefreshMatrix(B, BumpConstraint);
            //GlobalBumpConstraint = BumpConstraint;
            BumpConstraintPurple = BumpConstraint;
            return(true);
        }
 private void BeenTo(Vector3 at3d)
 {
     haveBeenTo.AddPoint(at3d);
     lock (moveToPoints) foreach (Vector3 point in LockInfo.CopyOf(moveToPoints))
         {
             if (Vector3.Distance(point, at3d) < 8)
             {
                 moveToPoints.Remove(point);
             }
         }
 }
Exemplo n.º 4
0
        public void RemoveFromWaypoints(Box3Fill changed)
        {
            float detail = PathStore.StepSize;// -0.001f;
            float MinX = OuterBox.MinX;
            float MaxX = OuterBox.MaxX;
            float MinY = OuterBox.MinY;
            float MaxY = OuterBox.MaxY;

            float MinZ = OuterBox.MinZ;
            float MaxZ = OuterBox.MaxZ;

            changed.AddPoint(MinX, MinY, MinZ, Vector3.Zero);
            changed.AddPoint(MaxX, MaxY, MaxZ, Vector3.Zero);

            for (float x = MinX; x <= MaxX; x += detail)
            {
                for (float y = MinY; y <= MaxY; y += detail)
                {
                    RemoveFromWaypoint(x, y, MinZ, MaxZ);
                }
            }
            RemoveFromWaypoint(MaxX, MaxY, MinZ, MaxZ);
        }
Exemplo n.º 5
0
 internal bool ChangeConstraints(Vector3 loc, float BumpConstraint)
 {   
     Box3Fill B = new Box3Fill(true);
     B.AddPoint(loc.X,loc.Y,loc.Z,new Vector3(2f,2f,5f));
     RefreshMatrix(B, BumpConstraint);
     //GlobalBumpConstraint = BumpConstraint;
     BumpConstraintPurple = BumpConstraint;
     return true;
 }
        public CmdResult Execute(string[] args, UUID fromAgentID, OutputDelegate WriteLine)
        {
            Client.Self.Movement.Camera.Far = 1023;
            Client.Self.Movement.SendUpdate(true);
            Exporting   = this;
            IsExporting = true;
            var CurSim = Client.Network.CurrentSim;

            RegionHandle = CurSim.Handle;
            haveBeenTo.AddPoint(TheSimAvatar.SimPosition);
            AttemptSitMover();
            WorldObjects.MaintainSimObjectInfoMap          = false;
            SimObjectImpl.AffordinancesGuessSimObjectTypes = false;
            WorldSystem.IgnoreKillObjects = true;
            inventoryHolder.Clear();
            lslScripts.Clear();
            successfullyExportedPrims.Clear();
            const string hlp = @"
            
            Toplevel Directives

            // todo  = shows what must be done for export to be complete (suggest adding verbose)
            // perms  = shows what perms are going to be a problem (suggest adding verbose)
            // clear - clear the export dir
            // reset - reset the exporter state
            // cache - blow away asset cache
            // move - begin moving arround
            // nomove - stop moving arround

            // spec [spec] - do only prims meeting spec (default is 'spec $region') 
            // incr - do only do what is 'todo'
            // nonincr - do things 'todo' but also 'redo' things already done

            // noperms = dont skip things when perms might be a problem
            // quietly = terser output
            // verbose = more verbose
            // request = will rerequest missing things like textures
            // force = will allow unequal LLSD files - this should only be used as last resort

            // users - users files 
            // groups - groups files 
            // terrain - terrain files 
            // parcels - parcels files 
            // estate - estate files (TODO)
            // siminfo - estate files (TODO)
            // llsd - llsd files 
            // links - operate on linset
            // deps - operate on dependant assets
            // dl - operate on dependant downloads
            // tasks - save task files
            // taskobj - task objects
            // all = llsd tasks deps links (dl and taskobj not included)

           
            ";

            if (args == null || args.Length == 0)
            {
                return(Failure(hlp));
            }
            string[]       nargs   = { "$region" };
            ImportSettings arglist = new ImportSettings
            {
                CurSim  = Client.Network.CurrentSim,
                GroupID = Client.Self.ActiveGroup
            };

            settings = arglist;
            if (args[0] == "hhp")
            {
                args = new string[] { "taskobjs", "nobuf", "all", "spec", "f0a89a9f-3f33-b2aa-2829-eaeec3d08b82" };
            }
            foreach (string s in args)
            {
                arglist.Add(s);
            }
            if (arglist.Contains("error"))
            {
                return(WriteErrors(args));
            }
            if (arglist.Contains("help"))
            {
                return(Success(hlp));
            }
            if (args.Length > 1)
            {
                int specIndex = Array.IndexOf(args, "spec");
                if (specIndex > 0)
                {
                    nargs = Parser.SplitOff(args, specIndex + 1);
                }

                int fnd = Array.IndexOf(args, "move");
                if (fnd > -1 && (fnd + 1 < args.Length))
                {
                    int mv;
                    if (int.TryParse(args[fnd + 1], out mv))
                    {
                        moveSleep = mv;
                        if ((fnd + 2 < args.Length) && int.TryParse(args[fnd + 2], out mv))
                        {
                            maxHeigth = mv;
                        }
                    }
                }
            }
            if (arglist.Contains("move"))
            {
                if (arglist.Contains("wps"))
                {
                    AddRegionWaypoints();
                }

                BeginMoving();
                GiveStatus();
                return(Success("Began moving"));
            }
            if (arglist.Contains("nomove"))
            {
                StopMoving();
                GiveStatus();
                return(Success("Stopped moving"));
            }
            quietly = arglist.Contains("quietly");
            if (arglist.Contains("prim"))
            {
                arglist.Add("llsd");
                arglist.Add("dep");
                arglist.Add("link");
            }
            if (arglist.Contains("all"))
            {
                arglist.Add("llsd");
                arglist.Add("task");
                arglist.Add("dep");
                arglist.Add("link");
            }

            needFiles = 0;
            taskobj   = arglist.Contains("taskobj");
            forced    = arglist.Contains("force") || arglist.Contains("forced");
            if (arglist.Contains("nonincr"))
            {
                Incremental = false;
            }
            if (arglist.Contains("incr"))
            {
                Incremental = true;
            }
            bool fileOnly = false;

            lock (fileWriterLock)
            {
                if (arglist.Contains("clear"))
                {
                    KillAllUnpacked(WriteLine, true);
                    PurgeExport();
                    arglist.Add("reset");
                }

                if (!Directory.Exists(dumpDir))
                {
                    Directory.CreateDirectory(dumpDir);
                }
                if (!Directory.Exists(assetDumpDir))
                {
                    Directory.CreateDirectory(assetDumpDir);
                }
                if (!Directory.Exists(terrainDir))
                {
                    Directory.CreateDirectory(terrainDir);
                }
                if (!Directory.Exists(siminfoDir))
                {
                    Directory.CreateDirectory(siminfoDir);
                }

                if (arglist.Contains("cache"))
                {
                    fileOnly = true;
                    PurgeCache();
                }
            }
            if (arglist.Contains("reset"))
            {
                slowlyExport.Clear();
                lock (ToDownloadAssets) ToDownloadAssets.Clear();
                lock (CompletedAssets) CompletedAssets.Clear();
                lock (PrimWaitingLinkset) PrimWaitingLinkset.Clear();
                lock (AllRelatedAssets) AllRelatedAssets.Clear();
                lock (PrimDepsAssets) PrimDepsAssets.Clear();
                lock (TaskAssetWaiting) TaskAssetWaiting.Clear();
                lock (CompletedTaskItem) CompletedTaskItem.Clear();
#if OBJECTUNPACKER
                lock (TasksRezed) TasksRezed.Clear();
#endif
                GiveStatus();
                return(Success("Reset SimExport State"));
            }

            if (fileOnly)
            {
                GiveStatus();
                return(Success("Manipulated filesystem"));
            }

            if (arglist.Contains("cleanup"))
            {
                return(CleanupAfterExport(fromAgentID, WriteLine));
            }
            if (arglist.Contains("killtasks"))
            {
                KillAllUnpacked(WriteLine, true);
                return(SuccessOrFailure());
            }
            IsExporting = true;
            FolderCalled("TaskInvHolder");
            //string file = args[args.Length - 1];
            int used;
            List <SimObject> PS = WorldSystem.GetPrimitives(nargs, out used);
            if (IsEmpty(PS))
            {
                return(Failure("Cannot find objects from " + string.Join(" ", args)));
            }
            showsStatus      = arglist.Contains("statu");
            showPermsOnly    = arglist.Contains("perm");
            skipPerms        = !arglist.Contains("obeyperm");
            showsMissingOnly = arglist.Contains("todo");
            if (showsMissingOnly)
            {
                quietly = true;
            }
            verbosely = arglist.Contains("verbose");
            if (verbosely && !arglist.Contains("quietly"))
            {
                quietly = false;
            }
            int missing   = 0;
            var canExport = new List <SimObject>();
            int objects   = 0;
            if (arglist.Contains("terrain"))
            {
                SaveTerrainHeight(arglist);
                StartTerrainDownload(arglist);
            }
            if (arglist.Contains("parcel"))
            {
                SaveParcelInfoCommand(arglist);
            }
            bool primsAtAll = arglist.Contains("link") || arglist.Contains("task") || arglist.Contains("llsd") ||
                              arglist.Contains("taskobj") || arglist.Contains("all");
            bool wasShouldBeMoving = shouldBeMoving;
            if (primsAtAll)
            {
                shouldBeMoving = false;
            }
            if (arglist.Contains("nobuf"))
            {
                PSBuf.Clear();
            }
            PSBuf.AddRange(PS);
            lock (Importing.MustExport)
            {
                foreach (UUID id in LockInfo.CopyOf(Importing.MustExport))
                {
                    var o = WorldObjects.GetSimObjectFromUUID(id);
                    if (o != null)
                    {
                        PSBuf.Add(o);
                    }
                }
            }

            foreach (var P in PSBuf)
            {
                if (!primsAtAll)
                {
                    break;
                }
                if (string.IsNullOrEmpty(IsComplete(P.ID, false, false, arglist)))
                {
                    continue;
                }
                // skip attachments and avatars
                if (IsSkipped(P, arglist))
                {
                    continue;
                }
                if (!P.HasPrim)
                {
                    if (!quietly)
                    {
                        Failure("Missing Prim: " + named(P));
                    }
                    continue;
                }
                if (P.RegionHandle != RegionHandle)
                {
                    continue;
                }

                Vector3 sp;
                if (!P.TryGetSimPosition(out sp))
                {
                    continue;
                }

                objects++;
                string issues = P.MissingData;
                if (!string.IsNullOrEmpty(issues) && !arglist.Allows(issues, P))
                {
                    missing++;
                    if (!quietly)
                    {
                        Failure("Issues " + issues + " " + named(P));
                    }
                    continue;
                }

                bool exportPossible =
                    checkPerms(Client, P, showPermsOnly ? (OutputDelegate)LocalFailure : SilientFailure, false) || skipPerms;
                if (exportPossible)
                {
                    SnagUsers(P);
                    canExport.Add(P);
                }
            }

            Success("Can export " + canExport.Count + " of " + objects);
            if (showPermsOnly)
            {
                return(Success("Shown perms"));
            }

            foreach (var P in canExport)
            {
                if (!primsAtAll)
                {
                    break;
                }
                if (P is SimAvatar)
                {
                    continue;
                }
                // skip attachments
                if (P.Parent is SimAvatar)
                {
                    continue;
                }
                string issues = P.MissingData;
                if (!string.IsNullOrEmpty(issues) && !arglist.Allows(issues, P))
                {
                    continue;
                }
                //if (exportedPrims.Contains(P)) continue;
                LocalFailures = 0;
                PrimDepsAssets.Clear();
                ExportPrim(Client, P, LocalFailure, arglist);
                if (P.IsRoot)
                {
                    float pSimPositionZ = P.SimPosition.Z;
                    if (pSimPositionZ > maxHeigth)
                    {
                        maxHeigth = pSimPositionZ + 10;
                    }
                    seenObjectsAt.AddPoint(P.SimPosition);
                }
                if (LocalFailures == 0)
                {
                    if (!successfullyExportedPrims.Contains(P))
                    {
                        successfullyExportedPrims.Add(P);
                    }
                }
            }
            ExportRelatedAssets();
            if (showsStatus)
            {
                arglist.Add("link");
                arglist.Add("task");
                arglist.Add("llsd");
            }

            if (arglist.Contains("link"))
            {
                // lock (PrimWaitingLinkset)
                {
                    foreach (var pa in LockInfo.CopyOf(PrimWaitingLinkset))
                    {
                        var exportPrim = pa.Value.O;
                        if (verbosely)
                        {
                            Failure("Awaiting Linkset " + named(exportPrim));
                        }
                        if (arglist.Contains("request"))
                        {
                            RequestLinksetInfo(Client, Path.Combine(dumpDir, exportPrim.ID.ToString()), exportPrim,
                                               WriteLine, arglist);
                        }
                    }
                }
            }

            if (arglist.Contains("task"))
            {
                lock (TaskAssetWaiting)
                {
                    foreach (var pa in LockInfo.CopyOf(TaskAssetWaiting))
                    {
                        UUID assetID = pa.Value.SourceItem.AssetUUID;
                        if (!CogbotHelpers.IsNullOrZero(assetID))
                        {
                            if (CompletedAssets.Contains(assetID))
                            {
                                int count = TaskAssetWaiting.Count;
                                TaskAssetWaiting.Remove(pa.Key);
                                if (TaskAssetWaiting.Count != count - 1)
                                {
                                    Failure("VERY BAD!");
                                }
                            }
                        }
                        if (verbosely)
                        {
                            Failure("Awaiting TaskAsset " + pa.Value);
                        }
                        if (arglist.Contains("request"))
                        {
                            pa.Value.Request();
                        }
                    }
                }
            }
            ExportRelatedAssets();
            foreach (var assetID in LockInfo.CopyOf(ToDownloadAssets))
            {
                PingAssetCache(assetID);
            }

            if (arglist.Contains("dl"))
            {
                foreach (var assetID in LockInfo.CopyOf(ToDownloadAssets))
                {
                    AssetType assetType = assetTypeOf(assetID);
                    if (verbosely)
                    {
                        Failure("Awaiting DL " + assetID + " " + assetType);
                    }
                    if (arglist.Contains("request"))
                    {
                        StartAssetDownload(null, assetID, assetType);
                    }
                }
            }
            if (arglist.Contains("user"))
            {
                RequestUsersAndGroups();
            }
            if (arglist.Contains("siprim"))
            {
                foreach (SimObject o in LockInfo.CopyOf(SIPrims))
                {
                    if (o.Prim.ParentID == 0)
                    {
                        Client.Inventory.RequestDeRezToInventory(o.LocalID, DeRezDestination.AgentInventoryCopy,
                                                                 FolderCalled("UseSIForCompleteness"), UUID.Random());
                    }
                    else
                    {
                        Failure("Child SIPrim " + o);
                    }
                }
            }
            Success("Missing PrimData: " + missing);
            Success("Started XFERS " + ToDownloadCalledAssets.Count + " assets");
            shouldBeMoving = wasShouldBeMoving;
            GiveStatus();
            if (primsAtAll)
            {
                shouldBeMoving = wasShouldBeMoving;
            }
            return(Success("Done"));
        }