Minor style fixes

This commit is contained in:
UnknownShadow200 2020-05-09 14:42:01 +10:00
parent 8d6bce32ff
commit 96676fb374
18 changed files with 76 additions and 76 deletions

View File

@ -54,7 +54,7 @@ void Audio_PlayStepSound(cc_uint8 type) { }
#include <AL/alc.h>
#endif
#endif
static StringsBuffer files;
static struct StringsBuffer files;
static void Volume_Mix16(cc_int16* samples, int count, int volume) {
int i;
@ -507,7 +507,7 @@ static struct SoundGroup* Soundboard_Find(struct Soundboard* board, const String
return NULL;
}
static void Soundboard_Init(struct Soundboard* board, const String* boardName, StringsBuffer* files) {
static void Soundboard_Init(struct Soundboard* board, const String* boardName, struct StringsBuffer* files) {
String file, name;
struct SoundGroup* group;
struct Sound* snd;

View File

@ -381,8 +381,8 @@ cc_result Png_Decode(Bitmap* bmp, struct Stream* stream) {
for (;;) {
res = Stream_Read(stream, tmp, 8);
if (res) return res;
dataSize = Stream_GetU32_BE(&tmp[0]);
fourCC = Stream_GetU32_BE(&tmp[4]);
dataSize = Stream_GetU32_BE(tmp + 0);
fourCC = Stream_GetU32_BE(tmp + 4);
switch (fourCC) {
case PNG_FourCC('I','H','D','R'): {
@ -390,8 +390,8 @@ cc_result Png_Decode(Bitmap* bmp, struct Stream* stream) {
res = Stream_Read(stream, tmp, PNG_IHDR_SIZE);
if (res) return res;
bmp->Width = (int)Stream_GetU32_BE(&tmp[0]);
bmp->Height = (int)Stream_GetU32_BE(&tmp[4]);
bmp->Width = (int)Stream_GetU32_BE(tmp + 0);
bmp->Height = (int)Stream_GetU32_BE(tmp + 4);
if (bmp->Width < 0 || bmp->Width > PNG_MAX_DIMS) return PNG_ERR_TOO_WIDE;
if (bmp->Height < 0 || bmp->Height > PNG_MAX_DIMS) return PNG_ERR_TOO_TALL;
@ -465,7 +465,7 @@ cc_result Png_Decode(Bitmap* bmp, struct Stream* stream) {
inflate.Source = &datStream;
/* TODO: This assumes zlib header will be in 1 IDAT chunk */
while (!zlibHeader.Done) {
while (!zlibHeader.done) {
if ((res = ZLibHeader_Read(&datStream, &zlibHeader))) return res;
}
if (!bmp->Scan0) return PNG_ERR_NO_DATA;

View File

@ -25,7 +25,7 @@ String Chat_ClientStatus[2] = { String_FromArray(msgs[7]), String_FromArray(msgs
String Chat_Announcement = String_FromArray(msgs[9]);
double Chat_AnnouncementReceived;
StringsBuffer Chat_Log, Chat_InputLog;
struct StringsBuffer Chat_Log, Chat_InputLog;
cc_bool Chat_Logging;
/*########################################################################################################################*

View File

@ -22,11 +22,11 @@ enum MsgType {
extern String Chat_Status[4], Chat_BottomRight[3], Chat_ClientStatus[2], Chat_Announcement;
/* All chat messages received. */
extern StringsBuffer Chat_Log;
extern struct StringsBuffer Chat_Log;
/* Time each chat message was received at. */
extern double* Chat_LogTime;
/* All chat entered by the user. */
extern StringsBuffer Chat_InputLog;
extern struct StringsBuffer Chat_InputLog;
/* Whether chat messages are logged to disc. */
extern cc_bool Chat_Logging;

View File

@ -17,80 +17,80 @@ enum GzipState {
};
void GZipHeader_Init(struct GZipHeader* header) {
header->State = GZIP_STATE_HEADER1;
header->Done = false;
header->Flags = 0;
header->PartsRead = 0;
header->state = GZIP_STATE_HEADER1;
header->done = false;
header->flags = 0;
header->partsRead = 0;
}
cc_result GZipHeader_Read(struct Stream* s, struct GZipHeader* header) {
cc_uint8 tmp;
cc_result res;
switch (header->State) {
switch (header->state) {
case GZIP_STATE_HEADER1:
Header_ReadU8(tmp);
if (tmp != 0x1F) return GZIP_ERR_HEADER1;
header->State++;
header->state++;
case GZIP_STATE_HEADER2:
Header_ReadU8(tmp);
if (tmp != 0x8B) return GZIP_ERR_HEADER2;
header->State++;
header->state++;
case GZIP_STATE_COMPRESSIONMETHOD:
Header_ReadU8(tmp);
if (tmp != 0x08) return GZIP_ERR_METHOD;
header->State++;
header->state++;
case GZIP_STATE_FLAGS:
Header_ReadU8(tmp);
header->Flags = tmp;
if (header->Flags & 0x04) return GZIP_ERR_FLAGS;
header->State++;
header->flags = tmp;
if (header->flags & 0x04) return GZIP_ERR_FLAGS;
header->state++;
case GZIP_STATE_LASTMODIFIED:
for (; header->PartsRead < 4; header->PartsRead++) {
for (; header->partsRead < 4; header->partsRead++) {
Header_ReadU8(tmp);
}
header->State++;
header->PartsRead = 0;
header->state++;
header->partsRead = 0;
case GZIP_STATE_COMPRESSIONFLAGS:
Header_ReadU8(tmp);
header->State++;
header->state++;
case GZIP_STATE_OPERATINGSYSTEM:
Header_ReadU8(tmp);
header->State++;
header->state++;
case GZIP_STATE_FILENAME:
if (header->Flags & 0x08) {
if (header->flags & 0x08) {
for (; ;) {
Header_ReadU8(tmp);
if (tmp == '\0') break;
}
}
header->State++;
header->state++;
case GZIP_STATE_COMMENT:
if (header->Flags & 0x10) {
if (header->flags & 0x10) {
for (; ;) {
Header_ReadU8(tmp);
if (tmp == '\0') break;
}
}
header->State++;
header->state++;
case GZIP_STATE_HEADERCHECKSUM:
if (header->Flags & 0x02) {
for (; header->PartsRead < 2; header->PartsRead++) {
if (header->flags & 0x02) {
for (; header->partsRead < 2; header->partsRead++) {
Header_ReadU8(tmp);
}
}
header->State++;
header->PartsRead = 0;
header->Done = true;
header->state++;
header->partsRead = 0;
header->done = true;
}
return 0;
}
@ -102,27 +102,27 @@ cc_result GZipHeader_Read(struct Stream* s, struct GZipHeader* header) {
enum ZlibState { ZLIB_STATE_COMPRESSIONMETHOD, ZLIB_STATE_FLAGS, ZLIB_STATE_DONE };
void ZLibHeader_Init(struct ZLibHeader* header) {
header->State = ZLIB_STATE_COMPRESSIONMETHOD;
header->Done = false;
header->state = ZLIB_STATE_COMPRESSIONMETHOD;
header->done = false;
}
cc_result ZLibHeader_Read(struct Stream* s, struct ZLibHeader* header) {
cc_uint8 tmp;
cc_result res;
switch (header->State) {
switch (header->state) {
case ZLIB_STATE_COMPRESSIONMETHOD:
Header_ReadU8(tmp);
if ((tmp & 0x0F) != 0x08) return ZLIB_ERR_METHOD;
if ((tmp >> 4) > 7) return ZLIB_ERR_WINDOW_SIZE;
/* 2^(size + 8) must be < 32768 for LZ77 window */
header->State++;
header->state++;
case ZLIB_STATE_FLAGS:
Header_ReadU8(tmp);
if (tmp & 0x20) return ZLIB_ERR_FLAGS;
header->State++;
header->Done = true;
header->state++;
header->done = true;
}
return 0;
}

View File

@ -11,11 +11,11 @@
*/
struct Stream;
struct GZipHeader { cc_uint8 State; cc_bool Done; cc_uint8 PartsRead; cc_int32 Flags; };
struct GZipHeader { cc_uint8 state; cc_bool done; cc_uint8 partsRead; cc_int32 flags; };
void GZipHeader_Init(struct GZipHeader* header);
cc_result GZipHeader_Read(struct Stream* s, struct GZipHeader* header);
struct ZLibHeader { cc_uint8 State; cc_bool Done; };
struct ZLibHeader { cc_uint8 state; cc_bool done; };
void ZLibHeader_Init(struct ZLibHeader* header);
cc_result ZLibHeader_Read(struct Stream* s, struct ZLibHeader* header);

View File

@ -693,7 +693,7 @@ struct IGameComponent Drawer2D_Component = {
*---------------------------------------------------Drawer2D component----------------------------------------------------*
*#########################################################################################################################*/
#ifdef CC_BUILD_WEB
void Font_GetNames(StringsBuffer* buffer) { }
void Font_GetNames(struct StringsBuffer* buffer) { }
String Font_Lookup(const String* fontName, int style) {
String str = String_FromConst("-----"); return str;
}
@ -926,7 +926,7 @@ void SysFonts_Register(const String* path) {
}
}
void Font_GetNames(StringsBuffer* buffer) {
void Font_GetNames(struct StringsBuffer* buffer) {
String entry, name, path;
int i;
if (!font_list.entries.count) SysFonts_Init();

View File

@ -93,7 +93,7 @@ void Drawer2D_ReducePadding_Height(int* height, int point, int scale);
cc_bool Drawer2D_SetFontBitmap(Bitmap* bmp);
/* Gets the list of all supported system font names on this platform. */
void Font_GetNames(StringsBuffer* buffer);
void Font_GetNames(struct StringsBuffer* buffer);
/* Reduces padding for a bitmapped font. */
void Font_ReducePadding(struct FontDesc* desc, int scale);
/* Finds the path and face number of the given system font, with closest matching style */

View File

@ -157,7 +157,7 @@ CC_VAR extern struct _TabListData {
cc_uint16 NameOffsets[TABLIST_MAX_NAMES];
/* Position/Order of this entry within the group. */
cc_uint8 GroupRanks[TABLIST_MAX_NAMES];
StringsBuffer _buffer;
struct StringsBuffer _buffer;
} TabList;
/* Removes the tab list entry with the given ID, raising TabListEvents.Removed event. */

View File

@ -33,7 +33,7 @@ static cc_result Map_SkipGZipHeader(struct Stream* stream) {
cc_result res;
GZipHeader_Init(&gzHeader);
while (!gzHeader.Done) {
while (!gzHeader.done) {
if ((res = GZipHeader_Read(stream, &gzHeader))) return res;
}
return 0;

View File

@ -374,7 +374,7 @@ const cc_uint8 Hotkeys_LWJGL[256] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
struct HotkeyData HotkeysList[HOTKEYS_MAX_COUNT];
StringsBuffer HotkeysText;
struct StringsBuffer HotkeysText;
static void Hotkeys_QuickSort(int left, int right) {
struct HotkeyData* keys = HotkeysList; struct HotkeyData key;

View File

@ -135,7 +135,7 @@ struct HotkeyData {
#define HOTKEYS_MAX_COUNT 256
extern struct HotkeyData HotkeysList[HOTKEYS_MAX_COUNT];
extern StringsBuffer HotkeysText;
extern struct StringsBuffer HotkeysText;
enum HotkeyModifiers {
HOTKEY_MOD_CTRL = 1, HOTKEY_MOD_SHIFT = 2, HOTKEY_MOD_ALT = 4
};

View File

@ -235,7 +235,7 @@ static struct ListScreen {
void (*UpdateEntry)(struct ListScreen* s, struct ButtonWidget* btn, const String* text);
const char* titleText;
struct TextWidget title, page;
StringsBuffer entries;
struct StringsBuffer entries;
} ListScreen;
static struct Widget* list_widgets[10] = {
@ -314,7 +314,7 @@ static void ListScreen_MoveForwards(void* screen, void* b) {
}
static void ListScreen_QuickSort(int left, int right) {
StringsBuffer* buffer = &ListScreen.entries;
struct StringsBuffer* buffer = &ListScreen.entries;
cc_uint32* keys = buffer->flagsBuffer; cc_uint32 key;
while (left < right) {
@ -1512,7 +1512,7 @@ static void TexturePackScreen_FilterFiles(const String* path, void* obj) {
if (!String_CaselessEnds(path, &zip)) return;
Utils_UNSAFE_TrimFirstDirectory(&relPath);
StringsBuffer_Add((StringsBuffer*)obj, &relPath);
StringsBuffer_Add((struct StringsBuffer*)obj, &relPath);
}
static void TexturePackScreen_LoadEntries(struct ListScreen* s) {
@ -1674,7 +1674,7 @@ static void LoadLevelScreen_FilterFiles(const String* path, void* obj) {
if (!importer) return;
Utils_UNSAFE_TrimFirstDirectory(&relPath);
StringsBuffer_Add((StringsBuffer*)obj, &relPath);
StringsBuffer_Add((struct StringsBuffer*)obj, &relPath);
}
static void LoadLevelScreen_LoadEntries(struct ListScreen* s) {

View File

@ -9,21 +9,21 @@
#include "Logger.h"
struct EntryList Options;
static StringsBuffer Options_Changed;
static struct StringsBuffer changedOpts;
int Options_ChangedCount(void) { return Options_Changed.count; }
int Options_ChangedCount(void) { return changedOpts.count; }
void Options_Free(void) {
StringsBuffer_Clear(&Options.entries);
StringsBuffer_Clear(&Options_Changed);
StringsBuffer_Clear(&changedOpts);
}
cc_bool Options_HasChanged(const String* key) {
String entry;
int i;
for (i = 0; i < Options_Changed.count; i++) {
entry = StringsBuffer_UNSAFE_Get(&Options_Changed, i);
for (i = 0; i < changedOpts.count; i++) {
entry = StringsBuffer_UNSAFE_Get(&changedOpts, i);
if (String_CaselessEquals(&entry, key)) return true;
}
return false;
@ -125,7 +125,7 @@ void Options_SetString(const String* key, const String* value) {
#endif
if (Options_HasChanged(key)) return;
StringsBuffer_Add(&Options_Changed, key);
StringsBuffer_Add(&changedOpts, key);
}
static cc_bool Options_LoadFilter(const String* entry) {
@ -158,7 +158,7 @@ void Options_Load(void) {
void Options_Save(void) {
EntryList_Save(&Options);
StringsBuffer_Clear(&Options_Changed);
StringsBuffer_Clear(&changedOpts);
}
void Options_SetSecure(const char* opt, const String* src, const String* key) {

View File

@ -460,7 +460,7 @@ static void Classic_LevelInit(cc_uint8* data) {
/* Fast map puts volume in header, and uses raw DEFLATE without GZIP header/footer */
map_volume = Stream_GetU32_BE(data);
map_gzHeader.Done = true;
map_gzHeader.done = true;
map_sizeIndex = 4;
}
@ -483,12 +483,12 @@ static void Classic_LevelDataChunk(cc_uint8* data) {
data += 1024;
value = *data; /* progress in original classic, but we ignore it */
if (!map_gzHeader.Done) {
if (!map_gzHeader.done) {
res = GZipHeader_Read(&map_part, &map_gzHeader);
if (res && res != ERR_END_OF_STREAM) Logger_Abort2(res, "reading map data");
}
if (map_gzHeader.Done) {
if (map_gzHeader.done) {
if (map_sizeIndex < 4) {
left = 4 - map_sizeIndex;
map.stream.Read(&map.stream, &map_size[map_sizeIndex], left, &read);

View File

@ -743,7 +743,7 @@ cc_bool Convert_ParseBool(const String* str, cc_bool* value) {
*#########################################################################################################################*/
#define STRINGSBUFFER_BUFFER_EXPAND_SIZE 8192
CC_NOINLINE static void StringsBuffer_Init(StringsBuffer* buffer) {
CC_NOINLINE static void StringsBuffer_Init(struct StringsBuffer* buffer) {
buffer->count = 0;
buffer->totalLength = 0;
buffer->textBuffer = buffer->_defaultBuffer;
@ -752,7 +752,7 @@ CC_NOINLINE static void StringsBuffer_Init(StringsBuffer* buffer) {
buffer->_flagsCapacity = STRINGSBUFFER_FLAGS_DEF_ELEMS;
}
void StringsBuffer_Clear(StringsBuffer* buffer) {
void StringsBuffer_Clear(struct StringsBuffer* buffer) {
/* Never initialised to begin with */
if (!buffer->_flagsCapacity) return;
@ -765,7 +765,7 @@ void StringsBuffer_Clear(StringsBuffer* buffer) {
StringsBuffer_Init(buffer);
}
String StringsBuffer_UNSAFE_Get(StringsBuffer* buffer, int i) {
String StringsBuffer_UNSAFE_Get(struct StringsBuffer* buffer, int i) {
cc_uint32 flags, offset, len;
if (i < 0 || i >= buffer->count) Logger_Abort("Tried to get String past StringsBuffer end");
@ -775,7 +775,7 @@ String StringsBuffer_UNSAFE_Get(StringsBuffer* buffer, int i) {
return String_Init(&buffer->textBuffer[offset], len, len);
}
void StringsBuffer_Add(StringsBuffer* buffer, const String* str) {
void StringsBuffer_Add(struct StringsBuffer* buffer, const String* str) {
int textOffset;
/* StringsBuffer hasn't been initalised yet, do it here */
if (!buffer->_flagsCapacity) StringsBuffer_Init(buffer);
@ -802,7 +802,7 @@ void StringsBuffer_Add(StringsBuffer* buffer, const String* str) {
buffer->totalLength += str->length;
}
void StringsBuffer_Remove(StringsBuffer* buffer, int index) {
void StringsBuffer_Remove(struct StringsBuffer* buffer, int index) {
cc_uint32 flags, offset, len;
cc_uint32 i, offsetAdj;
if (index < 0 || index >= buffer->count) Logger_Abort("Tried to remove String past StringsBuffer end");

View File

@ -205,7 +205,7 @@ CC_API cc_bool Convert_ParseBool(const String* str, cc_bool* value);
#define STRINGSBUFFER_LEN_SHIFT 9
#define STRINGSBUFFER_LEN_MASK 0x1FFUL
typedef struct StringsBuffer_ {
struct StringsBuffer {
char* textBuffer; /* Raw characters of all entries */
cc_uint32* flagsBuffer; /* Private flags for each entry */
int count, totalLength;
@ -213,17 +213,17 @@ typedef struct StringsBuffer_ {
int _textCapacity, _flagsCapacity;
char _defaultBuffer[STRINGSBUFFER_BUFFER_DEF_SIZE];
cc_uint32 _defaultFlags[STRINGSBUFFER_FLAGS_DEF_ELEMS];
} StringsBuffer;
};
/* Resets counts to 0, and frees any allocated memory. */
CC_API void StringsBuffer_Clear(StringsBuffer* buffer);
CC_API void StringsBuffer_Clear(struct StringsBuffer* buffer);
/* UNSAFE: Returns a direct pointer to the i'th string in the given buffer. */
/* You MUST NOT change the characters of this string. Copy to another string if necessary.*/
CC_API STRING_REF String StringsBuffer_UNSAFE_Get(StringsBuffer* buffer, int i);
CC_API STRING_REF String StringsBuffer_UNSAFE_Get(struct StringsBuffer* buffer, int i);
/* Adds a given string to the end of the given buffer. */
CC_API void StringsBuffer_Add(StringsBuffer* buffer, const String* str);
CC_API void StringsBuffer_Add(struct StringsBuffer* buffer, const String* str);
/* Removes the i'th string from the given buffer, shifting following strings downwards. */
CC_API void StringsBuffer_Remove(StringsBuffer* buffer, int index);
CC_API void StringsBuffer_Remove(struct StringsBuffer* buffer, int index);
/* Performs line wrapping on the given string. */
/* e.g. "some random tex|t* (| is lineLen) becomes "some random" "text" */

View File

@ -57,7 +57,7 @@ int Convert_FromBase64(const char* src, int len, cc_uint8* dst);
struct EntryList {
const char* path;
char separator;
StringsBuffer entries;
struct StringsBuffer entries;
};
typedef cc_bool (*EntryList_Filter)(const String* entry);