minor code cleanup

This commit is contained in:
UnknownShadow200 2018-11-10 12:59:46 +11:00
parent caddf623b7
commit ad4c4b7c6d
31 changed files with 324 additions and 287 deletions

View file

@ -203,7 +203,7 @@ static struct Soundboard digBoard, stepBoard;
static struct SoundOutput monoOutputs[AUDIO_MAX_HANDLES] = { SOUND_INV, SOUND_INV, SOUND_INV, SOUND_INV, SOUND_INV, SOUND_INV };
static struct SoundOutput stereoOutputs[AUDIO_MAX_HANDLES] = { SOUND_INV, SOUND_INV, SOUND_INV, SOUND_INV, SOUND_INV, SOUND_INV };
NOINLINE_ static void Sounds_Fail(ReturnCode res) {
CC_NOINLINE static void Sounds_Fail(ReturnCode res) {
Chat_LogError(res, "playing sounds");
Chat_AddRaw("&cDisabling sounds");
Audio_SetSounds(0);

View file

@ -224,7 +224,7 @@ static bool Commands_IsCommandPrefix(const String* str) {
|| String_CaselessEquals(str, &prefix);
}
NOINLINE_ static void Commands_Register(struct ChatCommand* cmd) {
CC_NOINLINE static void Commands_Register(struct ChatCommand* cmd) {
if (commands_count == Array_Elems(commands_list)) {
ErrorHandler_Fail("Commands_Register - hit max client commands");
}

View file

@ -34,8 +34,8 @@ void Chat_Add(const String* text);
void Chat_AddOf(const String* text, MsgType type);
void Chat_AddRaw(const char* raw);
NOINLINE_ void Chat_LogError(ReturnCode result, const char* place);
NOINLINE_ void Chat_LogError2(ReturnCode result, const char* place, const String* path);
CC_NOINLINE void Chat_LogError(ReturnCode result, const char* place);
CC_NOINLINE void Chat_LogError2(ReturnCode result, const char* place, const String* path);
void Chat_Add1(const char* format, const void* a1);
void Chat_Add2(const char* format, const void* a1, const void* a2);
void Chat_Add3(const char* format, const void* a1, const void* a2, const void* a3);

View file

@ -19,17 +19,17 @@ typedef signed __int8 int8_t;
typedef signed __int16 int16_t;
typedef signed __int32 int32_t;
typedef signed __int64 int64_t;
#define NOINLINE_ __declspec(noinline)
#define ALIGN_HINT_(x) /* TODO: Why does this cause LNK2005 errors */
#define EXPORT_ __declspec(dllexport, noinline)
#define CC_NOINLINE __declspec(noinline)
#define CC_ALIGN_HINT(x) /* TODO: Why does this cause LNK2005 errors */
#define CC_EXPORT __declspec(dllexport, noinline)
#elif __GNUC__
#include <stdint.h>
#define NOINLINE_ __attribute__((noinline))
#define ALIGN_HINT_(x) __attribute__((aligned(x)))
#define CC_NOINLINE __attribute__((noinline))
#define CC_ALIGN_HINT(x) __attribute__((aligned(x)))
#ifdef _WIN32
#define EXPORT_ __attribute__((dllexport, noinline))
#define CC_EXPORT __attribute__((dllexport, noinline))
#else
#define EXPORT_ __attribute__((visibility("default"), noinline))
#define CC_EXPORT __attribute__((visibility("default"), noinline))
#endif
#else
#error "I don't recognise this compiler. You'll need to add required definitions in Core.h!"

View file

@ -70,7 +70,7 @@ void Inflate_Process(struct InflateState* state);
/* Deompresses input data read from another stream using DEFLATE. Read only stream. */
/* NOTE: This only uncompresses pure DEFLATE compressed data. */
/* If the data starts with a GZIP or ZLIB header, use GZipHeader_Read or ZLibHeader_Read to skip it. */
EXPORT_ void Inflate_MakeStream(struct Stream* stream, struct InflateState* state, struct Stream* underlying);
CC_EXPORT void Inflate_MakeStream(struct Stream* stream, struct InflateState* state, struct Stream* underlying);
#define DEFLATE_BUFFER_SIZE 16384
@ -94,14 +94,14 @@ struct DeflateState {
};
/* Compresses input data using DEFLATE, then writes compressed output to another stream. Write only stream. */
/* DEFLATE compression is pure compressed data, there is no header or footer. */
EXPORT_ void Deflate_MakeStream(struct Stream* stream, struct DeflateState* state, struct Stream* underlying);
CC_EXPORT void Deflate_MakeStream(struct Stream* stream, struct DeflateState* state, struct Stream* underlying);
struct GZipState { struct DeflateState Base; uint32_t Crc32, Size; };
/* Compresses input data using GZIP, then writes compressed output to another stream. Write only stream. */
/* GZIP compression is GZIP header, followed by DEFLATE compressed data, followed by GZIP footer. */
EXPORT_ void GZip_MakeStream(struct Stream* stream, struct GZipState* state, struct Stream* underlying);
CC_EXPORT void GZip_MakeStream(struct Stream* stream, struct GZipState* state, struct Stream* underlying);
struct ZLibState { struct DeflateState Base; uint32_t Adler32; };
/* Compresses input data using ZLIB, then writes compressed output to another stream. Write only stream. */
/* ZLIB compression is ZLIB header, followed by DEFLATE compressed data, followed by ZLIB footer. */
EXPORT_ void ZLib_MakeStream(struct Stream* stream, struct ZLibState* state, struct Stream* underlying);
CC_EXPORT void ZLib_MakeStream(struct Stream* stream, struct ZLibState* state, struct Stream* underlying);
#endif

View file

@ -11,7 +11,7 @@ struct Texture;
void DrawTextArgs_Make(struct DrawTextArgs* args, STRING_REF const String* text, const FontDesc* font, bool useShadow);
void DrawTextArgs_MakeEmpty(struct DrawTextArgs* args, const FontDesc* font, bool useShadow);
NOINLINE_ void Drawer2D_MakeFont(FontDesc* desc, int size, int style);
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. */

View file

@ -9,7 +9,7 @@
void ErrorHandler_Init(void);
void ErrorHandler_Log(const String* msg);
void ErrorHandler_Fail(const char* raw_msg);
NOINLINE_ void ErrorHandler_Fail2(ReturnCode result, const char* raw_msg);
CC_NOINLINE void ErrorHandler_Fail2(ReturnCode result, const char* raw_msg);
#define ErrorHandler_CheckOrFail(result, raw_msg) if (result) { ErrorHandler_Fail2(result, raw_msg); }
NOINLINE_ void ErrorHandler_ShowDialog(const char* title, const char* msg);
CC_NOINLINE void ErrorHandler_ShowDialog(const char* title, const char* msg);
#endif

View file

@ -12,7 +12,14 @@
#include "Funcs.h"
#include "Errors.h"
#include "Stream.h"
#include "Chat.h"
#include "Inventory.h"
#include "TexturePack.h"
/*########################################################################################################################*
*--------------------------------------------------------General----------------------------------------------------------*
*#########################################################################################################################*/
static ReturnCode Map_ReadBlocks(struct Stream* stream) {
World_BlocksSize = World_Width * World_Length * World_Height;
World_Blocks = Mem_Alloc(World_BlocksSize, 1, "map blocks");
@ -33,7 +40,7 @@ static ReturnCode Map_SkipGZipHeader(struct Stream* stream) {
return 0;
}
NOINLINE_ IMapImporter Map_FindImporter(const String* path) {
IMapImporter Map_FindImporter(const String* path) {
static String cw = String_FromConst(".cw"), lvl = String_FromConst(".lvl");
static String fcm = String_FromConst(".fcm"), dat = String_FromConst(".dat");
@ -45,6 +52,43 @@ NOINLINE_ IMapImporter Map_FindImporter(const String* path) {
return NULL;
}
void Map_LoadFrom(const String* path) {
struct LocalPlayer* p = &LocalPlayer_Instance;
struct LocationUpdate update;
IMapImporter importer;
struct Stream stream;
ReturnCode res;
World_Reset();
Event_RaiseVoid(&WorldEvents_NewMap);
if (World_TextureUrl.length) {
TexturePack_ExtractDefault();
World_TextureUrl.length = 0;
}
Block_Reset();
Inventory_SetDefaultMapping();
res = Stream_OpenFile(&stream, path);
if (res) { Chat_LogError2(res, "opening", path); return; }
importer = Map_FindImporter(path);
if ((res = importer(&stream))) {
World_Reset();
Chat_LogError2(res, "decoding", path); stream.Close(&stream); return;
}
res = stream.Close(&stream);
if (res) { Chat_LogError2(res, "closing", path); }
World_SetNewMap(World_Blocks, World_BlocksSize, World_Width, World_Height, World_Length);
Event_RaiseVoid(&WorldEvents_MapLoaded);
LocationUpdate_MakePosAndOri(&update, p->Spawn, p->SpawnRotY, p->SpawnHeadX, false);
p->Base.VTABLE->SetLocation(&p->Base, &update, false);
}
/*########################################################################################################################*
*--------------------------------------------------MCSharp level Format---------------------------------------------------*

View file

@ -10,7 +10,10 @@ struct Stream;
typedef ReturnCode (*IMapImporter)(struct Stream* stream);
/* Attempts to find the suitable importer based on filename. */
/* Returns NULL if no match found. */
NOINLINE_ IMapImporter Map_FindImporter(const String* path);
CC_EXPORT IMapImporter Map_FindImporter(const String* path);
/* Attempts to import the map from the given file. */
/* NOTE: Uses Map_FindImporter to import based on filename. */
CC_EXPORT void Map_LoadFrom(const String* path);
/* Imports a world from a .lvl MCSharp server map file. */
/* Used by MCSharp/MCLawl/MCForge/MCDzienny/MCGalaxy. */

View file

@ -22,7 +22,7 @@ struct IGameComponent {
};
void IGameComponent_MakeEmpty(struct IGameComponent* comp);
NOINLINE_ void Game_AddComponent(struct IGameComponent* comp);
CC_NOINLINE void Game_AddComponent(struct IGameComponent* comp);
/* Represents a task that periodically runs on the main thread every specified interval. */
struct ScheduledTask;
@ -36,5 +36,5 @@ struct ScheduledTask {
};
typedef void (*ScheduledTaskCallback)(struct ScheduledTask* task);
NOINLINE_ int ScheduledTask_Add(double interval, ScheduledTaskCallback callback);
CC_NOINLINE int ScheduledTask_Add(double interval, ScheduledTaskCallback callback);
#endif

View file

@ -91,11 +91,11 @@ struct Screen* Gui_GetActiveScreen(void);
This means if an overlay is active, it will return the screen under it. */
struct Screen* Gui_GetUnderlyingScreen(void);
NOINLINE_ void Gui_FreeActive(void);
CC_NOINLINE void Gui_FreeActive(void);
/* NOTE: This doesn't free old active screen - must call Gui_FreeActive() first */
NOINLINE_ void Gui_SetActive(struct Screen* screen);
CC_NOINLINE void Gui_SetActive(struct Screen* screen);
/* NOTE: Same as Gui_FreeActive(); Gui_SetActive(NULL); */
NOINLINE_ void Gui_CloseActive(void);
CC_NOINLINE void Gui_CloseActive(void);
void Gui_RefreshHud(void);
void Gui_ShowOverlay(struct Screen* overlay, bool atFront);

View file

@ -541,7 +541,7 @@ static bool ListScreen_MouseScroll(void* screen, float delta) {
return true;
}
struct ScreenVTABLE ListScreen_VTABLE = {
static struct ScreenVTABLE ListScreen_VTABLE = {
ListScreen_Init, ListScreen_Render, ListScreen_Free, Gui_DefaultRecreate,
ListScreen_KeyDown, Menu_KeyUp, Menu_KeyPress,
Menu_MouseDown, Menu_MouseUp, Menu_MouseMove, ListScreen_MouseScroll,
@ -671,7 +671,7 @@ static void PauseScreen_Free(void* screen) {
Event_UnregisterVoid(&UserEvents_HackPermissionsChanged, s, PauseScreen_CheckHacksAllowed);
}
struct ScreenVTABLE PauseScreen_VTABLE = {
static struct ScreenVTABLE PauseScreen_VTABLE = {
PauseScreen_Init, MenuScreen_Render, PauseScreen_Free, Gui_DefaultRecreate,
MenuScreen_KeyDown, Menu_KeyUp, Menu_KeyPress,
Menu_MouseDown, Menu_MouseUp, Menu_MouseMove, MenuScreen_MouseScroll,
@ -762,7 +762,7 @@ static bool OptionsGroupScreen_MouseMove(void* screen, int x, int y) {
return true;
}
struct ScreenVTABLE OptionsGroupScreen_VTABLE = {
static struct ScreenVTABLE OptionsGroupScreen_VTABLE = {
OptionsGroupScreen_Init, MenuScreen_Render, OptionsGroupScreen_Free, Gui_DefaultRecreate,
MenuScreen_KeyDown, Menu_KeyUp, Menu_KeyPress,
Menu_MouseDown, Menu_MouseUp, OptionsGroupScreen_MouseMove, MenuScreen_MouseScroll,
@ -972,7 +972,7 @@ static void EditHotkeyScreen_ContextRecreated(void* screen) {
ANCHOR_CENTRE, ANCHOR_CENTRE, 0, -35);
}
struct ScreenVTABLE EditHotkeyScreen_VTABLE = {
static struct ScreenVTABLE EditHotkeyScreen_VTABLE = {
EditHotkeyScreen_Init, EditHotkeyScreen_Render, EditHotkeyScreen_Free, Gui_DefaultRecreate,
EditHotkeyScreen_KeyDown, EditHotkeyScreen_KeyUp, EditHotkeyScreen_KeyPress,
Menu_MouseDown, Menu_MouseUp, Menu_MouseMove, MenuScreen_MouseScroll,
@ -998,7 +998,7 @@ struct Screen* EditHotkeyScreen_MakeInstance(struct HotkeyData original) {
*-----------------------------------------------------GenLevelScreen------------------------------------------------------*
*#########################################################################################################################*/
static struct GenLevelScreen GenLevelScreen_Instance;
NOINLINE_ static int GenLevelScreen_GetInt(struct GenLevelScreen* s, int index) {
CC_NOINLINE static int GenLevelScreen_GetInt(struct GenLevelScreen* s, int index) {
struct MenuInputWidget* input = &s->Inputs[index];
struct MenuInputValidator* v;
String text = input->Base.Text;
@ -1009,7 +1009,7 @@ NOINLINE_ static int GenLevelScreen_GetInt(struct GenLevelScreen* s, int index)
Convert_TryParseInt(&text, &value); return value;
}
NOINLINE_ static int GenLevelScreen_GetSeedInt(struct GenLevelScreen* s, int index) {
CC_NOINLINE static int GenLevelScreen_GetSeedInt(struct GenLevelScreen* s, int index) {
struct MenuInputWidget* input = &s->Inputs[index];
RNGState rnd;
@ -1136,7 +1136,7 @@ static void GenLevelScreen_ContextRecreated(void* screen) {
Menu_Back(s, 11, &s->Buttons[2], "Cancel", &s->TitleFont, Menu_SwitchPause);
}
struct ScreenVTABLE GenLevelScreen_VTABLE = {
static struct ScreenVTABLE GenLevelScreen_VTABLE = {
GenLevelScreen_Init, MenuScreen_Render, GenLevelScreen_Free, Gui_DefaultRecreate,
GenLevelScreen_KeyDown, GenLevelScreen_KeyUp, GenLevelScreen_KeyPress,
Menu_MouseDown, Menu_MouseUp, Menu_MouseMove, MenuScreen_MouseScroll,
@ -1187,7 +1187,7 @@ static void ClassicGenScreen_ContextRecreated(void* screen) {
Menu_Back(s, 3, &s->Buttons[3], "Cancel", &s->TitleFont, Menu_SwitchPause);
}
struct ScreenVTABLE ClassicGenScreen_VTABLE = {
static struct ScreenVTABLE ClassicGenScreen_VTABLE = {
MenuScreen_Init, MenuScreen_Render, MenuScreen_Free, Gui_DefaultRecreate,
MenuScreen_KeyDown, Menu_KeyUp, Menu_KeyPress,
Menu_MouseDown, Menu_MouseUp, Menu_MouseMove, MenuScreen_MouseScroll,
@ -1368,7 +1368,7 @@ static void SaveLevelScreen_ContextRecreated(void* screen) {
s->Widgets[5] = NULL; /* description widget placeholder */
}
struct ScreenVTABLE SaveLevelScreen_VTABLE = {
static struct ScreenVTABLE SaveLevelScreen_VTABLE = {
SaveLevelScreen_Init, SaveLevelScreen_Render, SaveLevelScreen_Free, Gui_DefaultRecreate,
SaveLevelScreen_KeyDown, SaveLevelScreen_KeyUp, SaveLevelScreen_KeyPress,
Menu_MouseDown, Menu_MouseUp, Menu_MouseMove, MenuScreen_MouseScroll,
@ -1467,7 +1467,7 @@ static void FontListScreen_Init(void* screen) {
ListScreen_Select(s, &Game_FontName);
}
struct ScreenVTABLE FontListScreen_VTABLE = {
static struct ScreenVTABLE FontListScreen_VTABLE = {
FontListScreen_Init, ListScreen_Render, ListScreen_Free, Gui_DefaultRecreate,
ListScreen_KeyDown, Menu_KeyUp, Menu_KeyPress,
Menu_MouseDown, Menu_MouseUp, Menu_MouseMove, ListScreen_MouseScroll,
@ -1578,43 +1578,6 @@ static void LoadLevelScreen_FilterFiles(const String* path, void* obj) {
StringsBuffer_Add((StringsBuffer*)obj, &file);
}
void LoadLevelScreen_LoadMap(const String* path) {
struct LocalPlayer* p = &LocalPlayer_Instance;
struct LocationUpdate update;
IMapImporter importer;
struct Stream stream;
ReturnCode res;
World_Reset();
Event_RaiseVoid(&WorldEvents_NewMap);
if (World_TextureUrl.length) {
TexturePack_ExtractDefault();
World_TextureUrl.length = 0;
}
Block_Reset();
Inventory_SetDefaultMapping();
res = Stream_OpenFile(&stream, path);
if (res) { Chat_LogError2(res, "opening", path); return; }
importer = Map_FindImporter(path);
if ((res = importer(&stream))) {
World_Reset();
Chat_LogError2(res, "decoding", path); stream.Close(&stream); return;
}
res = stream.Close(&stream);
if (res) { Chat_LogError2(res, "closing", path); }
World_SetNewMap(World_Blocks, World_BlocksSize, World_Width, World_Height, World_Length);
Event_RaiseVoid(&WorldEvents_MapLoaded);
LocationUpdate_MakePosAndOri(&update, p->Spawn, p->SpawnRotY, p->SpawnHeadX, false);
p->Base.VTABLE->SetLocation(&p->Base, &update, false);
}
static void LoadLevelScreen_EntryClick(void* screen, void* widget) {
struct ListScreen* s = screen;
String filename;
@ -1624,7 +1587,7 @@ static void LoadLevelScreen_EntryClick(void* screen, void* widget) {
filename = ListScreen_UNSAFE_GetCur(s, widget);
String_Format2(&path, "maps%r%s", &Directory_Separator, &filename);
if (!File_Exists(&path)) return;
LoadLevelScreen_LoadMap(&path);
Map_LoadFrom(&path);
}
struct Screen* LoadLevelScreen_MakeInstance(void) {
@ -1748,7 +1711,7 @@ static bool KeyBindingsScreen_MouseDown(void* screen, int x, int y, MouseButton
return true;
}
struct ScreenVTABLE KeyBindingsScreen_VTABLE = {
static struct ScreenVTABLE KeyBindingsScreen_VTABLE = {
MenuScreen_Init, MenuScreen_Render, MenuScreen_Free, Gui_DefaultRecreate,
KeyBindingsScreen_KeyDown, Menu_KeyUp, Menu_KeyPress,
KeyBindingsScreen_MouseDown, Menu_MouseUp, Menu_MouseMove, MenuScreen_MouseScroll,
@ -2173,7 +2136,7 @@ static void MenuOptionsScreen_Input(void* screen, void* widget) {
ANCHOR_CENTRE, ANCHOR_CENTRE, 0, 150);
}
struct ScreenVTABLE MenuOptionsScreen_VTABLE = {
static struct ScreenVTABLE MenuOptionsScreen_VTABLE = {
MenuOptionsScreen_Init, MenuOptionsScreen_Render, MenuOptionsScreen_Free, Gui_DefaultRecreate,
MenuOptionsScreen_KeyDown, MenuOptionsScreen_KeyUp, MenuOptionsScreen_KeyPress,
Menu_MouseDown, Menu_MouseUp, MenuOptionsScreen_MouseMove, MenuScreen_MouseScroll,
@ -3102,7 +3065,7 @@ static bool TexIdsOverlay_KeyUp(void* screen, Key key) {
return Elem_HandlesKeyUp(active, key);
}
struct ScreenVTABLE TexIdsOverlay_VTABLE = {
static struct ScreenVTABLE TexIdsOverlay_VTABLE = {
TexIdsOverlay_Init, TexIdsOverlay_Render, MenuScreen_Free, Gui_DefaultRecreate,
TexIdsOverlay_KeyDown, TexIdsOverlay_KeyUp, TexIdsOverlay_KeyPress,
Menu_MouseDown, Menu_MouseUp, Menu_MouseMove, MenuScreen_MouseScroll,
@ -3150,7 +3113,7 @@ static void UrlWarningOverlay_ContextRecreated(void* screen) {
UrlWarningOverlay_OpenUrl, UrlWarningOverlay_AppendUrl);
}
struct ScreenVTABLE UrlWarningOverlay_VTABLE = {
static struct ScreenVTABLE UrlWarningOverlay_VTABLE = {
MenuScreen_Init, MenuScreen_Render, MenuScreen_Free, Gui_DefaultRecreate,
Overlay_KeyDown, Menu_KeyUp, Menu_KeyPress,
Menu_MouseDown, Menu_MouseUp, Menu_MouseMove, MenuScreen_MouseScroll,
@ -3216,7 +3179,7 @@ static void ConfirmDenyOverlay_ContextRecreated(void* screen) {
ANCHOR_CENTRE, ANCHOR_CENTRE, 110, 30);
}
struct ScreenVTABLE ConfirmDenyOverlay_VTABLE = {
static struct ScreenVTABLE ConfirmDenyOverlay_VTABLE = {
MenuScreen_Init, MenuScreen_Render, MenuScreen_Free, Gui_DefaultRecreate,
Overlay_KeyDown, Menu_KeyUp, Menu_KeyPress,
Menu_MouseDown, Menu_MouseUp, Menu_MouseMove, MenuScreen_MouseScroll,
@ -3318,7 +3281,7 @@ static void TexPackOverlay_ContextRecreated(void* screen) {
TexPackOverlay_YesClick, TexPackOverlay_NoClick);
}
struct ScreenVTABLE TexPackOverlay_VTABLE = {
static struct ScreenVTABLE TexPackOverlay_VTABLE = {
MenuScreen_Init, TexPackOverlay_Render, MenuScreen_Free, Gui_DefaultRecreate,
Overlay_KeyDown, Menu_KeyUp, Menu_KeyPress,
Menu_MouseDown, Menu_MouseUp, Menu_MouseMove, MenuScreen_MouseScroll,

View file

@ -20,7 +20,6 @@ struct Screen* MouseKeyBindingsScreen_MakeInstance(void);
struct Screen* GenLevelScreen_MakeInstance(void);
struct Screen* ClassicGenScreen_MakeInstance(void);
void LoadLevelScreen_LoadMap(const String* path);
struct Screen* LoadLevelScreen_MakeInstance(void);
struct Screen* SaveLevelScreen_MakeInstance(void);
struct Screen* TexturePackScreen_MakeInstance(void);

View file

@ -333,7 +333,7 @@ static struct ModelSet Chibi_Set;
static struct ModelVertex ChibiModel_Vertices[MODEL_BOX_VERTICES * (7 + 7 + 4)];
static struct Model ChibiModel;
NOINLINE_ static void ChibiModel_ScalePart(struct ModelPart* dst, struct ModelPart* src) {
CC_NOINLINE static void ChibiModel_ScalePart(struct ModelPart* dst, struct ModelPart* src) {
struct ModelVertex v;
int i;
@ -347,7 +347,7 @@ NOINLINE_ static void ChibiModel_ScalePart(struct ModelPart* dst, struct ModelPa
}
}
NOINLINE_ static void ChibiModel_ScaleLimbs(struct ModelLimbs* dst, struct ModelLimbs* src) {
CC_NOINLINE static void ChibiModel_ScaleLimbs(struct ModelLimbs* dst, struct ModelLimbs* src) {
ChibiModel_ScalePart(&dst->LeftLeg, &src->LeftLeg);
ChibiModel_ScalePart(&dst->RightLeg, &src->RightLeg);
ChibiModel_ScalePart(&dst->LeftArm, &src->LeftArm);

View file

@ -24,15 +24,15 @@ VertexP3fT2fC4b ModelCache_Vertices[MODELCACHE_MAX_VERTICES];
void ModelCache_Init(void);
void ModelCache_Free(void);
/* Returns pointer to model whose name caselessly matches given name. */
EXPORT_ struct Model* ModelCache_Get(const String* name);
CC_EXPORT struct Model* ModelCache_Get(const String* name);
/* Returns index of cached texture whose name caselessly matches given name. */
EXPORT_ int ModelCache_GetTextureIndex(const String* texName);
CC_EXPORT int ModelCache_GetTextureIndex(const String* texName);
/* Adds a model to the list of cached models. (e.g. "skeleton") */
/* Cached models can be applied to entities to change their appearance. Use Entity_SetModel for that. */
/* NOTE: defaultTexName can be NULL, and is for some models. (such as the "block" model) */
EXPORT_ void ModelCache_Register(STRING_REF const char* name, const char* defaultTexName, struct Model* instance);
CC_EXPORT void ModelCache_Register(STRING_REF const char* name, const char* defaultTexName, struct Model* instance);
/* Adds a texture to the list of cached textures. (e.g. "skeleton.png") */
/* Cached textures are automatically loaded from texture packs. Used as a 'default skin' for models. */
/* NOTE: Textures should be registered BEFORE models are registered. */
EXPORT_ void ModelCache_RegisterTexture(STRING_REF const char* texName);
CC_EXPORT void ModelCache_RegisterTexture(STRING_REF const char* texName);
#endif

View file

@ -19,7 +19,7 @@ void Options_Free(void) {
StringsBuffer_Clear(&Options_Changed);
}
NOINLINE_ static int Options_CaselessIndexOf(StringsBuffer* buffer, const String* str) {
CC_NOINLINE static int Options_CaselessIndexOf(StringsBuffer* buffer, const String* str) {
String entry;
int i;

View file

@ -74,32 +74,32 @@ StringsBuffer Options_Keys;
StringsBuffer Options_Values;
/* Returns whether user has changed any options this session. */
NOINLINE_ bool Options_HasAnyChanged(void);
CC_NOINLINE bool Options_HasAnyChanged(void);
/* Frees any memory allocated in storing options. */
NOINLINE_ void Options_Free(void);
CC_NOINLINE void Options_Free(void);
/* Returns value of given option, or defalt value if not found. */
EXPORT_ void Options_Get(const char* key, String* value, const char* defValue);
CC_EXPORT void Options_Get(const char* key, String* value, const char* defValue);
/* Returns value of given option as an integer, or defalt value if could not be converted. */
EXPORT_ int Options_GetInt(const char* key, int min, int max, int defValue);
CC_EXPORT int Options_GetInt(const char* key, int min, int max, int defValue);
/* Returns value of given option as a bool, or defalt value if could not be converted. */
EXPORT_ bool Options_GetBool(const char* key, bool defValue);
CC_EXPORT bool Options_GetBool(const char* key, bool defValue);
/* Returns value of given option as a float, or defalt value if could not be converted. */
EXPORT_ float Options_GetFloat(const char* key, float min, float max, float defValue);
CC_EXPORT float Options_GetFloat(const char* key, float min, float max, float defValue);
/* Returns value of given option as an integer, or defalt value if could not be converted. */
/* NOTE: Conversion is done by going through all elements of names, returning index of a match. */
EXPORT_ int Options_GetEnum(const char* key, int defValue, const char** names, int namesCount);
CC_EXPORT int Options_GetEnum(const char* key, int defValue, const char** names, int namesCount);
/* Sets value of given option to either "true" or "false". */
EXPORT_ void Options_SetBool(const char* keyRaw, bool value);
CC_EXPORT void Options_SetBool(const char* keyRaw, bool value);
/* Sets value of given option to given integer converted to a string. */
EXPORT_ void Options_SetInt(const char* keyRaw, int value);
CC_EXPORT void Options_SetInt(const char* keyRaw, int value);
/* Sets value of given option to given string. */
EXPORT_ void Options_Set(const char* keyRaw, const String* value);
CC_EXPORT void Options_Set(const char* keyRaw, const String* value);
/* Sets value of given option to given string. */
EXPORT_ void Options_SetString(const String* key, const String* value);
CC_EXPORT void Options_SetString(const String* key, const String* value);
/* Loads options from disc. Leaves options changed in this session alone. */
EXPORT_ void Options_Load(void);
CC_EXPORT void Options_Load(void);
/* Saves all options to disc. */
EXPORT_ void Options_Save(void);
CC_EXPORT void Options_Save(void);
#endif

View file

@ -6,7 +6,7 @@
*/
/* Represents an ARGB colour, in a format suitable for the native graphics api. */
typedef ALIGN_HINT_(4) struct PackedCol_ {
typedef CC_ALIGN_HINT(4) struct PackedCol_ {
#ifdef CC_BUILD_D3D9
uint8_t B, G, R, A;
#else
@ -35,9 +35,9 @@ bool PackedCol_Equals(PackedCol a, PackedCol b);
uint32_t PackedCol_ToARGB(PackedCol col);
PackedCol PackedCol_Scale(PackedCol value, float t);
PackedCol PackedCol_Lerp(PackedCol a, PackedCol b, float t);
NOINLINE_ bool PackedCol_Unhex(char hex, int* value);
NOINLINE_ void PackedCol_ToHex(String* str, PackedCol value);
NOINLINE_ bool PackedCol_TryParseHex(const String* str, PackedCol* value);
CC_NOINLINE bool PackedCol_Unhex(char hex, int* value);
CC_NOINLINE void PackedCol_ToHex(String* str, PackedCol value);
CC_NOINLINE bool PackedCol_TryParseHex(const String* str, PackedCol* value);
#define PACKEDCOL_SHADE_X 0.6f
#define PACKEDCOL_SHADE_Z 0.8f

View file

@ -1250,12 +1250,11 @@ static void CPE_SetMapEnvProperty(uint8_t* data) {
Game_MaxViewDistance = value <= 0 ? 32768 : value;
Game_SetViewDistance(Game_UserViewDistance); break;
case 5:
Env_SetCloudsSpeed(value / 256.0f); break;
Env_SetCloudsSpeed(value / 256.0f); break;
case 6:
Env_SetWeatherSpeed(value / 256.0f); break;
case 7:
Math_Clamp(value, 0, UInt8_MaxValue);
Env_SetWeatherFade(value / 128.0f); break;
Env_SetWeatherFade(value / 128.0f); break;
case 8:
Env_SetExpFog(value != 0); break;
case 9:

View file

@ -140,7 +140,7 @@ void GraphicsMode_MakeDefault(struct GraphicsMode* m) {
void Mem_Set(void* dst, uint8_t value, uint32_t numBytes) { memset(dst, value, numBytes); }
void Mem_Copy(void* dst, void* src, uint32_t numBytes) { memcpy(dst, src, numBytes); }
NOINLINE_ static void Platform_AllocFailed(const char* place) {
CC_NOINLINE static void Platform_AllocFailed(const char* place) {
char logBuffer[STRING_SIZE+20 + 1];
String log = String_NT_Array(logBuffer);
String_Format1(&log, "Failed allocating memory for: %c", place);

View file

@ -49,7 +49,7 @@ void GraphicsMode_MakeDefault(struct GraphicsMode* m);
/* Encodes a string in platform specific format. (e.g. unicode on windows, UTF8 on linux) */
/* NOTE: Only useful for platform specific function calls - do NOT try to interpret the data.
Returns the number of bytes written, excluding trailing NULL terminator. */
EXPORT_ int Platform_ConvertString(void* data, const String* src);
CC_EXPORT int Platform_ConvertString(void* data, const String* src);
/* Initalises the platform specific state. */
void Platform_Init(void);
/* Frees the platform specific state. */
@ -61,16 +61,16 @@ void Platform_Exit(ReturnCode code);
/* Gets the command line arguments passed to the program. */
int Platform_GetCommandLineArgs(int argc, STRING_REF const char** argv, String* args);
/* Starts the platform's shell with the given arguments. (e.g. open http:// url in web browser) */
EXPORT_ ReturnCode Platform_StartShell(const String* args);
CC_EXPORT ReturnCode Platform_StartShell(const String* args);
/* Allocates a block of memory, with undetermined contents. Exits process on allocation failure. */
EXPORT_ void* Mem_Alloc(uint32_t numElems, uint32_t elemsSize, const char* place);
CC_EXPORT void* Mem_Alloc(uint32_t numElems, uint32_t elemsSize, const char* place);
/* Allocates a block of memory, with contents of all 0. Exits process on allocation failure. */
EXPORT_ void* Mem_AllocCleared(uint32_t numElems, uint32_t elemsSize, const char* place);
CC_EXPORT void* Mem_AllocCleared(uint32_t numElems, uint32_t elemsSize, const char* place);
/* Reallocates a block of memory, with undetermined contents. Exits process on reallocation failure. */
EXPORT_ void* Mem_Realloc(void* mem, uint32_t numElems, uint32_t elemsSize, const char* place);
CC_EXPORT void* Mem_Realloc(void* mem, uint32_t numElems, uint32_t elemsSize, const char* place);
/* Frees an allocated a block of memory. Does nothing when passed NULL. */
EXPORT_ void Mem_Free(void* mem);
CC_EXPORT void Mem_Free(void* mem);
/* Sets the contents of a block of memory to the given value. */
void Mem_Set(void* dst, uint8_t value, uint32_t numBytes);
/* Copies a block of memory to another block. NOTE: These blocks MUST NOT overlap. */
@ -130,47 +130,47 @@ ReturnCode File_Position(void* file, uint32_t* position);
ReturnCode File_Length(void* file, uint32_t* length);
/* Blocks the current thread for the given number of milliseconds. */
EXPORT_ void Thread_Sleep(uint32_t milliseconds);
CC_EXPORT void Thread_Sleep(uint32_t milliseconds);
typedef void Thread_StartFunc(void);
/* Starts a new thread, optionally immediately detaching it. (See Thread_Detach) */
EXPORT_ void* Thread_Start(Thread_StartFunc* func, bool detach);
CC_EXPORT void* Thread_Start(Thread_StartFunc* func, bool detach);
/* Frees the platform specific persistent data associated with the thread. */
/* NOTE: You must either detach or join threads, as this data otherwise leaks. */
EXPORT_ void Thread_Detach(void* handle);
CC_EXPORT void Thread_Detach(void* handle);
/* Blocks the current thread, until the given thread has finished. */
/* NOTE: Once a thread has been detached, you can no longer use this method. */
EXPORT_ void Thread_Join(void* handle);
CC_EXPORT void Thread_Join(void* handle);
/* Allocates a new mutex. (used to synchronise access to a shared resource) */
EXPORT_ void* Mutex_Create(void);
CC_EXPORT void* Mutex_Create(void);
/* Frees an allocated mutex. */
EXPORT_ void Mutex_Free(void* handle);
CC_EXPORT void Mutex_Free(void* handle);
/* Locks the given mutex, blocking other threads from entering. */
EXPORT_ void Mutex_Lock(void* handle);
CC_EXPORT void Mutex_Lock(void* handle);
/* Unlocks the given mutex, allowing other threads to enter. */
EXPORT_ void Mutex_Unlock(void* handle);
CC_EXPORT void Mutex_Unlock(void* handle);
/* Allocates a new waitable. (used to conditionally wake-up a blocked thread) */
EXPORT_ void* Waitable_Create(void);
CC_EXPORT void* Waitable_Create(void);
/* Frees an allocated waitable. */
EXPORT_ void Waitable_Free(void* handle);
CC_EXPORT void Waitable_Free(void* handle);
/* Signals a waitable, waking up blocked threads. */
EXPORT_ void Waitable_Signal(void* handle);
CC_EXPORT void Waitable_Signal(void* handle);
/* Blocks the calling thread until the waitable gets signalled. */
EXPORT_ void Waitable_Wait(void* handle);
CC_EXPORT void Waitable_Wait(void* handle);
/* Blocks the calling thread until the waitable gets signalled, or milliseconds delay passes. */
EXPORT_ void Waitable_WaitFor(void* handle, uint32_t milliseconds);
CC_EXPORT void Waitable_WaitFor(void* handle, uint32_t milliseconds);
/* Gets the list of all supported font names on this platform. */
EXPORT_ void Font_GetNames(StringsBuffer* buffer);
CC_EXPORT void Font_GetNames(StringsBuffer* buffer);
/* Allocates a new font from the given arguments. */
EXPORT_ void Font_Make(FontDesc* desc, const String* fontName, int size, int style);
CC_EXPORT void Font_Make(FontDesc* desc, const String* fontName, int size, int style);
/* Frees an allocated font. */
EXPORT_ void Font_Free(FontDesc* desc);
CC_EXPORT void Font_Free(FontDesc* desc);
/* Measures dimensions of the given text, if it was drawn with the given font. */
EXPORT_ Size2D Platform_TextMeasure(struct DrawTextArgs* args);
CC_EXPORT Size2D Platform_TextMeasure(struct DrawTextArgs* args);
/* Draws the given text with the given font onto the given bitmap. */
EXPORT_ Size2D Platform_TextDraw(struct DrawTextArgs* args, Bitmap* bmp, int x, int y, PackedCol col);
CC_EXPORT Size2D Platform_TextDraw(struct DrawTextArgs* args, Bitmap* bmp, int x, int y, PackedCol col);
/* Allocates a new socket. */
void Socket_Create(SocketPtr* socket);

View file

@ -108,7 +108,7 @@ static bool Screen_MouseMove(void* elem, int x, int y) { return false; }
/*########################################################################################################################*
*-----------------------------------------------------InventoryScreen-----------------------------------------------------*
*#########################################################################################################################*/
struct InventoryScreen InventoryScreen_Instance;
static struct InventoryScreen InventoryScreen_Instance;
static void InventoryScreen_OnBlockChanged(void* screen) {
struct InventoryScreen* s = screen;
TableWidget_OnInventoryChanged(&s->Table);
@ -242,7 +242,7 @@ static bool InventoryScreen_MouseScroll(void* screen, float delta) {
return Elem_HandlesMouseScroll(table, delta);
}
struct ScreenVTABLE InventoryScreen_VTABLE = {
static struct ScreenVTABLE InventoryScreen_VTABLE = {
InventoryScreen_Init, InventoryScreen_Render, InventoryScreen_Free, Gui_DefaultRecreate,
InventoryScreen_KeyDown, InventoryScreen_KeyUp, InventoryScreen_KeyPress,
InventoryScreen_MouseDown, InventoryScreen_MouseUp, InventoryScreen_MouseMove, InventoryScreen_MouseScroll,
@ -425,7 +425,7 @@ static void StatusScreen_Free(void* screen) {
Event_UnregisterVoid(&ChatEvents_FontChanged, s, StatusScreen_FontChanged);
}
struct ScreenVTABLE StatusScreen_VTABLE = {
static struct ScreenVTABLE StatusScreen_VTABLE = {
StatusScreen_Init, StatusScreen_Render, StatusScreen_Free, Gui_DefaultRecreate,
StatusScreen_Key, StatusScreen_Key, StatusScreen_KeyPress,
Screen_Mouse, Screen_Mouse, Screen_MouseMove, StatusScreen_MouseScroll,
@ -588,7 +588,7 @@ static void LoadingScreen_Free(void* screen) {
Event_UnregisterFloat(&WorldEvents_Loading, s, LoadingScreen_MapLoading);
}
struct ScreenVTABLE LoadingScreen_VTABLE = {
static struct ScreenVTABLE LoadingScreen_VTABLE = {
LoadingScreen_Init, LoadingScreen_Render, LoadingScreen_Free, Gui_DefaultRecreate,
LoadingScreen_KeyDown, LoadingScreen_KeyUp, LoadingScreen_KeyPress,
LoadingScreen_MouseDown, LoadingScreen_MouseUp, LoadingScreen_MouseMove, LoadingScreen_MouseScroll,
@ -671,7 +671,7 @@ static void GeneratingScreen_Render(void* screen, double delta) {
LoadingScreen_SetMessage(s);
}
struct ScreenVTABLE GeneratingScreen_VTABLE = {
static struct ScreenVTABLE GeneratingScreen_VTABLE = {
GeneratingScreen_Init, GeneratingScreen_Render, LoadingScreen_Free, Gui_DefaultRecreate,
LoadingScreen_KeyDown, LoadingScreen_KeyUp, LoadingScreen_KeyPress,
LoadingScreen_MouseDown, LoadingScreen_MouseUp, LoadingScreen_MouseMove, LoadingScreen_MouseScroll,
@ -1169,7 +1169,7 @@ static void ChatScreen_Free(void* screen) {
Event_UnregisterInt(&ChatEvents_ColCodeChanged, s, ChatScreen_ColCodeChanged);
}
struct ScreenVTABLE ChatScreen_VTABLE = {
static struct ScreenVTABLE ChatScreen_VTABLE = {
ChatScreen_Init, ChatScreen_Render, ChatScreen_Free, Gui_DefaultRecreate,
ChatScreen_KeyDown, ChatScreen_KeyUp, ChatScreen_KeyPress,
ChatScreen_MouseDown, Screen_Mouse, Screen_MouseMove, ChatScreen_MouseScroll,
@ -1355,7 +1355,7 @@ static void HUDScreen_Free(void* screen) {
Screen_CommonFree(s);
}
struct ScreenVTABLE HUDScreen_VTABLE = {
static struct ScreenVTABLE HUDScreen_VTABLE = {
HUDScreen_Init, HUDScreen_Render, HUDScreen_Free, Gui_DefaultRecreate,
HUDScreen_KeyDown, HUDScreen_KeyUp, HUDScreen_KeyPress,
HUDScreen_MouseDown, Screen_Mouse, Screen_MouseMove, HUDScreen_MouseScroll,
@ -1526,7 +1526,7 @@ static bool DisconnectScreen_MouseMove(void* screen, int x, int y) {
static bool DisconnectScreen_MouseScroll(void* screen, float delta) { return true; }
static bool DisconnectScreen_MouseUp(void* screen, int x, int y, MouseButton btn) { return true; }
struct ScreenVTABLE DisconnectScreen_VTABLE = {
static struct ScreenVTABLE DisconnectScreen_VTABLE = {
DisconnectScreen_Init, DisconnectScreen_Render, DisconnectScreen_Free, Gui_DefaultRecreate,
DisconnectScreen_KeyDown, DisconnectScreen_KeyUp, DisconnectScreen_KeyPress,
DisconnectScreen_MouseDown, DisconnectScreen_MouseUp, DisconnectScreen_MouseMove, DisconnectScreen_MouseScroll,

View file

@ -10,6 +10,7 @@
#include "Entity.h"
#include "Gui.h"
#include "Screens.h"
#include "Formats.h"
#include "MapGenerator.h"
#include "World.h"
#include "Camera.h"
@ -24,14 +25,15 @@
/*########################################################################################################################*
*-----------------------------------------------------Common handlers-----------------------------------------------------*
*#########################################################################################################################*/
static char ServerConnection_ServerNameBuffer[STRING_SIZE];
String ServerConnection_ServerName = String_FromArray(ServerConnection_ServerNameBuffer);
static char ServerConnection_ServerMOTDBuffer[STRING_SIZE];
String ServerConnection_ServerMOTD = String_FromArray(ServerConnection_ServerMOTDBuffer);
static char ServerConnection_AppNameBuffer[STRING_SIZE];
String ServerConnection_AppName = String_FromArray(ServerConnection_AppNameBuffer);
static char server_nameBuffer[STRING_SIZE];
static char server_motdBuffer[STRING_SIZE];
static char server_appBuffer[STRING_SIZE];
static int server_ticks;
String ServerConnection_ServerName = String_FromArray(server_nameBuffer);
String ServerConnection_ServerMOTD = String_FromArray(server_motdBuffer);
String ServerConnection_AppName = String_FromArray(server_appBuffer);
static void ServerConnection_ResetState(void) {
ServerConnection_Disconnected = false;
ServerConnection_SupportsExtPlayerList = false;
@ -152,7 +154,7 @@ static void SPConnection_BeginConnect(void) {
/* For when user drops a map file onto ClassiCube.exe */
path = Game_Username;
if (String_IndexOf(&path, Directory_Separator, 0) >= 0 && File_Exists(&path)) {
LoadLevelScreen_LoadMap(&path);
Map_LoadFrom(&path);
Gui_CloseActive();
return;
}

View file

@ -50,20 +50,20 @@ void Stream_Init(struct Stream* s);
ReturnCode Stream_DefaultReadU8(struct Stream* s, uint8_t* data);
/* Wrapper for File_Open() then Stream_FromFile() */
EXPORT_ ReturnCode Stream_OpenFile(struct Stream* s, const String* path);
CC_EXPORT ReturnCode Stream_OpenFile(struct Stream* s, const String* path);
/* Wrapper for File_Create() then Stream_FromFile() */
EXPORT_ ReturnCode Stream_CreateFile(struct Stream* s, const String* path);
CC_EXPORT ReturnCode Stream_CreateFile(struct Stream* s, const String* path);
/* Wraps a file, allowing reading from/writing to/seeking in the file. */
EXPORT_ void Stream_FromFile(struct Stream* s, void* file);
CC_EXPORT void Stream_FromFile(struct Stream* s, void* file);
/* Wraps another Stream, only allows reading up to 'len' bytes from the wrapped stream. */
EXPORT_ void Stream_ReadonlyPortion(struct Stream* s, struct Stream* source, uint32_t len);
CC_EXPORT void Stream_ReadonlyPortion(struct Stream* s, struct Stream* source, uint32_t len);
/* Wraps a block of memory, allowing reading from and seeking in the block. */
EXPORT_ void Stream_ReadonlyMemory(struct Stream* s, void* data, uint32_t len);
CC_EXPORT void Stream_ReadonlyMemory(struct Stream* s, void* data, uint32_t len);
/* Wraps a block of memory, allowing writing to and seeking in the block. */
EXPORT_ void Stream_WriteonlyMemory(struct Stream* s, void* data, uint32_t len);
CC_EXPORT void Stream_WriteonlyMemory(struct Stream* s, void* data, uint32_t len);
/* Wraps another Stream, reading through an intermediary buffer. (Useful for files, since each read call is expensive) */
EXPORT_ void Stream_ReadonlyBuffered(struct Stream* s, struct Stream* source, void* data, uint32_t size);
CC_EXPORT void Stream_ReadonlyBuffered(struct Stream* s, struct Stream* source, void* data, uint32_t size);
/* Reads a little-endian 16 bit unsigned integer from memory. */
uint16_t Stream_GetU16_LE(uint8_t* data);
@ -87,7 +87,7 @@ ReturnCode Stream_ReadU32_BE(struct Stream* s, uint32_t* value);
/* Reads a line of UTF8 encoded character from the stream. */
/* NOTE: Reads one byte at a time. May want to use Stream_ReadonlyBuffered. */
EXPORT_ ReturnCode Stream_ReadLine(struct Stream* s, String* text);
CC_EXPORT ReturnCode Stream_ReadLine(struct Stream* s, String* text);
/* Writes a line of UTF8 encoded text to the stream. */
EXPORT_ ReturnCode Stream_WriteLine(struct Stream* s, String* text);
CC_EXPORT ReturnCode Stream_WriteLine(struct Stream* s, String* text);
#endif

View file

@ -237,7 +237,7 @@ bool String_AppendHex(String* str, uint8_t value) {
return String_Append(str, c_hi) && String_Append(str, c_lo);
}
NOINLINE_ static bool String_Hex32(String* str, uint32_t value) {
CC_NOINLINE static bool String_Hex32(String* str, uint32_t value) {
bool appended;
int shift;
@ -248,7 +248,7 @@ NOINLINE_ static bool String_Hex32(String* str, uint32_t value) {
return appended;
}
NOINLINE_ static bool String_Hex64(String* str, uint64_t value) {
CC_NOINLINE static bool String_Hex64(String* str, uint64_t value) {
bool appended;
int shift;
@ -745,7 +745,7 @@ bool Convert_TryParseBool(const String* str, bool* value) {
#define STRINGSBUFFER_LEN_MASK 0x1FFUL
#define STRINGSBUFFER_BUFFER_EXPAND_SIZE 8192
NOINLINE_ static void StringsBuffer_Init(StringsBuffer* buffer) {
CC_NOINLINE static void StringsBuffer_Init(StringsBuffer* buffer) {
buffer->Count = 0;
buffer->TotalLength = 0;
buffer->TextBuffer = buffer->_DefaultBuffer;

View file

@ -31,9 +31,9 @@ String String_Init(STRING_REF char* buffer, int length, int capacity);
/* Constructs a string from the given arguments, then sets all characters to '\0'. */
String String_InitAndClear(STRING_REF char* buffer, int capacity);
/* Constructs a string from a (maybe null terminated) buffer. */
NOINLINE_ String String_FromRaw(STRING_REF char* buffer, int capacity);
CC_NOINLINE String String_FromRaw(STRING_REF char* buffer, int capacity);
/* Constructs a string from a null-terminated constant readonly buffer. */
NOINLINE_ String String_FromReadonly(STRING_REF const char* buffer);
CC_NOINLINE String String_FromReadonly(STRING_REF const char* buffer);
/* Constructs a string from a compile time array, then sets all characters to '\0'. */
#define String_ClearedArray(buffer) String_InitAndClear(buffer, sizeof(buffer))
@ -49,93 +49,93 @@ NOINLINE_ String String_FromReadonly(STRING_REF const char* buffer);
#define String_InitArray(str, buffr) str.buffer = buffr; str.length = 0; str.capacity = sizeof(buffr);
/* Removes all colour codes from the given string. */
NOINLINE_ void String_StripCols(String* str);
CC_NOINLINE void String_StripCols(String* str);
/* Sets length of dst to 0, then appends all characters in src. */
NOINLINE_ void String_Copy(String* dst, const String* src);
CC_NOINLINE void String_Copy(String* dst, const String* src);
/* UNSAFE: Returns a substring of the given string. (sub.buffer is within str.buffer + str.length) */
NOINLINE_ String String_UNSAFE_Substring(STRING_REF const String* str, int offset, int length);
CC_NOINLINE String String_UNSAFE_Substring(STRING_REF const String* str, int offset, int length);
/* UNSAFE: Returns a substring of the given string. (sub.buffer is within str.buffer + str.length) */
#define String_UNSAFE_SubstringAt(str, offset) (String_UNSAFE_Substring(str, offset, (str)->length - (offset)))
/* UNSAFE: Splits a string of the form [str1][c][str2][c][str3].. into substrings. */
/* e.g., "abc:id:xyz" becomes "abc","id","xyz" */
NOINLINE_ int String_UNSAFE_Split(STRING_REF const String* str, char c, String* subs, int maxSubs);
CC_NOINLINE int String_UNSAFE_Split(STRING_REF const String* str, char c, String* subs, int maxSubs);
/* UNSAFE: Splits a string of the form [key][c][value] into two substrings. */
/* e.g., "allowed =true" becomes "allowed" and "true", and excludes the space. */
/* If c is not found, sets key to str and value to String_Empty, returns false. */
NOINLINE_ bool String_UNSAFE_Separate(STRING_REF const String* str, char c, String* key, String* value);
CC_NOINLINE bool String_UNSAFE_Separate(STRING_REF const String* str, char c, String* key, String* value);
/* Whether all characters of the strings are equal. */
NOINLINE_ bool String_Equals(const String* a, const String* b);
CC_NOINLINE bool String_Equals(const String* a, const String* b);
/* Whether all characters of the strings are case-insensitively equal. */
NOINLINE_ bool String_CaselessEquals(const String* a, const String* b);
CC_NOINLINE bool String_CaselessEquals(const String* a, const String* b);
/* Whether all characters of the strings are case-insensitively equal. */
/* NOTE: Faster than String_CaselessEquals(a, String_FromReadonly(b)) */
NOINLINE_ bool String_CaselessEqualsConst(const String* a, const char* b);
CC_NOINLINE bool String_CaselessEqualsConst(const String* a, const char* b);
/* Breaks down an integer into an array of digits. */
/* NOTE: Digits are in reverse order, so e.g. '200' becomes '0','0','2' */
NOINLINE_ int String_MakeUInt32(uint32_t num, char* numBuffer);
CC_NOINLINE int String_MakeUInt32(uint32_t num, char* numBuffer);
/* Appends a character to the end of a string. */
/* Returns false when str->length == str->capcity, true otherwise. */
bool String_Append(String* str, char c);
/* Appends a boolean as either "true" or "false" to the end of a string. */
NOINLINE_ bool String_AppendBool(String* str, bool value);
CC_NOINLINE bool String_AppendBool(String* str, bool value);
/* Appends the digits of an integer (and -sign if negative) to the end of a string. */
NOINLINE_ bool String_AppendInt(String* str, int num);
CC_NOINLINE bool String_AppendInt(String* str, int num);
/* Appends the digits of an unsigned 32 bit integer to the end of a string. */
NOINLINE_ bool String_AppendUInt32(String* str, uint32_t num);
CC_NOINLINE bool String_AppendUInt32(String* str, uint32_t num);
/* Attempts to append an integer value to the end of a string, padding left with 0. */
NOINLINE_ bool String_AppendPaddedInt(String* str, int num, int minDigits);
CC_NOINLINE bool String_AppendPaddedInt(String* str, int num, int minDigits);
/* Appends the digits of an unsigned 64 bit integer to the end of a string. */
NOINLINE_ bool String_AppendUInt64(String* str, uint64_t num);
CC_NOINLINE bool String_AppendUInt64(String* str, uint64_t num);
/* Appends the digits of a float as a decimal. */
/* NOTE: If the number is an integer, no decimal point is added. */
/* Otherwise, fracDigits digits are added after a decimal point. */
/* e.g. 1.0f produces "1", 2.6745f produces "2.67" when fracDigits is 2 */
NOINLINE_ bool String_AppendFloat(String* str, float num, int fracDigits); /* TODO: Need to account for , or . for decimal */
CC_NOINLINE bool String_AppendFloat(String* str, float num, int fracDigits); /* TODO: Need to account for , or . for decimal */
/* Appends characters to the end of a string. src MUST be null-terminated. */
NOINLINE_ bool String_AppendConst(String* str, const char* src);
CC_NOINLINE bool String_AppendConst(String* str, const char* src);
/* Appends characters to the end of a string. */
NOINLINE_ bool String_AppendString(String* str, const String* src);
CC_NOINLINE bool String_AppendString(String* str, const String* src);
/* Appends characters to the end of a string, skipping any colour codes. */
NOINLINE_ bool String_AppendColorless(String* str, const String* src);
CC_NOINLINE bool String_AppendColorless(String* str, const String* src);
/* Appends the two hex digits of a byte to the end of a string. */
NOINLINE_ bool String_AppendHex(String* str, uint8_t value);
CC_NOINLINE bool String_AppendHex(String* str, uint8_t value);
/* Returns first index of the given character in the given string, -1 if not found. */
NOINLINE_ int String_IndexOf(const String* str, char c, int offset);
CC_NOINLINE int String_IndexOf(const String* str, char c, int offset);
/* Returns last index of the given character in the given string, -1 if not found. */
NOINLINE_ int String_LastIndexOf(const String* str, char c);
CC_NOINLINE int String_LastIndexOf(const String* str, char c);
/* Inserts the given character into the given string. Exits process if this fails. */
/* e.g. inserting 'd' at offset '1' into "abc" produces "adbc" */
NOINLINE_ void String_InsertAt(String* str, int offset, char c);
CC_NOINLINE void String_InsertAt(String* str, int offset, char c);
/* Deletes a character from the given string. Exits process if this fails. */
/* e.g. deleting at offset '1' from "adbc" produces "abc" */
NOINLINE_ void String_DeleteAt(String* str, int offset);
CC_NOINLINE void String_DeleteAt(String* str, int offset);
/* Trims leading spaces from the given string. */
/* NOTE: Works by adjusting buffer/length, the characters in memory are not shifted. */
NOINLINE_ void String_TrimStart(String* str);
CC_NOINLINE void String_TrimStart(String* str);
/* Trims trailing spaces from the given string. */
/* NOTE: Works by adjusting buffer/length, the characters in memory are not shifted. */
NOINLINE_ void String_TrimEnd(String* str);
CC_NOINLINE void String_TrimEnd(String* str);
/* Returns first index of the given substring in the given string, -1 if not found. */
/* e.g. index of "ab" within "cbabd" is 2 */
NOINLINE_ int String_IndexOfString(const String* str, const String* sub);
CC_NOINLINE int String_IndexOfString(const String* str, const String* sub);
/* Returns whether given substring is inside the given string. */
#define String_ContainsString(str, sub) (String_IndexOfString(str, sub) >= 0)
/* Returns whether given substring is case-insensitively inside the given string. */
NOINLINE_ bool String_CaselessContains(const String* str, const String* sub);
CC_NOINLINE bool String_CaselessContains(const String* str, const String* sub);
/* Returns whether given substring is case-insensitively equal to the beginning of the given string. */
NOINLINE_ bool String_CaselessStarts(const String* str, const String* sub);
CC_NOINLINE bool String_CaselessStarts(const String* str, const String* sub);
/* Returns whether given substring is case-insensitively equal to the ending of the given string. */
NOINLINE_ bool String_CaselessEnds(const String* str, const String* sub);
CC_NOINLINE bool String_CaselessEnds(const String* str, const String* sub);
/* Compares the length of the given strings, then compares the characters if same length. Returns: */
/* -X if a.length < b.length, X if a.length > b.length */
/* -X if a.buffer[i] < b.buffer[i], X if a.buffer[i] > b.buffer[i] */
/* else returns 0. NOTE: The return value is not just in -1,0,1! */
NOINLINE_ int String_Compare(const String* a, const String* b);
CC_NOINLINE int String_Compare(const String* a, const String* b);
/* See String_Format4 */
void String_Format1(String* str, const char* format, const void* a1);
@ -162,20 +162,20 @@ int Convert_Utf8ToUnicode(Codepoint* cp, const uint8_t* data, uint32_t len);
int Convert_UnicodeToUtf8(Codepoint cp, uint8_t* data);
/* Attempts to convert the given string into an unsigned 8 bit integer. */
NOINLINE_ bool Convert_TryParseUInt8(const String* str, uint8_t* value);
CC_NOINLINE bool Convert_TryParseUInt8(const String* str, uint8_t* value);
/* Attempts to convert the given string into an signed 16 bit integer. */
NOINLINE_ bool Convert_TryParseInt16(const String* str, int16_t* value);
CC_NOINLINE bool Convert_TryParseInt16(const String* str, int16_t* value);
/* Attempts to convert the given string into an unsigned 16 bit integer. */
NOINLINE_ bool Convert_TryParseUInt16(const String* str, uint16_t* value);
CC_NOINLINE bool Convert_TryParseUInt16(const String* str, uint16_t* value);
/* Attempts to convert the given string into an integer. */
NOINLINE_ bool Convert_TryParseInt(const String* str, int* value);
CC_NOINLINE bool Convert_TryParseInt(const String* str, int* value);
/* Attempts to convert the given string into an unsigned 64 bit integer. */
NOINLINE_ bool Convert_TryParseUInt64(const String* str, uint64_t* value);
CC_NOINLINE bool Convert_TryParseUInt64(const String* str, uint64_t* value);
/* Attempts to convert the given string into a floating point number. */
NOINLINE_ bool Convert_TryParseFloat(const String* str, float* value);
CC_NOINLINE bool Convert_TryParseFloat(const String* str, float* value);
/* Attempts to convert the given string into a bool. */
/* NOTE: String must case-insensitively equal "true" or "false" */
NOINLINE_ bool Convert_TryParseBool(const String* str, bool* value);
CC_NOINLINE bool Convert_TryParseBool(const String* str, bool* value);
#define STRINGSBUFFER_BUFFER_DEF_SIZE 4096
#define STRINGSBUFFER_FLAGS_DEF_ELEMS 256
@ -190,23 +190,23 @@ typedef struct StringsBuffer_ {
} StringsBuffer;
/* Resets counts to 0, and frees any allocated memory. */
NOINLINE_ void StringsBuffer_Clear(StringsBuffer* buffer);
CC_NOINLINE void StringsBuffer_Clear(StringsBuffer* buffer);
/* Copies the characters from the i'th string in the given buffer into the given string. */
NOINLINE_ void StringsBuffer_Get(StringsBuffer* buffer, int i, String* str);
CC_NOINLINE void StringsBuffer_Get(StringsBuffer* buffer, int i, String* str);
/* UNSAFE: Returns a direct pointer to the i'th string in the given buffer. */
NOINLINE_ STRING_REF String StringsBuffer_UNSAFE_Get(StringsBuffer* buffer, int i);
CC_NOINLINE STRING_REF String StringsBuffer_UNSAFE_Get(StringsBuffer* buffer, int i);
/* Adds a given string to the end of the given buffer. */
NOINLINE_ void StringsBuffer_Add(StringsBuffer* buffer, const String* str);
CC_NOINLINE void StringsBuffer_Add(StringsBuffer* buffer, const String* str);
/* Removes the i'th string from the given buffer, shifting following strings downwards. */
NOINLINE_ void StringsBuffer_Remove(StringsBuffer* buffer, int index);
CC_NOINLINE void StringsBuffer_Remove(StringsBuffer* buffer, int index);
/* Performs line wrapping on the given string. */
/* e.g. "some random tex|t* (| is lineLen) becomes "some random" "text" */
NOINLINE_ void WordWrap_Do(STRING_REF String* text, String* lines, int numLines, int lineLen);
CC_NOINLINE void WordWrap_Do(STRING_REF String* text, String* lines, int numLines, int lineLen);
/* Calculates the position of a raw index in the wrapped lines. */
NOINLINE_ void WordWrap_GetCoords(int index, const String* lines, int numLines, int* coordX, int* coordY);
CC_NOINLINE void WordWrap_GetCoords(int index, const String* lines, int numLines, int* coordX, int* coordY);
/* Returns number of characters from current character to end of previous word. */
NOINLINE_ int WordWrap_GetBackLength(const String* text, int index);
CC_NOINLINE int WordWrap_GetBackLength(const String* text, int index);
/* Returns number of characters from current character to start of next word. */
NOINLINE_ int WordWrap_GetForwardLength(const String* text, int index);
CC_NOINLINE int WordWrap_GetForwardLength(const String* text, int index);
#endif

View file

@ -23,7 +23,7 @@ TimeMS DateTime_TotalMs(const DateTime* time);
void DateTime_FromTotalMs(DateTime* time, TimeMS ms);
void DateTime_HttpDate(TimeMS ms, String* str);
NOINLINE_ int Utils_ParseEnum(const String* text, int defValue, const char** names, int namesCount);
CC_NOINLINE int Utils_ParseEnum(const String* text, int defValue, const char** names, int namesCount);
bool Utils_IsValidInputChar(char c, bool supportsCP437);
bool Utils_IsUrlPrefix(const String* value, int index);
@ -37,6 +37,6 @@ 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];
NOINLINE_ void* Utils_Resize(void* buffer, uint32_t* maxElems, uint32_t elemSize, uint32_t defElems, uint32_t expandElems);
NOINLINE_ bool Utils_ParseIP(const String* ip, uint8_t* data);
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

@ -51,7 +51,7 @@ static void TextWidget_Reposition(void* widget) {
w->Texture.Y += w->Y - oldY;
}
struct WidgetVTABLE TextWidget_VTABLE = {
static struct WidgetVTABLE TextWidget_VTABLE = {
Widget_NullFunc, TextWidget_Render, TextWidget_Free, Gui_DefaultRecreate,
Widget_Key, Widget_Key, Widget_KeyPress,
Widget_Mouse, Widget_Mouse, Widget_MouseMove, Widget_MouseScroll,
@ -154,7 +154,7 @@ static void ButtonWidget_Render(void* widget, double delta) {
Texture_RenderShaded(&w->Texture, col);
}
struct WidgetVTABLE ButtonWidget_VTABLE = {
static struct WidgetVTABLE ButtonWidget_VTABLE = {
Widget_NullFunc, ButtonWidget_Render, ButtonWidget_Free, Gui_DefaultRecreate,
Widget_Key, Widget_Key, Widget_KeyPress,
Widget_Mouse, Widget_Mouse, Widget_MouseMove, Widget_MouseScroll,
@ -295,7 +295,7 @@ static bool ScrollbarWidget_MouseMove(void* widget, int x, int y) {
return false;
}
struct WidgetVTABLE ScrollbarWidget_VTABLE = {
static struct WidgetVTABLE ScrollbarWidget_VTABLE = {
Widget_NullFunc, ScrollbarWidget_Render, Widget_NullFunc, Gui_DefaultRecreate,
Widget_Key, Widget_Key, Widget_KeyPress,
ScrollbarWidget_MouseDown, ScrollbarWidget_MouseUp, ScrollbarWidget_MouseMove, ScrollbarWidget_MouseScroll,
@ -478,7 +478,7 @@ static bool HotbarWidget_MouseScroll(void* widget, float delta) {
return true;
}
struct WidgetVTABLE HotbarWidget_VTABLE = {
static struct WidgetVTABLE HotbarWidget_VTABLE = {
HotbarWidget_Init, HotbarWidget_Render, Widget_NullFunc, Gui_DefaultRecreate,
HotbarWidget_KeyDown, HotbarWidget_KeyUp, Widget_KeyPress,
HotbarWidget_MouseDown, Widget_Mouse, Widget_MouseMove, HotbarWidget_MouseScroll,
@ -812,7 +812,7 @@ static bool TableWidget_KeyDown(void* widget, Key key) {
return true;
}
struct WidgetVTABLE TableWidget_VTABLE = {
static struct WidgetVTABLE TableWidget_VTABLE = {
TableWidget_Init, TableWidget_Render, TableWidget_Free, TableWidget_Recreate,
TableWidget_KeyDown, Widget_Key, Widget_KeyPress,
TableWidget_MouseDown, TableWidget_MouseUp, TableWidget_MouseMove, TableWidget_MouseScroll,
@ -1261,7 +1261,7 @@ static bool InputWidget_MouseDown(void* widget, int x, int y, MouseButton button
return true;
}
NOINLINE_ static void InputWidget_Create(struct InputWidget* w, const FontDesc* font, STRING_REF const String* prefix) {
CC_NOINLINE static void InputWidget_Create(struct InputWidget* w, const FontDesc* font, STRING_REF const String* prefix) {
static String caret = String_FromConst("_");
struct DrawTextArgs args;
Size2D size;
@ -1306,7 +1306,7 @@ static bool Hex_ValidValue(struct MenuInputValidator* v, const String* s) {
return PackedCol_TryParseHex(s, &col);
}
struct MenuInputValidatorVTABLE HexInputValidator_VTABLE = {
static struct MenuInputValidatorVTABLE HexInputValidator_VTABLE = {
Hex_Range, Hex_ValidChar, Hex_ValidString, Hex_ValidValue,
};
struct MenuInputValidator MenuInputValidator_Hex(void) {
@ -1334,7 +1334,7 @@ static bool Int_ValidValue(struct MenuInputValidator* v, const String* s) {
return Convert_TryParseInt(s, &value) && min <= value && value <= max;
}
struct MenuInputValidatorVTABLE IntInputValidator_VTABLE = {
static struct MenuInputValidatorVTABLE IntInputValidator_VTABLE = {
Int_Range, Int_ValidChar, Int_ValidString, Int_ValidValue,
};
struct MenuInputValidator MenuInputValidator_Int(int min, int max) {
@ -1349,7 +1349,7 @@ static void Seed_Range(struct MenuInputValidator* v, String* range) {
String_AppendConst(range, "&7(an integer)");
}
struct MenuInputValidatorVTABLE SeedInputValidator_VTABLE = {
static struct MenuInputValidatorVTABLE SeedInputValidator_VTABLE = {
Seed_Range, Int_ValidChar, Int_ValidString, Int_ValidValue,
};
struct MenuInputValidator MenuInputValidator_Seed(void) {
@ -1377,7 +1377,7 @@ static bool Float_ValidValue(struct MenuInputValidator* v, const String* s) {
return Convert_TryParseFloat(s, &value) && min <= value && value <= max;
}
struct MenuInputValidatorVTABLE FloatInputValidator_VTABLE = {
static struct MenuInputValidatorVTABLE FloatInputValidator_VTABLE = {
Float_Range, Float_ValidChar, Float_ValidString, Float_ValidValue,
};
struct MenuInputValidator MenuInputValidator_Float(float min, float max) {
@ -1398,7 +1398,7 @@ static bool Path_ValidChar(struct MenuInputValidator* v, char c) {
}
static bool Path_ValidString(struct MenuInputValidator* v, const String* s) { return true; }
struct MenuInputValidatorVTABLE PathInputValidator_VTABLE = {
static struct MenuInputValidatorVTABLE PathInputValidator_VTABLE = {
Path_Range, Path_ValidChar, Path_ValidString, Path_ValidString,
};
struct MenuInputValidator MenuInputValidator_Path(void) {
@ -1427,7 +1427,7 @@ static bool String_ValidString(struct MenuInputValidator* v, const String* s) {
return s->length <= STRING_SIZE;
}
struct MenuInputValidatorVTABLE StringInputValidator_VTABLE = {
static struct MenuInputValidatorVTABLE StringInputValidator_VTABLE = {
String_Range, String_ValidChar, String_ValidString, String_ValidString,
};
struct MenuInputValidator MenuInputValidator_String(void) {
@ -1523,7 +1523,7 @@ static bool MenuInputWidget_AllowedChar(void* widget, char c) {
}
static int MenuInputWidget_GetMaxLines(void) { return 1; }
struct WidgetVTABLE MenuInputWidget_VTABLE = {
static struct WidgetVTABLE MenuInputWidget_VTABLE = {
InputWidget_Init, MenuInputWidget_Render, InputWidget_Free, InputWidget_Recreate,
InputWidget_KeyDown, InputWidget_KeyUp, InputWidget_KeyPress,
InputWidget_MouseDown, Widget_Mouse, Widget_MouseMove, Widget_MouseScroll,
@ -1773,7 +1773,7 @@ static int ChatInputWidget_GetMaxLines(void) {
return !Game_ClassicMode && ServerConnection_SupportsPartialMessages ? 3 : 1;
}
struct WidgetVTABLE ChatInputWidget_VTABLE = {
static struct WidgetVTABLE ChatInputWidget_VTABLE = {
InputWidget_Init, ChatInputWidget_Render, InputWidget_Free, InputWidget_Recreate,
ChatInputWidget_KeyDown, InputWidget_KeyUp, InputWidget_KeyPress,
InputWidget_MouseDown, Widget_Mouse, Widget_MouseMove, Widget_MouseScroll,
@ -2165,7 +2165,7 @@ static void PlayerListWidget_Free(void* widget) {
Event_UnregisterInt(&TabListEvents_Removed, w, PlayerListWidget_TabEntryRemoved);
}
struct WidgetVTABLE PlayerListWidget_VTABLE = {
static struct WidgetVTABLE PlayerListWidget_VTABLE = {
PlayerListWidget_Init, PlayerListWidget_Render, PlayerListWidget_Free, Gui_DefaultRecreate,
Widget_Key, Widget_Key, Widget_KeyPress,
Widget_Mouse, Widget_Mouse, Widget_MouseMove, Widget_MouseScroll,
@ -2606,7 +2606,7 @@ static void TextGroupWidget_Free(void* widget) {
}
}
struct WidgetVTABLE TextGroupWidget_VTABLE = {
static struct WidgetVTABLE TextGroupWidget_VTABLE = {
TextGroupWidget_Init, TextGroupWidget_Render, TextGroupWidget_Free, Gui_DefaultRecreate,
Widget_Key, Widget_Key, Widget_KeyPress,
Widget_Mouse, Widget_Mouse, Widget_MouseMove, Widget_MouseScroll,
@ -2858,7 +2858,7 @@ void SpecialInputWidget_SetActive(struct SpecialInputWidget* w, bool active) {
if (active && w->PendingRedraw) SpecialInputWidget_Redraw(w);
}
struct WidgetVTABLE SpecialInputWidget_VTABLE = {
static struct WidgetVTABLE SpecialInputWidget_VTABLE = {
SpecialInputWidget_Init, SpecialInputWidget_Render, SpecialInputWidget_Free, Gui_DefaultRecreate,
Widget_Key, Widget_Key, Widget_KeyPress,
SpecialInputWidget_MouseDown, Widget_Mouse, Widget_MouseMove, Widget_MouseScroll,

View file

@ -15,9 +15,9 @@ struct TextWidget {
bool ReducePadding;
PackedCol Col;
};
NOINLINE_ void TextWidget_Make(struct TextWidget* w);
NOINLINE_ void TextWidget_Create(struct TextWidget* w, const String* text, const FontDesc* font);
NOINLINE_ void TextWidget_Set(struct TextWidget* w, const String* text, const FontDesc* font);
CC_NOINLINE void TextWidget_Make(struct TextWidget* w);
CC_NOINLINE void TextWidget_Create(struct TextWidget* w, const String* text, const FontDesc* font);
CC_NOINLINE void TextWidget_Set(struct TextWidget* w, const String* text, const FontDesc* font);
typedef void (*Button_Get)(String* raw);
@ -31,8 +31,8 @@ struct ButtonWidget {
Button_Get GetValue;
Button_Set SetValue;
};
NOINLINE_ void ButtonWidget_Create(struct ButtonWidget* w, int minWidth, const String* text, const FontDesc* font, Widget_LeftClick onClick);
NOINLINE_ void ButtonWidget_Set(struct ButtonWidget* w, const String* text, const FontDesc* font);
CC_NOINLINE void ButtonWidget_Create(struct ButtonWidget* w, int minWidth, const String* text, const FontDesc* font, Widget_LeftClick onClick);
CC_NOINLINE void ButtonWidget_Set(struct ButtonWidget* w, const String* text, const FontDesc* font);
struct ScrollbarWidget {
@ -42,7 +42,7 @@ struct ScrollbarWidget {
int MouseOffset;
bool DraggingMouse;
};
NOINLINE_ void ScrollbarWidget_Create(struct ScrollbarWidget* w);
CC_NOINLINE void ScrollbarWidget_Create(struct ScrollbarWidget* w);
struct HotbarWidget {
@ -53,7 +53,7 @@ struct HotbarWidget {
float ScrollAcc;
bool AltHandled;
};
NOINLINE_ void HotbarWidget_Create(struct HotbarWidget* w);
CC_NOINLINE void HotbarWidget_Create(struct HotbarWidget* w);
struct TableWidget {
@ -72,10 +72,10 @@ struct TableWidget {
int LastX, LastY;
};
NOINLINE_ void TableWidget_Create(struct TableWidget* w);
NOINLINE_ void TableWidget_SetBlockTo(struct TableWidget* w, BlockID block);
NOINLINE_ void TableWidget_OnInventoryChanged(struct TableWidget* w);
NOINLINE_ void TableWidget_MakeDescTex(struct TableWidget* w, BlockID block);
CC_NOINLINE void TableWidget_Create(struct TableWidget* w);
CC_NOINLINE void TableWidget_SetBlockTo(struct TableWidget* w, BlockID block);
CC_NOINLINE void TableWidget_OnInventoryChanged(struct TableWidget* w);
CC_NOINLINE void TableWidget_MakeDescTex(struct TableWidget* w, BlockID block);
#define INPUTWIDGET_MAX_LINES 3
@ -106,9 +106,9 @@ struct InputWidget {
double CaretAccumulator;
};
NOINLINE_ void InputWidget_Clear(struct InputWidget* w);
NOINLINE_ void InputWidget_AppendString(struct InputWidget* w, const String* text);
NOINLINE_ void InputWidget_Append(struct InputWidget* w, char c);
CC_NOINLINE void InputWidget_Clear(struct InputWidget* w);
CC_NOINLINE void InputWidget_AppendString(struct InputWidget* w, const String* text);
CC_NOINLINE void InputWidget_Append(struct InputWidget* w, char c);
struct MenuInputValidator;
@ -142,7 +142,7 @@ struct MenuInputWidget {
struct MenuInputValidator Validator;
char __TextBuffer[INPUTWIDGET_LEN];
};
NOINLINE_ void MenuInputWidget_Create(struct MenuInputWidget* w, int width, int height, const String* text, const FontDesc* font, struct MenuInputValidator* v);
CC_NOINLINE void MenuInputWidget_Create(struct MenuInputWidget* w, int width, int height, const String* text, const FontDesc* font, struct MenuInputValidator* v);
struct ChatInputWidget {
@ -153,7 +153,7 @@ struct ChatInputWidget {
String OrigStr;
};
NOINLINE_ void ChatInputWidget_Create(struct ChatInputWidget* w, const FontDesc* font);
CC_NOINLINE void ChatInputWidget_Create(struct ChatInputWidget* w, const FontDesc* font);
#define TEXTGROUPWIDGET_MAX_LINES 30
@ -168,13 +168,13 @@ struct TextGroupWidget {
char* Buffer;
};
NOINLINE_ void TextGroupWidget_Create(struct TextGroupWidget* w, int lines, const FontDesc* font, const FontDesc* ulFont, STRING_REF struct Texture* textures, STRING_REF char* buffer);
NOINLINE_ void TextGroupWidget_SetUsePlaceHolder(struct TextGroupWidget* w, int index, bool placeHolder);
NOINLINE_ void TextGroupWidget_PushUpAndReplaceLast(struct TextGroupWidget* w, const String* text);
NOINLINE_ int TextGroupWidget_UsedHeight(struct TextGroupWidget* w);
NOINLINE_ void TextGroupWidget_GetSelected(struct TextGroupWidget* w, String* text, int mouseX, int mouseY);
NOINLINE_ void TextGroupWidget_GetText(struct TextGroupWidget* w, int index, String* text);
NOINLINE_ void TextGroupWidget_SetText(struct TextGroupWidget* w, int index, const String* text);
CC_NOINLINE void TextGroupWidget_Create(struct TextGroupWidget* w, int lines, const FontDesc* font, const FontDesc* ulFont, STRING_REF struct Texture* textures, STRING_REF char* buffer);
CC_NOINLINE void TextGroupWidget_SetUsePlaceHolder(struct TextGroupWidget* w, int index, bool placeHolder);
CC_NOINLINE void TextGroupWidget_PushUpAndReplaceLast(struct TextGroupWidget* w, const String* text);
CC_NOINLINE int TextGroupWidget_UsedHeight(struct TextGroupWidget* w);
CC_NOINLINE void TextGroupWidget_GetSelected(struct TextGroupWidget* w, String* text, int mouseX, int mouseY);
CC_NOINLINE void TextGroupWidget_GetText(struct TextGroupWidget* w, int index, String* text);
CC_NOINLINE void TextGroupWidget_SetText(struct TextGroupWidget* w, int index, const String* text);
struct PlayerListWidget {
@ -187,8 +187,8 @@ struct PlayerListWidget {
uint16_t IDs[TABLIST_MAX_NAMES * 2];
struct Texture Textures[TABLIST_MAX_NAMES * 2];
};
NOINLINE_ void PlayerListWidget_Create(struct PlayerListWidget* w, const FontDesc* font, bool classic);
NOINLINE_ void PlayerListWidget_GetNameUnder(struct PlayerListWidget* w, int mouseX, int mouseY, String* name);
CC_NOINLINE void PlayerListWidget_Create(struct PlayerListWidget* w, const FontDesc* font, bool classic);
CC_NOINLINE void PlayerListWidget_GetNameUnder(struct PlayerListWidget* w, int mouseX, int mouseY, String* name);
typedef void (*SpecialInputAppendFunc)(void* userData, char c);
@ -211,7 +211,7 @@ struct SpecialInputWidget {
char __ColBuffer[DRAWER2D_MAX_COLS * 4];
};
NOINLINE_ void SpecialInputWidget_Create(struct SpecialInputWidget* w, const FontDesc* font, struct InputWidget* appendObj);
NOINLINE_ void SpecialInputWidget_UpdateCols(struct SpecialInputWidget* w);
NOINLINE_ void SpecialInputWidget_SetActive(struct SpecialInputWidget* w, bool active);
CC_NOINLINE void SpecialInputWidget_Create(struct SpecialInputWidget* w, const FontDesc* font, struct InputWidget* appendObj);
CC_NOINLINE void SpecialInputWidget_UpdateCols(struct SpecialInputWidget* w);
CC_NOINLINE void SpecialInputWidget_SetActive(struct SpecialInputWidget* w, bool active);
#endif

View file

@ -149,15 +149,6 @@ void Env_Reset(void) {
Env_SkyboxHorSpeed = 0.0f;
Env_SkyboxVerSpeed = 0.0f;
Env_ResetLight();
Env_SkyCol = Env_DefaultSkyCol;
Env_FogCol = Env_DefaultFogCol;
Env_CloudsCol = Env_DefaultCloudsCol;
Env_Weather = WEATHER_SUNNY;
Env_ExpFog = false;
}
void Env_ResetLight(void) {
Env_ShadowCol = Env_DefaultShadowCol;
PackedCol_GetShaded(Env_ShadowCol, &Env_ShadowXSide,
&Env_ShadowZSide, &Env_ShadowYMin);
@ -165,6 +156,12 @@ void Env_ResetLight(void) {
Env_SunCol = Env_DefaultSunCol;
PackedCol_GetShaded(Env_SunCol, &Env_SunXSide,
&Env_SunZSide, &Env_SunYMin);
Env_SkyCol = Env_DefaultSkyCol;
Env_FogCol = Env_DefaultFogCol;
Env_CloudsCol = Env_DefaultCloudsCol;
Env_Weather = WEATHER_SUNNY;
Env_ExpFog = false;
}

View file

@ -23,8 +23,12 @@ int World_OneY;
uint8_t World_Uuid[16];
extern String World_TextureUrl;
void World_Reset(void);
void World_SetNewMap(BlockRaw* blocks, int blocksSize, int width, int height, int length);
/* Frees the blocks array, sets dimensions to 0, resets environment to default. */
CC_EXPORT void World_Reset(void);
/* Sets the blocks array and dimensions of the map. */
/* May also sets some environment settings like border/clouds height, if they are -1 */
/* NOTE: Exits the game if size vs dimensions are inconsistent. */
CC_EXPORT void World_SetNewMap(BlockRaw* blocks, int blocksSize, int width, int height, int length);
#ifdef EXTENDED_BLOCKS
extern int Block_IDMask;
@ -76,32 +80,58 @@ extern PackedCol Env_DefaultSunCol, Env_DefaultShadowCol;
#define ENV_DEFAULT_SUNCOL_HEX "FFFFFF"
#define ENV_DEFAULT_SHADOWCOL_HEX "9B9B9B"
void Env_Reset(void);
void Env_ResetLight(void);
void Env_SetEdgeBlock(BlockID block);
void Env_SetSidesBlock(BlockID block);
void Env_SetEdgeHeight(int height);
void Env_SetSidesOffset(int offset);
void Env_SetCloudsHeight(int height);
void Env_SetCloudsSpeed(float speed);
/* Resets all environment settings to default. */
/* NOTE: Unlike Env_Set functions, DOES NOT raise EnvVarChanged event. */
CC_EXPORT void Env_Reset(void);
/* Sets the edge/horizon block. (default water) */
CC_EXPORT void Env_SetEdgeBlock(BlockID block);
/* Sets the sides/border block. (default bedrock) */
CC_EXPORT void Env_SetSidesBlock(BlockID block);
/* Sets the edge/horizon height. (default height/2) */
CC_EXPORT void Env_SetEdgeHeight(int height);
/* Sets offset of sides/border from horizon. (default -2) */
CC_EXPORT void Env_SetSidesOffset(int offset);
/* Sets clouds height. (default height+2)*/
CC_EXPORT void Env_SetCloudsHeight(int height);
/* Sets how fast clouds move. (default 1) */
/* Negative speeds move in opposite direction. */
CC_EXPORT void Env_SetCloudsSpeed(float speed);
void Env_SetWeatherSpeed(float speed);
void Env_SetWeatherFade(float rate);
void Env_SetWeather(int weather);
void Env_SetExpFog(bool expFog);
void Env_SetSkyboxHorSpeed(float speed);
void Env_SetSkyboxVerSpeed(float speed);
/* Sets how fast rain/snow falls. (default 1) */
/* Negative speeds makes rain/snow fall upwards. */
CC_EXPORT void Env_SetWeatherSpeed(float speed);
/* Sets how quickly rain/snow fades over distance. (default 1) */
CC_EXPORT void Env_SetWeatherFade(float rate);
/* Sets the weather of the map. (default sun) */
/* Can be sun/rain/snow, see WEATHER_ enum. */
CC_EXPORT void Env_SetWeather(int weather);
/* Sets whether exponential/smooth fog is used. (default false) */
CC_EXPORT void Env_SetExpFog(bool expFog);
/* Sets how quickly skybox rotates/spins horizontally. (default 0) */
/* speed is in rotations/second, so '2' completes two full spins per second. */
CC_EXPORT void Env_SetSkyboxHorSpeed(float speed);
/* Sets how quickly skybox rotates/spins vertically. (default 0) */
/* speed is in rotations/second, so '2' completes two full spins per second. */
CC_EXPORT void Env_SetSkyboxVerSpeed(float speed);
void Env_SetSkyCol(PackedCol col);
void Env_SetFogCol(PackedCol col);
void Env_SetCloudsCol(PackedCol col);
void Env_SetSunCol(PackedCol col);
void Env_SetShadowCol(PackedCol col);
/* Sets colour of the sky above clouds. (default #99CCFF) */
CC_EXPORT void Env_SetSkyCol(PackedCol col);
/* Sets base colour of the horizon fog. (default #FFFFFF) */
/* Actual fog colour is blended between sky and fog colours, based on view distance. */
CC_EXPORT void Env_SetFogCol(PackedCol col);
/* Sets colour of the clouds and skybox. (default #FFFFFF) */
CC_EXPORT void Env_SetCloudsCol(PackedCol col);
/* Sets colour of sunlight. (default #FFFFFF) */
/* This is the colour used for lighting when not underground. */
CC_EXPORT void Env_SetSunCol(PackedCol col);
/* Sets colour of shadow. (default #9B9B9B) */
/* This is the colour used for lighting when underground. */
CC_EXPORT void Env_SetShadowCol(PackedCol col);
#define RESPAWN_NOT_FOUND -100000.0f
/* Finds the highest free Y coordinate in the given bounding box */
float Respawn_HighestFreeY(struct AABB* bb);
/* Finds a suitable spawn position for the entity, by iterating
downwards from top of the world until the ground is found */
/* Finds a suitable spawn position for the entity. */
/* Works by iterating downwards from top of world until ground is found. */
Vector3 Respawn_FindSpawnPosition(float x, float z, Vector3 modelSize);
#endif