Did major cleanup, as Amanieu reccomended
Applied Semi Mark Fix (Issue 84) Applied MediStation shove control (Issue 85) Fixed g_modhumanstamina, now affects jums too (Issue 86) Applied high turret angles (Issue 87) Changed !demo to the PROPER adminchat flag (?)
This commit is contained in:
1 parent
1933b4fb90
commit
04c5735b78
363 files changed
+102
-224759
No files matched your search
@@ -21,11 +21,11 @@ else
|
||||
COMPILE_ARCH=$(shell uname -m | sed -e s/i.86/x86/)
|
||||
endif
|
||||
|
||||
BUILD_CLIENT =0
|
||||
BUILD_CLIENT_SMP =0
|
||||
BUILD_SERVER =0
|
||||
BUILD_GAME_SO =0
|
||||
BUILD_GAME_QVM =1
|
||||
BUILD_CLIENT = 0
|
||||
BUILD_CLIENT_SMP = 0
|
||||
BUILD_SERVER = 0
|
||||
BUILD_GAME_SO =
|
||||
BUILD_GAME_QVM =
|
||||
|
||||
#############################################################################
|
||||
#
|
||||
@@ -95,6 +95,14 @@ ifndef USE_OPENAL_DLOPEN
|
||||
USE_OPENAL_DLOPEN=0
|
||||
endif
|
||||
|
||||
ifndef USE_GMP_DLOPEN
|
||||
USE_GMP_DLOPEN=0
|
||||
endif
|
||||
|
||||
ifndef USE_NETTLE_DLOPEN
|
||||
USE_NETTLE_DLOPEN=0
|
||||
endif
|
||||
|
||||
ifndef USE_CURL
|
||||
USE_CURL=1
|
||||
endif
|
||||
@@ -115,10 +123,6 @@ ifndef USE_LOCAL_HEADERS
|
||||
USE_LOCAL_HEADERS=1
|
||||
endif
|
||||
|
||||
ifndef BUILD_MASTER_SERVER
|
||||
BUILD_MASTER_SERVER=0
|
||||
endif
|
||||
|
||||
#############################################################################
|
||||
|
||||
BD=$(BUILD_DIR)/debug-$(PLATFORM)-$(ARCH)
|
||||
@@ -137,7 +141,6 @@ JPDIR=$(MOUNT_DIR)/jpeg-6
|
||||
TOOLSDIR=$(MOUNT_DIR)/tools
|
||||
SDLHDIR=$(MOUNT_DIR)/SDL12
|
||||
LIBSDIR=$(MOUNT_DIR)/libs
|
||||
MASTERDIR=$(MOUNT_DIR)/master
|
||||
|
||||
# extract version info
|
||||
VERSION=$(shell grep "\#define VERSION_NUMBER" $(CMDIR)/q_shared.h | \
|
||||
@@ -210,6 +213,15 @@ ifeq ($(PLATFORM),linux)
|
||||
BASE_CFLAGS += -I/usr/X11R6/include
|
||||
endif
|
||||
|
||||
ifeq ($(USE_NETTLE_DLOPEN),1)
|
||||
BASE_CFLAGS += -DUSE_NETTLE_DLOPEN
|
||||
else
|
||||
USE_GMP_DLOPEN = 0
|
||||
endif
|
||||
ifeq ($(USE_GMP_DLOPEN),1)
|
||||
BASE_CFLAGS += -DUSE_GMP_DLOPEN
|
||||
endif
|
||||
|
||||
OPTIMIZE = -O3 -ffast-math -funroll-loops -fomit-frame-pointer
|
||||
|
||||
ifeq ($(ARCH),x86_64)
|
||||
@@ -269,6 +281,13 @@ ifeq ($(PLATFORM),linux)
|
||||
CLIENT_LDFLAGS += -lvorbisfile -lvorbis -logg
|
||||
endif
|
||||
|
||||
ifneq ($(USE_NETTLE_DLOPEN),1)
|
||||
LDFLAGS += -lnettle
|
||||
endif
|
||||
ifneq ($(USE_GMP_DLOPEN),1)
|
||||
LDFLAGS += -lgmp
|
||||
endif
|
||||
|
||||
ifeq ($(ARCH),x86)
|
||||
# linux32 make ...
|
||||
BASE_CFLAGS += -m32
|
||||
@@ -463,6 +482,15 @@ endif
|
||||
CLIENT_LDFLAGS += -lvorbisfile -lvorbis -logg
|
||||
endif
|
||||
|
||||
# Building nettle as a dll is broken, atm
|
||||
LDFLAGS += -lnettle -lgmp
|
||||
# ifneq ($(USE_NETTLE_DLOPEN),1)
|
||||
# LDFLAGS += -lnettle
|
||||
# endif
|
||||
# ifneq ($(USE_GMP_DLOPEN),1)
|
||||
# LDFLAGS += -lgmp
|
||||
# endif
|
||||
|
||||
ifeq ($(ARCH),x86)
|
||||
# build 32bit
|
||||
BASE_CFLAGS += -m32
|
||||
@@ -712,17 +740,13 @@ endif
|
||||
|
||||
ifneq ($(BUILD_GAME_SO),0)
|
||||
TARGETS += \
|
||||
$(B)/base/cgame$(ARCH).$(SHLIBEXT) \
|
||||
$(B)/base/game$(ARCH).$(SHLIBEXT) \
|
||||
$(B)/base/ui$(ARCH).$(SHLIBEXT)
|
||||
$(B)/base/game$(ARCH).$(SHLIBEXT)
|
||||
endif
|
||||
|
||||
ifneq ($(BUILD_GAME_QVM),0)
|
||||
ifneq ($(CROSS_COMPILING),1)
|
||||
TARGETS += \
|
||||
$(B)/base/vm/cgame.qvm \
|
||||
$(B)/base/vm/game.qvm \
|
||||
$(B)/base/vm/ui.qvm
|
||||
$(B)/base/vm/game.qvm
|
||||
endif
|
||||
endif
|
||||
|
||||
@@ -796,15 +820,9 @@ all: debug release
|
||||
|
||||
debug:
|
||||
@$(MAKE) targets B=$(BD) CFLAGS="$(CFLAGS) $(DEBUG_CFLAGS)"
|
||||
ifeq ($(BUILD_MASTER_SERVER),1)
|
||||
$(MAKE) -C $(MASTERDIR) debug
|
||||
endif
|
||||
|
||||
release:
|
||||
@$(MAKE) targets B=$(BR) CFLAGS="$(CFLAGS) $(RELEASE_CFLAGS)"
|
||||
ifeq ($(BUILD_MASTER_SERVER),1)
|
||||
$(MAKE) -C $(MASTERDIR) release
|
||||
endif
|
||||
|
||||
# Create the build directories and tools, print out
|
||||
# an informational message, then start building
|
||||
@@ -886,6 +904,7 @@ Q3OBJ = \
|
||||
\
|
||||
$(B)/client/cmd.o \
|
||||
$(B)/client/common.o \
|
||||
$(B)/client/crypto.o \
|
||||
$(B)/client/cvar.o \
|
||||
$(B)/client/files.o \
|
||||
$(B)/client/md4.o \
|
||||
@@ -1089,6 +1108,7 @@ Q3DOBJ = \
|
||||
$(B)/ded/cm_trace.o \
|
||||
$(B)/ded/cmd.o \
|
||||
$(B)/ded/common.o \
|
||||
$(B)/ded/crypto.o \
|
||||
$(B)/ded/cvar.o \
|
||||
$(B)/ded/files.o \
|
||||
$(B)/ded/md4.o \
|
||||
@@ -1364,7 +1384,6 @@ $(B)/base/qcommon/%.asm: $(CMDIR)/%.c
|
||||
#############################################################################
|
||||
|
||||
clean: clean-debug clean-release
|
||||
@$(MAKE) -C $(MASTERDIR) clean
|
||||
|
||||
clean2:
|
||||
@echo "CLEAN $(B)"
|
||||
|
||||
@@ -1,95 +0,0 @@
|
||||
#!/bin/sh
|
||||
APPBUNDLE=Tremulous.app
|
||||
BINARY=Tremulous.ub
|
||||
PKGINFO=APPLTREM
|
||||
ICNS=src/unix/MacSupport/Tremulous.icns
|
||||
DESTDIR=build/release-darwin-ub
|
||||
BASEDIR=base
|
||||
Q3_VERSION=`grep "\#define Q3_VERSION" src/qcommon/q_shared.h | \
|
||||
sed -e 's/.*".* \([^ ]*\)"/\1/'`;
|
||||
|
||||
BIN_OBJ="
|
||||
build/release-darwin-ppc/tremulous.ppc
|
||||
build/release-darwin-x86/tremulous.x86
|
||||
"
|
||||
BASE_OBJ="
|
||||
build/release-darwin-ppc/$BASEDIR/cgameppc.dylib
|
||||
build/release-darwin-x86/$BASEDIR/cgamex86.dylib
|
||||
build/release-darwin-ppc/$BASEDIR/uippc.dylib
|
||||
build/release-darwin-x86/$BASEDIR/uix86.dylib
|
||||
build/release-darwin-ppc/$BASEDIR/gameppc.dylib
|
||||
build/release-darwin-x86/$BASEDIR/gamex86.dylib
|
||||
"
|
||||
if [ ! -f Makefile ]; then
|
||||
echo "This script must be run from the Tremulous build directory";
|
||||
fi
|
||||
|
||||
if [ ! -d /Developer/SDKs/MacOSX10.2.8.sdk ]; then
|
||||
echo "
|
||||
/Developer/SDKs/MacOSX10.2.8.sdk/ is missing, this doesn't install by default
|
||||
with newer XCode releases, but the installers is included"
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
if [ ! -d /Developer/SDKs/MacOSX10.4u.sdk ]; then
|
||||
echo "
|
||||
/Developer/SDKs/MacOSX10.4u.sdk/ is missing. You must install XCode 2.2 or
|
||||
newer in order to build Universal Binaries"
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
(BUILD_MACOSX_UB=ppc make && BUILD_MACOSX_UB=x86 make) || exit 1;
|
||||
|
||||
echo "Creating .app bundle $DESTDIR/$APPBUNDLE"
|
||||
if [ ! -d $DESTDIR/$APPBUNDLE/Contents/MacOS/$BASEDIR ]; then
|
||||
mkdir -p $DESTDIR/$APPBUNDLE/Contents/MacOS/$BASEDIR || exit 1;
|
||||
fi
|
||||
if [ ! -d $DESTDIR/$APPBUNDLE/Contents/MacOS/$MPACKDIR ]; then
|
||||
mkdir -p $DESTDIR/$APPBUNDLE/Contents/MacOS/$MPACKDIR || exit 1;
|
||||
fi
|
||||
if [ ! -d $DESTDIR/$APPBUNDLE/Contents/Resources ]; then
|
||||
mkdir -p $DESTDIR/$APPBUNDLE/Contents/Resources
|
||||
fi
|
||||
cp $ICNS $DESTDIR/$APPBUNDLE/Contents/Resources/Tremulous.icns || exit 1;
|
||||
echo $PKGINFO > $DESTDIR/$APPBUNDLE/Contents/PkgInfo
|
||||
echo "
|
||||
<?xml version=\"1.0\" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist
|
||||
PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\"
|
||||
\"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">
|
||||
<plist version=\"1.0\">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>English</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$BINARY</string>
|
||||
<key>CFBundleGetInfoString</key>
|
||||
<string>$Q3_VERSION</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string>Tremulous.icns</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>net.tremulous</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>Tremulous</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>$Q3_VERSION</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>$PKGINFO</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>$Q3_VERSION</string>
|
||||
<key>NSExtensions</key>
|
||||
<dict/>
|
||||
<key>NSPrincipalClass</key>
|
||||
<string>NSApplication</string>
|
||||
</dict>
|
||||
</plist>
|
||||
" > $DESTDIR/$APPBUNDLE/Contents/Info.plist
|
||||
|
||||
lipo -create -o $DESTDIR/$APPBUNDLE/Contents/MacOS/$BINARY $BIN_OBJ
|
||||
cp $BASE_OBJ $DESTDIR/$APPBUNDLE/Contents/MacOS/$BASEDIR/
|
||||
cp src/libs/macosx/*.dylib $DESTDIR/$APPBUNDLE/Contents/MacOS/
|
||||
|
||||
-1707
File diff suppressed because it is too large.
Load diff
-8358
File diff suppressed because it is too large.
Load diff
@@ -1,50 +0,0 @@
|
||||
#! /bin/sh
|
||||
|
||||
cd /tmp
|
||||
|
||||
# Make sure previous copies are gone
|
||||
rm -rf quake3/
|
||||
|
||||
# Checkout a new copy of ioq3
|
||||
svn co svn://svn.icculus.org/quake3/trunk/ quake3
|
||||
cd quake3/
|
||||
|
||||
IOQ3REVISION=`svnversion .`
|
||||
IOQ3VERSION=ioq3-r$IOQ3REVISION
|
||||
|
||||
rm -rf $IOQ3VERSION
|
||||
svn export . $IOQ3VERSION
|
||||
cd $IOQ3VERSION
|
||||
|
||||
# Remove READMEs and the like
|
||||
rm -rf BUGS ChangeLog README COPYING.txt NOTTODO TODO id-readme.txt web/
|
||||
|
||||
# Remove Q3 ui stuff
|
||||
rm -rf ui/
|
||||
|
||||
# Remove Windows/VC related stuff
|
||||
rm -f `find -iname "*.bat"`
|
||||
rm -f `find -iname "*.lnt"`
|
||||
rm -f `find -iname "*.sln"`
|
||||
rm -f `find -iname "*.vcproj"`
|
||||
rm -f `find -iname "*.def"`
|
||||
rm -f `find -iname "*.q3asm"`
|
||||
rm -f `find -iname "*.mak"`
|
||||
rm -f `find -iname "*.ico"`
|
||||
rm -f `find -iname "*.bmp"`
|
||||
rm -f code/tools/lcc/makefile.nt
|
||||
rm -rf code/win32/msvc/
|
||||
|
||||
# Remove Linux docs
|
||||
rm -rf code/unix/LinuxSupport/
|
||||
rm -rf code/unix/setup/
|
||||
rm -f code/unix/README.*
|
||||
rm -f code/unix/quake3.*
|
||||
|
||||
# Remove game code
|
||||
rm -rf code/cgame/ code/game/ code/ui/ code/q3_ui/
|
||||
|
||||
mv code src
|
||||
|
||||
cd ..
|
||||
svn_load_dirs svn://svn.icculus.org/tremulous/ -t upstream/$IOQ3VERSION upstream/current $IOQ3VERSION/
|
||||
@@ -1,39 +0,0 @@
|
||||
//Example Tremulous 1.1 decicated server config
|
||||
|
||||
set sv_pure 1
|
||||
|
||||
//passwords
|
||||
set g_needpass 0
|
||||
//set g_password password //server password
|
||||
//set rconPassword password //rcon password
|
||||
|
||||
//loading screen
|
||||
set sv_hostname "Tremulous 1.1.0 Server"
|
||||
set g_motd "http://tremulous.net/"
|
||||
|
||||
//disallow downloads from the server
|
||||
set sv_allowdownload 0
|
||||
|
||||
//maximum number of clients
|
||||
//greater than 24 is not recommended from a gameplay point of view
|
||||
set sv_maxclients 24
|
||||
|
||||
//after 50 minutes, all build points are removed
|
||||
set g_suddenDeathTime 50
|
||||
//after 60 minutes, the game will end as a draw
|
||||
set timelimit 60
|
||||
|
||||
//forces each team to have a similar number of players
|
||||
set g_teamForceBalance 1
|
||||
|
||||
//following the first map, start this rotation
|
||||
set g_initialMapRotation rotation1
|
||||
|
||||
//misc settings
|
||||
set pmove_fixed 0
|
||||
set sv_minRate 5000
|
||||
set sv_maxRate 15000
|
||||
set sv_minSnaps 10
|
||||
|
||||
//start this map first
|
||||
map niveus
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 198 B |
@@ -1,90 +0,0 @@
|
||||
/* XPM */
|
||||
static char * tremulous_xpm[] = {
|
||||
"48 48 39 1",
|
||||
" c None",
|
||||
". c #0F0F0F",
|
||||
"+ c #181818",
|
||||
"@ c #000000",
|
||||
"# c #282828",
|
||||
"$ c #212121",
|
||||
"% c #060606",
|
||||
"& c #1D1D1D",
|
||||
"* c #252525",
|
||||
"= c #080808",
|
||||
"- c #0E0E0E",
|
||||
"; c #050505",
|
||||
"> c #0B0B0B",
|
||||
", c #0C0C0C",
|
||||
"' c #232323",
|
||||
") c #1F1F1F",
|
||||
"! c #030303",
|
||||
"~ c #0D0D0D",
|
||||
"{ c #040404",
|
||||
"] c #020202",
|
||||
"^ c #141414",
|
||||
"/ c #1E1E1E",
|
||||
"( c #131313",
|
||||
"_ c #111111",
|
||||
": c #010101",
|
||||
"< c #191919",
|
||||
"[ c #090909",
|
||||
"} c #292929",
|
||||
"| c #070707",
|
||||
"1 c #121212",
|
||||
"2 c #1B1B1B",
|
||||
"3 c #161616",
|
||||
"4 c #0A0A0A",
|
||||
"5 c #222222",
|
||||
"6 c #242424",
|
||||
"7 c #1A1A1A",
|
||||
"8 c #151515",
|
||||
"9 c #101010",
|
||||
"0 c #171717",
|
||||
" ",
|
||||
" ... ",
|
||||
" +@@@@@# ",
|
||||
" $@@@@@@% ",
|
||||
" &@@@@@@@@ * ",
|
||||
" =- ;@@@@@@@@> ,@- ",
|
||||
" @@' ;@@@@@@@@@ ,@@ ",
|
||||
" )@! ;@@@@@@@@@ ~@@; ",
|
||||
" ;@{ ]@@@@@@@@@~ ,@@; ",
|
||||
" ^@@] /@@@@@@@@@@@( -@@; ",
|
||||
" .@@; /@@@@@@@@@@@ -@@@/ ",
|
||||
" _@@] /@@@@@@@@@@@ #:@@@_ ",
|
||||
" @@@; /@@@@@@@@@@< :@@@- ",
|
||||
" :@@! ]@@@@@@@@@ @@@@- ",
|
||||
" $@@@; ;@@@@@@@@[ ~]@@@- ",
|
||||
" %@@@; }!@@@@@@@@- }|@@@@, ",
|
||||
" !@@@; 1@@@@@@@@@@ 2@@@@@~ ",
|
||||
" ;@@@% [@@@@@@@@@@@@@@@@, ",
|
||||
" @@@@{|||:@@@@@@@@@@@@@@!- ",
|
||||
" -@@@@@@@@@@@@@@@@@@@@@] ",
|
||||
" .@@@@@@@@@@@@@@@@@@@{ ",
|
||||
" ]@@@@@@@@@@@@@@@@@ ",
|
||||
" .@@@@@@@@@@@@@@@@ ",
|
||||
" +@@@@@@@@@@@@@@@@@@@@@@@@@@/ ",
|
||||
" =@@@@@@@@@@@@@@@@@@@@@@@@@/ ",
|
||||
" .=@@@@@@@@@@@@@@@@@@% ",
|
||||
" ,@@@@@@@@@@@@@@@@@@@@@ ",
|
||||
" 2>]@@@@@@@@@@@@@@@@@@@@@@@3 ",
|
||||
" *:@@@@@@@@@@@@@@@@@@@@@@@@@^ ",
|
||||
" @@@||| 4]@@@@@@@@@@@@@@@@@ ",
|
||||
" 556 _@@@@@@@@@@@@@@@@3 ",
|
||||
" >@@@@@@@@@@@@@@@@+ ",
|
||||
" ;@@@@@@@@@@@@@@@@@7 ",
|
||||
" &@@@@@@@@@@@@@@@@@@@+ ",
|
||||
" @@@@@@@@@@@@@@@@@@@@@/ ",
|
||||
" 8@@@@@@@@@@@@@@@[ =@@| ",
|
||||
" ;@@:::@@@@@@@@@[ %@@[ ",
|
||||
" @@9 (@@@@@@@4 =@@ ",
|
||||
" ,@@ {:@@: {@! ",
|
||||
" !@@ << 3@@0 ",
|
||||
" !@- 3@@6 ",
|
||||
" ]@( (@[ ",
|
||||
" 7@@ ]@ ",
|
||||
" 7@@ * ",
|
||||
" 7@} ",
|
||||
" 7@ ",
|
||||
" . ",
|
||||
" "};
|
||||
@@ -1,16 +0,0 @@
|
||||
This file identifies the version of the AL headers in this directory. If you
|
||||
change or update the AL headers in any way, please make sure you also update
|
||||
this file.
|
||||
|
||||
SVN revision >= 402
|
||||
-------------------
|
||||
Headers are from OpenAL CVS 6th August 2005:
|
||||
$ cvs -d:pserver:guest@opensource.creative.com:/usr/local/cvs-repository
|
||||
login
|
||||
(use password "guest")
|
||||
$ cvs -d:pserver:guest@opensource.creative.com:/usr/local/cvs-repository
|
||||
co -D "6 Aug 2005" openal
|
||||
|
||||
SVN revision >= 374
|
||||
-------------------
|
||||
Standard OpenAL 1.0 headers
|
||||
-505
@@ -1,505 +0,0 @@
|
||||
#ifndef __al_h_
|
||||
#define __al_h_
|
||||
|
||||
/**
|
||||
* OpenAL cross platform audio library
|
||||
* Copyright (C) 1999-2000 by authors.
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
* Or go to http://www.gnu.org/copyleft/lgpl.html
|
||||
*/
|
||||
#include "altypes.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* WIN32, not Xbox */
|
||||
#ifdef _WIN32
|
||||
#ifndef _XBOX
|
||||
#ifdef _OPENAL32LIB
|
||||
#define ALAPI __declspec(dllexport)
|
||||
#else
|
||||
#define ALAPI __declspec(dllimport)
|
||||
#endif
|
||||
#define ALAPIENTRY __cdecl
|
||||
#define AL_CALLBACK
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef TARGET_OS_MAC
|
||||
#if TARGET_OS_MAC
|
||||
#pragma export on
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef ALAPI
|
||||
#define ALAPI
|
||||
#endif
|
||||
|
||||
#ifndef ALAPIENTRY
|
||||
#define ALAPIENTRY
|
||||
#endif
|
||||
|
||||
#ifndef CALLBACK
|
||||
#define AL_CALLBACK
|
||||
#endif
|
||||
|
||||
#define OPENAL
|
||||
|
||||
#ifndef AL_NO_PROTOTYPES
|
||||
|
||||
/*
|
||||
* Renderer State management
|
||||
*/
|
||||
ALAPI void ALAPIENTRY alEnable( ALenum capability );
|
||||
|
||||
ALAPI void ALAPIENTRY alDisable( ALenum capability );
|
||||
|
||||
ALAPI ALboolean ALAPIENTRY alIsEnabled( ALenum capability );
|
||||
|
||||
|
||||
/*
|
||||
* State retrieval
|
||||
*/
|
||||
ALAPI const ALchar* ALAPIENTRY alGetString( ALenum param );
|
||||
|
||||
ALAPI void ALAPIENTRY alGetBooleanv( ALenum param, ALboolean* data );
|
||||
|
||||
ALAPI void ALAPIENTRY alGetIntegerv( ALenum param, ALint* data );
|
||||
|
||||
ALAPI void ALAPIENTRY alGetFloatv( ALenum param, ALfloat* data );
|
||||
|
||||
ALAPI void ALAPIENTRY alGetDoublev( ALenum param, ALdouble* data );
|
||||
|
||||
ALAPI ALboolean ALAPIENTRY alGetBoolean( ALenum param );
|
||||
|
||||
ALAPI ALint ALAPIENTRY alGetInteger( ALenum param );
|
||||
|
||||
ALAPI ALfloat ALAPIENTRY alGetFloat( ALenum param );
|
||||
|
||||
ALAPI ALdouble ALAPIENTRY alGetDouble( ALenum param );
|
||||
|
||||
|
||||
/*
|
||||
* Error support.
|
||||
* Obtain the most recent error generated in the AL state machine.
|
||||
*/
|
||||
ALAPI ALenum ALAPIENTRY alGetError( ALvoid );
|
||||
|
||||
|
||||
/*
|
||||
* Extension support.
|
||||
* Query for the presence of an extension, and obtain any appropriate
|
||||
* function pointers and enum values.
|
||||
*/
|
||||
ALAPI ALboolean ALAPIENTRY alIsExtensionPresent( const ALchar* extname );
|
||||
|
||||
ALAPI void* ALAPIENTRY alGetProcAddress( const ALchar* fname );
|
||||
|
||||
ALAPI ALenum ALAPIENTRY alGetEnumValue( const ALchar* ename );
|
||||
|
||||
|
||||
/*
|
||||
* LISTENER
|
||||
* Listener represents the location and orientation of the
|
||||
* 'user' in 3D-space.
|
||||
*
|
||||
* Properties include: -
|
||||
*
|
||||
* Gain AL_GAIN ALfloat
|
||||
* Position AL_POSITION ALfloat[3]
|
||||
* Velocity AL_VELOCITY ALfloat[3]
|
||||
* Orientation AL_ORIENTATION ALfloat[6] (Forward then Up vectors)
|
||||
*/
|
||||
|
||||
/*
|
||||
* Set Listener parameters
|
||||
*/
|
||||
ALAPI void ALAPIENTRY alListenerf( ALenum param, ALfloat value );
|
||||
|
||||
ALAPI void ALAPIENTRY alListener3f( ALenum param, ALfloat value1, ALfloat value2, ALfloat value3 );
|
||||
|
||||
ALAPI void ALAPIENTRY alListenerfv( ALenum param, const ALfloat* values );
|
||||
|
||||
ALAPI void ALAPIENTRY alListeneri( ALenum param, ALint value );
|
||||
|
||||
ALAPI void ALAPIENTRY alListener3i( ALenum param, ALint value1, ALint value2, ALint value3 );
|
||||
|
||||
ALAPI void ALAPIENTRY alListeneriv( ALenum param, const ALint* values );
|
||||
|
||||
/*
|
||||
* Get Listener parameters
|
||||
*/
|
||||
ALAPI void ALAPIENTRY alGetListenerf( ALenum param, ALfloat* value );
|
||||
|
||||
ALAPI void ALAPIENTRY alGetListener3f( ALenum param, ALfloat *value1, ALfloat *value2, ALfloat *value3 );
|
||||
|
||||
ALAPI void ALAPIENTRY alGetListenerfv( ALenum param, ALfloat* values );
|
||||
|
||||
ALAPI void ALAPIENTRY alGetListeneri( ALenum param, ALint* value );
|
||||
|
||||
ALAPI void ALAPIENTRY alGetListener3i( ALenum param, ALint *value1, ALint *value2, ALint *value3 );
|
||||
|
||||
ALAPI void ALAPIENTRY alGetListeneriv( ALenum param, ALint* values );
|
||||
|
||||
|
||||
/**
|
||||
* SOURCE
|
||||
* Sources represent individual sound objects in 3D-space.
|
||||
* Sources take the PCM data provided in the specified Buffer,
|
||||
* apply Source-specific modifications, and then
|
||||
* submit them to be mixed according to spatial arrangement etc.
|
||||
*
|
||||
* Properties include: -
|
||||
*
|
||||
* Gain AL_GAIN ALfloat
|
||||
* Min Gain AL_MIN_GAIN ALfloat
|
||||
* Max Gain AL_MAX_GAIN ALfloat
|
||||
* Position AL_POSITION ALfloat[3]
|
||||
* Velocity AL_VELOCITY ALfloat[3]
|
||||
* Direction AL_DIRECTION ALfloat[3]
|
||||
* Head Relative Mode AL_SOURCE_RELATIVE ALint (AL_TRUE or AL_FALSE)
|
||||
* Reference Distance AL_REFERENCE_DISTANCE ALfloat
|
||||
* Max Distance AL_MAX_DISTANCE ALfloat
|
||||
* RollOff Factor AL_ROLLOFF_FACTOR ALfloat
|
||||
* Inner Angle AL_CONE_INNER_ANGLE ALint or ALfloat
|
||||
* Outer Angle AL_CONE_OUTER_ANGLE ALint or ALfloat
|
||||
* Cone Outer Gain AL_CONE_OUTER_GAIN ALint or ALfloat
|
||||
* Pitch AL_PITCH ALfloat
|
||||
* Looping AL_LOOPING ALint (AL_TRUE or AL_FALSE)
|
||||
* MS Offset AL_MSEC_OFFSET ALint or ALfloat
|
||||
* Byte Offset AL_BYTE_OFFSET ALint or ALfloat
|
||||
* Sample Offset AL_SAMPLE_OFFSET ALint or ALfloat
|
||||
* Attached Buffer AL_BUFFER ALint
|
||||
* State (Query only) AL_SOURCE_STATE ALint
|
||||
* Buffers Queued (Query only) AL_BUFFERS_QUEUED ALint
|
||||
* Buffers Processed (Query only) AL_BUFFERS_PROCESSED ALint
|
||||
*/
|
||||
|
||||
/* Create Source objects */
|
||||
ALAPI void ALAPIENTRY alGenSources( ALsizei n, ALuint* sources );
|
||||
|
||||
/* Delete Source objects */
|
||||
ALAPI void ALAPIENTRY alDeleteSources( ALsizei n, const ALuint* sources );
|
||||
|
||||
/* Verify a handle is a valid Source */
|
||||
ALAPI ALboolean ALAPIENTRY alIsSource( ALuint sid );
|
||||
|
||||
/*
|
||||
* Set Source parameters
|
||||
*/
|
||||
ALAPI void ALAPIENTRY alSourcef( ALuint sid, ALenum param, ALfloat value );
|
||||
|
||||
ALAPI void ALAPIENTRY alSource3f( ALuint sid, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3 );
|
||||
|
||||
ALAPI void ALAPIENTRY alSourcefv( ALuint sid, ALenum param, const ALfloat* values );
|
||||
|
||||
ALAPI void ALAPIENTRY alSourcei( ALuint sid, ALenum param, ALint value );
|
||||
|
||||
ALAPI void ALAPIENTRY alSource3i( ALuint sid, ALenum param, ALint value1, ALint value2, ALint value3 );
|
||||
|
||||
ALAPI void ALAPIENTRY alSourceiv( ALuint sid, ALenum param, const ALint* values );
|
||||
|
||||
/*
|
||||
* Get Source parameters
|
||||
*/
|
||||
ALAPI void ALAPIENTRY alGetSourcef( ALuint sid, ALenum param, ALfloat* value );
|
||||
|
||||
ALAPI void ALAPIENTRY alGetSource3f( ALuint sid, ALenum param, ALfloat* value1, ALfloat* value2, ALfloat* value3);
|
||||
|
||||
ALAPI void ALAPIENTRY alGetSourcefv( ALuint sid, ALenum param, ALfloat* values );
|
||||
|
||||
ALAPI void ALAPIENTRY alGetSourcei( ALuint sid, ALenum param, ALint* value );
|
||||
|
||||
ALAPI void ALAPIENTRY alGetSource3i( ALuint sid, ALenum param, ALint* value1, ALint* value2, ALint* value3);
|
||||
|
||||
ALAPI void ALAPIENTRY alGetSourceiv( ALuint sid, ALenum param, ALint* values );
|
||||
|
||||
|
||||
/*
|
||||
* Source vector based playback calls
|
||||
*/
|
||||
|
||||
/* Play, replay, or resume (if paused) a list of Sources */
|
||||
ALAPI void ALAPIENTRY alSourcePlayv( ALsizei ns, const ALuint *sids );
|
||||
|
||||
/* Stop a list of Sources */
|
||||
ALAPI void ALAPIENTRY alSourceStopv( ALsizei ns, const ALuint *sids );
|
||||
|
||||
/* Rewind a list of Sources */
|
||||
ALAPI void ALAPIENTRY alSourceRewindv( ALsizei ns, const ALuint *sids );
|
||||
|
||||
/* Pause a list of Sources */
|
||||
ALAPI void ALAPIENTRY alSourcePausev( ALsizei ns, const ALuint *sids );
|
||||
|
||||
/*
|
||||
* Source based playback calls
|
||||
*/
|
||||
|
||||
/* Play, replay, or resume a Source */
|
||||
ALAPI void ALAPIENTRY alSourcePlay( ALuint sid );
|
||||
|
||||
/* Stop a Source */
|
||||
ALAPI void ALAPIENTRY alSourceStop( ALuint sid );
|
||||
|
||||
/* Rewind a Source (set playback postiton to beginning) */
|
||||
ALAPI void ALAPIENTRY alSourceRewind( ALuint sid );
|
||||
|
||||
/* Pause a Source */
|
||||
ALAPI void ALAPIENTRY alSourcePause( ALuint sid );
|
||||
|
||||
/*
|
||||
* Source Queuing
|
||||
*/
|
||||
ALAPI void ALAPIENTRY alSourceQueueBuffers( ALuint sid, ALsizei numEntries, const ALuint *bids );
|
||||
|
||||
ALAPI void ALAPIENTRY alSourceUnqueueBuffers( ALuint sid, ALsizei numEntries, ALuint *bids );
|
||||
|
||||
|
||||
/**
|
||||
* BUFFER
|
||||
* Buffer objects are storage space for sample data.
|
||||
* Buffers are referred to by Sources. One Buffer can be used
|
||||
* by multiple Sources.
|
||||
*
|
||||
* Properties include: -
|
||||
*
|
||||
* Frequency (Query only) AL_FREQUENCY ALint
|
||||
* Size (Query only) AL_SIZE ALint
|
||||
* Bits (Query only) AL_BITS ALint
|
||||
* Channels (Query only) AL_CHANNELS ALint
|
||||
*/
|
||||
|
||||
/* Create Buffer objects */
|
||||
ALAPI void ALAPIENTRY alGenBuffers( ALsizei n, ALuint* buffers );
|
||||
|
||||
/* Delete Buffer objects */
|
||||
ALAPI void ALAPIENTRY alDeleteBuffers( ALsizei n, const ALuint* buffers );
|
||||
|
||||
/* Verify a handle is a valid Buffer */
|
||||
ALAPI ALboolean ALAPIENTRY alIsBuffer( ALuint bid );
|
||||
|
||||
/* Specify the data to be copied into a buffer */
|
||||
ALAPI void ALAPIENTRY alBufferData( ALuint bid, ALenum format, const ALvoid* data, ALsizei size, ALsizei freq );
|
||||
|
||||
/*
|
||||
* Set Buffer parameters
|
||||
*/
|
||||
ALAPI void ALAPIENTRY alBufferf( ALuint bid, ALenum param, ALfloat value );
|
||||
|
||||
ALAPI void ALAPIENTRY alBuffer3f( ALuint bid, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3 );
|
||||
|
||||
ALAPI void ALAPIENTRY alBufferfv( ALuint bid, ALenum param, const ALfloat* values );
|
||||
|
||||
ALAPI void ALAPIENTRY alBufferi( ALuint bid, ALenum param, ALint value );
|
||||
|
||||
ALAPI void ALAPIENTRY alBuffer3i( ALuint bid, ALenum param, ALint value1, ALint value2, ALint value3 );
|
||||
|
||||
ALAPI void ALAPIENTRY alBufferiv( ALuint bid, ALenum param, const ALint* values );
|
||||
|
||||
/*
|
||||
* Get Buffer parameters
|
||||
*/
|
||||
ALAPI void ALAPIENTRY alGetBufferf( ALuint bid, ALenum param, ALfloat* value );
|
||||
|
||||
ALAPI void ALAPIENTRY alGetBuffer3f( ALuint bid, ALenum param, ALfloat* value1, ALfloat* value2, ALfloat* value3);
|
||||
|
||||
ALAPI void ALAPIENTRY alGetBufferfv( ALuint bid, ALenum param, ALfloat* values );
|
||||
|
||||
ALAPI void ALAPIENTRY alGetBufferi( ALuint bid, ALenum param, ALint* value );
|
||||
|
||||
ALAPI void ALAPIENTRY alGetBuffer3i( ALuint bid, ALenum param, ALint* value1, ALint* value2, ALint* value3);
|
||||
|
||||
ALAPI void ALAPIENTRY alGetBufferiv( ALuint bid, ALenum param, ALint* values );
|
||||
|
||||
|
||||
/*
|
||||
* Global Parameters
|
||||
*/
|
||||
ALAPI void ALAPIENTRY alDopplerFactor( ALfloat value );
|
||||
|
||||
ALAPI void ALAPIENTRY alDopplerVelocity( ALfloat value );
|
||||
|
||||
ALAPI void ALAPIENTRY alSpeedOfSound( ALfloat value );
|
||||
|
||||
ALAPI void ALAPIENTRY alDistanceModel( ALenum distanceModel );
|
||||
|
||||
#else /* AL_NO_PROTOTYPES */
|
||||
|
||||
void (ALAPIENTRY *alEnable)( ALenum capability );
|
||||
void (ALAPIENTRY *alDisable)( ALenum capability );
|
||||
ALboolean (ALAPIENTRY *alIsEnabled)( ALenum capability );
|
||||
const ALchar* (ALAPIENTRY *alGetString)( ALenum param );
|
||||
void (ALAPIENTRY *alGetBooleanv)( ALenum param, ALboolean* data );
|
||||
void (ALAPIENTRY *alGetIntegerv)( ALenum param, ALint* data );
|
||||
void (ALAPIENTRY *alGetFloatv)( ALenum param, ALfloat* data );
|
||||
void (ALAPIENTRY *alGetDoublev)( ALenum param, ALdouble* data );
|
||||
ALboolean (ALAPIENTRY *alGetBoolean)( ALenum param );
|
||||
ALint (ALAPIENTRY *alGetInteger)( ALenum param );
|
||||
ALfloat (ALAPIENTRY *alGetFloat)( ALenum param );
|
||||
ALdouble (ALAPIENTRY *alGetDouble)( ALenum param );
|
||||
ALenum (ALAPIENTRY *alGetError)( ALvoid );
|
||||
ALboolean (ALAPIENTRY *alIsExtensionPresent)(const ALchar* extname );
|
||||
void* (ALAPIENTRY *alGetProcAddress)( const ALchar* fname );
|
||||
ALenum (ALAPIENTRY *alGetEnumValue)( const ALchar* ename );
|
||||
void (ALAPIENTRY *alListenerf)( ALenum param, ALfloat value );
|
||||
void (ALAPIENTRY *alListener3f)( ALenum param, ALfloat value1, ALfloat value2, ALfloat value3 );
|
||||
void (ALAPIENTRY *alListenerfv)( ALenum param, const ALfloat* values );
|
||||
void (ALAPIENTRY *alListeneri)( ALenum param, ALint value );
|
||||
void (ALAPIENTRY *alListener3i)( ALenum param, ALint value1, ALint value2, ALint value3 );
|
||||
void (ALAPIENTRY *alListeneriv)( ALenum param, const ALint* values );
|
||||
void (ALAPIENTRY *alGetListenerf)( ALenum param, ALfloat* value );
|
||||
void (ALAPIENTRY *alGetListener3f)( ALenum param, ALfloat *value1, ALfloat *value2, ALfloat *value3 );
|
||||
void (ALAPIENTRY *alGetListenerfv)( ALenum param, ALfloat* values );
|
||||
void (ALAPIENTRY *alGetListeneri)( ALenum param, ALint* value );
|
||||
void (ALAPIENTRY *alGetListener3i)( ALenum param, ALint *value1, ALint *value2, ALint *value3 );
|
||||
void (ALAPIENTRY *alGetListeneriv)( ALenum param, ALint* values );
|
||||
void (ALAPIENTRY *alGenSources)( ALsizei n, ALuint* sources );
|
||||
void (ALAPIENTRY *alDeleteSources)( ALsizei n, const ALuint* sources );
|
||||
ALboolean (ALAPIENTRY *alIsSource)( ALuint sid );
|
||||
void (ALAPIENTRY *alSourcef)( ALuint sid, ALenum param, ALfloat value);
|
||||
void (ALAPIENTRY *alSource3f)( ALuint sid, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3 );
|
||||
void (ALAPIENTRY *alSourcefv)( ALuint sid, ALenum param, const ALfloat* values );
|
||||
void (ALAPIENTRY *alSourcei)( ALuint sid, ALenum param, ALint value);
|
||||
void (ALAPIENTRY *alSource3i)( ALuint sid, ALenum param, ALint value1, ALint value2, ALint value3 );
|
||||
void (ALAPIENTRY *alSourceiv)( ALuint sid, ALenum param, const ALint* values );
|
||||
void (ALAPIENTRY *alGetSourcef)( ALuint sid, ALenum param, ALfloat* value );
|
||||
void (ALAPIENTRY *alGetSource3f)( ALuint sid, ALenum param, ALfloat* value1, ALfloat* value2, ALfloat* value3);
|
||||
void (ALAPIENTRY *alGetSourcefv)( ALuint sid, ALenum param, ALfloat* values );
|
||||
void (ALAPIENTRY *alGetSourcei)( ALuint sid, ALenum param, ALint* value );
|
||||
void (ALAPIENTRY *alGetSource3i)( ALuint sid, ALenum param, ALint* value1, ALint* value2, ALint* value3);
|
||||
void (ALAPIENTRY *alGetSourceiv)( ALuint sid, ALenum param, ALint* values );
|
||||
void (ALAPIENTRY *alSourcePlayv)( ALsizei ns, const ALuint *sids );
|
||||
void (ALAPIENTRY *alSourceStopv)( ALsizei ns, const ALuint *sids );
|
||||
void (ALAPIENTRY *alSourceRewindv)( ALsizei ns, const ALuint *sids );
|
||||
void (ALAPIENTRY *alSourcePausev)( ALsizei ns, const ALuint *sids );
|
||||
void (ALAPIENTRY *alSourcePlay)( ALuint sid );
|
||||
void (ALAPIENTRY *alSourceStop)( ALuint sid );
|
||||
void (ALAPIENTRY *alSourceRewind)( ALuint sid );
|
||||
void (ALAPIENTRY *alSourcePause)( ALuint sid );
|
||||
void (ALAPIENTRY *alSourceQueueBuffers)( ALuint sid, ALsizei numEntries, const ALuint *bids );
|
||||
void (ALAPIENTRY *alSourceUnqueueBuffers)( ALuint sid, ALsizei numEntries, ALuint *bids );
|
||||
void (ALAPIENTRY *alGenBuffers)( ALsizei n, ALuint* buffers );
|
||||
void (ALAPIENTRY *alDeleteBuffers)( ALsizei n, const ALuint* buffers );
|
||||
ALboolean (ALAPIENTRY *alIsBuffer)( ALuint bid );
|
||||
void (ALAPIENTRY *alBufferData)( ALuint bid, ALenum format, const ALvoid* data, ALsizei size, ALsizei freq );
|
||||
void (ALAPIENTRY *alBufferf)( ALuint bid, ALenum param, ALfloat value);
|
||||
void (ALAPIENTRY *alBuffer3f)( ALuint bid, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3 );
|
||||
void (ALAPIENTRY *alBufferfv)( ALuint bid, ALenum param, const ALfloat* values );
|
||||
void (ALAPIENTRY *alBufferi)( ALuint bid, ALenum param, ALint value);
|
||||
void (ALAPIENTRY *alBuffer3i)( ALuint bid, ALenum param, ALint value1, ALint value2, ALint value3 );
|
||||
void (ALAPIENTRY *alBufferiv)( ALuint bid, ALenum param, const ALint* values );
|
||||
void (ALAPIENTRY *alGetBufferf)( ALuint bid, ALenum param, ALfloat* value );
|
||||
void (ALAPIENTRY *alGetBuffer3f)( ALuint bid, ALenum param, ALfloat* value1, ALfloat* value2, ALfloat* value3);
|
||||
void (ALAPIENTRY *alGetBufferfv)( ALuint bid, ALenum param, ALfloat* values );
|
||||
void (ALAPIENTRY *alGetBufferi)( ALuint bid, ALenum param, ALint* value );
|
||||
void (ALAPIENTRY *alGetBuffer3i)( ALuint bid, ALenum param, ALint* value1, ALint* value2, ALint* value3);
|
||||
void (ALAPIENTRY *alGetBufferiv)( ALuint bid, ALenum param, ALint* values );
|
||||
void (ALAPIENTRY *alDopplerFactor)( ALfloat value );
|
||||
void (ALAPIENTRY *alDopplerVelocity)( ALfloat value );
|
||||
void (ALAPIENTRY *alSpeedOfSound)( ALfloat value );
|
||||
void (ALAPIENTRY *alDistanceModel)( ALenum distanceModel );
|
||||
|
||||
/* Type Definitions */
|
||||
|
||||
typedef void (ALAPIENTRY *LPALENABLE)( ALenum capability );
|
||||
typedef void (ALAPIENTRY *LPALDISABLE)( ALenum capability );
|
||||
typedef ALboolean (ALAPIENTRY *LPALISENABLED)( ALenum capability );
|
||||
typedef const ALchar* (ALAPIENTRY *LPALGETSTRING)( ALenum param );
|
||||
typedef void (ALAPIENTRY *LPALGETBOOLEANV)( ALenum param, ALboolean* data );
|
||||
typedef void (ALAPIENTRY *LPALGETINTEGERV)( ALenum param, ALint* data );
|
||||
typedef void (ALAPIENTRY *LPALGETFLOATV)( ALenum param, ALfloat* data );
|
||||
typedef void (ALAPIENTRY *LPALGETDOUBLEV)( ALenum param, ALdouble* data );
|
||||
typedef ALboolean (ALAPIENTRY *LPALGETBOOLEAN)( ALenum param );
|
||||
typedef ALint (ALAPIENTRY *LPALGETINTEGER)( ALenum param );
|
||||
typedef ALfloat (ALAPIENTRY *LPALGETFLOAT)( ALenum param );
|
||||
typedef ALdouble (ALAPIENTRY *LPALGETDOUBLE)( ALenum param );
|
||||
typedef ALenum (ALAPIENTRY *LPALGETERROR)( ALvoid );
|
||||
typedef ALboolean (ALAPIENTRY *LPALISEXTENSIONPRESENT)(const ALchar* extname );
|
||||
typedef void* (ALAPIENTRY *LPALGETPROCADDRESS)( const ALchar* fname );
|
||||
typedef ALenum (ALAPIENTRY *LPALGETENUMVALUE)( const ALchar* ename );
|
||||
typedef void (ALAPIENTRY *LPALLISTENERF)( ALenum param, ALfloat value );
|
||||
typedef void (ALAPIENTRY *LPALLISTENER3F)( ALenum param, ALfloat value1, ALfloat value2, ALfloat value3 );
|
||||
typedef void (ALAPIENTRY *LPALLISTENERFV)( ALenum param, const ALfloat* values );
|
||||
typedef void (ALAPIENTRY *LPALLISTENERI)( ALenum param, ALint value );
|
||||
typedef void (ALAPIENTRY *LPALLISTENER3I)( ALenum param, ALint value1, ALint value2, ALint value3 );
|
||||
typedef void (ALAPIENTRY *LPALLISTENERIV)( ALenum param, const ALint* values );
|
||||
typedef void (ALAPIENTRY *LPALGETLISTENERF)( ALenum param, ALfloat* value );
|
||||
typedef void (ALAPIENTRY *LPALGETLISTENER3F)( ALenum param, ALfloat *value1, ALfloat *value2, ALfloat *value3 );
|
||||
typedef void (ALAPIENTRY *LPALGETLISTENERFV)( ALenum param, ALfloat* values );
|
||||
typedef void (ALAPIENTRY *LPALGETLISTENERI)( ALenum param, ALint* value );
|
||||
typedef void (ALAPIENTRY *LPALGETLISTENER3I)( ALenum param, ALint *value1, ALint *value2, ALint *value3 );
|
||||
typedef void (ALAPIENTRY *LPALGETLISTENERIV)( ALenum param, ALint* values );
|
||||
typedef void (ALAPIENTRY *LPALGENSOURCES)( ALsizei n, ALuint* sources );
|
||||
typedef void (ALAPIENTRY *LPALDELETESOURCES)( ALsizei n, const ALuint* sources );
|
||||
typedef ALboolean (ALAPIENTRY *LPALISSOURCE)( ALuint sid );
|
||||
typedef void (ALAPIENTRY *LPALSOURCEF)( ALuint sid, ALenum param, ALfloat value);
|
||||
typedef void (ALAPIENTRY *LPALSOURCE3F)( ALuint sid, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3 );
|
||||
typedef void (ALAPIENTRY *LPALSOURCEFV)( ALuint sid, ALenum param, const ALfloat* values );
|
||||
typedef void (ALAPIENTRY *LPALSOURCEI)( ALuint sid, ALenum param, ALint value);
|
||||
typedef void (ALAPIENTRY *LPALSOURCE3I)( ALuint sid, ALenum param, ALint value1, ALint value2, ALint value3 );
|
||||
typedef void (ALAPIENTRY *LPALSOURCEIV)( ALuint sid, ALenum param, const ALint* values );
|
||||
typedef void (ALAPIENTRY *LPALGETSOURCEF)( ALuint sid, ALenum param, ALfloat* value );
|
||||
typedef void (ALAPIENTRY *LPALGETSOURCE3F)( ALuint sid, ALenum param, ALfloat* value1, ALfloat* value2, ALfloat* value3);
|
||||
typedef void (ALAPIENTRY *LPALGETSOURCEFV)( ALuint sid, ALenum param, ALfloat* values );
|
||||
typedef void (ALAPIENTRY *LPALGETSOURCEI)( ALuint sid, ALenum param, ALint* value );
|
||||
typedef void (ALAPIENTRY *LPALGETSOURCE3I)( ALuint sid, ALenum param, ALint* value1, ALint* value2, ALint* value3);
|
||||
typedef void (ALAPIENTRY *LPALGETSOURCEIV)( ALuint sid, ALenum param, ALint* values );
|
||||
typedef void (ALAPIENTRY *LPALSOURCEPLAYV)( ALsizei ns, const ALuint *sids );
|
||||
typedef void (ALAPIENTRY *LPALSOURCESTOPV)( ALsizei ns, const ALuint *sids );
|
||||
typedef void (ALAPIENTRY *LPALSOURCEREWINDV)( ALsizei ns, const ALuint *sids );
|
||||
typedef void (ALAPIENTRY *LPALSOURCEPAUSEV)( ALsizei ns, const ALuint *sids );
|
||||
typedef void (ALAPIENTRY *LPALSOURCEPLAY)( ALuint sid );
|
||||
typedef void (ALAPIENTRY *LPALSOURCESTOP)( ALuint sid );
|
||||
typedef void (ALAPIENTRY *LPALSOURCEREWIND)( ALuint sid );
|
||||
typedef void (ALAPIENTRY *LPALSOURCEPAUSE)( ALuint sid );
|
||||
typedef void (ALAPIENTRY *LPALSOURCEQUEUEBUFFERS)(ALuint sid, ALsizei numEntries, const ALuint *bids );
|
||||
typedef void (ALAPIENTRY *LPALSOURCEUNQUEUEBUFFERS)(ALuint sid, ALsizei numEntries, ALuint *bids );
|
||||
typedef void (ALAPIENTRY *LPALGENBUFFERS)( ALsizei n, ALuint* buffers );
|
||||
typedef void (ALAPIENTRY *LPALDELETEBUFFERS)( ALsizei n, const ALuint* buffers );
|
||||
typedef ALboolean (ALAPIENTRY *LPALISBUFFER)( ALuint bid );
|
||||
typedef void (ALAPIENTRY *LPALBUFFERDATA)( ALuint bid, ALenum format, const ALvoid* data, ALsizei size, ALsizei freq );
|
||||
typedef void (ALAPIENTRY *LPALBUFFERF)( ALuint bid, ALenum param, ALfloat value);
|
||||
typedef void (ALAPIENTRY *LPALBUFFER3F)( ALuint bid, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3 );
|
||||
typedef void (ALAPIENTRY *LPALBUFFERFV)( ALuint bid, ALenum param, const ALfloat* values );
|
||||
typedef void (ALAPIENTRY *LPALBUFFERI)( ALuint bid, ALenum param, ALint value);
|
||||
typedef void (ALAPIENTRY *LPALBUFFER3I)( ALuint bid, ALenum param, ALint value1, ALint value2, ALint value3 );
|
||||
typedef void (ALAPIENTRY *LPALBUFFERIV)( ALuint bid, ALenum param, const ALint* values );
|
||||
typedef void (ALAPIENTRY *LPALGETBUFFERF)( ALuint bid, ALenum param, ALfloat* value );
|
||||
typedef void (ALAPIENTRY *LPALGETBUFFER3F)( ALuint bid, ALenum param, ALfloat* value1, ALfloat* value2, ALfloat* value3);
|
||||
typedef void (ALAPIENTRY *LPALGETBUFFERFV)( ALuint bid, ALenum param, ALfloat* values );
|
||||
typedef void (ALAPIENTRY *LPALGETBUFFERI)( ALuint bid, ALenum param, ALint* value );
|
||||
typedef void (ALAPIENTRY *LPALGETBUFFER3I)( ALuint bid, ALenum param, ALint* value1, ALint* value2, ALint* value3);
|
||||
typedef void (ALAPIENTRY *LPALGETBUFFERIV)( ALuint bid, ALenum param, ALint* values );
|
||||
typedef void (ALAPIENTRY *LPALDOPPLERFACTOR)( ALfloat value );
|
||||
typedef void (ALAPIENTRY *LPALDOPPLERVELOCITY)( ALfloat value );
|
||||
typedef void (ALAPIENTRY *LPALSPEEDOFSOUND)( ALfloat value );
|
||||
typedef void (ALAPIENTRY *LPALDISTANCEMODEL)( ALenum distanceModel );
|
||||
|
||||
#endif /* AL_NO_PROTOTYPES */
|
||||
|
||||
#ifdef TARGET_OS_MAC
|
||||
#if TARGET_OS_MAC
|
||||
#pragma export off
|
||||
#endif /* TARGET_OS_MAC */
|
||||
#endif /* TARGET_OS_MAC */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* __al_h_ */
|
||||
-166
@@ -1,166 +0,0 @@
|
||||
#ifndef ALC_CONTEXT_H_
|
||||
#define ALC_CONTEXT_H_
|
||||
|
||||
#include "altypes.h"
|
||||
#include "alctypes.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define ALC_VERSION_0_1 1
|
||||
|
||||
#ifdef _WIN32
|
||||
typedef struct ALCdevice_struct ALCdevice;
|
||||
typedef struct ALCcontext_struct ALCcontext;
|
||||
#ifndef _XBOX
|
||||
#ifdef _OPENAL32LIB
|
||||
#define ALCAPI __declspec(dllexport)
|
||||
#else
|
||||
#define ALCAPI __declspec(dllimport)
|
||||
#endif
|
||||
#define ALCAPIENTRY __cdecl
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef TARGET_OS_MAC
|
||||
#if TARGET_OS_MAC
|
||||
#pragma export on
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef ALCAPI
|
||||
#define ALCAPI
|
||||
#endif
|
||||
|
||||
#ifndef ALCAPIENTRY
|
||||
#define ALCAPIENTRY
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef ALC_NO_PROTOTYPES
|
||||
|
||||
/*
|
||||
* Context Management
|
||||
*/
|
||||
ALCAPI ALCcontext * ALCAPIENTRY alcCreateContext( ALCdevice *device, const ALCint* attrlist );
|
||||
|
||||
ALCAPI ALCboolean ALCAPIENTRY alcMakeContextCurrent( ALCcontext *context );
|
||||
|
||||
ALCAPI void ALCAPIENTRY alcProcessContext( ALCcontext *context );
|
||||
|
||||
ALCAPI void ALCAPIENTRY alcSuspendContext( ALCcontext *context );
|
||||
|
||||
ALCAPI void ALCAPIENTRY alcDestroyContext( ALCcontext *context );
|
||||
|
||||
ALCAPI ALCcontext * ALCAPIENTRY alcGetCurrentContext( ALCvoid );
|
||||
|
||||
ALCAPI ALCdevice* ALCAPIENTRY alcGetContextsDevice( ALCcontext *context );
|
||||
|
||||
|
||||
/*
|
||||
* Device Management
|
||||
*/
|
||||
ALCAPI ALCdevice * ALCAPIENTRY alcOpenDevice( const ALchar *devicename );
|
||||
|
||||
ALCAPI ALCboolean ALCAPIENTRY alcCloseDevice( ALCdevice *device );
|
||||
|
||||
|
||||
/*
|
||||
* Error support.
|
||||
* Obtain the most recent Context error
|
||||
*/
|
||||
ALCAPI ALCenum ALCAPIENTRY alcGetError( ALCdevice *device );
|
||||
|
||||
|
||||
/*
|
||||
* Extension support.
|
||||
* Query for the presence of an extension, and obtain any appropriate
|
||||
* function pointers and enum values.
|
||||
*/
|
||||
ALCAPI ALCboolean ALCAPIENTRY alcIsExtensionPresent( ALCdevice *device, const ALCchar *extname );
|
||||
|
||||
ALCAPI void * ALCAPIENTRY alcGetProcAddress( ALCdevice *device, const ALCchar *funcname );
|
||||
|
||||
ALCAPI ALCenum ALCAPIENTRY alcGetEnumValue( ALCdevice *device, const ALCchar *enumname );
|
||||
|
||||
|
||||
/*
|
||||
* Query functions
|
||||
*/
|
||||
ALCAPI const ALCchar * ALCAPIENTRY alcGetString( ALCdevice *device, ALCenum param );
|
||||
|
||||
ALCAPI void ALCAPIENTRY alcGetIntegerv( ALCdevice *device, ALCenum param, ALCsizei size, ALCint *data );
|
||||
|
||||
|
||||
/*
|
||||
* Capture functions
|
||||
*/
|
||||
ALCAPI ALCdevice* ALCAPIENTRY alcCaptureOpenDevice( const ALCchar *devicename, ALCuint frequency, ALCenum format, ALCsizei buffersize );
|
||||
|
||||
ALCAPI ALCboolean ALCAPIENTRY alcCaptureCloseDevice( ALCdevice *device );
|
||||
|
||||
ALCAPI void ALCAPIENTRY alcCaptureStart( ALCdevice *device );
|
||||
|
||||
ALCAPI void ALCAPIENTRY alcCaptureStop( ALCdevice *device );
|
||||
|
||||
ALCAPI void ALCAPIENTRY alcCaptureSamples( ALCdevice *device, ALCvoid *buffer, ALCsizei samples );
|
||||
|
||||
#else /* ALC_NO_PROTOTYPES */
|
||||
|
||||
ALCAPI ALCcontext * (ALCAPIENTRY *alcCreateContext)( ALCdevice *device, const ALCint* attrlist );
|
||||
ALCAPI ALCboolean (ALCAPIENTRY *alcMakeContextCurrent)( ALCcontext *context );
|
||||
ALCAPI void (ALCAPIENTRY *alcProcessContext)( ALCcontext *context );
|
||||
ALCAPI void (ALCAPIENTRY *alcSuspendContext)( ALCcontext *context );
|
||||
ALCAPI void (ALCAPIENTRY *alcDestroyContext)( ALCcontext *context );
|
||||
ALCAPI ALCcontext * (ALCAPIENTRY *alcGetCurrentContext)( ALCvoid );
|
||||
ALCAPI ALCdevice * (ALCAPIENTRY *alcGetContextsDevice)( ALCcontext *context );
|
||||
ALCAPI ALCdevice * (ALCAPIENTRY *alcOpenDevice)( const ALCchar *devicename );
|
||||
ALCAPI ALCboolean (ALCAPIENTRY *alcCloseDevice)( ALCdevice *device );
|
||||
ALCAPI ALCenum (ALCAPIENTRY *alcGetError)( ALCdevice *device );
|
||||
ALCAPI ALCboolean (ALCAPIENTRY *alcIsExtensionPresent)( ALCdevice *device, const ALCchar *extname );
|
||||
ALCAPI void * (ALCAPIENTRY *alcGetProcAddress)( ALCdevice *device, const ALCchar *funcname );
|
||||
ALCAPI ALCenum (ALCAPIENTRY *alcGetEnumValue)( ALCdevice *device, const ALCchar *enumname );
|
||||
ALCAPI const ALCchar* (ALCAPIENTRY *alcGetString)( ALCdevice *device, ALCenum param );
|
||||
ALCAPI void (ALCAPIENTRY *alcGetIntegerv)( ALCdevice *device, ALCenum param, ALCsizei size, ALCint *dest );
|
||||
ALCAPI ALCdevice * (ALCAPIENTRY *alcCaptureOpenDevice)( const ALCchar *devicename, ALCuint frequency, ALCenum format, ALCsizei buffersize );
|
||||
ALCAPI ALCboolean (ALCAPIENTRY *alcCaptureCloseDevice)( ALCdevice *device );
|
||||
ALCAPI void (ALCAPIENTRY *alcCaptureStart)( ALCdevice *device );
|
||||
ALCAPI void (ALCAPIENTRY *alcCaptureStop)( ALCdevice *device );
|
||||
ALCAPI void (ALCAPIENTRY *alcCaptureSamples)( ALCdevice *device, ALCvoid *buffer, ALCsizei samples );
|
||||
|
||||
/* Type definitions */
|
||||
typedef ALCcontext * (ALCAPIENTRY *LPALCCREATECONTEXT) (ALCdevice *device, const ALCint *attrlist);
|
||||
typedef ALCboolean (ALCAPIENTRY *LPALCMAKECONTEXTCURRENT)( ALCcontext *context );
|
||||
typedef void (ALCAPIENTRY *LPALCPROCESSCONTEXT)( ALCcontext *context );
|
||||
typedef void (ALCAPIENTRY *LPALCSUSPENDCONTEXT)( ALCcontext *context );
|
||||
typedef void (ALCAPIENTRY *LPALCDESTROYCONTEXT)( ALCcontext *context );
|
||||
typedef ALCcontext * (ALCAPIENTRY *LPALCGETCURRENTCONTEXT)( ALCvoid );
|
||||
typedef ALCdevice * (ALCAPIENTRY *LPALCGETCONTEXTSDEVICE)( ALCcontext *context );
|
||||
typedef ALCdevice * (ALCAPIENTRY *LPALCOPENDEVICE)( const ALCchar *devicename );
|
||||
typedef ALCboolean (ALCAPIENTRY *LPALCCLOSEDEVICE)( ALCdevice *device );
|
||||
typedef ALCenum (ALCAPIENTRY *LPALCGETERROR)( ALCdevice *device );
|
||||
typedef ALCboolean (ALCAPIENTRY *LPALCISEXTENSIONPRESENT)( ALCdevice *device, const ALCchar *extname );
|
||||
typedef void * (ALCAPIENTRY *LPALCGETPROCADDRESS)(ALCdevice *device, const ALCchar *funcname );
|
||||
typedef ALCenum (ALCAPIENTRY *LPALCGETENUMVALUE)(ALCdevice *device, const ALCchar *enumname );
|
||||
typedef const ALCchar* (ALCAPIENTRY *LPALCGETSTRING)( ALCdevice *device, ALCenum param );
|
||||
typedef void (ALCAPIENTRY *LPALCGETINTEGERV)( ALCdevice *device, ALCenum param, ALCsizei size, ALCint *dest );
|
||||
typedef ALCdevice * (ALCAPIENTRY *LPALCCAPTUREOPENDEVICE)( const ALCchar *devicename, ALCuint frequency, ALCenum format, ALCsizei buffersize );
|
||||
typedef ALCboolean (ALCAPIENTRY *LPALCCAPTURECLOSEDEVICE)( ALCdevice *device );
|
||||
typedef void (ALCAPIENTRY *LPALCCAPTURESTART)( ALCdevice *device );
|
||||
typedef void (ALCAPIENTRY *LPALCCAPTURESTOP)( ALCdevice *device );
|
||||
typedef void (ALCAPIENTRY *LPALCCAPTURESAMPLES)( ALCdevice *device, ALCvoid *buffer, ALCsizei samples );
|
||||
|
||||
#endif /* ALC_NO_PROTOTYPES */
|
||||
|
||||
#ifdef TARGET_OS_MAC
|
||||
#if TARGET_OS_MAC
|
||||
#pragma export off
|
||||
#endif /* TARGET_OS_MAC */
|
||||
#endif /* TARGET_OS_MAC */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* ALC_CONTEXT_H_ */
|
||||
@@ -1,142 +0,0 @@
|
||||
#ifndef _ALCTYPES_H_
|
||||
#define _ALCTYPES_H_
|
||||
|
||||
#if !defined(_WIN32)
|
||||
struct _AL_device;
|
||||
typedef struct _AL_device ALCdevice;
|
||||
|
||||
typedef void ALCcontext;
|
||||
#endif /* _WIN32 */
|
||||
|
||||
typedef int ALCenum;
|
||||
|
||||
/** ALC boolean type. */
|
||||
typedef char ALCboolean;
|
||||
|
||||
/** ALC 8bit signed byte. */
|
||||
typedef char ALCbyte;
|
||||
|
||||
/** ALC 8bit unsigned byte. */
|
||||
typedef unsigned char ALCubyte;
|
||||
|
||||
/** OpenAL 8bit char */
|
||||
typedef char ALCchar;
|
||||
|
||||
/** ALC 16bit signed short integer type. */
|
||||
typedef short ALCshort;
|
||||
|
||||
/** ALC 16bit unsigned short integer type. */
|
||||
typedef unsigned short ALCushort;
|
||||
|
||||
/** ALC 32bit unsigned integer type. */
|
||||
typedef unsigned ALCuint;
|
||||
|
||||
/** ALC 32bit signed integer type. */
|
||||
typedef int ALCint;
|
||||
|
||||
/** ALC 32bit floating point type. */
|
||||
typedef float ALCfloat;
|
||||
|
||||
/** ALC 64bit double point type. */
|
||||
typedef double ALCdouble;
|
||||
|
||||
/** ALC 32bit type. */
|
||||
typedef int ALCsizei;
|
||||
|
||||
/** ALC void type */
|
||||
typedef void ALCvoid;
|
||||
|
||||
/* Enumerant values begin at column 50. No tabs. */
|
||||
|
||||
/* bad value */
|
||||
#define ALC_INVALID 0
|
||||
|
||||
/* Boolean False. */
|
||||
#define ALC_FALSE 0
|
||||
|
||||
/* Boolean True. */
|
||||
#define ALC_TRUE 1
|
||||
|
||||
/**
|
||||
* followed by <int> Hz
|
||||
*/
|
||||
#define ALC_FREQUENCY 0x1007
|
||||
|
||||
/**
|
||||
* followed by <int> Hz
|
||||
*/
|
||||
#define ALC_REFRESH 0x1008
|
||||
|
||||
/**
|
||||
* followed by AL_TRUE, AL_FALSE
|
||||
*/
|
||||
#define ALC_SYNC 0x1009
|
||||
|
||||
/**
|
||||
* followed by <int> Num of requested Mono (3D) Sources
|
||||
*/
|
||||
#define ALC_MONO_SOURCES 0x1010
|
||||
|
||||
/**
|
||||
* followed by <int> Num of requested Stereo Sources
|
||||
*/
|
||||
#define ALC_STEREO_SOURCES 0x1011
|
||||
|
||||
/**
|
||||
* errors
|
||||
*/
|
||||
|
||||
/**
|
||||
* No error
|
||||
*/
|
||||
#define ALC_NO_ERROR ALC_FALSE
|
||||
|
||||
/**
|
||||
* No device
|
||||
*/
|
||||
#define ALC_INVALID_DEVICE 0xA001
|
||||
|
||||
/**
|
||||
* invalid context ID
|
||||
*/
|
||||
#define ALC_INVALID_CONTEXT 0xA002
|
||||
|
||||
/**
|
||||
* bad enum
|
||||
*/
|
||||
#define ALC_INVALID_ENUM 0xA003
|
||||
|
||||
/**
|
||||
* bad value
|
||||
*/
|
||||
#define ALC_INVALID_VALUE 0xA004
|
||||
|
||||
/**
|
||||
* Out of memory.
|
||||
*/
|
||||
#define ALC_OUT_OF_MEMORY 0xA005
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* The Specifier string for default device
|
||||
*/
|
||||
#define ALC_DEFAULT_DEVICE_SPECIFIER 0x1004
|
||||
#define ALC_DEVICE_SPECIFIER 0x1005
|
||||
#define ALC_EXTENSIONS 0x1006
|
||||
|
||||
#define ALC_MAJOR_VERSION 0x1000
|
||||
#define ALC_MINOR_VERSION 0x1001
|
||||
|
||||
#define ALC_ATTRIBUTES_SIZE 0x1002
|
||||
#define ALC_ALL_ATTRIBUTES 0x1003
|
||||
|
||||
/**
|
||||
* Capture extension
|
||||
*/
|
||||
#define ALC_CAPTURE_DEVICE_SPECIFIER 0x310
|
||||
#define ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER 0x311
|
||||
#define ALC_CAPTURE_SAMPLES 0x312
|
||||
|
||||
|
||||
#endif /* _ALCTYPES_H */
|
||||
@@ -1,352 +0,0 @@
|
||||
#ifndef _AL_TYPES_H_
|
||||
#define _AL_TYPES_H_
|
||||
|
||||
/* define platform type */
|
||||
#if !defined(MACINTOSH_AL) && !defined(LINUX_AL) && !defined(WINDOWS_AL)
|
||||
#ifdef __APPLE__
|
||||
#define MACINTOSH_AL
|
||||
#else
|
||||
#ifdef _WIN32
|
||||
#define WINDOWS_AL
|
||||
#else
|
||||
#define LINUX_AL
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/** OpenAL bool type. */
|
||||
typedef char ALboolean;
|
||||
|
||||
/** OpenAL 8bit signed byte. */
|
||||
typedef char ALbyte;
|
||||
|
||||
/** OpenAL 8bit unsigned byte. */
|
||||
typedef unsigned char ALubyte;
|
||||
|
||||
/** OpenAL 8bit char */
|
||||
typedef char ALchar;
|
||||
|
||||
/** OpenAL 16bit signed short integer type. */
|
||||
typedef short ALshort;
|
||||
|
||||
/** OpenAL 16bit unsigned short integer type. */
|
||||
typedef unsigned short ALushort;
|
||||
|
||||
/** OpenAL 32bit unsigned integer type. */
|
||||
typedef unsigned int ALuint;
|
||||
|
||||
/** OpenAL 32bit signed integer type. */
|
||||
typedef int ALint;
|
||||
|
||||
/** OpenAL 32bit floating point type. */
|
||||
typedef float ALfloat;
|
||||
|
||||
/** OpenAL 64bit double point type. */
|
||||
typedef double ALdouble;
|
||||
|
||||
/** OpenAL 32bit type. */
|
||||
typedef int ALsizei;
|
||||
|
||||
/** OpenAL void type (for params, not returns). */
|
||||
typedef void ALvoid;
|
||||
|
||||
/** OpenAL enumerations. */
|
||||
typedef int ALenum;
|
||||
|
||||
/** OpenAL bitfields. */
|
||||
typedef unsigned int ALbitfield;
|
||||
|
||||
/** OpenAL clamped float. */
|
||||
typedef ALfloat ALclampf;
|
||||
|
||||
/** Openal clamped double. */
|
||||
typedef ALdouble ALclampd;
|
||||
|
||||
/* Enumerant values begin at column 50. No tabs. */
|
||||
|
||||
/* bad value */
|
||||
#define AL_INVALID -1
|
||||
|
||||
#define AL_NONE 0
|
||||
|
||||
/* Boolean False. */
|
||||
#define AL_FALSE 0
|
||||
|
||||
/** Boolean True. */
|
||||
#define AL_TRUE 1
|
||||
|
||||
/** Indicate Source has relative coordinates. */
|
||||
#define AL_SOURCE_RELATIVE 0x202
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Directional source, inner cone angle, in degrees.
|
||||
* Range: [0-360]
|
||||
* Default: 360
|
||||
*/
|
||||
#define AL_CONE_INNER_ANGLE 0x1001
|
||||
|
||||
/**
|
||||
* Directional source, outer cone angle, in degrees.
|
||||
* Range: [0-360]
|
||||
* Default: 360
|
||||
*/
|
||||
#define AL_CONE_OUTER_ANGLE 0x1002
|
||||
|
||||
/**
|
||||
* Specify the pitch to be applied, either at source,
|
||||
* or on mixer results, at listener.
|
||||
* Range: [0.5-2.0]
|
||||
* Default: 1.0
|
||||
*/
|
||||
#define AL_PITCH 0x1003
|
||||
|
||||
/**
|
||||
* Specify the current location in three dimensional space.
|
||||
* OpenAL, like OpenGL, uses a right handed coordinate system,
|
||||
* where in a frontal default view X (thumb) points right,
|
||||
* Y points up (index finger), and Z points towards the
|
||||
* viewer/camera (middle finger).
|
||||
* To switch from a left handed coordinate system, flip the
|
||||
* sign on the Z coordinate.
|
||||
* Listener position is always in the world coordinate system.
|
||||
*/
|
||||
#define AL_POSITION 0x1004
|
||||
|
||||
/** Specify the current direction. */
|
||||
#define AL_DIRECTION 0x1005
|
||||
|
||||
/** Specify the current velocity in three dimensional space. */
|
||||
#define AL_VELOCITY 0x1006
|
||||
|
||||
/**
|
||||
* Indicate whether source is looping.
|
||||
* Type: ALboolean?
|
||||
* Range: [AL_TRUE, AL_FALSE]
|
||||
* Default: FALSE.
|
||||
*/
|
||||
#define AL_LOOPING 0x1007
|
||||
|
||||
/**
|
||||
* Indicate the buffer to provide sound samples.
|
||||
* Type: ALuint.
|
||||
* Range: any valid Buffer id.
|
||||
*/
|
||||
#define AL_BUFFER 0x1009
|
||||
|
||||
/**
|
||||
* Indicate the gain (volume amplification) applied.
|
||||
* Type: ALfloat.
|
||||
* Range: ]0.0- ]
|
||||
* A value of 1.0 means un-attenuated/unchanged.
|
||||
* Each division by 2 equals an attenuation of -6dB.
|
||||
* Each multiplicaton with 2 equals an amplification of +6dB.
|
||||
* A value of 0.0 is meaningless with respect to a logarithmic
|
||||
* scale; it is interpreted as zero volume - the channel
|
||||
* is effectively disabled.
|
||||
*/
|
||||
#define AL_GAIN 0x100A
|
||||
|
||||
/*
|
||||
* Indicate minimum source attenuation
|
||||
* Type: ALfloat
|
||||
* Range: [0.0 - 1.0]
|
||||
*
|
||||
* Logarthmic
|
||||
*/
|
||||
#define AL_MIN_GAIN 0x100D
|
||||
|
||||
/**
|
||||
* Indicate maximum source attenuation
|
||||
* Type: ALfloat
|
||||
* Range: [0.0 - 1.0]
|
||||
*
|
||||
* Logarthmic
|
||||
*/
|
||||
#define AL_MAX_GAIN 0x100E
|
||||
|
||||
/**
|
||||
* Indicate listener orientation.
|
||||
*
|
||||
* at/up
|
||||
*/
|
||||
#define AL_ORIENTATION 0x100F
|
||||
|
||||
/**
|
||||
* Specify the channel mask. (Creative)
|
||||
* Type: ALuint
|
||||
* Range: [0 - 255]
|
||||
*/
|
||||
#define AL_CHANNEL_MASK 0x3000
|
||||
|
||||
|
||||
/**
|
||||
* Source state information.
|
||||
*/
|
||||
#define AL_SOURCE_STATE 0x1010
|
||||
#define AL_INITIAL 0x1011
|
||||
#define AL_PLAYING 0x1012
|
||||
#define AL_PAUSED 0x1013
|
||||
#define AL_STOPPED 0x1014
|
||||
|
||||
/**
|
||||
* Buffer Queue params
|
||||
*/
|
||||
#define AL_BUFFERS_QUEUED 0x1015
|
||||
#define AL_BUFFERS_PROCESSED 0x1016
|
||||
|
||||
/**
|
||||
* Source buffer position information
|
||||
*/
|
||||
#define AL_SEC_OFFSET 0x1024
|
||||
#define AL_SAMPLE_OFFSET 0x1025
|
||||
#define AL_BYTE_OFFSET 0x1026
|
||||
|
||||
/*
|
||||
* Source type (Static, Streaming or undetermined)
|
||||
* Source is Static if a Buffer has been attached using AL_BUFFER
|
||||
* Source is Streaming if one or more Buffers have been attached using alSourceQueueBuffers
|
||||
* Source is undetermined when it has the NULL buffer attached
|
||||
*/
|
||||
#define AL_SOURCE_TYPE 0x1027
|
||||
#define AL_STATIC 0x1028
|
||||
#define AL_STREAMING 0x1029
|
||||
#define AL_UNDETERMINED 0x1030
|
||||
|
||||
/** Sound samples: format specifier. */
|
||||
#define AL_FORMAT_MONO8 0x1100
|
||||
#define AL_FORMAT_MONO16 0x1101
|
||||
#define AL_FORMAT_STEREO8 0x1102
|
||||
#define AL_FORMAT_STEREO16 0x1103
|
||||
|
||||
/**
|
||||
* source specific reference distance
|
||||
* Type: ALfloat
|
||||
* Range: 0.0 - +inf
|
||||
*
|
||||
* At 0.0, no distance attenuation occurs. Default is
|
||||
* 1.0.
|
||||
*/
|
||||
#define AL_REFERENCE_DISTANCE 0x1020
|
||||
|
||||
/**
|
||||
* source specific rolloff factor
|
||||
* Type: ALfloat
|
||||
* Range: 0.0 - +inf
|
||||
*
|
||||
*/
|
||||
#define AL_ROLLOFF_FACTOR 0x1021
|
||||
|
||||
/**
|
||||
* Directional source, outer cone gain.
|
||||
*
|
||||
* Default: 0.0
|
||||
* Range: [0.0 - 1.0]
|
||||
* Logarithmic
|
||||
*/
|
||||
#define AL_CONE_OUTER_GAIN 0x1022
|
||||
|
||||
/**
|
||||
* Indicate distance above which sources are not
|
||||
* attenuated using the inverse clamped distance model.
|
||||
*
|
||||
* Default: +inf
|
||||
* Type: ALfloat
|
||||
* Range: 0.0 - +inf
|
||||
*/
|
||||
#define AL_MAX_DISTANCE 0x1023
|
||||
|
||||
/**
|
||||
* Sound samples: frequency, in units of Hertz [Hz].
|
||||
* This is the number of samples per second. Half of the
|
||||
* sample frequency marks the maximum significant
|
||||
* frequency component.
|
||||
*/
|
||||
#define AL_FREQUENCY 0x2001
|
||||
#define AL_BITS 0x2002
|
||||
#define AL_CHANNELS 0x2003
|
||||
#define AL_SIZE 0x2004
|
||||
#define AL_DATA 0x2005
|
||||
|
||||
/**
|
||||
* Buffer state.
|
||||
*
|
||||
* Not supported for public use (yet).
|
||||
*/
|
||||
#define AL_UNUSED 0x2010
|
||||
#define AL_PENDING 0x2011
|
||||
#define AL_PROCESSED 0x2012
|
||||
|
||||
|
||||
/** Errors: No Error. */
|
||||
#define AL_NO_ERROR AL_FALSE
|
||||
|
||||
/**
|
||||
* Invalid Name paramater passed to AL call.
|
||||
*/
|
||||
#define AL_INVALID_NAME 0xA001
|
||||
|
||||
/**
|
||||
* Invalid parameter passed to AL call.
|
||||
*/
|
||||
#define AL_ILLEGAL_ENUM 0xA002
|
||||
#define AL_INVALID_ENUM 0xA002
|
||||
|
||||
/**
|
||||
* Invalid enum parameter value.
|
||||
*/
|
||||
#define AL_INVALID_VALUE 0xA003
|
||||
|
||||
/**
|
||||
* Illegal call.
|
||||
*/
|
||||
#define AL_ILLEGAL_COMMAND 0xA004
|
||||
#define AL_INVALID_OPERATION 0xA004
|
||||
|
||||
|
||||
/**
|
||||
* No mojo.
|
||||
*/
|
||||
#define AL_OUT_OF_MEMORY 0xA005
|
||||
|
||||
|
||||
/** Context strings: Vendor Name. */
|
||||
#define AL_VENDOR 0xB001
|
||||
#define AL_VERSION 0xB002
|
||||
#define AL_RENDERER 0xB003
|
||||
#define AL_EXTENSIONS 0xB004
|
||||
|
||||
/** Global tweakage. */
|
||||
|
||||
/**
|
||||
* Doppler scale. Default 1.0
|
||||
*/
|
||||
#define AL_DOPPLER_FACTOR 0xC000
|
||||
|
||||
/**
|
||||
* Tweaks speed of propagation.
|
||||
*/
|
||||
#define AL_DOPPLER_VELOCITY 0xC001
|
||||
|
||||
/**
|
||||
* Speed of Sound in units per second
|
||||
*/
|
||||
#define AL_SPEED_OF_SOUND 0xC003
|
||||
|
||||
/**
|
||||
* Distance models
|
||||
*
|
||||
* used in conjunction with DistanceModel
|
||||
*
|
||||
* implicit: NONE, which disances distance attenuation.
|
||||
*/
|
||||
#define AL_DISTANCE_MODEL 0xD000
|
||||
#define AL_INVERSE_DISTANCE 0xD001
|
||||
#define AL_INVERSE_DISTANCE_CLAMPED 0xD002
|
||||
#define AL_LINEAR_DISTANCE 0xD003
|
||||
#define AL_LINEAR_DISTANCE_CLAMPED 0xD004
|
||||
#define AL_EXPONENT_DISTANCE 0xD005
|
||||
#define AL_EXPONENT_DISTANCE_CLAMPED 0xD006
|
||||
|
||||
#endif
|
||||
@@ -1,90 +0,0 @@
|
||||
#ifndef _ALUT_H_
|
||||
#define _ALUT_H_
|
||||
|
||||
/* define platform type */
|
||||
#if !defined(MACINTOSH_AL) && !defined(LINUX_AL) && !defined(WINDOWS_AL)
|
||||
#ifdef __APPLE__
|
||||
#define MACINTOSH_AL
|
||||
#else
|
||||
#ifdef _WIN32
|
||||
#define WINDOWS_AL
|
||||
#else
|
||||
#define LINUX_AL
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "altypes.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#define ALUTAPI
|
||||
#define ALUTAPIENTRY __cdecl
|
||||
#define AL_CALLBACK
|
||||
#else /* _WIN32 */
|
||||
|
||||
#ifdef TARGET_OS_MAC
|
||||
#if TARGET_OS_MAC
|
||||
#pragma export on
|
||||
#endif /* TARGET_OS_MAC */
|
||||
#endif /* TARGET_OS_MAC */
|
||||
|
||||
#ifndef ALUTAPI
|
||||
#define ALUTAPI
|
||||
#endif
|
||||
|
||||
#ifndef ALUTAPIENTRY
|
||||
#define ALUTAPIENTRY
|
||||
#endif
|
||||
|
||||
#ifndef AL_CALLBACK
|
||||
#define AL_CALLBACK
|
||||
#endif
|
||||
|
||||
#endif /* _WIN32 */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef ALUT_NO_PROTOTYPES
|
||||
|
||||
ALUTAPI void ALUTAPIENTRY alutInit(int *argc, char *argv[]);
|
||||
ALUTAPI void ALUTAPIENTRY alutExit(ALvoid);
|
||||
|
||||
#ifndef MACINTOSH_AL
|
||||
/* Windows and Linux versions have a loop parameter, Macintosh doesn't */
|
||||
ALUTAPI void ALUTAPIENTRY alutLoadWAVFile(ALbyte *file, ALenum *format, ALvoid **data, ALsizei *size, ALsizei *freq, ALboolean *loop);
|
||||
ALUTAPI void ALUTAPIENTRY alutLoadWAVMemory(ALbyte *memory, ALenum *format, ALvoid **data, ALsizei *size, ALsizei *freq, ALboolean *loop);
|
||||
#else
|
||||
ALUTAPI void ALUTAPIENTRY alutLoadWAVFile(ALbyte *file, ALenum *format, ALvoid **data, ALsizei *size, ALsizei *freq);
|
||||
ALUTAPI void ALUTAPIENTRY alutLoadWAVMemory(ALbyte *memory, ALenum *format, ALvoid **data, ALsizei *size, ALsizei *freq);
|
||||
#endif
|
||||
|
||||
ALUTAPI void ALUTAPIENTRY alutUnloadWAV(ALenum format, ALvoid *data, ALsizei size, ALsizei freq);
|
||||
|
||||
#else /* ALUT_NO_PROTOTYPES */
|
||||
|
||||
void (ALUTAPIENTRY *alutInit)( int *argc, char *argv[] );
|
||||
void (ALUTAPIENTRY *alutExit)( ALvoid );
|
||||
#ifndef MACINTOSH_AL
|
||||
void (ALUTAPIENTRY *alutLoadWAVFile)( ALbyte *file,ALenum *format,ALvoid **data,ALsizei *size,ALsizei *freq,ALboolean *loop );
|
||||
void (ALUTAPIENTRY *alutLoadWAVMemory)( ALbyte *memory,ALenum *format,ALvoid **data,ALsizei *size,ALsizei *freq,ALboolean *loop );
|
||||
#else
|
||||
void (ALUTAPIENTRY *alutLoadWAVFile( ALbyte *file,ALenum *format,ALvoid **data,ALsizei *size,ALsizei *freq );
|
||||
void (ALUTAPIENTRY *alutLoadWAVMemory)( ALbyte *memory,ALenum *format,ALvoid **data,ALsizei *size,ALsizei *freq );
|
||||
#endif
|
||||
void (ALUTAPIENTRY *alutUnloadWAV)( ALenum format,ALvoid *data,ALsizei size,ALsizei freq );
|
||||
|
||||
#endif /* ALUT_NO_PROTOTYPES */
|
||||
|
||||
#ifdef TARGET_OS_MAC
|
||||
#if TARGET_OS_MAC
|
||||
#pragma export off
|
||||
#endif /* TARGET_OS_MAC */
|
||||
#endif /* TARGET_OS_MAC */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1,94 +0,0 @@
|
||||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2006 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
/* Main include header for the SDL library */
|
||||
|
||||
#ifndef _SDL_H
|
||||
#define _SDL_H
|
||||
|
||||
#include "SDL_main.h"
|
||||
#include "SDL_stdinc.h"
|
||||
#include "SDL_audio.h"
|
||||
#include "SDL_cdrom.h"
|
||||
#include "SDL_cpuinfo.h"
|
||||
#include "SDL_endian.h"
|
||||
#include "SDL_error.h"
|
||||
#include "SDL_events.h"
|
||||
#include "SDL_loadso.h"
|
||||
#include "SDL_mutex.h"
|
||||
#include "SDL_rwops.h"
|
||||
#include "SDL_thread.h"
|
||||
#include "SDL_timer.h"
|
||||
#include "SDL_video.h"
|
||||
#include "SDL_version.h"
|
||||
|
||||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* As of version 0.5, SDL is loaded dynamically into the application */
|
||||
|
||||
/* These are the flags which may be passed to SDL_Init() -- you should
|
||||
specify the subsystems which you will be using in your application.
|
||||
*/
|
||||
#define SDL_INIT_TIMER 0x00000001
|
||||
#define SDL_INIT_AUDIO 0x00000010
|
||||
#define SDL_INIT_VIDEO 0x00000020
|
||||
#define SDL_INIT_CDROM 0x00000100
|
||||
#define SDL_INIT_JOYSTICK 0x00000200
|
||||
#define SDL_INIT_NOPARACHUTE 0x00100000 /* Don't catch fatal signals */
|
||||
#define SDL_INIT_EVENTTHREAD 0x01000000 /* Not supported on all OS's */
|
||||
#define SDL_INIT_EVERYTHING 0x0000FFFF
|
||||
|
||||
/* This function loads the SDL dynamically linked library and initializes
|
||||
* the subsystems specified by 'flags' (and those satisfying dependencies)
|
||||
* Unless the SDL_INIT_NOPARACHUTE flag is set, it will install cleanup
|
||||
* signal handlers for some commonly ignored fatal signals (like SIGSEGV)
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_Init(Uint32 flags);
|
||||
|
||||
/* This function initializes specific SDL subsystems */
|
||||
extern DECLSPEC int SDLCALL SDL_InitSubSystem(Uint32 flags);
|
||||
|
||||
/* This function cleans up specific SDL subsystems */
|
||||
extern DECLSPEC void SDLCALL SDL_QuitSubSystem(Uint32 flags);
|
||||
|
||||
/* This function returns mask of the specified subsystems which have
|
||||
been initialized.
|
||||
If 'flags' is 0, it returns a mask of all initialized subsystems.
|
||||
*/
|
||||
extern DECLSPEC Uint32 SDLCALL SDL_WasInit(Uint32 flags);
|
||||
|
||||
/* This function cleans up all initialized subsystems and unloads the
|
||||
* dynamically linked library. You should call it upon all exit conditions.
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_Quit(void);
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* _SDL_H */
|
||||
@@ -1,58 +0,0 @@
|
||||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2006 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
/* Include file for SDL application focus event handling */
|
||||
|
||||
#ifndef _SDL_active_h
|
||||
#define _SDL_active_h
|
||||
|
||||
#include "SDL_stdinc.h"
|
||||
#include "SDL_error.h"
|
||||
|
||||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* The available application states */
|
||||
#define SDL_APPMOUSEFOCUS 0x01 /* The app has mouse coverage */
|
||||
#define SDL_APPINPUTFOCUS 0x02 /* The app has input focus */
|
||||
#define SDL_APPACTIVE 0x04 /* The application is active */
|
||||
|
||||
/* Function prototypes */
|
||||
/*
|
||||
* This function returns the current state of the application, which is a
|
||||
* bitwise combination of SDL_APPMOUSEFOCUS, SDL_APPINPUTFOCUS, and
|
||||
* SDL_APPACTIVE. If SDL_APPACTIVE is set, then the user is able to
|
||||
* see your application, otherwise it has been iconified or disabled.
|
||||
*/
|
||||
extern DECLSPEC Uint8 SDLCALL SDL_GetAppState(void);
|
||||
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* _SDL_active_h */
|
||||
@@ -1,253 +0,0 @@
|
||||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2006 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
/* Access to the raw audio mixing buffer for the SDL library */
|
||||
|
||||
#ifndef _SDL_audio_h
|
||||
#define _SDL_audio_h
|
||||
|
||||
#include "SDL_stdinc.h"
|
||||
#include "SDL_error.h"
|
||||
#include "SDL_endian.h"
|
||||
#include "SDL_mutex.h"
|
||||
#include "SDL_thread.h"
|
||||
#include "SDL_rwops.h"
|
||||
|
||||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* The calculated values in this structure are calculated by SDL_OpenAudio() */
|
||||
typedef struct SDL_AudioSpec {
|
||||
int freq; /* DSP frequency -- samples per second */
|
||||
Uint16 format; /* Audio data format */
|
||||
Uint8 channels; /* Number of channels: 1 mono, 2 stereo */
|
||||
Uint8 silence; /* Audio buffer silence value (calculated) */
|
||||
Uint16 samples; /* Audio buffer size in samples (power of 2) */
|
||||
Uint16 padding; /* Necessary for some compile environments */
|
||||
Uint32 size; /* Audio buffer size in bytes (calculated) */
|
||||
/* This function is called when the audio device needs more data.
|
||||
'stream' is a pointer to the audio data buffer
|
||||
'len' is the length of that buffer in bytes.
|
||||
Once the callback returns, the buffer will no longer be valid.
|
||||
Stereo samples are stored in a LRLRLR ordering.
|
||||
*/
|
||||
void (SDLCALL *callback)(void *userdata, Uint8 *stream, int len);
|
||||
void *userdata;
|
||||
} SDL_AudioSpec;
|
||||
|
||||
/* Audio format flags (defaults to LSB byte order) */
|
||||
#define AUDIO_U8 0x0008 /* Unsigned 8-bit samples */
|
||||
#define AUDIO_S8 0x8008 /* Signed 8-bit samples */
|
||||
#define AUDIO_U16LSB 0x0010 /* Unsigned 16-bit samples */
|
||||
#define AUDIO_S16LSB 0x8010 /* Signed 16-bit samples */
|
||||
#define AUDIO_U16MSB 0x1010 /* As above, but big-endian byte order */
|
||||
#define AUDIO_S16MSB 0x9010 /* As above, but big-endian byte order */
|
||||
#define AUDIO_U16 AUDIO_U16LSB
|
||||
#define AUDIO_S16 AUDIO_S16LSB
|
||||
|
||||
/* Native audio byte ordering */
|
||||
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
|
||||
#define AUDIO_U16SYS AUDIO_U16LSB
|
||||
#define AUDIO_S16SYS AUDIO_S16LSB
|
||||
#else
|
||||
#define AUDIO_U16SYS AUDIO_U16MSB
|
||||
#define AUDIO_S16SYS AUDIO_S16MSB
|
||||
#endif
|
||||
|
||||
|
||||
/* A structure to hold a set of audio conversion filters and buffers */
|
||||
typedef struct SDL_AudioCVT {
|
||||
int needed; /* Set to 1 if conversion possible */
|
||||
Uint16 src_format; /* Source audio format */
|
||||
Uint16 dst_format; /* Target audio format */
|
||||
double rate_incr; /* Rate conversion increment */
|
||||
Uint8 *buf; /* Buffer to hold entire audio data */
|
||||
int len; /* Length of original audio buffer */
|
||||
int len_cvt; /* Length of converted audio buffer */
|
||||
int len_mult; /* buffer must be len*len_mult big */
|
||||
double len_ratio; /* Given len, final size is len*len_ratio */
|
||||
void (SDLCALL *filters[10])(struct SDL_AudioCVT *cvt, Uint16 format);
|
||||
int filter_index; /* Current audio conversion function */
|
||||
} SDL_AudioCVT;
|
||||
|
||||
|
||||
/* Function prototypes */
|
||||
|
||||
/* These functions are used internally, and should not be used unless you
|
||||
* have a specific need to specify the audio driver you want to use.
|
||||
* You should normally use SDL_Init() or SDL_InitSubSystem().
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_AudioInit(const char *driver_name);
|
||||
extern DECLSPEC void SDLCALL SDL_AudioQuit(void);
|
||||
|
||||
/* This function fills the given character buffer with the name of the
|
||||
* current audio driver, and returns a pointer to it if the audio driver has
|
||||
* been initialized. It returns NULL if no driver has been initialized.
|
||||
*/
|
||||
extern DECLSPEC char * SDLCALL SDL_AudioDriverName(char *namebuf, int maxlen);
|
||||
|
||||
/*
|
||||
* This function opens the audio device with the desired parameters, and
|
||||
* returns 0 if successful, placing the actual hardware parameters in the
|
||||
* structure pointed to by 'obtained'. If 'obtained' is NULL, the audio
|
||||
* data passed to the callback function will be guaranteed to be in the
|
||||
* requested format, and will be automatically converted to the hardware
|
||||
* audio format if necessary. This function returns -1 if it failed
|
||||
* to open the audio device, or couldn't set up the audio thread.
|
||||
*
|
||||
* When filling in the desired audio spec structure,
|
||||
* 'desired->freq' should be the desired audio frequency in samples-per-second.
|
||||
* 'desired->format' should be the desired audio format.
|
||||
* 'desired->samples' is the desired size of the audio buffer, in samples.
|
||||
* This number should be a power of two, and may be adjusted by the audio
|
||||
* driver to a value more suitable for the hardware. Good values seem to
|
||||
* range between 512 and 8096 inclusive, depending on the application and
|
||||
* CPU speed. Smaller values yield faster response time, but can lead
|
||||
* to underflow if the application is doing heavy processing and cannot
|
||||
* fill the audio buffer in time. A stereo sample consists of both right
|
||||
* and left channels in LR ordering.
|
||||
* Note that the number of samples is directly related to time by the
|
||||
* following formula: ms = (samples*1000)/freq
|
||||
* 'desired->size' is the size in bytes of the audio buffer, and is
|
||||
* calculated by SDL_OpenAudio().
|
||||
* 'desired->silence' is the value used to set the buffer to silence,
|
||||
* and is calculated by SDL_OpenAudio().
|
||||
* 'desired->callback' should be set to a function that will be called
|
||||
* when the audio device is ready for more data. It is passed a pointer
|
||||
* to the audio buffer, and the length in bytes of the audio buffer.
|
||||
* This function usually runs in a separate thread, and so you should
|
||||
* protect data structures that it accesses by calling SDL_LockAudio()
|
||||
* and SDL_UnlockAudio() in your code.
|
||||
* 'desired->userdata' is passed as the first parameter to your callback
|
||||
* function.
|
||||
*
|
||||
* The audio device starts out playing silence when it's opened, and should
|
||||
* be enabled for playing by calling SDL_PauseAudio(0) when you are ready
|
||||
* for your audio callback function to be called. Since the audio driver
|
||||
* may modify the requested size of the audio buffer, you should allocate
|
||||
* any local mixing buffers after you open the audio device.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_OpenAudio(SDL_AudioSpec *desired, SDL_AudioSpec *obtained);
|
||||
|
||||
/*
|
||||
* Get the current audio state:
|
||||
*/
|
||||
typedef enum {
|
||||
SDL_AUDIO_STOPPED = 0,
|
||||
SDL_AUDIO_PLAYING,
|
||||
SDL_AUDIO_PAUSED
|
||||
} SDL_audiostatus;
|
||||
extern DECLSPEC SDL_audiostatus SDLCALL SDL_GetAudioStatus(void);
|
||||
|
||||
/*
|
||||
* This function pauses and unpauses the audio callback processing.
|
||||
* It should be called with a parameter of 0 after opening the audio
|
||||
* device to start playing sound. This is so you can safely initialize
|
||||
* data for your callback function after opening the audio device.
|
||||
* Silence will be written to the audio device during the pause.
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_PauseAudio(int pause_on);
|
||||
|
||||
/*
|
||||
* This function loads a WAVE from the data source, automatically freeing
|
||||
* that source if 'freesrc' is non-zero. For example, to load a WAVE file,
|
||||
* you could do:
|
||||
* SDL_LoadWAV_RW(SDL_RWFromFile("sample.wav", "rb"), 1, ...);
|
||||
*
|
||||
* If this function succeeds, it returns the given SDL_AudioSpec,
|
||||
* filled with the audio data format of the wave data, and sets
|
||||
* 'audio_buf' to a malloc()'d buffer containing the audio data,
|
||||
* and sets 'audio_len' to the length of that audio buffer, in bytes.
|
||||
* You need to free the audio buffer with SDL_FreeWAV() when you are
|
||||
* done with it.
|
||||
*
|
||||
* This function returns NULL and sets the SDL error message if the
|
||||
* wave file cannot be opened, uses an unknown data format, or is
|
||||
* corrupt. Currently raw and MS-ADPCM WAVE files are supported.
|
||||
*/
|
||||
extern DECLSPEC SDL_AudioSpec * SDLCALL SDL_LoadWAV_RW(SDL_RWops *src, int freesrc, SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len);
|
||||
|
||||
/* Compatibility convenience function -- loads a WAV from a file */
|
||||
#define SDL_LoadWAV(file, spec, audio_buf, audio_len) \
|
||||
SDL_LoadWAV_RW(SDL_RWFromFile(file, "rb"),1, spec,audio_buf,audio_len)
|
||||
|
||||
/*
|
||||
* This function frees data previously allocated with SDL_LoadWAV_RW()
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_FreeWAV(Uint8 *audio_buf);
|
||||
|
||||
/*
|
||||
* This function takes a source format and rate and a destination format
|
||||
* and rate, and initializes the 'cvt' structure with information needed
|
||||
* by SDL_ConvertAudio() to convert a buffer of audio data from one format
|
||||
* to the other.
|
||||
* This function returns 0, or -1 if there was an error.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_BuildAudioCVT(SDL_AudioCVT *cvt,
|
||||
Uint16 src_format, Uint8 src_channels, int src_rate,
|
||||
Uint16 dst_format, Uint8 dst_channels, int dst_rate);
|
||||
|
||||
/* Once you have initialized the 'cvt' structure using SDL_BuildAudioCVT(),
|
||||
* created an audio buffer cvt->buf, and filled it with cvt->len bytes of
|
||||
* audio data in the source format, this function will convert it in-place
|
||||
* to the desired format.
|
||||
* The data conversion may expand the size of the audio data, so the buffer
|
||||
* cvt->buf should be allocated after the cvt structure is initialized by
|
||||
* SDL_BuildAudioCVT(), and should be cvt->len*cvt->len_mult bytes long.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_ConvertAudio(SDL_AudioCVT *cvt);
|
||||
|
||||
/*
|
||||
* This takes two audio buffers of the playing audio format and mixes
|
||||
* them, performing addition, volume adjustment, and overflow clipping.
|
||||
* The volume ranges from 0 - 128, and should be set to SDL_MIX_MAXVOLUME
|
||||
* for full audio volume. Note this does not change hardware volume.
|
||||
* This is provided for convenience -- you can mix your own audio data.
|
||||
*/
|
||||
#define SDL_MIX_MAXVOLUME 128
|
||||
extern DECLSPEC void SDLCALL SDL_MixAudio(Uint8 *dst, const Uint8 *src, Uint32 len, int volume);
|
||||
|
||||
/*
|
||||
* The lock manipulated by these functions protects the callback function.
|
||||
* During a LockAudio/UnlockAudio pair, you can be guaranteed that the
|
||||
* callback function is not running. Do not call these from the callback
|
||||
* function or you will cause deadlock.
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_LockAudio(void);
|
||||
extern DECLSPEC void SDLCALL SDL_UnlockAudio(void);
|
||||
|
||||
/*
|
||||
* This function shuts down audio processing and closes the audio device.
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_CloseAudio(void);
|
||||
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* _SDL_audio_h */
|
||||
@@ -1,24 +0,0 @@
|
||||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2006 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
/* DEPRECATED */
|
||||
#include "SDL_endian.h"
|
||||
@@ -1,171 +0,0 @@
|
||||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2006 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
/* This is the CD-audio control API for Simple DirectMedia Layer */
|
||||
|
||||
#ifndef _SDL_cdrom_h
|
||||
#define _SDL_cdrom_h
|
||||
|
||||
#include "SDL_stdinc.h"
|
||||
#include "SDL_error.h"
|
||||
|
||||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* In order to use these functions, SDL_Init() must have been called
|
||||
with the SDL_INIT_CDROM flag. This causes SDL to scan the system
|
||||
for CD-ROM drives, and load appropriate drivers.
|
||||
*/
|
||||
|
||||
/* The maximum number of CD-ROM tracks on a disk */
|
||||
#define SDL_MAX_TRACKS 99
|
||||
|
||||
/* The types of CD-ROM track possible */
|
||||
#define SDL_AUDIO_TRACK 0x00
|
||||
#define SDL_DATA_TRACK 0x04
|
||||
|
||||
/* The possible states which a CD-ROM drive can be in. */
|
||||
typedef enum {
|
||||
CD_TRAYEMPTY,
|
||||
CD_STOPPED,
|
||||
CD_PLAYING,
|
||||
CD_PAUSED,
|
||||
CD_ERROR = -1
|
||||
} CDstatus;
|
||||
|
||||
/* Given a status, returns true if there's a disk in the drive */
|
||||
#define CD_INDRIVE(status) ((int)(status) > 0)
|
||||
|
||||
typedef struct SDL_CDtrack {
|
||||
Uint8 id; /* Track number */
|
||||
Uint8 type; /* Data or audio track */
|
||||
Uint16 unused;
|
||||
Uint32 length; /* Length, in frames, of this track */
|
||||
Uint32 offset; /* Offset, in frames, from start of disk */
|
||||
} SDL_CDtrack;
|
||||
|
||||
/* This structure is only current as of the last call to SDL_CDStatus() */
|
||||
typedef struct SDL_CD {
|
||||
int id; /* Private drive identifier */
|
||||
CDstatus status; /* Current drive status */
|
||||
|
||||
/* The rest of this structure is only valid if there's a CD in drive */
|
||||
int numtracks; /* Number of tracks on disk */
|
||||
int cur_track; /* Current track position */
|
||||
int cur_frame; /* Current frame offset within current track */
|
||||
SDL_CDtrack track[SDL_MAX_TRACKS+1];
|
||||
} SDL_CD;
|
||||
|
||||
/* Conversion functions from frames to Minute/Second/Frames and vice versa */
|
||||
#define CD_FPS 75
|
||||
#define FRAMES_TO_MSF(f, M,S,F) { \
|
||||
int value = f; \
|
||||
*(F) = value%CD_FPS; \
|
||||
value /= CD_FPS; \
|
||||
*(S) = value%60; \
|
||||
value /= 60; \
|
||||
*(M) = value; \
|
||||
}
|
||||
#define MSF_TO_FRAMES(M, S, F) ((M)*60*CD_FPS+(S)*CD_FPS+(F))
|
||||
|
||||
/* CD-audio API functions: */
|
||||
|
||||
/* Returns the number of CD-ROM drives on the system, or -1 if
|
||||
SDL_Init() has not been called with the SDL_INIT_CDROM flag.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_CDNumDrives(void);
|
||||
|
||||
/* Returns a human-readable, system-dependent identifier for the CD-ROM.
|
||||
Example:
|
||||
"/dev/cdrom"
|
||||
"E:"
|
||||
"/dev/disk/ide/1/master"
|
||||
*/
|
||||
extern DECLSPEC const char * SDLCALL SDL_CDName(int drive);
|
||||
|
||||
/* Opens a CD-ROM drive for access. It returns a drive handle on success,
|
||||
or NULL if the drive was invalid or busy. This newly opened CD-ROM
|
||||
becomes the default CD used when other CD functions are passed a NULL
|
||||
CD-ROM handle.
|
||||
Drives are numbered starting with 0. Drive 0 is the system default CD-ROM.
|
||||
*/
|
||||
extern DECLSPEC SDL_CD * SDLCALL SDL_CDOpen(int drive);
|
||||
|
||||
/* This function returns the current status of the given drive.
|
||||
If the drive has a CD in it, the table of contents of the CD and current
|
||||
play position of the CD will be stored in the SDL_CD structure.
|
||||
*/
|
||||
extern DECLSPEC CDstatus SDLCALL SDL_CDStatus(SDL_CD *cdrom);
|
||||
|
||||
/* Play the given CD starting at 'start_track' and 'start_frame' for 'ntracks'
|
||||
tracks and 'nframes' frames. If both 'ntrack' and 'nframe' are 0, play
|
||||
until the end of the CD. This function will skip data tracks.
|
||||
This function should only be called after calling SDL_CDStatus() to
|
||||
get track information about the CD.
|
||||
For example:
|
||||
// Play entire CD:
|
||||
if ( CD_INDRIVE(SDL_CDStatus(cdrom)) )
|
||||
SDL_CDPlayTracks(cdrom, 0, 0, 0, 0);
|
||||
// Play last track:
|
||||
if ( CD_INDRIVE(SDL_CDStatus(cdrom)) ) {
|
||||
SDL_CDPlayTracks(cdrom, cdrom->numtracks-1, 0, 0, 0);
|
||||
}
|
||||
// Play first and second track and 10 seconds of third track:
|
||||
if ( CD_INDRIVE(SDL_CDStatus(cdrom)) )
|
||||
SDL_CDPlayTracks(cdrom, 0, 0, 2, 10);
|
||||
|
||||
This function returns 0, or -1 if there was an error.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_CDPlayTracks(SDL_CD *cdrom,
|
||||
int start_track, int start_frame, int ntracks, int nframes);
|
||||
|
||||
/* Play the given CD starting at 'start' frame for 'length' frames.
|
||||
It returns 0, or -1 if there was an error.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_CDPlay(SDL_CD *cdrom, int start, int length);
|
||||
|
||||
/* Pause play -- returns 0, or -1 on error */
|
||||
extern DECLSPEC int SDLCALL SDL_CDPause(SDL_CD *cdrom);
|
||||
|
||||
/* Resume play -- returns 0, or -1 on error */
|
||||
extern DECLSPEC int SDLCALL SDL_CDResume(SDL_CD *cdrom);
|
||||
|
||||
/* Stop play -- returns 0, or -1 on error */
|
||||
extern DECLSPEC int SDLCALL SDL_CDStop(SDL_CD *cdrom);
|
||||
|
||||
/* Eject CD-ROM -- returns 0, or -1 on error */
|
||||
extern DECLSPEC int SDLCALL SDL_CDEject(SDL_CD *cdrom);
|
||||
|
||||
/* Closes the handle for the CD-ROM drive */
|
||||
extern DECLSPEC void SDLCALL SDL_CDClose(SDL_CD *cdrom);
|
||||
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* _SDL_video_h */
|
||||
@@ -1,45 +0,0 @@
|
||||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2006 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
#ifndef _SDL_config_h
|
||||
#define _SDL_config_h
|
||||
|
||||
#include "SDL_platform.h"
|
||||
|
||||
/* Add any platform that doesn't build using the configure system */
|
||||
#if defined(__AMIGA__)
|
||||
#include "SDL_config_amiga.h"
|
||||
#elif defined(__DREAMCAST__)
|
||||
#include "SDL_config_dreamcast.h"
|
||||
#elif defined(__MACOS__)
|
||||
#include "SDL_config_macos.h"
|
||||
#elif defined(__MACOSX__)
|
||||
#include "SDL_config_macosx.h"
|
||||
#elif defined(__WIN32__)
|
||||
#include "SDL_config_win32.h"
|
||||
#elif defined(__OS2__)
|
||||
#include "SDL_config_os2.h"
|
||||
#else
|
||||
#include "SDL_config_minimal.h"
|
||||
#endif /* platform config */
|
||||
|
||||
#endif /* _SDL_config_h */
|
||||
@@ -1,80 +0,0 @@
|
||||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2006 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
#ifndef _SDL_config_amiga_h
|
||||
#define _SDL_config_amiga_h
|
||||
|
||||
#include "SDL_platform.h"
|
||||
|
||||
/* This is a set of defines to configure the SDL features */
|
||||
|
||||
#define SDL_HAS_64BIT_TYPE 1
|
||||
|
||||
/* Useful headers */
|
||||
#define HAVE_SYS_TYPES_H 1
|
||||
#define HAVE_STDIO_H 1
|
||||
#define STDC_HEADERS 1
|
||||
#define HAVE_STRING_H 1
|
||||
#define HAVE_INTTYPES_H 1
|
||||
#define HAVE_SIGNAL_H 1
|
||||
|
||||
/* C library functions */
|
||||
#define HAVE_MALLOC 1
|
||||
#define HAVE_CALLOC 1
|
||||
#define HAVE_REALLOC 1
|
||||
#define HAVE_FREE 1
|
||||
#define HAVE_ALLOCA 1
|
||||
#define HAVE_GETENV 1
|
||||
#define HAVE_PUTENV 1
|
||||
#define HAVE_MEMSET 1
|
||||
#define HAVE_MEMCPY 1
|
||||
#define HAVE_MEMMOVE 1
|
||||
#define HAVE_MEMCMP 1
|
||||
|
||||
/* Enable various audio drivers */
|
||||
#define SDL_AUDIO_DRIVER_AHI 1
|
||||
#define SDL_AUDIO_DRIVER_DISK 1
|
||||
#define SDL_AUDIO_DRIVER_DUMMY 1
|
||||
|
||||
/* Enable various cdrom drivers */
|
||||
#define SDL_CDROM_DUMMY 1
|
||||
|
||||
/* Enable various input drivers */
|
||||
#define SDL_JOYSTICK_AMIGA 1
|
||||
|
||||
/* Enable various shared object loading systems */
|
||||
#define SDL_LOADSO_DUMMY 1
|
||||
|
||||
/* Enable various threading systems */
|
||||
#define SDL_THREAD_AMIGA 1
|
||||
|
||||
/* Enable various timer systems */
|
||||
#define SDL_TIMER_AMIGA 1
|
||||
|
||||
/* Enable various video drivers */
|
||||
#define SDL_VIDEO_DRIVER_CYBERGRAPHICS 1
|
||||
#define SDL_VIDEO_DRIVER_DUMMY 1
|
||||
|
||||
/* Enable OpenGL support */
|
||||
#define SDL_VIDEO_OPENGL 1
|
||||
|
||||
#endif /* _SDL_config_amiga_h */
|
||||
@@ -1,106 +0,0 @@
|
||||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2006 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
#ifndef _SDL_config_dreamcast_h
|
||||
#define _SDL_config_dreamcast_h
|
||||
|
||||
#include "SDL_platform.h"
|
||||
|
||||
/* This is a set of defines to configure the SDL features */
|
||||
|
||||
typedef signed char int8_t;
|
||||
typedef unsigned char uint8_t;
|
||||
typedef signed short int16_t;
|
||||
typedef unsigned short uint16_t;
|
||||
typedef signed int int32_t;
|
||||
typedef unsigned int uint32_t;
|
||||
typedef signed long long int64_t;
|
||||
typedef unsigned long long uint64_t;
|
||||
typedef unsigned long uintptr_t;
|
||||
#define SDL_HAS_64BIT_TYPE 1
|
||||
|
||||
/* Useful headers */
|
||||
#define HAVE_SYS_TYPES_H 1
|
||||
#define HAVE_STDIO_H 1
|
||||
#define STDC_HEADERS 1
|
||||
#define HAVE_STRING_H 1
|
||||
#define HAVE_CTYPE_H 1
|
||||
|
||||
/* C library functions */
|
||||
#define HAVE_MALLOC 1
|
||||
#define HAVE_CALLOC 1
|
||||
#define HAVE_REALLOC 1
|
||||
#define HAVE_FREE 1
|
||||
#define HAVE_ALLOCA 1
|
||||
#define HAVE_GETENV 1
|
||||
#define HAVE_PUTENV 1
|
||||
#define HAVE_QSORT 1
|
||||
#define HAVE_ABS 1
|
||||
#define HAVE_BCOPY 1
|
||||
#define HAVE_MEMSET 1
|
||||
#define HAVE_MEMCPY 1
|
||||
#define HAVE_MEMMOVE 1
|
||||
#define HAVE_MEMCMP 1
|
||||
#define HAVE_STRLEN 1
|
||||
#define HAVE_STRDUP 1
|
||||
#define HAVE_INDEX 1
|
||||
#define HAVE_RINDEX 1
|
||||
#define HAVE_STRCHR 1
|
||||
#define HAVE_STRRCHR 1
|
||||
#define HAVE_STRSTR 1
|
||||
#define HAVE_STRTOL 1
|
||||
#define HAVE_STRTOD 1
|
||||
#define HAVE_ATOI 1
|
||||
#define HAVE_ATOF 1
|
||||
#define HAVE_STRCMP 1
|
||||
#define HAVE_STRNCMP 1
|
||||
#define HAVE_STRICMP 1
|
||||
#define HAVE_STRCASECMP 1
|
||||
#define HAVE_SSCANF 1
|
||||
#define HAVE_SNPRINTF 1
|
||||
#define HAVE_VSNPRINTF 1
|
||||
|
||||
/* Enable various audio drivers */
|
||||
#define SDL_AUDIO_DRIVER_DC 1
|
||||
#define SDL_AUDIO_DRIVER_DISK 1
|
||||
#define SDL_AUDIO_DRIVER_DUMMY 1
|
||||
|
||||
/* Enable various cdrom drivers */
|
||||
#define SDL_CDROM_DC 1
|
||||
|
||||
/* Enable various input drivers */
|
||||
#define SDL_JOYSTICK_DC 1
|
||||
|
||||
/* Enable various shared object loading systems */
|
||||
#define SDL_LOADSO_DUMMY 1
|
||||
|
||||
/* Enable various threading systems */
|
||||
#define SDL_THREAD_DC 1
|
||||
|
||||
/* Enable various timer systems */
|
||||
#define SDL_TIMER_DC 1
|
||||
|
||||
/* Enable various video drivers */
|
||||
#define SDL_VIDEO_DRIVER_DC 1
|
||||
#define SDL_VIDEO_DRIVER_DUMMY 1
|
||||
|
||||
#endif /* _SDL_config_dreamcast_h */
|
||||
@@ -1,112 +0,0 @@
|
||||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2006 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
#ifndef _SDL_config_macos_h
|
||||
#define _SDL_config_macos_h
|
||||
|
||||
#include "SDL_platform.h"
|
||||
|
||||
/* This is a set of defines to configure the SDL features */
|
||||
|
||||
#include <MacTypes.h>
|
||||
|
||||
typedef SInt8 int8_t;
|
||||
typedef UInt8 uint8_t;
|
||||
typedef SInt16 int16_t;
|
||||
typedef UInt16 uint16_t;
|
||||
typedef SInt32 int32_t;
|
||||
typedef UInt32 uint32_t;
|
||||
typedef SInt64 int64_t;
|
||||
typedef UInt64 uint64_t;
|
||||
typedef unsigned long uintptr_t;
|
||||
|
||||
#define SDL_HAS_64BIT_TYPE 1
|
||||
|
||||
/* Useful headers */
|
||||
#define HAVE_STDIO_H 1
|
||||
#define STDC_HEADERS 1
|
||||
#define HAVE_STRING_H 1
|
||||
#define HAVE_CTYPE_H 1
|
||||
#define HAVE_MATH_H 1
|
||||
#define HAVE_SIGNAL_H 1
|
||||
|
||||
/* C library functions */
|
||||
#define HAVE_MALLOC 1
|
||||
#define HAVE_CALLOC 1
|
||||
#define HAVE_REALLOC 1
|
||||
#define HAVE_FREE 1
|
||||
#define HAVE_ALLOCA 1
|
||||
#define HAVE_ABS 1
|
||||
#define HAVE_MEMSET 1
|
||||
#define HAVE_MEMCPY 1
|
||||
#define HAVE_MEMMOVE 1
|
||||
#define HAVE_MEMCMP 1
|
||||
#define HAVE_STRLEN 1
|
||||
#define HAVE_STRCHR 1
|
||||
#define HAVE_STRRCHR 1
|
||||
#define HAVE_STRSTR 1
|
||||
#define HAVE_ITOA 1
|
||||
#define HAVE_STRTOL 1
|
||||
#define HAVE_STRTOD 1
|
||||
#define HAVE_ATOI 1
|
||||
#define HAVE_ATOF 1
|
||||
#define HAVE_STRCMP 1
|
||||
#define HAVE_STRNCMP 1
|
||||
#define HAVE_SSCANF 1
|
||||
|
||||
/* Enable various audio drivers */
|
||||
#define SDL_AUDIO_DRIVER_SNDMGR 1
|
||||
#define SDL_AUDIO_DRIVER_DISK 1
|
||||
#define SDL_AUDIO_DRIVER_DUMMY 1
|
||||
|
||||
/* Enable various cdrom drivers */
|
||||
#if TARGET_API_MAC_CARBON
|
||||
#define SDL_CDROM_DUMMY 1
|
||||
#else
|
||||
#define SDL_CDROM_MACOS 1
|
||||
#endif
|
||||
|
||||
/* Enable various input drivers */
|
||||
#if TARGET_API_MAC_CARBON
|
||||
#define SDL_JOYSTICK_DUMMY 1
|
||||
#else
|
||||
#define SDL_JOYSTICK_MACOS 1
|
||||
#endif
|
||||
|
||||
/* Enable various shared object loading systems */
|
||||
#define SDL_LOADSO_MACOS 1
|
||||
|
||||
/* Enable various threading systems */
|
||||
#define SDL_THREADS_DISABLED 1
|
||||
|
||||
/* Enable various timer systems */
|
||||
#define SDL_TIMER_MACOS 1
|
||||
|
||||
/* Enable various video drivers */
|
||||
#define SDL_VIDEO_DRIVER_DUMMY 1
|
||||
#define SDL_VIDEO_DRIVER_DRAWSPROCKET 1
|
||||
#define SDL_VIDEO_DRIVER_TOOLBOX 1
|
||||
|
||||
/* Enable OpenGL support */
|
||||
#define SDL_VIDEO_OPENGL 1
|
||||
|
||||
#endif /* _SDL_config_macos_h */
|
||||
@@ -1,132 +0,0 @@
|
||||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2006 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
#ifndef _SDL_config_macosx_h
|
||||
#define _SDL_config_macosx_h
|
||||
|
||||
#include "SDL_platform.h"
|
||||
|
||||
/* This is a set of defines to configure the SDL features */
|
||||
|
||||
#define SDL_HAS_64BIT_TYPE 1
|
||||
|
||||
/* Useful headers */
|
||||
/* If we specified an SDK or have a post-PowerPC chip, then alloca.h exists. */
|
||||
#if ( (MAC_OS_X_VERSION_MIN_REQUIRED >= 1030) || (!defined(__POWERPC__)) )
|
||||
#define HAVE_ALLOCA_H 1
|
||||
#endif
|
||||
#define HAVE_SYS_TYPES_H 1
|
||||
#define HAVE_STDIO_H 1
|
||||
#define STDC_HEADERS 1
|
||||
#define HAVE_STRING_H 1
|
||||
#define HAVE_INTTYPES_H 1
|
||||
#define HAVE_STDINT_H 1
|
||||
#define HAVE_CTYPE_H 1
|
||||
#define HAVE_MATH_H 1
|
||||
#define HAVE_SIGNAL_H 1
|
||||
|
||||
/* C library functions */
|
||||
#define HAVE_MALLOC 1
|
||||
#define HAVE_CALLOC 1
|
||||
#define HAVE_REALLOC 1
|
||||
#define HAVE_FREE 1
|
||||
#define HAVE_ALLOCA 1
|
||||
#define HAVE_GETENV 1
|
||||
#define HAVE_PUTENV 1
|
||||
#define HAVE_UNSETENV 1
|
||||
#define HAVE_QSORT 1
|
||||
#define HAVE_ABS 1
|
||||
#define HAVE_BCOPY 1
|
||||
#define HAVE_MEMSET 1
|
||||
#define HAVE_MEMCPY 1
|
||||
#define HAVE_MEMMOVE 1
|
||||
#define HAVE_MEMCMP 1
|
||||
#define HAVE_STRLEN 1
|
||||
#define HAVE_STRLCPY 1
|
||||
#define HAVE_STRLCAT 1
|
||||
#define HAVE_STRDUP 1
|
||||
#define HAVE_STRCHR 1
|
||||
#define HAVE_STRRCHR 1
|
||||
#define HAVE_STRSTR 1
|
||||
#define HAVE_STRTOL 1
|
||||
#define HAVE_STRTOUL 1
|
||||
#define HAVE_STRTOLL 1
|
||||
#define HAVE_STRTOULL 1
|
||||
#define HAVE_STRTOD 1
|
||||
#define HAVE_ATOI 1
|
||||
#define HAVE_ATOF 1
|
||||
#define HAVE_STRCMP 1
|
||||
#define HAVE_STRNCMP 1
|
||||
#define HAVE_STRCASECMP 1
|
||||
#define HAVE_STRNCASECMP 1
|
||||
#define HAVE_SSCANF 1
|
||||
#define HAVE_SNPRINTF 1
|
||||
#define HAVE_VSNPRINTF 1
|
||||
#define HAVE_SIGACTION 1
|
||||
#define HAVE_SETJMP 1
|
||||
#define HAVE_NANOSLEEP 1
|
||||
|
||||
/* Enable various audio drivers */
|
||||
#define SDL_AUDIO_DRIVER_COREAUDIO 1
|
||||
#define SDL_AUDIO_DRIVER_SNDMGR 1
|
||||
#define SDL_AUDIO_DRIVER_DISK 1
|
||||
#define SDL_AUDIO_DRIVER_DUMMY 1
|
||||
|
||||
/* Enable various cdrom drivers */
|
||||
#define SDL_CDROM_MACOSX 1
|
||||
|
||||
/* Enable various input drivers */
|
||||
#define SDL_JOYSTICK_IOKIT 1
|
||||
|
||||
/* Enable various shared object loading systems */
|
||||
#ifdef __ppc__
|
||||
/* For Mac OS X 10.2 compatibility */
|
||||
#define SDL_LOADSO_DLCOMPAT 1
|
||||
#else
|
||||
#define SDL_LOADSO_DLOPEN 1
|
||||
#endif
|
||||
|
||||
/* Enable various threading systems */
|
||||
#define SDL_THREAD_PTHREAD 1
|
||||
#define SDL_THREAD_PTHREAD_RECURSIVE_MUTEX 1
|
||||
|
||||
/* Enable various timer systems */
|
||||
#define SDL_TIMER_UNIX 1
|
||||
|
||||
/* Enable various video drivers */
|
||||
#define SDL_VIDEO_DRIVER_DUMMY 1
|
||||
#if TARGET_API_MAC_CARBON
|
||||
#define SDL_VIDEO_DRIVER_TOOLBOX 1
|
||||
#else
|
||||
#define SDL_VIDEO_DRIVER_QUARTZ 1
|
||||
#endif
|
||||
|
||||
/* Enable OpenGL support */
|
||||
#define SDL_VIDEO_OPENGL 1
|
||||
|
||||
/* Enable assembly routines */
|
||||
#define SDL_ASSEMBLY_ROUTINES 1
|
||||
#ifdef __ppc__
|
||||
#define SDL_ALTIVEC_BLITTERS 1
|
||||
#endif
|
||||
|
||||
#endif /* _SDL_config_macosx_h */
|
||||
@@ -1,62 +0,0 @@
|
||||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2006 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
#ifndef _SDL_config_minimal_h
|
||||
#define _SDL_config_minimal_h
|
||||
|
||||
#include "SDL_platform.h"
|
||||
|
||||
/* This is the minimal configuration that can be used to build SDL */
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
typedef signed char int8_t;
|
||||
typedef unsigned char uint8_t;
|
||||
typedef signed short int16_t;
|
||||
typedef unsigned short uint16_t;
|
||||
typedef signed int int32_t;
|
||||
typedef unsigned int uint32_t;
|
||||
typedef unsigned int size_t;
|
||||
typedef unsigned long uintptr_t;
|
||||
|
||||
/* Enable the dummy audio driver (src/audio/dummy/\*.c) */
|
||||
#define SDL_AUDIO_DRIVER_DUMMY 1
|
||||
|
||||
/* Enable the stub cdrom driver (src/cdrom/dummy/\*.c) */
|
||||
#define SDL_CDROM_DISABLED 1
|
||||
|
||||
/* Enable the stub joystick driver (src/joystick/dummy/\*.c) */
|
||||
#define SDL_JOYSTICK_DISABLED 1
|
||||
|
||||
/* Enable the stub shared object loader (src/loadso/dummy/\*.c) */
|
||||
#define SDL_LOADSO_DISABLED 1
|
||||
|
||||
/* Enable the stub thread support (src/thread/generic/\*.c) */
|
||||
#define SDL_THREADS_DISABLED 1
|
||||
|
||||
/* Enable the stub timer support (src/timer/dummy/\*.c) */
|
||||
#define SDL_TIMERS_DISABLED 1
|
||||
|
||||
/* Enable the dummy video driver (src/video/dummy/\*.c) */
|
||||
#define SDL_VIDEO_DRIVER_DUMMY 1
|
||||
|
||||
#endif /* _SDL_config_minimal_h */
|
||||
@@ -1,141 +0,0 @@
|
||||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2006 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
#ifndef _SDL_config_os2_h
|
||||
#define _SDL_config_os2_h
|
||||
|
||||
#include "SDL_platform.h"
|
||||
|
||||
/* This is a set of defines to configure the SDL features */
|
||||
|
||||
typedef signed char int8_t;
|
||||
typedef unsigned char uint8_t;
|
||||
typedef signed short int16_t;
|
||||
typedef unsigned short uint16_t;
|
||||
typedef signed int int32_t;
|
||||
typedef unsigned int uint32_t;
|
||||
typedef unsigned int size_t;
|
||||
typedef unsigned long uintptr_t;
|
||||
typedef signed long long int64_t;
|
||||
typedef unsigned long long uint64_t;
|
||||
|
||||
#define SDL_HAS_64BIT_TYPE 1
|
||||
|
||||
/* Use Watcom's LIBC */
|
||||
#define HAVE_LIBC 1
|
||||
|
||||
/* Useful headers */
|
||||
#define HAVE_SYS_TYPES_H 1
|
||||
#define HAVE_STDIO_H 1
|
||||
#define STDC_HEADERS 1
|
||||
#define HAVE_STDLIB_H 1
|
||||
#define HAVE_STDARG_H 1
|
||||
#define HAVE_MALLOC_H 1
|
||||
#define HAVE_MEMORY_H 1
|
||||
#define HAVE_STRING_H 1
|
||||
#define HAVE_STRINGS_H 1
|
||||
#define HAVE_INTTYPES_H 1
|
||||
#define HAVE_STDINT_H 1
|
||||
#define HAVE_CTYPE_H 1
|
||||
#define HAVE_MATH_H 1
|
||||
#define HAVE_SIGNAL_H 1
|
||||
|
||||
/* C library functions */
|
||||
#define HAVE_MALLOC 1
|
||||
#define HAVE_CALLOC 1
|
||||
#define HAVE_REALLOC 1
|
||||
#define HAVE_FREE 1
|
||||
#define HAVE_ALLOCA 1
|
||||
#define HAVE_GETENV 1
|
||||
#define HAVE_PUTENV 1
|
||||
#define HAVE_UNSETENV 1
|
||||
#define HAVE_QSORT 1
|
||||
#define HAVE_ABS 1
|
||||
#define HAVE_BCOPY 1
|
||||
#define HAVE_MEMSET 1
|
||||
#define HAVE_MEMCPY 1
|
||||
#define HAVE_MEMMOVE 1
|
||||
#define HAVE_MEMCMP 1
|
||||
#define HAVE_STRLEN 1
|
||||
#define HAVE_STRLCPY 1
|
||||
#define HAVE_STRLCAT 1
|
||||
#define HAVE_STRDUP 1
|
||||
#define HAVE__STRREV 1
|
||||
#define HAVE__STRUPR 1
|
||||
#define HAVE__STRLWR 1
|
||||
#define HAVE_INDEX 1
|
||||
#define HAVE_RINDEX 1
|
||||
#define HAVE_STRCHR 1
|
||||
#define HAVE_STRRCHR 1
|
||||
#define HAVE_STRSTR 1
|
||||
#define HAVE_ITOA 1
|
||||
#define HAVE__LTOA 1
|
||||
#define HAVE__UITOA 1
|
||||
#define HAVE__ULTOA 1
|
||||
#define HAVE_STRTOL 1
|
||||
#define HAVE__I64TOA 1
|
||||
#define HAVE__UI64TOA 1
|
||||
#define HAVE_STRTOLL 1
|
||||
#define HAVE_STRTOD 1
|
||||
#define HAVE_ATOI 1
|
||||
#define HAVE_ATOF 1
|
||||
#define HAVE_STRCMP 1
|
||||
#define HAVE_STRNCMP 1
|
||||
#define HAVE_STRICMP 1
|
||||
#define HAVE_STRCASECMP 1
|
||||
#define HAVE_SSCANF 1
|
||||
#define HAVE_SNPRINTF 1
|
||||
#define HAVE_VSNPRINTF 1
|
||||
#define HAVE_SETJMP 1
|
||||
#define HAVE_CLOCK_GETTIME 1
|
||||
|
||||
/* Enable various audio drivers */
|
||||
#define SDL_AUDIO_DRIVER_DART 1
|
||||
#define SDL_AUDIO_DRIVER_DISK 1
|
||||
#define SDL_AUDIO_DRIVER_DUMMY 1
|
||||
|
||||
/* Enable various cdrom drivers */
|
||||
#define SDL_CDROM_OS2 1
|
||||
|
||||
/* Enable various input drivers */
|
||||
#define SDL_JOYSTICK_OS2 1
|
||||
|
||||
/* Enable various shared object loading systems */
|
||||
#define SDL_LOADSO_OS2 1
|
||||
|
||||
/* Enable various threading systems */
|
||||
#define SDL_THREAD_OS2 1
|
||||
|
||||
/* Enable various timer systems */
|
||||
#define SDL_TIMER_OS2 1
|
||||
|
||||
/* Enable various video drivers */
|
||||
#define SDL_VIDEO_DRIVER_DUMMY 1
|
||||
#define SDL_VIDEO_DRIVER_OS2FS 1
|
||||
|
||||
/* Enable OpenGL support */
|
||||
/* Nothing here yet for OS/2... :( */
|
||||
|
||||
/* Enable assembly routines where available */
|
||||
#define SDL_ASSEMBLY_ROUTINES 1
|
||||
|
||||
#endif /* _SDL_config_os2_h */
|
||||
@@ -1,173 +0,0 @@
|
||||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2006 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
#ifndef _SDL_config_win32_h
|
||||
#define _SDL_config_win32_h
|
||||
|
||||
#include "SDL_platform.h"
|
||||
|
||||
/* This is a set of defines to configure the SDL features */
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define HAVE_STDINT_H 1
|
||||
#elif defined(_MSC_VER)
|
||||
typedef signed __int8 int8_t;
|
||||
typedef unsigned __int8 uint8_t;
|
||||
typedef signed __int16 int16_t;
|
||||
typedef unsigned __int16 uint16_t;
|
||||
typedef signed __int32 int32_t;
|
||||
typedef unsigned __int32 uint32_t;
|
||||
typedef signed __int64 int64_t;
|
||||
typedef unsigned __int64 uint64_t;
|
||||
#ifndef _UINTPTR_T_DEFINED
|
||||
#ifdef _WIN64
|
||||
typedef unsigned __int64 uintptr_t;
|
||||
#else
|
||||
typedef unsigned int uintptr_t;
|
||||
#endif
|
||||
#define _UINTPTR_T_DEFINED
|
||||
#endif
|
||||
#else /* !__GNUC__ && !_MSC_VER */
|
||||
typedef signed char int8_t;
|
||||
typedef unsigned char uint8_t;
|
||||
typedef signed short int16_t;
|
||||
typedef unsigned short uint16_t;
|
||||
typedef signed int int32_t;
|
||||
typedef unsigned int uint32_t;
|
||||
typedef signed long long int64_t;
|
||||
typedef unsigned long long uint64_t;
|
||||
#ifndef _SIZE_T_DEFINED_
|
||||
#define _SIZE_T_DEFINED_
|
||||
typedef unsigned int size_t;
|
||||
#endif
|
||||
typedef unsigned int uintptr_t;
|
||||
#endif /* __GNUC__ || _MSC_VER */
|
||||
#define SDL_HAS_64BIT_TYPE 1
|
||||
|
||||
/* Enabled for SDL 1.2 (binary compatibility) */
|
||||
#define HAVE_LIBC 1
|
||||
#ifdef HAVE_LIBC
|
||||
/* Useful headers */
|
||||
#define HAVE_STDIO_H 1
|
||||
#define STDC_HEADERS 1
|
||||
#define HAVE_STRING_H 1
|
||||
#define HAVE_CTYPE_H 1
|
||||
#define HAVE_MATH_H 1
|
||||
#ifndef _WIN32_WCE
|
||||
#define HAVE_SIGNAL_H 1
|
||||
#endif
|
||||
|
||||
/* C library functions */
|
||||
#define HAVE_MALLOC 1
|
||||
#define HAVE_CALLOC 1
|
||||
#define HAVE_REALLOC 1
|
||||
#define HAVE_FREE 1
|
||||
#define HAVE_ALLOCA 1
|
||||
#define HAVE_QSORT 1
|
||||
#define HAVE_ABS 1
|
||||
#define HAVE_MEMSET 1
|
||||
#define HAVE_MEMCPY 1
|
||||
#define HAVE_MEMMOVE 1
|
||||
#define HAVE_MEMCMP 1
|
||||
#define HAVE_STRLEN 1
|
||||
#define HAVE__STRREV 1
|
||||
#define HAVE__STRUPR 1
|
||||
#define HAVE__STRLWR 1
|
||||
#define HAVE_STRCHR 1
|
||||
#define HAVE_STRRCHR 1
|
||||
#define HAVE_STRSTR 1
|
||||
#define HAVE_ITOA 1
|
||||
#define HAVE__LTOA 1
|
||||
#define HAVE__ULTOA 1
|
||||
#define HAVE_STRTOL 1
|
||||
#define HAVE_STRTOUL 1
|
||||
#define HAVE_STRTOLL 1
|
||||
#define HAVE_STRTOD 1
|
||||
#define HAVE_ATOI 1
|
||||
#define HAVE_ATOF 1
|
||||
#define HAVE_STRCMP 1
|
||||
#define HAVE_STRNCMP 1
|
||||
#define HAVE__STRICMP 1
|
||||
#define HAVE__STRNICMP 1
|
||||
#define HAVE_SSCANF 1
|
||||
#else
|
||||
#define HAVE_STDARG_H 1
|
||||
#define HAVE_STDDEF_H 1
|
||||
#endif
|
||||
|
||||
/* Enable various audio drivers */
|
||||
#ifndef _WIN32_WCE
|
||||
#define SDL_AUDIO_DRIVER_DSOUND 1
|
||||
#endif
|
||||
#define SDL_AUDIO_DRIVER_WAVEOUT 1
|
||||
#define SDL_AUDIO_DRIVER_DISK 1
|
||||
#define SDL_AUDIO_DRIVER_DUMMY 1
|
||||
|
||||
/* Enable various cdrom drivers */
|
||||
#ifdef _WIN32_WCE
|
||||
#define SDL_CDROM_DISABLED 1
|
||||
#else
|
||||
#define SDL_CDROM_WIN32 1
|
||||
#endif
|
||||
|
||||
/* Enable various input drivers */
|
||||
#ifdef _WIN32_WCE
|
||||
#define SDL_JOYSTICK_DISABLED 1
|
||||
#else
|
||||
#define SDL_JOYSTICK_WINMM 1
|
||||
#endif
|
||||
|
||||
/* Enable various shared object loading systems */
|
||||
#define SDL_LOADSO_WIN32 1
|
||||
|
||||
/* Enable various threading systems */
|
||||
#define SDL_THREAD_WIN32 1
|
||||
|
||||
/* Enable various timer systems */
|
||||
#ifdef _WIN32_WCE
|
||||
#define SDL_TIMER_WINCE 1
|
||||
#else
|
||||
#define SDL_TIMER_WIN32 1
|
||||
#endif
|
||||
|
||||
/* Enable various video drivers */
|
||||
#ifdef _WIN32_WCE
|
||||
#define SDL_VIDEO_DRIVER_GAPI 1
|
||||
#endif
|
||||
#ifndef _WIN32_WCE
|
||||
#define SDL_VIDEO_DRIVER_DDRAW 1
|
||||
#endif
|
||||
#define SDL_VIDEO_DRIVER_DUMMY 1
|
||||
#define SDL_VIDEO_DRIVER_WINDIB 1
|
||||
|
||||
/* Enable OpenGL support */
|
||||
#ifndef _WIN32_WCE
|
||||
#define SDL_VIDEO_OPENGL 1
|
||||
#define SDL_VIDEO_OPENGL_WGL 1
|
||||
#endif
|
||||
|
||||
/* Enable assembly routines (Win64 doesn't have inline asm) */
|
||||
#ifndef _WIN64
|
||||
#define SDL_ASSEMBLY_ROUTINES 1
|
||||
#endif
|
||||
|
||||
#endif /* _SDL_config_win32_h */
|
||||
@@ -1,22 +0,0 @@
|
||||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2006 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
@@ -1,75 +0,0 @@
|
||||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2006 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
/* CPU feature detection for SDL */
|
||||
|
||||
#ifndef _SDL_cpuinfo_h
|
||||
#define _SDL_cpuinfo_h
|
||||
|
||||
#include "SDL_stdinc.h"
|
||||
|
||||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* This function returns true if the CPU has the RDTSC instruction
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_HasRDTSC(void);
|
||||
|
||||
/* This function returns true if the CPU has MMX features
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_HasMMX(void);
|
||||
|
||||
/* This function returns true if the CPU has MMX Ext. features
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_HasMMXExt(void);
|
||||
|
||||
/* This function returns true if the CPU has 3DNow features
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_Has3DNow(void);
|
||||
|
||||
/* This function returns true if the CPU has 3DNow! Ext. features
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_Has3DNowExt(void);
|
||||
|
||||
/* This function returns true if the CPU has SSE features
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE(void);
|
||||
|
||||
/* This function returns true if the CPU has SSE2 features
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE2(void);
|
||||
|
||||
/* This function returns true if the CPU has AltiVec features
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_HasAltiVec(void);
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* _SDL_cpuinfo_h */
|
||||
@@ -1,192 +0,0 @@
|
||||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2006 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
/* Functions for reading and writing endian-specific values */
|
||||
|
||||
#ifndef _SDL_endian_h
|
||||
#define _SDL_endian_h
|
||||
|
||||
#include "SDL_stdinc.h"
|
||||
|
||||
/* The two types of endianness */
|
||||
#define SDL_LIL_ENDIAN 1234
|
||||
#define SDL_BIG_ENDIAN 4321
|
||||
|
||||
#ifndef SDL_BYTEORDER /* Not defined in SDL_config.h? */
|
||||
#if defined(__hppa__) || \
|
||||
defined(__m68k__) || defined(mc68000) || defined(_M_M68K) || \
|
||||
(defined(__MIPS__) && defined(__MISPEB__)) || \
|
||||
defined(__ppc__) || defined(__POWERPC__) || defined(_M_PPC) || \
|
||||
defined(__sparc__)
|
||||
#define SDL_BYTEORDER SDL_BIG_ENDIAN
|
||||
#else
|
||||
#define SDL_BYTEORDER SDL_LIL_ENDIAN
|
||||
#endif
|
||||
#endif /* !SDL_BYTEORDER */
|
||||
|
||||
|
||||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Use inline functions for compilers that support them, and static
|
||||
functions for those that do not. Because these functions become
|
||||
static for compilers that do not support inline functions, this
|
||||
header should only be included in files that actually use them.
|
||||
*/
|
||||
#if defined(__GNUC__) && defined(__i386__) && \
|
||||
!(__GNUC__ == 2 && __GNUC_MINOR__ == 95 /* broken gcc version */)
|
||||
static __inline__ Uint16 SDL_Swap16(Uint16 x)
|
||||
{
|
||||
__asm__("xchgb %b0,%h0" : "=q" (x) : "0" (x));
|
||||
return x;
|
||||
}
|
||||
#elif defined(__GNUC__) && defined(__x86_64__)
|
||||
static __inline__ Uint16 SDL_Swap16(Uint16 x)
|
||||
{
|
||||
__asm__("xchgb %b0,%h0" : "=Q" (x) : "0" (x));
|
||||
return x;
|
||||
}
|
||||
#elif defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__))
|
||||
static __inline__ Uint16 SDL_Swap16(Uint16 x)
|
||||
{
|
||||
Uint16 result;
|
||||
|
||||
__asm__("rlwimi %0,%2,8,16,23" : "=&r" (result) : "0" (x >> 8), "r" (x));
|
||||
return result;
|
||||
}
|
||||
#elif defined(__GNUC__) && (defined(__M68000__) || defined(__M68020__))
|
||||
static __inline__ Uint16 SDL_Swap16(Uint16 x)
|
||||
{
|
||||
__asm__("rorw #8,%0" : "=d" (x) : "0" (x) : "cc");
|
||||
return x;
|
||||
}
|
||||
#else
|
||||
static __inline__ Uint16 SDL_Swap16(Uint16 x) {
|
||||
return((x<<8)|(x>>8));
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__) && defined(__i386__)
|
||||
static __inline__ Uint32 SDL_Swap32(Uint32 x)
|
||||
{
|
||||
__asm__("bswap %0" : "=r" (x) : "0" (x));
|
||||
return x;
|
||||
}
|
||||
#elif defined(__GNUC__) && defined(__x86_64__)
|
||||
static __inline__ Uint32 SDL_Swap32(Uint32 x)
|
||||
{
|
||||
__asm__("bswapl %0" : "=r" (x) : "0" (x));
|
||||
return x;
|
||||
}
|
||||
#elif defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__))
|
||||
static __inline__ Uint32 SDL_Swap32(Uint32 x)
|
||||
{
|
||||
Uint32 result;
|
||||
|
||||
__asm__("rlwimi %0,%2,24,16,23" : "=&r" (result) : "0" (x>>24), "r" (x));
|
||||
__asm__("rlwimi %0,%2,8,8,15" : "=&r" (result) : "0" (result), "r" (x));
|
||||
__asm__("rlwimi %0,%2,24,0,7" : "=&r" (result) : "0" (result), "r" (x));
|
||||
return result;
|
||||
}
|
||||
#elif defined(__GNUC__) && (defined(__M68000__) || defined(__M68020__))
|
||||
static __inline__ Uint32 SDL_Swap32(Uint32 x)
|
||||
{
|
||||
__asm__("rorw #8,%0\n\tswap %0\n\trorw #8,%0" : "=d" (x) : "0" (x) : "cc");
|
||||
return x;
|
||||
}
|
||||
#else
|
||||
static __inline__ Uint32 SDL_Swap32(Uint32 x) {
|
||||
return((x<<24)|((x<<8)&0x00FF0000)|((x>>8)&0x0000FF00)|(x>>24));
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SDL_HAS_64BIT_TYPE
|
||||
#if defined(__GNUC__) && defined(__i386__)
|
||||
static __inline__ Uint64 SDL_Swap64(Uint64 x)
|
||||
{
|
||||
union {
|
||||
struct { Uint32 a,b; } s;
|
||||
Uint64 u;
|
||||
} v;
|
||||
v.u = x;
|
||||
__asm__("bswapl %0 ; bswapl %1 ; xchgl %0,%1"
|
||||
: "=r" (v.s.a), "=r" (v.s.b)
|
||||
: "0" (v.s.a), "1" (v.s.b));
|
||||
return v.u;
|
||||
}
|
||||
#elif defined(__GNUC__) && defined(__x86_64__)
|
||||
static __inline__ Uint64 SDL_Swap64(Uint64 x)
|
||||
{
|
||||
__asm__("bswapq %0" : "=r" (x) : "0" (x));
|
||||
return x;
|
||||
}
|
||||
#else
|
||||
static __inline__ Uint64 SDL_Swap64(Uint64 x)
|
||||
{
|
||||
Uint32 hi, lo;
|
||||
|
||||
/* Separate into high and low 32-bit values and swap them */
|
||||
lo = (Uint32)(x&0xFFFFFFFF);
|
||||
x >>= 32;
|
||||
hi = (Uint32)(x&0xFFFFFFFF);
|
||||
x = SDL_Swap32(lo);
|
||||
x <<= 32;
|
||||
x |= SDL_Swap32(hi);
|
||||
return(x);
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
/* This is mainly to keep compilers from complaining in SDL code.
|
||||
If there is no real 64-bit datatype, then compilers will complain about
|
||||
the fake 64-bit datatype that SDL provides when it compiles user code.
|
||||
*/
|
||||
#define SDL_Swap64(X) (X)
|
||||
#endif /* SDL_HAS_64BIT_TYPE */
|
||||
|
||||
|
||||
/* Byteswap item from the specified endianness to the native endianness */
|
||||
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
|
||||
#define SDL_SwapLE16(X) (X)
|
||||
#define SDL_SwapLE32(X) (X)
|
||||
#define SDL_SwapLE64(X) (X)
|
||||
#define SDL_SwapBE16(X) SDL_Swap16(X)
|
||||
#define SDL_SwapBE32(X) SDL_Swap32(X)
|
||||
#define SDL_SwapBE64(X) SDL_Swap64(X)
|
||||
#else
|
||||
#define SDL_SwapLE16(X) SDL_Swap16(X)
|
||||
#define SDL_SwapLE32(X) SDL_Swap32(X)
|
||||
#define SDL_SwapLE64(X) SDL_Swap64(X)
|
||||
#define SDL_SwapBE16(X) (X)
|
||||
#define SDL_SwapBE32(X) (X)
|
||||
#define SDL_SwapBE64(X) (X)
|
||||
#endif
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* _SDL_endian_h */
|
||||
@@ -1,61 +0,0 @@
|
||||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2006 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
/* Simple error message routines for SDL */
|
||||
|
||||
#ifndef _SDL_error_h
|
||||
#define _SDL_error_h
|
||||
|
||||
#include "SDL_stdinc.h"
|
||||
|
||||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Public functions */
|
||||
extern DECLSPEC void SDLCALL SDL_SetError(const char *fmt, ...);
|
||||
extern DECLSPEC char * SDLCALL SDL_GetError(void);
|
||||
extern DECLSPEC void SDLCALL SDL_ClearError(void);
|
||||
|
||||
/* Private error message function - used internally */
|
||||
#define SDL_OutOfMemory() SDL_Error(SDL_ENOMEM)
|
||||
#define SDL_Unsupported() SDL_Error(SDL_UNSUPPORTED)
|
||||
typedef enum {
|
||||
SDL_ENOMEM,
|
||||
SDL_EFREAD,
|
||||
SDL_EFWRITE,
|
||||
SDL_EFSEEK,
|
||||
SDL_UNSUPPORTED,
|
||||
SDL_LASTERROR
|
||||
} SDL_errorcode;
|
||||
extern DECLSPEC void SDLCALL SDL_Error(SDL_errorcode code);
|
||||
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* _SDL_error_h */
|
||||
@@ -1,337 +0,0 @@
|
||||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2006 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
/* Include file for SDL event handling */
|
||||
|
||||
#ifndef _SDL_events_h
|
||||
#define _SDL_events_h
|
||||
|
||||
#include "SDL_stdinc.h"
|
||||
#include "SDL_error.h"
|
||||
#include "SDL_active.h"
|
||||
#include "SDL_keyboard.h"
|
||||
#include "SDL_mouse.h"
|
||||
#include "SDL_joystick.h"
|
||||
#include "SDL_quit.h"
|
||||
|
||||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* General keyboard/mouse state definitions */
|
||||
#define SDL_RELEASED 0
|
||||
#define SDL_PRESSED 1
|
||||
|
||||
/* Event enumerations */
|
||||
typedef enum {
|
||||
SDL_NOEVENT = 0, /* Unused (do not remove) */
|
||||
SDL_ACTIVEEVENT, /* Application loses/gains visibility */
|
||||
SDL_KEYDOWN, /* Keys pressed */
|
||||
SDL_KEYUP, /* Keys released */
|
||||
SDL_MOUSEMOTION, /* Mouse moved */
|
||||
SDL_MOUSEBUTTONDOWN, /* Mouse button pressed */
|
||||
SDL_MOUSEBUTTONUP, /* Mouse button released */
|
||||
SDL_JOYAXISMOTION, /* Joystick axis motion */
|
||||
SDL_JOYBALLMOTION, /* Joystick trackball motion */
|
||||
SDL_JOYHATMOTION, /* Joystick hat position change */
|
||||
SDL_JOYBUTTONDOWN, /* Joystick button pressed */
|
||||
SDL_JOYBUTTONUP, /* Joystick button released */
|
||||
SDL_QUIT, /* User-requested quit */
|
||||
SDL_SYSWMEVENT, /* System specific event */
|
||||
SDL_EVENT_RESERVEDA, /* Reserved for future use.. */
|
||||
SDL_EVENT_RESERVEDB, /* Reserved for future use.. */
|
||||
SDL_VIDEORESIZE, /* User resized video mode */
|
||||
SDL_VIDEOEXPOSE, /* Screen needs to be redrawn */
|
||||
SDL_EVENT_RESERVED2, /* Reserved for future use.. */
|
||||
SDL_EVENT_RESERVED3, /* Reserved for future use.. */
|
||||
SDL_EVENT_RESERVED4, /* Reserved for future use.. */
|
||||
SDL_EVENT_RESERVED5, /* Reserved for future use.. */
|
||||
SDL_EVENT_RESERVED6, /* Reserved for future use.. */
|
||||
SDL_EVENT_RESERVED7, /* Reserved for future use.. */
|
||||
/* Events SDL_USEREVENT through SDL_MAXEVENTS-1 are for your use */
|
||||
SDL_USEREVENT = 24,
|
||||
/* This last event is only for bounding internal arrays
|
||||
It is the number of bits in the event mask datatype -- Uint32
|
||||
*/
|
||||
SDL_NUMEVENTS = 32
|
||||
} SDL_EventType;
|
||||
|
||||
/* Predefined event masks */
|
||||
#define SDL_EVENTMASK(X) (1<<(X))
|
||||
typedef enum {
|
||||
SDL_ACTIVEEVENTMASK = SDL_EVENTMASK(SDL_ACTIVEEVENT),
|
||||
SDL_KEYDOWNMASK = SDL_EVENTMASK(SDL_KEYDOWN),
|
||||
SDL_KEYUPMASK = SDL_EVENTMASK(SDL_KEYUP),
|
||||
SDL_KEYEVENTMASK = SDL_EVENTMASK(SDL_KEYDOWN)|
|
||||
SDL_EVENTMASK(SDL_KEYUP),
|
||||
SDL_MOUSEMOTIONMASK = SDL_EVENTMASK(SDL_MOUSEMOTION),
|
||||
SDL_MOUSEBUTTONDOWNMASK = SDL_EVENTMASK(SDL_MOUSEBUTTONDOWN),
|
||||
SDL_MOUSEBUTTONUPMASK = SDL_EVENTMASK(SDL_MOUSEBUTTONUP),
|
||||
SDL_MOUSEEVENTMASK = SDL_EVENTMASK(SDL_MOUSEMOTION)|
|
||||
SDL_EVENTMASK(SDL_MOUSEBUTTONDOWN)|
|
||||
SDL_EVENTMASK(SDL_MOUSEBUTTONUP),
|
||||
SDL_JOYAXISMOTIONMASK = SDL_EVENTMASK(SDL_JOYAXISMOTION),
|
||||
SDL_JOYBALLMOTIONMASK = SDL_EVENTMASK(SDL_JOYBALLMOTION),
|
||||
SDL_JOYHATMOTIONMASK = SDL_EVENTMASK(SDL_JOYHATMOTION),
|
||||
SDL_JOYBUTTONDOWNMASK = SDL_EVENTMASK(SDL_JOYBUTTONDOWN),
|
||||
SDL_JOYBUTTONUPMASK = SDL_EVENTMASK(SDL_JOYBUTTONUP),
|
||||
SDL_JOYEVENTMASK = SDL_EVENTMASK(SDL_JOYAXISMOTION)|
|
||||
SDL_EVENTMASK(SDL_JOYBALLMOTION)|
|
||||
SDL_EVENTMASK(SDL_JOYHATMOTION)|
|
||||
SDL_EVENTMASK(SDL_JOYBUTTONDOWN)|
|
||||
SDL_EVENTMASK(SDL_JOYBUTTONUP),
|
||||
SDL_VIDEORESIZEMASK = SDL_EVENTMASK(SDL_VIDEORESIZE),
|
||||
SDL_VIDEOEXPOSEMASK = SDL_EVENTMASK(SDL_VIDEOEXPOSE),
|
||||
SDL_QUITMASK = SDL_EVENTMASK(SDL_QUIT),
|
||||
SDL_SYSWMEVENTMASK = SDL_EVENTMASK(SDL_SYSWMEVENT)
|
||||
} SDL_EventMask ;
|
||||
#define SDL_ALLEVENTS 0xFFFFFFFF
|
||||
|
||||
/* Application visibility event structure */
|
||||
typedef struct SDL_ActiveEvent {
|
||||
Uint8 type; /* SDL_ACTIVEEVENT */
|
||||
Uint8 gain; /* Whether given states were gained or lost (1/0) */
|
||||
Uint8 state; /* A mask of the focus states */
|
||||
} SDL_ActiveEvent;
|
||||
|
||||
/* Keyboard event structure */
|
||||
typedef struct SDL_KeyboardEvent {
|
||||
Uint8 type; /* SDL_KEYDOWN or SDL_KEYUP */
|
||||
Uint8 which; /* The keyboard device index */
|
||||
Uint8 state; /* SDL_PRESSED or SDL_RELEASED */
|
||||
SDL_keysym keysym;
|
||||
} SDL_KeyboardEvent;
|
||||
|
||||
/* Mouse motion event structure */
|
||||
typedef struct SDL_MouseMotionEvent {
|
||||
Uint8 type; /* SDL_MOUSEMOTION */
|
||||
Uint8 which; /* The mouse device index */
|
||||
Uint8 state; /* The current button state */
|
||||
Uint16 x, y; /* The X/Y coordinates of the mouse */
|
||||
Sint16 xrel; /* The relative motion in the X direction */
|
||||
Sint16 yrel; /* The relative motion in the Y direction */
|
||||
} SDL_MouseMotionEvent;
|
||||
|
||||
/* Mouse button event structure */
|
||||
typedef struct SDL_MouseButtonEvent {
|
||||
Uint8 type; /* SDL_MOUSEBUTTONDOWN or SDL_MOUSEBUTTONUP */
|
||||
Uint8 which; /* The mouse device index */
|
||||
Uint8 button; /* The mouse button index */
|
||||
Uint8 state; /* SDL_PRESSED or SDL_RELEASED */
|
||||
Uint16 x, y; /* The X/Y coordinates of the mouse at press time */
|
||||
} SDL_MouseButtonEvent;
|
||||
|
||||
/* Joystick axis motion event structure */
|
||||
typedef struct SDL_JoyAxisEvent {
|
||||
Uint8 type; /* SDL_JOYAXISMOTION */
|
||||
Uint8 which; /* The joystick device index */
|
||||
Uint8 axis; /* The joystick axis index */
|
||||
Sint16 value; /* The axis value (range: -32768 to 32767) */
|
||||
} SDL_JoyAxisEvent;
|
||||
|
||||
/* Joystick trackball motion event structure */
|
||||
typedef struct SDL_JoyBallEvent {
|
||||
Uint8 type; /* SDL_JOYBALLMOTION */
|
||||
Uint8 which; /* The joystick device index */
|
||||
Uint8 ball; /* The joystick trackball index */
|
||||
Sint16 xrel; /* The relative motion in the X direction */
|
||||
Sint16 yrel; /* The relative motion in the Y direction */
|
||||
} SDL_JoyBallEvent;
|
||||
|
||||
/* Joystick hat position change event structure */
|
||||
typedef struct SDL_JoyHatEvent {
|
||||
Uint8 type; /* SDL_JOYHATMOTION */
|
||||
Uint8 which; /* The joystick device index */
|
||||
Uint8 hat; /* The joystick hat index */
|
||||
Uint8 value; /* The hat position value:
|
||||
SDL_HAT_LEFTUP SDL_HAT_UP SDL_HAT_RIGHTUP
|
||||
SDL_HAT_LEFT SDL_HAT_CENTERED SDL_HAT_RIGHT
|
||||
SDL_HAT_LEFTDOWN SDL_HAT_DOWN SDL_HAT_RIGHTDOWN
|
||||
Note that zero means the POV is centered.
|
||||
*/
|
||||
} SDL_JoyHatEvent;
|
||||
|
||||
/* Joystick button event structure */
|
||||
typedef struct SDL_JoyButtonEvent {
|
||||
Uint8 type; /* SDL_JOYBUTTONDOWN or SDL_JOYBUTTONUP */
|
||||
Uint8 which; /* The joystick device index */
|
||||
Uint8 button; /* The joystick button index */
|
||||
Uint8 state; /* SDL_PRESSED or SDL_RELEASED */
|
||||
} SDL_JoyButtonEvent;
|
||||
|
||||
/* The "window resized" event
|
||||
When you get this event, you are responsible for setting a new video
|
||||
mode with the new width and height.
|
||||
*/
|
||||
typedef struct SDL_ResizeEvent {
|
||||
Uint8 type; /* SDL_VIDEORESIZE */
|
||||
int w; /* New width */
|
||||
int h; /* New height */
|
||||
} SDL_ResizeEvent;
|
||||
|
||||
/* The "screen redraw" event */
|
||||
typedef struct SDL_ExposeEvent {
|
||||
Uint8 type; /* SDL_VIDEOEXPOSE */
|
||||
} SDL_ExposeEvent;
|
||||
|
||||
/* The "quit requested" event */
|
||||
typedef struct SDL_QuitEvent {
|
||||
Uint8 type; /* SDL_QUIT */
|
||||
} SDL_QuitEvent;
|
||||
|
||||
/* A user-defined event type */
|
||||
typedef struct SDL_UserEvent {
|
||||
Uint8 type; /* SDL_USEREVENT through SDL_NUMEVENTS-1 */
|
||||
int code; /* User defined event code */
|
||||
void *data1; /* User defined data pointer */
|
||||
void *data2; /* User defined data pointer */
|
||||
} SDL_UserEvent;
|
||||
|
||||
/* If you want to use this event, you should include SDL_syswm.h */
|
||||
struct SDL_SysWMmsg;
|
||||
typedef struct SDL_SysWMmsg SDL_SysWMmsg;
|
||||
typedef struct SDL_SysWMEvent {
|
||||
Uint8 type;
|
||||
SDL_SysWMmsg *msg;
|
||||
} SDL_SysWMEvent;
|
||||
|
||||
/* General event structure */
|
||||
typedef union SDL_Event {
|
||||
Uint8 type;
|
||||
SDL_ActiveEvent active;
|
||||
SDL_KeyboardEvent key;
|
||||
SDL_MouseMotionEvent motion;
|
||||
SDL_MouseButtonEvent button;
|
||||
SDL_JoyAxisEvent jaxis;
|
||||
SDL_JoyBallEvent jball;
|
||||
SDL_JoyHatEvent jhat;
|
||||
SDL_JoyButtonEvent jbutton;
|
||||
SDL_ResizeEvent resize;
|
||||
SDL_ExposeEvent expose;
|
||||
SDL_QuitEvent quit;
|
||||
SDL_UserEvent user;
|
||||
SDL_SysWMEvent syswm;
|
||||
} SDL_Event;
|
||||
|
||||
|
||||
/* Function prototypes */
|
||||
|
||||
/* Pumps the event loop, gathering events from the input devices.
|
||||
This function updates the event queue and internal input device state.
|
||||
This should only be run in the thread that sets the video mode.
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_PumpEvents(void);
|
||||
|
||||
/* Checks the event queue for messages and optionally returns them.
|
||||
If 'action' is SDL_ADDEVENT, up to 'numevents' events will be added to
|
||||
the back of the event queue.
|
||||
If 'action' is SDL_PEEKEVENT, up to 'numevents' events at the front
|
||||
of the event queue, matching 'mask', will be returned and will not
|
||||
be removed from the queue.
|
||||
If 'action' is SDL_GETEVENT, up to 'numevents' events at the front
|
||||
of the event queue, matching 'mask', will be returned and will be
|
||||
removed from the queue.
|
||||
This function returns the number of events actually stored, or -1
|
||||
if there was an error. This function is thread-safe.
|
||||
*/
|
||||
typedef enum {
|
||||
SDL_ADDEVENT,
|
||||
SDL_PEEKEVENT,
|
||||
SDL_GETEVENT
|
||||
} SDL_eventaction;
|
||||
/* */
|
||||
extern DECLSPEC int SDLCALL SDL_PeepEvents(SDL_Event *events, int numevents,
|
||||
SDL_eventaction action, Uint32 mask);
|
||||
|
||||
/* Polls for currently pending events, and returns 1 if there are any pending
|
||||
events, or 0 if there are none available. If 'event' is not NULL, the next
|
||||
event is removed from the queue and stored in that area.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_PollEvent(SDL_Event *event);
|
||||
|
||||
/* Waits indefinitely for the next available event, returning 1, or 0 if there
|
||||
was an error while waiting for events. If 'event' is not NULL, the next
|
||||
event is removed from the queue and stored in that area.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_WaitEvent(SDL_Event *event);
|
||||
|
||||
/* Add an event to the event queue.
|
||||
This function returns 0 on success, or -1 if the event queue was full
|
||||
or there was some other error.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_PushEvent(SDL_Event *event);
|
||||
|
||||
/*
|
||||
This function sets up a filter to process all events before they
|
||||
change internal state and are posted to the internal event queue.
|
||||
|
||||
The filter is protypted as:
|
||||
*/
|
||||
typedef int (SDLCALL *SDL_EventFilter)(const SDL_Event *event);
|
||||
/*
|
||||
If the filter returns 1, then the event will be added to the internal queue.
|
||||
If it returns 0, then the event will be dropped from the queue, but the
|
||||
internal state will still be updated. This allows selective filtering of
|
||||
dynamically arriving events.
|
||||
|
||||
WARNING: Be very careful of what you do in the event filter function, as
|
||||
it may run in a different thread!
|
||||
|
||||
There is one caveat when dealing with the SDL_QUITEVENT event type. The
|
||||
event filter is only called when the window manager desires to close the
|
||||
application window. If the event filter returns 1, then the window will
|
||||
be closed, otherwise the window will remain open if possible.
|
||||
If the quit event is generated by an interrupt signal, it will bypass the
|
||||
internal queue and be delivered to the application at the next event poll.
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_SetEventFilter(SDL_EventFilter filter);
|
||||
|
||||
/*
|
||||
Return the current event filter - can be used to "chain" filters.
|
||||
If there is no event filter set, this function returns NULL.
|
||||
*/
|
||||
extern DECLSPEC SDL_EventFilter SDLCALL SDL_GetEventFilter(void);
|
||||
|
||||
/*
|
||||
This function allows you to set the state of processing certain events.
|
||||
If 'state' is set to SDL_IGNORE, that event will be automatically dropped
|
||||
from the event queue and will not event be filtered.
|
||||
If 'state' is set to SDL_ENABLE, that event will be processed normally.
|
||||
If 'state' is set to SDL_QUERY, SDL_EventState() will return the
|
||||
current processing state of the specified event.
|
||||
*/
|
||||
#define SDL_QUERY -1
|
||||
#define SDL_IGNORE 0
|
||||
#define SDL_DISABLE 0
|
||||
#define SDL_ENABLE 1
|
||||
extern DECLSPEC Uint8 SDLCALL SDL_EventState(Uint8 type, int state);
|
||||
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* _SDL_events_h */
|
||||
@@ -1,24 +0,0 @@
|
||||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2006 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
/* DEPRECATED */
|
||||
#include "SDL_stdinc.h"
|
||||
@@ -1,167 +0,0 @@
|
||||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2006 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
/* Include file for SDL joystick event handling */
|
||||
|
||||
#ifndef _SDL_joystick_h
|
||||
#define _SDL_joystick_h
|
||||
|
||||
#include "SDL_stdinc.h"
|
||||
#include "SDL_error.h"
|
||||
|
||||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* In order to use these functions, SDL_Init() must have been called
|
||||
with the SDL_INIT_JOYSTICK flag. This causes SDL to scan the system
|
||||
for joysticks, and load appropriate drivers.
|
||||
*/
|
||||
|
||||
/* The joystick structure used to identify an SDL joystick */
|
||||
struct _SDL_Joystick;
|
||||
typedef struct _SDL_Joystick SDL_Joystick;
|
||||
|
||||
|
||||
/* Function prototypes */
|
||||
/*
|
||||
* Count the number of joysticks attached to the system
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_NumJoysticks(void);
|
||||
|
||||
/*
|
||||
* Get the implementation dependent name of a joystick.
|
||||
* This can be called before any joysticks are opened.
|
||||
* If no name can be found, this function returns NULL.
|
||||
*/
|
||||
extern DECLSPEC const char * SDLCALL SDL_JoystickName(int device_index);
|
||||
|
||||
/*
|
||||
* Open a joystick for use - the index passed as an argument refers to
|
||||
* the N'th joystick on the system. This index is the value which will
|
||||
* identify this joystick in future joystick events.
|
||||
*
|
||||
* This function returns a joystick identifier, or NULL if an error occurred.
|
||||
*/
|
||||
extern DECLSPEC SDL_Joystick * SDLCALL SDL_JoystickOpen(int device_index);
|
||||
|
||||
/*
|
||||
* Returns 1 if the joystick has been opened, or 0 if it has not.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_JoystickOpened(int device_index);
|
||||
|
||||
/*
|
||||
* Get the device index of an opened joystick.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_JoystickIndex(SDL_Joystick *joystick);
|
||||
|
||||
/*
|
||||
* Get the number of general axis controls on a joystick
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_JoystickNumAxes(SDL_Joystick *joystick);
|
||||
|
||||
/*
|
||||
* Get the number of trackballs on a joystick
|
||||
* Joystick trackballs have only relative motion events associated
|
||||
* with them and their state cannot be polled.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_JoystickNumBalls(SDL_Joystick *joystick);
|
||||
|
||||
/*
|
||||
* Get the number of POV hats on a joystick
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_JoystickNumHats(SDL_Joystick *joystick);
|
||||
|
||||
/*
|
||||
* Get the number of buttons on a joystick
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_JoystickNumButtons(SDL_Joystick *joystick);
|
||||
|
||||
/*
|
||||
* Update the current state of the open joysticks.
|
||||
* This is called automatically by the event loop if any joystick
|
||||
* events are enabled.
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_JoystickUpdate(void);
|
||||
|
||||
/*
|
||||
* Enable/disable joystick event polling.
|
||||
* If joystick events are disabled, you must call SDL_JoystickUpdate()
|
||||
* yourself and check the state of the joystick when you want joystick
|
||||
* information.
|
||||
* The state can be one of SDL_QUERY, SDL_ENABLE or SDL_IGNORE.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_JoystickEventState(int state);
|
||||
|
||||
/*
|
||||
* Get the current state of an axis control on a joystick
|
||||
* The state is a value ranging from -32768 to 32767.
|
||||
* The axis indices start at index 0.
|
||||
*/
|
||||
extern DECLSPEC Sint16 SDLCALL SDL_JoystickGetAxis(SDL_Joystick *joystick, int axis);
|
||||
|
||||
/*
|
||||
* Get the current state of a POV hat on a joystick
|
||||
* The return value is one of the following positions:
|
||||
*/
|
||||
#define SDL_HAT_CENTERED 0x00
|
||||
#define SDL_HAT_UP 0x01
|
||||
#define SDL_HAT_RIGHT 0x02
|
||||
#define SDL_HAT_DOWN 0x04
|
||||
#define SDL_HAT_LEFT 0x08
|
||||
#define SDL_HAT_RIGHTUP (SDL_HAT_RIGHT|SDL_HAT_UP)
|
||||
#define SDL_HAT_RIGHTDOWN (SDL_HAT_RIGHT|SDL_HAT_DOWN)
|
||||
#define SDL_HAT_LEFTUP (SDL_HAT_LEFT|SDL_HAT_UP)
|
||||
#define SDL_HAT_LEFTDOWN (SDL_HAT_LEFT|SDL_HAT_DOWN)
|
||||
/*
|
||||
* The hat indices start at index 0.
|
||||
*/
|
||||
extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetHat(SDL_Joystick *joystick, int hat);
|
||||
|
||||
/*
|
||||
* Get the ball axis change since the last poll
|
||||
* This returns 0, or -1 if you passed it invalid parameters.
|
||||
* The ball indices start at index 0.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_JoystickGetBall(SDL_Joystick *joystick, int ball, int *dx, int *dy);
|
||||
|
||||
/*
|
||||
* Get the current state of a button on a joystick
|
||||
* The button indices start at index 0.
|
||||
*/
|
||||
extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetButton(SDL_Joystick *joystick, int button);
|
||||
|
||||
/*
|
||||
* Close a joystick previously opened with SDL_JoystickOpen()
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_JoystickClose(SDL_Joystick *joystick);
|
||||
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* _SDL_joystick_h */
|
||||
@@ -1,121 +0,0 @@
|
||||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2006 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
/* Include file for SDL keyboard event handling */
|
||||
|
||||
#ifndef _SDL_keyboard_h
|
||||
#define _SDL_keyboard_h
|
||||
|
||||
#include "SDL_stdinc.h"
|
||||
#include "SDL_error.h"
|
||||
#include "SDL_keysym.h"
|
||||
|
||||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Keysym structure
|
||||
- The scancode is hardware dependent, and should not be used by general
|
||||
applications. If no hardware scancode is available, it will be 0.
|
||||
|
||||
- The 'unicode' translated character is only available when character
|
||||
translation is enabled by the SDL_EnableUNICODE() API. If non-zero,
|
||||
this is a UNICODE character corresponding to the keypress. If the
|
||||
high 9 bits of the character are 0, then this maps to the equivalent
|
||||
ASCII character:
|
||||
char ch;
|
||||
if ( (keysym.unicode & 0xFF80) == 0 ) {
|
||||
ch = keysym.unicode & 0x7F;
|
||||
} else {
|
||||
An international character..
|
||||
}
|
||||
*/
|
||||
typedef struct SDL_keysym {
|
||||
Uint8 scancode; /* hardware specific scancode */
|
||||
SDLKey sym; /* SDL virtual keysym */
|
||||
SDLMod mod; /* current key modifiers */
|
||||
Uint16 unicode; /* translated character */
|
||||
} SDL_keysym;
|
||||
|
||||
/* This is the mask which refers to all hotkey bindings */
|
||||
#define SDL_ALL_HOTKEYS 0xFFFFFFFF
|
||||
|
||||
/* Function prototypes */
|
||||
/*
|
||||
* Enable/Disable UNICODE translation of keyboard input.
|
||||
* This translation has some overhead, so translation defaults off.
|
||||
* If 'enable' is 1, translation is enabled.
|
||||
* If 'enable' is 0, translation is disabled.
|
||||
* If 'enable' is -1, the translation state is not changed.
|
||||
* It returns the previous state of keyboard translation.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_EnableUNICODE(int enable);
|
||||
|
||||
/*
|
||||
* Enable/Disable keyboard repeat. Keyboard repeat defaults to off.
|
||||
* 'delay' is the initial delay in ms between the time when a key is
|
||||
* pressed, and keyboard repeat begins.
|
||||
* 'interval' is the time in ms between keyboard repeat events.
|
||||
*/
|
||||
#define SDL_DEFAULT_REPEAT_DELAY 500
|
||||
#define SDL_DEFAULT_REPEAT_INTERVAL 30
|
||||
/*
|
||||
* If 'delay' is set to 0, keyboard repeat is disabled.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_EnableKeyRepeat(int delay, int interval);
|
||||
extern DECLSPEC void SDLCALL SDL_GetKeyRepeat(int *delay, int *interval);
|
||||
|
||||
/*
|
||||
* Get a snapshot of the current state of the keyboard.
|
||||
* Returns an array of keystates, indexed by the SDLK_* syms.
|
||||
* Used:
|
||||
* Uint8 *keystate = SDL_GetKeyState(NULL);
|
||||
* if ( keystate[SDLK_RETURN] ) ... <RETURN> is pressed.
|
||||
*/
|
||||
extern DECLSPEC Uint8 * SDLCALL SDL_GetKeyState(int *numkeys);
|
||||
|
||||
/*
|
||||
* Get the current key modifier state
|
||||
*/
|
||||
extern DECLSPEC SDLMod SDLCALL SDL_GetModState(void);
|
||||
|
||||
/*
|
||||
* Set the current key modifier state
|
||||
* This does not change the keyboard state, only the key modifier flags.
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_SetModState(SDLMod modstate);
|
||||
|
||||
/*
|
||||
* Get the name of an SDL virtual keysym
|
||||
*/
|
||||
extern DECLSPEC char * SDLCALL SDL_GetKeyName(SDLKey key);
|
||||
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* _SDL_keyboard_h */
|
||||
@@ -1,311 +0,0 @@
|
||||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2006 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
#ifndef _SDL_keysym_h
|
||||
#define _SDL_keysym_h
|
||||
|
||||
/* What we really want is a mapping of every raw key on the keyboard.
|
||||
To support international keyboards, we use the range 0xA1 - 0xFF
|
||||
as international virtual keycodes. We'll follow in the footsteps of X11...
|
||||
The names of the keys
|
||||
*/
|
||||
|
||||
typedef enum {
|
||||
/* The keyboard syms have been cleverly chosen to map to ASCII */
|
||||
SDLK_UNKNOWN = 0,
|
||||
SDLK_FIRST = 0,
|
||||
SDLK_BACKSPACE = 8,
|
||||
SDLK_TAB = 9,
|
||||
SDLK_CLEAR = 12,
|
||||
SDLK_RETURN = 13,
|
||||
SDLK_PAUSE = 19,
|
||||
SDLK_ESCAPE = 27,
|
||||
SDLK_SPACE = 32,
|
||||
SDLK_EXCLAIM = 33,
|
||||
SDLK_QUOTEDBL = 34,
|
||||
SDLK_HASH = 35,
|
||||
SDLK_DOLLAR = 36,
|
||||
SDLK_AMPERSAND = 38,
|
||||
SDLK_QUOTE = 39,
|
||||
SDLK_LEFTPAREN = 40,
|
||||
SDLK_RIGHTPAREN = 41,
|
||||
SDLK_ASTERISK = 42,
|
||||
SDLK_PLUS = 43,
|
||||
SDLK_COMMA = 44,
|
||||
SDLK_MINUS = 45,
|
||||
SDLK_PERIOD = 46,
|
||||
SDLK_SLASH = 47,
|
||||
SDLK_0 = 48,
|
||||
SDLK_1 = 49,
|
||||
SDLK_2 = 50,
|
||||
SDLK_3 = 51,
|
||||
SDLK_4 = 52,
|
||||
SDLK_5 = 53,
|
||||
SDLK_6 = 54,
|
||||
SDLK_7 = 55,
|
||||
SDLK_8 = 56,
|
||||
SDLK_9 = 57,
|
||||
SDLK_COLON = 58,
|
||||
SDLK_SEMICOLON = 59,
|
||||
SDLK_LESS = 60,
|
||||
SDLK_EQUALS = 61,
|
||||
SDLK_GREATER = 62,
|
||||
SDLK_QUESTION = 63,
|
||||
SDLK_AT = 64,
|
||||
/*
|
||||
Skip uppercase letters
|
||||
*/
|
||||
SDLK_LEFTBRACKET = 91,
|
||||
SDLK_BACKSLASH = 92,
|
||||
SDLK_RIGHTBRACKET = 93,
|
||||
SDLK_CARET = 94,
|
||||
SDLK_UNDERSCORE = 95,
|
||||
SDLK_BACKQUOTE = 96,
|
||||
SDLK_a = 97,
|
||||
SDLK_b = 98,
|
||||
SDLK_c = 99,
|
||||
SDLK_d = 100,
|
||||
SDLK_e = 101,
|
||||
SDLK_f = 102,
|
||||
SDLK_g = 103,
|
||||
SDLK_h = 104,
|
||||
SDLK_i = 105,
|
||||
SDLK_j = 106,
|
||||
SDLK_k = 107,
|
||||
SDLK_l = 108,
|
||||
SDLK_m = 109,
|
||||
SDLK_n = 110,
|
||||
SDLK_o = 111,
|
||||
SDLK_p = 112,
|
||||
SDLK_q = 113,
|
||||
SDLK_r = 114,
|
||||
SDLK_s = 115,
|
||||
SDLK_t = 116,
|
||||
SDLK_u = 117,
|
||||
SDLK_v = 118,
|
||||
SDLK_w = 119,
|
||||
SDLK_x = 120,
|
||||
SDLK_y = 121,
|
||||
SDLK_z = 122,
|
||||
SDLK_DELETE = 127,
|
||||
/* End of ASCII mapped keysyms */
|
||||
|
||||
/* International keyboard syms */
|
||||
SDLK_WORLD_0 = 160, /* 0xA0 */
|
||||
SDLK_WORLD_1 = 161,
|
||||
SDLK_WORLD_2 = 162,
|
||||
SDLK_WORLD_3 = 163,
|
||||
SDLK_WORLD_4 = 164,
|
||||
SDLK_WORLD_5 = 165,
|
||||
SDLK_WORLD_6 = 166,
|
||||
SDLK_WORLD_7 = 167,
|
||||
SDLK_WORLD_8 = 168,
|
||||
SDLK_WORLD_9 = 169,
|
||||
SDLK_WORLD_10 = 170,
|
||||
SDLK_WORLD_11 = 171,
|
||||
SDLK_WORLD_12 = 172,
|
||||
SDLK_WORLD_13 = 173,
|
||||
SDLK_WORLD_14 = 174,
|
||||
SDLK_WORLD_15 = 175,
|
||||
SDLK_WORLD_16 = 176,
|
||||
SDLK_WORLD_17 = 177,
|
||||
SDLK_WORLD_18 = 178,
|
||||
SDLK_WORLD_19 = 179,
|
||||
SDLK_WORLD_20 = 180,
|
||||
SDLK_WORLD_21 = 181,
|
||||
SDLK_WORLD_22 = 182,
|
||||
SDLK_WORLD_23 = 183,
|
||||
SDLK_WORLD_24 = 184,
|
||||
SDLK_WORLD_25 = 185,
|
||||
SDLK_WORLD_26 = 186,
|
||||
SDLK_WORLD_27 = 187,
|
||||
SDLK_WORLD_28 = 188,
|
||||
SDLK_WORLD_29 = 189,
|
||||
SDLK_WORLD_30 = 190,
|
||||
SDLK_WORLD_31 = 191,
|
||||
SDLK_WORLD_32 = 192,
|
||||
SDLK_WORLD_33 = 193,
|
||||
SDLK_WORLD_34 = 194,
|
||||
SDLK_WORLD_35 = 195,
|
||||
SDLK_WORLD_36 = 196,
|
||||
SDLK_WORLD_37 = 197,
|
||||
SDLK_WORLD_38 = 198,
|
||||
SDLK_WORLD_39 = 199,
|
||||
SDLK_WORLD_40 = 200,
|
||||
SDLK_WORLD_41 = 201,
|
||||
SDLK_WORLD_42 = 202,
|
||||
SDLK_WORLD_43 = 203,
|
||||
SDLK_WORLD_44 = 204,
|
||||
SDLK_WORLD_45 = 205,
|
||||
SDLK_WORLD_46 = 206,
|
||||
SDLK_WORLD_47 = 207,
|
||||
SDLK_WORLD_48 = 208,
|
||||
SDLK_WORLD_49 = 209,
|
||||
SDLK_WORLD_50 = 210,
|
||||
SDLK_WORLD_51 = 211,
|
||||
SDLK_WORLD_52 = 212,
|
||||
SDLK_WORLD_53 = 213,
|
||||
SDLK_WORLD_54 = 214,
|
||||
SDLK_WORLD_55 = 215,
|
||||
SDLK_WORLD_56 = 216,
|
||||
SDLK_WORLD_57 = 217,
|
||||
SDLK_WORLD_58 = 218,
|
||||
SDLK_WORLD_59 = 219,
|
||||
SDLK_WORLD_60 = 220,
|
||||
SDLK_WORLD_61 = 221,
|
||||
SDLK_WORLD_62 = 222,
|
||||
SDLK_WORLD_63 = 223,
|
||||
SDLK_WORLD_64 = 224,
|
||||
SDLK_WORLD_65 = 225,
|
||||
SDLK_WORLD_66 = 226,
|
||||
SDLK_WORLD_67 = 227,
|
||||
SDLK_WORLD_68 = 228,
|
||||
SDLK_WORLD_69 = 229,
|
||||
SDLK_WORLD_70 = 230,
|
||||
SDLK_WORLD_71 = 231,
|
||||
SDLK_WORLD_72 = 232,
|
||||
SDLK_WORLD_73 = 233,
|
||||
SDLK_WORLD_74 = 234,
|
||||
SDLK_WORLD_75 = 235,
|
||||
SDLK_WORLD_76 = 236,
|
||||
SDLK_WORLD_77 = 237,
|
||||
SDLK_WORLD_78 = 238,
|
||||
SDLK_WORLD_79 = 239,
|
||||
SDLK_WORLD_80 = 240,
|
||||
SDLK_WORLD_81 = 241,
|
||||
SDLK_WORLD_82 = 242,
|
||||
SDLK_WORLD_83 = 243,
|
||||
SDLK_WORLD_84 = 244,
|
||||
SDLK_WORLD_85 = 245,
|
||||
SDLK_WORLD_86 = 246,
|
||||
SDLK_WORLD_87 = 247,
|
||||
SDLK_WORLD_88 = 248,
|
||||
SDLK_WORLD_89 = 249,
|
||||
SDLK_WORLD_90 = 250,
|
||||
SDLK_WORLD_91 = 251,
|
||||
SDLK_WORLD_92 = 252,
|
||||
SDLK_WORLD_93 = 253,
|
||||
SDLK_WORLD_94 = 254,
|
||||
SDLK_WORLD_95 = 255, /* 0xFF */
|
||||
|
||||
/* Numeric keypad */
|
||||
SDLK_KP0 = 256,
|
||||
SDLK_KP1 = 257,
|
||||
SDLK_KP2 = 258,
|
||||
SDLK_KP3 = 259,
|
||||
SDLK_KP4 = 260,
|
||||
SDLK_KP5 = 261,
|
||||
SDLK_KP6 = 262,
|
||||
SDLK_KP7 = 263,
|
||||
SDLK_KP8 = 264,
|
||||
SDLK_KP9 = 265,
|
||||
SDLK_KP_PERIOD = 266,
|
||||
SDLK_KP_DIVIDE = 267,
|
||||
SDLK_KP_MULTIPLY = 268,
|
||||
SDLK_KP_MINUS = 269,
|
||||
SDLK_KP_PLUS = 270,
|
||||
SDLK_KP_ENTER = 271,
|
||||
SDLK_KP_EQUALS = 272,
|
||||
|
||||
/* Arrows + Home/End pad */
|
||||
SDLK_UP = 273,
|
||||
SDLK_DOWN = 274,
|
||||
SDLK_RIGHT = 275,
|
||||
SDLK_LEFT = 276,
|
||||
SDLK_INSERT = 277,
|
||||
SDLK_HOME = 278,
|
||||
SDLK_END = 279,
|
||||
SDLK_PAGEUP = 280,
|
||||
SDLK_PAGEDOWN = 281,
|
||||
|
||||
/* Function keys */
|
||||
SDLK_F1 = 282,
|
||||
SDLK_F2 = 283,
|
||||
SDLK_F3 = 284,
|
||||
SDLK_F4 = 285,
|
||||
SDLK_F5 = 286,
|
||||
SDLK_F6 = 287,
|
||||
SDLK_F7 = 288,
|
||||
SDLK_F8 = 289,
|
||||
SDLK_F9 = 290,
|
||||
SDLK_F10 = 291,
|
||||
SDLK_F11 = 292,
|
||||
SDLK_F12 = 293,
|
||||
SDLK_F13 = 294,
|
||||
SDLK_F14 = 295,
|
||||
SDLK_F15 = 296,
|
||||
|
||||
/* Key state modifier keys */
|
||||
SDLK_NUMLOCK = 300,
|
||||
SDLK_CAPSLOCK = 301,
|
||||
SDLK_SCROLLOCK = 302,
|
||||
SDLK_RSHIFT = 303,
|
||||
SDLK_LSHIFT = 304,
|
||||
SDLK_RCTRL = 305,
|
||||
SDLK_LCTRL = 306,
|
||||
SDLK_RALT = 307,
|
||||
SDLK_LALT = 308,
|
||||
SDLK_RMETA = 309,
|
||||
SDLK_LMETA = 310,
|
||||
SDLK_LSUPER = 311, /* Left "Windows" key */
|
||||
SDLK_RSUPER = 312, /* Right "Windows" key */
|
||||
SDLK_MODE = 313, /* "Alt Gr" key */
|
||||
SDLK_COMPOSE = 314, /* Multi-key compose key */
|
||||
|
||||
/* Miscellaneous function keys */
|
||||
SDLK_HELP = 315,
|
||||
SDLK_PRINT = 316,
|
||||
SDLK_SYSREQ = 317,
|
||||
SDLK_BREAK = 318,
|
||||
SDLK_MENU = 319,
|
||||
SDLK_POWER = 320, /* Power Macintosh power key */
|
||||
SDLK_EURO = 321, /* Some european keyboards */
|
||||
SDLK_UNDO = 322, /* Atari keyboard has Undo */
|
||||
|
||||
/* Add any other keys here */
|
||||
|
||||
SDLK_LAST
|
||||
} SDLKey;
|
||||
|
||||
/* Enumeration of valid key mods (possibly OR'd together) */
|
||||
typedef enum {
|
||||
KMOD_NONE = 0x0000,
|
||||
KMOD_LSHIFT= 0x0001,
|
||||
KMOD_RSHIFT= 0x0002,
|
||||
KMOD_LCTRL = 0x0040,
|
||||
KMOD_RCTRL = 0x0080,
|
||||
KMOD_LALT = 0x0100,
|
||||
KMOD_RALT = 0x0200,
|
||||
KMOD_LMETA = 0x0400,
|
||||
KMOD_RMETA = 0x0800,
|
||||
KMOD_NUM = 0x1000,
|
||||
KMOD_CAPS = 0x2000,
|
||||
KMOD_MODE = 0x4000,
|
||||
KMOD_RESERVED = 0x8000
|
||||
} SDLMod;
|
||||
|
||||
#define KMOD_CTRL (KMOD_LCTRL|KMOD_RCTRL)
|
||||
#define KMOD_SHIFT (KMOD_LSHIFT|KMOD_RSHIFT)
|
||||
#define KMOD_ALT (KMOD_LALT|KMOD_RALT)
|
||||
#define KMOD_META (KMOD_LMETA|KMOD_RMETA)
|
||||
|
||||
#endif /* _SDL_keysym_h */
|
||||
@@ -1,74 +0,0 @@
|
||||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2006 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
/* System dependent library loading routines */
|
||||
|
||||
/* Some things to keep in mind:
|
||||
- These functions only work on C function names. Other languages may
|
||||
have name mangling and intrinsic language support that varies from
|
||||
compiler to compiler.
|
||||
- Make sure you declare your function pointers with the same calling
|
||||
convention as the actual library function. Your code will crash
|
||||
mysteriously if you do not do this.
|
||||
- Avoid namespace collisions. If you load a symbol from the library,
|
||||
it is not defined whether or not it goes into the global symbol
|
||||
namespace for the application. If it does and it conflicts with
|
||||
symbols in your code or other shared libraries, you will not get
|
||||
the results you expect. :)
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _SDL_loadso_h
|
||||
#define _SDL_loadso_h
|
||||
|
||||
#include "SDL_stdinc.h"
|
||||
#include "SDL_error.h"
|
||||
|
||||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* This function dynamically loads a shared object and returns a pointer
|
||||
* to the object handle (or NULL if there was an error).
|
||||
* The 'sofile' parameter is a system dependent name of the object file.
|
||||
*/
|
||||
extern DECLSPEC void * SDLCALL SDL_LoadObject(const char *sofile);
|
||||
|
||||
/* Given an object handle, this function looks up the address of the
|
||||
* named function in the shared object and returns it. This address
|
||||
* is no longer valid after calling SDL_UnloadObject().
|
||||
*/
|
||||
extern DECLSPEC void * SDLCALL SDL_LoadFunction(void *handle, const char *name);
|
||||
|
||||
/* Unload a shared object from memory */
|
||||
extern DECLSPEC void SDLCALL SDL_UnloadObject(void *handle);
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* _SDL_loadso_h */
|
||||
@@ -1,98 +0,0 @@
|
||||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2006 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
#ifndef _SDL_main_h
|
||||
#define _SDL_main_h
|
||||
|
||||
#include "SDL_stdinc.h"
|
||||
|
||||
/* Redefine main() on Win32 and MacOS so that it is called by winmain.c */
|
||||
|
||||
#if defined(__WIN32__) || \
|
||||
(defined(__MWERKS__) && !defined(__BEOS__)) || \
|
||||
defined(__MACOS__) || defined(__MACOSX__) || \
|
||||
defined(__SYMBIAN32__) || defined(QWS)
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define C_LINKAGE "C"
|
||||
#else
|
||||
#define C_LINKAGE
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/* The application's main() function must be called with C linkage,
|
||||
and should be declared like this:
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
#endif
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
}
|
||||
*/
|
||||
#define main SDL_main
|
||||
|
||||
/* The prototype for the application's main() function */
|
||||
extern C_LINKAGE int SDL_main(int argc, char *argv[]);
|
||||
|
||||
|
||||
/* From the SDL library code -- needed for registering the app on Win32 */
|
||||
#ifdef __WIN32__
|
||||
|
||||
#include "begin_code.h"
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* This should be called from your WinMain() function, if any */
|
||||
extern DECLSPEC void SDLCALL SDL_SetModuleHandle(void *hInst);
|
||||
/* This can also be called, but is no longer necessary */
|
||||
extern DECLSPEC int SDLCALL SDL_RegisterApp(char *name, Uint32 style, void *hInst);
|
||||
/* This can also be called, but is no longer necessary (SDL_Quit calls it) */
|
||||
extern DECLSPEC void SDLCALL SDL_UnregisterApp(void);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
#endif
|
||||
|
||||
/* From the SDL library code -- needed for registering QuickDraw on MacOS */
|
||||
#if defined(__MACOS__)
|
||||
|
||||
#include "begin_code.h"
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Forward declaration so we don't need to include QuickDraw.h */
|
||||
struct QDGlobals;
|
||||
|
||||
/* This should be called from your main() function, if any */
|
||||
extern DECLSPEC void SDLCALL SDL_InitQuickDraw(struct QDGlobals *the_qd);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
#endif
|
||||
|
||||
#endif /* Need to redefine main()? */
|
||||
|
||||
#endif /* _SDL_main_h */
|
||||
@@ -1,136 +0,0 @@
|
||||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2006 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
/* Include file for SDL mouse event handling */
|
||||
|
||||
#ifndef _SDL_mouse_h
|
||||
#define _SDL_mouse_h
|
||||
|
||||
#include "SDL_stdinc.h"
|
||||
#include "SDL_error.h"
|
||||
#include "SDL_video.h"
|
||||
|
||||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct WMcursor WMcursor; /* Implementation dependent */
|
||||
typedef struct SDL_Cursor {
|
||||
SDL_Rect area; /* The area of the mouse cursor */
|
||||
Sint16 hot_x, hot_y; /* The "tip" of the cursor */
|
||||
Uint8 *data; /* B/W cursor data */
|
||||
Uint8 *mask; /* B/W cursor mask */
|
||||
Uint8 *save[2]; /* Place to save cursor area */
|
||||
WMcursor *wm_cursor; /* Window-manager cursor */
|
||||
} SDL_Cursor;
|
||||
|
||||
/* Function prototypes */
|
||||
/*
|
||||
* Retrieve the current state of the mouse.
|
||||
* The current button state is returned as a button bitmask, which can
|
||||
* be tested using the SDL_BUTTON(X) macros, and x and y are set to the
|
||||
* current mouse cursor position. You can pass NULL for either x or y.
|
||||
*/
|
||||
extern DECLSPEC Uint8 SDLCALL SDL_GetMouseState(int *x, int *y);
|
||||
|
||||
/*
|
||||
* Retrieve the current state of the mouse.
|
||||
* The current button state is returned as a button bitmask, which can
|
||||
* be tested using the SDL_BUTTON(X) macros, and x and y are set to the
|
||||
* mouse deltas since the last call to SDL_GetRelativeMouseState().
|
||||
*/
|
||||
extern DECLSPEC Uint8 SDLCALL SDL_GetRelativeMouseState(int *x, int *y);
|
||||
|
||||
/*
|
||||
* Set the position of the mouse cursor (generates a mouse motion event)
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_WarpMouse(Uint16 x, Uint16 y);
|
||||
|
||||
/*
|
||||
* Create a cursor using the specified data and mask (in MSB format).
|
||||
* The cursor width must be a multiple of 8 bits.
|
||||
*
|
||||
* The cursor is created in black and white according to the following:
|
||||
* data mask resulting pixel on screen
|
||||
* 0 1 White
|
||||
* 1 1 Black
|
||||
* 0 0 Transparent
|
||||
* 1 0 Inverted color if possible, black if not.
|
||||
*
|
||||
* Cursors created with this function must be freed with SDL_FreeCursor().
|
||||
*/
|
||||
extern DECLSPEC SDL_Cursor * SDLCALL SDL_CreateCursor
|
||||
(Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y);
|
||||
|
||||
/*
|
||||
* Set the currently active cursor to the specified one.
|
||||
* If the cursor is currently visible, the change will be immediately
|
||||
* represented on the display.
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_SetCursor(SDL_Cursor *cursor);
|
||||
|
||||
/*
|
||||
* Returns the currently active cursor.
|
||||
*/
|
||||
extern DECLSPEC SDL_Cursor * SDLCALL SDL_GetCursor(void);
|
||||
|
||||
/*
|
||||
* Deallocates a cursor created with SDL_CreateCursor().
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_FreeCursor(SDL_Cursor *cursor);
|
||||
|
||||
/*
|
||||
* Toggle whether or not the cursor is shown on the screen.
|
||||
* The cursor start off displayed, but can be turned off.
|
||||
* SDL_ShowCursor() returns 1 if the cursor was being displayed
|
||||
* before the call, or 0 if it was not. You can query the current
|
||||
* state by passing a 'toggle' value of -1.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_ShowCursor(int toggle);
|
||||
|
||||
/* Used as a mask when testing buttons in buttonstate
|
||||
Button 1: Left mouse button
|
||||
Button 2: Middle mouse button
|
||||
Button 3: Right mouse button
|
||||
Button 4: Mouse wheel up (may also be a real button)
|
||||
Button 5: Mouse wheel down (may also be a real button)
|
||||
*/
|
||||
#define SDL_BUTTON(X) (1 << ((X)-1))
|
||||
#define SDL_BUTTON_LEFT 1
|
||||
#define SDL_BUTTON_MIDDLE 2
|
||||
#define SDL_BUTTON_RIGHT 3
|
||||
#define SDL_BUTTON_WHEELUP 4
|
||||
#define SDL_BUTTON_WHEELDOWN 5
|
||||
#define SDL_BUTTON_LMASK SDL_BUTTON(SDL_BUTTON_LEFT)
|
||||
#define SDL_BUTTON_MMASK SDL_BUTTON(SDL_BUTTON_MIDDLE)
|
||||
#define SDL_BUTTON_RMASK SDL_BUTTON(SDL_BUTTON_RIGHT)
|
||||
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* _SDL_mouse_h */
|
||||
@@ -1,162 +0,0 @@
|
||||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2006 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
#ifndef _SDL_mutex_h
|
||||
#define _SDL_mutex_h
|
||||
|
||||
/* Functions to provide thread synchronization primitives
|
||||
|
||||
These are independent of the other SDL routines.
|
||||
*/
|
||||
|
||||
#include "SDL_stdinc.h"
|
||||
#include "SDL_error.h"
|
||||
|
||||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Synchronization functions which can time out return this value
|
||||
if they time out.
|
||||
*/
|
||||
#define SDL_MUTEX_TIMEDOUT 1
|
||||
|
||||
/* This is the timeout value which corresponds to never time out */
|
||||
#define SDL_MUTEX_MAXWAIT (~(Uint32)0)
|
||||
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
/* Mutex functions */
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
/* The SDL mutex structure, defined in SDL_mutex.c */
|
||||
struct SDL_mutex;
|
||||
typedef struct SDL_mutex SDL_mutex;
|
||||
|
||||
/* Create a mutex, initialized unlocked */
|
||||
extern DECLSPEC SDL_mutex * SDLCALL SDL_CreateMutex(void);
|
||||
|
||||
/* Lock the mutex (Returns 0, or -1 on error) */
|
||||
#define SDL_LockMutex(m) SDL_mutexP(m)
|
||||
extern DECLSPEC int SDLCALL SDL_mutexP(SDL_mutex *mutex);
|
||||
|
||||
/* Unlock the mutex (Returns 0, or -1 on error)
|
||||
It is an error to unlock a mutex that has not been locked by
|
||||
the current thread, and doing so results in undefined behavior.
|
||||
*/
|
||||
#define SDL_UnlockMutex(m) SDL_mutexV(m)
|
||||
extern DECLSPEC int SDLCALL SDL_mutexV(SDL_mutex *mutex);
|
||||
|
||||
/* Destroy a mutex */
|
||||
extern DECLSPEC void SDLCALL SDL_DestroyMutex(SDL_mutex *mutex);
|
||||
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
/* Semaphore functions */
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
/* The SDL semaphore structure, defined in SDL_sem.c */
|
||||
struct SDL_semaphore;
|
||||
typedef struct SDL_semaphore SDL_sem;
|
||||
|
||||
/* Create a semaphore, initialized with value, returns NULL on failure. */
|
||||
extern DECLSPEC SDL_sem * SDLCALL SDL_CreateSemaphore(Uint32 initial_value);
|
||||
|
||||
/* Destroy a semaphore */
|
||||
extern DECLSPEC void SDLCALL SDL_DestroySemaphore(SDL_sem *sem);
|
||||
|
||||
/* This function suspends the calling thread until the semaphore pointed
|
||||
* to by sem has a positive count. It then atomically decreases the semaphore
|
||||
* count.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_SemWait(SDL_sem *sem);
|
||||
|
||||
/* Non-blocking variant of SDL_SemWait(), returns 0 if the wait succeeds,
|
||||
SDL_MUTEX_TIMEDOUT if the wait would block, and -1 on error.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_SemTryWait(SDL_sem *sem);
|
||||
|
||||
/* Variant of SDL_SemWait() with a timeout in milliseconds, returns 0 if
|
||||
the wait succeeds, SDL_MUTEX_TIMEDOUT if the wait does not succeed in
|
||||
the allotted time, and -1 on error.
|
||||
On some platforms this function is implemented by looping with a delay
|
||||
of 1 ms, and so should be avoided if possible.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_SemWaitTimeout(SDL_sem *sem, Uint32 ms);
|
||||
|
||||
/* Atomically increases the semaphore's count (not blocking), returns 0,
|
||||
or -1 on error.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_SemPost(SDL_sem *sem);
|
||||
|
||||
/* Returns the current count of the semaphore */
|
||||
extern DECLSPEC Uint32 SDLCALL SDL_SemValue(SDL_sem *sem);
|
||||
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
/* Condition variable functions */
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
/* The SDL condition variable structure, defined in SDL_cond.c */
|
||||
struct SDL_cond;
|
||||
typedef struct SDL_cond SDL_cond;
|
||||
|
||||
/* Create a condition variable */
|
||||
extern DECLSPEC SDL_cond * SDLCALL SDL_CreateCond(void);
|
||||
|
||||
/* Destroy a condition variable */
|
||||
extern DECLSPEC void SDLCALL SDL_DestroyCond(SDL_cond *cond);
|
||||
|
||||
/* Restart one of the threads that are waiting on the condition variable,
|
||||
returns 0 or -1 on error.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_CondSignal(SDL_cond *cond);
|
||||
|
||||
/* Restart all threads that are waiting on the condition variable,
|
||||
returns 0 or -1 on error.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_CondBroadcast(SDL_cond *cond);
|
||||
|
||||
/* Wait on the condition variable, unlocking the provided mutex.
|
||||
The mutex must be locked before entering this function!
|
||||
The mutex is re-locked once the condition variable is signaled.
|
||||
Returns 0 when it is signaled, or -1 on error.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_CondWait(SDL_cond *cond, SDL_mutex *mut);
|
||||
|
||||
/* Waits for at most 'ms' milliseconds, and returns 0 if the condition
|
||||
variable is signaled, SDL_MUTEX_TIMEDOUT if the condition is not
|
||||
signaled in the allotted time, and -1 on error.
|
||||
On some platforms this function is implemented by looping with a delay
|
||||
of 1 ms, and so should be avoided if possible.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_CondWaitTimeout(SDL_cond *cond, SDL_mutex *mutex, Uint32 ms);
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* _SDL_mutex_h */
|
||||
@@ -1,11 +0,0 @@
|
||||
|
||||
#ifndef _SDLname_h_
|
||||
#define _SDLname_h_
|
||||
|
||||
#if defined(__STDC__) || defined(__cplusplus)
|
||||
#define NeedFunctionPrototypes 1
|
||||
#endif
|
||||
|
||||
#define SDL_NAME(X) SDL_##X
|
||||
|
||||
#endif /* _SDLname_h_ */
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,104 +0,0 @@
|
||||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2006 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
/* Try to get a standard set of platform defines */
|
||||
|
||||
#ifndef _SDL_platform_h
|
||||
#define _SDL_platform_h
|
||||
|
||||
#if defined(_AIX)
|
||||
#undef __AIX__
|
||||
#define __AIX__ 1
|
||||
#endif
|
||||
#if defined(AMIGA) || defined(__AMIGA) || defined(__amigados__)
|
||||
#undef __AMIGA__
|
||||
#define __AMIGA__ 1
|
||||
#endif
|
||||
#if defined(__BEOS__)
|
||||
#undef __BEOS__
|
||||
#define __BEOS__ 1
|
||||
#endif
|
||||
#if defined(bsdi) || defined(__bsdi) || defined(__bsdi__)
|
||||
#undef __BSDI__
|
||||
#define __BSDI__ 1
|
||||
#endif
|
||||
#if defined(_arch_dreamcast)
|
||||
#undef __DREAMCAST__
|
||||
#define __DREAMCAST__ 1
|
||||
#endif
|
||||
#if defined(__FreeBSD__) || defined(__DragonFly__)
|
||||
#undef __FREEBSD__
|
||||
#define __FREEBSD__ 1
|
||||
#endif
|
||||
#if defined(hpux) || defined(__hpux) || defined(__hpux__)
|
||||
#undef __HPUX__
|
||||
#define __HPUX__ 1
|
||||
#endif
|
||||
#if defined(sgi) || defined(__sgi) || defined(__sgi__) || defined(_SGI_SOURCE)
|
||||
#undef __IRIX__
|
||||
#define __IRIX__ 1
|
||||
#endif
|
||||
#if defined(linux) || defined(__linux) || defined(__linux__)
|
||||
#undef __LINUX__
|
||||
#define __LINUX__ 1
|
||||
#endif
|
||||
#if defined(__APPLE__)
|
||||
#undef __MACOSX__
|
||||
#define __MACOSX__ 1
|
||||
#elif defined(macintosh)
|
||||
#undef __MACOS__
|
||||
#define __MACOS__ 1
|
||||
#endif
|
||||
#if defined(__NetBSD__)
|
||||
#undef __NETBSD__
|
||||
#define __NETBSD__ 1
|
||||
#endif
|
||||
#if defined(__OpenBSD__)
|
||||
#undef __OPENBSD__
|
||||
#define __OPENBSD__ 1
|
||||
#endif
|
||||
#if defined(__OS2__)
|
||||
#undef __OS2__
|
||||
#define __OS2__ 1
|
||||
#endif
|
||||
#if defined(osf) || defined(__osf) || defined(__osf__) || defined(_OSF_SOURCE)
|
||||
#undef __OSF__
|
||||
#define __OSF__ 1
|
||||
#endif
|
||||
#if defined(__QNXNTO__)
|
||||
#undef __QNXNTO__
|
||||
#define __QNXNTO__ 1
|
||||
#endif
|
||||
#if defined(riscos) || defined(__riscos) || defined(__riscos__)
|
||||
#undef __RISCOS__
|
||||
#define __RISCOS__ 1
|
||||
#endif
|
||||
#if defined(__SVR4)
|
||||
#undef __SOLARIS__
|
||||
#define __SOLARIS__ 1
|
||||
#endif
|
||||
#if defined(WIN32) || defined(_WIN32)
|
||||
#undef __WIN32__
|
||||
#define __WIN32__ 1
|
||||
#endif
|
||||
|
||||
#endif /* _SDL_platform_h */
|
||||
@@ -1,50 +0,0 @@
|
||||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2006 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
/* Include file for SDL quit event handling */
|
||||
|
||||
#ifndef _SDL_quit_h
|
||||
#define _SDL_quit_h
|
||||
|
||||
#include "SDL_stdinc.h"
|
||||
#include "SDL_error.h"
|
||||
|
||||
/*
|
||||
An SDL_QUITEVENT is generated when the user tries to close the application
|
||||
window. If it is ignored or filtered out, the window will remain open.
|
||||
If it is not ignored or filtered, it is queued normally and the window
|
||||
is allowed to close. When the window is closed, screen updates will
|
||||
complete, but have no effect.
|
||||
|
||||
SDL_Init() installs signal handlers for SIGINT (keyboard interrupt)
|
||||
and SIGTERM (system termination request), if handlers do not already
|
||||
exist, that generate SDL_QUITEVENT events as well. There is no way
|
||||
to determine the cause of an SDL_QUITEVENT, but setting a signal
|
||||
handler in your application will override the default generation of
|
||||
quit events for that signal.
|
||||
*/
|
||||
|
||||
/* There are no functions directly affecting the quit event */
|
||||
#define SDL_QuitRequested() \
|
||||
(SDL_PumpEvents(), SDL_PeepEvents(NULL,0,SDL_PEEKEVENT,SDL_QUITMASK))
|
||||
|
||||
#endif /* _SDL_quit_h */
|
||||
@@ -1,139 +0,0 @@
|
||||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2006 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
/* This file provides a general interface for SDL to read and write
|
||||
data sources. It can easily be extended to files, memory, etc.
|
||||
*/
|
||||
|
||||
#ifndef _SDL_rwops_h
|
||||
#define _SDL_rwops_h
|
||||
|
||||
#include "SDL_stdinc.h"
|
||||
#include "SDL_error.h"
|
||||
|
||||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* This is the read/write operation structure -- very basic */
|
||||
|
||||
typedef struct SDL_RWops {
|
||||
/* Seek to 'offset' relative to whence, one of stdio's whence values:
|
||||
SEEK_SET, SEEK_CUR, SEEK_END
|
||||
Returns the final offset in the data source.
|
||||
*/
|
||||
int (SDLCALL *seek)(struct SDL_RWops *context, int offset, int whence);
|
||||
|
||||
/* Read up to 'num' objects each of size 'objsize' from the data
|
||||
source to the area pointed at by 'ptr'.
|
||||
Returns the number of objects read, or -1 if the read failed.
|
||||
*/
|
||||
int (SDLCALL *read)(struct SDL_RWops *context, void *ptr, int size, int maxnum);
|
||||
|
||||
/* Write exactly 'num' objects each of size 'objsize' from the area
|
||||
pointed at by 'ptr' to data source.
|
||||
Returns 'num', or -1 if the write failed.
|
||||
*/
|
||||
int (SDLCALL *write)(struct SDL_RWops *context, const void *ptr, int size, int num);
|
||||
|
||||
/* Close and free an allocated SDL_FSops structure */
|
||||
int (SDLCALL *close)(struct SDL_RWops *context);
|
||||
|
||||
Uint32 type;
|
||||
union {
|
||||
#ifdef __WIN32__
|
||||
struct {
|
||||
int append;
|
||||
void* h;
|
||||
} win32io;
|
||||
#endif
|
||||
#ifdef HAVE_STDIO_H
|
||||
struct {
|
||||
int autoclose;
|
||||
FILE *fp;
|
||||
} stdio;
|
||||
#endif
|
||||
struct {
|
||||
Uint8 *base;
|
||||
Uint8 *here;
|
||||
Uint8 *stop;
|
||||
} mem;
|
||||
struct {
|
||||
void *data1;
|
||||
} unknown;
|
||||
} hidden;
|
||||
|
||||
} SDL_RWops;
|
||||
|
||||
|
||||
/* Functions to create SDL_RWops structures from various data sources */
|
||||
|
||||
extern DECLSPEC SDL_RWops * SDLCALL SDL_RWFromFile(const char *file, const char *mode);
|
||||
|
||||
#ifdef HAVE_STDIO_H
|
||||
extern DECLSPEC SDL_RWops * SDLCALL SDL_RWFromFP(FILE *fp, int autoclose);
|
||||
#endif
|
||||
|
||||
extern DECLSPEC SDL_RWops * SDLCALL SDL_RWFromMem(void *mem, int size);
|
||||
extern DECLSPEC SDL_RWops * SDLCALL SDL_RWFromConstMem(const void *mem, int size);
|
||||
|
||||
extern DECLSPEC SDL_RWops * SDLCALL SDL_AllocRW(void);
|
||||
extern DECLSPEC void SDLCALL SDL_FreeRW(SDL_RWops *area);
|
||||
|
||||
#define RW_SEEK_SET 0 /* Seek from the beginning of data */
|
||||
#define RW_SEEK_CUR 1 /* Seek relative to current read point */
|
||||
#define RW_SEEK_END 2 /* Seek relative to the end of data */
|
||||
|
||||
/* Macros to easily read and write from an SDL_RWops structure */
|
||||
#define SDL_RWseek(ctx, offset, whence) (ctx)->seek(ctx, offset, whence)
|
||||
#define SDL_RWtell(ctx) (ctx)->seek(ctx, 0, RW_SEEK_CUR)
|
||||
#define SDL_RWread(ctx, ptr, size, n) (ctx)->read(ctx, ptr, size, n)
|
||||
#define SDL_RWwrite(ctx, ptr, size, n) (ctx)->write(ctx, ptr, size, n)
|
||||
#define SDL_RWclose(ctx) (ctx)->close(ctx)
|
||||
|
||||
|
||||
/* Read an item of the specified endianness and return in native format */
|
||||
extern DECLSPEC Uint16 SDLCALL SDL_ReadLE16(SDL_RWops *src);
|
||||
extern DECLSPEC Uint16 SDLCALL SDL_ReadBE16(SDL_RWops *src);
|
||||
extern DECLSPEC Uint32 SDLCALL SDL_ReadLE32(SDL_RWops *src);
|
||||
extern DECLSPEC Uint32 SDLCALL SDL_ReadBE32(SDL_RWops *src);
|
||||
extern DECLSPEC Uint64 SDLCALL SDL_ReadLE64(SDL_RWops *src);
|
||||
extern DECLSPEC Uint64 SDLCALL SDL_ReadBE64(SDL_RWops *src);
|
||||
|
||||
/* Write an item of native format to the specified endianness */
|
||||
extern DECLSPEC int SDLCALL SDL_WriteLE16(SDL_RWops *dst, Uint16 value);
|
||||
extern DECLSPEC int SDLCALL SDL_WriteBE16(SDL_RWops *dst, Uint16 value);
|
||||
extern DECLSPEC int SDLCALL SDL_WriteLE32(SDL_RWops *dst, Uint32 value);
|
||||
extern DECLSPEC int SDLCALL SDL_WriteBE32(SDL_RWops *dst, Uint32 value);
|
||||
extern DECLSPEC int SDLCALL SDL_WriteLE64(SDL_RWops *dst, Uint64 value);
|
||||
extern DECLSPEC int SDLCALL SDL_WriteBE64(SDL_RWops *dst, Uint64 value);
|
||||
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* _SDL_rwops_h */
|
||||
@@ -1,586 +0,0 @@
|
||||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2006 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
/* This is a general header that includes C language support */
|
||||
|
||||
#ifndef _SDL_stdinc_h
|
||||
#define _SDL_stdinc_h
|
||||
|
||||
#include "SDL_config.h"
|
||||
|
||||
|
||||
#ifdef HAVE_SYS_TYPES_H
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
#ifdef HAVE_STDIO_H
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
#if defined(STDC_HEADERS)
|
||||
# include <stdlib.h>
|
||||
# include <stddef.h>
|
||||
# include <stdarg.h>
|
||||
#else
|
||||
# if defined(HAVE_STDLIB_H)
|
||||
# include <stdlib.h>
|
||||
# elif defined(HAVE_MALLOC_H)
|
||||
# include <malloc.h>
|
||||
# endif
|
||||
# if defined(HAVE_STDDEF_H)
|
||||
# include <stddef.h>
|
||||
# endif
|
||||
# if defined(HAVE_STDARG_H)
|
||||
# include <stdarg.h>
|
||||
# endif
|
||||
#endif
|
||||
#ifdef HAVE_STRING_H
|
||||
# if !defined(STDC_HEADERS) && defined(HAVE_MEMORY_H)
|
||||
# include <memory.h>
|
||||
# endif
|
||||
# include <string.h>
|
||||
#endif
|
||||
#ifdef HAVE_STRINGS_H
|
||||
# include <strings.h>
|
||||
#endif
|
||||
#if defined(HAVE_INTTYPES_H)
|
||||
# include <inttypes.h>
|
||||
#elif defined(HAVE_STDINT_H)
|
||||
# include <stdint.h>
|
||||
#endif
|
||||
#ifdef HAVE_CTYPE_H
|
||||
# include <ctype.h>
|
||||
#endif
|
||||
#ifdef HAVE_ICONV_H
|
||||
# include <iconv.h>
|
||||
#endif
|
||||
|
||||
/* The number of elements in an array */
|
||||
#define SDL_arraysize(array) (sizeof(array)/sizeof(array[0]))
|
||||
#define SDL_TABLESIZE(table) SDL_arraysize(table)
|
||||
|
||||
/* Basic data types */
|
||||
typedef enum SDL_bool {
|
||||
SDL_FALSE = 0,
|
||||
SDL_TRUE = 1
|
||||
} SDL_bool;
|
||||
|
||||
typedef int8_t Sint8;
|
||||
typedef uint8_t Uint8;
|
||||
typedef int16_t Sint16;
|
||||
typedef uint16_t Uint16;
|
||||
typedef int32_t Sint32;
|
||||
typedef uint32_t Uint32;
|
||||
|
||||
#ifdef SDL_HAS_64BIT_TYPE
|
||||
typedef int64_t Sint64;
|
||||
typedef uint64_t Uint64;
|
||||
#else
|
||||
/* This is really just a hack to prevent the compiler from complaining */
|
||||
typedef struct {
|
||||
Uint32 hi;
|
||||
Uint32 lo;
|
||||
} Uint64, Sint64;
|
||||
#endif
|
||||
|
||||
/* Make sure the types really have the right sizes */
|
||||
#define SDL_COMPILE_TIME_ASSERT(name, x) \
|
||||
typedef int SDL_dummy_ ## name[(x) * 2 - 1]
|
||||
|
||||
SDL_COMPILE_TIME_ASSERT(uint8, sizeof(Uint8) == 1);
|
||||
SDL_COMPILE_TIME_ASSERT(sint8, sizeof(Sint8) == 1);
|
||||
SDL_COMPILE_TIME_ASSERT(uint16, sizeof(Uint16) == 2);
|
||||
SDL_COMPILE_TIME_ASSERT(sint16, sizeof(Sint16) == 2);
|
||||
SDL_COMPILE_TIME_ASSERT(uint32, sizeof(Uint32) == 4);
|
||||
SDL_COMPILE_TIME_ASSERT(sint32, sizeof(Sint32) == 4);
|
||||
SDL_COMPILE_TIME_ASSERT(uint64, sizeof(Uint64) == 8);
|
||||
SDL_COMPILE_TIME_ASSERT(sint64, sizeof(Sint64) == 8);
|
||||
|
||||
/* Check to make sure enums are the size of ints, for structure packing.
|
||||
For both Watcom C/C++ and Borland C/C++ the compiler option that makes
|
||||
enums having the size of an int must be enabled.
|
||||
This is "-b" for Borland C/C++ and "-ei" for Watcom C/C++ (v11).
|
||||
*/
|
||||
/* Enable enums always int in CodeWarrior (for MPW use "-enum int") */
|
||||
#ifdef __MWERKS__
|
||||
#pragma enumsalwaysint on
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
DUMMY_ENUM_VALUE
|
||||
} SDL_DUMMY_ENUM;
|
||||
|
||||
SDL_COMPILE_TIME_ASSERT(enum, sizeof(SDL_DUMMY_ENUM) == sizeof(int));
|
||||
|
||||
|
||||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_MALLOC
|
||||
#define SDL_malloc malloc
|
||||
#else
|
||||
extern DECLSPEC void * SDLCALL SDL_malloc(size_t size);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CALLOC
|
||||
#define SDL_calloc calloc
|
||||
#else
|
||||
extern DECLSPEC void * SDLCALL SDL_calloc(size_t nmemb, size_t size);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_REALLOC
|
||||
#define SDL_realloc realloc
|
||||
#else
|
||||
extern DECLSPEC void * SDLCALL SDL_realloc(void *mem, size_t size);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_FREE
|
||||
#define SDL_free free
|
||||
#else
|
||||
extern DECLSPEC void SDLCALL SDL_free(void *mem);
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_ALLOCA) && !defined(alloca)
|
||||
# if defined(HAVE_ALLOCA_H)
|
||||
# include <alloca.h>
|
||||
# elif defined(__GNUC__)
|
||||
# define alloca __builtin_alloca
|
||||
# elif defined(_MSC_VER)
|
||||
# include <malloc.h>
|
||||
# define alloca _alloca
|
||||
# elif defined(__WATCOMC__)
|
||||
# include <malloc.h>
|
||||
# elif defined(__DMC__)
|
||||
# include <stdlib.h>
|
||||
# elif defined(__AIX__)
|
||||
#pragma alloca
|
||||
# elif defined(__MRC__)
|
||||
void *alloca (unsigned);
|
||||
# else
|
||||
char *alloca ();
|
||||
# endif
|
||||
#endif
|
||||
#ifdef HAVE_ALLOCA
|
||||
#define SDL_stack_alloc(type, count) (type*)alloca(sizeof(type)*count)
|
||||
#define SDL_stack_free(data)
|
||||
#else
|
||||
#define SDL_stack_alloc(type, count) (type*)SDL_malloc(sizeof(type)*count)
|
||||
#define SDL_stack_free(data) SDL_free(data)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_GETENV
|
||||
#define SDL_getenv getenv
|
||||
#else
|
||||
extern DECLSPEC char * SDLCALL SDL_getenv(const char *name);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PUTENV
|
||||
#define SDL_putenv putenv
|
||||
#else
|
||||
extern DECLSPEC int SDLCALL SDL_putenv(const char *variable);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_QSORT
|
||||
#define SDL_qsort qsort
|
||||
#else
|
||||
extern DECLSPEC void SDLCALL SDL_qsort(void *base, size_t nmemb, size_t size,
|
||||
int (*compare)(const void *, const void *));
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_ABS
|
||||
#define SDL_abs abs
|
||||
#else
|
||||
#define SDL_abs(X) ((X) < 0 ? -(X) : (X))
|
||||
#endif
|
||||
|
||||
#define SDL_min(x, y) (((x) < (y)) ? (x) : (y))
|
||||
#define SDL_max(x, y) (((x) > (y)) ? (x) : (y))
|
||||
|
||||
#ifdef HAVE_CTYPE_H
|
||||
#define SDL_isdigit(X) isdigit(X)
|
||||
#define SDL_isspace(X) isspace(X)
|
||||
#define SDL_toupper(X) toupper(X)
|
||||
#define SDL_tolower(X) tolower(X)
|
||||
#else
|
||||
#define SDL_isdigit(X) (((X) >= '0') && ((X) <= '9'))
|
||||
#define SDL_isspace(X) (((X) == ' ') || ((X) == '\t') || ((X) == '\r') || ((X) == '\n'))
|
||||
#define SDL_toupper(X) (((X) >= 'a') && ((X) <= 'z') ? ('A'+((X)-'a')) : (X))
|
||||
#define SDL_tolower(X) (((X) >= 'A') && ((X) <= 'Z') ? ('a'+((X)-'A')) : (X))
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_MEMSET
|
||||
#define SDL_memset memset
|
||||
#else
|
||||
extern DECLSPEC void * SDLCALL SDL_memset(void *dst, int c, size_t len);
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__) && defined(i386)
|
||||
#define SDL_memset4(dst, val, len) \
|
||||
do { \
|
||||
int u0, u1, u2; \
|
||||
__asm__ __volatile__ ( \
|
||||
"cld\n\t" \
|
||||
"rep ; stosl\n\t" \
|
||||
: "=&D" (u0), "=&a" (u1), "=&c" (u2) \
|
||||
: "0" (dst), "1" (val), "2" ((Uint32)(len)) \
|
||||
: "memory" ); \
|
||||
} while(0)
|
||||
#endif
|
||||
#ifndef SDL_memset4
|
||||
#define SDL_memset4(dst, val, len) \
|
||||
do { \
|
||||
unsigned _count = (len); \
|
||||
unsigned _n = (_count + 3) / 4; \
|
||||
Uint32 *_p = (Uint32 *)(dst); \
|
||||
Uint32 _val = (val); \
|
||||
switch (_count % 4) { \
|
||||
case 0: do { *_p++ = _val; \
|
||||
case 3: *_p++ = _val; \
|
||||
case 2: *_p++ = _val; \
|
||||
case 1: *_p++ = _val; \
|
||||
} while ( --_n ); \
|
||||
} \
|
||||
} while(0)
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__) && defined(i386)
|
||||
#define SDL_memcpy(dst, src, len) \
|
||||
do { \
|
||||
int u0, u1, u2; \
|
||||
__asm__ __volatile__ ( \
|
||||
"cld\n\t" \
|
||||
"rep ; movsl\n\t" \
|
||||
"testb $2,%b4\n\t" \
|
||||
"je 1f\n\t" \
|
||||
"movsw\n" \
|
||||
"1:\ttestb $1,%b4\n\t" \
|
||||
"je 2f\n\t" \
|
||||
"movsb\n" \
|
||||
"2:" \
|
||||
: "=&c" (u0), "=&D" (u1), "=&S" (u2) \
|
||||
: "0" ((unsigned)(len)/4), "q" (len), "1" (dst),"2" (src) \
|
||||
: "memory" ); \
|
||||
} while(0)
|
||||
#endif
|
||||
#ifndef SDL_memcpy
|
||||
#ifdef HAVE_MEMCPY
|
||||
#define SDL_memcpy memcpy
|
||||
#elif defined(HAVE_BCOPY)
|
||||
#define SDL_memcpy(d, s, n) bcopy((s), (d), (n))
|
||||
#else
|
||||
extern DECLSPEC void * SDLCALL SDL_memcpy(void *dst, const void *src, size_t len);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__) && defined(i386)
|
||||
#define SDL_memcpy4(dst, src, len) \
|
||||
do { \
|
||||
int ecx, edi, esi; \
|
||||
__asm__ __volatile__ ( \
|
||||
"cld\n\t" \
|
||||
"rep ; movsl" \
|
||||
: "=&c" (ecx), "=&D" (edi), "=&S" (esi) \
|
||||
: "0" ((unsigned)(len)), "1" (dst), "2" (src) \
|
||||
: "memory" ); \
|
||||
} while(0)
|
||||
#endif
|
||||
#ifndef SDL_memcpy4
|
||||
#define SDL_memcpy4(dst, src, len) SDL_memcpy(dst, src, (len) << 2)
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__) && defined(i386)
|
||||
#define SDL_revcpy(dst, src, len) \
|
||||
do { \
|
||||
int u0, u1, u2; \
|
||||
char *dstp = (char *)(dst); \
|
||||
char *srcp = (char *)(src); \
|
||||
int n = (len); \
|
||||
if ( n >= 4 ) { \
|
||||
__asm__ __volatile__ ( \
|
||||
"std\n\t" \
|
||||
"rep ; movsl\n\t" \
|
||||
: "=&c" (u0), "=&D" (u1), "=&S" (u2) \
|
||||
: "0" (n >> 2), \
|
||||
"1" (dstp+(n-4)), "2" (srcp+(n-4)) \
|
||||
: "memory" ); \
|
||||
} \
|
||||
switch (n & 3) { \
|
||||
case 3: dstp[2] = srcp[2]; \
|
||||
case 2: dstp[1] = srcp[1]; \
|
||||
case 1: dstp[0] = srcp[0]; \
|
||||
break; \
|
||||
default: \
|
||||
break; \
|
||||
} \
|
||||
} while(0)
|
||||
#endif
|
||||
#ifndef SDL_revcpy
|
||||
extern DECLSPEC void * SDLCALL SDL_revcpy(void *dst, const void *src, size_t len);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_MEMMOVE
|
||||
#define SDL_memmove memmove
|
||||
#elif defined(HAVE_BCOPY)
|
||||
#define SDL_memmove(d, s, n) bcopy((s), (d), (n))
|
||||
#else
|
||||
#define SDL_memmove(dst, src, len) \
|
||||
do { \
|
||||
if ( dst < src ) { \
|
||||
SDL_memcpy(dst, src, len); \
|
||||
} else { \
|
||||
SDL_revcpy(dst, src, len); \
|
||||
} \
|
||||
} while(0)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_MEMCMP
|
||||
#define SDL_memcmp memcmp
|
||||
#else
|
||||
extern DECLSPEC int SDLCALL SDL_memcmp(const void *s1, const void *s2, size_t len);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRLEN
|
||||
#define SDL_strlen strlen
|
||||
#else
|
||||
extern DECLSPEC size_t SDLCALL SDL_strlen(const char *string);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRLCPY
|
||||
#define SDL_strlcpy strlcpy
|
||||
#else
|
||||
extern DECLSPEC size_t SDLCALL SDL_strlcpy(char *dst, const char *src, size_t maxlen);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRLCAT
|
||||
#define SDL_strlcat strlcat
|
||||
#else
|
||||
extern DECLSPEC size_t SDLCALL SDL_strlcat(char *dst, const char *src, size_t maxlen);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRDUP
|
||||
#define SDL_strdup strdup
|
||||
#else
|
||||
extern DECLSPEC char * SDLCALL SDL_strdup(const char *string);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE__STRREV
|
||||
#define SDL_strrev _strrev
|
||||
#else
|
||||
extern DECLSPEC char * SDLCALL SDL_strrev(char *string);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE__STRUPR
|
||||
#define SDL_strupr _strupr
|
||||
#else
|
||||
extern DECLSPEC char * SDLCALL SDL_strupr(char *string);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE__STRLWR
|
||||
#define SDL_strlwr _strlwr
|
||||
#else
|
||||
extern DECLSPEC char * SDLCALL SDL_strlwr(char *string);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRCHR
|
||||
#define SDL_strchr strchr
|
||||
#elif defined(HAVE_INDEX)
|
||||
#define SDL_strchr index
|
||||
#else
|
||||
extern DECLSPEC char * SDLCALL SDL_strchr(const char *string, int c);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRRCHR
|
||||
#define SDL_strrchr strrchr
|
||||
#elif defined(HAVE_RINDEX)
|
||||
#define SDL_strrchr rindex
|
||||
#else
|
||||
extern DECLSPEC char * SDLCALL SDL_strrchr(const char *string, int c);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRSTR
|
||||
#define SDL_strstr strstr
|
||||
#else
|
||||
extern DECLSPEC char * SDLCALL SDL_strstr(const char *haystack, const char *needle);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_ITOA
|
||||
#define SDL_itoa itoa
|
||||
#else
|
||||
#define SDL_itoa(value, string, radix) SDL_ltoa((long)value, string, radix)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE__LTOA
|
||||
#define SDL_ltoa _ltoa
|
||||
#else
|
||||
extern DECLSPEC char * SDLCALL SDL_ltoa(long value, char *string, int radix);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE__UITOA
|
||||
#define SDL_uitoa _uitoa
|
||||
#else
|
||||
#define SDL_uitoa(value, string, radix) SDL_ultoa((long)value, string, radix)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE__ULTOA
|
||||
#define SDL_ultoa _ultoa
|
||||
#else
|
||||
extern DECLSPEC char * SDLCALL SDL_ultoa(unsigned long value, char *string, int radix);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRTOL
|
||||
#define SDL_strtol strtol
|
||||
#else
|
||||
extern DECLSPEC long SDLCALL SDL_strtol(const char *string, char **endp, int base);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRTOUL
|
||||
#define SDL_strtoul strtoul
|
||||
#else
|
||||
extern DECLSPEC unsigned long SDLCALL SDL_strtoul(const char *string, char **endp, int base);
|
||||
#endif
|
||||
|
||||
#ifdef SDL_HAS_64BIT_TYPE
|
||||
|
||||
#ifdef HAVE__I64TOA
|
||||
#define SDL_lltoa _i64toa
|
||||
#else
|
||||
extern DECLSPEC char* SDLCALL SDL_lltoa(Sint64 value, char *string, int radix);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE__UI64TOA
|
||||
#define SDL_ulltoa _ui64toa
|
||||
#else
|
||||
extern DECLSPEC char* SDLCALL SDL_ulltoa(Uint64 value, char *string, int radix);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRTOLL
|
||||
#define SDL_strtoll strtoll
|
||||
#else
|
||||
extern DECLSPEC Sint64 SDLCALL SDL_strtoll(const char *string, char **endp, int base);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRTOULL
|
||||
#define SDL_strtoull strtoull
|
||||
#else
|
||||
extern DECLSPEC Uint64 SDLCALL SDL_strtoull(const char *string, char **endp, int base);
|
||||
#endif
|
||||
|
||||
#endif /* SDL_HAS_64BIT_TYPE */
|
||||
|
||||
#ifdef HAVE_STRTOD
|
||||
#define SDL_strtod strtod
|
||||
#else
|
||||
extern DECLSPEC double SDLCALL SDL_strtod(const char *string, char **endp);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_ATOI
|
||||
#define SDL_atoi atoi
|
||||
#else
|
||||
#define SDL_atoi(X) SDL_strtol(X, NULL, 0)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_ATOF
|
||||
#define SDL_atof atof
|
||||
#else
|
||||
#define SDL_atof(X) SDL_strtod(X, NULL)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRCMP
|
||||
#define SDL_strcmp strcmp
|
||||
#else
|
||||
extern DECLSPEC int SDLCALL SDL_strcmp(const char *str1, const char *str2);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRNCMP
|
||||
#define SDL_strncmp strncmp
|
||||
#else
|
||||
extern DECLSPEC int SDLCALL SDL_strncmp(const char *str1, const char *str2, size_t maxlen);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRCASECMP
|
||||
#define SDL_strcasecmp strcasecmp
|
||||
#elif defined(HAVE__STRICMP)
|
||||
#define SDL_strcasecmp _stricmp
|
||||
#else
|
||||
extern DECLSPEC int SDLCALL SDL_strcasecmp(const char *str1, const char *str2);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRNCASECMP
|
||||
#define SDL_strncasecmp strncasecmp
|
||||
#elif defined(HAVE__STRNICMP)
|
||||
#define SDL_strncasecmp _strnicmp
|
||||
#else
|
||||
extern DECLSPEC int SDLCALL SDL_strncasecmp(const char *str1, const char *str2, size_t maxlen);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SSCANF
|
||||
#define SDL_sscanf sscanf
|
||||
#else
|
||||
extern DECLSPEC int SDLCALL SDL_sscanf(const char *text, const char *fmt, ...);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SNPRINTF
|
||||
#define SDL_snprintf snprintf
|
||||
#else
|
||||
extern DECLSPEC int SDLCALL SDL_snprintf(char *text, size_t maxlen, const char *fmt, ...);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_VSNPRINTF
|
||||
#define SDL_vsnprintf vsnprintf
|
||||
#else
|
||||
extern DECLSPEC int SDLCALL SDL_vsnprintf(char *text, size_t maxlen, const char *fmt, va_list ap);
|
||||
#endif
|
||||
|
||||
/* The SDL implementation of iconv() returns these error codes */
|
||||
#define SDL_ICONV_ERROR (size_t)-1
|
||||
#define SDL_ICONV_E2BIG (size_t)-2
|
||||
#define SDL_ICONV_EILSEQ (size_t)-3
|
||||
#define SDL_ICONV_EINVAL (size_t)-4
|
||||
|
||||
#ifdef HAVE_ICONV
|
||||
#define SDL_iconv_t iconv_t
|
||||
#define SDL_iconv_open iconv_open
|
||||
#define SDL_iconv_close iconv_close
|
||||
extern DECLSPEC size_t SDLCALL SDL_iconv(SDL_iconv_t cd, char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft);
|
||||
#else
|
||||
typedef struct _SDL_iconv_t *SDL_iconv_t;
|
||||
extern DECLSPEC SDL_iconv_t SDLCALL SDL_iconv_open(const char *tocode, const char *fromcode);
|
||||
extern DECLSPEC int SDLCALL SDL_iconv_close(SDL_iconv_t cd);
|
||||
extern DECLSPEC size_t SDLCALL SDL_iconv(SDL_iconv_t cd, char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft);
|
||||
#endif
|
||||
/* This function converts a string between encodings in one pass, returning a
|
||||
string that must be freed with SDL_free() or NULL on error.
|
||||
*/
|
||||
extern DECLSPEC char * SDLCALL SDL_iconv_string(const char *tocode, const char *fromcode, char *inbuf, size_t inbytesleft);
|
||||
#define SDL_iconv_utf8_ascii(S) SDL_iconv_string("ASCII", "UTF-8", S, SDL_strlen(S)+1)
|
||||
#define SDL_iconv_utf8_latin1(S) SDL_iconv_string("LATIN1", "UTF-8", S, SDL_strlen(S)+1)
|
||||
#define SDL_iconv_utf8_ucs2(S) (Uint16 *)SDL_iconv_string("UCS-2", "UTF-8", S, SDL_strlen(S)+1)
|
||||
#define SDL_iconv_utf8_ucs4(S) (Uint32 *)SDL_iconv_string("UCS-4", "UTF-8", S, SDL_strlen(S)+1)
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* _SDL_stdinc_h */
|
||||
@@ -1,210 +0,0 @@
|
||||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2006 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
/* Include file for SDL custom system window manager hooks */
|
||||
|
||||
#ifndef _SDL_syswm_h
|
||||
#define _SDL_syswm_h
|
||||
|
||||
#include "SDL_stdinc.h"
|
||||
#include "SDL_error.h"
|
||||
#include "SDL_version.h"
|
||||
|
||||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Your application has access to a special type of event 'SDL_SYSWMEVENT',
|
||||
which contains window-manager specific information and arrives whenever
|
||||
an unhandled window event occurs. This event is ignored by default, but
|
||||
you can enable it with SDL_EventState()
|
||||
*/
|
||||
#ifdef SDL_PROTOTYPES_ONLY
|
||||
struct SDL_SysWMinfo;
|
||||
typedef struct SDL_SysWMinfo SDL_SysWMinfo;
|
||||
#else
|
||||
|
||||
/* This is the structure for custom window manager events */
|
||||
#if defined(SDL_VIDEO_DRIVER_X11)
|
||||
#if defined(__APPLE__) && defined(__MACH__)
|
||||
/* conflicts with Quickdraw.h */
|
||||
#define Cursor X11Cursor
|
||||
#endif
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xatom.h>
|
||||
|
||||
#if defined(__APPLE__) && defined(__MACH__)
|
||||
/* matches the re-define above */
|
||||
#undef Cursor
|
||||
#endif
|
||||
|
||||
/* These are the various supported subsystems under UNIX */
|
||||
typedef enum {
|
||||
SDL_SYSWM_X11
|
||||
} SDL_SYSWM_TYPE;
|
||||
|
||||
/* The UNIX custom event structure */
|
||||
struct SDL_SysWMmsg {
|
||||
SDL_version version;
|
||||
SDL_SYSWM_TYPE subsystem;
|
||||
union {
|
||||
XEvent xevent;
|
||||
} event;
|
||||
};
|
||||
|
||||
/* The UNIX custom window manager information structure.
|
||||
When this structure is returned, it holds information about which
|
||||
low level system it is using, and will be one of SDL_SYSWM_TYPE.
|
||||
*/
|
||||
typedef struct SDL_SysWMinfo {
|
||||
SDL_version version;
|
||||
SDL_SYSWM_TYPE subsystem;
|
||||
union {
|
||||
struct {
|
||||
Display *display; /* The X11 display */
|
||||
Window window; /* The X11 display window */
|
||||
/* These locking functions should be called around
|
||||
any X11 functions using the display variable.
|
||||
They lock the event thread, so should not be
|
||||
called around event functions or from event filters.
|
||||
*/
|
||||
void (*lock_func)(void);
|
||||
void (*unlock_func)(void);
|
||||
|
||||
/* Introduced in SDL 1.0.2 */
|
||||
Window fswindow; /* The X11 fullscreen window */
|
||||
Window wmwindow; /* The X11 managed input window */
|
||||
} x11;
|
||||
} info;
|
||||
} SDL_SysWMinfo;
|
||||
|
||||
#elif defined(SDL_VIDEO_DRIVER_NANOX)
|
||||
#include <microwin/nano-X.h>
|
||||
|
||||
/* The generic custom event structure */
|
||||
struct SDL_SysWMmsg {
|
||||
SDL_version version;
|
||||
int data;
|
||||
};
|
||||
|
||||
/* The windows custom window manager information structure */
|
||||
typedef struct SDL_SysWMinfo {
|
||||
SDL_version version ;
|
||||
GR_WINDOW_ID window ; /* The display window */
|
||||
} SDL_SysWMinfo;
|
||||
|
||||
#elif defined(SDL_VIDEO_DRIVER_WINDIB) || defined(SDL_VIDEO_DRIVER_DDRAW) || defined(SDL_VIDEO_DRIVER_GAPI)
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
|
||||
/* The windows custom event structure */
|
||||
struct SDL_SysWMmsg {
|
||||
SDL_version version;
|
||||
HWND hwnd; /* The window for the message */
|
||||
UINT msg; /* The type of message */
|
||||
WPARAM wParam; /* WORD message parameter */
|
||||
LPARAM lParam; /* LONG message parameter */
|
||||
};
|
||||
|
||||
/* The windows custom window manager information structure */
|
||||
typedef struct SDL_SysWMinfo {
|
||||
SDL_version version;
|
||||
HWND window; /* The Win32 display window */
|
||||
HGLRC hglrc; /* The OpenGL context, if any */
|
||||
} SDL_SysWMinfo;
|
||||
|
||||
#elif defined(SDL_VIDEO_DRIVER_RISCOS)
|
||||
|
||||
/* RISC OS custom event structure */
|
||||
struct SDL_SysWMmsg {
|
||||
SDL_version version;
|
||||
int eventCode; /* The window for the message */
|
||||
int pollBlock[64];
|
||||
};
|
||||
|
||||
/* The RISC OS custom window manager information structure */
|
||||
typedef struct SDL_SysWMinfo {
|
||||
SDL_version version;
|
||||
int wimpVersion; /* Wimp version running under */
|
||||
int taskHandle; /* The RISC OS task handle */
|
||||
int window; /* The RISC OS display window */
|
||||
} SDL_SysWMinfo;
|
||||
|
||||
#elif defined(SDL_VIDEO_DRIVER_PHOTON)
|
||||
#include <sys/neutrino.h>
|
||||
#include <Ph.h>
|
||||
|
||||
/* The QNX custom event structure */
|
||||
struct SDL_SysWMmsg {
|
||||
SDL_version version;
|
||||
int data;
|
||||
};
|
||||
|
||||
/* The QNX custom window manager information structure */
|
||||
typedef struct SDL_SysWMinfo {
|
||||
SDL_version version;
|
||||
int data;
|
||||
} SDL_SysWMinfo;
|
||||
|
||||
#else
|
||||
|
||||
/* The generic custom event structure */
|
||||
struct SDL_SysWMmsg {
|
||||
SDL_version version;
|
||||
int data;
|
||||
};
|
||||
|
||||
/* The generic custom window manager information structure */
|
||||
typedef struct SDL_SysWMinfo {
|
||||
SDL_version version;
|
||||
int data;
|
||||
} SDL_SysWMinfo;
|
||||
|
||||
#endif /* video driver type */
|
||||
|
||||
#endif /* SDL_PROTOTYPES_ONLY */
|
||||
|
||||
/* Function prototypes */
|
||||
/*
|
||||
* This function gives you custom hooks into the window manager information.
|
||||
* It fills the structure pointed to by 'info' with custom information and
|
||||
* returns 1 if the function is implemented. If it's not implemented, or
|
||||
* the version member of the 'info' structure is invalid, it returns 0.
|
||||
*
|
||||
* You typically use this function like this:
|
||||
* SDL_SysWMInfo info;
|
||||
* SDL_VERSION(&info.version);
|
||||
* if ( SDL_GetWMInfo(&info) ) { ... }
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_GetWMInfo(SDL_SysWMinfo *info);
|
||||
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* _SDL_syswm_h */
|
||||
@@ -1,119 +0,0 @@
|
||||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2006 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
#ifndef _SDL_thread_h
|
||||
#define _SDL_thread_h
|
||||
|
||||
/* Header for the SDL thread management routines
|
||||
|
||||
These are independent of the other SDL routines.
|
||||
*/
|
||||
|
||||
#include "SDL_stdinc.h"
|
||||
#include "SDL_error.h"
|
||||
|
||||
/* Thread synchronization primitives */
|
||||
#include "SDL_mutex.h"
|
||||
|
||||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* The SDL thread structure, defined in SDL_thread.c */
|
||||
struct SDL_Thread;
|
||||
typedef struct SDL_Thread SDL_Thread;
|
||||
|
||||
/* Create a thread */
|
||||
#if (defined(__WIN32__) && !defined(HAVE_LIBC)) || defined(__OS2__)
|
||||
/*
|
||||
We compile SDL into a DLL on OS/2. This means, that it's the DLL which
|
||||
creates a new thread for the calling process with the SDL_CreateThread()
|
||||
API. There is a problem with this, that only the RTL of the SDL.DLL will
|
||||
be initialized for those threads, and not the RTL of the calling application!
|
||||
To solve this, we make a little hack here.
|
||||
We'll always use the caller's _beginthread() and _endthread() APIs to
|
||||
start a new thread. This way, if it's the SDL.DLL which uses this API,
|
||||
then the RTL of SDL.DLL will be used to create the new thread, and if it's
|
||||
the application, then the RTL of the application will be used.
|
||||
So, in short:
|
||||
Always use the _beginthread() and _endthread() of the calling runtime library!
|
||||
*/
|
||||
#define SDL_PASSED_BEGINTHREAD_ENDTHREAD
|
||||
#ifndef _WIN32_WCE
|
||||
#include <process.h> /* This has _beginthread() and _endthread() defined! */
|
||||
#endif
|
||||
|
||||
#ifdef __OS2__
|
||||
typedef int (*pfnSDL_CurrentBeginThread)(void (*func)(void *), void *, unsigned, void *arg);
|
||||
typedef void (*pfnSDL_CurrentEndThread)(void);
|
||||
#elif __GNUC__
|
||||
typedef unsigned long (__cdecl *pfnSDL_CurrentBeginThread) (void *, unsigned,
|
||||
unsigned (__stdcall *func)(void *), void *arg,
|
||||
unsigned, unsigned *threadID);
|
||||
typedef void (__cdecl *pfnSDL_CurrentEndThread)(unsigned code);
|
||||
#else
|
||||
typedef uintptr_t (__cdecl *pfnSDL_CurrentBeginThread) (void *, unsigned,
|
||||
unsigned (__stdcall *func)(void *), void *arg,
|
||||
unsigned, unsigned *threadID);
|
||||
typedef void (__cdecl *pfnSDL_CurrentEndThread)(unsigned code);
|
||||
#endif
|
||||
|
||||
extern DECLSPEC SDL_Thread * SDLCALL SDL_CreateThread(int (SDLCALL *fn)(void *), void *data, pfnSDL_CurrentBeginThread pfnBeginThread, pfnSDL_CurrentEndThread pfnEndThread);
|
||||
|
||||
#ifdef __OS2__
|
||||
#define SDL_CreateThread(fn, data) SDL_CreateThread(fn, data, _beginthread, _endthread)
|
||||
#elif defined(_WIN32_WCE)
|
||||
#define SDL_CreateThread(fn, data) SDL_CreateThread(fn, data, NULL, NULL)
|
||||
#else
|
||||
#define SDL_CreateThread(fn, data) SDL_CreateThread(fn, data, _beginthreadex, _endthreadex)
|
||||
#endif
|
||||
#else
|
||||
extern DECLSPEC SDL_Thread * SDLCALL SDL_CreateThread(int (SDLCALL *fn)(void *), void *data);
|
||||
#endif
|
||||
|
||||
/* Get the 32-bit thread identifier for the current thread */
|
||||
extern DECLSPEC Uint32 SDLCALL SDL_ThreadID(void);
|
||||
|
||||
/* Get the 32-bit thread identifier for the specified thread,
|
||||
equivalent to SDL_ThreadID() if the specified thread is NULL.
|
||||
*/
|
||||
extern DECLSPEC Uint32 SDLCALL SDL_GetThreadID(SDL_Thread *thread);
|
||||
|
||||
/* Wait for a thread to finish.
|
||||
The return code for the thread function is placed in the area
|
||||
pointed to by 'status', if 'status' is not NULL.
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_WaitThread(SDL_Thread *thread, int *status);
|
||||
|
||||
/* Forcefully kill a thread without worrying about its state */
|
||||
extern DECLSPEC void SDLCALL SDL_KillThread(SDL_Thread *thread);
|
||||
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* _SDL_thread_h */
|
||||
@@ -1,115 +0,0 @@
|
||||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2006 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
#ifndef _SDL_timer_h
|
||||
#define _SDL_timer_h
|
||||
|
||||
/* Header for the SDL time management routines */
|
||||
|
||||
#include "SDL_stdinc.h"
|
||||
#include "SDL_error.h"
|
||||
|
||||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* This is the OS scheduler timeslice, in milliseconds */
|
||||
#define SDL_TIMESLICE 10
|
||||
|
||||
/* This is the maximum resolution of the SDL timer on all platforms */
|
||||
#define TIMER_RESOLUTION 10 /* Experimentally determined */
|
||||
|
||||
/* Get the number of milliseconds since the SDL library initialization.
|
||||
* Note that this value wraps if the program runs for more than ~49 days.
|
||||
*/
|
||||
extern DECLSPEC Uint32 SDLCALL SDL_GetTicks(void);
|
||||
|
||||
/* Wait a specified number of milliseconds before returning */
|
||||
extern DECLSPEC void SDLCALL SDL_Delay(Uint32 ms);
|
||||
|
||||
/* Function prototype for the timer callback function */
|
||||
typedef Uint32 (SDLCALL *SDL_TimerCallback)(Uint32 interval);
|
||||
|
||||
/* Set a callback to run after the specified number of milliseconds has
|
||||
* elapsed. The callback function is passed the current timer interval
|
||||
* and returns the next timer interval. If the returned value is the
|
||||
* same as the one passed in, the periodic alarm continues, otherwise a
|
||||
* new alarm is scheduled. If the callback returns 0, the periodic alarm
|
||||
* is cancelled.
|
||||
*
|
||||
* To cancel a currently running timer, call SDL_SetTimer(0, NULL);
|
||||
*
|
||||
* The timer callback function may run in a different thread than your
|
||||
* main code, and so shouldn't call any functions from within itself.
|
||||
*
|
||||
* The maximum resolution of this timer is 10 ms, which means that if
|
||||
* you request a 16 ms timer, your callback will run approximately 20 ms
|
||||
* later on an unloaded system. If you wanted to set a flag signaling
|
||||
* a frame update at 30 frames per second (every 33 ms), you might set a
|
||||
* timer for 30 ms:
|
||||
* SDL_SetTimer((33/10)*10, flag_update);
|
||||
*
|
||||
* If you use this function, you need to pass SDL_INIT_TIMER to SDL_Init().
|
||||
*
|
||||
* Under UNIX, you should not use raise or use SIGALRM and this function
|
||||
* in the same program, as it is implemented using setitimer(). You also
|
||||
* should not use this function in multi-threaded applications as signals
|
||||
* to multi-threaded apps have undefined behavior in some implementations.
|
||||
*
|
||||
* This function returns 0 if successful, or -1 if there was an error.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_SetTimer(Uint32 interval, SDL_TimerCallback callback);
|
||||
|
||||
/* New timer API, supports multiple timers
|
||||
* Written by Stephane Peter <megastep@lokigames.com>
|
||||
*/
|
||||
|
||||
/* Function prototype for the new timer callback function.
|
||||
* The callback function is passed the current timer interval and returns
|
||||
* the next timer interval. If the returned value is the same as the one
|
||||
* passed in, the periodic alarm continues, otherwise a new alarm is
|
||||
* scheduled. If the callback returns 0, the periodic alarm is cancelled.
|
||||
*/
|
||||
typedef Uint32 (SDLCALL *SDL_NewTimerCallback)(Uint32 interval, void *param);
|
||||
|
||||
/* Definition of the timer ID type */
|
||||
typedef struct _SDL_TimerID *SDL_TimerID;
|
||||
|
||||
/* Add a new timer to the pool of timers already running.
|
||||
Returns a timer ID, or NULL when an error occurs.
|
||||
*/
|
||||
extern DECLSPEC SDL_TimerID SDLCALL SDL_AddTimer(Uint32 interval, SDL_NewTimerCallback callback, void *param);
|
||||
|
||||
/* Remove one of the multiple timers knowing its ID.
|
||||
* Returns a boolean value indicating success.
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_RemoveTimer(SDL_TimerID t);
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* _SDL_timer_h */
|
||||
@@ -1,24 +0,0 @@
|
||||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2006 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
/* DEPRECATED */
|
||||
#include "SDL_stdinc.h"
|
||||
@@ -1,85 +0,0 @@
|
||||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2006 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
/* This header defines the current SDL version */
|
||||
|
||||
#ifndef _SDL_version_h
|
||||
#define _SDL_version_h
|
||||
|
||||
#include "SDL_stdinc.h"
|
||||
|
||||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL
|
||||
*/
|
||||
#define SDL_MAJOR_VERSION 1
|
||||
#define SDL_MINOR_VERSION 2
|
||||
#define SDL_PATCHLEVEL 11
|
||||
|
||||
typedef struct SDL_version {
|
||||
Uint8 major;
|
||||
Uint8 minor;
|
||||
Uint8 patch;
|
||||
} SDL_version;
|
||||
|
||||
/* This macro can be used to fill a version structure with the compile-time
|
||||
* version of the SDL library.
|
||||
*/
|
||||
#define SDL_VERSION(X) \
|
||||
{ \
|
||||
(X)->major = SDL_MAJOR_VERSION; \
|
||||
(X)->minor = SDL_MINOR_VERSION; \
|
||||
(X)->patch = SDL_PATCHLEVEL; \
|
||||
}
|
||||
|
||||
/* This macro turns the version numbers into a numeric value:
|
||||
(1,2,3) -> (1203)
|
||||
This assumes that there will never be more than 100 patchlevels
|
||||
*/
|
||||
#define SDL_VERSIONNUM(X, Y, Z) \
|
||||
((X)*1000 + (Y)*100 + (Z))
|
||||
|
||||
/* This is the version number macro for the current SDL version */
|
||||
#define SDL_COMPILEDVERSION \
|
||||
SDL_VERSIONNUM(SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL)
|
||||
|
||||
/* This macro will evaluate to true if compiled with SDL at least X.Y.Z */
|
||||
#define SDL_VERSION_ATLEAST(X, Y, Z) \
|
||||
(SDL_COMPILEDVERSION >= SDL_VERSIONNUM(X, Y, Z))
|
||||
|
||||
/* This function gets the version of the dynamically linked SDL library.
|
||||
it should NOT be used to fill a version structure, instead you should
|
||||
use the SDL_Version() macro.
|
||||
*/
|
||||
extern DECLSPEC const SDL_version * SDLCALL SDL_Linked_Version(void);
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* _SDL_version_h */
|
||||
@@ -1,889 +0,0 @@
|
||||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2006 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
/* Header file for access to the SDL raw framebuffer window */
|
||||
|
||||
#ifndef _SDL_video_h
|
||||
#define _SDL_video_h
|
||||
|
||||
#include "SDL_stdinc.h"
|
||||
#include "SDL_error.h"
|
||||
#include "SDL_rwops.h"
|
||||
|
||||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Transparency definitions: These define alpha as the opacity of a surface */
|
||||
#define SDL_ALPHA_OPAQUE 255
|
||||
#define SDL_ALPHA_TRANSPARENT 0
|
||||
|
||||
/* Useful data types */
|
||||
typedef struct SDL_Rect {
|
||||
Sint16 x, y;
|
||||
Uint16 w, h;
|
||||
} SDL_Rect;
|
||||
|
||||
typedef struct SDL_Color {
|
||||
Uint8 r;
|
||||
Uint8 g;
|
||||
Uint8 b;
|
||||
Uint8 unused;
|
||||
} SDL_Color;
|
||||
#define SDL_Colour SDL_Color
|
||||
|
||||
typedef struct SDL_Palette {
|
||||
int ncolors;
|
||||
SDL_Color *colors;
|
||||
} SDL_Palette;
|
||||
|
||||
/* Everything in the pixel format structure is read-only */
|
||||
typedef struct SDL_PixelFormat {
|
||||
SDL_Palette *palette;
|
||||
Uint8 BitsPerPixel;
|
||||
Uint8 BytesPerPixel;
|
||||
Uint8 Rloss;
|
||||
Uint8 Gloss;
|
||||
Uint8 Bloss;
|
||||
Uint8 Aloss;
|
||||
Uint8 Rshift;
|
||||
Uint8 Gshift;
|
||||
Uint8 Bshift;
|
||||
Uint8 Ashift;
|
||||
Uint32 Rmask;
|
||||
Uint32 Gmask;
|
||||
Uint32 Bmask;
|
||||
Uint32 Amask;
|
||||
|
||||
/* RGB color key information */
|
||||
Uint32 colorkey;
|
||||
/* Alpha value information (per-surface alpha) */
|
||||
Uint8 alpha;
|
||||
} SDL_PixelFormat;
|
||||
|
||||
/* This structure should be treated as read-only, except for 'pixels',
|
||||
which, if not NULL, contains the raw pixel data for the surface.
|
||||
*/
|
||||
typedef struct SDL_Surface {
|
||||
Uint32 flags; /* Read-only */
|
||||
SDL_PixelFormat *format; /* Read-only */
|
||||
int w, h; /* Read-only */
|
||||
Uint16 pitch; /* Read-only */
|
||||
void *pixels; /* Read-write */
|
||||
int offset; /* Private */
|
||||
|
||||
/* Hardware-specific surface info */
|
||||
struct private_hwdata *hwdata;
|
||||
|
||||
/* clipping information */
|
||||
SDL_Rect clip_rect; /* Read-only */
|
||||
Uint32 unused1; /* for binary compatibility */
|
||||
|
||||
/* Allow recursive locks */
|
||||
Uint32 locked; /* Private */
|
||||
|
||||
/* info for fast blit mapping to other surfaces */
|
||||
struct SDL_BlitMap *map; /* Private */
|
||||
|
||||
/* format version, bumped at every change to invalidate blit maps */
|
||||
unsigned int format_version; /* Private */
|
||||
|
||||
/* Reference count -- used when freeing surface */
|
||||
int refcount; /* Read-mostly */
|
||||
} SDL_Surface;
|
||||
|
||||
/* These are the currently supported flags for the SDL_surface */
|
||||
/* Available for SDL_CreateRGBSurface() or SDL_SetVideoMode() */
|
||||
#define SDL_SWSURFACE 0x00000000 /* Surface is in system memory */
|
||||
#define SDL_HWSURFACE 0x00000001 /* Surface is in video memory */
|
||||
#define SDL_ASYNCBLIT 0x00000004 /* Use asynchronous blits if possible */
|
||||
/* Available for SDL_SetVideoMode() */
|
||||
#define SDL_ANYFORMAT 0x10000000 /* Allow any video depth/pixel-format */
|
||||
#define SDL_HWPALETTE 0x20000000 /* Surface has exclusive palette */
|
||||
#define SDL_DOUBLEBUF 0x40000000 /* Set up double-buffered video mode */
|
||||
#define SDL_FULLSCREEN 0x80000000 /* Surface is a full screen display */
|
||||
#define SDL_OPENGL 0x00000002 /* Create an OpenGL rendering context */
|
||||
#define SDL_OPENGLBLIT 0x0000000A /* Create an OpenGL rendering context and use it for blitting */
|
||||
#define SDL_RESIZABLE 0x00000010 /* This video mode may be resized */
|
||||
#define SDL_NOFRAME 0x00000020 /* No window caption or edge frame */
|
||||
/* Used internally (read-only) */
|
||||
#define SDL_HWACCEL 0x00000100 /* Blit uses hardware acceleration */
|
||||
#define SDL_SRCCOLORKEY 0x00001000 /* Blit uses a source color key */
|
||||
#define SDL_RLEACCELOK 0x00002000 /* Private flag */
|
||||
#define SDL_RLEACCEL 0x00004000 /* Surface is RLE encoded */
|
||||
#define SDL_SRCALPHA 0x00010000 /* Blit uses source alpha blending */
|
||||
#define SDL_PREALLOC 0x01000000 /* Surface uses preallocated memory */
|
||||
|
||||
/* Evaluates to true if the surface needs to be locked before access */
|
||||
#define SDL_MUSTLOCK(surface) \
|
||||
(surface->offset || \
|
||||
((surface->flags & (SDL_HWSURFACE|SDL_ASYNCBLIT|SDL_RLEACCEL)) != 0))
|
||||
|
||||
/* typedef for private surface blitting functions */
|
||||
typedef int (*SDL_blit)(struct SDL_Surface *src, SDL_Rect *srcrect,
|
||||
struct SDL_Surface *dst, SDL_Rect *dstrect);
|
||||
|
||||
|
||||
/* Useful for determining the video hardware capabilities */
|
||||
typedef struct SDL_VideoInfo {
|
||||
Uint32 hw_available :1; /* Flag: Can you create hardware surfaces? */
|
||||
Uint32 wm_available :1; /* Flag: Can you talk to a window manager? */
|
||||
Uint32 UnusedBits1 :6;
|
||||
Uint32 UnusedBits2 :1;
|
||||
Uint32 blit_hw :1; /* Flag: Accelerated blits HW --> HW */
|
||||
Uint32 blit_hw_CC :1; /* Flag: Accelerated blits with Colorkey */
|
||||
Uint32 blit_hw_A :1; /* Flag: Accelerated blits with Alpha */
|
||||
Uint32 blit_sw :1; /* Flag: Accelerated blits SW --> HW */
|
||||
Uint32 blit_sw_CC :1; /* Flag: Accelerated blits with Colorkey */
|
||||
Uint32 blit_sw_A :1; /* Flag: Accelerated blits with Alpha */
|
||||
Uint32 blit_fill :1; /* Flag: Accelerated color fill */
|
||||
Uint32 UnusedBits3 :16;
|
||||
Uint32 video_mem; /* The total amount of video memory (in K) */
|
||||
SDL_PixelFormat *vfmt; /* Value: The format of the video surface */
|
||||
int current_w; /* Value: The current video mode width */
|
||||
int current_h; /* Value: The current video mode height */
|
||||
} SDL_VideoInfo;
|
||||
|
||||
|
||||
/* The most common video overlay formats.
|
||||
For an explanation of these pixel formats, see:
|
||||
http://www.webartz.com/fourcc/indexyuv.htm
|
||||
|
||||
For information on the relationship between color spaces, see:
|
||||
http://www.neuro.sfc.keio.ac.jp/~aly/polygon/info/color-space-faq.html
|
||||
*/
|
||||
#define SDL_YV12_OVERLAY 0x32315659 /* Planar mode: Y + V + U (3 planes) */
|
||||
#define SDL_IYUV_OVERLAY 0x56555949 /* Planar mode: Y + U + V (3 planes) */
|
||||
#define SDL_YUY2_OVERLAY 0x32595559 /* Packed mode: Y0+U0+Y1+V0 (1 plane) */
|
||||
#define SDL_UYVY_OVERLAY 0x59565955 /* Packed mode: U0+Y0+V0+Y1 (1 plane) */
|
||||
#define SDL_YVYU_OVERLAY 0x55595659 /* Packed mode: Y0+V0+Y1+U0 (1 plane) */
|
||||
|
||||
/* The YUV hardware video overlay */
|
||||
typedef struct SDL_Overlay {
|
||||
Uint32 format; /* Read-only */
|
||||
int w, h; /* Read-only */
|
||||
int planes; /* Read-only */
|
||||
Uint16 *pitches; /* Read-only */
|
||||
Uint8 **pixels; /* Read-write */
|
||||
|
||||
/* Hardware-specific surface info */
|
||||
struct private_yuvhwfuncs *hwfuncs;
|
||||
struct private_yuvhwdata *hwdata;
|
||||
|
||||
/* Special flags */
|
||||
Uint32 hw_overlay :1; /* Flag: This overlay hardware accelerated? */
|
||||
Uint32 UnusedBits :31;
|
||||
} SDL_Overlay;
|
||||
|
||||
|
||||
/* Public enumeration for setting the OpenGL window attributes. */
|
||||
typedef enum {
|
||||
SDL_GL_RED_SIZE,
|
||||
SDL_GL_GREEN_SIZE,
|
||||
SDL_GL_BLUE_SIZE,
|
||||
SDL_GL_ALPHA_SIZE,
|
||||
SDL_GL_BUFFER_SIZE,
|
||||
SDL_GL_DOUBLEBUFFER,
|
||||
SDL_GL_DEPTH_SIZE,
|
||||
SDL_GL_STENCIL_SIZE,
|
||||
SDL_GL_ACCUM_RED_SIZE,
|
||||
SDL_GL_ACCUM_GREEN_SIZE,
|
||||
SDL_GL_ACCUM_BLUE_SIZE,
|
||||
SDL_GL_ACCUM_ALPHA_SIZE,
|
||||
SDL_GL_STEREO,
|
||||
SDL_GL_MULTISAMPLEBUFFERS,
|
||||
SDL_GL_MULTISAMPLESAMPLES,
|
||||
SDL_GL_ACCELERATED_VISUAL,
|
||||
SDL_GL_SWAP_CONTROL
|
||||
} SDL_GLattr;
|
||||
|
||||
/* flags for SDL_SetPalette() */
|
||||
#define SDL_LOGPAL 0x01
|
||||
#define SDL_PHYSPAL 0x02
|
||||
|
||||
/* Function prototypes */
|
||||
|
||||
/* These functions are used internally, and should not be used unless you
|
||||
* have a specific need to specify the video driver you want to use.
|
||||
* You should normally use SDL_Init() or SDL_InitSubSystem().
|
||||
*
|
||||
* SDL_VideoInit() initializes the video subsystem -- sets up a connection
|
||||
* to the window manager, etc, and determines the current video mode and
|
||||
* pixel format, but does not initialize a window or graphics mode.
|
||||
* Note that event handling is activated by this routine.
|
||||
*
|
||||
* If you use both sound and video in your application, you need to call
|
||||
* SDL_Init() before opening the sound device, otherwise under Win32 DirectX,
|
||||
* you won't be able to set full-screen display modes.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_VideoInit(const char *driver_name, Uint32 flags);
|
||||
extern DECLSPEC void SDLCALL SDL_VideoQuit(void);
|
||||
|
||||
/* This function fills the given character buffer with the name of the
|
||||
* video driver, and returns a pointer to it if the video driver has
|
||||
* been initialized. It returns NULL if no driver has been initialized.
|
||||
*/
|
||||
extern DECLSPEC char * SDLCALL SDL_VideoDriverName(char *namebuf, int maxlen);
|
||||
|
||||
/*
|
||||
* This function returns a pointer to the current display surface.
|
||||
* If SDL is doing format conversion on the display surface, this
|
||||
* function returns the publicly visible surface, not the real video
|
||||
* surface.
|
||||
*/
|
||||
extern DECLSPEC SDL_Surface * SDLCALL SDL_GetVideoSurface(void);
|
||||
|
||||
/*
|
||||
* This function returns a read-only pointer to information about the
|
||||
* video hardware. If this is called before SDL_SetVideoMode(), the 'vfmt'
|
||||
* member of the returned structure will contain the pixel format of the
|
||||
* "best" video mode.
|
||||
*/
|
||||
extern DECLSPEC const SDL_VideoInfo * SDLCALL SDL_GetVideoInfo(void);
|
||||
|
||||
/*
|
||||
* Check to see if a particular video mode is supported.
|
||||
* It returns 0 if the requested mode is not supported under any bit depth,
|
||||
* or returns the bits-per-pixel of the closest available mode with the
|
||||
* given width and height. If this bits-per-pixel is different from the
|
||||
* one used when setting the video mode, SDL_SetVideoMode() will succeed,
|
||||
* but will emulate the requested bits-per-pixel with a shadow surface.
|
||||
*
|
||||
* The arguments to SDL_VideoModeOK() are the same ones you would pass to
|
||||
* SDL_SetVideoMode()
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_VideoModeOK(int width, int height, int bpp, Uint32 flags);
|
||||
|
||||
/*
|
||||
* Return a pointer to an array of available screen dimensions for the
|
||||
* given format and video flags, sorted largest to smallest. Returns
|
||||
* NULL if there are no dimensions available for a particular format,
|
||||
* or (SDL_Rect **)-1 if any dimension is okay for the given format.
|
||||
*
|
||||
* If 'format' is NULL, the mode list will be for the format given
|
||||
* by SDL_GetVideoInfo()->vfmt
|
||||
*/
|
||||
extern DECLSPEC SDL_Rect ** SDLCALL SDL_ListModes(SDL_PixelFormat *format, Uint32 flags);
|
||||
|
||||
/*
|
||||
* Set up a video mode with the specified width, height and bits-per-pixel.
|
||||
*
|
||||
* If 'bpp' is 0, it is treated as the current display bits per pixel.
|
||||
*
|
||||
* If SDL_ANYFORMAT is set in 'flags', the SDL library will try to set the
|
||||
* requested bits-per-pixel, but will return whatever video pixel format is
|
||||
* available. The default is to emulate the requested pixel format if it
|
||||
* is not natively available.
|
||||
*
|
||||
* If SDL_HWSURFACE is set in 'flags', the video surface will be placed in
|
||||
* video memory, if possible, and you may have to call SDL_LockSurface()
|
||||
* in order to access the raw framebuffer. Otherwise, the video surface
|
||||
* will be created in system memory.
|
||||
*
|
||||
* If SDL_ASYNCBLIT is set in 'flags', SDL will try to perform rectangle
|
||||
* updates asynchronously, but you must always lock before accessing pixels.
|
||||
* SDL will wait for updates to complete before returning from the lock.
|
||||
*
|
||||
* If SDL_HWPALETTE is set in 'flags', the SDL library will guarantee
|
||||
* that the colors set by SDL_SetColors() will be the colors you get.
|
||||
* Otherwise, in 8-bit mode, SDL_SetColors() may not be able to set all
|
||||
* of the colors exactly the way they are requested, and you should look
|
||||
* at the video surface structure to determine the actual palette.
|
||||
* If SDL cannot guarantee that the colors you request can be set,
|
||||
* i.e. if the colormap is shared, then the video surface may be created
|
||||
* under emulation in system memory, overriding the SDL_HWSURFACE flag.
|
||||
*
|
||||
* If SDL_FULLSCREEN is set in 'flags', the SDL library will try to set
|
||||
* a fullscreen video mode. The default is to create a windowed mode
|
||||
* if the current graphics system has a window manager.
|
||||
* If the SDL library is able to set a fullscreen video mode, this flag
|
||||
* will be set in the surface that is returned.
|
||||
*
|
||||
* If SDL_DOUBLEBUF is set in 'flags', the SDL library will try to set up
|
||||
* two surfaces in video memory and swap between them when you call
|
||||
* SDL_Flip(). This is usually slower than the normal single-buffering
|
||||
* scheme, but prevents "tearing" artifacts caused by modifying video
|
||||
* memory while the monitor is refreshing. It should only be used by
|
||||
* applications that redraw the entire screen on every update.
|
||||
*
|
||||
* If SDL_RESIZABLE is set in 'flags', the SDL library will allow the
|
||||
* window manager, if any, to resize the window at runtime. When this
|
||||
* occurs, SDL will send a SDL_VIDEORESIZE event to you application,
|
||||
* and you must respond to the event by re-calling SDL_SetVideoMode()
|
||||
* with the requested size (or another size that suits the application).
|
||||
*
|
||||
* If SDL_NOFRAME is set in 'flags', the SDL library will create a window
|
||||
* without any title bar or frame decoration. Fullscreen video modes have
|
||||
* this flag set automatically.
|
||||
*
|
||||
* This function returns the video framebuffer surface, or NULL if it fails.
|
||||
*
|
||||
* If you rely on functionality provided by certain video flags, check the
|
||||
* flags of the returned surface to make sure that functionality is available.
|
||||
* SDL will fall back to reduced functionality if the exact flags you wanted
|
||||
* are not available.
|
||||
*/
|
||||
extern DECLSPEC SDL_Surface * SDLCALL SDL_SetVideoMode
|
||||
(int width, int height, int bpp, Uint32 flags);
|
||||
|
||||
/*
|
||||
* Makes sure the given list of rectangles is updated on the given screen.
|
||||
* If 'x', 'y', 'w' and 'h' are all 0, SDL_UpdateRect will update the entire
|
||||
* screen.
|
||||
* These functions should not be called while 'screen' is locked.
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_UpdateRects
|
||||
(SDL_Surface *screen, int numrects, SDL_Rect *rects);
|
||||
extern DECLSPEC void SDLCALL SDL_UpdateRect
|
||||
(SDL_Surface *screen, Sint32 x, Sint32 y, Uint32 w, Uint32 h);
|
||||
|
||||
/*
|
||||
* On hardware that supports double-buffering, this function sets up a flip
|
||||
* and returns. The hardware will wait for vertical retrace, and then swap
|
||||
* video buffers before the next video surface blit or lock will return.
|
||||
* On hardware that doesn not support double-buffering, this is equivalent
|
||||
* to calling SDL_UpdateRect(screen, 0, 0, 0, 0);
|
||||
* The SDL_DOUBLEBUF flag must have been passed to SDL_SetVideoMode() when
|
||||
* setting the video mode for this function to perform hardware flipping.
|
||||
* This function returns 0 if successful, or -1 if there was an error.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_Flip(SDL_Surface *screen);
|
||||
|
||||
/*
|
||||
* Set the gamma correction for each of the color channels.
|
||||
* The gamma values range (approximately) between 0.1 and 10.0
|
||||
*
|
||||
* If this function isn't supported directly by the hardware, it will
|
||||
* be emulated using gamma ramps, if available. If successful, this
|
||||
* function returns 0, otherwise it returns -1.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_SetGamma(float red, float green, float blue);
|
||||
|
||||
/*
|
||||
* Set the gamma translation table for the red, green, and blue channels
|
||||
* of the video hardware. Each table is an array of 256 16-bit quantities,
|
||||
* representing a mapping between the input and output for that channel.
|
||||
* The input is the index into the array, and the output is the 16-bit
|
||||
* gamma value at that index, scaled to the output color precision.
|
||||
*
|
||||
* You may pass NULL for any of the channels to leave it unchanged.
|
||||
* If the call succeeds, it will return 0. If the display driver or
|
||||
* hardware does not support gamma translation, or otherwise fails,
|
||||
* this function will return -1.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_SetGammaRamp(const Uint16 *red, const Uint16 *green, const Uint16 *blue);
|
||||
|
||||
/*
|
||||
* Retrieve the current values of the gamma translation tables.
|
||||
*
|
||||
* You must pass in valid pointers to arrays of 256 16-bit quantities.
|
||||
* Any of the pointers may be NULL to ignore that channel.
|
||||
* If the call succeeds, it will return 0. If the display driver or
|
||||
* hardware does not support gamma translation, or otherwise fails,
|
||||
* this function will return -1.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_GetGammaRamp(Uint16 *red, Uint16 *green, Uint16 *blue);
|
||||
|
||||
/*
|
||||
* Sets a portion of the colormap for the given 8-bit surface. If 'surface'
|
||||
* is not a palettized surface, this function does nothing, returning 0.
|
||||
* If all of the colors were set as passed to SDL_SetColors(), it will
|
||||
* return 1. If not all the color entries were set exactly as given,
|
||||
* it will return 0, and you should look at the surface palette to
|
||||
* determine the actual color palette.
|
||||
*
|
||||
* When 'surface' is the surface associated with the current display, the
|
||||
* display colormap will be updated with the requested colors. If
|
||||
* SDL_HWPALETTE was set in SDL_SetVideoMode() flags, SDL_SetColors()
|
||||
* will always return 1, and the palette is guaranteed to be set the way
|
||||
* you desire, even if the window colormap has to be warped or run under
|
||||
* emulation.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_SetColors(SDL_Surface *surface,
|
||||
SDL_Color *colors, int firstcolor, int ncolors);
|
||||
|
||||
/*
|
||||
* Sets a portion of the colormap for a given 8-bit surface.
|
||||
* 'flags' is one or both of:
|
||||
* SDL_LOGPAL -- set logical palette, which controls how blits are mapped
|
||||
* to/from the surface,
|
||||
* SDL_PHYSPAL -- set physical palette, which controls how pixels look on
|
||||
* the screen
|
||||
* Only screens have physical palettes. Separate change of physical/logical
|
||||
* palettes is only possible if the screen has SDL_HWPALETTE set.
|
||||
*
|
||||
* The return value is 1 if all colours could be set as requested, and 0
|
||||
* otherwise.
|
||||
*
|
||||
* SDL_SetColors() is equivalent to calling this function with
|
||||
* flags = (SDL_LOGPAL|SDL_PHYSPAL).
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_SetPalette(SDL_Surface *surface, int flags,
|
||||
SDL_Color *colors, int firstcolor,
|
||||
int ncolors);
|
||||
|
||||
/*
|
||||
* Maps an RGB triple to an opaque pixel value for a given pixel format
|
||||
*/
|
||||
extern DECLSPEC Uint32 SDLCALL SDL_MapRGB
|
||||
(SDL_PixelFormat *format, Uint8 r, Uint8 g, Uint8 b);
|
||||
|
||||
/*
|
||||
* Maps an RGBA quadruple to a pixel value for a given pixel format
|
||||
*/
|
||||
extern DECLSPEC Uint32 SDLCALL SDL_MapRGBA(SDL_PixelFormat *format,
|
||||
Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
|
||||
/*
|
||||
* Maps a pixel value into the RGB components for a given pixel format
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_GetRGB(Uint32 pixel, SDL_PixelFormat *fmt,
|
||||
Uint8 *r, Uint8 *g, Uint8 *b);
|
||||
|
||||
/*
|
||||
* Maps a pixel value into the RGBA components for a given pixel format
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_GetRGBA(Uint32 pixel, SDL_PixelFormat *fmt,
|
||||
Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a);
|
||||
|
||||
/*
|
||||
* Allocate and free an RGB surface (must be called after SDL_SetVideoMode)
|
||||
* If the depth is 4 or 8 bits, an empty palette is allocated for the surface.
|
||||
* If the depth is greater than 8 bits, the pixel format is set using the
|
||||
* flags '[RGB]mask'.
|
||||
* If the function runs out of memory, it will return NULL.
|
||||
*
|
||||
* The 'flags' tell what kind of surface to create.
|
||||
* SDL_SWSURFACE means that the surface should be created in system memory.
|
||||
* SDL_HWSURFACE means that the surface should be created in video memory,
|
||||
* with the same format as the display surface. This is useful for surfaces
|
||||
* that will not change much, to take advantage of hardware acceleration
|
||||
* when being blitted to the display surface.
|
||||
* SDL_ASYNCBLIT means that SDL will try to perform asynchronous blits with
|
||||
* this surface, but you must always lock it before accessing the pixels.
|
||||
* SDL will wait for current blits to finish before returning from the lock.
|
||||
* SDL_SRCCOLORKEY indicates that the surface will be used for colorkey blits.
|
||||
* If the hardware supports acceleration of colorkey blits between
|
||||
* two surfaces in video memory, SDL will try to place the surface in
|
||||
* video memory. If this isn't possible or if there is no hardware
|
||||
* acceleration available, the surface will be placed in system memory.
|
||||
* SDL_SRCALPHA means that the surface will be used for alpha blits and
|
||||
* if the hardware supports hardware acceleration of alpha blits between
|
||||
* two surfaces in video memory, to place the surface in video memory
|
||||
* if possible, otherwise it will be placed in system memory.
|
||||
* If the surface is created in video memory, blits will be _much_ faster,
|
||||
* but the surface format must be identical to the video surface format,
|
||||
* and the only way to access the pixels member of the surface is to use
|
||||
* the SDL_LockSurface() and SDL_UnlockSurface() calls.
|
||||
* If the requested surface actually resides in video memory, SDL_HWSURFACE
|
||||
* will be set in the flags member of the returned surface. If for some
|
||||
* reason the surface could not be placed in video memory, it will not have
|
||||
* the SDL_HWSURFACE flag set, and will be created in system memory instead.
|
||||
*/
|
||||
#define SDL_AllocSurface SDL_CreateRGBSurface
|
||||
extern DECLSPEC SDL_Surface * SDLCALL SDL_CreateRGBSurface
|
||||
(Uint32 flags, int width, int height, int depth,
|
||||
Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask);
|
||||
extern DECLSPEC SDL_Surface * SDLCALL SDL_CreateRGBSurfaceFrom(void *pixels,
|
||||
int width, int height, int depth, int pitch,
|
||||
Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask);
|
||||
extern DECLSPEC void SDLCALL SDL_FreeSurface(SDL_Surface *surface);
|
||||
|
||||
/*
|
||||
* SDL_LockSurface() sets up a surface for directly accessing the pixels.
|
||||
* Between calls to SDL_LockSurface()/SDL_UnlockSurface(), you can write
|
||||
* to and read from 'surface->pixels', using the pixel format stored in
|
||||
* 'surface->format'. Once you are done accessing the surface, you should
|
||||
* use SDL_UnlockSurface() to release it.
|
||||
*
|
||||
* Not all surfaces require locking. If SDL_MUSTLOCK(surface) evaluates
|
||||
* to 0, then you can read and write to the surface at any time, and the
|
||||
* pixel format of the surface will not change. In particular, if the
|
||||
* SDL_HWSURFACE flag is not given when calling SDL_SetVideoMode(), you
|
||||
* will not need to lock the display surface before accessing it.
|
||||
*
|
||||
* No operating system or library calls should be made between lock/unlock
|
||||
* pairs, as critical system locks may be held during this time.
|
||||
*
|
||||
* SDL_LockSurface() returns 0, or -1 if the surface couldn't be locked.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_LockSurface(SDL_Surface *surface);
|
||||
extern DECLSPEC void SDLCALL SDL_UnlockSurface(SDL_Surface *surface);
|
||||
|
||||
/*
|
||||
* Load a surface from a seekable SDL data source (memory or file.)
|
||||
* If 'freesrc' is non-zero, the source will be closed after being read.
|
||||
* Returns the new surface, or NULL if there was an error.
|
||||
* The new surface should be freed with SDL_FreeSurface().
|
||||
*/
|
||||
extern DECLSPEC SDL_Surface * SDLCALL SDL_LoadBMP_RW(SDL_RWops *src, int freesrc);
|
||||
|
||||
/* Convenience macro -- load a surface from a file */
|
||||
#define SDL_LoadBMP(file) SDL_LoadBMP_RW(SDL_RWFromFile(file, "rb"), 1)
|
||||
|
||||
/*
|
||||
* Save a surface to a seekable SDL data source (memory or file.)
|
||||
* If 'freedst' is non-zero, the source will be closed after being written.
|
||||
* Returns 0 if successful or -1 if there was an error.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_SaveBMP_RW
|
||||
(SDL_Surface *surface, SDL_RWops *dst, int freedst);
|
||||
|
||||
/* Convenience macro -- save a surface to a file */
|
||||
#define SDL_SaveBMP(surface, file) \
|
||||
SDL_SaveBMP_RW(surface, SDL_RWFromFile(file, "wb"), 1)
|
||||
|
||||
/*
|
||||
* Sets the color key (transparent pixel) in a blittable surface.
|
||||
* If 'flag' is SDL_SRCCOLORKEY (optionally OR'd with SDL_RLEACCEL),
|
||||
* 'key' will be the transparent pixel in the source image of a blit.
|
||||
* SDL_RLEACCEL requests RLE acceleration for the surface if present,
|
||||
* and removes RLE acceleration if absent.
|
||||
* If 'flag' is 0, this function clears any current color key.
|
||||
* This function returns 0, or -1 if there was an error.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_SetColorKey
|
||||
(SDL_Surface *surface, Uint32 flag, Uint32 key);
|
||||
|
||||
/*
|
||||
* This function sets the alpha value for the entire surface, as opposed to
|
||||
* using the alpha component of each pixel. This value measures the range
|
||||
* of transparency of the surface, 0 being completely transparent to 255
|
||||
* being completely opaque. An 'alpha' value of 255 causes blits to be
|
||||
* opaque, the source pixels copied to the destination (the default). Note
|
||||
* that per-surface alpha can be combined with colorkey transparency.
|
||||
*
|
||||
* If 'flag' is 0, alpha blending is disabled for the surface.
|
||||
* If 'flag' is SDL_SRCALPHA, alpha blending is enabled for the surface.
|
||||
* OR:ing the flag with SDL_RLEACCEL requests RLE acceleration for the
|
||||
* surface; if SDL_RLEACCEL is not specified, the RLE accel will be removed.
|
||||
*
|
||||
* The 'alpha' parameter is ignored for surfaces that have an alpha channel.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_SetAlpha(SDL_Surface *surface, Uint32 flag, Uint8 alpha);
|
||||
|
||||
/*
|
||||
* Sets the clipping rectangle for the destination surface in a blit.
|
||||
*
|
||||
* If the clip rectangle is NULL, clipping will be disabled.
|
||||
* If the clip rectangle doesn't intersect the surface, the function will
|
||||
* return SDL_FALSE and blits will be completely clipped. Otherwise the
|
||||
* function returns SDL_TRUE and blits to the surface will be clipped to
|
||||
* the intersection of the surface area and the clipping rectangle.
|
||||
*
|
||||
* Note that blits are automatically clipped to the edges of the source
|
||||
* and destination surfaces.
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_SetClipRect(SDL_Surface *surface, const SDL_Rect *rect);
|
||||
|
||||
/*
|
||||
* Gets the clipping rectangle for the destination surface in a blit.
|
||||
* 'rect' must be a pointer to a valid rectangle which will be filled
|
||||
* with the correct values.
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_GetClipRect(SDL_Surface *surface, SDL_Rect *rect);
|
||||
|
||||
/*
|
||||
* Creates a new surface of the specified format, and then copies and maps
|
||||
* the given surface to it so the blit of the converted surface will be as
|
||||
* fast as possible. If this function fails, it returns NULL.
|
||||
*
|
||||
* The 'flags' parameter is passed to SDL_CreateRGBSurface() and has those
|
||||
* semantics. You can also pass SDL_RLEACCEL in the flags parameter and
|
||||
* SDL will try to RLE accelerate colorkey and alpha blits in the resulting
|
||||
* surface.
|
||||
*
|
||||
* This function is used internally by SDL_DisplayFormat().
|
||||
*/
|
||||
extern DECLSPEC SDL_Surface * SDLCALL SDL_ConvertSurface
|
||||
(SDL_Surface *src, SDL_PixelFormat *fmt, Uint32 flags);
|
||||
|
||||
/*
|
||||
* This performs a fast blit from the source surface to the destination
|
||||
* surface. It assumes that the source and destination rectangles are
|
||||
* the same size. If either 'srcrect' or 'dstrect' are NULL, the entire
|
||||
* surface (src or dst) is copied. The final blit rectangles are saved
|
||||
* in 'srcrect' and 'dstrect' after all clipping is performed.
|
||||
* If the blit is successful, it returns 0, otherwise it returns -1.
|
||||
*
|
||||
* The blit function should not be called on a locked surface.
|
||||
*
|
||||
* The blit semantics for surfaces with and without alpha and colorkey
|
||||
* are defined as follows:
|
||||
*
|
||||
* RGBA->RGB:
|
||||
* SDL_SRCALPHA set:
|
||||
* alpha-blend (using alpha-channel).
|
||||
* SDL_SRCCOLORKEY ignored.
|
||||
* SDL_SRCALPHA not set:
|
||||
* copy RGB.
|
||||
* if SDL_SRCCOLORKEY set, only copy the pixels matching the
|
||||
* RGB values of the source colour key, ignoring alpha in the
|
||||
* comparison.
|
||||
*
|
||||
* RGB->RGBA:
|
||||
* SDL_SRCALPHA set:
|
||||
* alpha-blend (using the source per-surface alpha value);
|
||||
* set destination alpha to opaque.
|
||||
* SDL_SRCALPHA not set:
|
||||
* copy RGB, set destination alpha to source per-surface alpha value.
|
||||
* both:
|
||||
* if SDL_SRCCOLORKEY set, only copy the pixels matching the
|
||||
* source colour key.
|
||||
*
|
||||
* RGBA->RGBA:
|
||||
* SDL_SRCALPHA set:
|
||||
* alpha-blend (using the source alpha channel) the RGB values;
|
||||
* leave destination alpha untouched. [Note: is this correct?]
|
||||
* SDL_SRCCOLORKEY ignored.
|
||||
* SDL_SRCALPHA not set:
|
||||
* copy all of RGBA to the destination.
|
||||
* if SDL_SRCCOLORKEY set, only copy the pixels matching the
|
||||
* RGB values of the source colour key, ignoring alpha in the
|
||||
* comparison.
|
||||
*
|
||||
* RGB->RGB:
|
||||
* SDL_SRCALPHA set:
|
||||
* alpha-blend (using the source per-surface alpha value).
|
||||
* SDL_SRCALPHA not set:
|
||||
* copy RGB.
|
||||
* both:
|
||||
* if SDL_SRCCOLORKEY set, only copy the pixels matching the
|
||||
* source colour key.
|
||||
*
|
||||
* If either of the surfaces were in video memory, and the blit returns -2,
|
||||
* the video memory was lost, so it should be reloaded with artwork and
|
||||
* re-blitted:
|
||||
while ( SDL_BlitSurface(image, imgrect, screen, dstrect) == -2 ) {
|
||||
while ( SDL_LockSurface(image) < 0 )
|
||||
Sleep(10);
|
||||
-- Write image pixels to image->pixels --
|
||||
SDL_UnlockSurface(image);
|
||||
}
|
||||
* This happens under DirectX 5.0 when the system switches away from your
|
||||
* fullscreen application. The lock will also fail until you have access
|
||||
* to the video memory again.
|
||||
*/
|
||||
/* You should call SDL_BlitSurface() unless you know exactly how SDL
|
||||
blitting works internally and how to use the other blit functions.
|
||||
*/
|
||||
#define SDL_BlitSurface SDL_UpperBlit
|
||||
|
||||
/* This is the public blit function, SDL_BlitSurface(), and it performs
|
||||
rectangle validation and clipping before passing it to SDL_LowerBlit()
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_UpperBlit
|
||||
(SDL_Surface *src, SDL_Rect *srcrect,
|
||||
SDL_Surface *dst, SDL_Rect *dstrect);
|
||||
/* This is a semi-private blit function and it performs low-level surface
|
||||
blitting only.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_LowerBlit
|
||||
(SDL_Surface *src, SDL_Rect *srcrect,
|
||||
SDL_Surface *dst, SDL_Rect *dstrect);
|
||||
|
||||
/*
|
||||
* This function performs a fast fill of the given rectangle with 'color'
|
||||
* The given rectangle is clipped to the destination surface clip area
|
||||
* and the final fill rectangle is saved in the passed in pointer.
|
||||
* If 'dstrect' is NULL, the whole surface will be filled with 'color'
|
||||
* The color should be a pixel of the format used by the surface, and
|
||||
* can be generated by the SDL_MapRGB() function.
|
||||
* This function returns 0 on success, or -1 on error.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_FillRect
|
||||
(SDL_Surface *dst, SDL_Rect *dstrect, Uint32 color);
|
||||
|
||||
/*
|
||||
* This function takes a surface and copies it to a new surface of the
|
||||
* pixel format and colors of the video framebuffer, suitable for fast
|
||||
* blitting onto the display surface. It calls SDL_ConvertSurface()
|
||||
*
|
||||
* If you want to take advantage of hardware colorkey or alpha blit
|
||||
* acceleration, you should set the colorkey and alpha value before
|
||||
* calling this function.
|
||||
*
|
||||
* If the conversion fails or runs out of memory, it returns NULL
|
||||
*/
|
||||
extern DECLSPEC SDL_Surface * SDLCALL SDL_DisplayFormat(SDL_Surface *surface);
|
||||
|
||||
/*
|
||||
* This function takes a surface and copies it to a new surface of the
|
||||
* pixel format and colors of the video framebuffer (if possible),
|
||||
* suitable for fast alpha blitting onto the display surface.
|
||||
* The new surface will always have an alpha channel.
|
||||
*
|
||||
* If you want to take advantage of hardware colorkey or alpha blit
|
||||
* acceleration, you should set the colorkey and alpha value before
|
||||
* calling this function.
|
||||
*
|
||||
* If the conversion fails or runs out of memory, it returns NULL
|
||||
*/
|
||||
extern DECLSPEC SDL_Surface * SDLCALL SDL_DisplayFormatAlpha(SDL_Surface *surface);
|
||||
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
/* YUV video surface overlay functions */
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
/* This function creates a video output overlay
|
||||
Calling the returned surface an overlay is something of a misnomer because
|
||||
the contents of the display surface underneath the area where the overlay
|
||||
is shown is undefined - it may be overwritten with the converted YUV data.
|
||||
*/
|
||||
extern DECLSPEC SDL_Overlay * SDLCALL SDL_CreateYUVOverlay(int width, int height,
|
||||
Uint32 format, SDL_Surface *display);
|
||||
|
||||
/* Lock an overlay for direct access, and unlock it when you are done */
|
||||
extern DECLSPEC int SDLCALL SDL_LockYUVOverlay(SDL_Overlay *overlay);
|
||||
extern DECLSPEC void SDLCALL SDL_UnlockYUVOverlay(SDL_Overlay *overlay);
|
||||
|
||||
/* Blit a video overlay to the display surface.
|
||||
The contents of the video surface underneath the blit destination are
|
||||
not defined.
|
||||
The width and height of the destination rectangle may be different from
|
||||
that of the overlay, but currently only 2x scaling is supported.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_DisplayYUVOverlay(SDL_Overlay *overlay, SDL_Rect *dstrect);
|
||||
|
||||
/* Free a video overlay */
|
||||
extern DECLSPEC void SDLCALL SDL_FreeYUVOverlay(SDL_Overlay *overlay);
|
||||
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
/* OpenGL support functions. */
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
/*
|
||||
* Dynamically load an OpenGL library, or the default one if path is NULL
|
||||
*
|
||||
* If you do this, you need to retrieve all of the GL functions used in
|
||||
* your program from the dynamic library using SDL_GL_GetProcAddress().
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_GL_LoadLibrary(const char *path);
|
||||
|
||||
/*
|
||||
* Get the address of a GL function
|
||||
*/
|
||||
extern DECLSPEC void * SDLCALL SDL_GL_GetProcAddress(const char* proc);
|
||||
|
||||
/*
|
||||
* Set an attribute of the OpenGL subsystem before intialization.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_GL_SetAttribute(SDL_GLattr attr, int value);
|
||||
|
||||
/*
|
||||
* Get an attribute of the OpenGL subsystem from the windowing
|
||||
* interface, such as glX. This is of course different from getting
|
||||
* the values from SDL's internal OpenGL subsystem, which only
|
||||
* stores the values you request before initialization.
|
||||
*
|
||||
* Developers should track the values they pass into SDL_GL_SetAttribute
|
||||
* themselves if they want to retrieve these values.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_GL_GetAttribute(SDL_GLattr attr, int* value);
|
||||
|
||||
/*
|
||||
* Swap the OpenGL buffers, if double-buffering is supported.
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_GL_SwapBuffers(void);
|
||||
|
||||
/*
|
||||
* Internal functions that should not be called unless you have read
|
||||
* and understood the source code for these functions.
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_GL_UpdateRects(int numrects, SDL_Rect* rects);
|
||||
extern DECLSPEC void SDLCALL SDL_GL_Lock(void);
|
||||
extern DECLSPEC void SDLCALL SDL_GL_Unlock(void);
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
/* These functions allow interaction with the window manager, if any. */
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
/*
|
||||
* Sets/Gets the title and icon text of the display window (UTF-8 encoded)
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_WM_SetCaption(const char *title, const char *icon);
|
||||
extern DECLSPEC void SDLCALL SDL_WM_GetCaption(char **title, char **icon);
|
||||
|
||||
/*
|
||||
* Sets the icon for the display window.
|
||||
* This function must be called before the first call to SDL_SetVideoMode().
|
||||
* It takes an icon surface, and a mask in MSB format.
|
||||
* If 'mask' is NULL, the entire icon surface will be used as the icon.
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_WM_SetIcon(SDL_Surface *icon, Uint8 *mask);
|
||||
|
||||
/*
|
||||
* This function iconifies the window, and returns 1 if it succeeded.
|
||||
* If the function succeeds, it generates an SDL_APPACTIVE loss event.
|
||||
* This function is a noop and returns 0 in non-windowed environments.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_WM_IconifyWindow(void);
|
||||
|
||||
/*
|
||||
* Toggle fullscreen mode without changing the contents of the screen.
|
||||
* If the display surface does not require locking before accessing
|
||||
* the pixel information, then the memory pointers will not change.
|
||||
*
|
||||
* If this function was able to toggle fullscreen mode (change from
|
||||
* running in a window to fullscreen, or vice-versa), it will return 1.
|
||||
* If it is not implemented, or fails, it returns 0.
|
||||
*
|
||||
* The next call to SDL_SetVideoMode() will set the mode fullscreen
|
||||
* attribute based on the flags parameter - if SDL_FULLSCREEN is not
|
||||
* set, then the display will be windowed by default where supported.
|
||||
*
|
||||
* This is currently only implemented in the X11 video driver.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_WM_ToggleFullScreen(SDL_Surface *surface);
|
||||
|
||||
/*
|
||||
* This function allows you to set and query the input grab state of
|
||||
* the application. It returns the new input grab state.
|
||||
*/
|
||||
typedef enum {
|
||||
SDL_GRAB_QUERY = -1,
|
||||
SDL_GRAB_OFF = 0,
|
||||
SDL_GRAB_ON = 1,
|
||||
SDL_GRAB_FULLSCREEN /* Used internally */
|
||||
} SDL_GrabMode;
|
||||
/*
|
||||
* Grabbing means that the mouse is confined to the application window,
|
||||
* and nearly all keyboard input is passed directly to the application,
|
||||
* and not interpreted by a window manager, if any.
|
||||
*/
|
||||
extern DECLSPEC SDL_GrabMode SDLCALL SDL_WM_GrabInput(SDL_GrabMode mode);
|
||||
|
||||
/* Not in public API at the moment - do not use! */
|
||||
extern DECLSPEC int SDLCALL SDL_SoftStretch(SDL_Surface *src, SDL_Rect *srcrect,
|
||||
SDL_Surface *dst, SDL_Rect *dstrect);
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* _SDL_video_h */
|
||||
@@ -1,150 +0,0 @@
|
||||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2004 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
/* This file sets things up for C dynamic library function definitions,
|
||||
static inlined functions, and structures aligned at 4-byte alignment.
|
||||
If you don't like ugly C preprocessor code, don't look at this file. :)
|
||||
*/
|
||||
|
||||
/* This shouldn't be nested -- included it around code only. */
|
||||
#ifdef _begin_code_h
|
||||
#error Nested inclusion of begin_code.h
|
||||
#endif
|
||||
#define _begin_code_h
|
||||
|
||||
/* Some compilers use a special export keyword */
|
||||
#ifndef DECLSPEC
|
||||
# if defined(__BEOS__)
|
||||
# if defined(__GNUC__)
|
||||
# define DECLSPEC __declspec(dllexport)
|
||||
# else
|
||||
# define DECLSPEC __declspec(export)
|
||||
# endif
|
||||
# elif defined(__WIN32__)
|
||||
# ifdef __BORLANDC__
|
||||
# ifdef BUILD_SDL
|
||||
# define DECLSPEC
|
||||
# else
|
||||
# define DECLSPEC __declspec(dllimport)
|
||||
# endif
|
||||
# else
|
||||
# define DECLSPEC __declspec(dllexport)
|
||||
# endif
|
||||
# elif defined(__OS2__)
|
||||
# ifdef __WATCOMC__
|
||||
# ifdef BUILD_SDL
|
||||
# define DECLSPEC __declspec(dllexport)
|
||||
# else
|
||||
# define DECLSPEC
|
||||
# endif
|
||||
# else
|
||||
# define DECLSPEC
|
||||
# endif
|
||||
# else
|
||||
# if defined(__GNUC__) && __GNUC__ >= 4
|
||||
# define DECLSPEC __attribute__ ((visibility("default")))
|
||||
# else
|
||||
# define DECLSPEC
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* By default SDL uses the C calling convention */
|
||||
#ifndef SDLCALL
|
||||
#if defined(__WIN32__) && !defined(__GNUC__)
|
||||
#define SDLCALL __cdecl
|
||||
#else
|
||||
#ifdef __OS2__
|
||||
/* But on OS/2, we use the _System calling convention */
|
||||
/* to be compatible with every compiler */
|
||||
#define SDLCALL _System
|
||||
#else
|
||||
#define SDLCALL
|
||||
#endif
|
||||
#endif
|
||||
#endif /* SDLCALL */
|
||||
|
||||
/* Removed DECLSPEC on Symbian OS because SDL cannot be a DLL in EPOC */
|
||||
#ifdef __SYMBIAN32__
|
||||
#undef DECLSPEC
|
||||
#define DECLSPEC
|
||||
#endif /* __SYMBIAN32__ */
|
||||
|
||||
/* Force structure packing at 4 byte alignment.
|
||||
This is necessary if the header is included in code which has structure
|
||||
packing set to an alternate value, say for loading structures from disk.
|
||||
The packing is reset to the previous value in close_code.h
|
||||
*/
|
||||
#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__BORLANDC__)
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable: 4103)
|
||||
#endif
|
||||
#ifdef __BORLANDC__
|
||||
#pragma nopackwarning
|
||||
#endif
|
||||
#pragma pack(push,4)
|
||||
#elif (defined(__MWERKS__) && defined(__MACOS__))
|
||||
#pragma options align=mac68k4byte
|
||||
#pragma enumsalwaysint on
|
||||
#endif /* Compiler needs structure packing set */
|
||||
|
||||
/* Set up compiler-specific options for inlining functions */
|
||||
#ifndef SDL_INLINE_OKAY
|
||||
#ifdef __GNUC__
|
||||
#define SDL_INLINE_OKAY
|
||||
#else
|
||||
/* Add any special compiler-specific cases here */
|
||||
#if defined(_MSC_VER) || defined(__BORLANDC__) || \
|
||||
defined(__DMC__) || defined(__SC__) || \
|
||||
defined(__WATCOMC__) || defined(__LCC__) || \
|
||||
defined(__DECC)
|
||||
#ifndef __inline__
|
||||
#define __inline__ __inline
|
||||
#endif
|
||||
#define SDL_INLINE_OKAY
|
||||
#else
|
||||
#if !defined(__MRC__) && !defined(_SGI_SOURCE)
|
||||
#define __inline__ inline
|
||||
#define SDL_INLINE_OKAY
|
||||
#endif /* Not a funky compiler */
|
||||
#endif /* Visual C++ */
|
||||
#endif /* GNU C */
|
||||
#endif /* SDL_INLINE_OKAY */
|
||||
|
||||
/* If inlining isn't supported, remove "__inline__", turning static
|
||||
inlined functions into static functions (resulting in code bloat
|
||||
in all files which include the offending header files)
|
||||
*/
|
||||
#ifndef SDL_INLINE_OKAY
|
||||
#define __inline__
|
||||
#endif
|
||||
|
||||
/* Apparently this is needed by several Windows compilers */
|
||||
#if !defined(__MACH__)
|
||||
#ifndef NULL
|
||||
#ifdef __cplusplus
|
||||
#define NULL 0
|
||||
#else
|
||||
#define NULL ((void *)0)
|
||||
#endif
|
||||
#endif /* NULL */
|
||||
#endif /* ! Mac OS X - breaks precompiled headers */
|
||||
@@ -1,41 +0,0 @@
|
||||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2004 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
/* This file reverses the effects of begin_code.h and should be included
|
||||
after you finish any function and structure declarations in your headers
|
||||
*/
|
||||
|
||||
#undef _begin_code_h
|
||||
|
||||
/* Reset structure packing at previous byte alignment */
|
||||
#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__WATCOMC__) || defined(__BORLANDC__)
|
||||
#ifdef __BORLANDC__
|
||||
#pragma nopackwarning
|
||||
#endif
|
||||
#if (defined(__MWERKS__) && defined(__MACOS__))
|
||||
#pragma options align=reset
|
||||
#pragma enumsalwaysint reset
|
||||
#else
|
||||
#pragma pack(pop)
|
||||
#endif
|
||||
#endif /* Compiler needs structure packing set */
|
||||
|
||||
@@ -1,111 +0,0 @@
|
||||
/*
|
||||
===========================================================================
|
||||
Copyright (C) 1999-2005 Id Software, Inc.
|
||||
Copyright (C) 2000-2006 Tim Angus
|
||||
|
||||
This file is part of Tremulous.
|
||||
|
||||
Tremulous is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
Tremulous is distributed in the hope that it will be
|
||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Tremulous; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
===========================================================================
|
||||
*/
|
||||
|
||||
#include "cg_local.h"
|
||||
|
||||
/*
|
||||
===============
|
||||
CG_RunLerpFrame
|
||||
|
||||
Sets cg.snap, cg.oldFrame, and cg.backlerp
|
||||
cg.time should be between oldFrameTime and frameTime after exit
|
||||
===============
|
||||
*/
|
||||
void CG_RunLerpFrame( lerpFrame_t *lf )
|
||||
{
|
||||
int f, numFrames;
|
||||
animation_t *anim;
|
||||
|
||||
// debugging tool to get no animations
|
||||
if( cg_animSpeed.integer == 0 )
|
||||
{
|
||||
lf->oldFrame = lf->frame = lf->backlerp = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
// if we have passed the current frame, move it to
|
||||
// oldFrame and calculate a new frame
|
||||
if( cg.time >= lf->frameTime )
|
||||
{
|
||||
lf->oldFrame = lf->frame;
|
||||
lf->oldFrameTime = lf->frameTime;
|
||||
|
||||
// get the next frame based on the animation
|
||||
anim = lf->animation;
|
||||
if( !anim->frameLerp )
|
||||
return; // shouldn't happen
|
||||
|
||||
if( cg.time < lf->animationTime )
|
||||
lf->frameTime = lf->animationTime; // initial lerp
|
||||
else
|
||||
lf->frameTime = lf->oldFrameTime + anim->frameLerp;
|
||||
|
||||
f = ( lf->frameTime - lf->animationTime ) / anim->frameLerp;
|
||||
numFrames = anim->numFrames;
|
||||
if( anim->flipflop )
|
||||
numFrames *= 2;
|
||||
|
||||
if( f >= numFrames )
|
||||
{
|
||||
f -= numFrames;
|
||||
if( anim->loopFrames )
|
||||
{
|
||||
f %= anim->loopFrames;
|
||||
f += anim->numFrames - anim->loopFrames;
|
||||
}
|
||||
else
|
||||
{
|
||||
f = numFrames - 1;
|
||||
// the animation is stuck at the end, so it
|
||||
// can immediately transition to another sequence
|
||||
lf->frameTime = cg.time;
|
||||
}
|
||||
}
|
||||
|
||||
if( anim->reversed )
|
||||
lf->frame = anim->firstFrame + anim->numFrames - 1 - f;
|
||||
else if( anim->flipflop && f >= anim->numFrames )
|
||||
lf->frame = anim->firstFrame + anim->numFrames - 1 - ( f % anim->numFrames );
|
||||
else
|
||||
lf->frame = anim->firstFrame + f;
|
||||
|
||||
if( cg.time > lf->frameTime )
|
||||
{
|
||||
lf->frameTime = cg.time;
|
||||
if( cg_debugAnim.integer )
|
||||
CG_Printf( "Clamp lf->frameTime\n" );
|
||||
}
|
||||
}
|
||||
|
||||
if( lf->frameTime > cg.time + 200 )
|
||||
lf->frameTime = cg.time;
|
||||
|
||||
if( lf->oldFrameTime > cg.time )
|
||||
lf->oldFrameTime = cg.time;
|
||||
|
||||
// calculate current lerp value
|
||||
if( lf->frameTime == lf->oldFrameTime )
|
||||
lf->backlerp = 0;
|
||||
else
|
||||
lf->backlerp = 1.0 - (float)( cg.time - lf->oldFrameTime ) / ( lf->frameTime - lf->oldFrameTime );
|
||||
}
|
||||
@@ -1,227 +0,0 @@
|
||||
/*
|
||||
===========================================================================
|
||||
Copyright (C) 1999-2005 Id Software, Inc.
|
||||
Copyright (C) 2000-2006 Tim Angus
|
||||
|
||||
This file is part of Tremulous.
|
||||
|
||||
Tremulous is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
Tremulous is distributed in the hope that it will be
|
||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Tremulous; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
===========================================================================
|
||||
*/
|
||||
|
||||
#include "cg_local.h"
|
||||
|
||||
|
||||
/*
|
||||
===============
|
||||
CG_DoorAnimation
|
||||
===============
|
||||
*/
|
||||
static void CG_DoorAnimation( centity_t *cent, int *old, int *now, float *backLerp )
|
||||
{
|
||||
CG_RunLerpFrame( ¢->lerpFrame );
|
||||
|
||||
*old = cent->lerpFrame.oldFrame;
|
||||
*now = cent->lerpFrame.frame;
|
||||
*backLerp = cent->lerpFrame.backlerp;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
===============
|
||||
CG_ModelDoor
|
||||
===============
|
||||
*/
|
||||
void CG_ModelDoor( centity_t *cent )
|
||||
{
|
||||
refEntity_t ent;
|
||||
entityState_t *es;
|
||||
animation_t anim;
|
||||
lerpFrame_t *lf = ¢->lerpFrame;
|
||||
|
||||
es = ¢->currentState;
|
||||
|
||||
if( !es->modelindex )
|
||||
return;
|
||||
|
||||
//create the render entity
|
||||
memset( &ent, 0, sizeof( ent ) );
|
||||
VectorCopy( cent->lerpOrigin, ent.origin );
|
||||
VectorCopy( cent->lerpOrigin, ent.oldorigin );
|
||||
AnglesToAxis( cent->lerpAngles, ent.axis );
|
||||
|
||||
ent.renderfx = RF_NOSHADOW;
|
||||
|
||||
//add the door model
|
||||
ent.skinNum = 0;
|
||||
ent.hModel = cgs.gameModels[ es->modelindex ];
|
||||
|
||||
//scale the door
|
||||
VectorScale( ent.axis[ 0 ], es->origin2[ 0 ], ent.axis[ 0 ] );
|
||||
VectorScale( ent.axis[ 1 ], es->origin2[ 1 ], ent.axis[ 1 ] );
|
||||
VectorScale( ent.axis[ 2 ], es->origin2[ 2 ], ent.axis[ 2 ] );
|
||||
ent.nonNormalizedAxes = qtrue;
|
||||
|
||||
//setup animation
|
||||
anim.firstFrame = es->powerups;
|
||||
anim.numFrames = es->weapon;
|
||||
anim.reversed = !es->legsAnim;
|
||||
anim.flipflop = qfalse;
|
||||
anim.loopFrames = 0;
|
||||
anim.frameLerp = 1000 / es->torsoAnim;
|
||||
anim.initialLerp = 1000 / es->torsoAnim;
|
||||
|
||||
//door changed state
|
||||
if( es->legsAnim != cent->doorState )
|
||||
{
|
||||
lf->animationTime = lf->frameTime + anim.initialLerp;
|
||||
cent->doorState = es->legsAnim;
|
||||
}
|
||||
|
||||
lf->animation = &anim;
|
||||
|
||||
//run animation
|
||||
CG_DoorAnimation( cent, &ent.oldframe, &ent.frame, &ent.backlerp );
|
||||
|
||||
trap_R_AddRefEntityToScene( &ent );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
===============
|
||||
CG_AMOAnimation
|
||||
===============
|
||||
*/
|
||||
static void CG_AMOAnimation( centity_t *cent, int *old, int *now, float *backLerp )
|
||||
{
|
||||
if( !( cent->currentState.eFlags & EF_MOVER_STOP ) || cent->animPlaying )
|
||||
{
|
||||
int delta = cg.time - cent->miscTime;
|
||||
|
||||
//hack to prevent "pausing" mucking up the lerping
|
||||
if( delta > 900 )
|
||||
{
|
||||
cent->lerpFrame.oldFrameTime += delta;
|
||||
cent->lerpFrame.frameTime += delta;
|
||||
}
|
||||
|
||||
CG_RunLerpFrame( ¢->lerpFrame );
|
||||
cent->miscTime = cg.time;
|
||||
}
|
||||
|
||||
*old = cent->lerpFrame.oldFrame;
|
||||
*now = cent->lerpFrame.frame;
|
||||
*backLerp = cent->lerpFrame.backlerp;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
==================
|
||||
CG_animMapObj
|
||||
==================
|
||||
*/
|
||||
void CG_AnimMapObj( centity_t *cent )
|
||||
{
|
||||
refEntity_t ent;
|
||||
entityState_t *es;
|
||||
float scale;
|
||||
animation_t anim;
|
||||
|
||||
es = ¢->currentState;
|
||||
|
||||
// if set to invisible, skip
|
||||
if( !es->modelindex || ( es->eFlags & EF_NODRAW ) )
|
||||
return;
|
||||
|
||||
memset( &ent, 0, sizeof( ent ) );
|
||||
|
||||
VectorCopy( es->angles, cent->lerpAngles );
|
||||
AnglesToAxis( cent->lerpAngles, ent.axis );
|
||||
|
||||
ent.hModel = cgs.gameModels[ es->modelindex ];
|
||||
|
||||
VectorCopy( cent->lerpOrigin, ent.origin);
|
||||
VectorCopy( cent->lerpOrigin, ent.oldorigin);
|
||||
|
||||
ent.nonNormalizedAxes = qfalse;
|
||||
|
||||
//scale the model
|
||||
if( es->angles2[ 0 ] )
|
||||
{
|
||||
scale = es->angles2[ 0 ];
|
||||
VectorScale( ent.axis[ 0 ], scale, ent.axis[ 0 ] );
|
||||
VectorScale( ent.axis[ 1 ], scale, ent.axis[ 1 ] );
|
||||
VectorScale( ent.axis[ 2 ], scale, ent.axis[ 2 ] );
|
||||
ent.nonNormalizedAxes = qtrue;
|
||||
}
|
||||
|
||||
//setup animation
|
||||
anim.firstFrame = es->powerups;
|
||||
anim.numFrames = es->weapon;
|
||||
anim.reversed = qfalse;
|
||||
anim.flipflop = qfalse;
|
||||
|
||||
// if numFrames is negative the animation is reversed
|
||||
if( anim.numFrames < 0 )
|
||||
{
|
||||
anim.numFrames = -anim.numFrames;
|
||||
anim.reversed = qtrue;
|
||||
}
|
||||
|
||||
anim.loopFrames = es->torsoAnim;
|
||||
|
||||
if( !es->legsAnim )
|
||||
{
|
||||
anim.frameLerp = 1000;
|
||||
anim.initialLerp = 1000;
|
||||
}
|
||||
else
|
||||
{
|
||||
anim.frameLerp = 1000 / es->legsAnim;
|
||||
anim.initialLerp = 1000 / es->legsAnim;
|
||||
}
|
||||
|
||||
cent->lerpFrame.animation = &anim;
|
||||
|
||||
if( !anim.loopFrames )
|
||||
{
|
||||
// add one frame to allow the animation to play the last frame
|
||||
// add another to get it to stop playing at the first frame
|
||||
anim.numFrames += 2;
|
||||
|
||||
if( !cent->animInit )
|
||||
{
|
||||
cent->animInit = qtrue;
|
||||
cent->animPlaying = !( cent->currentState.eFlags & EF_MOVER_STOP );
|
||||
}
|
||||
else
|
||||
{
|
||||
if( cent->animLastState !=
|
||||
!( cent->currentState.eFlags & EF_MOVER_STOP ) )
|
||||
{
|
||||
cent->animPlaying = qtrue;
|
||||
cent->lerpFrame.animationTime = cg.time;
|
||||
cent->lerpFrame.frameTime = cg.time;
|
||||
}
|
||||
}
|
||||
cent->animLastState = !( cent->currentState.eFlags & EF_MOVER_STOP );
|
||||
}
|
||||
|
||||
//run animation
|
||||
CG_AMOAnimation( cent, &ent.oldframe, &ent.frame, &ent.backlerp );
|
||||
|
||||
// add to refresh list
|
||||
trap_R_AddRefEntityToScene(&ent);
|
||||
}
|
||||
@@ -1,404 +0,0 @@
|
||||
/*
|
||||
===========================================================================
|
||||
Copyright (C) 2000-2006 Tim Angus
|
||||
|
||||
This file is part of Tremulous.
|
||||
|
||||
Tremulous is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
Tremulous is distributed in the hope that it will be
|
||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Tremulous; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
===========================================================================
|
||||
*/
|
||||
|
||||
// cg_attachment.c -- an abstract attachment system
|
||||
|
||||
#include "cg_local.h"
|
||||
|
||||
/*
|
||||
===============
|
||||
CG_AttachmentPoint
|
||||
|
||||
Return the attachment point
|
||||
===============
|
||||
*/
|
||||
qboolean CG_AttachmentPoint( attachment_t *a, vec3_t v )
|
||||
{
|
||||
centity_t *cent;
|
||||
|
||||
if( !a )
|
||||
return qfalse;
|
||||
|
||||
// if it all breaks, then use the last point we know was correct
|
||||
VectorCopy( a->lastValidAttachmentPoint, v );
|
||||
|
||||
switch( a->type )
|
||||
{
|
||||
case AT_STATIC:
|
||||
if( !a->staticValid )
|
||||
return qfalse;
|
||||
|
||||
VectorCopy( a->origin, v );
|
||||
break;
|
||||
|
||||
case AT_TAG:
|
||||
if( !a->tagValid )
|
||||
return qfalse;
|
||||
|
||||
AxisCopy( axisDefault, a->re.axis );
|
||||
CG_PositionRotatedEntityOnTag( &a->re, &a->parent,
|
||||
a->model, a->tagName );
|
||||
VectorCopy( a->re.origin, v );
|
||||
break;
|
||||
|
||||
case AT_CENT:
|
||||
if( !a->centValid )
|
||||
return qfalse;
|
||||
|
||||
if( a->centNum == cg.predictedPlayerState.clientNum )
|
||||
{
|
||||
// this is smoother if it's the local client
|
||||
VectorCopy( cg.predictedPlayerState.origin, v );
|
||||
}
|
||||
else
|
||||
{
|
||||
cent = &cg_entities[ a->centNum ];
|
||||
VectorCopy( cent->lerpOrigin, v );
|
||||
}
|
||||
break;
|
||||
|
||||
case AT_PARTICLE:
|
||||
if( !a->particleValid )
|
||||
return qfalse;
|
||||
|
||||
if( !a->particle->valid )
|
||||
{
|
||||
a->particleValid = qfalse;
|
||||
return qfalse;
|
||||
}
|
||||
else
|
||||
VectorCopy( a->particle->origin, v );
|
||||
break;
|
||||
|
||||
default:
|
||||
CG_Printf( S_COLOR_RED "ERROR: Invalid attachmentType_t in attachment\n" );
|
||||
break;
|
||||
}
|
||||
|
||||
if( a->hasOffset )
|
||||
VectorAdd( v, a->offset, v );
|
||||
|
||||
VectorCopy( v, a->lastValidAttachmentPoint );
|
||||
|
||||
return qtrue;
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
CG_AttachmentDir
|
||||
|
||||
Return the attachment direction
|
||||
===============
|
||||
*/
|
||||
qboolean CG_AttachmentDir( attachment_t *a, vec3_t v )
|
||||
{
|
||||
vec3_t forward;
|
||||
centity_t *cent;
|
||||
|
||||
if( !a )
|
||||
return qfalse;
|
||||
|
||||
switch( a->type )
|
||||
{
|
||||
case AT_STATIC:
|
||||
return qfalse;
|
||||
break;
|
||||
|
||||
case AT_TAG:
|
||||
if( !a->tagValid )
|
||||
return qfalse;
|
||||
|
||||
VectorCopy( a->re.axis[ 0 ], v );
|
||||
break;
|
||||
|
||||
case AT_CENT:
|
||||
if( !a->centValid )
|
||||
return qfalse;
|
||||
|
||||
cent = &cg_entities[ a->centNum ];
|
||||
AngleVectors( cent->lerpAngles, forward, NULL, NULL );
|
||||
VectorCopy( forward, v );
|
||||
break;
|
||||
|
||||
case AT_PARTICLE:
|
||||
if( !a->particleValid )
|
||||
return qfalse;
|
||||
|
||||
if( !a->particle->valid )
|
||||
{
|
||||
a->particleValid = qfalse;
|
||||
return qfalse;
|
||||
}
|
||||
else
|
||||
VectorCopy( a->particle->velocity, v );
|
||||
break;
|
||||
|
||||
default:
|
||||
CG_Printf( S_COLOR_RED "ERROR: Invalid attachmentType_t in attachment\n" );
|
||||
break;
|
||||
}
|
||||
|
||||
VectorNormalize( v );
|
||||
return qtrue;
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
CG_AttachmentAxis
|
||||
|
||||
Return the attachment axis
|
||||
===============
|
||||
*/
|
||||
qboolean CG_AttachmentAxis( attachment_t *a, vec3_t axis[ 3 ] )
|
||||
{
|
||||
centity_t *cent;
|
||||
|
||||
if( !a )
|
||||
return qfalse;
|
||||
|
||||
switch( a->type )
|
||||
{
|
||||
case AT_STATIC:
|
||||
return qfalse;
|
||||
break;
|
||||
|
||||
case AT_TAG:
|
||||
if( !a->tagValid )
|
||||
return qfalse;
|
||||
|
||||
AxisCopy( a->re.axis, axis );
|
||||
break;
|
||||
|
||||
case AT_CENT:
|
||||
if( !a->centValid )
|
||||
return qfalse;
|
||||
|
||||
cent = &cg_entities[ a->centNum ];
|
||||
AnglesToAxis( cent->lerpAngles, axis );
|
||||
break;
|
||||
|
||||
case AT_PARTICLE:
|
||||
return qfalse;
|
||||
break;
|
||||
|
||||
default:
|
||||
CG_Printf( S_COLOR_RED "ERROR: Invalid attachmentType_t in attachment\n" );
|
||||
break;
|
||||
}
|
||||
|
||||
return qtrue;
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
CG_AttachmentVelocity
|
||||
|
||||
If the attachment can have velocity, return it
|
||||
===============
|
||||
*/
|
||||
qboolean CG_AttachmentVelocity( attachment_t *a, vec3_t v )
|
||||
{
|
||||
if( !a )
|
||||
return qfalse;
|
||||
|
||||
if( a->particleValid && a->particle->valid )
|
||||
{
|
||||
VectorCopy( a->particle->velocity, v );
|
||||
return qtrue;
|
||||
}
|
||||
else if( a->centValid )
|
||||
{
|
||||
centity_t *cent = &cg_entities[ a->centNum ];
|
||||
|
||||
VectorCopy( cent->currentState.pos.trDelta, v );
|
||||
return qtrue;
|
||||
}
|
||||
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
CG_AttachmentCentNum
|
||||
|
||||
If the attachment has a centNum, return it
|
||||
===============
|
||||
*/
|
||||
int CG_AttachmentCentNum( attachment_t *a )
|
||||
{
|
||||
if( !a || !a->centValid )
|
||||
return -1;
|
||||
|
||||
return a->centNum;
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
CG_Attached
|
||||
|
||||
If the attachment is valid, return qtrue
|
||||
===============
|
||||
*/
|
||||
qboolean CG_Attached( attachment_t *a )
|
||||
{
|
||||
if( !a )
|
||||
return qfalse;
|
||||
|
||||
return a->attached;
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
CG_AttachToPoint
|
||||
|
||||
Attach to a point in space
|
||||
===============
|
||||
*/
|
||||
void CG_AttachToPoint( attachment_t *a )
|
||||
{
|
||||
if( !a || !a->staticValid )
|
||||
return;
|
||||
|
||||
a->type = AT_STATIC;
|
||||
a->attached = qtrue;
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
CG_AttachToCent
|
||||
|
||||
Attach to a centity_t
|
||||
===============
|
||||
*/
|
||||
void CG_AttachToCent( attachment_t *a )
|
||||
{
|
||||
if( !a || !a->centValid )
|
||||
return;
|
||||
|
||||
a->type = AT_CENT;
|
||||
a->attached = qtrue;
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
CG_AttachToTag
|
||||
|
||||
Attach to a model tag
|
||||
===============
|
||||
*/
|
||||
void CG_AttachToTag( attachment_t *a )
|
||||
{
|
||||
if( !a || !a->tagValid )
|
||||
return;
|
||||
|
||||
a->type = AT_TAG;
|
||||
a->attached = qtrue;
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
CG_AttachToParticle
|
||||
|
||||
Attach to a particle
|
||||
===============
|
||||
*/
|
||||
void CG_AttachToParticle( attachment_t *a )
|
||||
{
|
||||
if( !a || !a->particleValid )
|
||||
return;
|
||||
|
||||
a->type = AT_PARTICLE;
|
||||
a->attached = qtrue;
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
CG_SetAttachmentPoint
|
||||
===============
|
||||
*/
|
||||
void CG_SetAttachmentPoint( attachment_t *a, vec3_t v )
|
||||
{
|
||||
if( !a )
|
||||
return;
|
||||
|
||||
VectorCopy( v, a->origin );
|
||||
a->staticValid = qtrue;
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
CG_SetAttachmentCent
|
||||
===============
|
||||
*/
|
||||
void CG_SetAttachmentCent( attachment_t *a, centity_t *cent )
|
||||
{
|
||||
if( !a || !cent )
|
||||
return;
|
||||
|
||||
a->centNum = cent->currentState.number;
|
||||
a->centValid = qtrue;
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
CG_SetAttachmentTag
|
||||
===============
|
||||
*/
|
||||
void CG_SetAttachmentTag( attachment_t *a, refEntity_t parent,
|
||||
qhandle_t model, char *tagName )
|
||||
{
|
||||
if( !a )
|
||||
return;
|
||||
|
||||
a->parent = parent;
|
||||
a->model = model;
|
||||
strncpy( a->tagName, tagName, MAX_STRING_CHARS );
|
||||
a->tagValid = qtrue;
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
CG_SetAttachmentParticle
|
||||
===============
|
||||
*/
|
||||
void CG_SetAttachmentParticle( attachment_t *a, particle_t *p )
|
||||
{
|
||||
if( !a )
|
||||
return;
|
||||
|
||||
a->particle = p;
|
||||
a->particleValid = qtrue;
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
CG_SetAttachmentOffset
|
||||
===============
|
||||
*/
|
||||
void CG_SetAttachmentOffset( attachment_t *a, vec3_t v )
|
||||
{
|
||||
if( !a )
|
||||
return;
|
||||
|
||||
VectorCopy( v, a->offset );
|
||||
a->hasOffset = qtrue;
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,325 +0,0 @@
|
||||
/*
|
||||
===========================================================================
|
||||
Copyright (C) 1999-2005 Id Software, Inc.
|
||||
Copyright (C) 2000-2006 Tim Angus
|
||||
|
||||
This file is part of Tremulous.
|
||||
|
||||
Tremulous is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
Tremulous is distributed in the hope that it will be
|
||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Tremulous; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
===========================================================================
|
||||
*/
|
||||
|
||||
// cg_consolecmds.c -- text commands typed in at the local console, or
|
||||
// executed by a key binding
|
||||
|
||||
|
||||
#include "cg_local.h"
|
||||
|
||||
|
||||
|
||||
void CG_TargetCommand_f( void )
|
||||
{
|
||||
int targetNum;
|
||||
char test[ 4 ];
|
||||
|
||||
targetNum = CG_CrosshairPlayer( );
|
||||
if( !targetNum )
|
||||
return;
|
||||
|
||||
trap_Argv( 1, test, 4 );
|
||||
trap_SendConsoleCommand( va( "gc %i %i", targetNum, atoi( test ) ) );
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
=================
|
||||
CG_SizeUp_f
|
||||
|
||||
Keybinding command
|
||||
=================
|
||||
*/
|
||||
static void CG_SizeUp_f( void )
|
||||
{
|
||||
trap_Cvar_Set( "cg_viewsize", va( "%i", (int)( cg_viewsize.integer + 10 ) ) );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
=================
|
||||
CG_SizeDown_f
|
||||
|
||||
Keybinding command
|
||||
=================
|
||||
*/
|
||||
static void CG_SizeDown_f( void )
|
||||
{
|
||||
trap_Cvar_Set( "cg_viewsize", va( "%i", (int)( cg_viewsize.integer - 10 ) ) );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
=============
|
||||
CG_Viewpos_f
|
||||
|
||||
Debugging command to print the current position
|
||||
=============
|
||||
*/
|
||||
static void CG_Viewpos_f( void )
|
||||
{
|
||||
CG_Printf( "(%i %i %i) : %i\n", (int)cg.refdef.vieworg[ 0 ],
|
||||
(int)cg.refdef.vieworg[ 1 ], (int)cg.refdef.vieworg[ 2 ],
|
||||
(int)cg.refdefViewAngles[ YAW ] );
|
||||
}
|
||||
|
||||
qboolean CG_RequestScores( void )
|
||||
{
|
||||
if( cg.scoresRequestTime + 2000 < cg.time )
|
||||
{
|
||||
// the scores are more than two seconds out of data,
|
||||
// so request new ones
|
||||
cg.scoresRequestTime = cg.time;
|
||||
//TA: added \n SendClientCommand doesn't call flush( )?
|
||||
trap_SendClientCommand( "score\n" );
|
||||
|
||||
return qtrue;
|
||||
}
|
||||
else
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
extern menuDef_t *menuScoreboard;
|
||||
|
||||
static void CG_scrollScoresDown_f( void )
|
||||
{
|
||||
if( menuScoreboard && cg.scoreBoardShowing )
|
||||
{
|
||||
Menu_ScrollFeeder( menuScoreboard, FEEDER_ALIENTEAM_LIST, qtrue );
|
||||
Menu_ScrollFeeder( menuScoreboard, FEEDER_HUMANTEAM_LIST, qtrue );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void CG_scrollScoresUp_f( void )
|
||||
{
|
||||
if( menuScoreboard && cg.scoreBoardShowing )
|
||||
{
|
||||
Menu_ScrollFeeder( menuScoreboard, FEEDER_ALIENTEAM_LIST, qfalse );
|
||||
Menu_ScrollFeeder( menuScoreboard, FEEDER_HUMANTEAM_LIST, qfalse );
|
||||
}
|
||||
}
|
||||
|
||||
static void CG_ScoresDown_f( void )
|
||||
{
|
||||
if( !cg.showScores )
|
||||
{
|
||||
Menu_SetFeederSelection( menuScoreboard, FEEDER_ALIENTEAM_LIST, 0, NULL );
|
||||
Menu_SetFeederSelection( menuScoreboard, FEEDER_HUMANTEAM_LIST, 0, NULL );
|
||||
}
|
||||
|
||||
if( CG_RequestScores( ) )
|
||||
{
|
||||
// leave the current scores up if they were already
|
||||
// displayed, but if this is the first hit, clear them out
|
||||
if( !cg.showScores )
|
||||
{
|
||||
if( cg_debugRandom.integer )
|
||||
CG_Printf( "CG_ScoresDown_f: scores out of date\n" );
|
||||
|
||||
cg.showScores = qtrue;
|
||||
cg.numScores = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// show the cached contents even if they just pressed if it
|
||||
// is within two seconds
|
||||
cg.showScores = qtrue;
|
||||
}
|
||||
}
|
||||
|
||||
static void CG_ScoresUp_f( void )
|
||||
{
|
||||
if( cg.showScores )
|
||||
{
|
||||
cg.showScores = qfalse;
|
||||
cg.scoreFadeTime = cg.time;
|
||||
}
|
||||
}
|
||||
|
||||
static void CG_TellTarget_f( void )
|
||||
{
|
||||
int clientNum;
|
||||
char command[ 128 ];
|
||||
char message[ 128 ];
|
||||
|
||||
clientNum = CG_CrosshairPlayer( );
|
||||
if( clientNum == -1 )
|
||||
return;
|
||||
|
||||
trap_Args( message, 128 );
|
||||
Com_sprintf( command, 128, "tell %i %s", clientNum, message );
|
||||
trap_SendClientCommand( command );
|
||||
}
|
||||
|
||||
static void CG_TellAttacker_f( void )
|
||||
{
|
||||
int clientNum;
|
||||
char command[ 128 ];
|
||||
char message[ 128 ];
|
||||
|
||||
clientNum = CG_LastAttacker( );
|
||||
if( clientNum == -1 )
|
||||
return;
|
||||
|
||||
trap_Args( message, 128 );
|
||||
Com_sprintf( command, 128, "tell %i %s", clientNum, message );
|
||||
trap_SendClientCommand( command );
|
||||
}
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char *cmd;
|
||||
void (*function)( void );
|
||||
} consoleCommand_t;
|
||||
|
||||
static consoleCommand_t commands[ ] =
|
||||
{
|
||||
{ "testgun", CG_TestGun_f },
|
||||
{ "testmodel", CG_TestModel_f },
|
||||
{ "nextframe", CG_TestModelNextFrame_f },
|
||||
{ "prevframe", CG_TestModelPrevFrame_f },
|
||||
{ "nextskin", CG_TestModelNextSkin_f },
|
||||
{ "prevskin", CG_TestModelPrevSkin_f },
|
||||
{ "viewpos", CG_Viewpos_f },
|
||||
{ "+scores", CG_ScoresDown_f },
|
||||
{ "-scores", CG_ScoresUp_f },
|
||||
{ "scoresUp", CG_scrollScoresUp_f },
|
||||
{ "scoresDown", CG_scrollScoresDown_f },
|
||||
{ "sizeup", CG_SizeUp_f },
|
||||
{ "sizedown", CG_SizeDown_f },
|
||||
{ "weapnext", CG_NextWeapon_f },
|
||||
{ "weapprev", CG_PrevWeapon_f },
|
||||
{ "weapon", CG_Weapon_f },
|
||||
{ "tell_target", CG_TellTarget_f },
|
||||
{ "tell_attacker", CG_TellAttacker_f },
|
||||
{ "tcmd", CG_TargetCommand_f },
|
||||
{ "testPS", CG_TestPS_f },
|
||||
{ "destroyTestPS", CG_DestroyTestPS_f },
|
||||
{ "testTS", CG_TestTS_f },
|
||||
{ "destroyTestTS", CG_DestroyTestTS_f },
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
=================
|
||||
CG_ConsoleCommand
|
||||
|
||||
The string has been tokenized and can be retrieved with
|
||||
Cmd_Argc() / Cmd_Argv()
|
||||
=================
|
||||
*/
|
||||
qboolean CG_ConsoleCommand( void )
|
||||
{
|
||||
const char *cmd;
|
||||
const char *arg1;
|
||||
int i;
|
||||
|
||||
cmd = CG_Argv( 0 );
|
||||
|
||||
//TA: ugly hacky special case
|
||||
if( !Q_stricmp( cmd, "ui_menu" ) )
|
||||
{
|
||||
arg1 = CG_Argv( 1 );
|
||||
trap_SendConsoleCommand( va( "menu %s\n", arg1 ) );
|
||||
return qtrue;
|
||||
}
|
||||
|
||||
for( i = 0; i < sizeof( commands ) / sizeof( commands[ 0 ] ); i++ )
|
||||
{
|
||||
if( !Q_stricmp( cmd, commands[ i ].cmd ) )
|
||||
{
|
||||
commands[ i ].function( );
|
||||
return qtrue;
|
||||
}
|
||||
}
|
||||
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
=================
|
||||
CG_InitConsoleCommands
|
||||
|
||||
Let the client system know about all of our commands
|
||||
so it can perform tab completion
|
||||
=================
|
||||
*/
|
||||
void CG_InitConsoleCommands( void )
|
||||
{
|
||||
int i;
|
||||
|
||||
for( i = 0 ; i < sizeof( commands ) / sizeof( commands[ 0 ] ) ; i++ )
|
||||
trap_AddCommand( commands[ i ].cmd );
|
||||
|
||||
//
|
||||
// the game server will interpret these commands, which will be automatically
|
||||
// forwarded to the server after they are not recognized locally
|
||||
//
|
||||
trap_AddCommand( "kill" );
|
||||
trap_AddCommand( "say" );
|
||||
trap_AddCommand( "say_team" );
|
||||
trap_AddCommand( "tell" );
|
||||
trap_AddCommand( "vsay" );
|
||||
trap_AddCommand( "vsay_team" );
|
||||
trap_AddCommand( "vtell" );
|
||||
trap_AddCommand( "vtaunt" );
|
||||
trap_AddCommand( "vosay" );
|
||||
trap_AddCommand( "vosay_team" );
|
||||
trap_AddCommand( "votell" );
|
||||
trap_AddCommand( "give" );
|
||||
trap_AddCommand( "god" );
|
||||
trap_AddCommand( "notarget" );
|
||||
trap_AddCommand( "noclip" );
|
||||
trap_AddCommand( "team" );
|
||||
trap_AddCommand( "follow" );
|
||||
trap_AddCommand( "levelshot" );
|
||||
trap_AddCommand( "addbot" );
|
||||
trap_AddCommand( "setviewpos" );
|
||||
trap_AddCommand( "callvote" );
|
||||
trap_AddCommand( "vote" );
|
||||
trap_AddCommand( "callteamvote" );
|
||||
trap_AddCommand( "teamvote" );
|
||||
trap_AddCommand( "stats" );
|
||||
trap_AddCommand( "teamtask" );
|
||||
trap_AddCommand( "class" );
|
||||
trap_AddCommand( "build" );
|
||||
trap_AddCommand( "buy" );
|
||||
trap_AddCommand( "sell" );
|
||||
trap_AddCommand( "reload" );
|
||||
trap_AddCommand( "itemact" );
|
||||
trap_AddCommand( "itemdeact" );
|
||||
trap_AddCommand( "itemtoggle" );
|
||||
trap_AddCommand( "destroy" );
|
||||
trap_AddCommand( "deconstruct" );
|
||||
trap_AddCommand( "menu" );
|
||||
trap_AddCommand( "ui_menu" );
|
||||
trap_AddCommand( "mapRotation" );
|
||||
trap_AddCommand( "stopMapRotation" );
|
||||
trap_AddCommand( "advanceMapRotation" );
|
||||
trap_AddCommand( "alienWin" );
|
||||
trap_AddCommand( "humanWin" );
|
||||
}
|
||||
-3524
File diff suppressed because it is too large.
Load diff
@@ -1,378 +0,0 @@
|
||||
/*
|
||||
===========================================================================
|
||||
Copyright (C) 1999-2005 Id Software, Inc.
|
||||
Copyright (C) 2000-2006 Tim Angus
|
||||
|
||||
This file is part of Tremulous.
|
||||
|
||||
Tremulous is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
Tremulous is distributed in the hope that it will be
|
||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Tremulous; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
===========================================================================
|
||||
*/
|
||||
|
||||
// cg_drawtools.c -- helper functions called by cg_draw, cg_scoreboard, cg_info, etc
|
||||
|
||||
|
||||
#include "cg_local.h"
|
||||
|
||||
/*
|
||||
===============
|
||||
CG_DrawPlane
|
||||
|
||||
Draw a quad in 3 space - basically CG_DrawPic in 3 space
|
||||
===============
|
||||
*/
|
||||
void CG_DrawPlane( vec3_t origin, vec3_t down, vec3_t right, qhandle_t shader )
|
||||
{
|
||||
polyVert_t verts[ 4 ];
|
||||
vec3_t temp;
|
||||
|
||||
VectorCopy( origin, verts[ 0 ].xyz );
|
||||
verts[ 0 ].st[ 0 ] = 0;
|
||||
verts[ 0 ].st[ 1 ] = 0;
|
||||
verts[ 0 ].modulate[ 0 ] = 255;
|
||||
verts[ 0 ].modulate[ 1 ] = 255;
|
||||
verts[ 0 ].modulate[ 2 ] = 255;
|
||||
verts[ 0 ].modulate[ 3 ] = 255;
|
||||
|
||||
VectorAdd( origin, right, temp );
|
||||
VectorCopy( temp, verts[ 1 ].xyz );
|
||||
verts[ 1 ].st[ 0 ] = 1;
|
||||
verts[ 1 ].st[ 1 ] = 0;
|
||||
verts[ 1 ].modulate[ 0 ] = 255;
|
||||
verts[ 1 ].modulate[ 1 ] = 255;
|
||||
verts[ 1 ].modulate[ 2 ] = 255;
|
||||
verts[ 1 ].modulate[ 3 ] = 255;
|
||||
|
||||
VectorAdd( origin, right, temp );
|
||||
VectorAdd( temp, down, temp );
|
||||
VectorCopy( temp, verts[ 2 ].xyz );
|
||||
verts[ 2 ].st[ 0 ] = 1;
|
||||
verts[ 2 ].st[ 1 ] = 1;
|
||||
verts[ 2 ].modulate[ 0 ] = 255;
|
||||
verts[ 2 ].modulate[ 1 ] = 255;
|
||||
verts[ 2 ].modulate[ 2 ] = 255;
|
||||
verts[ 2 ].modulate[ 3 ] = 255;
|
||||
|
||||
VectorAdd( origin, down, temp );
|
||||
VectorCopy( temp, verts[ 3 ].xyz );
|
||||
verts[ 3 ].st[ 0 ] = 0;
|
||||
verts[ 3 ].st[ 1 ] = 1;
|
||||
verts[ 3 ].modulate[ 0 ] = 255;
|
||||
verts[ 3 ].modulate[ 1 ] = 255;
|
||||
verts[ 3 ].modulate[ 2 ] = 255;
|
||||
verts[ 3 ].modulate[ 3 ] = 255;
|
||||
|
||||
trap_R_AddPolyToScene( shader, 4, verts );
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
CG_AdjustFrom640
|
||||
|
||||
Adjusted for resolution and screen aspect ratio
|
||||
================
|
||||
*/
|
||||
void CG_AdjustFrom640( float *x, float *y, float *w, float *h )
|
||||
{
|
||||
#if 0
|
||||
// adjust for wide screens
|
||||
if ( cgs.glconfig.vidWidth * 480 > cgs.glconfig.vidHeight * 640 ) {
|
||||
*x += 0.5 * ( cgs.glconfig.vidWidth - ( cgs.glconfig.vidHeight * 640 / 480 ) );
|
||||
}
|
||||
#endif
|
||||
// scale for screen sizes
|
||||
*x *= cgs.screenXScale;
|
||||
*y *= cgs.screenYScale;
|
||||
*w *= cgs.screenXScale;
|
||||
*h *= cgs.screenYScale;
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
CG_FillRect
|
||||
|
||||
Coordinates are 640*480 virtual values
|
||||
=================
|
||||
*/
|
||||
void CG_FillRect( float x, float y, float width, float height, const float *color )
|
||||
{
|
||||
trap_R_SetColor( color );
|
||||
|
||||
CG_AdjustFrom640( &x, &y, &width, &height );
|
||||
trap_R_DrawStretchPic( x, y, width, height, 0, 0, 0, 0, cgs.media.whiteShader );
|
||||
|
||||
trap_R_SetColor( NULL );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
================
|
||||
CG_DrawSides
|
||||
|
||||
Coords are virtual 640x480
|
||||
================
|
||||
*/
|
||||
void CG_DrawSides( float x, float y, float w, float h, float size )
|
||||
{
|
||||
CG_AdjustFrom640( &x, &y, &w, &h );
|
||||
size *= cgs.screenXScale;
|
||||
trap_R_DrawStretchPic( x, y, size, h, 0, 0, 0, 0, cgs.media.whiteShader );
|
||||
trap_R_DrawStretchPic( x + w - size, y, size, h, 0, 0, 0, 0, cgs.media.whiteShader );
|
||||
}
|
||||
|
||||
void CG_DrawTopBottom( float x, float y, float w, float h, float size )
|
||||
{
|
||||
CG_AdjustFrom640( &x, &y, &w, &h );
|
||||
size *= cgs.screenYScale;
|
||||
trap_R_DrawStretchPic( x, y, w, size, 0, 0, 0, 0, cgs.media.whiteShader );
|
||||
trap_R_DrawStretchPic( x, y + h - size, w, size, 0, 0, 0, 0, cgs.media.whiteShader );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
================
|
||||
CG_DrawRect
|
||||
|
||||
Coordinates are 640*480 virtual values
|
||||
=================
|
||||
*/
|
||||
void CG_DrawRect( float x, float y, float width, float height, float size, const float *color )
|
||||
{
|
||||
trap_R_SetColor( color );
|
||||
|
||||
CG_DrawTopBottom( x, y, width, height, size );
|
||||
CG_DrawSides( x, y, width, height, size );
|
||||
|
||||
trap_R_SetColor( NULL );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
================
|
||||
CG_DrawPic
|
||||
|
||||
Coordinates are 640*480 virtual values
|
||||
=================
|
||||
*/
|
||||
void CG_DrawPic( float x, float y, float width, float height, qhandle_t hShader )
|
||||
{
|
||||
CG_AdjustFrom640( &x, &y, &width, &height );
|
||||
trap_R_DrawStretchPic( x, y, width, height, 0, 0, 1, 1, hShader );
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
================
|
||||
CG_DrawFadePic
|
||||
|
||||
Coordinates are 640*480 virtual values
|
||||
=================
|
||||
*/
|
||||
void CG_DrawFadePic( float x, float y, float width, float height, vec4_t fcolor,
|
||||
vec4_t tcolor, float amount, qhandle_t hShader )
|
||||
{
|
||||
vec4_t finalcolor;
|
||||
float inverse;
|
||||
|
||||
inverse = 100 - amount;
|
||||
|
||||
CG_AdjustFrom640( &x, &y, &width, &height );
|
||||
|
||||
finalcolor[ 0 ] = ( ( inverse * fcolor[ 0 ] ) + ( amount * tcolor[ 0 ] ) ) / 100;
|
||||
finalcolor[ 1 ] = ( ( inverse * fcolor[ 1 ] ) + ( amount * tcolor[ 1 ] ) ) / 100;
|
||||
finalcolor[ 2 ] = ( ( inverse * fcolor[ 2 ] ) + ( amount * tcolor[ 2 ] ) ) / 100;
|
||||
finalcolor[ 3 ] = ( ( inverse * fcolor[ 3 ] ) + ( amount * tcolor[ 3 ] ) ) / 100;
|
||||
|
||||
trap_R_SetColor( finalcolor );
|
||||
trap_R_DrawStretchPic( x, y, width, height, 0, 0, 1, 1, hShader );
|
||||
trap_R_SetColor( NULL );
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
CG_DrawStrlen
|
||||
|
||||
Returns character count, skiping color escape codes
|
||||
=================
|
||||
*/
|
||||
int CG_DrawStrlen( const char *str )
|
||||
{
|
||||
const char *s = str;
|
||||
int count = 0;
|
||||
|
||||
while( *s )
|
||||
{
|
||||
if( Q_IsColorString( s ) )
|
||||
s += 2;
|
||||
else
|
||||
{
|
||||
count++;
|
||||
s++;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
/*
|
||||
=============
|
||||
CG_TileClearBox
|
||||
|
||||
This repeats a 64*64 tile graphic to fill the screen around a sized down
|
||||
refresh window.
|
||||
=============
|
||||
*/
|
||||
static void CG_TileClearBox( int x, int y, int w, int h, qhandle_t hShader )
|
||||
{
|
||||
float s1, t1, s2, t2;
|
||||
|
||||
s1 = x / 64.0;
|
||||
t1 = y / 64.0;
|
||||
s2 = ( x + w ) / 64.0;
|
||||
t2 = ( y + h ) / 64.0;
|
||||
trap_R_DrawStretchPic( x, y, w, h, s1, t1, s2, t2, hShader );
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
==============
|
||||
CG_TileClear
|
||||
|
||||
Clear around a sized down screen
|
||||
==============
|
||||
*/
|
||||
void CG_TileClear( void )
|
||||
{
|
||||
int top, bottom, left, right;
|
||||
int w, h;
|
||||
|
||||
w = cgs.glconfig.vidWidth;
|
||||
h = cgs.glconfig.vidHeight;
|
||||
|
||||
if( cg.refdef.x == 0 && cg.refdef.y == 0 &&
|
||||
cg.refdef.width == w && cg.refdef.height == h )
|
||||
return; // full screen rendering
|
||||
|
||||
top = cg.refdef.y;
|
||||
bottom = top + cg.refdef.height - 1;
|
||||
left = cg.refdef.x;
|
||||
right = left + cg.refdef.width - 1;
|
||||
|
||||
// clear above view screen
|
||||
CG_TileClearBox( 0, 0, w, top, cgs.media.backTileShader );
|
||||
|
||||
// clear below view screen
|
||||
CG_TileClearBox( 0, bottom, w, h - bottom, cgs.media.backTileShader );
|
||||
|
||||
// clear left of view screen
|
||||
CG_TileClearBox( 0, top, left, bottom - top + 1, cgs.media.backTileShader );
|
||||
|
||||
// clear right of view screen
|
||||
CG_TileClearBox( right, top, w - right, bottom - top + 1, cgs.media.backTileShader );
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
CG_FadeColor
|
||||
================
|
||||
*/
|
||||
float *CG_FadeColor( int startMsec, int totalMsec )
|
||||
{
|
||||
static vec4_t color;
|
||||
int t;
|
||||
|
||||
if( startMsec == 0 )
|
||||
return NULL;
|
||||
|
||||
t = cg.time - startMsec;
|
||||
|
||||
if( t >= totalMsec )
|
||||
return NULL;
|
||||
|
||||
// fade out
|
||||
if( totalMsec - t < FADE_TIME )
|
||||
color[ 3 ] = ( totalMsec - t ) * 1.0 / FADE_TIME;
|
||||
else
|
||||
color[ 3 ] = 1.0;
|
||||
|
||||
color[ 0 ] = color[ 1 ] = color[ 2 ] = 1;
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
CG_WorldToScreen
|
||||
================
|
||||
*/
|
||||
qboolean CG_WorldToScreen( vec3_t point, float *x, float *y )
|
||||
{
|
||||
vec3_t trans;
|
||||
float xc, yc;
|
||||
float px, py;
|
||||
float z;
|
||||
|
||||
px = tan( cg.refdef.fov_x * M_PI / 360.0 );
|
||||
py = tan( cg.refdef.fov_y * M_PI / 360.0 );
|
||||
|
||||
VectorSubtract( point, cg.refdef.vieworg, trans );
|
||||
|
||||
xc = 640.0f / 2.0f;
|
||||
yc = 480.0f / 2.0f;
|
||||
|
||||
z = DotProduct( trans, cg.refdef.viewaxis[ 0 ] );
|
||||
if( z <= 0.001f )
|
||||
return qfalse;
|
||||
|
||||
if( x )
|
||||
*x = xc - DotProduct( trans, cg.refdef.viewaxis[ 1 ] ) * xc / ( z * px );
|
||||
|
||||
if( y )
|
||||
*y = yc - DotProduct( trans, cg.refdef.viewaxis[ 2 ] ) * yc / ( z * py );
|
||||
|
||||
return qtrue;
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
CG_KeyBinding
|
||||
================
|
||||
*/
|
||||
char *CG_KeyBinding( const char *bind )
|
||||
{
|
||||
static char key[ 32 ];
|
||||
char bindbuff[ MAX_CVAR_VALUE_STRING ];
|
||||
int i;
|
||||
|
||||
key[ 0 ] = '\0';
|
||||
// NOTE: change K_LAST_KEY to MAX_KEYS for full key support (eventually)
|
||||
for( i = 0; i < K_LAST_KEY; i++ )
|
||||
{
|
||||
trap_Key_GetBindingBuf( i, bindbuff, sizeof( bindbuff ) );
|
||||
if( !Q_stricmp( bindbuff, bind ) )
|
||||
{
|
||||
trap_Key_KeynumToStringBuf( i, key, sizeof( key ) );
|
||||
break;
|
||||
}
|
||||
}
|
||||
if( !key[ 0 ] )
|
||||
{
|
||||
Q_strncpyz( key, "\\", sizeof( key ) );
|
||||
Q_strcat( key, sizeof( key ), bind );
|
||||
}
|
||||
return key;
|
||||
}
|
||||
-1256
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
-1840
File diff suppressed because it is too large.
Load diff
@@ -1,289 +0,0 @@
|
||||
/*
|
||||
===========================================================================
|
||||
Copyright (C) 1999-2005 Id Software, Inc.
|
||||
Copyright (C) 2000-2006 Tim Angus
|
||||
|
||||
This file is part of Tremulous.
|
||||
|
||||
Tremulous is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
Tremulous is distributed in the hope that it will be
|
||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Tremulous; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
===========================================================================
|
||||
*/
|
||||
|
||||
// cg_marks.c -- wall marks
|
||||
|
||||
|
||||
#include "cg_local.h"
|
||||
|
||||
/*
|
||||
===================================================================
|
||||
|
||||
MARK POLYS
|
||||
|
||||
===================================================================
|
||||
*/
|
||||
|
||||
|
||||
markPoly_t cg_activeMarkPolys; // double linked list
|
||||
markPoly_t *cg_freeMarkPolys; // single linked list
|
||||
markPoly_t cg_markPolys[ MAX_MARK_POLYS ];
|
||||
static int markTotal;
|
||||
|
||||
/*
|
||||
===================
|
||||
CG_InitMarkPolys
|
||||
|
||||
This is called at startup and for tournement restarts
|
||||
===================
|
||||
*/
|
||||
void CG_InitMarkPolys( void )
|
||||
{
|
||||
int i;
|
||||
|
||||
memset( cg_markPolys, 0, sizeof( cg_markPolys ) );
|
||||
|
||||
cg_activeMarkPolys.nextMark = &cg_activeMarkPolys;
|
||||
cg_activeMarkPolys.prevMark = &cg_activeMarkPolys;
|
||||
cg_freeMarkPolys = cg_markPolys;
|
||||
|
||||
for( i = 0; i < MAX_MARK_POLYS - 1; i++ )
|
||||
cg_markPolys[ i ].nextMark = &cg_markPolys[ i + 1 ];
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
==================
|
||||
CG_FreeMarkPoly
|
||||
==================
|
||||
*/
|
||||
void CG_FreeMarkPoly( markPoly_t *le )
|
||||
{
|
||||
if( !le->prevMark )
|
||||
CG_Error( "CG_FreeLocalEntity: not active" );
|
||||
|
||||
// remove from the doubly linked active list
|
||||
le->prevMark->nextMark = le->nextMark;
|
||||
le->nextMark->prevMark = le->prevMark;
|
||||
|
||||
// the free list is only singly linked
|
||||
le->nextMark = cg_freeMarkPolys;
|
||||
cg_freeMarkPolys = le;
|
||||
}
|
||||
|
||||
/*
|
||||
===================
|
||||
CG_AllocMark
|
||||
|
||||
Will allways succeed, even if it requires freeing an old active mark
|
||||
===================
|
||||
*/
|
||||
markPoly_t *CG_AllocMark( void )
|
||||
{
|
||||
markPoly_t *le;
|
||||
int time;
|
||||
|
||||
if( !cg_freeMarkPolys )
|
||||
{
|
||||
// no free entities, so free the one at the end of the chain
|
||||
// remove the oldest active entity
|
||||
time = cg_activeMarkPolys.prevMark->time;
|
||||
|
||||
while( cg_activeMarkPolys.prevMark && time == cg_activeMarkPolys.prevMark->time )
|
||||
CG_FreeMarkPoly( cg_activeMarkPolys.prevMark );
|
||||
}
|
||||
|
||||
le = cg_freeMarkPolys;
|
||||
cg_freeMarkPolys = cg_freeMarkPolys->nextMark;
|
||||
|
||||
memset( le, 0, sizeof( *le ) );
|
||||
|
||||
// link into the active list
|
||||
le->nextMark = cg_activeMarkPolys.nextMark;
|
||||
le->prevMark = &cg_activeMarkPolys;
|
||||
cg_activeMarkPolys.nextMark->prevMark = le;
|
||||
cg_activeMarkPolys.nextMark = le;
|
||||
return le;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
=================
|
||||
CG_ImpactMark
|
||||
|
||||
origin should be a point within a unit of the plane
|
||||
dir should be the plane normal
|
||||
|
||||
temporary marks will not be stored or randomly oriented, but immediately
|
||||
passed to the renderer.
|
||||
=================
|
||||
*/
|
||||
#define MAX_MARK_FRAGMENTS 128
|
||||
#define MAX_MARK_POINTS 384
|
||||
|
||||
void CG_ImpactMark( qhandle_t markShader, const vec3_t origin, const vec3_t dir,
|
||||
float orientation, float red, float green, float blue, float alpha,
|
||||
qboolean alphaFade, float radius, qboolean temporary )
|
||||
{
|
||||
vec3_t axis[ 3 ];
|
||||
float texCoordScale;
|
||||
vec3_t originalPoints[ 4 ];
|
||||
byte colors[ 4 ];
|
||||
int i, j;
|
||||
int numFragments;
|
||||
markFragment_t markFragments[ MAX_MARK_FRAGMENTS ], *mf;
|
||||
vec3_t markPoints[ MAX_MARK_POINTS ];
|
||||
vec3_t projection;
|
||||
|
||||
if( !cg_addMarks.integer )
|
||||
return;
|
||||
|
||||
if( radius <= 0 )
|
||||
CG_Error( "CG_ImpactMark called with <= 0 radius" );
|
||||
|
||||
//if ( markTotal >= MAX_MARK_POLYS ) {
|
||||
// return;
|
||||
//}
|
||||
|
||||
// create the texture axis
|
||||
VectorNormalize2( dir, axis[ 0 ] );
|
||||
PerpendicularVector( axis[ 1 ], axis[ 0 ] );
|
||||
RotatePointAroundVector( axis[ 2 ], axis[ 0 ], axis[ 1 ], orientation );
|
||||
CrossProduct( axis[ 0 ], axis[ 2 ], axis[ 1 ] );
|
||||
|
||||
texCoordScale = 0.5 * 1.0 / radius;
|
||||
|
||||
// create the full polygon
|
||||
for( i = 0; i < 3; i++ )
|
||||
{
|
||||
originalPoints[ 0 ][ i ] = origin[ i ] - radius * axis[ 1 ][ i ] - radius * axis[ 2 ][ i ];
|
||||
originalPoints[ 1 ][ i ] = origin[ i ] + radius * axis[ 1 ][ i ] - radius * axis[ 2 ][ i ];
|
||||
originalPoints[ 2 ][ i ] = origin[ i ] + radius * axis[ 1 ][ i ] + radius * axis[ 2 ][ i ];
|
||||
originalPoints[ 3 ][ i ] = origin[ i ] - radius * axis[ 1 ][ i ] + radius * axis[ 2 ][ i ];
|
||||
}
|
||||
|
||||
// get the fragments
|
||||
VectorScale( dir, -20, projection );
|
||||
numFragments = trap_CM_MarkFragments( 4, (void *)originalPoints,
|
||||
projection, MAX_MARK_POINTS, markPoints[ 0 ],
|
||||
MAX_MARK_FRAGMENTS, markFragments );
|
||||
|
||||
colors[ 0 ] = red * 255;
|
||||
colors[ 1 ] = green * 255;
|
||||
colors[ 2 ] = blue * 255;
|
||||
colors[ 3 ] = alpha * 255;
|
||||
|
||||
for( i = 0, mf = markFragments; i < numFragments; i++, mf++ )
|
||||
{
|
||||
polyVert_t *v;
|
||||
polyVert_t verts[ MAX_VERTS_ON_POLY ];
|
||||
markPoly_t *mark;
|
||||
|
||||
// we have an upper limit on the complexity of polygons
|
||||
// that we store persistantly
|
||||
if( mf->numPoints > MAX_VERTS_ON_POLY )
|
||||
mf->numPoints = MAX_VERTS_ON_POLY;
|
||||
|
||||
for( j = 0, v = verts; j < mf->numPoints; j++, v++ )
|
||||
{
|
||||
vec3_t delta;
|
||||
|
||||
VectorCopy( markPoints[ mf->firstPoint + j ], v->xyz );
|
||||
|
||||
VectorSubtract( v->xyz, origin, delta );
|
||||
v->st[ 0 ] = 0.5 + DotProduct( delta, axis[ 1 ] ) * texCoordScale;
|
||||
v->st[ 1 ] = 0.5 + DotProduct( delta, axis[ 2 ] ) * texCoordScale;
|
||||
*(int *)v->modulate = *(int *)colors;
|
||||
}
|
||||
|
||||
// if it is a temporary (shadow) mark, add it immediately and forget about it
|
||||
if( temporary )
|
||||
{
|
||||
trap_R_AddPolyToScene( markShader, mf->numPoints, verts );
|
||||
continue;
|
||||
}
|
||||
|
||||
// otherwise save it persistantly
|
||||
mark = CG_AllocMark( );
|
||||
mark->time = cg.time;
|
||||
mark->alphaFade = alphaFade;
|
||||
mark->markShader = markShader;
|
||||
mark->poly.numVerts = mf->numPoints;
|
||||
mark->color[ 0 ] = red;
|
||||
mark->color[ 1 ] = green;
|
||||
mark->color[ 2 ] = blue;
|
||||
mark->color[ 3 ] = alpha;
|
||||
memcpy( mark->verts, verts, mf->numPoints * sizeof( verts[ 0 ] ) );
|
||||
markTotal++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
===============
|
||||
CG_AddMarks
|
||||
===============
|
||||
*/
|
||||
#define MARK_TOTAL_TIME 10000
|
||||
#define MARK_FADE_TIME 1000
|
||||
|
||||
void CG_AddMarks( void )
|
||||
{
|
||||
int j;
|
||||
markPoly_t *mp, *next;
|
||||
int t;
|
||||
int fade;
|
||||
|
||||
if( !cg_addMarks.integer )
|
||||
return;
|
||||
|
||||
mp = cg_activeMarkPolys.nextMark;
|
||||
for ( ; mp != &cg_activeMarkPolys; mp = next )
|
||||
{
|
||||
// grab next now, so if the local entity is freed we
|
||||
// still have it
|
||||
next = mp->nextMark;
|
||||
|
||||
// see if it is time to completely remove it
|
||||
if( cg.time > mp->time + MARK_TOTAL_TIME )
|
||||
{
|
||||
CG_FreeMarkPoly( mp );
|
||||
continue;
|
||||
}
|
||||
|
||||
// fade all marks out with time
|
||||
t = mp->time + MARK_TOTAL_TIME - cg.time;
|
||||
if( t < MARK_FADE_TIME )
|
||||
{
|
||||
fade = 255 * t / MARK_FADE_TIME;
|
||||
if( mp->alphaFade )
|
||||
{
|
||||
for( j = 0; j < mp->poly.numVerts; j++ )
|
||||
mp->verts[ j ].modulate[ 3 ] = fade;
|
||||
}
|
||||
else
|
||||
{
|
||||
for( j = 0; j < mp->poly.numVerts; j++ )
|
||||
{
|
||||
mp->verts[ j ].modulate[ 0 ] = mp->color[ 0 ] * fade;
|
||||
mp->verts[ j ].modulate[ 1 ] = mp->color[ 1 ] * fade;
|
||||
mp->verts[ j ].modulate[ 2 ] = mp->color[ 2 ] * fade;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
trap_R_AddPolyToScene( mp->markShader, mp->poly.numVerts, mp->verts );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,202 +0,0 @@
|
||||
/*
|
||||
===========================================================================
|
||||
Copyright (C) 1999-2005 Id Software, Inc.
|
||||
Copyright (C) 2000-2006 Tim Angus
|
||||
|
||||
This file is part of Tremulous.
|
||||
|
||||
Tremulous is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
Tremulous is distributed in the hope that it will be
|
||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Tremulous; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
===========================================================================
|
||||
*/
|
||||
|
||||
#include "cg_local.h"
|
||||
|
||||
#define POOLSIZE (256 * 1024)
|
||||
#define FREEMEMCOOKIE ((int)0xDEADBE3F) // Any unlikely to be used value
|
||||
#define ROUNDBITS 31 // Round to 32 bytes
|
||||
|
||||
struct freememnode
|
||||
{
|
||||
// Size of ROUNDBITS
|
||||
int cookie, size; // Size includes node (obviously)
|
||||
struct freememnode *prev, *next;
|
||||
};
|
||||
|
||||
static char memoryPool[ POOLSIZE ];
|
||||
static struct freememnode *freehead;
|
||||
static int freemem;
|
||||
|
||||
void *CG_Alloc( int size )
|
||||
{
|
||||
// Find a free block and allocate.
|
||||
// Does two passes, attempts to fill same-sized free slot first.
|
||||
|
||||
struct freememnode *fmn, *prev, *next, *smallest;
|
||||
int allocsize, smallestsize;
|
||||
char *endptr;
|
||||
int *ptr;
|
||||
|
||||
allocsize = ( size + sizeof(int) + ROUNDBITS ) & ~ROUNDBITS; // Round to 32-byte boundary
|
||||
ptr = NULL;
|
||||
|
||||
smallest = NULL;
|
||||
smallestsize = POOLSIZE + 1; // Guaranteed not to miss any slots :)
|
||||
for( fmn = freehead; fmn; fmn = fmn->next )
|
||||
{
|
||||
if( fmn->cookie != FREEMEMCOOKIE )
|
||||
CG_Error( "CG_Alloc: Memory corruption detected!\n" );
|
||||
|
||||
if( fmn->size >= allocsize )
|
||||
{
|
||||
// We've got a block
|
||||
if( fmn->size == allocsize )
|
||||
{
|
||||
// Same size, just remove
|
||||
|
||||
prev = fmn->prev;
|
||||
next = fmn->next;
|
||||
if( prev )
|
||||
prev->next = next; // Point previous node to next
|
||||
if( next )
|
||||
next->prev = prev; // Point next node to previous
|
||||
if( fmn == freehead )
|
||||
freehead = next; // Set head pointer to next
|
||||
ptr = (int *) fmn;
|
||||
break; // Stop the loop, this is fine
|
||||
}
|
||||
else
|
||||
{
|
||||
// Keep track of the smallest free slot
|
||||
if( fmn->size < smallestsize )
|
||||
{
|
||||
smallest = fmn;
|
||||
smallestsize = fmn->size;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( !ptr && smallest )
|
||||
{
|
||||
// We found a slot big enough
|
||||
smallest->size -= allocsize;
|
||||
endptr = (char *) smallest + smallest->size;
|
||||
ptr = (int *) endptr;
|
||||
}
|
||||
|
||||
if( ptr )
|
||||
{
|
||||
freemem -= allocsize;
|
||||
if( cg_debugAlloc.integer )
|
||||
CG_Printf( "CG_Alloc of %i bytes (%i left)\n", allocsize, freemem );
|
||||
memset( ptr, 0, allocsize );
|
||||
*ptr++ = allocsize; // Store a copy of size for deallocation
|
||||
return( (void *) ptr );
|
||||
}
|
||||
|
||||
CG_Error( "CG_Alloc: failed on allocation of %i bytes\n", size );
|
||||
return( NULL );
|
||||
}
|
||||
|
||||
void CG_Free( void *ptr )
|
||||
{
|
||||
// Release allocated memory, add it to the free list.
|
||||
|
||||
struct freememnode *fmn;
|
||||
char *freeend;
|
||||
int *freeptr;
|
||||
|
||||
freeptr = ptr;
|
||||
freeptr--;
|
||||
|
||||
freemem += *freeptr;
|
||||
if( cg_debugAlloc.integer )
|
||||
CG_Printf( "CG_Free of %i bytes (%i left)\n", *freeptr, freemem );
|
||||
|
||||
for( fmn = freehead; fmn; fmn = fmn->next )
|
||||
{
|
||||
freeend = ((char *) fmn) + fmn->size;
|
||||
if( freeend == (char *) freeptr )
|
||||
{
|
||||
// Released block can be merged to an existing node
|
||||
|
||||
fmn->size += *freeptr; // Add size of node.
|
||||
return;
|
||||
}
|
||||
}
|
||||
// No merging, add to head of list
|
||||
|
||||
fmn = (struct freememnode *) freeptr;
|
||||
fmn->size = *freeptr; // Set this first to avoid corrupting *freeptr
|
||||
fmn->cookie = FREEMEMCOOKIE;
|
||||
fmn->prev = NULL;
|
||||
fmn->next = freehead;
|
||||
freehead->prev = fmn;
|
||||
freehead = fmn;
|
||||
}
|
||||
|
||||
void CG_InitMemory( void )
|
||||
{
|
||||
// Set up the initial node
|
||||
|
||||
freehead = (struct freememnode *) memoryPool;
|
||||
freehead->cookie = FREEMEMCOOKIE;
|
||||
freehead->size = POOLSIZE;
|
||||
freehead->next = NULL;
|
||||
freehead->prev = NULL;
|
||||
freemem = sizeof(memoryPool);
|
||||
}
|
||||
|
||||
void CG_DefragmentMemory( void )
|
||||
{
|
||||
// If there's a frenzy of deallocation and we want to
|
||||
// allocate something big, this is useful. Otherwise...
|
||||
// not much use.
|
||||
|
||||
struct freememnode *startfmn, *endfmn, *fmn;
|
||||
|
||||
for( startfmn = freehead; startfmn; )
|
||||
{
|
||||
endfmn = (struct freememnode *)(((char *) startfmn) + startfmn->size);
|
||||
for( fmn = freehead; fmn; )
|
||||
{
|
||||
if( fmn->cookie != FREEMEMCOOKIE )
|
||||
CG_Error( "CG_DefragmentMemory: Memory corruption detected!\n" );
|
||||
|
||||
if( fmn == endfmn )
|
||||
{
|
||||
// We can add fmn onto startfmn.
|
||||
|
||||
if( fmn->prev )
|
||||
fmn->prev->next = fmn->next;
|
||||
if( fmn->next )
|
||||
{
|
||||
if( !(fmn->next->prev = fmn->prev) )
|
||||
freehead = fmn->next; // We're removing the head node
|
||||
}
|
||||
startfmn->size += fmn->size;
|
||||
memset( fmn, 0, sizeof(struct freememnode) ); // A redundant call, really.
|
||||
|
||||
startfmn = freehead;
|
||||
endfmn = fmn = NULL; // Break out of current loop
|
||||
}
|
||||
else
|
||||
fmn = fmn->next;
|
||||
}
|
||||
|
||||
if( endfmn )
|
||||
startfmn = startfmn->next; // endfmn acts as a 'restart' flag here
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -1,317 +0,0 @@
|
||||
/*
|
||||
===========================================================================
|
||||
Copyright (C) 1999-2005 Id Software, Inc.
|
||||
Copyright (C) 2000-2006 Tim Angus
|
||||
|
||||
This file is part of Tremulous.
|
||||
|
||||
Tremulous is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
Tremulous is distributed in the hope that it will be
|
||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Tremulous; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
===========================================================================
|
||||
*/
|
||||
|
||||
// cg_playerstate.c -- this file acts on changes in a new playerState_t
|
||||
// With normal play, this will be done after local prediction, but when
|
||||
// following another player or playing back a demo, it will be checked
|
||||
// when the snapshot transitions like all the other entities
|
||||
|
||||
|
||||
#include "cg_local.h"
|
||||
|
||||
/*
|
||||
==============
|
||||
CG_DamageFeedback
|
||||
==============
|
||||
*/
|
||||
void CG_DamageFeedback( int yawByte, int pitchByte, int damage )
|
||||
{
|
||||
float left, front, up;
|
||||
float kick;
|
||||
int health;
|
||||
float scale;
|
||||
vec3_t dir;
|
||||
vec3_t angles;
|
||||
float dist;
|
||||
float yaw, pitch;
|
||||
|
||||
// show the attacking player's head and name in corner
|
||||
cg.attackerTime = cg.time;
|
||||
|
||||
// the lower on health you are, the greater the view kick will be
|
||||
health = cg.snap->ps.stats[STAT_HEALTH];
|
||||
|
||||
if( health < 40 )
|
||||
scale = 1;
|
||||
else
|
||||
scale = 40.0 / health;
|
||||
|
||||
kick = damage * scale;
|
||||
|
||||
if( kick < 5 )
|
||||
kick = 5;
|
||||
|
||||
if( kick > 10 )
|
||||
kick = 10;
|
||||
|
||||
// if yaw and pitch are both 255, make the damage always centered (falling, etc)
|
||||
if( yawByte == 255 && pitchByte == 255 )
|
||||
{
|
||||
cg.damageX = 0;
|
||||
cg.damageY = 0;
|
||||
cg.v_dmg_roll = 0;
|
||||
cg.v_dmg_pitch = -kick;
|
||||
}
|
||||
else
|
||||
{
|
||||
// positional
|
||||
pitch = pitchByte / 255.0 * 360;
|
||||
yaw = yawByte / 255.0 * 360;
|
||||
|
||||
angles[ PITCH ] = pitch;
|
||||
angles[ YAW ] = yaw;
|
||||
angles[ ROLL ] = 0;
|
||||
|
||||
AngleVectors( angles, dir, NULL, NULL );
|
||||
VectorSubtract( vec3_origin, dir, dir );
|
||||
|
||||
front = DotProduct( dir, cg.refdef.viewaxis[ 0 ] );
|
||||
left = DotProduct( dir, cg.refdef.viewaxis[ 1 ] );
|
||||
up = DotProduct( dir, cg.refdef.viewaxis[ 2 ] );
|
||||
|
||||
dir[ 0 ] = front;
|
||||
dir[ 1 ] = left;
|
||||
dir[ 2 ] = 0;
|
||||
dist = VectorLength( dir );
|
||||
|
||||
if( dist < 0.1f )
|
||||
dist = 0.1f;
|
||||
|
||||
cg.v_dmg_roll = kick * left;
|
||||
|
||||
cg.v_dmg_pitch = -kick * front;
|
||||
|
||||
if( front <= 0.1 )
|
||||
front = 0.1f;
|
||||
|
||||
cg.damageX = -left / front;
|
||||
cg.damageY = up / dist;
|
||||
}
|
||||
|
||||
// clamp the position
|
||||
if( cg.damageX > 1.0 )
|
||||
cg.damageX = 1.0;
|
||||
|
||||
if( cg.damageX < - 1.0 )
|
||||
cg.damageX = -1.0;
|
||||
|
||||
if( cg.damageY > 1.0 )
|
||||
cg.damageY = 1.0;
|
||||
|
||||
if( cg.damageY < - 1.0 )
|
||||
cg.damageY = -1.0;
|
||||
|
||||
// don't let the screen flashes vary as much
|
||||
if( kick > 10 )
|
||||
kick = 10;
|
||||
|
||||
cg.damageValue = kick;
|
||||
cg.v_dmg_time = cg.time + DAMAGE_TIME;
|
||||
cg.damageTime = cg.snap->serverTime;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
================
|
||||
CG_Respawn
|
||||
|
||||
A respawn happened this snapshot
|
||||
================
|
||||
*/
|
||||
void CG_Respawn( void )
|
||||
{
|
||||
// no error decay on player movement
|
||||
cg.thisFrameTeleport = qtrue;
|
||||
|
||||
// display weapons available
|
||||
cg.weaponSelectTime = cg.time;
|
||||
|
||||
// select the weapon the server says we are using
|
||||
cg.weaponSelect = cg.snap->ps.weapon;
|
||||
|
||||
CG_ResetPainBlend( );
|
||||
}
|
||||
|
||||
/*
|
||||
==============
|
||||
CG_CheckPlayerstateEvents
|
||||
|
||||
==============
|
||||
*/
|
||||
void CG_CheckPlayerstateEvents( playerState_t *ps, playerState_t *ops )
|
||||
{
|
||||
int i;
|
||||
int event;
|
||||
centity_t *cent;
|
||||
|
||||
if( ps->externalEvent && ps->externalEvent != ops->externalEvent )
|
||||
{
|
||||
cent = &cg_entities[ ps->clientNum ];
|
||||
cent->currentState.event = ps->externalEvent;
|
||||
cent->currentState.eventParm = ps->externalEventParm;
|
||||
CG_EntityEvent( cent, cent->lerpOrigin );
|
||||
}
|
||||
|
||||
cent = &cg.predictedPlayerEntity; // cg_entities[ ps->clientNum ];
|
||||
|
||||
// go through the predictable events buffer
|
||||
for( i = ps->eventSequence - MAX_PS_EVENTS; i < ps->eventSequence; i++ )
|
||||
{
|
||||
// if we have a new predictable event
|
||||
if( i >= ops->eventSequence ||
|
||||
// or the server told us to play another event instead of a predicted event we already issued
|
||||
// or something the server told us changed our prediction causing a different event
|
||||
( i > ops->eventSequence - MAX_PS_EVENTS && ps->events[ i & ( MAX_PS_EVENTS - 1 ) ] !=
|
||||
ops->events[ i & ( MAX_PS_EVENTS - 1 ) ] ) )
|
||||
{
|
||||
event = ps->events[ i & ( MAX_PS_EVENTS - 1 ) ];
|
||||
|
||||
cent->currentState.event = event;
|
||||
cent->currentState.eventParm = ps->eventParms[ i & ( MAX_PS_EVENTS - 1 ) ];
|
||||
CG_EntityEvent( cent, cent->lerpOrigin );
|
||||
cg.predictableEvents[ i & ( MAX_PREDICTED_EVENTS - 1 ) ] = event;
|
||||
|
||||
cg.eventSequence++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
==================
|
||||
CG_CheckChangedPredictableEvents
|
||||
==================
|
||||
*/
|
||||
void CG_CheckChangedPredictableEvents( playerState_t *ps )
|
||||
{
|
||||
int i;
|
||||
int event;
|
||||
centity_t *cent;
|
||||
|
||||
cent = &cg.predictedPlayerEntity;
|
||||
|
||||
for( i = ps->eventSequence - MAX_PS_EVENTS; i < ps->eventSequence; i++ )
|
||||
{
|
||||
//
|
||||
if( i >= cg.eventSequence )
|
||||
continue;
|
||||
|
||||
// if this event is not further back in than the maximum predictable events we remember
|
||||
if( i > cg.eventSequence - MAX_PREDICTED_EVENTS )
|
||||
{
|
||||
// if the new playerstate event is different from a previously predicted one
|
||||
if( ps->events[ i & ( MAX_PS_EVENTS - 1 ) ] != cg.predictableEvents[ i & ( MAX_PREDICTED_EVENTS - 1 ) ] )
|
||||
{
|
||||
event = ps->events[ i & ( MAX_PS_EVENTS - 1 ) ];
|
||||
cent->currentState.event = event;
|
||||
cent->currentState.eventParm = ps->eventParms[ i & ( MAX_PS_EVENTS - 1 ) ];
|
||||
CG_EntityEvent( cent, cent->lerpOrigin );
|
||||
|
||||
cg.predictableEvents[ i & ( MAX_PREDICTED_EVENTS - 1 ) ] = event;
|
||||
|
||||
if( cg_showmiss.integer )
|
||||
CG_Printf( "WARNING: changed predicted event\n" );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
==================
|
||||
CG_CheckLocalSounds
|
||||
==================
|
||||
*/
|
||||
void CG_CheckLocalSounds( playerState_t *ps, playerState_t *ops )
|
||||
{
|
||||
int reward;
|
||||
|
||||
// don't play the sounds if the player just changed teams
|
||||
if( ps->persistant[ PERS_TEAM ] != ops->persistant[ PERS_TEAM ] )
|
||||
return;
|
||||
|
||||
// health changes of more than -1 should make pain sounds
|
||||
if( ps->stats[ STAT_HEALTH ] < ops->stats[ STAT_HEALTH ] - 1 )
|
||||
{
|
||||
if( ps->stats[ STAT_HEALTH ] > 0 )
|
||||
CG_PainEvent( &cg.predictedPlayerEntity, ps->stats[ STAT_HEALTH ] );
|
||||
}
|
||||
|
||||
|
||||
// if we are going into the intermission, don't start any voices
|
||||
if( cg.intermissionStarted )
|
||||
return;
|
||||
|
||||
// reward sounds
|
||||
reward = qfalse;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
===============
|
||||
CG_TransitionPlayerState
|
||||
|
||||
===============
|
||||
*/
|
||||
void CG_TransitionPlayerState( playerState_t *ps, playerState_t *ops )
|
||||
{
|
||||
// check for changing follow mode
|
||||
if( ps->clientNum != ops->clientNum )
|
||||
{
|
||||
cg.thisFrameTeleport = qtrue;
|
||||
// make sure we don't get any unwanted transition effects
|
||||
*ops = *ps;
|
||||
|
||||
CG_ResetPainBlend( );
|
||||
}
|
||||
|
||||
// damage events (player is getting wounded)
|
||||
if( ps->damageEvent != ops->damageEvent && ps->damageCount )
|
||||
CG_DamageFeedback( ps->damageYaw, ps->damagePitch, ps->damageCount );
|
||||
|
||||
// respawning
|
||||
if( ps->persistant[ PERS_SPAWN_COUNT ] != ops->persistant[ PERS_SPAWN_COUNT ] )
|
||||
CG_Respawn( );
|
||||
|
||||
if( cg.mapRestart )
|
||||
{
|
||||
CG_Respawn( );
|
||||
cg.mapRestart = qfalse;
|
||||
}
|
||||
|
||||
if( cg.snap->ps.pm_type != PM_INTERMISSION &&
|
||||
ps->persistant[ PERS_TEAM ] != TEAM_SPECTATOR )
|
||||
CG_CheckLocalSounds( ps, ops );
|
||||
|
||||
// run events
|
||||
CG_CheckPlayerstateEvents( ps, ops );
|
||||
|
||||
// smooth the ducking viewheight change
|
||||
if( ps->viewheight != ops->viewheight )
|
||||
{
|
||||
cg.duckChange = ps->viewheight - ops->viewheight;
|
||||
cg.duckTime = cg.time;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,878 +0,0 @@
|
||||
/*
|
||||
===========================================================================
|
||||
Copyright (C) 1999-2005 Id Software, Inc.
|
||||
Copyright (C) 2000-2006 Tim Angus
|
||||
|
||||
This file is part of Tremulous.
|
||||
|
||||
Tremulous is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
Tremulous is distributed in the hope that it will be
|
||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Tremulous; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
===========================================================================
|
||||
*/
|
||||
|
||||
// cg_predict.c -- this file generates cg.predictedPlayerState by either
|
||||
// interpolating between snapshots from the server or locally predicting
|
||||
// ahead the client's movement.
|
||||
// It also handles local physics interaction, like fragments bouncing off walls
|
||||
|
||||
|
||||
#include "cg_local.h"
|
||||
|
||||
static pmove_t cg_pmove;
|
||||
|
||||
static int cg_numSolidEntities;
|
||||
static centity_t *cg_solidEntities[MAX_ENTITIES_IN_SNAPSHOT];
|
||||
static int cg_numTriggerEntities;
|
||||
static centity_t *cg_triggerEntities[MAX_ENTITIES_IN_SNAPSHOT];
|
||||
|
||||
/*
|
||||
====================
|
||||
CG_BuildSolidList
|
||||
|
||||
When a new cg.snap has been set, this function builds a sublist
|
||||
of the entities that are actually solid, to make for more
|
||||
efficient collision detection
|
||||
====================
|
||||
*/
|
||||
void CG_BuildSolidList( void )
|
||||
{
|
||||
int i;
|
||||
centity_t *cent;
|
||||
snapshot_t *snap;
|
||||
entityState_t *ent;
|
||||
|
||||
cg_numSolidEntities = 0;
|
||||
cg_numTriggerEntities = 0;
|
||||
|
||||
if( cg.nextSnap && !cg.nextFrameTeleport && !cg.thisFrameTeleport )
|
||||
snap = cg.nextSnap;
|
||||
else
|
||||
snap = cg.snap;
|
||||
|
||||
for( i = 0; i < snap->numEntities; i++ )
|
||||
{
|
||||
cent = &cg_entities[ snap->entities[ i ].number ];
|
||||
ent = ¢->currentState;
|
||||
|
||||
if( ent->eType == ET_ITEM || ent->eType == ET_PUSH_TRIGGER || ent->eType == ET_TELEPORT_TRIGGER )
|
||||
{
|
||||
cg_triggerEntities[ cg_numTriggerEntities ] = cent;
|
||||
cg_numTriggerEntities++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if( cent->nextState.solid && ent->eType != ET_MISSILE )
|
||||
{
|
||||
cg_solidEntities[ cg_numSolidEntities ] = cent;
|
||||
cg_numSolidEntities++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
====================
|
||||
CG_ClipMoveToEntities
|
||||
|
||||
====================
|
||||
*/
|
||||
static void CG_ClipMoveToEntities ( const vec3_t start, const vec3_t mins,
|
||||
const vec3_t maxs, const vec3_t end, int skipNumber,
|
||||
int mask, trace_t *tr, traceType_t collisionType )
|
||||
{
|
||||
int i, j, x, zd, zu;
|
||||
trace_t trace;
|
||||
entityState_t *ent;
|
||||
clipHandle_t cmodel;
|
||||
vec3_t bmins, bmaxs;
|
||||
vec3_t origin, angles;
|
||||
centity_t *cent;
|
||||
|
||||
//SUPAR HACK
|
||||
//this causes a trace to collide with the local player
|
||||
if( skipNumber == MAGIC_TRACE_HACK )
|
||||
j = cg_numSolidEntities + 1;
|
||||
else
|
||||
j = cg_numSolidEntities;
|
||||
|
||||
for( i = 0; i < j; i++ )
|
||||
{
|
||||
if( i < cg_numSolidEntities )
|
||||
cent = cg_solidEntities[ i ];
|
||||
else
|
||||
cent = &cg.predictedPlayerEntity;
|
||||
|
||||
ent = ¢->currentState;
|
||||
|
||||
if( ent->number == skipNumber )
|
||||
continue;
|
||||
|
||||
if( ent->solid == SOLID_BMODEL )
|
||||
{
|
||||
// special value for bmodel
|
||||
cmodel = trap_CM_InlineModel( ent->modelindex );
|
||||
VectorCopy( cent->lerpAngles, angles );
|
||||
BG_EvaluateTrajectory( ¢->currentState.pos, cg.physicsTime, origin );
|
||||
}
|
||||
else
|
||||
{
|
||||
// encoded bbox
|
||||
x = ( ent->solid & 255 );
|
||||
zd = ( ( ent->solid >> 8 ) & 255 );
|
||||
zu = ( ( ent->solid >> 16 ) & 255 ) - 32;
|
||||
|
||||
bmins[ 0 ] = bmins[ 1 ] = -x;
|
||||
bmaxs[ 0 ] = bmaxs[ 1 ] = x;
|
||||
bmins[ 2 ] = -zd;
|
||||
bmaxs[ 2 ] = zu;
|
||||
|
||||
if( i == cg_numSolidEntities )
|
||||
BG_FindBBoxForClass( ( ent->powerups >> 8 ) & 0xFF, bmins, bmaxs, NULL, NULL, NULL );
|
||||
|
||||
cmodel = trap_CM_TempBoxModel( bmins, bmaxs );
|
||||
VectorCopy( vec3_origin, angles );
|
||||
VectorCopy( cent->lerpOrigin, origin );
|
||||
}
|
||||
|
||||
|
||||
if( collisionType == TT_CAPSULE )
|
||||
{
|
||||
trap_CM_TransformedCapsuleTrace ( &trace, start, end,
|
||||
mins, maxs, cmodel, mask, origin, angles );
|
||||
}
|
||||
else if( collisionType == TT_AABB )
|
||||
{
|
||||
trap_CM_TransformedBoxTrace ( &trace, start, end,
|
||||
mins, maxs, cmodel, mask, origin, angles );
|
||||
}
|
||||
else if( collisionType == TT_BISPHERE )
|
||||
{
|
||||
trap_CM_TransformedBiSphereTrace( &trace, start, end,
|
||||
mins[ 0 ], maxs[ 0 ], cmodel, mask, origin );
|
||||
}
|
||||
|
||||
if( trace.allsolid || trace.fraction < tr->fraction )
|
||||
{
|
||||
trace.entityNum = ent->number;
|
||||
|
||||
if( tr->lateralFraction < trace.lateralFraction )
|
||||
{
|
||||
float oldLateralFraction = tr->lateralFraction;
|
||||
*tr = trace;
|
||||
tr->lateralFraction = oldLateralFraction;
|
||||
}
|
||||
else
|
||||
*tr = trace;
|
||||
}
|
||||
else if( trace.startsolid )
|
||||
tr->startsolid = qtrue;
|
||||
|
||||
if( tr->allsolid )
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
CG_Trace
|
||||
================
|
||||
*/
|
||||
void CG_Trace( trace_t *result, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end,
|
||||
int skipNumber, int mask )
|
||||
{
|
||||
trace_t t;
|
||||
|
||||
trap_CM_BoxTrace( &t, start, end, mins, maxs, 0, mask );
|
||||
t.entityNum = t.fraction != 1.0 ? ENTITYNUM_WORLD : ENTITYNUM_NONE;
|
||||
// check all other solid models
|
||||
CG_ClipMoveToEntities( start, mins, maxs, end, skipNumber, mask, &t, TT_AABB );
|
||||
|
||||
*result = t;
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
CG_CapTrace
|
||||
================
|
||||
*/
|
||||
void CG_CapTrace( trace_t *result, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end,
|
||||
int skipNumber, int mask )
|
||||
{
|
||||
trace_t t;
|
||||
|
||||
trap_CM_CapsuleTrace( &t, start, end, mins, maxs, 0, mask );
|
||||
t.entityNum = t.fraction != 1.0 ? ENTITYNUM_WORLD : ENTITYNUM_NONE;
|
||||
// check all other solid models
|
||||
CG_ClipMoveToEntities( start, mins, maxs, end, skipNumber, mask, &t, TT_CAPSULE );
|
||||
|
||||
*result = t;
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
CG_BiSphereTrace
|
||||
================
|
||||
*/
|
||||
void CG_BiSphereTrace( trace_t *result, const vec3_t start, const vec3_t end,
|
||||
const float startRadius, const float endRadius, int skipNumber, int mask )
|
||||
{
|
||||
trace_t t;
|
||||
vec3_t mins, maxs;
|
||||
|
||||
mins[ 0 ] = startRadius;
|
||||
maxs[ 0 ] = endRadius;
|
||||
|
||||
trap_CM_BiSphereTrace( &t, start, end, startRadius, endRadius, 0, mask );
|
||||
t.entityNum = t.fraction != 1.0 ? ENTITYNUM_WORLD : ENTITYNUM_NONE;
|
||||
// check all other solid models
|
||||
CG_ClipMoveToEntities( start, mins, maxs, end, skipNumber, mask, &t, TT_BISPHERE );
|
||||
|
||||
*result = t;
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
CG_PointContents
|
||||
================
|
||||
*/
|
||||
int CG_PointContents( const vec3_t point, int passEntityNum )
|
||||
{
|
||||
int i;
|
||||
entityState_t *ent;
|
||||
centity_t *cent;
|
||||
clipHandle_t cmodel;
|
||||
int contents;
|
||||
|
||||
contents = trap_CM_PointContents (point, 0);
|
||||
|
||||
for( i = 0; i < cg_numSolidEntities; i++ )
|
||||
{
|
||||
cent = cg_solidEntities[ i ];
|
||||
|
||||
ent = ¢->currentState;
|
||||
|
||||
if( ent->number == passEntityNum )
|
||||
continue;
|
||||
|
||||
if( ent->solid != SOLID_BMODEL ) // special value for bmodel
|
||||
continue;
|
||||
|
||||
cmodel = trap_CM_InlineModel( ent->modelindex );
|
||||
|
||||
if( !cmodel )
|
||||
continue;
|
||||
|
||||
contents |= trap_CM_TransformedPointContents( point, cmodel, ent->origin, ent->angles );
|
||||
}
|
||||
|
||||
return contents;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
========================
|
||||
CG_InterpolatePlayerState
|
||||
|
||||
Generates cg.predictedPlayerState by interpolating between
|
||||
cg.snap->player_state and cg.nextFrame->player_state
|
||||
========================
|
||||
*/
|
||||
static void CG_InterpolatePlayerState( qboolean grabAngles )
|
||||
{
|
||||
float f;
|
||||
int i;
|
||||
playerState_t *out;
|
||||
snapshot_t *prev, *next;
|
||||
|
||||
out = &cg.predictedPlayerState;
|
||||
prev = cg.snap;
|
||||
next = cg.nextSnap;
|
||||
|
||||
*out = cg.snap->ps;
|
||||
|
||||
// if we are still allowing local input, short circuit the view angles
|
||||
if( grabAngles )
|
||||
{
|
||||
usercmd_t cmd;
|
||||
int cmdNum;
|
||||
|
||||
cmdNum = trap_GetCurrentCmdNumber( );
|
||||
trap_GetUserCmd( cmdNum, &cmd );
|
||||
|
||||
PM_UpdateViewAngles( out, &cmd );
|
||||
}
|
||||
|
||||
// if the next frame is a teleport, we can't lerp to it
|
||||
if( cg.nextFrameTeleport )
|
||||
return;
|
||||
|
||||
if( !next || next->serverTime <= prev->serverTime )
|
||||
return;
|
||||
|
||||
f = (float)( cg.time - prev->serverTime ) / ( next->serverTime - prev->serverTime );
|
||||
|
||||
i = next->ps.bobCycle;
|
||||
if( i < prev->ps.bobCycle )
|
||||
i += 256; // handle wraparound
|
||||
|
||||
out->bobCycle = prev->ps.bobCycle + f * ( i - prev->ps.bobCycle );
|
||||
|
||||
for( i = 0; i < 3; i++ )
|
||||
{
|
||||
out->origin[ i ] = prev->ps.origin[ i ] + f * ( next->ps.origin[ i ] - prev->ps.origin[ i ] );
|
||||
|
||||
if( !grabAngles )
|
||||
out->viewangles[ i ] = LerpAngle( prev->ps.viewangles[ i ], next->ps.viewangles[ i ], f );
|
||||
|
||||
out->velocity[ i ] = prev->ps.velocity[ i ] +
|
||||
f * (next->ps.velocity[ i ] - prev->ps.velocity[ i ] );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
=========================
|
||||
CG_TouchTriggerPrediction
|
||||
|
||||
Predict push triggers and items
|
||||
=========================
|
||||
*/
|
||||
static void CG_TouchTriggerPrediction( void )
|
||||
{
|
||||
int i;
|
||||
trace_t trace;
|
||||
entityState_t *ent;
|
||||
clipHandle_t cmodel;
|
||||
centity_t *cent;
|
||||
qboolean spectator;
|
||||
|
||||
// dead clients don't activate triggers
|
||||
if( cg.predictedPlayerState.stats[ STAT_HEALTH ] <= 0 )
|
||||
return;
|
||||
|
||||
spectator = ( cg.predictedPlayerState.pm_type == PM_SPECTATOR );
|
||||
|
||||
if( cg.predictedPlayerState.pm_type != PM_NORMAL && !spectator )
|
||||
return;
|
||||
|
||||
for( i = 0; i < cg_numTriggerEntities; i++ )
|
||||
{
|
||||
cent = cg_triggerEntities[ i ];
|
||||
ent = ¢->currentState;
|
||||
|
||||
if( ent->solid != SOLID_BMODEL )
|
||||
continue;
|
||||
|
||||
cmodel = trap_CM_InlineModel( ent->modelindex );
|
||||
if( !cmodel )
|
||||
continue;
|
||||
|
||||
trap_CM_BoxTrace( &trace, cg.predictedPlayerState.origin, cg.predictedPlayerState.origin,
|
||||
cg_pmove.mins, cg_pmove.maxs, cmodel, -1 );
|
||||
|
||||
if( !trace.startsolid )
|
||||
continue;
|
||||
|
||||
if( ent->eType == ET_TELEPORT_TRIGGER )
|
||||
cg.hyperspace = qtrue;
|
||||
}
|
||||
}
|
||||
|
||||
static int CG_IsUnacceptableError( playerState_t *ps, playerState_t *pps )
|
||||
{
|
||||
vec3_t delta;
|
||||
int i;
|
||||
|
||||
if( pps->pm_type != ps->pm_type ||
|
||||
pps->pm_flags != ps->pm_flags ||
|
||||
pps->pm_time != ps->pm_time )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
VectorSubtract( pps->origin, ps->origin, delta );
|
||||
if( VectorLengthSquared( delta ) > 0.1f * 0.1f )
|
||||
{
|
||||
if( cg_showmiss.integer )
|
||||
{
|
||||
CG_Printf( "origin delta: %.2f ", VectorLength( delta ) );
|
||||
}
|
||||
return 2;
|
||||
}
|
||||
|
||||
VectorSubtract( pps->velocity, ps->velocity, delta );
|
||||
if( VectorLengthSquared( delta ) > 0.1f * 0.1f )
|
||||
{
|
||||
if( cg_showmiss.integer )
|
||||
{
|
||||
CG_Printf( "velocity delta: %.2f ", VectorLength( delta ) );
|
||||
}
|
||||
return 3;
|
||||
}
|
||||
|
||||
if( pps->weaponTime != ps->weaponTime ||
|
||||
pps->gravity != ps->gravity ||
|
||||
pps->speed != ps->speed ||
|
||||
pps->delta_angles[ 0 ] != ps->delta_angles[ 0 ] ||
|
||||
pps->delta_angles[ 1 ] != ps->delta_angles[ 1 ] ||
|
||||
pps->delta_angles[ 2 ] != ps->delta_angles[ 2 ] ||
|
||||
pps->groundEntityNum != ps->groundEntityNum )
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
if( pps->legsTimer != ps->legsTimer ||
|
||||
pps->legsAnim != ps->legsAnim ||
|
||||
pps->torsoTimer != ps->torsoTimer ||
|
||||
pps->torsoAnim != ps->torsoAnim ||
|
||||
pps->movementDir != ps->movementDir )
|
||||
{
|
||||
return 5;
|
||||
}
|
||||
|
||||
VectorSubtract( pps->grapplePoint, ps->grapplePoint, delta );
|
||||
if( VectorLengthSquared( delta ) > 0.1f * 0.1f )
|
||||
return 6;
|
||||
|
||||
if( pps->eFlags != ps->eFlags )
|
||||
return 7;
|
||||
|
||||
if( pps->eventSequence != ps->eventSequence )
|
||||
return 8;
|
||||
|
||||
for( i = 0; i < MAX_PS_EVENTS; i++ )
|
||||
{
|
||||
if ( pps->events[ i ] != ps->events[ i ] ||
|
||||
pps->eventParms[ i ] != ps->eventParms[ i ] )
|
||||
{
|
||||
return 9;
|
||||
}
|
||||
}
|
||||
|
||||
if( pps->externalEvent != ps->externalEvent ||
|
||||
pps->externalEventParm != ps->externalEventParm ||
|
||||
pps->externalEventTime != ps->externalEventTime )
|
||||
{
|
||||
return 10;
|
||||
}
|
||||
|
||||
if( pps->clientNum != ps->clientNum ||
|
||||
pps->weapon != ps->weapon ||
|
||||
pps->weaponstate != ps->weaponstate )
|
||||
{
|
||||
return 11;
|
||||
}
|
||||
|
||||
if( fabs( AngleDelta( ps->viewangles[ 0 ], pps->viewangles[ 0 ] ) ) > 1.0f ||
|
||||
fabs( AngleDelta( ps->viewangles[ 1 ], pps->viewangles[ 1 ] ) ) > 1.0f ||
|
||||
fabs( AngleDelta( ps->viewangles[ 2 ], pps->viewangles[ 2 ] ) ) > 1.0f )
|
||||
{
|
||||
return 12;
|
||||
}
|
||||
|
||||
if( pps->viewheight != ps->viewheight )
|
||||
return 13;
|
||||
|
||||
if( pps->damageEvent != ps->damageEvent ||
|
||||
pps->damageYaw != ps->damageYaw ||
|
||||
pps->damagePitch != ps->damagePitch ||
|
||||
pps->damageCount != ps->damageCount )
|
||||
{
|
||||
return 14;
|
||||
}
|
||||
|
||||
for( i = 0; i < MAX_STATS; i++ )
|
||||
{
|
||||
if( pps->stats[ i ] != ps->stats[ i ] )
|
||||
return 15;
|
||||
}
|
||||
|
||||
for( i = 0; i < MAX_PERSISTANT; i++ )
|
||||
{
|
||||
if( pps->persistant[ i ] != ps->persistant[ i ] )
|
||||
return 16;
|
||||
}
|
||||
|
||||
for( i = 0; i < MAX_WEAPONS; i++ )
|
||||
{
|
||||
if( pps->ammo[ i ] != ps->ammo[ i ] )
|
||||
return 18;
|
||||
}
|
||||
|
||||
if( pps->generic1 != ps->generic1 ||
|
||||
pps->loopSound != ps->loopSound )
|
||||
{
|
||||
return 19;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
=================
|
||||
CG_PredictPlayerState
|
||||
|
||||
Generates cg.predictedPlayerState for the current cg.time
|
||||
cg.predictedPlayerState is guaranteed to be valid after exiting.
|
||||
|
||||
For demo playback, this will be an interpolation between two valid
|
||||
playerState_t.
|
||||
|
||||
For normal gameplay, it will be the result of predicted usercmd_t on
|
||||
top of the most recent playerState_t received from the server.
|
||||
|
||||
Each new snapshot will usually have one or more new usercmd over the last,
|
||||
but we simulate all unacknowledged commands each time, not just the new ones.
|
||||
This means that on an internet connection, quite a few pmoves may be issued
|
||||
each frame.
|
||||
|
||||
OPTIMIZE: don't re-simulate unless the newly arrived snapshot playerState_t
|
||||
differs from the predicted one. Would require saving all intermediate
|
||||
playerState_t during prediction.
|
||||
|
||||
We detect prediction errors and allow them to be decayed off over several frames
|
||||
to ease the jerk.
|
||||
=================
|
||||
*/
|
||||
void CG_PredictPlayerState( void )
|
||||
{
|
||||
int cmdNum, current, i;
|
||||
playerState_t oldPlayerState;
|
||||
qboolean moved;
|
||||
usercmd_t oldestCmd;
|
||||
usercmd_t latestCmd;
|
||||
int stateIndex = 0, predictCmd = 0;
|
||||
|
||||
cg.hyperspace = qfalse; // will be set if touching a trigger_teleport
|
||||
|
||||
// if this is the first frame we must guarantee
|
||||
// predictedPlayerState is valid even if there is some
|
||||
// other error condition
|
||||
if( !cg.validPPS )
|
||||
{
|
||||
cg.validPPS = qtrue;
|
||||
cg.predictedPlayerState = cg.snap->ps;
|
||||
}
|
||||
|
||||
|
||||
// demo playback just copies the moves
|
||||
if( cg.demoPlayback || (cg.snap->ps.pm_flags & PMF_FOLLOW) )
|
||||
{
|
||||
CG_InterpolatePlayerState( qfalse );
|
||||
return;
|
||||
}
|
||||
|
||||
// non-predicting local movement will grab the latest angles
|
||||
if( cg_nopredict.integer || cg_synchronousClients.integer )
|
||||
{
|
||||
CG_InterpolatePlayerState( qtrue );
|
||||
return;
|
||||
}
|
||||
|
||||
// prepare for pmove
|
||||
cg_pmove.ps = &cg.predictedPlayerState;
|
||||
cg_pmove.pmext = &cg.pmext;
|
||||
cg_pmove.trace = CG_Trace;
|
||||
cg_pmove.pointcontents = CG_PointContents;
|
||||
cg_pmove.debugLevel = cg_debugMove.integer;
|
||||
|
||||
if( cg_pmove.ps->pm_type == PM_DEAD )
|
||||
cg_pmove.tracemask = MASK_PLAYERSOLID & ~CONTENTS_BODY;
|
||||
else
|
||||
cg_pmove.tracemask = MASK_PLAYERSOLID;
|
||||
|
||||
if( cg.snap->ps.persistant[ PERS_TEAM ] == TEAM_SPECTATOR )
|
||||
cg_pmove.tracemask &= ~CONTENTS_BODY; // spectators can fly through bodies
|
||||
|
||||
cg_pmove.noFootsteps = 0;
|
||||
|
||||
// save the state before the pmove so we can detect transitions
|
||||
oldPlayerState = cg.predictedPlayerState;
|
||||
|
||||
current = trap_GetCurrentCmdNumber( );
|
||||
|
||||
// if we don't have the commands right after the snapshot, we
|
||||
// can't accurately predict a current position, so just freeze at
|
||||
// the last good position we had
|
||||
cmdNum = current - CMD_BACKUP + 1;
|
||||
trap_GetUserCmd( cmdNum, &oldestCmd );
|
||||
|
||||
if( oldestCmd.serverTime > cg.snap->ps.commandTime &&
|
||||
oldestCmd.serverTime < cg.time )
|
||||
{ // special check for map_restart
|
||||
if( cg_showmiss.integer )
|
||||
CG_Printf( "exceeded PACKET_BACKUP on commands\n" );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// get the latest command so we can know which commands are from previous map_restarts
|
||||
trap_GetUserCmd( current, &latestCmd );
|
||||
|
||||
// get the most recent information we have, even if
|
||||
// the server time is beyond our current cg.time,
|
||||
// because predicted player positions are going to
|
||||
// be ahead of everything else anyway
|
||||
if( cg.nextSnap && !cg.nextFrameTeleport && !cg.thisFrameTeleport )
|
||||
{
|
||||
cg.predictedPlayerState = cg.nextSnap->ps;
|
||||
cg.physicsTime = cg.nextSnap->serverTime;
|
||||
}
|
||||
else
|
||||
{
|
||||
cg.predictedPlayerState = cg.snap->ps;
|
||||
cg.physicsTime = cg.snap->serverTime;
|
||||
}
|
||||
|
||||
if( pmove_msec.integer < 8 )
|
||||
trap_Cvar_Set( "pmove_msec", "8" );
|
||||
else if( pmove_msec.integer > 33 )
|
||||
trap_Cvar_Set( "pmove_msec", "33" );
|
||||
|
||||
cg_pmove.pmove_fixed = pmove_fixed.integer;// | cg_pmove_fixed.integer;
|
||||
cg_pmove.pmove_msec = pmove_msec.integer;
|
||||
|
||||
// Like the comments described above, a player's state is entirely
|
||||
// re-predicted from the last valid snapshot every client frame, which
|
||||
// can be really, really, really slow. Every old command has to be
|
||||
// run again. For every client frame that is *not* directly after a
|
||||
// snapshot, this is unnecessary, since we have no new information.
|
||||
// For those, we'll play back the predictions from the last frame and
|
||||
// predict only the newest commands. Essentially, we'll be doing
|
||||
// an incremental predict instead of a full predict.
|
||||
//
|
||||
// If we have a new snapshot, we can compare its player state's command
|
||||
// time to the command times in the queue to find a match. If we find
|
||||
// a matching state, and the predicted version has not deviated, we can
|
||||
// use the predicted state as a base - and also do an incremental predict.
|
||||
//
|
||||
// With this method, we get incremental predicts on every client frame
|
||||
// except a frame following a new snapshot in which there was a prediction
|
||||
// error. This yeilds anywhere from a 15% to 40% performance increase,
|
||||
// depending on how much of a bottleneck the CPU is.
|
||||
if( cg_optimizePrediction.integer )
|
||||
{
|
||||
if( cg.nextFrameTeleport || cg.thisFrameTeleport )
|
||||
{
|
||||
// do a full predict
|
||||
cg.lastPredictedCommand = 0;
|
||||
cg.stateTail = cg.stateHead;
|
||||
predictCmd = current - CMD_BACKUP + 1;
|
||||
}
|
||||
// cg.physicsTime is the current snapshot's serverTime if it's the same
|
||||
// as the last one
|
||||
else if( cg.physicsTime == cg.lastServerTime )
|
||||
{
|
||||
// we have no new information, so do an incremental predict
|
||||
predictCmd = cg.lastPredictedCommand + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
// we have a new snapshot
|
||||
int i;
|
||||
int errorcode;
|
||||
qboolean error = qtrue;
|
||||
|
||||
// loop through the saved states queue
|
||||
for( i = cg.stateHead; i != cg.stateTail;
|
||||
i = ( i + 1 ) % NUM_SAVED_STATES )
|
||||
{
|
||||
// if we find a predicted state whose commandTime matches the snapshot
|
||||
// player state's commandTime
|
||||
if( cg.savedPmoveStates[ i ].commandTime !=
|
||||
cg.predictedPlayerState.commandTime )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
// make sure the state differences are acceptable
|
||||
errorcode = CG_IsUnacceptableError( &cg.predictedPlayerState,
|
||||
&cg.savedPmoveStates[ i ] );
|
||||
|
||||
if( errorcode )
|
||||
{
|
||||
if( cg_showmiss.integer )
|
||||
CG_Printf("errorcode %d at %d\n", errorcode, cg.time);
|
||||
break;
|
||||
}
|
||||
|
||||
// this one is almost exact, so we'll copy it in as the starting point
|
||||
*cg_pmove.ps = cg.savedPmoveStates[ i ];
|
||||
// advance the head
|
||||
cg.stateHead = ( i + 1 ) % NUM_SAVED_STATES;
|
||||
|
||||
// set the next command to predict
|
||||
predictCmd = cg.lastPredictedCommand + 1;
|
||||
|
||||
// a saved state matched, so flag it
|
||||
error = qfalse;
|
||||
break;
|
||||
}
|
||||
|
||||
// if no saved states matched
|
||||
if( error )
|
||||
{
|
||||
// do a full predict
|
||||
cg.lastPredictedCommand = 0;
|
||||
cg.stateTail = cg.stateHead;
|
||||
predictCmd = current - CMD_BACKUP + 1;
|
||||
}
|
||||
}
|
||||
|
||||
// keep track of the server time of the last snapshot so we
|
||||
// know when we're starting from a new one in future calls
|
||||
cg.lastServerTime = cg.physicsTime;
|
||||
stateIndex = cg.stateHead;
|
||||
}
|
||||
|
||||
// run cmds
|
||||
moved = qfalse;
|
||||
|
||||
for( cmdNum = current - CMD_BACKUP + 1; cmdNum <= current; cmdNum++ )
|
||||
{
|
||||
// get the command
|
||||
trap_GetUserCmd( cmdNum, &cg_pmove.cmd );
|
||||
|
||||
if( cg_pmove.pmove_fixed )
|
||||
PM_UpdateViewAngles( cg_pmove.ps, &cg_pmove.cmd );
|
||||
|
||||
// don't do anything if the time is before the snapshot player time
|
||||
if( cg_pmove.cmd.serverTime <= cg.predictedPlayerState.commandTime )
|
||||
continue;
|
||||
|
||||
// don't do anything if the command was from a previous map_restart
|
||||
if( cg_pmove.cmd.serverTime > latestCmd.serverTime )
|
||||
continue;
|
||||
|
||||
// check for a prediction error from last frame
|
||||
// on a lan, this will often be the exact value
|
||||
// from the snapshot, but on a wan we will have
|
||||
// to predict several commands to get to the point
|
||||
// we want to compare
|
||||
if( cg.predictedPlayerState.commandTime == oldPlayerState.commandTime )
|
||||
{
|
||||
vec3_t delta;
|
||||
float len;
|
||||
|
||||
if( cg.thisFrameTeleport )
|
||||
{
|
||||
// a teleport will not cause an error decay
|
||||
VectorClear( cg.predictedError );
|
||||
|
||||
if( cg_showmiss.integer )
|
||||
CG_Printf( "PredictionTeleport\n" );
|
||||
|
||||
cg.thisFrameTeleport = qfalse;
|
||||
}
|
||||
else
|
||||
{
|
||||
vec3_t adjusted;
|
||||
CG_AdjustPositionForMover( cg.predictedPlayerState.origin,
|
||||
cg.predictedPlayerState.groundEntityNum, cg.physicsTime, cg.oldTime, adjusted );
|
||||
|
||||
if( cg_showmiss.integer )
|
||||
{
|
||||
if( !VectorCompare( oldPlayerState.origin, adjusted ) )
|
||||
CG_Printf("prediction error\n");
|
||||
}
|
||||
|
||||
VectorSubtract( oldPlayerState.origin, adjusted, delta );
|
||||
len = VectorLength( delta );
|
||||
|
||||
if( len > 0.1 )
|
||||
{
|
||||
if( cg_showmiss.integer )
|
||||
CG_Printf( "Prediction miss: %f\n", len );
|
||||
|
||||
if( cg_errorDecay.integer )
|
||||
{
|
||||
int t;
|
||||
float f;
|
||||
|
||||
t = cg.time - cg.predictedErrorTime;
|
||||
f = ( cg_errorDecay.value - t ) / cg_errorDecay.value;
|
||||
|
||||
if( f < 0 )
|
||||
f = 0;
|
||||
|
||||
if( f > 0 && cg_showmiss.integer )
|
||||
CG_Printf( "Double prediction decay: %f\n", f );
|
||||
|
||||
VectorScale( cg.predictedError, f, cg.predictedError );
|
||||
}
|
||||
else
|
||||
VectorClear( cg.predictedError );
|
||||
|
||||
VectorAdd( delta, cg.predictedError, cg.predictedError );
|
||||
cg.predictedErrorTime = cg.oldTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// don't predict gauntlet firing, which is only supposed to happen
|
||||
// when it actually inflicts damage
|
||||
for( i = WP_NONE + 1; i < WP_NUM_WEAPONS; i++ )
|
||||
cg_pmove.autoWeaponHit[ i ] = qfalse;
|
||||
|
||||
if( cg_pmove.pmove_fixed )
|
||||
cg_pmove.cmd.serverTime = ( ( cg_pmove.cmd.serverTime + pmove_msec.integer - 1 ) /
|
||||
pmove_msec.integer ) * pmove_msec.integer;
|
||||
|
||||
if( !cg_optimizePrediction.integer )
|
||||
{
|
||||
Pmove( &cg_pmove );
|
||||
}
|
||||
else if( cg_optimizePrediction.integer && ( cmdNum >= predictCmd ||
|
||||
( stateIndex + 1 ) % NUM_SAVED_STATES == cg.stateHead ) )
|
||||
{
|
||||
Pmove( &cg_pmove );
|
||||
// record the last predicted command
|
||||
cg.lastPredictedCommand = cmdNum;
|
||||
|
||||
// if we haven't run out of space in the saved states queue
|
||||
if( ( stateIndex + 1 ) % NUM_SAVED_STATES != cg.stateHead )
|
||||
{
|
||||
// save the state for the false case ( of cmdNum >= predictCmd )
|
||||
// in later calls to this function
|
||||
cg.savedPmoveStates[ stateIndex ] = *cg_pmove.ps;
|
||||
stateIndex = ( stateIndex + 1 ) % NUM_SAVED_STATES;
|
||||
cg.stateTail = stateIndex;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
*cg_pmove.ps = cg.savedPmoveStates[ stateIndex ];
|
||||
stateIndex = ( stateIndex + 1 ) % NUM_SAVED_STATES;
|
||||
}
|
||||
|
||||
moved = qtrue;
|
||||
|
||||
// add push trigger movement effects
|
||||
CG_TouchTriggerPrediction( );
|
||||
|
||||
// check for predictable events that changed from previous predictions
|
||||
//CG_CheckChangedPredictableEvents(&cg.predictedPlayerState);
|
||||
}
|
||||
|
||||
// adjust for the movement of the groundentity
|
||||
CG_AdjustPositionForMover( cg.predictedPlayerState.origin,
|
||||
cg.predictedPlayerState.groundEntityNum,
|
||||
cg.physicsTime, cg.time, cg.predictedPlayerState.origin );
|
||||
|
||||
|
||||
// fire events and other transition triggered things
|
||||
CG_TransitionPlayerState( &cg.predictedPlayerState, &oldPlayerState );
|
||||
|
||||
|
||||
}
|
||||
@@ -1,81 +0,0 @@
|
||||
/*
|
||||
===========================================================================
|
||||
Copyright (C) 2000-2006 Tim Angus
|
||||
|
||||
This file is part of Tremulous.
|
||||
|
||||
Tremulous is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
Tremulous is distributed in the hope that it will be
|
||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Tremulous; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
===========================================================================
|
||||
*/
|
||||
|
||||
// cg_ptr.c -- post timeout restoration handling
|
||||
|
||||
|
||||
#include "cg_local.h"
|
||||
|
||||
#define PTRC_FILE "ptrc.cfg"
|
||||
|
||||
/*
|
||||
===============
|
||||
CG_ReadPTRCode
|
||||
|
||||
Read a PTR code from disk
|
||||
===============
|
||||
*/
|
||||
int CG_ReadPTRCode( void )
|
||||
{
|
||||
int len;
|
||||
char text[ 16 ];
|
||||
fileHandle_t f;
|
||||
|
||||
// load the file
|
||||
len = trap_FS_FOpenFile( PTRC_FILE, &f, FS_READ );
|
||||
if( len <= 0 )
|
||||
return 0;
|
||||
|
||||
// should never happen - malformed write
|
||||
if( len >= sizeof( text ) - 1 )
|
||||
return 0;
|
||||
|
||||
trap_FS_Read( text, len, f );
|
||||
text[ len ] = 0;
|
||||
trap_FS_FCloseFile( f );
|
||||
|
||||
return atoi( text );
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
CG_WritePTRCode
|
||||
|
||||
Write a PTR code to disk
|
||||
===============
|
||||
*/
|
||||
void CG_WritePTRCode( int code )
|
||||
{
|
||||
char text[ 16 ];
|
||||
fileHandle_t f;
|
||||
|
||||
Com_sprintf( text, 16, "%d", code );
|
||||
|
||||
// open file
|
||||
if( trap_FS_FOpenFile( PTRC_FILE, &f, FS_WRITE ) < 0 )
|
||||
return;
|
||||
|
||||
// write the code
|
||||
trap_FS_Write( text, strlen( text ), f );
|
||||
|
||||
trap_FS_FCloseFile( f );
|
||||
}
|
||||
@@ -1,365 +0,0 @@
|
||||
/*
|
||||
===========================================================================
|
||||
Copyright (C) 2000-2006 Tim Angus
|
||||
|
||||
This file is part of Tremulous.
|
||||
|
||||
Tremulous is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
Tremulous is distributed in the hope that it will be
|
||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Tremulous; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
===========================================================================
|
||||
*/
|
||||
|
||||
|
||||
#include "cg_local.h"
|
||||
|
||||
static entityPos_t entityPositions;
|
||||
|
||||
#define HUMAN_SCANNER_UPDATE_PERIOD 700
|
||||
|
||||
/*
|
||||
=============
|
||||
CG_UpdateEntityPositions
|
||||
|
||||
Update this client's perception of entity positions
|
||||
=============
|
||||
*/
|
||||
void CG_UpdateEntityPositions( void )
|
||||
{
|
||||
centity_t *cent = NULL;
|
||||
int i;
|
||||
|
||||
if( cg.predictedPlayerState.stats[ STAT_PTEAM ] == PTE_HUMANS )
|
||||
{
|
||||
if( entityPositions.lastUpdateTime + HUMAN_SCANNER_UPDATE_PERIOD > cg.time )
|
||||
return;
|
||||
}
|
||||
|
||||
VectorCopy( cg.refdef.vieworg, entityPositions.origin );
|
||||
VectorCopy( cg.refdefViewAngles, entityPositions.vangles );
|
||||
entityPositions.lastUpdateTime = cg.time;
|
||||
|
||||
entityPositions.numAlienBuildables = 0;
|
||||
entityPositions.numHumanBuildables = 0;
|
||||
entityPositions.numAlienClients = 0;
|
||||
entityPositions.numHumanClients = 0;
|
||||
|
||||
for( i = 0; i < cg.snap->numEntities; i++ )
|
||||
{
|
||||
cent = &cg_entities[ cg.snap->entities[ i ].number ];
|
||||
|
||||
if( cent->currentState.eType == ET_BUILDABLE )
|
||||
{
|
||||
//TA: add to list of item positions (for creep)
|
||||
if( cent->currentState.modelindex2 == BIT_ALIENS )
|
||||
{
|
||||
VectorCopy( cent->lerpOrigin, entityPositions.alienBuildablePos[
|
||||
entityPositions.numAlienBuildables ] );
|
||||
entityPositions.alienBuildableTimes[
|
||||
entityPositions.numAlienBuildables ] = cent->miscTime;
|
||||
|
||||
if( entityPositions.numAlienBuildables < MAX_GENTITIES )
|
||||
entityPositions.numAlienBuildables++;
|
||||
}
|
||||
else if( cent->currentState.modelindex2 == BIT_HUMANS )
|
||||
{
|
||||
VectorCopy( cent->lerpOrigin, entityPositions.humanBuildablePos[
|
||||
entityPositions.numHumanBuildables ] );
|
||||
|
||||
if( entityPositions.numHumanBuildables < MAX_GENTITIES )
|
||||
entityPositions.numHumanBuildables++;
|
||||
}
|
||||
}
|
||||
else if( cent->currentState.eType == ET_PLAYER )
|
||||
{
|
||||
int team = cent->currentState.powerups & 0x00FF;
|
||||
|
||||
if( team == PTE_ALIENS )
|
||||
{
|
||||
VectorCopy( cent->lerpOrigin, entityPositions.alienClientPos[
|
||||
entityPositions.numAlienClients ] );
|
||||
|
||||
if( entityPositions.numAlienClients < MAX_CLIENTS )
|
||||
entityPositions.numAlienClients++;
|
||||
}
|
||||
else if( team == PTE_HUMANS )
|
||||
{
|
||||
VectorCopy( cent->lerpOrigin, entityPositions.humanClientPos[
|
||||
entityPositions.numHumanClients ] );
|
||||
|
||||
if( entityPositions.numHumanClients < MAX_CLIENTS )
|
||||
entityPositions.numHumanClients++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#define STALKWIDTH 2.0f
|
||||
#define BLIPX 16.0f
|
||||
#define BLIPY 8.0f
|
||||
#define FAR_ALPHA 0.8f
|
||||
#define NEAR_ALPHA 1.2f
|
||||
|
||||
/*
|
||||
=============
|
||||
CG_DrawBlips
|
||||
|
||||
Draw blips and stalks for the human scanner
|
||||
=============
|
||||
*/
|
||||
static void CG_DrawBlips( rectDef_t *rect, vec3_t origin, vec4_t colour )
|
||||
{
|
||||
vec3_t drawOrigin;
|
||||
vec3_t up = { 0, 0, 1 };
|
||||
float alphaMod = 1.0f;
|
||||
float timeFractionSinceRefresh = 1.0f -
|
||||
( (float)( cg.time - entityPositions.lastUpdateTime ) /
|
||||
(float)HUMAN_SCANNER_UPDATE_PERIOD );
|
||||
vec4_t localColour;
|
||||
|
||||
Vector4Copy( colour, localColour );
|
||||
|
||||
RotatePointAroundVector( drawOrigin, up, origin, -entityPositions.vangles[ 1 ] - 90 );
|
||||
drawOrigin[ 0 ] /= ( 2 * HELMET_RANGE / rect->w );
|
||||
drawOrigin[ 1 ] /= ( 2 * HELMET_RANGE / rect->h );
|
||||
drawOrigin[ 2 ] /= ( 2 * HELMET_RANGE / rect->w );
|
||||
|
||||
alphaMod = FAR_ALPHA +
|
||||
( ( drawOrigin[ 1 ] + ( rect->h / 2.0f ) ) / rect->h ) * ( NEAR_ALPHA - FAR_ALPHA );
|
||||
|
||||
localColour[ 3 ] *= alphaMod;
|
||||
localColour[ 3 ] *= ( 0.5f + ( timeFractionSinceRefresh * 0.5f ) );
|
||||
|
||||
if( localColour[ 3 ] > 1.0f )
|
||||
localColour[ 3 ] = 1.0f;
|
||||
else if( localColour[ 3 ] < 0.0f )
|
||||
localColour[ 3 ] = 0.0f;
|
||||
|
||||
trap_R_SetColor( localColour );
|
||||
|
||||
if( drawOrigin[ 2 ] > 0 )
|
||||
CG_DrawPic( rect->x + ( rect->w / 2 ) - ( STALKWIDTH / 2 ) - drawOrigin[ 0 ],
|
||||
rect->y + ( rect->h / 2 ) + drawOrigin[ 1 ] - drawOrigin[ 2 ],
|
||||
STALKWIDTH, drawOrigin[ 2 ], cgs.media.scannerLineShader );
|
||||
else
|
||||
CG_DrawPic( rect->x + ( rect->w / 2 ) - ( STALKWIDTH / 2 ) - drawOrigin[ 0 ],
|
||||
rect->y + ( rect->h / 2 ) + drawOrigin[ 1 ],
|
||||
STALKWIDTH, -drawOrigin[ 2 ], cgs.media.scannerLineShader );
|
||||
|
||||
CG_DrawPic( rect->x + ( rect->w / 2 ) - ( BLIPX / 2 ) - drawOrigin[ 0 ],
|
||||
rect->y + ( rect->h / 2 ) - ( BLIPY / 2 ) + drawOrigin[ 1 ] - drawOrigin[ 2 ],
|
||||
BLIPX, BLIPY, cgs.media.scannerBlipShader );
|
||||
trap_R_SetColor( NULL );
|
||||
}
|
||||
|
||||
#define BLIPX2 24.0f
|
||||
#define BLIPY2 24.0f
|
||||
|
||||
/*
|
||||
=============
|
||||
CG_DrawDir
|
||||
|
||||
Draw dot marking the direction to an enemy
|
||||
=============
|
||||
*/
|
||||
static void CG_DrawDir( rectDef_t *rect, vec3_t origin, vec4_t colour )
|
||||
{
|
||||
vec3_t drawOrigin;
|
||||
vec3_t noZOrigin;
|
||||
vec3_t normal, antinormal, normalDiff;
|
||||
vec3_t view, noZview;
|
||||
vec3_t up = { 0.0f, 0.0f, 1.0f };
|
||||
vec3_t top = { 0.0f, -1.0f, 0.0f };
|
||||
float angle;
|
||||
playerState_t *ps = &cg.snap->ps;
|
||||
|
||||
if( ps->stats[ STAT_STATE ] & SS_WALLCLIMBING )
|
||||
{
|
||||
if( ps->stats[ STAT_STATE ] & SS_WALLCLIMBINGCEILING )
|
||||
VectorSet( normal, 0.0f, 0.0f, -1.0f );
|
||||
else
|
||||
VectorCopy( ps->grapplePoint, normal );
|
||||
}
|
||||
else
|
||||
VectorSet( normal, 0.0f, 0.0f, 1.0f );
|
||||
|
||||
AngleVectors( entityPositions.vangles, view, NULL, NULL );
|
||||
|
||||
ProjectPointOnPlane( noZOrigin, origin, normal );
|
||||
ProjectPointOnPlane( noZview, view, normal );
|
||||
VectorNormalize( noZOrigin );
|
||||
VectorNormalize( noZview );
|
||||
|
||||
//calculate the angle between the images of the blip and the view
|
||||
angle = RAD2DEG( acos( DotProduct( noZOrigin, noZview ) ) );
|
||||
CrossProduct( noZOrigin, noZview, antinormal );
|
||||
VectorNormalize( antinormal );
|
||||
|
||||
//decide which way to rotate
|
||||
VectorSubtract( normal, antinormal, normalDiff );
|
||||
if( VectorLength( normalDiff ) < 1.0f )
|
||||
angle = 360.0f - angle;
|
||||
|
||||
RotatePointAroundVector( drawOrigin, up, top, angle );
|
||||
|
||||
trap_R_SetColor( colour );
|
||||
CG_DrawPic( rect->x + ( rect->w / 2 ) - ( BLIPX2 / 2 ) - drawOrigin[ 0 ] * ( rect->w / 2 ),
|
||||
rect->y + ( rect->h / 2 ) - ( BLIPY2 / 2 ) + drawOrigin[ 1 ] * ( rect->h / 2 ),
|
||||
BLIPX2, BLIPY2, cgs.media.scannerBlipShader );
|
||||
trap_R_SetColor( NULL );
|
||||
}
|
||||
|
||||
/*
|
||||
=============
|
||||
CG_AlienSense
|
||||
=============
|
||||
*/
|
||||
void CG_AlienSense( rectDef_t *rect )
|
||||
{
|
||||
int i;
|
||||
vec3_t origin;
|
||||
vec3_t relOrigin;
|
||||
vec4_t buildable = { 1.0f, 0.0f, 0.0f, 0.7f };
|
||||
vec4_t client = { 0.0f, 0.0f, 1.0f, 0.7f };
|
||||
|
||||
VectorCopy( entityPositions.origin, origin );
|
||||
|
||||
//draw human buildables
|
||||
for( i = 0; i < entityPositions.numHumanBuildables; i++ )
|
||||
{
|
||||
VectorClear( relOrigin );
|
||||
VectorSubtract( entityPositions.humanBuildablePos[ i ], origin, relOrigin );
|
||||
|
||||
if( VectorLength( relOrigin ) < ALIENSENSE_RANGE )
|
||||
CG_DrawDir( rect, relOrigin, buildable );
|
||||
}
|
||||
|
||||
//draw human clients
|
||||
for( i = 0; i < entityPositions.numHumanClients; i++ )
|
||||
{
|
||||
VectorClear( relOrigin );
|
||||
VectorSubtract( entityPositions.humanClientPos[ i ], origin, relOrigin );
|
||||
|
||||
if( VectorLength( relOrigin ) < ALIENSENSE_RANGE )
|
||||
CG_DrawDir( rect, relOrigin, client );
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
=============
|
||||
CG_Scanner
|
||||
=============
|
||||
*/
|
||||
void CG_Scanner( rectDef_t *rect, qhandle_t shader, vec4_t color )
|
||||
{
|
||||
int i;
|
||||
vec3_t origin;
|
||||
vec3_t relOrigin;
|
||||
vec4_t hIabove;
|
||||
vec4_t hIbelow;
|
||||
vec4_t aIabove = { 1.0f, 0.0f, 0.0f, 0.75f };
|
||||
vec4_t aIbelow = { 1.0f, 0.0f, 0.0f, 0.5f };
|
||||
|
||||
Vector4Copy( color, hIabove );
|
||||
hIabove[ 3 ] *= 1.5f;
|
||||
Vector4Copy( color, hIbelow );
|
||||
|
||||
VectorCopy( entityPositions.origin, origin );
|
||||
|
||||
//draw human buildables below scanner plane
|
||||
for( i = 0; i < entityPositions.numHumanBuildables; i++ )
|
||||
{
|
||||
VectorClear( relOrigin );
|
||||
VectorSubtract( entityPositions.humanBuildablePos[ i ], origin, relOrigin );
|
||||
|
||||
if( VectorLength( relOrigin ) < HELMET_RANGE && ( relOrigin[ 2 ] < 0 ) )
|
||||
CG_DrawBlips( rect, relOrigin, hIbelow );
|
||||
}
|
||||
|
||||
//draw alien buildables below scanner plane
|
||||
for( i = 0; i < entityPositions.numAlienBuildables; i++ )
|
||||
{
|
||||
VectorClear( relOrigin );
|
||||
VectorSubtract( entityPositions.alienBuildablePos[ i ], origin, relOrigin );
|
||||
|
||||
if( VectorLength( relOrigin ) < HELMET_RANGE && ( relOrigin[ 2 ] < 0 ) )
|
||||
CG_DrawBlips( rect, relOrigin, aIbelow );
|
||||
}
|
||||
|
||||
//draw human clients below scanner plane
|
||||
for( i = 0; i < entityPositions.numHumanClients; i++ )
|
||||
{
|
||||
VectorClear( relOrigin );
|
||||
VectorSubtract( entityPositions.humanClientPos[ i ], origin, relOrigin );
|
||||
|
||||
if( VectorLength( relOrigin ) < HELMET_RANGE && ( relOrigin[ 2 ] < 0 ) )
|
||||
CG_DrawBlips( rect, relOrigin, hIbelow );
|
||||
}
|
||||
|
||||
//draw alien buildables below scanner plane
|
||||
for( i = 0; i < entityPositions.numAlienClients; i++ )
|
||||
{
|
||||
VectorClear( relOrigin );
|
||||
VectorSubtract( entityPositions.alienClientPos[ i ], origin, relOrigin );
|
||||
|
||||
if( VectorLength( relOrigin ) < HELMET_RANGE && ( relOrigin[ 2 ] < 0 ) )
|
||||
CG_DrawBlips( rect, relOrigin, aIbelow );
|
||||
}
|
||||
|
||||
if( !cg_disableScannerPlane.integer )
|
||||
{
|
||||
trap_R_SetColor( color );
|
||||
CG_DrawPic( rect->x, rect->y, rect->w, rect->h, shader );
|
||||
trap_R_SetColor( NULL );
|
||||
}
|
||||
|
||||
//draw human buildables above scanner plane
|
||||
for( i = 0; i < entityPositions.numHumanBuildables; i++ )
|
||||
{
|
||||
VectorClear( relOrigin );
|
||||
VectorSubtract( entityPositions.humanBuildablePos[ i ], origin, relOrigin );
|
||||
|
||||
if( VectorLength( relOrigin ) < HELMET_RANGE && ( relOrigin[ 2 ] > 0 ) )
|
||||
CG_DrawBlips( rect, relOrigin, hIabove );
|
||||
}
|
||||
|
||||
//draw alien buildables above scanner plane
|
||||
for( i = 0; i < entityPositions.numAlienBuildables; i++ )
|
||||
{
|
||||
VectorClear( relOrigin );
|
||||
VectorSubtract( entityPositions.alienBuildablePos[ i ], origin, relOrigin );
|
||||
|
||||
if( VectorLength( relOrigin ) < HELMET_RANGE && ( relOrigin[ 2 ] > 0 ) )
|
||||
CG_DrawBlips( rect, relOrigin, aIabove );
|
||||
}
|
||||
|
||||
//draw human clients above scanner plane
|
||||
for( i = 0; i < entityPositions.numHumanClients; i++ )
|
||||
{
|
||||
VectorClear( relOrigin );
|
||||
VectorSubtract( entityPositions.humanClientPos[ i ], origin, relOrigin );
|
||||
|
||||
if( VectorLength( relOrigin ) < HELMET_RANGE && ( relOrigin[ 2 ] > 0 ) )
|
||||
CG_DrawBlips( rect, relOrigin, hIabove );
|
||||
}
|
||||
|
||||
//draw alien clients above scanner plane
|
||||
for( i = 0; i < entityPositions.numAlienClients; i++ )
|
||||
{
|
||||
VectorClear( relOrigin );
|
||||
VectorSubtract( entityPositions.alienClientPos[ i ], origin, relOrigin );
|
||||
|
||||
if( VectorLength( relOrigin ) < HELMET_RANGE && ( relOrigin[ 2 ] > 0 ) )
|
||||
CG_DrawBlips( rect, relOrigin, aIabove );
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,411 +0,0 @@
|
||||
/*
|
||||
===========================================================================
|
||||
Copyright (C) 1999-2005 Id Software, Inc.
|
||||
Copyright (C) 2000-2006 Tim Angus
|
||||
|
||||
This file is part of Tremulous.
|
||||
|
||||
Tremulous is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
Tremulous is distributed in the hope that it will be
|
||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Tremulous; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
===========================================================================
|
||||
*/
|
||||
|
||||
// cg_snapshot.c -- things that happen on snapshot transition,
|
||||
// not necessarily every single rendered frame
|
||||
|
||||
|
||||
#include "cg_local.h"
|
||||
|
||||
/*
|
||||
==================
|
||||
CG_ResetEntity
|
||||
==================
|
||||
*/
|
||||
static void CG_ResetEntity( centity_t *cent )
|
||||
{
|
||||
// if the previous snapshot this entity was updated in is at least
|
||||
// an event window back in time then we can reset the previous event
|
||||
if( cent->snapShotTime < cg.time - EVENT_VALID_MSEC )
|
||||
cent->previousEvent = 0;
|
||||
|
||||
cent->trailTime = cg.snap->serverTime;
|
||||
|
||||
VectorCopy( cent->currentState.origin, cent->lerpOrigin );
|
||||
VectorCopy( cent->currentState.angles, cent->lerpAngles );
|
||||
|
||||
if( cent->currentState.eType == ET_PLAYER )
|
||||
CG_ResetPlayerEntity( cent );
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
CG_TransitionEntity
|
||||
|
||||
cent->nextState is moved to cent->currentState and events are fired
|
||||
===============
|
||||
*/
|
||||
static void CG_TransitionEntity( centity_t *cent )
|
||||
{
|
||||
cent->currentState = cent->nextState;
|
||||
cent->currentValid = qtrue;
|
||||
|
||||
// reset if the entity wasn't in the last frame or was teleported
|
||||
if( !cent->interpolate )
|
||||
CG_ResetEntity( cent );
|
||||
|
||||
// clear the next state. if will be set by the next CG_SetNextSnap
|
||||
cent->interpolate = qfalse;
|
||||
|
||||
// check for events
|
||||
CG_CheckEvents( cent );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
==================
|
||||
CG_SetInitialSnapshot
|
||||
|
||||
This will only happen on the very first snapshot, or
|
||||
on tourney restarts. All other times will use
|
||||
CG_TransitionSnapshot instead.
|
||||
|
||||
FIXME: Also called by map_restart?
|
||||
==================
|
||||
*/
|
||||
void CG_SetInitialSnapshot( snapshot_t *snap )
|
||||
{
|
||||
int i;
|
||||
centity_t *cent;
|
||||
entityState_t *state;
|
||||
|
||||
cg.snap = snap;
|
||||
|
||||
BG_PlayerStateToEntityState( &snap->ps, &cg_entities[ snap->ps.clientNum ].currentState, qfalse );
|
||||
|
||||
// sort out solid entities
|
||||
CG_BuildSolidList( );
|
||||
|
||||
CG_ExecuteNewServerCommands( snap->serverCommandSequence );
|
||||
|
||||
// set our local weapon selection pointer to
|
||||
// what the server has indicated the current weapon is
|
||||
CG_Respawn( );
|
||||
|
||||
for( i = 0; i < cg.snap->numEntities; i++ )
|
||||
{
|
||||
state = &cg.snap->entities[ i ];
|
||||
cent = &cg_entities[ state->number ];
|
||||
|
||||
memcpy( ¢->currentState, state, sizeof( entityState_t ) );
|
||||
//cent->currentState = *state;
|
||||
cent->interpolate = qfalse;
|
||||
cent->currentValid = qtrue;
|
||||
|
||||
CG_ResetEntity( cent );
|
||||
|
||||
// check for events
|
||||
CG_CheckEvents( cent );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
===================
|
||||
CG_TransitionSnapshot
|
||||
|
||||
The transition point from snap to nextSnap has passed
|
||||
===================
|
||||
*/
|
||||
static void CG_TransitionSnapshot( void )
|
||||
{
|
||||
centity_t *cent;
|
||||
snapshot_t *oldFrame;
|
||||
int i;
|
||||
|
||||
if( !cg.snap )
|
||||
CG_Error( "CG_TransitionSnapshot: NULL cg.snap" );
|
||||
|
||||
if( !cg.nextSnap )
|
||||
CG_Error( "CG_TransitionSnapshot: NULL cg.nextSnap" );
|
||||
|
||||
// execute any server string commands before transitioning entities
|
||||
CG_ExecuteNewServerCommands( cg.nextSnap->serverCommandSequence );
|
||||
|
||||
// if we had a map_restart, set everthing with initial
|
||||
if( !cg.snap ) { } //TA: ?
|
||||
|
||||
// clear the currentValid flag for all entities in the existing snapshot
|
||||
for( i = 0; i < cg.snap->numEntities; i++ )
|
||||
{
|
||||
cent = &cg_entities[ cg.snap->entities[ i ].number ];
|
||||
cent->currentValid = qfalse;
|
||||
}
|
||||
|
||||
// move nextSnap to snap and do the transitions
|
||||
oldFrame = cg.snap;
|
||||
cg.snap = cg.nextSnap;
|
||||
|
||||
BG_PlayerStateToEntityState( &cg.snap->ps, &cg_entities[ cg.snap->ps.clientNum ].currentState, qfalse );
|
||||
cg_entities[ cg.snap->ps.clientNum ].interpolate = qfalse;
|
||||
|
||||
for( i = 0; i < cg.snap->numEntities; i++ )
|
||||
{
|
||||
cent = &cg_entities[ cg.snap->entities[ i ].number ];
|
||||
CG_TransitionEntity( cent );
|
||||
|
||||
// remember time of snapshot this entity was last updated in
|
||||
cent->snapShotTime = cg.snap->serverTime;
|
||||
}
|
||||
|
||||
cg.nextSnap = NULL;
|
||||
|
||||
// check for playerstate transition events
|
||||
if( oldFrame )
|
||||
{
|
||||
playerState_t *ops, *ps;
|
||||
|
||||
ops = &oldFrame->ps;
|
||||
ps = &cg.snap->ps;
|
||||
// teleporting checks are irrespective of prediction
|
||||
if( ( ps->eFlags ^ ops->eFlags ) & EF_TELEPORT_BIT )
|
||||
cg.thisFrameTeleport = qtrue; // will be cleared by prediction code
|
||||
|
||||
// if we are not doing client side movement prediction for any
|
||||
// reason, then the client events and view changes will be issued now
|
||||
if( cg.demoPlayback || ( cg.snap->ps.pm_flags & PMF_FOLLOW ) ||
|
||||
cg_nopredict.integer || cg_synchronousClients.integer )
|
||||
CG_TransitionPlayerState( ps, ops );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
===================
|
||||
CG_SetNextSnap
|
||||
|
||||
A new snapshot has just been read in from the client system.
|
||||
===================
|
||||
*/
|
||||
static void CG_SetNextSnap( snapshot_t *snap )
|
||||
{
|
||||
int num;
|
||||
entityState_t *es;
|
||||
centity_t *cent;
|
||||
|
||||
cg.nextSnap = snap;
|
||||
|
||||
BG_PlayerStateToEntityState( &snap->ps, &cg_entities[ snap->ps.clientNum ].nextState, qfalse );
|
||||
cg_entities[ cg.snap->ps.clientNum ].interpolate = qtrue;
|
||||
|
||||
// check for extrapolation errors
|
||||
for( num = 0 ; num < snap->numEntities ; num++ )
|
||||
{
|
||||
es = &snap->entities[ num ];
|
||||
cent = &cg_entities[ es->number ];
|
||||
|
||||
memcpy( ¢->nextState, es, sizeof( entityState_t ) );
|
||||
//cent->nextState = *es;
|
||||
|
||||
// if this frame is a teleport, or the entity wasn't in the
|
||||
// previous frame, don't interpolate
|
||||
if( !cent->currentValid || ( ( cent->currentState.eFlags ^ es->eFlags ) & EF_TELEPORT_BIT ) )
|
||||
cent->interpolate = qfalse;
|
||||
else
|
||||
cent->interpolate = qtrue;
|
||||
}
|
||||
|
||||
// if the next frame is a teleport for the playerstate, we
|
||||
// can't interpolate during demos
|
||||
if( cg.snap && ( ( snap->ps.eFlags ^ cg.snap->ps.eFlags ) & EF_TELEPORT_BIT ) )
|
||||
cg.nextFrameTeleport = qtrue;
|
||||
else
|
||||
cg.nextFrameTeleport = qfalse;
|
||||
|
||||
// if changing follow mode, don't interpolate
|
||||
if( cg.nextSnap->ps.clientNum != cg.snap->ps.clientNum )
|
||||
cg.nextFrameTeleport = qtrue;
|
||||
|
||||
// if changing server restarts, don't interpolate
|
||||
if( ( cg.nextSnap->snapFlags ^ cg.snap->snapFlags ) & SNAPFLAG_SERVERCOUNT )
|
||||
cg.nextFrameTeleport = qtrue;
|
||||
|
||||
// sort out solid entities
|
||||
CG_BuildSolidList( );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
========================
|
||||
CG_ReadNextSnapshot
|
||||
|
||||
This is the only place new snapshots are requested
|
||||
This may increment cgs.processedSnapshotNum multiple
|
||||
times if the client system fails to return a
|
||||
valid snapshot.
|
||||
========================
|
||||
*/
|
||||
static snapshot_t *CG_ReadNextSnapshot( void )
|
||||
{
|
||||
qboolean r;
|
||||
snapshot_t *dest;
|
||||
|
||||
if( cg.latestSnapshotNum > cgs.processedSnapshotNum + 1000 )
|
||||
{
|
||||
CG_Printf( "WARNING: CG_ReadNextSnapshot: way out of range, %i > %i",
|
||||
cg.latestSnapshotNum, cgs.processedSnapshotNum );
|
||||
}
|
||||
|
||||
while( cgs.processedSnapshotNum < cg.latestSnapshotNum )
|
||||
{
|
||||
// decide which of the two slots to load it into
|
||||
if( cg.snap == &cg.activeSnapshots[ 0 ] )
|
||||
dest = &cg.activeSnapshots[ 1 ];
|
||||
else
|
||||
dest = &cg.activeSnapshots[ 0 ];
|
||||
|
||||
// try to read the snapshot from the client system
|
||||
cgs.processedSnapshotNum++;
|
||||
r = trap_GetSnapshot( cgs.processedSnapshotNum, dest );
|
||||
|
||||
// FIXME: why would trap_GetSnapshot return a snapshot with the same server time
|
||||
if( cg.snap && r && dest->serverTime == cg.snap->serverTime )
|
||||
{
|
||||
//continue;
|
||||
}
|
||||
|
||||
// if it succeeded, return
|
||||
if( r )
|
||||
{
|
||||
CG_AddLagometerSnapshotInfo( dest );
|
||||
return dest;
|
||||
}
|
||||
|
||||
// a GetSnapshot will return failure if the snapshot
|
||||
// never arrived, or is so old that its entities
|
||||
// have been shoved off the end of the circular
|
||||
// buffer in the client system.
|
||||
|
||||
// record as a dropped packet
|
||||
CG_AddLagometerSnapshotInfo( NULL );
|
||||
|
||||
// If there are additional snapshots, continue trying to
|
||||
// read them.
|
||||
}
|
||||
|
||||
// nothing left to read
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
============
|
||||
CG_ProcessSnapshots
|
||||
|
||||
We are trying to set up a renderable view, so determine
|
||||
what the simulated time is, and try to get snapshots
|
||||
both before and after that time if available.
|
||||
|
||||
If we don't have a valid cg.snap after exiting this function,
|
||||
then a 3D game view cannot be rendered. This should only happen
|
||||
right after the initial connection. After cg.snap has been valid
|
||||
once, it will never turn invalid.
|
||||
|
||||
Even if cg.snap is valid, cg.nextSnap may not be, if the snapshot
|
||||
hasn't arrived yet (it becomes an extrapolating situation instead
|
||||
of an interpolating one)
|
||||
|
||||
============
|
||||
*/
|
||||
void CG_ProcessSnapshots( void )
|
||||
{
|
||||
snapshot_t *snap;
|
||||
int n;
|
||||
|
||||
// see what the latest snapshot the client system has is
|
||||
trap_GetCurrentSnapshotNumber( &n, &cg.latestSnapshotTime );
|
||||
|
||||
if( n != cg.latestSnapshotNum )
|
||||
{
|
||||
if( n < cg.latestSnapshotNum )
|
||||
{
|
||||
// this should never happen
|
||||
CG_Error( "CG_ProcessSnapshots: n < cg.latestSnapshotNum" );
|
||||
}
|
||||
|
||||
cg.latestSnapshotNum = n;
|
||||
}
|
||||
|
||||
// If we have yet to receive a snapshot, check for it.
|
||||
// Once we have gotten the first snapshot, cg.snap will
|
||||
// always have valid data for the rest of the game
|
||||
while( !cg.snap )
|
||||
{
|
||||
snap = CG_ReadNextSnapshot( );
|
||||
|
||||
if( !snap )
|
||||
{
|
||||
// we can't continue until we get a snapshot
|
||||
return;
|
||||
}
|
||||
|
||||
// set our weapon selection to what
|
||||
// the playerstate is currently using
|
||||
if( !( snap->snapFlags & SNAPFLAG_NOT_ACTIVE ) )
|
||||
CG_SetInitialSnapshot( snap );
|
||||
}
|
||||
|
||||
// loop until we either have a valid nextSnap with a serverTime
|
||||
// greater than cg.time to interpolate towards, or we run
|
||||
// out of available snapshots
|
||||
do
|
||||
{
|
||||
// if we don't have a nextframe, try and read a new one in
|
||||
if( !cg.nextSnap )
|
||||
{
|
||||
snap = CG_ReadNextSnapshot( );
|
||||
|
||||
// if we still don't have a nextframe, we will just have to
|
||||
// extrapolate
|
||||
if( !snap )
|
||||
break;
|
||||
|
||||
CG_SetNextSnap( snap );
|
||||
|
||||
// if time went backwards, we have a level restart
|
||||
if( cg.nextSnap->serverTime < cg.snap->serverTime )
|
||||
CG_Error( "CG_ProcessSnapshots: Server time went backwards" );
|
||||
}
|
||||
|
||||
// if our time is < nextFrame's, we have a nice interpolating state
|
||||
if( cg.time >= cg.snap->serverTime && cg.time < cg.nextSnap->serverTime )
|
||||
break;
|
||||
|
||||
// we have passed the transition from nextFrame to frame
|
||||
CG_TransitionSnapshot( );
|
||||
} while( 1 );
|
||||
|
||||
// assert our valid conditions upon exiting
|
||||
if( cg.snap == NULL )
|
||||
CG_Error( "CG_ProcessSnapshots: cg.snap == NULL" );
|
||||
|
||||
if( cg.time < cg.snap->serverTime )
|
||||
{
|
||||
// this can happen right after a vid_restart
|
||||
cg.time = cg.snap->serverTime;
|
||||
}
|
||||
|
||||
if( cg.nextSnap != NULL && cg.nextSnap->serverTime <= cg.time )
|
||||
CG_Error( "CG_ProcessSnapshots: cg.nextSnap->serverTime <= cg.time" );
|
||||
}
|
||||
|
||||
@@ -1,116 +0,0 @@
|
||||
code
|
||||
|
||||
equ trap_Print -1
|
||||
equ trap_Error -2
|
||||
equ trap_Milliseconds -3
|
||||
equ trap_Cvar_Register -4
|
||||
equ trap_Cvar_Update -5
|
||||
equ trap_Cvar_Set -6
|
||||
equ trap_Cvar_VariableStringBuffer -7
|
||||
equ trap_Argc -8
|
||||
equ trap_Argv -9
|
||||
equ trap_Args -10
|
||||
equ trap_FS_FOpenFile -11
|
||||
equ trap_FS_Read -12
|
||||
equ trap_FS_Write -13
|
||||
equ trap_FS_FCloseFile -14
|
||||
equ trap_SendConsoleCommand -15
|
||||
equ trap_AddCommand -16
|
||||
equ trap_SendClientCommand -17
|
||||
equ trap_UpdateScreen -18
|
||||
equ trap_CM_LoadMap -19
|
||||
equ trap_CM_NumInlineModels -20
|
||||
equ trap_CM_InlineModel -21
|
||||
equ trap_CM_LoadModel -22
|
||||
equ trap_CM_TempBoxModel -23
|
||||
equ trap_CM_PointContents -24
|
||||
equ trap_CM_TransformedPointContents -25
|
||||
equ trap_CM_BoxTrace -26
|
||||
equ trap_CM_TransformedBoxTrace -27
|
||||
equ trap_CM_MarkFragments -28
|
||||
equ trap_S_StartSound -29
|
||||
equ trap_S_StartLocalSound -30
|
||||
equ trap_S_ClearLoopingSounds -31
|
||||
equ trap_S_AddLoopingSound -32
|
||||
equ trap_S_UpdateEntityPosition -33
|
||||
equ trap_S_Respatialize -34
|
||||
equ trap_S_RegisterSound -35
|
||||
equ trap_S_StartBackgroundTrack -36
|
||||
equ trap_R_LoadWorldMap -37
|
||||
equ trap_R_RegisterModel -38
|
||||
equ trap_R_RegisterSkin -39
|
||||
equ trap_R_RegisterShader -40
|
||||
equ trap_R_ClearScene -41
|
||||
equ trap_R_AddRefEntityToScene -42
|
||||
equ trap_R_AddPolyToScene -43
|
||||
equ trap_R_AddLightToScene -44
|
||||
equ trap_R_RenderScene -45
|
||||
equ trap_R_SetColor -46
|
||||
equ trap_R_DrawStretchPic -47
|
||||
equ trap_R_ModelBounds -48
|
||||
equ trap_R_LerpTag -49
|
||||
equ trap_GetGlconfig -50
|
||||
equ trap_GetGameState -51
|
||||
equ trap_GetCurrentSnapshotNumber -52
|
||||
equ trap_GetSnapshot -53
|
||||
equ trap_GetServerCommand -54
|
||||
equ trap_GetCurrentCmdNumber -55
|
||||
equ trap_GetUserCmd -56
|
||||
equ trap_SetUserCmdValue -57
|
||||
equ trap_R_RegisterShaderNoMip -58
|
||||
equ trap_MemoryRemaining -59
|
||||
equ trap_R_RegisterFont -60
|
||||
equ trap_Key_IsDown -61
|
||||
equ trap_Key_GetCatcher -62
|
||||
equ trap_Key_SetCatcher -63
|
||||
equ trap_Key_GetKey -64
|
||||
equ trap_S_StopBackgroundTrack -65
|
||||
equ trap_RealTime -66
|
||||
equ trap_SnapVector -67
|
||||
equ trap_RemoveCommand -68
|
||||
equ trap_R_LightForPoint -69
|
||||
equ trap_CIN_PlayCinematic -70
|
||||
equ trap_CIN_StopCinematic -71
|
||||
equ trap_CIN_RunCinematic -72
|
||||
equ trap_CIN_DrawCinematic -73
|
||||
equ trap_CIN_SetExtents -74
|
||||
equ trap_R_RemapShader -75
|
||||
equ trap_S_AddRealLoopingSound -76
|
||||
equ trap_S_StopLoopingSound -77
|
||||
equ trap_CM_TempCapsuleModel -78
|
||||
equ trap_CM_CapsuleTrace -79
|
||||
equ trap_CM_TransformedCapsuleTrace -80
|
||||
equ trap_R_AddAdditiveLightToScene -81
|
||||
equ trap_GetEntityToken -82
|
||||
equ trap_R_AddPolysToScene -83
|
||||
equ trap_R_inPVS -84
|
||||
equ trap_FS_Seek -85
|
||||
equ trap_FS_GetFileList -86
|
||||
equ trap_LiteralArgs -87
|
||||
equ trap_CM_BiSphereTrace -88
|
||||
equ trap_CM_TransformedBiSphereTrace -89
|
||||
equ trap_GetDemoState -90
|
||||
equ trap_GetDemoPos -91
|
||||
equ trap_GetDemoName -92
|
||||
equ trap_Key_KeynumToStringBuf -93
|
||||
equ trap_Key_GetBindingBuf -94
|
||||
equ trap_Key_SetBinding -95
|
||||
|
||||
equ trap_Parse_AddGlobalDefine -96
|
||||
equ trap_Parse_LoadSource -97
|
||||
equ trap_Parse_FreeSource -98
|
||||
equ trap_Parse_ReadToken -99
|
||||
equ trap_Parse_SourceFileAndLine -100
|
||||
|
||||
equ memset -201
|
||||
equ memcpy -202
|
||||
equ strncpy -203
|
||||
equ sin -204
|
||||
equ cos -205
|
||||
equ atan2 -206
|
||||
equ sqrt -207
|
||||
equ floor -208
|
||||
equ ceil -209
|
||||
equ testPrintInt -210
|
||||
equ testPrintFloat -211
|
||||
|
||||
@@ -1,570 +0,0 @@
|
||||
/*
|
||||
===========================================================================
|
||||
Copyright (C) 1999-2005 Id Software, Inc.
|
||||
Copyright (C) 2000-2006 Tim Angus
|
||||
|
||||
This file is part of Tremulous.
|
||||
|
||||
Tremulous is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
Tremulous is distributed in the hope that it will be
|
||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Tremulous; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
===========================================================================
|
||||
*/
|
||||
|
||||
// cg_syscalls.c -- this file is only included when building a dll
|
||||
// cg_syscalls.asm is included instead when building a qvm
|
||||
|
||||
|
||||
#include "cg_local.h"
|
||||
|
||||
static intptr_t (QDECL *syscall)( intptr_t arg, ... ) = (intptr_t (QDECL *)( intptr_t, ...))-1;
|
||||
|
||||
|
||||
void dllEntry( intptr_t (QDECL *syscallptr)( intptr_t arg,... ) )
|
||||
{
|
||||
syscall = syscallptr;
|
||||
}
|
||||
|
||||
|
||||
int PASSFLOAT( float x )
|
||||
{
|
||||
float floatTemp;
|
||||
floatTemp = x;
|
||||
return *(int *)&floatTemp;
|
||||
}
|
||||
|
||||
void trap_Print( const char *fmt )
|
||||
{
|
||||
syscall( CG_PRINT, fmt );
|
||||
}
|
||||
|
||||
void trap_Error( const char *fmt )
|
||||
{
|
||||
syscall( CG_ERROR, fmt );
|
||||
}
|
||||
|
||||
int trap_Milliseconds( void )
|
||||
{
|
||||
return syscall( CG_MILLISECONDS );
|
||||
}
|
||||
|
||||
void trap_Cvar_Register( vmCvar_t *vmCvar, const char *varName, const char *defaultValue, int flags )
|
||||
{
|
||||
syscall( CG_CVAR_REGISTER, vmCvar, varName, defaultValue, flags );
|
||||
}
|
||||
|
||||
void trap_Cvar_Update( vmCvar_t *vmCvar )
|
||||
{
|
||||
syscall( CG_CVAR_UPDATE, vmCvar );
|
||||
}
|
||||
|
||||
void trap_Cvar_Set( const char *var_name, const char *value )
|
||||
{
|
||||
syscall( CG_CVAR_SET, var_name, value );
|
||||
}
|
||||
|
||||
void trap_Cvar_VariableStringBuffer( const char *var_name, char *buffer, int bufsize )
|
||||
{
|
||||
syscall( CG_CVAR_VARIABLESTRINGBUFFER, var_name, buffer, bufsize );
|
||||
}
|
||||
|
||||
int trap_Argc( void )
|
||||
{
|
||||
return syscall( CG_ARGC );
|
||||
}
|
||||
|
||||
void trap_Argv( int n, char *buffer, int bufferLength )
|
||||
{
|
||||
syscall( CG_ARGV, n, buffer, bufferLength );
|
||||
}
|
||||
|
||||
void trap_Args( char *buffer, int bufferLength )
|
||||
{
|
||||
syscall( CG_ARGS, buffer, bufferLength );
|
||||
}
|
||||
|
||||
void trap_LiteralArgs( char *buffer, int bufferLength )
|
||||
{
|
||||
syscall( CG_LITERAL_ARGS, buffer, bufferLength );
|
||||
}
|
||||
|
||||
int trap_FS_FOpenFile( const char *qpath, fileHandle_t *f, fsMode_t mode )
|
||||
{
|
||||
return syscall( CG_FS_FOPENFILE, qpath, f, mode );
|
||||
}
|
||||
|
||||
void trap_FS_Read( void *buffer, int len, fileHandle_t f )
|
||||
{
|
||||
syscall( CG_FS_READ, buffer, len, f );
|
||||
}
|
||||
|
||||
void trap_FS_Write( const void *buffer, int len, fileHandle_t f )
|
||||
{
|
||||
syscall( CG_FS_WRITE, buffer, len, f );
|
||||
}
|
||||
|
||||
void trap_FS_FCloseFile( fileHandle_t f )
|
||||
{
|
||||
syscall( CG_FS_FCLOSEFILE, f );
|
||||
}
|
||||
|
||||
void trap_FS_Seek( fileHandle_t f, long offset, fsOrigin_t origin )
|
||||
{
|
||||
syscall( CG_FS_SEEK, f, offset, origin );
|
||||
}
|
||||
|
||||
int trap_FS_GetFileList( const char *path, const char *extension, char *listbuf, int bufsize )
|
||||
{
|
||||
return syscall( CG_FS_GETFILELIST, path, extension, listbuf, bufsize );
|
||||
}
|
||||
|
||||
void trap_SendConsoleCommand( const char *text )
|
||||
{
|
||||
syscall( CG_SENDCONSOLECOMMAND, text );
|
||||
}
|
||||
|
||||
void trap_AddCommand( const char *cmdName )
|
||||
{
|
||||
syscall( CG_ADDCOMMAND, cmdName );
|
||||
}
|
||||
|
||||
void trap_RemoveCommand( const char *cmdName )
|
||||
{
|
||||
syscall( CG_REMOVECOMMAND, cmdName );
|
||||
}
|
||||
|
||||
void trap_SendClientCommand( const char *s )
|
||||
{
|
||||
syscall( CG_SENDCLIENTCOMMAND, s );
|
||||
}
|
||||
|
||||
void trap_UpdateScreen( void )
|
||||
{
|
||||
syscall( CG_UPDATESCREEN );
|
||||
}
|
||||
|
||||
void trap_CM_LoadMap( const char *mapname )
|
||||
{
|
||||
syscall( CG_CM_LOADMAP, mapname );
|
||||
}
|
||||
|
||||
int trap_CM_NumInlineModels( void )
|
||||
{
|
||||
return syscall( CG_CM_NUMINLINEMODELS );
|
||||
}
|
||||
|
||||
clipHandle_t trap_CM_InlineModel( int index )
|
||||
{
|
||||
return syscall( CG_CM_INLINEMODEL, index );
|
||||
}
|
||||
|
||||
clipHandle_t trap_CM_TempBoxModel( const vec3_t mins, const vec3_t maxs )
|
||||
{
|
||||
return syscall( CG_CM_TEMPBOXMODEL, mins, maxs );
|
||||
}
|
||||
|
||||
clipHandle_t trap_CM_TempCapsuleModel( const vec3_t mins, const vec3_t maxs )
|
||||
{
|
||||
return syscall( CG_CM_TEMPCAPSULEMODEL, mins, maxs );
|
||||
}
|
||||
|
||||
int trap_CM_PointContents( const vec3_t p, clipHandle_t model )
|
||||
{
|
||||
return syscall( CG_CM_POINTCONTENTS, p, model );
|
||||
}
|
||||
|
||||
int trap_CM_TransformedPointContents( const vec3_t p, clipHandle_t model, const vec3_t origin,
|
||||
const vec3_t angles )
|
||||
{
|
||||
return syscall( CG_CM_TRANSFORMEDPOINTCONTENTS, p, model, origin, angles );
|
||||
}
|
||||
|
||||
void trap_CM_BoxTrace( trace_t *results, const vec3_t start, const vec3_t end,
|
||||
const vec3_t mins, const vec3_t maxs,
|
||||
clipHandle_t model, int brushmask )
|
||||
{
|
||||
syscall( CG_CM_BOXTRACE, results, start, end, mins, maxs, model, brushmask );
|
||||
}
|
||||
|
||||
void trap_CM_CapsuleTrace( trace_t *results, const vec3_t start, const vec3_t end,
|
||||
const vec3_t mins, const vec3_t maxs,
|
||||
clipHandle_t model, int brushmask )
|
||||
{
|
||||
syscall( CG_CM_CAPSULETRACE, results, start, end, mins, maxs, model, brushmask );
|
||||
}
|
||||
|
||||
void trap_CM_TransformedBoxTrace( trace_t *results, const vec3_t start, const vec3_t end,
|
||||
const vec3_t mins, const vec3_t maxs,
|
||||
clipHandle_t model, int brushmask,
|
||||
const vec3_t origin, const vec3_t angles )
|
||||
{
|
||||
syscall( CG_CM_TRANSFORMEDBOXTRACE, results, start, end, mins, maxs, model, brushmask, origin, angles );
|
||||
}
|
||||
|
||||
void trap_CM_TransformedCapsuleTrace( trace_t *results, const vec3_t start, const vec3_t end,
|
||||
const vec3_t mins, const vec3_t maxs,
|
||||
clipHandle_t model, int brushmask,
|
||||
const vec3_t origin, const vec3_t angles )
|
||||
{
|
||||
syscall( CG_CM_TRANSFORMEDCAPSULETRACE, results, start, end, mins, maxs, model, brushmask, origin, angles );
|
||||
}
|
||||
|
||||
void trap_CM_BiSphereTrace( trace_t *results, const vec3_t start,
|
||||
const vec3_t end, float startRad, float endRad,
|
||||
clipHandle_t model, int mask )
|
||||
{
|
||||
syscall( CG_CM_BISPHERETRACE, results, start, end,
|
||||
PASSFLOAT( startRad ), PASSFLOAT( endRad ), model, mask );
|
||||
}
|
||||
|
||||
void trap_CM_TransformedBiSphereTrace( trace_t *results, const vec3_t start,
|
||||
const vec3_t end, float startRad, float endRad,
|
||||
clipHandle_t model, int mask,
|
||||
const vec3_t origin )
|
||||
{
|
||||
syscall( CG_CM_TRANSFORMEDBISPHERETRACE, results, start, end, PASSFLOAT( startRad ),
|
||||
PASSFLOAT( endRad ), model, mask, origin );
|
||||
}
|
||||
|
||||
int trap_CM_MarkFragments( int numPoints, const vec3_t *points,
|
||||
const vec3_t projection,
|
||||
int maxPoints, vec3_t pointBuffer,
|
||||
int maxFragments, markFragment_t *fragmentBuffer )
|
||||
{
|
||||
return syscall( CG_CM_MARKFRAGMENTS, numPoints, points, projection, maxPoints,
|
||||
pointBuffer, maxFragments, fragmentBuffer );
|
||||
}
|
||||
|
||||
void trap_S_StartSound( vec3_t origin, int entityNum, int entchannel, sfxHandle_t sfx )
|
||||
{
|
||||
syscall( CG_S_STARTSOUND, origin, entityNum, entchannel, sfx );
|
||||
}
|
||||
|
||||
void trap_S_StartLocalSound( sfxHandle_t sfx, int channelNum )
|
||||
{
|
||||
syscall( CG_S_STARTLOCALSOUND, sfx, channelNum );
|
||||
}
|
||||
|
||||
void trap_S_ClearLoopingSounds( qboolean killall )
|
||||
{
|
||||
syscall( CG_S_CLEARLOOPINGSOUNDS, killall );
|
||||
}
|
||||
|
||||
void trap_S_AddLoopingSound( int entityNum, const vec3_t origin, const vec3_t velocity, sfxHandle_t sfx )
|
||||
{
|
||||
syscall( CG_S_ADDLOOPINGSOUND, entityNum, origin, velocity, sfx );
|
||||
}
|
||||
|
||||
void trap_S_AddRealLoopingSound( int entityNum, const vec3_t origin, const vec3_t velocity, sfxHandle_t sfx )
|
||||
{
|
||||
syscall( CG_S_ADDREALLOOPINGSOUND, entityNum, origin, velocity, sfx );
|
||||
}
|
||||
|
||||
void trap_S_StopLoopingSound( int entityNum )
|
||||
{
|
||||
syscall( CG_S_STOPLOOPINGSOUND, entityNum );
|
||||
}
|
||||
|
||||
void trap_S_UpdateEntityPosition( int entityNum, const vec3_t origin )
|
||||
{
|
||||
syscall( CG_S_UPDATEENTITYPOSITION, entityNum, origin );
|
||||
}
|
||||
|
||||
void trap_S_Respatialize( int entityNum, const vec3_t origin, vec3_t axis[3], int inwater )
|
||||
{
|
||||
syscall( CG_S_RESPATIALIZE, entityNum, origin, axis, inwater );
|
||||
}
|
||||
|
||||
sfxHandle_t trap_S_RegisterSound( const char *sample, qboolean compressed )
|
||||
{
|
||||
return syscall( CG_S_REGISTERSOUND, sample, compressed );
|
||||
}
|
||||
|
||||
void trap_S_StartBackgroundTrack( const char *intro, const char *loop )
|
||||
{
|
||||
syscall( CG_S_STARTBACKGROUNDTRACK, intro, loop );
|
||||
}
|
||||
|
||||
void trap_R_LoadWorldMap( const char *mapname )
|
||||
{
|
||||
syscall( CG_R_LOADWORLDMAP, mapname );
|
||||
}
|
||||
|
||||
qhandle_t trap_R_RegisterModel( const char *name )
|
||||
{
|
||||
return syscall( CG_R_REGISTERMODEL, name );
|
||||
}
|
||||
|
||||
qhandle_t trap_R_RegisterSkin( const char *name )
|
||||
{
|
||||
return syscall( CG_R_REGISTERSKIN, name );
|
||||
}
|
||||
|
||||
qhandle_t trap_R_RegisterShader( const char *name )
|
||||
{
|
||||
return syscall( CG_R_REGISTERSHADER, name );
|
||||
}
|
||||
|
||||
qhandle_t trap_R_RegisterShaderNoMip( const char *name )
|
||||
{
|
||||
return syscall( CG_R_REGISTERSHADERNOMIP, name );
|
||||
}
|
||||
|
||||
void trap_R_RegisterFont( const char *fontName, int pointSize, fontInfo_t *font )
|
||||
{
|
||||
syscall(CG_R_REGISTERFONT, fontName, pointSize, font );
|
||||
}
|
||||
|
||||
void trap_R_ClearScene( void )
|
||||
{
|
||||
syscall( CG_R_CLEARSCENE );
|
||||
}
|
||||
|
||||
void trap_R_AddRefEntityToScene( const refEntity_t *re )
|
||||
{
|
||||
syscall( CG_R_ADDREFENTITYTOSCENE, re );
|
||||
}
|
||||
|
||||
void trap_R_AddPolyToScene( qhandle_t hShader , int numVerts, const polyVert_t *verts )
|
||||
{
|
||||
syscall( CG_R_ADDPOLYTOSCENE, hShader, numVerts, verts );
|
||||
}
|
||||
|
||||
void trap_R_AddPolysToScene( qhandle_t hShader , int numVerts, const polyVert_t *verts, int num )
|
||||
{
|
||||
syscall( CG_R_ADDPOLYSTOSCENE, hShader, numVerts, verts, num );
|
||||
}
|
||||
|
||||
int trap_R_LightForPoint( vec3_t point, vec3_t ambientLight, vec3_t directedLight, vec3_t lightDir )
|
||||
{
|
||||
return syscall( CG_R_LIGHTFORPOINT, point, ambientLight, directedLight, lightDir );
|
||||
}
|
||||
|
||||
void trap_R_AddLightToScene( const vec3_t org, float intensity, float r, float g, float b )
|
||||
{
|
||||
syscall( CG_R_ADDLIGHTTOSCENE, org, PASSFLOAT(intensity), PASSFLOAT(r), PASSFLOAT(g), PASSFLOAT(b) );
|
||||
}
|
||||
|
||||
void trap_R_AddAdditiveLightToScene( const vec3_t org, float intensity, float r, float g, float b )
|
||||
{
|
||||
syscall( CG_R_ADDADDITIVELIGHTTOSCENE, org, PASSFLOAT(intensity), PASSFLOAT(r), PASSFLOAT(g), PASSFLOAT(b) );
|
||||
}
|
||||
|
||||
void trap_R_RenderScene( const refdef_t *fd )
|
||||
{
|
||||
syscall( CG_R_RENDERSCENE, fd );
|
||||
}
|
||||
|
||||
void trap_R_SetColor( const float *rgba )
|
||||
{
|
||||
syscall( CG_R_SETCOLOR, rgba );
|
||||
}
|
||||
|
||||
void trap_R_DrawStretchPic( float x, float y, float w, float h,
|
||||
float s1, float t1, float s2, float t2, qhandle_t hShader )
|
||||
{
|
||||
syscall( CG_R_DRAWSTRETCHPIC, PASSFLOAT(x), PASSFLOAT(y), PASSFLOAT(w), PASSFLOAT(h),
|
||||
PASSFLOAT(s1), PASSFLOAT(t1), PASSFLOAT(s2), PASSFLOAT(t2), hShader );
|
||||
}
|
||||
|
||||
void trap_R_ModelBounds( clipHandle_t model, vec3_t mins, vec3_t maxs ) {
|
||||
syscall( CG_R_MODELBOUNDS, model, mins, maxs );
|
||||
}
|
||||
|
||||
int trap_R_LerpTag( orientation_t *tag, clipHandle_t mod, int startFrame, int endFrame,
|
||||
float frac, const char *tagName )
|
||||
{
|
||||
return syscall( CG_R_LERPTAG, tag, mod, startFrame, endFrame, PASSFLOAT(frac), tagName );
|
||||
}
|
||||
|
||||
void trap_R_RemapShader( const char *oldShader, const char *newShader, const char *timeOffset )
|
||||
{
|
||||
syscall( CG_R_REMAP_SHADER, oldShader, newShader, timeOffset );
|
||||
}
|
||||
|
||||
void trap_GetGlconfig( glconfig_t *glconfig )
|
||||
{
|
||||
syscall( CG_GETGLCONFIG, glconfig );
|
||||
}
|
||||
|
||||
void trap_GetGameState( gameState_t *gamestate )
|
||||
{
|
||||
syscall( CG_GETGAMESTATE, gamestate );
|
||||
}
|
||||
|
||||
void trap_GetCurrentSnapshotNumber( int *snapshotNumber, int *serverTime )
|
||||
{
|
||||
syscall( CG_GETCURRENTSNAPSHOTNUMBER, snapshotNumber, serverTime );
|
||||
}
|
||||
|
||||
qboolean trap_GetSnapshot( int snapshotNumber, snapshot_t *snapshot )
|
||||
{
|
||||
return syscall( CG_GETSNAPSHOT, snapshotNumber, snapshot );
|
||||
}
|
||||
|
||||
qboolean trap_GetServerCommand( int serverCommandNumber )
|
||||
{
|
||||
return syscall( CG_GETSERVERCOMMAND, serverCommandNumber );
|
||||
}
|
||||
|
||||
int trap_GetCurrentCmdNumber( void )
|
||||
{
|
||||
return syscall( CG_GETCURRENTCMDNUMBER );
|
||||
}
|
||||
|
||||
qboolean trap_GetUserCmd( int cmdNumber, usercmd_t *ucmd )
|
||||
{
|
||||
return syscall( CG_GETUSERCMD, cmdNumber, ucmd );
|
||||
}
|
||||
|
||||
void trap_SetUserCmdValue( int stateValue, float sensitivityScale )
|
||||
{
|
||||
syscall( CG_SETUSERCMDVALUE, stateValue, PASSFLOAT( sensitivityScale ) );
|
||||
}
|
||||
|
||||
void testPrintInt( char *string, int i )
|
||||
{
|
||||
syscall( CG_TESTPRINTINT, string, i );
|
||||
}
|
||||
|
||||
void testPrintFloat( char *string, float f )
|
||||
{
|
||||
syscall( CG_TESTPRINTFLOAT, string, PASSFLOAT(f) );
|
||||
}
|
||||
|
||||
int trap_MemoryRemaining( void )
|
||||
{
|
||||
return syscall( CG_MEMORY_REMAINING );
|
||||
}
|
||||
|
||||
qboolean trap_Key_IsDown( int keynum )
|
||||
{
|
||||
return syscall( CG_KEY_ISDOWN, keynum );
|
||||
}
|
||||
|
||||
int trap_Key_GetCatcher( void )
|
||||
{
|
||||
return syscall( CG_KEY_GETCATCHER );
|
||||
}
|
||||
|
||||
void trap_Key_SetCatcher( int catcher )
|
||||
{
|
||||
syscall( CG_KEY_SETCATCHER, catcher );
|
||||
}
|
||||
|
||||
int trap_Key_GetKey( const char *binding )
|
||||
{
|
||||
return syscall( CG_KEY_GETKEY, binding );
|
||||
}
|
||||
|
||||
int trap_Parse_AddGlobalDefine( char *define )
|
||||
{
|
||||
return syscall( CG_PARSE_ADD_GLOBAL_DEFINE, define );
|
||||
}
|
||||
|
||||
int trap_Parse_LoadSource( const char *filename )
|
||||
{
|
||||
return syscall( CG_PARSE_LOAD_SOURCE, filename );
|
||||
}
|
||||
|
||||
int trap_Parse_FreeSource( int handle )
|
||||
{
|
||||
return syscall( CG_PARSE_FREE_SOURCE, handle );
|
||||
}
|
||||
|
||||
int trap_Parse_ReadToken( int handle, pc_token_t *pc_token )
|
||||
{
|
||||
return syscall( CG_PARSE_READ_TOKEN, handle, pc_token );
|
||||
}
|
||||
|
||||
int trap_Parse_SourceFileAndLine( int handle, char *filename, int *line )
|
||||
{
|
||||
return syscall( CG_PARSE_SOURCE_FILE_AND_LINE, handle, filename, line );
|
||||
}
|
||||
|
||||
void trap_S_StopBackgroundTrack( void )
|
||||
{
|
||||
syscall( CG_S_STOPBACKGROUNDTRACK );
|
||||
}
|
||||
|
||||
int trap_RealTime(qtime_t *qtime)
|
||||
{
|
||||
return syscall( CG_REAL_TIME, qtime );
|
||||
}
|
||||
|
||||
void trap_SnapVector( float *v )
|
||||
{
|
||||
syscall( CG_SNAPVECTOR, v );
|
||||
}
|
||||
|
||||
// this returns a handle. arg0 is the name in the format "idlogo.roq", set arg1 to NULL, alteredstates to qfalse (do not alter gamestate)
|
||||
int trap_CIN_PlayCinematic( const char *arg0, int xpos, int ypos, int width, int height, int bits )
|
||||
{
|
||||
return syscall(CG_CIN_PLAYCINEMATIC, arg0, xpos, ypos, width, height, bits);
|
||||
}
|
||||
|
||||
// stops playing the cinematic and ends it. should always return FMV_EOF
|
||||
// cinematics must be stopped in reverse order of when they are started
|
||||
e_status trap_CIN_StopCinematic( int handle )
|
||||
{
|
||||
return syscall(CG_CIN_STOPCINEMATIC, handle);
|
||||
}
|
||||
|
||||
|
||||
// will run a frame of the cinematic but will not draw it. Will return FMV_EOF if the end of the cinematic has been reached.
|
||||
e_status trap_CIN_RunCinematic( int handle )
|
||||
{
|
||||
return syscall(CG_CIN_RUNCINEMATIC, handle);
|
||||
}
|
||||
|
||||
|
||||
// draws the current frame
|
||||
void trap_CIN_DrawCinematic( int handle )
|
||||
{
|
||||
syscall(CG_CIN_DRAWCINEMATIC, handle);
|
||||
}
|
||||
|
||||
|
||||
// allows you to resize the animation dynamically
|
||||
void trap_CIN_SetExtents( int handle, int x, int y, int w, int h )
|
||||
{
|
||||
syscall(CG_CIN_SETEXTENTS, handle, x, y, w, h);
|
||||
}
|
||||
|
||||
int trap_GetDemoState( void )
|
||||
{
|
||||
return syscall( CG_GETDEMOSTATE );
|
||||
}
|
||||
|
||||
int trap_GetDemoPos( void )
|
||||
{
|
||||
return syscall( CG_GETDEMOPOS );
|
||||
}
|
||||
|
||||
void trap_GetDemoName( char *buffer, int size )
|
||||
{
|
||||
syscall( CG_GETDEMONAME, buffer, size );
|
||||
}
|
||||
|
||||
void trap_Key_KeynumToStringBuf( int keynum, char *buf, int buflen ) {
|
||||
syscall( CG_KEY_KEYNUMTOSTRINGBUF, keynum, buf, buflen );
|
||||
}
|
||||
|
||||
void trap_Key_GetBindingBuf( int keynum, char *buf, int buflen ) {
|
||||
syscall( CG_KEY_GETBINDINGBUF, keynum, buf, buflen );
|
||||
}
|
||||
|
||||
void trap_Key_SetBinding( int keynum, const char *binding ) {
|
||||
syscall( CG_KEY_SETBINDING, keynum, binding );
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,669 +0,0 @@
|
||||
/*
|
||||
===========================================================================
|
||||
Copyright (C) 2000-2006 Tim Angus
|
||||
|
||||
This file is part of Tremulous.
|
||||
|
||||
Tremulous is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
Tremulous is distributed in the hope that it will be
|
||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Tremulous; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
===========================================================================
|
||||
*/
|
||||
|
||||
// cg_tutorial.c -- the tutorial system
|
||||
|
||||
#include "cg_local.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char *command;
|
||||
char *humanName;
|
||||
keyNum_t keys[ 2 ];
|
||||
} bind_t;
|
||||
|
||||
static bind_t bindings[ ] =
|
||||
{
|
||||
{ "+button2", "Activate Upgrade", { -1, -1 } },
|
||||
{ "+speed", "Run/Walk", { -1, -1 } },
|
||||
{ "boost", "Sprint", { -1, -1 } },
|
||||
{ "+moveup", "Jump", { -1, -1 } },
|
||||
{ "+movedown", "Crouch", { -1, -1 } },
|
||||
{ "+attack", "Primary Attack", { -1, -1 } },
|
||||
{ "+button5", "Secondary Attack", { -1, -1 } },
|
||||
{ "reload", "Reload", { -1, -1 } },
|
||||
{ "buy ammo", "Buy Ammo", { -1, -1 } },
|
||||
{ "itemact medkit", "Use Medkit", { -1, -1 } },
|
||||
{ "+button7", "Use Structure/Evolve", { -1, -1 } },
|
||||
{ "deconstruct", "Deconstruct Structure", { -1, -1 } },
|
||||
{ "weapprev", "Previous Upgrade", { -1, -1 } },
|
||||
{ "weapnext", "Next Upgrade", { -1, -1 } }
|
||||
};
|
||||
|
||||
static const int numBindings = sizeof( bindings ) / sizeof( bind_t );
|
||||
|
||||
/*
|
||||
=================
|
||||
CG_GetBindings
|
||||
=================
|
||||
*/
|
||||
static void CG_GetBindings( void )
|
||||
{
|
||||
int i, j, numKeys;
|
||||
char buffer[ MAX_STRING_CHARS ];
|
||||
|
||||
for( i = 0; i < numBindings; i++ )
|
||||
{
|
||||
bindings[ i ].keys[ 0 ] = bindings[ i ].keys[ 1 ] = K_NONE;
|
||||
numKeys = 0;
|
||||
|
||||
for( j = 0; j < K_LAST_KEY; j++ )
|
||||
{
|
||||
trap_Key_GetBindingBuf( j, buffer, MAX_STRING_CHARS );
|
||||
|
||||
if( buffer[ 0 ] == 0 )
|
||||
continue;
|
||||
|
||||
if( !Q_stricmp( buffer, bindings[ i ].command ) )
|
||||
{
|
||||
bindings[ i ].keys[ numKeys++ ] = j;
|
||||
|
||||
if( numKeys > 1 )
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
CG_KeyNameForCommand
|
||||
===============
|
||||
*/
|
||||
static const char *CG_KeyNameForCommand( const char *command )
|
||||
{
|
||||
int i, j;
|
||||
static char buffer[ MAX_STRING_CHARS ];
|
||||
int firstKeyLength;
|
||||
|
||||
buffer[ 0 ] = '\0';
|
||||
|
||||
for( i = 0; i < numBindings; i++ )
|
||||
{
|
||||
if( !Q_stricmp( command, bindings[ i ].command ) )
|
||||
{
|
||||
if( bindings[ i ].keys[ 0 ] != K_NONE )
|
||||
{
|
||||
trap_Key_KeynumToStringBuf( bindings[ i ].keys[ 0 ],
|
||||
buffer, MAX_STRING_CHARS );
|
||||
firstKeyLength = strlen( buffer );
|
||||
|
||||
for( j = 0; j < firstKeyLength; j++ )
|
||||
buffer[ j ] = toupper( buffer[ j ] );
|
||||
|
||||
if( bindings[ i ].keys[ 1 ] != K_NONE )
|
||||
{
|
||||
Q_strcat( buffer, MAX_STRING_CHARS, " or " );
|
||||
trap_Key_KeynumToStringBuf( bindings[ i ].keys[ 1 ],
|
||||
buffer + strlen( buffer ), MAX_STRING_CHARS - strlen( buffer ) );
|
||||
|
||||
for( j = firstKeyLength + 4; j < strlen( buffer ); j++ )
|
||||
buffer[ j ] = toupper( buffer[ j ] );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Q_strncpyz( buffer, va( "\"%s\"", bindings[ i ].humanName ),
|
||||
MAX_STRING_CHARS );
|
||||
Q_strcat( buffer, MAX_STRING_CHARS, " (unbound)" );
|
||||
}
|
||||
|
||||
return buffer;
|
||||
}
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
#define MAX_TUTORIAL_TEXT 4096
|
||||
|
||||
/*
|
||||
===============
|
||||
CG_BuildableInRange
|
||||
===============
|
||||
*/
|
||||
static entityState_t *CG_BuildableInRange( playerState_t *ps, float *healthFraction )
|
||||
{
|
||||
vec3_t view, point;
|
||||
trace_t trace;
|
||||
entityState_t *es;
|
||||
int health;
|
||||
|
||||
AngleVectors( cg.refdefViewAngles, view, NULL, NULL );
|
||||
VectorMA( cg.refdef.vieworg, 64, view, point );
|
||||
CG_Trace( &trace, cg.refdef.vieworg, NULL, NULL,
|
||||
point, ps->clientNum, MASK_SHOT );
|
||||
|
||||
es = &cg_entities[ trace.entityNum ].currentState;
|
||||
|
||||
if( healthFraction )
|
||||
{
|
||||
health = es->generic1 & B_HEALTH_MASK;
|
||||
*healthFraction = (float)health / B_HEALTH_MASK;
|
||||
}
|
||||
|
||||
if( es->eType == ET_BUILDABLE &&
|
||||
ps->stats[ STAT_PTEAM ] == BG_FindTeamForBuildable( es->modelindex ) )
|
||||
return es;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
CG_AlienBuilderText
|
||||
===============
|
||||
*/
|
||||
static void CG_AlienBuilderText( char *text, playerState_t *ps )
|
||||
{
|
||||
buildable_t buildable = ps->stats[ STAT_BUILDABLE ] & ~SB_VALID_TOGGLEBIT;
|
||||
entityState_t *es;
|
||||
|
||||
if( buildable > BA_NONE )
|
||||
{
|
||||
Q_strcat( text, MAX_TUTORIAL_TEXT,
|
||||
va( "Press %s to place the %s\n",
|
||||
CG_KeyNameForCommand( "+attack" ),
|
||||
BG_FindHumanNameForBuildable( buildable ) ) );
|
||||
|
||||
Q_strcat( text, MAX_TUTORIAL_TEXT,
|
||||
va( "Press %s to cancel placing the %s\n",
|
||||
CG_KeyNameForCommand( "+button5" ),
|
||||
BG_FindHumanNameForBuildable( buildable ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
Q_strcat( text, MAX_TUTORIAL_TEXT,
|
||||
va( "Press %s to build a structure\n",
|
||||
CG_KeyNameForCommand( "+attack" ) ) );
|
||||
|
||||
if( ( es = CG_BuildableInRange( ps, NULL ) ) )
|
||||
{
|
||||
if( cgs.markDeconstruct )
|
||||
{
|
||||
if( es->generic1 & B_MARKED_TOGGLEBIT )
|
||||
{
|
||||
Q_strcat( text, MAX_TUTORIAL_TEXT,
|
||||
va( "Press %s to unmark this structure\n",
|
||||
CG_KeyNameForCommand( "deconstruct" ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
Q_strcat( text, MAX_TUTORIAL_TEXT,
|
||||
va( "Press %s to mark this structure\n",
|
||||
CG_KeyNameForCommand( "deconstruct" ) ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Q_strcat( text, MAX_TUTORIAL_TEXT,
|
||||
va( "Press %s to destroy this structure\n",
|
||||
CG_KeyNameForCommand( "deconstruct" ) ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( ps->stats[ STAT_PCLASS ] == PCL_ALIEN_BUILDER0_UPG )
|
||||
{
|
||||
if( ( ps->stats[ STAT_BUILDABLE ] & ~SB_VALID_TOGGLEBIT ) == BA_NONE )
|
||||
{
|
||||
Q_strcat( text, MAX_TUTORIAL_TEXT,
|
||||
va( "Press %s to swipe\n",
|
||||
CG_KeyNameForCommand( "+button5" ) ) );
|
||||
}
|
||||
|
||||
Q_strcat( text, MAX_TUTORIAL_TEXT,
|
||||
va( "Press %s to launch a projectile\n",
|
||||
CG_KeyNameForCommand( "+button2" ) ) );
|
||||
|
||||
Q_strcat( text, MAX_TUTORIAL_TEXT,
|
||||
va( "Press %s to walk on walls\n",
|
||||
CG_KeyNameForCommand( "+movedown" ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
CG_AlienLevel0Text
|
||||
===============
|
||||
*/
|
||||
static void CG_AlienLevel0Text( char *text, playerState_t *ps )
|
||||
{
|
||||
Q_strcat( text, MAX_TUTORIAL_TEXT,
|
||||
"Touch a human to damage it\n" );
|
||||
|
||||
Q_strcat( text, MAX_TUTORIAL_TEXT,
|
||||
va( "Press %s to walk on walls\n",
|
||||
CG_KeyNameForCommand( "+movedown" ) ) );
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
CG_AlienLevel1Text
|
||||
===============
|
||||
*/
|
||||
static void CG_AlienLevel1Text( char *text, playerState_t *ps )
|
||||
{
|
||||
Q_strcat( text, MAX_TUTORIAL_TEXT,
|
||||
"Touch a human to grab it\n" );
|
||||
|
||||
Q_strcat( text, MAX_TUTORIAL_TEXT,
|
||||
va( "Press %s to swipe\n",
|
||||
CG_KeyNameForCommand( "+attack" ) ) );
|
||||
|
||||
if( ps->stats[ STAT_PCLASS ] == PCL_ALIEN_LEVEL1_UPG )
|
||||
{
|
||||
Q_strcat( text, MAX_TUTORIAL_TEXT,
|
||||
va( "Press %s to spray poisonous gas\n",
|
||||
CG_KeyNameForCommand( "+button5" ) ) );
|
||||
}
|
||||
|
||||
Q_strcat( text, MAX_TUTORIAL_TEXT,
|
||||
va( "Press %s to walk on walls\n",
|
||||
CG_KeyNameForCommand( "+movedown" ) ) );
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
CG_AlienLevel2Text
|
||||
===============
|
||||
*/
|
||||
static void CG_AlienLevel2Text( char *text, playerState_t *ps )
|
||||
{
|
||||
Q_strcat( text, MAX_TUTORIAL_TEXT,
|
||||
va( "Press %s to bite\n",
|
||||
CG_KeyNameForCommand( "+attack" ) ) );
|
||||
|
||||
if( ps->stats[ STAT_PCLASS ] == PCL_ALIEN_LEVEL2_UPG )
|
||||
{
|
||||
Q_strcat( text, MAX_TUTORIAL_TEXT,
|
||||
va( "Press %s to invoke an electrical attack\n",
|
||||
CG_KeyNameForCommand( "+button5" ) ) );
|
||||
}
|
||||
|
||||
Q_strcat( text, MAX_TUTORIAL_TEXT,
|
||||
va( "Hold down %s then touch a wall to wall jump\n",
|
||||
CG_KeyNameForCommand( "+moveup" ) ) );
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
CG_AlienLevel3Text
|
||||
===============
|
||||
*/
|
||||
static void CG_AlienLevel3Text( char *text, playerState_t *ps )
|
||||
{
|
||||
Q_strcat( text, MAX_TUTORIAL_TEXT,
|
||||
va( "Press %s to bite\n",
|
||||
CG_KeyNameForCommand( "+attack" ) ) );
|
||||
|
||||
if( ps->stats[ STAT_PCLASS ] == PCL_ALIEN_LEVEL3_UPG )
|
||||
{
|
||||
Q_strcat( text, MAX_TUTORIAL_TEXT,
|
||||
va( "Press %s to launch a projectile\n",
|
||||
CG_KeyNameForCommand( "+button2" ) ) );
|
||||
}
|
||||
|
||||
Q_strcat( text, MAX_TUTORIAL_TEXT,
|
||||
va( "Hold down and release %s to pounce\n",
|
||||
CG_KeyNameForCommand( "+button5" ) ) );
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
CG_AlienLevel4Text
|
||||
===============
|
||||
*/
|
||||
static void CG_AlienLevel4Text( char *text, playerState_t *ps )
|
||||
{
|
||||
Q_strcat( text, MAX_TUTORIAL_TEXT,
|
||||
va( "Press %s to swipe\n",
|
||||
CG_KeyNameForCommand( "+attack" ) ) );
|
||||
|
||||
Q_strcat( text, MAX_TUTORIAL_TEXT,
|
||||
va( "Hold down and release %s to charge\n",
|
||||
CG_KeyNameForCommand( "+button5" ) ) );
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
CG_HumanCkitText
|
||||
===============
|
||||
*/
|
||||
static void CG_HumanCkitText( char *text, playerState_t *ps )
|
||||
{
|
||||
buildable_t buildable = ps->stats[ STAT_BUILDABLE ] & ~SB_VALID_TOGGLEBIT;
|
||||
float health;
|
||||
|
||||
if( buildable > BA_NONE )
|
||||
{
|
||||
Q_strcat( text, MAX_TUTORIAL_TEXT,
|
||||
va( "Press %s to place the %s\n",
|
||||
CG_KeyNameForCommand( "+attack" ),
|
||||
BG_FindHumanNameForBuildable( buildable ) ) );
|
||||
|
||||
Q_strcat( text, MAX_TUTORIAL_TEXT,
|
||||
va( "Press %s to cancel placing the %s\n",
|
||||
CG_KeyNameForCommand( "+button5" ),
|
||||
BG_FindHumanNameForBuildable( buildable ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
Q_strcat( text, MAX_TUTORIAL_TEXT,
|
||||
va( "Press %s to build a structure\n",
|
||||
CG_KeyNameForCommand( "+attack" ) ) );
|
||||
|
||||
if( CG_BuildableInRange( ps, &health ) )
|
||||
{
|
||||
if( health < 1.0f )
|
||||
{
|
||||
Q_strcat( text, MAX_TUTORIAL_TEXT,
|
||||
va( "Hold %s to repair this structure\n",
|
||||
CG_KeyNameForCommand( "+button5" ) ) );
|
||||
}
|
||||
|
||||
Q_strcat( text, MAX_TUTORIAL_TEXT,
|
||||
va( "Press %s to destroy this structure\n",
|
||||
CG_KeyNameForCommand( "deconstruct" ) ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
CG_HumanText
|
||||
===============
|
||||
*/
|
||||
static void CG_HumanText( char *text, playerState_t *ps )
|
||||
{
|
||||
char *name;
|
||||
int ammo, clips;
|
||||
upgrade_t upgrade = UP_NONE;
|
||||
|
||||
if( cg.weaponSelect <= 32 )
|
||||
name = cg_weapons[ cg.weaponSelect ].humanName;
|
||||
else if( cg.weaponSelect > 32 )
|
||||
{
|
||||
name = cg_upgrades[ cg.weaponSelect - 32 ].humanName;
|
||||
upgrade = cg.weaponSelect - 32;
|
||||
}
|
||||
|
||||
BG_UnpackAmmoArray( ps->weapon, ps->ammo, ps->powerups, &ammo, &clips );
|
||||
|
||||
if( !ammo && !clips && !BG_FindInfinteAmmoForWeapon( ps->weapon ) )
|
||||
{
|
||||
//no ammo
|
||||
switch( ps->weapon )
|
||||
{
|
||||
case WP_MACHINEGUN:
|
||||
case WP_CHAINGUN:
|
||||
case WP_SHOTGUN:
|
||||
case WP_FLAMER:
|
||||
Q_strcat( text, MAX_TUTORIAL_TEXT,
|
||||
va( "Find an Armoury and press %s for more ammo\n",
|
||||
CG_KeyNameForCommand( "buy ammo" ) ) );
|
||||
break;
|
||||
|
||||
case WP_LAS_GUN:
|
||||
case WP_PULSE_RIFLE:
|
||||
case WP_MASS_DRIVER:
|
||||
case WP_LUCIFER_CANNON:
|
||||
Q_strcat( text, MAX_TUTORIAL_TEXT,
|
||||
va( "Find a Reactor or Repeater and press %s for more ammo\n",
|
||||
CG_KeyNameForCommand( "buy ammo" ) ) );
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch( ps->weapon )
|
||||
{
|
||||
case WP_BLASTER:
|
||||
case WP_MACHINEGUN:
|
||||
case WP_SHOTGUN:
|
||||
case WP_LAS_GUN:
|
||||
case WP_CHAINGUN:
|
||||
case WP_PULSE_RIFLE:
|
||||
case WP_FLAMER:
|
||||
Q_strcat( text, MAX_TUTORIAL_TEXT,
|
||||
va( "Press %s to fire the %s\n",
|
||||
CG_KeyNameForCommand( "+attack" ),
|
||||
BG_FindHumanNameForWeapon( ps->weapon ) ) );
|
||||
break;
|
||||
|
||||
case WP_MASS_DRIVER:
|
||||
Q_strcat( text, MAX_TUTORIAL_TEXT,
|
||||
va( "Press %s to fire the %s\n",
|
||||
CG_KeyNameForCommand( "+attack" ),
|
||||
BG_FindHumanNameForWeapon( ps->weapon ) ) );
|
||||
|
||||
Q_strcat( text, MAX_TUTORIAL_TEXT,
|
||||
va( "Hold %s to zoom\n",
|
||||
CG_KeyNameForCommand( "+button5" ) ) );
|
||||
break;
|
||||
|
||||
case WP_PAIN_SAW:
|
||||
Q_strcat( text, MAX_TUTORIAL_TEXT,
|
||||
va( "Hold %s to activate the %s\n",
|
||||
CG_KeyNameForCommand( "+attack" ),
|
||||
BG_FindHumanNameForWeapon( ps->weapon ) ) );
|
||||
break;
|
||||
|
||||
case WP_LUCIFER_CANNON:
|
||||
Q_strcat( text, MAX_TUTORIAL_TEXT,
|
||||
va( "Hold and release %s to fire a charged shot\n",
|
||||
CG_KeyNameForCommand( "+attack" ) ) );
|
||||
|
||||
Q_strcat( text, MAX_TUTORIAL_TEXT,
|
||||
va( "Press %s to fire the %s\n",
|
||||
CG_KeyNameForCommand( "+button5" ),
|
||||
BG_FindHumanNameForWeapon( ps->weapon ) ) );
|
||||
break;
|
||||
|
||||
case WP_HBUILD:
|
||||
case WP_HBUILD2:
|
||||
CG_HumanCkitText( text, ps );
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Q_strcat( text, MAX_TUTORIAL_TEXT,
|
||||
va( "Press %s and ",
|
||||
CG_KeyNameForCommand( "weapprev" ) ) );
|
||||
Q_strcat( text, MAX_TUTORIAL_TEXT,
|
||||
va( "%s to select an upgrade\n",
|
||||
CG_KeyNameForCommand( "weapnext" ) ) );
|
||||
|
||||
if( upgrade == UP_NONE ||
|
||||
( upgrade > UP_NONE && BG_FindUsableForUpgrade( upgrade ) ) )
|
||||
{
|
||||
Q_strcat( text, MAX_TUTORIAL_TEXT,
|
||||
va( "Press %s to use the %s\n",
|
||||
CG_KeyNameForCommand( "+button2" ),
|
||||
name ) );
|
||||
}
|
||||
|
||||
if( ps->stats[ STAT_HEALTH ] <= 35 &&
|
||||
BG_InventoryContainsUpgrade( UP_MEDKIT, ps->stats ) )
|
||||
{
|
||||
Q_strcat( text, MAX_TUTORIAL_TEXT,
|
||||
va( "Press %s to use your %s\n",
|
||||
CG_KeyNameForCommand( "itemact medkit" ),
|
||||
BG_FindHumanNameForUpgrade( UP_MEDKIT ) ) );
|
||||
}
|
||||
|
||||
Q_strcat( text, MAX_TUTORIAL_TEXT,
|
||||
va( "Press %s to use a structure\n",
|
||||
CG_KeyNameForCommand( "+button7" ) ) );
|
||||
|
||||
Q_strcat( text, MAX_TUTORIAL_TEXT,
|
||||
va( "Press %s to sprint\n",
|
||||
CG_KeyNameForCommand( "boost" ) ) );
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
CG_SpectatorText
|
||||
===============
|
||||
*/
|
||||
static void CG_SpectatorText( char *text, playerState_t *ps )
|
||||
{
|
||||
if( ps->pm_flags & PMF_FOLLOW )
|
||||
{
|
||||
Q_strcat( text, MAX_TUTORIAL_TEXT,
|
||||
va( "Press %s to return to free spectator mode\n",
|
||||
CG_KeyNameForCommand( "+button2" ) ) );
|
||||
|
||||
if( CG_PlayerCount( ) > 1 )
|
||||
{
|
||||
Q_strcat( text, MAX_TUTORIAL_TEXT,
|
||||
va( "Press %s or ",
|
||||
CG_KeyNameForCommand( "weapprev" ) ) );
|
||||
Q_strcat( text, MAX_TUTORIAL_TEXT,
|
||||
va( "%s to change player\n",
|
||||
CG_KeyNameForCommand( "weapnext" ) ) );
|
||||
}
|
||||
}
|
||||
else if( ps->pm_type == PM_SPECTATOR )
|
||||
{
|
||||
Q_strcat( text, MAX_TUTORIAL_TEXT,
|
||||
va( "Press %s to join a team\n",
|
||||
CG_KeyNameForCommand( "+attack" ) ) );
|
||||
|
||||
if( CG_PlayerCount( ) > 0 )
|
||||
{
|
||||
Q_strcat( text, MAX_TUTORIAL_TEXT,
|
||||
va( "Press %s to enter spectator follow mode\n",
|
||||
CG_KeyNameForCommand( "+button2" ) ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Q_strcat( text, MAX_TUTORIAL_TEXT,
|
||||
va( "Press %s to spawn\n",
|
||||
CG_KeyNameForCommand( "+attack" ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
CG_TutorialText
|
||||
|
||||
Returns context help for the current class/weapon
|
||||
===============
|
||||
*/
|
||||
const char *CG_TutorialText( void )
|
||||
{
|
||||
playerState_t *ps;
|
||||
static char text[ MAX_TUTORIAL_TEXT ];
|
||||
|
||||
CG_GetBindings( );
|
||||
|
||||
text[ 0 ] = '\0';
|
||||
ps = &cg.snap->ps;
|
||||
|
||||
if( !cg.intermissionStarted && !cg.demoPlayback )
|
||||
{
|
||||
if( ps->persistant[ PERS_TEAM ] == TEAM_SPECTATOR ||
|
||||
ps->pm_flags & PMF_FOLLOW )
|
||||
{
|
||||
CG_SpectatorText( text, ps );
|
||||
}
|
||||
else if( ps->stats[ STAT_HEALTH ] > 0 )
|
||||
{
|
||||
switch( ps->stats[ STAT_PCLASS ] )
|
||||
{
|
||||
case PCL_ALIEN_BUILDER0:
|
||||
case PCL_ALIEN_BUILDER0_UPG:
|
||||
CG_AlienBuilderText( text, ps );
|
||||
break;
|
||||
|
||||
case PCL_ALIEN_LEVEL0:
|
||||
CG_AlienLevel0Text( text, ps );
|
||||
break;
|
||||
|
||||
case PCL_ALIEN_LEVEL1:
|
||||
case PCL_ALIEN_LEVEL1_UPG:
|
||||
CG_AlienLevel1Text( text, ps );
|
||||
break;
|
||||
|
||||
case PCL_ALIEN_LEVEL2:
|
||||
case PCL_ALIEN_LEVEL2_UPG:
|
||||
CG_AlienLevel2Text( text, ps );
|
||||
break;
|
||||
|
||||
case PCL_ALIEN_LEVEL3:
|
||||
case PCL_ALIEN_LEVEL3_UPG:
|
||||
CG_AlienLevel3Text( text, ps );
|
||||
break;
|
||||
|
||||
case PCL_ALIEN_LEVEL4:
|
||||
CG_AlienLevel4Text( text, ps );
|
||||
break;
|
||||
|
||||
case PCL_HUMAN:
|
||||
CG_HumanText( text, ps );
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if( ps->stats[ STAT_PTEAM ] == PTE_ALIENS )
|
||||
{
|
||||
entityState_t *es = CG_BuildableInRange( ps, NULL );
|
||||
|
||||
if( ps->stats[ STAT_STATE ] & SS_HOVELING )
|
||||
{
|
||||
Q_strcat( text, MAX_TUTORIAL_TEXT,
|
||||
va( "Press %s to exit the hovel\n",
|
||||
CG_KeyNameForCommand( "+button7" ) ) );
|
||||
}
|
||||
else if( es && es->modelindex == BA_A_HOVEL &&
|
||||
es->generic1 & B_SPAWNED_TOGGLEBIT &&
|
||||
( ps->stats[ STAT_PCLASS ] == PCL_ALIEN_BUILDER0 ||
|
||||
ps->stats[ STAT_PCLASS ] == PCL_ALIEN_BUILDER0_UPG ) )
|
||||
{
|
||||
Q_strcat( text, MAX_TUTORIAL_TEXT,
|
||||
va( "Press %s to enter the hovel\n",
|
||||
CG_KeyNameForCommand( "+button7" ) ) );
|
||||
}
|
||||
else if( BG_UpgradeClassAvailable( ps ) )
|
||||
{
|
||||
Q_strcat( text, MAX_TUTORIAL_TEXT,
|
||||
va( "Press %s to evolve\n",
|
||||
CG_KeyNameForCommand( "+button7" ) ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Q_strcat( text, MAX_TUTORIAL_TEXT, "Press ESC for the menu" );
|
||||
}
|
||||
|
||||
return text;
|
||||
}
|
||||
-1340
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -1,664 +0,0 @@
|
||||
/*
|
||||
===========================================================================
|
||||
Copyright (C) 2005-2006 Tim Angus
|
||||
|
||||
This file is part of Tremulous.
|
||||
|
||||
Tremulous is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
Tremulous is distributed in the hope that it will be
|
||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Tremulous; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
===========================================================================
|
||||
*/
|
||||
|
||||
#include "client.h"
|
||||
#include "snd_local.h"
|
||||
|
||||
#define INDEX_FILE_EXTENSION ".index.dat"
|
||||
|
||||
#define MAX_RIFF_CHUNKS 16
|
||||
|
||||
typedef struct audioFormat_s
|
||||
{
|
||||
int rate;
|
||||
int format;
|
||||
int channels;
|
||||
int bits;
|
||||
|
||||
int sampleSize;
|
||||
int totalBytes;
|
||||
} audioFormat_t;
|
||||
|
||||
typedef struct aviFileData_s
|
||||
{
|
||||
qboolean fileOpen;
|
||||
fileHandle_t f;
|
||||
char fileName[ MAX_QPATH ];
|
||||
int fileSize;
|
||||
int moviOffset;
|
||||
int moviSize;
|
||||
|
||||
fileHandle_t idxF;
|
||||
int numIndices;
|
||||
|
||||
int frameRate;
|
||||
int framePeriod;
|
||||
int width, height;
|
||||
int numVideoFrames;
|
||||
int maxRecordSize;
|
||||
qboolean motionJpeg;
|
||||
|
||||
qboolean audio;
|
||||
audioFormat_t a;
|
||||
int numAudioFrames;
|
||||
|
||||
int chunkStack[ MAX_RIFF_CHUNKS ];
|
||||
int chunkStackTop;
|
||||
|
||||
byte *cBuffer, *eBuffer;
|
||||
} aviFileData_t;
|
||||
|
||||
static aviFileData_t afd;
|
||||
|
||||
#define MAX_AVI_BUFFER 2048
|
||||
|
||||
static byte buffer[ MAX_AVI_BUFFER ];
|
||||
static int bufIndex;
|
||||
|
||||
/*
|
||||
===============
|
||||
SafeFS_Write
|
||||
===============
|
||||
*/
|
||||
static ID_INLINE void SafeFS_Write( const void *buffer, int len, fileHandle_t f )
|
||||
{
|
||||
if( FS_Write( buffer, len, f ) < len )
|
||||
Com_Error( ERR_DROP, "Failed to write avi file\n" );
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
WRITE_STRING
|
||||
===============
|
||||
*/
|
||||
static ID_INLINE void WRITE_STRING( const char *s )
|
||||
{
|
||||
Com_Memcpy( &buffer[ bufIndex ], s, strlen( s ) );
|
||||
bufIndex += strlen( s );
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
WRITE_4BYTES
|
||||
===============
|
||||
*/
|
||||
static ID_INLINE void WRITE_4BYTES( int x )
|
||||
{
|
||||
buffer[ bufIndex + 0 ] = (byte)( ( x >> 0 ) & 0xFF );
|
||||
buffer[ bufIndex + 1 ] = (byte)( ( x >> 8 ) & 0xFF );
|
||||
buffer[ bufIndex + 2 ] = (byte)( ( x >> 16 ) & 0xFF );
|
||||
buffer[ bufIndex + 3 ] = (byte)( ( x >> 24 ) & 0xFF );
|
||||
bufIndex += 4;
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
WRITE_2BYTES
|
||||
===============
|
||||
*/
|
||||
static ID_INLINE void WRITE_2BYTES( int x )
|
||||
{
|
||||
buffer[ bufIndex + 0 ] = (byte)( ( x >> 0 ) & 0xFF );
|
||||
buffer[ bufIndex + 1 ] = (byte)( ( x >> 8 ) & 0xFF );
|
||||
bufIndex += 2;
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
WRITE_1BYTES
|
||||
===============
|
||||
*/
|
||||
static ID_INLINE void WRITE_1BYTES( int x )
|
||||
{
|
||||
buffer[ bufIndex ] = x;
|
||||
bufIndex += 1;
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
START_CHUNK
|
||||
===============
|
||||
*/
|
||||
static ID_INLINE void START_CHUNK( const char *s )
|
||||
{
|
||||
if( afd.chunkStackTop == MAX_RIFF_CHUNKS )
|
||||
{
|
||||
Com_Error( ERR_DROP, "ERROR: Top of chunkstack breached\n" );
|
||||
}
|
||||
|
||||
afd.chunkStack[ afd.chunkStackTop ] = bufIndex;
|
||||
afd.chunkStackTop++;
|
||||
WRITE_STRING( s );
|
||||
WRITE_4BYTES( 0 );
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
END_CHUNK
|
||||
===============
|
||||
*/
|
||||
static ID_INLINE void END_CHUNK( void )
|
||||
{
|
||||
int endIndex = bufIndex;
|
||||
|
||||
if( afd.chunkStackTop <= 0 )
|
||||
{
|
||||
Com_Error( ERR_DROP, "ERROR: Bottom of chunkstack breached\n" );
|
||||
}
|
||||
|
||||
afd.chunkStackTop--;
|
||||
bufIndex = afd.chunkStack[ afd.chunkStackTop ];
|
||||
bufIndex += 4;
|
||||
WRITE_4BYTES( endIndex - bufIndex - 4 );
|
||||
bufIndex = endIndex;
|
||||
bufIndex = PAD( bufIndex, 2 );
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
CL_WriteAVIHeader
|
||||
===============
|
||||
*/
|
||||
void CL_WriteAVIHeader( void )
|
||||
{
|
||||
bufIndex = 0;
|
||||
afd.chunkStackTop = 0;
|
||||
|
||||
START_CHUNK( "RIFF" );
|
||||
{
|
||||
WRITE_STRING( "AVI " );
|
||||
{
|
||||
START_CHUNK( "LIST" );
|
||||
{
|
||||
WRITE_STRING( "hdrl" );
|
||||
WRITE_STRING( "avih" );
|
||||
WRITE_4BYTES( 56 ); //"avih" "chunk" size
|
||||
WRITE_4BYTES( afd.framePeriod ); //dwMicroSecPerFrame
|
||||
WRITE_4BYTES( afd.maxRecordSize *
|
||||
afd.frameRate ); //dwMaxBytesPerSec
|
||||
WRITE_4BYTES( 0 ); //dwReserved1
|
||||
WRITE_4BYTES( 0x110 ); //dwFlags bits HAS_INDEX and IS_INTERLEAVED
|
||||
WRITE_4BYTES( afd.numVideoFrames ); //dwTotalFrames
|
||||
WRITE_4BYTES( 0 ); //dwInitialFrame
|
||||
|
||||
if( afd.audio ) //dwStreams
|
||||
WRITE_4BYTES( 2 );
|
||||
else
|
||||
WRITE_4BYTES( 1 );
|
||||
|
||||
WRITE_4BYTES( afd.maxRecordSize ); //dwSuggestedBufferSize
|
||||
WRITE_4BYTES( afd.width ); //dwWidth
|
||||
WRITE_4BYTES( afd.height ); //dwHeight
|
||||
WRITE_4BYTES( 0 ); //dwReserved[ 0 ]
|
||||
WRITE_4BYTES( 0 ); //dwReserved[ 1 ]
|
||||
WRITE_4BYTES( 0 ); //dwReserved[ 2 ]
|
||||
WRITE_4BYTES( 0 ); //dwReserved[ 3 ]
|
||||
|
||||
START_CHUNK( "LIST" );
|
||||
{
|
||||
WRITE_STRING( "strl" );
|
||||
WRITE_STRING( "strh" );
|
||||
WRITE_4BYTES( 56 ); //"strh" "chunk" size
|
||||
WRITE_STRING( "vids" );
|
||||
|
||||
if( afd.motionJpeg )
|
||||
WRITE_STRING( "MJPG" );
|
||||
else
|
||||
WRITE_4BYTES( 0 ); // BI_RGB
|
||||
|
||||
WRITE_4BYTES( 0 ); //dwFlags
|
||||
WRITE_4BYTES( 0 ); //dwPriority
|
||||
WRITE_4BYTES( 0 ); //dwInitialFrame
|
||||
|
||||
WRITE_4BYTES( 1 ); //dwTimescale
|
||||
WRITE_4BYTES( afd.frameRate ); //dwDataRate
|
||||
WRITE_4BYTES( 0 ); //dwStartTime
|
||||
WRITE_4BYTES( afd.numVideoFrames ); //dwDataLength
|
||||
|
||||
WRITE_4BYTES( afd.maxRecordSize ); //dwSuggestedBufferSize
|
||||
WRITE_4BYTES( -1 ); //dwQuality
|
||||
WRITE_4BYTES( 0 ); //dwSampleSize
|
||||
WRITE_2BYTES( 0 ); //rcFrame
|
||||
WRITE_2BYTES( 0 ); //rcFrame
|
||||
WRITE_2BYTES( afd.width ); //rcFrame
|
||||
WRITE_2BYTES( afd.height ); //rcFrame
|
||||
|
||||
WRITE_STRING( "strf" );
|
||||
WRITE_4BYTES( 40 ); //"strf" "chunk" size
|
||||
WRITE_4BYTES( 40 ); //biSize
|
||||
WRITE_4BYTES( afd.width ); //biWidth
|
||||
WRITE_4BYTES( afd.height ); //biHeight
|
||||
WRITE_2BYTES( 1 ); //biPlanes
|
||||
WRITE_2BYTES( 24 ); //biBitCount
|
||||
|
||||
if( afd.motionJpeg ) { //biCompression
|
||||
WRITE_STRING( "MJPG" );
|
||||
WRITE_4BYTES( afd.width *
|
||||
afd.height ); //biSizeImage
|
||||
} else {
|
||||
WRITE_4BYTES( 0 ); // BI_RGB
|
||||
WRITE_4BYTES( afd.width *
|
||||
afd.height*3 ); //biSizeImage
|
||||
}
|
||||
|
||||
WRITE_4BYTES( 0 ); //biXPelsPetMeter
|
||||
WRITE_4BYTES( 0 ); //biYPelsPetMeter
|
||||
WRITE_4BYTES( 0 ); //biClrUsed
|
||||
WRITE_4BYTES( 0 ); //biClrImportant
|
||||
}
|
||||
END_CHUNK( );
|
||||
|
||||
if( afd.audio )
|
||||
{
|
||||
START_CHUNK( "LIST" );
|
||||
{
|
||||
WRITE_STRING( "strl" );
|
||||
WRITE_STRING( "strh" );
|
||||
WRITE_4BYTES( 56 ); //"strh" "chunk" size
|
||||
WRITE_STRING( "auds" );
|
||||
WRITE_4BYTES( 0 ); //FCC
|
||||
WRITE_4BYTES( 0 ); //dwFlags
|
||||
WRITE_4BYTES( 0 ); //dwPriority
|
||||
WRITE_4BYTES( 0 ); //dwInitialFrame
|
||||
|
||||
WRITE_4BYTES( afd.a.sampleSize ); //dwTimescale
|
||||
WRITE_4BYTES( afd.a.sampleSize *
|
||||
afd.a.rate ); //dwDataRate
|
||||
WRITE_4BYTES( 0 ); //dwStartTime
|
||||
WRITE_4BYTES( afd.a.totalBytes /
|
||||
afd.a.sampleSize ); //dwDataLength
|
||||
|
||||
WRITE_4BYTES( 0 ); //dwSuggestedBufferSize
|
||||
WRITE_4BYTES( -1 ); //dwQuality
|
||||
WRITE_4BYTES( afd.a.sampleSize ); //dwSampleSize
|
||||
WRITE_2BYTES( 0 ); //rcFrame
|
||||
WRITE_2BYTES( 0 ); //rcFrame
|
||||
WRITE_2BYTES( 0 ); //rcFrame
|
||||
WRITE_2BYTES( 0 ); //rcFrame
|
||||
|
||||
WRITE_STRING( "strf" );
|
||||
WRITE_4BYTES( 18 ); //"strf" "chunk" size
|
||||
WRITE_2BYTES( afd.a.format ); //wFormatTag
|
||||
WRITE_2BYTES( afd.a.channels ); //nChannels
|
||||
WRITE_4BYTES( afd.a.rate ); //nSamplesPerSec
|
||||
WRITE_4BYTES( afd.a.sampleSize *
|
||||
afd.a.rate ); //nAvgBytesPerSec
|
||||
WRITE_2BYTES( afd.a.sampleSize ); //nBlockAlign
|
||||
WRITE_2BYTES( afd.a.bits ); //wBitsPerSample
|
||||
WRITE_2BYTES( 0 ); //cbSize
|
||||
}
|
||||
END_CHUNK( );
|
||||
}
|
||||
}
|
||||
END_CHUNK( );
|
||||
|
||||
afd.moviOffset = bufIndex;
|
||||
|
||||
START_CHUNK( "LIST" );
|
||||
{
|
||||
WRITE_STRING( "movi" );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
CL_OpenAVIForWriting
|
||||
|
||||
Creates an AVI file and gets it into a state where
|
||||
writing the actual data can begin
|
||||
===============
|
||||
*/
|
||||
qboolean CL_OpenAVIForWriting( const char *fileName )
|
||||
{
|
||||
if( afd.fileOpen )
|
||||
return qfalse;
|
||||
|
||||
Com_Memset( &afd, 0, sizeof( aviFileData_t ) );
|
||||
|
||||
// Don't start if a framerate has not been chosen
|
||||
if( cl_aviFrameRate->integer <= 0 )
|
||||
{
|
||||
Com_Printf( S_COLOR_RED "cl_aviFrameRate must be >= 1\n" );
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
if( ( afd.f = FS_FOpenFileWrite( fileName ) ) <= 0 )
|
||||
return qfalse;
|
||||
|
||||
if( ( afd.idxF = FS_FOpenFileWrite(
|
||||
va( "%s" INDEX_FILE_EXTENSION, fileName ) ) ) <= 0 )
|
||||
{
|
||||
FS_FCloseFile( afd.f );
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
Q_strncpyz( afd.fileName, fileName, MAX_QPATH );
|
||||
|
||||
afd.frameRate = cl_aviFrameRate->integer;
|
||||
afd.framePeriod = (int)( 1000000.0f / afd.frameRate );
|
||||
afd.width = cls.glconfig.vidWidth;
|
||||
afd.height = cls.glconfig.vidHeight;
|
||||
|
||||
if( cl_aviMotionJpeg->integer )
|
||||
afd.motionJpeg = qtrue;
|
||||
else
|
||||
afd.motionJpeg = qfalse;
|
||||
|
||||
afd.cBuffer = Z_Malloc( afd.width * afd.height * 4 );
|
||||
afd.eBuffer = Z_Malloc( afd.width * afd.height * 4 );
|
||||
|
||||
afd.a.rate = dma.speed;
|
||||
afd.a.format = WAV_FORMAT_PCM;
|
||||
afd.a.channels = dma.channels;
|
||||
afd.a.bits = dma.samplebits;
|
||||
afd.a.sampleSize = ( afd.a.bits / 8 ) * afd.a.channels;
|
||||
|
||||
if( afd.a.rate % afd.frameRate )
|
||||
{
|
||||
int suggestRate = afd.frameRate;
|
||||
|
||||
while( ( afd.a.rate % suggestRate ) && suggestRate >= 1 )
|
||||
suggestRate--;
|
||||
|
||||
Com_Printf( S_COLOR_YELLOW "WARNING: cl_aviFrameRate is not a divisor "
|
||||
"of the audio rate, suggest %d\n", suggestRate );
|
||||
}
|
||||
|
||||
if( !Cvar_VariableIntegerValue( "s_initsound" ) )
|
||||
{
|
||||
afd.audio = qfalse;
|
||||
}
|
||||
else if( Q_stricmp( Cvar_VariableString( "s_backend" ), "OpenAL" ) )
|
||||
{
|
||||
if( afd.a.bits == 16 && afd.a.channels == 2 )
|
||||
afd.audio = qtrue;
|
||||
else
|
||||
afd.audio = qfalse; //FIXME: audio not implemented for this case
|
||||
}
|
||||
else
|
||||
{
|
||||
afd.audio = qfalse;
|
||||
Com_Printf( S_COLOR_YELLOW "WARNING: Audio capture is not supported "
|
||||
"with OpenAL. Set s_useOpenAL to 0 for audio capture\n" );
|
||||
}
|
||||
|
||||
// This doesn't write a real header, but allocates the
|
||||
// correct amount of space at the beginning of the file
|
||||
CL_WriteAVIHeader( );
|
||||
|
||||
SafeFS_Write( buffer, bufIndex, afd.f );
|
||||
afd.fileSize = bufIndex;
|
||||
|
||||
bufIndex = 0;
|
||||
START_CHUNK( "idx1" );
|
||||
SafeFS_Write( buffer, bufIndex, afd.idxF );
|
||||
|
||||
afd.moviSize = 4; // For the "movi"
|
||||
afd.fileOpen = qtrue;
|
||||
|
||||
return qtrue;
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
CL_CheckFileSize
|
||||
===============
|
||||
*/
|
||||
static qboolean CL_CheckFileSize( int bytesToAdd )
|
||||
{
|
||||
unsigned int newFileSize;
|
||||
|
||||
newFileSize =
|
||||
afd.fileSize + // Current file size
|
||||
bytesToAdd + // What we want to add
|
||||
( afd.numIndices * 16 ) + // The index
|
||||
4; // The index size
|
||||
|
||||
// I assume all the operating systems
|
||||
// we target can handle a 2Gb file
|
||||
if( newFileSize > INT_MAX )
|
||||
{
|
||||
// Close the current file...
|
||||
CL_CloseAVI( );
|
||||
|
||||
// ...And open a new one
|
||||
CL_OpenAVIForWriting( va( "%s_", afd.fileName ) );
|
||||
|
||||
return qtrue;
|
||||
}
|
||||
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
CL_WriteAVIVideoFrame
|
||||
===============
|
||||
*/
|
||||
void CL_WriteAVIVideoFrame( const byte *imageBuffer, int size )
|
||||
{
|
||||
int chunkOffset = afd.fileSize - afd.moviOffset - 8;
|
||||
int chunkSize = 8 + size;
|
||||
int paddingSize = PAD( size, 2 ) - size;
|
||||
byte padding[ 4 ] = { 0 };
|
||||
|
||||
if( !afd.fileOpen )
|
||||
return;
|
||||
|
||||
// Chunk header + contents + padding
|
||||
if( CL_CheckFileSize( 8 + size + 2 ) )
|
||||
return;
|
||||
|
||||
bufIndex = 0;
|
||||
WRITE_STRING( "00dc" );
|
||||
WRITE_4BYTES( size );
|
||||
|
||||
SafeFS_Write( buffer, 8, afd.f );
|
||||
SafeFS_Write( imageBuffer, size, afd.f );
|
||||
SafeFS_Write( padding, paddingSize, afd.f );
|
||||
afd.fileSize += ( chunkSize + paddingSize );
|
||||
|
||||
afd.numVideoFrames++;
|
||||
afd.moviSize += ( chunkSize + paddingSize );
|
||||
|
||||
if( size > afd.maxRecordSize )
|
||||
afd.maxRecordSize = size;
|
||||
|
||||
// Index
|
||||
bufIndex = 0;
|
||||
WRITE_STRING( "00dc" ); //dwIdentifier
|
||||
WRITE_4BYTES( 0x00000010 ); //dwFlags (all frames are KeyFrames)
|
||||
WRITE_4BYTES( chunkOffset ); //dwOffset
|
||||
WRITE_4BYTES( size ); //dwLength
|
||||
SafeFS_Write( buffer, 16, afd.idxF );
|
||||
|
||||
afd.numIndices++;
|
||||
}
|
||||
|
||||
#define PCM_BUFFER_SIZE 44100
|
||||
|
||||
/*
|
||||
===============
|
||||
CL_WriteAVIAudioFrame
|
||||
===============
|
||||
*/
|
||||
void CL_WriteAVIAudioFrame( const byte *pcmBuffer, int size )
|
||||
{
|
||||
static byte pcmCaptureBuffer[ PCM_BUFFER_SIZE ] = { 0 };
|
||||
static int bytesInBuffer = 0;
|
||||
|
||||
if( !afd.audio )
|
||||
return;
|
||||
|
||||
if( !afd.fileOpen )
|
||||
return;
|
||||
|
||||
// Chunk header + contents + padding
|
||||
if( CL_CheckFileSize( 8 + bytesInBuffer + size + 2 ) )
|
||||
return;
|
||||
|
||||
if( bytesInBuffer + size > PCM_BUFFER_SIZE )
|
||||
{
|
||||
Com_Printf( S_COLOR_YELLOW
|
||||
"WARNING: Audio capture buffer overflow -- truncating\n" );
|
||||
size = PCM_BUFFER_SIZE - bytesInBuffer;
|
||||
}
|
||||
|
||||
Com_Memcpy( &pcmCaptureBuffer[ bytesInBuffer ], pcmBuffer, size );
|
||||
bytesInBuffer += size;
|
||||
|
||||
// Only write if we have a frame's worth of audio
|
||||
if( bytesInBuffer >= (int)ceil( (float)afd.a.rate / (float)afd.frameRate ) *
|
||||
afd.a.sampleSize )
|
||||
{
|
||||
int chunkOffset = afd.fileSize - afd.moviOffset - 8;
|
||||
int chunkSize = 8 + bytesInBuffer;
|
||||
int paddingSize = PAD( bytesInBuffer, 2 ) - bytesInBuffer;
|
||||
byte padding[ 4 ] = { 0 };
|
||||
|
||||
bufIndex = 0;
|
||||
WRITE_STRING( "01wb" );
|
||||
WRITE_4BYTES( bytesInBuffer );
|
||||
|
||||
SafeFS_Write( buffer, 8, afd.f );
|
||||
SafeFS_Write( pcmBuffer, bytesInBuffer, afd.f );
|
||||
SafeFS_Write( padding, paddingSize, afd.f );
|
||||
afd.fileSize += ( chunkSize + paddingSize );
|
||||
|
||||
afd.numAudioFrames++;
|
||||
afd.moviSize += ( chunkSize + paddingSize );
|
||||
afd.a.totalBytes =+ bytesInBuffer;
|
||||
|
||||
// Index
|
||||
bufIndex = 0;
|
||||
WRITE_STRING( "01wb" ); //dwIdentifier
|
||||
WRITE_4BYTES( 0 ); //dwFlags
|
||||
WRITE_4BYTES( chunkOffset ); //dwOffset
|
||||
WRITE_4BYTES( bytesInBuffer ); //dwLength
|
||||
SafeFS_Write( buffer, 16, afd.idxF );
|
||||
|
||||
afd.numIndices++;
|
||||
|
||||
bytesInBuffer = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
CL_TakeVideoFrame
|
||||
===============
|
||||
*/
|
||||
void CL_TakeVideoFrame( void )
|
||||
{
|
||||
// AVI file isn't open
|
||||
if( !afd.fileOpen )
|
||||
return;
|
||||
|
||||
re.TakeVideoFrame( afd.width, afd.height,
|
||||
afd.cBuffer, afd.eBuffer, afd.motionJpeg );
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
CL_CloseAVI
|
||||
|
||||
Closes the AVI file and writes an index chunk
|
||||
===============
|
||||
*/
|
||||
qboolean CL_CloseAVI( void )
|
||||
{
|
||||
int indexRemainder;
|
||||
int indexSize = afd.numIndices * 16;
|
||||
const char *idxFileName = va( "%s" INDEX_FILE_EXTENSION, afd.fileName );
|
||||
|
||||
// AVI file isn't open
|
||||
if( !afd.fileOpen )
|
||||
return qfalse;
|
||||
|
||||
afd.fileOpen = qfalse;
|
||||
|
||||
FS_Seek( afd.idxF, 4, FS_SEEK_SET );
|
||||
bufIndex = 0;
|
||||
WRITE_4BYTES( indexSize );
|
||||
SafeFS_Write( buffer, bufIndex, afd.idxF );
|
||||
FS_FCloseFile( afd.idxF );
|
||||
|
||||
// Write index
|
||||
|
||||
// Open the temp index file
|
||||
if( ( indexSize = FS_FOpenFileRead( idxFileName,
|
||||
&afd.idxF, qtrue ) ) <= 0 )
|
||||
{
|
||||
FS_FCloseFile( afd.f );
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
indexRemainder = indexSize;
|
||||
|
||||
// Append index to end of avi file
|
||||
while( indexRemainder > MAX_AVI_BUFFER )
|
||||
{
|
||||
FS_Read( buffer, MAX_AVI_BUFFER, afd.idxF );
|
||||
SafeFS_Write( buffer, MAX_AVI_BUFFER, afd.f );
|
||||
afd.fileSize += MAX_AVI_BUFFER;
|
||||
indexRemainder -= MAX_AVI_BUFFER;
|
||||
}
|
||||
FS_Read( buffer, indexRemainder, afd.idxF );
|
||||
SafeFS_Write( buffer, indexRemainder, afd.f );
|
||||
afd.fileSize += indexRemainder;
|
||||
FS_FCloseFile( afd.idxF );
|
||||
|
||||
// Remove temp index file
|
||||
FS_HomeRemove( idxFileName );
|
||||
|
||||
// Write the real header
|
||||
FS_Seek( afd.f, 0, FS_SEEK_SET );
|
||||
CL_WriteAVIHeader( );
|
||||
|
||||
bufIndex = 4;
|
||||
WRITE_4BYTES( afd.fileSize - 8 ); // "RIFF" size
|
||||
|
||||
bufIndex = afd.moviOffset + 4; // Skip "LIST"
|
||||
WRITE_4BYTES( afd.moviSize );
|
||||
|
||||
SafeFS_Write( buffer, bufIndex, afd.f );
|
||||
|
||||
Z_Free( afd.cBuffer );
|
||||
Z_Free( afd.eBuffer );
|
||||
FS_FCloseFile( afd.f );
|
||||
|
||||
Com_Printf( "Wrote %d:%d frames to %s\n", afd.numVideoFrames, afd.numAudioFrames, afd.fileName );
|
||||
|
||||
return qtrue;
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
CL_VideoRecording
|
||||
===============
|
||||
*/
|
||||
qboolean CL_VideoRecording( void )
|
||||
{
|
||||
return afd.fileOpen;
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
-1658
File diff suppressed because it is too large.
Load diff
@@ -1,701 +0,0 @@
|
||||
/*
|
||||
===========================================================================
|
||||
Copyright (C) 1999-2005 Id Software, Inc.
|
||||
Copyright (C) 2000-2006 Tim Angus
|
||||
|
||||
This file is part of Tremulous.
|
||||
|
||||
Tremulous is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
Tremulous is distributed in the hope that it will be
|
||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Tremulous; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
===========================================================================
|
||||
*/
|
||||
// console.c
|
||||
|
||||
#include "client.h"
|
||||
|
||||
|
||||
int g_console_field_width = 78;
|
||||
|
||||
|
||||
#define NUM_CON_TIMES 4
|
||||
|
||||
#define CON_TEXTSIZE 32768
|
||||
typedef struct {
|
||||
qboolean initialized;
|
||||
|
||||
short text[CON_TEXTSIZE];
|
||||
int current; // line where next message will be printed
|
||||
int x; // offset in current line for next print
|
||||
int display; // bottom of console displays this line
|
||||
|
||||
int linewidth; // characters across screen
|
||||
int totallines; // total lines in console scrollback
|
||||
|
||||
float xadjust; // for wide aspect screens
|
||||
|
||||
float displayFrac; // aproaches finalFrac at scr_conspeed
|
||||
float finalFrac; // 0.0 to 1.0 lines of console to display
|
||||
|
||||
int vislines; // in scanlines
|
||||
|
||||
vec4_t color;
|
||||
} console_t;
|
||||
|
||||
extern console_t con;
|
||||
|
||||
console_t con;
|
||||
|
||||
cvar_t *con_conspeed;
|
||||
|
||||
#define DEFAULT_CONSOLE_WIDTH 78
|
||||
|
||||
vec4_t console_color = {1.0, 1.0, 1.0, 1.0};
|
||||
|
||||
|
||||
/*
|
||||
================
|
||||
Con_ToggleConsole_f
|
||||
================
|
||||
*/
|
||||
void Con_ToggleConsole_f (void) {
|
||||
// closing a full screen console restarts the demo loop
|
||||
if ( cls.state == CA_DISCONNECTED && cls.keyCatchers == KEYCATCH_CONSOLE ) {
|
||||
CL_StartDemoLoop();
|
||||
return;
|
||||
}
|
||||
|
||||
Field_Clear( &g_consoleField );
|
||||
g_consoleField.widthInChars = g_console_field_width;
|
||||
|
||||
cls.keyCatchers ^= KEYCATCH_CONSOLE;
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
Con_MessageMode_f
|
||||
================
|
||||
*/
|
||||
void Con_MessageMode_f (void) {
|
||||
chat_playerNum = -1;
|
||||
chat_team = qfalse;
|
||||
Field_Clear( &chatField );
|
||||
chatField.widthInChars = 30;
|
||||
|
||||
cls.keyCatchers ^= KEYCATCH_MESSAGE;
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
Con_MessageMode2_f
|
||||
================
|
||||
*/
|
||||
void Con_MessageMode2_f (void) {
|
||||
chat_playerNum = -1;
|
||||
chat_team = qtrue;
|
||||
Field_Clear( &chatField );
|
||||
chatField.widthInChars = 25;
|
||||
cls.keyCatchers ^= KEYCATCH_MESSAGE;
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
Con_MessageMode3_f
|
||||
================
|
||||
*/
|
||||
void Con_MessageMode3_f (void) {
|
||||
chat_playerNum = VM_Call( cgvm, CG_CROSSHAIR_PLAYER );
|
||||
if ( chat_playerNum < 0 || chat_playerNum >= MAX_CLIENTS ) {
|
||||
chat_playerNum = -1;
|
||||
return;
|
||||
}
|
||||
chat_team = qfalse;
|
||||
Field_Clear( &chatField );
|
||||
chatField.widthInChars = 30;
|
||||
cls.keyCatchers ^= KEYCATCH_MESSAGE;
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
Con_MessageMode4_f
|
||||
================
|
||||
*/
|
||||
void Con_MessageMode4_f (void) {
|
||||
chat_playerNum = VM_Call( cgvm, CG_LAST_ATTACKER );
|
||||
if ( chat_playerNum < 0 || chat_playerNum >= MAX_CLIENTS ) {
|
||||
chat_playerNum = -1;
|
||||
return;
|
||||
}
|
||||
chat_team = qfalse;
|
||||
Field_Clear( &chatField );
|
||||
chatField.widthInChars = 30;
|
||||
cls.keyCatchers ^= KEYCATCH_MESSAGE;
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
Con_Clear_f
|
||||
================
|
||||
*/
|
||||
void Con_Clear_f (void) {
|
||||
int i;
|
||||
|
||||
for ( i = 0 ; i < CON_TEXTSIZE ; i++ ) {
|
||||
con.text[i] = (ColorIndex(COLOR_WHITE)<<8) | ' ';
|
||||
}
|
||||
|
||||
Con_Bottom(); // go to end
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
================
|
||||
Con_Dump_f
|
||||
|
||||
Save the console contents out to a file
|
||||
================
|
||||
*/
|
||||
void Con_Dump_f (void)
|
||||
{
|
||||
int l, x, i;
|
||||
short *line;
|
||||
fileHandle_t f;
|
||||
char buffer[1024];
|
||||
|
||||
if (Cmd_Argc() != 2)
|
||||
{
|
||||
Com_Printf ("usage: condump <filename>\n");
|
||||
return;
|
||||
}
|
||||
|
||||
Com_Printf ("Dumped console text to %s.\n", Cmd_Argv(1) );
|
||||
|
||||
f = FS_FOpenFileWrite( Cmd_Argv( 1 ) );
|
||||
if (!f)
|
||||
{
|
||||
Com_Printf ("ERROR: couldn't open.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
// skip empty lines
|
||||
for (l = con.current - con.totallines + 1 ; l <= con.current ; l++)
|
||||
{
|
||||
line = con.text + (l%con.totallines)*con.linewidth;
|
||||
for (x=0 ; x<con.linewidth ; x++)
|
||||
if ((line[x] & 0xff) != ' ')
|
||||
break;
|
||||
if (x != con.linewidth)
|
||||
break;
|
||||
}
|
||||
|
||||
// write the remaining lines
|
||||
buffer[con.linewidth] = 0;
|
||||
for ( ; l <= con.current ; l++)
|
||||
{
|
||||
line = con.text + (l%con.totallines)*con.linewidth;
|
||||
for(i=0; i<con.linewidth; i++)
|
||||
buffer[i] = line[i] & 0xff;
|
||||
for (x=con.linewidth-1 ; x>=0 ; x--)
|
||||
{
|
||||
if (buffer[x] == ' ')
|
||||
buffer[x] = 0;
|
||||
else
|
||||
break;
|
||||
}
|
||||
strcat( buffer, "\n" );
|
||||
FS_Write(buffer, strlen(buffer), f);
|
||||
}
|
||||
|
||||
FS_FCloseFile( f );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
================
|
||||
Con_ClearNotify
|
||||
================
|
||||
*/
|
||||
void Con_ClearNotify( void ) {
|
||||
Cmd_TokenizeString( NULL );
|
||||
CL_GameConsoleText( );
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
================
|
||||
Con_CheckResize
|
||||
|
||||
If the line width has changed, reformat the buffer.
|
||||
================
|
||||
*/
|
||||
void Con_CheckResize (void)
|
||||
{
|
||||
int i, j, width, oldwidth, oldtotallines, numlines, numchars;
|
||||
short tbuf[CON_TEXTSIZE];
|
||||
|
||||
width = (SCREEN_WIDTH / SMALLCHAR_WIDTH) - 2;
|
||||
|
||||
if (width == con.linewidth)
|
||||
return;
|
||||
|
||||
if (width < 1) // video hasn't been initialized yet
|
||||
{
|
||||
width = DEFAULT_CONSOLE_WIDTH;
|
||||
con.linewidth = width;
|
||||
con.totallines = CON_TEXTSIZE / con.linewidth;
|
||||
for(i=0; i<CON_TEXTSIZE; i++)
|
||||
|
||||
con.text[i] = (ColorIndex(COLOR_WHITE)<<8) | ' ';
|
||||
}
|
||||
else
|
||||
{
|
||||
oldwidth = con.linewidth;
|
||||
con.linewidth = width;
|
||||
oldtotallines = con.totallines;
|
||||
con.totallines = CON_TEXTSIZE / con.linewidth;
|
||||
numlines = oldtotallines;
|
||||
|
||||
if (con.totallines < numlines)
|
||||
numlines = con.totallines;
|
||||
|
||||
numchars = oldwidth;
|
||||
|
||||
if (con.linewidth < numchars)
|
||||
numchars = con.linewidth;
|
||||
|
||||
Com_Memcpy (tbuf, con.text, CON_TEXTSIZE * sizeof(short));
|
||||
for(i=0; i<CON_TEXTSIZE; i++)
|
||||
|
||||
con.text[i] = (ColorIndex(COLOR_WHITE)<<8) | ' ';
|
||||
|
||||
|
||||
for (i=0 ; i<numlines ; i++)
|
||||
{
|
||||
for (j=0 ; j<numchars ; j++)
|
||||
{
|
||||
con.text[(con.totallines - 1 - i) * con.linewidth + j] =
|
||||
tbuf[((con.current - i + oldtotallines) %
|
||||
oldtotallines) * oldwidth + j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
con.current = con.totallines - 1;
|
||||
con.display = con.current;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
================
|
||||
Con_Init
|
||||
================
|
||||
*/
|
||||
void Con_Init (void) {
|
||||
int i;
|
||||
|
||||
con_conspeed = Cvar_Get ("scr_conspeed", "3", 0);
|
||||
|
||||
Field_Clear( &g_consoleField );
|
||||
g_consoleField.widthInChars = g_console_field_width;
|
||||
for ( i = 0 ; i < COMMAND_HISTORY ; i++ ) {
|
||||
Field_Clear( &historyEditLines[i] );
|
||||
historyEditLines[i].widthInChars = g_console_field_width;
|
||||
}
|
||||
CL_LoadConsoleHistory( );
|
||||
|
||||
Cmd_AddCommand ("toggleconsole", Con_ToggleConsole_f);
|
||||
Cmd_AddCommand ("messagemode", Con_MessageMode_f);
|
||||
Cmd_AddCommand ("messagemode2", Con_MessageMode2_f);
|
||||
Cmd_AddCommand ("messagemode3", Con_MessageMode3_f);
|
||||
Cmd_AddCommand ("messagemode4", Con_MessageMode4_f);
|
||||
Cmd_AddCommand ("clear", Con_Clear_f);
|
||||
Cmd_AddCommand ("condump", Con_Dump_f);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
===============
|
||||
Con_Linefeed
|
||||
===============
|
||||
*/
|
||||
void Con_Linefeed (qboolean skipnotify)
|
||||
{
|
||||
int i;
|
||||
|
||||
con.x = 0;
|
||||
if (con.display == con.current)
|
||||
con.display++;
|
||||
con.current++;
|
||||
for(i=0; i<con.linewidth; i++)
|
||||
con.text[(con.current%con.totallines)*con.linewidth+i] = (ColorIndex(COLOR_WHITE)<<8) | ' ';
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
CL_ConsolePrint
|
||||
|
||||
Handles cursor positioning, line wrapping, etc
|
||||
All console printing must go through this in order to be logged to disk
|
||||
If no console is visible, the text will appear at the top of the game window
|
||||
================
|
||||
*/
|
||||
void CL_ConsolePrint( char *txt ) {
|
||||
int y;
|
||||
int c, l;
|
||||
int color;
|
||||
qboolean skipnotify = qfalse; // NERVE - SMF
|
||||
|
||||
// TTimo - prefix for text that shows up in console but not in notify
|
||||
// backported from RTCW
|
||||
if ( !Q_strncmp( txt, "[skipnotify]", 12 ) ) {
|
||||
skipnotify = qtrue;
|
||||
txt += 12;
|
||||
}
|
||||
|
||||
// for some demos we don't want to ever show anything on the console
|
||||
if ( cl_noprint && cl_noprint->integer ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!con.initialized) {
|
||||
con.color[0] =
|
||||
con.color[1] =
|
||||
con.color[2] =
|
||||
con.color[3] = 1.0f;
|
||||
con.linewidth = -1;
|
||||
Con_CheckResize ();
|
||||
con.initialized = qtrue;
|
||||
}
|
||||
|
||||
if( !skipnotify && !( cls.keyCatchers & KEYCATCH_CONSOLE ) ) {
|
||||
Cmd_SaveCmdContext( );
|
||||
|
||||
// feed the text to cgame
|
||||
Cmd_TokenizeString( txt );
|
||||
CL_GameConsoleText( );
|
||||
|
||||
Cmd_RestoreCmdContext( );
|
||||
}
|
||||
|
||||
color = ColorIndex(COLOR_WHITE);
|
||||
|
||||
while ( (c = *txt) != 0 ) {
|
||||
if ( Q_IsColorString( txt ) ) {
|
||||
color = ColorIndex( *(txt+1) );
|
||||
txt += 2;
|
||||
continue;
|
||||
}
|
||||
|
||||
// count word length
|
||||
for (l=0 ; l< con.linewidth ; l++) {
|
||||
if ( txt[l] <= ' ') {
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// word wrap
|
||||
if (l != con.linewidth && (con.x + l >= con.linewidth) ) {
|
||||
Con_Linefeed(skipnotify);
|
||||
|
||||
}
|
||||
|
||||
txt++;
|
||||
|
||||
switch (c)
|
||||
{
|
||||
case '\n':
|
||||
Con_Linefeed (skipnotify);
|
||||
break;
|
||||
case '\r':
|
||||
con.x = 0;
|
||||
break;
|
||||
default: // display character and advance
|
||||
y = con.current % con.totallines;
|
||||
con.text[y*con.linewidth+con.x] = (color << 8) | c;
|
||||
con.x++;
|
||||
if (con.x >= con.linewidth) {
|
||||
Con_Linefeed(skipnotify);
|
||||
con.x = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
DRAWING
|
||||
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
================
|
||||
Con_DrawInput
|
||||
|
||||
Draw the editline after a ] prompt
|
||||
================
|
||||
*/
|
||||
void Con_DrawInput (void) {
|
||||
int y;
|
||||
|
||||
if ( cls.state != CA_DISCONNECTED && !(cls.keyCatchers & KEYCATCH_CONSOLE ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
y = con.vislines - ( SMALLCHAR_HEIGHT * 2 );
|
||||
|
||||
re.SetColor( con.color );
|
||||
|
||||
SCR_DrawSmallChar( con.xadjust + 1 * SMALLCHAR_WIDTH, y, ']' );
|
||||
|
||||
Field_Draw( &g_consoleField, con.xadjust + 2 * SMALLCHAR_WIDTH, y,
|
||||
SCREEN_WIDTH - 3 * SMALLCHAR_WIDTH, qtrue );
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
Con_DrawSolidConsole
|
||||
|
||||
Draws the console with the solid background
|
||||
================
|
||||
*/
|
||||
void Con_DrawSolidConsole( float frac ) {
|
||||
int i, x, y;
|
||||
int rows;
|
||||
short *text;
|
||||
int row;
|
||||
int lines;
|
||||
// qhandle_t conShader;
|
||||
int currentColor;
|
||||
vec4_t color;
|
||||
|
||||
lines = cls.glconfig.vidHeight * frac;
|
||||
if (lines <= 0)
|
||||
return;
|
||||
|
||||
if (lines > cls.glconfig.vidHeight )
|
||||
lines = cls.glconfig.vidHeight;
|
||||
|
||||
// on wide screens, we will center the text
|
||||
con.xadjust = 0;
|
||||
SCR_AdjustFrom640( &con.xadjust, NULL, NULL, NULL );
|
||||
|
||||
// draw the background
|
||||
y = frac * SCREEN_HEIGHT - 2;
|
||||
if ( y < 1 ) {
|
||||
y = 0;
|
||||
}
|
||||
else {
|
||||
SCR_DrawPic( 0, 0, SCREEN_WIDTH, y, cls.consoleShader );
|
||||
}
|
||||
|
||||
color[0] = 1;
|
||||
color[1] = 0;
|
||||
color[2] = 0;
|
||||
color[3] = 1;
|
||||
SCR_FillRect( 0, y, SCREEN_WIDTH, 2, color );
|
||||
|
||||
|
||||
// draw the version number
|
||||
|
||||
re.SetColor( g_color_table[ColorIndex(COLOR_RED)] );
|
||||
|
||||
i = strlen( SVN_VERSION );
|
||||
|
||||
for (x=0 ; x<i ; x++) {
|
||||
|
||||
SCR_DrawSmallChar( cls.glconfig.vidWidth - ( i - x ) * SMALLCHAR_WIDTH,
|
||||
|
||||
(lines-(SMALLCHAR_HEIGHT+SMALLCHAR_HEIGHT/2)), SVN_VERSION[x] );
|
||||
|
||||
}
|
||||
|
||||
|
||||
// draw the text
|
||||
con.vislines = lines;
|
||||
rows = (lines-SMALLCHAR_WIDTH)/SMALLCHAR_WIDTH; // rows of text to draw
|
||||
|
||||
y = lines - (SMALLCHAR_HEIGHT*3);
|
||||
|
||||
// draw from the bottom up
|
||||
if (con.display != con.current)
|
||||
{
|
||||
// draw arrows to show the buffer is backscrolled
|
||||
re.SetColor( g_color_table[ColorIndex(COLOR_RED)] );
|
||||
for (x=0 ; x<con.linewidth ; x+=4)
|
||||
SCR_DrawSmallChar( con.xadjust + (x+1)*SMALLCHAR_WIDTH, y, '^' );
|
||||
y -= SMALLCHAR_HEIGHT;
|
||||
rows--;
|
||||
}
|
||||
|
||||
row = con.display;
|
||||
|
||||
if ( con.x == 0 ) {
|
||||
row--;
|
||||
}
|
||||
|
||||
currentColor = 7;
|
||||
re.SetColor( g_color_table[currentColor] );
|
||||
|
||||
for (i=0 ; i<rows ; i++, y -= SMALLCHAR_HEIGHT, row--)
|
||||
{
|
||||
if (row < 0)
|
||||
break;
|
||||
if (con.current - row >= con.totallines) {
|
||||
// past scrollback wrap point
|
||||
continue;
|
||||
}
|
||||
|
||||
text = con.text + (row % con.totallines)*con.linewidth;
|
||||
|
||||
for (x=0 ; x<con.linewidth ; x++) {
|
||||
if ( ( text[x] & 0xff ) == ' ' ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( ( (text[x]>>8)&7 ) != currentColor ) {
|
||||
currentColor = (text[x]>>8)&7;
|
||||
re.SetColor( g_color_table[currentColor] );
|
||||
}
|
||||
SCR_DrawSmallChar( con.xadjust + (x+1)*SMALLCHAR_WIDTH, y, text[x] & 0xff );
|
||||
}
|
||||
}
|
||||
|
||||
// draw the input prompt, user text, and cursor if desired
|
||||
Con_DrawInput ();
|
||||
|
||||
re.SetColor( NULL );
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
==================
|
||||
Con_DrawConsole
|
||||
==================
|
||||
*/
|
||||
void Con_DrawConsole( void ) {
|
||||
// check for console width changes from a vid mode change
|
||||
Con_CheckResize ();
|
||||
|
||||
// if disconnected, render console full screen
|
||||
if ( cls.state == CA_DISCONNECTED ) {
|
||||
if ( !( cls.keyCatchers & (KEYCATCH_UI | KEYCATCH_CGAME)) ) {
|
||||
Con_DrawSolidConsole( 1.0 );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if ( con.displayFrac ) {
|
||||
Con_DrawSolidConsole( con.displayFrac );
|
||||
}
|
||||
|
||||
if( cls.keyCatchers & ( KEYCATCH_UI | KEYCATCH_CGAME ) )
|
||||
return;
|
||||
|
||||
// draw the chat line
|
||||
if( cls.keyCatchers & KEYCATCH_MESSAGE )
|
||||
{
|
||||
int skip;
|
||||
|
||||
if( chat_team )
|
||||
{
|
||||
SCR_DrawBigString( 8, 232, "Team Say:", 1.0f );
|
||||
skip = 11;
|
||||
}
|
||||
else
|
||||
{
|
||||
SCR_DrawBigString( 8, 232, "Say:", 1.0f );
|
||||
skip = 5;
|
||||
}
|
||||
|
||||
Field_BigDraw( &chatField, skip * BIGCHAR_WIDTH, 232,
|
||||
SCREEN_WIDTH - ( skip + 1 ) * BIGCHAR_WIDTH, qtrue );
|
||||
}
|
||||
}
|
||||
|
||||
//================================================================
|
||||
|
||||
/*
|
||||
==================
|
||||
Con_RunConsole
|
||||
|
||||
Scroll it up or down
|
||||
==================
|
||||
*/
|
||||
void Con_RunConsole (void) {
|
||||
// decide on the destination height of the console
|
||||
if ( cls.keyCatchers & KEYCATCH_CONSOLE )
|
||||
con.finalFrac = 0.5; // half screen
|
||||
else
|
||||
con.finalFrac = 0; // none visible
|
||||
|
||||
// scroll towards the destination height
|
||||
if (con.finalFrac < con.displayFrac)
|
||||
{
|
||||
con.displayFrac -= con_conspeed->value*cls.realFrametime*0.001;
|
||||
if (con.finalFrac > con.displayFrac)
|
||||
con.displayFrac = con.finalFrac;
|
||||
|
||||
}
|
||||
else if (con.finalFrac > con.displayFrac)
|
||||
{
|
||||
con.displayFrac += con_conspeed->value*cls.realFrametime*0.001;
|
||||
if (con.finalFrac < con.displayFrac)
|
||||
con.displayFrac = con.finalFrac;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void Con_PageUp( void ) {
|
||||
con.display -= 2;
|
||||
if ( con.current - con.display >= con.totallines ) {
|
||||
con.display = con.current - con.totallines + 1;
|
||||
}
|
||||
}
|
||||
|
||||
void Con_PageDown( void ) {
|
||||
con.display += 2;
|
||||
if (con.display > con.current) {
|
||||
con.display = con.current;
|
||||
}
|
||||
}
|
||||
|
||||
void Con_Top( void ) {
|
||||
con.display = con.totallines;
|
||||
if ( con.current - con.display >= con.totallines ) {
|
||||
con.display = con.current - con.totallines + 1;
|
||||
}
|
||||
}
|
||||
|
||||
void Con_Bottom( void ) {
|
||||
con.display = con.current;
|
||||
}
|
||||
|
||||
|
||||
void Con_Close( void ) {
|
||||
if ( !com_cl_running->integer ) {
|
||||
return;
|
||||
}
|
||||
Field_Clear( &g_consoleField );
|
||||
cls.keyCatchers &= ~KEYCATCH_CONSOLE;
|
||||
con.finalFrac = 0; // none visible
|
||||
con.displayFrac = 0;
|
||||
}
|
||||
@@ -1,360 +0,0 @@
|
||||
/*
|
||||
===========================================================================
|
||||
Copyright (C) 2006 Tony J. White (tjw@tjw.org)
|
||||
|
||||
This file is part of Tremulous.
|
||||
|
||||
Tremulous is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
Tremulous is distributed in the hope that it will be
|
||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Tremulous; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
===========================================================================
|
||||
*/
|
||||
|
||||
#if USE_CURL
|
||||
#include "client.h"
|
||||
cvar_t *cl_cURLLib;
|
||||
|
||||
#if USE_CURL_DLOPEN
|
||||
|
||||
#if USE_SDL_VIDEO
|
||||
#include "SDL.h"
|
||||
#include "SDL_loadso.h"
|
||||
#define OBJTYPE void *
|
||||
#define OBJLOAD(x) SDL_LoadObject(x)
|
||||
#define SYMLOAD(x,y) SDL_LoadFunction(x,y)
|
||||
#define OBJFREE(x) SDL_UnloadObject(x)
|
||||
|
||||
#elif defined _WIN32
|
||||
#include <windows.h>
|
||||
#define OBJTYPE HMODULE
|
||||
#define OBJLOAD(x) LoadLibrary(x)
|
||||
#define SYMLOAD(x,y) GetProcAddress(x,y)
|
||||
#define OBJFREE(x) FreeLibrary(x)
|
||||
|
||||
#elif defined __linux__ || defined __FreeBSD__ || defined MACOS_X || defined __sun
|
||||
#include <dlfcn.h>
|
||||
#define OBJTYPE void *
|
||||
#define OBJLOAD(x) dlopen(x, RTLD_LAZY | RTLD_GLOBAL)
|
||||
#define SYMLOAD(x,y) dlsym(x,y)
|
||||
#define OBJFREE(x) dlclose(x)
|
||||
#else
|
||||
|
||||
#error "Your platform has no lib loading code or it is disabled"
|
||||
#endif
|
||||
|
||||
#if defined __linux__ || defined __FreeBSD__ || defined MACOS_X
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
|
||||
char* (*qcurl_version)(void);
|
||||
|
||||
CURL* (*qcurl_easy_init)(void);
|
||||
CURLcode (*qcurl_easy_setopt)(CURL *curl, CURLoption option, ...);
|
||||
CURLcode (*qcurl_easy_perform)(CURL *curl);
|
||||
void (*qcurl_easy_cleanup)(CURL *curl);
|
||||
CURLcode (*qcurl_easy_getinfo)(CURL *curl, CURLINFO info, ...);
|
||||
CURL* (*qcurl_easy_duphandle)(CURL *curl);
|
||||
void (*qcurl_easy_reset)(CURL *curl);
|
||||
const char *(*qcurl_easy_strerror)(CURLcode);
|
||||
|
||||
CURLM* (*qcurl_multi_init)(void);
|
||||
CURLMcode (*qcurl_multi_add_handle)(CURLM *multi_handle,
|
||||
CURL *curl_handle);
|
||||
CURLMcode (*qcurl_multi_remove_handle)(CURLM *multi_handle,
|
||||
CURL *curl_handle);
|
||||
CURLMcode (*qcurl_multi_fdset)(CURLM *multi_handle,
|
||||
fd_set *read_fd_set,
|
||||
fd_set *write_fd_set,
|
||||
fd_set *exc_fd_set,
|
||||
int *max_fd);
|
||||
CURLMcode (*qcurl_multi_perform)(CURLM *multi_handle,
|
||||
int *running_handles);
|
||||
CURLMcode (*qcurl_multi_cleanup)(CURLM *multi_handle);
|
||||
CURLMsg *(*qcurl_multi_info_read)(CURLM *multi_handle,
|
||||
int *msgs_in_queue);
|
||||
const char *(*qcurl_multi_strerror)(CURLMcode);
|
||||
|
||||
static OBJTYPE cURLLib = NULL;
|
||||
|
||||
/*
|
||||
=================
|
||||
GPA
|
||||
=================
|
||||
*/
|
||||
static void *GPA(char *str)
|
||||
{
|
||||
void *rv;
|
||||
|
||||
rv = SYMLOAD(cURLLib, str);
|
||||
if(!rv)
|
||||
{
|
||||
Com_Printf("Can't load symbol %s\n", str);
|
||||
clc.cURLEnabled = qfalse;
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
Com_DPrintf("Loaded symbol %s (0x%p)\n", str, rv);
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
#endif /* USE_CURL_DLOPEN */
|
||||
|
||||
/*
|
||||
=================
|
||||
CL_cURL_Init
|
||||
=================
|
||||
*/
|
||||
qboolean CL_cURL_Init()
|
||||
{
|
||||
#if USE_CURL_DLOPEN
|
||||
if(cURLLib)
|
||||
return qtrue;
|
||||
|
||||
|
||||
Com_Printf("Loading \"%s\"...", cl_cURLLib->string);
|
||||
if( (cURLLib = OBJLOAD(cl_cURLLib->string)) == 0 )
|
||||
{
|
||||
#ifdef _WIN32
|
||||
return qfalse;
|
||||
#else
|
||||
char fn[1024];
|
||||
getcwd(fn, sizeof(fn));
|
||||
strncat(fn, "/", sizeof(fn)-strlen(fn)-1);
|
||||
strncat(fn, cl_cURLLib->string, sizeof(fn)-strlen(fn)-1);
|
||||
|
||||
if( (cURLLib = OBJLOAD(fn)) == 0 )
|
||||
{
|
||||
return qfalse;
|
||||
}
|
||||
#endif /* _WIN32 */
|
||||
}
|
||||
|
||||
clc.cURLEnabled = qtrue;
|
||||
|
||||
qcurl_version = GPA("curl_version");
|
||||
|
||||
qcurl_easy_init = GPA("curl_easy_init");
|
||||
qcurl_easy_setopt = GPA("curl_easy_setopt");
|
||||
qcurl_easy_perform = GPA("curl_easy_perform");
|
||||
qcurl_easy_cleanup = GPA("curl_easy_cleanup");
|
||||
qcurl_easy_getinfo = GPA("curl_easy_getinfo");
|
||||
qcurl_easy_duphandle = GPA("curl_easy_duphandle");
|
||||
qcurl_easy_reset = GPA("curl_easy_reset");
|
||||
qcurl_easy_strerror = GPA("curl_easy_strerror");
|
||||
|
||||
qcurl_multi_init = GPA("curl_multi_init");
|
||||
qcurl_multi_add_handle = GPA("curl_multi_add_handle");
|
||||
qcurl_multi_remove_handle = GPA("curl_multi_remove_handle");
|
||||
qcurl_multi_fdset = GPA("curl_multi_fdset");
|
||||
qcurl_multi_perform = GPA("curl_multi_perform");
|
||||
qcurl_multi_cleanup = GPA("curl_multi_cleanup");
|
||||
qcurl_multi_info_read = GPA("curl_multi_info_read");
|
||||
qcurl_multi_strerror = GPA("curl_multi_strerror");
|
||||
|
||||
if(!clc.cURLEnabled)
|
||||
{
|
||||
CL_cURL_Shutdown();
|
||||
Com_Printf("FAIL One or more symbols not found\n");
|
||||
return qfalse;
|
||||
}
|
||||
Com_Printf("OK\n");
|
||||
|
||||
return qtrue;
|
||||
#else
|
||||
clc.cURLEnabled = qtrue;
|
||||
return qtrue;
|
||||
#endif /* USE_CURL_DLOPEN */
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
CL_cURL_Shutdown
|
||||
=================
|
||||
*/
|
||||
void CL_cURL_Shutdown( void )
|
||||
{
|
||||
CL_cURL_Cleanup();
|
||||
#if USE_CURL_DLOPEN
|
||||
if(cURLLib)
|
||||
{
|
||||
OBJFREE(cURLLib);
|
||||
cURLLib = NULL;
|
||||
}
|
||||
qcurl_easy_init = NULL;
|
||||
qcurl_easy_setopt = NULL;
|
||||
qcurl_easy_perform = NULL;
|
||||
qcurl_easy_cleanup = NULL;
|
||||
qcurl_easy_getinfo = NULL;
|
||||
qcurl_easy_duphandle = NULL;
|
||||
qcurl_easy_reset = NULL;
|
||||
|
||||
qcurl_multi_init = NULL;
|
||||
qcurl_multi_add_handle = NULL;
|
||||
qcurl_multi_remove_handle = NULL;
|
||||
qcurl_multi_fdset = NULL;
|
||||
qcurl_multi_perform = NULL;
|
||||
qcurl_multi_cleanup = NULL;
|
||||
qcurl_multi_info_read = NULL;
|
||||
qcurl_multi_strerror = NULL;
|
||||
#endif /* USE_CURL_DLOPEN */
|
||||
}
|
||||
|
||||
void CL_cURL_Cleanup(void)
|
||||
{
|
||||
if(clc.downloadCURLM) {
|
||||
if(clc.downloadCURL) {
|
||||
qcurl_multi_remove_handle(clc.downloadCURLM,
|
||||
clc.downloadCURL);
|
||||
qcurl_easy_cleanup(clc.downloadCURL);
|
||||
}
|
||||
qcurl_multi_cleanup(clc.downloadCURLM);
|
||||
clc.downloadCURLM = NULL;
|
||||
clc.downloadCURL = NULL;
|
||||
}
|
||||
else if(clc.downloadCURL) {
|
||||
qcurl_easy_cleanup(clc.downloadCURL);
|
||||
clc.downloadCURL = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static int CL_cURL_CallbackProgress( void *dummy, double dltotal, double dlnow,
|
||||
double ultotal, double ulnow )
|
||||
{
|
||||
clc.downloadSize = (int)dltotal;
|
||||
Cvar_SetValue( "cl_downloadSize", clc.downloadSize );
|
||||
clc.downloadCount = (int)dlnow;
|
||||
Cvar_SetValue( "cl_downloadCount", clc.downloadCount );
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int CL_cURL_CallbackWrite(void *buffer, size_t size, size_t nmemb,
|
||||
void *stream)
|
||||
{
|
||||
FS_Write( buffer, size*nmemb, ((fileHandle_t*)stream)[0] );
|
||||
return size*nmemb;
|
||||
}
|
||||
|
||||
void CL_cURL_BeginDownload( const char *localName, const char *remoteURL )
|
||||
{
|
||||
clc.cURLUsed = qtrue;
|
||||
Com_Printf("URL: %s\n", remoteURL);
|
||||
Com_DPrintf("***** CL_cURL_BeginDownload *****\n"
|
||||
"Localname: %s\n"
|
||||
"RemoteURL: %s\n"
|
||||
"****************************\n", localName, remoteURL);
|
||||
CL_cURL_Cleanup();
|
||||
Q_strncpyz(clc.downloadURL, remoteURL, sizeof(clc.downloadURL));
|
||||
Q_strncpyz(clc.downloadName, localName, sizeof(clc.downloadName));
|
||||
Com_sprintf(clc.downloadTempName, sizeof(clc.downloadTempName),
|
||||
"%s.tmp", localName);
|
||||
|
||||
// Set so UI gets access to it
|
||||
Cvar_Set("cl_downloadName", localName);
|
||||
Cvar_Set("cl_downloadSize", "0");
|
||||
Cvar_Set("cl_downloadCount", "0");
|
||||
Cvar_SetValue("cl_downloadTime", cls.realtime);
|
||||
|
||||
clc.downloadBlock = 0; // Starting new file
|
||||
clc.downloadCount = 0;
|
||||
|
||||
clc.downloadCURL = qcurl_easy_init();
|
||||
if(!clc.downloadCURL) {
|
||||
Com_Error(ERR_DROP, "CL_cURL_BeginDownload: qcurl_easy_init() "
|
||||
"failed\n");
|
||||
return;
|
||||
}
|
||||
clc.download = FS_SV_FOpenFileWrite(clc.downloadTempName);
|
||||
if(!clc.download) {
|
||||
Com_Error(ERR_DROP, "CL_cURL_BeginDownload: failed to open "
|
||||
"%s for writing\n", clc.downloadTempName);
|
||||
return;
|
||||
}
|
||||
qcurl_easy_setopt(clc.downloadCURL, CURLOPT_WRITEDATA, clc.download);
|
||||
if(com_developer->integer)
|
||||
qcurl_easy_setopt(clc.downloadCURL, CURLOPT_VERBOSE, 1);
|
||||
qcurl_easy_setopt(clc.downloadCURL, CURLOPT_URL, clc.downloadURL);
|
||||
qcurl_easy_setopt(clc.downloadCURL, CURLOPT_TRANSFERTEXT, 0);
|
||||
qcurl_easy_setopt(clc.downloadCURL, CURLOPT_REFERER, va("ioQ3://%s",
|
||||
NET_AdrToString(clc.serverAddress)));
|
||||
qcurl_easy_setopt(clc.downloadCURL, CURLOPT_USERAGENT, va("%s %s",
|
||||
Q3_VERSION, qcurl_version()));
|
||||
qcurl_easy_setopt(clc.downloadCURL, CURLOPT_WRITEFUNCTION,
|
||||
CL_cURL_CallbackWrite);
|
||||
qcurl_easy_setopt(clc.downloadCURL, CURLOPT_WRITEDATA, &clc.download);
|
||||
qcurl_easy_setopt(clc.downloadCURL, CURLOPT_NOPROGRESS, 0);
|
||||
qcurl_easy_setopt(clc.downloadCURL, CURLOPT_PROGRESSFUNCTION,
|
||||
CL_cURL_CallbackProgress);
|
||||
qcurl_easy_setopt(clc.downloadCURL, CURLOPT_PROGRESSDATA, NULL);
|
||||
qcurl_easy_setopt(clc.downloadCURL, CURLOPT_FAILONERROR, 1);
|
||||
qcurl_easy_setopt(clc.downloadCURL, CURLOPT_FOLLOWLOCATION, 1);
|
||||
qcurl_easy_setopt(clc.downloadCURL, CURLOPT_MAXREDIRS, 5);
|
||||
clc.downloadCURLM = qcurl_multi_init();
|
||||
if(!clc.downloadCURLM) {
|
||||
qcurl_easy_cleanup(clc.downloadCURL);
|
||||
clc.downloadCURL = NULL;
|
||||
Com_Error(ERR_DROP, "CL_cURL_BeginDownload: qcurl_multi_init() "
|
||||
"failed\n");
|
||||
return;
|
||||
}
|
||||
qcurl_multi_add_handle(clc.downloadCURLM, clc.downloadCURL);
|
||||
|
||||
if(!(clc.sv_allowDownload & DLF_NO_DISCONNECT) &&
|
||||
!clc.cURLDisconnected) {
|
||||
|
||||
CL_AddReliableCommand("disconnect");
|
||||
CL_WritePacket();
|
||||
CL_WritePacket();
|
||||
CL_WritePacket();
|
||||
clc.cURLDisconnected = qtrue;
|
||||
}
|
||||
}
|
||||
|
||||
void CL_cURL_PerformDownload(void)
|
||||
{
|
||||
CURLMcode res;
|
||||
CURLMsg *msg;
|
||||
int c;
|
||||
int i = 0;
|
||||
|
||||
res = qcurl_multi_perform(clc.downloadCURLM, &c);
|
||||
while(res == CURLM_CALL_MULTI_PERFORM && i < 100) {
|
||||
res = qcurl_multi_perform(clc.downloadCURLM, &c);
|
||||
i++;
|
||||
}
|
||||
if(res == CURLM_CALL_MULTI_PERFORM)
|
||||
return;
|
||||
msg = qcurl_multi_info_read(clc.downloadCURLM, &c);
|
||||
if(msg == NULL) {
|
||||
return;
|
||||
}
|
||||
FS_FCloseFile(clc.download);
|
||||
if(msg->msg == CURLMSG_DONE && msg->data.result == CURLE_OK) {
|
||||
FS_SV_Rename(clc.downloadTempName, clc.downloadName);
|
||||
clc.downloadRestart = qtrue;
|
||||
}
|
||||
else {
|
||||
long code;
|
||||
|
||||
qcurl_easy_getinfo(msg->easy_handle, CURLINFO_RESPONSE_CODE,
|
||||
&code);
|
||||
Com_Error(ERR_DROP, "Download Error: %s Code: %ld URL: %s",
|
||||
qcurl_easy_strerror(msg->data.result),
|
||||
code, clc.downloadURL);
|
||||
}
|
||||
*clc.downloadTempName = *clc.downloadName = 0;
|
||||
Cvar_Set( "cl_downloadName", "" );
|
||||
CL_NextDownload();
|
||||
}
|
||||
#endif /* USE_CURL */
|
||||
@@ -1,101 +0,0 @@
|
||||
/*
|
||||
===========================================================================
|
||||
Copyright (C) 2006 Tony J. White (tjw@tjw.org)
|
||||
|
||||
This file is part of Tremulous.
|
||||
|
||||
Tremulous is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
Tremulous is distributed in the hope that it will be
|
||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Tremulous; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
===========================================================================
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __QCURL_H__
|
||||
#define __QCURL_H__
|
||||
|
||||
extern cvar_t *cl_cURLLib;
|
||||
|
||||
#include "../qcommon/q_shared.h"
|
||||
#include "../qcommon/qcommon.h"
|
||||
|
||||
#ifdef WIN32
|
||||
#define DEFAULT_CURL_LIB "libcurl-3.dll"
|
||||
#elif defined(MACOS_X)
|
||||
#define DEFAULT_CURL_LIB "libcurl.dylib"
|
||||
#else
|
||||
#define DEFAULT_CURL_LIB "libcurl.so.3"
|
||||
#endif
|
||||
|
||||
#if USE_LOCAL_HEADERS
|
||||
#include "../libcurl/curl/curl.h"
|
||||
#else
|
||||
#include <curl/curl.h>
|
||||
#endif
|
||||
|
||||
|
||||
#if USE_CURL_DLOPEN
|
||||
extern char* (*qcurl_version)(void);
|
||||
|
||||
extern CURL* (*qcurl_easy_init)(void);
|
||||
extern CURLcode (*qcurl_easy_setopt)(CURL *curl, CURLoption option, ...);
|
||||
extern CURLcode (*qcurl_easy_perform)(CURL *curl);
|
||||
extern void (*qcurl_easy_cleanup)(CURL *curl);
|
||||
extern CURLcode (*qcurl_easy_getinfo)(CURL *curl, CURLINFO info, ...);
|
||||
extern void (*qcurl_easy_reset)(CURL *curl);
|
||||
extern const char *(*qcurl_easy_strerror)(CURLcode);
|
||||
|
||||
extern CURLM* (*qcurl_multi_init)(void);
|
||||
extern CURLMcode (*qcurl_multi_add_handle)(CURLM *multi_handle,
|
||||
CURL *curl_handle);
|
||||
extern CURLMcode (*qcurl_multi_remove_handle)(CURLM *multi_handle,
|
||||
CURL *curl_handle);
|
||||
extern CURLMcode (*qcurl_multi_fdset)(CURLM *multi_handle,
|
||||
fd_set *read_fd_set,
|
||||
fd_set *write_fd_set,
|
||||
fd_set *exc_fd_set,
|
||||
int *max_fd);
|
||||
extern CURLMcode (*qcurl_multi_perform)(CURLM *multi_handle,
|
||||
int *running_handles);
|
||||
extern CURLMcode (*qcurl_multi_cleanup)(CURLM *multi_handle);
|
||||
extern CURLMsg *(*qcurl_multi_info_read)(CURLM *multi_handle,
|
||||
int *msgs_in_queue);
|
||||
extern const char *(*qcurl_multi_strerror)(CURLMcode);
|
||||
#else
|
||||
#define qcurl_version curl_version
|
||||
|
||||
#define qcurl_easy_init curl_easy_init
|
||||
#define qcurl_easy_setopt curl_easy_setopt
|
||||
#define qcurl_easy_perform curl_easy_perform
|
||||
#define qcurl_easy_cleanup curl_easy_cleanup
|
||||
#define qcurl_easy_getinfo curl_easy_getinfo
|
||||
#define qcurl_easy_duphandle curl_easy_duphandle
|
||||
#define qcurl_easy_reset curl_easy_reset
|
||||
#define qcurl_easy_strerror curl_easy_strerror
|
||||
|
||||
#define qcurl_multi_init curl_multi_init
|
||||
#define qcurl_multi_add_handle curl_multi_add_handle
|
||||
#define qcurl_multi_remove_handle curl_multi_remove_handle
|
||||
#define qcurl_multi_fdset curl_multi_fdset
|
||||
#define qcurl_multi_perform curl_multi_perform
|
||||
#define qcurl_multi_cleanup curl_multi_cleanup
|
||||
#define qcurl_multi_info_read curl_multi_info_read
|
||||
#define qcurl_multi_strerror curl_multi_strerror
|
||||
#endif
|
||||
|
||||
qboolean CL_cURL_Init( void );
|
||||
void CL_cURL_Shutdown( void );
|
||||
void CL_cURL_BeginDownload( const char *localName, const char *remoteURL );
|
||||
void CL_cURL_PerformDownload( void );
|
||||
void CL_cURL_Cleanup( void );
|
||||
#endif // __QCURL_H__
|
||||
@@ -1,903 +0,0 @@
|
||||
/*
|
||||
===========================================================================
|
||||
Copyright (C) 1999-2005 Id Software, Inc.
|
||||
Copyright (C) 2000-2006 Tim Angus
|
||||
|
||||
This file is part of Tremulous.
|
||||
|
||||
Tremulous is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
Tremulous is distributed in the hope that it will be
|
||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Tremulous; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
===========================================================================
|
||||
*/
|
||||
// cl.input.c -- builds an intended movement command to send to the server
|
||||
|
||||
#include "client.h"
|
||||
|
||||
unsigned frame_msec;
|
||||
int old_com_frameTime;
|
||||
|
||||
/*
|
||||
===============================================================================
|
||||
|
||||
KEY BUTTONS
|
||||
|
||||
Continuous button event tracking is complicated by the fact that two different
|
||||
input sources (say, mouse button 1 and the control key) can both press the
|
||||
same button, but the button should only be released when both of the
|
||||
pressing key have been released.
|
||||
|
||||
When a key event issues a button command (+forward, +attack, etc), it appends
|
||||
its key number as argv(1) so it can be matched up with the release.
|
||||
|
||||
argv(2) will be set to the time the event happened, which allows exact
|
||||
control even at low framerates when the down and up events may both get qued
|
||||
at the same time.
|
||||
|
||||
===============================================================================
|
||||
*/
|
||||
|
||||
|
||||
kbutton_t in_left, in_right, in_forward, in_back;
|
||||
kbutton_t in_lookup, in_lookdown, in_moveleft, in_moveright;
|
||||
kbutton_t in_strafe, in_speed;
|
||||
kbutton_t in_up, in_down;
|
||||
|
||||
kbutton_t in_buttons[16];
|
||||
|
||||
|
||||
qboolean in_mlooking;
|
||||
|
||||
|
||||
void IN_MLookDown( void ) {
|
||||
in_mlooking = qtrue;
|
||||
}
|
||||
|
||||
void IN_MLookUp( void ) {
|
||||
in_mlooking = qfalse;
|
||||
if ( !cl_freelook->integer ) {
|
||||
IN_CenterView ();
|
||||
}
|
||||
}
|
||||
|
||||
void IN_KeyDown( kbutton_t *b ) {
|
||||
int k;
|
||||
char *c;
|
||||
|
||||
c = Cmd_Argv(1);
|
||||
if ( c[0] ) {
|
||||
k = atoi(c);
|
||||
} else {
|
||||
k = -1; // typed manually at the console for continuous down
|
||||
}
|
||||
|
||||
if ( k == b->down[0] || k == b->down[1] ) {
|
||||
return; // repeating key
|
||||
}
|
||||
|
||||
if ( !b->down[0] ) {
|
||||
b->down[0] = k;
|
||||
} else if ( !b->down[1] ) {
|
||||
b->down[1] = k;
|
||||
} else {
|
||||
Com_Printf ("Three keys down for a button!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if ( b->active ) {
|
||||
return; // still down
|
||||
}
|
||||
|
||||
// save timestamp for partial frame summing
|
||||
c = Cmd_Argv(2);
|
||||
b->downtime = atoi(c);
|
||||
|
||||
b->active = qtrue;
|
||||
b->wasPressed = qtrue;
|
||||
}
|
||||
|
||||
void IN_KeyUp( kbutton_t *b ) {
|
||||
int k;
|
||||
char *c;
|
||||
unsigned uptime;
|
||||
|
||||
c = Cmd_Argv(1);
|
||||
if ( c[0] ) {
|
||||
k = atoi(c);
|
||||
} else {
|
||||
// typed manually at the console, assume for unsticking, so clear all
|
||||
b->down[0] = b->down[1] = 0;
|
||||
b->active = qfalse;
|
||||
return;
|
||||
}
|
||||
|
||||
if ( b->down[0] == k ) {
|
||||
b->down[0] = 0;
|
||||
} else if ( b->down[1] == k ) {
|
||||
b->down[1] = 0;
|
||||
} else {
|
||||
return; // key up without coresponding down (menu pass through)
|
||||
}
|
||||
if ( b->down[0] || b->down[1] ) {
|
||||
return; // some other key is still holding it down
|
||||
}
|
||||
|
||||
b->active = qfalse;
|
||||
|
||||
// save timestamp for partial frame summing
|
||||
c = Cmd_Argv(2);
|
||||
uptime = atoi(c);
|
||||
if ( uptime ) {
|
||||
b->msec += uptime - b->downtime;
|
||||
} else {
|
||||
b->msec += frame_msec / 2;
|
||||
}
|
||||
|
||||
b->active = qfalse;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
===============
|
||||
CL_KeyState
|
||||
|
||||
Returns the fraction of the frame that the key was down
|
||||
===============
|
||||
*/
|
||||
float CL_KeyState( kbutton_t *key ) {
|
||||
float val;
|
||||
int msec;
|
||||
|
||||
msec = key->msec;
|
||||
key->msec = 0;
|
||||
|
||||
if ( key->active ) {
|
||||
// still down
|
||||
if ( !key->downtime ) {
|
||||
msec = com_frameTime;
|
||||
} else {
|
||||
msec += com_frameTime - key->downtime;
|
||||
}
|
||||
key->downtime = com_frameTime;
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (msec) {
|
||||
Com_Printf ("%i ", msec);
|
||||
}
|
||||
#endif
|
||||
|
||||
val = (float)msec / frame_msec;
|
||||
if ( val < 0 ) {
|
||||
val = 0;
|
||||
}
|
||||
if ( val > 1 ) {
|
||||
val = 1;
|
||||
}
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void IN_UpDown(void) {IN_KeyDown(&in_up);}
|
||||
void IN_UpUp(void) {IN_KeyUp(&in_up);}
|
||||
void IN_DownDown(void) {IN_KeyDown(&in_down);}
|
||||
void IN_DownUp(void) {IN_KeyUp(&in_down);}
|
||||
void IN_LeftDown(void) {IN_KeyDown(&in_left);}
|
||||
void IN_LeftUp(void) {IN_KeyUp(&in_left);}
|
||||
void IN_RightDown(void) {IN_KeyDown(&in_right);}
|
||||
void IN_RightUp(void) {IN_KeyUp(&in_right);}
|
||||
void IN_ForwardDown(void) {IN_KeyDown(&in_forward);}
|
||||
void IN_ForwardUp(void) {IN_KeyUp(&in_forward);}
|
||||
void IN_BackDown(void) {IN_KeyDown(&in_back);}
|
||||
void IN_BackUp(void) {IN_KeyUp(&in_back);}
|
||||
void IN_LookupDown(void) {IN_KeyDown(&in_lookup);}
|
||||
void IN_LookupUp(void) {IN_KeyUp(&in_lookup);}
|
||||
void IN_LookdownDown(void) {IN_KeyDown(&in_lookdown);}
|
||||
void IN_LookdownUp(void) {IN_KeyUp(&in_lookdown);}
|
||||
void IN_MoveleftDown(void) {IN_KeyDown(&in_moveleft);}
|
||||
void IN_MoveleftUp(void) {IN_KeyUp(&in_moveleft);}
|
||||
void IN_MoverightDown(void) {IN_KeyDown(&in_moveright);}
|
||||
void IN_MoverightUp(void) {IN_KeyUp(&in_moveright);}
|
||||
|
||||
void IN_SpeedDown(void) {IN_KeyDown(&in_speed);}
|
||||
void IN_SpeedUp(void) {IN_KeyUp(&in_speed);}
|
||||
void IN_StrafeDown(void) {IN_KeyDown(&in_strafe);}
|
||||
void IN_StrafeUp(void) {IN_KeyUp(&in_strafe);}
|
||||
|
||||
void IN_Button0Down(void) {IN_KeyDown(&in_buttons[0]);}
|
||||
void IN_Button0Up(void) {IN_KeyUp(&in_buttons[0]);}
|
||||
void IN_Button1Down(void) {IN_KeyDown(&in_buttons[1]);}
|
||||
void IN_Button1Up(void) {IN_KeyUp(&in_buttons[1]);}
|
||||
void IN_Button2Down(void) {IN_KeyDown(&in_buttons[2]);}
|
||||
void IN_Button2Up(void) {IN_KeyUp(&in_buttons[2]);}
|
||||
void IN_Button3Down(void) {IN_KeyDown(&in_buttons[3]);}
|
||||
void IN_Button3Up(void) {IN_KeyUp(&in_buttons[3]);}
|
||||
void IN_Button4Down(void) {IN_KeyDown(&in_buttons[4]);}
|
||||
void IN_Button4Up(void) {IN_KeyUp(&in_buttons[4]);}
|
||||
void IN_Button5Down(void) {IN_KeyDown(&in_buttons[5]);}
|
||||
void IN_Button5Up(void) {IN_KeyUp(&in_buttons[5]);}
|
||||
void IN_Button6Down(void) {IN_KeyDown(&in_buttons[6]);}
|
||||
void IN_Button6Up(void) {IN_KeyUp(&in_buttons[6]);}
|
||||
void IN_Button7Down(void) {IN_KeyDown(&in_buttons[7]);}
|
||||
void IN_Button7Up(void) {IN_KeyUp(&in_buttons[7]);}
|
||||
void IN_Button8Down(void) {IN_KeyDown(&in_buttons[8]);}
|
||||
void IN_Button8Up(void) {IN_KeyUp(&in_buttons[8]);}
|
||||
void IN_Button9Down(void) {IN_KeyDown(&in_buttons[9]);}
|
||||
void IN_Button9Up(void) {IN_KeyUp(&in_buttons[9]);}
|
||||
void IN_Button10Down(void) {IN_KeyDown(&in_buttons[10]);}
|
||||
void IN_Button10Up(void) {IN_KeyUp(&in_buttons[10]);}
|
||||
void IN_Button11Down(void) {IN_KeyDown(&in_buttons[11]);}
|
||||
void IN_Button11Up(void) {IN_KeyUp(&in_buttons[11]);}
|
||||
void IN_Button12Down(void) {IN_KeyDown(&in_buttons[12]);}
|
||||
void IN_Button12Up(void) {IN_KeyUp(&in_buttons[12]);}
|
||||
void IN_Button13Down(void) {IN_KeyDown(&in_buttons[13]);}
|
||||
void IN_Button13Up(void) {IN_KeyUp(&in_buttons[13]);}
|
||||
void IN_Button14Down(void) {IN_KeyDown(&in_buttons[14]);}
|
||||
void IN_Button14Up(void) {IN_KeyUp(&in_buttons[14]);}
|
||||
void IN_Button15Down(void) {IN_KeyDown(&in_buttons[15]);}
|
||||
void IN_Button15Up(void) {IN_KeyUp(&in_buttons[15]);}
|
||||
|
||||
void IN_ButtonDown (void) {
|
||||
IN_KeyDown(&in_buttons[1]);}
|
||||
void IN_ButtonUp (void) {
|
||||
IN_KeyUp(&in_buttons[1]);}
|
||||
|
||||
void IN_CenterView (void) {
|
||||
cl.viewangles[PITCH] = -SHORT2ANGLE(cl.snap.ps.delta_angles[PITCH]);
|
||||
}
|
||||
|
||||
|
||||
//==========================================================================
|
||||
|
||||
cvar_t *cl_upspeed;
|
||||
cvar_t *cl_forwardspeed;
|
||||
cvar_t *cl_sidespeed;
|
||||
|
||||
cvar_t *cl_yawspeed;
|
||||
cvar_t *cl_pitchspeed;
|
||||
|
||||
cvar_t *cl_run;
|
||||
|
||||
cvar_t *cl_anglespeedkey;
|
||||
|
||||
|
||||
/*
|
||||
================
|
||||
CL_AdjustAngles
|
||||
|
||||
Moves the local angle positions
|
||||
================
|
||||
*/
|
||||
void CL_AdjustAngles( void ) {
|
||||
float speed;
|
||||
|
||||
if ( in_speed.active ) {
|
||||
speed = 0.001 * cls.frametime * cl_anglespeedkey->value;
|
||||
} else {
|
||||
speed = 0.001 * cls.frametime;
|
||||
}
|
||||
|
||||
if ( !in_strafe.active ) {
|
||||
cl.viewangles[YAW] -= speed*cl_yawspeed->value*CL_KeyState (&in_right);
|
||||
cl.viewangles[YAW] += speed*cl_yawspeed->value*CL_KeyState (&in_left);
|
||||
}
|
||||
|
||||
cl.viewangles[PITCH] -= speed*cl_pitchspeed->value * CL_KeyState (&in_lookup);
|
||||
cl.viewangles[PITCH] += speed*cl_pitchspeed->value * CL_KeyState (&in_lookdown);
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
CL_KeyMove
|
||||
|
||||
Sets the usercmd_t based on key states
|
||||
================
|
||||
*/
|
||||
void CL_KeyMove( usercmd_t *cmd ) {
|
||||
int movespeed;
|
||||
int forward, side, up;
|
||||
|
||||
//
|
||||
// adjust for speed key / running
|
||||
// the walking flag is to keep animations consistant
|
||||
// even during acceleration and develeration
|
||||
//
|
||||
if ( in_speed.active ^ cl_run->integer ) {
|
||||
movespeed = 127;
|
||||
cmd->buttons &= ~BUTTON_WALKING;
|
||||
} else {
|
||||
cmd->buttons |= BUTTON_WALKING;
|
||||
movespeed = 64;
|
||||
}
|
||||
|
||||
forward = 0;
|
||||
side = 0;
|
||||
up = 0;
|
||||
if ( in_strafe.active ) {
|
||||
side += movespeed * CL_KeyState (&in_right);
|
||||
side -= movespeed * CL_KeyState (&in_left);
|
||||
}
|
||||
|
||||
side += movespeed * CL_KeyState (&in_moveright);
|
||||
side -= movespeed * CL_KeyState (&in_moveleft);
|
||||
|
||||
|
||||
up += movespeed * CL_KeyState (&in_up);
|
||||
up -= movespeed * CL_KeyState (&in_down);
|
||||
|
||||
forward += movespeed * CL_KeyState (&in_forward);
|
||||
forward -= movespeed * CL_KeyState (&in_back);
|
||||
|
||||
cmd->forwardmove = ClampChar( forward );
|
||||
cmd->rightmove = ClampChar( side );
|
||||
cmd->upmove = ClampChar( up );
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
CL_MouseEvent
|
||||
=================
|
||||
*/
|
||||
void CL_MouseEvent( int dx, int dy, int time ) {
|
||||
if ( cls.keyCatchers & KEYCATCH_UI ) {
|
||||
VM_Call( uivm, UI_MOUSE_EVENT, dx, dy );
|
||||
} else if (cls.keyCatchers & KEYCATCH_CGAME) {
|
||||
VM_Call (cgvm, CG_MOUSE_EVENT, dx, dy);
|
||||
} else {
|
||||
cl.mouseDx[cl.mouseIndex] += dx;
|
||||
cl.mouseDy[cl.mouseIndex] += dy;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
CL_JoystickEvent
|
||||
|
||||
Joystick values stay set until changed
|
||||
=================
|
||||
*/
|
||||
void CL_JoystickEvent( int axis, int value, int time ) {
|
||||
if ( axis < 0 || axis >= MAX_JOYSTICK_AXIS ) {
|
||||
Com_Error( ERR_DROP, "CL_JoystickEvent: bad axis %i", axis );
|
||||
}
|
||||
cl.joystickAxis[axis] = value;
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
CL_JoystickMove
|
||||
=================
|
||||
*/
|
||||
void CL_JoystickMove( usercmd_t *cmd ) {
|
||||
int movespeed;
|
||||
float anglespeed;
|
||||
|
||||
if ( in_speed.active ^ cl_run->integer ) {
|
||||
movespeed = 2;
|
||||
} else {
|
||||
movespeed = 1;
|
||||
cmd->buttons |= BUTTON_WALKING;
|
||||
}
|
||||
|
||||
if ( in_speed.active ) {
|
||||
anglespeed = 0.001 * cls.frametime * cl_anglespeedkey->value;
|
||||
} else {
|
||||
anglespeed = 0.001 * cls.frametime;
|
||||
}
|
||||
|
||||
if ( !in_strafe.active ) {
|
||||
cl.viewangles[YAW] += anglespeed * cl_yawspeed->value * cl.joystickAxis[AXIS_SIDE];
|
||||
} else {
|
||||
cmd->rightmove = ClampChar( cmd->rightmove + cl.joystickAxis[AXIS_SIDE] );
|
||||
}
|
||||
|
||||
if ( in_mlooking ) {
|
||||
cl.viewangles[PITCH] += anglespeed * cl_pitchspeed->value * cl.joystickAxis[AXIS_FORWARD];
|
||||
} else {
|
||||
cmd->forwardmove = ClampChar( cmd->forwardmove + cl.joystickAxis[AXIS_FORWARD] );
|
||||
}
|
||||
|
||||
cmd->upmove = ClampChar( cmd->upmove + cl.joystickAxis[AXIS_UP] );
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
CL_MouseMove
|
||||
=================
|
||||
*/
|
||||
void CL_MouseMove( usercmd_t *cmd ) {
|
||||
float mx, my;
|
||||
float accelSensitivity;
|
||||
float rate;
|
||||
|
||||
// allow mouse smoothing
|
||||
if ( m_filter->integer ) {
|
||||
mx = ( cl.mouseDx[0] + cl.mouseDx[1] ) * 0.5;
|
||||
my = ( cl.mouseDy[0] + cl.mouseDy[1] ) * 0.5;
|
||||
} else {
|
||||
mx = cl.mouseDx[cl.mouseIndex];
|
||||
my = cl.mouseDy[cl.mouseIndex];
|
||||
}
|
||||
cl.mouseIndex ^= 1;
|
||||
cl.mouseDx[cl.mouseIndex] = 0;
|
||||
cl.mouseDy[cl.mouseIndex] = 0;
|
||||
|
||||
rate = sqrt( mx * mx + my * my ) / (float)frame_msec;
|
||||
accelSensitivity = ( cl_sensitivity->value *
|
||||
cl_platformSensitivity->value ) + rate * cl_mouseAccel->value;
|
||||
|
||||
// scale by FOV
|
||||
accelSensitivity *= cl.cgameSensitivity;
|
||||
|
||||
if ( rate && cl_showMouseRate->integer ) {
|
||||
Com_Printf( "%f : %f\n", rate, accelSensitivity );
|
||||
}
|
||||
|
||||
mx *= accelSensitivity;
|
||||
my *= accelSensitivity;
|
||||
|
||||
if (!mx && !my) {
|
||||
return;
|
||||
}
|
||||
|
||||
// add mouse X/Y movement to cmd
|
||||
if ( in_strafe.active ) {
|
||||
cmd->rightmove = ClampChar( cmd->rightmove + m_side->value * mx );
|
||||
} else {
|
||||
cl.viewangles[YAW] -= m_yaw->value * mx;
|
||||
}
|
||||
|
||||
if ( (in_mlooking || cl_freelook->integer) && !in_strafe.active ) {
|
||||
cl.viewangles[PITCH] += m_pitch->value * my;
|
||||
} else {
|
||||
cmd->forwardmove = ClampChar( cmd->forwardmove - m_forward->value * my );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
==============
|
||||
CL_CmdButtons
|
||||
==============
|
||||
*/
|
||||
void CL_CmdButtons( usercmd_t *cmd ) {
|
||||
int i;
|
||||
|
||||
//
|
||||
// figure button bits
|
||||
// send a button bit even if the key was pressed and released in
|
||||
// less than a frame
|
||||
//
|
||||
for (i = 0 ; i < 15 ; i++) {
|
||||
if ( in_buttons[i].active || in_buttons[i].wasPressed ) {
|
||||
cmd->buttons |= 1 << i;
|
||||
}
|
||||
in_buttons[i].wasPressed = qfalse;
|
||||
}
|
||||
|
||||
if ( cls.keyCatchers ) {
|
||||
cmd->buttons |= BUTTON_TALK;
|
||||
}
|
||||
|
||||
// allow the game to know if any key at all is
|
||||
// currently pressed, even if it isn't bound to anything
|
||||
if ( anykeydown && !cls.keyCatchers ) {
|
||||
cmd->buttons |= BUTTON_ANY;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
==============
|
||||
CL_FinishMove
|
||||
==============
|
||||
*/
|
||||
void CL_FinishMove( usercmd_t *cmd ) {
|
||||
int i;
|
||||
|
||||
// copy the state that the cgame is currently sending
|
||||
cmd->weapon = cl.cgameUserCmdValue;
|
||||
|
||||
// send the current server time so the amount of movement
|
||||
// can be determined without allowing cheating
|
||||
cmd->serverTime = cl.serverTime;
|
||||
|
||||
for (i=0 ; i<3 ; i++) {
|
||||
cmd->angles[i] = ANGLE2SHORT(cl.viewangles[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
=================
|
||||
CL_CreateCmd
|
||||
=================
|
||||
*/
|
||||
usercmd_t CL_CreateCmd( void ) {
|
||||
usercmd_t cmd;
|
||||
vec3_t oldAngles;
|
||||
|
||||
VectorCopy( cl.viewangles, oldAngles );
|
||||
|
||||
// keyboard angle adjustment
|
||||
CL_AdjustAngles ();
|
||||
|
||||
Com_Memset( &cmd, 0, sizeof( cmd ) );
|
||||
|
||||
CL_CmdButtons( &cmd );
|
||||
|
||||
// get basic movement from keyboard
|
||||
CL_KeyMove( &cmd );
|
||||
|
||||
// get basic movement from mouse
|
||||
CL_MouseMove( &cmd );
|
||||
|
||||
// get basic movement from joystick
|
||||
CL_JoystickMove( &cmd );
|
||||
|
||||
// check to make sure the angles haven't wrapped
|
||||
if ( cl.viewangles[PITCH] - oldAngles[PITCH] > 90 ) {
|
||||
cl.viewangles[PITCH] = oldAngles[PITCH] + 90;
|
||||
} else if ( oldAngles[PITCH] - cl.viewangles[PITCH] > 90 ) {
|
||||
cl.viewangles[PITCH] = oldAngles[PITCH] - 90;
|
||||
}
|
||||
|
||||
// store out the final values
|
||||
CL_FinishMove( &cmd );
|
||||
|
||||
// draw debug graphs of turning for mouse testing
|
||||
if ( cl_debugMove->integer ) {
|
||||
if ( cl_debugMove->integer == 1 ) {
|
||||
SCR_DebugGraph( abs(cl.viewangles[YAW] - oldAngles[YAW]), 0 );
|
||||
}
|
||||
if ( cl_debugMove->integer == 2 ) {
|
||||
SCR_DebugGraph( abs(cl.viewangles[PITCH] - oldAngles[PITCH]), 0 );
|
||||
}
|
||||
}
|
||||
|
||||
return cmd;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
=================
|
||||
CL_CreateNewCommands
|
||||
|
||||
Create a new usercmd_t structure for this frame
|
||||
=================
|
||||
*/
|
||||
void CL_CreateNewCommands( void ) {
|
||||
usercmd_t *cmd;
|
||||
int cmdNum;
|
||||
|
||||
// no need to create usercmds until we have a gamestate
|
||||
if ( cls.state < CA_PRIMED ) {
|
||||
return;
|
||||
}
|
||||
|
||||
frame_msec = com_frameTime - old_com_frameTime;
|
||||
|
||||
// if running less than 5fps, truncate the extra time to prevent
|
||||
// unexpected moves after a hitch
|
||||
if ( frame_msec > 200 ) {
|
||||
frame_msec = 200;
|
||||
}
|
||||
old_com_frameTime = com_frameTime;
|
||||
|
||||
|
||||
// generate a command for this frame
|
||||
cl.cmdNumber++;
|
||||
cmdNum = cl.cmdNumber & CMD_MASK;
|
||||
cl.cmds[cmdNum] = CL_CreateCmd ();
|
||||
cmd = &cl.cmds[cmdNum];
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
CL_ReadyToSendPacket
|
||||
|
||||
Returns qfalse if we are over the maxpackets limit
|
||||
and should choke back the bandwidth a bit by not sending
|
||||
a packet this frame. All the commands will still get
|
||||
delivered in the next packet, but saving a header and
|
||||
getting more delta compression will reduce total bandwidth.
|
||||
=================
|
||||
*/
|
||||
qboolean CL_ReadyToSendPacket( void ) {
|
||||
int oldPacketNum;
|
||||
int delta;
|
||||
|
||||
// don't send anything if playing back a demo
|
||||
if ( clc.demoplaying || cls.state == CA_CINEMATIC ) {
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
// If we are downloading, we send no less than 50ms between packets
|
||||
if ( *clc.downloadTempName &&
|
||||
cls.realtime - clc.lastPacketSentTime < 50 ) {
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
// if we don't have a valid gamestate yet, only send
|
||||
// one packet a second
|
||||
if ( cls.state != CA_ACTIVE &&
|
||||
cls.state != CA_PRIMED &&
|
||||
!*clc.downloadTempName &&
|
||||
cls.realtime - clc.lastPacketSentTime < 1000 ) {
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
// send every frame for loopbacks
|
||||
if ( clc.netchan.remoteAddress.type == NA_LOOPBACK ) {
|
||||
return qtrue;
|
||||
}
|
||||
|
||||
// send every frame for LAN
|
||||
if ( cl_lanForcePackets->integer && Sys_IsLANAddress( clc.netchan.remoteAddress ) ) {
|
||||
return qtrue;
|
||||
}
|
||||
|
||||
// check for exceeding cl_maxpackets
|
||||
if ( cl_maxpackets->integer < 15 ) {
|
||||
Cvar_Set( "cl_maxpackets", "15" );
|
||||
} else if ( cl_maxpackets->integer > 125 ) {
|
||||
Cvar_Set( "cl_maxpackets", "125" );
|
||||
}
|
||||
oldPacketNum = (clc.netchan.outgoingSequence - 1) & PACKET_MASK;
|
||||
delta = cls.realtime - cl.outPackets[ oldPacketNum ].p_realtime;
|
||||
if ( delta < 1000 / cl_maxpackets->integer ) {
|
||||
// the accumulated commands will go out in the next packet
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
return qtrue;
|
||||
}
|
||||
|
||||
/*
|
||||
===================
|
||||
CL_WritePacket
|
||||
|
||||
Create and send the command packet to the server
|
||||
Including both the reliable commands and the usercmds
|
||||
|
||||
During normal gameplay, a client packet will contain something like:
|
||||
|
||||
4 sequence number
|
||||
2 qport
|
||||
4 serverid
|
||||
4 acknowledged sequence number
|
||||
4 clc.serverCommandSequence
|
||||
<optional reliable commands>
|
||||
1 clc_move or clc_moveNoDelta
|
||||
1 command count
|
||||
<count * usercmds>
|
||||
|
||||
===================
|
||||
*/
|
||||
void CL_WritePacket( void ) {
|
||||
msg_t buf;
|
||||
byte data[MAX_MSGLEN];
|
||||
int i, j;
|
||||
usercmd_t *cmd, *oldcmd;
|
||||
usercmd_t nullcmd;
|
||||
int packetNum;
|
||||
int oldPacketNum;
|
||||
int count, key;
|
||||
|
||||
// don't send anything if playing back a demo
|
||||
if ( clc.demoplaying || cls.state == CA_CINEMATIC ) {
|
||||
return;
|
||||
}
|
||||
|
||||
Com_Memset( &nullcmd, 0, sizeof(nullcmd) );
|
||||
oldcmd = &nullcmd;
|
||||
|
||||
MSG_Init( &buf, data, sizeof(data) );
|
||||
|
||||
MSG_Bitstream( &buf );
|
||||
// write the current serverId so the server
|
||||
// can tell if this is from the current gameState
|
||||
MSG_WriteLong( &buf, cl.serverId );
|
||||
|
||||
// write the last message we received, which can
|
||||
// be used for delta compression, and is also used
|
||||
// to tell if we dropped a gamestate
|
||||
MSG_WriteLong( &buf, clc.serverMessageSequence );
|
||||
|
||||
// write the last reliable message we received
|
||||
MSG_WriteLong( &buf, clc.serverCommandSequence );
|
||||
|
||||
// write any unacknowledged clientCommands
|
||||
for ( i = clc.reliableAcknowledge + 1 ; i <= clc.reliableSequence ; i++ ) {
|
||||
MSG_WriteByte( &buf, clc_clientCommand );
|
||||
MSG_WriteLong( &buf, i );
|
||||
MSG_WriteString( &buf, clc.reliableCommands[ i & (MAX_RELIABLE_COMMANDS-1) ] );
|
||||
}
|
||||
|
||||
// we want to send all the usercmds that were generated in the last
|
||||
// few packet, so even if a couple packets are dropped in a row,
|
||||
// all the cmds will make it to the server
|
||||
if ( cl_packetdup->integer < 0 ) {
|
||||
Cvar_Set( "cl_packetdup", "0" );
|
||||
} else if ( cl_packetdup->integer > 5 ) {
|
||||
Cvar_Set( "cl_packetdup", "5" );
|
||||
}
|
||||
oldPacketNum = (clc.netchan.outgoingSequence - 1 - cl_packetdup->integer) & PACKET_MASK;
|
||||
count = cl.cmdNumber - cl.outPackets[ oldPacketNum ].p_cmdNumber;
|
||||
if ( count > MAX_PACKET_USERCMDS ) {
|
||||
count = MAX_PACKET_USERCMDS;
|
||||
Com_Printf("MAX_PACKET_USERCMDS\n");
|
||||
}
|
||||
if ( count >= 1 ) {
|
||||
if ( cl_showSend->integer ) {
|
||||
Com_Printf( "(%i)", count );
|
||||
}
|
||||
|
||||
// begin a client move command
|
||||
if ( cl_nodelta->integer || !cl.snap.valid || clc.demowaiting
|
||||
|| clc.serverMessageSequence != cl.snap.messageNum ) {
|
||||
MSG_WriteByte (&buf, clc_moveNoDelta);
|
||||
} else {
|
||||
MSG_WriteByte (&buf, clc_move);
|
||||
}
|
||||
|
||||
// write the command count
|
||||
MSG_WriteByte( &buf, count );
|
||||
|
||||
// use the checksum feed in the key
|
||||
key = clc.checksumFeed;
|
||||
// also use the message acknowledge
|
||||
key ^= clc.serverMessageSequence;
|
||||
// also use the last acknowledged server command in the key
|
||||
key ^= Com_HashKey(clc.serverCommands[ clc.serverCommandSequence & (MAX_RELIABLE_COMMANDS-1) ], 32);
|
||||
|
||||
// write all the commands, including the predicted command
|
||||
for ( i = 0 ; i < count ; i++ ) {
|
||||
j = (cl.cmdNumber - count + i + 1) & CMD_MASK;
|
||||
cmd = &cl.cmds[j];
|
||||
MSG_WriteDeltaUsercmdKey (&buf, key, oldcmd, cmd);
|
||||
oldcmd = cmd;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// deliver the message
|
||||
//
|
||||
packetNum = clc.netchan.outgoingSequence & PACKET_MASK;
|
||||
cl.outPackets[ packetNum ].p_realtime = cls.realtime;
|
||||
cl.outPackets[ packetNum ].p_serverTime = oldcmd->serverTime;
|
||||
cl.outPackets[ packetNum ].p_cmdNumber = cl.cmdNumber;
|
||||
clc.lastPacketSentTime = cls.realtime;
|
||||
|
||||
if ( cl_showSend->integer ) {
|
||||
Com_Printf( "%i ", buf.cursize );
|
||||
}
|
||||
|
||||
CL_Netchan_Transmit (&clc.netchan, &buf);
|
||||
|
||||
// clients never really should have messages large enough
|
||||
// to fragment, but in case they do, fire them all off
|
||||
// at once
|
||||
// TTimo: this causes a packet burst, which is bad karma for winsock
|
||||
// added a WARNING message, we'll see if there are legit situations where this happens
|
||||
while ( clc.netchan.unsentFragments ) {
|
||||
Com_DPrintf( "WARNING: #462 unsent fragments (not supposed to happen!)\n" );
|
||||
CL_Netchan_TransmitNextFragment( &clc.netchan );
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
CL_SendCmd
|
||||
|
||||
Called every frame to builds and sends a command packet to the server.
|
||||
=================
|
||||
*/
|
||||
void CL_SendCmd( void ) {
|
||||
// don't send any message if not connected
|
||||
if ( cls.state < CA_CONNECTED ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// don't send commands if paused
|
||||
if ( com_sv_running->integer && sv_paused->integer && cl_paused->integer ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// we create commands even if a demo is playing,
|
||||
CL_CreateNewCommands();
|
||||
|
||||
// don't send a packet if the last packet was sent too recently
|
||||
if ( !CL_ReadyToSendPacket() ) {
|
||||
if ( cl_showSend->integer ) {
|
||||
Com_Printf( ". " );
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
CL_WritePacket();
|
||||
}
|
||||
|
||||
/*
|
||||
============
|
||||
CL_InitInput
|
||||
============
|
||||
*/
|
||||
void CL_InitInput( void ) {
|
||||
Cmd_AddCommand ("centerview",IN_CenterView);
|
||||
|
||||
Cmd_AddCommand ("+moveup",IN_UpDown);
|
||||
Cmd_AddCommand ("-moveup",IN_UpUp);
|
||||
Cmd_AddCommand ("+movedown",IN_DownDown);
|
||||
Cmd_AddCommand ("-movedown",IN_DownUp);
|
||||
Cmd_AddCommand ("+left",IN_LeftDown);
|
||||
Cmd_AddCommand ("-left",IN_LeftUp);
|
||||
Cmd_AddCommand ("+right",IN_RightDown);
|
||||
Cmd_AddCommand ("-right",IN_RightUp);
|
||||
Cmd_AddCommand ("+forward",IN_ForwardDown);
|
||||
Cmd_AddCommand ("-forward",IN_ForwardUp);
|
||||
Cmd_AddCommand ("+back",IN_BackDown);
|
||||
Cmd_AddCommand ("-back",IN_BackUp);
|
||||
Cmd_AddCommand ("+lookup", IN_LookupDown);
|
||||
Cmd_AddCommand ("-lookup", IN_LookupUp);
|
||||
Cmd_AddCommand ("+lookdown", IN_LookdownDown);
|
||||
Cmd_AddCommand ("-lookdown", IN_LookdownUp);
|
||||
Cmd_AddCommand ("+strafe", IN_StrafeDown);
|
||||
Cmd_AddCommand ("-strafe", IN_StrafeUp);
|
||||
Cmd_AddCommand ("+moveleft", IN_MoveleftDown);
|
||||
Cmd_AddCommand ("-moveleft", IN_MoveleftUp);
|
||||
Cmd_AddCommand ("+moveright", IN_MoverightDown);
|
||||
Cmd_AddCommand ("-moveright", IN_MoverightUp);
|
||||
Cmd_AddCommand ("+speed", IN_SpeedDown);
|
||||
Cmd_AddCommand ("-speed", IN_SpeedUp);
|
||||
Cmd_AddCommand ("+attack", IN_Button0Down);
|
||||
Cmd_AddCommand ("-attack", IN_Button0Up);
|
||||
Cmd_AddCommand ("+button0", IN_Button0Down);
|
||||
Cmd_AddCommand ("-button0", IN_Button0Up);
|
||||
Cmd_AddCommand ("+button1", IN_Button1Down);
|
||||
Cmd_AddCommand ("-button1", IN_Button1Up);
|
||||
Cmd_AddCommand ("+button2", IN_Button2Down);
|
||||
Cmd_AddCommand ("-button2", IN_Button2Up);
|
||||
Cmd_AddCommand ("+button3", IN_Button3Down);
|
||||
Cmd_AddCommand ("-button3", IN_Button3Up);
|
||||
Cmd_AddCommand ("+button4", IN_Button4Down);
|
||||
Cmd_AddCommand ("-button4", IN_Button4Up);
|
||||
Cmd_AddCommand ("+button5", IN_Button5Down);
|
||||
Cmd_AddCommand ("-button5", IN_Button5Up);
|
||||
Cmd_AddCommand ("+button6", IN_Button6Down);
|
||||
Cmd_AddCommand ("-button6", IN_Button6Up);
|
||||
Cmd_AddCommand ("+button7", IN_Button7Down);
|
||||
Cmd_AddCommand ("-button7", IN_Button7Up);
|
||||
Cmd_AddCommand ("+button8", IN_Button8Down);
|
||||
Cmd_AddCommand ("-button8", IN_Button8Up);
|
||||
Cmd_AddCommand ("+button9", IN_Button9Down);
|
||||
Cmd_AddCommand ("-button9", IN_Button9Up);
|
||||
Cmd_AddCommand ("+button10", IN_Button10Down);
|
||||
Cmd_AddCommand ("-button10", IN_Button10Up);
|
||||
Cmd_AddCommand ("+button11", IN_Button11Down);
|
||||
Cmd_AddCommand ("-button11", IN_Button11Up);
|
||||
Cmd_AddCommand ("+button12", IN_Button12Down);
|
||||
Cmd_AddCommand ("-button12", IN_Button12Up);
|
||||
Cmd_AddCommand ("+button13", IN_Button13Down);
|
||||
Cmd_AddCommand ("-button13", IN_Button13Up);
|
||||
Cmd_AddCommand ("+button14", IN_Button14Down);
|
||||
Cmd_AddCommand ("-button14", IN_Button14Up);
|
||||
Cmd_AddCommand ("+mlook", IN_MLookDown);
|
||||
Cmd_AddCommand ("-mlook", IN_MLookUp);
|
||||
|
||||
cl_nodelta = Cvar_Get ("cl_nodelta", "0", 0);
|
||||
cl_debugMove = Cvar_Get ("cl_debugMove", "0", 0);
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -1,168 +0,0 @@
|
||||
/*
|
||||
===========================================================================
|
||||
Copyright (C) 1999-2005 Id Software, Inc.
|
||||
Copyright (C) 2000-2006 Tim Angus
|
||||
|
||||
This file is part of Tremulous.
|
||||
|
||||
Tremulous is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
Tremulous is distributed in the hope that it will be
|
||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Tremulous; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
===========================================================================
|
||||
*/
|
||||
|
||||
#include "../qcommon/q_shared.h"
|
||||
#include "../qcommon/qcommon.h"
|
||||
#include "client.h"
|
||||
|
||||
/*
|
||||
==============
|
||||
CL_Netchan_Encode
|
||||
|
||||
// first 12 bytes of the data are always:
|
||||
long serverId;
|
||||
long messageAcknowledge;
|
||||
long reliableAcknowledge;
|
||||
|
||||
==============
|
||||
*/
|
||||
static void CL_Netchan_Encode( msg_t *msg ) {
|
||||
int serverId, messageAcknowledge, reliableAcknowledge;
|
||||
int i, index, srdc, sbit, soob;
|
||||
byte key, *string;
|
||||
|
||||
if ( msg->cursize <= CL_ENCODE_START ) {
|
||||
return;
|
||||
}
|
||||
|
||||
srdc = msg->readcount;
|
||||
sbit = msg->bit;
|
||||
soob = msg->oob;
|
||||
|
||||
msg->bit = 0;
|
||||
msg->readcount = 0;
|
||||
msg->oob = 0;
|
||||
|
||||
serverId = MSG_ReadLong(msg);
|
||||
messageAcknowledge = MSG_ReadLong(msg);
|
||||
reliableAcknowledge = MSG_ReadLong(msg);
|
||||
|
||||
msg->oob = soob;
|
||||
msg->bit = sbit;
|
||||
msg->readcount = srdc;
|
||||
|
||||
string = (byte *)clc.serverCommands[ reliableAcknowledge & (MAX_RELIABLE_COMMANDS-1) ];
|
||||
index = 0;
|
||||
//
|
||||
key = clc.challenge ^ serverId ^ messageAcknowledge;
|
||||
for (i = CL_ENCODE_START; i < msg->cursize; i++) {
|
||||
// modify the key with the last received now acknowledged server command
|
||||
if (!string[index])
|
||||
index = 0;
|
||||
if (string[index] > 127 || string[index] == '%') {
|
||||
key ^= '.' << (i & 1);
|
||||
}
|
||||
else {
|
||||
key ^= string[index] << (i & 1);
|
||||
}
|
||||
index++;
|
||||
// encode the data with this key
|
||||
*(msg->data + i) = (*(msg->data + i)) ^ key;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
==============
|
||||
CL_Netchan_Decode
|
||||
|
||||
// first four bytes of the data are always:
|
||||
long reliableAcknowledge;
|
||||
|
||||
==============
|
||||
*/
|
||||
static void CL_Netchan_Decode( msg_t *msg ) {
|
||||
long reliableAcknowledge, i, index;
|
||||
byte key, *string;
|
||||
int srdc, sbit, soob;
|
||||
|
||||
srdc = msg->readcount;
|
||||
sbit = msg->bit;
|
||||
soob = msg->oob;
|
||||
|
||||
msg->oob = 0;
|
||||
|
||||
reliableAcknowledge = MSG_ReadLong(msg);
|
||||
|
||||
msg->oob = soob;
|
||||
msg->bit = sbit;
|
||||
msg->readcount = srdc;
|
||||
|
||||
string = (byte *) clc.reliableCommands[ reliableAcknowledge & (MAX_RELIABLE_COMMANDS-1) ];
|
||||
index = 0;
|
||||
// xor the client challenge with the netchan sequence number (need something that changes every message)
|
||||
key = clc.challenge ^ LittleLong( *(unsigned *)msg->data );
|
||||
for (i = msg->readcount + CL_DECODE_START; i < msg->cursize; i++) {
|
||||
// modify the key with the last sent and with this message acknowledged client command
|
||||
if (!string[index])
|
||||
index = 0;
|
||||
if (string[index] > 127 || string[index] == '%') {
|
||||
key ^= '.' << (i & 1);
|
||||
}
|
||||
else {
|
||||
key ^= string[index] << (i & 1);
|
||||
}
|
||||
index++;
|
||||
// decode the data with this key
|
||||
*(msg->data + i) = *(msg->data + i) ^ key;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
CL_Netchan_TransmitNextFragment
|
||||
=================
|
||||
*/
|
||||
void CL_Netchan_TransmitNextFragment( netchan_t *chan ) {
|
||||
Netchan_TransmitNextFragment( chan );
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
CL_Netchan_Transmit
|
||||
================
|
||||
*/
|
||||
void CL_Netchan_Transmit( netchan_t *chan, msg_t* msg ) {
|
||||
MSG_WriteByte( msg, clc_EOF );
|
||||
|
||||
CL_Netchan_Encode( msg );
|
||||
Netchan_Transmit( chan, msg->cursize, msg->data );
|
||||
}
|
||||
|
||||
extern int oldsize;
|
||||
int newsize = 0;
|
||||
|
||||
/*
|
||||
=================
|
||||
CL_Netchan_Process
|
||||
=================
|
||||
*/
|
||||
qboolean CL_Netchan_Process( netchan_t *chan, msg_t *msg ) {
|
||||
int ret;
|
||||
|
||||
ret = Netchan_Process( chan, msg );
|
||||
if (!ret)
|
||||
return qfalse;
|
||||
CL_Netchan_Decode( msg );
|
||||
newsize += msg->cursize;
|
||||
return qtrue;
|
||||
}
|
||||
@@ -1,722 +0,0 @@
|
||||
/*
|
||||
===========================================================================
|
||||
Copyright (C) 1999-2005 Id Software, Inc.
|
||||
Copyright (C) 2000-2006 Tim Angus
|
||||
|
||||
This file is part of Tremulous.
|
||||
|
||||
Tremulous is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
Tremulous is distributed in the hope that it will be
|
||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Tremulous; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
===========================================================================
|
||||
*/
|
||||
// cl_parse.c -- parse a message received from the server
|
||||
|
||||
#include "client.h"
|
||||
|
||||
char *svc_strings[256] = {
|
||||
"svc_bad",
|
||||
|
||||
"svc_nop",
|
||||
"svc_gamestate",
|
||||
"svc_configstring",
|
||||
"svc_baseline",
|
||||
"svc_serverCommand",
|
||||
"svc_download",
|
||||
"svc_snapshot"
|
||||
};
|
||||
|
||||
void SHOWNET( msg_t *msg, char *s) {
|
||||
if ( cl_shownet->integer >= 2) {
|
||||
Com_Printf ("%3i:%s\n", msg->readcount-1, s);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
=========================================================================
|
||||
|
||||
MESSAGE PARSING
|
||||
|
||||
=========================================================================
|
||||
*/
|
||||
|
||||
/*
|
||||
==================
|
||||
CL_DeltaEntity
|
||||
|
||||
Parses deltas from the given base and adds the resulting entity
|
||||
to the current frame
|
||||
==================
|
||||
*/
|
||||
void CL_DeltaEntity (msg_t *msg, clSnapshot_t *frame, int newnum, entityState_t *old,
|
||||
qboolean unchanged) {
|
||||
entityState_t *state;
|
||||
|
||||
// save the parsed entity state into the big circular buffer so
|
||||
// it can be used as the source for a later delta
|
||||
state = &cl.parseEntities[cl.parseEntitiesNum & (MAX_PARSE_ENTITIES-1)];
|
||||
|
||||
if ( unchanged ) {
|
||||
*state = *old;
|
||||
} else {
|
||||
MSG_ReadDeltaEntity( msg, old, state, newnum );
|
||||
}
|
||||
|
||||
if ( state->number == (MAX_GENTITIES-1) ) {
|
||||
return; // entity was delta removed
|
||||
}
|
||||
cl.parseEntitiesNum++;
|
||||
frame->numEntities++;
|
||||
}
|
||||
|
||||
/*
|
||||
==================
|
||||
CL_ParsePacketEntities
|
||||
|
||||
==================
|
||||
*/
|
||||
void CL_ParsePacketEntities( msg_t *msg, clSnapshot_t *oldframe, clSnapshot_t *newframe) {
|
||||
int newnum;
|
||||
entityState_t *oldstate;
|
||||
int oldindex, oldnum;
|
||||
|
||||
newframe->parseEntitiesNum = cl.parseEntitiesNum;
|
||||
newframe->numEntities = 0;
|
||||
|
||||
// delta from the entities present in oldframe
|
||||
oldindex = 0;
|
||||
oldstate = NULL;
|
||||
if (!oldframe) {
|
||||
oldnum = 99999;
|
||||
} else {
|
||||
if ( oldindex >= oldframe->numEntities ) {
|
||||
oldnum = 99999;
|
||||
} else {
|
||||
oldstate = &cl.parseEntities[
|
||||
(oldframe->parseEntitiesNum + oldindex) & (MAX_PARSE_ENTITIES-1)];
|
||||
oldnum = oldstate->number;
|
||||
}
|
||||
}
|
||||
|
||||
while ( 1 ) {
|
||||
// read the entity index number
|
||||
newnum = MSG_ReadBits( msg, GENTITYNUM_BITS );
|
||||
|
||||
if ( newnum == (MAX_GENTITIES-1) ) {
|
||||
break;
|
||||
}
|
||||
|
||||
if ( msg->readcount > msg->cursize ) {
|
||||
Com_Error (ERR_DROP,"CL_ParsePacketEntities: end of message");
|
||||
}
|
||||
|
||||
while ( oldnum < newnum ) {
|
||||
// one or more entities from the old packet are unchanged
|
||||
if ( cl_shownet->integer == 3 ) {
|
||||
Com_Printf ("%3i: unchanged: %i\n", msg->readcount, oldnum);
|
||||
}
|
||||
CL_DeltaEntity( msg, newframe, oldnum, oldstate, qtrue );
|
||||
|
||||
oldindex++;
|
||||
|
||||
if ( oldindex >= oldframe->numEntities ) {
|
||||
oldnum = 99999;
|
||||
} else {
|
||||
oldstate = &cl.parseEntities[
|
||||
(oldframe->parseEntitiesNum + oldindex) & (MAX_PARSE_ENTITIES-1)];
|
||||
oldnum = oldstate->number;
|
||||
}
|
||||
}
|
||||
if (oldnum == newnum) {
|
||||
// delta from previous state
|
||||
if ( cl_shownet->integer == 3 ) {
|
||||
Com_Printf ("%3i: delta: %i\n", msg->readcount, newnum);
|
||||
}
|
||||
CL_DeltaEntity( msg, newframe, newnum, oldstate, qfalse );
|
||||
|
||||
oldindex++;
|
||||
|
||||
if ( oldindex >= oldframe->numEntities ) {
|
||||
oldnum = 99999;
|
||||
} else {
|
||||
oldstate = &cl.parseEntities[
|
||||
(oldframe->parseEntitiesNum + oldindex) & (MAX_PARSE_ENTITIES-1)];
|
||||
oldnum = oldstate->number;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( oldnum > newnum ) {
|
||||
// delta from baseline
|
||||
if ( cl_shownet->integer == 3 ) {
|
||||
Com_Printf ("%3i: baseline: %i\n", msg->readcount, newnum);
|
||||
}
|
||||
CL_DeltaEntity( msg, newframe, newnum, &cl.entityBaselines[newnum], qfalse );
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// any remaining entities in the old frame are copied over
|
||||
while ( oldnum != 99999 ) {
|
||||
// one or more entities from the old packet are unchanged
|
||||
if ( cl_shownet->integer == 3 ) {
|
||||
Com_Printf ("%3i: unchanged: %i\n", msg->readcount, oldnum);
|
||||
}
|
||||
CL_DeltaEntity( msg, newframe, oldnum, oldstate, qtrue );
|
||||
|
||||
oldindex++;
|
||||
|
||||
if ( oldindex >= oldframe->numEntities ) {
|
||||
oldnum = 99999;
|
||||
} else {
|
||||
oldstate = &cl.parseEntities[
|
||||
(oldframe->parseEntitiesNum + oldindex) & (MAX_PARSE_ENTITIES-1)];
|
||||
oldnum = oldstate->number;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
================
|
||||
CL_ParseSnapshot
|
||||
|
||||
If the snapshot is parsed properly, it will be copied to
|
||||
cl.snap and saved in cl.snapshots[]. If the snapshot is invalid
|
||||
for any reason, no changes to the state will be made at all.
|
||||
================
|
||||
*/
|
||||
void CL_ParseSnapshot( msg_t *msg ) {
|
||||
int len;
|
||||
clSnapshot_t *old;
|
||||
clSnapshot_t newSnap;
|
||||
int deltaNum;
|
||||
int oldMessageNum;
|
||||
int i, packetNum;
|
||||
|
||||
// get the reliable sequence acknowledge number
|
||||
// NOTE: now sent with all server to client messages
|
||||
//clc.reliableAcknowledge = MSG_ReadLong( msg );
|
||||
|
||||
// read in the new snapshot to a temporary buffer
|
||||
// we will only copy to cl.snap if it is valid
|
||||
Com_Memset (&newSnap, 0, sizeof(newSnap));
|
||||
|
||||
// we will have read any new server commands in this
|
||||
// message before we got to svc_snapshot
|
||||
newSnap.serverCommandNum = clc.serverCommandSequence;
|
||||
|
||||
newSnap.serverTime = MSG_ReadLong( msg );
|
||||
|
||||
// if we were just unpaused, we can only *now* really let the
|
||||
// change come into effect or the client hangs.
|
||||
cl_paused->modified = 0;
|
||||
|
||||
newSnap.messageNum = clc.serverMessageSequence;
|
||||
|
||||
deltaNum = MSG_ReadByte( msg );
|
||||
if ( !deltaNum ) {
|
||||
newSnap.deltaNum = -1;
|
||||
} else {
|
||||
newSnap.deltaNum = newSnap.messageNum - deltaNum;
|
||||
}
|
||||
newSnap.snapFlags = MSG_ReadByte( msg );
|
||||
|
||||
// If the frame is delta compressed from data that we
|
||||
// no longer have available, we must suck up the rest of
|
||||
// the frame, but not use it, then ask for a non-compressed
|
||||
// message
|
||||
if ( newSnap.deltaNum <= 0 ) {
|
||||
newSnap.valid = qtrue; // uncompressed frame
|
||||
old = NULL;
|
||||
clc.demowaiting = qfalse; // we can start recording now
|
||||
} else {
|
||||
old = &cl.snapshots[newSnap.deltaNum & PACKET_MASK];
|
||||
if ( !old->valid ) {
|
||||
// should never happen
|
||||
Com_Printf ("Delta from invalid frame (not supposed to happen!).\n");
|
||||
} else if ( old->messageNum != newSnap.deltaNum ) {
|
||||
// The frame that the server did the delta from
|
||||
// is too old, so we can't reconstruct it properly.
|
||||
Com_Printf ("Delta frame too old.\n");
|
||||
} else if ( cl.parseEntitiesNum - old->parseEntitiesNum > MAX_PARSE_ENTITIES-128 ) {
|
||||
Com_Printf ("Delta parseEntitiesNum too old.\n");
|
||||
} else {
|
||||
newSnap.valid = qtrue; // valid delta parse
|
||||
}
|
||||
}
|
||||
|
||||
// read areamask
|
||||
len = MSG_ReadByte( msg );
|
||||
|
||||
if(len > sizeof(newSnap.areamask))
|
||||
{
|
||||
Com_Error (ERR_DROP,"CL_ParseSnapshot: Invalid size %d for areamask.", len);
|
||||
return;
|
||||
}
|
||||
|
||||
MSG_ReadData( msg, &newSnap.areamask, len);
|
||||
|
||||
// read playerinfo
|
||||
SHOWNET( msg, "playerstate" );
|
||||
if ( old ) {
|
||||
MSG_ReadDeltaPlayerstate( msg, &old->ps, &newSnap.ps );
|
||||
} else {
|
||||
MSG_ReadDeltaPlayerstate( msg, NULL, &newSnap.ps );
|
||||
}
|
||||
|
||||
// read packet entities
|
||||
SHOWNET( msg, "packet entities" );
|
||||
CL_ParsePacketEntities( msg, old, &newSnap );
|
||||
|
||||
// if not valid, dump the entire thing now that it has
|
||||
// been properly read
|
||||
if ( !newSnap.valid ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// clear the valid flags of any snapshots between the last
|
||||
// received and this one, so if there was a dropped packet
|
||||
// it won't look like something valid to delta from next
|
||||
// time we wrap around in the buffer
|
||||
oldMessageNum = cl.snap.messageNum + 1;
|
||||
|
||||
if ( newSnap.messageNum - oldMessageNum >= PACKET_BACKUP ) {
|
||||
oldMessageNum = newSnap.messageNum - ( PACKET_BACKUP - 1 );
|
||||
}
|
||||
for ( ; oldMessageNum < newSnap.messageNum ; oldMessageNum++ ) {
|
||||
cl.snapshots[oldMessageNum & PACKET_MASK].valid = qfalse;
|
||||
}
|
||||
|
||||
// copy to the current good spot
|
||||
cl.snap = newSnap;
|
||||
cl.snap.ping = 999;
|
||||
// calculate ping time
|
||||
for ( i = 0 ; i < PACKET_BACKUP ; i++ ) {
|
||||
packetNum = ( clc.netchan.outgoingSequence - 1 - i ) & PACKET_MASK;
|
||||
if ( cl.snap.ps.commandTime >= cl.outPackets[ packetNum ].p_serverTime ) {
|
||||
cl.snap.ping = cls.realtime - cl.outPackets[ packetNum ].p_realtime;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// save the frame off in the backup array for later delta comparisons
|
||||
cl.snapshots[cl.snap.messageNum & PACKET_MASK] = cl.snap;
|
||||
|
||||
if (cl_shownet->integer == 3) {
|
||||
Com_Printf( " snapshot:%i delta:%i ping:%i\n", cl.snap.messageNum,
|
||||
cl.snap.deltaNum, cl.snap.ping );
|
||||
}
|
||||
|
||||
cl.newSnapshots = qtrue;
|
||||
}
|
||||
|
||||
|
||||
//=====================================================================
|
||||
|
||||
int cl_connectedToPureServer;
|
||||
int cl_connectedToCheatServer;
|
||||
|
||||
/*
|
||||
==================
|
||||
CL_SystemInfoChanged
|
||||
|
||||
The systeminfo configstring has been changed, so parse
|
||||
new information out of it. This will happen at every
|
||||
gamestate, and possibly during gameplay.
|
||||
==================
|
||||
*/
|
||||
void CL_SystemInfoChanged( void ) {
|
||||
char *systemInfo;
|
||||
const char *s, *t;
|
||||
char key[BIG_INFO_KEY];
|
||||
char value[BIG_INFO_VALUE];
|
||||
qboolean gameSet;
|
||||
|
||||
systemInfo = cl.gameState.stringData + cl.gameState.stringOffsets[ CS_SYSTEMINFO ];
|
||||
// NOTE TTimo:
|
||||
// when the serverId changes, any further messages we send to the server will use this new serverId
|
||||
// https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=475
|
||||
// in some cases, outdated cp commands might get sent with this news serverId
|
||||
cl.serverId = atoi( Info_ValueForKey( systemInfo, "sv_serverid" ) );
|
||||
|
||||
// don't set any vars when playing a demo
|
||||
if ( clc.demoplaying ) {
|
||||
return;
|
||||
}
|
||||
|
||||
s = Info_ValueForKey( systemInfo, "sv_cheats" );
|
||||
cl_connectedToCheatServer = atoi( s );
|
||||
if ( !cl_connectedToCheatServer ) {
|
||||
Cvar_SetCheatState();
|
||||
}
|
||||
|
||||
// check pure server string
|
||||
s = Info_ValueForKey( systemInfo, "sv_paks" );
|
||||
t = Info_ValueForKey( systemInfo, "sv_pakNames" );
|
||||
FS_PureServerSetLoadedPaks( s, t );
|
||||
|
||||
s = Info_ValueForKey( systemInfo, "sv_referencedPaks" );
|
||||
t = Info_ValueForKey( systemInfo, "sv_referencedPakNames" );
|
||||
FS_PureServerSetReferencedPaks( s, t );
|
||||
|
||||
gameSet = qfalse;
|
||||
// scan through all the variables in the systeminfo and locally set cvars to match
|
||||
s = systemInfo;
|
||||
while ( s ) {
|
||||
int cvar_flags;
|
||||
|
||||
Info_NextPair( &s, key, value );
|
||||
if ( !key[0] ) {
|
||||
break;
|
||||
}
|
||||
|
||||
// ehw!
|
||||
if (!Q_stricmp(key, "fs_game"))
|
||||
{
|
||||
if(FS_CheckDirTraversal(value))
|
||||
{
|
||||
Com_Printf(S_COLOR_YELLOW "WARNING: Server sent invalid fs_game value %s\n", value);
|
||||
continue;
|
||||
}
|
||||
|
||||
gameSet = qtrue;
|
||||
}
|
||||
|
||||
if((cvar_flags = Cvar_Flags(key)) == CVAR_NONEXISTENT)
|
||||
Cvar_Get(key, value, CVAR_SERVER_CREATED | CVAR_ROM);
|
||||
else
|
||||
{
|
||||
// If this cvar may not be modified by a server discard the value.
|
||||
if(!(cvar_flags & (CVAR_SYSTEMINFO | CVAR_SERVER_CREATED)))
|
||||
{
|
||||
Com_Printf(S_COLOR_YELLOW "WARNING: server is not allowed to set %s=%s\n", key, value);
|
||||
continue;
|
||||
}
|
||||
|
||||
Cvar_Set(key, value);
|
||||
}
|
||||
}
|
||||
// if game folder should not be set and it is set at the client side
|
||||
if ( !gameSet && *Cvar_VariableString("fs_game") ) {
|
||||
Cvar_Set( "fs_game", "" );
|
||||
}
|
||||
cl_connectedToPureServer = Cvar_VariableValue( "sv_pure" );
|
||||
}
|
||||
|
||||
/*
|
||||
==================
|
||||
CL_ParseServerInfo
|
||||
==================
|
||||
*/
|
||||
static void CL_ParseServerInfo(void)
|
||||
{
|
||||
const char *serverInfo;
|
||||
|
||||
serverInfo = cl.gameState.stringData
|
||||
+ cl.gameState.stringOffsets[ CS_SERVERINFO ];
|
||||
|
||||
clc.sv_allowDownload = atoi(Info_ValueForKey(serverInfo,
|
||||
"sv_allowDownload"));
|
||||
Q_strncpyz(clc.sv_dlURL,
|
||||
Info_ValueForKey(serverInfo, "sv_dlURL"),
|
||||
sizeof(clc.sv_dlURL));
|
||||
}
|
||||
|
||||
/*
|
||||
==================
|
||||
CL_ParseGamestate
|
||||
==================
|
||||
*/
|
||||
void CL_ParseGamestate( msg_t *msg ) {
|
||||
int i;
|
||||
entityState_t *es;
|
||||
int newnum;
|
||||
entityState_t nullstate;
|
||||
int cmd;
|
||||
char *s;
|
||||
|
||||
Con_Close();
|
||||
|
||||
clc.connectPacketCount = 0;
|
||||
|
||||
// wipe local client state
|
||||
CL_ClearState();
|
||||
|
||||
// a gamestate always marks a server command sequence
|
||||
clc.serverCommandSequence = MSG_ReadLong( msg );
|
||||
|
||||
// parse all the configstrings and baselines
|
||||
cl.gameState.dataCount = 1; // leave a 0 at the beginning for uninitialized configstrings
|
||||
while ( 1 ) {
|
||||
cmd = MSG_ReadByte( msg );
|
||||
|
||||
if ( cmd == svc_EOF ) {
|
||||
break;
|
||||
}
|
||||
|
||||
if ( cmd == svc_configstring ) {
|
||||
int len;
|
||||
|
||||
i = MSG_ReadShort( msg );
|
||||
if ( i < 0 || i >= MAX_CONFIGSTRINGS ) {
|
||||
Com_Error( ERR_DROP, "configstring > MAX_CONFIGSTRINGS" );
|
||||
}
|
||||
s = MSG_ReadBigString( msg );
|
||||
len = strlen( s );
|
||||
|
||||
if ( len + 1 + cl.gameState.dataCount > MAX_GAMESTATE_CHARS ) {
|
||||
Com_Error( ERR_DROP, "MAX_GAMESTATE_CHARS exceeded" );
|
||||
}
|
||||
|
||||
// append it to the gameState string buffer
|
||||
cl.gameState.stringOffsets[ i ] = cl.gameState.dataCount;
|
||||
Com_Memcpy( cl.gameState.stringData + cl.gameState.dataCount, s, len + 1 );
|
||||
cl.gameState.dataCount += len + 1;
|
||||
} else if ( cmd == svc_baseline ) {
|
||||
newnum = MSG_ReadBits( msg, GENTITYNUM_BITS );
|
||||
if ( newnum < 0 || newnum >= MAX_GENTITIES ) {
|
||||
Com_Error( ERR_DROP, "Baseline number out of range: %i", newnum );
|
||||
}
|
||||
Com_Memset (&nullstate, 0, sizeof(nullstate));
|
||||
es = &cl.entityBaselines[ newnum ];
|
||||
MSG_ReadDeltaEntity( msg, &nullstate, es, newnum );
|
||||
} else {
|
||||
Com_Error( ERR_DROP, "CL_ParseGamestate: bad command byte" );
|
||||
}
|
||||
}
|
||||
|
||||
clc.clientNum = MSG_ReadLong(msg);
|
||||
// read the checksum feed
|
||||
clc.checksumFeed = MSG_ReadLong( msg );
|
||||
|
||||
// parse useful values out of CS_SERVERINFO
|
||||
CL_ParseServerInfo();
|
||||
|
||||
// parse serverId and other cvars
|
||||
CL_SystemInfoChanged();
|
||||
|
||||
// stop recording now so the demo won't have an unnecessary level load at the end.
|
||||
if(cl_autoRecordDemo->integer && clc.demorecording)
|
||||
CL_StopRecord_f();
|
||||
|
||||
// reinitialize the filesystem if the game directory has changed
|
||||
FS_ConditionalRestart( clc.checksumFeed );
|
||||
|
||||
// This used to call CL_StartHunkUsers, but now we enter the download state before loading the
|
||||
// cgame
|
||||
CL_InitDownloads();
|
||||
|
||||
// make sure the game starts
|
||||
Cvar_Set( "cl_paused", "0" );
|
||||
}
|
||||
|
||||
|
||||
//=====================================================================
|
||||
|
||||
/*
|
||||
=====================
|
||||
CL_ParseDownload
|
||||
|
||||
A download message has been received from the server
|
||||
=====================
|
||||
*/
|
||||
void CL_ParseDownload ( msg_t *msg ) {
|
||||
int size;
|
||||
unsigned char data[MAX_MSGLEN];
|
||||
int block;
|
||||
|
||||
if (!*clc.downloadTempName) {
|
||||
Com_Printf("Server sending download, but no download was requested\n");
|
||||
CL_AddReliableCommand( "stopdl" );
|
||||
return;
|
||||
}
|
||||
|
||||
// read the data
|
||||
block = MSG_ReadShort ( msg );
|
||||
|
||||
if ( !block )
|
||||
{
|
||||
// block zero is special, contains file size
|
||||
clc.downloadSize = MSG_ReadLong ( msg );
|
||||
|
||||
Cvar_SetValue( "cl_downloadSize", clc.downloadSize );
|
||||
|
||||
if (clc.downloadSize < 0)
|
||||
{
|
||||
Com_Error(ERR_DROP, MSG_ReadString( msg ) );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
size = MSG_ReadShort ( msg );
|
||||
if (size < 0 || size > sizeof(data))
|
||||
{
|
||||
Com_Error(ERR_DROP, "CL_ParseDownload: Invalid size %d for download chunk.", size);
|
||||
return;
|
||||
}
|
||||
|
||||
MSG_ReadData(msg, data, size);
|
||||
|
||||
if (clc.downloadBlock != block) {
|
||||
Com_DPrintf( "CL_ParseDownload: Expected block %d, got %d\n", clc.downloadBlock, block);
|
||||
return;
|
||||
}
|
||||
|
||||
// open the file if not opened yet
|
||||
if (!clc.download)
|
||||
{
|
||||
clc.download = FS_SV_FOpenFileWrite( clc.downloadTempName );
|
||||
|
||||
if (!clc.download) {
|
||||
Com_Printf( "Could not create %s\n", clc.downloadTempName );
|
||||
CL_AddReliableCommand( "stopdl" );
|
||||
CL_NextDownload();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (size)
|
||||
FS_Write( data, size, clc.download );
|
||||
|
||||
CL_AddReliableCommand( va("nextdl %d", clc.downloadBlock) );
|
||||
clc.downloadBlock++;
|
||||
|
||||
clc.downloadCount += size;
|
||||
|
||||
// So UI gets access to it
|
||||
Cvar_SetValue( "cl_downloadCount", clc.downloadCount );
|
||||
|
||||
if (!size) { // A zero length block means EOF
|
||||
if (clc.download) {
|
||||
FS_FCloseFile( clc.download );
|
||||
clc.download = 0;
|
||||
|
||||
// rename the file
|
||||
FS_SV_Rename ( clc.downloadTempName, clc.downloadName );
|
||||
}
|
||||
*clc.downloadTempName = *clc.downloadName = 0;
|
||||
Cvar_Set( "cl_downloadName", "" );
|
||||
|
||||
// send intentions now
|
||||
// We need this because without it, we would hold the last nextdl and then start
|
||||
// loading right away. If we take a while to load, the server is happily trying
|
||||
// to send us that last block over and over.
|
||||
// Write it twice to help make sure we acknowledge the download
|
||||
CL_WritePacket();
|
||||
CL_WritePacket();
|
||||
|
||||
// get another file if needed
|
||||
CL_NextDownload ();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
=====================
|
||||
CL_ParseCommandString
|
||||
|
||||
Command strings are just saved off until cgame asks for them
|
||||
when it transitions a snapshot
|
||||
=====================
|
||||
*/
|
||||
void CL_ParseCommandString( msg_t *msg ) {
|
||||
char *s;
|
||||
int seq;
|
||||
int index;
|
||||
|
||||
seq = MSG_ReadLong( msg );
|
||||
s = MSG_ReadString( msg );
|
||||
|
||||
// see if we have already executed stored it off
|
||||
if ( clc.serverCommandSequence >= seq ) {
|
||||
return;
|
||||
}
|
||||
clc.serverCommandSequence = seq;
|
||||
|
||||
index = seq & (MAX_RELIABLE_COMMANDS-1);
|
||||
Q_strncpyz( clc.serverCommands[ index ], s, sizeof( clc.serverCommands[ index ] ) );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
=====================
|
||||
CL_ParseServerMessage
|
||||
=====================
|
||||
*/
|
||||
void CL_ParseServerMessage( msg_t *msg ) {
|
||||
int cmd;
|
||||
|
||||
if ( cl_shownet->integer == 1 ) {
|
||||
Com_Printf ("%i ",msg->cursize);
|
||||
} else if ( cl_shownet->integer >= 2 ) {
|
||||
Com_Printf ("------------------\n");
|
||||
}
|
||||
|
||||
MSG_Bitstream(msg);
|
||||
|
||||
// get the reliable sequence acknowledge number
|
||||
clc.reliableAcknowledge = MSG_ReadLong( msg );
|
||||
//
|
||||
if ( clc.reliableAcknowledge < clc.reliableSequence - MAX_RELIABLE_COMMANDS ) {
|
||||
clc.reliableAcknowledge = clc.reliableSequence;
|
||||
}
|
||||
|
||||
//
|
||||
// parse the message
|
||||
//
|
||||
while ( 1 ) {
|
||||
if ( msg->readcount > msg->cursize ) {
|
||||
Com_Error (ERR_DROP,"CL_ParseServerMessage: read past end of server message");
|
||||
break;
|
||||
}
|
||||
|
||||
cmd = MSG_ReadByte( msg );
|
||||
|
||||
if ( cmd == svc_EOF) {
|
||||
SHOWNET( msg, "END OF MESSAGE" );
|
||||
break;
|
||||
}
|
||||
|
||||
if ( cl_shownet->integer >= 2 ) {
|
||||
if ( !svc_strings[cmd] ) {
|
||||
Com_Printf( "%3i:BAD CMD %i\n", msg->readcount-1, cmd );
|
||||
} else {
|
||||
SHOWNET( msg, svc_strings[cmd] );
|
||||
}
|
||||
}
|
||||
|
||||
// other commands
|
||||
switch ( cmd ) {
|
||||
default:
|
||||
Com_Error (ERR_DROP,"CL_ParseServerMessage: Illegible server message\n");
|
||||
break;
|
||||
case svc_nop:
|
||||
break;
|
||||
case svc_serverCommand:
|
||||
CL_ParseCommandString( msg );
|
||||
break;
|
||||
case svc_gamestate:
|
||||
CL_ParseGamestate( msg );
|
||||
break;
|
||||
case svc_snapshot:
|
||||
CL_ParseSnapshot( msg );
|
||||
break;
|
||||
case svc_download:
|
||||
CL_ParseDownload( msg );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,524 +0,0 @@
|
||||
/*
|
||||
===========================================================================
|
||||
Copyright (C) 1999-2005 Id Software, Inc.
|
||||
Copyright (C) 2000-2006 Tim Angus
|
||||
|
||||
This file is part of Tremulous.
|
||||
|
||||
Tremulous is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
Tremulous is distributed in the hope that it will be
|
||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Tremulous; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
===========================================================================
|
||||
*/
|
||||
// cl_scrn.c -- master for refresh, status bar, console, chat, notify, etc
|
||||
|
||||
#include "client.h"
|
||||
|
||||
qboolean scr_initialized; // ready to draw
|
||||
|
||||
cvar_t *cl_timegraph;
|
||||
cvar_t *cl_debuggraph;
|
||||
cvar_t *cl_graphheight;
|
||||
cvar_t *cl_graphscale;
|
||||
cvar_t *cl_graphshift;
|
||||
|
||||
/*
|
||||
================
|
||||
SCR_DrawNamedPic
|
||||
|
||||
Coordinates are 640*480 virtual values
|
||||
=================
|
||||
*/
|
||||
void SCR_DrawNamedPic( float x, float y, float width, float height, const char *picname ) {
|
||||
qhandle_t hShader;
|
||||
|
||||
assert( width != 0 );
|
||||
|
||||
hShader = re.RegisterShader( picname );
|
||||
SCR_AdjustFrom640( &x, &y, &width, &height );
|
||||
re.DrawStretchPic( x, y, width, height, 0, 0, 1, 1, hShader );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
================
|
||||
SCR_AdjustFrom640
|
||||
|
||||
Adjusted for resolution and screen aspect ratio
|
||||
================
|
||||
*/
|
||||
void SCR_AdjustFrom640( float *x, float *y, float *w, float *h ) {
|
||||
float xscale;
|
||||
float yscale;
|
||||
|
||||
#if 0
|
||||
// adjust for wide screens
|
||||
if ( cls.glconfig.vidWidth * 480 > cls.glconfig.vidHeight * 640 ) {
|
||||
*x += 0.5 * ( cls.glconfig.vidWidth - ( cls.glconfig.vidHeight * 640 / 480 ) );
|
||||
}
|
||||
#endif
|
||||
|
||||
// scale for screen sizes
|
||||
xscale = cls.glconfig.vidWidth / 640.0;
|
||||
yscale = cls.glconfig.vidHeight / 480.0;
|
||||
if ( x ) {
|
||||
*x *= xscale;
|
||||
}
|
||||
if ( y ) {
|
||||
*y *= yscale;
|
||||
}
|
||||
if ( w ) {
|
||||
*w *= xscale;
|
||||
}
|
||||
if ( h ) {
|
||||
*h *= yscale;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
SCR_FillRect
|
||||
|
||||
Coordinates are 640*480 virtual values
|
||||
=================
|
||||
*/
|
||||
void SCR_FillRect( float x, float y, float width, float height, const float *color ) {
|
||||
re.SetColor( color );
|
||||
|
||||
SCR_AdjustFrom640( &x, &y, &width, &height );
|
||||
re.DrawStretchPic( x, y, width, height, 0, 0, 0, 0, cls.whiteShader );
|
||||
|
||||
re.SetColor( NULL );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
================
|
||||
SCR_DrawPic
|
||||
|
||||
Coordinates are 640*480 virtual values
|
||||
=================
|
||||
*/
|
||||
void SCR_DrawPic( float x, float y, float width, float height, qhandle_t hShader ) {
|
||||
SCR_AdjustFrom640( &x, &y, &width, &height );
|
||||
re.DrawStretchPic( x, y, width, height, 0, 0, 1, 1, hShader );
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
** SCR_DrawChar
|
||||
** chars are drawn at 640*480 virtual screen size
|
||||
*/
|
||||
static void SCR_DrawChar( int x, int y, float size, int ch ) {
|
||||
int row, col;
|
||||
float frow, fcol;
|
||||
float ax, ay, aw, ah;
|
||||
|
||||
ch &= 255;
|
||||
|
||||
if ( ch == ' ' ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( y < -size ) {
|
||||
return;
|
||||
}
|
||||
|
||||
ax = x;
|
||||
ay = y;
|
||||
aw = size;
|
||||
ah = size;
|
||||
SCR_AdjustFrom640( &ax, &ay, &aw, &ah );
|
||||
|
||||
row = ch>>4;
|
||||
col = ch&15;
|
||||
|
||||
frow = row*0.0625;
|
||||
fcol = col*0.0625;
|
||||
size = 0.0625;
|
||||
|
||||
re.DrawStretchPic( ax, ay, aw, ah,
|
||||
fcol, frow,
|
||||
fcol + size, frow + size,
|
||||
cls.charSetShader );
|
||||
}
|
||||
|
||||
/*
|
||||
** SCR_DrawSmallChar
|
||||
** small chars are drawn at native screen resolution
|
||||
*/
|
||||
void SCR_DrawSmallChar( int x, int y, int ch ) {
|
||||
int row, col;
|
||||
float frow, fcol;
|
||||
float size;
|
||||
|
||||
ch &= 255;
|
||||
|
||||
if ( ch == ' ' ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( y < -SMALLCHAR_HEIGHT ) {
|
||||
return;
|
||||
}
|
||||
|
||||
row = ch>>4;
|
||||
col = ch&15;
|
||||
|
||||
frow = row*0.0625;
|
||||
fcol = col*0.0625;
|
||||
size = 0.0625;
|
||||
|
||||
re.DrawStretchPic( x, y, SMALLCHAR_WIDTH, SMALLCHAR_HEIGHT,
|
||||
fcol, frow,
|
||||
fcol + size, frow + size,
|
||||
cls.charSetShader );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
==================
|
||||
SCR_DrawBigString[Color]
|
||||
|
||||
Draws a multi-colored string with a drop shadow, optionally forcing
|
||||
to a fixed color.
|
||||
|
||||
Coordinates are at 640 by 480 virtual resolution
|
||||
==================
|
||||
*/
|
||||
void SCR_DrawStringExt( int x, int y, float size, const char *string, float *setColor, qboolean forceColor ) {
|
||||
vec4_t color;
|
||||
const char *s;
|
||||
int xx;
|
||||
|
||||
// draw the drop shadow
|
||||
color[0] = color[1] = color[2] = 0;
|
||||
color[3] = setColor[3];
|
||||
re.SetColor( color );
|
||||
s = string;
|
||||
xx = x;
|
||||
while ( *s ) {
|
||||
if ( Q_IsColorString( s ) ) {
|
||||
s += 2;
|
||||
continue;
|
||||
}
|
||||
SCR_DrawChar( xx+2, y+2, size, *s );
|
||||
xx += size;
|
||||
s++;
|
||||
}
|
||||
|
||||
|
||||
// draw the colored text
|
||||
s = string;
|
||||
xx = x;
|
||||
re.SetColor( setColor );
|
||||
while ( *s ) {
|
||||
if ( Q_IsColorString( s ) ) {
|
||||
if ( !forceColor ) {
|
||||
Com_Memcpy( color, g_color_table[ColorIndex(*(s+1))], sizeof( color ) );
|
||||
color[3] = setColor[3];
|
||||
re.SetColor( color );
|
||||
}
|
||||
s += 2;
|
||||
continue;
|
||||
}
|
||||
SCR_DrawChar( xx, y, size, *s );
|
||||
xx += size;
|
||||
s++;
|
||||
}
|
||||
re.SetColor( NULL );
|
||||
}
|
||||
|
||||
|
||||
void SCR_DrawBigString( int x, int y, const char *s, float alpha ) {
|
||||
float color[4];
|
||||
|
||||
color[0] = color[1] = color[2] = 1.0;
|
||||
color[3] = alpha;
|
||||
SCR_DrawStringExt( x, y, BIGCHAR_WIDTH, s, color, qfalse );
|
||||
}
|
||||
|
||||
void SCR_DrawBigStringColor( int x, int y, const char *s, vec4_t color ) {
|
||||
SCR_DrawStringExt( x, y, BIGCHAR_WIDTH, s, color, qtrue );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
==================
|
||||
SCR_DrawSmallString[Color]
|
||||
|
||||
Draws a multi-colored string with a drop shadow, optionally forcing
|
||||
to a fixed color.
|
||||
|
||||
Coordinates are at 640 by 480 virtual resolution
|
||||
==================
|
||||
*/
|
||||
void SCR_DrawSmallStringExt( int x, int y, const char *string, float *setColor, qboolean forceColor ) {
|
||||
vec4_t color;
|
||||
const char *s;
|
||||
int xx;
|
||||
|
||||
// draw the colored text
|
||||
s = string;
|
||||
xx = x;
|
||||
re.SetColor( setColor );
|
||||
while ( *s ) {
|
||||
if ( Q_IsColorString( s ) ) {
|
||||
if ( !forceColor ) {
|
||||
Com_Memcpy( color, g_color_table[ColorIndex(*(s+1))], sizeof( color ) );
|
||||
color[3] = setColor[3];
|
||||
re.SetColor( color );
|
||||
}
|
||||
s += 2;
|
||||
continue;
|
||||
}
|
||||
SCR_DrawSmallChar( xx, y, *s );
|
||||
xx += SMALLCHAR_WIDTH;
|
||||
s++;
|
||||
}
|
||||
re.SetColor( NULL );
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
** SCR_Strlen -- skips color escape codes
|
||||
*/
|
||||
static int SCR_Strlen( const char *str ) {
|
||||
const char *s = str;
|
||||
int count = 0;
|
||||
|
||||
while ( *s ) {
|
||||
if ( Q_IsColorString( s ) ) {
|
||||
s += 2;
|
||||
} else {
|
||||
count++;
|
||||
s++;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
/*
|
||||
** SCR_GetBigStringWidth
|
||||
*/
|
||||
int SCR_GetBigStringWidth( const char *str ) {
|
||||
return SCR_Strlen( str ) * 16;
|
||||
}
|
||||
|
||||
|
||||
//===============================================================================
|
||||
|
||||
/*
|
||||
===============================================================================
|
||||
|
||||
DEBUG GRAPH
|
||||
|
||||
===============================================================================
|
||||
*/
|
||||
|
||||
typedef struct
|
||||
{
|
||||
float value;
|
||||
int color;
|
||||
} graphsamp_t;
|
||||
|
||||
static int current;
|
||||
static graphsamp_t values[1024];
|
||||
|
||||
/*
|
||||
==============
|
||||
SCR_DebugGraph
|
||||
==============
|
||||
*/
|
||||
void SCR_DebugGraph (float value, int color)
|
||||
{
|
||||
values[current&1023].value = value;
|
||||
values[current&1023].color = color;
|
||||
current++;
|
||||
}
|
||||
|
||||
/*
|
||||
==============
|
||||
SCR_DrawDebugGraph
|
||||
==============
|
||||
*/
|
||||
void SCR_DrawDebugGraph (void)
|
||||
{
|
||||
int a, x, y, w, i, h;
|
||||
float v;
|
||||
int color;
|
||||
|
||||
//
|
||||
// draw the graph
|
||||
//
|
||||
w = cls.glconfig.vidWidth;
|
||||
x = 0;
|
||||
y = cls.glconfig.vidHeight;
|
||||
re.SetColor( g_color_table[0] );
|
||||
re.DrawStretchPic(x, y - cl_graphheight->integer,
|
||||
w, cl_graphheight->integer, 0, 0, 0, 0, cls.whiteShader );
|
||||
re.SetColor( NULL );
|
||||
|
||||
for (a=0 ; a<w ; a++)
|
||||
{
|
||||
i = (current-1-a+1024) & 1023;
|
||||
v = values[i].value;
|
||||
color = values[i].color;
|
||||
v = v * cl_graphscale->integer + cl_graphshift->integer;
|
||||
|
||||
if (v < 0)
|
||||
v += cl_graphheight->integer * (1+(int)(-v / cl_graphheight->integer));
|
||||
h = (int)v % cl_graphheight->integer;
|
||||
re.DrawStretchPic( x+w-1-a, y - h, 1, h, 0, 0, 0, 0, cls.whiteShader );
|
||||
}
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
|
||||
/*
|
||||
==================
|
||||
SCR_Init
|
||||
==================
|
||||
*/
|
||||
void SCR_Init( void ) {
|
||||
cl_timegraph = Cvar_Get ("timegraph", "0", CVAR_CHEAT);
|
||||
cl_debuggraph = Cvar_Get ("debuggraph", "0", CVAR_CHEAT);
|
||||
cl_graphheight = Cvar_Get ("graphheight", "32", CVAR_CHEAT);
|
||||
cl_graphscale = Cvar_Get ("graphscale", "1", CVAR_CHEAT);
|
||||
cl_graphshift = Cvar_Get ("graphshift", "0", CVAR_CHEAT);
|
||||
|
||||
scr_initialized = qtrue;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================
|
||||
|
||||
/*
|
||||
==================
|
||||
SCR_DrawScreenField
|
||||
|
||||
This will be called twice if rendering in stereo mode
|
||||
==================
|
||||
*/
|
||||
void SCR_DrawScreenField( stereoFrame_t stereoFrame ) {
|
||||
re.BeginFrame( stereoFrame );
|
||||
|
||||
// wide aspect ratio screens need to have the sides cleared
|
||||
// unless they are displaying game renderings
|
||||
if ( cls.state != CA_ACTIVE && cls.state != CA_CINEMATIC ) {
|
||||
if ( cls.glconfig.vidWidth * 480 > cls.glconfig.vidHeight * 640 ) {
|
||||
re.SetColor( g_color_table[0] );
|
||||
re.DrawStretchPic( 0, 0, cls.glconfig.vidWidth, cls.glconfig.vidHeight, 0, 0, 0, 0, cls.whiteShader );
|
||||
re.SetColor( NULL );
|
||||
}
|
||||
}
|
||||
|
||||
if ( !uivm ) {
|
||||
Com_DPrintf("draw screen without UI loaded\n");
|
||||
return;
|
||||
}
|
||||
|
||||
// if the menu is going to cover the entire screen, we
|
||||
// don't need to render anything under it
|
||||
if ( !VM_Call( uivm, UI_IS_FULLSCREEN )) {
|
||||
switch( cls.state ) {
|
||||
default:
|
||||
Com_Error( ERR_FATAL, "SCR_DrawScreenField: bad cls.state" );
|
||||
break;
|
||||
case CA_CINEMATIC:
|
||||
SCR_DrawCinematic();
|
||||
break;
|
||||
case CA_DISCONNECTED:
|
||||
// force menu up
|
||||
S_StopAllSounds();
|
||||
VM_Call( uivm, UI_SET_ACTIVE_MENU, UIMENU_MAIN );
|
||||
break;
|
||||
case CA_CONNECTING:
|
||||
case CA_CHALLENGING:
|
||||
case CA_CONNECTED:
|
||||
// connecting clients will only show the connection dialog
|
||||
// refresh to update the time
|
||||
VM_Call( uivm, UI_REFRESH, cls.realtime );
|
||||
VM_Call( uivm, UI_DRAW_CONNECT_SCREEN, qfalse );
|
||||
break;
|
||||
case CA_LOADING:
|
||||
case CA_PRIMED:
|
||||
// draw the game information screen and loading progress
|
||||
CL_CGameRendering( stereoFrame );
|
||||
|
||||
// also draw the connection information, so it doesn't
|
||||
// flash away too briefly on local or lan games
|
||||
// refresh to update the time
|
||||
VM_Call( uivm, UI_REFRESH, cls.realtime );
|
||||
VM_Call( uivm, UI_DRAW_CONNECT_SCREEN, qtrue );
|
||||
break;
|
||||
case CA_ACTIVE:
|
||||
CL_CGameRendering( stereoFrame );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// the menu draws next
|
||||
if ( cls.keyCatchers & KEYCATCH_UI && uivm ) {
|
||||
VM_Call( uivm, UI_REFRESH, cls.realtime );
|
||||
}
|
||||
|
||||
// console draws next
|
||||
Con_DrawConsole ();
|
||||
|
||||
// debug graph can be drawn on top of anything
|
||||
if ( cl_debuggraph->integer || cl_timegraph->integer || cl_debugMove->integer ) {
|
||||
SCR_DrawDebugGraph ();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
==================
|
||||
SCR_UpdateScreen
|
||||
|
||||
This is called every frame, and can also be called explicitly to flush
|
||||
text to the screen.
|
||||
==================
|
||||
*/
|
||||
void SCR_UpdateScreen( void ) {
|
||||
static int recursive;
|
||||
|
||||
if ( !scr_initialized ) {
|
||||
return; // not initialized yet
|
||||
}
|
||||
|
||||
if ( ++recursive > 2 ) {
|
||||
Com_Error( ERR_FATAL, "SCR_UpdateScreen: recursively called" );
|
||||
}
|
||||
recursive = 1;
|
||||
|
||||
// if running in stereo, we need to draw the frame twice
|
||||
if ( cls.glconfig.stereoEnabled ) {
|
||||
SCR_DrawScreenField( STEREO_LEFT );
|
||||
SCR_DrawScreenField( STEREO_RIGHT );
|
||||
} else {
|
||||
SCR_DrawScreenField( STEREO_CENTER );
|
||||
}
|
||||
|
||||
if ( com_speeds->integer ) {
|
||||
re.EndFrame( &time_frontend, &time_backend );
|
||||
} else {
|
||||
re.EndFrame( NULL, NULL );
|
||||
}
|
||||
|
||||
recursive = 0;
|
||||
}
|
||||
|
||||
-1102
File diff suppressed because it is too large.
Load diff
@@ -1,561 +0,0 @@
|
||||
/*
|
||||
===========================================================================
|
||||
Copyright (C) 1999-2005 Id Software, Inc.
|
||||
Copyright (C) 2000-2006 Tim Angus
|
||||
|
||||
This file is part of Tremulous.
|
||||
|
||||
Tremulous is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
Tremulous is distributed in the hope that it will be
|
||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Tremulous; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
===========================================================================
|
||||
*/
|
||||
// client.h -- primary header for client
|
||||
|
||||
#include "../qcommon/q_shared.h"
|
||||
#include "../qcommon/qcommon.h"
|
||||
#include "../renderer/tr_public.h"
|
||||
#include "../ui/ui_public.h"
|
||||
#include "keys.h"
|
||||
#include "snd_public.h"
|
||||
#include "../cgame/cg_public.h"
|
||||
#include "../game/bg_public.h"
|
||||
|
||||
#if USE_CURL
|
||||
#include "cl_curl.h"
|
||||
#endif /* USE_CURL */
|
||||
|
||||
// file full of random crap that gets used to create cl_guid
|
||||
#define QKEY_FILE "qkey"
|
||||
#define QKEY_SIZE 2048
|
||||
|
||||
#define RETRANSMIT_TIMEOUT 3000 // time between connection packet retransmits
|
||||
|
||||
// snapshots are a view of the server at a given time
|
||||
typedef struct {
|
||||
qboolean valid; // cleared if delta parsing was invalid
|
||||
int snapFlags; // rate delayed and dropped commands
|
||||
|
||||
int serverTime; // server time the message is valid for (in msec)
|
||||
|
||||
int messageNum; // copied from netchan->incoming_sequence
|
||||
int deltaNum; // messageNum the delta is from
|
||||
int ping; // time from when cmdNum-1 was sent to time packet was reeceived
|
||||
byte areamask[MAX_MAP_AREA_BYTES]; // portalarea visibility bits
|
||||
|
||||
int cmdNum; // the next cmdNum the server is expecting
|
||||
playerState_t ps; // complete information about the current player at this time
|
||||
|
||||
int numEntities; // all of the entities that need to be presented
|
||||
int parseEntitiesNum; // at the time of this snapshot
|
||||
|
||||
int serverCommandNum; // execute all commands up to this before
|
||||
// making the snapshot current
|
||||
} clSnapshot_t;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
=============================================================================
|
||||
|
||||
the clientActive_t structure is wiped completely at every
|
||||
new gamestate_t, potentially several times during an established connection
|
||||
|
||||
=============================================================================
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
int p_cmdNumber; // cl.cmdNumber when packet was sent
|
||||
int p_serverTime; // usercmd->serverTime when packet was sent
|
||||
int p_realtime; // cls.realtime when packet was sent
|
||||
} outPacket_t;
|
||||
|
||||
// the parseEntities array must be large enough to hold PACKET_BACKUP frames of
|
||||
// entities, so that when a delta compressed message arives from the server
|
||||
// it can be un-deltad from the original
|
||||
#define MAX_PARSE_ENTITIES 2048
|
||||
|
||||
extern int g_console_field_width;
|
||||
|
||||
typedef struct {
|
||||
int timeoutcount; // it requres several frames in a timeout condition
|
||||
// to disconnect, preventing debugging breaks from
|
||||
// causing immediate disconnects on continue
|
||||
clSnapshot_t snap; // latest received from server
|
||||
|
||||
int serverTime; // may be paused during play
|
||||
int oldServerTime; // to prevent time from flowing bakcwards
|
||||
int oldFrameServerTime; // to check tournament restarts
|
||||
int serverTimeDelta; // cl.serverTime = cls.realtime + cl.serverTimeDelta
|
||||
// this value changes as net lag varies
|
||||
qboolean extrapolatedSnapshot; // set if any cgame frame has been forced to extrapolate
|
||||
// cleared when CL_AdjustTimeDelta looks at it
|
||||
qboolean newSnapshots; // set on parse of any valid packet
|
||||
|
||||
gameState_t gameState; // configstrings
|
||||
char mapname[MAX_QPATH]; // extracted from CS_SERVERINFO
|
||||
|
||||
int parseEntitiesNum; // index (not anded off) into cl_parse_entities[]
|
||||
|
||||
int mouseDx[2], mouseDy[2]; // added to by mouse events
|
||||
int mouseIndex;
|
||||
int joystickAxis[MAX_JOYSTICK_AXIS]; // set by joystick events
|
||||
|
||||
// cgame communicates a few values to the client system
|
||||
int cgameUserCmdValue; // current weapon to add to usercmd_t
|
||||
float cgameSensitivity;
|
||||
|
||||
// cmds[cmdNumber] is the predicted command, [cmdNumber-1] is the last
|
||||
// properly generated command
|
||||
usercmd_t cmds[CMD_BACKUP]; // each mesage will send several old cmds
|
||||
int cmdNumber; // incremented each frame, because multiple
|
||||
// frames may need to be packed into a single packet
|
||||
|
||||
outPacket_t outPackets[PACKET_BACKUP]; // information about each packet we have sent out
|
||||
|
||||
// the client maintains its own idea of view angles, which are
|
||||
// sent to the server each frame. It is cleared to 0 upon entering each level.
|
||||
// the server sends a delta each frame which is added to the locally
|
||||
// tracked view angles to account for standing on rotating objects,
|
||||
// and teleport direction changes
|
||||
vec3_t viewangles;
|
||||
|
||||
int serverId; // included in each client message so the server
|
||||
// can tell if it is for a prior map_restart
|
||||
// big stuff at end of structure so most offsets are 15 bits or less
|
||||
clSnapshot_t snapshots[PACKET_BACKUP];
|
||||
|
||||
entityState_t entityBaselines[MAX_GENTITIES]; // for delta compression when not in previous frame
|
||||
|
||||
entityState_t parseEntities[MAX_PARSE_ENTITIES];
|
||||
} clientActive_t;
|
||||
|
||||
extern clientActive_t cl;
|
||||
|
||||
/*
|
||||
=============================================================================
|
||||
|
||||
the clientConnection_t structure is wiped when disconnecting from a server,
|
||||
either to go to a full screen console, play a demo, or connect to a different server
|
||||
|
||||
A connection can be to either a server through the network layer or a
|
||||
demo through a file.
|
||||
|
||||
=============================================================================
|
||||
*/
|
||||
|
||||
|
||||
typedef struct {
|
||||
|
||||
int clientNum;
|
||||
int lastPacketSentTime; // for retransmits during connection
|
||||
int lastPacketTime; // for timeouts
|
||||
|
||||
netadr_t serverAddress;
|
||||
int connectTime; // for connection retransmits
|
||||
int connectPacketCount; // for display on connection dialog
|
||||
char serverMessage[MAX_STRING_TOKENS]; // for display on connection dialog
|
||||
|
||||
int challenge; // from the server to use for connecting
|
||||
int checksumFeed; // from the server for checksum calculations
|
||||
|
||||
// these are our reliable messages that go to the server
|
||||
int reliableSequence;
|
||||
int reliableAcknowledge; // the last one the server has executed
|
||||
char reliableCommands[MAX_RELIABLE_COMMANDS][MAX_STRING_CHARS];
|
||||
|
||||
// server message (unreliable) and command (reliable) sequence
|
||||
// numbers are NOT cleared at level changes, but continue to
|
||||
// increase as long as the connection is valid
|
||||
|
||||
// message sequence is used by both the network layer and the
|
||||
// delta compression layer
|
||||
int serverMessageSequence;
|
||||
|
||||
// reliable messages received from server
|
||||
int serverCommandSequence;
|
||||
int lastExecutedServerCommand; // last server command grabbed or executed with CL_GetServerCommand
|
||||
char serverCommands[MAX_RELIABLE_COMMANDS][MAX_STRING_CHARS];
|
||||
|
||||
// file transfer from server
|
||||
fileHandle_t download;
|
||||
char downloadTempName[MAX_OSPATH];
|
||||
char downloadName[MAX_OSPATH];
|
||||
#ifdef USE_CURL
|
||||
qboolean cURLEnabled;
|
||||
qboolean cURLUsed;
|
||||
qboolean cURLDisconnected;
|
||||
char downloadURL[MAX_OSPATH];
|
||||
CURL *downloadCURL;
|
||||
CURLM *downloadCURLM;
|
||||
#endif /* USE_CURL */
|
||||
int sv_allowDownload;
|
||||
char sv_dlURL[MAX_CVAR_VALUE_STRING];
|
||||
int downloadNumber;
|
||||
int downloadBlock; // block we are waiting for
|
||||
int downloadCount; // how many bytes we got
|
||||
int downloadSize; // how many bytes we got
|
||||
char downloadList[MAX_INFO_STRING]; // list of paks we need to download
|
||||
qboolean downloadRestart; // if true, we need to do another FS_Restart because we downloaded a pak
|
||||
|
||||
// demo information
|
||||
char demoName[MAX_QPATH];
|
||||
qboolean spDemoRecording;
|
||||
qboolean demorecording;
|
||||
qboolean demoplaying;
|
||||
qboolean demowaiting; // don't record until a non-delta message is received
|
||||
qboolean firstDemoFrameSkipped;
|
||||
fileHandle_t demofile;
|
||||
|
||||
int timeDemoFrames; // counter of rendered frames
|
||||
int timeDemoStart; // cls.realtime before first frame
|
||||
int timeDemoBaseTime; // each frame will be at this time + frameNum * 50
|
||||
|
||||
// big stuff at end of structure so most offsets are 15 bits or less
|
||||
netchan_t netchan;
|
||||
} clientConnection_t;
|
||||
|
||||
extern clientConnection_t clc;
|
||||
|
||||
/*
|
||||
==================================================================
|
||||
|
||||
the clientStatic_t structure is never wiped, and is used even when
|
||||
no client connection is active at all
|
||||
|
||||
==================================================================
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
netadr_t adr;
|
||||
int start;
|
||||
int time;
|
||||
char info[MAX_INFO_STRING];
|
||||
} ping_t;
|
||||
|
||||
typedef struct {
|
||||
netadr_t adr;
|
||||
char hostName[MAX_HOSTNAME_LENGTH];
|
||||
char mapName[MAX_NAME_LENGTH];
|
||||
char game[MAX_NAME_LENGTH];
|
||||
int netType;
|
||||
int gameType;
|
||||
int clients;
|
||||
int maxClients;
|
||||
int minPing;
|
||||
int maxPing;
|
||||
int ping;
|
||||
qboolean visible;
|
||||
} serverInfo_t;
|
||||
|
||||
typedef struct {
|
||||
byte ip[4];
|
||||
unsigned short port;
|
||||
} serverAddress_t;
|
||||
|
||||
typedef struct {
|
||||
connstate_t state; // connection status
|
||||
int keyCatchers; // bit flags
|
||||
|
||||
qboolean cddialog; // bring up the cd needed dialog next frame
|
||||
|
||||
char servername[MAX_OSPATH]; // name of server from original connect (used by reconnect)
|
||||
|
||||
// when the server clears the hunk, all of these must be restarted
|
||||
qboolean rendererStarted;
|
||||
qboolean soundStarted;
|
||||
qboolean soundRegistered;
|
||||
qboolean uiStarted;
|
||||
qboolean cgameStarted;
|
||||
|
||||
int framecount;
|
||||
int frametime; // msec since last frame
|
||||
|
||||
int realtime; // ignores pause
|
||||
int realFrametime; // ignoring pause, so console always works
|
||||
|
||||
int numlocalservers;
|
||||
serverInfo_t localServers[MAX_OTHER_SERVERS];
|
||||
|
||||
int numglobalservers;
|
||||
serverInfo_t globalServers[MAX_GLOBAL_SERVERS];
|
||||
// additional global servers
|
||||
int numGlobalServerAddresses;
|
||||
serverAddress_t globalServerAddresses[MAX_GLOBAL_SERVERS];
|
||||
|
||||
int numfavoriteservers;
|
||||
serverInfo_t favoriteServers[MAX_OTHER_SERVERS];
|
||||
|
||||
int nummplayerservers;
|
||||
serverInfo_t mplayerServers[MAX_OTHER_SERVERS];
|
||||
|
||||
int pingUpdateSource; // source currently pinging or updating
|
||||
|
||||
int masterNum;
|
||||
|
||||
// update server info
|
||||
netadr_t updateServer;
|
||||
char updateChallenge[MAX_TOKEN_CHARS];
|
||||
char updateInfoString[MAX_INFO_STRING];
|
||||
|
||||
netadr_t authorizeServer;
|
||||
|
||||
// rendering info
|
||||
glconfig_t glconfig;
|
||||
qhandle_t charSetShader;
|
||||
qhandle_t whiteShader;
|
||||
qhandle_t consoleShader;
|
||||
} clientStatic_t;
|
||||
|
||||
extern clientStatic_t cls;
|
||||
|
||||
//=============================================================================
|
||||
|
||||
extern vm_t *cgvm; // interface to cgame dll or vm
|
||||
extern vm_t *uivm; // interface to ui dll or vm
|
||||
extern refexport_t re; // interface to refresh .dll
|
||||
|
||||
|
||||
//
|
||||
// cvars
|
||||
//
|
||||
extern cvar_t *cl_nodelta;
|
||||
extern cvar_t *cl_debugMove;
|
||||
extern cvar_t *cl_noprint;
|
||||
extern cvar_t *cl_timegraph;
|
||||
extern cvar_t *cl_maxpackets;
|
||||
extern cvar_t *cl_packetdup;
|
||||
extern cvar_t *cl_shownet;
|
||||
extern cvar_t *cl_showSend;
|
||||
extern cvar_t *cl_timeNudge;
|
||||
extern cvar_t *cl_showTimeDelta;
|
||||
extern cvar_t *cl_freezeDemo;
|
||||
|
||||
extern cvar_t *cl_yawspeed;
|
||||
extern cvar_t *cl_pitchspeed;
|
||||
extern cvar_t *cl_run;
|
||||
extern cvar_t *cl_anglespeedkey;
|
||||
|
||||
extern cvar_t *cl_sensitivity;
|
||||
extern cvar_t *cl_platformSensitivity;
|
||||
extern cvar_t *cl_freelook;
|
||||
|
||||
extern cvar_t *cl_mouseAccel;
|
||||
extern cvar_t *cl_showMouseRate;
|
||||
|
||||
extern cvar_t *m_pitch;
|
||||
extern cvar_t *m_yaw;
|
||||
extern cvar_t *m_forward;
|
||||
extern cvar_t *m_side;
|
||||
extern cvar_t *m_filter;
|
||||
|
||||
extern cvar_t *cl_timedemo;
|
||||
extern cvar_t *cl_aviFrameRate;
|
||||
extern cvar_t *cl_aviMotionJpeg;
|
||||
|
||||
extern cvar_t *cl_activeAction;
|
||||
|
||||
extern cvar_t *cl_allowDownload;
|
||||
extern cvar_t *cl_downloadMethod;
|
||||
extern cvar_t *cl_conXOffset;
|
||||
extern cvar_t *cl_inGameVideo;
|
||||
|
||||
extern cvar_t *cl_lanForcePackets;
|
||||
extern cvar_t *cl_autoRecordDemo;
|
||||
|
||||
//=================================================
|
||||
|
||||
//
|
||||
// cl_main
|
||||
//
|
||||
|
||||
void CL_Init (void);
|
||||
void CL_FlushMemory(void);
|
||||
void CL_ShutdownAll(void);
|
||||
void CL_AddReliableCommand( const char *cmd );
|
||||
|
||||
void CL_StartHunkUsers( void );
|
||||
|
||||
void CL_Disconnect_f (void);
|
||||
void CL_GetChallengePacket (void);
|
||||
void CL_Vid_Restart_f( void );
|
||||
void CL_Snd_Restart_f (void);
|
||||
void CL_StartDemoLoop( void );
|
||||
void CL_NextDemo( void );
|
||||
void CL_ReadDemoMessage( void );
|
||||
demoState_t CL_DemoState( void );
|
||||
int CL_DemoPos( void );
|
||||
void CL_DemoName( char *buffer, int size );
|
||||
void CL_StopRecord_f( void );
|
||||
|
||||
void CL_InitDownloads(void);
|
||||
void CL_NextDownload(void);
|
||||
|
||||
void CL_GetPing( int n, char *buf, int buflen, int *pingtime );
|
||||
void CL_GetPingInfo( int n, char *buf, int buflen );
|
||||
void CL_ClearPing( int n );
|
||||
int CL_GetPingQueueCount( void );
|
||||
|
||||
void CL_ShutdownRef( void );
|
||||
void CL_InitRef( void );
|
||||
int CL_ServerStatus( char *serverAddress, char *serverStatusString, int maxLen );
|
||||
|
||||
qboolean CL_CheckPaused(void);
|
||||
|
||||
//
|
||||
// cl_input
|
||||
//
|
||||
typedef struct {
|
||||
int down[2]; // key nums holding it down
|
||||
unsigned downtime; // msec timestamp
|
||||
unsigned msec; // msec down this frame if both a down and up happened
|
||||
qboolean active; // current state
|
||||
qboolean wasPressed; // set when down, not cleared when up
|
||||
} kbutton_t;
|
||||
|
||||
extern kbutton_t in_mlook, in_klook;
|
||||
extern kbutton_t in_strafe;
|
||||
extern kbutton_t in_speed;
|
||||
|
||||
void CL_InitInput (void);
|
||||
void CL_SendCmd (void);
|
||||
void CL_ClearState (void);
|
||||
void CL_ReadPackets (void);
|
||||
|
||||
void CL_WritePacket( void );
|
||||
void IN_CenterView (void);
|
||||
|
||||
void CL_VerifyCode( void );
|
||||
|
||||
float CL_KeyState (kbutton_t *key);
|
||||
char *Key_KeynumToString (int keynum);
|
||||
|
||||
//
|
||||
// cl_parse.c
|
||||
//
|
||||
extern int cl_connectedToPureServer;
|
||||
extern int cl_connectedToCheatServer;
|
||||
|
||||
void CL_SystemInfoChanged( void );
|
||||
void CL_ParseServerMessage( msg_t *msg );
|
||||
|
||||
//====================================================================
|
||||
|
||||
void CL_ServerInfoPacket( netadr_t from, msg_t *msg );
|
||||
void CL_LocalServers_f( void );
|
||||
void CL_GlobalServers_f( void );
|
||||
void CL_FavoriteServers_f( void );
|
||||
void CL_Ping_f( void );
|
||||
qboolean CL_UpdateVisiblePings_f( int source );
|
||||
|
||||
|
||||
//
|
||||
// console
|
||||
//
|
||||
void Con_DrawCharacter (int cx, int line, int num);
|
||||
|
||||
void Con_CheckResize (void);
|
||||
void Con_Init (void);
|
||||
void Con_Clear_f (void);
|
||||
void Con_ToggleConsole_f (void);
|
||||
void Con_DrawNotify (void);
|
||||
void Con_ClearNotify (void);
|
||||
void Con_RunConsole (void);
|
||||
void Con_DrawConsole (void);
|
||||
void Con_PageUp( void );
|
||||
void Con_PageDown( void );
|
||||
void Con_Top( void );
|
||||
void Con_Bottom( void );
|
||||
void Con_Close( void );
|
||||
|
||||
void CL_LoadConsoleHistory( void );
|
||||
void CL_SaveConsoleHistory( void );
|
||||
|
||||
//
|
||||
// cl_scrn.c
|
||||
//
|
||||
void SCR_Init (void);
|
||||
void SCR_UpdateScreen (void);
|
||||
|
||||
void SCR_DebugGraph (float value, int color);
|
||||
|
||||
int SCR_GetBigStringWidth( const char *str ); // returns in virtual 640x480 coordinates
|
||||
|
||||
void SCR_AdjustFrom640( float *x, float *y, float *w, float *h );
|
||||
void SCR_FillRect( float x, float y, float width, float height,
|
||||
const float *color );
|
||||
void SCR_DrawPic( float x, float y, float width, float height, qhandle_t hShader );
|
||||
void SCR_DrawNamedPic( float x, float y, float width, float height, const char *picname );
|
||||
|
||||
void SCR_DrawBigString( int x, int y, const char *s, float alpha ); // draws a string with embedded color control characters with fade
|
||||
void SCR_DrawBigStringColor( int x, int y, const char *s, vec4_t color ); // ignores embedded color control characters
|
||||
void SCR_DrawSmallStringExt( int x, int y, const char *string, float *setColor, qboolean forceColor );
|
||||
void SCR_DrawSmallChar( int x, int y, int ch );
|
||||
|
||||
|
||||
//
|
||||
// cl_cin.c
|
||||
//
|
||||
|
||||
void CL_PlayCinematic_f( void );
|
||||
void SCR_DrawCinematic (void);
|
||||
void SCR_RunCinematic (void);
|
||||
void SCR_StopCinematic (void);
|
||||
int CIN_PlayCinematic( const char *arg0, int xpos, int ypos, int width, int height, int bits);
|
||||
e_status CIN_StopCinematic(int handle);
|
||||
e_status CIN_RunCinematic (int handle);
|
||||
void CIN_DrawCinematic (int handle);
|
||||
void CIN_SetExtents (int handle, int x, int y, int w, int h);
|
||||
void CIN_SetLooping (int handle, qboolean loop);
|
||||
void CIN_UploadCinematic(int handle);
|
||||
void CIN_CloseAllVideos(void);
|
||||
|
||||
//
|
||||
// cl_cgame.c
|
||||
//
|
||||
void CL_InitCGame( void );
|
||||
void CL_ShutdownCGame( void );
|
||||
qboolean CL_GameCommand( void );
|
||||
void CL_GameConsoleText( void );
|
||||
void CL_CGameRendering( stereoFrame_t stereo );
|
||||
void CL_SetCGameTime( void );
|
||||
void CL_FirstSnapshot( void );
|
||||
void CL_ShaderStateChanged(void);
|
||||
|
||||
//
|
||||
// cl_ui.c
|
||||
//
|
||||
void CL_InitUI( void );
|
||||
void CL_ShutdownUI( void );
|
||||
int Key_GetCatcher( void );
|
||||
void Key_SetCatcher( int catcher );
|
||||
void LAN_LoadCachedServers( void );
|
||||
void LAN_SaveServersToCache( void );
|
||||
|
||||
|
||||
//
|
||||
// cl_net_chan.c
|
||||
//
|
||||
void CL_Netchan_Transmit( netchan_t *chan, msg_t* msg); //int length, const byte *data );
|
||||
void CL_Netchan_TransmitNextFragment( netchan_t *chan );
|
||||
qboolean CL_Netchan_Process( netchan_t *chan, msg_t *msg );
|
||||
|
||||
//
|
||||
// cl_avi.c
|
||||
//
|
||||
qboolean CL_OpenAVIForWriting( const char *filename );
|
||||
void CL_TakeVideoFrame( void );
|
||||
void CL_WriteAVIVideoFrame( const byte *imageBuffer, int size );
|
||||
void CL_WriteAVIAudioFrame( const byte *pcmBuffer, int size );
|
||||
qboolean CL_CloseAVI( void );
|
||||
qboolean CL_VideoRecording( void );
|
||||
@@ -1,278 +0,0 @@
|
||||
/*
|
||||
===========================================================================
|
||||
Copyright (C) 1999-2005 Id Software, Inc.
|
||||
Copyright (C) 2000-2006 Tim Angus
|
||||
|
||||
This file is part of Tremulous.
|
||||
|
||||
Tremulous is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
Tremulous is distributed in the hope that it will be
|
||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Tremulous; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
===========================================================================
|
||||
*/
|
||||
//
|
||||
#ifndef __KEYCODES_H__
|
||||
#define __KEYCODES_H__
|
||||
|
||||
//
|
||||
// these are the key numbers that should be passed to KeyEvent
|
||||
//
|
||||
|
||||
// normal keys should be passed as lowercased ascii
|
||||
|
||||
typedef enum {
|
||||
K_NONE = -1,
|
||||
K_TAB = 9,
|
||||
K_ENTER = 13,
|
||||
K_ESCAPE = 27,
|
||||
K_SPACE = 32,
|
||||
|
||||
K_BACKSPACE = 127,
|
||||
|
||||
K_COMMAND = 128,
|
||||
K_CAPSLOCK,
|
||||
K_POWER,
|
||||
K_PAUSE,
|
||||
|
||||
K_UPARROW,
|
||||
K_DOWNARROW,
|
||||
K_LEFTARROW,
|
||||
K_RIGHTARROW,
|
||||
|
||||
K_ALT,
|
||||
K_CTRL,
|
||||
K_SHIFT,
|
||||
K_INS,
|
||||
K_DEL,
|
||||
K_PGDN,
|
||||
K_PGUP,
|
||||
K_HOME,
|
||||
K_END,
|
||||
|
||||
K_F1,
|
||||
K_F2,
|
||||
K_F3,
|
||||
K_F4,
|
||||
K_F5,
|
||||
K_F6,
|
||||
K_F7,
|
||||
K_F8,
|
||||
K_F9,
|
||||
K_F10,
|
||||
K_F11,
|
||||
K_F12,
|
||||
K_F13,
|
||||
K_F14,
|
||||
K_F15,
|
||||
|
||||
K_KP_HOME,
|
||||
K_KP_UPARROW,
|
||||
K_KP_PGUP,
|
||||
K_KP_LEFTARROW,
|
||||
K_KP_5,
|
||||
K_KP_RIGHTARROW,
|
||||
K_KP_END,
|
||||
K_KP_DOWNARROW,
|
||||
K_KP_PGDN,
|
||||
K_KP_ENTER,
|
||||
K_KP_INS,
|
||||
K_KP_DEL,
|
||||
K_KP_SLASH,
|
||||
K_KP_MINUS,
|
||||
K_KP_PLUS,
|
||||
K_KP_NUMLOCK,
|
||||
K_KP_STAR,
|
||||
K_KP_EQUALS,
|
||||
|
||||
K_MOUSE1,
|
||||
K_MOUSE2,
|
||||
K_MOUSE3,
|
||||
K_MOUSE4,
|
||||
K_MOUSE5,
|
||||
|
||||
K_MWHEELDOWN,
|
||||
K_MWHEELUP,
|
||||
|
||||
K_JOY1,
|
||||
K_JOY2,
|
||||
K_JOY3,
|
||||
K_JOY4,
|
||||
K_JOY5,
|
||||
K_JOY6,
|
||||
K_JOY7,
|
||||
K_JOY8,
|
||||
K_JOY9,
|
||||
K_JOY10,
|
||||
K_JOY11,
|
||||
K_JOY12,
|
||||
K_JOY13,
|
||||
K_JOY14,
|
||||
K_JOY15,
|
||||
K_JOY16,
|
||||
K_JOY17,
|
||||
K_JOY18,
|
||||
K_JOY19,
|
||||
K_JOY20,
|
||||
K_JOY21,
|
||||
K_JOY22,
|
||||
K_JOY23,
|
||||
K_JOY24,
|
||||
K_JOY25,
|
||||
K_JOY26,
|
||||
K_JOY27,
|
||||
K_JOY28,
|
||||
K_JOY29,
|
||||
K_JOY30,
|
||||
K_JOY31,
|
||||
K_JOY32,
|
||||
|
||||
K_AUX1,
|
||||
K_AUX2,
|
||||
K_AUX3,
|
||||
K_AUX4,
|
||||
K_AUX5,
|
||||
K_AUX6,
|
||||
K_AUX7,
|
||||
K_AUX8,
|
||||
K_AUX9,
|
||||
K_AUX10,
|
||||
K_AUX11,
|
||||
K_AUX12,
|
||||
K_AUX13,
|
||||
K_AUX14,
|
||||
K_AUX15,
|
||||
K_AUX16,
|
||||
|
||||
K_WORLD_0,
|
||||
K_WORLD_1,
|
||||
K_WORLD_2,
|
||||
K_WORLD_3,
|
||||
K_WORLD_4,
|
||||
K_WORLD_5,
|
||||
K_WORLD_6,
|
||||
K_WORLD_7,
|
||||
K_WORLD_8,
|
||||
K_WORLD_9,
|
||||
K_WORLD_10,
|
||||
K_WORLD_11,
|
||||
K_WORLD_12,
|
||||
K_WORLD_13,
|
||||
K_WORLD_14,
|
||||
K_WORLD_15,
|
||||
K_WORLD_16,
|
||||
K_WORLD_17,
|
||||
K_WORLD_18,
|
||||
K_WORLD_19,
|
||||
K_WORLD_20,
|
||||
K_WORLD_21,
|
||||
K_WORLD_22,
|
||||
K_WORLD_23,
|
||||
K_WORLD_24,
|
||||
K_WORLD_25,
|
||||
K_WORLD_26,
|
||||
K_WORLD_27,
|
||||
K_WORLD_28,
|
||||
K_WORLD_29,
|
||||
K_WORLD_30,
|
||||
K_WORLD_31,
|
||||
K_WORLD_32,
|
||||
K_WORLD_33,
|
||||
K_WORLD_34,
|
||||
K_WORLD_35,
|
||||
K_WORLD_36,
|
||||
K_WORLD_37,
|
||||
K_WORLD_38,
|
||||
K_WORLD_39,
|
||||
K_WORLD_40,
|
||||
K_WORLD_41,
|
||||
K_WORLD_42,
|
||||
K_WORLD_43,
|
||||
K_WORLD_44,
|
||||
K_WORLD_45,
|
||||
K_WORLD_46,
|
||||
K_WORLD_47,
|
||||
K_WORLD_48,
|
||||
K_WORLD_49,
|
||||
K_WORLD_50,
|
||||
K_WORLD_51,
|
||||
K_WORLD_52,
|
||||
K_WORLD_53,
|
||||
K_WORLD_54,
|
||||
K_WORLD_55,
|
||||
K_WORLD_56,
|
||||
K_WORLD_57,
|
||||
K_WORLD_58,
|
||||
K_WORLD_59,
|
||||
K_WORLD_60,
|
||||
K_WORLD_61,
|
||||
K_WORLD_62,
|
||||
K_WORLD_63,
|
||||
K_WORLD_64,
|
||||
K_WORLD_65,
|
||||
K_WORLD_66,
|
||||
K_WORLD_67,
|
||||
K_WORLD_68,
|
||||
K_WORLD_69,
|
||||
K_WORLD_70,
|
||||
K_WORLD_71,
|
||||
K_WORLD_72,
|
||||
K_WORLD_73,
|
||||
K_WORLD_74,
|
||||
K_WORLD_75,
|
||||
K_WORLD_76,
|
||||
K_WORLD_77,
|
||||
K_WORLD_78,
|
||||
K_WORLD_79,
|
||||
K_WORLD_80,
|
||||
K_WORLD_81,
|
||||
K_WORLD_82,
|
||||
K_WORLD_83,
|
||||
K_WORLD_84,
|
||||
K_WORLD_85,
|
||||
K_WORLD_86,
|
||||
K_WORLD_87,
|
||||
K_WORLD_88,
|
||||
K_WORLD_89,
|
||||
K_WORLD_90,
|
||||
K_WORLD_91,
|
||||
K_WORLD_92,
|
||||
K_WORLD_93,
|
||||
K_WORLD_94,
|
||||
K_WORLD_95,
|
||||
|
||||
K_SUPER,
|
||||
K_COMPOSE,
|
||||
K_MODE,
|
||||
K_HELP,
|
||||
K_PRINT,
|
||||
K_SYSREQ,
|
||||
K_SCROLLOCK,
|
||||
K_BREAK,
|
||||
K_MENU,
|
||||
K_EURO,
|
||||
K_UNDO,
|
||||
|
||||
MAX_KEYS
|
||||
} keyNum_t;
|
||||
|
||||
// MAX_KEYS replaces K_LAST_KEY, however some mods may have used K_LAST_KEY
|
||||
// in detecting binds, so we leave it defined to the old hardcoded value
|
||||
// of maxiumum keys to prevent mods from crashing older versions of the engine
|
||||
#define K_LAST_KEY 256
|
||||
|
||||
// The menu code needs to get both key and char events, but
|
||||
// to avoid duplicating the paths, the char events are just
|
||||
// distinguished by or'ing in K_CHAR_FLAG (ugly)
|
||||
#define K_CHAR_FLAG 1024
|
||||
|
||||
#endif
|
||||
@@ -1,58 +0,0 @@
|
||||
/*
|
||||
===========================================================================
|
||||
Copyright (C) 1999-2005 Id Software, Inc.
|
||||
Copyright (C) 2000-2006 Tim Angus
|
||||
|
||||
This file is part of Tremulous.
|
||||
|
||||
Tremulous is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
Tremulous is distributed in the hope that it will be
|
||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Tremulous; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
===========================================================================
|
||||
*/
|
||||
#include "keycodes.h"
|
||||
|
||||
typedef struct {
|
||||
qboolean down;
|
||||
int repeats; // if > 1, it is autorepeating
|
||||
char *binding;
|
||||
} qkey_t;
|
||||
|
||||
extern qboolean key_overstrikeMode;
|
||||
extern qkey_t keys[MAX_KEYS];
|
||||
|
||||
// NOTE TTimo the declaration of field_t and Field_Clear is now in qcommon/qcommon.h
|
||||
void Field_KeyDownEvent( field_t *edit, int key );
|
||||
void Field_CharEvent( field_t *edit, int ch );
|
||||
void Field_Draw( field_t *edit, int x, int y, int width, qboolean showCursor );
|
||||
void Field_BigDraw( field_t *edit, int x, int y, int width, qboolean showCursor );
|
||||
|
||||
#define COMMAND_HISTORY 32
|
||||
extern field_t historyEditLines[COMMAND_HISTORY];
|
||||
|
||||
extern field_t g_consoleField;
|
||||
extern field_t chatField;
|
||||
extern int anykeydown;
|
||||
extern qboolean chat_team;
|
||||
extern int chat_playerNum;
|
||||
|
||||
void Key_WriteBindings( fileHandle_t f );
|
||||
void Key_SetBinding( int keynum, const char *binding );
|
||||
char *Key_GetBinding( int keynum );
|
||||
qboolean Key_IsDown( int keynum );
|
||||
qboolean Key_GetOverstrikeMode( void );
|
||||
void Key_SetOverstrikeMode( qboolean state );
|
||||
void Key_ClearStates( void );
|
||||
int Key_GetKey(const char *binding);
|
||||
void Key_KeynumToStringBuf( int keynum, char *buf, int buflen );
|
||||
void Key_GetBindingBuf( int keynum, char *buf, int buflen );
|
||||
@@ -1,366 +0,0 @@
|
||||
/*
|
||||
===========================================================================
|
||||
Copyright (C) 1999-2005 Id Software, Inc.
|
||||
Copyright (C) 2000-2006 Tim Angus
|
||||
Copyright (C) 2005 Stuart Dalton (badcdev@gmail.com)
|
||||
|
||||
This file is part of Tremulous.
|
||||
|
||||
Tremulous is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
Tremulous is distributed in the hope that it will be
|
||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Tremulous; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
===========================================================================
|
||||
*/
|
||||
|
||||
// Dynamically loads OpenAL
|
||||
|
||||
#if USE_OPENAL
|
||||
|
||||
#include "qal.h"
|
||||
|
||||
#if USE_OPENAL_DLOPEN
|
||||
|
||||
#if USE_SDL_VIDEO
|
||||
#include "SDL.h"
|
||||
#include "SDL_loadso.h"
|
||||
#define OBJTYPE void *
|
||||
#define OBJLOAD(x) SDL_LoadObject(x)
|
||||
#define SYMLOAD(x,y) SDL_LoadFunction(x,y)
|
||||
#define OBJFREE(x) SDL_UnloadObject(x)
|
||||
|
||||
#elif defined _WIN32
|
||||
#include <windows.h>
|
||||
#define OBJTYPE HMODULE
|
||||
#define OBJLOAD(x) LoadLibrary(x)
|
||||
#define SYMLOAD(x,y) GetProcAddress(x,y)
|
||||
#define OBJFREE(x) FreeLibrary(x)
|
||||
|
||||
#elif defined __linux__ || defined __FreeBSD__ || defined MACOS_X || defined __sun
|
||||
#include <dlfcn.h>
|
||||
#define OBJTYPE void *
|
||||
#define OBJLOAD(x) dlopen(x, RTLD_LAZY | RTLD_GLOBAL)
|
||||
#define SYMLOAD(x,y) dlsym(x,y)
|
||||
#define OBJFREE(x) dlclose(x)
|
||||
#else
|
||||
|
||||
#error "Your platform has no lib loading code or it is disabled"
|
||||
#endif
|
||||
|
||||
#if defined __linux__ || defined __FreeBSD__ || defined MACOS_X
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
|
||||
LPALENABLE qalEnable;
|
||||
LPALDISABLE qalDisable;
|
||||
LPALISENABLED qalIsEnabled;
|
||||
LPALGETSTRING qalGetString;
|
||||
LPALGETBOOLEANV qalGetBooleanv;
|
||||
LPALGETINTEGERV qalGetIntegerv;
|
||||
LPALGETFLOATV qalGetFloatv;
|
||||
LPALGETDOUBLEV qalGetDoublev;
|
||||
LPALGETBOOLEAN qalGetBoolean;
|
||||
LPALGETINTEGER qalGetInteger;
|
||||
LPALGETFLOAT qalGetFloat;
|
||||
LPALGETDOUBLE qalGetDouble;
|
||||
LPALGETERROR qalGetError;
|
||||
LPALISEXTENSIONPRESENT qalIsExtensionPresent;
|
||||
LPALGETPROCADDRESS qalGetProcAddress;
|
||||
LPALGETENUMVALUE qalGetEnumValue;
|
||||
LPALLISTENERF qalListenerf;
|
||||
LPALLISTENER3F qalListener3f;
|
||||
LPALLISTENERFV qalListenerfv;
|
||||
LPALLISTENERI qalListeneri;
|
||||
LPALGETLISTENERF qalGetListenerf;
|
||||
LPALGETLISTENER3F qalGetListener3f;
|
||||
LPALGETLISTENERFV qalGetListenerfv;
|
||||
LPALGETLISTENERI qalGetListeneri;
|
||||
LPALGENSOURCES qalGenSources;
|
||||
LPALDELETESOURCES qalDeleteSources;
|
||||
LPALISSOURCE qalIsSource;
|
||||
LPALSOURCEF qalSourcef;
|
||||
LPALSOURCE3F qalSource3f;
|
||||
LPALSOURCEFV qalSourcefv;
|
||||
LPALSOURCEI qalSourcei;
|
||||
LPALGETSOURCEF qalGetSourcef;
|
||||
LPALGETSOURCE3F qalGetSource3f;
|
||||
LPALGETSOURCEFV qalGetSourcefv;
|
||||
LPALGETSOURCEI qalGetSourcei;
|
||||
LPALSOURCEPLAYV qalSourcePlayv;
|
||||
LPALSOURCESTOPV qalSourceStopv;
|
||||
LPALSOURCEREWINDV qalSourceRewindv;
|
||||
LPALSOURCEPAUSEV qalSourcePausev;
|
||||
LPALSOURCEPLAY qalSourcePlay;
|
||||
LPALSOURCESTOP qalSourceStop;
|
||||
LPALSOURCEREWIND qalSourceRewind;
|
||||
LPALSOURCEPAUSE qalSourcePause;
|
||||
LPALSOURCEQUEUEBUFFERS qalSourceQueueBuffers;
|
||||
LPALSOURCEUNQUEUEBUFFERS qalSourceUnqueueBuffers;
|
||||
LPALGENBUFFERS qalGenBuffers;
|
||||
LPALDELETEBUFFERS qalDeleteBuffers;
|
||||
LPALISBUFFER qalIsBuffer;
|
||||
LPALBUFFERDATA qalBufferData;
|
||||
LPALGETBUFFERF qalGetBufferf;
|
||||
LPALGETBUFFERI qalGetBufferi;
|
||||
LPALDOPPLERFACTOR qalDopplerFactor;
|
||||
LPALDOPPLERVELOCITY qalDopplerVelocity;
|
||||
LPALDISTANCEMODEL qalDistanceModel;
|
||||
|
||||
LPALCCREATECONTEXT qalcCreateContext;
|
||||
LPALCMAKECONTEXTCURRENT qalcMakeContextCurrent;
|
||||
LPALCPROCESSCONTEXT qalcProcessContext;
|
||||
LPALCSUSPENDCONTEXT qalcSuspendContext;
|
||||
LPALCDESTROYCONTEXT qalcDestroyContext;
|
||||
LPALCGETCURRENTCONTEXT qalcGetCurrentContext;
|
||||
LPALCGETCONTEXTSDEVICE qalcGetContextsDevice;
|
||||
LPALCOPENDEVICE qalcOpenDevice;
|
||||
LPALCCLOSEDEVICE qalcCloseDevice;
|
||||
LPALCGETERROR qalcGetError;
|
||||
LPALCISEXTENSIONPRESENT qalcIsExtensionPresent;
|
||||
LPALCGETPROCADDRESS qalcGetProcAddress;
|
||||
LPALCGETENUMVALUE qalcGetEnumValue;
|
||||
LPALCGETSTRING qalcGetString;
|
||||
LPALCGETINTEGERV qalcGetIntegerv;
|
||||
|
||||
static OBJTYPE OpenALLib = NULL;
|
||||
|
||||
static qboolean alinit_fail = qfalse;
|
||||
|
||||
/*
|
||||
=================
|
||||
GPA
|
||||
=================
|
||||
*/
|
||||
static void *GPA(char *str)
|
||||
{
|
||||
void *rv;
|
||||
|
||||
rv = SYMLOAD(OpenALLib, str);
|
||||
if(!rv)
|
||||
{
|
||||
Com_Printf( " Can't load symbol %s\n", str);
|
||||
alinit_fail = qtrue;
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
Com_DPrintf( " Loaded symbol %s (%p)\n", str, rv);
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
QAL_Init
|
||||
=================
|
||||
*/
|
||||
qboolean QAL_Init(const char *libname)
|
||||
{
|
||||
if(OpenALLib)
|
||||
return qtrue;
|
||||
|
||||
Com_Printf( "Loading \"%s\"...\n", libname);
|
||||
if( (OpenALLib = OBJLOAD(libname)) == 0 )
|
||||
{
|
||||
#ifdef _WIN32
|
||||
return qfalse;
|
||||
#else
|
||||
char fn[1024];
|
||||
getcwd(fn, sizeof(fn));
|
||||
strncat(fn, "/", sizeof(fn) - strlen(fn) - 1);
|
||||
strncat(fn, libname, sizeof(fn) - strlen(fn) - 1);
|
||||
|
||||
if( (OpenALLib = OBJLOAD(fn)) == 0 )
|
||||
{
|
||||
return qfalse;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
alinit_fail = qfalse;
|
||||
|
||||
qalEnable = GPA("alEnable");
|
||||
qalDisable = GPA("alDisable");
|
||||
qalIsEnabled = GPA("alIsEnabled");
|
||||
qalGetString = GPA("alGetString");
|
||||
qalGetBooleanv = GPA("alGetBooleanv");
|
||||
qalGetIntegerv = GPA("alGetIntegerv");
|
||||
qalGetFloatv = GPA("alGetFloatv");
|
||||
qalGetDoublev = GPA("alGetDoublev");
|
||||
qalGetBoolean = GPA("alGetBoolean");
|
||||
qalGetInteger = GPA("alGetInteger");
|
||||
qalGetFloat = GPA("alGetFloat");
|
||||
qalGetDouble = GPA("alGetDouble");
|
||||
qalGetError = GPA("alGetError");
|
||||
qalIsExtensionPresent = GPA("alIsExtensionPresent");
|
||||
qalGetProcAddress = GPA("alGetProcAddress");
|
||||
qalGetEnumValue = GPA("alGetEnumValue");
|
||||
qalListenerf = GPA("alListenerf");
|
||||
qalListener3f = GPA("alListener3f");
|
||||
qalListenerfv = GPA("alListenerfv");
|
||||
qalListeneri = GPA("alListeneri");
|
||||
qalGetListenerf = GPA("alGetListenerf");
|
||||
qalGetListener3f = GPA("alGetListener3f");
|
||||
qalGetListenerfv = GPA("alGetListenerfv");
|
||||
qalGetListeneri = GPA("alGetListeneri");
|
||||
qalGenSources = GPA("alGenSources");
|
||||
qalDeleteSources = GPA("alDeleteSources");
|
||||
qalIsSource = GPA("alIsSource");
|
||||
qalSourcef = GPA("alSourcef");
|
||||
qalSource3f = GPA("alSource3f");
|
||||
qalSourcefv = GPA("alSourcefv");
|
||||
qalSourcei = GPA("alSourcei");
|
||||
qalGetSourcef = GPA("alGetSourcef");
|
||||
qalGetSource3f = GPA("alGetSource3f");
|
||||
qalGetSourcefv = GPA("alGetSourcefv");
|
||||
qalGetSourcei = GPA("alGetSourcei");
|
||||
qalSourcePlayv = GPA("alSourcePlayv");
|
||||
qalSourceStopv = GPA("alSourceStopv");
|
||||
qalSourceRewindv = GPA("alSourceRewindv");
|
||||
qalSourcePausev = GPA("alSourcePausev");
|
||||
qalSourcePlay = GPA("alSourcePlay");
|
||||
qalSourceStop = GPA("alSourceStop");
|
||||
qalSourceRewind = GPA("alSourceRewind");
|
||||
qalSourcePause = GPA("alSourcePause");
|
||||
qalSourceQueueBuffers = GPA("alSourceQueueBuffers");
|
||||
qalSourceUnqueueBuffers = GPA("alSourceUnqueueBuffers");
|
||||
qalGenBuffers = GPA("alGenBuffers");
|
||||
qalDeleteBuffers = GPA("alDeleteBuffers");
|
||||
qalIsBuffer = GPA("alIsBuffer");
|
||||
qalBufferData = GPA("alBufferData");
|
||||
qalGetBufferf = GPA("alGetBufferf");
|
||||
qalGetBufferi = GPA("alGetBufferi");
|
||||
qalDopplerFactor = GPA("alDopplerFactor");
|
||||
qalDopplerVelocity = GPA("alDopplerVelocity");
|
||||
qalDistanceModel = GPA("alDistanceModel");
|
||||
|
||||
qalcCreateContext = GPA("alcCreateContext");
|
||||
qalcMakeContextCurrent = GPA("alcMakeContextCurrent");
|
||||
qalcProcessContext = GPA("alcProcessContext");
|
||||
qalcSuspendContext = GPA("alcSuspendContext");
|
||||
qalcDestroyContext = GPA("alcDestroyContext");
|
||||
qalcGetCurrentContext = GPA("alcGetCurrentContext");
|
||||
qalcGetContextsDevice = GPA("alcGetContextsDevice");
|
||||
qalcOpenDevice = GPA("alcOpenDevice");
|
||||
qalcCloseDevice = GPA("alcCloseDevice");
|
||||
qalcGetError = GPA("alcGetError");
|
||||
qalcIsExtensionPresent = GPA("alcIsExtensionPresent");
|
||||
qalcGetProcAddress = GPA("alcGetProcAddress");
|
||||
qalcGetEnumValue = GPA("alcGetEnumValue");
|
||||
qalcGetString = GPA("alcGetString");
|
||||
qalcGetIntegerv = GPA("alcGetIntegerv");
|
||||
|
||||
if(alinit_fail)
|
||||
{
|
||||
QAL_Shutdown();
|
||||
Com_Printf( " One or more symbols not found\n");
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
return qtrue;
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
QAL_Shutdown
|
||||
=================
|
||||
*/
|
||||
void QAL_Shutdown( void )
|
||||
{
|
||||
if(OpenALLib)
|
||||
{
|
||||
OBJFREE(OpenALLib);
|
||||
OpenALLib = NULL;
|
||||
}
|
||||
|
||||
qalEnable = NULL;
|
||||
qalDisable = NULL;
|
||||
qalIsEnabled = NULL;
|
||||
qalGetString = NULL;
|
||||
qalGetBooleanv = NULL;
|
||||
qalGetIntegerv = NULL;
|
||||
qalGetFloatv = NULL;
|
||||
qalGetDoublev = NULL;
|
||||
qalGetBoolean = NULL;
|
||||
qalGetInteger = NULL;
|
||||
qalGetFloat = NULL;
|
||||
qalGetDouble = NULL;
|
||||
qalGetError = NULL;
|
||||
qalIsExtensionPresent = NULL;
|
||||
qalGetProcAddress = NULL;
|
||||
qalGetEnumValue = NULL;
|
||||
qalListenerf = NULL;
|
||||
qalListener3f = NULL;
|
||||
qalListenerfv = NULL;
|
||||
qalListeneri = NULL;
|
||||
qalGetListenerf = NULL;
|
||||
qalGetListener3f = NULL;
|
||||
qalGetListenerfv = NULL;
|
||||
qalGetListeneri = NULL;
|
||||
qalGenSources = NULL;
|
||||
qalDeleteSources = NULL;
|
||||
qalIsSource = NULL;
|
||||
qalSourcef = NULL;
|
||||
qalSource3f = NULL;
|
||||
qalSourcefv = NULL;
|
||||
qalSourcei = NULL;
|
||||
qalGetSourcef = NULL;
|
||||
qalGetSource3f = NULL;
|
||||
qalGetSourcefv = NULL;
|
||||
qalGetSourcei = NULL;
|
||||
qalSourcePlayv = NULL;
|
||||
qalSourceStopv = NULL;
|
||||
qalSourceRewindv = NULL;
|
||||
qalSourcePausev = NULL;
|
||||
qalSourcePlay = NULL;
|
||||
qalSourceStop = NULL;
|
||||
qalSourceRewind = NULL;
|
||||
qalSourcePause = NULL;
|
||||
qalSourceQueueBuffers = NULL;
|
||||
qalSourceUnqueueBuffers = NULL;
|
||||
qalGenBuffers = NULL;
|
||||
qalDeleteBuffers = NULL;
|
||||
qalIsBuffer = NULL;
|
||||
qalBufferData = NULL;
|
||||
qalGetBufferf = NULL;
|
||||
qalGetBufferi = NULL;
|
||||
qalDopplerFactor = NULL;
|
||||
qalDopplerVelocity = NULL;
|
||||
qalDistanceModel = NULL;
|
||||
|
||||
qalcCreateContext = NULL;
|
||||
qalcMakeContextCurrent = NULL;
|
||||
qalcProcessContext = NULL;
|
||||
qalcSuspendContext = NULL;
|
||||
qalcDestroyContext = NULL;
|
||||
qalcGetCurrentContext = NULL;
|
||||
qalcGetContextsDevice = NULL;
|
||||
qalcOpenDevice = NULL;
|
||||
qalcCloseDevice = NULL;
|
||||
qalcGetError = NULL;
|
||||
qalcIsExtensionPresent = NULL;
|
||||
qalcGetProcAddress = NULL;
|
||||
qalcGetEnumValue = NULL;
|
||||
qalcGetString = NULL;
|
||||
qalcGetIntegerv = NULL;
|
||||
}
|
||||
#else
|
||||
qboolean QAL_Init(const char *libname)
|
||||
{
|
||||
return qtrue;
|
||||
}
|
||||
void QAL_Shutdown( void )
|
||||
{
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@@ -1,246 +0,0 @@
|
||||
/*
|
||||
===========================================================================
|
||||
Copyright (C) 1999-2005 Id Software, Inc.
|
||||
Copyright (C) 2000-2006 Tim Angus
|
||||
Copyright (C) 2005 Stuart Dalton (badcdev@gmail.com)
|
||||
|
||||
This file is part of Tremulous.
|
||||
|
||||
Tremulous is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
Tremulous is distributed in the hope that it will be
|
||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Tremulous; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
===========================================================================
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __QAL_H__
|
||||
#define __QAL_H__
|
||||
|
||||
#include "../qcommon/q_shared.h"
|
||||
#include "../qcommon/qcommon.h"
|
||||
|
||||
#if USE_OPENAL_DLOPEN
|
||||
#define AL_NO_PROTOTYPES
|
||||
#define ALC_NO_PROTOTYPES
|
||||
#endif
|
||||
|
||||
#if USE_LOCAL_HEADERS
|
||||
#include "../AL/al.h"
|
||||
#include "../AL/alc.h"
|
||||
#else
|
||||
#ifdef _MSC_VER
|
||||
// MSVC users must install the OpenAL SDK which doesn't use the AL/*.h scheme.
|
||||
#include <al.h>
|
||||
#include <alc.h>
|
||||
#else
|
||||
#include <AL/al.h>
|
||||
#include <AL/alc.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if USE_OPENAL_DLOPEN
|
||||
extern LPALENABLE qalEnable;
|
||||
extern LPALDISABLE qalDisable;
|
||||
extern LPALISENABLED qalIsEnabled;
|
||||
extern LPALGETSTRING qalGetString;
|
||||
extern LPALGETBOOLEANV qalGetBooleanv;
|
||||
extern LPALGETINTEGERV qalGetIntegerv;
|
||||
extern LPALGETFLOATV qalGetFloatv;
|
||||
extern LPALGETDOUBLEV qalGetDoublev;
|
||||
extern LPALGETBOOLEAN qalGetBoolean;
|
||||
extern LPALGETINTEGER qalGetInteger;
|
||||
extern LPALGETFLOAT qalGetFloat;
|
||||
extern LPALGETDOUBLE qalGetDouble;
|
||||
extern LPALGETERROR qalGetError;
|
||||
extern LPALISEXTENSIONPRESENT qalIsExtensionPresent;
|
||||
extern LPALGETPROCADDRESS qalGetProcAddress;
|
||||
extern LPALGETENUMVALUE qalGetEnumValue;
|
||||
extern LPALLISTENERF qalListenerf;
|
||||
extern LPALLISTENER3F qalListener3f;
|
||||
extern LPALLISTENERFV qalListenerfv;
|
||||
extern LPALLISTENERI qalListeneri;
|
||||
extern LPALLISTENER3I qalListener3i;
|
||||
extern LPALLISTENERIV qalListeneriv;
|
||||
extern LPALGETLISTENERF qalGetListenerf;
|
||||
extern LPALGETLISTENER3F qalGetListener3f;
|
||||
extern LPALGETLISTENERFV qalGetListenerfv;
|
||||
extern LPALGETLISTENERI qalGetListeneri;
|
||||
extern LPALGETLISTENER3I qalGetListener3i;
|
||||
extern LPALGETLISTENERIV qalGetListeneriv;
|
||||
extern LPALGENSOURCES qalGenSources;
|
||||
extern LPALDELETESOURCES qalDeleteSources;
|
||||
extern LPALISSOURCE qalIsSource;
|
||||
extern LPALSOURCEF qalSourcef;
|
||||
extern LPALSOURCE3F qalSource3f;
|
||||
extern LPALSOURCEFV qalSourcefv;
|
||||
extern LPALSOURCEI qalSourcei;
|
||||
extern LPALSOURCE3I qalSource3i;
|
||||
extern LPALSOURCEIV qalSourceiv;
|
||||
extern LPALGETSOURCEF qalGetSourcef;
|
||||
extern LPALGETSOURCE3F qalGetSource3f;
|
||||
extern LPALGETSOURCEFV qalGetSourcefv;
|
||||
extern LPALGETSOURCEI qalGetSourcei;
|
||||
extern LPALGETSOURCE3I qalGetSource3i;
|
||||
extern LPALGETSOURCEIV qalGetSourceiv;
|
||||
extern LPALSOURCEPLAYV qalSourcePlayv;
|
||||
extern LPALSOURCESTOPV qalSourceStopv;
|
||||
extern LPALSOURCEREWINDV qalSourceRewindv;
|
||||
extern LPALSOURCEPAUSEV qalSourcePausev;
|
||||
extern LPALSOURCEPLAY qalSourcePlay;
|
||||
extern LPALSOURCESTOP qalSourceStop;
|
||||
extern LPALSOURCEREWIND qalSourceRewind;
|
||||
extern LPALSOURCEPAUSE qalSourcePause;
|
||||
extern LPALSOURCEQUEUEBUFFERS qalSourceQueueBuffers;
|
||||
extern LPALSOURCEUNQUEUEBUFFERS qalSourceUnqueueBuffers;
|
||||
extern LPALGENBUFFERS qalGenBuffers;
|
||||
extern LPALDELETEBUFFERS qalDeleteBuffers;
|
||||
extern LPALISBUFFER qalIsBuffer;
|
||||
extern LPALBUFFERDATA qalBufferData;
|
||||
extern LPALBUFFERF qalBufferf;
|
||||
extern LPALBUFFER3F qalBuffer3f;
|
||||
extern LPALBUFFERFV qalBufferfv;
|
||||
extern LPALBUFFERF qalBufferi;
|
||||
extern LPALBUFFER3F qalBuffer3i;
|
||||
extern LPALBUFFERFV qalBufferiv;
|
||||
extern LPALGETBUFFERF qalGetBufferf;
|
||||
extern LPALGETBUFFER3F qalGetBuffer3f;
|
||||
extern LPALGETBUFFERFV qalGetBufferfv;
|
||||
extern LPALGETBUFFERI qalGetBufferi;
|
||||
extern LPALGETBUFFER3I qalGetBuffer3i;
|
||||
extern LPALGETBUFFERIV qalGetBufferiv;
|
||||
extern LPALDOPPLERFACTOR qalDopplerFactor;
|
||||
extern LPALDOPPLERVELOCITY qalDopplerVelocity;
|
||||
extern LPALSPEEDOFSOUND qalSpeedOfSound;
|
||||
extern LPALDISTANCEMODEL qalDistanceModel;
|
||||
|
||||
extern LPALCCREATECONTEXT qalcCreateContext;
|
||||
extern LPALCMAKECONTEXTCURRENT qalcMakeContextCurrent;
|
||||
extern LPALCPROCESSCONTEXT qalcProcessContext;
|
||||
extern LPALCSUSPENDCONTEXT qalcSuspendContext;
|
||||
extern LPALCDESTROYCONTEXT qalcDestroyContext;
|
||||
extern LPALCGETCURRENTCONTEXT qalcGetCurrentContext;
|
||||
extern LPALCGETCONTEXTSDEVICE qalcGetContextsDevice;
|
||||
extern LPALCOPENDEVICE qalcOpenDevice;
|
||||
extern LPALCCLOSEDEVICE qalcCloseDevice;
|
||||
extern LPALCGETERROR qalcGetError;
|
||||
extern LPALCISEXTENSIONPRESENT qalcIsExtensionPresent;
|
||||
extern LPALCGETPROCADDRESS qalcGetProcAddress;
|
||||
extern LPALCGETENUMVALUE qalcGetEnumValue;
|
||||
extern LPALCGETSTRING qalcGetString;
|
||||
extern LPALCGETINTEGERV qalcGetIntegerv;
|
||||
extern LPALCCAPTUREOPENDEVICE qalcCaptureOpenDevice;
|
||||
extern LPALCCAPTURECLOSEDEVICE qalcCaptureCloseDevice;
|
||||
extern LPALCCAPTURESTART qalcCaptureStart;
|
||||
extern LPALCCAPTURESTOP qalcCaptureStop;
|
||||
extern LPALCCAPTURESAMPLES qalcCaptureSamples;
|
||||
#else
|
||||
#define qalEnable alEnable
|
||||
#define qalDisable alDisable
|
||||
#define qalIsEnabled alIsEnabled
|
||||
#define qalGetString alGetString
|
||||
#define qalGetBooleanv alGetBooleanv
|
||||
#define qalGetIntegerv alGetIntegerv
|
||||
#define qalGetFloatv alGetFloatv
|
||||
#define qalGetDoublev alGetDoublev
|
||||
#define qalGetBoolean alGetBoolean
|
||||
#define qalGetInteger alGetInteger
|
||||
#define qalGetFloat alGetFloat
|
||||
#define qalGetDouble alGetDouble
|
||||
#define qalGetError alGetError
|
||||
#define qalIsExtensionPresent alIsExtensionPresent
|
||||
#define qalGetProcAddress alGetProcAddress
|
||||
#define qalGetEnumValue alGetEnumValue
|
||||
#define qalListenerf alListenerf
|
||||
#define qalListener3f alListener3f
|
||||
#define qalListenerfv alListenerfv
|
||||
#define qalListeneri alListeneri
|
||||
#define qalListener3i alListener3i
|
||||
#define qalListeneriv alListeneriv
|
||||
#define qalGetListenerf alGetListenerf
|
||||
#define qalGetListener3f alGetListener3f
|
||||
#define qalGetListenerfv alGetListenerfv
|
||||
#define qalGetListeneri alGetListeneri
|
||||
#define qalGetListener3i alGetListener3i
|
||||
#define qalGetListeneriv alGetListeneriv
|
||||
#define qalGenSources alGenSources
|
||||
#define qalDeleteSources alDeleteSources
|
||||
#define qalIsSource alIsSource
|
||||
#define qalSourcef alSourcef
|
||||
#define qalSource3f alSource3f
|
||||
#define qalSourcefv alSourcefv
|
||||
#define qalSourcei alSourcei
|
||||
#define qalSource3i alSource3i
|
||||
#define qalSourceiv alSourceiv
|
||||
#define qalGetSourcef alGetSourcef
|
||||
#define qalGetSource3f alGetSource3f
|
||||
#define qalGetSourcefv alGetSourcefv
|
||||
#define qalGetSourcei alGetSourcei
|
||||
#define qalGetSource3i alGetSource3i
|
||||
#define qalGetSourceiv alGetSourceiv
|
||||
#define qalSourcePlayv alSourcePlayv
|
||||
#define qalSourceStopv alSourceStopv
|
||||
#define qalSourceRewindv alSourceRewindv
|
||||
#define qalSourcePausev alSourcePausev
|
||||
#define qalSourcePlay alSourcePlay
|
||||
#define qalSourceStop alSourceStop
|
||||
#define qalSourceRewind alSourceRewind
|
||||
#define qalSourcePause alSourcePause
|
||||
#define qalSourceQueueBuffers alSourceQueueBuffers
|
||||
#define qalSourceUnqueueBuffers alSourceUnqueueBuffers
|
||||
#define qalGenBuffers alGenBuffers
|
||||
#define qalDeleteBuffers alDeleteBuffers
|
||||
#define qalIsBuffer alIsBuffer
|
||||
#define qalBufferData alBufferData
|
||||
#define qalBufferf alBufferf
|
||||
#define qalBuffer3f alBuffer3f
|
||||
#define qalBufferfv alBufferfv
|
||||
#define qalBufferi alBufferi
|
||||
#define qalBuffer3i alBuffer3i
|
||||
#define qalBufferiv alBufferiv
|
||||
#define qalGetBufferf alGetBufferf
|
||||
#define qalGetBuffer3f alGetBuffer3f
|
||||
#define qalGetBufferfv alGetBufferfv
|
||||
#define qalGetBufferi alGetBufferi
|
||||
#define qalGetBuffer3i alGetBuffer3i
|
||||
#define qalGetBufferiv alGetBufferiv
|
||||
#define qalDopplerFactor alDopplerFactor
|
||||
#define qalDopplerVelocity alDopplerVelocity
|
||||
#define qalSpeedOfSound alSpeedOfSound
|
||||
#define qalDistanceModel alDistanceModel
|
||||
|
||||
#define qalcCreateContext alcCreateContext
|
||||
#define qalcMakeContextCurrent alcMakeContextCurrent
|
||||
#define qalcProcessContext alcProcessContext
|
||||
#define qalcSuspendContext alcSuspendContext
|
||||
#define qalcDestroyContext alcDestroyContext
|
||||
#define qalcGetCurrentContext alcGetCurrentContext
|
||||
#define qalcGetContextsDevice alcGetContextsDevice
|
||||
#define qalcOpenDevice alcOpenDevice
|
||||
#define qalcCloseDevice alcCloseDevice
|
||||
#define qalcGetError alcGetError
|
||||
#define qalcIsExtensionPresent alcIsExtensionPresent
|
||||
#define qalcGetProcAddress alcGetProcAddress
|
||||
#define qalcGetEnumValue alcGetEnumValue
|
||||
#define qalcGetString alcGetString
|
||||
#define qalcGetIntegerv alcGetIntegerv
|
||||
#define qalcCaptureOpenDevice alcCaptureOpenDevice
|
||||
#define qalcCaptureCloseDevice alcCaptureCloseDevice
|
||||
#define qalcCaptureStart alcCaptureStart
|
||||
#define qalcCaptureStop alcCaptureStop
|
||||
#define qalcCaptureSamples alcCaptureSamples
|
||||
#endif
|
||||
|
||||
qboolean QAL_Init(const char *libname);
|
||||
void QAL_Shutdown( void );
|
||||
|
||||
#endif // __QAL_H__
|
||||
@@ -1,330 +0,0 @@
|
||||
/***********************************************************
|
||||
Copyright 1992 by Stichting Mathematisch Centrum, Amsterdam, The
|
||||
Netherlands.
|
||||
|
||||
All Rights Reserved
|
||||
|
||||
Permission to use, copy, modify, and distribute this software and its
|
||||
documentation for any purpose and without fee is hereby granted,
|
||||
provided that the above copyright notice appear in all copies and that
|
||||
both that copyright notice and this permission notice appear in
|
||||
supporting documentation, and that the names of Stichting Mathematisch
|
||||
Centrum or CWI not be used in advertising or publicity pertaining to
|
||||
distribution of the software without specific, written prior permission.
|
||||
|
||||
STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
|
||||
THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
|
||||
FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
|
||||
OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
******************************************************************/
|
||||
|
||||
/*
|
||||
** Intel/DVI ADPCM coder/decoder.
|
||||
**
|
||||
** The algorithm for this coder was taken from the IMA Compatability Project
|
||||
** proceedings, Vol 2, Number 2; May 1992.
|
||||
**
|
||||
** Version 1.2, 18-Dec-92.
|
||||
*/
|
||||
|
||||
#include "snd_local.h"
|
||||
|
||||
|
||||
/* Intel ADPCM step variation table */
|
||||
static int indexTable[16] = {
|
||||
-1, -1, -1, -1, 2, 4, 6, 8,
|
||||
-1, -1, -1, -1, 2, 4, 6, 8,
|
||||
};
|
||||
|
||||
static int stepsizeTable[89] = {
|
||||
7, 8, 9, 10, 11, 12, 13, 14, 16, 17,
|
||||
19, 21, 23, 25, 28, 31, 34, 37, 41, 45,
|
||||
50, 55, 60, 66, 73, 80, 88, 97, 107, 118,
|
||||
130, 143, 157, 173, 190, 209, 230, 253, 279, 307,
|
||||
337, 371, 408, 449, 494, 544, 598, 658, 724, 796,
|
||||
876, 963, 1060, 1166, 1282, 1411, 1552, 1707, 1878, 2066,
|
||||
2272, 2499, 2749, 3024, 3327, 3660, 4026, 4428, 4871, 5358,
|
||||
5894, 6484, 7132, 7845, 8630, 9493, 10442, 11487, 12635, 13899,
|
||||
15289, 16818, 18500, 20350, 22385, 24623, 27086, 29794, 32767
|
||||
};
|
||||
|
||||
|
||||
void S_AdpcmEncode( short indata[], char outdata[], int len, struct adpcm_state *state ) {
|
||||
short *inp; /* Input buffer pointer */
|
||||
signed char *outp; /* output buffer pointer */
|
||||
int val; /* Current input sample value */
|
||||
int sign; /* Current adpcm sign bit */
|
||||
int delta; /* Current adpcm output value */
|
||||
int diff; /* Difference between val and sample */
|
||||
int step; /* Stepsize */
|
||||
int valpred; /* Predicted output value */
|
||||
int vpdiff; /* Current change to valpred */
|
||||
int index; /* Current step change index */
|
||||
int outputbuffer; /* place to keep previous 4-bit value */
|
||||
int bufferstep; /* toggle between outputbuffer/output */
|
||||
|
||||
outp = (signed char *)outdata;
|
||||
inp = indata;
|
||||
|
||||
valpred = state->sample;
|
||||
index = state->index;
|
||||
step = stepsizeTable[index];
|
||||
|
||||
outputbuffer = 0; // quiet a compiler warning
|
||||
bufferstep = 1;
|
||||
|
||||
for ( ; len > 0 ; len-- ) {
|
||||
val = *inp++;
|
||||
|
||||
/* Step 1 - compute difference with previous value */
|
||||
diff = val - valpred;
|
||||
sign = (diff < 0) ? 8 : 0;
|
||||
if ( sign ) diff = (-diff);
|
||||
|
||||
/* Step 2 - Divide and clamp */
|
||||
/* Note:
|
||||
** This code *approximately* computes:
|
||||
** delta = diff*4/step;
|
||||
** vpdiff = (delta+0.5)*step/4;
|
||||
** but in shift step bits are dropped. The net result of this is
|
||||
** that even if you have fast mul/div hardware you cannot put it to
|
||||
** good use since the fixup would be too expensive.
|
||||
*/
|
||||
delta = 0;
|
||||
vpdiff = (step >> 3);
|
||||
|
||||
if ( diff >= step ) {
|
||||
delta = 4;
|
||||
diff -= step;
|
||||
vpdiff += step;
|
||||
}
|
||||
step >>= 1;
|
||||
if ( diff >= step ) {
|
||||
delta |= 2;
|
||||
diff -= step;
|
||||
vpdiff += step;
|
||||
}
|
||||
step >>= 1;
|
||||
if ( diff >= step ) {
|
||||
delta |= 1;
|
||||
vpdiff += step;
|
||||
}
|
||||
|
||||
/* Step 3 - Update previous value */
|
||||
if ( sign )
|
||||
valpred -= vpdiff;
|
||||
else
|
||||
valpred += vpdiff;
|
||||
|
||||
/* Step 4 - Clamp previous value to 16 bits */
|
||||
if ( valpred > 32767 )
|
||||
valpred = 32767;
|
||||
else if ( valpred < -32768 )
|
||||
valpred = -32768;
|
||||
|
||||
/* Step 5 - Assemble value, update index and step values */
|
||||
delta |= sign;
|
||||
|
||||
index += indexTable[delta];
|
||||
if ( index < 0 ) index = 0;
|
||||
if ( index > 88 ) index = 88;
|
||||
step = stepsizeTable[index];
|
||||
|
||||
/* Step 6 - Output value */
|
||||
if ( bufferstep ) {
|
||||
outputbuffer = (delta << 4) & 0xf0;
|
||||
} else {
|
||||
*outp++ = (delta & 0x0f) | outputbuffer;
|
||||
}
|
||||
bufferstep = !bufferstep;
|
||||
}
|
||||
|
||||
/* Output last step, if needed */
|
||||
if ( !bufferstep )
|
||||
*outp++ = outputbuffer;
|
||||
|
||||
state->sample = valpred;
|
||||
state->index = index;
|
||||
}
|
||||
|
||||
|
||||
/* static */ void S_AdpcmDecode( const char indata[], short *outdata, int len, struct adpcm_state *state ) {
|
||||
signed char *inp; /* Input buffer pointer */
|
||||
int outp; /* output buffer pointer */
|
||||
int sign; /* Current adpcm sign bit */
|
||||
int delta; /* Current adpcm output value */
|
||||
int step; /* Stepsize */
|
||||
int valpred; /* Predicted value */
|
||||
int vpdiff; /* Current change to valpred */
|
||||
int index; /* Current step change index */
|
||||
int inputbuffer; /* place to keep next 4-bit value */
|
||||
int bufferstep; /* toggle between inputbuffer/input */
|
||||
|
||||
outp = 0;
|
||||
inp = (signed char *)indata;
|
||||
|
||||
valpred = state->sample;
|
||||
index = state->index;
|
||||
step = stepsizeTable[index];
|
||||
|
||||
bufferstep = 0;
|
||||
inputbuffer = 0; // quiet a compiler warning
|
||||
for ( ; len > 0 ; len-- ) {
|
||||
|
||||
/* Step 1 - get the delta value */
|
||||
if ( bufferstep ) {
|
||||
delta = inputbuffer & 0xf;
|
||||
} else {
|
||||
inputbuffer = *inp++;
|
||||
delta = (inputbuffer >> 4) & 0xf;
|
||||
}
|
||||
bufferstep = !bufferstep;
|
||||
|
||||
/* Step 2 - Find new index value (for later) */
|
||||
index += indexTable[delta];
|
||||
if ( index < 0 ) index = 0;
|
||||
if ( index > 88 ) index = 88;
|
||||
|
||||
/* Step 3 - Separate sign and magnitude */
|
||||
sign = delta & 8;
|
||||
delta = delta & 7;
|
||||
|
||||
/* Step 4 - Compute difference and new predicted value */
|
||||
/*
|
||||
** Computes 'vpdiff = (delta+0.5)*step/4', but see comment
|
||||
** in adpcm_coder.
|
||||
*/
|
||||
vpdiff = step >> 3;
|
||||
if ( delta & 4 ) vpdiff += step;
|
||||
if ( delta & 2 ) vpdiff += step>>1;
|
||||
if ( delta & 1 ) vpdiff += step>>2;
|
||||
|
||||
if ( sign )
|
||||
valpred -= vpdiff;
|
||||
else
|
||||
valpred += vpdiff;
|
||||
|
||||
/* Step 5 - clamp output value */
|
||||
if ( valpred > 32767 )
|
||||
valpred = 32767;
|
||||
else if ( valpred < -32768 )
|
||||
valpred = -32768;
|
||||
|
||||
/* Step 6 - Update step value */
|
||||
step = stepsizeTable[index];
|
||||
|
||||
/* Step 7 - Output value */
|
||||
outdata[outp] = valpred;
|
||||
outp++;
|
||||
}
|
||||
|
||||
state->sample = valpred;
|
||||
state->index = index;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
====================
|
||||
S_AdpcmMemoryNeeded
|
||||
|
||||
Returns the amount of memory (in bytes) needed to store the samples in out internal adpcm format
|
||||
====================
|
||||
*/
|
||||
int S_AdpcmMemoryNeeded( const wavinfo_t *info ) {
|
||||
float scale;
|
||||
int scaledSampleCount;
|
||||
int sampleMemory;
|
||||
int blockCount;
|
||||
int headerMemory;
|
||||
|
||||
// determine scale to convert from input sampling rate to desired sampling rate
|
||||
scale = (float)info->rate / dma.speed;
|
||||
|
||||
// calc number of samples at playback sampling rate
|
||||
scaledSampleCount = info->samples / scale;
|
||||
|
||||
// calc memory need to store those samples using ADPCM at 4 bits per sample
|
||||
sampleMemory = scaledSampleCount / 2;
|
||||
|
||||
// calc number of sample blocks needed of PAINTBUFFER_SIZE
|
||||
blockCount = scaledSampleCount / PAINTBUFFER_SIZE;
|
||||
if( scaledSampleCount % PAINTBUFFER_SIZE ) {
|
||||
blockCount++;
|
||||
}
|
||||
|
||||
// calc memory needed to store the block headers
|
||||
headerMemory = blockCount * sizeof(adpcm_state_t);
|
||||
|
||||
return sampleMemory + headerMemory;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
====================
|
||||
S_AdpcmGetSamples
|
||||
====================
|
||||
*/
|
||||
void S_AdpcmGetSamples(sndBuffer *chunk, short *to) {
|
||||
adpcm_state_t state;
|
||||
byte *out;
|
||||
|
||||
// get the starting state from the block header
|
||||
state.index = chunk->adpcm.index;
|
||||
state.sample = chunk->adpcm.sample;
|
||||
|
||||
out = (byte *)chunk->sndChunk;
|
||||
// get samples
|
||||
S_AdpcmDecode((char *) out, to, SND_CHUNK_SIZE_BYTE*2, &state );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
====================
|
||||
S_AdpcmEncodeSound
|
||||
====================
|
||||
*/
|
||||
void S_AdpcmEncodeSound( sfx_t *sfx, short *samples ) {
|
||||
adpcm_state_t state;
|
||||
int inOffset;
|
||||
int count;
|
||||
int n;
|
||||
sndBuffer *newchunk, *chunk;
|
||||
byte *out;
|
||||
|
||||
inOffset = 0;
|
||||
count = sfx->soundLength;
|
||||
state.index = 0;
|
||||
state.sample = samples[0];
|
||||
|
||||
chunk = NULL;
|
||||
while( count ) {
|
||||
n = count;
|
||||
if( n > SND_CHUNK_SIZE_BYTE*2 ) {
|
||||
n = SND_CHUNK_SIZE_BYTE*2;
|
||||
}
|
||||
|
||||
newchunk = SND_malloc();
|
||||
if (sfx->soundData == NULL) {
|
||||
sfx->soundData = newchunk;
|
||||
} else {
|
||||
chunk->next = newchunk;
|
||||
}
|
||||
chunk = newchunk;
|
||||
|
||||
// output the header
|
||||
chunk->adpcm.index = state.index;
|
||||
chunk->adpcm.sample = state.sample;
|
||||
|
||||
out = (byte *)chunk->sndChunk;
|
||||
|
||||
// encode the samples
|
||||
S_AdpcmEncode( samples + inOffset, (char *) out, n, &state );
|
||||
|
||||
inOffset += n;
|
||||
count -= n;
|
||||
}
|
||||
}
|
||||
Loaded 100 of 363 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user