Compare commits

...

5 Commits

21 changed files with 105 additions and 706 deletions

View File

@ -9,20 +9,21 @@ if(NOT MSVC)
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wall -Wextra -Werror")
endif()
find_package(OpenGL REQUIRED)
find_package(OpenGL REQUIRED)
find_package(PkgConfig REQUIRED)
pkg_check_modules(SDL2 REQUIRED IMPORTED_TARGET sdl2>=2.0.0)
pkg_check_modules(FLAC REQUIRED IMPORTED_TARGET flac>=1.3.3)
pkg_check_modules(Vorbis REQUIRED IMPORTED_TARGET vorbis>=1.3.6
vorbisfile>=1.3.6
ogg>=1.3.4)
pkg_check_modules(Opus REQUIRED IMPORTED_TARGET opus>=1.3.1
opusfile>=0.11
ogg>=1.3.4)
pkg_check_modules(MikMod REQUIRED IMPORTED_TARGET libmikmod>=3.3.11)
pkg_check_modules(SDL2 REQUIRED IMPORTED_TARGET sdl2>=2.0.0)
add_executable(quake WIN32
pkg_check_modules(FLAC IMPORTED_TARGET flac>=1.3.3)
pkg_check_modules(Vorbis IMPORTED_TARGET vorbis>=1.3.6
vorbisfile>=1.3.6
ogg>=1.3.4)
pkg_check_modules(Opus IMPORTED_TARGET opus>=1.3.1
opusfile>=0.11
ogg>=1.3.4)
pkg_check_modules(MikMod IMPORTED_TARGET libmikmod>=3.3.11)
set(srcs
source/anorm_dots.h
source/anorms.h
source/arch_def.h
@ -85,7 +86,6 @@ add_executable(quake WIN32
source/menu.h
source/modelgen.h
source/net.h
source/net_bsd.c
source/net_defs.h
source/net_dgrm.c
source/net_dgrm.h
@ -93,9 +93,6 @@ add_executable(quake WIN32
source/net_loop.h
source/net_main.c
source/net_sys.h
source/net_udp.c
source/net_udp.h
source/pl_linux.c
source/platform.h
source/pr_cmds.c
source/pr_comp.h
@ -140,10 +137,6 @@ add_executable(quake WIN32
source/snd_umx.h
source/snd_vorbis.c
source/snd_vorbis.h
source/snd_wave.c
source/snd_wave.h
source/snd_xmp.c
source/snd_xmp.h
source/spritegn.h
source/stb_image_write.h
source/strl_fn.h
@ -154,7 +147,6 @@ add_executable(quake WIN32
source/sv_phys.c
source/sv_user.c
source/sys.h
source/sys_sdl_unix.c
source/vid.h
source/view.c
source/view.h
@ -166,20 +158,36 @@ add_executable(quake WIN32
source/zone.c
source/zone.h)
target_compile_definitions(
quake
PUBLIC
-DUSE_CODEC_FLAC=1
-DUSE_CODEC_VORBIS=1
-DUSE_CODEC_OPUS=1
-DUSE_CODEC_MIKMOD=1
-DUSE_CODEC_UMX=1)
if(WIN32)
list(APPEND srcs
source/net_win.c
source/net_wins.c
source/net_wins.h
source/net_wipx.c
source/net_wipx.h
source/pl_win.c
source/sys_sdl_win.c)
else()
list(APPEND srcs
source/net_bsd.c
source/net_udp.c
source/net_udp.h
source/pl_linux.c
source/sys_sdl_unix.c)
endif()
target_link_libraries(quake
m
OpenGL::GL
PkgConfig::SDL2
PkgConfig::FLAC
PkgConfig::Vorbis
PkgConfig::Opus
PkgConfig::MikMod)
add_executable(quake WIN32 ${srcs})
function(agw_checked_library define library)
if(${library}_FOUND)
target_compile_definitions(quake PUBLIC -D${define}=1)
target_link_libraries(quake PkgConfig::${library})
endif()
endfunction()
agw_checked_library(USE_CODEC_FLAC FLAC)
agw_checked_library(USE_CODEC_VORBIS Vorbis)
agw_checked_library(USE_CODEC_OPUS Opus)
agw_checked_library(USE_CODEC_MikMod MikMod)
target_link_libraries(quake m OpenGL::GL PkgConfig::SDL2)

View File

@ -25,6 +25,7 @@
#include "quakedef.h"
#include "snd_codec.h"
#include "bgmusic.h"
#include "cdaudio.h"
#define MUSIC_DIRNAME "music"
@ -169,7 +170,7 @@ qboolean BGM_Init (void)
}
}
return true;
return CDAudio_Init ();
}
void BGM_Shutdown (void)
@ -178,6 +179,7 @@ void BGM_Shutdown (void)
/* sever our connections to
* midi_drv and snd_codec */
music_handlers = NULL;
CDAudio_Shutdown ();
}
static void BGM_Play_noext (const char *filename, unsigned int allowed_types)
@ -292,7 +294,7 @@ void BGM_PlayCDtrack (byte track, qboolean looping)
BGM_Stop();
if (CDAudio_Play(track, looping) == 0)
return; /* success */
return; /* success */
if (music_handlers == NULL)
return;
@ -344,6 +346,7 @@ void BGM_Stop (void)
bgmstream = NULL;
s_rawend = 0;
}
CDAudio_Stop();
}
void BGM_Pause (void)
@ -353,6 +356,7 @@ void BGM_Pause (void)
if (bgmstream->status == STREAM_PLAY)
bgmstream->status = STREAM_PAUSE;
}
CDAudio_Pause ();
}
void BGM_Resume (void)
@ -362,6 +366,7 @@ void BGM_Resume (void)
if (bgmstream->status == STREAM_PAUSE)
bgmstream->status = STREAM_PLAY;
}
CDAudio_Resume ();
}
static void BGM_UpdateStream (void)
@ -465,5 +470,7 @@ void BGM_Update (void)
}
if (bgmstream)
BGM_UpdateStream ();
CDAudio_Update();
}

