fix fungusy architecture crap
parent
1e5b30ba49
commit
55aef43175
|
@ -22,6 +22,7 @@ pkg_check_modules(MikMod IMPORTED_TARGET libmikmod>=3.3.11)
|
|||
set(srcs
|
||||
source/anorm_dots.h
|
||||
source/anorms.h
|
||||
source/arch_def.c
|
||||
source/arch_def.h
|
||||
source/bgmusic.c
|
||||
source/bgmusic.h
|
||||
|
|
|
@ -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",
|
||||
};
|
||||
|
|
@ -27,144 +27,50 @@
|
|||
#ifndef ARCHDEFS_H
|
||||
#define ARCHDEFS_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_DOS 1
|
||||
# endif
|
||||
#define PLATFORM_IS(x) (PLATFORM == PLATFRM_##x)
|
||||
|
||||
#elif defined(__OS2__) || defined(__EMX__)
|
||||
|
||||
# if !defined(PLATFORM_OS2)
|
||||
# define PLATFORM_OS2 1
|
||||
# endif
|
||||
|
||||
#elif defined(_WIN32) || defined(__WIN32__) || defined(_WIN64) || defined(__NT__) || defined(_Windows)
|
||||
|
||||
# if !defined(PLATFORM_WINDOWS)
|
||||
# define PLATFORM_WINDOWS 1
|
||||
# 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
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
#define PLATFORM PLATFRM_WINDOWS
|
||||
#elif defined(__APPLE__) && defined(__MACH__)
|
||||
#define PLATFORM PLATFRM_OSX
|
||||
#elif defined(__FreeBSD__) || defined(__DragonFly__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__bsdi__)
|
||||
#define PLATFORM PLATFRM_BSD
|
||||
#elif defined(__linux__)
|
||||
#define PLATFORM PLATFRM_LINUX
|
||||
#elif defined(_arch_dreamcast)
|
||||
#define PLATFORM PLATFRM_DREAMCAST
|
||||
#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(PLATFORM_UNIX)
|
||||
# define PLATFORM_UNIX 2
|
||||
# endif
|
||||
#endif /* OS X -> PLATFORM_UNIX */
|
||||
#if defined(__GNUC__)
|
||||
#define PLATFORM_IS_GNUC __GNUC__
|
||||
#endif
|
||||
|
||||
#if !defined(PLATFORM)
|
||||
#error "Platform not defined. The program will not compile."
|
||||
#endif
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__DragonFly__) || \
|
||||
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 */
|
||||
extern char const platform_names[][16];
|
||||
|
||||
#endif
|
||||
|
|
|
@ -44,7 +44,6 @@ void CDAudio_Update(void)
|
|||
|
||||
int32_t CDAudio_Init(void)
|
||||
{
|
||||
Con_Printf("CDAudio disabled at compile time\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ static void CDAudio_Eject(void)
|
|||
if(!cd_handle || !enabled)
|
||||
return;
|
||||
|
||||
#ifdef __linux__
|
||||
#if PLATFORM_IS(LINUX)
|
||||
SDL_CDStop(cd_handle); /* see CDAudio_Stop() */
|
||||
#endif
|
||||
if(SDL_CDEject(cd_handle) < 0)
|
||||
|
@ -144,7 +144,7 @@ void CDAudio_Stop(void)
|
|||
if(!playing)
|
||||
return;
|
||||
|
||||
#ifdef __linux__
|
||||
#if PLATFORM_IS(LINUX)
|
||||
/* Don't really stop, but just pause: On some devices, the CDROMSTOP
|
||||
* ioctl causes any followup ioctls to fail for a considerable time.
|
||||
* 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)
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
#if PLATFORM_IS(WINDOWS)
|
||||
/* arg should be like "D:\", make sure it is so,
|
||||
* but tolerate args like "D" or "D:", as well. */
|
||||
static char drive[4];
|
||||
|
@ -475,7 +475,7 @@ static void export_cddev_arg(void)
|
|||
{
|
||||
/* Bad ugly hack to workaround SDL's cdrom device detection.
|
||||
* not needed for windows due to the way SDL_cdrom works. */
|
||||
#if !defined(_WIN32)
|
||||
#if !PLATFORM_IS(WINDOWS)
|
||||
int32_t i = COM_CheckParm("-cddev");
|
||||
if(i != 0 && i < com_argc - 1 && com_argv[i + 1][0] != '\0')
|
||||
{
|
||||
|
@ -571,7 +571,7 @@ void CDAudio_Shutdown(void)
|
|||
CDAudio_Stop();
|
||||
if(hw_vol_works)
|
||||
CD_SetVolume(NULL); /* no SDL support at present. */
|
||||
#ifdef __linux__
|
||||
#if PLATFORM_IS(LINUX)
|
||||
SDL_CDStop(cd_handle); /* see CDAudio_Stop() */
|
||||
#endif
|
||||
SDL_CDClose(cd_handle);
|
||||
|
|
|
@ -331,12 +331,12 @@ void CL_UpdateTEnts(void)
|
|||
}
|
||||
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)
|
||||
yaw += 360;
|
||||
|
||||
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)
|
||||
pitch += 360;
|
||||
}
|
||||
|
|
|
@ -216,7 +216,7 @@ char *q_strupr(char *str)
|
|||
}
|
||||
|
||||
/* platform dependant (v)snprintf function names: */
|
||||
#if defined(_WIN32)
|
||||
#if PLATFORM_IS(WINDOWS)
|
||||
#define snprintf_func _snprintf
|
||||
#define vsnprintf_func _vsnprintf
|
||||
#else
|
||||
|
@ -596,7 +596,7 @@ void MSG_WriteChar(sizebuf_t *sb, int32_t c)
|
|||
{
|
||||
byte *buf;
|
||||
|
||||
#ifdef PARANOID
|
||||
#if defined(PARANOID)
|
||||
if(c < -128 || c > 127)
|
||||
Sys_Error("MSG_WriteChar: range error");
|
||||
#endif
|
||||
|
@ -609,7 +609,7 @@ void MSG_WriteByte(sizebuf_t *sb, int32_t c)
|
|||
{
|
||||
byte *buf;
|
||||
|
||||
#ifdef PARANOID
|
||||
#if defined(PARANOID)
|
||||
if(c < 0 || c > 255)
|
||||
Sys_Error("MSG_WriteByte: range error");
|
||||
#endif
|
||||
|
@ -622,7 +622,7 @@ void MSG_WriteShort(sizebuf_t *sb, int32_t c)
|
|||
{
|
||||
byte *buf;
|
||||
|
||||
#ifdef PARANOID
|
||||
#if defined(PARANOID)
|
||||
if(c < ((int16_t)0x8000) || c > (int16_t)0x7fff)
|
||||
Sys_Error("MSG_WriteShort: range error");
|
||||
#endif
|
||||
|
|
|
@ -21,16 +21,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
*/
|
||||
// console.c
|
||||
|
||||
#include "quakedef.h"
|
||||
#include <sys/types.h>
|
||||
#include <time.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#ifdef _WIN32
|
||||
#if PLATFORM_IS(WINDOWS)
|
||||
#include <io.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include "quakedef.h"
|
||||
|
||||
int32_t con_linewidth;
|
||||
|
||||
|
|
|
@ -29,68 +29,21 @@
|
|||
|
||||
#include <string.h>
|
||||
|
||||
/* ---------------------- Windows, DOS, OS2: ---------------------- */
|
||||
#if defined(__MSDOS__) || defined(__DOS__) || defined(__DJGPP__) || \
|
||||
defined(_MSDOS) || defined(__OS2__) || defined(__EMX__) || \
|
||||
defined(_WIN32) || defined(_Windows) || defined(__WINDOWS__) || \
|
||||
defined(__NT__) || defined(__CYGWIN__)
|
||||
|
||||
#if PLATFORM_IS(WINDOWS)
|
||||
#define HAVE_DOS_BASED_FILE_SYSTEM 1
|
||||
#define HAVE_CASE_INSENSITIVE_FILE_SYSTEM 1
|
||||
|
||||
#define HAS_DRIVE_SPEC(f) ((f)[0] && ((f)[1] == ':'))
|
||||
#define STRIP_DRIVE_SPEC(f) ((f) + 2)
|
||||
#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_STR "\\"
|
||||
#endif
|
||||
/* 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
|
||||
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. */
|
||||
#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)
|
||||
{
|
||||
char *p1 = strchr(_the_path, '/');
|
||||
|
@ -99,6 +52,7 @@ static inline char *FIND_FIRST_DIRSEP(const char *_the_path)
|
|||
if(p2 == NULL) return p1;
|
||||
return (p1 < p2) ? p1 : p2;
|
||||
}
|
||||
|
||||
static inline char *FIND_LAST_DIRSEP(const char *_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;
|
||||
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
|
||||
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 DIR_SEPARATOR_CHAR '/'
|
||||
#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 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)
|
||||
{
|
||||
return strchr(_the_path, '/');
|
||||
}
|
||||
|
||||
static inline char *FIND_LAST_DIRSEP(const char *_the_path)
|
||||
{
|
||||
return strrchr(_the_path, '/');
|
||||
}
|
||||
#endif /* C++ */
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* FILENAMES_H */
|
||||
|
|
|
@ -108,7 +108,7 @@ void R_RenderDlight(dlight_t *light)
|
|||
glColor3f(0, 0, 0);
|
||||
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++)
|
||||
v[j] = light->origin[j] + vright[j] * cos(a) * rad
|
||||
+ vup[j] * sin(a) * rad;
|
||||
|
|
|
@ -414,7 +414,7 @@ assumes side and forward are perpendicular, and normalized
|
|||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
float xmax, ymax;
|
||||
xmax = NEARCLIP * tan(fovx * M_PI / 360.0);
|
||||
ymax = NEARCLIP * tan(fovy * M_PI / 360.0);
|
||||
xmax = NEARCLIP * tan(fovx * PI / 360.0);
|
||||
ymax = NEARCLIP * tan(fovy * PI / 360.0);
|
||||
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)
|
||||
{
|
||||
//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_fovy = atan(tan(DEG2RAD(r_refdef.fov_y) / 2) * (1.03 - 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 / PI_DIV_180;
|
||||
}
|
||||
}
|
||||
//johnfitz
|
||||
|
|
|
@ -249,8 +249,8 @@ float AdaptFovx(float fov_x, float width, float height)
|
|||
return fov_x;
|
||||
if((x = height / width) == 0.75)
|
||||
return fov_x;
|
||||
a = atan(0.75 / x * tan(fov_x / 360 * M_PI));
|
||||
a = a * 360 / M_PI;
|
||||
a = atan(0.75 / x * tan(fov_x / 360 * PI));
|
||||
a = a * 360 / PI;
|
||||
return a;
|
||||
}
|
||||
|
||||
|
@ -266,9 +266,9 @@ float CalcFovy(float fov_x, float width, float height)
|
|||
if(fov_x < 1 || fov_x > 179)
|
||||
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 = a * 360 / M_PI;
|
||||
a = a * 360 / PI;
|
||||
return a;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#include <SDL.h>
|
||||
|
||||
//ericw -- for putting the driver into multithreaded mode
|
||||
#ifdef __APPLE__
|
||||
#if PLATFORM_IS(OSX)
|
||||
#include <OpenGL/OpenGL.h>
|
||||
#endif
|
||||
|
||||
|
@ -1181,11 +1181,10 @@ static void GL_Init(void)
|
|||
|
||||
GL_CheckExtensions(); //johnfitz
|
||||
|
||||
#ifdef __APPLE__
|
||||
#if PLATFORM_IS(OSX)
|
||||
// ericw -- enable multi-threaded OpenGL, gives a decent FPS boost.
|
||||
// https://developer.apple.com/library/mac/technotes/tn2085/
|
||||
if(host_parms->numcpus > 1 &&
|
||||
kCGLNoError != CGLEnable(CGLGetCurrentContext(), kCGLCEMPEngine))
|
||||
if(host_parms->numcpus > 1 && kCGLNoError != CGLEnable(CGLGetCurrentContext(), kCGLCEMPEngine))
|
||||
{
|
||||
Con_Warning("Couldn't enable multi-threaded OpenGL");
|
||||
}
|
||||
|
|
|
@ -36,8 +36,8 @@ float turbsin[] =
|
|||
#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 WARPCALC2(s,t) ((s + turbsin[(int32_t)((t*0.125+cl.time)*(128.0/M_PI)) & 255]) * (1.0/64)) //johnfitz -- old 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/PI)) & 255]) * (1.0/64)) //johnfitz -- old warp
|
||||
|
||||
//==============================================================================
|
||||
//
|
||||
|
|
|
@ -22,7 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
*/
|
||||
|
||||
#include "quakedef.h"
|
||||
#ifndef _WIN32
|
||||
#if !PLATFORM_IS(WINDOWS)
|
||||
#include <dirent.h>
|
||||
#endif
|
||||
|
||||
|
@ -116,7 +116,7 @@ void ExtraMaps_Add(const char *name)
|
|||
|
||||
void ExtraMaps_Init(void)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
#if PLATFORM_IS(WINDOWS)
|
||||
WIN32_FIND_DATA fdat;
|
||||
HANDLE fhnd;
|
||||
#else
|
||||
|
@ -138,7 +138,7 @@ void ExtraMaps_Init(void)
|
|||
{
|
||||
if(*search->filename) //directory
|
||||
{
|
||||
#ifdef _WIN32
|
||||
#if PLATFORM_IS(WINDOWS)
|
||||
q_snprintf(filestring, sizeof(filestring), "%s/maps/*.bsp", search->filename);
|
||||
fhnd = FindFirstFile(filestring, &fdat);
|
||||
if(fhnd == INVALID_HANDLE_VALUE)
|
||||
|
@ -228,7 +228,7 @@ void Modlist_Add(const char *name)
|
|||
FileList_Add(name, &modlist);
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
#if PLATFORM_IS(WINDOWS)
|
||||
void Modlist_Init(void)
|
||||
{
|
||||
WIN32_FIND_DATA fdat;
|
||||
|
@ -308,7 +308,7 @@ void DemoList_Rebuild(void)
|
|||
// TODO: Factor out to a general-purpose file searching function
|
||||
void DemoList_Init(void)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
#if PLATFORM_IS(WINDOWS)
|
||||
WIN32_FIND_DATA fdat;
|
||||
HANDLE fhnd;
|
||||
#else
|
||||
|
@ -330,7 +330,7 @@ void DemoList_Init(void)
|
|||
{
|
||||
if(*search->filename) //directory
|
||||
{
|
||||
#ifdef _WIN32
|
||||
#if PLATFORM_IS(WINDOWS)
|
||||
q_snprintf(filestring, sizeof(filestring), "%s/*.dem", search->filename);
|
||||
fhnd = FindFirstFile(filestring, &fdat);
|
||||
if(fhnd == INVALID_HANDLE_VALUE)
|
||||
|
|
|
@ -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);
|
||||
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());
|
||||
#endif
|
||||
|
||||
|
|
|
@ -28,12 +28,12 @@ static bool textmode;
|
|||
|
||||
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 */
|
||||
#define MACOS_X_ACCELERATION_HACK
|
||||
#endif
|
||||
|
||||
#ifdef MACOS_X_ACCELERATION_HACK
|
||||
#if defined(MACOS_X_ACCELERATION_HACK)
|
||||
#include <IOKit/IOTypes.h>
|
||||
#include <IOKit/hidsystem/IOHIDLib.h>
|
||||
#include <IOKit/hidsystem/IOHIDParameter.h>
|
||||
|
@ -105,7 +105,7 @@ static void IN_EndIgnoringMouseEvents(void)
|
|||
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 double originalMouseSpeed = -1.0;
|
||||
|
||||
|
@ -180,7 +180,7 @@ void IN_Activate(void)
|
|||
if(no_mouse)
|
||||
return;
|
||||
|
||||
#ifdef MACOS_X_ACCELERATION_HACK
|
||||
#if defined(MACOS_X_ACCELERATION_HACK)
|
||||
/* Save the status of mouse acceleration */
|
||||
if(originalMouseSpeed == -1 && in_disablemacosxmouseaccel.value)
|
||||
IN_DisableOSXMouseAccel();
|
||||
|
@ -202,7 +202,7 @@ void IN_Deactivate(bool free_cursor)
|
|||
if(no_mouse)
|
||||
return;
|
||||
|
||||
#ifdef MACOS_X_ACCELERATION_HACK
|
||||
#if defined(MACOS_X_ACCELERATION_HACK)
|
||||
if(originalMouseSpeed != -1)
|
||||
IN_ReenableOSXMouseAccel();
|
||||
#endif
|
||||
|
@ -294,7 +294,7 @@ void IN_Init(void)
|
|||
IN_BeginIgnoringMouseEvents();
|
||||
}
|
||||
|
||||
#ifdef MACOS_X_ACCELERATION_HACK
|
||||
#if defined(MACOS_X_ACCELERATION_HACK)
|
||||
Cvar_RegisterVariable(&in_disablemacosxmouseaccel);
|
||||
#endif
|
||||
Cvar_RegisterVariable(&in_debugkeys);
|
||||
|
@ -350,11 +350,6 @@ static joyaxisstate_t joy_axisstate;
|
|||
static double joy_buttontimer[SDL_CONTROLLER_BUTTON_MAX];
|
||||
static double joy_emulatedkeytimer[10];
|
||||
|
||||
#ifdef __WATCOMC__ /* OW1.9 doesn't have powf() / sqrtf() */
|
||||
#define powf pow
|
||||
#define sqrtf sqrt
|
||||
#endif
|
||||
|
||||
/*
|
||||
================
|
||||
IN_AxisMagnitude
|
||||
|
|
|
@ -22,7 +22,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
*/
|
||||
|
||||
#include "quakedef.h"
|
||||
#include "arch_def.h"
|
||||
|
||||
/* key up events are sent even if in console mode */
|
||||
|
||||
|
@ -418,7 +417,7 @@ void Key_Console(int32_t key)
|
|||
|
||||
case 'v':
|
||||
case 'V':
|
||||
#if defined(PLATFORM_OSX) || defined(PLATFORM_MAC)
|
||||
#if PLATFORM_IS(OSX)
|
||||
if(keydown[K_COMMAND]) /* Cmd+v paste (Mac-only) */
|
||||
{
|
||||
PasteToConsole();
|
||||
|
@ -869,7 +868,7 @@ void Key_Init(void)
|
|||
consolekeys[K_KP_ENTER] = true;
|
||||
consolekeys[K_KP_INS] = true;
|
||||
consolekeys[K_KP_DEL] = true;
|
||||
#if defined(PLATFORM_OSX) || defined(PLATFORM_MAC)
|
||||
#if PLATFORM_IS(OSX)
|
||||
consolekeys[K_COMMAND] = true;
|
||||
#endif
|
||||
consolekeys[K_MWHEELUP] = true;
|
||||
|
@ -1097,7 +1096,7 @@ void Char_Event(int32_t key)
|
|||
if(key < 32 || key > 126)
|
||||
return;
|
||||
|
||||
#if defined(PLATFORM_OSX) || defined(PLATFORM_MAC)
|
||||
#if PLATFORM_IS(OSX)
|
||||
if(keydown[K_COMMAND])
|
||||
return;
|
||||
#endif
|
||||
|
|
342
source/lodepng.c
342
source/lodepng.c
|
@ -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
|
||||
from here.*/
|
||||
|
||||
#ifdef LODEPNG_COMPILE_ALLOCATORS
|
||||
#if defined(LODEPNG_COMPILE_ALLOCATORS)
|
||||
static void* lodepng_malloc(size_t 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.
|
||||
*/
|
||||
|
||||
#ifdef LODEPNG_COMPILE_ZLIB
|
||||
#if defined(LODEPNG_COMPILE_ZLIB)
|
||||
/*dynamic vector of unsigned ints*/
|
||||
typedef struct uivector
|
||||
{
|
||||
|
@ -188,7 +188,7 @@ static void uivector_init(uivector* p)
|
|||
p->size = p->allocsize = 0;
|
||||
}
|
||||
|
||||
#ifdef LODEPNG_COMPILE_ENCODER
|
||||
#if defined(LODEPNG_COMPILE_ENCODER)
|
||||
/*returns 1 if success, 0 if failure ==> nothing done*/
|
||||
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*/
|
||||
}
|
||||
|
||||
#ifdef LODEPNG_COMPILE_PNG
|
||||
#if defined(LODEPNG_COMPILE_PNG)
|
||||
|
||||
static void ucvector_cleanup(void* p)
|
||||
{
|
||||
|
@ -250,7 +250,7 @@ static void ucvector_init(ucvector* p)
|
|||
}
|
||||
#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
|
||||
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)
|
||||
|
@ -273,8 +273,8 @@ static unsigned ucvector_push_back(ucvector* p, uint8_t c)
|
|||
|
||||
/* ////////////////////////////////////////////////////////////////////////// */
|
||||
|
||||
#ifdef LODEPNG_COMPILE_PNG
|
||||
#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS
|
||||
#if defined(LODEPNG_COMPILE_PNG)
|
||||
#if defined(LODEPNG_COMPILE_ANCILLARY_CHUNKS)
|
||||
/*returns 1 if success, 0 if failure ==> nothing done*/
|
||||
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)*/
|
||||
|
||||
#ifdef LODEPNG_COMPILE_ENCODER
|
||||
#if defined(LODEPNG_COMPILE_ENCODER)
|
||||
static void lodepng_add32bitInt(ucvector* buffer, unsigned value)
|
||||
{
|
||||
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 / */
|
||||
/* ////////////////////////////////////////////////////////////////////////// */
|
||||
|
||||
#ifdef LODEPNG_COMPILE_DISK
|
||||
#if defined(LODEPNG_COMPILE_DISK)
|
||||
|
||||
/* returns negative value on error. This should be pure C compatible, so no fstat. */
|
||||
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
|
||||
#ifdef LODEPNG_COMPILE_ENCODER
|
||||
#if defined(LODEPNG_COMPILE_ZLIB)
|
||||
#if defined(LODEPNG_COMPILE_ENCODER)
|
||||
/*TODO: this ignores potential out of memory errors*/
|
||||
#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*/
|
||||
|
||||
#ifdef LODEPNG_COMPILE_DECODER
|
||||
#if defined(LODEPNG_COMPILE_DECODER)
|
||||
|
||||
#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);
|
||||
}
|
||||
|
||||
#ifdef LODEPNG_COMPILE_ENCODER
|
||||
#if defined(LODEPNG_COMPILE_ENCODER)
|
||||
|
||||
/*BPM: Boundary Package Merge, see "A Fast and Space-Economical Algorithm for Length-Limited Coding",
|
||||
Jyrki Katajainen, Alistair Moffat, Andrew Turpin, 1995.*/
|
||||
|
@ -942,7 +942,7 @@ static unsigned generateFixedDistanceTree(HuffmanTree* tree)
|
|||
return error;
|
||||
}
|
||||
|
||||
#ifdef LODEPNG_COMPILE_DECODER
|
||||
#if defined(LODEPNG_COMPILE_DECODER)
|
||||
|
||||
/*
|
||||
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*/
|
||||
|
||||
#ifdef LODEPNG_COMPILE_DECODER
|
||||
#if defined(LODEPNG_COMPILE_DECODER)
|
||||
|
||||
/* ////////////////////////////////////////////////////////////////////////// */
|
||||
/* / Inflator (Decompressor) / */
|
||||
|
@ -1318,7 +1318,7 @@ static unsigned inflate(uint8_t** out, size_t* outsize,
|
|||
|
||||
#endif /*LODEPNG_COMPILE_DECODER*/
|
||||
|
||||
#ifdef LODEPNG_COMPILE_ENCODER
|
||||
#if defined(LODEPNG_COMPILE_ENCODER)
|
||||
|
||||
/* ////////////////////////////////////////////////////////////////////////// */
|
||||
/* / Deflator (Compressor) / */
|
||||
|
@ -2135,7 +2135,7 @@ static unsigned adler32(const uint8_t* data, unsigned len)
|
|||
/* / Zlib / */
|
||||
/* ////////////////////////////////////////////////////////////////////////// */
|
||||
|
||||
#ifdef LODEPNG_COMPILE_DECODER
|
||||
#if defined(LODEPNG_COMPILE_DECODER)
|
||||
|
||||
unsigned lodepng_zlib_decompress(uint8_t** out, size_t* outsize, const uint8_t* in,
|
||||
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*/
|
||||
|
||||
#ifdef LODEPNG_COMPILE_ENCODER
|
||||
#if defined(LODEPNG_COMPILE_ENCODER)
|
||||
|
||||
unsigned lodepng_zlib_compress(uint8_t** out, size_t* outsize, const uint8_t* in,
|
||||
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*/
|
||||
|
||||
#ifdef LODEPNG_COMPILE_DECODER
|
||||
#if defined(LODEPNG_COMPILE_DECODER)
|
||||
static unsigned zlib_decompress(uint8_t** out, size_t* outsize, const uint8_t* in,
|
||||
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);
|
||||
}
|
||||
#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,
|
||||
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*/
|
||||
#define DEFAULT_WINDOWSIZE 2048
|
||||
|
@ -2304,7 +2304,7 @@ const LodePNGCompressSettings lodepng_default_compress_settings = {2, 1, DEFAULT
|
|||
|
||||
#endif /*LODEPNG_COMPILE_ENCODER*/
|
||||
|
||||
#ifdef LODEPNG_COMPILE_DECODER
|
||||
#if defined(LODEPNG_COMPILE_DECODER)
|
||||
|
||||
void lodepng_decompress_settings_init(LodePNGDecompressSettings* settings)
|
||||
{
|
||||
|
@ -2325,7 +2325,7 @@ const LodePNGDecompressSettings lodepng_default_decompress_settings = {0, 0, 0,
|
|||
/* ////////////////////////////////////////////////////////////////////////// */
|
||||
/* ////////////////////////////////////////////////////////////////////////// */
|
||||
|
||||
#ifdef LODEPNG_COMPILE_PNG
|
||||
#if defined(LODEPNG_COMPILE_PNG)
|
||||
|
||||
/* ////////////////////////////////////////////////////////////////////////// */
|
||||
/* / CRC32 / */
|
||||
|
@ -2408,7 +2408,7 @@ static unsigned readBitsFromReversedStream(size_t* bitpointer, const uint8_t* bi
|
|||
return result;
|
||||
}
|
||||
|
||||
#ifdef LODEPNG_COMPILE_DECODER
|
||||
#if defined(LODEPNG_COMPILE_DECODER)
|
||||
static void setBitOfReversedStream0(size_t* bitpointer, uint8_t* bitstream, uint8_t bit)
|
||||
{
|
||||
/*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
|
||||
#ifdef LODEPNG_COMPILE_DECODER
|
||||
#if defined(LODEPNG_COMPILE_PNG)
|
||||
#if defined(LODEPNG_COMPILE_DECODER)
|
||||
/*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)
|
||||
{
|
||||
|
@ -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_PNG*/
|
||||
|
||||
#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS
|
||||
#if defined(LODEPNG_COMPILE_ANCILLARY_CHUNKS)
|
||||
|
||||
static void LodePNGUnknownChunks_init(LodePNGInfo* info)
|
||||
{
|
||||
|
@ -2944,7 +2944,7 @@ void lodepng_info_init(LodePNGInfo* info)
|
|||
info->interlace_method = 0;
|
||||
info->compression_method = 0;
|
||||
info->filter_method = 0;
|
||||
#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS
|
||||
#if defined(LODEPNG_COMPILE_ANCILLARY_CHUNKS)
|
||||
info->background_defined = 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)
|
||||
{
|
||||
lodepng_color_mode_cleanup(&info->color);
|
||||
#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS
|
||||
#if defined(LODEPNG_COMPILE_ANCILLARY_CHUNKS)
|
||||
LodePNGText_cleanup(info);
|
||||
LodePNGIText_cleanup(info);
|
||||
|
||||
|
@ -2976,7 +2976,7 @@ unsigned lodepng_info_copy(LodePNGInfo* dest, const LodePNGInfo* source)
|
|||
lodepng_color_mode_init(&dest->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(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;
|
||||
}
|
||||
|
||||
#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)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
#ifdef LODEPNG_COMPILE_ENCODER
|
||||
#if defined(LODEPNG_COMPILE_ENCODER)
|
||||
|
||||
void lodepng_color_profile_init(LodePNGColorProfile* profile)
|
||||
{
|
||||
|
@ -3849,7 +3849,7 @@ unsigned lodepng_auto_choose_color(LodePNGColorMode* mode_out,
|
|||
return error;
|
||||
}
|
||||
|
||||
#endif /* #ifdef LODEPNG_COMPILE_ENCODER */
|
||||
#endif /* #if defined(LODEPNG_COMPILE_ENCODER) */
|
||||
|
||||
/*
|
||||
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 / */
|
||||
|
@ -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)*/
|
||||
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*/
|
||||
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*/
|
||||
#endif /*LODEPNG_COMPILE_ANCILLARY_CHUNKS*/
|
||||
|
||||
|
@ -4617,7 +4617,7 @@ static void decodeGeneric(uint8_t** out, unsigned* w, unsigned* h,
|
|||
size_t oldsize = idat.size;
|
||||
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];
|
||||
#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS
|
||||
#if defined(LODEPNG_COMPILE_ANCILLARY_CHUNKS)
|
||||
critical_pos = 3;
|
||||
#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);
|
||||
if(state->error) break;
|
||||
#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS
|
||||
#if defined(LODEPNG_COMPILE_ANCILLARY_CHUNKS)
|
||||
critical_pos = 2;
|
||||
#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);
|
||||
if(state->error) break;
|
||||
}
|
||||
#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS
|
||||
#if defined(LODEPNG_COMPILE_ANCILLARY_CHUNKS)
|
||||
/*background color 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;
|
||||
#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS
|
||||
#if defined(LODEPNG_COMPILE_ANCILLARY_CHUNKS)
|
||||
if(state->decoder.remember_unknown_chunks)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
#ifdef LODEPNG_COMPILE_DISK
|
||||
#if defined(LODEPNG_COMPILE_DISK)
|
||||
unsigned lodepng_decode_file(uint8_t** out, unsigned* w, unsigned* h, const char* filename,
|
||||
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)
|
||||
{
|
||||
settings->color_convert = 1;
|
||||
#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS
|
||||
#if defined(LODEPNG_COMPILE_ANCILLARY_CHUNKS)
|
||||
settings->read_text_chunks = 1;
|
||||
settings->remember_unknown_chunks = 0;
|
||||
#endif /*LODEPNG_COMPILE_ANCILLARY_CHUNKS*/
|
||||
|
@ -4868,10 +4868,10 @@ void lodepng_decoder_settings_init(LodePNGDecoderSettings* settings)
|
|||
|
||||
void lodepng_state_init(LodePNGState* state)
|
||||
{
|
||||
#ifdef LODEPNG_COMPILE_DECODER
|
||||
#if defined(LODEPNG_COMPILE_DECODER)
|
||||
lodepng_decoder_settings_init(&state->decoder);
|
||||
#endif /*LODEPNG_COMPILE_DECODER*/
|
||||
#ifdef LODEPNG_COMPILE_ENCODER
|
||||
#if defined(LODEPNG_COMPILE_ENCODER)
|
||||
lodepng_encoder_settings_init(&state->encoder);
|
||||
#endif /*LODEPNG_COMPILE_ENCODER*/
|
||||
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) */
|
||||
|
||||
#ifdef LODEPNG_COMPILE_ENCODER
|
||||
#if defined(LODEPNG_COMPILE_ENCODER)
|
||||
|
||||
/* ////////////////////////////////////////////////////////////////////////// */
|
||||
/* / PNG Encoder / */
|
||||
|
@ -5031,7 +5031,7 @@ static unsigned addChunk_IEND(ucvector* out)
|
|||
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)
|
||||
{
|
||||
|
@ -5675,7 +5675,7 @@ static unsigned getPaletteTranslucency(const uint8_t* palette, size_t palettesiz
|
|||
return key;
|
||||
}
|
||||
|
||||
#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS
|
||||
#if defined(LODEPNG_COMPILE_ANCILLARY_CHUNKS)
|
||||
static unsigned addUnknownChunks(ucvector* out, uint8_t* data, size_t datasize)
|
||||
{
|
||||
uint8_t* inchunk = data;
|
||||
|
@ -5758,14 +5758,14 @@ unsigned lodepng_encode(uint8_t** out, size_t* outsize,
|
|||
ucvector_init(&outv);
|
||||
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;
|
||||
#endif /*LODEPNG_COMPILE_ANCILLARY_CHUNKS*/
|
||||
/*write signature and chunks*/
|
||||
writeSignature(&outv);
|
||||
/*IHDR*/
|
||||
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*/
|
||||
if(info.unknown_chunks_data[0])
|
||||
{
|
||||
|
@ -5791,7 +5791,7 @@ unsigned lodepng_encode(uint8_t** out, size_t* outsize,
|
|||
{
|
||||
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*/
|
||||
if(info.background_defined) addChunk_bKGD(&outv, &info);
|
||||
/*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)*/
|
||||
state->error = addChunk_IDAT(&outv, data, datasize, &state->encoder.zlibsettings);
|
||||
if(state->error) break;
|
||||
#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS
|
||||
#if defined(LODEPNG_COMPILE_ANCILLARY_CHUNKS)
|
||||
/*tIME*/
|
||||
if(info.time_defined) addChunk_tIME(&outv, &info.time);
|
||||
/*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);
|
||||
}
|
||||
|
||||
#ifdef LODEPNG_COMPILE_DISK
|
||||
#if defined(LODEPNG_COMPILE_DISK)
|
||||
unsigned lodepng_encode_file(const char* filename, const uint8_t* image, unsigned w, unsigned h,
|
||||
LodePNGColorType colortype, unsigned bitdepth)
|
||||
{
|
||||
|
@ -5945,7 +5945,7 @@ void lodepng_encoder_settings_init(LodePNGEncoderSettings* settings)
|
|||
settings->auto_convert = 1;
|
||||
settings->force_palette = 0;
|
||||
settings->predefined_filters = 0;
|
||||
#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS
|
||||
#if defined(LODEPNG_COMPILE_ANCILLARY_CHUNKS)
|
||||
settings->add_id = 0;
|
||||
settings->text_compression = 1;
|
||||
#endif /*LODEPNG_COMPILE_ANCILLARY_CHUNKS*/
|
||||
|
@ -5954,7 +5954,7 @@ void lodepng_encoder_settings_init(LodePNGEncoderSettings* settings)
|
|||
#endif /*LODEPNG_COMPILE_ENCODER*/
|
||||
#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
|
||||
the documentation of all the error codes.
|
||||
|
@ -6141,237 +6141,3 @@ const char* lodepng_error_text(unsigned code)
|
|||
return "unknown error code";
|
||||
}
|
||||
#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*/
|
||||
|
|
206
source/lodepng.h
206
source/lodepng.h
|
@ -41,52 +41,41 @@ allow implementing a custom lodepng_crc32.
|
|||
*/
|
||||
/*deflate & zlib. If disabled, you must specify alternative zlib functions in
|
||||
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
|
||||
#endif
|
||||
/*png encoder and png decoder*/
|
||||
#ifndef LODEPNG_NO_COMPILE_PNG
|
||||
#if !defined(LODEPNG_NO_COMPILE_PNG)
|
||||
#define LODEPNG_COMPILE_PNG
|
||||
#endif
|
||||
/*deflate&zlib decoder and png decoder*/
|
||||
#ifndef LODEPNG_NO_COMPILE_DECODER
|
||||
#if !defined(LODEPNG_NO_COMPILE_DECODER)
|
||||
#define LODEPNG_COMPILE_DECODER
|
||||
#endif
|
||||
/*deflate&zlib encoder and png encoder*/
|
||||
#ifndef LODEPNG_NO_COMPILE_ENCODER
|
||||
#if !defined(LODEPNG_NO_COMPILE_ENCODER)
|
||||
#define LODEPNG_COMPILE_ENCODER
|
||||
#endif
|
||||
/*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
|
||||
#endif
|
||||
/*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
|
||||
#endif
|
||||
/*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
|
||||
#endif
|
||||
/*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
|
||||
source files with custom allocators.*/
|
||||
#ifndef LODEPNG_NO_COMPILE_ALLOCATORS
|
||||
#if !defined(LODEPNG_NO_COMPILE_ALLOCATORS)
|
||||
#define LODEPNG_COMPILE_ALLOCATORS
|
||||
#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
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#endif /*LODEPNG_COMPILE_CPP*/
|
||||
|
||||
#ifdef LODEPNG_COMPILE_PNG
|
||||
#if defined(LODEPNG_COMPILE_PNG)
|
||||
/*The PNG color types (also used for raw).*/
|
||||
typedef enum LodePNGColorType
|
||||
{
|
||||
|
@ -97,7 +86,7 @@ typedef enum LodePNGColorType
|
|||
LCT_RGBA = 6 /*RGB with alpha: 8,16 bit*/
|
||||
} LodePNGColorType;
|
||||
|
||||
#ifdef LODEPNG_COMPILE_DECODER
|
||||
#if defined(LODEPNG_COMPILE_DECODER)
|
||||
/*
|
||||
Converts PNG data in memory to 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,
|
||||
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.
|
||||
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*/
|
||||
|
||||
|
||||
#ifdef LODEPNG_COMPILE_ENCODER
|
||||
#if defined(LODEPNG_COMPILE_ENCODER)
|
||||
/*
|
||||
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
|
||||
|
@ -174,7 +163,7 @@ unsigned lodepng_encode32(uint8_t** out, size_t* outsize,
|
|||
unsigned lodepng_encode24(uint8_t** out, size_t* outsize,
|
||||
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.
|
||||
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_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*/
|
||||
|
||||
#ifdef LODEPNG_COMPILE_ERROR_TEXT
|
||||
#if defined(LODEPNG_COMPILE_ERROR_TEXT)
|
||||
/*Returns an English description of the numerical error code.*/
|
||||
const char* lodepng_error_text(unsigned code);
|
||||
#endif /*LODEPNG_COMPILE_ERROR_TEXT*/
|
||||
|
||||
#ifdef LODEPNG_COMPILE_DECODER
|
||||
#if defined(LODEPNG_COMPILE_DECODER)
|
||||
/*Settings for zlib decompression*/
|
||||
typedef struct LodePNGDecompressSettings LodePNGDecompressSettings;
|
||||
struct LodePNGDecompressSettings
|
||||
|
@ -276,7 +216,7 @@ extern const LodePNGDecompressSettings lodepng_default_decompress_settings;
|
|||
void lodepng_decompress_settings_init(LodePNGDecompressSettings* settings);
|
||||
#endif /*LODEPNG_COMPILE_DECODER*/
|
||||
|
||||
#ifdef LODEPNG_COMPILE_ENCODER
|
||||
#if defined(LODEPNG_COMPILE_ENCODER)
|
||||
/*
|
||||
Settings for zlib compression. Tweaking these settings tweaks the balance
|
||||
between speed and compression ratio.
|
||||
|
@ -310,7 +250,7 @@ extern const LodePNGCompressSettings lodepng_default_compress_settings;
|
|||
void lodepng_compress_settings_init(LodePNGCompressSettings* settings);
|
||||
#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
|
||||
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*/
|
||||
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.*/
|
||||
typedef struct LodePNGTime
|
||||
{
|
||||
|
@ -413,7 +353,7 @@ typedef struct LodePNGInfo
|
|||
unsigned interlace_method; /*interlace method of the original 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)
|
||||
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)*/
|
||||
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*/
|
||||
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,
|
||||
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
|
||||
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*/
|
||||
|
||||
#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*/
|
||||
/*store all bytes from unknown chunks in the LodePNGInfo (off by default, useful for a png editor)*/
|
||||
unsigned remember_unknown_chunks;
|
||||
|
@ -538,7 +478,7 @@ typedef struct LodePNGDecoderSettings
|
|||
void lodepng_decoder_settings_init(LodePNGDecoderSettings* settings);
|
||||
#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*/
|
||||
typedef enum LodePNGFilterStrategy
|
||||
{
|
||||
|
@ -609,7 +549,7 @@ typedef struct LodePNGEncoderSettings
|
|||
/*force creating a PLTE chunk if colortype is 2 or 6 (= a suggested palette).
|
||||
If colortype is 3, PLTE is _always_ created.*/
|
||||
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*/
|
||||
unsigned add_id;
|
||||
/*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.*/
|
||||
typedef struct LodePNGState
|
||||
{
|
||||
#ifdef LODEPNG_COMPILE_DECODER
|
||||
#if defined(LODEPNG_COMPILE_DECODER)
|
||||
LodePNGDecoderSettings decoder; /*the decoding settings*/
|
||||
#endif /*LODEPNG_COMPILE_DECODER*/
|
||||
#ifdef LODEPNG_COMPILE_ENCODER
|
||||
#if defined(LODEPNG_COMPILE_ENCODER)
|
||||
LodePNGEncoderSettings encoder; /*the encoding settings*/
|
||||
#endif /*LODEPNG_COMPILE_ENCODER*/
|
||||
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*/
|
||||
unsigned error;
|
||||
#ifdef LODEPNG_COMPILE_CPP
|
||||
/* For the lodepng::State subclass. */
|
||||
virtual ~LodePNGState() {}
|
||||
#endif
|
||||
} LodePNGState;
|
||||
|
||||
/*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);
|
||||
#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
|
||||
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*/
|
||||
|
||||
|
||||
#ifdef LODEPNG_COMPILE_ENCODER
|
||||
#if defined(LODEPNG_COMPILE_ENCODER)
|
||||
/*This function allocates the out buffer with standard malloc and stores the size in *outsize.*/
|
||||
unsigned lodepng_encode(uint8_t** out, size_t* outsize,
|
||||
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*/
|
||||
|
||||
|
||||
#ifdef LODEPNG_COMPILE_ZLIB
|
||||
#if defined(LODEPNG_COMPILE_ZLIB)
|
||||
/*
|
||||
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
|
||||
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.*/
|
||||
unsigned lodepng_inflate(uint8_t** out, size_t* outsize,
|
||||
const uint8_t* in, size_t insize,
|
||||
|
@ -767,7 +703,7 @@ unsigned lodepng_zlib_decompress(uint8_t** out, size_t* outsize,
|
|||
const LodePNGDecompressSettings* settings);
|
||||
#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.
|
||||
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_ZLIB*/
|
||||
|
||||
#ifdef LODEPNG_COMPILE_DISK
|
||||
#if defined(LODEPNG_COMPILE_DISK)
|
||||
/*
|
||||
Load a file from disk into buffer. The function allocates the out buffer, and
|
||||
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);
|
||||
#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:
|
||||
[.] test if there are no memory leaks or security exploits - done a lot but needs to be checked often
|
||||
|
@ -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.
|
||||
|
||||
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
|
||||
ignore it, and the C code is made to compile both with strict ISO C90 and C++.
|
||||
the additional C++ code is in "#if defined(__cplusplus" blocks that make
|
||||
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
|
||||
(instead of lodepng.c), and compile it with a C++ compiler.
|
||||
|
|
|
@ -69,7 +69,7 @@ static quakeparms_t parms;
|
|||
|
||||
// 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.
|
||||
#if defined(__APPLE__)
|
||||
#if PLATFORM_IS(OSX)
|
||||
#define main SDL_main
|
||||
#endif
|
||||
|
||||
|
|
|
@ -29,8 +29,7 @@ vec3_t vec3_origin = {0, 0, 0};
|
|||
/*-----------------------------------------------------------------*/
|
||||
|
||||
|
||||
//#define DEG2RAD( a ) ( a * M_PI ) / 180.0F
|
||||
#define DEG2RAD( a ) ( (a) * M_PI_DIV_180 ) //johnfitz
|
||||
#define DEG2RAD( a ) ( (a) * PI_DIV_180 ) //johnfitz
|
||||
|
||||
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)
|
||||
sides |= 2;
|
||||
|
||||
#ifdef PARANOID
|
||||
#if defined(PARANOID)
|
||||
if(sides == 0)
|
||||
Sys_Error("BoxOnPlaneSide: sides==0");
|
||||
#endif
|
||||
|
@ -219,8 +218,8 @@ void VectorAngles(const vec3_t forward, vec3_t angles)
|
|||
temp[0] = forward[0];
|
||||
temp[1] = forward[1];
|
||||
temp[2] = 0;
|
||||
angles[PITCH] = -atan2(forward[2], VectorLength(temp)) / M_PI_DIV_180;
|
||||
angles[YAW] = atan2(forward[1], forward[0]) / M_PI_DIV_180;
|
||||
angles[PITCH] = -atan2(forward[2], VectorLength(temp)) / PI_DIV_180;
|
||||
angles[YAW] = atan2(forward[1], forward[0]) / PI_DIV_180;
|
||||
angles[ROLL] = 0;
|
||||
}
|
||||
|
||||
|
@ -229,13 +228,13 @@ void AngleVectors(vec3_t angles, vec3_t forward, vec3_t right, vec3_t up)
|
|||
float angle;
|
||||
float sr, sp, sy, cr, cp, cy;
|
||||
|
||||
angle = angles[YAW] * (M_PI * 2 / 360);
|
||||
angle = angles[YAW] * (PI * 2 / 360);
|
||||
sy = sin(angle);
|
||||
cy = cos(angle);
|
||||
angle = angles[PITCH] * (M_PI * 2 / 360);
|
||||
angle = angles[PITCH] * (PI * 2 / 360);
|
||||
sp = sin(angle);
|
||||
cp = cos(angle);
|
||||
angle = angles[ROLL] * (M_PI * 2 / 360);
|
||||
angle = angles[ROLL] * (PI * 2 / 360);
|
||||
sr = sin(angle);
|
||||
cr = cos(angle);
|
||||
|
||||
|
@ -427,7 +426,7 @@ void FloorDivMod(double numer, double denom, int32_t *quotient,
|
|||
int32_t q, r;
|
||||
double x;
|
||||
|
||||
#ifndef PARANOID
|
||||
#if !defined(PARANOID)
|
||||
if(denom <= 0.0)
|
||||
Sys_Error("FloorDivMod: bad denominator %f\n", denom);
|
||||
|
||||
|
|
|
@ -28,11 +28,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
#include <math.h>
|
||||
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.14159265358979323846 // matches value in gcc v2 math.h
|
||||
#endif
|
||||
|
||||
#define M_PI_DIV_180 (M_PI / 180.0) //johnfitz
|
||||
#define PI 3.14159265358979323846
|
||||
#define PI_DIV_180 (PI / 180.0) //johnfitz
|
||||
|
||||
struct mplane_s;
|
||||
|
||||
|
|
|
@ -988,10 +988,7 @@ enum
|
|||
OPT_ALWAYSMLOOK,
|
||||
OPT_LOOKSPRING,
|
||||
OPT_LOOKSTRAFE,
|
||||
//#ifdef _WIN32
|
||||
// OPT_USEMOUSE,
|
||||
//#endif
|
||||
OPT_VIDEO, // This is the last before OPTIONS_ITEMS
|
||||
OPT_VIDEO, // This is the last before OPTIONS_ITEMS
|
||||
OPTIONS_ITEMS
|
||||
};
|
||||
|
||||
|
|
|
@ -32,21 +32,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
// * 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_ONSEAM 0x0020
|
||||
|
|
|
@ -23,7 +23,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#define BAN_TEST
|
||||
|
||||
#include "q_stdinc.h"
|
||||
#include "arch_def.h"
|
||||
#include "net_sys.h"
|
||||
#include "quakedef.h"
|
||||
#include "net_defs.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 banMask;
|
||||
|
@ -135,7 +134,7 @@ int32_t Datagram_SendMessage(qsocket_t *sock, sizebuf_t *data)
|
|||
uint32_t dataLen;
|
||||
uint32_t eom;
|
||||
|
||||
#ifdef DEBUG
|
||||
#if defined(DEBUG)
|
||||
if(data->cursize == 0)
|
||||
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;
|
||||
|
||||
#ifdef DEBUG
|
||||
#if defined(DEBUG)
|
||||
if(data->cursize == 0)
|
||||
Sys_Error("Datagram_SendUnreliableMessage: zero length message\n");
|
||||
|
||||
|
@ -788,7 +787,7 @@ int32_t Datagram_Init(void)
|
|||
int32_t i, num_inited;
|
||||
sys_socket_t csock;
|
||||
|
||||
#ifdef BAN_TEST
|
||||
#if defined(BAN_TEST)
|
||||
banAddr.s_addr = INADDR_ANY;
|
||||
banMask.s_addr = INADDR_NONE;
|
||||
#endif
|
||||
|
@ -813,7 +812,7 @@ int32_t Datagram_Init(void)
|
|||
if(num_inited == 0)
|
||||
return -1;
|
||||
|
||||
#ifdef BAN_TEST
|
||||
#if defined(BAN_TEST)
|
||||
Cmd_AddCommand("ban", NET_Ban_f);
|
||||
#endif
|
||||
Cmd_AddCommand("test", Test_f);
|
||||
|
@ -1001,7 +1000,7 @@ static qsocket_t *_Datagram_CheckNewConnections(void)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
#ifdef BAN_TEST
|
||||
#if defined(BAN_TEST)
|
||||
// check for a ban
|
||||
if(clientaddr.qsa_family == AF_INET)
|
||||
{
|
||||
|
|
|
@ -20,7 +20,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
*/
|
||||
|
||||
#include "q_stdinc.h"
|
||||
#include "arch_def.h"
|
||||
#include "net_sys.h"
|
||||
#include "quakedef.h"
|
||||
#include "net_defs.h"
|
||||
|
|
|
@ -20,7 +20,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
*/
|
||||
|
||||
#include "q_stdinc.h"
|
||||
#include "arch_def.h"
|
||||
#include "net_sys.h"
|
||||
#include "quakedef.h"
|
||||
#include "net_defs.h"
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
/*
|
||||
* 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>
|
||||
*
|
||||
|
@ -29,9 +27,7 @@
|
|||
#include <stddef.h>
|
||||
#include <limits.h>
|
||||
|
||||
#if defined(PLATFORM_BSD) || defined(PLATFORM_OSX) || \
|
||||
defined(PLATFORM_AMIGA) /* bsdsocket.library */ || \
|
||||
defined(__GNU__) /* GNU/Hurd */ || defined(__riscos__)
|
||||
#if PLATFORM_IS(BSD) || PLATFORM_IS(OSX)
|
||||
/* 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
|
||||
* uint16_t. This should matter only when PLATFORM_UNIX is defined,
|
||||
|
@ -47,14 +43,9 @@
|
|||
#endif /* BSD, sockaddr */
|
||||
|
||||
/* unix includes and compatibility macros */
|
||||
#if defined(PLATFORM_UNIX) || defined(PLATFORM_RISCOS)
|
||||
|
||||
#if PLATFORM_IS_UNIX
|
||||
#include <sys/param.h>
|
||||
#include <sys/ioctl.h>
|
||||
#if defined(__sun) || defined(sun)
|
||||
#include <sys/filio.h>
|
||||
#include <sys/sockio.h>
|
||||
#endif /* __sunos__ */
|
||||
#include <unistd.h>
|
||||
#include <sys/socket.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,
|
||||
"HAVE_SA_LEN not defined correctly");
|
||||
|
||||
#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 */
|
||||
|
||||
#endif /* PLATFORM_IS_UNIX */
|
||||
|
||||
/* windows includes and compatibility macros */
|
||||
#if defined(PLATFORM_WINDOWS)
|
||||
#if PLATFORM_IS(WINDOWS)
|
||||
|
||||
/* NOTE: winsock[2].h already includes windows.h */
|
||||
#if !defined(_USE_WINSOCK2)
|
||||
|
|
|
@ -192,7 +192,7 @@ static void SetMinMaxSize(edict_t *e, float *minvec, float *maxvec, bool rotate)
|
|||
// find min / max for rotations
|
||||
angles = e->v.angles;
|
||||
|
||||
a = angles[1] / 180 * M_PI;
|
||||
a = angles[1] / 180 * PI;
|
||||
|
||||
xvector[0] = cos(a);
|
||||
xvector[1] = sin(a);
|
||||
|
@ -455,7 +455,7 @@ static void PF_vectoyaw(void)
|
|||
yaw = 0;
|
||||
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)
|
||||
yaw += 360;
|
||||
}
|
||||
|
@ -489,12 +489,12 @@ static void PF_vectoangles(void)
|
|||
}
|
||||
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)
|
||||
yaw += 360;
|
||||
|
||||
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)
|
||||
pitch += 360;
|
||||
}
|
||||
|
@ -1175,7 +1175,7 @@ static void PF_walkmove(void)
|
|||
return;
|
||||
}
|
||||
|
||||
yaw = yaw * M_PI * 2 / 360;
|
||||
yaw = yaw * PI * 2 / 360;
|
||||
|
||||
move[0] = cos(yaw) * dist;
|
||||
move[1] = sin(yaw) * dist;
|
||||
|
|
|
@ -534,7 +534,7 @@ void PR_ExecuteProgram(func_t fnum)
|
|||
|
||||
case OP_ADDRESS:
|
||||
ed = PROG_TO_EDICT(OPA->edict);
|
||||
#ifdef PARANOID
|
||||
#if defined(PARANOID)
|
||||
NUM_FOR_EDICT(ed); // Make sure it's in range
|
||||
#endif
|
||||
if(ed == (edict_t *)sv.edicts && sv.state == ss_active)
|
||||
|
@ -551,7 +551,7 @@ void PR_ExecuteProgram(func_t fnum)
|
|||
case OP_LOAD_S:
|
||||
case OP_LOAD_FNC:
|
||||
ed = PROG_TO_EDICT(OPA->edict);
|
||||
#ifdef PARANOID
|
||||
#if defined(PARANOID)
|
||||
NUM_FOR_EDICT(ed); // Make sure it's in range
|
||||
#endif
|
||||
OPC->_int = ((eval_t *)((int32_t *)&ed->v + OPB->_int))->_int;
|
||||
|
@ -559,7 +559,7 @@ void PR_ExecuteProgram(func_t fnum)
|
|||
|
||||
case OP_LOAD_V:
|
||||
ed = PROG_TO_EDICT(OPA->edict);
|
||||
#ifdef PARANOID
|
||||
#if defined(PARANOID)
|
||||
NUM_FOR_EDICT(ed); // Make sure it's in range
|
||||
#endif
|
||||
ptr = (eval_t *)((int32_t *)&ed->v + OPB->_int);
|
||||
|
|
|
@ -131,9 +131,6 @@ extern int32_t pr_xstatement;
|
|||
extern uint16_t pr_crc;
|
||||
|
||||
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_PrintNum(int32_t ent);
|
||||
|
|
|
@ -29,6 +29,8 @@
|
|||
#ifndef __QSTDINC_H
|
||||
#define __QSTDINC_H
|
||||
|
||||
#include "arch_def.h"
|
||||
|
||||
#include <limits.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
|
@ -40,7 +42,7 @@
|
|||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifndef _WIN32
|
||||
#if !PLATFORM_IS(WINDOWS)
|
||||
#include <sys/param.h>
|
||||
#endif
|
||||
|
||||
|
@ -70,28 +72,28 @@ typedef vec_t vec5_t[5];
|
|||
#if !defined(PATH_MAX)
|
||||
/* equivalent values? */
|
||||
#if defined(MAXPATHLEN)
|
||||
#define PATH_MAX MAXPATHLEN
|
||||
#elif defined(_WIN32) && defined(_MAX_PATH)
|
||||
#define PATH_MAX _MAX_PATH
|
||||
#elif defined(_WIN32) && defined(MAX_PATH)
|
||||
#define PATH_MAX MAX_PATH
|
||||
#else /* fallback */
|
||||
#define PATH_MAX 1024
|
||||
#define PATH_MAX MAXPATHLEN
|
||||
#elif defined(_MAX_PATH)
|
||||
#define PATH_MAX _MAX_PATH
|
||||
#elif defined(MAX_PATH)
|
||||
#define PATH_MAX MAX_PATH
|
||||
#else
|
||||
#error "no PATH_MAX available"
|
||||
#endif
|
||||
#endif
|
||||
#endif /* PATH_MAX */
|
||||
|
||||
#define MAX_OSPATH PATH_MAX
|
||||
|
||||
/* function attributes, etc */
|
||||
#if defined(__GNUC__)
|
||||
#if PLATFORM_IS_GNUC
|
||||
#define FUNC_PRINTF(x,y) __attribute__((__format__(__printf__,x,y)))
|
||||
#else
|
||||
#define FUNC_PRINTF(x,y)
|
||||
#endif
|
||||
|
||||
/* argument format attributes for function pointers are supported for gcc >= 3.1 */
|
||||
#if defined(__GNUC__) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 0))
|
||||
#define FUNCP_PRINTF FUNC_PRINTF
|
||||
#if PLATFORM_IS_GNUC >= 3
|
||||
#define FUNCP_PRINTF FUNC_PRINTF
|
||||
#else
|
||||
#define FUNCP_PRINTF(x,y)
|
||||
#endif
|
||||
|
|
|
@ -202,9 +202,6 @@ typedef struct
|
|||
#include "platform.h"
|
||||
#include <SDL.h>
|
||||
#include <SDL_opengl.h>
|
||||
#ifndef APIENTRY
|
||||
#define APIENTRY
|
||||
#endif
|
||||
|
||||
#include "console.h"
|
||||
#include "wad.h"
|
||||
|
@ -272,10 +269,6 @@ void Host_Shutdown(void);
|
|||
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_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_Quit_f(void);
|
||||
void Host_ClientCommands(const char *fmt, ...) FUNC_PRINTF(1, 2);
|
||||
|
|
|
@ -124,7 +124,7 @@ void R_DrawSpriteModel(entity_t *e)
|
|||
s_right = v_right;
|
||||
break;
|
||||
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);
|
||||
cr = cos(angle);
|
||||
v_right[0] = vright[0] * cr + vup[0] * sr;
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#if defined(APSTUDIO_INVOKED)
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 113
|
||||
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||
|
|
|
@ -62,19 +62,19 @@ void S_CodecInit(void)
|
|||
/* Register in the inverse order
|
||||
* of codec choice preference: */
|
||||
S_CodecRegister(&umx_codec);
|
||||
#ifdef USE_CODEC_MIKMOD
|
||||
#if defined(USE_CODEC_MIKMOD)
|
||||
S_CodecRegister(&mikmod_codec);
|
||||
#endif
|
||||
#ifdef USE_CODEC_FLAC
|
||||
#if defined(USE_CODEC_FLAC)
|
||||
S_CodecRegister(&flac_codec);
|
||||
#endif
|
||||
#ifdef USE_CODEC_OPUS
|
||||
#if defined(USE_CODEC_OPUS)
|
||||
S_CodecRegister(&opus_codec);
|
||||
#endif
|
||||
#ifdef USE_CODEC_VORBIS
|
||||
#if defined(USE_CODEC_VORBIS)
|
||||
S_CodecRegister(&vorbis_codec);
|
||||
#endif
|
||||
#ifdef USE_CODEC_MP3
|
||||
#if defined(USE_CODEC_MP3)
|
||||
S_CodecRegister(&mp3_codec);
|
||||
#endif
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ cvar_t loadas8bit = {"loadas8bit", "0", CVAR_NONE};
|
|||
cvar_t sndspeed = {"sndspeed", "11025", CVAR_NONE};
|
||||
cvar_t snd_mixspeed = {"snd_mixspeed", "44100", CVAR_NONE};
|
||||
|
||||
#if defined(_WIN32)
|
||||
#if PLATFORM_IS(WINDOWS)
|
||||
#define SND_FILTERQUALITY_DEFAULT "5"
|
||||
#else
|
||||
#define SND_FILTERQUALITY_DEFAULT "1"
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
#include <FLAC/seekable_stream_decoder.h>
|
||||
#endif
|
||||
|
||||
#ifdef LEGACY_FLAC
|
||||
#if defined(LEGACY_FLAC)
|
||||
#define FLAC__StreamDecoder FLAC__SeekableStreamDecoder
|
||||
#define FLAC__StreamDecoderReadStatus FLAC__SeekableStreamDecoderReadStatus
|
||||
#define FLAC__StreamDecoderSeekStatus FLAC__SeekableStreamDecoderSeekStatus
|
||||
|
@ -263,7 +263,7 @@ static bool S_FLAC_CodecOpenStream(snd_stream_t *stream)
|
|||
ff->file = & stream->fh;
|
||||
ff->info->dataofs = -1; /* check for STREAMINFO metadata existence */
|
||||
|
||||
#ifdef LEGACY_FLAC
|
||||
#if defined(LEGACY_FLAC)
|
||||
FLAC__seekable_stream_decoder_set_error_callback(ff->decoder, flac_error_func);
|
||||
FLAC__seekable_stream_decoder_set_read_callback(ff->decoder, flac_read_func);
|
||||
FLAC__seekable_stream_decoder_set_seek_callback(ff->decoder, flac_seek_func);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* fLaC streaming music support. */
|
||||
|
||||
#if !defined(_SND_FLAC_H_)
|
||||
#ifndef _SND_FLAC_H_
|
||||
#define _SND_FLAC_H_ 1
|
||||
|
||||
#if defined(USE_CODEC_FLAC)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* module tracker decoding support using libmikmod */
|
||||
|
||||
#if !defined(_SND_MIKMOD_H_)
|
||||
#ifndef _SND_MIKMOD_H_
|
||||
#define _SND_MIKMOD_H_
|
||||
|
||||
#if defined(USE_CODEC_MIKMOD)
|
||||
|
|
|
@ -169,13 +169,13 @@ static void S_MakeBlackmanWindowKernel(float *kernel, int32_t M, float f_c)
|
|||
{
|
||||
if(i == M / 2)
|
||||
{
|
||||
kernel[i] = 2 * M_PI * f_c;
|
||||
kernel[i] = 2 * PI * f_c;
|
||||
}
|
||||
else
|
||||
{
|
||||
kernel[i] = (sin(2 * M_PI * f_c * (i - M / 2.0)) / (i - (M / 2.0)))
|
||||
* (0.42 - 0.5 * cos(2 * M_PI * i / (double)M)
|
||||
+ 0.08 * cos(4 * M_PI * i / (double)M));
|
||||
kernel[i] = (sin(2 * PI * f_c * (i - M / 2.0)) / (i - (M / 2.0))) *
|
||||
(0.42 - 0.5 * cos(2 * PI * i / (double)M) +
|
||||
0.08 * cos(4 * PI * i / (double)M));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* MP3 decoding support using libmad or libmpg123. */
|
||||
|
||||
#if !defined(_SND_MP3_H_)
|
||||
#ifndef _SND_MP3_H_
|
||||
#define _SND_MP3_H_
|
||||
|
||||
#if defined(USE_CODEC_MP3)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* Ogg/Opus streaming music support. */
|
||||
|
||||
#if !defined(_SND_OPUS_H_)
|
||||
#ifndef _SND_OPUS_H_
|
||||
#define _SND_OPUS_H_ 1
|
||||
|
||||
#if defined(USE_CODEC_OPUS)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* Unreal UMX format support */
|
||||
#if !defined(_SND_UMX_H_)
|
||||
#ifndef _SND_UMX_H_
|
||||
#define _SND_UMX_H_
|
||||
|
||||
extern snd_codec_t umx_codec;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* Ogg/Vorbis streaming music support. */
|
||||
|
||||
#if !defined(_SND_VORBIS_H_)
|
||||
#ifndef _SND_VORBIS_H_
|
||||
#define _SND_VORBIS_H_ 1
|
||||
|
||||
#if defined(USE_CODEC_VORBIS)
|
||||
|
|
|
@ -47,22 +47,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
// <endrepeat>
|
||||
//-------------------------------------------------------
|
||||
|
||||
#ifdef INCLUDELIBS
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "cmdlib.h"
|
||||
#include "scriplib.h"
|
||||
#include "dictlib.h"
|
||||
#include "trilib.h"
|
||||
#include "lbmlib.h"
|
||||
#include "mathlib.h"
|
||||
|
||||
#endif
|
||||
|
||||
#define SPRITE_VERSION 1
|
||||
|
||||
// must match definition in modelgen.h
|
||||
|
|
|
@ -126,17 +126,13 @@ LICENSE
|
|||
#ifndef INCLUDE_STB_IMAGE_WRITE_H
|
||||
#define INCLUDE_STB_IMAGE_WRITE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef STB_IMAGE_WRITE_STATIC
|
||||
#if defined(STB_IMAGE_WRITE_STATIC)
|
||||
#define STBIWDEF static
|
||||
#else
|
||||
#define STBIWDEF extern
|
||||
#endif
|
||||
|
||||
#ifndef STBI_WRITE_NO_STDIO
|
||||
#if !defined(STBI_WRITE_NO_STDIO)
|
||||
STBIWDEF int32_t stbi_write_jpg(char const *filename, int32_t x, int32_t y, int32_t comp, const void *data, int32_t quality);
|
||||
#endif
|
||||
|
||||
|
@ -146,24 +142,20 @@ typedef void stbi_write_func(void *context, void *data, int32_t size);
|
|||
STBIWDEF int32_t stbi_write_jpg_to_func(stbi_write_func *func, void *context, int32_t x, int32_t y, int32_t comp, const void *data, int32_t quality);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif//INCLUDE_STB_IMAGE_WRITE_H
|
||||
|
||||
#ifdef STB_IMAGE_WRITE_IMPLEMENTATION
|
||||
#if defined(STB_IMAGE_WRITE_IMPLEMENTATION)
|
||||
|
||||
#ifdef _WIN32
|
||||
#ifndef _CRT_SECURE_NO_WARNINGS
|
||||
#if defined(_WIN32)
|
||||
#if !defined(_CRT_SECURE_NO_WARNINGS)
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#endif
|
||||
#ifndef _CRT_NONSTDC_NO_DEPRECATE
|
||||
#if !defined(_CRT_NONSTDC_NO_DEPRECATE)
|
||||
#define _CRT_NONSTDC_NO_DEPRECATE
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef STBI_WRITE_NO_STDIO
|
||||
#if !defined(STBI_WRITE_NO_STDIO)
|
||||
#include <stdio.h>
|
||||
#endif // STBI_WRITE_NO_STDIO
|
||||
|
||||
|
@ -180,23 +172,23 @@ STBIWDEF int32_t stbi_write_jpg_to_func(stbi_write_func *func, void *context, in
|
|||
#error "Must define all or none of STBIW_MALLOC, STBIW_FREE, and STBIW_REALLOC (or STBIW_REALLOC_SIZED)."
|
||||
#endif
|
||||
|
||||
#ifndef STBIW_MALLOC
|
||||
#if !defined(STBIW_MALLOC)
|
||||
#define STBIW_MALLOC(sz) malloc(sz)
|
||||
#define STBIW_REALLOC(p,newsz) realloc(p,newsz)
|
||||
#define STBIW_FREE(p) free(p)
|
||||
#endif
|
||||
|
||||
#ifndef STBIW_REALLOC_SIZED
|
||||
#if !defined(STBIW_REALLOC_SIZED)
|
||||
#define STBIW_REALLOC_SIZED(p,oldsz,newsz) STBIW_REALLOC(p,newsz)
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef STBIW_MEMMOVE
|
||||
#if !defined(STBIW_MEMMOVE)
|
||||
#define STBIW_MEMMOVE(a,b,sz) memmove(a,b,sz)
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef STBIW_ASSERT
|
||||
#if !defined(STBIW_ASSERT)
|
||||
#include <assert.h>
|
||||
#define STBIW_ASSERT(x) assert(x)
|
||||
#endif
|
||||
|
@ -216,7 +208,7 @@ static void stbi__start_write_callbacks(stbi__write_context *s, stbi_write_func
|
|||
s->context = context;
|
||||
}
|
||||
|
||||
#ifndef STBI_WRITE_NO_STDIO
|
||||
#if !defined(STBI_WRITE_NO_STDIO)
|
||||
|
||||
static void stbi__stdio_write(void *context, void *data, int32_t size)
|
||||
{
|
||||
|
@ -629,7 +621,7 @@ STBIWDEF int32_t stbi_write_jpg_to_func(stbi_write_func *func, void *context, in
|
|||
#endif
|
||||
|
||||
|
||||
#ifndef STBI_WRITE_NO_STDIO
|
||||
#if !defined(STBI_WRITE_NO_STDIO)
|
||||
STBIWDEF int32_t stbi_write_jpg(char const *filename, int32_t x, int32_t y, int32_t comp, const void *data, int32_t quality)
|
||||
{
|
||||
stbi__write_context s;
|
||||
|
|
|
@ -241,7 +241,7 @@ bool SV_StepDirection(edict_t *ent, float yaw, float dist)
|
|||
ent->v.ideal_yaw = yaw;
|
||||
PF_changeyaw();
|
||||
|
||||
yaw = yaw * M_PI * 2 / 360;
|
||||
yaw = yaw * PI * 2 / 360;
|
||||
move[0] = cos(yaw) * dist;
|
||||
move[1] = sin(yaw) * dist;
|
||||
move[2] = 0;
|
||||
|
|
|
@ -61,7 +61,7 @@ void SV_SetIdealPitch(void)
|
|||
if(!((int32_t)sv_player->v.flags & FL_ONGROUND))
|
||||
return;
|
||||
|
||||
angleval = sv_player->v.angles[YAW] * M_PI * 2 / 360;
|
||||
angleval = sv_player->v.angles[YAW] * PI * 2 / 360;
|
||||
sinval = sin(angleval);
|
||||
cosval = cos(angleval);
|
||||
|
||||
|
|
|
@ -48,10 +48,6 @@ void Sys_mkdir(const char *path);
|
|||
noreturn void Sys_Quit(void);
|
||||
noreturn void Sys_Error(const char *error, ...) FUNC_PRINTF(1, 2);
|
||||
// an error will cause the entire program to exit
|
||||
#ifdef __WATCOMC__
|
||||
#pragma aux Sys_Error aborts;
|
||||
#pragma aux Sys_Quit aborts;
|
||||
#endif
|
||||
|
||||
void Sys_Printf(const char *fmt, ...) FUNC_PRINTF(1, 2);
|
||||
// send text to the console
|
||||
|
|
|
@ -20,7 +20,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
*/
|
||||
|
||||
#include "q_stdinc.h"
|
||||
#include "arch_def.h"
|
||||
#include "net_sys.h"
|
||||
#include "quakedef.h"
|
||||
#include "net_defs.h"
|
||||
|
|
|
@ -21,7 +21,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
*/
|
||||
|
||||
#include "q_stdinc.h"
|
||||
#include "arch_def.h"
|
||||
#include "net_sys.h"
|
||||
#include "quakedef.h"
|
||||
#include "net_defs.h"
|
||||
|
@ -59,7 +58,7 @@ sys_socket_t UDP_Init(void)
|
|||
else
|
||||
{
|
||||
buff[MAXHOSTNAMELEN - 1] = 0;
|
||||
#ifdef PLATFORM_OSX
|
||||
#if PLATFORM_IS(OSX)
|
||||
// ericw -- if our hostname ends in ".local" (a macOS thing),
|
||||
// don't bother calling gethostbyname(), because it blocks for a few seconds
|
||||
// and then fails (on my system anyway.)
|
||||
|
|
|
@ -21,13 +21,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
*/
|
||||
|
||||
#include "arch_def.h"
|
||||
#include "quakedef.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#ifdef PLATFORM_OSX
|
||||
#if PLATFORM_IS(OSX)
|
||||
#include <libgen.h> /* dirname() and basename() */
|
||||
#endif
|
||||
#include <sys/stat.h>
|
||||
|
@ -145,29 +144,24 @@ int32_t Sys_FileTime(const char *path)
|
|||
}
|
||||
|
||||
|
||||
#if defined(__linux__) || defined(__sun) || defined(sun) || defined(_AIX)
|
||||
#if PLATFORM_IS(LINUX)
|
||||
static int32_t Sys_NumCPUs(void)
|
||||
{
|
||||
int32_t numcpus = sysconf(_SC_NPROCESSORS_ONLN);
|
||||
return (numcpus < 1) ? 1 : numcpus;
|
||||
}
|
||||
|
||||
#elif defined(PLATFORM_OSX)
|
||||
#elif PLATFORM_IS(OSX)
|
||||
#include <sys/sysctl.h>
|
||||
#if !defined(HW_AVAILCPU) /* using an ancient SDK? */
|
||||
#define HW_AVAILCPU 25 /* needs >= 10.2 */
|
||||
#endif
|
||||
|
||||
static int32_t Sys_NumCPUs(void)
|
||||
{
|
||||
int32_t numcpus;
|
||||
int32_t mib[2];
|
||||
size_t len;
|
||||
|
||||
#if defined(_SC_NPROCESSORS_ONLN) /* needs >= 10.5 */
|
||||
numcpus = sysconf(_SC_NPROCESSORS_ONLN);
|
||||
if(numcpus != -1)
|
||||
return (numcpus < 1) ? 1 : numcpus;
|
||||
#endif
|
||||
len = sizeof(numcpus);
|
||||
mib[0] = CTL_HW;
|
||||
mib[1] = HW_AVAILCPU;
|
||||
|
@ -180,17 +174,7 @@ static int32_t Sys_NumCPUs(void)
|
|||
}
|
||||
return (numcpus < 1) ? 1 : numcpus;
|
||||
}
|
||||
|
||||
#elif defined(__sgi) || defined(sgi) || defined(__sgi__) /* IRIX */
|
||||
static int32_t Sys_NumCPUs(void)
|
||||
{
|
||||
int32_t numcpus = sysconf(_SC_NPROC_ONLN);
|
||||
if(numcpus < 1)
|
||||
numcpus = 1;
|
||||
return numcpus;
|
||||
}
|
||||
|
||||
#elif defined(PLATFORM_BSD)
|
||||
#elif PLATFORM_IS(BSD)
|
||||
#include <sys/sysctl.h>
|
||||
static int32_t Sys_NumCPUs(void)
|
||||
{
|
||||
|
@ -198,11 +182,9 @@ static int32_t Sys_NumCPUs(void)
|
|||
int32_t mib[2];
|
||||
size_t len;
|
||||
|
||||
#if defined(_SC_NPROCESSORS_ONLN)
|
||||
numcpus = sysconf(_SC_NPROCESSORS_ONLN);
|
||||
if(numcpus != -1)
|
||||
return (numcpus < 1) ? 1 : numcpus;
|
||||
#endif
|
||||
len = sizeof(numcpus);
|
||||
mib[0] = CTL_HW;
|
||||
mib[1] = HW_NCPU;
|
||||
|
@ -210,16 +192,7 @@ static int32_t Sys_NumCPUs(void)
|
|||
return 1;
|
||||
return (numcpus < 1) ? 1 : numcpus;
|
||||
}
|
||||
|
||||
#elif defined(__hpux) || defined(__hpux__) || defined(_hpux)
|
||||
#include <sys/mpctl.h>
|
||||
static int32_t Sys_NumCPUs(void)
|
||||
{
|
||||
int32_t numcpus = mpctl(MPC_GETNUMSPUS, NULL, NULL);
|
||||
return numcpus;
|
||||
}
|
||||
|
||||
#else /* unknown OS */
|
||||
#else
|
||||
static int32_t Sys_NumCPUs(void)
|
||||
{
|
||||
return -2;
|
||||
|
@ -244,11 +217,11 @@ static char const *Sys_GetHomeDir(void)
|
|||
static char const *Sys_GetUserDir(void)
|
||||
{
|
||||
static char user_dir[MAX_OSPATH];
|
||||
static char app_name[] = "AGWQuake";
|
||||
static char app_name[] = "spingle";
|
||||
|
||||
char const *home_dir;
|
||||
|
||||
#ifdef PLATFORM_OSX
|
||||
#if PLATFORM_IS(OSX)
|
||||
if(!(home_dir = Sys_GetHomeDir()))
|
||||
return NULL;
|
||||
|
||||
|
@ -269,7 +242,7 @@ static char const *Sys_GetUserDir(void)
|
|||
return user_dir;
|
||||
}
|
||||
|
||||
#ifdef PLATFORM_OSX
|
||||
#if PLATFORM_IS(OSX)
|
||||
static char *OSX_StripAppBundle(char *dir)
|
||||
{
|
||||
/* based on the ioquake3 project at icculus.org. */
|
||||
|
|
|
@ -119,9 +119,9 @@ float V_CalcBob(void)
|
|||
cycle = cl.time - (int32_t)(cl.time / cl_bobcycle.value) * cl_bobcycle.value;
|
||||
cycle /= cl_bobcycle.value;
|
||||
if(cycle < cl_bobup.value)
|
||||
cycle = M_PI * cycle / cl_bobup.value;
|
||||
cycle = PI * cycle / cl_bobup.value;
|
||||
else
|
||||
cycle = M_PI + M_PI * (cycle - cl_bobup.value) / (1.0 - cl_bobup.value);
|
||||
cycle = PI + PI * (cycle - cl_bobup.value) / (1.0 - cl_bobup.value);
|
||||
|
||||
// bob is proportional to velocity in the xy plane
|
||||
// (don't count Z, or jumping messes it up)
|
||||
|
|
|
@ -20,7 +20,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
*/
|
||||
|
||||
#include "q_stdinc.h"
|
||||
#include "arch_def.h"
|
||||
#include "net_sys.h"
|
||||
#include "quakedef.h"
|
||||
#include "net_defs.h"
|
||||
|
|
|
@ -19,7 +19,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
*/
|
||||
|
||||
#include "q_stdinc.h"
|
||||
#include "arch_def.h"
|
||||
#include "net_sys.h"
|
||||
#include "quakedef.h"
|
||||
#include "net_defs.h"
|
||||
|
@ -89,13 +88,13 @@ static void WINS_GetLocalAddress(void)
|
|||
}
|
||||
|
||||
buff[MAXHOSTNAMELEN - 1] = 0;
|
||||
#ifndef _USE_WINSOCK2
|
||||
#if !defined(_USE_WINSOCK2)
|
||||
blocktime = Sys_DoubleTime();
|
||||
WSASetBlockingHook(BlockingHook);
|
||||
#endif
|
||||
local = gethostbyname(buff);
|
||||
err = WSAGetLastError();
|
||||
#ifndef _USE_WINSOCK2
|
||||
#if !defined(_USE_WINSOCK2)
|
||||
WSAUnhookBlockingHook();
|
||||
#endif
|
||||
if(local == NULL)
|
||||
|
|
|
@ -22,7 +22,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
// net_wipx.c
|
||||
|
||||
#include "q_stdinc.h"
|
||||
#include "arch_def.h"
|
||||
#include "net_sys.h"
|
||||
#include <wsipx.h>
|
||||
#include "quakedef.h"
|
||||
|
|
|
@ -46,7 +46,7 @@ void PL_SetWindowIcon(void)
|
|||
return; /* wrong SDL version */
|
||||
|
||||
hwnd = wminfo.info.win.window;
|
||||
#ifdef _WIN64
|
||||
#if defined(_WIN64)
|
||||
SetClassLongPtr(hwnd, GCLP_HICON, (LONG_PTR) icon);
|
||||
#else
|
||||
SetClassLong(hwnd, GCL_HICON, (LONG) icon);
|
||||
|
|
|
@ -21,9 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
*/
|
||||
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#endif
|
||||
#include <windows.h>
|
||||
#include <mmsystem.h>
|
||||
|
||||
|
|
|
@ -685,7 +685,7 @@ bool SV_RecursiveHullCheck(hull_t *hull, int32_t num, float p1f, float p2f, vec3
|
|||
if(!SV_RecursiveHullCheck(hull, node->children[side], p1f, midf, p1, mid, trace))
|
||||
return false;
|
||||
|
||||
#ifdef PARANOID
|
||||
#if defined(PARANOID)
|
||||
if(SV_HullPointContents(sv_hullmodel, mid, node->children[side])
|
||||
== CONTENTS_SOLID)
|
||||
{
|
||||
|
|
|
@ -433,7 +433,7 @@ void *Hunk_AllocName(int32_t size, const char *name)
|
|||
{
|
||||
hunk_t *h;
|
||||
|
||||
#ifdef PARANOID
|
||||
#if defined(PARANOID)
|
||||
Hunk_Check();
|
||||
#endif
|
||||
|
||||
|
@ -525,7 +525,7 @@ void *Hunk_HighAllocName(int32_t size, const char *name)
|
|||
hunk_tempactive = false;
|
||||
}
|
||||
|
||||
#ifdef PARANOID
|
||||
#if defined(PARANOID)
|
||||
Hunk_Check();
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in New Issue