disable some more unused bits of freetype

This commit is contained in:
UnknownShadow200 2018-11-01 22:17:02 +11:00
parent 5185b79a45
commit aa020aaf22
11 changed files with 122 additions and 88 deletions

View File

@ -385,7 +385,7 @@ ReturnCode Png_Decode(Bitmap* bmp, struct Stream* stream) {
scanlineBytes = scanlineSize + 1; /* Add 1 byte for filter byte of each scanline */ scanlineBytes = scanlineSize + 1; /* Add 1 byte for filter byte of each scanline */
Mem_Set(buffer, 0, scanlineBytes); /* Prior row should be 0 per PNG spec */ Mem_Set(buffer, 0, scanlineBytes); /* Prior row should be 0 per PNG spec */
bufferIdx = scanlineBytes; bufferIdx = scanlineBytes;
bufferRows = PNG_BUFFER_SIZE / scanlineBytes; bufferRows = PNG_BUFFER_SIZE / scanlineBytes;
} break; } break;

View File

@ -475,17 +475,18 @@ void TabList_MakeComponent(struct IGameComponent* comp) {
*#########################################################################################################################*/ *#########################################################################################################################*/
#define PLAYER_NAME_EMPTY_TEX -30000 #define PLAYER_NAME_EMPTY_TEX -30000
static void Player_MakeNameTexture(struct Player* player) { static void Player_MakeNameTexture(struct Player* player) {
struct DrawTextArgs args;
Size2D size;
Bitmap bmp;
/* we want names to always be drawn not using the system font */ /* we want names to always be drawn not using the system font */
bool bitmapped = Drawer2D_BitmappedText; bool bitmapped = Drawer2D_BitmappedText;
Drawer2D_BitmappedText = true; Drawer2D_BitmappedText = true;
String displayName = String_FromRawArray(player->DisplayNameRaw); String displayName = String_FromRawArray(player->DisplayNameRaw);
FontDesc font;
Drawer2D_MakeFont(&font, 24, FONT_STYLE_NORMAL);
struct DrawTextArgs args; Drawer2D_MakeFont(&args.Font, 24, FONT_STYLE_NORMAL);
DrawTextArgs_Make(&args, &displayName, &font, false); DrawTextArgs_Make(&args, &displayName, &args.Font, false);
Size2D size = Drawer2D_MeasureText(&args); size = Drawer2D_MeasureText(&args);
if (size.Width == 0) { if (size.Width == 0) {
player->NameTex.ID = GFX_NULL; player->NameTex.ID = GFX_NULL;
@ -495,7 +496,7 @@ static void Player_MakeNameTexture(struct Player* player) {
String shadowName = String_FromArray(buffer); String shadowName = String_FromArray(buffer);
size.Width += 3; size.Height += 3; size.Width += 3; size.Height += 3;
Bitmap bmp; Bitmap_AllocateClearedPow2(&bmp, size.Width, size.Height); Bitmap_AllocateClearedPow2(&bmp, size.Width, size.Height);
{ {
PackedCol origWhiteCol = Drawer2D_Cols['f']; PackedCol origWhiteCol = Drawer2D_Cols['f'];
@ -526,6 +527,7 @@ static void Player_DrawName(struct Player* player) {
struct Entity* e = &player->Base; struct Entity* e = &player->Base;
struct Model* model = e->Model; struct Model* model = e->Model;
Vector3 pos; Vector3 pos;
float scale;
if (player->NameTex.X == PLAYER_NAME_EMPTY_TEX) return; if (player->NameTex.X == PLAYER_NAME_EMPTY_TEX) return;
if (!player->NameTex.ID) Player_MakeNameTexture(player); if (!player->NameTex.ID) Player_MakeNameTexture(player);
@ -534,7 +536,7 @@ static void Player_DrawName(struct Player* player) {
model->RecalcProperties(e); model->RecalcProperties(e);
Vector3_TransformY(&pos, model->NameYOffset, &e->Transform); Vector3_TransformY(&pos, model->NameYOffset, &e->Transform);
float scale = model->NameScale * e->ModelScale.Y; scale = model->NameScale * e->ModelScale.Y;
scale = scale > 1.0f ? (1.0f / 70.0f) : (scale / 70.0f); scale = scale > 1.0f ? (1.0f / 70.0f) : (scale / 70.0f);
Vector2 size = { player->NameTex.Width * scale, player->NameTex.Height * scale }; Vector2 size = { player->NameTex.Width * scale, player->NameTex.Height * scale };
@ -665,9 +667,11 @@ static void Player_ClearHat(Bitmap* bmp, uint8_t skinType) {
static void Player_EnsurePow2(struct Player* player, Bitmap* bmp) { static void Player_EnsurePow2(struct Player* player, Bitmap* bmp) {
int width = Math_NextPowOf2(bmp->Width); int width = Math_NextPowOf2(bmp->Width);
int height = Math_NextPowOf2(bmp->Height); int height = Math_NextPowOf2(bmp->Height);
Bitmap scaled;
if (width == bmp->Width && height == bmp->Height) return; if (width == bmp->Width && height == bmp->Height) return;
Bitmap scaled; Bitmap_Allocate(&scaled, width, height); Bitmap_Allocate(&scaled, width, height);
int y; int y;
uint32_t stride = (uint32_t)(bmp->Width) * BITMAP_SIZEOF_PIXEL; uint32_t stride = (uint32_t)(bmp->Width) * BITMAP_SIZEOF_PIXEL;
for (y = 0; y < bmp->Height; y++) { for (y = 0; y < bmp->Height; y++) {

View File

@ -45,6 +45,6 @@ enum ERRORS_ALL {
DAT_ERR_JCLASS_TYPE, DAT_ERR_JCLASS_FIELDS, DAT_ERR_JCLASS_ANNOTATION, DAT_ERR_JCLASS_TYPE, DAT_ERR_JCLASS_FIELDS, DAT_ERR_JCLASS_ANNOTATION,
DAT_ERR_JOBJECT_TYPE, DAT_ERR_JARRAY_TYPE, DAT_ERR_JARRAY_CONTENT, DAT_ERR_JOBJECT_TYPE, DAT_ERR_JARRAY_TYPE, DAT_ERR_JARRAY_CONTENT,
/* CW map decoding errors */ /* CW map decoding errors */
NBT_ERR_INT32S, NBT_ERR_UNKNOWN, CW_ERR_ROOT_TAG, CW_ERR_STRING_LEN, NBT_ERR_INT32S, NBT_ERR_UNKNOWN, CW_ERR_ROOT_TAG, CW_ERR_STRING_LEN
}; };
#endif #endif

View File

@ -48,7 +48,7 @@ struct ListScreen {
String TitleText; String TitleText;
struct TextWidget Title, Page; struct TextWidget Title, Page;
struct Widget* ListWidgets[LIST_SCREEN_BUTTONS + 2]; struct Widget* ListWidgets[LIST_SCREEN_BUTTONS + 2];
StringsBuffer Entries; /* NOTE: this is the last member so we can avoid memsetting it to 0 */ StringsBuffer Entries;
}; };
#define MenuScreen_Layout MenuBase_Layout FontDesc TitleFont, TextFont; #define MenuScreen_Layout MenuBase_Layout FontDesc TitleFont, TextFont;
@ -1392,14 +1392,16 @@ struct Screen* SaveLevelScreen_MakeInstance(void) {
*#########################################################################################################################*/ *#########################################################################################################################*/
static void TexturePackScreen_EntryClick(void* screen, void* widget) { static void TexturePackScreen_EntryClick(void* screen, void* widget) {
struct ListScreen* s = screen; struct ListScreen* s = screen;
String filename;
int idx;
char pathBuffer[FILENAME_SIZE]; char pathBuffer[FILENAME_SIZE];
String path = String_FromArray(pathBuffer); String path = String_FromArray(pathBuffer);
String filename = ListScreen_UNSAFE_GetCur(s, widget); filename = ListScreen_UNSAFE_GetCur(s, widget);
String_Format2(&path, "texpacks%r%s", &Directory_Separator, &filename); String_Format2(&path, "texpacks%r%s", &Directory_Separator, &filename);
if (!File_Exists(&path)) return; if (!File_Exists(&path)) return;
int idx = s->CurrentIndex; idx = s->CurrentIndex;
Game_SetDefaultTexturePack(&filename); Game_SetDefaultTexturePack(&filename);
TexturePack_ExtractDefault(); TexturePack_ExtractDefault();
Elem_Recreate(s); Elem_Recreate(s);
@ -1614,10 +1616,11 @@ void LoadLevelScreen_LoadMap(const String* path) {
static void LoadLevelScreen_EntryClick(void* screen, void* widget) { static void LoadLevelScreen_EntryClick(void* screen, void* widget) {
struct ListScreen* s = screen; struct ListScreen* s = screen;
String filename;
char pathBuffer[FILENAME_SIZE]; char pathBuffer[FILENAME_SIZE];
String path = String_FromArray(pathBuffer); String path = String_FromArray(pathBuffer);
String filename = ListScreen_UNSAFE_GetCur(s, widget); filename = ListScreen_UNSAFE_GetCur(s, widget);
String_Format2(&path, "maps%r%s", &Directory_Separator, &filename); String_Format2(&path, "maps%r%s", &Directory_Separator, &filename);
if (!File_Exists(&path)) return; if (!File_Exists(&path)) return;
LoadLevelScreen_LoadMap(&path); LoadLevelScreen_LoadMap(&path);
@ -1651,13 +1654,14 @@ static void KeyBindingsScreen_GetText(struct KeyBindingsScreen* s, int i, String
static void KeyBindingsScreen_OnBindingClick(void* screen, void* widget) { static void KeyBindingsScreen_OnBindingClick(void* screen, void* widget) {
struct KeyBindingsScreen* s = screen; struct KeyBindingsScreen* s = screen;
struct ButtonWidget* btn = widget; struct ButtonWidget* btn = widget;
struct ButtonWidget* cur;
char textBuffer[STRING_SIZE]; char textBuffer[STRING_SIZE];
String text = String_FromArray(textBuffer); String text = String_FromArray(textBuffer);
/* previously selected a different button for binding */ /* previously selected a different button for binding */
if (s->CurI >= 0) { if (s->CurI >= 0) {
KeyBindingsScreen_GetText(s, s->CurI, &text); KeyBindingsScreen_GetText(s, s->CurI, &text);
struct ButtonWidget* cur = (struct ButtonWidget*)s->Widgets[s->CurI]; cur = (struct ButtonWidget*)s->Widgets[s->CurI];
ButtonWidget_Set(cur, &text, &s->TitleFont); ButtonWidget_Set(cur, &text, &s->TitleFont);
} }
s->CurI = Menu_Index(s, btn); s->CurI = Menu_Index(s, btn);
@ -1669,7 +1673,10 @@ static void KeyBindingsScreen_OnBindingClick(void* screen, void* widget) {
ButtonWidget_Set(btn, &text, &s->TitleFont); ButtonWidget_Set(btn, &text, &s->TitleFont);
} }
static int KeyBindingsScreen_MakeWidgets(struct KeyBindingsScreen* s, int y, int arrowsY, int leftLength, const char* title, int btnWidth) { static int KeyBindingsScreen_MakeWidgets(struct KeyBindingsScreen* s, int y, int arrowsY, int leftLength, const char* title, int btnWidth) {
static String lArrow = String_FromConst("<");
static String rArrow = String_FromConst(">");
int i, origin = y, xOffset = btnWidth / 2 + 5; int i, origin = y, xOffset = btnWidth / 2 + 5;
s->CurI = -1; s->CurI = -1;
@ -1696,24 +1703,23 @@ static int KeyBindingsScreen_MakeWidgets(struct KeyBindingsScreen* s, int y, int
Menu_Back(s, i, &s->Back, "Done", &s->TitleFont, backClick); i++; Menu_Back(s, i, &s->Back, "Done", &s->TitleFont, backClick); i++;
if (!s->LeftPage && !s->RightPage) return i; if (!s->LeftPage && !s->RightPage) return i;
String lArrow = String_FromConst("<"); Menu_Button(s, i, &s->Left, 40, &lArrow, &s->TitleFont, s->LeftPage,
Menu_Button(s, i, &s->Left, 40, &lArrow, &s->TitleFont, s->LeftPage,
ANCHOR_CENTRE, ANCHOR_CENTRE, -btnWidth - 35, arrowsY); i++; ANCHOR_CENTRE, ANCHOR_CENTRE, -btnWidth - 35, arrowsY); i++;
s->Left.Disabled = !s->LeftPage;
String rArrow = String_FromConst(">");
Menu_Button(s, i, &s->Right, 40, &rArrow, &s->TitleFont, s->RightPage, Menu_Button(s, i, &s->Right, 40, &rArrow, &s->TitleFont, s->RightPage,
ANCHOR_CENTRE, ANCHOR_CENTRE, btnWidth + 35, arrowsY); i++; ANCHOR_CENTRE, ANCHOR_CENTRE, btnWidth + 35, arrowsY); i++;
s->Right.Disabled = !s->RightPage;
s->Left.Disabled = !s->LeftPage;
s->Right.Disabled = !s->RightPage;
return i; return i;
} }
static bool KeyBindingsScreen_KeyDown(void* screen, Key key) { static bool KeyBindingsScreen_KeyDown(void* screen, Key key) {
struct KeyBindingsScreen* s = screen; struct KeyBindingsScreen* s = screen;
struct ButtonWidget* cur;
KeyBind bind;
if (s->CurI == -1) return MenuScreen_KeyDown(s, key); if (s->CurI == -1) return MenuScreen_KeyDown(s, key);
KeyBind bind = s->Binds[s->CurI]; bind = s->Binds[s->CurI];
if (key == Key_Escape) key = KeyBind_GetDefault(bind); if (key == Key_Escape) key = KeyBind_GetDefault(bind);
KeyBind_Set(bind, key); KeyBind_Set(bind, key);
@ -1721,7 +1727,7 @@ static bool KeyBindingsScreen_KeyDown(void* screen, Key key) {
String text = String_FromArray(textBuffer); String text = String_FromArray(textBuffer);
KeyBindingsScreen_GetText(s, s->CurI, &text); KeyBindingsScreen_GetText(s, s->CurI, &text);
struct ButtonWidget* cur = (struct ButtonWidget*)s->Widgets[s->CurI]; cur = (struct ButtonWidget*)s->Widgets[s->CurI];
ButtonWidget_Set(cur, &text, &s->TitleFont); ButtonWidget_Set(cur, &text, &s->TitleFont);
s->CurI = -1; s->CurI = -1;
return true; return true;
@ -2142,13 +2148,12 @@ static void MenuOptionsScreen_Input(void* screen, void* widget) {
static String okay = String_FromConst("OK"); static String okay = String_FromConst("OK");
static String def = String_FromConst("Default value"); static String def = String_FromConst("Default value");
struct MenuOptionsScreen* s = screen;
struct ButtonWidget* btn = widget;
int i;
char valueBuffer[STRING_SIZE]; char valueBuffer[STRING_SIZE];
String value = String_FromArray(valueBuffer); String value = String_FromArray(valueBuffer);
struct MenuOptionsScreen* s = screen;
struct ButtonWidget* btn = widget;
int i;
s->ActiveI = Menu_Index(s, btn); s->ActiveI = Menu_Index(s, btn);
MenuOptionsScreen_FreeExtHelp(s); MenuOptionsScreen_FreeExtHelp(s);
MenuOptionsScreen_FreeInput(s); MenuOptionsScreen_FreeInput(s);
@ -3168,8 +3173,10 @@ struct Screen* UrlWarningOverlay_MakeInstance(const String* url) {
struct ConfirmDenyOverlay ConfirmDenyOverlay_Instance; struct ConfirmDenyOverlay ConfirmDenyOverlay_Instance;
static void ConfirmDenyOverlay_ConfirmNoClick(void* screen, void* b) { static void ConfirmDenyOverlay_ConfirmNoClick(void* screen, void* b) {
struct ConfirmDenyOverlay* s = screen; struct ConfirmDenyOverlay* s = screen;
String url;
Gui_FreeOverlay(s); Gui_FreeOverlay(s);
String url = s->Url; url = s->Url;
if (s->AlwaysDeny && !TextureCache_HasDenied(&url)) { if (s->AlwaysDeny && !TextureCache_HasDenied(&url)) {
TextureCache_Deny(&url); TextureCache_Deny(&url);
@ -3178,8 +3185,10 @@ static void ConfirmDenyOverlay_ConfirmNoClick(void* screen, void* b) {
static void ConfirmDenyOverlay_GoBackClick(void* screen, void* b) { static void ConfirmDenyOverlay_GoBackClick(void* screen, void* b) {
struct ConfirmDenyOverlay* s = screen; struct ConfirmDenyOverlay* s = screen;
struct Screen* overlay;
Gui_FreeOverlay(s); Gui_FreeOverlay(s);
struct Screen* overlay = TexPackOverlay_MakeInstance(&s->Url); overlay = TexPackOverlay_MakeInstance(&s->Url);
Gui_ShowOverlay(overlay, true); Gui_ShowOverlay(overlay, true);
} }
@ -3232,12 +3241,14 @@ struct Screen* ConfirmDenyOverlay_MakeInstance(const String* url, bool alwaysDen
struct TexPackOverlay TexPackOverlay_Instance; struct TexPackOverlay TexPackOverlay_Instance;
static void TexPackOverlay_YesClick(void* screen, void* widget) { static void TexPackOverlay_YesClick(void* screen, void* widget) {
struct TexPackOverlay* s = screen; struct TexPackOverlay* s = screen;
String url;
bool isAlways;
Gui_FreeOverlay(s); Gui_FreeOverlay(s);
String url = s->Identifier; url = String_UNSAFE_SubstringAt(&s->Identifier, 3);
url = String_UNSAFE_SubstringAt(&url, 3);
ServerConnection_DownloadTexturePack(&url); ServerConnection_DownloadTexturePack(&url);
bool isAlways = WarningOverlay_IsAlways(s, widget); isAlways = WarningOverlay_IsAlways(s, widget);
if (isAlways && !TextureCache_HasAccepted(&url)) { if (isAlways && !TextureCache_HasAccepted(&url)) {
TextureCache_Accept(&url); TextureCache_Accept(&url);
} }
@ -3245,11 +3256,13 @@ static void TexPackOverlay_YesClick(void* screen, void* widget) {
static void TexPackOverlay_NoClick(void* screen, void* widget) { static void TexPackOverlay_NoClick(void* screen, void* widget) {
struct TexPackOverlay* s = screen; struct TexPackOverlay* s = screen;
Gui_FreeOverlay(s); String url;
String url = s->Identifier; bool isAlways;
url = String_UNSAFE_SubstringAt(&url, 3);
bool isAlways = WarningOverlay_IsAlways(s, widget); Gui_FreeOverlay(s);
url = String_UNSAFE_SubstringAt(&s->Identifier, 3);
isAlways = WarningOverlay_IsAlways(s, widget);
struct Screen* overlay = ConfirmDenyOverlay_MakeInstance(&url, isAlways); struct Screen* overlay = ConfirmDenyOverlay_MakeInstance(&url, isAlways);
Gui_ShowOverlay(overlay, true); Gui_ShowOverlay(overlay, true);
} }
@ -3269,11 +3282,10 @@ static void TexPackOverlay_Render(void* screen, double delta) {
static void TexPackOverlay_ContextRecreated(void* screen) { static void TexPackOverlay_ContextRecreated(void* screen) {
static String https = String_FromConst("https://"); static String https = String_FromConst("https://");
static String http = String_FromConst("http://"); static String http = String_FromConst("http://");
struct TexPackOverlay* s = screen; struct TexPackOverlay* s = screen;
String url = s->Identifier; String url;
url = String_UNSAFE_SubstringAt(&url, 3);
url = String_UNSAFE_SubstringAt(&s->Identifier, 3);
if (String_CaselessStarts(&url, &https)) { if (String_CaselessStarts(&url, &https)) {
url = String_UNSAFE_SubstringAt(&url, https.length); url = String_UNSAFE_SubstringAt(&url, https.length);
} }

View File

@ -944,16 +944,15 @@ static bool ChatScreen_KeyUp(void* screen, Key key) {
if (!s->HandlesAllInput) return false; if (!s->HandlesAllInput) return false;
if (ServerConnection_SupportsFullCP437 && key == KeyBind_Get(KeyBind_ExtInput)) { if (ServerConnection_SupportsFullCP437 && key == KeyBind_Get(KeyBind_ExtInput)) {
if (Window_Focused) { if (!Window_Focused) return true;
bool active = !s->AltText.Active; SpecialInputWidget_SetActive(&s->AltText, !s->AltText.Active);
SpecialInputWidget_SetActive(&s->AltText, active);
}
} }
return true; return true;
} }
static bool ChatScreen_KeyPress(void* screen, char keyChar) { static bool ChatScreen_KeyPress(void* screen, char keyChar) {
struct ChatScreen* s = screen; struct ChatScreen* s = screen;
bool handled;
if (!s->HandlesAllInput) return false; if (!s->HandlesAllInput) return false;
if (s->SuppressNextPress) { if (s->SuppressNextPress) {
@ -961,16 +960,17 @@ static bool ChatScreen_KeyPress(void* screen, char keyChar) {
return false; return false;
} }
bool handled = Elem_HandlesKeyPress(&s->Input.Base, keyChar); handled = Elem_HandlesKeyPress(&s->Input.Base, keyChar);
ChatScreen_UpdateAltTextY(s); ChatScreen_UpdateAltTextY(s);
return handled; return handled;
} }
static bool ChatScreen_MouseScroll(void* screen, float delta) { static bool ChatScreen_MouseScroll(void* screen, float delta) {
struct ChatScreen* s = screen; struct ChatScreen* s = screen;
int steps;
if (!s->HandlesAllInput) return false; if (!s->HandlesAllInput) return false;
int steps = Utils_AccumulateWheelDelta(&s->ChatAcc, delta); steps = Utils_AccumulateWheelDelta(&s->ChatAcc, delta);
ChatScreen_ScrollHistoryBy(s, -steps); ChatScreen_ScrollHistoryBy(s, -steps);
return true; return true;
} }

View File

@ -198,7 +198,8 @@ static ReturnCode Stream_MemoryRead(struct Stream* s, uint8_t* data, uint32_t co
count = min(count, s->Meta.Mem.Left); count = min(count, s->Meta.Mem.Left);
Mem_Copy(data, s->Meta.Mem.Cur, count); Mem_Copy(data, s->Meta.Mem.Cur, count);
s->Meta.Mem.Cur += count; s->Meta.Mem.Left -= count; s->Meta.Mem.Cur += count;
s->Meta.Mem.Left -= count;
*modified = count; *modified = count;
return 0; return 0;
} }
@ -207,7 +208,8 @@ static ReturnCode Stream_MemoryReadU8(struct Stream* s, uint8_t* data) {
if (!s->Meta.Mem.Left) return ERR_END_OF_STREAM; if (!s->Meta.Mem.Left) return ERR_END_OF_STREAM;
*data = *s->Meta.Mem.Cur; *data = *s->Meta.Mem.Cur;
s->Meta.Mem.Cur++; s->Meta.Mem.Left--; s->Meta.Mem.Cur++;
s->Meta.Mem.Left--;
return 0; return 0;
} }
@ -215,7 +217,8 @@ static ReturnCode Stream_MemoryWrite(struct Stream* s, uint8_t* data, uint32_t c
count = min(count, s->Meta.Mem.Left); count = min(count, s->Meta.Mem.Left);
Mem_Copy(s->Meta.Mem.Cur, data, count); Mem_Copy(s->Meta.Mem.Cur, data, count);
s->Meta.Mem.Cur += count; s->Meta.Mem.Left -= count; s->Meta.Mem.Cur += count;
s->Meta.Mem.Left -= count;
*modified = count; *modified = count;
return 0; return 0;
} }
@ -223,7 +226,8 @@ static ReturnCode Stream_MemoryWrite(struct Stream* s, uint8_t* data, uint32_t c
static ReturnCode Stream_MemorySkip(struct Stream* s, uint32_t count) { static ReturnCode Stream_MemorySkip(struct Stream* s, uint32_t count) {
if (count > s->Meta.Mem.Left) return ReturnCode_InvalidArg; if (count > s->Meta.Mem.Left) return ReturnCode_InvalidArg;
s->Meta.Mem.Cur += count; s->Meta.Mem.Left -= count; s->Meta.Mem.Cur += count;
s->Meta.Mem.Left -= count;
return 0; return 0;
} }
@ -288,18 +292,19 @@ static ReturnCode Stream_BufferedRead(struct Stream* s, uint8_t* data, uint32_t
count = min(count, s->Meta.Buffered.Left); count = min(count, s->Meta.Buffered.Left);
Mem_Copy(data, s->Meta.Buffered.Cur, count); Mem_Copy(data, s->Meta.Buffered.Cur, count);
s->Meta.Buffered.Cur += count; s->Meta.Buffered.Left -= count; s->Meta.Buffered.Cur += count;
s->Meta.Buffered.Left -= count;
*modified = count; *modified = count;
return 0; return 0;
} }
static ReturnCode Stream_BufferedReadU8(struct Stream* s, uint8_t* data) { static ReturnCode Stream_BufferedReadU8(struct Stream* s, uint8_t* data) {
if (s->Meta.Buffered.Left) { if (!s->Meta.Buffered.Left) return Stream_DefaultReadU8(s, data);
*data = *s->Meta.Buffered.Cur;
s->Meta.Buffered.Cur++; s->Meta.Buffered.Left--; *data = *s->Meta.Buffered.Cur;
return 0; s->Meta.Buffered.Cur++;
} s->Meta.Buffered.Left--;
return Stream_DefaultReadU8(s, data); return 0;
} }
static ReturnCode Stream_BufferedSeek(struct Stream* s, uint32_t position) { static ReturnCode Stream_BufferedSeek(struct Stream* s, uint32_t position) {

View File

@ -115,10 +115,10 @@ static ReturnCode Zip_ReadEndOfCentralDirectory(struct ZipState* state, uint32_t
return 0; return 0;
} }
enum ZIP_SIG { enum ZipSig {
ZIP_SIG_ENDOFCENTRALDIR = 0x06054b50, ZIP_SIG_ENDOFCENTRALDIR = 0x06054b50,
ZIP_SIG_CENTRALDIR = 0x02014b50, ZIP_SIG_CENTRALDIR = 0x02014b50,
ZIP_SIG_LOCALFILEHEADER = 0x04034b50, ZIP_SIG_LOCALFILEHEADER = 0x04034b50
}; };
static void Zip_DefaultProcessor(const String* path, struct Stream* data, struct ZipEntry* entry) { } static void Zip_DefaultProcessor(const String* path, struct Stream* data, struct ZipEntry* entry) { }
@ -233,16 +233,18 @@ static void EntryList_Load(struct EntryList* list) {
} }
static void EntryList_Save(struct EntryList* list) { static void EntryList_Save(struct EntryList* list) {
struct Stream stream;
ReturnCode res;
int i;
char pathBuffer[FILENAME_SIZE]; char pathBuffer[FILENAME_SIZE];
String path = String_FromArray(pathBuffer); String path = String_FromArray(pathBuffer);
String_Format3(&path, "%c%r%c", list->Folder, &Directory_Separator, list->Filename); String_Format3(&path, "%c%r%c", list->Folder, &Directory_Separator, list->Filename);
if (!Utils_EnsureDirectory(list->Folder)) return; if (!Utils_EnsureDirectory(list->Folder)) return;
ReturnCode res; struct Stream stream;
res = Stream_CreateFile(&stream, &path); res = Stream_CreateFile(&stream, &path);
if (res) { Chat_LogError2(res, "creating", &path); return; } if (res) { Chat_LogError2(res, "creating", &path); return; }
int i;
for (i = 0; i < list->Entries.Count; i++) { for (i = 0; i < list->Entries.Count; i++) {
String entry = StringsBuffer_UNSAFE_Get(&list->Entries, i); String entry = StringsBuffer_UNSAFE_Get(&list->Entries, i);
res = Stream_WriteLine(&stream, &entry); res = Stream_WriteLine(&stream, &entry);
@ -354,10 +356,12 @@ void TextureCache_GetETag(const String* url, String* etag) {
} }
void TextureCache_Set(const String* url, uint8_t* data, uint32_t length) { void TextureCache_Set(const String* url, uint8_t* data, uint32_t length) {
struct Stream stream;
ReturnCode res;
TexCache_InitAndMakePath(url); TexCache_InitAndMakePath(url);
if (!Utils_EnsureDirectory(TEXCACHE_FOLDER)) return; if (!Utils_EnsureDirectory(TEXCACHE_FOLDER)) return;
ReturnCode res; struct Stream stream;
res = Stream_CreateFile(&stream, &path); res = Stream_CreateFile(&stream, &path);
if (res) { Chat_LogError2(res, "creating cache for", &path); return; } if (res) { Chat_LogError2(res, "creating cache for", &path); return; }
@ -390,7 +394,7 @@ void TextureCache_SetETag(const String* url, const String* etag) {
TextureCache_AddToTags(url, etag, &cache_eTags); TextureCache_AddToTags(url, etag, &cache_eTags);
} }
void TextureCache_SetLastModified(const String* url, TimeMS* lastModified) { void TextureCache_SetLastModified(const String* url, const TimeMS* lastModified) {
if (!lastModified) return; if (!lastModified) return;
uint64_t ticks = (*lastModified) * TEXCACHE_TICKS_PER_MS; uint64_t ticks = (*lastModified) * TEXCACHE_TICKS_PER_MS;

View File

@ -61,7 +61,7 @@ void TextureCache_Set(const String* url, uint8_t* data, uint32_t length);
/* Sets the cached ETag header for the given url. */ /* Sets the cached ETag header for the given url. */
void TextureCache_SetETag(const String* url, const String* etag); void TextureCache_SetETag(const String* url, const String* etag);
/* Sets the cached Last-Modified header for the given url. */ /* Sets the cached Last-Modified header for the given url. */
void TextureCache_SetLastModified(const String* url, TimeMS* lastModified); void TextureCache_SetLastModified(const String* url, const TimeMS* lastModified);
void TexturePack_ExtractZip_File(const String* filename); void TexturePack_ExtractZip_File(const String* filename);
void TexturePack_ExtractDefault(void); void TexturePack_ExtractDefault(void);

View File

@ -43,6 +43,7 @@ static ReturnCode Ogg_NextPage(struct Stream* stream) {
} }
static ReturnCode Ogg_Read(struct Stream* stream, uint8_t* data, uint32_t count, uint32_t* modified) { static ReturnCode Ogg_Read(struct Stream* stream, uint8_t* data, uint32_t count, uint32_t* modified) {
ReturnCode res;
for (;;) { for (;;) {
if (stream->Meta.Ogg.Left) { if (stream->Meta.Ogg.Left) {
count = min(count, stream->Meta.Ogg.Left); count = min(count, stream->Meta.Ogg.Left);
@ -57,8 +58,6 @@ static ReturnCode Ogg_Read(struct Stream* stream, uint8_t* data, uint32_t count,
/* try again with data from next page */ /* try again with data from next page */
*modified = 0; *modified = 0;
if (stream->Meta.Ogg.Last) return 0; if (stream->Meta.Ogg.Last) return 0;
ReturnCode res;
if ((res = Ogg_NextPage(stream))) return res; if ((res = Ogg_NextPage(stream))) return res;
} }
} }
@ -67,7 +66,8 @@ static ReturnCode Ogg_ReadU8(struct Stream* stream, uint8_t* data) {
if (!stream->Meta.Ogg.Left) return Stream_DefaultReadU8(stream, data); if (!stream->Meta.Ogg.Left) return Stream_DefaultReadU8(stream, data);
*data = *stream->Meta.Ogg.Cur; *data = *stream->Meta.Ogg.Cur;
stream->Meta.Ogg.Cur++; stream->Meta.Ogg.Left--; stream->Meta.Ogg.Cur++;
stream->Meta.Ogg.Left--;
return 0; return 0;
} }
@ -96,20 +96,25 @@ void Ogg_MakeStream(struct Stream* stream, uint8_t* buffer, struct Stream* sourc
/* TODO: Make sure this is inlined */ /* TODO: Make sure this is inlined */
static uint32_t Vorbis_ReadBits(struct VorbisState* ctx, uint32_t bitsCount) { static uint32_t Vorbis_ReadBits(struct VorbisState* ctx, uint32_t bitsCount) {
uint8_t portion; uint8_t portion;
uint32_t data;
ReturnCode res;
while (ctx->NumBits < bitsCount) { while (ctx->NumBits < bitsCount) {
ReturnCode res = ctx->Source->ReadU8(ctx->Source, &portion); res = ctx->Source->ReadU8(ctx->Source, &portion);
if (res) { ErrorHandler_Fail2(res, "Failed to read byte for vorbis"); } if (res) { ErrorHandler_Fail2(res, "Failed to read byte for vorbis"); }
Vorbis_PushByte(ctx, portion); Vorbis_PushByte(ctx, portion);
} }
uint32_t data = Vorbis_PeekBits(ctx, bitsCount); Vorbis_ConsumeBits(ctx, bitsCount); data = Vorbis_PeekBits(ctx, bitsCount); Vorbis_ConsumeBits(ctx, bitsCount);
return data; return data;
} }
static ReturnCode Vorbis_TryReadBits(struct VorbisState* ctx, uint32_t bitsCount, uint32_t* data) { static ReturnCode Vorbis_TryReadBits(struct VorbisState* ctx, uint32_t bitsCount, uint32_t* data) {
uint8_t portion; uint8_t portion;
ReturnCode res;
while (ctx->NumBits < bitsCount) { while (ctx->NumBits < bitsCount) {
ReturnCode res = ctx->Source->ReadU8(ctx->Source, &portion); res = ctx->Source->ReadU8(ctx->Source, &portion);
if (res) return res; if (res) return res;
Vorbis_PushByte(ctx, portion); Vorbis_PushByte(ctx, portion);
} }
@ -989,11 +994,13 @@ static bool Vorbis_ValidBlockSize(uint32_t size) {
static ReturnCode Vorbis_CheckHeader(struct VorbisState* ctx, uint8_t type) { static ReturnCode Vorbis_CheckHeader(struct VorbisState* ctx, uint8_t type) {
uint8_t header[7]; uint8_t header[7];
bool OK;
ReturnCode res; ReturnCode res;
if ((res = Stream_Read(ctx->Source, header, sizeof(header)))) return res;
if ((res = Stream_Read(ctx->Source, header, sizeof(header)))) return res;
if (header[0] != type) return VORBIS_ERR_WRONG_HEADER; if (header[0] != type) return VORBIS_ERR_WRONG_HEADER;
bool OK =
OK =
header[1] == 'v' && header[2] == 'o' && header[3] == 'r' && header[1] == 'v' && header[2] == 'o' && header[3] == 'r' &&
header[4] == 'b' && header[5] == 'i' && header[6] == 's'; header[4] == 'b' && header[5] == 'i' && header[6] == 's';
return OK ? 0 : ReturnCode_InvalidArg; return OK ? 0 : ReturnCode_InvalidArg;
@ -1001,10 +1008,11 @@ static ReturnCode Vorbis_CheckHeader(struct VorbisState* ctx, uint8_t type) {
static ReturnCode Vorbis_DecodeIdentifier(struct VorbisState* ctx) { static ReturnCode Vorbis_DecodeIdentifier(struct VorbisState* ctx) {
uint8_t header[23]; uint8_t header[23];
uint32_t version;
ReturnCode res; ReturnCode res;
if ((res = Stream_Read(ctx->Source, header, sizeof(header)))) return res;
uint32_t version = Stream_GetU32_LE(&header[0]); if ((res = Stream_Read(ctx->Source, header, sizeof(header)))) return res;
version = Stream_GetU32_LE(&header[0]);
if (version != 0) return VORBIS_ERR_VERSION; if (version != 0) return VORBIS_ERR_VERSION;
ctx->Channels = header[4]; ctx->Channels = header[4];
@ -1104,8 +1112,8 @@ static ReturnCode Vorbis_DecodeSetup(struct VorbisState* ctx) {
} }
ReturnCode Vorbis_DecodeHeaders(struct VorbisState* ctx) { ReturnCode Vorbis_DecodeHeaders(struct VorbisState* ctx) {
ReturnCode res;
uint32_t count; uint32_t count;
ReturnCode res;
if ((res = Vorbis_CheckHeader(ctx, 1))) return res; if ((res = Vorbis_CheckHeader(ctx, 1))) return res;
if ((res = Vorbis_DecodeIdentifier(ctx))) return res; if ((res = Vorbis_DecodeIdentifier(ctx))) return res;

View File

@ -2220,12 +2220,13 @@ static int TextGroupWidget_CalcY(struct TextGroupWidget* w, int index, int newHe
} }
void TextGroupWidget_SetUsePlaceHolder(struct TextGroupWidget* w, int index, bool placeHolder) { void TextGroupWidget_SetUsePlaceHolder(struct TextGroupWidget* w, int index, bool placeHolder) {
int height;
w->PlaceholderHeight[index] = placeHolder; w->PlaceholderHeight[index] = placeHolder;
if (w->Textures[index].ID) return; if (w->Textures[index].ID) return;
int newHeight = placeHolder ? w->DefaultHeight : 0; height = placeHolder ? w->DefaultHeight : 0;
w->Textures[index].Y = TextGroupWidget_CalcY(w, index, newHeight); w->Textures[index].Y = TextGroupWidget_CalcY(w, index, height);
w->Textures[index].Height = newHeight; w->Textures[index].Height = height;
} }
int TextGroupWidget_UsedHeight(struct TextGroupWidget* w) { int TextGroupWidget_UsedHeight(struct TextGroupWidget* w) {

View File

@ -260,7 +260,7 @@ FT_BEGIN_HEADER
/* supply font data incrementally as the document is parsed, such */ /* supply font data incrementally as the document is parsed, such */
/* as the Ghostscript interpreter for the PostScript language. */ /* as the Ghostscript interpreter for the PostScript language. */
/* */ /* */
#define FT_CONFIG_OPTION_INCREMENTAL #undef FT_CONFIG_OPTION_INCREMENTAL
/*************************************************************************/ /*************************************************************************/
@ -556,7 +556,7 @@ FT_BEGIN_HEADER
/* and avar tables). This has many similarities to Type 1 Multiple */ /* and avar tables). This has many similarities to Type 1 Multiple */
/* Masters support. */ /* Masters support. */
/* */ /* */
#define TT_CONFIG_OPTION_GX_VAR_SUPPORT #undef TT_CONFIG_OPTION_GX_VAR_SUPPORT
/*************************************************************************/ /*************************************************************************/
@ -628,7 +628,7 @@ FT_BEGIN_HEADER
/* files into an existing face. Note that if set, the T1 driver will be */ /* files into an existing face. Note that if set, the T1 driver will be */
/* unable to produce kerning distances. */ /* unable to produce kerning distances. */
/* */ /* */
#undef T1_CONFIG_OPTION_NO_AFM #define T1_CONFIG_OPTION_NO_AFM
/*************************************************************************/ /*************************************************************************/
@ -637,7 +637,7 @@ FT_BEGIN_HEADER
/* compilation of the Multiple Masters font support in the Type 1 */ /* compilation of the Multiple Masters font support in the Type 1 */
/* driver. */ /* driver. */
/* */ /* */
#undef T1_CONFIG_OPTION_NO_MM_SUPPORT #define T1_CONFIG_OPTION_NO_MM_SUPPORT
/*************************************************************************/ /*************************************************************************/