View File

@ -310,101 +310,5 @@ typedef struct
//============================================================================
#ifndef QUAKE_GAME
#define ANGLE_UP -1
#define ANGLE_DOWN -2
// the utilities get to be lazy and just use large static arrays
extern int nummodels;
extern dmodel_t dmodels[MAX_MAP_MODELS];
extern int visdatasize;
extern byte dvisdata[MAX_MAP_VISIBILITY];
extern int lightdatasize;
extern byte dlightdata[MAX_MAP_LIGHTING];
extern int texdatasize;
extern byte dtexdata[MAX_MAP_MIPTEX]; // (dmiptexlump_t)
extern int entdatasize;
extern char dentdata[MAX_MAP_ENTSTRING];
//extern int numleafs;
//extern dleaf_t dleafs[MAX_MAP_LEAFS];
extern int numplanes;
extern dplane_t dplanes[MAX_MAP_PLANES];
extern int numvertexes;
extern dvertex_t dvertexes[MAX_MAP_VERTS];
extern int numnodes;
extern dnode_t dnodes[MAX_MAP_NODES];
extern int numtexinfo;
extern texinfo_t texinfo[MAX_MAP_TEXINFO];
extern int numfaces;
extern dface_t dfaces[MAX_MAP_FACES];
extern int numclipnodes;
extern dclipnode_t dclipnodes[MAX_MAP_CLIPNODES];
extern int numedges;
extern dedge_t dedges[MAX_MAP_EDGES];
extern int nummarksurfaces;
extern unsigned short dmarksurfaces[MAX_MAP_MARKSURFACES];
extern int numsurfedges;
extern int dsurfedges[MAX_MAP_SURFEDGES];
void DecompressVis (byte *in, byte *decompressed);
int CompressVis (byte *vis, byte *dest);
void LoadBSPFile (char *filename);
void WriteBSPFile (char *filename);
void PrintBSPFileSizes (void);
//===============
typedef struct epair_s
{
struct epair_s *next;
char *key;
char *value;
} epair_t;
typedef struct
{
vec3_t origin;
int firstbrush;
int numbrushes;
epair_t *epairs;
} entity_t;
extern int num_entities;
extern entity_t entities[MAX_MAP_ENTITIES];
void ParseEntities (void);
void UnparseEntities (void);
void SetKeyValue (entity_t *ent, char *key, char *value);
char *ValueForKey (entity_t *ent, char *key);
// will return "" if not present
vec_t FloatForKey (entity_t *ent, char *key);
void GetVectorForKey (entity_t *ent, char *key, vec3_t vec);
epair_t *ParseEpair (void);
#endif /* QUAKE_GAME */
#endif /* __BSPFILE_H */

View File

@ -24,16 +24,15 @@
#include <SDL.h>
#ifndef SDL_INIT_CDROM
#if !defined(SDL_INIT_CDROM)
/* SDL dropped support for
cd audio since v1.3.0 */
#pragma message("Warning: SDL CDAudio support disabled")
/* SDL dropped support for CD audio since v1.3.0 */
#include "cd_null.c"
#else /* SDL_INIT_CDROM */
#else /* defined(SDL_INIT_CDROM) */
#include "quakedef.h"
#include "cdaudio.h"
static qboolean cdValid = false;
static qboolean playing = false;
@ -581,5 +580,5 @@ void CDAudio_Shutdown(void)
SDL_QuitSubSystem(SDL_INIT_CDROM);
}
#endif /* SDL_INIT_CDROM */
#endif /* defined(SDL_INIT_CDROM) */

View File

