├── shared ├── pch.cpp ├── cube.h ├── igame.h └── tools.cpp ├── engine ├── pch.cpp ├── bih.h ├── glare.cpp ├── world.h ├── model.h ├── lightmap.h ├── lightning.h ├── scale.h ├── sdl2_keymap_extrakeys.h └── lensflare.h ├── fpsgame ├── pch.cpp ├── extinfo.h └── movable.cpp ├── lib ├── SDL2.lib ├── enet.lib ├── zdll.lib ├── SDL2_image.lib └── SDL2_mixer.lib ├── lib64 ├── SDL2.lib ├── enet.lib ├── zdll.lib ├── SDL2_image.lib └── SDL2_mixer.lib ├── vcpp ├── cube2.ico ├── mingw.rc ├── sauerbraten.rc ├── dpiaware.manifest ├── sauerbraten.sln └── sauerbraten.nsi ├── include ├── SDL_revision.h ├── SDL_copying.h ├── SDL_opengles2_gl2platform.h ├── SDL_types.h ├── SDL_name.h ├── SDL_opengles.h ├── close_code.h ├── SDL_opengles2.h ├── SDL_clipboard.h ├── SDL_quit.h ├── SDL_blendmode.h ├── SDL_gesture.h ├── SDL_error.h ├── SDL_touch.h ├── SDL_power.h ├── SDL_bits.h ├── SDL_loadso.h ├── SDL_timer.h ├── SDL.h ├── begin_code.h ├── SDL_cpuinfo.h ├── SDL_rect.h ├── SDL_messagebox.h ├── SDL_main.h ├── SDL_platform.h ├── SDL_filesystem.h ├── SDL_version.h ├── SDL_config_macosx.h ├── SDL_shape.h ├── SDL_config_windows.h ├── SDL_image.h ├── SDL_config.h └── SDL_endian.h ├── .gitignore ├── enet ├── include │ └── enet │ │ ├── utility.h │ │ ├── types.h │ │ ├── time.h │ │ ├── callbacks.h │ │ ├── list.h │ │ ├── unix.h │ │ ├── win32.h │ │ └── protocol.h ├── README ├── Makefile ├── LICENSE ├── callbacks.c ├── check_cflags.sh ├── list.c └── packet.c ├── README.md └── readme_source.txt /shared/pch.cpp: -------------------------------------------------------------------------------- 1 | #include "cube.h" 2 | -------------------------------------------------------------------------------- /engine/pch.cpp: -------------------------------------------------------------------------------- 1 | #include "engine.h" 2 | 3 | -------------------------------------------------------------------------------- /fpsgame/pch.cpp: -------------------------------------------------------------------------------- 1 | #include "game.h" 2 | 3 | -------------------------------------------------------------------------------- /lib/SDL2.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/extra-a/sauer-sdl2/HEAD/lib/SDL2.lib -------------------------------------------------------------------------------- /lib/enet.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/extra-a/sauer-sdl2/HEAD/lib/enet.lib -------------------------------------------------------------------------------- /lib/zdll.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/extra-a/sauer-sdl2/HEAD/lib/zdll.lib -------------------------------------------------------------------------------- /lib64/SDL2.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/extra-a/sauer-sdl2/HEAD/lib64/SDL2.lib -------------------------------------------------------------------------------- /lib64/enet.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/extra-a/sauer-sdl2/HEAD/lib64/enet.lib -------------------------------------------------------------------------------- /lib64/zdll.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/extra-a/sauer-sdl2/HEAD/lib64/zdll.lib -------------------------------------------------------------------------------- /vcpp/cube2.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/extra-a/sauer-sdl2/HEAD/vcpp/cube2.ico -------------------------------------------------------------------------------- /lib/SDL2_image.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/extra-a/sauer-sdl2/HEAD/lib/SDL2_image.lib -------------------------------------------------------------------------------- /lib/SDL2_mixer.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/extra-a/sauer-sdl2/HEAD/lib/SDL2_mixer.lib -------------------------------------------------------------------------------- /lib64/SDL2_image.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/extra-a/sauer-sdl2/HEAD/lib64/SDL2_image.lib -------------------------------------------------------------------------------- /lib64/SDL2_mixer.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/extra-a/sauer-sdl2/HEAD/lib64/SDL2_mixer.lib -------------------------------------------------------------------------------- /include/SDL_revision.h: -------------------------------------------------------------------------------- 1 | #define SDL_REVISION "hg-10001:e12c38730512" 2 | #define SDL_REVISION_NUMBER 10001 3 | -------------------------------------------------------------------------------- /vcpp/mingw.rc: -------------------------------------------------------------------------------- 1 | #include "sauerbraten.rc" 2 | CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "dpiaware.manifest" 3 | -------------------------------------------------------------------------------- /vcpp/sauerbraten.rc: -------------------------------------------------------------------------------- 1 | #include "winresrc.h" 2 | #define IDI_ICON1 1 3 | 4 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US 5 | IDI_ICON1 ICON "cube2.ico" 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | .svn 3 | *.o 4 | *.a 5 | *.gch 6 | sauer_client 7 | sauer_server 8 | vcpp/sauerbraten.suo 9 | vcpp/sauerbraten.sdf 10 | vcpp/sauerbraten.opensdf 11 | vcpp/sauerbraten.vcxproj.user 12 | vcpp/Debug/ 13 | vcpp/Release/ 14 | vcpp/ipch 15 | vcpp/*.suo 16 | vcpp/.vs 17 | vcpp/*.opendb 18 | .vs/ 19 | -------------------------------------------------------------------------------- /enet/include/enet/utility.h: -------------------------------------------------------------------------------- 1 | /** 2 | @file utility.h 3 | @brief ENet utility header 4 | */ 5 | #ifndef __ENET_UTILITY_H__ 6 | #define __ENET_UTILITY_H__ 7 | 8 | #define ENET_MAX(x, y) ((x) > (y) ? (x) : (y)) 9 | #define ENET_MIN(x, y) ((x) < (y) ? (x) : (y)) 10 | 11 | #endif /* __ENET_UTILITY_H__ */ 12 | 13 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | # Sauerbraten SDL2 Client 3 | 4 | Sauerbraten SDL2 Client client for windows/linux. It also has some 5 | additional features, that have been missing for years (all of them are 6 | disabled by default and separate configuration files are used). SLD2 7 | port is based on SDOS client code. 8 | 9 | http://extra-a.github.io/ 10 | -------------------------------------------------------------------------------- /enet/README: -------------------------------------------------------------------------------- 1 | Please visit the ENet homepage at http://enet.bespin.org for installation 2 | and usage instructions. 3 | 4 | If you obtained this package from github, the quick description on how to build 5 | is: 6 | 7 | # Generate the build system. 8 | 9 | autoreconf -vfi 10 | 11 | # Compile and install the library. 12 | 13 | ./configure && make && make install 14 | 15 | 16 | -------------------------------------------------------------------------------- /enet/include/enet/types.h: -------------------------------------------------------------------------------- 1 | /** 2 | @file types.h 3 | @brief type definitions for ENet 4 | */ 5 | #ifndef __ENET_TYPES_H__ 6 | #define __ENET_TYPES_H__ 7 | 8 | typedef unsigned char enet_uint8; /**< unsigned 8-bit type */ 9 | typedef unsigned short enet_uint16; /**< unsigned 16-bit type */ 10 | typedef unsigned int enet_uint32; /**< unsigned 32-bit type */ 11 | 12 | #endif /* __ENET_TYPES_H__ */ 13 | 14 | -------------------------------------------------------------------------------- /enet/Makefile: -------------------------------------------------------------------------------- 1 | CFLAGS=-O3 -fomit-frame-pointer 2 | override CFLAGS:= $(CFLAGS) -Iinclude $(shell ./check_cflags.sh $(CC) $(CFLAGS)) 3 | 4 | OBJS= \ 5 | callbacks.o \ 6 | compress.o \ 7 | host.o \ 8 | list.o \ 9 | packet.o \ 10 | peer.o \ 11 | protocol.o \ 12 | unix.o \ 13 | win32.o 14 | 15 | libenet.a: $(OBJS) 16 | $(AR) rcs $@ $(OBJS) 17 | 18 | default: libenet.a 19 | 20 | clean: 21 | -$(RM) libenet.a $(OBJS) 22 | 23 | -------------------------------------------------------------------------------- /enet/include/enet/time.h: -------------------------------------------------------------------------------- 1 | /** 2 | @file time.h 3 | @brief ENet time constants and macros 4 | */ 5 | #ifndef __ENET_TIME_H__ 6 | #define __ENET_TIME_H__ 7 | 8 | #define ENET_TIME_OVERFLOW 86400000 9 | 10 | #define ENET_TIME_LESS(a, b) ((a) - (b) >= ENET_TIME_OVERFLOW) 11 | #define ENET_TIME_GREATER(a, b) ((b) - (a) >= ENET_TIME_OVERFLOW) 12 | #define ENET_TIME_LESS_EQUAL(a, b) (! ENET_TIME_GREATER (a, b)) 13 | #define ENET_TIME_GREATER_EQUAL(a, b) (! ENET_TIME_LESS (a, b)) 14 | 15 | #define ENET_TIME_DIFFERENCE(a, b) ((a) - (b) >= ENET_TIME_OVERFLOW ? (b) - (a) : (a) - (b)) 16 | 17 | #endif /* __ENET_TIME_H__ */ 18 | 19 | -------------------------------------------------------------------------------- /enet/include/enet/callbacks.h: -------------------------------------------------------------------------------- 1 | /** 2 | @file callbacks.h 3 | @brief ENet callbacks 4 | */ 5 | #ifndef __ENET_CALLBACKS_H__ 6 | #define __ENET_CALLBACKS_H__ 7 | 8 | #include 9 | 10 | typedef struct _ENetCallbacks 11 | { 12 | void * (ENET_CALLBACK * malloc) (size_t size); 13 | void (ENET_CALLBACK * free) (void * memory); 14 | void (ENET_CALLBACK * no_memory) (void); 15 | } ENetCallbacks; 16 | 17 | /** @defgroup callbacks ENet internal callbacks 18 | @{ 19 | @ingroup private 20 | */ 21 | extern void * enet_malloc (size_t); 22 | extern void enet_free (void *); 23 | 24 | /** @} */ 25 | 26 | #endif /* __ENET_CALLBACKS_H__ */ 27 | 28 | -------------------------------------------------------------------------------- /vcpp/dpiaware.manifest: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | true 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /include/SDL_copying.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2013 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | -------------------------------------------------------------------------------- /enet/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2002-2015 Lee Salzman 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | -------------------------------------------------------------------------------- /include/SDL_opengles2_gl2platform.h: -------------------------------------------------------------------------------- 1 | #ifndef __gl2platform_h_ 2 | #define __gl2platform_h_ 3 | 4 | /* $Revision: 10602 $ on $Date:: 2010-03-04 22:35:34 -0800 #$ */ 5 | 6 | /* 7 | * This document is licensed under the SGI Free Software B License Version 8 | * 2.0. For details, see http://oss.sgi.com/projects/FreeB/ . 9 | */ 10 | 11 | /* Platform-specific types and definitions for OpenGL ES 2.X gl2.h 12 | * 13 | * Adopters may modify khrplatform.h and this file to suit their platform. 14 | * You are encouraged to submit all modifications to the Khronos group so that 15 | * they can be included in future versions of this file. Please submit changes 16 | * by sending them to the public Khronos Bugzilla (http://khronos.org/bugzilla) 17 | * by filing a bug against product "OpenGL-ES" component "Registry". 18 | */ 19 | 20 | /*#include */ 21 | 22 | #ifndef GL_APICALL 23 | #define GL_APICALL KHRONOS_APICALL 24 | #endif 25 | 26 | #ifndef GL_APIENTRY 27 | #define GL_APIENTRY KHRONOS_APIENTRY 28 | #endif 29 | 30 | #endif /* __gl2platform_h_ */ 31 | -------------------------------------------------------------------------------- /shared/cube.h: -------------------------------------------------------------------------------- 1 | #ifndef __CUBE_H__ 2 | #define __CUBE_H__ 3 | 4 | #define _FILE_OFFSET_BITS 64 5 | 6 | #ifdef WIN32 7 | #define _USE_MATH_DEFINES 8 | #endif 9 | #include 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | #ifdef WIN32 21 | #define WIN32_LEAN_AND_MEAN 22 | #ifdef _WIN32_WINNT 23 | #undef _WIN32_WINNT 24 | #endif 25 | #define _WIN32_WINNT 0x0500 26 | #include "windows.h" 27 | #ifndef _WINDOWS 28 | #define _WINDOWS 29 | #endif 30 | #ifndef __GNUC__ 31 | #include 32 | #include 33 | #endif 34 | #define ZLIB_DLL 35 | #endif 36 | 37 | #ifndef STANDALONE 38 | #include 39 | #include 40 | #endif 41 | 42 | #include 43 | 44 | #include 45 | 46 | #include "tools.h" 47 | #include "geom.h" 48 | #include "ents.h" 49 | #include "command.h" 50 | 51 | #include "iengine.h" 52 | #include "igame.h" 53 | 54 | #endif 55 | 56 | -------------------------------------------------------------------------------- /include/SDL_types.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_types.h 24 | * 25 | * \deprecated 26 | */ 27 | 28 | /* DEPRECATED */ 29 | #include "SDL_stdinc.h" 30 | -------------------------------------------------------------------------------- /enet/callbacks.c: -------------------------------------------------------------------------------- 1 | /** 2 | @file callbacks.c 3 | @brief ENet callback functions 4 | */ 5 | #define ENET_BUILDING_LIB 1 6 | #include "enet/enet.h" 7 | 8 | static ENetCallbacks callbacks = { malloc, free, abort }; 9 | 10 | int 11 | enet_initialize_with_callbacks (ENetVersion version, const ENetCallbacks * inits) 12 | { 13 | if (version < ENET_VERSION_CREATE (1, 3, 0)) 14 | return -1; 15 | 16 | if (inits -> malloc != NULL || inits -> free != NULL) 17 | { 18 | if (inits -> malloc == NULL || inits -> free == NULL) 19 | return -1; 20 | 21 | callbacks.malloc = inits -> malloc; 22 | callbacks.free = inits -> free; 23 | } 24 | 25 | if (inits -> no_memory != NULL) 26 | callbacks.no_memory = inits -> no_memory; 27 | 28 | return enet_initialize (); 29 | } 30 | 31 | ENetVersion 32 | enet_linked_version (void) 33 | { 34 | return ENET_VERSION; 35 | } 36 | 37 | void * 38 | enet_malloc (size_t size) 39 | { 40 | void * memory = callbacks.malloc (size); 41 | 42 | if (memory == NULL) 43 | callbacks.no_memory (); 44 | 45 | return memory; 46 | } 47 | 48 | void 49 | enet_free (void * memory) 50 | { 51 | callbacks.free (memory); 52 | } 53 | 54 | -------------------------------------------------------------------------------- /enet/include/enet/list.h: -------------------------------------------------------------------------------- 1 | /** 2 | @file list.h 3 | @brief ENet list management 4 | */ 5 | #ifndef __ENET_LIST_H__ 6 | #define __ENET_LIST_H__ 7 | 8 | #include 9 | 10 | typedef struct _ENetListNode 11 | { 12 | struct _ENetListNode * next; 13 | struct _ENetListNode * previous; 14 | } ENetListNode; 15 | 16 | typedef ENetListNode * ENetListIterator; 17 | 18 | typedef struct _ENetList 19 | { 20 | ENetListNode sentinel; 21 | } ENetList; 22 | 23 | extern void enet_list_clear (ENetList *); 24 | 25 | extern ENetListIterator enet_list_insert (ENetListIterator, void *); 26 | extern void * enet_list_remove (ENetListIterator); 27 | extern ENetListIterator enet_list_move (ENetListIterator, void *, void *); 28 | 29 | extern size_t enet_list_size (ENetList *); 30 | 31 | #define enet_list_begin(list) ((list) -> sentinel.next) 32 | #define enet_list_end(list) (& (list) -> sentinel) 33 | 34 | #define enet_list_empty(list) (enet_list_begin (list) == enet_list_end (list)) 35 | 36 | #define enet_list_next(iterator) ((iterator) -> next) 37 | #define enet_list_previous(iterator) ((iterator) -> previous) 38 | 39 | #define enet_list_front(list) ((void *) (list) -> sentinel.next) 40 | #define enet_list_back(list) ((void *) (list) -> sentinel.previous) 41 | 42 | #endif /* __ENET_LIST_H__ */ 43 | 44 | -------------------------------------------------------------------------------- /include/SDL_name.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | #ifndef _SDLname_h_ 23 | #define _SDLname_h_ 24 | 25 | #if defined(__STDC__) || defined(__cplusplus) 26 | #define NeedFunctionPrototypes 1 27 | #endif 28 | 29 | #define SDL_NAME(X) SDL_##X 30 | 31 | #endif /* _SDLname_h_ */ 32 | 33 | /* vi: set ts=4 sw=4 expandtab: */ 34 | -------------------------------------------------------------------------------- /include/SDL_opengles.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_opengles.h 24 | * 25 | * This is a simple file to encapsulate the OpenGL ES 1.X API headers. 26 | */ 27 | 28 | #ifdef __IPHONEOS__ 29 | #include 30 | #include 31 | #else 32 | #include 33 | #include 34 | #endif 35 | 36 | #ifndef APIENTRY 37 | #define APIENTRY 38 | #endif 39 | -------------------------------------------------------------------------------- /engine/bih.h: -------------------------------------------------------------------------------- 1 | struct BIHNode 2 | { 3 | short split[2]; 4 | ushort child[2]; 5 | 6 | int axis() const { return child[0]>>14; } 7 | int childindex(int which) const { return child[which]&0x3FFF; } 8 | bool isleaf(int which) const { return (child[1]&(1<<(14+which)))!=0; } 9 | }; 10 | 11 | struct BIH 12 | { 13 | struct tri : triangle 14 | { 15 | float tc[6]; 16 | Texture *tex; 17 | }; 18 | 19 | int maxdepth; 20 | int numnodes; 21 | BIHNode *nodes; 22 | int numtris; 23 | tri *tris, *noclip; 24 | 25 | vec bbmin, bbmax; 26 | float radius; 27 | 28 | BIH(vector *t); 29 | 30 | ~BIH() 31 | { 32 | DELETEA(nodes); 33 | DELETEA(tris); 34 | } 35 | 36 | static bool triintersect(tri &t, const vec &o, const vec &ray, float maxdist, float &dist, int mode, tri *noclip); 37 | 38 | void build(vector &buildnodes, ushort *indices, int numindices, const vec &vmin, const vec &vmax, int depth = 1); 39 | 40 | bool traverse(const vec &o, const vec &ray, float maxdist, float &dist, int mode); 41 | bool traverse(const vec &o, const vec &ray, const vec &invray, float maxdist, float &dist, int mode, BIHNode *curnode, float tmin, float tmax); 42 | 43 | void preload(); 44 | }; 45 | 46 | extern bool mmintersect(const extentity &e, const vec &o, const vec &ray, float maxdist, int mode, float &dist); 47 | 48 | -------------------------------------------------------------------------------- /enet/include/enet/unix.h: -------------------------------------------------------------------------------- 1 | /** 2 | @file unix.h 3 | @brief ENet Unix header 4 | */ 5 | #ifndef __ENET_UNIX_H__ 6 | #define __ENET_UNIX_H__ 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #ifdef MSG_MAXIOVLEN 16 | #define ENET_BUFFER_MAXIMUM MSG_MAXIOVLEN 17 | #endif 18 | 19 | typedef int ENetSocket; 20 | 21 | #define ENET_SOCKET_NULL -1 22 | 23 | #define ENET_HOST_TO_NET_16(value) (htons (value)) /**< macro that converts host to net byte-order of a 16-bit value */ 24 | #define ENET_HOST_TO_NET_32(value) (htonl (value)) /**< macro that converts host to net byte-order of a 32-bit value */ 25 | 26 | #define ENET_NET_TO_HOST_16(value) (ntohs (value)) /**< macro that converts net to host byte-order of a 16-bit value */ 27 | #define ENET_NET_TO_HOST_32(value) (ntohl (value)) /**< macro that converts net to host byte-order of a 32-bit value */ 28 | 29 | typedef struct 30 | { 31 | void * data; 32 | size_t dataLength; 33 | } ENetBuffer; 34 | 35 | #define ENET_CALLBACK 36 | 37 | #define ENET_API extern 38 | 39 | typedef fd_set ENetSocketSet; 40 | 41 | #define ENET_SOCKETSET_EMPTY(sockset) FD_ZERO (& (sockset)) 42 | #define ENET_SOCKETSET_ADD(sockset, socket) FD_SET (socket, & (sockset)) 43 | #define ENET_SOCKETSET_REMOVE(sockset, socket) FD_CLR (socket, & (sockset)) 44 | #define ENET_SOCKETSET_CHECK(sockset, socket) FD_ISSET (socket, & (sockset)) 45 | 46 | #endif /* __ENET_UNIX_H__ */ 47 | 48 | -------------------------------------------------------------------------------- /engine/glare.cpp: -------------------------------------------------------------------------------- 1 | #include "engine.h" 2 | #include "rendertarget.h" 3 | 4 | static struct glaretexture : rendertarget 5 | { 6 | bool dorender() 7 | { 8 | extern void drawglare(); 9 | drawglare(); 10 | return true; 11 | } 12 | } glaretex; 13 | 14 | void cleanupglare() 15 | { 16 | glaretex.cleanup(true); 17 | } 18 | 19 | VARFP(glaresize, 6, 8, 10, cleanupglare()); 20 | VARP(glare, 0, 0, 1); 21 | VARP(blurglare, 0, 4, 7); 22 | VARP(blurglaresigma, 1, 50, 200); 23 | 24 | VAR(debugglare, 0, 0, 1); 25 | 26 | void viewglaretex() 27 | { 28 | if(!glare) return; 29 | glaretex.debug(); 30 | } 31 | 32 | bool glaring = false; 33 | 34 | void drawglaretex() 35 | { 36 | if(!glare || renderpath==R_FIXEDFUNCTION) return; 37 | 38 | glaretex.render(1< 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file close_code.h 24 | * 25 | * This file reverses the effects of begin_code.h and should be included 26 | * after you finish any function and structure declarations in your headers 27 | */ 28 | 29 | #undef _begin_code_h 30 | 31 | /* Reset structure packing at previous byte alignment */ 32 | #if defined(_MSC_VER) || defined(__MWERKS__) || defined(__WATCOMC__) || defined(__BORLANDC__) 33 | #ifdef __BORLANDC__ 34 | #pragma nopackwarning 35 | #endif 36 | #pragma pack(pop) 37 | #endif /* Compiler needs structure packing set */ 38 | -------------------------------------------------------------------------------- /enet/include/enet/win32.h: -------------------------------------------------------------------------------- 1 | /** 2 | @file win32.h 3 | @brief ENet Win32 header 4 | */ 5 | #ifndef __ENET_WIN32_H__ 6 | #define __ENET_WIN32_H__ 7 | 8 | #ifdef _MSC_VER 9 | #ifdef ENET_BUILDING_LIB 10 | #pragma warning (disable: 4267) // size_t to int conversion 11 | #pragma warning (disable: 4244) // 64bit to 32bit int 12 | #pragma warning (disable: 4018) // signed/unsigned mismatch 13 | #pragma warning (disable: 4146) // unary minus operator applied to unsigned type 14 | #endif 15 | #endif 16 | 17 | #include 18 | #include 19 | 20 | typedef SOCKET ENetSocket; 21 | 22 | #define ENET_SOCKET_NULL INVALID_SOCKET 23 | 24 | #define ENET_HOST_TO_NET_16(value) (htons (value)) 25 | #define ENET_HOST_TO_NET_32(value) (htonl (value)) 26 | 27 | #define ENET_NET_TO_HOST_16(value) (ntohs (value)) 28 | #define ENET_NET_TO_HOST_32(value) (ntohl (value)) 29 | 30 | typedef struct 31 | { 32 | size_t dataLength; 33 | void * data; 34 | } ENetBuffer; 35 | 36 | #define ENET_CALLBACK __cdecl 37 | 38 | #ifdef ENET_DLL 39 | #ifdef ENET_BUILDING_LIB 40 | #define ENET_API __declspec( dllexport ) 41 | #else 42 | #define ENET_API __declspec( dllimport ) 43 | #endif /* ENET_BUILDING_LIB */ 44 | #else /* !ENET_DLL */ 45 | #define ENET_API extern 46 | #endif /* ENET_DLL */ 47 | 48 | typedef fd_set ENetSocketSet; 49 | 50 | #define ENET_SOCKETSET_EMPTY(sockset) FD_ZERO (& (sockset)) 51 | #define ENET_SOCKETSET_ADD(sockset, socket) FD_SET (socket, & (sockset)) 52 | #define ENET_SOCKETSET_REMOVE(sockset, socket) FD_CLR (socket, & (sockset)) 53 | #define ENET_SOCKETSET_CHECK(sockset, socket) FD_ISSET (socket, & (sockset)) 54 | 55 | #endif /* __ENET_WIN32_H__ */ 56 | 57 | 58 | -------------------------------------------------------------------------------- /enet/check_cflags.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # ENet cflags detection for unix by Daniel 'q66' Kolesa 3 | # I hereby put this file into public domain, use as you wish 4 | 5 | CC=$* 6 | 7 | cat << EOF > check_func.c 8 | void TEST_FUN(); 9 | int main() { TEST_FUN(); return 0; } 10 | EOF 11 | cat << EOF > check_member.c 12 | #include "check_member.h" 13 | static void pass() {} 14 | int main() { struct TEST_STRUCT test; pass(test.TEST_FIELD); return 0; } 15 | EOF 16 | cat << EOF > check_type.c 17 | #include "check_type.h" 18 | int main() { TEST_TYPE test; return 0; } 19 | EOF 20 | 21 | CHECK_FUNC() { 22 | $CC check_func.c -DTEST_FUN=$1 -o check_func 2>/dev/null 23 | if [ $? -eq 0 ]; then printf " $2"; rm check_func; fi 24 | } 25 | 26 | CHECK_FUNC getaddrinfo -DHAS_GETADDRINFO 27 | CHECK_FUNC getnameinfo -DHAS_GETNAMEINFO 28 | CHECK_FUNC gethostbyaddr_r -DHAS_GETHOSTBYADDR_R 29 | CHECK_FUNC gethostbyname_r -DHAS_GETHOSTBYNAME_R 30 | CHECK_FUNC poll -DHAS_POLL 31 | CHECK_FUNC fcntl -DHAS_FCNTL 32 | CHECK_FUNC inet_pton -DHAS_INET_PTON 33 | CHECK_FUNC inet_ntop -DHAS_INET_NTOP 34 | 35 | echo "#include " > check_member.h 36 | $CC check_member.c -DTEST_STRUCT=msghdr -DTEST_FIELD=msg_flags \ 37 | -o check_member 2>/dev/null 38 | if [ $? -eq 0 ]; then printf " -DHAS_MSGHDR_FLAGS"; rm check_member; fi 39 | rm check_member.h 40 | 41 | echo "#include " > check_type.h 42 | echo "#include " >> check_type.h 43 | $CC check_type.c -DTEST_TYPE=socklen_t -o check_type 2>/dev/null 44 | if [ $? -eq 0 ]; then printf " -DHAS_SOCKLEN_T"; rm check_type; fi 45 | rm check_type.h 46 | 47 | echo '' 48 | rm check_func.c 49 | rm check_member.c 50 | rm check_type.c 51 | -------------------------------------------------------------------------------- /include/SDL_opengles2.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_opengles2.h 24 | * 25 | * This is a simple file to encapsulate the OpenGL ES 2.0 API headers. 26 | */ 27 | #ifndef _MSC_VER 28 | 29 | #ifdef __IPHONEOS__ 30 | #include 31 | #include 32 | #else 33 | #include 34 | #include 35 | #include 36 | #endif 37 | 38 | #else /* _MSC_VER */ 39 | 40 | /* OpenGL ES2 headers for Visual Studio */ 41 | #include "SDL_opengles2_khrplatform.h" 42 | #include "SDL_opengles2_gl2platform.h" 43 | #include "SDL_opengles2_gl2.h" 44 | #include "SDL_opengles2_gl2ext.h" 45 | 46 | #endif /* _MSC_VER */ 47 | 48 | #ifndef APIENTRY 49 | #define APIENTRY GL_APIENTRY 50 | #endif 51 | -------------------------------------------------------------------------------- /vcpp/sauerbraten.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual C++ Express 2010 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sauerbraten", "sauerbraten.vcxproj", "{06594C6D-6DA9-49DC-9A91-8F47221DDCFD}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Win32 = Debug|Win32 9 | Debug|x64 = Debug|x64 10 | Profile|Win32 = Profile|Win32 11 | Profile|x64 = Profile|x64 12 | Release|Win32 = Release|Win32 13 | Release|x64 = Release|x64 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {06594C6D-6DA9-49DC-9A91-8F47221DDCFD}.Debug|Win32.ActiveCfg = Debug|Win32 17 | {06594C6D-6DA9-49DC-9A91-8F47221DDCFD}.Debug|Win32.Build.0 = Debug|Win32 18 | {06594C6D-6DA9-49DC-9A91-8F47221DDCFD}.Debug|x64.ActiveCfg = Debug|x64 19 | {06594C6D-6DA9-49DC-9A91-8F47221DDCFD}.Debug|x64.Build.0 = Debug|x64 20 | {06594C6D-6DA9-49DC-9A91-8F47221DDCFD}.Profile|Win32.ActiveCfg = Profile|Win32 21 | {06594C6D-6DA9-49DC-9A91-8F47221DDCFD}.Profile|Win32.Build.0 = Profile|Win32 22 | {06594C6D-6DA9-49DC-9A91-8F47221DDCFD}.Profile|x64.ActiveCfg = Profile|x64 23 | {06594C6D-6DA9-49DC-9A91-8F47221DDCFD}.Profile|x64.Build.0 = Profile|x64 24 | {06594C6D-6DA9-49DC-9A91-8F47221DDCFD}.Release|Win32.ActiveCfg = Release|Win32 25 | {06594C6D-6DA9-49DC-9A91-8F47221DDCFD}.Release|Win32.Build.0 = Release|Win32 26 | {06594C6D-6DA9-49DC-9A91-8F47221DDCFD}.Release|x64.ActiveCfg = Release|x64 27 | {06594C6D-6DA9-49DC-9A91-8F47221DDCFD}.Release|x64.Build.0 = Release|x64 28 | EndGlobalSection 29 | GlobalSection(SolutionProperties) = preSolution 30 | HideSolutionNode = FALSE 31 | EndGlobalSection 32 | EndGlobal 33 | -------------------------------------------------------------------------------- /engine/world.h: -------------------------------------------------------------------------------- 1 | 2 | enum // hardcoded texture numbers 3 | { 4 | DEFAULT_SKY = 0, 5 | DEFAULT_GEOM 6 | }; 7 | 8 | #define MAPVERSION 33 // bump if map format changes, see worldio.cpp 9 | 10 | struct octaheader 11 | { 12 | char magic[4]; // "OCTA" 13 | int version; // any >8bit quantity is little endian 14 | int headersize; // sizeof(header) 15 | int worldsize; 16 | int numents; 17 | int numpvs; 18 | int lightmaps; 19 | int blendmap; 20 | int numvars; 21 | int numvslots; 22 | }; 23 | 24 | struct compatheader // map file format header 25 | { 26 | char magic[4]; // "OCTA" 27 | int version; // any >8bit quantity is little endian 28 | int headersize; // sizeof(header) 29 | int worldsize; 30 | int numents; 31 | int numpvs; 32 | int lightmaps; 33 | int lightprecision, lighterror, lightlod; 34 | uchar ambient; 35 | uchar watercolour[3]; 36 | uchar blendmap; 37 | uchar lerpangle, lerpsubdiv, lerpsubdivsize; 38 | uchar bumperror; 39 | uchar skylight[3]; 40 | uchar lavacolour[3]; 41 | uchar waterfallcolour[3]; 42 | uchar reserved[10]; 43 | char maptitle[128]; 44 | }; 45 | 46 | #define WATER_AMPLITUDE 0.4f 47 | #define WATER_OFFSET 1.1f 48 | 49 | enum 50 | { 51 | MATSURF_NOT_VISIBLE = 0, 52 | MATSURF_VISIBLE, 53 | MATSURF_EDIT_ONLY 54 | }; 55 | 56 | #define TEX_SCALE 8.0f 57 | 58 | struct vertexff { vec pos; bvec4 norm; float u, v; float lmu, lmv; }; 59 | struct vertex { vec pos; bvec4 norm; float u, v; short lmu, lmv; bvec4 tangent; }; 60 | 61 | #define VTXSIZE (renderpath==R_FIXEDFUNCTION ? sizeof(vertexff) : sizeof(vertex)) 62 | 63 | -------------------------------------------------------------------------------- /enet/list.c: -------------------------------------------------------------------------------- 1 | /** 2 | @file list.c 3 | @brief ENet linked list functions 4 | */ 5 | #define ENET_BUILDING_LIB 1 6 | #include "enet/enet.h" 7 | 8 | /** 9 | @defgroup list ENet linked list utility functions 10 | @ingroup private 11 | @{ 12 | */ 13 | void 14 | enet_list_clear (ENetList * list) 15 | { 16 | list -> sentinel.next = & list -> sentinel; 17 | list -> sentinel.previous = & list -> sentinel; 18 | } 19 | 20 | ENetListIterator 21 | enet_list_insert (ENetListIterator position, void * data) 22 | { 23 | ENetListIterator result = (ENetListIterator) data; 24 | 25 | result -> previous = position -> previous; 26 | result -> next = position; 27 | 28 | result -> previous -> next = result; 29 | position -> previous = result; 30 | 31 | return result; 32 | } 33 | 34 | void * 35 | enet_list_remove (ENetListIterator position) 36 | { 37 | position -> previous -> next = position -> next; 38 | position -> next -> previous = position -> previous; 39 | 40 | return position; 41 | } 42 | 43 | ENetListIterator 44 | enet_list_move (ENetListIterator position, void * dataFirst, void * dataLast) 45 | { 46 | ENetListIterator first = (ENetListIterator) dataFirst, 47 | last = (ENetListIterator) dataLast; 48 | 49 | first -> previous -> next = last -> next; 50 | last -> next -> previous = first -> previous; 51 | 52 | first -> previous = position -> previous; 53 | last -> next = position; 54 | 55 | first -> previous -> next = first; 56 | position -> previous = last; 57 | 58 | return first; 59 | } 60 | 61 | size_t 62 | enet_list_size (ENetList * list) 63 | { 64 | size_t size = 0; 65 | ENetListIterator position; 66 | 67 | for (position = enet_list_begin (list); 68 | position != enet_list_end (list); 69 | position = enet_list_next (position)) 70 | ++ size; 71 | 72 | return size; 73 | } 74 | 75 | /** @} */ 76 | -------------------------------------------------------------------------------- /include/SDL_clipboard.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_clipboard.h 24 | * 25 | * Include file for SDL clipboard handling 26 | */ 27 | 28 | #ifndef _SDL_clipboard_h 29 | #define _SDL_clipboard_h 30 | 31 | #include "SDL_stdinc.h" 32 | 33 | #include "begin_code.h" 34 | /* Set up for C function definitions, even when using C++ */ 35 | #ifdef __cplusplus 36 | extern "C" { 37 | #endif 38 | 39 | /* Function prototypes */ 40 | 41 | /** 42 | * \brief Put UTF-8 text into the clipboard 43 | * 44 | * \sa SDL_GetClipboardText() 45 | */ 46 | extern DECLSPEC int SDLCALL SDL_SetClipboardText(const char *text); 47 | 48 | /** 49 | * \brief Get UTF-8 text from the clipboard, which must be freed with SDL_free() 50 | * 51 | * \sa SDL_SetClipboardText() 52 | */ 53 | extern DECLSPEC char * SDLCALL SDL_GetClipboardText(void); 54 | 55 | /** 56 | * \brief Returns a flag indicating whether the clipboard exists and contains a text string that is non-empty 57 | * 58 | * \sa SDL_GetClipboardText() 59 | */ 60 | extern DECLSPEC SDL_bool SDLCALL SDL_HasClipboardText(void); 61 | 62 | 63 | /* Ends C function definitions when using C++ */ 64 | #ifdef __cplusplus 65 | } 66 | #endif 67 | #include "close_code.h" 68 | 69 | #endif /* _SDL_clipboard_h */ 70 | 71 | /* vi: set ts=4 sw=4 expandtab: */ 72 | -------------------------------------------------------------------------------- /include/SDL_quit.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_quit.h 24 | * 25 | * Include file for SDL quit event handling. 26 | */ 27 | 28 | #ifndef _SDL_quit_h 29 | #define _SDL_quit_h 30 | 31 | #include "SDL_stdinc.h" 32 | #include "SDL_error.h" 33 | 34 | /** 35 | * \file SDL_quit.h 36 | * 37 | * An ::SDL_QUIT event is generated when the user tries to close the application 38 | * window. If it is ignored or filtered out, the window will remain open. 39 | * If it is not ignored or filtered, it is queued normally and the window 40 | * is allowed to close. When the window is closed, screen updates will 41 | * complete, but have no effect. 42 | * 43 | * SDL_Init() installs signal handlers for SIGINT (keyboard interrupt) 44 | * and SIGTERM (system termination request), if handlers do not already 45 | * exist, that generate ::SDL_QUIT events as well. There is no way 46 | * to determine the cause of an ::SDL_QUIT event, but setting a signal 47 | * handler in your application will override the default generation of 48 | * quit events for that signal. 49 | * 50 | * \sa SDL_Quit() 51 | */ 52 | 53 | /* There are no functions directly affecting the quit event */ 54 | 55 | #define SDL_QuitRequested() \ 56 | (SDL_PumpEvents(), (SDL_PeepEvents(NULL,0,SDL_PEEKEVENT,SDL_QUIT,SDL_QUIT) > 0)) 57 | 58 | #endif /* _SDL_quit_h */ 59 | -------------------------------------------------------------------------------- /vcpp/sauerbraten.nsi: -------------------------------------------------------------------------------- 1 | Name "Sauerbraten" 2 | 3 | OutFile "sauerbraten_20YY_MM_DD_foo_edition_win32_setup.exe" 4 | 5 | InstallDir $PROGRAMFILES\Sauerbraten 6 | 7 | InstallDirRegKey HKLM "Software\Sauerbraten" "Install_Dir" 8 | 9 | SetCompressor /SOLID lzma 10 | XPStyle on 11 | 12 | Page components 13 | Page directory 14 | Page instfiles 15 | 16 | UninstPage uninstConfirm 17 | UninstPage instfiles 18 | 19 | Section "Sauerbraten (required)" 20 | 21 | SectionIn RO 22 | 23 | SetOutPath $INSTDIR 24 | 25 | File /r "..\..\*.*" 26 | 27 | WriteRegStr HKLM SOFTWARE\Sauerbraten "Install_Dir" "$INSTDIR" 28 | 29 | WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Sauerbraten" "DisplayName" "Sauerbraten" 30 | WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Sauerbraten" "UninstallString" '"$INSTDIR\uninstall.exe"' 31 | WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Sauerbraten" "NoModify" 1 32 | WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Sauerbraten" "NoRepair" 1 33 | WriteUninstaller "uninstall.exe" 34 | 35 | IfFileExists "$DOCUMENTS\My Games\Sauerbraten\config.cfg" ConfigFound NoConfig 36 | ConfigFound: 37 | Delete "$DOCUMENTS\My Games\Sauerbraten\old-config.cfg" 38 | Rename "$DOCUMENTS\My Games\Sauerbraten\config.cfg" "$DOCUMENTS\My Games\Sauerbraten\old-config.cfg" 39 | NoConfig: 40 | 41 | SectionEnd 42 | 43 | Section "Start Menu Shortcuts" 44 | 45 | CreateDirectory "$SMPROGRAMS\Sauerbraten" 46 | 47 | SetOutPath "$INSTDIR" 48 | 49 | CreateShortCut "$INSTDIR\Sauerbraten.lnk" "$INSTDIR\sauerbraten.bat" "" "$INSTDIR\bin\sauerbraten.exe" 0 SW_SHOWMINIMIZED 50 | CreateShortCut "$SMPROGRAMS\Sauerbraten\Sauerbraten.lnk" "$INSTDIR\sauerbraten.bat" "" "$INSTDIR\bin\sauerbraten.exe" 0 SW_SHOWMINIMIZED 51 | CreateShortCut "$SMPROGRAMS\Sauerbraten\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0 52 | CreateShortCut "$SMPROGRAMS\Sauerbraten\README.lnk" "$INSTDIR\README.html" "" "$INSTDIR\README.html" 0 53 | 54 | SectionEnd 55 | 56 | Section "Uninstall" 57 | 58 | DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Sauerbraten" 59 | DeleteRegKey HKLM SOFTWARE\Sauerbraten 60 | 61 | RMDir /r "$SMPROGRAMS\Sauerbraten" 62 | RMDir /r "$INSTDIR" 63 | 64 | SectionEnd 65 | -------------------------------------------------------------------------------- /include/SDL_blendmode.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_blendmode.h 24 | * 25 | * Header file declaring the SDL_BlendMode enumeration 26 | */ 27 | 28 | #ifndef _SDL_blendmode_h 29 | #define _SDL_blendmode_h 30 | 31 | #include "begin_code.h" 32 | /* Set up for C function definitions, even when using C++ */ 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | /** 38 | * \brief The blend mode used in SDL_RenderCopy() and drawing operations. 39 | */ 40 | typedef enum 41 | { 42 | SDL_BLENDMODE_NONE = 0x00000000, /**< no blending 43 | dstRGBA = srcRGBA */ 44 | SDL_BLENDMODE_BLEND = 0x00000001, /**< alpha blending 45 | dstRGB = (srcRGB * srcA) + (dstRGB * (1-srcA)) 46 | dstA = srcA + (dstA * (1-srcA)) */ 47 | SDL_BLENDMODE_ADD = 0x00000002, /**< additive blending 48 | dstRGB = (srcRGB * srcA) + dstRGB 49 | dstA = dstA */ 50 | SDL_BLENDMODE_MOD = 0x00000004 /**< color modulate 51 | dstRGB = srcRGB * dstRGB 52 | dstA = dstA */ 53 | } SDL_BlendMode; 54 | 55 | /* Ends C function definitions when using C++ */ 56 | #ifdef __cplusplus 57 | } 58 | #endif 59 | #include "close_code.h" 60 | 61 | #endif /* _SDL_blendmode_h */ 62 | 63 | /* vi: set ts=4 sw=4 expandtab: */ 64 | -------------------------------------------------------------------------------- /include/SDL_gesture.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_gesture.h 24 | * 25 | * Include file for SDL gesture event handling. 26 | */ 27 | 28 | #ifndef _SDL_gesture_h 29 | #define _SDL_gesture_h 30 | 31 | #include "SDL_stdinc.h" 32 | #include "SDL_error.h" 33 | #include "SDL_video.h" 34 | 35 | #include "SDL_touch.h" 36 | 37 | 38 | #include "begin_code.h" 39 | /* Set up for C function definitions, even when using C++ */ 40 | #ifdef __cplusplus 41 | extern "C" { 42 | #endif 43 | 44 | typedef Sint64 SDL_GestureID; 45 | 46 | /* Function prototypes */ 47 | 48 | /** 49 | * \brief Begin Recording a gesture on the specified touch, or all touches (-1) 50 | * 51 | * 52 | */ 53 | extern DECLSPEC int SDLCALL SDL_RecordGesture(SDL_TouchID touchId); 54 | 55 | 56 | /** 57 | * \brief Save all currently loaded Dollar Gesture templates 58 | * 59 | * 60 | */ 61 | extern DECLSPEC int SDLCALL SDL_SaveAllDollarTemplates(SDL_RWops *dst); 62 | 63 | /** 64 | * \brief Save a currently loaded Dollar Gesture template 65 | * 66 | * 67 | */ 68 | extern DECLSPEC int SDLCALL SDL_SaveDollarTemplate(SDL_GestureID gestureId,SDL_RWops *dst); 69 | 70 | 71 | /** 72 | * \brief Load Dollar Gesture templates from a file 73 | * 74 | * 75 | */ 76 | extern DECLSPEC int SDLCALL SDL_LoadDollarTemplates(SDL_TouchID touchId, SDL_RWops *src); 77 | 78 | 79 | /* Ends C function definitions when using C++ */ 80 | #ifdef __cplusplus 81 | } 82 | #endif 83 | #include "close_code.h" 84 | 85 | #endif /* _SDL_gesture_h */ 86 | 87 | /* vi: set ts=4 sw=4 expandtab: */ 88 | -------------------------------------------------------------------------------- /include/SDL_error.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_error.h 24 | * 25 | * Simple error message routines for SDL. 26 | */ 27 | 28 | #ifndef _SDL_error_h 29 | #define _SDL_error_h 30 | 31 | #include "SDL_stdinc.h" 32 | 33 | #include "begin_code.h" 34 | /* Set up for C function definitions, even when using C++ */ 35 | #ifdef __cplusplus 36 | extern "C" { 37 | #endif 38 | 39 | /* Public functions */ 40 | /* SDL_SetError() unconditionally returns -1. */ 41 | extern DECLSPEC int SDLCALL SDL_SetError(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(1); 42 | extern DECLSPEC const char *SDLCALL SDL_GetError(void); 43 | extern DECLSPEC void SDLCALL SDL_ClearError(void); 44 | 45 | /** 46 | * \name Internal error functions 47 | * 48 | * \internal 49 | * Private error reporting function - used internally. 50 | */ 51 | /* @{ */ 52 | #define SDL_OutOfMemory() SDL_Error(SDL_ENOMEM) 53 | #define SDL_Unsupported() SDL_Error(SDL_UNSUPPORTED) 54 | #define SDL_InvalidParamError(param) SDL_SetError("Parameter '%s' is invalid", (param)) 55 | typedef enum 56 | { 57 | SDL_ENOMEM, 58 | SDL_EFREAD, 59 | SDL_EFWRITE, 60 | SDL_EFSEEK, 61 | SDL_UNSUPPORTED, 62 | SDL_LASTERROR 63 | } SDL_errorcode; 64 | /* SDL_Error() unconditionally returns -1. */ 65 | extern DECLSPEC int SDLCALL SDL_Error(SDL_errorcode code); 66 | /* @} *//* Internal error functions */ 67 | 68 | /* Ends C function definitions when using C++ */ 69 | #ifdef __cplusplus 70 | } 71 | #endif 72 | #include "close_code.h" 73 | 74 | #endif /* _SDL_error_h */ 75 | 76 | /* vi: set ts=4 sw=4 expandtab: */ 77 | -------------------------------------------------------------------------------- /include/SDL_touch.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_touch.h 24 | * 25 | * Include file for SDL touch event handling. 26 | */ 27 | 28 | #ifndef _SDL_touch_h 29 | #define _SDL_touch_h 30 | 31 | #include "SDL_stdinc.h" 32 | #include "SDL_error.h" 33 | #include "SDL_video.h" 34 | 35 | #include "begin_code.h" 36 | /* Set up for C function definitions, even when using C++ */ 37 | #ifdef __cplusplus 38 | extern "C" { 39 | #endif 40 | 41 | typedef Sint64 SDL_TouchID; 42 | typedef Sint64 SDL_FingerID; 43 | 44 | typedef struct SDL_Finger 45 | { 46 | SDL_FingerID id; 47 | float x; 48 | float y; 49 | float pressure; 50 | } SDL_Finger; 51 | 52 | /* Used as the device ID for mouse events simulated with touch input */ 53 | #define SDL_TOUCH_MOUSEID ((Uint32)-1) 54 | 55 | 56 | /* Function prototypes */ 57 | 58 | /** 59 | * \brief Get the number of registered touch devices. 60 | */ 61 | extern DECLSPEC int SDLCALL SDL_GetNumTouchDevices(void); 62 | 63 | /** 64 | * \brief Get the touch ID with the given index, or 0 if the index is invalid. 65 | */ 66 | extern DECLSPEC SDL_TouchID SDLCALL SDL_GetTouchDevice(int index); 67 | 68 | /** 69 | * \brief Get the number of active fingers for a given touch device. 70 | */ 71 | extern DECLSPEC int SDLCALL SDL_GetNumTouchFingers(SDL_TouchID touchID); 72 | 73 | /** 74 | * \brief Get the finger object of the given touch, with the given index. 75 | */ 76 | extern DECLSPEC SDL_Finger * SDLCALL SDL_GetTouchFinger(SDL_TouchID touchID, int index); 77 | 78 | /* Ends C function definitions when using C++ */ 79 | #ifdef __cplusplus 80 | } 81 | #endif 82 | #include "close_code.h" 83 | 84 | #endif /* _SDL_touch_h */ 85 | 86 | /* vi: set ts=4 sw=4 expandtab: */ 87 | -------------------------------------------------------------------------------- /include/SDL_power.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | #ifndef _SDL_power_h 23 | #define _SDL_power_h 24 | 25 | /** 26 | * \file SDL_power.h 27 | * 28 | * Header for the SDL power management routines. 29 | */ 30 | 31 | #include "SDL_stdinc.h" 32 | 33 | #include "begin_code.h" 34 | /* Set up for C function definitions, even when using C++ */ 35 | #ifdef __cplusplus 36 | extern "C" { 37 | #endif 38 | 39 | /** 40 | * \brief The basic state for the system's power supply. 41 | */ 42 | typedef enum 43 | { 44 | SDL_POWERSTATE_UNKNOWN, /**< cannot determine power status */ 45 | SDL_POWERSTATE_ON_BATTERY, /**< Not plugged in, running on the battery */ 46 | SDL_POWERSTATE_NO_BATTERY, /**< Plugged in, no battery available */ 47 | SDL_POWERSTATE_CHARGING, /**< Plugged in, charging battery */ 48 | SDL_POWERSTATE_CHARGED /**< Plugged in, battery charged */ 49 | } SDL_PowerState; 50 | 51 | 52 | /** 53 | * \brief Get the current power supply details. 54 | * 55 | * \param secs Seconds of battery life left. You can pass a NULL here if 56 | * you don't care. Will return -1 if we can't determine a 57 | * value, or we're not running on a battery. 58 | * 59 | * \param pct Percentage of battery life left, between 0 and 100. You can 60 | * pass a NULL here if you don't care. Will return -1 if we 61 | * can't determine a value, or we're not running on a battery. 62 | * 63 | * \return The state of the battery (if any). 64 | */ 65 | extern DECLSPEC SDL_PowerState SDLCALL SDL_GetPowerInfo(int *secs, int *pct); 66 | 67 | /* Ends C function definitions when using C++ */ 68 | #ifdef __cplusplus 69 | } 70 | #endif 71 | #include "close_code.h" 72 | 73 | #endif /* _SDL_power_h */ 74 | 75 | /* vi: set ts=4 sw=4 expandtab: */ 76 | -------------------------------------------------------------------------------- /include/SDL_bits.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_bits.h 24 | * 25 | * Functions for fiddling with bits and bitmasks. 26 | */ 27 | 28 | #ifndef _SDL_bits_h 29 | #define _SDL_bits_h 30 | 31 | #include "SDL_stdinc.h" 32 | 33 | #include "begin_code.h" 34 | /* Set up for C function definitions, even when using C++ */ 35 | #ifdef __cplusplus 36 | extern "C" { 37 | #endif 38 | 39 | /** 40 | * \file SDL_bits.h 41 | */ 42 | 43 | /** 44 | * Get the index of the most significant bit. Result is undefined when called 45 | * with 0. This operation can also be stated as "count leading zeroes" and 46 | * "log base 2". 47 | * 48 | * \return Index of the most significant bit, or -1 if the value is 0. 49 | */ 50 | SDL_FORCE_INLINE int 51 | SDL_MostSignificantBitIndex32(Uint32 x) 52 | { 53 | #if defined(__GNUC__) && __GNUC__ >= 4 54 | /* Count Leading Zeroes builtin in GCC. 55 | * http://gcc.gnu.org/onlinedocs/gcc-4.3.4/gcc/Other-Builtins.html 56 | */ 57 | if (x == 0) { 58 | return -1; 59 | } 60 | return 31 - __builtin_clz(x); 61 | #else 62 | /* Based off of Bit Twiddling Hacks by Sean Eron Anderson 63 | * , released in the public domain. 64 | * http://graphics.stanford.edu/~seander/bithacks.html#IntegerLog 65 | */ 66 | const Uint32 b[] = {0x2, 0xC, 0xF0, 0xFF00, 0xFFFF0000}; 67 | const int S[] = {1, 2, 4, 8, 16}; 68 | 69 | int msbIndex = 0; 70 | int i; 71 | 72 | if (x == 0) { 73 | return -1; 74 | } 75 | 76 | for (i = 4; i >= 0; i--) 77 | { 78 | if (x & b[i]) 79 | { 80 | x >>= S[i]; 81 | msbIndex |= S[i]; 82 | } 83 | } 84 | 85 | return msbIndex; 86 | #endif 87 | } 88 | 89 | /* Ends C function definitions when using C++ */ 90 | #ifdef __cplusplus 91 | } 92 | #endif 93 | #include "close_code.h" 94 | 95 | #endif /* _SDL_bits_h */ 96 | 97 | /* vi: set ts=4 sw=4 expandtab: */ 98 | -------------------------------------------------------------------------------- /include/SDL_loadso.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_loadso.h 24 | * 25 | * System dependent library loading routines 26 | * 27 | * Some things to keep in mind: 28 | * \li These functions only work on C function names. Other languages may 29 | * have name mangling and intrinsic language support that varies from 30 | * compiler to compiler. 31 | * \li Make sure you declare your function pointers with the same calling 32 | * convention as the actual library function. Your code will crash 33 | * mysteriously if you do not do this. 34 | * \li Avoid namespace collisions. If you load a symbol from the library, 35 | * it is not defined whether or not it goes into the global symbol 36 | * namespace for the application. If it does and it conflicts with 37 | * symbols in your code or other shared libraries, you will not get 38 | * the results you expect. :) 39 | */ 40 | 41 | #ifndef _SDL_loadso_h 42 | #define _SDL_loadso_h 43 | 44 | #include "SDL_stdinc.h" 45 | #include "SDL_error.h" 46 | 47 | #include "begin_code.h" 48 | /* Set up for C function definitions, even when using C++ */ 49 | #ifdef __cplusplus 50 | extern "C" { 51 | #endif 52 | 53 | /** 54 | * This function dynamically loads a shared object and returns a pointer 55 | * to the object handle (or NULL if there was an error). 56 | * The 'sofile' parameter is a system dependent name of the object file. 57 | */ 58 | extern DECLSPEC void *SDLCALL SDL_LoadObject(const char *sofile); 59 | 60 | /** 61 | * Given an object handle, this function looks up the address of the 62 | * named function in the shared object and returns it. This address 63 | * is no longer valid after calling SDL_UnloadObject(). 64 | */ 65 | extern DECLSPEC void *SDLCALL SDL_LoadFunction(void *handle, 66 | const char *name); 67 | 68 | /** 69 | * Unload a shared object from memory. 70 | */ 71 | extern DECLSPEC void SDLCALL SDL_UnloadObject(void *handle); 72 | 73 | /* Ends C function definitions when using C++ */ 74 | #ifdef __cplusplus 75 | } 76 | #endif 77 | #include "close_code.h" 78 | 79 | #endif /* _SDL_loadso_h */ 80 | 81 | /* vi: set ts=4 sw=4 expandtab: */ 82 | -------------------------------------------------------------------------------- /engine/model.h: -------------------------------------------------------------------------------- 1 | enum { MDL_MD2 = 0, MDL_MD3, MDL_MD5, MDL_OBJ, MDL_SMD, MDL_IQM, NUMMODELTYPES }; 2 | 3 | struct model 4 | { 5 | float spinyaw, spinpitch, offsetyaw, offsetpitch; 6 | bool collide, ellipsecollide, shadow, alphadepth, depthoffset; 7 | float scale; 8 | vec translate; 9 | BIH *bih; 10 | vec bbcenter, bbradius, bbextend, collidecenter, collideradius; 11 | float rejectradius, eyeheight, collidexyradius, collideheight; 12 | int batch; 13 | 14 | model() : spinyaw(0), spinpitch(0), offsetyaw(0), offsetpitch(0), collide(true), ellipsecollide(false), shadow(true), alphadepth(true), depthoffset(false), scale(1.0f), translate(0, 0, 0), bih(0), bbcenter(0, 0, 0), bbradius(-1, -1, -1), bbextend(0, 0, 0), collidecenter(0, 0, 0), collideradius(-1, -1, -1), rejectradius(-1), eyeheight(0.9f), collidexyradius(0), collideheight(0), batch(-1) {} 15 | virtual ~model() { DELETEP(bih); } 16 | virtual void calcbb(vec ¢er, vec &radius) = 0; 17 | virtual void render(int anim, int basetime, int basetime2, const vec &o, float yaw, float pitch, dynent *d, modelattach *a = NULL, const vec &color = vec(0, 0, 0), const vec &dir = vec(0, 0, 0), float transparent = 1) = 0; 18 | virtual bool load() = 0; 19 | virtual const char *name() const = 0; 20 | virtual int type() const = 0; 21 | virtual BIH *setBIH() { return 0; } 22 | virtual bool envmapped() { return false; } 23 | virtual bool skeletal() const { return false; } 24 | 25 | virtual void setshader(Shader *shader) {} 26 | virtual void setenvmap(float envmapmin, float envmapmax, Texture *envmap) {} 27 | virtual void setspec(float spec) {} 28 | virtual void setambient(float ambient) {} 29 | virtual void setglow(float glow, float glowdelta, float glowpulse) {} 30 | virtual void setglare(float specglare, float glowglare) {} 31 | virtual void setalphatest(float alpha) {} 32 | virtual void setalphablend(bool blend) {} 33 | virtual void setfullbright(float fullbright) {} 34 | virtual void setcullface(bool cullface) {} 35 | 36 | virtual void preloadBIH() { if(!bih) setBIH(); } 37 | virtual void preloadshaders() {} 38 | virtual void preloadmeshes() {} 39 | virtual void cleanup() {} 40 | 41 | virtual void startrender() {} 42 | virtual void endrender() {} 43 | 44 | void boundbox(vec ¢er, vec &radius) 45 | { 46 | if(bbradius.x < 0) 47 | { 48 | calcbb(bbcenter, bbradius); 49 | bbradius.add(bbextend); 50 | } 51 | center = bbcenter; 52 | radius = bbradius; 53 | } 54 | 55 | float collisionbox(vec ¢er, vec &radius) 56 | { 57 | if(collideradius.x < 0) 58 | { 59 | boundbox(collidecenter, collideradius); 60 | if(collidexyradius) 61 | { 62 | collidecenter.x = collidecenter.y = 0; 63 | collideradius.x = collideradius.y = collidexyradius; 64 | } 65 | if(collideheight) 66 | { 67 | collidecenter.z = collideradius.z = collideheight/2; 68 | } 69 | rejectradius = collideradius.magnitude(); 70 | } 71 | center = collidecenter; 72 | radius = collideradius; 73 | return rejectradius; 74 | } 75 | 76 | float boundsphere(vec ¢er) 77 | { 78 | vec radius; 79 | boundbox(center, radius); 80 | return radius.magnitude(); 81 | } 82 | 83 | float above() 84 | { 85 | vec center, radius; 86 | boundbox(center, radius); 87 | return center.z+radius.z; 88 | } 89 | }; 90 | 91 | -------------------------------------------------------------------------------- /readme_source.txt: -------------------------------------------------------------------------------- 1 | Sauerbraten source code license, usage, and documentation. 2 | 3 | You may use the Sauerbraten source code if you abide by the ZLIB license 4 | http://www.opensource.org/licenses/zlib-license.php 5 | (very similar to the BSD license): 6 | 7 | 8 | LICENSE 9 | ======= 10 | 11 | Sauerbraten game engine source code, any release. 12 | 13 | Copyright (C) 2001-2015 Wouter van Oortmerssen, Lee Salzman, Mike Dysart, Robert Pointon, and Quinton Reeves 14 | 15 | This software is provided 'as-is', without any express or implied 16 | warranty. In no event will the authors be held liable for any damages 17 | arising from the use of this software. 18 | 19 | Permission is granted to anyone to use this software for any purpose, 20 | including commercial applications, and to alter it and redistribute it 21 | freely, subject to the following restrictions: 22 | 23 | 1. The origin of this software must not be misrepresented; you must not 24 | claim that you wrote the original software. If you use this software 25 | in a product, an acknowledgment in the product documentation would be 26 | appreciated but is not required. 27 | 2. Altered source versions must be plainly marked as such, and must not be 28 | misrepresented as being the original software. 29 | 3. This notice may not be removed or altered from any source distribution. 30 | 31 | 32 | LICENSE NOTES 33 | ============= 34 | The license covers the source code found in the "src" directory of this 35 | archive as well as the .cfg files under the "data" directory. The included 36 | ENet network library which Sauerbraten uses is covered by an MIT-style 37 | license, which is however compatible with the above license for all 38 | practical purposes. 39 | 40 | Game media included in the game (maps, textures, sounds, models etc.) 41 | are NOT covered by this license, and may have individual copyrights and 42 | distribution restrictions (see individual readmes). 43 | 44 | 45 | USAGE 46 | ===== 47 | Compiling the sources should be straight forward. 48 | 49 | Unix users need to make sure to have the development version of all libs 50 | installed (OpenGL, SDL, SDL_mixer, SDL_image, zlib). The included 51 | Makefile can be used to build. 52 | 53 | Windows users can use the included Visual Studio project files in the vcpp 54 | directory, which references the lib/include directories for the external 55 | libraries and should thus be self contained. Release mode builds will place 56 | executables in the bin dir ready for testing and distribution. 57 | 58 | An alternative to Visual Studio for Windows is MinGW/MSYS, which can be compiled 59 | using the provided Makefile. Another alternative for Windows is to compile under 60 | Code::Blocks with the provided vcpp/sauerbraten.cbp project file. 61 | 62 | The Sauerbraten sources are very small, compact, and non-redundant, so anyone 63 | wishing to modify the source code should be able to gain an overview of 64 | Sauerbraten's inner workings by simply reading through the source code in its 65 | entirety. Small amounts of comments should guide you through the more 66 | tricky sections. 67 | 68 | When reading the source code and trying to understand Sauerbaten's internal design, 69 | keep in mind the goal of Cube: minimalism. I wanted to create a very complete 70 | game / game engine with absolutely minimal means, and made a sport out of it 71 | keeping the implementation small and simple. Sauerbraten is not a commercial 72 | product, it is merely the author's idea of a fun little programming project. 73 | 74 | 75 | AUTHORS 76 | ====== 77 | Wouter "Aardappel" van Oortmerssen 78 | http://strlen.com 79 | 80 | Lee "eihrul" Salzman 81 | http://sauerbraten.org/lee/ 82 | 83 | Mike "Gilt" Dysart 84 | 85 | Robert "baby-rabbit" Pointon 86 | http://www.fernlightning.com 87 | 88 | Quinton "Quin" Reeves 89 | http://www.redeclipse.net 90 | 91 | For additional authors/contributors, see the Sauerbraten binary distribution readme. 92 | 93 | -------------------------------------------------------------------------------- /include/SDL_timer.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | #ifndef _SDL_timer_h 23 | #define _SDL_timer_h 24 | 25 | /** 26 | * \file SDL_timer.h 27 | * 28 | * Header for the SDL time management routines. 29 | */ 30 | 31 | #include "SDL_stdinc.h" 32 | #include "SDL_error.h" 33 | 34 | #include "begin_code.h" 35 | /* Set up for C function definitions, even when using C++ */ 36 | #ifdef __cplusplus 37 | extern "C" { 38 | #endif 39 | 40 | /** 41 | * \brief Get the number of milliseconds since the SDL library initialization. 42 | * 43 | * \note This value wraps if the program runs for more than ~49 days. 44 | */ 45 | extern DECLSPEC Uint32 SDLCALL SDL_GetTicks(void); 46 | 47 | /** 48 | * \brief Compare SDL ticks values, and return true if A has passed B 49 | * 50 | * e.g. if you want to wait 100 ms, you could do this: 51 | * Uint32 timeout = SDL_GetTicks() + 100; 52 | * while (!SDL_TICKS_PASSED(SDL_GetTicks(), timeout)) { 53 | * ... do work until timeout has elapsed 54 | * } 55 | */ 56 | #define SDL_TICKS_PASSED(A, B) ((Sint32)((B) - (A)) <= 0) 57 | 58 | /** 59 | * \brief Get the current value of the high resolution counter 60 | */ 61 | extern DECLSPEC Uint64 SDLCALL SDL_GetPerformanceCounter(void); 62 | 63 | /** 64 | * \brief Get the count per second of the high resolution counter 65 | */ 66 | extern DECLSPEC Uint64 SDLCALL SDL_GetPerformanceFrequency(void); 67 | 68 | /** 69 | * \brief Wait a specified number of milliseconds before returning. 70 | */ 71 | extern DECLSPEC void SDLCALL SDL_Delay(Uint32 ms); 72 | 73 | /** 74 | * Function prototype for the timer callback function. 75 | * 76 | * The callback function is passed the current timer interval and returns 77 | * the next timer interval. If the returned value is the same as the one 78 | * passed in, the periodic alarm continues, otherwise a new alarm is 79 | * scheduled. If the callback returns 0, the periodic alarm is cancelled. 80 | */ 81 | typedef Uint32 (SDLCALL * SDL_TimerCallback) (Uint32 interval, void *param); 82 | 83 | /** 84 | * Definition of the timer ID type. 85 | */ 86 | typedef int SDL_TimerID; 87 | 88 | /** 89 | * \brief Add a new timer to the pool of timers already running. 90 | * 91 | * \return A timer ID, or 0 when an error occurs. 92 | */ 93 | extern DECLSPEC SDL_TimerID SDLCALL SDL_AddTimer(Uint32 interval, 94 | SDL_TimerCallback callback, 95 | void *param); 96 | 97 | /** 98 | * \brief Remove a timer knowing its ID. 99 | * 100 | * \return A boolean value indicating success or failure. 101 | * 102 | * \warning It is not safe to remove a timer multiple times. 103 | */ 104 | extern DECLSPEC SDL_bool SDLCALL SDL_RemoveTimer(SDL_TimerID id); 105 | 106 | 107 | /* Ends C function definitions when using C++ */ 108 | #ifdef __cplusplus 109 | } 110 | #endif 111 | #include "close_code.h" 112 | 113 | #endif /* _SDL_timer_h */ 114 | 115 | /* vi: set ts=4 sw=4 expandtab: */ 116 | -------------------------------------------------------------------------------- /engine/lightmap.h: -------------------------------------------------------------------------------- 1 | #define LM_MINW 2 2 | #define LM_MINH 2 3 | #define LM_MAXW 128 4 | #define LM_MAXH 128 5 | #define LM_PACKW 512 6 | #define LM_PACKH 512 7 | 8 | struct PackNode 9 | { 10 | PackNode *child1, *child2; 11 | ushort x, y, w, h; 12 | int available; 13 | 14 | PackNode() : child1(0), child2(0), x(0), y(0), w(LM_PACKW), h(LM_PACKH), available(min(LM_PACKW, LM_PACKH)) {} 15 | PackNode(ushort x, ushort y, ushort w, ushort h) : child1(0), child2(0), x(x), y(y), w(w), h(h), available(min(w, h)) {} 16 | 17 | void clear() 18 | { 19 | DELETEP(child1); 20 | DELETEP(child2); 21 | } 22 | 23 | ~PackNode() 24 | { 25 | clear(); 26 | } 27 | 28 | bool insert(ushort &tx, ushort &ty, ushort tw, ushort th); 29 | }; 30 | 31 | enum 32 | { 33 | LM_DIFFUSE = 0, 34 | LM_BUMPMAP0, 35 | LM_BUMPMAP1, 36 | LM_TYPE = 0x0F, 37 | 38 | LM_ALPHA = 1<<4, 39 | LM_FLAGS = 0xF0 40 | }; 41 | 42 | struct LightMap 43 | { 44 | int type, bpp, tex, offsetx, offsety; 45 | PackNode packroot; 46 | uint lightmaps, lumels; 47 | int unlitx, unlity; 48 | uchar *data; 49 | 50 | LightMap() 51 | : type(LM_DIFFUSE), bpp(3), tex(-1), offsetx(-1), offsety(-1), 52 | lightmaps(0), lumels(0), unlitx(-1), unlity(-1), 53 | data(NULL) 54 | { 55 | } 56 | 57 | ~LightMap() 58 | { 59 | if(data) delete[] data; 60 | } 61 | 62 | void finalize() 63 | { 64 | packroot.clear(); 65 | packroot.available = 0; 66 | } 67 | 68 | void copy(ushort tx, ushort ty, uchar *src, ushort tw, ushort th); 69 | bool insert(ushort &tx, ushort &ty, uchar *src, ushort tw, ushort th); 70 | }; 71 | 72 | extern vector lightmaps; 73 | 74 | struct LightMapTexture 75 | { 76 | int w, h, type; 77 | GLuint id; 78 | int unlitx, unlity; 79 | 80 | LightMapTexture() 81 | : w(0), h(0), type(LM_DIFFUSE), id(0), unlitx(-1), unlity(-1) 82 | {} 83 | }; 84 | 85 | extern vector lightmaptexs; 86 | 87 | extern bvec ambientcolor, skylightcolor; 88 | 89 | extern void clearlights(); 90 | extern void initlights(); 91 | extern void lightents(bool force = false); 92 | extern void clearlightcache(int id = -1); 93 | extern void resetlightmaps(bool fullclean = true); 94 | extern void brightencube(cube &c); 95 | extern void setsurfaces(cube &c, const surfaceinfo *surfs, const vertinfo *verts, int numverts); 96 | extern void setsurface(cube &c, int orient, const surfaceinfo &surf, const vertinfo *verts, int numverts); 97 | extern void previewblends(const ivec &bo, const ivec &bs); 98 | 99 | struct lerpvert 100 | { 101 | vec normal; 102 | float u, v; 103 | 104 | bool operator==(const lerpvert &l) const { return u == l.u && v == l.v; } 105 | bool operator!=(const lerpvert &l) const { return u != l.u || v != l.v; } 106 | }; 107 | 108 | struct lerpbounds 109 | { 110 | const lerpvert *min; 111 | const lerpvert *max; 112 | float u, ustep; 113 | vec normal, nstep; 114 | int winding; 115 | }; 116 | 117 | extern void calcnormals(bool lerptjoints = false); 118 | extern void clearnormals(); 119 | extern void findnormal(const vec &key, const vec &surface, vec &v); 120 | extern void calclerpverts(const vec2 *c, const vec *n, lerpvert *lv, int &numv); 121 | extern void initlerpbounds(float u, float v, const lerpvert *lv, int numv, lerpbounds &start, lerpbounds &end); 122 | extern void lerpnormal(float u, float v, const lerpvert *lv, int numv, lerpbounds &start, lerpbounds &end, vec &normal, vec &nstep); 123 | 124 | #define CHECK_CALCLIGHT_PROGRESS_LOCKED(exit, show_calclight_progress, before, after) \ 125 | if(check_calclight_progress) \ 126 | { \ 127 | if(!calclight_canceled) \ 128 | { \ 129 | before; \ 130 | show_calclight_progress(); \ 131 | check_calclight_canceled(); \ 132 | after; \ 133 | } \ 134 | if(calclight_canceled) { exit; } \ 135 | } 136 | #define CHECK_CALCLIGHT_PROGRESS(exit, show_calclight_progress) CHECK_CALCLIGHT_PROGRESS_LOCKED(exit, show_calclight_progress, , ) 137 | 138 | extern bool calclight_canceled; 139 | extern volatile bool check_calclight_progress; 140 | 141 | extern void check_calclight_canceled(); 142 | 143 | extern int lightmapping; 144 | 145 | -------------------------------------------------------------------------------- /engine/lightning.h: -------------------------------------------------------------------------------- 1 | #define MAXLIGHTNINGSTEPS 64 2 | #define LIGHTNINGSTEP 8 3 | int lnjitterx[2][MAXLIGHTNINGSTEPS], lnjittery[2][MAXLIGHTNINGSTEPS]; 4 | int lnjitterframe = 0, lastlnjitter = 0; 5 | 6 | VAR(lnjittermillis, 0, 100, 1000); 7 | VAR(lnjitterradius, 0, 4, 100); 8 | FVAR(lnjitterscale, 0, 0.5f, 10); 9 | VAR(lnscrollmillis, 1, 300, 5000); 10 | FVAR(lnscrollscale, 0, 0.125f, 10); 11 | FVAR(lnblendpower, 0, 0.25f, 1000); 12 | 13 | static void calclightningjitter(int frame) 14 | { 15 | loopi(MAXLIGHTNINGSTEPS) 16 | { 17 | lnjitterx[lnjitterframe][i] = -lnjitterradius + rnd(2*lnjitterradius + 1); 18 | lnjittery[lnjitterframe][i] = -lnjitterradius + rnd(2*lnjitterradius + 1); 19 | } 20 | } 21 | 22 | static void setuplightning() 23 | { 24 | if(!lastlnjitter || lastmillis-lastlnjitter > lnjittermillis) 25 | { 26 | if(!lastlnjitter) calclightningjitter(lnjitterframe); 27 | lastlnjitter = lastmillis - (lastmillis%lnjittermillis); 28 | calclightningjitter(lnjitterframe ^= 1); 29 | } 30 | } 31 | 32 | static void renderlightning(Texture *tex, const vec &o, const vec &d, float sz) 33 | { 34 | vec step(d); 35 | step.sub(o); 36 | float len = step.magnitude(); 37 | int numsteps = clamp(int(ceil(len/LIGHTNINGSTEP)), 2, MAXLIGHTNINGSTEPS); 38 | step.div(numsteps+1); 39 | int jitteroffset = detrnd(int(d.x+d.y+d.z), MAXLIGHTNINGSTEPS); 40 | vec cur(o), up, right; 41 | up.orthogonal(step); 42 | up.normalize(); 43 | right.cross(up, step); 44 | right.normalize(); 45 | float scroll = -float(lastmillis%lnscrollmillis)/lnscrollmillis, 46 | scrollscale = lnscrollscale*(LIGHTNINGSTEP*tex->ys)/(sz*tex->xs), 47 | blend = pow(clamp(float(lastmillis - lastlnjitter)/lnjittermillis, 0.0f, 1.0f), lnblendpower), 48 | jitter0 = (1-blend)*lnjitterscale*sz/lnjitterradius, jitter1 = blend*lnjitterscale*sz/lnjitterradius; 49 | glBegin(GL_TRIANGLE_STRIP); 50 | loopj(numsteps) 51 | { 52 | vec next(cur); 53 | next.add(step); 54 | if(j+1==numsteps) next = d; 55 | else 56 | { 57 | int lj = (j+jitteroffset)%MAXLIGHTNINGSTEPS; 58 | next.add(vec(right).mul((jitter1*lnjitterx[lnjitterframe][lj] + jitter0*lnjitterx[lnjitterframe^1][lj]))); 59 | next.add(vec(up).mul((jitter1*lnjittery[lnjitterframe][lj] + jitter0*lnjittery[lnjitterframe^1][lj]))); 60 | } 61 | vec dir1 = next, dir2 = next, across; 62 | dir1.sub(cur); 63 | dir2.sub(camera1->o); 64 | across.cross(dir2, dir1).normalize().mul(sz); 65 | glTexCoord2f(scroll, 1); glVertex3f(cur.x-across.x, cur.y-across.y, cur.z-across.z); 66 | glTexCoord2f(scroll, 0); glVertex3f(cur.x+across.x, cur.y+across.y, cur.z+across.z); 67 | scroll += scrollscale; 68 | if(j+1==numsteps) 69 | { 70 | glTexCoord2f(scroll, 1); glVertex3f(next.x-across.x, next.y-across.y, next.z-across.z); 71 | glTexCoord2f(scroll, 0); glVertex3f(next.x+across.x, next.y+across.y, next.z+across.z); 72 | } 73 | cur = next; 74 | } 75 | glEnd(); 76 | } 77 | 78 | struct lightningrenderer : listrenderer 79 | { 80 | lightningrenderer() 81 | : listrenderer("packages/particles/lightning.jpg", 2, PT_LIGHTNING|PT_TRACK|PT_GLARE) 82 | {} 83 | 84 | void startrender() 85 | { 86 | glDisable(GL_CULL_FACE); 87 | } 88 | 89 | void endrender() 90 | { 91 | glEnable(GL_CULL_FACE); 92 | } 93 | 94 | void update() 95 | { 96 | setuplightning(); 97 | } 98 | 99 | void seedemitter(particleemitter &pe, const vec &o, const vec &d, int fade, float size, int gravity) 100 | { 101 | pe.maxfade = max(pe.maxfade, fade); 102 | pe.extendbb(o, size); 103 | pe.extendbb(d, size); 104 | } 105 | 106 | void renderpart(listparticle *p, const vec &o, const vec &d, int blend, int ts, uchar *color) 107 | { 108 | blend = min(blend<<2, 255); 109 | if(type&PT_MOD) //multiply alpha into color 110 | glColor3ub((color[0]*blend)>>8, (color[1]*blend)>>8, (color[2]*blend)>>8); 111 | else 112 | glColor4ub(color[0], color[1], color[2], blend); 113 | renderlightning(tex, o, d, p->size); 114 | } 115 | }; 116 | static lightningrenderer lightnings; 117 | 118 | -------------------------------------------------------------------------------- /include/SDL.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL.h 24 | * 25 | * Main include header for the SDL library 26 | */ 27 | 28 | 29 | #ifndef _SDL_H 30 | #define _SDL_H 31 | 32 | #include "SDL_main.h" 33 | #include "SDL_stdinc.h" 34 | #include "SDL_assert.h" 35 | #include "SDL_atomic.h" 36 | #include "SDL_audio.h" 37 | #include "SDL_clipboard.h" 38 | #include "SDL_cpuinfo.h" 39 | #include "SDL_endian.h" 40 | #include "SDL_error.h" 41 | #include "SDL_events.h" 42 | #include "SDL_filesystem.h" 43 | #include "SDL_joystick.h" 44 | #include "SDL_gamecontroller.h" 45 | #include "SDL_haptic.h" 46 | #include "SDL_hints.h" 47 | #include "SDL_loadso.h" 48 | #include "SDL_log.h" 49 | #include "SDL_messagebox.h" 50 | #include "SDL_mutex.h" 51 | #include "SDL_power.h" 52 | #include "SDL_render.h" 53 | #include "SDL_rwops.h" 54 | #include "SDL_system.h" 55 | #include "SDL_thread.h" 56 | #include "SDL_timer.h" 57 | #include "SDL_version.h" 58 | #include "SDL_video.h" 59 | 60 | #include "begin_code.h" 61 | /* Set up for C function definitions, even when using C++ */ 62 | #ifdef __cplusplus 63 | extern "C" { 64 | #endif 65 | 66 | /* As of version 0.5, SDL is loaded dynamically into the application */ 67 | 68 | /** 69 | * \name SDL_INIT_* 70 | * 71 | * These are the flags which may be passed to SDL_Init(). You should 72 | * specify the subsystems which you will be using in your application. 73 | */ 74 | /* @{ */ 75 | #define SDL_INIT_TIMER 0x00000001 76 | #define SDL_INIT_AUDIO 0x00000010 77 | #define SDL_INIT_VIDEO 0x00000020 /**< SDL_INIT_VIDEO implies SDL_INIT_EVENTS */ 78 | #define SDL_INIT_JOYSTICK 0x00000200 /**< SDL_INIT_JOYSTICK implies SDL_INIT_EVENTS */ 79 | #define SDL_INIT_HAPTIC 0x00001000 80 | #define SDL_INIT_GAMECONTROLLER 0x00002000 /**< SDL_INIT_GAMECONTROLLER implies SDL_INIT_JOYSTICK */ 81 | #define SDL_INIT_EVENTS 0x00004000 82 | #define SDL_INIT_NOPARACHUTE 0x00100000 /**< compatibility; this flag is ignored. */ 83 | #define SDL_INIT_EVERYTHING ( \ 84 | SDL_INIT_TIMER | SDL_INIT_AUDIO | SDL_INIT_VIDEO | SDL_INIT_EVENTS | \ 85 | SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC | SDL_INIT_GAMECONTROLLER \ 86 | ) 87 | /* @} */ 88 | 89 | /** 90 | * This function initializes the subsystems specified by \c flags 91 | */ 92 | extern DECLSPEC int SDLCALL SDL_Init(Uint32 flags); 93 | 94 | /** 95 | * This function initializes specific SDL subsystems 96 | * 97 | * Subsystem initialization is ref-counted, you must call 98 | * SDL_QuitSubSystem for each SDL_InitSubSystem to correctly 99 | * shutdown a subsystem manually (or call SDL_Quit to force shutdown). 100 | * If a subsystem is already loaded then this call will 101 | * increase the ref-count and return. 102 | */ 103 | extern DECLSPEC int SDLCALL SDL_InitSubSystem(Uint32 flags); 104 | 105 | /** 106 | * This function cleans up specific SDL subsystems 107 | */ 108 | extern DECLSPEC void SDLCALL SDL_QuitSubSystem(Uint32 flags); 109 | 110 | /** 111 | * This function returns a mask of the specified subsystems which have 112 | * previously been initialized. 113 | * 114 | * If \c flags is 0, it returns a mask of all initialized subsystems. 115 | */ 116 | extern DECLSPEC Uint32 SDLCALL SDL_WasInit(Uint32 flags); 117 | 118 | /** 119 | * This function cleans up all initialized subsystems. You should 120 | * call it upon all exit conditions. 121 | */ 122 | extern DECLSPEC void SDLCALL SDL_Quit(void); 123 | 124 | /* Ends C function definitions when using C++ */ 125 | #ifdef __cplusplus 126 | } 127 | #endif 128 | #include "close_code.h" 129 | 130 | #endif /* _SDL_H */ 131 | 132 | /* vi: set ts=4 sw=4 expandtab: */ 133 | -------------------------------------------------------------------------------- /enet/packet.c: -------------------------------------------------------------------------------- 1 | /** 2 | @file packet.c 3 | @brief ENet packet management functions 4 | */ 5 | #include 6 | #define ENET_BUILDING_LIB 1 7 | #include "enet/enet.h" 8 | 9 | /** @defgroup Packet ENet packet functions 10 | @{ 11 | */ 12 | 13 | /** Creates a packet that may be sent to a peer. 14 | @param data initial contents of the packet's data; the packet's data will remain uninitialized if data is NULL. 15 | @param dataLength size of the data allocated for this packet 16 | @param flags flags for this packet as described for the ENetPacket structure. 17 | @returns the packet on success, NULL on failure 18 | */ 19 | ENetPacket * 20 | enet_packet_create (const void * data, size_t dataLength, enet_uint32 flags) 21 | { 22 | ENetPacket * packet = (ENetPacket *) enet_malloc (sizeof (ENetPacket)); 23 | if (packet == NULL) 24 | return NULL; 25 | 26 | if (flags & ENET_PACKET_FLAG_NO_ALLOCATE) 27 | packet -> data = (enet_uint8 *) data; 28 | else 29 | if (dataLength <= 0) 30 | packet -> data = NULL; 31 | else 32 | { 33 | packet -> data = (enet_uint8 *) enet_malloc (dataLength); 34 | if (packet -> data == NULL) 35 | { 36 | enet_free (packet); 37 | return NULL; 38 | } 39 | 40 | if (data != NULL) 41 | memcpy (packet -> data, data, dataLength); 42 | } 43 | 44 | packet -> referenceCount = 0; 45 | packet -> flags = flags; 46 | packet -> dataLength = dataLength; 47 | packet -> freeCallback = NULL; 48 | packet -> userData = NULL; 49 | 50 | return packet; 51 | } 52 | 53 | /** Destroys the packet and deallocates its data. 54 | @param packet packet to be destroyed 55 | */ 56 | void 57 | enet_packet_destroy (ENetPacket * packet) 58 | { 59 | if (packet == NULL) 60 | return; 61 | 62 | if (packet -> freeCallback != NULL) 63 | (* packet -> freeCallback) (packet); 64 | if (! (packet -> flags & ENET_PACKET_FLAG_NO_ALLOCATE) && 65 | packet -> data != NULL) 66 | enet_free (packet -> data); 67 | enet_free (packet); 68 | } 69 | 70 | /** Attempts to resize the data in the packet to length specified in the 71 | dataLength parameter 72 | @param packet packet to resize 73 | @param dataLength new size for the packet data 74 | @returns 0 on success, < 0 on failure 75 | */ 76 | int 77 | enet_packet_resize (ENetPacket * packet, size_t dataLength) 78 | { 79 | enet_uint8 * newData; 80 | 81 | if (dataLength <= packet -> dataLength || (packet -> flags & ENET_PACKET_FLAG_NO_ALLOCATE)) 82 | { 83 | packet -> dataLength = dataLength; 84 | 85 | return 0; 86 | } 87 | 88 | newData = (enet_uint8 *) enet_malloc (dataLength); 89 | if (newData == NULL) 90 | return -1; 91 | 92 | memcpy (newData, packet -> data, packet -> dataLength); 93 | enet_free (packet -> data); 94 | 95 | packet -> data = newData; 96 | packet -> dataLength = dataLength; 97 | 98 | return 0; 99 | } 100 | 101 | static int initializedCRC32 = 0; 102 | static enet_uint32 crcTable [256]; 103 | 104 | static enet_uint32 105 | reflect_crc (int val, int bits) 106 | { 107 | int result = 0, bit; 108 | 109 | for (bit = 0; bit < bits; bit ++) 110 | { 111 | if(val & 1) result |= 1 << (bits - 1 - bit); 112 | val >>= 1; 113 | } 114 | 115 | return result; 116 | } 117 | 118 | static void 119 | initialize_crc32 (void) 120 | { 121 | int byte; 122 | 123 | for (byte = 0; byte < 256; ++ byte) 124 | { 125 | enet_uint32 crc = reflect_crc (byte, 8) << 24; 126 | int offset; 127 | 128 | for(offset = 0; offset < 8; ++ offset) 129 | { 130 | if (crc & 0x80000000) 131 | crc = (crc << 1) ^ 0x04c11db7; 132 | else 133 | crc <<= 1; 134 | } 135 | 136 | crcTable [byte] = reflect_crc (crc, 32); 137 | } 138 | 139 | initializedCRC32 = 1; 140 | } 141 | 142 | enet_uint32 143 | enet_crc32 (const ENetBuffer * buffers, size_t bufferCount) 144 | { 145 | enet_uint32 crc = 0xFFFFFFFF; 146 | 147 | if (! initializedCRC32) initialize_crc32 (); 148 | 149 | while (bufferCount -- > 0) 150 | { 151 | const enet_uint8 * data = (const enet_uint8 *) buffers -> data, 152 | * dataEnd = & data [buffers -> dataLength]; 153 | 154 | while (data < dataEnd) 155 | { 156 | crc = (crc >> 8) ^ crcTable [(crc & 0xFF) ^ *data++]; 157 | } 158 | 159 | ++ buffers; 160 | } 161 | 162 | return ENET_HOST_TO_NET_32 (~ crc); 163 | } 164 | 165 | /** @} */ 166 | -------------------------------------------------------------------------------- /include/begin_code.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file begin_code.h 24 | * 25 | * This file sets things up for C dynamic library function definitions, 26 | * static inlined functions, and structures aligned at 4-byte alignment. 27 | * If you don't like ugly C preprocessor code, don't look at this file. :) 28 | */ 29 | 30 | /* This shouldn't be nested -- included it around code only. */ 31 | #ifdef _begin_code_h 32 | #error Nested inclusion of begin_code.h 33 | #endif 34 | #define _begin_code_h 35 | 36 | #ifndef SDL_DEPRECATED 37 | # if (__GNUC__ >= 4) /* technically, this arrived in gcc 3.1, but oh well. */ 38 | # define SDL_DEPRECATED __attribute__((deprecated)) 39 | # else 40 | # define SDL_DEPRECATED 41 | # endif 42 | #endif 43 | 44 | #ifndef SDL_UNUSED 45 | # ifdef __GNUC__ 46 | # define SDL_UNUSED __attribute__((unused)) 47 | # else 48 | # define SDL_UNUSED 49 | # endif 50 | #endif 51 | 52 | /* Some compilers use a special export keyword */ 53 | #ifndef DECLSPEC 54 | # if defined(__WIN32__) || defined(__WINRT__) 55 | # ifdef __BORLANDC__ 56 | # ifdef BUILD_SDL 57 | # define DECLSPEC 58 | # else 59 | # define DECLSPEC __declspec(dllimport) 60 | # endif 61 | # else 62 | # define DECLSPEC __declspec(dllexport) 63 | # endif 64 | # else 65 | # if defined(__GNUC__) && __GNUC__ >= 4 66 | # define DECLSPEC __attribute__ ((visibility("default"))) 67 | # else 68 | # define DECLSPEC 69 | # endif 70 | # endif 71 | #endif 72 | 73 | /* By default SDL uses the C calling convention */ 74 | #ifndef SDLCALL 75 | #if (defined(__WIN32__) || defined(__WINRT__)) && !defined(__GNUC__) 76 | #define SDLCALL __cdecl 77 | #else 78 | #define SDLCALL 79 | #endif 80 | #endif /* SDLCALL */ 81 | 82 | /* Removed DECLSPEC on Symbian OS because SDL cannot be a DLL in EPOC */ 83 | #ifdef __SYMBIAN32__ 84 | #undef DECLSPEC 85 | #define DECLSPEC 86 | #endif /* __SYMBIAN32__ */ 87 | 88 | /* Force structure packing at 4 byte alignment. 89 | This is necessary if the header is included in code which has structure 90 | packing set to an alternate value, say for loading structures from disk. 91 | The packing is reset to the previous value in close_code.h 92 | */ 93 | #if defined(_MSC_VER) || defined(__MWERKS__) || defined(__BORLANDC__) 94 | #ifdef _MSC_VER 95 | #pragma warning(disable: 4103) 96 | #endif 97 | #ifdef __BORLANDC__ 98 | #pragma nopackwarning 99 | #endif 100 | #ifdef _M_X64 101 | /* Use 8-byte alignment on 64-bit architectures, so pointers are aligned */ 102 | #pragma pack(push,8) 103 | #else 104 | #pragma pack(push,4) 105 | #endif 106 | #endif /* Compiler needs structure packing set */ 107 | 108 | #ifndef SDL_INLINE 109 | #if defined(__GNUC__) 110 | #define SDL_INLINE __inline__ 111 | #elif defined(_MSC_VER) || defined(__BORLANDC__) || \ 112 | defined(__DMC__) || defined(__SC__) || \ 113 | defined(__WATCOMC__) || defined(__LCC__) || \ 114 | defined(__DECC) 115 | #define SDL_INLINE __inline 116 | #ifndef __inline__ 117 | #define __inline__ __inline 118 | #endif 119 | #else 120 | #define SDL_INLINE inline 121 | #ifndef __inline__ 122 | #define __inline__ inline 123 | #endif 124 | #endif 125 | #endif /* SDL_INLINE not defined */ 126 | 127 | #ifndef SDL_FORCE_INLINE 128 | #if defined(_MSC_VER) 129 | #define SDL_FORCE_INLINE __forceinline 130 | #elif ( (defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__) ) 131 | #define SDL_FORCE_INLINE __attribute__((always_inline)) static __inline__ 132 | #else 133 | #define SDL_FORCE_INLINE static SDL_INLINE 134 | #endif 135 | #endif /* SDL_FORCE_INLINE not defined */ 136 | 137 | /* Apparently this is needed by several Windows compilers */ 138 | #if !defined(__MACH__) 139 | #ifndef NULL 140 | #ifdef __cplusplus 141 | #define NULL 0 142 | #else 143 | #define NULL ((void *)0) 144 | #endif 145 | #endif /* NULL */ 146 | #endif /* ! Mac OS X - breaks precompiled headers */ 147 | -------------------------------------------------------------------------------- /engine/scale.h: -------------------------------------------------------------------------------- 1 | static void FUNCNAME(halvetexture)(uchar *src, uint sw, uint sh, uint stride, uchar *dst) 2 | { 3 | for(uchar *yend = &src[sh*stride]; src < yend;) 4 | { 5 | for(uchar *xend = &src[sw*BPP], *xsrc = src; xsrc < xend; xsrc += 2*BPP, dst += BPP) 6 | { 7 | #define OP(c, n) dst[n] = (uint(xsrc[n]) + uint(xsrc[n+BPP]) + uint(xsrc[stride+n]) + uint(xsrc[stride+n+BPP]))>>2 8 | PIXELOP 9 | #undef OP 10 | } 11 | src += 2*stride; 12 | } 13 | } 14 | 15 | static void FUNCNAME(shifttexture)(uchar *src, uint sw, uint sh, uint stride, uchar *dst, uint dw, uint dh) 16 | { 17 | uint wfrac = sw/dw, hfrac = sh/dh, wshift = 0, hshift = 0; 18 | while(dw<>tshift 40 | PIXELOP 41 | #undef OP 42 | } 43 | src += hfrac*stride; 44 | } 45 | } 46 | 47 | static void FUNCNAME(scaletexture)(uchar *src, uint sw, uint sh, uint stride, uchar *dst, uint dw, uint dh) 48 | { 49 | uint wfrac = (sw<<12)/dw, hfrac = (sh<<12)/dh, darea = dw*dh, sarea = sw*sh; 50 | int over, under; 51 | for(over = 0; (darea>>over) > sarea; over++); 52 | for(under = 0; (darea<>12, h = (yn>>12) - yi, ylow = ((yn|(-int(h)>>24))&0xFFFU) + 1 - (y&0xFFFU), yhigh = (yn&0xFFFU) + 1; 62 | const uchar *ysrc = &src[yi*stride]; 63 | for(uint x = 0; x < dw; x += wfrac, dst += BPP) 64 | { 65 | const uint xn = x + wfrac - 1, xi = x>>12, w = (xn>>12) - xi, xlow = ((w+0xFFFU)&0x1000U) - (x&0xFFFU), xhigh = (xn&0xFFFU) + 1; 66 | const uchar *xsrc = &ysrc[xi*BPP], *xend = &xsrc[w*BPP]; 67 | #define OP(c, n) c##t = 0 68 | DEFPIXEL 69 | #undef OP 70 | for(const uchar *xcur = &xsrc[BPP]; xcur < xend; xcur += BPP) 71 | { 72 | #define OP(c, n) c##t += xcur[n] 73 | PIXELOP 74 | #undef OP 75 | } 76 | #define OP(c, n) c##t = (ylow*(c##t + ((xsrc[n]*xlow + xend[n]*xhigh)>>12)))>>cscale 77 | PIXELOP 78 | #undef OP 79 | if(h) 80 | { 81 | xsrc += stride; 82 | xend += stride; 83 | for(uint hcur = h; --hcur; xsrc += stride, xend += stride) 84 | { 85 | #define OP(c, n) c = 0 86 | DEFPIXEL 87 | #undef OP 88 | for(const uchar *xcur = &xsrc[BPP]; xcur < xend; xcur += BPP) 89 | { 90 | #define OP(c, n) c += xcur[n] 91 | PIXELOP 92 | #undef OP 93 | } 94 | #define OP(c, n) c##t += ((c<<12) + xsrc[n]*xlow + xend[n]*xhigh)>>cscale; 95 | PIXELOP 96 | #undef OP 97 | } 98 | #define OP(c, n) c = 0 99 | DEFPIXEL 100 | #undef OP 101 | for(const uchar *xcur = &xsrc[BPP]; xcur < xend; xcur += BPP) 102 | { 103 | #define OP(c, n) c += xcur[n] 104 | PIXELOP 105 | #undef OP 106 | } 107 | #define OP(c, n) c##t += (yhigh*(c + ((xsrc[n]*xlow + xend[n]*xhigh)>>12)))>>cscale 108 | PIXELOP 109 | #undef OP 110 | } 111 | #define OP(c, n) dst[n] = (c##t * area)>>dscale 112 | PIXELOP 113 | #undef OP 114 | } 115 | } 116 | } 117 | 118 | #undef FUNCNAME 119 | #undef DEFPIXEL 120 | #undef PIXELOP 121 | #undef BPP 122 | 123 | -------------------------------------------------------------------------------- /include/SDL_cpuinfo.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_cpuinfo.h 24 | * 25 | * CPU feature detection for SDL. 26 | */ 27 | 28 | #ifndef _SDL_cpuinfo_h 29 | #define _SDL_cpuinfo_h 30 | 31 | #include "SDL_stdinc.h" 32 | 33 | /* Need to do this here because intrin.h has C++ code in it */ 34 | /* Visual Studio 2005 has a bug where intrin.h conflicts with winnt.h */ 35 | #if defined(_MSC_VER) && (_MSC_VER >= 1500) && (defined(_M_IX86) || defined(_M_X64)) 36 | #include 37 | #ifndef _WIN64 38 | #define __MMX__ 39 | #define __3dNOW__ 40 | #endif 41 | #define __SSE__ 42 | #define __SSE2__ 43 | #elif defined(__MINGW64_VERSION_MAJOR) 44 | #include 45 | #else 46 | #ifdef __ALTIVEC__ 47 | #if HAVE_ALTIVEC_H && !defined(__APPLE_ALTIVEC__) 48 | #include 49 | #undef pixel 50 | #endif 51 | #endif 52 | #ifdef __MMX__ 53 | #include 54 | #endif 55 | #ifdef __3dNOW__ 56 | #include 57 | #endif 58 | #ifdef __SSE__ 59 | #include 60 | #endif 61 | #ifdef __SSE2__ 62 | #include 63 | #endif 64 | #endif 65 | 66 | #include "begin_code.h" 67 | /* Set up for C function definitions, even when using C++ */ 68 | #ifdef __cplusplus 69 | extern "C" { 70 | #endif 71 | 72 | /* This is a guess for the cacheline size used for padding. 73 | * Most x86 processors have a 64 byte cache line. 74 | * The 64-bit PowerPC processors have a 128 byte cache line. 75 | * We'll use the larger value to be generally safe. 76 | */ 77 | #define SDL_CACHELINE_SIZE 128 78 | 79 | /** 80 | * This function returns the number of CPU cores available. 81 | */ 82 | extern DECLSPEC int SDLCALL SDL_GetCPUCount(void); 83 | 84 | /** 85 | * This function returns the L1 cache line size of the CPU 86 | * 87 | * This is useful for determining multi-threaded structure padding 88 | * or SIMD prefetch sizes. 89 | */ 90 | extern DECLSPEC int SDLCALL SDL_GetCPUCacheLineSize(void); 91 | 92 | /** 93 | * This function returns true if the CPU has the RDTSC instruction. 94 | */ 95 | extern DECLSPEC SDL_bool SDLCALL SDL_HasRDTSC(void); 96 | 97 | /** 98 | * This function returns true if the CPU has AltiVec features. 99 | */ 100 | extern DECLSPEC SDL_bool SDLCALL SDL_HasAltiVec(void); 101 | 102 | /** 103 | * This function returns true if the CPU has MMX features. 104 | */ 105 | extern DECLSPEC SDL_bool SDLCALL SDL_HasMMX(void); 106 | 107 | /** 108 | * This function returns true if the CPU has 3DNow! features. 109 | */ 110 | extern DECLSPEC SDL_bool SDLCALL SDL_Has3DNow(void); 111 | 112 | /** 113 | * This function returns true if the CPU has SSE features. 114 | */ 115 | extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE(void); 116 | 117 | /** 118 | * This function returns true if the CPU has SSE2 features. 119 | */ 120 | extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE2(void); 121 | 122 | /** 123 | * This function returns true if the CPU has SSE3 features. 124 | */ 125 | extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE3(void); 126 | 127 | /** 128 | * This function returns true if the CPU has SSE4.1 features. 129 | */ 130 | extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE41(void); 131 | 132 | /** 133 | * This function returns true if the CPU has SSE4.2 features. 134 | */ 135 | extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE42(void); 136 | 137 | /** 138 | * This function returns true if the CPU has AVX features. 139 | */ 140 | extern DECLSPEC SDL_bool SDLCALL SDL_HasAVX(void); 141 | 142 | /** 143 | * This function returns true if the CPU has AVX2 features. 144 | */ 145 | extern DECLSPEC SDL_bool SDLCALL SDL_HasAVX2(void); 146 | 147 | /** 148 | * This function returns the amount of RAM configured in the system, in MB. 149 | */ 150 | extern DECLSPEC int SDLCALL SDL_GetSystemRAM(void); 151 | 152 | 153 | /* Ends C function definitions when using C++ */ 154 | #ifdef __cplusplus 155 | } 156 | #endif 157 | #include "close_code.h" 158 | 159 | #endif /* _SDL_cpuinfo_h */ 160 | 161 | /* vi: set ts=4 sw=4 expandtab: */ 162 | -------------------------------------------------------------------------------- /include/SDL_rect.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_rect.h 24 | * 25 | * Header file for SDL_rect definition and management functions. 26 | */ 27 | 28 | #ifndef _SDL_rect_h 29 | #define _SDL_rect_h 30 | 31 | #include "SDL_stdinc.h" 32 | #include "SDL_error.h" 33 | #include "SDL_pixels.h" 34 | #include "SDL_rwops.h" 35 | 36 | #include "begin_code.h" 37 | /* Set up for C function definitions, even when using C++ */ 38 | #ifdef __cplusplus 39 | extern "C" { 40 | #endif 41 | 42 | /** 43 | * \brief The structure that defines a point 44 | * 45 | * \sa SDL_EnclosePoints 46 | * \sa SDL_PointInRect 47 | */ 48 | typedef struct SDL_Point 49 | { 50 | int x; 51 | int y; 52 | } SDL_Point; 53 | 54 | /** 55 | * \brief A rectangle, with the origin at the upper left. 56 | * 57 | * \sa SDL_RectEmpty 58 | * \sa SDL_RectEquals 59 | * \sa SDL_HasIntersection 60 | * \sa SDL_IntersectRect 61 | * \sa SDL_UnionRect 62 | * \sa SDL_EnclosePoints 63 | */ 64 | typedef struct SDL_Rect 65 | { 66 | int x, y; 67 | int w, h; 68 | } SDL_Rect; 69 | 70 | /** 71 | * \brief Returns true if point resides inside a rectangle. 72 | */ 73 | SDL_FORCE_INLINE SDL_bool SDL_PointInRect(const SDL_Point *p, const SDL_Rect *r) 74 | { 75 | return ( (p->x >= r->x) && (p->x < (r->x + r->w)) && 76 | (p->y >= r->y) && (p->y < (r->y + r->h)) ) ? SDL_TRUE : SDL_FALSE; 77 | } 78 | 79 | /** 80 | * \brief Returns true if the rectangle has no area. 81 | */ 82 | SDL_FORCE_INLINE SDL_bool SDL_RectEmpty(const SDL_Rect *r) 83 | { 84 | return ((!r) || (r->w <= 0) || (r->h <= 0)) ? SDL_TRUE : SDL_FALSE; 85 | } 86 | 87 | /** 88 | * \brief Returns true if the two rectangles are equal. 89 | */ 90 | SDL_FORCE_INLINE SDL_bool SDL_RectEquals(const SDL_Rect *a, const SDL_Rect *b) 91 | { 92 | return (a && b && (a->x == b->x) && (a->y == b->y) && 93 | (a->w == b->w) && (a->h == b->h)) ? SDL_TRUE : SDL_FALSE; 94 | } 95 | 96 | /** 97 | * \brief Determine whether two rectangles intersect. 98 | * 99 | * \return SDL_TRUE if there is an intersection, SDL_FALSE otherwise. 100 | */ 101 | extern DECLSPEC SDL_bool SDLCALL SDL_HasIntersection(const SDL_Rect * A, 102 | const SDL_Rect * B); 103 | 104 | /** 105 | * \brief Calculate the intersection of two rectangles. 106 | * 107 | * \return SDL_TRUE if there is an intersection, SDL_FALSE otherwise. 108 | */ 109 | extern DECLSPEC SDL_bool SDLCALL SDL_IntersectRect(const SDL_Rect * A, 110 | const SDL_Rect * B, 111 | SDL_Rect * result); 112 | 113 | /** 114 | * \brief Calculate the union of two rectangles. 115 | */ 116 | extern DECLSPEC void SDLCALL SDL_UnionRect(const SDL_Rect * A, 117 | const SDL_Rect * B, 118 | SDL_Rect * result); 119 | 120 | /** 121 | * \brief Calculate a minimal rectangle enclosing a set of points 122 | * 123 | * \return SDL_TRUE if any points were within the clipping rect 124 | */ 125 | extern DECLSPEC SDL_bool SDLCALL SDL_EnclosePoints(const SDL_Point * points, 126 | int count, 127 | const SDL_Rect * clip, 128 | SDL_Rect * result); 129 | 130 | /** 131 | * \brief Calculate the intersection of a rectangle and line segment. 132 | * 133 | * \return SDL_TRUE if there is an intersection, SDL_FALSE otherwise. 134 | */ 135 | extern DECLSPEC SDL_bool SDLCALL SDL_IntersectRectAndLine(const SDL_Rect * 136 | rect, int *X1, 137 | int *Y1, int *X2, 138 | int *Y2); 139 | 140 | /* Ends C function definitions when using C++ */ 141 | #ifdef __cplusplus 142 | } 143 | #endif 144 | #include "close_code.h" 145 | 146 | #endif /* _SDL_rect_h */ 147 | 148 | /* vi: set ts=4 sw=4 expandtab: */ 149 | -------------------------------------------------------------------------------- /include/SDL_messagebox.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | #ifndef _SDL_messagebox_h 23 | #define _SDL_messagebox_h 24 | 25 | #include "SDL_stdinc.h" 26 | #include "SDL_video.h" /* For SDL_Window */ 27 | 28 | #include "begin_code.h" 29 | /* Set up for C function definitions, even when using C++ */ 30 | #ifdef __cplusplus 31 | extern "C" { 32 | #endif 33 | 34 | /** 35 | * \brief SDL_MessageBox flags. If supported will display warning icon, etc. 36 | */ 37 | typedef enum 38 | { 39 | SDL_MESSAGEBOX_ERROR = 0x00000010, /**< error dialog */ 40 | SDL_MESSAGEBOX_WARNING = 0x00000020, /**< warning dialog */ 41 | SDL_MESSAGEBOX_INFORMATION = 0x00000040 /**< informational dialog */ 42 | } SDL_MessageBoxFlags; 43 | 44 | /** 45 | * \brief Flags for SDL_MessageBoxButtonData. 46 | */ 47 | typedef enum 48 | { 49 | SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT = 0x00000001, /**< Marks the default button when return is hit */ 50 | SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT = 0x00000002 /**< Marks the default button when escape is hit */ 51 | } SDL_MessageBoxButtonFlags; 52 | 53 | /** 54 | * \brief Individual button data. 55 | */ 56 | typedef struct 57 | { 58 | Uint32 flags; /**< ::SDL_MessageBoxButtonFlags */ 59 | int buttonid; /**< User defined button id (value returned via SDL_ShowMessageBox) */ 60 | const char * text; /**< The UTF-8 button text */ 61 | } SDL_MessageBoxButtonData; 62 | 63 | /** 64 | * \brief RGB value used in a message box color scheme 65 | */ 66 | typedef struct 67 | { 68 | Uint8 r, g, b; 69 | } SDL_MessageBoxColor; 70 | 71 | typedef enum 72 | { 73 | SDL_MESSAGEBOX_COLOR_BACKGROUND, 74 | SDL_MESSAGEBOX_COLOR_TEXT, 75 | SDL_MESSAGEBOX_COLOR_BUTTON_BORDER, 76 | SDL_MESSAGEBOX_COLOR_BUTTON_BACKGROUND, 77 | SDL_MESSAGEBOX_COLOR_BUTTON_SELECTED, 78 | SDL_MESSAGEBOX_COLOR_MAX 79 | } SDL_MessageBoxColorType; 80 | 81 | /** 82 | * \brief A set of colors to use for message box dialogs 83 | */ 84 | typedef struct 85 | { 86 | SDL_MessageBoxColor colors[SDL_MESSAGEBOX_COLOR_MAX]; 87 | } SDL_MessageBoxColorScheme; 88 | 89 | /** 90 | * \brief MessageBox structure containing title, text, window, etc. 91 | */ 92 | typedef struct 93 | { 94 | Uint32 flags; /**< ::SDL_MessageBoxFlags */ 95 | SDL_Window *window; /**< Parent window, can be NULL */ 96 | const char *title; /**< UTF-8 title */ 97 | const char *message; /**< UTF-8 message text */ 98 | 99 | int numbuttons; 100 | const SDL_MessageBoxButtonData *buttons; 101 | 102 | const SDL_MessageBoxColorScheme *colorScheme; /**< ::SDL_MessageBoxColorScheme, can be NULL to use system settings */ 103 | } SDL_MessageBoxData; 104 | 105 | /** 106 | * \brief Create a modal message box. 107 | * 108 | * \param messageboxdata The SDL_MessageBoxData structure with title, text, etc. 109 | * \param buttonid The pointer to which user id of hit button should be copied. 110 | * 111 | * \return -1 on error, otherwise 0 and buttonid contains user id of button 112 | * hit or -1 if dialog was closed. 113 | * 114 | * \note This function should be called on the thread that created the parent 115 | * window, or on the main thread if the messagebox has no parent. It will 116 | * block execution of that thread until the user clicks a button or 117 | * closes the messagebox. 118 | */ 119 | extern DECLSPEC int SDLCALL SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid); 120 | 121 | /** 122 | * \brief Create a simple modal message box 123 | * 124 | * \param flags ::SDL_MessageBoxFlags 125 | * \param title UTF-8 title text 126 | * \param message UTF-8 message text 127 | * \param window The parent window, or NULL for no parent 128 | * 129 | * \return 0 on success, -1 on error 130 | * 131 | * \sa SDL_ShowMessageBox 132 | */ 133 | extern DECLSPEC int SDLCALL SDL_ShowSimpleMessageBox(Uint32 flags, const char *title, const char *message, SDL_Window *window); 134 | 135 | 136 | /* Ends C function definitions when using C++ */ 137 | #ifdef __cplusplus 138 | } 139 | #endif 140 | #include "close_code.h" 141 | 142 | #endif /* _SDL_messagebox_h */ 143 | 144 | /* vi: set ts=4 sw=4 expandtab: */ 145 | -------------------------------------------------------------------------------- /include/SDL_main.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | #ifndef _SDL_main_h 23 | #define _SDL_main_h 24 | 25 | #include "SDL_stdinc.h" 26 | 27 | /** 28 | * \file SDL_main.h 29 | * 30 | * Redefine main() on some platforms so that it is called by SDL. 31 | */ 32 | 33 | #ifndef SDL_MAIN_HANDLED 34 | #if defined(__WIN32__) 35 | /* On Windows SDL provides WinMain(), which parses the command line and passes 36 | the arguments to your main function. 37 | 38 | If you provide your own WinMain(), you may define SDL_MAIN_HANDLED 39 | */ 40 | #define SDL_MAIN_AVAILABLE 41 | 42 | #elif defined(__WINRT__) 43 | /* On WinRT, SDL provides a main function that initializes CoreApplication, 44 | creating an instance of IFrameworkView in the process. 45 | 46 | Please note that #include'ing SDL_main.h is not enough to get a main() 47 | function working. In non-XAML apps, the file, 48 | src/main/winrt/SDL_WinRT_main_NonXAML.cpp, or a copy of it, must be compiled 49 | into the app itself. In XAML apps, the function, SDL_WinRTRunApp must be 50 | called, with a pointer to the Direct3D-hosted XAML control passed in. 51 | */ 52 | #define SDL_MAIN_NEEDED 53 | 54 | #elif defined(__IPHONEOS__) 55 | /* On iOS SDL provides a main function that creates an application delegate 56 | and starts the iOS application run loop. 57 | 58 | See src/video/uikit/SDL_uikitappdelegate.m for more details. 59 | */ 60 | #define SDL_MAIN_NEEDED 61 | 62 | #elif defined(__ANDROID__) 63 | /* On Android SDL provides a Java class in SDLActivity.java that is the 64 | main activity entry point. 65 | 66 | See README-android.txt for more details on extending that class. 67 | */ 68 | #define SDL_MAIN_NEEDED 69 | 70 | #elif defined(__NACL__) 71 | /* On NACL we use ppapi_simple to set up the application helper code, 72 | then wait for the first PSE_INSTANCE_DIDCHANGEVIEW event before 73 | starting the user main function. 74 | All user code is run in a separate thread by ppapi_simple, thus 75 | allowing for blocking io to take place via nacl_io 76 | */ 77 | #define SDL_MAIN_NEEDED 78 | 79 | #endif 80 | #endif /* SDL_MAIN_HANDLED */ 81 | 82 | #ifdef __cplusplus 83 | #define C_LINKAGE "C" 84 | #else 85 | #define C_LINKAGE 86 | #endif /* __cplusplus */ 87 | 88 | /** 89 | * \file SDL_main.h 90 | * 91 | * The application's main() function must be called with C linkage, 92 | * and should be declared like this: 93 | * \code 94 | * #ifdef __cplusplus 95 | * extern "C" 96 | * #endif 97 | * int main(int argc, char *argv[]) 98 | * { 99 | * } 100 | * \endcode 101 | */ 102 | 103 | #if defined(SDL_MAIN_NEEDED) || defined(SDL_MAIN_AVAILABLE) 104 | #define main SDL_main 105 | #endif 106 | 107 | /** 108 | * The prototype for the application's main() function 109 | */ 110 | extern C_LINKAGE int SDL_main(int argc, char *argv[]); 111 | 112 | 113 | #include "begin_code.h" 114 | #ifdef __cplusplus 115 | extern "C" { 116 | #endif 117 | 118 | /** 119 | * This is called by the real SDL main function to let the rest of the 120 | * library know that initialization was done properly. 121 | * 122 | * Calling this yourself without knowing what you're doing can cause 123 | * crashes and hard to diagnose problems with your application. 124 | */ 125 | extern DECLSPEC void SDLCALL SDL_SetMainReady(void); 126 | 127 | #ifdef __WIN32__ 128 | 129 | /** 130 | * This can be called to set the application class at startup 131 | */ 132 | extern DECLSPEC int SDLCALL SDL_RegisterApp(char *name, Uint32 style, 133 | void *hInst); 134 | extern DECLSPEC void SDLCALL SDL_UnregisterApp(void); 135 | 136 | #endif /* __WIN32__ */ 137 | 138 | 139 | #ifdef __WINRT__ 140 | 141 | /** 142 | * \brief Initializes and launches an SDL/WinRT application. 143 | * 144 | * \param mainFunction The SDL app's C-style main(). 145 | * \param reserved Reserved for future use; should be NULL 146 | * \return 0 on success, -1 on failure. On failure, use SDL_GetError to retrieve more 147 | * information on the failure. 148 | */ 149 | extern DECLSPEC int SDLCALL SDL_WinRTRunApp(int (*mainFunction)(int, char **), void * reserved); 150 | 151 | #endif /* __WINRT__ */ 152 | 153 | 154 | #ifdef __cplusplus 155 | } 156 | #endif 157 | #include "close_code.h" 158 | 159 | #endif /* _SDL_main_h */ 160 | 161 | /* vi: set ts=4 sw=4 expandtab: */ 162 | -------------------------------------------------------------------------------- /fpsgame/extinfo.h: -------------------------------------------------------------------------------- 1 | 2 | #define EXT_ACK -1 3 | #define EXT_VERSION 105 4 | #define EXT_NO_ERROR 0 5 | #define EXT_ERROR 1 6 | #define EXT_PLAYERSTATS_RESP_IDS -10 7 | #define EXT_PLAYERSTATS_RESP_STATS -11 8 | #define EXT_UPTIME 0 9 | #define EXT_PLAYERSTATS 1 10 | #define EXT_TEAMSCORE 2 11 | 12 | /* 13 | Client: 14 | ----- 15 | A: 0 EXT_UPTIME 16 | B: 0 EXT_PLAYERSTATS cn #a client number or -1 for all players# 17 | C: 0 EXT_TEAMSCORE 18 | 19 | Server: 20 | -------- 21 | A: 0 EXT_UPTIME EXT_ACK EXT_VERSION uptime #in seconds# 22 | B: 0 EXT_PLAYERSTATS cn #send by client# EXT_ACK EXT_VERSION 0 or 1 #error, if cn was > -1 and client does not exist# ... 23 | EXT_PLAYERSTATS_RESP_IDS pid(s) #1 packet# 24 | EXT_PLAYERSTATS_RESP_STATS pid playerdata #1 packet for each player# 25 | C: 0 EXT_TEAMSCORE EXT_ACK EXT_VERSION 0 or 1 #error, no teammode# remaining_time gamemode loop(teamdata [numbases bases] or -1) 26 | 27 | Errors: 28 | -------------- 29 | B:C:default: 0 command EXT_ACK EXT_VERSION EXT_ERROR 30 | */ 31 | 32 | void extinfoplayer(ucharbuf &p, clientinfo *ci) 33 | { 34 | ucharbuf q = p; 35 | putint(q, EXT_PLAYERSTATS_RESP_STATS); // send player stats following 36 | putint(q, ci->clientnum); //add player id 37 | putint(q, ci->ping); 38 | sendstring(ci->name, q); 39 | sendstring(ci->team, q); 40 | putint(q, ci->state.frags); 41 | putint(q, ci->state.flags); 42 | putint(q, ci->state.deaths); 43 | putint(q, ci->state.teamkills); 44 | putint(q, ci->state.damage*100/max(ci->state.shotdamage,1)); 45 | putint(q, ci->state.health); 46 | putint(q, ci->state.armour); 47 | putint(q, ci->state.gunselect); 48 | putint(q, ci->privilege); 49 | putint(q, ci->state.state); 50 | uint ip = getclientip(ci->clientnum); 51 | q.put((uchar*)&ip, 3); 52 | sendserverinforeply(q); 53 | } 54 | 55 | static inline void extinfoteamscore(ucharbuf &p, const char *team, int score) 56 | { 57 | sendstring(team, p); 58 | putint(p, score); 59 | if(!smode || !smode->extinfoteam(team, p)) 60 | putint(p,-1); //no bases follow 61 | } 62 | 63 | void extinfoteams(ucharbuf &p) 64 | { 65 | putint(p, m_teammode ? 0 : 1); 66 | putint(p, gamemode); 67 | putint(p, max((gamelimit - gamemillis)/1000, 0)); 68 | if(!m_teammode) return; 69 | 70 | vector scores; 71 | if(smode && smode->hidefrags()) smode->getteamscores(scores); 72 | loopv(clients) 73 | { 74 | clientinfo *ci = clients[i]; 75 | if(ci->state.state!=CS_SPECTATOR && ci->team[0] && scores.htfind(ci->team) < 0) 76 | { 77 | if(smode && smode->hidefrags()) scores.add(teamscore(ci->team, 0)); 78 | else { teaminfo *ti = teaminfos.access(ci->team); scores.add(teamscore(ci->team, ti ? ti->frags : 0)); } 79 | } 80 | } 81 | loopv(scores) extinfoteamscore(p, scores[i].team, scores[i].score); 82 | } 83 | 84 | void extserverinforeply(ucharbuf &req, ucharbuf &p) 85 | { 86 | int extcmd = getint(req); // extended commands 87 | 88 | //Build a new packet 89 | putint(p, EXT_ACK); //send ack 90 | putint(p, EXT_VERSION); //send version of extended info 91 | 92 | switch(extcmd) 93 | { 94 | case EXT_UPTIME: 95 | { 96 | putint(p, totalsecs); //in seconds 97 | break; 98 | } 99 | 100 | case EXT_PLAYERSTATS: 101 | { 102 | int cn = getint(req); //a special player, -1 for all 103 | 104 | clientinfo *ci = NULL; 105 | if(cn >= 0) 106 | { 107 | loopv(clients) if(clients[i]->clientnum == cn) { ci = clients[i]; break; } 108 | if(!ci) 109 | { 110 | putint(p, EXT_ERROR); //client requested by id was not found 111 | sendserverinforeply(p); 112 | return; 113 | } 114 | } 115 | 116 | putint(p, EXT_NO_ERROR); //so far no error can happen anymore 117 | 118 | ucharbuf q = p; //remember buffer position 119 | putint(q, EXT_PLAYERSTATS_RESP_IDS); //send player ids following 120 | if(ci) putint(q, ci->clientnum); 121 | else loopv(clients) putint(q, clients[i]->clientnum); 122 | sendserverinforeply(q); 123 | 124 | if(ci) extinfoplayer(p, ci); 125 | else loopv(clients) extinfoplayer(p, clients[i]); 126 | return; 127 | } 128 | 129 | case EXT_TEAMSCORE: 130 | { 131 | extinfoteams(p); 132 | break; 133 | } 134 | 135 | default: 136 | { 137 | putint(p, EXT_ERROR); 138 | break; 139 | } 140 | } 141 | sendserverinforeply(p); 142 | } 143 | 144 | -------------------------------------------------------------------------------- /include/SDL_platform.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_platform.h 24 | * 25 | * Try to get a standard set of platform defines. 26 | */ 27 | 28 | #ifndef _SDL_platform_h 29 | #define _SDL_platform_h 30 | 31 | #if defined(_AIX) 32 | #undef __AIX__ 33 | #define __AIX__ 1 34 | #endif 35 | #if defined(__HAIKU__) 36 | #undef __HAIKU__ 37 | #define __HAIKU__ 1 38 | #endif 39 | #if defined(bsdi) || defined(__bsdi) || defined(__bsdi__) 40 | #undef __BSDI__ 41 | #define __BSDI__ 1 42 | #endif 43 | #if defined(_arch_dreamcast) 44 | #undef __DREAMCAST__ 45 | #define __DREAMCAST__ 1 46 | #endif 47 | #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) 48 | #undef __FREEBSD__ 49 | #define __FREEBSD__ 1 50 | #endif 51 | #if defined(hpux) || defined(__hpux) || defined(__hpux__) 52 | #undef __HPUX__ 53 | #define __HPUX__ 1 54 | #endif 55 | #if defined(sgi) || defined(__sgi) || defined(__sgi__) || defined(_SGI_SOURCE) 56 | #undef __IRIX__ 57 | #define __IRIX__ 1 58 | #endif 59 | #if (defined(linux) || defined(__linux) || defined(__linux__)) 60 | #undef __LINUX__ 61 | #define __LINUX__ 1 62 | #endif 63 | #if defined(ANDROID) || defined(__ANDROID__) 64 | #undef __ANDROID__ 65 | #undef __LINUX__ /* do we need to do this? */ 66 | #define __ANDROID__ 1 67 | #endif 68 | 69 | #if defined(__APPLE__) 70 | /* lets us know what version of Mac OS X we're compiling on */ 71 | #include "AvailabilityMacros.h" 72 | #include "TargetConditionals.h" 73 | #if TARGET_OS_IPHONE 74 | /* if compiling for iPhone */ 75 | #undef __IPHONEOS__ 76 | #define __IPHONEOS__ 1 77 | #undef __MACOSX__ 78 | #else 79 | /* if not compiling for iPhone */ 80 | #undef __MACOSX__ 81 | #define __MACOSX__ 1 82 | #if MAC_OS_X_VERSION_MIN_REQUIRED < 1050 83 | # error SDL for Mac OS X only supports deploying on 10.5 and above. 84 | #endif /* MAC_OS_X_VERSION_MIN_REQUIRED < 1050 */ 85 | #endif /* TARGET_OS_IPHONE */ 86 | #endif /* defined(__APPLE__) */ 87 | 88 | #if defined(__NetBSD__) 89 | #undef __NETBSD__ 90 | #define __NETBSD__ 1 91 | #endif 92 | #if defined(__OpenBSD__) 93 | #undef __OPENBSD__ 94 | #define __OPENBSD__ 1 95 | #endif 96 | #if defined(__OS2__) 97 | #undef __OS2__ 98 | #define __OS2__ 1 99 | #endif 100 | #if defined(osf) || defined(__osf) || defined(__osf__) || defined(_OSF_SOURCE) 101 | #undef __OSF__ 102 | #define __OSF__ 1 103 | #endif 104 | #if defined(__QNXNTO__) 105 | #undef __QNXNTO__ 106 | #define __QNXNTO__ 1 107 | #endif 108 | #if defined(riscos) || defined(__riscos) || defined(__riscos__) 109 | #undef __RISCOS__ 110 | #define __RISCOS__ 1 111 | #endif 112 | #if defined(__sun) && defined(__SVR4) 113 | #undef __SOLARIS__ 114 | #define __SOLARIS__ 1 115 | #endif 116 | 117 | #if defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__) || defined(__MINGW32__) 118 | /* Try to find out if we're compiling for WinRT or non-WinRT */ 119 | /* If _USING_V110_SDK71_ is defined it means we are using the v110_xp or v120_xp toolset. */ 120 | #if (defined(_MSC_VER) && (_MSC_VER >= 1700) && !_USING_V110_SDK71_) /* _MSC_VER==1700 for MSVC 2012 */ 121 | #include 122 | #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) 123 | #undef __WINDOWS__ 124 | #define __WINDOWS__ 1 125 | /* See if we're compiling for WinRT: */ 126 | #elif WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) 127 | #undef __WINRT__ 128 | #define __WINRT__ 1 129 | #endif 130 | #else 131 | #undef __WINDOWS__ 132 | #define __WINDOWS__ 1 133 | #endif /* _MSC_VER < 1700 */ 134 | #endif /* defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__) */ 135 | 136 | #if defined(__WINDOWS__) 137 | #undef __WIN32__ 138 | #define __WIN32__ 1 139 | #endif 140 | #if defined(__PSP__) 141 | #undef __PSP__ 142 | #define __PSP__ 1 143 | #endif 144 | 145 | /* The NACL compiler defines __native_client__ and __pnacl__ 146 | * Ref: http://www.chromium.org/nativeclient/pnacl/stability-of-the-pnacl-bitcode-abi 147 | */ 148 | #if defined(__native_client__) 149 | #undef __LINUX__ 150 | #undef __NACL__ 151 | #define __NACL__ 1 152 | #endif 153 | #if defined(__pnacl__) 154 | #undef __LINUX__ 155 | #undef __PNACL__ 156 | #define __PNACL__ 1 157 | /* PNACL with newlib supports static linking only */ 158 | #define __SDL_NOGETPROCADDR__ 159 | #endif 160 | 161 | 162 | #include "begin_code.h" 163 | /* Set up for C function definitions, even when using C++ */ 164 | #ifdef __cplusplus 165 | extern "C" { 166 | #endif 167 | 168 | /** 169 | * \brief Gets the name of the platform. 170 | */ 171 | extern DECLSPEC const char * SDLCALL SDL_GetPlatform (void); 172 | 173 | /* Ends C function definitions when using C++ */ 174 | #ifdef __cplusplus 175 | } 176 | #endif 177 | #include "close_code.h" 178 | 179 | #endif /* _SDL_platform_h */ 180 | 181 | /* vi: set ts=4 sw=4 expandtab: */ 182 | -------------------------------------------------------------------------------- /include/SDL_filesystem.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_filesystem.h 24 | * 25 | * \brief Include file for filesystem SDL API functions 26 | */ 27 | 28 | #ifndef _SDL_filesystem_h 29 | #define _SDL_filesystem_h 30 | 31 | #include "SDL_stdinc.h" 32 | 33 | #include "begin_code.h" 34 | 35 | /* Set up for C function definitions, even when using C++ */ 36 | #ifdef __cplusplus 37 | extern "C" { 38 | #endif 39 | 40 | /** 41 | * \brief Get the path where the application resides. 42 | * 43 | * Get the "base path". This is the directory where the application was run 44 | * from, which is probably the installation directory, and may or may not 45 | * be the process's current working directory. 46 | * 47 | * This returns an absolute path in UTF-8 encoding, and is guaranteed to 48 | * end with a path separator ('\\' on Windows, '/' most other places). 49 | * 50 | * The pointer returned by this function is owned by you. Please call 51 | * SDL_free() on the pointer when you are done with it, or it will be a 52 | * memory leak. This is not necessarily a fast call, though, so you should 53 | * call this once near startup and save the string if you need it. 54 | * 55 | * Some platforms can't determine the application's path, and on other 56 | * platforms, this might be meaningless. In such cases, this function will 57 | * return NULL. 58 | * 59 | * \return String of base dir in UTF-8 encoding, or NULL on error. 60 | * 61 | * \sa SDL_GetPrefPath 62 | */ 63 | extern DECLSPEC char *SDLCALL SDL_GetBasePath(void); 64 | 65 | /** 66 | * \brief Get the user-and-app-specific path where files can be written. 67 | * 68 | * Get the "pref dir". This is meant to be where users can write personal 69 | * files (preferences and save games, etc) that are specific to your 70 | * application. This directory is unique per user, per application. 71 | * 72 | * This function will decide the appropriate location in the native filesystem, 73 | * create the directory if necessary, and return a string of the absolute 74 | * path to the directory in UTF-8 encoding. 75 | * 76 | * On Windows, the string might look like: 77 | * "C:\\Users\\bob\\AppData\\Roaming\\My Company\\My Program Name\\" 78 | * 79 | * On Linux, the string might look like: 80 | * "/home/bob/.local/share/My Program Name/" 81 | * 82 | * On Mac OS X, the string might look like: 83 | * "/Users/bob/Library/Application Support/My Program Name/" 84 | * 85 | * (etc.) 86 | * 87 | * You specify the name of your organization (if it's not a real organization, 88 | * your name or an Internet domain you own might do) and the name of your 89 | * application. These should be untranslated proper names. 90 | * 91 | * Both the org and app strings may become part of a directory name, so 92 | * please follow these rules: 93 | * 94 | * - Try to use the same org string (including case-sensitivity) for 95 | * all your applications that use this function. 96 | * - Always use a unique app string for each one, and make sure it never 97 | * changes for an app once you've decided on it. 98 | * - Unicode characters are legal, as long as it's UTF-8 encoded, but... 99 | * - ...only use letters, numbers, and spaces. Avoid punctuation like 100 | * "Game Name 2: Bad Guy's Revenge!" ... "Game Name 2" is sufficient. 101 | * 102 | * This returns an absolute path in UTF-8 encoding, and is guaranteed to 103 | * end with a path separator ('\\' on Windows, '/' most other places). 104 | * 105 | * The pointer returned by this function is owned by you. Please call 106 | * SDL_free() on the pointer when you are done with it, or it will be a 107 | * memory leak. This is not necessarily a fast call, though, so you should 108 | * call this once near startup and save the string if you need it. 109 | * 110 | * You should assume the path returned by this function is the only safe 111 | * place to write files (and that SDL_GetBasePath(), while it might be 112 | * writable, or even the parent of the returned path, aren't where you 113 | * should be writing things). 114 | * 115 | * Some platforms can't determine the pref path, and on other 116 | * platforms, this might be meaningless. In such cases, this function will 117 | * return NULL. 118 | * 119 | * \param org The name of your organization. 120 | * \param app The name of your application. 121 | * \return UTF-8 string of user dir in platform-dependent notation. NULL 122 | * if there's a problem (creating directory failed, etc). 123 | * 124 | * \sa SDL_GetBasePath 125 | */ 126 | extern DECLSPEC char *SDLCALL SDL_GetPrefPath(const char *org, const char *app); 127 | 128 | /* Ends C function definitions when using C++ */ 129 | #ifdef __cplusplus 130 | } 131 | #endif 132 | #include "close_code.h" 133 | 134 | #endif /* _SDL_filesystem_h */ 135 | 136 | /* vi: set ts=4 sw=4 expandtab: */ 137 | -------------------------------------------------------------------------------- /include/SDL_version.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_version.h 24 | * 25 | * This header defines the current SDL version. 26 | */ 27 | 28 | #ifndef _SDL_version_h 29 | #define _SDL_version_h 30 | 31 | #include "SDL_stdinc.h" 32 | 33 | #include "begin_code.h" 34 | /* Set up for C function definitions, even when using C++ */ 35 | #ifdef __cplusplus 36 | extern "C" { 37 | #endif 38 | 39 | /** 40 | * \brief Information the version of SDL in use. 41 | * 42 | * Represents the library's version as three levels: major revision 43 | * (increments with massive changes, additions, and enhancements), 44 | * minor revision (increments with backwards-compatible changes to the 45 | * major revision), and patchlevel (increments with fixes to the minor 46 | * revision). 47 | * 48 | * \sa SDL_VERSION 49 | * \sa SDL_GetVersion 50 | */ 51 | typedef struct SDL_version 52 | { 53 | Uint8 major; /**< major version */ 54 | Uint8 minor; /**< minor version */ 55 | Uint8 patch; /**< update version */ 56 | } SDL_version; 57 | 58 | /* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL 59 | */ 60 | #define SDL_MAJOR_VERSION 2 61 | #define SDL_MINOR_VERSION 0 62 | #define SDL_PATCHLEVEL 4 63 | 64 | /** 65 | * \brief Macro to determine SDL version program was compiled against. 66 | * 67 | * This macro fills in a SDL_version structure with the version of the 68 | * library you compiled against. This is determined by what header the 69 | * compiler uses. Note that if you dynamically linked the library, you might 70 | * have a slightly newer or older version at runtime. That version can be 71 | * determined with SDL_GetVersion(), which, unlike SDL_VERSION(), 72 | * is not a macro. 73 | * 74 | * \param x A pointer to a SDL_version struct to initialize. 75 | * 76 | * \sa SDL_version 77 | * \sa SDL_GetVersion 78 | */ 79 | #define SDL_VERSION(x) \ 80 | { \ 81 | (x)->major = SDL_MAJOR_VERSION; \ 82 | (x)->minor = SDL_MINOR_VERSION; \ 83 | (x)->patch = SDL_PATCHLEVEL; \ 84 | } 85 | 86 | /** 87 | * This macro turns the version numbers into a numeric value: 88 | * \verbatim 89 | (1,2,3) -> (1203) 90 | \endverbatim 91 | * 92 | * This assumes that there will never be more than 100 patchlevels. 93 | */ 94 | #define SDL_VERSIONNUM(X, Y, Z) \ 95 | ((X)*1000 + (Y)*100 + (Z)) 96 | 97 | /** 98 | * This is the version number macro for the current SDL version. 99 | */ 100 | #define SDL_COMPILEDVERSION \ 101 | SDL_VERSIONNUM(SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL) 102 | 103 | /** 104 | * This macro will evaluate to true if compiled with SDL at least X.Y.Z. 105 | */ 106 | #define SDL_VERSION_ATLEAST(X, Y, Z) \ 107 | (SDL_COMPILEDVERSION >= SDL_VERSIONNUM(X, Y, Z)) 108 | 109 | /** 110 | * \brief Get the version of SDL that is linked against your program. 111 | * 112 | * If you are linking to SDL dynamically, then it is possible that the 113 | * current version will be different than the version you compiled against. 114 | * This function returns the current version, while SDL_VERSION() is a 115 | * macro that tells you what version you compiled with. 116 | * 117 | * \code 118 | * SDL_version compiled; 119 | * SDL_version linked; 120 | * 121 | * SDL_VERSION(&compiled); 122 | * SDL_GetVersion(&linked); 123 | * printf("We compiled against SDL version %d.%d.%d ...\n", 124 | * compiled.major, compiled.minor, compiled.patch); 125 | * printf("But we linked against SDL version %d.%d.%d.\n", 126 | * linked.major, linked.minor, linked.patch); 127 | * \endcode 128 | * 129 | * This function may be called safely at any time, even before SDL_Init(). 130 | * 131 | * \sa SDL_VERSION 132 | */ 133 | extern DECLSPEC void SDLCALL SDL_GetVersion(SDL_version * ver); 134 | 135 | /** 136 | * \brief Get the code revision of SDL that is linked against your program. 137 | * 138 | * Returns an arbitrary string (a hash value) uniquely identifying the 139 | * exact revision of the SDL library in use, and is only useful in comparing 140 | * against other revisions. It is NOT an incrementing number. 141 | */ 142 | extern DECLSPEC const char *SDLCALL SDL_GetRevision(void); 143 | 144 | /** 145 | * \brief Get the revision number of SDL that is linked against your program. 146 | * 147 | * Returns a number uniquely identifying the exact revision of the SDL 148 | * library in use. It is an incrementing number based on commits to 149 | * hg.libsdl.org. 150 | */ 151 | extern DECLSPEC int SDLCALL SDL_GetRevisionNumber(void); 152 | 153 | 154 | /* Ends C function definitions when using C++ */ 155 | #ifdef __cplusplus 156 | } 157 | #endif 158 | #include "close_code.h" 159 | 160 | #endif /* _SDL_version_h */ 161 | 162 | /* vi: set ts=4 sw=4 expandtab: */ 163 | -------------------------------------------------------------------------------- /engine/sdl2_keymap_extrakeys.h: -------------------------------------------------------------------------------- 1 | #ifndef SDL2_KEYMAP_EXTRAKEYS_H_ 2 | #define SDL2_KEYMAP_EXTRAKEYS_H_ 3 | 4 | struct sdl2_keymap{ 5 | int code; 6 | const char* key; 7 | sdl2_keymap(int code, const char* key): code(code), key(key) {} 8 | }; 9 | 10 | static const sdl2_keymap sdl2_keymap_extrakeys[] = { 11 | //x wheel, sdl2 only 12 | sdl2_keymap(-35, "WHEELXR"), 13 | sdl2_keymap(-36, "WHEELXL"), 14 | //extended keys and modifiers 15 | sdl2_keymap(0x40000059, "KP1"), 16 | sdl2_keymap(0x4000005a, "KP2"), 17 | sdl2_keymap(0x4000005b, "KP3"), 18 | sdl2_keymap(0x4000005c, "KP4"), 19 | sdl2_keymap(0x4000005d, "KP5"), 20 | sdl2_keymap(0x4000005e, "KP6"), 21 | sdl2_keymap(0x4000005f, "KP7"), 22 | sdl2_keymap(0x40000060, "KP8"), 23 | sdl2_keymap(0x40000061, "KP9"), 24 | sdl2_keymap(0x40000062, "KP0"), 25 | sdl2_keymap(0x40000063, "KP_PERIOD"), 26 | sdl2_keymap(0x40000054, "KP_DIVIDE"), 27 | sdl2_keymap(0x40000055, "KP_MULTIPLY"), 28 | sdl2_keymap(0x40000056, "KP_MINUS"), 29 | sdl2_keymap(0x40000057, "KP_PLUS"), 30 | sdl2_keymap(0x40000058, "KP_ENTER"), 31 | sdl2_keymap(0x40000067, "KP_EQUALS"), 32 | sdl2_keymap(0x40000052, "UP"), 33 | sdl2_keymap(0x40000051, "DOWN"), 34 | sdl2_keymap(0x4000004f, "RIGHT"), 35 | sdl2_keymap(0x40000050, "LEFT"), 36 | sdl2_keymap(0x40000048, "PAUSE"), 37 | sdl2_keymap(0x40000049, "INSERT"), 38 | sdl2_keymap(0x4000004a, "HOME"), 39 | sdl2_keymap(0x4000004d, "END"), 40 | sdl2_keymap(0x4000004b, "PAGEUP"), 41 | sdl2_keymap(0x4000004e, "PAGEDOWN"), 42 | sdl2_keymap(0x4000003a, "F1"), 43 | sdl2_keymap(0x4000003b, "F2"), 44 | sdl2_keymap(0x4000003c, "F3"), 45 | sdl2_keymap(0x4000003d, "F4"), 46 | sdl2_keymap(0x4000003e, "F5"), 47 | sdl2_keymap(0x4000003f, "F6"), 48 | sdl2_keymap(0x40000040, "F7"), 49 | sdl2_keymap(0x40000041, "F8"), 50 | sdl2_keymap(0x40000042, "F9"), 51 | sdl2_keymap(0x40000043, "F10"), 52 | sdl2_keymap(0x40000044, "F11"), 53 | sdl2_keymap(0x40000045, "F12"), 54 | sdl2_keymap(0x40000053, "NUMLOCK"), 55 | sdl2_keymap(0x40000039, "CAPSLOCK"), 56 | sdl2_keymap(0x40000047, "SCROLLOCK"), 57 | sdl2_keymap(0x400000e5, "RSHIFT"), 58 | sdl2_keymap(0x400000e1, "LSHIFT"), 59 | sdl2_keymap(0x400000e4, "RCTRL"), 60 | sdl2_keymap(0x400000e0, "LCTRL"), 61 | sdl2_keymap(0x400000e6, "RALT"), 62 | sdl2_keymap(0x400000e2, "LALT"), 63 | sdl2_keymap(0x400000e7, "RMETA"), 64 | sdl2_keymap(0x400000e3, "LMETA"), 65 | sdl2_keymap(0x40000065, "COMPOSE"), 66 | sdl2_keymap(0x40000075, "HELP"), 67 | sdl2_keymap(0x40000046, "PRINT"), 68 | sdl2_keymap(0x4000009a, "SYSREQ"), 69 | sdl2_keymap(0x40000076, "MENU"), 70 | // gamepad map 71 | sdl2_keymap(0xFF000001, "GP_LT"), 72 | sdl2_keymap(0xFF000002, "GP_RT"), 73 | sdl2_keymap(0xFF000003, "GP_LB"), 74 | sdl2_keymap(0xFF000004, "GP_RB"), 75 | sdl2_keymap(0xFF000005, "GP_A"), 76 | sdl2_keymap(0xFF000006, "GP_B"), 77 | sdl2_keymap(0xFF000007, "GP_X"), 78 | sdl2_keymap(0xFF000008, "GP_Y"), 79 | sdl2_keymap(0xFF000009, "GP_START"), 80 | sdl2_keymap(0xFF00000a, "GP_BACK"), 81 | sdl2_keymap(0xFF00000b, "GP_GUIDE"), 82 | sdl2_keymap(0xFF00000c, "GP_LS"), 83 | sdl2_keymap(0xFF00000d, "GP_RS"), 84 | sdl2_keymap(0xFF00000e, "GP_UP"), 85 | sdl2_keymap(0xFF00000f, "GP_RIGHT"), 86 | sdl2_keymap(0xFF000010, "GP_DOWN"), 87 | sdl2_keymap(0xFF000011, "GP_LEFT"), 88 | sdl2_keymap(0xFF000012, "GP_DUP"), 89 | sdl2_keymap(0xFF000013, "GP_DRIGHT"), 90 | sdl2_keymap(0xFF000014, "GP_DDOWN"), 91 | sdl2_keymap(0xFF000015, "GP_DLEFT") 92 | }; 93 | 94 | // gamepad related data 95 | static struct ShortNames { 96 | hashtable names; 97 | hashtable codes; 98 | ShortNames() { 99 | names["lefttrigger"] = "GP_LT"; 100 | names["righttrigger"] = "GP_RT"; 101 | names["leftshoulder"] = "GP_LB"; 102 | names["rightshoulder"] = "GP_RB"; 103 | names["a"] = "GP_A"; 104 | names["b"] = "GP_B"; 105 | names["x"] = "GP_X"; 106 | names["y"] = "GP_Y"; 107 | names["start"] = "GP_START"; 108 | names["back"] = "GP_BACK"; 109 | names["guide"] = "GP_GUIDE"; 110 | names["leftstick"] = "GP_LS"; 111 | names["rightstick"] = "GP_RS"; 112 | names["spup"] = "GP_UP"; 113 | names["spright"] = "GP_RIGHT"; 114 | names["spdown"] = "GP_DOWN"; 115 | names["spleft"] = "GP_LEFT"; 116 | names["dpup"] = "GP_DUP"; 117 | names["dpright"] = "GP_DRIGHT"; 118 | names["dpdown"] = "GP_DDOWN"; 119 | names["dpleft"] = "GP_DLEFT"; 120 | codes["lefttrigger"] = 0xFF000001; 121 | codes["righttrigger"] = 0xFF000002; 122 | codes["leftshoulder"] = 0xFF000003; 123 | codes["rightshoulder"] = 0xFF000004; 124 | codes["a"] = 0xFF000005; 125 | codes["b"] = 0xFF000006; 126 | codes["x"] = 0xFF000007; 127 | codes["y"] = 0xFF000008; 128 | codes["start"] = 0xFF000009; 129 | codes["back"] = 0xFF00000a; 130 | codes["guide"] = 0xFF00000b; 131 | codes["leftstick"] = 0xFF00000c; 132 | codes["rightstick"] = 0xFF00000d; 133 | codes["spup"] = 0xFF00000e; 134 | codes["spright"] = 0xFF00000f; 135 | codes["spdown"] = 0xFF000010; 136 | codes["spleft"] = 0xFF000011; 137 | codes["dpup"] = 0xFF000012; 138 | codes["dpright"] = 0xFF000013; 139 | codes["dpdown"] = 0xFF000014; 140 | codes["dpleft"] = 0xFF000015; 141 | } 142 | char* getshortname(const char* name) { 143 | return (char*)names.find(name,NULL); 144 | } 145 | int getcode(const char* name) { 146 | return codes.find(name, 0); 147 | } 148 | } padbuttons; 149 | 150 | 151 | #endif /* SDL2_KEYMAP_EXTRAKEYS_H_ */ 152 | -------------------------------------------------------------------------------- /shared/igame.h: -------------------------------------------------------------------------------- 1 | // the interface the engine uses to run the gameplay module 2 | 3 | namespace entities 4 | { 5 | extern void editent(int i, bool local); 6 | extern const char *entnameinfo(entity &e); 7 | extern const char *entname(int i); 8 | extern int extraentinfosize(); 9 | extern void writeent(entity &e, char *buf); 10 | extern void readent(entity &e, char *buf, int ver); 11 | extern float dropheight(entity &e); 12 | extern void fixentity(extentity &e); 13 | extern void entradius(extentity &e, bool color); 14 | extern bool mayattach(extentity &e); 15 | extern bool attachent(extentity &e, extentity &a); 16 | extern bool printent(extentity &e, char *buf); 17 | extern extentity *newentity(); 18 | extern void deleteentity(extentity *e); 19 | extern void clearents(); 20 | extern vector &getents(); 21 | extern const char *entmodel(const entity &e); 22 | extern void animatemapmodel(const extentity &e, int &anim, int &basetime); 23 | } 24 | 25 | namespace game 26 | { 27 | extern void parseoptions(vector &args); 28 | 29 | extern void gamedisconnect(bool cleanup); 30 | extern void parsepacketclient(int chan, packetbuf &p); 31 | extern void connectattempt(const char *name, const char *password, const ENetAddress &address); 32 | extern void connectfail(); 33 | extern void gameconnect(bool _remote); 34 | extern bool allowedittoggle(); 35 | extern void edittoggled(bool on); 36 | extern void writeclientinfo(stream *f); 37 | extern void toserver(char *text); 38 | extern void changemap(const char *name); 39 | extern void forceedit(const char *name); 40 | extern bool ispaused(); 41 | extern int scaletime(int t); 42 | extern bool allowmouselook(); 43 | 44 | extern const char *gameident(); 45 | extern const char *savedconfig(); 46 | extern const char *restoreconfig(); 47 | extern const char *defaultconfig(); 48 | extern const char *autoexec(); 49 | extern const char *savedservers(); 50 | extern const char *ignoredservers(); 51 | extern void loadconfigs(); 52 | 53 | extern void updateworld(); 54 | extern void checkgameinfo(); 55 | extern void initclient(); 56 | extern const char **getgamescripts(); 57 | extern void physicstrigger(physent *d, bool local, int floorlevel, int waterlevel, int material = 0); 58 | extern void bounced(physent *d, const vec &surface); 59 | extern void edittrigger(const selinfo &sel, int op, int arg1 = 0, int arg2 = 0, int arg3 = 0); 60 | extern void vartrigger(ident *id); 61 | extern void dynentcollide(physent *d, physent *o, const vec &dir); 62 | extern const char *getclientmap(); 63 | extern const char *getmapinfo(); 64 | extern void resetgamestate(); 65 | extern void suicide(physent *d); 66 | extern void newmap(int size); 67 | extern void startmap(const char *name); 68 | extern void preload(); 69 | extern float abovegameplayhud(int w, int h); 70 | extern void gameplayhud(int w, int h); 71 | extern bool canjump(); 72 | extern bool allowmove(physent *d); 73 | extern void doattack(bool on); 74 | extern dynent *iterdynents(int i); 75 | extern int numdynents(); 76 | extern void rendergame(bool mainpass); 77 | extern void renderavatar(); 78 | extern void renderplayerpreview(int model, int team, int weap); 79 | extern void writegamedata(vector &extras); 80 | extern void readgamedata(vector &extras); 81 | extern int clipconsole(int w, int h); 82 | extern void g3d_gamemenus(); 83 | extern const char *defaultcrosshair(int index); 84 | extern int selectcrosshair(float &r, float &g, float &b); 85 | extern void lighteffects(dynent *d, vec &color, vec &dir); 86 | extern void setupcamera(); 87 | extern bool detachcamera(); 88 | extern bool collidecamera(); 89 | extern void adddynlights(); 90 | extern void particletrack(physent *owner, vec &o, vec &d); 91 | extern void dynlighttrack(physent *owner, vec &o, vec &hud); 92 | extern bool serverinfostartcolumn(g3d_gui *g, int i); 93 | extern void serverinfoendcolumn(g3d_gui *g, int i); 94 | extern bool serverinfoentry(g3d_gui *g, int i, const char *name, int port, const char *desc, const char *map, int ping, const vector &attr, int np); 95 | extern void setserverpreview(int servername, int serverport); 96 | extern const char* showserverpreview(g3d_gui *g); 97 | extern bool needminimap(); 98 | extern void requestgameinfo(ENetAddress address); 99 | extern const char* showplayersgui(g3d_gui *cgui, const char *name); 100 | extern void showdemoslist(g3d_gui *cgui); 101 | } 102 | 103 | namespace server 104 | { 105 | extern void *newclientinfo(); 106 | extern void deleteclientinfo(void *ci); 107 | extern void serverinit(); 108 | extern int reserveclients(); 109 | extern int numchannels(); 110 | extern void clientdisconnect(int n); 111 | extern int clientconnect(int n, uint ip); 112 | extern void localdisconnect(int n); 113 | extern void localconnect(int n); 114 | extern bool allowbroadcast(int n); 115 | extern void recordpacket(int chan, void *data, int len); 116 | extern void parsepacket(int sender, int chan, packetbuf &p); 117 | extern void sendservmsg(const char *s); 118 | extern bool sendpackets(bool force = false); 119 | extern void serverinforeply(ucharbuf &req, ucharbuf &p); 120 | extern void serverupdate(); 121 | extern bool servercompatible(char *name, char *sdec, char *map, int ping, const vector &attr, int np); 122 | extern int laninfoport(); 123 | extern int serverinfoport(int servport = -1); 124 | extern int serverport(int infoport = -1); 125 | extern const char *defaultmaster(); 126 | extern int masterport(); 127 | extern void processmasterinput(const char *cmd, int cmdlen, const char *args); 128 | extern void masterconnected(); 129 | extern void masterdisconnected(); 130 | extern bool ispaused(); 131 | extern int scaletime(int t); 132 | } 133 | -------------------------------------------------------------------------------- /include/SDL_config_macosx.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2014 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | #ifndef _SDL_config_macosx_h 23 | #define _SDL_config_macosx_h 24 | 25 | #include "SDL_platform.h" 26 | 27 | /* This gets us MAC_OS_X_VERSION_MIN_REQUIRED... */ 28 | #include 29 | 30 | /* This is a set of defines to configure the SDL features */ 31 | 32 | #ifdef __LP64__ 33 | #define SIZEOF_VOIDP 8 34 | #else 35 | #define SIZEOF_VOIDP 4 36 | #endif 37 | 38 | /* Useful headers */ 39 | #define HAVE_ALLOCA_H 1 40 | #define HAVE_SYS_TYPES_H 1 41 | #define HAVE_STDIO_H 1 42 | #define STDC_HEADERS 1 43 | #define HAVE_STRING_H 1 44 | #define HAVE_INTTYPES_H 1 45 | #define HAVE_STDINT_H 1 46 | #define HAVE_CTYPE_H 1 47 | #define HAVE_MATH_H 1 48 | #define HAVE_SIGNAL_H 1 49 | 50 | /* C library functions */ 51 | #define HAVE_MALLOC 1 52 | #define HAVE_CALLOC 1 53 | #define HAVE_REALLOC 1 54 | #define HAVE_FREE 1 55 | #define HAVE_ALLOCA 1 56 | #define HAVE_GETENV 1 57 | #define HAVE_SETENV 1 58 | #define HAVE_PUTENV 1 59 | #define HAVE_UNSETENV 1 60 | #define HAVE_QSORT 1 61 | #define HAVE_ABS 1 62 | #define HAVE_BCOPY 1 63 | #define HAVE_MEMSET 1 64 | #define HAVE_MEMCPY 1 65 | #define HAVE_MEMMOVE 1 66 | #define HAVE_MEMCMP 1 67 | #define HAVE_STRLEN 1 68 | #define HAVE_STRLCPY 1 69 | #define HAVE_STRLCAT 1 70 | #define HAVE_STRDUP 1 71 | #define HAVE_STRCHR 1 72 | #define HAVE_STRRCHR 1 73 | #define HAVE_STRSTR 1 74 | #define HAVE_STRTOL 1 75 | #define HAVE_STRTOUL 1 76 | #define HAVE_STRTOLL 1 77 | #define HAVE_STRTOULL 1 78 | #define HAVE_STRTOD 1 79 | #define HAVE_ATOI 1 80 | #define HAVE_ATOF 1 81 | #define HAVE_STRCMP 1 82 | #define HAVE_STRNCMP 1 83 | #define HAVE_STRCASECMP 1 84 | #define HAVE_STRNCASECMP 1 85 | #define HAVE_VSSCANF 1 86 | #define HAVE_VSNPRINTF 1 87 | #define HAVE_CEIL 1 88 | #define HAVE_COPYSIGN 1 89 | #define HAVE_COS 1 90 | #define HAVE_COSF 1 91 | #define HAVE_FABS 1 92 | #define HAVE_FLOOR 1 93 | #define HAVE_LOG 1 94 | #define HAVE_POW 1 95 | #define HAVE_SCALBN 1 96 | #define HAVE_SIN 1 97 | #define HAVE_SINF 1 98 | #define HAVE_SQRT 1 99 | #define HAVE_SIGACTION 1 100 | #define HAVE_SETJMP 1 101 | #define HAVE_NANOSLEEP 1 102 | #define HAVE_SYSCONF 1 103 | #define HAVE_SYSCTLBYNAME 1 104 | #define HAVE_ATAN 1 105 | #define HAVE_ATAN2 1 106 | #define HAVE_ACOS 1 107 | #define HAVE_ASIN 1 108 | 109 | /* Enable various audio drivers */ 110 | #define SDL_AUDIO_DRIVER_COREAUDIO 1 111 | #define SDL_AUDIO_DRIVER_DISK 1 112 | #define SDL_AUDIO_DRIVER_DUMMY 1 113 | 114 | /* Enable various input drivers */ 115 | #define SDL_JOYSTICK_IOKIT 1 116 | #define SDL_HAPTIC_IOKIT 1 117 | 118 | /* Enable various shared object loading systems */ 119 | #define SDL_LOADSO_DLOPEN 1 120 | 121 | /* Enable various threading systems */ 122 | #define SDL_THREAD_PTHREAD 1 123 | #define SDL_THREAD_PTHREAD_RECURSIVE_MUTEX 1 124 | 125 | /* Enable various timer systems */ 126 | #define SDL_TIMER_UNIX 1 127 | 128 | /* Enable various video drivers */ 129 | #define SDL_VIDEO_DRIVER_COCOA 1 130 | #define SDL_VIDEO_DRIVER_DUMMY 1 131 | #undef SDL_VIDEO_DRIVER_X11 132 | #define SDL_VIDEO_DRIVER_X11_DYNAMIC "/usr/X11R6/lib/libX11.6.dylib" 133 | #define SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT "/usr/X11R6/lib/libXext.6.dylib" 134 | #define SDL_VIDEO_DRIVER_X11_DYNAMIC_XINERAMA "/usr/X11R6/lib/libXinerama.1.dylib" 135 | #define SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT2 "/usr/X11R6/lib/libXi.6.dylib" 136 | #define SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR "/usr/X11R6/lib/libXrandr.2.dylib" 137 | #define SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS "/usr/X11R6/lib/libXss.1.dylib" 138 | #define SDL_VIDEO_DRIVER_X11_DYNAMIC_XVIDMODE "/usr/X11R6/lib/libXxf86vm.1.dylib" 139 | #define SDL_VIDEO_DRIVER_X11_XINERAMA 1 140 | #define SDL_VIDEO_DRIVER_X11_XRANDR 1 141 | #define SDL_VIDEO_DRIVER_X11_XSCRNSAVER 1 142 | #define SDL_VIDEO_DRIVER_X11_XSHAPE 1 143 | #define SDL_VIDEO_DRIVER_X11_XVIDMODE 1 144 | #define SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM 1 145 | 146 | #ifdef MAC_OS_X_VERSION_10_8 147 | /* 148 | * No matter the versions targeted, this is the 10.8 or later SDK, so you have 149 | * to use the external Xquartz, which is a more modern Xlib. Previous SDKs 150 | * used an older Xlib. 151 | */ 152 | #define SDL_VIDEO_DRIVER_X11_XINPUT2 1 153 | #define SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS 1 154 | #define SDL_VIDEO_DRIVER_X11_CONST_PARAM_XEXTADDDISPLAY 1 155 | #endif 156 | 157 | #ifndef SDL_VIDEO_RENDER_OGL 158 | #define SDL_VIDEO_RENDER_OGL 1 159 | #endif 160 | 161 | /* Enable OpenGL support */ 162 | #ifndef SDL_VIDEO_OPENGL 163 | #define SDL_VIDEO_OPENGL 1 164 | #endif 165 | #ifndef SDL_VIDEO_OPENGL_CGL 166 | #define SDL_VIDEO_OPENGL_CGL 1 167 | #endif 168 | #ifndef SDL_VIDEO_OPENGL_GLX 169 | #define SDL_VIDEO_OPENGL_GLX 1 170 | #endif 171 | 172 | /* Enable system power support */ 173 | #define SDL_POWER_MACOSX 1 174 | 175 | /* enable filesystem support */ 176 | #define SDL_FILESYSTEM_COCOA 1 177 | 178 | /* Enable assembly routines */ 179 | #define SDL_ASSEMBLY_ROUTINES 1 180 | #ifdef __ppc__ 181 | #define SDL_ALTIVEC_BLITTERS 1 182 | #endif 183 | 184 | #endif /* _SDL_config_macosx_h */ 185 | -------------------------------------------------------------------------------- /include/SDL_shape.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | #ifndef _SDL_shape_h 23 | #define _SDL_shape_h 24 | 25 | #include "SDL_stdinc.h" 26 | #include "SDL_pixels.h" 27 | #include "SDL_rect.h" 28 | #include "SDL_surface.h" 29 | #include "SDL_video.h" 30 | 31 | #include "begin_code.h" 32 | /* Set up for C function definitions, even when using C++ */ 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | /** \file SDL_shape.h 38 | * 39 | * Header file for the shaped window API. 40 | */ 41 | 42 | #define SDL_NONSHAPEABLE_WINDOW -1 43 | #define SDL_INVALID_SHAPE_ARGUMENT -2 44 | #define SDL_WINDOW_LACKS_SHAPE -3 45 | 46 | /** 47 | * \brief Create a window that can be shaped with the specified position, dimensions, and flags. 48 | * 49 | * \param title The title of the window, in UTF-8 encoding. 50 | * \param x The x position of the window, ::SDL_WINDOWPOS_CENTERED, or 51 | * ::SDL_WINDOWPOS_UNDEFINED. 52 | * \param y The y position of the window, ::SDL_WINDOWPOS_CENTERED, or 53 | * ::SDL_WINDOWPOS_UNDEFINED. 54 | * \param w The width of the window. 55 | * \param h The height of the window. 56 | * \param flags The flags for the window, a mask of SDL_WINDOW_BORDERLESS with any of the following: 57 | * ::SDL_WINDOW_OPENGL, ::SDL_WINDOW_INPUT_GRABBED, 58 | * ::SDL_WINDOW_HIDDEN, ::SDL_WINDOW_RESIZABLE, 59 | * ::SDL_WINDOW_MAXIMIZED, ::SDL_WINDOW_MINIMIZED, 60 | * ::SDL_WINDOW_BORDERLESS is always set, and ::SDL_WINDOW_FULLSCREEN is always unset. 61 | * 62 | * \return The window created, or NULL if window creation failed. 63 | * 64 | * \sa SDL_DestroyWindow() 65 | */ 66 | extern DECLSPEC SDL_Window * SDLCALL SDL_CreateShapedWindow(const char *title,unsigned int x,unsigned int y,unsigned int w,unsigned int h,Uint32 flags); 67 | 68 | /** 69 | * \brief Return whether the given window is a shaped window. 70 | * 71 | * \param window The window to query for being shaped. 72 | * 73 | * \return SDL_TRUE if the window is a window that can be shaped, SDL_FALSE if the window is unshaped or NULL. 74 | * \sa SDL_CreateShapedWindow 75 | */ 76 | extern DECLSPEC SDL_bool SDLCALL SDL_IsShapedWindow(const SDL_Window *window); 77 | 78 | /** \brief An enum denoting the specific type of contents present in an SDL_WindowShapeParams union. */ 79 | typedef enum { 80 | /** \brief The default mode, a binarized alpha cutoff of 1. */ 81 | ShapeModeDefault, 82 | /** \brief A binarized alpha cutoff with a given integer value. */ 83 | ShapeModeBinarizeAlpha, 84 | /** \brief A binarized alpha cutoff with a given integer value, but with the opposite comparison. */ 85 | ShapeModeReverseBinarizeAlpha, 86 | /** \brief A color key is applied. */ 87 | ShapeModeColorKey 88 | } WindowShapeMode; 89 | 90 | #define SDL_SHAPEMODEALPHA(mode) (mode == ShapeModeDefault || mode == ShapeModeBinarizeAlpha || mode == ShapeModeReverseBinarizeAlpha) 91 | 92 | /** \brief A union containing parameters for shaped windows. */ 93 | typedef union { 94 | /** \brief a cutoff alpha value for binarization of the window shape's alpha channel. */ 95 | Uint8 binarizationCutoff; 96 | SDL_Color colorKey; 97 | } SDL_WindowShapeParams; 98 | 99 | /** \brief A struct that tags the SDL_WindowShapeParams union with an enum describing the type of its contents. */ 100 | typedef struct SDL_WindowShapeMode { 101 | /** \brief The mode of these window-shape parameters. */ 102 | WindowShapeMode mode; 103 | /** \brief Window-shape parameters. */ 104 | SDL_WindowShapeParams parameters; 105 | } SDL_WindowShapeMode; 106 | 107 | /** 108 | * \brief Set the shape and parameters of a shaped window. 109 | * 110 | * \param window The shaped window whose parameters should be set. 111 | * \param shape A surface encoding the desired shape for the window. 112 | * \param shape_mode The parameters to set for the shaped window. 113 | * 114 | * \return 0 on success, SDL_INVALID_SHAPE_ARGUMENT on invalid an invalid shape argument, or SDL_NONSHAPEABLE_WINDOW 115 | * if the SDL_Window* given does not reference a valid shaped window. 116 | * 117 | * \sa SDL_WindowShapeMode 118 | * \sa SDL_GetShapedWindowMode. 119 | */ 120 | extern DECLSPEC int SDLCALL SDL_SetWindowShape(SDL_Window *window,SDL_Surface *shape,SDL_WindowShapeMode *shape_mode); 121 | 122 | /** 123 | * \brief Get the shape parameters of a shaped window. 124 | * 125 | * \param window The shaped window whose parameters should be retrieved. 126 | * \param shape_mode An empty shape-mode structure to fill, or NULL to check whether the window has a shape. 127 | * 128 | * \return 0 if the window has a shape and, provided shape_mode was not NULL, shape_mode has been filled with the mode 129 | * data, SDL_NONSHAPEABLE_WINDOW if the SDL_Window given is not a shaped window, or SDL_WINDOW_LACKS_SHAPE if 130 | * the SDL_Window* given is a shapeable window currently lacking a shape. 131 | * 132 | * \sa SDL_WindowShapeMode 133 | * \sa SDL_SetWindowShape 134 | */ 135 | extern DECLSPEC int SDLCALL SDL_GetShapedWindowMode(SDL_Window *window,SDL_WindowShapeMode *shape_mode); 136 | 137 | /* Ends C function definitions when using C++ */ 138 | #ifdef __cplusplus 139 | } 140 | #endif 141 | #include "close_code.h" 142 | 143 | #endif /* _SDL_shape_h */ 144 | -------------------------------------------------------------------------------- /include/SDL_config_windows.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2014 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | #ifndef _SDL_config_windows_h 23 | #define _SDL_config_windows_h 24 | 25 | #include "SDL_platform.h" 26 | 27 | /* This is a set of defines to configure the SDL features */ 28 | 29 | #if !defined(_STDINT_H_) && (!defined(HAVE_STDINT_H) || !_HAVE_STDINT_H) 30 | #if defined(__GNUC__) || defined(__DMC__) || defined(__WATCOMC__) 31 | #define HAVE_STDINT_H 1 32 | #elif defined(_MSC_VER) 33 | typedef signed __int8 int8_t; 34 | typedef unsigned __int8 uint8_t; 35 | typedef signed __int16 int16_t; 36 | typedef unsigned __int16 uint16_t; 37 | typedef signed __int32 int32_t; 38 | typedef unsigned __int32 uint32_t; 39 | typedef signed __int64 int64_t; 40 | typedef unsigned __int64 uint64_t; 41 | #ifndef _UINTPTR_T_DEFINED 42 | #ifdef _WIN64 43 | typedef unsigned __int64 uintptr_t; 44 | #else 45 | typedef unsigned int uintptr_t; 46 | #endif 47 | #define _UINTPTR_T_DEFINED 48 | #endif 49 | /* Older Visual C++ headers don't have the Win64-compatible typedefs... */ 50 | #if ((_MSC_VER <= 1200) && (!defined(DWORD_PTR))) 51 | #define DWORD_PTR DWORD 52 | #endif 53 | #if ((_MSC_VER <= 1200) && (!defined(LONG_PTR))) 54 | #define LONG_PTR LONG 55 | #endif 56 | #else /* !__GNUC__ && !_MSC_VER */ 57 | typedef signed char int8_t; 58 | typedef unsigned char uint8_t; 59 | typedef signed short int16_t; 60 | typedef unsigned short uint16_t; 61 | typedef signed int int32_t; 62 | typedef unsigned int uint32_t; 63 | typedef signed long long int64_t; 64 | typedef unsigned long long uint64_t; 65 | #ifndef _SIZE_T_DEFINED_ 66 | #define _SIZE_T_DEFINED_ 67 | typedef unsigned int size_t; 68 | #endif 69 | typedef unsigned int uintptr_t; 70 | #endif /* __GNUC__ || _MSC_VER */ 71 | #endif /* !_STDINT_H_ && !HAVE_STDINT_H */ 72 | 73 | #ifdef _WIN64 74 | # define SIZEOF_VOIDP 8 75 | #else 76 | # define SIZEOF_VOIDP 4 77 | #endif 78 | 79 | /* This is disabled by default to avoid C runtime dependencies and manifest requirements */ 80 | #ifdef HAVE_LIBC 81 | /* Useful headers */ 82 | #define HAVE_STDIO_H 1 83 | #define STDC_HEADERS 1 84 | #define HAVE_STRING_H 1 85 | #define HAVE_CTYPE_H 1 86 | #define HAVE_MATH_H 1 87 | #define HAVE_SIGNAL_H 1 88 | 89 | /* C library functions */ 90 | #define HAVE_MALLOC 1 91 | #define HAVE_CALLOC 1 92 | #define HAVE_REALLOC 1 93 | #define HAVE_FREE 1 94 | #define HAVE_ALLOCA 1 95 | #define HAVE_QSORT 1 96 | #define HAVE_ABS 1 97 | #define HAVE_MEMSET 1 98 | #define HAVE_MEMCPY 1 99 | #define HAVE_MEMMOVE 1 100 | #define HAVE_MEMCMP 1 101 | #define HAVE_STRLEN 1 102 | #define HAVE__STRREV 1 103 | #define HAVE__STRUPR 1 104 | #define HAVE__STRLWR 1 105 | #define HAVE_STRCHR 1 106 | #define HAVE_STRRCHR 1 107 | #define HAVE_STRSTR 1 108 | #define HAVE__LTOA 1 109 | #define HAVE__ULTOA 1 110 | #define HAVE_STRTOL 1 111 | #define HAVE_STRTOUL 1 112 | #define HAVE_STRTOD 1 113 | #define HAVE_ATOI 1 114 | #define HAVE_ATOF 1 115 | #define HAVE_STRCMP 1 116 | #define HAVE_STRNCMP 1 117 | #define HAVE__STRICMP 1 118 | #define HAVE__STRNICMP 1 119 | #define HAVE_ATAN 1 120 | #define HAVE_ATAN2 1 121 | #define HAVE_ACOS 1 122 | #define HAVE_ASIN 1 123 | #define HAVE_CEIL 1 124 | #define HAVE_COS 1 125 | #define HAVE_COSF 1 126 | #define HAVE_FABS 1 127 | #define HAVE_FLOOR 1 128 | #define HAVE_LOG 1 129 | #define HAVE_POW 1 130 | #define HAVE_SIN 1 131 | #define HAVE_SINF 1 132 | #define HAVE_SQRT 1 133 | #if _MSC_VER >= 1800 134 | #define HAVE_STRTOLL 1 135 | #define HAVE_VSSCANF 1 136 | #define HAVE_COPYSIGN 1 137 | #define HAVE_SCALBN 1 138 | #endif 139 | #if !defined(_MSC_VER) || defined(_USE_MATH_DEFINES) 140 | #define HAVE_M_PI 1 141 | #endif 142 | #else 143 | #define HAVE_STDARG_H 1 144 | #define HAVE_STDDEF_H 1 145 | #endif 146 | 147 | /* Enable various audio drivers */ 148 | #define SDL_AUDIO_DRIVER_DSOUND 1 149 | #define SDL_AUDIO_DRIVER_XAUDIO2 1 150 | #define SDL_AUDIO_DRIVER_WINMM 1 151 | #define SDL_AUDIO_DRIVER_DISK 1 152 | #define SDL_AUDIO_DRIVER_DUMMY 1 153 | 154 | /* Enable various input drivers */ 155 | #define SDL_JOYSTICK_DINPUT 1 156 | #define SDL_HAPTIC_DINPUT 1 157 | 158 | /* Enable various shared object loading systems */ 159 | #define SDL_LOADSO_WINDOWS 1 160 | 161 | /* Enable various threading systems */ 162 | #define SDL_THREAD_WINDOWS 1 163 | 164 | /* Enable various timer systems */ 165 | #define SDL_TIMER_WINDOWS 1 166 | 167 | /* Enable various video drivers */ 168 | #define SDL_VIDEO_DRIVER_DUMMY 1 169 | #define SDL_VIDEO_DRIVER_WINDOWS 1 170 | 171 | #ifndef SDL_VIDEO_RENDER_D3D 172 | #define SDL_VIDEO_RENDER_D3D 1 173 | #endif 174 | #ifndef SDL_VIDEO_RENDER_D3D11 175 | #define SDL_VIDEO_RENDER_D3D11 0 176 | #endif 177 | 178 | /* Enable OpenGL support */ 179 | #ifndef SDL_VIDEO_OPENGL 180 | #define SDL_VIDEO_OPENGL 1 181 | #endif 182 | #ifndef SDL_VIDEO_OPENGL_WGL 183 | #define SDL_VIDEO_OPENGL_WGL 1 184 | #endif 185 | #ifndef SDL_VIDEO_RENDER_OGL 186 | #define SDL_VIDEO_RENDER_OGL 1 187 | #endif 188 | #ifndef SDL_VIDEO_RENDER_OGL_ES2 189 | #define SDL_VIDEO_RENDER_OGL_ES2 1 190 | #endif 191 | #ifndef SDL_VIDEO_OPENGL_ES2 192 | #define SDL_VIDEO_OPENGL_ES2 1 193 | #endif 194 | #ifndef SDL_VIDEO_OPENGL_EGL 195 | #define SDL_VIDEO_OPENGL_EGL 1 196 | #endif 197 | 198 | 199 | /* Enable system power support */ 200 | #define SDL_POWER_WINDOWS 1 201 | 202 | /* Enable filesystem support */ 203 | #define SDL_FILESYSTEM_WINDOWS 1 204 | 205 | /* Enable assembly routines (Win64 doesn't have inline asm) */ 206 | #ifndef _WIN64 207 | #define SDL_ASSEMBLY_ROUTINES 1 208 | #endif 209 | 210 | #endif /* _SDL_config_windows_h */ 211 | -------------------------------------------------------------------------------- /enet/include/enet/protocol.h: -------------------------------------------------------------------------------- 1 | /** 2 | @file protocol.h 3 | @brief ENet protocol 4 | */ 5 | #ifndef __ENET_PROTOCOL_H__ 6 | #define __ENET_PROTOCOL_H__ 7 | 8 | #include "enet/types.h" 9 | 10 | enum 11 | { 12 | ENET_PROTOCOL_MINIMUM_MTU = 576, 13 | ENET_PROTOCOL_MAXIMUM_MTU = 4096, 14 | ENET_PROTOCOL_MAXIMUM_PACKET_COMMANDS = 32, 15 | ENET_PROTOCOL_MINIMUM_WINDOW_SIZE = 4096, 16 | ENET_PROTOCOL_MAXIMUM_WINDOW_SIZE = 65536, 17 | ENET_PROTOCOL_MINIMUM_CHANNEL_COUNT = 1, 18 | ENET_PROTOCOL_MAXIMUM_CHANNEL_COUNT = 255, 19 | ENET_PROTOCOL_MAXIMUM_PEER_ID = 0xFFF, 20 | ENET_PROTOCOL_MAXIMUM_FRAGMENT_COUNT = 1024 * 1024 21 | }; 22 | 23 | typedef enum _ENetProtocolCommand 24 | { 25 | ENET_PROTOCOL_COMMAND_NONE = 0, 26 | ENET_PROTOCOL_COMMAND_ACKNOWLEDGE = 1, 27 | ENET_PROTOCOL_COMMAND_CONNECT = 2, 28 | ENET_PROTOCOL_COMMAND_VERIFY_CONNECT = 3, 29 | ENET_PROTOCOL_COMMAND_DISCONNECT = 4, 30 | ENET_PROTOCOL_COMMAND_PING = 5, 31 | ENET_PROTOCOL_COMMAND_SEND_RELIABLE = 6, 32 | ENET_PROTOCOL_COMMAND_SEND_UNRELIABLE = 7, 33 | ENET_PROTOCOL_COMMAND_SEND_FRAGMENT = 8, 34 | ENET_PROTOCOL_COMMAND_SEND_UNSEQUENCED = 9, 35 | ENET_PROTOCOL_COMMAND_BANDWIDTH_LIMIT = 10, 36 | ENET_PROTOCOL_COMMAND_THROTTLE_CONFIGURE = 11, 37 | ENET_PROTOCOL_COMMAND_SEND_UNRELIABLE_FRAGMENT = 12, 38 | ENET_PROTOCOL_COMMAND_COUNT = 13, 39 | 40 | ENET_PROTOCOL_COMMAND_MASK = 0x0F 41 | } ENetProtocolCommand; 42 | 43 | typedef enum _ENetProtocolFlag 44 | { 45 | ENET_PROTOCOL_COMMAND_FLAG_ACKNOWLEDGE = (1 << 7), 46 | ENET_PROTOCOL_COMMAND_FLAG_UNSEQUENCED = (1 << 6), 47 | 48 | ENET_PROTOCOL_HEADER_FLAG_COMPRESSED = (1 << 14), 49 | ENET_PROTOCOL_HEADER_FLAG_SENT_TIME = (1 << 15), 50 | ENET_PROTOCOL_HEADER_FLAG_MASK = ENET_PROTOCOL_HEADER_FLAG_COMPRESSED | ENET_PROTOCOL_HEADER_FLAG_SENT_TIME, 51 | 52 | ENET_PROTOCOL_HEADER_SESSION_MASK = (3 << 12), 53 | ENET_PROTOCOL_HEADER_SESSION_SHIFT = 12 54 | } ENetProtocolFlag; 55 | 56 | #ifdef _MSC_VER 57 | #pragma pack(push, 1) 58 | #define ENET_PACKED 59 | #elif defined(__GNUC__) || defined(__clang__) 60 | #define ENET_PACKED __attribute__ ((packed)) 61 | #else 62 | #define ENET_PACKED 63 | #endif 64 | 65 | typedef struct _ENetProtocolHeader 66 | { 67 | enet_uint16 peerID; 68 | enet_uint16 sentTime; 69 | } ENET_PACKED ENetProtocolHeader; 70 | 71 | typedef struct _ENetProtocolCommandHeader 72 | { 73 | enet_uint8 command; 74 | enet_uint8 channelID; 75 | enet_uint16 reliableSequenceNumber; 76 | } ENET_PACKED ENetProtocolCommandHeader; 77 | 78 | typedef struct _ENetProtocolAcknowledge 79 | { 80 | ENetProtocolCommandHeader header; 81 | enet_uint16 receivedReliableSequenceNumber; 82 | enet_uint16 receivedSentTime; 83 | } ENET_PACKED ENetProtocolAcknowledge; 84 | 85 | typedef struct _ENetProtocolConnect 86 | { 87 | ENetProtocolCommandHeader header; 88 | enet_uint16 outgoingPeerID; 89 | enet_uint8 incomingSessionID; 90 | enet_uint8 outgoingSessionID; 91 | enet_uint32 mtu; 92 | enet_uint32 windowSize; 93 | enet_uint32 channelCount; 94 | enet_uint32 incomingBandwidth; 95 | enet_uint32 outgoingBandwidth; 96 | enet_uint32 packetThrottleInterval; 97 | enet_uint32 packetThrottleAcceleration; 98 | enet_uint32 packetThrottleDeceleration; 99 | enet_uint32 connectID; 100 | enet_uint32 data; 101 | } ENET_PACKED ENetProtocolConnect; 102 | 103 | typedef struct _ENetProtocolVerifyConnect 104 | { 105 | ENetProtocolCommandHeader header; 106 | enet_uint16 outgoingPeerID; 107 | enet_uint8 incomingSessionID; 108 | enet_uint8 outgoingSessionID; 109 | enet_uint32 mtu; 110 | enet_uint32 windowSize; 111 | enet_uint32 channelCount; 112 | enet_uint32 incomingBandwidth; 113 | enet_uint32 outgoingBandwidth; 114 | enet_uint32 packetThrottleInterval; 115 | enet_uint32 packetThrottleAcceleration; 116 | enet_uint32 packetThrottleDeceleration; 117 | enet_uint32 connectID; 118 | } ENET_PACKED ENetProtocolVerifyConnect; 119 | 120 | typedef struct _ENetProtocolBandwidthLimit 121 | { 122 | ENetProtocolCommandHeader header; 123 | enet_uint32 incomingBandwidth; 124 | enet_uint32 outgoingBandwidth; 125 | } ENET_PACKED ENetProtocolBandwidthLimit; 126 | 127 | typedef struct _ENetProtocolThrottleConfigure 128 | { 129 | ENetProtocolCommandHeader header; 130 | enet_uint32 packetThrottleInterval; 131 | enet_uint32 packetThrottleAcceleration; 132 | enet_uint32 packetThrottleDeceleration; 133 | } ENET_PACKED ENetProtocolThrottleConfigure; 134 | 135 | typedef struct _ENetProtocolDisconnect 136 | { 137 | ENetProtocolCommandHeader header; 138 | enet_uint32 data; 139 | } ENET_PACKED ENetProtocolDisconnect; 140 | 141 | typedef struct _ENetProtocolPing 142 | { 143 | ENetProtocolCommandHeader header; 144 | } ENET_PACKED ENetProtocolPing; 145 | 146 | typedef struct _ENetProtocolSendReliable 147 | { 148 | ENetProtocolCommandHeader header; 149 | enet_uint16 dataLength; 150 | } ENET_PACKED ENetProtocolSendReliable; 151 | 152 | typedef struct _ENetProtocolSendUnreliable 153 | { 154 | ENetProtocolCommandHeader header; 155 | enet_uint16 unreliableSequenceNumber; 156 | enet_uint16 dataLength; 157 | } ENET_PACKED ENetProtocolSendUnreliable; 158 | 159 | typedef struct _ENetProtocolSendUnsequenced 160 | { 161 | ENetProtocolCommandHeader header; 162 | enet_uint16 unsequencedGroup; 163 | enet_uint16 dataLength; 164 | } ENET_PACKED ENetProtocolSendUnsequenced; 165 | 166 | typedef struct _ENetProtocolSendFragment 167 | { 168 | ENetProtocolCommandHeader header; 169 | enet_uint16 startSequenceNumber; 170 | enet_uint16 dataLength; 171 | enet_uint32 fragmentCount; 172 | enet_uint32 fragmentNumber; 173 | enet_uint32 totalLength; 174 | enet_uint32 fragmentOffset; 175 | } ENET_PACKED ENetProtocolSendFragment; 176 | 177 | typedef union _ENetProtocol 178 | { 179 | ENetProtocolCommandHeader header; 180 | ENetProtocolAcknowledge acknowledge; 181 | ENetProtocolConnect connect; 182 | ENetProtocolVerifyConnect verifyConnect; 183 | ENetProtocolDisconnect disconnect; 184 | ENetProtocolPing ping; 185 | ENetProtocolSendReliable sendReliable; 186 | ENetProtocolSendUnreliable sendUnreliable; 187 | ENetProtocolSendUnsequenced sendUnsequenced; 188 | ENetProtocolSendFragment sendFragment; 189 | ENetProtocolBandwidthLimit bandwidthLimit; 190 | ENetProtocolThrottleConfigure throttleConfigure; 191 | } ENET_PACKED ENetProtocol; 192 | 193 | #ifdef _MSC_VER 194 | #pragma pack(pop) 195 | #endif 196 | 197 | #endif /* __ENET_PROTOCOL_H__ */ 198 | 199 | -------------------------------------------------------------------------------- /fpsgame/movable.cpp: -------------------------------------------------------------------------------- 1 | // movable.cpp: implements physics for inanimate models 2 | #include "game.h" 3 | 4 | extern int physsteps; 5 | 6 | namespace game 7 | { 8 | enum 9 | { 10 | BOXWEIGHT = 25, 11 | BARRELHEALTH = 50, 12 | BARRELWEIGHT = 25, 13 | PLATFORMWEIGHT = 1000, 14 | PLATFORMSPEED = 8, 15 | EXPLODEDELAY = 200 16 | }; 17 | 18 | struct movable : dynent 19 | { 20 | int etype, mapmodel, health, weight, exploding, tag, dir; 21 | physent *stacked; 22 | vec stackpos; 23 | 24 | movable(const entity &e) : 25 | etype(e.type), 26 | mapmodel(e.attr2), 27 | health(e.type==BARREL ? (e.attr4 ? e.attr4 : BARRELHEALTH) : 0), 28 | weight(e.type==PLATFORM || e.type==ELEVATOR ? PLATFORMWEIGHT : (e.attr3 ? e.attr3 : (e.type==BARREL ? BARRELWEIGHT : BOXWEIGHT))), 29 | exploding(0), 30 | tag(e.type==PLATFORM || e.type==ELEVATOR ? e.attr3 : 0), 31 | dir(e.type==PLATFORM || e.type==ELEVATOR ? (e.attr4 < 0 ? -1 : 1) : 0), 32 | stacked(NULL), 33 | stackpos(0, 0, 0) 34 | { 35 | state = CS_ALIVE; 36 | type = ENT_INANIMATE; 37 | yaw = e.attr1; 38 | if(e.type==PLATFORM || e.type==ELEVATOR) 39 | { 40 | maxspeed = e.attr4 ? fabs(float(e.attr4)) : PLATFORMSPEED; 41 | if(tag) vel = vec(0, 0, 0); 42 | else if(e.type==PLATFORM) { vecfromyawpitch(yaw, 0, 1, 0, vel); vel.mul(dir*maxspeed); } 43 | else vel = vec(0, 0, dir*maxspeed); 44 | } 45 | 46 | const char *mdlname = mapmodelname(e.attr2); 47 | if(mdlname) setbbfrommodel(this, mdlname); 48 | } 49 | 50 | void hitpush(int damage, const vec &dir, fpsent *actor, int gun) 51 | { 52 | if(etype!=BOX && etype!=BARREL) return; 53 | vec push(dir); 54 | push.mul(80*damage/weight); 55 | vel.add(push); 56 | } 57 | 58 | void explode(dynent *at) 59 | { 60 | state = CS_DEAD; 61 | exploding = 0; 62 | game::explode(true, (fpsent *)at, o, this, guns[GUN_BARREL].damage, GUN_BARREL); 63 | } 64 | 65 | void damaged(int damage, fpsent *at, int gun = -1) 66 | { 67 | if(etype!=BARREL || state!=CS_ALIVE || exploding) return; 68 | health -= damage; 69 | if(health>0) return; 70 | if(gun==GUN_BARREL) exploding = lastmillis + EXPLODEDELAY; 71 | else explode(at); 72 | } 73 | 74 | void suicide() 75 | { 76 | state = CS_DEAD; 77 | if(etype==BARREL) explode(player1); 78 | } 79 | }; 80 | 81 | vector movables; 82 | 83 | void clearmovables() 84 | { 85 | if(movables.length()) 86 | { 87 | cleardynentcache(); 88 | movables.deletecontents(); 89 | } 90 | if(!m_dmsp && !m_classicsp) return; 91 | loopv(entities::ents) 92 | { 93 | const entity &e = *entities::ents[i]; 94 | if(e.type!=BOX && e.type!=BARREL && e.type!=PLATFORM && e.type!=ELEVATOR) continue; 95 | movable *m = new movable(e); 96 | movables.add(m); 97 | m->o = e.o; 98 | entinmap(m); 99 | updatedynentcache(m); 100 | } 101 | } 102 | 103 | void triggerplatform(int tag, int newdir) 104 | { 105 | newdir = max(-1, min(1, newdir)); 106 | loopv(movables) 107 | { 108 | movable *m = movables[i]; 109 | if(m->state!=CS_ALIVE || (m->etype!=PLATFORM && m->etype!=ELEVATOR) || m->tag!=tag) continue; 110 | if(!newdir) 111 | { 112 | if(m->tag) m->vel = vec(0, 0, 0); 113 | else m->vel.neg(); 114 | } 115 | else 116 | { 117 | if(m->etype==PLATFORM) { vecfromyawpitch(m->yaw, 0, 1, 0, m->vel); m->vel.mul(newdir*m->dir*m->maxspeed); } 118 | else m->vel = vec(0, 0, newdir*m->dir*m->maxspeed); 119 | } 120 | } 121 | } 122 | ICOMMAND(platform, "ii", (int *tag, int *newdir), triggerplatform(*tag, *newdir)); 123 | 124 | void stackmovable(movable *d, physent *o) 125 | { 126 | d->stacked = o; 127 | d->stackpos = o->o; 128 | } 129 | 130 | void updatemovables(int curtime) 131 | { 132 | if(!curtime) return; 133 | loopv(movables) 134 | { 135 | movable *m = movables[i]; 136 | if(m->state!=CS_ALIVE) continue; 137 | if(m->etype==PLATFORM || m->etype==ELEVATOR) 138 | { 139 | if(m->vel.iszero()) continue; 140 | for(int remaining = curtime; remaining>0;) 141 | { 142 | int step = min(remaining, 20); 143 | remaining -= step; 144 | if(!moveplatform(m, vec(m->vel).mul(step/1000.0f))) 145 | { 146 | if(m->tag) { m->vel = vec(0, 0, 0); break; } 147 | else m->vel.neg(); 148 | } 149 | } 150 | } 151 | else if(m->exploding && lastmillis >= m->exploding) 152 | { 153 | m->explode(m); 154 | adddecal(DECAL_SCORCH, m->o, vec(0, 0, 1), guns[GUN_BARREL].exprad/2); 155 | } 156 | else if(m->maymove() || (m->stacked && (m->stacked->state!=CS_ALIVE || m->stackpos != m->stacked->o))) 157 | { 158 | if(physsteps > 0) m->stacked = NULL; 159 | moveplayer(m, 1, true); 160 | } 161 | } 162 | } 163 | 164 | void rendermovables() 165 | { 166 | loopv(movables) 167 | { 168 | movable &m = *movables[i]; 169 | if(m.state!=CS_ALIVE) continue; 170 | vec o = m.feetpos(); 171 | const char *mdlname = mapmodelname(m.mapmodel); 172 | if(!mdlname) continue; 173 | rendermodel(NULL, mdlname, ANIM_MAPMODEL|ANIM_LOOP, o, m.yaw, 0, MDL_LIGHT | MDL_SHADOW | MDL_CULL_VFC | MDL_CULL_DIST | MDL_CULL_OCCLUDED, &m); 174 | } 175 | } 176 | 177 | void suicidemovable(movable *m) 178 | { 179 | m->suicide(); 180 | } 181 | 182 | void hitmovable(int damage, movable *m, fpsent *at, const vec &vel, int gun) 183 | { 184 | m->hitpush(damage, vel, at, gun); 185 | m->damaged(damage, at, gun); 186 | } 187 | } 188 | 189 | -------------------------------------------------------------------------------- /include/SDL_image.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL_image: An example image loading library for use with SDL 3 | Copyright (C) 1997-2013 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /* A simple library to load images of various formats as SDL surfaces */ 23 | 24 | #ifndef _SDL_IMAGE_H 25 | #define _SDL_IMAGE_H 26 | 27 | #include "SDL.h" 28 | #include "SDL_version.h" 29 | #include "begin_code.h" 30 | 31 | /* Set up for C function definitions, even when using C++ */ 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif 35 | 36 | /* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL 37 | */ 38 | #define SDL_IMAGE_MAJOR_VERSION 2 39 | #define SDL_IMAGE_MINOR_VERSION 0 40 | #define SDL_IMAGE_PATCHLEVEL 0 41 | 42 | /* This macro can be used to fill a version structure with the compile-time 43 | * version of the SDL_image library. 44 | */ 45 | #define SDL_IMAGE_VERSION(X) \ 46 | { \ 47 | (X)->major = SDL_IMAGE_MAJOR_VERSION; \ 48 | (X)->minor = SDL_IMAGE_MINOR_VERSION; \ 49 | (X)->patch = SDL_IMAGE_PATCHLEVEL; \ 50 | } 51 | 52 | /* This function gets the version of the dynamically linked SDL_image library. 53 | it should NOT be used to fill a version structure, instead you should 54 | use the SDL_IMAGE_VERSION() macro. 55 | */ 56 | extern DECLSPEC const SDL_version * SDLCALL IMG_Linked_Version(void); 57 | 58 | typedef enum 59 | { 60 | IMG_INIT_JPG = 0x00000001, 61 | IMG_INIT_PNG = 0x00000002, 62 | IMG_INIT_TIF = 0x00000004, 63 | IMG_INIT_WEBP = 0x00000008 64 | } IMG_InitFlags; 65 | 66 | /* Loads dynamic libraries and prepares them for use. Flags should be 67 | one or more flags from IMG_InitFlags OR'd together. 68 | It returns the flags successfully initialized, or 0 on failure. 69 | */ 70 | extern DECLSPEC int SDLCALL IMG_Init(int flags); 71 | 72 | /* Unloads libraries loaded with IMG_Init */ 73 | extern DECLSPEC void SDLCALL IMG_Quit(void); 74 | 75 | /* Load an image from an SDL data source. 76 | The 'type' may be one of: "BMP", "GIF", "PNG", etc. 77 | 78 | If the image format supports a transparent pixel, SDL will set the 79 | colorkey for the surface. You can enable RLE acceleration on the 80 | surface afterwards by calling: 81 | SDL_SetColorKey(image, SDL_RLEACCEL, image->format->colorkey); 82 | */ 83 | extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadTyped_RW(SDL_RWops *src, int freesrc, const char *type); 84 | /* Convenience functions */ 85 | extern DECLSPEC SDL_Surface * SDLCALL IMG_Load(const char *file); 86 | extern DECLSPEC SDL_Surface * SDLCALL IMG_Load_RW(SDL_RWops *src, int freesrc); 87 | 88 | #if SDL_VERSION_ATLEAST(2,0,0) 89 | /* Load an image directly into a render texture. 90 | */ 91 | extern DECLSPEC SDL_Texture * SDLCALL IMG_LoadTexture(SDL_Renderer *renderer, const char *file); 92 | extern DECLSPEC SDL_Texture * SDLCALL IMG_LoadTexture_RW(SDL_Renderer *renderer, SDL_RWops *src, int freesrc); 93 | extern DECLSPEC SDL_Texture * SDLCALL IMG_LoadTextureTyped_RW(SDL_Renderer *renderer, SDL_RWops *src, int freesrc, const char *type); 94 | #endif /* SDL 2.0 */ 95 | 96 | /* Functions to detect a file type, given a seekable source */ 97 | extern DECLSPEC int SDLCALL IMG_isICO(SDL_RWops *src); 98 | extern DECLSPEC int SDLCALL IMG_isCUR(SDL_RWops *src); 99 | extern DECLSPEC int SDLCALL IMG_isBMP(SDL_RWops *src); 100 | extern DECLSPEC int SDLCALL IMG_isGIF(SDL_RWops *src); 101 | extern DECLSPEC int SDLCALL IMG_isJPG(SDL_RWops *src); 102 | extern DECLSPEC int SDLCALL IMG_isLBM(SDL_RWops *src); 103 | extern DECLSPEC int SDLCALL IMG_isPCX(SDL_RWops *src); 104 | extern DECLSPEC int SDLCALL IMG_isPNG(SDL_RWops *src); 105 | extern DECLSPEC int SDLCALL IMG_isPNM(SDL_RWops *src); 106 | extern DECLSPEC int SDLCALL IMG_isTIF(SDL_RWops *src); 107 | extern DECLSPEC int SDLCALL IMG_isXCF(SDL_RWops *src); 108 | extern DECLSPEC int SDLCALL IMG_isXPM(SDL_RWops *src); 109 | extern DECLSPEC int SDLCALL IMG_isXV(SDL_RWops *src); 110 | extern DECLSPEC int SDLCALL IMG_isWEBP(SDL_RWops *src); 111 | 112 | /* Individual loading functions */ 113 | extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadICO_RW(SDL_RWops *src); 114 | extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadCUR_RW(SDL_RWops *src); 115 | extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadBMP_RW(SDL_RWops *src); 116 | extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadGIF_RW(SDL_RWops *src); 117 | extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadJPG_RW(SDL_RWops *src); 118 | extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadLBM_RW(SDL_RWops *src); 119 | extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadPCX_RW(SDL_RWops *src); 120 | extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadPNG_RW(SDL_RWops *src); 121 | extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadPNM_RW(SDL_RWops *src); 122 | extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadTGA_RW(SDL_RWops *src); 123 | extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadTIF_RW(SDL_RWops *src); 124 | extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadXCF_RW(SDL_RWops *src); 125 | extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadXPM_RW(SDL_RWops *src); 126 | extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadXV_RW(SDL_RWops *src); 127 | extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadWEBP_RW(SDL_RWops *src); 128 | 129 | extern DECLSPEC SDL_Surface * SDLCALL IMG_ReadXPMFromArray(char **xpm); 130 | 131 | /* Individual saving functions */ 132 | extern DECLSPEC int SDLCALL IMG_SavePNG(SDL_Surface *surface, const char *file); 133 | extern DECLSPEC int SDLCALL IMG_SavePNG_RW(SDL_Surface *surface, SDL_RWops *dst, int freedst); 134 | 135 | /* We'll use SDL for reporting errors */ 136 | #define IMG_SetError SDL_SetError 137 | #define IMG_GetError SDL_GetError 138 | 139 | /* Ends C function definitions when using C++ */ 140 | #ifdef __cplusplus 141 | } 142 | #endif 143 | #include "close_code.h" 144 | 145 | #endif /* _SDL_IMAGE_H */ 146 | -------------------------------------------------------------------------------- /include/SDL_config.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | #ifndef _SDL_config_windows_h 23 | #define _SDL_config_windows_h 24 | 25 | #include "SDL_platform.h" 26 | 27 | /* This is a set of defines to configure the SDL features */ 28 | 29 | #if !defined(_STDINT_H_) && (!defined(HAVE_STDINT_H) || !_HAVE_STDINT_H) 30 | #if defined(__GNUC__) || defined(__DMC__) || defined(__WATCOMC__) 31 | #define HAVE_STDINT_H 1 32 | #elif defined(_MSC_VER) 33 | typedef signed __int8 int8_t; 34 | typedef unsigned __int8 uint8_t; 35 | typedef signed __int16 int16_t; 36 | typedef unsigned __int16 uint16_t; 37 | typedef signed __int32 int32_t; 38 | typedef unsigned __int32 uint32_t; 39 | typedef signed __int64 int64_t; 40 | typedef unsigned __int64 uint64_t; 41 | #ifndef _UINTPTR_T_DEFINED 42 | #ifdef _WIN64 43 | typedef unsigned __int64 uintptr_t; 44 | #else 45 | typedef unsigned int uintptr_t; 46 | #endif 47 | #define _UINTPTR_T_DEFINED 48 | #endif 49 | /* Older Visual C++ headers don't have the Win64-compatible typedefs... */ 50 | #if ((_MSC_VER <= 1200) && (!defined(DWORD_PTR))) 51 | #define DWORD_PTR DWORD 52 | #endif 53 | #if ((_MSC_VER <= 1200) && (!defined(LONG_PTR))) 54 | #define LONG_PTR LONG 55 | #endif 56 | #else /* !__GNUC__ && !_MSC_VER */ 57 | typedef signed char int8_t; 58 | typedef unsigned char uint8_t; 59 | typedef signed short int16_t; 60 | typedef unsigned short uint16_t; 61 | typedef signed int int32_t; 62 | typedef unsigned int uint32_t; 63 | typedef signed long long int64_t; 64 | typedef unsigned long long uint64_t; 65 | #ifndef _SIZE_T_DEFINED_ 66 | #define _SIZE_T_DEFINED_ 67 | typedef unsigned int size_t; 68 | #endif 69 | typedef unsigned int uintptr_t; 70 | #endif /* __GNUC__ || _MSC_VER */ 71 | #endif /* !_STDINT_H_ && !HAVE_STDINT_H */ 72 | 73 | #ifdef _WIN64 74 | # define SIZEOF_VOIDP 8 75 | #else 76 | # define SIZEOF_VOIDP 4 77 | #endif 78 | 79 | #define HAVE_DDRAW_H 1 80 | #define HAVE_DINPUT_H 1 81 | #define HAVE_DSOUND_H 1 82 | #define HAVE_DXGI_H 1 83 | #define HAVE_XINPUT_H 1 84 | 85 | /* This is disabled by default to avoid C runtime dependencies and manifest requirements */ 86 | #ifdef HAVE_LIBC 87 | /* Useful headers */ 88 | #define HAVE_STDIO_H 1 89 | #define STDC_HEADERS 1 90 | #define HAVE_STRING_H 1 91 | #define HAVE_CTYPE_H 1 92 | #define HAVE_MATH_H 1 93 | #define HAVE_SIGNAL_H 1 94 | 95 | /* C library functions */ 96 | #define HAVE_MALLOC 1 97 | #define HAVE_CALLOC 1 98 | #define HAVE_REALLOC 1 99 | #define HAVE_FREE 1 100 | #define HAVE_ALLOCA 1 101 | #define HAVE_QSORT 1 102 | #define HAVE_ABS 1 103 | #define HAVE_MEMSET 1 104 | #define HAVE_MEMCPY 1 105 | #define HAVE_MEMMOVE 1 106 | #define HAVE_MEMCMP 1 107 | #define HAVE_STRLEN 1 108 | #define HAVE__STRREV 1 109 | #define HAVE__STRUPR 1 110 | #define HAVE__STRLWR 1 111 | #define HAVE_STRCHR 1 112 | #define HAVE_STRRCHR 1 113 | #define HAVE_STRSTR 1 114 | #define HAVE__LTOA 1 115 | #define HAVE__ULTOA 1 116 | #define HAVE_STRTOL 1 117 | #define HAVE_STRTOUL 1 118 | #define HAVE_STRTOD 1 119 | #define HAVE_ATOI 1 120 | #define HAVE_ATOF 1 121 | #define HAVE_STRCMP 1 122 | #define HAVE_STRNCMP 1 123 | #define HAVE__STRICMP 1 124 | #define HAVE__STRNICMP 1 125 | #define HAVE_ATAN 1 126 | #define HAVE_ATAN2 1 127 | #define HAVE_ACOS 1 128 | #define HAVE_ASIN 1 129 | #define HAVE_CEIL 1 130 | #define HAVE_COS 1 131 | #define HAVE_COSF 1 132 | #define HAVE_FABS 1 133 | #define HAVE_FLOOR 1 134 | #define HAVE_LOG 1 135 | #define HAVE_POW 1 136 | #define HAVE_SIN 1 137 | #define HAVE_SINF 1 138 | #define HAVE_SQRT 1 139 | #define HAVE_SQRTF 1 140 | #define HAVE_TAN 1 141 | #define HAVE_TANF 1 142 | #if _MSC_VER >= 1800 143 | #define HAVE_STRTOLL 1 144 | #define HAVE_VSSCANF 1 145 | #define HAVE_COPYSIGN 1 146 | #define HAVE_SCALBN 1 147 | #endif 148 | #if !defined(_MSC_VER) || defined(_USE_MATH_DEFINES) 149 | #define HAVE_M_PI 1 150 | #endif 151 | #else 152 | #define HAVE_STDARG_H 1 153 | #define HAVE_STDDEF_H 1 154 | #endif 155 | 156 | /* Enable various audio drivers */ 157 | #define SDL_AUDIO_DRIVER_DSOUND 1 158 | #define SDL_AUDIO_DRIVER_XAUDIO2 1 159 | #define SDL_AUDIO_DRIVER_WINMM 1 160 | #define SDL_AUDIO_DRIVER_DISK 1 161 | #define SDL_AUDIO_DRIVER_DUMMY 1 162 | 163 | /* Enable various input drivers */ 164 | #define SDL_JOYSTICK_DINPUT 1 165 | #define SDL_JOYSTICK_XINPUT 1 166 | #define SDL_HAPTIC_DINPUT 1 167 | #define SDL_HAPTIC_XINPUT 1 168 | 169 | /* Enable various shared object loading systems */ 170 | #define SDL_LOADSO_WINDOWS 1 171 | 172 | /* Enable various threading systems */ 173 | #define SDL_THREAD_WINDOWS 1 174 | 175 | /* Enable various timer systems */ 176 | #define SDL_TIMER_WINDOWS 1 177 | 178 | /* Enable various video drivers */ 179 | #define SDL_VIDEO_DRIVER_DUMMY 1 180 | #define SDL_VIDEO_DRIVER_WINDOWS 1 181 | 182 | #ifndef SDL_VIDEO_RENDER_D3D 183 | #define SDL_VIDEO_RENDER_D3D 1 184 | #endif 185 | #ifndef SDL_VIDEO_RENDER_D3D11 186 | #define SDL_VIDEO_RENDER_D3D11 0 187 | #endif 188 | 189 | /* Enable OpenGL support */ 190 | #ifndef SDL_VIDEO_OPENGL 191 | #define SDL_VIDEO_OPENGL 1 192 | #endif 193 | #ifndef SDL_VIDEO_OPENGL_WGL 194 | #define SDL_VIDEO_OPENGL_WGL 1 195 | #endif 196 | #ifndef SDL_VIDEO_RENDER_OGL 197 | #define SDL_VIDEO_RENDER_OGL 1 198 | #endif 199 | #ifndef SDL_VIDEO_RENDER_OGL_ES2 200 | #define SDL_VIDEO_RENDER_OGL_ES2 1 201 | #endif 202 | #ifndef SDL_VIDEO_OPENGL_ES2 203 | #define SDL_VIDEO_OPENGL_ES2 1 204 | #endif 205 | #ifndef SDL_VIDEO_OPENGL_EGL 206 | #define SDL_VIDEO_OPENGL_EGL 1 207 | #endif 208 | 209 | 210 | /* Enable system power support */ 211 | #define SDL_POWER_WINDOWS 1 212 | 213 | /* Enable filesystem support */ 214 | #define SDL_FILESYSTEM_WINDOWS 1 215 | 216 | /* Enable assembly routines (Win64 doesn't have inline asm) */ 217 | #ifndef _WIN64 218 | #define SDL_ASSEMBLY_ROUTINES 1 219 | #endif 220 | 221 | #endif /* _SDL_config_windows_h */ 222 | -------------------------------------------------------------------------------- /include/SDL_endian.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_endian.h 24 | * 25 | * Functions for reading and writing endian-specific values 26 | */ 27 | 28 | #ifndef _SDL_endian_h 29 | #define _SDL_endian_h 30 | 31 | #include "SDL_stdinc.h" 32 | 33 | /** 34 | * \name The two types of endianness 35 | */ 36 | /* @{ */ 37 | #define SDL_LIL_ENDIAN 1234 38 | #define SDL_BIG_ENDIAN 4321 39 | /* @} */ 40 | 41 | #ifndef SDL_BYTEORDER /* Not defined in SDL_config.h? */ 42 | #ifdef __linux__ 43 | #include 44 | #define SDL_BYTEORDER __BYTE_ORDER 45 | #else /* __linux__ */ 46 | #if defined(__hppa__) || \ 47 | defined(__m68k__) || defined(mc68000) || defined(_M_M68K) || \ 48 | (defined(__MIPS__) && defined(__MISPEB__)) || \ 49 | defined(__ppc__) || defined(__POWERPC__) || defined(_M_PPC) || \ 50 | defined(__sparc__) 51 | #define SDL_BYTEORDER SDL_BIG_ENDIAN 52 | #else 53 | #define SDL_BYTEORDER SDL_LIL_ENDIAN 54 | #endif 55 | #endif /* __linux__ */ 56 | #endif /* !SDL_BYTEORDER */ 57 | 58 | 59 | #include "begin_code.h" 60 | /* Set up for C function definitions, even when using C++ */ 61 | #ifdef __cplusplus 62 | extern "C" { 63 | #endif 64 | 65 | /** 66 | * \file SDL_endian.h 67 | */ 68 | #if defined(__GNUC__) && defined(__i386__) && \ 69 | !(__GNUC__ == 2 && __GNUC_MINOR__ == 95 /* broken gcc version */) 70 | SDL_FORCE_INLINE Uint16 71 | SDL_Swap16(Uint16 x) 72 | { 73 | __asm__("xchgb %b0,%h0": "=q"(x):"0"(x)); 74 | return x; 75 | } 76 | #elif defined(__GNUC__) && defined(__x86_64__) 77 | SDL_FORCE_INLINE Uint16 78 | SDL_Swap16(Uint16 x) 79 | { 80 | __asm__("xchgb %b0,%h0": "=Q"(x):"0"(x)); 81 | return x; 82 | } 83 | #elif defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__)) 84 | SDL_FORCE_INLINE Uint16 85 | SDL_Swap16(Uint16 x) 86 | { 87 | int result; 88 | 89 | __asm__("rlwimi %0,%2,8,16,23": "=&r"(result):"0"(x >> 8), "r"(x)); 90 | return (Uint16)result; 91 | } 92 | #elif defined(__GNUC__) && (defined(__M68000__) || defined(__M68020__)) && !defined(__mcoldfire__) 93 | SDL_FORCE_INLINE Uint16 94 | SDL_Swap16(Uint16 x) 95 | { 96 | __asm__("rorw #8,%0": "=d"(x): "0"(x):"cc"); 97 | return x; 98 | } 99 | #else 100 | SDL_FORCE_INLINE Uint16 101 | SDL_Swap16(Uint16 x) 102 | { 103 | return SDL_static_cast(Uint16, ((x << 8) | (x >> 8))); 104 | } 105 | #endif 106 | 107 | #if defined(__GNUC__) && defined(__i386__) 108 | SDL_FORCE_INLINE Uint32 109 | SDL_Swap32(Uint32 x) 110 | { 111 | __asm__("bswap %0": "=r"(x):"0"(x)); 112 | return x; 113 | } 114 | #elif defined(__GNUC__) && defined(__x86_64__) 115 | SDL_FORCE_INLINE Uint32 116 | SDL_Swap32(Uint32 x) 117 | { 118 | __asm__("bswapl %0": "=r"(x):"0"(x)); 119 | return x; 120 | } 121 | #elif defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__)) 122 | SDL_FORCE_INLINE Uint32 123 | SDL_Swap32(Uint32 x) 124 | { 125 | Uint32 result; 126 | 127 | __asm__("rlwimi %0,%2,24,16,23": "=&r"(result):"0"(x >> 24), "r"(x)); 128 | __asm__("rlwimi %0,%2,8,8,15": "=&r"(result):"0"(result), "r"(x)); 129 | __asm__("rlwimi %0,%2,24,0,7": "=&r"(result):"0"(result), "r"(x)); 130 | return result; 131 | } 132 | #elif defined(__GNUC__) && (defined(__M68000__) || defined(__M68020__)) && !defined(__mcoldfire__) 133 | SDL_FORCE_INLINE Uint32 134 | SDL_Swap32(Uint32 x) 135 | { 136 | __asm__("rorw #8,%0\n\tswap %0\n\trorw #8,%0": "=d"(x): "0"(x):"cc"); 137 | return x; 138 | } 139 | #else 140 | SDL_FORCE_INLINE Uint32 141 | SDL_Swap32(Uint32 x) 142 | { 143 | return SDL_static_cast(Uint32, ((x << 24) | ((x << 8) & 0x00FF0000) | 144 | ((x >> 8) & 0x0000FF00) | (x >> 24))); 145 | } 146 | #endif 147 | 148 | #if defined(__GNUC__) && defined(__i386__) 149 | SDL_FORCE_INLINE Uint64 150 | SDL_Swap64(Uint64 x) 151 | { 152 | union 153 | { 154 | struct 155 | { 156 | Uint32 a, b; 157 | } s; 158 | Uint64 u; 159 | } v; 160 | v.u = x; 161 | __asm__("bswapl %0 ; bswapl %1 ; xchgl %0,%1": "=r"(v.s.a), "=r"(v.s.b):"0"(v.s.a), 162 | "1"(v.s. 163 | b)); 164 | return v.u; 165 | } 166 | #elif defined(__GNUC__) && defined(__x86_64__) 167 | SDL_FORCE_INLINE Uint64 168 | SDL_Swap64(Uint64 x) 169 | { 170 | __asm__("bswapq %0": "=r"(x):"0"(x)); 171 | return x; 172 | } 173 | #else 174 | SDL_FORCE_INLINE Uint64 175 | SDL_Swap64(Uint64 x) 176 | { 177 | Uint32 hi, lo; 178 | 179 | /* Separate into high and low 32-bit values and swap them */ 180 | lo = SDL_static_cast(Uint32, x & 0xFFFFFFFF); 181 | x >>= 32; 182 | hi = SDL_static_cast(Uint32, x & 0xFFFFFFFF); 183 | x = SDL_Swap32(lo); 184 | x <<= 32; 185 | x |= SDL_Swap32(hi); 186 | return (x); 187 | } 188 | #endif 189 | 190 | 191 | SDL_FORCE_INLINE float 192 | SDL_SwapFloat(float x) 193 | { 194 | union 195 | { 196 | float f; 197 | Uint32 ui32; 198 | } swapper; 199 | swapper.f = x; 200 | swapper.ui32 = SDL_Swap32(swapper.ui32); 201 | return swapper.f; 202 | } 203 | 204 | 205 | /** 206 | * \name Swap to native 207 | * Byteswap item from the specified endianness to the native endianness. 208 | */ 209 | /* @{ */ 210 | #if SDL_BYTEORDER == SDL_LIL_ENDIAN 211 | #define SDL_SwapLE16(X) (X) 212 | #define SDL_SwapLE32(X) (X) 213 | #define SDL_SwapLE64(X) (X) 214 | #define SDL_SwapFloatLE(X) (X) 215 | #define SDL_SwapBE16(X) SDL_Swap16(X) 216 | #define SDL_SwapBE32(X) SDL_Swap32(X) 217 | #define SDL_SwapBE64(X) SDL_Swap64(X) 218 | #define SDL_SwapFloatBE(X) SDL_SwapFloat(X) 219 | #else 220 | #define SDL_SwapLE16(X) SDL_Swap16(X) 221 | #define SDL_SwapLE32(X) SDL_Swap32(X) 222 | #define SDL_SwapLE64(X) SDL_Swap64(X) 223 | #define SDL_SwapFloatLE(X) SDL_SwapFloat(X) 224 | #define SDL_SwapBE16(X) (X) 225 | #define SDL_SwapBE32(X) (X) 226 | #define SDL_SwapBE64(X) (X) 227 | #define SDL_SwapFloatBE(X) (X) 228 | #endif 229 | /* @} *//* Swap to native */ 230 | 231 | /* Ends C function definitions when using C++ */ 232 | #ifdef __cplusplus 233 | } 234 | #endif 235 | #include "close_code.h" 236 | 237 | #endif /* _SDL_endian_h */ 238 | 239 | /* vi: set ts=4 sw=4 expandtab: */ 240 | -------------------------------------------------------------------------------- /shared/tools.cpp: -------------------------------------------------------------------------------- 1 | // implementation of generic tools 2 | 3 | #include "cube.h" 4 | 5 | void *operator new(size_t size) 6 | { 7 | void *p = malloc(size); 8 | if(!p) abort(); 9 | return p; 10 | } 11 | 12 | void *operator new[](size_t size) 13 | { 14 | void *p = malloc(size); 15 | if(!p) abort(); 16 | return p; 17 | } 18 | 19 | void operator delete(void *p) { if(p) free(p); } 20 | 21 | void operator delete[](void *p) { if(p) free(p); } 22 | 23 | #ifndef WIN32 24 | #include 25 | #endif 26 | 27 | ////////////////////////// rnd numbers //////////////////////////////////////// 28 | 29 | #define N (624) 30 | #define M (397) 31 | #define K (0x9908B0DFU) 32 | 33 | static uint state[N]; 34 | static int next = N; 35 | 36 | void seedMT(uint seed) 37 | { 38 | state[0] = seed; 39 | for(uint i = 1; i < N; i++) 40 | state[i] = seed = 1812433253U * (seed ^ (seed >> 30)) + i; 41 | next = 0; 42 | } 43 | 44 | uint randomMT() 45 | { 46 | int cur = next; 47 | if(++next >= N) 48 | { 49 | if(next > N) { seedMT(5489U + time(NULL)); cur = next++; } 50 | else next = 0; 51 | } 52 | uint y = (state[cur] & 0x80000000U) | (state[next] & 0x7FFFFFFFU); 53 | state[cur] = y = state[cur < N-M ? cur + M : cur + M-N] ^ (y >> 1) ^ (-int(y & 1U) & K); 54 | y ^= (y >> 11); 55 | y ^= (y << 7) & 0x9D2C5680U; 56 | y ^= (y << 15) & 0xEFC60000U; 57 | y ^= (y >> 18); 58 | return y; 59 | } 60 | 61 | ///////////////////////// network /////////////////////// 62 | 63 | // all network traffic is in 32bit ints, which are then compressed using the following simple scheme (assumes that most values are small). 64 | 65 | template 66 | static inline void putint_(T &p, int n) 67 | { 68 | if(n<128 && n>-127) p.put(n); 69 | else if(n<0x8000 && n>=-0x8000) { p.put(0x80); p.put(n); p.put(n>>8); } 70 | else { p.put(0x81); p.put(n); p.put(n>>8); p.put(n>>16); p.put(n>>24); } 71 | } 72 | void putint(ucharbuf &p, int n) { putint_(p, n); } 73 | void putint(packetbuf &p, int n) { putint_(p, n); } 74 | void putint(vector &p, int n) { putint_(p, n); } 75 | 76 | int getint(ucharbuf &p) 77 | { 78 | int c = (char)p.get(); 79 | if(c==-128) { int n = p.get(); n |= char(p.get())<<8; return n; } 80 | else if(c==-127) { int n = p.get(); n |= p.get()<<8; n |= p.get()<<16; return n|(p.get()<<24); } 81 | else return c; 82 | } 83 | 84 | // much smaller encoding for unsigned integers up to 28 bits, but can handle signed 85 | template 86 | static inline void putuint_(T &p, int n) 87 | { 88 | if(n < 0 || n >= (1<<21)) 89 | { 90 | p.put(0x80 | (n & 0x7F)); 91 | p.put(0x80 | ((n >> 7) & 0x7F)); 92 | p.put(0x80 | ((n >> 14) & 0x7F)); 93 | p.put(n >> 21); 94 | } 95 | else if(n < (1<<7)) p.put(n); 96 | else if(n < (1<<14)) 97 | { 98 | p.put(0x80 | (n & 0x7F)); 99 | p.put(n >> 7); 100 | } 101 | else 102 | { 103 | p.put(0x80 | (n & 0x7F)); 104 | p.put(0x80 | ((n >> 7) & 0x7F)); 105 | p.put(n >> 14); 106 | } 107 | } 108 | void putuint(ucharbuf &p, int n) { putuint_(p, n); } 109 | void putuint(packetbuf &p, int n) { putuint_(p, n); } 110 | void putuint(vector &p, int n) { putuint_(p, n); } 111 | 112 | int getuint(ucharbuf &p) 113 | { 114 | int n = p.get(); 115 | if(n & 0x80) 116 | { 117 | n += (p.get() << 7) - 0x80; 118 | if(n & (1<<14)) n += (p.get() << 14) - (1<<14); 119 | if(n & (1<<21)) n += (p.get() << 21) - (1<<21); 120 | if(n & (1<<28)) n |= -1<<28; 121 | } 122 | return n; 123 | } 124 | 125 | template 126 | static inline void putfloat_(T &p, float f) 127 | { 128 | lilswap(&f, 1); 129 | p.put((uchar *)&f, sizeof(float)); 130 | } 131 | void putfloat(ucharbuf &p, float f) { putfloat_(p, f); } 132 | void putfloat(packetbuf &p, float f) { putfloat_(p, f); } 133 | void putfloat(vector &p, float f) { putfloat_(p, f); } 134 | 135 | float getfloat(ucharbuf &p) 136 | { 137 | float f; 138 | p.get((uchar *)&f, sizeof(float)); 139 | return lilswap(f); 140 | } 141 | 142 | template 143 | static inline void sendstring_(const char *t, T &p) 144 | { 145 | while(*t) putint(p, *t++); 146 | putint(p, 0); 147 | } 148 | void sendstring(const char *t, ucharbuf &p) { sendstring_(t, p); } 149 | void sendstring(const char *t, packetbuf &p) { sendstring_(t, p); } 150 | void sendstring(const char *t, vector &p) { sendstring_(t, p); } 151 | 152 | void getstring(char *text, ucharbuf &p, size_t len) 153 | { 154 | char *t = text; 155 | do 156 | { 157 | if(t>=&text[len]) { text[len-1] = 0; return; } 158 | if(!p.remaining()) { *t = 0; return; } 159 | *t = getint(p); 160 | } 161 | while(*t++); 162 | } 163 | 164 | void filtertext(char *dst, const char *src, bool whitespace, bool forcespace, size_t len) 165 | { 166 | for(int c = uchar(*src); c; c = uchar(*++src)) 167 | { 168 | if(c == '\f') 169 | { 170 | if(!*++src) break; 171 | continue; 172 | } 173 | if(!iscubeprint(c)) 174 | { 175 | if(!iscubespace(c) || !whitespace) continue; 176 | if(forcespace) c = ' '; 177 | } 178 | *dst++ = c; 179 | if(!--len) break; 180 | } 181 | *dst = '\0'; 182 | } 183 | 184 | void ipmask::parse(const char *name) 185 | { 186 | union { uchar b[sizeof(enet_uint32)]; enet_uint32 i; } ipconv, maskconv; 187 | ipconv.i = 0; 188 | maskconv.i = 0; 189 | loopi(4) 190 | { 191 | char *end = NULL; 192 | int n = strtol(name, &end, 10); 193 | if(!end) break; 194 | if(end > name) { ipconv.b[i] = n; maskconv.b[i] = 0xFF; } 195 | name = end; 196 | while(int c = *name) 197 | { 198 | ++name; 199 | if(c == '.') break; 200 | if(c == '/') 201 | { 202 | int range = clamp(int(strtol(name, NULL, 10)), 0, 32); 203 | mask = range ? ENET_HOST_TO_NET_32(0xFFffFFff << (32 - range)) : maskconv.i; 204 | ip = ipconv.i & mask; 205 | return; 206 | } 207 | } 208 | } 209 | ip = ipconv.i; 210 | mask = maskconv.i; 211 | } 212 | 213 | int ipmask::print(char *buf) const 214 | { 215 | char *start = buf; 216 | union { uchar b[sizeof(enet_uint32)]; enet_uint32 i; } ipconv, maskconv; 217 | ipconv.i = ip; 218 | maskconv.i = mask; 219 | int lastdigit = -1; 220 | loopi(4) if(maskconv.b[i]) 221 | { 222 | if(lastdigit >= 0) *buf++ = '.'; 223 | loopj(i - lastdigit - 1) { *buf++ = '*'; *buf++ = '.'; } 224 | buf += sprintf(buf, "%d", ipconv.b[i]); 225 | lastdigit = i; 226 | } 227 | enet_uint32 bits = ~ENET_NET_TO_HOST_32(mask); 228 | int range = 32; 229 | for(; (bits&0xFF) == 0xFF; bits >>= 8) range -= 8; 230 | for(; bits&1; bits >>= 1) --range; 231 | if(!bits && range%8) buf += sprintf(buf, "/%d", range); 232 | return int(buf-start); 233 | } 234 | 235 | -------------------------------------------------------------------------------- /engine/lensflare.h: -------------------------------------------------------------------------------- 1 | static struct flaretype 2 | { 3 | int type; /* flaretex index, 0..5, -1 for 6+random shine */ 4 | float loc; /* postion on axis */ 5 | float scale; /* texture scaling */ 6 | uchar alpha; /* color alpha */ 7 | } flaretypes[] = 8 | { 9 | {2, 1.30f, 0.04f, 153}, //flares 10 | {3, 1.00f, 0.10f, 102}, 11 | {1, 0.50f, 0.20f, 77}, 12 | {3, 0.20f, 0.05f, 77}, 13 | {0, 0.00f, 0.04f, 77}, 14 | {5, -0.25f, 0.07f, 127}, 15 | {5, -0.40f, 0.02f, 153}, 16 | {5, -0.60f, 0.04f, 102}, 17 | {5, -1.00f, 0.03f, 51}, 18 | {-1, 1.00f, 0.30f, 255}, //shine - red, green, blue 19 | {-2, 1.00f, 0.20f, 255}, 20 | {-3, 1.00f, 0.25f, 255} 21 | }; 22 | 23 | struct flare 24 | { 25 | vec o, center; 26 | float size; 27 | bvec color; 28 | bool sparkle; 29 | }; 30 | 31 | VAR(flarelights, 0, 0, 1); 32 | VARP(flarecutoff, 0, 1000, 10000); 33 | VARP(flaresize, 20, 100, 500); 34 | 35 | struct flarerenderer : partrenderer 36 | { 37 | int maxflares, numflares; 38 | unsigned int shinetime; 39 | flare *flares; 40 | 41 | flarerenderer(const char *texname, int maxflares) 42 | : partrenderer(texname, 3, PT_FLARE), maxflares(maxflares), numflares(0), shinetime(0) 43 | { 44 | flares = new flare[maxflares]; 45 | } 46 | ~flarerenderer() 47 | { 48 | delete[] flares; 49 | } 50 | 51 | void reset() 52 | { 53 | numflares = 0; 54 | } 55 | 56 | void newflare(vec &o, const vec ¢er, uchar r, uchar g, uchar b, float mod, float size, bool sun, bool sparkle) 57 | { 58 | if(numflares >= maxflares) return; 59 | vec target; //occlusion check (neccessary as depth testing is turned off) 60 | if(!raycubelos(o, camera1->o, target)) return; 61 | flare &f = flares[numflares++]; 62 | f.o = o; 63 | f.center = center; 64 | f.size = size; 65 | f.color[0] = uchar(r*mod); 66 | f.color[1] = uchar(g*mod); 67 | f.color[2] = uchar(b*mod); 68 | f.sparkle = sparkle; 69 | } 70 | 71 | void addflare(vec &o, uchar r, uchar g, uchar b, bool sun, bool sparkle) 72 | { 73 | //frustrum + fog check 74 | if(isvisiblesphere(0.0f, o) > (sun?VFC_FOGGED:VFC_FULL_VISIBLE)) return; 75 | //find closest point between camera line of sight and flare pos 76 | vec flaredir = vec(o).sub(camera1->o); 77 | vec center = vec(camdir).mul(flaredir.dot(camdir)).add(camera1->o); 78 | float mod, size; 79 | if(sun) //fixed size 80 | { 81 | mod = 1.0; 82 | size = flaredir.magnitude() * flaresize / 100.0f; 83 | } 84 | else 85 | { 86 | mod = (flarecutoff-vec(o).sub(center).squaredlen())/flarecutoff; 87 | if(mod < 0.0f) return; 88 | size = flaresize / 5.0f; 89 | } 90 | newflare(o, center, r, g, b, mod, size, sun, sparkle); 91 | } 92 | 93 | void makelightflares() 94 | { 95 | numflares = 0; //regenerate flarelist each frame 96 | shinetime = lastmillis/10; 97 | 98 | if(editmode || !flarelights) return; 99 | 100 | const vector &ents = entities::getents(); 101 | extern const vector &checklightcache(int x, int y); 102 | const vector &lights = checklightcache(int(camera1->o.x), int(camera1->o.y)); 103 | loopv(lights) 104 | { 105 | entity &e = *ents[lights[i]]; 106 | if(e.type != ET_LIGHT) continue; 107 | bool sun = (e.attr1==0); 108 | float radius = float(e.attr1); 109 | vec flaredir = vec(e.o).sub(camera1->o); 110 | float len = flaredir.magnitude(); 111 | if(!sun && (len > radius)) continue; 112 | if(isvisiblesphere(0.0f, e.o) > (sun?VFC_FOGGED:VFC_FULL_VISIBLE)) continue; 113 | vec center = vec(camdir).mul(flaredir.dot(camdir)).add(camera1->o); 114 | float mod, size; 115 | if(sun) //fixed size 116 | { 117 | mod = 1.0; 118 | size = len * flaresize / 100.0f; 119 | } 120 | else 121 | { 122 | mod = (radius-len)/radius; 123 | size = flaresize / 5.0f; 124 | } 125 | newflare(e.o, center, e.attr2, e.attr3, e.attr4, mod, size, sun, sun); 126 | } 127 | } 128 | 129 | int count() 130 | { 131 | return numflares; 132 | } 133 | 134 | bool haswork() 135 | { 136 | return (numflares != 0) && !glaring && !reflecting && !refracting; 137 | } 138 | 139 | void render() 140 | { 141 | glDisable(GL_FOG); 142 | defaultshader->set(); 143 | glDisable(GL_DEPTH_TEST); 144 | if(!tex) tex = textureload(texname); 145 | glBindTexture(GL_TEXTURE_2D, tex->id); 146 | glBegin(GL_QUADS); 147 | loopi(numflares) 148 | { 149 | const flare &f = flares[i]; 150 | vec center = f.center; 151 | vec axis = vec(f.o).sub(center); 152 | bvec4 color(f.color, 255); 153 | loopj(f.sparkle?12:9) 154 | { 155 | const flaretype &ft = flaretypes[j]; 156 | vec o = vec(axis).mul(ft.loc).add(center); 157 | float sz = ft.scale * f.size; 158 | int tex = ft.type; 159 | if(ft.type < 0) //sparkles - always done last 160 | { 161 | shinetime = (shinetime + 1) % 10; 162 | tex = 6+shinetime; 163 | color.r = 0; 164 | color.g = 0; 165 | color.b = 0; 166 | color[-ft.type-1] = f.color[-ft.type-1]; //only want a single channel 167 | } 168 | color.a = ft.alpha; 169 | glColor4ubv(color.v); 170 | const float tsz = 0.25; //flares are aranged in 4x4 grid 171 | float tx = tsz*(tex&0x03); 172 | float ty = tsz*((tex>>2)&0x03); 173 | glTexCoord2f(tx, ty+tsz); glVertex3f(o.x+(-camright.x+camup.x)*sz, o.y+(-camright.y+camup.y)*sz, o.z+(-camright.z+camup.z)*sz); 174 | glTexCoord2f(tx+tsz, ty+tsz); glVertex3f(o.x+( camright.x+camup.x)*sz, o.y+( camright.y+camup.y)*sz, o.z+( camright.z+camup.z)*sz); 175 | glTexCoord2f(tx+tsz, ty); glVertex3f(o.x+( camright.x-camup.x)*sz, o.y+( camright.y-camup.y)*sz, o.z+( camright.z-camup.z)*sz); 176 | glTexCoord2f(tx, ty); glVertex3f(o.x+(-camright.x-camup.x)*sz, o.y+(-camright.y-camup.y)*sz, o.z+(-camright.z-camup.z)*sz); 177 | } 178 | } 179 | glEnd(); 180 | glEnable(GL_DEPTH_TEST); 181 | glEnable(GL_FOG); 182 | } 183 | 184 | //square per round hole - use addflare(..) instead 185 | particle *addpart(const vec &o, const vec &d, int fade, int color, float size, int gravity = 0) { return NULL; } 186 | }; 187 | static flarerenderer flares("packages/particles/lensflares.png", 64); 188 | 189 | --------------------------------------------------------------------------------