mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-15 18:45:23 -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);
|
||||
}
|
||||
|
||||
static int PackedCol_DeHex(char hex) {
|
||||
int PackedCol_DeHex(char hex) {
|
||||
if (hex >= '0' && hex <= '9') {
|
||||
return (hex - '0');
|
||||
} 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. */
|
||||
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 void PackedCol_ToHex(cc_string* str, PackedCol value);
|
||||
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 ENC_SIZE 8 /* 2 32 bit ints per block */
|
||||
|
||||
/* "b3c5a0d9" --> 0xB3C5A0D9 */
|
||||
static void DecodeMachineID(char* tmp, cc_uint8* key) {
|
||||
int hex[MACHINEID_LEN], i;
|
||||
PackedCol_Unhex(tmp, hex, MACHINEID_LEN);
|
||||
/* "b3 c5a-0d9" --> 0xB3C5A0D9 */
|
||||
static void DecodeMachineID(char* tmp, int len, cc_uint32* key) {
|
||||
int hex[MACHINEID_LEN] = { 0 }, i, j, c;
|
||||
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++) {
|
||||
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_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
|
||||
static void GetMachineID(cc_uint32* key) {
|
||||
io_registry_entry_t registry;
|
||||
CFStringRef uuid;
|
||||
char tmp[MACHINEID_LEN] = { 0 };
|
||||
CFStringRef uuid = NULL;
|
||||
const char* src;
|
||||
struct Stream s;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 4; i++) key[i] = 0;
|
||||
|
||||
registry = IORegistryEntryFromPath(kIOMasterPortDefault, "IOService:/");
|
||||
if (!registry) return;
|
||||
|
||||
#ifdef kIOPlatformUUIDKey
|
||||
uuid = IORegistryEntryCreateCFProperty(registry, CFSTR(kIOPlatformUUIDKey), kCFAllocatorDefault, 0);
|
||||
if (uuid && (src = CFStringGetCStringPtr(uuid, kCFStringEncodingUTF8))) {
|
||||
for (i = 0; *src && i < MACHINEID_LEN; src++) {
|
||||
if (*src == '-') continue;
|
||||
tmp[i++] = *src;
|
||||
}
|
||||
DecodeMachineID(tmp, (cc_uint8*)key);
|
||||
DecodeMachineID(src, String_Length(src), key);
|
||||
}
|
||||
#endif
|
||||
if (uuid) CFRelease(uuid);
|
||||
IOObjectRelease(registry);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user