Combine GameStructs.h into Game.h

Also breaks all plugin source code, sorry about that
This commit is contained in:
UnknownShadow200 2020-06-13 11:13:41 +10:00
parent 6f05953799
commit 9d68364781
26 changed files with 39 additions and 67 deletions

View File

@ -36,7 +36,7 @@ Here's the idea for a basic plugin that shows "Hello world" in chat when the gam
### Basic plugin boilerplate ### Basic plugin boilerplate
```C ```C
#include "src/Chat.h" #include "src/Chat.h"
#include "src/GameStructs.h" #include "src/Game.h"
#ifdef CC_BUILD_WIN #ifdef CC_BUILD_WIN
#define CC_API __declspec(dllimport) #define CC_API __declspec(dllimport)
@ -66,7 +66,7 @@ When writing plugins with C++, game headers must be surroundined with `extern "C
```C ```C
extern "C" { extern "C" {
#include "src/Chat.h" #include "src/Chat.h"
#include "src/GameStructs.h" #include "src/Game.h"
} }
``` ```
Otherwise you will get obscure `Undefined reference` errors when compiling. Otherwise you will get obscure `Undefined reference` errors when compiling.

View File

@ -5,7 +5,6 @@
#include "ExtMath.h" #include "ExtMath.h"
#include "Funcs.h" #include "Funcs.h"
#include "Game.h" #include "Game.h"
#include "GameStructs.h"
#include "Errors.h" #include "Errors.h"
#include "Vorbis.h" #include "Vorbis.h"
#include "Chat.h" #include "Chat.h"

View File

@ -6,7 +6,6 @@
#include "Camera.h" #include "Camera.h"
#include "Event.h" #include "Event.h"
#include "Entity.h" #include "Entity.h"
#include "GameStructs.h"
cc_bool AxisLinesRenderer_Enabled; cc_bool AxisLinesRenderer_Enabled;
static GfxResourceID axisLines_vb; static GfxResourceID axisLines_vb;

View File

@ -7,7 +7,6 @@
#include "Inventory.h" #include "Inventory.h"
#include "Event.h" #include "Event.h"
#include "Platform.h" #include "Platform.h"
#include "GameStructs.h"
struct _BlockLists Blocks; struct _BlockLists Blocks;

View File

@ -14,7 +14,6 @@
#include "TexturePack.h" #include "TexturePack.h"
#include "Game.h" #include "Game.h"
#include "Options.h" #include "Options.h"
#include "GameStructs.h"
int Builder_SidesLevel, Builder_EdgeLevel; int Builder_SidesLevel, Builder_EdgeLevel;
/* Packs an index into the 16x16x16 count array. Coordinates range from 0 to 15. */ /* Packs an index into the 16x16x16 count array. Coordinates range from 0 to 15. */

View File

@ -13,7 +13,6 @@
#include "Funcs.h" #include "Funcs.h"
#include "Block.h" #include "Block.h"
#include "EnvRenderer.h" #include "EnvRenderer.h"
#include "GameStructs.h"
#include "Utils.h" #include "Utils.h"
#include "TexturePack.h" #include "TexturePack.h"
#include "Options.h" #include "Options.h"

View File

@ -12,7 +12,6 @@
#include "Errors.h" #include "Errors.h"
#include "Window.h" #include "Window.h"
#include "Options.h" #include "Options.h"
#include "GameStructs.h"
cc_bool Drawer2D_BitmappedText; cc_bool Drawer2D_BitmappedText;
cc_bool Drawer2D_BlackTextShadows; cc_bool Drawer2D_BlackTextShadows;

View File

@ -21,7 +21,6 @@
#include "Logger.h" #include "Logger.h"
#include "Options.h" #include "Options.h"
#include "Errors.h" #include "Errors.h"
#include "GameStructs.h"
const char* const NameMode_Names[NAME_MODE_COUNT] = { "None", "Hovered", "All", "AllHovered", "AllUnscaled" }; const char* const NameMode_Names[NAME_MODE_COUNT] = { "None", "Hovered", "All", "AllHovered", "AllUnscaled" };
const char* const ShadowMode_Names[SHADOW_MODE_COUNT] = { "None", "SnapToBlock", "Circle", "CircleAll" }; const char* const ShadowMode_Names[SHADOW_MODE_COUNT] = { "None", "SnapToBlock", "Circle", "CircleAll" };

View File

@ -17,7 +17,6 @@
#include "Camera.h" #include "Camera.h"
#include "Particle.h" #include "Particle.h"
#include "Options.h" #include "Options.h"
#include "GameStructs.h"
cc_bool EnvRenderer_Legacy, EnvRenderer_Minimal; cc_bool EnvRenderer_Legacy, EnvRenderer_Minimal;

View File

@ -33,7 +33,6 @@
#include "Audio.h" #include "Audio.h"
#include "Stream.h" #include "Stream.h"
#include "Builder.h" #include "Builder.h"
#include "GameStructs.h"
#include "Protocol.h" #include "Protocol.h"
struct _GameData Game; struct _GameData Game;

View File

@ -3,7 +3,7 @@
#include "Picking.h" #include "Picking.h"
#include "String.h" #include "String.h"
#include "Bitmap.h" #include "Bitmap.h"
/* Represents the game. /* Represents the game and related structures.
Copyright 2014-2019 ClassiCube | Licensed under BSD-3 Copyright 2014-2019 ClassiCube | Licensed under BSD-3
*/ */
@ -82,4 +82,38 @@ void Game_SetFpsLimit(int method);
/* Runs the main game loop until the window is closed. */ /* Runs the main game loop until the window is closed. */
void Game_Run(int width, int height, const String* title); void Game_Run(int width, int height, const String* title);
/* Represents a game component. */
struct IGameComponent;
struct IGameComponent {
/* Called when the game is being loaded. */
void(*Init)(void);
/* Called when the component is being freed. (e.g. due to game being closed) */
void(*Free)(void);
/* Called to reset the component's state. (e.g. reconnecting to server) */
void(*Reset)(void);
/* Called to update the component's state when the user begins loading a new map. */
void(*OnNewMap)(void);
/* Called to update the component's state when the user has finished loading a new map. */
void(*OnNewMapLoaded)(void);
/* Next component in linked list of components. */
struct IGameComponent* next;
};
/* Adds a component to linked list of components. (always at end) */
CC_NOINLINE void Game_AddComponent(struct IGameComponent* comp);
/* Represents a task that periodically runs on the main thread every specified interval. */
struct ScheduledTask;
struct ScheduledTask {
/* How long (in seconds) has elapsed since callback was last invoked */
double Accumulator;
/* How long (in seconds) between invocations of the callback */
double Interval;
/* Callback function that is periodically invoked */
void (*Callback)(struct ScheduledTask* task);
};
typedef void (*ScheduledTaskCallback)(struct ScheduledTask* task);
/* Adds a component to list of scheduled tasks. (always at end) */
CC_NOINLINE int ScheduledTask_Add(double interval, ScheduledTaskCallback callback);
#endif #endif

View File

@ -1,41 +0,0 @@
#ifndef CC_GAMESTRUCTS_H
#define CC_GAMESTRUCTS_H
#include "Core.h"
/* Represents Game related structures.
Copyright 2014-2019 ClassiCube | Licensed under BSD-3
*/
struct IGameComponent;
/* Represents a game component. */
struct IGameComponent {
/* Called when the game is being loaded. */
void (*Init)(void);
/* Called when the component is being freed. (e.g. due to game being closed) */
void (*Free)(void);
/* Called to reset the component's state. (e.g. reconnecting to server) */
void (*Reset)(void);
/* Called to update the component's state when the user begins loading a new map. */
void (*OnNewMap)(void);
/* Called to update the component's state when the user has finished loading a new map. */
void (*OnNewMapLoaded)(void);
/* Next component in linked list of components. */
struct IGameComponent* next;
};
/* Adds a component to linked list of components. (always at end) */
CC_NOINLINE void Game_AddComponent(struct IGameComponent* comp);
/* Represents a task that periodically runs on the main thread every specified interval. */
struct ScheduledTask;
struct ScheduledTask {
/* How long (in seconds) has elapsed since callback was last invoked */
double Accumulator;
/* How long (in seconds) between invocations of the callback */
double Interval;
/* Callback function that is periodically invoked */
void (*Callback)(struct ScheduledTask* task);
};
typedef void (*ScheduledTaskCallback)(struct ScheduledTask* task);
/* Adds a component to list of scheduled tasks. (always at end) */
CC_NOINLINE int ScheduledTask_Add(double interval, ScheduledTaskCallback callback);
#endif

View File

@ -12,7 +12,6 @@
#include "Platform.h" #include "Platform.h"
#include "Bitmap.h" #include "Bitmap.h"
#include "Options.h" #include "Options.h"
#include "GameStructs.h"
#include "Funcs.h" #include "Funcs.h"
cc_bool Gui_ClassicTexture, Gui_ClassicTabList, Gui_ClassicMenu, Gui_ClassicChat; cc_bool Gui_ClassicTexture, Gui_ClassicTabList, Gui_ClassicMenu, Gui_ClassicChat;

View File

@ -8,7 +8,6 @@
#include "Event.h" #include "Event.h"
#include "Entity.h" #include "Entity.h"
#include "Model.h" #include "Model.h"
#include "GameStructs.h"
#include "Options.h" #include "Options.h"
cc_bool HeldBlockRenderer_Show; cc_bool HeldBlockRenderer_Show;

View File

@ -3,7 +3,7 @@
#include "Funcs.h" #include "Funcs.h"
#include "Logger.h" #include "Logger.h"
#include "Stream.h" #include "Stream.h"
#include "GameStructs.h" #include "Game.h"
void HttpRequest_Free(struct HttpRequest* request) { void HttpRequest_Free(struct HttpRequest* request) {
Mem_Free(request->data); Mem_Free(request->data);

View File

@ -4,7 +4,6 @@
#include "Block.h" #include "Block.h"
#include "Event.h" #include "Event.h"
#include "Chat.h" #include "Chat.h"
#include "GameStructs.h"
struct _InventoryData Inventory; struct _InventoryData Inventory;

View File

@ -9,7 +9,6 @@
#include "Utils.h" #include "Utils.h"
#include "Input.h" #include "Input.h"
#include "Window.h" #include "Window.h"
#include "GameStructs.h"
#include "Event.h" #include "Event.h"
#include "Http.h" #include "Http.h"
#include "ExtMath.h" #include "ExtMath.h"

View File

@ -6,7 +6,7 @@
#include "World.h" #include "World.h"
#include "Logger.h" #include "Logger.h"
#include "Event.h" #include "Event.h"
#include "GameStructs.h" #include "Game.h"
cc_int16* Lighting_Heightmap; cc_int16* Lighting_Heightmap;
#define HEIGHT_UNCALCULATED Int16_MaxValue #define HEIGHT_UNCALCULATED Int16_MaxValue

View File

@ -14,7 +14,6 @@
#include "Utils.h" #include "Utils.h"
#include "World.h" #include "World.h"
#include "Options.h" #include "Options.h"
#include "GameStructs.h"
int MapRenderer_ChunksX, MapRenderer_ChunksY, MapRenderer_ChunksZ; int MapRenderer_ChunksX, MapRenderer_ChunksY, MapRenderer_ChunksZ;
int MapRenderer_1DUsedCount, MapRenderer_ChunksCount; int MapRenderer_1DUsedCount, MapRenderer_ChunksCount;

View File

@ -13,7 +13,6 @@
#include "Stream.h" #include "Stream.h"
#include "Funcs.h" #include "Funcs.h"
#include "Options.h" #include "Options.h"
#include "GameStructs.h"
struct _ModelsData Models; struct _ModelsData Models;

View File

@ -9,7 +9,6 @@
#include "Funcs.h" #include "Funcs.h"
#include "Game.h" #include "Game.h"
#include "Event.h" #include "Event.h"
#include "GameStructs.h"
/*########################################################################################################################* /*########################################################################################################################*

View File

@ -6,7 +6,6 @@
#include "Picking.h" #include "Picking.h"
#include "Funcs.h" #include "Funcs.h"
#include "Camera.h" #include "Camera.h"
#include "GameStructs.h"
static GfxResourceID pickedPos_vb; static GfxResourceID pickedPos_vb;
#define PICKEDPOS_NUM_VERTICES (16 * 6) #define PICKEDPOS_NUM_VERTICES (16 * 6)

View File

@ -25,7 +25,6 @@
#include "Camera.h" #include "Camera.h"
#include "Window.h" #include "Window.h"
#include "Particle.h" #include "Particle.h"
#include "GameStructs.h"
cc_uint16 Net_PacketSizes[OPCODE_COUNT]; cc_uint16 Net_PacketSizes[OPCODE_COUNT];
Net_Handler Net_Handlers[OPCODE_COUNT]; Net_Handler Net_Handlers[OPCODE_COUNT];

View File

@ -5,7 +5,6 @@
#include "Funcs.h" #include "Funcs.h"
#include "Game.h" #include "Game.h"
#include "Camera.h" #include "Camera.h"
#include "GameStructs.h"
/* Data for a selection box. */ /* Data for a selection box. */
struct SelectionBox { struct SelectionBox {

View File

@ -21,7 +21,6 @@
#include "Protocol.h" #include "Protocol.h"
#include "Inventory.h" #include "Inventory.h"
#include "Platform.h" #include "Platform.h"
#include "GameStructs.h"
static char nameBuffer[STRING_SIZE]; static char nameBuffer[STRING_SIZE];
static char motdBuffer[STRING_SIZE]; static char motdBuffer[STRING_SIZE];

View File

@ -17,7 +17,6 @@
#include "Chat.h" #include "Chat.h"
#include "Options.h" #include "Options.h"
#include "Logger.h" #include "Logger.h"
#include "GameStructs.h"
#define LIQUID_ANIM_MAX 64 #define LIQUID_ANIM_MAX 64
#define WATER_TEX_LOC 14 #define WATER_TEX_LOC 14