*Land has now been linked to the StorageManager. Next step is to fill in the functions for the different datastore interfaces for Land Objects.

afrisby
mingchen 2007-12-17 03:49:13 +00:00
parent 8e8c26acac
commit d845da215f
10 changed files with 155 additions and 64 deletions

View File

@ -289,17 +289,17 @@ namespace OpenSim.Framework.Data.MySQL
return terret; return terret;
} }
public void RemoveLandObject(uint id) public void RemoveLandObject(uint id, LLUUID regionUUID)
{ {
} }
public void StoreParcel(Land parcel) public void StoreLandObject(Land parcel, LLUUID regionUUID)
{ {
} }
public List<Land> LoadLandObjects() public List<Framework.LandData> LoadLandObjects(LLUUID regionUUID)
{ {
return new List<Land>(); return new List<LandData>();
} }
private void DisplayDataSet(DataSet ds, string title) private void DisplayDataSet(DataSet ds, string title)

View File

@ -26,7 +26,7 @@
* *
*/ */
using libsecondlife; using libsecondlife;
using System.Collections.Generic;
namespace OpenSim.Framework namespace OpenSim.Framework
{ {
public class LandData public class LandData
@ -74,6 +74,8 @@ namespace OpenSim.Framework
public LLVector3 userLocation = new LLVector3(); public LLVector3 userLocation = new LLVector3();
public LLVector3 userLookAt = new LLVector3(); public LLVector3 userLookAt = new LLVector3();
public List<ParcelManager.ParcelAccessEntry> parcelAccessList = new List<ParcelManager.ParcelAccessEntry>();
public LandData() public LandData()
{ {
globalID = LLUUID.Random(); globalID = LLUUID.Random();
@ -117,6 +119,17 @@ namespace OpenSim.Framework
landData.userLocation = userLocation; landData.userLocation = userLocation;
landData.userLookAt = userLookAt; landData.userLookAt = userLookAt;
landData.parcelAccessList.Clear();
foreach (ParcelManager.ParcelAccessEntry entry in parcelAccessList)
{
ParcelManager.ParcelAccessEntry newEntry = new ParcelManager.ParcelAccessEntry();
newEntry.AgentID = entry.AgentID;
newEntry.Flags = entry.Flags;
newEntry.Time = entry.Time;
landData.parcelAccessList.Add(newEntry);
}
return landData; return landData;
} }
} }

View File

@ -136,19 +136,17 @@ namespace OpenSim.Region.ClientStack
{ {
m_log.Verbose("PARCEL", "Found master avatar [" + masterAvatar.UUID.ToStringHyphenated() + "]"); m_log.Verbose("PARCEL", "Found master avatar [" + masterAvatar.UUID.ToStringHyphenated() + "]");
scene.RegionInfo.MasterAvatarAssignedUUID = masterAvatar.UUID; scene.RegionInfo.MasterAvatarAssignedUUID = masterAvatar.UUID;
//TODO: Load parcels from storageManager
} }
else else
{ {
m_log.Verbose("PARCEL", "No master avatar found, using null."); m_log.Verbose("PARCEL", "No master avatar found, using null.");
scene.RegionInfo.MasterAvatarAssignedUUID = LLUUID.Zero; scene.RegionInfo.MasterAvatarAssignedUUID = LLUUID.Zero;
//TODO: Load parcels from storageManager
} }
scene.LandManager.resetSimLandObjects(); scene.LandManager.resetSimLandObjects();
scene.LoadPrimsFromStorage(m_permissions); scene.LoadPrimsFromStorage(m_permissions);
scene.loadAllLandObjectsFromStorage();
scene.performParcelPrimCountUpdate(); scene.performParcelPrimCountUpdate();
scene.StartTimer(); scene.StartTimer();
return scene; return scene;

View File

@ -50,9 +50,9 @@ namespace OpenSim.Region.Environment.Interfaces
void StoreTerrain(double[,] terrain, LLUUID regionID); void StoreTerrain(double[,] terrain, LLUUID regionID);
double[,] LoadTerrain(LLUUID regionID); double[,] LoadTerrain(LLUUID regionID);
void StoreParcel(Land Parcel); void StoreLandObject(Land Parcel,LLUUID regionUUID);
void RemoveLandObject(uint ID); void RemoveLandObject(uint ID, LLUUID regionUUID);
List<Land> LoadLandObjects(); List<Framework.LandData> LoadLandObjects(LLUUID regionUUID);
void Shutdown(); void Shutdown();
} }

