Пример #1
0
        public byte[] FindTelehub(Dictionary <string, object> request)
        {
            UUID regionID = UUID.Zero;

            UUID.TryParse(request["REGIONID"].ToString(), out regionID);

            Dictionary <string, object> result = new Dictionary <string, object>();
            Telehub telehub = TelehubConnector.FindTelehub(regionID, 0);

            if (telehub != null)
            {
                result = telehub.ToKVP();
            }
            string xmlString = WebUtils.BuildXmlResponse(result);
            //MainConsole.Instance.DebugFormat("[AuroraDataServerPostHandler]: resp string: {0}", xmlString);
            UTF8Encoding encoding = new UTF8Encoding();

            return(encoding.GetBytes(xmlString));
        }
        public virtual void HandleMapItemRequest(IClientAPI remoteClient, uint flags,
                                                 uint EstateID, bool godlike, uint itemtype, ulong regionhandle)
        {
            //All the parts are in for this, except for popular places and those are not in as they are not reqested anymore.

            List <mapItemReply> mapitems = new List <mapItemReply>();
            mapItemReply        mapitem  = new mapItemReply();
            uint xstart = 0;
            uint ystart = 0;

            Utils.LongToUInts(remoteClient.Scene.RegionInfo.RegionHandle, out xstart, out ystart);
            GridRegion GR = null;

            GR = regionhandle == 0 ? new GridRegion(remoteClient.Scene.RegionInfo) : m_Scenes[0].GridService.GetRegionByPosition(remoteClient.AllScopeIDs, (int)xstart, (int)ystart);
            if (GR == null)
            {
                //No region???
                return;
            }

            #region Telehub

            if (itemtype == (uint)GridItemType.Telehub)
            {
                IRegionConnector GF = DataManager.DataManager.RequestPlugin <IRegionConnector>();
                if (GF == null)
                {
                    return;
                }

                int tc = Environment.TickCount;
                //Find the telehub
                Telehub telehub = GF.FindTelehub(GR.RegionID, GR.RegionHandle);
                if (telehub != null)
                {
                    mapitem = new mapItemReply
                    {
                        x      = (uint)(GR.RegionLocX + telehub.TelehubLocX),
                        y      = (uint)(GR.RegionLocY + telehub.TelehubLocY),
                        id     = GR.RegionID,
                        name   = Util.Md5Hash(GR.RegionName + tc.ToString()),
                        Extra  = 1,
                        Extra2 = 0
                    };
                    //The position is in GLOBAL coordinates (in meters)
                    //This is how the name is sent, go figure
                    //Not sure, but this is what gets sent

                    mapitems.Add(mapitem);
                    remoteClient.SendMapItemReply(mapitems.ToArray(), itemtype, flags);
                    mapitems.Clear();
                }
            }

            #endregion

            #region Land for sale

            //PG land that is for sale
            if (itemtype == (uint)GridItemType.LandForSale)
            {
                if (directoryService == null)
                {
                    return;
                }
                //Find all the land, use "0" for the flags so we get all land for sale, no price or area checking
                List <DirLandReplyData> Landdata = directoryService.FindLandForSaleInRegion("0", uint.MaxValue, 0, 0, 0, GR.RegionID);

                int locX = 0;
                int locY = 0;
                foreach (DirLandReplyData landDir in Landdata)
                {
                    if (landDir == null)
                    {
                        continue;
                    }
                    LandData landdata = directoryService.GetParcelInfo(landDir.parcelID);
                    if (landdata == null || landdata.Maturity != 0)
                    {
                        continue; //Not a PG land
                    }
#if (!ISWIN)
                    foreach (IScene scene in m_Scenes)
                    {
                        if (scene.RegionInfo.RegionID == landdata.RegionID)
                        {
                            //Global coords, so add the meters
                            locX = scene.RegionInfo.RegionLocX;
                            locY = scene.RegionInfo.RegionLocY;
                        }
                    }
#else
                    foreach (IScene scene in m_Scenes.Where(scene => scene.RegionInfo.RegionID == landdata.RegionID))
                    {
                        //Global coords, so add the meters
                        locX = scene.RegionInfo.RegionLocX;
                        locY = scene.RegionInfo.RegionLocY;
                    }
#endif
                    if (locY == 0 && locX == 0)
                    {
                        //Ask the grid service for the coordinates if the region is not local
                        GridRegion r = m_Scenes[0].GridService.GetRegionByUUID(remoteClient.AllScopeIDs, landdata.RegionID);
                        if (r != null)
                        {
                            locX = r.RegionLocX;
                            locY = r.RegionLocY;
                        }
                    }
                    if (locY == 0 && locX == 0) //Couldn't find the region, don't send
                    {
                        continue;
                    }

                    mapitem = new mapItemReply
                    {
                        x      = (uint)(locX + landdata.UserLocation.X),
                        y      = (uint)(locY + landdata.UserLocation.Y),
                        id     = landDir.parcelID,
                        name   = landDir.name,
                        Extra  = landDir.actualArea,
                        Extra2 = landDir.salePrice
                    };
                    //Global coords, so make sure its in meters
                    mapitems.Add(mapitem);
                }
                //Send all the map items
                if (mapitems.Count != 0)
                {
                    remoteClient.SendMapItemReply(mapitems.ToArray(), itemtype, flags);
                    mapitems.Clear();
                }
            }

            //Adult or mature land that is for sale
            if (itemtype == (uint)GridItemType.AdultLandForSale)
            {
                if (directoryService == null)
                {
                    return;
                }
                //Find all the land, use "0" for the flags so we get all land for sale, no price or area checking
                List <DirLandReplyData> Landdata = directoryService.FindLandForSale("0", uint.MaxValue, 0, 0, 0, remoteClient.ScopeID);

                int locX = 0;
                int locY = 0;
                foreach (DirLandReplyData landDir in Landdata)
                {
                    LandData landdata = directoryService.GetParcelInfo(landDir.parcelID);
                    if (landdata == null || landdata.Maturity == 0)
                    {
                        continue; //Its PG
                    }
#if (!ISWIN)
                    foreach (IScene scene in m_Scenes)
                    {
                        if (scene.RegionInfo.RegionID == landdata.RegionID)
                        {
                            locX = scene.RegionInfo.RegionLocX;
                            locY = scene.RegionInfo.RegionLocY;
                        }
                    }
#else
                    foreach (IScene scene in m_Scenes.Where(scene => scene.RegionInfo.RegionID == landdata.RegionID))
                    {
                        locX = scene.RegionInfo.RegionLocX;
                        locY = scene.RegionInfo.RegionLocY;
                    }
#endif
                    if (locY == 0 && locX == 0)
                    {
                        //Ask the grid service for the coordinates if the region is not local
                        GridRegion r = m_Scenes[0].GridService.GetRegionByUUID(remoteClient.AllScopeIDs, landdata.RegionID);
                        if (r != null)
                        {
                            locX = r.RegionLocX;
                            locY = r.RegionLocY;
                        }
                    }
                    if (locY == 0 && locX == 0) //Couldn't find the region, don't send
                    {
                        continue;
                    }

                    mapitem = new mapItemReply
                    {
                        x      = (uint)(locX + landdata.UserLocation.X),
                        y      = (uint)(locY + landdata.UserLocation.Y),
                        id     = landDir.parcelID,
                        name   = landDir.name,
                        Extra  = landDir.actualArea,
                        Extra2 = landDir.salePrice
                    };
                    //Global coords, so make sure its in meters

                    mapitems.Add(mapitem);
                }
                //Send the results if we have any
                if (mapitems.Count != 0)
                {
                    remoteClient.SendMapItemReply(mapitems.ToArray(), itemtype, flags);
                    mapitems.Clear();
                }
            }

            #endregion

            #region Events

            if (itemtype == (uint)GridItemType.PgEvent ||
                itemtype == (uint)GridItemType.MatureEvent ||
                itemtype == (uint)GridItemType.AdultEvent)
            {
                if (directoryService == null)
                {
                    return;
                }

                //Find the maturity level
                int maturity = itemtype == (uint)GridItemType.PgEvent
                                   ? (int)DirectoryManager.EventFlags.PG
                                   : (itemtype == (uint)GridItemType.MatureEvent)
                                         ? (int)DirectoryManager.EventFlags.Mature
                                         : (int)DirectoryManager.EventFlags.Adult;

                //Gets all the events occuring in the given region by maturity level
                List <DirEventsReplyData> Eventdata = directoryService.FindAllEventsInRegion(GR.RegionName, maturity);

                foreach (DirEventsReplyData eventData in Eventdata)
                {
                    //Get more info on the event
                    EventData eventdata = directoryService.GetEventInfo(eventData.eventID);
                    if (eventdata == null)
                    {
                        continue; //Can't do anything about it
                    }
                    Vector3 globalPos = eventdata.globalPos;
                    mapitem = new mapItemReply
                    {
                        x      = (uint)(globalPos.X + (remoteClient.Scene.RegionInfo.RegionSizeX / 2)),
                        y      = (uint)(globalPos.Y + (remoteClient.Scene.RegionInfo.RegionSizeY / 2)),
                        id     = UUID.Random(),
                        name   = eventData.name,
                        Extra  = (int)eventdata.dateUTC,
                        Extra2 = (int)eventdata.eventID
                    };

                    //Use global position plus half the region so that it doesn't always appear in the bottom corner

                    mapitems.Add(mapitem);
                }
                //Send if we have any
                if (mapitems.Count != 0)
                {
                    remoteClient.SendMapItemReply(mapitems.ToArray(), itemtype, flags);
                    mapitems.Clear();
                }
            }

            #endregion

            #region Classified

            if (itemtype == (uint)GridItemType.Classified)
            {
                if (directoryService == null)
                {
                    return;
                }
                //Get all the classifieds in this region
                List <Classified> Classifieds = directoryService.GetClassifiedsInRegion(GR.RegionName);
                foreach (Classified classified in Classifieds)
                {
                    //Get the region so we have its position
                    GridRegion region = m_Scenes[0].GridService.GetRegionByName(remoteClient.AllScopeIDs, classified.SimName);

                    mapitem = new mapItemReply
                    {
                        x = (uint)
                            (region.RegionLocX + classified.GlobalPos.X +
                             (remoteClient.Scene.RegionInfo.RegionSizeX / 2)),
                        y = (uint)
                            (region.RegionLocY + classified.GlobalPos.Y +
                             (remoteClient.Scene.RegionInfo.RegionSizeY / 2)),
                        id     = classified.CreatorUUID,
                        name   = classified.Name,
                        Extra  = 0,
                        Extra2 = 0
                    };

                    //Use global position plus half the sim so that all classifieds are not in the bottom corner

                    mapitems.Add(mapitem);
                }
                //Send the events, if we have any
                if (mapitems.Count != 0)
                {
                    remoteClient.SendMapItemReply(mapitems.ToArray(), itemtype, flags);
                    mapitems.Clear();
                }
            }

            #endregion
        }
