From a5de244744efe082e844a14faa8bd7bb2dc59968 Mon Sep 17 00:00:00 2001 From: Josef Gajdusek Date: Thu, 4 Dec 2014 10:12:33 +0100 Subject: [PATCH] pipepanic: Save high score file to config/settings The file was previously in ~. --- .../pipepanic/patches/pipepanic-0.1.3.patch | 111 ++++++++++++++++-- games-kids/pipepanic/pipepanic-0.1.3.recipe | 3 + 2 files changed, 107 insertions(+), 7 deletions(-) diff --git a/games-kids/pipepanic/patches/pipepanic-0.1.3.patch b/games-kids/pipepanic/patches/pipepanic-0.1.3.patch index 371ff24ad..1a6812cfb 100644 --- a/games-kids/pipepanic/patches/pipepanic-0.1.3.patch +++ b/games-kids/pipepanic/patches/pipepanic-0.1.3.patch @@ -1,17 +1,34 @@ ---- ../main.c 2006-05-16 22:11:29.042991616 +0200 -+++ main-new.c 2013-12-09 16:52:30.000000000 +0100 -@@ -16,6 +16,10 @@ +diff --git a/main.c b/main.c +index 6cf114c..960f57a 100644 +--- a/main.c ++++ b/main.c +@@ -16,6 +16,14 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /* Includes */ +// chdir() +#include +#include ++ ++#ifdef __HAIKU__ ++#include ++#endif + #include #include #include -@@ -102,6 +106,9 @@ +@@ -44,6 +52,10 @@ SDL_Surface *temp; + SDL_Event event; + char *current_dir; + char *user_home_dir; ++#ifdef __HAIKU__ ++char user_settings_dir[256]; ++#endif ++char save_file[256]; + int quit = 0; + int game_mode = GAMEON; + int previous_game_mode = 0; +@@ -102,6 +114,9 @@ extern "C" int main(int argc, char *argv[]) { int count, count2; @@ -21,9 +38,89 @@ /* Initialise the highscoreboard array because there may not yet be a saved highscore[board]/rc file */ for (count = 0; count < 5; count++) { - ---- ../pipepanic.rdef -+++ pipepanic.rdef +@@ -114,7 +129,16 @@ int main(int argc, char *argv[]) { + + current_dir = getenv("PWD"); + user_home_dir = getenv("HOME"); +- ++ ++ #ifdef __HAIKU__ ++ find_directory(B_USER_SETTINGS_DIRECTORY, NULL, true, ++ user_settings_dir, sizeof(user_settings_dir)); ++ snprintf(save_file, sizeof(save_file), ++ "%s/" RESOURCEFILE, user_settings_dir); ++ #else ++ snprintf(save_file, sizeof(save_file), ++ "%s/" RESOURCEFILE, user_home_dir); ++ #endif + #ifdef DEBUG + printf("PWD=%s\n", current_dir); + printf("HOME=%s\n", user_home_dir); +@@ -1567,16 +1591,12 @@ void read_rc_file(void) { + FILE* file; + int result, value, count; + +- strcpy(buffer, user_home_dir); +- strcat(buffer, "/"); +- strcat(buffer, RESOURCEFILE); +- + #ifdef DEBUG +- printf("%s\n", buffer); ++ printf("%s\n", save_file); + #endif + +- if ((file = fopen(buffer,"r")) == NULL) { +- printf("%s: Cannot read from file %s\n", __func__, buffer); ++ if ((file = fopen(save_file,"r")) == NULL) { ++ printf("%s: Cannot read from file %s\n", __func__, save_file); + return; + } + +@@ -1638,20 +1658,15 @@ void read_rc_file(void) { + ***************************************************************************/ + + void save_rc_file(void) { +- char buffer[256]; + FILE* file; + int count; + +- strcpy(buffer, user_home_dir); +- strcat(buffer, "/"); +- strcat(buffer, RESOURCEFILE); +- + #ifdef DEBUG +- printf("%s\n", buffer); ++ printf("%s\n", save_file); + #endif + +- if ((file = fopen(buffer,"w")) == NULL) { +- printf("%s: Cannot write to file %s\n", __func__, buffer); ++ if ((file = fopen(save_file,"w")) == NULL) { ++ printf("%s: Cannot write to file %s\n", __func__, save_file); + return; + } + +diff --git a/main.h b/main.h +index 664b75b..178f665 100644 +--- a/main.h ++++ b/main.h +@@ -27,7 +27,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + #define TILES48BMP "tiles48.bmp" + #define ASCII15BMP "ascii15.bmp" + #define ASCII30BMP "ascii30.bmp" ++#ifdef __HAIKU__ ++#define RESOURCEFILE "pipepanic" ++#else + #define RESOURCEFILE ".pipepanicrc" ++#endif + + #define MAGENTA 0xff, 0x00, 0xff + #define YELLOW 0xff, 0xcc, 0x66 +diff --git a/pipepanic.rdef b/pipepanic.rdef +new file mode 100644 +index 0000000..096d98d +--- /dev/null ++++ b/pipepanic.rdef @@ -0,0 +1,30 @@ +resource app_signature "application/x-vnd.Thnor-Pipepanic"; + diff --git a/games-kids/pipepanic/pipepanic-0.1.3.recipe b/games-kids/pipepanic/pipepanic-0.1.3.recipe index 766366857..4434a25b4 100644 --- a/games-kids/pipepanic/pipepanic-0.1.3.recipe +++ b/games-kids/pipepanic/pipepanic-0.1.3.recipe @@ -28,6 +28,9 @@ BUILD_PREREQUIRES=" cmd:gcc$secondaryArchSuffix cmd:make " +USER_SETTINGS_FILES=" + settings/pipepanic + " PATCHES=" pipepanic-0.1.3.patch "