View | Details | Raw Unified | Return to bug 152637
Collapse All | Expand All

(-)ioquake3/Makefile (-4 / +19 lines)
Lines 7-18 Link Here
7
7
8
PORTNAME?=	ioquake3
8
PORTNAME?=	ioquake3
9
DISTVERSION?=	1.36
9
DISTVERSION?=	1.36
10
PORTREVISION?=	6
10
PORTREVISION?=	7
11
CATEGORIES=	games
11
CATEGORIES=	games
12
MASTER_SITES?=	http://ioquake3.org/files/${DISTVERSION}/
12
MASTER_SITES?=	http://ioquake3.org/files/${DISTVERSION}/
13
13
14
MAINTAINER?=	kamikaze@bsdforen.de
14
MAINTAINER?=	kamikaze@bsdforen.de
15
COMMENT?=	Cleaned-up and enhaced version of Quake 3
15
COMMENT?=	Cleaned-up and enhanced version of Quake 3
16
16
17
USE_ZIP?=	yes
17
USE_ZIP?=	yes
18
# Allow slave ports to turn off zip.
18
# Allow slave ports to turn off zip.
Lines 31-37 Link Here
31
31
32
MAKE_ARGS+=	DEFAULT_BASEDIR="${Q3DIR}" \
32
MAKE_ARGS+=	DEFAULT_BASEDIR="${Q3DIR}" \
33
		DEFAULT_LIBDIR="${LIBDIR}" \
33
		DEFAULT_LIBDIR="${LIBDIR}" \
34
		HOMEPATH="/.${PORTNAME}" \
34
		HOMEPATH="${HOMEPATH}" \
35
		VERSION="${DISTVERSION}" \
35
		VERSION="${DISTVERSION}" \
36
		ARCH="${ARCH}"
36
		ARCH="${ARCH}"
37
PLIST_SUB+=	LIBDIR="${LIBDIR:S/${PREFIX}\///}" \
37
PLIST_SUB+=	LIBDIR="${LIBDIR:S/${PREFIX}\///}" \
Lines 43-48 Link Here
43
LIBDIR=		${PREFIX}/lib/${PORTNAME}
43
LIBDIR=		${PREFIX}/lib/${PORTNAME}
44
BUILDDIR=	${WRKSRC}/build/release-${OPSYS:L}-${ARCH}
44
BUILDDIR=	${WRKSRC}/build/release-${OPSYS:L}-${ARCH}
45
BINSUFFIX?=
45
BINSUFFIX?=
46
HOMEPATH?=	/.${PORTNAME}
46
Q3CLIENT?=	ioquake3
47
Q3CLIENT?=	ioquake3
47
Q3SERVER?=	ioq3ded
48
Q3SERVER?=	ioq3ded
48
Q3TOOLS?=	q3asm \
49
Q3TOOLS?=	q3asm \
Lines 51-56 Link Here
51
		q3rcc
52
		q3rcc
52
Q3BASE?=	baseq3 \
53
Q3BASE?=	baseq3 \
53
		missionpack
54
		missionpack
55
Q3ICON?=	${PREFIX}/share/pixmaps/quake3.xpm
54
Q3INSTALL?=
56
Q3INSTALL?=
55
57
56
ONLY_FOR_ARCHS=	amd64 i386
58
ONLY_FOR_ARCHS=	amd64 i386
Lines 61-68 Link Here
61
63
62
.include <bsd.port.options.mk>
64
.include <bsd.port.options.mk>
63
65
66
.if !defined(DESKTOP_ENTRIES)
67
.if defined(WITH_CLIENT)
68
DESKTOP_ENTRIES+=	"${Q3CLIENT} ${DISTVERSION}" "${COMMENT}"  \
69
		"${Q3ICON}" \
70
		"${Q3CLIENT}${BINSUFFIX}" "Application;Game;" false
71
.endif
72
.if defined(WITH_SMP)
73
DESKTOP_ENTRIES+=	"${Q3CLIENT} ${DISTVERSION} SMP" "${COMMENT}" \
74
		"${Q3ICON}" \
75
		"${Q3CLIENT}-smp${BINSUFFIX}" "Application;Game;" false
76
.endif
77
.endif
78
64
.if defined(WITHOUT_CLIENT) && defined(WITHOUT_DEDICATED) && \
79
.if defined(WITHOUT_CLIENT) && defined(WITHOUT_DEDICATED) && \
65
    defined(WITHOUT_SMP)
80
    !defined(WITH_SMP)
66
IGNORE=		needs at least one of CLIENT, DEDICATED and SMP options
81
IGNORE=		needs at least one of CLIENT, DEDICATED and SMP options
67
.endif
82
.endif
68
83
(-)ioquake3/distinfo (-1 lines)
Lines 1-3 Link Here
1
MD5 (ioquake3-1.36.zip) = 8e48a3957b3e70601d0ea0a450dc6359
2
SHA256 (ioquake3-1.36.zip) = 3f8fecd81f9af484b9215df4cf58bcc6a378adb6f1504b0bba169c3dbadb4c94
1
SHA256 (ioquake3-1.36.zip) = 3f8fecd81f9af484b9215df4cf58bcc6a378adb6f1504b0bba169c3dbadb4c94
3
SIZE (ioquake3-1.36.zip) = 4583577
2
SIZE (ioquake3-1.36.zip) = 4583577
(-)ioquake3/files/patch-code-qcommon-vm_x86.c (+29 lines)
Line 0 Link Here
1
--- code/qcommon/vm_x86.c.orig	2008-08-18 01:22:06.000000000 +0200
2
+++ code/qcommon/vm_x86.c	2010-11-27 14:01:33.000000000 +0100
3
@@ -36,7 +36,25 @@
4
 
5
 /* need this on NX enabled systems (i386 with PAE kernel or
6
  * noexec32=on x86_64) */
7
-#ifdef __linux__
8
+//     Rambetter's note: I'm adding the test for __FreeBSD__ in addition to the [already
9
+// existing] test for __linux__.  Here is why.  I own a 32 bit FreeBSD 8.0 server with
10
+// a PAE kernel.  Without VM_X86_MMAP, ioq3ded segfaults shortly after starting
11
+// (this should come as no surprise).  With VM_X86_MMAP, ioq3ded runs very smoothly.
12
+// So, at a very minimum, we need to set VM_X86_MMAP for FreeBSD PAE kernels.
13
+//     Now, I also happen to own a 32 bit FreeBSD 7.1 server with just the standard kernel
14
+// (non-PAE).  I have run ioq3ded successfully on it with and without VM_X86_MMAP for many
15
+// months.  So, in the case of non-PAE FreeBSD, we can go either way - use VM_X86_MMAP or
16
+// not use it.  The absolute safest fix to this problem is to only set VM_X86_MMAP on
17
+// PAE FreeBSD kernels (in addition to Linux); however, I don't know of a way to detect
18
+// the PAE kernel easily.  Therefore, since using VM_X86_MMAP won't break anything on
19
+// non-PAE kernels [apparently], we'll just use it all the time on FreeBSD 32 bit.
20
+//     Now, you may ask the question: Why not change the entire test for just __unix__?
21
+// Unfortunately I cannot say anything about this because I don't have access to every
22
+// other system that has __unix__ defined, so I cannot possibly test all those cases to
23
+// make sure things work.  We'll just leave it with __linux__ and __FreeBSD__ to be safe.
24
+// If someone with a different flavor of UNIX running a PAE kernel has this problem too,
25
+// they can report the bug and we will adjust the line below accordingly.
26
+#if defined(__linux__) || defined(__FreeBSD__)
27
 #define VM_X86_MMAP
28
 #endif
29
 
(-)ioquake3-devel/Makefile (-10 / +10 lines)
Lines 5-23 Link Here
5
# $FreeBSD: ports/games/ioquake3-devel/Makefile,v 1.7 2010/05/22 06:09:50 miwi Exp $
5
# $FreeBSD: ports/games/ioquake3-devel/Makefile,v 1.7 2010/05/22 06:09:50 miwi Exp $
6
#
6
#
7
7
8
PORTNAME=	ioquake3-devel
8
PORTNAME?=	ioquake3-devel
9
DISTVERSION=	1.36_SVN${SVNREVISION}
9
DISTVERSION?=	1.36_SVN${SVNREVISION}
10
PORTREVISION=	0
10
PORTREVISION?=	0
11
MASTER_SITES=	ftp://deponie.yamagi.org/freebsd/distfiles/ioquake3/ \
11
MASTER_SITES?=	ftp://deponie.yamagi.org/freebsd/distfiles/ioquake3/ \
12
		http://deponie.yamagi.org/freebsd/distfiles/ioquake3/
12
		http://deponie.yamagi.org/freebsd/distfiles/ioquake3/
13
13
14
MAINTAINER=	kamikaze@bsdforen.de
14
MAINTAINER?=	kamikaze@bsdforen.de
15
COMMENT=	Development SVN snapshots of ioquake3
15
COMMENT?=	Development SVN snapshots of ioquake3
16
16
17
PLIST=		${.CURDIR}/../ioquake3/pkg-plist
17
PLIST?=		${.CURDIR}/../ioquake3/pkg-plist
18
PATCHDIR=	${WRKDIR}/freebsd-patchset/
18
PATCHDIR?=	${WRKDIR}/freebsd-patchset/
19
19
20
SVNREVISION=	1784
20
SVNREVISION?=	1803
21
BINSUFFIX=	-devel
21
BINSUFFIX?=	-devel
22
22
23
.include "${.CURDIR}/../ioquake3/Makefile"
23
.include "${.CURDIR}/../ioquake3/Makefile"
(-)ioquake3-devel/distinfo (-3 / +2 lines)
Lines 1-3 Link Here
1
MD5 (ioquake3-devel-1.36_SVN1784.zip) = 519a106119b64bc388f1c91fd0f51b5b
1
SHA256 (ioquake3-devel-1.36_SVN1803.zip) = 2d73b8f4818c7f82adc2f28308e7a6bdca7f3b5e9db0fbbfa5c34e2569a386da
2
SHA256 (ioquake3-devel-1.36_SVN1784.zip) = daf0c428fa119e393b2a595709e4655f61fa3d639419368475411f8e636ad905
2
SIZE (ioquake3-devel-1.36_SVN1803.zip) = 4930935
3
SIZE (ioquake3-devel-1.36_SVN1784.zip) = 4930534
(-)openarena/Makefile (-3 / +5 lines)
Lines 7-16 Link Here
7
7
8
PORTNAME=	openarena
8
PORTNAME=	openarena
9
PORTVERSION=	0.8.5
9
PORTVERSION=	0.8.5
10
DISTVERSION=	1.36_SVN1783+${PORTVERSION}
10
DISTVERSION=	1.36_SVN1788+${PORTVERSION}
11
PORTREVISION=	0
11
PORTREVISION=	1
12
MASTER_SITES=	http://files.poulsander.com/~poul19/public_files/oa/dev081/
12
MASTER_SITES=	http://files.poulsander.com/~poul19/public_files/oa/dev081/
13
DISTNAME=	${PORTNAME}-engine-source-0.8.x-15
13
DISTNAME=	${PORTNAME}-engine-source-0.8.x-18
14
14
15
MAINTAINER=	kamikaze@bsdforen.de
15
MAINTAINER=	kamikaze@bsdforen.de
16
COMMENT=	Quake3 total conversion based on the ioquake3 engine
16
COMMENT=	Quake3 total conversion based on the ioquake3 engine
Lines 28-32 Link Here
28
Q3TOOLS=
28
Q3TOOLS=
29
Q3BASE=		baseoa
29
Q3BASE=		baseoa
30
Q3DIR=		${DATADIR}
30
Q3DIR=		${DATADIR}
31
# No icon included with OpenArena
32
Q3ICON=
31
33
32
.include "../ioquake3/Makefile"
34
.include "../ioquake3/Makefile"
(-)openarena/distinfo (-3 / +2 lines)
Lines 1-3 Link Here
1
MD5 (openarena-engine-source-0.8.x-15.tar.bz2) = 868a6d0dca1579a0cbc05192b9cdc70d
1
SHA256 (openarena-engine-source-0.8.x-18.tar.bz2) = 77180d70af00134b3cfbc51a3c1371f99665e2f073b2ec5fdbf08f6c93ae1c24
2
SHA256 (openarena-engine-source-0.8.x-15.tar.bz2) = fc274de6cc4a6a880618d38267d4453fdb3125fc8587b08e6ea51dd137a88650
2
SIZE (openarena-engine-source-0.8.x-18.tar.bz2) = 7211834
3
SIZE (openarena-engine-source-0.8.x-15.tar.bz2) = 8080759
(-)openarena/files/patch-Makefile (-116 / +9 lines)
Lines 1-126 Link Here
1
--- Makefile.orig	2010-04-24 23:29:15.000000000 +0200
1
--- Makefile.orig	2010-07-02 21:50:49.000000000 +0200
2
+++ Makefile	2010-05-22 00:10:08.000000000 +0200
2
+++ Makefile	2010-11-27 14:39:09.000000000 +0100
3
@@ -561,45 +561,22 @@
3
@@ -561,9 +561,16 @@
4
 
4
 
5
 ifeq ($(PLATFORM),freebsd)
5
 ifeq ($(PLATFORM),freebsd)
6
 
6
 
7
-  ifneq (,$(findstring alpha,$(shell uname -m)))
8
-    ARCH=axp
9
-  else #default to i386
10
-    ARCH=i386
11
-  endif #alpha test
12
+  # system integration
7
+  # system integration
13
+  ifndef DEFAULT_LIBDIR
8
+  ifndef DEFAULT_LIBDIR
14
+    DEFAULT_LIBDIR = /usr/local/lib/ioquake3
9
+    DEFAULT_LIBDIR = /usr/local/lib/ioquake3
15
+  endif
10
+  endif
16
 
11
+
17
-  BASE_CFLAGS = -Wall -fno-strict-aliasing -Wimplicit -Wstrict-prototypes \
12
   # flags
18
-    -DUSE_ICON
13
   BASE_CFLAGS = $(shell env MACHINE_ARCH=$(ARCH) make -f /dev/null -VCFLAGS) \
19
+  # flags
14
     -Wall -fno-strict-aliasing -Wimplicit -Wstrict-prototypes \
20
+  BASE_CFLAGS = $(shell env MACHINE_ARCH=$(ARCH) make -f /dev/null -VCFLAGS) \
15
+    -DHOMEPATH=\\\"$(HOMEPATH)\\\" \
21
+    -Wall -fno-strict-aliasing -Wimplicit -Wstrict-prototypes \
22
+    -DDEFAULT_LIBDIR=\\\"$(DEFAULT_LIBDIR)\\\" \
16
+    -DDEFAULT_LIBDIR=\\\"$(DEFAULT_LIBDIR)\\\" \
23
+    -DUSE_ICON -DMAP_ANONYMOUS=MAP_ANON
17
     -DUSE_ICON -DMAP_ANONYMOUS=MAP_ANON
24
   CLIENT_CFLAGS = $(SDL_CFLAGS)
18
   CLIENT_CFLAGS = $(SDL_CFLAGS)
25
   SERVER_CFLAGS = 
19
   SERVER_CFLAGS = 
26
+  HAVE_VM_COMPILED = true
27
 
28
-  ifeq ($(USE_OPENAL),1)
29
-    CLIENT_CFLAGS += -DUSE_OPENAL
30
-    ifeq ($(USE_OPENAL_DLOPEN),1)
31
-      CLIENT_CFLAGS += -DUSE_OPENAL_DLOPEN
32
-    endif
33
-  endif
34
-
35
-  ifeq ($(USE_CODEC_VORBIS),1)
36
-    CLIENT_CFLAGS += -DUSE_CODEC_VORBIS
37
-  endif
38
-
39
-  OPTIMIZEVM = -O3 -funroll-loops -fomit-frame-pointer
40
-
41
-  ifeq ($(ARCH),axp)
42
-    BASE_CFLAGS += -DNO_VM_COMPILED
43
-    OPTIMIZEVM += -fexpensive-optimizations
44
-  else
45
-  ifeq ($(ARCH),i386)
46
-    OPTIMIZEVM += -mtune=pentiumpro \
47
-      -march=pentium -pipe -falign-loops=2 -falign-jumps=2 \
48
-      -falign-functions=2 -funroll-loops -fstrength-reduce
49
-    HAVE_VM_COMPILED=true
50
-  else
51
-    BASE_CFLAGS += -DNO_VM_COMPILED
52
-  endif
53
-  endif
54
-
55
-  OPTIMIZE = $(OPTIMIZEVM) -ffast-math
56
+  OPTIMIZEVM = -O3 -funroll-loops -fomit-frame-pointer -ffast-math
57
+  OPTIMIZE = $(OPTIMIZEVM)
58
 
59
   SHLIBEXT=so
60
   SHLIBCFLAGS=-fPIC
61
@@ -613,17 +590,40 @@
62
 
