Exemplo n.º 1
0
        public override CmdResult ExecuteRequest(CmdRequest args)
        {
            // Get the agent's current "patch" position, where each patch of
            // wind data is a 16x16m square
            int         argsUsed;
            SimPosition aPos     = WorldSystem.GetVector(args, out argsUsed);
            Vector3     agentPos = aPos.SimPosition;
            int         xPos     = (int)Utils.Clamp(agentPos.X, 0.0f, 255.0f) / 16;
            int         yPos     = (int)Utils.Clamp(agentPos.Y, 0.0f, 255.0f) / 16;
            Simulator   sim      = SimRegion.GetRegion(aPos.GlobalPosition).TheSimulator;

            if (sim == null)
            {
                return(Failure("Unknown simulator for " + aPos));
            }
            ulong handle = sim.Handle;

            if (sim.WindSpeeds == null)
            {
                return(Failure("Unknown wind speed at sim: " + sim));
            }
            Vector2[] windSpeeds = sim.WindSpeeds;
            Vector2   windSpeed  = windSpeeds[yPos * 16 + xPos];

            return(Success("Wind speed at " + aPos + " is " + windSpeed));
        }
Exemplo n.º 2
0
        public BotAction GetNextAction()
        {
            BotAction        act            = CurrentAction;
            List <BotAction> KnownBotAcions = GetPossibleActions(MaxThinkAboutDistance, MaxSupportedZChange);

            lock (KnownBotAcions)
            {
                if (KnownBotAcions.Count > 0)
                {
                    act = KnownBotAcions[0];// (BotAction)FindBestUsage(KnownBotAcions);
                }
                if (act == null)
                {
                    SimRegion R = Actor.GetSimRegion();
                    if (R == null)
                    {
                        return(new CommandAction(Actor, "anim shrug"));
                    }
                    Vector3d v3d =
                        R.LocalToGlobal(new Vector3(MyRandom.Next(250) + 5, MyRandom.Next(250) + 5,
                                                    Actor.SimPosition.Z));
                    Actor.Debug("MoveToLocation: " + Actor.DistanceVectorString(v3d));
                    SimPosition WP = SimWaypointImpl.CreateGlobal(v3d);
                    act = new MoveToLocation(Actor, WP);
                }
                return(act);
            }
        }
 public void Objects_OnObjectProperties11(Simulator simulator, Primitive prim, Primitive.ObjectProperties props)
 {
     //Primitive prim = GetPrimitive(props.ObjectID, simulator);
     if (prim == null)
     {
         prim = GetPrimitive(props.ObjectID, simulator);
     }
     DeclareProperties(prim, props, simulator);
     if (prim != null)
     {
         prim.RegionHandle = simulator.Handle;
         SimObject updateMe = GetSimObject(prim, simulator);
         if (updateMe == null)
         {
             return;
         }
         if (prim.ParentID == 0 && !SimRegion.OutOfRegion(prim.Position))
         {
             updateMe.ResetPrim(prim, client, simulator);
         }
         if (MaintainObjectProperties)
         {
             //updateMe.Properties = null;
             updateMe.Properties = (props);
         }
         //Debug("UpdateProperties: {0}", updateMe.DebugInfo());
         describePrimToAI(prim, simulator);
     }
 }
Exemplo n.º 4
0
        public Sculpt(BinaryReader br)
        {
            this.contextVersion = br.ReadUInt32();
            uint publicKeyCount    = br.ReadUInt32();
            uint externalKeyCount  = br.ReadUInt32();
            uint delayLoadKeyCount = br.ReadUInt32();
            uint objectKeyCount    = br.ReadUInt32();

            this.publicKey = new TGI[publicKeyCount];
            for (int i = 0; i < publicKeyCount; i++)
            {
                publicKey[i] = new TGI(br, TGI.TGIsequence.ITG);
            }
            this.externalKey = new TGI[externalKeyCount];
            for (int i = 0; i < externalKeyCount; i++)
            {
                externalKey[i] = new TGI(br, TGI.TGIsequence.ITG);
            }
            this.BGEOKey = new TGI[delayLoadKeyCount];
            for (int i = 0; i < delayLoadKeyCount; i++)
            {
                BGEOKey[i] = new TGI(br, TGI.TGIsequence.ITG);
            }
            this.objectKey = new ObjectData[objectKeyCount];
            for (int i = 0; i < objectKeyCount; i++)
            {
                objectKey[i] = new ObjectData(br);
            }
            this.version   = br.ReadUInt32();
            this.ageGender = (AgeGender)br.ReadUInt32();
            this.region    = (SimRegion)br.ReadUInt32();
            this.subRegion = (SimSubRegion)br.ReadUInt32();
        }
