Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 28 Jun 2020 14:23:58 +0000 (UTC)
From:      Li-Wen Hsu <lwhsu@FreeBSD.org>
To:        ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org
Subject:   svn commit: r540723 - in head/games: . shockolate shockolate/files
Message-ID:  <202006281423.05SENwYp076153@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: lwhsu
Date: Sun Jun 28 14:23:58 2020
New Revision: 540723
URL: https://svnweb.freebsd.org/changeset/ports/540723

Log:
  Add games/shockolate, Cross platform System Shock
  
  PR:		246072
  Submitted by:	Vasily Postnicov <shamaz.mazum@gmail.com>

Added:
  head/games/shockolate/
  head/games/shockolate/Makefile   (contents, props changed)
  head/games/shockolate/distinfo   (contents, props changed)
  head/games/shockolate/files/
  head/games/shockolate/files/patch-src_GameSrc_setup.c   (contents, props changed)
  head/games/shockolate/files/patch-src_Libraries_RES_Source_caseless.c   (contents, props changed)
  head/games/shockolate/files/patch-src_MacSrc_OpenGL.cc   (contents, props changed)
  head/games/shockolate/files/patch-src_MusicSrc_MusicDevice.c   (contents, props changed)
  head/games/shockolate/pkg-descr   (contents, props changed)
  head/games/shockolate/pkg-message   (contents, props changed)
  head/games/shockolate/pkg-plist   (contents, props changed)
Modified:
  head/games/Makefile

Modified: head/games/Makefile
==============================================================================
--- head/games/Makefile	Sun Jun 28 14:21:13 2020	(r540722)
+++ head/games/Makefile	Sun Jun 28 14:23:58 2020	(r540723)
@@ -873,6 +873,7 @@
     SUBDIR += sex
     SUBDIR += sgt-puzzles
     SUBDIR += shaaft
+    SUBDIR += shockolate
     SUBDIR += shootingstar
     SUBDIR += simplevaders
     SUBDIR += simsu

Added: head/games/shockolate/Makefile
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/games/shockolate/Makefile	Sun Jun 28 14:23:58 2020	(r540723)
@@ -0,0 +1,41 @@
+# Created by: Vasily Postnicov <shamaz.mazum@gmail.com>
+# $FreeBSD$
+
+PORTNAME=	shockolate
+DISTVERSIONPREFIX=	v
+DISTVERSION=	0.8.2-43
+DISTVERSIONSUFFIX=	-ga9eb1b93
+CATEGORIES=	games
+
+MAINTAINER=	shamaz.mazum@gmail.com
+COMMENT=	Open source and cross-platform remake of a cult game System Shock
+
+LICENSE=	GPLv3
+LICENSE_FILE=	${WRKSRC}/LICENSE
+
+LIB_DEPENDS=	libfluidsynth.so:audio/fluidsynth \
+		libasound.so:audio/alsa-lib
+
+USES=		cmake gl sdl pkgconfig
+USE_GL=		gl glu
+USE_SDL=	sdl2 mixer2
+
+USE_GITHUB=	yes
+GH_ACCOUNT=	Interrupt
+GH_PROJECT=	systemshock
+
+CMAKE_ON=	ENABLE_SDL2 ENABLE_SOUND ENABLE_FLUIDSYNTH
+
+post-patch: .SILENT
+	${REINPLACE_CMD} -e 's|%%DATADIR%%|${LOCALBASE}/share/shockolate/|' \
+		${WRKSRC}/src/Libraries/RES/Source/caseless.c \
+		${WRKSRC}/src/MacSrc/OpenGL.cc
+	${REINPLACE_CMD} -e 's|%%MIDIDIR%%|${LOCALBASE}/share/sounds/sf2/|' \
+		${WRKSRC}/src/MusicSrc/MusicDevice.c
+
+do-install:
+	${INSTALL_PROGRAM} ${BUILD_WRKSRC}/systemshock ${STAGEDIR}${PREFIX}/bin
+	(cd ${WRKSRC} && ${COPYTREE_SHARE} shaders ${STAGEDIR}${DATADIR})
+	${MKDIR} ${STAGEDIR}${DATADIR}/res
+
+.include <bsd.port.mk>