63
   CLIENT_LIBS += $(SDL_LIBS) -lGL
64
 
65
+  # optional features/libraries
66
   ifeq ($(USE_OPENAL),1)
67
-    ifneq ($(USE_OPENAL_DLOPEN),1)
68
+    CLIENT_CFLAGS += -DUSE_OPENAL
69
+    ifeq ($(USE_OPENAL_DLOPEN),1)
70
+      CLIENT_CFLAGS += -DUSE_OPENAL_DLOPEN
71
       CLIENT_LIBS += $(THREAD_LIBS) -lopenal
72
     endif
73
   endif
74
 
75
+  ifeq ($(USE_CURL),1)
76
+    CLIENT_CFLAGS += -DUSE_CURL
77
+    ifeq ($(USE_CURL_DLOPEN),1)
78
+      CLIENT_CFLAGS += -DUSE_CURL_DLOPEN
79
+      CLIENT_LIBS += -lcurl
80
+    endif
81
+  endif
82
+
83
   ifeq ($(USE_CODEC_VORBIS),1)
84
-    ifeq ($(PLATFORM),mingw32)
85
-      CLIENT_LIBS += $(LIBSDIR)/win32/libvorbisfile.a $(LIBSDIR)/win32/libvorbis.a $(LIBSDIR)/win32/libogg.a
86
-    else
87
-      CLIENT_LIBS += -lvorbisfile -lvorbis -logg
88
+    CLIENT_CFLAGS += -DUSE_CODEC_VORBIS
89
+  endif
90
+
91
+  ifeq ($(USE_CODEC_VORBIS),1)
92
+    CLIENT_LIBS += -lvorbisfile -lvorbis -logg
93
+  endif
94
+
95
+  # cross-compiling tweaks
96
+  ifeq ($(ARCH),i386)
97
+    ifeq ($(CROSS_COMPILING),1)
98
+      BASE_CFLAGS += -m32
99
+    endif
100
+  endif
101
+  ifeq ($(ARCH),amd64)
102
+    ifeq ($(CROSS_COMPILING),1)
103
+      BASE_CFLAGS += -m64
104
     endif
105
   endif
106
 
107
@@ -1555,6 +1555,9 @@
108
   ifeq ($(ARCH),x86_64)
109
     Q3OBJ += $(B)/client/vm_x86_64.o $(B)/client/vm_x86_64_assembler.o
110
   endif
111
+  ifeq ($(ARCH),amd64)
112
+    Q3OBJ += $(B)/client/vm_x86_64.o $(B)/client/vm_x86_64_assembler.o
113
+  endif
114
   ifeq ($(ARCH),ppc)
115
     Q3OBJ += $(B)/client/vm_powerpc.o $(B)/client/vm_powerpc_asm.o
116
   endif
117
@@ -1720,6 +1723,9 @@
118
   ifeq ($(ARCH),x86_64)
119
     Q3DOBJ += $(B)/ded/vm_x86_64.o $(B)/ded/vm_x86_64_assembler.o
120
   endif
121
+  ifeq ($(ARCH),amd64)
122
+    Q3DOBJ += $(B)/ded/vm_x86_64.o $(B)/ded/vm_x86_64_assembler.o
123
+  endif
124
   ifeq ($(ARCH),ppc)
125
     Q3DOBJ += $(B)/ded/vm_powerpc.o $(B)/ded/vm_powerpc_asm.o
126
   endif
(-)openarena/files/patch-code-qcommon-vm_x86.c (+29 lines)
Line 0 Link Here
1
--- code/qcommon/vm_x86.c.orig	2008-08-18 01:22:06.000000000 +0200
2
+++ code/qcommon/vm_x86.c	2010-11-27 14:01:33.000000000 +0100
3
@@ -36,7 +36,25 @@
4
 
5
 /* need this on NX enabled systems (i386 with PAE kernel or
6
  * noexec32=on x86_64) */
7
-#ifdef __linux__
8
+//     Rambetter's note: I'm adding the test for __FreeBSD__ in addition to the [already
9
+// existing] test for __linux__.  Here is why.  I own a 32 bit FreeBSD 8.0 server with
10
+// a PAE kernel.  Without VM_X86_MMAP, ioq3ded segfaults shortly after starting
11
+// (this should come as no surprise).  With VM_X86_MMAP, ioq3ded runs very smoothly.
12
+// So, at a very minimum, we need to set VM_X86_MMAP for FreeBSD PAE kernels.
13
+//     Now, I also happen to own a 32 bit FreeBSD 7.1 server with just the standard kernel
14
+// (non-PAE).  I have run ioq3ded successfully on it with and without VM_X86_MMAP for many
15
+// months.  So, in the case of non-PAE FreeBSD, we can go either way - use VM_X86_MMAP or
16
+// not use it.  The absolute safest fix to this problem is to only set VM_X86_MMAP on
17
+// PAE FreeBSD kernels (in addition to Linux); however, I don't know of a way to detect
18
+// the PAE kernel easily.  Therefore, since using VM_X86_MMAP won't break anything on
19
+// non-PAE kernels [apparently], we'll just use it all the time on FreeBSD 32 bit.
20
+//     Now, you may ask the question: Why not change the entire test for just __unix__?
21
+// Unfortunately I cannot say anything about this because I don't have access to every
22
+// other system that has __unix__ defined, so I cannot possibly test all those cases to
23
+// make sure things work.  We'll just leave it with __linux__ and __FreeBSD__ to be safe.
24
+// If someone with a different flavor of UNIX running a PAE kernel has this problem too,
25
+// they can report the bug and we will adjust the line below accordingly.
26
+#if defined(__linux__) || defined(__FreeBSD__)
27
 #define VM_X86_MMAP
28
 #endif
29
 
(-)openarena-oax/Makefile (-1 / +1 lines)
Lines 6-12 Link Here
6
#
6
#
7
7
8
PORTNAME=	oax
8
PORTNAME=	oax
9
PORTVERSION=	B45
9
PORTVERSION=	B47
10
CATEGORIES=	games
10
CATEGORIES=	games
11
MASTER_SITES=	http://files.poulsander.com/~poul19/public_files/eliminationSource/
11
MASTER_SITES=	http://files.poulsander.com/~poul19/public_files/eliminationSource/
12
DISTNAME=	${PORTNAME}${PORTVERSION}
12
DISTNAME=	${PORTNAME}${PORTVERSION}
(-)openarena-oax/distinfo (-3 / +2 lines)
Lines 1-3 Link Here
1
MD5 (oaxB45.zip) = 395b29a38184100cea7dc3206979770f
1
SHA256 (oaxB47.zip) = 16f4a199621162a09107d043b8edfc9cda70fa432c9351aaa8fd055e94048952
2
SHA256 (oaxB45.zip) = 43f21a45329b549b5a0a967269e50cf89803b5e084598d7fbef726fa63e0aa14
2
SIZE (oaxB47.zip) = 468070
3
SIZE (oaxB45.zip) = 465245
(-)iourbanterror/Makefile (-158 / +31 lines)
Lines 6-178 Link Here
6
#
6
#
7
7
8
PORTNAME=	iourbanterror
8
PORTNAME=	iourbanterror
9
DISTVERSION=	2007_12_20
9
PORTVERSION=	4.1
10
PORTREVISION=	8
10
DISTVERSION=	1.36_SVN${SVNREVISION}+${PORTVERSION}
11
PORTREVISION=	0
12
PORTEPOCH=	1
11
CATEGORIES=	games
13
CATEGORIES=	games
12
MASTER_SITES=	http://ftp.snt.utwente.nl/pub/games/urbanterror/iourbanterror/source/complete/
14
DISTNAME=	ioquake3-devel-1.36_SVN${SVNREVISION}
13
DISTNAME=	ioUrbanTerrorSource_${DISTVERSION}
14
15
15
MAINTAINER=	kamikaze@bsdforen.de
16
MAINTAINER=	kamikaze@bsdforen.de
16
COMMENT=	Quake 3 engine modified for Urban Terror (based on ioquake3)
17
COMMENT=	Quake 3 engine modified for Urban Terror (based on ioquake3)
17
18
18
RUN_DEPENDS=	${Q3DIR}/q3ut4:${PORTSDIR}/games/urbanterror-data
19
RUN_DEPENDS=	${Q3DIR}/q3ut4:${PORTSDIR}/games/urbanterror-data
19
20
20
USE_ZIP=	yes
21
PLIST=		${.CURDIR}/pkg-plist
21
USE_GMAKE=	yes
22
22
ALL_TARGET=	release
23
# The docs belong to ioquake3
23
WRKSRC=		${WRKDIR}/ioUrbanTerrorClientSource
24
NOPORTDOCS=	yes
24
25
25
OPTIONS=	CLIENT "Build client" on \
26
Q3TOTALCONV=	yes
26
		CELLSHADING "Enable Cell Shading effect" off \
27
Q3DIR=		${PREFIX}/share/quake3
27
		CURL "Enable curl support" on \
28
Q3ICON=		${PREFIX}/share/quake3/q3ut4/q3ut.ico
28
		CURL_DLOPEN "Enable dynamic loading of curl" on \
29
Q3CLIENT=	ioUrbanTerror
29
		GAMELIBS "Build game libraries (when not mandatory)" off \
30
Q3SERVER=	ioUrTded
30
		DEDICATED "Build dedicated server" on \
31
Q3TOOLS=
31
		MP3 "Enable MP3 support" off \
32
Q3BASE=		q3ut4
32
		OPENAL "Enable OpenAL (3D sound) support" off \
33
BINSUFFIX=
33
		OPENAL_DLOPEN "Enable dynamic loading of OpenAL" off \
34
HOMEPATH=	/.ioUrbanTerror
34
		OPTIMIZED_CFLAGS "Enable compilation optimizations" on \
35
		SDL_AUDIO "Use SDL for audio" off \
36
		SDL_VIDEO "Use SDL for video" off \
37
		SMP "Build SMP (threaded) client" on \
38
		VORBIS "Enable Ogg Vorbis codec support" off
39
40
MAKE_ENV=	DEFAULT_BASEDIR="${Q3DIR}" LIBDIR="${LIBDIR}" \
41
		PTHREAD_LIBS="${PTHREAD_LIBS}"
42
PLIST_SUB=	LIBDIR="${LIBDIR:S/${PREFIX}\///}"
43
44
LIBDIR=		${PREFIX}/lib/${PORTNAME}
45
VM_ARCHS=	amd64 i386 powerpc
46
47
.include <bsd.port.pre.mk>
48
49
Q3DIR!=		cd ${PORTSDIR}/games/quake3-data && ${MAKE} -V Q3DIR
50
51
.if defined(WITHOUT_CLIENT) && defined(WITHOUT_DEDICATED) && \
52
    defined(WITHOUT_SMP)
53
IGNORE=		needs at least one of CLIENT, DEDICATED and SMP options
54
.endif
55
56
.for i in ${ARCH}
57
.   if ${VM_ARCHS:M${i}} != ""
58
HAVE_VM_COMPILED=	yes
59
.   endif
60
.endfor
61
35
62
.if defined(HAVE_VM_COMPILED)
36
MAKE_ARGS+=	BUILD_MISSIONPACK=0 \
63
MAKE_ENV+=	HAVE_VM_COMPILED=true
37
		BUILD_STANDALONE=1
64
.endif
38
65
39
UTPATCHES!=	echo ${.CURDIR}/files/*
66
.if defined(WITH_CELLSHADING)
67
EXTRA_PATCHES+=	${FILESDIR}/extra-patch-cellshading
68
.endif
69
70
.if !defined(WITHOUT_CLIENT) || !defined(WITHOUT_SMP)
71
# curl
72
.   if defined(WITH_CURL)
73
LIB_DEPENDS+=	curl.6:${PORTSDIR}/ftp/curl
74
MAKE_ENV+=	USE_CURL=1
75
.       if defined(WITH_CURL_DLOPEN)
76
MAKE_ENV+=	USE_CURL_DLOPEN=1
77
.       endif
78
.   endif
79
# OpenAL
80
.   if defined(WITH_OPENAL)
81
USE_OPENAL=	al
82
MAKE_ENV+=	USE_OPENAL=1
83
.       if defined(WITH_OPENAL_DLOPEN)
84
MAKE_ENV+=	USE_OPENAL_DLOPEN=1
85
.       endif
86
.   endif
87
# SDL
88
.   if defined(WITH_SDL_AUDIO)
89
USE_SDL=	sdl
90
MAKE_ENV+=	USE_SDL_AUDIO=1
91
.   endif
92
.   if defined(WITH_SDL_VIDEO)
93
USE_SDL=	sdl
94
MAKE_ENV+=	USE_SDL_VIDEO=1
95
.   else
96
USE_GL=		yes
97
USE_XORG=	xxf86dga
98
.   endif
99
# Vorbis
100
.   if defined(WITH_VORBIS)
101
LIB_DEPENDS+=	vorbis.4:${PORTSDIR}/audio/libvorbis
102
MAKE_ENV+=	USE_CODEC_VORBIS=1
103
.   endif
104
.endif
105
106
.if !defined(WITHOUT_CLIENT)
107
MAKE_ENV+=	BUILD_CLIENT=1
108
PLIST_SUB+=	CLIENT=""
109
Q3BIN+=		ioUrbanTerror
110
.else
111
PLIST_SUB+=	CLIENT="@comment "
112
.endif
113
114
.if !defined(WITHOUT_DEDICATED)
115
MAKE_ENV+=	BUILD_SERVER=1
116
PLIST_SUB+=	DEDICATED=""
117
Q3BIN+=		ioUrTded
118
.else
119
PLIST_SUB+=	DEDICATED="@comment "
120
.endif
121
122
.if defined(WITH_GAMELIBS) || !defined(HAVE_VM_COMPILED)
123
MAKE_ENV+=	BUILD_GAME_SO=1
124
PLIST_SUB+=	GAMELIBS=""
125
.else
126
PLIST_SUB+=	GAMELIBS="@comment "
127
.endif
128
129
.if defined(WITH_MP3)
130
EXTRA_PATCHES+=	${FILESDIR}/extra-patch-mp3
131
LIB_DEPENDS+=	mad.2:${PORTSDIR}/audio/libmad
132
MAKE_ENV+=	USE_CODEC_MP3=1
133
.endif
134
135
.if !defined(WITHOUT_OPTIMIZED_CFLAGS)
136
MAKE_ENV+=	USE_OPTIMIZED_CFLAGS=1
137
.endif
138
139
.if !defined(WITHOUT_SMP)
140
MAKE_ENV+=	BUILD_CLIENT_SMP=1
141
PLIST_SUB+=	SMP=""
142
Q3BIN+=		ioUrbanTerror-smp
143
.else
144
PLIST_SUB+=	SMP="@comment "
145
.endif
146
40
147
post-patch:
41
post-patch:
148
# There are new variables in the config files, so keep them in another dir.
42
.for _file in ${UTPATCHES}
149
	@${REINPLACE_CMD} -E 's|/\.q3a|/.ioUrbanTerror|' \
43
	@${PATCH} -sd "${WRKSRC}" < ${_file}
150
		${WRKSRC}/code/unix/unix_shared.c
151
# Fix wrong library version (use general case as only one is installed).
152
.if defined(WITH_CURL_DLOPEN)
153
	@${REINPLACE_CMD} -e 's|libcurl\.so\.[[:digit:]]|libcurl.so|' \
154
		${WRKSRC}/code/client/cl_curl.h
155
.endif
156
157
do-install:
158
.for bin in ${Q3BIN}
159
	${INSTALL_PROGRAM} ${WRKSRC}/build/release/${bin} ${PREFIX}/bin
160
.endfor
161
.if defined(WITH_GAMELIBS) || !defined(HAVE_VM_COMPILED)
162
.for dir in baseq3 missionpack
163
	${MKDIR} ${LIBDIR}/${dir}
164
	${INSTALL_PROGRAM} ${WRKSRC}/build/release/${dir}/*.so ${LIBDIR}/${dir}
165
.endfor
44
.endfor
166
.endif
45
	@${REINPLACE_CMD} \
167
.if !defined(NOPORTDOCS)
46
		-e 's/ioquake3/${Q3CLIENT}/g' \
168
	${MKDIR} ${DOCSDIR}
47
		-e 's/ioq3ded/${Q3SERVER}/g' \
169
	${INSTALL_DATA} ${WRKDIR}/ioUrbanTerror_README.txt \
48
		-e 's/baseq3/${Q3BASE}/g' \
170
		${WRKSRC}/README ${DOCSDIR}
49
		"${WRKSRC}/Makefile"
171
.endif
172
173
post-install:
174
	@${ECHO_CMD}
175
	@${CAT} ${PKGMESSAGE}
176
	@${ECHO_CMD}
177
50
178
.include <bsd.port.post.mk>
51
.include "../ioquake3-devel/Makefile"
(-)iourbanterror/distinfo (-3 / +2 lines)
Lines 1-3 Link Here
1
MD5 (ioUrbanTerrorSource_2007_12_20.zip) = 4dbe5a03a10f23138f42b5e0dc39598b
1
SHA256 (ioquake3-devel-1.36_SVN1803.zip) = 2d73b8f4818c7f82adc2f28308e7a6bdca7f3b5e9db0fbbfa5c34e2569a386da
2
SHA256 (ioUrbanTerrorSource_2007_12_20.zip) = 96d58662852d31fa6ab03431120328dab7f36bf60010a2cfdc1b427d6ac23ce8
2
SIZE (ioquake3-devel-1.36_SVN1803.zip) = 4930935
3
SIZE (ioUrbanTerrorSource_2007_12_20.zip) = 17284593
(-)iourbanterror/files/extra-patch-cellshading (-933 lines)
Lines 1-933 Link Here
1
Index: code/renderer/tr_image.c
2
===================================================================
3
--- code/renderer/tr_image.c	(revision 933)
4
+++ code/renderer/tr_image.c	(working copy)
5
@@ -34,7 +34,24 @@
6
 #define JPEG_INTERNALS
7
 #include "../jpeg-6/jpeglib.h"
8
 
9
+/**
10
+ * Headers for cell shading
11
+ * @author Jordi Prats Catala
12
+ * @author Guillermo Miranda Alamo
13
+ */
14
+/*
15
+byte getImageR(byte *targa_rgba, int x, int y, int columns, int rows);
16
+byte getImageG(byte *targa_rgba, int x, int y, int columns, int rows);
17
+byte getImageB(byte *targa_rgba, int x, int y, int columns, int rows);
18
+byte getImageA(byte *targa_rgba, int x, int y, int columns, int rows);
19
+void setImageR(byte *targa_rgba, int x, int y, int columns, int rows, byte value);
20
+void setImageG(byte *targa_rgba, int x, int y, int columns, int rows, byte value);
21
+void setImageB(byte *targa_rgba, int x, int y, int columns, int rows, byte value);
22
+void setImageA(byte *targa_rgba, int x, int y, int columns, int rows, byte value);
23
+*/
24
+//void kuwahara(int columns, int rows, byte *targa_rgba);
25
 