Пример #3
0
        public void GodlikeMessage(IClientAPI client, UUID requester, string Method, List <string> Parameters)
        {
            if (RegionConnector == null)
            {
                return;
            }
            IScenePresence Sp = ((Scene)client.Scene).GetScenePresence(client.AgentId);

            if (!((Scene)client.Scene).Permissions.CanIssueEstateCommand(client.AgentId, false))
            {
                return;
            }

            string parameter1 = Parameters[0];

            if (Method == "telehub")
            {
                if (parameter1 == "spawnpoint remove")
                {
                    Telehub telehub = RegionConnector.FindTelehub(client.Scene.RegionInfo.RegionID, client.Scene.RegionInfo.RegionHandle);
                    if (telehub == null)
                    {
                        return;
                    }
                    //Remove the one we sent at X
                    telehub.SpawnPos.RemoveAt(int.Parse(Parameters[1]));
                    RegionConnector.AddTelehub(telehub, client.Scene.RegionInfo.RegionHandle);
                    SendTelehubInfo(client);
                }
                if (parameter1 == "spawnpoint add")
                {
                    ISceneChildEntity part = Sp.Scene.GetSceneObjectPart(uint.Parse(Parameters[1]));
                    if (part == null)
                    {
                        return;
                    }
                    Telehub telehub = RegionConnector.FindTelehub(client.Scene.RegionInfo.RegionID, client.Scene.RegionInfo.RegionHandle);
                    if (telehub == null)
                    {
                        return;
                    }
                    telehub.RegionLocX = client.Scene.RegionInfo.RegionLocX;
                    telehub.RegionLocY = client.Scene.RegionInfo.RegionLocY;
                    telehub.RegionID   = client.Scene.RegionInfo.RegionID;
                    Vector3 pos = new Vector3(telehub.TelehubLocX, telehub.TelehubLocY, telehub.TelehubLocZ);
                    if (telehub.TelehubLocX == 0 && telehub.TelehubLocY == 0)
                    {
                        return;                                        //No spawns without a telehub
                    }
                    telehub.SpawnPos.Add(part.AbsolutePosition - pos); //Spawns are offsets
                    RegionConnector.AddTelehub(telehub, client.Scene.RegionInfo.RegionHandle);
                    SendTelehubInfo(client);
                }
                if (parameter1 == "delete")
                {
                    RegionConnector.RemoveTelehub(client.Scene.RegionInfo.RegionID, client.Scene.RegionInfo.RegionHandle);
                    SendTelehubInfo(client);
                }
                if (parameter1 == "connect")
                {
                    ISceneChildEntity part = Sp.Scene.GetSceneObjectPart(uint.Parse(Parameters[1]));
                    if (part == null)
                    {
                        return;
                    }
                    Telehub telehub = RegionConnector.FindTelehub(client.Scene.RegionInfo.RegionID, client.Scene.RegionInfo.RegionHandle);
                    if (telehub == null)
                    {
                        telehub = new Telehub();
                    }
                    telehub.RegionLocX  = client.Scene.RegionInfo.RegionLocX;
                    telehub.RegionLocY  = client.Scene.RegionInfo.RegionLocY;
                    telehub.RegionID    = client.Scene.RegionInfo.RegionID;
                    telehub.TelehubLocX = part.AbsolutePosition.X;
                    telehub.TelehubLocY = part.AbsolutePosition.Y;
                    telehub.TelehubLocZ = part.AbsolutePosition.Z;
                    telehub.TelehubRotX = part.ParentEntity.Rotation.X;
                    telehub.TelehubRotY = part.ParentEntity.Rotation.Y;
                    telehub.TelehubRotZ = part.ParentEntity.Rotation.Z;
                    telehub.ObjectUUID  = part.UUID;
                    telehub.Name        = part.Name;
                    RegionConnector.AddTelehub(telehub, client.Scene.RegionInfo.RegionHandle);
                    SendTelehubInfo(client);
                }

                if (parameter1 == "info ui")
                {
                    SendTelehubInfo(client);
                }
            }
        }