View File

@ -32,6 +32,7 @@ using libsecondlife;
using libsecondlife.Packets; using libsecondlife.Packets;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Region.Environment.Scenes; using OpenSim.Region.Environment.Scenes;
using OpenSim.Region.Environment.Interfaces;
namespace OpenSim.Region.Environment.LandManagement namespace OpenSim.Region.Environment.LandManagement
{ {
@ -47,7 +48,6 @@ namespace OpenSim.Region.Environment.LandManagement
public LandData landData = new LandData(); public LandData landData = new LandData();
public List<SceneObjectGroup> primsOverMe = new List<SceneObjectGroup>(); public List<SceneObjectGroup> primsOverMe = new List<SceneObjectGroup>();
public List<libsecondlife.ParcelManager.ParcelAccessEntry> parcelAccessList = new List<ParcelManager.ParcelAccessEntry>();
public Scene m_scene; public Scene m_scene;
private bool[,] landBitmap = new bool[64,64]; private bool[,] landBitmap = new bool[64,64];
@ -93,21 +93,12 @@ namespace OpenSim.Region.Environment.LandManagement
//Place all new variables here! //Place all new variables here!
newLand.landBitmap = (bool[,]) (landBitmap.Clone()); newLand.landBitmap = (bool[,]) (landBitmap.Clone());
newLand.parcelAccessList.Clear();
foreach (ParcelManager.ParcelAccessEntry entry in parcelAccessList)
{
ParcelManager.ParcelAccessEntry newEntry = new ParcelManager.ParcelAccessEntry();
newEntry.AgentID = entry.AgentID;
newEntry.Flags = entry.Flags;
newEntry.Time = entry.Time;
newLand.parcelAccessList.Add(newEntry);
}
newLand.landData = landData.Copy(); newLand.landData = landData.Copy();
return newLand; return newLand;
} }
#endregion #endregion
#region Packet Request Handling #region Packet Request Handling
@ -209,24 +200,30 @@ namespace OpenSim.Region.Environment.LandManagement
if (remote_client.AgentId == landData.ownerID) if (remote_client.AgentId == landData.ownerID)
{ {
//Needs later group support //Needs later group support
landData.authBuyerID = packet.ParcelData.AuthBuyerID; LandData newData = landData.Copy();
landData.category = (Parcel.ParcelCategory) packet.ParcelData.Category; newData.authBuyerID = packet.ParcelData.AuthBuyerID;
landData.landDesc = Helpers.FieldToUTF8String(packet.ParcelData.Desc); newData.category = (Parcel.ParcelCategory)packet.ParcelData.Category;
landData.groupID = packet.ParcelData.GroupID; newData.landDesc = Helpers.FieldToUTF8String(packet.ParcelData.Desc);
landData.landingType = packet.ParcelData.LandingType; newData.groupID = packet.ParcelData.GroupID;
landData.mediaAutoScale = packet.ParcelData.MediaAutoScale; newData.landingType = packet.ParcelData.LandingType;
landData.mediaID = packet.ParcelData.MediaID; newData.mediaAutoScale = packet.ParcelData.MediaAutoScale;
landData.mediaURL = Helpers.FieldToUTF8String(packet.ParcelData.MediaURL); newData.mediaID = packet.ParcelData.MediaID;
landData.musicURL = Helpers.FieldToUTF8String(packet.ParcelData.MusicURL); newData.mediaURL = Helpers.FieldToUTF8String(packet.ParcelData.MediaURL);
landData.landName = Helpers.FieldToUTF8String(packet.ParcelData.Name); newData.musicURL = Helpers.FieldToUTF8String(packet.ParcelData.MusicURL);
landData.landFlags = packet.ParcelData.ParcelFlags; newData.landName = Helpers.FieldToUTF8String(packet.ParcelData.Name);
landData.passHours = packet.ParcelData.PassHours; newData.landFlags = packet.ParcelData.ParcelFlags;
landData.passPrice = packet.ParcelData.PassPrice; newData.passHours = packet.ParcelData.PassHours;
landData.salePrice = packet.ParcelData.SalePrice; newData.passPrice = packet.ParcelData.PassPrice;
landData.snapshotID = packet.ParcelData.SnapshotID; newData.salePrice = packet.ParcelData.SalePrice;
landData.userLocation = packet.ParcelData.UserLocation; newData.snapshotID = packet.ParcelData.SnapshotID;
landData.userLookAt = packet.ParcelData.UserLookAt; newData.userLocation = packet.ParcelData.UserLocation;
newData.userLookAt = packet.ParcelData.UserLookAt;
m_scene.LandManager.updateLandObject(landData.localID, newData);
sendLandUpdateToAvatarsOverMe(); sendLandUpdateToAvatarsOverMe();
} }
} }
@ -257,7 +254,7 @@ namespace OpenSim.Region.Environment.LandManagement
public ParcelAccessListReplyPacket.ListBlock[] createAccessListArrayByFlag(ParcelManager.AccessList flag) public ParcelAccessListReplyPacket.ListBlock[] createAccessListArrayByFlag(ParcelManager.AccessList flag)
{ {
List<ParcelAccessListReplyPacket.ListBlock> list = new List<ParcelAccessListReplyPacket.ListBlock>(); List<ParcelAccessListReplyPacket.ListBlock> list = new List<ParcelAccessListReplyPacket.ListBlock>();
foreach (ParcelManager.ParcelAccessEntry entry in parcelAccessList) foreach (ParcelManager.ParcelAccessEntry entry in landData.parcelAccessList)
{ {
if (entry.Flags == flag) if (entry.Flags == flag)
{ {
@ -317,13 +314,15 @@ namespace OpenSim.Region.Environment.LandManagement
public void updateAccessList(uint flags, List<ParcelManager.ParcelAccessEntry> entries, IClientAPI remote_client) public void updateAccessList(uint flags, List<ParcelManager.ParcelAccessEntry> entries, IClientAPI remote_client)
{ {
LandData newData = landData.Copy();
if (entries.Count == 1 && entries[0].AgentID == LLUUID.Zero) if (entries.Count == 1 && entries[0].AgentID == LLUUID.Zero)
{ {
entries.Clear(); entries.Clear();
} }
List<ParcelManager.ParcelAccessEntry> toRemove = new List<ParcelManager.ParcelAccessEntry>(); List<ParcelManager.ParcelAccessEntry> toRemove = new List<ParcelManager.ParcelAccessEntry>();
foreach (ParcelManager.ParcelAccessEntry entry in parcelAccessList) foreach (ParcelManager.ParcelAccessEntry entry in newData.parcelAccessList)
{ {
if (entry.Flags == (ParcelManager.AccessList)flags) if (entry.Flags == (ParcelManager.AccessList)flags)
{ {
@ -333,7 +332,7 @@ namespace OpenSim.Region.Environment.LandManagement
foreach (ParcelManager.ParcelAccessEntry entry in toRemove) foreach (ParcelManager.ParcelAccessEntry entry in toRemove)
{ {
parcelAccessList.Remove(entry); newData.parcelAccessList.Remove(entry);
} }
foreach (ParcelManager.ParcelAccessEntry entry in entries) foreach (ParcelManager.ParcelAccessEntry entry in entries)
{ {
@ -342,11 +341,14 @@ namespace OpenSim.Region.Environment.LandManagement
temp.Time = new DateTime() ; //Pointless? Yes. temp.Time = new DateTime() ; //Pointless? Yes.
temp.Flags = (ParcelManager.AccessList)flags; temp.Flags = (ParcelManager.AccessList)flags;
if (!this.parcelAccessList.Contains(temp)) if (!newData.parcelAccessList.Contains(temp))
{ {
this.parcelAccessList.Add(temp); newData.parcelAccessList.Add(temp);
} }
} }
m_scene.LandManager.updateLandObject(landData.localID, newData);
} }
#endregion #endregion
@ -385,6 +387,7 @@ namespace OpenSim.Region.Environment.LandManagement
new LLVector3((float) (max_x*4), (float) (max_y*4), new LLVector3((float) (max_x*4), (float) (max_y*4),
(float) m_scene.Terrain.GetHeight((max_x*4), (max_y*4))); (float) m_scene.Terrain.GetHeight((max_x*4), (max_y*4)));
landData.area = tempArea; landData.area = tempArea;
} }
public void updateLandBitmapByteArray() public void updateLandBitmapByteArray()

View File

@ -31,6 +31,7 @@ using libsecondlife;
using libsecondlife.Packets; using libsecondlife.Packets;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Region.Environment.Scenes; using OpenSim.Region.Environment.Scenes;
using OpenSim.Region.Environment.Interfaces;
namespace OpenSim.Region.Environment.LandManagement namespace OpenSim.Region.Environment.LandManagement
{ {
@ -75,6 +76,34 @@ namespace OpenSim.Region.Environment.LandManagement
#endregion #endregion
#region Events and Triggers
public delegate void LandObjectAdded(Land newParcel, LLUUID regionUUID);
public delegate void LandObjectRemoved(uint localParcelID, LLUUID regionUUID);
public event LandObjectAdded OnLandObjectAdded;
public event LandObjectRemoved OnLandObjectRemoved;
public void triggerLandObjectAdded(Land newParcel)
{
if (OnLandObjectAdded != null)
{
OnLandObjectAdded(newParcel, m_scene.RegionInfo.RegionID);
}
}
public void triggerLandObjectRemoved(uint localParcelID)
{
if (OnLandObjectRemoved != null)
{
OnLandObjectRemoved(localParcelID, m_scene.RegionInfo.RegionID);
}
}
public void triggerLandObjectUpdated(uint localParcelID, Land newParcel)
{
triggerLandObjectRemoved(localParcelID);
triggerLandObjectAdded(newParcel);
}
#endregion
#region Member Variables #region Member Variables
public Dictionary<int, Land> landList = new Dictionary<int, Land>(); public Dictionary<int, Land> landList = new Dictionary<int, Land>();
@ -100,13 +129,23 @@ namespace OpenSim.Region.Environment.LandManagement
landIDList.Initialize(); landIDList.Initialize();
} }
#endregion #endregion
#region Member Functions #region Member Functions
#region Parcel From Storage Functions #region Land Object From Storage Functions
public void LandFromStorage(LandData data) public void IncomingLandObjectsFromStorage(List<LandData> data)
{
foreach (LandData parcel in data)
{
IncomingLandObjectFromStorage(parcel);
}
}
public void IncomingLandObjectFromStorage(LandData data)
{ {
Land new_land = new Land(data.ownerID, data.isGroupOwned, m_scene); Land new_land = new Land(data.ownerID, data.isGroupOwned, m_scene);
new_land.landData = data.Copy(); new_land.landData = data.Copy();
@ -116,6 +155,7 @@ namespace OpenSim.Region.Environment.LandManagement
public void NoLandDataFromStorage() public void NoLandDataFromStorage()
{ {
Console.WriteLine("No LandData in storage! Loading a single, flat parcel instead");
resetSimLandObjects(); resetSimLandObjects();
} }
@ -156,7 +196,7 @@ namespace OpenSim.Region.Environment.LandManagement
} }
} }
landList[lastLandLocalID].forceUpdateLandInfo(); landList[lastLandLocalID].forceUpdateLandInfo();
triggerLandObjectAdded(new_land);
return new_land; return new_land;
} }
@ -177,8 +217,21 @@ namespace OpenSim.Region.Environment.LandManagement
} }
} }
} }
// TODO: Put event here for storage manager to bind to.
landList.Remove(local_id); landList.Remove(local_id);
triggerLandObjectRemoved((uint)local_id);
}
public void updateLandObject(int local_id, LandData newData)
{
if (landList.ContainsKey(local_id))
{
landList[local_id].landData = newData.Copy();
triggerLandObjectUpdated((uint)local_id, landList[local_id]);
}
else
{
throw new Exception("Could not update land object. Local ID '" + local_id + "' does not exist");
}
} }
private void performFinalLandJoin(Land master, Land slave) private void performFinalLandJoin(Land master, Land slave)
@ -195,6 +248,7 @@ namespace OpenSim.Region.Environment.LandManagement
} }
} }
} }
removeLandObject(slave.landData.localID); removeLandObject(slave.landData.localID);
} }
@ -293,7 +347,6 @@ namespace OpenSim.Region.Environment.LandManagement
Land.modifyLandBitmapSquare(startLandObject.getLandBitmap(), start_x, start_y, end_x, end_y, false)); Land.modifyLandBitmapSquare(startLandObject.getLandBitmap(), start_x, start_y, end_x, end_y, false));
landList[startLandObjectIndex].forceUpdateLandInfo(); landList[startLandObjectIndex].forceUpdateLandInfo();
setPrimsTainted(); setPrimsTainted();
//Now add the new land object //Now add the new land object

