Spin off terrain save into a new thread and make it so that it uses the old
values for places where NaN are found.avinationmerge
parent
6d1d1c0dbf
commit
df65245671
|
@ -561,6 +561,10 @@ namespace OpenSim.Data.MySQL
|
||||||
|
|
||||||
public virtual void StoreTerrain(double[,] ter, UUID regionID)
|
public virtual void StoreTerrain(double[,] ter, UUID regionID)
|
||||||
{
|
{
|
||||||
|
Util.FireAndForget(delegate(object x)
|
||||||
|
{
|
||||||
|
double[,] oldTerrain = LoadTerrain(regionID);
|
||||||
|
|
||||||
m_log.Info("[REGION DB]: Storing terrain");
|
m_log.Info("[REGION DB]: Storing terrain");
|
||||||
|
|
||||||
lock (m_dbLock)
|
lock (m_dbLock)
|
||||||
|
@ -583,23 +587,20 @@ namespace OpenSim.Data.MySQL
|
||||||
"1, ?Heightfield)";
|
"1, ?Heightfield)";
|
||||||
|
|
||||||
cmd2.Parameters.AddWithValue("RegionUUID", regionID.ToString());
|
cmd2.Parameters.AddWithValue("RegionUUID", regionID.ToString());
|
||||||
cmd2.Parameters.AddWithValue("Heightfield", SerializeTerrain(ter));
|
cmd2.Parameters.AddWithValue("Heightfield", SerializeTerrain(ter, oldTerrain));
|
||||||
|
|
||||||
ExecuteNonQuery(cmd);
|
ExecuteNonQuery(cmd);
|
||||||
ExecuteNonQuery(cmd2);
|
ExecuteNonQuery(cmd2);
|
||||||
}
|
}
|
||||||
catch
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
// If we get here there is a NaN in the terrain
|
m_log.ErrorFormat(e.ToString());
|
||||||
// and the terrain can't be saved. A crash here
|
|
||||||
// is much better than losing all the work
|
|
||||||
m_log.ErrorFormat("[DATA]: Unable to save terrain. Stopping simulator to prevent data loss");
|
|
||||||
Environment.Exit(1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual double[,] LoadTerrain(UUID regionID)
|
public virtual double[,] LoadTerrain(UUID regionID)
|
||||||
|
@ -1411,7 +1412,7 @@ namespace OpenSim.Data.MySQL
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="val"></param>
|
/// <param name="val"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
private static Array SerializeTerrain(double[,] val)
|
private static Array SerializeTerrain(double[,] val, double[,] oldTerrain)
|
||||||
{
|
{
|
||||||
MemoryStream str = new MemoryStream(((int)Constants.RegionSize * (int)Constants.RegionSize) *sizeof (double));
|
MemoryStream str = new MemoryStream(((int)Constants.RegionSize * (int)Constants.RegionSize) *sizeof (double));
|
||||||
BinaryWriter bw = new BinaryWriter(str);
|
BinaryWriter bw = new BinaryWriter(str);
|
||||||
|
@ -1420,7 +1421,11 @@ namespace OpenSim.Data.MySQL
|
||||||
for (int x = 0; x < (int)Constants.RegionSize; x++)
|
for (int x = 0; x < (int)Constants.RegionSize; x++)
|
||||||
for (int y = 0; y < (int)Constants.RegionSize; y++)
|
for (int y = 0; y < (int)Constants.RegionSize; y++)
|
||||||
{
|
{
|
||||||
double height = val[x, y];
|
double height = 20.0;
|
||||||
|
if (oldTerrain != null)
|
||||||
|
height = oldTerrain[x, y];
|
||||||
|
if (!double.IsNaN(val[x, y]))
|
||||||
|
height = val[x, y];
|
||||||
if (height == 0.0)
|
if (height == 0.0)
|
||||||
height = double.Epsilon;
|
height = double.Epsilon;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue