From b4dd516d7de4c055930ea3c85d5cbd0098212db8 Mon Sep 17 00:00:00 2001 From: Misa Date: Fri, 5 Mar 2021 23:45:40 -0800 Subject: [PATCH] Move assetdir off of Graphics It's only used in FileSystemUtils and never anywhere else, especially not Graphics. Why is this on Graphics again? It's now a static variable inside FileSystemUtils. It has also been renamed to assetDir for consistency with saveDir and levelDir. Also, it's a C string now, and is no longer an STL string. --- desktop_version/src/FileSystemUtils.cpp | 14 ++++++++------ desktop_version/src/Graphics.h | 1 - 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/desktop_version/src/FileSystemUtils.cpp b/desktop_version/src/FileSystemUtils.cpp index 2ff8360d..24b6d5d5 100644 --- a/desktop_version/src/FileSystemUtils.cpp +++ b/desktop_version/src/FileSystemUtils.cpp @@ -26,6 +26,8 @@ static char saveDir[MAX_PATH] = {'\0'}; static char levelDir[MAX_PATH] = {'\0'}; +static char assetDir[MAX_PATH] = {'\0'}; + static void PLATFORM_getOSDirectory(char* output); static void PLATFORM_migrateSaveData(char* output); static void PLATFORM_copyFile(const char *oldLocation, const char *newLocation); @@ -221,7 +223,7 @@ void FILESYSTEM_mount(const char *fname) } else { - graphics.assetdir = std::string(path); + SDL_strlcpy(assetDir, path, sizeof(assetDir)); } } @@ -318,7 +320,7 @@ void FILESYSTEM_mountassets(const char* path) } else { - graphics.assetdir = std::string(zip_data); + SDL_strlcpy(assetDir, zip_data, sizeof(assetDir)); } FILESYSTEM_assetsmounted = true; @@ -345,11 +347,11 @@ void FILESYSTEM_mountassets(const char* path) void FILESYSTEM_unmountassets(void) { - if (graphics.assetdir != "") + if (assetDir[0] != '\0') { - printf("Unmounting %s\n", graphics.assetdir.c_str()); - PHYSFS_unmount(graphics.assetdir.c_str()); - graphics.assetdir = ""; + printf("Unmounting %s\n", assetDir); + PHYSFS_unmount(assetDir); + assetDir[0] = '\0'; graphics.reloadresources(); } else diff --git a/desktop_version/src/Graphics.h b/desktop_version/src/Graphics.h index 16377469..b17fb8ae 100644 --- a/desktop_version/src/Graphics.h +++ b/desktop_version/src/Graphics.h @@ -184,7 +184,6 @@ public: bool onscreen(int t); void reloadresources(void); - std::string assetdir; void menuoffrender(void);