Added: head/games/shockolate/distinfo
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/games/shockolate/distinfo	Sun Jun 28 14:23:58 2020	(r540723)
@@ -0,0 +1,3 @@
+TIMESTAMP = 1591116062
+SHA256 (Interrupt-systemshock-v0.8.2-43-ga9eb1b93_GH0.tar.gz) = f7c9e9e4a87346ef70e928a965449c7f8e81f0ad47af168d6135fc6cd1bcea1e
+SIZE (Interrupt-systemshock-v0.8.2-43-ga9eb1b93_GH0.tar.gz) = 12381862

Added: head/games/shockolate/files/patch-src_GameSrc_setup.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/games/shockolate/files/patch-src_GameSrc_setup.c	Sun Jun 28 14:23:58 2020	(r540723)
@@ -0,0 +1,52 @@
+--- src/GameSrc/setup.c.orig	2020-04-23 04:29:54 UTC
++++ src/GameSrc/setup.c
+@@ -25,6 +25,7 @@ along with this program.  If not, see <http://www.gnu.
+ 
+ #define __SETUP_SRC
+ 
++#include <stdlib.h>
+ #include <string.h>
+ 
+ // TODO: extract this into a compatibility header
+@@ -36,6 +37,10 @@ along with this program.  If not, see <http://www.gnu.
+ 	#include <unistd.h>
+ #endif
+ 
++#ifndef PATH_MAX
++#define PATH_MAX 4096
++#endif
++
+ #include "archiveformat.h"
+ #include "ShockDialogs.h"
+ #include "setup.h"
+@@ -1305,8 +1310,21 @@ uchar intro_key_handler(uiEvent *ev, LGRegion *r, intp
+   return (main_kb_callback(ev, r, user_data));
+ }
+ 
++static int file_exists_in_homedir_p (const char *filename)
++{
++    char *home = getenv ("HOME");
++    char path[PATH_MAX];
++    int res = 0;
+ 
++    if (home != NULL) {
++        snprintf (path, PATH_MAX, "%s/.sshock/%s",
++                  home, filename);
++        res = access (path, F_OK) != -1;
++    }
+ 
++    return res;
++}
++
+ errtype load_savegame_names(void)
+ {
+   int i;
+@@ -1320,7 +1338,7 @@ errtype load_savegame_names(void)
+   {
+     Poke_SaveName(i);
+ 
+-    if (access(save_game_name, F_OK) != -1)
++    if (file_exists_in_homedir_p (save_game_name))
+     {
+       file = ResOpenFile(save_game_name);
+       if (ResInUse(OLD_SAVE_GAME_ID_BASE))

Added: head/games/shockolate/files/patch-src_Libraries_RES_Source_caseless.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/games/shockolate/files/patch-src_Libraries_RES_Source_caseless.c	Sun Jun 28 14:23:58 2020	(r540723)
@@ -0,0 +1,49 @@
+--- src/Libraries/RES/Source/caseless.c.orig	2020-04-23 04:29:54 UTC
++++ src/Libraries/RES/Source/caseless.c
+@@ -20,6 +20,7 @@ along with this program.  If not, see <http://www.gnu.
+ // DG 2018: a case-insensitive fopen() wrapper, and functions used by it
+ 
+ #include <assert.h>
++#include <stdlib.h>
+ #include <string.h>
+ #include <stdio.h>
+ #include <sys/stat.h>
+@@ -241,18 +242,35 @@ int caselesspath(const char *inpath, char *outpath, in
+ 
+ FILE *fopen_caseless(const char *path, const char *mode) {
+     FILE *ret = NULL;
++    char fullpath[PATH_MAX];
++    char *home = getenv("HOME");
+ 
+     if (path == NULL || mode == NULL)
+         return NULL;
+ 
+-    ret = fopen(path, mode);
++    if (strcmp (path, "CurrentGame.dat") == 0 ||
++        strncmp (path, "savgam", strlen ("savgam")) == 0) {
++        if (home == NULL)
++            return NULL;
+ 
++        snprintf (fullpath, PATH_MAX, "%s/.sshock/", home);
++        if (strstr (mode, "w") != NULL) {
++            /* Ensure the local directory exists */
++            mkdir (fullpath, 0755);
++        }
++
++        strlcat (fullpath, path, PATH_MAX);
++    } else {
++        snprintf (fullpath, PATH_MAX, "%%DATADIR%%%s", path);
++    }
++
++    ret = fopen(fullpath, mode);
+ #ifndef _WIN32 // not windows
+     if (ret == NULL) {
+         char fixedpath[PATH_MAX];
+-        size_t pathlen = strlen(path);
++        size_t pathlen = strlen(fullpath);
+ 
+-        if (pathlen < sizeof(fixedpath) && caselesspath(path, fixedpath, 0)) {
++        if (pathlen < sizeof(fixedpath) && caselesspath(fullpath, fixedpath, 0)) {
+             ret = fopen(fixedpath, mode);
+         }
+     }

Added: head/games/shockolate/files/patch-src_MacSrc_OpenGL.cc
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/games/shockolate/files/patch-src_MacSrc_OpenGL.cc	Sun Jun 28 14:23:58 2020	(r540723)
@@ -0,0 +1,11 @@
+--- src/MacSrc/OpenGL.cc.orig	2020-04-23 04:29:54 UTC
++++ src/MacSrc/OpenGL.cc
+@@ -195,7 +195,7 @@ static GLuint loadShader(GLenum type, const char *file
+     DEBUG("Loading shader %s", filename);
+ 
+     char fb[256];
+-    sprintf(fb, "shaders/%s", filename);
++    sprintf(fb, "%%DATADIR%%shaders/%s", filename);
+ 
+     FILE* file = fopen(fb, "r");
+     if(file == nullptr) {

Added: head/games/shockolate/files/patch-src_MusicSrc_MusicDevice.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/games/shockolate/files/patch-src_MusicSrc_MusicDevice.c	Sun Jun 28 14:23:58 2020	(r540723)
@@ -0,0 +1,91 @@
+--- src/MusicSrc/MusicDevice.c.orig	2020-04-23 04:29:54 UTC
++++ src/MusicSrc/MusicDevice.c
+@@ -1023,9 +1023,10 @@ static int FluidMidiInit(MusicDevice *dev, const unsig
+     fluid_settings_t *settings;
+     fluid_synth_t *synth;
+     int sfid;
+-    char fileName[1024] = "res/";
++    char fileName[1024] = "%%MIDIDIR%%";
++    size_t dirlen = strlen (fileName);
+ 
+-    FluidMidiGetOutputName(dev, outputIndex, &fileName[4], 1020);
++    FluidMidiGetOutputName(dev, outputIndex, &fileName[dirlen], 1024 - dirlen);
+     if (strlen(fileName) == 4)
+     {
+         WARN("Failed to locate SoundFont for outputIndex=%d", outputIndex);
+@@ -1184,19 +1185,20 @@ static unsigned int FluidMidiGetOutputCount(MusicDevic
+         FindClose(hFind);
+     }
+ #else
+-    DIR *dirp = opendir("res");
++    DIR *dirp = opendir("%%MIDIDIR%%");
+     struct dirent *dp = 0;
+-    while ((dp = readdir(dirp)))
+-    {
+-        char *filename = dp->d_name;
+-        char namelen = strlen(filename);
+-        if (namelen < 4) continue; // ".sf2"
+-        if (strcasecmp(".sf2", (char*)(filename + (namelen - 4)))) continue;
+-        // found one
+-        // INFO("Counting SoundFont file: %s", filename);
+-        ++outputCount;
++    if (dirp != NULL) {
++        while ((dp = readdir(dirp))) {
++            char *filename = dp->d_name;
++            char namelen = strlen(filename);
++            if (namelen < 4) continue; // ".sf2"
++            if (strcasecmp(".sf2", (char*)(filename + (namelen - 4)))) continue;
++            // found one
++            // INFO("Counting SoundFont file: %s", filename);
++            ++outputCount;
++        }
++        closedir(dirp);
+     }
+-    closedir(dirp);
+ #endif
+ 
+     // suppress compiler warnings
+@@ -1237,24 +1239,26 @@ static void FluidMidiGetOutputName(MusicDevice *dev, c
+     unsigned int outputCount = 0; // subtract 1 to get index
+     // count .sf2 files in res/ subdirectory until we find the one that the user
+     //  probably wants
+-    DIR *dirp = opendir("res");
+-    struct dirent *dp = 0;
+-    while ((outputCount <= outputIndex) &&
+-           (dp = readdir(dirp)))
+-    {
+-        char *filename = dp->d_name;
+-        char namelen = strlen(filename);
+-        if (namelen < 4) continue; // ".sf2"
+-        if (strcasecmp(".sf2", (char*)(filename + (namelen - 4)))) continue;
+-        // found one
+-        // INFO("Counting SoundFont file: %s", filename);
+-        ++outputCount;
+-        if (outputCount - 1 != outputIndex) continue;
+-        // found it
+-        strncpy(buffer, filename, bufferSize - 1);
+-        // INFO("Found SoundFont file for outputIndex=%d: %s", outputIndex, filename);
++    DIR *dirp = opendir("%%MIDIDIR%%");
++
++    if (dirp != NULL) {
++        struct dirent *dp = 0;
++        while ((outputCount <= outputIndex) &&
++               (dp = readdir(dirp))) {
++            char *filename = dp->d_name;
++            char namelen = strlen(filename);
++            if (namelen < 4) continue; // ".sf2"
++            if (strcasecmp(".sf2", (char*)(filename + (namelen - 4)))) continue;
++            // found one
++            // INFO("Counting SoundFont file: %s", filename);
++            ++outputCount;
++            if (outputCount - 1 != outputIndex) continue;
++            // found it
++            strncpy(buffer, filename, bufferSize - 1);
++            // INFO("Found SoundFont file for outputIndex=%d: %s", outputIndex, filename);
++        }
++        closedir(dirp);
+     }
+-    closedir(dirp);
+ #endif
+     // put NULL in last position in case we filled up everything else
+     *(buffer + bufferSize - 1) = '\0';

Added: head/games/shockolate/pkg-descr
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/games/shockolate/pkg-descr	Sun Jun 28 14:23:58 2020	(r540723)
@@ -0,0 +1,6 @@
+Shockolate is an opensource remake of System Shock, a 1994 FPS game in
+cyberpunk setting.
+
+You will need original System Shock data files to run the game.
+
+WWW: https://github.com/Interrupt/systemshock

Added: head/games/shockolate/pkg-message
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/games/shockolate/pkg-message	Sun Jun 28 14:23:58 2020	(r540723)
@@ -0,0 +1,13 @@
+[
+{ type: install
+  message: << EOM
+To run the game, copy the game's datafiles (data and sound
+directories) into %%PREFIX%%/shared/shockolate/res, then run
+
+$ systemshock
+
+If you want to play MIDI soundtracks with fluidsynth, you need to
+manually install audio/fluid-soundfont port.
+EOM
+}
+]

Added: head/games/shockolate/pkg-plist
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/games/shockolate/pkg-plist	Sun Jun 28 14:23:58 2020	(r540723)
@@ -0,0 +1,6 @@
+bin/systemshock
+%%DATADIR%%/shaders/color.frag
+%%DATADIR%%/shaders/main.vert
+%%DATADIR%%/shaders/star.frag
+%%DATADIR%%/shaders/texture.frag
+@dir %%DATADIR%%/res



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202006281423.05SENwYp076153>