26
+
27
 static void LoadBMP( const char *name, byte **pic, int *width, int *height );
28
 static void LoadTGA( const char *name, byte **pic, int *width, int *height );
29
 static void LoadJPG( const char *name, byte **pic, int *width, int *height );
30
@@ -799,7 +816,643 @@
31
 	return image;
32
 }
33
 
34
+/****************************
35
+RGB GET/SET
36
+****************************/
37
 
38
+//RED
39
+static byte getImageR(byte *targa_rgba, int x, int y, int columns, int rows)
40
+{
41
+	byte	*pixbuf;
42
+	
43
+	x*=((x<0)?-1:1);
44
+	y*=((y<0)?-1:1);
45
+  if(rows<=y)
46
+		y=y%rows;
47
+  if(columns<=x)
48
+		x=x%columns;
49
+	x*=((x<0)?-1:1);
50
+	y*=((y<0)?-1:1);
51
+  
52
+	
53
+	pixbuf = targa_rgba + y*columns*4;
54
+	
55
+	pixbuf+=(x*4);
56
+	
57
+	return *pixbuf;
58
+}
59
+
60
+static void setImageR(byte *targa_rgba, int x, int y, int columns, int rows, byte value)
61
+{
62
+	byte	*pixbuf;
63
+	
64
+	x*=((x<0)?-1:1);
65
+	y*=((y<0)?-1:1);
66
+	
67
+	pixbuf = targa_rgba + y*columns*4;
68
+	
69
+	pixbuf+=(x*4);
70
+	
71
+	*pixbuf=value;
72
+}
73
+//GREEN
74
+static byte getImageG(byte *targa_rgba, int x, int y, int columns, int rows)
75
+{
76
+	byte	*pixbuf;
77
+	
78
+	x*=((x<0)?-1:1);
79
+	y*=((y<0)?-1:1);
80
+  if(rows<=y)
81
+		y=y%rows;
82
+  if(columns<=x)
83
+		x=x%columns;
84
+	x*=((x<0)?-1:1);
85
+	y*=((y<0)?-1:1);
86
+	
87
+	pixbuf = targa_rgba + y*columns*4;
88
+	
89
+	pixbuf+=(x*4);
90
+	
91
+	pixbuf++;
92
+	return *pixbuf;
93
+}
94
+
95
+static void setImageG(byte *targa_rgba, int x, int y, int columns, int rows, byte value)
96
+{
97
+	byte	*pixbuf;
98
+
99
+	x*=((x<0)?-1:1);
100
+	y*=((y<0)?-1:1);
101
+
102
+	pixbuf = targa_rgba + y*columns*4;
103
+	
104
+	pixbuf+=(x*4);
105
+	pixbuf++;
106
+	*pixbuf=value;
107
+}
108
+//BLUE
109
+static byte getImageB(byte *targa_rgba, int x, int y, int columns, int rows)
110
+{
111
+	byte	*pixbuf;
112
+	
113
+	x*=((x<0)?-1:1);
114
+	y*=((y<0)?-1:1);
115
+  if(rows<=y)
116
+		y=y%rows;
117
+  if(columns<=x)
118
+		x=x%columns;
119
+	x*=((x<0)?-1:1);
120
+	y*=((y<0)?-1:1);
121
+	
122
+	pixbuf = targa_rgba + y*columns*4;
123
+	
124
+	pixbuf+=(x*4);
125
+	pixbuf+=2;
126
+	return *pixbuf;
127
+}
128
+
129
+static void setImageB(byte *targa_rgba, int x, int y, int columns, int rows, byte value)
130
+{
131
+	byte	*pixbuf;
132
+	
133
+	x*=((x<0)?-1:1);
134
+	y*=((y<0)?-1:1);
135
+	
136
+	pixbuf = targa_rgba + y*columns*4;
137
+	
138
+	pixbuf+=(x*4);
139
+	pixbuf+=2;
140
+	*pixbuf=value;
141
+}
142
+//ALPHA
143
+static byte getImageA(byte *targa_rgba, int x, int y, int columns, int rows)
144
+{
145
+	byte	*pixbuf;
146
+	
147
+	x*=((x<0)?-1:1);
148
+	y*=((y<0)?-1:1);
149
+	
150
+	pixbuf = targa_rgba + y*columns*4;
151
+	
152
+	pixbuf+=(x*4);
153
+	pixbuf+=3;
154
+	return *pixbuf;
155
+}
156
+
157
+static void setImageA(byte *targa_rgba, int x, int y, int columns, int rows, byte value)
158
+{
159
+	byte	*pixbuf;
160
+	
161
+	x*=((x<0)?-1:1);
162
+	y*=((y<0)?-1:1);
163
+	
164
+	pixbuf = targa_rgba + y*columns*4;
165
+	
166
+	pixbuf+=(x*4);
167
+	pixbuf+=3;
168
+	*pixbuf=value;
169
+}
170
+
171
+//RGB
172
+static void getImageRGB(byte *targa_rgba, int x, int y, int columns, int rows, vec3_t rgb)
173
+{
174
+	byte	*pixbuf;
175
+	
176
+	x*=((x<0)?-1:1);
177
+	y*=((y<0)?-1:1);
178
+  //if(rows<=y)
179
+	y=y%rows;
180
+  //if(columns<=x)
181
+	x=x%columns;
182
+	//x*=((x<0)?-1:1);
183
+	//y*=((y<0)?-1:1);
184
+	
185
+	pixbuf = targa_rgba + y*columns*4 + x*4;
186
+	
187
+	rgb[0]=*pixbuf;
188
+	rgb[1]=*(pixbuf+1);
189
+	rgb[2]=*(pixbuf+2);
190
+}
191
+
192
+static void setImageRGB(byte *targa_rgba, int x, int y, int columns, int rows, vec3_t rgb)
193
+{
194
+	byte	*pixbuf;
195
+	
196
+	//x*=((x<0)?-1:1);
197
+	//y*=((y<0)?-1:1);
198
+	
199
+	pixbuf = targa_rgba + y*columns*4 + (x*4);
200
+	
201
+	*pixbuf=(byte)(rgb[0]);
202
+	*(pixbuf+1)=(byte)(rgb[1]);
203
+	*(pixbuf+2)=(byte)(rgb[2]);
204
+}
205
+
206
+/****************************
207
+NO BRAINER'S BLUR
208
+****************************/
209
+static void blur(int columns, int rows, byte *targa_rgba)
210
+{
211
+	int		row, column;
212
+	float sum;
213
+	
214
+	
215
+		for(row=0; row<rows; row++) 
216
+		{
217
+			//pixbuf = targa_rgba + row*columns*4;
218
+			for(column=0; column<columns; column++) 
219
+			{
220
+				sum=0;
221
+				sum+=getImageR(targa_rgba,column-1,row-1,columns,rows);
222
+				sum+=getImageR(targa_rgba,column,row-1,columns,rows);
223
+				sum+=getImageR(targa_rgba,column+1,row-1,columns,rows);
224
+				sum+=getImageR(targa_rgba,column-1,row,columns,rows);
225
+				sum+=getImageR(targa_rgba,column,row,columns,rows);
226
+				sum+=getImageR(targa_rgba,column+1,row,columns,rows);
227
+				sum+=getImageR(targa_rgba,column-1,row+1,columns,rows);
228
+				sum+=getImageR(targa_rgba,column,row+1,columns,rows);
229
+				sum+=getImageR(targa_rgba,column+1,row+1,columns,rows);
230
+				
231
+				sum/=9.0f;
232
+				
233
+				setImageR(targa_rgba, column, row, columns, rows, (byte)sum);
234
+				////////////////////
235
+				sum=0;
236
+				sum+=getImageG(targa_rgba,column-1,row-1,columns,rows);
237
+				sum+=getImageG(targa_rgba,column,row-1,columns,rows);
238
+				sum+=getImageG(targa_rgba,column+1,row-1,columns,rows);
239
+				sum+=getImageG(targa_rgba,column-1,row,columns,rows);
240
+				sum+=getImageG(targa_rgba,column,row,columns,rows);
241
+				sum+=getImageG(targa_rgba,column+1,row,columns,rows);
242
+				sum+=getImageG(targa_rgba,column-1,row+1,columns,rows);
243
+				sum+=getImageG(targa_rgba,column,row+1,columns,rows);
244
+				sum+=getImageG(targa_rgba,column+1,row+1,columns,rows);
245
+				
246
+				sum/=9.0f;
247
+				
248
+				setImageG(targa_rgba, column, row, columns, rows, (byte)sum);
249
+				////////////////////////
250
+				sum=0;
251
+				sum+=getImageB(targa_rgba,column-1,row-1,columns,rows);
252
+				sum+=getImageB(targa_rgba,column,row-1,columns,rows);
253
+				sum+=getImageB(targa_rgba,column+1,row-1,columns,rows);
254
+				sum+=getImageB(targa_rgba,column-1,row,columns,rows);
255
+				sum+=getImageB(targa_rgba,column,row,columns,rows);
256
+				sum+=getImageB(targa_rgba,column+1,row,columns,rows);
257
+				sum+=getImageB(targa_rgba,column-1,row+1,columns,rows);
258
+				sum+=getImageB(targa_rgba,column,row+1,columns,rows);
259
+				sum+=getImageB(targa_rgba,column+1,row+1,columns,rows);
260
+				
261
+				sum/=9.0f;
262
+				
263
+				setImageB(targa_rgba, column, row, columns, rows, (byte)sum);
264
+				
265
+				// "halftoning"
266
+				/*if((row%5==0)&&(column%5==1))
267
+				{
268
+					gris=0;
269
+					gris+=red;
270
+					gris+=green;
271
+					gris+=blue;
272
+					gris/=3;
273
+					
274
+					gris=255-gris;
275
+					if(gris<0)
276
+						gris=0;
277
+						
278
+						setImageR(targa_rgba, column, row, columns, rows, (byte)gris);
279
+						setImageG(targa_rgba, column, row, columns, rows, (byte)gris);
280
+						setImageB(targa_rgba, column, row, columns, rows, (byte)gris);
281
+					
282
+				}*/
283
+			
284
+			}
285
+		}
286
+
287
+}
288
+
289
+
290
+/****************************
291
+COLORED LIGHTMAP
292
+****************************/
293
+void whiteTextureOne(int columns, int rows, byte *targa_rgba){
294
+	//byte	*pixbyf;
295
+	int		row, column;
296
+	long	rMean=0, gMean=0, bMean=0;
297
+	int		pixels=0;
298
+
299
+	for(row=0;row<rows;row++){
300
+		for(column=0;column<columns;column++){
301
+			// Don't count fully transparent pixels
302
+			if(getImageA(targa_rgba,column,row,columns,rows)==0)
303
+				continue;
304
+			// Sum pixels values
305
+			rMean+=getImageR(targa_rgba,column,row,columns,rows);
306
+			gMean+=getImageG(targa_rgba,column,row,columns,rows);
307
+			bMean+=getImageB(targa_rgba,column,row,columns,rows);
308
+			pixels++;
309
+		}
310
+	}
311
+
312
+	// Calculate average
313
+	if(pixels>0){
314
+		rMean=((float)rMean/(float)pixels);
315
+		gMean=((float)gMean/(float)pixels);
316
+		bMean=((float)bMean/(float)pixels);
317
+	}
318
+	else{
319
+		return;
320
+	}
321
+
322
+	for(row=0;row<rows;row++){
323
+		for(column=0;column<columns;column++){
324
+			if(getImageA(targa_rgba,column,row,columns,rows)<32)
325
+				continue;
326
+			setImageR(targa_rgba,column,row,columns,rows,rMean);
327
+			setImageG(targa_rgba,column,row,columns,rows,gMean);
328
+			setImageB(targa_rgba,column,row,columns,rows,bMean);
329
+		}
330
+	}
331
+}
332
+
333
+int diffSquare(int mean, int val){
334
+	float variance = (val-mean)/255.0f;
335
+	float radius = mean<128?mean:255-mean;
336
+	return mean+(radius*variance);
337
+}
338
+
339
+/****************************
340
+DECONTRAST
341
+****************************/
342
+void whiteTextureTwo(int columns, int rows, byte *targa_rgba){
343
+	int		row, column;
344
+	long	rMean=0, gMean=0, bMean=0;
345
+	int r=0, g=0, b=0;
346
+	int		pixels=0;
347
+
348
+	
349
+	for(row=0;row<rows;row++){
350
+		for(column=0;column<columns;column++){
351
+			// Don't count fully transparent pixels
352
+			if(getImageA(targa_rgba,column,row,columns,rows)<32)
353
+				continue;
354
+			// Sum pixels values
355
+			rMean+=getImageR(targa_rgba,column,row,columns,rows);
356
+			gMean+=getImageG(targa_rgba,column,row,columns,rows);
357
+			bMean+=getImageB(targa_rgba,column,row,columns,rows);
358
+			pixels++;
359
+		}
360
+	}
361
+
362
+	// Calculate average
363
+	if(pixels>0){
364
+		rMean=rMean/pixels;
365
+		gMean=gMean/pixels;
366
+		bMean=bMean/pixels;
367
+	}
368
+	else{
369
+		return;
370
+	}
371
+	
372
+
373
+	for(row=0;row<rows;row++){
374
+		for(column=0;column<columns;column++){
375
+			if(getImageA(targa_rgba,column,row,columns,rows)<32)
376
+				continue;
377
+			r=getImageR(targa_rgba,column,row,columns,rows);
378
+			g=getImageG(targa_rgba,column,row,columns,rows);
379
+			b=getImageB(targa_rgba,column,row,columns,rows);
380
+			
381
+			setImageR(targa_rgba,column,row,columns,rows,diffSquare(rMean,r));
382
+			setImageG(targa_rgba,column,row,columns,rows,diffSquare(gMean,g));
383
+			setImageB(targa_rgba,column,row,columns,rows,diffSquare(bMean,b));
384
+			
385
+		}
386
+	}
387
+}
388
+
389
+/****************************
390
+KUWAHARA ,FAILS SOMEWHERE
391
+****************************/
392
+#define KWH_RADIUS 2
393
+static void mean_variance(int x0, int y0, int x1, int y1, int columns, int rows, byte *targa_rgba, vec4_t mv )
394
+{
395
+	short min=255*3, max=0;
396
+	unsigned short count= 0;
397
+	short row, column;
398
+	unsigned short value;
399
+	vec3_t rgb;
400
+	
401
+	mv[0]=mv[1]=mv[2]=mv[3]=0;
402
+
403
+	for(row=y0;row<=y1;row++)
404
+	{
405
+		for(column=x0;column<=x1;column++)
406
+		{
407
+			getImageRGB(targa_rgba,column,row,columns,rows,rgb);
408
+			
409
+			VectorAdd(mv,rgb,mv);
410
+			
411
+			count++;
412
+			value=rgb[0]+rgb[1]+rgb[2];
413
+			if(value<min) min=value;
414
+			if(value>max) max=value;
415
+		}
416
+	}
417
+
418
+	mv[0]/=count;
419
+	mv[1]/=count;
420
+	mv[2]/=count;
421
+	mv[3]= (max-min)/3.0f;
422
+}
423
+
424
+
425
+static void rgb_kuwahara(int x, int y, int columns, int rows, byte *targa_rgba, vec4_t bmv)
426
+{
427
+  vec4_t mv;
428
+	bmv[0]=bmv[1]=bmv[2]=bmv[3]=255;
429
+	
430
+	mean_variance(x-KWH_RADIUS, y-KWH_RADIUS, x, y, columns, rows, targa_rgba, mv);
431
+	if( mv[3] < bmv[3] )
432
+	{
433
+		Vector4Copy(mv,bmv);
434
+	}
435
+	
436
+	mean_variance(x, y-KWH_RADIUS, x+KWH_RADIUS, y, columns, rows, targa_rgba, mv);
437
+	if( mv[3] < bmv[3] )
438
+	{
439
+		Vector4Copy(mv,bmv);
440
+	}
441
+	
442
+	mean_variance(x, y, x+KWH_RADIUS, y+KWH_RADIUS, columns, rows, targa_rgba, mv);
443
+	if( mv[3] < bmv[3] )
444
+	{
445
+		Vector4Copy(mv,bmv);
446
+	}
447
+	
448
+	mean_variance(x-KWH_RADIUS, y, x, y+KWH_RADIUS, columns, rows, targa_rgba, mv);
449
+	if( mv[3] < bmv[3] )
450
+	{
451
+		Vector4Copy(mv,bmv);
452
+	}
453
+}
454
+
455
+static void kuwahara(int columns, int rows, byte *targa_rgba){
456
+	int		row, column;
457
+	vec4_t rgbv;
458
+	
459
+	for(row=0;row<rows;row++){
460
+		for(column=0;column<columns;column++){
461
+			rgb_kuwahara(column, row, columns, rows, targa_rgba, rgbv);
462
+			setImageRGB(targa_rgba,column,row,columns,rows,rgbv);
463
+		}
464
+	}
465
+}
466
+
467
+
468
+#define FLT_MAX		3.40282346638528860000e+38
469
+static void kuwahara3(int columns, int rows, byte *targa_rgba)
470
+{
471
+	byte channel;
472
+	int size = 10;
473
+	int index1,index2;
474
+	int width = columns-4;
475
+	int height = rows-4;
476
+	int size2 = (size+1)/2;
477
+	int offset = (size-1)/2;
478
+	const int width2 = columns + offset;
479
+	const int height2 = rows + offset;
480
+	int x1start = 4;
481
+	int y1start = 4;
482
+	int x2, y2;
483
+	int sum, sum2, n, v=0, xbase, ybase;
484
+	int y1,x1;
485
+	int xbase2=0, ybase2=0;
486
+	float var, min;
487
+	float** mean, **variance;
488
+
489
+	//blur(columns, rows, targa_rgba);
490
+
491
+	// I hate malloc I hate malloc I hate malloc I hate malloc I hate malloc I hate malloc 
492
+	mean = (float**)malloc(sizeof(float*)*width2);
493
+	for(index1=0;index1<width2;index1++)
494
+		mean[index1] = (float*)malloc(sizeof(float)*height2);
495
+
496
+	variance = (float**)malloc(sizeof(float*)*width2);
497
+	for(index2=0;index2<width2;index2++)
498
+		variance[index2] = (float*)malloc(sizeof(float)*height2);
499
+
500
+	// For each channel (R,G,B)
501
+	// for(channel=0;channel<2;channel++)
502
+	// FTL
503
+	for(channel=0;channel<3;channel++){
504
+		for (y1=y1start-offset; y1<y1start+height; y1++) {
505
+
506
+			for (x1=x1start-offset; x1<x1start+width; x1++) {
507
+				sum=0; sum2=0; n=0;
508
+				for (x2=x1; x2<x1+size2; x2++) {
509
+					for (y2=y1; y2<y1+size2; y2++) {
510
+						//v = i(x2, y2);
511
+						switch(channel){
512
+							case 0:
513
+								v = getImageR(targa_rgba,x2,y2,columns,rows);
514
+								break;
515
+							case 1:
516
+								v = getImageG(targa_rgba,x2,y2,columns,rows);
517
+								break;
518
+							case 2:
519
+								v = getImageB(targa_rgba,x2,y2,columns,rows);
520
+								break;
521
+						}
522
+						//v = *targa_rgba + y2*columns*4+x2*4;
523
+						v/=10;
524
+						v*=10;
525
+						sum += v;
526
+						sum2 += v*v;
527
+						n++;
528
+					}
529
+				}
530
+				//cerr << "Accedo" << endl;
531
+				mean[x1+offset][y1+offset] = (float)(sum/n);
532
+				variance[x1+offset][y1+offset] = (float)((n*sum2-sum*sum)/n);
533
+			}
534
+		}
535
+
536
+		for (y1=y1start; y1<y1start+height; y1++) {
537
+			/*if ((y1%20)==0)
538
+				cout << (0.7+0.3*(y1-y1start)/height);*/
539
+			for (x1=x1start; x1<x1start+width; x1++) {
540
+				min =  FLT_MAX;
541
+				xbase = x1; ybase=y1;
542
+				var = variance[xbase][ybase];
543
+				if (var<min){
544
+					min= var;
545
+					xbase2=xbase;
546
+					ybase2=ybase;
547
+				}
548
+				xbase = x1+offset;
549
+				var = variance[xbase][ybase];
550
+				if (var<min){
551
+					min= var;
552
+					xbase2=xbase;
553
+					ybase2=ybase;
554
+				}
555
+				ybase = y1+offset;
556
+				var = variance[xbase][ybase];
557
+				if (var<min){
558
+					min= var;
559
+					xbase2=xbase;
560
+					ybase2=ybase;
561
+				}
562
+				xbase = x1;
563
+				var = variance[xbase][ybase];
564
+				if (var<min){
565
+					min= var;
566
+					xbase2=xbase;
567
+					ybase2=ybase;
568
+				}
569
+				//i(x1, y1)=(int)(mean[xbase2][ybase2]+0.5);
570
+				switch(channel){
571
+					case 0:
572
+						setImageR(targa_rgba,x1,y1,columns,rows,(byte)(mean[xbase2][ybase2]+0.5));
573
+						break;
574
+					case 1:
575
+						setImageG(targa_rgba,x1,y1,columns,rows,(byte)(mean[xbase2][ybase2]+0.5));
576
+						break;
577
+					case 2:
578
+						setImageB(targa_rgba,x1,y1,columns,rows,(byte)(mean[xbase2][ybase2]+0.5));
579
+						break;
580
+				}
581
+			}
582
+		}
583
+	}
584
+	// Fuck mean & variance, this is hell (!+) Bad Religion
585
+	for(index1=0;index1<width2;index1++)
586
+		free(mean[index1]);
587
+	free(mean);
588
+
589
+	for(index2=0;index2<width2;index2++)
590
+		free(variance[index2]);
591
+	free(variance);
592
+	
593
+	//blur(columns, rows, targa_rgba);  
594
+}
595
+
596
+/****************************
597
+Symmetric Nearest Neighbour
598
+****************************/
599
+
600
+#define SNN_RADIUS 3
601
+
602
+static int deltaE(int l1,int a1,int b1,int l2,int a2,int b2)
603
+{
604
+	return (l1-l2)*(l1-l2) + (a1-a2)*(a1-a2) + (b1-b2)*(b1-b2);
605
+}
606
+
607
+static void snn(int columns, int rows, byte *targa_rgba)
608
+{
609
+	
610
+	int row, column;
611
+	unsigned short sumR, sumG, sumB;
612
+	unsigned short count;
613
+	short u, v;
614
+	byte r, g, b;
615
+	byte r1, g1, b1;
616
+	byte r2, g2, b2;
617
+	for(row=0;row<rows;row++){
618
+		for(column=0;column<columns;column++){
619
+			sumR=0;
620
+			sumG=0;
621
+			sumB=0;
622
+			count=0;
623
+			
624
+			r=getImageR(targa_rgba,column,row,columns,rows);
625
+			g=getImageG(targa_rgba,column,row,columns,rows);
626
+			b=getImageB(targa_rgba,column,row,columns,rows);
627
+			
628
+			for(v=-SNN_RADIUS;v<=0;v++)
629
+			{
630
+				for(u=-SNN_RADIUS;u<=SNN_RADIUS;u++)
631
+				{
632
+					if(v==0&&u>=0) break;
633
+					// Sum pixels values
634
+					r1=getImageR(targa_rgba,column+u,row+v,columns,rows);
635
+					g1=getImageG(targa_rgba,column+u,row+v,columns,rows);
636
+					b1=getImageB(targa_rgba,column+u,row+v,columns,rows);
637
+					
638
+					r2=getImageR(targa_rgba,column-u,row-v,columns,rows);
639
+					g2=getImageG(targa_rgba,column-u,row-v,columns,rows);
640
+					b2=getImageB(targa_rgba,column-u,row-v,columns,rows);
641
+					
642
+					if ( deltaE(r,g,b,r1,g1,b1) < deltaE(r,g,b,r2,g2,b2))
643
+					{
644
+						sumR += r1;
645
+						sumG += g1;
646
+						sumB += b1;
647
+					}
648
+					else
649
+					{
650
+						sumR += r2;
651
+						sumG += g2;
652
+						sumB += b2;
653
+					}
654
+					count++;
655
+				}
656
+			}
657
+			
658
+			r=(byte)((int)(2*sumR+r)/(int)(2*count+1));
659
+			g=(byte)((int)(2*sumG+g)/(int)(2*count+1));
660
+			b=(byte)((int)(2*sumB+b)/(int)(2*count+1));
661
+			
662
+			setImageR(targa_rgba,column,row,columns,rows,r);
663
+			setImageG(targa_rgba,column,row,columns,rows,g);
664
+			setImageB(targa_rgba,column,row,columns,rows,b);
665
+		}
666
+	}
667
+}
668
+
669
+
670
+
671
 /*
672
 =========================================================
673
 
674
@@ -1968,6 +2621,50 @@
675
 	} else if ( !Q_stricmp( name+len-4, ".jpg" ) ) {
676
 		LoadJPG( name, pic, width, height );
677
 	}
678
+
679
+	switch(r_celshadalgo->integer)
680
+	{
681
+		case 1:
682
+			whiteTextureOne(*width,*height,*pic);
683
+			break;
684
+		case 2:
685
+			whiteTextureTwo(*width,*height,*pic);
686
+			break;
687
+		case 10:
688
+			kuwahara(*width,*height,*pic);
689
+			break;
690
+		case 11:
691
+			blur(*width,*height,*pic);
692
+			kuwahara(*width,*height,*pic);
693
+			break;
694
+		case 12:
695
+			kuwahara(*width,*height,*pic);
696
+			blur(*width,*height,*pic);
697
+			break;
698
+		case 13:
699
+			blur(*width,*height,*pic);
700
+			kuwahara(*width,*height,*pic);
701
+			blur(*width,*height,*pic);
702
+			break;
703
+		case 20:
704
+			snn(*width,*height,*pic);
705
+			break;
706
+		case 21:
707
+			blur(*width,*height,*pic);
708
+			snn(*width,*height,*pic);
709
+			break;
710
+		case 22:
711
+			snn(*width,*height,*pic);
712
+			blur(*width,*height,*pic);
713
+			break;
714
+		case 23:
715
+			blur(*width,*height,*pic);
716
+			snn(*width,*height,*pic);
717
+			blur(*width,*height,*pic);
718
+			break;
719
+		default:
720
+			break;
721
+	}
722
 }
723
 
724
 
725
Index: code/renderer/tr_init.c
726
===================================================================
727
--- code/renderer/tr_init.c	(revision 933)
728
+++ code/renderer/tr_init.c	(working copy)
729
@@ -111,6 +111,10 @@
730
 cvar_t	*r_roundImagesDown;
731
 cvar_t	*r_colorMipLevels;
732
 cvar_t	*r_picmip;
733
+// Next one added for cell shading algorithm selection
734
+cvar_t	*r_celshadalgo;
735
+//. next one for enable/disable cel bordering all together.
736
+cvar_t	*r_celoutline;
737
 cvar_t	*r_showtris;
738
 cvar_t	*r_showsky;
739
 cvar_t	*r_shownormals;
740
@@ -1110,6 +1114,10 @@
741
 	r_debugSurface = ri.Cvar_Get ("r_debugSurface", "0", CVAR_CHEAT);
742
 	r_nobind = ri.Cvar_Get ("r_nobind", "0", CVAR_CHEAT);
743
 	r_showtris = ri.Cvar_Get ("r_showtris", "0", CVAR_CHEAT);
744
+	// for cell shading algorithm selection
745
+	r_celshadalgo = ri.Cvar_Get ("r_celshadalgo", "1", CVAR_LATCH);
746
+	// cel outline option
747
+	r_celoutline = ri.Cvar_Get("r_celoutline","1", CVAR_ARCHIVE);
748
 	r_showsky = ri.Cvar_Get ("r_showsky", "0", CVAR_CHEAT);
749
 	r_shownormals = ri.Cvar_Get ("r_shownormals", "0", CVAR_CHEAT);
750
 	r_clear = ri.Cvar_Get ("r_clear", "0", CVAR_CHEAT);
751
Index: code/renderer/tr_local.h
752
===================================================================
753
--- code/renderer/tr_local.h	(revision 933)
754
+++ code/renderer/tr_local.h	(working copy)
755
@@ -1063,6 +1063,8 @@
756
 extern	cvar_t	*r_uiFullScreen;				// ui is running fullscreen
757
 
758
 extern	cvar_t	*r_logFile;						// number of frames to emit GL logs
759
+extern	cvar_t	*r_celshadalgo;					// Cell shading, chooses method: 0 = disabled, 1 = kuwahara, 2 = whiteTexture
760
+extern	cvar_t	*r_celoutline;						//. cel outline. 1 on, 0 off. (maybe other options later)
761
 extern	cvar_t	*r_showtris;					// enables wireframe rendering of the world
762
 extern	cvar_t	*r_showsky;						// forces sky in front of all surfaces
763
 extern	cvar_t	*r_shownormals;					// draws wireframe normals
764
Index: code/renderer/tr_shade.c
765
===================================================================
766
--- code/renderer/tr_shade.c	(revision 933)
767
+++ code/renderer/tr_shade.c	(working copy)
768
@@ -201,6 +201,86 @@
769
 }
770
 
771
 
772
+//R_DRAWCEL
773
+static void R_DrawCel( int numIndexes, const glIndex_t *indexes ) {
774
+	int		primitives;
775
+	
776
+	if(
777
+		//. ignore the 2d projection. do i smell the HUD?
778
+		(backEnd.projection2D == qtrue) ||
779
+		//. ignore general entitites that are sprites. SEE NOTE #3.
780
+		(backEnd.currentEntity->e.reType == RT_SPRITE) ||
781
+		//. ignore these liquids. why? ever see liquid with tris on the surface? exactly. SEE NOTE #4.
782
+		(tess.shader->contentFlags & (CONTENTS_WATER | CONTENTS_LAVA | CONTENTS_SLIME | CONTENTS_FOG)) ||
783
+		//. ignore things that are two sided, meaning mostly things that have transparency. SEE NOTE #1.		
784
+		(tess.shader->cullType == CT_TWO_SIDED)
785
+		
786
+		) {
787
+		return;
788
+	}
789
+
790
+	primitives = r_primitives->integer;
791
+
792
+	// default is to use triangles if compiled vertex arrays are present
793
+	if ( primitives == 0 ) {
794
+		if ( qglLockArraysEXT ) {
795
+			primitives = 2;
796
+		} else {
797
+			primitives = 1;
798
+		}
799
+	}
800
+
801
+	//. correction for mirrors. SEE NOTE #2.
802
+	if(backEnd.viewParms.isMirror == qtrue) { qglCullFace (GL_FRONT); }
803
+	else { qglCullFace (GL_BACK); }	
804
+
805
+	qglEnable (GL_BLEND);
806
+	qglBlendFunc (GL_SRC_ALPHA ,GL_ONE_MINUS_SRC_ALPHA);
807
+	qglColor3f (0.0f,0.0f,0.0f);
808
+	qglLineWidth( (float) r_celoutline->integer );	
809
+
810
+	if(primitives == 2) {
811
+		qglDrawElements( GL_TRIANGLES, numIndexes, GL_INDEX_TYPE, indexes );
812
+	} else if(primitives == 1) {
813
+		R_DrawStripElements( numIndexes,  indexes, qglArrayElement );
814
+	} else if(primitives == 3) {
815
+		R_DrawStripElements( numIndexes,  indexes, R_ArrayElementDiscrete );
816
+	}
817
+
818
+	//. correction for mirrors. SEE NOTE #2.
819
+	if(backEnd.viewParms.isMirror == qtrue) { qglCullFace (GL_BACK); }
820
+	else { qglCullFace (GL_FRONT); }
821
+	
822
+	qglDisable (GL_BLEND);
823
+	
824
+	return;
825
+
826
+/* Notes
827
+
828
+1. this is going to be a pain in the arse. it fixes things like light `beams` from being cel'd but it
829
+also will ignore any other shader set with no culling. this usually is everything that is translucent.
830
+but this is a good hack to clean up the screen untill something more selective comes along. or who knows
831
+group desision might actually be that this is liked. if so i take back calling it a `hack`, lol.
832
+	= bob.
833
+
834
+2. mirrors display correctly because the normals of the displayed are inverted of normal space. so to
835
+continue to have them display correctly, we must invert them inversely from a normal inversion.
836
+	= bob.
837
+	
838
+3. this turns off a lot of space hogging sprite cel outlines. picture if you will five people in a small
839
+room all shooting rockets. each smoke puff gets a big black square around it, each explosion gets a big
840
+black square around it, and now nobody can see eachother because everyones screen is solid black.
841
+	= bob.
842
+
843
+4. ignoring liquids means you will not get black tris lines all over the top of your liquid. i put this in
844
+after seeing the lava on q3dm7 and water on q3ctf2 that had black lines all over the top, making the
845
+liquids look solid instead of... liquid.
846
+	= bob.
847
+
848
+*/
849
+}
850
+
851
+
852
 /*
853
 =============================================================
854
 
855
@@ -245,6 +325,33 @@
856
 	GL_Bind( bundle->image[ index ] );
857
 }
858
 
859
+//DRAWCEL
860
+static void DrawCel (shaderCommands_t *input) {
861
+
862
+	GL_Bind( tr.whiteImage );
863
+	qglColor3f (1,1,1);
864
+
865
+	GL_State( GLS_POLYMODE_LINE | GLS_DEPTHMASK_TRUE );
866
+
867
+	qglDisableClientState (GL_COLOR_ARRAY);
868
+	qglDisableClientState (GL_TEXTURE_COORD_ARRAY);
869
+
870
+	qglVertexPointer (3, GL_FLOAT, 16, input->xyz);	// padded for SIMD
871
+
872
+	if (qglLockArraysEXT) {
873
+		qglLockArraysEXT(0, input->numVertexes);
874
+		GLimp_LogComment( "glLockArraysEXT\n" );
875
+	}
876
+
877
+	R_DrawCel( input->numIndexes, input->indexes );
878
+
879
+	if (qglUnlockArraysEXT) {
880
+		qglUnlockArraysEXT();
881
+		GLimp_LogComment( "glUnlockArraysEXT\n" );
882
+	}
883
+
884
+}
885
+
886
 /*
887
 ================
888
 DrawTris
889
@@ -1140,6 +1247,12 @@
890
 		qglPolygonOffset( r_offsetFactor->value, r_offsetUnits->value );
891
 	}
892
 
893
+	//. show me cel outlines.
894
+	//. there has to be a better place to put this.
895
+	if(r_celoutline->integer > 0) {
896
+		DrawCel(&tess);
897
+	}
898
+
899
 	//
900
 	// if there is only a single pass then we can enable color
901
 	// and texture arrays before we compile, otherwise we need
902
Index: code/renderer/tr_shader.c
903
===================================================================
904
--- code/renderer/tr_shader.c	(revision 933)
905
+++ code/renderer/tr_shader.c	(working copy)
906
@@ -2744,7 +2744,17 @@
907
 */
