mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-16 02:56:09 -04:00
Fix not compiling with macOS SDK < 10.5
This commit is contained in:
parent
f6b9fa63a4
commit
e31adc09e3
@ -30,7 +30,7 @@ void PackedCol_GetShaded(PackedCol normal, PackedCol* xSide, PackedCol* zSide, P
|
|||||||
*yMin = PackedCol_Scale(normal, PACKEDCOL_SHADE_YMIN);
|
*yMin = PackedCol_Scale(normal, PACKEDCOL_SHADE_YMIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int PackedCol_DeHex(char hex) {
|
int PackedCol_DeHex(char hex) {
|
||||||
if (hex >= '0' && hex <= '9') {
|
if (hex >= '0' && hex <= '9') {
|
||||||
return (hex - '0');
|
return (hex - '0');
|
||||||
} else if (hex >= 'a' && hex <= 'f') {
|
} else if (hex >= 'a' && hex <= 'f') {
|
||||||
|
@ -49,6 +49,7 @@ CC_API PackedCol PackedCol_Lerp(PackedCol a, PackedCol b, float t);
|
|||||||
/* Multiplies RGB components of the two given colours. */
|
/* Multiplies RGB components of the two given colours. */
|
||||||
CC_API PackedCol PackedCol_Tint(PackedCol a, PackedCol b);
|
CC_API PackedCol PackedCol_Tint(PackedCol a, PackedCol b);
|
||||||
|
|
||||||
|
CC_NOINLINE int PackedCol_DeHex(char hex);
|
||||||
CC_NOINLINE cc_bool PackedCol_Unhex(const char* src, int* dst, int count);
|
CC_NOINLINE cc_bool PackedCol_Unhex(const char* src, int* dst, int count);
|
||||||
CC_NOINLINE void PackedCol_ToHex(cc_string* str, PackedCol value);
|
CC_NOINLINE void PackedCol_ToHex(cc_string* str, PackedCol value);
|
||||||
CC_NOINLINE cc_bool PackedCol_TryParseHex(const cc_string* str, cc_uint8* rgb);
|
CC_NOINLINE cc_bool PackedCol_TryParseHex(const cc_string* str, cc_uint8* rgb);
|
||||||
|
@ -1821,13 +1821,19 @@ static void DecipherBlock(cc_uint32* v, const cc_uint32* key) {
|
|||||||
#define MACHINEID_LEN 32
|
#define MACHINEID_LEN 32
|
||||||
#define ENC_SIZE 8 /* 2 32 bit ints per block */
|
#define ENC_SIZE 8 /* 2 32 bit ints per block */
|
||||||
|
|
||||||
/* "b3c5a0d9" --> 0xB3C5A0D9 */
|
/* "b3 c5a-0d9" --> 0xB3C5A0D9 */
|
||||||
static void DecodeMachineID(char* tmp, cc_uint8* key) {
|
static void DecodeMachineID(char* tmp, int len, cc_uint32* key) {
|
||||||
int hex[MACHINEID_LEN], i;
|
int hex[MACHINEID_LEN] = { 0 }, i, j, c;
|
||||||
PackedCol_Unhex(tmp, hex, MACHINEID_LEN);
|
cc_uint8* dst = (cc_uint8*)key;
|
||||||
|
|
||||||
|
/* Get each valid hex character */
|
||||||
|
for (i = 0, j = 0; i < len && j < MACHINEID_LEN; i++) {
|
||||||
|
c = PackedCol_DeHex(tmp[i]);
|
||||||
|
if (c != -1) hex[j++] = c;
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < MACHINEID_LEN / 2; i++) {
|
for (i = 0; i < MACHINEID_LEN / 2; i++) {
|
||||||
key[i] = (hex[i * 2] << 4) | hex[i * 2 + 1];
|
dst[i] = (hex[i * 2] << 4) | hex[i * 2 + 1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1843,32 +1849,28 @@ static void GetMachineID(cc_uint32* key) {
|
|||||||
if (Stream_OpenFile(&s, &idFile)) return;
|
if (Stream_OpenFile(&s, &idFile)) return;
|
||||||
|
|
||||||
if (!Stream_Read(&s, tmp, MACHINEID_LEN)) {
|
if (!Stream_Read(&s, tmp, MACHINEID_LEN)) {
|
||||||
DecodeMachineID(tmp, (cc_uint8*)key);
|
DecodeMachineID(tmp, MACHINEID_LEN, key);
|
||||||
}
|
}
|
||||||
s.Close(&s);
|
(void)s.Close(&s);
|
||||||
}
|
}
|
||||||
#elif defined CC_BUILD_MACOS
|
#elif defined CC_BUILD_MACOS
|
||||||
static void GetMachineID(cc_uint32* key) {
|
static void GetMachineID(cc_uint32* key) {
|
||||||
io_registry_entry_t registry;
|
io_registry_entry_t registry;
|
||||||
CFStringRef uuid;
|
CFStringRef uuid = NULL;
|
||||||
char tmp[MACHINEID_LEN] = { 0 };
|
|
||||||
const char* src;
|
const char* src;
|
||||||
struct Stream s;
|
struct Stream s;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < 4; i++) key[i] = 0;
|
for (i = 0; i < 4; i++) key[i] = 0;
|
||||||
|
|
||||||
registry = IORegistryEntryFromPath(kIOMasterPortDefault, "IOService:/");
|
registry = IORegistryEntryFromPath(kIOMasterPortDefault, "IOService:/");
|
||||||
if (!registry) return;
|
if (!registry) return;
|
||||||
|
|
||||||
|
#ifdef kIOPlatformUUIDKey
|
||||||
uuid = IORegistryEntryCreateCFProperty(registry, CFSTR(kIOPlatformUUIDKey), kCFAllocatorDefault, 0);
|
uuid = IORegistryEntryCreateCFProperty(registry, CFSTR(kIOPlatformUUIDKey), kCFAllocatorDefault, 0);
|
||||||
if (uuid && (src = CFStringGetCStringPtr(uuid, kCFStringEncodingUTF8))) {
|
if (uuid && (src = CFStringGetCStringPtr(uuid, kCFStringEncodingUTF8))) {
|
||||||
for (i = 0; *src && i < MACHINEID_LEN; src++) {
|
DecodeMachineID(src, String_Length(src), key);
|
||||||
if (*src == '-') continue;
|
|
||||||
tmp[i++] = *src;
|
|
||||||
}
|
|
||||||
DecodeMachineID(tmp, (cc_uint8*)key);
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
if (uuid) CFRelease(uuid);
|
if (uuid) CFRelease(uuid);
|
||||||
IOObjectRelease(registry);
|
IOObjectRelease(registry);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user