some cosmetics, like npcs down eat terrain

This commit is contained in:
UbitUmarov
2022-03-30 01:15:31 +01:00
parent 3f30f17187
commit 667a18161b
5 changed files with 62 additions and 60 deletions

View File

@@ -595,15 +595,26 @@ namespace OpenSim.Framework
CompressionFactor = hmCompressionFactor;
// In case database info doesn't match real terrain size, initialize the whole terrain.
ClearLand();
bool needClear = false;
if (hmSizeX > SizeX)
hmSizeX = SizeX;
else if (hmSizeX < SizeX)
needClear = true;
if (hmSizeY > SizeY)
hmSizeY = SizeY;
else if (hmSizeY < SizeY)
needClear = true;
if (needClear)
ClearLand();
for (int yy = 0; yy < hmSizeY; yy++)
{
for (int xx = 0; xx < hmSizeX; xx++)
{
float val = FromCompressedHeight(br.ReadInt16());
if (xx < SizeX && yy < SizeY)
m_heightmap[xx, yy] = val;
m_heightmap[xx, yy] = val;
}
}
}
@@ -631,16 +642,26 @@ namespace OpenSim.Framework
hmSizeX = br.ReadInt32();
hmSizeY = br.ReadInt32();
// In case database info doesn't match real terrain size, initialize the whole terrain.
ClearLand();
bool needClear = false;
if (hmSizeX > SizeX)
hmSizeX = SizeX;
else if (hmSizeX < SizeX)
needClear = true;
if (hmSizeY > SizeY)
hmSizeY = SizeY;
else if (hmSizeY < SizeY)
needClear = true;
if (needClear)
ClearLand();
for (int yy = 0; yy < hmSizeY; yy++)
{
for (int xx = 0; xx < hmSizeX; xx++)
{
float val = br.ReadSingle();
if (xx < SizeX && yy < SizeY)
m_heightmap[xx, yy] = val;
m_heightmap[xx, yy] = val;
}
}
}
@@ -665,8 +686,7 @@ namespace OpenSim.Framework
{
m_log.InfoFormat("{0} VD2Gzip {1} bytes input",
LogHeader, pBlob.Length);
Int32 hmSizeX, hmSizeY;
int hmSizeX, hmSizeY;
try
{
@@ -688,16 +708,26 @@ namespace OpenSim.Framework
hmSizeX = br.ReadInt32();
hmSizeY = br.ReadInt32();
// In case database info doesn't match real terrain size, initialize the whole terrain.
ClearLand();
bool needClear = false;
if(hmSizeX > SizeX)
hmSizeX = SizeX;
else if (hmSizeX < SizeX)
needClear = true;
if (hmSizeY > SizeY)
hmSizeY = SizeY;
else if (hmSizeY < SizeY)
needClear = true;
if (needClear)
ClearLand();
for (int yy = 0; yy < hmSizeY; yy++)
{
for (int xx = 0; xx < hmSizeX; xx++)
{
float val = br.ReadSingle();
if (xx < SizeX && yy < SizeY)
m_heightmap[xx, yy] = val;
m_heightmap[xx, yy] = val;
}
}
}

View File

@@ -152,41 +152,19 @@ namespace OpenSim.Region.CoreModules.World.Terrain
protected string parseFloat(String s, out float f)
{
string result;
float d;
if (float.TryParse(s, out d))
{
try
{
f = (float)d;
result = String.Empty;
}
catch(InvalidCastException)
{
result = String.Format("{0} is invalid", s);
f = -1.0f;
}
}
else
{
f = -1.0f;
result = String.Format("{0} is invalid", s);
}
return result;
if (float.TryParse(s, out f))
return string.Empty;
f = -1.0f;
return string.Format("{0} is invalid", s);
}
protected string parseInt(String s, out int i)
{
string result;
if (Int32.TryParse(s, out i))
{
result = String.Empty;
}
else
{
result = String.Format("{0} is invalid", s);
}
return result;
return string.Empty;
return string.Format("{0} is invalid", s);
}
protected void applyModification(ITerrainChannel map, TerrainModifierData data)

View File

@@ -1091,6 +1091,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain
{
m_scene.ForEachScenePresence(presence =>
{
if(presence.IsNPC)
return;
if (!m_perClientPatchUpdates.TryGetValue(presence.UUID, out PatchUpdates thisClientUpdates))
{
// There is a ScenePresence without a send patch map. Create one. should not happen

View File

@@ -153,10 +153,9 @@ namespace OpenSim.Region.Framework.Scenes
}
set
{
if (Double.IsNaN(value) || Double.IsInfinity(value))
if (float.IsNaN(value) || float.IsInfinity(value))
return;
m_terrainData[x, y] = (float)value;
m_terrainData[x, y] = value;
}
}

View File

@@ -137,8 +137,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
float sub = 0.5f * header.Range + header.DCOffset;
int wordsize = (prequant - 2) & 0x0f;
header.QuantWBits = wordsize;
header.QuantWBits |= wordsize << 4;
header.QuantWBits = wordsize | (wordsize << 4);
int k = 0;
for (int j = 0; j < 256 ; j += 16)
@@ -293,21 +292,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP
int prequant, out int wbits, int* iout)
{
float* block = stackalloc float[256];
float oozrange = 1.0f / header.Range;
float invprequat = (1 << prequant);
float premult = oozrange * invprequat;
float sub = 0.5f * header.Range + header.DCOffset;
int wordsize = (prequant - 2) & 0x0f;
header.QuantWBits = wordsize;
header.QuantWBits |= wordsize << 4;
float sub = header.Range;
float premult = (1 << prequant) / sub;
sub = 0.5f * sub + header.DCOffset;
terrData.GetPatchBlock(block, patchX, patchY, sub, premult);
wbits = (prequant >> 1);
int wordsize = (prequant - 2) & 0x0f;
header.QuantWBits = wordsize | (wordsize << 4);
wbits = (prequant >> 1);
dct16x16(block, iout, ref wbits);
}