Merge branch 'master' into forge

This commit is contained in:
Jeff Teunissen 2010-11-28 03:05:30 -05:00
commit b0217bf0cf
260 changed files with 8453 additions and 5134 deletions

View file

@ -11,9 +11,9 @@ UNIX users: because of the diversity of machines QuakeForge runs on, we do not p
* GNU flex
* GNU make (BSD make doesn't like some constructs used)
* C compiler and preprocessor (gcc and cpp recommended)
* libsamplerate
The following are recommended:
* subversion (highly recommended for staying up to date with current
changes)
* git (highly recommended for staying up to date with current changes)
* zlib devel (highly recommended for compressed file and download support)
* Ogg Vorbis libs (for compressed sound effects support)
* X11 devel (for X11-based clients: software and OpenGL)

View file

@ -10,8 +10,8 @@ if test "$1" = "clean"; then
fi
find . -name Makefile.in -print0 | xargs $ARGS rm -f
find . -name config.h.in -print0 | xargs $ARGS rm -f
find . -name config.h -print0 | xargs $ARGS rm -f
find . -path ./tools/texpaint -prune -o -name config.h.in -print0 | xargs $ARGS rm -f
find . \( -path ./vc2005 -o -path ./vc2008 \) -prune -o -name config.h -print0 | xargs $ARGS rm -f
find . -name stamp-h1 -print0 | xargs $ARGS rm -f
find . -name '*~' -type f -print0 | xargs $ARGS rm -f
find . -name '*.rej' -type f -print0 | xargs $ARGS rm -f
@ -23,7 +23,7 @@ if test "$1" = "clean"; then
rm -rf autom4te.cache
cd -
find . -name Makefile -print0 | xargs $ARGS rm -f
find . \( -path ./tools/gas2masm -o -path ./tools/quaketoascii \) -name Makefile -print0 | xargs $ARGS rm -f
find . -name core -print0 | xargs $ARGS rm -f
rm -f RPM/build_rpm RPM/quakeforge.conf RPM/quakeforge.spec RPM/rpmmacros
find . -name '*.o' -type f -print0 | xargs $ARGS rm -f
@ -49,15 +49,15 @@ if test -n "$lt" ; then
LTIZE_VER_MAJOR=`echo $LTIZE_VER | cut -f1 -d'.'`
LTIZE_VER_MINOR=`echo $LTIZE_VER | cut -f2 -d'.' | sed -e 's/[^0-9]//g'`
if test "$LTIZE_VER_MAJOR" -lt "2"; then
errors="Libtool 1.4 or greater needed to build configure.\n$errors"
if test "$LTIZE_VER_MAJOR" -lt "1"; then
errors="Libtool 1.5 or greater needed to build configure.\n$errors"
fi
if test "$LTIZE_VER_MAJOR" -eq "2" -a "$LTIZE_VER_MINOR" -lt "2" ; then
errors="Libtool 1.4 or greater needed to build configure.\n$errors"
if test "$LTIZE_VER_MAJOR" -eq "1" -a "$LTIZE_VER_MINOR" -lt "5" ; then
errors="Libtool 1.5 or greater needed to build configure.\n$errors"
fi
fi
else
errors="Libtool not found. QuakeForge CVS requires libtool to bootstrap itself.\n$errors"
errors="Libtool not found. QuakeForge git requires libtool to bootstrap itself.\n$errors"
fi
# Check Autoconf version
@ -69,15 +69,15 @@ if test -n "$ac" ; then
AC_VER_MINOR=`echo $AC_VER | cut -f2 -d'.' | sed 's/[^0-9]*$//'`
if test "$AC_VER_MAJOR" -lt "2" ; then
errors="Autoconf 2.67 or greater needed to build configure.\n$errors"
errors="Autoconf 2.61 or greater needed to build configure.\n$errors"
fi
if test "$AC_VER_MAJOR" -eq "2" -a "$AC_VER_MINOR" -lt "67" ; then
errors="Autoconf 2.67 or greater needed to build configure.\n$errors"
if test "$AC_VER_MAJOR" -eq "2" -a "$AC_VER_MINOR" -lt "61" ; then
errors="Autoconf 2.61 or greater needed to build configure.\n$errors"
fi
fi
else
errors="Autoconf not found. QuakeForge CVS requires autoconf to bootstrap itself.\n$errors"
errors="Autoconf not found. QuakeForge git requires autoconf to bootstrap itself.\n$errors"
fi
am=`which automake`
@ -87,14 +87,14 @@ if test -n "$am" ; then
AM_VER_MAJOR=`echo $AM_VER | cut -f1 -d.`
AM_VER_MINOR=`echo $AM_VER | cut -f2 -d.`
if test "$AM_VER_MAJOR" -lt "1"; then
errors="Automake 1.6 or greater needed to build makefiles.\n$errors"
errors="Automake 1.10 or greater needed to build makefiles.\n$errors"
fi
if test "$AM_VER_MAJOR" -eq "1" -a "$AM_VER_MINOR" -lt "11"; then
errors="Automake 1.11 or greater needed to build makefiles.\n$errors"
if test "$AM_VER_MAJOR" -eq "1" -a "$AM_VER_MINOR" -lt "10"; then
errors="Automake 1.10 or greater needed to build makefiles.\n$errors"
fi
fi
else
errors="Automake not found. QuakeForge CVS requires automake to bootstrap itself.\n$errors"
errors="Automake not found. QuakeForge git requires automake to bootstrap itself.\n$errors"
fi
if test -n "$errors" ; then

View file

@ -1,5 +1,5 @@
dnl Process this file with autoconf to produce a configure script.
AC_PREREQ(2.67)
AC_PREREQ(2.61)
dnl This is the only place where the package name and version appear
AC_INIT([QuakeForge], [git-master])
@ -10,7 +10,8 @@ if test "x${CFLAGS-unset}" = xunset; then
CFLAGS=""
fi
saved_CFLAGS="$CFLAGS"
LT_INIT([win32-dll])
dnl LT_INIT([win32-dll])
AM_PROG_LIBTOOL
CFLAGS="$saved_CFLAGS"
AC_REVISION([$Revision$]) dnl

2
debian/control vendored
View file

@ -3,7 +3,7 @@ Section: contrib/games
Priority: optional
Maintainer: Jeff Teunissen <deek@debian.org>
Standards-Version: 3.1.1
Build-Depends: automake (>= 1.8) | automake1.8, autoconf, libtool, bison, flex, debhelper, libsdl1.2-dev, zlib1g-dev, libncurses5-dev, xorg-dev | xlibs-dev (>= 4), libasound2-dev, libogg-dev, libvorbis-dev, libflac-dev, libpng12-dev
Build-Depends: automake (>= 1.8) | automake1.8, autoconf, libtool, bison, flex, debhelper, libsdl1.2-dev, zlib1g-dev, libncurses5-dev, xorg-dev | xlibs-dev (>= 4), libasound2-dev, libogg-dev, libvorbis-dev, libflac-dev, libpng12-dev, libsamplerate0-dev, git-core, x11proto-xf86vidmode-dev
Package: quakeforge
Architecture: any

4
debian/rules vendored
View file

@ -38,7 +38,7 @@ configure: configure-stamp
configure-stamp:
dh_testdir
# Add here commands to configure the package.
if test -d CVS; then ./bootstrap; fi
if test -d .git; then ./bootstrap; fi
./configure --prefix=/usr $(RETARGET) --bindir=/usr/games \
--without-fbdev \
--disable-xmms \
@ -60,7 +60,7 @@ build-stamp:
changelog-stamp:
dh_testdir
# Add here commands to build the changelog
if test -d CVS; then $(MAKE) changelog; fi
if test -d .git; then $(MAKE) changelog; fi
touch $@
clean:

52
doc/filesystem.txt Normal file
View file

@ -0,0 +1,52 @@
//unfortunately, have to wrap the docs in a C comment for doxygen
/**
\page filesystem QuakeForge Directory Trees
The QuakeForge directory trees resemble that of Quake, but have been made
more suitable for multi-user systems. The directory trees have been split
into "shared data" and "user data".
The shared data tree is intended to be in a read-only location that is
accessible by permitted users of the system. The contents of the shared
data will usually be the game data as extracted from the Quake or mission
pack CDs, or mod data downloaded from the internet.
The user data tree is intended to be private to the individual user and will
usually be in the user's home directory. The user data tree usually starts
out empty as it is created by QuakeForge when needed, but user configs,
saved games, recorded demos, screen-shots, quakeworld downloads etc will be
written to the user data tree. Also, QuakeC/Ruamoko file access is
generally restricted to the user data tree. Files in the user data tree
take precedence over files in the shared data tree.
Except for the system configuration file, the user configuration file, and
the directory configuration file, QuakeForge will not read any file outside
of the shared or user data trees.
The shared data tree is specified by the \c fs_sharepath cvar. The default
value varies depending on the system, but will generally be either \c
/usr/local/share/games/quakeforge or \c /usr/share/games/quakeforge on
Linux or other UNIX like systems, and \c . (the current directory) on
Windows systems.
The user data tree is specified by the \c fs_userpath cvar. The default
value varies depending on the system, but will generally be \c
~/.quakeforge or \c ~/.local/share/quakeforge on Linux or other UNIX like
systems, and \c . (the current directory) on Windows systems.
The user data tree and the shared data tree being in the same place is
quite valid, and QuakeForge is smart enough to not search twice for files
when the trees are in the same place.
Once QuakeForge is running, \c fs_sharepath and \c fs_userpath cannot be
altered. However, they may be altered by setting them in the system
configuration file, the user configuration file, or on the command line.
The internal layout of the shared and user data trees are, by default, the
same as Quake (an \c id1 directory tree, plus other mod directories), but
with the addition of a \c QF directory which holds QuakeForge specific data
(such as the menus). The structure of the data trees and, more importantly,
the relationship between the mod directories can be configured with the
directory configurtion file (see \ref dirconf).
*/

View file

@ -308,7 +308,7 @@ EXTRACT_PRIVATE = NO
# If the EXTRACT_STATIC tag is set to YES all static members of a file
# will be included in the documentation.
EXTRACT_STATIC = NO
EXTRACT_STATIC = YES
# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs)
# defined locally in source files will be included in the documentation.
@ -426,7 +426,7 @@ SORT_MEMBERS_CTORS_1ST = NO
# hierarchy of group names into alphabetical order. If set to NO (the default)
# the group names will appear in their defined order.
SORT_GROUP_NAMES = NO
SORT_GROUP_NAMES = YES
# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be
# sorted by fully-qualified names, including namespaces. If set to
@ -592,6 +592,7 @@ INPUT += @TOPSRC@/doc/connect.txt
INPUT += @TOPSRC@/doc/cshifts.txt
INPUT += @TOPSRC@/doc/dirconf.txt
INPUT += @TOPSRC@/doc/faq.txt
INPUT += @TOPSRC@/doc/filesystem.txt
INPUT += @TOPSRC@/doc/mapformat.txt
INPUT += @TOPSRC@/doc/quakeforge.txt
INPUT += @TOPSRC@/doc/qw-cap-spec.txt

View file

@ -11,6 +11,7 @@ of players we can.
\li \subpage faq
\li \subpage key_binding
\li \subpage cshift_cvars
\li \subpage filesystem
\li \subpage dirconf
\li \subpage qw_cap_spec
\li \subpage qw_download_spec

View file

@ -33,36 +33,34 @@
// upper design bounds
#define MAX_MAP_HULLS 4
#define MAX_MAP_HULLS 4
#define MAX_MAP_MODELS 256
#define MAX_MAP_BRUSHES 4096
#define MAX_MAP_ENTITIES 1024
#define MAX_MAP_ENTSTRING 65536
#define MAX_MAP_MODELS 256
#define MAX_MAP_BRUSHES 4096
#define MAX_MAP_ENTITIES 1024
#define MAX_MAP_ENTSTRING 65536
#define MAX_MAP_PLANES 32767
//#define MAX_MAP_PLANES 8192
#define MAX_MAP_NODES 32767 // because negative shorts are contents
#define MAX_MAP_CLIPNODES 32767 //
#define MAX_MAP_LEAFS 32767 //
//#define MAX_MAP_LEAFS 8192
#define MAX_MAP_VERTS 65535
#define MAX_MAP_FACES 65535
#define MAX_MAP_MARKSURFACES 65535
#define MAX_MAP_TEXINFO 4096
#define MAX_MAP_EDGES 256000
#define MAX_MAP_SURFEDGES 512000
#define MAX_MAP_TEXTURES 512
#define MAX_MAP_MIPTEX 0x200000
#define MAX_MAP_LIGHTING 0x100000
#define MAX_MAP_VISIBILITY 0x100000
#define MAX_MAP_PLANES 32767
#define MAX_MAP_NODES 32767 // because negative shorts are contents
#define MAX_MAP_CLIPNODES 32767 //
#define MAX_MAP_LEAFS 32767 //
#define MAX_MAP_VERTS 65535
#define MAX_MAP_FACES 65535
#define MAX_MAP_MARKSURFACES 65535
#define MAX_MAP_TEXINFO 4096
#define MAX_MAP_EDGES 256000
#define MAX_MAP_SURFEDGES 512000
#define MAX_MAP_TEXTURES 512
#define MAX_MAP_MIPTEX 0x200000
#define MAX_MAP_LIGHTING 0x100000
#define MAX_MAP_VISIBILITY 0x100000
#define MAX_MAP_PORTALS 65536
#define MAX_MAP_PORTALS 65536
// key / value pair sizes
#define MAX_KEY 32
#define MAX_VALUE 1024
#define MAX_KEY 32
#define MAX_VALUE 1024
//=============================================================================
@ -72,227 +70,263 @@
#define BSPVERSION 29
#define Q2BSPVERSION 38
#define TOOLVERSION 2
#define TOOLVERSION 2
typedef struct lump_s {
int fileofs;
int filelen;
int32_t fileofs;
int32_t filelen;
} lump_t;
#define LUMP_ENTITIES 0
#define LUMP_PLANES 1
#define LUMP_TEXTURES 2
#define LUMP_VERTEXES 3
#define LUMP_VISIBILITY 4
#define LUMP_NODES 5
#define LUMP_TEXINFO 6
#define LUMP_FACES 7
#define LUMP_LIGHTING 8
#define LUMP_CLIPNODES 9
#define LUMP_LEAFS 10
#define LUMP_MARKSURFACES 11
#define LUMP_EDGES 12
#define LUMP_SURFEDGES 13
#define LUMP_MODELS 14
#define HEADER_LUMPS 15
#define LUMP_ENTITIES 0
#define LUMP_PLANES 1
#define LUMP_TEXTURES 2
#define LUMP_VERTEXES 3
#define LUMP_VISIBILITY 4
#define LUMP_NODES 5
#define LUMP_TEXINFO 6
#define LUMP_FACES 7
#define LUMP_LIGHTING 8
#define LUMP_CLIPNODES 9
#define LUMP_LEAFS 10
#define LUMP_MARKSURFACES 11
#define LUMP_EDGES 12
#define LUMP_SURFEDGES 13
#define LUMP_MODELS 14
#define HEADER_LUMPS 15
typedef struct dmodel_s {
float mins[3], maxs[3];
float origin[3];
int headnode[MAX_MAP_HULLS];
int visleafs; // not including the solid leaf 0
int firstface, numfaces;
float mins[3], maxs[3];
float origin[3];
int32_t headnode[MAX_MAP_HULLS];
int32_t visleafs; // not including the solid leaf 0
int32_t firstface, numfaces;
} dmodel_t;
typedef struct dheader_s {
int version;
lump_t lumps[HEADER_LUMPS];
int32_t version;
lump_t lumps[HEADER_LUMPS];
} dheader_t;
typedef struct dmiptexlump_s {
int nummiptex;
int dataofs[4]; // [nummiptex]
int32_t nummiptex;
int32_t dataofs[4]; // [nummiptex]
} dmiptexlump_t;
#define MIPLEVELS 4
#define MIPLEVELS 4
typedef struct miptex_s {
char name[16];
unsigned int width, height;
unsigned int offsets[MIPLEVELS]; // four mip maps stored
char name[16];
uint32_t width, height;
uint32_t offsets[MIPLEVELS]; // four mip maps stored
} miptex_t;
typedef struct dvertex_s {
float point[3];
float point[3];
} dvertex_t;
// 0-2 are axial planes
#define PLANE_X 0
#define PLANE_Y 1
#define PLANE_Z 2
#define PLANE_X 0
#define PLANE_Y 1
#define PLANE_Z 2
// 3-5 are non-axial planes snapped to the nearest
#define PLANE_ANYX 3
#define PLANE_ANYY 4
#define PLANE_ANYZ 5
#define PLANE_ANYX 3
#define PLANE_ANYY 4
#define PLANE_ANYZ 5
typedef struct dplane_s {
float normal[3];
float dist;
int type; // PLANE_X - PLANE_ANYZ ?remove? trivial to regenerate
float normal[3];
float dist;
int32_t type; // PLANE_X - PLANE_ANYZ
} dplane_t;
#define CONTENTS_EMPTY -1
#define CONTENTS_SOLID -2
#define CONTENTS_WATER -3
#define CONTENTS_SLIME -4
#define CONTENTS_LAVA -5
#define CONTENTS_SKY -6
#define CONTENTS_ORIGIN -7 // removed at csg time
#define CONTENTS_CLIP -8 // changed to contents_solid
#define CONTENTS_EMPTY -1
#define CONTENTS_SOLID -2
#define CONTENTS_WATER -3
#define CONTENTS_SLIME -4
#define CONTENTS_LAVA -5
#define CONTENTS_SKY -6
#define CONTENTS_ORIGIN -7 // removed at csg time
#define CONTENTS_CLIP -8 // changed to contents_solid
#define CONTENTS_CURRENT_0 -9
#define CONTENTS_CURRENT_90 -10
#define CONTENTS_CURRENT_180 -11
#define CONTENTS_CURRENT_270 -12
#define CONTENTS_CURRENT_UP -13
#define CONTENTS_CURRENT_DOWN -14
#define CONTENTS_CURRENT_0 -9
#define CONTENTS_CURRENT_90 -10
#define CONTENTS_CURRENT_180 -11
#define CONTENTS_CURRENT_270 -12
#define CONTENTS_CURRENT_UP -13
#define CONTENTS_CURRENT_DOWN -14
// !!! if this is changed, it must be changed in asm_i386.h too !!!
typedef struct dnode_s {
int planenum;
short children[2]; // negative numbers are -(leafs+1), not nodes
short mins[3]; // for sphere culling
short maxs[3];
unsigned short firstface;
unsigned short numfaces; // counting both sides
int32_t planenum;
int16_t children[2]; // negative numbers are -(leafs+1), not nodes
int16_t mins[3]; // for sphere culling
int16_t maxs[3];
uint16_t firstface;
uint16_t numfaces; // counting both sides
} dnode_t;
typedef struct dclipnode_s {
int planenum;
short children[2]; // negative numbers are contents
int32_t planenum;
int16_t children[2]; // negative numbers are contents
} dclipnode_t;
typedef struct texinfo_s {
float vecs[2][4]; // [s/t][xyz offset]
int miptex;
int flags;
float vecs[2][4]; // [s/t][xyz offset]
int32_t miptex;
int32_t flags;
} texinfo_t;
#define TEX_SPECIAL 1 // sky or slime, no lightmap or 256 subdivision
#define TEX_SPECIAL 1 // sky or slime, no lightmap or 256 subdivision
#define TEX_MISSING 2 // this texinfo does not have a texture
// note that edge 0 is never used, because negative edge nums are used for
// counterclockwise use of the edge in a face
typedef struct dedge_s {
unsigned short v[2]; // vertex numbers
uint16_t v[2]; // vertex numbers
} dedge_t;
#define MAXLIGHTMAPS 4
#define MAXLIGHTMAPS 4
typedef struct dface_s {
short planenum;
short side;
int16_t planenum;
int16_t side;
int firstedge; // we must support > 64k edges
short numedges;
short texinfo;
int32_t firstedge; // we must support > 64k edges
int16_t numedges;
int16_t texinfo;
// lighting info
byte styles[MAXLIGHTMAPS];
int lightofs; // start of [numstyles*surfsize] samples
byte styles[MAXLIGHTMAPS];
int32_t lightofs; // start of [numstyles*surfsize] samples
} dface_t;
#define AMBIENT_WATER 0
#define AMBIENT_SKY 1
#define AMBIENT_SLIME 2
#define AMBIENT_LAVA 3
#define AMBIENT_WATER 0
#define AMBIENT_SKY 1
#define AMBIENT_SLIME 2
#define AMBIENT_LAVA 3
#define NUM_AMBIENTS 4 // automatic ambient sounds
#define NUM_AMBIENTS 4 // automatic ambient sounds
// leaf 0 is the generic CONTENTS_SOLID leaf, used for all solid areas
// all other leafs need visibility info
typedef struct dleaf_s {
int contents;
int visofs; // -1 = no visibility info
int32_t contents;
int32_t visofs; // -1 = no visibility info
short mins[3]; // for frustum culling
short maxs[3];
int16_t mins[3]; // for frustum culling
int16_t maxs[3];
unsigned short firstmarksurface;
unsigned short nummarksurfaces;
uint16_t firstmarksurface;
uint16_t nummarksurfaces;
byte ambient_level[NUM_AMBIENTS];
byte ambient_level[NUM_AMBIENTS];
} dleaf_t;
//============================================================================
typedef struct bsp_s {
int nummodels;
dmodel_t *models;
int own_header;
dheader_t *header;
int visdatasize;
byte *visdata;
int own_models;
int nummodels;
dmodel_t *models;
int lightdatasize;
byte *lightdata;
int own_visdata;
size_t visdatasize;
byte *visdata;
int texdatasize;
byte *texdata; // (dmiptexlump_t)
int own_lightdata;
size_t lightdatasize;
byte *lightdata;
int entdatasize;
char *entdata;
int own_texdata;
size_t texdatasize;
byte *texdata; // (dmiptexlump_t)
int numleafs;
dleaf_t *leafs;
int own_entdata;
size_t entdatasize;
char *entdata;
int numplanes;
dplane_t *planes;
int own_leafs;
int numleafs;
dleaf_t *leafs;
int numvertexes;
dvertex_t *vertexes;
int own_planes;
int numplanes;
dplane_t *planes;
int numnodes;
dnode_t *nodes;
int own_vertexes;
int numvertexes;
dvertex_t *vertexes;
int numtexinfo;
texinfo_t *texinfo;
int own_nodes;
int numnodes;
dnode_t *nodes;
int numfaces;
dface_t *faces;
int own_texinfo;
int numtexinfo;
texinfo_t *texinfo;
int numclipnodes;
dclipnode_t *clipnodes;
int own_faces;
int numfaces;
dface_t *faces;
int numedges;
dedge_t *edges;
int own_clipnodes;
int numclipnodes;
dclipnode_t *clipnodes;
int nummarksurfaces;
unsigned short *marksurfaces;
int own_edges;
int numedges;
dedge_t *edges;
int numsurfedges;
int *surfedges;
int own_marksurfaces;
int nummarksurfaces;
uint16_t *marksurfaces;
int own_surfedges;
int numsurfedges;
int32_t *surfedges;
} bsp_t;
bsp_t *LoadBSPMem (void *mem, int size);
bsp_t *LoadBSPFile (QFile *file, int size);
void WriteBSPFile (bsp_t *bsp, QFile *file);
bsp_t *BSP_New (void);
void BSP_AddPlane (bsp_t *bsp, dplane_t *plane);
void BSP_AddLeaf (bsp_t *bsp, dleaf_t *leaf);
void BSP_AddVertex (bsp_t *bsp, dvertex_t *vertex);
void BSP_AddNode (bsp_t *bsp, dnode_t *node);
void BSP_AddTexinfo (bsp_t *bsp, texinfo_t *texinfo);
void BSP_AddFace (bsp_t *bsp, dface_t *face);
void BSP_AddClipnode (bsp_t *bsp, dclipnode_t *clipnode);
void BSP_AddMarkSurface (bsp_t *bsp, unsigned short marksurface);
void BSP_AddSurfEdge (bsp_t *bsp, int surfedge);
void BSP_AddEdge (bsp_t *bsp, dedge_t *edge);
void BSP_AddModel (bsp_t *bsp, dmodel_t *model);
void BSP_AddLighting (bsp_t *bsp, byte *lightdata, int lightdatasize);
void BSP_AddVisibility (bsp_t *bsp, byte *visdata, int visdatasize);
void BSP_AddEntities (bsp_t *bsp, char *entdata, int entdatasize);
void BSP_AddTextures (bsp_t *bsp, byte *texdata, int texdatasize);
/** Create a bsp structure from a memory buffer.
The returned structure will be setup to point into the supplied buffer.
All structures within the bsp will be byte-swapped. For this reason, if
a callback is provided, the callback be called after byteswapping the
header, but before byteswapping any data in the lumps.
#endif // __bspfile_h_
\param mem The buffer holding the bsp data.
\param size The size of the buffer. This is used for sanity checking.
\param cb Pointer to the callback function.
\param cbdata Pointer to extra data for the callback.
\return Initialized bsp structure.
\note The caller maintains ownership of the memory buffer. BSP_Free will
free only the bsp structure itself. However, if the caller wishes to
relinquish ownership of the buffer, set bsp_t::own_header to true.
*/
bsp_t *LoadBSPMem (void *mem, size_t size, void (*cb) (const bsp_t *, void *),
void *cbdata);
bsp_t *LoadBSPFile (QFile *file, size_t size);
void WriteBSPFile (const bsp_t *bsp, QFile *file);
bsp_t *BSP_New (void);
void BSP_Free (bsp_t *bsp);
void BSP_AddPlane (bsp_t *bsp, const dplane_t *plane);
void BSP_AddLeaf (bsp_t *bsp, const dleaf_t *leaf);
void BSP_AddVertex (bsp_t *bsp, const dvertex_t *vertex);
void BSP_AddNode (bsp_t *bsp, const dnode_t *node);
void BSP_AddTexinfo (bsp_t *bsp, const texinfo_t *texinfo);
void BSP_AddFace (bsp_t *bsp, const dface_t *face);
void BSP_AddClipnode (bsp_t *bsp, const dclipnode_t *clipnode);
void BSP_AddMarkSurface (bsp_t *bsp, int marksurface);
void BSP_AddSurfEdge (bsp_t *bsp, int surfedge);
void BSP_AddEdge (bsp_t *bsp, const dedge_t *edge);
void BSP_AddModel (bsp_t *bsp, const dmodel_t *model);
void BSP_AddLighting (bsp_t *bsp, const byte *lightdata, size_t lightdatasize);
void BSP_AddVisibility (bsp_t *bsp, const byte *visdata, size_t visdatasize);
void BSP_AddEntities (bsp_t *bsp, const char *entdata, size_t entdatasize);
void BSP_AddTextures (bsp_t *bsp, const byte *texdata, size_t texdatasize);
#endif//__bspfile_h_

View file

@ -37,23 +37,22 @@
#include "QF/qtypes.h"
#include "QF/quakeio.h"
typedef struct cvar_s
{
const char *name;
const char *string;
int flags;
void (*callback)(struct cvar_s *var);
const char *description; // for "help" command
float value;
int int_val;
vec3_t vec;
typedef struct cvar_s {
const char *name;
const char *string;
const char *default_string;
int flags;
void (*callback)(struct cvar_s *var);
const char *description; // for "help" command
float value;
int int_val;
vec3_t vec;
struct cvar_s *next;
} cvar_t;
typedef struct cvar_alias_s
{
char *name;
cvar_t *cvar;
typedef struct cvar_alias_s {
char *name;
cvar_t *cvar;
struct cvar_alias_s *next;
} cvar_alias_t;
@ -96,6 +95,9 @@ void Cvar_SetROM (cvar_t *var, const char *value);
// allows you to change a Cvar's flags without a full Cvar_Get
void Cvar_SetFlags (cvar_t *var, int cvarflags);
// reset a Cvar to its default setting
void Cvar_Reset (cvar_t *var);
// returns 0 if not defined or non numeric
float Cvar_VariableValue (const char *var_name);

View file

@ -436,7 +436,7 @@ model_t *Mod_FindName (const char *name);
void Mod_ProcessTexture(miptex_t *mt, texture_t *tx);
void Mod_LoadExternalSkins (model_t * mod);
void Mod_LoadExternalTextures (model_t * mod);
void Mod_LoadLighting (lump_t *l);
void Mod_LoadLighting (bsp_t *bsp);
int Mod_CalcFullbright (byte *in, byte *out, int pixels);
int Mod_Fullbright (byte * skin, int width, int height, char *name);

View file

@ -46,7 +46,8 @@ void MSG_WriteCoordAngleV (sizebuf_t *sb, const vec3_t coord,
const vec3_t angles);
void MSG_WriteAngle (sizebuf_t *sb, float angle);
void MSG_WriteAngleV (sizebuf_t *sb, const vec3_t angles);
void MSG_WriteAngle16 (sizebuf_t *sb, float angle16);
void MSG_WriteAngle16 (sizebuf_t *sb, float angle);
void MSG_WriteAngle16V (sizebuf_t *sb, const vec3_t angle);
void MSG_WriteUTF8 (sizebuf_t *sb, unsigned utf8);
typedef struct msg_s {
@ -72,6 +73,7 @@ float MSG_ReadAngle (qmsg_t *msg);
void MSG_ReadCoordAngleV (qmsg_t *msg, vec3_t coord, vec3_t angles);
void MSG_ReadAngleV (qmsg_t *msg, vec3_t angles);
float MSG_ReadAngle16 (qmsg_t *msg);
void MSG_ReadAngle16V (qmsg_t *msg, vec3_t angles);
int MSG_ReadUTF8 (qmsg_t *msg);
//@}

View file

@ -34,12 +34,9 @@
#define MAX_QPATH 64
#define MAX_CL_STATS 32
#define NUM_CSHIFTS 4
#define MAX_MODELS 256
#define MAX_SOUNDS 256
#define MAX_SCOREBOARD 16
#define MAX_SCOREBOARDNAME 32
#define MAX_STYLESTRING 64
#define MAX_EDICTS 768
#define MAX_LIGHTSTYLES 64
#define clc_stringcmd 4

View file

@ -88,7 +88,7 @@ typedef struct plitem_s plitem_t;
\param string the saved plist, as read from a file.
\return Returns an object equivalent to the passed-in string.
\note You are responsible for freeing the object returned.
\note You are responsible for freeing the returned object.
*/
plitem_t *PL_GetPropertyList (const char *string);
@ -96,7 +96,7 @@ plitem_t *PL_GetPropertyList (const char *string);
\param pl the in-memory representation
\return the text representation of the property list
\note You are responsible for freeing the string returned.
\note You are responsible for freeing the returned string.
*/
char *PL_WritePropertyList (plitem_t *pl);
@ -167,7 +167,7 @@ int PL_D_NumKeys (plitem_t *dict);
/** Add a key/value pair to a dictionary.
\param dict The dictionary to add the key/value pair to
\param dict The dictionary to which the key/value pair will be added
\param key The key of the key/value pair to be added to the dictionary
\param value The value of the key/value pair to be added to the dictionary
@ -179,7 +179,7 @@ qboolean PL_D_AddObject (plitem_t *dict, const char *key, plitem_t *value);
/** Add an item to an array.
\param array The array to add the item to
\param array The array to which the item will be added
\param item The item to be added to the array
\return true on success, false on failure
@ -190,7 +190,7 @@ qboolean PL_A_AddObject (plitem_t *array, plitem_t *item);
/** Retrieve the number of items in an array.
\param array The array to get the number of objects in
\param array The array from which to get the number of objects
\return number of objects in the array
*/
@ -198,7 +198,7 @@ int PL_A_NumObjects (plitem_t *array);
/** Insert an item into an array before the specified location.
\param array The array to add the item to
\param array The array to which the item will be added
\param item The item to be added to the array
\param index The location at which to insert the item into the array
@ -211,7 +211,7 @@ qboolean PL_A_InsertObjectAtIndex (plitem_t *array, plitem_t *item, int index);
/** Remove a value from an array object.
The array items will be shuffled to fill the resulting hole.
\param array The array to get the value from
\param array The array from which to remove the value
\param index The index within the array to remove
\return the value associated with the index, or NULL if not found or array
isn't an array.

View file

@ -66,8 +66,14 @@ extern lightstyle_t r_lightstyle[MAX_LIGHTSTYLES];
#define TOP_RANGE 16 // soldier uniform colors
#define BOTTOM_RANGE 96
typedef struct entity_s
{
#define LERP_MOVESTEP (1<<0) //this is a MOVETYPE_STEP entity, enable movement lerp
#define LERP_RESETANIM (1<<1) //disable anim lerping until next anim frame
#define LERP_RESETANIM2 (1<<2) //set this and previous flag to disable anim lerping for two anim frames
#define LERP_RESETMOVE (1<<3) //disable movement lerping until next origin/angles change
#define LERP_FINISH (1<<4) //use lerpfinish time from server update instead of assuming interval of 0.1
typedef struct entity_s {
vec3_t origin;
vec3_t old_origin;
vec3_t angles;
@ -94,10 +100,18 @@ typedef struct entity_s
// splits bmodel, or NULL if not split
// Animation interpolation
float frame_start_time;
float frame_interval;
int pose1;
int pose2;
// FIXME separate struct?
byte lerpflags;
float lerpstart;
float lerptime;
float lerpfinish;
short previouspose;
short currentpose;
float movelerpstart;
vec3_t previousorigin;
vec3_t currentorigin;
vec3_t previousangles; //FIXME quaternion?
vec3_t currentangles;
} entity_t;
// !!! if this is changed, it must be changed in asm_draw.h too !!!

View file

@ -69,7 +69,6 @@ void Sys_SetErrPrintf (sys_printf_t func);
void Sys_Print (FILE *stream, const char *fmt, va_list args);
void Sys_Printf (const char *fmt, ...) __attribute__((format(printf,1,2)));
void Sys_DPrintf (const char *fmt, ...) __attribute__((format(printf,1,2)));
void Sys_Error (const char *error, ...) __attribute__((format(printf,1,2), noreturn));
void Sys_Quit (void) __attribute__((noreturn));
void Sys_Shutdown (void);
@ -77,6 +76,11 @@ void Sys_RegisterShutdown (void (*func) (void));
double Sys_DoubleTime (void);
void Sys_TimeOfDay(date_t *date);
void Sys_MaskPrintf (int mask, const char *fmt, ...) __attribute__((format(printf,2,3)));
#define SYS_DEV 1
#define SYS_WARN 3 // bit 0 so developer 1 will pick it up
#define SYS_VID 5
int Sys_CheckInput (int idle, int net_socket);
const char *Sys_ConsoleInput (void);

View file

@ -41,7 +41,7 @@ struct qsockaddr
#define NET_NAMELEN 64
#define NET_MAXMESSAGE 8192
#define NET_MAXMESSAGE 32000
#define NET_HEADERSIZE (2 * sizeof(unsigned int))
#define NET_DATAGRAMSIZE (MAX_DATAGRAM + NET_HEADERSIZE)
@ -287,7 +287,7 @@ int NET_SendUnreliableMessage (struct qsocket_s *sock, sizebuf_t *data);
// returns 1 if the message was sent properly
// returns -1 if the connection died
int NET_SendToAll(sizebuf_t *data, int blocktime);
int NET_SendToAll(sizebuf_t *data, double blocktime);
// This is a reliable *blocking* send to all attached clients.

View file

@ -56,6 +56,7 @@ void RUA_String_Init (struct progs_s *pr, int secure);
void RUA_QFile_Init (struct progs_s *pr, int secure);
int QFile_AllocHandle (struct progs_s *pr, QFile *file);
QFile *QFile_GetFile (struct progs_s *pr, int handle);
void RUA_QFS_Init (struct progs_s *pr, int secure);

View file

@ -297,7 +297,7 @@ void SND_SFX_Init (void);
*/
//@{
#define MAX_CHANNELS 512 //!< number of available mixing channels
#define MAX_DYNAMIC_CHANNELS 8 //!< number of dynamic channels
#define MAX_DYNAMIC_CHANNELS 128 //!< number of dynamic channels
#define MAX_STATIC_CHANNELS 256 //!< number of static channels
extern channel_t snd_channels[MAX_CHANNELS]; //!< pool of available channels
extern int snd_total_channels; //!< number of active channels

View file

Before

Width:  |  Height:  |  Size: 76 KiB

After

Width:  |  Height:  |  Size: 76 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 307 KiB

View file

@ -302,6 +302,8 @@ I_OGGMus_Play (int track, qboolean looping)
if (playing)
I_OGGMus_Stop ();
if (!track)
return;
I_OGGMus_SetPlayList (track);
I_OGGMus_PlayNext (looping);
}

View file

@ -89,7 +89,7 @@ I_CDAudio_CloseDoor (void)
return; // no cd init'd
if (ioctl (cdfile, CDROMCLOSETRAY) == -1)
Sys_DPrintf ("CDAudio: ioctl cdromclosetray failed\n");
Sys_MaskPrintf (SYS_DEV, "CDAudio: ioctl cdromclosetray failed\n");
}
static void
@ -99,7 +99,7 @@ I_CDAudio_Eject (void)
return; // no cd init'd
if (ioctl (cdfile, CDROMEJECT) == -1)
Sys_DPrintf ("CDAudio: ioctl cdromeject failed\n");
Sys_MaskPrintf (SYS_DEV, "CDAudio: ioctl cdromeject failed\n");
}
static int
@ -110,12 +110,12 @@ I_CDAudio_GetAudioDiskInfo (void)
cdValid = false;
if (ioctl (cdfile, CDROMREADTOCHDR, &tochdr) == -1) {
Sys_DPrintf ("CDAudio: ioctl cdromreadtochdr failed\n");
Sys_MaskPrintf (SYS_DEV, "CDAudio: ioctl cdromreadtochdr failed\n");
return -1;
}
if (tochdr.cdth_trk0 < 1) {
Sys_DPrintf ("CDAudio: no music tracks\n");
Sys_MaskPrintf (SYS_DEV, "CDAudio: no music tracks\n");
return -1;
}
@ -135,7 +135,7 @@ I_CDAudio_Pause (void)
return;
if (ioctl (cdfile, CDROMPAUSE) == -1)
Sys_DPrintf ("CDAudio: ioctl cdrompause failed\n");
Sys_MaskPrintf (SYS_DEV, "CDAudio: ioctl cdrompause failed\n");
wasPlaying = playing;
playing = false;
@ -151,7 +151,8 @@ I_CDAudio_Stop (void)
return;
if (ioctl (cdfile, CDROMSTOP) == -1)
Sys_DPrintf ("CDAudio: ioctl cdromstop failed (%d)\n", errno);
Sys_MaskPrintf (SYS_DEV, "CDAudio: ioctl cdromstop failed (%d)\n",
errno);
wasPlaying = false;
playing = false;
@ -188,7 +189,7 @@ I_CDAudio_Play (int track, qboolean looping)
entry0.cdte_track = track;
entry0.cdte_format = CDROM_MSF;
if (ioctl (cdfile, CDROMREADTOCENTRY, &entry0) == -1) {
Sys_DPrintf ("CDAudio: ioctl cdromreadtocentry failed\n");
Sys_MaskPrintf (SYS_DEV, "CDAudio: ioctl cdromreadtocentry failed\n");
return;
}
entry1.cdte_track = track + 1;
@ -197,7 +198,7 @@ I_CDAudio_Play (int track, qboolean looping)
entry1.cdte_track = CDROM_LEADOUT;
}
if (ioctl (cdfile, CDROMREADTOCENTRY, &entry1) == -1) {
Sys_DPrintf ("CDAudio: ioctl cdromreadtocentry failed\n");
Sys_MaskPrintf (SYS_DEV, "CDAudio: ioctl cdromreadtocentry failed\n");
return;
}
if (entry0.cdte_ctrl == CDROM_DATA_TRACK) {
@ -219,15 +220,16 @@ I_CDAudio_Play (int track, qboolean looping)
msf.cdmsf_sec1 = entry1.cdte_addr.msf.second;
msf.cdmsf_frame1 = entry1.cdte_addr.msf.frame;
Sys_DPrintf ("%2d:%02d:%02d %2d:%02d:%02d\n",
msf.cdmsf_min0,
msf.cdmsf_sec0,
msf.cdmsf_frame0,
msf.cdmsf_min1, msf.cdmsf_sec1, msf.cdmsf_frame1);
Sys_MaskPrintf (SYS_DEV, "%2d:%02d:%02d %2d:%02d:%02d\n",
msf.cdmsf_min0,
msf.cdmsf_sec0,
msf.cdmsf_frame0,
msf.cdmsf_min1, msf.cdmsf_sec1, msf.cdmsf_frame1);
if (ioctl (cdfile, CDROMPLAYMSF, &msf) == -1) {
Sys_DPrintf ("CDAudio: ioctl cdromplaytrkind failed (%s)\n",
strerror (errno));
Sys_MaskPrintf (SYS_DEV,
"CDAudio: ioctl cdromplaytrkind failed (%s)\n",
strerror (errno));
return;
}
@ -252,7 +254,7 @@ I_CDAudio_Resume (void)
return;
if (ioctl (cdfile, CDROMRESUME) == -1)
Sys_DPrintf ("CDAudio: ioctl cdromresume failed\n");
Sys_MaskPrintf (SYS_DEV, "CDAudio: ioctl cdromresume failed\n");
playing = true;
}
@ -397,7 +399,7 @@ I_CDAudio_Update (void)
lastchk = time (NULL) + 2; // two seconds between chks
subchnl.cdsc_format = CDROM_MSF;
if (ioctl (cdfile, CDROMSUBCHNL, &subchnl) == -1) {
Sys_DPrintf ("CDAudio: ioctl cdromsubchnl failed\n");
Sys_MaskPrintf (SYS_DEV, "CDAudio: ioctl cdromsubchnl failed\n");
playing = false;
return;
}
@ -422,8 +424,9 @@ Mus_CDChange (cvar_t *mus_cdaudio)
cdfile = open (mus_cdaudio->string, O_RDONLY | O_NONBLOCK);
if (cdfile == -1) {
Sys_DPrintf ("Mus_CDInit: open of device \"%s\" failed (error %i)\n",
mus_cdaudio->string, errno);
Sys_MaskPrintf (SYS_DEV,
"Mus_CDInit: open device \"%s\" failed (error %i)\n",
mus_cdaudio->string, errno);
return;
}

