From 77c146af8021637a9a9b4bea5cd2f054439e9aa0 Mon Sep 17 00:00:00 2001 From: Josef Gajdusek Date: Thu, 15 Jan 2015 20:25:32 +0100 Subject: [PATCH] abe: Save game to B_USER_SETTINGS_DIRECTORY + fix crash on startup --- games-kids/abe/abe-1.1.recipe | 4 +- games-kids/abe/patches/abe-1.1.patch | 69 ++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 games-kids/abe/patches/abe-1.1.patch diff --git a/games-kids/abe/abe-1.1.recipe b/games-kids/abe/abe-1.1.recipe index f63def4e8..cb7949546 100644 --- a/games-kids/abe/abe-1.1.recipe +++ b/games-kids/abe/abe-1.1.recipe @@ -38,7 +38,9 @@ BUILD_PREREQUIRES=" cmd:automake cmd:autoconf " - + +PATCHES="abe-1.1.patch" + PATCH() { sed -i 's/AM_CONFIG_HEADER/AC_CONFIG_HEADERS/g' configure.in diff --git a/games-kids/abe/patches/abe-1.1.patch b/games-kids/abe/patches/abe-1.1.patch new file mode 100644 index 000000000..cdb203f51 --- /dev/null +++ b/games-kids/abe/patches/abe-1.1.patch @@ -0,0 +1,69 @@ +diff --git a/src/Directories.c b/src/Directories.c +index cca0472..f43d181 100644 +--- a/src/Directories.c ++++ b/src/Directories.c +@@ -7,7 +7,12 @@ getHomeUserAbe() + { + + static char path[PATH_SIZE]; +-#ifndef WIN32 ++#ifdef WIN32 ++ sprintf(path, xstr(BASE_DIR) PATH_SEP); ++#elif __HAIKU__ ++ find_directory(B_USER_SETTINGS_DIRECTORY, -1, true, path, PATH_SIZE); ++ strncat(path, "/abe/", PATH_SIZE); ++#else + struct passwd *pwent; + + pwent = getpwuid(getuid()); +@@ -17,8 +22,6 @@ getHomeUserAbe() + } + + sprintf(path, "%s%s", pwent->pw_dir, PATH_SEP ".abe" PATH_SEP); +-#else +- sprintf(path, xstr(BASE_DIR) PATH_SEP); + #endif + + return path; +diff --git a/src/Directories.h b/src/Directories.h +index 3abe73e..45e8d12 100644 +--- a/src/Directories.h ++++ b/src/Directories.h +@@ -9,6 +9,10 @@ + #include + #endif + ++#ifdef __HAIKU__ ++#include ++#endif ++ + // The macros xstr(s) and str(s) were extracted from + // http://gcc.gnu.org/onlinedocs/cpp/Stringification.html + // They are used to expand BASE_DIR . +diff --git a/src/Main.c b/src/Main.c +index 2520856..a158796 100644 +--- a/src/Main.c ++++ b/src/Main.c +@@ -90,12 +90,22 @@ main(int argc, char *argv[]) + int intro = 0; + char *mapname; + int mapwidth, mapheight; ++ char *directory; ++ char *sep; + + mainstruct.drawBackground = 1; + mainstruct.alphaBlend = 1; + mainstruct.effects_enabled = 1; + runmode = RUNMODE_SPLASH; + mainstruct.full_screen = 1; ++ ++ directory = strdup(argv[0]); ++ sep = strrchr(directory, '/'); ++ if (sep != NULL) { ++ *sep = '\0'; ++ chdir(directory); ++ } ++ free(directory); + + // my laptop can't handle fullscreen for some reason + #if defined(__APPLE__) || defined(__MACH_O__)