- Add games/sdlquake2.

Basically this is a combination of R1Q2 and R1GL with SDL code from
Quake2Forge. Meaning it's R1Q2 protocol 35 compatible Linux client. Tested on
Debian Sarge. Both client and dedicated server.

WWW: http://koti.mbnet.fi/~turol/sdlquake2/
This commit is contained in:
Alejandro Pulver 2006-05-05 17:42:08 +00:00
parent 0b0a8361b2
commit 0eaf5b215b
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=161432
22 changed files with 445 additions and 0 deletions

View File

@ -555,6 +555,7 @@
SUBDIR += scummvm
SUBDIR += scummvm-tools
SUBDIR += sdb
SUBDIR += sdlquake2
SUBDIR += sdlroids
SUBDIR += seabattle
SUBDIR += seahaven

45
games/sdlquake2/Makefile Normal file
View File

@ -0,0 +1,45 @@
# New ports collection makefile for: sdlquake2
# Date created: 5 May 2006
# Whom: alepulver
#
# $FreeBSD$
#
PORTNAME= sdlquake2
PORTVERSION= 0.1.4
CATEGORIES= games
MASTER_SITES= http://koti.mbnet.fi/~turol/sdlquake2/
MAINTAINER= alepulver@FreeBSD.org
COMMENT= Combination of R1Q2 and R1GL with SDL code from Quake2Forge
LIB_DEPENDS= execinfo.1:${PORTSDIR}/devel/libexecinfo \
jpeg.9:${PORTSDIR}/graphics/jpeg \
png.5:${PORTSDIR}/graphics/png
USE_BZIP2= yes
USE_GCC= 3.2+
USE_GMAKE= yes
USE_GL= yes
USE_SDL= sdl
MAKE_ENV= LIBDIR="${LIBDIR}"
LIBDIR= ${PREFIX}/lib/${PORTNAME}
PLIST_SUB= LIBDIR=${LIBDIR:S/${PREFIX}\///}
do-install:
${MKDIR} ${LIBDIR}/baseq2
${INSTALL_PROGRAM} ${WRKSRC}/ref_sdlgl.so ${LIBDIR}
${INSTALL_PROGRAM} ${WRKSRC}/baseq2/game.so ${LIBDIR}/baseq2
${INSTALL_PROGRAM} ${WRKSRC}/quake2 ${PREFIX}/bin/${PORTNAME}
${INSTALL_PROGRAM} ${WRKSRC}/q2ded ${PREFIX}/bin/${PORTNAME}-ded
post-install:
@${ECHO_CMD}
@${CAT} ${PKGMESSAGE}
@${ECHO_CMD}
.include "${.CURDIR}/../quake2-data/Makefile.include"
.include <bsd.port.mk>

3
games/sdlquake2/distinfo Normal file
View File

@ -0,0 +1,3 @@
MD5 (sdlquake2-0.1.4.tar.bz2) = 7f7b9b871558e09783c404472d593478
SHA256 (sdlquake2-0.1.4.tar.bz2) = 5e44652f474236f8d94257c17132f68af6e70437df891856892e594572dfea73
SIZE (sdlquake2-0.1.4.tar.bz2) = 581563

View File

@ -0,0 +1,42 @@
--- ./Makefile.orig Thu May 19 17:56:13 2005
+++ ./Makefile Sun Feb 26 11:24:53 2006
@@ -1,5 +1,18 @@
-CC:=gcc
-CFLAGS:=-O3 -ffast-math -march=athlon-xp -g -Wall $(shell sdl-config --cflags)
+CC?=gcc
+SDL_CONFIG?=sdl-config
+LOCALBASE?=/usr/local
+X11BASE?=/usr/X11R6
+CFLAGS+=-O3 -ffast-math -DDATADIR='"$(Q2DIR)"' -DLIBDIR='"$(LIBDIR)"' $(shell $(SDL_CONFIG) --cflags) -I$(X11BASE)/include
+
+LIBS=-lm -lz
+
+ifeq ($(shell uname),Linux)
+LIBS+=-ldl
+endif
+
+ifeq ($(shell uname),FreeBSD)
+LIBS+=-L$(LOCALBASE)/lib -lexecinfo
+endif
GAMES:=baseq2
@@ -43,15 +56,14 @@
@sed "s@^\(.*\)\.o:@$(dir $*)\1.o:@" < .depends/$*.d > .depends/$*.d.new
@mv .depends/$*.d.new .depends/$*.d
-
quake2: $(quake2_OBJ)
- $(CC) -g -o $@ $(shell sdl-config --libs) -lz -ldl $^
+ $(CC) -g -o $@ $(shell $(SDL_CONFIG) --libs) $(LIBS) $^
q2ded: $(q2ded_OBJ)
- $(CC) -g -o $@ $^ -lz -ldl
+ $(CC) -g -o $@ $^ $(LIBS)
ref_sdlgl.so: $(sdlgl_OBJ)
- $(CC) -shared -g -o $@ $(shell sdl-config --libs) -lGL -ljpeg -lpng12 $^
+ $(CC) -shared -g -o $@ $(shell $(SDL_CONFIG) --libs) -L$(X11BASE)/lib -lGL -ljpeg -lpng $^
ALLOBJ:=$(quake2_OBJ) $(sdlgl_OBJ)

View File

@ -0,0 +1,11 @@
--- ./cl_main.c.orig Thu May 19 17:56:13 2005
+++ ./cl_main.c Sun Feb 26 11:23:56 2006
@@ -3657,7 +3657,7 @@
Cbuf_Execute ();
Con_Init ();
-#if defined __linux__ || defined __sgi
+#if defined __linux__ || defined __sgi || defined __FreeBSD__
S_Init (true);
VID_Init ();

View File

@ -0,0 +1,60 @@
--- ./files.c.orig Thu May 19 17:56:13 2005
+++ ./files.c Sun Feb 26 11:23:56 2006
@@ -233,7 +233,7 @@
#ifdef MAGIC_BTREE
rb = rbinit (_compare, 1);
#else
-#ifdef LINUX
+#if defined(__linux__) || defined(__FreeBSD__)
rb = rbinit ((int (*)(const void *, const void *))strcmp, 0);
#else
rb = rbinit ((int (*)(const void *, const void *))Q_stricmp, 0);
@@ -1158,6 +1158,7 @@
Com_sprintf (fs_gamedir, sizeof(fs_gamedir), "%s/%s", fs_basedir->string, dir);
Cvar_FullSet ("gamedir", dir, CVAR_SERVERINFO|CVAR_NOSET);
FS_AddGameDirectory (va("%s/%s", fs_basedir->string, dir) );
+ FS_AddGameDirectory (va("%s/%s", LIBDIR, dir));
}
}
@@ -1383,6 +1384,9 @@
*/
void FS_InitFilesystem (void)
{
+ char *home;
+ char homedir[MAX_OSPATH];
+
current_filename = "unknown";
Cmd_AddCommand ("path", FS_Path_f);
@@ -1405,7 +1409,7 @@
// basedir <path>
// allows the game to run from outside the data tree
//
- fs_basedir = Cvar_Get ("basedir", ".", CVAR_NOSET);
+ fs_basedir = Cvar_Get ("basedir", DATADIR, CVAR_NOSET);
fs_cache = Cvar_Get ("fs_cache", "7", 0);
fs_noextern = Cvar_Get ("fs_noextern", "0", 0);
@@ -1413,6 +1417,7 @@
// start up with baseq2 by default
//
FS_AddGameDirectory (va("%s/"BASEDIRNAME, fs_basedir->string) );
+ FS_AddGameDirectory (va("%s/"BASEDIRNAME, LIBDIR));
// any set gamedirs will be freed up to here
fs_base_searchpaths = fs_searchpaths;
@@ -1421,4 +1426,13 @@
fs_gamedirvar = Cvar_Get ("game", "", CVAR_LATCH|CVAR_SERVERINFO);
if (fs_gamedirvar->string[0])
FS_SetGamedir (fs_gamedirvar->string);
+
+ if ((home = getenv("HOME")) != NULL) {
+ strncpy(homedir, home, sizeof(homedir)-1);
+ strncat(homedir, "/.sdlquake2/", sizeof(homedir)-strlen(homedir)-1);
+ Sys_Mkdir(homedir);
+ strncat(homedir, fs_gamedirvar->string[0] ? fs_gamedirvar->string : BASEDIRNAME, sizeof(homedir)-strlen(homedir)-1);
+ Sys_Mkdir(homedir);
+ FS_AddGameDirectory(homedir);
+ }
}

