mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-17 19:45:23 -04:00
Forgot missing offsetType <= 7 in last commit
This commit is contained in:
parent
dc3d176b1b
commit
3cdcad8974
@ -130,7 +130,7 @@ namespace ClassicalSharp {
|
||||
float v1 = vOrigin, v2 = vOrigin + invVerElementSize * 15.99f/16f;
|
||||
|
||||
byte offsetType = BlockInfo.SpriteOffset[curBlock];
|
||||
if (offsetType >= 6) {
|
||||
if (offsetType >= 6 && offsetType <= 7) {
|
||||
spriteRng.SetSeed((X + 1217 * Y + 4751 * Z) & 0x7fffffff);
|
||||
float valX = spriteRng.Next(-3, 3 + 1) / 16.0f;
|
||||
float valY = spriteRng.Next(0, 3 + 1) / 16.0f;
|
||||
|
@ -59,22 +59,22 @@ void Block_SetCollide(BlockID block, UInt8 collide) {
|
||||
Block_ExtendedCollide[block] = collide;
|
||||
|
||||
/* Reduce extended collision types to their simpler forms. */
|
||||
if (collide == CollideType_Ice) collide = CollideType_Solid;
|
||||
if (collide == CollideType_SlipperyIce) collide = CollideType_Solid;
|
||||
if (collide == COLLIDE_ICE) collide = COLLIDE_SOLID;
|
||||
if (collide == COLLIDE_SLIPPERY_ICE) collide = COLLIDE_SOLID;
|
||||
|
||||
if (collide == CollideType_LiquidWater) collide = CollideType_Liquid;
|
||||
if (collide == CollideType_LiquidLava) collide = CollideType_Liquid;
|
||||
if (collide == COLLIDE_LIQUID_WATER) collide = COLLIDE_LIQUID;
|
||||
if (collide == COLLIDE_LIQUID_LAVA) collide = COLLIDE_LIQUID;
|
||||
Block_Collide[block] = collide;
|
||||
}
|
||||
|
||||
void Block_SetDrawType(BlockID block, UInt8 draw) {
|
||||
if (draw == DrawType_Opaque && Block_Collide[block] != CollideType_Solid) {
|
||||
draw = DrawType_Transparent;
|
||||
if (draw == DRAW_OPAQUE && Block_Collide[block] != COLLIDE_SOLID) {
|
||||
draw = DRAW_TRANSPARENT;
|
||||
}
|
||||
Block_Draw[block] = draw;
|
||||
|
||||
Vector3 zero = Vector3_Zero, one = Vector3_One;
|
||||
Block_FullOpaque[block] = draw == DrawType_Opaque
|
||||
Block_FullOpaque[block] = draw == DRAW_OPAQUE
|
||||
&& Vector3_Equals(&Block_MinBB[block], &zero)
|
||||
&& Vector3_Equals(&Block_MaxBB[block], &one);
|
||||
}
|
||||
@ -133,7 +133,7 @@ void Block_ResetProps(BlockID block) {
|
||||
Block_SpriteOffset[block] = 0;
|
||||
|
||||
Block_Draw[block] = DefaultSet_Draw(block);
|
||||
if (Block_Draw[block] == DrawType_Sprite) {
|
||||
if (Block_Draw[block] == DRAW_SPRITE) {
|
||||
Block_MinBB[block] = Vector3_Create3(2.50f / 16.0f, 0.0f, 2.50f / 16.0f);
|
||||
Block_MaxBB[block] = Vector3_Create3(13.5f / 16.0f, 1.0f, 13.5f / 16.0f);
|
||||
} else {
|
||||
@ -173,10 +173,10 @@ Int32 Block_FindID(STRING_PURE String* name) {
|
||||
}
|
||||
|
||||
bool Block_IsLiquid(BlockID b) {
|
||||
CollideType collide = Block_ExtendedCollide[b];
|
||||
UInt8 collide = Block_ExtendedCollide[b];
|
||||
return
|
||||
(collide == CollideType_LiquidWater && Block_Draw[b] == DrawType_Translucent) ||
|
||||
(collide == CollideType_LiquidLava && Block_Draw[b] == DrawType_Transparent);
|
||||
(collide == COLLIDE_LIQUID_WATER && Block_Draw[b] == DRAW_TRANSLUCENT) ||
|
||||
(collide == COLLIDE_LIQUID_LAVA && Block_Draw[b] == DRAW_TRANSPARENT);
|
||||
}
|
||||
|
||||
|
||||
@ -236,7 +236,7 @@ void Block_CalcRenderBounds(BlockID block) {
|
||||
min.X -= 0.1f / 16.0f; max.X -= 0.1f / 16.0f;
|
||||
min.Z -= 0.1f / 16.0f; max.Z -= 0.1f / 16.0f;
|
||||
min.Y -= 1.5f / 16.0f; max.Y -= 1.5f / 16.0f;
|
||||
} else if (Block_Draw[block] == DrawType_Translucent && Block_Collide[block] != CollideType_Solid) {
|
||||
} else if (Block_Draw[block] == DRAW_TRANSLUCENT && Block_Collide[block] != COLLIDE_SOLID) {
|
||||
min.X += 0.1f / 16.0f; max.X += 0.1f / 16.0f;
|
||||
min.Z += 0.1f / 16.0f; max.Z += 0.1f / 16.0f;
|
||||
min.Y -= 0.1f / 16.0f; max.Y -= 0.1f / 16.0f;
|
||||
@ -254,7 +254,7 @@ UInt8 Block_CalcLightOffset(BlockID block) {
|
||||
if (min.Z != 0) flags &= ~(1 << Face_ZMin);
|
||||
if (max.Z != 1) flags &= ~(1 << Face_ZMax);
|
||||
|
||||
if ((min.Y != 0 && max.Y == 1) && Block_Draw[block] != DrawType_Gas) {
|
||||
if ((min.Y != 0 && max.Y == 1) && Block_Draw[block] != DRAW_GAS) {
|
||||
flags &= ~(1 << Face_YMax);
|
||||
flags &= ~(1 << Face_YMin);
|
||||
}
|
||||
@ -264,7 +264,7 @@ UInt8 Block_CalcLightOffset(BlockID block) {
|
||||
void Block_RecalculateSpriteBB(void) {
|
||||
Int32 block;
|
||||
for (block = BLOCK_AIR; block < BLOCK_COUNT; block++) {
|
||||
if (Block_Draw[block] != DrawType_Sprite) continue;
|
||||
if (Block_Draw[block] != DRAW_SPRITE) continue;
|
||||
|
||||
Block_RecalculateBB((BlockID)block);
|
||||
}
|
||||
@ -360,7 +360,7 @@ void Block_CalcCulling(BlockID block, BlockID other) {
|
||||
if (Block_IsLiquid(block)) bMax.Y -= 1.5f / 16;
|
||||
if (Block_IsLiquid(other)) oMax.Y -= 1.5f / 16;
|
||||
|
||||
if (Block_Draw[block] == DrawType_Sprite) {
|
||||
if (Block_Draw[block] == DRAW_SPRITE) {
|
||||
Block_SetHidden(block, other, Face_XMin, true);
|
||||
Block_SetHidden(block, other, Face_XMax, true);
|
||||
Block_SetHidden(block, other, Face_ZMin, true);
|
||||
@ -408,7 +408,7 @@ void Block_UpdateCulling(BlockID block) {
|
||||
|
||||
bool Block_IsHidden(BlockID block, BlockID other) {
|
||||
/* Sprite blocks can never hide faces. */
|
||||
if (Block_Draw[block] == DrawType_Sprite) return false;
|
||||
if (Block_Draw[block] == DRAW_SPRITE) return false;
|
||||
|
||||
/* NOTE: Water is always culled by lava. */
|
||||
if ((block == BLOCK_WATER || block == BLOCK_STILL_WATER)
|
||||
@ -416,16 +416,16 @@ bool Block_IsHidden(BlockID block, BlockID other) {
|
||||
return true;
|
||||
|
||||
/* All blocks (except for say leaves) cull with themselves. */
|
||||
if (block == other) return Block_Draw[block] != DrawType_TransparentThick;
|
||||
if (block == other) return Block_Draw[block] != DRAW_TRANSPARENT_THICK;
|
||||
|
||||
/* An opaque neighbour (asides from lava) culls the face. */
|
||||
if (Block_Draw[other] == DrawType_Opaque && !Block_IsLiquid(other)) return true;
|
||||
if (Block_Draw[block] != DrawType_Translucent || Block_Draw[other] != DrawType_Translucent) return false;
|
||||
if (Block_Draw[other] == DRAW_OPAQUE && !Block_IsLiquid(other)) return true;
|
||||
if (Block_Draw[block] != DRAW_TRANSLUCENT || Block_Draw[other] != DRAW_TRANSLUCENT) return false;
|
||||
|
||||
/* e.g. for water / ice, don't need to draw water. */
|
||||
UInt8 bType = Block_Collide[block], oType = Block_Collide[other];
|
||||
bool canSkip = (bType == CollideType_Solid && oType == CollideType_Solid)
|
||||
|| bType != CollideType_Solid;
|
||||
bool canSkip = (bType == COLLIDE_SOLID && oType == COLLIDE_SOLID)
|
||||
|| bType != COLLIDE_SOLID;
|
||||
return canSkip;
|
||||
}
|
||||
|
||||
@ -587,82 +587,82 @@ PackedCol DefaultSet_FogColour(BlockID b) {
|
||||
return PackedCol_Create4(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
CollideType DefaultSet_Collide(BlockID b) {
|
||||
if (b == BLOCK_ICE) return CollideType_Ice;
|
||||
UInt8 DefaultSet_Collide(BlockID b) {
|
||||
if (b == BLOCK_ICE) return COLLIDE_ICE;
|
||||
if (b == BLOCK_WATER || b == BLOCK_STILL_WATER)
|
||||
return CollideType_LiquidWater;
|
||||
return COLLIDE_LIQUID_WATER;
|
||||
if (b == BLOCK_LAVA || b == BLOCK_STILL_LAVA)
|
||||
return CollideType_LiquidLava;
|
||||
return COLLIDE_LIQUID_LAVA;
|
||||
|
||||
if (b == BLOCK_SNOW || b == BLOCK_AIR || DefaultSet_Draw(b) == DrawType_Sprite)
|
||||
return CollideType_Gas;
|
||||
return CollideType_Solid;
|
||||
if (b == BLOCK_SNOW || b == BLOCK_AIR || DefaultSet_Draw(b) == DRAW_SPRITE)
|
||||
return COLLIDE_GAS;
|
||||
return COLLIDE_SOLID;
|
||||
}
|
||||
|
||||
CollideType DefaultSet_MapOldCollide(BlockID b, CollideType collide) {
|
||||
if (b == BLOCK_ICE && collide == CollideType_Solid)
|
||||
return CollideType_Ice;
|
||||
if ((b == BLOCK_WATER || b == BLOCK_STILL_WATER) && collide == CollideType_Liquid)
|
||||
return CollideType_LiquidWater;
|
||||
if ((b == BLOCK_LAVA || b == BLOCK_STILL_LAVA) && collide == CollideType_Liquid)
|
||||
return CollideType_LiquidLava;
|
||||
UInt8 DefaultSet_MapOldCollide(BlockID b, UInt8 collide) {
|
||||
if (b == BLOCK_ICE && collide == COLLIDE_SOLID)
|
||||
return COLLIDE_ICE;
|
||||
if ((b == BLOCK_WATER || b == BLOCK_STILL_WATER) && collide == COLLIDE_LIQUID)
|
||||
return COLLIDE_LIQUID_WATER;
|
||||
if ((b == BLOCK_LAVA || b == BLOCK_STILL_LAVA) && collide == COLLIDE_LIQUID)
|
||||
return COLLIDE_LIQUID_LAVA;
|
||||
return collide;
|
||||
}
|
||||
|
||||
bool DefaultSet_BlocksLight(BlockID b) {
|
||||
return !(b == BLOCK_GLASS || b == BLOCK_LEAVES
|
||||
|| b == BLOCK_AIR || DefaultSet_Draw(b) == DrawType_Sprite);
|
||||
|| b == BLOCK_AIR || DefaultSet_Draw(b) == DRAW_SPRITE);
|
||||
}
|
||||
|
||||
SoundType DefaultSet_StepSound(BlockID b) {
|
||||
if (b == BLOCK_GLASS) return SoundType_Stone;
|
||||
if (b == BLOCK_ROPE) return SoundType_Cloth;
|
||||
if (DefaultSet_Draw(b) == DrawType_Sprite) return SoundType_None;
|
||||
UInt8 DefaultSet_StepSound(BlockID b) {
|
||||
if (b == BLOCK_GLASS) return SOUND_STONE;
|
||||
if (b == BLOCK_ROPE) return SOUND_CLOTH;
|
||||
if (DefaultSet_Draw(b) == DRAW_SPRITE) return SOUND_NONE;
|
||||
return DefaultSet_DigSound(b);
|
||||
}
|
||||
|
||||
DrawType DefaultSet_Draw(BlockID b) {
|
||||
if (b == BLOCK_AIR || b == BLOCK_Invalid) return DrawType_Gas;
|
||||
if (b == BLOCK_LEAVES) return DrawType_TransparentThick;
|
||||
UInt8 DefaultSet_Draw(BlockID b) {
|
||||
if (b == BLOCK_AIR || b == BLOCK_Invalid) return DRAW_GAS;
|
||||
if (b == BLOCK_LEAVES) return DRAW_TRANSPARENT_THICK;
|
||||
|
||||
if (b == BLOCK_ICE || b == BLOCK_WATER || b == BLOCK_STILL_WATER)
|
||||
return DrawType_Translucent;
|
||||
return DRAW_TRANSLUCENT;
|
||||
if (b == BLOCK_GLASS || b == BLOCK_LEAVES)
|
||||
return DrawType_Transparent;
|
||||
return DRAW_TRANSPARENT;
|
||||
|
||||
if (b >= BLOCK_DANDELION && b <= BLOCK_RED_SHROOM)
|
||||
return DrawType_Sprite;
|
||||
return DRAW_SPRITE;
|
||||
if (b == BLOCK_SAPLING || b == BLOCK_ROPE || b == BLOCK_FIRE)
|
||||
return DrawType_Sprite;
|
||||
return DrawType_Opaque;
|
||||
return DRAW_SPRITE;
|
||||
return DRAW_OPAQUE;
|
||||
}
|
||||
|
||||
SoundType DefaultSet_DigSound(BlockID b) {
|
||||
UInt8 DefaultSet_DigSound(BlockID b) {
|
||||
if (b >= BLOCK_RED && b <= BLOCK_WHITE)
|
||||
return SoundType_Cloth;
|
||||
return SOUND_CLOTH;
|
||||
if (b >= BLOCK_LIGHT_PINK && b <= BLOCK_TURQUOISE)
|
||||
return SoundType_Cloth;
|
||||
return SOUND_CLOTH;
|
||||
if (b == BLOCK_IRON || b == BLOCK_GOLD)
|
||||
return SoundType_Metal;
|
||||
return SOUND_METAL;
|
||||
|
||||
if (b == BLOCK_BOOKSHELF || b == BLOCK_WOOD || b == BLOCK_LOG || b == BLOCK_CRATE || b == BLOCK_FIRE)
|
||||
return SoundType_Wood;
|
||||
return SOUND_WOOD;
|
||||
|
||||
if (b == BLOCK_ROPE) return SoundType_Cloth;
|
||||
if (b == BLOCK_SAND) return SoundType_Sand;
|
||||
if (b == BLOCK_SNOW) return SoundType_Snow;
|
||||
if (b == BLOCK_GLASS) return SoundType_Glass;
|
||||
if (b == BLOCK_ROPE) return SOUND_CLOTH;
|
||||
if (b == BLOCK_SAND) return SOUND_SAND;
|
||||
if (b == BLOCK_SNOW) return SOUND_SNOW;
|
||||
if (b == BLOCK_GLASS) return SOUND_GLASS;
|
||||
if (b == BLOCK_DIRT || b == BLOCK_GRAVEL)
|
||||
return SoundType_Gravel;
|
||||
return SOUND_GRAVEL;
|
||||
|
||||
if (b == BLOCK_GRASS || b == BLOCK_SAPLING || b == BLOCK_TNT || b == BLOCK_LEAVES || b == BLOCK_SPONGE)
|
||||
return SoundType_Grass;
|
||||
return SOUND_GRASS;
|
||||
|
||||
if (b >= BLOCK_DANDELION && b <= BLOCK_RED_SHROOM)
|
||||
return SoundType_Grass;
|
||||
return SOUND_GRASS;
|
||||
if (b >= BLOCK_WATER && b <= BLOCK_STILL_LAVA)
|
||||
return SoundType_None;
|
||||
return SOUND_NONE;
|
||||
if (b >= BLOCK_STONE && b <= BLOCK_STONE_BRICK)
|
||||
return SoundType_Stone;
|
||||
return SoundType_None;
|
||||
return SOUND_STONE;
|
||||
return SOUND_NONE;
|
||||
}
|
@ -15,36 +15,33 @@
|
||||
*/
|
||||
|
||||
/* Sound types for blocks. */
|
||||
typedef UInt8 SoundType;
|
||||
#define SoundType_None 0
|
||||
#define SoundType_Wood 1
|
||||
#define SoundType_Gravel 2
|
||||
#define SoundType_Grass 3
|
||||
#define SoundType_Stone 4
|
||||
#define SoundType_Metal 5
|
||||
#define SoundType_Glass 6
|
||||
#define SoundType_Cloth 7
|
||||
#define SoundType_Sand 8
|
||||
#define SoundType_Snow 9
|
||||
#define SOUND_NONE 0
|
||||
#define SOUND_WOOD 1
|
||||
#define SOUND_GRAVEL 2
|
||||
#define SOUND_GRASS 3
|
||||
#define SOUND_STONE 4
|
||||
#define SOUND_METAL 5
|
||||
#define SOUND_GLASS 6
|
||||
#define SOUND_CLOTH 7
|
||||
#define SOUND_SAND 8
|
||||
#define SOUND_SNOW 9
|
||||
|
||||
/* Describes how a block is rendered in the world. */
|
||||
typedef UInt8 DrawType;
|
||||
#define DrawType_Opaque 0 /* Completely covers blocks behind (e.g. dirt). */
|
||||
#define DrawType_Transparent 1 /* Blocks behind show (e.g. glass). Pixels either fully visible or invisible. */
|
||||
#define DrawType_TransparentThick 2 /* Same as Transparent, but all neighbour faces show. (e.g. leaves) */
|
||||
#define DrawType_Translucent 3 /* Blocks behind show (e.g. water). Pixels blend with other blocks behind. */
|
||||
#define DrawType_Gas 4 /* Does not show (e.g. air). Can still be collided with. */
|
||||
#define DrawType_Sprite 5 /* Block renders as an X (e.g. sapling). Pixels either fully visible or invisible. */
|
||||
#define DRAW_OPAQUE 0 /* Completely covers blocks behind (e.g. dirt). */
|
||||
#define DRAW_TRANSPARENT 1 /* Blocks behind show (e.g. glass). Pixels either fully visible or invisible. */
|
||||
#define DRAW_TRANSPARENT_THICK 2 /* Same as Transparent, but all neighbour faces show. (e.g. leaves) */
|
||||
#define DRAW_TRANSLUCENT 3 /* Blocks behind show (e.g. water). Pixels blend with other blocks behind. */
|
||||
#define DRAW_GAS 4 /* Does not show (e.g. air). Can still be collided with. */
|
||||
#define DRAW_SPRITE 5 /* Block renders as an X (e.g. sapling). Pixels either fully visible or invisible. */
|
||||
|
||||
/* Describes the interaction a block has with a player when they collide with it. */
|
||||
typedef UInt8 CollideType;
|
||||
#define CollideType_Gas 0 /* No interaction when player collides. */
|
||||
#define CollideType_Liquid 1 /* 'swimming'/'bobbing' interaction when player collides. */
|
||||
#define CollideType_Solid 2 /* Block completely stops the player when they are moving. */
|
||||
#define CollideType_Ice 3 /* Block is solid and partially slidable on. */
|
||||
#define CollideType_SlipperyIce 4 /* Block is solid and fully slidable on. */
|
||||
#define CollideType_LiquidWater 5 /* Water style 'swimming'/'bobbing' interaction when player collides. */
|
||||
#define CollideType_LiquidLava 6 /* Lava style 'swimming'/'bobbing' interaction when player collides. */
|
||||
#define COLLIDE_GAS 0 /* No interaction when player collides. */
|
||||
#define COLLIDE_LIQUID 1 /* 'swimming'/'bobbing' interaction when player collides. */
|
||||
#define COLLIDE_SOLID 2 /* Block completely stops the player when they are moving. */
|
||||
#define COLLIDE_ICE 3 /* Block is solid and partially slidable on. */
|
||||
#define COLLIDE_SLIPPERY_ICE 4 /* Block is solid and fully slidable on. */
|
||||
#define COLLIDE_LIQUID_WATER 5 /* Water style 'swimming'/'bobbing' interaction when player collides. */
|
||||
#define COLLIDE_LIQUID_LAVA 6 /* Lava style 'swimming'/'bobbing' interaction when player collides. */
|
||||
|
||||
UInt8 Block_NamesBuffer[String_BufferSize(STRING_SIZE) * BLOCK_COUNT];
|
||||
#define Block_NamePtr(i) &Block_NamesBuffer[String_BufferSize(STRING_SIZE) * i]
|
||||
@ -54,14 +51,14 @@ bool Block_FullBright[BLOCK_COUNT];
|
||||
String Block_Name[BLOCK_COUNT];
|
||||
PackedCol Block_FogColour[BLOCK_COUNT];
|
||||
Real32 Block_FogDensity[BLOCK_COUNT];
|
||||
CollideType Block_Collide[BLOCK_COUNT];
|
||||
CollideType Block_ExtendedCollide[BLOCK_COUNT];
|
||||
UInt8 Block_Collide[BLOCK_COUNT];
|
||||
UInt8 Block_ExtendedCollide[BLOCK_COUNT];
|
||||
Real32 Block_SpeedMultiplier[BLOCK_COUNT];
|
||||
UInt8 Block_LightOffset[BLOCK_COUNT];
|
||||
DrawType Block_Draw[BLOCK_COUNT];
|
||||
UInt8 Block_Draw[BLOCK_COUNT];
|
||||
UInt32 DefinedCustomBlocks[BLOCK_COUNT >> 5];
|
||||
SoundType Block_DigSounds[BLOCK_COUNT];
|
||||
SoundType Block_StepSounds[BLOCK_COUNT];
|
||||
UInt8 Block_DigSounds[BLOCK_COUNT];
|
||||
UInt8 Block_StepSounds[BLOCK_COUNT];
|
||||
bool Block_Tinted[BLOCK_COUNT];
|
||||
/* Gets whether the given block has an opaque draw type and is also a full tile block.
|
||||
Full tile block means Min of (0, 0, 0) and max of (1, 1, 1).*/
|
||||
@ -124,11 +121,11 @@ Real32 DefaultSet_Height(BlockID b);
|
||||
bool DefaultSet_FullBright(BlockID b);
|
||||
Real32 DefaultSet_FogDensity(BlockID b);
|
||||
PackedCol DefaultSet_FogColour(BlockID b);
|
||||
CollideType DefaultSet_Collide(BlockID b);
|
||||
UInt8 DefaultSet_Collide(BlockID b);
|
||||
/* Gets a backwards compatible collide type of a block. */
|
||||
CollideType DefaultSet_MapOldCollide(BlockID b, CollideType collide);
|
||||
UInt8 DefaultSet_MapOldCollide(BlockID b, UInt8 collide);
|
||||
bool DefaultSet_BlocksLight(BlockID b);
|
||||
SoundType DefaultSet_StepSound(BlockID b);
|
||||
DrawType DefaultSet_Draw(BlockID b);
|
||||
SoundType DefaultSet_DigSound(BlockID b);
|
||||
UInt8 DefaultSet_StepSound(BlockID b);
|
||||
UInt8 DefaultSet_Draw(BlockID b);
|
||||
UInt8 DefaultSet_DigSound(BlockID b);
|
||||
#endif
|
@ -166,7 +166,7 @@ void BordersRenderer_DrawY(Int32 x1, Int32 z1, Int32 x2, Int32 z2, Real32 y, Int
|
||||
void BordersRenderer_RebuildSides(Int32 y, Int32 axisSize) {
|
||||
BlockID block = WorldEnv_SidesBlock;
|
||||
borders_sidesVertices = 0;
|
||||
if (Block_Draw[block] == DrawType_Gas) return;
|
||||
if (Block_Draw[block] == DRAW_GAS) return;
|
||||
|
||||
Int32 i;
|
||||
for (i = 0; i < 4; i++) {
|
||||
@ -212,7 +212,7 @@ void BordersRenderer_RebuildSides(Int32 y, Int32 axisSize) {
|
||||
void BordersRenderer_RebuildEdges(Int32 y, Int32 axisSize) {
|
||||
BlockID block = WorldEnv_EdgeBlock;
|
||||
borders_edgesVertices = 0;
|
||||
if (Block_Draw[block] == DrawType_Gas) return;
|
||||
if (Block_Draw[block] == DRAW_GAS) return;
|
||||
|
||||
Int32 i;
|
||||
for (i = 0; i < 4; i++) {
|
||||
|
@ -83,7 +83,7 @@ void Builder_AddSpriteVertices(BlockID block) {
|
||||
}
|
||||
|
||||
void Builder_AddVertices(BlockID block, Face face) {
|
||||
Int32 baseOffset = (Block_Draw[block] == DrawType_Translucent) * ATLAS1D_MAX_ATLASES_COUNT;
|
||||
Int32 baseOffset = (Block_Draw[block] == DRAW_TRANSLUCENT) * ATLAS1D_MAX_ATLASES_COUNT;
|
||||
Int32 i = Atlas1D_Index(Block_GetTexLoc(block, face));
|
||||
Builder1DPart* part = &Builder_Parts[baseOffset + i];
|
||||
part->fCount[face] += 4;
|
||||
@ -135,12 +135,12 @@ void Builder_Stretch(Int32 x1, Int32 y1, Int32 z1) {
|
||||
for (x = x1, xx = 0; x < xMax; x++, xx++) {
|
||||
cIndex++;
|
||||
BlockID b = Builder_Chunk[cIndex];
|
||||
if (Block_Draw[b] == DrawType_Gas) continue;
|
||||
if (Block_Draw[b] == DRAW_GAS) continue;
|
||||
Int32 index = ((yy << 8) | (zz << 4) | xx) * Face_Count;
|
||||
|
||||
/* Sprites only use one face to indicate stretching count, so we can take a shortcut here.
|
||||
Note that sprites are not drawn with any of the DrawXFace, they are drawn using DrawSprite. */
|
||||
if (Block_Draw[b] == DrawType_Sprite) {
|
||||
if (Block_Draw[b] == DRAW_SPRITE) {
|
||||
index += Face_YMax;
|
||||
if (Builder_Counts[index] != 0) {
|
||||
Builder_X = x; Builder_Y = y; Builder_Z = z;
|
||||
@ -257,7 +257,7 @@ bool Builder_ReadChunkData(Int32 x1, Int32 y1, Int32 z1, bool* outAllAir) {
|
||||
if (x >= World_Width) break;
|
||||
BlockID rawBlock = World_Blocks[index];
|
||||
|
||||
allAir = allAir && Block_Draw[rawBlock] == DrawType_Gas;
|
||||
allAir = allAir && Block_Draw[rawBlock] == DRAW_GAS;
|
||||
allSolid = allSolid && Block_FullOpaque[rawBlock];
|
||||
Builder_Chunk[chunkIndex] = rawBlock;
|
||||
}
|
||||
@ -298,7 +298,7 @@ bool Builder_BuildChunk(Int32 x1, Int32 y1, Int32 z1, bool* allAir) {
|
||||
Int32 chunkIndex = (yy + 1) * EXTCHUNK_SIZE_2 + (zz + 1) * EXTCHUNK_SIZE + (0 + 1);
|
||||
for (x = x1, xx = 0; x < xMax; x++, xx++) {
|
||||
Builder_Block = chunk[chunkIndex];
|
||||
if (Block_Draw[Builder_Block] != DrawType_Gas) {
|
||||
if (Block_Draw[Builder_Block] != DRAW_GAS) {
|
||||
Int32 index = ((yy << 8) | (zz << 4) | xx) * Face_Count;
|
||||
Builder_X = x; Builder_Y = y; Builder_Z = z;
|
||||
Builder_ChunkIndex = chunkIndex;
|
||||
@ -346,10 +346,10 @@ bool Builder_OccludedLiquid(Int32 chunkIndex) {
|
||||
chunkIndex += EXTCHUNK_SIZE_2; /* Checking y above */
|
||||
return
|
||||
Block_FullOpaque[Builder_Chunk[chunkIndex]]
|
||||
&& Block_Draw[Builder_Chunk[chunkIndex - EXTCHUNK_SIZE]] != DrawType_Gas
|
||||
&& Block_Draw[Builder_Chunk[chunkIndex - 1]] != DrawType_Gas
|
||||
&& Block_Draw[Builder_Chunk[chunkIndex + 1]] != DrawType_Gas
|
||||
&& Block_Draw[Builder_Chunk[chunkIndex + EXTCHUNK_SIZE]] != DrawType_Gas;
|
||||
&& Block_Draw[Builder_Chunk[chunkIndex - EXTCHUNK_SIZE]] != DRAW_GAS
|
||||
&& Block_Draw[Builder_Chunk[chunkIndex - 1]] != DRAW_GAS
|
||||
&& Block_Draw[Builder_Chunk[chunkIndex + 1]] != DRAW_GAS
|
||||
&& Block_Draw[Builder_Chunk[chunkIndex + EXTCHUNK_SIZE]] != DRAW_GAS;
|
||||
}
|
||||
|
||||
void Builder_DefaultPreStretchTiles(Int32 x1, Int32 y1, Int32 z1) {
|
||||
@ -384,9 +384,9 @@ void Builder_DrawSprite(Int32 count) {
|
||||
UInt8 offsetType = Block_SpriteOffset[Builder_Block];
|
||||
if (offsetType >= 6 && offsetType <= 7) {
|
||||
Random_SetSeed(&spriteRng, (Builder_X + 1217 * Builder_Y + 4751 * Builder_Z) & 0x7fffffff);
|
||||
Real32 valX = Random_Next(&spriteRng, -3, 3 + 1) / 16.0f;
|
||||
Real32 valY = Random_Next(&spriteRng, 0, 3 + 1) / 16.0f;
|
||||
Real32 valZ = Random_Next(&spriteRng, -3, 3 + 1) / 16.0f;
|
||||
Real32 valX = Random_Range(&spriteRng, -3, 3 + 1) / 16.0f;
|
||||
Real32 valY = Random_Range(&spriteRng, 0, 3 + 1) / 16.0f;
|
||||
Real32 valZ = Random_Range(&spriteRng, -3, 3 + 1) / 16.0f;
|
||||
|
||||
x1 += valX - 1.7f; x2 += valX + 1.7f;
|
||||
z1 += valZ - 1.7f; z2 += valZ + 1.7f;
|
||||
@ -512,7 +512,7 @@ Int32 NormalBuilder_StretchZ(Int32 countIndex, Int32 x, Int32 y, Int32 z, Int32
|
||||
}
|
||||
|
||||
void NormalBuilder_RenderBlock(Int32 index) {
|
||||
if (Block_Draw[Builder_Block] == DrawType_Sprite) {
|
||||
if (Block_Draw[Builder_Block] == DRAW_SPRITE) {
|
||||
Builder_FullBright = Block_FullBright[Builder_Block];
|
||||
Builder_Tinted = Block_Tinted[Builder_Block];
|
||||
|
||||
@ -533,7 +533,7 @@ void NormalBuilder_RenderBlock(Int32 index) {
|
||||
|
||||
|
||||
bool fullBright = Block_FullBright[Builder_Block];
|
||||
Int32 partOffset = (Block_Draw[Builder_Block] == DrawType_Translucent) * ATLAS1D_MAX_ATLASES_COUNT;
|
||||
Int32 partOffset = (Block_Draw[Builder_Block] == DRAW_TRANSLUCENT) * ATLAS1D_MAX_ATLASES_COUNT;
|
||||
Int32 lightFlags = Block_LightOffset[Builder_Block];
|
||||
|
||||
Drawer_MinBB = Block_MinBB[Builder_Block]; Drawer_MinBB.Y = 1.0f - Drawer_MinBB.Y;
|
||||
|
@ -180,14 +180,14 @@ bool Entity_TouchesAnyRope(Entity* entity) {
|
||||
|
||||
Vector3 entity_liqExpand = { 0.25f / 16.0f, 0.0f / 16.0f, 0.25f / 16.0f };
|
||||
|
||||
bool Entity_IsLava(BlockID b) { return Block_ExtendedCollide[b] == CollideType_LiquidLava; }
|
||||
bool Entity_IsLava(BlockID b) { return Block_ExtendedCollide[b] == COLLIDE_LIQUID_LAVA; }
|
||||
bool Entity_TouchesAnyLava(Entity* entity) {
|
||||
AABB bounds; Entity_GetBounds(entity, &bounds);
|
||||
AABB_Offset(&bounds, &bounds, &entity_liqExpand);
|
||||
return Entity_TouchesAny(&bounds, Entity_IsLava);
|
||||
}
|
||||
|
||||
bool Entity_IsWater(BlockID b) { return Block_ExtendedCollide[b] == CollideType_LiquidWater; }
|
||||
bool Entity_IsWater(BlockID b) { return Block_ExtendedCollide[b] == COLLIDE_LIQUID_WATER; }
|
||||
bool Entity_TouchesAnyWater(Entity* entity) {
|
||||
AABB bounds; Entity_GetBounds(entity, &bounds);
|
||||
AABB_Offset(&bounds, &bounds, &entity_liqExpand);
|
||||
|
@ -69,7 +69,7 @@ void Game_UpdateBlock(Int32 x, Int32 y, Int32 z, BlockID block) {
|
||||
/* Refresh the chunk the block was located in. */
|
||||
Int32 cx = x >> 4, cy = y >> 4, cz = z >> 4;
|
||||
ChunkInfo* chunk = MapRenderer_GetChunk(cx, cy, cz);
|
||||
chunk->AllAir &= Block_Draw[block] == DrawType_Gas;
|
||||
chunk->AllAir &= Block_Draw[block] == DRAW_GAS;
|
||||
MapRenderer_RefreshChunk(cx, cy, cz);
|
||||
}
|
||||
|
||||
@ -88,9 +88,9 @@ void Game_SetViewDistance(Real32 distance, bool userDist) {
|
||||
}
|
||||
|
||||
bool Game_CanPick(BlockID block) {
|
||||
if (Block_Draw[block] == DrawType_Gas) return false;
|
||||
if (Block_Draw[block] == DrawType_Sprite) return true;
|
||||
if (Block_Draw[block] == DRAW_GAS) return false;
|
||||
if (Block_Draw[block] == DRAW_SPRITE) return true;
|
||||
|
||||
if (Block_Collide[block] != CollideType_Liquid) return true;
|
||||
if (Block_Collide[block] != COLLIDE_LIQUID) return true;
|
||||
return Game_ModifiableLiquids && Block_CanPlace[block] && Block_CanDelete[block];
|
||||
}
|
@ -51,7 +51,7 @@ void GameMode_PickLeft(BlockID old) {
|
||||
}
|
||||
|
||||
void GameMode_PickMiddle(BlockID old) {
|
||||
if (Block_Draw[old] == DrawType_Gas) return;
|
||||
if (Block_Draw[old] == DRAW_GAS) return;
|
||||
if (!(Block_CanPlace[old] || Block_CanDelete[old])) return;
|
||||
if (!Inventory_CanChangeSelected() || Inventory_SelectedBlock == old) return;
|
||||
UInt32 i;
|
||||
|
@ -149,17 +149,17 @@ void GfxCommon_MakeIndices(UInt16* indices, Int32 iCount) {
|
||||
}
|
||||
|
||||
void GfxCommon_SetupAlphaState(UInt8 draw) {
|
||||
if (draw == DrawType_Translucent) Gfx_SetAlphaBlending(true);
|
||||
if (draw == DrawType_Transparent) Gfx_SetAlphaTest(true);
|
||||
if (draw == DrawType_TransparentThick) Gfx_SetAlphaTest(true);
|
||||
if (draw == DrawType_Sprite) Gfx_SetAlphaTest(true);
|
||||
if (draw == DRAW_TRANSLUCENT) Gfx_SetAlphaBlending(true);
|
||||
if (draw == DRAW_TRANSPARENT) Gfx_SetAlphaTest(true);
|
||||
if (draw == DRAW_TRANSPARENT_THICK) Gfx_SetAlphaTest(true);
|
||||
if (draw == DRAW_SPRITE) Gfx_SetAlphaTest(true);
|
||||
}
|
||||
|
||||
void GfxCommon_RestoreAlphaState(UInt8 draw) {
|
||||
if (draw == DrawType_Translucent) Gfx_SetAlphaBlending(false);
|
||||
if (draw == DrawType_Transparent) Gfx_SetAlphaTest(false);
|
||||
if (draw == DrawType_TransparentThick) Gfx_SetAlphaTest(false);
|
||||
if (draw == DrawType_Sprite) Gfx_SetAlphaTest(false);
|
||||
if (draw == DRAW_TRANSLUCENT) Gfx_SetAlphaBlending(false);
|
||||
if (draw == DRAW_TRANSPARENT) Gfx_SetAlphaTest(false);
|
||||
if (draw == DRAW_TRANSPARENT_THICK) Gfx_SetAlphaTest(false);
|
||||
if (draw == DRAW_SPRITE) Gfx_SetAlphaTest(false);
|
||||
}
|
||||
|
||||
|
||||
|
@ -133,7 +133,7 @@ void IsometricDrawer_BeginBatch(VertexP3fT2fC4b* vertices, GfxResourceID vb) {
|
||||
|
||||
void IsometricDrawer_DrawBatch(BlockID block, Real32 size, Real32 x, Real32 y) {
|
||||
bool bright = Block_FullBright[block];
|
||||
if (Block_Draw[block] == DrawType_Gas) return;
|
||||
if (Block_Draw[block] == DRAW_GAS) return;
|
||||
|
||||
/* isometric coords size: cosY * -scale - sinY * scale */
|
||||
/* we need to divide by (2 * cosY), as the calling function expects size to be in pixels. */
|
||||
@ -147,7 +147,7 @@ void IsometricDrawer_DrawBatch(BlockID block, Real32 size, Real32 x, Real32 y) {
|
||||
/* See comment in GfxCommon_Draw2DTexture() */
|
||||
iso_pos.X -= 0.5f; iso_pos.Y -= 0.5f;
|
||||
|
||||
if (Block_Draw[block] == DrawType_Sprite) {
|
||||
if (Block_Draw[block] == DRAW_SPRITE) {
|
||||
IsometricDrawer_SpriteXQuad(block, true);
|
||||
IsometricDrawer_SpriteZQuad(block, true);
|
||||
|
||||
|
@ -129,7 +129,7 @@ void Lighting_UpdateLighting(Int32 x, Int32 y, Int32 z, BlockID oldBlock, BlockI
|
||||
|
||||
|
||||
bool Lighting_Needs(BlockID block, BlockID other) {
|
||||
return Block_Draw[block] != DrawType_Opaque || Block_Draw[other] != DrawType_Gas;
|
||||
return Block_Draw[block] != DRAW_OPAQUE || Block_Draw[other] != DRAW_GAS;
|
||||
}
|
||||
|
||||
void Lighting_ResetNeighourChunk(Int32 cx, Int32 cy, Int32 cz, BlockID block, Int32 y, Int32 index, Int32 nY) {
|
||||
@ -138,7 +138,7 @@ void Lighting_ResetNeighourChunk(Int32 cx, Int32 cy, Int32 cz, BlockID block, In
|
||||
/* Update if any blocks in the chunk are affected by light change. */
|
||||
for (; y >= minY; y--) {
|
||||
BlockID other = World_Blocks[index];
|
||||
bool affected = y == nY ? Lighting_Needs(block, other) : Block_Draw[other] != DrawType_Gas;
|
||||
bool affected = y == nY ? Lighting_Needs(block, other) : Block_Draw[other] != DRAW_GAS;
|
||||
if (affected) { MapRenderer_RefreshChunk(cx, cy, cz); return; }
|
||||
index -= World_OneY;
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ void MapRenderer_CheckWeather(Real64 deltaTime) {
|
||||
|
||||
BlockID block = World_SafeGetBlock_3I(coords);
|
||||
bool outside = !World_IsValidPos_3I(coords);
|
||||
inTranslucent = Block_Draw[block] == DrawType_Translucent || (pos.Y < WorldEnv_EdgeHeight && outside);
|
||||
inTranslucent = Block_Draw[block] == DRAW_TRANSLUCENT || (pos.Y < WorldEnv_EdgeHeight && outside);
|
||||
|
||||
/* If we are under water, render weather before to blend properly */
|
||||
if (!inTranslucent || WorldEnv_Weather == Weather_Sunny) return;
|
||||
|
@ -1114,7 +1114,7 @@ void BlockModel_RecalcProperties(Entity* p) {
|
||||
BlockID block = p->ModelBlock;
|
||||
Real32 height;
|
||||
|
||||
if (Block_Draw[block] == DrawType_Gas) {
|
||||
if (Block_Draw[block] == DRAW_GAS) {
|
||||
BlockModel_minBB = Vector3_Zero;
|
||||
BlockModel_maxBB = Vector3_One;
|
||||
height = 1.0f;
|
||||
@ -1235,10 +1235,10 @@ void BlockModel_DrawModel(Entity* p) {
|
||||
IModel_Cols[i] = white;
|
||||
}
|
||||
}
|
||||
if (Block_Draw[BlockModel_block] == DrawType_Gas) return;
|
||||
if (Block_Draw[BlockModel_block] == DRAW_GAS) return;
|
||||
|
||||
BlockModel_lastTexIndex = -1;
|
||||
bool sprite = Block_Draw[BlockModel_block] == DrawType_Sprite;
|
||||
bool sprite = Block_Draw[BlockModel_block] == DRAW_SPRITE;
|
||||
BlockModel_DrawParts(sprite);
|
||||
if (BlockModel.index == 0) return;
|
||||
|
||||
|
@ -44,7 +44,7 @@ void Particle_Reset(Particle* p, Vector3 pos, Vector3 velocity, Real32 lifetime)
|
||||
|
||||
bool Particle_CanPass(BlockID block, bool throughLiquids) {
|
||||
DrawType draw = Block_Draw[block];
|
||||
return draw == DrawType_Gas || draw == DrawType_Sprite || (throughLiquids && Block_IsLiquid(block));
|
||||
return draw == DRAW_GAS || draw == DRAW_SPRITE || (throughLiquids && Block_IsLiquid(block));
|
||||
}
|
||||
|
||||
bool Particle_CollideHor(Vector3* nextPos, BlockID block) {
|
||||
|
@ -311,7 +311,7 @@ void Physics_PropagateLava(Int32 posIndex, Int32 x, Int32 y, Int32 z) {
|
||||
BlockID block = World_Blocks[posIndex];
|
||||
if (block == BLOCK_WATER || block == BLOCK_STILL_WATER) {
|
||||
Game_UpdateBlock(x, y, z, BLOCK_STONE);
|
||||
} else if (Block_Collide[block] == CollideType_Gas) {
|
||||
} else if (Block_Collide[block] == COLLIDE_GAS) {
|
||||
TickQueue_Enqueue(&physics_lavaQ, physics_defLavaTick | (UInt32)posIndex);
|
||||
Game_UpdateBlock(x, y, z, BLOCK_LAVA);
|
||||
}
|
||||
@ -349,7 +349,7 @@ void Physics_PropagateWater(Int32 posIndex, Int32 x, Int32 y, Int32 z) {
|
||||
BlockID block = World_Blocks[posIndex];
|
||||
if (block == BLOCK_LAVA || block == BLOCK_STILL_LAVA) {
|
||||
Game_UpdateBlock(x, y, z, BLOCK_STONE);
|
||||
} else if (Block_Collide[block] == CollideType_Gas && block != BLOCK_ROPE) {
|
||||
} else if (Block_Collide[block] == COLLIDE_GAS && block != BLOCK_ROPE) {
|
||||
/* Sponge check */
|
||||
Int32 xx, yy, zz;
|
||||
for (yy = (y < 2 ? 0 : y - 2); yy <= (y > physics_maxWaterY ? World_MaxY : y + 2); yy++) {
|
||||
|
@ -195,7 +195,7 @@ bool Picking_ClipBlock(PickedPos* pos) {
|
||||
}
|
||||
|
||||
bool Picking_ClipCamera(PickedPos* pos) {
|
||||
if (Block_Draw[tracer.Block] == DrawType_Gas || Block_Collide[tracer.Block] != CollideType_Solid) {
|
||||
if (Block_Draw[tracer.Block] == DRAW_GAS || Block_Collide[tracer.Block] != COLLIDE_SOLID) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,10 @@ typedef Int64 Random;
|
||||
void Random_Init(Random* rnd, Int32 seed);
|
||||
void Random_InitFromCurrentTime(Random* rnd);
|
||||
void Random_SetSeed(Random* rnd, Int32 seed);
|
||||
Int32 Random_Range(Random* rnd, Int32 min, Int32 max); /* range from min inclusive to max exclusive*/
|
||||
Int32 Random_Next(Random* rnd, Int32 n); /* range from 0 inclusive to n exclusive*/
|
||||
Real32 Random_Float(Random* rnd); /* range from 0 inclusive to 1 exclusive*/
|
||||
/* Returns integer from min inclusive to max exclusive */
|
||||
Int32 Random_Range(Random* rnd, Int32 min, Int32 max);
|
||||
/* Returns integer from 0 inclusive to n exclusive */
|
||||
Int32 Random_Next(Random* rnd, Int32 n);
|
||||
/* Returns real from 0 inclusive to 1 exclusive */
|
||||
Real32 Random_Float(Random* rnd);
|
||||
#endif
|
@ -41,7 +41,7 @@ Int32 WeatherRenderer_CalcHeightAt(Int32 x, Int32 maxY, Int32 z, Int32 index) {
|
||||
Int32 y = maxY;
|
||||
for (y = maxY; y >= 0; y--) {
|
||||
UInt8 draw = Block_Draw[World_Blocks[mapIndex]];
|
||||
if (!(draw == DrawType_Gas || draw == DrawType_Sprite)) {
|
||||
if (!(draw == DRAW_GAS || draw == DRAW_SPRITE)) {
|
||||
Weather_Heightmap[index] = (Int16)y;
|
||||
return y;
|
||||
}
|
||||
@ -63,8 +63,8 @@ Real32 WeatherRenderer_RainHeight(Int32 x, Int32 z) {
|
||||
}
|
||||
|
||||
void WeatherRenderer_OnBlockChanged(Int32 x, Int32 y, Int32 z, BlockID oldBlock, BlockID newBlock) {
|
||||
bool didBlock = !(Block_Draw[oldBlock] == DrawType_Gas || Block_Draw[oldBlock] == DrawType_Sprite);
|
||||
bool nowBlock = !(Block_Draw[newBlock] == DrawType_Gas || Block_Draw[newBlock] == DrawType_Sprite);
|
||||
bool didBlock = !(Block_Draw[oldBlock] == DRAW_GAS || Block_Draw[oldBlock] == DRAW_SPRITE);
|
||||
bool nowBlock = !(Block_Draw[newBlock] == DRAW_GAS || Block_Draw[newBlock] == DRAW_SPRITE);
|
||||
if (didBlock == nowBlock) return;
|
||||
|
||||
Int32 index = (x * World_Length) + z;
|
||||
|
@ -244,7 +244,7 @@ Real32 Respawn_HighestFreeY(AABB* bb) {
|
||||
Vector3_Add(&blockBB.Min, &pos, &Block_MinBB[block]);
|
||||
Vector3_Add(&blockBB.Max, &pos, &Block_MaxBB[block]);
|
||||
|
||||
if (Block_Collide[block] != CollideType_Solid) continue;
|
||||
if (Block_Collide[block] != COLLIDE_SOLID) continue;
|
||||
if (!AABB_Intersects(bb, &blockBB)) continue;
|
||||
if (blockBB.Max.Y > spawnY) blockBB.Max.Y = spawnY;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user