Exemplo n.º 5
0
        public override CmdResult ExecuteRequest(CmdRequest args)
        {
            if (args.Length < 1)
            {
                return(ShowUsage()); // " goto sim/x/y/z";
            }
            int         argsUsed;
            SimPosition position = WorldSystem.GetVector(args, out argsUsed);

            if (position == null)
            {
                return(Failure("Teleport - Cannot resolve to a location: " + args.str));
            }
            SimPathStore ps     = position.PathStore;
            ulong        handle = SimRegion.GetRegionHandle(ps);

            TheSimAvatar.StopMoving();
            if (Client.Self.Teleport(handle, position.SimPosition))
            {
                return(Success("Teleported to " + Client.Network.CurrentSim));
            }
            else
            {
                return(Failure("Teleport failed: " + Client.Self.TeleportMessage));
            }
        }
        public override void Parcels_OnParcelProperties(object sender, ParcelPropertiesEventArgs e)
        {
            Simulator simulator = e.Simulator;
            var       parcel    = e.Parcel;
            SimRegion r         = SimRegion.GetRegion(simulator);

            r.Parcels_OnParcelProperties(simulator, parcel, e.Result, e.SelectedPrims, e.SequenceID, e.SnapSelection);
            //base.Parcels_OnParcelProperties(simulator, parcel, result, selectedPrims, sequenceID, snapSelection);
        }
        private void FindNewMaster(ulong handle)
        {
            IEnumerable <Simulator> _AllSimulators = AllSimulators;
            SimRegion R = SimRegion.GetRegion(handle);

            lock (_AllSimulators)
            {
                foreach (var simulator in _AllSimulators)
                {
                    if (simulator.Client == client.gridClient)
                    {
                        continue;
                    }
                    if (simulator.Handle != handle)
                    {
                        continue;
                    }
                    GridClient cl = simulator.Client;
                    R.SetMaster(cl);
                    BotClient bc = BotClientFor(cl);
                    if (SimRegion.IsMaster(simulator, bc.gridClient))
                    {
                        bc.WorldSystem.MasteringRegions.Add(handle);
                    }
                    else
                    {
                        bc.WorldSystem.MasteringRegions.Add(handle);
                    }
                    Debug("Found a strong new client for region " + R + " as " + cl);
                    return;
                }
                foreach (var simulator in _AllSimulators)
                {
                    //   if (simulator.Client == client.gridClient) continue;
                    if (simulator.Handle != handle)
                    {
                        continue;
                    }
                    GridClient cl = simulator.Client;
                    BotClient  bc = BotClientFor(cl);
                    if (SimRegion.IsMaster(simulator, bc.gridClient))
                    {
                        bc.WorldSystem.MasteringRegions.Add(handle);
                    }
                    if (!cl.Network.Simulators.Contains(simulator))
                    {
                        continue;
                    }
                    R.SetMaster(cl);
                    Debug("Found a new client for region " + R + " as " + cl);
                    return;
                }
            }
            Debug("UHT OH, No client is Mastering for region " + R);
        }
        public override void Parcels_OnParcelSelectedObjects(object sender, ForceSelectObjectsReplyEventArgs e)
        {
            Simulator simulator = e.Simulator;
            var       objectIDs = e.ObjectIDs;
            var       resetList = e.ResetList;

            SimRegion r = SimRegion.GetRegion(simulator);

            r.Parcels_OnParcelSelectedObjects(simulator, objectIDs, resetList);
            base.Parcels_OnParcelSelectedObjects(sender, e);
        }
Exemplo n.º 9
0
        internal SimRegion GetRegion(ulong RegionHandle)
        {
            if (RegionHandle == 0)
            {
                return(null);
            }
            var R = SimRegion.GetRegion(RegionHandle, client);

            R.RegionMaster   = client;
            R.TheWorldSystem = this;
            return(R);
        }
        public override void Parcels_OnAccessListReply(object sender, ParcelAccessListReplyEventArgs e)
        {
            return;

            SimRegion r = SimRegion.GetRegion(e.Simulator.RegionID, client);

            if (r != null)
            {
                r.Parcels_OnAccessList(e);
            }
            //base.Parcels_OnAccessListReply(simulator, sequenceID, localID, flags, accessEntries);
        }
        public override void Grid_OnGridRegion(object sender, GridRegionEventArgs e)
        {
            var       region = e.Region;
            SimRegion R      = SimRegion.GetRegion(region.RegionHandle, client);

            if (R != null)
            {
                R.GridInfo       = region;
                R.TheWorldSystem = this;
                R.RegionMaster   = client;
            }

            // base.Grid_OnGridRegion(region);
        }
        public override void Parcels_OnParcelInfo(object sender, ParcelInfoReplyEventArgs e)
        {
            var       parcel = e.Parcel;
            SimRegion r      = SimRegion.GetRegion(parcel.SimName, client);

            if (r != null)
            {
                r.Parcels_OnParcelInfo(parcel);
            }
            else
            {
                base.Parcels_OnParcelInfo(sender, e);
            }
        }
