Get rid of unneeded includes from header files

This commit is contained in:
UnknownShadow200 2018-03-30 22:46:09 +11:00
parent 27d5add8ec
commit 31b0cde8aa
64 changed files with 112 additions and 215 deletions

View File

@ -1,6 +1,5 @@
#ifndef CC_ANIMS_H #ifndef CC_ANIMS_H
#define CC_ANIMS_H #define CC_ANIMS_H
#include "Typedefs.h"
#include "GameStructs.h" #include "GameStructs.h"
/* Texture animations, and water and lava liquid animations. /* Texture animations, and water and lava liquid animations.
Copyright 2014 - 2017 ClassicalSharp | Licensed under BSD-3 Copyright 2014 - 2017 ClassicalSharp | Licensed under BSD-3

View File

@ -1,6 +1,5 @@
#ifndef CC_ASYNCDOWNLOADER_H #ifndef CC_ASYNCDOWNLOADER_H
#define CC_ASYNCDOWNLOADER_H #define CC_ASYNCDOWNLOADER_H
#include "Typedefs.h"
#include "Constants.h" #include "Constants.h"
#include "Utils.h" #include "Utils.h"
#include "GameStructs.h" #include "GameStructs.h"

View File

@ -1,6 +1,5 @@
#ifndef CC_AXISLINESRENDERER_H #ifndef CC_AXISLINESRENDERER_H
#define CC_AXISLINESRENDERER_H #define CC_AXISLINESRENDERER_H
#include "Typedefs.h"
#include "GameStructs.h" #include "GameStructs.h"
/* Renders 3 lines showing direction of each axis. /* Renders 3 lines showing direction of each axis.
Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3 Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3

View File

@ -1,6 +1,5 @@
#ifndef CC_BORDERSRENDERER_H #ifndef CC_BORDERSRENDERER_H
#define CC_BORDERSRENDERER_H #define CC_BORDERSRENDERER_H
#include "Typedefs.h"
#include "GameStructs.h" #include "GameStructs.h"
/* Renders map sides and map edges (horizon) as large quads. /* Renders map sides and map edges (horizon) as large quads.
Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3 Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3

View File

@ -9,6 +9,43 @@
#include "ErrorHandler.h" #include "ErrorHandler.h"
#include "Drawer.h" #include "Drawer.h"
#include "Random.h" #include "Random.h"
#include "ChunkUpdater.h"
#include "BlockID.h"
#include "Block.h"
#include "PackedCol.h"
#include "TerrainAtlas.h"
#include "VertexStructs.h"
BlockID* Builder_Chunk;
UInt8* Builder_Counts;
Int32* Builder_BitFlags;
bool Builder_UseBitFlags;
Int32 Builder_X, Builder_Y, Builder_Z;
BlockID Builder_Block;
Int32 Builder_ChunkIndex;
bool Builder_FullBright;
bool Builder_Tinted;
Int32 Builder_ChunkEndX, Builder_ChunkEndZ;
Int32 Builder_Offsets[6];
Int32 (*Builder_StretchXLiquid)(Int32 countIndex, Int32 x, Int32 y, Int32 z, Int32 chunkIndex, BlockID block);
Int32 (*Builder_StretchX)(Int32 countIndex, Int32 x, Int32 y, Int32 z, Int32 chunkIndex, BlockID block, Face face);
Int32 (*Builder_StretchZ)(Int32 countIndex, Int32 x, Int32 y, Int32 z, Int32 chunkIndex, BlockID block, Face face);
void (*Builder_RenderBlock)(Int32 countsIndex);
void (*Builder_PreStretchTiles)(Int32 x1, Int32 y1, Int32 z1);
void (*Builder_PostStretchTiles)(Int32 x1, Int32 y1, Int32 z1);
/* Contains state for vertices for a portion of a chunk mesh (vertices that are in a 1D atlas) */
typedef struct Builder1DPart_ {
VertexP3fT2fC4b* fVertices[FACE_COUNT];
Int32 fCount[FACE_COUNT];
Int32 sCount, sOffset, sAdvance;
VertexP3fT2fC4b* vertices;
Int32 verticesBufferCount;
} Builder1DPart;
/* Part builder data, for both normal and translucent parts.
The first ATLAS1D_MAX_ATLASES_COUNT parts are for normal parts, remainder are for translucent parts. */
Builder1DPart Builder_Parts[ATLAS1D_MAX_ATLASES_COUNT * 2];
void Builder1DPart_Prepare(Builder1DPart* part) { void Builder1DPart_Prepare(Builder1DPart* part) {
part->sOffset = 0; part->sOffset = 0;
@ -51,30 +88,6 @@ Int32 Builder1DPart_VerticesCount(Builder1DPart* part) {
return count; return count;
} }
void Builder_Init(void) {
Builder_Offsets[FACE_XMIN] = -1;
Builder_Offsets[FACE_XMAX] = 1;
Builder_Offsets[FACE_ZMIN] = -EXTCHUNK_SIZE;
Builder_Offsets[FACE_ZMAX] = EXTCHUNK_SIZE;
Builder_Offsets[FACE_YMIN] = -EXTCHUNK_SIZE_2;
Builder_Offsets[FACE_YMAX] = EXTCHUNK_SIZE_2;
}
void Builder_SetDefault(void) {
Builder_StretchXLiquid = NULL;
Builder_StretchX = NULL;
Builder_StretchZ = NULL;
Builder_RenderBlock = NULL;
Builder_UseBitFlags = false;
Builder_PreStretchTiles = Builder_DefaultPreStretchTiles;
Builder_PostStretchTiles = Builder_DefaultPostStretchTiles;
}
void Builder_OnNewMapLoaded(void) {
Builder_SidesLevel = max(0, WorldEnv_SidesHeight);
Builder_EdgeLevel = max(0, WorldEnv_EdgeHeight);
}
void Builder_AddSpriteVertices(BlockID block) { void Builder_AddSpriteVertices(BlockID block) {
Int32 i = Atlas1D_Index(Block_GetTexLoc(block, FACE_XMIN)); Int32 i = Atlas1D_Index(Block_GetTexLoc(block, FACE_XMIN));
@ -428,6 +441,31 @@ void Builder_DrawSprite(Int32 count) {
part->sOffset += 4; part->sOffset += 4;
} }
void Builder_Init(void) {
Builder_Offsets[FACE_XMIN] = -1;
Builder_Offsets[FACE_XMAX] = 1;
Builder_Offsets[FACE_ZMIN] = -EXTCHUNK_SIZE;
Builder_Offsets[FACE_ZMAX] = EXTCHUNK_SIZE;
Builder_Offsets[FACE_YMIN] = -EXTCHUNK_SIZE_2;
Builder_Offsets[FACE_YMAX] = EXTCHUNK_SIZE_2;
}
void Builder_SetDefault(void) {
Builder_StretchXLiquid = NULL;
Builder_StretchX = NULL;
Builder_StretchZ = NULL;
Builder_RenderBlock = NULL;
Builder_UseBitFlags = false;
Builder_PreStretchTiles = Builder_DefaultPreStretchTiles;
Builder_PostStretchTiles = Builder_DefaultPostStretchTiles;
}
void Builder_OnNewMapLoaded(void) {
Builder_SidesLevel = max(0, WorldEnv_SidesHeight);
Builder_EdgeLevel = max(0, WorldEnv_EdgeHeight);
}
PackedCol NormalBuilder_LightCol(Int32 x, Int32 y, Int32 z, Int32 face, BlockID block) { PackedCol NormalBuilder_LightCol(Int32 x, Int32 y, Int32 z, Int32 face, BlockID block) {
Int32 offset = (Block_LightOffset[block] >> face) & 1; Int32 offset = (Block_LightOffset[block] >> face) & 1;

View File

@ -1,12 +1,6 @@
#ifndef CC_BUILDER_H #ifndef CC_BUILDER_H
#define CC_BUILDER_H #define CC_BUILDER_H
#include "Typedefs.h" #include "Typedefs.h"
#include "Block.h"
#include "PackedCol.h"
#include "ChunkUpdater.h"
#include "BlockID.h"
#include "TerrainAtlas.h"
#include "VertexStructs.h"
/* Converts a 16x16x16 chunk into a mesh of vertices. /* Converts a 16x16x16 chunk into a mesh of vertices.
NormalMeshBuilder: NormalMeshBuilder:
Implements a simple chunk mesh builder, where each block face is a single colour. Implements a simple chunk mesh builder, where each block face is a single colour.
@ -14,88 +8,14 @@ NormalMeshBuilder:
Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3 Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3
*/ */
typedef struct ChunkInfo_ ChunkInfo;
/* Contains state for vertices for a portion of a chunk mesh (vertices that are in a 1D atlas) */
typedef struct Builder1DPart_ {
/* Pointers to offset within vertices, indexed by face. */
VertexP3fT2fC4b* fVertices[FACE_COUNT];
/* Number of indices, indexed by face. */
Int32 fCount[FACE_COUNT];
/* Number of indices, for sprites. */
Int32 sCount;
/* Current offset within vertices for sprites, delta between each sprite face. */
Int32 sOffset, sAdvance;
/* Pointer to vertex data. */
VertexP3fT2fC4b* vertices;
/* Number of elements in the vertices pointer. */
Int32 verticesBufferCount;
} Builder1DPart;
/* Prepares the given part for building vertices. */
void Builder1DPart_Prepare(Builder1DPart* part);
/* Resets counts to zero for the given part.*/
void Builder1DPart_Reset(Builder1DPart* part);
/* Counts the total number of vertices in the given part. */
Int32 Builder1DPart_VerticesCount(Builder1DPart* part);
/* Current world coordinates being processed. */
Int32 Builder_X, Builder_Y, Builder_Z;
/* Current block being processed. */
BlockID Builder_Block;
/* Current chunk index being processed. */
Int32 Builder_ChunkIndex;
/* Whether current block being processed is full bright. */
bool Builder_FullBright;
/* Whether current block being processed is tinted. */
bool Builder_Tinted;
/* Pointer to current chunk on stack.*/
BlockID* Builder_Chunk;
/* Pointer to current counts on stack. */
UInt8* Builder_Counts;
/* Pointer to current bitflags on stack. */
Int32* Builder_BitFlags;
/* Whether BitFlags should actually be assigned and cleared. Default false. */
bool Builder_UseBitFlags;
/* Caches map edge and sides height. */
Int32 Builder_SidesLevel, Builder_EdgeLevel; Int32 Builder_SidesLevel, Builder_EdgeLevel;
/* End coordinates of the chunk, as map may not be divisible by CHUNK_SIZE. */
Int32 Builder_ChunkEndX, Builder_ChunkEndZ;
/* Offset chunk indices for each face. */
Int32 Builder_Offsets[6];
/* Part builder data, for both normal and translucent parts.
The first ATLAS1D_MAX_ATLASES_COUNT parts are for normal parts, remainder are for translucent parts. */
Builder1DPart Builder_Parts[ATLAS1D_MAX_ATLASES_COUNT * 2];
/* Initalises state of this mesh builder. */
void Builder_Init(void); void Builder_Init(void);
/* Sets function pointers and variables to default. */
void Builder_SetDefault(void); void Builder_SetDefault(void);
/* Called when a new map is loaded. */
void Builder_OnNewMapLoaded(void); void Builder_OnNewMapLoaded(void);
/* Builds a mesh for the given chunk. */
void Builder_MakeChunk(ChunkInfo* info); void Builder_MakeChunk(ChunkInfo* info);
/* Returns whether a liquid block is occluded at the given index in the chunk. */
bool Builder_OccludedLiquid(Int32 chunkIndex);
/* Calculates how many blocks the current block face mesh can be stretched on X axis. */
Int32 (*Builder_StretchXLiquid)(Int32 countIndex, Int32 x, Int32 y, Int32 z, Int32 chunkIndex, BlockID block);
/* Calculates how many blocks the current block face mesh can be stretched on X axis. */
Int32 (*Builder_StretchX)(Int32 countIndex, Int32 x, Int32 y, Int32 z, Int32 chunkIndex, BlockID block, Face face);
/* Calculates how many blocks the current block face mesh can be stretched on Z axis. */
Int32 (*Builder_StretchZ)(Int32 countIndex, Int32 x, Int32 y, Int32 z, Int32 chunkIndex, BlockID block, Face face);
/* Renders the current block. */
void (*Builder_RenderBlock)(Int32 countsIndex);
/* Called just before Stretch(). */
void (*Builder_PreStretchTiles)(Int32 x1, Int32 y1, Int32 z1);
/* Called just after Stretch(). */
void (*Builder_PostStretchTiles)(Int32 x1, Int32 y1, Int32 z1);
void Builder_DefaultPreStretchTiles(Int32 x1, Int32 y1, Int32 z1);
void Builder_DefaultPostStretchTiles(Int32 x1, Int32 y1, Int32 z1);
/* Renders a sprite block. */
void Builder_DrawSprite(Int32 count);
/* Replaces function pointers in Builder with function pointers for normal mesh builder. */
void NormalBuilder_SetActive(void); void NormalBuilder_SetActive(void);
#endif #endif

View File

@ -1,7 +1,5 @@
#ifndef CC_CAMERA_H #ifndef CC_CAMERA_H
#define CC_CAMERA_H #define CC_CAMERA_H
#include "Typedefs.h"
#include "Vectors.h"
#include "Picking.h" #include "Picking.h"
/* Represents a camera, may be first or third person. /* Represents a camera, may be first or third person.

View File

@ -1,6 +1,5 @@
#ifndef CC_CHAT_H #ifndef CC_CHAT_H
#define CC_CHAT_H #define CC_CHAT_H
#include "Typedefs.h"
#include "Constants.h" #include "Constants.h"
#include "Utils.h" #include "Utils.h"
#include "GameStructs.h" #include "GameStructs.h"

View File

@ -1,6 +1,5 @@
#ifndef CC_CHUNKUPDATER_H #ifndef CC_CHUNKUPDATER_H
#define CC_CHUNKUPDATER_H #define CC_CHUNKUPDATER_H
#include "Typedefs.h"
#include "Vectors.h" #include "Vectors.h"
/* Manages the process of building/deleting chunk meshes. /* Manages the process of building/deleting chunk meshes.
Also sorts chunks so nearest chunks are ordered first, and calculates chunk visibility. Also sorts chunks so nearest chunks are ordered first, and calculates chunk visibility.

View File

@ -1,6 +1,5 @@
#ifndef CC_DEFLATE_H #ifndef CC_DEFLATE_H
#define CC_DEFLATE_H #define CC_DEFLATE_H
#include "Typedefs.h"
#include "Stream.h" #include "Stream.h"
/* Decodes data compressed using DEFLATE in a streaming manner. /* Decodes data compressed using DEFLATE in a streaming manner.
Partially based off information from Partially based off information from

View File

@ -1,8 +1,6 @@
#ifndef CC_DRAWER_H #ifndef CC_DRAWER_H
#define CC_DRAWER_H #define CC_DRAWER_H
#include "VertexStructs.h" #include "VertexStructs.h"
#include "PackedCol.h"
#include "Typedefs.h"
#include "Vectors.h" #include "Vectors.h"
/* Draws the vertices for a cuboid region. /* Draws the vertices for a cuboid region.
Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3 Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3

View File

@ -1,10 +1,7 @@
#ifndef CC_DRAWER2D_H #ifndef CC_DRAWER2D_H
#define CC_DRAWER2D_H #define CC_DRAWER2D_H
#include "Typedefs.h"
#include "Platform.h" #include "Platform.h"
#include "Bitmap.h" #include "Bitmap.h"
#include "PackedCol.h"
#include "2DStructs.h"
#include "Texture.h" #include "Texture.h"
#include "Constants.h" #include "Constants.h"
/* Responsible for performing drawing operations on bitmaps, and for converting bitmaps into textures. /* Responsible for performing drawing operations on bitmaps, and for converting bitmaps into textures.

View File

@ -15,6 +15,7 @@
#include "GraphicsCommon.h" #include "GraphicsCommon.h"
#include "AsyncDownloader.h" #include "AsyncDownloader.h"
#include "ErrorHandler.h" #include "ErrorHandler.h"
#include "IModel.h"
const UInt8* NameMode_Names[5] = { "None", "Hovered", "All", "AllHovered", "AllUnscaled" }; const UInt8* NameMode_Names[5] = { "None", "Hovered", "All", "AllHovered", "AllUnscaled" };
const UInt8* ShadowMode_Names[4] = { "None", "SnapToBlock", "Circle", "CircleAll" }; const UInt8* ShadowMode_Names[4] = { "None", "SnapToBlock", "Circle", "CircleAll" };

View File

@ -13,6 +13,7 @@
#include "GraphicsCommon.h" #include "GraphicsCommon.h"
#include "ModelCache.h" #include "ModelCache.h"
#include "Physics.h" #include "Physics.h"
#include "IModel.h"
#define ANIM_MAX_ANGLE (110 * MATH_DEG2RAD) #define ANIM_MAX_ANGLE (110 * MATH_DEG2RAD)
#define ANIM_ARM_MAX (60.0f * MATH_DEG2RAD) #define ANIM_ARM_MAX (60.0f * MATH_DEG2RAD)
@ -635,6 +636,6 @@ void ShadowComponent_Draw(Entity* entity) {
ShadowComponent_BoundShadowTex = true; ShadowComponent_BoundShadowTex = true;
} }
UInt32 vCount = (UInt32)(ptr - vertices) / VertexP3fT2fC4b_Size; UInt32 vCount = (UInt32)(ptr - vertices) / (UInt32)sizeof(VertexP3fT2fC4b);
GfxCommon_UpdateDynamicVb_IndexedTris(vb, vertices, vCount); GfxCommon_UpdateDynamicVb_IndexedTris(vb, vertices, vCount);
} }

View File

@ -1,6 +1,5 @@
#ifndef CC_ENTITY_COMPONENTS_H #ifndef CC_ENTITY_COMPONENTS_H
#define CC_ENTITY_COMPONENTS_H #define CC_ENTITY_COMPONENTS_H
#include "Typedefs.h"
#include "Vectors.h" #include "Vectors.h"
#include "String.h" #include "String.h"
/* Various components for entities. /* Various components for entities.

View File

@ -1,6 +1,5 @@
#ifndef CC_ENVRENDERER_H #ifndef CC_ENVRENDERER_H
#define CC_ENVRENDERER_H #define CC_ENVRENDERER_H
#include "Typedefs.h"
#include "GameStructs.h" #include "GameStructs.h"
/* Renders environment of the map. (clouds, sky, fog) /* Renders environment of the map. (clouds, sky, fog)
Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3 Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3

View File

@ -1,6 +1,5 @@
#ifndef CC_EVENT_H #ifndef CC_EVENT_H
#define CC_EVENT_H #define CC_EVENT_H
#include "Typedefs.h"
#include "String.h" #include "String.h"
#include "Stream.h" #include "Stream.h"
#include "Vectors.h" #include "Vectors.h"

View File

@ -11,6 +11,7 @@
#include "ExtMath.h" #include "ExtMath.h"
#include "Gui.h" #include "Gui.h"
#include "Window.h" #include "Window.h"
#include "Event.h"
Int32 Game_GetWindowScale(void) { Int32 Game_GetWindowScale(void) {
Real32 windowScale = min(Game_Width / 640.0f, Game_Height / 480.0f); Real32 windowScale = min(Game_Width / 640.0f, Game_Height / 480.0f);

View File

@ -1,6 +1,5 @@
#ifndef CC_GAME_H #ifndef CC_GAME_H
#define CC_GAME_H #define CC_GAME_H
#include "Typedefs.h"
#include "Stream.h" #include "Stream.h"
#include "Picking.h" #include "Picking.h"
#include "Options.h" #include "Options.h"

View File

@ -1,6 +1,5 @@
#ifndef CC_GAMEMODE_H #ifndef CC_GAMEMODE_H
#define CC_GAMEMODE_H #define CC_GAMEMODE_H
#include "Typedefs.h"
#include "GameStructs.h" #include "GameStructs.h"
#include "Input.h" #include "Input.h"
#include "Widgets.h" #include "Widgets.h"

View File

@ -1,6 +1,5 @@
#ifndef CC_GFXAPI_H #ifndef CC_GFXAPI_H
#define CC_GFXAPI_H #define CC_GFXAPI_H
#include "Typedefs.h"
#include "Bitmap.h" #include "Bitmap.h"
#include "PackedCol.h" #include "PackedCol.h"
#include "Vectors.h" #include "Vectors.h"

View File

@ -1,7 +1,5 @@
#ifndef CC_GFXCOMMON_H #ifndef CC_GFXCOMMON_H
#define CC_GFXCOMMON_H #define CC_GFXCOMMON_H
#include "Typedefs.h"
#include "PackedCol.h"
#include "String.h" #include "String.h"
#include "Texture.h" #include "Texture.h"
#include "VertexStructs.h" #include "VertexStructs.h"

View File

@ -1,6 +1,5 @@
#ifndef CC_GUI_H #ifndef CC_GUI_H
#define CC_GUI_H #define CC_GUI_H
#include "Typedefs.h"
#include "Input.h" #include "Input.h"
#include "VertexStructs.h" #include "VertexStructs.h"
#include "Texture.h" #include "Texture.h"

View File

@ -8,6 +8,7 @@
#include "ModelCache.h" #include "ModelCache.h"
#include "ExtMath.h" #include "ExtMath.h"
#include "Event.h" #include "Event.h"
#include "Entity.h"
BlockID held_block; BlockID held_block;
Entity held_entity; Entity held_entity;

View File

@ -1,6 +1,5 @@
#ifndef CC_HELDBLOCKRENDERER_H #ifndef CC_HELDBLOCKRENDERER_H
#define CC_HELDBLOCKRENDERER_H #define CC_HELDBLOCKRENDERER_H
#include "Typedefs.h"
#include "GameStructs.h" #include "GameStructs.h"
/* Implements rendering of held block/arm at bottom right of game. /* Implements rendering of held block/arm at bottom right of game.
Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3 Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3

View File

@ -5,6 +5,7 @@
#include "ModelCache.h" #include "ModelCache.h"
#include "GraphicsCommon.h" #include "GraphicsCommon.h"
#include "GraphicsAPI.h" #include "GraphicsAPI.h"
#include "Entity.h"
#define UV_POS_MASK ((UInt16)0x7FFF) #define UV_POS_MASK ((UInt16)0x7FFF)
#define UV_MAX ((UInt16)0x8000) #define UV_MAX ((UInt16)0x8000)

View File

@ -1,15 +1,13 @@
#ifndef CC_MODEL_H #ifndef CC_MODEL_H
#define CC_MODEL_H #define CC_MODEL_H
#include "Typedefs.h"
#include "Vectors.h" #include "Vectors.h"
#include "PackedCol.h" #include "PackedCol.h"
#include "Physics.h"
#include "Entity.h"
#include "Constants.h" #include "Constants.h"
/* Contains various structs and methods for an entity model. /* Contains various structs and methods for an entity model.
Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3 Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3
*/ */
typedef struct Entity_ Entity; typedef struct Entity_ Entity;
typedef struct AABB_ AABB;
#define IMODEL_QUAD_VERTICES 4 #define IMODEL_QUAD_VERTICES 4
#define IMODEL_BOX_VERTICES (FACE_COUNT * IMODEL_QUAD_VERTICES) #define IMODEL_BOX_VERTICES (FACE_COUNT * IMODEL_QUAD_VERTICES)

View File

@ -1,6 +1,5 @@
#ifndef CC_INPUT_H #ifndef CC_INPUT_H
#define CC_INPUT_H #define CC_INPUT_H
#include "Typedefs.h"
#include "String.h" #include "String.h"
/* Manages the keyboard, and raises events when keys are pressed etc. /* Manages the keyboard, and raises events when keys are pressed etc.
Copyright 2017 ClassicalSharp | Licensed under BSD-3 | Based on OpenTK code Copyright 2017 ClassicalSharp | Licensed under BSD-3 | Based on OpenTK code

View File

@ -1,6 +1,5 @@
#ifndef CC_INPUTHANDLER_H #ifndef CC_INPUTHANDLER_H
#define CC_INPUTHANDLER_H #define CC_INPUTHANDLER_H
#include "Typedefs.h"
#include "Gui.h" #include "Gui.h"
/* Implements base handlers for mouse and keyboard input. /* Implements base handlers for mouse and keyboard input.
Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3 Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3

View File

@ -1,6 +1,5 @@
#ifndef CC_INVENTORY_H #ifndef CC_INVENTORY_H
#define CC_INVENTORY_H #define CC_INVENTORY_H
#include "Typedefs.h"
#include "GameStructs.h" #include "GameStructs.h"
#include "BlockID.h" #include "BlockID.h"

View File

@ -1,6 +1,5 @@
#ifndef CC_ISOMETRICDRAWER_H #ifndef CC_ISOMETRICDRAWER_H
#define CC_ISOMETRICDRAWER_H #define CC_ISOMETRICDRAWER_H
#include "Typedefs.h"
#include "VertexStructs.h" #include "VertexStructs.h"
#include "Block.h" #include "Block.h"
/* Draws 2D isometric blocks for the hotbar and inventory UIs. /* Draws 2D isometric blocks for the hotbar and inventory UIs.

View File

@ -5,7 +5,7 @@
#include "Platform.h" #include "Platform.h"
#include "World.h" #include "World.h"
#include "ErrorHandler.h" #include "ErrorHandler.h"
/* Manages lighting through a simple heightmap, where each block is either in sun or shadow. */ #include "Event.h"
Int16* Lighting_heightmap; Int16* Lighting_heightmap;
PackedCol shadow, shadowZSide, shadowXSide, shadowYBottom; PackedCol shadow, shadowZSide, shadowXSide, shadowYBottom;

View File

@ -1,10 +1,9 @@
#ifndef CC_WORLDLIGHTING_H #ifndef CC_WORLDLIGHTING_H
#define CC_WORLDLIGHTING_H #define CC_WORLDLIGHTING_H
#include "Typedefs.h"
#include "PackedCol.h" #include "PackedCol.h"
#include "Event.h"
#include "GameStructs.h" #include "GameStructs.h"
/* Manages lighting of blocks in the world. /* Manages lighting of blocks in the world.
BasicLighting: Uses a simple heightmap, where each block is either in sun or shadow.
Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3 Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3
*/ */

View File

@ -1,6 +1,5 @@
#ifndef CC_MAP_GEN_H #ifndef CC_MAP_GEN_H
#define CC_MAP_GEN_H #define CC_MAP_GEN_H
#include "Typedefs.h"
#include "String.h" #include "String.h"
/* Implements flatgrass map generator, and original classic vanilla map generation. /* Implements flatgrass map generator, and original classic vanilla map generation.
Based on: https://github.com/UnknownShadow200/ClassicalSharp/wiki/Minecraft-Classic-map-generation-algorithm Based on: https://github.com/UnknownShadow200/ClassicalSharp/wiki/Minecraft-Classic-map-generation-algorithm

View File

@ -1,6 +1,5 @@
#ifndef CC_MAPRENDERER_H #ifndef CC_MAPRENDERER_H
#define CC_MAPRENDERER_H #define CC_MAPRENDERER_H
#include "Typedefs.h"
#include "TerrainAtlas.h" #include "TerrainAtlas.h"
#include "ChunkUpdater.h" #include "ChunkUpdater.h"
/* Renders the blocks of the world by subdividing it into chunks. /* Renders the blocks of the world by subdividing it into chunks.

View File

@ -10,6 +10,8 @@
#include "Block.h" #include "Block.h"
#include "Stream.h" #include "Stream.h"
#include "ErrorHandler.h" #include "ErrorHandler.h"
#include "Entity.h"
#include "IModel.h"
UInt32 ModelCache_texCount, ModelCache_modelCount; UInt32 ModelCache_texCount, ModelCache_modelCount;

View File

@ -1,12 +1,11 @@
#ifndef CC_MODELCACHE_H #ifndef CC_MODELCACHE_H
#define CC_MODELCACHE_H #define CC_MODELCACHE_H
#include "Typedefs.h"
#include "String.h" #include "String.h"
#include "IModel.h"
#include "VertexStructs.h" #include "VertexStructs.h"
/* Contains a cache of model instances and default textures for models. /* Contains a cache of model instances and default textures for models.
Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3 Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3
*/ */
typedef struct IModel_ IModel;
typedef struct CachedModel_ { typedef struct CachedModel_ {
String Name; /* Name associated with the model, all lowercase. */ String Name; /* Name associated with the model, all lowercase. */

View File

@ -473,7 +473,7 @@ void Gfx_DrawIndexedVb_TrisT2fC4b(Int32 verticesCount, Int32 startVertex) {
return; return;
} }
UInt32 offset = startVertex * VertexP3fT2fC4b_Size; UInt32 offset = startVertex * (UInt32)sizeof(VertexP3fT2fC4b);
glVertexPointer(3, GL_FLOAT, sizeof(VertexP3fT2fC4b), (void*)(offset)); glVertexPointer(3, GL_FLOAT, sizeof(VertexP3fT2fC4b), (void*)(offset));
glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(VertexP3fT2fC4b), (void*)(offset + 12)); glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(VertexP3fT2fC4b), (void*)(offset + 12));
glTexCoordPointer(2, GL_FLOAT, sizeof(VertexP3fT2fC4b), (void*)(offset + 16)); glTexCoordPointer(2, GL_FLOAT, sizeof(VertexP3fT2fC4b), (void*)(offset + 16));

View File

@ -1,6 +1,5 @@
#ifndef CC_OPTIONS_H #ifndef CC_OPTIONS_H
#define CC_OPTIONS_H #define CC_OPTIONS_H
#include "Typedefs.h"
#include "String.h" #include "String.h"
/* Manages loading and saving options. /* Manages loading and saving options.
Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3 Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3

View File

@ -1,6 +1,5 @@
#ifndef CC_PACKEDCOL_H #ifndef CC_PACKEDCOL_H
#define CC_PACKEDCOL_H #define CC_PACKEDCOL_H
#include "Typedefs.h"
#include "String.h" #include "String.h"
/* Manipulates an ARGB colour, in a format suitable for the native 3d graphics api. /* Manipulates an ARGB colour, in a format suitable for the native 3d graphics api.
Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3 Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3

View File

@ -10,6 +10,7 @@
#include "GraphicsCommon.h" #include "GraphicsCommon.h"
#include "Funcs.h" #include "Funcs.h"
#include "Game.h" #include "Game.h"
#include "Event.h"
void Particle_DoRender(Vector2* size, Vector3* pos, TextureRec* rec, PackedCol col, VertexP3fT2fC4b** vertices) { void Particle_DoRender(Vector2* size, Vector3* pos, TextureRec* rec, PackedCol col, VertexP3fT2fC4b** vertices) {
Real32 sX = size->X * 0.5f, sY = size->Y * 0.5f; Real32 sX = size->X * 0.5f, sY = size->Y * 0.5f;

View File

@ -1,8 +1,6 @@
#ifndef CC_PARTICLE_H #ifndef CC_PARTICLE_H
#define CC_PARTICLE_H #define CC_PARTICLE_H
#include "Typedefs.h"
#include "Vectors.h" #include "Vectors.h"
#include "PackedCol.h"
#include "VertexStructs.h" #include "VertexStructs.h"
#include "2DStructs.h" #include "2DStructs.h"
#include "GameStructs.h" #include "GameStructs.h"

View File

@ -1,6 +1,5 @@
#ifndef CC_PHYSICS_H #ifndef CC_PHYSICS_H
#define CC_PHYSICS_H #define CC_PHYSICS_H
#include "Typedefs.h"
#include "Vectors.h" #include "Vectors.h"
/* Contains: /* Contains:
- An axis aligned bounding box, and various methods related to them. - An axis aligned bounding box, and various methods related to them.

View File

@ -1,6 +1,5 @@
#ifndef CC_PICKEDPOSRENDERER_H #ifndef CC_PICKEDPOSRENDERER_H
#define CC_PICKEDPOSRENDERER_H #define CC_PICKEDPOSRENDERER_H
#include "Typedefs.h"
#include "GameStructs.h" #include "GameStructs.h"
#include "Picking.h" #include "Picking.h"
#include "Vectors.h" #include "Vectors.h"

View File

@ -1,6 +1,5 @@
#ifndef CC_PICKING_H #ifndef CC_PICKING_H
#define CC_PICKING_H #define CC_PICKING_H
#include "Typedefs.h"
#include "Constants.h" #include "Constants.h"
#include "Vectors.h" #include "Vectors.h"
/* Data for picking/selecting block by the user, and clipping the camera. /* Data for picking/selecting block by the user, and clipping the camera.

View File

@ -1,6 +1,5 @@
#ifndef CC_PLATFORM_H #ifndef CC_PLATFORM_H
#define CC_PLATFORM_H #define CC_PLATFORM_H
#include "Typedefs.h"
#include "Utils.h" #include "Utils.h"
#include "2DStructs.h" #include "2DStructs.h"
/* Abstracts platform specific memory management, I/O, etc. /* Abstracts platform specific memory management, I/O, etc.

View File

@ -1,6 +1,5 @@
#ifndef CC_SCREEN_H #ifndef CC_SCREEN_H
#define CC_SCREEN_H #define CC_SCREEN_H
#include "Typedefs.h"
#include "Gui.h" #include "Gui.h"
#include "String.h" #include "String.h"

View File

@ -1,6 +1,5 @@
#ifndef CC_SELECTIONBOX_H #ifndef CC_SELECTIONBOX_H
#define CC_SELECTIONBOX_H #define CC_SELECTIONBOX_H
#include "Typedefs.h"
#include "VertexStructs.h" #include "VertexStructs.h"
#include "GameStructs.h" #include "GameStructs.h"
#include "Vectors.h" #include "Vectors.h"

View File

@ -1,6 +1,5 @@
#ifndef CC_SERVERCONNECTION_H #ifndef CC_SERVERCONNECTION_H
#define CC_SERVERCONNECTION_H #define CC_SERVERCONNECTION_H
#include "Typedefs.h"
#include "String.h" #include "String.h"
#include "Input.h" #include "Input.h"
#include "GameStructs.h" #include "GameStructs.h"

View File

@ -1,6 +1,5 @@
#ifndef CC_SKYBOXRENDERER_H #ifndef CC_SKYBOXRENDERER_H
#define CC_SKYBOXRENDERER_H #define CC_SKYBOXRENDERER_H
#include "Typedefs.h"
#include "GameStructs.h" #include "GameStructs.h"
/* Renders a skybox. /* Renders a skybox.
Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3 Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3

View File

@ -1,6 +1,5 @@
#ifndef CC_STREAM_H #ifndef CC_STREAM_H
#define CC_STREAM_H #define CC_STREAM_H
#include "Typedefs.h"
#include "String.h" #include "String.h"
#include "Constants.h" #include "Constants.h"
/* Defines an abstract way of reading and writing data in a streaming manner. /* Defines an abstract way of reading and writing data in a streaming manner.

View File

@ -1,6 +1,5 @@
#ifndef CC_TERRAINATLAS_H #ifndef CC_TERRAINATLAS_H
#define CC_TERRAINATLAS_H #define CC_TERRAINATLAS_H
#include "Typedefs.h"
#include "Bitmap.h" #include "Bitmap.h"
#include "2DStructs.h" #include "2DStructs.h"
/* Represents the 2D texture atlas of terrain.png, and converted into an array of 1D textures. /* Represents the 2D texture atlas of terrain.png, and converted into an array of 1D textures.

View File

@ -1,6 +1,5 @@
#ifndef CC_TEXTURE_H #ifndef CC_TEXTURE_H
#define CC_TEXTURE_H #define CC_TEXTURE_H
#include "Typedefs.h"
#include "PackedCol.h" #include "PackedCol.h"
#include "2DStructs.h" #include "2DStructs.h"

View File

@ -1,6 +1,5 @@
#ifndef CC_TREE_GEN_H #ifndef CC_TREE_GEN_H
#define CC_TREE_GEN_H #define CC_TREE_GEN_H
#include "Typedefs.h"
#include "Random.h" #include "Random.h"
#include "Vectors.h" #include "Vectors.h"
/* Implements original classic vanilla map generation /* Implements original classic vanilla map generation

View File

@ -1,6 +1,5 @@
#ifndef CC_UTILS_H #ifndef CC_UTILS_H
#define CC_UTILS_H #define CC_UTILS_H
#include "Typedefs.h"
#include "String.h" #include "String.h"
#include "Bitmap.h" #include "Bitmap.h"
/* Implements various utility functions. /* Implements various utility functions.

View File

@ -1,27 +1,15 @@
#ifndef CC_VERTEXSTRUCTS_H #ifndef CC_VERTEXSTRUCTS_H
#define CC_VERTEXSTRUCTS_H #define CC_VERTEXSTRUCTS_H
#include "Typedefs.h"
#include "PackedCol.h" #include "PackedCol.h"
/* Represents simple vertex formats. /* Represents simple vertex formats.
Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3 Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3
*/ */
/* 3 floats for position (XYZ), 4 bytes for colour. */ /* 3 floats for position (XYZ), 4 bytes for colour. */
typedef struct VertexP3fC4b_ { typedef struct VertexP3fC4b_ { Real32 X, Y, Z; PackedCol Col; } VertexP3fC4b;
Real32 X, Y, Z;
PackedCol Col;
} VertexP3fC4b;
void VertexP3fC4b_Set(VertexP3fC4b* target, Real32 x, Real32 y, Real32 z, PackedCol col); void VertexP3fC4b_Set(VertexP3fC4b* target, Real32 x, Real32 y, Real32 z, PackedCol col);
/* 3 * 4 + 4 * 1 */
#define VertexP3fC4b_Size 16
/* 3 floats for position (XYZ), 2 floats for texture coordinates (UV), 4 bytes for colour. */ /* 3 floats for position (XYZ), 2 floats for texture coordinates (UV), 4 bytes for colour. */
typedef struct VertexP3fT2fC4b_ { typedef struct VertexP3fT2fC4b_ { Real32 X, Y, Z; PackedCol Col; Real32 U, V; } VertexP3fT2fC4b;
Real32 X, Y, Z;
PackedCol Col;
Real32 U, V;
} VertexP3fT2fC4b;
void VertexP3fT2fC4b_Set(VertexP3fT2fC4b* target, Real32 x, Real32 y, Real32 z, Real32 u, Real32 v, PackedCol col); void VertexP3fT2fC4b_Set(VertexP3fT2fC4b* target, Real32 x, Real32 y, Real32 z, Real32 u, Real32 v, PackedCol col);
/* 3 * 4 + 2 * 4 + 4 * 1 */
#define VertexP3fT2fC4b_Size 24
#endif #endif

View File

@ -13,6 +13,7 @@
#include "World.h" #include "World.h"
#include "Particle.h" #include "Particle.h"
#include "ErrorHandler.h" #include "ErrorHandler.h"
#include "Stream.h"
GfxResourceID weather_rainTex; GfxResourceID weather_rainTex;
GfxResourceID weather_snowTex; GfxResourceID weather_snowTex;
@ -173,7 +174,7 @@ void WeatherRenderer_Render(Real64 deltaTime) {
Gfx_SetAlphaArgBlend(true); Gfx_SetAlphaArgBlend(true);
Gfx_SetBatchFormat(VERTEX_FORMAT_P3FT2FC4B); Gfx_SetBatchFormat(VERTEX_FORMAT_P3FT2FC4B);
UInt32 vCount = (UInt32)(ptr - vertices) / VertexP3fT2fC4b_Size; UInt32 vCount = (UInt32)(ptr - vertices) / (UInt32)sizeof(VertexP3fT2fC4b);
GfxCommon_UpdateDynamicVb_IndexedTris(weather_vb, vertices, vCount); GfxCommon_UpdateDynamicVb_IndexedTris(weather_vb, vertices, vCount);
Gfx_SetAlphaArgBlend(false); Gfx_SetAlphaArgBlend(false);

View File

@ -1,17 +1,12 @@
#ifndef CC_WEATHERRENDERER_H #ifndef CC_WEATHERRENDERER_H
#define CC_WEATHERRENDERER_H #define CC_WEATHERRENDERER_H
#include "Typedefs.h"
#include "Stream.h"
#include "GameStructs.h" #include "GameStructs.h"
/* Renders rain and snow. /* Renders rain and snow.
Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3 Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3
*/ */
Int16* Weather_Heightmap; Int16* Weather_Heightmap;
/* Creates game component implementation. */
IGameComponent WeatherRenderer_MakeGameComponent(void); IGameComponent WeatherRenderer_MakeGameComponent(void);
/* Invokes to update state of rain/snow heightmap when a block is changed in the world. */
void WeatherRenderer_OnBlockChanged(Int32 x, Int32 y, Int32 z, BlockID oldBlock, BlockID newBlock); void WeatherRenderer_OnBlockChanged(Int32 x, Int32 y, Int32 z, BlockID oldBlock, BlockID newBlock);
/* Renders weather in the world. */
void WeatherRenderer_Render(Real64 deltaTime); void WeatherRenderer_Render(Real64 deltaTime);
#endif #endif

View File

@ -1,6 +1,5 @@
#ifndef CC_WINDOW_H #ifndef CC_WINDOW_H
#define CC_WINDOW_H #define CC_WINDOW_H
#include "Typedefs.h"
#include "String.h" #include "String.h"
#include "Bitmap.h" #include "Bitmap.h"
#include "2DStructs.h" #include "2DStructs.h"

View File

@ -1,6 +1,5 @@
#ifndef CC_WORDWRAP_H #ifndef CC_WORDWRAP_H
#define CC_WORDWRAP_H #define CC_WORDWRAP_H
#include "Typedefs.h"
#include "String.h" #include "String.h"
/* Allows wrapping a single line of text into multiple lines. /* Allows wrapping a single line of text into multiple lines.
Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3 Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3

View File

@ -85,6 +85,8 @@ extern PackedCol WorldEnv_DefaultFogCol = PACKEDCOL_CONST(0xFF, 0xFF, 0xFF, 0
extern PackedCol WorldEnv_DefaultCloudsCol = PACKEDCOL_CONST(0xFF, 0xFF, 0xFF, 0xFF); extern PackedCol WorldEnv_DefaultCloudsCol = PACKEDCOL_CONST(0xFF, 0xFF, 0xFF, 0xFF);
extern PackedCol WorldEnv_DefaultSunCol = PACKEDCOL_CONST(0xFF, 0xFF, 0xFF, 0xFF); extern PackedCol WorldEnv_DefaultSunCol = PACKEDCOL_CONST(0xFF, 0xFF, 0xFF, 0xFF);
extern PackedCol WorldEnv_DefaultShadowCol = PACKEDCOL_CONST(0x9B, 0x9B, 0x9B, 0xFF); extern PackedCol WorldEnv_DefaultShadowCol = PACKEDCOL_CONST(0x9B, 0x9B, 0x9B, 0xFF);
UInt8 World_TextureUrlBuffer[String_BufferSize(STRING_SIZE)];
extern String World_TextureUrl = String_FromEmptyArray(World_TextureUrlBuffer);
void WorldEnv_Reset(void) { void WorldEnv_Reset(void) {
WorldEnv_EdgeHeight = -1; WorldEnv_EdgeHeight = -1;

View File

@ -1,6 +1,5 @@
#ifndef CC_WORLD_H #ifndef CC_WORLD_H
#define CC_WORLD_H #define CC_WORLD_H
#include "Typedefs.h"
#include "String.h" #include "String.h"
#include "Vectors.h" #include "Vectors.h"
#include "PackedCol.h" #include "PackedCol.h"
@ -8,6 +7,7 @@
Also contains associated environment metadata. Also contains associated environment metadata.
Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3 Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3
*/ */
typedef struct AABB_ AABB;
#define World_Unpack(index, x, y, z)\ #define World_Unpack(index, x, y, z)\
x = index % World_Width;\ x = index % World_Width;\
@ -22,8 +22,7 @@ Int32 World_Width, World_Height, World_Length;
Int32 World_MaxX, World_MaxY, World_MaxZ; Int32 World_MaxX, World_MaxY, World_MaxZ;
Int32 World_OneY; Int32 World_OneY;
UInt8 World_Uuid[16]; UInt8 World_Uuid[16];
String World_TextureUrl; extern String World_TextureUrl;
/* TODO: how to initalise World_TextureUrl string */
void World_Reset(void); void World_Reset(void);
void World_SetNewMap(BlockID* blocks, Int32 blocksSize, Int32 width, Int32 height, Int32 length); void World_SetNewMap(BlockID* blocks, Int32 blocksSize, Int32 width, Int32 height, Int32 length);
@ -88,7 +87,6 @@ void WorldEnv_SetCloudsCol(PackedCol col);
void WorldEnv_SetSunCol(PackedCol col); void WorldEnv_SetSunCol(PackedCol col);
void WorldEnv_SetShadowCol(PackedCol col); void WorldEnv_SetShadowCol(PackedCol col);
typedef struct AABB_ AABB; /* Forward declaration */
/* Finds the highest free Y coordinate in the given bounding box.*/ /* Finds the highest free Y coordinate in the given bounding box.*/
Real32 Respawn_HighestFreeY(AABB* bb); Real32 Respawn_HighestFreeY(AABB* bb);
/* Finds a suitable spawn position for the entity, by iterating /* Finds a suitable spawn position for the entity, by iterating

View File

@ -2,6 +2,7 @@
#include "ErrorHandler.h" #include "ErrorHandler.h"
#include "Platform.h" #include "Platform.h"
#include "Deflate.h" #include "Deflate.h"
#include "Stream.h"
String Zip_ReadFixedString(Stream* stream, UInt8* buffer, UInt16 length) { String Zip_ReadFixedString(Stream* stream, UInt8* buffer, UInt16 length) {
String fileName; String fileName;

View File

@ -1,11 +1,10 @@
#ifndef CC_ZIPARCHIVE_H #ifndef CC_ZIPARCHIVE_H
#define CC_ZIPARCHIVE_H #define CC_ZIPARCHIVE_H
#include "Typedefs.h"
#include "String.h" #include "String.h"
#include "Stream.h"
/* Extracts entries from a .zip archive stream. /* Extracts entries from a .zip archive stream.
Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3 Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3
*/ */
typedef struct Stream_ Stream;
typedef struct ZipEntry_ { typedef struct ZipEntry_ {
Int32 CompressedDataSize, UncompressedDataSize, LocalHeaderOffset; Int32 CompressedDataSize, UncompressedDataSize, LocalHeaderOffset;