View File

@ -225,10 +225,16 @@ namespace OpenSim.Region.Environment.Scenes
m_physicalPrim = physicalPrim; m_physicalPrim = physicalPrim;
m_sendTasksToChild = SendTasksToChild; m_sendTasksToChild = SendTasksToChild;
m_LandManager = new LandManager(this, m_regInfo);
m_estateManager = new EstateManager(this, m_regInfo);
m_eventManager = new EventManager(); m_eventManager = new EventManager();
m_LandManager = new LandManager(this, m_regInfo);
//Bind Storage Manager functions to some land manager functions for this scene
m_LandManager.OnLandObjectAdded += new LandManager.LandObjectAdded(m_storageManager.DataStore.StoreLandObject);
m_LandManager.OnLandObjectRemoved += new LandManager.LandObjectRemoved(m_storageManager.DataStore.RemoveLandObject);
m_estateManager = new EstateManager(this, m_regInfo);
m_permissionManager = permissionManager; m_permissionManager = permissionManager;
m_permissionManager.Initialise(this); m_permissionManager.Initialise(this);
@ -833,6 +839,24 @@ namespace OpenSim.Region.Environment.Scenes
#endregion #endregion
#region Load Land
public void loadAllLandObjectsFromStorage()
{
MainLog.Instance.Verbose("SCENE", "Loading land objects from storage");
List<Framework.LandData> landData = m_storageManager.DataStore.LoadLandObjects(RegionInfo.RegionID);
if (landData.Count == 0)
{
m_LandManager.NoLandDataFromStorage();
}
else
{
m_LandManager.IncomingLandObjectsFromStorage(landData);
}
}
#endregion
#region Primitives Methods #region Primitives Methods
/// <summary> /// <summary>