Exemplo n.º 13
0
        public SMOD(BinaryReader br)
        {
            this.contextVersion = br.ReadUInt32();
            uint publicKeyCount    = br.ReadUInt32();
            uint externalKeyCount  = br.ReadUInt32();
            uint delayLoadKeyCount = br.ReadUInt32();
            uint objectKeyCount    = br.ReadUInt32();

            this.publicKey = new TGI[publicKeyCount];
            for (int i = 0; i < publicKeyCount; i++)
            {
                publicKey[i] = new TGI(br, TGI.TGIsequence.ITG);
            }
            this.externalKey = new TGI[externalKeyCount];
            for (int i = 0; i < externalKeyCount; i++)
            {
                externalKey[i] = new TGI(br, TGI.TGIsequence.ITG);
            }
            this.BGEOKey = new TGI[delayLoadKeyCount];
            for (int i = 0; i < delayLoadKeyCount; i++)
            {
                BGEOKey[i] = new TGI(br, TGI.TGIsequence.ITG);
            }
            this.objectKey = new ObjectData[objectKeyCount];
            for (int i = 0; i < objectKeyCount; i++)
            {
                objectKey[i] = new ObjectData(br);
            }
            this.version   = br.ReadUInt32();
            this.ageGender = (AgeGender)br.ReadUInt32();
            this.region    = (SimRegion)br.ReadUInt32();
            if (this.version >= 144)
            {
                this.subRegion = (SimSubRegion)br.ReadUInt32();
            }
            this.linkTag              = (BgeoLinkTag)br.ReadUInt32();
            this.bonePoseKey          = new TGI(br, TGI.TGIsequence.ITG);
            this.deformerMapShapeKey  = new TGI(br, TGI.TGIsequence.ITG);
            this.deformerMapNormalKey = new TGI(br, TGI.TGIsequence.ITG);
            uint count = br.ReadUInt32();

            this.boneEntryList = new BoneEntry[count];
            for (int i = 0; i < count; i++)
            {
                this.boneEntryList[i] = new BoneEntry(br);
            }
        }
Exemplo n.º 14
0
        private object AsRLocation(Simulator simulator, Vector3d targetPos, SimPosition pos)
        {
            Vector3   lpos = new Vector3((float)targetPos.X, (float)targetPos.Y, (float)targetPos.Z);
            SimRegion r    = SimRegion.GetRegion(simulator);

            if (targetPos == Vector3d.Zero)
            {
                if (r == null)
                {
                    if (pos != null && pos.IsRegionAttached)
                    {
                        return(new SimHeading(pos));
                    }
                    return(SimHeading.UNKNOWN);
                }
                return(r);
            }
            return(new SimHeading(pos, lpos));
        }
Exemplo n.º 15
0
        private object AsLocation(UUID reg, Vector3 position)
        {
            SimRegion r = GetRegion(reg);

            if (position == Vector3.Zero)
            {
                if (r == null)
                {
                    if (reg == UUID.Zero)
                    {
                        return(SimHeading.UNKNOWN);
                    }
                    return(SimHeading.UNKNOWN);
                    // return r;
                }
                return(r);
            }
            return(new SimHeading(r.GetPathStore(position), position, Quaternion.Identity));
        }
        public override void Network_OnSimDisconnected(object sender, SimDisconnectedEventArgs e)
        {
            var simulator = e.Simulator;
            var reason    = e.Reason;

            base.Network_OnSimDisconnected(sender, e);
            RemoveSim(simulator);
            SimRegion.GetRegion(simulator).RemoveSim(simulator);
            LeaveSimulator(simulator);

            if (simulator == client.Network.CurrentSim)
            {
                PropertyQueue.AddFirst(() =>
                {
                    Debug("CLOSE for region " + simulator);
                    //client.Login();
                }
                                       );
            }
        }
 public override void Network_OnDisconnected(object sender, DisconnectedEventArgs e)
 {
     {
         foreach (var simulator in AllSimulators)
         {
             if (simulator.Client != client.gridClient)
             {
                 if (GridMaster == this && simulator.Connected)
                 {
                     GridMaster = BotClientFor(simulator.Client).WorldSystem;
                     Debug("Changed GridMaster to " + GridMaster);
                 }
                 continue;
             }
             RemoveSim(simulator);
             SimRegion.GetRegion(simulator).RemoveSim(simulator);
             LeaveSimulator(simulator);
         }
     }
     base.Network_OnDisconnected(sender, e);
 }
 public override CmdResult ExecuteRequest(CmdRequest args)
 {
     if (args.Length == 0)
     {
         //foreach (SimRegion R in SimRegion.CurrentRegions)
         //{
         //    R.ShowDebugger();
         //}
         SimRegion.GetRegion(Client.Network.CurrentSim).ShowDebugger();
     }
     else
     {
         foreach (SimRegion R in SimRegion.CurrentRegions)
         {
             if (R.RegionName.Contains(String.Join(" ", args)))
             {
                 R.ShowDebugger();
             }
         }
     }
     return(Success("Ran " + Name));
 }
 public void EnsureSimulator(Simulator simulator)
 {
     if (simulator == null || simulator.Handle == 0)
     {
         return;
     }
     if (!Monitor.TryEnter(_AllSimulators, 10000))
     {
         WriteLine("Cant lock _AllSimulators");
         return;
     }
     lock (SimMaster)
     {
         if (!SimMaster.ContainsKey(simulator.Handle))
         {
             SimMaster[simulator.Handle] = this;
             MasteringRegions.AddTo(simulator.Handle);
         }
     }
     try
     {
         {
             foreach (Simulator set in _AllSimulators)
             {
                 if (set.Handle == simulator.Handle && set.Client == simulator.Client)
                 {
                     return;
                 }
             }
             _AllSimulators.Add(simulator);
         }
         SimRegion.GetRegion(simulator);
     }
     finally
     {
         Monitor.Exit(_AllSimulators);
     }
 }
