On Fri, Aug 04 2023, Thomas Frohwein wrote:

> On Sat, Jan 28, 2023 at 11:46:10AM +0200, Timo Myyrä wrote:
>> Thomas Frohwein <tfrohw...@fastmail.com> writes:
>> 
>> > Hi,
>> >
>> > This diff updates gzdoom to latest version 4.10.0. I've been trying out
>> > a few gzdoom games and ended up updating this port in the process, even
>> > though not strictly necessary to run the one I mainly tested - the demo
>> > of Beyond Sunset [1]. Hands of Necromancy also works.
>> >
>> > The diff drops 2 patches that are no longer needed. Adds a new one to
>> > bypass get_current_dir_name() in i_system.cpp.
>> >
>> > CC'ing maintainer
>> >
>> > [1] https://metacorp.itch.io/beyond-sunset
>
> [...]
>
>> Hi,
>> 
>> Great that someone has play-tested the update so it works.
>> The I_GetCWD should be patched correctly instead of bypassing the
>> logic. It seems to be used when adding WAD files from directory so this
>> version would break that functionality. The other function may be
>> patched as well but I recall that was only used for debugging so it is
>> not that important.
>> 
>> Timo
>
> A couple of months later, but I finally got around to figuring out the
> fix. This can also run the early access version of "Supplice" [1].
>
> The change in GH_ACCOUNT is because the previous repo now forwards to
> https://github.com/ZDoom/gzdoom anyway.
>
> ok?
>
> [1] https://store.steampowered.com/app/1693280/Supplice/
>
> Index: Makefile
> ===================================================================
> RCS file: /cvs/ports/games/gzdoom/Makefile,v
> retrieving revision 1.17
> diff -u -p -r1.17 Makefile
> --- Makefile  18 Jul 2022 08:27:45 -0000      1.17
> +++ Makefile  5 Aug 2023 02:58:11 -0000
> @@ -6,8 +6,8 @@ ONLY_FOR_ARCHS =      i386 amd64
>  
>  COMMENT =            OpenGL engine for idTech 1 games like 
> doom,hexen,heretic...
>  
> -V =                  4.8.2
> -GH_ACCOUNT =         coelckers
> +V =                  4.10.0
> +GH_ACCOUNT =         ZDoom
>  GH_PROJECT =         gzdoom
>  GH_TAGNAME =         g${V}
>  DISTNAME =           gzdoom-${V}
> Index: distinfo
> ===================================================================
> RCS file: /cvs/ports/games/gzdoom/distinfo,v
> retrieving revision 1.7
> diff -u -p -r1.7 distinfo
> --- distinfo  18 Jul 2022 08:27:45 -0000      1.7
> +++ distinfo  5 Aug 2023 02:58:11 -0000
> @@ -1,2 +1,2 @@
> -SHA256 (gzdoom-4.8.2.tar.gz) = Tt1g+AlMncPft0AL28DrsKXldLCmdH7uTI2fH2r3cSc=
> -SIZE (gzdoom-4.8.2.tar.gz) = 24247668
> +SHA256 (gzdoom-4.10.0.tar.gz) = hwJSLAUEjf1KdlxqyConDYvQlC6BPVvG9LaXlaXSOiA=
> +SIZE (gzdoom-4.10.0.tar.gz) = 24319337
> Index: patches/patch-libraries_discordrpc_CMakeLists_txt
> ===================================================================
> RCS file: patches/patch-libraries_discordrpc_CMakeLists_txt
> diff -N patches/patch-libraries_discordrpc_CMakeLists_txt
> --- patches/patch-libraries_discordrpc_CMakeLists_txt 31 Jul 2022 20:50:40 
> -0000      1.1
> +++ /dev/null 1 Jan 1970 00:00:00 -0000
> @@ -1,15 +0,0 @@
> -don't pick up clang-format is present
> -
> -Index: libraries/discordrpc/CMakeLists.txt
> ---- libraries/discordrpc/CMakeLists.txt.orig
> -+++ libraries/discordrpc/CMakeLists.txt
> -@@ -10,7 +10,8 @@ file(GLOB_RECURSE ALL_SOURCE_FILES
> - )
> - 
> - # Set CLANG_FORMAT_SUFFIX if you are using custom clang-format, e.g. 
> clang-format-5.0
> --find_program(CLANG_FORMAT_CMD clang-format${CLANG_FORMAT_SUFFIX})
> -+#find_program(CLANG_FORMAT_CMD clang-format${CLANG_FORMAT_SUFFIX})
> -+set(CLANG_FORMAT_CMD, FALSE)
> - 
> - if (CLANG_FORMAT_CMD)
> -     add_custom_target(
> Index: patches/patch-src_common_platform_posix_sdl_i_system_cpp
> ===================================================================
> RCS file: patches/patch-src_common_platform_posix_sdl_i_system_cpp
> diff -N patches/patch-src_common_platform_posix_sdl_i_system_cpp
> --- /dev/null 1 Jan 1970 00:00:00 -0000
> +++ patches/patch-src_common_platform_posix_sdl_i_system_cpp  5 Aug 2023 
> 02:58:11 -0000
> @@ -0,0 +1,42 @@
> +use getcwd(3) instead of non-portable get_current_dir_name()
> +
> +Index: src/common/platform/posix/sdl/i_system.cpp
> +--- src/common/platform/posix/sdl/i_system.cpp.orig
> ++++ src/common/platform/posix/sdl/i_system.cpp
> +@@ -52,6 +52,8 @@
> + #include <linux/perf_event.h>
> + #include <sys/mman.h>
> + #include "printf.h"
> ++#elif defined(__OpenBSD__)
> ++#include "printf.h"
> + #endif
> + 
> + #include <SDL.h>
> +@@ -408,11 +410,10 @@ FString I_GetFromClipboard (bool use_primary_selection
> + 
> + FString I_GetCWD()
> + {
> +-    char* curdir = get_current_dir_name();
> +-    if (!curdir) 
> +-    {
> +-            return "";
> +-    }
> ++    char curdir[PATH_MAX];
> ++
> ++    if (getcwd(curdir, sizeof(curdir)) == nullptr)
> ++            return "";
> +     FString ret(curdir);
> +     free(curdir);
> +     return ret;
> +@@ -447,7 +448,10 @@ unsigned int I_MakeRNGSeed()
> + 
> + void I_OpenShellFolder(const char* infolder)
> + {
> +-    char* curdir = get_current_dir_name();
> ++    char curdir[PATH_MAX];
> ++
> ++    if (getcwd(curdir, sizeof(curdir)) == nullptr)
> ++            Printf("Unable to get current working directory\n");
> + 
> +     if (!chdir(infolder))
> +     {
> Index: patches/patch-src_d_main_cpp
> ===================================================================
> RCS file: patches/patch-src_d_main_cpp
> diff -N patches/patch-src_d_main_cpp
> --- patches/patch-src_d_main_cpp      18 Jul 2022 08:27:46 -0000      1.1
> +++ /dev/null 1 Jan 1970 00:00:00 -0000
> @@ -1,24 +0,0 @@
> -fix gzdoom.pk3 not found error, backport of
> -https://github.com/coelckers/gzdoom/pull/1665
> -
> -Index: src/d_main.cpp
> ---- src/d_main.cpp.orig
> -+++ src/d_main.cpp
> -@@ -3534,6 +3534,8 @@ static int D_DoomMain_Internal (void)
> -     
> -     std::set_new_handler(NewFailure);
> -     const char *batchout = Args->CheckValue("-errorlog");
> -+
> -+    D_DoomInit();
> -     
> -     // [RH] Make sure zdoom.pk3 is always loaded,
> -     // as it contains magic stuff we need.
> -@@ -3567,8 +3569,6 @@ static int D_DoomMain_Internal (void)
> -     }
> - 
> -     if (!batchrun) Printf(PRINT_LOG, "%s version %s\n", GAMENAME, 
> GetVersionString());
> --
> --    D_DoomInit();
> - 
> -     extern void D_ConfirmSendStats();
> -     D_ConfirmSendStats();

Thanks for the diff.
Does this run for you? I get following:
[tmy@asteroid gzdoom]$ gzdoom  
GZDoom <unknown version> -  - SDL version
Compiled on Aug  6 2023

OS: OpenBSD 7.3 on amd64
GZDoom version <unknown version>
Please select a game wad (or 0 to exit):
1. Freedoom: Phase 1 (freedoom1)
2. Freedoom: Phase 2 (freedoom2)
Which one? 2
gzdoom(41929) in free(): bogus pointer (double free?) 0x79cea25bfad0
Abort trap (core dumped) 
[tmy@asteroid gzdoom]$ sysctl vm.malloc_conf   
vm.malloc_conf=CF

Timo

Reply via email to