Ports: Add Duke Nukem 3D

This adds 'JonoF's Duke Nukem 3D Port'.

Parts of the network-related stuff has been patched out.
See patch: patches/0002-mmulti.c-ifdef-out-network-related-stuff-we-currentl.patch

Notes:
- Some sound work seems to be needed. During the title screen and
  gameplay SFX works, but music does not play. At the ending screen of
  Hollywood Holocaust music does play.
- GTK has been disabled, by default it will start in fullscreen, to get
  back to windowed mode can be done through the Video Settings.
- OpenGL support has been disabled, as far as I can tell it will need
  OpenGL 2.0 support which we do not currently have.
- True 3D renderer has been turned on.
This commit is contained in:
Kenneth Myhra 2023-05-02 18:21:28 +02:00 committed by Jelle Raaijmakers
parent 9c3e36e72c
commit 368c255368
Notes: sideshowbarker 2024-07-17 10:10:18 +09:00
5 changed files with 181 additions and 0 deletions

View file

@ -108,6 +108,7 @@ This list is also available at [ports.serenityos.net](https://ports.serenityos.n
| [`indent`](indent/) | GNU indent | 2.2.11 | https://www.gnu.org/software/indent/ |
| [`isl`](isl/) | Integer Set Library | 0.24 | https://libisl.sourceforge.io/ |
| [`ja2`](ja2/) | Jagged Alliance 2 Stracciatella | 0.15.x | https://github.com/safarp/ja2-stracciatella/tree/0.15.x |
| [`jfduke3d`](jfduke3d/) | JonoF's Duke Nukem 3D Port | 41cd46b | https://github.com/jonof/jfduke3d |
| [`joe`](joe/) | joe's own editor | 4.6 | https://joe-editor.sourceforge.io/ |
| [`jot`](jot/) | jot (OpenBSD) | 6.6 | https://github.com/ibara/libpuffy |
| [`jq`](jq/) | jq | 1.6 | https://stedolan.github.io/jq/ |

44
Ports/jfduke3d/package.sh Executable file
View file

@ -0,0 +1,44 @@
#!/usr/bin/env -S bash ../.port_include.sh
port='jfduke3d'
version='41cd46bc00633e7457d07d88c8add9f99a7d9d41'
workdir="jfduke3d-${version}"
launcher_name='Duke Nukem 3D'
launcher_category='Games'
launcher_command='duke3d'
auth_type='sha256'
depends=(
'SDL2'
)
jfaudiolib_commit='d72aa171a6fad72d4f19e689f4be989fe472e763'
jfbuild_commit='d3f86131e1eb5fb1397c3e7d477caef675c359d2'
jfmact_commit='1f0746a3b9704906669d8aaed2bbb982053a393e'
files="https://github.com/jonof/jfduke3d/archive/${version}.tar.gz jfduke3d-${version}.tar.gz cef20187b9e9b69b48007e9aaf0c41996aa227abccc5e2fd4ecece2cb503934d
https://github.com/jonof/jfaudiolib/archive/${jfaudiolib_commit}.tar.gz jfaudiolib-${jfaudiolib_commit}.tar.gz 520204c06d6be41838b5a6575a9cbb5dc8889345624c74ff8b9bacee005bd819
https://github.com/jonof/jfbuild/archive/${jfbuild_commit}.tar.gz jfbuild-${jfbuild_commit}.tar.gz 8917f91f10d595fffd3e79e2c816c9130448d8480fb804eba4a880fb0676b0b5
https://github.com/jonof/jfmact/archive/${jfmact_commit}.tar.gz jfmact-${jfmact_commit}.tar.gz 173d978cbeec1b387aac458f77d831d64aa56bb30164939ba75885cea04c777d"
makeopts=(
'USE_OPENGL=0'
'WITHOUT_GTK=1'
'USE_POLYMOST=1'
"SDL2CONFIG=${SERENITY_BUILD_DIR}/Root/usr/local/bin/sdl2-config"
)
pre_patch() {
pushd "${workdir}"
# Initialize submodules from tarballs
rm -rf jfaudiolib
cp -r ../jfaudiolib-${jfaudiolib_commit} jfaudiolib
rm -rf jfbuild
cp -r ../jfbuild-${jfbuild_commit} jfbuild
rm -rf jfmact
cp -r ../jfmact-${jfmact_commit} jfmact
popd
}
install() {
run mkdir -p "${SERENITY_INSTALL_ROOT}/usr/local/bin"
run cp build "${SERENITY_INSTALL_ROOT}/usr/local/bin"
run cp duke3d "${SERENITY_INSTALL_ROOT}/usr/local/bin"
}

View file

@ -0,0 +1,27 @@
From af5cc138782430963d05b2f92e60916f48c9f807 Mon Sep 17 00:00:00 2001
From: Kenneth Myhra <kennethmyhra@gmail.com>
Date: Mon, 1 May 2023 17:33:37 +0200
Subject: [PATCH 1/2] [compat.h] Recognize endianness of SerenityOS by picking
up endian.h
We have endian.h so let's pick that header.
---
include/compat.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/jfbuild/include/compat.h b/jfbuild/include/compat.h
index 8a879b0..66ddcad 100644
--- a/jfbuild/include/compat.h
+++ b/jfbuild/include/compat.h
@@ -100,7 +100,7 @@ typedef unsigned __int64 uint64_t;
# define NULL ((void *)0)
#endif
-#if defined(__linux)
+#if defined(__linux) || defined(__serenity__)
# include <endian.h>
# if __BYTE_ORDER == __LITTLE_ENDIAN
# define B_LITTLE_ENDIAN 1
--
2.40.1

View file

@ -0,0 +1,91 @@
From 792069a881f0b189aaa9f694165b1cd2274a581f Mon Sep 17 00:00:00 2001
From: Kenneth Myhra <kennethmyhra@gmail.com>
Date: Mon, 1 May 2023 18:24:10 +0200
Subject: [PATCH 2/2] [mmulti.c] #ifdef out network-related stuff we currently
do not support
This patches out network-relatd stuff like IP_PKTINFO, IPV6_PKTINFO, and
IP_RECVDSTADDR which we currently do not support.
This is merely done to make the code compile, and since we do not try to
support any multiplayer option or other network-related stuff it should
not matter for the time being.
---
src/mmulti.c | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
diff --git a/jfbuild/src/mmulti.c b/jfbuild/src/mmulti.c
index ca3922f..8191358 100644
--- a/jfbuild/src/mmulti.c
+++ b/jfbuild/src/mmulti.c
@@ -205,7 +205,10 @@ int netinit (int portnum)
}
// Request that we receive IPV4 packet info.
-#if defined(__linux) || defined(_WIN32)
+#if defined(__serenity__)
+ // Do nothing
+ if (0)
+#elif defined(__linux) || defined(_WIN32)
if (setsockopt(mysock, IPPROTO_IP, IP_PKTINFO, (void *)&on, sizeof(on)) != 0)
#else
if (domain == PF_INET && setsockopt(mysock, IPPROTO_IP, IP_RECVDSTADDR, &on, sizeof(on)) != 0)
@@ -337,7 +340,9 @@ int netsend (int other, void *dabuf, int bufsiz) //0:buffer full... can't send
// just have to cross our fingers.
if (replyfrom4[other].s_addr != INADDR_ANY) {
cmsg->cmsg_level = IPPROTO_IP;
-#if defined(__linux) || defined(_WIN32)
+#if defined(__serenity__)
+ // Do nothing
+#elif defined(__linux) || defined(_WIN32)
cmsg->cmsg_type = IP_PKTINFO;
cmsg->cmsg_len = CMSG_LEN(sizeof(struct in_pktinfo));
#ifdef _WIN32
@@ -355,6 +360,7 @@ int netsend (int other, void *dabuf, int bufsiz) //0:buffer full... can't send
cmsg = CMSG_NXTHDR(&msg, cmsg);
}
#endif
+#ifndef __serenity__
if (!IN6_IS_ADDR_UNSPECIFIED(&replyfrom6[other])) {
cmsg->cmsg_level = IPPROTO_IPV6;
cmsg->cmsg_type = IPV6_PKTINFO;
@@ -363,6 +369,7 @@ int netsend (int other, void *dabuf, int bufsiz) //0:buffer full... can't send
len += CMSG_SPACE(sizeof(struct in6_pktinfo));
cmsg = CMSG_NXTHDR(&msg, cmsg);
}
+#endif
#ifdef _WIN32
msg.Control.len = len;
if (len == 0) {
@@ -449,7 +456,11 @@ int netread (int *other, void *dabuf, int bufsiz) //0:no packets in buffer
memset(&snatchreplyfrom4, 0, sizeof(snatchreplyfrom4));
memset(&snatchreplyfrom6, 0, sizeof(snatchreplyfrom6));
for (cmsg = CMSG_FIRSTHDR(&msg); cmsg; cmsg = CMSG_NXTHDR(&msg, cmsg)) {
-#if defined(__linux) || defined(_WIN32)
+#if defined(__serenity__)
+ // Do nothing
+ if (0) {
+ }
+#elif defined(__linux) || defined(_WIN32)
if (cmsg->cmsg_level == IPPROTO_IP && cmsg->cmsg_type == IP_PKTINFO) {
snatchreplyfrom4 = ((struct in_pktinfo *)CMSG_DATA(cmsg))->ipi_addr;
#ifdef MMULTI_DEBUG_SENDRECV_WIRE
@@ -511,6 +522,7 @@ static int issameaddress(struct sockaddr *a, struct sockaddr *b) {
return a4->sin_addr.s_addr == b4->sin_addr.s_addr &&
a4->sin_port == b4->sin_port;
}
+#ifndef __serenity__
if (a->sa_family == AF_INET6) {
// IPV6.
struct sockaddr_in6 *a6 = (struct sockaddr_in6 *)a;
@@ -518,6 +530,7 @@ static int issameaddress(struct sockaddr *a, struct sockaddr *b) {
return IN6_ARE_ADDR_EQUAL(&a6->sin6_addr, &b6->sin6_addr) &&
a6->sin6_port == b6->sin6_port;
}
+#endif
return 0;
}
--
2.40.1

View file

@ -0,0 +1,18 @@
# Patches for jfduke3d on SerenityOS
## `0001-compat.h-Recognize-endianness-of-SerenityOS-by-picki.patch`
[compat.h] Recognize endianness of SerenityOS by picking up endian.h
We have endian.h so let's pick that header.
## `0002-mmulti.c-ifdef-out-network-related-stuff-we-currentl.patch`
[mmulti.c] #ifdef out network-related stuff we currently
This patches out network-relatd stuff like IP_PKTINFO, IPV6_PKTINFO, and
IP_RECVDSTADDR which we currently do not support.
This is merely done to make the code compile, and since we do not try to
support any multiplayer option or other network-related stuff it should
not matter for the time being.