git: 973414029d34 - main - games/devilutionX: update to 1.4

From: Dmitry Marakasov <amdmi3_at_FreeBSD.org>
Date: Wed, 18 May 2022 18:56:47 UTC
The branch main has been updated by amdmi3:

URL: https://cgit.FreeBSD.org/ports/commit/?id=973414029d3442683b314739d3b4df5153b04394

commit 973414029d3442683b314739d3b4df5153b04394
Author:     Dmitry Marakasov <amdmi3@FreeBSD.org>
AuthorDate: 2022-05-17 14:43:57 +0000
Commit:     Dmitry Marakasov <amdmi3@FreeBSD.org>
CommitDate: 2022-05-18 18:54:10 +0000

    games/devilutionX: update to 1.4
    
    - Update to 1.4
    - Drop dependency on font, no longer needed
    - Drop unnecessary .desktop file patches (also upstream PR exists)
    - Install from the port (instead of patching CMakeLists.txt), to be
      more explicit and flexible
    - Convert to pkg-plist as there are more files now
    - The new version tries to fetch dependencies from the net, for some
      depenencies this is unconditional. Fetch these properly with
      GH_TUPLE and place in a directory where CMake expectes them.
    - Upstream code expects patch component in the version, so add an extra
      .0 to VERSION_NUM. This should not break on (future) X.Y.Z versions
      as the component will move to micropatch position and will be ignored
    - BINARY_RELEASE option is gone
    - Untie DEBUG (engine debug bode) from WITH_DEBUG knob (build debug
      binary), these are orthogonal
    - Properly support optional depends; zerotier is the only one
      broken as it conflicts with system header (see
      https://github.com/diasurgical/devilutionX/issues/4585)
    - Install devilutionx (own) data file
      - Since it's not versioned, use a little hack to add a tag to the
        filename to avoid clashes on the future updates; this seemed less
        evil than introducing DIST_SUBDIR
      - Use two-level datadir to be consistent with ~/.local/share path
    - Update pkg-message (Diablo data file doesn't have to be lowercase,
      works either way)
    
    PR:             264064
    Approved by:    eduardo@FreeBSD.org (maintainer)
---
 games/devilutionX/Makefile                         | 101 ++++++++++++++++-----
 games/devilutionX/distinfo                         |  26 +++++-
 games/devilutionX/files/patch-CMakeLists.txt       |  20 ++--
 .../patch-Packaging_fedora_devilutionx.desktop     |  17 ----
 .../files/patch-Source_engine_random.cpp           |  14 +++
 games/devilutionX/files/patch-Source_init.cpp      |  11 +++
 games/devilutionX/files/patch-Source_sound.h       |  14 +++
 games/devilutionX/pkg-message                      |   3 +-
 games/devilutionX/pkg-plist                        |   6 ++
 9 files changed, 156 insertions(+), 56 deletions(-)

diff --git a/games/devilutionX/Makefile b/games/devilutionX/Makefile
index 1723b6e09fba..bc4eb3b34e38 100644
--- a/games/devilutionX/Makefile
+++ b/games/devilutionX/Makefile
@@ -1,39 +1,96 @@
 PORTNAME=	devilutionX
-DISTVERSION=	1.2.1
-PORTREVISION=	1
+DISTVERSION=	1.4
 CATEGORIES=	games
+MASTER_SITES=	https://github.com/diasurgical/devilutionx-assets/releases/download/${DATA_VERSION}/:data
+DISTFILES=	devilutionx.mpq?tag=${DATA_VERSION}:data
+EXTRACT_ONLY=	${DISTFILES:N*\:data:C/:.*//}
 
 MAINTAINER=	eduardo@FreeBSD.org
 COMMENT=	Diablo I engine for modern operating systems
 
-LICENSE=	UNLICENSE
-LICENSE_FILE=	${WRKSRC}/LICENSE
+LICENSE=	UNLICENSE CC-BY-NC-SA-4.0 OFL11
+LICENSE_COMB=	multi
+LICENSE_FILE_UNLICENSE=	${WRKSRC}/LICENSE
 
-_MY_DEPENDS=	CharisSIL>0:x11-fonts/charis
-BUILD_DEPENDS=	${_MY_DEPENDS}
-LIB_DEPENDS=	libsodium.so:security/libsodium
-RUN_DEPENDS=	${_MY_DEPENDS}
+LIB_DEPENDS=	libfmt.so:devel/libfmt
 
-USES=		cmake compiler:c++11-lang dos2unix sdl
-DOS2UNIX_GLOB=	*.c *.h CMakeLists.txt
+USES=		cmake compiler:c++11-lang dos2unix gettext-tools pkgconfig sdl
+DOS2UNIX_GLOB=	*.cpp *.h CMakeLists.txt
 USE_GITHUB=	yes
 GH_ACCOUNT=	diasurgical
-USE_SDL=	mixer2 sdl2 ttf2
+GH_TUPLE=	diasurgical:libsmackerdec:2997ee0e41e91bb723003bc09234be553b190e38:libsmackerdec/_deps/libsmackerdec-src \
+		brofield:simpleini:9b3ed7ec815997bc8c5b9edf140d6bde653e1458:simpleini/_deps/simpleini-src \
+		diasurgical:libmpq:0f10bd1600f406b13932bf5351ba713361262184:libmpq/_deps/libmpq-src
+USE_SDL=	sdl2 image2
 
 CMAKE_ARGS=	-DCMAKE_INSTALL_SHAREDIR:PATH=${PREFIX}/share \
-		-DVERSION_NUM=${PORTVERSION}
+		-DVERSION_NUM="${PORTVERSION}.0"
+CMAKE_ON=	FETCHCONTENT_FULLY_DISCONNECTED
 
-.if defined(WITH_DEBUG)
-CMAKE_ON=	DEBUG
-.else
-CMAKE_ON=	BINARY_RELEASE
-.endif
+DATA_VERSION=	v2
+DATADIR=	${PREFIX}/share/diasurgical/devilutionx
+
+OPTIONS_DEFINE=		TEST SOUND LTO DEBUG
+OPTIONS_GROUP=		NETWORKING
+OPTIONS_GROUP_NETWORKING=	NETWORK TCP ZEROTIER ENCRYPTION
+OPTIONS_DEFAULT=	LTO NETWORK TCP ENCRYPTION SOUND
+
+TEST_CMAKE_BOOL=	BUILD_TESTING
+TEST_BUILD_DEPENDS=	googletest>0:devel/googletest
+
+NETWORK_DESC=		Enable network support
+NETWORK_CMAKE_BOOL_OFF=	NONET
+
+TCP_DESC=		TCP multiplayer option
+TCP_CMAKE_BOOL_OFF=	DISABLE_TCP
+TCP_IMPLIES=		NETWORK
+TCP_GH_TUPLE=		diasurgical:asio:ebeff99f539da23d27c2e8d4bdbc1ee011968644:asio/_deps/asio-src
+
+ZEROTIER_DESC=		ZeroTier multiplayer option (broken)
+ZEROTIER_BROKEN=	does not build: fatal error: 'sys/appleapiopts.h' file not found
+ZEROTIER_CMAKE_BOOL_OFF=DISABLE_ZERO_TIER
+ZEROTIER_IMPLIES=	NETWORK
+ZEROTIER_GH_TUPLE=	diasurgical:libzt:a34ba7f1cc2e41b05badd25d1b01fdc5fd2f4e02:libzt/_deps/libzt-src \
+			diasurgical:ZeroTierOne:b1350ac91118d1bd6bb71c0c41be5f4a30196838:ZeroTierOne/_deps/libzt-src/ext/ZeroTierOne \
+			diasurgical:lwip:1bf7e011caf4e992ad139f6cb8c9818a9c1fbe1b:lwip/_deps/libzt-src/ext/lwip \
+			diasurgical:lwip-contrib:1f9e26e221a41542563834222c4ec8399be1908f:lwipcontrib/_deps/libzt-src/ext/lwip-contrib
+
+ENCRYPTION_DESC=	Encrypt network packets
+ENCRYPTION_CMAKE_BOOL=	PACKET_ENCRYPTION
+ENCRYPTION_IMPLIES=	NETWORK
+ENCRYPTION_LIB_DEPENDS=	libsodium.so:security/libsodium
 
-CXXFLAGS+=	-DTTF_FONT_NAME=\\\"${LOCALBASE}/share/fonts/CharisSIL/CharisSIL-Bold.ttf\\\"
+SOUND_CMAKE_BOOL_OFF=	NOSOUND
+SOUND_GH_TUPLE=		realnc:SDL_audiolib:1a69135313c79817b38a3a99826d4ac28d627fdf:SDL_audiolib/_deps/sdl_audiolib-src
 
-PLIST_FILES=	bin/devilutionx \
-		share/applications/devilutionx.desktop \
-		share/icons/hicolor/512x512/apps/devilutionx.png \
-		share/icons/hicolor/512x512/apps/devilutionx_solid.png
+LTO_CMAKE_BOOL_OFF=	DISABLE_LTO
+
+DEBUG_CMAKE_BOOL=	DEBUG
+
+post-extract:
+	@${MKDIR} ${BUILD_WRKSRC}
+	@${LN} -s ${WRKSRC}/_deps ${BUILD_WRKSRC}/_deps
+
+post-patch:
+	@${REINPLACE_CMD} -e 's|/usr/local|${PREFIX}|' ${WRKSRC}/Source/init.cpp
+
+do-install:
+	${INSTALL_PROGRAM} ${BUILD_WRKSRC}/devilutionx ${STAGEDIR}${PREFIX}/bin
+	${INSTALL_DATA} ${WRKSRC}/Packaging/nix/devilutionx.desktop ${STAGEDIR}${PREFIX}/share/applications
+	${INSTALL_DATA} ${WRKSRC}/Packaging/nix/devilutionx-hellfire.desktop ${STAGEDIR}${PREFIX}/share/applications
+	@${MKDIR} ${STAGEDIR}${PREFIX}/share/icons/hicolor/512x512/apps
+	${INSTALL_DATA} ${WRKSRC}/Packaging/resources/icon.png ${STAGEDIR}${PREFIX}/share/icons/hicolor/512x512/apps/devilutionx.png
+	${INSTALL_DATA} ${WRKSRC}/Packaging/resources/hellfire.png ${STAGEDIR}${PREFIX}/share/icons/hicolor/512x512/apps/devilutionx-hellfire.png
+	@${MKDIR} ${STAGEDIR}${DATADIR}
+	${INSTALL_DATA} ${DISTDIR}/devilutionx.mpq?tag=${DATA_VERSION} ${STAGEDIR}${DATADIR}/devilutionx.mpq
+
+do-test-TEST-on:
+	@cd ${TEST_WRKSRC} && ${SETENV} ${TEST_ENV} ${LOCALBASE}/bin/ctest -V
+
+.if make(makesum)
+GH_TUPLE+=	${TCP_GH_TUPLE} \
+		${ZEROTIER_GH_TUPLE} \
+		${SOUND_GH_TUPLE}
+.endif
 
 .include <bsd.port.mk>
diff --git a/games/devilutionX/distinfo b/games/devilutionX/distinfo
index 6936974b1c1a..8eade3a9e6b8 100644
--- a/games/devilutionX/distinfo
+++ b/games/devilutionX/distinfo
@@ -1,3 +1,23 @@
-TIMESTAMP = 1619323414
-SHA256 (diasurgical-devilutionX-1.2.1_GH0.tar.gz) = 002dcbd4d4a5bdf8db1a3ec01139e5bfbed46d6a1caa32b17c9f2df161ad3521
-SIZE (diasurgical-devilutionX-1.2.1_GH0.tar.gz) = 3573200
+TIMESTAMP = 1652828881
+SHA256 (devilutionx.mpq?tag=v2) = 90467c15f5e0ac902b2b8ac916f63a1fe2dd4b554ca36ab218bcd27f5121e988
+SIZE (devilutionx.mpq?tag=v2) = 4959860
+SHA256 (diasurgical-devilutionX-1.4_GH0.tar.gz) = 02efcb59c0b4c9f9332a93c9d9056d828381b261f00727d10e461b5b6a052c71
+SIZE (diasurgical-devilutionX-1.4_GH0.tar.gz) = 7559966
+SHA256 (diasurgical-libsmackerdec-2997ee0e41e91bb723003bc09234be553b190e38_GH0.tar.gz) = 40c0dc21943de22e153d56a7992c621a42a0c56c7cd833f8b84f90e48da753ea
+SIZE (diasurgical-libsmackerdec-2997ee0e41e91bb723003bc09234be553b190e38_GH0.tar.gz) = 18556
+SHA256 (brofield-simpleini-9b3ed7ec815997bc8c5b9edf140d6bde653e1458_GH0.tar.gz) = f7792eca9f3f7b0ee8916ffa4e124cb4b319b11d5849e15c5eef58eb910b0451
+SIZE (brofield-simpleini-9b3ed7ec815997bc8c5b9edf140d6bde653e1458_GH0.tar.gz) = 62870
+SHA256 (diasurgical-libmpq-0f10bd1600f406b13932bf5351ba713361262184_GH0.tar.gz) = ee173f5edb20f162482658cbc9d4bb84b640f651041d686c0ad7b2af12baf2a1
+SIZE (diasurgical-libmpq-0f10bd1600f406b13932bf5351ba713361262184_GH0.tar.gz) = 69570
+SHA256 (diasurgical-asio-ebeff99f539da23d27c2e8d4bdbc1ee011968644_GH0.tar.gz) = 88bb72f7bbdde7dbd050789bd73ff2abb2e9eacd8f9c889202b502f222230b6e
+SIZE (diasurgical-asio-ebeff99f539da23d27c2e8d4bdbc1ee011968644_GH0.tar.gz) = 1614738
+SHA256 (diasurgical-libzt-a34ba7f1cc2e41b05badd25d1b01fdc5fd2f4e02_GH0.tar.gz) = 40fd669e429b477bf2463e94c730b1db26752aafe06e4337dd76a112933ae1bf
+SIZE (diasurgical-libzt-a34ba7f1cc2e41b05badd25d1b01fdc5fd2f4e02_GH0.tar.gz) = 390951
+SHA256 (diasurgical-ZeroTierOne-b1350ac91118d1bd6bb71c0c41be5f4a30196838_GH0.tar.gz) = 39c1b7e28f9d4d92edaaa831007715358465a068019fe84a56b5366b386a1363
+SIZE (diasurgical-ZeroTierOne-b1350ac91118d1bd6bb71c0c41be5f4a30196838_GH0.tar.gz) = 13122622
+SHA256 (diasurgical-lwip-1bf7e011caf4e992ad139f6cb8c9818a9c1fbe1b_GH0.tar.gz) = 1477b5a427672480d0035b5af3e2cfae01c691afa9cace4500b43fcd262fa0bf
+SIZE (diasurgical-lwip-1bf7e011caf4e992ad139f6cb8c9818a9c1fbe1b_GH0.tar.gz) = 1136882
+SHA256 (diasurgical-lwip-contrib-1f9e26e221a41542563834222c4ec8399be1908f_GH0.tar.gz) = 0fd240b20ec56da41f5072161b8d1f1ad4367f994e183579bb5de9576394dcda
+SIZE (diasurgical-lwip-contrib-1f9e26e221a41542563834222c4ec8399be1908f_GH0.tar.gz) = 395250
+SHA256 (realnc-SDL_audiolib-1a69135313c79817b38a3a99826d4ac28d627fdf_GH0.tar.gz) = 8e013245bf8e676d4e2c61661d7cee6cb9de74f97a475c9e6b35a25d5e7a7715
+SIZE (realnc-SDL_audiolib-1a69135313c79817b38a3a99826d4ac28d627fdf_GH0.tar.gz) = 304183
diff --git a/games/devilutionX/files/patch-CMakeLists.txt b/games/devilutionX/files/patch-CMakeLists.txt
index 94b22747cbe4..0d51936652a8 100644
--- a/games/devilutionX/files/patch-CMakeLists.txt
+++ b/games/devilutionX/files/patch-CMakeLists.txt
@@ -1,14 +1,10 @@
---- CMakeLists.txt.orig	2021-04-08 06:20:26 UTC
+--- CMakeLists.txt.orig	2022-04-25 02:21:41 UTC
 +++ CMakeLists.txt
-@@ -873,6 +873,11 @@ if(CPACK)
-     set(CPACK_GENERATOR "DragNDrop")
-   endif()
+@@ -156,7 +156,6 @@ if(NONET)
+   set(PACKET_ENCRYPTION OFF)
+ endif()
  
-+install(TARGETS devilutionx 				DESTINATION ${CMAKE_INSTALL_BINDIR})
-+install(FILES   Packaging/fedora/devilutionx.desktop 	DESTINATION ${CMAKE_INSTALL_SHAREDIR}/applications)
-+install(FILES   Packaging/resources/icon.png 		DESTINATION ${CMAKE_INSTALL_SHAREDIR}/icons/hicolor/512x512/apps RENAME devilutionx.png)
-+install(FILES   Packaging/resources/icon_solid.png 	DESTINATION ${CMAKE_INSTALL_SHAREDIR}/icons/hicolor/512x512/apps RENAME devilutionx_solid.png)
-+
-   set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
-   set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
-   set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
+-find_program(CCACHE_PROGRAM ccache)
+ if(CCACHE_PROGRAM)
+   set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_PROGRAM}")
+ endif()
diff --git a/games/devilutionX/files/patch-Packaging_fedora_devilutionx.desktop b/games/devilutionX/files/patch-Packaging_fedora_devilutionx.desktop
deleted file mode 100644
index 46627d9440d7..000000000000
--- a/games/devilutionX/files/patch-Packaging_fedora_devilutionx.desktop
+++ /dev/null
@@ -1,17 +0,0 @@
---- Packaging/fedora/devilutionx.desktop.orig	2021-04-06 05:51:05 UTC
-+++ Packaging/fedora/devilutionx.desktop
-@@ -1,10 +1,10 @@
- [Desktop Entry]
- Name=DevilutionX
- GenericName=DevilutionX
--Comment=Play Diablo I on Linux
--Comment[da]=Spil Diablo I på Linux
--Comment[hr]=Igrajte Diablo I na Linuxu
--Comment[it]=Gioca a Diablo I su Linux
-+Comment=Play Diablo
-+Comment[da]=Spil Diablo I
-+Comment[hr]=Igrajte Diablo I
-+Comment[it]=Gioca a Diablo I
- Exec=devilutionx --diablo
- Icon=devilutionx
- Terminal=false
diff --git a/games/devilutionX/files/patch-Source_engine_random.cpp b/games/devilutionX/files/patch-Source_engine_random.cpp
new file mode 100644
index 000000000000..ac57d195923f
--- /dev/null
+++ b/games/devilutionX/files/patch-Source_engine_random.cpp
@@ -0,0 +1,14 @@
+https://github.com/diasurgical/devilutionX/pull/4588
+
+--- Source/engine/random.cpp.orig	2022-04-25 02:21:41 UTC
++++ Source/engine/random.cpp
+@@ -29,7 +29,8 @@ uint32_t GetLCGEngineState()
+ 
+ int32_t GetRndSeed()
+ {
+-	return abs(static_cast<int32_t>(sglGameSeed));
++	const int32_t seed = static_cast<int32_t>(sglGameSeed);
++	return seed == -2147483648 ? -2147483648 : abs(seed);
+ }
+ 
+ int32_t AdvanceRndSeed()
diff --git a/games/devilutionX/files/patch-Source_init.cpp b/games/devilutionX/files/patch-Source_init.cpp
new file mode 100644
index 000000000000..96130a70054a
--- /dev/null
+++ b/games/devilutionX/files/patch-Source_init.cpp
@@ -0,0 +1,11 @@
+--- Source/init.cpp.orig	2022-04-25 02:21:41 UTC
++++ Source/init.cpp
+@@ -90,7 +90,7 @@ std::vector<std::string> GetMPQSearchPaths()
+ 	if (paths[0] == paths[1])
+ 		paths.pop_back();
+ 
+-#if defined(__linux__) && !defined(__ANDROID__)
++#if (defined(__linux__) && !defined(__ANDROID__)) || defined(__FreeBSD__)
+ 	paths.emplace_back("/usr/share/diasurgical/devilutionx/");
+ 	paths.emplace_back("/usr/local/share/diasurgical/devilutionx/");
+ #elif defined(__3DS__) || defined(__SWITCH__)
diff --git a/games/devilutionX/files/patch-Source_sound.h b/games/devilutionX/files/patch-Source_sound.h
new file mode 100644
index 000000000000..c392962bd8dc
--- /dev/null
+++ b/games/devilutionX/files/patch-Source_sound.h
@@ -0,0 +1,14 @@
+--- Source/sound.h.orig	2022-05-17 15:57:06 UTC
++++ Source/sound.h
+@@ -60,7 +60,11 @@ struct TSnd {
+ };
+ 
+ extern bool gbSndInited;
++#ifndef NOSOUND
+ extern _music_id sgnMusicTrack;
++#else
++inline const _music_id sgnMusicTrack = NUM_MUSIC;
++#endif
+ 
+ void ClearDuplicateSounds();
+ void snd_stop_snd(TSnd *pSnd);
diff --git a/games/devilutionX/pkg-message b/games/devilutionX/pkg-message
index b084bb8cb89f..14e563baa00c 100644
--- a/games/devilutionX/pkg-message
+++ b/games/devilutionX/pkg-message
@@ -4,8 +4,7 @@
 This game requires a datafile from the original Diablo(tm) CD or the GOG release.
 If you don't own it yet, you can buy it at https://www.gog.com/game/diablo
 
-Copy DIABDAT.MPQ to ~/.local/share/diasurgical/devilution/diabdat.mpq
-Pay attention to the case, the resulting file needs to be entirely lowercase!
+Copy DIABDAT.MPQ to ~/.local/share/diasurgical/devilution/
 
 If you have any issues with this game, please file a bug report on the GitHub page:
 https://github.com/diasurgical/devilutionX/issues
diff --git a/games/devilutionX/pkg-plist b/games/devilutionX/pkg-plist
new file mode 100644
index 000000000000..1add42c683cb
--- /dev/null
+++ b/games/devilutionX/pkg-plist
@@ -0,0 +1,6 @@
+bin/devilutionx
+share/applications/devilutionx-hellfire.desktop
+share/applications/devilutionx.desktop
+%%DATADIR%%/devilutionx.mpq
+share/icons/hicolor/512x512/apps/devilutionx-hellfire.png
+share/icons/hicolor/512x512/apps/devilutionx.png