Ports: Add openttd

This commit is contained in:
Gunnar Beutner 2021-04-17 15:40:17 +02:00 committed by Linus Groh
parent 4b33365078
commit ae32abffe9
8 changed files with 244 additions and 0 deletions

View file

@ -81,6 +81,9 @@ Please make sure to keep this list up to date when adding and updating ports. :^
| [`nyancat`](nyancat/) | Nyancat | | https://github.com/klange/nyancat |
| [`openssh`](openssh/) | OpenSSH | 8.3-9ca7e9c | https://github.com/openssh/openssh-portable |
| [`openssl`](openssl/) | OpenSSL | 1.0.2t | https://www.openssl.org/ |
| [`openttd`](openttd/) | OpenTTD | 1.11.0 | https://www.openttd.org/ |
| [`openttd-opengfx`](openttd-opengfx/) | OpenGFX graphics for OpenTTD | 0.6.1 | https://www.openttd.org/ |
| [`openttd-opensfx`](openttd-opensfx/) | OpenSFX audio files for OpenTTD | 1.0.1 | https://www.openttd.org/ |
| [`oksh`](oksh/) | oksh | 6.8.1 | https://github.com/ibara/oksh |
| [`patch`](patch/) | patch (OpenBSD) | 6.6 | https://github.com/ibara/libpuffy |
| [`pcre`](pcre/) | Perl-compatible Regular Expressions (PCRE) | 8.44 | https://www.pcre.org/ |

View file

