public bool TryUnlinkRegion(string mapName) { MainConsole.Instance.DebugFormat("[HYPERGRID LINKER]: Request to unlink {0}", mapName); GridRegion regInfo = null; //TODO: List <GridRegion> regions = m_Database.Get(mapName, null, null, null); if (regions != null && regions.Count > 0) { Aurora.Framework.RegionFlags rflags = (Aurora.Framework.RegionFlags)regions[0].Flags; if ((rflags & Aurora.Framework.RegionFlags.Hyperlink) != 0) { regInfo = new GridRegion(); regInfo.RegionID = regions[0].RegionID; regInfo.ScopeID = m_ScopeID; } } if (regInfo != null) { RemoveHyperlinkRegion(regInfo.RegionID); return(true); } else { MainConsole.Instance.InfoFormat("[HYPERGRID LINKER]: Region {0} not found", mapName); return(false); } }
OSDMap GetRegion(OSDMap map) { OSDMap resp = new OSDMap(); IRegionData regiondata = DataPlugins.RequestPlugin <IRegionData> (); if (regiondata != null && (map.ContainsKey("RegionID") || map.ContainsKey("Region"))) { string regionName = map.ContainsKey("Region") ? map ["Region"].ToString().Trim() : ""; UUID regionID = map.ContainsKey("RegionID") ? UUID.Parse(map ["RegionID"].ToString()) : UUID.Zero; // not used?? // UUID scopeID = map.ContainsKey ("ScopeID") ? UUID.Parse (map ["ScopeID"].ToString ()) : UUID.Zero; GridRegion region = null; if (regionID != UUID.Zero) { region = regiondata.Get(regionID, null); } else if (regionName != string.Empty) { region = regiondata.Get(regionName, null, null, null) [0]; } if (region != null) { resp ["Region"] = region.ToOSD(); } } return(resp); }
public bool TryUnlinkRegion(string mapName) { m_log.DebugFormat("[HYPERGRID LINKER]: Request to unlink {0}", mapName); GridRegion regInfo = null; List <RegionData> regions = m_Database.Get(Util.EscapeForLike(mapName), m_ScopeID); if (regions != null && regions.Count > 0) { OpenSim.Framework.RegionFlags rflags = (OpenSim.Framework.RegionFlags)Convert.ToInt32(regions[0].Data["flags"]); if ((rflags & OpenSim.Framework.RegionFlags.Hyperlink) != 0) { regInfo = new GridRegion(); regInfo.RegionID = regions[0].RegionID; regInfo.ScopeID = m_ScopeID; } } if (regInfo != null) { RemoveHyperlinkRegion(regInfo.RegionID); return(true); } else { m_log.InfoFormat("[HYPERGRID LINKER]: Region {0} not found", mapName); return(false); } }
public List <LandData> GetParcelsWithNameByRegion(uint start, uint count, UUID RegionID, UUID ScopeID, string name) { List <LandData> resp = new List <LandData>(0); if (count == 0) { return(resp); } IRegionData regiondata = DataManager.DataManager.RequestPlugin <IRegionData>(); if (regiondata != null) { GridRegion region = regiondata.Get(RegionID, ScopeID); if (region != null) { QueryFilter filter = new QueryFilter(); filter.andFilters["RegionID"] = RegionID; filter.andFilters["Name"] = name; Dictionary <string, bool> sort = new Dictionary <string, bool>(1); sort["OwnerID"] = false; return(Query2LandData(GD.Query(new string[1] { "*" }, "searchparcel", filter, sort, start, count))); } } return(resp); }
public List <LandData> GetParcelsByRegion(uint start, uint count, UUID RegionID, UUID scopeID, UUID owner, ParcelFlags flags, ParcelCategory category) { List <LandData> resp = new List <LandData>(0); if (count == 0) { return(resp); } IRegionData regiondata = DataManager.DataManager.RequestPlugin <IRegionData>(); if (regiondata != null) { GridRegion region = regiondata.Get(RegionID, scopeID); if (region != null) { QueryFilter filter = GetParcelsByRegionWhereClause(RegionID, scopeID, owner, flags, category); Dictionary <string, bool> sort = new Dictionary <string, bool>(1); sort["OwnerID"] = false; return(Query2LandData(GD.Query(new string[1] { "*" }, "searchparcel", filter, sort, start, count))); } } return(resp); }
public LandData GetParcelInfo(UUID RegionID, UUID ScopeID, string ParcelName) { IRegionData regiondata = DataManager.DataManager.RequestPlugin <IRegionData>(); if (regiondata != null) { GridRegion region = regiondata.Get(RegionID, ScopeID); if (region != null) { UUID parcelInfoID = UUID.Zero; QueryFilter filter = new QueryFilter(); filter.andFilters["Name"] = ParcelName; filter.andFilters["RegionID"] = RegionID; List <string> query = GD.Query(new string[1] { "InfoUUID" }, "searchparcel", filter, null, 0, 1); if (query.Count >= 1 && UUID.TryParse(query[0], out parcelInfoID)) { return(GetParcelInfo(parcelInfoID)); } } } return(null); }
private OSDArray MonolithicRegionLookup(string[] parts) { OSDArray resp = new OSDArray(); if (parts.Length < 1 || parts[0] != "MonolithicRegionLookup") { return(resp); } IRegionData regiondata = Aurora.DataManager.DataManager.RequestPlugin <IRegionData>(); if (regiondata != null) { List <GridRegion> regions = regiondata.Get(RegionFlags.RegionOnline); OSDMap regionResp; foreach (GridRegion region in regions) { regionResp = new OSDMap(8); regionResp["Name"] = region.RegionName; regionResp["UUID"] = region.RegionID; regionResp["x"] = region.RegionLocX / Constants.RegionSize; regionResp["y"] = region.RegionLocY / Constants.RegionSize; regionResp["z"] = region.RegionLocZ / Constants.RegionSize; regionResp["width"] = region.RegionSizeX; regionResp["height"] = region.RegionSizeY; regionResp["depth"] = region.RegionSizeZ; resp.Add(regionResp); } } return(resp); }
private static List <EventData> Query2EventData(List <string> RetVal) { List <EventData> Events = new List <EventData>(); IRegionData regiondata = Aurora.DataManager.DataManager.RequestPlugin <IRegionData>(); if (RetVal.Count % 15 != 0 || regiondata == null) { return(Events); } GridRegion region; EventData data; for (int i = 0; i < RetVal.Count; i += 15) { data = new EventData(); region = regiondata.Get(UUID.Parse(RetVal[2].ToString()), UUID.Zero); if (region == null) { continue; } data.simName = region.RegionName; data.eventID = Convert.ToUInt32(RetVal[i]); data.creator = RetVal[i + 1]; //Parse the time out for the viewer DateTime date = DateTime.Parse(RetVal[i + 4].ToString()); data.date = date.ToString(new DateTimeFormatInfo()); data.dateUTC = (uint)Util.ToUnixTime(date); data.cover = data.amount = Convert.ToUInt32(RetVal[i + 5]); data.maturity = Convert.ToInt32(RetVal[i + 6]); data.eventFlags = Convert.ToUInt32(RetVal[i + 7]); data.duration = Convert.ToUInt32(RetVal[i + 8]); data.globalPos = new Vector3( region.RegionLocX + float.Parse(RetVal[i + 9]), region.RegionLocY + float.Parse(RetVal[i + 10]), region.RegionLocZ + float.Parse(RetVal[i + 11]) ); data.name = RetVal[i + 12]; data.description = RetVal[i + 13]; data.category = RetVal[i + 14]; Events.Add(data); } return(Events); }
/// <summary> /// Retrives all events in the given region by their maturity level /// </summary> /// <param name = "regionName"></param> /// <param name = "maturity">Uses DirectoryManager.EventFlags to determine the maturity requested</param> /// <returns></returns> public DirEventsReplyData[] FindAllEventsInRegion(string regionName, int maturity) { List <DirEventsReplyData> Data = new List <DirEventsReplyData>(); IRegionData regiondata = Aurora.DataManager.DataManager.RequestPlugin <IRegionData>(); if (regiondata != null) { List <GridRegion> regions = regiondata.Get(regionName, UUID.Zero); if (regions.Count >= 1) { Dictionary <string, object> whereClause = new Dictionary <string, object>(); whereClause["region"] = regions[0].RegionID.ToString(); whereClause["maturity"] = maturity; List <string> retVal = GD.Query(new string[] { "EID", "creator", "date", "maturity", "flags", "name" }, "asevents", new QueryFilter { andFilters = whereClause }, null, null, null); if (retVal.Count > 0) { DirEventsReplyData replyData; for (int i = 0; i < retVal.Count; i += 6) { replyData = new DirEventsReplyData { eventID = Convert.ToUInt32(retVal[i]), ownerID = new UUID(retVal[i + 1]), name = retVal[i + 5], }; DateTime date = DateTime.Parse(retVal[i + 2].ToString()); replyData.date = date.ToString(new DateTimeFormatInfo()); replyData.unixTime = (uint)Util.ToUnixTime(date); replyData.eventFlags = Convert.ToUInt32(retVal[i + 4]); Data.Add(replyData); } } } } return(Data.ToArray()); }
public uint GetNumberOfParcelsByRegion(UUID RegionID, UUID scopeID, UUID owner, ParcelFlags flags, ParcelCategory category) { IRegionData regiondata = DataManager.DataManager.RequestPlugin <IRegionData>(); if (regiondata != null) { GridRegion region = regiondata.Get(RegionID, scopeID); if (region != null) { QueryFilter filter = GetParcelsByRegionWhereClause(RegionID, scopeID, owner, flags, category); return(uint.Parse(GD.Query(new string[1] { "COUNT(ParcelID)" }, "searchparcel", filter, null, null, null)[0])); } } return(0); }
public uint GetNumberOfParcelsWithNameByRegion(UUID RegionID, UUID ScopeID, string name) { IRegionData regiondata = DataManager.DataManager.RequestPlugin <IRegionData>(); if (regiondata != null) { GridRegion region = regiondata.Get(RegionID, ScopeID); if (region != null) { QueryFilter filter = new QueryFilter(); filter.andFilters["RegionID"] = RegionID; filter.andFilters["Name"] = name; return(uint.Parse(GD.Query(new string[1] { "COUNT(ParcelID)" }, "searchparcel", filter, null, null, null)[0])); } } return(0); }
public bool TryUnlinkRegion(string mapName) { m_log.DebugFormat("[HYPERGRID LINKER]: Request to unlink {0}", mapName); GridRegion regInfo = null; List <RegionData> regions = m_Database.Get(mapName, m_ScopeID); if (regions != null && regions.Count > 0) { OpenSim.Data.RegionFlags rflags = (OpenSim.Data.RegionFlags)Convert.ToInt32(regions[0].Data["flags"]); if ((rflags & OpenSim.Data.RegionFlags.Hyperlink) != 0) { regInfo = new GridRegion(); regInfo.RegionID = regions[0].RegionID; regInfo.ScopeID = m_ScopeID; } } //foreach (GridRegion r in m_HyperlinkRegions.Values) //{ // m_log.DebugFormat("XXX Comparing {0}:{1} with {2}:{3}", host, port, r.ExternalHostName, r.HttpPort); // if (host.Equals(r.ExternalHostName) && (port == r.HttpPort)) // regInfo = r; //} if (regInfo != null) { RemoveHyperlinkRegion(regInfo.RegionID); return(true); } else { m_log.InfoFormat("[HYPERGRID LINKER]: Region {0} not found", mapName); return(false); } }
public EventData CreateEvent(UUID creator, UUID regionID, UUID parcelID, DateTime date, uint cover, EventFlags maturity, uint flags, uint duration, Vector3 localPos, string name, string description, string category) { IRegionData regiondata = Aurora.DataManager.DataManager.RequestPlugin <IRegionData>(); IParcelServiceConnector parceldata = Aurora.DataManager.DataManager.RequestPlugin <IParcelServiceConnector>(); if (regiondata == null || parceldata == null) { return(null); } GridRegion region = regiondata.Get(regionID, UUID.Zero); if (region == null) { return(null); } if (parcelID != UUID.Zero) { LandData parcel = parceldata.GetLandData(region.RegionID, parcelID); if (parcel == null) { return(null); } } EventData eventData = new EventData(); eventData.eventID = GetMaxEventID() + 1; eventData.creator = creator.ToString(); eventData.simName = region.RegionName; eventData.date = date.ToString(new DateTimeFormatInfo()); eventData.dateUTC = (uint)Util.ToUnixTime(date); eventData.cover = eventData.amount = cover; eventData.maturity = (int)maturity; eventData.eventFlags = flags | (uint)maturity; eventData.duration = duration; eventData.globalPos = new Vector3( region.RegionLocX + localPos.X, region.RegionLocY + localPos.Y, region.RegionLocZ + localPos.Z ); eventData.name = name; eventData.description = description; eventData.category = category; GD.Insert("asevents", new string[] { "EID", "creator", "region", "parcel", "date", "cover", "maturity", "flags", "duration", "localPosX", "localPosY", "localPosZ", "name", "description", "category" }, new object[] { eventData.eventID, creator.ToString(), regionID.ToString(), parcelID.ToString(), date.ToString("s"), eventData.cover, (uint)maturity, flags, duration, localPos.X, localPos.Y, localPos.Z, name, description, category }); return(eventData); }
private OSDMap RegionDetails(string[] parts) { OSDMap resp = new OSDMap(); if (parts.Length < 2 || parts[0] != "RegionDetails") { resp["Error"] = OSD.FromString("Invalid method invokation"); } else { IRegionData regiondata = Aurora.DataManager.DataManager.RequestPlugin <IRegionData>(); GridRegion region = null; if (regiondata == null) { resp["Error"] = OSD.FromString("Could not find IRegionData"); } else { UUID scopeID = UUID.Zero; UUID regionID = UUID.Zero; int x; int y; int z = 0; if (parts.Length == 2) { bool isUUID = UUID.TryParse(parts[1], out regionID); if (isUUID) { region = regiondata.Get(regionID, scopeID); } else { List <GridRegion> regions = regiondata.Get(parts[1], scopeID); if (regions.Count > 0) { region = regions[0]; } } } else if (parts.Length == 3) { bool hasScopeID = UUID.TryParse(parts[1], out scopeID); bool hasRegionID = UUID.TryParse(parts[2], out regionID); if (!hasScopeID && !hasRegionID && (int.TryParse(parts[1], out x) && int.TryParse(parts[2], out y))) { List <GridRegion> regions = regiondata.Get(x, y, UUID.Zero); if (regions.Count == 1) { region = regions[0]; } else { foreach (GridRegion _region in regions) { if (_region.RegionLocZ == 0) { region = _region; break; } } } } else if (hasScopeID && hasRegionID) { region = regiondata.Get(regionID, scopeID); } else if (hasScopeID && !hasRegionID) { List <GridRegion> regions = regiondata.Get(parts[1], scopeID); if (regions.Count > 0) { region = regions[0]; } } } else if (parts.Length == 4 && (int.TryParse(parts[1], out x) && int.TryParse(parts[2], out y) && int.TryParse(parts[3], out z))) { List <GridRegion> regions = regiondata.Get(x, y, UUID.Zero); foreach (GridRegion _region in regions) { if (_region.RegionLocZ == z) { region = _region; break; } } } } if (region == null) { resp["Error"] = OSD.FromString("Region not found"); } else { OSDMap regionDetails = new OSDMap(); regionDetails["ScopeID"] = region.ScopeID; regionDetails["RegionID"] = region.RegionID; regionDetails["RegionName"] = region.RegionName; regionDetails["RegionLocX"] = region.RegionLocX; regionDetails["RegionLocY"] = region.RegionLocY; regionDetails["RegionLocZ"] = region.RegionLocZ; regionDetails["RegionSizeX"] = region.RegionSizeX; regionDetails["RegionSizeY"] = region.RegionSizeY; regionDetails["RegionSizeZ"] = region.RegionSizeZ; regionDetails["EstateOwnerID"] = region.EstateOwner; regionDetails["EstateOwnerName"] = "Unknown User"; IUserAccountService accountService = m_registry.RequestModuleInterface <IUserAccountService>(); if (accountService != null && region.EstateOwner != UUID.Zero) { UserAccount user = accountService.GetUserAccount(region.ScopeID, region.EstateOwner); if (user != null) { regionDetails["EstateOwnerName"] = user.Name; } } resp["Region"] = regionDetails; } } return(resp); }
/// <summary> /// Tells the grid server that this region is not able to be connected to. /// This updates the down flag in the map and blocks it from becoming a 'safe' region fallback /// Only called by LLLoginService /// </summary> /// <param name = "r"></param> public virtual void SetRegionUnsafe(UUID ID) { GridRegion data = m_Database.Get(ID, UUID.Zero); if (data == null) { return; } if ((data.Flags & (int)RegionFlags.Safe) == (int)RegionFlags.Safe) { data.Flags &= ~(int)RegionFlags.Safe; //Remove only the safe var the first time } else if ((data.Flags & (int)RegionFlags.RegionOnline) == (int)RegionFlags.RegionOnline) { data.Flags &= ~(int)RegionFlags.RegionOnline; //Remove online the second time it fails } m_Database.Store(data); }
public string RegisterRegion(GridRegion regionInfos, UUID oldSessionID, out UUID SessionID) { SessionID = UUID.Zero; if (m_DisableRegistrations) { return("Registrations are disabled."); } UUID NeedToDeletePreviousRegion = UUID.Zero; IConfig gridConfig = m_config.Configs["GridService"]; //Get the range of this so that we get the full count and make sure that we are not overlapping smaller regions List <GridRegion> regions = m_Database.Get(regionInfos.RegionLocX, regionInfos.RegionLocY, regionInfos.RegionLocX + regionInfos.RegionSizeX - 1, regionInfos.RegionLocY + regionInfos.RegionSizeY - 1, regionInfos.ScopeID); if (regions.Count > 1) { //More than one region is here... it is overlapping stuff m_log.WarnFormat("[GRID SERVICE]: Region {0} tried to register in coordinates {1}, {2} which are already in use in scope {3}.", regionInfos.RegionID, regionInfos.RegionLocX, regionInfos.RegionLocY, regionInfos.ScopeID); return("Region overlaps another region"); } GridRegion region = regions.Count > 0 ? regions[0] : null; if (!m_AllowNewRegistrations && region == null) { m_log.WarnFormat("[GRID SERVICE]: Region {0} tried to register but registrations are disabled.", regionInfos.RegionName); return("Registrations are disabled."); } if (m_maxRegionSize != 0 && (regionInfos.RegionSizeX > m_maxRegionSize || regionInfos.RegionSizeY > m_maxRegionSize)) { //Too big... kick it out m_log.WarnFormat("[GRID SERVICE]: Region {0} tried to register with too large of a size {1},{2}.", regionInfos.RegionName, regionInfos.RegionSizeX, regionInfos.RegionSizeY); return("Region overlaps another region"); } if ((region != null) && (region.RegionID != regionInfos.RegionID)) { m_log.WarnFormat("[GRID SERVICE]: Region {0} tried to register in coordinates {1}, {2} which are already in use in scope {3}.", regionInfos.RegionName, regionInfos.RegionLocX, regionInfos.RegionLocY, regionInfos.ScopeID); return("Region overlaps another region"); } if ((region != null) && (region.RegionID == regionInfos.RegionID) && ((region.RegionLocX != regionInfos.RegionLocX) || (region.RegionLocY != regionInfos.RegionLocY))) { if ((region.Flags & (int)RegionFlags.NoMove) != 0) { return("Can't move this region," + region.RegionLocX + "," + region.RegionLocY); } // Region reregistering in other coordinates. Delete the old entry m_log.DebugFormat("[GRID SERVICE]: Region {0} ({1}) was previously registered at {2}-{3}. Deleting old entry.", regionInfos.RegionName, regionInfos.RegionID, regionInfos.RegionLocX, regionInfos.RegionLocY); NeedToDeletePreviousRegion = regionInfos.RegionID; } if (region != null) { // There is a preexisting record // // Get it's flags // RegionFlags rflags = (RegionFlags)region.Flags; // Is this a reservation? // if ((rflags & RegionFlags.Reservation) != 0) { // Regions reserved for the null key cannot be taken. if (region.SessionID == UUID.Zero) { return("Region location is reserved"); } // Treat it as an auth request // // NOTE: Fudging the flags value here, so these flags // should not be used elsewhere. Don't optimize // this with the later retrieval of the same flags! rflags |= RegionFlags.Authenticate; } if ((rflags & RegionFlags.Authenticate) != 0) { // Can we authenticate at all? // if (m_AuthenticationService == null) { return("No authentication possible"); } //Make sure the key exists if (!m_AuthenticationService.CheckExists(regionInfos.SessionID)) { return("Bad authentication"); } //Now verify the key if (!m_AuthenticationService.Verify(regionInfos.SessionID, regionInfos.AuthToken, 30)) { return("Bad authentication"); } } } if (!m_AllowDuplicateNames) { List <GridRegion> dupe = m_Database.Get(regionInfos.RegionName, regionInfos.ScopeID); if (dupe != null && dupe.Count > 0) { foreach (GridRegion d in dupe) { if (d.RegionID != regionInfos.RegionID) { m_log.WarnFormat("[GRID SERVICE]: Region {0} tried to register duplicate name with ID {1}.", regionInfos.RegionName, regionInfos.RegionID); return("Duplicate region name"); } } } } if (region != null) { //If we are locked out, we can't come in if ((region.Flags & (int)RegionFlags.LockedOut) != 0) { return("Region locked out"); } //Remove the reservation if we are there now region.Flags &= ~(int)RegionFlags.Reservation; regionInfos.Flags = region.Flags; // Preserve flags } else { //Regions do not get to set flags, so wipe them regionInfos.Flags = 0; //See if we are in the configs anywhere and have flags set if ((gridConfig != null) && regionInfos.RegionName != string.Empty) { int newFlags = 0; string regionName = regionInfos.RegionName.Trim().Replace(' ', '_'); newFlags = ParseFlags(newFlags, gridConfig.GetString("DefaultRegionFlags", String.Empty)); newFlags = ParseFlags(newFlags, gridConfig.GetString("Region_" + regionName, String.Empty)); newFlags = ParseFlags(newFlags, gridConfig.GetString("Region_" + regionInfos.RegionID.ToString(), String.Empty)); regionInfos.Flags = newFlags; } } //Set these so that we can make sure the region is online later regionInfos.Flags |= (int)RegionFlags.RegionOnline; regionInfos.Flags |= (int)RegionFlags.Safe; regionInfos.LastSeen = Util.UnixTimeSinceEpoch(); if (region != null) { //If we already have a session, we need to check it if (m_UseSessionID && region.SessionID != oldSessionID) { m_log.WarnFormat("[GRID SERVICE]: Region {0} called register, but the sessionID they provided is wrong!", region.RegionName); return("Wrong Session ID"); } } //Update the sessionID, use the old so that we don't generate a bunch of these if (oldSessionID == UUID.Zero) { SessionID = UUID.Random(); } else { SessionID = oldSessionID; } regionInfos.SessionID = SessionID; // Everything is ok, let's register try { if (NeedToDeletePreviousRegion != UUID.Zero) { m_Database.Delete(NeedToDeletePreviousRegion); } if (m_Database.Store(regionInfos)) { //Fire the event so that other modules notice m_simulationBase.EventManager.FireGenericEventHandler("RegionRegistered", regionInfos); m_log.DebugFormat("[GRID SERVICE]: Region {0} registered successfully at {1}-{2}", regionInfos.RegionName, regionInfos.RegionLocX, regionInfos.RegionLocY); return(String.Empty); } } catch (Exception e) { m_log.WarnFormat("[GRID SERVICE]: Database exception: {0}", e.ToString()); } return("Failed to save region into the database."); }