Exemplo n.º 20
0
        public override CmdResult ExecuteRequest(CmdRequest args)
        {
            int argsUsed;
            var keyargs = args.GetProperty("targets");
            ICollection <SimObject> objs = WorldSystem.GetPrimitives(keyargs, out argsUsed);
            bool rightNow = true;

            if (argsUsed == 0)
            {
                objs     = (ICollection <SimObject>)WorldSystem.GetAllSimObjects();
                rightNow = false;
            }
            WriteLine("Meshing " + objs.Count);
            foreach (SimObject o2 in objs)
            {
                SimObjectPathFinding o = o2.PathFinding;
                o.IsWorthMeshing = true;
                if (rightNow)
                {
                    o.AddCollisionsNow();
                }
                else
                {
                    o.AddCollisions();
                }
            }
            if (rightNow)
            {
                SimRegion.BakeRegions();
            }
            else
            {
                Cogbot.WorldPathSystem.MeshingQueue.Enqueue(SimRegion.BakeRegions);
            }

            return(TheBotClient.ExecuteCommand("meshinfo", args.CallerAgent, args.Output, args.CmdFlags));
        }
Exemplo n.º 21
0
        public string RezAll(BotInventoryEval man, InventoryBase b, SimPosition dest)
        {
            string ret     = "";
            var    manager = man.Manager;

            if (b is InventoryItem)
            {
                InventoryItem item = b as InventoryItem;

                bool canCopy = (item.Permissions.OwnerMask & PermissionMask.Copy) == PermissionMask.Copy;

                ret += item.Name + nl;
                if (dest == null)
                {
                    Simulator sim = Client.Network.CurrentSim;
                    Client.Inventory.RequestRestoreRezFromInventory(sim, item, item.UUID);
                }
                else
                {
                    Simulator sim = SimRegion.GetRegion(dest.GlobalPosition).TheSimulator;
                    Client.Inventory.RequestRezFromInventory(sim, dest.SimRotation, dest.SimPosition, item, UUID.Zero);
                }
            }
            else if (b is InventoryFolder)
            {
                InventoryFolder      folder         = b as InventoryFolder;
                List <InventoryBase> folderContents = man.FolderContents(folder.UUID);
                if (folderContents != null)
                {
                    foreach (InventoryBase list in folderContents)
                    {
                        ret += RezAll(man, list, dest);
                    }
                }
            }
            return(ret);
        }
Exemplo n.º 22
0
        private object AsLocation(Simulator simulator, Vector3 position, SimPosition pos)
        {
            SimRegion r = SimRegion.GetRegion(simulator);

            if (position == Vector3.Zero)
            {
                if (r == null)
                {
                    if (pos != null && pos.IsRegionAttached)
                    {
                        return(new SimHeading(pos));
                    }
                    return(SimHeading.UNKNOWN);
                }
                return(r);
            }
            Quaternion rot = Quaternion.Identity;

            if (pos != null && pos.IsRegionAttached)
            {
                rot = pos.SimRotation;
            }
            return(new SimHeading(r.GetPathStore(position), position, rot));
        }
Exemplo n.º 23
0
        public Simulator TryGetSim(string[] args, out int argsUsed)
        {
            if (args.Length > 0)
            {
                string    s = String.Join(" ", args);
                SimRegion R = SimRegion.GetRegion(s, client);
                if (R == null)
                {
                    argsUsed = 0;
                    WriteLine("cant find sim " + s);
                    return(null);
                }

                Simulator sim = R.TheSimulator;
                if (sim == null)
                {
                    WriteLine("not connect to sim" + R);
                }
                argsUsed = args.Length;
                return(sim);
            }
            argsUsed = 0;
            return(client.Network.CurrentSim);
        }
