From 7700f8b88ec9dd5d9d67b012c362f520a5abd438 Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Wed, 30 Oct 2019 12:37:49 +1000
Subject: [PATCH] OpenJK:Jedi Outcast: add recipe
---
.../additional-files/openjk_outcast.rdef.in | 40 ++++
.../openjk_outcast-2019.10.25.recipe | 129 +++++++++++++
.../openjk_outcast-2019.10.25.patchset | 179 ++++++++++++++++++
3 files changed, 348 insertions(+)
create mode 100644 games-fps/openjk_outcast/additional-files/openjk_outcast.rdef.in
create mode 100644 games-fps/openjk_outcast/openjk_outcast-2019.10.25.recipe
create mode 100644 games-fps/openjk_outcast/patches/openjk_outcast-2019.10.25.patchset
diff --git a/games-fps/openjk_outcast/additional-files/openjk_outcast.rdef.in b/games-fps/openjk_outcast/additional-files/openjk_outcast.rdef.in
new file mode 100644
index 000000000..142507938
--- /dev/null
+++ b/games-fps/openjk_outcast/additional-files/openjk_outcast.rdef.in
@@ -0,0 +1,40 @@
+resource app_flags B_SINGLE_LAUNCH;
+
+resource app_version {
+ major = @MAJOR@,
+ middle = @MIDDLE@,
+ minor = @MINOR@,
+
+ variety = B_APPV_FINAL,
+ internal = 0,
+
+ short_info = "StarWars: Jedi Outcast",
+ long_info = "@LONG_INFO@"
+};
+
+resource app_signature "@APP_SIGNATURE@";
+
+resource vector_icon array {
+ $"6E6369660403066AFF020106033811E53E0C75BE628C3868E049B04F4A7B3700"
+ $"FFFFFFE5B6E6FFFF82D4FF0501040158040627ABBAFFFFFFFFBBAAEF3EBF67C3"
+ $"5ABF67C35ABF2EC308BE04C154BEE7C3C6BC25C42DBEE7C493BDD6C6AABF5BC5"
+ $"11BF2BC544BF47C819BF43C8D8BC3CBEB4B874C5B0BC3CBEB4BBCAB64CB785B9"
+ $"7FBBCAB64CB91FC243B47FBAB3B91FC243B74CBABEB54CBE86B74CBABEB80EC5"
+ $"05B3D4BFA3B80EC505B5E0C198B6E6C44FB5E0C198BFA8C9C7B69FC9ACBFA8C9"
+ $"C7BFA8C9C7BFA8C9C7BFB0C9C740C9C7BFB8C9C7BFC7C9C7BFD7C9C7BFCFC9C7"
+ $"BFD7C9C7BFD7C9C7BFD7C9C7C8E0C9ACC99FC198C99FC198C899C44FC771C505"
+ $"C771C505CBABBFA3C833BABEC833BABECA33BE86C660C243C660C243CB00BAB3"
+ $"C3B5B64CC3B5B64CC7FAB97FC343BEB4C343BEB4C70BC5B0C03CC8D8C024C511"
+ $"C038C819C054C544C1A9C6AAC098C493C35AC42DC098C3C6C17BC154C018C35A"
+ $"C051C308BFFFBF7A40B5D340B5DF40B5B840B5B840B5C340B5B8BFBFB5B8BFBF"
+ $"B5B8BFBFB5D3BFBFB5B8BFBFB5E6BF67C35ABF80BF7DBF67C35A020540204020"
+ $"B8B520204020B8B520C6CA40CC7FB8B5CC7FC6CACC7FCC7F40CC7FC6CACC7FB8"
+ $"B54020C6CA204020020540B48740B487C5F2B487CAF840CAF8B98DCAF8C5F240"
+ $"CAF8C5F2CAF8B98DCAF8B48740B487C5F2B487B98D40B487B98DB48740B48702"
+ $"0540204020B8B520204020B8B520C6CA40CC7FB8B5CC7FC6CACC7FCC7F40CC7F"
+ $"C6CACC7FB8B54020C6CA204020050A03020001023F0FF30000000000003C7FB4"
+ $"47C0194AC0120A020101023FBFFC0000000000003FCFFD2969FF288F870A0101"
+ $"02023FBFFC0000000000003FCFFD2969FF288F870A000100023F74FB00000000"
+ $"00003F83BC42D01F42DC190A00020203123F66360000000000003F74B842CE4D"
+ $"42DA3F0115810204"
+};
diff --git a/games-fps/openjk_outcast/openjk_outcast-2019.10.25.recipe b/games-fps/openjk_outcast/openjk_outcast-2019.10.25.recipe
new file mode 100644
index 000000000..95a04c4c9
--- /dev/null
+++ b/games-fps/openjk_outcast/openjk_outcast-2019.10.25.recipe
@@ -0,0 +1,129 @@
+SUMMARY="Community-maintained Star Wars Jedi Knight II: Jedi Outcast, story version"
+DESCRIPTION="OpenJK is an effort by the JACoders group to maintain and improve the \
+game engines on which the Jedi Academy (JA) and Jedi Outcast (JO) games run on, while \
+maintaining full backwards compatibility with the existing games. This project does \
+not attempt to rebalance or otherwise modify core gameplay.
+
+Our aims are to:
+* Improve the stability of the engine by fixing bugs and improving performance.
+* Provide a clean base from which new JO and JA code modifications can be made.
+
+Make available this engine to more operating systems.
+Currently, the most stable portion of this project is the Jedi Academy multiplayer code, \
+with the single player code in a reasonable state.
+
+Rough support for Jedi Outcast single player is also available, however this should be \
+considered heavily work in progress. This is not currently actively worked on or tested. \
+OpenJK does not have Jedi Outcast multiplayer support."
+HOMEPAGE="https://github.com/JACoders/OpenJK"
+COPYRIGHT="2003 Activision"
+LICENSE="GNU GPL v2"
+REVISION="1"
+srcGitRev="e9116155052ef6a22135a1806a10e959aa9a1e00"
+SOURCE_URI="https://github.com/JACoders/OpenJK/archive/$srcGitRev.tar.gz"
+CHECKSUM_SHA256="eb2e51d113c23073ec05b0a799dd2e54bb7332556585c4539d32540039c138a6"
+SOURCE_DIR="OpenJK-$srcGitRev"
+srcGitRev2="68b5907feff0dda72fe5435e1108ccd2ad7e8ed5"
+SOURCE_URI_2="https://github.com/EXL/BeGameLauncher/archive/$srcGitRev2.tar.gz"
+CHECKSUM_SHA256_2="e564291d665ad3c9bb329e6849ab399d1ce0cbc59bd47bcc15a22f3c6e9345a1"
+SOURCE_DIR_2="BeGameLauncher-$srcGitRev2"
+PATCHES="openjk_outcast-$portVersion.patchset"
+ADDITIONAL_FILES="openjk_outcast.rdef.in"
+
+ARCHITECTURES="!x86_gcc2 x86_64"
+SECONDARY_ARCHITECTURES="x86"
+
+PROVIDES="
+ openjk_outcast$secondaryArchSuffix = $portVersion
+ app:JediOutcast$secondaryArchSuffix = $portVersion
+ "
+REQUIRES="
+ haiku$secondaryArchSuffix
+ lib:libgl$secondaryArchSuffix
+ lib:libintl$secondaryArchSuffix
+ lib:libjpeg$secondaryArchSuffix
+ lib:libpng16$secondaryArchSuffix
+ lib:libsdl2_2.0$secondaryArchSuffix
+ lib:libz$secondaryArchSuffix
+ lib:libzlib$secondaryArchSuffix
+ "
+
+BUILD_REQUIRES="
+ haiku${secondaryArchSuffix}_devel
+ devel:libgl$secondaryArchSuffix
+ devel:libintl$secondaryArchSuffix
+ devel:libjpeg$secondaryArchSuffix
+ devel:libpng16$secondaryArchSuffix
+ devel:libsdl2_2.0$secondaryArchSuffix
+ devel:libz$secondaryArchSuffix
+ devel:libzlib$secondaryArchSuffix
+ "
+BUILD_PREREQUIRES="
+ cmd:cmake
+ cmd:gcc$secondaryArchSuffix
+ cmd:ld$secondaryArchSuffix
+ cmd:make
+ cmd:pkg_config$secondaryArchSuffix
+ "
+
+BUILD()
+{
+ mkdir -p build
+ cd build
+
+ cmake .. \
+ -DCMAKE_BUILD_TYPE=Release \
+ -DCMAKE_INSTALL_PREFIX=$appsDir/JediOutcast \
+ -DSDL2_INCLUDE_DIR=/system/$relativeIncludeDir/SDL2 \
+ -DBuildJK2SPEngine=ON \
+ -DBuildJK2SPGame=ON \
+ -DBuildJK2SPRdVanilla=ON \
+ -DBuildMPCGame=OFF \
+ -DBuildMPDed=OFF \
+ -DBuildMPEngine=OFF \
+ -DBuildMPGame=OFF \
+ -DBuildMPRdVanilla=OFF \
+ -DBuildMPUI=OFF \
+ -DBuildSPEngine=OFF \
+ -DBuildSPGame=OFF \
+ -DBuildSPRdVanilla=OFF \
+ -DBuildTests=OFF
+ make $jobArgs
+
+ cd $sourceDir2
+ mkdir -p build
+ cd build
+ cmake .. \
+ -DCMAKE_BUILD_TYPE=Release \
+ -DLAUNCHER=openjk_outcast
+ make $jobArgs
+}
+
+INSTALL()
+{
+ cd build
+
+ mkdir -p $appsDir/JediOutcast/lib
+
+ cp openjo_sp.* $appsDir/JediOutcast/JediOutcast
+ cp code/rd-vanilla/*.so $appsDir/JediOutcast/lib
+ cp codeJK2/game/*.so $appsDir/JediOutcast/lib
+ cp $sourceDir2/build/JediOutcastLauncher $appsDir/JediOutcast
+
+ local APP_SIGNATURE="application/x-vnd.JediOutcast"
+ local MAJOR="`echo "$portVersion" | cut -d. -f1`"
+ local MIDDLE="`echo "$portVersion" | cut -d. -f2`"
+ local MINOR="`echo "$portVersion" | cut -d. -f3`"
+ local LONG_INFO="$SUMMARY"
+ sed \
+ -e "s|@APP_SIGNATURE@|$APP_SIGNATURE|" \
+ -e "s|@MAJOR@|$MAJOR|" \
+ -e "s|@MIDDLE@|$MIDDLE|" \
+ -e "s|@MINOR@|$MINOR|" \
+ -e "s|@LONG_INFO@|$LONG_INFO|" \
+ $portDir/additional-files/openjk_outcast.rdef.in > $sourceDir/build/openjk_outcast.rdef
+
+ addResourcesToBinaries $sourceDir/build/openjk_outcast.rdef $appsDir/JediOutcast/JediOutcast
+
+ addAppDeskbarSymlink $appsDir/JediOutcast/JediOutcastLauncher "StarWars Jedi Knight II: Jedi Outcast"
+}
diff --git a/games-fps/openjk_outcast/patches/openjk_outcast-2019.10.25.patchset b/games-fps/openjk_outcast/patches/openjk_outcast-2019.10.25.patchset
new file mode 100644
index 000000000..996491d88
--- /dev/null
+++ b/games-fps/openjk_outcast/patches/openjk_outcast-2019.10.25.patchset
@@ -0,0 +1,179 @@
+From fd56d9c29cb9d90e6718cffca7a8e19314e968d7 Mon Sep 17 00:00:00 2001
+From: Gerasim Troeglazov <3dEyes@gmail.com>
+Date: Wed, 30 Oct 2019 00:18:24 +1000
+Subject: Add Haiku support
+
+
+diff --git a/code/qcommon/files.cpp b/code/qcommon/files.cpp
+index c35d0e0..c4f6149 100644
+--- a/code/qcommon/files.cpp
++++ b/code/qcommon/files.cpp
+@@ -2885,6 +2885,12 @@ void FS_Startup( const char *gameName ) {
+ if (fs_basepath->string[0]) {
+ FS_AddGameDirectory( fs_basepath->string, gameName );
+ }
++#ifdef __HAIKU__
++ char *p;
++ if ( (p = getenv( "OPENJK_GAME_DATA" )) != NULL ) {
++ FS_AddGameDirectory( p, gameName );
++ }
++#endif
+
+ #ifdef MACOS_X
+ fs_apppath = Cvar_Get ("fs_apppath", Sys_DefaultAppPath(), CVAR_INIT|CVAR_PROTECTED );
+diff --git a/code/rd-vanilla/qgl.h b/code/rd-vanilla/qgl.h
+index f9fc10f..3e3d384 100644
+--- a/code/rd-vanilla/qgl.h
++++ b/code/rd-vanilla/qgl.h
+@@ -39,6 +39,8 @@ along with this program; if not, see .
+ # if defined(__FX__)
+ # include
+ # endif
++#elif defined( __HAIKU__ )
++# include
+ #elif defined( __FreeBSD__ ) || defined(__OpenBSD__) // rb010123
+ # include
+ # include
+diff --git a/lib/minizip/ioapi.c b/lib/minizip/ioapi.c
+index 7f5c191..0db4bbf 100644
+--- a/lib/minizip/ioapi.c
++++ b/lib/minizip/ioapi.c
+@@ -14,7 +14,7 @@
+ #define _CRT_SECURE_NO_WARNINGS
+ #endif
+
+-#if defined(__APPLE__) || defined(IOAPI_NO_64)
++#if defined(__APPLE__) || defined(__HAIKU__) || defined(IOAPI_NO_64)
+ // In darwin and perhaps other BSD variants off_t is a 64 bit value, hence no need for specific 64 bit functions
+ #define FOPEN_FUNC(filename, mode) fopen(filename, mode)
+ #define FTELLO_FUNC(stream) ftello(stream)
+diff --git a/shared/qcommon/q_platform.h b/shared/qcommon/q_platform.h
+index bddb7bd..d54b0f8 100644
+--- a/shared/qcommon/q_platform.h
++++ b/shared/qcommon/q_platform.h
+@@ -143,6 +143,30 @@ along with this program; if not, see .
+
+ #define DLL_EXT ".so"
+
++// Haiku
++#elif defined(__HAIKU__)
++
++ #include
++ #define OS_STRING "haiku"
++ #define QINLINE inline
++ #define PATH_SEP '/'
++
++ #if !defined(ARCH_STRING)
++ #error ARCH_STRING should be defined by the build system
++ #endif
++
++ #if defined(__x86_64__)
++ #define idx64
++ #endif
++
++ #if __FLOAT_WORD_ORDER == __BIG_ENDIAN
++ #define Q3_BIG_ENDIAN
++ #else
++ #define Q3_LITTLE_ENDIAN
++ #endif
++
++ #define DLL_EXT ".so"
++
+ // BSD
+ #elif defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)
+
+diff --git a/shared/sdl/sdl_window.cpp b/shared/sdl/sdl_window.cpp
+index 5fa0f8b..4dfd01b 100644
+--- a/shared/sdl/sdl_window.cpp
++++ b/shared/sdl/sdl_window.cpp
+@@ -87,7 +87,7 @@ const vidmode_t r_vidModes[] = {
+ };
+ static const int s_numVidModes = ARRAY_LEN( r_vidModes );
+
+-#define R_MODE_FALLBACK (4) // 640x480
++#define R_MODE_FALLBACK (6) // 1024x768
+
+ qboolean R_GetModeInfo( int *width, int *height, int mode ) {
+ const vidmode_t *vm;
+@@ -347,6 +347,12 @@ static rserr_t GLimp_SetMode(glconfig_t *glConfig, const windowDesc_t *windowDes
+ #endif
+ );
+
++#ifdef __HAIKU__
++ if (r_fullscreen->integer == 1) {
++ mode = -2;
++ }
++#endif
++
+ // If a window exists, note its display index
+ if ( screen != NULL )
+ {
+@@ -713,9 +719,11 @@ static qboolean GLimp_StartDriverAndSetMode(glconfig_t *glConfig, const windowDe
+ case RSERR_INVALID_MODE:
+ Com_Printf( "...WARNING: could not set the given mode (%d)\n", mode );
+ return qfalse;
++#ifndef __HAIKU__
+ case RSERR_UNKNOWN:
+ Com_Printf( "...ERROR: no display modes could be found.\n" );
+ return qfalse;
++#endif
+ default:
+ break;
+ }
+@@ -809,8 +817,9 @@ void WIN_Shutdown( void )
+ Cmd_RemoveCommand("minimize");
+
+ IN_Shutdown();
+-
++#ifndef __HAIKU__
+ SDL_QuitSubSystem( SDL_INIT_VIDEO );
++#endif
+ screen = NULL;
+ }
+
+diff --git a/shared/sys/sys_unix.cpp b/shared/sys/sys_unix.cpp
+index 96f5b7a..c90f068 100644
+--- a/shared/sys/sys_unix.cpp
++++ b/shared/sys/sys_unix.cpp
+@@ -400,6 +400,12 @@ Sys_Mkdir
+ */
+ qboolean Sys_Mkdir( const char *path )
+ {
++#ifdef __HAIKU__
++ struct stat buff;
++ if (stat(path, &buff) == 0)
++ if (S_ISDIR(buff.st_mode))
++ return qtrue;
++#endif
+ int result = mkdir( path, 0750 );
+
+ if( result != 0 )
+@@ -468,6 +474,25 @@ char *Sys_DefaultHomePath(void)
+
+ return homePath;
+ }
++#elif defined(__HAIKU__)
++char *Sys_DefaultHomePath(void)
++{
++ char *p;
++
++ if ( !homePath[0] )
++ {
++ if ( (p = getenv( "HOME" )) != NULL )
++ {
++ Com_sprintf( homePath, sizeof( homePath ), "%s/config/settings/OpenJK/", p );
++ if ( com_homepath && com_homepath->string[0] )
++ Q_strcat( homePath, sizeof( homePath ), com_homepath->string );
++ else
++ Q_strcat( homePath, sizeof( homePath ), HOMEPATH_NAME_MACOSX );
++ return homePath;
++ }
++ }
++ return homePath;
++}
+ #else
+ char *Sys_DefaultHomePath(void)
+ {
+--
+2.23.0
+