mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-01-22 09:01:57 -05:00
Mac: Implement session caching too
This commit is contained in:
parent
b692db5a16
commit
3ad1f1f169
4 changed files with 35 additions and 7 deletions
|
@ -74,14 +74,14 @@ build_mac32() {
|
|||
echo "Building mac32.."
|
||||
cp $SOURCE_DIR/misc/CCicon_mac32 $SOURCE_DIR/src/CCicon_mac32.o
|
||||
rm cc-osx32
|
||||
$MAC32_CC *.c $ALL_FLAGS $MACOS_FLAGS CCicon_mac32.o -DCC_COMMIT_SHA=\"$LATEST\" -o cc-osx32 -framework Carbon -framework AGL -framework OpenGL -lgcc_s.1
|
||||
$MAC32_CC *.c $ALL_FLAGS $MACOS_FLAGS CCicon_mac32.o -DCC_COMMIT_SHA=\"$LATEST\" -o cc-osx32 -framework Carbon -framework AGL -framework OpenGL -framework IOKit -lgcc_s.1
|
||||
}
|
||||
|
||||
build_mac64() {
|
||||
echo "Building mac64.."
|
||||
cp $SOURCE_DIR/misc/CCicon_mac64 $SOURCE_DIR/src/CCicon_mac64.o
|
||||
rm cc-osx64
|
||||
$MAC64_CC *.c $ALL_FLAGS $MACOS_FLAGS CCicon_mac64.o -DCC_COMMIT_SHA=\"$LATEST\" -o cc-osx64 -framework Cocoa -framework OpenGL -lobjc
|
||||
$MAC64_CC *.c $ALL_FLAGS $MACOS_FLAGS CCicon_mac64.o -DCC_COMMIT_SHA=\"$LATEST\" -o cc-osx64 -framework Cocoa -framework OpenGL -framework IOKit -lobjc
|
||||
}
|
||||
|
||||
build_web() {
|
||||
|
|
|
@ -80,11 +80,11 @@ Although the regular linux compiliation flags will work fine, to take full advan
|
|||
|
||||
##### Using gcc/clang (32 bit)
|
||||
|
||||
```cc *.c -o ClassiCube -framework Carbon -framework AGL -framework OpenGL```
|
||||
```cc *.c -o ClassiCube -framework Carbon -framework AGL -framework OpenGL -framework IOKit```
|
||||
|
||||
##### Using gcc/clang (64 bit)
|
||||
|
||||
```cc *.c -o ClassiCube -framework Cocoa -framework OpenGL -lobjc```
|
||||
```cc *.c -o ClassiCube -framework Cocoa -framework OpenGL -framework IOKit -lobjc```
|
||||
|
||||
### Compiling - other desktop OSes
|
||||
|
||||
|
|
|
@ -667,7 +667,7 @@ void Session_Load(void) {
|
|||
}
|
||||
|
||||
void Session_Save(void) {
|
||||
#if defined CC_BUILD_WIN || defined CC_BUILD_LINUX
|
||||
#if defined CC_BUILD_WIN || defined CC_BUILD_LINUX || defined CC_BUILD_MACOS
|
||||
cc_string session = EntryList_UNSAFE_Get(&ccCookies, &sessionKey, '=');
|
||||
if (!session.length) return;
|
||||
Options_SetSecure(LOPT_SESSION, &session, &Game_Username);
|
||||
|
|
|
@ -1776,8 +1776,8 @@ cc_result Platform_Decrypt(const cc_string* key, const void* data, int len, cc_s
|
|||
LocalFree(output.pbData);
|
||||
return 0;
|
||||
}
|
||||
#elif defined CC_BUILD_LINUX
|
||||
/* Encrypts data using XTEA block cipher, with /var/lib/dbus/machine-id as the key */
|
||||
#elif defined CC_BUILD_LINUX || defined CC_BUILD_MACOS
|
||||
/* Encrypts data using XTEA block cipher, with OS specific method to get machine-specific key */
|
||||
|
||||
static void EncipherBlock(cc_uint32* v, const cc_uint32* key, cc_string* dst) {
|
||||
cc_uint32 v0 = v[0], v1 = v[1], sum = 0, delta = 0x9E3779B9;
|
||||
|
@ -1820,6 +1820,8 @@ static void DecodeMachineID(char* tmp, cc_uint8* key) {
|
|||
}
|
||||
}
|
||||
|
||||
#if defined CC_BUILD_LINUX
|
||||
/* Read /var/lib/dbus/machine-id for the key */
|
||||
static void GetMachineID(cc_uint32* key) {
|
||||
const cc_string idFile = String_FromConst("/var/lib/dbus/machine-id");
|
||||
char tmp[MACHINEID_LEN];
|
||||
|
@ -1834,6 +1836,32 @@ static void GetMachineID(cc_uint32* key) {
|
|||
}
|
||||
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 };
|
||||
const char* src;
|
||||
struct Stream s;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 4; i++) key[i] = 0;
|
||||
|
||||
registry = IORegistryEntryFromPath(kIOMasterPortDefault, "IOService:/");
|
||||
if (!registry) return;
|
||||
|
||||
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);
|
||||
}
|
||||
CFRelease(uuid);
|
||||
IOObjectRelease(registry);
|
||||
}
|
||||
#endif
|
||||
|
||||
cc_result Platform_Encrypt(const cc_string* key_, const void* data, int len, cc_string* dst) {
|
||||
const cc_uint8* src = (const cc_uint8*)data;
|
||||
|
|
Loading…
Reference in a new issue