Exemplo n.º 24
0
        public Primitive AddTempPrim(SimRegion R, string name, PrimType primType, Vector3 scale, Vector3 loc)
        {
            Primitive.ConstructionData CD = ObjectManager.BuildBasicShape(primType);
            CD.Material    = Material.Light;
            CD.ProfileHole = HoleType.Triangle;

            bool success = false;

            Simulator simulator = R.TheSimulator;
            Primitive newPrim   = null;
            // Register a handler for the creation event
            AutoResetEvent creationEvent          = new AutoResetEvent(false);
            Quaternion     rot                    = Quaternion.Identity;
            EventHandler <PrimEventArgs> callback =
                (s, e) =>//delegate(Simulator simulator0, Primitive prim, ulong regionHandle, ushort timeDilation)
            {
                var regionHandle = e.Simulator.Handle;
                var prim         = e.Prim;
                if (regionHandle != R.RegionHandle)
                {
                    return;
                }
                if ((loc - prim.Position).Length() > 3)
                {
                    Debug("Not the prim " + (loc - prim.Position).Length());
                    return;
                }
                if (prim.PrimData.ProfileHole != HoleType.Triangle)
                {
                    Debug("Not the prim?  prim.PrimData.ProfileHole != HoleType.Triangle: {0}!={1}",
                          prim.PrimData.ProfileHole, HoleType.Triangle);
                    // return;       //
                }
                if (Material.Light != prim.PrimData.Material)
                {
                    Debug("Not the prim? Material.Light != prim.PrimData.Material: {0}!={1}", Material.Light,
                          prim.PrimData.Material);
                    // return;
                }
                if ((prim.Flags & PrimFlags.CreateSelected) == 0)
                {
                    Debug("Not the prim? (prim.Flags & PrimFlags.CreateSelected) == 0) was {0}", prim.Flags);
                    // return;
                }
                if (primType != prim.Type)
                {
                    Debug("Not the prim? Material.Light != prim.PrimData.Material: {0}!={1}", Material.Light,
                          prim.PrimData.Material);
                    // return;
                }
                //if (prim.Scale != scale) return;
                //     if (prim.Rotation != rot) return;

                //  if (Material.Light != prim.PrimData.Material) return;
                //if (CD != prim.PrimData) return;
                newPrim = prim;
                creationEvent.Set();
            };

            client.Objects.ObjectUpdate += callback;

            // Start the creation setting process (with baking enabled or disabled)
            client.Objects.AddPrim(simulator, CD, UUID.Zero, loc, scale, rot,
                                   PrimFlags.CreateSelected | PrimFlags.Phantom | PrimFlags.Temporary);

            // Wait for the process to complete or time out
            if (creationEvent.WaitOne(1000 * 120, false))
            {
                success = true;
            }

            // Unregister the handler
            client.Objects.ObjectUpdate -= callback;

            // Return success or failure message
            if (!success)
            {
                Debug("Timeout on new prim " + name);
                return(null);
            }
            uint LocalID = newPrim.LocalID;

            client.Objects.SetName(simulator, LocalID, name);
            client.Objects.SetPosition(simulator, LocalID, loc);
            client.Objects.SetScale(simulator, LocalID, scale, true, true);
            client.Objects.SetRotation(simulator, LocalID, rot);
            client.Objects.SetFlags(simulator, LocalID, false, true, true, false);
            return(newPrim);
        }
        private void acceptInput0(string verb, Parser parser)
        {
            String[] args = parser.GetProperty("to");
            string   ToS  = Parser.Rejoin(args, 0);

            if (String.IsNullOrEmpty(ToS))
            {
                ToS = parser.str;
            }
            int argUsed;

            if (ToS == "home")
            {
                Client.Self.GoHome();
                AddSuccess("teleporting home");
                return;
            }
            SimPosition pos = WorldSystem.GetVector(args, out argUsed);

            if (argUsed > 0)
            {
                Vector3d global = pos.GlobalPosition;
                WriteLine("Teleporting to " + pos + "...");
                float x, y;
                TheSimAvatar.StopMoving();
                bool res =
                    Client.Self.Teleport(
                        SimRegion.GlobalPosToRegionHandle((float)global.X, (float)global.Y, out x, out y),
                        pos.SimPosition, pos.SimPosition);
                if (res)
                {
                    AddSuccess("Teleported to " + pos);
                }
                else
                {
                    Failure("Teleport Failed to " + pos);
                }
                return;
            }
            char[] splitchar = null;
            if (ToS.Contains("/"))
            {
                splitchar = new char[] { '/' };
            }
            string[] tokens = ToS.Split(splitchar);
            if (tokens.Length == 0)
            {
                WriteLine("Provide somewhere to teleport to.");
            }
            else
            {
                Vector3 coords  = new Vector3(128, 128, 40);
                string  simName = ""; //CurSim.Name;

                bool ifCoordinates = false;

                if (tokens.Length >= 3)
                {
                    try
                    {
                        coords.X      = float.Parse(tokens[tokens.Length - 3]);
                        coords.Y      = float.Parse(tokens[tokens.Length - 2]);
                        coords.Z      = float.Parse(tokens[tokens.Length - 1]);
                        ifCoordinates = true;
                    }
                    catch (Exception e)
                    {
                    }
                }

                if (!ifCoordinates)
                {
                    for (int i = 0; i < tokens.Length; i++)
                    {
                        simName += tokens[i] + " ";
                    }
                    simName = simName.Trim();
                }
                else
                {
                    for (int i = 0; i < tokens.Length - 3; i++)
                    {
                        simName += tokens[i] + " ";
                    }
                    simName = simName.Trim();
                }
                {
                    if (String.IsNullOrEmpty(simName))
                    {
                        simName = Client.Network.CurrentSim.Name;
                    }
                    TeleportFinished.Reset();
                    Client.Self.TeleportProgress += On_Teleport;
                    WriteLine("Trying to teleport to " + simName + " " + coords);
                    Client.Self.Teleport(simName, coords);
                    // wait 30 seconds
                    if (!TeleportFinished.WaitOne(30000, false))
                    {
                        Client.Self.TeleportProgress -= On_Teleport;
                        WriteLine("Timeout on teleport to " + simName + " " + coords);
                    }
                }
            }
        }
        private void SaveParcelInfo(ImportSettings settings)
        {
            var CurSim = settings.CurSim;

            Client.Parcels.RequestAllSimParcels(CurSim);

            if (CurSim.IsParcelMapFull())
            {
                ParcelsDownloaded.Set();
            }

            if (ParcelsDownloaded.WaitOne(30000, false) && Client.Network.Connected)
            {
                Success(string.Format("Downloaded {0} Parcels in {1} " + Environment.NewLine, CurSim.Parcels.Count, CurSim.Name));
                IDictionary <int, Parcel> curSimParcels = null;
                lock (CurSim.Parcels.Dictionary)
                {
                    curSimParcels = LockInfo.CopyOf(CurSim.Parcels.Dictionary);
                }

                List <UUID> ParcelPrimOwners = new List <UUID>();
                List <uint> ParcelObjectIDS  = new List <uint>();
                foreach (KeyValuePair <int, Parcel> simParcel in curSimParcels)
                {
                    var parcel   = simParcel.Value;
                    int parcelID = parcel.LocalID;

                    Success(string.Format(
                                "Parcel[{0}]: Name: \"{1}\", Description: \"{2}\" ACLBlacklist Count: {3}, ACLWhiteList Count: {5} Traffic: {4}" +
                                Environment.NewLine,
                                parcel.LocalID, parcel.Name, parcel.Desc,
                                parcel.AccessBlackList.Count, parcel.Dwell,
                                parcel.AccessWhiteList.Count));
                    AddExportUser(parcel.OwnerID);
                    AddExportGroup(parcel.GroupID);

                    Success(Helpers.StructToString(parcel));
                    foreach (
                        ParcelManager.ParcelAccessEntry white in parcel.AccessWhiteList)
                    {
                        if (white.AgentID != UUID.Zero)
                        {
                            Success(string.Format(
                                        "\tAllowed Avatar {0}" + Environment.NewLine,
                                        white.AgentID));
                        }
                    }
                    foreach (
                        ParcelManager.ParcelAccessEntry black in parcel.AccessBlackList)
                    {
                        //    if(black.AgentID != UUID.Zero)
                        Success(string.Format("\t Banned Avatar {0}" + Environment.NewLine,
                                              black.AgentID));
                    }
                    {
                        AutoResetEvent parcelOwnerWait = new AutoResetEvent(false);

                        EventHandler <ParcelObjectOwnersReplyEventArgs> callback =
                            delegate(object sender, ParcelObjectOwnersReplyEventArgs e)
                        {
                            for (int i = 0; i < e.PrimOwners.Count; i++)
                            {
                                ParcelManager.ParcelPrimOwners ownerse = e.PrimOwners[i];
                                if (ownerse.IsGroupOwned)
                                {
                                    AddExportGroup(ownerse.OwnerID);
                                }
                                else
                                {
                                    AddExportUser(ownerse.OwnerID);
                                }
                                Success(string.Format("Owner: {0} Count: {1}" + Environment.NewLine,
                                                      ownerse.OwnerID, ownerse.Count));
                                if (!CogbotHelpers.IsNullOrZero(ownerse.OwnerID))
                                {
                                    ParcelPrimOwners.Add(ownerse.OwnerID);
                                }
                            }
                            parcelOwnerWait.Set();
                        };

                        Client.Parcels.ParcelObjectOwnersReply += callback;
                        try
                        {
                            Client.Parcels.RequestObjectOwners(CurSim, parcelID);
                            if (!parcelOwnerWait.WaitOne(10000, false))
                            {
                                Failure("Timed out waiting for packet.");
                            }
                        }
                        finally
                        {
                            Client.Parcels.ParcelObjectOwnersReply -= callback;
                        }
                    }
                    foreach (UUID ownerUUID in ParcelPrimOwners)
                    {
                        AutoResetEvent wait = new AutoResetEvent(false);
                        EventHandler <ForceSelectObjectsReplyEventArgs> callback = delegate(object sender, ForceSelectObjectsReplyEventArgs e)
                        {
                            ParcelObjectIDS.AddRange(e.ObjectIDs);

                            for (int i = 0; i < e.ObjectIDs.Count; i++)
                            {
                                // Success(string.Format(e.ObjectIDs[i].ToString() + " "));
                                // counter++;
                            }

                            if (e.ObjectIDs.Count < 251)
                            {
                                wait.Set();
                            }
                        };


                        Client.Parcels.ForceSelectObjectsReply += callback;
                        Client.Parcels.RequestSelectObjects(parcelID, (ObjectReturnType)16, ownerUUID);
                        wait.WaitOne(10000);
                    }
                }
                foreach (uint u in ParcelObjectIDS)
                {
                    RequiredForExportLocalIDs.Add(u);
                }
                Success("Parcel LocalIDs=" + ParcelObjectIDS.Count + " ParcelOwners=" + ParcelPrimOwners.Count);
            }
            else
            {
                Failure("Failed to retrieve information on all the simulator parcels");
            }

            string parcelDirs = settings.OarDir + "landdata/";

            Directory.CreateDirectory(parcelDirs);


            SimRegion r = SimRegion.GetRegion(CurSim);

            foreach (var p in r.ParcelMap)
            {
                Parcel parcel = p.Value;
                if (CogbotHelpers.IsNullOrZero(parcel.GlobalID))
                {
                    parcel.GlobalID = UUID.Random();
                }
                File.WriteAllText(parcelDirs + "" + parcel.GlobalID + ".xml", OarFile.Serialize(parcel));
            }
        }
