From ca5fb29d6724a2c3685fb3188c9e4ada7d0e6114 Mon Sep 17 00:00:00 2001 From: Crestwave <35413013+Crestwave@users.noreply.github.com> Date: Sat, 15 Aug 2020 00:40:57 +0800 Subject: [PATCH] puckman: new recipe (#4742) --- .../puckman/patches/puckman-1.0~git.patch | 78 +++++++++++++++++++ games-arcade/puckman/puckman-1.0~git.recipe | 53 +++++++++++++ 2 files changed, 131 insertions(+) create mode 100644 games-arcade/puckman/patches/puckman-1.0~git.patch create mode 100644 games-arcade/puckman/puckman-1.0~git.recipe diff --git a/games-arcade/puckman/patches/puckman-1.0~git.patch b/games-arcade/puckman/patches/puckman-1.0~git.patch new file mode 100644 index 000000000..3d755d08c --- /dev/null +++ b/games-arcade/puckman/patches/puckman-1.0~git.patch @@ -0,0 +1,78 @@ +diff --git a/puckman.c b/puckman.c +index ec9a669..57f59d5 100644 +--- a/puckman.c ++++ b/puckman.c +@@ -29,7 +29,11 @@ + #include + #include + +-#define PACPATH "/usr/share/puckman/" ++#include ++#include ++#include ++#include ++ + #define SCREEN_WIDTH 461 + #define SCREEN_HEIGHT 580 + #define RIGHT 0 +@@ -1407,8 +1411,21 @@ void Game_init() { + free(str); + game->candy_index = 0; + game->candy_blow_delay = 0; +- char *scores_file = (char *) malloc((strlen(getenv("HOME")) + 25) * sizeof(char)); +- snprintf(scores_file, strlen(getenv("HOME")) + 25, "%s/.puckman/highscores.txt", getenv("HOME")); ++ ++ char buf[B_PATH_NAME_LENGTH]; ++ char *scores_file; ++ if (find_directory(B_USER_SETTINGS_DIRECTORY, 0, false, buf, sizeof(buf)) == B_OK) { ++ char path[B_PATH_NAME_LENGTH]; ++ snprintf(path, sizeof(path), "%s/puckman", buf); ++ ++ struct stat st = {0}; ++ if (stat(path, &st) == -1) ++ mkdir(path, 0755); ++ ++ scores_file = (char *) malloc((strlen(path) + 25) * sizeof(char)); ++ snprintf(scores_file, strlen(path) + 25, "%s/highscores.txt", path); ++ } ++ + game->scores_file = scores_file; + FILE *f; + if ((f = fopen(game->scores_file, "r")) == NULL) { +@@ -1505,16 +1522,26 @@ void Game_process() { + } + } + SDL_Surface *getImage(char *str) { +- int size = strlen("images/") + strlen(str) + strlen(PACPATH) + 1; +- char *path = (char *) malloc(size * sizeof(char)); +- snprintf(path, size, "%simages/%s", PACPATH, str); +- SDL_Surface *image = IMG_Load(path); +- if (!image) { +- printf("IMG_Load: %s\n", IMG_GetError()); +- cleanUp(1); +- } +- free(path); +- return image; ++ char **paths; ++ size_t pathsCount; ++ if (find_paths(B_FIND_PATH_DATA_DIRECTORY, "puckman", &paths, &pathsCount) == B_OK) { ++ SDL_Surface *image; ++ for (size_t i = 0; i < pathsCount; ++i) { ++ int size = strlen("/images/") + strlen(str) + strlen(paths[i]) + 1; ++ char *path = (char *) malloc(size * sizeof(char)); ++ snprintf(path, size, "%s/images/%s", paths[i], str); ++ image = IMG_Load(path); ++ free(path); ++ if (image) ++ break; ++ } ++ free(paths); ++ if (!image) { ++ printf("IMG_Load: %s\n", IMG_GetError()); ++ cleanUp(1); ++ } ++ return image; ++ } + } + SDL_Surface *getLetter(int letter) { + char *str = (char *) malloc(13 * sizeof(char)); diff --git a/games-arcade/puckman/puckman-1.0~git.recipe b/games-arcade/puckman/puckman-1.0~git.recipe new file mode 100644 index 000000000..4be10c34a --- /dev/null +++ b/games-arcade/puckman/puckman-1.0~git.recipe @@ -0,0 +1,53 @@ +SUMMARY="An unofficial clone of the original Namco's Pac-Man" +DESCRIPTION="This game is an unofficial clone of the original Pac-Man game \ +and is not endorsed by the registered trademark owners Namco, Inc." +HOMEPAGE="https://github.com/patapizza/puckman" +COPYRIGHT="2009 Julien Odent + 2009 Martin Meys" +LICENSE="GNU GPL v3" +REVISION="1" +srcGitRev="f5b809cc843daa99808dcad53da87208e0b67ffe" +SOURCE_URI="$HOMEPAGE/archive/$srcGitRev.tar.gz" +CHECKSUM_SHA256="630d3f08a631d97a798b094789e04f9a89fb9460b5725a8fc4e39630634800a2" +SOURCE_FILENAME="puckman-$srcGitRev.tar.gz" +SOURCE_DIR="puckman-$srcGitRev" +PATCHES="puckman-$portVersion.patch" + +ARCHITECTURES="!x86_gcc2 ?x86 x86_64" +SECONDARY_ARCHITECTURES="?x86" + +PROVIDES=" + puckman$secondaryArchSuffix = $portVersion + app:Puck_Man = $portVersion + " +REQUIRES=" + haiku$secondaryArchSuffix + lib:libSDL_1.2$secondaryArchSuffix + lib:libSDL_gfx$secondaryArchSuffix + lib:libSDL_image_1.2$secondaryArchSuffix + " + +BUILD_REQUIRES=" + haiku${secondaryArchSuffix}_devel + devel:libSDL_1.2$secondaryArchSuffix + devel:libSDL_gfx$secondaryArchSuffix + devel:libSDL_image_1.2$secondaryArchSuffix + " +BUILD_PREREQUIRES=" + cmd:gcc$secondaryArchSuffix + " + +BUILD() +{ + includedir=$(finddir B_SYSTEM_HEADERS_DIRECTORY)$secondaryArchSubDir + gcc puckman.c -Wall -I"$includedir"/SDL -lSDL -lSDL_image -lSDL_gfx \ + -o puckman +} + +INSTALL() +{ + install -m 755 -d "$appsDir" "$dataDir/puckman/images" + install -m 755 puckman "$appsDir/Puck-Man" + install -m 644 images/* "$dataDir/puckman/images" + addAppDeskbarSymlink "$appsDir/Puck-Man" +}