Compare commits

...

6 Commits

Author SHA1 Message Date
an 8df34b4c3f move quakedefs to q_defs 2019-12-02 10:07:37 -05:00
an 6909073d3d make messages consistent 2019-12-02 10:01:47 -05:00
an 2473e7d835 fix header defines 2019-12-02 10:00:56 -05:00
an 55aef43175 fix fungusy architecture crap 2019-12-02 07:24:20 -05:00
an 1e5b30ba49 remove the rest of the antipiracy 2019-11-28 21:19:42 -05:00
an 7396d8e285 butts 2019-11-28 19:24:30 -05:00
146 changed files with 856 additions and 1680 deletions

View File

@ -22,6 +22,7 @@ pkg_check_modules(MikMod IMPORTED_TARGET libmikmod>=3.3.11)
set(srcs set(srcs
source/anorm_dots.h source/anorm_dots.h
source/anorms.h source/anorms.h
source/arch_def.c
source/arch_def.h source/arch_def.h
source/bgmusic.c source/bgmusic.c
source/bgmusic.h source/bgmusic.h
@ -98,17 +99,15 @@ set(srcs
source/progs.h source/progs.h
source/protocol.h source/protocol.h
source/q_ctype.h source/q_ctype.h
source/q_defs.h
source/q_sound.h source/q_sound.h
source/q_stdinc.h source/q_stdinc.h
source/qs_bmp.h
source/quakedef.h
source/r_alias.c source/r_alias.c
source/r_brush.c source/r_brush.c
source/r_part.c source/r_part.c
source/r_sprite.c source/r_sprite.c
source/r_world.c source/r_world.c
source/render.h source/render.h
source/resource.h
source/sbar.c source/sbar.c
source/sbar.h source/sbar.h
source/screen.h source/screen.h
@ -154,7 +153,8 @@ set(srcs
source/zone.h) source/zone.h)
set(srcs_linux set(srcs_linux
source/linux/pl_linux.c) source/linux/pl_linux.c
source/linux/qs_bmp.h)
set(srcs_osx set(srcs_osx
source/osx/pl_osx.c) source/osx/pl_osx.c)
@ -172,6 +172,7 @@ set(srcs_windows
source/windows/net_wipx.c source/windows/net_wipx.c
source/windows/net_wipx.h source/windows/net_wipx.h
source/windows/pl_win.c source/windows/pl_win.c
source/windows/resource.h
source/windows/sys_sdl_win.c source/windows/sys_sdl_win.c
source/windows/wsaerror.h) source/windows/wsaerror.h)

37
source/arch_def.c Normal file
View File

@ -0,0 +1,37 @@
/*
* arch_def.c
*
* Copyright (C) 2019 Alison G. Watson
*
* 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 "arch_def.h"
char const platform_names[][16] = {
[PLATFRM_BSD] = "BSD",
[PLATFRM_DREAMCAST] = "Dreamcast",
[PLATFRM_LINUX] = "Linux",
[PLATFRM_OSX] = "OSX",
[PLATFRM_UNIX] = "*nix",
[PLATFRM_WINDOWS] = "Windows",
[PLATFRM_IRIX] = "IRIX",
[PLATFRM_SWITCH] = "Switch",
[PLATFRM_WII] = "Wii",
[PLATFRM_PLAN9] = "plan9",
};

View File

@ -24,147 +24,53 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
#ifndef ARCHDEFS_H #ifndef spingle__arch_def_h
#define ARCHDEFS_H #define spingle__arch_def_h
/* core ports */
#define PLATFRM_BSD 0
#define PLATFRM_DREAMCAST 1
#define PLATFRM_LINUX 2
#define PLATFRM_OSX 3
#define PLATFRM_UNIX 4
#define PLATFRM_WINDOWS 5
#if defined(__DJGPP__) || defined(__MSDOS__) || defined(__DOS__) || defined(_MSDOS) /* wanted ports */
#define PLATFRM_IRIX 6
#define PLATFRM_SWITCH 7
#define PLATFRM_WII 8
#define PLATFRM_PLAN9 9
# if !defined(PLATFORM_DOS) #define PLATFORM_IS(x) (PLATFORM == PLATFRM_##x)
# define PLATFORM_DOS 1
# endif
#elif defined(__OS2__) || defined(__EMX__) #if defined(_WIN32) || defined(_WIN64)
#define PLATFORM PLATFRM_WINDOWS
# if !defined(PLATFORM_OS2) #elif defined(__APPLE__) && defined(__MACH__)
# define PLATFORM_OS2 1 #define PLATFORM PLATFRM_OSX
# endif #elif defined(__FreeBSD__) || defined(__DragonFly__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__bsdi__)
#define PLATFORM PLATFRM_BSD
#elif defined(_WIN32) || defined(__WIN32__) || defined(_WIN64) || defined(__NT__) || defined(_Windows) #elif defined(__linux__)
#define PLATFORM PLATFRM_LINUX
# if !defined(PLATFORM_WINDOWS) #elif defined(_arch_dreamcast)
# define PLATFORM_WINDOWS 1 #define PLATFORM PLATFRM_DREAMCAST
# endif
#elif defined(__APPLE__) && defined(__MACH__) /* Mac OS X */
# if !defined(PLATFORM_OSX)
# define PLATFORM_OSX 1
# endif
#elif defined(macintosh) /* Mac OS classic */
# if !defined(PLATFORM_MAC)
# define PLATFORM_MAC 1
# endif
#elif defined(__MORPHOS__) || defined(__AROS__) || defined(AMIGAOS) || \
defined(__amigaos__) || defined(__amigaos4__) ||defined(__amigados__) || \
defined(AMIGA) || defined(_AMIGA) || defined(__AMIGA__)
# if !defined(PLATFORM_AMIGA)
# define PLATFORM_AMIGA 1
# endif
#elif defined(__riscos__)
# if !defined(PLATFORM_RISCOS)
# define PLATFORM_RISCOS 1
# endif
#else /* here goes the unix platforms */
#if defined(__unix) || defined(__unix__) || defined(unix) || \
defined(__linux__) || defined(__linux) || \
defined(__FreeBSD__) || defined(__DragonFly__) || \
defined(__FreeBSD_kernel__) /* Debian GNU/kFreeBSD */ || \
defined(__OpenBSD__) || defined(__NetBSD__) || \
defined(__hpux) || defined(__hpux__) || defined(_hpux) || \
defined(__sun) || defined(sun) || \
defined(__sgi) || defined(sgi) || defined(__sgi__) || \
defined(__GNU__) /* GNU/Hurd */ || \
defined(__QNX__) || defined(__QNXNTO__)
# if !defined(PLATFORM_UNIX)
# define PLATFORM_UNIX 1
# endif
#endif #endif
#endif /* PLATFORM_xxx */ #if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
#if !defined(PLATFORM)
#define PLATFORM PLATFRM_UNIX
#endif
#define PLATFORM_IS_UNIX 1
#endif
#if defined (PLATFORM_OSX) /* OS X is unix-based */ #if defined(__GNUC__)
# if !defined(PLATFORM_UNIX) #define PLATFORM_IS_GNUC __GNUC__
# define PLATFORM_UNIX 2 #endif
# endif
#endif /* OS X -> PLATFORM_UNIX */
#if !defined(PLATFORM)
#error "Platform not defined. The program will not compile."
#endif
#if defined(__FreeBSD__) || defined(__DragonFly__) || \ extern char const platform_names[][16];
defined(__FreeBSD_kernel__) /* Debian GNU/kFreeBSD */ || \
defined(__OpenBSD__) || defined(__NetBSD__)
# if !defined(PLATFORM_BSD)
# define PLATFORM_BSD 1
# endif
#endif /* PLATFORM_BSD (for convenience) */
#if defined(PLATFORM_AMIGA) && !defined(PLATFORM_AMIGAOS3)
# if !defined(__MORPHOS__) && !defined(__AROS__) && !defined(__amigaos4__)
# define PLATFORM_AMIGAOS3 1
# endif
#endif /* PLATFORM_AMIGAOS3 (for convenience) */
#if defined(_WIN64)
# define PLATFORM_STRING "Win64"
#elif defined(PLATFORM_WINDOWS)
# define PLATFORM_STRING "Windows"
#elif defined(PLATFORM_DOS)
# define PLATFORM_STRING "DOS"
#elif defined(PLATFORM_OS2)
# define PLATFORM_STRING "OS/2"
#elif defined(__linux__) || defined(__linux)
# define PLATFORM_STRING "Linux"
#elif defined(__DragonFly__)
# define PLATFORM_STRING "DragonFly"
#elif defined(__FreeBSD__)
# define PLATFORM_STRING "FreeBSD"
#elif defined(__NetBSD__)
# define PLATFORM_STRING "NetBSD"
#elif defined(__OpenBSD__)
# define PLATFORM_STRING "OpenBSD"
#elif defined(__MORPHOS__)
# define PLATFORM_STRING "MorphOS"
#elif defined(__AROS__)
# define PLATFORM_STRING "AROS"
#elif defined(__amigaos4__)
# define PLATFORM_STRING "AmigaOS4"
#elif defined(PLATFORM_AMIGA)
# define PLATFORM_STRING "AmigaOS"
#elif defined(__QNX__) || defined(__QNXNTO__)
# define PLATFORM_STRING "QNX"
#elif defined(PLATFORM_OSX)
# define PLATFORM_STRING "MacOSX"
#elif defined(PLATFORM_MAC)
# define PLATFORM_STRING "MacOS"
#elif defined(__hpux) || defined(__hpux__) || defined(_hpux)
# define PLATFORM_STRING "HP-UX"
#elif (defined(__sun) || defined(sun)) && (defined(__svr4__) || defined(__SVR4))
# define PLATFORM_STRING "Solaris"
#elif defined(__sun) || defined(sun)
# define PLATFORM_STRING "SunOS"
#elif defined(__sgi) || defined(sgi) || defined(__sgi__)
# define PLATFORM_STRING "Irix"
#elif defined(PLATFORM_RISCOS)
# define PLATFORM_STRING "RiscOS"
#elif defined(__GNU__)
# define PLATFORM_STRING "GNU/Hurd"
#elif defined(PLATFORM_UNIX)
# define PLATFORM_STRING "Unix"
#else
# define PLATFORM_STRING "Unknown"
# warning "Platform is UNKNOWN."
#endif /* PLATFORM_STRING */
#endif /* ARCHDEFS_H */
#endif

View File

@ -22,7 +22,7 @@
* *
*/ */
#include "quakedef.h" #include "q_defs.h"
#include "snd_codec.h" #include "snd_codec.h"
#include "bgmusic.h" #include "bgmusic.h"
#include "cdaudio.h" #include "cdaudio.h"

View File

@ -22,8 +22,8 @@
* *
*/ */
#ifndef _BGMUSIC_H_ #ifndef spingle__bgmusic_h
#define _BGMUSIC_H_ #define spingle__bgmusic_h
extern bool bgmloop; extern bool bgmloop;
extern cvar_t bgm_extmusic; extern cvar_t bgm_extmusic;
@ -39,5 +39,4 @@ void BGM_Resume(void);
void BGM_PlayCDtrack(byte track, bool looping); void BGM_PlayCDtrack(byte track, bool looping);
#endif /* _BGMUSIC_H_ */ #endif

View File

@ -20,8 +20,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#ifndef __BSPFILE_H #ifndef spingle__bspfile_h
#define __BSPFILE_H #define spingle__bspfile_h
// upper design bounds // upper design bounds
@ -310,5 +310,4 @@ typedef struct
//============================================================================ //============================================================================
#endif /* __BSPFILE_H */ #endif

View File

@ -18,7 +18,7 @@
*/ */
#include "quakedef.h" #include "q_defs.h"
int32_t CDAudio_Play(byte track, bool looping) int32_t CDAudio_Play(byte track, bool looping)
{ {
@ -44,7 +44,6 @@ void CDAudio_Update(void)
int32_t CDAudio_Init(void) int32_t CDAudio_Init(void)
{ {
Con_Printf("CDAudio disabled at compile time\n");
return -1; return -1;
} }

View File

@ -31,7 +31,7 @@
#else /* defined(SDL_INIT_CDROM) */ #else /* defined(SDL_INIT_CDROM) */
#include "quakedef.h" #include "q_defs.h"
#include "cdaudio.h" #include "cdaudio.h"
static bool cdValid = false; static bool cdValid = false;
@ -53,7 +53,7 @@ static void CDAudio_Eject(void)
if(!cd_handle || !enabled) if(!cd_handle || !enabled)
return; return;
#ifdef __linux__ #if PLATFORM_IS(LINUX)
SDL_CDStop(cd_handle); /* see CDAudio_Stop() */ SDL_CDStop(cd_handle); /* see CDAudio_Stop() */
#endif #endif
if(SDL_CDEject(cd_handle) < 0) if(SDL_CDEject(cd_handle) < 0)
@ -144,7 +144,7 @@ void CDAudio_Stop(void)
if(!playing) if(!playing)
return; return;
#ifdef __linux__ #if PLATFORM_IS(LINUX)
/* Don't really stop, but just pause: On some devices, the CDROMSTOP /* Don't really stop, but just pause: On some devices, the CDROMSTOP
* ioctl causes any followup ioctls to fail for a considerable time. * ioctl causes any followup ioctls to fail for a considerable time.
* observed with a TSSTcorp CDW/DVD SH-M522C drive with TS05 and TS08 * observed with a TSSTcorp CDW/DVD SH-M522C drive with TS05 and TS08
@ -427,7 +427,7 @@ void CDAudio_Update(void)
static const char *get_cddev_arg(const char *arg) static const char *get_cddev_arg(const char *arg)
{ {
#if defined(_WIN32) #if PLATFORM_IS(WINDOWS)
/* arg should be like "D:\", make sure it is so, /* arg should be like "D:\", make sure it is so,
* but tolerate args like "D" or "D:", as well. */ * but tolerate args like "D" or "D:", as well. */
static char drive[4]; static char drive[4];
@ -475,7 +475,7 @@ static void export_cddev_arg(void)
{ {
/* Bad ugly hack to workaround SDL's cdrom device detection. /* Bad ugly hack to workaround SDL's cdrom device detection.
* not needed for windows due to the way SDL_cdrom works. */ * not needed for windows due to the way SDL_cdrom works. */
#if !defined(_WIN32) #if !PLATFORM_IS(WINDOWS)
int32_t i = COM_CheckParm("-cddev"); int32_t i = COM_CheckParm("-cddev");
if(i != 0 && i < com_argc - 1 && com_argv[i + 1][0] != '\0') if(i != 0 && i < com_argc - 1 && com_argv[i + 1][0] != '\0')
{ {
@ -502,8 +502,7 @@ int32_t CDAudio_Init(void)
} }
sdl_num_drives = SDL_CDNumDrives(); sdl_num_drives = SDL_CDNumDrives();
Con_Printf("SDL detected %" PRIi32 " CD-ROM drive%c\n", sdl_num_drives, Con_Printf("SDL detected %" PRIi32 " CD-ROM drive(s)\n", sdl_num_drives);
sdl_num_drives == 1 ? ' ' : 's');
if(sdl_num_drives < 1) if(sdl_num_drives < 1)
return -1; return -1;
@ -571,7 +570,7 @@ void CDAudio_Shutdown(void)
CDAudio_Stop(); CDAudio_Stop();
if(hw_vol_works) if(hw_vol_works)
CD_SetVolume(NULL); /* no SDL support at present. */ CD_SetVolume(NULL); /* no SDL support at present. */
#ifdef __linux__ #if PLATFORM_IS(LINUX)
SDL_CDStop(cd_handle); /* see CDAudio_Stop() */ SDL_CDStop(cd_handle); /* see CDAudio_Stop() */
#endif #endif
SDL_CDClose(cd_handle); SDL_CDClose(cd_handle);

View File

@ -19,8 +19,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#ifndef __CDAUDIO_H #ifndef spingle__cdaudio_h
#define __CDAUDIO_H #define spingle__cdaudio_h
int32_t CDAudio_Init(void); int32_t CDAudio_Init(void);
int32_t CDAudio_Play(byte track, bool looping); int32_t CDAudio_Play(byte track, bool looping);
@ -31,5 +31,4 @@ void CDAudio_Resume(void);
void CDAudio_Shutdown(void); void CDAudio_Shutdown(void);
void CDAudio_Update(void); void CDAudio_Update(void);
#endif /* __CDAUDIO_H */ #endif

View File

@ -19,7 +19,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
#include "quakedef.h" #include "q_defs.h"
static fshandle_t *cfg_file; static fshandle_t *cfg_file;

View File

@ -19,8 +19,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
#ifndef __CFGFILE_H #ifndef spingle__cfgfile_h
#define __CFGFILE_H #define spingle__cfgfile_h
int32_t CFG_OpenConfig(const char *cfg_name); int32_t CFG_OpenConfig(const char *cfg_name);
// opens the given config file. only one open config file is // opens the given config file. only one open config file is
@ -39,4 +39,4 @@ void CFG_ReadCvarOverrides(const char **vars, int32_t num_vars);
// the config file. call this after CFG_ReadCvars() and before // the config file. call this after CFG_ReadCvars() and before
// locking your cvars. // locking your cvars.
#endif /* __CFGFILE_H */ #endif

View File

@ -21,7 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
// chase.c -- chase camera code // chase.c -- chase camera code
#include "quakedef.h" #include "q_defs.h"
cvar_t chase_back = {"chase_back", "100", CVAR_NONE}; cvar_t chase_back = {"chase_back", "100", CVAR_NONE};
cvar_t chase_up = {"chase_up", "16", CVAR_NONE}; cvar_t chase_up = {"chase_up", "16", CVAR_NONE};

View File

@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#include "quakedef.h" #include "q_defs.h"
static void CL_FinishTimeDemo(void); static void CL_FinishTimeDemo(void);

View File

@ -24,7 +24,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
// Quake is a trademark of Id Software, Inc., (c) 1996 Id Software, Inc. All // Quake is a trademark of Id Software, Inc., (c) 1996 Id Software, Inc. All
// rights reserved. // rights reserved.
#include "quakedef.h" #include "q_defs.h"
extern cvar_t cl_maxpitch; //johnfitz -- variable pitch clamping extern cvar_t cl_maxpitch; //johnfitz -- variable pitch clamping
extern cvar_t cl_minpitch; //johnfitz -- variable pitch clamping extern cvar_t cl_minpitch; //johnfitz -- variable pitch clamping

View File

@ -21,7 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
// cl_main.c -- client main loop // cl_main.c -- client main loop
#include "quakedef.h" #include "q_defs.h"
#include "bgmusic.h" #include "bgmusic.h"
// we need to declare some mouse variables here, because the menu system // we need to declare some mouse variables here, because the menu system

View File

@ -22,7 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
// cl_parse.c -- parse a message received from the server // cl_parse.c -- parse a message received from the server
#include "quakedef.h" #include "q_defs.h"
#include "bgmusic.h" #include "bgmusic.h"
const char *svc_strings[] = const char *svc_strings[] =
@ -316,7 +316,7 @@ void CL_ParseServerInfo(void)
// seperate the printfs so the server message can have a color // seperate the printfs so the server message can have a color
Con_Printf("\n%s\n", Con_Quakebar(40)); //johnfitz Con_Printf("\n%s\n", Con_Quakebar(40)); //johnfitz
Con_Printf("%c%s\n", 2, str); Con_Printf("\x02%s\n", str);
//johnfitz -- tell user which protocol this is //johnfitz -- tell user which protocol this is
Con_Printf("Using protocol %" PRIi32 "\n", i); Con_Printf("Using protocol %" PRIi32 "\n", i);

View File

@ -21,7 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
// cl_tent.c -- client side temporary entities // cl_tent.c -- client side temporary entities
#include "quakedef.h" #include "q_defs.h"
entity_t *cl_temp_entities; entity_t *cl_temp_entities;
int32_t num_temp_entities; int32_t num_temp_entities;
@ -331,12 +331,12 @@ void CL_UpdateTEnts(void)
} }
else else
{ {
yaw = (int32_t)(atan2(dist[1], dist[0]) * 180 / M_PI); yaw = (int32_t)(atan2(dist[1], dist[0]) * 180 / PI);
if(yaw < 0) if(yaw < 0)
yaw += 360; yaw += 360;
forward = sqrt(dist[0] * dist[0] + dist[1] * dist[1]); forward = sqrt(dist[0] * dist[0] + dist[1] * dist[1]);
pitch = (int32_t)(atan2(dist[2], forward) * 180 / M_PI); pitch = (int32_t)(atan2(dist[2], forward) * 180 / PI);
if(pitch < 0) if(pitch < 0)
pitch += 360; pitch += 360;
} }

View File

@ -20,8 +20,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#ifndef _CLIENT_H_ #ifndef spingle__client_h
#define _CLIENT_H_ #define spingle__client_h
// client.h // client.h
@ -379,5 +379,4 @@ void TraceLine(vec3_t start, vec3_t end, vec3_t impact);
void Chase_UpdateForClient(void); //johnfitz void Chase_UpdateForClient(void); //johnfitz
void Chase_UpdateForDrawing(void); //johnfitz void Chase_UpdateForDrawing(void); //johnfitz
#endif /* _CLIENT_H_ */ #endif

View File

@ -22,7 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
// cmd.c -- Quake script command processing module // cmd.c -- Quake script command processing module
#include "quakedef.h" #include "q_defs.h"
void Cmd_ForwardToServer(void); void Cmd_ForwardToServer(void);

View File

@ -20,8 +20,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#ifndef _QUAKE_CMD_H #ifndef spingle__cmd_h
#define _QUAKE_CMD_H #define spingle__cmd_h
// cmd.h -- Command buffer and command execution // cmd.h -- Command buffer and command execution
@ -123,5 +123,4 @@ void Cmd_Print(const char *text);
// used by command functions to send output to either the graphics console or // used by command functions to send output to either the graphics console or
// passed as a print message to the client // passed as a print message to the client
#endif /* _QUAKE_CMD_H */ #endif

View File

@ -22,7 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
// common.c -- misc functions used in client and server // common.c -- misc functions used in client and server
#include "quakedef.h" #include "q_defs.h"
#include "q_ctype.h" #include "q_ctype.h"
#include <errno.h> #include <errno.h>
@ -34,19 +34,8 @@ int32_t safemode;
cvar_t registered = {"registered", "1", CVAR_ROM}; cvar_t registered = {"registered", "1", CVAR_ROM};
cvar_t cmdline = {"cmdline", "", CVAR_ROM/*|CVAR_SERVERINFO*/}; /* sending cmdline upon CCREQ_RULE_INFO is evil */ cvar_t cmdline = {"cmdline", "", CVAR_ROM/*|CVAR_SERVERINFO*/}; /* sending cmdline upon CCREQ_RULE_INFO is evil */
static bool com_modified; // set true if using non-id files
static void COM_Path_f(void); static void COM_Path_f(void);
// if a packfile directory differs from this, it is assumed to be hacked
#define PAK0_COUNT 339 /* id1/pak0.pak - v1.0x */
#define PAK0_CRC_V100 13900 /* id1/pak0.pak - v1.00 */
#define PAK0_CRC_V101 62751 /* id1/pak0.pak - v1.01 */
#define PAK0_CRC_V106 32981 /* id1/pak0.pak - v1.06 */
#define PAK0_CRC (PAK0_CRC_V106)
#define PAK0_COUNT_V091 308 /* id1/pak0.pak - v0.91/0.92, not supported */
#define PAK0_CRC_V091 28804 /* id1/pak0.pak - v0.91/0.92, not supported */
char com_token[1024]; char com_token[1024];
int32_t com_argc; int32_t com_argc;
char **com_argv; char **com_argv;
@ -227,7 +216,7 @@ char *q_strupr(char *str)
} }
/* platform dependant (v)snprintf function names: */ /* platform dependant (v)snprintf function names: */
#if defined(_WIN32) #if PLATFORM_IS(WINDOWS)
#define snprintf_func _snprintf #define snprintf_func _snprintf
#define vsnprintf_func _vsnprintf #define vsnprintf_func _vsnprintf
#else #else
@ -607,7 +596,7 @@ void MSG_WriteChar(sizebuf_t *sb, int32_t c)
{ {
byte *buf; byte *buf;
#ifdef PARANOID #if defined(PARANOID)
if(c < -128 || c > 127) if(c < -128 || c > 127)
Sys_Error("MSG_WriteChar: range error"); Sys_Error("MSG_WriteChar: range error");
#endif #endif
@ -620,7 +609,7 @@ void MSG_WriteByte(sizebuf_t *sb, int32_t c)
{ {
byte *buf; byte *buf;
#ifdef PARANOID #if defined(PARANOID)
if(c < 0 || c > 255) if(c < 0 || c > 255)
Sys_Error("MSG_WriteByte: range error"); Sys_Error("MSG_WriteByte: range error");
#endif #endif
@ -633,7 +622,7 @@ void MSG_WriteShort(sizebuf_t *sb, int32_t c)
{ {
byte *buf; byte *buf;
#ifdef PARANOID #if defined(PARANOID)
if(c < ((int16_t)0x8000) || c > (int16_t)0x7fff) if(c < ((int16_t)0x8000) || c > (int16_t)0x7fff)
Sys_Error("MSG_WriteShort: range error"); Sys_Error("MSG_WriteShort: range error");
#endif #endif
@ -1854,7 +1843,6 @@ static pack_t *COM_LoadPackFile(const char *packfile)
pack_t *pack; pack_t *pack;
int32_t packhandle; int32_t packhandle;
dpackfile_t info[MAX_FILES_IN_PACK]; dpackfile_t info[MAX_FILES_IN_PACK];
uint16_t crc;
if(Sys_FileOpenRead(packfile, &packhandle) == -1) if(Sys_FileOpenRead(packfile, &packhandle) == -1)
return NULL; return NULL;
@ -1882,21 +1870,11 @@ static pack_t *COM_LoadPackFile(const char *packfile)
if(numpackfiles > MAX_FILES_IN_PACK) if(numpackfiles > MAX_FILES_IN_PACK)
Sys_Error("%s has %" PRIi32 " files", packfile, numpackfiles); Sys_Error("%s has %" PRIi32 " files", packfile, numpackfiles);
if(numpackfiles != PAK0_COUNT)
com_modified = true; // not the original file
newfiles = (packfile_t *) Z_Malloc(numpackfiles * sizeof(packfile_t)); newfiles = (packfile_t *) Z_Malloc(numpackfiles * sizeof(packfile_t));
Sys_FileSeek(packhandle, header.dirofs); Sys_FileSeek(packhandle, header.dirofs);
Sys_FileRead(packhandle, (void *)info, header.dirlen); Sys_FileRead(packhandle, (void *)info, header.dirlen);
// crc the directory to check for modifications
CRC_Init(&crc);
for(i = 0; i < header.dirlen; i++)
CRC_ProcessByte(&crc, ((byte *)info)[i]);
if(crc != PAK0_CRC_V106 && crc != PAK0_CRC_V101 && crc != PAK0_CRC_V100)
com_modified = true;
// parse the directory // parse the directory
for(i = 0; i < numpackfiles; i++) for(i = 0; i < numpackfiles; i++)
{ {
@ -2025,8 +2003,6 @@ _same:
} }
} }
com_modified = true;
//Kill the server //Kill the server
CL_Disconnect(); CL_Disconnect();
Host_ShutdownServer(true); Host_ShutdownServer(true);
@ -2120,6 +2096,7 @@ void COM_InitFilesystem(void) //johnfitz -- modified based on topaz's tutorial
int32_t i, j; int32_t i, j;
Cvar_RegisterVariable(&cmdline); Cvar_RegisterVariable(&cmdline);
Cvar_RegisterVariable(&registered);
Cmd_AddCommand("path", COM_Path_f); Cmd_AddCommand("path", COM_Path_f);
Cmd_AddCommand("game", COM_Game_f); //johnfitz Cmd_AddCommand("game", COM_Game_f); //johnfitz
@ -2158,7 +2135,6 @@ void COM_InitFilesystem(void) //johnfitz -- modified based on topaz's tutorial
const char *p = com_argv[i + 1]; const char *p = com_argv[i + 1];
if(!*p || !strcmp(p, ".") || strstr(p, "..") || strstr(p, "/") || strstr(p, "\\") || strstr(p, ":")) if(!*p || !strcmp(p, ".") || strstr(p, "..") || strstr(p, "/") || strstr(p, "\\") || strstr(p, ":"))
Sys_Error("gamedir should be a single directory name, not a path\n"); Sys_Error("gamedir should be a single directory name, not a path\n");
com_modified = true;
// don't load mission packs twice // don't load mission packs twice
if(COM_CheckParm("-rogue") && !q_strcasecmp(p, "rogue")) p = NULL; if(COM_CheckParm("-rogue") && !q_strcasecmp(p, "rogue")) p = NULL;
if(COM_CheckParm("-hipnotic") && !q_strcasecmp(p, "hipnotic")) p = NULL; if(COM_CheckParm("-hipnotic") && !q_strcasecmp(p, "hipnotic")) p = NULL;

View File

@ -20,25 +20,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#ifndef _Q_COMMON_H #ifndef spingle__common_h
#define _Q_COMMON_H #define spingle__common_h
// comndef.h -- general definitions // comndef.h -- general definitions
#if defined(_WIN32)
#ifdef _MSC_VER
# pragma warning(disable:4244)
/* 'argument' : conversion from 'type1' to 'type2',
possible loss of data */
# pragma warning(disable:4305)
/* 'identifier' : truncation from 'type1' to 'type2' */
/* in our case, truncation from 'double' to 'float' */
# pragma warning(disable:4267)
/* 'var' : conversion from 'size_t' to 'type',
possible loss of data (/Wp64 warning) */
#endif /* _MSC_VER */
#endif /* _WIN32 */
#undef min #undef min
#undef max #undef max
#define q_min(a, b) (((a) < (b)) ? (a) : (b)) #define q_min(a, b) (((a) < (b)) ? (a) : (b))
@ -299,5 +285,4 @@ extern bool standard_quake, rogue, hipnotic;
struct cvar_s; struct cvar_s;
#endif /* _Q_COMMON_H */ #endif

View File

@ -21,16 +21,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
// console.c // console.c
#include "q_defs.h"
#include <sys/types.h> #include <sys/types.h>
#include <time.h> #include <time.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <fcntl.h> #include <fcntl.h>
#ifdef _WIN32 #if PLATFORM_IS(WINDOWS)
#include <io.h> #include <io.h>
#else #else
#include <unistd.h> #include <unistd.h>
#endif #endif
#include "quakedef.h"
int32_t con_linewidth; int32_t con_linewidth;
@ -325,7 +325,7 @@ void Con_Init(void)
con_current = con_totallines - 1; con_current = con_totallines - 1;
//johnfitz //johnfitz
Con_Printf("Console initialized.\n"); Con_Printf("Console initialized\n");
Cvar_RegisterVariable(&con_notifytime); Cvar_RegisterVariable(&con_notifytime);
Cvar_RegisterVariable(&con_logcenterprint); //johnfitz Cvar_RegisterVariable(&con_logcenterprint); //johnfitz
@ -1186,9 +1186,10 @@ The typing input line at the bottom should only be drawn if typing is allowed
*/ */
void Con_DrawConsole(int32_t lines, bool drawinput) void Con_DrawConsole(int32_t lines, bool drawinput)
{ {
static char const ver[] = ENGINE_NAME " " VERSION;
int32_t i, x, y, j, sb, rows; int32_t i, x, y, j, sb, rows;
const char *text; const char *text;
char ver[32];
if(lines <= 0) if(lines <= 0)
return; return;
@ -1231,9 +1232,8 @@ void Con_DrawConsole(int32_t lines, bool drawinput)
//draw version number in bottom right //draw version number in bottom right
y += 8; y += 8;
q_snprintf(ver, sizeof(ver), "QuakeSpasm " QUAKESPASM_VERSION); for(x = 0; x < (int32_t)strsizeof(ver); x++)
for(x = 0; x < (int32_t)strlen(ver); x++) Draw_Character((con_linewidth - strsizeof(ver) + x + 2) << 3, y, ver[x] /*+ 128*/);
Draw_Character((con_linewidth - strlen(ver) + x + 2) << 3, y, ver[x] /*+ 128*/);
} }

View File

@ -20,8 +20,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#ifndef __CONSOLE_H #ifndef spingle__console_h
#define __CONSOLE_H #define spingle__console_h
// //
// console // console
@ -65,5 +65,4 @@ void LOG_Init(quakeparms_t *parms);
void LOG_Close(void); void LOG_Close(void);
void Con_DebugLog(const char *msg); void Con_DebugLog(const char *msg);
#endif /* __CONSOLE_H */ #endif

View File

@ -20,7 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
/* crc.c */ /* crc.c */
#include "quakedef.h" #include "q_defs.h"
#include "crc.h" #include "crc.h"
// this is a 16 bit, non-reflected CRC using the polynomial 0x1021 // this is a 16 bit, non-reflected CRC using the polynomial 0x1021

View File

@ -19,8 +19,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#ifndef _QUAKE_CRC_H #ifndef spingle__crc_h
#define _QUAKE_CRC_H #define spingle__crc_h
/* crc.h */ /* crc.h */
@ -29,5 +29,4 @@ void CRC_ProcessByte(uint16_t *crcvalue, byte data);
uint16_t CRC_Value(uint16_t crcvalue); uint16_t CRC_Value(uint16_t crcvalue);
uint16_t CRC_Block(const byte *start, int32_t count); //johnfitz -- texture crc uint16_t CRC_Block(const byte *start, int32_t count); //johnfitz -- texture crc
#endif /* _QUAKE_CRC_H */ #endif

View File

@ -21,7 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
// cvar.c -- dynamic variable tracking // cvar.c -- dynamic variable tracking
#include "quakedef.h" #include "q_defs.h"
static cvar_t *cvar_vars; static cvar_t *cvar_vars;
static char cvar_null_string[] = ""; static char cvar_null_string[] = "";

View File

@ -20,8 +20,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#ifndef __CVAR_H__ #ifndef spingle__cvar_h
#define __CVAR_H__ #define spingle__cvar_h
/* /*
cvar_t variables are used to hold scalar or string variables that can cvar_t variables are used to hold scalar or string variables that can
@ -139,5 +139,4 @@ const char *Cvar_CompleteVariable(const char *partial);
// attempts to match a partial variable name for command line completion // attempts to match a partial variable name for command line completion
// returns NULL if nothing fits // returns NULL if nothing fits
#endif /* __CVAR_H__ */ #endif

View File

@ -20,8 +20,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#ifndef _QUAKE_DRAW_H #ifndef spingle__draw_h
#define _QUAKE_DRAW_H #define spingle__draw_h
// draw.h -- these are the only functions outside the refresh allowed // draw.h -- these are the only functions outside the refresh allowed
// to touch the vid buffer // to touch the vid buffer
@ -44,5 +44,4 @@ void Draw_NewGame(void);
void GL_SetCanvas(canvastype newcanvas); //johnfitz void GL_SetCanvas(canvastype newcanvas); //johnfitz
#endif /* _QUAKE_DRAW_H */ #endif

View File

@ -24,73 +24,26 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/ */
#ifndef FILENAMES_H #ifndef spingle__filenames_h
#define FILENAMES_H #define spingle__filenames_h
#include <string.h> #include <string.h>
/* ---------------------- Windows, DOS, OS2: ---------------------- */ #if PLATFORM_IS(WINDOWS)
#if defined(__MSDOS__) || defined(__DOS__) || defined(__DJGPP__) || \
defined(_MSDOS) || defined(__OS2__) || defined(__EMX__) || \
defined(_WIN32) || defined(_Windows) || defined(__WINDOWS__) || \
defined(__NT__) || defined(__CYGWIN__)
#define HAVE_DOS_BASED_FILE_SYSTEM 1 #define HAVE_DOS_BASED_FILE_SYSTEM 1
#define HAVE_CASE_INSENSITIVE_FILE_SYSTEM 1 #define HAVE_CASE_INSENSITIVE_FILE_SYSTEM 1
#define HAS_DRIVE_SPEC(f) ((f)[0] && ((f)[1] == ':')) #define HAS_DRIVE_SPEC(f) ((f)[0] && ((f)[1] == ':'))
#define STRIP_DRIVE_SPEC(f) ((f) + 2) #define STRIP_DRIVE_SPEC(f) ((f) + 2)
#define IS_DIR_SEPARATOR(c) ((c) == '/' || (c) == '\\') #define IS_DIR_SEPARATOR(c) ((c) == '/' || (c) == '\\')
/* both '/' and '\\' work as dir separator. djgpp likes changing
* '\\' into '/', so I define DIR_SEPARATOR_CHAR as '/' for djgpp,
* '\\' otherwise. */
#ifdef __DJGPP__
#define DIR_SEPARATOR_CHAR '/'
#define DIR_SEPARATOR_STR "/"
#else
#define DIR_SEPARATOR_CHAR '\\' #define DIR_SEPARATOR_CHAR '\\'
#define DIR_SEPARATOR_STR "\\" #define DIR_SEPARATOR_STR "\\"
#endif
/* Note that IS_ABSOLUTE_PATH accepts d:foo as well, although it is /* Note that IS_ABSOLUTE_PATH accepts d:foo as well, although it is
only semi-absolute. This is because the users of IS_ABSOLUTE_PATH only semi-absolute. This is because the users of IS_ABSOLUTE_PATH
want to know whether to prepend the current working directory to want to know whether to prepend the current working directory to
a file name, which should not be done with a name like d:foo. */ a file name, which should not be done with a name like d:foo. */
#define IS_ABSOLUTE_PATH(f) (IS_DIR_SEPARATOR((f)[0]) || HAS_DRIVE_SPEC((f))) #define IS_ABSOLUTE_PATH(f) (IS_DIR_SEPARATOR((f)[0]) || HAS_DRIVE_SPEC((f)))
#ifdef __cplusplus
static inline char *FIND_FIRST_DIRSEP(char *_the_path)
{
char *p1 = strchr(_the_path, '/');
char *p2 = strchr(_the_path, '\\');
if(p1 == NULL) return p2;
if(p2 == NULL) return p1;
return (p1 < p2) ? p1 : p2;
}
static inline char *FIND_LAST_DIRSEP(char *_the_path)
{
char *p1 = strrchr(_the_path, '/');
char *p2 = strrchr(_the_path, '\\');
if(p1 == NULL) return p2;
if(p2 == NULL) return p1;
return (p1 > p2) ? p1 : p2;
}
static inline const char *FIND_FIRST_DIRSEP(const char *_the_path)
{
const char *p1 = strchr(_the_path, '/');
const char *p2 = strchr(_the_path, '\\');
if(p1 == NULL) return p2;
if(p2 == NULL) return p1;
return (p1 < p2) ? p1 : p2;
}
static inline const char *FIND_LAST_DIRSEP(const char *_the_path)
{
const char *p1 = strrchr(_the_path, '/');
const char *p2 = strrchr(_the_path, '\\');
if(p1 == NULL) return p2;
if(p2 == NULL) return p1;
return (p1 > p2) ? p1 : p2;
}
#else
static inline char *FIND_FIRST_DIRSEP(const char *_the_path) static inline char *FIND_FIRST_DIRSEP(const char *_the_path)
{ {
char *p1 = strchr(_the_path, '/'); char *p1 = strchr(_the_path, '/');
@ -99,6 +52,7 @@ static inline char *FIND_FIRST_DIRSEP(const char *_the_path)
if(p2 == NULL) return p1; if(p2 == NULL) return p1;
return (p1 < p2) ? p1 : p2; return (p1 < p2) ? p1 : p2;
} }
static inline char *FIND_LAST_DIRSEP(const char *_the_path) static inline char *FIND_LAST_DIRSEP(const char *_the_path)
{ {
char *p1 = strrchr(_the_path, '/'); char *p1 = strrchr(_the_path, '/');
@ -107,64 +61,7 @@ static inline char *FIND_LAST_DIRSEP(const char *_the_path)
if(p2 == NULL) return p1; if(p2 == NULL) return p1;
return (p1 > p2) ? p1 : p2; return (p1 > p2) ? p1 : p2;
} }
#endif /* C++ */
/* ----------------- AmigaOS, MorphOS, AROS, etc: ----------------- */
#elif defined(__MORPHOS__) || defined(__AROS__) || defined(AMIGAOS) || \
defined(__amigaos__) || defined(__amigaos4__) ||defined(__amigados__) || \
defined(AMIGA) || defined(_AMIGA) || defined(__AMIGA__)
#define HAS_DRIVE_SPEC(f) (0) /* */
#define STRIP_DRIVE_SPEC(f) (f) /* */
#define IS_DIR_SEPARATOR(c) ((c) == '/' || (c) == ':')
#define DIR_SEPARATOR_CHAR '/'
#define DIR_SEPARATOR_STR "/"
#define IS_ABSOLUTE_PATH(f) (IS_DIR_SEPARATOR((f)[0]) || (strchr((f), ':')))
#define HAVE_CASE_INSENSITIVE_FILE_SYSTEM 1
#ifdef __cplusplus
static inline char *FIND_FIRST_DIRSEP(char *_the_path)
{
char *p = strchr(_the_path, ':');
if(p != NULL) return p;
return strchr(_the_path, '/');
}
static inline char *FIND_LAST_DIRSEP(char *_the_path)
{
char *p = strrchr(_the_path, '/');
if(p != NULL) return p;
return strchr(_the_path, ':');
}
static inline const char *FIND_FIRST_DIRSEP(const char *_the_path)
{
const char *p = strchr(_the_path, ':');
if(p != NULL) return p;
return strchr(_the_path, '/');
}
static inline const char *FIND_LAST_DIRSEP(const char *_the_path)
{
const char *p = strrchr(_the_path, '/');
if(p != NULL) return p;
return strchr(_the_path, ':');
}
#else #else
static inline char *FIND_FIRST_DIRSEP(const char *_the_path)
{
char *p = strchr(_the_path, ':');
if(p != NULL) return p;
return strchr(_the_path, '/');
}
static inline char *FIND_LAST_DIRSEP(const char *_the_path)
{
char *p = strrchr(_the_path, '/');
if(p != NULL) return p;
return strchr(_the_path, ':');
}
#endif /* C++ */
/* ---------------------- assumed UNIX-ish : ---------------------- */
#else /* */
#define IS_DIR_SEPARATOR(c) ((c) == '/') #define IS_DIR_SEPARATOR(c) ((c) == '/')
#define DIR_SEPARATOR_CHAR '/' #define DIR_SEPARATOR_CHAR '/'
#define DIR_SEPARATOR_STR "/" #define DIR_SEPARATOR_STR "/"
@ -172,34 +69,15 @@ static inline char *FIND_LAST_DIRSEP(const char *_the_path)
#define HAS_DRIVE_SPEC(f) (0) #define HAS_DRIVE_SPEC(f) (0)
#define STRIP_DRIVE_SPEC(f) (f) #define STRIP_DRIVE_SPEC(f) (f)
#ifdef __cplusplus
static inline char *FIND_FIRST_DIRSEP(char *_the_path)
{
return strchr(_the_path, '/');
}
static inline char *FIND_LAST_DIRSEP(char *_the_path)
{
return strrchr(_the_path, '/');
}
static inline const char *FIND_FIRST_DIRSEP(const char *_the_path)
{
return strchr(_the_path, '/');
}
static inline const char *FIND_LAST_DIRSEP(const char *_the_path)
{
return strrchr(_the_path, '/');
}
#else
static inline char *FIND_FIRST_DIRSEP(const char *_the_path) static inline char *FIND_FIRST_DIRSEP(const char *_the_path)
{ {
return strchr(_the_path, '/'); return strchr(_the_path, '/');
} }
static inline char *FIND_LAST_DIRSEP(const char *_the_path) static inline char *FIND_LAST_DIRSEP(const char *_the_path)
{ {
return strrchr(_the_path, '/'); return strrchr(_the_path, '/');
} }
#endif /* C++ */
#endif #endif
#endif /* FILENAMES_H */ #endif

View File

@ -23,7 +23,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
// draw.c -- 2d drawing // draw.c -- 2d drawing
#include "quakedef.h" #include "q_defs.h"
//extern uint8_t d_15to8table[65536]; //johnfitz -- never used //extern uint8_t d_15to8table[65536]; //johnfitz -- never used

View File

@ -21,7 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
//gl_fog.c -- global and volumetric fog //gl_fog.c -- global and volumetric fog
#include "quakedef.h" #include "q_defs.h"
//============================================================================== //==============================================================================
// //

View File

@ -21,7 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
// gl_mesh.c: triangle model functions // gl_mesh.c: triangle model functions
#include "quakedef.h" #include "q_defs.h"
/* /*

View File

@ -24,7 +24,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
// models are the only shared resource between a client and server running // models are the only shared resource between a client and server running
// on the same machine. // on the same machine.
#include "quakedef.h" #include "q_defs.h"
qmodel_t *loadmodel; qmodel_t *loadmodel;
char loadname[32]; // for hunk tags char loadname[32]; // for hunk tags

View File

@ -20,8 +20,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#ifndef __MODEL__ #ifndef spingle__gl_model_h
#define __MODEL__ #define spingle__gl_model_h
#include "modelgen.h" #include "modelgen.h"
#include "spritegn.h" #include "spritegn.h"
@ -519,4 +519,4 @@ byte *Mod_NoVisPVS(qmodel_t *model);
void Mod_SetExtraFlags(qmodel_t *mod); void Mod_SetExtraFlags(qmodel_t *mod);
#endif // __MODEL__ #endif

View File

@ -21,7 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
// r_efrag.c // r_efrag.c
#include "quakedef.h" #include "q_defs.h"
mnode_t *r_pefragtopnode; mnode_t *r_pefragtopnode;

View File

@ -21,7 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
// r_light.c // r_light.c
#include "quakedef.h" #include "q_defs.h"
int32_t r_dlightframecount; int32_t r_dlightframecount;
@ -108,7 +108,7 @@ void R_RenderDlight(dlight_t *light)
glColor3f(0, 0, 0); glColor3f(0, 0, 0);
for(i = 16 ; i >= 0 ; i--) for(i = 16 ; i >= 0 ; i--)
{ {
a = i / 16.0 * M_PI * 2; a = i / 16.0 * PI * 2;
for(j = 0 ; j < 3 ; j++) for(j = 0 ; j < 3 ; j++)
v[j] = light->origin[j] + vright[j] * cos(a) * rad v[j] = light->origin[j] + vright[j] * cos(a) * rad
+ vup[j] * sin(a) * rad; + vup[j] * sin(a) * rad;

View File

@ -21,7 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
// r_main.c // r_main.c
#include "quakedef.h" #include "q_defs.h"
bool r_cache_thrash; // compatability bool r_cache_thrash; // compatability
@ -414,7 +414,7 @@ assumes side and forward are perpendicular, and normalized
to turn away from side, use a negative angle to turn away from side, use a negative angle
=============== ===============
*/ */
#define DEG2RAD( a ) ( (a) * M_PI_DIV_180 ) #define DEG2RAD( a ) ( (a) * PI_DIV_180 )
void TurnVector(vec3_t out, const vec3_t forward, const vec3_t side, float angle) void TurnVector(vec3_t out, const vec3_t forward, const vec3_t side, float angle)
{ {
float scale_forward, scale_side; float scale_forward, scale_side;
@ -462,8 +462,8 @@ float frustum_skew = 0.0; //used by r_stereo
void GL_SetFrustum(float fovx, float fovy) void GL_SetFrustum(float fovx, float fovy)
{ {
float xmax, ymax; float xmax, ymax;
xmax = NEARCLIP * tan(fovx * M_PI / 360.0); xmax = NEARCLIP * tan(fovx * PI / 360.0);
ymax = NEARCLIP * tan(fovy * M_PI / 360.0); ymax = NEARCLIP * tan(fovy * PI / 360.0);
glFrustum(-xmax + frustum_skew, xmax + frustum_skew, -ymax, ymax, NEARCLIP, gl_farclip.value); glFrustum(-xmax + frustum_skew, xmax + frustum_skew, -ymax, ymax, NEARCLIP, gl_farclip.value);
} }
@ -575,8 +575,8 @@ void R_SetupView(void)
if(contents == CONTENTS_WATER || contents == CONTENTS_SLIME || contents == CONTENTS_LAVA) if(contents == CONTENTS_WATER || contents == CONTENTS_SLIME || contents == CONTENTS_LAVA)
{ {
//variance is a percentage of width, where width = 2 * tan(fov / 2) otherwise the effect is too dramatic at high FOV and too subtle at low FOV. what a mess! //variance is a percentage of width, where width = 2 * tan(fov / 2) otherwise the effect is too dramatic at high FOV and too subtle at low FOV. what a mess!
r_fovx = atan(tan(DEG2RAD(r_refdef.fov_x) / 2) * (0.97 + sin(cl.time * 1.5) * 0.03)) * 2 / M_PI_DIV_180; r_fovx = atan(tan(DEG2RAD(r_refdef.fov_x) / 2) * (0.97 + sin(cl.time * 1.5) * 0.03)) * 2 / PI_DIV_180;
r_fovy = atan(tan(DEG2RAD(r_refdef.fov_y) / 2) * (1.03 - sin(cl.time * 1.5) * 0.03)) * 2 / M_PI_DIV_180; r_fovy = atan(tan(DEG2RAD(r_refdef.fov_y) / 2) * (1.03 - sin(cl.time * 1.5) * 0.03)) * 2 / PI_DIV_180;
} }
} }
//johnfitz //johnfitz

View File

@ -22,7 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
// r_misc.c // r_misc.c
#include "quakedef.h" #include "q_defs.h"
//johnfitz -- new cvars //johnfitz -- new cvars
extern cvar_t r_stereo; extern cvar_t r_stereo;

View File

@ -23,7 +23,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
// screen.c -- master for refresh, status bar, console, chat, notify, etc // screen.c -- master for refresh, status bar, console, chat, notify, etc
#include "quakedef.h" #include "q_defs.h"
/* /*
@ -249,8 +249,8 @@ float AdaptFovx(float fov_x, float width, float height)
return fov_x; return fov_x;
if((x = height / width) == 0.75) if((x = height / width) == 0.75)
return fov_x; return fov_x;
a = atan(0.75 / x * tan(fov_x / 360 * M_PI)); a = atan(0.75 / x * tan(fov_x / 360 * PI));
a = a * 360 / M_PI; a = a * 360 / PI;
return a; return a;
} }
@ -266,9 +266,9 @@ float CalcFovy(float fov_x, float width, float height)
if(fov_x < 1 || fov_x > 179) if(fov_x < 1 || fov_x > 179)
Sys_Error("Bad fov: %f", fov_x); Sys_Error("Bad fov: %f", fov_x);
x = width / tan(fov_x / 360 * M_PI); x = width / tan(fov_x / 360 * PI);
a = atan(height / x); a = atan(height / x);
a = a * 360 / M_PI; a = a * 360 / PI;
return a; return a;
} }

View File

@ -22,7 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
//gl_sky.c //gl_sky.c
#include "quakedef.h" #include "q_defs.h"
#define MAX_CLIP_VERTS 64 #define MAX_CLIP_VERTS 64

View File

@ -22,7 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//gl_texmgr.c -- fitzquake's texture manager. manages opengl texture images //gl_texmgr.c -- fitzquake's texture manager. manages opengl texture images
#include "quakedef.h" #include "q_defs.h"
const int32_t gl_solid_format = 3; const int32_t gl_solid_format = 3;
const int32_t gl_alpha_format = 4; const int32_t gl_alpha_format = 4;

View File

@ -19,8 +19,8 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#ifndef _GL_TEXMAN_H #ifndef spingle__gl_texmgr_h
#define _GL_TEXMAN_H #define spingle__gl_texmgr_h
//gl_texmgr.h -- fitzquake's texture manager. manages opengl texture images //gl_texmgr.h -- fitzquake's texture manager. manages opengl texture images
@ -107,5 +107,4 @@ void GL_EnableMultitexture(void); //selects texture unit 1
void GL_Bind(gltexture_t *texture); void GL_Bind(gltexture_t *texture);
void GL_ClearBindings(void); void GL_ClearBindings(void);
#endif /* _GL_TEXMAN_H */ #endif

View File

@ -22,14 +22,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
// gl_vidsdl.c -- SDL GL vid component // gl_vidsdl.c -- SDL GL vid component
#include "quakedef.h" #include "q_defs.h"
#include "cfgfile.h" #include "cfgfile.h"
#include "bgmusic.h" #include "bgmusic.h"
#include "resource.h"
#include <SDL.h> #include <SDL.h>
//ericw -- for putting the driver into multithreaded mode //ericw -- for putting the driver into multithreaded mode
#ifdef __APPLE__ #if PLATFORM_IS(OSX)
#include <OpenGL/OpenGL.h> #include <OpenGL/OpenGL.h>
#endif #endif
@ -279,8 +278,10 @@ static void VID_Gamma_Init(void)
gammaworks = (SDL_SetWindowBrightness(draw_context, 1) == 0); gammaworks = (SDL_SetWindowBrightness(draw_context, 1) == 0);
# endif # endif
#if defined(DEBUG)
if(!gammaworks) if(!gammaworks)
Con_SafePrintf("gamma adjustment not available\n"); Con_SafePrintf("gamma adjustment not available\n");
#endif
} }
/* /*
@ -476,9 +477,10 @@ VID_SetMode
*/ */
static bool VID_SetMode(int32_t width, int32_t height, int32_t refreshrate, int32_t bpp, bool fullscreen) static bool VID_SetMode(int32_t width, int32_t height, int32_t refreshrate, int32_t bpp, bool fullscreen)
{ {
static char const caption[] = ENGINE_NAME " " VERSION;
int32_t temp; int32_t temp;
Uint32 flags; Uint32 flags;
char caption[50];
int32_t depthbits, stencilbits; int32_t depthbits, stencilbits;
int32_t fsaa_obtained; int32_t fsaa_obtained;
int32_t previous_display; int32_t previous_display;
@ -507,8 +509,6 @@ static bool VID_SetMode(int32_t width, int32_t height, int32_t refreshrate, int3
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, fsaa > 0 ? 1 : 0); SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, fsaa > 0 ? 1 : 0);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, fsaa); SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, fsaa);
q_snprintf(caption, sizeof(caption), "QuakeSpasm " QUAKESPASM_VERSION);
/* Create the window if needed, hidden */ /* Create the window if needed, hidden */
if(!draw_context) if(!draw_context)
{ {
@ -818,6 +818,14 @@ static char *GL_MakeNiceExtensionsList(const char *in)
return out; return out;
} }
static void GL_ShowBriefInfo(void)
{
Con_SafePrintf("GL Vendor : %s\n", gl_vendor);
Con_SafePrintf("GL Renderer: %s\n", gl_renderer);
Con_SafePrintf("GL Version : %s\n", gl_version);
Con_SafePrintf("GL TexUnits: %" PRIi32 "\n", (int32_t)gl_max_texture_units);
}
/* /*
=============== ===============
GL_Info_f -- johnfitz GL_Info_f -- johnfitz
@ -825,9 +833,7 @@ GL_Info_f -- johnfitz
*/ */
static void GL_Info_f(void) static void GL_Info_f(void)
{ {
Con_SafePrintf("GL_VENDOR: %s\n", gl_vendor); GL_ShowBriefInfo();
Con_SafePrintf("GL_RENDERER: %s\n", gl_renderer);
Con_SafePrintf("GL_VERSION: %s\n", gl_version);
Con_Printf("GL_EXTENSIONS: %s\n", gl_extensions_nice); Con_Printf("GL_EXTENSIONS: %s\n", gl_extensions_nice);
} }
@ -880,13 +886,17 @@ static void GL_CheckExtensions(void)
GL_GenBuffersFunc = (PFNGLGENBUFFERSARBPROC) SDL_GL_GetProcAddress("glGenBuffersARB"); GL_GenBuffersFunc = (PFNGLGENBUFFERSARBPROC) SDL_GL_GetProcAddress("glGenBuffersARB");
if(GL_BindBufferFunc && GL_BufferDataFunc && GL_BufferSubDataFunc && GL_DeleteBuffersFunc && GL_GenBuffersFunc) if(GL_BindBufferFunc && GL_BufferDataFunc && GL_BufferSubDataFunc && GL_DeleteBuffersFunc && GL_GenBuffersFunc)
{ {
#if defined(DEBUG)
Con_Printf("FOUND: ARB_vertex_buffer_object\n"); Con_Printf("FOUND: ARB_vertex_buffer_object\n");
#endif
gl_vbo_able = true; gl_vbo_able = true;
} }
#if defined(DEBUG)
else else
{ {
Con_Warning("ARB_vertex_buffer_object not available\n"); Con_Warning("ARB_vertex_buffer_object not available\n");
} }
#endif
} }
// multitexture // multitexture
@ -900,11 +910,12 @@ static void GL_CheckExtensions(void)
GL_ClientActiveTextureFunc = (PFNGLCLIENTACTIVETEXTUREARBPROC) SDL_GL_GetProcAddress("glClientActiveTextureARB"); GL_ClientActiveTextureFunc = (PFNGLCLIENTACTIVETEXTUREARBPROC) SDL_GL_GetProcAddress("glClientActiveTextureARB");
if(GL_MTexCoord2fFunc && GL_SelectTextureFunc && GL_ClientActiveTextureFunc) if(GL_MTexCoord2fFunc && GL_SelectTextureFunc && GL_ClientActiveTextureFunc)
{ {
#if defined(DEBUG)
Con_Printf("FOUND: ARB_multitexture\n"); Con_Printf("FOUND: ARB_multitexture\n");
#endif
gl_mtexable = true; gl_mtexable = true;
glGetIntegerv(GL_MAX_TEXTURE_UNITS, &gl_max_texture_units); glGetIntegerv(GL_MAX_TEXTURE_UNITS, &gl_max_texture_units);
Con_Printf("GL_MAX_TEXTURE_UNITS: %" PRIi32 "\n", (int32_t)gl_max_texture_units);
} }
else else
{ {
@ -922,12 +933,16 @@ static void GL_CheckExtensions(void)
Con_Warning("texture_env_combine disabled at command line\n"); Con_Warning("texture_env_combine disabled at command line\n");
else if(GL_ParseExtensionList(gl_extensions, "GL_ARB_texture_env_combine")) else if(GL_ParseExtensionList(gl_extensions, "GL_ARB_texture_env_combine"))
{ {
#if defined(DEBUG)
Con_Printf("FOUND: ARB_texture_env_combine\n"); Con_Printf("FOUND: ARB_texture_env_combine\n");
#endif
gl_texture_env_combine = true; gl_texture_env_combine = true;
} }
else if(GL_ParseExtensionList(gl_extensions, "GL_EXT_texture_env_combine")) else if(GL_ParseExtensionList(gl_extensions, "GL_EXT_texture_env_combine"))
{ {
#if defined(DEBUG)
Con_Printf("FOUND: EXT_texture_env_combine\n"); Con_Printf("FOUND: EXT_texture_env_combine\n");
#endif
gl_texture_env_combine = true; gl_texture_env_combine = true;
} }
else else
@ -941,12 +956,16 @@ static void GL_CheckExtensions(void)
Con_Warning("texture_env_add disabled at command line\n"); Con_Warning("texture_env_add disabled at command line\n");
else if(GL_ParseExtensionList(gl_extensions, "GL_ARB_texture_env_add")) else if(GL_ParseExtensionList(gl_extensions, "GL_ARB_texture_env_add"))
{ {
#if defined(DEBUG)
Con_Printf("FOUND: ARB_texture_env_add\n"); Con_Printf("FOUND: ARB_texture_env_add\n");
#endif
gl_texture_env_add = true; gl_texture_env_add = true;
} }
else if(GL_ParseExtensionList(gl_extensions, "GL_EXT_texture_env_add")) else if(GL_ParseExtensionList(gl_extensions, "GL_EXT_texture_env_add"))
{ {
#if defined(DEBUG)
Con_Printf("FOUND: EXT_texture_env_add\n"); Con_Printf("FOUND: EXT_texture_env_add\n");
#endif
gl_texture_env_add = true; gl_texture_env_add = true;
} }
else else
@ -972,7 +991,9 @@ static void GL_CheckExtensions(void)
} }
else else
{ {
#if defined(DEBUG)
Con_Printf("FOUND: SDL_GL_SetSwapInterval\n"); Con_Printf("FOUND: SDL_GL_SetSwapInterval\n");
#endif
} }
// anisotropic filtering // anisotropic filtering
@ -994,7 +1015,9 @@ static void GL_CheckExtensions(void)
if(test1 == 1 && test2 == 2) if(test1 == 1 && test2 == 2)
{ {
#if defined(DEBUG)
Con_Printf("FOUND: EXT_texture_filter_anisotropic\n"); Con_Printf("FOUND: EXT_texture_filter_anisotropic\n");
#endif
gl_anisotropy_able = true; gl_anisotropy_able = true;
} }
else else
@ -1023,7 +1046,9 @@ static void GL_CheckExtensions(void)
Con_Warning("texture_non_power_of_two disabled at command line\n"); Con_Warning("texture_non_power_of_two disabled at command line\n");
else if(GL_ParseExtensionList(gl_extensions, "GL_ARB_texture_non_power_of_two")) else if(GL_ParseExtensionList(gl_extensions, "GL_ARB_texture_non_power_of_two"))
{ {
#if defined(DEBUG)
Con_Printf("FOUND: ARB_texture_non_power_of_two\n"); Con_Printf("FOUND: ARB_texture_non_power_of_two\n");
#endif
gl_texture_NPOT = true; gl_texture_NPOT = true;
} }
else else
@ -1085,18 +1110,24 @@ static void GL_CheckExtensions(void)
GL_Uniform3fFunc && GL_Uniform3fFunc &&
GL_Uniform4fFunc) GL_Uniform4fFunc)
{ {
#if defined(DEBUG)
Con_Printf("FOUND: GLSL\n"); Con_Printf("FOUND: GLSL\n");
#endif
gl_glsl_able = true; gl_glsl_able = true;
} }
#if defined(DEBUG)
else else
{ {
Con_Warning("GLSL not available\n"); Con_Warning("GLSL not available\n");
} }
#endif
} }
#if defined(DEBUG)
else else
{ {
Con_Warning("OpenGL version < 2, GLSL not available\n"); Con_Warning("OpenGL version < 2, GLSL not available\n");
} }
#endif
// GLSL gamma // GLSL gamma
// //
@ -1106,10 +1137,12 @@ static void GL_CheckExtensions(void)
{ {
gl_glsl_gamma_able = true; gl_glsl_gamma_able = true;
} }
#if defined(DEBUG)
else else
{ {
Con_Warning("GLSL gamma not available, using hardware gamma\n"); Con_Warning("GLSL gamma not available, using hardware gamma\n");
} }
#endif
// GLSL alias model rendering // GLSL alias model rendering
// //
@ -1119,10 +1152,12 @@ static void GL_CheckExtensions(void)
{ {
gl_glsl_alias_able = true; gl_glsl_alias_able = true;
} }
#if defined(DEBUG)
else else
{ {
Con_Warning("GLSL alias model rendering not available, using Fitz renderer\n"); Con_Warning("GLSL alias model rendering not available, using Fitz renderer\n");
} }
#endif
} }
/* /*
@ -1165,10 +1200,6 @@ static void GL_Init(void)
gl_version = (const char *) glGetString(GL_VERSION); gl_version = (const char *) glGetString(GL_VERSION);
gl_extensions = (const char *) glGetString(GL_EXTENSIONS); gl_extensions = (const char *) glGetString(GL_EXTENSIONS);
Con_SafePrintf("GL_VENDOR: %s\n", gl_vendor);
Con_SafePrintf("GL_RENDERER: %s\n", gl_renderer);
Con_SafePrintf("GL_VERSION: %s\n", gl_version);
if(gl_version == NULL || sscanf(gl_version, "%" PRIi32 ".%" PRIi32 "", &gl_version_major, &gl_version_minor) < 2) if(gl_version == NULL || sscanf(gl_version, "%" PRIi32 ".%" PRIi32 "", &gl_version_major, &gl_version_minor) < 2)
{ {
gl_version_major = 0; gl_version_major = 0;
@ -1181,11 +1212,12 @@ static void GL_Init(void)
GL_CheckExtensions(); //johnfitz GL_CheckExtensions(); //johnfitz
#ifdef __APPLE__ GL_ShowBriefInfo();
#if PLATFORM_IS(OSX)
// ericw -- enable multi-threaded OpenGL, gives a decent FPS boost. // ericw -- enable multi-threaded OpenGL, gives a decent FPS boost.
// https://developer.apple.com/library/mac/technotes/tn2085/ // https://developer.apple.com/library/mac/technotes/tn2085/
if(host_parms->numcpus > 1 && if(host_parms->numcpus > 1 && kCGLNoError != CGLEnable(CGLGetCurrentContext(), kCGLCEMPEngine))
kCGLNoError != CGLEnable(CGLGetCurrentContext(), kCGLCEMPEngine))
{ {
Con_Warning("Couldn't enable multi-threaded OpenGL"); Con_Warning("Couldn't enable multi-threaded OpenGL");
} }

View File

@ -20,7 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
//gl_warp.c -- warping animation support //gl_warp.c -- warping animation support
#include "quakedef.h" #include "q_defs.h"
extern cvar_t r_drawflat; extern cvar_t r_drawflat;
@ -36,8 +36,8 @@ float turbsin[] =
#include "gl_warp_sin.h" #include "gl_warp_sin.h"
}; };
#define WARPCALC(s,t) ((s + turbsin[(int32_t)((t*2)+(cl.time*(128.0/M_PI))) & 255]) * (1.0/64)) //johnfitz -- correct warp #define WARPCALC(s,t) ((s + turbsin[(int32_t)((t*2)+(cl.time*(128.0/PI))) & 255]) * (1.0/64)) //johnfitz -- correct warp
#define WARPCALC2(s,t) ((s + turbsin[(int32_t)((t*0.125+cl.time)*(128.0/M_PI)) & 255]) * (1.0/64)) //johnfitz -- old warp #define WARPCALC2(s,t) ((s + turbsin[(int32_t)((t*0.125+cl.time)*(128.0/PI)) & 255]) * (1.0/64)) //johnfitz -- old warp
//============================================================================== //==============================================================================
// //

View File

@ -21,8 +21,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#ifndef __GLQUAKE_H #ifndef spingle__glquake_h
#define __GLQUAKE_H #define spingle__glquake_h
void GL_BeginRendering(int32_t *x, int32_t *y, int32_t *width, int32_t *height); void GL_BeginRendering(int32_t *x, int32_t *y, int32_t *width, int32_t *height);
void GL_EndRendering(void); void GL_EndRendering(void);
@ -376,5 +376,4 @@ void R_ScaleView_DeleteTexture(void);
float GL_WaterAlphaForSurface(msurface_t *fa); float GL_WaterAlphaForSurface(msurface_t *fa);
#endif /* __GLQUAKE_H */ #endif