@ -107,7 +107,6 @@ void CL_Disconnect (void)
// stop sounds (especially looping!)
S_StopAllSounds (true);
BGM_Stop();
CDAudio_Stop();
// if running a local server, shut it down
if (cls.demoplayback)
@ -446,7 +445,7 @@ void CL_RelinkEntities (void)
{
if (!ent->model)
{ // empty slot
// ericw -- efrags are only used for static entities in GLQuake
// ent can't be static, so this is a no-op.
//if (ent->forcelink)
@ -791,7 +790,7 @@ void CL_Init (void)
Cvar_RegisterVariable (&lookspring);
Cvar_RegisterVariable (&lookstrafe);
Cvar_RegisterVariable (&sensitivity);
Cvar_RegisterVariable (&cl_alwaysrun);
Cvar_RegisterVariable (&m_pitch);

View File

@ -286,17 +286,17 @@ void CL_ParseServerInfo (void)
if (cl.protocol == PROTOCOL_RMQ)
{
const unsigned int supportedflags = (PRFL_SHORTANGLE | PRFL_FLOATANGLE | PRFL_24BITCOORD | PRFL_FLOATCOORD | PRFL_EDICTSCALE | PRFL_INT32COORD);
// mh - read protocol flags from server so that we know what protocol features to expect
cl.protocolflags = (unsigned int) MSG_ReadLong ();
if (0 != (cl.protocolflags & (~supportedflags)))
{
Con_Warning("PROTOCOL_RMQ protocolflags %i contains unsupported flags\n", cl.protocolflags);
}
}
else cl.protocolflags = 0;
// parse maxclients
cl.maxclients = MSG_ReadByte ();
if (cl.maxclients < 1 || cl.maxclients > MAX_SCOREBOARD)
@ -816,7 +816,7 @@ void CL_ParseClientdata (void)
else
cl.viewent.alpha = ENTALPHA_DEFAULT;
//johnfitz
//johnfitz -- lerping
//ericw -- this was done before the upper 8 bits of cl.stats[STAT_WEAPON] were filled in, breaking on large maps like zendar.bsp
if (cl.viewent.model != cl.model_precache[cl.stats[STAT_WEAPON]])
@ -1124,15 +1124,9 @@ void CL_ParseServerMessage (void)
case svc_setpause:
cl.paused = MSG_ReadByte ();
if (cl.paused)
{
CDAudio_Pause ();
BGM_Pause ();
}
else
{
CDAudio_Resume ();
BGM_Resume ();
}
break;
case svc_signonnum:

View File

@ -522,7 +522,7 @@ void Con_Printf (const char *fmt, ...)
/*
================
Con_DWarning -- ericw
same as Con_Warning, but only prints if "developer" cvar is set.
use for "exceeds standard limit of" messages, which are only relevant for developers
targetting vanilla engines
@ -951,7 +951,7 @@ void Con_TabComplete (void)
// for (like "map ") and a list of all the maps.
arg_completion_type_t arg_completion = arg_completion_types[j];
const char *command_name = arg_completion.command;
if (!strncmp (key_lines[edit_line] + 1, command_name, strlen(command_name)))
{
int nummatches = 0;
@ -1227,7 +1227,7 @@ void Con_DrawConsole (int lines, qboolean drawinput)
//draw version number in bottom right
y += 8;
q_snprintf (ver, sizeof(ver), "QuakeSpasm " QUAKESPASM_VER_STRING);
q_snprintf (ver, sizeof(ver), "QuakeSpasm " QUAKESPASM_VERSION);
for (x = 0; x < (int)strlen(ver); x++)
Draw_Character ((con_linewidth - strlen(ver) + x + 2)<<3, y, ver[x] /*+ 128*/);
}

View File

