mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-14 10:05:44 -04:00
Don't crash when receiving 0 for block permissions.
This commit is contained in:
parent
e89dfb9f56
commit
2d7a74bd4a
@ -122,7 +122,7 @@ namespace ClassicalSharp {
|
|||||||
|
|
||||||
void RecreateBlockTextures() {
|
void RecreateBlockTextures() {
|
||||||
int blocksCount = 0;
|
int blocksCount = 0;
|
||||||
for( int i = 0; i < Window.CanPlace.Length; i++ ) {
|
for( int i = 0; i < BlockInfo.BlocksCount; i++ ) {
|
||||||
if( Window.CanPlace[i] || Window.CanDelete[i] ) {
|
if( Window.CanPlace[i] || Window.CanDelete[i] ) {
|
||||||
blocksCount++;
|
blocksCount++;
|
||||||
}
|
}
|
||||||
@ -135,7 +135,7 @@ namespace ClassicalSharp {
|
|||||||
blocksTable = new BlockDrawInfo[blocksCount];
|
blocksTable = new BlockDrawInfo[blocksCount];
|
||||||
|
|
||||||
int tableIndex = 0;
|
int tableIndex = 0;
|
||||||
for( int i = 0; i < Window.CanPlace.Length; i++ ) {
|
for( int i = 0; i < BlockInfo.BlocksCount; i++ ) {
|
||||||
if( Window.CanPlace[i] || Window.CanDelete[i] ) {
|
if( Window.CanPlace[i] || Window.CanDelete[i] ) {
|
||||||
Block block = (Block)i;
|
Block block = (Block)i;
|
||||||
int texId = Window.BlockInfo.GetOptimTextureLoc( (byte)block, TileSide.Left );
|
int texId = Window.BlockInfo.GetOptimTextureLoc( (byte)block, TileSide.Left );
|
||||||
|
@ -4,11 +4,11 @@ namespace ClassicalSharp {
|
|||||||
|
|
||||||
public partial class BlockInfo {
|
public partial class BlockInfo {
|
||||||
|
|
||||||
bool[] hidden = new bool[blocksCount * blocksCount * 6];
|
bool[] hidden = new bool[BlocksCount * BlocksCount * 6];
|
||||||
|
|
||||||
void SetupCullingCache() {
|
void SetupCullingCache() {
|
||||||
for( byte tile = 1; tile < blocksCount; tile++ ) {
|
for( byte tile = 1; tile < BlocksCount; tile++ ) {
|
||||||
for( byte neighbour = 1; neighbour < blocksCount; neighbour++ ) {
|
for( byte neighbour = 1; neighbour < BlocksCount; neighbour++ ) {
|
||||||
bool hidden = IsHidden( tile, neighbour );
|
bool hidden = IsHidden( tile, neighbour );
|
||||||
if( hidden ) {
|
if( hidden ) {
|
||||||
SetHidden( tile, neighbour, TileSide.Left, true );
|
SetHidden( tile, neighbour, TileSide.Left, true );
|
||||||
@ -29,11 +29,11 @@ namespace ClassicalSharp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SetHidden( byte tile, byte block, int tileSide, bool value ) {
|
void SetHidden( byte tile, byte block, int tileSide, bool value ) {
|
||||||
hidden[( tile * blocksCount + block ) * 6 + tileSide] = value;
|
hidden[( tile * BlocksCount + block ) * 6 + tileSide] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsFaceHidden( byte tile, byte block, int tileSide ) {
|
public bool IsFaceHidden( byte tile, byte block, int tileSide ) {
|
||||||
return hidden[( tile * blocksCount + block ) * 6 + tileSide];
|
return hidden[( tile * BlocksCount + block ) * 6 + tileSide];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -7,7 +7,7 @@ namespace ClassicalSharp {
|
|||||||
// The designation used is as follows:
|
// The designation used is as follows:
|
||||||
// 0 - left 1 - right 2 - front
|
// 0 - left 1 - right 2 - front
|
||||||
// 3 - back 4 - bottom 5 - top
|
// 3 - back 4 - bottom 5 - top
|
||||||
int[] optimTextures = new int[blocksCount * 6];
|
int[] optimTextures = new int[BlocksCount * 6];
|
||||||
const int Row1 = 0, Row2 = 16, Row3 = 32, Row4 = 48,
|
const int Row1 = 0, Row2 = 16, Row3 = 32, Row4 = 48,
|
||||||
Row5 = 64, Row6 = 80, Row7 = 96, Row8 = 112, Row9 = 128;
|
Row5 = 64, Row6 = 80, Row7 = 96, Row8 = 112, Row9 = 128;
|
||||||
|
|
||||||
|
@ -4,17 +4,18 @@ namespace ClassicalSharp {
|
|||||||
|
|
||||||
public partial class BlockInfo {
|
public partial class BlockInfo {
|
||||||
|
|
||||||
bool[] isTransparent = new bool[blocksCount];
|
bool[] isTransparent = new bool[BlocksCount];
|
||||||
bool[] isTranslucent = new bool[blocksCount];
|
bool[] isTranslucent = new bool[BlocksCount];
|
||||||
bool[] isOpaque = new bool[blocksCount];
|
bool[] isOpaque = new bool[BlocksCount];
|
||||||
bool[] isSprite = new bool[blocksCount];
|
bool[] isSprite = new bool[BlocksCount];
|
||||||
bool[] isLiquid = new bool[blocksCount];
|
bool[] isLiquid = new bool[BlocksCount];
|
||||||
float[] heights = new float[blocksCount];
|
float[] heights = new float[BlocksCount];
|
||||||
bool[] blocksLight = new bool[blocksCount];
|
bool[] blocksLight = new bool[BlocksCount];
|
||||||
const byte blocksCount = (byte)Block.StoneBrick + 1;
|
public const byte MaxDefinedBlock = (byte)Block.StoneBrick;
|
||||||
|
public const byte BlocksCount = MaxDefinedBlock + 1;
|
||||||
|
|
||||||
public void Init() {
|
public void Init() {
|
||||||
for( int tile = 1; tile < blocksCount; tile++ ) {
|
for( int tile = 1; tile < BlocksCount; tile++ ) {
|
||||||
heights[tile] = 1f;
|
heights[tile] = 1f;
|
||||||
blocksLight[tile] = true;
|
blocksLight[tile] = true;
|
||||||
isOpaque[tile] = true;
|
isOpaque[tile] = true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user