Fixed the problem of prims not being loaded from the database (that my last commit created).

afrisby
MW 2007-08-29 16:35:22 +00:00
parent 36fba5e7e2
commit 334dce42e7
2 changed files with 113 additions and 77 deletions

View File

@ -363,7 +363,10 @@ namespace OpenSim.Region.Environment.Scenes
/// </summary>
public void ScheduleFullUpdate()
{
m_parentGroup.HasChanged = true;
if (m_parentGroup != null)
{
m_parentGroup.HasChanged = true;
}
m_updateFlag = 2;
}
@ -374,7 +377,10 @@ namespace OpenSim.Region.Environment.Scenes
{
if (m_updateFlag < 1)
{
m_parentGroup.HasChanged = true;
if (m_parentGroup != null)
{
m_parentGroup.HasChanged = true;
}
m_updateFlag = 1;
}
}

View File

@ -128,14 +128,15 @@ namespace OpenSim.DataStore.MonoSqliteStorage
DataTable prims = ds.Tables["prims"];
DataTable shapes = ds.Tables["primshapes"];
string byRegion = "RegionUUID = '" + regionUUID.ToString() + "'";
string byRegion = "RegionUUID = '" + regionUUID.ToString() + "'";
string orderByParent = "ParentID ASC";
DataRow[] primsForRegion = prims.Select(byRegion, orderByParent);
MainLog.Instance.Verbose("DATASTORE", "Loaded " + primsForRegion.Length + " prims for region: " + regionUUID);
foreach (DataRow primRow in primsForRegion)
{
try {
try
{
string uuid = (string)primRow["UUID"];
string objID = (string)primRow["SceneGroupID"];
if (uuid == objID) //is new SceneObjectGroup ?
@ -173,14 +174,17 @@ namespace OpenSim.DataStore.MonoSqliteStorage
}
createdObjects[new LLUUID(objID)].AddPart(prim);
}
} catch(Exception) {
foreach (DataColumn col in prims.Columns) {
}
catch (Exception)
{
foreach (DataColumn col in prims.Columns)
{
MainLog.Instance.Verbose("Col: " + col.ColumnName + " => " + primRow[col]);
}
}
}
MainLog.Instance.Verbose("DATASTORE", "Sqlite - LoadObjects found " + prims.Rows.Count + " primitives");
MainLog.Instance.Verbose("DATASTORE", "Sqlite - Number of sceneObjects" + retvals.Count);
return retvals;
}
@ -214,42 +218,42 @@ namespace OpenSim.DataStore.MonoSqliteStorage
// TODO: DataSet commit
}
// public class TextureBlock
// {
// public byte[] TextureData;
// public byte[] ExtraParams = new byte[1];
// public class TextureBlock
// {
// public byte[] TextureData;
// public byte[] ExtraParams = new byte[1];
// public TextureBlock(byte[] data)
// {
// TextureData = data;
// }
// public TextureBlock(byte[] data)
// {
// TextureData = data;
// }
// public TextureBlock()
// {
// public TextureBlock()
// {
// }
// }
// public string ToXMLString()
// {
// StringWriter sw = new StringWriter();
// XmlTextWriter writer = new XmlTextWriter(sw);
// XmlSerializer serializer = new XmlSerializer(typeof(TextureBlock));
// serializer.Serialize(writer, this);
// return sw.ToString();
// }
// public string ToXMLString()
// {
// StringWriter sw = new StringWriter();
// XmlTextWriter writer = new XmlTextWriter(sw);
// XmlSerializer serializer = new XmlSerializer(typeof(TextureBlock));
// serializer.Serialize(writer, this);
// return sw.ToString();
// }
// public static TextureBlock FromXmlString(string xmlData)
// {
// TextureBlock textureEntry = null;
// StringReader sr = new StringReader(xmlData);
// XmlTextReader reader = new XmlTextReader(sr);
// XmlSerializer serializer = new XmlSerializer(typeof(TextureBlock));
// textureEntry = (TextureBlock)serializer.Deserialize(reader);
// reader.Close();
// sr.Close();
// return textureEntry;
// }
// }
// public static TextureBlock FromXmlString(string xmlData)
// {
// TextureBlock textureEntry = null;
// StringReader sr = new StringReader(xmlData);
// XmlTextReader reader = new XmlTextReader(sr);
// XmlSerializer serializer = new XmlSerializer(typeof(TextureBlock));
// textureEntry = (TextureBlock)serializer.Deserialize(reader);
// reader.Close();
// sr.Close();
// return textureEntry;
// }
// }
/***********************************************************************
*
@ -633,7 +637,8 @@ namespace OpenSim.DataStore.MonoSqliteStorage
* generate these strings instead of typing them out.
*/
string[] cols = new string[dt.Columns.Count];
for (int i = 0; i < dt.Columns.Count; i++) {
for (int i = 0; i < dt.Columns.Count; i++)
{
DataColumn col = dt.Columns[i];
cols[i] = col.ColumnName;
}
@ -693,7 +698,7 @@ namespace OpenSim.DataStore.MonoSqliteStorage
subsql += ",\n";
}
subsql += col.ColumnName + " " + sqliteType(col.DataType);
if(col == dt.PrimaryKey[0])
if (col == dt.PrimaryKey[0])
{
subsql += " primary key";
}
@ -782,10 +787,13 @@ namespace OpenSim.DataStore.MonoSqliteStorage
SqliteDataAdapter sDa = new SqliteDataAdapter(shapeSelectCmd);
DataSet tmpDS = new DataSet();
try {
try
{
pDa.Fill(tmpDS, "prims");
sDa.Fill(tmpDS, "primshapes");
} catch (Mono.Data.SqliteClient.SqliteSyntaxException) {
}
catch (Mono.Data.SqliteClient.SqliteSyntaxException)
{
MainLog.Instance.Verbose("DATASTORE", "SQLite Database doesn't exist... creating");
InitDB(conn);
}
@ -793,14 +801,18 @@ namespace OpenSim.DataStore.MonoSqliteStorage
pDa.Fill(tmpDS, "prims");
sDa.Fill(tmpDS, "primshapes");
foreach (DataColumn col in createPrimTable().Columns) {
if (! tmpDS.Tables["prims"].Columns.Contains(col.ColumnName) ) {
foreach (DataColumn col in createPrimTable().Columns)
{
if (!tmpDS.Tables["prims"].Columns.Contains(col.ColumnName))
{
MainLog.Instance.Verbose("DATASTORE", "Missing required column:" + col.ColumnName);
return false;
}
}
foreach (DataColumn col in createShapeTable().Columns) {
if (! tmpDS.Tables["primshapes"].Columns.Contains(col.ColumnName) ) {
foreach (DataColumn col in createShapeTable().Columns)
{
if (!tmpDS.Tables["primshapes"].Columns.Contains(col.ColumnName))
{
MainLog.Instance.Verbose("DATASTORE", "Missing required column:" + col.ColumnName);
return false;
}
@ -816,15 +828,24 @@ namespace OpenSim.DataStore.MonoSqliteStorage
private DbType dbtypeFromType(Type type)
{
if (type == typeof(System.String)) {
if (type == typeof(System.String))
{
return DbType.String;
} else if (type == typeof(System.Int32)) {
}
else if (type == typeof(System.Int32))
{
return DbType.Int32;
} else if (type == typeof(System.Double)) {
}
else if (type == typeof(System.Double))
{
return DbType.Double;
} else if (type == typeof(System.Byte[])) {
}
else if (type == typeof(System.Byte[]))
{
return DbType.Binary;
} else {
}
else
{
return DbType.String;
}
}
@ -833,15 +854,24 @@ namespace OpenSim.DataStore.MonoSqliteStorage
// slightly differently.
private string sqliteType(Type type)
{
if (type == typeof(System.String)) {
if (type == typeof(System.String))
{
return "varchar(255)";
} else if (type == typeof(System.Int32)) {
}
else if (type == typeof(System.Int32))
{
return "integer";
} else if (type == typeof(System.Double)) {
}
else if (type == typeof(System.Double))
{
return "float";
} else if (type == typeof(System.Byte[])) {
}
else if (type == typeof(System.Byte[]))
{
return "blob";
} else {
}
else
{
return "string";
}
}