Client should draw blocks at map boundaries.

This commit is contained in:
UnknownShadow200 2015-09-19 20:35:04 +10:00
parent c756094023
commit 60b87b7a6f
2 changed files with 18 additions and 14 deletions

View File

@ -22,7 +22,7 @@ namespace ClassicalSharp {
game.TerrainAtlasChanged += TerrainAtlasChanged; game.TerrainAtlasChanged += TerrainAtlasChanged;
} }
int width, length, height; internal int width, length, height, edgeLevel;
int maxX, maxY, maxZ; int maxX, maxY, maxZ;
byte[] counts = new byte[chunkSize3 * TileSide.Sides]; byte[] counts = new byte[chunkSize3 * TileSide.Sides];
byte[] chunk = new byte[extChunkSize3]; byte[] chunk = new byte[extChunkSize3];
@ -92,6 +92,8 @@ namespace ClassicalSharp {
} }
} }
if( x1 == 0 || y1 == 0 || z1 == 0 || x1 + chunkSize >= width ||
y1 + chunkSize >= height || z1 + chunkSize >= length ) allSolid = false;
if( !( allAir || allSolid ) ) { if( !( allAir || allSolid ) ) {
map.HeightmapHint( x1 - 1, z1 - 1, mapPtr ); map.HeightmapHint( x1 - 1, z1 - 1, mapPtr );
} }
@ -191,10 +193,9 @@ namespace ClassicalSharp {
void TestAndStretchX( int xx, int index, byte tile, int chunkIndex, int value, int test, int tileSide, int offset ) { void TestAndStretchX( int xx, int index, byte tile, int chunkIndex, int value, int test, int tileSide, int offset ) {
index += tileSide; index += tileSide;
if( value == test ) { if( counts[index] != 0 ) {
counts[index] = 0; if( (value == test && Y < edgeLevel) ||
} else if( counts[index] != 0 ) { (value != test && info.IsFaceHidden( tile, chunk[chunkIndex + offset], tileSide )) ) {
if( info.IsFaceHidden( tile, chunk[chunkIndex + offset], tileSide ) ) {
counts[index] = 0; counts[index] = 0;
} else { } else {
int count = StretchX( xx, index, X, Y, Z, chunkIndex, tile, tileSide ); int count = StretchX( xx, index, X, Y, Z, chunkIndex, tile, tileSide );
@ -206,10 +207,9 @@ namespace ClassicalSharp {
void TestAndStretchZ( int zz, int index, byte tile, int chunkIndex, int value, int test, int tileSide, int offset ) { void TestAndStretchZ( int zz, int index, byte tile, int chunkIndex, int value, int test, int tileSide, int offset ) {
index += tileSide; index += tileSide;
if( value == test ) { if( counts[index] != 0 ) {
counts[index] = 0; if( (value == test && Y < edgeLevel) ||
} else if( counts[index] != 0 ) { (value != test && info.IsFaceHidden( tile, chunk[chunkIndex + offset], tileSide )) ) {
if( info.IsFaceHidden( tile, chunk[chunkIndex + offset], tileSide ) ) {
counts[index] = 0; counts[index] = 0;
} else { } else {
int count = StretchZ( zz, index, X, Y, Z, chunkIndex, tile, tileSide ); int count = StretchZ( zz, index, X, Y, Z, chunkIndex, tile, tileSide );
@ -282,6 +282,7 @@ namespace ClassicalSharp {
width = map.Width; width = map.Width;
height = map.Height; height = map.Height;
length = map.Length; length = map.Length;
edgeLevel = map.GroundHeight;
maxX = width - 1; maxX = width - 1;
maxY = height - 1; maxY = height - 1;
maxZ = length - 1; maxZ = length - 1;

View File

@ -69,6 +69,9 @@ namespace ClassicalSharp {
void EnvVariableChanged( object sender, EnvVariableEventArgs e ) { void EnvVariableChanged( object sender, EnvVariableEventArgs e ) {
if( e.Var == EnvVariable.SunlightColour || e.Var == EnvVariable.ShadowlightColour ) { if( e.Var == EnvVariable.SunlightColour || e.Var == EnvVariable.ShadowlightColour ) {
Refresh(); Refresh();
} else if( e.Var == EnvVariable.WaterLevel ) {
builder.edgeLevel = game.Map.WaterHeight;
Refresh();
} }
} }