public ILandObject Copy() { ILandObject newLand = new LandObject(landData.OwnerID, landData.IsGroupOwned, m_scene); //Place all new variables here! newLand.landBitmap = (bool[, ])(landBitmap.Clone()); newLand.landData = landData.Copy(); return(newLand); }
public ILandObject GetLandObject(float x_float, float y_float) { if (m_landManagementModule != null) { return m_landManagementModule.GetLandObject(x_float, y_float); } ILandObject obj = new LandObject(UUID.Zero, false, m_scene); obj.LandData.Name = "NO LAND"; return obj; }
public void Clear(bool setupDefaultParcel) { m_parcels.Clear(); if (setupDefaultParcel) { ILandObject obj = new LandObject(UUID.Zero, false, m_scene); obj.LandData.Name = "Your Parcel"; m_parcels.Add(obj); } }
public ILandObject GetLandObject(int x, int y) { if (m_landManagementModule != null) { return m_landManagementModule.GetLandObject(x, y); } ILandObject obj = new LandObject(UUID.Zero, false, m_scene); obj.LandData.Name = "NO LAND"; return obj; }
public ILandObject GetNearestLandObjectInRegion(float x_float, float y_float) { if (m_landManagementModule != null) { return(m_landManagementModule.GetNearestLandObjectInRegion(x_float, y_float)); } ILandObject obj = new LandObject(UUID.Zero, false, m_scene); obj.landData.Name = "NO LAND"; return(obj); }
public ILandObject Copy() { ILandObject newLand = new LandObject(LandData.OwnerID, LandData.IsGroupOwned, m_scene); //Place all new variables here! newLand.LandData = LandData.Copy(); return newLand; }
public void TestLoadOarDeededLand() { TestHelpers.InMethod(); // TestHelpers.EnableLogging(); UUID landID = TestHelpers.ParseTail(0x10); MockGroupsServicesConnector groupsService = new MockGroupsServicesConnector(); IConfigSource configSource = new IniConfigSource(); IConfig config = configSource.AddConfig("Groups"); config.Set("Enabled", true); config.Set("Module", "GroupsModule"); config.Set("DebugEnabled", true); SceneHelpers.SetupSceneModules( m_scene, configSource, new object[] { new GroupsModule(), groupsService, new LandManagementModule() }); // Create group in scene for loading // FIXME: For now we'll put up with the issue that we'll get a group ID that varies across tests. UUID groupID = groupsService.CreateGroup(UUID.Zero, "group1", "", true, UUID.Zero, 3, true, true, true, UUID.Zero); // Construct OAR MemoryStream oarStream = new MemoryStream(); TarArchiveWriter tar = new TarArchiveWriter(oarStream); tar.WriteDir(ArchiveConstants.LANDDATA_PATH); tar.WriteFile( ArchiveConstants.CONTROL_FILE_PATH, new ArchiveWriteRequest(m_scene, (Stream)null, Guid.Empty).CreateControlFile(new ArchiveScenesGroup())); LandObject lo = new LandObject(groupID, true, m_scene); lo.SetLandBitmap(lo.BasicFullRegionLandBitmap()); LandData ld = lo.LandData; ld.GlobalID = landID; string ldPath = ArchiveConstants.CreateOarLandDataPath(ld); Dictionary<string, object> options = new Dictionary<string, object>(); tar.WriteFile(ldPath, LandDataSerializer.Serialize(ld, options)); tar.Close(); oarStream = new MemoryStream(oarStream.ToArray()); // Load OAR lock (this) { m_scene.EventManager.OnOarFileLoaded += LoadCompleted; m_archiverModule.DearchiveRegion(oarStream); } ILandObject rLo = m_scene.LandChannel.GetLandObject(16, 16); LandData rLd = rLo.LandData; Assert.That(rLd.GlobalID, Is.EqualTo(landID)); Assert.That(rLd.OwnerID, Is.EqualTo(groupID)); Assert.That(rLd.GroupID, Is.EqualTo(groupID)); Assert.That(rLd.IsGroupOwned, Is.EqualTo(true)); }
/// <summary> /// Create a default parcel that spans the entire region and is owned by the estate owner. /// </summary> /// <returns>The parcel created.</returns> protected ILandObject CreateDefaultParcel() { m_log.DebugFormat( "[LAND MANAGEMENT MODULE]: Creating default parcel for region {0}", m_scene.RegionInfo.RegionName); ILandObject fullSimParcel = new LandObject(UUID.Zero, false, m_scene); fullSimParcel.SetLandBitmap(fullSimParcel.GetSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize)); fullSimParcel.LandData.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner; fullSimParcel.LandData.ClaimDate = Util.UnixTimeSinceEpoch(); return AddLandObject(fullSimParcel); }
public ILandObject GetLandObject(float x, float y) { //m_log.DebugFormat("[BIGLANDTESTFLOAT]: <{0},{1}>", x, y); if (x > 0 && x <= (int)Constants.RegionSize && y > 0 && y <= (int)Constants.RegionSize) { return RootRegionLandChannel.GetLandObject(x, y); } else { int offsetX = (int)(x/(int) Constants.RegionSize); int offsetY = (int)(y/(int) Constants.RegionSize); offsetX *= (int) Constants.RegionSize; offsetY *= (int) Constants.RegionSize; foreach (RegionData regionData in RegionConnections) { if (regionData.Offset.X == offsetX && regionData.Offset.Y == offsetY) { return regionData.RegionScene.RequestModuleInterface<IParcelManagementModule>().GetLandObject(x - offsetX, y - offsetY); } } ILandObject obj = new LandObject(UUID.Zero, false, RegData.RegionScene); obj.LandData.Name = "NO LAND"; return obj; } }
private void EventManagerOnIncomingLandDataFromStorage(List<LandData> data) { // m_log.DebugFormat( // "[LAND MANAGMENT MODULE]: Processing {0} incoming parcels on {1}", data.Count, m_scene.Name); // Prevent race conditions from any auto-creation of new parcels for varregions whilst we are still loading // the existing parcels. lock (m_landList) { for (int i = 0; i < data.Count; i++) IncomingLandObjectFromStorage(data[i]); // Layer data is in landUnit (4m) chunks for (int y = 0; y < m_scene.RegionInfo.RegionSizeY / Constants.TerrainPatchSize * (Constants.TerrainPatchSize / LandUnit); y++) { for (int x = 0; x < m_scene.RegionInfo.RegionSizeX / Constants.TerrainPatchSize * (Constants.TerrainPatchSize / LandUnit); x++) { if (m_landIDList[x, y] == 0) { if (m_landList.Count == 1) { m_log.DebugFormat( "[{0}]: Auto-extending land parcel as landID at {1},{2} is 0 and only one land parcel is present in {3}", LogHeader, x, y, m_scene.Name); int onlyParcelID = 0; ILandObject onlyLandObject = null; foreach (KeyValuePair<int, ILandObject> kvp in m_landList) { onlyParcelID = kvp.Key; onlyLandObject = kvp.Value; break; } // There is only one parcel. Grow it to fill all the unallocated spaces. for (int xx = 0; xx < m_landIDList.GetLength(0); xx++) for (int yy = 0; yy < m_landIDList.GetLength(1); yy++) if (m_landIDList[xx, yy] == 0) m_landIDList[xx, yy] = onlyParcelID; onlyLandObject.LandBitmap = CreateBitmapForID(onlyParcelID); } else if (m_landList.Count > 1) { m_log.DebugFormat( "{0}: Auto-creating land parcel as landID at {1},{2} is 0 and more than one land parcel is present in {3}", LogHeader, x, y, m_scene.Name); // There are several other parcels so we must create a new one for the unassigned space ILandObject newLand = new LandObject(UUID.Zero, false, m_scene); // Claim all the unclaimed "0" ids newLand.SetLandBitmap(CreateBitmapForID(0)); newLand.LandData.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner; newLand.LandData.ClaimDate = Util.UnixTimeSinceEpoch(); newLand = AddLandObject(newLand); } else { // We should never reach this point as the separate code path when no land data exists should have fired instead. m_log.WarnFormat( "{0}: Ignoring request to auto-create parcel in {1} as there are no other parcels present", LogHeader, m_scene.Name); } } } } } }
/// <summary> /// Create a default parcel that spans the entire region and is owned by the estate owner. /// </summary> /// <returns>The parcel created.</returns> protected ILandObject CreateDefaultParcel() { m_log.DebugFormat("{0} Creating default parcel for region {1}", LogHeader, m_scene.RegionInfo.RegionName); ILandObject fullSimParcel = new LandObject(UUID.Zero, false, m_scene); fullSimParcel.SetLandBitmap(fullSimParcel.GetSquareLandBitmap(0, 0, (int)m_scene.RegionInfo.RegionSizeX, (int)m_scene.RegionInfo.RegionSizeY)); fullSimParcel.LandData.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner; fullSimParcel.LandData.ClaimDate = Util.UnixTimeSinceEpoch(); return AddLandObject(fullSimParcel); }
public void IncomingLandObjectFromStorage(LandData data) { ILandObject new_land = new LandObject(data.OwnerID, data.IsGroupOwned, m_scene); new_land.landData = data.Copy(); new_land.setLandBitmapFromByteArray(); new_land.landData.UpdateForcedAutoReturn(m_scene.RegionInfo.MaxAutoReturn); AddLandObject(new_land); }
// Given a region position, return the parcel land object for that location private ILandObject GetLandObject(int x, int y, bool returnNullIfLandObjectNotFound) { ILandObject ret = null; if (x >= m_scene.RegionInfo.RegionSizeX || y >= m_scene.RegionInfo.RegionSizeY || x < 0 || y < 0) { // These exceptions here will cause a lot of complaints from the users specifically because // they happen every time at border crossings if (returnNullIfLandObjectNotFound) return null; else throw new Exception( String.Format("{0} GetLandObject for non-existant position. Region={1}, pos=<{2},{3}", LogHeader, m_scene.RegionInfo.RegionName, x, y) ); } lock (m_landIDList) { try { int landID = m_landIDList[x / landUnit, y / landUnit]; if (landID == 0) { // Zero is the uninitialized value saying there is no parcel for this location. // This sometimes happens when terrain is resized. if (m_landList.Count == 1) { int onlyParcelID = 0; ILandObject onlyLandObject = null; foreach (KeyValuePair<int, ILandObject> kvp in m_landList) { onlyParcelID = kvp.Key; onlyLandObject = kvp.Value; break; } // There is only one parcel. Grow it to fill all the unallocated spaces. for (int xx = 0; xx < m_landIDList.GetLength(0); xx++) for (int yy = 0; yy < m_landIDList.GetLength(1); yy++) if (m_landIDList[xx, yy] == 0) m_landIDList[xx, yy] = onlyParcelID; onlyLandObject.LandBitmap = CreateBitmapForID(onlyParcelID); landID = onlyParcelID; } else { // There are several other parcels so we must create a new one for the unassigned space ILandObject newLand = new LandObject(UUID.Zero, false, m_scene); // Claim all the unclaimed "0" ids newLand.SetLandBitmap(CreateBitmapForID(0)); newLand.LandData.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner; newLand.LandData.ClaimDate = Util.UnixTimeSinceEpoch(); AddLandObject(newLand); landID = m_lastLandLocalID; } } ret = m_landList[landID]; } catch (IndexOutOfRangeException) { m_log.ErrorFormat( "{0} GetLandObject: Tried to retrieve land object from out of bounds co-ordinate ({1},{2}) in {3}. landListSize=({4},{5})", LogHeader, x, y, m_scene.RegionInfo.RegionName, m_landIDList.GetLength(0), m_landIDList.GetLength(1)); return null; } catch { m_log.ErrorFormat( "{0} GetLandObject: LandID not in landlist. XY=<{1},{2}> in {3}. landID[x,y]={4}", LogHeader, x, y, m_scene.RegionInfo.RegionName, m_landIDList[x/landUnit, y/landUnit]); return null; } } return ret; }
public void EventManagerOnIncomingLandDataFromStorage(List<LandData> data, Vector2 parcelOffset) { bool result = true; #if (!ISWIN) foreach (LandData t in data) { if (!PreprocessIncomingLandObjectFromStorage(t, parcelOffset)) { result = false; } } #else foreach (LandData t in data.Where(t => !PreprocessIncomingLandObjectFromStorage(t, parcelOffset))) { result = false; } #endif List<ILandObject> newSimDefault = new List<ILandObject>(); if (!result || data.Count == 0) //Force a new base first, then force a merge later newSimDefault = AllParcels().Count > 0 ? AllParcels() : new List<ILandObject>(new ILandObject[1] {ResetSimLandObjects()}); foreach (LandData t in data) { ILandObject new_land = new LandObject(t.OwnerID, t.IsGroupOwned, m_scene); new_land.LandData = t; if (SetLandBitmapFromByteArray(new_land, !result, parcelOffset)) //Merge it into the large parcel if possible { new_land.ForceUpdateLandInfo(); new_land.SetInfoID(); AddLandObject(new_land, true); } } if (AllParcels().Count == 0) //Serious fallback ResetSimLandObjects(); }
/// <summary> /// Resets the sim to the default land object (full sim piece of land owned by the default user) /// </summary> public void ResetSimLandObjects() { //Remove all the land objects in the sim and add a blank, full sim land object set to public lock (m_landList) { m_landList.Clear(); m_lastLandLocalID = ParcelManagementModule.START_LAND_LOCAL_ID; m_landIDList.Initialize(); } ILandObject fullSimParcel = new LandObject(UUID.Zero, false, m_scene); fullSimParcel.SetLandBitmap(fullSimParcel.GetSquareLandBitmap(0, 0, m_scene.RegionInfo.RegionSizeX, m_scene.RegionInfo.RegionSizeY)); if (fullSimParcel.LandData.OwnerID == UUID.Zero) fullSimParcel.LandData.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner; UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, fullSimParcel.LandData.OwnerID); while (fullSimParcel.LandData.OwnerID == UUID.Zero || account == null) { m_log.Warn("[ParcelManagement]: Could not find user for parcel, please give a valid user to make the owner"); string userName = MainConsole.Instance.CmdPrompt("User Name:", ""); if (userName == "") { m_log.Warn("Put in a valid username."); continue; } account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, userName); if (account != null) fullSimParcel.LandData.OwnerID = account.PrincipalID; else m_log.Warn("Could not find the user."); } m_log.Info("[ParcelManagement]: No land found for region " + m_scene.RegionInfo.RegionName + ", setting owner to " + fullSimParcel.LandData.OwnerID); fullSimParcel.LandData.ClaimDate = Util.UnixTimeSinceEpoch(); fullSimParcel.SetInfoID(); AddLandObject(fullSimParcel); }
private void IncomingLandObjectFromStorage(LandData data) { ILandObject new_land = new LandObject(data.OwnerID, data.IsGroupOwned, m_scene); new_land.LandData = data.Copy(); new_land.SetLandBitmapFromByteArray(); AddLandObject(new_land); // new_land.SendLandUpdateToAvatarsOverMe(); }
/// <summary> /// Resets the sim to the default land object (full sim piece of land owned by the default user) /// </summary> public void ResetSimLandObjects() { //Remove all the land objects in the sim and add a blank, full sim land object set to public lock (m_landList) { m_landList.Clear(); m_lastLandLocalID = LandChannel.START_LAND_LOCAL_ID - 1; m_landIDList.Initialize(); } ILandObject fullSimParcel = new LandObject(UUID.Zero, false, m_scene); fullSimParcel.setLandBitmap(fullSimParcel.getSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize)); if (m_scene.RegionInfo.EstateSettings.EstateOwner != UUID.Zero) fullSimParcel.landData.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner; else fullSimParcel.landData.OwnerID = m_scene.RegionInfo.MasterAvatarAssignedUUID; fullSimParcel.landData.ClaimDate = Util.UnixTimeSinceEpoch(); AddLandObject(fullSimParcel); }
/// <summary> /// Resets the sim to the default land object (full sim piece of land owned by the default user) /// </summary> public void ResetSimLandObjects() { //Remove all the land objects in the sim and add a blank, full sim land object set to public lock (m_landList) { m_landList.Clear(); m_lastLandLocalID = ParcelManagementModule.START_LAND_LOCAL_ID; m_landIDList.Initialize(); } ILandObject fullSimParcel = new LandObject(UUID.Zero, false, m_scene); fullSimParcel.SetLandBitmap(fullSimParcel.GetSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize)); fullSimParcel.LandData.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner; fullSimParcel.LandData.ClaimDate = Util.UnixTimeSinceEpoch(); fullSimParcel.SetInfoID(); AddLandObject(fullSimParcel); }
private void SetupDefaultParcel() { ILandObject obj = new LandObject(UUID.Zero, false, m_scene); obj.LandData.Name = "Your Parcel"; m_parcels.Add(obj); }
private void IncomingLandObjectFromStorage(LandData data) { ILandObject new_land = new LandObject(data, m_scene); new_land.SetLandBitmapFromByteArray(); AddLandObject(new_land); }
protected ILandObject GetNoLand() { ILandObject obj = new LandObject(UUID.Zero, false, m_scene); obj.LandData.Name = "NO LAND"; return obj; }
public void IncomingLandObjectFromStorage(LandData data) { ILandObject new_land = new LandObject(data.OwnerID, data.IsGroupOwned, m_scene); new_land.LandData = data.Copy(); new_land.SetLandBitmapFromByteArray(); AddLandObject(new_land); }
public void EventManagerOnIncomingLandDataFromStorage(List<LandData> data, Vector2 parcelOffset) { bool result = true; for (int i = 0; i < data.Count; i++) { if (!PreprocessIncomingLandObjectFromStorage(data[i], parcelOffset)) result = false; } List<ILandObject> newSimDefault = new List<ILandObject>(); if (!result || data.Count == 0)//Force a new base first, then force a merge later if (AllParcels().Count > 0) newSimDefault = AllParcels(); else newSimDefault = new List<ILandObject>(new ILandObject[1]{ResetSimLandObjects()}); for (int i = 0; i < data.Count; i++) { ILandObject new_land = new LandObject(data[i].OwnerID, data[i].IsGroupOwned, m_scene); new_land.LandData = data[i]; if (SetLandBitmapFromByteArray(new_land, !result, parcelOffset))//Merge it into the large parcel if possible { new_land.ForceUpdateLandInfo(); new_land.SetInfoID(); AddLandObject(new_land, true); } } if (AllParcels().Count == 0)//Serious fallback ResetSimLandObjects(); }
public ILandObject Copy() { ILandObject newLand = new LandObject(LandData, m_scene); newLand.LandBitmap = (bool[,]) (LandBitmap.Clone()); return newLand; }
public bool PreprocessIncomingLandObjectFromStorage(LandData data, Vector2 parcelOffset) { ILandObject new_land = new LandObject(data.OwnerID, data.IsGroupOwned, m_scene); new_land.LandData = data; return SetLandBitmapFromByteArray(new_land, false, parcelOffset); }
public ILandObject Copy() { ILandObject newLand = new LandObject(LandData.OwnerID, LandData.IsGroupOwned, m_scene); //Place all new variables here! newLand.LandBitmap = (bool[,]) (LandBitmap.Clone()); newLand.LandData = LandData.Copy(); return newLand; }
public bool PreprocessIncomingLandObjectFromStorage(LandData data) { ILandObject new_land = new LandObject(data.OwnerID, data.IsGroupOwned, m_scene); new_land.LandData = data; new_land.SetInfoID(); if (!new_land.SetLandBitmapFromByteArray()) return false; AddLandObject(new_land, true); return true; }
/// <summary> /// Resets the sim to the default land object (full sim piece of land owned by the default user) /// </summary> public ILandObject ResetSimLandObjects() { ClearAllParcels (); ILandObject fullSimParcel = new LandObject (UUID.Zero, false, m_scene); if (fullSimParcel.LandData.OwnerID == UUID.Zero) fullSimParcel.LandData.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner; UserAccount account = m_scene.UserAccountService.GetUserAccount (m_scene.RegionInfo.ScopeID, fullSimParcel.LandData.OwnerID); while (fullSimParcel.LandData.OwnerID == UUID.Zero || account == null) { m_log.Warn ("[ParcelManagement]: Could not find user for parcel, please give a valid user to make the owner"); string userName = MainConsole.Instance.CmdPrompt ("User Name:", ""); if (userName == "") { m_log.Warn ("Put in a valid username."); continue; } account = m_scene.UserAccountService.GetUserAccount (m_scene.RegionInfo.ScopeID, userName); if (account != null) fullSimParcel.LandData.OwnerID = account.PrincipalID; else m_log.Warn ("Could not find the user."); } m_log.Info ("[ParcelManagement]: No land found for region " + m_scene.RegionInfo.RegionName + ", setting owner to " + fullSimParcel.LandData.OwnerID); fullSimParcel.LandData.ClaimDate = Util.UnixTimeSinceEpoch (); fullSimParcel.SetInfoID (); fullSimParcel.LandData.Bitmap = new byte[(m_scene.RegionInfo.RegionSizeX / 4) * (m_scene.RegionInfo.RegionSizeY / 4) / 8]; fullSimParcel = AddLandObject(fullSimParcel); ModifyLandBitmapSquare(0, 0, m_scene.RegionInfo.RegionSizeX, m_scene.RegionInfo.RegionSizeY, fullSimParcel.LandData.LocalID); return fullSimParcel; }
public ILandObject GetLandObject(int x, int y) { //m_log.DebugFormat("[BIGLANDTESTINT]: <{0},{1}>", x, y); if (x > 0 && x <= (int)Constants.RegionSize && y > 0 && y <= (int)Constants.RegionSize) { return RootRegionLandChannel.GetLandObject(x, y); } else { int offsetX = (x / (int)Constants.RegionSize); int offsetY = (y / (int)Constants.RegionSize); offsetX *= (int)Constants.RegionSize; offsetY *= (int)Constants.RegionSize; foreach (RegionData regionData in RegionConnections) { if (regionData.Offset.X == offsetX && regionData.Offset.Y == offsetY) { return regionData.RegionScene.LandChannel.GetLandObject(x - offsetX, y - offsetY); } } ILandObject obj = new LandObject(UUID.Zero, false, RegData.RegionScene); obj.landData.Name = "NO LAND"; return obj; } }