mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-17 19:45:23 -04:00
disable some more unused bits of freetype
This commit is contained in:
parent
5185b79a45
commit
aa020aaf22
@ -385,7 +385,7 @@ ReturnCode Png_Decode(Bitmap* bmp, struct Stream* stream) {
|
||||
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 */
|
||||
bufferIdx = scanlineBytes;
|
||||
bufferIdx = scanlineBytes;
|
||||
bufferRows = PNG_BUFFER_SIZE / scanlineBytes;
|
||||
} break;
|
||||
|
||||
|
22
src/Entity.c
22
src/Entity.c
@ -475,17 +475,18 @@ void TabList_MakeComponent(struct IGameComponent* comp) {
|
||||
*#########################################################################################################################*/
|
||||
#define PLAYER_NAME_EMPTY_TEX -30000
|
||||
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 */
|
||||
bool bitmapped = Drawer2D_BitmappedText;
|
||||
Drawer2D_BitmappedText = true;
|
||||
|
||||
String displayName = String_FromRawArray(player->DisplayNameRaw);
|
||||
FontDesc font;
|
||||
Drawer2D_MakeFont(&font, 24, FONT_STYLE_NORMAL);
|
||||
|
||||
struct DrawTextArgs args;
|
||||
DrawTextArgs_Make(&args, &displayName, &font, false);
|
||||
Size2D size = Drawer2D_MeasureText(&args);
|
||||
Drawer2D_MakeFont(&args.Font, 24, FONT_STYLE_NORMAL);
|
||||
DrawTextArgs_Make(&args, &displayName, &args.Font, false);
|
||||
size = Drawer2D_MeasureText(&args);
|
||||
|
||||
if (size.Width == 0) {
|
||||
player->NameTex.ID = GFX_NULL;
|
||||
@ -495,7 +496,7 @@ static void Player_MakeNameTexture(struct Player* player) {
|
||||
String shadowName = String_FromArray(buffer);
|
||||
|
||||
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'];
|
||||
|
||||
@ -526,6 +527,7 @@ static void Player_DrawName(struct Player* player) {
|
||||
struct Entity* e = &player->Base;
|
||||
struct Model* model = e->Model;
|
||||
Vector3 pos;
|
||||
float scale;
|
||||
|
||||
if (player->NameTex.X == PLAYER_NAME_EMPTY_TEX) return;
|
||||
if (!player->NameTex.ID) Player_MakeNameTexture(player);
|
||||
@ -534,7 +536,7 @@ static void Player_DrawName(struct Player* player) {
|
||||
model->RecalcProperties(e);
|
||||
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);
|
||||
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) {
|
||||
int width = Math_NextPowOf2(bmp->Width);
|
||||
int height = Math_NextPowOf2(bmp->Height);
|
||||
Bitmap scaled;
|
||||
|
||||
if (width == bmp->Width && height == bmp->Height) return;
|
||||
|
||||
Bitmap scaled; Bitmap_Allocate(&scaled, width, height);
|
||||
Bitmap_Allocate(&scaled, width, height);
|
||||
int y;
|
||||
uint32_t stride = (uint32_t)(bmp->Width) * BITMAP_SIZEOF_PIXEL;
|
||||
for (y = 0; y < bmp->Height; y++) {
|
||||
|
@ -45,6 +45,6 @@ enum ERRORS_ALL {
|
||||
DAT_ERR_JCLASS_TYPE, DAT_ERR_JCLASS_FIELDS, DAT_ERR_JCLASS_ANNOTATION,
|
||||
DAT_ERR_JOBJECT_TYPE, DAT_ERR_JARRAY_TYPE, DAT_ERR_JARRAY_CONTENT,
|
||||
/* 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
|
||||
|
78
src/Menus.c
78
src/Menus.c
@ -48,7 +48,7 @@ struct ListScreen {
|
||||
String TitleText;
|
||||
struct TextWidget Title, Page;
|
||||
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;
|
||||
@ -1392,14 +1392,16 @@ struct Screen* SaveLevelScreen_MakeInstance(void) {
|
||||
*#########################################################################################################################*/
|
||||
static void TexturePackScreen_EntryClick(void* screen, void* widget) {
|
||||
struct ListScreen* s = screen;
|
||||
String filename;
|
||||
int idx;
|
||||
char pathBuffer[FILENAME_SIZE];
|
||||
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);
|
||||
if (!File_Exists(&path)) return;
|
||||
|
||||
int idx = s->CurrentIndex;
|
||||
idx = s->CurrentIndex;
|
||||
Game_SetDefaultTexturePack(&filename);
|
||||
TexturePack_ExtractDefault();
|
||||
Elem_Recreate(s);
|
||||
@ -1614,10 +1616,11 @@ void LoadLevelScreen_LoadMap(const String* path) {
|
||||
|
||||
static void LoadLevelScreen_EntryClick(void* screen, void* widget) {
|
||||
struct ListScreen* s = screen;
|
||||
String filename;
|
||||
char pathBuffer[FILENAME_SIZE];
|
||||
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);
|
||||
if (!File_Exists(&path)) return;
|
||||
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) {
|
||||
struct KeyBindingsScreen* s = screen;
|
||||
struct ButtonWidget* btn = widget;
|
||||
struct ButtonWidget* cur;
|
||||
char textBuffer[STRING_SIZE];
|
||||
String text = String_FromArray(textBuffer);
|
||||
|
||||
/* previously selected a different button for binding */
|
||||
if (s->CurI >= 0) {
|
||||
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);
|
||||
}
|
||||
s->CurI = Menu_Index(s, btn);
|
||||
@ -1669,7 +1673,10 @@ static void KeyBindingsScreen_OnBindingClick(void* screen, void* widget) {
|
||||
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;
|
||||
s->CurI = -1;
|
||||
|
||||
@ -1695,25 +1702,24 @@ static int KeyBindingsScreen_MakeWidgets(struct KeyBindingsScreen* s, int y, int
|
||||
Widget_LeftClick backClick = Game_UseClassicOptions ? Menu_SwitchClassicOptions : Menu_SwitchOptions;
|
||||
Menu_Back(s, i, &s->Back, "Done", &s->TitleFont, backClick); 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++;
|
||||
s->Left.Disabled = !s->LeftPage;
|
||||
|
||||
String rArrow = String_FromConst(">");
|
||||
Menu_Button(s, i, &s->Right, 40, &rArrow, &s->TitleFont, s->RightPage,
|
||||
ANCHOR_CENTRE, ANCHOR_CENTRE, btnWidth + 35, arrowsY); i++;
|
||||
s->Right.Disabled = !s->RightPage;
|
||||
ANCHOR_CENTRE, ANCHOR_CENTRE, btnWidth + 35, arrowsY); i++;
|
||||
|
||||
s->Left.Disabled = !s->LeftPage;
|
||||
s->Right.Disabled = !s->RightPage;
|
||||
return i;
|
||||
}
|
||||
|
||||
static bool KeyBindingsScreen_KeyDown(void* screen, Key key) {
|
||||
struct KeyBindingsScreen* s = screen;
|
||||
struct ButtonWidget* cur;
|
||||
KeyBind bind;
|
||||
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);
|
||||
KeyBind_Set(bind, key);
|
||||
|
||||
@ -1721,7 +1727,7 @@ static bool KeyBindingsScreen_KeyDown(void* screen, Key key) {
|
||||
String text = String_FromArray(textBuffer);
|
||||
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);
|
||||
s->CurI = -1;
|
||||
return true;
|
||||
@ -2142,13 +2148,12 @@ static void MenuOptionsScreen_Input(void* screen, void* widget) {
|
||||
static String okay = String_FromConst("OK");
|
||||
static String def = String_FromConst("Default value");
|
||||
|
||||
struct MenuOptionsScreen* s = screen;
|
||||
struct ButtonWidget* btn = widget;
|
||||
int i;
|
||||
char valueBuffer[STRING_SIZE];
|
||||
String value = String_FromArray(valueBuffer);
|
||||
|
||||
struct MenuOptionsScreen* s = screen;
|
||||
struct ButtonWidget* btn = widget;
|
||||
int i;
|
||||
|
||||
s->ActiveI = Menu_Index(s, btn);
|
||||
MenuOptionsScreen_FreeExtHelp(s);
|
||||
MenuOptionsScreen_FreeInput(s);
|
||||
@ -3168,8 +3173,10 @@ struct Screen* UrlWarningOverlay_MakeInstance(const String* url) {
|
||||
struct ConfirmDenyOverlay ConfirmDenyOverlay_Instance;
|
||||
static void ConfirmDenyOverlay_ConfirmNoClick(void* screen, void* b) {
|
||||
struct ConfirmDenyOverlay* s = screen;
|
||||
String url;
|
||||
|
||||
Gui_FreeOverlay(s);
|
||||
String url = s->Url;
|
||||
url = s->Url;
|
||||
|
||||
if (s->AlwaysDeny && !TextureCache_HasDenied(&url)) {
|
||||
TextureCache_Deny(&url);
|
||||
@ -3178,8 +3185,10 @@ static void ConfirmDenyOverlay_ConfirmNoClick(void* screen, void* b) {
|
||||
|
||||
static void ConfirmDenyOverlay_GoBackClick(void* screen, void* b) {
|
||||
struct ConfirmDenyOverlay* s = screen;
|
||||
struct Screen* overlay;
|
||||
|
||||
Gui_FreeOverlay(s);
|
||||
struct Screen* overlay = TexPackOverlay_MakeInstance(&s->Url);
|
||||
overlay = TexPackOverlay_MakeInstance(&s->Url);
|
||||
Gui_ShowOverlay(overlay, true);
|
||||
}
|
||||
|
||||
@ -3232,12 +3241,14 @@ struct Screen* ConfirmDenyOverlay_MakeInstance(const String* url, bool alwaysDen
|
||||
struct TexPackOverlay TexPackOverlay_Instance;
|
||||
static void TexPackOverlay_YesClick(void* screen, void* widget) {
|
||||
struct TexPackOverlay* s = screen;
|
||||
String url;
|
||||
bool isAlways;
|
||||
|
||||
Gui_FreeOverlay(s);
|
||||
String url = s->Identifier;
|
||||
url = String_UNSAFE_SubstringAt(&url, 3);
|
||||
url = String_UNSAFE_SubstringAt(&s->Identifier, 3);
|
||||
|
||||
ServerConnection_DownloadTexturePack(&url);
|
||||
bool isAlways = WarningOverlay_IsAlways(s, widget);
|
||||
isAlways = WarningOverlay_IsAlways(s, widget);
|
||||
if (isAlways && !TextureCache_HasAccepted(&url)) {
|
||||
TextureCache_Accept(&url);
|
||||
}
|
||||
@ -3245,11 +3256,13 @@ static void TexPackOverlay_YesClick(void* screen, void* widget) {
|
||||
|
||||
static void TexPackOverlay_NoClick(void* screen, void* widget) {
|
||||
struct TexPackOverlay* s = screen;
|
||||
Gui_FreeOverlay(s);
|
||||
String url = s->Identifier;
|
||||
url = String_UNSAFE_SubstringAt(&url, 3);
|
||||
String url;
|
||||
bool isAlways;
|
||||
|
||||
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);
|
||||
Gui_ShowOverlay(overlay, true);
|
||||
}
|
||||
@ -3269,11 +3282,10 @@ static void TexPackOverlay_Render(void* screen, double delta) {
|
||||
static void TexPackOverlay_ContextRecreated(void* screen) {
|
||||
static String https = String_FromConst("https://");
|
||||
static String http = String_FromConst("http://");
|
||||
|
||||
struct TexPackOverlay* s = screen;
|
||||
String url = s->Identifier;
|
||||
url = String_UNSAFE_SubstringAt(&url, 3);
|
||||
|
||||
String url;
|
||||
|
||||
url = String_UNSAFE_SubstringAt(&s->Identifier, 3);
|
||||
if (String_CaselessStarts(&url, &https)) {
|
||||
url = String_UNSAFE_SubstringAt(&url, https.length);
|
||||
}
|
||||
|
@ -944,16 +944,15 @@ static bool ChatScreen_KeyUp(void* screen, Key key) {
|
||||
if (!s->HandlesAllInput) return false;
|
||||
|
||||
if (ServerConnection_SupportsFullCP437 && key == KeyBind_Get(KeyBind_ExtInput)) {
|
||||
if (Window_Focused) {
|
||||
bool active = !s->AltText.Active;
|
||||
SpecialInputWidget_SetActive(&s->AltText, active);
|
||||
}
|
||||
if (!Window_Focused) return true;
|
||||
SpecialInputWidget_SetActive(&s->AltText, !s->AltText.Active);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool ChatScreen_KeyPress(void* screen, char keyChar) {
|
||||
struct ChatScreen* s = screen;
|
||||
bool handled;
|
||||
if (!s->HandlesAllInput) return false;
|
||||
|
||||
if (s->SuppressNextPress) {
|
||||
@ -961,16 +960,17 @@ static bool ChatScreen_KeyPress(void* screen, char keyChar) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool handled = Elem_HandlesKeyPress(&s->Input.Base, keyChar);
|
||||
handled = Elem_HandlesKeyPress(&s->Input.Base, keyChar);
|
||||
ChatScreen_UpdateAltTextY(s);
|
||||
return handled;
|
||||
}
|
||||
|
||||
static bool ChatScreen_MouseScroll(void* screen, float delta) {
|
||||
struct ChatScreen* s = screen;
|
||||
int steps;
|
||||
if (!s->HandlesAllInput) return false;
|
||||
|
||||
int steps = Utils_AccumulateWheelDelta(&s->ChatAcc, delta);
|
||||
steps = Utils_AccumulateWheelDelta(&s->ChatAcc, delta);
|
||||
ChatScreen_ScrollHistoryBy(s, -steps);
|
||||
return true;
|
||||
}
|
||||
|
27
src/Stream.c
27
src/Stream.c
@ -198,7 +198,8 @@ static ReturnCode Stream_MemoryRead(struct Stream* s, uint8_t* data, uint32_t co
|
||||
count = min(count, s->Meta.Mem.Left);
|
||||
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;
|
||||
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;
|
||||
|
||||
*data = *s->Meta.Mem.Cur;
|
||||
s->Meta.Mem.Cur++; s->Meta.Mem.Left--;
|
||||
s->Meta.Mem.Cur++;
|
||||
s->Meta.Mem.Left--;
|
||||
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);
|
||||
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;
|
||||
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) {
|
||||
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;
|
||||
}
|
||||
|
||||
@ -288,18 +292,19 @@ static ReturnCode Stream_BufferedRead(struct Stream* s, uint8_t* data, uint32_t
|
||||
count = min(count, s->Meta.Buffered.Left);
|
||||
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;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static ReturnCode Stream_BufferedReadU8(struct Stream* s, uint8_t* data) {
|
||||
if (s->Meta.Buffered.Left) {
|
||||
*data = *s->Meta.Buffered.Cur;
|
||||
s->Meta.Buffered.Cur++; s->Meta.Buffered.Left--;
|
||||
return 0;
|
||||
}
|
||||
return Stream_DefaultReadU8(s, data);
|
||||
if (!s->Meta.Buffered.Left) return Stream_DefaultReadU8(s, data);
|
||||
|
||||
*data = *s->Meta.Buffered.Cur;
|
||||
s->Meta.Buffered.Cur++;
|
||||
s->Meta.Buffered.Left--;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static ReturnCode Stream_BufferedSeek(struct Stream* s, uint32_t position) {
|
||||
|
@ -115,10 +115,10 @@ static ReturnCode Zip_ReadEndOfCentralDirectory(struct ZipState* state, uint32_t
|
||||
return 0;
|
||||
}
|
||||
|
||||
enum ZIP_SIG {
|
||||
enum ZipSig {
|
||||
ZIP_SIG_ENDOFCENTRALDIR = 0x06054b50,
|
||||
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) { }
|
||||
@ -233,16 +233,18 @@ static void EntryList_Load(struct EntryList* list) {
|
||||
}
|
||||
|
||||
static void EntryList_Save(struct EntryList* list) {
|
||||
struct Stream stream;
|
||||
ReturnCode res;
|
||||
int i;
|
||||
char pathBuffer[FILENAME_SIZE];
|
||||
String path = String_FromArray(pathBuffer);
|
||||
|
||||
String_Format3(&path, "%c%r%c", list->Folder, &Directory_Separator, list->Filename);
|
||||
if (!Utils_EnsureDirectory(list->Folder)) return;
|
||||
|
||||
ReturnCode res; struct Stream stream;
|
||||
|
||||
res = Stream_CreateFile(&stream, &path);
|
||||
if (res) { Chat_LogError2(res, "creating", &path); return; }
|
||||
|
||||
int i;
|
||||
for (i = 0; i < list->Entries.Count; i++) {
|
||||
String entry = StringsBuffer_UNSAFE_Get(&list->Entries, i);
|
||||
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) {
|
||||
struct Stream stream;
|
||||
ReturnCode res;
|
||||
|
||||
TexCache_InitAndMakePath(url);
|
||||
if (!Utils_EnsureDirectory(TEXCACHE_FOLDER)) return;
|
||||
|
||||
ReturnCode res; struct Stream stream;
|
||||
|
||||
res = Stream_CreateFile(&stream, &path);
|
||||
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);
|
||||
}
|
||||
|
||||
void TextureCache_SetLastModified(const String* url, TimeMS* lastModified) {
|
||||
void TextureCache_SetLastModified(const String* url, const TimeMS* lastModified) {
|
||||
if (!lastModified) return;
|
||||
uint64_t ticks = (*lastModified) * TEXCACHE_TICKS_PER_MS;
|
||||
|
||||
|
@ -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. */
|
||||
void TextureCache_SetETag(const String* url, const String* etag);
|
||||
/* 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_ExtractDefault(void);
|
||||
|
30
src/Vorbis.c
30
src/Vorbis.c
@ -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) {
|
||||
ReturnCode res;
|
||||
for (;;) {
|
||||
if (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 */
|
||||
*modified = 0;
|
||||
if (stream->Meta.Ogg.Last) return 0;
|
||||
|
||||
ReturnCode 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);
|
||||
|
||||
*data = *stream->Meta.Ogg.Cur;
|
||||
stream->Meta.Ogg.Cur++; stream->Meta.Ogg.Left--;
|
||||
stream->Meta.Ogg.Cur++;
|
||||
stream->Meta.Ogg.Left--;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -96,20 +96,25 @@ void Ogg_MakeStream(struct Stream* stream, uint8_t* buffer, struct Stream* sourc
|
||||
/* TODO: Make sure this is inlined */
|
||||
static uint32_t Vorbis_ReadBits(struct VorbisState* ctx, uint32_t bitsCount) {
|
||||
uint8_t portion;
|
||||
uint32_t data;
|
||||
ReturnCode res;
|
||||
|
||||
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"); }
|
||||
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;
|
||||
}
|
||||
|
||||
static ReturnCode Vorbis_TryReadBits(struct VorbisState* ctx, uint32_t bitsCount, uint32_t* data) {
|
||||
uint8_t portion;
|
||||
ReturnCode res;
|
||||
|
||||
while (ctx->NumBits < bitsCount) {
|
||||
ReturnCode res = ctx->Source->ReadU8(ctx->Source, &portion);
|
||||
res = ctx->Source->ReadU8(ctx->Source, &portion);
|
||||
if (res) return res;
|
||||
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) {
|
||||
uint8_t header[7];
|
||||
bool OK;
|
||||
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;
|
||||
bool OK =
|
||||
|
||||
OK =
|
||||
header[1] == 'v' && header[2] == 'o' && header[3] == 'r' &&
|
||||
header[4] == 'b' && header[5] == 'i' && header[6] == 's';
|
||||
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) {
|
||||
uint8_t header[23];
|
||||
uint32_t version;
|
||||
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;
|
||||
|
||||
ctx->Channels = header[4];
|
||||
@ -1104,8 +1112,8 @@ static ReturnCode Vorbis_DecodeSetup(struct VorbisState* ctx) {
|
||||
}
|
||||
|
||||
ReturnCode Vorbis_DecodeHeaders(struct VorbisState* ctx) {
|
||||
ReturnCode res;
|
||||
uint32_t count;
|
||||
ReturnCode res;
|
||||
|
||||
if ((res = Vorbis_CheckHeader(ctx, 1))) return res;
|
||||
if ((res = Vorbis_DecodeIdentifier(ctx))) return res;
|
||||
|
@ -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) {
|
||||
int height;
|
||||
w->PlaceholderHeight[index] = placeHolder;
|
||||
if (w->Textures[index].ID) return;
|
||||
|
||||
int newHeight = placeHolder ? w->DefaultHeight : 0;
|
||||
w->Textures[index].Y = TextGroupWidget_CalcY(w, index, newHeight);
|
||||
w->Textures[index].Height = newHeight;
|
||||
height = placeHolder ? w->DefaultHeight : 0;
|
||||
w->Textures[index].Y = TextGroupWidget_CalcY(w, index, height);
|
||||
w->Textures[index].Height = height;
|
||||
}
|
||||
|
||||
int TextGroupWidget_UsedHeight(struct TextGroupWidget* w) {
|
||||
|
@ -260,7 +260,7 @@ FT_BEGIN_HEADER
|
||||
/* supply font data incrementally as the document is parsed, such */
|
||||
/* 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 */
|
||||
/* 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 */
|
||||
/* 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 */
|
||||
/* driver. */
|
||||
/* */
|
||||
#undef T1_CONFIG_OPTION_NO_MM_SUPPORT
|
||||
#define T1_CONFIG_OPTION_NO_MM_SUPPORT
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
|
Loading…
x
Reference in New Issue
Block a user