Subject: [bug#39825] [PATCH] gnu: Add warsow-qfusion.

From: Pierre Neidhardt <[email-masked]>
Date: Fri, 28 Feb 2020 17:04:51 +0100

* gnu/packages/game-development.scm (warsow-qfusion): New variable.
* gnu/packages/patches/warsow-fix-bool-return-type.patch: New file.
* gnu/local.mk: Add patch.
---
 gnu/local.mk                                  |  1 +
 gnu/packages/game-development.scm             | 49 +++++++++++++++++++
 .../patches/warsow-fix-bool-return-type.patch | 24 +++++++++
 3 files changed, 74 insertions(+)
 create mode 100644 gnu/packages/patches/warsow-fix-bool-return-type.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 857345cfad..82d5490dd8 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1482,6 +1482,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/vsearch-unbundle-cityhash.patch		\
   %D%/packages/patches/vte-CVE-2012-2738-pt1.patch			\
   %D%/packages/patches/vte-CVE-2012-2738-pt2.patch			\
+  %D%/packages/patches/warsow-fix-bool-return-type.patch	\
   %D%/packages/patches/weasyprint-library-paths.patch		\
   %D%/packages/patches/websocketpp-fix-for-boost-1.70.patch	\
   %D%/packages/patches/wicd-bitrate-none-fix.patch		\
diff --git a/gnu/packages/game-development.scm b/gnu/packages/game-development.scm
index 05e026a846..f0b1b5f066 100644
--- a/gnu/packages/game-development.scm
+++ b/gnu/packages/game-development.scm
@@ -2188,3 +2188,52 @@ rigid body physics library written in C.")
 developers providing an advanced true color console, input, and lots of other
 utilities frequently used in roguelikes.")
     (license license:bsd-3)))
+
+(define-public warsow-qfusion
+  (let ((commit "5ec6887887850fa9e6f0a4418ab2b776f54fb395"))
+    (package
+      (name "warsow-qfusion")
+      (version (git-version "2.1.0" "1" commit))
+      (source (origin
+                (method git-fetch)
+                (uri (git-reference
+                      (url "https://github.com/Warsow/qfusion/")
+                      (commit commit)
+                      (recursive? #t)))
+                (file-name (git-file-name name version))
+                (sha256
+                 (base32
+                  "0bfwyikpwgwqcli33hxscdp557li1hkwyxy069csx5dy6sfvci6q"))
+                ;; Issue reported here: https://github.com/Warsow/qfusion/issues/46
+                (patches (search-patches "warsow-fix-bool-return-type.patch"))))
+      (build-system cmake-build-system)
+      (arguments
+       `(#:tests? #f                    ; No tests.
+         #:configure-flags '("-DQFUSION_GAME=Warsow")
+         #:phases
+         (modify-phases %standard-phases
+           (add-after 'unpack 'change-to-build-dir
+             (lambda _
+               (chdir "source")
+               #t)))))
+      (inputs
+       `(("sdl2" ,sdl2)
+         ("libjpeg" ,libjpeg)
+         ("libpng" ,libpng)
+         ("libvorbis" ,libvorbis)
+         ("libogg" ,libogg)
+         ("libtheora" ,libtheora)
+         ("freetype" ,freetype)
+         ("mesa" ,mesa)
+         ("openal" ,openal)
+         ("zlib" ,zlib)
+         ("curl" ,curl)
+         ("qtbase" ,qtbase)
+         ("qtdeclarative" ,qtdeclarative)
+         ("uuid.h" ,util-linux)))
+      (home-page "https://github.com/Warsow/qfusion")
+      (synopsis "Warsow's fork of qfusion, the id Tech 2 derived game engine")
+      (description
+       "This package contains Warsow's fork of qfusion, the id Tech 2 derived
+game engine.  id Tech 2 is the engine originally behind Quake 2.")
+      (license license:gpl2))))
diff --git a/gnu/packages/patches/warsow-fix-bool-return-type.patch b/gnu/packages/patches/warsow-fix-bool-return-type.patch
new file mode 100644
index 0000000000..cd2c58afef
--- /dev/null
+++ b/gnu/packages/patches/warsow-fix-bool-return-type.patch
@@ -0,0 +1,24 @@
+diff --git a/source/ref/imagelib.cpp b/source/ref/imagelib.cpp
+index 33337ac..bb9a156 100644
+--- a/source/ref/imagelib.cpp
++++ b/source/ref/imagelib.cpp
+@@ -762,7 +762,7 @@ static void q_jpg_noop( j_decompress_ptr cinfo ) {
+
+ static boolean q_jpg_fill_input_buffer( j_decompress_ptr cinfo ) {
+ 	Com_DPrintf( "Premature end of jpeg file\n" );
+-	return 1;
++	return TRUE;
+ }
+
+ static void q_jpg_skip_input_data( j_decompress_ptr cinfo, long num_bytes ) {
+@@ -955,7 +955,7 @@ bool WriteJPG( const char *name, r_imginfo_t *info, int quality ) {
+ 	}
+
+ 	// start compression
+-	qjpeg_start_compress( &cinfo, true );
++	qjpeg_start_compress( &cinfo, TRUE );
+
+ 	// feed scanline data
+ 	w3 = cinfo.image_width * info->samples;
+--
+2.25.1
-- 
2.25.1