View File

@ -0,0 +1,32 @@
--- ./gl_image.c.orig Thu May 19 17:56:13 2005
+++ ./gl_image.c Sun Feb 26 11:23:56 2006
@@ -555,7 +555,7 @@
size_t Pos;
} TPngFileBuffer;
-void __cdecl PngReadFunc(png_struct *Png, png_bytep buf, png_size_t size)
+void PngReadFunc(png_struct *Png, png_bytep buf, png_size_t size)
{
TPngFileBuffer *PngFileBuffer=(TPngFileBuffer*)png_get_io_ptr(Png);
memcpy(buf,PngFileBuffer->Buffer+PngFileBuffer->Pos,size);
@@ -1007,17 +1007,17 @@
=================================================================
*/
-void __cdecl jpg_null(j_decompress_ptr cinfo)
+void jpg_null(j_decompress_ptr cinfo)
{
}
-unsigned char __cdecl jpg_fill_input_buffer(j_decompress_ptr cinfo)
+unsigned char jpg_fill_input_buffer(j_decompress_ptr cinfo)
{
ri.Con_Printf(PRINT_ALL, "Premature end of JPEG data\n");
return 1;
}
-void __cdecl jpg_skip_input_data(j_decompress_ptr cinfo, long num_bytes)
+void jpg_skip_input_data(j_decompress_ptr cinfo, long num_bytes)
{
cinfo->src->next_input_byte += (size_t) num_bytes;

View File

@ -0,0 +1,11 @@
--- ./gl_local.h.orig Thu May 19 17:56:13 2005
+++ ./gl_local.h Sun Feb 26 11:23:56 2006
@@ -28,7 +28,7 @@
#include <GL/glu.h>
#include <math.h>
-#ifndef __linux__
+#if !defined(__linux__) && !defined(__FreeBSD__)
#ifndef GL_COLOR_INDEX8_EXT
#define GL_COLOR_INDEX8_EXT GL_COLOR_INDEX
#endif

View File

@ -0,0 +1,11 @@
--- ./gl_rmain.c.orig Thu May 19 17:56:13 2005
+++ ./gl_rmain.c Sun Feb 26 11:23:56 2006
@@ -1450,7 +1450,7 @@
ri.Cvar_Set( "scr_drawall", "0" );
}
-#ifdef __linux__
+#if defined(__linux__) || defined(__FreeBSD__)
ri.Cvar_SetValue( "gl_finish", 0 );
#endif

View File

@ -0,0 +1,10 @@
--- ./menu.c.orig Thu May 19 17:56:13 2005
+++ ./menu.c Sun Feb 26 11:23:56 2006
@@ -587,6 +587,7 @@
{
{"+attack", "attack"},
{"weapnext", "next weapon"},
+{"weapprev", "previous weapon"},
{"+forward", "walk forward"},
{"+back", "backpedal"},
{"+left", "turn left"},

View File

@ -0,0 +1,19 @@
--- ./q_shared.h.orig Thu May 19 17:56:13 2005
+++ ./q_shared.h Sun Feb 26 11:25:24 2006
@@ -97,7 +97,16 @@
typedef unsigned __int16 uint16;
typedef unsigned __int64 uint64;
#else /* NON-WIN32 */
+#ifdef __FreeBSD__
+#include <sys/param.h>
+#if __FreeBSD_version < 500000
+#include <inttypes.h>
+#else
#include <stdint.h>
+#endif
+#else
+#include <stdint.h>
+#endif
typedef int32_t int32;
typedef int16_t int16;
typedef int64_t int64;

View File

@ -0,0 +1,48 @@
--- ./q_shlinux.c.orig Thu May 19 17:56:13 2005
+++ ./q_shlinux.c Sun Feb 26 11:23:56 2006
@@ -12,6 +12,10 @@
#include "qcommon.h"
+#ifdef __FreeBSD__
+#include <machine/param.h>
+#endif
+
//===============================================================================
byte *membase;
@@ -54,14 +58,32 @@
int Hunk_End (void)
{
-#ifndef __FreeBSD__
byte *n;
+#ifdef __FreeBSD__
+ size_t old_size = maxhunksize;
+ size_t new_size = curhunksize + sizeof(int);
+ void * unmap_base;
+ size_t unmap_len;
+
+ new_size = round_page(new_size);
+ old_size = round_page(old_size);
+
+ if (new_size > old_size)
+ n = 0; /* error */
+ else if (new_size < old_size)
+ {
+ unmap_base = (caddr_t)(membase + new_size);
+ unmap_len = old_size - new_size;
+ n = munmap(unmap_base, unmap_len) + membase;
+ }
+#endif
+#ifdef __linux__
n = mremap(membase, maxhunksize, curhunksize + sizeof(int), 0);
+#endif
if (n != membase)
Sys_Error("Hunk_End: Could not remap virtual block (%d)", errno);
*((int *)membase) = curhunksize + sizeof(int);
-#endif
return curhunksize;
}

View File

@ -0,0 +1,20 @@
--- ./qgl.h.orig Thu May 19 17:56:13 2005
+++ ./qgl.h Sun Feb 26 11:23:56 2006
@@ -31,7 +31,7 @@
#include <GL/gl.h>
#include "glext.h"
-#ifdef __linux__
+#if defined(__linux__) || defined(__FreeBSD__)
//#include <GL/fxmesa.h>
#include <GL/glx.h>
#endif
@@ -436,7 +436,7 @@
#endif
-#ifdef __linux__
+#if defined(__linux__) || defined(__FreeBSD__)
// local function in dll
extern void *qwglGetProcAddress(char *symbol);

View File

@ -0,0 +1,22 @@
--- ./snd_mix.c.orig Thu May 19 17:56:13 2005
+++ ./snd_mix.c Sun Feb 26 11:23:56 2006
@@ -168,8 +168,8 @@
===============================================================================
*/
-void __cdecl S_PaintChannelFrom8 (channel_t *ch, sfxcache_t *sc, int endtime, int offset);
-void __cdecl S_PaintChannelFrom16 (channel_t *ch, sfxcache_t *sc, int endtime, int offset);
+void S_PaintChannelFrom8 (channel_t *ch, sfxcache_t *sc, int endtime, int offset);
+void S_PaintChannelFrom16 (channel_t *ch, sfxcache_t *sc, int endtime, int offset);
void S_PaintChannels(int endtime)
{
@@ -349,7 +349,7 @@
}
-void __cdecl S_PaintChannelFrom16 (channel_t *ch, sfxcache_t *sc, int count, int offset)
+void S_PaintChannelFrom16 (channel_t *ch, sfxcache_t *sc, int count, int offset)
{
int data;
int left, right;

View File

@ -0,0 +1,23 @@
--- ./snd_openal.h.orig Thu May 19 17:56:13 2005
+++ ./snd_openal.h Sun Feb 26 11:23:56 2006
@@ -18,7 +18,7 @@
#ifdef _WIN32
#include "alw_win.h"
#endif
-#ifdef __linux__
+#if defined(__linux__) || defined(__FreeBSD__)
#include "al_linux.h"
#endif
#endif
@@ -162,9 +162,9 @@
#define ALimp_Shutdown ALW_Shutdown
#else
-#ifdef __linux__
+#if defined(__linux__) || defined(__FreeBSD__)
-#define AL_DRIVER_OPENAL "/usr/lib/libopenal.so"
+#define AL_DRIVER_OPENAL "libopenal.so"
#define ALimp_Init AL_Init
#define ALimp_Shutdown AL_Shutdown

View File

@ -0,0 +1,12 @@
--- ./sv_ccmds.c.orig Thu May 19 17:56:13 2005
+++ ./sv_ccmds.c Sun Feb 26 11:23:56 2006
@@ -589,7 +589,8 @@
SV_Map (false, Cmd_Argv(1), false );
// archive server state
- strncpy (svs.mapcmd, Cmd_Argv(1), sizeof(svs.mapcmd)-1);
+ if (Cmd_Argv(1)[0] != '\0')
+ strncpy (svs.mapcmd, Cmd_Argv(1), sizeof(svs.mapcmd)-1);
// copy off the level to the autosave slot
if (!dedicated->intvalue && !Cvar_IntValue ("deathmatch"))

View File

@ -0,0 +1,11 @@
--- ./sv_user.c.orig Thu May 19 17:56:13 2005
+++ ./sv_user.c Sun Feb 26 11:23:56 2006
@@ -1183,7 +1183,7 @@
sv_client->downloadsize = FS_LoadFile (name, NULL);
//adjust case and re-try
-#ifdef LINUX
+#if defined(__linux__) || defined(__FreeBSD__)
if (sv_client->downloadsize == -1)
{
Q_strlwr (name);

View File

@ -0,0 +1,29 @@
--- ./sys_linux.c.orig Thu May 19 17:56:13 2005
+++ ./sys_linux.c Sun Feb 26 11:23:56 2006
@@ -230,7 +230,7 @@
size = backtrace (array, sizeof(array)/sizeof(void*));
-#ifndef __x86_64__
+#if !defined(__x86_64__) && !defined(__FreeBSD__)
array[1] = (void *) uc->uc_mcontext.gregs[REG_EIP];
#endif
@@ -423,7 +423,7 @@
if (baseq2)
{
- Com_sprintf (name, sizeof(name), "%s/%s/%s", curpath, BASEDIRNAME, gamename);
+ Com_sprintf (name, sizeof(name), "%s/%s/%s", LIBDIR, BASEDIRNAME, gamename);
game_library = dlopen (name, RTLD_NOW );
}
else
@@ -435,7 +435,7 @@
path = FS_NextPath (path);
if (!path)
return NULL; // couldn't find one anywhere
- Com_sprintf (name, sizeof(name), "%s/%s/%s", curpath, path, gamename);
+ Com_sprintf (name, sizeof(name), "%s/%s", path, gamename);
game_library = dlopen (name, RTLD_NOW );
if (game_library)
{

View File

@ -0,0 +1,11 @@
--- ./vid_so.c.orig Thu May 19 17:56:13 2005
+++ ./vid_so.c Sun Feb 26 11:23:56 2006
@@ -225,7 +225,7 @@
fn[strlen(fn) - 1] = 0;
*/
- strcpy (fn, ".");
+ strcpy (fn, LIBDIR);
strcat(fn, "/");
strcat(fn, name);

View File

@ -0,0 +1,5 @@
Basically this is a combination of R1Q2 and R1GL with SDL code from
Quake2Forge. Meaning it's R1Q2 protocol 35 compatible Linux client. Tested on
Debian Sarge. Both client and dedicated server.
WWW: http://koti.mbnet.fi/~turol/sdlquake2/

View File

@ -0,0 +1,13 @@
==============================================================================
SDLQuake2 has been installed.
The binaries have been renamed to "sdlquake2" and "sdlquake2-ded" to avoid
conflicting with the "games/quake2lnx" port.
The configuration will be written to the "~/.sdlquake2" directory.
The gamma can not be adjusted from the game. You can use "xgamma" to change it
before running it, and restore it later.
==============================================================================

View File

@ -0,0 +1,6 @@
bin/sdlquake2
bin/sdlquake2-ded
%%LIBDIR%%/baseq2/game.so
%%LIBDIR%%/ref_sdlgl.so
@dirrm %%LIBDIR%%/baseq2
@dirrm %%LIBDIR%%