View File

@ -22,7 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
// host.c -- coordinates spawning and killing of local servers // host.c -- coordinates spawning and killing of local servers
#include "quakedef.h" #include "q_defs.h"
#include "bgmusic.h" #include "bgmusic.h"
#include <setjmp.h> #include <setjmp.h>
@ -225,11 +225,15 @@ void Host_FindMaxClients(void)
Cvar_SetQuick(&deathmatch, "0"); Cvar_SetQuick(&deathmatch, "0");
} }
static void PrintExeTime(void)
{
Con_Printf("Compiled on " __DATE__ " " __TIME__ "\n");
}
void Host_Version_f(void) void Host_Version_f(void)
{ {
Con_Printf("Quake Version %s\n", VERSION); Con_Printf(ENGINE_NAME " Version " VERSION "\n");
Con_Printf("QuakeSpasm Version " QUAKESPASM_VERSION "\n"); PrintExeTime();
Con_Printf("Exe: " __TIME__ " " __DATE__ "\n");
} }
/* cvar callback functions : */ /* cvar callback functions : */
@ -836,7 +840,7 @@ void Host_Init(void)
NET_Init(); NET_Init();
SV_Init(); SV_Init();
Con_Printf("Exe: " __TIME__ " " __DATE__ "\n"); PrintExeTime();
Con_Printf("%4.1f megabyte heap\n", host_parms->memsize / (1024 * 1024.0)); Con_Printf("%4.1f megabyte heap\n", host_parms->memsize / (1024 * 1024.0));
if(cls.state != ca_dedicated) if(cls.state != ca_dedicated)