View file

@ -75,7 +75,7 @@ I_CDAudio_Eject (void)
return;
if (SDL_CDEject (cd_id))
Sys_DPrintf ("Unable to eject CD-ROM tray.\n");
Sys_MaskPrintf (SYS_DEV, "Unable to eject CD-ROM tray.\n");
}
static void
@ -87,7 +87,7 @@ I_CDAudio_Pause (void)
return;
if (SDL_CDPause (cd_id))
Sys_DPrintf ("CDAudio_Pause: Failed to pause track.\n");
Sys_MaskPrintf (SYS_DEV, "CDAudio_Pause: Failed to pause track.\n");
}
static void
@ -102,7 +102,7 @@ I_CDAudio_Stop (void)
return;
if (SDL_CDStop (cd_id))
Sys_DPrintf ("CDAudio_Stop: Failed to stop track.\n");
Sys_MaskPrintf (SYS_DEV, "CDAudio_Stop: Failed to stop track.\n");
}
static void
@ -135,7 +135,8 @@ I_CDAudio_Play (int track, qboolean looping)
if (SDL_CDPlay (cd_id, cd_id->track[track].offset,
cd_id->track[track].length)) {
Sys_DPrintf ("CDAudio_Play: Unable to play track: %d\n", track + 1);
Sys_MaskPrintf (SYS_DEV, "CDAudio_Play: Unable to play track: %d\n",
track + 1);
return;
}
playLooping = looping;
@ -150,7 +151,7 @@ I_CDAudio_Resume (void)
return;
if (SDL_CDResume (cd_id))
Sys_DPrintf ("CDAudio_Resume: Failed tp resume track.\n");
Sys_MaskPrintf (SYS_DEV, "CDAudio_Resume: Failed tp resume track.\n");
}
static void

View file

@ -73,7 +73,7 @@ I_SGI_Eject (void)
return; // no cd init'd
if (CDeject (cdp) == 0)
Sys_DPrintf ("I_SGI_Eject: CDeject failed\n");
Sys_MaskPrintf (SYS_DEV, "I_SGI_Eject: CDeject failed\n");
}
static int
@ -85,7 +85,7 @@ I_SGI_GetState (void)
return -1; // no cd init'd
if (CDgetstatus (cdp, &cds) == 0) {
Sys_DPrintf ("CDAudio_GetStatus: CDgetstatus failed\n");
Sys_MaskPrintf (SYS_DEV, "CDAudio_GetStatus: CDgetstatus failed\n");
return -1;
}
@ -101,7 +101,7 @@ I_SGI_MaxTrack (void)
return -1; // no cd init'd
if (CDgetstatus (cdp, &cds) == 0) {
Sys_DPrintf ("I_SGI_MaxTrack: CDgetstatus failed\n");
Sys_MaskPrintf (SYS_DEV, "I_SGI_MaxTrack: CDgetstatus failed\n");
return -1;
}
@ -115,7 +115,7 @@ I_SGI_Pause (void)
return;
if (CDtogglepause (cdp) == 0)
Sys_DPrintf ("CDAudio_PAUSE: CDtogglepause failed (%d)\n", errno);
Sys_MaskPrintf (SYS_DEV, "CDAudio_PAUSE: CDtogglepause failed (%d)\n", errno);
}
void
@ -133,7 +133,8 @@ I_SGI_Play (int track, qboolean looping)
}
if (maxtrack < 0) {
Sys_DPrintf ("CDAudio_Play: Error getting maximum track number\n");
Sys_MaskPrintf (SYS_DEV,
"CDAudio_Play: Error getting maximum track number\n");
return;
}
@ -172,7 +173,7 @@ I_SGI_Play (int track, qboolean looping)
}
if (CDplaytrack (cdp, track, cdvolume == 0.0 ? 0 : 1) == 0) {
Sys_DPrintf ("CDAudio_Play: CDplay failed (%d)\n", errno);
Sys_MaskPrintf (SYS_DEV, "CDAudio_Play: CDplay failed (%d)\n", errno);
return;
}
@ -187,7 +188,8 @@ I_SGI_Resume (void)
return;
if (CDtogglepause (cdp) == 0)
Sys_DPrintf ("CDAudio_Resume: CDtogglepause failed (%d)\n", errno);
Sys_MaskPrintf (SYS_DEV, "CDAudio_Resume: CDtogglepause failed (%d)\n",
errno);
}
void
@ -209,7 +211,7 @@ I_SGI_Stop (void)
return;
if (CDstop (cdp) == 0)
Sys_DPrintf ("I_SGI_Stop: CDStop failed (%d)\n", errno);
Sys_MaskPrintf (SYS_DEV, "I_SGI_Stop: CDStop failed (%d)\n", errno);
}
void

View file

@ -77,7 +77,8 @@ I_CDAudio_CloseDoor (void)
dwReturn =
mciSendCommand (wDeviceID, MCI_SET, MCI_SET_DOOR_CLOSED, (DWORD_PTR) NULL);
if (dwReturn) {
Sys_DPrintf ("MCI_SET_DOOR_CLOSED failed (%li)\n", dwReturn);
Sys_MaskPrintf (SYS_DEV, "MCI_SET_DOOR_CLOSED failed (%li)\n",
dwReturn);
}
}
@ -89,7 +90,7 @@ I_CDAudio_Eject (void)
dwReturn = mciSendCommand (wDeviceID, MCI_SET, MCI_SET_DOOR_OPEN,
(DWORD_PTR) NULL);
if (dwReturn) {
Sys_DPrintf ("MCI_SET_DOOR_OPEN failed (%li)\n", dwReturn);
Sys_MaskPrintf (SYS_DEV, "MCI_SET_DOOR_OPEN failed (%li)\n", dwReturn);
}
}
@ -106,11 +107,12 @@ I_CDAudio_GetAudioDiskInfo (void)
mciSendCommand (wDeviceID, MCI_STATUS, MCI_STATUS_ITEM | MCI_WAIT,
(DWORD_PTR) (LPVOID) & mciStatusParms);
if (dwReturn) {
Sys_DPrintf ("CDAudio: drive ready test - get status failed\n");
Sys_MaskPrintf (SYS_DEV,
"CDAudio: drive ready test - get status failed\n");
return -1;
}
if (!mciStatusParms.dwReturn) {
Sys_DPrintf ("CDAudio: drive not ready\n");
Sys_MaskPrintf (SYS_DEV, "CDAudio: drive not ready\n");
return -1;
}
@ -119,11 +121,11 @@ I_CDAudio_GetAudioDiskInfo (void)
mciSendCommand (wDeviceID, MCI_STATUS, MCI_STATUS_ITEM | MCI_WAIT,
(DWORD_PTR) (LPVOID) & mciStatusParms);
if (dwReturn) {
Sys_DPrintf ("CDAudio: get tracks - status failed\n");
Sys_MaskPrintf (SYS_DEV, "CDAudio: get tracks - status failed\n");
return -1;
}
if (mciStatusParms.dwReturn < 1) {
Sys_DPrintf ("CDAudio: no music tracks\n");
Sys_MaskPrintf (SYS_DEV, "CDAudio: no music tracks\n");
return -1;
}
@ -154,13 +156,14 @@ static I_CDAudio_MessageHandler (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPa
break;
case MCI_NOTIFY_FAILURE:
Sys_DPrintf ("MCI_NOTIFY_FAILURE\n");
Sys_MaskPrintf (SYS_DEV, "MCI_NOTIFY_FAILURE\n");
I_CDAudio_Stop ();
cdValid = false;
break;
default:
Sys_DPrintf ("Unexpected MM_MCINOTIFY type (%i)\n", wParam);
Sys_MaskPrintf (SYS_DEV, "Unexpected MM_MCINOTIFY type (%i)\n",
wParam);
return 1;
}
@ -184,7 +187,7 @@ I_CDAudio_Pause (void)
mciSendCommand (wDeviceID, MCI_PAUSE, 0,
(DWORD_PTR) (LPVOID) & mciGenericParms);
if (dwReturn) {
Sys_DPrintf ("MCI_PAUSE failed (%li)", dwReturn);
Sys_MaskPrintf (SYS_DEV, "MCI_PAUSE failed (%li)", dwReturn);
}
wasPlaying = playing;
@ -225,7 +228,7 @@ I_CDAudio_Play (int track, qboolean looping)
MCI_STATUS_ITEM | MCI_TRACK | MCI_WAIT,
(DWORD_PTR) (LPVOID) & mciStatusParms);
if (dwReturn) {
Sys_DPrintf ("MCI_STATUS failed (%li)\n", dwReturn);
Sys_MaskPrintf (SYS_DEV, "MCI_STATUS failed (%li)\n", dwReturn);
return;
}
if (mciStatusParms.dwReturn != MCI_CDA_TRACK_AUDIO) {
@ -240,7 +243,7 @@ I_CDAudio_Play (int track, qboolean looping)
MCI_STATUS_ITEM | MCI_TRACK | MCI_WAIT,
(DWORD_PTR) (LPVOID) & mciStatusParms);
if (dwReturn) {
Sys_DPrintf ("MCI_STATUS failed (%li)\n", dwReturn);
Sys_MaskPrintf (SYS_DEV, "MCI_STATUS failed (%li)\n", dwReturn);
return;
}
@ -257,7 +260,7 @@ I_CDAudio_Play (int track, qboolean looping)
mciSendCommand (wDeviceID, MCI_PLAY, MCI_NOTIFY | MCI_FROM | MCI_TO,
(DWORD_PTR) (LPVOID) & mciPlayParms);
if (dwReturn) {
Sys_DPrintf ("CDAudio: MCI_PLAY failed (%li)\n", dwReturn);
Sys_MaskPrintf (SYS_DEV, "CDAudio: MCI_PLAY failed (%li)\n", dwReturn);
return;
}
@ -289,7 +292,7 @@ I_CDAudio_Resume (void)
mciSendCommand (wDeviceID, MCI_PLAY, MCI_TO | MCI_NOTIFY,
(DWORD_PTR) (LPVOID) & mciPlayParms);
if (dwReturn) {
Sys_DPrintf ("CDAudio: MCI_PLAY failed (%li)\n", dwReturn);
Sys_MaskPrintf (SYS_DEV, "CDAudio: MCI_PLAY failed (%li)\n", dwReturn);
return;
}
playing = true;
@ -302,7 +305,7 @@ I_CDAudio_Shutdown (void)
return;
I_CDAudio_Stop ();
if (mciSendCommand (wDeviceID, MCI_CLOSE, MCI_WAIT, (DWORD_PTR) NULL))
Sys_DPrintf ("CDAudio_Shutdown: MCI_CLOSE failed\n");
Sys_MaskPrintf (SYS_DEV, "CDAudio_Shutdown: MCI_CLOSE failed\n");
}
static void
@ -317,7 +320,7 @@ I_CDAudio_Stop (void)
dwReturn = mciSendCommand (wDeviceID, MCI_STOP, 0, (DWORD_PTR) NULL);
if (dwReturn) {
Sys_DPrintf ("MCI_STOP failed (%li)", dwReturn);
Sys_MaskPrintf (SYS_DEV, "MCI_STOP failed (%li)", dwReturn);
}
wasPlaying = false;

View file

@ -152,7 +152,7 @@ I_XMMS_Running (void)
break;
case -1: // ICH!
// inform user
Sys_DPrintf ("XMMSAudio: error, can't fork!?\n");
Sys_MaskPrintf (SYS_DEV, "XMMSAudio: error, can't fork!?\n");
break;
default: // Parent
// don't need now :/

View file

