mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-19 04:26:52 -04:00
C client: Fix crashing when selecting font list
This commit is contained in:
parent
837fd1cf05
commit
d39ad38852
@ -883,12 +883,13 @@ NBT_END,
|
|||||||
static ReturnCode Cw_WriteBockDef(struct Stream* stream, Int32 b) {
|
static ReturnCode Cw_WriteBockDef(struct Stream* stream, Int32 b) {
|
||||||
UInt8 tmp[512];
|
UInt8 tmp[512];
|
||||||
bool sprite = Block_Draw[b] == DRAW_SPRITE;
|
bool sprite = Block_Draw[b] == DRAW_SPRITE;
|
||||||
|
union IntAndFloat speed;
|
||||||
|
|
||||||
Mem_Copy(tmp, cw_meta_def, sizeof(cw_meta_def));
|
Mem_Copy(tmp, cw_meta_def, sizeof(cw_meta_def));
|
||||||
{
|
{
|
||||||
tmp[13] = b;
|
tmp[13] = b;
|
||||||
tmp[28] = Block_Collide[b];
|
tmp[28] = Block_Collide[b];
|
||||||
union IntAndFloat speed; speed.f = Block_SpeedMultiplier[b];
|
speed.f = Block_SpeedMultiplier[b];
|
||||||
Stream_SetU32_BE(&tmp[37], speed.u);
|
Stream_SetU32_BE(&tmp[37], speed.u);
|
||||||
|
|
||||||
tmp[56] = (UInt8)Block_GetTexLoc(b, FACE_YMAX);
|
tmp[56] = (UInt8)Block_GetTexLoc(b, FACE_YMAX);
|
||||||
|
@ -52,19 +52,9 @@ bool PackedCol_Unhex(UInt8 hex, Int32* value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PackedCol_ToHex(String* str, PackedCol value) {
|
void PackedCol_ToHex(String* str, PackedCol value) {
|
||||||
UInt8 input[3] = { value.R, value.G, value.B };
|
String_AppendHex(str, value.R);
|
||||||
char hex[7];
|
String_AppendHex(str, value.G);
|
||||||
Int32 i;
|
String_AppendHex(str, value.B);
|
||||||
|
|
||||||
for (i = 0; i < 3; i++) {
|
|
||||||
Int32 cur = input[i], hi = cur >> 4, lo = cur & 0x0F;
|
|
||||||
/* 48 = index of 0, 55 = index of (A - 10) */
|
|
||||||
hex[i * 2 + 0] = hi < 10 ? (hi + 48) : (hi + 55);
|
|
||||||
hex[i * 2 + 1] = lo < 10 ? (lo + 48) : (lo + 55);
|
|
||||||
}
|
|
||||||
|
|
||||||
hex[6] = '\0';
|
|
||||||
String_AppendConst(str, hex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PackedCol_TryParseHex(const String* str, PackedCol* value) {
|
bool PackedCol_TryParseHex(const String* str, PackedCol* value) {
|
||||||
|
@ -29,14 +29,14 @@ PackedCol PackedCol_Create3(UInt8 r, UInt8 g, UInt8 b);
|
|||||||
UInt32 PackedCol_ToARGB(PackedCol col);
|
UInt32 PackedCol_ToARGB(PackedCol col);
|
||||||
PackedCol PackedCol_Scale(PackedCol value, float t);
|
PackedCol PackedCol_Scale(PackedCol value, float t);
|
||||||
PackedCol PackedCol_Lerp(PackedCol a, PackedCol b, float t);
|
PackedCol PackedCol_Lerp(PackedCol a, PackedCol b, float t);
|
||||||
void PackedCol_ToHex(String* str, PackedCol value);
|
NOINLINE_ void PackedCol_ToHex(String* str, PackedCol value);
|
||||||
bool PackedCol_TryParseHex(const String* str, PackedCol* value);
|
NOINLINE_ bool PackedCol_TryParseHex(const String* str, PackedCol* value);
|
||||||
bool PackedCol_Unhex(UInt8 hex, Int32* value);
|
NOINLINE_ bool PackedCol_Unhex(UInt8 hex, Int32* value);
|
||||||
|
|
||||||
#define PACKEDCOL_SHADE_X 0.6f
|
#define PACKEDCOL_SHADE_X 0.6f
|
||||||
#define PACKEDCOL_SHADE_Z 0.8f
|
#define PACKEDCOL_SHADE_Z 0.8f
|
||||||
#define PACKEDCOL_SHADE_YMIN 0.5f
|
#define PACKEDCOL_SHADE_YMIN 0.5f
|
||||||
/* Retrieves shaded colours for ambient block face lighting. */
|
/* Retrieves shaded colours for ambient block face lighting */
|
||||||
void PackedCol_GetShaded(PackedCol normal, PackedCol* xSide, PackedCol* zSide, PackedCol* yMin);
|
void PackedCol_GetShaded(PackedCol normal, PackedCol* xSide, PackedCol* zSide, PackedCol* yMin);
|
||||||
|
|
||||||
#define PACKEDCOL_WHITE PACKEDCOL_CONST(255, 255, 255, 255)
|
#define PACKEDCOL_WHITE PACKEDCOL_CONST(255, 255, 255, 255)
|
||||||
|
@ -763,7 +763,7 @@ static void Font_DirCallback(const String* srcPath, void* obj) {
|
|||||||
if (error) return;
|
if (error) return;
|
||||||
|
|
||||||
bool styled = (face->style_flags & FT_STYLE_FLAG_BOLD) || (face->style_flags & FT_STYLE_FLAG_ITALIC);
|
bool styled = (face->style_flags & FT_STYLE_FLAG_BOLD) || (face->style_flags & FT_STYLE_FLAG_ITALIC);
|
||||||
if (!styled && face->family_name) {
|
if (!styled && face->family_name && (face->face_flags & FT_FACE_FLAG_SCALABLE)) {
|
||||||
StringsBuffer_Add(&fonts_list, &path);
|
StringsBuffer_Add(&fonts_list, &path);
|
||||||
path.length = 0;
|
path.length = 0;
|
||||||
|
|
||||||
|
40
src/String.c
40
src/String.c
@ -226,30 +226,36 @@ bool String_AppendReal32(String* str, float num, Int32 fracDigits) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
NOINLINE_ static bool String_Hex32(String* str, UInt32 value) {
|
bool String_AppendHex(String* str, UInt8 value) {
|
||||||
char hex[9]; hex[8] = '\0';
|
|
||||||
Int32 i;
|
|
||||||
|
|
||||||
for (i = 0; i < 8; i++) {
|
|
||||||
UInt32 nibble = value & 0x0F;
|
|
||||||
/* 48 = index of 0, 55 = index of (A - 10) */
|
/* 48 = index of 0, 55 = index of (A - 10) */
|
||||||
hex[7 - i] = nibble < 10 ? (nibble + 48) : (nibble + 55);
|
UInt8 hi = (value >> 4) & 0xF;
|
||||||
value >>= 4;
|
char c_hi = hi < 10 ? (hi + 48) : (hi + 55);
|
||||||
|
UInt8 lo = value & 0xF;
|
||||||
|
char c_lo = lo < 10 ? (lo + 48) : (lo + 55);
|
||||||
|
|
||||||
|
return String_Append(str, c_hi) && String_Append(str, c_lo);
|
||||||
|
}
|
||||||
|
|
||||||
|
NOINLINE_ static bool String_Hex32(String* str, UInt32 value) {
|
||||||
|
bool appended;
|
||||||
|
Int32 shift;
|
||||||
|
|
||||||
|
for (shift = 24; shift >= 0; shift -= 8) {
|
||||||
|
UInt8 part = (UInt8)(value >> shift);
|
||||||
|
appended = String_AppendHex(str, part);
|
||||||
}
|
}
|
||||||
return String_AppendConst(str, hex);
|
return appended;
|
||||||
}
|
}
|
||||||
|
|
||||||
NOINLINE_ static bool String_Hex64(String* str, UInt64 value) {
|
NOINLINE_ static bool String_Hex64(String* str, UInt64 value) {
|
||||||
char hex[17]; hex[16] = '\0';
|
bool appended;
|
||||||
Int32 i;
|
Int32 shift;
|
||||||
|
|
||||||
for (i = 0; i < 16; i++) {
|
for (shift = 56; shift >= 0; shift -= 8) {
|
||||||
UInt32 nibble = (UInt32)(value & 0x0F);
|
UInt8 part = (UInt8)(value >> shift);
|
||||||
/* 48 = index of 0, 55 = index of (A - 10) */
|
appended = String_AppendHex(str, part);
|
||||||
hex[15 - i] = nibble < 10 ? (nibble + 48) : (nibble + 55);
|
|
||||||
value >>= 4;
|
|
||||||
}
|
}
|
||||||
return String_AppendConst(str, hex);
|
return appended;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool String_AppendConst(String* str, const char* src) {
|
bool String_AppendConst(String* str, const char* src) {
|
||||||
|
@ -61,6 +61,7 @@ NOINLINE_ bool String_AppendReal32(String* str, float num, Int32 fracDigits); /*
|
|||||||
NOINLINE_ bool String_AppendConst(String* str, const char* src);
|
NOINLINE_ bool String_AppendConst(String* str, const char* src);
|
||||||
NOINLINE_ bool String_AppendString(String* str, const String* src);
|
NOINLINE_ bool String_AppendString(String* str, const String* src);
|
||||||
NOINLINE_ bool String_AppendColorless(String* str, const String* src);
|
NOINLINE_ bool String_AppendColorless(String* str, const String* src);
|
||||||
|
NOINLINE_ bool String_AppendHex(String* str, UInt8 value);
|
||||||
|
|
||||||
NOINLINE_ Int32 String_IndexOf(const String* str, char c, Int32 offset);
|
NOINLINE_ Int32 String_IndexOf(const String* str, char c, Int32 offset);
|
||||||
NOINLINE_ Int32 String_LastIndexOf(const String* str, char c);
|
NOINLINE_ Int32 String_LastIndexOf(const String* str, char c);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user