@ -0,0 +1,16 @@
#!/usr/bin/env -S bash ../.port_include.sh
port=openttd-opengfx
version=0.6.1
workdir=.
files="https://cdn.openttd.org/opengfx-releases/${version}/opengfx-${version}-all.zip opengfx-${version}-all.zip c694a112cd508d9c8fdad1b92bde05e7c48b14d66bad0c3999e443367437e37e"
auth_type=sha256
build() {
# The ZIP file we downloaded contains a tarball.
run_nocd tar xf opengfx-${version}.tar
}
install() {
run_nocd mkdir -p ${SERENITY_INSTALL_ROOT}/usr/local/share/games/openttd/baseset/
run_nocd cp -a opengfx-${version}/* ${SERENITY_INSTALL_ROOT}/usr/local/share/games/openttd/baseset/
}

View file

@ -0,0 +1,16 @@
#!/usr/bin/env -S bash ../.port_include.sh
port=openttd-opensfx
version=1.0.1
workdir=.
files="https://cdn.openttd.org/opensfx-releases/${version}/opensfx-${version}-all.zip opensfx-${version}-all.zip 37b825426f1d690960313414423342733520d08916f512f30f7aaf30910a36c5"
auth_type=sha256
build() {
# The ZIP file we downloaded contains a tarball.
run_nocd tar xf opensfx-${version}.tar
}
install() {
run_nocd mkdir -p ${SERENITY_INSTALL_ROOT}/usr/local/share/games/openttd/baseset/
run_nocd cp -a opensfx-${version}/* ${SERENITY_INSTALL_ROOT}/usr/local/share/games/openttd/baseset/
}

47
Ports/openttd/package.sh Executable file
View file

@ -0,0 +1,47 @@
#!/usr/bin/env -S bash ../.port_include.sh
port=openttd
version=1.11.0
auth_type=sha256
depends="SDL2 libpng zlib xz"
files="https://cdn.openttd.org/openttd-releases/${version}/openttd-${version}-source.tar.xz openttd-${version}.tar.xz 5e65184e07368ba1afa62dbb3e35abaee6c4da6730ff4bc9eb4447d53363c7a8"
useconfigure=true
configopts="-DCMAKE_TOOLCHAIN_FILE=$SERENITY_ROOT/Toolchain/CMake/CMakeToolchain.txt"
configure() {
host_env
mkdir -p $workdir/host-build
(
cd $workdir/host-build
cmake .. -DOPTION_TOOLS_ONLY=1
)
target_env
mkdir -p $workdir/build
(
cd $workdir/build
cmake .. $configopts -DHOST_BINARY_DIR=$(pwd)/../host-build
)
}
build() {
host_env
(
cd $workdir/host-build
make $makeopts
)
target_env
(
cd $workdir/build
make $makeopts
)
}
install() {
(
cd $workdir/build
make install
)
ln -sf /usr/local/games/openttd $DESTDIR/usr/local/bin/openttd
}

View file

@ -0,0 +1,116 @@
diff -Naur openttd-1.11.0/cmake/CompileFlags.cmake openttd-1.11.0.serenity/cmake/CompileFlags.cmake
--- openttd-1.11.0/cmake/CompileFlags.cmake 2021-04-01 14:33:44.000000000 +0200
+++ openttd-1.11.0.serenity/cmake/CompileFlags.cmake 2021-04-19 19:30:33.457232215 +0200
@@ -154,7 +154,7 @@
message(FATAL_ERROR "No warning flags are set for this compiler yet; please consider creating a Pull Request to add support for this compiler.")
endif()
- if(NOT WIN32)
+ if(NOT WIN32 AND NOT SERENITYOS)
# rdynamic is used to get useful stack traces from crash reports.
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -rdynamic")
endif()
diff -Naur openttd-1.11.0/src/network/core/address.cpp openttd-1.11.0.serenity/src/network/core/address.cpp
--- openttd-1.11.0/src/network/core/address.cpp 2021-04-01 14:33:44.000000000 +0200
+++ openttd-1.11.0.serenity/src/network/core/address.cpp 2021-04-19 19:30:33.457232215 +0200
@@ -372,7 +372,7 @@
DEBUG(net, 3, "[%s] could not set reusable %s sockets for port %s: %s", type, family, address, strerror(errno));
}
-#ifndef __OS2__
+#if !defined(__OS2__) && !defined(__serenity__)
if (runp->ai_family == AF_INET6 &&
setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, (const char*)&on, sizeof(on)) == -1) {
DEBUG(net, 3, "[%s] could not disable IPv4 over IPv6 on port %s: %s", type, address, strerror(errno));
diff -Naur openttd-1.11.0/src/network/core/host.cpp openttd-1.11.0.serenity/src/network/core/host.cpp
--- openttd-1.11.0/src/network/core/host.cpp 2021-04-01 14:33:44.000000000 +0200
+++ openttd-1.11.0.serenity/src/network/core/host.cpp 2021-04-19 19:30:33.457232215 +0200
@@ -147,6 +147,7 @@
static void NetworkFindBroadcastIPsInternal(NetworkAddressList *broadcast) // !GETIFADDRS implementation
{
+#ifndef __serenity__
SOCKET sock = socket(AF_INET, SOCK_DGRAM, 0);
if (sock == INVALID_SOCKET) return;
@@ -183,6 +184,7 @@
}
closesocket(sock);
+#endif
}
#endif /* all NetworkFindBroadcastIPsInternals */
diff -Naur openttd-1.11.0/src/network/core/os_abstraction.h openttd-1.11.0.serenity/src/network/core/os_abstraction.h
--- openttd-1.11.0/src/network/core/os_abstraction.h 2021-04-01 14:33:44.000000000 +0200
+++ openttd-1.11.0.serenity/src/network/core/os_abstraction.h 2021-04-19 19:30:33.457232215 +0200
@@ -59,13 +59,14 @@
# include <unistd.h>
# include <sys/ioctl.h>
# include <sys/socket.h>
+# include <sys/select.h>
# include <netinet/in.h>
# include <netinet/tcp.h>
# include <arpa/inet.h>
# include <net/if.h>
/* According to glibc/NEWS, <ifaddrs.h> appeared in glibc-2.3. */
# if !defined(__sgi__) && !defined(SUNOS) && !defined(__INNOTEK_LIBC__) \
- && !(defined(__GLIBC__) && (__GLIBC__ <= 2) && (__GLIBC_MINOR__ <= 2)) && !defined(__dietlibc__) && !defined(HPUX)
+ && !(defined(__GLIBC__) && (__GLIBC__ <= 2) && (__GLIBC_MINOR__ <= 2)) && !defined(__dietlibc__) && !defined(HPUX) && !defined(__serenity__)
/* If for any reason ifaddrs.h does not exist on your system, comment out
* the following two lines and an alternative way will be used to fetch
* the list of IPs from the system. */
diff -Naur openttd-1.11.0/src/os/unix/unix.cpp openttd-1.11.0.serenity/src/os/unix/unix.cpp
--- openttd-1.11.0/src/os/unix/unix.cpp 2021-04-01 14:33:44.000000000 +0200
+++ openttd-1.11.0.serenity/src/os/unix/unix.cpp 2021-04-19 19:30:33.457232215 +0200
@@ -42,9 +42,11 @@
# define HAS_SYSCTL
#endif
+#ifndef __serenity__
#ifdef HAS_STATVFS
#include <sys/statvfs.h>
#endif
+#endif
#ifdef HAS_SYSCTL
#include <sys/sysctl.h>
@@ -84,7 +86,7 @@
if (statfs(path, &s) != 0) return false;
free = (uint64)s.f_bsize * s.f_bavail;
-#elif defined(HAS_STATVFS)
+#elif defined(HAS_STATVFS) && !defined(__serenity__)
struct statvfs s;
if (statvfs(path, &s) != 0) return false;
diff -Naur openttd-1.11.0/src/stdafx.h openttd-1.11.0.serenity/src/stdafx.h
--- openttd-1.11.0/src/stdafx.h 2021-04-01 14:33:44.000000000 +0200
+++ openttd-1.11.0.serenity/src/stdafx.h 2021-04-19 20:08:30.758187723 +0200
@@ -28,7 +28,7 @@
# define TROUBLED_INTS
#endif
-#if defined(__HAIKU__) || defined(__CYGWIN__)
+#if defined(__HAIKU__) || defined(__CYGWIN__) || defined(__serenity__)
# include <strings.h> /* strncasecmp */
#endif
@@ -107,7 +107,7 @@
# define strcasecmp stricmp
#endif
-#if defined(SUNOS) || defined(HPUX) || defined(__CYGWIN__)
+#if defined(SUNOS) || defined(HPUX) || defined(__CYGWIN__) || defined(__serenity__)
# include <alloca.h>
#endif
@@ -307,7 +307,7 @@
typedef unsigned char byte;
/* This is already defined in unix, but not in QNX Neutrino (6.x) or Cygwin. */
-#if (!defined(UNIX) && !defined(__HAIKU__)) || defined(__QNXNTO__) || defined(__CYGWIN__)
+#if (!defined(UNIX) && !defined(__HAIKU__)) || defined(__QNXNTO__) || defined(__CYGWIN__) || defined(__serenity__)
typedef unsigned int uint;
#endif

View file

@ -0,0 +1,22 @@
diff -Naur openttd-1.11.0/src/spritecache.cpp openttd-1.11.0.serenity/src/spritecache.cpp
--- openttd-1.11.0/src/spritecache.cpp 2021-04-01 14:33:44.000000000 +0200
+++ openttd-1.11.0.serenity/src/spritecache.cpp 2021-04-18 21:03:15.916430052 +0200
@@ -915,6 +915,7 @@
/* Remember 'target_size' from the previous allocation attempt, so we do not try to reach the target_size multiple times in case of failure. */
static uint last_alloc_attempt = 0;
+#ifndef __serenity__
if (_spritecache_ptr == nullptr || (_allocated_sprite_cache_size != target_size && target_size != last_alloc_attempt)) {
delete[] reinterpret_cast<byte *>(_spritecache_ptr);
@@ -950,6 +951,10 @@
ScheduleErrorMessage(msg);
}
}
+#else
+ _allocated_sprite_cache_size = target_size / 5;
+ _spritecache_ptr = reinterpret_cast<MemBlock *>(new byte[_allocated_sprite_cache_size]);
+#endif
/* A big free block */
_spritecache_ptr->size = (_allocated_sprite_cache_size - sizeof(MemBlock)) | S_FREE_MASK;

