From 4160743b77bc702e3d91bd7074e69412e057fbdd Mon Sep 17 00:00:00 2001 From: bjorn Date: Wed, 29 Jul 2020 16:30:14 -0600 Subject: [PATCH] Fix desktop game packaging issue; Accidentally hardcoded it to "assets" when updating Android. --- src/core/os.h | 2 +- src/core/os_android.c | 3 ++- src/core/os_linux.c | 3 ++- src/core/os_macos.c | 3 ++- src/core/os_web.c | 3 ++- src/core/os_win32.c | 3 ++- src/modules/filesystem/filesystem.c | 3 ++- 7 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/core/os.h b/src/core/os.h index b8e56e23..35c8ca80 100644 --- a/src/core/os.h +++ b/src/core/os.h @@ -68,7 +68,7 @@ size_t lovrPlatformGetHomeDirectory(char* buffer, size_t size); size_t lovrPlatformGetDataDirectory(char* buffer, size_t size); size_t lovrPlatformGetWorkingDirectory(char* buffer, size_t size); size_t lovrPlatformGetExecutablePath(char* buffer, size_t size); -size_t lovrPlatformGetBundlePath(char* buffer, size_t size); +size_t lovrPlatformGetBundlePath(char* buffer, size_t size, const char** root); bool lovrPlatformCreateWindow(WindowFlags* flags); bool lovrPlatformHasWindow(void); void lovrPlatformGetWindowSize(int* width, int* height); diff --git a/src/core/os_android.c b/src/core/os_android.c index 6267887d..24ebebe7 100644 --- a/src/core/os_android.c +++ b/src/core/os_android.c @@ -159,7 +159,7 @@ size_t lovrPlatformGetExecutablePath(char* buffer, size_t size) { } } -size_t lovrPlatformGetBundlePath(char* buffer, size_t size) { +size_t lovrPlatformGetBundlePath(char* buffer, size_t size, const char** root) { jobject activity = state.app->activity->clazz; jclass class = (*state.jni)->GetObjectClass(state.jni, activity); jmethodID getPackageCodePath = (*state.jni)->GetMethodID(state.jni, class, "getPackageCodePath", "()Ljava/lang/String;"); @@ -178,6 +178,7 @@ size_t lovrPlatformGetBundlePath(char* buffer, size_t size) { if (length >= size) return 0; memcpy(buffer, path, length); buffer[length] = '\0'; + *root = "/assets"; return length; } diff --git a/src/core/os_linux.c b/src/core/os_linux.c index 302eb574..b593a00a 100644 --- a/src/core/os_linux.c +++ b/src/core/os_linux.c @@ -110,6 +110,7 @@ size_t lovrPlatformGetExecutablePath(char* buffer, size_t size) { } } -size_t lovrPlatformGetBundlePath(char* buffer, size_t size) { +size_t lovrPlatformGetBundlePath(char* buffer, size_t size, const char** root) { + *root = NULL; return lovrPlatformGetExecutablePath(buffer, size); } diff --git a/src/core/os_macos.c b/src/core/os_macos.c index bd7c69a7..ef1d37e6 100644 --- a/src/core/os_macos.c +++ b/src/core/os_macos.c @@ -98,7 +98,7 @@ size_t lovrPlatformGetExecutablePath(char* buffer, size_t size) { return _NSGetExecutablePath(buffer, &size32) ? 0 : size32; } -size_t lovrPlatformGetBundlePath(char* buffer, size_t size) { +size_t lovrPlatformGetBundlePath(char* buffer, size_t size, const char** root) { id extension = ((id(*)(Class, SEL, char*)) objc_msgSend)(objc_getClass("NSString"), sel_registerName("stringWithUTF8String:"), "lovr"); id bundle = ((id(*)(Class, SEL)) objc_msgSend)(objc_getClass("NSBundle"), sel_registerName("mainBundle")); id path = ((id(*)(id, SEL, char*, id)) objc_msgSend)(bundle, sel_registerName("pathForResource:ofType:"), nil, extension); @@ -118,5 +118,6 @@ size_t lovrPlatformGetBundlePath(char* buffer, size_t size) { memcpy(buffer, cpath, length); buffer[length] = '\0'; + *root = NULL; return length; } diff --git a/src/core/os_web.c b/src/core/os_web.c index c4a0c663..cbda3cb1 100644 --- a/src/core/os_web.c +++ b/src/core/os_web.c @@ -61,6 +61,7 @@ size_t lovrPlatformGetExecutablePath(char* buffer, size_t size) { return 0; } -size_t lovrPlatformGetBundlePath(char* buffer, size_t size) { +size_t lovrPlatformGetBundlePath(char* buffer, size_t size, const char** root) { + *root = NULL; return 0; } diff --git a/src/core/os_win32.c b/src/core/os_win32.c index e304078c..801a9c7e 100644 --- a/src/core/os_win32.c +++ b/src/core/os_win32.c @@ -95,6 +95,7 @@ size_t lovrPlatformGetExecutablePath(char* buffer, size_t size) { return 0; } -size_t lovrPlatformGetBundlePath(char* buffer, size_t size) { +size_t lovrPlatformGetBundlePath(char* buffer, size_t size, const char** root) { + *root = NULL; return lovrPlatformGetExecutablePath(buffer, size); } diff --git a/src/modules/filesystem/filesystem.c b/src/modules/filesystem/filesystem.c index e7365ed0..7156db26 100755 --- a/src/modules/filesystem/filesystem.c +++ b/src/modules/filesystem/filesystem.c @@ -119,7 +119,8 @@ bool lovrFilesystemInit(const char* argExe, const char* argGame, const char* arg lovrFilesystemSetCRequirePath("??;lua_modules/??;deps/??"); // First, try to mount a bundled archive - if (lovrPlatformGetBundlePath(state.source, LOVR_PATH_MAX) && lovrFilesystemMount(state.source, NULL, true, "/assets")) { + const char* root = NULL; + if (lovrPlatformGetBundlePath(state.source, LOVR_PATH_MAX, &root) && lovrFilesystemMount(state.source, NULL, true, root)) { state.fused = true; return true; }