unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* bug#26468: Add teeworlds (game)
@ 2017-04-12 20:45 Ricardo Wurmus
  2017-04-12 20:47 ` bug#26468: [PATCH 1/2] gnu: Add bam Ricardo Wurmus
  0 siblings, 1 reply; 5+ messages in thread
From: Ricardo Wurmus @ 2017-04-12 20:45 UTC (permalink / raw)
  To: 26468

Here are two patches to add another game to Guix: Teeworlds.

-- 
Ricardo

GPG: BCA6 89B6 3655 3801 C3C6  2150 197A 5888 235F ACAC
https://elephly.net

^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#26468: [PATCH 1/2] gnu: Add bam.
  2017-04-12 20:45 bug#26468: Add teeworlds (game) Ricardo Wurmus
@ 2017-04-12 20:47 ` Ricardo Wurmus
  2017-04-12 20:47   ` bug#26468: [PATCH 2/2] gnu: Add teeworlds Ricardo Wurmus
  0 siblings, 1 reply; 5+ messages in thread
From: Ricardo Wurmus @ 2017-04-12 20:47 UTC (permalink / raw)
  To: 26468; +Cc: Ricardo Wurmus

* gnu/packages/build-tools.scm: New file.
* gnu/local.mk (GNU_SYSTEM_MODULES): Add it.
---
 gnu/local.mk                 |  1 +
 gnu/packages/build-tools.scm | 64 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 65 insertions(+)
 create mode 100644 gnu/packages/build-tools.scm

diff --git a/gnu/local.mk b/gnu/local.mk
index 78356753a..4ef3f22b7 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -70,6 +70,7 @@ GNU_SYSTEM_MODULES =				\
   %D%/packages/boost.scm			\
   %D%/packages/bootloaders.scm			\
   %D%/packages/bootstrap.scm			\
+  %D%/packages/build-tools.scm			\
   %D%/packages/busybox.scm			\
   %D%/packages/c.scm				\
   %D%/packages/calcurse.scm			\
diff --git a/gnu/packages/build-tools.scm b/gnu/packages/build-tools.scm
new file mode 100644
index 000000000..8901a4657
--- /dev/null
+++ b/gnu/packages/build-tools.scm
@@ -0,0 +1,64 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2017 Ricardo Wurmus <rekado@elephly.net>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix 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.
+;;;
+;;; GNU Guix 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 GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (gnu packages build-tools)
+  #:use-module ((guix licenses) #:prefix license:)
+  #:use-module (guix utils)
+  #:use-module (guix packages)
+  #:use-module (guix download)
+  #:use-module (gnu packages)
+  #:use-module (gnu packages python)
+  #:use-module (guix build-system gnu))
+
+(define-public bam
+  (package
+    (name "bam")
+    (version "0.4.0")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append "http://github.com/downloads/matricks/"
+                                  "bam/bam-" version ".tar.bz2"))
+              (sha256
+               (base32
+                "0z90wvyd4nfl7mybdrv9dsd4caaikc6fxw801b72gqi1m9q0c0sn"))))
+    (build-system gnu-build-system)
+    (arguments
+     `(#:phases
+       (modify-phases %standard-phases
+         (delete 'configure)
+         (replace 'build
+           (lambda _
+             (zero? (system* "bash" "make_unix.sh"))))
+         (replace 'check
+           (lambda _
+             (zero? (system* "python" "scripts/test.py"))))
+         (replace 'install
+           (lambda* (#:key outputs #:allow-other-keys)
+             (let ((bin (string-append (assoc-ref outputs "out") "/bin")))
+               (mkdir-p bin)
+               (install-file "bam" bin)
+               #t))))))
+    (native-inputs
+     `(("python" ,python-2)))
+    (home-page "https://matricks.github.io/bam/")
+    (synopsis "Fast and flexible build system")
+    (description "Bam is a fast and flexible build system.  Bam uses Lua to
+describe the build process.  It takes its inspiration for the script files
+from scons.  While scons focuses on being 100% correct when building, bam
+makes a few sacrifices to acquire fast full and incremental build times.")
+    (license license:bsd-3)))
-- 
2.12.2

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* bug#26468: [PATCH 2/2] gnu: Add teeworlds.
  2017-04-12 20:47 ` bug#26468: [PATCH 1/2] gnu: Add bam Ricardo Wurmus
@ 2017-04-12 20:47   ` Ricardo Wurmus
  2017-04-13 19:26     ` Marius Bakke
  0 siblings, 1 reply; 5+ messages in thread
From: Ricardo Wurmus @ 2017-04-12 20:47 UTC (permalink / raw)
  To: 26468; +Cc: Ricardo Wurmus

* gnu/packages/games.scm (teeworlds): New variable.
* gnu/packages/patches/teeworlds-use-latest-wavpack.patch: New file.
* gnu/local.mk (dist_patch_DATA): Add patch.
---
 gnu/local.mk                                       |  1 +
 gnu/packages/games.scm                             | 89 ++++++++++++++++++++++
 .../patches/teeworlds-use-latest-wavpack.patch     | 84 ++++++++++++++++++++
 3 files changed, 174 insertions(+)
 create mode 100644 gnu/packages/patches/teeworlds-use-latest-wavpack.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 4ef3f22b7..38b95c3bb 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -955,6 +955,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/tcsh-fix-autotest.patch			\
   %D%/packages/patches/tcsh-fix-out-of-bounds-read.patch	\
   %D%/packages/patches/teensy-loader-cli-help.patch		\
+  %D%/packages/patches/teeworlds-use-latest-wavpack.patch	\
   %D%/packages/patches/texlive-texmf-CVE-2016-10243.patch	\
   %D%/packages/patches/texi2html-document-encoding.patch	\
   %D%/packages/patches/texi2html-i18n.patch			\
diff --git a/gnu/packages/games.scm b/gnu/packages/games.scm
index 710b2746c..a956f0ca4 100644
--- a/gnu/packages/games.scm
+++ b/gnu/packages/games.scm
@@ -56,6 +56,7 @@
   #:use-module (gnu packages autotools)
   #:use-module (gnu packages backup)
   #:use-module (gnu packages base)
+  #:use-module (gnu packages build-tools)
   #:use-module (gnu packages admin)
   #:use-module (gnu packages audio)
   #:use-module (gnu packages avahi)
@@ -3649,3 +3650,91 @@ small robot living in the nano world, repair its maker.")
     ;; kiki-the-nano-bot/kiki-the-nano-bot_1.0.2+dfsg1-4_copyright>
     ;; for a statement from the author.
     (license license:public-domain)))
+
+(define-public teeworlds
+  (package
+    (name "teeworlds")
+    (version "0.6.4")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append "https://github.com/teeworlds/teeworlds/"
+                                  "archive/" version "-release.tar.gz"))
+              (file-name (string-append name "-" version ".tar.gz"))
+              (sha256
+               (base32
+                "1mqhp6xjl75l49050cid36wxyjn1qr0vjx1c709dfg1lkvmgs6l3"))
+              (modules '((guix build utils)))
+              (snippet
+               '(begin
+                  (for-each delete-file-recursively
+                            '("src/engine/external/wavpack/"
+                              "src/engine/external/zlib/"))
+                  #t))
+              (patches
+               (search-patches "teeworlds-use-latest-wavpack.patch"))))
+    (build-system gnu-build-system)
+    (arguments
+     `(#:tests? #f ; no tests included
+       #:phases
+       (modify-phases %standard-phases
+         (replace 'configure
+           (lambda* (#:key outputs #:allow-other-keys)
+             ;; Embed path to assets.
+             (substitute* "src/engine/shared/storage.cpp"
+               (("#define DATA_DIR.*")
+                (string-append "#define DATA_DIR \""
+                               (assoc-ref outputs "out")
+                               "/share/teeworlds/data"
+                               "\"")))
+
+             ;; Bam expects all files to have a recent time stamp.
+             (for-each (lambda (file)
+                         (utime file 1 1))
+                       (find-files "."))
+
+             ;; Do not use bundled libraries.
+             (substitute* "bam.lua"
+               (("if config.zlib.value == 1 then")
+                "if true then")
+               (("wavpack = .*")
+                "wavpack = {}
+settings.link.libs:Add(\"wavpack\")\n"))
+             (substitute* "src/engine/client/sound.cpp"
+               (("#include <engine/external/wavpack/wavpack.h>")
+                "#include <wavpack/wavpack.h>"))
+             #t))
+         (replace 'build
+           (lambda _
+             (zero? (system* "bam" "-a" "-v" "release"))))
+         (replace 'install
+           (lambda* (#:key outputs #:allow-other-keys)
+             (let* ((out  (assoc-ref outputs "out"))
+                    (bin  (string-append out "/bin"))
+                    (data (string-append out "/share/teeworlds/data")))
+               (mkdir-p bin)
+               (mkdir-p data)
+               (for-each (lambda (file)
+                           (install-file file bin))
+                         '("teeworlds" "teeworlds_srv"))
+               (copy-recursively "data" data)
+               #t))))))
+    ;; FIXME: teeworlds bundles the sources of "pnglite", a two-file PNG
+    ;; library without a build system.
+    (inputs
+     `(("freetype" ,freetype)
+       ("glu" ,glu)
+       ("mesa" ,mesa)
+       ("sdl-union" ,(sdl-union (list sdl
+                                      sdl-mixer
+                                      sdl-image)))
+       ("wavpack" ,wavpack)
+       ("zlib" ,zlib)))
+    (native-inputs
+     `(("bam" ,bam)
+       ("python" ,python-2)))
+    (home-page "https://www.teeworlds.com")
+    (synopsis "2D retro multiplayer shooter game")
+    (description "Teeworlds is an online multiplayer game.  Battle with up to
+16 players in a variety of game modes, including Team Deathmatch and Capture
+The Flag.  You can even design your own maps!")
+    (license license:bsd-3)))
diff --git a/gnu/packages/patches/teeworlds-use-latest-wavpack.patch b/gnu/packages/patches/teeworlds-use-latest-wavpack.patch
new file mode 100644
index 000000000..e9fd99108
--- /dev/null
+++ b/gnu/packages/patches/teeworlds-use-latest-wavpack.patch
@@ -0,0 +1,84 @@
+Downloaded from https://anonscm.debian.org/cgit/pkg-games/teeworlds.git/plain/debian/patches/new-wavpack.patch.
+
+This patch lets us build teeworlds with wavpack 5.1.0.
+
+--- a/src/engine/client/sound.cpp
++++ b/src/engine/client/sound.cpp
+@@ -328,17 +328,14 @@ void CSound::RateConvert(int SampleID)
+ 	pSample->m_NumFrames = NumFrames;
+ }
+ 
+-int CSound::ReadData(void *pBuffer, int Size)
+-{
+-	return io_read(ms_File, pBuffer, Size);
+-}
+-
+ int CSound::LoadWV(const char *pFilename)
+ {
+ 	CSample *pSample;
+ 	int SampleID = -1;
+ 	char aError[100];
+ 	WavpackContext *pContext;
++	char aWholePath[1024];
++	IOHANDLE File;
+ 
+ 	// don't waste memory on sound when we are stress testing
+ 	if(g_Config.m_DbgStress)
+@@ -351,19 +348,23 @@ int CSound::LoadWV(const char *pFilename
+ 	if(!m_pStorage)
+ 		return -1;
+ 
+-	ms_File = m_pStorage->OpenFile(pFilename, IOFLAG_READ, IStorage::TYPE_ALL);
+-	if(!ms_File)
++	File = m_pStorage->OpenFile(pFilename, IOFLAG_READ, IStorage::TYPE_ALL, aWholePath, sizeof(aWholePath));
++	if(!File)
+ 	{
+ 		dbg_msg("sound/wv", "failed to open file. filename='%s'", pFilename);
+ 		return -1;
+ 	}
++	else
++	{
++		io_close(File);
++	}
+ 
+ 	SampleID = AllocID();
+ 	if(SampleID < 0)
+ 		return -1;
+ 	pSample = &m_aSamples[SampleID];
+ 
+-	pContext = WavpackOpenFileInput(ReadData, aError);
++	pContext = WavpackOpenFileInput(aWholePath, aError, OPEN_2CH_MAX, 0);
+ 	if (pContext)
+ 	{
+ 		int m_aSamples = WavpackGetNumSamples(pContext);
+@@ -419,9 +420,6 @@ int CSound::LoadWV(const char *pFilename
+ 		dbg_msg("sound/wv", "failed to open %s: %s", pFilename, aError);
+ 	}
+ 
+-	io_close(ms_File);
+-	ms_File = NULL;
+-
+ 	if(g_Config.m_Debug)
+ 		dbg_msg("sound/wv", "loaded %s", pFilename);
+ 
+@@ -527,7 +525,5 @@ void CSound::StopAll()
+ 	lock_unlock(m_SoundLock);
+ }
+ 
+-IOHANDLE CSound::ms_File = 0;
+-
+ IEngineSound *CreateEngineSound() { return new CSound; }
+ 
+--- a/src/engine/client/sound.h
++++ b/src/engine/client/sound.h
+@@ -21,10 +21,6 @@ public:
+ 
+ 	static void RateConvert(int SampleID);
+ 
+-	// TODO: Refactor: clean this mess up
+-	static IOHANDLE ms_File;
+-	static int ReadData(void *pBuffer, int Size);
+-
+ 	virtual bool IsSoundEnabled() { return m_SoundEnabled != 0; }
+ 
+ 	virtual int LoadWV(const char *pFilename);
-- 
2.12.2

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* bug#26468: [PATCH 2/2] gnu: Add teeworlds.
  2017-04-12 20:47   ` bug#26468: [PATCH 2/2] gnu: Add teeworlds Ricardo Wurmus
@ 2017-04-13 19:26     ` Marius Bakke
  2017-04-13 21:37       ` Ricardo Wurmus
  0 siblings, 1 reply; 5+ messages in thread
From: Marius Bakke @ 2017-04-13 19:26 UTC (permalink / raw)
  To: Ricardo Wurmus, 26468

[-- Attachment #1: Type: text/plain, Size: 474 bytes --]

Ricardo Wurmus <rekado@elephly.net> writes:

> * gnu/packages/games.scm (teeworlds): New variable.
> * gnu/packages/patches/teeworlds-use-latest-wavpack.patch: New file.
> * gnu/local.mk (dist_patch_DATA): Add patch.

[...]

> +             ;; Bam expects all files to have a recent time stamp.
> +             (for-each (lambda (file)
> +                         (utime file 1 1))
> +                       (find-files "."))

This comment is hilarious :) The patches LGTM!

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#26468: [PATCH 2/2] gnu: Add teeworlds.
  2017-04-13 19:26     ` Marius Bakke
@ 2017-04-13 21:37       ` Ricardo Wurmus
  0 siblings, 0 replies; 5+ messages in thread
From: Ricardo Wurmus @ 2017-04-13 21:37 UTC (permalink / raw)
  To: Marius Bakke; +Cc: 26468-done


Marius Bakke <mbakke@fastmail.com> writes:

> Ricardo Wurmus <rekado@elephly.net> writes:
>
>> * gnu/packages/games.scm (teeworlds): New variable.
>> * gnu/packages/patches/teeworlds-use-latest-wavpack.patch: New file.
>> * gnu/local.mk (dist_patch_DATA): Add patch.
>
> [...]
>
>> +             ;; Bam expects all files to have a recent time stamp.
>> +             (for-each (lambda (file)
>> +                         (utime file 1 1))
>> +                       (find-files "."))
>
> This comment is hilarious :) The patches LGTM!

Thanks!  Pushed to master with commit
b77e3a1c4eabbd6010083a6cb9aad7cf5a9a4d45.

--
Ricardo

GPG: BCA6 89B6 3655 3801 C3C6  2150 197A 5888 235F ACAC
https://elephly.net

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-04-13 21:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-12 20:45 bug#26468: Add teeworlds (game) Ricardo Wurmus
2017-04-12 20:47 ` bug#26468: [PATCH 1/2] gnu: Add bam Ricardo Wurmus
2017-04-12 20:47   ` bug#26468: [PATCH 2/2] gnu: Add teeworlds Ricardo Wurmus
2017-04-13 19:26     ` Marius Bakke
2017-04-13 21:37       ` Ricardo Wurmus

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).