make variables extern

This commit is contained in:
UnknownShadow200 2018-11-26 22:47:41 +11:00
parent b2a6fd87ec
commit 0ace7afa1e
60 changed files with 546 additions and 293 deletions

View File

@ -35,7 +35,6 @@ struct AsyncRequest {
void ASyncRequest_Free(struct AsyncRequest* request);
void AsyncDownloader_MakeComponent(struct IGameComponent* comp);
void AsyncDownloader_GetSkin(const String* id, const String* skinName);
void AsyncDownloader_GetData(const String* url, bool priority, const String* id);
void AsyncDownloader_GetContentLength(const String* url, bool priority, const String* id);

View File

@ -10,6 +10,32 @@
#include "Bitmap.h"
#include "GameStructs.h"
bool Block_IsLiquid[BLOCK_COUNT];
bool Block_BlocksLight[BLOCK_COUNT];
bool Block_FullBright[BLOCK_COUNT];
PackedCol Block_FogCol[BLOCK_COUNT];
float Block_FogDensity[BLOCK_COUNT];
uint8_t Block_Collide[BLOCK_COUNT];
uint8_t Block_ExtendedCollide[BLOCK_COUNT];
float Block_SpeedMultiplier[BLOCK_COUNT];
uint8_t Block_LightOffset[BLOCK_COUNT];
uint8_t Block_Draw[BLOCK_COUNT];
uint8_t Block_DigSounds[BLOCK_COUNT], Block_StepSounds[BLOCK_COUNT];
uint8_t Block_Tinted[BLOCK_COUNT];
bool Block_FullOpaque[BLOCK_COUNT];
uint8_t Block_SpriteOffset[BLOCK_COUNT];
Vector3 Block_MinBB[BLOCK_COUNT], Block_RenderMinBB[BLOCK_COUNT];
Vector3 Block_MaxBB[BLOCK_COUNT], Block_RenderMaxBB[BLOCK_COUNT];
TextureLoc Block_Textures[BLOCK_COUNT * FACE_COUNT];
bool Block_CanPlace[BLOCK_COUNT], Block_CanDelete[BLOCK_COUNT];
uint8_t Block_Hidden[BLOCK_COUNT * BLOCK_COUNT];
uint8_t Block_CanStretch[BLOCK_COUNT];
int Block_UsedCount, Block_IDMask;
const char* Sound_Names[SOUND_COUNT] = {
"none", "wood", "gravel", "grass", "stone",
"metal", "glass", "cloth", "sand", "snow",

View File

@ -40,24 +40,26 @@ typedef enum CollideType_ {
COLLIDE_CLIMB_ROPE /* Rope/Ladder style climbing interaction when player collides. */
} CollideType;
bool Block_IsLiquid[BLOCK_COUNT];
/* Whether a block is a liquid. (Like water/lava) */
extern bool Block_IsLiquid[BLOCK_COUNT];
/* Whether a block prevents lights from passing through it. */
bool Block_BlocksLight[BLOCK_COUNT];
bool Block_FullBright[BLOCK_COUNT];
PackedCol Block_FogCol[BLOCK_COUNT];
float Block_FogDensity[BLOCK_COUNT];
extern bool Block_BlocksLight[BLOCK_COUNT];
/* Whether a block is fully bright/light emitting. (Like lava) */
extern bool Block_FullBright[BLOCK_COUNT];
extern PackedCol Block_FogCol[BLOCK_COUNT];
extern float Block_FogDensity[BLOCK_COUNT];
/* Basic collide type of a block. (gas, liquid, or solid) */
uint8_t Block_Collide[BLOCK_COUNT];
uint8_t Block_ExtendedCollide[BLOCK_COUNT];
float Block_SpeedMultiplier[BLOCK_COUNT];
uint8_t Block_LightOffset[BLOCK_COUNT];
uint8_t Block_Draw[BLOCK_COUNT];
uint8_t Block_DigSounds[BLOCK_COUNT];
uint8_t Block_StepSounds[BLOCK_COUNT];
uint8_t Block_Tinted[BLOCK_COUNT];
extern uint8_t Block_Collide[BLOCK_COUNT];
extern uint8_t Block_ExtendedCollide[BLOCK_COUNT];
extern float Block_SpeedMultiplier[BLOCK_COUNT];
extern uint8_t Block_LightOffset[BLOCK_COUNT];
extern uint8_t Block_Draw[BLOCK_COUNT];
extern uint8_t Block_DigSounds[BLOCK_COUNT];
extern uint8_t Block_StepSounds[BLOCK_COUNT];
extern uint8_t Block_Tinted[BLOCK_COUNT];
/* Whether a block has an opaque draw type, a min of (0,0,0), and a max of (1,1,1) */
bool Block_FullOpaque[BLOCK_COUNT];
uint8_t Block_SpriteOffset[BLOCK_COUNT];
extern bool Block_FullOpaque[BLOCK_COUNT];
extern uint8_t Block_SpriteOffset[BLOCK_COUNT];
#define Block_Tint(col, block)\
if (Block_Tinted[block]) {\
@ -67,28 +69,27 @@ if (Block_Tinted[block]) {\
col.B = (uint8_t)(col.B * tintCol.B / 255);\
}
Vector3 Block_MinBB[BLOCK_COUNT];
Vector3 Block_MaxBB[BLOCK_COUNT];
Vector3 Block_RenderMinBB[BLOCK_COUNT];
Vector3 Block_RenderMaxBB[BLOCK_COUNT];
extern Vector3 Block_MinBB[BLOCK_COUNT];
extern Vector3 Block_MaxBB[BLOCK_COUNT];
extern Vector3 Block_RenderMinBB[BLOCK_COUNT];
extern Vector3 Block_RenderMaxBB[BLOCK_COUNT];
TextureLoc Block_Textures[BLOCK_COUNT * FACE_COUNT];
bool Block_CanPlace[BLOCK_COUNT];
bool Block_CanDelete[BLOCK_COUNT];
extern TextureLoc Block_Textures[BLOCK_COUNT * FACE_COUNT];
/* Whether the player has permission to place a block. */
extern bool Block_CanPlace[BLOCK_COUNT];
/* Whether the player has permission to delete a block. */
extern bool Block_CanDelete[BLOCK_COUNT];
/* Bit flags of faces hidden of two neighbouring blocks. */
uint8_t Block_Hidden[BLOCK_COUNT * BLOCK_COUNT];
extern uint8_t Block_Hidden[BLOCK_COUNT * BLOCK_COUNT];
/* Bit flags of which faces of a block can stretch with greedy meshing. */
uint8_t Block_CanStretch[BLOCK_COUNT];
extern uint8_t Block_CanStretch[BLOCK_COUNT];
#ifdef EXTENDED_BLOCKS
int Block_UsedCount, Block_IDMask;
void Block_SetUsedCount(int count);
extern int Block_UsedCount, Block_IDMask;
extern void Block_SetUsedCount(int count);
#endif
void Block_Reset(void);
void Block_Init(void);
void Block_SetDefaultPerms(void);
bool Block_IsCustomDefined(BlockID block);
void Block_SetCustomDefined(BlockID block, bool defined);
void Block_DefineCustom(BlockID block);

View File

@ -89,6 +89,7 @@ static PhysicsHandler Physics_OnRandomTick[BLOCK_COUNT];
static PhysicsHandler Physics_OnPlace[BLOCK_COUNT];
static PhysicsHandler Physics_OnDelete[BLOCK_COUNT];
bool Physics_Enabled;
static RNGState physics_rnd;
static int physics_tickCount;
static int physics_maxWaterX, physics_maxWaterY, physics_maxWaterZ;

View File

@ -5,7 +5,7 @@
Copyright 2014 - 2017 ClassicalSharp | Licensed under BSD-3
*/
bool Physics_Enabled;
extern bool Physics_Enabled;
void Physics_SetEnabled(bool enabled);
void Physics_Init(void);
void Physics_Free(void);

View File

@ -15,6 +15,7 @@
#include "TerrainAtlas.h"
#include "VertexStructs.h"
int Builder_SidesLevel, Builder_EdgeLevel;
/* Packs an index into the 16x16x16 count array. Coordinates range from 0 to 15. */
#define Builder_PackCount(xx, yy, zz) ((((yy) << 8) | ((zz) << 4) | (xx)) * FACE_COUNT)
/* Packs an index into the 18x18x18 chunk array. Coordinates range from -1 to 16. */

View File

@ -10,7 +10,7 @@ Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3
*/
struct ChunkInfo;
int Builder_SidesLevel, Builder_EdgeLevel;
extern int Builder_SidesLevel, Builder_EdgeLevel;
void Builder_Init(void);
void Builder_OnNewMapLoaded(void);

View File

@ -8,6 +8,11 @@
#include "Entity.h"
#include "Input.h"
struct Matrix Camera_TiltM;
float Camera_BobbingVer, Camera_BobbingHor;
Vector3 Camera_CurrentPos;
struct Camera* Camera_Active;
static Vector2 cam_rotOffset;
static bool cam_isForwardThird;

View File

@ -9,11 +9,11 @@ struct PickedPos;
struct Camera;
/* Tilt effect applied to the camera. */
struct Matrix Camera_TiltM;
extern struct Matrix Camera_TiltM;
/* Bobbing offset of camera from player's eye. */
float Camera_BobbingVer, Camera_BobbingHor;
extern float Camera_BobbingVer, Camera_BobbingHor;
/* Cached position the camera is at */
Vector3 Camera_CurrentPos;
extern Vector3 Camera_CurrentPos;
struct Camera {
/* Whether this camera is third person. (i.e. not allowed when -thirdperson in MOTD) */
@ -45,7 +45,7 @@ struct Camera {
};
/* Camera user is currently using. */
struct Camera* Camera_Active;
extern struct Camera* Camera_Active;
/* Initialises the default cameras. */
void Camera_Init(void);
/* Switches to the next camera in the list. */

View File

@ -15,6 +15,9 @@
#include "EnvRenderer.h"
#include "GameStructs.h"
struct ChatLine Chat_Status[3], Chat_BottomRight[3], Chat_ClientStatus[3], Chat_Announcement;
StringsBuffer Chat_Log, Chat_InputLog;
/*########################################################################################################################*
*-------------------------------------------------------Chat logging------------------------------------------------------*
*#########################################################################################################################*/

View File

@ -24,8 +24,8 @@ typedef enum MsgType_ {
} MsgType;
struct ChatLine { char Buffer[STRING_SIZE]; TimeMS Received; };
struct ChatLine Chat_Status[3], Chat_BottomRight[3], Chat_ClientStatus[3], Chat_Announcement;
StringsBuffer Chat_Log, Chat_InputLog;
extern struct ChatLine Chat_Status[3], Chat_BottomRight[3], Chat_ClientStatus[3], Chat_Announcement;
extern StringsBuffer Chat_Log, Chat_InputLog;
/* Gets the time the ith chat message was received at. */
TimeMS Chat_GetLogTime(int i);

View File

@ -2,6 +2,12 @@
#include "TerrainAtlas.h"
#include "Constants.h"
bool Drawer_Tinted;
PackedCol Drawer_TintCol;
Vector3 Drawer_MinBB, Drawer_MaxBB;
float Drawer_X1, Drawer_Y1, Drawer_Z1;
float Drawer_X2, Drawer_Y2, Drawer_Z2;
/* Performance critical, use macro to ensure always inlined. */
#define ApplyTint \
if (Drawer_Tinted) {\

View File

@ -7,17 +7,17 @@
*/
/* Whether a colour tinting effect should be applied to all faces. */
bool Drawer_Tinted;
extern bool Drawer_Tinted;
/* The colour to multiply colour of faces by (tinting effect). */
PackedCol Drawer_TintCol;
extern PackedCol Drawer_TintCol;
/* Minimum corner of base block bounding box. (For texture UV) */
Vector3 Drawer_MinBB;
extern Vector3 Drawer_MinBB;
/* Maximum corner of base block bounding box. (For texture UV) */
Vector3 Drawer_MaxBB;
extern Vector3 Drawer_MaxBB;
/* Coordinate of minimum block bounding box corner in the world. */
float Drawer_X1, Drawer_Y1, Drawer_Z1;
extern float Drawer_X1, Drawer_Y1, Drawer_Z1;
/* Coordinate of maximum block bounding box corner in the world. */
float Drawer_X2, Drawer_Y2, Drawer_Z2;
extern float Drawer_X2, Drawer_Y2, Drawer_Z2;
void Drawer_XMin(int count, PackedCol col, TextureLoc texLoc, VertexP3fT2fC4b** vertices);
void Drawer_XMax(int count, PackedCol col, TextureLoc texLoc, VertexP3fT2fC4b** vertices);

View File

@ -7,6 +7,10 @@
#include "Bitmap.h"
#include "Game.h"
bool Drawer2D_BitmappedText;
bool Drawer2D_BlackTextShadows;
BitmapCol Drawer2D_Cols[DRAWER2D_MAX_COLS];
void DrawTextArgs_Make(struct DrawTextArgs* args, STRING_REF const String* text, const FontDesc* font, bool useShadow) {
args->Text = *text;
args->Font = *font;

View File

@ -18,10 +18,11 @@ CC_NOINLINE void Drawer2D_MakeFont(FontDesc* desc, int size, int style);
/* Whether chat text should be drawn and measuring using the currently bitmapped font,
false uses the font supplied as the DrawTextArgs argument supplied to the function. */
bool Drawer2D_BitmappedText;
extern bool Drawer2D_BitmappedText;
/* Whether the shadows behind text (that uses shadows) is fully black. */
bool Drawer2D_BlackTextShadows;
BitmapCol Drawer2D_Cols[DRAWER2D_MAX_COLS];
extern bool Drawer2D_BlackTextShadows;
/* List of all colours. (An A of 0 means the colour is not used) */
extern BitmapCol Drawer2D_Cols[DRAWER2D_MAX_COLS];
#define DRAWER2D_OFFSET 1
#define Drawer2D_GetCol(c) Drawer2D_Cols[(uint8_t)c]

View File

@ -19,6 +19,8 @@
#include "Stream.h"
#include "Bitmap.h"
NameMode Entities_NameMode;
ShadowMode Entities_ShadowMode;
const char* NameMode_Names[NAME_MODE_COUNT] = { "None", "Hovered", "All", "AllHovered", "AllUnscaled" };
const char* ShadowMode_Names[SHADOW_MODE_COUNT] = { "None", "SnapToBlock", "Circle", "CircleAll" };
@ -217,7 +219,9 @@ bool Entity_TouchesAnyWater(struct Entity* e) {
/*########################################################################################################################*
*--------------------------------------------------------Entities---------------------------------------------------------*
*#########################################################################################################################*/
struct Entity* Entities_List[ENTITIES_MAX_COUNT];
static EntityID entities_closestId;
void Entities_Tick(struct ScheduledTask* task) {
int i;
for (i = 0; i < ENTITIES_MAX_COUNT; i++) {
@ -378,6 +382,12 @@ void Entities_DrawShadows(void) {
/*########################################################################################################################*
*--------------------------------------------------------TabList----------------------------------------------------------*
*#########################################################################################################################*/
StringsBuffer TabList_Buffer;
uint16_t TabList_PlayerNames[TABLIST_MAX_NAMES];
uint16_t TabList_ListNames[TABLIST_MAX_NAMES];
uint16_t TabList_GroupNames[TABLIST_MAX_NAMES];
uint8_t TabList_GroupRanks[TABLIST_MAX_NAMES];
bool TabList_Valid(EntityID id) {
return TabList_PlayerNames[id] || TabList_ListNames[id] || TabList_GroupNames[id];
}
@ -755,6 +765,7 @@ static void Player_Init(struct Entity* e) {
/*########################################################################################################################*
*------------------------------------------------------LocalPlayer--------------------------------------------------------*
*#########################################################################################################################*/
struct LocalPlayer LocalPlayer_Instance;
float LocalPlayer_JumpHeight(void) {
struct LocalPlayer* p = &LocalPlayer_Instance;
return (float)PhysicsComp_GetMaxHeight(p->Physics.JumpVel);

View File

@ -25,13 +25,13 @@ extern struct IGameComponent Entities_Component;
typedef enum NameMode_ {
NAME_MODE_NONE, NAME_MODE_HOVERED, NAME_MODE_ALL, NAME_MODE_ALL_HOVERED, NAME_MODE_ALL_UNSCALED, NAME_MODE_COUNT
} NameMode;
NameMode Entities_NameMode;
extern NameMode Entities_NameMode;
extern const char* NameMode_Names[NAME_MODE_COUNT];
typedef enum ShadowMode_ {
SHADOW_MODE_NONE, SHADOW_MODE_SNAP_TO_BLOCK, SHADOW_MODE_CIRCLE, SHADOW_MODE_CIRCLE_ALL, SHADOW_MODE_COUNT
} ShadowMode;
ShadowMode Entities_ShadowMode;
extern ShadowMode Entities_ShadowMode;
extern const char* ShadowMode_Names[SHADOW_MODE_COUNT];
#define ENTITY_TYPE_NONE 0
@ -105,7 +105,7 @@ bool Entity_TouchesAnyRope(struct Entity* e);
bool Entity_TouchesAnyLava(struct Entity* e);
bool Entity_TouchesAnyWater(struct Entity* e);
struct Entity* Entities_List[ENTITIES_MAX_COUNT];
extern struct Entity* Entities_List[ENTITIES_MAX_COUNT];
void Entities_Tick(struct ScheduledTask* task);
void Entities_RenderModels(double delta, float t);
void Entities_RenderNames(double delta);
@ -115,11 +115,11 @@ EntityID Entities_GetCloset(struct Entity* src);
void Entities_DrawShadows(void);
#define TABLIST_MAX_NAMES 256
StringsBuffer TabList_Buffer;
uint16_t TabList_PlayerNames[TABLIST_MAX_NAMES];
uint16_t TabList_ListNames[TABLIST_MAX_NAMES];
uint16_t TabList_GroupNames[TABLIST_MAX_NAMES];
uint8_t TabList_GroupRanks[TABLIST_MAX_NAMES];
extern StringsBuffer TabList_Buffer;
extern uint16_t TabList_PlayerNames[TABLIST_MAX_NAMES];
extern uint16_t TabList_ListNames[TABLIST_MAX_NAMES];
extern uint16_t TabList_GroupNames[TABLIST_MAX_NAMES];
extern uint8_t TabList_GroupRanks[TABLIST_MAX_NAMES];
bool TabList_Valid(EntityID id);
bool TabList_Remove(EntityID id);
void TabList_Set(EntityID id, const String* player, const String* list, const String* group, uint8_t rank);
@ -157,8 +157,7 @@ struct LocalPlayer {
bool _WarnedRespawn, _WarnedFly, _WarnedNoclip;
};
struct LocalPlayer LocalPlayer_Instance;
void LocalPlayer_Init(void);
extern struct LocalPlayer LocalPlayer_Instance;
float LocalPlayer_JumpHeight(void);
void LocalPlayer_CheckHacksConsistency(void);
void LocalPlayer_SetInterpPosition(float t);

View File

@ -467,6 +467,8 @@ void LocalInterpComp_AdvanceState(struct InterpComp* interp) {
/*########################################################################################################################*
*-----------------------------------------------------ShadowComponent-----------------------------------------------------*
*#########################################################################################################################*/
bool ShadowComponent_BoundShadowTex;
GfxResourceID ShadowComponent_ShadowTex;
static float shadow_radius, shadow_uvScale;
struct ShadowData { float Y; BlockID Block; uint8_t A; };

View File

@ -100,8 +100,8 @@ void NetInterpComp_AdvanceState(struct NetInterpComp* interp);
/* Entity component that draws square and circle shadows beneath entities */
bool ShadowComponent_BoundShadowTex;
GfxResourceID ShadowComponent_ShadowTex;
extern bool ShadowComponent_BoundShadowTex;
extern GfxResourceID ShadowComponent_ShadowTex;
void ShadowComponent_Draw(struct Entity* entity);
/* Entity component that performs collision detection */

View File

@ -18,6 +18,8 @@
#include "Camera.h"
#include "Particle.h"
bool EnvRenderer_Legacy, EnvRenderer_Minimal;
#define ENV_SMALL_VERTICES 4096
static float EnvRenderer_BlendFactor(float x) {
/* return -0.05 + 0.22 * (Math_Log(x) * 0.25f); */
@ -356,14 +358,15 @@ static void EnvRenderer_UpdateSkybox(void) {
/*########################################################################################################################*
*----------------------------------------------------------Weather--------------------------------------------------------*
*#########################################################################################################################*/
int16_t* Weather_Heightmap;
static GfxResourceID rain_tex, snow_tex, weather_vb;
#define WEATHER_EXTENT 4
#define WEATHER_VERTS_COUNT 8 * (WEATHER_EXTENT * 2 + 1) * (WEATHER_EXTENT * 2 + 1)
#define Weather_Pack(x, z) ((x) * World_Length + (z))
static double weather_accumulator;
static Vector3I weather_lastPos;
#define WEATHER_EXTENT 4
#define WEATHER_VERTS_COUNT 8 * (WEATHER_EXTENT * 2 + 1) * (WEATHER_EXTENT * 2 + 1)
#define Weather_Pack(x, z) ((x) * World_Length + (z))
static void EnvRenderer_InitWeatherHeightmap(void) {
int i;
Weather_Heightmap = Mem_Alloc(World_Width * World_Length, 2, "weather heightmap");

View File

@ -16,11 +16,11 @@ void EnvRenderer_RenderMapEdges(double delta);
void EnvRenderer_RenderSkybox(double deltaTime);
bool EnvRenderer_ShouldRenderSkybox(void);
int16_t* Weather_Heightmap;
extern int16_t* Weather_Heightmap;
void EnvRenderer_OnBlockChanged(int x, int y, int z, BlockID oldBlock, BlockID newBlock);
void EnvRenderer_RenderWeather(double deltaTime);
bool EnvRenderer_Legacy, EnvRenderer_Minimal;
extern bool EnvRenderer_Legacy, EnvRenderer_Minimal;
void EnvRenderer_UseMinimalMode(bool minimal);
void EnvRenderer_UseLegacyMode(bool legacy);
#endif

View File

@ -1,6 +1,57 @@
#include "Event.h"
#include "ErrorHandler.h"
struct Event_Int EntityEvents_Added;
struct Event_Int EntityEvents_Removed;
struct Event_Int TabListEvents_Added;
struct Event_Int TabListEvents_Changed;
struct Event_Int TabListEvents_Removed;
struct Event_Void TextureEvents_AtlasChanged;
struct Event_Void TextureEvents_PackChanged;
struct Event_Entry TextureEvents_FileChanged;
struct Event_Void GfxEvents_ViewDistanceChanged;
struct Event_Void GfxEvents_LowVRAMDetected;
struct Event_Void GfxEvents_ProjectionChanged;
struct Event_Void GfxEvents_ContextLost;
struct Event_Void GfxEvents_ContextRecreated;
struct Event_Block UserEvents_BlockChanged;
struct Event_Void UserEvents_HackPermissionsChanged;
struct Event_Void UserEvents_HeldBlockChanged;
struct Event_Void BlockEvents_PermissionsChanged;
struct Event_Void BlockEvents_BlockDefChanged;
struct Event_Void WorldEvents_NewMap;
struct Event_Float WorldEvents_Loading;
struct Event_Void WorldEvents_MapLoaded;
struct Event_Int WorldEvents_EnvVarChanged;
struct Event_Void ChatEvents_FontChanged;
struct Event_Chat ChatEvents_ChatReceived;
struct Event_Chat ChatEvents_ChatSending;
struct Event_Int ChatEvents_ColCodeChanged;
struct Event_Void WindowEvents_Redraw;
struct Event_Void WindowEvents_Moved;
struct Event_Void WindowEvents_Resized;
struct Event_Void WindowEvents_Closing;
struct Event_Void WindowEvents_Closed;
struct Event_Void WindowEvents_VisibilityChanged;
struct Event_Void WindowEvents_FocusChanged;
struct Event_Void WindowEvents_StateChanged;
struct Event_Int KeyEvents_Press;
struct Event_Int KeyEvents_Down;
struct Event_Int KeyEvents_Up;
struct Event_MouseMove MouseEvents_Moved;
struct Event_Int MouseEvents_Down;
struct Event_Int MouseEvents_Up;
struct Event_Float MouseEvents_Wheel;
static void Event_RegisterImpl(struct Event_Void* handlers, void* obj, Event_Void_Callback handler) {
int i;
for (i = 0; i < handlers->Count; i++) {

View File

@ -80,54 +80,54 @@ void Event_RaiseChat(struct Event_Chat* handlers, const String* msg, int msgType
void Event_RegisterChat(struct Event_Chat* handlers, void* obj, Event_Chat_Callback handler);
void Event_UnregisterChat(struct Event_Chat* handlers, void* obj, Event_Chat_Callback handler);
struct Event_Int EntityEvents_Added; /* Entity is spawned in the current world */
struct Event_Int EntityEvents_Removed; /* Entity is despawned from the current world */
struct Event_Int TabListEvents_Added; /* Tab list entry is created */
struct Event_Int TabListEvents_Changed; /* Tab list entry is modified */
struct Event_Int TabListEvents_Removed; /* Tab list entry is removed */
extern struct Event_Int EntityEvents_Added; /* Entity is spawned in the current world */
extern struct Event_Int EntityEvents_Removed; /* Entity is despawned from the current world */
extern struct Event_Int TabListEvents_Added; /* Tab list entry is created */
extern struct Event_Int TabListEvents_Changed; /* Tab list entry is modified */
extern struct Event_Int TabListEvents_Removed; /* Tab list entry is removed */
struct Event_Void TextureEvents_AtlasChanged; /* Terrain atlas (terrain.png) is changed */
struct Event_Void TextureEvents_PackChanged; /* Texture pack is changed */
struct Event_Entry TextureEvents_FileChanged; /* File in a texture pack is changed (terrain.png, rain.png) */
extern struct Event_Void TextureEvents_AtlasChanged; /* Terrain atlas (terrain.png) is changed */
extern struct Event_Void TextureEvents_PackChanged; /* Texture pack is changed */
extern struct Event_Entry TextureEvents_FileChanged; /* File in a texture pack is changed (terrain.png, rain.png) */
struct Event_Void GfxEvents_ViewDistanceChanged; /* View/fog distance is changed */
struct Event_Void GfxEvents_LowVRAMDetected; /* Insufficient VRAM detected, need to free some GPU resources */
struct Event_Void GfxEvents_ProjectionChanged; /* Projection matrix has changed */
struct Event_Void GfxEvents_ContextLost; /* Context is destroyed after having been previously created */
struct Event_Void GfxEvents_ContextRecreated; /* Context is recreated after having been previously lost */
extern struct Event_Void GfxEvents_ViewDistanceChanged; /* View/fog distance is changed */
extern struct Event_Void GfxEvents_LowVRAMDetected; /* Insufficient VRAM detected, need to free some GPU resources */
extern struct Event_Void GfxEvents_ProjectionChanged; /* Projection matrix has changed */
extern struct Event_Void GfxEvents_ContextLost; /* Context is destroyed after having been previously created */
extern struct Event_Void GfxEvents_ContextRecreated; /* Context is recreated after having been previously lost */
struct Event_Block UserEvents_BlockChanged; /* User changes a block */
struct Event_Void UserEvents_HackPermissionsChanged; /* Hack permissions of the player changes */
struct Event_Void UserEvents_HeldBlockChanged; /* Held block in hotbar changes */
extern struct Event_Block UserEvents_BlockChanged; /* User changes a block */
extern struct Event_Void UserEvents_HackPermissionsChanged; /* Hack permissions of the player changes */
extern struct Event_Void UserEvents_HeldBlockChanged; /* Held block in hotbar changes */
struct Event_Void BlockEvents_PermissionsChanged; /* Block permissions (can place/delete) for a block changes */
struct Event_Void BlockEvents_BlockDefChanged; /* Block definition is changed or removed */
extern struct Event_Void BlockEvents_PermissionsChanged; /* Block permissions (can place/delete) for a block changes */
extern struct Event_Void BlockEvents_BlockDefChanged; /* Block definition is changed or removed */
struct Event_Void WorldEvents_NewMap; /* Player begins loading a new world */
struct Event_Float WorldEvents_Loading; /* Portion of world is decompressed/generated (Arg is progress from 0-1) */
struct Event_Void WorldEvents_MapLoaded; /* New world has finished loading, player can now interact with it */
struct Event_Int WorldEvents_EnvVarChanged; /* World environment variable changed by player/CPE/WoM config */
extern struct Event_Void WorldEvents_NewMap; /* Player begins loading a new world */
extern struct Event_Float WorldEvents_Loading; /* Portion of world is decompressed/generated (Arg is progress from 0-1) */
extern struct Event_Void WorldEvents_MapLoaded; /* New world has finished loading, player can now interact with it */
extern struct Event_Int WorldEvents_EnvVarChanged; /* World environment variable changed by player/CPE/WoM config */
struct Event_Void ChatEvents_FontChanged; /* User changes whether system chat font used, and when the bitmapped font texture changes */
struct Event_Chat ChatEvents_ChatReceived; /* Raised when message is being added to chat */
struct Event_Chat ChatEvents_ChatSending; /* Raised when user sends a message */
struct Event_Int ChatEvents_ColCodeChanged; /* Raised when a colour code changes */
extern struct Event_Void ChatEvents_FontChanged; /* User changes whether system chat font used, and when the bitmapped font texture changes */
extern struct Event_Chat ChatEvents_ChatReceived; /* Raised when message is being added to chat */
extern struct Event_Chat ChatEvents_ChatSending; /* Raised when user sends a message */
extern struct Event_Int ChatEvents_ColCodeChanged; /* Raised when a colour code changes */
struct Event_Void WindowEvents_Redraw; /* Window contents invalidated, should be redrawn */
struct Event_Void WindowEvents_Moved; /* Window is moved */
struct Event_Void WindowEvents_Resized; /* Window is resized */
struct Event_Void WindowEvents_Closing; /* Window is about to close */
struct Event_Void WindowEvents_Closed; /* Window has closed */
struct Event_Void WindowEvents_VisibilityChanged; /* Visibility of the window changed */
struct Event_Void WindowEvents_FocusChanged; /* Focus of the window changed */
struct Event_Void WindowEvents_StateChanged; /* WindowState of the window changed */
extern struct Event_Void WindowEvents_Redraw; /* Window contents invalidated, should be redrawn */
extern struct Event_Void WindowEvents_Moved; /* Window is moved */
extern struct Event_Void WindowEvents_Resized; /* Window is resized */
extern struct Event_Void WindowEvents_Closing; /* Window is about to close */
extern struct Event_Void WindowEvents_Closed; /* Window has closed */
extern struct Event_Void WindowEvents_VisibilityChanged; /* Visibility of the window changed */
extern struct Event_Void WindowEvents_FocusChanged; /* Focus of the window changed */
extern struct Event_Void WindowEvents_StateChanged; /* WindowState of the window changed */
struct Event_Int KeyEvents_Press; /* Raised when a character is typed. Arg is a character */
struct Event_Int KeyEvents_Down; /* Raised when a key is pressed. Arg is a member of Key enumeration */
struct Event_Int KeyEvents_Up; /* Raised when a key is released. Arg is a member of Key enumeration */
extern struct Event_Int KeyEvents_Press; /* Raised when a character is typed. Arg is a character */
extern struct Event_Int KeyEvents_Down; /* Raised when a key is pressed. Arg is a member of Key enumeration */
extern struct Event_Int KeyEvents_Up; /* Raised when a key is released. Arg is a member of Key enumeration */
struct Event_MouseMove MouseEvents_Moved; /* Mouse position is changed (Arg is delta from last position) */
struct Event_Int MouseEvents_Down; /* Mouse button is pressed (Arg is MouseButton member) */
struct Event_Int MouseEvents_Up; /* Mouse button is released (Arg is MouseButton member) */
struct Event_Float MouseEvents_Wheel; /* Mouse wheel is moved/scrolled (Arg is wheel delta) */
extern struct Event_MouseMove MouseEvents_Moved; /* Mouse position is changed (Arg is delta from last position) */
extern struct Event_Int MouseEvents_Down; /* Mouse button is pressed (Arg is MouseButton member) */
extern struct Event_Int MouseEvents_Up; /* Mouse button is released (Arg is MouseButton member) */
extern struct Event_Float MouseEvents_Wheel; /* Mouse wheel is moved/scrolled (Arg is wheel delta) */
#endif

View File

@ -35,6 +35,36 @@
#include "Stream.h"
#include "TerrainAtlas.h"
int Game_Width, Game_Height;
double Game_Accumulator;
int Game_ChunkUpdates, Game_Port;
bool Game_CameraClipping, Game_UseCPEBlocks;
struct PickedPos Game_SelectedPos, Game_CameraClipPos;
int Game_ViewDistance, Game_MaxViewDistance, Game_UserViewDistance;
int Game_Fov, Game_DefaultFov, Game_ZoomFov;
float game_limitMs;
int Game_FpsLimit, Game_Vertices;
bool Game_ShowAxisLines, Game_SimpleArmsAnim;
bool Game_ClassicArmModel, Game_InvertMouse;
int Game_MouseSensitivity, Game_ChatLines;
bool Game_TabAutocomplete, Game_UseClassicGui;
bool Game_UseClassicTabList, Game_UseClassicOptions;
bool Game_ClassicMode, Game_ClassicHacks;
bool Game_AllowCustomBlocks, Game_UseCPE;
bool Game_AllowServerTextures, Game_SmoothLighting;
bool Game_ChatLogging, Game_AutoRotate;
bool Game_SmoothCamera, Game_ClickableChat;
bool Game_HideGui, Game_ShowFPS;
bool Game_ViewBobbing, Game_ShowBlockInHand;
int Game_SoundsVolume, Game_MusicVolume;
bool Game_BreakableLiquids, Game_ScreenshotRequested;
int Game_MaxChunkUpdates;
float Game_RawHotbarScale, Game_RawChatScale, Game_RawInventoryScale;
static struct ScheduledTask Game_Tasks[6];
static int Game_TasksCount, entTaskI;

View File

@ -10,65 +10,64 @@
struct DisplayDevice;
struct Stream;
int Game_Width, Game_Height;
/* Total rendering time(in seconds) elapsed since the client was started. */
double Game_Accumulator;
int Game_ChunkUpdates;
bool Game_CameraClipping;
struct PickedPos Game_SelectedPos;
struct PickedPos Game_CameraClipPos;
GfxResourceID Game_DefaultIb;
bool Game_UseCPEBlocks;
extern int Game_Width, Game_Height;
/* Total rendering time (in seconds) elapsed since the client was started. */
extern double Game_Accumulator;
extern int Game_ChunkUpdates;
extern bool Game_CameraClipping;
extern struct PickedPos Game_SelectedPos;
extern struct PickedPos Game_CameraClipPos;
extern bool Game_UseCPEBlocks;
extern String Game_Username;
extern String Game_Mppass;
extern String Game_IPAddress;
int Game_Port;
extern int Game_Port;
int Game_ViewDistance;
int Game_MaxViewDistance;
int Game_UserViewDistance;
int Game_Fov;
int Game_DefaultFov, Game_ZoomFov;
extern int Game_ViewDistance;
extern int Game_MaxViewDistance;
extern int Game_UserViewDistance;
extern int Game_Fov;
extern int Game_DefaultFov, Game_ZoomFov;
float game_limitMs;
int Game_FpsLimit;
bool Game_ShowAxisLines;
bool Game_SimpleArmsAnim;
bool Game_ClassicArmModel;
bool Game_InvertMouse;
int Game_Vertices;
extern float game_limitMs;
extern int Game_FpsLimit;
extern bool Game_ShowAxisLines;
extern bool Game_SimpleArmsAnim;
extern bool Game_ClassicArmModel;
extern bool Game_InvertMouse;
extern int Game_Vertices;
int Game_MouseSensitivity;
bool Game_TabAutocomplete;
bool Game_UseClassicGui;
bool Game_UseClassicTabList;
bool Game_UseClassicOptions;
bool Game_ClassicMode;
bool Game_ClassicHacks;
extern int Game_MouseSensitivity;
extern bool Game_TabAutocomplete;
extern bool Game_UseClassicGui;
extern bool Game_UseClassicTabList;
extern bool Game_UseClassicOptions;
extern bool Game_ClassicMode;
extern bool Game_ClassicHacks;
#define Game_PureClassic (Game_ClassicMode && !Game_ClassicHacks)
bool Game_AllowCustomBlocks;
bool Game_UseCPE;
bool Game_AllowServerTextures;
bool Game_SmoothLighting;
bool Game_ChatLogging;
bool Game_AutoRotate;
bool Game_SmoothCamera;
extern bool Game_AllowCustomBlocks;
extern bool Game_UseCPE;
extern bool Game_AllowServerTextures;
extern bool Game_SmoothLighting;
extern bool Game_ChatLogging;
extern bool Game_AutoRotate;
extern bool Game_SmoothCamera;
extern String Game_FontName;
int Game_ChatLines;
bool Game_ClickableChat;
bool Game_HideGui;
bool Game_ShowFPS;
extern int Game_ChatLines;
extern bool Game_ClickableChat;
extern bool Game_HideGui;
extern bool Game_ShowFPS;
bool Game_ViewBobbing;
bool Game_ShowBlockInHand;
int Game_SoundsVolume;
int Game_MusicVolume;
bool Game_BreakableLiquids;
int Game_MaxChunkUpdates;
bool Game_ScreenshotRequested;
extern bool Game_ViewBobbing;
extern bool Game_ShowBlockInHand;
extern int Game_SoundsVolume;
extern int Game_MusicVolume;
extern bool Game_BreakableLiquids;
extern int Game_MaxChunkUpdates;
extern bool Game_ScreenshotRequested;
float Game_RawHotbarScale, Game_RawChatScale, Game_RawInventoryScale;
extern float Game_RawHotbarScale, Game_RawChatScale, Game_RawInventoryScale;
float Game_Scale(float value);
float Game_GetHotbarScale(void);
float Game_GetInventoryScale(void);

View File

@ -15,6 +15,24 @@
#define NOMCX
#define NOIME
int Gfx_MaxTexWidth, Gfx_MaxTexHeight;
float Gfx_MinZNear;
bool Gfx_LostContext;
bool Gfx_Mipmaps, Gfx_CustomMipmapsLevels;
struct Matrix Gfx_View, Gfx_Projection;
static char Gfx_ApiBuffer[7][STRING_SIZE];
String Gfx_ApiInfo[7] = {
String_FromArray(Gfx_ApiBuffer[0]), String_FromArray(Gfx_ApiBuffer[1]),
String_FromArray(Gfx_ApiBuffer[2]), String_FromArray(Gfx_ApiBuffer[3]),
String_FromArray(Gfx_ApiBuffer[4]), String_FromArray(Gfx_ApiBuffer[5]),
String_FromArray(Gfx_ApiBuffer[6]),
};
GfxResourceID Gfx_defaultIb;
GfxResourceID Gfx_quadVb, Gfx_texVb;
ScheduledTaskCallback Gfx_LostContextFunction;
static int Gfx_strideSizes[2] = { 16, 24 };
static int gfx_batchStride, gfx_batchFormat = -1;
@ -24,14 +42,6 @@ bool Gfx_GetFog(void) { return gfx_fogEnabled; }
/*########################################################################################################################*
*------------------------------------------------------Generic/Common-----------------------------------------------------*
*#########################################################################################################################*/
static char Gfx_ApiBuffer[7][STRING_SIZE];
String Gfx_ApiInfo[7] = {
String_FromArray(Gfx_ApiBuffer[0]), String_FromArray(Gfx_ApiBuffer[1]),
String_FromArray(Gfx_ApiBuffer[2]), String_FromArray(Gfx_ApiBuffer[3]),
String_FromArray(Gfx_ApiBuffer[4]), String_FromArray(Gfx_ApiBuffer[5]),
String_FromArray(Gfx_ApiBuffer[6]),
};
CC_NOINLINE static void Gfx_InitDefaultResources(void) {
uint16_t indices[GFX_MAX_INDICES];
Gfx_MakeIndices(indices, GFX_MAX_INDICES);
@ -184,7 +194,7 @@ void Gfx_RestoreAlphaState(uint8_t draw) {
/* Quoted from http://www.realtimerendering.com/blog/gpus-prefer-premultiplication/
The short version: if you want your renderer to properly handle textures with alphas when using
bilinear interpolation or mipmapping, you need to premultiply your PNG color data by their (unassociated) alphas. */
static BitmapCol GfxCommon_Average(BitmapCol p1, BitmapCol p2) {
static BitmapCol Gfx_Average(BitmapCol p1, BitmapCol p2) {
uint32_t a1, a2, aSum;
uint32_t b1, g1, r1;
uint32_t b2, g2, r2;
@ -227,9 +237,9 @@ void Gfx_GenMipmaps(int width, int height, uint8_t* lvlScan0, uint8_t* scan0) {
BitmapCol src10 = src1[srcX], src11 = src1[srcX + 1];
/* bilinear filter this mipmap */
BitmapCol ave0 = GfxCommon_Average(src00, src01);
BitmapCol ave1 = GfxCommon_Average(src10, src11);
dst[x] = GfxCommon_Average(ave0, ave1);
BitmapCol ave0 = Gfx_Average(src00, src01);
BitmapCol ave1 = Gfx_Average(src10, src11);
dst[x] = Gfx_Average(ave0, ave1);
}
}
}

View File

@ -34,23 +34,23 @@ typedef enum MatrixType_ {
void Gfx_Init(void);
void Gfx_Free(void);
int Gfx_MaxTexWidth, Gfx_MaxTexHeight;
float Gfx_MinZNear;
bool Gfx_LostContext;
bool Gfx_Mipmaps;
bool Gfx_CustomMipmapsLevels;
struct Matrix Gfx_View, Gfx_Projection;
extern int Gfx_MaxTexWidth, Gfx_MaxTexHeight;
extern float Gfx_MinZNear;
extern bool Gfx_LostContext;
extern bool Gfx_Mipmaps;
extern bool Gfx_CustomMipmapsLevels;
extern struct Matrix Gfx_View, Gfx_Projection;
extern String Gfx_ApiInfo[7];
GfxResourceID Gfx_defaultIb;
GfxResourceID Gfx_quadVb, Gfx_texVb;
extern GfxResourceID Gfx_defaultIb;
extern GfxResourceID Gfx_quadVb, Gfx_texVb;
#define ICOUNT(verticesCount) (((verticesCount) >> 2) * 6)
#define GFX_MAX_INDICES (65536 / 4 * 6)
#define GFX_MAX_VERTICES 65536
/* Callback invoked when the context is lost. Repeatedly invoked until a context can be retrieved. */
ScheduledTaskCallback Gfx_LostContextFunction;
extern ScheduledTaskCallback Gfx_LostContextFunction;
/* Creates a new texture. (and also generates mipmaps if mipmaps) */
/* NOTE: Only set mipmaps to true if Gfx_Mipmaps is also true, because whether textures

View File

@ -12,7 +12,13 @@
#include "Platform.h"
#include "Bitmap.h"
GfxResourceID Gui_GuiTex, Gui_GuiClassicTex, Gui_IconsTex;
struct Screen* Gui_Status;
struct Screen* Gui_HUD;
struct Screen* Gui_Active;
struct Screen* Gui_Overlays[GUI_MAX_OVERLAYS];
int Gui_OverlaysCount;
void Gui_DefaultRecreate(void* elem) {
struct GuiElem* e = elem;
Elem_Free(e); Elem_Init(e);

View File

@ -76,16 +76,15 @@ void Widget_Reset(void* widget);
bool Widget_Contains(void* widget, int x, int y);
GfxResourceID Gui_GuiTex, Gui_GuiClassicTex, Gui_IconsTex;
struct Screen* Gui_HUD;
struct Screen* Gui_Active;
extern GfxResourceID Gui_GuiTex, Gui_GuiClassicTex, Gui_IconsTex;
extern struct Screen* Gui_HUD;
extern struct Screen* Gui_Active;
#define GUI_MAX_OVERLAYS 6
struct Screen* Gui_Overlays[GUI_MAX_OVERLAYS];
int Gui_OverlaysCount;
extern struct Screen* Gui_Overlays[GUI_MAX_OVERLAYS];
extern int Gui_OverlaysCount;
int Gui_CalcPos(uint8_t anchor, int offset, int size, int axisLen);
bool Gui_Contains(int recX, int recY, int width, int height, int x, int y);
void Gui_MakeComponent(struct IGameComponent* comp);
/* Gets the screen that the user is currently interacting with.
This means if an overlay is active, it will be over the top of other screens. */
struct Screen* Gui_GetActiveScreen(void);

View File

@ -9,8 +9,11 @@
/*########################################################################################################################*
*--------------------------------------------------------Key/Mouse--------------------------------------------------------*
*-----------------------------------------------------------Key-----------------------------------------------------------*
*#########################################################################################################################*/
bool Key_KeyRepeat;
bool Key_Pressed[KEY_COUNT];
#define Key_Function_Names \
"F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10",\
"F11", "F12", "F13", "F14", "F15", "F16", "F17", "F18", "F19", "F20",\
@ -82,6 +85,14 @@ void Key_Clear(void) {
}
}
/*########################################################################################################################*
*----------------------------------------------------------Mouse----------------------------------------------------------*
*#########################################################################################################################*/
float Mouse_Wheel;
int Mouse_X, Mouse_Y;
bool Mouse_Pressed[MOUSE_COUNT];
void Mouse_SetPressed(MouseButton btn, bool pressed) {
if (Mouse_Pressed[btn] == pressed) return;
Mouse_Pressed[btn] = pressed;
@ -186,7 +197,7 @@ void KeyBind_Init(void) {
/*########################################################################################################################*
*---------------------------------------------------------Hotkeys---------------------------------------------------------*
*#########################################################################################################################*/
uint8_t Hotkeys_LWJGL[256] = {
const uint8_t Hotkeys_LWJGL[256] = {
0, KEY_ESCAPE, KEY_1, KEY_2, KEY_3, KEY_4, KEY_5, KEY_6, KEY_7, KEY_8, KEY_9, KEY_0, KEY_MINUS, KEY_PLUS, KEY_BACKSPACE, KEY_TAB,
KEY_Q, KEY_W, KEY_E, KEY_R, KEY_T, KEY_Y, KEY_U, KEY_I, KEY_O, KEY_P, KEY_LBRACKET, KEY_RBRACKET, KEY_ENTER, KEY_LCTRL, KEY_A, KEY_S,
KEY_D, KEY_F, KEY_G, KEY_H, KEY_J, KEY_K, KEY_L, KEY_SEMICOLON, KEY_QUOTE, KEY_TILDE, KEY_LSHIFT, KEY_BACKSLASH, KEY_Z, KEY_X, KEY_C, KEY_V,
@ -204,6 +215,8 @@ uint8_t Hotkeys_LWJGL[256] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
struct HotkeyData HotkeysList[HOTKEYS_MAX_COUNT];
StringsBuffer HotkeysText;
static void Hotkeys_QuickSort(int left, int right) {
struct HotkeyData* keys = HotkeysList; struct HotkeyData key;

View File

@ -68,7 +68,7 @@ typedef enum Key_ {
/* Gets whether key repeating is on or not. When on, multiple KeyDown events are raised when the same key is
held down for a period of time (frequency depends on platform). Should be on for menu input, off for game input. */
bool Key_KeyRepeat;
extern bool Key_KeyRepeat;
/* Simple names for each keyboard button. */
extern const char* Key_Names[KEY_COUNT];
@ -78,7 +78,7 @@ extern const char* Key_Names[KEY_COUNT];
#define Key_IsShiftPressed() (Key_Pressed[KEY_LSHIFT] || Key_Pressed[KEY_RSHIFT])
/* Pressed state of each keyboard button. Use Key_SetPressed to change. */
bool Key_Pressed[KEY_COUNT];
extern bool Key_Pressed[KEY_COUNT];
/* Sets the pressed state of a keyboard button. */
/* Raises KeyEvents_Up or KeyEvents_Down if state differs, or Key_KeyRepeat is on. */
void Key_SetPressed(Key key, bool pressed);
@ -93,12 +93,12 @@ typedef enum MouseButton_ {
} MouseButton;
/* Wheel position of the mouse. Use Mouse_SetWheel to change. */
float Mouse_Wheel;
extern float Mouse_Wheel;
/* X and Y coordinates of the mouse. Use Mouse_SetPosition to change. */
int Mouse_X, Mouse_Y;
extern int Mouse_X, Mouse_Y;
/* Pressed state of each mouse button. Use Mouse_SetPressed to change. */
bool Mouse_Pressed[MOUSE_COUNT];
extern bool Mouse_Pressed[MOUSE_COUNT];
/* Sets the pressed state of a mouse button. */
/* Raises MouseEvents_Up or MouseEvents_Down if state differs. */
void Mouse_SetPressed(MouseButton btn, bool pressed);
@ -134,7 +134,7 @@ void KeyBind_Set(KeyBind binding, Key key);
void KeyBind_Init(void);
extern uint8_t Hotkeys_LWJGL[256];
extern const uint8_t Hotkeys_LWJGL[256];
struct HotkeyData {
int TextIndex; /* contents to copy directly into the input bar */
uint8_t Trigger; /* Member of Key enumeration */
@ -143,8 +143,8 @@ struct HotkeyData {
};
#define HOTKEYS_MAX_COUNT 256
struct HotkeyData HotkeysList[HOTKEYS_MAX_COUNT];
StringsBuffer HotkeysText;
extern struct HotkeyData HotkeysList[HOTKEYS_MAX_COUNT];
extern StringsBuffer HotkeysText;
typedef enum HotkeyFlags_ {
HOTKEY_FLAG_CTRL = 1, HOTKEY_FLAG_SHIFT = 2, HOTKEY_FLAG_ALT = 4
} HotkeyFlags;

View File

@ -6,6 +6,13 @@
#include "Chat.h"
#include "GameStructs.h"
BlockID Inventory_Table[INVENTORY_HOTBARS * INVENTORY_BLOCKS_PER_HOTBAR];
BlockID Inventory_Map[BLOCK_COUNT];
int Inventory_SelectedIndex;
int Inventory_Offset;
bool Inventory_CanChangeHeldBlock, Inventory_CanPick;
bool Inventory_CanChangeSelected(void) {
if (!Inventory_CanChangeHeldBlock) {
Chat_AddRaw("&cThe server has forbidden you from changing your held block.");

View File

@ -12,16 +12,16 @@ extern struct IGameComponent Inventory_Component;
#define INVENTORY_BLOCKS_PER_HOTBAR 9
#define INVENTORY_HOTBARS 9
/* Stores the blocks for all hotbars. */
BlockID Inventory_Table[INVENTORY_HOTBARS * INVENTORY_BLOCKS_PER_HOTBAR];
extern BlockID Inventory_Table[INVENTORY_HOTBARS * INVENTORY_BLOCKS_PER_HOTBAR];
/* Mapping of indices in inventory menu to block IDs. */
BlockID Inventory_Map[BLOCK_COUNT];
extern BlockID Inventory_Map[BLOCK_COUNT];
int Inventory_SelectedIndex;
int Inventory_Offset;
extern int Inventory_SelectedIndex;
extern int Inventory_Offset;
#define Inventory_Get(idx) (Inventory_Table[Inventory_Offset + (idx)])
#define Inventory_Set(idx, block) Inventory_Table[Inventory_Offset + (idx)] = block
#define Inventory_SelectedBlock Inventory_Get(Inventory_SelectedIndex)
bool Inventory_CanChangeHeldBlock, Inventory_CanPick;
extern bool Inventory_CanChangeHeldBlock, Inventory_CanPick;
bool Inventory_CanChangeSelected(void);
void Inventory_SetSelectedIndex(int index);

View File

@ -8,6 +8,7 @@
#include "Event.h"
#include "GameStructs.h"
int16_t* Lighting_Heightmap;
#define HEIGHT_UNCALCULATED Int16_MaxValue
#define Lighting_CalcBody(get_block)\

View File

@ -9,7 +9,7 @@ struct IGameComponent;
extern struct IGameComponent Lighting_Component;
#define Lighting_Pack(x, z) ((x) + World_Width * (z))
int16_t* Lighting_Heightmap;
extern int16_t* Lighting_Heightmap;
/* Equivalent to (but far more optimised form of)
* for x = startX; x < startX + 18; x++

View File

@ -5,6 +5,13 @@
#include "Funcs.h"
#include "Platform.h"
volatile float Gen_CurrentProgress;
volatile const char* Gen_CurrentState;
volatile bool Gen_Done;
int Gen_Width, Gen_Height, Gen_Length, Gen_Seed;
bool Gen_Vanilla;
BlockRaw* Gen_Blocks;
static int Gen_MaxX, Gen_MaxY, Gen_MaxZ, Gen_Volume, Gen_OneY;
#define Gen_Pack(x, y, z) (((y) * Gen_Length + (z)) * Gen_Width + (x))
@ -636,8 +643,11 @@ float CombinedNoise_Calc(struct CombinedNoise* n, float x, float y) {
/*########################################################################################################################*
*--------------------------------------------------Tree generation----------------------------------------------------*
*----------------------------------------------------Tree generation------------------------------------------------------*
*#########################################################################################################################*/
int Tree_Width, Tree_Height, Tree_Length;
BlockRaw* Tree_Blocks;
RNGState* Tree_Rnd;
#define Tree_Pack(x, y, z) (((y) * Tree_Length + (z)) * Tree_Width + (x))
bool TreeGen_CanGrow(int treeX, int treeY, int treeZ, int treeHeight) {

View File

@ -9,12 +9,12 @@
Copyright 2014 - 2017 ClassicalSharp | Licensed under BSD-3
*/
volatile float Gen_CurrentProgress;
volatile const char* Gen_CurrentState;
volatile bool Gen_Done;
int Gen_Width, Gen_Height, Gen_Length, Gen_Seed;
bool Gen_Vanilla;
BlockRaw* Gen_Blocks;
extern volatile float Gen_CurrentProgress;
extern volatile const char* Gen_CurrentState;
extern volatile bool Gen_Done;
extern int Gen_Width, Gen_Height, Gen_Length, Gen_Seed;
extern bool Gen_Vanilla;
extern BlockRaw* Gen_Blocks;
#define Gen_SetDimensions(x, y, z) Gen_Width = x; Gen_Height = y; Gen_Length = z;
void FlatgrassGen_Generate(void);
@ -33,9 +33,9 @@ void CombinedNoise_Init(struct CombinedNoise* n, RNGState* rnd, int octaves1, in
float CombinedNoise_Calc(struct CombinedNoise* n, float x, float y);
int Tree_Width, Tree_Height, Tree_Length;
BlockRaw* Tree_Blocks;
RNGState* Tree_Rnd;
extern int Tree_Width, Tree_Height, Tree_Length;
extern BlockRaw* Tree_Blocks;
extern RNGState* Tree_Rnd;
/* Appropriate buffer size to hold positions and blocks generated by the tree generator. */
#define TREE_MAX_COUNT 96

View File

@ -14,6 +14,11 @@
#include "Utils.h"
#include "World.h"
int MapRenderer_ChunksX, MapRenderer_ChunksY, MapRenderer_ChunksZ;
int MapRenderer_1DUsedCount, MapRenderer_ChunksCount;
struct ChunkPartInfo* MapRenderer_PartsNormal;
struct ChunkPartInfo* MapRenderer_PartsTranslucent;
static bool inTranslucent;
static int elementsPerBitmap;
static Vector3I chunkPos;

View File

@ -10,19 +10,19 @@
struct IGameComponent;
extern struct IGameComponent MapRenderer_Component;
int MapRenderer_ChunksX, MapRenderer_ChunksY, MapRenderer_ChunksZ;
extern int MapRenderer_ChunksX, MapRenderer_ChunksY, MapRenderer_ChunksZ;
#define MapRenderer_Pack(cx, cy, cz) (((cz) * MapRenderer_ChunksY + (cy)) * MapRenderer_ChunksX + (cx))
/* TODO: Swap Y and Z? Make sure to update ChunkUpdater's ResetChunkCache and ClearChunkCache methods! */
/* Count of actual used 1D atlases. (i.e. 1DIndex(maxTextureLoc) + 1 */
int MapRenderer_1DUsedCount;
extern int MapRenderer_1DUsedCount;
/* Number of chunks in the world, or ChunksX * ChunksY * ChunksZ */
int MapRenderer_ChunksCount;
extern int MapRenderer_ChunksCount;
/* Buffer for all chunk parts. There are (MapRenderer_ChunksCount * Atlas1D_Count) parts in the buffer,
with parts for 'normal' buffer being in lower half. */
struct ChunkPartInfo* MapRenderer_PartsNormal; /* TODO: THAT DESC SUCKS */
struct ChunkPartInfo* MapRenderer_PartsTranslucent;
extern struct ChunkPartInfo* MapRenderer_PartsNormal; /* TODO: THAT DESC SUCKS */
extern struct ChunkPartInfo* MapRenderer_PartsTranslucent;
/* Describes a portion of the data needed for rendering a chunk. */
struct ChunkPartInfo {

View File

@ -13,6 +13,15 @@
#include "Stream.h"
#include "Funcs.h"
PackedCol Model_Cols[FACE_COUNT];
float Model_uScale, Model_vScale;
float Model_cosHead, Model_sinHead;
uint8_t Model_Rotation, Model_skinType;
struct Model* Model_ActiveModel;
GfxResourceID Model_Vb;
VertexP3fT2fC4b Model_Vertices[MODEL_MAX_VERTICES];
struct Model* Human_ModelPtr;
#define UV_POS_MASK ((uint16_t)0x7FFF)
#define UV_MAX ((uint16_t)0x8000)

View File

@ -72,14 +72,14 @@ struct Model {
public CustomModel[] CustomModels = new CustomModel[256];
#endif
PackedCol Model_Cols[FACE_COUNT];
extern PackedCol Model_Cols[FACE_COUNT];
/* U/V scale applied to the skin when rendering the model. */
/* Default uScale is 1/32, vScale is 1/32 or 1/64 depending on skin. */
float Model_uScale, Model_vScale;
/* Angle of offset of head to body rotation */
float Model_cosHead, Model_sinHead;
uint8_t Model_Rotation, Model_skinType;
struct Model* Model_ActiveModel;
extern float Model_uScale, Model_vScale;
/* Angle of offset of head from body rotation */
extern float Model_cosHead, Model_sinHead;
extern uint8_t Model_Rotation, Model_skinType;
extern struct Model* Model_ActiveModel;
void Model_Init(struct Model* model);
#define Model_SetPointers(instance, typeName)\
@ -102,9 +102,9 @@ void Model_DrawArmPart(struct ModelPart* part);
/* Maximum number of vertices a model can have */
#define MODEL_MAX_VERTICES (24 * 12)
GfxResourceID Model_Vb;
VertexP3fT2fC4b Model_Vertices[MODEL_MAX_VERTICES];
struct Model* Human_ModelPtr;
extern GfxResourceID Model_Vb;
extern VertexP3fT2fC4b Model_Vertices[MODEL_MAX_VERTICES];
extern struct Model* Human_ModelPtr;
void Models_Init(void);
void Models_Free(void);

View File

@ -9,6 +9,8 @@
const char* FpsLimit_Names[FPS_LIMIT_COUNT] = {
"LimitVSync", "Limit30FPS", "Limit60FPS", "Limit120FPS", "LimitNone",
};
StringsBuffer Options_Keys;
StringsBuffer Options_Values;
static StringsBuffer Options_Changed;
bool Options_HasAnyChanged(void) { return Options_Changed.Count > 0; }

View File

@ -70,8 +70,8 @@ extern const char* FpsLimit_Names[FPS_LIMIT_COUNT];
#define OPT_CLASSIC_ARM_MODEL "nostalgia-classicarm"
#define OPT_MAX_CHUNK_UPDATES "gfx-maxchunkupdates"
StringsBuffer Options_Keys;
StringsBuffer Options_Values;
extern StringsBuffer Options_Keys;
extern StringsBuffer Options_Values;
/* Returns whether user has changed any options this session. */
CC_NOINLINE bool Options_HasAnyChanged(void);

View File

@ -48,6 +48,7 @@ static BlockRaw* map2_blocks;
#endif
/* CPE state */
bool cpe_needD3Fix;
static int cpe_serverExtensionsCount, cpe_pingTicks;
static int cpe_envMapVer = 2, cpe_blockDefsExtVer = 2;
static bool cpe_sendHeldBlock, cpe_useMessageTypes, cpe_extEntityPos, cpe_blockPerms, cpe_fastMap;

View File

@ -13,7 +13,7 @@ void Handlers_RemoveEntity(EntityID id);
void Handlers_Reset(void);
void Handlers_Tick(void);
bool cpe_needD3Fix;
extern bool cpe_needD3Fix;
void Classic_WriteChat(const String* text, bool partial);
void Classic_WritePosition(Vector3 pos, float rotY, float headX);
void Classic_WriteSetBlock(int x, int y, int z, bool place, BlockID block);

View File

@ -19,7 +19,6 @@ struct Particle {
/* http://www.opengl-tutorial.org/intermediate-tutorials/billboards-particles/billboards/ */
void Particle_DoRender(Vector2* size, Vector3* pos, TextureRec* rec, PackedCol col, VertexP3fT2fC4b* vertices);
void Particles_MakeComponent(struct IGameComponent* comp);
void Particles_Render(double delta, float t);
void Particles_Tick(struct ScheduledTask* task);
void Particles_BreakBlockEffect(Vector3I coords, BlockID oldBlock, BlockID block);

View File

@ -44,12 +44,12 @@ char* Platform_NewLine = "\r\n";
char Directory_Separator = '\\';
char* Font_DefaultName = "Arial";
ReturnCode ReturnCode_FileShareViolation = ERROR_SHARING_VIOLATION;
ReturnCode ReturnCode_FileNotFound = ERROR_FILE_NOT_FOUND;
ReturnCode ReturnCode_NotSupported = ERROR_NOT_SUPPORTED;
ReturnCode ReturnCode_InvalidArg = ERROR_INVALID_PARAMETER;
ReturnCode ReturnCode_SocketInProgess = WSAEINPROGRESS;
ReturnCode ReturnCode_SocketWouldBlock = WSAEWOULDBLOCK;
const ReturnCode ReturnCode_FileShareViolation = ERROR_SHARING_VIOLATION;
const ReturnCode ReturnCode_FileNotFound = ERROR_FILE_NOT_FOUND;
const ReturnCode ReturnCode_NotSupported = ERROR_NOT_SUPPORTED;
const ReturnCode ReturnCode_InvalidArg = ERROR_INVALID_PARAMETER;
const ReturnCode ReturnCode_SocketInProgess = WSAEINPROGRESS;
const ReturnCode ReturnCode_SocketWouldBlock = WSAEWOULDBLOCK;
#endif
/* POSIX is mainly shared between Linux and OSX */
#ifdef CC_BUILD_POSIX
@ -77,12 +77,12 @@ char* Platform_NewLine = "\n";
char Directory_Separator = '/'; /* TODO: Is this right for old OSX though?? */
pthread_mutex_t event_mutex;
ReturnCode ReturnCode_FileShareViolation = 1000000000; /* TODO: not used apparently */
ReturnCode ReturnCode_FileNotFound = ENOENT;
ReturnCode ReturnCode_NotSupported = EPERM;
ReturnCode ReturnCode_InvalidArg = EINVAL;
ReturnCode ReturnCode_SocketInProgess = EINPROGRESS;
ReturnCode ReturnCode_SocketWouldBlock = EWOULDBLOCK;
const ReturnCode ReturnCode_FileShareViolation = 1000000000; /* TODO: not used apparently */
const ReturnCode ReturnCode_FileNotFound = ENOENT;
const ReturnCode ReturnCode_NotSupported = EPERM;
const ReturnCode ReturnCode_InvalidArg = EINVAL;
const ReturnCode ReturnCode_SocketInProgess = EINPROGRESS;
const ReturnCode ReturnCode_SocketWouldBlock = EWOULDBLOCK;
#endif
#ifdef CC_BUILD_NIX
#include <X11/Xlib.h>

View File

@ -27,12 +27,12 @@ extern char* Platform_NewLine;
extern char Directory_Separator;
/* Name of default system font used. (e.g. Arial) */
extern char* Font_DefaultName;
extern ReturnCode ReturnCode_FileShareViolation;
extern ReturnCode ReturnCode_FileNotFound;
extern ReturnCode ReturnCode_NotSupported;
extern ReturnCode ReturnCode_SocketInProgess;
extern ReturnCode ReturnCode_SocketWouldBlock;
extern ReturnCode ReturnCode_InvalidArg;
extern const ReturnCode ReturnCode_FileShareViolation;
extern const ReturnCode ReturnCode_FileNotFound;
extern const ReturnCode ReturnCode_NotSupported;
extern const ReturnCode ReturnCode_SocketInProgess;
extern const ReturnCode ReturnCode_SocketWouldBlock;
extern const ReturnCode ReturnCode_InvalidArg;
/* Data for a display device. (usually a monitor) */
struct DisplayDevice { int BitsPerPixel; Rect2D Bounds; };

View File

@ -23,18 +23,29 @@
#include "Platform.h"
#include "GameStructs.h"
/*########################################################################################################################*
*-----------------------------------------------------Common handlers-----------------------------------------------------*
*#########################################################################################################################*/
static char server_nameBuffer[STRING_SIZE];
static char server_motdBuffer[STRING_SIZE];
static char server_appBuffer[STRING_SIZE];
static int server_ticks;
bool ServerConnection_IsSinglePlayer, ServerConnection_Disconnected;
String ServerConnection_ServerName = String_FromArray(server_nameBuffer);
String ServerConnection_ServerMOTD = String_FromArray(server_motdBuffer);
String ServerConnection_AppName = String_FromArray(server_appBuffer);
void (*ServerConnection_BeginConnect)(void);
void (*ServerConnection_SendChat)(const String* text);
void (*ServerConnection_SendPosition)(Vector3 pos, float rotY, float headX);
void (*ServerConnection_SendPlayerClick)(MouseButton button, bool isDown, EntityID targetId, struct PickedPos* pos);
void (*ServerConnection_Tick)(struct ScheduledTask* task);
uint8_t* ServerConnection_WriteBuffer;
bool ServerConnection_SupportsExtPlayerList, ServerConnection_SupportsPlayerClick;
bool ServerConnection_SupportsPartialMessages, ServerConnection_SupportsFullCP437;
/*########################################################################################################################*
*-----------------------------------------------------Common handlers-----------------------------------------------------*
*#########################################################################################################################*/
static void ServerConnection_ResetState(void) {
ServerConnection_Disconnected = false;
ServerConnection_SupportsExtPlayerList = false;
@ -241,6 +252,9 @@ static void SPConnection_Init(void) {
/*########################################################################################################################*
*--------------------------------------------------Multiplayer connection-------------------------------------------------*
*#########################################################################################################################*/
uint16_t Net_PacketSizes[OPCODE_COUNT];
Net_Handler Net_Handlers[OPCODE_COUNT];
static SocketHandle net_socket;
static uint8_t net_readBuffer[4096 * 5];
static uint8_t net_writeBuffer[131];

View File

@ -46,30 +46,30 @@ int PingList_NextPingData(void);
void PingList_Update(int data);
int PingList_AveragePingMs(void);
bool ServerConnection_IsSinglePlayer;
bool ServerConnection_Disconnected;
extern bool ServerConnection_IsSinglePlayer;
extern bool ServerConnection_Disconnected;
extern String ServerConnection_ServerName;
extern String ServerConnection_ServerMOTD;
extern String ServerConnection_AppName;
void (*ServerConnection_BeginConnect)(void);
void (*ServerConnection_SendChat)(const String* text);
void (*ServerConnection_SendPosition)(Vector3 pos, float rotY, float headX);
void (*ServerConnection_SendPlayerClick)(MouseButton button, bool isDown, EntityID targetId, struct PickedPos* pos);
void (*ServerConnection_Tick)(struct ScheduledTask* task);
uint8_t* ServerConnection_WriteBuffer;
extern void (*ServerConnection_BeginConnect)(void);
extern void (*ServerConnection_SendChat)(const String* text);
extern void (*ServerConnection_SendPosition)(Vector3 pos, float rotY, float headX);
extern void (*ServerConnection_SendPlayerClick)(MouseButton button, bool isDown, EntityID targetId, struct PickedPos* pos);
extern void (*ServerConnection_Tick)(struct ScheduledTask* task);
extern uint8_t* ServerConnection_WriteBuffer;
bool ServerConnection_SupportsExtPlayerList;
bool ServerConnection_SupportsPlayerClick;
bool ServerConnection_SupportsPartialMessages;
bool ServerConnection_SupportsFullCP437;
extern bool ServerConnection_SupportsExtPlayerList;
extern bool ServerConnection_SupportsPlayerClick;
extern bool ServerConnection_SupportsPartialMessages;
extern bool ServerConnection_SupportsFullCP437;
void ServerConnection_RetrieveTexturePack(const String* url);
void ServerConnection_DownloadTexturePack(const String* url);
typedef void (*Net_Handler)(uint8_t* data);
uint16_t Net_PacketSizes[OPCODE_COUNT];
Net_Handler Net_Handlers[OPCODE_COUNT];
extern uint16_t Net_PacketSizes[OPCODE_COUNT];
extern Net_Handler Net_Handlers[OPCODE_COUNT];
void Net_Set(uint8_t opcode, Net_Handler handler, int size);
void Net_SendPacket(void);
#endif

View File

@ -5,6 +5,8 @@
#include "Stream.h"
#include "Utils.h"
const String String_Empty;
String String_Init(STRING_REF char* buffer, int length, int capacity) {
String s;
s.buffer = buffer; s.length = length; s.capacity = capacity;

View File

@ -25,7 +25,7 @@ typedef struct String_ {
int String_CalcLen(const char* raw, int capacity);
/* Constant string that points to NULL and has 0 length. */
/* NOTE: Do NOT modify the contents of this string! */
const String String_Empty;
extern const String String_Empty;
/* Constructs a string from the given arguments. */
String String_Init(STRING_REF char* buffer, int length, int capacity);
/* Constructs a string from the given arguments, then sets all characters to '\0'. */

View File

@ -5,6 +5,13 @@
#include "Graphics.h"
#include "Platform.h"
Bitmap Atlas2D_Bitmap;
int Atlas2D_TileSize, Atlas2D_RowsCount;
int Atlas1D_Count, Atlas1D_TilesPerAtlas;
int Atlas1D_Mask, Atlas1D_Shift;
float Atlas1D_InvTileSize;
GfxResourceID Atlas1D_TexIds[ATLAS1D_MAX_ATLASES];
void Atlas2D_UpdateState(Bitmap* bmp) {
Atlas2D_Bitmap = *bmp;
Atlas2D_TileSize = bmp->Width / ATLAS2D_TILES_PER_ROW;

View File

@ -15,12 +15,12 @@
#endif
#define ATLAS1D_MAX_ATLASES (ATLAS2D_TILES_PER_ROW * ATLAS2D_MAX_ROWS_COUNT)
Bitmap Atlas2D_Bitmap;
int Atlas2D_TileSize, Atlas2D_RowsCount;
int Atlas1D_Count, Atlas1D_TilesPerAtlas;
int Atlas1D_Mask, Atlas1D_Shift;
float Atlas1D_InvTileSize;
GfxResourceID Atlas1D_TexIds[ATLAS1D_MAX_ATLASES];
extern Bitmap Atlas2D_Bitmap;
extern int Atlas2D_TileSize, Atlas2D_RowsCount;
extern int Atlas1D_Count, Atlas1D_TilesPerAtlas;
extern int Atlas1D_Mask, Atlas1D_Shift;
extern float Atlas1D_InvTileSize;
extern GfxResourceID Atlas1D_TexIds[ATLAS1D_MAX_ATLASES];
#define Atlas2D_TileX(texLoc) ((texLoc) & ATLAS2D_MASK) /* texLoc % ATLAS2D_TILES_PER_ROW */
#define Atlas2D_TileY(texLoc) ((texLoc) >> ATLAS2D_SHIFT) /* texLoc / ATLAS2D_TILES_PER_ROW */

View File

@ -173,7 +173,7 @@ uint32_t Utils_CRC32(const uint8_t* data, uint32_t length) {
return crc ^ 0xffffffffUL;
}
uint32_t Utils_Crc32Table[256] = {
const uint32_t Utils_Crc32Table[256] = {
0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3, 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91,
0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE, 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7, 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, 0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5,
0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172, 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B, 0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940, 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59,

View File

@ -37,7 +37,7 @@ int Utils_AccumulateWheelDelta(float* accumulator, float delta);
uint8_t Utils_GetSkinType(const Bitmap* bmp);
uint32_t Utils_CRC32(const uint8_t* data, uint32_t length);
extern uint32_t Utils_Crc32Table[256];
extern const uint32_t Utils_Crc32Table[256];
CC_NOINLINE void* Utils_Resize(void* buffer, uint32_t* maxElems, uint32_t elemSize, uint32_t defElems, uint32_t expandElems);
CC_NOINLINE bool Utils_ParseIP(const String* ip, uint8_t* data);
#endif

View File

@ -5,6 +5,10 @@
#include "ErrorHandler.h"
#include "Funcs.h"
bool Window_Exists, Window_Focused;
Rect2D Window_Bounds;
Size2D Window_ClientSize;
static bool win_cursorVisible = true;
bool Window_GetCursorVisible(void) { return win_cursorVisible; }

View File

@ -49,9 +49,9 @@ void Window_SetClipboardText(const String* value);
/* TODO: IMPLEMENT void Window_SetIcon(Bitmap* bmp); */
/* Whether the window is actually valid (i.e. not destroyed). */
bool Window_Exists;
extern bool Window_Exists;
/* Whether the user is interacting with the window. */
bool Window_Focused;
extern bool Window_Focused;
/* Whether the window is visible on screen at all. */
/* NOTE: This does not count when just hidden behind other windows. */
bool Window_GetVisible(void);
@ -66,10 +66,10 @@ void Window_SetWindowState(int state);
/* The external bounds of the window in screen coordinates. */
/* Size of external bounds is client size + borders + title */
Rect2D Window_Bounds;
extern Rect2D Window_Bounds;
/* Size of the internal bounds of the window. */
/* This is the size of area that can be drawn on. (i.e. content size) */
Size2D Window_ClientSize;
extern Size2D Window_ClientSize;
/* Sets the position and external size of the window. */
void Window_SetBounds(Rect2D rect);
/* Sets the position of the window on the screen. */

View File

@ -9,6 +9,17 @@
#include "Physics.h"
#include "Game.h"
BlockRaw* World_Blocks;
#ifdef EXTENDED_BLOCKS
BlockRaw* World_Blocks2;
#endif
int World_BlocksSize;
int World_Width, World_Height, World_Length;
int World_MaxX, World_MaxY, World_MaxZ;
int World_OneY;
uint8_t World_Uuid[16];
/*########################################################################################################################*
*----------------------------------------------------------World----------------------------------------------------------*
*#########################################################################################################################*/
@ -132,6 +143,17 @@ PackedCol Env_DefaultFogCol = PACKEDCOL_CONST(0xFF, 0xFF, 0xFF, 0xFF);
PackedCol Env_DefaultCloudsCol = PACKEDCOL_CONST(0xFF, 0xFF, 0xFF, 0xFF);
PackedCol Env_DefaultSunCol = PACKEDCOL_CONST(0xFF, 0xFF, 0xFF, 0xFF);
PackedCol Env_DefaultShadowCol = PACKEDCOL_CONST(0x9B, 0x9B, 0x9B, 0xFF);
BlockID Env_EdgeBlock, Env_SidesBlock;
int Env_EdgeHeight, Env_SidesOffset, Env_CloudsHeight;
float Env_CloudsSpeed, Env_WeatherSpeed, Env_WeatherFade;
int Env_Weather; bool Env_ExpFog;
float Env_SkyboxHorSpeed, Env_SkyboxVerSpeed;
PackedCol Env_SkyCol, Env_FogCol, Env_CloudsCol;
PackedCol Env_SunCol, Env_SunXSide, Env_SunZSide, Env_SunYMin;
PackedCol Env_ShadowCol, Env_ShadowXSide, Env_ShadowZSide, Env_ShadowYMin;
static char World_TextureUrlBuffer[STRING_SIZE];
String World_TextureUrl = String_FromArray(World_TextureUrlBuffer);

View File

@ -11,16 +11,16 @@ struct AABB;
#define World_Unpack(idx, x, y, z) x = idx % World_Width; z = (idx / World_Width) % World_Length; y = (idx / World_Width) / World_Length;
#define World_Pack(x, y, z) (((y) * World_Length + (z)) * World_Width + (x))
BlockRaw* World_Blocks;
extern BlockRaw* World_Blocks;
#ifdef EXTENDED_BLOCKS
BlockRaw* World_Blocks2;
extern BlockRaw* World_Blocks2;
#endif
int World_BlocksSize;
extern int World_BlocksSize;
int World_Width, World_Height, World_Length;
int World_MaxX, World_MaxY, World_MaxZ;
int World_OneY;
uint8_t World_Uuid[16];
extern int World_Width, World_Height, World_Length;
extern int World_MaxX, World_MaxY, World_MaxZ;
extern int World_OneY;
extern uint8_t World_Uuid[16];
extern String World_TextureUrl;
/* Frees the blocks array, sets dimensions to 0, resets environment to default. */
@ -53,25 +53,25 @@ enum EnvVar_ {
ENV_VAR_SKY_COL, ENV_VAR_CLOUDS_COL, ENV_VAR_FOG_COL, ENV_VAR_SUN_COL, ENV_VAR_SHADOW_COL
};
BlockID Env_EdgeBlock, Env_SidesBlock;
int Env_EdgeHeight;
int Env_SidesOffset;
extern BlockID Env_EdgeBlock, Env_SidesBlock;
extern int Env_EdgeHeight;
extern int Env_SidesOffset;
#define Env_SidesHeight (Env_EdgeHeight + Env_SidesOffset)
int Env_CloudsHeight;
float Env_CloudsSpeed;
extern int Env_CloudsHeight;
extern float Env_CloudsSpeed;
enum Weather_ { WEATHER_SUNNY, WEATHER_RAINY, WEATHER_SNOWY };
extern const char* Weather_Names[3];
float Env_WeatherSpeed;
float Env_WeatherFade;
int Env_Weather;
bool Env_ExpFog;
float Env_SkyboxHorSpeed, Env_SkyboxVerSpeed;
extern float Env_WeatherSpeed;
extern float Env_WeatherFade;
extern int Env_Weather;
extern bool Env_ExpFog;
extern float Env_SkyboxHorSpeed, Env_SkyboxVerSpeed;
PackedCol Env_SkyCol, Env_FogCol, Env_CloudsCol;
extern PackedCol Env_SkyCol, Env_FogCol, Env_CloudsCol;
extern PackedCol Env_DefaultSkyCol, Env_DefaultFogCol, Env_DefaultCloudsCol;
PackedCol Env_SunCol, Env_SunXSide, Env_SunZSide, Env_SunYMin;
PackedCol Env_ShadowCol, Env_ShadowXSide, Env_ShadowZSide, Env_ShadowYMin;
extern PackedCol Env_SunCol, Env_SunXSide, Env_SunZSide, Env_SunYMin;
extern PackedCol Env_ShadowCol, Env_ShadowXSide, Env_ShadowZSide, Env_ShadowYMin;
extern PackedCol Env_DefaultSunCol, Env_DefaultShadowCol;
#define ENV_DEFAULT_SKYCOL_HEX "99CCFF"