Exemplo n.º 27
0
        public SimPosition GetVector(string[] args, out int argsUsed, SimPosition offset)
        {
            argsUsed = 0;
            if (args.Length == 0)
            {
                return(offset ?? TheSimAvatar);
            }
            //if (args.Length >= 2)
            {
                SimPosition R = GetSimV(args, 0, out argsUsed, offset);
                if (R != null)
                {
                    return(R);
                }
            }
            UUID uuid = UUID.Zero;

            if (UUID.TryParse(args[0], out uuid))
            {
                SimObject O = null;
                O = GetSimObjectFromUUID(uuid);
                if (O != null)
                {
                    argsUsed = 1;
                    return(O);
                }
            }

            List <SimObject> prim = GetSingleArg(args, out argsUsed);

            if (prim.Count == 1)
            {
                return(prim[0]);
            }


            argsUsed = 0;
            string destination = String.Empty;

            // Handle multi-word sim names by combining the arguments
            foreach (string arg in args)
            {
                destination += arg + " ";
            }
            int consume = args.Length;

            destination = destination.Trim();

            string[] tokens = destination.Split(new char[] { '/' });
            float    x, y = 128;

            if (!float.TryParse(tokens[0], out x))
            {
                x = 128;
            }
            else
            {
                argsUsed++;
            }
            string sim = tokens[argsUsed];

            //TODO use the GetSimV code
            argsUsed += 1;
            float z = -1;

            if (tokens.Length > argsUsed + 1)
            {
                if (!float.TryParse(tokens[argsUsed], out x) ||
                    !float.TryParse(tokens[argsUsed + 1], out y))
                {
                    return(null);
                }
                argsUsed += 2;
                if (tokens.Length > argsUsed)
                {
                    if (float.TryParse(tokens[argsUsed], out z))
                    {
                        argsUsed += 1;
                    }
                    else
                    {
                        z = -1;
                    }
                }
                // test for global
                if (x > 512 || y > 512)
                {
                    float.TryParse(tokens[argsUsed], out z);
                    return(SimWaypointImpl.CreateGlobal(x, y, z));
                }
            }
            SimRegion region = SimRegion.GetRegion(sim, client);

            if (region == null)
            {
                return(null);
            }
            if (z == -1)
            {
                z = region.AverageHieght;
            }

            Vector3 v3 = new Vector3(x, y, z);

            return(SimWaypointImpl.CreateLocal(v3, region.GetPathStore(v3)));
        }
