mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-15 10:35:11 -04:00
Minor style fixes
This commit is contained in:
parent
8d6bce32ff
commit
96676fb374
@ -54,7 +54,7 @@ void Audio_PlayStepSound(cc_uint8 type) { }
|
|||||||
#include <AL/alc.h>
|
#include <AL/alc.h>
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
static StringsBuffer files;
|
static struct StringsBuffer files;
|
||||||
|
|
||||||
static void Volume_Mix16(cc_int16* samples, int count, int volume) {
|
static void Volume_Mix16(cc_int16* samples, int count, int volume) {
|
||||||
int i;
|
int i;
|
||||||
@ -507,7 +507,7 @@ static struct SoundGroup* Soundboard_Find(struct Soundboard* board, const String
|
|||||||
return NULL;
|
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;
|
String file, name;
|
||||||
struct SoundGroup* group;
|
struct SoundGroup* group;
|
||||||
struct Sound* snd;
|
struct Sound* snd;
|
||||||
|
10
src/Bitmap.c
10
src/Bitmap.c
@ -381,8 +381,8 @@ cc_result Png_Decode(Bitmap* bmp, struct Stream* stream) {
|
|||||||
for (;;) {
|
for (;;) {
|
||||||
res = Stream_Read(stream, tmp, 8);
|
res = Stream_Read(stream, tmp, 8);
|
||||||
if (res) return res;
|
if (res) return res;
|
||||||
dataSize = Stream_GetU32_BE(&tmp[0]);
|
dataSize = Stream_GetU32_BE(tmp + 0);
|
||||||
fourCC = Stream_GetU32_BE(&tmp[4]);
|
fourCC = Stream_GetU32_BE(tmp + 4);
|
||||||
|
|
||||||
switch (fourCC) {
|
switch (fourCC) {
|
||||||
case PNG_FourCC('I','H','D','R'): {
|
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);
|
res = Stream_Read(stream, tmp, PNG_IHDR_SIZE);
|
||||||
if (res) return res;
|
if (res) return res;
|
||||||
|
|
||||||
bmp->Width = (int)Stream_GetU32_BE(&tmp[0]);
|
bmp->Width = (int)Stream_GetU32_BE(tmp + 0);
|
||||||
bmp->Height = (int)Stream_GetU32_BE(&tmp[4]);
|
bmp->Height = (int)Stream_GetU32_BE(tmp + 4);
|
||||||
if (bmp->Width < 0 || bmp->Width > PNG_MAX_DIMS) return PNG_ERR_TOO_WIDE;
|
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;
|
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;
|
inflate.Source = &datStream;
|
||||||
|
|
||||||
/* TODO: This assumes zlib header will be in 1 IDAT chunk */
|
/* 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 ((res = ZLibHeader_Read(&datStream, &zlibHeader))) return res;
|
||||||
}
|
}
|
||||||
if (!bmp->Scan0) return PNG_ERR_NO_DATA;
|
if (!bmp->Scan0) return PNG_ERR_NO_DATA;
|
||||||
|
@ -25,7 +25,7 @@ String Chat_ClientStatus[2] = { String_FromArray(msgs[7]), String_FromArray(msgs
|
|||||||
|
|
||||||
String Chat_Announcement = String_FromArray(msgs[9]);
|
String Chat_Announcement = String_FromArray(msgs[9]);
|
||||||
double Chat_AnnouncementReceived;
|
double Chat_AnnouncementReceived;
|
||||||
StringsBuffer Chat_Log, Chat_InputLog;
|
struct StringsBuffer Chat_Log, Chat_InputLog;
|
||||||
cc_bool Chat_Logging;
|
cc_bool Chat_Logging;
|
||||||
|
|
||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
|
@ -22,11 +22,11 @@ enum MsgType {
|
|||||||
|
|
||||||
extern String Chat_Status[4], Chat_BottomRight[3], Chat_ClientStatus[2], Chat_Announcement;
|
extern String Chat_Status[4], Chat_BottomRight[3], Chat_ClientStatus[2], Chat_Announcement;
|
||||||
/* All chat messages received. */
|
/* All chat messages received. */
|
||||||
extern StringsBuffer Chat_Log;
|
extern struct StringsBuffer Chat_Log;
|
||||||
/* Time each chat message was received at. */
|
/* Time each chat message was received at. */
|
||||||
extern double* Chat_LogTime;
|
extern double* Chat_LogTime;
|
||||||
/* All chat entered by the user. */
|
/* All chat entered by the user. */
|
||||||
extern StringsBuffer Chat_InputLog;
|
extern struct StringsBuffer Chat_InputLog;
|
||||||
/* Whether chat messages are logged to disc. */
|
/* Whether chat messages are logged to disc. */
|
||||||
extern cc_bool Chat_Logging;
|
extern cc_bool Chat_Logging;
|
||||||
|
|
||||||
|
@ -17,80 +17,80 @@ enum GzipState {
|
|||||||
};
|
};
|
||||||
|
|
||||||
void GZipHeader_Init(struct GZipHeader* header) {
|
void GZipHeader_Init(struct GZipHeader* header) {
|
||||||
header->State = GZIP_STATE_HEADER1;
|
header->state = GZIP_STATE_HEADER1;
|
||||||
header->Done = false;
|
header->done = false;
|
||||||
header->Flags = 0;
|
header->flags = 0;
|
||||||
header->PartsRead = 0;
|
header->partsRead = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
cc_result GZipHeader_Read(struct Stream* s, struct GZipHeader* header) {
|
cc_result GZipHeader_Read(struct Stream* s, struct GZipHeader* header) {
|
||||||
cc_uint8 tmp;
|
cc_uint8 tmp;
|
||||||
cc_result res;
|
cc_result res;
|
||||||
switch (header->State) {
|
switch (header->state) {
|
||||||
|
|
||||||
case GZIP_STATE_HEADER1:
|
case GZIP_STATE_HEADER1:
|
||||||
Header_ReadU8(tmp);
|
Header_ReadU8(tmp);
|
||||||
if (tmp != 0x1F) return GZIP_ERR_HEADER1;
|
if (tmp != 0x1F) return GZIP_ERR_HEADER1;
|
||||||
header->State++;
|
header->state++;
|
||||||
|
|
||||||
case GZIP_STATE_HEADER2:
|
case GZIP_STATE_HEADER2:
|
||||||
Header_ReadU8(tmp);
|
Header_ReadU8(tmp);
|
||||||
if (tmp != 0x8B) return GZIP_ERR_HEADER2;
|
if (tmp != 0x8B) return GZIP_ERR_HEADER2;
|
||||||
header->State++;
|
header->state++;
|
||||||
|
|
||||||
case GZIP_STATE_COMPRESSIONMETHOD:
|
case GZIP_STATE_COMPRESSIONMETHOD:
|
||||||
Header_ReadU8(tmp);
|
Header_ReadU8(tmp);
|
||||||
if (tmp != 0x08) return GZIP_ERR_METHOD;
|
if (tmp != 0x08) return GZIP_ERR_METHOD;
|
||||||
header->State++;
|
header->state++;
|
||||||
|
|
||||||
case GZIP_STATE_FLAGS:
|
case GZIP_STATE_FLAGS:
|
||||||
Header_ReadU8(tmp);
|
Header_ReadU8(tmp);
|
||||||
header->Flags = tmp;
|
header->flags = tmp;
|
||||||
if (header->Flags & 0x04) return GZIP_ERR_FLAGS;
|
if (header->flags & 0x04) return GZIP_ERR_FLAGS;
|
||||||
header->State++;
|
header->state++;
|
||||||
|
|
||||||
case GZIP_STATE_LASTMODIFIED:
|
case GZIP_STATE_LASTMODIFIED:
|
||||||
for (; header->PartsRead < 4; header->PartsRead++) {
|
for (; header->partsRead < 4; header->partsRead++) {
|
||||||
Header_ReadU8(tmp);
|
Header_ReadU8(tmp);
|
||||||
}
|
}
|
||||||
header->State++;
|
header->state++;
|
||||||
header->PartsRead = 0;
|
header->partsRead = 0;
|
||||||
|
|
||||||
case GZIP_STATE_COMPRESSIONFLAGS:
|
case GZIP_STATE_COMPRESSIONFLAGS:
|
||||||
Header_ReadU8(tmp);
|
Header_ReadU8(tmp);
|
||||||
header->State++;
|
header->state++;
|
||||||
|
|
||||||
case GZIP_STATE_OPERATINGSYSTEM:
|
case GZIP_STATE_OPERATINGSYSTEM:
|
||||||
Header_ReadU8(tmp);
|
Header_ReadU8(tmp);
|
||||||
header->State++;
|
header->state++;
|
||||||
|
|
||||||
case GZIP_STATE_FILENAME:
|
case GZIP_STATE_FILENAME:
|
||||||
if (header->Flags & 0x08) {
|
if (header->flags & 0x08) {
|
||||||
for (; ;) {
|
for (; ;) {
|
||||||
Header_ReadU8(tmp);
|
Header_ReadU8(tmp);
|
||||||
if (tmp == '\0') break;
|
if (tmp == '\0') break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
header->State++;
|
header->state++;
|
||||||
|
|
||||||
case GZIP_STATE_COMMENT:
|
case GZIP_STATE_COMMENT:
|
||||||
if (header->Flags & 0x10) {
|
if (header->flags & 0x10) {
|
||||||
for (; ;) {
|
for (; ;) {
|
||||||
Header_ReadU8(tmp);
|
Header_ReadU8(tmp);
|
||||||
if (tmp == '\0') break;
|
if (tmp == '\0') break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
header->State++;
|
header->state++;
|
||||||
|
|
||||||
case GZIP_STATE_HEADERCHECKSUM:
|
case GZIP_STATE_HEADERCHECKSUM:
|
||||||
if (header->Flags & 0x02) {
|
if (header->flags & 0x02) {
|
||||||
for (; header->PartsRead < 2; header->PartsRead++) {
|
for (; header->partsRead < 2; header->partsRead++) {
|
||||||
Header_ReadU8(tmp);
|
Header_ReadU8(tmp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
header->State++;
|
header->state++;
|
||||||
header->PartsRead = 0;
|
header->partsRead = 0;
|
||||||
header->Done = true;
|
header->done = true;
|
||||||
}
|
}
|
||||||
return 0;
|
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 };
|
enum ZlibState { ZLIB_STATE_COMPRESSIONMETHOD, ZLIB_STATE_FLAGS, ZLIB_STATE_DONE };
|
||||||
|
|
||||||
void ZLibHeader_Init(struct ZLibHeader* header) {
|
void ZLibHeader_Init(struct ZLibHeader* header) {
|
||||||
header->State = ZLIB_STATE_COMPRESSIONMETHOD;
|
header->state = ZLIB_STATE_COMPRESSIONMETHOD;
|
||||||
header->Done = false;
|
header->done = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
cc_result ZLibHeader_Read(struct Stream* s, struct ZLibHeader* header) {
|
cc_result ZLibHeader_Read(struct Stream* s, struct ZLibHeader* header) {
|
||||||
cc_uint8 tmp;
|
cc_uint8 tmp;
|
||||||
cc_result res;
|
cc_result res;
|
||||||
switch (header->State) {
|
switch (header->state) {
|
||||||
|
|
||||||
case ZLIB_STATE_COMPRESSIONMETHOD:
|
case ZLIB_STATE_COMPRESSIONMETHOD:
|
||||||
Header_ReadU8(tmp);
|
Header_ReadU8(tmp);
|
||||||
if ((tmp & 0x0F) != 0x08) return ZLIB_ERR_METHOD;
|
if ((tmp & 0x0F) != 0x08) return ZLIB_ERR_METHOD;
|
||||||
if ((tmp >> 4) > 7) return ZLIB_ERR_WINDOW_SIZE;
|
if ((tmp >> 4) > 7) return ZLIB_ERR_WINDOW_SIZE;
|
||||||
/* 2^(size + 8) must be < 32768 for LZ77 window */
|
/* 2^(size + 8) must be < 32768 for LZ77 window */
|
||||||
header->State++;
|
header->state++;
|
||||||
|
|
||||||
case ZLIB_STATE_FLAGS:
|
case ZLIB_STATE_FLAGS:
|
||||||
Header_ReadU8(tmp);
|
Header_ReadU8(tmp);
|
||||||
if (tmp & 0x20) return ZLIB_ERR_FLAGS;
|
if (tmp & 0x20) return ZLIB_ERR_FLAGS;
|
||||||
header->State++;
|
header->state++;
|
||||||
header->Done = true;
|
header->done = true;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -11,11 +11,11 @@
|
|||||||
*/
|
*/
|
||||||
struct Stream;
|
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);
|
void GZipHeader_Init(struct GZipHeader* header);
|
||||||
cc_result GZipHeader_Read(struct Stream* s, 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);
|
void ZLibHeader_Init(struct ZLibHeader* header);
|
||||||
cc_result ZLibHeader_Read(struct Stream* s, struct ZLibHeader* header);
|
cc_result ZLibHeader_Read(struct Stream* s, struct ZLibHeader* header);
|
||||||
|
|
||||||
|
@ -693,7 +693,7 @@ struct IGameComponent Drawer2D_Component = {
|
|||||||
*---------------------------------------------------Drawer2D component----------------------------------------------------*
|
*---------------------------------------------------Drawer2D component----------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
#ifdef CC_BUILD_WEB
|
#ifdef CC_BUILD_WEB
|
||||||
void Font_GetNames(StringsBuffer* buffer) { }
|
void Font_GetNames(struct StringsBuffer* buffer) { }
|
||||||
String Font_Lookup(const String* fontName, int style) {
|
String Font_Lookup(const String* fontName, int style) {
|
||||||
String str = String_FromConst("-----"); return str;
|
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;
|
String entry, name, path;
|
||||||
int i;
|
int i;
|
||||||
if (!font_list.entries.count) SysFonts_Init();
|
if (!font_list.entries.count) SysFonts_Init();
|
||||||
|
@ -93,7 +93,7 @@ void Drawer2D_ReducePadding_Height(int* height, int point, int scale);
|
|||||||
cc_bool Drawer2D_SetFontBitmap(Bitmap* bmp);
|
cc_bool Drawer2D_SetFontBitmap(Bitmap* bmp);
|
||||||
|
|
||||||
/* Gets the list of all supported system font names on this platform. */
|
/* 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. */
|
/* Reduces padding for a bitmapped font. */
|
||||||
void Font_ReducePadding(struct FontDesc* desc, int scale);
|
void Font_ReducePadding(struct FontDesc* desc, int scale);
|
||||||
/* Finds the path and face number of the given system font, with closest matching style */
|
/* Finds the path and face number of the given system font, with closest matching style */
|
||||||
|
@ -157,7 +157,7 @@ CC_VAR extern struct _TabListData {
|
|||||||
cc_uint16 NameOffsets[TABLIST_MAX_NAMES];
|
cc_uint16 NameOffsets[TABLIST_MAX_NAMES];
|
||||||
/* Position/Order of this entry within the group. */
|
/* Position/Order of this entry within the group. */
|
||||||
cc_uint8 GroupRanks[TABLIST_MAX_NAMES];
|
cc_uint8 GroupRanks[TABLIST_MAX_NAMES];
|
||||||
StringsBuffer _buffer;
|
struct StringsBuffer _buffer;
|
||||||
} TabList;
|
} TabList;
|
||||||
|
|
||||||
/* Removes the tab list entry with the given ID, raising TabListEvents.Removed event. */
|
/* Removes the tab list entry with the given ID, raising TabListEvents.Removed event. */
|
||||||
|
@ -33,7 +33,7 @@ static cc_result Map_SkipGZipHeader(struct Stream* stream) {
|
|||||||
cc_result res;
|
cc_result res;
|
||||||
GZipHeader_Init(&gzHeader);
|
GZipHeader_Init(&gzHeader);
|
||||||
|
|
||||||
while (!gzHeader.Done) {
|
while (!gzHeader.done) {
|
||||||
if ((res = GZipHeader_Read(stream, &gzHeader))) return res;
|
if ((res = GZipHeader_Read(stream, &gzHeader))) return res;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -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
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||||
};
|
};
|
||||||
struct HotkeyData HotkeysList[HOTKEYS_MAX_COUNT];
|
struct HotkeyData HotkeysList[HOTKEYS_MAX_COUNT];
|
||||||
StringsBuffer HotkeysText;
|
struct StringsBuffer HotkeysText;
|
||||||
|
|
||||||
static void Hotkeys_QuickSort(int left, int right) {
|
static void Hotkeys_QuickSort(int left, int right) {
|
||||||
struct HotkeyData* keys = HotkeysList; struct HotkeyData key;
|
struct HotkeyData* keys = HotkeysList; struct HotkeyData key;
|
||||||
|
@ -135,7 +135,7 @@ struct HotkeyData {
|
|||||||
|
|
||||||
#define HOTKEYS_MAX_COUNT 256
|
#define HOTKEYS_MAX_COUNT 256
|
||||||
extern struct HotkeyData HotkeysList[HOTKEYS_MAX_COUNT];
|
extern struct HotkeyData HotkeysList[HOTKEYS_MAX_COUNT];
|
||||||
extern StringsBuffer HotkeysText;
|
extern struct StringsBuffer HotkeysText;
|
||||||
enum HotkeyModifiers {
|
enum HotkeyModifiers {
|
||||||
HOTKEY_MOD_CTRL = 1, HOTKEY_MOD_SHIFT = 2, HOTKEY_MOD_ALT = 4
|
HOTKEY_MOD_CTRL = 1, HOTKEY_MOD_SHIFT = 2, HOTKEY_MOD_ALT = 4
|
||||||
};
|
};
|
||||||
|
@ -235,7 +235,7 @@ static struct ListScreen {
|
|||||||
void (*UpdateEntry)(struct ListScreen* s, struct ButtonWidget* btn, const String* text);
|
void (*UpdateEntry)(struct ListScreen* s, struct ButtonWidget* btn, const String* text);
|
||||||
const char* titleText;
|
const char* titleText;
|
||||||
struct TextWidget title, page;
|
struct TextWidget title, page;
|
||||||
StringsBuffer entries;
|
struct StringsBuffer entries;
|
||||||
} ListScreen;
|
} ListScreen;
|
||||||
|
|
||||||
static struct Widget* list_widgets[10] = {
|
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) {
|
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;
|
cc_uint32* keys = buffer->flagsBuffer; cc_uint32 key;
|
||||||
|
|
||||||
while (left < right) {
|
while (left < right) {
|
||||||
@ -1512,7 +1512,7 @@ static void TexturePackScreen_FilterFiles(const String* path, void* obj) {
|
|||||||
if (!String_CaselessEnds(path, &zip)) return;
|
if (!String_CaselessEnds(path, &zip)) return;
|
||||||
|
|
||||||
Utils_UNSAFE_TrimFirstDirectory(&relPath);
|
Utils_UNSAFE_TrimFirstDirectory(&relPath);
|
||||||
StringsBuffer_Add((StringsBuffer*)obj, &relPath);
|
StringsBuffer_Add((struct StringsBuffer*)obj, &relPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void TexturePackScreen_LoadEntries(struct ListScreen* s) {
|
static void TexturePackScreen_LoadEntries(struct ListScreen* s) {
|
||||||
@ -1674,7 +1674,7 @@ static void LoadLevelScreen_FilterFiles(const String* path, void* obj) {
|
|||||||
if (!importer) return;
|
if (!importer) return;
|
||||||
|
|
||||||
Utils_UNSAFE_TrimFirstDirectory(&relPath);
|
Utils_UNSAFE_TrimFirstDirectory(&relPath);
|
||||||
StringsBuffer_Add((StringsBuffer*)obj, &relPath);
|
StringsBuffer_Add((struct StringsBuffer*)obj, &relPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void LoadLevelScreen_LoadEntries(struct ListScreen* s) {
|
static void LoadLevelScreen_LoadEntries(struct ListScreen* s) {
|
||||||
|
@ -9,21 +9,21 @@
|
|||||||
#include "Logger.h"
|
#include "Logger.h"
|
||||||
|
|
||||||
struct EntryList Options;
|
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) {
|
void Options_Free(void) {
|
||||||
StringsBuffer_Clear(&Options.entries);
|
StringsBuffer_Clear(&Options.entries);
|
||||||
StringsBuffer_Clear(&Options_Changed);
|
StringsBuffer_Clear(&changedOpts);
|
||||||
}
|
}
|
||||||
|
|
||||||
cc_bool Options_HasChanged(const String* key) {
|
cc_bool Options_HasChanged(const String* key) {
|
||||||
String entry;
|
String entry;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < Options_Changed.count; i++) {
|
for (i = 0; i < changedOpts.count; i++) {
|
||||||
entry = StringsBuffer_UNSAFE_Get(&Options_Changed, i);
|
entry = StringsBuffer_UNSAFE_Get(&changedOpts, i);
|
||||||
if (String_CaselessEquals(&entry, key)) return true;
|
if (String_CaselessEquals(&entry, key)) return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -125,7 +125,7 @@ void Options_SetString(const String* key, const String* value) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (Options_HasChanged(key)) return;
|
if (Options_HasChanged(key)) return;
|
||||||
StringsBuffer_Add(&Options_Changed, key);
|
StringsBuffer_Add(&changedOpts, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
static cc_bool Options_LoadFilter(const String* entry) {
|
static cc_bool Options_LoadFilter(const String* entry) {
|
||||||
@ -158,7 +158,7 @@ void Options_Load(void) {
|
|||||||
|
|
||||||
void Options_Save(void) {
|
void Options_Save(void) {
|
||||||
EntryList_Save(&Options);
|
EntryList_Save(&Options);
|
||||||
StringsBuffer_Clear(&Options_Changed);
|
StringsBuffer_Clear(&changedOpts);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Options_SetSecure(const char* opt, const String* src, const String* key) {
|
void Options_SetSecure(const char* opt, const String* src, const String* key) {
|
||||||
|
@ -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 */
|
/* Fast map puts volume in header, and uses raw DEFLATE without GZIP header/footer */
|
||||||
map_volume = Stream_GetU32_BE(data);
|
map_volume = Stream_GetU32_BE(data);
|
||||||
map_gzHeader.Done = true;
|
map_gzHeader.done = true;
|
||||||
map_sizeIndex = 4;
|
map_sizeIndex = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -483,12 +483,12 @@ static void Classic_LevelDataChunk(cc_uint8* data) {
|
|||||||
data += 1024;
|
data += 1024;
|
||||||
value = *data; /* progress in original classic, but we ignore it */
|
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);
|
res = GZipHeader_Read(&map_part, &map_gzHeader);
|
||||||
if (res && res != ERR_END_OF_STREAM) Logger_Abort2(res, "reading map data");
|
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) {
|
if (map_sizeIndex < 4) {
|
||||||
left = 4 - map_sizeIndex;
|
left = 4 - map_sizeIndex;
|
||||||
map.stream.Read(&map.stream, &map_size[map_sizeIndex], left, &read);
|
map.stream.Read(&map.stream, &map_size[map_sizeIndex], left, &read);
|
||||||
|
10
src/String.c
10
src/String.c
@ -743,7 +743,7 @@ cc_bool Convert_ParseBool(const String* str, cc_bool* value) {
|
|||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
#define STRINGSBUFFER_BUFFER_EXPAND_SIZE 8192
|
#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->count = 0;
|
||||||
buffer->totalLength = 0;
|
buffer->totalLength = 0;
|
||||||
buffer->textBuffer = buffer->_defaultBuffer;
|
buffer->textBuffer = buffer->_defaultBuffer;
|
||||||
@ -752,7 +752,7 @@ CC_NOINLINE static void StringsBuffer_Init(StringsBuffer* buffer) {
|
|||||||
buffer->_flagsCapacity = STRINGSBUFFER_FLAGS_DEF_ELEMS;
|
buffer->_flagsCapacity = STRINGSBUFFER_FLAGS_DEF_ELEMS;
|
||||||
}
|
}
|
||||||
|
|
||||||
void StringsBuffer_Clear(StringsBuffer* buffer) {
|
void StringsBuffer_Clear(struct StringsBuffer* buffer) {
|
||||||
/* Never initialised to begin with */
|
/* Never initialised to begin with */
|
||||||
if (!buffer->_flagsCapacity) return;
|
if (!buffer->_flagsCapacity) return;
|
||||||
|
|
||||||
@ -765,7 +765,7 @@ void StringsBuffer_Clear(StringsBuffer* buffer) {
|
|||||||
StringsBuffer_Init(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;
|
cc_uint32 flags, offset, len;
|
||||||
if (i < 0 || i >= buffer->count) Logger_Abort("Tried to get String past StringsBuffer end");
|
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);
|
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;
|
int textOffset;
|
||||||
/* StringsBuffer hasn't been initalised yet, do it here */
|
/* StringsBuffer hasn't been initalised yet, do it here */
|
||||||
if (!buffer->_flagsCapacity) StringsBuffer_Init(buffer);
|
if (!buffer->_flagsCapacity) StringsBuffer_Init(buffer);
|
||||||
@ -802,7 +802,7 @@ void StringsBuffer_Add(StringsBuffer* buffer, const String* str) {
|
|||||||
buffer->totalLength += str->length;
|
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 flags, offset, len;
|
||||||
cc_uint32 i, offsetAdj;
|
cc_uint32 i, offsetAdj;
|
||||||
if (index < 0 || index >= buffer->count) Logger_Abort("Tried to remove String past StringsBuffer end");
|
if (index < 0 || index >= buffer->count) Logger_Abort("Tried to remove String past StringsBuffer end");
|
||||||
|
12
src/String.h
12
src/String.h
@ -205,7 +205,7 @@ CC_API cc_bool Convert_ParseBool(const String* str, cc_bool* value);
|
|||||||
#define STRINGSBUFFER_LEN_SHIFT 9
|
#define STRINGSBUFFER_LEN_SHIFT 9
|
||||||
#define STRINGSBUFFER_LEN_MASK 0x1FFUL
|
#define STRINGSBUFFER_LEN_MASK 0x1FFUL
|
||||||
|
|
||||||
typedef struct StringsBuffer_ {
|
struct StringsBuffer {
|
||||||
char* textBuffer; /* Raw characters of all entries */
|
char* textBuffer; /* Raw characters of all entries */
|
||||||
cc_uint32* flagsBuffer; /* Private flags for each entry */
|
cc_uint32* flagsBuffer; /* Private flags for each entry */
|
||||||
int count, totalLength;
|
int count, totalLength;
|
||||||
@ -213,17 +213,17 @@ typedef struct StringsBuffer_ {
|
|||||||
int _textCapacity, _flagsCapacity;
|
int _textCapacity, _flagsCapacity;
|
||||||
char _defaultBuffer[STRINGSBUFFER_BUFFER_DEF_SIZE];
|
char _defaultBuffer[STRINGSBUFFER_BUFFER_DEF_SIZE];
|
||||||
cc_uint32 _defaultFlags[STRINGSBUFFER_FLAGS_DEF_ELEMS];
|
cc_uint32 _defaultFlags[STRINGSBUFFER_FLAGS_DEF_ELEMS];
|
||||||
} StringsBuffer;
|
};
|
||||||
|
|
||||||
/* Resets counts to 0, and frees any allocated memory. */
|
/* 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. */
|
/* 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.*/
|
/* 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. */
|
/* 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. */
|
/* 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. */
|
/* Performs line wrapping on the given string. */
|
||||||
/* e.g. "some random tex|t* (| is lineLen) becomes "some random" "text" */
|
/* e.g. "some random tex|t* (| is lineLen) becomes "some random" "text" */
|
||||||
|
@ -57,7 +57,7 @@ int Convert_FromBase64(const char* src, int len, cc_uint8* dst);
|
|||||||
struct EntryList {
|
struct EntryList {
|
||||||
const char* path;
|
const char* path;
|
||||||
char separator;
|
char separator;
|
||||||
StringsBuffer entries;
|
struct StringsBuffer entries;
|
||||||
};
|
};
|
||||||
typedef cc_bool (*EntryList_Filter)(const String* entry);
|
typedef cc_bool (*EntryList_Filter)(const String* entry);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user