From f578247cdf90036a74ec00732f0b14f35520f11c Mon Sep 17 00:00:00 2001 From: Grigoris Pavlakis Date: Sat, 28 May 2022 18:25:25 +0300 Subject: [PATCH] Ports: Fix tuxracer port to use sdl12-compat instead of SDL2 --- Ports/tuxracer/package.sh | 15 +- .../0001-Explicitly-link-in-SDL2.patch | 44 -- ...01-Fix-config-macro-reference-syntax.patch | 69 +++ ...-bag-of-random-changes-to-the-source.patch | 396 ------------------ .../patches/0002-Disable-full-screen.patch | 25 ++ ...03-Exit-event-loop-on-SDL_QUIT-event.patch | 27 ++ Ports/tuxracer/patches/ReadMe.md | 14 +- 7 files changed, 131 insertions(+), 459 deletions(-) delete mode 100644 Ports/tuxracer/patches/0001-Explicitly-link-in-SDL2.patch create mode 100644 Ports/tuxracer/patches/0001-Fix-config-macro-reference-syntax.patch delete mode 100644 Ports/tuxracer/patches/0002-Big-bag-of-random-changes-to-the-source.patch create mode 100644 Ports/tuxracer/patches/0002-Disable-full-screen.patch create mode 100644 Ports/tuxracer/patches/0003-Exit-event-loop-on-SDL_QUIT-event.patch diff --git a/Ports/tuxracer/package.sh b/Ports/tuxracer/package.sh index c319ddd9e8a..154c6f13d65 100755 --- a/Ports/tuxracer/package.sh +++ b/Ports/tuxracer/package.sh @@ -5,7 +5,7 @@ version="0.61" files="http://ftp.e.kth.se/pub/mpkg/distfiles/tuxracer/${version}/tuxracer-${version}.tar.gz tuxracer-${version}.tar.gz a311d09080598fe556134d4b9faed7dc0c2ed956ebb10d062e5d4df022f91eff http://ftp.e.kth.se/pub/mpkg/distfiles/tuxracer/${version}/tuxracer-data-${version}.tar.gz tuxracer-data-${version}.tar.gz 3783d204b7bb1ed16aa5e5a1d5944de10fbee05bc7cebb8f616fce84301f3651" auth_type=sha256 -depends=("glu" "SDL2" "SDL2_mixer" "tcl") +depends=("glu" "SDL_mixer" "sdl12-compat" "tcl") configopts=( "--with-gl-inc=${SERENITY_INSTALL_ROOT}/usr/include/LibGL" "--with-gl-lib-name=gl" @@ -17,17 +17,8 @@ launcher_name="Tux Racer" launcher_category="Games" launcher_command="/usr/local/bin/tuxracer" -pre_configure() { - export CFLAGS="-I${SERENITY_INSTALL_ROOT}/usr/local/include/SDL2" - export CXXFLAGS="-I${SERENITY_INSTALL_ROOT}/usr/local/include/SDL2" - export LIBS="-lSDL2" -} - -post_configure() { - unset LIBS - unset CXXFLAGS - unset CFLAGS -} +# isnan() is a macro -> not linkable +export ac_cv_func_isnan=yes post_install() { resourcePath="${SERENITY_INSTALL_ROOT}/usr/local/share/tuxracer" diff --git a/Ports/tuxracer/patches/0001-Explicitly-link-in-SDL2.patch b/Ports/tuxracer/patches/0001-Explicitly-link-in-SDL2.patch deleted file mode 100644 index bf01fd58631..00000000000 --- a/Ports/tuxracer/patches/0001-Explicitly-link-in-SDL2.patch +++ /dev/null @@ -1,44 +0,0 @@ -From b00365ebd72508d88bc31da63b56230ed23a5c1d Mon Sep 17 00:00:00 2001 -From: Jelle Raaijmakers -Date: Fri, 24 Dec 2021 15:24:16 +0100 -Subject: [PATCH 1/2] Explicitly link in SDL2 - -Also pretend that isnan() works correctly. ---- - configure | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -diff --git a/configure b/configure -index 20d409b..e4de165 100755 ---- a/configure -+++ b/configure -@@ -1674,7 +1674,7 @@ $ac_func(); - - ; return 0; } - EOF --if { (eval echo configure:1678: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then -+if [ "$ac_func" = "isnan" ]; then - rm -rf conftest* - eval "ac_cv_func_$ac_func=yes" - else -@@ -3417,7 +3417,7 @@ if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 - else - ac_save_LIBS="$LIBS" --LIBS="-lSDL_mixer $LIBS" -+LIBS="-lSDL2_mixer $LIBS" - cat > conftest.$ac_ext < +Date: Fri, 24 Dec 2021 15:24:16 +0100 +Subject: [PATCH 1/3] Fix config macro reference syntax + +--- + src/game_config.c | 24 ++++++++++++------------ + 1 file changed, 12 insertions(+), 12 deletions(-) + +diff --git a/src/game_config.c b/src/game_config.c +index f12bb2d..6d1e979 100644 +--- a/src/game_config.c ++++ b/src/game_config.c +@@ -114,26 +114,26 @@ struct param { + */ + + #define INIT_PARAM( nam, val, typename, commnt ) \ +- Params. ## nam ## .loaded = False; \ +- Params. ## nam ## .name = #nam; \ +- Params. ## nam ## .deflt. ## typename ## _val = val; \ +- Params. ## nam ## .comment = commnt; ++ Params.nam.loaded = False; \ ++ Params.nam.name = #nam; \ ++ Params.nam.deflt.typename ## _val = val; \ ++ Params.nam.comment = commnt; + + #define INIT_PARAM_STRING( nam, val, commnt ) \ + INIT_PARAM( nam, val, string, commnt ); \ +- Params. ## nam ## .type = PARAM_STRING; ++ Params.nam.type = PARAM_STRING; + + #define INIT_PARAM_CHAR( nam, val, commnt ) \ + INIT_PARAM( nam, val, char, commnt ); \ +- Params. ## nam ## .type = PARAM_CHAR; ++ Params.nam.type = PARAM_CHAR; + + #define INIT_PARAM_INT( nam, val, commnt ) \ + INIT_PARAM( nam, val, int, commnt ); \ +- Params. ## nam ## .type = PARAM_INT; ++ Params.nam.type = PARAM_INT; + + #define INIT_PARAM_BOOL( nam, val, commnt ) \ + INIT_PARAM( nam, val, bool, commnt ); \ +- Params. ## nam ## .type = PARAM_BOOL; ++ Params.nam.type = PARAM_BOOL; + + + /* +@@ -310,13 +310,13 @@ void set_param_bool( struct param *p, bool_t new_val ) + */ + #define FN_PARAM( name, typename, type ) \ + type getparam_ ## name() { \ +- if ( !Params. ## name ## .loaded ) { \ +- fetch_param_ ## typename( &( Params. ## name ) ); \ ++ if ( !Params.name.loaded ) { \ ++ fetch_param_ ## typename( &( Params.name ) ); \ + } \ +- return Params. ## name ## .val. ## typename ## _val; \ ++ return Params.name.val.typename ## _val; \ + } \ + void setparam_ ## name( type val) { \ +- set_param_ ## typename( &( Params. ## name ), val ); } ++ set_param_ ## typename( &( Params.name ), val ); } + + #define FN_PARAM_STRING( name ) \ + FN_PARAM( name, string, char* ) +-- +2.36.1 + diff --git a/Ports/tuxracer/patches/0002-Big-bag-of-random-changes-to-the-source.patch b/Ports/tuxracer/patches/0002-Big-bag-of-random-changes-to-the-source.patch deleted file mode 100644 index 4055e6dc21b..00000000000 --- a/Ports/tuxracer/patches/0002-Big-bag-of-random-changes-to-the-source.patch +++ /dev/null @@ -1,396 +0,0 @@ -From 04c10bd91f64e3cbbcd827fc439ef8018473bcc9 Mon Sep 17 00:00:00 2001 -From: Jelle Raaijmakers -Date: Tue, 28 Dec 2021 00:15:59 +0100 -Subject: [PATCH 2/2] Big bag of random changes to the source - -FIXME: Split this up sensibly ---- - src/game_config.c | 26 +++++++++---------- - src/keyboard.c | 66 ++++++++++++++++++++++++++--------------------- - src/winsys.c | 45 +++++++++++++++----------------- - src/winsys.h | 28 ++++++++++---------- - 4 files changed, 85 insertions(+), 80 deletions(-) - -diff --git a/src/game_config.c b/src/game_config.c -index f12bb2d..35b6036 100644 ---- a/src/game_config.c -+++ b/src/game_config.c -@@ -114,26 +114,26 @@ struct param { - */ - - #define INIT_PARAM( nam, val, typename, commnt ) \ -- Params. ## nam ## .loaded = False; \ -- Params. ## nam ## .name = #nam; \ -- Params. ## nam ## .deflt. ## typename ## _val = val; \ -- Params. ## nam ## .comment = commnt; -+ Params.nam.loaded = False; \ -+ Params.nam.name = #nam; \ -+ Params.nam.deflt.typename ## _val = val; \ -+ Params.nam.comment = commnt; - - #define INIT_PARAM_STRING( nam, val, commnt ) \ - INIT_PARAM( nam, val, string, commnt ); \ -- Params. ## nam ## .type = PARAM_STRING; -+ Params.nam.type = PARAM_STRING; - - #define INIT_PARAM_CHAR( nam, val, commnt ) \ - INIT_PARAM( nam, val, char, commnt ); \ -- Params. ## nam ## .type = PARAM_CHAR; -+ Params.nam.type = PARAM_CHAR; - - #define INIT_PARAM_INT( nam, val, commnt ) \ - INIT_PARAM( nam, val, int, commnt ); \ -- Params. ## nam ## .type = PARAM_INT; -+ Params.nam.type = PARAM_INT; - - #define INIT_PARAM_BOOL( nam, val, commnt ) \ - INIT_PARAM( nam, val, bool, commnt ); \ -- Params. ## nam ## .type = PARAM_BOOL; -+ Params.nam.type = PARAM_BOOL; - - - /* -@@ -310,13 +310,13 @@ void set_param_bool( struct param *p, bool_t new_val ) - */ - #define FN_PARAM( name, typename, type ) \ - type getparam_ ## name() { \ -- if ( !Params. ## name ## .loaded ) { \ -- fetch_param_ ## typename( &( Params. ## name ) ); \ -+ if ( !Params.name.loaded ) { \ -+ fetch_param_ ## typename( &( Params.name ) ); \ - } \ -- return Params. ## name ## .val. ## typename ## _val; \ -+ return Params.name.val.typename ## _val; \ - } \ - void setparam_ ## name( type val) { \ -- set_param_ ## typename( &( Params. ## name ), val ); } -+ set_param_ ## typename( &( Params.name ), val ); } - - #define FN_PARAM_STRING( name ) \ - FN_PARAM( name, string, char* ) -@@ -505,7 +505,7 @@ void init_game_configuration() - "# decreasing this number, at the cost of lower image quality." ); - - INIT_PARAM_BOOL( -- fullscreen, True, -+ fullscreen, False, - "# If true then the game will run in full-screen mode." ); - - INIT_PARAM_INT( -diff --git a/src/keyboard.c b/src/keyboard.c -index d2b01ed..b0d38f5 100644 ---- a/src/keyboard.c -+++ b/src/keyboard.c -@@ -23,11 +23,17 @@ - #include "loop.h" - - #define KEYMAP_SIZE 1000 --#define KEYTABLE_SIZE WSK_LAST --#define SPECIAL_KEYTABLE_SIZE WSK_LAST -+#define KEYTABLE_SIZE 100 - --static key_cb_t keytable[KEYTABLE_SIZE]; --static key_cb_t special_keytable[SPECIAL_KEYTABLE_SIZE]; -+static key_cb_t keytable_callback[KEYTABLE_SIZE]; -+static int keytable_key[KEYTABLE_SIZE]; -+static int num_keytable_entries = 0; -+ -+static key_cb_t special_keytable_callback[KEYTABLE_SIZE]; -+static int special_keytable_key[KEYTABLE_SIZE]; -+static int num_special_keytable_entries = 0; -+ -+static key_cb_t default_keytable_callback = NULL; - - static keymap_t keymap[KEYMAP_SIZE]; - static int num_keymap_entries = 0; -@@ -50,19 +56,6 @@ int add_keymap_entry( game_mode_t mode, keymap_class_t keymap_class, - return 0; /* success */ - } - --static void fill_keytable( key_cb_t value ) --{ -- int i; -- -- for (i=0; i 0 ) { - for ( i=0; i +Date: Fri, 24 Dec 2021 15:24:16 +0100 +Subject: [PATCH 2/3] Disable full screen + +--- + src/game_config.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/game_config.c b/src/game_config.c +index 6d1e979..f4c1c0c 100644 +--- a/src/game_config.c ++++ b/src/game_config.c +@@ -505,7 +505,7 @@ void init_game_configuration() + "# decreasing this number, at the cost of lower image quality." ); + + INIT_PARAM_BOOL( +- fullscreen, True, ++ fullscreen, False, + "# If true then the game will run in full-screen mode." ); + + INIT_PARAM_INT( +-- +2.36.1 + diff --git a/Ports/tuxracer/patches/0003-Exit-event-loop-on-SDL_QUIT-event.patch b/Ports/tuxracer/patches/0003-Exit-event-loop-on-SDL_QUIT-event.patch new file mode 100644 index 00000000000..a5e28298750 --- /dev/null +++ b/Ports/tuxracer/patches/0003-Exit-event-loop-on-SDL_QUIT-event.patch @@ -0,0 +1,27 @@ +From 99e0390e8974a0f0438fb95665edc910ef176883 Mon Sep 17 00:00:00 2001 +From: Grigoris Pavlakis +Date: Mon, 30 May 2022 01:54:22 +0300 +Subject: [PATCH 3/3] Exit event loop on SDL_QUIT event + +--- + src/winsys.c | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/src/winsys.c b/src/winsys.c +index d932a1d..95eeefa 100644 +--- a/src/winsys.c ++++ b/src/winsys.c +@@ -392,6 +392,10 @@ void winsys_process_events() + } + + break; ++ ++ case SDL_QUIT: ++ winsys_exit( 0 ); ++ break; + } + + SDL_LockAudio(); +-- +2.36.1 + diff --git a/Ports/tuxracer/patches/ReadMe.md b/Ports/tuxracer/patches/ReadMe.md index 86be4634d2f..254c3c2b96a 100644 --- a/Ports/tuxracer/patches/ReadMe.md +++ b/Ports/tuxracer/patches/ReadMe.md @@ -1,14 +1,14 @@ # Patches for tuxracer on SerenityOS -## `0001-Explicitly-link-in-SDL2.patch` +## `0001-Fix-config-macro-reference-syntax.patch` -Explicitly link in SDL2 +Fix macro definitions using old syntax for referring to struct fields -Also pretend that isnan() works correctly. +## `0002-Disable-full-screen.patch` -## `0002-Big-bag-of-random-changes-to-the-source.patch` +Disable full screen by default (start in windowed mode) -Big bag of random changes to the source - -FIXME: Split this up sensibly +## `0003-Exit-event-loop-on-SDL_QUIT-event.patch` +Check for SDL_QUIT event and exit on its reception +Allows the game to close from the window button instead from the menu only