diff --git a/Ports/AvailablePorts.md b/Ports/AvailablePorts.md index c75f9a600b..efffc2daf9 100644 --- a/Ports/AvailablePorts.md +++ b/Ports/AvailablePorts.md @@ -277,6 +277,7 @@ This list is also available at [ports.serenityos.net](https://ports.serenityos.n | [`stpuzzles`](stpuzzles/) | Simon Tatham's Portable Puzzle Collection | | https://www.chiark.greenend.org.uk/~sgtatham/puzzles/ | | [`stress-ng`](stress-ng/) | stress-ng | 0.14.03 | https://github.com/ColinIanKing/stress-ng | | [`Super-Mario`](Super-Mario/) | Super-Mario Clone | | https://github.com/Bennyhwanggggg/Super-Mario-Clone-Cpp | +| [`SuperTuxKart`](SuperTuxKart/) | Super Tux Kart | 1.4 | https://supertuxkart.net/ | | [`tar`](tar/) | GNU tar | 1.34 | https://www.gnu.org/software/tar/ | | [`taskwarrior`](taskwarrior/) | TODO list manager | 2.6.2 | https://taskwarrior.org/ | | [`tcl`](tcl/) | Tcl | 8.6.12 | https://www.tcl-lang.org/ | diff --git a/Ports/SuperTuxKart/ReadMe.md b/Ports/SuperTuxKart/ReadMe.md new file mode 100644 index 0000000000..5cb6aae7e4 --- /dev/null +++ b/Ports/SuperTuxKart/ReadMe.md @@ -0,0 +1,6 @@ +# Non-obvious OOM on default VM settings + +If the game seems to initialize window fine, starts loading some of the +characters, but then crashes with a weird stack trace pointing somewhere to +LibGL, make sure that you have enough memory. This crash is verified not to +happen on 4GB of RAM. diff --git a/Ports/SuperTuxKart/package.sh b/Ports/SuperTuxKart/package.sh new file mode 100755 index 0000000000..b39e69610c --- /dev/null +++ b/Ports/SuperTuxKart/package.sh @@ -0,0 +1,56 @@ +#!/usr/bin/env -S bash ../.port_include.sh +port=SuperTuxKart +useconfigure='true' +version='1.4' +archive_hash='9890392419baf4715313f14d5ad60746f276eed36eb580636caf44e2532c0f03' +files="https://github.com/supertuxkart/stk-code/releases/download/${version}/supertuxkart-${version}-src.tar.xz ${port}-${version}-src.tar.xz $archive_hash" +auth_type='sha256' +workdir="${port}-${version}-src" +launcher_name='SuperTuxKart' +launcher_category='Games' +launcher_command='/usr/local/bin/supertuxkart' +depends=( + 'curl' + 'freetype' + 'glu' + 'harfbuzz' + 'libjpeg' + 'libopenal' + 'libogg' + 'libpng' + 'libvorbis' + 'openssl' + 'SDL2' + 'sqlite' + 'zlib' +) + +configopts=( + '-DCMAKE_BUILD_TYPE=STKRelease' + "-DCMAKE_INSTALL_PREFIX=${SERENITY_INSTALL_ROOT}/opt/SuperTuxKart" + "-DSTK_INSTALL_DATA_DIR=${SERENITY_INSTALL_ROOT}/opt/SuperTuxKart" + '-DSUPERTUXKART_DATADIR=/opt/SuperTuxKart' + "-DCMAKE_TOOLCHAIN_FILE=${SERENITY_BUILD_DIR}/CMakeToolchain.txt" + '-DBUILD_RECORDER=OFF' + '-DBUILD_SHARED_LIBS=OFF' + '-DUSE_WIIUSE=OFF' + '-DUSE_DNS_C=ON' + '-Bbuild' + '-GNinja' + "-DCMAKE_C_FLAGS=-I${SERENITY_INSTALL_ROOT}/usr/include/LibGL -I${SERENITY_INSTALL_ROOT}/usr/local/include/SDL2 -I${SERENITY_INSTALL_ROOT}/usr/local/include -lcurl -lharfbuzz -lfreetype" + "-DCMAKE_CXX_FLAGS=-I${SERENITY_INSTALL_ROOT}/usr/include/LibGL -I${SERENITY_INSTALL_ROOT}/usr/local/include/SDL2 -I${SERENITY_INSTALL_ROOT}/usr/local/include -lcurl -lharfbuzz -lfreetype" + '-DUSE_IPV6=OFF' + '-DUSE_SYSTEM_ENET=OFF' +) + +configure() { + run cmake "${configopts[@]}" . +} + +build() { + run ninja -C build +} + +install() { + run ninja -C build install +} diff --git a/Ports/SuperTuxKart/patches/0001-Add-build-system-support-for-Serenity.patch b/Ports/SuperTuxKart/patches/0001-Add-build-system-support-for-Serenity.patch new file mode 100644 index 0000000000..03a98b1f40 --- /dev/null +++ b/Ports/SuperTuxKart/patches/0001-Add-build-system-support-for-Serenity.patch @@ -0,0 +1,80 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Dominika Liberda +Date: Sun, 11 Jun 2023 01:56:50 +0200 +Subject: [PATCH] Add build system support for Serenity + +--- + lib/angelscript/source/as_memory.cpp | 2 +- + lib/irrlicht/include/IrrCompileConfig.h | 16 ++++++++++++---- + .../third_party/spirv-tools/CMakeLists.txt | 2 ++ + 3 files changed, 15 insertions(+), 5 deletions(-) + +diff --git a/lib/angelscript/source/as_memory.cpp b/lib/angelscript/source/as_memory.cpp +index 5914658ba23736da57506fc58066032b5f99e435..399a3842300ed01adaf0afdbf2ae794fd89c0415 100644 +--- a/lib/angelscript/source/as_memory.cpp ++++ b/lib/angelscript/source/as_memory.cpp +@@ -38,7 +38,7 @@ + + #include + +-#if !defined(__APPLE__) && !defined(__SNC__) && !defined(__ghs__) && !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__DragonFly__) ++#if !defined(__APPLE__) && !defined(__SNC__) && !defined(__ghs__) && !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__DragonFly__) && !defined(__serenity__) + #include + #endif + +diff --git a/lib/irrlicht/include/IrrCompileConfig.h b/lib/irrlicht/include/IrrCompileConfig.h +index 384c6836e2050ad8cfeaa4da3bf3365b5a3cf1a8..92a8d3dd4b6c82ee571ca2bf2d7858709de4f9d5 100644 +--- a/lib/irrlicht/include/IrrCompileConfig.h ++++ b/lib/irrlicht/include/IrrCompileConfig.h +@@ -23,6 +23,7 @@ + //! _IRR_WINDOWS_API_ for Windows or XBox + //! _IRR_LINUX_PLATFORM_ for Linux (it is defined here if no other os is defined) + //! _IRR_HAIKU_PLATFORM_ for Haiku ++//! _IRR_SERENITY_PLATFORM_ for SerenityOS + //! _IRR_SOLARIS_PLATFORM_ for Solaris + //! _IRR_OSX_PLATFORM_ for Apple systems running OSX + //! _IRR_IOS_PLATFORM_ for Apple devices running iOS +@@ -94,11 +95,15 @@ + #endif + #endif + +-#if defined(HAIKU) ++//#if defined(HAIKU) + #define _IRR_HAIKU_PLATFORM_ ++//#endif ++/* ++#if defined(__serenity__) ++#define _IRR_SERENITY_PLATFORM_ + #endif +- +-#if defined(_IRR_HAIKU_PLATFORM_) ++*/ ++#if defined(_IRR_HAIKU_PLATFORM_) || defined(_IRR_SERENITY_PLATFORM_) + #define _IRR_COMPILE_WITH_SDL_DEVICE_ + #define _IRR_COMPILE_WITH_OPENGL_ + #endif +@@ -113,7 +118,10 @@ + #define _IRR_COMPILE_WITH_OGLES2_ + #endif + +-#if !defined(_IRR_WINDOWS_API_) && !defined(_IRR_OSX_PLATFORM_) && !defined(_IRR_ANDROID_PLATFORM_) && !defined(_IRR_HAIKU_PLATFORM_) ++#define _IRR_POSIX_API_ ++ ++ ++#if !defined(_IRR_WINDOWS_API_) && !defined(_IRR_OSX_PLATFORM_) && !defined(_IRR_ANDROID_PLATFORM_) && !defined(_IRR_HAIKU_PLATFORM_) && !defined(_IRR_SERENITY_PLATFORM_) + #ifndef _IRR_SOLARIS_PLATFORM_ + #define _IRR_LINUX_PLATFORM_ + #endif +diff --git a/lib/shaderc/third_party/spirv-tools/CMakeLists.txt b/lib/shaderc/third_party/spirv-tools/CMakeLists.txt +index 2a06a9ca39a61f5f3b618dc3f5655889a9dd38f4..e471b0bacf1bb04dc4c545e8dad4db0f4209f930 100644 +--- a/lib/shaderc/third_party/spirv-tools/CMakeLists.txt ++++ b/lib/shaderc/third_party/spirv-tools/CMakeLists.txt +@@ -69,6 +69,8 @@ elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Haiku") + add_definitions(-DSPIRV_HAIKU) + elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "SunOS") + add_definitions(-DSPIRV_SOLARIS) ++elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "SerenityOS") ++ add_definitions(-DSPIRV_LINUX) + else() + message(FATAL_ERROR "Your platform '${CMAKE_SYSTEM_NAME}' is not supported!") + endif() diff --git a/Ports/SuperTuxKart/patches/0002-Fixup-Vulkan-SDL-platform-quirks.patch b/Ports/SuperTuxKart/patches/0002-Fixup-Vulkan-SDL-platform-quirks.patch new file mode 100644 index 0000000000..df809c4071 --- /dev/null +++ b/Ports/SuperTuxKart/patches/0002-Fixup-Vulkan-SDL-platform-quirks.patch @@ -0,0 +1,200 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Dominika Liberda +Date: Sun, 2 Jul 2023 05:49:46 +0200 +Subject: [PATCH] Fixup Vulkan/SDL platform quirks + +--- + lib/graphics_engine/include/ge_main.hpp | 1 + + lib/graphics_engine/include/vk_mem_alloc.h | 1 + + lib/graphics_engine/src/ge_main.cpp | 1 + + lib/graphics_engine/src/ge_spm_buffer.cpp | 1 + + lib/graphics_engine/src/ge_vulkan_command_loader.cpp | 1 + + lib/graphics_engine/src/ge_vulkan_depth_texture.cpp | 1 + + lib/graphics_engine/src/ge_vulkan_draw_call.cpp | 1 + + lib/graphics_engine/src/ge_vulkan_fbo_texture.cpp | 1 + + lib/graphics_engine/src/ge_vulkan_fbo_texture.hpp | 1 + + lib/graphics_engine/src/ge_vulkan_skybox_renderer.cpp | 1 + + lib/graphics_engine/src/ge_vulkan_texture.cpp | 1 + + lib/graphics_engine/src/ge_vulkan_texture_descriptor.cpp | 1 + + lib/irrlicht/source/Irrlicht/CIrrDeviceSDL.cpp | 4 ++-- + src/graphics/irr_driver.cpp | 2 +- + 14 files changed, 15 insertions(+), 3 deletions(-) + +diff --git a/lib/graphics_engine/include/ge_main.hpp b/lib/graphics_engine/include/ge_main.hpp +index 83ba0084f32a5593a96f8e8f2f6be7b7a8846dac..13ce04d0345bd56b66cc612071c0b152b37c0ca6 100644 +--- a/lib/graphics_engine/include/ge_main.hpp ++++ b/lib/graphics_engine/include/ge_main.hpp +@@ -7,6 +7,7 @@ + #include + #include + #include ++#include + + namespace irr + { +diff --git a/lib/graphics_engine/include/vk_mem_alloc.h b/lib/graphics_engine/include/vk_mem_alloc.h +index bdb4ff57610ce556dd144ea022347b93ed6d7351..71cde96f50b018f90214b9e1284146471417780a 100644 +--- a/lib/graphics_engine/include/vk_mem_alloc.h ++++ b/lib/graphics_engine/include/vk_mem_alloc.h +@@ -2562,6 +2562,7 @@ VMA_CALL_PRE void VMA_CALL_POST vmaFreeStatsString( + #ifdef VMA_IMPLEMENTATION + #undef VMA_IMPLEMENTATION + ++#include + #include + #include + #include +diff --git a/lib/graphics_engine/src/ge_main.cpp b/lib/graphics_engine/src/ge_main.cpp +index ea486dcd046aa196d3895c5a93fd35dc26517692..8813851a8c9a04e2af3188f07876d72f8628b719 100644 +--- a/lib/graphics_engine/src/ge_main.cpp ++++ b/lib/graphics_engine/src/ge_main.cpp +@@ -10,6 +10,7 @@ + + #include + #include ++#include + + namespace GE + { +diff --git a/lib/graphics_engine/src/ge_spm_buffer.cpp b/lib/graphics_engine/src/ge_spm_buffer.cpp +index 0dfa2829fa087c314f43ec76bfc1a41281c7e3ed..715af296c89cd7973b3fc71da70f655c3df48ade 100644 +--- a/lib/graphics_engine/src/ge_spm_buffer.cpp ++++ b/lib/graphics_engine/src/ge_spm_buffer.cpp +@@ -4,6 +4,7 @@ + #include "ge_vulkan_driver.hpp" + #include "ge_vulkan_features.hpp" + ++#include + #include + + namespace GE +diff --git a/lib/graphics_engine/src/ge_vulkan_command_loader.cpp b/lib/graphics_engine/src/ge_vulkan_command_loader.cpp +index 358cf9ab6ec65f0ce14874f1e02de38fa355d7aa..66db6ec3cd34191b986ef6a1b0a900b9a469e7d7 100644 +--- a/lib/graphics_engine/src/ge_vulkan_command_loader.cpp ++++ b/lib/graphics_engine/src/ge_vulkan_command_loader.cpp +@@ -9,6 +9,7 @@ + #include + #include + #include ++#include + + #include "../source/Irrlicht/os.h" + +diff --git a/lib/graphics_engine/src/ge_vulkan_depth_texture.cpp b/lib/graphics_engine/src/ge_vulkan_depth_texture.cpp +index 25cb242963891e68088be867f3b11c65fafa0865..9bb1bd1d4251850dc319bf8a0da7c7392ef6964b 100644 +--- a/lib/graphics_engine/src/ge_vulkan_depth_texture.cpp ++++ b/lib/graphics_engine/src/ge_vulkan_depth_texture.cpp +@@ -1,5 +1,6 @@ + #include "ge_vulkan_depth_texture.hpp" + ++#include + #include "ge_main.hpp" + #include "ge_vulkan_driver.hpp" + +diff --git a/lib/graphics_engine/src/ge_vulkan_draw_call.cpp b/lib/graphics_engine/src/ge_vulkan_draw_call.cpp +index ee8fd08fcb9b58daaf4e1c457d27c8487704c90f..03657953e01ac9221057d2b6f82c9b802bc8062d 100644 +--- a/lib/graphics_engine/src/ge_vulkan_draw_call.cpp ++++ b/lib/graphics_engine/src/ge_vulkan_draw_call.cpp +@@ -25,6 +25,7 @@ + #include + #include + #include ++#include + + #include "../source/Irrlicht/os.h" + #include "quaternion.h" +diff --git a/lib/graphics_engine/src/ge_vulkan_fbo_texture.cpp b/lib/graphics_engine/src/ge_vulkan_fbo_texture.cpp +index 9413a04bb00e0f19da1ab7ac104b8234b22f4bec..834a0b43b1e1a96bc1c7acb76910aa40d9aeee6c 100644 +--- a/lib/graphics_engine/src/ge_vulkan_fbo_texture.cpp ++++ b/lib/graphics_engine/src/ge_vulkan_fbo_texture.cpp +@@ -6,6 +6,7 @@ + + #include + #include ++#include + + namespace GE + { +diff --git a/lib/graphics_engine/src/ge_vulkan_fbo_texture.hpp b/lib/graphics_engine/src/ge_vulkan_fbo_texture.hpp +index ffc7fe9f831c9033c7951c3bdb3a788cec27513c..23d02a5b981e005a0ecbf66005844e7c478c97de 100644 +--- a/lib/graphics_engine/src/ge_vulkan_fbo_texture.hpp ++++ b/lib/graphics_engine/src/ge_vulkan_fbo_texture.hpp +@@ -2,6 +2,7 @@ + #define HEADER_GE_VULKAN_FBO_TEXTURE_HPP + + #include "ge_vulkan_texture.hpp" ++#include + + namespace GE + { +diff --git a/lib/graphics_engine/src/ge_vulkan_skybox_renderer.cpp b/lib/graphics_engine/src/ge_vulkan_skybox_renderer.cpp +index 2543b16086ff134f2cf0eb435bb2986547aa25cb..b34340d7659b3af754183b6968d9cef5b7565a16 100644 +--- a/lib/graphics_engine/src/ge_vulkan_skybox_renderer.cpp ++++ b/lib/graphics_engine/src/ge_vulkan_skybox_renderer.cpp +@@ -12,6 +12,7 @@ + #include + #include + #include ++#include + + namespace GE + { +diff --git a/lib/graphics_engine/src/ge_vulkan_texture.cpp b/lib/graphics_engine/src/ge_vulkan_texture.cpp +index 500eb65fc6204bda5b21eaef25c1c9de1404005e..9f7f155092c0762b1f2e40f9800a04c1e0b9b628 100644 +--- a/lib/graphics_engine/src/ge_vulkan_texture.cpp ++++ b/lib/graphics_engine/src/ge_vulkan_texture.cpp +@@ -9,6 +9,7 @@ + #include "ge_vulkan_command_loader.hpp" + #include "ge_vulkan_features.hpp" + #include "ge_vulkan_driver.hpp" ++#include + + extern "C" + { +diff --git a/lib/graphics_engine/src/ge_vulkan_texture_descriptor.cpp b/lib/graphics_engine/src/ge_vulkan_texture_descriptor.cpp +index 4fd8a2e8800e6620fb5980097fefefdab8150ab8..46b671ffdbe55e9be6f35eeb7d05857aa12880bc 100644 +--- a/lib/graphics_engine/src/ge_vulkan_texture_descriptor.cpp ++++ b/lib/graphics_engine/src/ge_vulkan_texture_descriptor.cpp +@@ -4,6 +4,7 @@ + #include "ge_vulkan_driver.hpp" + #include "ge_vulkan_texture.hpp" + ++#include + #include + #include + +diff --git a/lib/irrlicht/source/Irrlicht/CIrrDeviceSDL.cpp b/lib/irrlicht/source/Irrlicht/CIrrDeviceSDL.cpp +index 1dfef29db82f1f32bde84086d923dcea6e514329..e3344d61dbb9946803c28af3b759c23b5d902478 100644 +--- a/lib/irrlicht/source/Irrlicht/CIrrDeviceSDL.cpp ++++ b/lib/irrlicht/source/Irrlicht/CIrrDeviceSDL.cpp +@@ -128,7 +128,7 @@ CIrrDeviceSDL::CIrrDeviceSDL(const SIrrlichtCreationParameters& param) + SDL_VERSION(&Info.version); + + // Switch doesn't support GetWindowWMInfo +-#ifndef __SWITCH__ ++#if !defined(__SWITCH__) && !defined(__serenity__) + if (!SDL_GetWindowWMInfo(Window, &Info)) + return; + #endif +@@ -362,7 +362,7 @@ extern "C" void update_fullscreen_desktop(int val) + // Used in OptionsScreenVideo for live updating vertical sync config + extern "C" void update_swap_interval(int swap_interval) + { +-#ifndef IOS_STK ++#if !defined(IOS_STK) && !defined(__serenity__) + // iOS always use vertical sync + if (swap_interval > 1) + swap_interval = 1; +diff --git a/src/graphics/irr_driver.cpp b/src/graphics/irr_driver.cpp +index 763311a52293195bd59af4fc4807c6cf17b5705b..08bbf976a8ac63d7e703f32fa02b72f6789238c3 100644 +--- a/src/graphics/irr_driver.cpp ++++ b/src/graphics/irr_driver.cpp +@@ -186,7 +186,7 @@ IrrDriver::IrrDriver() + p.WindowSize = core::dimension2d(1280,720); + p.ForceLegacyDevice = UserConfigParams::m_force_legacy_device; + #else +- p.DriverType = video::EDT_NULL; ++ p.DriverType = video::EDT_OPENGL; + p.Bits = 16U; + p.WindowSize = core::dimension2d(640,480); + #endif diff --git a/Ports/SuperTuxKart/patches/0003-Remove-IPv6-support.patch b/Ports/SuperTuxKart/patches/0003-Remove-IPv6-support.patch new file mode 100644 index 0000000000..92d91b559c --- /dev/null +++ b/Ports/SuperTuxKart/patches/0003-Remove-IPv6-support.patch @@ -0,0 +1,904 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Dominika Liberda +Date: Sun, 2 Jul 2023 06:13:05 +0200 +Subject: [PATCH] Remove IPv6 support + +--- + CMakeLists.txt | 6 +- + lib/enet/unix.c | 5 +- + src/network/network_config.cpp | 24 +- + src/network/network_console.cpp | 1 + + src/network/protocols/connect_to_server.cpp | 22 +- + src/network/protocols/server_lobby.cpp | 17 +- + src/network/servers_manager.cpp | 8 +- + src/network/socket_address.cpp | 57 +-- + src/network/stk_host.cpp | 4 +- + src/network/stk_ipv6.cpp | 514 -------------------- + 10 files changed, 29 insertions(+), 629 deletions(-) + delete mode 100644 src/network/stk_ipv6.cpp + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 98dd5dcaef4547717f92440b269216b8994a29f0..a68f38ec32e7d240dae28998caf5511e936533ea 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -231,9 +231,9 @@ if((UNIX AND NOT APPLE) AND USE_SYSTEM_ENET AND NOT USE_IPV6) + pkg_check_modules(ENET libenet>=1.3.4) + endif() + +-if (USE_IPV6) +- add_definitions(-DENABLE_IPV6) +-endif() ++#if (USE_IPV6) ++# add_definitions(-DENABLE_IPV6) ++#endif() + + if(ENET_FOUND AND NOT USE_IPV6) + include_directories(${ENET_INCLUDE_DIRS}) +diff --git a/lib/enet/unix.c b/lib/enet/unix.c +index c10a3d99d998abac64b2c4dce17c45728cabaf12..1cadc204a9a167e02f9f8d445ec42f524a1fd815 100644 +--- a/lib/enet/unix.c ++++ b/lib/enet/unix.c +@@ -64,7 +64,10 @@ typedef int socklen_t; + static enet_uint32 timeBase = 0; + + // Global variable handled by STK +-extern int isIPv6Socket(void); ++//extern int isIPv6Socket(void); ++int isIPv6Socket(void) { ++ return 0; ++} + + int + enet_initialize (void) +diff --git a/src/network/network_config.cpp b/src/network/network_config.cpp +index 6d3f676cfb85de47403b944af43e76fa1f70d769..088bebd0a661170806d0d6cbf4f8a72ced612b4e 100644 +--- a/src/network/network_config.cpp ++++ b/src/network/network_config.cpp +@@ -103,31 +103,19 @@ void NetworkConfig::initSystemIP() + return; + } + ENetAddress eaddr = {}; +- setIPv6Socket(0); ++ //setIPv6Socket(0); + auto ipv4 = std::unique_ptr(new Network(1, 1, 0, 0, &eaddr)); +- setIPv6Socket(1); ++ //setIPv6Socket(1); + auto ipv6 = std::unique_ptr(new Network(1, 1, 0, 0, &eaddr)); +- setIPv6Socket(0); ++ //setIPv6Socket(0); + if (ipv4 && ipv4->getENetHost()) + m_system_ipv4 = true; +- if (ipv6 && ipv6->getENetHost()) +- m_system_ipv6 = true; ++ //if (ipv6 && ipv6->getENetHost()) ++ // m_system_ipv6 = true; + // If any 1 of them is missing set default network setting accordingly +- if (!m_system_ipv4) +- { +- Log::warn("NetworkConfig", "System doesn't support IPv4"); +- if (m_system_ipv6) +- { +- UserConfigParams::m_ipv6_lan = true; +- ServerConfig::m_ipv6_connection = true; +- } +- } +- else if (!m_system_ipv6) +- { +- Log::warn("NetworkConfig", "System doesn't support IPv6"); ++ + UserConfigParams::m_ipv6_lan = false; + ServerConfig::m_ipv6_connection = false; +- } + enet_deinitialize(); + } // initSystemIP + +diff --git a/src/network/network_console.cpp b/src/network/network_console.cpp +index 502ed5fcdffc27b167e14770a47254d7a5e18a20..2fe7e3282c6f48a61763c1e3a4b2b5a2d059fd92 100644 +--- a/src/network/network_console.cpp ++++ b/src/network/network_console.cpp +@@ -26,6 +26,7 @@ + #include "utils/time.hpp" + #include "utils/vs.hpp" + #include "main_loop.hpp" ++#include + + #include + #include +diff --git a/src/network/protocols/connect_to_server.cpp b/src/network/protocols/connect_to_server.cpp +index 598273c2a7094b2928828dfa2d10fbee678909b5..d3a4bc2952adc491f7e9393490db866f5b44d0b6 100644 +--- a/src/network/protocols/connect_to_server.cpp ++++ b/src/network/protocols/connect_to_server.cpp +@@ -115,13 +115,6 @@ void ConnectToServer::setup() + m_state = GOT_SERVER_ADDRESS; + // For graphical client server the IPv6 socket is handled by server + // process +- if (!STKHost::get()->isClientServer()) +- { +- if (m_server->useIPV6Connection()) +- setIPv6Socket(1); +- else +- setIPv6Socket(0); +- } + } + else + m_state = SET_PUBLIC_ADDRESS; +@@ -243,19 +236,6 @@ void ConnectToServer::asynchronousUpdate() + // the IPv4 address to NAT64 one in GOT_SERVER_ADDRESS + bool ipv6_socket = m_server->useIPV6Connection() || + NetworkConfig::get()->getIPType() == NetworkConfig::IP_V6_NAT64; +- if (STKHost::get()->getNetwork()->isIPv6Socket() != ipv6_socket) +- { +- // Free the bound socket first +- delete STKHost::get()->getNetwork(); +- setIPv6Socket(ipv6_socket ? 1 : 0); +- ENetAddress addr = {}; +- addr.port = NetworkConfig::get()->getClientPort(); +- auto new_network = new Network(/*peer_count*/1, +- /*channel_limit*/EVENT_CHANNEL_COUNT, +- /*max_in_bandwidth*/0, /*max_out_bandwidth*/0, &addr, +- true/*change_port_if_bound*/); +- STKHost::get()->replaceNetwork(new_network); +- } + + if (m_server->supportsEncryption()) + { +@@ -416,7 +396,7 @@ int ConnectToServer::interceptCallback(ENetHost* host, ENetEvent* event) + #if defined(ENABLE_IPV6) || defined(__SWITCH__) + if (enet_ip_not_equal(host->receivedAddress.host, m_server_address.host) || + #else +- if (host->receivedAddress.host != m_server_address.host || ++ if (host->receivedAddress.host.p0 != m_server_address.host.p0 || + #endif + host->receivedAddress.port != m_server_address.port) + { +diff --git a/src/network/protocols/server_lobby.cpp b/src/network/protocols/server_lobby.cpp +index 2f05fbacb4026054e1dd3f9b9ede35faa529c796..535094cf6aba847259501675ec8303e62faa3156 100644 +--- a/src/network/protocols/server_lobby.cpp ++++ b/src/network/protocols/server_lobby.cpp +@@ -120,7 +120,7 @@ static void upperIPv6SQL(sqlite3_context* context, int argc, + sqlite3_result_int64(context, 0); + return; + } +- sqlite3_result_int64(context, upperIPv6(ipv6)); ++ //sqlite3_result_int64(context, upperIPv6(ipv6)); + } + + // ---------------------------------------------------------------------------- +@@ -140,7 +140,7 @@ void insideIPv6CIDRSQL(sqlite3_context* context, int argc, + sqlite3_result_int(context, 0); + return; + } +- sqlite3_result_int(context, insideIPv6CIDR(ipv6_cidr, ipv6_in)); ++ //sqlite3_result_int(context, insideIPv6CIDR(ipv6_cidr, ipv6_in)); + } // insideIPv6CIDRSQL + + // ---------------------------------------------------------------------------- +@@ -307,10 +307,7 @@ void ServerLobby::initDatabase() + // Return zero to let caller return SQLITE_BUSY immediately + return 0; + }, NULL); +- sqlite3_create_function(m_db, "insideIPv6CIDR", 2, SQLITE_UTF8, NULL, +- &insideIPv6CIDRSQL, NULL, NULL); +- sqlite3_create_function(m_db, "upperIPv6", 1, SQLITE_UTF8, NULL, +- &upperIPv6SQL, NULL, NULL); ++ + checkTableExists(ServerConfig::m_ip_ban_table, m_ip_ban_table_exists); + checkTableExists(ServerConfig::m_ipv6_ban_table, m_ipv6_ban_table_exists); + checkTableExists(ServerConfig::m_online_id_ban_table, +@@ -1035,13 +1032,7 @@ void ServerLobby::pollDatabase() + continue; + + char* ipv6_cidr = data[0]; +- if (insideIPv6CIDR(ipv6_cidr, ipv6.c_str()) == 1) +- { +- Log::info("ServerLobby", +- "Kick %s, reason: %s, description: %s", +- ipv6.c_str(), data[1], data[2]); +- p->kick(); +- } ++ + } + return 0; + }, &peers, NULL); +diff --git a/src/network/servers_manager.cpp b/src/network/servers_manager.cpp +index 4187a319f7ae6535ef21b7dc9b1d6f3e546ef13d..8326ade484ad8d4e7cbf862884474ae6d105605f 100644 +--- a/src/network/servers_manager.cpp ++++ b/src/network/servers_manager.cpp +@@ -225,13 +225,11 @@ std::shared_ptr ServersManager::getLANRefreshRequest() const + return; + + ENetAddress addr = {}; +- setIPv6Socket(UserConfigParams::m_ipv6_lan ? 1 : 0); +- NetworkConfig::get()->setIPType(UserConfigParams::m_ipv6_lan ? +- NetworkConfig::IP_DUAL_STACK : NetworkConfig::IP_V4); ++ //setIPv6Socket(UserConfigParams::m_ipv6_lan ? 1 : 0); ++ NetworkConfig::get()->setIPType(NetworkConfig::IP_V4); + Network *broadcast = new Network(1, 1, 0, 0, &addr); + if (!broadcast->getENetHost()) + { +- setIPv6Socket(0); + m_success = true; + delete broadcast; + server_list->m_list_updated = true; +@@ -309,7 +307,7 @@ std::shared_ptr ServersManager::getLANRefreshRequest() const + //all_servers.[name] = servers_now.back(); + } // if received_data + } // while still waiting +- setIPv6Socket(0); ++ + delete broadcast; + m_success = true; + for (auto& i : servers_now) +diff --git a/src/network/socket_address.cpp b/src/network/socket_address.cpp +index affd7e81cabf71df4a3df6b9e99d8a3c188fbfd3..1fb7a6bebedc48d042f80481a11b24762088b106 100644 +--- a/src/network/socket_address.cpp ++++ b/src/network/socket_address.cpp +@@ -104,7 +104,7 @@ SocketAddress::SocketAddress(const ENetAddress& ea) + #ifdef __SWITCH__ + setIP(htonl(ea.host.p0)); + #else +- setIP(htonl(ea.host)); ++ setIP(htonl(ea.host.p0)); + #endif + setPort(ea.port); + #endif +@@ -190,7 +190,7 @@ void SocketAddress::init(const std::string& str, uint16_t port_number, + hints.ai_family = family; + hints.ai_socktype = SOCK_STREAM; + +- int status = getaddrinfo_compat(addr_str.c_str(), port_str.c_str(), &hints, ++ int status = getaddrinfo(addr_str.c_str(), port_str.c_str(), &hints, + &res); + if (status != 0) + { +@@ -235,15 +235,6 @@ void SocketAddress::init(const std::string& str, uint16_t port_number, + found = true; + break; + case AF_INET6: +- if (ipv4_mapped || +- !isIPv4MappedAddress((const struct sockaddr_in6*)addr->ai_addr)) +- { +- // OSX and iOS can return AF_INET6 with ::ffff:x.y.z.w for server +- // with A record, skip them and make it only get real AAAA record +- m_family = AF_INET6; +- memcpy(m_sockaddr.data(), addr->ai_addr, sizeof(sockaddr_in6)); +- found = true; +- } + break; + default: + break; +@@ -259,14 +250,7 @@ void SocketAddress::init(const std::string& str, uint16_t port_number, + * address too. */ + uint32_t SocketAddress::getIP() const + { +- if (m_family == AF_INET6) +- { +- sockaddr_in6* in6 = (sockaddr_in6*)m_sockaddr.data(); +- if (isIPv4MappedAddress(in6)) +- return ntohl(((in_addr*)(in6->sin6_addr.s6_addr + 12))->s_addr); +- return 0; +- } +- else if (m_family == AF_INET) ++ if (m_family == AF_INET) + { + sockaddr_in* in = (sockaddr_in*)m_sockaddr.data(); + return ntohl(in->sin_addr.s_addr); +@@ -369,11 +353,6 @@ bool SocketAddress::isPublicAddressLocalhost() const + memcpy(&addr, p->ifa_addr, sizeof(sockaddr_in6)); + sockaddr_in6* my_in6 = (sockaddr_in6*)m_sockaddr.data(); + addr.sin6_port = my_in6->sin6_port; +- if (sameIPV6(my_in6, &addr)) +- { +- is_local_host = true; +- break; +- } + } + } + freeifaddrs(addresses); +@@ -433,11 +412,6 @@ bool SocketAddress::isPublicAddressLocalhost() const + memcpy(&addr, unicast->Address.lpSockaddr, sizeof(sockaddr_in6)); + sockaddr_in6* my_in6 = (sockaddr_in6*)m_sockaddr.data(); + addr.sin6_port = my_in6->sin6_port; +- if (sameIPV6(my_in6, &addr)) +- { +- is_local_host = true; +- break; +- } + } + } + } +@@ -538,12 +512,7 @@ bool SocketAddress::operator==(const SocketAddress& other) const + return in_a->sin_addr.s_addr == in_b->sin_addr.s_addr && + in_a->sin_port == in_b->sin_port; + } +- else if (m_family == AF_INET6 && other.m_family == AF_INET6) +- { +- sockaddr_in6* in6_a = (sockaddr_in6*)m_sockaddr.data(); +- sockaddr_in6* in6_b = (sockaddr_in6*)(other.m_sockaddr.data()); +- return sameIPV6(in6_a, in6_b); +- } ++ + return false; + } // operator== + +@@ -558,12 +527,6 @@ bool SocketAddress::operator!=(const SocketAddress& other) const + return in_a->sin_addr.s_addr != in_b->sin_addr.s_addr || + in_a->sin_port != in_b->sin_port; + } +- else if (m_family == AF_INET6 && other.m_family == AF_INET6) +- { +- sockaddr_in6* in6_a = (sockaddr_in6*)m_sockaddr.data(); +- sockaddr_in6* in6_b = (sockaddr_in6*)(other.m_sockaddr.data()); +- return !sameIPV6(in6_a, in6_b); +- } + return true; + } // operator!= + +@@ -580,16 +543,6 @@ std::string SocketAddress::toString(bool show_port) const + if (show_port) + result += ":" + StringUtils::toString(getPort()); + } +- else +- { +- result = getIPV6ReadableFromIn6((sockaddr_in6*)m_sockaddr.data()); +- if (show_port) +- { +- result.insert (0, 1, '['); +- result += "]"; +- result += ":" + StringUtils::toString(getPort()); +- } +- } + return result; + } // toString + +@@ -769,7 +722,7 @@ ENetAddress SocketAddress::toENetAddress() const + ((ip & 0x000000ff) << 24); + } + #else +- ea.host = ((ip & 0xff000000) >> 24) + ++ ea.host.p0 = ((ip & 0xff000000) >> 24) + + ((ip & 0x00ff0000) >> 8) + ((ip & 0x0000ff00) << 8) + + ((ip & 0x000000ff) << 24); + #endif +diff --git a/src/network/stk_host.cpp b/src/network/stk_host.cpp +index 9cfec4adc3ec2240ecfce6b5a149363e82548d48..961e5ff79725cf66cd60ea42263427fa99b381d9 100644 +--- a/src/network/stk_host.cpp ++++ b/src/network/stk_host.cpp +@@ -265,7 +265,7 @@ STKHost::STKHost(bool server) + ENetAddress addr = {}; + if (server) + { +- setIPv6Socket(ServerConfig::m_ipv6_connection ? 1 : 0); ++ + #ifdef ENABLE_IPV6 + if (NetworkConfig::get()->getIPType() == NetworkConfig::IP_V4 && + ServerConfig::m_ipv6_connection) +@@ -1012,7 +1012,7 @@ void STKHost::mainLoop(ProcessType pt) + (enet_ip_not_equal(ea_peer_now.host, ea.host) && + ea_peer_now.port != ea.port)) + #else +- (ea_peer_now.host != ea.host && ea_peer_now.port != ea.port)) ++ (ea_peer_now.host.p0 != ea.host.p0 && ea_peer_now.port != ea.port)) + #endif + { + if (packet != NULL) +diff --git a/src/network/stk_ipv6.cpp b/src/network/stk_ipv6.cpp +deleted file mode 100644 +index a91c9178caad0dc4fb2291d9d86d717c9cc78024..0000000000000000000000000000000000000000 +--- a/src/network/stk_ipv6.cpp ++++ /dev/null +@@ -1,514 +0,0 @@ +-// SuperTuxKart - a fun racing game with go-kart +-// Copyright (C) 2019 SuperTuxKart-Team +-// +-// This program is free software; you can redistribute it and/or +-// modify it under the terms of the GNU General Public License +-// as published by the Free Software Foundation; either version 3 +-// of the License, or (at your option) any later version. +-// +-// This program is distributed in the hope that it will be useful, +-// but WITHOUT ANY WARRANTY; without even the implied warranty of +-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-// GNU General Public License for more details. +-// +-// You should have received a copy of the GNU General Public License +-// along with this program; if not, write to the Free Software +-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +- +-#include +-#ifdef WIN32 +-#ifdef __GNUC__ +-# include // Mingw / gcc on windows +-# undef _WIN32_WINNT +-# define _WIN32_WINNT 0x501 +-# include +-# include +- +-#else +-# include +-# include +-# include +-#endif +- +-#else +- +-#include +-#include +-#ifndef __SWITCH__ +-#include +-#endif +-#include +-#include +-#include +-#include +-#endif +- +-#include "network/network_config.hpp" +-#include +-#include +-#include +- +-// ============================================================================ +-// For Windows XP support +-#define IN6ADDRSZ 16 +-#define INADDRSZ 4 +-#define INT16SZ 2 +- +-static int +-stk_inet_pton4(const char *src, unsigned char *dst) +-{ +- static const char digits[] = "0123456789"; +- int saw_digit, octets, ch; +- unsigned char tmp[INADDRSZ], *tp; +- +- saw_digit = 0; +- octets = 0; +- tp = tmp; +- *tp = 0; +- while((ch = *src++) != '\0') +- { +- const char *pch; +- +- pch = strchr(digits, ch); +- if(pch) +- { +- unsigned int val = *tp * 10 + (unsigned int)(pch - digits); +- +- if(saw_digit && *tp == 0) +- return (0); +- if(val > 255) +- return (0); +- *tp = (unsigned char)val; +- if(! saw_digit) +- { +- if(++octets > 4) +- return (0); +- saw_digit = 1; +- } +- } +- else if(ch == '.' && saw_digit) +- { +- if(octets == 4) +- return (0); +- *++tp = 0; +- saw_digit = 0; +- } +- else +- return (0); +- } +- if(octets < 4) +- return (0); +- memcpy(dst, tmp, INADDRSZ); +- return (1); +-} +- +-static int +-stk_inet_pton6(const char *src, void *dest) +-{ +- unsigned char *dst = (unsigned char*)dest; +- static const char xdigits_l[] = "0123456789abcdef", +- xdigits_u[] = "0123456789ABCDEF"; +- unsigned char tmp[IN6ADDRSZ], *tp, *endp, *colonp; +- const char *curtok; +- int ch, saw_xdigit; +- size_t val; +- +- memset((tp = tmp), 0, IN6ADDRSZ); +- endp = tp + IN6ADDRSZ; +- colonp = NULL; +- /* Leading :: requires some special handling. */ +- if(*src == ':') +- { +- if(*++src != ':') +- return (0); +- } +- curtok = src; +- saw_xdigit = 0; +- val = 0; +- while((ch = *src++) != '\0') +- { +- const char *xdigits; +- const char *pch; +- +- pch = strchr((xdigits = xdigits_l), ch); +- if(!pch) +- pch = strchr((xdigits = xdigits_u), ch); +- if(pch != NULL) +- { +- val <<= 4; +- val |= (pch - xdigits); +- if(++saw_xdigit > 4) +- return (0); +- continue; +- } +- if(ch == ':') +- { +- curtok = src; +- if(!saw_xdigit) +- { +- if(colonp) +- return (0); +- colonp = tp; +- continue; +- } +- if(tp + INT16SZ > endp) +- return (0); +- *tp++ = (unsigned char) ((val >> 8) & 0xff); +- *tp++ = (unsigned char) (val & 0xff); +- saw_xdigit = 0; +- val = 0; +- continue; +- } +- if(ch == '.' && ((tp + INADDRSZ) <= endp) && +- stk_inet_pton4(curtok, tp) > 0) +- { +- tp += INADDRSZ; +- saw_xdigit = 0; +- break; /* '\0' was seen by stk_inet_pton4(). */ +- } +- return (0); +- } +- if(saw_xdigit) +- { +- if(tp + INT16SZ > endp) +- return (0); +- *tp++ = (unsigned char) ((val >> 8) & 0xff); +- *tp++ = (unsigned char) (val & 0xff); +- } +- if(colonp != NULL) +- { +- /* +- * Since some memmove()'s erroneously fail to handle +- * overlapping regions, we'll do the shift by hand. +- */ +- const ptrdiff_t n = tp - colonp; +- ptrdiff_t i; +- +- if(tp == endp) +- return (0); +- for(i = 1; i <= n; i++) +- { +- *(endp - i) = *(colonp + n - i); +- *(colonp + n - i) = 0; +- } +- tp = endp; +- } +- if(tp != endp) +- return (0); +- memcpy(dst, tmp, IN6ADDRSZ); +- return (1); +-} +- +-// ============================================================================ +-// Android STK seems to crash when using inet_ntop so we copy it from linux +-static const char * +-stk_inet_ntop4(const u_char *src, char *dst, socklen_t size) +-{ +- static const char fmt[] = "%u.%u.%u.%u"; +- char tmp[sizeof "255.255.255.255"]; +- +- if (sprintf(tmp, fmt, src[0], src[1], src[2], src[3]) >= (int)size) +- { +- return NULL; +- } +- return strcpy(dst, tmp); +-} +- +-static const char * +-stk_inet_ntop6(const uint8_t *src, char *dst, socklen_t size) +-{ +- /* +- * Note that int32_t and int16_t need only be "at least" large enough +- * to contain a value of the specified size. On some systems, like +- * Crays, there is no such thing as an integer variable with 16 bits. +- * Keep this in mind if you think this function should have been coded +- * to use pointer overlays. All the world's not a VAX. +- */ +- char tmp[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"], *tp; +- struct { int base, len; } best, cur; +- std::array words; +- int i; +- /* +- * Preprocess: +- * Copy the input (bytewise) array into a wordwise array. +- * Find the longest run of 0x00's in src[] for :: shorthanding. +- */ +- words.fill(0); +- for (i = 0; i < 16; i += 2) +- words[i / 2] = ((uint32_t)src[i] << 8) | src[i + 1]; +- // Test for nat64 prefix (remove the possible IPv4 in the last 32bit) +- std::array test_nat64 = words; +- test_nat64[6] = 0; +- test_nat64[7] = 0; +- +- best.base = -1; +- cur.base = -1; +- best.len = 0; +- cur.len = 0; +- for (i = 0; i < 8; i++) +- { +- if (words[i] == 0) +- { +- if (cur.base == -1) +- cur.base = i, cur.len = 1; +- else +- cur.len++; +- } +- else +- { +- if (cur.base != -1) +- { +- if (best.base == -1 || cur.len > best.len) +- best = cur; +- cur.base = -1; +- } +- } +- } +- if (cur.base != -1) +- { +- if (best.base == -1 || cur.len > best.len) +- best = cur; +- } +- if (best.base != -1 && best.len < 2) +- best.base = -1; +- /* +- * Format the result. +- */ +- tp = tmp; +- for (i = 0; i < 8; i++) +- { +- /* Are we inside the best run of 0x00's? */ +- if (best.base != -1 && i >= best.base && i < (best.base + best.len)) +- { +- if (i == best.base) +- *tp++ = ':'; +- continue; +- } +- /* Are we following an initial run of 0x00s or any real hex? */ +- if (i != 0) +- *tp++ = ':'; +- /* Is this address an encapsulated IPv4? */ +- if (i == 6 && +- ((best.base == 0 && +- (best.len == 6 || (best.len == 5 && words[5] == 0xffff))) || +- test_nat64 == NetworkConfig::get()->getNAT64PrefixData())) +- { +- if (!stk_inet_ntop4(src + 12, tp, sizeof tmp - (tp - tmp))) +- return (NULL); +- tp += strlen(tp); +- break; +- } +- tp += sprintf(tp, "%x", words[i]); +- } +- /* Was it a trailing run of 0x00's? */ +- if (best.base != -1 && (best.base + best.len) == 8) +- *tp++ = ':'; +- *tp++ = '\0'; +- /* +- * Check for overflow, copy, and we're done. +- */ +- if ((socklen_t)(tp - tmp) > size) +- { +- return NULL; +- } +- return strcpy(dst, tmp); +-} +- +-// ---------------------------------------------------------------------------- +-bool isIPv4MappedAddress(const struct sockaddr_in6* in6) +-{ +- uint8_t w0 = in6->sin6_addr.s6_addr[0]; +- uint8_t w1 = in6->sin6_addr.s6_addr[1]; +- uint8_t w2 = in6->sin6_addr.s6_addr[2]; +- uint8_t w3 = in6->sin6_addr.s6_addr[3]; +- uint8_t w4 = in6->sin6_addr.s6_addr[4]; +- uint8_t w5 = in6->sin6_addr.s6_addr[5]; +- uint8_t w6 = in6->sin6_addr.s6_addr[6]; +- uint8_t w7 = in6->sin6_addr.s6_addr[7]; +- uint8_t w8 = in6->sin6_addr.s6_addr[8]; +- uint8_t w9 = in6->sin6_addr.s6_addr[9]; +- uint8_t w10 = in6->sin6_addr.s6_addr[10]; +- uint8_t w11 = in6->sin6_addr.s6_addr[11]; +- if (w0 == 0 && w1 == 0 && w2 == 0 && w3 == 0 && w4 == 0 && +- w5 == 0 && w6 == 0 && w7 == 0 && w8 == 0 && w9 == 0 && +- w10 == 0xff && w11 == 0xff) +- return true; +- return false; +-} // isIPv4MappedAddress +- +-// ---------------------------------------------------------------------------- +-std::string getIPV6ReadableFromIn6(const struct sockaddr_in6* in) +-{ +- std::string ipv6; +- ipv6.resize(INET6_ADDRSTRLEN, 0); +- stk_inet_ntop6(in->sin6_addr.s6_addr, &ipv6[0], INET6_ADDRSTRLEN); +- size_t len = strlen(ipv6.c_str()); +- ipv6.resize(len); +- return ipv6; +-} // getIPV6ReadableFromIn6 +- +-// ---------------------------------------------------------------------------- +-bool sameIPV6(const struct sockaddr_in6* in_1, const struct sockaddr_in6* in_2) +-{ +- // Check port first, then address +- if (in_1->sin6_port != in_2->sin6_port) +- return false; +- +- const struct in6_addr* a = &(in_1->sin6_addr); +- const struct in6_addr* b = &(in_2->sin6_addr); +- for (unsigned i = 0; i < sizeof(struct in6_addr); i++) +- { +- if (a->s6_addr[i] != b->s6_addr[i]) +- return false; +- } +- return true; +-} // sameIPV6 +- +-// ---------------------------------------------------------------------------- +-/** Workaround of a bug in iOS 9 where port number is not written. */ +-extern "C" int getaddrinfo_compat(const char* hostname, +- const char* servname, +- const struct addrinfo* hints, +- struct addrinfo** res) +-{ +-#ifdef IOS_STK +- int err; +- int numericPort; +- +- // If we're given a service name and it's a numeric string, +- // set `numericPort` to that, otherwise it ends up as 0. +- numericPort = servname != NULL ? atoi(servname) : 0; +- +- // Call `getaddrinfo` with our input parameters. +- err = getaddrinfo(hostname, servname, hints, res); +- +- // Post-process the results of `getaddrinfo` to work around +- if ((err == 0) && (numericPort != 0)) +- { +- for (const struct addrinfo* addr = *res; addr != NULL; +- addr = addr->ai_next) +- { +- in_port_t* portPtr; +- switch (addr->ai_family) +- { +- case AF_INET: +- { +- portPtr = &((struct sockaddr_in*)addr->ai_addr)->sin_port; +- } +- break; +- case AF_INET6: +- { +- portPtr = &((struct sockaddr_in6*)addr->ai_addr)->sin6_port; +- } +- break; +- default: +- { +- portPtr = NULL; +- } +- break; +- } +- if ((portPtr != NULL) && (*portPtr == 0)) +- { +- *portPtr = htons(numericPort); +- } +- } +- } +- return err; +-#else +- return getaddrinfo(hostname, servname, hints, res); +-#endif +-} // getaddrinfo_compat +- +-// ---------------------------------------------------------------------------- +-void andIPv6(struct in6_addr* ipv6, const struct in6_addr* mask) +-{ +- for (unsigned i = 0; i < sizeof(struct in6_addr); i++) +- ipv6->s6_addr[i] &= mask->s6_addr[i]; +-} // andIPv6 +- +-// ---------------------------------------------------------------------------- +-extern "C" int64_t upperIPv6(const char* ipv6) +-{ +- struct in6_addr v6_in; +- if (stk_inet_pton6(ipv6, &v6_in) != 1) +- return 0; +- uint64_t result = 0; +- unsigned shift = 56; +- for (unsigned i = 0; i < 8; i++) +- { +- uint64_t val = v6_in.s6_addr[i]; +- result += val << shift; +- shift -= 8; +- } +- return result; +-} +- +-// ---------------------------------------------------------------------------- +-extern "C" int insideIPv6CIDR(const char* ipv6_cidr, const char* ipv6_in) +-{ +- const char* mask_location = strchr(ipv6_cidr, '/'); +- if (mask_location == NULL) +- return 0; +- struct in6_addr v6_in; +- if (stk_inet_pton6(ipv6_in, &v6_in) != 1) +- return 0; +- +- char ipv6[INET6_ADDRSTRLEN] = {}; +- memcpy(ipv6, ipv6_cidr, mask_location - ipv6_cidr); +- struct in6_addr cidr; +- if (stk_inet_pton6(ipv6, &cidr) != 1) +- return 0; +- +- int mask_length = atoi(mask_location + 1); +- if (mask_length > 128 || mask_length <= 0) +- return 0; +- +- struct in6_addr mask = {}; +- for (int i = mask_length, j = 0; i > 0; i -= 8, j++) +- { +- if (i >= 8) +- mask.s6_addr[j] = 0xff; +- else +- mask.s6_addr[j] = (unsigned long)(0xffU << (8 - i)); +- } +- +- andIPv6(&cidr, &mask); +- andIPv6(&v6_in, &mask); +- for (unsigned i = 0; i < sizeof(struct in6_addr); i++) +- { +- if (cidr.s6_addr[i] != v6_in.s6_addr[i]) +- return 0; +- } +- return 1; +-} // andIPv6 +- +-#ifndef ENABLE_IPV6 +-// ---------------------------------------------------------------------------- +-extern "C" int isIPv6Socket() +-{ +- return 0; +-} // isIPV6 +- +-// ---------------------------------------------------------------------------- +-extern "C" void setIPv6Socket(int val) +-{ +-} // setIPV6 +- +-#else +-#include +-// ============================================================================ +-// For client and server in same process using different thread +-std::atomic g_ipv6(0); +-// ============================================================================ +-extern "C" int isIPv6Socket() +-{ +- return g_ipv6.load(); +-} // isIPV6 +- +-// ---------------------------------------------------------------------------- +-extern "C" void setIPv6Socket(int val) +-{ +- g_ipv6.store(val); +-} // setIPV6 +- +-#endif diff --git a/Ports/SuperTuxKart/patches/0004-Correct-the-resource-install-path.patch b/Ports/SuperTuxKart/patches/0004-Correct-the-resource-install-path.patch new file mode 100644 index 0000000000..b60b780220 --- /dev/null +++ b/Ports/SuperTuxKart/patches/0004-Correct-the-resource-install-path.patch @@ -0,0 +1,22 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Dominika Liberda +Date: Sun, 2 Jul 2023 07:21:46 +0200 +Subject: [PATCH] Correct the resource install path + +--- + CMakeLists.txt | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index a68f38ec32e7d240dae28998caf5511e936533ea..38a93e7bf5bd388e9b08810cd2488ba8fefff711 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -593,7 +593,7 @@ else() + if(NOT STK_INSTALL_DATA_DIR_ABSOLUTE) + get_filename_component(STK_INSTALL_DATA_DIR_ABSOLUTE ${STK_INSTALL_DATA_DIR} ABSOLUTE) + if(${STK_INSTALL_DATA_DIR_ABSOLUTE} STREQUAL ${STK_INSTALL_DATA_DIR}) +- add_definitions(-DSUPERTUXKART_DATADIR=\"${STK_INSTALL_DATA_DIR_ABSOLUTE}\") ++ add_definitions(-DSUPERTUXKART_DATADIR=\"/opt/SuperTuxKart\") + else() + add_definitions(-DSUPERTUXKART_DATADIR=\"${CMAKE_INSTALL_PREFIX}/${STK_INSTALL_DATA_DIR}\") + endif() diff --git a/Ports/SuperTuxKart/patches/0005-Remove-reserved-word-from-goto-in-mcpp.patch b/Ports/SuperTuxKart/patches/0005-Remove-reserved-word-from-goto-in-mcpp.patch new file mode 100644 index 0000000000..c68811d30b --- /dev/null +++ b/Ports/SuperTuxKart/patches/0005-Remove-reserved-word-from-goto-in-mcpp.patch @@ -0,0 +1,49 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Dominika Liberda +Date: Sun, 2 Jul 2023 05:50:58 +0200 +Subject: [PATCH] Remove reserved word from goto in mcpp + +--- + lib/mcpp/system.c | 10 +++++----- + 1 file changed, 5 insertions(+), 5 deletions(-) + +diff --git a/lib/mcpp/system.c b/lib/mcpp/system.c +index a5b0d85c74203bd26365d99a874e5517aa78d2fb..1a61d240fec52c9cc96960566a03cca09084216c 100644 +--- a/lib/mcpp/system.c ++++ b/lib/mcpp/system.c +@@ -3435,7 +3435,7 @@ search: + if (! fullname) /* Non-existent or directory */ + return FALSE; + if (standard && included( fullname)) /* Once included */ +- goto true; ++ goto foo; + + if ((max_open != 0 && max_open <= include_nest) + /* Exceed the known limit of open files */ +@@ -3462,12 +3462,12 @@ search: + if ((fp = fopen( fullname, "r")) == NULL) { + file->fp = fopen( cur_fullname, "r"); + fseek( file->fp, file->pos, SEEK_SET); +- goto false; ++ goto bar; + } + if (max_open == 0) /* Remember the limit of the system */ + max_open = include_nest; + } else if (fp == NULL) /* No read permission */ +- goto false; ++ goto bar; + /* Truncate buffer of the includer to save memory */ + len = (int) (file->bptr - file->buffer); + if (len) { +@@ -3514,9 +3514,9 @@ search: + if (mkdep && ((mkdep & MD_SYSHEADER) || ! infile->sys_header)) + put_depend( fullname); /* Output dependency line */ + +-true: ++foo: + return TRUE; +-false: ++bar: + free( fullname); + return FALSE; + } diff --git a/Ports/SuperTuxKart/patches/ReadMe.md b/Ports/SuperTuxKart/patches/ReadMe.md new file mode 100644 index 0000000000..c2bd4ade15 --- /dev/null +++ b/Ports/SuperTuxKart/patches/ReadMe.md @@ -0,0 +1,27 @@ +# Patches for SuperTuxKart on SerenityOS + +## `0001-Add-build-system-support-for-Serenity.patch` + +Add build system support for Serenity + + +## `0002-Remove-reserved-word-from-goto-in-mcpp.patch` + +Remove reserved word from goto in mcpp + + +## `0003-Fixup-Vulkan-SDL-platform-quirks.patch` + +Fixup Vulkan/SDL platform quirks + + +## `0004-Remove-IPv6-support.patch` + +Remove IPv6 support + + +## `0005-Correct-the-resource-install-path.patch` + +Correct the resource install path + +