From 0e788576044b193914113bf4e09c872e922a17a5 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Thu, 11 May 2017 21:44:53 +1000 Subject: [PATCH] Fix majority of C compilation errors. Do I even know what I'm doing? --- src/Client/GraphicsAPI.h | 12 ++++++------ src/Client/Matrix.c | 7 +++++++ src/Client/Matrix.h | 8 +------- src/Client/WorldEnv.c | 12 ++++++++++++ src/Client/WorldEnv.h | 20 ++++++++++---------- src/Client/WorldEvents.h | 8 ++++---- 6 files changed, 40 insertions(+), 27 deletions(-) diff --git a/src/Client/GraphicsAPI.h b/src/Client/GraphicsAPI.h index d50698b39..a84c1e334 100644 --- a/src/Client/GraphicsAPI.h +++ b/src/Client/GraphicsAPI.h @@ -17,13 +17,13 @@ void Gfx_Init(Game* game); /* Maximum supported length of a dimension (width and height) of a 2D texture. */ -Int32 Gfx_MaxTextureDimensions = 0; +Int32 Gfx_MaxTextureDimensions; /* Minimum near plane value supported by the graphics API. */ -float Gfx_MinZNear = 0.0f; +float Gfx_MinZNear; /* Returns whether this graphics api had a valid context. */ -bool Gfx_LostContext = false; +bool Gfx_LostContext; /* Maximum number of vertices that can be indexed. */ #define Gfx_MaxIndices (65536 / 4 * 6) @@ -31,11 +31,11 @@ bool Gfx_LostContext = false; /* Event raised when a context is destroyed after having been previously lost. */ Event_Void Gfx_ContextLost[EventHandler_Size]; -Int32 Gfx_ContextLostCount = 0; +Int32 Gfx_ContextLostCount; /* Event raised when a context is recreated after having been previously lost. */ Event_Void Gfx_ContextRecreated[EventHandler_Size]; -Int32 Gfx_ContextRecreatedCount = 0; +Int32 Gfx_ContextRecreatedCount; // TODO: IMPLEMENT THIS /* /// Delegate that is invoked when the current context is lost, @@ -162,7 +162,7 @@ void Gfx_DrawIndexedVb_TrisT2fC4b_Range(Int32 indicesCount, Int32 offsetVertex, /* Optimised version of DrawIndexedVb for VertexFormat_Pos3fTex2fCol4b */ void Gfx_DrawIndexedVb_TrisT2fC4b(Int32 indicesCount, Int32 startIndex); -Int32 Gfx_strideSizes[2] = { 16, 24 }; +static Int32 Gfx_strideSizes[2] = { 16, 24 }; /* Sets the matrix type that load/push/pop operations should be applied to. */ diff --git a/src/Client/Matrix.c b/src/Client/Matrix.c index bde4bf3e9..668f4024b 100644 --- a/src/Client/Matrix.c +++ b/src/Client/Matrix.c @@ -1,6 +1,13 @@ #include "Matrix.h" #include "ExtMath.h" +Matrix Matrix_Identity = { + 1.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 1.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 1.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 1.0f +}; + /* Transposed, copied from https://open.gl/transformations */ void Matrix_RotateX(Real32 angle, Matrix* result) { diff --git a/src/Client/Matrix.h b/src/Client/Matrix.h index d86439b40..4894d4cda 100644 --- a/src/Client/Matrix.h +++ b/src/Client/Matrix.h @@ -22,13 +22,7 @@ typedef struct Matrix { } Matrix; /* Identity matrix. */ -Matrix Matrix_Identity = { - 1.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 1.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 1.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 1.0f -}; - +extern Matrix Matrix_Identity; /* Transformation matrix representing rotation angle radians around X axis. */ void Matrix_RotateX(Real32 angle, Matrix* result); diff --git a/src/Client/WorldEnv.c b/src/Client/WorldEnv.c index 6de0c2d52..426a2963d 100644 --- a/src/Client/WorldEnv.c +++ b/src/Client/WorldEnv.c @@ -3,6 +3,18 @@ #include "WorldEvents.h" +BlockID WorldEnv_EdgeBlock = BlockID_StillWater; +BlockID WorldEnv_SidesBlock = BlockID_Bedrock; +Int32 WorldEnv_EdgeHeight; +Int32 WorldEnv_SidesOffset = -2; +Int32 WorldEnv_CloudsHeight; +Real32 WorldEnv_CloudsSpeed = 1.0f; +Real32 WorldEnv_WeatherSpeed = 1.0f; +Real32 WorldEnv_WeatherFade = 1.0f; +Int32 WorldEnv_Weather = Weather_Sunny; +bool WorldEnv_ExpFog = false; + + /* Sets a value and potentially raises event. */ #define WorldEnv_Set(value, dst, envVar)\ if (value == dst) return;\ diff --git a/src/Client/WorldEnv.h b/src/Client/WorldEnv.h index d116997a0..71929e737 100644 --- a/src/Client/WorldEnv.h +++ b/src/Client/WorldEnv.h @@ -14,36 +14,36 @@ /* Block that surrounds map the map horizontally (default water) */ -BlockID WorldEnv_EdgeBlock = BlockID_StillWater; +extern BlockID WorldEnv_EdgeBlock; /* Block that surrounds the map that fills the bottom of the map horizontally, fills part of the vertical sides of the map, and also surrounds map the map horizontally. (default bedrock) */ -BlockID WorldEnv_SidesBlock = BlockID_Bedrock; +extern BlockID WorldEnv_SidesBlock; /* Height of the map edge. */ -Int32 WorldEnv_EdgeHeight; +extern Int32 WorldEnv_EdgeHeight; /* Offset of height of map sides from height of map edge. */ -Int32 WorldEnv_SidesOffset = -2; +extern Int32 WorldEnv_SidesOffset; /* Height of the clouds. */ -Int32 WorldEnv_CloudsHeight; +extern Int32 WorldEnv_CloudsHeight; /* Modifier of how fast clouds travel across the world, defaults to 1. */ -Real32 WorldEnv_CloudsSpeed = 1.0f; +extern Real32 WorldEnv_CloudsSpeed; /* Modifier of how fast rain/snow falls, defaults to 1. */ -Real32 WorldEnv_WeatherSpeed = 1.0f; +extern Real32 WorldEnv_WeatherSpeed; /* Modifier of how fast rain/snow fades, defaults to 1. */ -Real32 WorldEnv_WeatherFade = 1.0f; +extern Real32 WorldEnv_WeatherFade; /* Current weather for this particular map. */ -Int32 WorldEnv_Weather = Weather_Sunny; +extern Int32 WorldEnv_Weather; /* Whether exponential fog mode is used by default. */ -bool WorldEnv_ExpFog = false; +extern bool WorldEnv_ExpFog; /* Colour of the sky located behind / above clouds. */ diff --git a/src/Client/WorldEvents.h b/src/Client/WorldEvents.h index d7f8f04d3..e3db92a4f 100644 --- a/src/Client/WorldEvents.h +++ b/src/Client/WorldEvents.h @@ -8,7 +8,7 @@ /* Raised when the player joins and begins loading a new world. */ Event_Void WorldEvents_NewMap[EventHandler_Size]; -Int32 WorldEvents_NewMapCount = 0; +Int32 WorldEvents_NewMapCount; /* Raises NewMap event. */ #define WorldEvents_RaiseNewMap()\ @@ -18,7 +18,7 @@ EventHandler_Raise_Void(WorldEvents_NewMap, WorldEvents_NewMapCount); /* Raised when a portion of the world is read and decompressed, or generated. The floating point argument is progress (from 0 to 1). */ Event_Float32 WorldEvents_MapLoading[EventHandler_Size]; -Int32 WorldEvents_MapLoadingCount = 0; +Int32 WorldEvents_MapLoadingCount; /* Raises MapLoading event. */ #define WorldEvents_RaiseMapLoading(progress)\ @@ -27,7 +27,7 @@ EventHandler_Raise_Float32(WorldEvents_MapLoading, WorldEvents_MapLoadingCount, /* Raised when new world has finished loading and the player can now interact with it. */ Event_Void WorldEvents_MapLoaded[EventHandler_Size]; -Int32 WorldEvents_MapLoadedCount = 0; +Int32 WorldEvents_MapLoadedCount; /* Raises NewMapLoaded event. */ #define WorldEvents_RaiseMapLoaded()\ @@ -36,7 +36,7 @@ EventHandler_Raise_Void(WorldEvents_MapLoaded, WorldEvents_MapLoadedCount); /* Raised when an environment variable of the world is changed by the user, CPE, or WoM config. */ Event_Int32 WorldEvents_EnvVarChanged[EventHandler_Size]; -Int32 WorldEvents_EnvVarChangedCount = 0; +Int32 WorldEvents_EnvVarChangedCount; /* Raises EnvVariableChanged event. */ #define WorldEvents_RaiseEnvVariableChanged(envVar)\