Exemplo n.º 28
0
 public SimRegion GetRegion(UUID uuid)
 {
     return(SimRegion.GetRegion(uuid, client));
 }
Exemplo n.º 29
0
 public SimWaypoint GetWaypoint(Vector3d gloabl)
 {
     return(SimRegion.GetWaypoint(gloabl));
 }
        private void Self_OnMessage(string FromAgentName, UUID FromAgentID, UUID ToAgentID,
                                    string Message, UUID IMSessionID, bool GroupIM,
                                    UUID RegionID, Vector3 Position,
                                    InstantMessageDialog Dialog, ChatType Type, EventArgs origin)
        {
            if (Dialog == InstantMessageDialog.GroupNotice)
            {
                GroupIM = true;
            }

            BotPermissions perms = GetSecurityLevel(FromAgentID, FromAgentName);

            // Received an IM from someone that is authenticated
            if (Type == ChatType.OwnerSay)
            {
                perms |= BotPermissions.Owner;
            }

            bool displayedMessage = false;

            if (origin is ChatEventArgs && Message.Length > 0 && Dialog == InstantMessageDialog.MessageFromAgent)
            {
                WriteLine(String.Format("{0} says, \"{1}\".", FromAgentName, Message));
                PosterBoard["/posterboard/onchat"] = Message;
                if (FromAgentName == Self.Name)
                {
                    PosterBoard["/posterboard/onchat-said"] = Message;
                }
                else
                {
                    PosterBoard["/posterboard/onchat-heard"] = Message;
                }
            }

            bool groupIM = GroupIM && GroupMembers != null && GroupMembers.ContainsKey(FromAgentID) ? true : false;


            switch (Dialog)
            {
            case InstantMessageDialog.MessageBox:
                break;

            case InstantMessageDialog.GroupInvitation:
                if ((perms & BotPermissions.AcceptGroupAndFriendRequests) != 0)
                {
                    string groupName = Message;
                    int    found     = groupName.IndexOf("Group:");
                    if (found > 0)
                    {
                        groupName = groupName.Substring(found + 6);
                    }
                    Self.InstantMessage(Self.Name, FromAgentID, string.Empty, IMSessionID,
                                        InstantMessageDialog.GroupInvitationAccept, InstantMessageOnline.Offline,
                                        Self.SimPosition,
                                        UUID.Zero, new byte[0]);
                    found = groupName.IndexOf(":");
                    if (found > 0)
                    {
                        groupName = groupName.Substring(0, found).Trim();
                        ExecuteCommand("joingroup " + groupName, CMDFLAGS.NoResult);
                    }
                }
                break;

            case InstantMessageDialog.InventoryOffered:
                break;

            case InstantMessageDialog.InventoryAccepted:
                break;

            case InstantMessageDialog.InventoryDeclined:
                break;

            case InstantMessageDialog.GroupVote:
                break;

            case InstantMessageDialog.TaskInventoryOffered:
                break;

            case InstantMessageDialog.TaskInventoryAccepted:
                break;

            case InstantMessageDialog.TaskInventoryDeclined:
                break;

            case InstantMessageDialog.NewUserDefault:
                break;

            case InstantMessageDialog.SessionAdd:
                break;

            case InstantMessageDialog.SessionOfflineAdd:
                break;

            case InstantMessageDialog.SessionGroupStart:
                break;

            case InstantMessageDialog.SessionCardlessStart:
                break;

            case InstantMessageDialog.SessionSend:
                break;

            case InstantMessageDialog.SessionDrop:
                break;

            case InstantMessageDialog.BusyAutoResponse:
                break;

            case InstantMessageDialog.ConsoleAndChatHistory:
                break;

            case InstantMessageDialog.Lure911:
            case InstantMessageDialog.RequestTeleport:
                if ((perms & BotPermissions.AcceptTeleport) != 0)
                {
                    TheSimAvatar.StopMoving();
                    if (RegionID != UUID.Zero)
                    {
                        if (!displayedMessage)
                        {
                            DisplayNotificationInChat("TP to Lure from " + FromAgentName);
                            displayedMessage = true;
                        }
                        SimRegion R = SimRegion.GetRegion(RegionID, gridClient);
                        if (R != null)
                        {
                            Self.Teleport(R.RegionHandle, Position);
                            return;
                        }
                    }
                    DisplayNotificationInChat("Accepting TP Lure from " + FromAgentName);
                    displayedMessage = true;
                    Self.TeleportLureRespond(FromAgentID, IMSessionID, true);
                }
                break;

            case InstantMessageDialog.AcceptTeleport:
                break;

            case InstantMessageDialog.DenyTeleport:
                break;

            case InstantMessageDialog.GodLikeRequestTeleport:
                break;

            //  case InstantMessageDialog.CurrentlyUnused:
            //    break;
            case InstantMessageDialog.GotoUrl:
                break;

            case InstantMessageDialog.Session911Start:
                break;

            case InstantMessageDialog.FromTaskAsAlert:
                break;

            case InstantMessageDialog.GroupNotice:
                break;

            case InstantMessageDialog.GroupNoticeInventoryAccepted:
                break;

            case InstantMessageDialog.GroupNoticeInventoryDeclined:
                break;

            case InstantMessageDialog.GroupInvitationAccept:
                break;

            case InstantMessageDialog.GroupInvitationDecline:
                break;

            case InstantMessageDialog.GroupNoticeRequested:
                break;

            case InstantMessageDialog.FriendshipOffered:
                if ((perms & BotPermissions.AcceptGroupAndFriendRequests) != 0)
                {
                    DisplayNotificationInChat("Accepting Friendship from " + FromAgentName);
                    Friends.AcceptFriendship(FromAgentID, IMSessionID);
                    displayedMessage = true;
                }
                break;

            case InstantMessageDialog.FriendshipAccepted:
                break;

            case InstantMessageDialog.FriendshipDeclined:
                break;

            case InstantMessageDialog.StartTyping:
                break;

            case InstantMessageDialog.StopTyping:
                break;

            case InstantMessageDialog.MessageFromObject:
            case InstantMessageDialog.MessageFromAgent:
                // message from self
                if (FromAgentName == GetName())
                {
                    return;
                }
                // message from system
                if (FromAgentName == "System")
                {
                    return;
                }
                // message from others
                CommandInstance ci;
                if (Commands.TryGetValue("im", out ci))
                {
                    var whisper = ci.WithBotClient as Cogbot.Actions.Communication.ImCommand;
                    if (whisper != null)
                    {
                        whisper.currentAvatar  = FromAgentID;
                        whisper.currentSession = IMSessionID;
                    }
                }
                var cea = origin as ChatEventArgs;
                if ((perms & BotPermissions.ExecuteCommands) != 0)
                {
                    OutputDelegate WriteLine;
                    if (origin is InstantMessageEventArgs)
                    {
                        WriteLine = new OutputDelegate(
                            (string text, object[] ps) =>
                        {
                            string reply0 = DLRConsole.SafeFormat(text, ps);
                            InstantMessage(FromAgentID, reply0, IMSessionID);
                        });
                    }
                    else
                    {
                        WriteLine = new OutputDelegate(
                            (string text, object[] ps) =>
                        {
                            string reply0 = DLRConsole.SafeFormat(text, ps);
                            Talk(reply0, 0, Type);
                        });
                    }
                    string   cmd        = Message;
                    CMDFLAGS needResult = CMDFLAGS.Console;
                    if (cmd.StartsWith("cmcmd "))
                    {
                        cmd = cmd.Substring(6);
                        WriteLine("");
                        WriteLine(string.Format("invokecm='{0}'", cmd));
                        ClientManager.DoCommandAll(cmd, FromAgentID, WriteLine);
                    }
                    else if (cmd.StartsWith("cmd "))
                    {
                        cmd = cmd.Substring(4);
                        WriteLine(string.Format("invoke='{0}'", cmd));
                        var res = ExecuteCommand(cmd, FromAgentID, WriteLine, needResult);
                        WriteLine("iresult='" + res + "'");
                    }
                    else if (cmd.StartsWith("/") || cmd.StartsWith("@"))
                    {
                        cmd = cmd.Substring(1);
                        WriteLine("");
                        WriteLine(string.Format("invoke='{0}'", cmd));
                        var res = ExecuteCommand(cmd, FromAgentID, WriteLine, needResult);
                        WriteLine("iresult='" + res + "'");
                    }
                }
                if (cea != null && cea.AudibleLevel == ChatAudibleLevel.Barely)
                {
                    return;
                }
                break;

            default:
                break;
            }
            //if (Dialog != InstantMessageDialog.MessageFromAgent && Dialog != InstantMessageDialog.MessageFromObject)
            {
                string debug = String.Format("{0} {1} {2} {3} {4} {5}: {6}",
                                             groupIM ? "GroupIM" : "IM", Dialog, Type, perms, FromAgentID, FromAgentName,
                                             Helpers.StructToString(origin));
                if (!displayedMessage)
                {
                    DisplayNotificationInChat(debug);
                    displayedMessage = true;
                }
            }
        }