View File

@ -21,8 +21,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#include "quakedef.h" #include "q_defs.h"
#ifndef _WIN32 #if !PLATFORM_IS(WINDOWS)
#include <dirent.h> #include <dirent.h>
#endif #endif
@ -116,7 +116,7 @@ void ExtraMaps_Add(const char *name)
void ExtraMaps_Init(void) void ExtraMaps_Init(void)
{ {
#ifdef _WIN32 #if PLATFORM_IS(WINDOWS)
WIN32_FIND_DATA fdat; WIN32_FIND_DATA fdat;
HANDLE fhnd; HANDLE fhnd;
#else #else
@ -138,7 +138,7 @@ void ExtraMaps_Init(void)
{ {
if(*search->filename) //directory if(*search->filename) //directory
{ {
#ifdef _WIN32 #if PLATFORM_IS(WINDOWS)
q_snprintf(filestring, sizeof(filestring), "%s/maps/*.bsp", search->filename); q_snprintf(filestring, sizeof(filestring), "%s/maps/*.bsp", search->filename);
fhnd = FindFirstFile(filestring, &fdat); fhnd = FindFirstFile(filestring, &fdat);
if(fhnd == INVALID_HANDLE_VALUE) if(fhnd == INVALID_HANDLE_VALUE)
@ -228,7 +228,7 @@ void Modlist_Add(const char *name)
FileList_Add(name, &modlist); FileList_Add(name, &modlist);
} }
#ifdef _WIN32 #if PLATFORM_IS(WINDOWS)
void Modlist_Init(void) void Modlist_Init(void)
{ {
WIN32_FIND_DATA fdat; WIN32_FIND_DATA fdat;
@ -308,7 +308,7 @@ void DemoList_Rebuild(void)
// TODO: Factor out to a general-purpose file searching function // TODO: Factor out to a general-purpose file searching function
void DemoList_Init(void) void DemoList_Init(void)
{ {
#ifdef _WIN32 #if PLATFORM_IS(WINDOWS)
WIN32_FIND_DATA fdat; WIN32_FIND_DATA fdat;
HANDLE fhnd; HANDLE fhnd;
#else #else
@ -330,7 +330,7 @@ void DemoList_Init(void)
{ {
if(*search->filename) //directory if(*search->filename) //directory
{ {
#ifdef _WIN32 #if PLATFORM_IS(WINDOWS)
q_snprintf(filestring, sizeof(filestring), "%s/*.dem", search->filename); q_snprintf(filestring, sizeof(filestring), "%s/*.dem", search->filename);
fhnd = FindFirstFile(filestring, &fdat); fhnd = FindFirstFile(filestring, &fdat);
if(fhnd == INVALID_HANDLE_VALUE) if(fhnd == INVALID_HANDLE_VALUE)
@ -428,8 +428,7 @@ Host_Status_f
*/ */
void Host_Status_f(void) void Host_Status_f(void)
{ {
void (*print_fn)(const char *fmt, ...) void (*print_fn)(const char *fmt, ...) FUNCP_PRINTF(1, 2);
FUNCP_PRINTF(1, 2);
client_t *client; client_t *client;
int32_t seconds; int32_t seconds;
int32_t minutes; int32_t minutes;

View File

@ -21,7 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
//image.c -- image loading //image.c -- image loading
#include "quakedef.h" #include "q_defs.h"
#define STB_IMAGE_WRITE_IMPLEMENTATION #define STB_IMAGE_WRITE_IMPLEMENTATION
#define STB_IMAGE_WRITE_STATIC #define STB_IMAGE_WRITE_STATIC
@ -590,7 +590,7 @@ bool Image_WritePNG(const char *name, byte *data, int32_t width, int32_t height,
error = lodepng_encode(&png, &pngsize, flipped, width, height, &state); error = lodepng_encode(&png, &pngsize, flipped, width, height, &state);
if(error == 0) lodepng_save_file(png, pngsize, pathname); if(error == 0) lodepng_save_file(png, pngsize, pathname);
#ifdef LODEPNG_COMPILE_ERROR_TEXT #if defined(LODEPNG_COMPILE_ERROR_TEXT)
else Con_Printf("WritePNG: %s\n", lodepng_error_text()); else Con_Printf("WritePNG: %s\n", lodepng_error_text());
#endif #endif

View File

@ -20,8 +20,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#ifndef GL_IMAGE_H #ifndef spingle__image_h
#define GL_IMAGE_H #define spingle__image_h
//image.h -- image reading / writing //image.h -- image reading / writing
@ -34,5 +34,4 @@ bool Image_WriteTGA(const char *name, byte *data, int32_t width, int32_t height,
bool Image_WritePNG(const char *name, byte *data, int32_t width, int32_t height, int32_t bpp, bool upsidedown); bool Image_WritePNG(const char *name, byte *data, int32_t width, int32_t height, int32_t bpp, bool upsidedown);
bool Image_WriteJPG(const char *name, byte *data, int32_t width, int32_t height, int32_t bpp, int32_t quality, bool upsidedown); bool Image_WriteJPG(const char *name, byte *data, int32_t width, int32_t height, int32_t bpp, int32_t quality, bool upsidedown);
#endif /* GL_IMAGE_H */ #endif

View File

@ -21,19 +21,19 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#include "quakedef.h" #include "q_defs.h"
#include <SDL.h> #include <SDL.h>
static bool textmode; static bool textmode;
static cvar_t in_debugkeys = {"in_debugkeys", "0", CVAR_NONE}; static cvar_t in_debugkeys = {"in_debugkeys", "0", CVAR_NONE};
#ifdef __APPLE__ #if PLATFORM_IS(OSX)
/* Mouse acceleration needs to be disabled on OS X */ /* Mouse acceleration needs to be disabled on OS X */
#define MACOS_X_ACCELERATION_HACK #define MACOS_X_ACCELERATION_HACK
#endif #endif
#ifdef MACOS_X_ACCELERATION_HACK #if defined(MACOS_X_ACCELERATION_HACK)
#include <IOKit/IOTypes.h> #include <IOKit/IOTypes.h>
#include <IOKit/hidsystem/IOHIDLib.h> #include <IOKit/hidsystem/IOHIDLib.h>
#include <IOKit/hidsystem/IOHIDParameter.h> #include <IOKit/hidsystem/IOHIDParameter.h>
@ -105,7 +105,7 @@ static void IN_EndIgnoringMouseEvents(void)
SDL_SetEventFilter(NULL, NULL); SDL_SetEventFilter(NULL, NULL);
} }
#ifdef MACOS_X_ACCELERATION_HACK #if defined(MACOS_X_ACCELERATION_HACK)
static cvar_t in_disablemacosxmouseaccel = {"in_disablemacosxmouseaccel", "1", CVAR_ARCHIVE}; static cvar_t in_disablemacosxmouseaccel = {"in_disablemacosxmouseaccel", "1", CVAR_ARCHIVE};
static double originalMouseSpeed = -1.0; static double originalMouseSpeed = -1.0;
@ -180,7 +180,7 @@ void IN_Activate(void)
if(no_mouse) if(no_mouse)
return; return;
#ifdef MACOS_X_ACCELERATION_HACK #if defined(MACOS_X_ACCELERATION_HACK)
/* Save the status of mouse acceleration */ /* Save the status of mouse acceleration */
if(originalMouseSpeed == -1 && in_disablemacosxmouseaccel.value) if(originalMouseSpeed == -1 && in_disablemacosxmouseaccel.value)
IN_DisableOSXMouseAccel(); IN_DisableOSXMouseAccel();
@ -202,7 +202,7 @@ void IN_Deactivate(bool free_cursor)
if(no_mouse) if(no_mouse)
return; return;
#ifdef MACOS_X_ACCELERATION_HACK #if defined(MACOS_X_ACCELERATION_HACK)
if(originalMouseSpeed != -1) if(originalMouseSpeed != -1)
IN_ReenableOSXMouseAccel(); IN_ReenableOSXMouseAccel();
#endif #endif
@ -256,7 +256,7 @@ void IN_StartupJoystick(void)
gamecontroller = SDL_GameControllerOpen(i); gamecontroller = SDL_GameControllerOpen(i);
if(gamecontroller) if(gamecontroller)
{ {
Con_Printf("detected controller: %s\n", controllername != NULL ? controllername : "NULL"); Con_Printf("Controller found: %s\n", controllername != NULL ? controllername : "NULL");
joy_active_instaceid = SDL_JoystickInstanceID(SDL_GameControllerGetJoystick(gamecontroller)); joy_active_instaceid = SDL_JoystickInstanceID(SDL_GameControllerGetJoystick(gamecontroller));
joy_active_controller = gamecontroller; joy_active_controller = gamecontroller;
@ -294,7 +294,7 @@ void IN_Init(void)
IN_BeginIgnoringMouseEvents(); IN_BeginIgnoringMouseEvents();
} }
#ifdef MACOS_X_ACCELERATION_HACK #if defined(MACOS_X_ACCELERATION_HACK)
Cvar_RegisterVariable(&in_disablemacosxmouseaccel); Cvar_RegisterVariable(&in_disablemacosxmouseaccel);
#endif #endif
Cvar_RegisterVariable(&in_debugkeys); Cvar_RegisterVariable(&in_debugkeys);
@ -350,11 +350,6 @@ static joyaxisstate_t joy_axisstate;
static double joy_buttontimer[SDL_CONTROLLER_BUTTON_MAX]; static double joy_buttontimer[SDL_CONTROLLER_BUTTON_MAX];
static double joy_emulatedkeytimer[10]; static double joy_emulatedkeytimer[10];
#ifdef __WATCOMC__ /* OW1.9 doesn't have powf() / sqrtf() */
#define powf pow
#define sqrtf sqrt
#endif
/* /*
================ ================
IN_AxisMagnitude IN_AxisMagnitude

View File

@ -19,8 +19,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#ifndef _QUAKE_INPUT_H #ifndef spingle__input_h
#define _QUAKE_INPUT_H #define spingle__input_h
// input.h -- external (non-keyboard) input devices // input.h -- external (non-keyboard) input devices
@ -53,5 +53,4 @@ void IN_Activate();
// called when the app becomes inactive // called when the app becomes inactive
void IN_Deactivate(bool free_cursor); void IN_Deactivate(bool free_cursor);
#endif /* _QUAKE_INPUT_H */ #endif

View File

@ -21,8 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#include "quakedef.h" #include "q_defs.h"
#include "arch_def.h"
/* key up events are sent even if in console mode */ /* key up events are sent even if in console mode */
@ -418,7 +417,7 @@ void Key_Console(int32_t key)
case 'v': case 'v':
case 'V': case 'V':
#if defined(PLATFORM_OSX) || defined(PLATFORM_MAC) #if PLATFORM_IS(OSX)
if(keydown[K_COMMAND]) /* Cmd+v paste (Mac-only) */ if(keydown[K_COMMAND]) /* Cmd+v paste (Mac-only) */
{ {
PasteToConsole(); PasteToConsole();
@ -869,7 +868,7 @@ void Key_Init(void)
consolekeys[K_KP_ENTER] = true; consolekeys[K_KP_ENTER] = true;
consolekeys[K_KP_INS] = true; consolekeys[K_KP_INS] = true;
consolekeys[K_KP_DEL] = true; consolekeys[K_KP_DEL] = true;
#if defined(PLATFORM_OSX) || defined(PLATFORM_MAC) #if PLATFORM_IS(OSX)
consolekeys[K_COMMAND] = true; consolekeys[K_COMMAND] = true;
#endif #endif
consolekeys[K_MWHEELUP] = true; consolekeys[K_MWHEELUP] = true;
@ -1097,7 +1096,7 @@ void Char_Event(int32_t key)
if(key < 32 || key > 126) if(key < 32 || key > 126)
return; return;
#if defined(PLATFORM_OSX) || defined(PLATFORM_MAC) #if PLATFORM_IS(OSX)
if(keydown[K_COMMAND]) if(keydown[K_COMMAND])
return; return;
#endif #endif

View File

@ -20,8 +20,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#ifndef _QUAKE_KEYS_H #ifndef spingle__keys_h
#define _QUAKE_KEYS_H #define spingle__keys_h
// //
// these are the key numbers that should be passed to Key_Event // these are the key numbers that should be passed to Key_Event
@ -196,5 +196,4 @@ int32_t Key_GetChatMsgLen(void);
void History_Init(void); void History_Init(void);
void History_Shutdown(void); void History_Shutdown(void);
#endif /* _QUAKE_KEYS_H */ #endif

View File

@ -21,7 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#include "quakedef.h" #include "q_defs.h"
#include <SDL.h> #include <SDL.h>
static const Uint8 bmp_bytes[] = static const Uint8 bmp_bytes[] =

View File

@ -59,7 +59,7 @@ define them in your own project's source files without needing to change
lodepng source code. Don't forget to remove "static" if you copypaste them lodepng source code. Don't forget to remove "static" if you copypaste them
from here.*/ from here.*/
#ifdef LODEPNG_COMPILE_ALLOCATORS #if defined(LODEPNG_COMPILE_ALLOCATORS)
static void* lodepng_malloc(size_t size) static void* lodepng_malloc(size_t size)
{ {
return malloc(size); return malloc(size);
@ -132,7 +132,7 @@ About uivector, ucvector and string:
-As with many other structs in this file, the init and cleanup functions serve as ctor and dtor. -As with many other structs in this file, the init and cleanup functions serve as ctor and dtor.
*/ */
#ifdef LODEPNG_COMPILE_ZLIB #if defined(LODEPNG_COMPILE_ZLIB)
/*dynamic vector of unsigned ints*/ /*dynamic vector of unsigned ints*/
typedef struct uivector typedef struct uivector
{ {
@ -188,7 +188,7 @@ static void uivector_init(uivector* p)
p->size = p->allocsize = 0; p->size = p->allocsize = 0;
} }
#ifdef LODEPNG_COMPILE_ENCODER #if defined(LODEPNG_COMPILE_ENCODER)
/*returns 1 if success, 0 if failure ==> nothing done*/ /*returns 1 if success, 0 if failure ==> nothing done*/
static unsigned uivector_push_back(uivector* p, unsigned c) static unsigned uivector_push_back(uivector* p, unsigned c)
{ {
@ -234,7 +234,7 @@ static unsigned ucvector_resize(ucvector* p, size_t size)
return 1; /*success*/ return 1; /*success*/
} }
#ifdef LODEPNG_COMPILE_PNG #if defined(LODEPNG_COMPILE_PNG)
static void ucvector_cleanup(void* p) static void ucvector_cleanup(void* p)
{ {
@ -250,7 +250,7 @@ static void ucvector_init(ucvector* p)
} }
#endif /*LODEPNG_COMPILE_PNG*/ #endif /*LODEPNG_COMPILE_PNG*/
#ifdef LODEPNG_COMPILE_ZLIB #if defined(LODEPNG_COMPILE_ZLIB)
/*you can both convert from vector to buffer&size and vica versa. If you use /*you can both convert from vector to buffer&size and vica versa. If you use
init_buffer to take over a buffer and size, it is not needed to use cleanup*/ init_buffer to take over a buffer and size, it is not needed to use cleanup*/
static void ucvector_init_buffer(ucvector* p, uint8_t* buffer, size_t size) static void ucvector_init_buffer(ucvector* p, uint8_t* buffer, size_t size)
@ -273,8 +273,8 @@ static unsigned ucvector_push_back(ucvector* p, uint8_t c)
/* ////////////////////////////////////////////////////////////////////////// */ /* ////////////////////////////////////////////////////////////////////////// */
#ifdef LODEPNG_COMPILE_PNG #if defined(LODEPNG_COMPILE_PNG)
#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS #if defined(LODEPNG_COMPILE_ANCILLARY_CHUNKS)
/*returns 1 if success, 0 if failure ==> nothing done*/ /*returns 1 if success, 0 if failure ==> nothing done*/
static unsigned string_resize(char** out, size_t size) static unsigned string_resize(char** out, size_t size)
{ {
@ -333,7 +333,7 @@ static void lodepng_set32bitInt(uint8_t* buffer, unsigned value)
} }
#endif /*defined(LODEPNG_COMPILE_PNG) || defined(LODEPNG_COMPILE_ENCODER)*/ #endif /*defined(LODEPNG_COMPILE_PNG) || defined(LODEPNG_COMPILE_ENCODER)*/
#ifdef LODEPNG_COMPILE_ENCODER #if defined(LODEPNG_COMPILE_ENCODER)
static void lodepng_add32bitInt(ucvector* buffer, unsigned value) static void lodepng_add32bitInt(ucvector* buffer, unsigned value)
{ {
ucvector_resize(buffer, buffer->size + 4); /*todo: give error if resize failed*/ ucvector_resize(buffer, buffer->size + 4); /*todo: give error if resize failed*/
@ -345,7 +345,7 @@ static void lodepng_add32bitInt(ucvector* buffer, unsigned value)
/* / File IO / */ /* / File IO / */
/* ////////////////////////////////////////////////////////////////////////// */ /* ////////////////////////////////////////////////////////////////////////// */
#ifdef LODEPNG_COMPILE_DISK #if defined(LODEPNG_COMPILE_DISK)
/* returns negative value on error. This should be pure C compatible, so no fstat. */ /* returns negative value on error. This should be pure C compatible, so no fstat. */
static long lodepng_filesize(const char* filename) static long lodepng_filesize(const char* filename)
@ -415,8 +415,8 @@ unsigned lodepng_save_file(const uint8_t* buffer, size_t buffersize, const char*
/* ////////////////////////////////////////////////////////////////////////// */ /* ////////////////////////////////////////////////////////////////////////// */
/* ////////////////////////////////////////////////////////////////////////// */ /* ////////////////////////////////////////////////////////////////////////// */
#ifdef LODEPNG_COMPILE_ZLIB #if defined(LODEPNG_COMPILE_ZLIB)
#ifdef LODEPNG_COMPILE_ENCODER #if defined(LODEPNG_COMPILE_ENCODER)
/*TODO: this ignores potential out of memory errors*/ /*TODO: this ignores potential out of memory errors*/
#define addBitToStream(/*size_t**/ bitpointer, /*ucvector**/ bitstream, /*uint8_t*/ bit)\ #define addBitToStream(/*size_t**/ bitpointer, /*ucvector**/ bitstream, /*uint8_t*/ bit)\
{\ {\
@ -440,7 +440,7 @@ static void addBitsToStreamReversed(size_t* bitpointer, ucvector* bitstream, uns
} }
#endif /*LODEPNG_COMPILE_ENCODER*/ #endif /*LODEPNG_COMPILE_ENCODER*/
#ifdef LODEPNG_COMPILE_DECODER #if defined(LODEPNG_COMPILE_DECODER)
#define READBIT(bitpointer, bitstream) ((bitstream[bitpointer >> 3] >> (bitpointer & 0x7)) & (uint8_t)1) #define READBIT(bitpointer, bitstream) ((bitstream[bitpointer >> 3] >> (bitpointer & 0x7)) & (uint8_t)1)
@ -669,7 +669,7 @@ static unsigned HuffmanTree_makeFromLengths(HuffmanTree* tree, const unsigned* b
return HuffmanTree_makeFromLengths2(tree); return HuffmanTree_makeFromLengths2(tree);
} }
#ifdef LODEPNG_COMPILE_ENCODER #if defined(LODEPNG_COMPILE_ENCODER)
/*BPM: Boundary Package Merge, see "A Fast and Space-Economical Algorithm for Length-Limited Coding", /*BPM: Boundary Package Merge, see "A Fast and Space-Economical Algorithm for Length-Limited Coding",
Jyrki Katajainen, Alistair Moffat, Andrew Turpin, 1995.*/ Jyrki Katajainen, Alistair Moffat, Andrew Turpin, 1995.*/
@ -942,7 +942,7 @@ static unsigned generateFixedDistanceTree(HuffmanTree* tree)
return error; return error;
} }
#ifdef LODEPNG_COMPILE_DECODER #if defined(LODEPNG_COMPILE_DECODER)
/* /*
returns the code, or (unsigned)(-1) if error happened returns the code, or (unsigned)(-1) if error happened
@ -969,7 +969,7 @@ static unsigned huffmanDecodeSymbol(const uint8_t* in, size_t* bp,
} }
#endif /*LODEPNG_COMPILE_DECODER*/ #endif /*LODEPNG_COMPILE_DECODER*/
#ifdef LODEPNG_COMPILE_DECODER #if defined(LODEPNG_COMPILE_DECODER)
/* ////////////////////////////////////////////////////////////////////////// */ /* ////////////////////////////////////////////////////////////////////////// */
/* / Inflator (Decompressor) / */ /* / Inflator (Decompressor) / */
@ -1318,7 +1318,7 @@ static unsigned inflate(uint8_t** out, size_t* outsize,
#endif /*LODEPNG_COMPILE_DECODER*/ #endif /*LODEPNG_COMPILE_DECODER*/
#ifdef LODEPNG_COMPILE_ENCODER #if defined(LODEPNG_COMPILE_ENCODER)
/* ////////////////////////////////////////////////////////////////////////// */ /* ////////////////////////////////////////////////////////////////////////// */
/* / Deflator (Compressor) / */ /* / Deflator (Compressor) / */
@ -2135,7 +2135,7 @@ static unsigned adler32(const uint8_t* data, unsigned len)
/* / Zlib / */ /* / Zlib / */
/* ////////////////////////////////////////////////////////////////////////// */ /* ////////////////////////////////////////////////////////////////////////// */
#ifdef LODEPNG_COMPILE_DECODER #if defined(LODEPNG_COMPILE_DECODER)
unsigned lodepng_zlib_decompress(uint8_t** out, size_t* outsize, const uint8_t* in, unsigned lodepng_zlib_decompress(uint8_t** out, size_t* outsize, const uint8_t* in,
size_t insize, const LodePNGDecompressSettings* settings) size_t insize, const LodePNGDecompressSettings* settings)
@ -2197,7 +2197,7 @@ static unsigned zlib_decompress(uint8_t** out, size_t* outsize, const uint8_t* i
#endif /*LODEPNG_COMPILE_DECODER*/ #endif /*LODEPNG_COMPILE_DECODER*/
#ifdef LODEPNG_COMPILE_ENCODER #if defined(LODEPNG_COMPILE_ENCODER)
unsigned lodepng_zlib_compress(uint8_t** out, size_t* outsize, const uint8_t* in, unsigned lodepng_zlib_compress(uint8_t** out, size_t* outsize, const uint8_t* in,
size_t insize, const LodePNGCompressSettings* settings) size_t insize, const LodePNGCompressSettings* settings)
@ -2258,7 +2258,7 @@ static unsigned zlib_compress(uint8_t** out, size_t* outsize, const uint8_t* in,
#else /*no LODEPNG_COMPILE_ZLIB*/ #else /*no LODEPNG_COMPILE_ZLIB*/
#ifdef LODEPNG_COMPILE_DECODER #if defined(LODEPNG_COMPILE_DECODER)
static unsigned zlib_decompress(uint8_t** out, size_t* outsize, const uint8_t* in, static unsigned zlib_decompress(uint8_t** out, size_t* outsize, const uint8_t* in,
size_t insize, const LodePNGDecompressSettings* settings) size_t insize, const LodePNGDecompressSettings* settings)
{ {
@ -2266,7 +2266,7 @@ static unsigned zlib_decompress(uint8_t** out, size_t* outsize, const uint8_t* i
return settings->custom_zlib(out, outsize, in, insize, settings); return settings->custom_zlib(out, outsize, in, insize, settings);
} }
#endif /*LODEPNG_COMPILE_DECODER*/ #endif /*LODEPNG_COMPILE_DECODER*/
#ifdef LODEPNG_COMPILE_ENCODER #if defined(LODEPNG_COMPILE_ENCODER)
static unsigned zlib_compress(uint8_t** out, size_t* outsize, const uint8_t* in, static unsigned zlib_compress(uint8_t** out, size_t* outsize, const uint8_t* in,
size_t insize, const LodePNGCompressSettings* settings) size_t insize, const LodePNGCompressSettings* settings)
{ {
@ -2279,7 +2279,7 @@ static unsigned zlib_compress(uint8_t** out, size_t* outsize, const uint8_t* in,
/* ////////////////////////////////////////////////////////////////////////// */ /* ////////////////////////////////////////////////////////////////////////// */
#ifdef LODEPNG_COMPILE_ENCODER #if defined(LODEPNG_COMPILE_ENCODER)
/*this is a good tradeoff between speed and compression ratio*/ /*this is a good tradeoff between speed and compression ratio*/
#define DEFAULT_WINDOWSIZE 2048 #define DEFAULT_WINDOWSIZE 2048
@ -2304,7 +2304,7 @@ const LodePNGCompressSettings lodepng_default_compress_settings = {2, 1, DEFAULT
#endif /*LODEPNG_COMPILE_ENCODER*/ #endif /*LODEPNG_COMPILE_ENCODER*/
#ifdef LODEPNG_COMPILE_DECODER #if defined(LODEPNG_COMPILE_DECODER)
void lodepng_decompress_settings_init(LodePNGDecompressSettings* settings) void lodepng_decompress_settings_init(LodePNGDecompressSettings* settings)
{ {
@ -2325,14 +2325,14 @@ const LodePNGDecompressSettings lodepng_default_decompress_settings = {0, 0, 0,
/* ////////////////////////////////////////////////////////////////////////// */ /* ////////////////////////////////////////////////////////////////////////// */
/* ////////////////////////////////////////////////////////////////////////// */ /* ////////////////////////////////////////////////////////////////////////// */
#ifdef LODEPNG_COMPILE_PNG #if defined(LODEPNG_COMPILE_PNG)
/* ////////////////////////////////////////////////////////////////////////// */ /* ////////////////////////////////////////////////////////////////////////// */
/* / CRC32 / */ /* / CRC32 / */
/* ////////////////////////////////////////////////////////////////////////// */ /* ////////////////////////////////////////////////////////////////////////// */
#ifndef LODEPNG_NO_COMPILE_CRC #if !defined(LODEPNG_NO_COMPILE_CRC)
/* CRC polynomial: 0xedb88320 */ /* CRC polynomial: 0xedb88320 */
static unsigned lodepng_crc32_table[256] = static unsigned lodepng_crc32_table[256] =
{ {
@ -2408,7 +2408,7 @@ static unsigned readBitsFromReversedStream(size_t* bitpointer, const uint8_t* bi
return result; return result;
} }
#ifdef LODEPNG_COMPILE_DECODER #if defined(LODEPNG_COMPILE_DECODER)
static void setBitOfReversedStream0(size_t* bitpointer, uint8_t* bitstream, uint8_t bit) static void setBitOfReversedStream0(size_t* bitpointer, uint8_t* bitstream, uint8_t bit)
{ {
/*the current bit in bitstream must be 0 for this to work*/ /*the current bit in bitstream must be 0 for this to work*/
@ -2740,8 +2740,8 @@ size_t lodepng_get_raw_size(unsigned w, unsigned h, const LodePNGColorMode* colo
} }
#ifdef LODEPNG_COMPILE_PNG #if defined(LODEPNG_COMPILE_PNG)
#ifdef LODEPNG_COMPILE_DECODER #if defined(LODEPNG_COMPILE_DECODER)
/*in an idat chunk, each scanline is a multiple of 8 bits, unlike the lodepng output buffer*/ /*in an idat chunk, each scanline is a multiple of 8 bits, unlike the lodepng output buffer*/
static size_t lodepng_get_raw_size_idat(unsigned w, unsigned h, const LodePNGColorMode* color) static size_t lodepng_get_raw_size_idat(unsigned w, unsigned h, const LodePNGColorMode* color)
{ {
@ -2753,7 +2753,7 @@ static size_t lodepng_get_raw_size_idat(unsigned w, unsigned h, const LodePNGCol
#endif /*LODEPNG_COMPILE_DECODER*/ #endif /*LODEPNG_COMPILE_DECODER*/
#endif /*LODEPNG_COMPILE_PNG*/ #endif /*LODEPNG_COMPILE_PNG*/
#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS #if defined(LODEPNG_COMPILE_ANCILLARY_CHUNKS)
static void LodePNGUnknownChunks_init(LodePNGInfo* info) static void LodePNGUnknownChunks_init(LodePNGInfo* info)
{ {
@ -2944,7 +2944,7 @@ void lodepng_info_init(LodePNGInfo* info)
info->interlace_method = 0; info->interlace_method = 0;
info->compression_method = 0; info->compression_method = 0;
info->filter_method = 0; info->filter_method = 0;
#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS #if defined(LODEPNG_COMPILE_ANCILLARY_CHUNKS)
info->background_defined = 0; info->background_defined = 0;
info->background_r = info->background_g = info->background_b = 0; info->background_r = info->background_g = info->background_b = 0;
@ -2961,7 +2961,7 @@ void lodepng_info_init(LodePNGInfo* info)
void lodepng_info_cleanup(LodePNGInfo* info) void lodepng_info_cleanup(LodePNGInfo* info)
{ {
lodepng_color_mode_cleanup(&info->color); lodepng_color_mode_cleanup(&info->color);
#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS #if defined(LODEPNG_COMPILE_ANCILLARY_CHUNKS)
LodePNGText_cleanup(info); LodePNGText_cleanup(info);
LodePNGIText_cleanup(info); LodePNGIText_cleanup(info);
@ -2976,7 +2976,7 @@ unsigned lodepng_info_copy(LodePNGInfo* dest, const LodePNGInfo* source)
lodepng_color_mode_init(&dest->color); lodepng_color_mode_init(&dest->color);
CERROR_TRY_RETURN(lodepng_color_mode_copy(&dest->color, &source->color)); CERROR_TRY_RETURN(lodepng_color_mode_copy(&dest->color, &source->color));
#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS #if defined(LODEPNG_COMPILE_ANCILLARY_CHUNKS)
CERROR_TRY_RETURN(LodePNGText_copy(dest, source)); CERROR_TRY_RETURN(LodePNGText_copy(dest, source));
CERROR_TRY_RETURN(LodePNGIText_copy(dest, source)); CERROR_TRY_RETURN(LodePNGIText_copy(dest, source));
@ -3047,7 +3047,7 @@ static int32_t color_tree_get(ColorTree* tree, uint8_t r, uint8_t g, uint8_t b,
return tree ? tree->index : -1; return tree ? tree->index : -1;
} }
#ifdef LODEPNG_COMPILE_ENCODER #if defined(LODEPNG_COMPILE_ENCODER)
static int32_t color_tree_has(ColorTree* tree, uint8_t r, uint8_t g, uint8_t b, uint8_t a) static int32_t color_tree_has(ColorTree* tree, uint8_t r, uint8_t g, uint8_t b, uint8_t a)
{ {
return color_tree_get(tree, r, g, b, a) >= 0; return color_tree_get(tree, r, g, b, a) >= 0;
@ -3552,7 +3552,7 @@ unsigned lodepng_convert(uint8_t* out, const uint8_t* in,
return error; return error;
} }
#ifdef LODEPNG_COMPILE_ENCODER #if defined(LODEPNG_COMPILE_ENCODER)
void lodepng_color_profile_init(LodePNGColorProfile* profile) void lodepng_color_profile_init(LodePNGColorProfile* profile)
{ {
@ -3849,7 +3849,7 @@ unsigned lodepng_auto_choose_color(LodePNGColorMode* mode_out,
return error; return error;
} }
#endif /* #ifdef LODEPNG_COMPILE_ENCODER */ #endif /* #if defined(LODEPNG_COMPILE_ENCODER) */
/* /*
Paeth predicter, used by PNG filter type 4 Paeth predicter, used by PNG filter type 4
@ -3917,7 +3917,7 @@ static void Adam7_getpassvalues(unsigned passw[7], unsigned passh[7], size_t fil
} }
} }
#ifdef LODEPNG_COMPILE_DECODER #if defined(LODEPNG_COMPILE_DECODER)
/* ////////////////////////////////////////////////////////////////////////// */ /* ////////////////////////////////////////////////////////////////////////// */
/* / PNG Decoder / */ /* / PNG Decoder / */
@ -4296,7 +4296,7 @@ static unsigned readChunk_tRNS(LodePNGColorMode* color, const uint8_t* data, siz
} }
#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS #if defined(LODEPNG_COMPILE_ANCILLARY_CHUNKS)
/*background color chunk (bKGD)*/ /*background color chunk (bKGD)*/
static unsigned readChunk_bKGD(LodePNGInfo* info, const uint8_t* data, size_t chunkLength) static unsigned readChunk_bKGD(LodePNGInfo* info, const uint8_t* data, size_t chunkLength)
{ {
@ -4560,7 +4560,7 @@ static void decodeGeneric(uint8_t** out, unsigned* w, unsigned* h,
/*for unknown chunk order*/ /*for unknown chunk order*/
unsigned unknown = 0; unsigned unknown = 0;
#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS #if defined(LODEPNG_COMPILE_ANCILLARY_CHUNKS)
unsigned critical_pos = 1; /*1 = after IHDR, 2 = after PLTE, 3 = after IDAT*/ unsigned critical_pos = 1; /*1 = after IHDR, 2 = after PLTE, 3 = after IDAT*/
#endif /*LODEPNG_COMPILE_ANCILLARY_CHUNKS*/ #endif /*LODEPNG_COMPILE_ANCILLARY_CHUNKS*/
@ -4617,7 +4617,7 @@ static void decodeGeneric(uint8_t** out, unsigned* w, unsigned* h,
size_t oldsize = idat.size; size_t oldsize = idat.size;
if(!ucvector_resize(&idat, oldsize + chunkLength)) CERROR_BREAK(state->error, 83 /*alloc fail*/); if(!ucvector_resize(&idat, oldsize + chunkLength)) CERROR_BREAK(state->error, 83 /*alloc fail*/);
for(i = 0; i != chunkLength; ++i) idat.data[oldsize + i] = data[i]; for(i = 0; i != chunkLength; ++i) idat.data[oldsize + i] = data[i];
#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS #if defined(LODEPNG_COMPILE_ANCILLARY_CHUNKS)
critical_pos = 3; critical_pos = 3;
#endif /*LODEPNG_COMPILE_ANCILLARY_CHUNKS*/ #endif /*LODEPNG_COMPILE_ANCILLARY_CHUNKS*/
} }
@ -4631,7 +4631,7 @@ static void decodeGeneric(uint8_t** out, unsigned* w, unsigned* h,
{ {
state->error = readChunk_PLTE(&state->info_png.color, data, chunkLength); state->error = readChunk_PLTE(&state->info_png.color, data, chunkLength);
if(state->error) break; if(state->error) break;
#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS #if defined(LODEPNG_COMPILE_ANCILLARY_CHUNKS)
critical_pos = 2; critical_pos = 2;
#endif /*LODEPNG_COMPILE_ANCILLARY_CHUNKS*/ #endif /*LODEPNG_COMPILE_ANCILLARY_CHUNKS*/
} }
@ -4641,7 +4641,7 @@ static void decodeGeneric(uint8_t** out, unsigned* w, unsigned* h,
state->error = readChunk_tRNS(&state->info_png.color, data, chunkLength); state->error = readChunk_tRNS(&state->info_png.color, data, chunkLength);
if(state->error) break; if(state->error) break;
} }
#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS #if defined(LODEPNG_COMPILE_ANCILLARY_CHUNKS)
/*background color chunk (bKGD)*/ /*background color chunk (bKGD)*/
else if(lodepng_chunk_type_equals(chunk, "bKGD")) else if(lodepng_chunk_type_equals(chunk, "bKGD"))
{ {
@ -4695,7 +4695,7 @@ static void decodeGeneric(uint8_t** out, unsigned* w, unsigned* h,
} }
unknown = 1; unknown = 1;
#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS #if defined(LODEPNG_COMPILE_ANCILLARY_CHUNKS)
if(state->decoder.remember_unknown_chunks) if(state->decoder.remember_unknown_chunks)
{ {
state->error = lodepng_chunk_append(&state->info_png.unknown_chunks_data[critical_pos - 1], state->error = lodepng_chunk_append(&state->info_png.unknown_chunks_data[critical_pos - 1],
@ -4825,7 +4825,7 @@ unsigned lodepng_decode24(uint8_t** out, unsigned* w, unsigned* h, const uint8_t
return lodepng_decode_memory(out, w, h, in, insize, LCT_RGB, 8); return lodepng_decode_memory(out, w, h, in, insize, LCT_RGB, 8);
} }
#ifdef LODEPNG_COMPILE_DISK #if defined(LODEPNG_COMPILE_DISK)
unsigned lodepng_decode_file(uint8_t** out, unsigned* w, unsigned* h, const char* filename, unsigned lodepng_decode_file(uint8_t** out, unsigned* w, unsigned* h, const char* filename,
LodePNGColorType colortype, unsigned bitdepth) LodePNGColorType colortype, unsigned bitdepth)
{ {
@ -4852,7 +4852,7 @@ unsigned lodepng_decode24_file(uint8_t** out, unsigned* w, unsigned* h, const ch
void lodepng_decoder_settings_init(LodePNGDecoderSettings* settings) void lodepng_decoder_settings_init(LodePNGDecoderSettings* settings)
{ {
settings->color_convert = 1; settings->color_convert = 1;
#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS #if defined(LODEPNG_COMPILE_ANCILLARY_CHUNKS)
settings->read_text_chunks = 1; settings->read_text_chunks = 1;
settings->remember_unknown_chunks = 0; settings->remember_unknown_chunks = 0;
#endif /*LODEPNG_COMPILE_ANCILLARY_CHUNKS*/ #endif /*LODEPNG_COMPILE_ANCILLARY_CHUNKS*/
@ -4868,10 +4868,10 @@ void lodepng_decoder_settings_init(LodePNGDecoderSettings* settings)
void lodepng_state_init(LodePNGState* state) void lodepng_state_init(LodePNGState* state)
{ {
#ifdef LODEPNG_COMPILE_DECODER #if defined(LODEPNG_COMPILE_DECODER)
lodepng_decoder_settings_init(&state->decoder); lodepng_decoder_settings_init(&state->decoder);
#endif /*LODEPNG_COMPILE_DECODER*/ #endif /*LODEPNG_COMPILE_DECODER*/
#ifdef LODEPNG_COMPILE_ENCODER #if defined(LODEPNG_COMPILE_ENCODER)
lodepng_encoder_settings_init(&state->encoder); lodepng_encoder_settings_init(&state->encoder);
#endif /*LODEPNG_COMPILE_ENCODER*/ #endif /*LODEPNG_COMPILE_ENCODER*/
lodepng_color_mode_init(&state->info_raw); lodepng_color_mode_init(&state->info_raw);
@ -4899,7 +4899,7 @@ void lodepng_state_copy(LodePNGState* dest, const LodePNGState* source)
#endif /* defined(LODEPNG_COMPILE_DECODER) || defined(LODEPNG_COMPILE_ENCODER) */ #endif /* defined(LODEPNG_COMPILE_DECODER) || defined(LODEPNG_COMPILE_ENCODER) */
#ifdef LODEPNG_COMPILE_ENCODER #if defined(LODEPNG_COMPILE_ENCODER)
/* ////////////////////////////////////////////////////////////////////////// */ /* ////////////////////////////////////////////////////////////////////////// */
/* / PNG Encoder / */ /* / PNG Encoder / */
@ -5031,7 +5031,7 @@ static unsigned addChunk_IEND(ucvector* out)
return error; return error;
} }
#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS #if defined(LODEPNG_COMPILE_ANCILLARY_CHUNKS)
static unsigned addChunk_tEXt(ucvector* out, const char* keyword, const char* textstring) static unsigned addChunk_tEXt(ucvector* out, const char* keyword, const char* textstring)
{ {
@ -5675,7 +5675,7 @@ static unsigned getPaletteTranslucency(const uint8_t* palette, size_t palettesiz
return key; return key;
} }
#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS #if defined(LODEPNG_COMPILE_ANCILLARY_CHUNKS)
static unsigned addUnknownChunks(ucvector* out, uint8_t* data, size_t datasize) static unsigned addUnknownChunks(ucvector* out, uint8_t* data, size_t datasize)
{ {
uint8_t* inchunk = data; uint8_t* inchunk = data;
@ -5758,14 +5758,14 @@ unsigned lodepng_encode(uint8_t** out, size_t* outsize,
ucvector_init(&outv); ucvector_init(&outv);
while(!state->error) /*while only executed once, to break on error*/ while(!state->error) /*while only executed once, to break on error*/
{ {
#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS #if defined(LODEPNG_COMPILE_ANCILLARY_CHUNKS)
size_t i; size_t i;
#endif /*LODEPNG_COMPILE_ANCILLARY_CHUNKS*/ #endif /*LODEPNG_COMPILE_ANCILLARY_CHUNKS*/
/*write signature and chunks*/ /*write signature and chunks*/
writeSignature(&outv); writeSignature(&outv);
/*IHDR*/ /*IHDR*/
addChunk_IHDR(&outv, w, h, info.color.colortype, info.color.bitdepth, info.interlace_method); addChunk_IHDR(&outv, w, h, info.color.colortype, info.color.bitdepth, info.interlace_method);
#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS #if defined(LODEPNG_COMPILE_ANCILLARY_CHUNKS)
/*unknown chunks between IHDR and PLTE*/ /*unknown chunks between IHDR and PLTE*/
if(info.unknown_chunks_data[0]) if(info.unknown_chunks_data[0])
{ {
@ -5791,7 +5791,7 @@ unsigned lodepng_encode(uint8_t** out, size_t* outsize,
{ {
addChunk_tRNS(&outv, &info.color); addChunk_tRNS(&outv, &info.color);
} }
#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS #if defined(LODEPNG_COMPILE_ANCILLARY_CHUNKS)
/*bKGD (must come between PLTE and the IDAt chunks*/ /*bKGD (must come between PLTE and the IDAt chunks*/
if(info.background_defined) addChunk_bKGD(&outv, &info); if(info.background_defined) addChunk_bKGD(&outv, &info);
/*pHYs (must come before the IDAT chunks)*/ /*pHYs (must come before the IDAT chunks)*/
@ -5807,7 +5807,7 @@ unsigned lodepng_encode(uint8_t** out, size_t* outsize,
/*IDAT (multiple IDAT chunks must be consecutive)*/ /*IDAT (multiple IDAT chunks must be consecutive)*/
state->error = addChunk_IDAT(&outv, data, datasize, &state->encoder.zlibsettings); state->error = addChunk_IDAT(&outv, data, datasize, &state->encoder.zlibsettings);
if(state->error) break; if(state->error) break;
#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS #if defined(LODEPNG_COMPILE_ANCILLARY_CHUNKS)
/*tIME*/ /*tIME*/
if(info.time_defined) addChunk_tIME(&outv, &info.time); if(info.time_defined) addChunk_tIME(&outv, &info.time);
/*tEXt and/or zTXt*/ /*tEXt and/or zTXt*/
@ -5914,7 +5914,7 @@ unsigned lodepng_encode24(uint8_t** out, size_t* outsize, const uint8_t* image,
return lodepng_encode_memory(out, outsize, image, w, h, LCT_RGB, 8); return lodepng_encode_memory(out, outsize, image, w, h, LCT_RGB, 8);
} }
#ifdef LODEPNG_COMPILE_DISK #if defined(LODEPNG_COMPILE_DISK)
unsigned lodepng_encode_file(const char* filename, const uint8_t* image, unsigned w, unsigned h, unsigned lodepng_encode_file(const char* filename, const uint8_t* image, unsigned w, unsigned h,
LodePNGColorType colortype, unsigned bitdepth) LodePNGColorType colortype, unsigned bitdepth)
{ {
@ -5945,7 +5945,7 @@ void lodepng_encoder_settings_init(LodePNGEncoderSettings* settings)
settings->auto_convert = 1; settings->auto_convert = 1;
settings->force_palette = 0; settings->force_palette = 0;
settings->predefined_filters = 0; settings->predefined_filters = 0;
#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS #if defined(LODEPNG_COMPILE_ANCILLARY_CHUNKS)
settings->add_id = 0; settings->add_id = 0;
settings->text_compression = 1; settings->text_compression = 1;
#endif /*LODEPNG_COMPILE_ANCILLARY_CHUNKS*/ #endif /*LODEPNG_COMPILE_ANCILLARY_CHUNKS*/
@ -5954,7 +5954,7 @@ void lodepng_encoder_settings_init(LodePNGEncoderSettings* settings)
#endif /*LODEPNG_COMPILE_ENCODER*/ #endif /*LODEPNG_COMPILE_ENCODER*/
#endif /*LODEPNG_COMPILE_PNG*/ #endif /*LODEPNG_COMPILE_PNG*/
#ifdef LODEPNG_COMPILE_ERROR_TEXT #if defined(LODEPNG_COMPILE_ERROR_TEXT)
/* /*
This returns the description of a numerical error code in English. This is also This returns the description of a numerical error code in English. This is also
the documentation of all the error codes. the documentation of all the error codes.
@ -6141,237 +6141,3 @@ const char* lodepng_error_text(unsigned code)
return "unknown error code"; return "unknown error code";
} }
#endif /*LODEPNG_COMPILE_ERROR_TEXT*/ #endif /*LODEPNG_COMPILE_ERROR_TEXT*/
/* ////////////////////////////////////////////////////////////////////////// */
/* ////////////////////////////////////////////////////////////////////////// */
/* // C++ Wrapper // */
/* ////////////////////////////////////////////////////////////////////////// */
/* ////////////////////////////////////////////////////////////////////////// */
#ifdef LODEPNG_COMPILE_CPP
namespace lodepng
{
#ifdef LODEPNG_COMPILE_DISK
unsigned load_file(std::vector<uint8_t>& buffer, const std::string& filename)
{
long size = lodepng_filesize(filename.c_str());
if(size < 0) return 78;
buffer.resize((size_t)size);
return size == 0 ? 0 : lodepng_buffer_file(&buffer[0], (size_t)size, filename.c_str());
}
/*write given buffer to the file, overwriting the file, it doesn't append to it.*/
unsigned save_file(const std::vector<uint8_t>& buffer, const std::string& filename)
{
return lodepng_save_file(buffer.empty() ? 0 : &buffer[0], buffer.size(), filename.c_str());
}
#endif /* LODEPNG_COMPILE_DISK */
#ifdef LODEPNG_COMPILE_ZLIB
#ifdef LODEPNG_COMPILE_DECODER
unsigned decompress(std::vector<uint8_t>& out, const uint8_t* in, size_t insize,
const LodePNGDecompressSettings& settings)
{
uint8_t* buffer = 0;
size_t buffersize = 0;
unsigned error = zlib_decompress(&buffer, &buffersize, in, insize, &settings);
if(buffer)
{
out.insert(out.end(), &buffer[0], &buffer[buffersize]);
lodepng_free(buffer);
}
return error;
}
unsigned decompress(std::vector<uint8_t>& out, const std::vector<uint8_t>& in,
const LodePNGDecompressSettings& settings)
{
return decompress(out, in.empty() ? 0 : &in[0], in.size(), settings);
}
#endif /* LODEPNG_COMPILE_DECODER */
#ifdef LODEPNG_COMPILE_ENCODER
unsigned compress(std::vector<uint8_t>& out, const uint8_t* in, size_t insize,
const LodePNGCompressSettings& settings)
{
uint8_t* buffer = 0;
size_t buffersize = 0;
unsigned error = zlib_compress(&buffer, &buffersize, in, insize, &settings);
if(buffer)
{
out.insert(out.end(), &buffer[0], &buffer[buffersize]);
lodepng_free(buffer);
}
return error;
}
unsigned compress(std::vector<uint8_t>& out, const std::vector<uint8_t>& in,
const LodePNGCompressSettings& settings)
{
return compress(out, in.empty() ? 0 : &in[0], in.size(), settings);
}
#endif /* LODEPNG_COMPILE_ENCODER */
#endif /* LODEPNG_COMPILE_ZLIB */
#ifdef LODEPNG_COMPILE_PNG
State::State()
{
lodepng_state_init(this);
}
State::State(const State& other)
{
lodepng_state_init(this);
lodepng_state_copy(this, &other);
}
State::~State()
{
lodepng_state_cleanup(this);
}
State& State::operator=(const State& other)
{
lodepng_state_copy(this, &other);
return *this;
}
#ifdef LODEPNG_COMPILE_DECODER
unsigned decode(std::vector<uint8_t>& out, unsigned& w, unsigned& h, const uint8_t* in,
size_t insize, LodePNGColorType colortype, unsigned bitdepth)
{
uint8_t* buffer;
unsigned error = lodepng_decode_memory(&buffer, &w, &h, in, insize, colortype, bitdepth);
if(buffer && !error)
{
State state;
state.info_raw.colortype = colortype;
state.info_raw.bitdepth = bitdepth;
size_t buffersize = lodepng_get_raw_size(w, h, &state.info_raw);
out.insert(out.end(), &buffer[0], &buffer[buffersize]);
lodepng_free(buffer);
}
return error;
}
unsigned decode(std::vector<uint8_t>& out, unsigned& w, unsigned& h,
const std::vector<uint8_t>& in, LodePNGColorType colortype, unsigned bitdepth)
{
return decode(out, w, h, in.empty() ? 0 : &in[0], (unsigned)in.size(), colortype, bitdepth);
}
unsigned decode(std::vector<uint8_t>& out, unsigned& w, unsigned& h,
State& state,
const uint8_t* in, size_t insize)
{
uint8_t* buffer = NULL;
unsigned error = lodepng_decode(&buffer, &w, &h, &state, in, insize);
if(buffer && !error)
{
size_t buffersize = lodepng_get_raw_size(w, h, &state.info_raw);
out.insert(out.end(), &buffer[0], &buffer[buffersize]);
}
lodepng_free(buffer);
return error;
}
unsigned decode(std::vector<uint8_t>& out, unsigned& w, unsigned& h,
State& state,
const std::vector<uint8_t>& in)
{
return decode(out, w, h, state, in.empty() ? 0 : &in[0], in.size());
}
#ifdef LODEPNG_COMPILE_DISK
unsigned decode(std::vector<uint8_t>& out, unsigned& w, unsigned& h, const std::string& filename,
LodePNGColorType colortype, unsigned bitdepth)
{
std::vector<uint8_t> buffer;
unsigned error = load_file(buffer, filename);
if(error) return error;
return decode(out, w, h, buffer, colortype, bitdepth);
}
#endif /* LODEPNG_COMPILE_DECODER */
#endif /* LODEPNG_COMPILE_DISK */
#ifdef LODEPNG_COMPILE_ENCODER
static size_t lodepng_get_raw_size_lct(unsigned w, unsigned h, LodePNGColorType colortype, unsigned bitdepth)
{
/*will not overflow for any color type if roughly w * h < 268435455*/
size_t bpp = lodepng_get_bpp_lct(colortype, bitdepth);
size_t n = w * h;
return ((n / 8) * bpp) + ((n & 7) * bpp + 7) / 8;
}
unsigned encode(std::vector<uint8_t>& out, const uint8_t* in, unsigned w, unsigned h,
LodePNGColorType colortype, unsigned bitdepth)
{
uint8_t* buffer;
size_t buffersize;
unsigned error = lodepng_encode_memory(&buffer, &buffersize, in, w, h, colortype, bitdepth);
if(buffer)
{
out.insert(out.end(), &buffer[0], &buffer[buffersize]);
lodepng_free(buffer);
}
return error;
}
unsigned encode(std::vector<uint8_t>& out,
const std::vector<uint8_t>& in, unsigned w, unsigned h,
LodePNGColorType colortype, unsigned bitdepth)
{
if(lodepng_get_raw_size_lct(w, h, colortype, bitdepth) > in.size()) return 84;
return encode(out, in.empty() ? 0 : &in[0], w, h, colortype, bitdepth);
}
unsigned encode(std::vector<uint8_t>& out,
const uint8_t* in, unsigned w, unsigned h,
State& state)
{
uint8_t* buffer;
size_t buffersize;
unsigned error = lodepng_encode(&buffer, &buffersize, in, w, h, &state);
if(buffer)
{
out.insert(out.end(), &buffer[0], &buffer[buffersize]);
lodepng_free(buffer);
}
return error;
}
unsigned encode(std::vector<uint8_t>& out,
const std::vector<uint8_t>& in, unsigned w, unsigned h,
State& state)
{
if(lodepng_get_raw_size(w, h, &state.info_raw) > in.size()) return 84;
return encode(out, in.empty() ? 0 : &in[0], w, h, state);
}
#ifdef LODEPNG_COMPILE_DISK
unsigned encode(const std::string& filename,
const uint8_t* in, unsigned w, unsigned h,
LodePNGColorType colortype, unsigned bitdepth)
{
std::vector<uint8_t> buffer;
unsigned error = encode(buffer, in, w, h, colortype, bitdepth);
if(!error) error = save_file(buffer, filename);
return error;
}
unsigned encode(const std::string& filename,
const std::vector<uint8_t>& in, unsigned w, unsigned h,
LodePNGColorType colortype, unsigned bitdepth)
{
if(lodepng_get_raw_size_lct(w, h, colortype, bitdepth) > in.size()) return 84;
return encode(filename, in.empty() ? 0 : &in[0], w, h, colortype, bitdepth);
}
#endif /* LODEPNG_COMPILE_DISK */
#endif /* LODEPNG_COMPILE_ENCODER */
#endif /* LODEPNG_COMPILE_PNG */
} /* namespace lodepng */
#endif /*LODEPNG_COMPILE_CPP*/

View File

@ -23,8 +23,8 @@ freely, subject to the following restrictions:
distribution. distribution.
*/ */
#ifndef LODEPNG_H #ifndef spingle__lodepng_h
#define LODEPNG_H #define spingle__lodepng_h
#include <string.h> /*for size_t*/ #include <string.h> /*for size_t*/
@ -41,52 +41,41 @@ allow implementing a custom lodepng_crc32.
*/ */
/*deflate & zlib. If disabled, you must specify alternative zlib functions in /*deflate & zlib. If disabled, you must specify alternative zlib functions in
the custom_zlib field of the compress and decompress settings*/ the custom_zlib field of the compress and decompress settings*/
#ifndef LODEPNG_NO_COMPILE_ZLIB #if !defined(LODEPNG_NO_COMPILE_ZLIB)
#define LODEPNG_COMPILE_ZLIB #define LODEPNG_COMPILE_ZLIB
#endif #endif
/*png encoder and png decoder*/ /*png encoder and png decoder*/
#ifndef LODEPNG_NO_COMPILE_PNG #if !defined(LODEPNG_NO_COMPILE_PNG)
#define LODEPNG_COMPILE_PNG #define LODEPNG_COMPILE_PNG
#endif #endif
/*deflate&zlib decoder and png decoder*/ /*deflate&zlib decoder and png decoder*/
#ifndef LODEPNG_NO_COMPILE_DECODER #if !defined(LODEPNG_NO_COMPILE_DECODER)
#define LODEPNG_COMPILE_DECODER #define LODEPNG_COMPILE_DECODER
#endif #endif
/*deflate&zlib encoder and png encoder*/ /*deflate&zlib encoder and png encoder*/
#ifndef LODEPNG_NO_COMPILE_ENCODER #if !defined(LODEPNG_NO_COMPILE_ENCODER)
#define LODEPNG_COMPILE_ENCODER #define LODEPNG_COMPILE_ENCODER
#endif #endif
/*the optional built in harddisk file loading and saving functions*/ /*the optional built in harddisk file loading and saving functions*/
#ifndef LODEPNG_NO_COMPILE_DISK #if !defined(LODEPNG_NO_COMPILE_DISK)
#define LODEPNG_COMPILE_DISK #define LODEPNG_COMPILE_DISK
#endif #endif
/*support for chunks other than IHDR, IDAT, PLTE, tRNS, IEND: ancillary and unknown chunks*/ /*support for chunks other than IHDR, IDAT, PLTE, tRNS, IEND: ancillary and unknown chunks*/
#ifndef LODEPNG_NO_COMPILE_ANCILLARY_CHUNKS #if !defined(LODEPNG_NO_COMPILE_ANCILLARY_CHUNKS)
#define LODEPNG_COMPILE_ANCILLARY_CHUNKS #define LODEPNG_COMPILE_ANCILLARY_CHUNKS
#endif #endif
/*ability to convert error numerical codes to English text string*/ /*ability to convert error numerical codes to English text string*/
#ifndef LODEPNG_NO_COMPILE_ERROR_TEXT #if !defined(LODEPNG_NO_COMPILE_ERROR_TEXT)
#define LODEPNG_COMPILE_ERROR_TEXT #define LODEPNG_COMPILE_ERROR_TEXT
#endif #endif
/*Compile the default allocators (C's free, malloc and realloc). If you disable this, /*Compile the default allocators (C's free, malloc and realloc). If you disable this,
you can define the functions lodepng_free, lodepng_malloc and lodepng_realloc in your you can define the functions lodepng_free, lodepng_malloc and lodepng_realloc in your
source files with custom allocators.*/ source files with custom allocators.*/
#ifndef LODEPNG_NO_COMPILE_ALLOCATORS #if !defined(LODEPNG_NO_COMPILE_ALLOCATORS)
#define LODEPNG_COMPILE_ALLOCATORS #define LODEPNG_COMPILE_ALLOCATORS
#endif #endif
/*compile the C++ version (you can disable the C++ wrapper here even when compiling for C++)*/
#ifdef __cplusplus
#ifndef LODEPNG_NO_COMPILE_CPP
#define LODEPNG_COMPILE_CPP
#endif
#endif
#ifdef LODEPNG_COMPILE_CPP #if defined(LODEPNG_COMPILE_PNG)
#include <vector>
#include <string>
#endif /*LODEPNG_COMPILE_CPP*/
#ifdef LODEPNG_COMPILE_PNG
/*The PNG color types (also used for raw).*/ /*The PNG color types (also used for raw).*/
typedef enum LodePNGColorType typedef enum LodePNGColorType
{ {
@ -97,7 +86,7 @@ typedef enum LodePNGColorType
LCT_RGBA = 6 /*RGB with alpha: 8,16 bit*/ LCT_RGBA = 6 /*RGB with alpha: 8,16 bit*/
} LodePNGColorType; } LodePNGColorType;
#ifdef LODEPNG_COMPILE_DECODER #if defined(LODEPNG_COMPILE_DECODER)
/* /*
Converts PNG data in memory to raw pixel data. Converts PNG data in memory to raw pixel data.
out: Output parameter. Pointer to buffer that will contain the raw pixel data. out: Output parameter. Pointer to buffer that will contain the raw pixel data.
@ -125,7 +114,7 @@ unsigned lodepng_decode32(uint8_t** out, unsigned* w, unsigned* h,
unsigned lodepng_decode24(uint8_t** out, unsigned* w, unsigned* h, unsigned lodepng_decode24(uint8_t** out, unsigned* w, unsigned* h,
const uint8_t* in, size_t insize); const uint8_t* in, size_t insize);
#ifdef LODEPNG_COMPILE_DISK #if defined(LODEPNG_COMPILE_DISK)
/* /*
Load PNG from disk, from file with given name. Load PNG from disk, from file with given name.
Same as the other decode functions, but instead takes a filename as input. Same as the other decode functions, but instead takes a filename as input.
@ -145,7 +134,7 @@ unsigned lodepng_decode24_file(uint8_t** out, unsigned* w, unsigned* h,
#endif /*LODEPNG_COMPILE_DECODER*/ #endif /*LODEPNG_COMPILE_DECODER*/
#ifdef LODEPNG_COMPILE_ENCODER #if defined(LODEPNG_COMPILE_ENCODER)
/* /*
Converts raw pixel data into a PNG image in memory. The colortype and bitdepth Converts raw pixel data into a PNG image in memory. The colortype and bitdepth
of the output PNG image cannot be chosen, they are automatically determined of the output PNG image cannot be chosen, they are automatically determined
@ -174,7 +163,7 @@ unsigned lodepng_encode32(uint8_t** out, size_t* outsize,
unsigned lodepng_encode24(uint8_t** out, size_t* outsize, unsigned lodepng_encode24(uint8_t** out, size_t* outsize,
const uint8_t* image, unsigned w, unsigned h); const uint8_t* image, unsigned w, unsigned h);
#ifdef LODEPNG_COMPILE_DISK #if defined(LODEPNG_COMPILE_DISK)
/* /*
Converts raw pixel data into a PNG file on disk. Converts raw pixel data into a PNG file on disk.
Same as the other encode functions, but instead takes a filename as output. Same as the other encode functions, but instead takes a filename as output.
@ -194,63 +183,14 @@ unsigned lodepng_encode24_file(const char* filename,
#endif /*LODEPNG_COMPILE_DISK*/ #endif /*LODEPNG_COMPILE_DISK*/
#endif /*LODEPNG_COMPILE_ENCODER*/ #endif /*LODEPNG_COMPILE_ENCODER*/
#ifdef LODEPNG_COMPILE_CPP
namespace lodepng
{
#ifdef LODEPNG_COMPILE_DECODER
/*Same as lodepng_decode_memory, but decodes to an std::vector. The colortype
is the format to output the pixels to. Default is RGBA 8-bit per channel.*/
unsigned decode(std::vector<uint8_t>& out, unsigned& w, unsigned& h,
const uint8_t* in, size_t insize,
LodePNGColorType colortype = LCT_RGBA, unsigned bitdepth = 8);
unsigned decode(std::vector<uint8_t>& out, unsigned& w, unsigned& h,
const std::vector<uint8_t>& in,
LodePNGColorType colortype = LCT_RGBA, unsigned bitdepth = 8);
#ifdef LODEPNG_COMPILE_DISK
/*
Converts PNG file from disk to raw pixel data in memory.
Same as the other decode functions, but instead takes a filename as input.
*/
unsigned decode(std::vector<uint8_t>& out, unsigned& w, unsigned& h,
const std::string& filename,
LodePNGColorType colortype = LCT_RGBA, unsigned bitdepth = 8);
#endif /* LODEPNG_COMPILE_DISK */
#endif /* LODEPNG_COMPILE_DECODER */
#ifdef LODEPNG_COMPILE_ENCODER
/*Same as lodepng_encode_memory, but encodes to an std::vector. colortype
is that of the raw input data. The output PNG color type will be auto chosen.*/
unsigned encode(std::vector<uint8_t>& out,
const uint8_t* in, unsigned w, unsigned h,
LodePNGColorType colortype = LCT_RGBA, unsigned bitdepth = 8);
unsigned encode(std::vector<uint8_t>& out,
const std::vector<uint8_t>& in, unsigned w, unsigned h,
LodePNGColorType colortype = LCT_RGBA, unsigned bitdepth = 8);
#ifdef LODEPNG_COMPILE_DISK
/*
Converts 32-bit RGBA raw pixel data into a PNG file on disk.
Same as the other encode functions, but instead takes a filename as output.
NOTE: This overwrites existing files without warning!
*/
unsigned encode(const std::string& filename,
const uint8_t* in, unsigned w, unsigned h,
LodePNGColorType colortype = LCT_RGBA, unsigned bitdepth = 8);
unsigned encode(const std::string& filename,
const std::vector<uint8_t>& in, unsigned w, unsigned h,
LodePNGColorType colortype = LCT_RGBA, unsigned bitdepth = 8);
#endif /* LODEPNG_COMPILE_DISK */
#endif /* LODEPNG_COMPILE_ENCODER */
} /* namespace lodepng */
#endif /*LODEPNG_COMPILE_CPP*/
#endif /*LODEPNG_COMPILE_PNG*/ #endif /*LODEPNG_COMPILE_PNG*/
#ifdef LODEPNG_COMPILE_ERROR_TEXT #if defined(LODEPNG_COMPILE_ERROR_TEXT)
/*Returns an English description of the numerical error code.*/ /*Returns an English description of the numerical error code.*/
const char* lodepng_error_text(unsigned code); const char* lodepng_error_text(unsigned code);
#endif /*LODEPNG_COMPILE_ERROR_TEXT*/ #endif /*LODEPNG_COMPILE_ERROR_TEXT*/
#ifdef LODEPNG_COMPILE_DECODER #if defined(LODEPNG_COMPILE_DECODER)
/*Settings for zlib decompression*/ /*Settings for zlib decompression*/
typedef struct LodePNGDecompressSettings LodePNGDecompressSettings; typedef struct LodePNGDecompressSettings LodePNGDecompressSettings;
struct LodePNGDecompressSettings struct LodePNGDecompressSettings
@ -276,7 +216,7 @@ extern const LodePNGDecompressSettings lodepng_default_decompress_settings;
void lodepng_decompress_settings_init(LodePNGDecompressSettings* settings); void lodepng_decompress_settings_init(LodePNGDecompressSettings* settings);
#endif /*LODEPNG_COMPILE_DECODER*/ #endif /*LODEPNG_COMPILE_DECODER*/
#ifdef LODEPNG_COMPILE_ENCODER #if defined(LODEPNG_COMPILE_ENCODER)
/* /*
Settings for zlib compression. Tweaking these settings tweaks the balance Settings for zlib compression. Tweaking these settings tweaks the balance
between speed and compression ratio. between speed and compression ratio.
@ -310,7 +250,7 @@ extern const LodePNGCompressSettings lodepng_default_compress_settings;
void lodepng_compress_settings_init(LodePNGCompressSettings* settings); void lodepng_compress_settings_init(LodePNGCompressSettings* settings);
#endif /*LODEPNG_COMPILE_ENCODER*/ #endif /*LODEPNG_COMPILE_ENCODER*/
#ifdef LODEPNG_COMPILE_PNG #if defined(LODEPNG_COMPILE_PNG)
/* /*
Color mode of an image. Contains all information required to decode the pixel Color mode of an image. Contains all information required to decode the pixel
bits to RGBA colors. This information is the same as used in the PNG file bits to RGBA colors. This information is the same as used in the PNG file
@ -391,7 +331,7 @@ unsigned lodepng_can_have_alpha(const LodePNGColorMode* info);
/*Returns the byte size of a raw image buffer with given width, height and color mode*/ /*Returns the byte size of a raw image buffer with given width, height and color mode*/
size_t lodepng_get_raw_size(unsigned w, unsigned h, const LodePNGColorMode* color); size_t lodepng_get_raw_size(unsigned w, unsigned h, const LodePNGColorMode* color);
#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS #if defined(LODEPNG_COMPILE_ANCILLARY_CHUNKS)
/*The information of a Time chunk in PNG.*/ /*The information of a Time chunk in PNG.*/
typedef struct LodePNGTime typedef struct LodePNGTime
{ {
@ -413,7 +353,7 @@ typedef struct LodePNGInfo
unsigned interlace_method; /*interlace method of the original file*/ unsigned interlace_method; /*interlace method of the original file*/
LodePNGColorMode color; /*color type and bits, palette and transparency of the PNG file*/ LodePNGColorMode color; /*color type and bits, palette and transparency of the PNG file*/
#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS #if defined(LODEPNG_COMPILE_ANCILLARY_CHUNKS)
/* /*
suggested background color chunk (bKGD) suggested background color chunk (bKGD)
This color uses the same color mode as the PNG (except alpha channel), which can be 1-bit to 16-bit. This color uses the same color mode as the PNG (except alpha channel), which can be 1-bit to 16-bit.
@ -488,7 +428,7 @@ void lodepng_info_cleanup(LodePNGInfo* info);
/*return value is error code (0 means no error)*/ /*return value is error code (0 means no error)*/
unsigned lodepng_info_copy(LodePNGInfo* dest, const LodePNGInfo* source); unsigned lodepng_info_copy(LodePNGInfo* dest, const LodePNGInfo* source);
#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS #if defined(LODEPNG_COMPILE_ANCILLARY_CHUNKS)
void lodepng_clear_text(LodePNGInfo* info); /*use this to clear the texts again after you filled them in*/ void lodepng_clear_text(LodePNGInfo* info); /*use this to clear the texts again after you filled them in*/
unsigned lodepng_add_text(LodePNGInfo* info, const char* key, const char* str); /*push back both texts at once*/ unsigned lodepng_add_text(LodePNGInfo* info, const char* key, const char* str); /*push back both texts at once*/
@ -512,7 +452,7 @@ unsigned lodepng_convert(uint8_t* out, const uint8_t* in,
const LodePNGColorMode* mode_out, const LodePNGColorMode* mode_in, const LodePNGColorMode* mode_out, const LodePNGColorMode* mode_in,
unsigned w, unsigned h); unsigned w, unsigned h);
#ifdef LODEPNG_COMPILE_DECODER #if defined(LODEPNG_COMPILE_DECODER)
/* /*
Settings for the decoder. This contains settings for the PNG and the Zlib Settings for the decoder. This contains settings for the PNG and the Zlib
decoder, but not the Info settings from the Info structs. decoder, but not the Info settings from the Info structs.
@ -528,7 +468,7 @@ typedef struct LodePNGDecoderSettings
unsigned color_convert; /*whether to convert the PNG to the color type you want. Default: yes*/ unsigned color_convert; /*whether to convert the PNG to the color type you want. Default: yes*/
#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS #if defined(LODEPNG_COMPILE_ANCILLARY_CHUNKS)
unsigned read_text_chunks; /*if false but remember_unknown_chunks is true, they're stored in the unknown chunks*/ unsigned read_text_chunks; /*if false but remember_unknown_chunks is true, they're stored in the unknown chunks*/
/*store all bytes from unknown chunks in the LodePNGInfo (off by default, useful for a png editor)*/ /*store all bytes from unknown chunks in the LodePNGInfo (off by default, useful for a png editor)*/
unsigned remember_unknown_chunks; unsigned remember_unknown_chunks;
@ -538,7 +478,7 @@ typedef struct LodePNGDecoderSettings
void lodepng_decoder_settings_init(LodePNGDecoderSettings* settings); void lodepng_decoder_settings_init(LodePNGDecoderSettings* settings);
#endif /*LODEPNG_COMPILE_DECODER*/ #endif /*LODEPNG_COMPILE_DECODER*/
#ifdef LODEPNG_COMPILE_ENCODER #if defined(LODEPNG_COMPILE_ENCODER)
/*automatically use color type with less bits per pixel if losslessly possible. Default: AUTO*/ /*automatically use color type with less bits per pixel if losslessly possible. Default: AUTO*/
typedef enum LodePNGFilterStrategy typedef enum LodePNGFilterStrategy
{ {
@ -609,7 +549,7 @@ typedef struct LodePNGEncoderSettings
/*force creating a PLTE chunk if colortype is 2 or 6 (= a suggested palette). /*force creating a PLTE chunk if colortype is 2 or 6 (= a suggested palette).
If colortype is 3, PLTE is _always_ created.*/ If colortype is 3, PLTE is _always_ created.*/
unsigned force_palette; unsigned force_palette;
#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS #if defined(LODEPNG_COMPILE_ANCILLARY_CHUNKS)
/*add LodePNG identifier and version as a text chunk, for debugging*/ /*add LodePNG identifier and version as a text chunk, for debugging*/
unsigned add_id; unsigned add_id;
/*encode text chunks as zTXt chunks instead of tEXt chunks, and use compression in iTXt chunks*/ /*encode text chunks as zTXt chunks instead of tEXt chunks, and use compression in iTXt chunks*/
@ -625,19 +565,15 @@ void lodepng_encoder_settings_init(LodePNGEncoderSettings* settings);
/*The settings, state and information for extended encoding and decoding.*/ /*The settings, state and information for extended encoding and decoding.*/
typedef struct LodePNGState typedef struct LodePNGState
{ {
#ifdef LODEPNG_COMPILE_DECODER #if defined(LODEPNG_COMPILE_DECODER)
LodePNGDecoderSettings decoder; /*the decoding settings*/ LodePNGDecoderSettings decoder; /*the decoding settings*/
#endif /*LODEPNG_COMPILE_DECODER*/ #endif /*LODEPNG_COMPILE_DECODER*/
#ifdef LODEPNG_COMPILE_ENCODER #if defined(LODEPNG_COMPILE_ENCODER)
LodePNGEncoderSettings encoder; /*the encoding settings*/ LodePNGEncoderSettings encoder; /*the encoding settings*/
#endif /*LODEPNG_COMPILE_ENCODER*/ #endif /*LODEPNG_COMPILE_ENCODER*/
LodePNGColorMode info_raw; /*specifies the format in which you would like to get the raw pixel buffer*/ LodePNGColorMode info_raw; /*specifies the format in which you would like to get the raw pixel buffer*/
LodePNGInfo info_png; /*info of the PNG image obtained after decoding*/ LodePNGInfo info_png; /*info of the PNG image obtained after decoding*/
unsigned error; unsigned error;
#ifdef LODEPNG_COMPILE_CPP
/* For the lodepng::State subclass. */
virtual ~LodePNGState() {}
#endif
} LodePNGState; } LodePNGState;
/*init, cleanup and copy functions to use with this struct*/ /*init, cleanup and copy functions to use with this struct*/
@ -646,7 +582,7 @@ void lodepng_state_cleanup(LodePNGState* state);
void lodepng_state_copy(LodePNGState* dest, const LodePNGState* source); void lodepng_state_copy(LodePNGState* dest, const LodePNGState* source);
#endif /* defined(LODEPNG_COMPILE_DECODER) || defined(LODEPNG_COMPILE_ENCODER) */ #endif /* defined(LODEPNG_COMPILE_DECODER) || defined(LODEPNG_COMPILE_ENCODER) */
#ifdef LODEPNG_COMPILE_DECODER #if defined(LODEPNG_COMPILE_DECODER)
/* /*
Same as lodepng_decode_memory, but uses a LodePNGState to allow custom settings and Same as lodepng_decode_memory, but uses a LodePNGState to allow custom settings and
getting much more information about the PNG image and color mode. getting much more information about the PNG image and color mode.
@ -666,7 +602,7 @@ unsigned lodepng_inspect(unsigned* w, unsigned* h,
#endif /*LODEPNG_COMPILE_DECODER*/ #endif /*LODEPNG_COMPILE_DECODER*/
#ifdef LODEPNG_COMPILE_ENCODER #if defined(LODEPNG_COMPILE_ENCODER)
/*This function allocates the out buffer with standard malloc and stores the size in *outsize.*/ /*This function allocates the out buffer with standard malloc and stores the size in *outsize.*/
unsigned lodepng_encode(uint8_t** out, size_t* outsize, unsigned lodepng_encode(uint8_t** out, size_t* outsize,
const uint8_t* image, unsigned w, unsigned h, const uint8_t* image, unsigned w, unsigned h,
@ -743,14 +679,14 @@ unsigned lodepng_crc32(const uint8_t* buf, size_t len);
#endif /*LODEPNG_COMPILE_PNG*/ #endif /*LODEPNG_COMPILE_PNG*/
#ifdef LODEPNG_COMPILE_ZLIB #if defined(LODEPNG_COMPILE_ZLIB)
/* /*
This zlib part can be used independently to zlib compress and decompress a This zlib part can be used independently to zlib compress and decompress a
buffer. It cannot be used to create gzip files however, and it only supports the buffer. It cannot be used to create gzip files however, and it only supports the
part of zlib that is required for PNG, it does not support dictionaries. part of zlib that is required for PNG, it does not support dictionaries.
*/ */
#ifdef LODEPNG_COMPILE_DECODER #if defined(LODEPNG_COMPILE_DECODER)
/*Inflate a buffer. Inflate is the decompression step of deflate. Out buffer must be freed after use.*/ /*Inflate a buffer. Inflate is the decompression step of deflate. Out buffer must be freed after use.*/
unsigned lodepng_inflate(uint8_t** out, size_t* outsize, unsigned lodepng_inflate(uint8_t** out, size_t* outsize,
const uint8_t* in, size_t insize, const uint8_t* in, size_t insize,
@ -767,7 +703,7 @@ unsigned lodepng_zlib_decompress(uint8_t** out, size_t* outsize,
const LodePNGDecompressSettings* settings); const LodePNGDecompressSettings* settings);
#endif /*LODEPNG_COMPILE_DECODER*/ #endif /*LODEPNG_COMPILE_DECODER*/
#ifdef LODEPNG_COMPILE_ENCODER #if defined(LODEPNG_COMPILE_ENCODER)
/* /*
Compresses data with Zlib. Reallocates the out buffer and appends the data. Compresses data with Zlib. Reallocates the out buffer and appends the data.
Zlib adds a small header and trailer around the deflate data. Zlib adds a small header and trailer around the deflate data.
@ -794,7 +730,7 @@ unsigned lodepng_deflate(uint8_t** out, size_t* outsize,
#endif /*LODEPNG_COMPILE_ENCODER*/ #endif /*LODEPNG_COMPILE_ENCODER*/
#endif /*LODEPNG_COMPILE_ZLIB*/ #endif /*LODEPNG_COMPILE_ZLIB*/
#ifdef LODEPNG_COMPILE_DISK #if defined(LODEPNG_COMPILE_DISK)
/* /*
Load a file from disk into buffer. The function allocates the out buffer, and Load a file from disk into buffer. The function allocates the out buffer, and
after usage you should free it. after usage you should free it.
@ -816,79 +752,6 @@ return value: error code (0 means ok)
unsigned lodepng_save_file(const uint8_t* buffer, size_t buffersize, const char* filename); unsigned lodepng_save_file(const uint8_t* buffer, size_t buffersize, const char* filename);
#endif /*LODEPNG_COMPILE_DISK*/ #endif /*LODEPNG_COMPILE_DISK*/
#ifdef LODEPNG_COMPILE_CPP
/* The LodePNG C++ wrapper uses std::vectors instead of manually allocated memory buffers. */
namespace lodepng
{
#ifdef LODEPNG_COMPILE_PNG
class State : public LodePNGState
{
public:
State();
State(const State& other);
virtual ~State();
State& operator=(const State& other);
};
#ifdef LODEPNG_COMPILE_DECODER
/* Same as other lodepng::decode, but using a State for more settings and information. */
unsigned decode(std::vector<uint8_t>& out, unsigned& w, unsigned& h,
State& state,
const uint8_t* in, size_t insize);
unsigned decode(std::vector<uint8_t>& out, unsigned& w, unsigned& h,
State& state,
const std::vector<uint8_t>& in);
#endif /*LODEPNG_COMPILE_DECODER*/
#ifdef LODEPNG_COMPILE_ENCODER
/* Same as other lodepng::encode, but using a State for more settings and information. */
unsigned encode(std::vector<uint8_t>& out,
const uint8_t* in, unsigned w, unsigned h,
State& state);
unsigned encode(std::vector<uint8_t>& out,
const std::vector<uint8_t>& in, unsigned w, unsigned h,
State& state);
#endif /*LODEPNG_COMPILE_ENCODER*/
#ifdef LODEPNG_COMPILE_DISK
/*
Load a file from disk into an std::vector.
return value: error code (0 means ok)
*/
unsigned load_file(std::vector<uint8_t>& buffer, const std::string& filename);
/*
Save the binary data in an std::vector to a file on disk. The file is overwritten
without warning.
*/
unsigned save_file(const std::vector<uint8_t>& buffer, const std::string& filename);
#endif /* LODEPNG_COMPILE_DISK */
#endif /* LODEPNG_COMPILE_PNG */
#ifdef LODEPNG_COMPILE_ZLIB
#ifdef LODEPNG_COMPILE_DECODER
/* Zlib-decompress an uint8_t buffer */
unsigned decompress(std::vector<uint8_t>& out, const uint8_t* in, size_t insize,
const LodePNGDecompressSettings& settings = lodepng_default_decompress_settings);
/* Zlib-decompress an std::vector */
unsigned decompress(std::vector<uint8_t>& out, const std::vector<uint8_t>& in,
const LodePNGDecompressSettings& settings = lodepng_default_decompress_settings);
#endif /* LODEPNG_COMPILE_DECODER */
#ifdef LODEPNG_COMPILE_ENCODER
/* Zlib-compress an uint8_t buffer */
unsigned compress(std::vector<uint8_t>& out, const uint8_t* in, size_t insize,
const LodePNGCompressSettings& settings = lodepng_default_compress_settings);
/* Zlib-compress an std::vector */
unsigned compress(std::vector<uint8_t>& out, const std::vector<uint8_t>& in,
const LodePNGCompressSettings& settings = lodepng_default_compress_settings);
#endif /* LODEPNG_COMPILE_ENCODER */
#endif /* LODEPNG_COMPILE_ZLIB */
} /* namespace lodepng */
#endif /*LODEPNG_COMPILE_CPP*/
/* /*
TODO: TODO:
[.] test if there are no memory leaks or security exploits - done a lot but needs to be checked often [.] test if there are no memory leaks or security exploits - done a lot but needs to be checked often
@ -906,7 +769,7 @@ TODO:
[ ] allow user to give data (void*) to custom allocator [ ] allow user to give data (void*) to custom allocator
*/ */
#endif /*LODEPNG_H inclusion guard*/ #endif
/* /*
LodePNG Documentation LodePNG Documentation
@ -1036,8 +899,9 @@ The C++ version has extra functions with std::vectors in the interface and the
lodepng::State class which is a LodePNGState with constructor and destructor. lodepng::State class which is a LodePNGState with constructor and destructor.
These files work without modification for both C and C++ compilers because all These files work without modification for both C and C++ compilers because all
the additional C++ code is in "#ifdef __cplusplus" blocks that make C-compilers the additional C++ code is in "#if defined(__cplusplus" blocks that make
ignore it, and the C code is made to compile both with strict ISO C90 and C++. C-compilers) ignore it, and the C code is made to compile both with strict ISO
C90 and C++.
To use the C++ version, you need to rename the source file to lodepng.cpp To use the C++ version, you need to rename the source file to lodepng.cpp
(instead of lodepng.c), and compile it with a C++ compiler. (instead of lodepng.c), and compile it with a C++ compiler.

View File

@ -21,7 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#include "quakedef.h" #include "q_defs.h"
#include <SDL.h> #include <SDL.h>
#include <stdio.h> #include <stdio.h>
@ -43,23 +43,17 @@ static void Sys_InitSDL(void)
SDL_version *sdl_version = &v; SDL_version *sdl_version = &v;
SDL_GetVersion(&v); SDL_GetVersion(&v);
Sys_Printf("Found SDL version %" PRIi32 ".%" PRIi32 ".%" PRIi32 "\n", sdl_version->major, sdl_version->minor, sdl_version->patch); Sys_Printf("SDL version %" PRIi32 ".%" PRIi32 ".%" PRIi32 "\n", sdl_version->major, sdl_version->minor, sdl_version->patch);
if(SDL_VERSIONNUM(sdl_version->major, sdl_version->minor, sdl_version->patch) < SDL_REQUIREDVERSION) if(SDL_VERSIONNUM(sdl_version->major, sdl_version->minor, sdl_version->patch) < SDL_REQUIREDVERSION)
{ Sys_Error("Need at least v%" PRIi32 ".%" PRIi32 ".%" PRIi32 " of SDL to run. Exiting.", SDL_MIN_X, SDL_MIN_Y, SDL_MIN_Z);
/*reject running under older SDL versions */
Sys_Error("You need at least v%" PRIi32 ".%" PRIi32 ".%" PRIi32 " of SDL to run this game.", SDL_MIN_X, SDL_MIN_Y, SDL_MIN_Z);
}
if(SDL_VERSIONNUM(sdl_version->major, sdl_version->minor, sdl_version->patch) >= SDL_NEW_VERSION_REJECT) if(SDL_VERSIONNUM(sdl_version->major, sdl_version->minor, sdl_version->patch) >= SDL_NEW_VERSION_REJECT)
{ Sys_Error("Detected SDL is too new. Exiting.");
/*reject running under newer (1.3.x) SDL */
Sys_Error("Your version of SDL library is incompatible with me.\n"
"You need a library version in the line of %" PRIi32 ".%" PRIi32 ".%" PRIi32 "\n", SDL_MIN_X, SDL_MIN_Y, SDL_MIN_Z);
}
if(SDL_Init(0) < 0) if(SDL_Init(0) < 0)
{
Sys_Error("Couldn't init SDL: %s", SDL_GetError()); Sys_Error("Couldn't init SDL: %s", SDL_GetError());
}
atexit(Sys_AtExit); atexit(Sys_AtExit);
} }
@ -69,7 +63,7 @@ static quakeparms_t parms;
// On OS X we call SDL_main from the launcher, but SDL2 doesn't redefine main // On OS X we call SDL_main from the launcher, but SDL2 doesn't redefine main
// as SDL_main on OS X anymore, so we do it ourselves. // as SDL_main on OS X anymore, so we do it ourselves.
#if defined(__APPLE__) #if PLATFORM_IS(OSX)
#define main SDL_main #define main SDL_main
#endif #endif
@ -105,14 +99,12 @@ int32_t main(int32_t argc, char *argv[])
parms.membase = malloc(parms.memsize); parms.membase = malloc(parms.memsize);
if(!parms.membase) if(!parms.membase)
Sys_Error("Not enough memory free; check disk space\n"); Sys_Error("Not enough memory free for heap. You need 256MiB.\n");
Sys_Printf("Quake " VERSION " (c) id Software\n"); Sys_Printf(ENGINE_NAME " " VERSION " (c) id Software, John Fitzgibbons, "
Sys_Printf("FitzQuake " FITZQUAKE_VERSION " (c) John Fitzgibbons\n"); "SleepwalkR, Baker, Ozkan Sezer, Eric Wasylishen, "
Sys_Printf("FitzQuake SDL port (c) SleepwalkR, Baker\n"); "Alison Watson, et al.\n");
Sys_Printf("QuakeSpasm " QUAKESPASM_VERSION " (c) Ozkan Sezer, Eric Wasylishen & others\n");
Sys_Printf("Host_Init\n");
Host_Init(); Host_Init();
oldtime = Sys_DoubleTime(); oldtime = Sys_DoubleTime();

View File

@ -22,15 +22,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
// mathlib.c -- math primitives // mathlib.c -- math primitives
#include "quakedef.h" #include "q_defs.h"
vec3_t vec3_origin = {0, 0, 0}; vec3_t vec3_origin = {0, 0, 0};
/*-----------------------------------------------------------------*/ /*-----------------------------------------------------------------*/
//#define DEG2RAD( a ) ( a * M_PI ) / 180.0F #define DEG2RAD( a ) ( (a) * PI_DIV_180 ) //johnfitz
#define DEG2RAD( a ) ( (a) * M_PI_DIV_180 ) //johnfitz
void ProjectPointOnPlane(vec3_t dst, const vec3_t p, const vec3_t normal) void ProjectPointOnPlane(vec3_t dst, const vec3_t p, const vec3_t normal)
{ {
@ -202,7 +201,7 @@ int32_t BoxOnPlaneSide(vec3_t emins, vec3_t emaxs, mplane_t *p)
if(dist2 < p->dist) if(dist2 < p->dist)
sides |= 2; sides |= 2;
#ifdef PARANOID #if defined(PARANOID)
if(sides == 0) if(sides == 0)
Sys_Error("BoxOnPlaneSide: sides==0"); Sys_Error("BoxOnPlaneSide: sides==0");
#endif #endif
@ -219,8 +218,8 @@ void VectorAngles(const vec3_t forward, vec3_t angles)
temp[0] = forward[0]; temp[0] = forward[0];
temp[1] = forward[1]; temp[1] = forward[1];
temp[2] = 0; temp[2] = 0;
angles[PITCH] = -atan2(forward[2], VectorLength(temp)) / M_PI_DIV_180; angles[PITCH] = -atan2(forward[2], VectorLength(temp)) / PI_DIV_180;
angles[YAW] = atan2(forward[1], forward[0]) / M_PI_DIV_180; angles[YAW] = atan2(forward[1], forward[0]) / PI_DIV_180;
angles[ROLL] = 0; angles[ROLL] = 0;
} }
@ -229,13 +228,13 @@ void AngleVectors(vec3_t angles, vec3_t forward, vec3_t right, vec3_t up)
float angle; float angle;
float sr, sp, sy, cr, cp, cy; float sr, sp, sy, cr, cp, cy;
angle = angles[YAW] * (M_PI * 2 / 360); angle = angles[YAW] * (PI * 2 / 360);
sy = sin(angle); sy = sin(angle);
cy = cos(angle); cy = cos(angle);
angle = angles[PITCH] * (M_PI * 2 / 360); angle = angles[PITCH] * (PI * 2 / 360);
sp = sin(angle); sp = sin(angle);
cp = cos(angle); cp = cos(angle);
angle = angles[ROLL] * (M_PI * 2 / 360); angle = angles[ROLL] * (PI * 2 / 360);
sr = sin(angle); sr = sin(angle);
cr = cos(angle); cr = cos(angle);
@ -427,7 +426,7 @@ void FloorDivMod(double numer, double denom, int32_t *quotient,
int32_t q, r; int32_t q, r;
double x; double x;
#ifndef PARANOID #if !defined(PARANOID)
if(denom <= 0.0) if(denom <= 0.0)
Sys_Error("FloorDivMod: bad denominator %f\n", denom); Sys_Error("FloorDivMod: bad denominator %f\n", denom);

View File

@ -21,18 +21,15 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#ifndef __MATHLIB_H #ifndef spingle__mathlib_h
#define __MATHLIB_H #define spingle__mathlib_h
// mathlib.h // mathlib.h
#include <math.h> #include <math.h>
#ifndef M_PI #define PI 3.14159265358979323846
#define M_PI 3.14159265358979323846 // matches value in gcc v2 math.h #define PI_DIV_180 (PI / 180.0) //johnfitz
#endif
#define M_PI_DIV_180 (M_PI / 180.0) //johnfitz
struct mplane_s; struct mplane_s;
@ -106,21 +103,11 @@ int32_t BoxOnPlaneSide(vec3_t emins, vec3_t emaxs, struct mplane_s *plane);
float anglemod(float a); float anglemod(float a);
#define BOX_ON_PLANE_SIDE(emins, emaxs, p) \ #define BOX_ON_PLANE_SIDE(emins, emaxs, p) \
(((p)->type < 3)? \ (((p)->type < 3) \
( \ ? (((p)->dist <= (emins)[(p)->type]) \
((p)->dist <= (emins)[(p)->type])? \ ? 1 \
1 \ : (((p)->dist >= (emaxs)[(p)->type]) ? 2 : 3)) \
: \ : BoxOnPlaneSide((emins), (emaxs), (p)))
( \
((p)->dist >= (emaxs)[(p)->type])?\
2 \
: \
3 \
) \
) \
: \
BoxOnPlaneSide( (emins), (emaxs), (p)))
#endif /* __MATHLIB_H */
#endif

View File

@ -20,7 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#include "quakedef.h" #include "q_defs.h"
#include "bgmusic.h" #include "bgmusic.h"
void (*vid_menucmdfn)(void); //johnfitz void (*vid_menucmdfn)(void); //johnfitz
@ -988,10 +988,7 @@ enum
OPT_ALWAYSMLOOK, OPT_ALWAYSMLOOK,
OPT_LOOKSPRING, OPT_LOOKSPRING,
OPT_LOOKSTRAFE, OPT_LOOKSTRAFE,
//#ifdef _WIN32 OPT_VIDEO, // This is the last before OPTIONS_ITEMS
// OPT_USEMOUSE,
//#endif
OPT_VIDEO, // This is the last before OPTIONS_ITEMS
OPTIONS_ITEMS OPTIONS_ITEMS
}; };
@ -1680,10 +1677,10 @@ bool M_Quit_TextEntry(void)
} }
void M_Quit_Draw(void) //johnfitz -- modified for new quit message void M_Quit_Draw(void)
{ {
static char const msg1[] = "QuakeSpasm " QUAKESPASM_VERSION; static char const msg1[] = ENGINE_NAME " " VERSION;
static char const msg2[] = "by Ozkan, Ericw & Stevenaaus"; static char const msg2[] = "FIXME: make this customizable";
static char const msg3[] = "Press y to quit"; static char const msg3[] = "Press y to quit";
int32_t boxlen; int32_t boxlen;

View File

@ -20,8 +20,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#ifndef _QUAKE_MENU_H #ifndef spingle__menu_h
#define _QUAKE_MENU_H #define spingle__menu_h
enum m_state_e enum m_state_e
{ {
@ -72,5 +72,4 @@ void M_DrawPic(int32_t x, int32_t y, qpic_t *pic);
void M_DrawTransPic(int32_t x, int32_t y, qpic_t *pic); void M_DrawTransPic(int32_t x, int32_t y, qpic_t *pic);
void M_DrawCheckbox(int32_t x, int32_t y, int32_t on); void M_DrawCheckbox(int32_t x, int32_t y, int32_t on);
#endif /* _QUAKE_MENU_H */ #endif

View File

@ -19,8 +19,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#ifndef _MODELGEN_H #ifndef spingle__modelgen_h
#define _MODELGEN_H #define spingle__modelgen_h
// //
// modelgen.h: header file for model generation program // modelgen.h: header file for model generation program
@ -32,31 +32,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
// * pass data from one to the other via model files. * // * pass data from one to the other via model files. *
// ********************************************************* // *********************************************************
#ifdef INCLUDELIBS
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include "cmdlib.h"
#include "scriplib.h"
#include "trilib.h"
#include "lbmlib.h"
#include "mathlib.h"
#endif
#define ALIAS_VERSION 6 #define ALIAS_VERSION 6
#define ALIAS_ONSEAM 0x0020 #define ALIAS_ONSEAM 0x0020
// must match definition in spritegn.h
#ifndef SYNCTYPE_T
#define SYNCTYPE_T
typedef enum {ST_SYNC = 0, ST_RAND } synctype_t;
#endif
typedef enum { ALIAS_SINGLE = 0, ALIAS_GROUP } aliasframetype_t; typedef enum { ALIAS_SINGLE = 0, ALIAS_GROUP } aliasframetype_t;
typedef enum { ALIAS_SKIN_SINGLE = 0, ALIAS_SKIN_GROUP } aliasskintype_t; typedef enum { ALIAS_SKIN_SINGLE = 0, ALIAS_SKIN_GROUP } aliasskintype_t;
@ -148,5 +127,4 @@ typedef struct
#define IDPOLYHEADER (('O'<<24)+('P'<<16)+('D'<<8)+'I') #define IDPOLYHEADER (('O'<<24)+('P'<<16)+('D'<<8)+'I')
// little-endian "IDPO" // little-endian "IDPO"
#endif /* _MODELGEN_H */ #endif

View File

@ -28,8 +28,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
whole engine whole engine
*/ */
#ifndef _QUAKE_NET_H #ifndef spingle__quake_net_h
#define _QUAKE_NET_H #define spingle__quake_net_h
#define NET_NAMELEN 64 #define NET_NAMELEN 64
@ -111,5 +111,4 @@ extern bool tcpipAvailable;
extern char my_ipx_address[NET_NAMELEN]; extern char my_ipx_address[NET_NAMELEN];
extern char my_tcpip_address[NET_NAMELEN]; extern char my_tcpip_address[NET_NAMELEN];
#endif /* _QUAKE_NET_H */ #endif

View File

@ -21,8 +21,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
#ifndef __NET_DEFS_H #ifndef spingle__net_defs_h
#define __NET_DEFS_H #define spingle__net_defs_h
struct qsockaddr struct qsockaddr
{ {
@ -256,5 +256,4 @@ typedef struct _PollProcedure
void SchedulePollProcedure(PollProcedure *pp, double timeOffset); void SchedulePollProcedure(PollProcedure *pp, double timeOffset);
#endif /* __NET_DEFS_H */ #endif

View File

@ -23,9 +23,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define BAN_TEST #define BAN_TEST
#include "q_stdinc.h" #include "q_stdinc.h"
#include "arch_def.h"
#include "net_sys.h" #include "net_sys.h"
#include "quakedef.h" #include "q_defs.h"
#include "net_defs.h" #include "net_defs.h"
#include "net_dgrm.h" #include "net_dgrm.h"
@ -68,7 +67,7 @@ static char *StrAddr(struct qsockaddr *addr)
} }
#ifdef BAN_TEST #if defined(BAN_TEST)
static struct in_addr banAddr; static struct in_addr banAddr;
static struct in_addr banMask; static struct in_addr banMask;
@ -135,7 +134,7 @@ int32_t Datagram_SendMessage(qsocket_t *sock, sizebuf_t *data)
uint32_t dataLen; uint32_t dataLen;
uint32_t eom; uint32_t eom;
#ifdef DEBUG #if defined(DEBUG)
if(data->cursize == 0) if(data->cursize == 0)
Sys_Error("Datagram_SendMessage: zero length message\n"); Sys_Error("Datagram_SendMessage: zero length message\n");
@ -262,7 +261,7 @@ int32_t Datagram_SendUnreliableMessage(qsocket_t *sock, sizebuf_t *data)
{ {
int32_t packetLen; int32_t packetLen;
#ifdef DEBUG #if defined(DEBUG)
if(data->cursize == 0) if(data->cursize == 0)
Sys_Error("Datagram_SendUnreliableMessage: zero length message\n"); Sys_Error("Datagram_SendUnreliableMessage: zero length message\n");
@ -788,7 +787,7 @@ int32_t Datagram_Init(void)
int32_t i, num_inited; int32_t i, num_inited;
sys_socket_t csock; sys_socket_t csock;
#ifdef BAN_TEST #if defined(BAN_TEST)
banAddr.s_addr = INADDR_ANY; banAddr.s_addr = INADDR_ANY;
banMask.s_addr = INADDR_NONE; banMask.s_addr = INADDR_NONE;
#endif #endif
@ -813,7 +812,7 @@ int32_t Datagram_Init(void)
if(num_inited == 0) if(num_inited == 0)
return -1; return -1;
#ifdef BAN_TEST #if defined(BAN_TEST)
Cmd_AddCommand("ban", NET_Ban_f); Cmd_AddCommand("ban", NET_Ban_f);
#endif #endif
Cmd_AddCommand("test", Test_f); Cmd_AddCommand("test", Test_f);
@ -1001,7 +1000,7 @@ static qsocket_t *_Datagram_CheckNewConnections(void)
return NULL; return NULL;
} }
#ifdef BAN_TEST #if defined(BAN_TEST)
// check for a ban // check for a ban
if(clientaddr.qsa_family == AF_INET) if(clientaddr.qsa_family == AF_INET)
{ {

View File

@ -19,8 +19,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#ifndef __NET_DATAGRAM_H #ifndef spingle__net_dgrm_h
#define __NET_DATAGRAM_H #define spingle__net_dgrm_h
int32_t Datagram_Init(void); int32_t Datagram_Init(void);
void Datagram_Listen(bool state); void Datagram_Listen(bool state);
@ -35,5 +35,4 @@ bool Datagram_CanSendUnreliableMessage(qsocket_t *sock);
void Datagram_Close(qsocket_t *sock); void Datagram_Close(qsocket_t *sock);
void Datagram_Shutdown(void); void Datagram_Shutdown(void);
#endif /* __NET_DATAGRAM_H */ #endif

View File

@ -20,9 +20,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#include "q_stdinc.h" #include "q_stdinc.h"
#include "arch_def.h"
#include "net_sys.h" #include "net_sys.h"
#include "quakedef.h" #include "q_defs.h"
#include "net_defs.h" #include "net_defs.h"
#include "net_loop.h" #include "net_loop.h"

View File

@ -19,8 +19,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#ifndef __NET_LOOP_H #ifndef spingle__net_loop_h
#define __NET_LOOP_H #define spingle__net_loop_h
// net_loop.h // net_loop.h
int32_t Loop_Init(void); int32_t Loop_Init(void);
@ -36,5 +36,4 @@ bool Loop_CanSendUnreliableMessage(qsocket_t *sock);
void Loop_Close(qsocket_t *sock); void Loop_Close(qsocket_t *sock);
void Loop_Shutdown(void); void Loop_Shutdown(void);
#endif /* __NET_LOOP_H */ #endif

View File

@ -20,9 +20,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#include "q_stdinc.h" #include "q_stdinc.h"
#include "arch_def.h"
#include "net_sys.h" #include "net_sys.h"
#include "quakedef.h" #include "q_defs.h"
#include "net_defs.h" #include "net_defs.h"
qsocket_t *net_activeSockets = NULL; qsocket_t *net_activeSockets = NULL;

View File

@ -1,7 +1,5 @@
/* /*
* net_sys.h -- common network system header. * net_sys.h -- common network system header.
* - depends on arch_def.h
* - may depend on q_stdinc.h
* *
* Copyright (C) 2007-2012 O.Sezer <sezero@users.sourceforge.net> * Copyright (C) 2007-2012 O.Sezer <sezero@users.sourceforge.net>
* *
@ -21,17 +19,15 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
#ifndef __NET_SYS_H__ #ifndef spingle__net_sys_h
#define __NET_SYS_H__ #define spingle__net_sys_h
#include <sys/types.h> #include <sys/types.h>
#include <errno.h> #include <errno.h>
#include <stddef.h> #include <stddef.h>
#include <limits.h> #include <limits.h>
#if defined(PLATFORM_BSD) || defined(PLATFORM_OSX) || \ #if PLATFORM_IS(BSD) || PLATFORM_IS(OSX)
defined(PLATFORM_AMIGA) /* bsdsocket.library */ || \
defined(__GNU__) /* GNU/Hurd */ || defined(__riscos__)
/* struct sockaddr has uint8_t sa_len as the first member in BSD /* struct sockaddr has uint8_t sa_len as the first member in BSD
* variants and the family member is also an uint8_t instead of an * variants and the family member is also an uint8_t instead of an
* uint16_t. This should matter only when PLATFORM_UNIX is defined, * uint16_t. This should matter only when PLATFORM_UNIX is defined,
@ -47,14 +43,9 @@
#endif /* BSD, sockaddr */ #endif /* BSD, sockaddr */
/* unix includes and compatibility macros */ /* unix includes and compatibility macros */
#if defined(PLATFORM_UNIX) || defined(PLATFORM_RISCOS) #if PLATFORM_IS_UNIX
#include <sys/param.h> #include <sys/param.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#if defined(__sun) || defined(sun)
#include <sys/filio.h>
#include <sys/sockio.h>
#endif /* __sunos__ */
#include <unistd.h> #include <unistd.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <netinet/in.h> #include <netinet/in.h>
@ -78,55 +69,10 @@ typedef int32_t sys_socket_t;
_Static_assert(offsetof(struct sockaddr, sa_family) == SA_FAM_OFFSET, _Static_assert(offsetof(struct sockaddr, sa_family) == SA_FAM_OFFSET,
"HAVE_SA_LEN not defined correctly"); "HAVE_SA_LEN not defined correctly");
#endif /* PLATFORM_IS_UNIX */
#endif /* end of unix stuff */
/* amiga includes and compatibility macros */
#if defined(PLATFORM_AMIGA) /* Amiga bsdsocket.library */
#include <sys/param.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include <proto/exec.h>
#include <proto/socket.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
typedef int32_t sys_socket_t;
#define INVALID_SOCKET (-1)
#define SOCKET_ERROR (-1)
typedef uint32_t in_addr_t;
#define SOCKETERRNO Errno()
#define ioctlsocket IoctlSocket
#define closesocket CloseSocket
#define selectsocket(_N,_R,_W,_E,_T) \
WaitSelect((_N),(_R),(_W),(_E),(_T),NULL)
#define IOCTLARG_P(x) (char *) x
#if defined(__amigaos4__) || defined(PLATFORM_AMIGAOS3)
#define inet_ntoa(x) Inet_NtoA(x.s_addr) /* Inet_NtoA(*(ULONG*)&x) */
#define h_errno Errno()
#endif
#define NET_EWOULDBLOCK EWOULDBLOCK
#define NET_ECONNREFUSED ECONNREFUSED
#define socketerror(x) strerror((x))
/* there is h_errno but no hstrerror() */
#define hstrerror(x) strerror((x))
_Static_assert(offsetof(struct sockaddr, sa_family) == SA_FAM_OFFSET,
"HAVE_SA_LEN not defined correctly");
#endif /* end of amiga bsdsocket.library stuff */
/* windows includes and compatibility macros */ /* windows includes and compatibility macros */
#if defined(PLATFORM_WINDOWS) #if PLATFORM_IS(WINDOWS)
/* NOTE: winsock[2].h already includes windows.h */ /* NOTE: winsock[2].h already includes windows.h */
#if !defined(_USE_WINSOCK2) #if !defined(_USE_WINSOCK2)
@ -181,5 +127,4 @@ _Static_assert(offsetof(struct sockaddr, sa_family) == SA_FAM_OFFSET,
#endif /* MAXHOSTNAMELEN */ #endif /* MAXHOSTNAMELEN */
#endif /* __NET_SYS_H__ */ #endif

View File

@ -21,7 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#include "quakedef.h" #include "q_defs.h"
#include <SDL.h> #include <SDL.h>
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>

View File

@ -21,8 +21,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#ifndef _QUAKE_PLATFORM_H #ifndef spingle__platform_h
#define _QUAKE_PLATFORM_H #define spingle__platform_h
/* platform dependent way to set the window icon */ /* platform dependent way to set the window icon */
void PL_SetWindowIcon(void); void PL_SetWindowIcon(void);
@ -36,5 +36,4 @@ char *PL_GetClipboardData(void);
/* show an error dialog */ /* show an error dialog */
void PL_ErrorDialog(const char *text); void PL_ErrorDialog(const char *text);
#endif /* _QUAKE_PLATFORM_H */ #endif

View File

@ -20,7 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#include "quakedef.h" #include "q_defs.h"
#define STRINGTEMP_BUFFERS 16 #define STRINGTEMP_BUFFERS 16
#define STRINGTEMP_LENGTH 1024 #define STRINGTEMP_LENGTH 1024
@ -192,7 +192,7 @@ static void SetMinMaxSize(edict_t *e, float *minvec, float *maxvec, bool rotate)
// find min / max for rotations // find min / max for rotations
angles = e->v.angles; angles = e->v.angles;
a = angles[1] / 180 * M_PI; a = angles[1] / 180 * PI;
xvector[0] = cos(a); xvector[0] = cos(a);
xvector[1] = sin(a); xvector[1] = sin(a);
@ -455,7 +455,7 @@ static void PF_vectoyaw(void)
yaw = 0; yaw = 0;
else else
{ {
yaw = (int32_t)(atan2(value1[1], value1[0]) * 180 / M_PI); yaw = (int32_t)(atan2(value1[1], value1[0]) * 180 / PI);
if(yaw < 0) if(yaw < 0)
yaw += 360; yaw += 360;
} }
@ -489,12 +489,12 @@ static void PF_vectoangles(void)
} }
else else
{ {
yaw = (int32_t)(atan2(value1[1], value1[0]) * 180 / M_PI); yaw = (int32_t)(atan2(value1[1], value1[0]) * 180 / PI);
if(yaw < 0) if(yaw < 0)
yaw += 360; yaw += 360;
forward = sqrt(value1[0] * value1[0] + value1[1] * value1[1]); forward = sqrt(value1[0] * value1[0] + value1[1] * value1[1]);
pitch = (int32_t)(atan2(value1[2], forward) * 180 / M_PI); pitch = (int32_t)(atan2(value1[2], forward) * 180 / PI);
if(pitch < 0) if(pitch < 0)
pitch += 360; pitch += 360;
} }
@ -1175,7 +1175,7 @@ static void PF_walkmove(void)
return; return;
} }
yaw = yaw * M_PI * 2 / 360; yaw = yaw * PI * 2 / 360;
move[0] = cos(yaw) * dist; move[0] = cos(yaw) * dist;
move[1] = sin(yaw) * dist; move[1] = sin(yaw) * dist;

View File

@ -19,8 +19,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#ifndef __PR_COMP_H #ifndef spingle__pr_comp_h
#define __PR_COMP_H #define spingle__pr_comp_h
// this file is shared by quake and qcc // this file is shared by quake and qcc
@ -40,17 +40,16 @@ typedef enum
ev_pointer ev_pointer
} etype_t; } etype_t;
#define OFS_NULL 0 #define OFS_NULL 0
#define OFS_RETURN 1 #define OFS_RETURN 1
#define OFS_PARM0 4 // leave 3 ofs for each parm to hold vectors #define OFS_PARM0 4 // leave 3 ofs for each parm to hold vectors
#define OFS_PARM1 7 #define OFS_PARM1 7
#define OFS_PARM2 10 #define OFS_PARM2 10
#define OFS_PARM3 13 #define OFS_PARM3 13
#define OFS_PARM4 16 #define OFS_PARM4 16
#define OFS_PARM5 19 #define OFS_PARM5 19
#define OFS_PARM6 22 #define OFS_PARM6 22
#define OFS_PARM7 25 #define OFS_PARM7 25
#define RESERVED_OFS 28
enum enum
@ -193,5 +192,4 @@ typedef struct
int32_t entityfields; int32_t entityfields;
} dprograms_t; } dprograms_t;
#endif /* __PR_COMP_H */ #endif

View File

@ -21,7 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
// sv_edict.c -- entity dictionary // sv_edict.c -- entity dictionary
#include "quakedef.h" #include "q_defs.h"
dprograms_t *progs; dprograms_t *progs;
dfunction_t *pr_functions; dfunction_t *pr_functions;
@ -775,13 +775,13 @@ returns false if error
*/ */
static bool ED_ParseEpair(void *base, ddef_t *key, const char *s) static bool ED_ParseEpair(void *base, ddef_t *key, const char *s)
{ {
int32_t i; int32_t i;
char string[128]; char string[128];
ddef_t *def; ddef_t *def;
char *v, *w; char *v, *w;
char *end; char *end;
void *d; void *d;
dfunction_t *func; dfunction_t *func;
d = (void *)((int32_t *)base + key->ofs); d = (void *)((int32_t *)base + key->ofs);

View File

@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#include "quakedef.h" #include "q_defs.h"
typedef struct typedef struct
{ {
@ -356,12 +356,12 @@ The interpretation main loop
void PR_ExecuteProgram(func_t fnum) void PR_ExecuteProgram(func_t fnum)
{ {
eval_t *ptr; eval_t *ptr;
dstatement_t *st; dstatement_t *st;
dfunction_t *f, *newf; dfunction_t *f, *newf;
int32_t profile, startprofile; int32_t profile, startprofile;
edict_t *ed; edict_t *ed;
int32_t exitdepth; int32_t exitdepth;
if(!fnum || fnum >= progs->numfunctions) if(!fnum || fnum >= progs->numfunctions)
{ {
@ -374,7 +374,7 @@ void PR_ExecuteProgram(func_t fnum)
pr_trace = false; pr_trace = false;
// make a stack frame // make a stack frame
exitdepth = pr_depth; exitdepth = pr_depth;
st = &pr_statements[PR_EnterFunction(f)]; st = &pr_statements[PR_EnterFunction(f)];
@ -382,7 +382,8 @@ void PR_ExecuteProgram(func_t fnum)
while(1) while(1)
{ {
st++; /* next statement */ /* next statement */
st++;
if(++profile > 100000) if(++profile > 100000)
{ {
@ -444,24 +445,12 @@ void PR_ExecuteProgram(func_t fnum)
OPC->_float = (int32_t)OPA->_float | (int32_t)OPB->_float; OPC->_float = (int32_t)OPA->_float | (int32_t)OPB->_float;
break; break;
case OP_GE: case OP_GE: OPC->_float = OPA->_float >= OPB->_float; break;
OPC->_float = OPA->_float >= OPB->_float; case OP_LE: OPC->_float = OPA->_float <= OPB->_float; break;
break; case OP_GT: OPC->_float = OPA->_float > OPB->_float; break;
case OP_LE: case OP_LT: OPC->_float = OPA->_float < OPB->_float; break;
OPC->_float = OPA->_float <= OPB->_float; case OP_AND: OPC->_float = OPA->_float && OPB->_float; break;
break; case OP_OR: OPC->_float = OPA->_float || OPB->_float; break;
case OP_GT:
OPC->_float = OPA->_float > OPB->_float;
break;
case OP_LT:
OPC->_float = OPA->_float < OPB->_float;
break;
case OP_AND:
OPC->_float = OPA->_float && OPB->_float;
break;
case OP_OR:
OPC->_float = OPA->_float || OPB->_float;
break;
case OP_NOT_F: case OP_NOT_F:
OPC->_float = !OPA->_float; OPC->_float = !OPA->_float;
@ -517,9 +506,9 @@ void PR_ExecuteProgram(func_t fnum)
case OP_STORE_F: case OP_STORE_F:
case OP_STORE_ENT: case OP_STORE_ENT:
case OP_STORE_FLD: // integers case OP_STORE_FLD:
case OP_STORE_S: case OP_STORE_S:
case OP_STORE_FNC: // pointers case OP_STORE_FNC:
OPB->_int = OPA->_int; OPB->_int = OPA->_int;
break; break;
case OP_STORE_V: case OP_STORE_V:
@ -545,7 +534,7 @@ void PR_ExecuteProgram(func_t fnum)
case OP_ADDRESS: case OP_ADDRESS:
ed = PROG_TO_EDICT(OPA->edict); ed = PROG_TO_EDICT(OPA->edict);
#ifdef PARANOID #if defined(PARANOID)
NUM_FOR_EDICT(ed); // Make sure it's in range NUM_FOR_EDICT(ed); // Make sure it's in range
#endif #endif
if(ed == (edict_t *)sv.edicts && sv.state == ss_active) if(ed == (edict_t *)sv.edicts && sv.state == ss_active)
@ -562,7 +551,7 @@ void PR_ExecuteProgram(func_t fnum)
case OP_LOAD_S: case OP_LOAD_S:
case OP_LOAD_FNC: case OP_LOAD_FNC:
ed = PROG_TO_EDICT(OPA->edict); ed = PROG_TO_EDICT(OPA->edict);
#ifdef PARANOID #if defined(PARANOID)
NUM_FOR_EDICT(ed); // Make sure it's in range NUM_FOR_EDICT(ed); // Make sure it's in range
#endif #endif
OPC->_int = ((eval_t *)((int32_t *)&ed->v + OPB->_int))->_int; OPC->_int = ((eval_t *)((int32_t *)&ed->v + OPB->_int))->_int;
@ -570,7 +559,7 @@ void PR_ExecuteProgram(func_t fnum)
case OP_LOAD_V: case OP_LOAD_V:
ed = PROG_TO_EDICT(OPA->edict); ed = PROG_TO_EDICT(OPA->edict);
#ifdef PARANOID #if defined(PARANOID)
NUM_FOR_EDICT(ed); // Make sure it's in range NUM_FOR_EDICT(ed); // Make sure it's in range
#endif #endif
ptr = (eval_t *)((int32_t *)&ed->v + OPB->_int); ptr = (eval_t *)((int32_t *)&ed->v + OPB->_int);
@ -579,19 +568,9 @@ void PR_ExecuteProgram(func_t fnum)
OPC->vector[2] = ptr->vector[2]; OPC->vector[2] = ptr->vector[2];
break; break;
case OP_IFNOT: case OP_IFNOT: if(!OPA->_int) st += st->b - 1; break;
if(!OPA->_int) case OP_IF: if(OPA->_int) st += st->b - 1; break;
st += st->b - 1; /* -1 to offset the st++ */ case OP_GOTO: st += st->a - 1; break;
break;
case OP_IF:
if(OPA->_int)
st += st->b - 1; /* -1 to offset the st++ */
break;
case OP_GOTO:
st += st->a - 1; /* -1 to offset the st++ */
break;
case OP_CALL0: case OP_CALL0:
case OP_CALL1: case OP_CALL1:
@ -649,7 +628,7 @@ void PR_ExecuteProgram(func_t fnum)
pr_xstatement = st - pr_statements; pr_xstatement = st - pr_statements;
PR_RunError("Bad opcode %" PRIi32 "", st->op); PR_RunError("Bad opcode %" PRIi32 "", st->op);
} }
} /* end of while(1) loop */ }
} }
#undef OPA #undef OPA
#undef OPB #undef OPB

View File

@ -19,10 +19,149 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#ifndef __PROGDEFS_H #ifndef spingle__progdefs_h
#define __PROGDEFS_H #define spingle__progdefs_h
#include "progdefs.q1" typedef struct
{
int32_t pad[28];
int32_t self;
int32_t other;
int32_t world;
float time;
float frametime;
float force_retouch;
string_t mapname;
float deathmatch;
float coop;
float teamplay;
float serverflags;
float total_secrets;
float total_monsters;
float found_secrets;
float killed_monsters;
float parm1;
float parm2;
float parm3;
float parm4;
float parm5;
float parm6;
float parm7;
float parm8;
float parm9;
float parm10;
float parm11;
float parm12;
float parm13;
float parm14;
float parm15;
float parm16;
vec3_t v_forward;
vec3_t v_up;
vec3_t v_right;
float trace_allsolid;
float trace_startsolid;
float trace_fraction;
vec3_t trace_endpos;
vec3_t trace_plane_normal;
float trace_plane_dist;
int32_t trace_ent;
float trace_inopen;
float trace_inwater;
int32_t msg_entity;
func_t main;
func_t StartFrame;
func_t PlayerPreThink;
func_t PlayerPostThink;
func_t ClientKill;
func_t ClientConnect;
func_t PutClientInServer;
func_t ClientDisconnect;
func_t SetNewParms;
func_t SetChangeParms;
} globalvars_t;
#endif /* __PROGDEFS_H */ typedef struct
{
float modelindex;
vec3_t absmin;
vec3_t absmax;
float ltime;
float movetype;
float solid;
vec3_t origin;
vec3_t oldorigin;
vec3_t velocity;
vec3_t angles;
vec3_t avelocity;
vec3_t punchangle;
string_t classname;
string_t model;
float frame;
float skin;
float effects;
vec3_t mins;
vec3_t maxs;
vec3_t size;
func_t touch;
func_t use;
func_t think;
func_t blocked;
float nextthink;
int32_t groundentity;
float health;
float frags;
float weapon;
string_t weaponmodel;
float weaponframe;
float currentammo;
float ammo_shells;
float ammo_nails;
float ammo_rockets;
float ammo_cells;
float items;
float takedamage;
int32_t chain;
float deadflag;
vec3_t view_ofs;
float button0;
float button1;
float button2;
float impulse;
float fixangle;
vec3_t v_angle;
float idealpitch;
string_t netname;
int32_t enemy;
float flags;
float colormap;
float team;
float max_health;
float teleport_time;
float armortype;
float armorvalue;
float waterlevel;
float watertype;
float ideal_yaw;
float yaw_speed;
int32_t aiment;
int32_t goalentity;
float spawnflags;
string_t target;
string_t targetname;
float dmg_take;
float dmg_save;
int32_t dmg_inflictor;
int32_t owner;
vec3_t movedir;
string_t message;
float sounds;
string_t noise;
string_t noise1;
string_t noise2;
string_t noise3;
} entvars_t;
#define PROGHEADER_CRC 5927
#endif

View File

@ -1,143 +0,0 @@
/* file generated by qcc, do not modify */
typedef struct
{ int32_t pad[28];
int32_t self;
int32_t other;
int32_t world;
float time;
float frametime;
float force_retouch;
string_t mapname;
float deathmatch;
float coop;
float teamplay;
float serverflags;
float total_secrets;
float total_monsters;
float found_secrets;
float killed_monsters;
float parm1;
float parm2;
float parm3;
float parm4;
float parm5;
float parm6;
float parm7;
float parm8;
float parm9;
float parm10;
float parm11;
float parm12;
float parm13;
float parm14;
float parm15;
float parm16;
vec3_t v_forward;
vec3_t v_up;
vec3_t v_right;
float trace_allsolid;
float trace_startsolid;
float trace_fraction;
vec3_t trace_endpos;
vec3_t trace_plane_normal;
float trace_plane_dist;
int32_t trace_ent;
float trace_inopen;
float trace_inwater;
int32_t msg_entity;
func_t main;
func_t StartFrame;
func_t PlayerPreThink;
func_t PlayerPostThink;
func_t ClientKill;
func_t ClientConnect;
func_t PutClientInServer;
func_t ClientDisconnect;
func_t SetNewParms;
func_t SetChangeParms;
} globalvars_t;
typedef struct
{
float modelindex;
vec3_t absmin;
vec3_t absmax;
float ltime;
float movetype;
float solid;
vec3_t origin;
vec3_t oldorigin;
vec3_t velocity;
vec3_t angles;
vec3_t avelocity;
vec3_t punchangle;
string_t classname;
string_t model;
float frame;
float skin;
float effects;
vec3_t mins;
vec3_t maxs;
vec3_t size;
func_t touch;
func_t use;
func_t think;
func_t blocked;
float nextthink;
int32_t groundentity;
float health;
float frags;
float weapon;
string_t weaponmodel;
float weaponframe;
float currentammo;
float ammo_shells;
float ammo_nails;
float ammo_rockets;
float ammo_cells;
float items;
float takedamage;
int32_t chain;
float deadflag;
vec3_t view_ofs;
float button0;
float button1;
float button2;
float impulse;
float fixangle;
vec3_t v_angle;
float idealpitch;
string_t netname;
int32_t enemy;
float flags;
float colormap;
float team;
float max_health;
float teleport_time;
float armortype;
float armorvalue;
float waterlevel;
float watertype;
float ideal_yaw;
float yaw_speed;
int32_t aiment;
int32_t goalentity;
float spawnflags;
string_t target;
string_t targetname;
float dmg_take;
float dmg_save;
int32_t dmg_inflictor;
int32_t owner;
vec3_t movedir;
string_t message;
float sounds;
string_t noise;
string_t noise1;
string_t noise2;
string_t noise3;
} entvars_t;
#define PROGHEADER_CRC 5927

View File

@ -20,20 +20,20 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#ifndef _QUAKE_PROGS_H #ifndef spingle__progs_h
#define _QUAKE_PROGS_H #define spingle__progs_h
#include "pr_comp.h" /* defs shared with qcc */ #include "pr_comp.h" /* defs shared with qcc */
#include "progdefs.h" /* generated by program cdefs */ #include "progdefs.h" /* generated by program cdefs */
typedef union eval_s typedef union eval_s
{ {
string_t string; string_t string;
float _float; float _float;
float vector[3]; float vector[3];
func_t function; func_t function;
int32_t _int; int32_t _int;
int32_t edict; int32_t edict;
} eval_t; } eval_t;
#define MAX_ENT_LEAFS 32 #define MAX_ENT_LEAFS 32
@ -59,13 +59,13 @@ typedef struct edict_s
//============================================================================ //============================================================================
extern dprograms_t *progs; extern dprograms_t *progs;
extern dfunction_t *pr_functions; extern dfunction_t *pr_functions;
extern dstatement_t *pr_statements; extern dstatement_t *pr_statements;
extern globalvars_t *pr_global_struct; extern globalvars_t *pr_global_struct;
extern float *pr_globals; /* same as pr_global_struct */ extern float *pr_globals;
extern int32_t pr_edict_size; /* in bytes */ extern int32_t pr_edict_size;
void PR_Init(void); void PR_Init(void);
@ -131,14 +131,10 @@ extern int32_t pr_xstatement;
extern uint16_t pr_crc; extern uint16_t pr_crc;
noreturn void PR_RunError(const char *error, ...) FUNC_PRINTF(1, 2); noreturn void PR_RunError(const char *error, ...) FUNC_PRINTF(1, 2);
#ifdef __WATCOMC__
#pragma aux PR_RunError aborts;
#endif
void ED_PrintEdicts(void); void ED_PrintEdicts(void);
void ED_PrintNum(int32_t ent); void ED_PrintNum(int32_t ent);
eval_t *GetEdictFieldValue(edict_t *ed, const char *field); eval_t *GetEdictFieldValue(edict_t *ed, const char *field);
#endif /* _QUAKE_PROGS_H */ #endif

View File

@ -20,10 +20,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#ifndef _QUAKE_PROTOCOL_H #ifndef spingle__protocol_h
#define _QUAKE_PROTOCOL_H #define spingle__protocol_h
// protocol.h -- communications protocols
#define PROTOCOL_NETQUAKE 15 //johnfitz -- standard quake protocol #define PROTOCOL_NETQUAKE 15 //johnfitz -- standard quake protocol
#define PROTOCOL_FITZQUAKE 666 //johnfitz -- added new protocol for fitzquake 0.85 #define PROTOCOL_FITZQUAKE 666 //johnfitz -- added new protocol for fitzquake 0.85
@ -253,5 +251,4 @@ typedef struct
float upmove; float upmove;
} usercmd_t; } usercmd_t;
#endif /* _QUAKE_PROTOCOL_H */ #endif

View File

@ -17,8 +17,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
#ifndef Q_CTYPE_H #ifndef spingle__q_ctype_h
#define Q_CTYPE_H #define spingle__q_ctype_h
static inline int32_t q_isascii(int32_t c) static inline int32_t q_isascii(int32_t c)
{ {
@ -101,4 +101,4 @@ static inline int32_t q_toupper(int32_t c)
return ((q_islower(c)) ? (c & ~('a' - 'A')) : c); return ((q_islower(c)) ? (c & ~('a' - 'A')) : c);
} }
#endif /* Q_CTYPE_H */ #endif

View File

@ -21,18 +21,15 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#ifndef QUAKEDEFS_H #ifndef spingle__q_defs_h
#define QUAKEDEFS_H #define spingle__q_defs_h
// quakedef.h -- primary header for client #define ENGINE_NAME "spingle"
#define VERSION "6.90"
#define VERSION "1.09" //#define PARANOID // speed sapping error checking
#define FITZQUAKE_VERSION "0.85" //johnfitz
#define QUAKESPASM_VERSION "0.93.1"
//define PARANOID // speed sapping error checking #define GAMENAME "id1" // directory to look in by default
#define GAMENAME "id1" // directory to look in by default
#include "q_stdinc.h" #include "q_stdinc.h"
@ -168,6 +165,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define SOUND_CHANNELS 8 #define SOUND_CHANNELS 8
typedef enum {ST_SYNC = 0, ST_RAND } synctype_t;
typedef struct typedef struct
{ {
const char *basedir; const char *basedir;
@ -202,9 +201,6 @@ typedef struct
#include "platform.h" #include "platform.h"
#include <SDL.h> #include <SDL.h>
#include <SDL_opengl.h> #include <SDL_opengl.h>
#ifndef APIENTRY
#define APIENTRY
#endif
#include "console.h" #include "console.h"
#include "wad.h" #include "wad.h"
@ -272,10 +268,6 @@ void Host_Shutdown(void);
void Host_Callback_Notify(cvar_t *var); /* callback function for CVAR_NOTIFY */ void Host_Callback_Notify(cvar_t *var); /* callback function for CVAR_NOTIFY */
noreturn void Host_Error(const char *error, ...) FUNC_PRINTF(1, 2); noreturn void Host_Error(const char *error, ...) FUNC_PRINTF(1, 2);
noreturn void Host_EndGame(const char *message, ...) FUNC_PRINTF(1, 2); noreturn void Host_EndGame(const char *message, ...) FUNC_PRINTF(1, 2);
#ifdef __WATCOMC__
#pragma aux Host_Error aborts;
#pragma aux Host_EndGame aborts;
#endif
void Host_Frame(float time); void Host_Frame(float time);
void Host_Quit_f(void); void Host_Quit_f(void);
void Host_ClientCommands(const char *fmt, ...) FUNC_PRINTF(1, 2); void Host_ClientCommands(const char *fmt, ...) FUNC_PRINTF(1, 2);
@ -294,5 +286,4 @@ extern int32_t current_skill; // skill level for currently loaded leve
extern bool isDedicated; extern bool isDedicated;
#endif /* QUAKEDEFS_H */ #endif

View File

@ -22,10 +22,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
// sound.h -- client sound i/o functions // sound.h -- client sound i/o functions
#ifndef __QUAKE_SOUND__ #ifndef spingle__q_sound_h
#define __QUAKE_SOUND__ #define spingle__q_sound_h
/* !!! if this is changed, it must be changed in asm_i386.h too !!! */
typedef struct typedef struct
{ {
int32_t left; int32_t left;
@ -186,5 +185,4 @@ wavinfo_t GetWavinfo(const char *name, byte *wav, int32_t wavlength);
void SND_InitScaletable(void); void SND_InitScaletable(void);
#endif /* __QUAKE_SOUND__ */ #endif

View File

@ -26,8 +26,10 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
#ifndef __QSTDINC_H #ifndef spingle__q_stdinc_h
#define __QSTDINC_H #define spingle__q_stdinc_h
#include "arch_def.h"
#include <limits.h> #include <limits.h>
#include <stdarg.h> #include <stdarg.h>
@ -40,7 +42,7 @@
#include <string.h> #include <string.h>
#include <sys/types.h> #include <sys/types.h>
#ifndef _WIN32 #if !PLATFORM_IS(WINDOWS)
#include <sys/param.h> #include <sys/param.h>
#endif #endif
@ -70,28 +72,28 @@ typedef vec_t vec5_t[5];
#if !defined(PATH_MAX) #if !defined(PATH_MAX)
/* equivalent values? */ /* equivalent values? */
#if defined(MAXPATHLEN) #if defined(MAXPATHLEN)
#define PATH_MAX MAXPATHLEN #define PATH_MAX MAXPATHLEN
#elif defined(_WIN32) && defined(_MAX_PATH) #elif defined(_MAX_PATH)
#define PATH_MAX _MAX_PATH #define PATH_MAX _MAX_PATH
#elif defined(_WIN32) && defined(MAX_PATH) #elif defined(MAX_PATH)
#define PATH_MAX MAX_PATH #define PATH_MAX MAX_PATH
#else /* fallback */ #else
#define PATH_MAX 1024 #error "no PATH_MAX available"
#endif
#endif #endif
#endif /* PATH_MAX */
#define MAX_OSPATH PATH_MAX #define MAX_OSPATH PATH_MAX
/* function attributes, etc */ /* function attributes, etc */
#if defined(__GNUC__) #if PLATFORM_IS_GNUC
#define FUNC_PRINTF(x,y) __attribute__((__format__(__printf__,x,y))) #define FUNC_PRINTF(x,y) __attribute__((__format__(__printf__,x,y)))
#else #else
#define FUNC_PRINTF(x,y) #define FUNC_PRINTF(x,y)
#endif #endif
/* argument format attributes for function pointers are supported for gcc >= 3.1 */ /* argument format attributes for function pointers are supported for gcc >= 3.1 */
#if defined(__GNUC__) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 0)) #if PLATFORM_IS_GNUC >= 3
#define FUNCP_PRINTF FUNC_PRINTF #define FUNCP_PRINTF FUNC_PRINTF
#else #else
#define FUNCP_PRINTF(x,y) #define FUNCP_PRINTF(x,y)
#endif #endif
@ -99,4 +101,4 @@ typedef vec_t vec5_t[5];
#define arraysizeof(a) (sizeof(a) / sizeof(*a)) #define arraysizeof(a) (sizeof(a) / sizeof(*a))
#define strsizeof(a) (sizeof(a) - 1) #define strsizeof(a) (sizeof(a) - 1)
#endif /* __QSTDINC_H */ #endif

View File

@ -22,7 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//r_alias.c -- alias model rendering //r_alias.c -- alias model rendering
#include "quakedef.h" #include "q_defs.h"
extern cvar_t r_drawflat, gl_overbright_models, gl_fullbrights, r_lerpmodels, r_lerpmove; //johnfitz extern cvar_t r_drawflat, gl_overbright_models, gl_fullbrights, r_lerpmodels, r_lerpmove; //johnfitz

View File

@ -22,7 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
// r_brush.c: brush model rendering. renamed from r_surf.c // r_brush.c: brush model rendering. renamed from r_surf.c
#include "quakedef.h" #include "q_defs.h"
extern cvar_t gl_fullbrights, r_drawflat, gl_overbright, r_oldwater; //johnfitz extern cvar_t gl_fullbrights, r_drawflat, gl_overbright, r_oldwater; //johnfitz
extern cvar_t gl_zfix; // QuakeSpasm z-fighting fix extern cvar_t gl_zfix; // QuakeSpasm z-fighting fix

View File

@ -21,7 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#include "quakedef.h" #include "q_defs.h"
#define MAX_PARTICLES 2048 // default max # of particles at one #define MAX_PARTICLES 2048 // default max # of particles at one
// time // time

View File

@ -21,7 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
//r_sprite.c -- sprite model rendering //r_sprite.c -- sprite model rendering
#include "quakedef.h" #include "q_defs.h"
/* /*
================ ================
@ -124,7 +124,7 @@ void R_DrawSpriteModel(entity_t *e)
s_right = v_right; s_right = v_right;
break; break;
case SPR_VP_PARALLEL_ORIENTED: //faces view plane, but obeys roll value case SPR_VP_PARALLEL_ORIENTED: //faces view plane, but obeys roll value
angle = currententity->angles[ROLL] * M_PI_DIV_180; angle = currententity->angles[ROLL] * PI_DIV_180;
sr = sin(angle); sr = sin(angle);
cr = cos(angle); cr = cos(angle);
v_right[0] = vright[0] * cr + vup[0] * sr; v_right[0] = vright[0] * cr + vup[0] * sr;

View File

@ -22,7 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
// r_world.c: world model rendering // r_world.c: world model rendering
#include "quakedef.h" #include "q_defs.h"
extern cvar_t gl_fullbrights, r_drawflat, gl_overbright, r_oldwater, r_oldskyleaf, r_showtris; //johnfitz extern cvar_t gl_fullbrights, r_drawflat, gl_overbright, r_oldwater, r_oldskyleaf, r_showtris; //johnfitz

View File

@ -20,8 +20,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#ifndef _QUAKE_RENDER_H #ifndef spingle__render_h
#define _QUAKE_RENDER_H #define spingle__render_h
// refresh.h -- public interface to refresh functions // refresh.h -- public interface to refresh functions
@ -174,5 +174,4 @@ void D_DeleteSurfaceCache(void);
void D_InitCaches(void *buffer, int32_t size); void D_InitCaches(void *buffer, int32_t size);
void R_SetVrect(vrect_t *pvrect, vrect_t *pvrectin, int32_t lineadj); void R_SetVrect(vrect_t *pvrect, vrect_t *pvrectin, int32_t lineadj);
#endif /* _QUAKE_RENDER_H */ #endif

View File

@ -21,7 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
// sbar.c -- status bar code // sbar.c -- status bar code
#include "quakedef.h" #include "q_defs.h"
int32_t sb_updates; // if >= vid.numpages, no update needed int32_t sb_updates; // if >= vid.numpages, no update needed

View File

@ -20,8 +20,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#ifndef _QUAKE_SBAR_H #ifndef spingle__sbar_h
#define _QUAKE_SBAR_H #define spingle__sbar_h
// the status bar is only redrawn if something has changed, but if anything // the status bar is only redrawn if something has changed, but if anything
// does, the entire thing will be redrawn for the next vid.numpages frames. // does, the entire thing will be redrawn for the next vid.numpages frames.
@ -42,5 +42,4 @@ void Sbar_IntermissionOverlay(void);
void Sbar_FinaleOverlay(void); void Sbar_FinaleOverlay(void);
#endif /* _QUAKE_SBAR_H */ #endif

View File

@ -20,8 +20,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#ifndef _QUAKE_SCREEN_H #ifndef spingle__screen_h
#define _QUAKE_SCREEN_H #define spingle__screen_h
// screen.h // screen.h
@ -81,5 +81,4 @@ extern cvar_t scr_crosshairscale;
extern int32_t scr_tileclear_updates; //johnfitz extern int32_t scr_tileclear_updates; //johnfitz
#endif /* _QUAKE_SCREEN_H */ #endif

View File

@ -20,8 +20,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#ifndef _QUAKE_SERVER_H #ifndef spingle__server_h
#define _QUAKE_SERVER_H #define spingle__server_h
// server.h // server.h
@ -228,5 +228,4 @@ void SV_RunClients(void);
void SV_SaveSpawnparms(); void SV_SaveSpawnparms();
void SV_SpawnServer(const char *server); void SV_SpawnServer(const char *server);
#endif /* _QUAKE_SERVER_H */ #endif

View File

@ -23,7 +23,7 @@
* *
*/ */
#include "quakedef.h" #include "q_defs.h"
#include "snd_codec.h" #include "snd_codec.h"
#include "snd_codeci.h" #include "snd_codeci.h"
@ -62,19 +62,19 @@ void S_CodecInit(void)
/* Register in the inverse order /* Register in the inverse order
* of codec choice preference: */ * of codec choice preference: */
S_CodecRegister(&umx_codec); S_CodecRegister(&umx_codec);
#ifdef USE_CODEC_MIKMOD #if defined(USE_CODEC_MIKMOD)
S_CodecRegister(&mikmod_codec); S_CodecRegister(&mikmod_codec);
#endif #endif
#ifdef USE_CODEC_FLAC #if defined(USE_CODEC_FLAC)
S_CodecRegister(&flac_codec); S_CodecRegister(&flac_codec);
#endif #endif
#ifdef USE_CODEC_OPUS #if defined(USE_CODEC_OPUS)
S_CodecRegister(&opus_codec); S_CodecRegister(&opus_codec);
#endif #endif
#ifdef USE_CODEC_VORBIS #if defined(USE_CODEC_VORBIS)
S_CodecRegister(&vorbis_codec); S_CodecRegister(&vorbis_codec);
#endif #endif
#ifdef USE_CODEC_MP3 #if defined(USE_CODEC_MP3)
S_CodecRegister(&mp3_codec); S_CodecRegister(&mp3_codec);
#endif #endif

View File

@ -23,8 +23,8 @@
* *
*/ */
#ifndef _SND_CODEC_H_ #ifndef spingle__snd_codec_h
#define _SND_CODEC_H_ #define spingle__snd_codec_h
typedef struct snd_info_s typedef struct snd_info_s
{ {
@ -101,5 +101,4 @@ int32_t S_CodecIsAvailable(uint32_t type);
/* return 1 if available, 0 if codec failed init /* return 1 if available, 0 if codec failed init
* or -1 if no such codec is present. */ * or -1 if no such codec is present. */
#endif /* _SND_CODEC_H_ */ #endif

View File

@ -23,8 +23,8 @@
* *
*/ */
#ifndef _SND_CODECI_H_ #ifndef spingle__snd_codeci_h
#define _SND_CODECI_H_ #define spingle__snd_codeci_h
/* Codec internals */ /* Codec internals */
typedef bool (*CODEC_INIT)(void); typedef bool (*CODEC_INIT)(void);
@ -51,5 +51,4 @@ struct snd_codec_s
bool S_CodecForwardStream(snd_stream_t *stream, uint32_t type); bool S_CodecForwardStream(snd_stream_t *stream, uint32_t type);
/* Forward a stream to another codec of 'type' type. */ /* Forward a stream to another codec of 'type' type. */
#endif /* _SND_CODECI_H_ */ #endif

View File

@ -24,7 +24,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
// snd_dma.c -- main control for any streaming sound output device // snd_dma.c -- main control for any streaming sound output device
#include "quakedef.h" #include "q_defs.h"
#include "snd_codec.h" #include "snd_codec.h"
#include "bgmusic.h" #include "bgmusic.h"
@ -79,7 +79,7 @@ cvar_t loadas8bit = {"loadas8bit", "0", CVAR_NONE};
cvar_t sndspeed = {"sndspeed", "11025", CVAR_NONE}; cvar_t sndspeed = {"sndspeed", "11025", CVAR_NONE};
cvar_t snd_mixspeed = {"snd_mixspeed", "44100", CVAR_NONE}; cvar_t snd_mixspeed = {"snd_mixspeed", "44100", CVAR_NONE};
#if defined(_WIN32) #if PLATFORM_IS(WINDOWS)
#define SND_FILTERQUALITY_DEFAULT "5" #define SND_FILTERQUALITY_DEFAULT "5"
#else #else
#define SND_FILTERQUALITY_DEFAULT "1" #define SND_FILTERQUALITY_DEFAULT "1"
@ -189,8 +189,6 @@ void S_Init(void)
if(safemode || COM_CheckParm("-nosound")) if(safemode || COM_CheckParm("-nosound"))
return; return;
Con_Printf("\nSound Initialization\n");
Cmd_AddCommand("play", S_Play); Cmd_AddCommand("play", S_Play);
Cmd_AddCommand("playvol", S_PlayVol); Cmd_AddCommand("playvol", S_PlayVol);
Cmd_AddCommand("stopsound", S_StopAllSoundsC); Cmd_AddCommand("stopsound", S_StopAllSoundsC);

Some files were not shown because too many files have changed in this diff Show More