From 3a961310cae459b42a1c0a4507f40a5121a6b6bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20B=C3=B6hmwalder?= Date: Fri, 10 Jan 2020 22:04:04 +0100 Subject: [PATCH] actually return an error when data.zip is missing We should return an error code when we can't find data.zip, just letting the program crash is a little crude. --- desktop_version/src/FileSystemUtils.cpp | 9 ++++++++- desktop_version/src/FileSystemUtils.h | 2 +- desktop_version/src/main.cpp | 5 ++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/desktop_version/src/FileSystemUtils.cpp b/desktop_version/src/FileSystemUtils.cpp index 374f952c..40e54da9 100644 --- a/desktop_version/src/FileSystemUtils.cpp +++ b/desktop_version/src/FileSystemUtils.cpp @@ -32,7 +32,7 @@ void PLATFORM_getOSDirectory(char* output); void PLATFORM_migrateSaveData(char* output); void PLATFORM_copyFile(const char *oldLocation, const char *newLocation); -void FILESYSTEM_init(char *argvZero) +int FILESYSTEM_init(char *argvZero) { char output[MAX_PATH]; int mkdirResult; @@ -78,6 +78,11 @@ void FILESYSTEM_init(char *argvZero) #endif if (!PHYSFS_mount(output, NULL, 1)) { + puts("Error: data.zip missing!"); + puts("You do not have data.zip!"); + puts("Grab it from your purchased copy of the game,"); + puts("or get it from the free Make and Play Edition."); + SDL_ShowSimpleMessageBox( SDL_MESSAGEBOX_ERROR, "data.zip missing!", @@ -86,7 +91,9 @@ void FILESYSTEM_init(char *argvZero) "\nor get it from the free Make and Play Edition.", NULL ); + return 0; } + return 1; } void FILESYSTEM_deinit() diff --git a/desktop_version/src/FileSystemUtils.h b/desktop_version/src/FileSystemUtils.h index bcc7c5f5..26aa7a24 100644 --- a/desktop_version/src/FileSystemUtils.h +++ b/desktop_version/src/FileSystemUtils.h @@ -4,7 +4,7 @@ #include #include -void FILESYSTEM_init(char *argvZero); +int FILESYSTEM_init(char *argvZero); void FILESYSTEM_deinit(); char *FILESYSTEM_getUserSaveDirectory(); diff --git a/desktop_version/src/main.cpp b/desktop_version/src/main.cpp index d423223b..c26ab749 100644 --- a/desktop_version/src/main.cpp +++ b/desktop_version/src/main.cpp @@ -36,7 +36,10 @@ scriptclass script; int main(int argc, char *argv[]) { - FILESYSTEM_init(argv[0]); + if(!FILESYSTEM_init(argv[0])) + { + return 1; + } SDL_Init( SDL_INIT_VIDEO | SDL_INIT_AUDIO |