View File

@ -292,19 +292,19 @@ namespace OpenSim.DataStore.MSSQL
return terret; return terret;
} }
public void RemoveLandObject(uint id) public void RemoveLandObject(uint id, LLUUID regionUUID)
{ {
} }
public void StoreParcel(Land parcel) public void StoreLandObject(Land parcel, LLUUID regionUUID)
{ {
} }
public List<Land> LoadLandObjects() public List<Framework.LandData> LoadLandObjects(LLUUID regionUUID)
{ {
return new List<Land>(); return new List<LandData>();
} }
public void Commit() public void Commit()

View File

@ -346,17 +346,17 @@ namespace OpenSim.DataStore.MonoSqlite
} }
} }
public void RemoveLandObject(uint id) public void RemoveLandObject(uint id, LLUUID regionUUID)
{ {
} }
public void StoreParcel(Land parcel) public void StoreLandObject(Land parcel, LLUUID regionUUID)
{ {
} }
public List<Land> LoadLandObjects() public List<Framework.LandData> LoadLandObjects(LLUUID regionUUID)
{ {
return new List<Land>(); return new List<LandData>();
} }
public void Commit() public void Commit()

View File

@ -63,17 +63,17 @@ namespace OpenSim.DataStore.NullStorage
return null; return null;
} }
public void RemoveLandObject(uint id) public void RemoveLandObject(uint id, LLUUID regionUUID)
{ {
} }
public void StoreParcel(Land land) public void StoreLandObject(Land land, LLUUID regionUUID)
{ {
} }
public List<Land> LoadLandObjects() public List<Framework.LandData> LoadLandObjects(LLUUID regionUUID)
{ {
return new List<Land>(); return new List<Framework.LandData>();
} }
public void Shutdown() public void Shutdown()