diff options
author | Li-Wen Hsu <lwhsu@FreeBSD.org> | 2020-06-28 14:23:58 +0000 |
---|---|---|
committer | Li-Wen Hsu <lwhsu@FreeBSD.org> | 2020-06-28 14:23:58 +0000 |
commit | e9cc444501702854472554e7d35e120ebda3adc7 (patch) | |
tree | 9742ec02ec23b1ecf75cef22bbb6b6169c730c70 /games | |
parent | 716ed4b2d9ffa0f509ee6093e7f4189184b51f15 (diff) | |
download | ports-e9cc444501702854472554e7d35e120ebda3adc7.tar.gz ports-e9cc444501702854472554e7d35e120ebda3adc7.zip |
Add games/shockolate, Cross platform System Shock
PR: 246072
Submitted by: Vasily Postnicov <shamaz.mazum@gmail.com>
Notes
Notes:
svn path=/head/; revision=540723
Diffstat (limited to 'games')
-rw-r--r-- | games/Makefile | 1 | ||||
-rw-r--r-- | games/shockolate/Makefile | 41 | ||||
-rw-r--r-- | games/shockolate/distinfo | 3 | ||||
-rw-r--r-- | games/shockolate/files/patch-src_GameSrc_setup.c | 52 | ||||
-rw-r--r-- | games/shockolate/files/patch-src_Libraries_RES_Source_caseless.c | 49 | ||||
-rw-r--r-- | games/shockolate/files/patch-src_MacSrc_OpenGL.cc | 11 | ||||
-rw-r--r-- | games/shockolate/files/patch-src_MusicSrc_MusicDevice.c | 91 | ||||
-rw-r--r-- | games/shockolate/pkg-descr | 6 | ||||
-rw-r--r-- | games/shockolate/pkg-message | 13 | ||||
-rw-r--r-- | games/shockolate/pkg-plist | 6 |
10 files changed, 273 insertions, 0 deletions
diff --git a/games/Makefile b/games/Makefile index e3c52c6532e4..dd2a1932e876 100644 --- a/games/Makefile +++ b/games/Makefile @@ -873,6 +873,7 @@ SUBDIR += sex SUBDIR += sgt-puzzles SUBDIR += shaaft + SUBDIR += shockolate SUBDIR += shootingstar SUBDIR += simplevaders SUBDIR += simsu diff --git a/games/shockolate/Makefile b/games/shockolate/Makefile new file mode 100644 index 000000000000..bfe1c76597aa --- /dev/null +++ b/games/shockolate/Makefile @@ -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> diff --git a/games/shockolate/distinfo b/games/shockolate/distinfo new file mode 100644 index 000000000000..3dd933fe223c --- /dev/null +++ b/games/shockolate/distinfo @@ -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 diff --git a/games/shockolate/files/patch-src_GameSrc_setup.c b/games/shockolate/files/patch-src_GameSrc_setup.c new file mode 100644 index 000000000000..078cb28d4f93 --- /dev/null +++ b/games/shockolate/files/patch-src_GameSrc_setup.c @@ -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)) diff --git a/games/shockolate/files/patch-src_Libraries_RES_Source_caseless.c b/games/shockolate/files/patch-src_Libraries_RES_Source_caseless.c new file mode 100644 index 000000000000..8fa71ef9e9e7 --- /dev/null +++ b/games/shockolate/files/patch-src_Libraries_RES_Source_caseless.c @@ -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); + } + } diff --git a/games/shockolate/files/patch-src_MacSrc_OpenGL.cc b/games/shockolate/files/patch-src_MacSrc_OpenGL.cc new file mode 100644 index 000000000000..e303222fb3f9 --- /dev/null +++ b/games/shockolate/files/patch-src_MacSrc_OpenGL.cc @@ -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) { diff --git a/games/shockolate/files/patch-src_MusicSrc_MusicDevice.c b/games/shockolate/files/patch-src_MusicSrc_MusicDevice.c new file mode 100644 index 000000000000..f3209b4ecf50 --- /dev/null +++ b/games/shockolate/files/patch-src_MusicSrc_MusicDevice.c @@ -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'; diff --git a/games/shockolate/pkg-descr b/games/shockolate/pkg-descr new file mode 100644 index 000000000000..a2668ad839d9 --- /dev/null +++ b/games/shockolate/pkg-descr @@ -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 diff --git a/games/shockolate/pkg-message b/games/shockolate/pkg-message new file mode 100644 index 000000000000..3d6d5214084d --- /dev/null +++ b/games/shockolate/pkg-message @@ -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 +} +] diff --git a/games/shockolate/pkg-plist b/games/shockolate/pkg-plist new file mode 100644 index 000000000000..c0c9dbb7f77a --- /dev/null +++ b/games/shockolate/pkg-plist @@ -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 |