908
 qhandle_t RE_RegisterShaderNoMip( const char *name ) {
909
 	shader_t	*sh;
910
+	// Remember previous value
911
+	int			old_r_celshadalgo;
912
 
913
+	/*
914
+	 * This will prevent sprites, like buttons, go through
915
+	 * cel shading filters, like kuwahara.
916
+	 * @author gmiranda
917
+	 */
918
+	old_r_celshadalgo = r_celshadalgo->integer;
919
+	r_celshadalgo->integer=0;
920
+
921
 	if ( strlen( name ) >= MAX_QPATH ) {
922
 		Com_Printf( "Shader name exceeds MAX_QPATH\n" );
923
 		return 0;
924
@@ -2752,6 +2762,9 @@
925
 
926
 	sh = R_FindShader( name, LIGHTMAP_2D, qfalse );
927
 
928
+	// Restore value
929
+	r_celshadalgo->integer=old_r_celshadalgo;
930
+
931
 	// we want to return 0 if the shader failed to
932
 	// load for some reason, but R_FindShader should
933
 	// still keep a name allocated for it, so if
(-)iourbanterror/files/extra-patch-mp3 (-753 lines)
Lines 1-753 Link Here
1
Index: code/client/snd_codec.c
2
===================================================================
3
--- code/client/snd_codec.c	(revision 917)
4
+++ code/client/snd_codec.c	(working copy)
5
@@ -105,6 +105,9 @@
6
 #if USE_CODEC_VORBIS
7
 	S_CodecRegister(&ogg_codec);
8
 #endif
9
+#if USE_CODEC_MP3
10
+	S_CodecRegister(&mp3_codec);
11
+#endif
12
 }
13
 
14
 /*
15
Index: code/client/snd_codec.h
16
===================================================================
17
--- code/client/snd_codec.h	(revision 917)
18
+++ code/client/snd_codec.h	(working copy)
19
@@ -95,4 +95,13 @@
20
 int S_OGG_CodecReadStream(snd_stream_t *stream, int bytes, void *buffer);
21
 #endif // USE_CODEC_VORBIS
22
 
23
+// MP3 codec
24
+#ifdef USE_CODEC_MP3
25
+extern snd_codec_t mp3_codec;
26
+void *S_MP3_CodecLoad(const char *filename, snd_info_t *info);
27
+snd_stream_t *S_MP3_CodecOpenStream(const char *filename);
28
+void S_MP3_CodecCloseStream(snd_stream_t *stream);
29
+int S_MP3_CodecReadStream(snd_stream_t *stream, int bytes, void *buffer);
30
+#endif // USE_CODEC_MP3
31
+
32
 #endif // !_SND_CODEC_H_
33
Index: code/client/snd_codec_mp3.c
34
===================================================================
35
--- code/client/snd_codec_mp3.c	(revision 0)
36
+++ code/client/snd_codec_mp3.c	(revision 0)
37
@@ -0,0 +1,716 @@
38
+/*
39
+===========================================================================
40
+Copyright (C) 1999-2005 Id Software, Inc.
41
+Copyright (C) 2005 Stuart Dalton (badcdev@gmail.com)
42
+Copyright (C) 2005-2006 Joerg Dietrich <dietrich_joerg@gmx.de>
43
+Copyright (C) 2006 Thilo Schulz <arny@ats.s.bawue.de>
44
+
45
+This file is part of Quake III Arena source code.
46
+
47
+Quake III Arena source code is free software; you can redistribute it
48
+and/or modify it under the terms of the GNU General Public License as
49
+published by the Free Software Foundation; either version 2 of the License,
50
+or (at your option) any later version.
51
+
52
+Quake III Arena source code is distributed in the hope that it will be
53
+useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
54
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
55
+GNU General Public License for more details.
56
+
57
+You should have received a copy of the GNU General Public License
58
+along with Quake III Arena source code; if not, write to the Free Software
59
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
60
+===========================================================================
61
+*/
62
+
63
+// MP3 support is enabled by this define
64
+#if USE_CODEC_MP3
65
+
66
+// includes for the Q3 sound system
67
+#include "client.h"
68
+#include "snd_codec.h"
69
+
70
+// includes for the MP3 codec
71
+#include <mad.h>
72
+
73
+#define MP3_SAMPLE_WIDTH		2
74
+#define MP3_PCMSAMPLES_PERSLICE		32
75
+
76
+// buffer size used when reading through the mp3
77
+#define MP3_DATA_BUFSIZ			128*1024
78
+
79
+// undefine this if you don't want any dithering.
80
+#define MP3_DITHERING
81
+
82
+// Q3 MP3 codec
83
+snd_codec_t mp3_codec =
84
+{
85
+	".mp3",
86
+	S_MP3_CodecLoad,
87
+	S_MP3_CodecOpenStream,
88
+	S_MP3_CodecReadStream,
89
+	S_MP3_CodecCloseStream,
90
+	NULL
91
+};
92
+
93
+// structure used for info purposes
94
+struct snd_codec_mp3_info
95
+{
96
+	byte encbuf[MP3_DATA_BUFSIZ];	// left over bytes not consumed
97
+					// by the decoder.
98
+	struct mad_stream madstream;	// uses encbuf as buffer.
99
+	struct mad_frame madframe;	// control structures for libmad.
100
+	struct mad_synth madsynth;
101
+
102
+	byte *pcmbuf;			// buffer for not-used samples.
103
+	int buflen;			// length of buffer data.
104
+	int pcmbufsize;			// amount of allocated memory for
105
+					// pcmbuf. This should have at least
106
+					// the size of a decoded mp3 frame.	
107
+
108
+	byte *dest;			// copy decoded data here.
109
+	int destlen;			// amount of already copied data.
110
+	int destsize;			// amount of bytes we must decode.
111
+};
112
+
113
+/*************** MP3 utility functions ***************/
114
+
115
+/*
116
+=================
117
+S_MP3_ReadData
118
+=================
119
+*/
120
+
121
+// feed libmad with data
122
+int S_MP3_ReadData(snd_stream_t *stream, struct mad_stream *madstream, byte *encbuf, int encbufsize)
123
+{
124
+	int retval;
125
+	int leftover;
126
+	
127
+	if(!stream)
128
+		return -1;
129
+	
130
+	leftover =  madstream->bufend - madstream->next_frame;
131
+	if(leftover > 0)
132
+		memmove(encbuf, madstream->this_frame, leftover);
133
+
134
+
135
+	// Fill the buffer right to the end
136
+	
137
+	retval = FS_Read(&encbuf[leftover], encbufsize - leftover, stream->file);
138
+
139
+	if(retval <= 0)
140
+	{
141
+		// EOF reached, that's ok.
142
+		return 0;
143
+	}
144
+	
145
+	mad_stream_buffer(madstream, encbuf, retval + leftover);
146
+	
147
+	return retval;
148
+}
149
+
150
+
151
+/*
152
+=================
153
+S_MP3_Scanfile
154
+
155
+to determine the samplecount, we apparently must get *all* headers :(
156
+I basically used the xmms-mad plugin source to see how this stuff works.
157
+
158
+returns a value < 0 on error.
159
+=================
160
+*/
161
+
162
+int S_MP3_Scanfile(snd_stream_t *stream)
163
+{
164
+	struct mad_stream madstream;
165
+	struct mad_header madheader;
166
+	int retval;
167
+	int samplecount;
168
+	byte encbuf[MP3_DATA_BUFSIZ];
169
+
170
+	// error out on invalid input.
171
+	if(!stream)
172
+		return -1;
173
+
174
+	mad_stream_init(&madstream);
175
+	mad_header_init(&madheader);
176
+	
177
+	while(1)
178
+	{
179
+		retval = S_MP3_ReadData(stream, &madstream, encbuf, sizeof(encbuf));
180
+		if(retval < 0)
181
+			return -1;
182
+		else if(retval == 0)
183
+			break;
184
+		
185
+		// Start decoding the headers.
186
+		while(1)
187
+		{
188
+			if((retval = mad_header_decode(&madheader, &madstream)) < 0)
189
+			{
190
+				if(madstream.error == MAD_ERROR_BUFLEN)
191
+				{
192
+					// We need to read more data
193
+					break;
194
+				}
195
+
196
+				if(!MAD_RECOVERABLE (madstream.error))
197
+				{
198
+					// unrecoverable error... we must bail out.
199
+					return retval;
200
+				}
201
+
202
+				mad_stream_skip(&madstream, madstream.skiplen);
203
+				continue;
204
+			}
205
+			
206
+			// we got a valid header.
207
+			
208
+			if(madheader.layer != MAD_LAYER_III)
209
+			{
210
+				// we don't support non-mp3s
211
+				return -1;
212
+			}
213
+
214
+			if(!stream->info.samples)
215
+			{
216
+				// This here is the very first frame. Set initial values now,
217
+				// that we expect to stay constant throughout the whole mp3.
218
+				
219
+				stream->info.rate = madheader.samplerate;
220
+				stream->info.width = MP3_SAMPLE_WIDTH;
221
+				stream->info.channels = MAD_NCHANNELS(&madheader);
222
+				stream->info.samples = 0;
223
+				stream->info.size = 0;				// same here.
224
+				stream->info.dataofs = 0;
225
+			}
226
+			else
227
+			{
228
+				// Check whether something changed that shouldn't.
229
+				
230
+				if(stream->info.rate != madheader.samplerate ||
231
+				   stream->info.channels != MAD_NCHANNELS(&madheader))
232
+					return -1;
233
+			}
234
+
235
+			// Update the counters
236
+			samplecount = MAD_NSBSAMPLES(&madheader) * MP3_PCMSAMPLES_PERSLICE;
237
+			stream->info.samples += samplecount;
238
+			stream->info.size += samplecount * stream->info.channels * stream->info.width;			
239
+		}
240
+	}
241
+	
242
+	// Reset the file pointer so we can do the real decoding.
243
+	FS_Seek(stream->file, 0, FS_SEEK_SET);
244
+	
245
+	return 0;
246
+}
247
+
248
+/************************ dithering functions ***************************/
249
+
250
+#ifdef MP3_DITHERING
251
+
252
+// All dithering done here is taken from the GPL'ed xmms-mad plugin.
253
+
254
+/* Copyright (C) 1997 Makoto Matsumoto and Takuji Nishimura.       */
255
+/* Any feedback is very welcome. For any question, comments,       */
256
+/* see http://www.math.keio.ac.jp/matumoto/emt.html or email       */
257
+/* matumoto@math.keio.ac.jp                                        */
258
+
259
+/* Period parameters */
260
+#define MP3_DITH_N 624
261
+#define MP3_DITH_M 397
262
+#define MATRIX_A 0x9908b0df   /* constant vector a */
263
+#define UPPER_MASK 0x80000000 /* most significant w-r bits */
264
+#define LOWER_MASK 0x7fffffff /* least significant r bits */
265
+
266
+/* Tempering parameters */
267
+#define TEMPERING_MASK_B 0x9d2c5680
268
+#define TEMPERING_MASK_C 0xefc60000
269
+#define TEMPERING_SHIFT_U(y)  (y >> 11)
270
+#define TEMPERING_SHIFT_S(y)  (y << 7)
271
+#define TEMPERING_SHIFT_T(y)  (y << 15)
272
+#define TEMPERING_SHIFT_L(y)  (y >> 18)
273
+
274
+static unsigned long mt[MP3_DITH_N]; /* the array for the state vector  */
275
+static int mti=MP3_DITH_N+1; /* mti==MP3_DITH_N+1 means mt[MP3_DITH_N] is not initialized */
276
+
277
+/* initializing the array with a NONZERO seed */
278
+void sgenrand(unsigned long seed)
279
+{
280
+    /* setting initial seeds to mt[MP3_DITH_N] using         */
281
+    /* the generator Line 25 of Table 1 in          */
282
+    /* [KNUTH 1981, The Art of Computer Programming */
283
+    /*    Vol. 2 (2nd Ed.), pp102]                  */
284
+    mt[0]= seed & 0xffffffff;
285
+    for (mti=1; mti<MP3_DITH_N; mti++)
286
+        mt[mti] = (69069 * mt[mti-1]) & 0xffffffff;
287
+}
288
+
289
+unsigned long genrand(void)
290
+{
291
+    unsigned long y;
292
+    static unsigned long mag01[2]={0x0, MATRIX_A};
293
+    /* mag01[x] = x * MATRIX_A  for x=0,1 */
294
+
295
+    if (mti >= MP3_DITH_N) { /* generate MP3_DITH_N words at one time */
296
+        int kk;
297
+
298
+        if (mti == MP3_DITH_N+1)   /* if sgenrand() has not been called, */
299
+            sgenrand(4357); /* a default initial seed is used   */
300
+
301
+        for (kk=0;kk<MP3_DITH_N-MP3_DITH_M;kk++) {
302
+            y = (mt[kk]&UPPER_MASK)|(mt[kk+1]&LOWER_MASK);
303
+            mt[kk] = mt[kk+MP3_DITH_M] ^ (y >> 1) ^ mag01[y & 0x1];
304
+        }
305
+        for (;kk<MP3_DITH_N-1;kk++) {
306
+            y = (mt[kk]&UPPER_MASK)|(mt[kk+1]&LOWER_MASK);
307
+            mt[kk] = mt[kk+(MP3_DITH_M-MP3_DITH_N)] ^ (y >> 1) ^ mag01[y & 0x1];
308
+        }
309
+        y = (mt[MP3_DITH_N-1]&UPPER_MASK)|(mt[0]&LOWER_MASK);
310
+        mt[MP3_DITH_N-1] = mt[MP3_DITH_M-1] ^ (y >> 1) ^ mag01[y & 0x1];
311
+
312
+        mti = 0;
313
+    }
314
+
315
+    y = mt[mti++];
316
+    y ^= TEMPERING_SHIFT_U(y);
317
+    y ^= TEMPERING_SHIFT_S(y) & TEMPERING_MASK_B;
318
+    y ^= TEMPERING_SHIFT_T(y) & TEMPERING_MASK_C;
319
+    y ^= TEMPERING_SHIFT_L(y);
320
+
321
+    return y;
322
+}
323
+
324
+long triangular_dither_noise(int nbits) {
325
+    // parameter nbits : the peak-to-peak amplitude desired (in bits)
326
+    //  use with nbits set to    2 + nber of bits to be trimmed.
327
+    // (because triangular is made from two uniformly distributed processes,
328
+    // it starts at 2 bits peak-to-peak amplitude)
329
+    // see The Theory of Dithered Quantization by Robert Alexander Wannamaker
330
+    // for complete proof of why that's optimal
331
+
332
+    long v = (genrand()/2 - genrand()/2); // in ]-2^31, 2^31[
333
+    //int signe = (v>0) ? 1 : -1;
334
+    long P = 1 << (32 - nbits); // the power of 2
335
+    v /= P;
336
+    // now v in ]-2^(nbits-1), 2^(nbits-1) [
337
+
338
+    return v;
339
+}
340
+
341
+#endif // MP3_DITHERING
342
+
343
+/************************ decoder functions ***************************/
344
+
345
+/*
346
+=================
347
+S_MP3_Scale
348
+
349
+Converts the signal to 16 bit LE-PCM data and does dithering.
350
+
351
+- borrowed from xmms-mad plugin source.
352
+=================
353
+*/
354
+
355
+/*
356
+ * xmms-mad - mp3 plugin for xmms
357
+ * Copyright (C) 2001-2002 Sam Clegg
358
+ */
359
+
360
+signed int S_MP3_Scale(mad_fixed_t sample)
361
+{
362
+	int n_bits_to_loose = MAD_F_FRACBITS + 1 - 16;
363
+#ifdef MP3_DITHERING
364
+	int dither;
365
+#endif
366
+	
367
+	// round
368
+	sample += (1L << (n_bits_to_loose - 1));
369
+
370
+#ifdef MP3_DITHERING
371
+	dither = triangular_dither_noise(n_bits_to_loose + 1);
372
+	sample += dither;
373
+#endif
374
+
375
+	/* clip */
376
+	if (sample >= MAD_F_ONE)
377
+		sample = MAD_F_ONE - 1;
378
+	else if (sample < -MAD_F_ONE)
379
+		sample = -MAD_F_ONE;
380
+
381
+	/* quantize */
382
+	return sample >> n_bits_to_loose;
383
+}
384
+
385
+
386
+
387
+/*
388
+=================
389
+S_MP3_PCMCopy
390
+
391
+Copy and convert pcm data until bytecount bytes have been written.
392
+return the position in pcm->samples.
393
+indicate the amount of actually written bytes in wrotecnt.
394
+=================
395
+*/
396
+
397
+int S_MP3_PCMCopy(byte *buf, struct mad_pcm *pcm, int bufofs,
398
+			 int sampleofs, int bytecount, int *wrotecnt)
399
+{
400
+	int written = 0;
401
+	signed int sample;
402
+	int framesize = pcm->channels * MP3_SAMPLE_WIDTH;
403
+
404
+	// add new pcm data.
405
+	while(written < bytecount && sampleofs < pcm->length)
406
+	{
407
+		sample = S_MP3_Scale(pcm->samples[0][sampleofs]);
408
+
409
+#ifdef Q3_BIG_ENDIAN
410
+		// output to 16 bit big endian PCM
411
+		buf[bufofs++] = (sample >> 8) & 0xff;
412
+		buf[bufofs++] = sample & 0xff;
413
+#else
414
+		// output to 16 bit little endian PCM
415
+		buf[bufofs++] = sample & 0xff;
416
+		buf[bufofs++] = (sample >> 8) & 0xff;
417
+#endif
418
+		
419
+		if(pcm->channels == 2)
420
+		{
421
+			sample = S_MP3_Scale(pcm->samples[1][sampleofs]);
422
+
423
+#ifdef Q3_BIG_ENDIAN
424
+			buf[bufofs++] = (sample >> 8) & 0xff;
425
+			buf[bufofs++] = sample & 0xff;
426
+#else
427
+			buf[bufofs++] = sample & 0xff;
428
+			buf[bufofs++] = (sample >> 8) & 0xff;
429
+#endif
430
+		}
431
+		
432
+		sampleofs++;
433
+		written += framesize;
434
+	}	
435
+
436
+	if(wrotecnt)
437
+		*wrotecnt = written;
438
+
439
+	return sampleofs;
440
+}
441
+
442
+
443
+/*
444
+=================
445
+S_MP3_Decode
446
+=================
447
+*/
448
+
449
+// gets executed for every decoded frame.
450
+int S_MP3_Decode(snd_stream_t *stream)
451
+{
452
+	struct snd_codec_mp3_info *mp3info;
453
+	struct mad_stream *madstream;
454
+	struct mad_frame *madframe;
455
+	struct mad_synth *madsynth;
456
+	struct mad_pcm *pcm;
457
+	int cursize;
458
+	int samplecount;
459
+	int needcount;
460
+	int wrote;
461
+	int retval;
462
+
463
+	if(!stream)
464
+		return -1;
465
+
466
+	mp3info = stream->ptr;
467
+	madstream = &mp3info->madstream;
468
+	madframe = &mp3info->madframe;
469
+
470
+	if(mad_frame_decode(madframe, madstream))
471
+	{
472
+		if(madstream->error == MAD_ERROR_BUFLEN)
473
+		{
474
+			// we need more data. Read another chunk.
475
+			retval = S_MP3_ReadData(stream, madstream, mp3info->encbuf, sizeof(mp3info->encbuf));
476
+
477
+			// call myself again now that buffer is full.
478
+			if(retval > 0)
479
+				retval = S_MP3_Decode(stream);
480
+		}
481
+		else if(MAD_RECOVERABLE(madstream->error))
482
+		{
483
+			mad_stream_skip(madstream, madstream->skiplen);
484
+			return S_MP3_Decode(stream);
485
+		}
486
+		else
487
+			retval = -1;
488
+
489
+		return retval;
490
+	}
491
+
492
+	// check whether this really is an mp3
493
+	if(madframe->header.layer != MAD_LAYER_III)
494
+		return -1;
495
+
496
+	// generate pcm data
497
+	madsynth = &mp3info->madsynth;
498
+	mad_synth_frame(madsynth, madframe);
499
+
500
+	pcm = &madsynth->pcm;
501
+
502
+	// perform a few checks to see whether something changed that shouldn't.
503
+		
504
+	if(stream->info.rate != pcm->samplerate ||
505
+	   stream->info.channels != pcm->channels)
506
+	{
507
+		return -1;
508
+	}
509
+	// see whether we have got enough data now.
510
+	cursize = pcm->length * pcm->channels * stream->info.width;
511
+	needcount = mp3info->destsize - mp3info->destlen;
512
+
513
+	// Copy exactly as many samples as required.
514
+	samplecount = S_MP3_PCMCopy(mp3info->dest, pcm,
515
+				    mp3info->destlen, 0, needcount, &wrote);
516
+	mp3info->destlen += wrote;
517
+	
518
+	if(samplecount < pcm->length)
519
+	{
520
+		// Not all samples got copied. Copy the rest into the pcm buffer.
521
+		samplecount = S_MP3_PCMCopy(mp3info->pcmbuf, pcm,
522
+					    mp3info->buflen,
523
+					    samplecount,
524
+					    mp3info->pcmbufsize - mp3info->buflen,
525
+					    &wrote);
526
+		mp3info->buflen += wrote;
527
+		
528
+
529
+		if(samplecount < pcm->length)
530
+		{
531
+			// The pcm buffer was not large enough. Make it bigger.
532
+			byte *newbuf = Z_Malloc(cursize);
533
+			
534
+			if(mp3info->pcmbuf)
535
+			{
536
+				memcpy(newbuf, mp3info->pcmbuf, mp3info->buflen);
537
+				Z_Free(mp3info->pcmbuf);
538
+			}
539
+			
540
+			mp3info->pcmbuf = newbuf;
541
+			mp3info->pcmbufsize = cursize;
542
+			
543
+			samplecount = S_MP3_PCMCopy(mp3info->pcmbuf, pcm,
544
+						    mp3info->buflen,
545
+						    samplecount,
546
+						    mp3info->pcmbufsize - mp3info->buflen,
547
+						    &wrote);
548
+			mp3info->buflen += wrote;		
549
+		}		
550
+		
551
+		// we're definitely done.
552
+		retval = 0;
553
+	}
554
+	else if(mp3info->destlen >= mp3info->destsize)
555
+		retval = 0;
556
+	else
557
+		retval = 1;
558
+
559
+	return retval;
560
+}
561
+
562
+/*************** Callback functions for quake3 ***************/
563
+
564
+/*
565
+=================
566
+S_MP3_CodecOpenStream
567
+=================
568
+*/
569
+
570
+snd_stream_t *S_MP3_CodecOpenStream(const char *filename)
571
+{
572
+	snd_stream_t *stream;
573
+	struct snd_codec_mp3_info *mp3info;
574
+
575
+	// Open the stream
576
+	stream = S_CodecUtilOpen(filename, &mp3_codec);
577
+	if(!stream || stream->length <= 0)
578
+		return NULL;
579
+
580
+	// We have to scan through the MP3 to determine the important mp3 info.
581
+	if(S_MP3_Scanfile(stream) < 0)
582
+	{
583
+		// scanning didn't work out...
584
+		S_CodecUtilClose(stream);
585
+		return NULL;
586
+	}
587
+
588
+	// Initialize the mp3 info structure we need for streaming
589
+	mp3info = Z_Malloc(sizeof(*mp3info));
590
+	if(!mp3info)
591
+	{
592
+		S_CodecUtilClose(stream);
593
+		return NULL;
594
+	}
595
+
596
+	stream->ptr = mp3info;
597
+
598
+	// initialize the libmad control structures.
599
+	mad_stream_init(&mp3info->madstream);
600
+	mad_frame_init(&mp3info->madframe);
601
+	mad_synth_init(&mp3info->madsynth);
602
+
603
+	if(S_MP3_ReadData(stream, &mp3info->madstream, mp3info->encbuf, sizeof(mp3info->encbuf)) <= 0)
604
+	{
605
+		// we didnt read anything, that's bad.
606
+		S_MP3_CodecCloseStream(stream);
607
+		return NULL;
608
+	}
609
+
610
+	return stream;
611
+}
612
+
613
+/*
614
+=================
615
+S_MP3_CodecCloseStream
616
+=================
617
+*/
618
+
619
+// free all memory we allocated.
620
+void S_MP3_CodecCloseStream(snd_stream_t *stream)
621
+{
622
+	struct snd_codec_mp3_info *mp3info;
623
+	
624
+	if(!stream)
625
+		return;
626
+		
627
+	// free all data in our mp3info tree
628
+
629
+	if(stream->ptr)
630
+	{
631
+		mp3info = stream->ptr;
632
+
633
+		if(mp3info->pcmbuf)
634
+			Z_Free(mp3info->pcmbuf);
635
+
636
+		mad_synth_finish(&mp3info->madsynth);
637
+		mad_frame_finish(&mp3info->madframe);
638
+		mad_stream_finish(&mp3info->madstream);
639
+	
640
+		Z_Free(stream->ptr);
641
+	}
642
+
643
+	S_CodecUtilClose(stream);
644
+}
645
+
646
+/*
647
+=================
648
+S_MP3_CodecReadStream
649
+=================
650
+*/
651
+int S_MP3_CodecReadStream(snd_stream_t *stream, int bytes, void *buffer)
652
+{
653
+	struct snd_codec_mp3_info *mp3info;
654
+	int retval;
655
+	
656
+	if(!stream)
657
+		return -1;
658
+		
659
+	mp3info = stream->ptr;
660
+
661
+	// Make sure we get complete frames all the way through.
662
+	bytes -= bytes % (stream->info.channels * stream->info.width);
663
+
664
+	if(mp3info->buflen)
665
+	{
666
+		if(bytes < mp3info->buflen)
667
+		{
668
+			// we still have enough bytes in our decoded pcm buffer
669
+			memcpy(buffer, mp3info->pcmbuf, bytes);
670
+		
671
+			// remove the portion from our buffer.
672
+			mp3info->buflen -= bytes;
673
+			memmove(mp3info->pcmbuf, &mp3info->pcmbuf[bytes], mp3info->buflen);
674
+			return bytes;
675
+		}
676
+		else
677
+		{
678
+			// copy over the samples we already have.
679
+			memcpy(buffer, mp3info->pcmbuf, mp3info->buflen);
680
+			mp3info->destlen = mp3info->buflen;
681
+			mp3info->buflen = 0;
682
+		}
683
+	}
684
+	else
685
+		mp3info->destlen = 0;
686
+	
687
+	mp3info->dest = buffer;
688
+	mp3info->destsize = bytes;
689
+
690
+	do
691
+	{
692
+		retval = S_MP3_Decode(stream);
693
+	} while(retval > 0);
694
+	
695
+	// if there was an error return nothing.
696
+	if(retval < 0)
697
+		return 0;
698
+	
699
+	return mp3info->destlen;
700
+}
701
+
702
+/*
703
+=====================================================================
704
+S_MP3_CodecLoad
705
+
706
+We handle S_MP3_CodecLoad as a special case of the streaming functions 
707
+where we read the whole stream at once.
708
+======================================================================
709
+*/
710
+void *S_MP3_CodecLoad(const char *filename, snd_info_t *info)
711
+{
712
+	snd_stream_t *stream;
713
+	byte *pcmbuffer;
714
+
715
+	// check if input is valid
716
+	if(!filename)
717
+		return NULL;
718
+
719
+	stream = S_MP3_CodecOpenStream(filename);
720
+	
721
+	if(!stream)
722
+		return NULL;
723
+		
724
+        // copy over the info
725
+        info->rate = stream->info.rate;
726
+        info->width = stream->info.width;
727
+        info->channels = stream->info.channels;
728
+        info->samples = stream->info.samples;
729
+        info->dataofs = stream->info.dataofs;
730
+	
731
+	// allocate enough buffer for all pcm data
732
+	pcmbuffer = Z_Malloc(stream->info.size);
733
+	if(!pcmbuffer)
734
+	{
735
+		S_MP3_CodecCloseStream(stream);
736
+		return NULL;
737
+	}
738
+
739
+	info->size = S_MP3_CodecReadStream(stream, stream->info.size, pcmbuffer);
740
+
741
+	if(info->size <= 0)
742
+	{
743
+		// we didn't read anything at all. darn.
744
+		Z_Free(pcmbuffer);
745
+		pcmbuffer = NULL;
746
+	}
747
+
748
+	S_MP3_CodecCloseStream(stream);
749
+
750
+	return pcmbuffer;
751
+}
752
+
753
+#endif // USE_CODEC_MP3
(-)iourbanterror/files/patch-Makefile (-432 lines)
Lines 1-432 Link Here
1
--- Makefile.orig	2007-12-16 18:09:18.000000000 -0300
2
+++ Makefile	2008-02-28 11:39:45.000000000 -0300
3
@@ -27,16 +27,22 @@
4
   endif
5
 endif
6
 
7
-BUILD_CLIENT     =1
8
-BUILD_CLIENT_SMP =0
9
-BUILD_SERVER     =0
10
-BUILD_GAME_SO    =0
11
-BUILD_GAME_QVM   =0
12
-OPTIMIZE         =1
13
-USE_SDL          =1
14
-USE_OPENAL       =0
15
-USE_CURL         =1
16
-USE_CODEC_VORBIS =0 
17
+BUILD_CLIENT?=0
18
+BUILD_CLIENT_SMP?=0
19
+BUILD_GAME_QVM?=0
20
+BUILD_GAME_SO?=0
21
+BUILD_SERVER?=0
22
+HAVE_VM_COMPILED?=false
23
+USE_CODEC_MP3?=0
24
+USE_CODEC_VORBIS?=0
25
+USE_CURL?=0
26
+USE_CURL_DLOPEN?=0
27
+USE_LOCAL_HEADERS?=0
28
+USE_OPENAL?=0
29
+USE_OPENAL_DLOPEN?=0
30
+USE_OPTIMIZED_CFLAGS?=0
31
+USE_SDL_AUDIO?=0
32
+USE_SDL_VIDEO?=0
33
 
34
 ifeq ($(V),1)
35
 echo_cmd=@:
36
@@ -106,38 +112,10 @@
37
 USE_SDL=1
38
 endif
39
 
40
-ifndef USE_OPENAL
41
-USE_OPENAL=1
42
-endif
43
-
44
-ifndef USE_OPENAL_DLOPEN
45
-USE_OPENAL_DLOPEN=0
46
-endif
47
-
48
-ifndef USE_CURL
49
-USE_CURL=1
50
-endif
51
-
52
-ifndef USE_CURL_DLOPEN
53
-  ifeq ($(PLATFORM),mingw32)
54
-    USE_CURL_DLOPEN=0
55
-  else
56
-    USE_CURL_DLOPEN=1
57
-  endif
58
-endif
59
-
60
-ifndef USE_CODEC_VORBIS
61
-USE_CODEC_VORBIS=0
62
-endif
63
-
64
-ifndef USE_LOCAL_HEADERS
65
-USE_LOCAL_HEADERS=1
66
-endif
67
-
68
 #############################################################################
69
 
70
-BD=$(BUILD_DIR)/debug-$(PLATFORM)-$(ARCH)
71
-BR=$(BUILD_DIR)/release-$(PLATFORM)-$(ARCH)
72
+BD=$(BUILD_DIR)/debug
73
+BR=$(BUILD_DIR)/release
74
 CDIR=$(MOUNT_DIR)/client
75
 SDIR=$(MOUNT_DIR)/server
76
 RDIR=$(MOUNT_DIR)/renderer
77
@@ -221,6 +199,10 @@
78
     BASE_CFLAGS += -DUSE_CODEC_VORBIS=1
79
   endif
80
 
81
+  ifeq ($(USE_CODEC_MP3),1)
82
+    BASE_CFLAGS += -DUSE_CODEC_MP3=1
83
+  endif
84
+
85
   ifeq ($(USE_SDL),1)
86
     BASE_CFLAGS += -DUSE_SDL_VIDEO=1 -DUSE_SDL_SOUND=1 $(shell sdl-config --cflags)
87
   else
88
@@ -385,6 +367,11 @@
89
     endif
90
   endif
91
 
92
+  ifeq ($(USE_CODEC_MP3),1)
93
+    BASE_CFLAGS += -DUSE_CODEC_MP3=1
94
+    CLIENT_LDFLAGS += -lmad
95
+  endif
96
+
97
   ifeq ($(USE_CODEC_VORBIS),1)
98
     BASE_CFLAGS += -DUSE_CODEC_VORBIS=1
99
     CLIENT_LDFLAGS += -lvorbisfile -lvorbis -logg
100
@@ -476,6 +463,10 @@
101
     endif
102
   endif
103
 
104
+  ifeq ($(USE_CODEC_MP3),1)
105
+    CLIENT_LDFLAGS += -lmad
106
+  endif
107
+
108
   ifeq ($(USE_CODEC_VORBIS),1)
109
     CLIENT_LDFLAGS += -lvorbisfile -lvorbis -logg
110
   endif
111
@@ -497,17 +488,10 @@
112
 
113
 ifeq ($(PLATFORM),freebsd)
114
 
115
-  ifneq (,$(findstring alpha,$(shell uname -m)))
116
-    ARCH=axp
117
-  else #default to i386
118
-    ARCH=i386
119
-  endif #alpha test
120
-
121
-
122
-  BASE_CFLAGS = -Wall -fno-strict-aliasing -Wimplicit -Wstrict-prototypes \
123
-                -I/usr/X11R6/include
124
+  BASE_CFLAGS = -DARCH='\"$(ARCH)\"' -DLIBDIR='\"$(LIBDIR)\"' -I$(LOCALBASE)/include -Wall -fno-strict-aliasing -Wimplicit -Wstrict-prototypes
125
 
126
   DEBUG_CFLAGS=$(BASE_CFLAGS) -g
127
+  RELEASE_CFLAGS=$(BASE_CFLAGS) -DNDEBUG -pipe
128
 
129
   ifeq ($(USE_OPENAL),1)
130
     BASE_CFLAGS += -DUSE_OPENAL=1
131
@@ -516,49 +500,80 @@
132
     endif
133
   endif
134
 
135
+  ifeq ($(USE_CURL),1)
136
+    BASE_CFLAGS += -DUSE_CURL=1
137
+    ifneq ($(USE_CURL_DLOPEN),1)
138
+      CLIENT_LDFLAGS += -lcurl
139
+    else
140
+      BASE_CFLAGS += -DUSE_CURL_DLOPEN=1
141
+    endif
142
+  endif
143
+
144
   ifeq ($(USE_CODEC_VORBIS),1)
145
     BASE_CFLAGS += -DUSE_CODEC_VORBIS=1
146
   endif
147
 
148
-  ifeq ($(USE_SDL),1)
149
-    BASE_CFLAGS += $(shell sdl-config --cflags) -DUSE_SDL_VIDEO=1 -DUSE_SDL_SOUND=1
150
+  ifeq ($(USE_SDL_AUDIO),1)
151
+    BASE_CFLAGS += $(shell $(SDL_CONFIG) --cflags)
152
+  else
153
+    ifeq ($(USE_SDL_VIDEO),1)
154
+      BASE_CFLAGS += $(shell $(SDL_CONFIG) --cflags)
155
+    endif
156
   endif
157
 
158
-  ifeq ($(ARCH),axp)
159
-    BASE_CFLAGS += -DNO_VM_COMPILED
160
-    RELEASE_CFLAGS=$(BASE_CFLAGS) -DNDEBUG -O3 -ffast-math -funroll-loops \
161
-      -fomit-frame-pointer -fexpensive-optimizations
162
-  else
163
-  ifeq ($(ARCH),i386)
164
-    RELEASE_CFLAGS=$(BASE_CFLAGS) -DNDEBUG -O3 -mtune=pentiumpro \
165
-      -march=pentium -fomit-frame-pointer -pipe -ffast-math \
166
-      -falign-loops=2 -falign-jumps=2 -falign-functions=2 \
167
-      -funroll-loops -fstrength-reduce
168
-    HAVE_VM_COMPILED=true
169
-  else
170
-    BASE_CFLAGS += -DNO_VM_COMPILED
171
+  ifeq ($(USE_SDL_AUDIO),1)
172
+    BASE_CFLAGS += -DUSE_SDL_SOUND=1
173
   endif
174
+
175
+  ifeq ($(USE_SDL_VIDEO),1)
176
+    BASE_CFLAGS += -DUSE_SDL_VIDEO=1
177
+  endif
178
+
179
+  ifeq ($(USE_OPTIMIZED_CFLAGS),1)
180
+    RELEASE_CFLAGS+=-O3 -ffast-math -funroll-loops -fomit-frame-pointer \
181
+       -fexpensive-optimizations
182
+    ifeq ($(ARCH),i386)
183
+      RELEASE_CFLAGS+=-falign-loops=2 -falign-jumps=2 -falign-functions=2 \
184
+         -fstrength-reduce
185
+    endif
186
+  endif
187
+
188
+  ifneq ($(HAVE_VM_COMPILED),true)
189
+    BASE_CFLAGS += -DNO_VM_COMPILED
190
   endif
191
 
192
   SHLIBEXT=so
193
   SHLIBCFLAGS=-fPIC
194
   SHLIBLDFLAGS=-shared $(LDFLAGS)
195
 
196
-  THREAD_LDFLAGS=-lpthread
197
+  THREAD_LDFLAGS=$(PTHREAD_LIBS)
198
   # don't need -ldl (FreeBSD)
199
   LDFLAGS=-lm
200
 
201
-  CLIENT_LDFLAGS =
202
+  CLIENT_LDFLAGS = -L$(LOCALBASE)/lib
203
 
204
-  ifeq ($(USE_SDL),1)
205
-    CLIENT_LDFLAGS += $(shell sdl-config --libs)
206
+  ifeq ($(USE_SDL_AUDIO),1)
207
+    CLIENT_LDFLAGS += $(shell $(SDL_CONFIG) --libs)
208
   else
209
-    CLIENT_LDFLAGS += -L/usr/X11R6/$(LIB) -lGL -lX11 -lXext -lXxf86dga -lXxf86vm
210
+    ifeq ($(USE_SDL_VIDEO),1)
211
+      CLIENT_LDFLAGS += $(shell $(SDL_CONFIG) --libs)
212
+    endif
213
+  endif
214
+
215
+  ifneq ($(USE_SDL_VIDEO),1)
216
+    CLIENT_LDFLAGS += -L$(LOCALBASE)/lib -lGL -lX11 -lXext -lXxf86dga -lXxf86vm
217
   endif
218
 
219
   ifeq ($(USE_OPENAL),1)
220
+    CLIENT_LDFLAGS += $(THREAD_LDFLAGS)
221
     ifneq ($(USE_OPENAL_DLOPEN),1)
222
-      CLIENT_LDFLAGS += $(THREAD_LDFLAGS) -lopenal
223
+      CLIENT_LDFLAGS += -lopenal
224
+    endif
225
+  endif
226
+
227
+  ifeq ($(USE_CURL),1)
228
+    ifneq ($(USE_CURL_DLOPEN),1)
229
+      CLIENT_LDFLAGS += -lcurl
230
     endif
231
   endif
232
 
233
@@ -566,7 +581,6 @@
234
     CLIENT_LDFLAGS += -lvorbisfile -lvorbis -logg
235
   endif
236
 
237
-
238
 else # ifeq freebsd
239
 
240
 #############################################################################
241
@@ -717,24 +731,25 @@
242
 TARGETS =
243
 
244
 ifneq ($(BUILD_SERVER),0)
245
-  TARGETS += $(B)/ioUrTded.$(ARCH)$(BINEXT)
246
+  TARGETS += $(B)/ioUrTded$(BINEXT)
247
 endif
248
 
249
 ifneq ($(BUILD_CLIENT),0)
250
-  TARGETS += $(B)/ioUrbanTerror.$(ARCH)$(BINEXT)
251
-  ifneq ($(BUILD_CLIENT_SMP),0)
252
-    TARGETS += $(B)/ioUrbanTerror-smp.$(ARCH)$(BINEXT)
253
-  endif
254
+  TARGETS += $(B)/ioUrbanTerror$(BINEXT)
255
+endif
256
+
257
+ifneq ($(BUILD_CLIENT_SMP),0)
258
+  TARGETS += $(B)/ioUrbanTerror-smp$(BINEXT)
259
 endif
260
 
261
 ifneq ($(BUILD_GAME_SO),0)
262
   TARGETS += \
263
-    $(B)/baseq3/cgame$(ARCH).$(SHLIBEXT) \
264
-    $(B)/baseq3/qagame$(ARCH).$(SHLIBEXT) \
265
-    $(B)/baseq3/ui$(ARCH).$(SHLIBEXT)     \
266
-    $(B)/missionpack/cgame$(ARCH).$(SHLIBEXT) \
267
-    $(B)/missionpack/qagame$(ARCH).$(SHLIBEXT) \
268
-    $(B)/missionpack/ui$(ARCH).$(SHLIBEXT)
269
+    $(B)/baseq3/cgame.$(SHLIBEXT) \
270
+    $(B)/baseq3/qagame.$(SHLIBEXT) \
271
+    $(B)/baseq3/ui.$(SHLIBEXT)     \
272
+    $(B)/missionpack/cgame.$(SHLIBEXT) \
273
+    $(B)/missionpack/qagame.$(SHLIBEXT) \
274
+    $(B)/missionpack/ui.$(SHLIBEXT)
275
 endif
276
 
277
 ifneq ($(BUILD_GAME_QVM),0)
278
@@ -824,10 +839,10 @@
279
 all: debug release
280
 
281
 debug:
282
-	@$(MAKE) targets B=$(BD) CFLAGS="$(CFLAGS) $(DEBUG_CFLAGS)" V=$(V)
283
+	@$(MAKE) targets B=$(BD) CFLAGS+="$(CFLAGS) $(DEBUG_CFLAGS)" V=$(V)
284
 
285
 release:
286
-	@$(MAKE) targets B=$(BR) CFLAGS="$(CFLAGS) $(RELEASE_CFLAGS)" V=$(V)
287
+	@$(MAKE) targets B=$(BR) CFLAGS+="$(CFLAGS) $(RELEASE_CFLAGS)" V=$(V)
288
 
289
 # Create the build directories and tools, print out
290
 # an informational message, then start building
291
@@ -880,7 +895,7 @@
292
 Q3LCC=$(TOOLSDIR)/q3lcc$(BINEXT)
293
 Q3ASM=$(TOOLSDIR)/q3asm$(BINEXT)
294
 
295
-ifeq ($(CROSS_COMPILING),1)
296
+ifeq ($(BUILD_GAME_QVM),0)
297
 tools:
298
 	@echo QVM tools not built when cross-compiling
299
 else
300
@@ -943,8 +958,13 @@
301
   $(B)/client/snd_main.o \
302
   $(B)/client/snd_codec.o \
303
   $(B)/client/snd_codec_wav.o \
304
-  $(B)/client/snd_codec_ogg.o \
305
-  \
306
+  $(B)/client/snd_codec_ogg.o
307
+
308
+ifeq ($(USE_CODEC_MP3),1)
309
+  Q3OBJ += $(B)/client/snd_codec_mp3.o
310
+endif
311
+
312
+Q3OBJ += \
313
   $(B)/client/qal.o \
314
   $(B)/client/snd_openal.o \
315
   \
316
@@ -1078,9 +1098,15 @@
317
   ifeq ($(ARCH),x86)
318
     Q3OBJ += $(B)/client/vm_x86.o
319
   endif
320
+  ifeq ($(ARCH),amd64)
321
+    Q3OBJ += $(B)/client/vm_x86_64.o $(B)/client/vm_x86_64_assembler.o
322
+  endif
323
   ifeq ($(ARCH),x86_64)
324
     Q3OBJ += $(B)/client/vm_x86_64.o $(B)/client/vm_x86_64_assembler.o
325
   endif
326
+  ifeq ($(ARCH),powerpc)
327
+    Q3OBJ += $(B)/client/vm_ppc.o
328
+  endif
329
   ifeq ($(ARCH),ppc)
330
     Q3OBJ += $(B)/client/vm_ppc.o
331
   endif
332
@@ -1113,7 +1139,7 @@
333
 
334
   ifeq ($(USE_SDL),1)
335
     ifneq ($(PLATFORM),darwin)
336
-      BUILD_CLIENT_SMP = 0
337
+      #BUILD_CLIENT_SMP = 0
338
     endif
339
   endif
340
 
341
@@ -1126,12 +1152,12 @@
342
     $(B)/clientsmp/sdl_glimp.o
343
 endif
344
 
345
-$(B)/ioUrbanTerror.$(ARCH)$(BINEXT): $(Q3OBJ) $(Q3POBJ) $(LIBSDLMAIN)
346
+$(B)/ioUrbanTerror$(BINEXT): $(Q3OBJ) $(Q3POBJ) $(LIBSDLMAIN)
347
 	$(echo_cmd) "LD $@"
348
 	$(Q)$(CC) -o $@ $(Q3OBJ) $(Q3POBJ) $(CLIENT_LDFLAGS) \
349
 		$(LDFLAGS) $(LIBSDLMAIN)
350
 
351
-$(B)/ioUrbanTerror-smp.$(ARCH)$(BINEXT): $(Q3OBJ) $(Q3POBJ_SMP) $(LIBSDLMAIN)
352
+$(B)/ioUrbanTerror-smp$(BINEXT): $(Q3OBJ) $(Q3POBJ_SMP) $(LIBSDLMAIN)
353
 	$(echo_cmd) "LD $@"
354
 	$(Q)$(CC) -o $@ $(Q3OBJ) $(Q3POBJ_SMP) $(CLIENT_LDFLAGS) \
355
 		$(THREAD_LDFLAGS) $(LDFLAGS) $(LIBSDLMAIN)
356
@@ -1240,15 +1266,21 @@
357
   ifeq ($(ARCH),x86)
358
     Q3DOBJ += $(B)/ded/vm_x86.o
359
   endif
360
+  ifeq ($(ARCH),amd64)
361
+    Q3DOBJ += $(B)/ded/vm_x86_64.o $(B)/client/vm_x86_64_assembler.o
362
+  endif
363
   ifeq ($(ARCH),x86_64)
364
     Q3DOBJ += $(B)/ded/vm_x86_64.o $(B)/client/vm_x86_64_assembler.o
365
   endif
366
+  ifeq ($(ARCH),powerpc)
367
+    Q3DOBJ += $(B)/ded/vm_ppc.o
368
+  endif
369
   ifeq ($(ARCH),ppc)
370
     Q3DOBJ += $(B)/ded/vm_ppc.o
371
   endif
372
 endif
373
 
374
-$(B)/ioUrTded.$(ARCH)$(BINEXT): $(Q3DOBJ)
375
+$(B)/ioUrTded$(BINEXT): $(Q3DOBJ)
376
 	$(echo_cmd) "LD $@"
377
 	$(Q)$(CC) -o $@ $(Q3DOBJ) $(LDFLAGS)
378
 
379
@@ -1287,7 +1319,7 @@
380
 Q3CGOBJ = $(Q3CGOBJ_) $(B)/baseq3/cgame/cg_syscalls.o
381
 Q3CGVMOBJ = $(Q3CGOBJ_:%.o=%.asm) $(B)/baseq3/game/bg_lib.asm
382
 
383
-$(B)/baseq3/cgame$(ARCH).$(SHLIBEXT) : $(Q3CGOBJ)
384
+$(B)/baseq3/cgame.$(SHLIBEXT) : $(Q3CGOBJ)
385
 	$(echo_cmd) "LD $@"
386
 	$(Q)$(CC) $(SHLIBLDFLAGS) -o $@ $(Q3CGOBJ)
387
 
388
@@ -1330,7 +1362,7 @@
389
 MPCGOBJ = $(MPCGOBJ_) $(B)/missionpack/cgame/cg_syscalls.o
390
 MPCGVMOBJ = $(MPCGOBJ_:%.o=%.asm) $(B)/missionpack/game/bg_lib.asm
391
 
392
-$(B)/missionpack/cgame$(ARCH).$(SHLIBEXT) : $(MPCGOBJ)
393
+$(B)/missionpack/cgame.$(SHLIBEXT) : $(MPCGOBJ)
394
 	$(echo_cmd) "LD $@"
395
 	$(Q)$(CC) $(SHLIBLDFLAGS) -o $@ $(MPCGOBJ)
396
 
397
@@ -1382,7 +1414,7 @@
398
 Q3GOBJ = $(Q3GOBJ_) $(B)/baseq3/game/g_syscalls.o
399
 Q3GVMOBJ = $(Q3GOBJ_:%.o=%.asm) $(B)/baseq3/game/bg_lib.asm
400
 
401
-$(B)/baseq3/qagame$(ARCH).$(SHLIBEXT) : $(Q3GOBJ)
402
+$(B)/baseq3/qagame.$(SHLIBEXT) : $(Q3GOBJ)
403
 	$(echo_cmd) "LD $@"
404
 	$(Q)$(CC) $(SHLIBLDFLAGS) -o $@ $(Q3GOBJ)
405
 
406
@@ -1432,7 +1464,7 @@
407
 MPGOBJ = $(MPGOBJ_) $(B)/missionpack/game/g_syscalls.o
408
 MPGVMOBJ = $(MPGOBJ_:%.o=%.asm) $(B)/missionpack/game/bg_lib.asm
409
 
410
-$(B)/missionpack/qagame$(ARCH).$(SHLIBEXT) : $(MPGOBJ)
411
+$(B)/missionpack/qagame.$(SHLIBEXT) : $(MPGOBJ)
412
 	$(echo_cmd) "LD $@"
413
 	$(Q)$(CC) $(SHLIBLDFLAGS) -o $@ $(MPGOBJ)
414
 
415
@@ -1494,7 +1526,7 @@
416
 Q3UIOBJ = $(Q3UIOBJ_) $(B)/missionpack/ui/ui_syscalls.o
417
 Q3UIVMOBJ = $(Q3UIOBJ_:%.o=%.asm) $(B)/baseq3/game/bg_lib.asm
418
 
419
-$(B)/baseq3/ui$(ARCH).$(SHLIBEXT) : $(Q3UIOBJ)
420
+$(B)/baseq3/ui.$(SHLIBEXT) : $(Q3UIOBJ)
421
 	$(echo_cmd) "LD $@"
422
 	$(Q)$(CC) $(CFLAGS) $(SHLIBLDFLAGS) -o $@ $(Q3UIOBJ)
423
 
424
@@ -1521,7 +1553,7 @@
425
 MPUIOBJ = $(MPUIOBJ_) $(B)/missionpack/ui/ui_syscalls.o
426
 MPUIVMOBJ = $(MPUIOBJ_:%.o=%.asm) $(B)/baseq3/game/bg_lib.asm
427
 
428
-$(B)/missionpack/ui$(ARCH).$(SHLIBEXT) : $(MPUIOBJ)
429
+$(B)/missionpack/ui.$(SHLIBEXT) : $(MPUIOBJ)
430
 	$(echo_cmd) "LD $@"
431
 	$(Q)$(CC) $(CFLAGS) $(SHLIBLDFLAGS) -o $@ $(MPUIOBJ)
432
 
(-)iourbanterror/files/patch-code-qcommon-q_shared.h (+19 lines)
Line 0 Link Here
1
--- code/qcommon/q_shared.h.orig	2010-08-29 19:32:54.537567000 +0200
2
+++ code/qcommon/q_shared.h	2010-11-27 16:55:16.000000000 +0100
3
@@ -27,11 +27,11 @@
4
 // A user mod should never modify this file
5
 
6
 #ifdef STANDALONE
7
-  #define PRODUCT_NAME			"iofoo3"
8
-  #define BASEGAME			"foobar"
9
-  #define CLIENT_WINDOW_TITLE     	"changeme"
10
-  #define CLIENT_WINDOW_MIN_TITLE 	"changeme2"
11
-  #define GAMENAME_FOR_MASTER		"iofoo3"	// must NOT contain whitespaces
12
+  #define PRODUCT_NAME			"ioq3+UT"
13
+  #define BASEGAME			"q3ut4"
14
+  #define CLIENT_WINDOW_TITLE     	"ioUrbanTerror"
15
+  #define CLIENT_WINDOW_MIN_TITLE 	"ioUT"
16
+  #define GAMENAME_FOR_MASTER		"Quake3Arena"	// must NOT contain whitespaces
17
 #else
18
   #define PRODUCT_NAME			"ioq3"
19
   #define BASEGAME			"baseq3"
(-)iourbanterror/files/patch-code__qcommon__common.c (-10 lines)
Lines 1-10 Link Here
1
--- ./code/qcommon/common.c.orig	Wed Apr 26 08:27:12 2006
2
+++ ./code/qcommon/common.c	Sun Jun 11 17:26:26 2006
3
@@ -25,6 +25,7 @@
4
 #include "qcommon.h"
5
 #include <setjmp.h>
6
 #ifndef _WIN32
7
+#include <sys/types.h>
8
 #include <netinet/in.h>
9
 #include <sys/stat.h> // umask
10
 #else
(-)iourbanterror/files/patch-code__qcommon__q_platform.h (-15 lines)
Lines 1-15 Link Here
1
--- ./code/qcommon/q_platform.h.orig	Tue Dec 27 16:46:01 2005
2
+++ ./code/qcommon/q_platform.h	Sun Jun 11 17:26:26 2006
3
@@ -176,11 +176,7 @@
4
 #define ID_INLINE inline
5
 #define PATH_SEP '/'
6
 
7
-#ifdef __i386__
8
-#define ARCH_STRING "i386"
9
-#elif defined __axp__
10
-#define ARCH_STRING "alpha"
11
-#endif
12
+#define ARCH_STRING ARCH
13
 
14
 #if BYTE_ORDER == BIG_ENDIAN
15
 #define Q3_BIG_ENDIAN
(-)iourbanterror/files/patch-code__qcommon__vm_x86.c (-20 lines)
Lines 1-20 Link Here
1
--- ./code/qcommon/vm_x86.c.orig	2007-10-09 02:47:22.000000000 -0300
2
+++ ./code/qcommon/vm_x86.c	2008-03-04 10:45:08.000000000 -0300
3
@@ -36,7 +36,7 @@
4
 
5
 /* need this on NX enabled systems (i386 with PAE kernel or
6
  * noexec32=on x86_64) */
7
-#ifdef __linux__
8
+#ifdef __unix__
9
 #define VM_X86_MMAP
10
 #endif
11
 
12
@@ -1081,7 +1081,7 @@
13
 	// copy to an exact size buffer on the hunk
14
 	vm->codeLength = compiledOfs;
15
 #ifdef VM_X86_MMAP
16
-	vm->codeBase = mmap(NULL, compiledOfs, PROT_WRITE, MAP_SHARED|MAP_ANONYMOUS, -1, 0);
17
+	vm->codeBase = mmap(NULL, compiledOfs, PROT_WRITE, MAP_SHARED|MAP_ANON, -1, 0);
18
 	if(vm->codeBase == (void*)-1)
19
 		Com_Error(ERR_DROP, "VM_CompileX86: can't mmap memory");
20
 #elif _WIN32
(-)iourbanterror/files/patch-code__qcommon__vm_x86_64.c (-20 lines)
Lines 1-20 Link Here
1
--- ./code/qcommon/vm_x86_64.c.orig	2007-10-09 02:47:22.000000000 -0300
2
+++ ./code/qcommon/vm_x86_64.c	2008-03-04 10:45:08.000000000 -0300
3
@@ -246,7 +246,7 @@
4
 #else
5
 #define JMPIARG \
6
 	emit("movq $%lu, %%rax", vm->codeBase+vm->instructionPointers[iarg]); \
7
-	emit("jmpq *%rax");
8
+	emit("jmpq *%%rax");
9
 #endif
10
  
11
 // integer compare and jump
12
@@ -534,7 +534,7 @@
13
 	{
14
 		compiledOfs = assembler_get_code_size();
15
 		vm->codeLength = compiledOfs;
16
-		vm->codeBase = mmap(NULL, compiledOfs, PROT_WRITE, MAP_SHARED|MAP_ANONYMOUS, -1, 0);
17
+		vm->codeBase = mmap(NULL, compiledOfs, PROT_WRITE, MAP_SHARED|MAP_ANON, -1, 0);
18
 		if(vm->codeBase == (void*)-1)
19
 			Com_Error(ERR_DROP, "VM_CompileX86: can't mmap memory");
20
 
(-)iourbanterror/files/patch-code__unix__linux_glimp.c (-19 lines)
Lines 1-19 Link Here
1
--- ./code/unix/linux_glimp.c.orig	Sun Apr 30 11:32:56 2006
2
+++ ./code/unix/linux_glimp.c	Sun Jun 11 17:26:26 2006
3
@@ -631,8 +631,14 @@
4
 
5
           dx = ((int)event.xmotion.x - mwx);
6
           dy = ((int)event.xmotion.y - mwy);
7
-					mx += dx;
8
-					my += dy;
9
+          if (abs(dx) > 1)
10
+            mx += dx * 2;
11
+          else
12
+            mx += dx;
13
+          if (abs(dy) > 1)
14
+            my += dy * 2;
15
+          else
16
+            my += dy;
17
 
18
           mwx = event.xmotion.x;
19
           mwy = event.xmotion.y;
(-)iourbanterror/files/patch-code__unix__unix_main.c (-31 lines)
Lines 1-31 Link Here
1
--- ./code/unix/unix_main.c.orig	Sun Feb 26 18:22:12 2006
2
+++ ./code/unix/unix_main.c	Sun Jun 11 17:26:26 2006
3
@@ -774,6 +774,7 @@
4
   char  curpath[MAX_OSPATH];
5
   char  fname[MAX_OSPATH];
6
   char  *basepath;
7
+  char  *libpath;
8
   char  *homepath;
9
   char  *pwdpath;
10
   char  *cdpath;
11
@@ -789,14 +790,19 @@
12
   // TODO: use fs_searchpaths from files.c
13
   pwdpath = Sys_Cwd();
14
   basepath = Cvar_VariableString( "fs_basepath" );
15
+  libpath = LIBDIR;
16
   homepath = Cvar_VariableString( "fs_homepath" );
17
   cdpath = Cvar_VariableString( "fs_cdpath" );
18
   gamedir = Cvar_VariableString( "fs_game" );
19
 
20
-  libHandle = try_dlopen(pwdpath, gamedir, fname, fqpath);
21
+  if(!libHandle && homepath)
22
+    libHandle = try_dlopen(pwdpath, gamedir, fname, fqpath);
23
 
24
   if(!libHandle && homepath)
25
     libHandle = try_dlopen(homepath, gamedir, fname, fqpath);
26
+
27
+  if(!libHandle && basepath)
28
+    libHandle = try_dlopen(libpath, gamedir, fname, fqpath);
29
 
30
   if(!libHandle && basepath)
31
     libHandle = try_dlopen(basepath, gamedir, fname, fqpath);
(-)iourbanterror/files/patch-code_client_snd_openal.c (-11 lines)
Lines 1-11 Link Here
1
--- code/client/snd_openal.c.orig	2009-12-26 18:12:52.000000000 +0100
2
+++ code/client/snd_openal.c	2009-12-26 18:13:00.000000000 +0100
3
@@ -1676,7 +1676,7 @@
4
 #elif defined(MACOS_X)
5
 #define ALDRIVER_DEFAULT "/System/Library/Frameworks/OpenAL.framework/OpenAL"
6
 #else
7
-#define ALDRIVER_DEFAULT "libopenal.so.0"
8
+#define ALDRIVER_DEFAULT "libopenal.so"
9
 #endif
10
 
11
 /*
(-)iourbanterror/pkg-descr (-2 / +2 lines)
Lines 6-12 Link Here
6
strafe jump, which combined with wall jumping can lead to very quick movement
6
strafe jump, which combined with wall jumping can lead to very quick movement
7
and nice jumps. Urban Terror has 7 game modes, 25 maps and 15 weapons.
7
and nice jumps. Urban Terror has 7 game modes, 25 maps and 15 weapons.
8
8
9
This port installs the modified ioquake3 engine for Urban Terror called
9
This port installs a modified ioquake3 engine for Urban Terror called
10
ioUrbanTerror, and depends on the data, resulting in a playable game.
10
ioUrbanTerror, and depends on the data, resulting in a playable game.
11
11
12
WWW: http://ftp.snt.utwente.nl/pub/games/urbanterror/iourbanterror/source/
12
WWW: http://www.urbanterror.info/
(-)iourbanterror/pkg-message (-13 / +4 lines)
Lines 1-17 Link Here
1
==============================================================================
1
==============================================================================
2
2
3
If you have sound problems with SDL try setting the variable "s_sdlSpeed" to
3
Note, that the port was switched over to use the original ioquake project
4
"44100". It will be saved to the configuration file.
4
source code instead of code provided by the UrbanTerror project. The
5
5
UrbanTerror project is switching to a closed source licensing model:
6
If you have sound problems with OpenAL recompile without it. Also the OPENAL
6
	http://www.urbanterror.info/news/texts/285/
7
option causes the program to omit restoring gamma and mouse sensivity after
8
exitting.
9
10
The configuration files are saved to ~/.ioUrbanTerror instead of ~/.q3a
11
because they have additional variables which would be removed if other engines
12
overwrite them. But you can safely copy the original directory to the new one
13
for the first time.
14
15
If you enabled CELLSHADING, check files/extra-patch-cellshading for variables.
16
7
17
==============================================================================
8
==============================================================================
(-)iourbanterror/pkg-plist (-11 / +4 lines)
Lines 1-15 Link Here
1
%%DEDICATED%%bin/ioUrTded
1
%%DEDICATED%%bin/ioUrTded
2
%%CLIENT%%bin/ioUrbanTerror
2
%%CLIENT%%bin/ioUrbanTerror
3
%%SMP%%bin/ioUrbanTerror-smp
3
%%SMP%%bin/ioUrbanTerror-smp
4
%%GAMELIBS%%%%LIBDIR%%/baseq3/cgame.so
4
%%GAMELIBS%%%%LIBDIR%%/q3ut4/cgameamd64.so
5
%%GAMELIBS%%%%LIBDIR%%/baseq3/qagame.so
5
%%GAMELIBS%%%%LIBDIR%%/q3ut4/qagameamd64.so
6
%%GAMELIBS%%%%LIBDIR%%/baseq3/ui.so
6
%%GAMELIBS%%%%LIBDIR%%/q3ut4/uiamd64.so
7
%%GAMELIBS%%%%LIBDIR%%/missionpack/cgame.so
7
%%GAMELIBS%%@dirrm %%LIBDIR%%/q3ut4
8
%%GAMELIBS%%%%LIBDIR%%/missionpack/qagame.so
9
%%GAMELIBS%%%%LIBDIR%%/missionpack/ui.so
10
%%PORTDOCS%%%%DOCSDIR%%/README
11
%%PORTDOCS%%%%DOCSDIR%%/ioUrbanTerror_README.txt
12
%%GAMELIBS%%@dirrm %%LIBDIR%%/missionpack
13
%%GAMELIBS%%@dirrm %%LIBDIR%%/baseq3
14
%%GAMELIBS%%@dirrm %%LIBDIR%%
8
%%GAMELIBS%%@dirrm %%LIBDIR%%
15
%%PORTDOCS%%@dirrm %%DOCSDIR%%

Return to bug 152637