mirror of
https://git.FreeBSD.org/ports.git
synced 2024-11-20 00:21:35 +00:00
Add games/shockolate, Cross platform System Shock
PR: 246072 Submitted by: Vasily Postnicov <shamaz.mazum@gmail.com>
This commit is contained in:
parent
716ed4b2d9
commit
e9cc444501
Notes:
svn2git
2021-03-31 03:12:20 +00:00
svn path=/head/; revision=540723
@ -873,6 +873,7 @@
|
||||
SUBDIR += sex
|
||||
SUBDIR += sgt-puzzles
|
||||
SUBDIR += shaaft
|
||||
SUBDIR += shockolate
|
||||
SUBDIR += shootingstar
|
||||
SUBDIR += simplevaders
|
||||
SUBDIR += simsu
|
||||
|
41
games/shockolate/Makefile
Normal file
41
games/shockolate/Makefile
Normal file
@ -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>
|
3
games/shockolate/distinfo
Normal file
3
games/shockolate/distinfo
Normal file
@ -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
|
52
games/shockolate/files/patch-src_GameSrc_setup.c
Normal file
52
games/shockolate/files/patch-src_GameSrc_setup.c
Normal file
@ -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))
|
@ -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);
|
||||
}
|
||||
}
|
11
games/shockolate/files/patch-src_MacSrc_OpenGL.cc
Normal file
11
games/shockolate/files/patch-src_MacSrc_OpenGL.cc
Normal file
@ -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) {
|
91
games/shockolate/files/patch-src_MusicSrc_MusicDevice.c
Normal file
91
games/shockolate/files/patch-src_MusicSrc_MusicDevice.c
Normal file
@ -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';
|
6
games/shockolate/pkg-descr
Normal file
6
games/shockolate/pkg-descr
Normal file
@ -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
|
13
games/shockolate/pkg-message
Normal file
13
games/shockolate/pkg-message
Normal file
@ -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
|
||||
}
|
||||
]
|
6
games/shockolate/pkg-plist
Normal file
6
games/shockolate/pkg-plist
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user