@ -412,7 +412,7 @@ flac_get_info (flacfile_t *ff)
vc = &ff->vorbis_info->data.vorbis_comment;
for (i = 0, ve = vc->comments; i < vc->num_comments; ve++, i++) {
Sys_DPrintf ("%.*s\n", ve->length, ve->entry);
Sys_MaskPrintf (SYS_DEV, "%.*s\n", ve->length, ve->entry);
if (strncmp ("CUEPOINT=", (char *) ve->entry, 9) == 0) {
char *str = alloca (ve->length + 1);
strncpy (str, (char *) ve->entry, ve->length);
@ -433,15 +433,13 @@ flac_get_info (flacfile_t *ff)
info.dataofs = 0;
info.datalen = samples * info.channels * sizeof (float);
if (developer->int_val) {
Sys_Printf ("\nBitstream is %d channel, %dHz\n",
Sys_MaskPrintf (SYS_DEV, "\nBitstream is %d channel, %dHz\n",
info.channels, info.rate);
Sys_Printf ("\nDecoded length: %d samples (%d bytes)\n",
Sys_MaskPrintf (SYS_DEV, "\nDecoded length: %d samples (%d bytes)\n",
info.frames, info.width);
if (vc) {
Sys_Printf ("Encoded by: %.*s\n\n",
if (vc) {
Sys_MaskPrintf (SYS_DEV, "Encoded by: %.*s\n\n",
vc->vendor_string.length, vc->vendor_string.entry);
}
}
return info;
@ -463,10 +461,10 @@ SND_LoadFLAC (QFile *file, sfx_t *sfx, char *realname)
return -1;
}
if (info.frames / info.rate < 3) {
Sys_DPrintf ("cache %s\n", realname);
Sys_MaskPrintf (SYS_DEV, "cache %s\n", realname);
flac_cache (sfx, realname, ff, info);
} else {
Sys_DPrintf ("stream %s\n", realname);
Sys_MaskPrintf (SYS_DEV, "stream %s\n", realname);
flac_stream (sfx, realname, ff, info);
}
return 0;

View file

@ -198,7 +198,7 @@ SND_LoadMidi (QFile *file, sfx_t *sfx, char *realname)
WildMidi_Close (handle);
Sys_DPrintf ("stream %s\n", realname);
Sys_MaskPrintf (SYS_DEV, "stream %s\n", realname);
// we init stream here cause we will only ever stream
SND_SFX_Stream (sfx, realname, info, midi_stream_open);

View file

@ -74,6 +74,7 @@ static vec3_t listener_up;
static cvar_t *snd_phasesep;
static cvar_t *snd_volumesep;
static cvar_t *snd_swapchannelside;
static cvar_t *ambient_fade;
static cvar_t *ambient_level;
@ -148,7 +149,7 @@ SND_ScanChannels (int wait)
return;
if (wait) {
Sys_DPrintf ("scanning channels...\n");
Sys_MaskPrintf (SYS_DEV, "scanning channels...\n");
do {
count = 0;
for (i = 0; i < MAX_CHANNELS; i++) {
@ -158,12 +159,12 @@ SND_ScanChannels (int wait)
ch->stop = 1;
count++;
}
Sys_DPrintf ("count = %d\n", count);
Sys_MaskPrintf (SYS_DEV, "count = %d\n", count);
#ifdef HAVE_USLEEP
usleep (1000);
#endif
} while (count);
Sys_DPrintf ("scanning done.\n");
Sys_MaskPrintf (SYS_DEV, "scanning done.\n");
} else {
for (i = 0; i < MAX_CHANNELS; i++) {
ch = &snd_channels[i];
@ -307,6 +308,9 @@ SND_Channels_Init (void)
"20cm head");
snd_volumesep = Cvar_Get ("snd_volumesep", "1.0", CVAR_ARCHIVE, NULL,
"max stereo volume separation. 1.0 is max");
snd_swapchannelside = Cvar_Get ("snd_swapchannelside", "0", CVAR_ARCHIVE,
NULL, "Toggle swapping of left and right "
"channels");
ambient_fade = Cvar_Get ("ambient_fade", "100", CVAR_NONE, NULL,
"How quickly ambient sounds fade in or out");
ambient_level = Cvar_Get ("ambient_level", "0.3", CVAR_NONE, NULL,
@ -476,6 +480,8 @@ s_spatialize (channel_t *ch)
dist = VectorNormalize (source_vec) * ch->dist_mult;
dot = DotProduct (listener_right, source_vec);
if (snd_swapchannelside->int_val)
dot = -dot;
if (snd_shm->channels == 1) {
rscale = 1.0;

View file

@ -324,7 +324,7 @@ SND_Load (sfx_t *sfx)
Qseek (file, 0, SEEK_SET);
#ifdef HAVE_VORBIS
if (strnequal ("OggS", buf, 4)) {
Sys_DPrintf ("SND_Load: ogg file\n");
Sys_MaskPrintf (SYS_DEV, "SND_Load: ogg file\n");
if (SND_LoadOgg (file, sfx, realname) == -1)
goto bail;
return 0;
@ -332,7 +332,7 @@ SND_Load (sfx_t *sfx)
#endif
#ifdef HAVE_FLAC
if (strnequal ("fLaC", buf, 4)) {
Sys_DPrintf ("SND_Load: flac file\n");
Sys_MaskPrintf (SYS_DEV, "SND_Load: flac file\n");
if (SND_LoadFLAC (file, sfx, realname) == -1)
goto bail;
return 0;
@ -340,14 +340,14 @@ SND_Load (sfx_t *sfx)
#endif
#ifdef HAVE_WILDMIDI
if (strnequal ("MThd", buf, 4)) {
Sys_DPrintf ("SND_Load: midi file\n");
Sys_MaskPrintf (SYS_DEV, "SND_Load: midi file\n");
if (SND_LoadMidi (file, sfx, realname) == -1)
goto bail;
return 0;
}
#endif
if (strnequal ("RIFF", buf, 4)) {
Sys_DPrintf ("SND_Load: wav file\n");
Sys_MaskPrintf (SYS_DEV, "SND_Load: wav file\n");
if (SND_LoadWav (file, sfx, realname) == -1)
goto bail;
return 0;

View file

@ -120,6 +120,11 @@ SND_SFX_StreamOpen (sfx_t *sfx, void *file,
int frames;
int size;
// if the speed is 0, there is no sound driver (probably failed to connect
// to jackd)
if (!snd_shm->speed)
return 0;
sfx_t *new_sfx = calloc (1, sizeof (sfx_t));
new_sfx->name = sfx->name;

View file

@ -103,7 +103,7 @@ vorbis_get_info (OggVorbis_File *vf)
samples = ov_pcm_total (vf, -1);
for (ptr = ov_comment (vf, -1)->user_comments; *ptr; ptr++) {
Sys_DPrintf ("%s\n", *ptr);
Sys_MaskPrintf (SYS_DEV, "%s\n", *ptr);
if (strncmp ("CUEPOINT=", *ptr, 9) == 0) {
sscanf (*ptr + 9, "%d %d", &sample_start, &sample_count);
}
@ -120,13 +120,12 @@ vorbis_get_info (OggVorbis_File *vf)
info.dataofs = 0;
info.datalen = samples * info.channels * info.width;
if (developer->int_val) {
Sys_Printf ("\nBitstream is %d channel, %dHz\n",
Sys_MaskPrintf (SYS_DEV, "\nBitstream is %d channel, %dHz\n",
info.channels, info.rate);
Sys_Printf ("\nDecoded length: %d samples (%d bytes)\n",
Sys_MaskPrintf (SYS_DEV, "\nDecoded length: %d samples (%d bytes)\n",
info.frames, info.width);
Sys_Printf ("Encoded by: %s\n\n", ov_comment (vf, -1)->vendor);
}
Sys_MaskPrintf (SYS_DEV, "Encoded by: %s\n\n",
ov_comment (vf, -1)->vendor);
return info;
}
@ -304,10 +303,10 @@ SND_LoadOgg (QFile *file, sfx_t *sfx, char *realname)
return -1;
}
if (info.frames / info.rate < 3) {
Sys_DPrintf ("cache %s\n", realname);
Sys_MaskPrintf (SYS_DEV, "cache %s\n", realname);
vorbis_cache (sfx, realname, &vf, info);
} else {
Sys_DPrintf ("stream %s\n", realname);
Sys_MaskPrintf (SYS_DEV, "stream %s\n", realname);
vorbis_stream (sfx, realname, &vf, info);
}
return 0;

View file

@ -235,18 +235,18 @@ wav_get_info (QFile *file)
Sys_Printf ("missing format chunk\n");
goto bail;
}
if (!data) {
Sys_Printf ("missing data chunk\n");
goto bail;
}
if (dfmt->format_tag != 1) {
Sys_Printf ("not Microsfot PCM\n");
Sys_Printf ("not Microsoft PCM\n");
goto bail;
}
if (dfmt->channels < 1 || dfmt->channels > 8) {
Sys_Printf ("unsupported channel count\n");
goto bail;
}
if (!data) {
Sys_Printf ("missing data chunk\n");
goto bail;
}
info.rate = dfmt->samples_per_sec;
info.width = dfmt->bits_per_sample / 8;
@ -280,10 +280,10 @@ SND_LoadWav (QFile *file, sfx_t *sfx, char *realname)
}
if (info.frames / info.rate < 3) {
Sys_DPrintf ("cache %s\n", realname);
Sys_MaskPrintf (SYS_DEV, "cache %s\n", realname);
wav_cache (sfx, realname, file, info);
} else {
Sys_DPrintf ("stream %s\n", realname);
Sys_MaskPrintf (SYS_DEV, "stream %s\n", realname);
wav_stream (sfx, realname, file, info);
}
return 0;

View file

@ -315,7 +315,7 @@ SNDDMA_Submit (void)
// find which sound blocks have completed
while (1) {
if (snd_completed == snd_sent) {
Sys_DPrintf ("Sound overrun\n");
Sys_MaskPrintf (SYS_DEV, "Sound overrun\n");
break;
}

View file

@ -86,8 +86,15 @@ static hashtab_t *menu_hash;
static func_t menu_init;
static func_t menu_quit;
static func_t menu_draw_hud;
static func_t menu_post;
static const char *top_menu;
static void
run_menu_post (void)
{
PR_ExecuteProgram (&menu_pr_state, menu_post);
}
static int
menu_resolve_globals (progs_t *pr)
{
@ -101,6 +108,9 @@ menu_resolve_globals (progs_t *pr)
if (!(f = PR_FindFunction (pr, sym = "menu_draw_hud")))
goto error;
menu_draw_hud = (func_t) (f - pr->pr_functions);
if (!(f = PR_FindFunction (pr, sym = "menu_post")))
goto error;
menu_post = (func_t) (f - pr->pr_functions);
if (!(def = PR_FindGlobal (pr, sym = "time")))
goto error;
menu_pr_state.globals.time = &G_FLOAT (pr, def->ofs);
@ -342,6 +352,7 @@ bi_Menu_SelectMenu (progs_t *pr)
game_target = IMT_CONSOLE;
if (menu->enter_hook) {
PR_ExecuteProgram (&menu_pr_state, menu->enter_hook);
run_menu_post ();
}
} else {
if (name && *name)
@ -394,9 +405,13 @@ togglemenu_f (void)
static void
quit_f (void)
{
int ret;
if (confirm_quit->int_val && menu_quit) {
PR_ExecuteProgram (&menu_pr_state, menu_quit);
if (!R_INT (&menu_pr_state))
ret = R_INT (&menu_pr_state);
run_menu_post ();
if (!ret)
return;
}
bi_Menu_Quit (&menu_pr_state);
@ -503,6 +518,7 @@ Menu_Load (void)
RUA_Cbuf_SetCbuf (&menu_pr_state, con_data.cbuf);
InputLine_Progs_SetDraw (&menu_pr_state, C_DrawInputLine);
PR_ExecuteProgram (&menu_pr_state, menu_init);
run_menu_post ();
}
void
@ -524,11 +540,15 @@ Menu_Draw (view_t *view)
*menu_pr_state.globals.time = *con_data.realtime;
if (menu->draw) {
int ret;
PR_RESET_PARAMS (&menu_pr_state);
P_INT (&menu_pr_state, 0) = x;
P_INT (&menu_pr_state, 1) = y;
PR_ExecuteProgram (&menu_pr_state, menu->draw);
if (R_INT (&menu_pr_state))
ret = R_INT (&menu_pr_state);
run_menu_post ();
if (!ret)
return;
}
@ -558,6 +578,7 @@ Menu_Draw (view_t *view)
P_INT (&menu_pr_state, 0) = x + item->x;
P_INT (&menu_pr_state, 1) = y + item->y;
PR_ExecuteProgram (&menu_pr_state, menu->cursor);
run_menu_post ();
} else {
Draw_Character (x + item->x, y + item->y,
12 + ((int) (*con_data.realtime * 4) & 1));
@ -570,12 +591,14 @@ Menu_Draw_Hud (view_t *view)
*menu_pr_state.globals.time = *con_data.realtime;
PR_ExecuteProgram (&menu_pr_state, menu_draw_hud);
run_menu_post ();
}
void
Menu_KeyEvent (knum_t key, short unicode, qboolean down)
{
menu_item_t *item;
int ret;
if (!menu)
return;
@ -585,7 +608,9 @@ Menu_KeyEvent (knum_t key, short unicode, qboolean down)
P_INT (&menu_pr_state, 1) = unicode;
P_INT (&menu_pr_state, 2) = down;
PR_ExecuteProgram (&menu_pr_state, menu->keyevent);
if (R_INT (&menu_pr_state))
ret = R_INT (&menu_pr_state);
run_menu_post ();
if (ret)
return;
} else if (menu->items && menu->items[menu->cur_item]->func
&& menu->items[menu->cur_item]->allkeys) {
@ -597,7 +622,9 @@ Menu_KeyEvent (knum_t key, short unicode, qboolean down)
P_INT (&menu_pr_state, 1) = key;
PR_ExecuteProgram (&menu_pr_state, item->func);
PR_PopFrame (&menu_pr_state);
if (R_INT (&menu_pr_state))
ret = R_INT (&menu_pr_state);
run_menu_post ();
if (ret)
return;
}
if (!menu || !menu->items)
@ -625,10 +652,12 @@ Menu_KeyEvent (knum_t key, short unicode, qboolean down)
P_INT (&menu_pr_state, 1) = key;
PR_ExecuteProgram (&menu_pr_state, item->func);
PR_PopFrame (&menu_pr_state);
run_menu_post ();
} else {
menu = item;
if (menu->enter_hook) {
PR_ExecuteProgram (&menu_pr_state, menu->enter_hook);
run_menu_post ();
}
}
}
@ -651,6 +680,7 @@ Menu_Enter ()
menu = Hash_Find (menu_hash, top_menu);
if (menu && menu->enter_hook) {
PR_ExecuteProgram (&menu_pr_state, menu->enter_hook);
run_menu_post ();
}
}
@ -660,6 +690,7 @@ Menu_Leave ()
if (menu) {
if (menu->leave_hook) {
PR_ExecuteProgram (&menu_pr_state, menu->leave_hook);
run_menu_post ();
}
menu = menu->parent;
if (!menu) {

View file

@ -206,8 +206,9 @@ PR_RelocateBuiltins (progs_t *pr)
ind = pr->bi_map (pr, ind);
bi = PR_FindBuiltinNum (pr, ind);
if (!bi || !(proc = bi->proc)) {
Sys_DPrintf ("WARNING: Bad builtin call number: %s = #%d\n",
bi_name, -desc->first_statement);
Sys_MaskPrintf (SYS_DEV,
"WARNING: Bad builtin call number: %s = #%d\n",
bi_name, -desc->first_statement);
proc = bi_no_function;
}
func->first_statement = desc->first_statement;

View file

@ -127,7 +127,7 @@ pr_debug_expression_error (script_t *script, const char *msg)
}
static pr_type_t *
parse_expression (progs_t *pr, const char *expr)
parse_expression (progs_t *pr, const char *expr, int conditional)
{
script_t *es;
char *e;
@ -165,18 +165,21 @@ parse_expression (progs_t *pr, const char *expr)
goto error;
expr_ptr = PR_GetPointer (pr, global->ofs);
}
pr->wp_conditional = 0;
if (Script_TokenAvailable (es, 1)) {
if (!Script_GetToken (es, 1) && !strequal (es->token->str, "==" ))
goto error;
if (!Script_GetToken (es, 1))
goto error;
pr->wp_val.integer_var = strtol (es->token->str, &e, 0);
if (e == es->token->str)
goto error;
if (*e == '.' || *e == 'e' || *e == 'E')
pr->wp_val.float_var = strtod (es->token->str, &e);
pr->wp_conditional = 1;
if (conditional) {
pr->wp_conditional = 0;
if (Script_TokenAvailable (es, 1)) {
if (!Script_GetToken (es, 1)
&& !strequal (es->token->str, "==" ))
goto error;
if (!Script_GetToken (es, 1))
goto error;
pr->wp_val.integer_var = strtol (es->token->str, &e, 0);
if (e == es->token->str)
goto error;
if (*e == '.' || *e == 'e' || *e == 'E')
pr->wp_val.float_var = strtod (es->token->str, &e);
pr->wp_conditional = 1;
}
}
if (Script_TokenAvailable (es, 1))
Sys_Printf ("ignoring tail\n");
@ -204,7 +207,7 @@ PR_Debug_Init_Cvars (void)
static file_t *
PR_Load_Source_File (progs_t *pr, const char *fname)
{
char *path = 0, *l, *p, **dir;
char *l, *p, **dir;
file_t *f = Hash_Find (file_hash, fname);
if (f)
@ -217,37 +220,39 @@ PR_Load_Source_File (progs_t *pr, const char *fname)
fname));
}
if (!f->text) {
pr->file_error (pr, path);
free (f);
return 0;
pr->file_error (pr, fname);
} else {
for (f->num_lines = 1, l = f->text; *l; l++)
if (*l == '\n')
f->num_lines++;
}
for (f->num_lines = 1, l = f->text; *l; l++)
if (*l == '\n')
f->num_lines++;
f->name = strdup (fname);
if (!f->name) {
pr->free_progs_mem (pr, f->text);
free (f);
return 0;
}
f->lines = malloc (f->num_lines * sizeof (line_t));
if (!f->lines) {
free (f->name);
pr->free_progs_mem (pr, f->text);
free (f);
return 0;
}
f->lines[0].text = f->text;
for (f->num_lines = 0, l = f->text; *l; l++) {
if (*l == '\n') {
for (p = l; p > f->lines[f->num_lines].text && isspace(p[-1]); p--)
;
f->lines[f->num_lines].len = p - f->lines[f->num_lines].text;
f->lines[++f->num_lines].text = l + 1;
if (f->num_lines) {
f->lines = malloc (f->num_lines * sizeof (line_t));
if (!f->lines) {
free (f->name);
pr->free_progs_mem (pr, f->text);
free (f);
return 0;
}
f->lines[0].text = f->text;
for (f->num_lines = 0, l = f->text; *l; l++) {
if (*l == '\n') {
for (p = l; p > f->lines[f->num_lines].text && isspace(p[-1]);
p--)
;
f->lines[f->num_lines].len = p - f->lines[f->num_lines].text;
f->lines[++f->num_lines].text = l + 1;
}
}
f->lines[f->num_lines].len = l - f->lines[f->num_lines].text;
f->num_lines++;
}
f->lines[f->num_lines].len = l - f->lines[f->num_lines].text;
f->num_lines++;
f->pr = pr;
Hash_Add (file_hash, f);
return f;
@ -536,6 +541,8 @@ PR_DumpState (progs_t *pr)
PR_StackTrace (pr);
}
#define ISDENORM(x) ((x) && !((x) & 0x7f800000))
static const char *
value_string (progs_t *pr, etype_t type, pr_type_t *val)
{
@ -608,7 +615,10 @@ value_string (progs_t *pr, etype_t type, pr_type_t *val)
case ev_void:
return "void";
case ev_float:
dsprintf (line, "%g", val->float_var);
if (ISDENORM (val->integer_var) && val->uinteger_var != 0x80000000)
dsprintf (line, "<%08x>", val->integer_var);
else
dsprintf (line, "%g", val->float_var);
break;
case ev_vector:
dsprintf (line, "'%g %g %g'",
@ -724,7 +734,7 @@ PR_Debug_Watch (progs_t *pr, const char *expr)
return;
}
pr->watch = parse_expression (pr, expr);
pr->watch = parse_expression (pr, expr, 1);
if (pr->watch) {
Sys_Printf ("watchpoint set to [%d]\n", PR_SetPointer (pr, pr->watch));
if (pr->wp_conditional)
@ -744,7 +754,7 @@ PR_Debug_Print (progs_t *pr, const char *expr)
return;
}
print = parse_expression (pr, expr);
print = parse_expression (pr, expr, 0);
if (print) {
pr_int_t ofs = PR_SetPointer (pr, print);
const char *s = global_string (pr, ofs, ev_void, 1);
@ -879,6 +889,24 @@ PR_PrintStatement (progs_t *pr, dstatement_t *s, int contents)
case 'O':
str = va ("%04x", addr + (short) opval);
break;
case 'E':
{
edict_t *ed;
opval = pr->pr_globals[s->a].entity_var;
parm_ind = pr->pr_globals[s->b].uinteger_var;
if (parm_ind < pr->progs->entityfields
&& opval >= 0
&& opval < pr->pr_edictareasize) {
ed = PROG_TO_EDICT (pr, opval);
opval = &ed->v[parm_ind] - pr->pr_globals;
} else {
str = "bad entity.field";
break;
}
str = global_string (pr, opval, optype, contents & 1);
str = va ("%d %d %s", s->a, s->b, str);
}
break;
default:
goto err;
}

View file

@ -100,11 +100,13 @@ free_progs_mem (progs_t *pr, void *mem)
}
VISIBLE void
PR_LoadProgsFile (progs_t * pr, QFile *file, int size, int edicts, int zone)
PR_LoadProgsFile (progs_t *pr, QFile *file, int size, int edicts, int zone)
{
size_t i;
int mem_size;
int offset_tweak;
dprograms_t progs;
byte *base;
if (!pr->file_error)
pr->file_error = file_error;
@ -152,9 +154,14 @@ PR_LoadProgsFile (progs_t * pr, QFile *file, int size, int edicts, int zone)
}
}
// Some compilers (eg, FTE) put extra data between the header and the
// strings section. What's worse, they de-align the data.
offset_tweak = progs.ofs_strings % sizeof (pr_int_t);
offset_tweak = (sizeof (pr_int_t) - offset_tweak) % sizeof (pr_int_t);
// size of progs themselves
pr->progs_size = size;
Sys_DPrintf ("Programs occupy %iK.\n", size / 1024);
pr->progs_size = size + offset_tweak;
Sys_MaskPrintf (SYS_DEV, "Programs occupy %iK.\n", size / 1024);
// round off to next highest whole word address (esp for Alpha)
// this ensures that pointers in the engine data area are always
// properly aligned
@ -187,9 +194,10 @@ PR_LoadProgsFile (progs_t * pr, QFile *file, int size, int edicts, int zone)
((byte *) pr->progs)[mem_size] = 0;
memcpy (pr->progs, &progs, sizeof (progs));
Qread (file, pr->progs + 1, size - sizeof (progs));
CRC_ProcessBlock ((byte *)(pr->progs + 1), &pr->crc,
size - sizeof (progs));
base = (byte *) (pr->progs + 1) + offset_tweak;
Qread (file, base, size - sizeof (progs));
CRC_ProcessBlock (base, &pr->crc, size - sizeof (progs));
base -= sizeof (progs); // offsets are from file start
if (pr->edicts)
*pr->edicts = (edict_t *)((byte *) pr->progs + pr->progs_size);
@ -199,18 +207,14 @@ PR_LoadProgsFile (progs_t * pr, QFile *file, int size, int edicts, int zone)
PR_Zone_Init (pr);
pr->pr_functions =
(dfunction_t *) ((byte *) pr->progs + pr->progs->ofs_functions);
pr->pr_strings = (char *) pr->progs + pr->progs->ofs_strings;
pr->pr_stringsize = (char *) pr->zone + pr->zone_size - (char *) pr->progs;
pr->pr_globaldefs =
(ddef_t *) ((byte *) pr->progs + pr->progs->ofs_globaldefs);
pr->pr_fielddefs =
(ddef_t *) ((byte *) pr->progs + pr->progs->ofs_fielddefs);
pr->pr_statements =
(dstatement_t *) ((byte *) pr->progs + pr->progs->ofs_statements);
(dfunction_t *) (base + pr->progs->ofs_functions);
pr->pr_strings = (char *) base + pr->progs->ofs_strings;
pr->pr_stringsize = (char *) pr->zone + pr->zone_size - (char *) base;
pr->pr_globaldefs = (ddef_t *) (base + pr->progs->ofs_globaldefs);
pr->pr_fielddefs = (ddef_t *) (base + pr->progs->ofs_fielddefs);
pr->pr_statements = (dstatement_t *) (base + pr->progs->ofs_statements);
pr->pr_globals =
(pr_type_t *) ((byte *) pr->progs + pr->progs->ofs_globals);
pr->pr_globals = (pr_type_t *) (base + pr->progs->ofs_globals);
pr->globals_size = (pr_type_t*)((byte *) pr->zone + pr->zone_size)
- pr->pr_globals;

View file

@ -98,6 +98,7 @@ VISIBLE const char *pr_type_name[ev_type_count] = {
// P function parameter
// F function (must come before any P)
// R return value
// E entity + field (%Eab)
//
// a operand a
// b operand b
@ -266,52 +267,52 @@ VISIBLE opcode_t pr_opcodes[] = {
{".", "load.f", OP_LOAD_F, false,
ev_entity, ev_field, ev_float,
PROG_ID_VERSION,
"%Ga.%Gb, %gc",
"%Ga.%Gb(%Ec), %gc",//FIXME %E more flexible?
},
{".", "load.v", OP_LOAD_V, false,
ev_entity, ev_field, ev_vector,
PROG_ID_VERSION,
"%Ga.%Gb, %gc",
"%Ga.%Gb(%Ec), %gc",
},
{".", "load.q", OP_LOAD_Q, false,
ev_entity, ev_field, ev_quat,
PROG_ID_VERSION,
"%Ga.%Gb, %gc",
"%Ga.%Gb(%Ec), %gc",
},
{".", "load.s", OP_LOAD_S, false,
ev_entity, ev_field, ev_string,
PROG_ID_VERSION,
"%Ga.%Gb, %gc",
"%Ga.%Gb(%Ec), %gc",
},
{".", "load.ent", OP_LOAD_ENT, false,
ev_entity, ev_field, ev_entity,
PROG_ID_VERSION,
"%Ga.%Gb, %gc",
"%Ga.%Gb(%Ec), %gc",
},
{".", "load.fld", OP_LOAD_FLD, false,
ev_entity, ev_field, ev_field,
PROG_ID_VERSION,
"%Ga.%Gb, %gc",
"%Ga.%Gb(%Ec), %gc",
},
{".", "load.fn", OP_LOAD_FN, false,
ev_entity, ev_field, ev_func,
PROG_ID_VERSION,
"%Ga.%Gb, %gc",
"%Ga.%Gb(%Ec), %gc",
},
{".", "load.i", OP_LOAD_I, false,
ev_entity, ev_field, ev_integer,
PROG_VERSION,
"%Ga.%Gb, %gc",
"%Ga.%Gb(%Ec), %gc",
},
{".", "load.u", OP_LOAD_U, false,
ev_entity, ev_field, ev_uinteger,
PROG_VERSION,
"%Ga.%Gb, %gc",
"%Ga.%Gb(%Ec), %gc",
},
{".", "load.p", OP_LOAD_P, false,
ev_entity, ev_field, ev_pointer,
PROG_VERSION,
"%Ga.%Gb, %gc",
"%Ga.%Gb(%Ec), %gc",
},
{".", "loadb.f", OP_LOADB_F, false,
@ -419,6 +420,7 @@ VISIBLE opcode_t pr_opcodes[] = {
{"&", "address", OP_ADDRESS, false,
ev_entity, ev_field, ev_pointer,
PROG_ID_VERSION,
"%Ga.%Gb, %gc",
},
{"&", "address.f", OP_ADDRESS_F, false,
@ -1202,9 +1204,10 @@ check_branch (progs_t *pr, dstatement_t *st, opcode_t *op, short offset)
static inline void
check_global (progs_t *pr, dstatement_t *st, opcode_t *op, etype_t type,
unsigned short operand)
unsigned short operand, int check_denorm)
{
const char *msg;
ddef_t *def;
switch (type) {
case ev_short:
@ -1221,11 +1224,19 @@ check_global (progs_t *pr, dstatement_t *st, opcode_t *op, etype_t type,
msg = "out of bounds global index";
goto error;
}
if (type == ev_float)
if (ISDENORM (G_INT (pr, operand))
&& !pr->denorm_found) {
if (type != ev_float || !check_denorm)
break;
if (!ISDENORM (G_INT (pr, operand))
|| G_UINT(pr, operand) == 0x80000000)
break;
if ((def = PR_GlobalAtOfs (pr, operand))
&& (def->type & ~DEF_SAVEGLOBAL) != ev_float) {
// FTEqcc uses store.f parameters of most types :/
break;
}
if (!pr->denorm_found) {
pr->denorm_found = 1;
if (pr_boundscheck-> int_val) {
if (pr_boundscheck->int_val) {
Sys_Printf ("DENORMAL floats detected, these progs might "
"not work. Good luck.\n");
return;
@ -1303,7 +1314,7 @@ PR_Check_Opcodes (progs_t *pr)
switch (st->op) {
case OP_IF:
case OP_IFNOT:
check_global (pr, st, op, op->type_a, st->a);
check_global (pr, st, op, op->type_a, st->a, 1);
check_branch (pr, st, op, st->b);
break;
case OP_GOTO:
@ -1311,12 +1322,12 @@ PR_Check_Opcodes (progs_t *pr)
break;
case OP_DONE:
case OP_RETURN:
check_global (pr, st, op, ev_integer, st->a);
check_global (pr, st, op, ev_void, st->b);
check_global (pr, st, op, ev_void, st->c);
check_global (pr, st, op, ev_integer, st->a, 1);
check_global (pr, st, op, ev_void, st->b, 0);
check_global (pr, st, op, ev_void, st->c, 0);
break;
case OP_RCALL1:
check_global (pr, st, op, ev_void, st->c);
check_global (pr, st, op, ev_void, st->c, 1);
case OP_RCALL2:
case OP_RCALL3:
case OP_RCALL4:
@ -1325,9 +1336,9 @@ PR_Check_Opcodes (progs_t *pr)
case OP_RCALL7:
case OP_RCALL8:
if (st->op > OP_RCALL1)
check_global (pr, st, op, ev_integer, st->c);
check_global (pr, st, op, ev_integer, st->b);
check_global (pr, st, op, ev_func, st->a);
check_global (pr, st, op, ev_integer, st->c, 1);
check_global (pr, st, op, ev_integer, st->b, 1);
check_global (pr, st, op, ev_func, st->a, 1);
break;
case OP_STATE:
case OP_STATE_F:
@ -1335,18 +1346,19 @@ PR_Check_Opcodes (progs_t *pr)
PR_Error (pr, "PR_Check_Opcodes: %s used with missing "
"fields or globals", op->opname);
}
check_global (pr, st, op, op->type_a, st->a);
check_global (pr, st, op, op->type_b, st->b);
check_global (pr, st, op, op->type_c, st->c);
check_global (pr, st, op, op->type_a, st->a, 1);
check_global (pr, st, op, op->type_b, st->b, 1);
check_global (pr, st, op, op->type_c, st->c, 1);
break;
case OP_MOVE:
check_global_size (pr, st, op, st->b, st->a);
check_global_size (pr, st, op, st->b, st->c);
break;
default:
check_global (pr, st, op, op->type_a, st->a);
check_global (pr, st, op, op->type_b, st->b);
check_global (pr, st, op, op->type_c, st->c);
check_global (pr, st, op, op->type_a, st->a, 1);
check_global (pr, st, op, op->type_b, st->b,
op->opcode != OP_STORE_F);
check_global (pr, st, op, op->type_c, st->c, 0);
break;
}
}

View file

@ -231,8 +231,6 @@ PR_LoadStrings (progs_t *pr)
}
str += strlen (str) + 1;
}
pr->static_strings = realloc (pr->static_strings,
count * sizeof (strref_t));
pr->num_strings = count;
return 1;
}

View file

@ -74,7 +74,8 @@ GIB_Exec_Override_f (void)
return;
}
if (!Cvar_Command ()
&& (cmd_warncmd->int_val || (developer && developer->int_val)))
&& (cmd_warncmd->int_val
|| (developer && developer->int_val & SYS_DEV)))
Sys_Printf ("execing %s\n", Cmd_Argv (1));
if ((strlen (Cmd_Argv (1)) >= 4
&& !strcmp (Cmd_Argv (1) + strlen (Cmd_Argv (1)) - 4, ".gib"))

View file

@ -75,13 +75,13 @@ void
GIB_Tree_Ref (gib_tree_t ** tp)
{
(*tp)->refs++;
// Sys_DPrintf ("Ref: %p %u\n", *tp, (*tp)->refs);
// Sys_MaskPrintf (SYS_DEV, "Ref: %p %u\n", *tp, (*tp)->refs);
}
void
GIB_Tree_Unref (gib_tree_t ** tp)
{
// Sys_DPrintf ("Unref: %p %u\n", *tp, (*tp)->refs - 1);
// Sys_MaskPrintf (SYS_DEV, "Unref: %p %u\n", *tp, (*tp)->refs - 1);
if (!(--(*tp)->refs)) {
GIB_Tree_Free_Recursive (*tp);
*tp = 0;

View file

@ -235,7 +235,7 @@ skip_colormap (TargaHeader *targa, byte *data)
int bpe;
if (!targa->colormap_type)
return data;
Sys_DPrintf ("LoadTGA: skipping colormap\n");
Sys_MaskPrintf (SYS_DEV, "LoadTGA: skipping colormap\n");
bpe = (targa->pixel_size +7) / 8;
return data + bpe * targa->colormap_length;
}

View file

@ -322,8 +322,8 @@ BuildTris (void)
add_command (0); // end of list marker
Sys_DPrintf ("%3i tri %3i vert %3i cmd\n", pheader->mdl.numtris, numorder,
numcommands);
Sys_MaskPrintf (SYS_DEV, "%3i tri %3i vert %3i cmd\n",
pheader->mdl.numtris, numorder, numcommands);
allverts += numorder;
alltris += pheader->mdl.numtris;
@ -434,7 +434,7 @@ Mod_MakeAliasModelDisplayLists (model_t *m, aliashdr_t *hdr, void *_m, int _s, i
}
if (remesh) {
// build it from scratch
Sys_DPrintf ("meshing %s...\n", m->name);
Sys_MaskPrintf (SYS_DEV, "meshing %s...\n", m->name);
BuildTris (); // trifans or lists

View file

@ -102,8 +102,8 @@ Mod_FloodFillSkin (byte * skin, int skinwidth, int skinheight)
}
// can't fill to filled color or transparent color (used as visited marker)
if ((fillcolor == filledcolor) || (fillcolor == 255)) {
Sys_DPrintf ("not filling skin from %d to %d\n",
fillcolor, filledcolor);
Sys_MaskPrintf (SYS_DEV, "not filling skin from %d to %d\n",
fillcolor, filledcolor);
return;
}

View file

@ -137,12 +137,13 @@ Mod_LoadExternalTextures (model_t *mod)
}
void
Mod_LoadLighting (lump_t *l)
Mod_LoadLighting (bsp_t *bsp)
{
byte d;
byte *in, *out, *data;
dstring_t *litfilename = dstring_new ();
int i;
size_t i;
int ver;
dstring_copystr (litfilename, loadmodel->name);
loadmodel->lightdata = NULL;
@ -154,36 +155,38 @@ Mod_LoadLighting (lump_t *l)
if (data) {
if (data[0] == 'Q' && data[1] == 'L' && data[2] == 'I'
&& data[3] == 'T') {
i = LittleLong (((int *) data)[1]);
if (i == 1) {
Sys_DPrintf ("%s loaded", litfilename->str);
ver = LittleLong (((int32_t *) data)[1]);
if (ver == 1) {
Sys_MaskPrintf (SYS_DEV, "%s loaded", litfilename->str);
loadmodel->lightdata = data + 8;
return;
} else
Sys_DPrintf ("Unknown .lit file version (%d)\n", i);
Sys_MaskPrintf (SYS_DEV,
"Unknown .lit file version (%d)\n", ver);
} else
Sys_DPrintf ("Corrupt .lit file (old version?), ignoring\n");
Sys_MaskPrintf (SYS_DEV, "Corrupt .lit file (old version?)\n");
}
}
// LordHavoc: oh well, expand the white lighting data
if (!l->filelen) {
if (!bsp->lightdatasize) {
dstring_delete (litfilename);
return;
}
loadmodel->lightdata = Hunk_AllocName (l->filelen * mod_lightmap_bytes,
loadmodel->lightdata = Hunk_AllocName (bsp->lightdatasize
* mod_lightmap_bytes,
litfilename->str);
in = mod_base + l->fileofs;
in = bsp->lightdata;
out = loadmodel->lightdata;
if (mod_lightmap_bytes > 1)
for (i = 0; i < l->filelen ; i++) {
for (i = 0; i < bsp->lightdatasize ; i++) {
d = gammatable[*in++];
*out++ = d;
*out++ = d;
*out++ = d;
}
else
for (i = 0; i < l->filelen ; i++)
for (i = 0; i < bsp->lightdatasize ; i++)
*out++ = gammatable[*in++];
dstring_delete (litfilename);
}

View file

@ -128,8 +128,6 @@ Mod_LeafPVS (mleaf_t *leaf, model_t *model)
// BRUSHMODEL LOADING =========================================================
byte *mod_base;
//FIXME SLOW!
static void
mod_unique_miptex_name (texture_t **textures, texture_t *tx, int ind)
@ -156,7 +154,7 @@ mod_unique_miptex_name (texture_t **textures, texture_t *tx, int ind)
}
static void
Mod_LoadTextures (lump_t *l)
Mod_LoadTextures (bsp_t *bsp)
{
dmiptexlump_t *m;
int i, j, pixels, num, max, altmax;
@ -164,11 +162,11 @@ Mod_LoadTextures (lump_t *l)
texture_t *tx, *tx2;
texture_t *anims[10], *altanims[10];
if (!l->filelen) {
if (!bsp->texdatasize) {
loadmodel->textures = NULL;
return;
}
m = (dmiptexlump_t *) (mod_base + l->fileofs);
m = (dmiptexlump_t *) bsp->texdata;
m->nummiptex = LittleLong (m->nummiptex);
@ -292,38 +290,36 @@ Mod_LoadTextures (lump_t *l)
}
static void
Mod_LoadVisibility (lump_t *l)
Mod_LoadVisibility (bsp_t *bsp)
{
if (!l->filelen) {
if (!bsp->visdatasize) {
loadmodel->visdata = NULL;
return;
}
loadmodel->visdata = Hunk_AllocName (l->filelen, loadname);
memcpy (loadmodel->visdata, mod_base + l->fileofs, l->filelen);
loadmodel->visdata = Hunk_AllocName (bsp->visdatasize, loadname);
memcpy (loadmodel->visdata, bsp->visdata, bsp->visdatasize);
}
static void
Mod_LoadEntities (lump_t *l)
Mod_LoadEntities (bsp_t *bsp)
{
if (!l->filelen) {
if (!bsp->entdatasize) {
loadmodel->entities = NULL;
return;
}
loadmodel->entities = Hunk_AllocName (l->filelen, loadname);
memcpy (loadmodel->entities, mod_base + l->fileofs, l->filelen);
loadmodel->entities = Hunk_AllocName (bsp->entdatasize, loadname);
memcpy (loadmodel->entities, bsp->entdata, bsp->entdatasize);
}
static void
Mod_LoadVertexes (lump_t *l)
Mod_LoadVertexes (bsp_t *bsp)
{
dvertex_t *in;
int count, i;
mvertex_t *out;
in = (void *) (mod_base + l->fileofs);
if (l->filelen % sizeof (*in))
Sys_Error ("Mod_LoadBmodel: funny lump size in %s", loadmodel->name);
count = l->filelen / sizeof (*in);
in = bsp->vertexes;
count = bsp->numvertexes;
out = Hunk_AllocName (count * sizeof (*out), loadname);
loadmodel->vertexes = out;
@ -337,15 +333,13 @@ Mod_LoadVertexes (lump_t *l)
}
static void
Mod_LoadSubmodels (lump_t *l)
Mod_LoadSubmodels (bsp_t *bsp)
{
dmodel_t *in, *out;
int count, i, j;
in = (void *) (mod_base + l->fileofs);
if (l->filelen % sizeof (*in))
Sys_Error ("Mod_LoadBmodel: funny lump size in %s", loadmodel->name);
count = l->filelen / sizeof (*in);
in = bsp->models;
count = bsp->nummodels;
out = Hunk_AllocName (count * sizeof (*out), loadname);
loadmodel->submodels = out;
@ -363,19 +357,29 @@ Mod_LoadSubmodels (lump_t *l)
out->firstface = LittleLong (in->firstface);
out->numfaces = LittleLong (in->numfaces);
}
out = loadmodel->submodels;
if (out->visleafs > MAX_MAP_LEAFS) {
Sys_Error ("Mod_LoadSubmodels: too many visleafs (%d, max = %d) in %s",
out->visleafs, MAX_MAP_LEAFS, loadmodel->name);
}
if (out->visleafs > 8192)
Sys_MaskPrintf (SYS_WARN,
"%i visleafs exceeds standard limit of 8192.\n",
out->visleafs);
}
static void
Mod_LoadEdges (lump_t *l)
Mod_LoadEdges (bsp_t *bsp)
{
dedge_t *in;
int count, i;
medge_t *out;
in = (void *) (mod_base + l->fileofs);
if (l->filelen % sizeof (*in))
Sys_Error ("Mod_LoadBmodel: funny lump size in %s", loadmodel->name);
count = l->filelen / sizeof (*in);
in = bsp->edges;
count = bsp->numedges;
out = Hunk_AllocName ((count + 1) * sizeof (*out), loadname);
loadmodel->edges = out;
@ -388,17 +392,15 @@ Mod_LoadEdges (lump_t *l)
}
static void
Mod_LoadTexinfo (lump_t *l)
Mod_LoadTexinfo (bsp_t *bsp)
{
float len1, len2;
int count, miptex, i, j;
mtexinfo_t *out;
texinfo_t *in;
in = (void *) (mod_base + l->fileofs);
if (l->filelen % sizeof (*in))
Sys_Error ("Mod_LoadBmodel: funny lump size in %s", loadmodel->name);
count = l->filelen / sizeof (*in);
in = bsp->texinfo;
count = bsp->numtexinfo;
out = Hunk_AllocName (count * sizeof (*out), loadname);
loadmodel->texinfo = out;
@ -483,26 +485,29 @@ CalcSurfaceExtents (msurface_t *s)
s->texturemins[i] = bmins[i] * 16;
s->extents[i] = (bmaxs[i] - bmins[i]) * 16;
// FIXME even 512 is really too small, need a saner test
if (!(tex->flags & TEX_SPECIAL) && s->extents[i] > 512)
// FIXME even 2000 is really too small, need a saner test
if (!(tex->flags & TEX_SPECIAL) && s->extents[i] > 2000)
Sys_Error ("Bad surface extents: %d %x %d %d", i, tex->flags,
s->extents[i], LongSwap (s->extents[i]));
}
}
static void
Mod_LoadFaces (lump_t *l)
Mod_LoadFaces (bsp_t *bsp)
{
dface_t *in;
int count, planenum, side, surfnum, i;
msurface_t *out;
in = (void *) (mod_base + l->fileofs);
if (l->filelen % sizeof (*in))
Sys_Error ("Mod_LoadBmodel: funny lump size in %s", loadmodel->name);
count = l->filelen / sizeof (*in);
in = bsp->faces;
count = bsp->numfaces;
out = Hunk_AllocName (count * sizeof (*out), loadname);
if (count > 32767) {
Sys_MaskPrintf (SYS_WARN,
"%i faces exceeds standard limit of 32767.\n", count);
}
loadmodel->surfaces = out;
loadmodel->numsurfaces = count;
@ -568,18 +573,21 @@ Mod_SetParent (mnode_t *node, mnode_t *parent)
}
static void
Mod_LoadNodes (lump_t *l)
Mod_LoadNodes (bsp_t *bsp)
{
dnode_t *in;
int count, i, j, p;
mnode_t *out;
in = (void *) (mod_base + l->fileofs);
if (l->filelen % sizeof (*in))
Sys_Error ("Mod_LoadBmodel: funny lump size in %s", loadmodel->name);
count = l->filelen / sizeof (*in);
in = bsp->nodes;
count = bsp->numnodes;
out = Hunk_AllocName (count * sizeof (*out), loadname);
if (count > 32767) {
Sys_MaskPrintf (SYS_WARN,
"%i nodes exceeds standard limit of 32767.\n", count);
}
loadmodel->nodes = out;
loadmodel->numnodes = count;
@ -596,11 +604,22 @@ Mod_LoadNodes (lump_t *l)
out->numsurfaces = LittleShort (in->numfaces);
for (j = 0; j < 2; j++) {
p = LittleShort (in->children[j]);
if (p >= 0)
// handle > 32k nodes. From darkplaces via fitzquake
p = (unsigned short) LittleShort (in->children[j]);
if (p < count) {
out->children[j] = loadmodel->nodes + p;
else
out->children[j] = (mnode_t *) (loadmodel->leafs + (-1 - p));
} else {
p = 65535 - p; //NOTE this uses 65535 intentionally, -1 is leaf
if (p < loadmodel->numleafs) {
out->children[j] = (mnode_t *) (loadmodel->leafs + p);
} else {
Sys_Printf ("Mod_LoadNodes: invalid leaf index %i "
"(file has only %i leafs)\n", p,
loadmodel->numleafs);
//map it to the solid leaf
out->children[j] = (mnode_t *)(loadmodel->leafs);
}
}
}
}
@ -608,19 +627,20 @@ Mod_LoadNodes (lump_t *l)
}
static void
Mod_LoadLeafs (lump_t *l)
Mod_LoadLeafs (bsp_t *bsp)
{
dleaf_t *in;
int count, i, j, p;
mleaf_t *out;
qboolean isnotmap = true;
in = (void *) (mod_base + l->fileofs);
if (l->filelen % sizeof (*in))
Sys_Error ("Mod_LoadBmodel: funny lump size in %s", loadmodel->name);
count = l->filelen / sizeof (*in);
in = bsp->leafs;
count = bsp->numleafs;
out = Hunk_AllocName (count * sizeof (*out), loadname);
if (count > 32767)
Sys_Error ("%i leafs exceeds limit of 32767.\n", count);
loadmodel->leafs = out;
loadmodel->numleafs = count;
// snprintf(s, sizeof (s), "maps/%s.bsp",
@ -637,8 +657,8 @@ Mod_LoadLeafs (lump_t *l)
out->contents = p;
out->firstmarksurface = loadmodel->marksurfaces +
LittleShort (in->firstmarksurface);
out->nummarksurfaces = LittleShort (in->nummarksurfaces);
(uint16_t) LittleShort (in->firstmarksurface);
out->nummarksurfaces = (uint16_t) LittleShort (in->nummarksurfaces);
p = LittleLong (in->visofs);
if (p == -1)
@ -663,18 +683,22 @@ Mod_LoadLeafs (lump_t *l)
}
static void
Mod_LoadClipnodes (lump_t *l)
Mod_LoadClipnodes (bsp_t *bsp)
{
dclipnode_t *in, *out;
hull_t *hull;
int count, i;
in = (void *) (mod_base + l->fileofs);
if (l->filelen % sizeof (*in))
Sys_Error ("Mod_LoadBmodel: funny lump size in %s", loadmodel->name);
count = l->filelen / sizeof (*in);
in = bsp->clipnodes;
count = bsp->numclipnodes;
out = Hunk_AllocName (count * sizeof (*out), loadname);
if (count > 32767) {
Sys_MaskPrintf (SYS_WARN,
"%i clilpnodes exceeds standard limit of 32767.\n",
count);
}
loadmodel->clipnodes = out;
loadmodel->numclipnodes = count;
@ -706,8 +730,14 @@ Mod_LoadClipnodes (lump_t *l)
for (i = 0; i < count; i++, out++, in++) {
out->planenum = LittleLong (in->planenum);
out->children[0] = LittleShort (in->children[0]);
out->children[1] = LittleShort (in->children[1]);
if (out->planenum < 0 || out->planenum >= loadmodel->numplanes)
Sys_Error ("Mod_LoadClipnodes: planenum out of bounds");
out->children[0] = (uint16_t) LittleShort (in->children[0]);
out->children[1] = (uint16_t) LittleShort (in->children[1]);
if (out->children[0] >= count)
out->children[0] -= 65536;
if (out->children[1] >= count)
out->children[1] -= 65536;
if ((out->children[0] >= 0
&& (out->children[0] < hull->firstclipnode
|| out->children[0] > hull->lastclipnode))
@ -756,23 +786,27 @@ Mod_MakeHull0 (void)
}
static void
Mod_LoadMarksurfaces (lump_t *l)
Mod_LoadMarksurfaces (bsp_t *bsp)
{
int count, i, j;
msurface_t **out;
short *in;
uint16_t *in;
in = (void *) (mod_base + l->fileofs);
if (l->filelen % sizeof (*in))
Sys_Error ("Mod_LoadBmodel: funny lump size in %s", loadmodel->name);
count = l->filelen / sizeof (*in);
in = bsp->marksurfaces;
count = bsp->nummarksurfaces;
out = Hunk_AllocName (count * sizeof (*out), loadname);
if (count > 32767) {
Sys_MaskPrintf (SYS_WARN,
"%i marksurfaces exceeds standard limit of 32767.\n",
count);
}
loadmodel->marksurfaces = out;
loadmodel->nummarksurfaces = count;
for (i = 0; i < count; i++) {
j = LittleShort (in[i]);
j = (uint16_t) LittleShort (in[i]);
if (j >= loadmodel->numsurfaces)
Sys_Error ("Mod_ParseMarksurfaces: bad surface number");
out[i] = loadmodel->surfaces + j;
@ -780,15 +814,14 @@ Mod_LoadMarksurfaces (lump_t *l)
}
static void
Mod_LoadSurfedges (lump_t *l)
Mod_LoadSurfedges (bsp_t *bsp)
{
int count, i;
int *in, *out;
int count, i;
int32_t *in;
int *out;
in = (void *) (mod_base + l->fileofs);
if (l->filelen % sizeof (*in))
Sys_Error ("Mod_LoadBmodel: funny lump size in %s", loadmodel->name);
count = l->filelen / sizeof (*in);
in = bsp->surfedges;
count = bsp->numsurfedges;
out = Hunk_AllocName (count * sizeof (*out), loadname);
loadmodel->surfedges = out;
@ -799,16 +832,14 @@ Mod_LoadSurfedges (lump_t *l)
}
static void
Mod_LoadPlanes (lump_t *l)
Mod_LoadPlanes (bsp_t *bsp)
{
dplane_t *in;
int bits, count, i, j;
mplane_t *out;
in = (void *) (mod_base + l->fileofs);
if (l->filelen % sizeof (*in))
Sys_Error ("Mod_LoadBmodel: funny lump size in %s", loadmodel->name);
count = l->filelen / sizeof (*in);
in = bsp->planes;
count = bsp->numplanes;
out = Hunk_AllocName (count * 2 * sizeof (*out), loadname);
loadmodel->planes = out;
@ -828,66 +859,59 @@ Mod_LoadPlanes (lump_t *l)
}
}
void
Mod_LoadBrushModel (model_t *mod, void *buffer)
static void
do_checksums (const bsp_t *bsp, void *_mod)
{
dheader_t *header;
dmodel_t *bm;
int i, j;
int i;
model_t *mod = (model_t *) _mod;
byte *base;
loadmodel->type = mod_brush;
header = (dheader_t *) buffer;
i = LittleLong (header->version);
if (i != BSPVERSION)
Sys_Error ("Mod_LoadBrushModel: %s has wrong version number (%i "
"should be %i)", mod->name, i, BSPVERSION);
// swap all the lumps
mod_base = (byte *) header;
for (i = 0; i < (int) sizeof (dheader_t) / 4; i++)
((int *) header)[i] = LittleLong (((int *) header)[i]);
base = (byte *) bsp->header;
// checksum all of the map, except for entities
mod->checksum = 0;
mod->checksum2 = 0;
for (i = 0; i < HEADER_LUMPS; i++) {
lump_t *lump = header->lumps + i;
lump_t *lump = bsp->header->lumps + i;
int csum;
if (lump->fileofs > qfs_filesize
|| (lump->fileofs + lump->filelen) > qfs_filesize)
Sys_Error ("Mod_LoadBrushModel: %s seems to be truncated",
mod->name);
if (i == LUMP_ENTITIES)
continue;
csum = Com_BlockChecksum (mod_base + lump->fileofs, lump->filelen);
csum = Com_BlockChecksum (base + lump->fileofs, lump->filelen);
mod->checksum ^= csum;
if (i != LUMP_VISIBILITY && i != LUMP_LEAFS && i != LUMP_NODES)
mod->checksum2 ^= csum;
}
}
void
Mod_LoadBrushModel (model_t *mod, void *buffer)
{
dmodel_t *bm;
int i, j;
bsp_t *bsp;
loadmodel->type = mod_brush;
bsp = LoadBSPMem (buffer, qfs_filesize, do_checksums, mod);
// load into heap
Mod_LoadVertexes (&header->lumps[LUMP_VERTEXES]);
Mod_LoadEdges (&header->lumps[LUMP_EDGES]);
Mod_LoadSurfedges (&header->lumps[LUMP_SURFEDGES]);
Mod_LoadTextures (&header->lumps[LUMP_TEXTURES]);
Mod_LoadLighting (&header->lumps[LUMP_LIGHTING]);
Mod_LoadPlanes (&header->lumps[LUMP_PLANES]);
Mod_LoadTexinfo (&header->lumps[LUMP_TEXINFO]);
Mod_LoadFaces (&header->lumps[LUMP_FACES]);
Mod_LoadMarksurfaces (&header->lumps[LUMP_MARKSURFACES]);
Mod_LoadVisibility (&header->lumps[LUMP_VISIBILITY]);
Mod_LoadLeafs (&header->lumps[LUMP_LEAFS]);
Mod_LoadNodes (&header->lumps[LUMP_NODES]);
Mod_LoadClipnodes (&header->lumps[LUMP_CLIPNODES]);
Mod_LoadEntities (&header->lumps[LUMP_ENTITIES]);
Mod_LoadSubmodels (&header->lumps[LUMP_MODELS]);
Mod_LoadVertexes (bsp);
Mod_LoadEdges (bsp);
Mod_LoadSurfedges (bsp);
Mod_LoadTextures (bsp);
Mod_LoadLighting (bsp);
Mod_LoadPlanes (bsp);
Mod_LoadTexinfo (bsp);
Mod_LoadFaces (bsp);
Mod_LoadMarksurfaces (bsp);
Mod_LoadVisibility (bsp);
Mod_LoadLeafs (bsp);
Mod_LoadNodes (bsp);
Mod_LoadClipnodes (bsp);
Mod_LoadEntities (bsp);
Mod_LoadSubmodels (bsp);
Mod_MakeHull0 ();

View file

@ -62,13 +62,13 @@ Mod_LoadExternalTextures (model_t *mod)
}
void
Mod_LoadLighting (lump_t *l)
Mod_LoadLighting (bsp_t *bsp)
{
mod_lightmap_bytes = 1;
if (!l->filelen) {
if (!bsp->lightdatasize) {
loadmodel->lightdata = NULL;
return;
}
loadmodel->lightdata = Hunk_AllocName (l->filelen, loadname);
memcpy (loadmodel->lightdata, mod_base + l->fileofs, l->filelen);
loadmodel->lightdata = Hunk_AllocName (bsp->lightdatasize, loadname);
memcpy (loadmodel->lightdata, bsp->lightdata, bsp->lightdatasize);
}

View file

@ -76,7 +76,7 @@ Mod_Fullbright (byte *skin, int width, int height, char *name)
// Check for fullbright pixels
if (Mod_CalcFullbright (skin, ptexels, pixels)) {
Sys_DPrintf ("FB Model ID: '%s'\n", name);
Sys_MaskPrintf (SYS_DEV, "FB Model ID: '%s'\n", name);
texnum = GL_LoadTexture (name, width, height, ptexels, true, true, 1);
}

View file

@ -52,9 +52,10 @@ static __attribute__ ((used)) const char rcsid[] =
model_t *loadmodel;
char *loadname; // for hunk tags
#define MAX_MOD_KNOWN 512
model_t mod_known[MAX_MOD_KNOWN];
#define MOD_BLOCK 16 // allocate 16 models at a time
model_t **mod_known;
int mod_numknown;
int mod_maxknown;
VISIBLE texture_t *r_notexture_mip;
@ -116,13 +117,13 @@ VISIBLE void
Mod_ClearAll (void)
{
int i;
model_t *mod;
model_t **mod;
for (i = 0, mod = mod_known; i < mod_numknown; i++, mod++) {
if (mod->type != mod_alias)
mod->needload = true;
if (mod->type == mod_sprite)
mod->cache.data = 0;
if ((*mod)->type != mod_alias)
(*mod)->needload = true;
if ((*mod)->type == mod_sprite)
(*mod)->cache.data = 0;
}
}
@ -130,35 +131,41 @@ model_t *
Mod_FindName (const char *name)
{
int i;
model_t *mod;
model_t **mod;
if (!name[0])
Sys_Error ("Mod_FindName: empty name");
// search the currently loaded models
for (i = 0, mod = mod_known; i < mod_numknown; i++, mod++)
if (!strcmp (mod->name, name))
if (!strcmp ((*mod)->name, name))
break;
if (i == mod_numknown) {
if (mod_numknown == MAX_MOD_KNOWN)
Sys_Error ("mod_numknown == MAX_MOD_KNOWN");
strcpy (mod->name, name);
mod->needload = true;
if (mod_numknown == mod_maxknown) {
mod_maxknown += MOD_BLOCK;
mod_known = realloc (mod_known, mod_maxknown * sizeof (model_t *));
mod = mod_known + mod_numknown;
*mod = calloc (MOD_BLOCK, sizeof (model_t));
for (i = 1; i < MOD_BLOCK; i++)
mod[i] = mod[0] + i;
}
strcpy ((*mod)->name, name);
(*mod)->needload = true;
mod_numknown++;
Cache_Add (&mod->cache, mod, Mod_CallbackLoad);
Cache_Add (&(*mod)->cache, *mod, Mod_CallbackLoad);
}
return mod;
return *mod;
}
static model_t *
Mod_RealLoadModel (model_t *mod, qboolean crash, cache_allocator_t allocator)
{
unsigned int *buf;
uint32_t *buf;
// load the file
buf = (unsigned int *) QFS_LoadFile (mod->name, 0);
buf = (uint32_t *) QFS_LoadFile (mod->name, 0);
if (!buf) {
if (crash)
Sys_Error ("Mod_LoadModel: %s not found", mod->name);
@ -181,7 +188,7 @@ Mod_RealLoadModel (model_t *mod, qboolean crash, cache_allocator_t allocator)
mod->needload = false;
mod->hasfullbrights = false;
switch (LittleLong (*(unsigned int *) buf)) {
switch (LittleLong (*buf)) {
case IDHEADER_MDL: // Type 6: Quake 1 .mdl
case HEADER_MDL16: // QF Type 6 extended for 16bit precision
if (strequal (mod->name, "progs/grenade.mdl")) {
@ -265,7 +272,7 @@ Mod_ForName (const char *name, qboolean crash)
mod = Mod_FindName (name);
Sys_DPrintf ("Mod_ForName: %s, %p\n", name, mod);
Sys_MaskPrintf (SYS_DEV, "Mod_ForName: %s, %p\n", name, mod);
return Mod_LoadModel (mod, crash);
}
@ -286,11 +293,11 @@ VISIBLE void
Mod_Print (void)
{
int i;
model_t *mod;
model_t **mod;
Sys_Printf ("Cached models:\n");
for (i = 0, mod = mod_known; i < mod_numknown; i++, mod++) {
Sys_Printf ("%8p : %s\n", mod->cache.data, mod->name);
Sys_Printf ("%8p : %s\n", (*mod)->cache.data, (*mod)->name);
}
}

View file

@ -38,7 +38,7 @@ static __attribute__ ((used)) const char rcsid[] =
int mod_lightmap_bytes = 1;
void
Mod_LoadLighting (lump_t *l)
Mod_LoadLighting (bsp_t *bsp)
{
}

View file

@ -205,7 +205,7 @@ MOD_TraceLine (hull_t *hull, int num,
frac = (start_dist + offset) / (start_dist - end_dist);
} else {
// get here only when offset is non-zero
Sys_DPrintf ("foo\n");
Sys_MaskPrintf (SYS_DEV, "foo\n");
frac = 1;
side = start_dist < end_dist;
}

View file

@ -736,19 +736,17 @@ NET_CanSendMessage (qsocket_t * sock)
int
NET_SendToAll (sizebuf_t *data, int blocktime)
NET_SendToAll (sizebuf_t *data, double blocktime)
{
double start;
int i;
int count = 0;
qboolean state1[MAX_SCOREBOARD];
qboolean state2[MAX_SCOREBOARD];
qboolean state1[MAX_SCOREBOARD]; /* can we send */
qboolean state2[MAX_SCOREBOARD]; /* did we send */
for (i = 0, host_client = svs.clients; i < svs.maxclients;
i++, host_client++) {
if (!host_client->netconnection)
continue;
if (host_client->active) {
if (host_client->netconnection && host_client->active) {
if (host_client->netconnection->driver == 0) {
NET_SendMessage (host_client->netconnection, data);
state1[i] = true;
@ -890,9 +888,9 @@ NET_Init (void)
}
if (*my_ipx_address)
Sys_DPrintf ("IPX address %s\n", my_ipx_address);
Sys_MaskPrintf (SYS_DEV, "IPX address %s\n", my_ipx_address);
if (*my_tcpip_address)
Sys_DPrintf ("TCP/IP address %s\n", my_tcpip_address);
Sys_MaskPrintf (SYS_DEV, "TCP/IP address %s\n", my_tcpip_address);
}
/*

View file

@ -343,14 +343,14 @@ Datagram_GetMessage (qsocket_t * sock)
if (flags & NETFLAG_UNRELIABLE) {
if (sequence < sock->unreliableReceiveSequence) {
Sys_DPrintf ("Got a stale datagram\n");
Sys_MaskPrintf (SYS_DEV, "Got a stale datagram\n");
ret = 0;
break;
}
if (sequence != sock->unreliableReceiveSequence) {
count = sequence - sock->unreliableReceiveSequence;
droppedDatagrams += count;
Sys_DPrintf ("Dropped %u datagram(s)\n", count);
Sys_MaskPrintf (SYS_DEV, "Dropped %u datagram(s)\n", count);
}
sock->unreliableReceiveSequence = sequence + 1;
@ -365,15 +365,15 @@ Datagram_GetMessage (qsocket_t * sock)
if (flags & NETFLAG_ACK) {
if (sequence != (sock->sendSequence - 1)) {
Sys_DPrintf ("Stale ACK received\n");
Sys_MaskPrintf (SYS_DEV, "Stale ACK received\n");
continue;
}
if (sequence == sock->ackSequence) {
sock->ackSequence++;
if (sock->ackSequence != sock->sendSequence)
Sys_DPrintf ("ack sequencing error\n");
Sys_MaskPrintf (SYS_DEV, "ack sequencing error\n");
} else {
Sys_DPrintf ("Duplicate ACK received\n");
Sys_MaskPrintf (SYS_DEV, "Duplicate ACK received\n");
continue;
}
sock->sendMessageLength -= MAX_DATAGRAM;

View file

@ -141,7 +141,7 @@ get_address (int sock)
if (ioctl (sock, SIOCGIFADDR, &ifr[i]) == -1)
continue;
in_addr = (struct sockaddr_in *)&ifr[i].ifr_addr;
Sys_DPrintf ("%s: %s\n", ifr[i].ifr_name,
Sys_MaskPrintf (SYS_DEV, "%s: %s\n", ifr[i].ifr_name,
inet_ntoa (in_addr->sin_addr));
addr = *(unsigned *)&in_addr->sin_addr;
if (addr != htonl (0x7f000001)) {

View file

@ -202,7 +202,7 @@ WINS_Init (void)
// determine my name
if (pgethostname (buff, MAXHOSTNAMELEN) == SOCKET_ERROR) {
Sys_DPrintf ("Winsock TCP/IP Initialization failed.\n");
Sys_MaskPrintf (SYS_DEV, "Winsock TCP/IP Initialization failed.\n");
if (--winsock_initialized == 0)
pWSACleanup ();
return -1;

View file

@ -51,9 +51,10 @@ Garbage_Do_Mark (Object *root)
if (!root->marked) {
ObjRefs_t *allrefs;
root->marked = true;
Sys_DPrintf ("GC: Marked %s@%p.\n", root->cl->name, root);
Sys_MaskPrintf (SYS_DEV, "GC: Marked %s@%p.\n", root->cl->name, root);
if (root->allRefs)
for (allrefs = methodCall(root, allRefs); allrefs; allrefs = allrefs->next) {
for (allrefs = methodCall(root, allRefs); allrefs;
allrefs = allrefs->next) {
unsigned int i;
for (i = 0; i < allrefs->count; i++)
Garbage_Do_Mark (allrefs->objs[i]);
@ -81,7 +82,9 @@ Garbage_Do_Sweep (Object **allobjs)
obj->next = junk;
junk = obj;
junked++;
Sys_DPrintf ("GC: %s@%p is ready for disposal...\n", obj->cl->name, obj);
Sys_MaskPrintf (SYS_DEV,
"GC: %s@%p is ready for disposal...\n",
obj->cl->name, obj);
}
} else
*prevNext = obj->next;
@ -108,7 +111,8 @@ Garbage_Dispose (Object **allobjs, unsigned int amount)
junk->next = *allobjs;
*allobjs = junk;
} else {
Sys_DPrintf ("GC: Disposing of %s@%p...\n", junk->cl->name, junk);
Sys_MaskPrintf (SYS_DEV, "GC: Disposing of %s@%p...\n",
junk->cl->name, junk);
Object_Delete (junk);
junked--;
}

View file

@ -50,7 +50,8 @@ PushBackbuf (backbuf_t *rel)
{
int tail_backbuf;
Sys_DPrintf ("backbuffering %d %s\n", rel->num_backbuf, rel->name);
Sys_MaskPrintf (SYS_DEV, "backbuffering %d %s\n", rel->num_backbuf,
rel->name);
tail_backbuf = (rel->head_backbuf + rel->num_backbuf) % MAX_BACK_BUFFERS;
memset (&rel->backbuf, 0, sizeof (rel->backbuf));
rel->backbuf.allowoverflow = true;
@ -268,7 +269,7 @@ MSG_Reliable_Send (backbuf_t *rel)
return;
// will it fit?
if (msg->cursize + *size < msg->maxsize) {
Sys_DPrintf ("%s: backbuf %d bytes\n", rel->name, *size);
Sys_MaskPrintf (SYS_DEV, "%s: backbuf %d bytes\n", rel->name, *size);
// it'll fit
SZ_Write (msg, data, *size);

View file

@ -376,8 +376,8 @@ finish_class (progs_t *pr, pr_class_t *class, pointer_t object_ptr)
ml = &G_STRUCT (pr, pr_method_list_t, *ml).method_next;
*ml = class->methods;
}
Sys_DPrintf (" %d %d %d\n", meta->class_pointer, meta->super_class,
class->super_class);
Sys_MaskPrintf (SYS_DEV, " %d %d %d\n", meta->class_pointer,
meta->super_class, class->super_class);
}
//====================================================================

View file

@ -48,55 +48,172 @@ static __attribute__ ((used)) const char rcsid[] =
#include "rua_internal.h"
typedef struct bi_plist_s {
struct bi_plist_s *next;
struct bi_plist_s **prev;
plitem_t *plitem;
int own;
} bi_plist_t;
typedef struct {
hashtab_t *items;
PR_RESMAP (bi_plist_t) plist_map;
bi_plist_t *plists;
hashtab_t *plist_tab;
} plist_resources_t;
static inline void
return_plitem (progs_t *pr, plitem_t *plitem)
static bi_plist_t *
plist_new (plist_resources_t *res)
{
memset (&R_INT (pr), 0, 8);
memcpy (&R_INT (pr), &plitem, sizeof (plitem));
PR_RESNEW (bi_plist_t, res->plist_map);
}
static inline plitem_t *
p_plitem (progs_t *pr, int n)
static void
plist_free (plist_resources_t *res, bi_plist_t *plist)
{
plitem_t *plitem;
memcpy (&plitem, &P_INT (pr, n), sizeof (plitem));
return plitem;
PR_RESFREE (bi_plist_t, res->plist_map, plist);
}
static inline plitem_t *
record_plitem (progs_t *pr, plitem_t *plitem)
static void
plist_reset (plist_resources_t *res)
{
plist_resources_t *res = PR_Resources_Find (pr, "plist");
if (plitem)
Hash_AddElement (res->items, plitem);
return plitem;
PR_RESRESET (bi_plist_t, res->plist_map);
}
static inline plitem_t *
remove_plitem (progs_t *pr, plitem_t *plitem)
static inline bi_plist_t *
plist_get (plist_resources_t *res, unsigned index)
{
plist_resources_t *res = PR_Resources_Find (pr, "plist");
PR_RESGET(res->plist_map, index);
}
static inline int
plist_index (plist_resources_t *res, bi_plist_t *plist)
{
PR_RESINDEX(res->plist_map, plist);
}
static void
bi_plist_clear (progs_t *pr, void *data)
{
plist_resources_t *res = (plist_resources_t *) data;
bi_plist_t *plist;
for (plist = res->plists; plist; plist = plist->next) {
if (plist->own)
PL_Free (plist->plitem);
}
Hash_FlushTable (res->plist_tab);
plist_reset (res);
}
static inline int
plist_handle (plist_resources_t *res, plitem_t *plitem)
{
bi_plist_t dummy = {0, 0, plitem, 0};
bi_plist_t *plist = Hash_FindElement (res->plist_tab, &dummy);
Hash_DelElement (res->items, plitem);
return plitem;
if (plist)
return plist_index (res, plist);
plist = plist_new (res);
if (!plist)
return 0;
plist->next = res->plists;
plist->prev = &res->plists;
if (res->plists)
res->plists->prev = &plist->next;
res->plists = plist;
plist->plitem = plitem;
Hash_AddElement (res->plist_tab, plist);
return plist_index (res, plist);
}
static inline void
plist_free_handle (plist_resources_t *res, bi_plist_t *plist)
{
Hash_DelElement (res->plist_tab, plist);
*plist->prev = plist->next;
plist_free (res, plist);
}
static inline bi_plist_t *
get_plist (progs_t *pr, const char *name, int handle)
{
plist_resources_t *res = PR_Resources_Find (pr, "plist");
bi_plist_t *plist = plist_get (res, handle);
// plist->prev will be null if the handle is unallocated
if (!plist || !plist->prev)
PR_RunError (pr, "invalid plist passed to %s", name + 3);
return plist;
}
static inline int
plist_retain (plist_resources_t *res, plitem_t *plitem)
{
int handle;
bi_plist_t *plist;
if (!plitem)
return 0;
handle = plist_handle (res, plitem);
if (!handle) {
// we're taking ownership of the plitem, but we have nowhere to store
// it, so we have to lose it. However, in this situation, we have worse
// things to worry about.
PL_Free (plitem);
return 0;
}
plist = plist_get (res, handle);
plist->own = 1;
return handle;
}
static void
bi_PL_GetFromFile (progs_t *pr)
{
plist_resources_t *res = PR_Resources_Find (pr, "plist");
QFile *file = QFile_GetFile (pr, P_INT (pr, 0));
plitem_t *plitem;
long offset;
long size;
long len;
char *buf;
offset = Qtell (file);
size = Qfilesize (file);
len = size - offset;
buf = malloc (len + 1);
Qread (file, buf, len);
buf[len] = 0;
plitem = PL_GetPropertyList (buf);
R_INT (pr) = plist_retain (res, plitem);
}
static void
bi_PL_GetPropertyList (progs_t *pr)
{
plist_resources_t *res = PR_Resources_Find (pr, "plist");
plitem_t *plitem = PL_GetPropertyList (P_GSTRING (pr, 0));
return_plitem (pr, record_plitem (pr, plitem));
R_INT (pr) = plist_retain (res, plitem);
}
static void
bi_PL_WritePropertyList (progs_t *pr)
{
char *pl = PL_WritePropertyList (p_plitem (pr, 0));
int handle = P_INT (pr, 0);
bi_plist_t *plist = get_plist (pr, __FUNCTION__, handle);
char *pl = PL_WritePropertyList (plist->plitem);
R_STRING (pr) = PR_SetDynamicString (pr, pl);
free (pl);
}
@ -104,125 +221,218 @@ bi_PL_WritePropertyList (progs_t *pr)
static void
bi_PL_Type (progs_t *pr)
{
R_INT (pr) = PL_Type (p_plitem (pr, 0));
int handle = P_INT (pr, 0);
bi_plist_t *plist = get_plist (pr, __FUNCTION__, handle);
R_INT (pr) = PL_Type (plist->plitem);
}
static void
bi_PL_String (progs_t *pr)
{
const char *str = PL_String (p_plitem (pr, 0));
int handle = P_INT (pr, 0);
bi_plist_t *plist = get_plist (pr, __FUNCTION__, handle);
const char *str = PL_String (plist->plitem);
RETURN_STRING (pr, str);
}
static void
bi_PL_ObjectForKey (progs_t *pr)
{
return_plitem (pr, PL_ObjectForKey (p_plitem (pr, 0), P_GSTRING (pr, 1)));
plist_resources_t *res = PR_Resources_Find (pr, "plist");
int handle = P_INT (pr, 0);
bi_plist_t *plist = get_plist (pr, __FUNCTION__, handle);
const char *key = P_GSTRING (pr, 1);
plitem_t *plitem = PL_ObjectForKey (plist->plitem, key);
R_INT (pr) = 0;
if (!plitem)
return;
R_INT (pr) = plist_handle (res, plitem);
}
static void
bi_PL_RemoveObjectForKey (progs_t *pr)
{
plist_resources_t *res = PR_Resources_Find (pr, "plist");
int handle = P_INT (pr, 0);
bi_plist_t *plist = get_plist (pr, __FUNCTION__, handle);
const char *key = P_GSTRING (pr, 1);
plitem_t *plitem = PL_RemoveObjectForKey (plist->plitem, key);
R_INT (pr) = plist_retain (res, plitem);
}
static void
bi_PL_ObjectAtIndex (progs_t *pr)
{
return_plitem (pr, PL_ObjectAtIndex (p_plitem (pr, 0), P_INT (pr, 1)));
plist_resources_t *res = PR_Resources_Find (pr, "plist");
int handle = P_INT (pr, 0);
bi_plist_t *plist = get_plist (pr, __FUNCTION__, handle);
int ind = P_INT (pr, 1);
plitem_t *plitem = PL_ObjectAtIndex (plist->plitem, ind);
R_INT (pr) = 0;
if (!plitem)
return;
R_INT (pr) = plist_handle (res, plitem);
}
static void
bi_PL_D_AllKeys (progs_t *pr)
{
return_plitem (pr, PL_D_AllKeys (p_plitem (pr, 0)));
plist_resources_t *res = PR_Resources_Find (pr, "plist");
int handle = P_INT (pr, 0);
bi_plist_t *plist = get_plist (pr, __FUNCTION__, handle);
plitem_t *plitem = PL_D_AllKeys (plist->plitem);
R_INT (pr) = plist_retain (res, plitem);
}
static void
bi_PL_D_NumKeys (progs_t *pr)
{
R_INT (pr) = PL_D_NumKeys (p_plitem (pr, 0));
int handle = P_INT (pr, 0);
bi_plist_t *plist = get_plist (pr, __FUNCTION__, handle);
R_INT (pr) = PL_D_NumKeys (plist->plitem);
}
static void
bi_PL_D_AddObject (progs_t *pr)
{
R_INT (pr) = PL_D_AddObject (p_plitem (pr, 0), P_GSTRING (pr, 1),
remove_plitem (pr, p_plitem (pr, 2)));
int dict_handle = P_INT (pr, 0);
int obj_handle = P_INT (pr, 2);
bi_plist_t *dict = get_plist (pr, __FUNCTION__, dict_handle);
const char *key = P_GSTRING (pr, 1);
bi_plist_t *obj = get_plist (pr, __FUNCTION__, obj_handle);
obj->own = 0;
R_INT (pr) = PL_D_AddObject (dict->plitem, key, obj->plitem);
}
static void
bi_PL_A_AddObject (progs_t *pr)
{
R_INT (pr) = PL_A_AddObject (p_plitem (pr, 0),
remove_plitem (pr, p_plitem (pr, 1)));
int arr_handle = P_INT (pr, 0);
int obj_handle = P_INT (pr, 1);
bi_plist_t *arr = get_plist (pr, __FUNCTION__, arr_handle);
bi_plist_t *obj = get_plist (pr, __FUNCTION__, obj_handle);
obj->own = 0;
R_INT (pr) = PL_A_AddObject (arr->plitem, obj->plitem);
}
static void
bi_PL_A_NumObjects (progs_t *pr)
{
R_INT (pr) = PL_A_NumObjects (p_plitem (pr, 0));
int handle = P_INT (pr, 0);
bi_plist_t *plist = get_plist (pr, __FUNCTION__, handle);
R_INT (pr) = PL_A_NumObjects (plist->plitem);
}
static void
bi_PL_A_InsertObjectAtIndex (progs_t *pr)
{
R_INT (pr) = PL_A_InsertObjectAtIndex (p_plitem (pr, 0),
remove_plitem (pr, p_plitem (pr, 1)),
P_INT (pr, 2));
int dict_handle = P_INT (pr, 0);
int obj_handle = P_INT (pr, 1);
bi_plist_t *arr = get_plist (pr, __FUNCTION__, dict_handle);
bi_plist_t *obj = get_plist (pr, __FUNCTION__, obj_handle);
int ind = P_INT (pr, 2);
obj->own = 0;
R_INT (pr) = PL_A_InsertObjectAtIndex (arr->plitem, obj->plitem, ind);
}
static void
bi_PL_Free (progs_t *pr)
bi_PL_RemoveObjectAtIndex (progs_t *pr)
{
PL_Free (remove_plitem (pr, p_plitem (pr, 0)));
}
plist_resources_t *res = PR_Resources_Find (pr, "plist");
int handle = P_INT (pr, 0);
bi_plist_t *plist = get_plist (pr, __FUNCTION__, handle);
int ind = P_INT (pr, 1);
plitem_t *plitem = PL_RemoveObjectAtIndex (plist->plitem, ind);
static void
bi_PL_NewArray (progs_t *pr)
{
return_plitem (pr, record_plitem (pr, PL_NewArray ()));
}
static void
bi_PL_NewData (progs_t *pr)
{
return_plitem (pr, record_plitem (pr, PL_NewData (P_GPOINTER (pr, 0),
P_INT (pr, 1))));
}
static void
bi_PL_NewString (progs_t *pr)
{
return_plitem (pr, record_plitem (pr, PL_NewString (P_GSTRING (pr, 0))));
R_INT (pr) = plist_retain (res, plitem);
}
static void
bi_PL_NewDictionary (progs_t *pr)
{
return_plitem (pr, record_plitem (pr, PL_NewDictionary ()));
plist_resources_t *res = PR_Resources_Find (pr, "plist");
plitem_t *plitem = PL_NewDictionary ();
R_INT (pr) = plist_retain (res, plitem);
}
static void
bi_plist_clear (progs_t *pr, void *data)
bi_PL_NewArray (progs_t *pr)
{
plist_resources_t *res = (plist_resources_t *) data;
plist_resources_t *res = PR_Resources_Find (pr, "plist");
plitem_t *plitem = PL_NewArray ();
R_INT (pr) = plist_retain (res, plitem);
}
Hash_FlushTable (res->items);
static void
bi_PL_NewData (progs_t *pr)
{
//FIXME not safe
plist_resources_t *res = PR_Resources_Find (pr, "plist");
plitem_t *plitem = PL_NewData (P_GPOINTER (pr, 0), P_INT (pr, 1));
R_INT (pr) = plist_retain (res, plitem);
}
static void
bi_PL_NewString (progs_t *pr)
{
plist_resources_t *res = PR_Resources_Find (pr, "plist");
plitem_t *plitem = PL_NewString (P_GSTRING (pr, 0));
R_INT (pr) = plist_retain (res, plitem);
}
static void
bi_PL_Free (progs_t *pr)
{
plist_resources_t *res = PR_Resources_Find (pr, "plist");
int handle = P_INT (pr, 0);
bi_plist_t *plist = get_plist (pr, __FUNCTION__, handle);
if (!plist->own)
PR_RunError (pr, "attempt to free unowned plist");
PL_Free (plist->plitem);
plist_free_handle (res, plist);
}
static uintptr_t
plist_get_hash (void *key, void *unused)
{
return (uintptr_t) key;
bi_plist_t *plist = (bi_plist_t *) key;
return (uintptr_t) plist->plitem;
}
static int
plist_compare (void *k1, void *k2, void *unused)
{
return k1 == k2;
bi_plist_t *pl1 = (bi_plist_t *) k1;
bi_plist_t *pl2 = (bi_plist_t *) k2;
return pl1->plitem == pl2->plitem;
}
static builtin_t builtins[] = {
{"PL_GetFromFile", bi_PL_GetFromFile, -1},
{"PL_GetPropertyList", bi_PL_GetPropertyList, -1},
{"PL_WritePropertyList", bi_PL_WritePropertyList, -1},
{"PL_Type", bi_PL_Type, -1},
{"PL_String", bi_PL_String, -1},
{"PL_ObjectForKey", bi_PL_ObjectForKey, -1},
{"PL_RemoveObjectForKey", bi_PL_RemoveObjectForKey, -1},
{"PL_ObjectAtIndex", bi_PL_ObjectAtIndex, -1},
{"PL_D_AllKeys", bi_PL_D_AllKeys, -1},
{"PL_D_NumKeys", bi_PL_D_NumKeys, -1},
@ -230,6 +440,7 @@ static builtin_t builtins[] = {
{"PL_A_AddObject", bi_PL_A_AddObject, -1},
{"PL_A_NumObjects", bi_PL_A_NumObjects, -1},
{"PL_A_InsertObjectAtIndex", bi_PL_A_InsertObjectAtIndex, -1},
{"PL_RemoveObjectAtIndex", bi_PL_RemoveObjectAtIndex, -1},
{"PL_NewDictionary", bi_PL_NewDictionary, -1},
{"PL_NewArray", bi_PL_NewArray, -1},
{"PL_NewData", bi_PL_NewData, -1},
@ -242,8 +453,8 @@ void
RUA_Plist_Init (progs_t *pr, int secure)
{
plist_resources_t *res = calloc (1, sizeof (plist_resources_t));
res->items = Hash_NewTable (1021, 0, 0, 0);
Hash_SetHashCompare (res->items, plist_get_hash, plist_compare);
res->plist_tab = Hash_NewTable (1021, 0, 0, 0);
Hash_SetHashCompare (res->plist_tab, plist_get_hash, plist_compare);
PR_Resources_Register (pr, "plist", res, bi_plist_clear);
PR_RegisterBuiltins (pr, builtins);

View file

@ -174,6 +174,14 @@ get_handle (progs_t *pr, const char *name, int handle)
return h;
}
QFile *
QFile_GetFile (progs_t *pr, int handle)
{
qfile_t *h = get_handle (pr, __FUNCTION__, handle);
return h->file;
}
static void
bi_Qclose (progs_t *pr)
{
@ -182,7 +190,7 @@ bi_Qclose (progs_t *pr)
qfile_t *h = handle_get (res, handle);
if (!h)
PR_RunError (pr, "invalid file handle pass to Qclose");
PR_RunError (pr, "invalid file handle passed to Qclose");
Qclose (h->file);
*h->prev = h->next;
handle_free (res, h);

View file

@ -47,13 +47,26 @@ static __attribute__ ((used)) const char rcsid[] =
#include "QF/sys.h"
static void
swap_bsp (bsp_t *bsp, int todisk)
swap_bsp (bsp_t *bsp, int todisk, void (*cb) (const bsp_t *, void *),
void *cbdata)
{
int c, i, j;
dmiptexlump_t *mtl;
dmodel_t *d;
int c, i, j;
dmiptexlump_t *mtl;
dmodel_t *d;
// models
if (bsp->header) {
bsp->header->version = LittleLong (bsp->header->version);
for (i = 0; i < HEADER_LUMPS; i++) {
bsp->header->lumps[i].fileofs =
LittleLong (bsp->header->lumps[i].fileofs);
bsp->header->lumps[i].filelen =
LittleLong (bsp->header->lumps[i].filelen);
}
if (cb)
cb (bsp, cbdata);
}
// models
for (i=0 ; i<bsp->nummodels ; i++) {
d = &bsp->models[i];
@ -157,13 +170,13 @@ swap_bsp (bsp_t *bsp, int todisk)
// marksurfaces
for (i=0 ; i<bsp->nummarksurfaces ; i++) {
unsigned short *marksurface = &bsp->marksurfaces[i];
uint16_t *marksurface = &bsp->marksurfaces[i];
*marksurface = LittleShort (*marksurface);
}
// surfedges
for (i=0 ; i<bsp->numsurfedges ; i++) {
int *surfedge = &bsp->surfedges[i];
int32_t *surfedge = &bsp->surfedges[i];
*surfedge = LittleLong (*surfedge);
}
@ -176,29 +189,35 @@ swap_bsp (bsp_t *bsp, int todisk)
}
bsp_t *
LoadBSPMem (void *mem, int size)
LoadBSPMem (void *mem, size_t mem_size, void (*cb) (const bsp_t *, void *),
void *cbdata)
{
dheader_t *header = mem;
bsp_t *bsp;
if (LittleLong (header->version) != BSPVERSION)
Sys_Error ("version %i, not %i", LittleLong (header->version),
bsp = calloc (sizeof (bsp_t), 1);
bsp->header = mem;
if (LittleLong (bsp->header->version) != BSPVERSION)
Sys_Error ("version %i, not %i", LittleLong (bsp->header->version),
BSPVERSION);
#undef SET_LUMP
#define SET_LUMP(l,n) \
do { \
bsp->num##n = LittleLong (header->lumps[l].filelen); \
if (bsp->num##n) { \
bsp->n = malloc (bsp->num##n); \
memcpy (bsp->n, \
(byte *) header + LittleLong (header->lumps[l].fileofs), \
bsp->num##n); \
} \
bsp->num##n /= sizeof (bsp->n[0]); \
size_t size = LittleLong (bsp->header->lumps[l].filelen); \
size_t offs = LittleLong (bsp->header->lumps[l].fileofs); \
void *data = (byte *) mem + offs; \
if (offs >= mem_size || (offs + size) > mem_size) \
Sys_Error ("invalid lump"); \
if (size % sizeof (bsp->n[0])) \
Sys_Error ("funny lump size"); \
bsp->n = 0; \
if (size) \
bsp->n = (void *) data; \
bsp->num##n = size / sizeof (bsp->n[0]); \
} while (0)
bsp = malloc (sizeof (bsp_t));
SET_LUMP (LUMP_PLANES, planes);
SET_LUMP (LUMP_LEAFS, leafs);
SET_LUMP (LUMP_VERTEXES, vertexes);
@ -214,14 +233,15 @@ do { \
#undef SET_LUMP
#define SET_LUMP(l,n) \
do { \
bsp->n##size = LittleLong (header->lumps[l].filelen); \
if (bsp->n##size) { \
bsp->n = malloc (bsp->n##size); \
memcpy (bsp->n, \
(byte *) header + LittleLong (header->lumps[l].fileofs), \
bsp->n##size); \
} \
bsp->n##size /= sizeof (bsp->n[0]); \
size_t size = LittleLong (bsp->header->lumps[l].filelen); \
size_t offs = LittleLong (bsp->header->lumps[l].fileofs); \
void *data = (byte *) mem + offs; \
if (offs >= mem_size || (offs + size) > mem_size) \
Sys_Error ("invalid lump"); \
bsp->n = 0; \
if (size) \
bsp->n = (void *) data; \
bsp->n##size = size; \
} while (0)
SET_LUMP (LUMP_LIGHTING, lightdata);
@ -229,35 +249,32 @@ do { \
SET_LUMP (LUMP_ENTITIES, entdata);
SET_LUMP (LUMP_TEXTURES, texdata);
swap_bsp (bsp, 0);
swap_bsp (bsp, 0, cb, cbdata);
return bsp;
}
VISIBLE bsp_t *
LoadBSPFile (QFile *file, int size)
LoadBSPFile (QFile *file, size_t size)
{
void *buf;
bsp_t *bsp;
buf = malloc (size);
Qread (file, buf, size);
bsp = LoadBSPMem (buf, size);
free (buf);
bsp = LoadBSPMem (buf, size, 0, 0);
bsp->own_header = 1;
return bsp;
}
/*
WriteBSPFile
Swaps the bsp file in place, so it should not be referenced again
*/
VISIBLE void
WriteBSPFile (bsp_t *bsp, QFile *file)
{
int size;
dheader_t *header;
WriteBSPFile (const bsp_t *bsp, QFile *file)
{
size_t size;
byte *data;
bsp_t tbsp;
#define ROUND(x) (((x) + 3) & ~3)
@ -275,27 +292,31 @@ WriteBSPFile (bsp_t *bsp, QFile *file)
size += ROUND (bsp->numfaces * sizeof (dface_t));
size += ROUND (bsp->numclipnodes * sizeof (dclipnode_t));
size += ROUND (bsp->numedges * sizeof (dedge_t));
size += ROUND (bsp->nummarksurfaces * sizeof (unsigned short));
size += ROUND (bsp->numsurfedges * sizeof (int));
size += ROUND (bsp->nummarksurfaces * sizeof (uint16_t));
size += ROUND (bsp->numsurfedges * sizeof (uint32_t));
header = malloc (size);
memset (header, 0, size);
swap_bsp (bsp, 1);
tbsp.header = calloc (size, 1);
#undef SET_LUMP
#define SET_LUMP(l,n) \
do { \
bsp->num##n *= sizeof (bsp->n[0]); \
header->lumps[l].fileofs = LittleLong (data - (byte *) header); \
header->lumps[l].filelen = LittleLong (bsp->num##n); \
memcpy (data, bsp->n, bsp->num##n); \
data += ROUND (bsp->num##n); \
tbsp.num##n = bsp->num##n; \
if (tbsp.num##n) {\
tbsp.n = (void *) data; \
tbsp.header->lumps[l].fileofs = data - (byte *) tbsp.header; \
tbsp.header->lumps[l].filelen = tbsp.num##n * sizeof (bsp->n[0]); \
memcpy (data, bsp->n, tbsp.header->lumps[l].filelen); \
data += ROUND (tbsp.header->lumps[l].filelen); \
} else {\
tbsp.n = 0; \
tbsp.header->lumps[l].fileofs = 0; \
tbsp.header->lumps[l].filelen = 0; \
} \
} while (0)
header->version = LittleLong (BSPVERSION);
tbsp.header->version = BSPVERSION;
data = (byte *) &header[1];
data = (byte *) &tbsp.header[1];
SET_LUMP (LUMP_PLANES, planes);
SET_LUMP (LUMP_LEAFS, leafs);
SET_LUMP (LUMP_VERTEXES, vertexes);
@ -311,11 +332,18 @@ do { \
#undef SET_LUMP
#define SET_LUMP(l,n) \
do { \
bsp->n##size *= sizeof (bsp->n[0]); \
header->lumps[l].fileofs = LittleLong (data - (byte *) header); \
header->lumps[l].filelen = LittleLong (bsp->n##size); \
memcpy (data, bsp->n, bsp->n##size); \
data += ROUND (bsp->n##size); \
tbsp.n##size = bsp->n##size; \
if (tbsp.n##size) { \
tbsp.n = (void *) data; \
tbsp.header->lumps[l].fileofs = data - (byte *) tbsp.header; \
tbsp.header->lumps[l].filelen = tbsp.n##size; \
memcpy (data, bsp->n, bsp->n##size); \
data += ROUND (tbsp.header->lumps[l].filelen); \
} else {\
tbsp.n = 0; \
tbsp.header->lumps[l].fileofs = 0; \
tbsp.header->lumps[l].filelen = 0; \
} \
} while (0)
SET_LUMP (LUMP_LIGHTING, lightdata);
@ -323,8 +351,10 @@ do { \
SET_LUMP (LUMP_ENTITIES, entdata);
SET_LUMP (LUMP_TEXTURES, texdata);
Qwrite (file, header, size);
free (header);
swap_bsp (&tbsp, 1, 0, 0);
Qwrite (file, tbsp.header, size);
free (tbsp.header);
}
VISIBLE bsp_t *
@ -334,121 +364,157 @@ BSP_New (void)
}
VISIBLE void
BSP_AddPlane (bsp_t *bsp, dplane_t *plane)
BSP_Free (bsp_t *bsp)
{
bsp->planes = realloc (bsp->planes,
(bsp->numplanes + 1) * sizeof (dplane_t));
#define FREE(X) \
do { \
if (bsp->own_##X && bsp->X) \
free (bsp->X); \
} while (0)
FREE (models);
FREE (visdata);
FREE (lightdata);
FREE (texdata);
FREE (entdata);
FREE (leafs);
FREE (planes);
FREE (vertexes);
FREE (nodes);
FREE (texinfo);
FREE (faces);
FREE (clipnodes);
FREE (edges);
FREE (marksurfaces);
FREE (surfedges);
FREE (header);
free (bsp);
}
#define REALLOC(X) \
do { \
if (!bsp->own_##X) { \
bsp->own_##X = 1; \
bsp->X = 0; \
} \
bsp->X = realloc (bsp->X, (bsp->num##X + 1) * sizeof (bsp->X[0])); \
} while (0)
VISIBLE void
BSP_AddPlane (bsp_t *bsp, const dplane_t *plane)
{
REALLOC (planes);
bsp->planes[bsp->numplanes++] = *plane;
}
VISIBLE void
BSP_AddLeaf (bsp_t *bsp, dleaf_t *leaf)
BSP_AddLeaf (bsp_t *bsp, const dleaf_t *leaf)
{
bsp->leafs = realloc (bsp->leafs,
(bsp->numleafs + 1) * sizeof (dleaf_t));
REALLOC (leafs);
bsp->leafs[bsp->numleafs++] = *leaf;
}
VISIBLE void
BSP_AddVertex (bsp_t *bsp, dvertex_t *vertex)
BSP_AddVertex (bsp_t *bsp, const dvertex_t *vertex)
{
bsp->vertexes = realloc (bsp->vertexes,
(bsp->numvertexes + 1) * sizeof (dvertex_t));
REALLOC (vertexes);
bsp->vertexes[bsp->numvertexes++] = *vertex;
}
VISIBLE void
BSP_AddNode (bsp_t *bsp, dnode_t *node)
BSP_AddNode (bsp_t *bsp, const dnode_t *node)
{
bsp->nodes = realloc (bsp->nodes,
(bsp->numnodes + 1) * sizeof (dnode_t));
REALLOC (nodes);
bsp->nodes[bsp->numnodes++] = *node;
}
VISIBLE void
BSP_AddTexinfo (bsp_t *bsp, texinfo_t *texinfo)
BSP_AddTexinfo (bsp_t *bsp, const texinfo_t *texinfo)
{
bsp->texinfo = realloc (bsp->texinfo,
(bsp->numtexinfo + 1) * sizeof (texinfo_t));
REALLOC (texinfo);
bsp->texinfo[bsp->numtexinfo++] = *texinfo;
}
VISIBLE void
BSP_AddFace (bsp_t *bsp, dface_t *face)
BSP_AddFace (bsp_t *bsp, const dface_t *face)
{
bsp->faces = realloc (bsp->faces,
(bsp->numfaces + 1) * sizeof (dface_t));
REALLOC (faces);
bsp->faces[bsp->numfaces++] = *face;
}
VISIBLE void
BSP_AddClipnode (bsp_t *bsp, dclipnode_t *clipnode)
BSP_AddClipnode (bsp_t *bsp, const dclipnode_t *clipnode)
{
bsp->clipnodes = realloc (bsp->clipnodes,
(bsp->numclipnodes + 1) * sizeof (dclipnode_t));
REALLOC (clipnodes);
bsp->clipnodes[bsp->numclipnodes++] = *clipnode;
}
VISIBLE void
BSP_AddMarkSurface (bsp_t *bsp, unsigned short marksurface)
BSP_AddMarkSurface (bsp_t *bsp, int marksurface)
{
bsp->marksurfaces = realloc (bsp->marksurfaces,
(bsp->nummarksurfaces + 1)
* sizeof (unsigned short));
REALLOC (marksurfaces);
bsp->marksurfaces[bsp->nummarksurfaces++] = marksurface;
}
VISIBLE void
BSP_AddSurfEdge (bsp_t *bsp, int surfedge)
{
bsp->surfedges = realloc (bsp->surfedges,
(bsp->numsurfedges + 1) * sizeof (int));
REALLOC (surfedges);
bsp->surfedges[bsp->numsurfedges++] = surfedge;
}
VISIBLE void
BSP_AddEdge (bsp_t *bsp, dedge_t *edge)
BSP_AddEdge (bsp_t *bsp, const dedge_t *edge)
{
bsp->edges = realloc (bsp->edges,
(bsp->numedges + 1) * sizeof (dedge_t));
REALLOC (edges);
bsp->edges[bsp->numedges++] = *edge;
}
VISIBLE void
BSP_AddModel (bsp_t *bsp, dmodel_t *model)
BSP_AddModel (bsp_t *bsp, const dmodel_t *model)
{
bsp->models = realloc (bsp->models,
(bsp->nummodels + 1) * sizeof (dmodel_t));
REALLOC (models);
bsp->models[bsp->nummodels++] = *model;
}
#define OWN(X) \
do { \
FREE(X); \
bsp->own_##X = 1; \
} while (0)
VISIBLE void
BSP_AddLighting (bsp_t *bsp, byte *lightdata, int lightdatasize)
BSP_AddLighting (bsp_t *bsp, const byte *lightdata, size_t lightdatasize)
{
OWN (lightdata);
bsp->lightdatasize = lightdatasize;
bsp->lightdata = malloc (lightdatasize);
memcpy (bsp->lightdata, lightdata, lightdatasize);
}
VISIBLE void
BSP_AddVisibility (bsp_t *bsp, byte *visdata, int visdatasize)
BSP_AddVisibility (bsp_t *bsp, const byte *visdata, size_t visdatasize)
{
OWN (visdata);
bsp->visdatasize = visdatasize;
bsp->visdata = malloc (visdatasize);
memcpy (bsp->visdata, visdata, visdatasize);
}
VISIBLE void
BSP_AddEntities (bsp_t *bsp, char *entdata, int entdatasize)
BSP_AddEntities (bsp_t *bsp, const char *entdata, size_t entdatasize)
{
OWN (entdata);
bsp->entdatasize = entdatasize;
bsp->entdata = malloc (entdatasize);
memcpy (bsp->entdata, entdata, entdatasize);
}
VISIBLE void
BSP_AddTextures (bsp_t *bsp, byte *texdata, int texdatasize)
BSP_AddTextures (bsp_t *bsp, const byte *texdata, size_t texdatasize)
{
OWN (texdata);
bsp->texdatasize = texdatasize;
bsp->texdata = malloc (texdatasize);
memcpy (bsp->texdata, texdata, texdatasize);

View file

@ -131,7 +131,7 @@ Cmd_Command (cbuf_args_t *args)
return 0;
if (cbuf_active->strict)
return -1;
else if (cmd_warncmd->int_val || developer->int_val)
else if (cmd_warncmd->int_val || developer->int_val & SYS_DEV)
Sys_Printf ("Unknown command \"%s\"\n", Cmd_Argv (0));
return 0;
}
@ -147,7 +147,8 @@ Cmd_AddCommand (const char *cmd_name, xcommand_t function,
// fail if the command already exists
cmd = (cmd_function_t *) Hash_Find (cmd_hash, cmd_name);
if (cmd) {
Sys_DPrintf ("Cmd_AddCommand: %s already defined\n", cmd_name);
Sys_MaskPrintf (SYS_DEV, "Cmd_AddCommand: %s already defined\n",
cmd_name);
return 0;
}
@ -498,7 +499,8 @@ Cmd_Exec_f (void)
return;
}
if (!Cvar_Command ()
&& (cmd_warncmd->int_val || (developer && developer->int_val)))
&& (cmd_warncmd->int_val
|| (developer && developer->int_val & SYS_DEV)))
Sys_Printf ("execing %s\n", Cmd_Argv (1));
Cbuf_InsertText (cbuf_active, f);
Hunk_FreeToLowMark (mark);

View file

@ -237,7 +237,8 @@ Cvar_Set (cvar_t *var, const char *value)
return;
if (var->flags & CVAR_ROM) {
Sys_DPrintf ("Cvar \"%s\" is read-only, cannot modify\n", var->name);
Sys_MaskPrintf (SYS_DEV, "Cvar \"%s\" is read-only, cannot modify\n",
var->name);
return;
}
@ -352,8 +353,9 @@ set_cvar (const char *cmd, int orflags)
if (var) {
if (var->flags & CVAR_ROM) {
Sys_DPrintf ("Cvar \"%s\" is read-only, cannot modify\n",
var_name);
Sys_MaskPrintf (SYS_DEV,
"Cvar \"%s\" is read-only, cannot modify\n",
var_name);
} else {
Cvar_Set (var, value);
Cvar_SetFlags (var, var->flags | orflags);
@ -382,6 +384,30 @@ Cvar_Seta_f (void)
set_cvar ("seta", CVAR_ARCHIVE);
}
static void
Cvar_Inc_f (void)
{
cvar_t *var;
float inc = 1;
const char *name;
switch (Cmd_Argc ()) {
default:
case 1:
Sys_Printf ("inc <cvar> [amount] : increment cvar\n");
return;
case 3:
inc = atof (Cmd_Argv (2));
case 2:
name = Cmd_Argv (1);
var = Cvar_FindVar (name);
if (!var)
Sys_Printf ("Unknown variable \"%s\"\n", name);
break;
}
Cvar_SetValue (var, var->value + inc);
}
static void
Cvar_Toggle_f (void)
{
@ -403,6 +429,84 @@ Cvar_Toggle_f (void)
Cvar_Set (var, var->int_val ? "0" : "1");
}
static void
Cvar_Cycle_f (void)
{
int i;
const char *name;
cvar_t *var;
if (Cmd_Argc () < 3) {
Sys_Printf ("cycle <cvar> <value list>: cycle cvar through a list of "
"values\n");
return;
}
name = Cmd_Argv (1);
var = Cvar_FindVar (name);
if (!var) {
var = Cvar_Get (name, Cmd_Argv (Cmd_Argc () - 1), CVAR_USER_CREATED,
0, USER_CVAR);
}
// loop through the args until you find one that matches the current cvar
// value. yes, this will get stuck on a list that contains the same value
// twice. it's not worth dealing with, and i'm not even sure it can be
// dealt with -- johnfitz
for (i = 2; i < Cmd_Argc (); i++) {
// zero is assumed to be a string, even though it could actually be
// zero. The worst case is that the first time you call this command,
// it won't match on zero when it should, but after that, it will be
// comparing string that all had the same source (the user) so it will
// work.
if (atof (Cmd_Argv (i)) == 0) {
if (!strcmp (Cmd_Argv (i), var->string))
break;
} else {
if (atof (Cmd_Argv (i)) == var->value)
break;
}
}
if (i == Cmd_Argc ())
Cvar_Set (var, Cmd_Argv (2)); // no match
else if (i + 1 == Cmd_Argc ())
Cvar_Set (var, Cmd_Argv (2)); // matched last value in list
else
Cvar_Set (var, Cmd_Argv (i + 1)); // matched earlier in list
}
static void
Cvar_Reset_f (void)
{
cvar_t *var;
const char *name;
switch (Cmd_Argc ()) {
default:
case 1:
Sys_Printf ("reset <cvar> : reset cvar to default\n");
break;
case 2:
name = Cmd_Argv (1);
var = Cvar_FindVar (name);
if (!var)
Sys_Printf ("Unknown variable \"%s\"\n", name);
else
Cvar_Reset (var);
break;
}
}
static void Cvar_ResetAll_f (void)
{
cvar_t *var;
for (var = cvar_vars; var; var = var->next)
if (!(var->flags & CVAR_ROM))
Cvar_Reset (var);
}
static void
Cvar_CvarList_f (void)
{
@ -488,6 +592,11 @@ Cvar_Init (void)
"variablename setting)");
Cmd_AddCommand ("toggle", Cvar_Toggle_f, "Toggle a cvar on or off");
Cmd_AddCommand ("cvarlist", Cvar_CvarList_f, "List all cvars");
Cmd_AddCommand ("cycle", Cvar_Cycle_f,
"Cycle a cvar through a list of values");
Cmd_AddCommand ("inc", Cvar_Inc_f, "Increment a cvar");
Cmd_AddCommand ("reset", Cvar_Reset_f, "Reset a cvar");
Cmd_AddCommand ("resetall", Cvar_ResetAll_f, "Reset all cvars");
}
void
@ -534,6 +643,7 @@ Cvar_Get (const char *name, const char *string, int cvarflags,
// Cvar doesn't exist, so we create it
var->name = strdup (name);
var->string = strdup (string);
var->default_string = strdup (string);
var->flags = cvarflags;
var->callback = callback;
var->description = description;
@ -578,3 +688,9 @@ Cvar_SetFlags (cvar_t *var, int cvarflags)
var->flags = cvarflags;
}
VISIBLE void
Cvar_Reset (cvar_t *var)
{
Cvar_Set (var, var->default_string);
}

View file

@ -160,9 +160,24 @@ MSG_WriteAngleV (sizebuf_t *sb, const vec3_t angles)
}
VISIBLE void
MSG_WriteAngle16 (sizebuf_t *sb, float angle16)
MSG_WriteAngle16 (sizebuf_t *sb, float angle)
{
MSG_WriteShort (sb, (int) (angle16 * (65536.0 / 360.0)) & 65535);
MSG_WriteShort (sb, (int) (angle * (65536.0 / 360.0)) & 65535);
}
VISIBLE void
MSG_WriteAngle16V (sizebuf_t *sb, const vec3_t angles)
{
byte *buf;
int i;
unsigned short ang;
buf = SZ_GetSpace (sb, 6);
for (i = 0; i < 3; i++) {
ang = (int) (angles[i] * (65536.0 / 360.0)) & 65535;
*buf++ = ang & 0xff;
*buf++ = ang >> 8;
}
}
VISIBLE void
@ -383,6 +398,19 @@ MSG_ReadAngle16 (qmsg_t *msg)
return MSG_ReadShort (msg) * (360.0 / 65536.0);
}
VISIBLE void
MSG_ReadAngle16V (qmsg_t *msg, vec3_t angles)
{
int i;
short ang;
for (i = 0; i < 3; i++) {
ang = MSG_ReadByte (msg);
ang |= MSG_ReadByte (msg) << 8;
angles[i] = ang * (360.0 / 65536.0);
}
}
VISIBLE int
MSG_ReadUTF8 (qmsg_t *msg)
{

View file

@ -341,7 +341,7 @@ PI_LoadPlugin (const char *type, const char *name)
// try to reopen
if (!(dlhand = pi_open_lib (realname, 1))) {
Sys_Printf ("Error reopening plugin \"%s\".\n", realname);
Sys_DPrintf ("Reason: \"%s\".\n", pi_error);
Sys_MaskPrintf (SYS_DEV, "Reason: \"%s\".\n", pi_error);
return NULL;
}
@ -387,8 +387,9 @@ PI_UnloadPlugin (plugin_t *plugin)
&& plugin->functions->general->p_Shutdown) {
plugin->functions->general->p_Shutdown ();
} else {
Sys_DPrintf ("Warning: No shutdown function for type %d plugin!\n",
plugin->type);
Sys_MaskPrintf (SYS_DEV,
"Warning: No shutdown function for type %d plugin!\n",
plugin->type);
}
// remove from the table of loaded plugins

View file

@ -549,15 +549,15 @@ qfs_build_gamedir (const char **list)
gamedir->dir.maps = nva ("%s/maps", gamedir->dir.def);
qfs_gamedir = gamedir;
Sys_DPrintf ("%s\n", qfs_gamedir->name);
Sys_DPrintf (" gamedir : %s\n", qfs_gamedir->gamedir);
Sys_DPrintf (" path : %s\n", qfs_gamedir->path);
Sys_DPrintf (" gamecode: %s\n", qfs_gamedir->gamecode);
Sys_DPrintf (" def : %s\n", qfs_gamedir->dir.def);
Sys_DPrintf (" skins : %s\n", qfs_gamedir->dir.skins);
Sys_DPrintf (" models : %s\n", qfs_gamedir->dir.models);
Sys_DPrintf (" sound : %s\n", qfs_gamedir->dir.sound);
Sys_DPrintf (" maps : %s\n", qfs_gamedir->dir.maps);
Sys_MaskPrintf (SYS_DEV, "%s\n", qfs_gamedir->name);
Sys_MaskPrintf (SYS_DEV, " gamedir : %s\n", qfs_gamedir->gamedir);
Sys_MaskPrintf (SYS_DEV, " path : %s\n", qfs_gamedir->path);
Sys_MaskPrintf (SYS_DEV, " gamecode: %s\n", qfs_gamedir->gamecode);
Sys_MaskPrintf (SYS_DEV, " def : %s\n", qfs_gamedir->dir.def);
Sys_MaskPrintf (SYS_DEV, " skins : %s\n", qfs_gamedir->dir.skins);
Sys_MaskPrintf (SYS_DEV, " models : %s\n", qfs_gamedir->dir.models);
Sys_MaskPrintf (SYS_DEV, " sound : %s\n", qfs_gamedir->dir.sound);
Sys_MaskPrintf (SYS_DEV, " maps : %s\n", qfs_gamedir->dir.maps);
qfs_process_path (qfs_gamedir->path, dir);
free (path);
Hash_DelTable (dirs);
@ -575,8 +575,9 @@ qfs_load_config (void)
if (*fs_dirconf->string) {
dirconf = Sys_ExpandSquiggle (fs_dirconf->string);
if (!(f = Qopen (dirconf, "rt")))
Sys_DPrintf ("Could not load `%s', using builtin defaults\n",
dirconf);
Sys_MaskPrintf (SYS_DEV,
"Could not load `%s', using builtin defaults\n",
dirconf);
free (dirconf);
}
if (!f)
@ -630,7 +631,8 @@ qfs_contains_updir (const char *path, int levels)
}
static int
qfs_expand_path (dstring_t *full_path, const char *base, const char *path)
qfs_expand_path (dstring_t *full_path, const char *base, const char *path,
int levels)
{
const char *separator = "/";
char *cpath;
@ -641,7 +643,7 @@ qfs_expand_path (dstring_t *full_path, const char *base, const char *path)
return -1;
}
cpath = QFS_CompressPath (path);
if (qfs_contains_updir (cpath, 0)) {
if (qfs_contains_updir (cpath, levels)) {
free (cpath);
errno = EACCES;
return -1;
@ -659,7 +661,7 @@ qfs_expand_path (dstring_t *full_path, const char *base, const char *path)
static int
qfs_expand_userpath (dstring_t *full_path, const char *path)
{
return qfs_expand_path (full_path, qfs_userpath, path);
return qfs_expand_path (full_path, qfs_userpath, path, 0);
}
VISIBLE char *
@ -825,8 +827,8 @@ open_file (searchpath_t *search, const char *filename, QFile **gzfile,
packfile = pack_find_file (search->pack, filename);
if (packfile) {
Sys_DPrintf ("PackFile: %s : %s\n", search->pack->filename,
packfile->name);
Sys_MaskPrintf (SYS_DEV, "PackFile: %s : %s\n",
search->pack->filename, packfile->name);
// open a new file on the pakfile
if (foundname) {
dstring_clearstr (foundname);
@ -841,7 +843,7 @@ open_file (searchpath_t *search, const char *filename, QFile **gzfile,
// check a file in the directory tree
dstring_t *netpath = dstring_new ();
if (qfs_expand_path (netpath, search->filename, filename) == 0) {
if (qfs_expand_path (netpath, search->filename, filename, 1) == 0) {
if (foundname) {
dstring_clearstr (foundname);
dstring_appendstr (foundname, filename);
@ -851,7 +853,7 @@ open_file (searchpath_t *search, const char *filename, QFile **gzfile,
return -1;
}
Sys_DPrintf ("FindFile: %s\n", netpath->str);
Sys_MaskPrintf (SYS_DEV, "FindFile: %s\n", netpath->str);
*gzfile = qfs_openread (netpath->str, -1, -1, zip);
dstring_delete (netpath);
@ -880,7 +882,9 @@ _QFS_FOpenFile (const char *filename, QFile **gzfile,
// make sure they're not trying to do weird stuff with our private files
path = QFS_CompressPath (filename);
if (qfs_contains_updir(path, 1)) {
Sys_DPrintf ("FindFile: %s: attempt to escape directory tree!\n", path);
Sys_MaskPrintf (SYS_DEV,
"FindFile: %s: attempt to escape directory tree!\n",
path);
goto error;
}
@ -915,7 +919,7 @@ _QFS_FOpenFile (const char *filename, QFile **gzfile,
goto ok;
}
Sys_DPrintf ("FindFile: can't find %s\n", filename);
Sys_MaskPrintf (SYS_DEV, "FindFile: can't find %s\n", filename);
error:
*gzfile = NULL;
qfs_filesize = -1;
@ -1026,7 +1030,7 @@ qfs_load_pakfile (char *packfile)
pack_t *pack = pack_open (packfile);
if (pack)
Sys_DPrintf ("Added packfile %s (%i files)\n",
Sys_MaskPrintf (SYS_DEV, "Added packfile %s (%i files)\n",
packfile, pack->numfiles);
return pack;
}
@ -1076,7 +1080,7 @@ qfs_load_gamedir (const char *dir)
char **pakfiles = NULL;
int i = 0, bufsize = 0, count = 0;
Sys_DPrintf ("qfs_load_gamedir (\"%s\")\n", dir);
Sys_MaskPrintf (SYS_DEV, "qfs_load_gamedir (\"%s\")\n", dir);
pakfiles = calloc (1, FBLOCK_SIZE * sizeof (char *));
@ -1180,11 +1184,12 @@ qfs_add_gamedir (const char *dir)
if (s != e) {
dsprintf (s_dir, "%.*s", (int) (e - s), s);
if (strcmp (s_dir->str, fs_userpath->string) != 0) {
if (qfs_expand_path (f_dir, s_dir->str, dir) != 0) {
if (qfs_expand_path (f_dir, s_dir->str, dir, 0) != 0) {
Sys_Printf ("dropping bad directory %s\n", dir);
break;
}
Sys_DPrintf ("qfs_add_gamedir (\"%s\")\n", f_dir->str);
Sys_MaskPrintf (SYS_DEV, "qfs_add_gamedir (\"%s\")\n",
f_dir->str);
qfs_add_dir (f_dir->str);
}
@ -1193,7 +1198,7 @@ qfs_add_gamedir (const char *dir)
}
qfs_expand_userpath (f_dir, dir);
Sys_DPrintf ("qfs_add_gamedir (\"%s\")\n", f_dir->str);
Sys_MaskPrintf (SYS_DEV, "qfs_add_gamedir (\"%s\")\n", f_dir->str);
qfs_add_dir (f_dir->str);
dstring_delete (f_dir);
@ -1408,7 +1413,7 @@ QFS_Open (const char *path, const char *mode)
int write = 0;
if (qfs_expand_userpath (full_path, path) == 0) {
Sys_DPrintf ("QFS_Open: %s %s\n", full_path->str, mode);
Sys_MaskPrintf (SYS_DEV, "QFS_Open: %s %s\n", full_path->str, mode);
for (m = mode; *m; m++)
if (*m == 'w' || *m == '+' || *m == 'a')
write = 1;

View file

@ -84,7 +84,9 @@ struct QFile_s {
#endif
off_t size;
off_t start;
off_t pos;
int c;
int sub;
};
@ -216,12 +218,13 @@ Qdopen (int fd, const char *mode)
QFile *file;
char *m, *p;
int zip = 0;
int len = strlen (mode);
m = alloca (strlen (mode) + 1);
m = alloca (len + 1);
#ifdef _WIN32
setmode (fd, O_BINARY);
#endif
for (p = m; *mode && p - m < ((int) sizeof (m) - 1); mode++) {
for (p = m; *mode && p - m < len; mode++) {
if (*mode == 'z') {
zip = 1;
continue;
@ -288,6 +291,7 @@ Qsubopen (const char *path, int offs, int len, int zip)
file = Qdopen (fd, zip ? "rbz" : "rb");
file->size = len;
file->start = offs;
file->sub = 1;
return file;
}
@ -316,6 +320,19 @@ Qread (QFile *file, void *buf, int count)
offs = 1;
file->c = -1;
count--;
if (!count)
return 1;
}
if (file->sub) {
// sub-files are always opened in binary mode, so we don't need to
// worry about character translation messing up count/pos. Normal
// files can be left to the operating system to take care of EOF.
if (file->pos + count > file->size)
count = file->size - file->pos;
if (count < 0)
return -1;
if (!count)
return 0;
}
if (file->file)
ret = fread (buf, 1, count, file->file);
@ -325,12 +342,16 @@ Qread (QFile *file, void *buf, int count)
#else
return -1;
#endif
if (file->sub)
file->pos += ret;
return ret == -1 ? ret : ret + offs;
}
VISIBLE int
Qwrite (QFile *file, const void *buf, int count)
{
if (file->sub) // can't write to a sub-file
return -1;
if (file->file)
return fwrite (buf, 1, count, file->file);
#ifdef HAVE_ZLIB
@ -347,6 +368,8 @@ Qprintf (QFile *file, const char *fmt, ...)
va_list args;
int ret = -1;
if (file->sub) // can't write to a sub-file
return -1;
va_start (args, fmt);
if (file->file)
ret = vfprintf (file->file, fmt, args);
@ -372,6 +395,8 @@ Qprintf (QFile *file, const char *fmt, ...)
VISIBLE int
Qputs (QFile *file, const char *buf)
{
if (file->sub) // can't write to a sub-file
return -1;
if (file->file)
return fputs (buf, file->file);
#ifdef HAVE_ZLIB
@ -385,25 +410,22 @@ Qputs (QFile *file, const char *buf)
VISIBLE char *
Qgets (QFile *file, char *buf, int count)
{
char *ret = buf;
char *ret = buf;
char c;
if (file->c != -1) {
*buf++ = file->c;
count--;
file->c = -1;
if (!count)
return ret;
while (buf - ret < count - 1) {
c = Qgetc (file);
if (c < 0)
break;
*buf++ = c;
if (c == '\n')
break;
}
if (file->file)
buf = fgets (buf, count, file->file);
else {
#ifdef HAVE_ZLIB
buf = gzgets (file->gzfile, buf, count);
#else
if (buf == ret)
return 0;
#endif
}
return buf ? ret : 0;
*buf++ = 0;
return ret;
}
VISIBLE int
@ -414,6 +436,11 @@ Qgetc (QFile *file)
file->c = -1;
return c;
}
if (file->sub) {
if (file->pos >= file->size)
return EOF;
file->pos++;
}
if (file->file)
return fgetc (file->file);
#ifdef HAVE_ZLIB
@ -427,6 +454,8 @@ Qgetc (QFile *file)
VISIBLE int
Qputc (QFile *file, int c)
{
if (file->sub) // can't write to a sub-file
return -1;
if (file->file)
return fputc (c, file->file);
#ifdef HAVE_ZLIB
@ -448,9 +477,10 @@ Qungetc (QFile *file, int c)
VISIBLE int
Qseek (QFile *file, long offset, int whence)
{
int res;
file->c = -1;
if (file->file) {
int res;
switch (whence) {
case SEEK_SET:
res = fseek (file->file, file->start + offset, whence);
@ -474,13 +504,18 @@ Qseek (QFile *file, long offset, int whence)
}
if (res != -1)
res = ftell (file->file) - file->start;
if (file->sub)
file->pos = res;
return res;
}
#ifdef HAVE_ZLIB
else {
// libz seems to keep track of the true start position itself
// doesn't support SEEK_END, though
return gzseek (file->gzfile, offset, whence);
res = gzseek (file->gzfile, offset, whence);
if (file->sub)
file->pos = res;
return res;
}
#else
return -1;
@ -502,6 +537,8 @@ Qtell (QFile *file)
#else
return -1;
#endif
if (file->sub)
file->pos = ret;
return ret == -1 ? ret : ret - offs;
}
@ -523,6 +560,8 @@ Qeof (QFile *file)
{
if (file->c != -1)
return 0;
if (file->sub)
return file->pos >= file->size;
if (file->file)
return feof (file->file);
#ifdef HAVE_ZLIB
@ -536,7 +575,7 @@ Qeof (QFile *file)
/*
Qgetline
Dynamic length version of Qgets. DO NOT free the buffer.
Dynamic length version of Qgets. Do NOT free the buffer.
*/
VISIBLE const char *
Qgetline (QFile *file)

View file

@ -367,6 +367,27 @@ riff_read (QFile *f)
chunk = &data->ck;
}
break;
case RIFF_CASE ('w','a','v','l'):
// FIXME: Convert wavl to data ?
case RIFF_CASE ('s','l','n','t'):
// FIXME: Add silence to data
case RIFF_CASE ('l','i','s','t'):
case RIFF_CASE ('l','a','b','l'):
case RIFF_CASE ('n','o','t','e'):
case RIFF_CASE ('l','t','x','t'):
case RIFF_CASE ('p','l','s','t'):
case RIFF_CASE ('i','n','s','t'):
case RIFF_CASE ('f','a','c','t'):
case RIFF_CASE ('s','m','p','l'):
{ // Unused chunk, still present in a lot of wav files.
int c;
Qseek(f, ck.len, SEEK_CUR);
if ((c = Qgetc (f)) && c != -1)
Qungetc (f, c);
continue; // Skip those blocks.
}
break;
default:
// unknown chunk. bail (could be corrupted file)
chunk = 0;

View file

@ -266,11 +266,11 @@ Sys_Printf (const char *fmt, ...)
}
VISIBLE void
Sys_DPrintf (const char *fmt, ...)
Sys_MaskPrintf (int mask, const char *fmt, ...)
{
va_list args;
if (!developer || !developer->int_val)
if (!developer || !(developer->int_val & mask))
return;
va_start (args, fmt);
sys_std_printf_function (fmt, args);
@ -604,9 +604,14 @@ Sys_ConsoleInput (void)
}
text[len] = c;
len++;
text[len] = 0;
if (len == sizeof (text))
if (len < sizeof (text))
text[len] = 0;
else {
// buffer is full
len = 0;
text[sizeof (text) - 1] = 0;
return text;
}
}
return NULL;

View file

@ -155,7 +155,7 @@ Z_Malloc (memzone_t *zone, int size)
{
void *buf;
if (!developer || developer->int_val)
if (!developer || developer->int_val & SYS_DEV)
Z_CheckHeap (zone); // DEBUG
buf = Z_TagMalloc (zone, size, 1);
if (!buf)
@ -238,6 +238,8 @@ Z_Realloc (memzone_t *zone, void *ptr, int size)
Sys_Error ("Z_Realloc: realloced a freed pointer");
old_size = block->size;
old_size -= sizeof (memblock_t); // account for size of block header
old_size -= 4; // space for memory trash tester
old_ptr = ptr;
Z_Free (zone, ptr);
@ -261,8 +263,8 @@ Z_Print (memzone_t *zone)
for (block = zone->blocklist.next ; ; block = block->next) {
Sys_Printf ("block:%p size:%7i tag:%3i ofs:%d\n",
block, block->size, block->tag,
(int) ((byte *) block - (byte *) zone));
block, block->size - (int) sizeof (memblock_t) - 4,
block->tag, (int) ((byte *) block - (byte *) zone));
if (block->next == &zone->blocklist)
break; // all blocks have been hit
@ -590,7 +592,7 @@ Cache_Move (cache_system_t * c)
// we are clearing up space at the bottom, so allocate it late
new = Cache_TryAlloc (c->size, true);
if (new) {
Sys_DPrintf ("cache_move ok\n");
Sys_MaskPrintf (SYS_DEV, "cache_move ok\n");
memcpy (new + 1, c + 1, c->size - sizeof (cache_system_t));
new->user = c->user;
@ -598,7 +600,7 @@ Cache_Move (cache_system_t * c)
Cache_Free (c->user);
new->user->data = (void *) (new + 1);
} else {
Sys_DPrintf ("cache_move failed\n");
Sys_MaskPrintf (SYS_DEV, "cache_move failed\n");
Cache_Free (c->user); // tough luck...
}
@ -854,7 +856,7 @@ Cache_Free (cache_user_t *c)
if (cs->readlock)
Sys_Error ("Cache_Free: attempt to free locked block");
Sys_DPrintf ("Cache_Free: freeing '%s' %p\n", cs->name, cs);
Sys_MaskPrintf (SYS_DEV, "Cache_Free: freeing '%s' %p\n", cs->name, cs);
Cache_UnlinkLRU (cs);
@ -917,9 +919,9 @@ Cache_Alloc (cache_user_t *c, int size, const char *name)
VISIBLE void
Cache_Report (void)
{
Sys_DPrintf ("%4.1f megabyte data cache\n",
(hunk_size - hunk_high_used -
hunk_low_used) / (float) (1024 * 1024));
Sys_MaskPrintf (SYS_DEV, "%4.1f megabyte data cache\n",
(hunk_size - hunk_high_used -
hunk_low_used) / (float) (1024 * 1024));
}
VISIBLE void

View file

@ -101,6 +101,16 @@ static byte cs_data[8 * 8 * 4] = {
0xff, 0xfe, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff,
0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
//From FitzQuake
255,255,255,255,255,255,255,255,
255,255,255, 8, 9,255,255,255,
255,255,255, 6, 8, 2,255,255,
255, 6, 8, 8, 6, 8, 8,255,
255,255, 2, 8, 8, 2, 2, 2,
255,255,255, 7, 8, 2,255,255,
255,255,255,255, 2, 2,255,255,
255,255,255,255,255,255,255,255,
};
typedef struct {
@ -134,7 +144,8 @@ Draw_InitText (void)
tVAsize = 0;
if (tVAsize) {
Sys_DPrintf ("Text: %i maximum vertex elements.\n", tVAsize);
Sys_MaskPrintf (SYS_DEV, "Text: %i maximum vertex elements.\n",
tVAsize);
if (textVertices)
free (textVertices);
@ -152,7 +163,7 @@ Draw_InitText (void)
for (i = 0; i < tVAsize; i++)
tVAindices[i] = i;
} else {
Sys_DPrintf ("Text: Vertex Array use disabled.\n");
Sys_MaskPrintf (SYS_DEV, "Text: Vertex Array use disabled.\n");
}
}
@ -567,10 +578,60 @@ crosshair_3 (int x, int y)
qfglColor3ubv (color_white);
}
static void
crosshair_4 (int x, int y)
{
unsigned char *pColor;
pColor = (unsigned char *) &d_8to24table[crosshaircolor->int_val];
qfglColor4ubv (pColor);
qfglBindTexture (GL_TEXTURE_2D, cs_texture);
qfglBegin (GL_QUADS);
qfglTexCoord2f (0, 0.5);
qfglVertex2f (x - 7, y - 7);
qfglTexCoord2f (0.5, 0.5);
qfglVertex2f (x + 9, y - 7);
qfglTexCoord2f (0.5, 1);
qfglVertex2f (x + 9, y + 9);
qfglTexCoord2f (0, 1);
qfglVertex2f (x - 7, y + 9);
qfglEnd ();
qfglColor3ubv (color_white);
}
static void
crosshair_5 (int x, int y) //FIXME don't use until the data is filled in
{
unsigned char *pColor;
pColor = (unsigned char *) &d_8to24table[crosshaircolor->int_val];
qfglColor4ubv (pColor);
qfglBindTexture (GL_TEXTURE_2D, cs_texture);
qfglBegin (GL_QUADS);
qfglTexCoord2f (0.5, 0.5);
qfglVertex2f (x - 7, y - 7);
qfglTexCoord2f (1, 0.5);
qfglVertex2f (x + 9, y - 7);
qfglTexCoord2f (1, 1);
qfglVertex2f (x + 9, y + 9);
qfglTexCoord2f (0.5, 1);
qfglVertex2f (x - 7, y + 9);
qfglEnd ();
qfglColor3ubv (color_white);
}
static void (*crosshair_func[]) (int x, int y) = {
crosshair_1,
crosshair_2,
crosshair_3,
crosshair_4,
crosshair_5,
};
VISIBLE void

View file

@ -161,7 +161,9 @@ R_InitParticles (void)
else
pVAsize = 0;
if (pVAsize) {
Sys_DPrintf ("Particles: %i maximum vertex elements.\n", pVAsize);
Sys_MaskPrintf (SYS_DEV,
"Particles: %i maximum vertex elements.\n",
pVAsize);
if (particleVertexArray)
free (particleVertexArray);
@ -175,7 +177,8 @@ R_InitParticles (void)
for (i = 0; i < pVAsize; i++)
pVAindices[i] = i;
} else {
Sys_DPrintf ("Particles: Vertex Array use disabled.\n");
Sys_MaskPrintf (SYS_DEV,
"Particles: Vertex Array use disabled.\n");
}
} else {
if (particleVertexArray) {
@ -212,7 +215,7 @@ R_ReadPointFile_f (void)
return;
}
Sys_DPrintf ("Reading %s...\n", name);
Sys_MaskPrintf (SYS_DEV, "Reading %s...\n", name);
c = 0;
for (;;) {
char buf[64];
@ -224,7 +227,7 @@ R_ReadPointFile_f (void)
c++;
if (numparticles >= r_maxparticles) {
Sys_DPrintf ("Not enough free particles\n");
Sys_MaskPrintf (SYS_DEV, "Not enough free particles\n");
break;
} else {
particle_new (pt_static, part_tex_dot, org, 1.5, vec3_origin,
@ -232,7 +235,7 @@ R_ReadPointFile_f (void)
}
}
Qclose (f);
Sys_DPrintf ("%i points read\n", c);
Sys_MaskPrintf (SYS_DEV, "%i points read\n", c);
}
static void
@ -1547,7 +1550,8 @@ R_ParticlePhysics (particle_t *part)
part->scale -= time2;
break;
default:
Sys_DPrintf ("unhandled particle type %d\n", part->type);
Sys_MaskPrintf (SYS_DEV, "unhandled particle type %d\n",
part->type);
break;
}
}

View file

@ -76,6 +76,14 @@ typedef struct {
int count;
} vert_order_t;
typedef struct {
short pose1;
short pose2;
float blend;
vec3_t origin;
vec3_t angles;
} lerpdata_t;
float r_avertexnormals[NUMVERTEXNORMALS][3] = {
#include "anorms.h"
};
@ -246,27 +254,102 @@ GL_DrawAliasShadow (aliashdr_t *paliashdr, vert_order_t *vo)
}
}
static inline vert_order_t *
GL_GetAliasFrameVerts16 (int frame, aliashdr_t *paliashdr, entity_t *e)
static inline void
gl_calc_blend16 (byte *posedata, lerpdata_t *lerpdata, vert_order_t *vo,
int count)
{
float interval;
int count, numposes, pose, i;
trivertx16_t *verts;
vert_order_t *vo;
blended_vert_t *vo_v;
trivertx16_t *verts;
trivertx16_t *verts1, *verts2;
int i;
if ((frame >= paliashdr->mdl.numframes) || (frame < 0)) {
if (developer->int_val)
Sys_DPrintf ("R_AliasSetupFrame: no such frame %d %s\n", frame,
currententity->model->name);
frame = 0;
verts = (trivertx16_t *) posedata;
if (lerpdata->blend == 0.0) {
verts = verts + lerpdata->pose1 * count;
} else if (lerpdata->blend == 1.0) {
verts = verts + lerpdata->pose2 * count;
} else {
verts1 = verts + lerpdata->pose1 * count;
verts2 = verts + lerpdata->pose2 * count;
for (i = 0, vo_v = vo->verts; i < count;
i++, vo_v++, verts1++, verts2++) {
float *n1, *n2;
VectorBlend (verts1->v, verts2->v, lerpdata->blend, vo_v->vert);
n1 = r_avertexnormals[verts1->lightnormalindex];
n2 = r_avertexnormals[verts2->lightnormalindex];
VectorBlend (n1, n2, lerpdata->blend, vo_v->normal);
if (VectorIsZero (vo_v->normal)) {
if (lerpdata->blend < 0.5) {
VectorCopy (n1, vo_v->normal);
} else {
VectorCopy (n2, vo_v->normal);
}
}
}
return;
}
pose = paliashdr->frames[frame].firstpose;
numposes = paliashdr->frames[frame].numposes;
verts = (trivertx16_t *) ((byte *) paliashdr + paliashdr->posedata);
for (i = 0, vo_v = vo->verts; i < count; i++, vo_v++, verts++) {
VectorCopy (verts->v, vo_v->vert);
VectorCopy (r_avertexnormals[verts->lightnormalindex], vo_v->normal);
}
}
static inline void
gl_calc_blend8 (byte *posedata, lerpdata_t *lerpdata, vert_order_t *vo,
int count)
{
blended_vert_t *vo_v;
trivertx_t *verts;
trivertx_t *verts1, *verts2;
int i;
verts = (trivertx_t *) posedata;
if (lerpdata->blend == 0.0) {
verts = verts + lerpdata->pose1 * count;
} else if (lerpdata->blend == 1.0) {
verts = verts + lerpdata->pose2 * count;
} else {
verts1 = verts + lerpdata->pose1 * count;
verts2 = verts + lerpdata->pose2 * count;
for (i = 0, vo_v = vo->verts; i < count;
i++, vo_v++, verts1++, verts2++) {
float *n1, *n2;
VectorBlend (verts1->v, verts2->v, lerpdata->blend, vo_v->vert);
n1 = r_avertexnormals[verts1->lightnormalindex];
n2 = r_avertexnormals[verts2->lightnormalindex];
VectorBlend (n1, n2, lerpdata->blend, vo_v->normal);
if (VectorIsZero (vo_v->normal)) {
if (lerpdata->blend < 0.5) {
VectorCopy (n1, vo_v->normal);
} else {
VectorCopy (n2, vo_v->normal);
}
}
}
return;
}
for (i = 0, vo_v = vo->verts; i < count; i++, vo_v++, verts++) {
VectorCopy (verts->v, vo_v->vert);
VectorCopy (r_avertexnormals[verts->lightnormalindex], vo_v->normal);
}
}
static inline vert_order_t *
GL_GetAliasFrameVerts (aliashdr_t *paliashdr, lerpdata_t *lerpdata)
{
int count;
vert_order_t *vo;
byte *posedata;
posedata = (byte *) paliashdr + paliashdr->posedata;
count = paliashdr->poseverts;
vo = Hunk_TempAlloc (sizeof (*vo) + count * sizeof (blended_vert_t));
vo->order = (int *) ((byte *) paliashdr + paliashdr->commands);
vo->verts = (blended_vert_t *) &vo[1];
@ -277,185 +360,12 @@ GL_GetAliasFrameVerts16 (int frame, aliashdr_t *paliashdr, entity_t *e)
vo->tex_coord = NULL;
}
vo->count = count;
if (numposes > 1) {
interval = paliashdr->frames[frame].interval;
pose += (int) (r_realtime / interval) % numposes;
} else {
/*
One tenth of a second is good for most Quake animations. If
the nextthink is longer then the animation is usually meant
to pause (e.g. check out the shambler magic animation in
shambler.qc). If its shorter then things will still be
smoothed partly, and the jumps will be less noticable
because of the shorter time. So, this is probably a good
assumption.
*/
interval = 0.1;
}
if (gl_lerp_anim->int_val) {
trivertx16_t *verts1, *verts2;
float blend;
if (paliashdr->mdl.ident == HEADER_MDL16)
gl_calc_blend16 (posedata, lerpdata, vo, count);
else
gl_calc_blend8 (posedata, lerpdata, vo, count);
e->frame_interval = interval;
if (e->pose2 != pose) {
e->frame_start_time = r_realtime;
if (e->pose2 == -1) {
e->pose1 = pose;
} else {
e->pose1 = e->pose2;
}
e->pose2 = pose;
blend = 0.0;
} else if (r_paused) {
blend = 1.0;
} else {
blend = (r_realtime - e->frame_start_time) / e->frame_interval;
blend = min (blend, 1.0);
}
if (blend == 0.0) {
verts = verts + e->pose1 * count;
} else if (blend == 1.0) {
verts = verts + e->pose2 * count;
} else {
verts1 = verts + e->pose1 * count;
verts2 = verts + e->pose2 * count;
for (i = 0, vo_v = vo->verts; i < count;
i++, vo_v++, verts1++, verts2++) {
float *n1, *n2;
VectorBlend (verts1->v, verts2->v, blend, vo_v->vert);
n1 = r_avertexnormals[verts1->lightnormalindex];
n2 = r_avertexnormals[verts2->lightnormalindex];
VectorBlend (n1, n2, blend, vo_v->normal);
if (VectorIsZero (vo_v->normal)) {
if (blend < 0.5) {
VectorCopy (n1, vo_v->normal);
} else {
VectorCopy (n2, vo_v->normal);
}
}
}
return vo;
}
} else {
verts += pose * count;
}
for (i = 0, vo_v = vo->verts; i < count; i++, vo_v++, verts++) {
VectorCopy (verts->v, vo_v->vert);
VectorCopy (r_avertexnormals[verts->lightnormalindex], vo_v->normal);
}
return vo;
}
static inline vert_order_t *
GL_GetAliasFrameVerts (int frame, aliashdr_t *paliashdr, entity_t *e)
{
float interval;
int count, numposes, pose, i;
trivertx_t *verts;
vert_order_t *vo;
blended_vert_t *vo_v;
if ((frame >= paliashdr->mdl.numframes) || (frame < 0)) {
if (developer->int_val)
Sys_DPrintf ("R_AliasSetupFrame: no such frame %d %s\n", frame,
currententity->model->name);
frame = 0;
}
pose = paliashdr->frames[frame].firstpose;
numposes = paliashdr->frames[frame].numposes;
verts = (trivertx_t *) ((byte *) paliashdr + paliashdr->posedata);
count = paliashdr->poseverts;
vo = Hunk_TempAlloc (sizeof (*vo) + count * sizeof (blended_vert_t));
vo->order = (int *) ((byte *) paliashdr + paliashdr->commands);
vo->verts = (blended_vert_t *) &vo[1];
if (paliashdr->tex_coord) {
vo->tex_coord = (tex_coord_t *) ((byte *) paliashdr + paliashdr->tex_coord);
} else {
vo->tex_coord = NULL;
}
vo->count = count;
if (numposes > 1) {
interval = paliashdr->frames[frame].interval;
pose += (int) (r_realtime / interval) % numposes;
} else {
/*
One tenth of a second is good for most Quake animations. If
the nextthink is longer then the animation is usually meant
to pause (e.g. check out the shambler magic animation in
shambler.qc). If its shorter then things will still be
smoothed partly, and the jumps will be less noticable
because of the shorter time. So, this is probably a good
assumption.
*/
interval = 0.1;
}
if (gl_lerp_anim->int_val) {
trivertx_t *verts1, *verts2;
float blend;
e->frame_interval = interval;
if (e->pose2 != pose) {
e->frame_start_time = r_realtime;
if (e->pose2 == -1) {
e->pose1 = pose;
} else {
e->pose1 = e->pose2;
}
e->pose2 = pose;
blend = 0.0;
} else if (r_paused) {
blend = 1.0;
} else {
blend = (r_realtime - e->frame_start_time) / e->frame_interval;
blend = min (blend, 1.0);
}
if (blend == 0.0) {
verts = verts + e->pose1 * count;
} else if (blend == 1.0) {
verts = verts + e->pose2 * count;
} else {
verts1 = verts + e->pose1 * count;
verts2 = verts + e->pose2 * count;
for (i = 0, vo_v = vo->verts; i < count;
i++, vo_v++, verts1++, verts2++) {
float *n1, *n2;
VectorBlend (verts1->v, verts2->v, blend, vo_v->vert);
n1 = r_avertexnormals[verts1->lightnormalindex];
n2 = r_avertexnormals[verts2->lightnormalindex];
VectorBlend (n1, n2, blend, vo_v->normal);
if (VectorIsZero (vo_v->normal)) {
if (blend < 0.5) {
VectorCopy (n1, vo_v->normal);
} else {
VectorCopy (n2, vo_v->normal);
}
}
}
return vo;
}
} else {
verts += pose * count;
}
for (i = 0, vo_v = vo->verts; i < count; i++, vo_v++, verts++) {
VectorCopy (verts->v, vo_v->vert);
VectorCopy (r_avertexnormals[verts->lightnormalindex], vo_v->normal);
}
return vo;
}
@ -466,7 +376,8 @@ R_AliasGetSkindesc (int skinnum, aliashdr_t *ahdr)
maliasskingroup_t *paliasskingroup;
if ((skinnum >= ahdr->mdl.numskins) || (skinnum < 0)) {
Sys_DPrintf ("R_AliasSetupSkin: no such skin # %d\n", skinnum);
Sys_MaskPrintf (SYS_DEV, "R_AliasGetSkindesc: no such skin # %d\n",
skinnum);
skinnum = 0;
}
@ -499,6 +410,118 @@ R_AliasGetSkindesc (int skinnum, aliashdr_t *ahdr)
return pskindesc;
}
static void
r_alais_setup_lerp (aliashdr_t *paliashdr, entity_t *e, lerpdata_t *lerpdata)
{
int frame = e->frame;
int posenum, numposes;
if ((frame >= paliashdr->mdl.numframes) || (frame < 0)) {
Sys_MaskPrintf (SYS_DEV, "r_alais_setup_lerp: no such frame %d %s\n",
frame, currententity->model->name);
frame = 0;
}
posenum = paliashdr->frames[frame].firstpose;
numposes = paliashdr->frames[frame].numposes;
if (numposes > 1) {
e->lerptime = paliashdr->frames[frame].interval;
posenum += (int) (r_realtime / e->lerptime) % numposes;
} else {
e->lerptime = 0.1;
}
if (e->lerpflags & LERP_RESETANIM) {
//kill any lerp in progress
e->lerpstart = 0;
e->previouspose = posenum;
e->currentpose = posenum;
e->lerpflags &= ~LERP_RESETANIM;
} else if (e->currentpose != posenum) {
// pose changed, start new lerp
if (e->lerpflags & LERP_RESETANIM2) {
//defer lerping one more time
e->lerpstart = 0;
e->previouspose = posenum;
e->currentpose = posenum;
e->lerpflags &= ~LERP_RESETANIM2;
} else {
e->lerpstart = r_realtime;
e->previouspose = e->currentpose;
e->currentpose = posenum;
}
}
if (gl_lerp_anim->int_val
/*&& !(e->model->flags & MOD_NOLERP && gl_lerp_anim->int_val != 2)*/) {
float interval = e->lerpfinish - e->lerpstart;
float time = r_realtime - e->lerpstart;
if (e->lerpflags & LERP_FINISH && numposes == 1)
lerpdata->blend = bound (0, (time) / (interval), 1);
else
lerpdata->blend = bound (0, (time) / e->lerptime, 1);
lerpdata->pose1 = e->previouspose;
lerpdata->pose2 = e->currentpose;
} else {
lerpdata->blend = 1;
lerpdata->pose1 = posenum;
lerpdata->pose2 = posenum;
}
}
static void
r_alias_lerp_transform (entity_t *e, lerpdata_t *lerpdata)
{
float blend;
vec3_t d;
int i;
if (e->lerpflags & LERP_RESETMOVE) {
// kill any lerps in progress
e->movelerpstart = 0;
VectorCopy (e->origin, e->previousorigin);
VectorCopy (e->origin, e->currentorigin);
VectorCopy (e->angles, e->previousangles);
VectorCopy (e->angles, e->currentangles);
e->lerpflags &= ~LERP_RESETMOVE;
} else if (!VectorCompare (e->origin, e->currentorigin)
|| !VectorCompare (e->angles, e->currentangles)) {
// origin/angles changed, start new lerp
e->movelerpstart = r_realtime;
VectorCopy (e->currentorigin, e->previousorigin);
VectorCopy (e->origin, e->currentorigin);
VectorCopy (e->currentangles, e->previousangles);
VectorCopy (e->angles, e->currentangles);
}
if (gl_lerp_anim->int_val /* && e != &cl.viewent */
&& e->lerpflags & LERP_MOVESTEP) {
float interval = e->lerpfinish - e->lerpstart;
float time = r_realtime - e->movelerpstart;
if (e->lerpflags & LERP_FINISH)
blend = bound (0, (time) / (interval), 1);
else
blend = bound (0, (time) / 0.1, 1);
VectorBlend (e->previousorigin, e->currentorigin, blend,
lerpdata->origin);
//FIXME use quaternions?
VectorSubtract (e->currentangles, e->previousangles, d);
for (i = 0; i < 3; i++) {
if (d[i] > 180)
d[i] -= 360;
if (d[i] < -180)
d[i] += 360;
}
VectorMultAdd (e->previousangles, blend, d, lerpdata->angles);
} else {
//don't lerp
VectorCopy (e->origin, lerpdata->origin);
VectorCopy (e->angles, lerpdata->angles);
}
}
void
R_DrawAliasModel (entity_t *e)
{
@ -516,14 +539,21 @@ R_DrawAliasModel (entity_t *e)
model_t *model;
vec3_t dist, scale;
vert_order_t *vo;
lerpdata_t lerpdata;
paliashdr = Cache_Get (&e->model->cache);
r_alais_setup_lerp (paliashdr, e, &lerpdata);
r_alias_lerp_transform (e, &lerpdata);
model = e->model;
radius = model->radius;
if (e->scale != 1.0)
radius *= e->scale;
if (R_CullSphere (e->origin, radius))
if (R_CullSphere (e->origin, radius)) {
Cache_Release (&e->model->cache);
return;
}
VectorSubtract (r_origin, e->origin, modelorg);
@ -642,7 +672,6 @@ R_DrawAliasModel (entity_t *e)
}
// locate the proper data
paliashdr = Cache_Get (&e->model->cache);
c_alias_polys += paliashdr->mdl.numtris;
// if the model has a colorised/external skin, use it, otherwise use
@ -665,11 +694,10 @@ R_DrawAliasModel (entity_t *e)
if (paliashdr->mdl.ident == HEADER_MDL16) {
VectorScale (paliashdr->mdl.scale, e->scale / 256.0, scale);
vo = GL_GetAliasFrameVerts16 (e->frame, paliashdr, e);
} else {
VectorScale (paliashdr->mdl.scale, e->scale, scale);
vo = GL_GetAliasFrameVerts (e->frame, paliashdr, e);
}
vo = GL_GetAliasFrameVerts (paliashdr, &lerpdata);
// setup the transform
qfglPushMatrix ();

View file

@ -74,7 +74,7 @@ R_GetSpriteFrame (entity_t *currententity)
frame = currententity->frame;
if ((frame >= psprite->numframes) || (frame < 0)) {
Sys_DPrintf ("R_DrawSprite: no such frame %d\n", frame);
Sys_MaskPrintf (SYS_DEV, "R_DrawSprite: no such frame %d\n", frame);
frame = 0;
}
@ -260,7 +260,8 @@ R_InitSprites (void)
#else
sVAsize = 4;
#endif
Sys_DPrintf ("Sprites: %i maximum vertex elements.\n", sVAsize);
Sys_MaskPrintf (SYS_DEV, "Sprites: %i maximum vertex elements.\n",
sVAsize);
if (spriteVertexArray)
free (spriteVertexArray);

View file

@ -807,15 +807,15 @@ R_InitFishEyeOnce (void)
if (fisheye_init_once_completed)
return 1;
Sys_DPrintf ("GL_ARB_texture_cube_map ");
Sys_MaskPrintf (SYS_DEV, "GL_ARB_texture_cube_map ");
if (QFGL_ExtensionPresent ("GL_ARB_texture_cube_map")) {
qfglGetIntegerv (GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB,
&gl_cube_map_maxtex);
Sys_DPrintf ("present, max texture size %d.\n",
(int) gl_cube_map_maxtex);
Sys_MaskPrintf (SYS_DEV, "present, max texture size %d.\n",
(int) gl_cube_map_maxtex);
gl_cube_map_capable = true;
} else {
Sys_DPrintf ("not found.\n");
Sys_MaskPrintf (SYS_DEV, "not found.\n");
gl_cube_map_capable = false;
}
fisheye_init_once_completed = true;

View file

@ -232,7 +232,7 @@ R_TimeRefresh_f (void)
stop = Sys_DoubleTime ();
time = stop - start;
Sys_DPrintf ("%f seconds (%f fps)\n", time, 128 / time);
Sys_MaskPrintf (SYS_DEV, "%f seconds (%f fps)\n", time, 128 / time);
}
VISIBLE void

View file

@ -263,9 +263,9 @@ SCR_UpdateScreen (double realtime, SCR_Func *scr_funcs)
if (r_speeds->int_val) {
// qfglFinish ();
time2 = Sys_DoubleTime ();
Sys_DPrintf ("%3i ms %4i wpoly %4i epoly %4i parts\n",
(int) ((time2 - time1) * 1000), c_brush_polys,
c_alias_polys, numparticles);
Sys_MaskPrintf (SYS_DEV, "%3i ms %4i wpoly %4i epoly %4i parts\n",
(int) ((time2 - time1) * 1000), c_brush_polys,
c_alias_polys, numparticles);
}
GL_FlushText ();

View file

@ -221,8 +221,8 @@ Skin_Do_Translation_Model (model_t *model, int skinnum, int slot, skin_t *skin)
paliashdr = Cache_Get (&model->cache);
if (skinnum < 0
|| skinnum >= paliashdr->mdl.numskins) {
Sys_DPrintf ("(%d): Invalid player skin #%d\n", slot,
skinnum);
Sys_MaskPrintf (SYS_DEV, "(%d): Invalid player skin #%d\n", slot,
skinnum);
skinnum = 0;
}
pskindesc = ((maliasskindesc_t *)

View file

@ -110,7 +110,7 @@ vec5_t skyvec[6][4] = {
}
};
void
VISIBLE void
R_LoadSkys (const char *skyname)
{
const char *name;
@ -129,11 +129,11 @@ R_LoadSkys (const char *skyname)
targa = LoadImage (name = va ("env/%s%s", skyname, suf[i]));
if (!targa || targa->format < 3) { // FIXME Can't do PCX right now
Sys_DPrintf ("Couldn't load %s\n", name);
Sys_MaskPrintf (SYS_DEV, "Couldn't load %s\n", name);
// also look in gfx/env, where Darkplaces looks for skies
targa = LoadImage (name = va ("gfx/env/%s%s", skyname, suf[i]));
if (!targa) {
Sys_DPrintf ("Couldn't load %s\n", name);
Sys_MaskPrintf (SYS_DEV, "Couldn't load %s\n", name);
skyloaded = false;
continue;
}

View file

@ -84,7 +84,7 @@ bi_Draw_CachePic (progs_t *pr)
qpic_res_t *rpic = Hash_Find (res->pic_hash, path);
if (!pic) {
Sys_DPrintf ("can't load %s\n", path);
Sys_MaskPrintf (SYS_DEV, "can't load %s\n", path);
R_INT (pr) = 0;
return;
}

View file

@ -101,7 +101,7 @@ D_ClearCacheGuard (void)
void
D_InitCaches (void *buffer, int size)
{
Sys_DPrintf ("D_InitCaches: %ik surface cache\n", size/1024);
Sys_MaskPrintf (SYS_DEV, "D_InitCaches: %ik surface cache\n", size/1024);
sc_size = size - GUARDSIZE;
sc_base = (surfcache_t *) buffer;

View file

@ -113,7 +113,7 @@ R_AliasCheckBBox (void)
frame = currententity->frame;
// TODO: don't repeat this check when drawing?
if ((frame >= pmdl->numframes) || (frame < 0)) {
Sys_DPrintf ("No such frame %d %s\n", frame, pmodel->name);
Sys_MaskPrintf (SYS_DEV, "No such frame %d %s\n", frame, pmodel->name);
frame = 0;
}
@ -558,7 +558,8 @@ R_AliasSetupSkin (void)
skinnum = currententity->skinnum;
if ((skinnum >= pmdl->numskins) || (skinnum < 0)) {
Sys_DPrintf ("R_AliasSetupSkin: no such skin # %d\n", skinnum);
Sys_MaskPrintf (SYS_DEV, "R_AliasSetupSkin: no such skin # %d\n",
skinnum);
skinnum = 0;
}
@ -651,7 +652,8 @@ R_AliasSetupFrame (void)
frame = currententity->frame;
if ((frame >= pmdl->numframes) || (frame < 0)) {
Sys_DPrintf ("R_AliasSetupFrame: no such frame %d\n", frame);
Sys_MaskPrintf (SYS_DEV, "R_AliasSetupFrame: no such frame %d\n",
frame);
frame = 0;
}

View file

@ -832,7 +832,8 @@ R_DrawParticles (void)
p->vel[2] -= grav;
break;
default:
Sys_DPrintf ("unhandled particle type %d\n", p->type);
Sys_MaskPrintf (SYS_DEV, "unhandled particle type %d\n",
p->type);
break;
}
}

View file

@ -215,12 +215,10 @@ R_SetSkyFrame (void)
/*
R_LoadSkys
Stub function for loading a skybox. Currently we have support for
skyboxes only in GL targets, so we just do nothing here. --KB
*/
void
VISIBLE void
R_LoadSkys (const char *name)
{
}

View file

@ -107,7 +107,7 @@ D_ClearCacheGuard (void)
void
D_InitCaches (void *buffer, int size)
{
Sys_DPrintf ("D_InitCaches: %ik surface cache\n", size/1024);
Sys_MaskPrintf (SYS_DEV, "D_InitCaches: %ik surface cache\n", size/1024);
sc_size = size - GUARDSIZE;
sc_base = (surfcache_t *) buffer;

View file

@ -1090,7 +1090,7 @@ Draw_FadeScreen (void)
((byte *) vid.buffer + vid.rowbytes * y);
pbuf = (unsigned short *) vid.buffer + (vid.rowbytes >> 1) * y;
for (x = 0; x < vid.conwidth; x++)
pbuf[x] = (pbuf[x] >>= 1) & 0x7BEF;
pbuf[x] = (pbuf[x] >> 1) & 0x7BEF;
}
}
break;
@ -1100,7 +1100,7 @@ Draw_FadeScreen (void)
unsigned int *pbuf = (unsigned int *)
((byte *) vid.buffer + vid.rowbytes * y);
for (x = 0; x < vid.conwidth; x++)
pbuf[x] = (pbuf[x] >>= 1) & 0x7F7F7F7F;
pbuf[x] = (pbuf[x] >> 1) & 0x7F7F7F7F;
}
}
break;

View file

@ -113,7 +113,7 @@ R_AliasCheckBBox (void)
frame = currententity->frame;
// TODO: don't repeat this check when drawing?
if ((frame >= pmdl->numframes) || (frame < 0)) {
Sys_DPrintf ("No such frame %d %s\n", frame, pmodel->name);
Sys_MaskPrintf (SYS_DEV, "No such frame %d %s\n", frame, pmodel->name);
frame = 0;
}
@ -553,7 +553,8 @@ R_AliasSetupSkin (void)
skinnum = currententity->skinnum;
if ((skinnum >= pmdl->numskins) || (skinnum < 0)) {
Sys_DPrintf ("R_AliasSetupSkin: no such skin # %d\n", skinnum);
Sys_MaskPrintf (SYS_DEV, "R_AliasSetupSkin: no such skin # %d\n",
skinnum);
skinnum = 0;
}
@ -646,7 +647,8 @@ R_AliasSetupFrame (void)
frame = currententity->frame;
if ((frame >= pmdl->numframes) || (frame < 0)) {
Sys_DPrintf ("R_AliasSetupFrame: no such frame %d\n", frame);
Sys_MaskPrintf (SYS_DEV, "R_AliasSetupFrame: no such frame %d\n",
frame);
frame = 0;
}

View file

@ -842,7 +842,8 @@ R_DrawParticles (void)
p->vel[2] -= grav;
break;
default:
Sys_DPrintf ("unhandled particle type %d\n", p->type);
Sys_MaskPrintf (SYS_DEV, "unhandled particle type %d\n",
p->type);
break;
}
}

View file

@ -216,12 +216,10 @@ R_SetSkyFrame (void)
/*
R_LoadSkys
Stub function for loading a skybox. Currently we have support for
skyboxes only in GL targets, so we just do nothing here. --KB
*/
void
VISIBLE void
R_LoadSkys (const char *name)
{
}

View file

@ -63,6 +63,7 @@ static __attribute__ ((used)) const char rcsid[] =
# include <X11/extensions/xf86vmode.h>
#endif
#include "QF/cmd.h"
#include "QF/cvar.h"
#include "QF/input.h"
#include "QF/qargs.h"
@ -103,7 +104,6 @@ static qboolean vidmode_avail = false;
static qboolean vidmode_active = false;
static qboolean vid_context_created = false;
static int window_x, window_y, window_saved;
static int pos_x, pos_y;
#ifdef HAVE_VIDMODE
@ -118,6 +118,37 @@ static int accel_numerator;
static int accel_denominator;
static int accel_threshold;
#define _NET_WM_STATE_REMOVE 0
#define _NET_WM_STATE_ADD 1
#define _NET_WM_STATE_TOGGLE 2
static Atom x_net_state;
static Atom x_net_fullscreen;
static void
set_fullscreen (int full)
{
XEvent xev;
xev.xclient.type = ClientMessage;
xev.xclient.serial = 0;
xev.xclient.send_event = True;
xev.xclient.window = x_win;
xev.xclient.message_type = x_net_state;
xev.xclient.format = 32;
if (full)
xev.xclient.data.l[0] = _NET_WM_STATE_ADD;
else
xev.xclient.data.l[0] = _NET_WM_STATE_REMOVE;
xev.xclient.data.l[1] = x_net_fullscreen;
xev.xclient.data.l[2] = 0;
xev.xclient.data.l[3] = 0;
xev.xclient.data.l[4] = 0;
XSendEvent (x_disp, x_root, False,
SubstructureRedirectMask | SubstructureNotifyMask, &xev);
}
static void
configure_notify (XEvent *event)
{
@ -128,17 +159,20 @@ configure_notify (XEvent *event)
if (vidmode_active)
X11_ForceViewPort ();
#endif
Sys_DPrintf ("ConfigureNotify: %ld %d %ld %ld %d,%d (%d,%d) %d %ld %d\n",
c->serial, c->send_event, c->event, c->window, c->x, c->y,
c->width, c->height, c->border_width, c->above,
c->override_redirect);
Sys_MaskPrintf (SYS_VID,
"ConfigureNotify: %ld %d %ld %ld %d,%d (%d,%d) "
"%d %ld %d\n",
c->serial, c->send_event, c->event, c->window, c->x, c->y,
c->width, c->height, c->border_width, c->above,
c->override_redirect);
}
qboolean
X11_AddEvent (int event, void (*event_handler) (XEvent *))
{
if (event >= LASTEvent) {
Sys_DPrintf ("event: %d, LASTEvent: %d\n", event, LASTEvent);
Sys_MaskPrintf (SYS_VID, "event: %d, LASTEvent: %d\n", event,
LASTEvent);
return false;
}
@ -232,6 +266,10 @@ X11_OpenDisplay (void)
XDisplayName (NULL));
}
x_net_state = XInternAtom (x_disp, "_NET_WM_STATE", False);
x_net_fullscreen = XInternAtom (x_disp, "_NET_WM_STATE_FULLSCREEN",
False);
x_screen = DefaultScreen (x_disp);
x_root = RootWindow (x_disp, x_screen);
@ -294,28 +332,6 @@ X11_CreateNullCursor (void)
XDefineCursor (x_disp, x_win, nullcursor);
}
static void
X11_ForceMove (int x, int y)
{
int nx, ny;
if (!vid_context_created)
return;
XMoveWindow (x_disp, x_win, x, y);
X11_WaitForEvent (ConfigureNotify);
nx = pos_x - x;
ny = pos_y - y;
if (nx == 0 || ny == 0) {
return;
}
x -= nx;
y -= ny;
XMoveWindow (x_disp, x_win, x, y);
X11_WaitForEvent (ConfigureNotify);
}
static Bool
check_mouse_event (Display *disp, XEvent *ev, XPointer arg)
{
@ -428,8 +444,8 @@ X11_SetVidMode (int width, int height)
}
if (found_mode) {
Sys_DPrintf ("VID: Chose video mode: %dx%d\n",
vid.width, vid.height);
Sys_MaskPrintf (SYS_VID, "VID: Chose video mode: %dx%d\n",
vid.width, vid.height);
XF86VidModeSwitchToMode (x_disp, x_screen,
vidmodes[best_mode]);
@ -453,35 +469,30 @@ X11_UpdateFullscreen (cvar_t *fullscreen)
if (!fullscreen->int_val) {
X11_RestoreVidMode ();
if (window_saved) {
X11_ForceMove (window_x, window_y);
window_saved = 0;
}
set_fullscreen (0);
IN_UpdateGrab (in_grab);
X11_SetMouse ();
return;
} else {
window_x = pos_x;
window_y = pos_y;
window_saved = 1;
set_fullscreen (1);
X11_SetVidMode (vid.width, vid.height);
if (!vidmode_active) {
window_saved = 0;
return;
}
X11_ForceMove (0, 0);
X11_SetMouse ();
IN_UpdateGrab (in_grab);
}
}
static void
VID_Center_f (void)
{
X11_ForceViewPort ();
}
void
X11_Init_Cvars (void)
{
Cmd_AddCommand ("vid_center", VID_Center_f, "Center the view port on the "
"quake window in a virtual desktop.\n");
vid_fullscreen = Cvar_Get ("vid_fullscreen", "0", CVAR_ARCHIVE,
&X11_UpdateFullscreen,
"Toggles fullscreen game mode");

View file

@ -55,7 +55,11 @@ static __attribute__ ((used)) const char rcsid[] =
#endif
#ifdef HAVE_VIDMODE
# include <X11/extensions/xf86vmode.h>
# include <X11/extensions/xf86vmproto.h>
# ifdef DGA_OLD_HEADERS
# include <X11/extensions/xf86vmstr.h>
# else
# include <X11/extensions/xf86vmproto.h>
# endif
#endif
#include "QF/sys.h"
@ -93,11 +97,11 @@ VID_CheckDGA (Display * dpy, int *maj_ver, int *min_ver, int *hasvideo)
}
if ((!maj_ver) || (*maj_ver != XDGA_MAJOR_VERSION)) {
Sys_DPrintf ("VID: Incorrect DGA version: %d.%d, \n", *maj_ver,
*min_ver);
Sys_MaskPrintf (SYS_VID, "VID: Incorrect DGA version: %d.%d, \n",
*maj_ver, *min_ver);
return false;
}
Sys_DPrintf ("VID: DGA version: %d.%d\n", *maj_ver, *min_ver);
Sys_MaskPrintf (SYS_VID, "VID: DGA version: %d.%d\n", *maj_ver, *min_ver);
if (!hasvideo)
hasvideo = &dummy_video;
@ -147,12 +151,13 @@ VID_CheckVMode (Display * dpy, int *maj_ver, int *min_ver)
return false;
if ((!maj_ver) || (*maj_ver != XF86VIDMODE_MAJOR_VERSION)) {
Sys_DPrintf ("VID: Incorrect VidMode version: %d.%d\n", *maj_ver,
*min_ver);
Sys_MaskPrintf (SYS_VID, "VID: Incorrect VidMode version: %d.%d\n",
*maj_ver, *min_ver);
return false;
}
Sys_DPrintf ("VID: VidMode version: %d.%d\n", *maj_ver, *min_ver);
Sys_MaskPrintf (SYS_VID, "VID: VidMode version: %d.%d\n",
*maj_ver, *min_ver);
return true;
#else
return false;

View file

@ -135,7 +135,7 @@ IN_Shutdown (void)
{
JOY_Shutdown ();
Sys_DPrintf ("IN_Shutdown\n");
Sys_MaskPrintf (SYS_VID, "IN_Shutdown\n");
IN_LL_Shutdown ();
IE_Shutdown ();

View file

@ -115,7 +115,7 @@ keyhandler (int scancode, int state)
default:
break;
}
//Sys_DPrintf ("%d %02x %02lx %04x %c\n", sc, press, shifts,
//Sys_MaskPrintf (SYS_VID, "%d %02x %02lx %04x %c\n", sc, press, shifts,
// key, ascii > 32 && ascii < 127 ? ascii : '#');
Key_Event (key, ascii, press);
}
@ -386,16 +386,17 @@ IN_InitMouse (void)
mouserate = atoi (com_argv[COM_CheckParm ("-mrate") + 1]);
}
#if 0
Sys_DPrintf ("Mouse: dev=%s,type=%s,speed=%d\n",
Sys_MaskPrintf (SYS_VID, "Mouse: dev=%s,type=%s,speed=%d\n",
mousedev, mice[mtype].name, mouserate);
#endif
//FIXME: vga_init() opens the mouse automoatically
// closing it to ensure its opened how we want it
mouse_close();
if (mouse_init ((char *)mousedev, mtype, mouserate)) {
Sys_DPrintf ("No mouse found. Check your libvga.conf mouse settings"
" and that the mouse\n"
"device has appropriate permission settings.\n");
Sys_MaskPrintf (SYS_VID,
"No mouse found. Check your libvga.conf mouse settings"
" and that the mouse\n"
"device has appropriate permission settings.\n");
UseMouse = 0;
} else {
mouse_seteventhandler ((void *) mousehandler);
@ -406,7 +407,7 @@ IN_InitMouse (void)
void
IN_LL_Shutdown (void)
{
Sys_DPrintf ("IN_LL_Shutdown\n");
Sys_MaskPrintf (SYS_VID, "IN_LL_Shutdown\n");
if (UseMouse)
mouse_close ();

View file

@ -680,8 +680,9 @@ MapKey (unsigned int keycode, int press, int *k, int *u)
break;
}
Sys_DPrintf ("%08x %d %02x %02lx %04x %c\n", keycode, press, scan, shifts,
key, uc > 32 && uc < 127 ? uc : '#');
Sys_MaskPrintf (SYS_VID, "%08x %d %02x %02lx %04x %c\n",
keycode, press, scan, shifts,
key, uc > 32 && uc < 127 ? uc : '#');
*k = key;
*u = uc;
}

View file

@ -87,15 +87,19 @@ static qboolean dga_avail;
static qboolean dga_active;
static keydest_t old_key_dest = key_none;
static int p_mouse_x, p_mouse_y;
static int input_grabbed = 0;
static void
dga_on (void)
{
#ifdef HAVE_DGA
if (dga_avail && !dga_active) {
XF86DGADirectVideo (x_disp, DefaultScreen (x_disp),
int ret;
ret = XF86DGADirectVideo (x_disp, DefaultScreen (x_disp),
XF86DGADirectMouse);
dga_active = true;
Sys_MaskPrintf (SYS_VID, "XF86DGADirectVideo returned %d\n", ret);
if (ret)
dga_active = true;
}
#endif
}
@ -105,8 +109,11 @@ dga_off (void)
{
#ifdef HAVE_DGA
if (dga_avail && dga_active) {
XF86DGADirectVideo (x_disp, DefaultScreen (x_disp), 0);
dga_active = false;
int ret;
ret = XF86DGADirectVideo (x_disp, DefaultScreen (x_disp), 0);
Sys_MaskPrintf (SYS_VID, "XF86DGADirectVideo returned %d\n", ret);
if (ret)
dga_active = false;
}
#endif
}
@ -114,12 +121,12 @@ dga_off (void)
static void
in_dga_f (cvar_t *var)
{
if (in_grab && in_grab->int_val) {
if (var->int_val) {
dga_on ();
} else {
dga_off ();
}
if (var->int_val && input_grabbed) {
Sys_MaskPrintf (SYS_VID, "VID: in_dga_f on\n");
dga_on ();
} else {
Sys_MaskPrintf (SYS_VID, "VID: in_dga_f off\n");
dga_off ();
}
}
@ -617,7 +624,7 @@ event_motion (XEvent *event)
in_mouse_x += event->xmotion.x_root;
in_mouse_y += event->xmotion.y_root;
} else {
if (vid_fullscreen->int_val || in_grab->int_val) {
if (vid_fullscreen->int_val || input_grabbed) {
if (!event->xmotion.send_event) {
unsigned dist_x = abs (vid.width / 2 - event->xmotion.x);
unsigned dist_y = abs (vid.height / 2 - event->xmotion.y);
@ -664,8 +671,6 @@ grab_error (int code, const char *device)
void
IN_LL_Grab_Input (int grab)
{
static int input_grabbed = 0;
if (!x_disp || !x_win)
return;
@ -692,14 +697,12 @@ IN_LL_Grab_Input (int grab)
return;
}
input_grabbed = 1;
if (in_dga->int_val)
dga_on ();
in_dga_f (in_dga);
} else {
XUngrabPointer (x_disp, CurrentTime);
XUngrabKeyboard (x_disp, CurrentTime);
input_grabbed = 0;
if (in_dga->int_val)
dga_off ();
in_dga_f (in_dga);
}
}
@ -712,7 +715,7 @@ IN_LL_ProcessEvents (void)
void
IN_LL_Shutdown (void)
{
Sys_DPrintf ("IN_LL_Shutdown\n");
Sys_MaskPrintf (SYS_VID, "IN_LL_Shutdown\n");
in_mouse_avail = 0;
if (x_disp) {
XAutoRepeatOn (x_disp);
@ -756,6 +759,7 @@ IN_LL_Init (void)
if (!COM_CheckParm ("-nomouse")) {
dga_avail = VID_CheckDGA (x_disp, NULL, NULL, NULL);
Sys_MaskPrintf (SYS_VID, "VID_CheckDGA returned %d\n", dga_avail);
X11_AddEvent (ButtonPress, &event_button);
X11_AddEvent (ButtonRelease, &event_button);

View file

@ -155,7 +155,7 @@ JOY_Init (void)
int i;
if (JOY_Open () == -1) {
Sys_DPrintf ("JOY: Joystick not found.\n");
Sys_MaskPrintf (SYS_VID, "JOY: Joystick not found.\n");
joy_found = false;
joy_active = false;
return;
@ -164,12 +164,12 @@ JOY_Init (void)
joy_found = true;
if (!joy_enable->int_val) {
Sys_DPrintf ("JOY: Joystick found, but not enabled.\n");
Sys_MaskPrintf (SYS_VID, "JOY: Joystick found, but not enabled.\n");
joy_active = false;
JOY_Close ();
}
Sys_DPrintf ("JOY: Joystick found and activated.\n");
Sys_MaskPrintf (SYS_VID, "JOY: Joystick found and activated.\n");
// Initialize joystick if found and enabled
for (i = 0; i < JOY_MAX_BUTTONS; i++) {

View file

@ -99,8 +99,8 @@ JOY_Close (void)
i = close (joy_handle);
if (i) {
Sys_DPrintf ("JOY: Failed to close joystick device!\n");
Sys_MaskPrintf (SYS_VID, "JOY: Failed to close joystick device!\n");
} else {
Sys_DPrintf ("JOY_Shutdown\n");
Sys_MaskPrintf (SYS_VID, "JOY_Shutdown\n");
}
}

View file

@ -71,14 +71,14 @@ QFGL_ProcAddress (void *handle, const char *name, qboolean crit)
{
void *glfunc = NULL;
Sys_DPrintf ("DEBUG: Finding symbol %s ... ", name);
Sys_MaskPrintf (SYS_VID, "DEBUG: Finding symbol %s ... ", name);
glfunc = QFGL_GetProcAddress (handle, name);
if (glfunc) {
Sys_DPrintf ("found [%p]\n", glfunc);
Sys_MaskPrintf (SYS_VID, "found [%p]\n", glfunc);
return glfunc;
}
Sys_DPrintf ("not found\n");
Sys_MaskPrintf (SYS_VID, "not found\n");
if (crit) {
if (strncmp ("fxMesa", name, 6) == 0) {

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