View file

@ -0,0 +1,12 @@
diff -Naur openttd-1.11.0/src/cpu.cpp openttd-1.11.0.serenity/src/cpu.cpp
--- openttd-1.11.0/src/cpu.cpp 2021-04-22 01:14:21.038920133 +0200
+++ openttd-1.11.0.serenity/src/cpu.cpp 2021-04-22 01:13:56.638440518 +0200
@@ -40,7 +40,7 @@
#endif
/* rdtsc for all other *nix-en (hopefully). Use GCC syntax */
-#if (defined(__i386__) || defined(__x86_64__)) && !defined(RDTSC_AVAILABLE)
+#if (defined(__i386__) || defined(__x86_64__)) && !defined(__serenity__) && !defined(RDTSC_AVAILABLE)
uint64 ottd_rdtsc()
{
uint32 high, low;

View file

@ -0,0 +1,12 @@
diff -Naur openttd-1.11.0/src/os/unix/crashlog_unix.cpp openttd-1.11.0.serenity/src/os/unix/crashlog_unix.cpp
--- openttd-1.11.0/src/os/unix/crashlog_unix.cpp 2021-04-01 14:33:44.000000000 +0200
+++ openttd-1.11.0.serenity/src/os/unix/crashlog_unix.cpp 2021-04-18 21:40:06.426298674 +0200
@@ -178,7 +178,7 @@
/* static */ void CrashLog::InitialiseCrashLog()
{
for (const int *i = _signals_to_handle; i != endof(_signals_to_handle); i++) {
- signal(*i, HandleCrash);
+ //signal(*i, HandleCrash);
}
}