From 3cdcad89748bf4823c3334984b83a226e87d5366 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Mon, 20 Nov 2017 15:51:44 +1100 Subject: [PATCH] Forgot missing offsetType <= 7 in last commit --- ClassicalSharp/MeshBuilder/TileDrawer.cs | 2 +- src/Client/Block.c | 126 +++++++++++------------ src/Client/Block.h | 69 ++++++------- src/Client/BordersRenderer.c | 4 +- src/Client/Builder.c | 28 ++--- src/Client/Entity.c | 4 +- src/Client/Game.c | 8 +- src/Client/GameMode.c | 2 +- src/Client/GraphicsCommon.c | 16 +-- src/Client/IsometricDrawer.c | 4 +- src/Client/Lighting.c | 4 +- src/Client/MapRenderer.c | 2 +- src/Client/ModelCache.c | 6 +- src/Client/Particle.c | 2 +- src/Client/Physics.c | 4 +- src/Client/Picking.c | 2 +- src/Client/Random.h | 9 +- src/Client/WeatherRenderer.c | 6 +- src/Client/World.c | 2 +- 19 files changed, 150 insertions(+), 150 deletions(-) diff --git a/ClassicalSharp/MeshBuilder/TileDrawer.cs b/ClassicalSharp/MeshBuilder/TileDrawer.cs index f1ad2a3f3..070b319b9 100644 --- a/ClassicalSharp/MeshBuilder/TileDrawer.cs +++ b/ClassicalSharp/MeshBuilder/TileDrawer.cs @@ -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; diff --git a/src/Client/Block.c b/src/Client/Block.c index 8d53bf15a..543705a56 100644 --- a/src/Client/Block.c +++ b/src/Client/Block.c @@ -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; } \ No newline at end of file diff --git a/src/Client/Block.h b/src/Client/Block.h index 6fe4f9965..2b481914e 100644 --- a/src/Client/Block.h +++ b/src/Client/Block.h @@ -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 \ No newline at end of file diff --git a/src/Client/BordersRenderer.c b/src/Client/BordersRenderer.c index 44bcef189..6253fb879 100644 --- a/src/Client/BordersRenderer.c +++ b/src/Client/BordersRenderer.c @@ -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++) { diff --git a/src/Client/Builder.c b/src/Client/Builder.c index 4d7c29521..9ef098128 100644 --- a/src/Client/Builder.c +++ b/src/Client/Builder.c @@ -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; diff --git a/src/Client/Entity.c b/src/Client/Entity.c index 796d7bb66..cdc36be55 100644 --- a/src/Client/Entity.c +++ b/src/Client/Entity.c @@ -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); diff --git a/src/Client/Game.c b/src/Client/Game.c index a7e85a75f..de547ca63 100644 --- a/src/Client/Game.c +++ b/src/Client/Game.c @@ -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]; } \ No newline at end of file diff --git a/src/Client/GameMode.c b/src/Client/GameMode.c index 3018d3fae..fc76a88f8 100644 --- a/src/Client/GameMode.c +++ b/src/Client/GameMode.c @@ -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; diff --git a/src/Client/GraphicsCommon.c b/src/Client/GraphicsCommon.c index c246956ae..24f88e394 100644 --- a/src/Client/GraphicsCommon.c +++ b/src/Client/GraphicsCommon.c @@ -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); } diff --git a/src/Client/IsometricDrawer.c b/src/Client/IsometricDrawer.c index 608328f67..2b152787e 100644 --- a/src/Client/IsometricDrawer.c +++ b/src/Client/IsometricDrawer.c @@ -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); diff --git a/src/Client/Lighting.c b/src/Client/Lighting.c index 7e8ebeb9e..a833aabcf 100644 --- a/src/Client/Lighting.c +++ b/src/Client/Lighting.c @@ -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; } diff --git a/src/Client/MapRenderer.c b/src/Client/MapRenderer.c index a9cc61fd0..9efe03c05 100644 --- a/src/Client/MapRenderer.c +++ b/src/Client/MapRenderer.c @@ -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; diff --git a/src/Client/ModelCache.c b/src/Client/ModelCache.c index 16c9fa973..d53404529 100644 --- a/src/Client/ModelCache.c +++ b/src/Client/ModelCache.c @@ -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; diff --git a/src/Client/Particle.c b/src/Client/Particle.c index eeb000d1c..a09c52b1f 100644 --- a/src/Client/Particle.c +++ b/src/Client/Particle.c @@ -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) { diff --git a/src/Client/Physics.c b/src/Client/Physics.c index 9933217c6..25ccc7552 100644 --- a/src/Client/Physics.c +++ b/src/Client/Physics.c @@ -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++) { diff --git a/src/Client/Picking.c b/src/Client/Picking.c index 2d025d8fb..538027cc5 100644 --- a/src/Client/Picking.c +++ b/src/Client/Picking.c @@ -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; } diff --git a/src/Client/Random.h b/src/Client/Random.h index 73167b7bd..c41630987 100644 --- a/src/Client/Random.h +++ b/src/Client/Random.h @@ -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 \ No newline at end of file diff --git a/src/Client/WeatherRenderer.c b/src/Client/WeatherRenderer.c index 6ff835136..17e6606a7 100644 --- a/src/Client/WeatherRenderer.c +++ b/src/Client/WeatherRenderer.c @@ -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; diff --git a/src/Client/World.c b/src/Client/World.c index 55108dc0c..0441ea370 100644 --- a/src/Client/World.c +++ b/src/Client/World.c @@ -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; }