@ -485,7 +485,6 @@ static qboolean VID_SetMode (int width, int height, int refreshrate, int bpp, qb
temp = scr_disabled_for_loading;
scr_disabled_for_loading = true;
CDAudio_Pause ();
BGM_Pause ();
/* z-buffer depth */
@ -506,7 +505,7 @@ static qboolean VID_SetMode (int width, int height, int refreshrate, int bpp, qb
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, fsaa > 0 ? 1 : 0);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, fsaa);
q_snprintf(caption, sizeof(caption), "QuakeSpasm " QUAKESPASM_VER_STRING);
q_snprintf(caption, sizeof(caption), "QuakeSpasm " QUAKESPASM_VERSION);
/* Create the window if needed, hidden */
if (!draw_context)
@ -599,7 +598,6 @@ static qboolean VID_SetMode (int width, int height, int refreshrate, int bpp, qb
modestate = VID_GetFullscreen() ? MS_FULLSCREEN : MS_WINDOWED;
CDAudio_Resume ();
BGM_Resume ();
scr_disabled_for_loading = temp;

View File

@ -230,8 +230,8 @@ void Host_FindMaxClients (void)
void Host_Version_f (void)
{
Con_Printf ("Quake Version %1.2f\n", VERSION);
Con_Printf ("QuakeSpasm Version " QUAKESPASM_VER_STRING "\n");
Con_Printf ("Quake Version %s\n", VERSION);
Con_Printf ("QuakeSpasm Version " QUAKESPASM_VERSION "\n");
Con_Printf ("Exe: " __TIME__ " " __DATE__ "\n");
}
@ -749,8 +749,6 @@ void _Host_Frame (float time)
else
S_Update (vec3_origin, vec3_origin, vec3_origin, vec3_origin);
CDAudio_Update();
if (host_speeds.value)
{
pass1 = (time1 - time3)*1000;
@ -862,7 +860,6 @@ void Host_Init (void)
SCR_Init ();
R_Init ();
S_Init ();
CDAudio_Init ();
BGM_Init();
Sbar_Init ();
CL_Init ();
@ -924,7 +921,6 @@ void Host_Shutdown(void)
if (con_initialized)
History_Shutdown ();
BGM_Shutdown();
CDAudio_Shutdown ();
S_Shutdown ();
IN_Shutdown ();
VID_Shutdown();

View File

@ -98,7 +98,7 @@ void FileList_Add (const char *name, filelist_item_t **list)
static void FileList_Clear (filelist_item_t **list)
{
filelist_item_t *blah;
while (*list)
{
blah = (*list)->next;
@ -316,11 +316,11 @@ void DemoList_Init (void)
searchpath_t *search;
pack_t *pak;
int i;
// we don't want to list the demos in id1 pakfiles,
// because these are not "add-on" demos
q_snprintf (ignorepakdir, sizeof(ignorepakdir), "/%s/", GAMENAME);
for (search = com_searchpaths; search; search = search->next)
{
if (*search->filename) //directory
@ -442,7 +442,7 @@ void Host_Status_f (void)
print_fn = SV_ClientPrintf;
print_fn ("host: %s\n", Cvar_VariableString ("hostname"));
print_fn ("version: %4.2f\n", VERSION);
print_fn ("version: " VERSION "\n");
if (tcpipAvailable)
print_fn ("tcp/ip: %s\n", my_tcpip_address);
if (ipxAvailable)
@ -631,10 +631,10 @@ void Host_SetPos_f(void)
Cmd_ForwardToServer ();
return;
}
if (pr_global_struct->deathmatch)
return;
if (Cmd_Argc() != 7 && Cmd_Argc() != 4)
{
SV_ClientPrintf("usage:\n");
@ -650,23 +650,23 @@ void Host_SetPos_f(void)
(int)sv_player->v.v_angle[2]);
return;
}
if (sv_player->v.movetype != MOVETYPE_NOCLIP)
{
noclip_anglehack = true;
sv_player->v.movetype = MOVETYPE_NOCLIP;
SV_ClientPrintf ("noclip ON\n");
}
//make sure they're not going to whizz away from it
sv_player->v.velocity[0] = 0;
sv_player->v.velocity[1] = 0;
sv_player->v.velocity[2] = 0;
sv_player->v.origin[0] = atof(Cmd_Argv(1));
sv_player->v.origin[1] = atof(Cmd_Argv(2));
sv_player->v.origin[2] = atof(Cmd_Argv(3));
if (Cmd_Argc() == 7)
{
sv_player->v.angles[0] = atof(Cmd_Argv(4));
@ -674,7 +674,7 @@ void Host_SetPos_f(void)
sv_player->v.angles[2] = atof(Cmd_Argv(6));
sv_player->v.fixangle = 1;
}
SV_LinkEdict (sv_player, false);
}
@ -1120,7 +1120,7 @@ Host_Loadgame_f
void Host_Loadgame_f (void)
{
static char *start;
char name[MAX_OSPATH];
char mapname[MAX_QPATH];
float time, tfloat;
@ -1139,7 +1139,7 @@ void Host_Loadgame_f (void)
Con_Printf ("load <savename> : load a game\n");
return;
}
if (strstr(Cmd_Argv(1), ".."))
{
Con_Printf ("Relative pathnames are not allowed.\n");
@ -1156,11 +1156,11 @@ void Host_Loadgame_f (void)
// SCR_BeginLoadingPlaque ();
Con_Printf ("Loading game from %s...\n", name);
// avoid leaking if the previous Host_Loadgame_f failed with a Host_Error
if (start != NULL)
free (start);
start = (char *) COM_LoadMallocFile_TextMode_OSPath(name, NULL);
if (start == NULL)
{

View File

@ -105,11 +105,10 @@ int main(int argc, char *argv[])
if (!parms.membase)
Sys_Error ("Not enough memory free; check disk space\n");
Sys_Printf("Quake %1.2f (c) id Software\n", VERSION);
Sys_Printf("GLQuake %1.2f (c) id Software\n", GLQUAKE_VERSION);
Sys_Printf("FitzQuake %1.2f (c) John Fitzgibbons\n", FITZQUAKE_VERSION);
Sys_Printf("Quake " VERSION " (c) id Software\n");
Sys_Printf("FitzQuake " FITZQUAKE_VERSION " (c) John Fitzgibbons\n");
Sys_Printf("FitzQuake SDL port (c) SleepwalkR, Baker\n");
Sys_Printf("QuakeSpasm " QUAKESPASM_VER_STRING " (c) Ozkan Sezer, Eric Wasylishen & others\n");
Sys_Printf("QuakeSpasm " QUAKESPASM_VERSION " (c) Ozkan Sezer, Eric Wasylishen & others\n");
Sys_Printf("Host_Init\n");
Host_Init();

View File

@ -1089,9 +1089,9 @@ void M_AdjustSliders (int dir)
curr_alwaysrun = ALWAYSRUN_VANILLA;
else
curr_alwaysrun = ALWAYSRUN_OFF;
target_alwaysrun = (ALWAYSRUN_ITEMS + curr_alwaysrun + dir) % ALWAYSRUN_ITEMS;
if (target_alwaysrun == ALWAYSRUN_VANILLA)
{
Cvar_SetValue ("cl_alwaysrun", 0);
@ -1200,7 +1200,7 @@ void M_Options_Draw (void)
M_Print (16, 32 + 8*OPT_CONTRAST, " Contrast");
r = vid_contrast.value - 1.0;
M_DrawSlider (220, 32 + 8*OPT_CONTRAST, r);
// OPT_MOUSESPEED:
M_Print (16, 32 + 8*OPT_MOUSESPEED, " Mouse Speed");
r = (sensitivity.value - 1)/10;
@ -1696,7 +1696,7 @@ void M_Quit_Draw (void) //johnfitz -- modified for new quit message
m_state = m_quit;
}
sprintf(msg1, "QuakeSpasm " QUAKESPASM_VER_STRING);
sprintf(msg1, "QuakeSpasm " QUAKESPASM_VERSION);
//okay, this is kind of fucked up. M_DrawTextBox will always act as if
//width is even. Also, the width and lines values are for the interior of the box,

View File

@ -26,27 +26,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
// quakedef.h -- primary header for client
#define QUAKE_GAME // as opposed to utilities
#define VERSION 1.09
#define GLQUAKE_VERSION 1.00
#define D3DQUAKE_VERSION 0.01
#define WINQUAKE_VERSION 0.996
#define LINUX_VERSION 1.30
#define X11_VERSION 1.10
#define FITZQUAKE_VERSION 0.85 //johnfitz
#define QUAKESPASM_VERSION 0.93
#define QUAKESPASM_VER_PATCH 1 // helper to print a string like 0.93.1
#ifndef QUAKESPASM_VER_SUFFIX
#define QUAKESPASM_VER_SUFFIX // optional version suffix string literal like "-beta1"
#endif
#define QS_STRINGIFY_(x) #x
#define QS_STRINGIFY(x) QS_STRINGIFY_(x)
// combined version string like "0.92.1-beta1"
#define QUAKESPASM_VER_STRING QS_STRINGIFY(QUAKESPASM_VERSION) "." QS_STRINGIFY(QUAKESPASM_VER_PATCH) QUAKESPASM_VER_SUFFIX
#define VERSION "1.09"
#define FITZQUAKE_VERSION "0.85" //johnfitz
#define QUAKESPASM_VERSION "0.93.1"
//define PARANOID // speed sapping error checking
@ -248,7 +230,6 @@ typedef struct
#include "input.h"
#include "keys.h"
#include "menu.h"
#include "cdaudio.h"
#include "glquake.h"

View File

@ -29,9 +29,7 @@
/* headers for individual codecs */
#include "snd_mikmod.h"
#include "snd_xmp.h"
#include "snd_umx.h"
#include "snd_wave.h"
#include "snd_flac.h"
#include "snd_mp3.h"
#include "snd_vorbis.h"
@ -63,29 +61,21 @@ void S_CodecInit (void)
/* Register in the inverse order
* of codec choice preference: */
#ifdef USE_CODEC_UMX
S_CodecRegister(&umx_codec);
#endif
#ifdef USE_CODEC_MIKMOD
S_CodecRegister(&mikmod_codec);
#endif
#ifdef USE_CODEC_XMP
S_CodecRegister(&xmp_codec);
#endif
#ifdef USE_CODEC_WAVE
S_CodecRegister(&wav_codec);
#endif
#ifdef USE_CODEC_FLAC
S_CodecRegister(&flac_codec);
#endif
#ifdef USE_CODEC_MP3
S_CodecRegister(&mp3_codec);
#ifdef USE_CODEC_OPUS
S_CodecRegister(&opus_codec);
#endif
#ifdef USE_CODEC_VORBIS
S_CodecRegister(&vorbis_codec);
#endif
#ifdef USE_CODEC_OPUS
S_CodecRegister(&opus_codec);
#ifdef USE_CODEC_MP3
S_CodecRegister(&mp3_codec);
#endif
codec = codecs;

View File

@ -29,7 +29,6 @@
#include "quakedef.h"
#if defined(USE_CODEC_UMX)
#include "snd_codec.h"
#include "snd_codeci.h"
#include "snd_umx.h"
@ -403,5 +402,3 @@ snd_codec_t umx_codec =
NULL
};
#endif /* USE_CODEC_UMX */

View File

@ -2,11 +2,7 @@
#if !defined(_SND_UMX_H_)
#define _SND_UMX_H_
#if defined(USE_CODEC_UMX)
extern snd_codec_t umx_codec;
#endif /* USE_CODEC_UMX */
#endif /* ! _SND_UMX_H_ */

View File

@ -1,276 +0,0 @@
/*
* WAV streaming music support. Adapted from ioquake3 with changes.
*
* Copyright (C) 1999-2005 Id Software, Inc.
* Copyright (C) 2005 Stuart Dalton <badcdev@gmail.com>
* Copyright (C) 2010-2012 O.Sezer <sezero@users.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#include "quakedef.h"
#if defined(USE_CODEC_WAVE)
#include "snd_codec.h"
#include "snd_codeci.h"
#include "snd_wave.h"
/*
=================
FGetLittleLong
=================
*/
static int FGetLittleLong (FILE *f)
{
int v;
fread(&v, 1, sizeof(v), f);
return LittleLong(v);
}
/*
=================
FGetLittleShort
=================
*/
static short FGetLittleShort(FILE *f)
{
short v;
fread(&v, 1, sizeof(v), f);
return LittleShort(v);
}
/*
=================
WAV_ReadChunkInfo
=================
*/
static int WAV_ReadChunkInfo(FILE *f, char *name)
{
int len, r;
name[4] = 0;
r = fread(name, 1, 4, f);
if (r != 4)
return -1;
len = FGetLittleLong(f);
if (len < 0)
{
Con_Printf("WAV: Negative chunk length\n");
return -1;
}
return len;
}
/*
=================
WAV_FindRIFFChunk
Returns the length of the data in the chunk, or -1 if not found
=================
*/
static int WAV_FindRIFFChunk(FILE *f, const char *chunk)
{
char name[5];
int len;
while ((len = WAV_ReadChunkInfo(f, name)) >= 0)
{
/* If this is the right chunk, return */
if (!strncmp(name, chunk, 4))
return len;
len = ((len + 1) & ~1); /* pad by 2 . */
/* Not the right chunk - skip it */
fseek(f, len, SEEK_CUR);
}
return -1;
}
/*
=================
WAV_ReadRIFFHeader
=================
*/
static qboolean WAV_ReadRIFFHeader(const char *name, FILE *file, snd_info_t *info)
{
char dump[16];
int wav_format;
int fmtlen = 0;
if (fread(dump, 1, 12, file) < 12 ||
strncmp(dump, "RIFF", 4) != 0 ||
strncmp(&dump[8], "WAVE", 4) != 0)
{
Con_Printf("%s is missing RIFF/WAVE chunks\n", name);
return false;
}
/* Scan for the format chunk */
if ((fmtlen = WAV_FindRIFFChunk(file, "fmt ")) < 0)
{
Con_Printf("%s is missing fmt chunk\n", name);
return false;
}
/* Save the parameters */
wav_format = FGetLittleShort(file);
if (wav_format != WAV_FORMAT_PCM)
{
Con_Printf("%s is not Microsoft PCM format\n", name);
return false;
}
info->channels = FGetLittleShort(file);
info->rate = FGetLittleLong(file);
FGetLittleLong(file);
FGetLittleShort(file);
info->bits = FGetLittleShort(file);
if (info->bits != 8 && info->bits != 16)
{
Con_Printf("%s is not 8 or 16 bit\n", name);
return false;
}
info->width = info->bits / 8;
info->dataofs = 0;
/* Skip the rest of the format chunk if required */
if (fmtlen > 16)
{
fmtlen -= 16;
fseek(file, fmtlen, SEEK_CUR);
}
/* Scan for the data chunk */
if ((info->size = WAV_FindRIFFChunk(file, "data")) < 0)
{
Con_Printf("%s is missing data chunk\n", name);
return false;
}
if (info->channels != 1 && info->channels != 2)
{
Con_Printf("Unsupported number of channels %d in %s\n",
info->channels, name);
return false;
}
info->samples = (info->size / info->width) / info->channels;
if (info->samples == 0)
{
Con_Printf("%s has zero samples\n", name);
return false;
}
return true;
}
/*
=================
S_WAV_CodecOpenStream
=================
*/
static qboolean S_WAV_CodecOpenStream(snd_stream_t *stream)
{
long start = stream->fh.start;
/* Read the RIFF header */
/* The file reads are sequential, therefore no need
* for the FS_*() functions: We will manipulate the
* file by ourselves from now on. */
if (!WAV_ReadRIFFHeader(stream->name, stream->fh.file, &stream->info))
return false;
stream->fh.start = ftell(stream->fh.file); /* reset to data position */
if (stream->fh.start - start + stream->info.size > stream->fh.length)
{
Con_Printf("%s data size mismatch\n", stream->name);
return false;
}
return true;
}
/*
=================
S_WAV_CodecReadStream
=================
*/
int S_WAV_CodecReadStream(snd_stream_t *stream, int bytes, void *buffer)
{
int remaining = stream->info.size - stream->fh.pos;
int i, samples;
if (remaining <= 0)
return 0;
if (bytes > remaining)
bytes = remaining;
stream->fh.pos += bytes;
fread(buffer, 1, bytes, stream->fh.file);
if (stream->info.width == 2)
{
samples = bytes / 2;
for (i = 0; i < samples; i++)
((short *)buffer)[i] = LittleShort( ((short *)buffer)[i] );
}
return bytes;
}
static void S_WAV_CodecCloseStream (snd_stream_t *stream)
{
S_CodecUtilClose(&stream);
}
static int S_WAV_CodecRewindStream (snd_stream_t *stream)
{
FS_rewind(&stream->fh);
return 0;
}
static qboolean S_WAV_CodecInitialize (void)
{
return true;
}
static void S_WAV_CodecShutdown (void)
{
}
snd_codec_t wav_codec =
{
CODECTYPE_WAVE,
true, /* always available. */
"wav",
S_WAV_CodecInitialize,
S_WAV_CodecShutdown,
S_WAV_CodecOpenStream,
S_WAV_CodecReadStream,
S_WAV_CodecRewindStream,
S_WAV_CodecCloseStream,
NULL
};
#endif /* USE_CODEC_WAVE */

View File

@ -1,13 +0,0 @@
/* WAV streaming music support. */
#if !defined(_SND_WAVE_H_)
#define _SND_WAVE_H_
#if defined(USE_CODEC_WAVE)
extern snd_codec_t wav_codec;
#endif /* USE_CODEC_WAVE */
#endif /* ! _SND_WAVE_H_ */

View File

@ -1,168 +0,0 @@
/* tracker music (module file) decoding support using libxmp >= v4.2.0
* https://sourceforge.net/projects/xmp/
* https://github.com/cmatsuoka/libxmp.git
*
* Copyright (C) 2016 O.Sezer <sezero@users.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "quakedef.h"
#if defined(USE_CODEC_XMP)
#include "snd_codec.h"
#include "snd_codeci.h"
#include "snd_xmp.h"
#if defined(_WIN32) && defined(XMP_NO_DLL)
#define BUILDING_STATIC
#endif
#include <xmp.h>
#if ((XMP_VERCODE+0) < 0x040200)
#error libxmp version 4.2 or newer is required
#endif
static int S_XMP_StartPlay (snd_stream_t *stream)
{
int fmt = 0;
if (stream->info.channels == 1)
fmt |= XMP_FORMAT_MONO;
if (stream->info.width == 1)
fmt |= XMP_FORMAT_8BIT|XMP_FORMAT_UNSIGNED;
return xmp_start_player((xmp_context)stream->priv, stream->info.rate, fmt);
}
static qboolean S_XMP_CodecInitialize (void)
{
return true;
}
static void S_XMP_CodecShutdown (void)
{
}
static qboolean S_XMP_CodecOpenStream (snd_stream_t *stream)
{
/* need to load the whole file into memory and pass it to libxmp
* using xmp_load_module_from_memory() which requires libxmp >= 4.2.
* libxmp-4.0/4.1 only have xmp_load_module() which accepts a file
* name which isn't good with files in containers like paks, etc. */
xmp_context c;
byte *moddata;
long len;
int mark;
c = xmp_create_context();
if (c == NULL)
return false;
len = FS_filelength (&stream->fh);
mark = Hunk_LowMark();
moddata = (byte *) Hunk_Alloc(len);
FS_fread(moddata, 1, len, &stream->fh);
if (xmp_load_module_from_memory(c, moddata, len) != 0)
{
Con_DPrintf("Could not load module %s\n", stream->name);
goto err1;
}
Hunk_FreeToLowMark(mark); /* free original file data */
stream->priv = c;
if (shm->speed > XMP_MAX_SRATE)
stream->info.rate = 44100;
else if (shm->speed < XMP_MIN_SRATE)
stream->info.rate = 11025;
else stream->info.rate = shm->speed;
stream->info.bits = shm->samplebits;
stream->info.width = stream->info.bits / 8;
stream->info.channels = shm->channels;
if (S_XMP_StartPlay(stream) != 0)
goto err2;
/* percentual left/right channel separation, default is 70. */
if (stream->info.channels == 2)
if (xmp_set_player(c, XMP_PLAYER_MIX, 100) != 0)
goto err3;
/* interpolation type, default is XMP_INTERP_LINEAR */
if (xmp_set_player(c, XMP_PLAYER_INTERP, XMP_INTERP_SPLINE) != 0)
goto err3;
return true;
err3: xmp_end_player(c);
err2: xmp_release_module(c);
err1: xmp_free_context(c);
return false;
}
static int S_XMP_CodecReadStream (snd_stream_t *stream, int bytes, void *buffer)
{
int r;
/* xmp_play_buffer() requires libxmp >= 4.1. it will write
* native-endian pcm data to the buffer. if the data write
* is partial, the rest of the buffer will be zero-filled.
* the last param is the number that the current sequence of
* the song will be looped at max. */
r = xmp_play_buffer((xmp_context)stream->priv, buffer, bytes, 1);
if (r == 0) {
return bytes;
}
if (r == -XMP_END) {
Con_DPrintf("XMP EOF\n");
return 0;
}
return -1;
}
static void S_XMP_CodecCloseStream (snd_stream_t *stream)
{
xmp_context c = (xmp_context)stream->priv;
xmp_end_player(c);
xmp_release_module(c);
xmp_free_context(c);
S_CodecUtilClose(&stream);
}
static int S_XMP_CodecRewindStream (snd_stream_t *stream)
{
int ret;
ret = S_XMP_StartPlay(stream);
if (ret < 0) return ret;
/*ret = xmp_set_position((xmp_context)stream->priv, 0);*/
ret = xmp_seek_time((xmp_context)stream->priv, 0);
if (ret < 0) return ret;
return 0;
}
snd_codec_t xmp_codec =
{
CODECTYPE_MOD,
true, /* always available. */
"s3m",
S_XMP_CodecInitialize,
S_XMP_CodecShutdown,
S_XMP_CodecOpenStream,
S_XMP_CodecReadStream,
S_XMP_CodecRewindStream,
S_XMP_CodecCloseStream,
NULL
};
#endif /* USE_CODEC_XMP */

View File

@ -1,12 +0,0 @@
/* module tracker decoding support using libxmp */
#if !defined(_SND_XMP_H_)
#define _SND_XMP_H_
#if defined(USE_CODEC_XMP)
extern snd_codec_t xmp_codec;
#endif /* USE_CODEC_XMP */
#endif /* ! _SND_XMP_H_ */

View File

@ -289,18 +289,18 @@ void SV_SendServerinfo (client_t *client)
int i; //johnfitz
MSG_WriteByte (&client->message, svc_print);
sprintf (message, "%c\nFITZQUAKE %1.2f SERVER (%i CRC)\n", 2, FITZQUAKE_VERSION, pr_crc); //johnfitz -- include fitzquake version
sprintf (message, "%c\nFITZQUAKE " FITZQUAKE_VERSION " SERVER (%i CRC)\n", 2, pr_crc); //johnfitz -- include fitzquake version
MSG_WriteString (&client->message,message);
MSG_WriteByte (&client->message, svc_serverinfo);
MSG_WriteLong (&client->message, sv.protocol); //johnfitz -- sv.protocol instead of PROTOCOL_VERSION
if (sv.protocol == PROTOCOL_RMQ)
{
// mh - now send protocol flags so that the client knows the protocol features to expect
MSG_WriteLong (&client->message, sv.protocolflags);
}
MSG_WriteByte (&client->message, svs.maxclients);
if (!coop.value && deathmatch.value)
@ -517,7 +517,7 @@ byte *SV_FatPVS (vec3_t org, qmodel_t *worldmodel) //johnfitz -- added worldmode
if (!fatpvs)
Sys_Error ("SV_FatPVS: realloc() failed on %d bytes", fatpvs_capacity);
}
Q_memset (fatpvs, 0, fatbytes);
SV_AddToFatPVS (org, worldmodel->nodes, worldmodel); //johnfitz -- worldmodel as a parameter
return fatpvs;
@ -586,7 +586,7 @@ void SV_WriteEntitiesToClient (edict_t *clent, sizebuf_t *msg)
for (i=0 ; i < ent->num_leafs ; i++)
if (pvs[ent->leafnums[i] >> 3] & (1 << (ent->leafnums[i]&7) ))
break;
// ericw -- added ent->num_leafs < MAX_ENT_LEAFS condition.
//
// if ent->num_leafs == MAX_ENT_LEAFS, the ent is visible from too many leafs
@ -1365,7 +1365,7 @@ void SV_SpawnServer (const char *server)
q_strlcpy (sv.name, server, sizeof(sv.name));
sv.protocol = sv_protocol; // johnfitz
if (sv.protocol == PROTOCOL_RMQ)
{
// set up the protocol flags used by this server